@dahawa/hawa-code 2.4.31 → 2.4.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +38 -38
- package/hands.js +4 -4
- package/package.json +1 -1
package/hands.js
CHANGED
|
@@ -758,7 +758,7 @@ data: ${JSON.stringify(G)}
|
|
|
758
758
|
`);a=Q.pop()||"";for(let G of Q){let j=G.trim();if(!(!j||j==="data: [DONE]"))if(j.startsWith("data: ")){let q=j.slice(6);try{let V=JSON.parse(q);w(V)}catch(V){this.logger&&this.logger.error({err:V,line:j},"Failed to parse Gemini SSE chunk")}}else try{let q=JSON.parse(j);w(q)}catch{}}};(async()=>{try{for(;;){let{value:Q,done:G}=await s.read();if(G)break;a+=n.decode(Q,{stream:!0}),O()}I()}catch(Q){o.error(Q)}})()}})}convertGeminiResponseToAnthropic(t){this.logger&&this.logger.debug({response:t},"Original Gemini response");try{if(!t.candidates||!t.candidates[0])throw new Error("No candidates found in Gemini response");let r=t.candidates[0],n=[];r.content&&r.content.parts&&r.content.parts.forEach(o=>{if(o.text&&n.push({type:"text",text:o.text}),o.functionCall){let s=`toolu_${WB()}`,a=o.functionCall.thoughtSignature||o.functionCall.thought_signature||null;n.push({type:"tool_use",id:s,name:o.functionCall.name,input:o.functionCall.args||{},thought_signature:a})}}),r.groundingMetadata&&(this.logger&&this.logger.debug({groundingMetadata:r.groundingMetadata},"Processing grounding metadata"),r.groundingMetadata.webSearchQueries&&n.push({type:"text",text:`
|
|
759
759
|
|
|
760
760
|
[Search queries used: ${r.groundingMetadata.webSearchQueries.join(", ")}]`}));let i={id:`msg_${Math.random().toString(36).slice(2)}`,type:"message",role:"assistant",model:t.modelVersion||"gemini",content:n,stop_reason:r.finishReason?r.finishReason==="STOP"&&n.some(o=>o.type==="tool_use")?"tool_use":this.mapGeminiFinishReason(r.finishReason):"end_turn",stop_sequence:null,usage:{input_tokens:t.usageMetadata?.promptTokenCount||0,output_tokens:t.usageMetadata?.candidatesTokenCount||0}};return this.logger&&this.logger.debug({result:i},"Conversion complete, final Anthropic response"),i}catch{throw pHr(`Provider error: ${JSON.stringify(t)}`,500,"provider_error")}}mapGeminiFinishReason(t){switch(t){case"STOP":return"end_turn";case"MAX_TOKENS":return"max_tokens";case"SAFETY":case"RECITATION":return"stop_sequence";default:return"end_turn"}}},hbe=new Abe;var vgt=X(Sgt(),1);ar();fs();function Gg(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function Igt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function xrn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function wrn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function Drn(e,t="chat"){let r={request:{},response:{},openai:{request:{},response:{}}};return r.request.model=e.request.body.model,r.request.messages=e.request.body.messages,r.request.system=e.request.body.system,r.response.content=e.response.body.content,r.response.usage=e.response.body?.usage,t==="responses"?(r.openai.request.model=e.openai.request.body.model,r.openai.request.input=e.openai.request.body.input,r.openai.response.output=e.openai.response.body?.output,r.openai.response.usage=e.openai.response.body?.usage):(r.openai.request.model=e.openai.request.body.model,r.openai.request.messages=e.openai.request.body.messages,r.openai.response.choices=e.openai.response.body.choices,r.openai.response.usage=e.openai.response.body?.usage),r}function j5(e,t,r){$z(t,e),qz(t,Drn(e,r),r)}function P2(e){let t=[],r=e.getReader(),n,i=new Promise(l=>n=l),o=!1,s=()=>{o||(o=!0,n(Buffer.concat(t).toString("utf8")))};return{stream:new ReadableStream({async pull(l){try{let{done:c,value:u}=await r.read();if(c){l.close(),s();return}t.push(u),l.enqueue(u)}catch(c){l.error(c),s()}},cancel(l){r.cancel(l).catch(()=>{}),s()}}),done:i}}function Y5(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function zIe(e,t,r,n,i){let o;try{o={type:"error",error:{type:"api_error",message:JSON.parse(i).error?.message??`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}catch{o={type:"error",error:{type:"api_error",message:`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}return new Response(JSON.stringify(o),{status:r,statusText:n,headers:{"Content-Type":"application/json"}})}var Tgt=["/v1/messages"];function jIe(e){let t;try{typeof e=="string"?t=new Qv(e):e instanceof Qv?t=e:t=new Qv(e.url)}catch{return""}let r=t.pathname;for(let n of Tgt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function XZ(e,t){let r=typeof e=="string"?e:e instanceof Qv?e.toString():e.url,n;try{n=new Qv(r).pathname}catch{return!1}return Tgt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function Rrn(e){return async(t,r)=>{if(!XZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await eJ.transformRequestOut(n),o=jIe(t)+"/chat/completions",s=Gg(r.headers),a=s.authorization??s.Authorization??"";xrn(i,Igt(s));let l=await e(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(i),signal:r.signal});if(!l.ok){let _=await l.text();return K(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:_}),zIe("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,_)}let c=n.stream===!0,u=s["x-agent-id"],f={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:Gg(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let _=await l.text(),y=new Response(_,{status:l.status,statusText:l.statusText,headers:Y5(l.headers)}),S=await eJ.transformResponseIn(y,n),I=await S.text();try{j5({...f,openai:{...f.openai,response:{body:JSON.parse(_)}},response:{...f.response,body:JSON.parse(I)}},u)}catch(w){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",w)}return new Response(I,{status:S.status,statusText:S.statusText,headers:S.headers})}let g=P2(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:Y5(l.headers)}),A=await eJ.transformResponseIn(m,n),h=P2(A.body);return Promise.all([g.done,h.done]).then(async([_,y])=>{try{j5({...f,openai:{...f.openai,response:{body:await Xot(_)}},response:{...f.response,body:await LU(y)}},u)}catch(S){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+S?.stack)}}).catch(_=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+_)),new Response(h.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function Nrn(e){return async(t,r)=>{if(!XZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await tJ.transformRequestOut(n),o=Gg(r.headers);wrn(i,Igt(o));let s=JSON.stringify(i),l=jIe(t)+"/responses",c=o.authorization??o.Authorization??"";if(!c)return new Response(JSON.stringify({type:"error",error:{type:"api_error",message:"Missing Authorization header",code:"RESPONSES_AUTH_MISSING"}}),{status:401,headers:{"Content-Type":"application/json"}});let u=await e(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c,"x-api-key":c.replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal});if(!u.ok){let S=await u.text();return K(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:S}),zIe("OpenAI Responses API error","RESPONSES",u.status,u.statusText,S)}let f=n.stream===!0,g=o["x-agent-id"],m={request:{url:l,method:r.method,headers:o,body:n},response:{status:u.status,statusText:u.statusText,headers:Gg(u.headers)},openai:{request:{body:i},response:{}}};if(!f){let S=await u.text(),I=new Response(S,{status:u.status,statusText:u.statusText,headers:Y5(u.headers)}),w=await tJ.transformResponseIn(I,n),O=await w.text();try{j5({...m,openai:{...m.openai,response:{body:JSON.parse(S)}},response:{...m.response,body:JSON.parse(O)}},g,"responses")}catch(Q){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",Q)}return new Response(O,{status:w.status,statusText:w.statusText,headers:w.headers})}let A=P2(u.body),h=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:Y5(u.headers)}),_=await tJ.transformResponseIn(h,n),y=P2(_.body);return Promise.all([A.done,y.done]).then(async([S,I])=>{try{j5({...m,openai:{...m.openai,response:{body:await Zot(S)}},response:{...m.response,body:await LU(I)}},g,"responses")}catch(w){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+w?.stack)}}).catch(S=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+S)),new Response(y.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function Brn(e){return async(t,r)=>{if(!XZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=Gg(r.headers),o=await hbe.transformRequestOut(n),s=JSON.stringify(o),a=jIe(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,l=i.authorization??i.Authorization??"",c;try{c=await e(a,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":String(l).replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal})}catch(y){throw K("gemini request error:",y),y}if(!c.ok){let y=await c.text();return K(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:y}),zIe("Gemini API error","Gemini",c.status,c.statusText,y)}let u=n.stream===!0,f=i["x-agent-id"],g={request:{url:a,method:r.method,headers:Gg(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:Gg(c.headers)},openai:{request:{body:o},response:{}}},m=P2(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:Y5(c.headers)}),h=await hbe.transformResponseIn(A),_=P2(h.body);return Promise.all([m.done,_.done]).then(async([y,S])=>{try{let I=u?est(y):JSON.parse(y),w=u?await LU(S):JSON.parse(S);j5({...g,openai:{...g.openai,response:{body:I}},response:{...g.response,body:w}},f)}catch(I){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+I?.stack)}}).catch(y=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+y)),new Response(_.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function Orn(e){return async(t,r)=>{if(!XZ(t,r))return e(t,r);let n=r.body;if(r.body)try{let f=JSON.parse(r.body);n=JSON.stringify(f)}catch{}let i=Gg(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete i["x-api-key"],delete i["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete i.authorization,delete i.Authorization),delete i["content-length"];let a=await e(t,{method:r.method,headers:i,body:n,signal:r.signal});if(!a.ok){let f=await a.text();K(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof Qv?t.toString():t.url,status:a.status,errorResponse:f});let g;try{let m=JSON.parse(f);g={type:"error",error:{type:"api_error",message:m.error?.message||m.message||`API error: ${a.statusText}`,code:m.error?.code||m.code||`API_${a.status}_ERROR`}},m.error?.details&&(g.error.details=m.error.details)}catch{g={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(g),{status:a.status,statusText:a.statusText,headers:{"Content-Type":"application/json"}})}let l=a.clone(),c=!(Object.hasOwn(JSON.parse(n),"stream")&&!JSON.parse(n).stream),u={request:{url:typeof t=="string"?t:t instanceof Qv?t.toString():t.url,method:r.method,headers:Gg(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:Gg(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await LU(m)}else u.response.body=await a.json();let g=Gg(r.headers)["x-agent-id"];$z(g,u),qz(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(f=>K(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
|
|
761
|
-
Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var ZZ=null,GIe=!1;function krn(){ZZ=null,GIe=!1}gr.on("proxy:changed",krn);function Mrn(){if(GIe)return ZZ;if(GIe=!0,ut().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(ZZ=new vgt.ProxyAgent({uri:e}),Zt(`[proxy] using proxy: ${e}`)),ZZ}function Qrn(){let e=Mrn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function eX(e){let t=e||process.env.API_TYPE,r=Qrn();switch(t){case"openai":return Rrn(r);case"openai-responses":return Nrn(r);case"gemini":return Brn(r);default:return Orn(r)}}_h();var Urn=X(ge(),1);function xgt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=Prn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function Prn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||Lrn(t)?0:Frn(t)?2:1}function Lrn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function Frn(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function C_(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function cS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}ke();fs();var gc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function tX(e,t){gc.totalCost+=e,gc.totalAPIDuration+=t}function rX(e,t){gc.inputTokens+=e,gc.outputTokens+=t,gr.emit("token:change",{inputTokens:gc.inputTokens,outputTokens:gc.outputTokens})}function nX(e,t){gc.cacheCreationTokens+=e,gc.cacheReadTokens+=t}function YIe(){return{inputTokens:gc.inputTokens,outputTokens:gc.outputTokens,cacheCreationTokens:gc.cacheCreationTokens,cacheReadTokens:gc.cacheReadTokens}}function wgt(){return gc.totalCost}function Dgt(){return Date.now()-gc.startTime}function Rgt(){return gc.totalAPIDuration}function Ngt(e){gc.currentContextTokens=e}function Bgt(){return gc.currentContextTokens}ke();He();He();var VIe="2.4.31";globalThis.MACRO={VERSION:VIe,PACKAGE_URL:`@dahawa/${Ji}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var iX=process.env.HAWA_CODE_USER_AGENT||`${Ji}/${VIe} (${process.env.USER_TYPE})`;import{randomUUID as kE}from"crypto";fs();ke();Wt();Er();ke();He();import{existsSync as x_,readdirSync as man,statSync as gan}from"fs";import{join as pS,relative as Aan}from"path";import{homedir as SEt}from"os";import{platform as han}from"process";import{readFile as mS}from"fs/promises";Er();zg();ar();import{join as zrn,sep as jrn}from"path";function Cm(){if(!bm())return!1;try{let e=ut();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function tp(){return(zrn(Oe(),".hcode","team-memory")+jrn).normalize("NFC")}function I_(e){let t=e.normalize("NFC"),r=tp();return t.startsWith(r)}var IEt=X(r9(),1);Pi();var dTe=(e,t,r)=>{let n=e instanceof RegExp?Jht(e,r):e,i=t instanceof RegExp?Jht(t,r):t,o=n!==null&&i!=null&&isn(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},Jht=(e,t)=>{let r=t.match(e);return r?r[0]:null},isn=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var Zht="\0SLASH"+Math.random()+"\0",Xht="\0OPEN"+Math.random()+"\0",mTe="\0CLOSE"+Math.random()+"\0",eEt="\0COMMA"+Math.random()+"\0",tEt="\0PERIOD"+Math.random()+"\0",osn=new RegExp(Zht,"g"),ssn=new RegExp(Xht,"g"),asn=new RegExp(mTe,"g"),lsn=new RegExp(eEt,"g"),csn=new RegExp(tEt,"g"),usn=/\\\\/g,dsn=/\\{/g,fsn=/\\}/g,psn=/\\,/g,msn=/\\\./g,gsn=1e5,Asn=4e6;function fTe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function hsn(e){return e.replace(usn,Zht).replace(dsn,Xht).replace(fsn,mTe).replace(psn,eEt).replace(msn,tEt)}function Esn(e){return e.replace(osn,"\\").replace(ssn,"{").replace(asn,"}").replace(lsn,",").replace(csn,".")}function rEt(e){if(!e)return[""];let t=[],r=dTe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=rEt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function nEt(e,t={}){if(!e)return[];let{max:r=gsn,maxLength:n=Asn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),pTe(hsn(e),r,n,!0).map(Esn)}function _sn(e){return"{"+e+"}"}function ysn(e){return/^-?0\d/.test(e)}function bsn(e,t){return e<=t}function Csn(e,t){return e>=t}function n9(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function Ssn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=fTe(i[0]),a=fTe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(fTe(i[2])),1):1,u=bsn;a<s&&(c*=-1,u=Csn);let g=i.some(ysn),m=0;for(let A=s;u(A,a)&&o.length<r;A+=c){let h;if(t)h=String.fromCharCode(A),h==="\\"&&(h="");else if(h=String(A),g){let _=l-h.length;if(_>0){let y=new Array(_+1).join("0");A<0?h="-"+y+h.slice(1):h=y+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function pTe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=dTe("{","}",e);if(!a)return n9(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=n9(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+mTe+a.post,n=!0;continue}return n9(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=Ssn(a.body,u,t,r);else{let A=rEt(a.body);if(A.length===1&&A[0]!==void 0&&(A=pTe(A[0],t,r,!1).map(_sn),A.length===1)){if(i=n9(i,l+A[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=o&&!a.post.length&&!l;for(let y=0;h&&y<i.length;y++)i[y]&&(h=!1);m=[];let _=0;e:for(let y=0;y<A.length;y++){let S=pTe(A[y],t,r,!1);for(let I=0;I<S.length;I++){let w=S[I];if(!(h&&!w)){if(m.length>=t||_+w.length>r)break e;m.push(w),_+=w.length}}}}if(i=n9(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var i9=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Isn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},o9=e=>e.replace(/[[\]\\-]/g,"\\$&"),Tsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),iEt=e=>e.join(""),oEt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[_,[y,S,I]]of Object.entries(Isn))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,f){h>f?n.push(o9(f)+"-"+o9(h)):h===f&&n.push(o9(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(o9(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(o9(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let h=n[0].length===2?n[0].slice(-1):n[0];return[Tsn(h),!1,u-r,!1]}let g="["+(c?"^":"")+iEt(n)+"]",m="["+(c?"":"^")+iEt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var fS=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var zd,vsn=new Set(["!","?","+","*","@"]),gTe=e=>vsn.has(e),sEt=e=>gTe(e.type),xsn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),wsn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Dsn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),aEt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Rsn="(?!(?:^|/)\\.\\.?(?:$|/))",hX="(?!\\.)",Nsn=new Set(["[","."]),Bsn=new Set(["..","."]),Osn=new Set("().*{}+?[]^$\\!"),ksn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ATe="[^/]",lEt=ATe+"*?",cEt=ATe+"+?",Msn=0,Gv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++Msn;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof zd&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof zd&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new zd(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let h=n,_="";for(;h<t.length;){let y=t.charAt(h++);if(a||y==="\\"){a=!a,_+=y;continue}if(l){h===c+1?(y==="^"||y==="!")&&(u=!0):y==="]"&&!(h===c+2&&u)&&(l=!1),_+=y;continue}else if(y==="["){l=!0,c=h,u=!1,_+=y;continue}if(!i.noext&&gTe(y)&&t.charAt(h)==="("&&o<=s){r.push(_),_="";let I=new zd(y,r);h=zd.#c(t,I,h,i,o+1),r.push(I);continue}_+=y}return r.push(_),h}let f=n+1,g=new zd(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&gTe(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let y=r&&r.#E(h)?0:1;g.push(A),A="";let S=new zd(h,g);g.push(S),f=zd.#c(t,S,f,i,o+y);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new zd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,wsn)}#h(t,r=xsn){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type,r)}#E(t,r=Dsn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new zd(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#y(t){return!!aEt.get(this.type)?.has(t)}#S(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#I(t){let r=aEt.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#p=!1}static fromGlob(t,r={}){let n=new zd(null,void 0,r);return zd.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#_(),this.#f()),!sEt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,_,y]=typeof m=="string"?zd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||y,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&Bsn.has(this.#r[0]))){let A=Nsn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),_=!r&&!t&&A.has(c.charAt(0));u=h?Rsn:_?hX:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,fS(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,fS(this.toString()),!1,!1]}let s=!n||t||r||!hX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?hX:"")+cEt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?hX:"")+lEt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,fS(o),this.#t=!!this.#t,this.#n]}#_(){if(sEt(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#_(),this.#h(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#A(i,n)):this.#S(i)&&(r=!1,this.#I(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#_();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#C(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(Osn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?cEt:lEt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=oEt(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=ATe,r=!0;continue}o+=ksn(c)}return[o,fS(t),!!r,s]}};zd=Gv;var hTe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var hc=(e,t,r={})=>(i9(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Y2(t,r).match(e)),Qsn=/^\*+([^+@!?*[(]*)$/,Psn=e=>t=>!t.startsWith(".")&&t.endsWith(e),Lsn=e=>t=>t.endsWith(e),Fsn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Usn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Hsn=/^\*+\.\*+$/,$sn=e=>!e.startsWith(".")&&e.includes("."),qsn=e=>e!=="."&&e!==".."&&e.includes("."),Gsn=/^\.\*+$/,zsn=e=>e!=="."&&e!==".."&&e.startsWith("."),jsn=/^\*+$/,Ysn=e=>e.length!==0&&!e.startsWith("."),Vsn=e=>e.length!==0&&e!=="."&&e!=="..",Wsn=/^\?+([^+@!?*[(]*)?$/,Ksn=([e,t=""])=>{let r=fEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Jsn=([e,t=""])=>{let r=pEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Zsn=([e,t=""])=>{let r=pEt([e]);return t?n=>r(n)&&n.endsWith(t):r},Xsn=([e,t=""])=>{let r=fEt([e]);return t?n=>r(n)&&n.endsWith(t):r},fEt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},pEt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},mEt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",uEt={win32:{sep:"\\"},posix:{sep:"/"}},ean=mEt==="win32"?uEt.win32.sep:uEt.posix.sep;hc.sep=ean;var Jc=Symbol("globstar **");hc.GLOBSTAR=Jc;var tan="[^/]",ran=tan+"*?",nan="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ian="(?:(?!(?:\\/|^)\\.).)*?",oan=(e,t={})=>r=>hc(r,e,t);hc.filter=oan;var Sm=(e,t={})=>Object.assign({},e,t),san=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return hc;let t=hc;return Object.assign((n,i,o={})=>t(n,i,Sm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Sm(e,o))}static defaults(i){return t.defaults(Sm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Sm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Sm(e,o))}},unescape:(n,i={})=>t.unescape(n,Sm(e,i)),escape:(n,i={})=>t.escape(n,Sm(e,i)),filter:(n,i={})=>t.filter(n,Sm(e,i)),defaults:n=>t.defaults(Sm(e,n)),makeRe:(n,i={})=>t.makeRe(n,Sm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Sm(e,i)),match:(n,i,o={})=>t.match(n,i,Sm(e,o)),sep:t.sep,GLOBSTAR:Jc})};hc.defaults=san;var gEt=(e,t={})=>(i9(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:nEt(e,{max:t.braceExpandMax}));hc.braceExpand=gEt;var aan=(e,t={})=>new Y2(e,t).makeRe();hc.makeRe=aan;var lan=(e,t,r={})=>{let n=new Y2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};hc.match=lan;var dEt=/[?*]|[+@!]\(.*?\)|\[|\]/,can=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Y2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){i9(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||mEt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!dEt.test(o[2]))&&!dEt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Jc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Jc,o),a=r.lastIndexOf(Jc),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let S=t.slice(i,i+l.length);if(!this.#n(S,l,n,0,0))return!1;i+=l.length,o+=l.length}let f=0;if(u.length){if(u.length+i>t.length)return!1;let S=t.length-u.length;if(this.#n(t,u,n,S,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;f=u.length+1}}if(!c.length){let S=!!f;for(let I=i;I<t.length-f;I++){let w=String(t[I]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let g=[[[],0]],m=g[0],A=0,h=[0];for(let S of c)S===Jc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-f;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],f=t[s];if(this.debug(r,u,f),u===!1||u===Jc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return gEt(this.pattern,this.options)}parse(t){i9(t);let r=this.options;if(t==="**")return Jc;if(t==="")return"";let n,i=null;(n=t.match(jsn))?i=r.dot?Vsn:Ysn:(n=t.match(Qsn))?i=(r.nocase?r.dot?Usn:Fsn:r.dot?Lsn:Psn)(n[1]):(n=t.match(Wsn))?i=(r.nocase?r.dot?Jsn:Ksn:r.dot?Zsn:Xsn)(n):(n=t.match(Hsn))?i=r.dot?qsn:$sn:(n=t.match(Gsn))&&(i=zsn);let o=Gv.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?ran:r.dot?nan:ian,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?can(f):f===Jc?Jc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==Jc||A===Jc||(A===void 0?m!==void 0&&m!==Jc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Jc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Jc))});let u=c.filter(f=>f!==Jc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return hc.defaults(t).Minimatch}};hc.AST=Gv;hc.Minimatch=Y2;hc.escape=hTe;hc.unescape=fS;var EEt=X(r9(),1);Er();He();ke();wu();import{readFile as AEt}from"fs/promises";import{existsSync as ETe,readdirSync as uan,statSync as dan}from"fs";import{join as _Te,relative as _Et}from"path";import{homedir as fan}from"os";function hEt(e){try{let t=(0,EEt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return ve(t),{paths:[],content:e.trim()}}}function pan(e,t){return t.length===0?!0:t.some(r=>{try{return hc(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function yTe(e){let t=[];try{if(!ETe(e))return t;let r=uan(e);for(let n of r){let i=_Te(e,n),o=dan(i);o.isDirectory()?t.push(...yTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function EX(){let e=[];try{let t=_Te(fan(),Xr,"rules");if(ETe(t)){let r=yTe(t);for(let n of r)try{let i=await AEt(n,"utf-8"),{paths:o,content:s}=hEt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=_Te(Oe(),Xr,"rules");if(ETe(t)){let r=yTe(t);for(let n of r)try{let i=await AEt(n,"utf-8"),{paths:o,content:s}=hEt(i);o.length>0&&e.push({filePath:_Et(Oe(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function yEt(e,t){e=FV(e);let r=FV(Oe()),n=e.startsWith(r)?_Et(r,e):e;return t.filter(i=>pan(n,i.paths))}function bEt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
|
|
761
|
+
Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var ZZ=null,GIe=!1;function krn(){ZZ=null,GIe=!1}gr.on("proxy:changed",krn);function Mrn(){if(GIe)return ZZ;if(GIe=!0,ut().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(ZZ=new vgt.ProxyAgent({uri:e}),Zt(`[proxy] using proxy: ${e}`)),ZZ}function Qrn(){let e=Mrn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function eX(e){let t=e||process.env.API_TYPE,r=Qrn();switch(t){case"openai":return Rrn(r);case"openai-responses":return Nrn(r);case"gemini":return Brn(r);default:return Orn(r)}}_h();var Urn=X(ge(),1);function xgt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=Prn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function Prn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||Lrn(t)?0:Frn(t)?2:1}function Lrn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function Frn(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function C_(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function cS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}ke();fs();var gc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function tX(e,t){gc.totalCost+=e,gc.totalAPIDuration+=t}function rX(e,t){gc.inputTokens+=e,gc.outputTokens+=t,gr.emit("token:change",{inputTokens:gc.inputTokens,outputTokens:gc.outputTokens})}function nX(e,t){gc.cacheCreationTokens+=e,gc.cacheReadTokens+=t}function YIe(){return{inputTokens:gc.inputTokens,outputTokens:gc.outputTokens,cacheCreationTokens:gc.cacheCreationTokens,cacheReadTokens:gc.cacheReadTokens}}function wgt(){return gc.totalCost}function Dgt(){return Date.now()-gc.startTime}function Rgt(){return gc.totalAPIDuration}function Ngt(e){gc.currentContextTokens=e}function Bgt(){return gc.currentContextTokens}ke();He();He();var VIe="2.4.32";globalThis.MACRO={VERSION:VIe,PACKAGE_URL:`@dahawa/${Ji}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var iX=process.env.HAWA_CODE_USER_AGENT||`${Ji}/${VIe} (${process.env.USER_TYPE})`;import{randomUUID as kE}from"crypto";fs();ke();Wt();Er();ke();He();import{existsSync as x_,readdirSync as man,statSync as gan}from"fs";import{join as pS,relative as Aan}from"path";import{homedir as SEt}from"os";import{platform as han}from"process";import{readFile as mS}from"fs/promises";Er();zg();ar();import{join as zrn,sep as jrn}from"path";function Cm(){if(!bm())return!1;try{let e=ut();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function tp(){return(zrn(Oe(),".hcode","team-memory")+jrn).normalize("NFC")}function I_(e){let t=e.normalize("NFC"),r=tp();return t.startsWith(r)}var IEt=X(r9(),1);Pi();var dTe=(e,t,r)=>{let n=e instanceof RegExp?Jht(e,r):e,i=t instanceof RegExp?Jht(t,r):t,o=n!==null&&i!=null&&isn(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},Jht=(e,t)=>{let r=t.match(e);return r?r[0]:null},isn=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var Zht="\0SLASH"+Math.random()+"\0",Xht="\0OPEN"+Math.random()+"\0",mTe="\0CLOSE"+Math.random()+"\0",eEt="\0COMMA"+Math.random()+"\0",tEt="\0PERIOD"+Math.random()+"\0",osn=new RegExp(Zht,"g"),ssn=new RegExp(Xht,"g"),asn=new RegExp(mTe,"g"),lsn=new RegExp(eEt,"g"),csn=new RegExp(tEt,"g"),usn=/\\\\/g,dsn=/\\{/g,fsn=/\\}/g,psn=/\\,/g,msn=/\\\./g,gsn=1e5,Asn=4e6;function fTe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function hsn(e){return e.replace(usn,Zht).replace(dsn,Xht).replace(fsn,mTe).replace(psn,eEt).replace(msn,tEt)}function Esn(e){return e.replace(osn,"\\").replace(ssn,"{").replace(asn,"}").replace(lsn,",").replace(csn,".")}function rEt(e){if(!e)return[""];let t=[],r=dTe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=rEt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function nEt(e,t={}){if(!e)return[];let{max:r=gsn,maxLength:n=Asn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),pTe(hsn(e),r,n,!0).map(Esn)}function _sn(e){return"{"+e+"}"}function ysn(e){return/^-?0\d/.test(e)}function bsn(e,t){return e<=t}function Csn(e,t){return e>=t}function n9(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function Ssn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=fTe(i[0]),a=fTe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(fTe(i[2])),1):1,u=bsn;a<s&&(c*=-1,u=Csn);let g=i.some(ysn),m=0;for(let A=s;u(A,a)&&o.length<r;A+=c){let h;if(t)h=String.fromCharCode(A),h==="\\"&&(h="");else if(h=String(A),g){let _=l-h.length;if(_>0){let y=new Array(_+1).join("0");A<0?h="-"+y+h.slice(1):h=y+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function pTe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=dTe("{","}",e);if(!a)return n9(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=n9(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+mTe+a.post,n=!0;continue}return n9(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=Ssn(a.body,u,t,r);else{let A=rEt(a.body);if(A.length===1&&A[0]!==void 0&&(A=pTe(A[0],t,r,!1).map(_sn),A.length===1)){if(i=n9(i,l+A[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=o&&!a.post.length&&!l;for(let y=0;h&&y<i.length;y++)i[y]&&(h=!1);m=[];let _=0;e:for(let y=0;y<A.length;y++){let S=pTe(A[y],t,r,!1);for(let I=0;I<S.length;I++){let w=S[I];if(!(h&&!w)){if(m.length>=t||_+w.length>r)break e;m.push(w),_+=w.length}}}}if(i=n9(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var i9=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Isn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},o9=e=>e.replace(/[[\]\\-]/g,"\\$&"),Tsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),iEt=e=>e.join(""),oEt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[_,[y,S,I]]of Object.entries(Isn))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,f){h>f?n.push(o9(f)+"-"+o9(h)):h===f&&n.push(o9(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(o9(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(o9(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let h=n[0].length===2?n[0].slice(-1):n[0];return[Tsn(h),!1,u-r,!1]}let g="["+(c?"^":"")+iEt(n)+"]",m="["+(c?"":"^")+iEt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var fS=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var zd,vsn=new Set(["!","?","+","*","@"]),gTe=e=>vsn.has(e),sEt=e=>gTe(e.type),xsn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),wsn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Dsn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),aEt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Rsn="(?!(?:^|/)\\.\\.?(?:$|/))",hX="(?!\\.)",Nsn=new Set(["[","."]),Bsn=new Set(["..","."]),Osn=new Set("().*{}+?[]^$\\!"),ksn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ATe="[^/]",lEt=ATe+"*?",cEt=ATe+"+?",Msn=0,Gv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++Msn;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof zd&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof zd&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new zd(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let h=n,_="";for(;h<t.length;){let y=t.charAt(h++);if(a||y==="\\"){a=!a,_+=y;continue}if(l){h===c+1?(y==="^"||y==="!")&&(u=!0):y==="]"&&!(h===c+2&&u)&&(l=!1),_+=y;continue}else if(y==="["){l=!0,c=h,u=!1,_+=y;continue}if(!i.noext&&gTe(y)&&t.charAt(h)==="("&&o<=s){r.push(_),_="";let I=new zd(y,r);h=zd.#c(t,I,h,i,o+1),r.push(I);continue}_+=y}return r.push(_),h}let f=n+1,g=new zd(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&gTe(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let y=r&&r.#E(h)?0:1;g.push(A),A="";let S=new zd(h,g);g.push(S),f=zd.#c(t,S,f,i,o+y);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new zd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,wsn)}#h(t,r=xsn){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type,r)}#E(t,r=Dsn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new zd(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#y(t){return!!aEt.get(this.type)?.has(t)}#S(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#I(t){let r=aEt.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#p=!1}static fromGlob(t,r={}){let n=new zd(null,void 0,r);return zd.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#_(),this.#f()),!sEt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,_,y]=typeof m=="string"?zd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||y,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&Bsn.has(this.#r[0]))){let A=Nsn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),_=!r&&!t&&A.has(c.charAt(0));u=h?Rsn:_?hX:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,fS(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,fS(this.toString()),!1,!1]}let s=!n||t||r||!hX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?hX:"")+cEt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?hX:"")+lEt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,fS(o),this.#t=!!this.#t,this.#n]}#_(){if(sEt(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#_(),this.#h(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#A(i,n)):this.#S(i)&&(r=!1,this.#I(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#_();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#C(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(Osn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?cEt:lEt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=oEt(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=ATe,r=!0;continue}o+=ksn(c)}return[o,fS(t),!!r,s]}};zd=Gv;var hTe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var hc=(e,t,r={})=>(i9(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Y2(t,r).match(e)),Qsn=/^\*+([^+@!?*[(]*)$/,Psn=e=>t=>!t.startsWith(".")&&t.endsWith(e),Lsn=e=>t=>t.endsWith(e),Fsn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Usn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Hsn=/^\*+\.\*+$/,$sn=e=>!e.startsWith(".")&&e.includes("."),qsn=e=>e!=="."&&e!==".."&&e.includes("."),Gsn=/^\.\*+$/,zsn=e=>e!=="."&&e!==".."&&e.startsWith("."),jsn=/^\*+$/,Ysn=e=>e.length!==0&&!e.startsWith("."),Vsn=e=>e.length!==0&&e!=="."&&e!=="..",Wsn=/^\?+([^+@!?*[(]*)?$/,Ksn=([e,t=""])=>{let r=fEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Jsn=([e,t=""])=>{let r=pEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Zsn=([e,t=""])=>{let r=pEt([e]);return t?n=>r(n)&&n.endsWith(t):r},Xsn=([e,t=""])=>{let r=fEt([e]);return t?n=>r(n)&&n.endsWith(t):r},fEt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},pEt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},mEt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",uEt={win32:{sep:"\\"},posix:{sep:"/"}},ean=mEt==="win32"?uEt.win32.sep:uEt.posix.sep;hc.sep=ean;var Jc=Symbol("globstar **");hc.GLOBSTAR=Jc;var tan="[^/]",ran=tan+"*?",nan="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ian="(?:(?!(?:\\/|^)\\.).)*?",oan=(e,t={})=>r=>hc(r,e,t);hc.filter=oan;var Sm=(e,t={})=>Object.assign({},e,t),san=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return hc;let t=hc;return Object.assign((n,i,o={})=>t(n,i,Sm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Sm(e,o))}static defaults(i){return t.defaults(Sm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Sm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Sm(e,o))}},unescape:(n,i={})=>t.unescape(n,Sm(e,i)),escape:(n,i={})=>t.escape(n,Sm(e,i)),filter:(n,i={})=>t.filter(n,Sm(e,i)),defaults:n=>t.defaults(Sm(e,n)),makeRe:(n,i={})=>t.makeRe(n,Sm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Sm(e,i)),match:(n,i,o={})=>t.match(n,i,Sm(e,o)),sep:t.sep,GLOBSTAR:Jc})};hc.defaults=san;var gEt=(e,t={})=>(i9(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:nEt(e,{max:t.braceExpandMax}));hc.braceExpand=gEt;var aan=(e,t={})=>new Y2(e,t).makeRe();hc.makeRe=aan;var lan=(e,t,r={})=>{let n=new Y2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};hc.match=lan;var dEt=/[?*]|[+@!]\(.*?\)|\[|\]/,can=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Y2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){i9(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||mEt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!dEt.test(o[2]))&&!dEt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Jc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Jc,o),a=r.lastIndexOf(Jc),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let S=t.slice(i,i+l.length);if(!this.#n(S,l,n,0,0))return!1;i+=l.length,o+=l.length}let f=0;if(u.length){if(u.length+i>t.length)return!1;let S=t.length-u.length;if(this.#n(t,u,n,S,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;f=u.length+1}}if(!c.length){let S=!!f;for(let I=i;I<t.length-f;I++){let w=String(t[I]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let g=[[[],0]],m=g[0],A=0,h=[0];for(let S of c)S===Jc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-f;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],f=t[s];if(this.debug(r,u,f),u===!1||u===Jc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return gEt(this.pattern,this.options)}parse(t){i9(t);let r=this.options;if(t==="**")return Jc;if(t==="")return"";let n,i=null;(n=t.match(jsn))?i=r.dot?Vsn:Ysn:(n=t.match(Qsn))?i=(r.nocase?r.dot?Usn:Fsn:r.dot?Lsn:Psn)(n[1]):(n=t.match(Wsn))?i=(r.nocase?r.dot?Jsn:Ksn:r.dot?Zsn:Xsn)(n):(n=t.match(Hsn))?i=r.dot?qsn:$sn:(n=t.match(Gsn))&&(i=zsn);let o=Gv.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?ran:r.dot?nan:ian,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?can(f):f===Jc?Jc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==Jc||A===Jc||(A===void 0?m!==void 0&&m!==Jc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Jc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Jc))});let u=c.filter(f=>f!==Jc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return hc.defaults(t).Minimatch}};hc.AST=Gv;hc.Minimatch=Y2;hc.escape=hTe;hc.unescape=fS;var EEt=X(r9(),1);Er();He();ke();wu();import{readFile as AEt}from"fs/promises";import{existsSync as ETe,readdirSync as uan,statSync as dan}from"fs";import{join as _Te,relative as _Et}from"path";import{homedir as fan}from"os";function hEt(e){try{let t=(0,EEt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return ve(t),{paths:[],content:e.trim()}}}function pan(e,t){return t.length===0?!0:t.some(r=>{try{return hc(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function yTe(e){let t=[];try{if(!ETe(e))return t;let r=uan(e);for(let n of r){let i=_Te(e,n),o=dan(i);o.isDirectory()?t.push(...yTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function EX(){let e=[];try{let t=_Te(fan(),Xr,"rules");if(ETe(t)){let r=yTe(t);for(let n of r)try{let i=await AEt(n,"utf-8"),{paths:o,content:s}=hEt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=_Te(Oe(),Xr,"rules");if(ETe(t)){let r=yTe(t);for(let n of r)try{let i=await AEt(n,"utf-8"),{paths:o,content:s}=hEt(i);o.length>0&&e.push({filePath:_Et(Oe(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function yEt(e,t){e=FV(e);let r=FV(Oe()),n=e.startsWith(r)?_Et(r,e):e;return t.filter(i=>pan(n,i.paths))}function bEt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
|
|
762
762
|
|
|
763
763
|
${r.content}`}).join(`
|
|
764
764
|
|
|
@@ -929,7 +929,7 @@ try {
|
|
|
929
929
|
`);if(J.meta||J.shift)return Q.insert(`
|
|
930
930
|
`);r?.(e)}function ie(){if(y)return s?.(),Q;let J=Q.up();return J.equals(Q)&&s?.(),J}function oe(){if(y)return a?.(),Q;let J=Q.down();return J.equals(Q)&&a?.(),J}function Ee(J,Y){if(Y.tab)return;if(Y.backspace||Y.delete||J==="\b"||J==="\x7F"||J==="\b"){let Xe=Q.backspace();Q.equals(Xe)||(O(Xe.offset),Q.text!==Xe.text&&t(Xe.text));return}if(!Y.ctrl&&!Y.meta&&J.length>1){let Xe=Q.insert(J);Q.equals(Xe)||(O(Xe.offset),Q.text!==Xe.text&&t(Xe.text));return}let Ne=Ye(Y)(J);Ne&&(Q.equals(Ne)||(O(Ne.offset),Q.text!==Ne.text&&t(Ne.text)))}function Ye(J){if(J.backspace||J.delete)return q(),()=>Q.backspace();switch(!0){case J.escape:return u&&!e?()=>(u(),Q):$;case(J.leftArrow&&(J.ctrl||J.meta||"fn"in J&&J.fn)):return()=>Q.prevWord();case(J.rightArrow&&(J.ctrl||J.meta||"fn"in J&&J.fn)):return()=>Q.nextWord();case J.ctrl:return _e;case("home"in J&&J.home):return()=>Q.startOfLine();case("end"in J&&J.end):return()=>Q.endOfLine();case J.pageDown:return()=>Q.endOfLine();case J.pageUp:return()=>Q.startOfLine();case J.return:return()=>fe(J);case J.meta:return Ce;case J.upArrow:return ie;case J.downArrow:return oe;case J.leftArrow:return()=>Q.left();case J.rightArrow:return()=>Q.right()}return function(Y){switch(!0){case(Y=="\x1B[H"||Y=="\x1B[1~"):return Q.startOfLine();case(Y=="\x1B[F"||Y=="\x1B[4~"):return Q.endOfLine();case(Y==="\b"||Y==="\x7F"||Y==="\b"):return q(),Q.backspace();default:return Q.insert(Y.replace(/\r/g,`
|
|
931
931
|
`))}}}return{onInput:Ee,renderedValue:Q.render(m,f,A),offset:w,setOffset:O}}function dx({value:e,placeholder:t="",focus:r=!0,mask:n,multiline:i=!1,highlightPastedText:o=!1,showCursor:s=!0,onChange:a,onSubmit:l,onExit:c,onHistoryUp:u,onHistoryDown:f,onExitMessage:g,onMessage:m,onHistoryReset:A,onCancel:h,onEscape:_,columns:y,onImagePaste:S,onPaste:I,isDimmed:w=!1,disableCursorMovementForUpDownKeys:O=!1,cursorOffset:Q,onChangeCursorOffset:G}){let{onInput:j,renderedValue:q}=K_t({value:e,onChange:a,onSubmit:l,onExit:c,onExitMessage:g,onMessage:m,onHistoryReset:A,onHistoryUp:u,onHistoryDown:f,onCancel:h,onEscape:_,focus:r,mask:n,multiline:i,cursorChar:s?" ":"",highlightPastedText:o,invert:Ce=>cr.bgHex("#ffffff").hex("#000000")(Ce),themeText:Ce=>cr.hex(Be().text)(Ce),columns:y,onImagePaste:S,disableCursorMovementForUpDownKeys:O,externalOffset:Q,onOffsetChange:G}),[V,$]=kve.default.useState({chunks:[],timeoutId:null}),ce=Ce=>(Ce&&clearTimeout(Ce),setTimeout(()=>{$(({chunks:fe})=>{let ie=fe.join("");return Promise.resolve().then(()=>I(ie)),{chunks:[],timeoutId:null}})},100));er((Ce,fe)=>{if(I&&(Ce.length>10||V.timeoutId)){$(({chunks:ie,timeoutId:oe})=>({chunks:[...ie,Ce],timeoutId:ce(oe)}));return}j(Ce,fe)},{isActive:r});let M=t?cr.hex(Be().secondaryText)(t):void 0,se=Ce=>cr.bgHex("#ffffff").hex("#000000")(Ce);s&&r&&(M=t.length>0?se(t[0])+cr.hex(Be().secondaryText)(t.slice(1)):se(" "));let _e=e.length==0&&t;return kve.default.createElement(v,{wrap:"truncate-end",dimColor:w},_e?M:q)}function J_t({onClose:e}){let[t,r]=(0,ru.useState)(mn()),n=ci.useRef(mn()),[i,o]=(0,ru.useState)(0),s=tu(()=>process.exit(0)),[a,l]=(0,ru.useState)(ut().webServer?.enabled??!1),[c,u]=(0,ru.useState)(ut().proxy??!1),f=ci.useRef(ut().proxy??!1),[g,m]=(0,ru.useState)(nt.getLazyToolMode()),A=ci.useRef(nt.getLazyToolMode()),[h,_]=(0,ru.useState)(ut().autoMode?.enabled??!0),y=ci.useRef(ut().autoMode?.enabled??!0),[S,I]=(0,ru.useState)(ut().memo??!1),w=ci.useRef(ut().memo??!1),[O,Q]=(0,ru.useState)(ut().messageArchiving??!1),G=ci.useRef(ut().messageArchiving??!1),[j,q]=(0,ru.useState)(ut().archiveToolUseInputs??!1),V=ci.useRef(ut().archiveToolUseInputs??!1),[$,ce]=(0,ru.useState)(ut().planDirectory??""),ee=ci.useRef(ut().planDirectory??""),[M,se]=(0,ru.useState)(String(ut().agentDepth??1)),_e=ci.useRef(String(ut().agentDepth??1)),[Ce,fe]=(0,ru.useState)(ut().plugins?.pluginClaudeCompat??!1),ie=ci.useRef(ut().plugins?.pluginClaudeCompat??!1),[oe,Ee]=(0,ru.useState)(null),[Ye,J]=(0,ru.useState)(""),[Y,Ne]=(0,ru.useState)(0),Xe=[...process.env.ANTHROPIC_API_KEY?[{id:"apiKey",label:`Use custom API key: ${cr.bold(Ah(process.env.ANTHROPIC_API_KEY))}`,value:!!(process.env.ANTHROPIC_API_KEY&&t.customApiKeyResponses?.approved?.includes(Ah(process.env.ANTHROPIC_API_KEY))),type:"boolean",onChange(we){let Se={...mn()};if(Se.customApiKeyResponses||(Se.customApiKeyResponses={approved:[],rejected:[]}),Se.customApiKeyResponses.approved||(Se.customApiKeyResponses.approved=[]),Se.customApiKeyResponses.rejected||(Se.customApiKeyResponses.rejected=[]),process.env.ANTHROPIC_API_KEY){let qe=Ah(process.env.ANTHROPIC_API_KEY);we?(Se.customApiKeyResponses.approved=[...Se.customApiKeyResponses.approved.filter(Ge=>Ge!==qe),qe],Se.customApiKeyResponses.rejected=Se.customApiKeyResponses.rejected.filter(Ge=>Ge!==qe)):(Se.customApiKeyResponses.approved=Se.customApiKeyResponses.approved.filter(Ge=>Ge!==qe),Se.customApiKeyResponses.rejected=[...Se.customApiKeyResponses.rejected.filter(Ge=>Ge!==qe),qe])}vo(Se),r(Se)}}]:[],{id:"verbose",label:"Verbose output",value:t.verbose,type:"boolean",onChange(we){let Se={...mn(),verbose:we};vo(Se),r(Se)}},{id:"theme",label:"Theme",value:t.theme,options:["light","dark","light-daltonized","dark-daltonized"],type:"enum",onChange(we){let Se={...mn(),theme:we};vo(Se),r(Se)}},{id:"notifChannel",label:"Notifications",value:t.preferredNotifChannel,options:["iterm2","terminal_bell","iterm2_with_bell","notifications_disabled"],type:"enum",onChange(we){let Se={...mn(),preferredNotifChannel:we};vo(Se),r(Se)}},{id:"webServer",label:"Web Server",value:a?"on":"off",options:["off","on"],type:"enum",onChange(we){let Se=we==="on";l(Se);let qe=ut(),Ge={...qe.webServer,enabled:Se,port:qe.webServer?.port||3210,host:qe.webServer?.host||"127.0.0.1"};Fr.updateSetting("webServer",Ge),Se?O9.start().catch(()=>{}):O9.stop().catch(()=>{})}},{id:"proxy",label:"Proxy",value:c?"on":"off",options:["off","on"],type:"enum",onChange(we){let Se=we==="on";u(Se),Fr.updateSetting("proxy",Se),gr.emit("proxy:changed")}},{id:"lazyTool",label:"Lazy Tool",value:g,options:["off","loading","proxy"],type:"enum",onChange(we){let Se=we;m(Se),Fr.updateSetting("lazyTool",Se)}},{id:"autoMode",label:"Auto Mode",value:h?"on":"off",options:["off","on"],type:"enum",onChange(we){let Se=we==="on";_(Se);let Ge={...ut().autoMode,enabled:Se};Fr.updateSetting("autoMode",Ge)}},{id:"memo",label:"Memo",value:S?"on":"off",options:["off","on"],type:"enum",onChange(we){let Se=we==="on";I(Se),Fr.updateSetting("memo",Se)}},{id:"messageArchiving",label:"Message Archiving",value:O?"on":"off",options:["off","on"],type:"enum",onChange(we){let Se=we==="on";Q(Se),Fr.updateSetting("messageArchiving",Se)}},{id:"archiveToolUseInputs",label:"Archive Tool Use Inputs",value:j?"on":"off",options:["off","on"],type:"enum",onChange(we){let Se=we==="on";q(Se),Fr.updateSetting("archiveToolUseInputs",Se)}},{id:"pluginClaudeCompat",label:"Claude Code plugin compatibility",value:Ce?"on":"off",options:["off","on"],type:"enum",onChange(we){let Se=we==="on";fe(Se);let Ge={...ut().plugins,pluginClaudeCompat:Se};Fr.updateSetting("plugins",Ge)}},{id:"planDirectory",label:"Plan directory",value:$,placeholder:"Leave empty for default",type:"string",onChange(we){ce(we),Fr.updateSetting("planDirectory",we||void 0)}},{id:"agentDepth",label:"Agent depth",value:M,placeholder:"1-5",type:"string",onChange(we){let Se=parseInt(we,10),qe=Number.isNaN(Se)?1:Math.min(5,Math.max(1,Se)),Ge=String(qe);se(Ge),Fr.updateSetting("agentDepth",qe)}}];return er((we,Se)=>{if(Se.escape){let Ge=[],yr=!!(process.env.ANTHROPIC_API_KEY&&n.current.customApiKeyResponses?.approved?.includes(Ah(process.env.ANTHROPIC_API_KEY))),Dr=!!(process.env.ANTHROPIC_API_KEY&&t.customApiKeyResponses?.approved?.includes(Ah(process.env.ANTHROPIC_API_KEY)));yr!==Dr&&Ge.push(` \u23BF ${Dr?"Enabled":"Disabled"} custom API key`),t.verbose!==n.current.verbose&&Ge.push(` \u23BF Set verbose to ${cr.bold(t.verbose)}`),t.theme!==n.current.theme&&Ge.push(` \u23BF Set theme to ${cr.bold(t.theme)}`),t.preferredNotifChannel!==n.current.preferredNotifChannel&&Ge.push(` \u23BF Set notifications to ${cr.bold(t.preferredNotifChannel)}`),c!==f.current&&Ge.push(` \u23BF Set proxy to ${cr.bold(c?"on":"off")}`),g!==A.current&&Ge.push(` \u23BF Set lazy tool to ${cr.bold(g)}`),h!==y.current&&Ge.push(` \u23BF Set auto mode to ${cr.bold(h?"on":"off")}`),S!==w.current&&Ge.push(` \u23BF Set memo to ${cr.bold(S?"on":"off")}`),O!==G.current&&Ge.push(` \u23BF Set message archiving to ${cr.bold(O?"on":"off")}`),j!==V.current&&Ge.push(` \u23BF Set archive tool use inputs to ${cr.bold(j?"on":"off")}`),Ce!==ie.current&&Ge.push(` \u23BF Set Claude Code plugin compatibility to ${cr.bold(Ce?"on":"off")}`),$!==ee.current&&Ge.push(` \u23BF Set plan directory to ${cr.bold($||"default")}`),M!==_e.current&&Ge.push(` \u23BF Set agent depth to ${cr.bold(M)}`),Ge.length>0&&console.log(cr.gray(Ge.join(`
|
|
932
|
-
`))),e();return}function qe(){let Ge=Xe[i];if(!(!Ge||!Ge.onChange)){if(Ge.type==="boolean"){Ge.onChange(!Ge.value);return}if(Ge.type==="enum"){let Dr=(Ge.options.indexOf(Ge.value)+1)%Ge.options.length;Ge.onChange(Ge.options[Dr]);return}if(Ge.type==="string"){Ee(Ge.id),J(Ge.value);return}}}if(Se.return||we===" "){qe();return}Se.upArrow&&o(Ge=>Math.max(0,Ge-1)),Se.downArrow&&o(Ge=>Math.min(Xe.length-1,Ge+1))},{isActive:oe===null}),ci.createElement(ci.Fragment,null,ci.createElement(R,{flexDirection:"column",borderStyle:"round",borderColor:Be().secondaryBorder,paddingX:1,marginTop:1},ci.createElement(R,{flexDirection:"column",minHeight:2,marginBottom:1},ci.createElement(v,{bold:!0},"Settings"),ci.createElement(v,{dimColor:!0},"Configure ",yt," preferences")),Xe.map((we,Se)=>{let qe=Se===i;return ci.createElement(R,{key:we.id,height:2,minHeight:2},ci.createElement(R,{width:44},ci.createElement(v,{color:qe?"blue":void 0},qe?Vt.pointer:" "," ",we.label)),ci.createElement(R,null,we.type==="boolean"?ci.createElement(v,{color:qe?"blue":void 0},we.value.toString()):we.type==="string"&&oe===we.id?ci.createElement(dx,{value:Ye,onChange:J,onSubmit:Ge=>{let yr=Xe.find(Dr=>Dr.id===we.id);yr&&yr.type==="string"&&yr.onChange(Ge),Ee(null),Ne(0)},onCancel:()=>{Ee(null),J(""),Ne(0)},placeholder:we.placeholder,columns:Math.max(20,process.stdout.columns-50),cursorOffset:Y,onChangeCursorOffset:Ne}):ci.createElement(v,{color:(we.id==="webServer"||we.id==="proxy"||we.id==="autoMode"||we.id==="memo"||we.id==="messageArchiving"||we.id==="archiveToolUseInputs"||we.id==="pluginClaudeCompat")&&we.value==="on"||we.id==="lazyTool"&&we.value!=="off"?"green":qe?"blue":void 0},we.value.toString(),we.id==="webServer"&&we.value==="on"?` (${O9.getUrl()})`:"")))})),ci.createElement(R,{marginLeft:3},ci.createElement(v,{dimColor:!0},s.pending?ci.createElement(ci.Fragment,null,"Press ",s.keyName," again to exit"):oe?ci.createElement(ci.Fragment,null,"Enter to save \xB7 Esc to cancel"):ci.createElement(ci.Fragment,null,"\u2191/\u2193 to select \xB7 Enter/Space to change \xB7 Esc to close"))))}var Z_t=X(ge(),1),bun={type:"local-jsx",name:"config",description:()=>"Open config panel",isEnabled:!0,isHidden:!1,async call(e){return Z_t.createElement(J_t,{onClose:e})},userFacingName(){return"config"}},X_t=bun;var wn=X(ge(),1);function fx(e){return e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function eyt(e){let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let r=Math.floor(t/60),n=t%60;return`${r}m ${n.toFixed(0)}s`}function tyt(e){return`${e.toFixed(1)}%`}function ryt({costUSD:e,durationMs:t,apiDurationMs:r,inputTokens:n,outputTokens:i,cacheCreationTokens:o,cacheReadTokens:s,currentContextTokens:a,contextLimit:l,onDone:c}){let u=Be();er((A,h)=>{h.escape&&c()});let f=n+o+s,g=f>0?s/f*100:0,m=l>0?a/l*100:0;return wn.createElement(R,{flexDirection:"column",borderStyle:"round",paddingLeft:1,paddingRight:1,borderColor:u.secondaryBorder},wn.createElement(R,{marginBottom:1,flexDirection:"column"},wn.createElement(v,{bold:!0},"Session Cost & Usage")),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,null,wn.createElement(v,{dimColor:!0},"Cost: "),wn.createElement(v,null,"$",e.toFixed(4)))),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,{dimColor:!0},"Session Tokens"),wn.createElement(R,{marginLeft:2,flexDirection:"column"},wn.createElement(v,null,wn.createElement(v,null,"Input: "),wn.createElement(v,{bold:!0},fx(f)),wn.createElement(v,{dimColor:!0}," (uncached: ",fx(n),")")),wn.createElement(v,null,wn.createElement(v,null,"Output: "),wn.createElement(v,{bold:!0},fx(i))))),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,null,wn.createElement(v,{dimColor:!0},"Context Window: "),wn.createElement(v,{bold:!0},tyt(m)),wn.createElement(v,{dimColor:!0}," (",fx(a)," / ",fx(l)," tokens)"))),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,null,wn.createElement(v,{dimColor:!0},"Cache Hit Rate: "),wn.createElement(v,{bold:!0},tyt(g)),wn.createElement(v,{dimColor:!0}," ","(read: ",fx(s),", creation:"," ",fx(o),")"))),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,{dimColor:!0},"Duration"),wn.createElement(R,{marginLeft:2,flexDirection:"column"},wn.createElement(v,null,wn.createElement(v,null,"API: "),wn.createElement(v,{bold:!0},eyt(r))),wn.createElement(v,null,wn.createElement(v,null,"Wall: "),wn.createElement(v,{bold:!0},eyt(t))))),wn.createElement(R,{marginTop:1},wn.createElement(v,{dimColor:!0},"Esc to close")))}var uyt=X(ge(),1);await Qve();_h();ke();ar();Pi();Nf();gT();Wt();He();ke();ar();import{existsSync as iyt,mkdirSync as xun,readFileSync as wun,writeFileSync as Dun}from"fs";import{dirname as Run,join as Nun}from"path";import{homedir as Bun}from"os";var wm="__tool_result__";function Oun(){return nt.isArchiveToolUseInputsEnable()}var kun=new Set(["Cwd",sN,wg,Q0,vu,lN,ic,oc,mT,Bz,Oz,oN,zb,iAe,oAe]);function Mun(e){return e.replace(/[^a-zA-Z0-9]/g,"-")}function Qun(e,t=process.cwd()){return Nun(Bun(),Xr,"projects",Mun(t),"archive",`${e}.json`)}function Pun(e){iyt(e)||xun(e,{recursive:!0})}function Lun(e){if(!iyt(e))return new Map;try{let t=wun(e,"utf8");if(!t.trim())return new Map;let r=JSON.parse(t);if(typeof r!="object"||r===null||Array.isArray(r))return new Map;let n=new Map;for(let[i,o]of Object.entries(r))if(Array.isArray(o)){let s=o.filter(a=>typeof a=="string");s.length>0&&n.set(i,new Set(s))}return n}catch(t){return ve(`Failed to read archived tool use input fields from ${e}:`,t),new Map}}function Fun(e,t){Pun(Run(e));try{let r={};for(let[n,i]of t)i.size>0&&(r[n]=[...i]);Dun(e,JSON.stringify(r,null,2),"utf8")}catch(r){throw ve(`Failed to write archived tool use input fields to ${e}:`,r),r}}function Uun(e){return`<system>This tool result has been archived. You can use the Message Archiving Tool to unarchive it if needed (tool_use_id: ${e}).</system>`}function Hun(e,t){return`<system>This tool input field has been archived. You can use the Message Archiving Tool to unarchive it if needed (tool_use_id: ${e}, field: ${t}).</system>`}function $un(e){let t=e.content;return typeof t=="string"?t.length:Array.isArray(t)?t.reduce((r,n)=>typeof n=="string"?r+n.length:typeof n=="object"&&n!==null&&"text"in n&&typeof n.text=="string"?r+n.text.length:r,0):0}function oyt(e){return $un(e)<=100}function qun(e){return{type:"text",text:`[tool_use_id: ${e}]`}}function Pve(e){return typeof e=="string"?e.length:typeof e!="object"||e===null?0:Array.isArray(e)?e.reduce((t,r)=>Math.max(t,Pve(r)),0):Object.values(e).reduce((t,r)=>Math.max(t,Pve(r)),0)}function Lve(e){return Pve(e)<=100}function Uve(e){let t=new Map;for(let r of e){if(r.type!=="assistant")continue;let n=r.message.content;if(Array.isArray(n))for(let i of n)$ve(i)&&t.set(i.id,i.input)}return t}function Gun(e){let t=new Map;for(let r of e){if(r.type!=="assistant")continue;let n=r.message.content;if(Array.isArray(n)){for(let i of n)if(typeof i=="object"&&i!==null&&"type"in i&&i.type==="tool_use"&&"id"in i&&typeof i.id=="string"&&"name"in i&&typeof i.name=="string"){let o=i;t.set(o.id,o.name)}}}return t}function Hve(e){return kun.has(e)}function zun(e,t){let r=t.get(e.tool_use_id);return r?Hve(r):!1}function syt(e,t){let r,n;for(let s of t){if(s.type!=="assistant")continue;let a=s.message.content;if(Array.isArray(a)){for(let l of a)if($ve(l)&&l.id===e){r=l.input,n=l.name;break}if(n!==void 0)break}}if(!n)return{archivable:!1,reason:`no matching tool_use block found for tool_use_id ${e} in the conversation history`};if(Hve(n))return{archivable:!1,reason:`tool_use_id ${e} uses tool "${n}" which is blacklisted from archiving`};let i=!1,o=!1;for(let s of t){if(s.type!=="user")continue;let a=s.message.content;if(Array.isArray(a))for(let l of a)ayt(l)&&l.tool_use_id===e&&(i=!0,oyt(l)||(o=!0))}return i?o||!Lve(r)?{archivable:!0}:{archivable:!1,reason:`tool result and tool_use input for tool_use_id ${e} are both 100 characters or shorter`}:Lve(r)?{archivable:!1,reason:`tool_use input for tool_use_id ${e} is 100 characters or shorter`}:{archivable:!0}}function jun(e,t,r,n){let i=e.tool_use_id;if(zun(e,r))return e;let o=n.get(i);if(oyt(e)&&Lve(o))return e;if(t.get(i)?.has(wm)??!1)return{...e,content:[{type:"text",text:Uun(i)}]};let l;typeof e.content=="string"?l=[{type:"text",text:e.content}]:l=[...e.content];let c=Array.isArray(l)?l:[{type:"text",text:l}];return c.push(qun(i)),{...e,content:c}}function ayt(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_result"&&"tool_use_id"in e&&typeof e.tool_use_id=="string"}function $ve(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_use"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string"}function Yun(e,t,r,n){let i=e.message.content;if(!Array.isArray(i))return e;let o=i.map(s=>ayt(s)?jun(s,t,r,n):s);return{...e,message:{...e.message,content:o}}}function Vun(e,t,r){if(!Oun())return e;let n=e.message.content;if(!Array.isArray(n))return e;let i=!1,o=n.map(s=>{if(!$ve(s))return s;let a=s.id,l=r.get(a)??s.name;if(Hve(l))return s;let c=t.get(a);if(!c)return s;let u=[...c].filter(g=>g!==wm);if(u.length===0||typeof s.input!="object"||s.input===null)return s;let f=B0(s.input);for(let g of u)Zge(f,g)?tAe(f,g,Hun(a,g)):ve(`Archived input field path does not exist: ${g} for tool_use_id ${a}`);return i=!0,{...s,input:f}});return i?{...e,message:{...e.message,content:o}}:e}var Fve=class e{static instance;archivedToolUseInputFields=new Map;currentSessionId=null;currentArchiveFilePath=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadSession(t,r){if(!nt.isMessageArchivingEnable()){this.archivedToolUseInputFields.clear(),this.currentSessionId=t,this.currentArchiveFilePath=null;return}this.currentSessionId=t,this.currentArchiveFilePath=Qun(t,r),this.archivedToolUseInputFields=Lun(this.currentArchiveFilePath)}archive(t){if(nt.isMessageArchivingEnable()){for(let[r,n]of Object.entries(t)){this.archivedToolUseInputFields.has(r)||this.archivedToolUseInputFields.set(r,new Set);let i=this.archivedToolUseInputFields.get(r);for(let o of n)i.add(o)}this.persist()}}unarchive(t){if(nt.isMessageArchivingEnable()){for(let[r,n]of Object.entries(t)){let i=this.archivedToolUseInputFields.get(r);if(i){for(let o of n)i.delete(o);i.size===0&&this.archivedToolUseInputFields.delete(r)}}this.persist()}}isArchived(t){return this.archivedToolUseInputFields.get(t)?.has(wm)??!1}getArchivedIds(){let t=new Set;for(let[r,n]of this.archivedToolUseInputFields)n.has(wm)&&t.add(r);return t}getArchivedToolUseInputFields(t){return new Set(this.archivedToolUseInputFields.get(t)??[])}applyToMessages(t){if(!nt.isMessageArchivingEnable())return t;let r=Gun(t),n=Uve(t);return t.map(i=>i.type==="user"?Yun(i,this.archivedToolUseInputFields,r,n):i.type==="assistant"?Vun(i,this.archivedToolUseInputFields,r):i)}getCurrentArchiveFilePath(){return this.currentArchiveFilePath}persist(){this.currentArchiveFilePath&&Fun(this.currentArchiveFilePath,this.archivedToolUseInputFields)}},bS=Fve.getInstance();He();async function lyt(){let e=ut();if(!(!e.hooks?.SessionStart||e.hooks.SessionStart.length===0))try{let t=new Wg(e.hooks),r={session_id:Date.now().toString(),transcript_path:"",cwd:Os(),permission_mode:"default",hook_event_name:"SessionStart",source:"compact",model:process.env.ANTHROPIC_MODEL||"default"},n=await t.execute(r),i=[...n.additionalContext];n.asyncAdditionalContext&&n.getAsyncAdditionalContext().then(o=>{if(o.length>0){let s=Ze.getSessionContext(),l=[...s.getData("sessionStartAdditionalContexts")||[],...o];s.setData("sessionStartAdditionalContexts",l)}}).catch(o=>{K("SessionStart async hook execution error:",o)}),i.length>0&&Ze.getSessionContext().setData("sessionStartAdditionalContexts",i)}catch(t){K("SessionStart hook execution error in auto-compact:",t)}}var Wun={"claude-3-7-sonnet-20250219":2e5,"claude-3-5-sonnet-20241022":2e5,"claude-3-5-haiku-20241022":2e5,"claude-3-haiku-20240307":2e5,"us.anthropic.claude-3-7-sonnet-20250219-v1:0":2e5,"us.anthropic.claude-3-5-haiku-20241022-v1:0":2e5,"claude-3-7-sonnet@20250219":2e5,"claude-3-5-haiku@20241022":2e5,"kimi-k2.5":15e4,"kimi-k2.6":15e4,"k2.5":15e4,"k2.6":15e4};function Kun(e){return Wun[e.toLowerCase()]||2e5}function hO(){let e=Fn.getModelRoutingModels();if(e.length===0)throw new Error("No MODEL routing configuration found");let t=e.map(Kun);return Math.min(...t)}var Jun=`Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
|
|
932
|
+
`))),e();return}function qe(){let Ge=Xe[i];if(!(!Ge||!Ge.onChange)){if(Ge.type==="boolean"){Ge.onChange(!Ge.value);return}if(Ge.type==="enum"){let Dr=(Ge.options.indexOf(Ge.value)+1)%Ge.options.length;Ge.onChange(Ge.options[Dr]);return}if(Ge.type==="string"){Ee(Ge.id),J(Ge.value);return}}}if(Se.return||we===" "){qe();return}Se.upArrow&&o(Ge=>Math.max(0,Ge-1)),Se.downArrow&&o(Ge=>Math.min(Xe.length-1,Ge+1))},{isActive:oe===null}),ci.createElement(ci.Fragment,null,ci.createElement(R,{flexDirection:"column",borderStyle:"round",borderColor:Be().secondaryBorder,paddingX:1,marginTop:1},ci.createElement(R,{flexDirection:"column",minHeight:2,marginBottom:1},ci.createElement(v,{bold:!0},"Settings"),ci.createElement(v,{dimColor:!0},"Configure ",yt," preferences")),Xe.map((we,Se)=>{let qe=Se===i;return ci.createElement(R,{key:we.id,height:2,minHeight:2},ci.createElement(R,{width:44},ci.createElement(v,{color:qe?"blue":void 0},qe?Vt.pointer:" "," ",we.label)),ci.createElement(R,null,we.type==="boolean"?ci.createElement(v,{color:qe?"blue":void 0},we.value.toString()):we.type==="string"&&oe===we.id?ci.createElement(dx,{value:Ye,onChange:J,onSubmit:Ge=>{let yr=Xe.find(Dr=>Dr.id===we.id);yr&&yr.type==="string"&&yr.onChange(Ge),Ee(null),Ne(0)},onCancel:()=>{Ee(null),J(""),Ne(0)},placeholder:we.placeholder,columns:Math.max(20,process.stdout.columns-50),cursorOffset:Y,onChangeCursorOffset:Ne}):ci.createElement(v,{color:(we.id==="webServer"||we.id==="proxy"||we.id==="autoMode"||we.id==="memo"||we.id==="messageArchiving"||we.id==="archiveToolUseInputs"||we.id==="pluginClaudeCompat")&&we.value==="on"||we.id==="lazyTool"&&we.value!=="off"?"green":qe?"blue":void 0},we.id==="lazyTool"&&we.value==="loading"?"load":we.value.toString(),we.id==="webServer"&&we.value==="on"?` (${O9.getUrl()})`:"")))})),ci.createElement(R,{marginLeft:3},ci.createElement(v,{dimColor:!0},s.pending?ci.createElement(ci.Fragment,null,"Press ",s.keyName," again to exit"):oe?ci.createElement(ci.Fragment,null,"Enter to save \xB7 Esc to cancel"):ci.createElement(ci.Fragment,null,"\u2191/\u2193 to select \xB7 Enter/Space to change \xB7 Esc to close"))))}var Z_t=X(ge(),1),bun={type:"local-jsx",name:"config",description:()=>"Open config panel",isEnabled:!0,isHidden:!1,async call(e){return Z_t.createElement(J_t,{onClose:e})},userFacingName(){return"config"}},X_t=bun;var wn=X(ge(),1);function fx(e){return e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function eyt(e){let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let r=Math.floor(t/60),n=t%60;return`${r}m ${n.toFixed(0)}s`}function tyt(e){return`${e.toFixed(1)}%`}function ryt({costUSD:e,durationMs:t,apiDurationMs:r,inputTokens:n,outputTokens:i,cacheCreationTokens:o,cacheReadTokens:s,currentContextTokens:a,contextLimit:l,onDone:c}){let u=Be();er((A,h)=>{h.escape&&c()});let f=n+o+s,g=f>0?s/f*100:0,m=l>0?a/l*100:0;return wn.createElement(R,{flexDirection:"column",borderStyle:"round",paddingLeft:1,paddingRight:1,borderColor:u.secondaryBorder},wn.createElement(R,{marginBottom:1,flexDirection:"column"},wn.createElement(v,{bold:!0},"Session Cost & Usage")),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,null,wn.createElement(v,{dimColor:!0},"Cost: "),wn.createElement(v,null,"$",e.toFixed(4)))),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,{dimColor:!0},"Session Tokens"),wn.createElement(R,{marginLeft:2,flexDirection:"column"},wn.createElement(v,null,wn.createElement(v,null,"Input: "),wn.createElement(v,{bold:!0},fx(f)),wn.createElement(v,{dimColor:!0}," (uncached: ",fx(n),")")),wn.createElement(v,null,wn.createElement(v,null,"Output: "),wn.createElement(v,{bold:!0},fx(i))))),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,null,wn.createElement(v,{dimColor:!0},"Context Window: "),wn.createElement(v,{bold:!0},tyt(m)),wn.createElement(v,{dimColor:!0}," (",fx(a)," / ",fx(l)," tokens)"))),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,null,wn.createElement(v,{dimColor:!0},"Cache Hit Rate: "),wn.createElement(v,{bold:!0},tyt(g)),wn.createElement(v,{dimColor:!0}," ","(read: ",fx(s),", creation:"," ",fx(o),")"))),wn.createElement(R,{flexDirection:"column",marginBottom:1},wn.createElement(v,{dimColor:!0},"Duration"),wn.createElement(R,{marginLeft:2,flexDirection:"column"},wn.createElement(v,null,wn.createElement(v,null,"API: "),wn.createElement(v,{bold:!0},eyt(r))),wn.createElement(v,null,wn.createElement(v,null,"Wall: "),wn.createElement(v,{bold:!0},eyt(t))))),wn.createElement(R,{marginTop:1},wn.createElement(v,{dimColor:!0},"Esc to close")))}var uyt=X(ge(),1);await Qve();_h();ke();ar();Pi();Nf();gT();Wt();He();ke();ar();import{existsSync as iyt,mkdirSync as xun,readFileSync as wun,writeFileSync as Dun}from"fs";import{dirname as Run,join as Nun}from"path";import{homedir as Bun}from"os";var wm="__tool_result__";function Oun(){return nt.isArchiveToolUseInputsEnable()}var kun=new Set(["Cwd",sN,wg,Q0,vu,lN,ic,oc,mT,Bz,Oz,oN,zb,iAe,oAe]);function Mun(e){return e.replace(/[^a-zA-Z0-9]/g,"-")}function Qun(e,t=process.cwd()){return Nun(Bun(),Xr,"projects",Mun(t),"archive",`${e}.json`)}function Pun(e){iyt(e)||xun(e,{recursive:!0})}function Lun(e){if(!iyt(e))return new Map;try{let t=wun(e,"utf8");if(!t.trim())return new Map;let r=JSON.parse(t);if(typeof r!="object"||r===null||Array.isArray(r))return new Map;let n=new Map;for(let[i,o]of Object.entries(r))if(Array.isArray(o)){let s=o.filter(a=>typeof a=="string");s.length>0&&n.set(i,new Set(s))}return n}catch(t){return ve(`Failed to read archived tool use input fields from ${e}:`,t),new Map}}function Fun(e,t){Pun(Run(e));try{let r={};for(let[n,i]of t)i.size>0&&(r[n]=[...i]);Dun(e,JSON.stringify(r,null,2),"utf8")}catch(r){throw ve(`Failed to write archived tool use input fields to ${e}:`,r),r}}function Uun(e){return`<system>This tool result has been archived. You can use the Message Archiving Tool to unarchive it if needed (tool_use_id: ${e}).</system>`}function Hun(e,t){return`<system>This tool input field has been archived. You can use the Message Archiving Tool to unarchive it if needed (tool_use_id: ${e}, field: ${t}).</system>`}function $un(e){let t=e.content;return typeof t=="string"?t.length:Array.isArray(t)?t.reduce((r,n)=>typeof n=="string"?r+n.length:typeof n=="object"&&n!==null&&"text"in n&&typeof n.text=="string"?r+n.text.length:r,0):0}function oyt(e){return $un(e)<=100}function qun(e){return{type:"text",text:`[tool_use_id: ${e}]`}}function Pve(e){return typeof e=="string"?e.length:typeof e!="object"||e===null?0:Array.isArray(e)?e.reduce((t,r)=>Math.max(t,Pve(r)),0):Object.values(e).reduce((t,r)=>Math.max(t,Pve(r)),0)}function Lve(e){return Pve(e)<=100}function Uve(e){let t=new Map;for(let r of e){if(r.type!=="assistant")continue;let n=r.message.content;if(Array.isArray(n))for(let i of n)$ve(i)&&t.set(i.id,i.input)}return t}function Gun(e){let t=new Map;for(let r of e){if(r.type!=="assistant")continue;let n=r.message.content;if(Array.isArray(n)){for(let i of n)if(typeof i=="object"&&i!==null&&"type"in i&&i.type==="tool_use"&&"id"in i&&typeof i.id=="string"&&"name"in i&&typeof i.name=="string"){let o=i;t.set(o.id,o.name)}}}return t}function Hve(e){return kun.has(e)}function zun(e,t){let r=t.get(e.tool_use_id);return r?Hve(r):!1}function syt(e,t){let r,n;for(let s of t){if(s.type!=="assistant")continue;let a=s.message.content;if(Array.isArray(a)){for(let l of a)if($ve(l)&&l.id===e){r=l.input,n=l.name;break}if(n!==void 0)break}}if(!n)return{archivable:!1,reason:`no matching tool_use block found for tool_use_id ${e} in the conversation history`};if(Hve(n))return{archivable:!1,reason:`tool_use_id ${e} uses tool "${n}" which is blacklisted from archiving`};let i=!1,o=!1;for(let s of t){if(s.type!=="user")continue;let a=s.message.content;if(Array.isArray(a))for(let l of a)ayt(l)&&l.tool_use_id===e&&(i=!0,oyt(l)||(o=!0))}return i?o||!Lve(r)?{archivable:!0}:{archivable:!1,reason:`tool result and tool_use input for tool_use_id ${e} are both 100 characters or shorter`}:Lve(r)?{archivable:!1,reason:`tool_use input for tool_use_id ${e} is 100 characters or shorter`}:{archivable:!0}}function jun(e,t,r,n){let i=e.tool_use_id;if(zun(e,r))return e;let o=n.get(i);if(oyt(e)&&Lve(o))return e;if(t.get(i)?.has(wm)??!1)return{...e,content:[{type:"text",text:Uun(i)}]};let l;typeof e.content=="string"?l=[{type:"text",text:e.content}]:l=[...e.content];let c=Array.isArray(l)?l:[{type:"text",text:l}];return c.push(qun(i)),{...e,content:c}}function ayt(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_result"&&"tool_use_id"in e&&typeof e.tool_use_id=="string"}function $ve(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_use"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string"}function Yun(e,t,r,n){let i=e.message.content;if(!Array.isArray(i))return e;let o=i.map(s=>ayt(s)?jun(s,t,r,n):s);return{...e,message:{...e.message,content:o}}}function Vun(e,t,r){if(!Oun())return e;let n=e.message.content;if(!Array.isArray(n))return e;let i=!1,o=n.map(s=>{if(!$ve(s))return s;let a=s.id,l=r.get(a)??s.name;if(Hve(l))return s;let c=t.get(a);if(!c)return s;let u=[...c].filter(g=>g!==wm);if(u.length===0||typeof s.input!="object"||s.input===null)return s;let f=B0(s.input);for(let g of u)Zge(f,g)?tAe(f,g,Hun(a,g)):ve(`Archived input field path does not exist: ${g} for tool_use_id ${a}`);return i=!0,{...s,input:f}});return i?{...e,message:{...e.message,content:o}}:e}var Fve=class e{static instance;archivedToolUseInputFields=new Map;currentSessionId=null;currentArchiveFilePath=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadSession(t,r){if(!nt.isMessageArchivingEnable()){this.archivedToolUseInputFields.clear(),this.currentSessionId=t,this.currentArchiveFilePath=null;return}this.currentSessionId=t,this.currentArchiveFilePath=Qun(t,r),this.archivedToolUseInputFields=Lun(this.currentArchiveFilePath)}archive(t){if(nt.isMessageArchivingEnable()){for(let[r,n]of Object.entries(t)){this.archivedToolUseInputFields.has(r)||this.archivedToolUseInputFields.set(r,new Set);let i=this.archivedToolUseInputFields.get(r);for(let o of n)i.add(o)}this.persist()}}unarchive(t){if(nt.isMessageArchivingEnable()){for(let[r,n]of Object.entries(t)){let i=this.archivedToolUseInputFields.get(r);if(i){for(let o of n)i.delete(o);i.size===0&&this.archivedToolUseInputFields.delete(r)}}this.persist()}}isArchived(t){return this.archivedToolUseInputFields.get(t)?.has(wm)??!1}getArchivedIds(){let t=new Set;for(let[r,n]of this.archivedToolUseInputFields)n.has(wm)&&t.add(r);return t}getArchivedToolUseInputFields(t){return new Set(this.archivedToolUseInputFields.get(t)??[])}applyToMessages(t){if(!nt.isMessageArchivingEnable())return t;let r=Gun(t),n=Uve(t);return t.map(i=>i.type==="user"?Yun(i,this.archivedToolUseInputFields,r,n):i.type==="assistant"?Vun(i,this.archivedToolUseInputFields,r):i)}getCurrentArchiveFilePath(){return this.currentArchiveFilePath}persist(){this.currentArchiveFilePath&&Fun(this.currentArchiveFilePath,this.archivedToolUseInputFields)}},bS=Fve.getInstance();He();async function lyt(){let e=ut();if(!(!e.hooks?.SessionStart||e.hooks.SessionStart.length===0))try{let t=new Wg(e.hooks),r={session_id:Date.now().toString(),transcript_path:"",cwd:Os(),permission_mode:"default",hook_event_name:"SessionStart",source:"compact",model:process.env.ANTHROPIC_MODEL||"default"},n=await t.execute(r),i=[...n.additionalContext];n.asyncAdditionalContext&&n.getAsyncAdditionalContext().then(o=>{if(o.length>0){let s=Ze.getSessionContext(),l=[...s.getData("sessionStartAdditionalContexts")||[],...o];s.setData("sessionStartAdditionalContexts",l)}}).catch(o=>{K("SessionStart async hook execution error:",o)}),i.length>0&&Ze.getSessionContext().setData("sessionStartAdditionalContexts",i)}catch(t){K("SessionStart hook execution error in auto-compact:",t)}}var Wun={"claude-3-7-sonnet-20250219":2e5,"claude-3-5-sonnet-20241022":2e5,"claude-3-5-haiku-20241022":2e5,"claude-3-haiku-20240307":2e5,"us.anthropic.claude-3-7-sonnet-20250219-v1:0":2e5,"us.anthropic.claude-3-5-haiku-20241022-v1:0":2e5,"claude-3-7-sonnet@20250219":2e5,"claude-3-5-haiku@20241022":2e5,"kimi-k2.5":15e4,"kimi-k2.6":15e4,"k2.5":15e4,"k2.6":15e4};function Kun(e){return Wun[e.toLowerCase()]||2e5}function hO(){let e=Fn.getModelRoutingModels();if(e.length===0)throw new Error("No MODEL routing configuration found");let t=e.map(Kun);return Math.min(...t)}var Jun=`Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
|
|
933
933
|
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
|
|
934
934
|
|
|
935
935
|
Before providing your final summary, wrap your analysis in <analysis> tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
|
|
@@ -1131,7 +1131,7 @@ You are powered by the model ${e}.`}async function Ax(){return s9()?`gitStatus:
|
|
|
1131
1131
|
<context name="${c}">${u}</context>`;let s=i.map(c=>{let u=c.prompt({},t),f=JSON.stringify("inputJSONSchema"in c&&c.inputJSONSchema?c.inputJSONSchema:f0(c.inputSchema));return{name:c.name,description:`${u}
|
|
1132
1132
|
|
|
1133
1133
|
Schema:
|
|
1134
|
-
${f}`}}),{messages:a}=t,l=$dn(o);return qdn(o,l,s,a)}},bbt=Gdn;Yg();var $u=X(ge(),1),IO=X(ge(),1);ke();ke();import{existsSync as zdn,readdirSync as jdn,statSync as Ydn}from"fs";import{join as Vdn}from"path";function Wdn(){let e=Zi.plan();if(!zdn(e))return[];try{return jdn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=Vdn(e,r),i=Ydn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var Cbt=({onSelect:e})=>{let[t,r]=(0,IO.useState)([]),[n,i]=(0,IO.useState)(0),[o,s]=(0,IO.useState)(!1);(0,IO.useEffect)(()=>{let c=Wdn();r(c),s(!0)},[]);let a=[{label:"New plan",value:"__NEW_PLAN__",isNew:!0},...t.map(c=>({label:c.name,value:c.path,isNew:!1,modified:c.modified}))];er((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Be();return o?$u.createElement(R,{flexDirection:"column",marginY:1},$u.createElement(R,{marginBottom:1},$u.createElement(v,{bold:!0,color:l.claude},"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),$u.createElement(R,{marginBottom:1},$u.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return $u.createElement(R,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},$u.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),$u.createElement(v,{color:f?l.claude:l.text}," "),$u.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&$u.createElement(v,{dimColor:!0}," ","(",uAe(c.modified),")"))}),$u.createElement(R,{marginTop:1,marginLeft:2},$u.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):$u.createElement(R,{flexDirection:"column",marginY:1},$u.createElement(v,null,"Loading plan history..."))};var Sbt=X(ge(),1),Kdn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return vi.isPlanMode()?(e("Already in plan mode."),null):Sbt.createElement(Cbt,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?vi.setCurrentPlanFilePath(t):vi.generatePlanFilePath(),vi.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},Ibt=Kdn;Yg();var Jdn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return vi.isAutoMode()?"Already in auto mode.":(vi.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},Tbt=Jdn;Er();import{resolve as Zdn}from"path";var Xdn={type:"local",name:"cd",description:()=>"Move this session to a new working directory",isEnabled:!0,isHidden:!1,argNames:["path"],async call(e){let t=e.trim();if(t==="")throw new Error("Missing directory path. Usage: /cd <path>");let r=Oe(),n=Zdn(r,t);fa(n);let i=Oe();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},vbt=Xdn;var n1t=X(ge(),1);var $n=X(ge(),1);var Nfn=X(ge(),1);var q9=X(ge(),1),wfn=X(Rbt(),1);var Nbt={info:"blue",success:"green",error:"red",warning:"yellow"},pfn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:Nbt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Nbt[e]}),content:()=>({flexShrink:1,flexGrow:1,minWidth:0,flexDirection:"column",gap:1}),title:()=>({bold:!0}),message:()=>({})},config({variant:e}){let t;return e==="info"&&(t=Vt.info),e==="success"&&(t=Vt.tick),e==="error"&&(t=Vt.cross),e==="warning"&&(t=Vt.warning),{icon:t}}},Bbt=pfn;var mfn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},Obt=mfn;var gfn={styles:{input:({isFocused:e})=>({dimColor:!e})}},kbt=gfn;var Afn={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},Mbt=Afn;var hfn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},Qbt=hfn;var Efn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Vt.square,remainingCharacter:Vt.squareLightShade})},Pbt=Efn;var _fn={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},Lbt=_fn;var yfn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},Fbt=yfn;var bfn={success:"green",error:"red",warning:"yellow",info:"blue"},Cfn={success:Vt.tick,error:Vt.cross,warning:Vt.warning,info:Vt.info},Sfn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:bfn[e]}),message:()=>({})},config:({variant:e})=>({icon:Cfn[e]})},Ubt=Sfn;var Ifn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Vt.line})},Hbt=Ifn;var Tfn={styles:{value:()=>({})}},$bt=Tfn;var vfn={styles:{value:()=>({})}},qbt=vfn;var xfn={styles:{value:()=>({})}},Gbt=xfn;var Dfn={components:{Alert:Bbt,Badge:Obt,ConfirmInput:kbt,MultiSelect:Mbt,OrderedList:Qbt,ProgressBar:Pbt,Select:Lbt,Spinner:Fbt,StatusMessage:Ubt,UnorderedList:Hbt,TextInput:$bt,EmailInput:qbt,PasswordInput:Gbt}},Rfn=(0,q9.createContext)(Dfn);var mo=e=>(0,q9.useContext)(Rfn).components[e];var Bfn=X(ge(),1);var Q_=X(ge(),1);var vO=X(ge(),1);var zbt=X(ge(),1);var G9=Vt.line;var Cee=(0,zbt.createContext)({marker:G9});function jbt({children:e}){let{marker:t}=(0,vO.useContext)(Cee),{styles:r}=mo("UnorderedList");return vO.default.createElement(R,{...r.listItem()},vO.default.createElement(v,{...r.marker()},t),vO.default.createElement(R,{...r.content()},e))}var Ybt=X(ge(),1),ixe=(0,Ybt.createContext)({depth:0});function Ofn({children:e}){let{depth:t}=(0,Q_.useContext)(ixe),{styles:r,config:n}=mo("UnorderedList"),i=(0,Q_.useMemo)(()=>({depth:t+1}),[t]),o=(0,Q_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??G9}:{marker:G9}},[n,t]);return Q_.default.createElement(ixe.Provider,{value:i},Q_.default.createElement(Cee.Provider,{value:o},Q_.default.createElement(R,{...r.list()},e)))}Ofn.Item=jbt;var Mfn=X(ge(),1);var kfn=X(ge(),1);var z9=X(ge(),1);var xO=class extends Map{first;constructor(t){let r=[],n,i,o=0;for(let s of t){let a={...s,previous:i,next:void 0,index:o};i&&(i.next=a),n||=a,r.push([s.value,a]),o++,i=a}super(r),this.first=n}};var Vbt=X(ge(),1);var wO=X(ge(),1);var j9=X(ge(),1);function Wbt({isFocused:e,isSelected:t,children:r}){let{styles:n}=mo("Select");return j9.default.createElement(R,{...n.option({isFocused:e})},e&&j9.default.createElement(v,{...n.focusIndicator()},Vt.pointer),j9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&j9.default.createElement(v,{...n.selectedIndicator()},Vt.tick))}var Dm=X(ge(),1);import{isDeepStrictEqual as Qfn}from"node:util";var Pfn=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let o=Math.min(e.optionMap.size,e.visibleToIndex+1),s=o-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:o}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let o=Math.max(0,e.visibleFromIndex-1),s=o+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:o,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state}},Kbt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new xO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},Jbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Dm.useReducer)(Pfn,{visibleOptionCount:e,defaultValue:r,options:t},Kbt),[s,a]=(0,Dm.useState)(t);t!==s&&!Qfn(t,s)&&(o({type:"reset",state:Kbt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Dm.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Dm.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Dm.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,Dm.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Dm.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Zbt=({isDisabled:e=!1,state:t})=>{er((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function DO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=Jbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Zbt({isDisabled:e,state:s});let{styles:a}=mo("Select");return wO.default.createElement(R,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=wO.default.createElement(wO.default.Fragment,null,l.label.slice(0,u),wO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return wO.default.createElement(Wbt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Lfn=X(ge(),1);var Xbt=X(ge(),1);var Ufn=X(ge(),1);var See=X(ge(),1);var Ffn=X(ge(),1);var bMi=cr.inverse(" ");var Zg=X(ge(),1);var RO=X(ge(),1);var eCt=X(ge(),1);var Iee=(0,eCt.createContext)({marker:Vt.line});function Tee({children:e}){let{marker:t}=(0,RO.useContext)(Iee),{styles:r}=mo("OrderedList");return RO.default.createElement(R,{...r.listItem()},RO.default.createElement(v,{...r.marker()},t),RO.default.createElement(R,{...r.content()},e))}var tCt=X(ge(),1),oxe=(0,tCt.createContext)({marker:""});function Xg({children:e}){let{marker:t}=(0,Zg.useContext)(oxe),{styles:r}=mo("OrderedList"),n=0;for(let o of Zg.default.Children.toArray(e))!(0,Zg.isValidElement)(o)||o.type!==Tee||n++;let i=String(n).length;return Zg.default.createElement(R,{...r.list()},Zg.default.Children.map(e,(o,s)=>{if(!(0,Zg.isValidElement)(o)||o.type!==Tee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Zg.default.createElement(oxe.Provider,{value:{marker:l}},Zg.default.createElement(Iee.Provider,{value:{marker:l}},o))}))}Xg.Item=Tee;var $fn=X(ge(),1);var sxe=X(ge(),1);var Hfn=X(ge(),1);var KMi=cr.inverse(" ");var qfn=X(ge(),1);var Gfn=X(ge(),1);var jfn=X(ge(),1);var vee=X(ge(),1);var zfn=X(ge(),1);var yQi=cr.inverse(" ");var qi=X(ge(),1);var axe=X(ge(),1),lxe=X(ge(),1);l9();fs();Pi();ix();ar();var rCt=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"];function eA(){let e=[...rCt,...[...rCt].reverse()],{frame:t}=BR({interval:120});return axe.createElement(R,{flexWrap:"nowrap",height:1,width:2},axe.createElement(v,{color:Be().claude},e[t%e.length]))}var Dee=X(ge(),1);var wee=null,P_=null,xee=new Set;function uxe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=Zpe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function cxe(){P_&&(wee=uxe(P_),xee.forEach(e=>e(wee)))}function Yfn(e,t){return P_!==e&&(P_&&P_.off("resize",cxe),P_=e,wee=uxe(e),e.on("resize",cxe)),xee.add(t),()=>{xee.delete(t),xee.size===0&&P_&&(P_.off("resize",cxe),P_=null,wee=null)}}function dxe(){let{stdout:e}=Ob(),[t,r]=(0,Dee.useState)(()=>uxe(e));return(0,Dee.useEffect)(()=>Yfn(e,r),[e]),t}function NO(){return dxe()}He();Of();ke();mh();ke();var cLi=X(Bxe(),1);import{homedir as t4}from"os";import{join as kO}from"path";import{existsSync as r4,mkdirSync as zSt,appendFileSync as GSt,readFileSync as jSt,constants as Ggn,writeFileSync as zgn,unlinkSync as YSt,statSync as jgn}from"fs";import{platform as VSt}from"process";import{accessSync as Ygn}from"fs";var qgn="2.4.31",e4={VERSION:qgn,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"};He();var Ex=kO(W0,".update.lock"),Vgn=300*1e3;function WSt(){try{if(r4(W0)||zSt(W0,{recursive:!0}),r4(Ex)){let e=jgn(Ex);if(Date.now()-e.mtimeMs<Vgn)return!1;try{YSt(Ex)}catch(r){return ve(`Failed to remove stale lock file: ${r}`),!1}}return zgn(Ex,`${process.pid}`,"utf8"),!0}catch(e){return ve(`Failed to acquire lock: ${e}`),!1}}function KSt(){try{r4(Ex)&&jSt(Ex,"utf8")===`${process.pid}`&&YSt(Ex)}catch(e){ve(`Failed to release lock: ${e}`)}}async function Oxe(){try{let e=await ai("npm -g config get prefix");if(e.code!==0)return ve("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{Ygn(t,Ggn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(ve("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return ve(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function JSt(e){if(!WSt())throw Et("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:e4.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{r4(e)||zSt(e,{recursive:!0});let t=await ai(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
|
|
1134
|
+
${f}`}}),{messages:a}=t,l=$dn(o);return qdn(o,l,s,a)}},bbt=Gdn;Yg();var $u=X(ge(),1),IO=X(ge(),1);ke();ke();import{existsSync as zdn,readdirSync as jdn,statSync as Ydn}from"fs";import{join as Vdn}from"path";function Wdn(){let e=Zi.plan();if(!zdn(e))return[];try{return jdn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=Vdn(e,r),i=Ydn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var Cbt=({onSelect:e})=>{let[t,r]=(0,IO.useState)([]),[n,i]=(0,IO.useState)(0),[o,s]=(0,IO.useState)(!1);(0,IO.useEffect)(()=>{let c=Wdn();r(c),s(!0)},[]);let a=[{label:"New plan",value:"__NEW_PLAN__",isNew:!0},...t.map(c=>({label:c.name,value:c.path,isNew:!1,modified:c.modified}))];er((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Be();return o?$u.createElement(R,{flexDirection:"column",marginY:1},$u.createElement(R,{marginBottom:1},$u.createElement(v,{bold:!0,color:l.claude},"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),$u.createElement(R,{marginBottom:1},$u.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return $u.createElement(R,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},$u.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),$u.createElement(v,{color:f?l.claude:l.text}," "),$u.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&$u.createElement(v,{dimColor:!0}," ","(",uAe(c.modified),")"))}),$u.createElement(R,{marginTop:1,marginLeft:2},$u.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):$u.createElement(R,{flexDirection:"column",marginY:1},$u.createElement(v,null,"Loading plan history..."))};var Sbt=X(ge(),1),Kdn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return vi.isPlanMode()?(e("Already in plan mode."),null):Sbt.createElement(Cbt,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?vi.setCurrentPlanFilePath(t):vi.generatePlanFilePath(),vi.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},Ibt=Kdn;Yg();var Jdn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return vi.isAutoMode()?"Already in auto mode.":(vi.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},Tbt=Jdn;Er();import{resolve as Zdn}from"path";var Xdn={type:"local",name:"cd",description:()=>"Move this session to a new working directory",isEnabled:!0,isHidden:!1,argNames:["path"],async call(e){let t=e.trim();if(t==="")throw new Error("Missing directory path. Usage: /cd <path>");let r=Oe(),n=Zdn(r,t);fa(n);let i=Oe();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},vbt=Xdn;var n1t=X(ge(),1);var $n=X(ge(),1);var Nfn=X(ge(),1);var q9=X(ge(),1),wfn=X(Rbt(),1);var Nbt={info:"blue",success:"green",error:"red",warning:"yellow"},pfn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:Nbt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Nbt[e]}),content:()=>({flexShrink:1,flexGrow:1,minWidth:0,flexDirection:"column",gap:1}),title:()=>({bold:!0}),message:()=>({})},config({variant:e}){let t;return e==="info"&&(t=Vt.info),e==="success"&&(t=Vt.tick),e==="error"&&(t=Vt.cross),e==="warning"&&(t=Vt.warning),{icon:t}}},Bbt=pfn;var mfn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},Obt=mfn;var gfn={styles:{input:({isFocused:e})=>({dimColor:!e})}},kbt=gfn;var Afn={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},Mbt=Afn;var hfn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},Qbt=hfn;var Efn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Vt.square,remainingCharacter:Vt.squareLightShade})},Pbt=Efn;var _fn={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},Lbt=_fn;var yfn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},Fbt=yfn;var bfn={success:"green",error:"red",warning:"yellow",info:"blue"},Cfn={success:Vt.tick,error:Vt.cross,warning:Vt.warning,info:Vt.info},Sfn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:bfn[e]}),message:()=>({})},config:({variant:e})=>({icon:Cfn[e]})},Ubt=Sfn;var Ifn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Vt.line})},Hbt=Ifn;var Tfn={styles:{value:()=>({})}},$bt=Tfn;var vfn={styles:{value:()=>({})}},qbt=vfn;var xfn={styles:{value:()=>({})}},Gbt=xfn;var Dfn={components:{Alert:Bbt,Badge:Obt,ConfirmInput:kbt,MultiSelect:Mbt,OrderedList:Qbt,ProgressBar:Pbt,Select:Lbt,Spinner:Fbt,StatusMessage:Ubt,UnorderedList:Hbt,TextInput:$bt,EmailInput:qbt,PasswordInput:Gbt}},Rfn=(0,q9.createContext)(Dfn);var mo=e=>(0,q9.useContext)(Rfn).components[e];var Bfn=X(ge(),1);var Q_=X(ge(),1);var vO=X(ge(),1);var zbt=X(ge(),1);var G9=Vt.line;var Cee=(0,zbt.createContext)({marker:G9});function jbt({children:e}){let{marker:t}=(0,vO.useContext)(Cee),{styles:r}=mo("UnorderedList");return vO.default.createElement(R,{...r.listItem()},vO.default.createElement(v,{...r.marker()},t),vO.default.createElement(R,{...r.content()},e))}var Ybt=X(ge(),1),ixe=(0,Ybt.createContext)({depth:0});function Ofn({children:e}){let{depth:t}=(0,Q_.useContext)(ixe),{styles:r,config:n}=mo("UnorderedList"),i=(0,Q_.useMemo)(()=>({depth:t+1}),[t]),o=(0,Q_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??G9}:{marker:G9}},[n,t]);return Q_.default.createElement(ixe.Provider,{value:i},Q_.default.createElement(Cee.Provider,{value:o},Q_.default.createElement(R,{...r.list()},e)))}Ofn.Item=jbt;var Mfn=X(ge(),1);var kfn=X(ge(),1);var z9=X(ge(),1);var xO=class extends Map{first;constructor(t){let r=[],n,i,o=0;for(let s of t){let a={...s,previous:i,next:void 0,index:o};i&&(i.next=a),n||=a,r.push([s.value,a]),o++,i=a}super(r),this.first=n}};var Vbt=X(ge(),1);var wO=X(ge(),1);var j9=X(ge(),1);function Wbt({isFocused:e,isSelected:t,children:r}){let{styles:n}=mo("Select");return j9.default.createElement(R,{...n.option({isFocused:e})},e&&j9.default.createElement(v,{...n.focusIndicator()},Vt.pointer),j9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&j9.default.createElement(v,{...n.selectedIndicator()},Vt.tick))}var Dm=X(ge(),1);import{isDeepStrictEqual as Qfn}from"node:util";var Pfn=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let o=Math.min(e.optionMap.size,e.visibleToIndex+1),s=o-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:o}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let o=Math.max(0,e.visibleFromIndex-1),s=o+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:o,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state}},Kbt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new xO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},Jbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Dm.useReducer)(Pfn,{visibleOptionCount:e,defaultValue:r,options:t},Kbt),[s,a]=(0,Dm.useState)(t);t!==s&&!Qfn(t,s)&&(o({type:"reset",state:Kbt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Dm.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Dm.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Dm.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,Dm.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Dm.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Zbt=({isDisabled:e=!1,state:t})=>{er((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function DO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=Jbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Zbt({isDisabled:e,state:s});let{styles:a}=mo("Select");return wO.default.createElement(R,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=wO.default.createElement(wO.default.Fragment,null,l.label.slice(0,u),wO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return wO.default.createElement(Wbt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Lfn=X(ge(),1);var Xbt=X(ge(),1);var Ufn=X(ge(),1);var See=X(ge(),1);var Ffn=X(ge(),1);var bMi=cr.inverse(" ");var Zg=X(ge(),1);var RO=X(ge(),1);var eCt=X(ge(),1);var Iee=(0,eCt.createContext)({marker:Vt.line});function Tee({children:e}){let{marker:t}=(0,RO.useContext)(Iee),{styles:r}=mo("OrderedList");return RO.default.createElement(R,{...r.listItem()},RO.default.createElement(v,{...r.marker()},t),RO.default.createElement(R,{...r.content()},e))}var tCt=X(ge(),1),oxe=(0,tCt.createContext)({marker:""});function Xg({children:e}){let{marker:t}=(0,Zg.useContext)(oxe),{styles:r}=mo("OrderedList"),n=0;for(let o of Zg.default.Children.toArray(e))!(0,Zg.isValidElement)(o)||o.type!==Tee||n++;let i=String(n).length;return Zg.default.createElement(R,{...r.list()},Zg.default.Children.map(e,(o,s)=>{if(!(0,Zg.isValidElement)(o)||o.type!==Tee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Zg.default.createElement(oxe.Provider,{value:{marker:l}},Zg.default.createElement(Iee.Provider,{value:{marker:l}},o))}))}Xg.Item=Tee;var $fn=X(ge(),1);var sxe=X(ge(),1);var Hfn=X(ge(),1);var KMi=cr.inverse(" ");var qfn=X(ge(),1);var Gfn=X(ge(),1);var jfn=X(ge(),1);var vee=X(ge(),1);var zfn=X(ge(),1);var yQi=cr.inverse(" ");var qi=X(ge(),1);var axe=X(ge(),1),lxe=X(ge(),1);l9();fs();Pi();ix();ar();var rCt=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"];function eA(){let e=[...rCt,...[...rCt].reverse()],{frame:t}=BR({interval:120});return axe.createElement(R,{flexWrap:"nowrap",height:1,width:2},axe.createElement(v,{color:Be().claude},e[t%e.length]))}var Dee=X(ge(),1);var wee=null,P_=null,xee=new Set;function uxe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=Zpe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function cxe(){P_&&(wee=uxe(P_),xee.forEach(e=>e(wee)))}function Yfn(e,t){return P_!==e&&(P_&&P_.off("resize",cxe),P_=e,wee=uxe(e),e.on("resize",cxe)),xee.add(t),()=>{xee.delete(t),xee.size===0&&P_&&(P_.off("resize",cxe),P_=null,wee=null)}}function dxe(){let{stdout:e}=Ob(),[t,r]=(0,Dee.useState)(()=>uxe(e));return(0,Dee.useEffect)(()=>Yfn(e,r),[e]),t}function NO(){return dxe()}He();Of();ke();mh();ke();var cLi=X(Bxe(),1);import{homedir as t4}from"os";import{join as kO}from"path";import{existsSync as r4,mkdirSync as zSt,appendFileSync as GSt,readFileSync as jSt,constants as Ggn,writeFileSync as zgn,unlinkSync as YSt,statSync as jgn}from"fs";import{platform as VSt}from"process";import{accessSync as Ygn}from"fs";var qgn="2.4.32",e4={VERSION:qgn,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"};He();var Ex=kO(W0,".update.lock"),Vgn=300*1e3;function WSt(){try{if(r4(W0)||zSt(W0,{recursive:!0}),r4(Ex)){let e=jgn(Ex);if(Date.now()-e.mtimeMs<Vgn)return!1;try{YSt(Ex)}catch(r){return ve(`Failed to remove stale lock file: ${r}`),!1}}return zgn(Ex,`${process.pid}`,"utf8"),!0}catch(e){return ve(`Failed to acquire lock: ${e}`),!1}}function KSt(){try{r4(Ex)&&jSt(Ex,"utf8")===`${process.pid}`&&YSt(Ex)}catch(e){ve(`Failed to release lock: ${e}`)}}async function Oxe(){try{let e=await ai("npm -g config get prefix");if(e.code!==0)return ve("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{Ygn(t,Ggn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(ve("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return ve(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function JSt(e){if(!WSt())throw Et("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:e4.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{r4(e)||zSt(e,{recursive:!0});let t=await ai(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
|
|
1135
1135
|
# npm global path
|
|
1136
1136
|
export PATH="${e}/bin:$PATH"
|
|
1137
1137
|
`;if(VSt==="win32"){let n=await ai(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[kO(t4(),".bashrc"),kO(t4(),".bash_profile"),kO(t4(),".zshrc"),kO(t4(),".config","fish","config.fish")];for(let i of n)if(r4(i))try{if(!jSt(i,"utf8").includes(e)){if(i.includes("fish")){let s=`
|
|
@@ -3406,7 +3406,7 @@ If you have NOT used a tool in this conversation, you MUST load it first. Never
|
|
|
3406
3406
|
`);return`${G7t}
|
|
3407
3407
|
<loadable_tools>
|
|
3408
3408
|
${i}
|
|
3409
|
-
</loadable_tools>`},isReadOnly(){return!1},isConcurrencySafe(){return!1},get inputSchema(){return g6n()},get inputJSONSchema(){return A6n},userFacingName(e){return(e?.action??"load")==="load"?"LoadTool":Bs},async isEnabled(){return nt.isProxyToolEnable()},needsPermissions(){return!1},renderToolUseMessage(e){let t=e?.action??"load";return t==="load"?e?.name??"":`${t} ${e?.name??""}`.trim()},renderToolUseRejectedMessage(){return aQ.createElement(R,null,aQ.createElement(v,null,"tool execution was rejected"))},renderToolResultMessage(e){let t=e?.error?e.message:e?.action==="load"&&e?.name?`${e.name} tool is loaded`:e?.message??"";return aQ.createElement(R,{flexDirection:"row"},aQ.createElement(v,null,"\xA0\xA0\u23BF \xA0"),aQ.createElement(v,null,t))},renderResultForAssistant(e){return e.message},async*call(e,t){let r=e.action??"load",n=await z7t(t),i=n.find(o=>o.name===e.name);if(!i){let o=n.filter(gFe).map(l=>l.name).join(", "),s=`<error>Tool not found: ${e.name}. Run ${Bs}({action:'load'}) or refer to the list. Available tools: ${o}</error>`,a={action:r,name:e.name,message:s,error:!0};yield{type:"result",resultForAssistant:s,data:a};return}if(!gFe(i)){let o=`<error>Tool ${e.name} cannot be invoked through ${Bs}. Call it directly.</error>`,s={action:r,name:e.name,message:o,error:!0};yield{type:"result",resultForAssistant:o,data:s};return}if(r==="load"){let o=await i.prompt({dangerouslySkipPermissions:t?.options?.dangerouslySkipPermissions},t),s="inputJSONSchema"in i&&i.inputJSONSchema?i.inputJSONSchema:f0(i.inputSchema),a=yA(s,""),l=[`# ${i.name}`,o,"","## Input (TypeScript)"
|
|
3409
|
+
</loadable_tools>`},isReadOnly(){return!1},isConcurrencySafe(){return!1},get inputSchema(){return g6n()},get inputJSONSchema(){return A6n},userFacingName(e){return(e?.action??"load")==="load"?"LoadTool":Bs},async isEnabled(){return nt.isProxyToolEnable()},needsPermissions(){return!1},renderToolUseMessage(e){let t=e?.action??"load";return t==="load"?e?.name??"":`${t} ${e?.name??""}`.trim()},renderToolUseRejectedMessage(){return aQ.createElement(R,null,aQ.createElement(v,null,"tool execution was rejected"))},renderToolResultMessage(e){let t=e?.error?e.message:e?.action==="load"&&e?.name?`${e.name} tool is loaded`:e?.message??"";return aQ.createElement(R,{flexDirection:"row"},aQ.createElement(v,null,"\xA0\xA0\u23BF \xA0"),aQ.createElement(v,null,t))},renderResultForAssistant(e){return e.message},async*call(e,t){let r=e.action??"load",n=await z7t(t),i=n.find(o=>o.name===e.name);if(!i){let o=n.filter(gFe).map(l=>l.name).join(", "),s=`<error>Tool not found: ${e.name}. Run ${Bs}({action:'load'}) or refer to the list. Available tools: ${o}</error>`,a={action:r,name:e.name,message:s,error:!0};yield{type:"result",resultForAssistant:s,data:a};return}if(!gFe(i)){let o=`<error>Tool ${e.name} cannot be invoked through ${Bs}. Call it directly.</error>`,s={action:r,name:e.name,message:o,error:!0};yield{type:"result",resultForAssistant:o,data:s};return}if(r==="load"){let o=await i.prompt({dangerouslySkipPermissions:t?.options?.dangerouslySkipPermissions},t),s="inputJSONSchema"in i&&i.inputJSONSchema?i.inputJSONSchema:f0(i.inputSchema),a=yA(s,""),l=[`# ${i.name}`,o,"","## Input (TypeScript)",`type ${i.name}Input = ${a};`].join(`
|
|
3410
3410
|
`),c={action:r,name:i.name,schema:s,message:l};yield{type:"result",resultForAssistant:l,data:c};return}for await(let o of i.call(e.input??{},t,void 0))yield o}};var Y7t=()=>[y7t,H7t,j7t,R9t,f7t,Gi,$m,H3,$3,a1,l1,y9t,r1,t1,i1,dE,M9t,H6,K3t,T$t,k$t,M$t,Q$t,P$t,Tse,nqt,J$t,aqt,dqt,gqt,U3,Eqt,Cqt,Wzt,Kzt,Jzt,n7t,c7t,Fqt,vqt,Rqt,kqt],cf=Pe(async()=>{let e=[...Y7t(),...await cM()],t=await Promise.all(e.map(r=>r.isEnabled()));return e.filter((r,n)=>t[n])}),GM=Pe(async()=>{let e=Y7t().filter(r=>r.isReadOnly()),t=await Promise.all(e.map(r=>r.isEnabled()));return e.filter((r,n)=>t[n])});en.add(cf);en.add(GM);en.getTools=cf;He();var Z$t="Launch a new agent to handle complex, multi-step tasks autonomously.";async function V7t(e,t){let r=e.tools,n=await fLe(t);if(r){let i=Array.isArray(r)&&r.length===1&&r[0]==="*";r==="*"||i||Array.isArray(r)&&(n=n.filter(o=>r.includes(o.name)))}return n}async function fLe(e){return await(e?GM():cf())}async function X$t(e){let r=(await Iy()).map(n=>{let i=Array.isArray(n.tools)?n.tools.join(", "):"*";return`- ${n.agentType}: ${n.whenToUse} (Tools: ${i})`}).join(`
|
|
3411
3411
|
`);return`Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
3412
3412
|
|