@dahawa/hawa-code 1.27.1 → 1.27.2

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 (2) hide show
  1. package/cli.js +3 -3
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -113,7 +113,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
113
113
  `).concat(o.message));"exitCode"in o&&(i.exitCode=o.exitCode,i.code=o.exitCode),r(i)},complete:function(){return e(n)}})})}function qgr(t){return new Promise(function(e,r){var n="",o="";t.subscribe({next:function(i){return i.source==="stdout"?n+=i.text:o+=i.text},error:function(i){var s=new Error("".concat(n,`
114
114
  `).concat(i.message));"exitCode"in i&&(s.exitCode=i.exitCode,s.code=i.exitCode,s.stdout=n,s.stderr=o),r(s)},complete:function(){return e([n,o])}})})}function rYo(t,e,r){return r?.split?qgr(SZe(t,e,VE(VE({},r??{}),{split:!0}))):$gr(SZe(t,e,VE(VE({},r??{}),{split:!1})))}function nYo(t,e,r){return r?.split?qgr(Yee(t,e,VE(VE({},r??{}),{split:!0}))):$gr(Yee(t,e,VE(VE({},r??{}),{split:!1})))}});import{fileURLToPath as oYo}from"node:url";import*as d3 from"path";import{execFile as iYo}from"child_process";async function Kee(t,e,r){await cYo();let n=q2();return Gf("ripgrep called: %s %o",n,e,t),new Promise(o=>{iYo(q2(),[...t,e],{maxBuffer:1e6,signal:r,timeout:1e4},(i,s)=>{i?(i.code!==1&&(Gf("ripgrep error: %o",i),Te(i)),o([])):(Gf("ripgrep succeeded with %s",s),o(s.trim().split(`
115
115
  `).filter(Boolean)))})})}async function Vgr(t,e,r){try{return Gf("listAllContentFiles called: %s",t),(await Kee(["-l",".",t],t,e)).slice(0,r)}catch(n){return Gf("listAllContentFiles failed: %o",n),Te(n),[]}}async function cYo(){if(process.platform!=="darwin"||Ggr)return;if(Ggr=!0,Gf("checking if ripgrep is already signed"),!(await Cn("codesign",["-vv","-d",q2()],void 0,void 0,!1)).stdout.split(`
