@robota-sdk/agent-cli 3.0.0-beta.8 → 3.0.0-beta.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +1105 -116
  3. package/bin/robota.cjs +39 -0
  4. package/dist/node/bin.js +7 -9
  5. package/dist/node/bounded-output-DpjpS98g-DFgAppgl.js +2 -0
  6. package/dist/node/bounded-output-DpjpS98g-DFgAppgl.js.map +1 -0
  7. package/dist/node/bounded-output-DpjpS98g-DoRuRGhV.js +2 -0
  8. package/dist/node/bounded-output-DpjpS98g-yPybHprY.cjs +1 -0
  9. package/dist/node/cli-core-Bah38oug.js +2795 -0
  10. package/dist/node/command-executor-DV-H2oD6-BfKoGoFw.js +2 -0
  11. package/dist/node/command-executor-DV-H2oD6-OKy8pwYH.js +2 -0
  12. package/dist/node/command-executor-DV-H2oD6-OKy8pwYH.js.map +1 -0
  13. package/dist/node/command-executor-DV-H2oD6-iQAXtTLY.cjs +1 -0
  14. package/dist/node/headless.js +4 -0
  15. package/dist/node/http-executor-cWzI2svn-C7F17ZGz.cjs +1 -0
  16. package/dist/node/http-executor-cWzI2svn-TG_TMYKh.js +2 -0
  17. package/dist/node/http-executor-cWzI2svn-TG_TMYKh.js.map +1 -0
  18. package/dist/node/http-executor-cWzI2svn-Ype0naht.js +2 -0
  19. package/dist/node/index.cjs +2782 -1345
  20. package/dist/node/index.d.cts +3408 -36
  21. package/dist/node/index.d.cts.map +1 -0
  22. package/dist/node/index.d.ts +3408 -36
  23. package/dist/node/index.d.ts.map +1 -0
  24. package/dist/node/index.js +2794 -13
  25. package/dist/node/index.js.map +1 -0
  26. package/dist/node/node-2-nrieFn.js +2 -0
  27. package/dist/node/node-2-nrieFn.js.map +1 -0
  28. package/dist/node/node-C-hnFnOP.js +67 -0
  29. package/dist/node/node-CFTax5Wl.cjs +1 -0
  30. package/dist/node/node-CJnrbkAS.js +14 -0
  31. package/dist/node/node-CJnrbkAS.js.map +1 -0
  32. package/dist/node/node-ChG9Tg1I.js +2 -0
  33. package/dist/node/node-DDl02brx.cjs +66 -0
  34. package/dist/node/node-DIRGC_1P.js +67 -0
  35. package/dist/node/node-DIRGC_1P.js.map +1 -0
  36. package/dist/node/node-OBnZskvR.cjs +1 -0
  37. package/dist/node/node-bJ0lEuNF.js +2 -0
  38. package/dist/node/node-bJ0lEuNF.js.map +1 -0
  39. package/dist/node/node-tf433Aey.cjs +13 -0
  40. package/dist/node/node-uwhEt6sT.js +14 -0
  41. package/dist/node/rolldown-runtime-C9xYM0wc.js +1 -0
  42. package/dist/node/rolldown-runtime-DK3Fl9T5-BIInC43l.cjs +1 -0
  43. package/dist/node/rolldown-runtime-DK3Fl9T5-BeX3Bzvn.js +2 -0
  44. package/dist/node/rolldown-runtime-DK3Fl9T5-DK3Fl9T5.js +2 -0
  45. package/dist/node/rolldown-runtime-DK3Fl9T5-DK3Fl9T5.js.map +1 -0
  46. package/dist/node/rolldown-runtime-rs7quPpn.js +2 -0
  47. package/dist/node/verdict-decoder-Dk_w2NG9-BKWMtxp8.js +2 -0
  48. package/dist/node/verdict-decoder-Dk_w2NG9-Bka7Cldj.js +2 -0
  49. package/dist/node/verdict-decoder-Dk_w2NG9-Bka7Cldj.js.map +1 -0
  50. package/dist/node/verdict-decoder-Dk_w2NG9-DNTeVdQ8.cjs +1 -0
  51. package/dist/web/assets/index-8_Slbxe7.css +1 -0
  52. package/dist/web/assets/index-Cgu5C1kn.js +77 -0
  53. package/dist/web/index.html +13 -0
  54. package/package.json +159 -32
  55. package/dist/node/bin.cjs +0 -1339
  56. package/dist/node/bin.d.cts +0 -1
  57. package/dist/node/bin.d.ts +0 -1
  58. package/dist/node/chunk-ICKV3U6G.js +0 -1318
