@robota-sdk/agent-cli 3.0.0-beta.82 → 3.0.0-beta.83

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 (135) hide show
  1. package/CHANGELOG.md +2478 -0
  2. package/README.md +70 -18
  3. package/dist/node/bin.js +33 -2
  4. package/dist/node/cli-core-CfQhvbx3.js +2850 -0
  5. package/dist/node/headless.js +2 -2
  6. package/dist/node/index.d.ts +106 -13
  7. package/dist/node/index.d.ts.map +1 -1
  8. package/dist/node/index.js +394 -311
  9. package/dist/node/index.js.map +1 -1
  10. package/dist/node/{node-cmTHiSYe.js → node-B8BhZ3NW.js} +1 -1
  11. package/dist/node/{node-bJ0lEuNF.js → node-C4_FOvnk.js} +2 -2
  12. package/dist/node/{node-bJ0lEuNF.js.map → node-C4_FOvnk.js.map} +1 -1
  13. package/dist/node/{node-hHzxDyjn.js → node-CC5tfdMu.js} +17 -17
  14. package/dist/node/node-CC5tfdMu.js.map +1 -0
  15. package/dist/node/{node-Bs1jlR4B.js → node-CsbnL0Yf.js} +4 -4
  16. package/dist/node/{node-2-nrieFn.js → node-DENLEmMT.js} +2 -2
  17. package/dist/node/{node-2-nrieFn.js.map → node-DENLEmMT.js.map} +1 -1
  18. package/dist/node/node-DtKU0MUr.js +14 -0
  19. package/dist/node/node-DtKU0MUr.js.map +1 -0
  20. package/dist/node/node-j7KM8r3b.js +14 -0
  21. package/dist/web/assets/PretendardVariable.subset.0-BHUkWNFR.woff2 +0 -0
  22. package/dist/web/assets/PretendardVariable.subset.1-C-__qv6_.woff2 +0 -0
  23. package/dist/web/assets/PretendardVariable.subset.10-DzSWztS8.woff2 +0 -0
  24. package/dist/web/assets/PretendardVariable.subset.11-CqVmlKJn.woff2 +0 -0
  25. package/dist/web/assets/PretendardVariable.subset.12-BHuZSgT0.woff2 +0 -0
  26. package/dist/web/assets/PretendardVariable.subset.13-C42mj_j2.woff2 +0 -0
  27. package/dist/web/assets/PretendardVariable.subset.14-Bl512uUX.woff2 +0 -0
  28. package/dist/web/assets/PretendardVariable.subset.15-D04iXIE3.woff2 +0 -0
  29. package/dist/web/assets/PretendardVariable.subset.16-BQUnS2GX.woff2 +0 -0
  30. package/dist/web/assets/PretendardVariable.subset.17-BfZSA-Xc.woff2 +0 -0
  31. package/dist/web/assets/PretendardVariable.subset.18-CwAxMC3C.woff2 +0 -0
  32. package/dist/web/assets/PretendardVariable.subset.19-CJu4Zcdo.woff2 +0 -0
  33. package/dist/web/assets/PretendardVariable.subset.2-dCZkyKLw.woff2 +0 -0
  34. package/dist/web/assets/PretendardVariable.subset.20-Ig1-z3n5.woff2 +0 -0
  35. package/dist/web/assets/PretendardVariable.subset.21-yKPEdLXC.woff2 +0 -0
  36. package/dist/web/assets/PretendardVariable.subset.22-CSqxKoOs.woff2 +0 -0
  37. package/dist/web/assets/PretendardVariable.subset.23-DK80wi0t.woff2 +0 -0
  38. package/dist/web/assets/PretendardVariable.subset.24-CmkE8Q8D.woff2 +0 -0
  39. package/dist/web/assets/PretendardVariable.subset.25-CsoWBIZB.woff2 +0 -0
  40. package/dist/web/assets/PretendardVariable.subset.26-Sozl8dw8.woff2 +0 -0
  41. package/dist/web/assets/PretendardVariable.subset.27-CT6nuW9L.woff2 +0 -0
  42. package/dist/web/assets/PretendardVariable.subset.28-CpO0Y96p.woff2 +0 -0
  43. package/dist/web/assets/PretendardVariable.subset.29-D6hjrUWm.woff2 +0 -0
  44. package/dist/web/assets/PretendardVariable.subset.3-Dqw33sf4.woff2 +0 -0
  45. package/dist/web/assets/PretendardVariable.subset.30-CWDM1c0J.woff2 +0 -0
  46. package/dist/web/assets/PretendardVariable.subset.31-CdmyZ5mm.woff2 +0 -0
  47. package/dist/web/assets/PretendardVariable.subset.32-CGnFWD2i.woff2 +0 -0
  48. package/dist/web/assets/PretendardVariable.subset.33--0OT__YQ.woff2 +0 -0
  49. package/dist/web/assets/PretendardVariable.subset.34-CaCS33Md.woff2 +0 -0
  50. package/dist/web/assets/PretendardVariable.subset.35-DWFYRGLp.woff2 +0 -0
  51. package/dist/web/assets/PretendardVariable.subset.36-Dn5IBRQB.woff2 +0 -0
  52. package/dist/web/assets/PretendardVariable.subset.37-BD6FyOtY.woff2 +0 -0
  53. package/dist/web/assets/PretendardVariable.subset.38-D4hu443z.woff2 +0 -0
  54. package/dist/web/assets/PretendardVariable.subset.39-B_7wfth9.woff2 +0 -0
  55. package/dist/web/assets/PretendardVariable.subset.4-Bvh2YGoc.woff2 +0 -0
  56. package/dist/web/assets/PretendardVariable.subset.40-BDaOfdUe.woff2 +0 -0
  57. package/dist/web/assets/PretendardVariable.subset.41-BUACvzZC.woff2 +0 -0
  58. package/dist/web/assets/PretendardVariable.subset.42-Dp-5mnyL.woff2 +0 -0
  59. package/dist/web/assets/PretendardVariable.subset.43-DHdpry7N.woff2 +0 -0
  60. package/dist/web/assets/PretendardVariable.subset.44-qHopVhdd.woff2 +0 -0
  61. package/dist/web/assets/PretendardVariable.subset.45-BniyRFfm.woff2 +0 -0
  62. package/dist/web/assets/PretendardVariable.subset.46-BMRq7xC-.woff2 +0 -0
  63. package/dist/web/assets/PretendardVariable.subset.47-B-cWO2pw.woff2 +0 -0
  64. package/dist/web/assets/PretendardVariable.subset.48-Ct-fWrPO.woff2 +0 -0
  65. package/dist/web/assets/PretendardVariable.subset.49-BblQVys9.woff2 +0 -0
  66. package/dist/web/assets/PretendardVariable.subset.5-K_MNGNCe.woff2 +0 -0
  67. package/dist/web/assets/PretendardVariable.subset.50-C8IyFH7L.woff2 +0 -0
  68. package/dist/web/assets/PretendardVariable.subset.51-Bxd0gTAs.woff2 +0 -0
  69. package/dist/web/assets/PretendardVariable.subset.52-CNgqKOOJ.woff2 +0 -0
  70. package/dist/web/assets/PretendardVariable.subset.53-BSRnyb-u.woff2 +0 -0
  71. package/dist/web/assets/PretendardVariable.subset.54-Dt2-cQkx.woff2 +0 -0
  72. package/dist/web/assets/PretendardVariable.subset.55-jFgflYjX.woff2 +0 -0
  73. package/dist/web/assets/PretendardVariable.subset.56-BwZdvJZQ.woff2 +0 -0
  74. package/dist/web/assets/PretendardVariable.subset.57-BwFDg-Fs.woff2 +0 -0
  75. package/dist/web/assets/PretendardVariable.subset.58-DlucQts_.woff2 +0 -0
  76. package/dist/web/assets/PretendardVariable.subset.59-CMkWjhdo.woff2 +0 -0
  77. package/dist/web/assets/PretendardVariable.subset.6-Bxhohlcm.woff2 +0 -0
  78. package/dist/web/assets/PretendardVariable.subset.60-CeHezjjf.woff2 +0 -0
  79. package/dist/web/assets/PretendardVariable.subset.61-PUuTnod4.woff2 +0 -0
  80. package/dist/web/assets/PretendardVariable.subset.62-DGSAWCfb.woff2 +0 -0
  81. package/dist/web/assets/PretendardVariable.subset.63-B35xsm4O.woff2 +0 -0
  82. package/dist/web/assets/PretendardVariable.subset.64-CTbrgYF9.woff2 +0 -0
  83. package/dist/web/assets/PretendardVariable.subset.65-B66rjuyf.woff2 +0 -0
  84. package/dist/web/assets/PretendardVariable.subset.66-C3HqaDeY.woff2 +0 -0
  85. package/dist/web/assets/PretendardVariable.subset.67-BmuXdlDy.woff2 +0 -0
  86. package/dist/web/assets/PretendardVariable.subset.68-DS9B48d0.woff2 +0 -0
  87. package/dist/web/assets/PretendardVariable.subset.69-YT16ymcp.woff2 +0 -0
  88. package/dist/web/assets/PretendardVariable.subset.7-E2HaA55t.woff2 +0 -0
  89. package/dist/web/assets/PretendardVariable.subset.70-BUXiAGMT.woff2 +0 -0
  90. package/dist/web/assets/PretendardVariable.subset.71-DuPZj8us.woff2 +0 -0
  91. package/dist/web/assets/PretendardVariable.subset.72-pYYGrEQR.woff2 +0 -0
  92. package/dist/web/assets/PretendardVariable.subset.73-DMrK970F.woff2 +0 -0
  93. package/dist/web/assets/PretendardVariable.subset.74-D4tQnymK.woff2 +0 -0
  94. package/dist/web/assets/PretendardVariable.subset.75-CxKdrRNf.woff2 +0 -0
  95. package/dist/web/assets/PretendardVariable.subset.76-DhPm2b_q.woff2 +0 -0
  96. package/dist/web/assets/PretendardVariable.subset.77-DwaxqOC8.woff2 +0 -0
  97. package/dist/web/assets/PretendardVariable.subset.78-DhqRbBzT.woff2 +0 -0
  98. package/dist/web/assets/PretendardVariable.subset.79-XpoyPP38.woff2 +0 -0
  99. package/dist/web/assets/PretendardVariable.subset.8-CRbJhhyA.woff2 +0 -0
  100. package/dist/web/assets/PretendardVariable.subset.80-DsV9Qp_h.woff2 +0 -0
  101. package/dist/web/assets/PretendardVariable.subset.81-BZzF9Hb3.woff2 +0 -0
  102. package/dist/web/assets/PretendardVariable.subset.82-BgAHe30u.woff2 +0 -0
  103. package/dist/web/assets/PretendardVariable.subset.83-DF-zBLLe.woff2 +0 -0
  104. package/dist/web/assets/PretendardVariable.subset.84-Brb8EsYQ.woff2 +0 -0
  105. package/dist/web/assets/PretendardVariable.subset.85-Byo_x2hf.woff2 +0 -0
  106. package/dist/web/assets/PretendardVariable.subset.86-XG7lTN_6.woff2 +0 -0
  107. package/dist/web/assets/PretendardVariable.subset.87-Lzui2vbK.woff2 +0 -0
  108. package/dist/web/assets/PretendardVariable.subset.88-CqX6JSgh.woff2 +0 -0
  109. package/dist/web/assets/PretendardVariable.subset.89-DOzqWPpX.woff2 +0 -0
  110. package/dist/web/assets/PretendardVariable.subset.9-Btb3bmS6.woff2 +0 -0
  111. package/dist/web/assets/PretendardVariable.subset.90-BF7RiZjm.woff2 +0 -0
  112. package/dist/web/assets/PretendardVariable.subset.91-Csm0YNoH.woff2 +0 -0
  113. package/dist/web/assets/index-DbAewVPM.js +244 -0
  114. package/dist/web/assets/index-DzQQd7ql.css +1 -0
  115. package/dist/web/index.html +6 -4
  116. package/package.json +39 -44
  117. package/dist/node/bounded-output-DpjpS98g-yPybHprY.cjs +0 -1
  118. package/dist/node/cli-core-DWG6gqoq.js +0 -2798
  119. package/dist/node/command-executor-DV-H2oD6-BAvcn7Tf.cjs +0 -1
  120. package/dist/node/http-executor-cWzI2svn-Nn7UFLl8.cjs +0 -1
  121. package/dist/node/index.cjs +0 -2796
  122. package/dist/node/index.d.cts +0 -3445
  123. package/dist/node/index.d.cts.map +0 -1
  124. package/dist/node/node-CFTax5Wl.cjs +0 -1
  125. package/dist/node/node-CQqDd5KI.js +0 -14
  126. package/dist/node/node-CQqDd5KI.js.map +0 -1
  127. package/dist/node/node-D8uo8Kzf.cjs +0 -13
  128. package/dist/node/node-DE_LpiDk.cjs +0 -66
  129. package/dist/node/node-Du_7g6qW.js +0 -14
  130. package/dist/node/node-OBnZskvR.cjs +0 -1
  131. package/dist/node/node-hHzxDyjn.js.map +0 -1
  132. package/dist/node/rolldown-runtime-DK3Fl9T5-BIInC43l.cjs +0 -1
  133. package/dist/node/verdict-decoder-Dk_w2NG9-DNTeVdQ8.cjs +0 -1
  134. package/dist/web/assets/index-8_Slbxe7.css +0 -1
  135. package/dist/web/assets/index-Cgu5C1kn.js +0 -77