116
- `).find(r=>r.includes("linker-signed"))){Gf("seems to be already signed");return}try{Gf("signing ripgrep");let r=await Cn("codesign",["--sign","-","--force","--preserve-metadata=entitlements,requirements,flags,runtime",q2()]);r.code!==0&&(Gf("failed to sign ripgrep: %o",r),Te(`Failed to sign ripgrep: ${r.stdout} ${r.stderr}`)),Gf("removing quarantine");let n=await Cn("xattr",["-d","com.apple.quarantine",q2()]);n.code!==0&&(Gf("failed to remove quarantine: %o",n),Te(`Failed to remove quarantine: ${n.stdout} ${n.stderr}`))}catch(r){Gf("failed during sign: %o",r),Te(r)}}var jgr,zgr,sYo,aYo,Gf,Qgr,q2,Ggr,eH=m(()=>{jgr=j(Hgr(),1);Pr();et();bS();zgr=j(bF(),1);tt();sYo=oYo(import.meta.url),aYo=d3.resolve(d3.dirname(sYo),"."),Gf=(0,zgr.default)(`${Ea}:ripgrep`),Qgr=!!process.env.USE_BUILTIN_RIPGREP;Qgr&&Gf("Using builtin ripgrep because USE_BUILTIN_RIPGREP is set");q2=Ze(()=>{let{cmd:t}=(0,jgr.findActualExecutable)("rg",[]);if(Gf(`ripgrep initially resolved as: ${t}`),t!=="rg"&&!Qgr)return Gf("using system ripgrep from PATH"),t;{let e=d3.resolve(aYo,"vendor","ripgrep");if(process.platform==="win32"){let n=d3.resolve(e,"x64-win32","rg.exe");return Gf("using Windows builtin ripgrep: %s",n),n}let r=d3.resolve(e,`${process.arch}-${process.platform}`,"rg");return Gf("internal ripgrep resolved as: %s",r),r}});Ggr=!1});var Ygr=S((p_a,Wgr)=>{"use strict";Wgr.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}});var Zgr=S((f_a,Kgr)=>{"use strict";Kgr.exports=cs;cs.Node=p3;cs.create=cs;function cs(t){var e=this;if(e instanceof cs||(e=new cs),e.tail=null,e.head=null,e.length=0,t&&typeof t.forEach=="function")t.forEach(function(o){e.push(o)});else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)e.push(arguments[r]);return e}cs.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e};cs.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}};cs.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}};cs.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)lYo(this,arguments[t]);return this.length};cs.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)dYo(this,arguments[t]);return this.length};cs.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}};cs.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}};cs.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,n=0;r!==null;n++)t.call(e,r.value,n,this),r=r.next};cs.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,n=this.length-1;r!==null;n--)t.call(e,r.value,n,this),r=r.prev};cs.prototype.get=function(t){for(var e=0,r=this.head;r!==null&&e<t;e++)r=r.next;if(e===t&&r!==null)return r.value};cs.prototype.getReverse=function(t){for(var e=0,r=this.tail;r!==null&&e<t;e++)r=r.prev;if(e===t&&r!==null)return r.value};cs.prototype.map=function(t,e){e=e||this;for(var r=new cs,n=this.head;n!==null;)r.push(t.call(e,n.value,this)),n=n.next;return r};cs.prototype.mapReverse=function(t,e){e=e||this;for(var r=new cs,n=this.tail;n!==null;)r.push(t.call(e,n.value,this)),n=n.prev;return r};cs.prototype.reduce=function(t,e){var r,n=this.head;if(arguments.length>1)r=e;else if(this.head)n=this.head.next,r=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=0;n!==null;o++)r=t(r,n.value,o),n=n.next;return r};cs.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else if(this.tail)n=this.tail.prev,r=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=this.length-1;n!==null;o--)r=t(r,n.value,o),n=n.prev;return r};cs.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;r!==null;e++)t[e]=r.value,r=r.next;return t};cs.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;r!==null;e++)t[e]=r.value,r=r.prev;return t};cs.prototype.slice=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new cs;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=0,o=this.head;o!==null&&n<t;n++)o=o.next;for(;o!==null&&n<e;n++,o=o.next)r.push(o.value);return r};cs.prototype.sliceReverse=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new cs;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=this.length,o=this.tail;o!==null&&n>e;n--)o=o.prev;for(;o!==null&&n>t;n--,o=o.prev)r.push(o.value);return r};cs.prototype.splice=function(t,e){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var r=0,n=this.head;n!==null&&r<t;r++)n=n.next;for(var o=[],r=0;n&&r<e;r++)o.push(n.value),n=this.removeNode(n);n===null&&(n=this.tail),n!==this.head&&n!==this.tail&&(n=n.prev);for(var r=2;r<arguments.length;r++)n=uYo(this,n,arguments[r]);return o};cs.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;r!==null;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=e,this.tail=t,this};function uYo(t,e,r){var n=e===t.head?new p3(r,null,e,t):new p3(r,e,e.next,t);return n.next===null&&(t.tail=n),n.prev===null&&(t.head=n),t.length++,n}function lYo(t,e){t.tail=new p3(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function dYo(t,e){t.head=new p3(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function p3(t,e,r,n){if(!(this instanceof p3))return new p3(t,e,r,n);this.list=n,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}try{Ygr()(cs)}catch{}});var r_r=S((m_a,t_r)=>{"use strict";var pYo=Zgr(),f3=Symbol("max"),G2=Symbol("length"),tH=Symbol("lengthCalculator"),Jee=Symbol("allowStale"),m3=Symbol("maxAge"),H2=Symbol("dispose"),Jgr=Symbol("noDisposeOnSet"),Jp=Symbol("lruList"),ZS=Symbol("cache"),e_r=Symbol("updateAgeOnGet"),bZe=()=>1,vZe=class{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");let r=this[f3]=e.max||1/0,n=e.length||bZe;if(this[tH]=typeof n!="function"?bZe:n,this[Jee]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[m3]=e.maxAge||0,this[H2]=e.dispose,this[Jgr]=e.noDisposeOnSet||!1,this[e_r]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[f3]=e||1/0,Zee(this)}get max(){return this[f3]}set allowStale(e){this[Jee]=!!e}get allowStale(){return this[Jee]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[m3]=e,Zee(this)}get maxAge(){return this[m3]}set lengthCalculator(e){typeof e!="function"&&(e=bZe),e!==this[tH]&&(this[tH]=e,this[G2]=0,this[Jp].forEach(r=>{r.length=this[tH](r.value,r.key),this[G2]+=r.length})),Zee(this)}get lengthCalculator(){return this[tH]}get length(){return this[G2]}get itemCount(){return this[Jp].length}rforEach(e,r){r=r||this;for(let n=this[Jp].tail;n!==null;){let o=n.prev;Xgr(this,e,n,r),n=o}}forEach(e,r){r=r||this;for(let n=this[Jp].head;n!==null;){let o=n.next;Xgr(this,e,n,r),n=o}}keys(){return this[Jp].toArray().map(e=>e.key)}values(){return this[Jp].toArray().map(e=>e.value)}reset(){this[H2]&&this[Jp]&&this[Jp].length&&this[Jp].forEach(e=>this[H2](e.key,e.value)),this[ZS]=new Map,this[Jp]=new pYo,this[G2]=0}dump(){return this[Jp].map(e=>gTe(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[Jp]}set(e,r,n){if(n=n||this[m3],n&&typeof n!="number")throw new TypeError("maxAge must be a number");let o=n?Date.now():0,i=this[tH](r,e);if(this[ZS].has(e)){if(i>this[f3])return rH(this,this[ZS].get(e)),!1;let c=this[ZS].get(e).value;return this[H2]&&(this[Jgr]||this[H2](e,c.value)),c.now=o,c.maxAge=n,c.value=r,this[G2]+=i-c.length,c.length=i,this.get(e),Zee(this),!0}let s=new CZe(e,r,i,o,n);return s.length>this[f3]?(this[H2]&&this[H2](e,r),!1):(this[G2]+=s.length,this[Jp].unshift(s),this[ZS].set(e,this[Jp].head),Zee(this),!0)}has(e){if(!this[ZS].has(e))return!1;let r=this[ZS].get(e).value;return!gTe(this,r)}get(e){return TZe(this,e,!0)}peek(e){return TZe(this,e,!1)}pop(){let e=this[Jp].tail;return e?(rH(this,e),e.value):null}del(e){rH(this,this[ZS].get(e))}load(e){this.reset();let r=Date.now();for(let n=e.length-1;n>=0;n--){let o=e[n],i=o.e||0;if(i===0)this.set(o.k,o.v);else{let s=i-r;s>0&&this.set(o.k,o.v,s)}}}prune(){this[ZS].forEach((e,r)=>TZe(this,r,!1))}},TZe=(t,e,r)=>{let n=t[ZS].get(e);if(n){let o=n.value;if(gTe(t,o)){if(rH(t,n),!t[Jee])return}else r&&(t[e_r]&&(n.value.now=Date.now()),t[Jp].unshiftNode(n));return o.value}},gTe=(t,e)=>{if(!e||!e.maxAge&&!t[m3])return!1;let r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[m3]&&r>t[m3]},Zee=t=>{if(t[G2]>t[f3])for(let e=t[Jp].tail;t[G2]>t[f3]&&e!==null;){let r=e.prev;rH(t,e),e=r}},rH=(t,e)=>{if(e){let r=e.value;t[H2]&&t[H2](r.key,r.value),t[G2]-=r.length,t[ZS].delete(r.key),t[Jp].removeNode(e)}},CZe=class{constructor(e,r,n,o,i){this.key=e,this.value=r,this.length=n,this.now=o,this.maxAge=i||0}},Xgr=(t,e,r,n)=>{let o=r.value;gTe(t,o)&&(rH(t,r),t[Jee]||(o=void 0)),o&&e.call(n,o.value,o.key,t)};t_r.exports=vZe});async function RYo(){try{return await ZU("tengu-capable-model-config",v_r)}catch(t){return Te(t),v_r}}async function rte(){return!process.env.ANTHROPIC_MODEL||process.env.ANTHROPIC_MODEL===await tc()}function C_r(t){if(t?.startsWith("claude-3-5-haiku"))return process.env.VERTEX_REGION_CLAUDE_3_5_HAIKU;if(t?.startsWith("claude-3-5-sonnet"))return process.env.VERTEX_REGION_CLAUDE_3_5_SONNET;if(t?.startsWith("claude-3-7-sonnet"))return process.env.VERTEX_REGION_CLAUDE_3_7_SONNET}var vu,Cu,v_r,Hi,tc,ea=m(()=>{Pr();Ho();et();vu=!!process.env.CLAUDE_CODE_USE_BEDROCK,Cu=!!process.env.CLAUDE_CODE_USE_VERTEX,v_r={bedrock:"us.anthropic.claude-3-7-sonnet-20250219-v1:0",vertex:"claude-3-7-sonnet@20250219",firstParty:"claude-3-7-sonnet-20250219"},Hi=process.env.ANTHROPIC_SMALL_FAST_MODEL?process.env.ANTHROPIC_SMALL_FAST_MODEL:vu?"us.anthropic.claude-3-5-haiku-20241022-v1:0":Cu?"claude-3-5-haiku@20241022":"claude-3-5-haiku-20241022";tc=Ze(async()=>{if(process.env.ANTHROPIC_MODEL||process.env.USER_TYPE==="SWE_BENCH"&&process.env.ANTHROPIC_MODEL)return process.env.ANTHROPIC_MODEL;let t=await RYo();return vu?t.bedrock:Cu?t.vertex:t.firstParty})});var $Ze,F_r=m(()=>{tt();$Ze="1.27.1";globalThis.MACRO={VERSION:$Ze,PACKAGE_URL:`@dahawa/${Ea}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"}});var E3,TTe=m(()=>{tt();F_r();E3=`${Ea}/${$Ze} (${process.env.USER_TYPE})`});var U_r=S(vTe=>{"use strict";Object.defineProperty(vTe,"__esModule",{value:!0});vTe.VERSION=void 0;vTe.VERSION="0.24.3"});var $_r=S(A3=>{"use strict";var MYo=A3&&A3.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),kYo=A3&&A3.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&MYo(e,t,r)};Object.defineProperty(A3,"__esModule",{value:!0});kYo(oQe(),A3)});var ite=S(q_r=>{var CTe=qje(),LYo=$_r();CTe.kind||CTe.setShims(LYo.getRuntime(),{auto:!0});for(let t of Object.keys(CTe))Object.defineProperty(q_r,t,{get(){return CTe[t]}})});var jZe=S(Mv=>{"use strict";Object.defineProperty(Mv,"__esModule",{value:!0});Mv.readableStreamAsyncIterable=Mv._decodeChunks=Mv._iterSSEMessages=Mv.Stream=void 0;var BYo=ite(),xTe=aH(),H_r=wTe(),FYo=aH(),qZe=class t{constructor(e,r){this.iterator=e,this.controller=r}static fromSSEResponse(e,r){let n=!1;async function*o(){if(n)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let i=!1;try{for await(let s of G_r(e,r)){if(s.event==="completion")try{yield JSON.parse(s.data)}catch(a){throw console.error("Could not parse message into JSON:",s.data),console.error("From chunk:",s.raw),a}if(s.event==="message_start"||s.event==="message_delta"||s.event==="message_stop"||s.event==="content_block_start"||s.event==="content_block_delta"||s.event==="content_block_stop")try{yield JSON.parse(s.data)}catch(a){throw console.error("Could not parse message into JSON:",s.data),console.error("From chunk:",s.raw),a}if(s.event!=="ping"&&s.event==="error"){let a=s.data,c=(0,H_r.safeJSON)(a),u=c?void 0:a;throw FYo.APIError.generate(void 0,c,u,(0,H_r.createResponseHeaders)(e.headers))}}i=!0}catch(s){if(s instanceof Error&&s.name==="AbortError")return;throw s}finally{i||r.abort()}}return new t(o,r)}static fromReadableStream(e,r){let n=!1;async function*o(){let s=new y3,a=GZe(e);for await(let c of a)for(let u of s.decode(c))yield u;for(let c of s.flush())yield c}async function*i(){if(n)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let s=!1;try{for await(let a of o())s||a&&(yield JSON.parse(a));s=!0}catch(a){if(a instanceof Error&&a.name==="AbortError")return;throw a}finally{s||r.abort()}}return new t(i,r)}[Symbol.asyncIterator](){return this.iterator()}tee(){let e=[],r=[],n=this.iterator(),o=i=>({next:()=>{if(i.length===0){let s=n.next();e.push(s),r.push(s)}return i.shift()}});return[new t(()=>o(e),this.controller),new t(()=>o(r),this.controller)]}toReadableStream(){let e=this,r,n=new TextEncoder;return new BYo.ReadableStream({async start(){r=e[Symbol.asyncIterator]()},async pull(o){try{let{value:i,done:s}=await r.next();if(s)return o.close();let a=n.encode(JSON.stringify(i)+`
116
+ `).find(r=>r.includes("linker-signed"))){Gf("seems to be already signed");return}try{Gf("signing ripgrep");let r=await Cn("codesign",["--sign","-","--force","--preserve-metadata=entitlements,requirements,flags,runtime",q2()]);r.code!==0&&(Gf("failed to sign ripgrep: %o",r),Te(`Failed to sign ripgrep: ${r.stdout} ${r.stderr}`)),Gf("removing quarantine");let n=await Cn("xattr",["-d","com.apple.quarantine",q2()]);n.code!==0&&(Gf("failed to remove quarantine: %o",n),Te(`Failed to remove quarantine: ${n.stdout} ${n.stderr}`))}catch(r){Gf("failed during sign: %o",r),Te(r)}}var jgr,zgr,sYo,aYo,Gf,Qgr,q2,Ggr,eH=m(()=>{jgr=j(Hgr(),1);Pr();et();bS();zgr=j(bF(),1);tt();sYo=oYo(import.meta.url),aYo=d3.resolve(d3.dirname(sYo),"."),Gf=(0,zgr.default)(`${Ea}:ripgrep`),Qgr=!!process.env.USE_BUILTIN_RIPGREP;Qgr&&Gf("Using builtin ripgrep because USE_BUILTIN_RIPGREP is set");q2=Ze(()=>{let{cmd:t}=(0,jgr.findActualExecutable)("rg",[]);if(Gf(`ripgrep initially resolved as: ${t}`),t!=="rg"&&!Qgr)return Gf("using system ripgrep from PATH"),t;{let e=d3.resolve(aYo,"vendor","ripgrep");if(process.platform==="win32"){let n=d3.resolve(e,"x64-win32","rg.exe");return Gf("using Windows builtin ripgrep: %s",n),n}let r=d3.resolve(e,`${process.arch}-${process.platform}`,"rg");return Gf("internal ripgrep resolved as: %s",r),r}});Ggr=!1});var Ygr=S((p_a,Wgr)=>{"use strict";Wgr.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}});var Zgr=S((f_a,Kgr)=>{"use strict";Kgr.exports=cs;cs.Node=p3;cs.create=cs;function cs(t){var e=this;if(e instanceof cs||(e=new cs),e.tail=null,e.head=null,e.length=0,t&&typeof t.forEach=="function")t.forEach(function(o){e.push(o)});else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)e.push(arguments[r]);return e}cs.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e};cs.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}};cs.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}};cs.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)lYo(this,arguments[t]);return this.length};cs.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)dYo(this,arguments[t]);return this.length};cs.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}};cs.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}};cs.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,n=0;r!==null;n++)t.call(e,r.value,n,this),r=r.next};cs.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,n=this.length-1;r!==null;n--)t.call(e,r.value,n,this),r=r.prev};cs.prototype.get=function(t){for(var e=0,r=this.head;r!==null&&e<t;e++)r=r.next;if(e===t&&r!==null)return r.value};cs.prototype.getReverse=function(t){for(var e=0,r=this.tail;r!==null&&e<t;e++)r=r.prev;if(e===t&&r!==null)return r.value};cs.prototype.map=function(t,e){e=e||this;for(var r=new cs,n=this.head;n!==null;)r.push(t.call(e,n.value,this)),n=n.next;return r};cs.prototype.mapReverse=function(t,e){e=e||this;for(var r=new cs,n=this.tail;n!==null;)r.push(t.call(e,n.value,this)),n=n.prev;return r};cs.prototype.reduce=function(t,e){var r,n=this.head;if(arguments.length>1)r=e;else if(this.head)n=this.head.next,r=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=0;n!==null;o++)r=t(r,n.value,o),n=n.next;return r};cs.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else if(this.tail)n=this.tail.prev,r=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var o=this.length-1;n!==null;o--)r=t(r,n.value,o),n=n.prev;return r};cs.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;r!==null;e++)t[e]=r.value,r=r.next;return t};cs.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;r!==null;e++)t[e]=r.value,r=r.prev;return t};cs.prototype.slice=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new cs;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=0,o=this.head;o!==null&&n<t;n++)o=o.next;for(;o!==null&&n<e;n++,o=o.next)r.push(o.value);return r};cs.prototype.sliceReverse=function(t,e){e=e||this.length,e<0&&(e+=this.length),t=t||0,t<0&&(t+=this.length);var r=new cs;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=this.length,o=this.tail;o!==null&&n>e;n--)o=o.prev;for(;o!==null&&n>t;n--,o=o.prev)r.push(o.value);return r};cs.prototype.splice=function(t,e){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var r=0,n=this.head;n!==null&&r<t;r++)n=n.next;for(var o=[],r=0;n&&r<e;r++)o.push(n.value),n=this.removeNode(n);n===null&&(n=this.tail),n!==this.head&&n!==this.tail&&(n=n.prev);for(var r=2;r<arguments.length;r++)n=uYo(this,n,arguments[r]);return o};cs.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;r!==null;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=e,this.tail=t,this};function uYo(t,e,r){var n=e===t.head?new p3(r,null,e,t):new p3(r,e,e.next,t);return n.next===null&&(t.tail=n),n.prev===null&&(t.head=n),t.length++,n}function lYo(t,e){t.tail=new p3(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function dYo(t,e){t.head=new p3(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function p3(t,e,r,n){if(!(this instanceof p3))return new p3(t,e,r,n);this.list=n,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}try{Ygr()(cs)}catch{}});var r_r=S((m_a,t_r)=>{"use strict";var pYo=Zgr(),f3=Symbol("max"),G2=Symbol("length"),tH=Symbol("lengthCalculator"),Jee=Symbol("allowStale"),m3=Symbol("maxAge"),H2=Symbol("dispose"),Jgr=Symbol("noDisposeOnSet"),Jp=Symbol("lruList"),ZS=Symbol("cache"),e_r=Symbol("updateAgeOnGet"),bZe=()=>1,vZe=class{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");let r=this[f3]=e.max||1/0,n=e.length||bZe;if(this[tH]=typeof n!="function"?bZe:n,this[Jee]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[m3]=e.maxAge||0,this[H2]=e.dispose,this[Jgr]=e.noDisposeOnSet||!1,this[e_r]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[f3]=e||1/0,Zee(this)}get max(){return this[f3]}set allowStale(e){this[Jee]=!!e}get allowStale(){return this[Jee]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[m3]=e,Zee(this)}get maxAge(){return this[m3]}set lengthCalculator(e){typeof e!="function"&&(e=bZe),e!==this[tH]&&(this[tH]=e,this[G2]=0,this[Jp].forEach(r=>{r.length=this[tH](r.value,r.key),this[G2]+=r.length})),Zee(this)}get lengthCalculator(){return this[tH]}get length(){return this[G2]}get itemCount(){return this[Jp].length}rforEach(e,r){r=r||this;for(let n=this[Jp].tail;n!==null;){let o=n.prev;Xgr(this,e,n,r),n=o}}forEach(e,r){r=r||this;for(let n=this[Jp].head;n!==null;){let o=n.next;Xgr(this,e,n,r),n=o}}keys(){return this[Jp].toArray().map(e=>e.key)}values(){return this[Jp].toArray().map(e=>e.value)}reset(){this[H2]&&this[Jp]&&this[Jp].length&&this[Jp].forEach(e=>this[H2](e.key,e.value)),this[ZS]=new Map,this[Jp]=new pYo,this[G2]=0}dump(){return this[Jp].map(e=>gTe(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[Jp]}set(e,r,n){if(n=n||this[m3],n&&typeof n!="number")throw new TypeError("maxAge must be a number");let o=n?Date.now():0,i=this[tH](r,e);if(this[ZS].has(e)){if(i>this[f3])return rH(this,this[ZS].get(e)),!1;let c=this[ZS].get(e).value;return this[H2]&&(this[Jgr]||this[H2](e,c.value)),c.now=o,c.maxAge=n,c.value=r,this[G2]+=i-c.length,c.length=i,this.get(e),Zee(this),!0}let s=new CZe(e,r,i,o,n);return s.length>this[f3]?(this[H2]&&this[H2](e,r),!1):(this[G2]+=s.length,this[Jp].unshift(s),this[ZS].set(e,this[Jp].head),Zee(this),!0)}has(e){if(!this[ZS].has(e))return!1;let r=this[ZS].get(e).value;return!gTe(this,r)}get(e){return TZe(this,e,!0)}peek(e){return TZe(this,e,!1)}pop(){let e=this[Jp].tail;return e?(rH(this,e),e.value):null}del(e){rH(this,this[ZS].get(e))}load(e){this.reset();let r=Date.now();for(let n=e.length-1;n>=0;n--){let o=e[n],i=o.e||0;if(i===0)this.set(o.k,o.v);else{let s=i-r;s>0&&this.set(o.k,o.v,s)}}}prune(){this[ZS].forEach((e,r)=>TZe(this,r,!1))}},TZe=(t,e,r)=>{let n=t[ZS].get(e);if(n){let o=n.value;if(gTe(t,o)){if(rH(t,n),!t[Jee])return}else r&&(t[e_r]&&(n.value.now=Date.now()),t[Jp].unshiftNode(n));return o.value}},gTe=(t,e)=>{if(!e||!e.maxAge&&!t[m3])return!1;let r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[m3]&&r>t[m3]},Zee=t=>{if(t[G2]>t[f3])for(let e=t[Jp].tail;t[G2]>t[f3]&&e!==null;){let r=e.prev;rH(t,e),e=r}},rH=(t,e)=>{if(e){let r=e.value;t[H2]&&t[H2](r.key,r.value),t[G2]-=r.length,t[ZS].delete(r.key),t[Jp].removeNode(e)}},CZe=class{constructor(e,r,n,o,i){this.key=e,this.value=r,this.length=n,this.now=o,this.maxAge=i||0}},Xgr=(t,e,r,n)=>{let o=r.value;gTe(t,o)&&(rH(t,r),t[Jee]||(o=void 0)),o&&e.call(n,o.value,o.key,t)};t_r.exports=vZe});async function RYo(){try{return await ZU("tengu-capable-model-config",v_r)}catch(t){return Te(t),v_r}}async function rte(){return!process.env.ANTHROPIC_MODEL||process.env.ANTHROPIC_MODEL===await tc()}function C_r(t){if(t?.startsWith("claude-3-5-haiku"))return process.env.VERTEX_REGION_CLAUDE_3_5_HAIKU;if(t?.startsWith("claude-3-5-sonnet"))return process.env.VERTEX_REGION_CLAUDE_3_5_SONNET;if(t?.startsWith("claude-3-7-sonnet"))return process.env.VERTEX_REGION_CLAUDE_3_7_SONNET}var vu,Cu,v_r,Hi,tc,ea=m(()=>{Pr();Ho();et();vu=!!process.env.CLAUDE_CODE_USE_BEDROCK,Cu=!!process.env.CLAUDE_CODE_USE_VERTEX,v_r={bedrock:"us.anthropic.claude-3-7-sonnet-20250219-v1:0",vertex:"claude-3-7-sonnet@20250219",firstParty:"claude-3-7-sonnet-20250219"},Hi=process.env.ANTHROPIC_SMALL_FAST_MODEL?process.env.ANTHROPIC_SMALL_FAST_MODEL:vu?"us.anthropic.claude-3-5-haiku-20241022-v1:0":Cu?"claude-3-5-haiku@20241022":"claude-3-5-haiku-20241022";tc=Ze(async()=>{if(process.env.ANTHROPIC_MODEL||process.env.USER_TYPE==="SWE_BENCH"&&process.env.ANTHROPIC_MODEL)return process.env.ANTHROPIC_MODEL;let t=await RYo();return vu?t.bedrock:Cu?t.vertex:t.firstParty})});var $Ze,F_r=m(()=>{tt();$Ze="1.27.2";globalThis.MACRO={VERSION:$Ze,PACKAGE_URL:`@dahawa/${Ea}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"}});var E3,TTe=m(()=>{tt();F_r();E3=`${Ea}/${$Ze} (${process.env.USER_TYPE})`});var U_r=S(vTe=>{"use strict";Object.defineProperty(vTe,"__esModule",{value:!0});vTe.VERSION=void 0;vTe.VERSION="0.24.3"});var $_r=S(A3=>{"use strict";var MYo=A3&&A3.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),kYo=A3&&A3.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&MYo(e,t,r)};Object.defineProperty(A3,"__esModule",{value:!0});kYo(oQe(),A3)});var ite=S(q_r=>{var CTe=qje(),LYo=$_r();CTe.kind||CTe.setShims(LYo.getRuntime(),{auto:!0});for(let t of Object.keys(CTe))Object.defineProperty(q_r,t,{get(){return CTe[t]}})});var jZe=S(Mv=>{"use strict";Object.defineProperty(Mv,"__esModule",{value:!0});Mv.readableStreamAsyncIterable=Mv._decodeChunks=Mv._iterSSEMessages=Mv.Stream=void 0;var BYo=ite(),xTe=aH(),H_r=wTe(),FYo=aH(),qZe=class t{constructor(e,r){this.iterator=e,this.controller=r}static fromSSEResponse(e,r){let n=!1;async function*o(){if(n)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let i=!1;try{for await(let s of G_r(e,r)){if(s.event==="completion")try{yield JSON.parse(s.data)}catch(a){throw console.error("Could not parse message into JSON:",s.data),console.error("From chunk:",s.raw),a}if(s.event==="message_start"||s.event==="message_delta"||s.event==="message_stop"||s.event==="content_block_start"||s.event==="content_block_delta"||s.event==="content_block_stop")try{yield JSON.parse(s.data)}catch(a){throw console.error("Could not parse message into JSON:",s.data),console.error("From chunk:",s.raw),a}if(s.event!=="ping"&&s.event==="error"){let a=s.data,c=(0,H_r.safeJSON)(a),u=c?void 0:a;throw FYo.APIError.generate(void 0,c,u,(0,H_r.createResponseHeaders)(e.headers))}}i=!0}catch(s){if(s instanceof Error&&s.name==="AbortError")return;throw s}finally{i||r.abort()}}return new t(o,r)}static fromReadableStream(e,r){let n=!1;async function*o(){let s=new y3,a=GZe(e);for await(let c of a)for(let u of s.decode(c))yield u;for(let c of s.flush())yield c}async function*i(){if(n)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");n=!0;let s=!1;try{for await(let a of o())s||a&&(yield JSON.parse(a));s=!0}catch(a){if(a instanceof Error&&a.name==="AbortError")return;throw a}finally{s||r.abort()}}return new t(i,r)}[Symbol.asyncIterator](){return this.iterator()}tee(){let e=[],r=[],n=this.iterator(),o=i=>({next:()=>{if(i.length===0){let s=n.next();e.push(s),r.push(s)}return i.shift()}});return[new t(()=>o(e),this.controller),new t(()=>o(r),this.controller)]}toReadableStream(){let e=this,r,n=new TextEncoder;return new BYo.ReadableStream({async start(){r=e[Symbol.asyncIterator]()},async pull(o){try{let{value:i,done:s}=await r.next();if(s)return o.close();let a=n.encode(JSON.stringify(i)+`
117
117
  `);o.enqueue(a)}catch(i){o.error(i)}},async cancel(){await r.return?.()}})}};Mv.Stream=qZe;async function*G_r(t,e){if(!t.body)throw e.abort(),new xTe.AnthropicError("Attempted to iterate over a response with no body");let r=new HZe,n=new y3,o=GZe(t.body);for await(let i of UYo(o))for(let s of n.decode(i)){let a=r.decode(s);a&&(yield a)}for(let i of n.flush()){let s=r.decode(i);s&&(yield s)}}Mv._iterSSEMessages=G_r;async function*UYo(t){let e=new Uint8Array;for await(let r of t){if(r==null)continue;let n=r instanceof ArrayBuffer?new Uint8Array(r):typeof r=="string"?new TextEncoder().encode(r):r,o=new Uint8Array(e.length+n.length);o.set(e),o.set(n,e.length),e=o;let i;for(;(i=$Yo(e))!==-1;)yield e.slice(0,i),e=e.slice(i)}e.length>0&&(yield e)}function $Yo(t){for(let n=0;n<t.length-2;n++){if(t[n]===10&&t[n+1]===10||t[n]===13&&t[n+1]===13)return n+2;if(t[n]===13&&t[n+1]===10&&n+3<t.length&&t[n+2]===13&&t[n+3]===10)return n+4}return-1}var HZe=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let i={event:this.event,data:this.data.join(`
118
118
  `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],i}if(this.chunks.push(e),e.startsWith(":"))return null;let[r,n,o]=HYo(e,":");return o.startsWith(" ")&&(o=o.substring(1)),r==="event"?this.event=o:r==="data"&&this.data.push(o),null}},y3=class t{constructor(){this.buffer=[],this.trailingCR=!1}decode(e){let r=this.decodeText(e);if(this.trailingCR&&(r="\r"+r,this.trailingCR=!1),r.endsWith("\r")&&(this.trailingCR=!0,r=r.slice(0,-1)),!r)return[];let n=t.NEWLINE_CHARS.has(r[r.length-1]||""),o=r.split(t.NEWLINE_REGEXP);return n&&o.pop(),o.length===1&&!n?(this.buffer.push(o[0]),[]):(this.buffer.length>0&&(o=[this.buffer.join("")+o[0],...o.slice(1)],this.buffer=[]),n||(this.buffer=[o.pop()||""]),o)}decodeText(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof Buffer<"u"){if(e instanceof Buffer)return e.toString();if(e instanceof Uint8Array)return Buffer.from(e).toString();throw new xTe.AnthropicError(`Unexpected: received non-Uint8Array (${e.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if(e instanceof Uint8Array||e instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(e);throw new xTe.AnthropicError(`Unexpected: received non-Uint8Array/ArrayBuffer (${e.constructor.name}) in a web platform. Please report this error.`)}throw new xTe.AnthropicError("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length&&!this.trailingCR)return[];let e=[this.buffer.join("")];return this.buffer=[],this.trailingCR=!1,e}};y3.NEWLINE_CHARS=new Set([`
119
119
  `,"\r"]);y3.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function qYo(t){let e=new y3,r=[];for(let n of t)r.push(...e.decode(n));return r}Mv._decodeChunks=qYo;function HYo(t,e){let r=t.indexOf(e);return r!==-1?[t.substring(0,r),e,t.substring(r+e.length)]:[t,"",""]}function GZe(t){if(t[Symbol.asyncIterator])return t;let e=t.getReader();return{async next(){try{let r=await e.read();return r?.done&&e.releaseLock(),r}catch(r){throw e.releaseLock(),r}},async return(){let r=e.cancel();return e.releaseLock(),await r,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}Mv.readableStreamAsyncIterable=GZe});var ITe=S(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.createForm=us.multipartFormRequestOptions=us.maybeMultipartFormRequestOptions=us.isMultipartBody=us.toFile=us.isUploadable=us.isBlobLike=us.isFileLike=us.isResponseLike=us.fileFromPath=void 0;var cH=ite(),GYo=ite();Object.defineProperty(us,"fileFromPath",{enumerable:!0,get:function(){return GYo.fileFromPath}});var jYo=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";us.isResponseLike=jYo;var zYo=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&(0,us.isBlobLike)(t);us.isFileLike=zYo;var QYo=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function";us.isBlobLike=QYo;var VYo=t=>(0,us.isFileLike)(t)||(0,us.isResponseLike)(t)||(0,cH.isFsReadStream)(t);us.isUploadable=VYo;async function j_r(t,e,r){if(t=await t,r??(r=(0,us.isFileLike)(t)?{lastModified:t.lastModified,type:t.type}:{}),(0,us.isResponseLike)(t)){let o=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()??"unknown_file"),new cH.File([o],e,r)}let n=await WYo(t);if(e||(e=KYo(t)??"unknown_file"),!r.type){let o=n[0]?.type;typeof o=="string"&&(r={...r,type:o})}return new cH.File(n,e,r)}us.toFile=j_r;async function WYo(t){let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if((0,us.isBlobLike)(t))e.push(await t.arrayBuffer());else if(ZYo(t))for await(let r of t)e.push(r);else throw new Error(`Unexpected data type: ${typeof t}; constructor: ${t?.constructor?.name}; props: ${YYo(t)}`);return e}function YYo(t){return`[${Object.getOwnPropertyNames(t).map(r=>`"${r}"`).join(", ")}]`}function KYo(t){return zZe(t.name)||zZe(t.filename)||zZe(t.path)?.split(/[\\/]/).pop()}var zZe=t=>{if(typeof t=="string")return t;if(typeof Buffer<"u"&&t instanceof Buffer)return String(t)},ZYo=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",JYo=t=>t&&typeof t=="object"&&t.body&&t[Symbol.toStringTag]==="MultipartBody";us.isMultipartBody=JYo;var XYo=async t=>{if(!QZe(t.body))return t;let e=await(0,us.createForm)(t.body);return(0,cH.getMultipartRequestOptions)(e,t)};us.maybeMultipartFormRequestOptions=XYo;var eKo=async t=>{let e=await(0,us.createForm)(t.body);return(0,cH.getMultipartRequestOptions)(e,t)};us.multipartFormRequestOptions=eKo;var tKo=async t=>{let e=new cH.FormData;return await Promise.all(Object.entries(t||{}).map(([r,n])=>VZe(e,r,n))),e};us.createForm=tKo;var QZe=t=>{if((0,us.isUploadable)(t))return!0;if(Array.isArray(t))return t.some(QZe);if(t&&typeof t=="object"){for(let e in t)if(QZe(t[e]))return!0}return!1},VZe=async(t,e,r)=>{if(r!==void 0){if(r==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")t.append(e,String(r));else if((0,us.isUploadable)(r)){let n=await j_r(r);t.append(e,n)}else if(Array.isArray(r))await Promise.all(r.map(n=>VZe(t,e+"[]",n)));else if(typeof r=="object")await Promise.all(Object.entries(r).map(([n,o])=>VZe(t,`${e}[${n}]`,o)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${r} instead`)}}});var wTe=S(dr=>{"use strict";var rKo=dr&&dr.__classPrivateFieldSet||function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},nKo=dr&&dr.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},DTe;Object.defineProperty(dr,"__esModule",{value:!0});dr.isObj=dr.toBase64=dr.getRequiredHeader=dr.isHeadersProtocol=dr.isRunningInBrowser=dr.debug=dr.hasOwn=dr.isEmptyObj=dr.maybeCoerceBoolean=dr.maybeCoerceFloat=dr.maybeCoerceInteger=dr.coerceBoolean=dr.coerceFloat=dr.coerceInteger=dr.readEnv=dr.ensurePresent=dr.castToError=dr.sleep=dr.safeJSON=dr.isRequestOptions=dr.createResponseHeaders=dr.PagePromise=dr.AbstractPage=dr.APIClient=dr.APIPromise=dr.createForm=dr.multipartFormRequestOptions=dr.maybeMultipartFormRequestOptions=void 0;var uH=U_r(),oKo=jZe(),G0=aH(),WZe=ite(),YZe=ITe(),XZe=ITe();Object.defineProperty(dr,"maybeMultipartFormRequestOptions",{enumerable:!0,get:function(){return XZe.maybeMultipartFormRequestOptions}});Object.defineProperty(dr,"multipartFormRequestOptions",{enumerable:!0,get:function(){return XZe.multipartFormRequestOptions}});Object.defineProperty(dr,"createForm",{enumerable:!0,get:function(){return XZe.createForm}});async function Y_r(t){let{response:e}=t;if(t.options.stream)return S3("response",e.status,e.url,e.headers,e.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(e,t.controller):oKo.Stream.fromSSEResponse(e,t.controller);if(e.status===204)return null;if(t.options.__binaryResponse)return e;let r=e.headers.get("content-type");if(r?.includes("application/json")||r?.includes("application/vnd.api+json")){let i=await e.json();return S3("response",e.status,e.url,e.headers,i),i}let o=await e.text();return S3("response",e.status,e.url,e.headers,o),o}var ste=class t extends Promise{constructor(e,r=Y_r){super(n=>{n(null)}),this.responsePromise=e,this.parseResponse=r}_thenUnwrap(e){return new t(this.responsePromise,async r=>e(await this.parseResponse(r)))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:r}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(this.parseResponse)),this.parsedPromise}then(e,r){return this.parse().then(e,r)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};dr.APIPromise=ste;var ZZe=class{constructor({baseURL:e,maxRetries:r=2,timeout:n=6e5,httpAgent:o,fetch:i}){this.baseURL=e,this.maxRetries=KZe("maxRetries",r),this.timeout=KZe("timeout",n),this.httpAgent=o,this.fetch=i??WZe.fetch}authHeaders(e){return{}}defaultHeaders(e){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...lKo(),...this.authHeaders(e)}}validateHeaders(e,r){}defaultIdempotencyKey(){return`stainless-node-retry-${vKo()}`}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(async o=>{let i=o&&(0,YZe.isBlobLike)(o?.body)?new DataView(await o.body.arrayBuffer()):o?.body instanceof DataView?o.body:o?.body instanceof ArrayBuffer?new DataView(o.body):o&&ArrayBuffer.isView(o?.body)?new DataView(o.body.buffer):o?.body;return{method:e,path:r,...o,body:i}}))}getAPIList(e,r,n){return this.requestAPIList(r,{method:"get",path:e,...n})}calculateContentLength(e){if(typeof e=="string"){if(typeof Buffer<"u")return Buffer.byteLength(e,"utf8").toString();if(typeof TextEncoder<"u")return new TextEncoder().encode(e).length.toString()}else if(ArrayBuffer.isView(e))return e.byteLength.toString();return null}buildRequest(e){let{method:r,path:n,query:o,headers:i={}}=e,s=ArrayBuffer.isView(e.body)||e.__binaryRequest&&typeof e.body=="string"?e.body:(0,YZe.isMultipartBody)(e.body)?e.body.body:e.body?JSON.stringify(e.body,null,2):null,a=this.calculateContentLength(s),c=this.buildURL(n,o);"timeout"in e&&KZe("timeout",e.timeout);let u=e.timeout??this.timeout,l=e.httpAgent??this.httpAgent??(0,WZe.getDefaultAgent)(c),d=u+1e3;typeof l?.options?.timeout=="number"&&d>(l.options.timeout??0)&&(l.options.timeout=d),this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let p=this.buildHeaders({options:e,headers:i,contentLength:a});return{req:{method:r,...s&&{body:s},headers:p,...l&&{agent:l},signal:e.signal??null},url:c,timeout:u}}buildHeaders({options:e,headers:r,contentLength:n}){let o={};n&&(o["content-length"]=n);let i=this.defaultHeaders(e);return W_r(o,i),W_r(o,r),(0,YZe.isMultipartBody)(e.body)&&WZe.kind!=="node"&&delete o["content-type"],this.validateHeaders(o,r),o}async prepareOptions(e){}async prepareRequest(e,{url:r,options:n}){}parseHeaders(e){return e?Symbol.iterator in e?Object.fromEntries(Array.from(e).map(r=>[...r])):{...e}:{}}makeStatusError(e,r,n,o){return G0.APIError.generate(e,r,n,o)}request(e,r=null){return new ste(this.makeRequest(e,r))}async makeRequest(e,r){let n=await e;r==null&&(r=n.maxRetries??this.maxRetries),await this.prepareOptions(n);let{req:o,url:i,timeout:s}=this.buildRequest(n);if(await this.prepareRequest(o,{url:i,options:n}),S3("request",i,n,o.headers),n.signal?.aborted)throw new G0.APIUserAbortError;let a=new AbortController,c=await this.fetchWithTimeout(i,o,s,a).catch(dr.castToError);if(c instanceof Error){if(n.signal?.aborted)throw new G0.APIUserAbortError;if(r)return this.retryRequest(n,r);throw c.name==="AbortError"?new G0.APIConnectionTimeoutError:new G0.APIConnectionError({cause:c})}let u=(0,dr.createResponseHeaders)(c.headers);if(!c.ok){if(r&&this.shouldRetry(c)){let E=`retrying, ${r} attempts remaining`;return S3(`response (error; ${E})`,c.status,i,u),this.retryRequest(n,r,u)}let l=await c.text().catch(E=>(0,dr.castToError)(E).message),d=(0,dr.safeJSON)(l),p=d?void 0:l;throw S3(`response (error; ${r?"(error; no more retries left)":"(error; not retryable)"})`,c.status,i,u,p),this.makeStatusError(c.status,d,p,u)}return{response:c,options:n,controller:a}}requestAPIList(e,r){let n=this.makeRequest(r,null);return new RTe(this,n,e)}buildURL(e,r){let n=fKo(e)?new URL(e):new URL(this.baseURL+(this.baseURL.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery();return eJe(o)||(r={...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(n.search=this.stringifyQuery(r)),n.toString()}stringifyQuery(e){return Object.entries(e).filter(([r,n])=>typeof n<"u").map(([r,n])=>{if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return`${encodeURIComponent(r)}=${encodeURIComponent(n)}`;if(n===null)return`${encodeURIComponent(r)}=`;throw new G0.AnthropicError(`Cannot stringify type ${typeof n}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout(e,r,n,o){let{signal:i,...s}=r||{};i&&i.addEventListener("abort",()=>o.abort());let a=setTimeout(()=>o.abort(),n);return this.getRequestClient().fetch.call(void 0,e,{signal:o.signal,...s}).finally(()=>{clearTimeout(a)})}getRequestClient(){return{fetch:this.fetch}}shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n){let o,i=n?.["retry-after-ms"];if(i){let a=parseFloat(i);Number.isNaN(a)||(o=a)}let s=n?.["retry-after"];if(s&&!o){let a=parseFloat(s);Number.isNaN(a)?o=Date.parse(s)-Date.now():o=a*1e3}if(!(o&&0<=o&&o<60*1e3)){let a=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,a)}return await(0,dr.sleep)(o),this.makeRequest(e,r-1)}calculateDefaultRetryTimeoutMillis(e,r){let i=r-e,s=Math.min(.5*Math.pow(2,i),8),a=1-Math.random()*.25;return s*a*1e3}getUserAgent(){return`${this.constructor.name}/JS ${uH.VERSION}`}};dr.APIClient=ZZe;var JZe=class{constructor(e,r,n,o){DTe.set(this,void 0),rKo(this,DTe,e,"f"),this.options=o,this.response=r,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageInfo()!=null:!1}async getNextPage(){let e=this.nextPageInfo();if(!e)throw new G0.AnthropicError("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let r={...this.options};if("params"in e&&typeof r.query=="object")r.query={...r.query,...e.params};else if("url"in e){let n=[...Object.entries(r.query||{}),...e.url.searchParams.entries()];for(let[o,i]of n)e.url.searchParams.set(o,i);r.query=void 0,r.path=e.url.toString()}return await nKo(this,DTe,"f").requestAPIList(this.constructor,r)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(DTe=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let r of e.getPaginatedItems())yield r}};dr.AbstractPage=JZe;var RTe=class extends ste{constructor(e,r,n){super(r,async o=>new n(e,o.response,await Y_r(o),o.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let r of e)yield r}};dr.PagePromise=RTe;var iKo=t=>new Proxy(Object.fromEntries(t.entries()),{get(e,r){let n=r.toString();return e[n.toLowerCase()]||e[n]}});dr.createResponseHeaders=iKo;var sKo={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},aKo=t=>typeof t=="object"&&t!==null&&!eJe(t)&&Object.keys(t).every(e=>tJe(sKo,e));dr.isRequestOptions=aKo;var cKo=()=>{if(typeof Deno<"u"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":uH.VERSION,"X-Stainless-OS":Q_r(Deno.build.os),"X-Stainless-Arch":z_r(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":uH.VERSION,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":uH.VERSION,"X-Stainless-OS":Q_r(process.platform),"X-Stainless-Arch":z_r(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let t=uKo();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":uH.VERSION,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":uH.VERSION,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function uKo(){if(typeof navigator>"u"||!navigator)return null;let t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:r}of t){let n=r.exec(navigator.userAgent);if(n){let o=n[1]||0,i=n[2]||0,s=n[3]||0;return{browser:e,version:`${o}.${i}.${s}`}}}return null}var z_r=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",Q_r=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown"),V_r,lKo=()=>V_r??(V_r=cKo()),dKo=t=>{try{return JSON.parse(t)}catch{return}};dr.safeJSON=dKo;var pKo=new RegExp("^(?:[a-z]+:)?//","i"),fKo=t=>pKo.test(t),mKo=t=>new Promise(e=>setTimeout(e,t));dr.sleep=mKo;var KZe=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new G0.AnthropicError(`${t} must be an integer`);if(e<0)throw new G0.AnthropicError(`${t} must be a positive integer`);return e},hKo=t=>t instanceof Error?t:new Error(t);dr.castToError=hKo;var gKo=t=>{if(t==null)throw new G0.AnthropicError(`Expected a value to be given but received ${t} instead.`);return t};dr.ensurePresent=gKo;var _Ko=t=>{if(typeof process<"u")return process.env?.[t]?.trim()??void 0;if(typeof Deno<"u")return Deno.env?.get?.(t)?.trim()};dr.readEnv=_Ko;var EKo=t=>{if(typeof t=="number")return Math.round(t);if(typeof t=="string")return parseInt(t,10);throw new G0.AnthropicError(`Could not coerce ${t} (type: ${typeof t}) into a number`)};dr.coerceInteger=EKo;var AKo=t=>{if(typeof t=="number")return t;if(typeof t=="string")return parseFloat(t);throw new G0.AnthropicError(`Could not coerce ${t} (type: ${typeof t}) into a number`)};dr.coerceFloat=AKo;var yKo=t=>typeof t=="boolean"?t:typeof t=="string"?t==="true":!!t;dr.coerceBoolean=yKo;var SKo=t=>{if(t!==void 0)return(0,dr.coerceInteger)(t)};dr.maybeCoerceInteger=SKo;var bKo=t=>{if(t!==void 0)return(0,dr.coerceFloat)(t)};dr.maybeCoerceFloat=bKo;var TKo=t=>{if(t!==void 0)return(0,dr.coerceBoolean)(t)};dr.maybeCoerceBoolean=TKo;function eJe(t){if(!t)return!0;for(let e in t)return!1;return!0}dr.isEmptyObj=eJe;function tJe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}dr.hasOwn=tJe;function W_r(t,e){for(let r in e){if(!tJe(e,r))continue;let n=r.toLowerCase();if(!n)continue;let o=e[r];o===null?delete t[n]:o!==void 0&&(t[n]=o)}}function S3(t,...e){typeof process<"u"&&process?.env?.DEBUG==="true"&&console.log(`Anthropic:DEBUG:${t}`,...e)}dr.debug=S3;var vKo=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)}),CKo=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";dr.isRunningInBrowser=CKo;var xKo=t=>typeof t?.get=="function";dr.isHeadersProtocol=xKo;var wKo=(t,e)=>{let r=e.toLowerCase();if((0,dr.isHeadersProtocol)(t)){let n=e[0]?.toUpperCase()+e.substring(1).replace(/([^\w])(\w)/g,(o,i,s)=>i+s.toUpperCase());for(let o of[e,r,e.toUpperCase(),n]){let i=t.get(o);if(i)return i}}for(let[n,o]of Object.entries(t))if(n.toLowerCase()===r)return Array.isArray(o)?(o.length<=1||console.warn(`Received ${o.length} entries for the ${e} header, using the first entry.`),o[0]):o;throw new Error(`Could not find ${e} header`)};dr.getRequiredHeader=wKo;var IKo=t=>{if(!t)return"";if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof btoa<"u")return btoa(t);throw new G0.AnthropicError("Cannot generate b64 string; Expected `Buffer` or `btoa` to be defined")};dr.toBase64=IKo;function DKo(t){return t!=null&&typeof t=="object"&&!Array.isArray(t)}dr.isObj=DKo});var aH=S(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.InternalServerError=Sa.RateLimitError=Sa.UnprocessableEntityError=Sa.ConflictError=Sa.NotFoundError=Sa.PermissionDeniedError=Sa.AuthenticationError=Sa.BadRequestError=Sa.APIConnectionTimeoutError=Sa.APIConnectionError=Sa.APIUserAbortError=Sa.APIError=Sa.AnthropicError=void 0;var RKo=wTe(),OTe=class extends Error{};Sa.AnthropicError=OTe;var j0=class t extends OTe{constructor(e,r,n,o){super(`${t.makeMessage(e,r,n)}`),this.status=e,this.headers=o,this.error=r}static makeMessage(e,r,n){let o=r?.message?typeof r.message=="string"?r.message:JSON.stringify(r.message):r?JSON.stringify(r):n;return e&&o?`${e} ${o}`:e?`${e} status code (no body)`:o||"(no status code or body)"}static generate(e,r,n,o){if(!e)return new ate({cause:(0,RKo.castToError)(r)});let i=r;return e===400?new NTe(e,i,n,o):e===401?new PTe(e,i,n,o):e===403?new MTe(e,i,n,o):e===404?new kTe(e,i,n,o):e===409?new LTe(e,i,n,o):e===422?new BTe(e,i,n,o):e===429?new FTe(e,i,n,o):e>=500?new UTe(e,i,n,o):new t(e,i,n,o)}};Sa.APIError=j0;var rJe=class extends j0{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0),this.status=void 0}};Sa.APIUserAbortError=rJe;var ate=class extends j0{constructor({message:e,cause:r}){super(void 0,void 0,e||"Connection error.",void 0),this.status=void 0,r&&(this.cause=r)}};Sa.APIConnectionError=ate;var nJe=class extends ate{constructor({message:e}={}){super({message:e??"Request timed out."})}};Sa.APIConnectionTimeoutError=nJe;var NTe=class extends j0{constructor(){super(...arguments),this.status=400}};Sa.BadRequestError=NTe;var PTe=class extends j0{constructor(){super(...arguments),this.status=401}};Sa.AuthenticationError=PTe;var MTe=class extends j0{constructor(){super(...arguments),this.status=403}};Sa.PermissionDeniedError=MTe;var kTe=class extends j0{constructor(){super(...arguments),this.status=404}};Sa.NotFoundError=kTe;var LTe=class extends j0{constructor(){super(...arguments),this.status=409}};Sa.ConflictError=LTe;var BTe=class extends j0{constructor(){super(...arguments),this.status=422}};Sa.UnprocessableEntityError=BTe;var FTe=class extends j0{constructor(){super(...arguments),this.status=429}};Sa.RateLimitError=FTe;var UTe=class extends j0{};Sa.InternalServerError=UTe});var iJe=S($Te=>{"use strict";Object.defineProperty($Te,"__esModule",{value:!0});$Te.APIResource=void 0;var oJe=class{constructor(e){this._client=e}};$Te.APIResource=oJe});var K_r=S(lH=>{"use strict";Object.defineProperty(lH,"__esModule",{value:!0});lH.Completions=void 0;var OKo=iJe(),qTe=class extends OKo.APIResource{create(e,r){return this._client.post("/v1/complete",{body:e,timeout:6e5,...r,stream:e.stream??!1})}};lH.Completions=qTe;qTe=lH.Completions||(lH.Completions={})});var Z_r=S(HTe=>{"use strict";Object.defineProperty(HTe,"__esModule",{value:!0});HTe.partialParse=void 0;var NKo=t=>{let e=0,r=[];for(;e<t.length;){let n=t[e];if(n==="\\"){e++;continue}if(n==="{"){r.push({type:"brace",value:"{"}),e++;continue}if(n==="}"){r.push({type:"brace",value:"}"}),e++;continue}if(n==="["){r.push({type:"paren",value:"["}),e++;continue}if(n==="]"){r.push({type:"paren",value:"]"}),e++;continue}if(n===":"){r.push({type:"separator",value:":"}),e++;continue}if(n===","){r.push({type:"delimiter",value:","}),e++;continue}if(n==='"'){let a="",c=!1;for(n=t[++e];n!=='"';){if(e===t.length){c=!0;break}if(n==="\\"){if(e++,e===t.length){c=!0;break}a+=n+t[e],n=t[++e]}else a+=n,n=t[++e]}n=t[++e],c||r.push({type:"string",value:a});continue}if(n&&/\s/.test(n)){e++;continue}let i=/[0-9]/;if(n&&i.test(n)||n==="-"||n==="."){let a="";for(n==="-"&&(a+=n,n=t[++e]);n&&i.test(n)||n===".";)a+=n,n=t[++e];r.push({type:"number",value:a});continue}let s=/[a-z]/i;if(n&&s.test(n)){let a="";for(;n&&s.test(n)&&e!==t.length;)a+=n,n=t[++e];if(a=="true"||a=="false"||a==="null")r.push({type:"name",value:a});else{e++;continue}continue}e++}return r},dH=t=>{if(t.length===0)return t;let e=t[t.length-1];switch(e.type){case"separator":return t=t.slice(0,t.length-1),dH(t);break;case"number":let r=e.value[e.value.length-1];if(r==="."||r==="-")return t=t.slice(0,t.length-1),dH(t);case"string":let n=t[t.length-2];if(n?.type==="delimiter")return t=t.slice(0,t.length-1),dH(t);if(n?.type==="brace"&&n.value==="{")return t=t.slice(0,t.length-1),dH(t);break;case"delimiter":return t=t.slice(0,t.length-1),dH(t);break}return t},PKo=t=>{let e=[];return t.map(r=>{r.type==="brace"&&(r.value==="{"?e.push("}"):e.splice(e.lastIndexOf("}"),1)),r.type==="paren"&&(r.value==="["?e.push("]"):e.splice(e.lastIndexOf("]"),1))}),e.length>0&&e.reverse().map(r=>{r==="}"?t.push({type:"brace",value:"}"}):r==="]"&&t.push({type:"paren",value:"]"})}),t},MKo=t=>{let e="";return t.map(r=>{switch(r.type){case"string":e+='"'+r.value+'"';break;default:e+=r.value;break}}),e},kKo=t=>JSON.parse(MKo(PKo(dH(NKo(t)))));HTe.partialParse=kKo});var pJe=S(cN=>{"use strict";var S_=cN&&cN.__classPrivateFieldSet||function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},Ci=cN&&cN.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},WE,aN,GTe,jTe,cte,ute,zTe,lte,z2,dte,QTe,VTe,pH,sJe,J_r,aJe,cJe,uJe,lJe,X_r;Object.defineProperty(cN,"__esModule",{value:!0});cN.MessageStream=void 0;var b_=aH(),e0r=jZe(),LKo=Z_r(),t0r="__json_buf",dJe=class t{constructor(){WE.add(this),this.messages=[],this.receivedMessages=[],aN.set(this,void 0),this.controller=new AbortController,GTe.set(this,void 0),jTe.set(this,()=>{}),cte.set(this,()=>{}),ute.set(this,void 0),zTe.set(this,()=>{}),lte.set(this,()=>{}),z2.set(this,{}),dte.set(this,!1),QTe.set(this,!1),VTe.set(this,!1),pH.set(this,!1),aJe.set(this,e=>{if(S_(this,QTe,!0,"f"),e instanceof Error&&e.name==="AbortError"&&(e=new b_.APIUserAbortError),e instanceof b_.APIUserAbortError)return S_(this,VTe,!0,"f"),this._emit("abort",e);if(e instanceof b_.AnthropicError)return this._emit("error",e);if(e instanceof Error){let r=new b_.AnthropicError(e.message);return r.cause=e,this._emit("error",r)}return this._emit("error",new b_.AnthropicError(String(e)))}),S_(this,GTe,new Promise((e,r)=>{S_(this,jTe,e,"f"),S_(this,cte,r,"f")}),"f"),S_(this,ute,new Promise((e,r)=>{S_(this,zTe,e,"f"),S_(this,lte,r,"f")}),"f"),Ci(this,GTe,"f").catch(()=>{}),Ci(this,ute,"f").catch(()=>{})}static fromReadableStream(e){let r=new t;return r._run(()=>r._fromReadableStream(e)),r}static createMessage(e,r,n){let o=new t;for(let i of r.messages)o._addMessageParam(i);return o._run(()=>o._createMessage(e,{...r,stream:!0},{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},Ci(this,aJe,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,r=!0){this.receivedMessages.push(e),r&&this._emit("message",e)}async _createMessage(e,r,n){let o=n?.signal;o&&(o.aborted&&this.controller.abort(),o.addEventListener("abort",()=>this.controller.abort())),Ci(this,WE,"m",cJe).call(this);let i=await e.create({...r,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(let s of i)Ci(this,WE,"m",uJe).call(this,s);if(i.controller.signal?.aborted)throw new b_.APIUserAbortError;Ci(this,WE,"m",lJe).call(this)}_connected(){this.ended||(Ci(this,jTe,"f").call(this),this._emit("connect"))}get ended(){return Ci(this,dte,"f")}get errored(){return Ci(this,QTe,"f")}get aborted(){return Ci(this,VTe,"f")}abort(){this.controller.abort()}on(e,r){return(Ci(this,z2,"f")[e]||(Ci(this,z2,"f")[e]=[])).push({listener:r}),this}off(e,r){let n=Ci(this,z2,"f")[e];if(!n)return this;let o=n.findIndex(i=>i.listener===r);return o>=0&&n.splice(o,1),this}once(e,r){return(Ci(this,z2,"f")[e]||(Ci(this,z2,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,n)=>{S_(this,pH,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,r)})}async done(){S_(this,pH,!0,"f"),await Ci(this,ute,"f")}get currentMessage(){return Ci(this,aN,"f")}async finalMessage(){return await this.done(),Ci(this,WE,"m",sJe).call(this)}async finalText(){return await this.done(),Ci(this,WE,"m",J_r).call(this)}_emit(e,...r){if(Ci(this,dte,"f"))return;e==="end"&&(S_(this,dte,!0,"f"),Ci(this,zTe,"f").call(this));let n=Ci(this,z2,"f")[e];if(n&&(Ci(this,z2,"f")[e]=n.filter(o=>!o.once),n.forEach(({listener:o})=>o(...r))),e==="abort"){let o=r[0];!Ci(this,pH,"f")&&!n?.length&&Promise.reject(o),Ci(this,cte,"f").call(this,o),Ci(this,lte,"f").call(this,o),this._emit("end");return}if(e==="error"){let o=r[0];!Ci(this,pH,"f")&&!n?.length&&Promise.reject(o),Ci(this,cte,"f").call(this,o),Ci(this,lte,"f").call(this,o),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",Ci(this,WE,"m",sJe).call(this))}async _fromReadableStream(e,r){let n=r?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",()=>this.controller.abort())),Ci(this,WE,"m",cJe).call(this),this._connected();let o=e0r.Stream.fromReadableStream(e,this.controller);for await(let i of o)Ci(this,WE,"m",uJe).call(this,i);if(o.controller.signal?.aborted)throw new b_.APIUserAbortError;Ci(this,WE,"m",lJe).call(this)}[(aN=new WeakMap,GTe=new WeakMap,jTe=new WeakMap,cte=new WeakMap,ute=new WeakMap,zTe=new WeakMap,lte=new WeakMap,z2=new WeakMap,dte=new WeakMap,QTe=new WeakMap,VTe=new WeakMap,pH=new WeakMap,aJe=new WeakMap,WE=new WeakSet,sJe=function(){if(this.receivedMessages.length===0)throw new b_.AnthropicError("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},J_r=function(){if(this.receivedMessages.length===0)throw new b_.AnthropicError("stream ended without producing a Message with role=assistant");let r=this.receivedMessages.at(-1).content.filter(n=>n.type==="text").map(n=>n.text);if(r.length===0)throw new b_.AnthropicError("stream ended without producing a content block with type=text");return r.join(" ")},cJe=function(){this.ended||S_(this,aN,void 0,"f")},uJe=function(r){if(this.ended)return;let n=Ci(this,WE,"m",X_r).call(this,r);switch(this._emit("streamEvent",r,n),r.type){case"content_block_delta":{let o=n.content.at(-1);r.delta.type==="text_delta"&&o.type==="text"?this._emit("text",r.delta.text,o.text||""):r.delta.type==="input_json_delta"&&o.type==="tool_use"&&o.input&&this._emit("inputJson",r.delta.partial_json,o.input);break}case"message_stop":{this._addMessageParam(n),this._addMessage(n,!0);break}case"content_block_stop":{this._emit("contentBlock",n.content.at(-1));break}case"message_start":{S_(this,aN,n,"f");break}case"content_block_start":case"message_delta":break}},lJe=function(){if(this.ended)throw new b_.AnthropicError("stream has ended, this shouldn't happen");let r=Ci(this,aN,"f");if(!r)throw new b_.AnthropicError("request ended without sending any chunks");return S_(this,aN,void 0,"f"),r},X_r=function(r){let n=Ci(this,aN,"f");if(r.type==="message_start"){if(n)throw new b_.AnthropicError(`Unexpected event order, got ${r.type} before receiving "message_stop"`);return r.message}if(!n)throw new b_.AnthropicError(`Unexpected event order, got ${r.type} before "message_start"`);switch(r.type){case"message_stop":return n;case"message_delta":return n.stop_reason=r.delta.stop_reason,n.stop_sequence=r.delta.stop_sequence,n.usage.output_tokens=r.usage.output_tokens,n;case"content_block_start":return n.content.push(r.content_block),n;case"content_block_delta":{let o=n.content.at(r.index);if(o?.type==="text"&&r.delta.type==="text_delta")o.text+=r.delta.text;else if(o?.type==="tool_use"&&r.delta.type==="input_json_delta"){let i=o[t0r]||"";i+=r.delta.partial_json,Object.defineProperty(o,t0r,{value:i,enumerable:!1,writable:!0}),i&&(o.input=(0,LKo.partialParse)(i))}return n}case"content_block_stop":return n}},Symbol.asyncIterator)](){let e=[],r=[],n=!1;return this.on("streamEvent",o=>{let i=r.shift();i?i.resolve(o):e.push(o)}),this.on("end",()=>{n=!0;for(let o of r)o.resolve(void 0);r.length=0}),this.on("abort",o=>{n=!0;for(let i of r)i.reject(o);r.length=0}),this.on("error",o=>{n=!0;for(let i of r)i.reject(o);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((i,s)=>r.push({resolve:i,reject:s})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new e0r.Stream(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};cN.MessageStream=dJe});var r0r=S(uN=>{"use strict";Object.defineProperty(uN,"__esModule",{value:!0});uN.Messages=uN.MessageStream=void 0;var BKo=iJe(),FKo=pJe(),UKo=pJe();Object.defineProperty(uN,"MessageStream",{enumerable:!0,get:function(){return UKo.MessageStream}});var WTe=class extends BKo.APIResource{create(e,r){return this._client.post("/v1/messages",{body:e,timeout:6e5,...r,stream:e.stream??!1})}stream(e,r){return FKo.MessageStream.createMessage(this,e,r)}};uN.Messages=WTe;WTe=uN.Messages||(uN.Messages={})});var n0r=S(fH=>{"use strict";Object.defineProperty(fH,"__esModule",{value:!0});fH.Messages=fH.Completions=void 0;var $Ko=K_r();Object.defineProperty(fH,"Completions",{enumerable:!0,get:function(){return $Ko.Completions}});var qKo=r0r();Object.defineProperty(fH,"Messages",{enumerable:!0,get:function(){return qKo.Messages}})});var JTe=S((Un,i0r)=>{"use strict";var HKo=Un&&Un.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),GKo=Un&&Un.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),KTe=Un&&Un.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&HKo(e,t,r);return GKo(e,t),e},o0r;Object.defineProperty(Un,"__esModule",{value:!0});Un.fileFromPath=Un.toFile=Un.UnprocessableEntityError=Un.PermissionDeniedError=Un.InternalServerError=Un.AuthenticationError=Un.BadRequestError=Un.RateLimitError=Un.ConflictError=Un.NotFoundError=Un.APIUserAbortError=Un.APIConnectionTimeoutError=Un.APIConnectionError=Un.APIError=Un.AnthropicError=Un.AI_PROMPT=Un.HUMAN_PROMPT=Un.Anthropic=void 0;var rc=KTe(aH()),ZTe=KTe(ITe()),mH=KTe(wTe()),YTe=KTe(n0r()),Fa=class extends mH.APIClient{constructor({baseURL:e=mH.readEnv("ANTHROPIC_BASE_URL"),apiKey:r=mH.readEnv("ANTHROPIC_API_KEY")??null,authToken:n=mH.readEnv("ANTHROPIC_AUTH_TOKEN")??null,...o}={}){let i={apiKey:r,authToken:n,...o,baseURL:e||"https://api.anthropic.com"};super({baseURL:i.baseURL,timeout:i.timeout??6e5,httpAgent:i.httpAgent,maxRetries:i.maxRetries,fetch:i.fetch}),this.completions=new YTe.Completions(this),this.messages=new YTe.Messages(this),this._options=i,this.apiKey=r,this.authToken=n}defaultQuery(){return this._options.defaultQuery}defaultHeaders(e){return{...super.defaultHeaders(e),"anthropic-version":"2023-06-01",...this._options.defaultHeaders}}validateHeaders(e,r){if(!(this.apiKey&&e["x-api-key"])&&r["x-api-key"]!==null&&!(this.authToken&&e.authorization)&&r.authorization!==null)throw new Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}authHeaders(e){let r=this.apiKeyAuth(e),n=this.bearerAuth(e);return r!=null&&!mH.isEmptyObj(r)?r:n!=null&&!mH.isEmptyObj(n)?n:{}}apiKeyAuth(e){return this.apiKey==null?{}:{"X-Api-Key":this.apiKey}}bearerAuth(e){return this.authToken==null?{}:{Authorization:`Bearer ${this.authToken}`}}};Un.Anthropic=Fa;o0r=Fa;Fa.Anthropic=o0r;Fa.HUMAN_PROMPT=`
@@ -992,7 +992,7 @@ globstar while`,e,p,r,f,_),this.matchOne(e.slice(p),r.slice(f),n))return this.de
992
992
  `).join(`\r
993
993
  `)),mYo(t,o,{encoding:r,flush:!0})}var c_r=new ETe.default({fetchMethod:t=>SYo(t),ttl:300*1e3,ttlAutopurge:!1,max:1e3});async function h_r(t){let e=Xee(t);return c_r.get(e)||c_r.fetchMethod?.(e)}async function SYo(t){let e=new AbortController;setTimeout(()=>{e.abort()},1e3);let r=await Vgr(t,e.signal,15),n=0;for(let o of r)h3(o)==="CRLF"&&n++;return n>3?"CRLF":"LF"}function g_r(t,e,r){if(t.has(e))return t.get(e);let n=r();return t.set(e,n),n}var bYo=new ETe.default({fetchMethod:t=>__r(t),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function A_(t){let e=Xee(t);return g_r(bYo,e,()=>__r(e))}function __r(t){let r=Buffer.alloc(4096),n;try{n=u_r(t,"r");let o=l_r(n,r,0,4096,0);return o===0?"utf8":o>=2&&r[0]===255&&r[1]===254?"utf16le":o>=3&&r[0]===239&&r[1]===187&&r[2]===191||r.slice(0,o).toString("utf8").length>0?"utf8":"ascii"}catch(o){return Te(`Error detecting encoding for file ${t}: ${o}`),"utf8"}finally{n&&d_r(n)}}var TYo=new ETe.default({fetchMethod:t=>E_r(t),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function h3(t){let e=Xee(t);return g_r(TYo,e,()=>E_r(e))}function E_r(t,e="utf8"){try{if(!p_r(t).isFile())return"LF";let n=Buffer.alloc(4096),o=u_r(t,"r"),i=l_r(o,n,0,4096,0);d_r(o);let s=n.toString(e,0,i),a=0,c=0;for(let u=0;u<s.length;u++)s[u]===`
994
994
  `&&(u>0&&s[u-1]==="\r"?a++:c++);return a>c?"CRLF":"LF"}catch(r){return Te(`Error detecting line endings for file ${t}: ${r}`),"LF"}}function xZe(t){let e=f_r(t)?t:Xee(Ge(),t);return e.endsWith(" AM.png")?e.replace(" AM.png","\u202FAM.png"):e.endsWith(" PM.png")?e.replace(" PM.png","\u202FPM.png"):e}function wZe(t){return t?f_r(t)?t:Xee(Ge(),t):void 0}function A_r(t){try{let e=wZe(t),r=e?EYo(Ge(),e):void 0;return{absolutePath:e,relativePath:r}}catch(e){return ye("getAbsoluteAndRelativePaths error ",e),{absolutePath:null,relativePath:null}}}function STe(t){try{let e=AYo(t),r=i_r(t,s_r(t));if(!hYo(e))return;let i=gYo(e).filter(s=>i_r(s,s_r(s))===r&&yYo(e,s)!==t)[0];return i||void 0}catch(e){Te(`Error finding similar file for ${t}: ${e}`);return}}function sN({content:t,startLine:e}){return t?t.split(/\r?\n/).map((r,n)=>{let o=n+e,i=String(o);return i.length>=6?`${i} ${r}`:`${i.padStart(6," ")} ${r}`}).join(`
995
- `):""}function y_r(t){try{let e=_Yo(t),r=e.readSync();return e.closeSync(),r===null}catch(e){return Te(`Error checking directory: ${e}`),!1}}tt();function NO(){let t=Xn();t.hasCompletedProjectOnboarding||ys({...t,hasCompletedProjectOnboarding:!0})}function wYo(){let t=Er();Go({...t,lastReleaseNotesSeen:MACRO.VERSION})}function IZe({workspaceDir:t}){let r=!Xn().hasCompletedProjectOnboarding,o=Er().lastReleaseNotesSeen,i=[];(!o||(0,S_r.gt)(MACRO.VERSION,o))&&(i=fAe[MACRO.VERSION]||[]);let s=i.length>0;if(Ls.useEffect(()=>{s&&!r&&wYo()},[s,r]),!r&&!s)return null;let a=vYo(CYo(t,is)),c=y_r(t),u=!a&&!c,l=X$.isEnabled&&!Er().shiftEnterKeyBindingInstalled,d=se();return Ls.createElement(M,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&Ls.createElement(Ls.Fragment,null,Ls.createElement(x,{color:d.secondaryText},"Tips for getting started:"),Ls.createElement(Bf,{children:[]},(()=>{let p=[];return c&&p.push(Ls.createElement(Bf.Item,{key:"workspace"},Ls.createElement(x,{color:d.secondaryText},"Ask ",nt," to create a new app or clone a repository."))),u&&p.push(Ls.createElement(Bf.Item,{key:"claudemd"},Ls.createElement(x,{color:d.secondaryText},"Run ",Ls.createElement(x,{color:d.text},"/init")," to create a",is," file with instructions for Hawa code."))),l&&p.push(Ls.createElement(Bf.Item,{key:"terminal"},Ls.createElement(x,{color:d.secondaryText},"Run ",Ls.createElement(x,{color:d.text},"/terminal-setup"),Ls.createElement(x,{bold:!1}," to set up terminal integration")))),p.push(Ls.createElement(Bf.Item,{key:"questions"},Ls.createElement(x,{color:d.secondaryText},"Ask ",nt," questions about your codebase."))),p.push(Ls.createElement(Bf.Item,{key:"changes"},Ls.createElement(x,{color:d.secondaryText},"Ask ",nt," to implement changes to your codebase."))),p})())),!r&&s&&Ls.createElement(M,{borderColor:se().secondaryBorder,flexDirection:"column",marginRight:1},Ls.createElement(M,{flexDirection:"column",gap:0},Ls.createElement(M,{marginBottom:1},Ls.createElement(x,null,"\u{1F195} What's new in v",MACRO.VERSION,":")),Ls.createElement(M,{flexDirection:"column",marginLeft:1},i.map((p,f)=>Ls.createElement(x,{key:f,color:se().secondaryText},"\u2022 ",p))))),t===xYo()&&Ls.createElement(x,{color:se().warning},"Note: You have launched ",Ls.createElement(x,{bold:!0},nt)," in your home directory. For the best experience, launch it in a project directory instead."))}await He();var iH=j(fe(),1);await He();var oH=j(fe(),1);await He();var ete=j(fe(),1);function DZe({isFocused:t,isSelected:e,smallPointer:r,children:n}){let{styles:o}=Js("Select");return ete.default.createElement(M,{...o.option({isFocused:t})},t&&ete.default.createElement(x,{...o.focusIndicator()},r?dn.triangleDownSmall:dn.pointer),ete.default.createElement(x,{...o.label({isFocused:t,isSelected:e})},n),e&&ete.default.createElement(x,{...o.selectedIndicator()},dn.tick))}var y_=j(fe(),1);import{isDeepStrictEqual as IYo}from"node:util";var tte=class extends Map{first;constructor(e){let r=[],n,o,i=0;for(let s of e){let a={...s,previous:o,next:void 0,index:i};o&&(o.next=a),n||=a;let c="value"in s?s.value:RZe(s);r.push([c,a]),i++,o=a}super(r),this.first=n}};var DYo=(t,e)=>{switch(e.type){case"focus-next-option":{if(!t.focusedValue)return t;let r=t.optionMap.get(t.focusedValue);if(!r)return t;let n=r.next;for(;n&&!("value"in n);)n=n.next;if(!n)return t;if(!(n.index>=t.visibleToIndex))return{...t,focusedValue:n.value};let i=Math.min(t.optionMap.size,t.visibleToIndex+1),s=i-t.visibleOptionCount;return{...t,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:i}}case"focus-previous-option":{if(!t.focusedValue)return t;let r=t.optionMap.get(t.focusedValue);if(!r)return t;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return t;if(!(n.index<=t.visibleFromIndex))return{...t,focusedValue:n.value};let i=Math.max(0,t.visibleFromIndex-1),s=i+t.visibleOptionCount;return{...t,focusedValue:n.value,visibleFromIndex:i,visibleToIndex:s}}case"select-focused-option":return{...t,previousValue:t.value,value:t.focusedValue};case"reset":return e.state;case"set-focus":return{...t,focusedValue:e.value}}},OZe=t=>t.flatMap(e=>{if("options"in e){let r=OZe(e.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...e.header!==void 0?[{header:e.header,optionValues:n}]:[],...r]}return e}),b_r=({visibleOptionCount:t,defaultValue:e,options:r})=>{let n=OZe(r),o=typeof t=="number"?Math.min(t,n.length):n.length,i=new tte(n),s=i.first,a=s&&"value"in s?s.value:void 0;return{optionMap:i,visibleOptionCount:o,focusedValue:a,visibleFromIndex:0,visibleToIndex:o,previousValue:e,value:e}},NZe=({visibleOptionCount:t=5,options:e,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=OZe(e),[a,c]=(0,y_.useReducer)(DYo,{visibleOptionCount:t,defaultValue:r,options:e},b_r),[u,l]=(0,y_.useState)(s);s!==u&&!IYo(s,u)&&(c({type:"reset",state:b_r({visibleOptionCount:t,defaultValue:r,options:e})}),l(s));let d=(0,y_.useCallback)(()=>{c({type:"focus-next-option"})},[]),p=(0,y_.useCallback)(()=>{c({type:"focus-previous-option"})},[]),f=(0,y_.useCallback)(()=>{c({type:"select-focused-option"})},[]),_=(0,y_.useMemo)(()=>s.map((E,A)=>({...E,index:A})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,y_.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,e,n]),(0,y_.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,y_.useEffect)(()=>{i&&c({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:_,focusNextOption:d,focusPreviousOption:p,selectFocusedOption:f}};await He();var PZe=({isDisabled:t=!1,state:e})=>{jt((r,n)=>{n.downArrow&&e.focusNextOption(),n.upArrow&&e.focusPreviousOption(),n.return&&e.selectFocusedOption()},{isActive:!t})};var RZe=t=>`HEADER-${t.optionValues.join(",")}`;function j2({isDisabled:t=!1,visibleOptionCount:e=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let c=NZe({visibleOptionCount:e,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});PZe({isDisabled:t,state:c});let{styles:u}=Js("Select");return oH.default.createElement(M,{...u.container()},c.visibleOptions.map(l=>{let d="value"in l?l.value:RZe(l),p=!t&&c.focusedValue!==void 0&&("value"in l?c.focusedValue===l.value:l.optionValues.includes(c.focusedValue)),f=!!c.value&&("value"in l?c.value===l.value:l.optionValues.includes(c.value)),_="header"in l,E="label"in l?l.label:l.header,A=E;if(r&&E.includes(r)){let b=E.indexOf(r);A=oH.default.createElement(oH.default.Fragment,null,E.slice(0,b),oH.default.createElement(x,{...u.highlightedText()},r),E.slice(b+r.length))}return oH.default.createElement(DZe,{key:d,isFocused:p,isSelected:f,smallPointer:_},A)}))}Lt();function T_r({onDone:t}){return jt((e,r)=>{(r.ctrl&&(e==="c"||e==="d")||r.escape)&&t()}),iH.default.createElement(M,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:se().secondaryBorder},iH.default.createElement(M,{marginBottom:1,flexDirection:"column"},iH.default.createElement(x,{bold:!0},"You've spent $5 this session.")),iH.default.createElement(M,null,iH.default.createElement(j2,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:t})))}var Fo=j(fe(),1),Mr=j(fe(),1);await He();var ta=j(fe(),1);Lt();tt();Zo();vn();ea();var OYo="1.27.1",g3={VERSION:OYo,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var MZe=46,x_r=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function bTe({isDefaultModel:t=!1}){let e=Math.max(MZe,Ge().length+12),r=se(),n=x_r[Math.floor(Math.random()*x_r.length)],o=process.env.ANTHROPIC_MODEL,i=DE(),s=!W0e(),a=!t&&!!o,c=process.env.USER_TYPE==="ant"&&!!(s||process.env.DISABLE_PROMPT_CACHING||process.env.API_TIMEOUT_MS||process.env.MAX_THINKING_TOKENS||process.env.ANTHROPIC_BASE_URL||a);return ta.createElement(M,{flexDirection:"column"},ta.createElement(M,{flexDirection:"column",gap:1,paddingLeft:1,width:e},ta.createElement(x,null,ta.createElement(x,null,n)," Welcome to"," ",ta.createElement(x,{bold:!0},nt),ta.createElement(x,{color:r.secondaryText}," v",g3.VERSION)),ta.createElement(ta.Fragment,null,ta.createElement(M,{paddingLeft:2,flexDirection:"column",gap:1},ta.createElement(x,{color:r.secondaryText,italic:!0},"/help for help"),ta.createElement(x,{color:r.secondaryText},"cwd: ",Ge()),ta.createElement(x,{color:r.secondaryText},"model: ",tc())),c&&ta.createElement(M,{borderColor:r.secondaryBorder,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0,flexDirection:"column",marginLeft:2,marginRight:1,paddingTop:1},ta.createElement(M,{marginBottom:1},ta.createElement(x,{color:r.secondaryText},"Overrides (via env):")),a&&ta.createElement(x,{color:r.secondaryText},"\u2022 Model: ",ta.createElement(x,{bold:!0},o)),s&&i?ta.createElement(x,{color:r.secondaryText},"\u2022 API Key:"," ",ta.createElement(x,{bold:!0},"sk-ant-\u2026",i.slice(-e+25))):null,process.env.DISABLE_PROMPT_CACHING?ta.createElement(x,{color:r.secondaryText},"\u2022 Prompt caching:"," ",ta.createElement(x,{color:r.error,bold:!0},"off")):null,process.env.API_TIMEOUT_MS?ta.createElement(x,{color:r.secondaryText},"\u2022 API timeout:"," ",ta.createElement(x,{bold:!0},process.env.API_TIMEOUT_MS,"ms")):null,process.env.MAX_THINKING_TOKENS?ta.createElement(x,{color:r.secondaryText},"\u2022 Max thinking tokens:"," ",ta.createElement(x,{bold:!0},process.env.MAX_THINKING_TOKENS)):null,process.env.ANTHROPIC_BASE_URL?ta.createElement(x,{color:r.secondaryText},"\u2022 API Base URL:"," ",ta.createElement(x,{bold:!0},process.env.ANTHROPIC_BASE_URL)):null))))}await He();var sT=j(fe(),1);et();var nle=j(fe(),1);await He();import{randomUUID as HL}from"crypto";await He();var so=j(fe(),1),fy=j(fe(),1);Lt();var w_r=()=>[],I_r=()=>{};function D_r(t){w_r=t}function sH(){return w_r}function R_r(t){I_r=t}function O_r(){return I_r}var UZe=j(fe(),1);await He();Jc();var L_r=j(fe(),1);var kZe=j(fe(),1),N_r=2e3;function _3(t,e,r){let n=(0,kZe.useRef)(0),o=(0,kZe.useRef)();return()=>{let i=Date.now();i-n.current<=N_r&&o.current?(o.current&&(clearTimeout(o.current),o.current=void 0),e(),t(!1)):(r?.(),t(!0),o.current=setTimeout(()=>t(!1),N_r)),n.current=i}}sEe();var ote=class t{constructor(e,r=0,n=0){this.measuredText=e;this.selection=n;this.offset=Math.max(0,Math.min(this.measuredText.text.length,r))}offset;static fromText(e,r,n=0,o=0){return new t(new LZe(e,r-1),n,o)}render(e,r,n){let{line:o,column:i}=this.getPosition();return this.measuredText.getWrappedText().map((s,a,c)=>{let u=s;if(r&&a===c.length-1){let l=Math.max(0,s.length-6);u=r.repeat(l)+s.slice(l)}return o!=a?u.trimEnd():u.slice(0,i)+n(u[i]||e)+u.trimEnd().slice(i+1)}).join(`
995
+ `):""}function y_r(t){try{let e=_Yo(t),r=e.readSync();return e.closeSync(),r===null}catch(e){return Te(`Error checking directory: ${e}`),!1}}tt();function NO(){let t=Xn();t.hasCompletedProjectOnboarding||ys({...t,hasCompletedProjectOnboarding:!0})}function wYo(){let t=Er();Go({...t,lastReleaseNotesSeen:MACRO.VERSION})}function IZe({workspaceDir:t}){let r=!Xn().hasCompletedProjectOnboarding,o=Er().lastReleaseNotesSeen,i=[];(!o||(0,S_r.gt)(MACRO.VERSION,o))&&(i=fAe[MACRO.VERSION]||[]);let s=i.length>0;if(Ls.useEffect(()=>{s&&!r&&wYo()},[s,r]),!r&&!s)return null;let a=vYo(CYo(t,is)),c=y_r(t),u=!a&&!c,l=X$.isEnabled&&!Er().shiftEnterKeyBindingInstalled,d=se();return Ls.createElement(M,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&Ls.createElement(Ls.Fragment,null,Ls.createElement(x,{color:d.secondaryText},"Tips for getting started:"),Ls.createElement(Bf,{children:[]},(()=>{let p=[];return c&&p.push(Ls.createElement(Bf.Item,{key:"workspace"},Ls.createElement(x,{color:d.secondaryText},"Ask ",nt," to create a new app or clone a repository."))),u&&p.push(Ls.createElement(Bf.Item,{key:"claudemd"},Ls.createElement(x,{color:d.secondaryText},"Run ",Ls.createElement(x,{color:d.text},"/init")," to create a",is," file with instructions for Hawa code."))),l&&p.push(Ls.createElement(Bf.Item,{key:"terminal"},Ls.createElement(x,{color:d.secondaryText},"Run ",Ls.createElement(x,{color:d.text},"/terminal-setup"),Ls.createElement(x,{bold:!1}," to set up terminal integration")))),p.push(Ls.createElement(Bf.Item,{key:"questions"},Ls.createElement(x,{color:d.secondaryText},"Ask ",nt," questions about your codebase."))),p.push(Ls.createElement(Bf.Item,{key:"changes"},Ls.createElement(x,{color:d.secondaryText},"Ask ",nt," to implement changes to your codebase."))),p})())),!r&&s&&Ls.createElement(M,{borderColor:se().secondaryBorder,flexDirection:"column",marginRight:1},Ls.createElement(M,{flexDirection:"column",gap:0},Ls.createElement(M,{marginBottom:1},Ls.createElement(x,null,"\u{1F195} What's new in v",MACRO.VERSION,":")),Ls.createElement(M,{flexDirection:"column",marginLeft:1},i.map((p,f)=>Ls.createElement(x,{key:f,color:se().secondaryText},"\u2022 ",p))))),t===xYo()&&Ls.createElement(x,{color:se().warning},"Note: You have launched ",Ls.createElement(x,{bold:!0},nt)," in your home directory. For the best experience, launch it in a project directory instead."))}await He();var iH=j(fe(),1);await He();var oH=j(fe(),1);await He();var ete=j(fe(),1);function DZe({isFocused:t,isSelected:e,smallPointer:r,children:n}){let{styles:o}=Js("Select");return ete.default.createElement(M,{...o.option({isFocused:t})},t&&ete.default.createElement(x,{...o.focusIndicator()},r?dn.triangleDownSmall:dn.pointer),ete.default.createElement(x,{...o.label({isFocused:t,isSelected:e})},n),e&&ete.default.createElement(x,{...o.selectedIndicator()},dn.tick))}var y_=j(fe(),1);import{isDeepStrictEqual as IYo}from"node:util";var tte=class extends Map{first;constructor(e){let r=[],n,o,i=0;for(let s of e){let a={...s,previous:o,next:void 0,index:i};o&&(o.next=a),n||=a;let c="value"in s?s.value:RZe(s);r.push([c,a]),i++,o=a}super(r),this.first=n}};var DYo=(t,e)=>{switch(e.type){case"focus-next-option":{if(!t.focusedValue)return t;let r=t.optionMap.get(t.focusedValue);if(!r)return t;let n=r.next;for(;n&&!("value"in n);)n=n.next;if(!n)return t;if(!(n.index>=t.visibleToIndex))return{...t,focusedValue:n.value};let i=Math.min(t.optionMap.size,t.visibleToIndex+1),s=i-t.visibleOptionCount;return{...t,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:i}}case"focus-previous-option":{if(!t.focusedValue)return t;let r=t.optionMap.get(t.focusedValue);if(!r)return t;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return t;if(!(n.index<=t.visibleFromIndex))return{...t,focusedValue:n.value};let i=Math.max(0,t.visibleFromIndex-1),s=i+t.visibleOptionCount;return{...t,focusedValue:n.value,visibleFromIndex:i,visibleToIndex:s}}case"select-focused-option":return{...t,previousValue:t.value,value:t.focusedValue};case"reset":return e.state;case"set-focus":return{...t,focusedValue:e.value}}},OZe=t=>t.flatMap(e=>{if("options"in e){let r=OZe(e.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...e.header!==void 0?[{header:e.header,optionValues:n}]:[],...r]}return e}),b_r=({visibleOptionCount:t,defaultValue:e,options:r})=>{let n=OZe(r),o=typeof t=="number"?Math.min(t,n.length):n.length,i=new tte(n),s=i.first,a=s&&"value"in s?s.value:void 0;return{optionMap:i,visibleOptionCount:o,focusedValue:a,visibleFromIndex:0,visibleToIndex:o,previousValue:e,value:e}},NZe=({visibleOptionCount:t=5,options:e,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=OZe(e),[a,c]=(0,y_.useReducer)(DYo,{visibleOptionCount:t,defaultValue:r,options:e},b_r),[u,l]=(0,y_.useState)(s);s!==u&&!IYo(s,u)&&(c({type:"reset",state:b_r({visibleOptionCount:t,defaultValue:r,options:e})}),l(s));let d=(0,y_.useCallback)(()=>{c({type:"focus-next-option"})},[]),p=(0,y_.useCallback)(()=>{c({type:"focus-previous-option"})},[]),f=(0,y_.useCallback)(()=>{c({type:"select-focused-option"})},[]),_=(0,y_.useMemo)(()=>s.map((E,A)=>({...E,index:A})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,y_.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,e,n]),(0,y_.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,y_.useEffect)(()=>{i&&c({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:_,focusNextOption:d,focusPreviousOption:p,selectFocusedOption:f}};await He();var PZe=({isDisabled:t=!1,state:e})=>{jt((r,n)=>{n.downArrow&&e.focusNextOption(),n.upArrow&&e.focusPreviousOption(),n.return&&e.selectFocusedOption()},{isActive:!t})};var RZe=t=>`HEADER-${t.optionValues.join(",")}`;function j2({isDisabled:t=!1,visibleOptionCount:e=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let c=NZe({visibleOptionCount:e,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});PZe({isDisabled:t,state:c});let{styles:u}=Js("Select");return oH.default.createElement(M,{...u.container()},c.visibleOptions.map(l=>{let d="value"in l?l.value:RZe(l),p=!t&&c.focusedValue!==void 0&&("value"in l?c.focusedValue===l.value:l.optionValues.includes(c.focusedValue)),f=!!c.value&&("value"in l?c.value===l.value:l.optionValues.includes(c.value)),_="header"in l,E="label"in l?l.label:l.header,A=E;if(r&&E.includes(r)){let b=E.indexOf(r);A=oH.default.createElement(oH.default.Fragment,null,E.slice(0,b),oH.default.createElement(x,{...u.highlightedText()},r),E.slice(b+r.length))}return oH.default.createElement(DZe,{key:d,isFocused:p,isSelected:f,smallPointer:_},A)}))}Lt();function T_r({onDone:t}){return jt((e,r)=>{(r.ctrl&&(e==="c"||e==="d")||r.escape)&&t()}),iH.default.createElement(M,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:se().secondaryBorder},iH.default.createElement(M,{marginBottom:1,flexDirection:"column"},iH.default.createElement(x,{bold:!0},"You've spent $5 this session.")),iH.default.createElement(M,null,iH.default.createElement(j2,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:t})))}var Fo=j(fe(),1),Mr=j(fe(),1);await He();var ta=j(fe(),1);Lt();tt();Zo();vn();ea();var OYo="1.27.2",g3={VERSION:OYo,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var MZe=46,x_r=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function bTe({isDefaultModel:t=!1}){let e=Math.max(MZe,Ge().length+12),r=se(),n=x_r[Math.floor(Math.random()*x_r.length)],o=process.env.ANTHROPIC_MODEL,i=DE(),s=!W0e(),a=!t&&!!o,c=process.env.USER_TYPE==="ant"&&!!(s||process.env.DISABLE_PROMPT_CACHING||process.env.API_TIMEOUT_MS||process.env.MAX_THINKING_TOKENS||process.env.ANTHROPIC_BASE_URL||a);return ta.createElement(M,{flexDirection:"column"},ta.createElement(M,{flexDirection:"column",gap:1,paddingLeft:1,width:e},ta.createElement(x,null,ta.createElement(x,null,n)," Welcome to"," ",ta.createElement(x,{bold:!0},nt),ta.createElement(x,{color:r.secondaryText}," v",g3.VERSION)),ta.createElement(ta.Fragment,null,ta.createElement(M,{paddingLeft:2,flexDirection:"column",gap:1},ta.createElement(x,{color:r.secondaryText,italic:!0},"/help for help"),ta.createElement(x,{color:r.secondaryText},"cwd: ",Ge()),ta.createElement(x,{color:r.secondaryText},"model: ",tc())),c&&ta.createElement(M,{borderColor:r.secondaryBorder,borderStyle:"single",borderBottom:!1,borderLeft:!1,borderRight:!1,borderTop:!0,flexDirection:"column",marginLeft:2,marginRight:1,paddingTop:1},ta.createElement(M,{marginBottom:1},ta.createElement(x,{color:r.secondaryText},"Overrides (via env):")),a&&ta.createElement(x,{color:r.secondaryText},"\u2022 Model: ",ta.createElement(x,{bold:!0},o)),s&&i?ta.createElement(x,{color:r.secondaryText},"\u2022 API Key:"," ",ta.createElement(x,{bold:!0},"sk-ant-\u2026",i.slice(-e+25))):null,process.env.DISABLE_PROMPT_CACHING?ta.createElement(x,{color:r.secondaryText},"\u2022 Prompt caching:"," ",ta.createElement(x,{color:r.error,bold:!0},"off")):null,process.env.API_TIMEOUT_MS?ta.createElement(x,{color:r.secondaryText},"\u2022 API timeout:"," ",ta.createElement(x,{bold:!0},process.env.API_TIMEOUT_MS,"ms")):null,process.env.MAX_THINKING_TOKENS?ta.createElement(x,{color:r.secondaryText},"\u2022 Max thinking tokens:"," ",ta.createElement(x,{bold:!0},process.env.MAX_THINKING_TOKENS)):null,process.env.ANTHROPIC_BASE_URL?ta.createElement(x,{color:r.secondaryText},"\u2022 API Base URL:"," ",ta.createElement(x,{bold:!0},process.env.ANTHROPIC_BASE_URL)):null))))}await He();var sT=j(fe(),1);et();var nle=j(fe(),1);await He();import{randomUUID as HL}from"crypto";await He();var so=j(fe(),1),fy=j(fe(),1);Lt();var w_r=()=>[],I_r=()=>{};function D_r(t){w_r=t}function sH(){return w_r}function R_r(t){I_r=t}function O_r(){return I_r}var UZe=j(fe(),1);await He();Jc();var L_r=j(fe(),1);var kZe=j(fe(),1),N_r=2e3;function _3(t,e,r){let n=(0,kZe.useRef)(0),o=(0,kZe.useRef)();return()=>{let i=Date.now();i-n.current<=N_r&&o.current?(o.current&&(clearTimeout(o.current),o.current=void 0),e(),t(!1)):(r?.(),t(!0),o.current=setTimeout(()=>t(!1),N_r)),n.current=i}}sEe();var ote=class t{constructor(e,r=0,n=0){this.measuredText=e;this.selection=n;this.offset=Math.max(0,Math.min(this.measuredText.text.length,r))}offset;static fromText(e,r,n=0,o=0){return new t(new LZe(e,r-1),n,o)}render(e,r,n){let{line:o,column:i}=this.getPosition();return this.measuredText.getWrappedText().map((s,a,c)=>{let u=s;if(r&&a===c.length-1){let l=Math.max(0,s.length-6);u=r.repeat(l)+s.slice(l)}return o!=a?u.trimEnd():u.slice(0,i)+n(u[i]||e)+u.trimEnd().slice(i+1)}).join(`
996
996
  `)}left(){return new t(this.measuredText,this.offset-1)}right(){return new t(this.measuredText,this.offset+1)}up(){let{line:e,column:r}=this.getPosition();if(e==0)return new t(this.measuredText,0,0);let n=this.getOffset({line:e-1,column:r});return new t(this.measuredText,n,0)}down(){let{line:e,column:r}=this.getPosition();if(e>=this.measuredText.lineCount-1)return new t(this.measuredText,this.text.length,0);let n=this.getOffset({line:e+1,column:r});return new t(this.measuredText,n,0)}startOfLine(){let{line:e}=this.getPosition();return new t(this.measuredText,this.getOffset({line:e,column:0}),0)}endOfLine(){let{line:e}=this.getPosition(),r=this.measuredText.getLineLength(e),n=this.getOffset({line:e,column:r});return new t(this.measuredText,n,0)}nextWord(){let e=this;for(;e.isOverWordChar()&&!e.isAtEnd();)e=e.right();for(;!e.isOverWordChar()&&!e.isAtEnd();)e=e.right();return e}prevWord(){let e=this;for(e.left().isOverWordChar()||(e=e.left());!e.isOverWordChar()&&!e.isAtStart();)e=e.left();if(e.isOverWordChar())for(;e.left().isOverWordChar()&&!e.isAtStart();)e=e.left();return e}modifyText(e,r=""){let n=this.offset,o=e.offset,i=this.text.slice(0,n)+r+this.text.slice(o);return t.fromText(i,this.columns,n+r.length)}insert(e){return this.modifyText(this,e)}del(){return this.isAtEnd()?this:this.modifyText(this.right())}backspace(){return this.isAtStart()?this:this.left().modifyText(this)}deleteToLineStart(){return this.startOfLine().modifyText(this)}deleteToLineEnd(){return this.text[this.offset]===`
997
997
  `?this.modifyText(this.right()):this.modifyText(this.endOfLine())}deleteWordBefore(){return this.isAtStart()?this:this.prevWord().modifyText(this)}deleteWordAfter(){return this.isAtEnd()?this:this.modifyText(this.nextWord())}isOverWordChar(){let e=this.text[this.offset]??"";return/\w/.test(e)}equals(e){return this.offset===e.offset&&this.measuredText==e.measuredText}isAtStart(){return this.offset==0}isAtEnd(){return this.offset==this.text.length}get text(){return this.measuredText.text}get columns(){return this.measuredText.columns+1}getPosition(){return this.measuredText.getPositionFromOffset(this.offset)}getOffset(e){return this.measuredText.getOffsetFromPosition(e)}},nte=class{constructor(e,r,n,o=!1){this.text=e;this.startOffset=r;this.isPrecededByNewline=n;this.endsWithNewline=o}equals(e){return this.text===e.text&&this.startOffset===e.startOffset}get length(){return this.text.length+(this.endsWithNewline?1:0)}},LZe=class{constructor(e,r){this.text=e;this.columns=r;this.wrappedLines=this.measureWrappedText()}wrappedLines;measureWrappedText(){let e=U6(this.text,this.columns,{hard:!0,trim:!1}),r=[],n=0,o=-1,i=e.split(`
998
998
  `);for(let s=0;s<i.length;s++){let a=i[s],c=u=>s==0||u>0&&this.text[u-1]===`
@@ -1504,7 +1504,7 @@ Usage:
1504
1504
  - This tool can only read files, not directories. To read a directory, use an ls command via the Bash tool.
1505
1505
  - You can call multiple tools in a single response. It is always better to speculatively read multiple potentially useful files in parallel.
1506
1506
  - You will regularly be asked to read screenshots. If the user provides a path to a screenshot, ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths.
1507
- - If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`;tt();await zb();var C2t=3,R2t=.25*1024*1024,x2t=new Set([".png",".jpg",".jpeg",".gif",".bmp",".webp"]),R5e=2e3,O5e=2e3,w2t=3.75*1024*1024,kls=Ze(()=>le.strictObject({file_path:le.string().describe("The absolute path to the file to read"),offset:le.number().optional().describe("The line number to start reading from. Only provide if the file is too large to read at once"),limit:le.number().optional().describe("The number of lines to read. Only provide if the file is too large to read at once.")})),by={name:CFn,async description(){return xFn},async prompt(){return wFn},get inputSchema(){return kls()},isReadOnly(){return!0},userFacingName(){return Aa},async isEnabled(){return!0},needsPermissions({file_path:t}){return!BM(t||Ge())},renderToolUseMessage(t,{verbose:e}){let{file_path:r,...n}=t;return r?[["file_path",e?r:Mls(Ge(),r)],...Object.entries(n)].map(([i,s])=>`${i}: ${JSON.stringify(s)}`).join(", "):"file_path is null"},renderToolResultMessage(t,{verbose:e}){switch(t.type){case"image":return Dg.createElement(M,{justifyContent:"space-between",overflowX:"hidden",width:"100%"},Dg.createElement(M,{flexDirection:"row"},Dg.createElement(x,null,"\xA0\xA0\u23BF \xA0"),Dg.createElement(x,null,"Read image")));case"text":{let{filePath:r,content:n,numLines:o}=t.file,i=n||"(No content)";return Dg.createElement(M,{justifyContent:"space-between",overflowX:"hidden",width:"100%"},Dg.createElement(M,{flexDirection:"row"},Dg.createElement(x,null,"\xA0\xA0\u23BF \xA0"),Dg.createElement(M,{flexDirection:"column"},Dg.createElement(LM,{code:e?i:i.split(`
1507
+ - If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`;tt();await zb();var C2t=3,R2t=.25*1024*1024,x2t=new Set([".png",".jpg",".jpeg",".gif",".bmp",".webp"]),R5e=2e3,O5e=2e3,w2t=3.75*1024*1024,kls=Ze(()=>le.strictObject({file_path:le.string().describe("The absolute path to the file to read"),offset:le.number().optional().describe("The line number to start reading from. Defaults to reading from the first line. Only provide if the file is too large to read at once."),limit:le.number().optional().describe("The number of lines to read. Defaults to reading until the last line of the file. Only provide if the file is too large to read at once.")})),by={name:CFn,async description(){return xFn},async prompt(){return wFn},get inputSchema(){return kls()},isReadOnly(){return!0},userFacingName(){return Aa},async isEnabled(){return!0},needsPermissions({file_path:t}){return!BM(t||Ge())},renderToolUseMessage(t,{verbose:e}){let{file_path:r,offset:n,limit:o}=t;if(!r)return"file_path is null";let i=e?r:Mls(Ge(),r),s="";return n!==void 0&&o!==void 0?s=` \xB7 lines ${n}-${n+o-1}`:n!==void 0?s=` \xB7 from line ${n}`:o!==void 0&&(s=` \xB7 lines 1-${o}`),`${i}${s}`},renderToolResultMessage(t,{verbose:e}){switch(t.type){case"image":return Dg.createElement(M,{justifyContent:"space-between",overflowX:"hidden",width:"100%"},Dg.createElement(M,{flexDirection:"row"},Dg.createElement(x,null,"\xA0\xA0\u23BF \xA0"),Dg.createElement(x,null,"Read image")));case"text":{let{filePath:r,content:n,numLines:o}=t.file,i=n||"(No content)";return Dg.createElement(M,{justifyContent:"space-between",overflowX:"hidden",width:"100%"},Dg.createElement(M,{flexDirection:"row"},Dg.createElement(x,null,"\xA0\xA0\u23BF \xA0"),Dg.createElement(M,{flexDirection:"column"},Dg.createElement(LM,{code:e?i:i.split(`
1508
1508
  `).slice(0,C2t).filter(s=>s.trim()!=="").join(`
1509
1509
  `),language:Pls(r).slice(1)}),!e&&o>C2t&&Dg.createElement(x,{color:se().secondaryText},"... (+",o-C2t," lines)"))))}case"notebook":{if(t.error)return Dg.createElement(x,{color:"red"}," ","\u23BF"," ",t.message);let{cells:r}=t.file;return!r||r.length===0?Dg.createElement(x,null," ","\u23BF"," ","No cells found in notebook"):Dg.createElement(x,null," ","\u23BF"," ","Read ",r.length," cells")}}},renderToolUseRejectedMessage(){return Dg.createElement(Mo,null)},async validateInput({file_path:t,offset:e,limit:r}){if(!t)return{result:!1,message:" file_path is null"};let n=xZe(t);if(!Nls(n)){let a=STe(n),c="File does not exist.";return a&&(c+=` Did you mean ${a}?`),{result:!1,message:c}}let i=DFn(n).size,s=D2t.extname(n).toLowerCase();return!x2t.has(s)&&s!==".ipynb"&&i>R2t&&!e&&!r?{result:!1,message:IFn(i),meta:{fileSize:i}}:{result:!0}},async*call({file_path:t,offset:e=1,limit:r=void 0},{readFileTimestamps:n}){let o=D2t.extname(t).toLowerCase(),i=xZe(t);if(n[i]=Date.now(),lm("file:read",{filePath:i,extension:o,timestamp:Date.now()}),x2t.has(o)){let d=await Lls(i,o);yield{type:"result",data:d,resultForAssistant:this.renderResultForAssistant(d)};return}if(o===".ipynb"){try{let d=Cue(i,"utf-8"),p=JSON.parse(d),f=p.metadata.language_info?.name??"python",E={type:"notebook",file:{cells:p.cells.map((A,b)=>Uls(A,b,f))}};yield{type:"result",data:E,resultForAssistant:this.renderResultForAssistant(E)}}catch(d){let p=Cue(i,"utf-8"),f={type:"notebook",content:p,error:!0,message:d.message};yield{type:"result",data:f,resultForAssistant:[`The ipynb file content format is incorrect , ${f.message} ,The text content of the file is as follows: `,p]}}return}let s=e===0?0:e-1,{content:a,lineCount:c,totalLines:u}=yTe(i,s,r);if(!x2t.has(o)&&o!==".ipynb"&&a.length>R2t)throw new Error(IFn(a.length));let l={type:"text",file:{filePath:t,content:a,numLines:c,startLine:e,totalLines:u}};yield{type:"result",data:l,resultForAssistant:this.renderResultForAssistant(l)}},renderResultForAssistant(t){switch(t.type){case"image":return[{type:"image",source:{type:"base64",data:t.file.base64,media_type:t.file.type}}];case"text":return sN(t.file);case"notebook":return $ls(t.file.cells)}}},IFn=t=>`File content (${Math.round(t/1024)}KB) exceeds maximum allowed size (${Math.round(R2t/1024)}KB). Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.`;function vue(t,e){return{type:"image",file:{base64:t.toString("base64"),type:`image/${e.slice(1)}`}}}async function Lls(t,e){try{let r=DFn(t),n=(await import("sharp")).default,o=n(Cue(t)),i=await o.metadata();if((!i.width||!i.height)&&r.size>w2t){let u=await o.jpeg({quality:80}).toBuffer();return vue(u,"jpeg")}let s=i.width||0,a=i.height||0;if(r.size<=w2t&&s<=R5e&&a<=O5e)return vue(Cue(t),e);s>R5e&&(a=Math.round(a*R5e/s),s=R5e),a>O5e&&(s=Math.round(s*O5e/a),a=O5e);let c=await o.resize(s,a,{fit:"inside",withoutEnlargement:!0}).toBuffer();if(c.length>w2t){let u=await o.jpeg({quality:80}).toBuffer();return vue(u,"jpeg")}return vue(c,e)}catch(r){return Te(r),vue(Cue(t),e)}}function I2t(t){if(!t)return"";let e=Array.isArray(t)?t.join(""):t,{truncatedContent:r}=Qce(e);return r}function Bls(t){if(typeof t["image/png"]=="string")return{image_data:t["image/png"],media_type:"image/png"};if(typeof t["image/jpeg"]=="string")return{image_data:t["image/jpeg"],media_type:"image/jpeg"}}function Fls(t){switch(t.output_type){case"stream":return{output_type:t.output_type,text:I2t(t.text)};case"execute_result":case"display_data":return{output_type:t.output_type,text:I2t(t.data?.["text/plain"]),image:t.data&&Bls(t.data)};case"error":return{output_type:t.output_type,text:I2t(`${t.ename}: ${t.evalue}
1510
1510
  ${t.traceback?.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dahawa/hawa-code",
3
- "version": "1.27.1",
3
+ "version": "1.27.2",
4
4
  "bin": {
5
5
  "hcode": "hawa.js"
6
6
  },