@@ -0,0 +1,67 @@
1
+ ;(function(){var v=parseInt(process.versions.node.split('.')[0],10);if(v<22){process.stderr.write('\n✗ Node.js 22+ is required (current: '+process.version+')\n\nUpgrade:\n nvm: nvm install 22 && nvm use 22\n Volta: volta install node@22\n Download: https://nodejs.org/en/download\n\n');process.exit(1);}})();
2
+ import{E as e,Ft as t,V as n,bt as r,ct as i,o as a,tt as o}from"./node-uwhEt6sT.js";import{a as s,d as c,n as l,s as u,v as d}from"./bounded-output-DpjpS98g-DoRuRGhV.js";import"./command-executor-DV-H2oD6-BfKoGoFw.js";import"./http-executor-cWzI2svn-Ype0naht.js";import{spawn as f,spawnSync as p}from"node:child_process";import{accessSync as m,chmodSync as h,constants as g,cpSync as _,createReadStream as ee,existsSync as v,lstatSync as y,mkdirSync as b,readFileSync as te,readdirSync as ne,readlinkSync as re,realpathSync as x,renameSync as ie,rmSync as ae,statSync as S,symlinkSync as oe,unlinkSync as se,writeFileSync as ce}from"node:fs";import{basename as C,dirname as w,isAbsolute as T,join as E,posix as le,relative as ue,resolve as D,sep as de}from"node:path";import{randomBytes as fe,randomUUID as pe}from"node:crypto";import{chmod as me,mkdir as he,open as ge,readFile as _e,readdir as ve,rename as ye,rm as be,stat as O,writeFile as xe}from"node:fs/promises";import{homedir as Se,tmpdir as Ce}from"node:os";import{z as k}from"zod";import{lookup as we}from"node:dns/promises";import{isIP as Te}from"node:net";import Ee from"fast-glob";import De from"p-limit";import{EventEmitter as Oe}from"node:events";import{Worker as ke}from"node:worker_threads";const Ae=2e3,je=process.platform===`win32`;function A(e){return e.exitCode!==null||e.signalCode!==null}function Me(e,t,n){if(n&&!je&&typeof e.pid==`number`)try{process.kill(-e.pid,t);return}catch{}try{e.kill(t)}catch{}}function Ne(e,t){if(je&&typeof e.pid==`number`){p(`taskkill`,[`/pid`,String(e.pid),`/T`,`/F`],{stdio:`ignore`});return}Me(e,`SIGKILL`,t)}async function Pe(e,t={}){let n=t.graceMs??2e3,r=t.signal??`SIGTERM`,i=t.processGroup??!1;if(!A(e)){if(typeof e.pid!=`number`)throw Error(`[agent-process] killProcessTree called with an unspawned child (no pid)`);if(t.preKill){try{await t.preKill()}catch{}if(A(e))return}return new Promise(t=>{let a,o=()=>{a&&clearTimeout(a),t()};if(e.once(`exit`,o),A(e)){e.removeListener(`exit`,o),t();return}Me(e,r,i),a=setTimeout(()=>{A(e)||Ne(e,i)},n),a.unref?.()})}}function Fe(e){if(typeof e!=`string`)throw TypeError(`executionRoot must be a string`);if(e.trim().length===0)throw TypeError(`executionRoot must be a non-empty string`);if(!T(e))throw TypeError(`executionRoot must be an absolute path`);let t;try{t=x(e)}catch{throw TypeError(`executionRoot must name an existing accessible directory`)}if(!S(t).isDirectory())throw TypeError(`executionRoot must name a directory`);try{m(t,g.R_OK|g.X_OK)}catch{throw TypeError(`executionRoot directory must be readable and traversable`)}return t}function Ie(e){let t=[],n=D(e);for(;;)try{return E(x(n),...t)}catch{let r=w(n);if(r===n)return D(e);t.unshift(C(n)),n=r}}function Le(e,t){let n=Ie(e),r=Ie(t);return r===n||r.startsWith(n+de)}var Re=class extends Error{constructor(e){super(e),this.name=`OwnerOnlyModeError`}};function j(e=process.platform){return e===`win32`?`windows-acl`:`posix-mode`}function ze(e,t){let n=ue(e,t);if(n.startsWith(`..`)||T(n))throw new Re(`withinRoot ${e} is not an ancestor of ${t}, so this call cannot own the path between them.`);let r=n.split(de).filter(e=>e.length>0),i=[e],a=e;for(let e of r)a=E(a,e),i.push(a);return i}function M(e,t,n={}){if(j()!==`posix-mode`)return;let r=(n.readMode??(e=>S(e).mode&4095))(e);if(r&63)throw new Re(`${t} ${e} is mode 0${r.toString(8)} after being set owner-only; group or other permissions survived, so its contents are readable by another account.`)}function Be(e,t={}){let n=t.makeDirectory??((e,t)=>{b(e,{recursive:!0,mode:t})}),r=t.setMode??((e,t)=>h(e,t));n(e,448);let i=t.withinRoot===void 0?[e]:ze(t.withinRoot,e);for(let e of i)j()===`posix-mode`&&r(e,448),M(e,`directory`,t)}function Ve(e,t){Be(w(e));let n=`${e}.${process.pid}.tmp`;ae(n,{force:!0}),ce(n,t,{encoding:`utf8`,mode:384,flag:`wx`});try{M(n,`file`),ie(n,e)}catch(e){try{se(n)}catch{}throw e}M(e,`file`)}function He(e){if(j()!==`posix-mode`)return;let t;try{t=S(e).mode&4095}catch{return}t&63&&(h(e,384),M(e,`file`))}function Ue(e){let t=Te(e);return t===4?We(e.split(`.`).map(Number)):t!==6||Ge(e)}function We(e){let[t=0,n=0,r=0]=e;return t===0||t===10||t===127||t===100&&n>=64&&n<=127||t===169&&n===254||t===172&&n>=16&&n<=31||t===192&&n===0&&r===0||t===192&&n===168||t===198&&(n===18||n===19)||t>=224}function Ge(e){let t=qe(e);if(t===void 0)return!0;let[n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0]=t;return n===0&&r===0&&i===0&&a===0&&o===0&&s===65535||n===100&&r===65435&&i===0&&a===0&&o===0&&s===0?We([c>>8,c&255,l>>8,l&255]):n===0&&r===0&&i===0&&a===0&&o===0&&s===0||(n&65024)==64512||(n&65472)==65152||(n&65472)==65216||(n&65280)==65280}function Ke(e){let t=e.lastIndexOf(`:`),n=e.slice(t+1);if(!n.includes(`.`))return e;if(t<0||Te(n)!==4)return;let[r=0,i=0,a=0,o=0]=n.split(`.`).map(Number),s=(r<<8|i).toString(16),c=(a<<8|o).toString(16);return`${e.slice(0,t+1)}${s}:${c}`}function qe(e){let t=Ke(e.split(`%`)[0]??e);if(t===void 0)return;let n=t.split(`::`);if(n.length>2)return;let r=e=>e.length===0?[]:e.split(`:`).map(e=>Number.parseInt(e,16)),i=r(n[0]??``),a=n.length===2?r(n[1]??``):[],o=8-i.length-a.length;if(o<0||n.length===1&&o!==0)return;let s=[...i,...Array(o).fill(0),...a];return s.some(e=>Number.isNaN(e)||e<0||e>65535)?void 0:s}const Je=3e4,Ye=5e6,Xe=new Set([301,302,303,307,308]),Ze=new Set([`localhost`,`metadata`,`metadata.google.internal`,`metadata.goog`,`instance-data`,`instance-data.ec2.internal`]),Qe=async e=>(await we(e,{all:!0,verbatim:!0})).map(e=>e.address);async function $e(e,t={},n=Qe){let r=e.href;if(e.protocol!==`http:`&&e.protocol!==`https:`)return{reason:`unsupported_scheme`,url:r,message:`Only http(s) URLs may be fetched.`};if(t.allowPrivateAddresses===!0)return;let i=e.hostname.replace(/^\[|\]$/g,``).toLowerCase();if(t.allowedHosts?.includes(i))return;if(Ze.has(i)||i.endsWith(`.localhost`))return{reason:`metadata_host`,url:r,message:`Destination "${i}" is a loopback or cloud-metadata host and is not reachable from tools.`};let a=Te(i)?[i]:await et(i,n);if(a===void 0||a.length===0)return{reason:`unresolvable`,url:r,message:`Destination "${i}" did not resolve.`};let o=a.find(Ue);if(o!==void 0)return{reason:`private_destination`,url:r,message:`Destination "${i}" resolves to ${o}, a private, loopback or link-local address, and is not reachable from tools.`}}async function et(e,t){try{return await t(e)}catch{return}}async function tt(e,t={},n={},r={}){let i=r.fetch??((e,t)=>globalThis.fetch(e,t)),a=r.lookup??Qe,o=t.maxResponseBytes??Ye,s=n.maxRedirects??5,c=AbortSignal.timeout(t.timeoutMs??Je),l=t.signal?AbortSignal.any([c,t.signal]):c,u=new URL(e),d={...t.headers??{}};for(let e=0;;e+=1){let t=await $e(u,n,a);if(t!==void 0)return{ok:!1,rejection:t};let r=await i(u.href,{headers:d,signal:l,redirect:`manual`});if(!Xe.has(r.status))return it(r,u.href,o,l);let c=r.headers.get(`location`);if(c===null)return{ok:!1,rejection:{reason:`redirect_without_location`,url:u.href,message:`HTTP ${r.status} without a Location header.`}};if(e>=s)return{ok:!1,rejection:{reason:`redirect_limit`,url:u.href,message:`More than ${s} redirects.`}};let f=new URL(c,u);f.origin!==u.origin&&(d=rt(d)),u=f}}async function nt(e,t,n={},r={}){let i=r.fetch??((e,t)=>globalThis.fetch(e,t)),a=t.maxResponseBytes??Ye,o=AbortSignal.timeout(t.timeoutMs??Je),s=t.signal?AbortSignal.any([o,t.signal]):o,c=new URL(e),l=await $e(c,n,r.lookup??Qe);if(l!==void 0)return{ok:!1,rejection:l};let u=await i(c.href,{method:`POST`,headers:{...t.headers??{}},body:t.body,signal:s,redirect:`manual`});return u.status>=300&&u.status<400?(await u.body?.cancel().catch(()=>void 0),{ok:!1,rejection:{reason:`redirect_refused`,url:c.href,message:`HTTP ${u.status}: a POST is never redirected.`}}):it(u,c.href,a,s)}function rt(e){let t={};for(let[n,r]of Object.entries(e))n.toLowerCase()===`user-agent`&&(t[n]=r);return t}async function it(e,t,n,r){let i=e=>({ok:!1,rejection:{reason:`response_too_large`,url:t,message:`Response exceeds ${n} bytes (${e} seen).`}}),a=Number(e.headers.get(`content-length`));if(Number.isFinite(a)&&a>n)return await e.body?.cancel(),i(a);let o=[],s=0;if(!e.body&&typeof e.arrayBuffer==`function`){let t=new Uint8Array(await e.arrayBuffer());if(t.byteLength>n)return i(t.byteLength);o.push(t),s=t.byteLength}else if(e.body){let t=e.body.getReader();for(;;){r.throwIfAborted();let{done:e,value:a}=await t.read();if(e)break;if(s+=a.byteLength,s>n)return await t.cancel(),i(s);o.push(a)}}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.byteLength;return{ok:!0,status:e.status,statusText:e.statusText,headers:e.headers,body:c,finalUrl:t}}function at(e){return e===void 0?`host`:`sandbox-${e.filesystem??`separate`}`}function ot(e){return at(e)===`sandbox-separate`}function st(e){let t=[];e.environment&&Object.keys(e.environment).length>0&&t.push(`environment`);let n=e.permissions;if(n&&Object.values(n).some(e=>Array.isArray(e)?e.length>0:e!==void 0)&&t.push(`permissions`),t.length!==0)throw Error(`workspace manifest requests ${t.join(` and `)}, which this sandbox client cannot enforce. The built-in applicator applies entries only. Supply a sandbox client that implements applyManifest and honours these fields, or remove them from the manifest — they were previously accepted and silently ignored, which reported a sandbox policy that was never applied (issue #2027).`)}const ct=/^[A-Za-z]:[\\/]/,lt=/'/g;async function ut(e,t,n={}){if(e.applyManifest)return e.applyManifest(t,n);st(t);let r=xt(n.targetRoot??`/workspace`),i=[];for(let[a,o]of Object.entries(t.entries)){let t=dt(a),s=St(r,t);i.push(await ft(e,t,s,r,o,n))}return{entries:i}}function dt(e){if(e.length===0)throw Error(`workspace manifest path must not be empty`);if(e.includes(`\0`))throw Error(`workspace manifest path must not contain NUL bytes`);if(e.startsWith(`/`)||e.startsWith(`\\`)||ct.test(e))throw Error(`workspace manifest path must be workspace-relative`);let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);if(t.length===0)throw Error(`workspace manifest path must not resolve to the workspace root`);if(t.some(e=>e===`..`))throw Error(`workspace manifest path cannot contain traversal segments`);let n=t.filter(e=>e!==`.`);if(n.length===0)throw Error(`workspace manifest path must not resolve to the workspace root`);return n.join(`/`)}async function ft(e,t,n,r,i,a){switch(i.type){case`file`:return await _t(e,n,r,i.content),N(t,i.type);case`dir`:return await P(e,n),N(t,i.type);case`localFile`:return await pt(e,i.src,n,r,a),N(t,i.type);case`localDir`:return await mt(e,i.src,n,a),N(t,i.type);case`gitRepo`:return await gt(e,i,n),N(t,i.type);case`s3Mount`:case`gcsMount`:case`r2Mount`:case`azureBlobMount`:return{path:t,type:i.type,status:`unsupported`,message:`${i.type} requires a provider-specific sandbox adapter.`};default:return Ct(i)}}function N(e,t){return{path:e,type:t,status:`applied`}}async function pt(e,t,n,r,i){await _t(e,n,r,await _e(yt(t,i.hostRoot),`utf8`))}async function mt(e,t,n,r){await ht(e,yt(t,r.hostRoot),n)}async function ht(e,t,n){await P(e,n);let r=await ve(t,{withFileTypes:!0});for(let i of r){let r=E(t,i.name),a=St(n,i.name);if(i.isDirectory()){await ht(e,r,a);continue}if(i.isFile()){let t=await _e(r,`utf8`);await e.writeFile(a,t)}}}async function gt(e,t,n){await vt(e,`git clone${t.shallow===!1?``:` --depth 1`}${t.ref?` --branch ${F(t.ref)}`:``} ${F(t.url)} ${F(n)}`)}async function _t(e,t,n,r){let i=le.dirname(t);i!==n&&await P(e,i),await e.writeFile(t,r)}async function P(e,t){await vt(e,`mkdir -p ${F(t)}`)}async function vt(e,t){let n=await e.run(t);if(n.exitCode!==0)throw Error(`workspace manifest command failed: ${t}\n${n.stderr??n.stdout}`)}function yt(e,t){return T(e)?D(e):D(t??process.cwd(),e)}function bt(e){let t=e.length;for(;t>0&&e[t-1]===`/`;)--t;return e.slice(0,t)}function xt(e){let t=bt(e.replace(/\\/g,`/`));if(!t.startsWith(`/`))throw Error(`workspace manifest targetRoot must be an absolute sandbox path`);return t.length===0?`/`:t}function St(e,t){let n=xt(e);return n===`/`?`/${t}`:`${n}/${t}`}function F(e){return`'${e.replace(lt,`'\\''`)}'`}function Ct(e){throw Error(`unsupported workspace manifest entry: ${JSON.stringify(e)}`)}const I=[`.robota/worktrees`,`.claude/worktrees`];function L(e,t){let n=e.length;for(;n>0&&e[n-1]===`/`;)--n;return`${e.slice(0,n)}/${t}`}function R(){return[...i,...r]}function wt(e){let{policy:t}=e,n=[`--ro-bind`,`/`,`/`,`--dev`,`/dev`,`--proc`,`/proc`];for(let e of[t.root,...t.tempDirectories,...t.allowWrite])n.push(`--bind-try`,e,e);for(let r of R()){let i=L(t.root,r);e.exists(i)&&n.push(`--ro-bind`,i,i)}for(let r of I){let i=L(t.root,r);if(e.exists(i)){n.push(`--bind`,i,i);for(let t of e.listDirectory(i)){let r=L(i,`${t}/.git`);e.exists(r)&&n.push(`--ro-bind`,r,r)}}}for(let r of t.denyRead)e.exists(r.path)&&(r.directory?n.push(`--tmpfs`,r.path):n.push(`--ro-bind`,`/dev/null`,r.path));if(!t.network){if(e.seccompDescriptor===void 0)throw Error(`A sandbox without network needs the Unix-socket seccomp filter.`);n.push(`--unshare-net`,`--seccomp`,String(e.seccompDescriptor))}return n.push(`--unshare-pid`,`--die-with-parent`,`--new-session`,`--chdir`,e.cwd),n.push(`--`,e.command),[...n,...e.args]}function Tt(e){return e.replace(/[\\^$.*+?()[\]{}|"]/g,e=>`\\${e}`)}function z(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Et(e){let t=[e.root,...e.tempDirectories,...e.allowWrite].map(e=>`(subpath ${z(e)})`).join(` `),n=R().map(t=>{let n=L(e.root,t);return r.includes(t)?`(literal ${z(n)})`:`(subpath ${z(n)})`}),i=I.map(t=>`(subpath ${z(L(e.root,t))})`),a=[`(literal ${z(L(e.root,`.git`))})`,...I.map(t=>`(regex #"^${Tt(L(e.root,t))}/[^/]+/\\.git$")`)],o=[`(version 1)`,`(allow default)`,`(deny file-write*)`,`(allow file-write* ${t} (literal "/dev/null") (regex #"^/dev/tty") (regex #"^/dev/fd/"))`,`(deny file-write* ${n.join(` `)})`,`(allow file-write* ${i.join(` `)})`,`(deny file-write* ${a.join(` `)})`];if(e.denyRead.length>0){let t=e.denyRead.map(e=>e.directory?`(subpath ${z(e.path)})`:`(literal ${z(e.path)})`);o.push(`(deny file-read* ${t.join(` `)})`)}return e.network||o.push(`(deny network*)`),o.join(`
3
+ `)}const Dt={x64:{audit:3221225534,socket:41,ioUringSetup:425},arm64:{audit:3221225655,socket:198,ioUringSetup:425}};function B(e,t,n,r){return[e,t,n,r]}function Ot(e=process.arch){let t=Dt[e];if(t===void 0)return;let n=e=>327680|e,r=[B(32,0,0,4),B(21,1,0,t.audit),B(6,0,0,n(1)),B(32,0,0,0),B(69,0,1,1073741824),B(6,0,0,n(1)),B(21,0,1,t.ioUringSetup),B(6,0,0,n(1)),B(21,0,3,t.socket),B(32,0,0,16),B(21,0,1,1),B(6,0,0,n(97)),B(6,0,0,2147418112)],i=new Uint8Array(r.length*8),a=new DataView(i.buffer);return r.forEach(([e,t,n,r],i)=>{a.setUint16(i*8,e,!0),a.setUint8(i*8+2,t),a.setUint8(i*8+3,n),a.setUint32(i*8+4,r>>>0,!0)}),i}const kt=Object.freeze({enabled:!1,autoAllowBashIfSandboxed:!0,excludedCommands:[],allowWrite:[],denyRead:[],network:!1}),At=`/usr/bin/sandbox-exec`;function jt(e,t){let n=p(e,[...t],{timeout:5e3,encoding:`utf8`});if(n.error!==void 0)return{ok:!1,detail:n.error.message};let r=(n.stderr??``).trim().split(`
4
+ `)[0];return n.status===0?{ok:!0}:{ok:!1,...r?{detail:r}:{}}}function Mt(e={}){let t=e.platform??process.platform,n=e.probe??jt;if(t===`linux`){if(Ot(e.arch??process.arch)===void 0)return{backend:`bubblewrap`,missing:[`a seccomp filter for ${e.arch??process.arch} (x64 and arm64 are supported)`]};let t=n(`bwrap`,[`--ro-bind`,`/`,`/`,`--dev`,`/dev`,`--unshare-pid`,`true`]);return t.ok?{backend:`bubblewrap`,executable:`bwrap`,missing:[]}:{backend:`bubblewrap`,missing:[t.detail?.includes(`ENOENT`)?"bubblewrap (install the `bubblewrap` package)":`bubblewrap cannot create a sandbox here${t.detail?`: ${t.detail}`:``}`]}}if(t===`darwin`){let e=n(At,[`-p`,`(version 1)(allow default)`,`/usr/bin/true`]);return e.ok?{backend:`seatbelt`,executable:At,missing:[]}:{backend:`seatbelt`,missing:[`sandbox-exec cannot run${e.detail?`: ${e.detail}`:``}`]}}return{missing:[],unsupportedPlatform:t}}function V(e){try{return x(e)}catch{return e}}function Nt(e){try{return S(e).isDirectory()}catch{return!1}}function Pt(e){let t=y(e);if(!t.isSymbolicLink()&&(h(e,t.mode|448),t.isDirectory()))for(let t of ne(e))Pt(`${e}/${t}`)}function Ft(e){try{return y(e).isSymbolicLink()}catch{return!1}}function It(e){return e.trim().split(/\s+/)[0]}var Lt=class{filesystem=`shared`;root;availability;homeDirectory;current;inFlight=0;baseline=[];unresolved=new Map;constructor(e){this.root=V(e.root),this.availability=e.availability,this.homeDirectory=e.homeDirectory??Se(),this.current={...kt,...e.settings}}status(){return{settings:this.current,availability:this.availability,active:this.current.enabled&&this.availability.executable!==void 0}}configure(e){this.current={...this.current,...e}}confines(e){if(!this.status().active)return!1;if(a(e).length!==1)return!0;let t=It(e);return t===void 0||!this.current.excludedCommands.includes(t)}autoApproves(e){return!this.current.autoAllowBashIfSandboxed||!this.confines(e)||this.unresolved.size>0?!1:!this.protectedEntryStates().some(e=>e.kind===`symlink`&&!this.resolvesOutsideWritableWorkspace(e.path))}wrapCommand(e,t){if(!this.confines(t))return e;let n=this.policy(),r=this.availability.executable;if(this.availability.backend===`seatbelt`)return{command:r,args:[`-p`,Et(n),e.command,...e.args],cwd:e.cwd};let i=n.network?void 0:Ot();this.protectedEntryStates().some(e=>e.path.endsWith(`/.robota`)&&e.kind===`symlink`)||b(`${this.root}/.robota`,{recursive:!0});let a=wt({policy:n,exists:e=>v(e)&&!Ft(e),listDirectory:e=>ne(e),cwd:e.cwd,command:e.command,args:e.args,...i===void 0?{}:{seccompDescriptor:3}});this.inFlight===0&&(this.baseline=this.protectedEntryStates().map(e=>this.unresolved.get(e.path)??e)),this.inFlight+=1;let o=!1;return{command:r,args:a,cwd:e.cwd,...i===void 0?{}:{inputDescriptors:[i]},afterExit:()=>{if(!o)return o=!0,--this.inFlight,this.restoreProtectedEntries(this.baseline)}}}protectedEntryStates(){return R().map(e=>{let t=`${this.root}/${e}`;try{return y(t).isSymbolicLink()?{path:t,kind:`symlink`,target:re(t)}:{path:t,kind:`present`}}catch{return{path:t,kind:`missing`}}})}resolvesOutsideWritableWorkspace(e){let t;try{t=x(e)}catch{return!1}let n=this.policy();return![n.root,...n.tempDirectories,...n.allowWrite].some(e=>t===e||t.startsWith(`${e}/`))}restoreProtectedEntries(e){let t=`${this.quarantineRoot(e)}/${Date.now()}-${pe()}`,n=[];for(let r of e)if(r.kind!==`present`)try{let e=this.protectedEntryStates().find(e=>e.path===r.path);if(r.kind===`missing`&&e.kind===`missing`){this.unresolved.delete(r.path);continue}if(r.kind===`symlink`&&e.kind===`symlink`&&e.target===r.target){this.unresolved.delete(r.path);continue}e.kind!==`missing`&&n.push(this.setAside(r.path,t)),r.kind===`symlink`&&oe(r.target,r.path),this.unresolved.delete(r.path)}catch(e){this.unresolved.set(r.path,r),n.push(`could not restore ${r.path} (${e instanceof Error?e.message:String(e)}); commands will ask until it is removed`)}if(n.length!==0)return`[sandbox] A confined command may not create or replace git, agent, MCP or shell configuration: ${n.join(`; `)}.`}quarantineRoot(e){let t=`${this.root}/.robota`;return e.some(e=>e.path===t&&e.kind===`present`)?`${t}/sandbox-quarantine`:`${this.homeDirectory}/.robota/sandbox-quarantine`}setAside(e,t){let n=`${t}/${C(e)}`;b(t,{recursive:!0});try{ie(e,n)}catch(t){if(this.inFlight>0)throw t;Pt(e),t.code===`EXDEV`?(_(e,n,{recursive:!0,verbatimSymlinks:!0}),ae(e,{recursive:!0,force:!0})):ie(e,n)}return`moved ${e} to ${n}`}policy(){let e=e=>{let t=e===`~`||e.startsWith(`~/`)?`${this.homeDirectory}${e.slice(1)}`:e;return V(T(t)?t:D(this.root,t))},t=[...new Set([Ce(),`/tmp`].filter(v).map(V))];return{root:this.root,tempDirectories:t,allowWrite:this.current.allowWrite.map(e),denyRead:this.current.denyRead.map(t=>{let n=e(t);return{path:n,directory:Nt(n)}}),network:this.current.network}}run(e,t={}){let n=l(),r=t.workingDirectory??this.root,i=this.wrapCommand({command:n.command,args:n.commandArgs(e),cwd:r},e);return new Promise((e,n)=>{let r=i.inputDescriptors??[],a;try{a=f(i.command,[...i.args],{cwd:i.cwd,stdio:[`ignore`,`pipe`,`pipe`,...r.map(()=>`pipe`)],...t.timeoutMs===void 0?{}:{timeout:t.timeoutMs}})}catch(e){i.afterExit?.(),n(e instanceof Error?e:Error(String(e)));return}r.forEach((e,t)=>{let n=a.stdio[t+3];n?.on(`error`,()=>void 0),n?.end(Buffer.from(e))});let o=``,s=``;a.stdout?.on(`data`,e=>o+=e.toString()),a.stderr?.on(`data`,e=>s+=e.toString()),a.on(`error`,e=>{i.afterExit?.(),n(e)}),a.on(`close`,t=>{let n=i.afterExit?.();e({stdout:n===void 0?o:`${o}\n${n}`,...s?{stderr:s}:{},exitCode:t??1})})})}readFile(e){return Promise.resolve(te(e,`utf8`))}writeFile(e,t){return ce(e,t,`utf8`),Promise.resolve()}};function H(e,n,r,i,a={}){return new t({name:e,description:n,parameters:o(r),...a.deferLoading!==void 0&&{deferLoading:a.deferLoading}},async(e,t)=>{let n=r.safeParse(e);if(!n.success)throw new d(`Zod validation failed: ${n.error}`);let a=await i(n.data,t);return typeof a==`string`?a:JSON.stringify(a)})}const Rt={Read:{argument:{key:`filePath`,kind:`path`},riskClass:`inspect`},Glob:{argument:{key:`pattern`,kind:`text`},riskClass:`inspect`},Grep:{argument:{key:`pattern`,kind:`text`},riskClass:`inspect`},WebFetch:{argument:{key:`url`,kind:`url`},riskClass:`inspect`},WebSearch:{argument:{key:`query`,kind:`text`},riskClass:`inspect`},CodebaseRetrieval:{riskClass:`inspect`},AskUserQuestion:{riskClass:`inspect`},ToolSearch:{argument:{key:`query`,kind:`text`},riskClass:`inspect`},ComputerView:{riskClass:`inspect`},Write:{argument:{key:`filePath`,kind:`path`},riskClass:`modify`},Edit:{argument:{key:`filePath`,kind:`path`},riskClass:`modify`},Shell:{argument:{key:`command`,kind:`command`},riskClass:`execute`,aliases:[`Bash`]},Bash:{argument:{key:`command`,kind:`command`},riskClass:`execute`,aliases:[`Shell`]},Computer:{riskClass:`execute`}};function zt(){for(let[e,t]of Object.entries(Rt))n(e,t)}zt();const Bt=1e3,Vt=k.object({activeFiles:k.array(k.string()).optional().describe(`Repo-relative files currently in focus; the map is ranked toward what they reference.`),mentionedIdentifiers:k.array(k.string()).optional().describe(`Symbol names to bias the map toward (e.g. identifiers named in the task).`),tokenBudget:k.number().int().positive().optional().describe(`Maximum tokens for the returned map (default ${Bt}).`)});function Ht(e){return e.map(e=>`${e.file}:${e.line} ${e.kind} ${e.name}`).join(`
5
+ `)}async function Ut(e,t={}){if(!t.adapter)return`Codebase retrieval is not available in this session.`;let n=await t.adapter.retrieve({...e.activeFiles?{activeFiles:e.activeFiles}:{},...e.mentionedIdentifiers?{mentionedIdentifiers:e.mentionedIdentifiers}:{},tokenBudget:e.tokenBudget??Bt});return n.symbols.length===0?`No relevant symbols found within the token budget.`:`Most relevant symbols (~${n.totalTokens} tokens):\n${Ht(n.symbols)}`}function Wt(e={}){return H(`CodebaseRetrieval`,`Retrieve the most relevant slice of the codebase (a ranked repo map of symbols) for the current task, within a token budget. Provide the files you are focused on and/or identifiers named in the task; returns the highest-centrality definitions first.`,Vt,async t=>Ut(t,e))}const Gt=`Computer use is not available in this session (no driver injected).`,Kt=k.enum([`left`,`right`,`middle`]),qt=k.object({x:k.number(),y:k.number()}),Jt=k.object({type:k.enum([`click`,`double_click`,`type`,`keypress`,`scroll`,`drag`,`wait`,`takeover`]).describe(`Which action to perform.`),x:k.number().optional().describe(`X coordinate (click/double_click/scroll).`),y:k.number().optional().describe(`Y coordinate (click/double_click/scroll).`),button:Kt.optional().describe(`Mouse button (click/double_click/drag).`),text:k.string().optional().describe(`Text to type (type).`),keys:k.array(k.string()).optional().describe(`Keys to press as a chord (keypress).`),deltaX:k.number().optional().describe(`Horizontal wheel delta (scroll).`),deltaY:k.number().optional().describe(`Vertical wheel delta (scroll).`),path:k.array(qt).optional().describe(`Points to drag through (drag).`),ms:k.number().optional().describe(`Milliseconds to wait (wait).`),reason:k.string().optional().describe(`Human-readable reason surfaced to the user (takeover).`)}),Yt=k.object({action:Jt.describe(`The single mutating action to perform.`)}),Xt=k.object({});var U=class extends Error{};function W(e,t,n){if(typeof e!=`number`)throw new U(`Action '${n}' requires numeric '${t}'.`);return e}function Zt(e){let t=e.button;switch(e.type){case`click`:return{type:`click`,x:W(e.x,`x`,`click`),y:W(e.y,`y`,`click`),...t?{button:t}:{}};case`double_click`:return{type:`double_click`,x:W(e.x,`x`,`double_click`),y:W(e.y,`y`,`double_click`),...t?{button:t}:{}};case`type`:if(typeof e.text!=`string`)throw new U(`Action 'type' requires 'text'.`);return{type:`type`,text:e.text};case`keypress`:if(!e.keys||e.keys.length===0)throw new U(`Action 'keypress' requires non-empty 'keys'.`);return{type:`keypress`,keys:e.keys};case`scroll`:return{type:`scroll`,x:W(e.x,`x`,`scroll`),y:W(e.y,`y`,`scroll`),deltaX:W(e.deltaX,`deltaX`,`scroll`),deltaY:W(e.deltaY,`deltaY`,`scroll`)};case`drag`:if(!e.path||e.path.length<2)throw new U(`Action 'drag' requires a 'path' of at least two points.`);return{type:`drag`,path:e.path,...t?{button:t}:{}};case`wait`:return{type:`wait`,...typeof e.ms==`number`?{ms:e.ms}:{}};case`takeover`:return{type:`takeover`,...e.reason?{reason:e.reason}:{}};default:{let t=e.type;throw new U(`Unknown action type: ${String(t)}`)}}}async function Qt(e){if(!e.driver)return JSON.stringify({success:!1,error:Gt});let t=await e.driver.screenshot();return JSON.stringify(t?{success:!0,screenshot:t}:{success:!0,takeover:!0})}async function $t(e,t){if(!t.driver)return JSON.stringify({success:!1,error:Gt});let n;try{n=Zt(e.action)}catch(e){return JSON.stringify({success:!1,error:e instanceof Error?e.message:String(e)})}let r=await t.driver.act(n),i={success:!0,...r.screenshot?{screenshot:r.screenshot}:{},...r.takeover?{takeover:!0}:{}};return JSON.stringify(i)}function en(e={}){return H(`ComputerView`,`Perceive the computer/browser surface: capture and return a screenshot of the current screen so you can reason about what to do next. Read-only — it never changes anything.`,Xt,async()=>Qt(e))}function tn(e={}){return H(`Computer`,"Perform one mutating action on the computer/browser surface (click, double_click, type, keypress, scroll, drag, wait, or takeover) and return the resulting screenshot. Use `takeover` to hand control to the human for sensitive input (credentials/payment); perception is paused during a takeover.",Yt,async t=>$t(t,e))}function nn(e={}){return[en(e),tn(e)]}const rn=[{toolName:`Glob`,hint:` - File search: Use Glob (NOT find or ls)`},{toolName:`Grep`,hint:` - Content search: Use Grep (NOT grep or rg)`},{toolName:`Read`,hint:` - Read files: Use Read (NOT cat/head/tail)`},{toolName:`Edit`,hint:` - Edit files: Use Edit (NOT sed/awk)`}];function an(e,t){let n=t?rn.filter(e=>t.includes(e.toolName)):rn,r=n.length>0?["IMPORTANT: Avoid using this tool to run `find`, `grep`, `cat`, `head`, `tail`, `sed`, `awk`, or `echo` commands. Instead, use the appropriate dedicated tool:",...n.map(e=>e.hint)]:[];return[`Executes a command in the host shell and returns its output.`,``,`Active shell: ${e.label}. ${e.syntaxHint}`,``,`Each command runs in a fresh shell in workingDirectory (default: the configured working directory); no shell state carries over between calls.`,``,...r].join(`
6
+ `)}const G=process.platform!==`win32`,on=2e6,sn=k.object({command:k.string().describe(`The shell command to execute`),timeout:k.number().optional().describe(`Optional timeout in milliseconds (max 600000). Default is 120000 (2 minutes)`),workingDirectory:k.string().optional().describe(`Working directory for the command. Defaults to the current working directory`)});async function cn(e,t,n,r){try{let i=await r.sandboxClient.run(e,{timeoutMs:t,workingDirectory:n}),a={success:!0,output:i.stderr?`${i.stdout}\nstderr:\n${i.stderr}`:i.stdout,exitCode:i.exitCode};return JSON.stringify(a)}catch(e){let t={success:!1,output:``,error:e instanceof Error?e.message:String(e)};return JSON.stringify(t)}}async function ln(e,t,n,r,i){let{command:a,timeout:o=12e4,workingDirectory:c}=e,l=Math.min(o,6e5),d=c??t.cwd;if(d===void 0)return JSON.stringify({success:!1,output:``,error:"Shell tool has no working directory: it was constructed without a `cwd` (ARCH-010). This is an assembly bug — the tool would otherwise run in whatever directory the host process was started in."});if(t.sandboxClient&&t.sandboxClient.wrapCommand===void 0)return cn(a,l,c??t.cwd,t);let p={command:n.command,args:n.commandArgs(a),cwd:d},m=t.sandboxClient?.wrapCommand?.(p,a)??p,h=!1,g=()=>{if(!h){h=!0;try{return m.afterExit?.()}catch(e){return`[sandbox] clean-up failed: ${e instanceof Error?e.message:String(e)}`}}};return r?.aborted?(g(),JSON.stringify({success:!1,output:``,error:`Aborted before start`})):new Promise(e=>{let t=s({maxBytes:on}),n=s({maxBytes:on}),a=!1,o=!1,c;try{c=f(m.command,[...m.args],{cwd:m.cwd,env:i===void 0?process.env:u(process.env,i),stdio:[`pipe`,`pipe`,`pipe`,...(m.inputDescriptors??[]).map(()=>`pipe`)],detached:G})}catch(t){let n=g(),r=t instanceof Error?t.message:String(t);e(JSON.stringify({success:!1,output:n??``,error:r}));return}(m.inputDescriptors??[]).forEach((e,t)=>{let n=c.stdio[t+3];n?.on(`error`,()=>void 0),n?.end(Buffer.from(e))}),c.stdin?.end(),c.stdout?.on(`data`,e=>{t.append(e)}),c.stderr?.on(`data`,e=>{n.append(e)});let d=setTimeout(()=>{a=!0,Pe(c,{processGroup:G}),p({success:!1,output:t.toString(),error:`Command timed out after ${l}ms`})},l);function p(t){o||(o=!0,clearTimeout(d),r?.removeEventListener(`abort`,h),e(JSON.stringify(t)))}function h(){Pe(c,{processGroup:G}),p({success:!1,output:t.toString(),error:`Aborted`})}r?.addEventListener(`abort`,h,{once:!0}),c.on(`error`,e=>{c.pid===void 0&&g(),p({success:!1,output:``,error:e.message})}),c.on(`close`,e=>{let r=g();if(a){p({success:!1,output:t.toString(),error:`Command timed out after ${l}ms`,exitCode:e??void 0});return}let i=t.toString(),o=n.toString(),s=e??0,c=o?`${i}\nstderr:\n${o}`:i;p({success:!0,output:r===void 0?c:`${c}\n${r}`,exitCode:s})})})}function un(e,t){let n=l({executable:t.shellExecutable});return H(e,t.description??an(n,t.availableTools),sn,async(e,r)=>ln(e,t,n,r?.signal,r?.shellTraceEnv))}function dn(e){return un(`Shell`,e)}function fn(e){return un(`Bash`,e)}function K(e,t){return t!==void 0&&Le(t,e)}function pn(e,t){return t===void 0?e:D(t,e)}function q(e,t){if(t===void 0){let t={success:!1,output:``,error:`Access denied: "${e}" cannot be checked because no containment root is configured for this tool. This is an assembly bug, not a path problem — the tool was constructed without a \`cwd\`, so it has no boundary to enforce (ARCH-010).`};return JSON.stringify(t)}if(!K(e,t)){let t={success:!1,output:``,error:`Access denied: "${e}" is outside the working directory`};return JSON.stringify(t)}}function mn(e,t){if(t===void 0)return{root:``,error:q(e??``,void 0)};let n=e?D(t,e):t;return{root:n,error:q(n,t)}}const hn=2e3,J=4*1024*1024;var Y=class extends c{boundary;constructor(e){super(`Read ${e} exceeds its UTF-8 byte limit`,`Read`),this.boundary=e}},X=class extends c{constructor(){super(`Read cancelled`,`Read`)}};const gn=k.object({filePath:k.string().describe(`The absolute path to the file to read`),offset:k.number().optional().describe(`The line number to start reading from (1-based). Only provide if the file is too large to read at once`),limit:k.number().optional().describe(`The number of lines to read (default: ${hn}). Only provide if the file is too large to read at once`)});function _n(e){let t=Math.min(e.length,8192);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}function vn(e,t){let n=t+e.length-1,r=String(n).length;return e.map((e,n)=>`${String(t+n).padStart(r,` `)}\t${e}`).join(`
7
+ `)}function yn(e,t,n,r){let i=[],a=0,o=0,s=0,c=Math.trunc(n-1),l=Math.trunc(n-1+r);for(;s<t.length;){let e=t.indexOf(`
8
+ `,s),r=e===-1?t.length:e;if(o++,o>c&&o<=l){let e=t.slice(s,r);if(a+=Buffer.byteLength(e,`utf8`)+String(n+i.length).length+1,a>J)throw new Y(`output`);i.push(e)}if(e===-1)break;s=e+1}let u=i.length,d=u<o?`[File: ${e} (lines ${n}-${n+u-1} of ${o})]\n`:`[File: ${e} (${o} lines)]\n`,f=String(n+u-1).length,p=Buffer.byteLength(d,`utf8`)+Math.max(0,u-1);for(let e of i)p+=f+1+Buffer.byteLength(e,`utf8`);if(p>J)throw new Y(`output`);let m={success:!0,output:d+vn(i,n)};return JSON.stringify(m)}async function bn(e,t){if(t.signal?.aborted)throw new X;let{offset:n,limit:r=hn}=e,i=t.sandboxClient?e.filePath:pn(e.filePath,t.cwd),a=n!==void 0&&n>0?n:1;if(t.sandboxClient)try{let e=await t.sandboxClient.readFile(i);if(t.signal?.aborted)throw new X;if(Buffer.byteLength(e,`utf8`)>J)throw new Y(`input`);return yn(i,e,a,r)}catch(e){if(e instanceof Y||e instanceof X)throw e;let t={success:!1,output:``,error:e instanceof Error?e.message:String(e)};return JSON.stringify(t)}let o=q(i,t.cwd);if(o!==void 0)return o;let s;try{s=await O(i)}catch{let e={success:!1,output:``,error:`File not found: ${i}`};return JSON.stringify(e)}if(!s.isFile()){let e={success:!1,output:``,error:`Path is not a file: ${i}`};return JSON.stringify(e)}let c=Buffer.alloc(0),l=!1;try{let e=await ge(i,`r`);try{let n=[],r=Buffer.allocUnsafe(65536),i=0,a=0;for(;i<=J;){if(t.signal?.aborted)throw new X;let{bytesRead:o}=await e.read(r,0,Math.min(r.length,4194305-i),null);if(o===0)break;let s=Math.min(o,8192-a);if(s>0&&_n(r.subarray(0,s))){l=!0;break}if(a+=s,i+=o,i>J)throw new Y(`input`);n.push(Buffer.from(r.subarray(0,o)))}l||(c=Buffer.concat(n,i))}finally{await e.close()}}catch(e){if(e instanceof Y||e instanceof X)throw e;let t={success:!1,output:``,error:e instanceof Error?e.message:String(e)};return JSON.stringify(t)}if(t.signal?.aborted)throw new X;if(l){let e={success:!1,output:``,error:`Binary file not supported: ${i}`};return JSON.stringify(e)}return yn(i,c.toString(`utf8`),a,r)}function xn(e){return H(`Read`,e.description??`Reads a file from the local filesystem.
9
+
10
+ By default, reads up to 2000 lines from the beginning of the file. You can optionally specify offset and limit for partial reads.
11
+
12
+ Results are returned using cat -n format, with line numbers starting at 1.
13
+
14
+ The filePath parameter must be an absolute path, not a relative path.`,gn,async t=>bn(t,e))}function Sn(e){let t=w(e),n=C(e),r=fe(6).toString(`hex`);return E(t,`.${n}.atomic-tmp-${process.pid}-${Date.now()}-${r}`)}async function Cn(e){try{return(await O(e)).mode&4095}catch(e){if(e instanceof Error&&wn(e,`ENOENT`))return;throw e}}function wn(e,t){return`code`in e&&e.code===t}async function Tn(e,t){await he(w(e),{recursive:!0});let n=await Cn(e),r=Sn(e);try{await xe(r,t,`utf8`),n!==void 0&&await me(r,n),await ye(r,e)}catch(e){throw await be(r,{force:!0}).catch(()=>void 0),e}}const En=k.object({filePath:k.string().describe(`The absolute path to the file to write`),content:k.string().describe(`The content to write to the file`)});async function Dn(e,t){let{content:n}=e,r=t.sandboxClient?e.filePath:pn(e.filePath,t.cwd);if(!t.sandboxClient){let e=q(r,t.cwd);if(e!==void 0)return e}try{t.sandboxClient?await t.sandboxClient.writeFile(r,n):await Tn(r,n);let e={success:!0,output:`Written ${Buffer.byteLength(n,`utf8`)} bytes to ${r}`};return JSON.stringify(e)}catch(e){let t={success:!1,output:``,error:e instanceof Error?e.message:String(e)};return JSON.stringify(t)}}function On(e){return H(`Write`,e.description??`Writes a file to the local filesystem. This will overwrite an existing file if one exists.
15
+
16
+ Prefer the Edit tool for modifying existing files — it only sends the changed text. Use this tool to create new files or for complete rewrites.
17
+
18
+ Parent directories are created automatically when missing.`,En,async t=>Dn(t,e))}const kn=k.object({filePath:k.string().describe(`The absolute path to the file to modify`),oldString:k.string().describe(`The text to replace (must be an exact match of existing content)`),newString:k.string().describe(`The text to replace it with (must be different from oldString)`),replaceAll:k.boolean().optional().describe(`Replace all occurrences of oldString (default: false). Useful for renaming variables`)}),Z=4*1024*1024;var An=class extends Error{boundary;constructor(e){super(`Edit ${e} exceeds its ${Z}-byte limit`),this.boundary=e}};async function jn(e,t){let n=ee(e,{highWaterMark:65536}),r=[],i=0;try{for await(let e of n){let n=Buffer.isBuffer(e)?e:Buffer.from(e);if(i+=n.length,i>t)throw new An(`input`);r.push(n)}}finally{n.destroy()}return Buffer.concat(r,i).toString(`utf8`)}async function Mn(e,t){let{oldString:n,newString:r,replaceAll:i=!1}=e,a=t.sandboxClient?e.filePath:pn(e.filePath,t.cwd);if(!t.sandboxClient){let e=q(a,t.cwd);if(e!==void 0)return e}let o;try{if(t.sandboxClient){if(o=await t.sandboxClient.readFile(a),Buffer.byteLength(o,`utf8`)>Z)throw new An(`input`)}else o=await jn(a,Z)}catch(e){if(e instanceof An){let t={success:!1,output:``,error:`${e.message}: ${a}`};return JSON.stringify(t)}let t={success:!1,output:``,error:`File not found: ${a}`};return JSON.stringify(t)}if(!o.includes(n)){let e={success:!1,output:``,error:`oldString not found in file: ${a}`};return JSON.stringify(e)}let s=[];if(i)s=o.split(n);else if(o.indexOf(n)!==o.lastIndexOf(n)){let e={success:!1,output:``,error:`oldString is not unique in file (found ${o.split(n).length-1} occurrences). Provide more context to make it unique, or use replaceAll:true.`};return JSON.stringify(e)}let c=i?s.length-1:1,l=Buffer.byteLength(n,`utf8`),u=Buffer.byteLength(r,`utf8`);if(Buffer.byteLength(o,`utf8`)-c*l+c*u>Z){let e={success:!1,output:``,error:`Edit output exceeds its ${Z}-byte limit: ${a}`};return JSON.stringify(e)}let d=i?s.join(r):o.slice(0,o.indexOf(n))+r+o.slice(o.indexOf(n)+n.length);try{t.sandboxClient?await t.sandboxClient.writeFile(a,d):await Tn(a,d)}catch(e){let t={success:!1,output:``,error:e instanceof Error?e.message:String(e)};return JSON.stringify(t)}let f=o.indexOf(n),p=f>=0?o.substring(0,f).split(`
19
+ `).length:1,m={success:!0,output:`Replaced ${c} occurrence(s) in ${a}`,startLine:p};return JSON.stringify(m)}function Nn(e){return H(`Edit`,e.description??`Performs exact string replacements in files.
20
+
21
+ oldString must exactly match the file's current content, including whitespace and indentation — reading the file first (e.g. with a file-read tool) is the reliable way to copy exact text.
22
+
23
+ The edit will FAIL if oldString is not unique in the file. Either provide more surrounding context to make it unique, or set replaceAll to change every instance.`,kn,async t=>Mn(t,e))}const Pn=k.object({pattern:k.string().describe(`The glob pattern to match files against (e.g. "**/*.ts", "src/**/*.tsx")`),path:k.string().optional().describe(`The directory to search in. Defaults to the current working directory. Must be a valid directory path if provided`),limit:k.number().optional().describe(`Maximum number of results to return (default: 1000). Use a smaller limit to save context space`)});async function Fn(e,t,n){let r=De(100);return(await Promise.all(e.map(e=>r(async()=>{let r=D(t,e);if(K(r,n))try{return{path:e,mtime:(await O(r)).mtimeMs}}catch{return{path:e,mtime:0}}})))).filter(e=>e!==void 0).sort((e,t)=>t.mtime-e.mtime)}async function In(e,t,n){let r=[],i=!1,a=Ee.stream(e,t);for await(let e of a){if(r.length>=n){i=!0;break}r.push(e)}return{matches:r,truncated:i}}async function Ln(e,t,n=5e4){let{pattern:r,path:i}=e,a=t.cwd,{root:o,error:s}=mn(i,a);if(s)return s;let c;try{c=await In(r,{cwd:o,ignore:[`**/node_modules/**`,`**/.git/**`],dot:!0,absolute:!1,followSymbolicLinks:!1},n)}catch(e){let t={success:!1,output:``,error:e instanceof Error?e.message:String(e)};return JSON.stringify(t)}let{matches:l,truncated:u}=c,d=await Fn(l,o,a),f=e.limit??1e3,p=d.length,m=p>f,h=(m?d.slice(0,f):d).map(e=>e.path),g=h.length>0?h.join(`
24
+ `):`(no matches)`;return m&&(g+=`\n\n[Showing ${f} of ${p} matches. Use limit parameter to see more.]`),u&&(g+=`
25
+
26
+ [Candidate search stopped early; the search tree has more matches than this tool scans in one call. Results are ordered among the scanned candidates only — narrow the pattern or path to see the rest.]`),JSON.stringify({success:!0,output:g})}function Rn(e){return H(`Glob`,e.description??`Fast file pattern matching tool that works with any codebase size.
27
+
28
+ Supports glob patterns like '**/*.js' or 'src/**/*.ts'. Returns matching file paths sorted by modification time.
29
+
30
+ Use this tool when you need to find files by name patterns.
31
+
32
+ Default limit is 1000 results. Use the limit parameter if you need fewer results to save context space.`,Pn,async t=>Ln(t,e))}function zn(e){let t=e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`.+`).replace(/\*/g,`[^/]*`);return RegExp(`^${t}$`)}function Bn(e,t){return t===void 0||zn(t).test(e)}async function Vn(e,t,n,r=5e4){let i=[],a=0,o=!1;async function s(e){if(o)return;let c;try{c=await ve(e)}catch{return}for(let l of c){if(o)return;if(l===`node_modules`||l===`.git`)continue;let c=E(e,l);if(!K(c,n))continue;if(a>=r){o=!0;return}a++;let u;try{u=await O(c)}catch{continue}u.isDirectory()?await s(c):u.isFile()&&Bn(l,t)&&i.push(c)}}return await s(e),{files:i,truncated:o}}function Hn(e,t,n,r,i,a){let o=e.split(`
33
+ `),s=[];for(let e=0;e<o.length;e++)n.test(o[e])&&s.push(e);if(s.length===0)return[];if(i===`files_with_matches`)return[t];if(i===`count`)return[`${t}:${s.length}`];let c=new Set;for(let e of s)for(let t=Math.max(0,e-r);t<=Math.min(o.length-1,e+r);t++)c.add(t);let l=[],u=0,d=Array.from(c).sort((e,t)=>e-t),f,p=0;for(let e of d){f!==void 0&&e>f+1&&l.push(`--`);let n=e+1;for(;s[p]<e;)p++;let r=`${t}:${n}${s[p]===e?`:`:`-`}${o[e]}`;if(u+=Buffer.byteLength(r,`utf8`)+1,a!==void 0&&u>a)throw Error(`byte limit`);l.push(r),f=e}return l}const Un=`
34
+ const { parentPort } = require('node:worker_threads');
35
+ const searchFile = ${Hn.toString()};
36
+ let outputBytes = 0;
37
+ parentPort.on('message', (request) => {
38
+ try {
39
+ const regex = new RegExp(request.pattern);
40
+ const matches = searchFile(request.content, request.filePath, regex, request.contextLines, request.outputMode, 4 * 1024 * 1024);
41
+ let bytes = 0;
42
+ for (const match of matches) { bytes += Buffer.byteLength(match, 'utf8') + 1; if (outputBytes + bytes > 4 * 1024 * 1024) throw new Error('byte limit'); }
43
+ outputBytes += bytes;
44
+ parentPort.postMessage({ id: request.id, matches });
45
+ } catch (error) { parentPort.postMessage({ id: request.id, error: error?.message === 'byte limit' ? 'Grep search exceeded its byte limit' : 'Invalid grep regex execution' }); }
46
+ });
47
+ `;var Wn=class extends Oe{child=f(process.execPath,[`-e`,`
48
+ const searchFile = ${Hn.toString()};
49
+ const readline = require('node:readline');
50
+ let outputBytes = 0;
51
+ readline.createInterface({ input: process.stdin }).on('line', line => {
52
+ const request = JSON.parse(line);
53
+ try {
54
+ const regex = new RegExp(request.pattern);
55
+ const matches = searchFile(request.content, request.filePath, regex, request.contextLines, request.outputMode, 4 * 1024 * 1024);
56
+ let bytes = 0;
57
+ for (const match of matches) { bytes += Buffer.byteLength(match, 'utf8') + 1; if (outputBytes + bytes > 4 * 1024 * 1024) throw new Error('byte limit'); }
58
+ outputBytes += bytes;
59
+ process.stdout.write(JSON.stringify({ id: request.id, matches }) + String.fromCharCode(10));
60
+ } catch (error) { process.stdout.write(JSON.stringify({ id: request.id, error: error?.message === 'byte limit' ? 'Grep search exceeded its byte limit' : 'Invalid grep regex execution' }) + String.fromCharCode(10)); }
61
+ });
62
+ `],{env:{BUN_BE_BUN:`1`,...process.env.SystemRoot?{SystemRoot:process.env.SystemRoot}:{}},cwd:Ce(),stdio:`pipe`});closed;constructor(){super();let e=``;this.child.stdout.setEncoding(`utf8`),this.child.stdout.on(`data`,t=>{if(e+=t,Buffer.byteLength(e,`utf8`)>25166848){this.emit(`error`);return}let n;for(;(n=e.indexOf(`
63
+ `))>=0;){let t=e.slice(0,n);e=e.slice(n+1);try{this.emit(`message`,JSON.parse(t))}catch{this.emit(`error`)}}}),this.child.stderr.resume(),this.child.on(`error`,()=>this.emit(`error`)),this.child.stdin.on(`error`,()=>this.emit(`error`)),this.closed=new Promise(e=>{this.child.once(`close`,()=>{this.emit(`exit`),e()})})}postMessage(e){this.child.stdin.write(JSON.stringify(e)+`
64
+ `)}async terminate(){this.child.exitCode===null&&this.child.signalCode===null&&this.child.kill(`SIGKILL`),await this.closed}},Gn=class{pattern;signal;worker=process.versions.bun?new Wn:new ke(Un,{eval:!0,execArgv:[],resourceLimits:{maxOldGenerationSizeMb:128,maxYoungGenerationSizeMb:32}});pending=new Map;nextId=0;stopped=!1;termination;timer;abort=()=>{this.stop(Error(`Grep search cancelled`))};constructor(e,t){this.pattern=e,this.signal=t,this.worker.on(`message`,e=>{let t=this.pending.get(e.id);!t||this.stopped||(this.pending.delete(e.id),Array.isArray(e.matches)&&e.matches.every(e=>typeof e==`string`)?t.resolve(e.matches):t.reject(Error(e.error??`Invalid grep worker response`)))}),this.worker.on(`error`,()=>{this.stop(Error(`Grep search worker failed`))}),this.worker.once(`exit`,()=>{this.stop(Error(`Grep search worker exited`))}),this.timer=setTimeout(()=>{this.stop(Error(`Grep search timed out`))},2e3),t?.addEventListener(`abort`,this.abort,{once:!0}),t?.aborted&&this.abort()}search(e,t,n,r){if(this.stopped)return Promise.reject(Error(this.signal?.aborted?`Grep search cancelled`:`Grep search timed out`));let i=this.nextId++;return new Promise((a,o)=>{this.pending.set(i,{resolve:a,reject:o});try{this.worker.postMessage({id:i,content:e,filePath:t,pattern:this.pattern,contextLines:n,outputMode:r})}catch{this.stop(Error(`Grep search worker failed`))}})}async stop(e){return this.termination?this.termination:(this.stopped=!0,clearTimeout(this.timer),this.signal?.removeEventListener(`abort`,this.abort),this.termination=(async()=>{try{await this.worker.terminate()}catch{}for(let t of this.pending.values())t.reject(e??Error(`Grep search stopped`));this.pending.clear()})(),this.termination)}};const Kn=k.object({pattern:k.string().describe(`The regular expression pattern to search for in file contents`),path:k.string().optional().describe(`File or directory to search in. Defaults to the current working directory`),glob:k.string().optional().describe(`Glob pattern to filter files (e.g. "*.ts", "*.{ts,tsx}"). Only files matching this pattern will be searched`),contextLines:k.number().optional().describe(`Number of context lines to show before and after each match. Only applies when outputMode is "content". Default: 0`),outputMode:k.enum([`files_with_matches`,`content`,`count`]).optional().describe(`Output mode: "files_with_matches" shows only file paths (default), "content" shows matching lines with context, "count" shows per-file match counts`),headLimit:k.number().int().positive().optional().describe(`Maximum number of result lines (file paths, content lines, or count rows) to return. Excess results are truncated with a marker line`)}),qn=4*1024*1024;var Q=class extends c{reason;constructor(e){super(`Grep search ${e===`timeout`?`timed out`:e===`cancelled`?`cancelled`:e===`limit`?`exceeded its byte limit`:`worker failed`}`,`Grep`),this.reason=e}};async function Jn(e,t){let{pattern:n,path:r,glob:i,contextLines:a=0,outputMode:o=`files_with_matches`,headLimit:s}=e,c=t.cwd,{root:l,error:u}=mn(r,c);if(u)return u;try{new RegExp(n)}catch{let e={success:!1,output:``,error:`Invalid regex pattern: ${n}`};return JSON.stringify(e)}let d;try{d=await O(l)}catch{let e={success:!1,output:``,error:`Path not found: ${l}`};return JSON.stringify(e)}let f,p=!1;if(d.isFile())f=[l];else{let e=await Vn(l,i,c);f=e.files,p=e.truncated}let m=new Gn(n,t.signal),h=new AbortController,g=()=>h.abort();t.signal?.addEventListener(`abort`,g,{once:!0}),t.signal?.aborted&&g();let _;try{if(h.signal.aborted)throw new Q(`cancelled`);let e=Array(f.length),t=0,n,r=async e=>{let t;try{if((await O(e)).size>qn)throw new Q(`limit`);let n=ee(e,{highWaterMark:65536,signal:h.signal}),r=[],i=0;try{for await(let e of n){if(h.signal.aborted)throw new Q(`cancelled`);let t=Buffer.isBuffer(e)?e:Buffer.from(e);if(i+=t.length,i>qn)throw new Q(`limit`);r.push(t)}}finally{n.destroy()}let a=Buffer.concat(r,i),o=Math.min(a.length,8192),s=!1;for(let e=0;e<o;e++)if(a[e]===0){s=!0;break}if(s)return[];t=a.toString(`utf8`)}catch(e){if(e instanceof Q)throw e;if(h.signal.aborted)throw new Q(`cancelled`);return[]}return m.search(t,e,a,o)};if(await Promise.all(Array.from({length:Math.min(8,f.length)},async()=>{for(;n===void 0&&t<f.length;){let i=t++;try{e[i]=await r(f[i])}catch(e){n===void 0&&(n=e,h.abort(),m.stop(e instanceof Error?e:Error(`Grep search failed`)))}}})),n!==void 0)throw n;_=e}catch(e){let t=e instanceof Error?e.message:``;throw e instanceof Q?e:new Q(t.includes(`timed out`)?`timeout`:t.includes(`cancelled`)?`cancelled`:t.includes(`byte limit`)?`limit`:`failed`)}finally{t.signal?.removeEventListener(`abort`,g),await m.stop()}let v=0;for(let e of _)for(let t of e)if(v+=Buffer.byteLength(t,`utf8`)+1,v>4*1024*1024)throw new Q(`limit`);let y=_.flat();if(s!==void 0&&y.length>s){let e=y.length-s;y=[...y.slice(0,s),`(+${e} more results truncated by headLimit)`]}p&&(y=[...y,`[File enumeration stopped early; the search tree has more files than this tool scans in one call. Results may be incomplete — narrow the path or glob.]`]);let b={success:!0,output:y.length>0?y.join(`
65
+ `):`(no matches)`};return JSON.stringify(b)}function Yn(e){return`A powerful search tool built on regex matching.\n\nSupports full regex syntax (e.g., 'log.*Error', 'function\\\\s+\\\\w+'). Filter files with glob parameter (e.g., '*.js', '**/*.tsx').\n\nOutput modes: 'content' shows matching lines with context, 'files_with_matches' shows only file paths (default), 'count' shows per-file match counts.\n\nPrefer this tool over running grep or rg through the ${e} tool — it returns structured results directly.\n\nUse headLimit to control result size and save context space.`}function Xn(e){return H(`Grep`,e.description??Yn(e.shellToolName??`Shell`),Kn,async t=>Jn(t,e))}const Zn=3e4,Qn=5e6,$n=k.object({url:k.string().describe(`The URL to fetch`),headers:k.record(k.string()).optional().describe(`Optional HTTP headers as key-value pairs`)});function er(e,t){let n=`<${t}`,r=`</${t}>`,i=e.replace(/[A-Z]/g,e=>e.toLowerCase()),a=[],o=0;for(;;){let t=i.indexOf(n,o);if(t<0)break;let s=i.indexOf(r,t+n.length);if(s<0)break;a.push(e.slice(o,t)),o=s+r.length}return a.push(e.slice(o)),a.join(``)}function tr(e){let t=[],n=0;for(;;){let r=e.indexOf(`<`,n);if(r<0)break;let i=e.indexOf(`>`,r+1);if(i<0)break;if(i===r+1){t.push(e.slice(n,r+1)),n=r+1;continue}t.push(e.slice(n,r),` `),n=i+1}return t.push(e.slice(n)),t.join(``)}const nr={"&amp;":`&`,"&lt;":`<`,"&gt;":`>`,"&quot;":`"`,"&#39;":`'`,"&nbsp;":` `},rr=/&(?:amp|lt|gt|quot|nbsp|#39);/g;function ir(e){return tr(er(er(e,`script`),`style`)).replace(rr,e=>nr[e]).replace(/\s+/g,` `).trim()}function ar(e){if(!(e instanceof Error))return String(e);if(e.name===`AbortError`)return`Request timed out after ${Zn/1e3}s. The server did not respond in time.`;let t=e.code;return t===`ENOTFOUND`||t===`EAI_AGAIN`?`Network error: DNS resolution failed for this host. The URL may be incorrect or the host does not exist. Do not retry with the same URL.`:t===`ECONNREFUSED`?`Network error: Connection refused. The server is not accepting connections at this address. Do not retry with the same URL.`:t===`ECONNRESET`?`Network error: Connection was reset by the server. The server may be temporarily unavailable.`:t===`ETIMEDOUT`?`Network error: Connection timed out. The server is not reachable within the expected time.`:t===`CERT_HAS_EXPIRED`||t===`UNABLE_TO_VERIFY_LEAF_SIGNATURE`?`Network error: SSL certificate error (${t}). The server's certificate is invalid. Do not retry with the same URL.`:`Network error: ${e.message} Check that the URL is correct and the server is reachable.`}async function or(e,t,n){let{url:r,headers:i}=e;try{new URL(r)}catch{let e={success:!1,output:``,error:`Invalid URL: "${r}". Fix the URL format before retrying.`};return JSON.stringify(e)}try{let e=await tt(r,{headers:{"User-Agent":`Robota-CLI/3.0`,...i??{}},signal:n,timeoutMs:Zn,maxResponseBytes:Qn},t.policy,t.deps);if(!e.ok){let{rejection:t}=e,n={success:!1,output:``,error:t.reason===`response_too_large`?`Response too large (max ${Qn} bytes). Consider fetching a more specific URL or a paginated endpoint.`:`Blocked by egress policy: ${t.message} Do not retry with the same URL.`};return JSON.stringify(n)}if(e.status<200||e.status>=300){let t=e.status>=500?` The server is temporarily unavailable — retrying may help.`:` Do not retry with the same URL.`,n={success:!1,output:``,error:`HTTP ${e.status} ${e.statusText}.${t}`};return JSON.stringify(n)}let a=e.headers.get(`content-type`)??``,o=new TextDecoder().decode(e.body);return a.includes(`html`)&&(o=ir(o)),JSON.stringify({success:!0,output:o})}catch(e){let t={success:!1,output:``,error:ar(e)};return JSON.stringify(t)}}function sr(e={}){let t=e.egress??{};return H(`WebFetch`,e.description??`Fetch a URL and return its content as text. HTML pages are converted to plain text.`,$n,async(e,n)=>or(e,t,n?.signal))}const cr=sr();function lr(){return{async search({query:e,limit:t},n){let r=process.env.BRAVE_API_KEY;if(!r)throw Error(`Web search requires BRAVE_API_KEY environment variable for the default Brave Search provider, or inject a custom search provider at the composition root.`);let i=new URLSearchParams({q:e,count:String(Math.min(t,20))}),a=await fetch(`https://api.search.brave.com/res/v1/web/search?${i}`,{headers:{Accept:`application/json`,"Accept-Encoding":`gzip`,"X-Subscription-Token":r},...n?{signal:n}:{}});if(!a.ok)throw Error(`Brave Search API error: HTTP ${a.status} ${a.statusText}`);return((await a.json()).web?.results??[]).map(e=>({title:e.title,url:e.url,snippet:e.description}))}}}const ur=k.object({query:k.string().describe(`The search query`),limit:k.number().optional().describe(`Maximum number of results to return (default: 10)`)});async function dr(e,t,n){let{query:r,limit:i=10}=e;try{let e=new AbortController,a=setTimeout(()=>e.abort(),15e3),o=n?AbortSignal.any([e.signal,n]):e.signal;try{let e=await t.search({query:r,limit:i},o),n={success:!0,output:JSON.stringify(e,null,2)};return JSON.stringify(n)}finally{clearTimeout(a)}}catch(e){let t={success:!1,output:``,error:e instanceof Error?e.message:String(e)};return JSON.stringify(t)}}function fr(e={}){let t=e.provider??lr();return H(`WebSearch`,e.description??`Search the web and return results with title, URL, and snippet.`,ur,async(e,n)=>dr(e,t,n?.signal))}const pr=fr(),mr=k.object({question:k.string().min(1).describe(`The complete question to ask the user.`),header:k.string().optional().describe(`Very short topic label for the question (e.g. "Auth method").`),options:k.array(k.union([k.string().min(1).describe(`Display text of this choice.`),k.object({label:k.string().min(1).describe(`Display text of this choice.`),description:k.string().optional().describe(`What choosing this option means.`)})])).optional().describe(`Predefined choices (strings or {label, description}). Omit for pure free text.`),multiSelect:k.boolean().optional().describe(`Allow selecting multiple options (default: single select).`),allowFreeText:k.boolean().optional().describe(`Allow a typed custom answer besides the options (default: true).`)}),hr=k.object({questions:k.array(mr).min(1).max(4).describe(`Questions to ask the user (1-4), rendered one at a time.`)}),gr=[`Ask the user one or more structured questions and wait for their answers.`,``,`Use this when you are blocked on a decision only the user can make — ambiguous requirements,`,`mutually exclusive approaches, or choices with real trade-offs. Do not use it for decisions with`,`a conventional default or facts you can verify yourself.`,``,`Provide 1-4 questions. Each question offers predefined options and/or free text:`,` - options + default: user picks one option (or types a custom answer unless allowFreeText: false)`,` - multiSelect: true: user may pick several options`,` - no options: pure free-text entry`,``,"The result is a JSON array with one entry per question: the selected option labels in `values`","and/or the typed answer in `text`, or `cancelled: true` if the user dismissed the question.","If no interactive user is attached (headless run), the result is `{ unavailable: true }` —",`continue autonomously with your best judgment and say what you assumed.`].join(`
66
+ `);function _r(e){let t=(e.options??[]).map(e=>typeof e==`string`?{label:e}:e),n=e.multiSelect===!0&&t.length>1;return{id:`ask_${pe()}`,title:e.question,...e.header===void 0?{}:{description:e.header},...t.length>0?{options:t.map(e=>({value:e.label,label:e.label,...e.description===void 0?{}:{description:e.description}}))}:{},minSelect:+(t.length>0),maxSelect:n?t.length:1,allowFreeText:e.allowFreeText!==!1||t.length===0}}async function vr(e,t){let n=[],r=!1;for(let i of e.questions){if(r){n.push({question:i.question,cancelled:!0});continue}let e=await t(_r(i));if(e.type===`cancelled`){r=!0,n.push({question:i.question,cancelled:!0});continue}n.push({question:i.question,values:[...e.values],...e.text===void 0?{}:{text:e.text}})}return{answers:n}}function yr(e={}){return H(`AskUserQuestion`,e.description??gr,hr,async(e,t)=>{let n=e,r=t?.ask,i=r?await vr(n,r):{unavailable:!0,reason:`no interactive user attached`},a={success:!0,output:JSON.stringify(i)};return JSON.stringify(a)})}yr();const br=1/0;function $(e,t){e.description!==void 0&&t.push(e.description);for(let[n,r]of Object.entries(e.properties??{}))t.push(n),$(r,t);e.items!==void 0&&$(e.items,t);for(let n of e.anyOf??[])$(n,t)}function xr(e,t){let n=e.name.toLowerCase();if(n===t)return 0;if(n.includes(t))return 1;if(e.description.toLowerCase().includes(t))return 2;let r=[];return $(e.parameters,r),r.some(e=>e.toLowerCase().includes(t))?3:br}function Sr(e,t,n){let r=t.trim().toLowerCase();return r.length===0?[]:e.map(e=>({schema:e,rank:xr(e,r)})).filter(e=>e.rank!==br).sort((e,t)=>e.rank-t.rank||(e.schema.name<t.schema.name?-1:1)).slice(0,n).map(e=>e.schema)}const Cr=e,wr=k.object({query:k.string().optional().describe(`Text matched case-insensitively against each withheld tool's name, description, and its parameters' names and descriptions. An exact tool name is a valid query.`),names:k.array(k.string().min(1)).optional().describe(`Exact tool names to load, skipping the search. An unknown name is an error naming it.`),limit:k.number().int().positive().optional().describe(`Maximum tools to load from a query match (default 5).`)}),Tr=[`Load tools whose definitions are withheld from your tool list, so you can call them.`,``,`Some tools are deferred: they exist and are callable, but their schemas are not sent to you until`,`you load them here. If a capability you need is not in your tool list, search for it before`,`concluding it is unavailable — and if a tool call fails as "deferred and not yet loaded", load it`,`with this tool and call it again.`,``,` - query: what you are trying to do (e.g. "read a spreadsheet", "postgres"). Matched against tool`,` names, descriptions, and parameter names and descriptions. An exact tool name works too.`,` - names: load exactly these tools, skipping the search. Unknown names are an error.`,` - limit: how many matches to load (default 5).`,``,`The result lists what is now loaded; those tools appear in your tool list from your next turn and`,`stay available. A query that matches nothing returns an empty list — that is a normal answer, not`,"a failure. `unavailableSources` names any tool source that could not be consulted."].join(`
67
+ `);function Er(e){let t=e?.deferredTools;if(!t)throw Error(`${Cr} requires the deferred-tool catalog, which the execution runtime injects; it was not present, so this tool was called outside the agent execution loop.`);return t}function Dr(e,t){if(e.names!==void 0)return t.loadDeferredTools(e.names);if(e.query===void 0)throw Error(`${Cr} needs either "query" to search for tools or "names" to load exact ones.`);let n=Sr(t.listDeferredTools(),e.query,e.limit??5);return t.loadDeferredTools(n.map(e=>e.name))}function Or(e={}){return H(Cr,e.description??Tr,wr,async(e,t)=>{let n={loaded:Dr(e,Er(t)).map(({name:e,description:t})=>({name:e,description:t})),unavailableSources:[]},r={success:!0,output:JSON.stringify(n)};return JSON.stringify(r)})}Or();export{$e as A,pr as C,tt as D,j as E,Fe as M,Pe as N,nt as O,Ae as P,cr as S,Le as T,On as _,X as a,Mt as b,fn as c,Rn as d,Xn as f,Or as g,dn as h,Y as i,Ve as j,He as k,nn as l,Wt as m,Q as n,ut as o,xn as p,Lt as r,yr as s,kt as t,Nn as u,H as v,Be as w,ot as x,at as y};
@@ -0,0 +1 @@
1
+ const e=require("./node-OBnZskvR.cjs");let t=require("zod");var n=class{port;constructor(e){this.port=e.skillPort}async resolvePrompt(t){let n;try{n=this.port.loadCommands()}catch(t){return{ok:!1,error:e.S(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to load skills: ${t instanceof Error?t.message:String(t)}`,!0)}}let r=n.find(e=>e.name===t.skillName);return r?r.context===`fork`?{ok:!1,error:e.C(`DAG_VALIDATION_SKILL_FORK_UNSUPPORTED`,`Skill "${t.skillName}" uses fork context, which the resolver node does not support (no subagent runtime). Use an inject-context skill.`,{skillName:t.skillName})}:this.resolveInject(r,t):{ok:!1,error:e.C(`DAG_VALIDATION_SKILL_NOT_FOUND`,`Skill "${t.skillName}" was not found in the injected contribution sources`,{skillName:t.skillName},{action:`set_config`,suggestion:`Set skillName to an available skill`,options:n.map(e=>e.name)})}}async resolveInject(t,n){try{let r=await this.port.resolveSkill(t,n.args,n.sessionId===void 0?void 0:{sessionId:n.sessionId});return typeof r.prompt==`string`?{ok:!0,value:{prompt:r.prompt,mode:r.mode}}:{ok:!1,error:e.S(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Skill "${n.skillName}" did not resolve to an inject prompt`,!1,{skillName:n.skillName,mode:r.mode})}}catch(t){let r=t instanceof Error?t.message:String(t);return{ok:!1,error:e.S(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to resolve skill "${n.skillName}": ${r}`,!1,{skillName:n.skillName})}}}};const r=t.z.object({skillName:t.z.string().min(1),args:t.z.string().default(``),sessionId:t.z.string().optional(),baseCredits:t.z.number().nonnegative().default(0)}),i=[{key:`args`,label:`Args`,order:0,type:`string`,required:!1}],a=[{key:`prompt`,label:`Prompt`,order:0,type:`string`,required:!0},{key:`mode`,label:`Mode`,order:1,type:`string`,required:!0}];var o=class extends e.t{nodeType=`skill`;displayName=`Skill`;category=`Integration`;inputs=i;outputs=a;configSchemaDefinition=r;defaultInputPort=`args`;defaultOutputPort=`prompt`;runtime;constructor(e){super(),this.runtime=new n(e)}async estimateCostWithConfig(e,t,n){return{ok:!0,value:{estimatedCredits:n.baseCredits}}}async executeWithConfig(t,n,r){let i=new e.i(t,n.nodeDefinition.nodeId),a=i.getInput(`args`),o=typeof a==`string`&&a.trim().length>0?a:r.args,s=await this.runtime.resolvePrompt({skillName:r.skillName,args:o,...r.sessionId===void 0?{}:{sessionId:r.sessionId}});return s.ok?s.value.prompt.trim().length===0?{ok:!1,error:e.C(`DAG_VALIDATION_SKILL_EMPTY_PROMPT`,`Skill "${r.skillName}" resolved to an empty prompt`,{skillName:r.skillName})}:(i.setOutput(`prompt`,s.value.prompt),i.setOutput(`mode`,s.value.mode),i.setOutput(`_agentSummary`,`Skill "${r.skillName}" resolved (${s.value.mode}): ${s.value.prompt.length} chars.`),{ok:!0,value:i.toOutput()}):s}};exports.SkillNodeDefinition=o;