@swifty.js/swifty 0.0.33 → 0.0.36

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 (70) hide show
  1. package/dist/acp-ZU5LZRUP.js +14 -0
  2. package/dist/agent-YDU6HB4S.js +4 -0
  3. package/dist/{anthropic-FXRRA63E.js → anthropic-GDT73MMP.js} +1 -1
  4. package/dist/bwrap-4KOC7P3X.js +4 -0
  5. package/dist/{chunk-IKQTIDRL.js → chunk-325L2ILZ.js} +1 -1
  6. package/dist/chunk-44LPRRYU.js +60 -0
  7. package/dist/chunk-5W2TCASL.js +4 -0
  8. package/dist/{providers-WNYZUMZ3.js → chunk-EEEW3GG4.js} +3 -3
  9. package/dist/{chunk-4PQYUHSN.js → chunk-H56UQALW.js} +1 -1
  10. package/dist/chunk-IXCJZNBB.js +5 -0
  11. package/dist/chunk-JC44NVST.js +4 -0
  12. package/dist/{chunk-PXQD6GWP.js → chunk-MNP6IJ7C.js} +17 -17
  13. package/dist/chunk-MTAGHTBG.js +164 -0
  14. package/dist/chunk-NDPYUGE5.js +5 -0
  15. package/dist/chunk-PH643I2P.js +4 -0
  16. package/dist/{chunk-TNF3EHFY.js → chunk-Q3NPRV5P.js} +1 -1
  17. package/dist/chunk-RDVRYI56.js +610 -0
  18. package/dist/{chunk-4C3KJLJV.js → chunk-UJGMTIYO.js} +1 -1
  19. package/dist/{esm-4DBD7ONK.js → esm-PDXUGWFK.js} +1 -1
  20. package/dist/lib/agent-ZMIS6IH6.js +16 -0
  21. package/dist/lib/{anthropic-B33M2AVN.js → anthropic-FKIGL7NL.js} +6 -5
  22. package/dist/lib/bwrap-2OL7VPSO.js +7 -0
  23. package/dist/lib/{chunk-FODSMOWP.js → chunk-6V7RW6HA.js} +34 -16
  24. package/dist/lib/{chunk-TJLAJGG4.js → chunk-ALQHMYOZ.js} +14 -3
  25. package/dist/lib/{chunk-CFYAZWDA.js → chunk-BHSNJT6Z.js} +34 -56
  26. package/dist/lib/{chunk-XT67KGWE.js → chunk-BQFVUVLI.js} +12 -2
  27. package/dist/lib/chunk-FFM2LB4C.js +132 -0
  28. package/dist/lib/{chunk-VUD72RTY.js → chunk-FLKB4BK7.js} +16 -5
  29. package/dist/lib/{chunk-3OFLDUAW.js → chunk-HQSYRTER.js} +96 -49
  30. package/dist/lib/{chunk-LDWFI6MR.js → chunk-LRN4MOQ3.js} +25 -1
  31. package/dist/lib/chunk-MLKGABMK.js +9 -0
  32. package/dist/lib/{chunk-BCBD34D2.js → chunk-OLFXCZVH.js} +25 -7
  33. package/dist/lib/{providers-UJEWP7C7.js → chunk-PJ7354ZG.js} +46 -3
  34. package/dist/lib/chunk-YIWNQ7OA.js +47 -0
  35. package/dist/lib/{chunk-AFYPVA5C.js → chunk-YUDCYSKO.js} +958 -112
  36. package/dist/lib/{chunk-3XCGUKGJ.js → chunk-ZPIF7IJN.js} +219 -6
  37. package/dist/lib/index.d.ts +3771 -1322
  38. package/dist/lib/index.js +13714 -12463
  39. package/dist/lib/{openai-C2PZFGJ2.js → openai-ZWIYIBLC.js} +4 -3
  40. package/dist/lib/{checker-UPY4CXUL.js → permissions-77UJQITR.js} +4 -3
  41. package/dist/lib/providers-5SJFTU2G.js +9 -0
  42. package/dist/lib/sandbox-runtime-CCQ3X3SM.js +9 -0
  43. package/dist/lib/seatbelt-WO7YWKLR.js +7 -0
  44. package/dist/lib/{tool-filter-BFEINZIA.js → tool-filter-QU4LOZII.js} +2 -1
  45. package/dist/main.js +225 -191
  46. package/dist/{openai-WPEICAZ4.js → openai-7LMX5HKW.js} +1 -1
  47. package/dist/permissions-74IHQW76.js +4 -0
  48. package/dist/providers-FQCJFM3Q.js +4 -0
  49. package/dist/sandbox-runtime-RVW4BK3L.js +4 -0
  50. package/dist/seatbelt-GMQUP6SV.js +4 -0
  51. package/dist/server-C6H5ZWUG.js +4 -0
  52. package/dist/{tool-filter-X6IYME2K.js → tool-filter-U5SSL3LR.js} +1 -1
  53. package/package.json +6 -3
  54. package/dist/acp-5WRTN2LL.js +0 -14
  55. package/dist/agent-3CAPJCPD.js +0 -4
  56. package/dist/bwrap-ZTS67W2K.js +0 -4
  57. package/dist/checker-3O7QF7XV.js +0 -4
  58. package/dist/chunk-4HSQBZBI.js +0 -4
  59. package/dist/chunk-C5WLP3DH.js +0 -5
  60. package/dist/chunk-FUKVR3XO.js +0 -608
  61. package/dist/chunk-LHSUYZO5.js +0 -4
  62. package/dist/chunk-NAAAN2TD.js +0 -60
  63. package/dist/chunk-YIKI3EPG.js +0 -150
  64. package/dist/lib/agent-NNYCUIOF.js +0 -10
  65. package/dist/lib/bwrap-QRGPUP4J.js +0 -6
  66. package/dist/lib/chunk-GTHYQZRL.js +0 -31
  67. package/dist/lib/chunk-ORSYNBMM.js +0 -38
  68. package/dist/lib/seatbelt-FT5IY73W.js +0 -6
  69. package/dist/seatbelt-PSPJ5LBR.js +0 -5
  70. package/dist/server-YPBLBRDN.js +0 -4
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __swiftyCreateRequire } from "node:module";
3
3
  const require = __swiftyCreateRequire(import.meta.url);