@@ -1,2 +1,2 @@
1
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{a as e,i as t,n,r}from"./cli-core-DWG6gqoq.js";import{z as i}from"zod";var a=class{port;constructor(e){this.port=e.skillPort}async resolvePrompt(n){let r;try{r=this.port.loadCommands()}catch(e){return{ok:!1,error:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to load skills: ${e instanceof Error?e.message:String(e)}`,!0)}}let i=r.find(e=>e.name===n.skillName);return i?i.context===`fork`?{ok:!1,error:e(`DAG_VALIDATION_SKILL_FORK_UNSUPPORTED`,`Skill "${n.skillName}" uses fork context, which the resolver node does not support (no subagent runtime). Use an inject-context skill.`,{skillName:n.skillName})}:this.resolveInject(i,n):{ok:!1,error:e(`DAG_VALIDATION_SKILL_NOT_FOUND`,`Skill "${n.skillName}" was not found in the injected contribution sources`,{skillName:n.skillName},{action:`set_config`,suggestion:`Set skillName to an available skill`,options:r.map(e=>e.name)})}}async resolveInject(e,n){try{let r=await this.port.resolveSkill(e,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:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Skill "${n.skillName}" did not resolve to an inject prompt`,!1,{skillName:n.skillName,mode:r.mode})}}catch(e){let r=e instanceof Error?e.message:String(e);return{ok:!1,error:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to resolve skill "${n.skillName}": ${r}`,!1,{skillName:n.skillName})}}}};const o=i.object({skillName:i.string().min(1),args:i.string().default(``),sessionId:i.string().optional(),baseCredits:i.number().nonnegative().default(0)}),s=[{key:`args`,label:`Args`,order:0,type:`string`,required:!1}],c=[{key:`prompt`,label:`Prompt`,order:0,type:`string`,required:!0},{key:`mode`,label:`Mode`,order:1,type:`string`,required:!0}];var l=class extends n{nodeType=`skill`;displayName=`Skill`;category=`Integration`;inputs=s;outputs=c;configSchemaDefinition=o;defaultInputPort=`args`;defaultOutputPort=`prompt`;runtime;constructor(e){super(),this.runtime=new a(e)}async estimateCostWithConfig(e,t,n){return{ok:!0,value:{estimatedCredits:n.baseCredits}}}async executeWithConfig(t,n,i){let a=new r(t,n.nodeDefinition.nodeId),o=a.getInput(`args`),s=typeof o==`string`&&o.trim().length>0?o:i.args,c=await this.runtime.resolvePrompt({skillName:i.skillName,args:s,...i.sessionId===void 0?{}:{sessionId:i.sessionId}});return c.ok?c.value.prompt.trim().length===0?{ok:!1,error:e(`DAG_VALIDATION_SKILL_EMPTY_PROMPT`,`Skill "${i.skillName}" resolved to an empty prompt`,{skillName:i.skillName})}:(a.setOutput(`prompt`,c.value.prompt),a.setOutput(`mode`,c.value.mode),a.setOutput(`_agentSummary`,`Skill "${i.skillName}" resolved (${c.value.mode}): ${c.value.prompt.length} chars.`),{ok:!0,value:a.toOutput()}):c}};export{l as SkillNodeDefinition};
2
+ import{a as e,i as t,n,r}from"./cli-core-CfQhvbx3.js";import{z as i}from"zod";var a=class{port;constructor(e){this.port=e.skillPort}async resolvePrompt(n){let r;try{r=this.port.loadCommands()}catch(e){return{ok:!1,error:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to load skills: ${e instanceof Error?e.message:String(e)}`,!0)}}let i=r.find(e=>e.name===n.skillName);return i?i.context===`fork`?{ok:!1,error:e(`DAG_VALIDATION_SKILL_FORK_UNSUPPORTED`,`Skill "${n.skillName}" uses fork context, which the resolver node does not support (no subagent runtime). Use an inject-context skill.`,{skillName:n.skillName})}:this.resolveInject(i,n):{ok:!1,error:e(`DAG_VALIDATION_SKILL_NOT_FOUND`,`Skill "${n.skillName}" was not found in the injected contribution sources`,{skillName:n.skillName},{action:`set_config`,suggestion:`Set skillName to an available skill`,options:r.map(e=>e.name)})}}async resolveInject(e,n){try{let r=await this.port.resolveSkill(e,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:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Skill "${n.skillName}" did not resolve to an inject prompt`,!1,{skillName:n.skillName,mode:r.mode})}}catch(e){let r=e instanceof Error?e.message:String(e);return{ok:!1,error:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to resolve skill "${n.skillName}": ${r}`,!1,{skillName:n.skillName})}}}};const o=i.object({skillName:i.string().min(1),args:i.string().default(``),sessionId:i.string().optional(),baseCredits:i.number().nonnegative().default(0)}),s=[{key:`args`,label:`Args`,order:0,type:`string`,required:!1}],c=[{key:`prompt`,label:`Prompt`,order:0,type:`string`,required:!0},{key:`mode`,label:`Mode`,order:1,type:`string`,required:!0}];var l=class extends n{nodeType=`skill`;displayName=`Skill`;category=`Integration`;inputs=s;outputs=c;configSchemaDefinition=o;defaultInputPort=`args`;defaultOutputPort=`prompt`;runtime;constructor(e){super(),this.runtime=new a(e)}async estimateCostWithConfig(e,t,n){return{ok:!0,value:{estimatedCredits:n.baseCredits}}}async executeWithConfig(t,n,i){let a=new r(t,n.nodeDefinition.nodeId),o=a.getInput(`args`),s=typeof o==`string`&&o.trim().length>0?o:i.args,c=await this.runtime.resolvePrompt({skillName:i.skillName,args:s,...i.sessionId===void 0?{}:{sessionId:i.sessionId}});return c.ok?c.value.prompt.trim().length===0?{ok:!1,error:e(`DAG_VALIDATION_SKILL_EMPTY_PROMPT`,`Skill "${i.skillName}" resolved to an empty prompt`,{skillName:i.skillName})}:(a.setOutput(`prompt`,c.value.prompt),a.setOutput(`mode`,c.value.mode),a.setOutput(`_agentSummary`,`Skill "${i.skillName}" resolved (${c.value.mode}): ${c.value.prompt.length} chars.`),{ok:!0,value:a.toOutput()}):c}};export{l as SkillNodeDefinition};
@@ -1,2 +1,2 @@
1
- import{C as e,S as t,i as n,t as r}from"./node-2-nrieFn.js";import{z as i}from"zod";var a=class{port;constructor(e){this.port=e.skillPort}async resolvePrompt(n){let r;try{r=this.port.loadCommands()}catch(e){return{ok:!1,error:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to load skills: ${e instanceof Error?e.message:String(e)}`,!0)}}let i=r.find(e=>e.name===n.skillName);return i?i.context===`fork`?{ok:!1,error:e(`DAG_VALIDATION_SKILL_FORK_UNSUPPORTED`,`Skill "${n.skillName}" uses fork context, which the resolver node does not support (no subagent runtime). Use an inject-context skill.`,{skillName:n.skillName})}:this.resolveInject(i,n):{ok:!1,error:e(`DAG_VALIDATION_SKILL_NOT_FOUND`,`Skill "${n.skillName}" was not found in the injected contribution sources`,{skillName:n.skillName},{action:`set_config`,suggestion:`Set skillName to an available skill`,options:r.map(e=>e.name)})}}async resolveInject(e,n){try{let r=await this.port.resolveSkill(e,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:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Skill "${n.skillName}" did not resolve to an inject prompt`,!1,{skillName:n.skillName,mode:r.mode})}}catch(e){let r=e instanceof Error?e.message:String(e);return{ok:!1,error:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to resolve skill "${n.skillName}": ${r}`,!1,{skillName:n.skillName})}}}};const o=i.object({skillName:i.string().min(1),args:i.string().default(``),sessionId:i.string().optional(),baseCredits:i.number().nonnegative().default(0)}),s=[{key:`args`,label:`Args`,order:0,type:`string`,required:!1}],c=[{key:`prompt`,label:`Prompt`,order:0,type:`string`,required:!0},{key:`mode`,label:`Mode`,order:1,type:`string`,required:!0}];var l=class extends r{nodeType=`skill`;displayName=`Skill`;category=`Integration`;inputs=s;outputs=c;configSchemaDefinition=o;defaultInputPort=`args`;defaultOutputPort=`prompt`;runtime;constructor(e){super(),this.runtime=new a(e)}async estimateCostWithConfig(e,t,n){return{ok:!0,value:{estimatedCredits:n.baseCredits}}}async executeWithConfig(t,r,i){let a=new n(t,r.nodeDefinition.nodeId),o=a.getInput(`args`),s=typeof o==`string`&&o.trim().length>0?o:i.args,c=await this.runtime.resolvePrompt({skillName:i.skillName,args:s,...i.sessionId===void 0?{}:{sessionId:i.sessionId}});return c.ok?c.value.prompt.trim().length===0?{ok:!1,error:e(`DAG_VALIDATION_SKILL_EMPTY_PROMPT`,`Skill "${i.skillName}" resolved to an empty prompt`,{skillName:i.skillName})}:(a.setOutput(`prompt`,c.value.prompt),a.setOutput(`mode`,c.value.mode),a.setOutput(`_agentSummary`,`Skill "${i.skillName}" resolved (${c.value.mode}): ${c.value.prompt.length} chars.`),{ok:!0,value:a.toOutput()}):c}};export{l as SkillNodeDefinition};
2
- //# sourceMappingURL=node-bJ0lEuNF.js.map
1
+ import{C as e,S as t,i as n,t as r}from"./node-DENLEmMT.js";import{z as i}from"zod";var a=class{port;constructor(e){this.port=e.skillPort}async resolvePrompt(n){let r;try{r=this.port.loadCommands()}catch(e){return{ok:!1,error:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to load skills: ${e instanceof Error?e.message:String(e)}`,!0)}}let i=r.find(e=>e.name===n.skillName);return i?i.context===`fork`?{ok:!1,error:e(`DAG_VALIDATION_SKILL_FORK_UNSUPPORTED`,`Skill "${n.skillName}" uses fork context, which the resolver node does not support (no subagent runtime). Use an inject-context skill.`,{skillName:n.skillName})}:this.resolveInject(i,n):{ok:!1,error:e(`DAG_VALIDATION_SKILL_NOT_FOUND`,`Skill "${n.skillName}" was not found in the injected contribution sources`,{skillName:n.skillName},{action:`set_config`,suggestion:`Set skillName to an available skill`,options:r.map(e=>e.name)})}}async resolveInject(e,n){try{let r=await this.port.resolveSkill(e,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:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Skill "${n.skillName}" did not resolve to an inject prompt`,!1,{skillName:n.skillName,mode:r.mode})}}catch(e){let r=e instanceof Error?e.message:String(e);return{ok:!1,error:t(`DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED`,`Failed to resolve skill "${n.skillName}": ${r}`,!1,{skillName:n.skillName})}}}};const o=i.object({skillName:i.string().min(1),args:i.string().default(``),sessionId:i.string().optional(),baseCredits:i.number().nonnegative().default(0)}),s=[{key:`args`,label:`Args`,order:0,type:`string`,required:!1}],c=[{key:`prompt`,label:`Prompt`,order:0,type:`string`,required:!0},{key:`mode`,label:`Mode`,order:1,type:`string`,required:!0}];var l=class extends r{nodeType=`skill`;displayName=`Skill`;category=`Integration`;inputs=s;outputs=c;configSchemaDefinition=o;defaultInputPort=`args`;defaultOutputPort=`prompt`;runtime;constructor(e){super(),this.runtime=new a(e)}async estimateCostWithConfig(e,t,n){return{ok:!0,value:{estimatedCredits:n.baseCredits}}}async executeWithConfig(t,r,i){let a=new n(t,r.nodeDefinition.nodeId),o=a.getInput(`args`),s=typeof o==`string`&&o.trim().length>0?o:i.args,c=await this.runtime.resolvePrompt({skillName:i.skillName,args:s,...i.sessionId===void 0?{}:{sessionId:i.sessionId}});return c.ok?c.value.prompt.trim().length===0?{ok:!1,error:e(`DAG_VALIDATION_SKILL_EMPTY_PROMPT`,`Skill "${i.skillName}" resolved to an empty prompt`,{skillName:i.skillName})}:(a.setOutput(`prompt`,c.value.prompt),a.setOutput(`mode`,c.value.mode),a.setOutput(`_agentSummary`,`Skill "${i.skillName}" resolved (${c.value.mode}): ${c.value.prompt.length} chars.`),{ok:!0,value:a.toOutput()}):c}};export{l as SkillNodeDefinition};
2
+ //# sourceMappingURL=node-C4_FOvnk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-bJ0lEuNF.js","names":[],"sources":["../../../dag-nodes/skill/dist/node/index.js"],"sourcesContent":["import { AbstractNodeDefinition, NodeIoAccessor } from \"@robota-sdk/dag-node\";\nimport { buildTaskExecutionError, buildValidationError } from \"@robota-sdk/dag-core\";\nimport { z } from \"zod\";\n//#region src/runtime-core.ts\n/**\n* Resolves a Robota skill (by name) to its inject-mode prompt string through the injected\n* {@link ISkillExecutionPort}. No LLM, no provider, no shell: the port resolves with empty callbacks so shell\n* interpolations are stripped rather than executed, and fork skills are rejected here before resolution.\n*/\nvar SkillResolverRuntime = class {\n\tport;\n\tconstructor(options) {\n\t\tthis.port = options.skillPort;\n\t}\n\tasync resolvePrompt(request) {\n\t\tlet commands;\n\t\ttry {\n\t\t\tcommands = this.port.loadCommands();\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: buildTaskExecutionError(\"DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED\", `Failed to load skills: ${err instanceof Error ? err.message : String(err)}`, true)\n\t\t\t};\n\t\t}\n\t\tconst skill = commands.find((command) => command.name === request.skillName);\n\t\tif (!skill) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_SKILL_NOT_FOUND\", `Skill \"${request.skillName}\" was not found in the injected contribution sources`, { skillName: request.skillName }, {\n\t\t\t\taction: \"set_config\",\n\t\t\t\tsuggestion: \"Set skillName to an available skill\",\n\t\t\t\toptions: commands.map((command) => command.name)\n\t\t\t})\n\t\t};\n\t\tif (skill.context === \"fork\") return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_SKILL_FORK_UNSUPPORTED\", `Skill \"${request.skillName}\" uses fork context, which the resolver node does not support (no subagent runtime). Use an inject-context skill.`, { skillName: request.skillName })\n\t\t};\n\t\treturn this.resolveInject(skill, request);\n\t}\n\tasync resolveInject(skill, request) {\n\t\ttry {\n\t\t\tconst result = await this.port.resolveSkill(skill, request.args, request.sessionId !== void 0 ? { sessionId: request.sessionId } : void 0);\n\t\t\tif (typeof result.prompt !== \"string\") return {\n\t\t\t\tok: false,\n\t\t\t\terror: buildTaskExecutionError(\"DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED\", `Skill \"${request.skillName}\" did not resolve to an inject prompt`, false, {\n\t\t\t\t\tskillName: request.skillName,\n\t\t\t\t\tmode: result.mode\n\t\t\t\t})\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tprompt: result.prompt,\n\t\t\t\t\tmode: result.mode\n\t\t\t\t}\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: buildTaskExecutionError(\"DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED\", `Failed to resolve skill \"${request.skillName}\": ${message}`, false, { skillName: request.skillName })\n\t\t\t};\n\t\t}\n\t}\n};\n//#endregion\n//#region src/index.ts\nconst SkillNodeConfigSchema = z.object({\n\t/** Name of the skill to resolve (as discovered by SkillCommandSource). */\n\tskillName: z.string().min(1),\n\t/** Static skill arguments; the `args` input port overrides this when non-empty. */\n\targs: z.string().default(\"\"),\n\t/** Session id substituted for `${CLAUDE_SESSION_ID}` in the skill body. */\n\tsessionId: z.string().optional(),\n\t/** Base credit cost (resolution runs no model — default 0). */\n\tbaseCredits: z.number().nonnegative().default(0)\n});\nconst SKILL_INPUTS = [{\n\tkey: \"args\",\n\tlabel: \"Args\",\n\torder: 0,\n\ttype: \"string\",\n\trequired: false\n}];\nconst SKILL_OUTPUTS = [{\n\tkey: \"prompt\",\n\tlabel: \"Prompt\",\n\torder: 0,\n\ttype: \"string\",\n\trequired: true\n}, {\n\tkey: \"mode\",\n\tlabel: \"Mode\",\n\torder: 1,\n\ttype: \"string\",\n\trequired: true\n}];\n/**\n* DAG node that resolves a Robota skill to its inject-mode prompt string.\n*\n* Emits the expanded `<skill>` prompt for a downstream LLM node to execute;\n* it does not run the skill itself.\n*\n* @extends AbstractNodeDefinition\n*/\nvar SkillNodeDefinition = class extends AbstractNodeDefinition {\n\tnodeType = \"skill\";\n\tdisplayName = \"Skill\";\n\tcategory = \"Integration\";\n\tinputs = SKILL_INPUTS;\n\toutputs = SKILL_OUTPUTS;\n\tconfigSchemaDefinition = SkillNodeConfigSchema;\n\tdefaultInputPort = \"args\";\n\tdefaultOutputPort = \"prompt\";\n\truntime;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.runtime = new SkillResolverRuntime(options);\n\t}\n\tasync estimateCostWithConfig(_input, _context, config) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: { estimatedCredits: config.baseCredits }\n\t\t};\n\t}\n\tasync executeWithConfig(input, context, config) {\n\t\tconst io = new NodeIoAccessor(input, context.nodeDefinition.nodeId);\n\t\tconst argsInput = io.getInput(\"args\");\n\t\tconst args = typeof argsInput === \"string\" && argsInput.trim().length > 0 ? argsInput : config.args;\n\t\tconst resolved = await this.runtime.resolvePrompt({\n\t\t\tskillName: config.skillName,\n\t\t\targs,\n\t\t\t...config.sessionId !== void 0 ? { sessionId: config.sessionId } : {}\n\t\t});\n\t\tif (!resolved.ok) return resolved;\n\t\tif (resolved.value.prompt.trim().length === 0) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_SKILL_EMPTY_PROMPT\", `Skill \"${config.skillName}\" resolved to an empty prompt`, { skillName: config.skillName })\n\t\t};\n\t\tio.setOutput(\"prompt\", resolved.value.prompt);\n\t\tio.setOutput(\"mode\", resolved.value.mode);\n\t\tio.setOutput(\"_agentSummary\", `Skill \"${config.skillName}\" resolved (${resolved.value.mode}): ${resolved.value.prompt.length} chars.`);\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: io.toOutput()\n\t\t};\n\t}\n};\n//#endregion\nexport { SkillNodeConfigSchema, SkillNodeDefinition, SkillResolverRuntime };\n\n//# sourceMappingURL=index.js.map"],"mappings":"oFASA,IAAI,EAAuB,KAAM,CAChC,KACA,YAAY,EAAS,CACpB,KAAK,KAAO,EAAQ,SACrB,CACA,MAAM,cAAc,EAAS,CAC5B,IAAI,EACJ,GAAI,CACH,EAAW,KAAK,KAAK,aAAa,CACnC,OAAS,EAAK,CACb,MAAO,CACN,GAAI,GACJ,MAAO,EAAwB,0CAA2C,0BAA0B,aAAe,MAAQ,EAAI,QAAU,OAAO,CAAG,IAAK,EAAI,CAC7J,CACD,CACA,IAAM,EAAQ,EAAS,KAAM,GAAY,EAAQ,OAAS,EAAQ,SAAS,EAa3E,OAZK,EAQD,EAAM,UAAY,OAAe,CACpC,GAAI,GACJ,MAAO,EAAqB,wCAAyC,UAAU,EAAQ,UAAU,mHAAoH,CAAE,UAAW,EAAQ,SAAU,CAAC,CACtP,EACO,KAAK,cAAc,EAAO,CAAO,EAZrB,CAClB,GAAI,GACJ,MAAO,EAAqB,iCAAkC,UAAU,EAAQ,UAAU,sDAAuD,CAAE,UAAW,EAAQ,SAAU,EAAG,CAClL,OAAQ,aACR,WAAY,sCACZ,QAAS,EAAS,IAAK,GAAY,EAAQ,IAAI,CAChD,CAAC,CACF,CAMD,CACA,MAAM,cAAc,EAAO,EAAS,CACnC,GAAI,CACH,IAAM,EAAS,MAAM,KAAK,KAAK,aAAa,EAAO,EAAQ,KAAM,EAAQ,YAAc,IAAK,GAAuC,IAAK,GAAxC,CAAE,UAAW,EAAQ,SAAU,CAAU,EAQzI,OAPI,OAAO,EAAO,QAAW,SAOtB,CACN,GAAI,GACJ,MAAO,CACN,OAAQ,EAAO,OACf,KAAM,EAAO,IACd,CACD,EAb8C,CAC7C,GAAI,GACJ,MAAO,EAAwB,0CAA2C,UAAU,EAAQ,UAAU,uCAAwC,GAAO,CACpJ,UAAW,EAAQ,UACnB,KAAM,EAAO,IACd,CAAC,CACF,CAQD,OAAS,EAAK,CACb,IAAM,EAAU,aAAe,MAAQ,EAAI,QAAU,OAAO,CAAG,EAC/D,MAAO,CACN,GAAI,GACJ,MAAO,EAAwB,0CAA2C,4BAA4B,EAAQ,UAAU,KAAK,IAAW,GAAO,CAAE,UAAW,EAAQ,SAAU,CAAC,CAChL,CACD,CACD,CACD,EAGA,MAAM,EAAwB,EAAE,OAAO,CAEtC,UAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAE3B,KAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,EAE3B,UAAW,EAAE,OAAO,CAAC,CAAC,SAAS,EAE/B,YAAa,EAAE,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CAChD,CAAC,EACK,EAAe,CAAC,CACrB,IAAK,OACL,MAAO,OACP,MAAO,EACP,KAAM,SACN,SAAU,EACX,CAAC,EACK,EAAgB,CAAC,CACtB,IAAK,SACL,MAAO,SACP,MAAO,EACP,KAAM,SACN,SAAU,EACX,EAAG,CACF,IAAK,OACL,MAAO,OACP,MAAO,EACP,KAAM,SACN,SAAU,EACX,CAAC,EASD,IAAI,EAAsB,cAAc,CAAuB,CAC9D,SAAW,QACX,YAAc,QACd,SAAW,cACX,OAAS,EACT,QAAU,EACV,uBAAyB,EACzB,iBAAmB,OACnB,kBAAoB,SACpB,QACA,YAAY,EAAS,CACpB,MAAM,EACN,KAAK,QAAU,IAAI,EAAqB,CAAO,CAChD,CACA,MAAM,uBAAuB,EAAQ,EAAU,EAAQ,CACtD,MAAO,CACN,GAAI,GACJ,MAAO,CAAE,iBAAkB,EAAO,WAAY,CAC/C,CACD,CACA,MAAM,kBAAkB,EAAO,EAAS,EAAQ,CAC/C,IAAM,EAAK,IAAI,EAAe,EAAO,EAAQ,eAAe,MAAM,EAC5D,EAAY,EAAG,SAAS,MAAM,EAC9B,EAAO,OAAO,GAAc,UAAY,EAAU,KAAK,CAAC,CAAC,OAAS,EAAI,EAAY,EAAO,KACzF,EAAW,MAAM,KAAK,QAAQ,cAAc,CACjD,UAAW,EAAO,UAClB,OACA,GAAG,EAAO,YAAc,IAAK,GAAsC,CAAC,EAAnC,CAAE,UAAW,EAAO,SAAU,CAChE,CAAC,EASD,OARK,EAAS,GACV,EAAS,MAAM,OAAO,KAAK,CAAC,CAAC,SAAW,EAAU,CACrD,GAAI,GACJ,MAAO,EAAqB,oCAAqC,UAAU,EAAO,UAAU,+BAAgC,CAAE,UAAW,EAAO,SAAU,CAAC,CAC5J,GACA,EAAG,UAAU,SAAU,EAAS,MAAM,MAAM,EAC5C,EAAG,UAAU,OAAQ,EAAS,MAAM,IAAI,EACxC,EAAG,UAAU,gBAAiB,UAAU,EAAO,UAAU,cAAc,EAAS,MAAM,KAAK,KAAK,EAAS,MAAM,OAAO,OAAO,QAAQ,EAC9H,CACN,GAAI,GACJ,MAAO,EAAG,SAAS,CACpB,GAXyB,CAY1B,CACD"}
1
+ {"version":3,"file":"node-C4_FOvnk.js","names":[],"sources":["../../../dag-nodes/skill/dist/node/index.js"],"sourcesContent":["import { AbstractNodeDefinition, NodeIoAccessor } from \"@robota-sdk/dag-node\";\nimport { buildTaskExecutionError, buildValidationError } from \"@robota-sdk/dag-core\";\nimport { z } from \"zod\";\n//#region src/runtime-core.ts\n/**\n* Resolves a Robota skill (by name) to its inject-mode prompt string through the injected\n* {@link ISkillExecutionPort}. No LLM, no provider, no shell: the port resolves with empty callbacks so shell\n* interpolations are stripped rather than executed, and fork skills are rejected here before resolution.\n*/\nvar SkillResolverRuntime = class {\n\tport;\n\tconstructor(options) {\n\t\tthis.port = options.skillPort;\n\t}\n\tasync resolvePrompt(request) {\n\t\tlet commands;\n\t\ttry {\n\t\t\tcommands = this.port.loadCommands();\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: buildTaskExecutionError(\"DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED\", `Failed to load skills: ${err instanceof Error ? err.message : String(err)}`, true)\n\t\t\t};\n\t\t}\n\t\tconst skill = commands.find((command) => command.name === request.skillName);\n\t\tif (!skill) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_SKILL_NOT_FOUND\", `Skill \"${request.skillName}\" was not found in the injected contribution sources`, { skillName: request.skillName }, {\n\t\t\t\taction: \"set_config\",\n\t\t\t\tsuggestion: \"Set skillName to an available skill\",\n\t\t\t\toptions: commands.map((command) => command.name)\n\t\t\t})\n\t\t};\n\t\tif (skill.context === \"fork\") return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_SKILL_FORK_UNSUPPORTED\", `Skill \"${request.skillName}\" uses fork context, which the resolver node does not support (no subagent runtime). Use an inject-context skill.`, { skillName: request.skillName })\n\t\t};\n\t\treturn this.resolveInject(skill, request);\n\t}\n\tasync resolveInject(skill, request) {\n\t\ttry {\n\t\t\tconst result = await this.port.resolveSkill(skill, request.args, request.sessionId !== void 0 ? { sessionId: request.sessionId } : void 0);\n\t\t\tif (typeof result.prompt !== \"string\") return {\n\t\t\t\tok: false,\n\t\t\t\terror: buildTaskExecutionError(\"DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED\", `Skill \"${request.skillName}\" did not resolve to an inject prompt`, false, {\n\t\t\t\t\tskillName: request.skillName,\n\t\t\t\t\tmode: result.mode\n\t\t\t\t})\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tprompt: result.prompt,\n\t\t\t\t\tmode: result.mode\n\t\t\t\t}\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: buildTaskExecutionError(\"DAG_TASK_EXECUTION_SKILL_RESOLVE_FAILED\", `Failed to resolve skill \"${request.skillName}\": ${message}`, false, { skillName: request.skillName })\n\t\t\t};\n\t\t}\n\t}\n};\n//#endregion\n//#region src/index.ts\nconst SkillNodeConfigSchema = z.object({\n\t/** Name of the skill to resolve (as discovered by SkillCommandSource). */\n\tskillName: z.string().min(1),\n\t/** Static skill arguments; the `args` input port overrides this when non-empty. */\n\targs: z.string().default(\"\"),\n\t/** Session id substituted for `${CLAUDE_SESSION_ID}` in the skill body. */\n\tsessionId: z.string().optional(),\n\t/** Base credit cost (resolution runs no model — default 0). */\n\tbaseCredits: z.number().nonnegative().default(0)\n});\nconst SKILL_INPUTS = [{\n\tkey: \"args\",\n\tlabel: \"Args\",\n\torder: 0,\n\ttype: \"string\",\n\trequired: false\n}];\nconst SKILL_OUTPUTS = [{\n\tkey: \"prompt\",\n\tlabel: \"Prompt\",\n\torder: 0,\n\ttype: \"string\",\n\trequired: true\n}, {\n\tkey: \"mode\",\n\tlabel: \"Mode\",\n\torder: 1,\n\ttype: \"string\",\n\trequired: true\n}];\n/**\n* DAG node that resolves a Robota skill to its inject-mode prompt string.\n*\n* Emits the expanded `<skill>` prompt for a downstream LLM node to execute;\n* it does not run the skill itself.\n*\n* @extends AbstractNodeDefinition\n*/\nvar SkillNodeDefinition = class extends AbstractNodeDefinition {\n\tnodeType = \"skill\";\n\tdisplayName = \"Skill\";\n\tcategory = \"Integration\";\n\tinputs = SKILL_INPUTS;\n\toutputs = SKILL_OUTPUTS;\n\tconfigSchemaDefinition = SkillNodeConfigSchema;\n\tdefaultInputPort = \"args\";\n\tdefaultOutputPort = \"prompt\";\n\truntime;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.runtime = new SkillResolverRuntime(options);\n\t}\n\tasync estimateCostWithConfig(_input, _context, config) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: { estimatedCredits: config.baseCredits }\n\t\t};\n\t}\n\tasync executeWithConfig(input, context, config) {\n\t\tconst io = new NodeIoAccessor(input, context.nodeDefinition.nodeId);\n\t\tconst argsInput = io.getInput(\"args\");\n\t\tconst args = typeof argsInput === \"string\" && argsInput.trim().length > 0 ? argsInput : config.args;\n\t\tconst resolved = await this.runtime.resolvePrompt({\n\t\t\tskillName: config.skillName,\n\t\t\targs,\n\t\t\t...config.sessionId !== void 0 ? { sessionId: config.sessionId } : {}\n\t\t});\n\t\tif (!resolved.ok) return resolved;\n\t\tif (resolved.value.prompt.trim().length === 0) return {\n\t\t\tok: false,\n\t\t\terror: buildValidationError(\"DAG_VALIDATION_SKILL_EMPTY_PROMPT\", `Skill \"${config.skillName}\" resolved to an empty prompt`, { skillName: config.skillName })\n\t\t};\n\t\tio.setOutput(\"prompt\", resolved.value.prompt);\n\t\tio.setOutput(\"mode\", resolved.value.mode);\n\t\tio.setOutput(\"_agentSummary\", `Skill \"${config.skillName}\" resolved (${resolved.value.mode}): ${resolved.value.prompt.length} chars.`);\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: io.toOutput()\n\t\t};\n\t}\n};\n//#endregion\nexport { SkillNodeConfigSchema, SkillNodeDefinition, SkillResolverRuntime };\n\n//# sourceMappingURL=index.js.map"],"mappings":"oFASA,IAAI,EAAuB,KAAM,CAChC,KACA,YAAY,EAAS,CACpB,KAAK,KAAO,EAAQ,SACrB,CACA,MAAM,cAAc,EAAS,CAC5B,IAAI,EACJ,GAAI,CACH,EAAW,KAAK,KAAK,aAAa,CACnC,OAAS,EAAK,CACb,MAAO,CACN,GAAI,GACJ,MAAO,EAAwB,0CAA2C,0BAA0B,aAAe,MAAQ,EAAI,QAAU,OAAO,CAAG,IAAK,EAAI,CAC7J,CACD,CACA,IAAM,EAAQ,EAAS,KAAM,GAAY,EAAQ,OAAS,EAAQ,SAAS,EAa3E,OAZK,EAQD,EAAM,UAAY,OAAe,CACpC,GAAI,GACJ,MAAO,EAAqB,wCAAyC,UAAU,EAAQ,UAAU,mHAAoH,CAAE,UAAW,EAAQ,SAAU,CAAC,CACtP,EACO,KAAK,cAAc,EAAO,CAAO,EAZrB,CAClB,GAAI,GACJ,MAAO,EAAqB,iCAAkC,UAAU,EAAQ,UAAU,sDAAuD,CAAE,UAAW,EAAQ,SAAU,EAAG,CAClL,OAAQ,aACR,WAAY,sCACZ,QAAS,EAAS,IAAK,GAAY,EAAQ,IAAI,CAChD,CAAC,CACF,CAMD,CACA,MAAM,cAAc,EAAO,EAAS,CACnC,GAAI,CACH,IAAM,EAAS,MAAM,KAAK,KAAK,aAAa,EAAO,EAAQ,KAAM,EAAQ,YAAc,IAAK,GAAuC,IAAK,GAAxC,CAAE,UAAW,EAAQ,SAAU,CAAU,EAQzI,OAPI,OAAO,EAAO,QAAW,SAOtB,CACN,GAAI,GACJ,MAAO,CACN,OAAQ,EAAO,OACf,KAAM,EAAO,IACd,CACD,EAb8C,CAC7C,GAAI,GACJ,MAAO,EAAwB,0CAA2C,UAAU,EAAQ,UAAU,uCAAwC,GAAO,CACpJ,UAAW,EAAQ,UACnB,KAAM,EAAO,IACd,CAAC,CACF,CAQD,OAAS,EAAK,CACb,IAAM,EAAU,aAAe,MAAQ,EAAI,QAAU,OAAO,CAAG,EAC/D,MAAO,CACN,GAAI,GACJ,MAAO,EAAwB,0CAA2C,4BAA4B,EAAQ,UAAU,KAAK,IAAW,GAAO,CAAE,UAAW,EAAQ,SAAU,CAAC,CAChL,CACD,CACD,CACD,EAGA,MAAM,EAAwB,EAAE,OAAO,CAEtC,UAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAE3B,KAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,EAE3B,UAAW,EAAE,OAAO,CAAC,CAAC,SAAS,EAE/B,YAAa,EAAE,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CAChD,CAAC,EACK,EAAe,CAAC,CACrB,IAAK,OACL,MAAO,OACP,MAAO,EACP,KAAM,SACN,SAAU,EACX,CAAC,EACK,EAAgB,CAAC,CACtB,IAAK,SACL,MAAO,SACP,MAAO,EACP,KAAM,SACN,SAAU,EACX,EAAG,CACF,IAAK,OACL,MAAO,OACP,MAAO,EACP,KAAM,SACN,SAAU,EACX,CAAC,EASD,IAAI,EAAsB,cAAc,CAAuB,CAC9D,SAAW,QACX,YAAc,QACd,SAAW,cACX,OAAS,EACT,QAAU,EACV,uBAAyB,EACzB,iBAAmB,OACnB,kBAAoB,SACpB,QACA,YAAY,EAAS,CACpB,MAAM,EACN,KAAK,QAAU,IAAI,EAAqB,CAAO,CAChD,CACA,MAAM,uBAAuB,EAAQ,EAAU,EAAQ,CACtD,MAAO,CACN,GAAI,GACJ,MAAO,CAAE,iBAAkB,EAAO,WAAY,CAC/C,CACD,CACA,MAAM,kBAAkB,EAAO,EAAS,EAAQ,CAC/C,IAAM,EAAK,IAAI,EAAe,EAAO,EAAQ,eAAe,MAAM,EAC5D,EAAY,EAAG,SAAS,MAAM,EAC9B,EAAO,OAAO,GAAc,UAAY,EAAU,KAAK,CAAC,CAAC,OAAS,EAAI,EAAY,EAAO,KACzF,EAAW,MAAM,KAAK,QAAQ,cAAc,CACjD,UAAW,EAAO,UAClB,OACA,GAAG,EAAO,YAAc,IAAK,GAAsC,CAAC,EAAnC,CAAE,UAAW,EAAO,SAAU,CAChE,CAAC,EASD,OARK,EAAS,GACV,EAAS,MAAM,OAAO,KAAK,CAAC,CAAC,SAAW,EAAU,CACrD,GAAI,GACJ,MAAO,EAAqB,oCAAqC,UAAU,EAAO,UAAU,+BAAgC,CAAE,UAAW,EAAO,SAAU,CAAC,CAC5J,GACA,EAAG,UAAU,SAAU,EAAS,MAAM,MAAM,EAC5C,EAAG,UAAU,OAAQ,EAAS,MAAM,IAAI,EACxC,EAAG,UAAU,gBAAiB,UAAU,EAAO,UAAU,cAAc,EAAS,MAAM,KAAK,KAAK,EAAS,MAAM,OAAO,OAAO,QAAQ,EAC9H,CACN,GAAI,GACJ,MAAO,EAAG,SAAS,CACpB,GAXyB,CAY1B,CACD"}
@@ -1,25 +1,25 @@
1
- import{B as e,Mt as t,T as n,et as r,o as i,st as a,yt as o}from"./node-CQqDd5KI.js";import{a as s,d as c,n as l,s as u,v as d}from"./bounded-output-DpjpS98g-DFgAppgl.js";import"./command-executor-DV-H2oD6-OKy8pwYH.js";import"./http-executor-cWzI2svn-TG_TMYKh.js";import{randomBytes as f,randomUUID as p}from"node:crypto";import{basename as m,dirname as h,isAbsolute as g,join as _,posix as v,relative as y,resolve as b,sep as ee}from"node:path";import{spawn as x,spawnSync as te}from"node:child_process";import{chmod as ne,mkdir as re,open as ie,readFile as ae,readdir as oe,rename as se,rm as ce,stat as S,writeFile as le}from"node:fs/promises";import{accessSync as ue,chmodSync as de,constants as fe,cpSync as pe,createReadStream as me,existsSync as he,lstatSync as ge,mkdirSync as C,readFileSync as _e,readdirSync as ve,readlinkSync as ye,realpathSync as w,renameSync as T,rmSync as be,statSync as E,symlinkSync as xe,unlinkSync as Se,writeFileSync as Ce}from"node:fs";import{homedir as we,tmpdir as Te}from"node:os";import{z as D}from"zod";import{lookup as Ee}from"node:dns/promises";import{isIP as De}from"node:net";import Oe from"fast-glob";import ke from"p-limit";import{EventEmitter as Ae}from"node:events";import{Worker as je}from"node:worker_threads";const Me=2e3,Ne=process.platform===`win32`;function O(e){return e.exitCode!==null||e.signalCode!==null}function Pe(e,t,n){if(n&&!Ne&&typeof e.pid==`number`)try{process.kill(-e.pid,t);return}catch{}try{e.kill(t)}catch{}}function Fe(e,t){if(Ne&&typeof e.pid==`number`){te(`taskkill`,[`/pid`,String(e.pid),`/T`,`/F`],{stdio:`ignore`});return}Pe(e,`SIGKILL`,t)}async function k(e,t={}){let n=t.graceMs??2e3,r=t.signal??`SIGTERM`,i=t.processGroup??!1;if(!O(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(O(e))return}return new Promise(t=>{let a,o=()=>{a&&clearTimeout(a),t()};if(e.once(`exit`,o),O(e)){e.removeListener(`exit`,o),t();return}Pe(e,r,i),a=setTimeout(()=>{O(e)||Fe(e,i)},n),a.unref?.()})}}function Ie(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(!g(e))throw TypeError(`executionRoot must be an absolute path`);let t;try{t=w(e)}catch{throw TypeError(`executionRoot must name an existing accessible directory`)}if(!E(t).isDirectory())throw TypeError(`executionRoot must name a directory`);try{ue(t,fe.R_OK|fe.X_OK)}catch{throw TypeError(`executionRoot directory must be readable and traversable`)}return t}function Le(e){let t=[],n=b(e);for(;;)try{return _(w(n),...t)}catch{let r=h(n);if(r===n)return b(e);t.unshift(m(n)),n=r}}function Re(e,t){let n=Le(e),r=Le(t);return r===n||r.startsWith(n+ee)}var ze=class extends Error{constructor(e){super(e),this.name=`OwnerOnlyModeError`}};function A(e=process.platform){return e===`win32`?`windows-acl`:`posix-mode`}function Be(e,t){let n=y(e,t);if(n.startsWith(`..`)||g(n))throw new ze(`withinRoot ${e} is not an ancestor of ${t}, so this call cannot own the path between them.`);let r=n.split(ee).filter(e=>e.length>0),i=[e],a=e;for(let e of r)a=_(a,e),i.push(a);return i}function j(e,t,n={}){if(A()!==`posix-mode`)return;let r=(n.readMode??(e=>E(e).mode&4095))(e);if(r&63)throw new ze(`${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 Ve(e,t={}){let n=t.makeDirectory??((e,t)=>{C(e,{recursive:!0,mode:t})}),r=t.setMode??((e,t)=>de(e,t));n(e,448);let i=t.withinRoot===void 0?[e]:Be(t.withinRoot,e);for(let e of i)A()===`posix-mode`&&r(e,448),j(e,`directory`,t)}function He(e,t){Ve(h(e));let n=`${e}.${process.pid}.tmp`;be(n,{force:!0}),Ce(n,t,{encoding:`utf8`,mode:384,flag:`wx`});try{j(n,`file`),T(n,e)}catch(e){try{Se(n)}catch{}throw e}j(e,`file`)}function Ue(e){if(A()!==`posix-mode`)return;let t;try{t=E(e).mode&4095}catch{return}t&63&&(de(e,384),j(e,`file`))}function We(e){let t=De(e);return t===4?Ge(e.split(`.`).map(Number)):t!==6||Ke(e)}function Ge(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 Ke(e){let t=Je(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?Ge([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 qe(e){let t=e.lastIndexOf(`:`),n=e.slice(t+1);if(!n.includes(`.`))return e;if(t<0||De(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 Je(e){let t=qe(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 Ye=3e4,Xe=5e6,Ze=new Set([301,302,303,307,308]),Qe=new Set([`localhost`,`metadata`,`metadata.google.internal`,`metadata.goog`,`instance-data`,`instance-data.ec2.internal`]),M=async e=>(await Ee(e,{all:!0,verbatim:!0})).map(e=>e.address);async function N(e,t={},n=M){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(Qe.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=De(i)?[i]:await $e(i,n);if(a===void 0||a.length===0)return{reason:`unresolvable`,url:r,message:`Destination "${i}" did not resolve.`};let o=a.find(We);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 $e(e,t){try{return await t(e)}catch{return}}async function et(e,t={},n={},r={}){let i=r.fetch??((e,t)=>globalThis.fetch(e,t)),a=r.lookup??M,o=t.maxResponseBytes??Xe,s=n.maxRedirects??5,c=AbortSignal.timeout(t.timeoutMs??Ye),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 N(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(!Ze.has(r.status))return rt(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=nt(d)),u=f}}async function tt(e,t,n={},r={}){let i=r.fetch??((e,t)=>globalThis.fetch(e,t)),a=t.maxResponseBytes??Xe,o=AbortSignal.timeout(t.timeoutMs??Ye),s=t.signal?AbortSignal.any([o,t.signal]):o,c=new URL(e),l=await N(c,n,r.lookup??M);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.`}}):rt(u,c.href,a,s)}function nt(e){let t={};for(let[n,r]of Object.entries(e))n.toLowerCase()===`user-agent`&&(t[n]=r);return t}async function rt(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 it(e){return e===void 0?`host`:`sandbox-${e.filesystem??`separate`}`}function at(e){return it(e)===`sandbox-separate`}function ot(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 st=/^[A-Za-z]:[\\/]/,ct=/'/g;async function lt(e,t,n={}){if(e.applyManifest)return e.applyManifest(t,n);ot(t);let r=bt(n.targetRoot??`/workspace`),i=[];for(let[a,o]of Object.entries(t.entries)){let t=ut(a),s=xt(r,t);i.push(await dt(e,t,s,r,o,n))}return{entries:i}}function ut(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(`\\`)||st.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 dt(e,t,n,r,i,a){switch(i.type){case`file`:return await gt(e,n,r,i.content),P(t,i.type);case`dir`:return await F(e,n),P(t,i.type);case`localFile`:return await ft(e,i.src,n,r,a),P(t,i.type);case`localDir`:return await pt(e,i.src,n,a),P(t,i.type);case`gitRepo`:return await ht(e,i,n),P(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 St(i)}}function P(e,t){return{path:e,type:t,status:`applied`}}async function ft(e,t,n,r,i){await gt(e,n,r,await ae(vt(t,i.hostRoot),`utf8`))}async function pt(e,t,n,r){await mt(e,vt(t,r.hostRoot),n)}async function mt(e,t,n){await F(e,n);let r=await oe(t,{withFileTypes:!0});for(let i of r){let r=_(t,i.name),a=xt(n,i.name);if(i.isDirectory()){await mt(e,r,a);continue}if(i.isFile()){let t=await ae(r,`utf8`);await e.writeFile(a,t)}}}async function ht(e,t,n){await _t(e,`git clone${t.shallow===!1?``:` --depth 1`}${t.ref?` --branch ${I(t.ref)}`:``} ${I(t.url)} ${I(n)}`)}async function gt(e,t,n,r){let i=v.dirname(t);i!==n&&await F(e,i),await e.writeFile(t,r)}async function F(e,t){await _t(e,`mkdir -p ${I(t)}`)}async function _t(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 vt(e,t){return g(e)?b(e):b(t??process.cwd(),e)}function yt(e){let t=e.length;for(;t>0&&e[t-1]===`/`;)--t;return e.slice(0,t)}function bt(e){let t=yt(e.replace(/\\/g,`/`));if(!t.startsWith(`/`))throw Error(`workspace manifest targetRoot must be an absolute sandbox path`);return t.length===0?`/`:t}function xt(e,t){let n=bt(e);return n===`/`?`/${t}`:`${n}/${t}`}function I(e){return`'${e.replace(ct,`'\\''`)}'`}function St(e){throw Error(`unsupported workspace manifest entry: ${JSON.stringify(e)}`)}const Ct=[`.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 wt(){return[...a,...o]}function Tt(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 wt()){let i=L(t.root,r);e.exists(i)&&n.push(`--ro-bind`,i,i)}for(let r of Ct){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 Et(e){return e.replace(/[\\^$.*+?()[\]{}|"]/g,e=>`\\${e}`)}function R(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Dt(e){let t=[e.root,...e.tempDirectories,...e.allowWrite].map(e=>`(subpath ${R(e)})`).join(` `),n=wt().map(t=>{let n=L(e.root,t);return o.includes(t)?`(literal ${R(n)})`:`(subpath ${R(n)})`}),r=Ct.map(t=>`(subpath ${R(L(e.root,t))})`),i=[`(literal ${R(L(e.root,`.git`))})`,...Ct.map(t=>`(regex #"^${Et(L(e.root,t))}/[^/]+/\\.git$")`)],a=[`(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* ${r.join(` `)})`,`(deny file-write* ${i.join(` `)})`];if(e.denyRead.length>0){let t=e.denyRead.map(e=>e.directory?`(subpath ${R(e.path)})`:`(literal ${R(e.path)})`);a.push(`(deny file-read* ${t.join(` `)})`)}return e.network||a.push(`(deny network*)`),a.join(`
2
- `)}const Ot={x64:{audit:3221225534,socket:41,ioUringSetup:425},arm64:{audit:3221225655,socket:198,ioUringSetup:425}};function z(e,t,n,r){return[e,t,n,r]}function kt(e=process.arch){let t=Ot[e];if(t===void 0)return;let n=e=>327680|e,r=[z(32,0,0,4),z(21,1,0,t.audit),z(6,0,0,n(1)),z(32,0,0,0),z(69,0,1,1073741824),z(6,0,0,n(1)),z(21,0,1,t.ioUringSetup),z(6,0,0,n(1)),z(21,0,3,t.socket),z(32,0,0,16),z(21,0,1,1),z(6,0,0,n(97)),z(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 At=Object.freeze({enabled:!1,autoAllowBashIfSandboxed:!0,excludedCommands:[],allowWrite:[],denyRead:[],network:!1}),jt=`/usr/bin/sandbox-exec`;function Mt(e,t){let n=te(e,[...t],{timeout:5e3,encoding:`utf8`});if(n.error!==void 0)return{ok:!1,detail:n.error.message};let r=(n.stderr??``).trim().split(`
3
- `)[0];return n.status===0?{ok:!0}:{ok:!1,...r?{detail:r}:{}}}function Nt(e={}){let t=e.platform??process.platform,n=e.probe??Mt;if(t===`linux`){if(kt(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(jt,[`-p`,`(version 1)(allow default)`,`/usr/bin/true`]);return e.ok?{backend:`seatbelt`,executable:jt,missing:[]}:{backend:`seatbelt`,missing:[`sandbox-exec cannot run${e.detail?`: ${e.detail}`:``}`]}}return{missing:[],unsupportedPlatform:t}}function B(e){try{return w(e)}catch{return e}}function Pt(e){try{return E(e).isDirectory()}catch{return!1}}function Ft(e){let t=ge(e);if(!t.isSymbolicLink()&&(de(e,t.mode|448),t.isDirectory()))for(let t of ve(e))Ft(`${e}/${t}`)}function It(e){try{return ge(e).isSymbolicLink()}catch{return!1}}function Lt(e){return e.trim().split(/\s+/)[0]}var Rt=class{filesystem=`shared`;root;availability;homeDirectory;current;inFlight=0;baseline=[];unresolved=new Map;constructor(e){this.root=B(e.root),this.availability=e.availability,this.homeDirectory=e.homeDirectory??we(),this.current={...At,...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(i(e).length!==1)return!0;let t=Lt(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`,Dt(n),e.command,...e.args],cwd:e.cwd};let i=n.network?void 0:kt();this.protectedEntryStates().some(e=>e.path.endsWith(`/.robota`)&&e.kind===`symlink`)||C(`${this.root}/.robota`,{recursive:!0});let a=Tt({policy:n,exists:e=>he(e)&&!It(e),listDirectory:e=>ve(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 wt().map(e=>{let t=`${this.root}/${e}`;try{return ge(t).isSymbolicLink()?{path:t,kind:`symlink`,target:ye(t)}:{path:t,kind:`present`}}catch{return{path:t,kind:`missing`}}})}resolvesOutsideWritableWorkspace(e){let t;try{t=w(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()}-${p()}`,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`&&xe(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}/${m(e)}`;C(t,{recursive:!0});try{T(e,n)}catch(t){if(this.inFlight>0)throw t;Ft(e),t.code===`EXDEV`?(pe(e,n,{recursive:!0,verbatimSymlinks:!0}),be(e,{recursive:!0,force:!0})):T(e,n)}return`moved ${e} to ${n}`}policy(){let e=e=>{let t=e===`~`||e.startsWith(`~/`)?`${this.homeDirectory}${e.slice(1)}`:e;return B(g(t)?t:b(this.root,t))},t=[...new Set([Te(),`/tmp`].filter(he).map(B))];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:Pt(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=x(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(_e(e,`utf8`))}writeFile(e,t){return Ce(e,t,`utf8`),Promise.resolve()}};function V(e,n,i,a,o={}){return new t({name:e,description:n,parameters:r(i),...o.deferLoading!==void 0&&{deferLoading:o.deferLoading}},async(e,t)=>{let n=i.safeParse(e);if(!n.success)throw new d(`Zod validation failed: ${n.error}`);let r=await a(n.data,t);return typeof r==`string`?r:JSON.stringify(r)})}const zt={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 Bt(){for(let[t,n]of Object.entries(zt))e(t,n)}Bt();const Vt=1e3,Ht=D.object({activeFiles:D.array(D.string()).optional().describe(`Repo-relative files currently in focus; the map is ranked toward what they reference.`),mentionedIdentifiers:D.array(D.string()).optional().describe(`Symbol names to bias the map toward (e.g. identifiers named in the task).`),tokenBudget:D.number().int().positive().optional().describe(`Maximum tokens for the returned map (default ${Vt}).`)});function Ut(e){return e.map(e=>`${e.file}:${e.line} ${e.kind} ${e.name}`).join(`
4
- `)}async function Wt(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??Vt});return n.symbols.length===0?`No relevant symbols found within the token budget.`:`Most relevant symbols (~${n.totalTokens} tokens):\n${Ut(n.symbols)}`}function Gt(e={}){return V(`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.`,Ht,async t=>Wt(t,e))}const Kt=`Computer use is not available in this session (no driver injected).`,qt=D.enum([`left`,`right`,`middle`]),Jt=D.object({x:D.number(),y:D.number()}),Yt=D.object({type:D.enum([`click`,`double_click`,`type`,`keypress`,`scroll`,`drag`,`wait`,`takeover`]).describe(`Which action to perform.`),x:D.number().optional().describe(`X coordinate (click/double_click/scroll).`),y:D.number().optional().describe(`Y coordinate (click/double_click/scroll).`),button:qt.optional().describe(`Mouse button (click/double_click/drag).`),text:D.string().optional().describe(`Text to type (type).`),keys:D.array(D.string()).optional().describe(`Keys to press as a chord (keypress).`),deltaX:D.number().optional().describe(`Horizontal wheel delta (scroll).`),deltaY:D.number().optional().describe(`Vertical wheel delta (scroll).`),path:D.array(Jt).optional().describe(`Points to drag through (drag).`),ms:D.number().optional().describe(`Milliseconds to wait (wait).`),reason:D.string().optional().describe(`Human-readable reason surfaced to the user (takeover).`)}),Xt=D.object({action:Yt.describe(`The single mutating action to perform.`)}),Zt=D.object({});var H=class extends Error{};function U(e,t,n){if(typeof e!=`number`)throw new H(`Action '${n}' requires numeric '${t}'.`);return e}function Qt(e){let t=e.button;switch(e.type){case`click`:return{type:`click`,x:U(e.x,`x`,`click`),y:U(e.y,`y`,`click`),...t?{button:t}:{}};case`double_click`:return{type:`double_click`,x:U(e.x,`x`,`double_click`),y:U(e.y,`y`,`double_click`),...t?{button:t}:{}};case`type`:if(typeof e.text!=`string`)throw new H(`Action 'type' requires 'text'.`);return{type:`type`,text:e.text};case`keypress`:if(!e.keys||e.keys.length===0)throw new H(`Action 'keypress' requires non-empty 'keys'.`);return{type:`keypress`,keys:e.keys};case`scroll`:return{type:`scroll`,x:U(e.x,`x`,`scroll`),y:U(e.y,`y`,`scroll`),deltaX:U(e.deltaX,`deltaX`,`scroll`),deltaY:U(e.deltaY,`deltaY`,`scroll`)};case`drag`:if(!e.path||e.path.length<2)throw new H(`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 H(`Unknown action type: ${String(t)}`)}}}async function $t(e){if(!e.driver)return JSON.stringify({success:!1,error:Kt});let t=await e.driver.screenshot();return JSON.stringify(t?{success:!0,screenshot:t}:{success:!0,takeover:!0})}async function en(e,t){if(!t.driver)return JSON.stringify({success:!1,error:Kt});let n;try{n=Qt(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 tn(e={}){return V(`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.`,Zt,async()=>$t(e))}function nn(e={}){return V(`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.",Xt,async t=>en(t,e))}function rn(e={}){return[tn(e),nn(e)]}const an=[{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 on(e,t){let n=t?an.filter(e=>t.includes(e.toolName)):an,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(`
5
- `)}const W=process.platform!==`win32`,sn=2e6,cn=D.object({command:D.string().describe(`The shell command to execute`),timeout:D.number().optional().describe(`Optional timeout in milliseconds (max 600000). Default is 120000 (2 minutes)`),workingDirectory:D.string().optional().describe(`Working directory for the command. Defaults to the current working directory`)});async function ln(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 un(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 ln(a,l,c??t.cwd,t);let f={command:n.command,args:n.commandArgs(a),cwd:d},p=t.sandboxClient?.wrapCommand?.(f,a)??f,m=!1,h=()=>{if(!m){m=!0;try{return p.afterExit?.()}catch(e){return`[sandbox] clean-up failed: ${e instanceof Error?e.message:String(e)}`}}};return r?.aborted?(h(),JSON.stringify({success:!1,output:``,error:`Aborted before start`})):new Promise(e=>{let t=s({maxBytes:sn}),n=s({maxBytes:sn}),a=!1,o=!1,c;try{c=x(p.command,[...p.args],{cwd:p.cwd,env:i===void 0?process.env:u(process.env,i),stdio:[`pipe`,`pipe`,`pipe`,...(p.inputDescriptors??[]).map(()=>`pipe`)],detached:W})}catch(t){let n=h(),r=t instanceof Error?t.message:String(t);e(JSON.stringify({success:!1,output:n??``,error:r}));return}(p.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,k(c,{processGroup:W}),f({success:!1,output:t.toString(),error:`Command timed out after ${l}ms`})},l);function f(t){o||(o=!0,clearTimeout(d),r?.removeEventListener(`abort`,m),e(JSON.stringify(t)))}function m(){k(c,{processGroup:W}),f({success:!1,output:t.toString(),error:`Aborted`})}r?.addEventListener(`abort`,m,{once:!0}),c.on(`error`,e=>{c.pid===void 0&&h(),f({success:!1,output:``,error:e.message})}),c.on(`close`,e=>{let r=h();if(a){f({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;f({success:!0,output:r===void 0?c:`${c}\n${r}`,exitCode:s})})})}function dn(e,t){let n=l({executable:t.shellExecutable});return V(e,t.description??on(n,t.availableTools),cn,async(e,r)=>un(e,t,n,r?.signal,r?.shellTraceEnv))}function fn(e){return dn(`Shell`,e)}function pn(e){return dn(`Bash`,e)}function G(e,t){return t!==void 0&&Re(t,e)}function K(e,t){return t===void 0?e:b(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(!G(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?b(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=D.object({filePath:D.string().describe(`The absolute path to the file to read`),offset:D.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:D.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(`
1
+ import{E as e,Z as t,i as n,it as r,pt as i,r as a,st as o}from"./node-DtKU0MUr.js";import{a as s,d as c,n as l,s as u,v as d}from"./bounded-output-DpjpS98g-DFgAppgl.js";import"./command-executor-DV-H2oD6-OKy8pwYH.js";import"./http-executor-cWzI2svn-TG_TMYKh.js";import{randomBytes as f,randomUUID as p}from"node:crypto";import{basename as m,dirname as h,isAbsolute as g,join as _,posix as ee,relative as v,resolve as y,sep as te}from"node:path";import{spawn as ne,spawnSync as re}from"node:child_process";import{chmod as ie,mkdir as ae,open as oe,readFile as se,readdir as ce,rename as le,rm as ue,stat as b,writeFile as de}from"node:fs/promises";import{accessSync as fe,chmodSync as x,constants as S,cpSync as pe,createReadStream as me,existsSync as he,lstatSync as C,mkdirSync as w,readFileSync as ge,readdirSync as _e,readlinkSync as ve,realpathSync as T,renameSync as E,rmSync as ye,statSync as D,symlinkSync as be,unlinkSync as xe,writeFileSync as Se}from"node:fs";import{homedir as Ce,tmpdir as we}from"node:os";import{z as O}from"zod";import{lookup as Te}from"node:dns/promises";import{isIP as Ee}from"node:net";import De from"fast-glob";import Oe from"p-limit";import{EventEmitter as ke}from"node:events";import{Worker as Ae}from"node:worker_threads";const je=2e3,Me=process.platform===`win32`;function k(e){return e.exitCode!==null||e.signalCode!==null}function Ne(e,t,n){if(n&&!Me&&typeof e.pid==`number`)try{process.kill(-e.pid,t);return}catch{}try{e.kill(t)}catch{}}function Pe(e,t){if(Me&&typeof e.pid==`number`){re(`taskkill`,[`/pid`,String(e.pid),`/T`,`/F`],{stdio:`ignore`});return}Ne(e,`SIGKILL`,t)}async function Fe(e,t={}){let n=t.graceMs??2e3,r=t.signal??`SIGTERM`,i=t.processGroup??!1;if(!k(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(k(e))return}return new Promise(t=>{let a,o=()=>{a&&clearTimeout(a),t()};if(e.once(`exit`,o),k(e)){e.removeListener(`exit`,o),t();return}Ne(e,r,i),a=setTimeout(()=>{k(e)||Pe(e,i)},n),a.unref?.()})}}function Ie(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(!g(e))throw TypeError(`executionRoot must be an absolute path`);let t;try{t=T(e)}catch{throw TypeError(`executionRoot must name an existing accessible directory`)}if(!D(t).isDirectory())throw TypeError(`executionRoot must name a directory`);try{fe(t,S.R_OK|S.X_OK)}catch{throw TypeError(`executionRoot directory must be readable and traversable`)}return t}function Le(e){let t=[],n=y(e);for(;;)try{return _(T(n),...t)}catch{let r=h(n);if(r===n)return y(e);t.unshift(m(n)),n=r}}function Re(e,t){let n=Le(e),r=Le(t);return r===n||r.startsWith(n+te)}var ze=class extends Error{constructor(e){super(e),this.name=`OwnerOnlyModeError`}};function A(e=process.platform){return e===`win32`?`windows-acl`:`posix-mode`}function Be(e,t){let n=v(e,t);if(n.startsWith(`..`)||g(n))throw new ze(`withinRoot ${e} is not an ancestor of ${t}, so this call cannot own the path between them.`);let r=n.split(te).filter(e=>e.length>0),i=[e],a=e;for(let e of r)a=_(a,e),i.push(a);return i}function j(e,t,n={}){if(A()!==`posix-mode`)return;let r=(n.readMode??(e=>D(e).mode&4095))(e);if(r&63)throw new ze(`${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 Ve(e,t={}){let n=t.makeDirectory??((e,t)=>{w(e,{recursive:!0,mode:t})}),r=t.setMode??((e,t)=>x(e,t));n(e,448);let i=t.withinRoot===void 0?[e]:Be(t.withinRoot,e);for(let e of i)A()===`posix-mode`&&r(e,448),j(e,`directory`,t)}function He(e,t){Ve(h(e));let n=`${e}.${process.pid}.tmp`;ye(n,{force:!0}),Se(n,t,{encoding:`utf8`,mode:384,flag:`wx`});try{j(n,`file`),E(n,e)}catch(e){try{xe(n)}catch{}throw e}j(e,`file`)}function Ue(e){if(A()!==`posix-mode`)return;let t;try{t=D(e).mode&4095}catch{return}t&63&&(x(e,384),j(e,`file`))}function We(e){let t=Ee(e);return t===4?Ge(e.split(`.`).map(Number)):t!==6||Ke(e)}function Ge(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 Ke(e){let t=Je(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?Ge([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 qe(e){let t=e.lastIndexOf(`:`),n=e.slice(t+1);if(!n.includes(`.`))return e;if(t<0||Ee(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 Je(e){let t=qe(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 Ye=3e4,Xe=5e6,Ze=new Set([301,302,303,307,308]),Qe=new Set([`localhost`,`metadata`,`metadata.google.internal`,`metadata.goog`,`instance-data`,`instance-data.ec2.internal`]),$e=async e=>(await Te(e,{all:!0,verbatim:!0})).map(e=>e.address);async function et(e,t={},n=$e){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(Qe.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=Ee(i)?[i]:await tt(i,n);if(a===void 0||a.length===0)return{reason:`unresolvable`,url:r,message:`Destination "${i}" did not resolve.`};let o=a.find(We);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 tt(e,t){try{return await t(e)}catch{return}}async function nt(e,t={},n={},r={}){let i=r.fetch??((e,t)=>globalThis.fetch(e,t)),a=r.lookup??$e,o=t.maxResponseBytes??Xe,s=n.maxRedirects??5,c=AbortSignal.timeout(t.timeoutMs??Ye),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 et(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(!Ze.has(r.status))return at(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=it(d)),u=f}}async function rt(e,t,n={},r={}){let i=r.fetch??((e,t)=>globalThis.fetch(e,t)),a=t.maxResponseBytes??Xe,o=AbortSignal.timeout(t.timeoutMs??Ye),s=t.signal?AbortSignal.any([o,t.signal]):o,c=new URL(e),l=await et(c,n,r.lookup??$e);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.`}}):at(u,c.href,a,s)}function it(e){let t={};for(let[n,r]of Object.entries(e))n.toLowerCase()===`user-agent`&&(t[n]=r);return t}async function at(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 ot(e){return e===void 0?`host`:`sandbox-${e.filesystem??`separate`}`}function st(e){return ot(e)===`sandbox-separate`}function ct(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 lt=/^[A-Za-z]:[\\/]/,ut=/'/g;async function dt(e,t,n={}){if(e.applyManifest)return e.applyManifest(t,n);ct(t);let r=St(n.targetRoot??`/workspace`),i=[];for(let[a,o]of Object.entries(t.entries)){let t=ft(a),s=Ct(r,t);i.push(await pt(e,t,s,r,o,n))}return{entries:i}}function ft(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(`\\`)||lt.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 pt(e,t,n,r,i,a){switch(i.type){case`file`:return await vt(e,n,r,i.content),M(t,i.type);case`dir`:return await N(e,n),M(t,i.type);case`localFile`:return await mt(e,i.src,n,r,a),M(t,i.type);case`localDir`:return await ht(e,i.src,n,a),M(t,i.type);case`gitRepo`:return await _t(e,i,n),M(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 wt(i)}}function M(e,t){return{path:e,type:t,status:`applied`}}async function mt(e,t,n,r,i){await vt(e,n,r,await se(bt(t,i.hostRoot),`utf8`))}async function ht(e,t,n,r){await gt(e,bt(t,r.hostRoot),n)}async function gt(e,t,n){await N(e,n);let r=await ce(t,{withFileTypes:!0});for(let i of r){let r=_(t,i.name),a=Ct(n,i.name);if(i.isDirectory()){await gt(e,r,a);continue}if(i.isFile()){let t=await se(r,`utf8`);await e.writeFile(a,t)}}}async function _t(e,t,n){await yt(e,`git clone${t.shallow===!1?``:` --depth 1`}${t.ref?` --branch ${P(t.ref)}`:``} ${P(t.url)} ${P(n)}`)}async function vt(e,t,n,r){let i=ee.dirname(t);i!==n&&await N(e,i),await e.writeFile(t,r)}async function N(e,t){await yt(e,`mkdir -p ${P(t)}`)}async function yt(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 bt(e,t){return g(e)?y(e):y(t??process.cwd(),e)}function xt(e){let t=e.length;for(;t>0&&e[t-1]===`/`;)--t;return e.slice(0,t)}function St(e){let t=xt(e.replace(/\\/g,`/`));if(!t.startsWith(`/`))throw Error(`workspace manifest targetRoot must be an absolute sandbox path`);return t.length===0?`/`:t}function Ct(e,t){let n=St(e);return n===`/`?`/${t}`:`${n}/${t}`}function P(e){return`'${e.replace(ut,`'\\''`)}'`}function wt(e){throw Error(`unsupported workspace manifest entry: ${JSON.stringify(e)}`)}const F=[`.robota/worktrees`,`.claude/worktrees`];function I(e,t){let n=e.length;for(;n>0&&e[n-1]===`/`;)--n;return`${e.slice(0,n)}/${t}`}function L(){return[...i,...o]}function Tt(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 L()){let i=I(t.root,r);e.exists(i)&&n.push(`--ro-bind`,i,i)}for(let r of F){let i=I(t.root,r);if(e.exists(i)){n.push(`--bind`,i,i);for(let t of e.listDirectory(i)){let r=I(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 Et(e){return e.replace(/[\\^$.*+?()[\]{}|"]/g,e=>`\\${e}`)}function R(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Dt(e){let t=[e.root,...e.tempDirectories,...e.allowWrite].map(e=>`(subpath ${R(e)})`).join(` `),n=L().map(t=>{let n=I(e.root,t);return o.includes(t)?`(literal ${R(n)})`:`(subpath ${R(n)})`}),r=F.map(t=>`(subpath ${R(I(e.root,t))})`),i=[`(literal ${R(I(e.root,`.git`))})`,...F.map(t=>`(regex #"^${Et(I(e.root,t))}/[^/]+/\\.git$")`)],a=[`(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* ${r.join(` `)})`,`(deny file-write* ${i.join(` `)})`];if(e.denyRead.length>0){let t=e.denyRead.map(e=>e.directory?`(subpath ${R(e.path)})`:`(literal ${R(e.path)})`);a.push(`(deny file-read* ${t.join(` `)})`)}return e.network||a.push(`(deny network*)`),a.join(`
2
+ `)}const Ot={x64:{audit:3221225534,socket:41,ioUringSetup:425},arm64:{audit:3221225655,socket:198,ioUringSetup:425}};function z(e,t,n,r){return[e,t,n,r]}function kt(e=process.arch){let t=Ot[e];if(t===void 0)return;let n=e=>327680|e,r=[z(32,0,0,4),z(21,1,0,t.audit),z(6,0,0,n(1)),z(32,0,0,0),z(69,0,1,1073741824),z(6,0,0,n(1)),z(21,0,1,t.ioUringSetup),z(6,0,0,n(1)),z(21,0,3,t.socket),z(32,0,0,16),z(21,0,1,1),z(6,0,0,n(97)),z(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 At=Object.freeze({enabled:!1,autoAllowBashIfSandboxed:!0,excludedCommands:[],allowWrite:[],denyRead:[],network:!1}),jt=`/usr/bin/sandbox-exec`;function Mt(e,t){let n=re(e,[...t],{timeout:5e3,encoding:`utf8`});if(n.error!==void 0)return{ok:!1,detail:n.error.message};let r=(n.stderr??``).trim().split(`
3
+ `)[0];return n.status===0?{ok:!0}:{ok:!1,...r?{detail:r}:{}}}function Nt(e={}){let t=e.platform??process.platform,n=e.probe??Mt;if(t===`linux`){if(kt(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(jt,[`-p`,`(version 1)(allow default)`,`/usr/bin/true`]);return e.ok?{backend:`seatbelt`,executable:jt,missing:[]}:{backend:`seatbelt`,missing:[`sandbox-exec cannot run${e.detail?`: ${e.detail}`:``}`]}}return{missing:[],unsupportedPlatform:t}}function B(e){try{return T(e)}catch{return e}}function Pt(e){try{return D(e).isDirectory()}catch{return!1}}function Ft(e){let t=C(e);if(!t.isSymbolicLink()&&(x(e,t.mode|448),t.isDirectory()))for(let t of _e(e))Ft(`${e}/${t}`)}function It(e){try{return C(e).isSymbolicLink()}catch{return!1}}function Lt(e){return e.trim().split(/\s+/)[0]}var Rt=class{filesystem=`shared`;root;availability;homeDirectory;current;inFlight=0;baseline=[];unresolved=new Map;watchers=new Set;constructor(e){this.root=B(e.root),this.availability=e.availability,this.homeDirectory=e.homeDirectory??Ce(),this.current={...At,...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};for(let e of this.watchers)e(this.current)}watchSettings(e){return this.watchers.add(e),()=>{this.watchers.delete(e)}}confines(e){if(!this.status().active)return!1;if(n(e).length!==1)return!0;let t=Lt(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`,Dt(n),e.command,...e.args],cwd:e.cwd};let i=n.network?void 0:kt();this.protectedEntryStates().some(e=>e.path.endsWith(`/.robota`)&&e.kind===`symlink`)||w(`${this.root}/.robota`,{recursive:!0});let a=Tt({policy:n,exists:e=>he(e)&&!It(e),listDirectory:e=>_e(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 L().map(e=>{let t=`${this.root}/${e}`;try{return C(t).isSymbolicLink()?{path:t,kind:`symlink`,target:ve(t)}:{path:t,kind:`present`}}catch{return{path:t,kind:`missing`}}})}resolvesOutsideWritableWorkspace(e){let t;try{t=T(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()}-${p()}`,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`&&be(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}/${m(e)}`;w(t,{recursive:!0});try{E(e,n)}catch(t){if(this.inFlight>0)throw t;Ft(e),t.code===`EXDEV`?(pe(e,n,{recursive:!0,verbatimSymlinks:!0}),ye(e,{recursive:!0,force:!0})):E(e,n)}return`moved ${e} to ${n}`}policy(){let e=e=>{let t=e===`~`||e.startsWith(`~/`)?`${this.homeDirectory}${e.slice(1)}`:e;return B(g(t)?t:y(this.root,t))},t=[...new Set([we(),`/tmp`].filter(he).map(B))];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:Pt(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=ne(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(ge(e,`utf8`))}writeFile(e,t){return Se(e,t,`utf8`),Promise.resolve()}};function V(e,n,r,i,o={}){return new a({name:e,description:n,parameters:t(r),...o.deferLoading!==void 0&&{deferLoading:o.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 zt={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 Bt(){for(let[e,t]of Object.entries(zt))r(e,t)}Bt();const Vt=1e3,Ht=O.object({activeFiles:O.array(O.string()).optional().describe(`Repo-relative files currently in focus; the map is ranked toward what they reference.`),mentionedIdentifiers:O.array(O.string()).optional().describe(`Symbol names to bias the map toward (e.g. identifiers named in the task).`),tokenBudget:O.number().int().positive().optional().describe(`Maximum tokens for the returned map (default ${Vt}).`)});function Ut(e){return e.map(e=>`${e.file}:${e.line} ${e.kind} ${e.name}`).join(`
4
+ `)}async function Wt(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??Vt});return n.symbols.length===0?`No relevant symbols found within the token budget.`:`Most relevant symbols (~${n.totalTokens} tokens):\n${Ut(n.symbols)}`}function Gt(e={}){return V(`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.`,Ht,async t=>Wt(t,e))}const Kt=`Computer use is not available in this session (no driver injected).`,qt=O.enum([`left`,`right`,`middle`]),Jt=O.object({x:O.number(),y:O.number()}),Yt=O.object({type:O.enum([`click`,`double_click`,`type`,`keypress`,`scroll`,`drag`,`wait`,`takeover`]).describe(`Which action to perform.`),x:O.number().optional().describe(`X coordinate (click/double_click/scroll).`),y:O.number().optional().describe(`Y coordinate (click/double_click/scroll).`),button:qt.optional().describe(`Mouse button (click/double_click/drag).`),text:O.string().optional().describe(`Text to type (type).`),keys:O.array(O.string()).optional().describe(`Keys to press as a chord (keypress).`),deltaX:O.number().optional().describe(`Horizontal wheel delta (scroll).`),deltaY:O.number().optional().describe(`Vertical wheel delta (scroll).`),path:O.array(Jt).optional().describe(`Points to drag through (drag).`),ms:O.number().optional().describe(`Milliseconds to wait (wait).`),reason:O.string().optional().describe(`Human-readable reason surfaced to the user (takeover).`)}),Xt=O.object({action:Yt.describe(`The single mutating action to perform.`)}),Zt=O.object({});var H=class extends Error{};function U(e,t,n){if(typeof e!=`number`)throw new H(`Action '${n}' requires numeric '${t}'.`);return e}function Qt(e){let t=e.button;switch(e.type){case`click`:return{type:`click`,x:U(e.x,`x`,`click`),y:U(e.y,`y`,`click`),...t?{button:t}:{}};case`double_click`:return{type:`double_click`,x:U(e.x,`x`,`double_click`),y:U(e.y,`y`,`double_click`),...t?{button:t}:{}};case`type`:if(typeof e.text!=`string`)throw new H(`Action 'type' requires 'text'.`);return{type:`type`,text:e.text};case`keypress`:if(!e.keys||e.keys.length===0)throw new H(`Action 'keypress' requires non-empty 'keys'.`);return{type:`keypress`,keys:e.keys};case`scroll`:return{type:`scroll`,x:U(e.x,`x`,`scroll`),y:U(e.y,`y`,`scroll`),deltaX:U(e.deltaX,`deltaX`,`scroll`),deltaY:U(e.deltaY,`deltaY`,`scroll`)};case`drag`:if(!e.path||e.path.length<2)throw new H(`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 H(`Unknown action type: ${String(t)}`)}}}async function $t(e){if(!e.driver)return JSON.stringify({success:!1,error:Kt});let t=await e.driver.screenshot();return JSON.stringify(t?{success:!0,screenshot:t}:{success:!0,takeover:!0})}async function en(e,t){if(!t.driver)return JSON.stringify({success:!1,error:Kt});let n;try{n=Qt(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 tn(e={}){return V(`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.`,Zt,async()=>$t(e))}function nn(e={}){return V(`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.",Xt,async t=>en(t,e))}function rn(e={}){return[tn(e),nn(e)]}const an=[{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 on(e,t){let n=t?an.filter(e=>t.includes(e.toolName)):an,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(`
5
+ `)}const W=process.platform!==`win32`,sn=2e6,cn=O.object({command:O.string().describe(`The shell command to execute`),timeout:O.number().optional().describe(`Optional timeout in milliseconds (max 600000). Default is 120000 (2 minutes)`),workingDirectory:O.string().optional().describe(`Working directory for the command. Defaults to the current working directory`)});async function ln(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 un(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 ln(a,l,c??t.cwd,t);let f={command:n.command,args:n.commandArgs(a),cwd:d},p=t.sandboxClient?.wrapCommand?.(f,a)??f,m=!1,h=()=>{if(!m){m=!0;try{return p.afterExit?.()}catch(e){return`[sandbox] clean-up failed: ${e instanceof Error?e.message:String(e)}`}}};return r?.aborted?(h(),JSON.stringify({success:!1,output:``,error:`Aborted before start`})):new Promise(e=>{let t=s({maxBytes:sn}),n=s({maxBytes:sn}),a=!1,o=!1,c;try{c=ne(p.command,[...p.args],{cwd:p.cwd,env:i===void 0?process.env:u(process.env,i),stdio:[`pipe`,`pipe`,`pipe`,...(p.inputDescriptors??[]).map(()=>`pipe`)],detached:W})}catch(t){let n=h(),r=t instanceof Error?t.message:String(t);e(JSON.stringify({success:!1,output:n??``,error:r}));return}(p.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,Fe(c,{processGroup:W}),f({success:!1,output:t.toString(),error:`Command timed out after ${l}ms`})},l);function f(t){o||(o=!0,clearTimeout(d),r?.removeEventListener(`abort`,m),e(JSON.stringify(t)))}function m(){Fe(c,{processGroup:W}),f({success:!1,output:t.toString(),error:`Aborted`})}r?.addEventListener(`abort`,m,{once:!0}),c.on(`error`,e=>{c.pid===void 0&&h(),f({success:!1,output:``,error:e.message})}),c.on(`close`,e=>{let r=h();if(a){f({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;f({success:!0,output:r===void 0?c:`${c}\n${r}`,exitCode:s})})})}function dn(e,t){let n=l({executable:t.shellExecutable});return V(e,t.description??on(n,t.availableTools),cn,async(e,r)=>un(e,t,n,r?.signal,r?.shellTraceEnv))}function fn(e){return dn(`Shell`,e)}function pn(e){return dn(`Bash`,e)}function G(e,t){return t!==void 0&&Re(t,e)}function K(e,t){return t===void 0?e:y(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(!G(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?y(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=O.object({filePath:O.string().describe(`The absolute path to the file to read`),offset:O.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:O.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(`
6
6
  `)}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(`
7
- `,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:K(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 S(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 ie(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 V(`Read`,e.description??`Reads a file from the local filesystem.
7
+ `,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:K(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=e=>JSON.stringify({success:!1,output:``,error:e}),c;try{c=await oe(i,S.O_RDONLY|S.O_NONBLOCK,384)}catch(e){let t=await b(i).catch(()=>void 0);return t===void 0?s(`File not found: ${i}`):t.isFile()?s(e instanceof Error?e.message:String(e)):s(`Path is not a file: ${i}`)}let l=Buffer.alloc(0),u=!1;try{if(!(await c.stat()).isFile())return s(`Path is not a file: ${i}`);let e=[],n=Buffer.allocUnsafe(65536),r=0,a=0;for(;r<=J;){if(t.signal?.aborted)throw new X;let{bytesRead:i}=await c.read(n,0,Math.min(n.length,4194305-r),null);if(i===0)break;let o=Math.min(i,8192-a);if(o>0&&_n(n.subarray(0,o))){u=!0;break}if(a+=o,r+=i,r>J)throw new Y(`input`);e.push(Buffer.from(n.subarray(0,i)))}u||(l=Buffer.concat(e,r))}catch(e){if(e instanceof Y||e instanceof X)throw e;return s(e instanceof Error?e.message:String(e))}finally{await c.close()}if(t.signal?.aborted)throw new X;if(u){let e={success:!1,output:``,error:`Binary file not supported: ${i}`};return JSON.stringify(e)}return yn(i,l.toString(`utf8`),a,r)}function xn(e){return V(`Read`,e.description??`Reads a file from the local filesystem.
8
8
 
9
9
  By default, reads up to 2000 lines from the beginning of the file. You can optionally specify offset and limit for partial reads.
10
10
 
11
11
  Results are returned using cat -n format, with line numbers starting at 1.
12
12
 
13
- The filePath parameter must be an absolute path, not a relative path.`,gn,async t=>bn(t,e))}function Sn(e){let t=h(e),n=m(e),r=f(6).toString(`hex`);return _(t,`.${n}.atomic-tmp-${process.pid}-${Date.now()}-${r}`)}async function Cn(e){try{return(await S(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 re(h(e),{recursive:!0});let n=await Cn(e),r=Sn(e);try{await le(r,t,`utf8`),n!==void 0&&await ne(r,n),await se(r,e)}catch(e){throw await ce(r,{force:!0}).catch(()=>void 0),e}}const En=D.object({filePath:D.string().describe(`The absolute path to the file to write`),content:D.string().describe(`The content to write to the file`)});async function Dn(e,t){let{content:n}=e,r=t.sandboxClient?e.filePath:K(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 V(`Write`,e.description??`Writes a file to the local filesystem. This will overwrite an existing file if one exists.
13
+ The filePath parameter must be an absolute path, not a relative path.`,gn,async t=>bn(t,e))}function Sn(e){let t=h(e),n=m(e),r=f(6).toString(`hex`);return _(t,`.${n}.atomic-tmp-${process.pid}-${Date.now()}-${r}`)}async function Cn(e){try{return(await b(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 ae(h(e),{recursive:!0});let n=await Cn(e),r=Sn(e);try{await de(r,t,`utf8`),n!==void 0&&await ie(r,n),await le(r,e)}catch(e){throw await ue(r,{force:!0}).catch(()=>void 0),e}}const En=O.object({filePath:O.string().describe(`The absolute path to the file to write`),content:O.string().describe(`The content to write to the file`)});async function Dn(e,t){let{content:n}=e,r=t.sandboxClient?e.filePath:K(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 V(`Write`,e.description??`Writes a file to the local filesystem. This will overwrite an existing file if one exists.
14
14
 
15
15
  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.
16
16
 
17
- Parent directories are created automatically when missing.`,En,async t=>Dn(t,e))}const kn=D.object({filePath:D.string().describe(`The absolute path to the file to modify`),oldString:D.string().describe(`The text to replace (must be an exact match of existing content)`),newString:D.string().describe(`The text to replace it with (must be different from oldString)`),replaceAll:D.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=me(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:K(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(`
17
+ Parent directories are created automatically when missing.`,En,async t=>Dn(t,e))}const kn=O.object({filePath:O.string().describe(`The absolute path to the file to modify`),oldString:O.string().describe(`The text to replace (must be an exact match of existing content)`),newString:O.string().describe(`The text to replace it with (must be different from oldString)`),replaceAll:O.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=me(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:K(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(`
18
18
  `).length:1,m={success:!0,output:`Replaced ${c} occurrence(s) in ${a}`,startLine:p};return JSON.stringify(m)}function Nn(e){return V(`Edit`,e.description??`Performs exact string replacements in files.
19
19
 
20
20
  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.
21
21
 
22
- 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=D.object({pattern:D.string().describe(`The glob pattern to match files against (e.g. "**/*.ts", "src/**/*.tsx")`),path:D.string().optional().describe(`The directory to search in. Defaults to the current working directory. Must be a valid directory path if provided`),limit:D.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=ke(100);return(await Promise.all(e.map(e=>r(async()=>{let r=b(t,e);if(G(r,n))try{return{path:e,mtime:(await S(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=Oe.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(`
22
+ 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=O.object({pattern:O.string().describe(`The glob pattern to match files against (e.g. "**/*.ts", "src/**/*.tsx")`),path:O.string().optional().describe(`The directory to search in. Defaults to the current working directory. Must be a valid directory path if provided`),limit:O.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=Oe(100);return(await Promise.all(e.map(e=>r(async()=>{let r=y(t,e);if(G(r,n))try{return{path:e,mtime:(await b(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=De.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(`
23
23
  `):`(no matches)`;return m&&(g+=`\n\n[Showing ${f} of ${p} matches. Use limit parameter to see more.]`),u&&(g+=`
24
24
 
25
25
  [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 V(`Glob`,e.description??`Fast file pattern matching tool that works with any codebase size.
@@ -28,7 +28,7 @@ Supports glob patterns like '**/*.js' or 'src/**/*.ts'. Returns matching file pa
28
28
 
29
29
  Use this tool when you need to find files by name patterns.
30
30
 
31
- 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 oe(e)}catch{return}for(let l of c){if(o)return;if(l===`node_modules`||l===`.git`)continue;let c=_(e,l);if(!G(c,n))continue;if(a>=r){o=!0;return}a++;let u;try{u=await S(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(`
31
+ 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 ce(e)}catch{return}for(let l of c){if(o)return;if(l===`node_modules`||l===`.git`)continue;let c=_(e,l);if(!G(c,n))continue;if(a>=r){o=!0;return}a++;let u;try{u=await b(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(`
32
32
  `),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=`
33
33
  const { parentPort } = require('node:worker_threads');
34
34
  const searchFile = ${Hn.toString()};
@@ -43,7 +43,7 @@ parentPort.on('message', (request) => {
43
43
  parentPort.postMessage({ id: request.id, matches });
44
44
  } catch (error) { parentPort.postMessage({ id: request.id, error: error?.message === 'byte limit' ? 'Grep search exceeded its byte limit' : 'Invalid grep regex execution' }); }
45
45
  });
46
- `;var Wn=class extends Ae{child=x(process.execPath,[`-e`,`
46
+ `;var Wn=class extends ke{child=ne(process.execPath,[`-e`,`
47
47
  const searchFile = ${Hn.toString()};
48
48
  const readline = require('node:readline');
49
49
  let outputBytes = 0;
@@ -58,10 +58,10 @@ readline.createInterface({ input: process.stdin }).on('line', line => {
58
58
  process.stdout.write(JSON.stringify({ id: request.id, matches }) + String.fromCharCode(10));
59
59
  } 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)); }
60
60
  });
61
- `],{env:{BUN_BE_BUN:`1`,...process.env.SystemRoot?{SystemRoot:process.env.SystemRoot}:{}},cwd:Te(),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(`
61
+ `],{env:{BUN_BE_BUN:`1`,...process.env.SystemRoot?{SystemRoot:process.env.SystemRoot}:{}},cwd:we(),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(`
62
62
  `))>=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)+`
63
- `)}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 je(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=D.object({pattern:D.string().describe(`The regular expression pattern to search for in file contents`),path:D.string().optional().describe(`File or directory to search in. Defaults to the current working directory`),glob:D.string().optional().describe(`Glob pattern to filter files (e.g. "*.ts", "*.{ts,tsx}"). Only files matching this pattern will be searched`),contextLines:D.number().optional().describe(`Number of context lines to show before and after each match. Only applies when outputMode is "content". Default: 0`),outputMode:D.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:D.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 S(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 S(e)).size>qn)throw new Q(`limit`);let n=me(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(`
64
- `):`(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 V(`Grep`,e.description??Yn(e.shellToolName??`Shell`),Kn,async t=>Jn(t,e))}const Zn=3e4,Qn=5e6,$n=D.object({url:D.string().describe(`The URL to fetch`),headers:D.record(D.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 et(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 V(`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=D.object({query:D.string().describe(`The search query`),limit:D.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 V(`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=D.object({question:D.string().min(1).describe(`The complete question to ask the user.`),header:D.string().optional().describe(`Very short topic label for the question (e.g. "Auth method").`),options:D.array(D.union([D.string().min(1).describe(`Display text of this choice.`),D.object({label:D.string().min(1).describe(`Display text of this choice.`),description:D.string().optional().describe(`What choosing this option means.`)})])).optional().describe(`Predefined choices (strings or {label, description}). Omit for pure free text.`),multiSelect:D.boolean().optional().describe(`Allow selecting multiple options (default: single select).`),allowFreeText:D.boolean().optional().describe(`Allow a typed custom answer besides the options (default: true).`)}),hr=D.object({questions:D.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(`
65
- `);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_${p()}`,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 V(`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=n,wr=D.object({query:D.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:D.array(D.string().min(1)).optional().describe(`Exact tool names to load, skipping the search. An unknown name is an error naming it.`),limit:D.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(`
66
- `);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 V(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{N as A,pr as C,et as D,A as E,Ie as M,k as N,tt as O,Me as P,cr as S,Re as T,On as _,X as a,Nt as b,pn as c,Rn as d,Xn as f,Or as g,fn as h,Y as i,He as j,Ue as k,rn as l,Gt as m,Q as n,lt as o,xn as p,Rt as r,yr as s,At as t,Nn as u,V as v,Ve as w,at as x,it as y};
67
- //# sourceMappingURL=node-hHzxDyjn.js.map
63
+ `)}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 Ae(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=O.object({pattern:O.string().describe(`The regular expression pattern to search for in file contents`),path:O.string().optional().describe(`File or directory to search in. Defaults to the current working directory`),glob:O.string().optional().describe(`Glob pattern to filter files (e.g. "*.ts", "*.{ts,tsx}"). Only files matching this pattern will be searched`),contextLines:O.number().optional().describe(`Number of context lines to show before and after each match. Only applies when outputMode is "content". Default: 0`),outputMode:O.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:O.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 b(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 b(e)).size>qn)throw new Q(`limit`);let n=me(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 ee=0;for(let e of _)for(let t of e)if(ee+=Buffer.byteLength(t,`utf8`)+1,ee>4*1024*1024)throw new Q(`limit`);let v=_.flat();if(s!==void 0&&v.length>s){let e=v.length-s;v=[...v.slice(0,s),`(+${e} more results truncated by headLimit)`]}p&&(v=[...v,`[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 y={success:!0,output:v.length>0?v.join(`
64
+ `):`(no matches)`};return JSON.stringify(y)}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 V(`Grep`,e.description??Yn(e.shellToolName??`Shell`),Kn,async t=>Jn(t,e))}const Zn=3e4,Qn=5e6,$n=O.object({url:O.string().describe(`The URL to fetch`),headers:O.record(O.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 nt(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 V(`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=O.object({query:O.string().describe(`The search query`),limit:O.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 V(`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=O.object({question:O.string().min(1).describe(`The complete question to ask the user.`),header:O.string().optional().describe(`Very short topic label for the question (e.g. "Auth method").`),options:O.array(O.union([O.string().min(1).describe(`Display text of this choice.`),O.object({label:O.string().min(1).describe(`Display text of this choice.`),description:O.string().optional().describe(`What choosing this option means.`)})])).optional().describe(`Predefined choices (strings or {label, description}). Omit for pure free text.`),multiSelect:O.boolean().optional().describe(`Allow selecting multiple options (default: single select).`),allowFreeText:O.boolean().optional().describe(`Allow a typed custom answer besides the options (default: true).`)}),hr=O.object({questions:O.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(`
65
+ `);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_${p()}`,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 V(`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=O.object({query:O.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:O.array(O.string().min(1)).optional().describe(`Exact tool names to load, skipping the search. An unknown name is an error naming it.`),limit:O.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(`
66
+ `);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 V(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{et as A,pr as C,nt as D,A as E,Ie as M,Fe as N,rt as O,je as P,cr as S,Re as T,On as _,X as a,Nt as b,pn as c,Rn as d,Xn as f,Or as g,fn as h,Y as i,He as j,Ue as k,rn as l,Gt as m,Q as n,dt as o,xn as p,Rt as r,yr as s,At as t,Nn as u,V as v,Ve as w,st as x,ot as y};
67
+ //# sourceMappingURL=node-CC5tfdMu.js.map