4
- var d=class{tools=new Map;discovered=new Set;mcpLoadingMode="eager";exposeToolSearch=!1;exposeMcpCall=!1;register(e){this.tools.set(e.name,e)}unregister(e){this.tools.delete(e),this.discovered.delete(e)}get(e){return this.tools.get(e)}listTools(){return[...this.tools.values()]}getAllSchemas(e,o){let t=e??"anthropic",l=t==="openai"||t==="openai-compat",r=this.mcpLoadingMode==="native"&&!l,n=[];for(let i of this.tools.values()){if(o&&!o(i.name)||i.name==="ToolSearch"&&!this.exposeToolSearch||i.name==="McpCall"&&!this.exposeMcpCall)continue;let c=!!i.deferred&&!this.discovered.has(i.name);if(c&&!r)continue;let p=e?i.providerSchema?.(t):void 0;if(p){n.push(p);continue}let s=i.schema();t==="openai"?n.push({strict:s.strict??!1,type:"function",name:s.name,description:s.description,parameters:s.input_schema}):t==="openai-compat"?n.push({type:"function",function:{name:s.name,description:s.description,parameters:s.input_schema,strict:s.strict??!1}}):n.push({...s,type:"custom",...c?{defer_loading:!0}:{}})}return n}getDeferredToolNames(){let e=[];for(let o of this.tools.values())o.deferred&&!this.discovered.has(o.name)&&e.push(o.name);return e.sort()}getDeferredTools(){return[...this.tools.values()].filter(e=>e.deferred&&!this.discovered.has(e.name))}searchDeferred(e,o=5){let t=e.toLowerCase(),l=[];for(let r of this.tools.values())if(!(!r.deferred||this.discovered.has(r.name))&&(r.name.toLowerCase().includes(t)||r.description.toLowerCase().includes(t))&&(l.push(r),l.length>=o))break;return l}findDeferredByNames(e){let o=new Map;for(let[t,l]of this.tools)o.set(t.toLowerCase(),l);return e.map(t=>o.get(t.toLowerCase())).filter(t=>t?.deferred??!1)}markDiscovered(e){this.discovered.add(e)}isDiscovered(e){return this.discovered.has(e)}};var h=new Set(["ComputerUse","AskUserQuestion","ExitPlanMode"]),m=new Set([...h,"Agent","TaskStop"]),L=new Set(["TeamCreate","TeamDelete"]),T=new Set(["ExitPlanMode","Agent","AskUserQuestion","TaskStop"]),f=new Set(["ReadFile","Grep","Glob","Bash","PowerShell","EditFile","WriteFile","LoadSkill","SyntheticOutput","ToolSearch","EnterWorktree","ExitWorktree","McpCall"]);function g(a){return a.startsWith("mcp__")}function O(a,e,o,t,l=!1){let r=new Set(o??[]),n=new Set(e??[]),i=n.size>0&&!(n.size===1&&n.has("*")),c=new d;c.mcpLoadingMode=a.mcpLoadingMode;for(let p of a.listTools()){let s=p.name;if(g(s)){!r.has(s)&&(!i||n.has(s))&&c.register(p);continue}m.has(s)||l&&T.has(s)||t&&!f.has(s)||r.has(s)||i&&!n.has(s)||c.register(p)}return c}var u="agent:builtin:fork";function v(a){let e=new d;e.mcpLoadingMode=a.mcpLoadingMode;for(let o of a.listTools())if(!h.has(o.name))if(o.name==="Agent"&&"querySource"in o){let t=Object.create(Object.getPrototypeOf(o),Object.getOwnPropertyDescriptors(o));t.querySource=u,e.register(t)}else e.register(o);return e}export{d as a,h as b,m as c,L as d,T as e,f,O as g,u as h,v as i};
4
+ var d=class{tools=new Map;discovered=new Set;mcpLoadingMode="eager";exposeToolSearch=!1;exposeMcpCall=!1;register(e){this.tools.set(e.name,e)}unregister(e){this.tools.delete(e),this.discovered.delete(e)}get(e){return this.tools.get(e)}listTools(){return[...this.tools.values()]}getAllSchemas(e,o){let t=e??"anthropic",a=t==="openai"||t==="openai-compat",r=this.mcpLoadingMode==="native"&&!a,n=[];for(let i of this.tools.values()){if(o&&!o(i.name)||i.name==="ToolSearch"&&!this.exposeToolSearch||i.name==="McpCall"&&!this.exposeMcpCall)continue;let c=!!i.deferred&&!this.discovered.has(i.name);if(c&&!r)continue;let p=e?i.providerSchema?.(t):void 0;if(p){n.push(p);continue}let s=i.schema();t==="openai"?n.push({strict:s.strict??!1,type:"function",name:s.name,description:s.description,parameters:s.input_schema}):t==="openai-compat"?n.push({type:"function",function:{name:s.name,description:s.description,parameters:s.input_schema,strict:s.strict??!1}}):n.push({...s,type:"custom",...c?{defer_loading:!0}:{}})}return n}getDeferredToolNames(){let e=[];for(let o of this.tools.values())o.deferred&&!this.discovered.has(o.name)&&e.push(o.name);return e.sort()}getDeferredTools(){return[...this.tools.values()].filter(e=>e.deferred&&!this.discovered.has(e.name))}searchDeferred(e,o=5){let t=e.toLowerCase(),a=[];for(let r of this.tools.values())if(!(!r.deferred||this.discovered.has(r.name))&&(r.name.toLowerCase().includes(t)||r.description.toLowerCase().includes(t))&&(a.push(r),a.length>=o))break;return a}findDeferredByNames(e){let o=new Map;for(let[t,a]of this.tools)o.set(t.toLowerCase(),a);return e.map(t=>o.get(t.toLowerCase())).filter(t=>t?.deferred??!1)}markDiscovered(e){this.discovered.add(e)}isDiscovered(e){return this.discovered.has(e)}};var h=new Set(["ComputerUse","AskUserQuestion","ExitPlanMode"]),m=new Set([...h,"Agent","TaskStop"]),v=new Set(["TeamCreate","TeamDelete"]),T=new Set(["ExitPlanMode","Agent","AskUserQuestion","TaskStop"]),f=new Set(["ReadFile","Grep","Glob","Bash","JavaScript","PowerShell","EditFile","WriteFile","LoadSkill","SyntheticOutput","ToolSearch","EnterWorktree","ExitWorktree","McpCall"]);function g(l){return l.startsWith("mcp__")}function L(l,e,o,t,a=!1){let r=new Set(o??[]),n=new Set(e??[]),i=n.size>0&&!(n.size===1&&n.has("*")),c=new d;c.mcpLoadingMode=l.mcpLoadingMode;for(let p of l.listTools()){let s=p.name;if(g(s)){!r.has(s)&&(!i||n.has(s))&&c.register(p);continue}m.has(s)||a&&T.has(s)||t&&!f.has(s)||r.has(s)||i&&!n.has(s)||c.register(p)}return c}var u="agent:builtin:fork";function O(l){let e=new d;e.mcpLoadingMode=l.mcpLoadingMode;for(let o of l.listTools())if(!h.has(o.name))if(o.name==="Agent"&&"querySource"in o){let t=Object.create(Object.getPrototypeOf(o),Object.getOwnPropertyDescriptors(o));t.querySource=u,e.register(t)}else e.register(o);return e}export{d as a,h as b,m as c,v as d,T as e,f,L as g,u as h,O as i};
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __swiftyCreateRequire } from "node:module";
3
3
  const require = __swiftyCreateRequire(import.meta.url);
4
- import{a as Rr,c as lv}from"./chunk-XGUH7SGV.js";import{a as B2}from"./chunk-I7XJSLRI.js";import{F as y_,G as av,M as cv,a as ks,b as Ls,d as sv,r as zp}from"./chunk-YKWIZE5D.js";import{a as ov,c as Li,d as Jp,g as vr,h as iv,k as b_,m as vt,n as Dn,o as pe,p as on,q as $p,r as uo,s as he,u as at}from"./chunk-LC7ZWLIH.js";import{a as Lt,c as Nr,d as rv,e as Qp}from"./chunk-IZ7QOBSB.js";var fk=Nr((kTe,mk)=>{"use strict";var Ha=1e3,Fa=Ha*60,Wa=Fa*60,cs=Wa*24,tZ=cs*7,nZ=cs*365.25;mk.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return rZ(e);if(n==="number"&&isFinite(e))return t.long?iZ(e):oZ(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function rZ(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*nZ;case"weeks":case"week":case"w":return n*tZ;case"days":case"day":case"d":return n*cs;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Wa;case"minutes":case"minute":case"mins":case"min":case"m":return n*Fa;case"seconds":case"second":case"secs":case"sec":case"s":return n*Ha;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function oZ(e){var t=Math.abs(e);return t>=cs?Math.round(e/cs)+"d":t>=Wa?Math.round(e/Wa)+"h":t>=Fa?Math.round(e/Fa)+"m":t>=Ha?Math.round(e/Ha)+"s":e+"ms"}function iZ(e){var t=Math.abs(e);return t>=cs?zd(e,t,cs,"day"):t>=Wa?zd(e,t,Wa,"hour"):t>=Fa?zd(e,t,Fa,"minute"):t>=Ha?zd(e,t,Ha,"second"):e+" ms"}function zd(e,t,n,r){var o=t>=n*1.5;return Math.round(e/n)+" "+r+(o?"s":"")}});var Qy=Nr((LTe,gk)=>{"use strict";function sZ(e){n.debug=n,n.default=n,n.coerce=a,n.disable=s,n.enable=o,n.enabled=c,n.humanize=fk(),n.destroy=l,Object.keys(e).forEach(p=>{n[p]=e[p]}),n.names=[],n.skips=[],n.formatters={};function t(p){let u=0;for(let d=0;d<p.length;d++)u=(u<<5)-u+p.charCodeAt(d),u|=0;return n.colors[Math.abs(u)%n.colors.length]}n.selectColor=t;function n(p){let u,d=null,m,_;function h(...b){if(!h.enabled)return;let N=h,L=Number(new Date),R=L-(u||L);N.diff=R,N.prev=u,N.curr=L,u=L,b[0]=n.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let v=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(G,I)=>{if(G==="%%")return"%";v++;let B=n.formatters[I];if(typeof B=="function"){let k=b[v];G=B.call(N,k),b.splice(v,1),v--}return G}),n.formatArgs.call(N,b),(N.log||n.log).apply(N,b)}return h.namespace=p,h.useColors=n.useColors(),h.color=n.selectColor(p),h.extend=r,h.destroy=n.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(m!==n.namespaces&&(m=n.namespaces,_=n.enabled(p)),_),set:b=>{d=b}}),typeof n.init=="function"&&n.init(h),h}function r(p,u){let d=n(this.namespace+(typeof u>"u"?":":u)+p);return d.log=this.log,d}function o(p){n.save(p),n.namespaces=p,n.names=[],n.skips=[];let u=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of u)d[0]==="-"?n.skips.push(d.slice(1)):n.names.push(d)}function i(p,u){let d=0,m=0,_=-1,h=0;for(;d<p.length;)if(m<u.length&&(u[m]===p[d]||u[m]==="*"))u[m]==="*"?(_=m,h=d,m++):(d++,m++);else if(_!==-1)m=_+1,h++,d=h;else return!1;for(;m<u.length&&u[m]==="*";)m++;return m===u.length}function s(){let p=[...n.names,...n.skips.map(u=>"-"+u)].join(",");return n.enable(""),p}function c(p){for(let u of n.skips)if(i(p,u))return!1;for(let u of n.names)if(i(p,u))return!0;return!1}function a(p){return p instanceof Error?p.stack||p.message:p}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}gk.exports=sZ});var _k=Nr((En,em)=>{"use strict";En.formatArgs=cZ;En.save=lZ;En.load=pZ;En.useColors=aZ;En.storage=uZ();En.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();En.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function aZ(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function cZ(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+em.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let n=0,r=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(n++,o==="%c"&&(r=n))}),e.splice(r,0,t)}En.log=console.debug||console.log||(()=>{});function lZ(e){try{e?En.storage.setItem("debug",e):En.storage.removeItem("debug")}catch{}}function pZ(){let e;try{e=En.storage.getItem("debug")||En.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function uZ(){try{return localStorage}catch{}}em.exports=Qy()(En);var{formatters:dZ}=em.exports;dZ.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var yk=Nr((MTe,bk)=>{"use strict";var mZ=Lt("os"),hk=Lt("tty"),Zn=B2(),{env:xt}=process,tm;Zn("no-color")||Zn("no-colors")||Zn("color=false")||Zn("color=never")?tm=0:(Zn("color")||Zn("colors")||Zn("color=true")||Zn("color=always"))&&(tm=1);function fZ(){if("FORCE_COLOR"in xt)return xt.FORCE_COLOR==="true"?1:xt.FORCE_COLOR==="false"?0:xt.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(xt.FORCE_COLOR,10),3)}function gZ(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function _Z(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=fZ();r!==void 0&&(tm=r);let o=n?tm:r;if(o===0)return 0;if(n){if(Zn("color=16m")||Zn("color=full")||Zn("color=truecolor"))return 3;if(Zn("color=256"))return 2}if(e&&!t&&o===void 0)return 0;let i=o||0;if(xt.TERM==="dumb")return i;if(process.platform==="win32"){let s=mZ.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in xt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(s=>s in xt)||xt.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in xt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(xt.TEAMCITY_VERSION)?1:0;if(xt.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in xt){let s=Number.parseInt((xt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(xt.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(xt.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(xt.TERM)||"COLORTERM"in xt?1:i}function Jy(e,t={}){let n=_Z(e,{streamIsTTY:e&&e.isTTY,...t});return gZ(n)}bk.exports={supportsColor:Jy,stdout:Jy({isTTY:hk.isatty(1)}),stderr:Jy({isTTY:hk.isatty(2)})}});var Ek=Nr((Pt,rm)=>{"use strict";var hZ=Lt("tty"),nm=Lt("util");Pt.init=AZ;Pt.log=EZ;Pt.formatArgs=yZ;Pt.save=TZ;Pt.load=IZ;Pt.useColors=bZ;Pt.destroy=nm.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Pt.colors=[6,2,3,4,5,1];try{let e=yk();e&&(e.stderr||e).level>=2&&(Pt.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}Pt.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(o,i)=>i.toUpperCase()),r=process.env[t];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),e[n]=r,e},{});function bZ(){return"colors"in Pt.inspectOpts?!!Pt.inspectOpts.colors:hZ.isatty(process.stderr.fd)}function yZ(e){let{namespace:t,useColors:n}=this;if(n){let r=this.color,o="\x1B[3"+(r<8?r:"8;5;"+r),i=` ${o};1m${t} \x1B[0m`;e[0]=i+e[0].split(`
4
+ import{a as B2}from"./chunk-I7XJSLRI.js";import{a as Rr,c as lv}from"./chunk-XGUH7SGV.js";import{F as y_,G as av,M as cv,a as ks,b as Ls,d as sv,r as zp}from"./chunk-YKWIZE5D.js";import{a as ov,c as Li,d as Jp,g as vr,h as iv,k as b_,m as vt,n as Dn,o as pe,p as on,q as $p,r as uo,s as he,u as at}from"./chunk-LC7ZWLIH.js";import{a as Lt,c as Nr,d as rv,e as Qp}from"./chunk-IZ7QOBSB.js";var fk=Nr((kTe,mk)=>{"use strict";var Ha=1e3,Fa=Ha*60,Wa=Fa*60,cs=Wa*24,tZ=cs*7,nZ=cs*365.25;mk.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return rZ(e);if(n==="number"&&isFinite(e))return t.long?iZ(e):oZ(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function rZ(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*nZ;case"weeks":case"week":case"w":return n*tZ;case"days":case"day":case"d":return n*cs;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Wa;case"minutes":case"minute":case"mins":case"min":case"m":return n*Fa;case"seconds":case"second":case"secs":case"sec":case"s":return n*Ha;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function oZ(e){var t=Math.abs(e);return t>=cs?Math.round(e/cs)+"d":t>=Wa?Math.round(e/Wa)+"h":t>=Fa?Math.round(e/Fa)+"m":t>=Ha?Math.round(e/Ha)+"s":e+"ms"}function iZ(e){var t=Math.abs(e);return t>=cs?zd(e,t,cs,"day"):t>=Wa?zd(e,t,Wa,"hour"):t>=Fa?zd(e,t,Fa,"minute"):t>=Ha?zd(e,t,Ha,"second"):e+" ms"}function zd(e,t,n,r){var o=t>=n*1.5;return Math.round(e/n)+" "+r+(o?"s":"")}});var Qy=Nr((LTe,gk)=>{"use strict";function sZ(e){n.debug=n,n.default=n,n.coerce=a,n.disable=s,n.enable=o,n.enabled=c,n.humanize=fk(),n.destroy=l,Object.keys(e).forEach(p=>{n[p]=e[p]}),n.names=[],n.skips=[],n.formatters={};function t(p){let u=0;for(let d=0;d<p.length;d++)u=(u<<5)-u+p.charCodeAt(d),u|=0;return n.colors[Math.abs(u)%n.colors.length]}n.selectColor=t;function n(p){let u,d=null,m,_;function h(...b){if(!h.enabled)return;let N=h,L=Number(new Date),R=L-(u||L);N.diff=R,N.prev=u,N.curr=L,u=L,b[0]=n.coerce(b[0]),typeof b[0]!="string"&&b.unshift("%O");let v=0;b[0]=b[0].replace(/%([a-zA-Z%])/g,(G,I)=>{if(G==="%%")return"%";v++;let B=n.formatters[I];if(typeof B=="function"){let k=b[v];G=B.call(N,k),b.splice(v,1),v--}return G}),n.formatArgs.call(N,b),(N.log||n.log).apply(N,b)}return h.namespace=p,h.useColors=n.useColors(),h.color=n.selectColor(p),h.extend=r,h.destroy=n.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(m!==n.namespaces&&(m=n.namespaces,_=n.enabled(p)),_),set:b=>{d=b}}),typeof n.init=="function"&&n.init(h),h}function r(p,u){let d=n(this.namespace+(typeof u>"u"?":":u)+p);return d.log=this.log,d}function o(p){n.save(p),n.namespaces=p,n.names=[],n.skips=[];let u=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of u)d[0]==="-"?n.skips.push(d.slice(1)):n.names.push(d)}function i(p,u){let d=0,m=0,_=-1,h=0;for(;d<p.length;)if(m<u.length&&(u[m]===p[d]||u[m]==="*"))u[m]==="*"?(_=m,h=d,m++):(d++,m++);else if(_!==-1)m=_+1,h++,d=h;else return!1;for(;m<u.length&&u[m]==="*";)m++;return m===u.length}function s(){let p=[...n.names,...n.skips.map(u=>"-"+u)].join(",");return n.enable(""),p}function c(p){for(let u of n.skips)if(i(p,u))return!1;for(let u of n.names)if(i(p,u))return!0;return!1}function a(p){return p instanceof Error?p.stack||p.message:p}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}gk.exports=sZ});var _k=Nr((En,em)=>{"use strict";En.formatArgs=cZ;En.save=lZ;En.load=pZ;En.useColors=aZ;En.storage=uZ();En.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();En.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function aZ(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function cZ(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+em.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let n=0,r=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(n++,o==="%c"&&(r=n))}),e.splice(r,0,t)}En.log=console.debug||console.log||(()=>{});function lZ(e){try{e?En.storage.setItem("debug",e):En.storage.removeItem("debug")}catch{}}function pZ(){let e;try{e=En.storage.getItem("debug")||En.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function uZ(){try{return localStorage}catch{}}em.exports=Qy()(En);var{formatters:dZ}=em.exports;dZ.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var yk=Nr((MTe,bk)=>{"use strict";var mZ=Lt("os"),hk=Lt("tty"),Zn=B2(),{env:xt}=process,tm;Zn("no-color")||Zn("no-colors")||Zn("color=false")||Zn("color=never")?tm=0:(Zn("color")||Zn("colors")||Zn("color=true")||Zn("color=always"))&&(tm=1);function fZ(){if("FORCE_COLOR"in xt)return xt.FORCE_COLOR==="true"?1:xt.FORCE_COLOR==="false"?0:xt.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(xt.FORCE_COLOR,10),3)}function gZ(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function _Z(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=fZ();r!==void 0&&(tm=r);let o=n?tm:r;if(o===0)return 0;if(n){if(Zn("color=16m")||Zn("color=full")||Zn("color=truecolor"))return 3;if(Zn("color=256"))return 2}if(e&&!t&&o===void 0)return 0;let i=o||0;if(xt.TERM==="dumb")return i;if(process.platform==="win32"){let s=mZ.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in xt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(s=>s in xt)||xt.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in xt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(xt.TEAMCITY_VERSION)?1:0;if(xt.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in xt){let s=Number.parseInt((xt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(xt.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(xt.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(xt.TERM)||"COLORTERM"in xt?1:i}function Jy(e,t={}){let n=_Z(e,{streamIsTTY:e&&e.isTTY,...t});return gZ(n)}bk.exports={supportsColor:Jy,stdout:Jy({isTTY:hk.isatty(1)}),stderr:Jy({isTTY:hk.isatty(2)})}});var Ek=Nr((Pt,rm)=>{"use strict";var hZ=Lt("tty"),nm=Lt("util");Pt.init=AZ;Pt.log=EZ;Pt.formatArgs=yZ;Pt.save=TZ;Pt.load=IZ;Pt.useColors=bZ;Pt.destroy=nm.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Pt.colors=[6,2,3,4,5,1];try{let e=yk();e&&(e.stderr||e).level>=2&&(Pt.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}Pt.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(o,i)=>i.toUpperCase()),r=process.env[t];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),e[n]=r,e},{});function bZ(){return"colors"in Pt.inspectOpts?!!Pt.inspectOpts.colors:hZ.isatty(process.stderr.fd)}function yZ(e){let{namespace:t,useColors:n}=this;if(n){let r=this.color,o="\x1B[3"+(r<8?r:"8;5;"+r),i=` ${o};1m${t} \x1B[0m`;e[0]=i+e[0].split(`
5
5
  `).join(`
6
6
  `+i),e.push(o+"m+"+rm.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=SZ()+t+" "+e[0]}function SZ(){return Pt.inspectOpts.hideDate?"":new Date().toISOString()+" "}function EZ(...e){return process.stderr.write(nm.formatWithOptions(Pt.inspectOpts,...e)+`
7
7
  `)}function TZ(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function IZ(){return process.env.DEBUG}function AZ(e){e.inspectOpts={};let t=Object.keys(Pt.inspectOpts);for(let n=0;n<t.length;n++)e.inspectOpts[t[n]]=Pt.inspectOpts[t[n]]}rm.exports=Qy()(Pt);var{formatters:Sk}=rm.exports;Sk.o=function(e){return this.inspectOpts.colors=this.useColors,nm.inspect(e,this.inspectOpts).split(`
@@ -0,0 +1,16 @@
1
+ import {
2
+ Agent,
3
+ events_exports,
4
+ streaming_executor_exports
5
+ } from "./chunk-YUDCYSKO.js";
6
+ import "./chunk-PJ7354ZG.js";
7
+ import "./chunk-BQFVUVLI.js";
8
+ import "./chunk-HQSYRTER.js";
9
+ import "./chunk-OLFXCZVH.js";
10
+ import "./chunk-ZPIF7IJN.js";
11
+ import "./chunk-MLKGABMK.js";
12
+ export {
13
+ Agent,
14
+ events_exports as Events,
15
+ streaming_executor_exports as StreamingExecutor
16
+ };
@@ -5,11 +5,12 @@ import {
5
5
  markLastUserTailForCache,
6
6
  markToolsForCache,
7
7
  needsToolSearchBeta
8
- } from "./chunk-FODSMOWP.js";
9
- import "./chunk-XT67KGWE.js";
10
- import "./chunk-BCBD34D2.js";
11
- import "./chunk-3OFLDUAW.js";
12
- import "./chunk-3XCGUKGJ.js";
8
+ } from "./chunk-6V7RW6HA.js";
9
+ import "./chunk-BQFVUVLI.js";
10
+ import "./chunk-HQSYRTER.js";
11
+ import "./chunk-OLFXCZVH.js";
12
+ import "./chunk-ZPIF7IJN.js";
13
+ import "./chunk-MLKGABMK.js";
13
14
  export {
14
15
  AnthropicClient,
15
16
  buildAnthropicMessages,
@@ -0,0 +1,7 @@
1
+ import {
2
+ BwrapSandbox
3
+ } from "./chunk-YIWNQ7OA.js";
4
+ import "./chunk-MLKGABMK.js";
5
+ export {
6
+ BwrapSandbox
7
+ };
@@ -1,10 +1,6 @@
1
1
  import {
2
2
  normalizeToolResultContentBlock
3
- } from "./chunk-XT67KGWE.js";
4
- import {
5
- MCP_TOOL_PREFIX,
6
- isMcpToolLike
7
- } from "./chunk-BCBD34D2.js";
3
+ } from "./chunk-BQFVUVLI.js";
8
4
  import {
9
5
  AuthenticationError,
10
6
  ContextTooLongError,
@@ -21,7 +17,11 @@ import {
21
17
  thinkingBudgetForLevel,
22
18
  toAnthropicThinkingEffort,
23
19
  toReasoningEffort
24
- } from "./chunk-3OFLDUAW.js";
20
+ } from "./chunk-HQSYRTER.js";
21
+ import {
22
+ MCP_TOOL_PREFIX,
23
+ isMcpToolLike
24
+ } from "./chunk-OLFXCZVH.js";
25
25
  import {
26
26
  asErrorString,
27
27
  asRecord,
@@ -30,13 +30,37 @@ import {
30
30
  createChildLogger,
31
31
  isRecord,
32
32
  strArg
33
- } from "./chunk-3XCGUKGJ.js";
33
+ } from "./chunk-ZPIF7IJN.js";
34
+ import {
35
+ __export
36
+ } from "./chunk-MLKGABMK.js";
34
37
 
35
38
  // src/llm/anthropic.ts
39
+ var anthropic_exports = {};
40
+ __export(anthropic_exports, {
41
+ AnthropicClient: () => AnthropicClient,
42
+ buildAnthropicMessages: () => buildAnthropicMessages,
43
+ fetchModelContextWindow: () => fetchModelContextWindow,
44
+ markLastUserTailForCache: () => markLastUserTailForCache,
45
+ markToolsForCache: () => markToolsForCache,
46
+ needsToolSearchBeta: () => needsToolSearchBeta
47
+ });
36
48
  import Anthropic from "@anthropic-ai/sdk";
37
49
  import { safeParseAsync, z } from "zod";
38
50
 
39
51
  // src/mcp/strategy.ts
52
+ var strategy_exports = {};
53
+ __export(strategy_exports, {
54
+ CHARS_PER_TOKEN: () => CHARS_PER_TOKEN,
55
+ DEFAULT_EAGER_THRESHOLD_PERCENT: () => DEFAULT_EAGER_THRESHOLD_PERCENT,
56
+ NATIVE_TOOL_USE_BETA: () => NATIVE_TOOL_USE_BETA,
57
+ applyMode: () => applyMode,
58
+ decideAndApply: () => decideAndApply,
59
+ decideMode: () => decideMode,
60
+ estimateSchemaTokens: () => estimateSchemaTokens,
61
+ isOfficialAnthropicEndpoint: () => isOfficialAnthropicEndpoint,
62
+ measureSchemaChars: () => measureSchemaChars
63
+ });
40
64
  var DEFAULT_EAGER_THRESHOLD_PERCENT = 10;
41
65
  var CHARS_PER_TOKEN = 2.5;
42
66
  var NATIVE_TOOL_USE_BETA = "advanced-tool-use-2025-11-20";
@@ -570,19 +594,13 @@ function classifyAnthropicError(err) {
570
594
  }
571
595
 
572
596
  export {
573
- DEFAULT_EAGER_THRESHOLD_PERCENT,
574
- CHARS_PER_TOKEN,
575
- NATIVE_TOOL_USE_BETA,
576
- isOfficialAnthropicEndpoint,
577
- estimateSchemaTokens,
578
- decideMode,
579
- measureSchemaChars,
580
- applyMode,
581
597
  decideAndApply,
598
+ strategy_exports,
582
599
  markToolsForCache,
583
600
  needsToolSearchBeta,
584
601
  fetchModelContextWindow,
585
602
  buildAnthropicMessages,
586
603
  AnthropicClient,
587
- markLastUserTailForCache
604
+ markLastUserTailForCache,
605
+ anthropic_exports
588
606
  };
@@ -11,7 +11,7 @@ import {
11
11
  getThinkingLevel,
12
12
  resolveAPIKey,
13
13
  toReasoningEffort
14
- } from "./chunk-3OFLDUAW.js";
14
+ } from "./chunk-HQSYRTER.js";
15
15
  import {
16
16
  asRecord,
17
17
  asString,
@@ -19,9 +19,19 @@ import {
19
19
  createChildLogger,
20
20
  isRecord,
21
21
  strArg
22
- } from "./chunk-3XCGUKGJ.js";
22
+ } from "./chunk-ZPIF7IJN.js";
23
+ import {
24
+ __export
25
+ } from "./chunk-MLKGABMK.js";
23
26
 
24
27
  // src/llm/openai.ts
28
+ var openai_exports = {};
29
+ __export(openai_exports, {
30
+ OpenAIClient: () => OpenAIClient,
31
+ OpenAICompatClient: () => OpenAICompatClient,
32
+ buildChatCompletionMessages: () => buildChatCompletionMessages,
33
+ buildOpenAIInput: () => buildOpenAIInput
34
+ });
25
35
  import OpenAI from "openai";
26
36
  var log = createChildLogger({ module: "llm" });
27
37
  function computerActionArguments(action) {
@@ -842,5 +852,6 @@ export {
842
852
  OpenAIClient,
843
853
  buildOpenAIInput,
844
854
  OpenAICompatClient,
845
- buildChatCompletionMessages
855
+ buildChatCompletionMessages,
856
+ openai_exports
846
857
  };
@@ -1,52 +1,32 @@
1
1
  import {
2
2
  mcpCallPermissionContent
3
- } from "./chunk-BCBD34D2.js";
3
+ } from "./chunk-OLFXCZVH.js";
4
4
  import {
5
+ canonicalPath,
5
6
  createChildLogger,
7
+ isPathWithin,
6
8
  isRecord,
7
9
  strArg
8
- } from "./chunk-3XCGUKGJ.js";
10
+ } from "./chunk-ZPIF7IJN.js";
11
+ import {
12
+ __export
13
+ } from "./chunk-MLKGABMK.js";
9
14
 
10
- // src/permissions/checker.ts
15
+ // src/permissions/index.ts
16
+ var permissions_exports = {};
17
+ __export(permissions_exports, {
18
+ PathSandbox: () => PathSandbox,
19
+ PermissionChecker: () => PermissionChecker,
20
+ RuleEngine: () => RuleEngine,
21
+ evaluateRules: () => evaluateRules,
22
+ extractContent: () => extractContent,
23
+ isSafeCommand: () => isSafeCommand
24
+ });
11
25
  import { readFileSync, writeFileSync, mkdirSync, statSync } from "fs";
12
- import { homedir as homedir2, tmpdir } from "os";
13
- import { join as join2, resolve as resolve2, dirname as dirname2 } from "path";
26
+ import { homedir, tmpdir } from "os";
27
+ import { join, resolve, dirname } from "path";
14
28
  import yaml from "js-yaml";
15
29
  import z, { parse } from "zod";
16
-
17
- // src/utils/paths.ts
18
- import { realpathSync } from "fs";
19
- import { homedir } from "os";
20
- import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "path";
21
- function canonicalPath(path) {
22
- let current = resolve(path);
23
- const missing = [];
24
- for (; ; ) {
25
- try {
26
- return join(realpathSync(current), ...missing);
27
- } catch (error) {
28
- if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT" && error.code !== "ENOTDIR") {
29
- throw error;
30
- }
31
- const parent = dirname(current);
32
- if (parent === current) {
33
- return resolve(path);
34
- }
35
- missing.unshift(basename(current));
36
- current = parent;
37
- }
38
- }
39
- }
40
- function isPathWithin(root, path) {
41
- const child = relative(root, path);
42
- return child === "" || child !== ".." && !child.startsWith(`..${sep}`) && !isAbsolute(child);
43
- }
44
- function compactPath(path) {
45
- const home = homedir();
46
- return path === home ? "~" : path.startsWith(`${home}/`) ? `~/${path.slice(home.length + 1)}` : path;
47
- }
48
-
49
- // src/permissions/checker.ts
50
30
  var log = createChildLogger({ module: "permissions" });
51
31
  var DANGEROUS_PATTERNS = [];
52
32
  var SAFE_PREFIXES = [
@@ -267,23 +247,23 @@ var PathSandbox = class {
267
247
  denyWritePaths;
268
248
  projectDir;
269
249
  constructor(projectDir) {
270
- this.projectDir = resolve2(projectDir);
250
+ this.projectDir = resolve(projectDir);
271
251
  this.allowedRoots = [this.projectDir, tmpdir()];
272
- this.denyWritePaths = DEFAULT_DENY_WRITE.map((p) => join2(this.projectDir, p));
252
+ this.denyWritePaths = DEFAULT_DENY_WRITE.map((p) => join(this.projectDir, p));
273
253
  }
274
254
  addRoot(root) {
275
- this.allowedRoots.push(resolve2(root));
255
+ this.allowedRoots.push(resolve(root));
276
256
  }
277
257
  // Add custom deny-write paths
278
258
  addDenyWrite(path) {
279
- this.denyWritePaths.push(resolve2(path));
259
+ this.denyWritePaths.push(resolve(path));
280
260
  }
281
261
  /**
282
262
  * Check whether a path is in the deny-write list.
283
263
  * denyWrite has the highest priority — even if the path is within an allowed root, writes are still denied.
284
264
  */
285
265
  checkDenyWrite(filePath) {
286
- const absolute = resolve2(this.projectDir, filePath);
266
+ const absolute = resolve(this.projectDir, filePath);
287
267
  const canonical = canonicalPath(absolute);
288
268
  for (const denied of this.denyWritePaths) {
289
269
  if (isPathWithin(denied, absolute) || isPathWithin(canonicalPath(denied), canonical)) {
@@ -296,7 +276,7 @@ var PathSandbox = class {
296
276
  return null;
297
277
  }
298
278
  check(filePath) {
299
- const absolute = canonicalPath(resolve2(this.projectDir, filePath));
279
+ const absolute = canonicalPath(resolve(this.projectDir, filePath));
300
280
  for (const root of this.allowedRoots) {
301
281
  if (isPathWithin(canonicalPath(root), absolute)) {
302
282
  return null;
@@ -378,8 +358,8 @@ var RuleEngine = class {
378
358
  projectPath;
379
359
  cache = /* @__PURE__ */ new Map();
380
360
  constructor(workDir) {
381
- this.userPath = join2(homedir2(), ".swifty", "permissions.yaml");
382
- this.projectPath = join2(workDir, ".swifty", "permissions.yaml");
361
+ this.userPath = join(homedir(), ".swifty", "permissions.yaml");
362
+ this.projectPath = join(workDir, ".swifty", "permissions.yaml");
383
363
  }
384
364
  // Read a single rules file; skips disk I/O and parsing on cache hit.
385
365
  rulesFor(path) {
@@ -416,7 +396,7 @@ var RuleEngine = class {
416
396
  // Persists a rule to the project-level YAML file in the `Tool(pattern)`
417
397
  // format so "allow always" survives a restart.
418
398
  appendProjectRule(rule) {
419
- mkdirSync(dirname2(this.projectPath), { recursive: true });
399
+ mkdirSync(dirname(this.projectPath), { recursive: true });
420
400
  const rules = loadRulesFile(this.projectPath);
421
401
  const exists = rules.some(
422
402
  (r) => r.tool === rule.tool && r.pattern === rule.pattern && r.effect === rule.effect
@@ -501,7 +481,7 @@ var PermissionChecker = class _PermissionChecker {
501
481
  }
502
482
  if (this.mode === "plan" && (toolName === "WriteFile" || toolName === "EditFile")) {
503
483
  const path = strArg(args, "file_path", "");
504
- if (this.planFilePath && canonicalPath(resolve2(this.workDir, path)) === canonicalPath(resolve2(this.workDir, this.planFilePath)) && !this.sandbox.checkDenyWrite(path)) {
484
+ if (this.planFilePath && canonicalPath(resolve(this.workDir, path)) === canonicalPath(resolve(this.workDir, this.planFilePath)) && !this.sandbox.checkDenyWrite(path)) {
505
485
  return {
506
486
  effect: "allow",
507
487
  reason: "Plan file write allowed in plan mode"
@@ -584,13 +564,13 @@ var PermissionChecker = class _PermissionChecker {
584
564
  const isFilePath = toolName === "ReadFile" || toolName === "WriteFile" || toolName === "EditFile";
585
565
  let pattern;
586
566
  if (isFilePath && content) {
587
- const abs = resolve2(this.workDir, content);
567
+ const abs = resolve(this.workDir, content);
588
568
  let isDir = false;
589
569
  try {
590
570
  isDir = statSync(abs).isDirectory();
591
571
  } catch {
592
572
  }
593
- pattern = join2(isDir ? abs : dirname2(abs), "*");
573
+ pattern = join(isDir ? abs : dirname(abs), "*");
594
574
  } else {
595
575
  const words = content.trim().split(/\s+/).slice(0, 2);
596
576
  pattern = words.join(" ") + "*";
@@ -603,7 +583,7 @@ var PermissionChecker = class _PermissionChecker {
603
583
  }
604
584
  /**
605
585
  * Generate a human-readable description of the tool action for display in HITL confirmation dialogs.
606
- * Prioritizes extracting fields defined in contentFields (e.g., command, file_path);
586
+ * Prioritizes extracting fields defined in CONTENT_FIELDS (e.g., command, file_path);
607
587
  * falls back to a key:value summary of parameters if no match is found.
608
588
  */
609
589
  describeToolAction(toolName, args) {
@@ -624,13 +604,11 @@ var PermissionChecker = class _PermissionChecker {
624
604
  };
625
605
 
626
606
  export {
627
- canonicalPath,
628
- isPathWithin,
629
- compactPath,
630
607
  extractContent,
631
608
  PathSandbox,
632
609
  evaluateRules,
633
610
  RuleEngine,
634
611
  isSafeCommand,
635
- PermissionChecker
612
+ PermissionChecker,
613
+ permissions_exports
636
614
  };
@@ -1,4 +1,14 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-MLKGABMK.js";
4
+
1
5
  // src/tools/types.ts
6
+ var types_exports = {};
7
+ __export(types_exports, {
8
+ SKIP_DIRS: () => SKIP_DIRS,
9
+ isToolResultContentBlock: () => isToolResultContentBlock,
10
+ normalizeToolResultContentBlock: () => normalizeToolResultContentBlock
11
+ });
2
12
  function isRecord(value) {
3
13
  return typeof value === "object" && value !== null && !Array.isArray(value);
4
14
  }
@@ -135,6 +145,6 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
135
145
 
136
146
  export {
137
147
  normalizeToolResultContentBlock,
138
- isToolResultContentBlock,
139
- SKIP_DIRS
148
+ SKIP_DIRS,
149
+ types_exports
140
150
  };
@@ -0,0 +1,132 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-MLKGABMK.js";
4
+
5
+ // src/sandbox/sandbox-runtime.ts
6
+ var sandbox_runtime_exports = {};
7
+ __export(sandbox_runtime_exports, {
8
+ SandboxRuntimeSandbox: () => SandboxRuntimeSandbox,
9
+ createSandboxRuntimeConfig: () => createSandboxRuntimeConfig
10
+ });
11
+ import { isAbsolute, resolve } from "path";
12
+ async function loadSandboxRuntime() {
13
+ return await import("@anthropic-ai/sandbox-runtime");
14
+ }
15
+ function resolvePaths(paths, cwd) {
16
+ return paths.map((path) => isAbsolute(path) ? path : resolve(cwd, path));
17
+ }
18
+ function createSandboxRuntimeConfig(config, cwd) {
19
+ return {
20
+ network: {
21
+ allowedDomains: [],
22
+ deniedDomains: config.networkEnabled ? [] : ["*"],
23
+ strictAllowlist: !config.networkEnabled
24
+ },
25
+ filesystem: {
26
+ denyRead: [],
27
+ allowWrite: resolvePaths(config.allowWrite, cwd),
28
+ denyWrite: resolvePaths(config.denyWrite, cwd),
29
+ allowGitConfig: false
30
+ }
31
+ };
32
+ }
33
+ var SandboxRuntimeSandbox = class {
34
+ implementation = "sandbox-runtime";
35
+ availabilityError;
36
+ availabilityPromise;
37
+ configKey;
38
+ initializationPromise;
39
+ runtimePromise;
40
+ available() {
41
+ return this.availabilityPromise ??= this.checkAvailability();
42
+ }
43
+ async prepare(command, config, context) {
44
+ if (!await this.available()) {
45
+ throw new Error(this.availabilityError ?? "sandbox runtime is unavailable");
46
+ }
47
+ const runtime = await this.loadRuntime();
48
+ const runtimeConfig = runtime.SandboxRuntimeConfigSchema.parse(
49
+ createSandboxRuntimeConfig(config, context.cwd)
50
+ );
51
+ const configKey = JSON.stringify(runtimeConfig);
52
+ if (this.initializationPromise) {
53
+ await this.initializationPromise;
54
+ }
55
+ if (this.configKey !== configKey || !runtime.SandboxManager.isSandboxingEnabled()) {
56
+ this.initializationPromise = (async () => {
57
+ if (runtime.SandboxManager.isSandboxingEnabled()) {
58
+ await runtime.SandboxManager.reset();
59
+ }
60
+ await runtime.SandboxManager.initialize(
61
+ runtimeConfig,
62
+ config.networkEnabled ? () => Promise.resolve(true) : void 0
63
+ );
64
+ this.configKey = configKey;
65
+ })();
66
+ try {
67
+ await this.initializationPromise;
68
+ } finally {
69
+ this.initializationPromise = void 0;
70
+ }
71
+ }
72
+ const commandId = context.commandId ?? command;
73
+ const prepared = await runtime.SandboxManager.wrapWithSandboxArgv(
74
+ command,
75
+ "/bin/bash",
76
+ void 0,
77
+ context.abortSignal,
78
+ context.cwd,
79
+ { commandId, commandText: command }
80
+ );
81
+ const [executable, ...args] = prepared.argv;
82
+ if (!executable) {
83
+ throw new Error("sandbox runtime returned an empty command");
84
+ }
85
+ return {
86
+ executable,
87
+ args,
88
+ env: prepared.env,
89
+ annotateStderr: (stderr) => runtime.SandboxManager.annotateStderrWithSandboxFailures(commandId, stderr),
90
+ cleanup: () => {
91
+ runtime.SandboxManager.cleanupAfterCommand();
92
+ }
93
+ };
94
+ }
95
+ async dispose() {
96
+ if (!this.runtimePromise) {
97
+ return;
98
+ }
99
+ await this.initializationPromise;
100
+ const runtime = await this.runtimePromise;
101
+ await runtime.SandboxManager.reset();
102
+ this.configKey = void 0;
103
+ }
104
+ async checkAvailability() {
105
+ try {
106
+ const runtime = await this.loadRuntime();
107
+ if (!runtime.SandboxManager.isSupportedPlatform()) {
108
+ this.availabilityError = "sandbox runtime does not support this platform";
109
+ return false;
110
+ }
111
+ const dependencies = await runtime.SandboxManager.checkDependenciesAsync();
112
+ if (dependencies.errors.length > 0) {
113
+ this.availabilityError = dependencies.errors.join("; ");
114
+ return false;
115
+ }
116
+ this.availabilityError = void 0;
117
+ return true;
118
+ } catch (error) {
119
+ this.availabilityError = error instanceof Error ? error.message : String(error);
120
+ return false;
121
+ }
122
+ }
123
+ loadRuntime() {
124
+ return this.runtimePromise ??= loadSandboxRuntime();
125
+ }
126
+ };
127
+
128
+ export {
129
+ createSandboxRuntimeConfig,
130
+ SandboxRuntimeSandbox,
131
+ sandbox_runtime_exports
132
+ };
@@ -1,14 +1,24 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-MLKGABMK.js";
4
+
1
5
  // src/sandbox/seatbelt.ts
6
+ var seatbelt_exports = {};
7
+ __export(seatbelt_exports, {
8
+ SeatbeltSandbox: () => SeatbeltSandbox
9
+ });
2
10
  import { existsSync, statSync } from "fs";
3
11
  var SANDBOX_EXEC_PATH = "/usr/bin/sandbox-exec";
4
12
  var SeatbeltSandbox = class {
13
+ implementation = "seatbelt";
5
14
  available() {
6
15
  return existsSync(SANDBOX_EXEC_PATH);
7
16
  }
8
- wrap(command, config) {
9
- const profile = buildProfile(config);
10
- const escaped = command.replace(/'/g, "'\\''");
11
- return `${SANDBOX_EXEC_PATH} -p '${profile}' bash -c '${escaped}'`;
17
+ prepare(command, config) {
18
+ return {
19
+ executable: SANDBOX_EXEC_PATH,
20
+ args: ["-p", buildProfile(config), "bash", "-c", command]
21
+ };
12
22
  }
13
23
  };
14
24
  function buildProfile(config) {
@@ -35,5 +45,6 @@ function buildProfile(config) {
35
45
  }
36
46
 
37
47
  export {
38
- SeatbeltSandbox
48
+ SeatbeltSandbox,
49
+ seatbelt_exports
39
50
  };