@sourcegraph/amp 0.0.1772201356-g024e62 → 0.0.1772208429-ge4b10a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +11 -11
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -91,7 +91,7 @@ Expected format:
91
91
  *** Begin Patch
92
92
  *** Add File: path/to/file.ts
93
93
  +file contents
94
- *** End Patch`);if(D===-1)throw Error('Invalid patch format: missing *** Begin Patch marker. Patch must start with "*** Begin Patch"');if(K===-1)throw Error('Invalid patch format: missing *** End Patch marker. Patch must end with "*** End Patch"');if(K<D)throw Error("Invalid patch format: *** End Patch appears before *** Begin Patch. Check marker ordering.");let z=Q.slice(0,D).filter((W)=>W.trim()!=="");if(z.length>0)Y.push(`Warning: ${z.length} non-empty line(s) before *** Begin Patch were ignored. First ignored: "${z[0].slice(0,40)}${z[0].length>40?"...":""}"`);let q=Q.findIndex((W,H)=>H>D&&W.trim()==="*** Begin Patch");if(q!==-1&&q<K)Y.push(`Warning: duplicate "*** Begin Patch" found at line ${q+1}. Only the first marker is used.`);let F=Q.slice(K+1).filter((W)=>W.trim()!=="");if(F.length>0)Y.push(`Warning: ${F.length} non-empty line(s) after *** End Patch were ignored. First ignored: "${F[0].slice(0,40)}${F[0].length>40?"...":""}"`);let G=D+1;while(G<K){let W=LU6(Q,G);if(!W){G++;continue}let H=Q[G];if(H.startsWith("*** Add File:")){let{content:B,nextIdx:w}=IU6(Q,W.nextIdx);X.push({type:"add",path:W.filePath,contents:B}),G=w}else if(H.startsWith("*** Delete File:"))X.push({type:"delete",path:W.filePath}),G=W.nextIdx;else if(H.startsWith("*** Update File:")){let{chunks:B,nextIdx:w}=MU6(Q,W.nextIdx);X.push({type:"update",path:W.filePath,movePath:W.movePath,chunks:B}),G=w}else G++}return{hunks:X,warnings:Y.length>0?Y:void 0}}var lv="run_terminal_command",cW0="read_file",U9="Task",FZ="task_list",c3="finder",HV="get_diagnostics",g6="Bash",GZ="shell_command",H7="oracle",_M="mermaid",jw="chart",iE1="walkthrough",Na="walkthrough_diagram",nE1="todo_write",BY="read_web_page",fK="read_thread",Rw="find_thread",l3="create_file",RF="glob",SM="undo_edit",Oa="read_mcp_resource",w6="Read",T3="edit_file",Ea="format_file",PF="web_search",i3="Grep",aE1="docs_list",oE1="docs_read",rE1="docs_write",La="code_review",WZ="librarian",Ia="look_at",Ma="read_github",Aa="search_github",ja="commit_search",Ra="list_directory_github",Pa="list_repositories",Ca="glob_github",Ta="diff",sE1="read_bitbucket_enterprise",tE1="list_directory_bitbucket_enterprise",eE1="list_repositories_bitbucket_enterprise",$L1="glob_bitbucket_enterprise",JL1="search_bitbucket_enterprise",ZL1="diff_bitbucket_enterprise",QL1="commit_search_bitbucket_enterprise",s7="skill",_a="repl",vM="handoff",Sa="painter",bK="apply_patch",XL1="restore_snapshot",lW0="slack_write",iW0="slack_read",YL1;var w4=J0(()=>{YL1=["Task","task_list","finder","get_diagnostics","Bash","shell_command","oracle","mermaid","chart","walkthrough","walkthrough_diagram","read_web_page","create_file","glob","Glob","undo_edit","Read","edit_file","delete_file","format_file","web_search","Grep","search_documents","get_document","docs_list","docs_read","docs_write","code_review","look_at","librarian","read_thread","find_thread","skill","read_github","search_github","commit_search","list_directory_github","list_repositories","glob_github","diff","read_bitbucket_enterprise","list_directory_bitbucket_enterprise","list_repositories_bitbucket_enterprise","glob_bitbucket_enterprise","search_bitbucket_enterprise","diff_bitbucket_enterprise","commit_search_bitbucket_enterprise","handoff","painter","apply_patch","restore_snapshot","thread_status","create_thread"]});var iv=y((L$3,VL1)=>{var UL1={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)",SEP:"/"},jU6={...UL1,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},RU6={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};VL1.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:RU6,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(J){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${J.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(J){return J===!0?jU6:UL1}}});var nv=y((SU6)=>{var{REGEX_BACKSLASH:PU6,REGEX_REMOVE_BACKSLASH:CU6,REGEX_SPECIAL_CHARS:TU6,REGEX_SPECIAL_CHARS_GLOBAL:_U6}=iv();SU6.isObject=(J)=>J!==null&&typeof J==="object"&&!Array.isArray(J);SU6.hasRegexChars=(J)=>TU6.test(J);SU6.isRegexChar=(J)=>J.length===1&&SU6.hasRegexChars(J);SU6.escapeRegex=(J)=>J.replace(_U6,"\\$1");SU6.toPosixSlashes=(J)=>J.replace(PU6,"/");SU6.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let J=navigator.platform.toLowerCase();return J==="win32"||J==="windows"}if(typeof process<"u"&&process.platform)return process.platform==="win32";return!1};SU6.removeBackslashes=(J)=>{return J.replace(CU6,(Z)=>{return Z==="\\"?"":Z})};SU6.escapeLast=(J,Z,Q)=>{let X=J.lastIndexOf(Z,Q);if(X===-1)return J;if(J[X-1]==="\\")return SU6.escapeLast(J,Z,X-1);return`${J.slice(0,X)}\\${J.slice(X)}`};SU6.removePrefix=(J,Z={})=>{let Q=J;if(Q.startsWith("./"))Q=Q.slice(2),Z.prefix="./";return Q};SU6.wrapOutput=(J,Z={},Q={})=>{let X=Q.contains?"":"^",Y=Q.contains?"":"$",U=`${X}(?:${J})${Y}`;if(Z.negated===!0)U=`(?:^(?!${U}).*$)`;return U};SU6.basename=(J,{windows:Z}={})=>{let Q=J.split(Z?/[\\/]/:"/"),X=Q[Q.length-1];if(X==="")return Q[Q.length-2];return X}});var wL1=y((M$3,BL1)=>{var zL1=nv(),{CHAR_ASTERISK:nW0,CHAR_AT:gU6,CHAR_BACKWARD_SLASH:av,CHAR_COMMA:pU6,CHAR_DOT:aW0,CHAR_EXCLAMATION_MARK:oW0,CHAR_FORWARD_SLASH:HL1,CHAR_LEFT_CURLY_BRACE:rW0,CHAR_LEFT_PARENTHESES:sW0,CHAR_LEFT_SQUARE_BRACKET:dU6,CHAR_PLUS:cU6,CHAR_QUESTION_MARK:qL1,CHAR_RIGHT_CURLY_BRACE:lU6,CHAR_RIGHT_PARENTHESES:FL1,CHAR_RIGHT_SQUARE_BRACKET:iU6}=iv(),GL1=(J)=>{return J===HL1||J===av},WL1=(J)=>{if(J.isPrefix!==!0)J.depth=J.isGlobstar?1/0:1},nU6=(J,Z)=>{let Q=Z||{},X=J.length-1,Y=Q.parts===!0||Q.scanToEnd===!0,U=[],V=[],D=[],K=J,z=-1,q=0,F=0,G=!1,W=!1,H=!1,B=!1,w=!1,N=!1,O=!1,E=!1,L=!1,I=!1,M=0,A,R,_={value:"",depth:0,isGlob:!1},k=()=>z>=X,u=()=>K.charCodeAt(z+1),h=()=>{return A=R,K.charCodeAt(++z)};while(z<X){R=h();let l;if(R===av){if(O=_.backslashes=!0,R=h(),R===rW0)N=!0;continue}if(N===!0||R===rW0){M++;while(k()!==!0&&(R=h())){if(R===av){O=_.backslashes=!0,h();continue}if(R===rW0){M++;continue}if(N!==!0&&R===aW0&&(R=h())===aW0){if(G=_.isBrace=!0,H=_.isGlob=!0,I=!0,Y===!0)continue;break}if(N!==!0&&R===pU6){if(G=_.isBrace=!0,H=_.isGlob=!0,I=!0,Y===!0)continue;break}if(R===lU6){if(M--,M===0){N=!1,G=_.isBrace=!0,I=!0;break}}}if(Y===!0)continue;break}if(R===HL1){if(U.push(z),V.push(_),_={value:"",depth:0,isGlob:!1},I===!0)continue;if(A===aW0&&z===q+1){q+=2;continue}F=z+1;continue}if(Q.noext!==!0){if((R===cU6||R===gU6||R===nW0||R===qL1||R===oW0)===!0&&u()===sW0){if(H=_.isGlob=!0,B=_.isExtglob=!0,I=!0,R===oW0&&z===q)L=!0;if(Y===!0){while(k()!==!0&&(R=h())){if(R===av){O=_.backslashes=!0,R=h();continue}if(R===FL1){H=_.isGlob=!0,I=!0;break}}continue}break}}if(R===nW0){if(A===nW0)w=_.isGlobstar=!0;if(H=_.isGlob=!0,I=!0,Y===!0)continue;break}if(R===qL1){if(H=_.isGlob=!0,I=!0,Y===!0)continue;break}if(R===dU6){while(k()!==!0&&(l=h())){if(l===av){O=_.backslashes=!0,h();continue}if(l===iU6){W=_.isBracket=!0,H=_.isGlob=!0,I=!0;break}}if(Y===!0)continue;break}if(Q.nonegate!==!0&&R===oW0&&z===q){E=_.negated=!0,q++;continue}if(Q.noparen!==!0&&R===sW0){if(H=_.isGlob=!0,Y===!0){while(k()!==!0&&(R=h())){if(R===sW0){O=_.backslashes=!0,R=h();continue}if(R===FL1){I=!0;break}}continue}break}if(H===!0){if(I=!0,Y===!0)continue;break}}if(Q.noext===!0)B=!1,H=!1;let f=K,S="",x="";if(q>0)S=K.slice(0,q),K=K.slice(q),F-=q;if(f&&H===!0&&F>0)f=K.slice(0,F),x=K.slice(F);else if(H===!0)f="",x=K;else f=K;if(f&&f!==""&&f!=="/"&&f!==K){if(GL1(f.charCodeAt(f.length-1)))f=f.slice(0,-1)}if(Q.unescape===!0){if(x)x=zL1.removeBackslashes(x);if(f&&O===!0)f=zL1.removeBackslashes(f)}let m={prefix:S,input:J,start:q,base:f,glob:x,isBrace:G,isBracket:W,isGlob:H,isExtglob:B,isGlobstar:w,negated:E,negatedExtglob:L};if(Q.tokens===!0){if(m.maxDepth=0,!GL1(R))V.push(_);m.tokens=V}if(Q.parts===!0||Q.tokens===!0){let l;for(let g=0;g<U.length;g++){let n=l?l+1:q,d=U[g],$0=J.slice(n,d);if(Q.tokens){if(g===0&&q!==0)V[g].isPrefix=!0,V[g].value=S;else V[g].value=$0;WL1(V[g]),m.maxDepth+=V[g].depth}if(g!==0||$0!=="")D.push($0);l=d}if(l&&l+1<J.length){let g=J.slice(l+1);if(D.push(g),Q.tokens)V[V.length-1].value=g,WL1(V[V.length-1]),m.maxDepth+=V[V.length-1].depth}m.slashes=U,m.parts=D}return m};BL1.exports=nU6});var EL1=y((A$3,OL1)=>{var va=iv(),BV=nv(),{MAX_LENGTH:ka,POSIX_REGEX_SOURCE:aU6,REGEX_NON_SPECIAL_CHARS:oU6,REGEX_SPECIAL_CHARS_BACKREF:rU6,REPLACEMENTS:NL1}=va,sU6=(J,Z)=>{if(typeof Z.expandRange==="function")return Z.expandRange(...J,Z);J.sort();let Q=`[${J.join("-")}]`;try{new RegExp(Q)}catch(X){return J.map((Y)=>BV.escapeRegex(Y)).join("..")}return Q},kM=(J,Z)=>{return`Missing ${J}: "${Z}" - use "\\\\${Z}" to match literal characters`},tW0=(J,Z)=>{if(typeof J!=="string")throw TypeError("Expected a string");J=NL1[J]||J;let Q={...Z},X=typeof Q.maxLength==="number"?Math.min(ka,Q.maxLength):ka,Y=J.length;if(Y>X)throw SyntaxError(`Input length: ${Y}, exceeds maximum allowed length: ${X}`);let U={type:"bos",value:"",output:Q.prepend||""},V=[U],D=Q.capture?"":"?:",K=va.globChars(Q.windows),z=va.extglobChars(K),{DOT_LITERAL:q,PLUS_LITERAL:F,SLASH_LITERAL:G,ONE_CHAR:W,DOTS_SLASH:H,NO_DOT:B,NO_DOT_SLASH:w,NO_DOTS_SLASH:N,QMARK:O,QMARK_NO_DOT:E,STAR:L,START_ANCHOR:I}=K,M=(H0)=>{return`(${D}(?:(?!${I}${H0.dot?H:q}).)*?)`},A=Q.dot?"":B,R=Q.dot?O:E,_=Q.bash===!0?M(Q):L;if(Q.capture)_=`(${_})`;if(typeof Q.noext==="boolean")Q.noextglob=Q.noext;let k={input:J,index:-1,start:0,dot:Q.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:V};J=BV.removePrefix(J,k),Y=J.length;let u=[],h=[],f=[],S=U,x,m=()=>k.index===Y-1,l=k.peek=(H0=1)=>J[k.index+H0],g=k.advance=()=>J[++k.index]||"",n=()=>J.slice(k.index+1),d=(H0="",c=0)=>{k.consumed+=H0,k.index+=c},$0=(H0)=>{k.output+=H0.output!=null?H0.output:H0.value,d(H0.value)},B0=()=>{let H0=1;while(l()==="!"&&(l(2)!=="("||l(3)==="?"))g(),k.start++,H0++;if(H0%2===0)return!1;return k.negated=!0,k.start++,!0},s=(H0)=>{k[H0]++,f.push(H0)},q0=(H0)=>{k[H0]--,f.pop()},K0=(H0)=>{if(S.type==="globstar"){let c=k.braces>0&&(H0.type==="comma"||H0.type==="brace"),r=H0.extglob===!0||u.length&&(H0.type==="pipe"||H0.type==="paren");if(H0.type!=="slash"&&H0.type!=="paren"&&!c&&!r)k.output=k.output.slice(0,-S.output.length),S.type="star",S.value="*",S.output=_,k.output+=S.output}if(u.length&&H0.type!=="paren")u[u.length-1].inner+=H0.value;if(H0.value||H0.output)$0(H0);if(S&&S.type==="text"&&H0.type==="text"){S.output=(S.output||S.value)+H0.value,S.value+=H0.value;return}H0.prev=S,V.push(H0),S=H0},O0=(H0,c)=>{let r={...z[c],conditions:1,inner:""};r.prev=S,r.parens=k.parens,r.output=k.output;let e=(Q.capture?"(":"")+r.open;s("parens"),K0({type:H0,value:c,output:k.output?"":W}),K0({type:"paren",extglob:!0,value:g(),output:e}),u.push(r)},Y0=(H0)=>{let c=H0.close+(Q.capture?")":""),r;if(H0.type==="negate"){let e=_;if(H0.inner&&H0.inner.length>1&&H0.inner.includes("/"))e=M(Q);if(e!==_||m()||/^\)+$/.test(n()))c=H0.close=`)$))${e}`;if(H0.inner.includes("*")&&(r=n())&&/^\.[^\\/.]+$/.test(r)){let i=tW0(r,{...Z,fastpaths:!1}).output;c=H0.close=`)${i})${e})`}if(H0.prev.type==="bos")k.negatedExtglob=!0}K0({type:"paren",extglob:!0,value:x,output:c}),q0("parens")};if(Q.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(J)){let H0=!1,c=J.replace(rU6,(r,e,i,o,Z0,D0)=>{if(o==="\\")return H0=!0,r;if(o==="?"){if(e)return e+o+(Z0?O.repeat(Z0.length):"");if(D0===0)return R+(Z0?O.repeat(Z0.length):"");return O.repeat(i.length)}if(o===".")return q.repeat(i.length);if(o==="*"){if(e)return e+o+(Z0?_:"");return _}return e?r:`\\${r}`});if(H0===!0)if(Q.unescape===!0)c=c.replace(/\\/g,"");else c=c.replace(/\\+/g,(r)=>{return r.length%2===0?"\\\\":r?"\\":""});if(c===J&&Q.contains===!0)return k.output=J,k;return k.output=BV.wrapOutput(c,k,Z),k}while(!m()){if(x=g(),x==="\x00")continue;if(x==="\\"){let r=l();if(r==="/"&&Q.bash!==!0)continue;if(r==="."||r===";")continue;if(!r){x+="\\",K0({type:"text",value:x});continue}let e=/^\\+/.exec(n()),i=0;if(e&&e[0].length>2){if(i=e[0].length,k.index+=i,i%2!==0)x+="\\"}if(Q.unescape===!0)x=g();else x+=g();if(k.brackets===0){K0({type:"text",value:x});continue}}if(k.brackets>0&&(x!=="]"||S.value==="["||S.value==="[^")){if(Q.posix!==!1&&x===":"){let r=S.value.slice(1);if(r.includes("[")){if(S.posix=!0,r.includes(":")){let e=S.value.lastIndexOf("["),i=S.value.slice(0,e),o=S.value.slice(e+2),Z0=aU6[o];if(Z0){if(S.value=i+Z0,k.backtrack=!0,g(),!U.output&&V.indexOf(S)===1)U.output=W;continue}}}}if(x==="["&&l()!==":"||x==="-"&&l()==="]")x=`\\${x}`;if(x==="]"&&(S.value==="["||S.value==="[^"))x=`\\${x}`;if(Q.posix===!0&&x==="!"&&S.value==="[")x="^";S.value+=x,$0({value:x});continue}if(k.quotes===1&&x!=='"'){x=BV.escapeRegex(x),S.value+=x,$0({value:x});continue}if(x==='"'){if(k.quotes=k.quotes===1?0:1,Q.keepQuotes===!0)K0({type:"text",value:x});continue}if(x==="("){s("parens"),K0({type:"paren",value:x});continue}if(x===")"){if(k.parens===0&&Q.strictBrackets===!0)throw SyntaxError(kM("opening","("));let r=u[u.length-1];if(r&&k.parens===r.parens+1){Y0(u.pop());continue}K0({type:"paren",value:x,output:k.parens?")":"\\)"}),q0("parens");continue}if(x==="["){if(Q.nobracket===!0||!n().includes("]")){if(Q.nobracket!==!0&&Q.strictBrackets===!0)throw SyntaxError(kM("closing","]"));x=`\\${x}`}else s("brackets");K0({type:"bracket",value:x});continue}if(x==="]"){if(Q.nobracket===!0||S&&S.type==="bracket"&&S.value.length===1){K0({type:"text",value:x,output:`\\${x}`});continue}if(k.brackets===0){if(Q.strictBrackets===!0)throw SyntaxError(kM("opening","["));K0({type:"text",value:x,output:`\\${x}`});continue}q0("brackets");let r=S.value.slice(1);if(S.posix!==!0&&r[0]==="^"&&!r.includes("/"))x=`/${x}`;if(S.value+=x,$0({value:x}),Q.literalBrackets===!1||BV.hasRegexChars(r))continue;let e=BV.escapeRegex(S.value);if(k.output=k.output.slice(0,-S.value.length),Q.literalBrackets===!0){k.output+=e,S.value=e;continue}S.value=`(${D}${e}|${S.value})`,k.output+=S.value;continue}if(x==="{"&&Q.nobrace!==!0){s("braces");let r={type:"brace",value:x,output:"(",outputIndex:k.output.length,tokensIndex:k.tokens.length};h.push(r),K0(r);continue}if(x==="}"){let r=h[h.length-1];if(Q.nobrace===!0||!r){K0({type:"text",value:x,output:x});continue}let e=")";if(r.dots===!0){let i=V.slice(),o=[];for(let Z0=i.length-1;Z0>=0;Z0--){if(V.pop(),i[Z0].type==="brace")break;if(i[Z0].type!=="dots")o.unshift(i[Z0].value)}e=sU6(o,Q),k.backtrack=!0}if(r.comma!==!0&&r.dots!==!0){let i=k.output.slice(0,r.outputIndex),o=k.tokens.slice(r.tokensIndex);r.value=r.output="\\{",x=e="\\}",k.output=i;for(let Z0 of o)k.output+=Z0.output||Z0.value}K0({type:"brace",value:x,output:e}),q0("braces"),h.pop();continue}if(x==="|"){if(u.length>0)u[u.length-1].conditions++;K0({type:"text",value:x});continue}if(x===","){let r=x,e=h[h.length-1];if(e&&f[f.length-1]==="braces")e.comma=!0,r="|";K0({type:"comma",value:x,output:r});continue}if(x==="/"){if(S.type==="dot"&&k.index===k.start+1){k.start=k.index+1,k.consumed="",k.output="",V.pop(),S=U;continue}K0({type:"slash",value:x,output:G});continue}if(x==="."){if(k.braces>0&&S.type==="dot"){if(S.value===".")S.output=q;let r=h[h.length-1];S.type="dots",S.output+=x,S.value+=x,r.dots=!0;continue}if(k.braces+k.parens===0&&S.type!=="bos"&&S.type!=="slash"){K0({type:"text",value:x,output:q});continue}K0({type:"dot",value:x,output:q});continue}if(x==="?"){if(!(S&&S.value==="(")&&Q.noextglob!==!0&&l()==="("&&l(2)!=="?"){O0("qmark",x);continue}if(S&&S.type==="paren"){let e=l(),i=x;if(S.value==="("&&!/[!=<:]/.test(e)||e==="<"&&!/<([!=]|\w+>)/.test(n()))i=`\\${x}`;K0({type:"text",value:x,output:i});continue}if(Q.dot!==!0&&(S.type==="slash"||S.type==="bos")){K0({type:"qmark",value:x,output:E});continue}K0({type:"qmark",value:x,output:O});continue}if(x==="!"){if(Q.noextglob!==!0&&l()==="("){if(l(2)!=="?"||!/[!=<:]/.test(l(3))){O0("negate",x);continue}}if(Q.nonegate!==!0&&k.index===0){B0();continue}}if(x==="+"){if(Q.noextglob!==!0&&l()==="("&&l(2)!=="?"){O0("plus",x);continue}if(S&&S.value==="("||Q.regex===!1){K0({type:"plus",value:x,output:F});continue}if(S&&(S.type==="bracket"||S.type==="paren"||S.type==="brace")||k.parens>0){K0({type:"plus",value:x});continue}K0({type:"plus",value:F});continue}if(x==="@"){if(Q.noextglob!==!0&&l()==="("&&l(2)!=="?"){K0({type:"at",extglob:!0,value:x,output:""});continue}K0({type:"text",value:x});continue}if(x!=="*"){if(x==="$"||x==="^")x=`\\${x}`;let r=oU6.exec(n());if(r)x+=r[0],k.index+=r[0].length;K0({type:"text",value:x});continue}if(S&&(S.type==="globstar"||S.star===!0)){S.type="star",S.star=!0,S.value+=x,S.output=_,k.backtrack=!0,k.globstar=!0,d(x);continue}let H0=n();if(Q.noextglob!==!0&&/^\([^?]/.test(H0)){O0("star",x);continue}if(S.type==="star"){if(Q.noglobstar===!0){d(x);continue}let r=S.prev,e=r.prev,i=r.type==="slash"||r.type==="bos",o=e&&(e.type==="star"||e.type==="globstar");if(Q.bash===!0&&(!i||H0[0]&&H0[0]!=="/")){K0({type:"star",value:x,output:""});continue}let Z0=k.braces>0&&(r.type==="comma"||r.type==="brace"),D0=u.length&&(r.type==="pipe"||r.type==="paren");if(!i&&r.type!=="paren"&&!Z0&&!D0){K0({type:"star",value:x,output:""});continue}while(H0.slice(0,3)==="/**"){let z0=J[k.index+4];if(z0&&z0!=="/")break;H0=H0.slice(3),d("/**",3)}if(r.type==="bos"&&m()){S.type="globstar",S.value+=x,S.output=M(Q),k.output=S.output,k.globstar=!0,d(x);continue}if(r.type==="slash"&&r.prev.type!=="bos"&&!o&&m()){k.output=k.output.slice(0,-(r.output+S.output).length),r.output=`(?:${r.output}`,S.type="globstar",S.output=M(Q)+(Q.strictSlashes?")":"|$)"),S.value+=x,k.globstar=!0,k.output+=r.output+S.output,d(x);continue}if(r.type==="slash"&&r.prev.type!=="bos"&&H0[0]==="/"){let z0=H0[1]!==void 0?"|$":"";k.output=k.output.slice(0,-(r.output+S.output).length),r.output=`(?:${r.output}`,S.type="globstar",S.output=`${M(Q)}${G}|${G}${z0})`,S.value+=x,k.output+=r.output+S.output,k.globstar=!0,d(x+g()),K0({type:"slash",value:"/",output:""});continue}if(r.type==="bos"&&H0[0]==="/"){S.type="globstar",S.value+=x,S.output=`(?:^|${G}|${M(Q)}${G})`,k.output=S.output,k.globstar=!0,d(x+g()),K0({type:"slash",value:"/",output:""});continue}k.output=k.output.slice(0,-S.output.length),S.type="globstar",S.output=M(Q),S.value+=x,k.output+=S.output,k.globstar=!0,d(x);continue}let c={type:"star",value:x,output:_};if(Q.bash===!0){if(c.output=".*?",S.type==="bos"||S.type==="slash")c.output=A+c.output;K0(c);continue}if(S&&(S.type==="bracket"||S.type==="paren")&&Q.regex===!0){c.output=x,K0(c);continue}if(k.index===k.start||S.type==="slash"||S.type==="dot"){if(S.type==="dot")k.output+=w,S.output+=w;else if(Q.dot===!0)k.output+=N,S.output+=N;else k.output+=A,S.output+=A;if(l()!=="*")k.output+=W,S.output+=W}K0(c)}while(k.brackets>0){if(Q.strictBrackets===!0)throw SyntaxError(kM("closing","]"));k.output=BV.escapeLast(k.output,"["),q0("brackets")}while(k.parens>0){if(Q.strictBrackets===!0)throw SyntaxError(kM("closing",")"));k.output=BV.escapeLast(k.output,"("),q0("parens")}while(k.braces>0){if(Q.strictBrackets===!0)throw SyntaxError(kM("closing","}"));k.output=BV.escapeLast(k.output,"{"),q0("braces")}if(Q.strictSlashes!==!0&&(S.type==="star"||S.type==="bracket"))K0({type:"maybe_slash",value:"",output:`${G}?`});if(k.backtrack===!0){k.output="";for(let H0 of k.tokens)if(k.output+=H0.output!=null?H0.output:H0.value,H0.suffix)k.output+=H0.suffix}return k};tW0.fastpaths=(J,Z)=>{let Q={...Z},X=typeof Q.maxLength==="number"?Math.min(ka,Q.maxLength):ka,Y=J.length;if(Y>X)throw SyntaxError(`Input length: ${Y}, exceeds maximum allowed length: ${X}`);J=NL1[J]||J;let{DOT_LITERAL:U,SLASH_LITERAL:V,ONE_CHAR:D,DOTS_SLASH:K,NO_DOT:z,NO_DOTS:q,NO_DOTS_SLASH:F,STAR:G,START_ANCHOR:W}=va.globChars(Q.windows),H=Q.dot?q:z,B=Q.dot?F:z,w=Q.capture?"":"?:",N={negated:!1,prefix:""},O=Q.bash===!0?".*?":G;if(Q.capture)O=`(${O})`;let E=(A)=>{if(A.noglobstar===!0)return O;return`(${w}(?:(?!${W}${A.dot?K:U}).)*?)`},L=(A)=>{switch(A){case"*":return`${H}${D}${O}`;case".*":return`${U}${D}${O}`;case"*.*":return`${H}${O}${U}${D}${O}`;case"*/*":return`${H}${O}${V}${D}${B}${O}`;case"**":return H+E(Q);case"**/*":return`(?:${H}${E(Q)}${V})?${B}${D}${O}`;case"**/*.*":return`(?:${H}${E(Q)}${V})?${B}${O}${U}${D}${O}`;case"**/.*":return`(?:${H}${E(Q)}${V})?${U}${D}${O}`;default:{let R=/^(.*?)\.(\w+)$/.exec(A);if(!R)return;let _=L(R[1]);if(!_)return;return _+U+R[2]}}},I=BV.removePrefix(J,N),M=L(I);if(M&&Q.strictSlashes!==!0)M+=`${V}?`;return M};OL1.exports=tW0});var $H0=y((j$3,IL1)=>{var tU6=wL1(),eW0=EL1(),LL1=nv(),eU6=iv(),$V6=(J)=>J&&typeof J==="object"&&!Array.isArray(J),V9=(J,Z,Q=!1)=>{if(Array.isArray(J)){let q=J.map((G)=>V9(G,Z,Q));return(G)=>{for(let W of q){let H=W(G);if(H)return H}return!1}}let X=$V6(J)&&J.tokens&&J.input;if(J===""||typeof J!=="string"&&!X)throw TypeError("Expected pattern to be a non-empty string");let Y=Z||{},U=Y.windows,V=X?V9.compileRe(J,Z):V9.makeRe(J,Z,!1,!0),D=V.state;delete V.state;let K=()=>!1;if(Y.ignore){let q={...Z,ignore:null,onMatch:null,onResult:null};K=V9(Y.ignore,q,Q)}let z=(q,F=!1)=>{let{isMatch:G,match:W,output:H}=V9.test(q,V,Z,{glob:J,posix:U}),B={glob:J,state:D,regex:V,posix:U,input:q,output:H,match:W,isMatch:G};if(typeof Y.onResult==="function")Y.onResult(B);if(G===!1)return B.isMatch=!1,F?B:!1;if(K(q)){if(typeof Y.onIgnore==="function")Y.onIgnore(B);return B.isMatch=!1,F?B:!1}if(typeof Y.onMatch==="function")Y.onMatch(B);return F?B:!0};if(Q)z.state=D;return z};V9.test=(J,Z,Q,{glob:X,posix:Y}={})=>{if(typeof J!=="string")throw TypeError("Expected input to be a string");if(J==="")return{isMatch:!1,output:""};let U=Q||{},V=U.format||(Y?LL1.toPosixSlashes:null),D=J===X,K=D&&V?V(J):J;if(D===!1)K=V?V(J):J,D=K===X;if(D===!1||U.capture===!0)if(U.matchBase===!0||U.basename===!0)D=V9.matchBase(J,Z,Q,Y);else D=Z.exec(K);return{isMatch:Boolean(D),match:D,output:K}};V9.matchBase=(J,Z,Q)=>{return(Z instanceof RegExp?Z:V9.makeRe(Z,Q)).test(LL1.basename(J))};V9.isMatch=(J,Z,Q)=>V9(Z,Q)(J);V9.parse=(J,Z)=>{if(Array.isArray(J))return J.map((Q)=>V9.parse(Q,Z));return eW0(J,{...Z,fastpaths:!1})};V9.scan=(J,Z)=>tU6(J,Z);V9.compileRe=(J,Z,Q=!1,X=!1)=>{if(Q===!0)return J.output;let Y=Z||{},U=Y.contains?"":"^",V=Y.contains?"":"$",D=`${U}(?:${J.output})${V}`;if(J&&J.negated===!0)D=`^(?!${D}).*$`;let K=V9.toRegex(D,Z);if(X===!0)K.state=J;return K};V9.makeRe=(J,Z={},Q=!1,X=!1)=>{if(!J||typeof J!=="string")throw TypeError("Expected a non-empty string");let Y={negated:!1,fastpaths:!0};if(Z.fastpaths!==!1&&(J[0]==="."||J[0]==="*"))Y.output=eW0.fastpaths(J,Z);if(!Y.output)Y=eW0(J,Z);return V9.compileRe(Y,Z,Q,X)};V9.toRegex=(J,Z)=>{try{let Q=Z||{};return new RegExp(J,Q.flags||(Q.nocase?"i":""))}catch(Q){if(Z&&Z.debug===!0)throw Q;return/$^/}};V9.constants=eU6;IL1.exports=V9});var hK=y((R$3,jL1)=>{var ML1=$H0(),JV6=nv();function AL1(J,Z,Q=!1){if(Z&&(Z.windows===null||Z.windows===void 0))Z={...Z,windows:JV6.isWindows()};return ML1(J,Z,Q)}Object.assign(AL1,ML1);jL1.exports=AL1});function JH0(J){return ya[J]??0}function ZV6(J){return typeof J==="number"&&Number.isInteger(J)&&J>=1&&J<=3600}function PL1(J){let Z=J.settings["tools.inactivityTimeout"],Q=J.settings["tools.stopTimeout"],X=Z;if(X===void 0&&Q!==void 0)X=Q;if(X===void 0)X=JH0("amp.tools.inactivityTimeout");if(!ZV6(X))return null;return X*1000}function CL1(J){let Z=J.settings["tools.stopTimeout"],Q=JH0("amp.tools.stopTimeout");return(Z??Q)*1000}function ua(J){let Z=J.settings["network.timeout"],Q=JH0("amp.network.timeout");return(Z??Q)*1000}var ya,RL1;var yM=J0(()=>{ya={"amp.tools.inactivityTimeout":300,"amp.tools.stopTimeout":300,"amp.network.timeout":30},RL1={"amp.tools.inactivityTimeout":{default:ya["amp.tools.inactivityTimeout"]},"amp.tools.stopTimeout":{default:ya["amp.tools.stopTimeout"]},"amp.network.timeout":{default:ya["amp.network.timeout"]}}});function _3(J){let Z=P6[J];return`${Z.provider}/${Z.name}`}function wV(J){let Z=J.indexOf("/");if(Z===-1)throw Error(`Invalid provider/model format: ${J}`);return{provider:J.slice(0,Z),model:J.slice(Z+1)}}function i9(J){let{provider:Z,model:Q}=wV(J);for(let X of Object.values(P6))if(X.provider===Z&&X.name===Q)return X;switch(Z){case"anthropic":return P6.CLAUDE_SONNET_4_5;case"openai":return P6.GPT_5;case"xai":return P6.GROK_CODE_FAST_1;case"cerebras":return P6.Z_AI_GLM_4_7;case"fireworks":return P6.FIREWORKS_GLM_4P6;case"baseten":return P6.BASETEN_KIMI_K2P5;case"moonshotai":return P6.KIMI_K2_INSTRUCT;case"openrouter":return P6.SONOMA_SKY_ALPHA;case"groq":return P6.GPT_OSS_120B;case"vertexai":return P6.GEMINI_3_PRO_PREVIEW;default:throw Error(`Unknown provider: ${Z}`)}}function ov(J){for(let Q of Object.values(P6))if(Q.name===J)return Q;let Z=J.match(/^(.*)-\d{4}-\d{2}-\d{2}$/);if(Z){let Q=Z[1];for(let X of Object.values(P6))if(X.name===Q)return X}return}function D8(J){let Z=J.indexOf("/");if(Z===-1)return J;return J.slice(Z+1)}function H$(J){let Z=i9(J);return Z.contextWindow-Z.maxOutputTokens}function xa(J){return i9(J).maxOutputTokens}var M6,P6,ZH0;var t7=J0(()=>{M6={ANTHROPIC:"anthropic",BASENTEN:"baseten",OPENAI:"openai",XAI:"xai",CEREBRAS:"cerebras",FIREWORKS:"fireworks",GROQ:"groq",MOONSHOT:"moonshotai",OPENROUTER:"openrouter",VERTEXAI:"vertexai"},P6={CLAUDE_SONNET_4:{provider:M6.ANTHROPIC,name:"claude-sonnet-4-20250514",displayName:"Claude Sonnet 4",contextWindow:1e6,maxOutputTokens:32000,pricing:{input:3,output:15,cached:0.3,cacheWrite:3.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_SONNET_4_5:{provider:M6.ANTHROPIC,name:"claude-sonnet-4-5-20250929",displayName:"Claude Sonnet 4.5",contextWindow:1e6,maxOutputTokens:32000,pricing:{input:3,output:15,cached:0.3,cacheWrite:3.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_SONNET_4_6:{provider:M6.ANTHROPIC,name:"claude-sonnet-4-6",displayName:"Claude Sonnet 4.6",contextWindow:1e6,maxOutputTokens:64000,pricing:{input:3,output:15,cached:0.3,cacheWrite:3.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4:{provider:M6.ANTHROPIC,name:"claude-opus-4-20250514",displayName:"Claude Opus 4",contextWindow:200000,maxOutputTokens:32000,pricing:{input:15,output:75,cached:1.5,cacheWrite:18.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_1:{provider:M6.ANTHROPIC,name:"claude-opus-4-1-20250805",displayName:"Claude Opus 4.1",contextWindow:200000,maxOutputTokens:32000,pricing:{input:15,output:75,cached:1.5,cacheWrite:18.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_5:{provider:M6.ANTHROPIC,name:"claude-opus-4-5-20251101",displayName:"Claude Opus 4.5",contextWindow:200000,maxOutputTokens:32000,pricing:{input:5,output:25,cached:0.5,cacheWrite:6.25,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_6:{provider:M6.ANTHROPIC,name:"claude-opus-4-6",displayName:"Claude Opus 4.6",contextWindow:200000,maxOutputTokens:32000,pricing:{input:5,output:25,cached:0.5,cacheWrite:6.25,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_HAIKU_4_5:{provider:M6.ANTHROPIC,name:"claude-haiku-4-5-20251001",displayName:"Claude Haiku 4.5",contextWindow:200000,maxOutputTokens:64000,pricing:{input:1,output:5,cached:0.1,cacheWrite:1.25,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5:{provider:M6.OPENAI,name:"gpt-5",displayName:"GPT-5",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_1:{provider:M6.OPENAI,name:"gpt-5.1",displayName:"GPT-5.1",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_2:{provider:M6.OPENAI,name:"gpt-5.2",displayName:"GPT-5.2",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.75,output:14,cached:0.175},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_CODEX:{provider:M6.OPENAI,name:"gpt-5-codex",displayName:"GPT-5 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,tools:!0}},GPT_5_1_CODEX:{provider:M6.OPENAI,name:"gpt-5.1-codex",displayName:"GPT-5.1 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,tools:!0}},GPT_5_2_CODEX:{provider:M6.OPENAI,name:"gpt-5.2-codex",displayName:"GPT-5.2 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.75,output:14,cached:0.175},capabilities:{reasoning:!0,tools:!0,vision:!0}},GPT_5_3_CODEX:{provider:M6.OPENAI,name:"gpt-5.3-codex",displayName:"GPT-5.3 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.75,output:14,cached:0.175},capabilities:{reasoning:!0,tools:!0,vision:!0}},GPT_5_MINI:{provider:M6.OPENAI,name:"gpt-5-mini",displayName:"GPT-5 Mini",contextWindow:400000,maxOutputTokens:128000,pricing:{input:0.25,output:2,cached:0.025},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_NANO:{provider:M6.OPENAI,name:"gpt-5-nano",displayName:"GPT-5 Nano",contextWindow:400000,maxOutputTokens:128000,pricing:{input:0.05,output:0.4,cached:0.005},capabilities:{reasoning:!0,vision:!0,tools:!0}},O3:{provider:M6.OPENAI,name:"o3",displayName:"o3",contextWindow:200000,maxOutputTokens:1e5,pricing:{input:2,output:8,cached:0.5},capabilities:{reasoning:!0,tools:!0}},O3_MINI:{provider:M6.OPENAI,name:"o3-mini",displayName:"o3-mini",contextWindow:200000,maxOutputTokens:1e5,pricing:{input:1.1,output:4.4,cached:0.55},capabilities:{reasoning:!0,tools:!0}},GPT_OSS_120B:{provider:M6.OPENAI,name:"openai/gpt-oss-120b",displayName:"GPT OSS 120B",contextWindow:128000,maxOutputTokens:32000,capabilities:{reasoning:!0,tools:!0}},GROK_CODE_FAST_1:{provider:M6.XAI,name:"grok-code-fast-1",displayName:"Grok Code Fast 1",contextWindow:256000,maxOutputTokens:32000,capabilities:{reasoning:!0,tools:!0}},GEMINI_3_PRO_PREVIEW:{provider:M6.VERTEXAI,name:"gemini-3-pro-preview",displayName:"Gemini 3 Pro Preview",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI_3_1_PRO_PREVIEW:{provider:M6.VERTEXAI,name:"gemini-3.1-pro-preview",displayName:"Gemini 3.1 Pro Preview",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI3_FLASH_PREVIEW:{provider:M6.VERTEXAI,name:"gemini-3-flash-preview",displayName:"Gemini 3 Flash Preview",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI_3_PRO_IMAGE:{provider:M6.VERTEXAI,name:"gemini-3-pro-image-preview",displayName:"Gemini 3 Pro Image",contextWindow:1048576,maxOutputTokens:65535,capabilities:{vision:!0,imageGeneration:!0}},Z_AI_GLM_4_7:{provider:M6.CEREBRAS,name:"zai-glm-4.7",displayName:"Z.ai GLM 4.7",contextWindow:131000,maxOutputTokens:40000,capabilities:{tools:!0}},FIREWORKS_QWEN3_CODER_480B:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/qwen3-coder-480b-a35b-instruct",displayName:"Qwen3 Coder 480B",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_KIMI_K2_INSTRUCT:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/kimi-k2-instruct-0905",displayName:"Kimi K2 Instruct",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_QWEN3_235B:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/qwen3-235b-a22b-instruct-2507",displayName:"Qwen3 235B",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_GLM_4P6:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/glm-4p6",displayName:"GLM 4P6",contextWindow:162752,maxOutputTokens:40000,capabilities:{tools:!0,reasoning:!0}},FIREWORKS_GLM_5:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/glm-5",displayName:"GLM 5",contextWindow:202800,maxOutputTokens:40000,pricing:{input:1,output:3.2},capabilities:{tools:!0}},FIREWORKS_MINIMAX_M2P5:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/minimax-m2p5",displayName:"MiniMax M2.5",contextWindow:200000,maxOutputTokens:32000,pricing:{input:0.3,output:1.2,cached:0.03},capabilities:{tools:!0}},BASETEN_KIMI_K2P5:{provider:M6.BASENTEN,name:"moonshotai/Kimi-K2.5",displayName:"Kimi K2.5",contextWindow:262144,maxOutputTokens:32000,pricing:{input:0.6,output:3,cached:0.1},capabilities:{tools:!0,vision:!0}},KIMI_K2_INSTRUCT:{provider:M6.MOONSHOT,name:"kimi-k2-instruct-0905",displayName:"Kimi K2 Instruct",contextWindow:1e6,maxOutputTokens:32000,capabilities:{tools:!0}},SONOMA_SKY_ALPHA:{provider:M6.OPENROUTER,name:"sonoma-sky-alpha",displayName:"Sonoma Sky Alpha",contextWindow:256000,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_GLM_4_6:{provider:M6.OPENROUTER,name:"z-ai/glm-4.6",displayName:"OpenRouter GLM 4.6",contextWindow:131000,maxOutputTokens:40000,capabilities:{tools:!0}},OPENROUTER_KIMI_K2_0905:{provider:M6.OPENROUTER,name:"moonshotai/kimi-k2-0905",displayName:"Kimi K2 0905 (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_QWEN3_CODER_480B:{provider:M6.OPENROUTER,name:"qwen/qwen3-coder",displayName:"Qwen3 Coder 480B (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_QWEN3_235B:{provider:M6.OPENROUTER,name:"qwen/qwen3-235b-a22b-2507",displayName:"Qwen3 235B A22B (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}}};ZH0={FINDER:"finder"}});function QH0(J,Z){let Q=_2(Z);if(!Q)return!1;if(QV6.has(J)){let X=Q.finder??ZH0.FINDER,Y=XV6[X];if(J!==Y)return!1}if(Q.includeTools){if(Q.deferredTools?.includes(J))return!0;return Q.includeTools.includes(J)}return!0}function XH0(J,Z){let Q=_2(Z);if(!Q)return!1;return Q.deferredTools?.includes(J)??!1}function bQ(J,Z,Q){let X=J?.["internal.visibleModes"]??[],Y=J?.["experimental.modes"]??[],U=[...X,...Y],V=new Set(J?.disabledAgentModes??[]);return Object.values(NV).filter((D)=>{if(D.key===fa)return!1;if(U.includes(`!${D.key}`))return!1;if(Z===!1&&P8(D.key))return!1;if(V.has(D.key))return!1;if(Q?.v2&&!(("visibleInV2"in D)&&D.visibleInV2))return!1;let z="visible"in D?D.visible:!1,q=U.includes(D.key);return z||q}).map((D)=>({mode:D.key,description:"description"in D?D.description:void 0})).sort((D,K)=>D.mode.localeCompare(K.mode))}function _2(J){return Object.values(NV).find((Z)=>Z.key===J)}function hQ(J){return _2(J)?.primaryModel??_3("CLAUDE_SONNET_4_5")}function rv(J){let Z=_2(J);if(!Z)return!1;return i9(Z.primaryModel).capabilities?.vision??!1}function P8(J){return J==="free"||J.startsWith("free-")}function YH0(J,Z){return Z.find((Q)=>Q.mode===J)?.description}function UH0(J,Z){let X=(Z.findIndex((U)=>U.mode===J)+1)%Z.length;return Z[X]?.mode??"smart"}var QV6,XV6,SL1,vL1,YV6,UV6,TL1,_L1,VV6,DV6,KV6,NV,fa,zV6;var WJ=J0(()=>{t7();QV6=new Set(["finder"]),XV6={finder:"finder"},SL1={r:0,g:55,b:0},vL1={r:0,g:255,b:136},YV6=["Read","Grep","glob","finder","Bash","create_file","edit_file","format_file","get_diagnostics","web_search","read_web_page","task_list","read_thread","find_thread","mermaid","chart","skill"],UV6=["Read","Grep","glob","finder","Bash","create_file","edit_file","format_file","undo_edit","get_diagnostics","web_search","read_web_page","read_mcp_resource","mermaid","chart","read_thread","find_thread","skill","oracle","handoff","librarian","Task","task_list","look_at","painter"],TL1=["Read","finder","Bash","repl","create_file","edit_file","undo_edit","web_search","read_web_page","task_list","read_thread","find_thread","skill","oracle","librarian","Task","Grep","glob","read_mcp_resource","mermaid","chart","look_at","format_file","get_diagnostics","handoff","painter","restore_snapshot","slack_write","slack_read"],_L1=["code_review","walkthrough","walkthrough_diagram"],VV6=["code_review"],DV6=["find_thread","read_thread","docs_list","docs_read","docs_write","create_thread","slack_write","slack_read"],KV6=["shell_command","apply_patch","web_search","read_web_page","chart","mermaid","skill","read_thread","find_thread","librarian","finder","painter","handoff"],NV={SMART:{key:"smart",displayName:"Smart",description:"The most capable model and set of tools",primaryModel:_3("CLAUDE_OPUS_4_6"),includeTools:TL1,deferredTools:_L1,visible:!0,visibleInV2:!0,uiHints:{labelAnimation:"glow",primaryColor:{r:0,g:55,b:20},secondaryColor:{r:0,g:255,b:136}}},FREE:{key:"free",displayName:"Free",description:"Amp Free",primaryModel:_3("CLAUDE_HAIKU_4_5"),includeTools:YV6,visible:!0,uiHints:{primaryColor:{r:0,g:26,b:51},secondaryColor:{r:0,g:184,b:255}}},RUSH:{key:"rush",displayName:"Rush",description:"Faster and cheaper for small, well-defined tasks",primaryModel:_3("CLAUDE_HAIKU_4_5"),includeTools:UV6,visible:!0,uiHints:{fasterAnimation:!0,labelAnimation:"jitter",primaryColor:{r:128,g:51,b:0},secondaryColor:{r:255,g:215,b:0}}},AGG:{key:"agg-man",displayName:"Agg",description:"Query and summarize your Amp threads",primaryModel:_3("CLAUDE_OPUS_4_6"),includeTools:DV6,visible:!1,uiHints:{primaryColor:{r:26,g:0,b:77},secondaryColor:{r:102,g:153,b:255}}},LARGE:{key:"large",displayName:"Large",description:"The biggest context window possible (Sonnet 4.6 1M tokens), for large tasks",primaryModel:_3("CLAUDE_SONNET_4_6"),includeTools:TL1,deferredTools:_L1,visible:!1,uiHints:{labelAnimation:"glow",primaryColor:{r:42,g:26,b:77},secondaryColor:{r:153,g:102,b:255}}},DEEP:{key:"deep",displayName:"Deep",description:"Deep reasoning with GPT-5.3 Codex",primaryModel:_3("GPT_5_3_CODEX"),includeTools:KV6,deferredTools:VV6,visible:!0,visibleInV2:!0,reasoningEffort:"high",uiHints:{labelAnimation:"glow",primaryColor:{r:0,g:77,b:64},secondaryColor:{r:29,g:233,b:182}}}},fa=NV.AGG.key,zV6=Object.values(NV).map((J)=>J.key)});function ba(J,Z,Q){if(J.startsWith("mcp__"))return Z.allowMcp??!1;if(J.startsWith("tb__")){if(!(Z.allowToolbox??!1))return!1;let X="subagentType"in Z?Z.subagentType:void 0;if(X&&Q){if(!Q.subagentTypes)return!1;return Q.subagentTypes.includes("all")||Q.subagentTypes.includes(X)}return!0}return Z.includeTools.includes(J)}var VH0,kL1,qV6,DH0,FV6,GV6,WV6,KH0,h8,v$3;var wY=J0(()=>{t7();VH0=["read_github","search_github","commit_search","diff","list_directory_github","list_repositories","glob_github"],kL1=["read_bitbucket_enterprise","search_bitbucket_enterprise","commit_search_bitbucket_enterprise","diff_bitbucket_enterprise","list_directory_bitbucket_enterprise","list_repositories_bitbucket_enterprise","glob_bitbucket_enterprise"],qV6=["Grep","glob","Read"],DH0=["Read","Grep","glob","web_search","read_web_page","read_thread","find_thread"],FV6=["Grep","glob","Read","Bash","edit_file","create_file","format_file","read_web_page","get_diagnostics","web_search","finder","skill","task_list"],GV6=["Read","Grep","glob","web_search","read_web_page","Bash"],WV6=["Read","Grep","glob","Bash"],KH0=["Read","Grep","glob","finder"],h8={finder:{key:"finder",displayName:"Finder",model:_3("CLAUDE_HAIKU_4_5"),includeTools:qV6,allowMcp:!1,allowToolbox:!1},oracle:{key:"oracle",displayName:"Oracle",model:_3("GPT_5_2"),includeTools:DH0,allowMcp:!1,allowToolbox:!1},librarian:{key:"librarian",displayName:"Librarian",model:_3("CLAUDE_SONNET_4_6"),includeTools:VH0,allowMcp:!1,allowToolbox:!1},"task-subagent":{key:"task-subagent",displayName:"Task Subagent",model:void 0,includeTools:FV6,allowMcp:!0,allowToolbox:!0},"code-review":{key:"code-review",displayName:"Code Review",model:_3("CLAUDE_SONNET_4_5"),includeTools:GV6,allowMcp:!1,allowToolbox:!1},"codereview-check":{key:"codereview-check",displayName:"Codereview Check",model:_3("CLAUDE_HAIKU_4_5"),includeTools:WV6,allowMcp:!1,allowToolbox:!1}},v$3=Object.keys(h8)});function yL1(J,Z){return new v0((Q)=>{let X=setTimeout(Y,Z);function Y(){Q.error(Error(`Tool execution timed out after ${Z/1000} seconds`))}function U(){if(X)clearTimeout(X);X=setTimeout(Y,Z)}let V=J.subscribe({next:(D)=>{U(),Q.next(D)},error:(D)=>{if(X)clearTimeout(X),X=null;Q.error(D)},complete:()=>{if(X)clearTimeout(X),X=null;Q.complete()}});return()=>{if(X)clearTimeout(X),X=null;V.unsubscribe()}})}var uL1=J0(()=>{H1()});function fL1(J){return{tool:J,action:"allow"}}function HV6(J){if(!J||!("cmd"in J))return J;let{cmd:Z,...Q}=J;return{...Q,command:Z}}function BV6(J){return J.flatMap((Z)=>{if(Z.tool!==g6)return[];return[{...Z,tool:GZ,matches:HV6(Z.matches)}]})}var xL1,uM;var ha=J0(()=>{w4();xL1=[{tool:"Bash",action:"ask",matches:{cmd:"*git*push*"}},{tool:"mcp__*",action:"allow"},{tool:Oa,action:"allow"},{tool:"tb__*",action:"allow"},{tool:"Bash",matches:{cmd:"/^(.*\\s+)?(bazel|ibazel)\\s+.*\\/\\/[^\\s]*.*$/"},action:"allow"},{tool:"Bash",matches:{cmd:["ls","ls *","dir","dir *","cat *","head *","tail *","less *","more *","grep *","egrep *","fgrep *","tree","tree *","file *","wc *","pwd","stat *","du *","df *","ps *","top","htop","echo *","printenv *","id","which *","whereis *","date","cal *","uptime","free *","ping *","dig *","nslookup *","host *","netstat *","ss *","lsof *","ifconfig *","ip *","man *","info *","mkdir *","touch *","uname *","whoami","go version","go env *","go help *","cargo version","cargo --version","cargo help *","rustc --version","rustc --help","rustc --explain *","javac --version","javac -version","javac -help","javac --help","dotnet --info","dotnet --version","dotnet --help","dotnet help *","gcc --version","gcc -v","gcc --help","gcc -dumpversion","g++ --version","g++ -v","g++ --help","g++ -dumpversion","clang --version","clang --help","clang++ --version","clang++ --help","python -V","python --version","python -h","python --help","python3 -V","python3 --version","python3 -h","python3 --help","ruby -v","ruby --version","ruby -h","ruby --help","node -v","node --version","node -h","node --help","npm --help","npm --version","npm -v","npm help *","yarn --help","yarn --version","yarn -v","yarn help *","pnpm --help","pnpm --version","pnpm -v","pnpm help *","pytest -h","pytest --help","pytest --version","jest --help","jest --version","mocha --help","mocha --version","make --version","make --help","docker --version","docker --help","docker version","docker help *","git --version","git --help","git help *","git version"]},action:"allow"},{tool:"Bash",matches:{cmd:["go test *","go run *","go build *","go vet *","go fmt *","go list *","cargo test *","cargo run *","cargo build *","cargo check *","cargo fmt *","cargo tree *","make -n *","make --dry-run *","mvn test *","mvn verify *","mvn dependency:tree *","gradle tasks *","gradle dependencies *","gradle properties *","dotnet test *","dotnet list *","python -c *","ruby -e *","node -e *","npm list *","npm ls *","npm outdated *","npm test*","npm run*","npm view *","npm info *","yarn list*","yarn ls *","yarn info *","yarn test*","yarn run *","yarn why *","pnpm list*","pnpm ls *","pnpm outdated *","pnpm test*","pnpm run *","pytest --collect-only *","jest --listTests *","jest --showConfig *","mocha --list *","git status*","git show *","git diff*","git grep *","git branch *","git tag *","git remote -v *","git rev-parse --is-inside-work-tree *","git rev-parse --show-toplevel *","git config --list *","git log *"]},action:"allow"},{tool:"Bash",matches:{cmd:["./gradlew *","./mvnw *","./build.sh *","./configure *","cmake *","./node_modules/.bin/tsc *","./node_modules/.bin/eslint *","./node_modules/.bin/prettier *","prettier *","./node_modules/.bin/tailwindcss *","./node_modules/.bin/tsx *","./node_modules/.bin/vite *","bun *","tsx *","vite *"]},action:"allow"},{tool:"Bash",matches:{cmd:[".venv/bin/activate *",".venv/Scripts/activate *","source .venv/bin/activate *","source venv/bin/activate *","pip list *","pip show *","pip check *","pip freeze *","uv *","poetry show *","poetry check *","pipenv check *"]},action:"allow"},{tool:"Bash",matches:{cmd:["asdf list *","asdf current *","asdf which *","mise list *","mise current *","mise which *","mise use *","rbenv version *","rbenv versions *","rbenv which *","nvm list *","nvm current *","nvm which *"]},action:"allow"},{tool:"Bash",matches:{cmd:["./test*","./run_tests.sh *","./run_*_tests.sh *","vitest *","bundle exec rspec *","bundle exec rubocop *","rspec *","rubocop *","swiftlint *","clippy *","ruff *","black *","isort *","mypy *","flake8 *","bandit *","safety *","biome check *","biome format *"]},action:"allow"},{tool:"Bash",matches:{cmd:["rails server *","rails s *","bin/rails server *","bin/rails s *","flask run *","django-admin runserver *","python manage.py runserver *","uvicorn *","streamlit run *"]},action:"allow"},{tool:"Bash",matches:{cmd:["bin/rails db:status","bin/rails db:version","rails db:rollback *","rails db:status *","rails db:version *","alembic current *","alembic history *","bundle exec rails db:status","bundle exec rails db:version"]},action:"allow"},{tool:"Bash",matches:{cmd:["docker ps *","docker images *","docker logs *","docker inspect *","docker info *","docker stats *","docker system df *","docker system info *","podman ps *","podman images *","podman logs *","podman inspect *","podman info *"]},action:"allow"},{tool:"Bash",matches:{cmd:["aws --version *","aws configure list *","aws sts get-caller-identity *","aws s3 ls *","gcloud config list *","gcloud auth list *","gcloud projects list *","az account list *","az account show *","kubectl get *","kubectl describe *","kubectl logs *","kubectl version *","helm list *","helm status *","helm version *"]},action:"allow"},{tool:"Bash",matches:{cmd:["swift build *","swift test *","zig build *","zig build test*","kotlinc *","scalac *","javac *","javap *","clang *","jar *","sbt *","gradle *","bazel build *","bazel test *","bazel run *","mix *","lua *","ruby *","php *"]},action:"allow"},{tool:"Bash",matches:{cmd:["mkdir -p *","chmod +x *","dos2unix *","unix2dos *","ln -s *"]},action:"allow"},{tool:"Bash",matches:{cmd:["for *","while *","do *","done *","if *","then *","else *","elif *","fi *","case *","esac *","in *","function *","select *","until *","{ *","} *","[[ *","]] *"]},action:"ask"},{tool:"Bash",matches:{cmd:"/^find(?!.*(-delete|-exec|-execdir)).*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(echo|ls|pwd|date|whoami|id|uname)\\s.*[&|;].*\\s*(echo|ls|pwd|date|whoami|id|uname)($|\\s.*)/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(cat|grep|head|tail|less|more|find)\\s.*\\|\\s*(grep|head|tail|less|more|wc|sort|uniq)($|\\s.*)/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^rm\\s+.*(-[rf].*-[rf]|-[rf]{2,}|--recursive.*--force|--force.*--recursive).*$/"},action:"ask"},{tool:"Bash",matches:{cmd:"/^find.*(-delete|-exec|-execdir).*$/"},action:"ask"},{tool:"Bash",matches:{cmd:"/^(ls|cat|grep|head|tail|file|stat)\\s+[^/]*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(?!.*(rm|mv|cp|chmod|chown|sudo|su|dd)\\b).*/dev/(null|zero|stdout|stderr|stdin).*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/(^|\\s)(\\/(?!dev\\/(null|zero|stdout|stderr|stdin))[^\\s]*|\\.\\.\\/)(?![^\\s]*\\.(log|txt|md|json|yml|yaml)$)/"},action:"ask"},{tool:"Bash",action:"ask"},fL1("Glob")],uM=[...xL1,...BV6(xL1),...YL1.map(fL1)]});var J4=J0(()=>{Sv();Ja();LM()});function FH0(J){let Z=J;if(Z.startsWith("~/")){let Q=process.env.HOME||process.env.USERPROFILE||"";Z=Z.replace("~/",`${Q}/`)}else if(Z==="~")Z=process.env.HOME||process.env.USERPROFILE||"";if(Z=Z.replace(/%([^%]+)%/g,(Q,X)=>{return process.env[X]||`%${X}%`}),Z.includes("%USERPROFILE%")&&process.env.USERPROFILE)Z=Z.replace(/%USERPROFILE%/g,process.env.USERPROFILE);return q1.file(Z)}function zH0(J,Z){let Q=FH0(Z);if(Q.path.includes("*")){let X=J.toString(),Y=Q.path;if(!Y.startsWith("file://")){if(!Y.startsWith("/"))Y=`/${Y}`;Y=`file://${Y}`}let U=Y.replace(/\./g,"\\.").replace(/\*\*/g,"§DOUBLESTAR§").replace(/\*/g,"[^/]*").replace(/§DOUBLESTAR§/g,".*");return new RegExp(`^${U}$`,"i").test(X)}else return Q.toString().toLowerCase()===J.toString().toLowerCase()}function bL1(J,Z){return Z.some((Q)=>zH0(J,Q))}async function wV6(J,Z){try{return await Z.realpath(J)}catch{}let Q=[],X=J;while(!0){let Y=V1.dirname(X);if(Y.toString()===X.toString())break;Q.unshift(V1.basename(X)),X=Y;try{let V=await Z.realpath(X);for(let D of Q)V=V1.joinPath(V,D);return V}catch{}}return J}async function NV6(J,Z,Q){try{let X=await wV6(J,Z),U=[...["~/.config/AGENT.md"],...Q];for(let V of U)if(zH0(X,V)||zH0(J,V))return null;for(let{key:V,pattern:D}of qH0)if(bL1(X,D.patterns)||bL1(J,D.patterns))return{key:V,pattern:D};return null}catch{return null}}async function GH0(J,Z,Q){if(Q?.dangerouslyAllowAll??!1)return{requiresConsent:!1};try{let Y=await NV6(J,Z,Q["guardedFiles.allowlist"]??[]);if(Y)return{requiresConsent:!0,reason:`${Y.pattern.description}`,toAllow:J.fsPath};return{requiresConsent:!1}}catch{return{requiresConsent:!0,reason:"Unable to resolve file path",toAllow:J.fsPath}}}var qH0;var ma=J0(()=>{J4();qH0=[{key:"vscode-user-settings",pattern:{description:"VS Code User Settings",patterns:["~/Library/Application Support/Code/User/settings.json","~/.config/Code/User/settings.json","%APPDATA%/Code/User/settings.json"]}},{key:"vscode-workspace-config",pattern:{description:"VS Code Workspace Configuration",patterns:["**/.vscode/**"]}},{key:"vscode-workspace-files",pattern:{description:"VS Code Workspace Files",patterns:["**/*.code-workspace"]}},{key:"cursor-config",pattern:{description:"Cursor Configuration",patterns:["**/.cursor/**","~/.cursor/**","~/Library/Application Support/Cursor/**","~/.config/Cursor/**","%APPDATA%/Cursor/**"]}},{key:"windsurf-config",pattern:{description:"Windsurf Configuration",patterns:["**/.windsurf/**","~/.codeium/windsurf/**","~/Library/Application Support/Windsurf/**","~/.config/Windsurf/**","%APPDATA%/Windsurf/**","/Library/Application Support/Windsurf/**","/etc/windsurf/**","%ProgramData%/Windsurf/**"]}},{key:"antigravity-config",pattern:{description:"Antigravity Configuration",patterns:["~/.gemini/**"]}},{key:"jetbrains-config",pattern:{description:"JetBrains IDE Configuration",patterns:["~/Library/Application Support/JetBrains/**","~/.config/JetBrains/**","~/.local/share/JetBrains/**","%APPDATA%/JetBrains/**","%LOCALAPPDATA%/JetBrains/**"]}},{key:"jetbrains-idea-config",pattern:{description:"JetBrains IDE Project Configuration",patterns:["**/.idea/**"]}},{key:"neovim-config",pattern:{description:"Neovim Configuration",patterns:["~/.config/nvim/**","~/.local/share/nvim/**","~/.local/state/nvim/**"]}},{key:"amp-settings",pattern:{description:"Amp Configuration Files",patterns:["**/amp.json","**/.amp/**"]}},{key:"shell-configs",pattern:{description:"Shell Configuration Files",patterns:["~/.bashrc","~/.zshrc","~/.fishrc","~/.cshrc","~/.tcshrc"]}},{key:"ssh-keys",pattern:{description:"SSH Keys and Configuration",patterns:["**/.ssh/**","~/.ssh/**"]}},{key:"gnupg-keys",pattern:{description:"GnuPG Keys and Configuration",patterns:["**/.gnupg/**","~/.gnupg/**"]}},{key:"environment-files",pattern:{description:"Environment Variable Files",patterns:["**/.env","**/.env.*"]}},{key:"claude-config",pattern:{description:"Claude AI Configuration",patterns:["**/.claude/**","~/.claude/**"]}},{key:"codex-config",pattern:{description:"Codex Configuration",patterns:["**/.codex/**","~/.codex/**"]}},{key:"git-internals",pattern:{description:"Git Internal Files",patterns:["**/.git/**"]}},{key:"kubernetes-config",pattern:{description:"Kubernetes Configuration",patterns:["**/.kube/**","~/.kube/**"]}},{key:"cache-directories",pattern:{description:"Cache Directories",patterns:["**/.cache/**","~/.cache/**"]}},{key:"windows-appdata",pattern:{description:"Windows Application Data",patterns:["%APPDATA%/**"]}},{key:"windows-system-directories",pattern:{description:"Windows System Directories",patterns:["%WINDIR%/**","%SYSTEMROOT%/**","%ProgramFiles%/**","%ProgramFiles(x86)%/**","%ProgramData%/**"]}},{key:"sqlite3-files",pattern:{description:"SQLite Database Files",patterns:["**/*.db","**/*.sqlite","**/*.sqlite3"]}},{key:"common-configuration-patterns",pattern:{description:"Configuration Directories",patterns:["~/.*","~/.*/**","~/.config/**","~/Library/**","~/Library/Preferences/**"]}},{key:"macos-applications",pattern:{description:"macOS Applications",patterns:["/Applications/**","~/Applications/**"]}},{key:"macos-system-library",pattern:{description:"macOS System Library",patterns:["/Library/**"]}},{key:"unix-system-directories",pattern:{description:"Unix System Directories",patterns:["/usr/**","/bin/**","/sbin/**","/lib/**","/lib64/**","/boot/**"]}},{key:"system-config-directories",pattern:{description:"System Configuration and State",patterns:["/private/etc/**","/etc/**","/private/var/**","/var/**"]}},{key:"opt-directory",pattern:{description:"Optional Software Installs (/opt, e.g., Homebrew)",patterns:["/opt/**"]}}]});function OV6(){if(Pw.size===0)return;P.info("Killing all child processes");for(let J of Pw)hL1(J);Pw.clear(),P.info("All child processes killed")}function hL1(J){if(!J.pid){try{J.kill("SIGKILL")}catch(Z){P.error("Failed to kill process without PID",Z)}return}if(sv.has(J.pid)){P.debug(`Process ${J.pid} already being killed, skipping`);return}sv.add(J.pid);try{if(process.platform==="win32"){let{spawn:Z}=P0("node:child_process"),Q=Z("taskkill",["/F","/T","/PID",J.pid.toString()],{stdio:"ignore"});Q.on("error",(X)=>{P.error(`Failed to kill Windows process tree ${J.pid}`,X);try{J.kill("SIGKILL")}catch(Y){P.error(`Fallback kill also failed for ${J.pid}`,Y)}}),Q.on("exit",()=>{sv.delete(J.pid)})}else{try{process.kill(J.pid,0),process.kill(-J.pid,"SIGKILL")}catch(Z){P.debug(`Process ${J.pid} no longer exists, skipping kill`)}sv.delete(J.pid)}}catch(Z){P.error(`Failed to kill process ${J.pid}`,Z),sv.delete(J.pid)}}function NY(...J){return new v0((Z)=>{let Q=!1,X,Y=!1;return(async()=>{try{let{spawn:V}=await import("node:child_process");if(Q)return;let D={...J[2],detached:process.platform!=="win32",env:{...process.env,...J[2]?.env||{},NONINTERACTIVE:"1",DEBIAN_FRONTEND:"noninteractive"}};if(!D.stdio)D.stdio=["pipe","pipe","pipe"];X=V(J[0],J[1],D),Pw.add(X);let K={stdout:"",stderr:"",combinedOutput:"",exitCode:null,exited:!1,pid:X.pid};X.on("spawn",()=>{Z.next({...K,process:X})}),X.stdout?.on("data",(z)=>{if(Q)return;let q=z.toString();K.stdout+=q,K.combinedOutput+=q,K.lastData=z,Z.next({...K,process:X})}),X.stderr?.on("data",(z)=>{if(Q)return;let q=z.toString();K.stderr+=q,K.combinedOutput+=q,K.lastData=z,Z.next({...K,process:X})}),X.on("exit",(z)=>{if(Q)return;if(Y)return;if(Y=!0,K.exitCode=z??-1,K.exited=!0,K.lastData=void 0,Z.next({...K,process:X}),Z.complete(),X)Pw.delete(X)}),X.on("error",(z)=>{if(Q)return;if(Z.error(z),X)Pw.delete(X)})}catch(V){if(Q)return;Z.error(V)}})(),()=>{if(Q=!0,X&&!Y)hL1(X),Pw.delete(X)}})}function ga(J){if(typeof J!=="string")throw Error("arg is not a string");if(J.startsWith("-"))throw Error("arg is not safe")}function OV(J){if(!J)throw Error("tool requires a working directory");if(J.scheme!=="file"&&J.scheme!=="vscode-vfs")throw Error(`tool requires a dir with a file: URI (got ${JSON.stringify(J.scheme)})`)}var Pw,sv;var mQ=J0(()=>{H1();m0();Pw=new Set,sv=new Set;if(typeof process<"u")process.on("exit",()=>{OV6()})});function mK(J,Z){if(Z==="")return!1;let Q=J.toLowerCase(),X=Z.toLowerCase();if(X.length===1){if(X==="*")return!0;return X===Q}if(Q===X)return!0;if(X.includes("*")||X.includes("?")||X.includes("[")||X.includes("{"))try{return mL1.default(X,{dot:!0})(Q)}catch(Y){return!1}return!1}function WH0(J,Z){let Q=Z.split("."),X=J;for(let Y of Q){if(X===null||X===void 0)return;if(Array.isArray(X)){let U=parseInt(Y,10);if(isNaN(U)||U<0||U>=X.length)return;X=X[U]}else if(typeof X==="object")X=X[Y];else return}return X}function EV6(J,Z,Q,X){if(!mK(Z,J.tool))return!1;if(J.context&&J.context!==X)return!1;if(!J.matches||Object.keys(J.matches).length===0)return!0;return Object.entries(J.matches).every(([Y,U])=>{if(U===void 0){if(Y.includes("."))return WH0(Q,Y)===void 0;return Y in Q&&Q[Y]===void 0}let V=Y.includes(".")?WH0(Q,Y):Q[Y];return pa(V,U)})}async function LV6(J,Z,Q,X,Y,U){if(J.action!=="delegate"){if(J.action==="reject"&&J.message)return{action:J.action,matchedEntry:J,error:J.message};return{action:J.action,matchedEntry:J}}if(!Q||!J.to)return{action:null,matchedEntry:J,error:"No spawn function provided"};try{let V=await IV6(J.to,Z,Q,X,Y,U);return MV6(V,J)}catch(V){return{action:"reject",error:V instanceof Error?V.message:"Unknown error",matchedEntry:J}}}async function IV6(J,Z,Q,X,Y,U){let V={AGENT:"amp"};if(X)V.AMP_THREAD_ID=X;if(Y)V.AGENT_TOOL_NAME=Y;if(U)V.AGENT_TOOL_USE_ID=U;let K=J.includes("~")||J.includes("%")?FH0(J).path:J,q=Q(K,[],{env:V});return new Promise((F,G)=>{let W;q.subscribe({next:(H)=>{if(typeof H==="object"&&H!==null&&"status"in H&&H.status==="error"){G(Error("Delegate command timed out after 10 seconds"));return}if(H.process&&!H.exited)H.process.stdin?.write(JSON.stringify(Z)),H.process.stdin?.end();W=H},complete:()=>{if(W?.exited)F({exitCode:W.exitCode??-1,stdout:W.stdout,stderr:W.stderr});else G(Error("Process did not exit properly"))},error:(H)=>{G(H)}})})}function MV6({exitCode:J,stderr:Z},Q){switch(J){case 0:return{action:"allow",matchedEntry:Q};case 1:return{action:"ask",matchedEntry:Q};default:return{action:"reject",matchedEntry:Q,error:Z}}}async function xM(J,Z,Q,X,Y,U,V,D){let K=0;for(let z of Q)try{if(!EV6(z,J,Z,X)){K=K+1;continue}let q=await LV6(z,Z,Y,U,J,D);if(q.matchIndex=K,V)q.source=V;return q}catch(q){return{action:null,error:q instanceof Error?q.message:"Unknown error"}}return{action:null}}function pa(J,Z){if(typeof Z==="string"){if(typeof J!=="string")return!1;return jV6(J,Z)}if(Array.isArray(Z))return Z.some((Q)=>{if(typeof Q==="string")return typeof J==="string"&&HH0(J,Q);return J===Q});if(typeof Z==="object"&&Z!==null)return AV6(J,Z);return J===Z}function AV6(J,Z){if(Object.keys(Z).length===0)return typeof J==="object"&&J!==null;if(typeof J!=="object"||J===null)return!1;for(let[Q,X]of Object.entries(Z)){let Y=WH0(J,Q);if(!pa(Y,X))return!1}return!0}function jV6(J,Z){if(typeof Z==="string")return HH0(J,Z);if(Array.isArray(Z))return Z.some((Q)=>typeof Q==="string"&&HH0(J,Q));return!1}function HH0(J,Z){if(Z.length>=3&&Z.startsWith("/")&&Z.endsWith("/"))try{let Y=Z.slice(1,-1);return new RegExp(Y,"m").test(J)}catch(Y){throw Error(`Invalid regex pattern: ${Z}`)}if(Z==="*")return!0;if(!Z.includes("*"))return J===Z;let Q=Z.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${Q}$`,"m").test(J)}var mL1,tv;var Cw=J0(()=>{ma();mQ();mL1=H4(hK(),1),tv=NY});class gL1{input;position=0;line=1;column=1;tokens=[];constructor(J){this.input=J}current(){return this.position<this.input.length?this.input[this.position]:""}peek(){return this.position+1<this.input.length?this.input[this.position+1]:""}advance(){let J=this.current();if(this.position++,J===`
94
+ *** End Patch`);if(D===-1)throw Error('Invalid patch format: missing *** Begin Patch marker. Patch must start with "*** Begin Patch"');if(K===-1)throw Error('Invalid patch format: missing *** End Patch marker. Patch must end with "*** End Patch"');if(K<D)throw Error("Invalid patch format: *** End Patch appears before *** Begin Patch. Check marker ordering.");let z=Q.slice(0,D).filter((W)=>W.trim()!=="");if(z.length>0)Y.push(`Warning: ${z.length} non-empty line(s) before *** Begin Patch were ignored. First ignored: "${z[0].slice(0,40)}${z[0].length>40?"...":""}"`);let q=Q.findIndex((W,H)=>H>D&&W.trim()==="*** Begin Patch");if(q!==-1&&q<K)Y.push(`Warning: duplicate "*** Begin Patch" found at line ${q+1}. Only the first marker is used.`);let F=Q.slice(K+1).filter((W)=>W.trim()!=="");if(F.length>0)Y.push(`Warning: ${F.length} non-empty line(s) after *** End Patch were ignored. First ignored: "${F[0].slice(0,40)}${F[0].length>40?"...":""}"`);let G=D+1;while(G<K){let W=LU6(Q,G);if(!W){G++;continue}let H=Q[G];if(H.startsWith("*** Add File:")){let{content:B,nextIdx:w}=IU6(Q,W.nextIdx);X.push({type:"add",path:W.filePath,contents:B}),G=w}else if(H.startsWith("*** Delete File:"))X.push({type:"delete",path:W.filePath}),G=W.nextIdx;else if(H.startsWith("*** Update File:")){let{chunks:B,nextIdx:w}=MU6(Q,W.nextIdx);X.push({type:"update",path:W.filePath,movePath:W.movePath,chunks:B}),G=w}else G++}return{hunks:X,warnings:Y.length>0?Y:void 0}}var lv="run_terminal_command",cW0="read_file",U9="Task",FZ="task_list",c3="finder",HV="get_diagnostics",g6="Bash",GZ="shell_command",H7="oracle",_M="mermaid",jw="chart",iE1="walkthrough",Na="walkthrough_diagram",nE1="todo_write",BY="read_web_page",fK="read_thread",Rw="find_thread",l3="create_file",RF="glob",SM="undo_edit",Oa="read_mcp_resource",w6="Read",T3="edit_file",Ea="format_file",PF="web_search",i3="Grep",aE1="docs_list",oE1="docs_read",rE1="docs_write",La="code_review",WZ="librarian",Ia="look_at",Ma="read_github",Aa="search_github",ja="commit_search",Ra="list_directory_github",Pa="list_repositories",Ca="glob_github",Ta="diff",sE1="read_bitbucket_enterprise",tE1="list_directory_bitbucket_enterprise",eE1="list_repositories_bitbucket_enterprise",$L1="glob_bitbucket_enterprise",JL1="search_bitbucket_enterprise",ZL1="diff_bitbucket_enterprise",QL1="commit_search_bitbucket_enterprise",s7="skill",_a="repl",vM="handoff",Sa="painter",bK="apply_patch",XL1="restore_snapshot",lW0="slack_write",iW0="slack_read",YL1;var w4=J0(()=>{YL1=["Task","task_list","finder","get_diagnostics","Bash","shell_command","oracle","mermaid","chart","walkthrough","walkthrough_diagram","read_web_page","create_file","glob","Glob","undo_edit","Read","edit_file","delete_file","format_file","web_search","Grep","search_documents","get_document","docs_list","docs_read","docs_write","code_review","look_at","librarian","read_thread","find_thread","skill","read_github","search_github","commit_search","list_directory_github","list_repositories","glob_github","diff","read_bitbucket_enterprise","list_directory_bitbucket_enterprise","list_repositories_bitbucket_enterprise","glob_bitbucket_enterprise","search_bitbucket_enterprise","diff_bitbucket_enterprise","commit_search_bitbucket_enterprise","handoff","painter","apply_patch","restore_snapshot","thread_status","create_thread"]});var iv=y((L$3,VL1)=>{var UL1={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)",SEP:"/"},jU6={...UL1,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},RU6={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};VL1.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:RU6,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(J){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${J.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(J){return J===!0?jU6:UL1}}});var nv=y((SU6)=>{var{REGEX_BACKSLASH:PU6,REGEX_REMOVE_BACKSLASH:CU6,REGEX_SPECIAL_CHARS:TU6,REGEX_SPECIAL_CHARS_GLOBAL:_U6}=iv();SU6.isObject=(J)=>J!==null&&typeof J==="object"&&!Array.isArray(J);SU6.hasRegexChars=(J)=>TU6.test(J);SU6.isRegexChar=(J)=>J.length===1&&SU6.hasRegexChars(J);SU6.escapeRegex=(J)=>J.replace(_U6,"\\$1");SU6.toPosixSlashes=(J)=>J.replace(PU6,"/");SU6.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let J=navigator.platform.toLowerCase();return J==="win32"||J==="windows"}if(typeof process<"u"&&process.platform)return process.platform==="win32";return!1};SU6.removeBackslashes=(J)=>{return J.replace(CU6,(Z)=>{return Z==="\\"?"":Z})};SU6.escapeLast=(J,Z,Q)=>{let X=J.lastIndexOf(Z,Q);if(X===-1)return J;if(J[X-1]==="\\")return SU6.escapeLast(J,Z,X-1);return`${J.slice(0,X)}\\${J.slice(X)}`};SU6.removePrefix=(J,Z={})=>{let Q=J;if(Q.startsWith("./"))Q=Q.slice(2),Z.prefix="./";return Q};SU6.wrapOutput=(J,Z={},Q={})=>{let X=Q.contains?"":"^",Y=Q.contains?"":"$",U=`${X}(?:${J})${Y}`;if(Z.negated===!0)U=`(?:^(?!${U}).*$)`;return U};SU6.basename=(J,{windows:Z}={})=>{let Q=J.split(Z?/[\\/]/:"/"),X=Q[Q.length-1];if(X==="")return Q[Q.length-2];return X}});var wL1=y((M$3,BL1)=>{var zL1=nv(),{CHAR_ASTERISK:nW0,CHAR_AT:gU6,CHAR_BACKWARD_SLASH:av,CHAR_COMMA:pU6,CHAR_DOT:aW0,CHAR_EXCLAMATION_MARK:oW0,CHAR_FORWARD_SLASH:HL1,CHAR_LEFT_CURLY_BRACE:rW0,CHAR_LEFT_PARENTHESES:sW0,CHAR_LEFT_SQUARE_BRACKET:dU6,CHAR_PLUS:cU6,CHAR_QUESTION_MARK:qL1,CHAR_RIGHT_CURLY_BRACE:lU6,CHAR_RIGHT_PARENTHESES:FL1,CHAR_RIGHT_SQUARE_BRACKET:iU6}=iv(),GL1=(J)=>{return J===HL1||J===av},WL1=(J)=>{if(J.isPrefix!==!0)J.depth=J.isGlobstar?1/0:1},nU6=(J,Z)=>{let Q=Z||{},X=J.length-1,Y=Q.parts===!0||Q.scanToEnd===!0,U=[],V=[],D=[],K=J,z=-1,q=0,F=0,G=!1,W=!1,H=!1,B=!1,w=!1,N=!1,O=!1,E=!1,L=!1,I=!1,M=0,A,R,_={value:"",depth:0,isGlob:!1},k=()=>z>=X,u=()=>K.charCodeAt(z+1),h=()=>{return A=R,K.charCodeAt(++z)};while(z<X){R=h();let l;if(R===av){if(O=_.backslashes=!0,R=h(),R===rW0)N=!0;continue}if(N===!0||R===rW0){M++;while(k()!==!0&&(R=h())){if(R===av){O=_.backslashes=!0,h();continue}if(R===rW0){M++;continue}if(N!==!0&&R===aW0&&(R=h())===aW0){if(G=_.isBrace=!0,H=_.isGlob=!0,I=!0,Y===!0)continue;break}if(N!==!0&&R===pU6){if(G=_.isBrace=!0,H=_.isGlob=!0,I=!0,Y===!0)continue;break}if(R===lU6){if(M--,M===0){N=!1,G=_.isBrace=!0,I=!0;break}}}if(Y===!0)continue;break}if(R===HL1){if(U.push(z),V.push(_),_={value:"",depth:0,isGlob:!1},I===!0)continue;if(A===aW0&&z===q+1){q+=2;continue}F=z+1;continue}if(Q.noext!==!0){if((R===cU6||R===gU6||R===nW0||R===qL1||R===oW0)===!0&&u()===sW0){if(H=_.isGlob=!0,B=_.isExtglob=!0,I=!0,R===oW0&&z===q)L=!0;if(Y===!0){while(k()!==!0&&(R=h())){if(R===av){O=_.backslashes=!0,R=h();continue}if(R===FL1){H=_.isGlob=!0,I=!0;break}}continue}break}}if(R===nW0){if(A===nW0)w=_.isGlobstar=!0;if(H=_.isGlob=!0,I=!0,Y===!0)continue;break}if(R===qL1){if(H=_.isGlob=!0,I=!0,Y===!0)continue;break}if(R===dU6){while(k()!==!0&&(l=h())){if(l===av){O=_.backslashes=!0,h();continue}if(l===iU6){W=_.isBracket=!0,H=_.isGlob=!0,I=!0;break}}if(Y===!0)continue;break}if(Q.nonegate!==!0&&R===oW0&&z===q){E=_.negated=!0,q++;continue}if(Q.noparen!==!0&&R===sW0){if(H=_.isGlob=!0,Y===!0){while(k()!==!0&&(R=h())){if(R===sW0){O=_.backslashes=!0,R=h();continue}if(R===FL1){I=!0;break}}continue}break}if(H===!0){if(I=!0,Y===!0)continue;break}}if(Q.noext===!0)B=!1,H=!1;let f=K,S="",x="";if(q>0)S=K.slice(0,q),K=K.slice(q),F-=q;if(f&&H===!0&&F>0)f=K.slice(0,F),x=K.slice(F);else if(H===!0)f="",x=K;else f=K;if(f&&f!==""&&f!=="/"&&f!==K){if(GL1(f.charCodeAt(f.length-1)))f=f.slice(0,-1)}if(Q.unescape===!0){if(x)x=zL1.removeBackslashes(x);if(f&&O===!0)f=zL1.removeBackslashes(f)}let m={prefix:S,input:J,start:q,base:f,glob:x,isBrace:G,isBracket:W,isGlob:H,isExtglob:B,isGlobstar:w,negated:E,negatedExtglob:L};if(Q.tokens===!0){if(m.maxDepth=0,!GL1(R))V.push(_);m.tokens=V}if(Q.parts===!0||Q.tokens===!0){let l;for(let g=0;g<U.length;g++){let n=l?l+1:q,d=U[g],$0=J.slice(n,d);if(Q.tokens){if(g===0&&q!==0)V[g].isPrefix=!0,V[g].value=S;else V[g].value=$0;WL1(V[g]),m.maxDepth+=V[g].depth}if(g!==0||$0!=="")D.push($0);l=d}if(l&&l+1<J.length){let g=J.slice(l+1);if(D.push(g),Q.tokens)V[V.length-1].value=g,WL1(V[V.length-1]),m.maxDepth+=V[V.length-1].depth}m.slashes=U,m.parts=D}return m};BL1.exports=nU6});var EL1=y((A$3,OL1)=>{var va=iv(),BV=nv(),{MAX_LENGTH:ka,POSIX_REGEX_SOURCE:aU6,REGEX_NON_SPECIAL_CHARS:oU6,REGEX_SPECIAL_CHARS_BACKREF:rU6,REPLACEMENTS:NL1}=va,sU6=(J,Z)=>{if(typeof Z.expandRange==="function")return Z.expandRange(...J,Z);J.sort();let Q=`[${J.join("-")}]`;try{new RegExp(Q)}catch(X){return J.map((Y)=>BV.escapeRegex(Y)).join("..")}return Q},kM=(J,Z)=>{return`Missing ${J}: "${Z}" - use "\\\\${Z}" to match literal characters`},tW0=(J,Z)=>{if(typeof J!=="string")throw TypeError("Expected a string");J=NL1[J]||J;let Q={...Z},X=typeof Q.maxLength==="number"?Math.min(ka,Q.maxLength):ka,Y=J.length;if(Y>X)throw SyntaxError(`Input length: ${Y}, exceeds maximum allowed length: ${X}`);let U={type:"bos",value:"",output:Q.prepend||""},V=[U],D=Q.capture?"":"?:",K=va.globChars(Q.windows),z=va.extglobChars(K),{DOT_LITERAL:q,PLUS_LITERAL:F,SLASH_LITERAL:G,ONE_CHAR:W,DOTS_SLASH:H,NO_DOT:B,NO_DOT_SLASH:w,NO_DOTS_SLASH:N,QMARK:O,QMARK_NO_DOT:E,STAR:L,START_ANCHOR:I}=K,M=(H0)=>{return`(${D}(?:(?!${I}${H0.dot?H:q}).)*?)`},A=Q.dot?"":B,R=Q.dot?O:E,_=Q.bash===!0?M(Q):L;if(Q.capture)_=`(${_})`;if(typeof Q.noext==="boolean")Q.noextglob=Q.noext;let k={input:J,index:-1,start:0,dot:Q.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:V};J=BV.removePrefix(J,k),Y=J.length;let u=[],h=[],f=[],S=U,x,m=()=>k.index===Y-1,l=k.peek=(H0=1)=>J[k.index+H0],g=k.advance=()=>J[++k.index]||"",n=()=>J.slice(k.index+1),d=(H0="",c=0)=>{k.consumed+=H0,k.index+=c},$0=(H0)=>{k.output+=H0.output!=null?H0.output:H0.value,d(H0.value)},B0=()=>{let H0=1;while(l()==="!"&&(l(2)!=="("||l(3)==="?"))g(),k.start++,H0++;if(H0%2===0)return!1;return k.negated=!0,k.start++,!0},s=(H0)=>{k[H0]++,f.push(H0)},q0=(H0)=>{k[H0]--,f.pop()},K0=(H0)=>{if(S.type==="globstar"){let c=k.braces>0&&(H0.type==="comma"||H0.type==="brace"),r=H0.extglob===!0||u.length&&(H0.type==="pipe"||H0.type==="paren");if(H0.type!=="slash"&&H0.type!=="paren"&&!c&&!r)k.output=k.output.slice(0,-S.output.length),S.type="star",S.value="*",S.output=_,k.output+=S.output}if(u.length&&H0.type!=="paren")u[u.length-1].inner+=H0.value;if(H0.value||H0.output)$0(H0);if(S&&S.type==="text"&&H0.type==="text"){S.output=(S.output||S.value)+H0.value,S.value+=H0.value;return}H0.prev=S,V.push(H0),S=H0},O0=(H0,c)=>{let r={...z[c],conditions:1,inner:""};r.prev=S,r.parens=k.parens,r.output=k.output;let e=(Q.capture?"(":"")+r.open;s("parens"),K0({type:H0,value:c,output:k.output?"":W}),K0({type:"paren",extglob:!0,value:g(),output:e}),u.push(r)},Y0=(H0)=>{let c=H0.close+(Q.capture?")":""),r;if(H0.type==="negate"){let e=_;if(H0.inner&&H0.inner.length>1&&H0.inner.includes("/"))e=M(Q);if(e!==_||m()||/^\)+$/.test(n()))c=H0.close=`)$))${e}`;if(H0.inner.includes("*")&&(r=n())&&/^\.[^\\/.]+$/.test(r)){let i=tW0(r,{...Z,fastpaths:!1}).output;c=H0.close=`)${i})${e})`}if(H0.prev.type==="bos")k.negatedExtglob=!0}K0({type:"paren",extglob:!0,value:x,output:c}),q0("parens")};if(Q.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(J)){let H0=!1,c=J.replace(rU6,(r,e,i,o,Z0,D0)=>{if(o==="\\")return H0=!0,r;if(o==="?"){if(e)return e+o+(Z0?O.repeat(Z0.length):"");if(D0===0)return R+(Z0?O.repeat(Z0.length):"");return O.repeat(i.length)}if(o===".")return q.repeat(i.length);if(o==="*"){if(e)return e+o+(Z0?_:"");return _}return e?r:`\\${r}`});if(H0===!0)if(Q.unescape===!0)c=c.replace(/\\/g,"");else c=c.replace(/\\+/g,(r)=>{return r.length%2===0?"\\\\":r?"\\":""});if(c===J&&Q.contains===!0)return k.output=J,k;return k.output=BV.wrapOutput(c,k,Z),k}while(!m()){if(x=g(),x==="\x00")continue;if(x==="\\"){let r=l();if(r==="/"&&Q.bash!==!0)continue;if(r==="."||r===";")continue;if(!r){x+="\\",K0({type:"text",value:x});continue}let e=/^\\+/.exec(n()),i=0;if(e&&e[0].length>2){if(i=e[0].length,k.index+=i,i%2!==0)x+="\\"}if(Q.unescape===!0)x=g();else x+=g();if(k.brackets===0){K0({type:"text",value:x});continue}}if(k.brackets>0&&(x!=="]"||S.value==="["||S.value==="[^")){if(Q.posix!==!1&&x===":"){let r=S.value.slice(1);if(r.includes("[")){if(S.posix=!0,r.includes(":")){let e=S.value.lastIndexOf("["),i=S.value.slice(0,e),o=S.value.slice(e+2),Z0=aU6[o];if(Z0){if(S.value=i+Z0,k.backtrack=!0,g(),!U.output&&V.indexOf(S)===1)U.output=W;continue}}}}if(x==="["&&l()!==":"||x==="-"&&l()==="]")x=`\\${x}`;if(x==="]"&&(S.value==="["||S.value==="[^"))x=`\\${x}`;if(Q.posix===!0&&x==="!"&&S.value==="[")x="^";S.value+=x,$0({value:x});continue}if(k.quotes===1&&x!=='"'){x=BV.escapeRegex(x),S.value+=x,$0({value:x});continue}if(x==='"'){if(k.quotes=k.quotes===1?0:1,Q.keepQuotes===!0)K0({type:"text",value:x});continue}if(x==="("){s("parens"),K0({type:"paren",value:x});continue}if(x===")"){if(k.parens===0&&Q.strictBrackets===!0)throw SyntaxError(kM("opening","("));let r=u[u.length-1];if(r&&k.parens===r.parens+1){Y0(u.pop());continue}K0({type:"paren",value:x,output:k.parens?")":"\\)"}),q0("parens");continue}if(x==="["){if(Q.nobracket===!0||!n().includes("]")){if(Q.nobracket!==!0&&Q.strictBrackets===!0)throw SyntaxError(kM("closing","]"));x=`\\${x}`}else s("brackets");K0({type:"bracket",value:x});continue}if(x==="]"){if(Q.nobracket===!0||S&&S.type==="bracket"&&S.value.length===1){K0({type:"text",value:x,output:`\\${x}`});continue}if(k.brackets===0){if(Q.strictBrackets===!0)throw SyntaxError(kM("opening","["));K0({type:"text",value:x,output:`\\${x}`});continue}q0("brackets");let r=S.value.slice(1);if(S.posix!==!0&&r[0]==="^"&&!r.includes("/"))x=`/${x}`;if(S.value+=x,$0({value:x}),Q.literalBrackets===!1||BV.hasRegexChars(r))continue;let e=BV.escapeRegex(S.value);if(k.output=k.output.slice(0,-S.value.length),Q.literalBrackets===!0){k.output+=e,S.value=e;continue}S.value=`(${D}${e}|${S.value})`,k.output+=S.value;continue}if(x==="{"&&Q.nobrace!==!0){s("braces");let r={type:"brace",value:x,output:"(",outputIndex:k.output.length,tokensIndex:k.tokens.length};h.push(r),K0(r);continue}if(x==="}"){let r=h[h.length-1];if(Q.nobrace===!0||!r){K0({type:"text",value:x,output:x});continue}let e=")";if(r.dots===!0){let i=V.slice(),o=[];for(let Z0=i.length-1;Z0>=0;Z0--){if(V.pop(),i[Z0].type==="brace")break;if(i[Z0].type!=="dots")o.unshift(i[Z0].value)}e=sU6(o,Q),k.backtrack=!0}if(r.comma!==!0&&r.dots!==!0){let i=k.output.slice(0,r.outputIndex),o=k.tokens.slice(r.tokensIndex);r.value=r.output="\\{",x=e="\\}",k.output=i;for(let Z0 of o)k.output+=Z0.output||Z0.value}K0({type:"brace",value:x,output:e}),q0("braces"),h.pop();continue}if(x==="|"){if(u.length>0)u[u.length-1].conditions++;K0({type:"text",value:x});continue}if(x===","){let r=x,e=h[h.length-1];if(e&&f[f.length-1]==="braces")e.comma=!0,r="|";K0({type:"comma",value:x,output:r});continue}if(x==="/"){if(S.type==="dot"&&k.index===k.start+1){k.start=k.index+1,k.consumed="",k.output="",V.pop(),S=U;continue}K0({type:"slash",value:x,output:G});continue}if(x==="."){if(k.braces>0&&S.type==="dot"){if(S.value===".")S.output=q;let r=h[h.length-1];S.type="dots",S.output+=x,S.value+=x,r.dots=!0;continue}if(k.braces+k.parens===0&&S.type!=="bos"&&S.type!=="slash"){K0({type:"text",value:x,output:q});continue}K0({type:"dot",value:x,output:q});continue}if(x==="?"){if(!(S&&S.value==="(")&&Q.noextglob!==!0&&l()==="("&&l(2)!=="?"){O0("qmark",x);continue}if(S&&S.type==="paren"){let e=l(),i=x;if(S.value==="("&&!/[!=<:]/.test(e)||e==="<"&&!/<([!=]|\w+>)/.test(n()))i=`\\${x}`;K0({type:"text",value:x,output:i});continue}if(Q.dot!==!0&&(S.type==="slash"||S.type==="bos")){K0({type:"qmark",value:x,output:E});continue}K0({type:"qmark",value:x,output:O});continue}if(x==="!"){if(Q.noextglob!==!0&&l()==="("){if(l(2)!=="?"||!/[!=<:]/.test(l(3))){O0("negate",x);continue}}if(Q.nonegate!==!0&&k.index===0){B0();continue}}if(x==="+"){if(Q.noextglob!==!0&&l()==="("&&l(2)!=="?"){O0("plus",x);continue}if(S&&S.value==="("||Q.regex===!1){K0({type:"plus",value:x,output:F});continue}if(S&&(S.type==="bracket"||S.type==="paren"||S.type==="brace")||k.parens>0){K0({type:"plus",value:x});continue}K0({type:"plus",value:F});continue}if(x==="@"){if(Q.noextglob!==!0&&l()==="("&&l(2)!=="?"){K0({type:"at",extglob:!0,value:x,output:""});continue}K0({type:"text",value:x});continue}if(x!=="*"){if(x==="$"||x==="^")x=`\\${x}`;let r=oU6.exec(n());if(r)x+=r[0],k.index+=r[0].length;K0({type:"text",value:x});continue}if(S&&(S.type==="globstar"||S.star===!0)){S.type="star",S.star=!0,S.value+=x,S.output=_,k.backtrack=!0,k.globstar=!0,d(x);continue}let H0=n();if(Q.noextglob!==!0&&/^\([^?]/.test(H0)){O0("star",x);continue}if(S.type==="star"){if(Q.noglobstar===!0){d(x);continue}let r=S.prev,e=r.prev,i=r.type==="slash"||r.type==="bos",o=e&&(e.type==="star"||e.type==="globstar");if(Q.bash===!0&&(!i||H0[0]&&H0[0]!=="/")){K0({type:"star",value:x,output:""});continue}let Z0=k.braces>0&&(r.type==="comma"||r.type==="brace"),D0=u.length&&(r.type==="pipe"||r.type==="paren");if(!i&&r.type!=="paren"&&!Z0&&!D0){K0({type:"star",value:x,output:""});continue}while(H0.slice(0,3)==="/**"){let z0=J[k.index+4];if(z0&&z0!=="/")break;H0=H0.slice(3),d("/**",3)}if(r.type==="bos"&&m()){S.type="globstar",S.value+=x,S.output=M(Q),k.output=S.output,k.globstar=!0,d(x);continue}if(r.type==="slash"&&r.prev.type!=="bos"&&!o&&m()){k.output=k.output.slice(0,-(r.output+S.output).length),r.output=`(?:${r.output}`,S.type="globstar",S.output=M(Q)+(Q.strictSlashes?")":"|$)"),S.value+=x,k.globstar=!0,k.output+=r.output+S.output,d(x);continue}if(r.type==="slash"&&r.prev.type!=="bos"&&H0[0]==="/"){let z0=H0[1]!==void 0?"|$":"";k.output=k.output.slice(0,-(r.output+S.output).length),r.output=`(?:${r.output}`,S.type="globstar",S.output=`${M(Q)}${G}|${G}${z0})`,S.value+=x,k.output+=r.output+S.output,k.globstar=!0,d(x+g()),K0({type:"slash",value:"/",output:""});continue}if(r.type==="bos"&&H0[0]==="/"){S.type="globstar",S.value+=x,S.output=`(?:^|${G}|${M(Q)}${G})`,k.output=S.output,k.globstar=!0,d(x+g()),K0({type:"slash",value:"/",output:""});continue}k.output=k.output.slice(0,-S.output.length),S.type="globstar",S.output=M(Q),S.value+=x,k.output+=S.output,k.globstar=!0,d(x);continue}let c={type:"star",value:x,output:_};if(Q.bash===!0){if(c.output=".*?",S.type==="bos"||S.type==="slash")c.output=A+c.output;K0(c);continue}if(S&&(S.type==="bracket"||S.type==="paren")&&Q.regex===!0){c.output=x,K0(c);continue}if(k.index===k.start||S.type==="slash"||S.type==="dot"){if(S.type==="dot")k.output+=w,S.output+=w;else if(Q.dot===!0)k.output+=N,S.output+=N;else k.output+=A,S.output+=A;if(l()!=="*")k.output+=W,S.output+=W}K0(c)}while(k.brackets>0){if(Q.strictBrackets===!0)throw SyntaxError(kM("closing","]"));k.output=BV.escapeLast(k.output,"["),q0("brackets")}while(k.parens>0){if(Q.strictBrackets===!0)throw SyntaxError(kM("closing",")"));k.output=BV.escapeLast(k.output,"("),q0("parens")}while(k.braces>0){if(Q.strictBrackets===!0)throw SyntaxError(kM("closing","}"));k.output=BV.escapeLast(k.output,"{"),q0("braces")}if(Q.strictSlashes!==!0&&(S.type==="star"||S.type==="bracket"))K0({type:"maybe_slash",value:"",output:`${G}?`});if(k.backtrack===!0){k.output="";for(let H0 of k.tokens)if(k.output+=H0.output!=null?H0.output:H0.value,H0.suffix)k.output+=H0.suffix}return k};tW0.fastpaths=(J,Z)=>{let Q={...Z},X=typeof Q.maxLength==="number"?Math.min(ka,Q.maxLength):ka,Y=J.length;if(Y>X)throw SyntaxError(`Input length: ${Y}, exceeds maximum allowed length: ${X}`);J=NL1[J]||J;let{DOT_LITERAL:U,SLASH_LITERAL:V,ONE_CHAR:D,DOTS_SLASH:K,NO_DOT:z,NO_DOTS:q,NO_DOTS_SLASH:F,STAR:G,START_ANCHOR:W}=va.globChars(Q.windows),H=Q.dot?q:z,B=Q.dot?F:z,w=Q.capture?"":"?:",N={negated:!1,prefix:""},O=Q.bash===!0?".*?":G;if(Q.capture)O=`(${O})`;let E=(A)=>{if(A.noglobstar===!0)return O;return`(${w}(?:(?!${W}${A.dot?K:U}).)*?)`},L=(A)=>{switch(A){case"*":return`${H}${D}${O}`;case".*":return`${U}${D}${O}`;case"*.*":return`${H}${O}${U}${D}${O}`;case"*/*":return`${H}${O}${V}${D}${B}${O}`;case"**":return H+E(Q);case"**/*":return`(?:${H}${E(Q)}${V})?${B}${D}${O}`;case"**/*.*":return`(?:${H}${E(Q)}${V})?${B}${O}${U}${D}${O}`;case"**/.*":return`(?:${H}${E(Q)}${V})?${U}${D}${O}`;default:{let R=/^(.*?)\.(\w+)$/.exec(A);if(!R)return;let _=L(R[1]);if(!_)return;return _+U+R[2]}}},I=BV.removePrefix(J,N),M=L(I);if(M&&Q.strictSlashes!==!0)M+=`${V}?`;return M};OL1.exports=tW0});var $H0=y((j$3,IL1)=>{var tU6=wL1(),eW0=EL1(),LL1=nv(),eU6=iv(),$V6=(J)=>J&&typeof J==="object"&&!Array.isArray(J),V9=(J,Z,Q=!1)=>{if(Array.isArray(J)){let q=J.map((G)=>V9(G,Z,Q));return(G)=>{for(let W of q){let H=W(G);if(H)return H}return!1}}let X=$V6(J)&&J.tokens&&J.input;if(J===""||typeof J!=="string"&&!X)throw TypeError("Expected pattern to be a non-empty string");let Y=Z||{},U=Y.windows,V=X?V9.compileRe(J,Z):V9.makeRe(J,Z,!1,!0),D=V.state;delete V.state;let K=()=>!1;if(Y.ignore){let q={...Z,ignore:null,onMatch:null,onResult:null};K=V9(Y.ignore,q,Q)}let z=(q,F=!1)=>{let{isMatch:G,match:W,output:H}=V9.test(q,V,Z,{glob:J,posix:U}),B={glob:J,state:D,regex:V,posix:U,input:q,output:H,match:W,isMatch:G};if(typeof Y.onResult==="function")Y.onResult(B);if(G===!1)return B.isMatch=!1,F?B:!1;if(K(q)){if(typeof Y.onIgnore==="function")Y.onIgnore(B);return B.isMatch=!1,F?B:!1}if(typeof Y.onMatch==="function")Y.onMatch(B);return F?B:!0};if(Q)z.state=D;return z};V9.test=(J,Z,Q,{glob:X,posix:Y}={})=>{if(typeof J!=="string")throw TypeError("Expected input to be a string");if(J==="")return{isMatch:!1,output:""};let U=Q||{},V=U.format||(Y?LL1.toPosixSlashes:null),D=J===X,K=D&&V?V(J):J;if(D===!1)K=V?V(J):J,D=K===X;if(D===!1||U.capture===!0)if(U.matchBase===!0||U.basename===!0)D=V9.matchBase(J,Z,Q,Y);else D=Z.exec(K);return{isMatch:Boolean(D),match:D,output:K}};V9.matchBase=(J,Z,Q)=>{return(Z instanceof RegExp?Z:V9.makeRe(Z,Q)).test(LL1.basename(J))};V9.isMatch=(J,Z,Q)=>V9(Z,Q)(J);V9.parse=(J,Z)=>{if(Array.isArray(J))return J.map((Q)=>V9.parse(Q,Z));return eW0(J,{...Z,fastpaths:!1})};V9.scan=(J,Z)=>tU6(J,Z);V9.compileRe=(J,Z,Q=!1,X=!1)=>{if(Q===!0)return J.output;let Y=Z||{},U=Y.contains?"":"^",V=Y.contains?"":"$",D=`${U}(?:${J.output})${V}`;if(J&&J.negated===!0)D=`^(?!${D}).*$`;let K=V9.toRegex(D,Z);if(X===!0)K.state=J;return K};V9.makeRe=(J,Z={},Q=!1,X=!1)=>{if(!J||typeof J!=="string")throw TypeError("Expected a non-empty string");let Y={negated:!1,fastpaths:!0};if(Z.fastpaths!==!1&&(J[0]==="."||J[0]==="*"))Y.output=eW0.fastpaths(J,Z);if(!Y.output)Y=eW0(J,Z);return V9.compileRe(Y,Z,Q,X)};V9.toRegex=(J,Z)=>{try{let Q=Z||{};return new RegExp(J,Q.flags||(Q.nocase?"i":""))}catch(Q){if(Z&&Z.debug===!0)throw Q;return/$^/}};V9.constants=eU6;IL1.exports=V9});var hK=y((R$3,jL1)=>{var ML1=$H0(),JV6=nv();function AL1(J,Z,Q=!1){if(Z&&(Z.windows===null||Z.windows===void 0))Z={...Z,windows:JV6.isWindows()};return ML1(J,Z,Q)}Object.assign(AL1,ML1);jL1.exports=AL1});function JH0(J){return ya[J]??0}function ZV6(J){return typeof J==="number"&&Number.isInteger(J)&&J>=1&&J<=3600}function PL1(J){let Z=J.settings["tools.inactivityTimeout"],Q=J.settings["tools.stopTimeout"],X=Z;if(X===void 0&&Q!==void 0)X=Q;if(X===void 0)X=JH0("amp.tools.inactivityTimeout");if(!ZV6(X))return null;return X*1000}function CL1(J){let Z=J.settings["tools.stopTimeout"],Q=JH0("amp.tools.stopTimeout");return(Z??Q)*1000}function ua(J){let Z=J.settings["network.timeout"],Q=JH0("amp.network.timeout");return(Z??Q)*1000}var ya,RL1;var yM=J0(()=>{ya={"amp.tools.inactivityTimeout":300,"amp.tools.stopTimeout":300,"amp.network.timeout":30},RL1={"amp.tools.inactivityTimeout":{default:ya["amp.tools.inactivityTimeout"]},"amp.tools.stopTimeout":{default:ya["amp.tools.stopTimeout"]},"amp.network.timeout":{default:ya["amp.network.timeout"]}}});function _3(J){let Z=P6[J];return`${Z.provider}/${Z.name}`}function wV(J){let Z=J.indexOf("/");if(Z===-1)throw Error(`Invalid provider/model format: ${J}`);return{provider:J.slice(0,Z),model:J.slice(Z+1)}}function i9(J){let{provider:Z,model:Q}=wV(J);for(let X of Object.values(P6))if(X.provider===Z&&X.name===Q)return X;switch(Z){case"anthropic":return P6.CLAUDE_SONNET_4_5;case"openai":return P6.GPT_5;case"xai":return P6.GROK_CODE_FAST_1;case"cerebras":return P6.Z_AI_GLM_4_7;case"fireworks":return P6.FIREWORKS_GLM_4P6;case"baseten":return P6.BASETEN_KIMI_K2P5;case"moonshotai":return P6.KIMI_K2_INSTRUCT;case"openrouter":return P6.SONOMA_SKY_ALPHA;case"groq":return P6.GPT_OSS_120B;case"vertexai":return P6.GEMINI_3_PRO_PREVIEW;default:throw Error(`Unknown provider: ${Z}`)}}function ov(J){for(let Q of Object.values(P6))if(Q.name===J)return Q;let Z=J.match(/^(.*)-\d{4}-\d{2}-\d{2}$/);if(Z){let Q=Z[1];for(let X of Object.values(P6))if(X.name===Q)return X}return}function D8(J){let Z=J.indexOf("/");if(Z===-1)return J;return J.slice(Z+1)}function H$(J){let Z=i9(J);return Z.contextWindow-Z.maxOutputTokens}function xa(J){return i9(J).maxOutputTokens}var M6,P6,ZH0;var t7=J0(()=>{M6={ANTHROPIC:"anthropic",BASENTEN:"baseten",OPENAI:"openai",XAI:"xai",CEREBRAS:"cerebras",FIREWORKS:"fireworks",GROQ:"groq",MOONSHOT:"moonshotai",OPENROUTER:"openrouter",VERTEXAI:"vertexai"},P6={CLAUDE_SONNET_4:{provider:M6.ANTHROPIC,name:"claude-sonnet-4-20250514",displayName:"Claude Sonnet 4",contextWindow:1e6,maxOutputTokens:32000,pricing:{input:3,output:15,cached:0.3,cacheWrite:3.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_SONNET_4_5:{provider:M6.ANTHROPIC,name:"claude-sonnet-4-5-20250929",displayName:"Claude Sonnet 4.5",contextWindow:1e6,maxOutputTokens:32000,pricing:{input:3,output:15,cached:0.3,cacheWrite:3.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_SONNET_4_6:{provider:M6.ANTHROPIC,name:"claude-sonnet-4-6",displayName:"Claude Sonnet 4.6",contextWindow:1e6,maxOutputTokens:64000,pricing:{input:3,output:15,cached:0.3,cacheWrite:3.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4:{provider:M6.ANTHROPIC,name:"claude-opus-4-20250514",displayName:"Claude Opus 4",contextWindow:200000,maxOutputTokens:32000,pricing:{input:15,output:75,cached:1.5,cacheWrite:18.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_1:{provider:M6.ANTHROPIC,name:"claude-opus-4-1-20250805",displayName:"Claude Opus 4.1",contextWindow:200000,maxOutputTokens:32000,pricing:{input:15,output:75,cached:1.5,cacheWrite:18.75,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_5:{provider:M6.ANTHROPIC,name:"claude-opus-4-5-20251101",displayName:"Claude Opus 4.5",contextWindow:200000,maxOutputTokens:32000,pricing:{input:5,output:25,cached:0.5,cacheWrite:6.25,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_OPUS_4_6:{provider:M6.ANTHROPIC,name:"claude-opus-4-6",displayName:"Claude Opus 4.6",contextWindow:200000,maxOutputTokens:32000,pricing:{input:5,output:25,cached:0.5,cacheWrite:6.25,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},CLAUDE_HAIKU_4_5:{provider:M6.ANTHROPIC,name:"claude-haiku-4-5-20251001",displayName:"Claude Haiku 4.5",contextWindow:200000,maxOutputTokens:64000,pricing:{input:1,output:5,cached:0.1,cacheWrite:1.25,cacheTTL:300},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5:{provider:M6.OPENAI,name:"gpt-5",displayName:"GPT-5",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_1:{provider:M6.OPENAI,name:"gpt-5.1",displayName:"GPT-5.1",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_2:{provider:M6.OPENAI,name:"gpt-5.2",displayName:"GPT-5.2",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.75,output:14,cached:0.175},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_CODEX:{provider:M6.OPENAI,name:"gpt-5-codex",displayName:"GPT-5 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,tools:!0}},GPT_5_1_CODEX:{provider:M6.OPENAI,name:"gpt-5.1-codex",displayName:"GPT-5.1 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.25,output:10,cached:0.125},capabilities:{reasoning:!0,tools:!0}},GPT_5_2_CODEX:{provider:M6.OPENAI,name:"gpt-5.2-codex",displayName:"GPT-5.2 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.75,output:14,cached:0.175},capabilities:{reasoning:!0,tools:!0,vision:!0}},GPT_5_3_CODEX:{provider:M6.OPENAI,name:"gpt-5.3-codex",displayName:"GPT-5.3 Codex",contextWindow:400000,maxOutputTokens:128000,pricing:{input:1.75,output:14,cached:0.175},capabilities:{reasoning:!0,tools:!0,vision:!0}},GPT_5_MINI:{provider:M6.OPENAI,name:"gpt-5-mini",displayName:"GPT-5 Mini",contextWindow:400000,maxOutputTokens:128000,pricing:{input:0.25,output:2,cached:0.025},capabilities:{reasoning:!0,vision:!0,tools:!0}},GPT_5_NANO:{provider:M6.OPENAI,name:"gpt-5-nano",displayName:"GPT-5 Nano",contextWindow:400000,maxOutputTokens:128000,pricing:{input:0.05,output:0.4,cached:0.005},capabilities:{reasoning:!0,vision:!0,tools:!0}},O3:{provider:M6.OPENAI,name:"o3",displayName:"o3",contextWindow:200000,maxOutputTokens:1e5,pricing:{input:2,output:8,cached:0.5},capabilities:{reasoning:!0,tools:!0}},O3_MINI:{provider:M6.OPENAI,name:"o3-mini",displayName:"o3-mini",contextWindow:200000,maxOutputTokens:1e5,pricing:{input:1.1,output:4.4,cached:0.55},capabilities:{reasoning:!0,tools:!0}},GPT_OSS_120B:{provider:M6.OPENAI,name:"openai/gpt-oss-120b",displayName:"GPT OSS 120B",contextWindow:128000,maxOutputTokens:32000,capabilities:{reasoning:!0,tools:!0}},GROK_CODE_FAST_1:{provider:M6.XAI,name:"grok-code-fast-1",displayName:"Grok Code Fast 1",contextWindow:256000,maxOutputTokens:32000,capabilities:{reasoning:!0,tools:!0}},GEMINI_3_PRO_PREVIEW:{provider:M6.VERTEXAI,name:"gemini-3-pro-preview",displayName:"Gemini 3 Pro Preview",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI_3_1_PRO_PREVIEW:{provider:M6.VERTEXAI,name:"gemini-3.1-pro-preview",displayName:"Gemini 3.1 Pro Preview",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI3_FLASH_PREVIEW:{provider:M6.VERTEXAI,name:"gemini-3-flash-preview",displayName:"Gemini 3 Flash Preview",contextWindow:1048576,maxOutputTokens:65535,capabilities:{tools:!0,reasoning:!0,vision:!0}},GEMINI_3_PRO_IMAGE:{provider:M6.VERTEXAI,name:"gemini-3-pro-image-preview",displayName:"Gemini 3 Pro Image",contextWindow:1048576,maxOutputTokens:65535,capabilities:{vision:!0,imageGeneration:!0}},Z_AI_GLM_4_7:{provider:M6.CEREBRAS,name:"zai-glm-4.7",displayName:"Z.ai GLM 4.7",contextWindow:131000,maxOutputTokens:40000,capabilities:{tools:!0}},FIREWORKS_QWEN3_CODER_480B:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/qwen3-coder-480b-a35b-instruct",displayName:"Qwen3 Coder 480B",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_KIMI_K2_INSTRUCT:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/kimi-k2-instruct-0905",displayName:"Kimi K2 Instruct",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_QWEN3_235B:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/qwen3-235b-a22b-instruct-2507",displayName:"Qwen3 235B",contextWindow:230144,maxOutputTokens:32000,capabilities:{tools:!0}},FIREWORKS_GLM_4P6:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/glm-4p6",displayName:"GLM 4P6",contextWindow:162752,maxOutputTokens:40000,capabilities:{tools:!0,reasoning:!0}},FIREWORKS_GLM_5:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/glm-5",displayName:"GLM 5",contextWindow:202800,maxOutputTokens:40000,pricing:{input:1,output:3.2},capabilities:{tools:!0}},FIREWORKS_MINIMAX_M2P5:{provider:M6.FIREWORKS,name:"accounts/fireworks/models/minimax-m2p5",displayName:"MiniMax M2.5",contextWindow:200000,maxOutputTokens:32000,pricing:{input:0.3,output:1.2,cached:0.03},capabilities:{tools:!0}},BASETEN_KIMI_K2P5:{provider:M6.BASENTEN,name:"moonshotai/Kimi-K2.5",displayName:"Kimi K2.5",contextWindow:262144,maxOutputTokens:32000,pricing:{input:0.6,output:3,cached:0.1},capabilities:{tools:!0,vision:!0}},KIMI_K2_INSTRUCT:{provider:M6.MOONSHOT,name:"kimi-k2-instruct-0905",displayName:"Kimi K2 Instruct",contextWindow:1e6,maxOutputTokens:32000,capabilities:{tools:!0}},SONOMA_SKY_ALPHA:{provider:M6.OPENROUTER,name:"sonoma-sky-alpha",displayName:"Sonoma Sky Alpha",contextWindow:256000,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_GLM_4_6:{provider:M6.OPENROUTER,name:"z-ai/glm-4.6",displayName:"OpenRouter GLM 4.6",contextWindow:131000,maxOutputTokens:40000,capabilities:{tools:!0}},OPENROUTER_KIMI_K2_0905:{provider:M6.OPENROUTER,name:"moonshotai/kimi-k2-0905",displayName:"Kimi K2 0905 (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_QWEN3_CODER_480B:{provider:M6.OPENROUTER,name:"qwen/qwen3-coder",displayName:"Qwen3 Coder 480B (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}},OPENROUTER_QWEN3_235B:{provider:M6.OPENROUTER,name:"qwen/qwen3-235b-a22b-2507",displayName:"Qwen3 235B A22B (OpenRouter)",contextWindow:262144,maxOutputTokens:32000,capabilities:{tools:!0}}};ZH0={FINDER:"finder"}});function QH0(J,Z){let Q=_2(Z);if(!Q)return!1;if(QV6.has(J)){let X=Q.finder??ZH0.FINDER,Y=XV6[X];if(J!==Y)return!1}if(Q.includeTools){if(Q.deferredTools?.includes(J))return!0;return Q.includeTools.includes(J)}return!0}function XH0(J,Z){let Q=_2(Z);if(!Q)return!1;return Q.deferredTools?.includes(J)??!1}function bQ(J,Z,Q){let X=J?.["internal.visibleModes"]??[],Y=J?.["experimental.modes"]??[],U=[...X,...Y],V=new Set(J?.disabledAgentModes??[]);return Object.values(NV).filter((D)=>{if(D.key===fa)return!1;if(U.includes(`!${D.key}`))return!1;if(Z===!1&&P8(D.key))return!1;if(V.has(D.key))return!1;if(Q?.v2&&!(("visibleInV2"in D)&&D.visibleInV2))return!1;let z="visible"in D?D.visible:!1,q=U.includes(D.key);return z||q}).map((D)=>({mode:D.key,description:"description"in D?D.description:void 0})).sort((D,K)=>D.mode.localeCompare(K.mode))}function _2(J){return Object.values(NV).find((Z)=>Z.key===J)}function hQ(J){return _2(J)?.primaryModel??_3("CLAUDE_SONNET_4_5")}function rv(J){let Z=_2(J);if(!Z)return!1;return i9(Z.primaryModel).capabilities?.vision??!1}function P8(J){return J==="free"||J.startsWith("free-")}function YH0(J,Z){return Z.find((Q)=>Q.mode===J)?.description}function UH0(J,Z){let X=(Z.findIndex((U)=>U.mode===J)+1)%Z.length;return Z[X]?.mode??"smart"}var QV6,XV6,SL1,vL1,YV6,UV6,TL1,_L1,VV6,DV6,KV6,NV,fa,zV6;var WJ=J0(()=>{t7();QV6=new Set(["finder"]),XV6={finder:"finder"},SL1={r:0,g:55,b:0},vL1={r:0,g:255,b:136},YV6=["Read","Grep","glob","finder","Bash","create_file","edit_file","format_file","get_diagnostics","web_search","read_web_page","task_list","read_thread","find_thread","mermaid","chart","skill"],UV6=["Read","Grep","glob","finder","Bash","create_file","edit_file","format_file","undo_edit","get_diagnostics","web_search","read_web_page","read_mcp_resource","mermaid","chart","read_thread","find_thread","skill","oracle","handoff","librarian","Task","task_list","look_at","painter"],TL1=["Read","finder","Bash","repl","create_file","edit_file","undo_edit","web_search","read_web_page","task_list","read_thread","find_thread","skill","oracle","librarian","Task","Grep","glob","read_mcp_resource","mermaid","chart","look_at","format_file","get_diagnostics","handoff","painter","restore_snapshot","slack_write","slack_read"],_L1=["code_review","walkthrough","walkthrough_diagram"],VV6=["code_review"],DV6=["find_thread","read_thread","docs_list","docs_read","docs_write","create_thread","slack_write","slack_read"],KV6=["shell_command","apply_patch","web_search","read_web_page","chart","skill","read_thread","find_thread","librarian","finder","painter","handoff"],NV={SMART:{key:"smart",displayName:"Smart",description:"The most capable model and set of tools",primaryModel:_3("CLAUDE_OPUS_4_6"),includeTools:TL1,deferredTools:_L1,visible:!0,visibleInV2:!0,uiHints:{labelAnimation:"glow",primaryColor:{r:0,g:55,b:20},secondaryColor:{r:0,g:255,b:136}}},FREE:{key:"free",displayName:"Free",description:"Amp Free",primaryModel:_3("CLAUDE_HAIKU_4_5"),includeTools:YV6,visible:!0,uiHints:{primaryColor:{r:0,g:26,b:51},secondaryColor:{r:0,g:184,b:255}}},RUSH:{key:"rush",displayName:"Rush",description:"Faster and cheaper for small, well-defined tasks",primaryModel:_3("CLAUDE_HAIKU_4_5"),includeTools:UV6,visible:!0,uiHints:{fasterAnimation:!0,labelAnimation:"jitter",primaryColor:{r:128,g:51,b:0},secondaryColor:{r:255,g:215,b:0}}},AGG:{key:"agg-man",displayName:"Agg",description:"Query and summarize your Amp threads",primaryModel:_3("CLAUDE_OPUS_4_6"),includeTools:DV6,visible:!1,uiHints:{primaryColor:{r:26,g:0,b:77},secondaryColor:{r:102,g:153,b:255}}},LARGE:{key:"large",displayName:"Large",description:"The biggest context window possible (Sonnet 4.6 1M tokens), for large tasks",primaryModel:_3("CLAUDE_SONNET_4_6"),includeTools:TL1,deferredTools:_L1,visible:!1,uiHints:{labelAnimation:"glow",primaryColor:{r:42,g:26,b:77},secondaryColor:{r:153,g:102,b:255}}},DEEP:{key:"deep",displayName:"Deep",description:"Deep reasoning with GPT-5.3 Codex",primaryModel:_3("GPT_5_3_CODEX"),includeTools:KV6,deferredTools:VV6,visible:!0,visibleInV2:!0,reasoningEffort:"high",uiHints:{labelAnimation:"glow",primaryColor:{r:0,g:77,b:64},secondaryColor:{r:29,g:233,b:182}}}},fa=NV.AGG.key,zV6=Object.values(NV).map((J)=>J.key)});function ba(J,Z,Q){if(J.startsWith("mcp__"))return Z.allowMcp??!1;if(J.startsWith("tb__")){if(!(Z.allowToolbox??!1))return!1;let X="subagentType"in Z?Z.subagentType:void 0;if(X&&Q){if(!Q.subagentTypes)return!1;return Q.subagentTypes.includes("all")||Q.subagentTypes.includes(X)}return!0}return Z.includeTools.includes(J)}var VH0,kL1,qV6,DH0,FV6,GV6,WV6,KH0,h8,v$3;var wY=J0(()=>{t7();VH0=["read_github","search_github","commit_search","diff","list_directory_github","list_repositories","glob_github"],kL1=["read_bitbucket_enterprise","search_bitbucket_enterprise","commit_search_bitbucket_enterprise","diff_bitbucket_enterprise","list_directory_bitbucket_enterprise","list_repositories_bitbucket_enterprise","glob_bitbucket_enterprise"],qV6=["Grep","glob","Read"],DH0=["Read","Grep","glob","web_search","read_web_page","read_thread","find_thread"],FV6=["Grep","glob","Read","Bash","edit_file","create_file","format_file","read_web_page","get_diagnostics","web_search","finder","skill","task_list"],GV6=["Read","Grep","glob","web_search","read_web_page","Bash"],WV6=["Read","Grep","glob","Bash"],KH0=["Read","Grep","glob","finder"],h8={finder:{key:"finder",displayName:"Finder",model:_3("CLAUDE_HAIKU_4_5"),includeTools:qV6,allowMcp:!1,allowToolbox:!1},oracle:{key:"oracle",displayName:"Oracle",model:_3("GPT_5_2"),includeTools:DH0,allowMcp:!1,allowToolbox:!1},librarian:{key:"librarian",displayName:"Librarian",model:_3("CLAUDE_SONNET_4_6"),includeTools:VH0,allowMcp:!1,allowToolbox:!1},"task-subagent":{key:"task-subagent",displayName:"Task Subagent",model:void 0,includeTools:FV6,allowMcp:!0,allowToolbox:!0},"code-review":{key:"code-review",displayName:"Code Review",model:_3("CLAUDE_SONNET_4_5"),includeTools:GV6,allowMcp:!1,allowToolbox:!1},"codereview-check":{key:"codereview-check",displayName:"Codereview Check",model:_3("CLAUDE_HAIKU_4_5"),includeTools:WV6,allowMcp:!1,allowToolbox:!1}},v$3=Object.keys(h8)});function yL1(J,Z){return new v0((Q)=>{let X=setTimeout(Y,Z);function Y(){Q.error(Error(`Tool execution timed out after ${Z/1000} seconds`))}function U(){if(X)clearTimeout(X);X=setTimeout(Y,Z)}let V=J.subscribe({next:(D)=>{U(),Q.next(D)},error:(D)=>{if(X)clearTimeout(X),X=null;Q.error(D)},complete:()=>{if(X)clearTimeout(X),X=null;Q.complete()}});return()=>{if(X)clearTimeout(X),X=null;V.unsubscribe()}})}var uL1=J0(()=>{H1()});function fL1(J){return{tool:J,action:"allow"}}function HV6(J){if(!J||!("cmd"in J))return J;let{cmd:Z,...Q}=J;return{...Q,command:Z}}function BV6(J){return J.flatMap((Z)=>{if(Z.tool!==g6)return[];return[{...Z,tool:GZ,matches:HV6(Z.matches)}]})}var xL1,uM;var ha=J0(()=>{w4();xL1=[{tool:"Bash",action:"ask",matches:{cmd:"*git*push*"}},{tool:"mcp__*",action:"allow"},{tool:Oa,action:"allow"},{tool:"tb__*",action:"allow"},{tool:"Bash",matches:{cmd:"/^(.*\\s+)?(bazel|ibazel)\\s+.*\\/\\/[^\\s]*.*$/"},action:"allow"},{tool:"Bash",matches:{cmd:["ls","ls *","dir","dir *","cat *","head *","tail *","less *","more *","grep *","egrep *","fgrep *","tree","tree *","file *","wc *","pwd","stat *","du *","df *","ps *","top","htop","echo *","printenv *","id","which *","whereis *","date","cal *","uptime","free *","ping *","dig *","nslookup *","host *","netstat *","ss *","lsof *","ifconfig *","ip *","man *","info *","mkdir *","touch *","uname *","whoami","go version","go env *","go help *","cargo version","cargo --version","cargo help *","rustc --version","rustc --help","rustc --explain *","javac --version","javac -version","javac -help","javac --help","dotnet --info","dotnet --version","dotnet --help","dotnet help *","gcc --version","gcc -v","gcc --help","gcc -dumpversion","g++ --version","g++ -v","g++ --help","g++ -dumpversion","clang --version","clang --help","clang++ --version","clang++ --help","python -V","python --version","python -h","python --help","python3 -V","python3 --version","python3 -h","python3 --help","ruby -v","ruby --version","ruby -h","ruby --help","node -v","node --version","node -h","node --help","npm --help","npm --version","npm -v","npm help *","yarn --help","yarn --version","yarn -v","yarn help *","pnpm --help","pnpm --version","pnpm -v","pnpm help *","pytest -h","pytest --help","pytest --version","jest --help","jest --version","mocha --help","mocha --version","make --version","make --help","docker --version","docker --help","docker version","docker help *","git --version","git --help","git help *","git version"]},action:"allow"},{tool:"Bash",matches:{cmd:["go test *","go run *","go build *","go vet *","go fmt *","go list *","cargo test *","cargo run *","cargo build *","cargo check *","cargo fmt *","cargo tree *","make -n *","make --dry-run *","mvn test *","mvn verify *","mvn dependency:tree *","gradle tasks *","gradle dependencies *","gradle properties *","dotnet test *","dotnet list *","python -c *","ruby -e *","node -e *","npm list *","npm ls *","npm outdated *","npm test*","npm run*","npm view *","npm info *","yarn list*","yarn ls *","yarn info *","yarn test*","yarn run *","yarn why *","pnpm list*","pnpm ls *","pnpm outdated *","pnpm test*","pnpm run *","pytest --collect-only *","jest --listTests *","jest --showConfig *","mocha --list *","git status*","git show *","git diff*","git grep *","git branch *","git tag *","git remote -v *","git rev-parse --is-inside-work-tree *","git rev-parse --show-toplevel *","git config --list *","git log *"]},action:"allow"},{tool:"Bash",matches:{cmd:["./gradlew *","./mvnw *","./build.sh *","./configure *","cmake *","./node_modules/.bin/tsc *","./node_modules/.bin/eslint *","./node_modules/.bin/prettier *","prettier *","./node_modules/.bin/tailwindcss *","./node_modules/.bin/tsx *","./node_modules/.bin/vite *","bun *","tsx *","vite *"]},action:"allow"},{tool:"Bash",matches:{cmd:[".venv/bin/activate *",".venv/Scripts/activate *","source .venv/bin/activate *","source venv/bin/activate *","pip list *","pip show *","pip check *","pip freeze *","uv *","poetry show *","poetry check *","pipenv check *"]},action:"allow"},{tool:"Bash",matches:{cmd:["asdf list *","asdf current *","asdf which *","mise list *","mise current *","mise which *","mise use *","rbenv version *","rbenv versions *","rbenv which *","nvm list *","nvm current *","nvm which *"]},action:"allow"},{tool:"Bash",matches:{cmd:["./test*","./run_tests.sh *","./run_*_tests.sh *","vitest *","bundle exec rspec *","bundle exec rubocop *","rspec *","rubocop *","swiftlint *","clippy *","ruff *","black *","isort *","mypy *","flake8 *","bandit *","safety *","biome check *","biome format *"]},action:"allow"},{tool:"Bash",matches:{cmd:["rails server *","rails s *","bin/rails server *","bin/rails s *","flask run *","django-admin runserver *","python manage.py runserver *","uvicorn *","streamlit run *"]},action:"allow"},{tool:"Bash",matches:{cmd:["bin/rails db:status","bin/rails db:version","rails db:rollback *","rails db:status *","rails db:version *","alembic current *","alembic history *","bundle exec rails db:status","bundle exec rails db:version"]},action:"allow"},{tool:"Bash",matches:{cmd:["docker ps *","docker images *","docker logs *","docker inspect *","docker info *","docker stats *","docker system df *","docker system info *","podman ps *","podman images *","podman logs *","podman inspect *","podman info *"]},action:"allow"},{tool:"Bash",matches:{cmd:["aws --version *","aws configure list *","aws sts get-caller-identity *","aws s3 ls *","gcloud config list *","gcloud auth list *","gcloud projects list *","az account list *","az account show *","kubectl get *","kubectl describe *","kubectl logs *","kubectl version *","helm list *","helm status *","helm version *"]},action:"allow"},{tool:"Bash",matches:{cmd:["swift build *","swift test *","zig build *","zig build test*","kotlinc *","scalac *","javac *","javap *","clang *","jar *","sbt *","gradle *","bazel build *","bazel test *","bazel run *","mix *","lua *","ruby *","php *"]},action:"allow"},{tool:"Bash",matches:{cmd:["mkdir -p *","chmod +x *","dos2unix *","unix2dos *","ln -s *"]},action:"allow"},{tool:"Bash",matches:{cmd:["for *","while *","do *","done *","if *","then *","else *","elif *","fi *","case *","esac *","in *","function *","select *","until *","{ *","} *","[[ *","]] *"]},action:"ask"},{tool:"Bash",matches:{cmd:"/^find(?!.*(-delete|-exec|-execdir)).*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(echo|ls|pwd|date|whoami|id|uname)\\s.*[&|;].*\\s*(echo|ls|pwd|date|whoami|id|uname)($|\\s.*)/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(cat|grep|head|tail|less|more|find)\\s.*\\|\\s*(grep|head|tail|less|more|wc|sort|uniq)($|\\s.*)/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^rm\\s+.*(-[rf].*-[rf]|-[rf]{2,}|--recursive.*--force|--force.*--recursive).*$/"},action:"ask"},{tool:"Bash",matches:{cmd:"/^find.*(-delete|-exec|-execdir).*$/"},action:"ask"},{tool:"Bash",matches:{cmd:"/^(ls|cat|grep|head|tail|file|stat)\\s+[^/]*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/^(?!.*(rm|mv|cp|chmod|chown|sudo|su|dd)\\b).*/dev/(null|zero|stdout|stderr|stdin).*$/"},action:"allow"},{tool:"Bash",matches:{cmd:"/(^|\\s)(\\/(?!dev\\/(null|zero|stdout|stderr|stdin))[^\\s]*|\\.\\.\\/)(?![^\\s]*\\.(log|txt|md|json|yml|yaml)$)/"},action:"ask"},{tool:"Bash",action:"ask"},fL1("Glob")],uM=[...xL1,...BV6(xL1),...YL1.map(fL1)]});var J4=J0(()=>{Sv();Ja();LM()});function FH0(J){let Z=J;if(Z.startsWith("~/")){let Q=process.env.HOME||process.env.USERPROFILE||"";Z=Z.replace("~/",`${Q}/`)}else if(Z==="~")Z=process.env.HOME||process.env.USERPROFILE||"";if(Z=Z.replace(/%([^%]+)%/g,(Q,X)=>{return process.env[X]||`%${X}%`}),Z.includes("%USERPROFILE%")&&process.env.USERPROFILE)Z=Z.replace(/%USERPROFILE%/g,process.env.USERPROFILE);return q1.file(Z)}function zH0(J,Z){let Q=FH0(Z);if(Q.path.includes("*")){let X=J.toString(),Y=Q.path;if(!Y.startsWith("file://")){if(!Y.startsWith("/"))Y=`/${Y}`;Y=`file://${Y}`}let U=Y.replace(/\./g,"\\.").replace(/\*\*/g,"§DOUBLESTAR§").replace(/\*/g,"[^/]*").replace(/§DOUBLESTAR§/g,".*");return new RegExp(`^${U}$`,"i").test(X)}else return Q.toString().toLowerCase()===J.toString().toLowerCase()}function bL1(J,Z){return Z.some((Q)=>zH0(J,Q))}async function wV6(J,Z){try{return await Z.realpath(J)}catch{}let Q=[],X=J;while(!0){let Y=V1.dirname(X);if(Y.toString()===X.toString())break;Q.unshift(V1.basename(X)),X=Y;try{let V=await Z.realpath(X);for(let D of Q)V=V1.joinPath(V,D);return V}catch{}}return J}async function NV6(J,Z,Q){try{let X=await wV6(J,Z),U=[...["~/.config/AGENT.md"],...Q];for(let V of U)if(zH0(X,V)||zH0(J,V))return null;for(let{key:V,pattern:D}of qH0)if(bL1(X,D.patterns)||bL1(J,D.patterns))return{key:V,pattern:D};return null}catch{return null}}async function GH0(J,Z,Q){if(Q?.dangerouslyAllowAll??!1)return{requiresConsent:!1};try{let Y=await NV6(J,Z,Q["guardedFiles.allowlist"]??[]);if(Y)return{requiresConsent:!0,reason:`${Y.pattern.description}`,toAllow:J.fsPath};return{requiresConsent:!1}}catch{return{requiresConsent:!0,reason:"Unable to resolve file path",toAllow:J.fsPath}}}var qH0;var ma=J0(()=>{J4();qH0=[{key:"vscode-user-settings",pattern:{description:"VS Code User Settings",patterns:["~/Library/Application Support/Code/User/settings.json","~/.config/Code/User/settings.json","%APPDATA%/Code/User/settings.json"]}},{key:"vscode-workspace-config",pattern:{description:"VS Code Workspace Configuration",patterns:["**/.vscode/**"]}},{key:"vscode-workspace-files",pattern:{description:"VS Code Workspace Files",patterns:["**/*.code-workspace"]}},{key:"cursor-config",pattern:{description:"Cursor Configuration",patterns:["**/.cursor/**","~/.cursor/**","~/Library/Application Support/Cursor/**","~/.config/Cursor/**","%APPDATA%/Cursor/**"]}},{key:"windsurf-config",pattern:{description:"Windsurf Configuration",patterns:["**/.windsurf/**","~/.codeium/windsurf/**","~/Library/Application Support/Windsurf/**","~/.config/Windsurf/**","%APPDATA%/Windsurf/**","/Library/Application Support/Windsurf/**","/etc/windsurf/**","%ProgramData%/Windsurf/**"]}},{key:"antigravity-config",pattern:{description:"Antigravity Configuration",patterns:["~/.gemini/**"]}},{key:"jetbrains-config",pattern:{description:"JetBrains IDE Configuration",patterns:["~/Library/Application Support/JetBrains/**","~/.config/JetBrains/**","~/.local/share/JetBrains/**","%APPDATA%/JetBrains/**","%LOCALAPPDATA%/JetBrains/**"]}},{key:"jetbrains-idea-config",pattern:{description:"JetBrains IDE Project Configuration",patterns:["**/.idea/**"]}},{key:"neovim-config",pattern:{description:"Neovim Configuration",patterns:["~/.config/nvim/**","~/.local/share/nvim/**","~/.local/state/nvim/**"]}},{key:"amp-settings",pattern:{description:"Amp Configuration Files",patterns:["**/amp.json","**/.amp/**"]}},{key:"shell-configs",pattern:{description:"Shell Configuration Files",patterns:["~/.bashrc","~/.zshrc","~/.fishrc","~/.cshrc","~/.tcshrc"]}},{key:"ssh-keys",pattern:{description:"SSH Keys and Configuration",patterns:["**/.ssh/**","~/.ssh/**"]}},{key:"gnupg-keys",pattern:{description:"GnuPG Keys and Configuration",patterns:["**/.gnupg/**","~/.gnupg/**"]}},{key:"environment-files",pattern:{description:"Environment Variable Files",patterns:["**/.env","**/.env.*"]}},{key:"claude-config",pattern:{description:"Claude AI Configuration",patterns:["**/.claude/**","~/.claude/**"]}},{key:"codex-config",pattern:{description:"Codex Configuration",patterns:["**/.codex/**","~/.codex/**"]}},{key:"git-internals",pattern:{description:"Git Internal Files",patterns:["**/.git/**"]}},{key:"kubernetes-config",pattern:{description:"Kubernetes Configuration",patterns:["**/.kube/**","~/.kube/**"]}},{key:"cache-directories",pattern:{description:"Cache Directories",patterns:["**/.cache/**","~/.cache/**"]}},{key:"windows-appdata",pattern:{description:"Windows Application Data",patterns:["%APPDATA%/**"]}},{key:"windows-system-directories",pattern:{description:"Windows System Directories",patterns:["%WINDIR%/**","%SYSTEMROOT%/**","%ProgramFiles%/**","%ProgramFiles(x86)%/**","%ProgramData%/**"]}},{key:"sqlite3-files",pattern:{description:"SQLite Database Files",patterns:["**/*.db","**/*.sqlite","**/*.sqlite3"]}},{key:"common-configuration-patterns",pattern:{description:"Configuration Directories",patterns:["~/.*","~/.*/**","~/.config/**","~/Library/**","~/Library/Preferences/**"]}},{key:"macos-applications",pattern:{description:"macOS Applications",patterns:["/Applications/**","~/Applications/**"]}},{key:"macos-system-library",pattern:{description:"macOS System Library",patterns:["/Library/**"]}},{key:"unix-system-directories",pattern:{description:"Unix System Directories",patterns:["/usr/**","/bin/**","/sbin/**","/lib/**","/lib64/**","/boot/**"]}},{key:"system-config-directories",pattern:{description:"System Configuration and State",patterns:["/private/etc/**","/etc/**","/private/var/**","/var/**"]}},{key:"opt-directory",pattern:{description:"Optional Software Installs (/opt, e.g., Homebrew)",patterns:["/opt/**"]}}]});function OV6(){if(Pw.size===0)return;P.info("Killing all child processes");for(let J of Pw)hL1(J);Pw.clear(),P.info("All child processes killed")}function hL1(J){if(!J.pid){try{J.kill("SIGKILL")}catch(Z){P.error("Failed to kill process without PID",Z)}return}if(sv.has(J.pid)){P.debug(`Process ${J.pid} already being killed, skipping`);return}sv.add(J.pid);try{if(process.platform==="win32"){let{spawn:Z}=P0("node:child_process"),Q=Z("taskkill",["/F","/T","/PID",J.pid.toString()],{stdio:"ignore"});Q.on("error",(X)=>{P.error(`Failed to kill Windows process tree ${J.pid}`,X);try{J.kill("SIGKILL")}catch(Y){P.error(`Fallback kill also failed for ${J.pid}`,Y)}}),Q.on("exit",()=>{sv.delete(J.pid)})}else{try{process.kill(J.pid,0),process.kill(-J.pid,"SIGKILL")}catch(Z){P.debug(`Process ${J.pid} no longer exists, skipping kill`)}sv.delete(J.pid)}}catch(Z){P.error(`Failed to kill process ${J.pid}`,Z),sv.delete(J.pid)}}function NY(...J){return new v0((Z)=>{let Q=!1,X,Y=!1;return(async()=>{try{let{spawn:V}=await import("node:child_process");if(Q)return;let D={...J[2],detached:process.platform!=="win32",env:{...process.env,...J[2]?.env||{},NONINTERACTIVE:"1",DEBIAN_FRONTEND:"noninteractive"}};if(!D.stdio)D.stdio=["pipe","pipe","pipe"];X=V(J[0],J[1],D),Pw.add(X);let K={stdout:"",stderr:"",combinedOutput:"",exitCode:null,exited:!1,pid:X.pid};X.on("spawn",()=>{Z.next({...K,process:X})}),X.stdout?.on("data",(z)=>{if(Q)return;let q=z.toString();K.stdout+=q,K.combinedOutput+=q,K.lastData=z,Z.next({...K,process:X})}),X.stderr?.on("data",(z)=>{if(Q)return;let q=z.toString();K.stderr+=q,K.combinedOutput+=q,K.lastData=z,Z.next({...K,process:X})}),X.on("exit",(z)=>{if(Q)return;if(Y)return;if(Y=!0,K.exitCode=z??-1,K.exited=!0,K.lastData=void 0,Z.next({...K,process:X}),Z.complete(),X)Pw.delete(X)}),X.on("error",(z)=>{if(Q)return;if(Z.error(z),X)Pw.delete(X)})}catch(V){if(Q)return;Z.error(V)}})(),()=>{if(Q=!0,X&&!Y)hL1(X),Pw.delete(X)}})}function ga(J){if(typeof J!=="string")throw Error("arg is not a string");if(J.startsWith("-"))throw Error("arg is not safe")}function OV(J){if(!J)throw Error("tool requires a working directory");if(J.scheme!=="file"&&J.scheme!=="vscode-vfs")throw Error(`tool requires a dir with a file: URI (got ${JSON.stringify(J.scheme)})`)}var Pw,sv;var mQ=J0(()=>{H1();m0();Pw=new Set,sv=new Set;if(typeof process<"u")process.on("exit",()=>{OV6()})});function mK(J,Z){if(Z==="")return!1;let Q=J.toLowerCase(),X=Z.toLowerCase();if(X.length===1){if(X==="*")return!0;return X===Q}if(Q===X)return!0;if(X.includes("*")||X.includes("?")||X.includes("[")||X.includes("{"))try{return mL1.default(X,{dot:!0})(Q)}catch(Y){return!1}return!1}function WH0(J,Z){let Q=Z.split("."),X=J;for(let Y of Q){if(X===null||X===void 0)return;if(Array.isArray(X)){let U=parseInt(Y,10);if(isNaN(U)||U<0||U>=X.length)return;X=X[U]}else if(typeof X==="object")X=X[Y];else return}return X}function EV6(J,Z,Q,X){if(!mK(Z,J.tool))return!1;if(J.context&&J.context!==X)return!1;if(!J.matches||Object.keys(J.matches).length===0)return!0;return Object.entries(J.matches).every(([Y,U])=>{if(U===void 0){if(Y.includes("."))return WH0(Q,Y)===void 0;return Y in Q&&Q[Y]===void 0}let V=Y.includes(".")?WH0(Q,Y):Q[Y];return pa(V,U)})}async function LV6(J,Z,Q,X,Y,U){if(J.action!=="delegate"){if(J.action==="reject"&&J.message)return{action:J.action,matchedEntry:J,error:J.message};return{action:J.action,matchedEntry:J}}if(!Q||!J.to)return{action:null,matchedEntry:J,error:"No spawn function provided"};try{let V=await IV6(J.to,Z,Q,X,Y,U);return MV6(V,J)}catch(V){return{action:"reject",error:V instanceof Error?V.message:"Unknown error",matchedEntry:J}}}async function IV6(J,Z,Q,X,Y,U){let V={AGENT:"amp"};if(X)V.AMP_THREAD_ID=X;if(Y)V.AGENT_TOOL_NAME=Y;if(U)V.AGENT_TOOL_USE_ID=U;let K=J.includes("~")||J.includes("%")?FH0(J).path:J,q=Q(K,[],{env:V});return new Promise((F,G)=>{let W;q.subscribe({next:(H)=>{if(typeof H==="object"&&H!==null&&"status"in H&&H.status==="error"){G(Error("Delegate command timed out after 10 seconds"));return}if(H.process&&!H.exited)H.process.stdin?.write(JSON.stringify(Z)),H.process.stdin?.end();W=H},complete:()=>{if(W?.exited)F({exitCode:W.exitCode??-1,stdout:W.stdout,stderr:W.stderr});else G(Error("Process did not exit properly"))},error:(H)=>{G(H)}})})}function MV6({exitCode:J,stderr:Z},Q){switch(J){case 0:return{action:"allow",matchedEntry:Q};case 1:return{action:"ask",matchedEntry:Q};default:return{action:"reject",matchedEntry:Q,error:Z}}}async function xM(J,Z,Q,X,Y,U,V,D){let K=0;for(let z of Q)try{if(!EV6(z,J,Z,X)){K=K+1;continue}let q=await LV6(z,Z,Y,U,J,D);if(q.matchIndex=K,V)q.source=V;return q}catch(q){return{action:null,error:q instanceof Error?q.message:"Unknown error"}}return{action:null}}function pa(J,Z){if(typeof Z==="string"){if(typeof J!=="string")return!1;return jV6(J,Z)}if(Array.isArray(Z))return Z.some((Q)=>{if(typeof Q==="string")return typeof J==="string"&&HH0(J,Q);return J===Q});if(typeof Z==="object"&&Z!==null)return AV6(J,Z);return J===Z}function AV6(J,Z){if(Object.keys(Z).length===0)return typeof J==="object"&&J!==null;if(typeof J!=="object"||J===null)return!1;for(let[Q,X]of Object.entries(Z)){let Y=WH0(J,Q);if(!pa(Y,X))return!1}return!0}function jV6(J,Z){if(typeof Z==="string")return HH0(J,Z);if(Array.isArray(Z))return Z.some((Q)=>typeof Q==="string"&&HH0(J,Q));return!1}function HH0(J,Z){if(Z.length>=3&&Z.startsWith("/")&&Z.endsWith("/"))try{let Y=Z.slice(1,-1);return new RegExp(Y,"m").test(J)}catch(Y){throw Error(`Invalid regex pattern: ${Z}`)}if(Z==="*")return!0;if(!Z.includes("*"))return J===Z;let Q=Z.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${Q}$`,"m").test(J)}var mL1,tv;var Cw=J0(()=>{ma();mQ();mL1=H4(hK(),1),tv=NY});class gL1{input;position=0;line=1;column=1;tokens=[];constructor(J){this.input=J}current(){return this.position<this.input.length?this.input[this.position]:""}peek(){return this.position+1<this.input.length?this.input[this.position+1]:""}advance(){let J=this.current();if(this.position++,J===`
95
95
  `)this.line++,this.column=1;else this.column++;return J}skipWhitespace(){while(this.current()&&/\s/.test(this.current())&&this.current()!==`
96
96
  `)this.advance()}readString(){let J="",Z=this.current();this.advance();while(this.current()&&this.current()!==Z)if(this.current()==="\\"&&this.peek()===Z)this.advance(),J+=this.advance();else J+=this.advance();if(!this.current())throw Error("Unterminated string");return this.advance(),J}readIdentifier(){let J="";if(this.current()==="-"&&/\d/.test(this.peek()))J+=this.advance();while(this.current()&&/[a-zA-Z0-9_*.-]/.test(this.current()))J+=this.advance();if((this.current()==="e"||this.current()==="E")&&/[-+]?\d/.test(this.peek())){if(J+=this.advance(),this.current()==="+"||this.current()==="-")J+=this.advance();while(this.current()&&/\d/.test(this.current()))J+=this.advance()}return J}readFlag(){let J="";this.advance(),this.advance();while(this.current()&&/[a-zA-Z0-9_*:.-]/.test(this.current()))J+=this.advance();return J}readComment(){let J="";this.advance();while(this.current()&&this.current()!==`
97
97
  `)J+=this.advance();return J.trim()}tokenize(){this.tokens=[];while(this.position<this.input.length){let J={position:this.position,line:this.line,column:this.column};if(this.skipWhitespace(),!this.current())break;if(this.current()==="'"||this.current()==='"'){try{let Z=this.readString();this.tokens.push({type:"STRING",value:Z,...J})}catch(Z){throw Error(`Parse error at line ${this.line}, column ${this.column}: ${Z}`)}continue}if(this.current()===`
@@ -5865,11 +5865,11 @@ ${W}`))}},error:(G)=>{if(!F)F=!0,D(Error(`Failed to spawn brew: ${G.message}`))}
5865
5865
  ${W}`;if(Y==="pnpm"&&W.includes("Unable to find the global bin directory"))H+=`
5866
5866
 
5867
5867
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
5868
- npm install -g @sourcegraph/amp`;D(Error(H))}},error:(G)=>{if(!q)q=!0,D(Error(`Failed to spawn ${Y}: ${G.message}`))},complete:()=>{if(!q)q=!0,V()}})})}m0();m0();sA();async function l30(J,Z){let X=Z||"https://registry.npmjs.org",Y=new AbortController,U=setTimeout(()=>Y.abort(),5000);try{let V=await fetch(`${X}/@sourcegraph/amp`,{signal:Y.signal});if(!V.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let D=await V.json(),K=D["dist-tags"]?.latest;if(!K)return{hasUpdate:!1,currentVersion:J,source:"npm"};let z=VX4(J,K),q=z<0,F,G;if(D.time){let W=D.time[J],H=D.time[K],B=Date.now();if(W)F=Math.floor((B-new Date(W).getTime())/3600000);if(H)G=Math.floor((B-new Date(H).getTime())/3600000)}return P.info("NPM version comparison",{currentVersion:J,latestVersion:K,compareResult:z,hasUpdate:q,currentVersionAge:F,latestVersionAge:G}),{hasUpdate:q,latestVersion:K,currentVersion:J,currentVersionAge:F,latestVersionAge:G,source:"npm"}}catch(V){return P.debug("Error checking npm version",{error:V}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(U)}}var aw5="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function i30(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let X=await fetch(`${aw5}?t=${Date.now()}`,{signal:Z.signal,cache:"no-store"});if(!X.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let Y=(await X.text()).trim();if(!Y||!/^\d+\.\d+\.\d+/.test(Y))return{hasUpdate:!1,currentVersion:J,source:"bin"};let U=VX4(J,Y),V=U<0;return P.info("Bin version comparison",{currentVersion:J,latestVersion:Y,compareResult:U,hasUpdate:V}),{hasUpdate:V,latestVersion:Y,currentVersion:J,source:"bin"}}catch(X){return P.debug("Error checking bin version",{error:X}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var ow5=604800000;function UX4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>ow5)return{ageMs:Q};return null}function VX4(J,Z){let Q=(V)=>{let[D,K]=V.split("-");return{parts:D?.split(".").map(Number)||[],label:K}},X=Q(J),Y=Q(Z),U=Math.max(X.parts.length,Y.parts.length);for(let V=0;V<U;V++){let D=X.parts[V]||0,K=Y.parts[V]||0;if(D<K)return-1;if(D>K)return 1}if(X.label===Y.label)return 0;if(!X.label&&Y.label)return 1;if(X.label&&!Y.label)return-1;if(X.label&&Y.label)return X.label<Y.label?-1:1;return 0}function ty0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,X=Z[2],Y=Q!==0?YG(Q):void 0;return{sha:X,age:Y}}catch{return null}}H1();function ey0(J,Z){let Q=new U4,X=Q.pipe(L6({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new XV().scoped("update"),U=X.subscribe({next:(V)=>{Y.debug("emit new state",V)}});try{let V=process.env.AMP_TEST_UPDATE_STATUS;if(V){Y.debug("using fake update status for testing",{status:V}),await Kz(500),Q.next(V);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){Y.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let D=await Z.get("updates.mode");if(D==="disabled"){Y.debug("checking disabled");return}let K=await c30(),z=K==="binary"||K==="brew";Y.debug("checking",{currentVersion:J,mode:D,packageManager:K,isBinaryDistribution:z});let q=z?await i30(J):await l30(J,BE());if(!(q.latestVersion&&q.hasUpdate)){Y.debug("no update available");return}let F=()=>{if(q.currentVersionAge!==void 0&&q.latestVersionAge!==void 0){let G=q.currentVersionAge-q.latestVersionAge,W=0.5;if(Math.abs(G)<0.5)return Y.debug("versions too close together, suppressing update warning",{currentVersionAge:q.currentVersionAge,latestVersionAge:q.latestVersionAge,ageDifferenceHours:G}),!0}return!1};if(!D)D=K==="pnpm"?"warn":"auto",Y.debug("no configured update mode; selected default based on package manager",{packageManager:K,mode:D});if(K==="brew"){if(!F())Q.next("update-available-brew");return}if(K==="binary"&&process.execPath!==iy0()){if(Y.debug("non-standard binary path, showing warning"),!F())Q.next("update-available-unrecognized-path");return}if(D==="warn"){if(!F())Q.next("update-available");return}if(!K){if(Y.debug("auto-update not supported, falling back to warn mode"),!F())Q.next("update-available");return}if(K==="binary"&&process.platform==="win32"){if(Y.debug("binary auto-update not supported on Windows, falling back to warn mode"),!F())Q.next("update-available");return}try{await zm(q.latestVersion,K);let G=await bW(q.latestVersion),W={from:q.currentVersion,to:q.latestVersion,...G};if(G.status==="same")Y.info("success",W),Q.next("updated");else Y.warn("success with warning",W),Q.next("updated-with-warning")}catch(G){Q.next("update-error")}}catch(V){Y.debug("check failed",{error:V})}finally{await Kz(5000),Q.next("hidden"),U.unsubscribe(),Q.complete()}}),{state:X}}sA();import{stderr as _D}from"node:process";function DX4(J){let Z=new RW().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(X)=>{await py0(X.force||!1,X.verbose||!1,"0.0.1772201356-g024e62"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new RW("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--target-version <version>","Update to a specific version").allowUnknownOption(!1).action(async(X)=>{await rw5(X.targetVersion)});J.addCommand(Q)}async function rw5(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")_D.write(Z1.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
5868
+ npm install -g @sourcegraph/amp`;D(Error(H))}},error:(G)=>{if(!q)q=!0,D(Error(`Failed to spawn ${Y}: ${G.message}`))},complete:()=>{if(!q)q=!0,V()}})})}m0();m0();sA();async function l30(J,Z){let X=Z||"https://registry.npmjs.org",Y=new AbortController,U=setTimeout(()=>Y.abort(),5000);try{let V=await fetch(`${X}/@sourcegraph/amp`,{signal:Y.signal});if(!V.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let D=await V.json(),K=D["dist-tags"]?.latest;if(!K)return{hasUpdate:!1,currentVersion:J,source:"npm"};let z=VX4(J,K),q=z<0,F,G;if(D.time){let W=D.time[J],H=D.time[K],B=Date.now();if(W)F=Math.floor((B-new Date(W).getTime())/3600000);if(H)G=Math.floor((B-new Date(H).getTime())/3600000)}return P.info("NPM version comparison",{currentVersion:J,latestVersion:K,compareResult:z,hasUpdate:q,currentVersionAge:F,latestVersionAge:G}),{hasUpdate:q,latestVersion:K,currentVersion:J,currentVersionAge:F,latestVersionAge:G,source:"npm"}}catch(V){return P.debug("Error checking npm version",{error:V}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(U)}}var aw5="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function i30(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let X=await fetch(`${aw5}?t=${Date.now()}`,{signal:Z.signal,cache:"no-store"});if(!X.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let Y=(await X.text()).trim();if(!Y||!/^\d+\.\d+\.\d+/.test(Y))return{hasUpdate:!1,currentVersion:J,source:"bin"};let U=VX4(J,Y),V=U<0;return P.info("Bin version comparison",{currentVersion:J,latestVersion:Y,compareResult:U,hasUpdate:V}),{hasUpdate:V,latestVersion:Y,currentVersion:J,source:"bin"}}catch(X){return P.debug("Error checking bin version",{error:X}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var ow5=604800000;function UX4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>ow5)return{ageMs:Q};return null}function VX4(J,Z){let Q=(V)=>{let[D,K]=V.split("-");return{parts:D?.split(".").map(Number)||[],label:K}},X=Q(J),Y=Q(Z),U=Math.max(X.parts.length,Y.parts.length);for(let V=0;V<U;V++){let D=X.parts[V]||0,K=Y.parts[V]||0;if(D<K)return-1;if(D>K)return 1}if(X.label===Y.label)return 0;if(!X.label&&Y.label)return 1;if(X.label&&!Y.label)return-1;if(X.label&&Y.label)return X.label<Y.label?-1:1;return 0}function ty0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,X=Z[2],Y=Q!==0?YG(Q):void 0;return{sha:X,age:Y}}catch{return null}}H1();function ey0(J,Z){let Q=new U4,X=Q.pipe(L6({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new XV().scoped("update"),U=X.subscribe({next:(V)=>{Y.debug("emit new state",V)}});try{let V=process.env.AMP_TEST_UPDATE_STATUS;if(V){Y.debug("using fake update status for testing",{status:V}),await Kz(500),Q.next(V);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){Y.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let D=await Z.get("updates.mode");if(D==="disabled"){Y.debug("checking disabled");return}let K=await c30(),z=K==="binary"||K==="brew";Y.debug("checking",{currentVersion:J,mode:D,packageManager:K,isBinaryDistribution:z});let q=z?await i30(J):await l30(J,BE());if(!(q.latestVersion&&q.hasUpdate)){Y.debug("no update available");return}let F=()=>{if(q.currentVersionAge!==void 0&&q.latestVersionAge!==void 0){let G=q.currentVersionAge-q.latestVersionAge,W=0.5;if(Math.abs(G)<0.5)return Y.debug("versions too close together, suppressing update warning",{currentVersionAge:q.currentVersionAge,latestVersionAge:q.latestVersionAge,ageDifferenceHours:G}),!0}return!1};if(!D)D=K==="pnpm"?"warn":"auto",Y.debug("no configured update mode; selected default based on package manager",{packageManager:K,mode:D});if(K==="brew"){if(!F())Q.next("update-available-brew");return}if(K==="binary"&&process.execPath!==iy0()){if(Y.debug("non-standard binary path, showing warning"),!F())Q.next("update-available-unrecognized-path");return}if(D==="warn"){if(!F())Q.next("update-available");return}if(!K){if(Y.debug("auto-update not supported, falling back to warn mode"),!F())Q.next("update-available");return}if(K==="binary"&&process.platform==="win32"){if(Y.debug("binary auto-update not supported on Windows, falling back to warn mode"),!F())Q.next("update-available");return}try{await zm(q.latestVersion,K);let G=await bW(q.latestVersion),W={from:q.currentVersion,to:q.latestVersion,...G};if(G.status==="same")Y.info("success",W),Q.next("updated");else Y.warn("success with warning",W),Q.next("updated-with-warning")}catch(G){Q.next("update-error")}}catch(V){Y.debug("check failed",{error:V})}finally{await Kz(5000),Q.next("hidden"),U.unsubscribe(),Q.complete()}}),{state:X}}sA();import{stderr as _D}from"node:process";function DX4(J){let Z=new RW().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(X)=>{await py0(X.force||!1,X.verbose||!1,"0.0.1772208429-ge4b10a"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new RW("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--target-version <version>","Update to a specific version").allowUnknownOption(!1).action(async(X)=>{await rw5(X.targetVersion)});J.addCommand(Q)}async function rw5(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")_D.write(Z1.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
5869
5869
 
5870
5870
  `));try{if(!J){_D.write(Z1.blue(`Checking for updates...
5871
- `));let{hasUpdate:X,latestVersion:Y}=dy0()?await i30("0.0.1772201356-g024e62"):await l30("0.0.1772201356-g024e62",BE());if(!X){let U=ty0("0.0.1772201356-g024e62"),V=U?.age?`released ${U.age} ago`:`built ${YG(new Date("2026-02-27T14:14:52.407Z"))} ago`;_D.write(Z1.green(`✓ Amp is already up to date on version ${"0.0.1772201356-g024e62"} (${V})
5872
- `));let D=await bW("0.0.1772201356-g024e62");if(D.warning)_D.write(`
5871
+ `));let{hasUpdate:X,latestVersion:Y}=dy0()?await i30("0.0.1772208429-ge4b10a"):await l30("0.0.1772208429-ge4b10a",BE());if(!X){let U=ty0("0.0.1772208429-ge4b10a"),V=U?.age?`released ${U.age} ago`:`built ${YG(new Date("2026-02-27T16:13:08.868Z"))} ago`;_D.write(Z1.green(`✓ Amp is already up to date on version ${"0.0.1772208429-ge4b10a"} (${V})
5872
+ `));let D=await bW("0.0.1772208429-ge4b10a");if(D.warning)_D.write(`
5873
5873
  `+Z1.yellow(D.warning)+`
5874
5874
  `);process.exit(0)}if(!Y)_D.write(Z1.yellow("[WARN] could not find latest version")),process.exit(0);J=Y}_D.write(Z1.blue(`Updating to version ${J}...
5875
5875
  `)),await zm(J,void 0,(X)=>{_D.write(Z1.dim(`Running: ${X}
@@ -6193,7 +6193,7 @@ To fix: Add "amp.mcpTrustedWorkspaces": ["${Z.getWorkspaceRootPath()}"] to ${X}
6193
6193
  `)}};function vN5(J){let Z={};for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X&&X.startsWith("--")){let Y=X.slice(2),U=J[Q+1];if(U&&!U.startsWith("--"))Z[Y]=U,Q++}}return Z}function kN5(J){if(J.action==="ask")return 1;if(J.action==="reject")return 2;return 0}async function RX4(J){let Z=J.json?_N5:SN5;try{let Q=vN5(J.remainingArgs),X=await J.settings.get("permissions",J.scope)??[],Y=TF(X);if(!Y.success){let V={success:!1,error:"Invalid permissions configuration",details:Y.error.issues.map((D)=>({path:D.path.join("."),message:D.message,code:D.code}))};Z.outputError(J,Q,V),J.exit(1);return}let U=await xM(J.toolName,Q,Y.data,J.context,tv,J.threadId,"user");if(!U.matchedEntry)U=await xM(J.toolName,Q,uM,J.context,tv,J.threadId,"built-in");Z.outputResult(J,Q,U),J.exit(kN5(U))}catch(Q){let X={success:!1,error:Q instanceof Error?Q.message:"Unknown error"};Z.outputError(J,{},X),J.exit(1)}}function PX4(J,Z){let Q=J.command("permissions").alias("permission").summary("Manage permissions").description(`Configure and test tool permissions to control what actions the AI agent can take.
6194
6194
 
6195
6195
  See ${Z1.underline("https://ampcode.com/manual#permissions")} for more details`).enablePositionalOptions();yN5(Q,Z),uN5(Q,Z),xN5(Q,Z),fN5(Q,Z)}function yN5(J,Z){J.command("list").alias("ls").summary("List permissions").description("List user-configured permissions.").option("--json","output as JSON").option("--builtin","output only builtin permissions").option("-w, --workspace","List workspace permissions instead of global").action(async(Q,X)=>{let Y=await Z(X),U=X.optsWithGlobals();await jX4({builtinOnly:U.builtin??!1,settings:Y.settings,exit:process.exit.bind(process),json:U.json,stdout:process.stdout,scope:U.workspace?"workspace":"global"})})}function uN5(J,Z){J.command("test").summary("Test permissions").description("Test permissions against configured rules without running the tool.").argument("<tool-name>","Name of the tool to test").option("-c, --context <context>","Execution context (thread or subagent)").option("-t, --thread-id <id>","Thread ID for evaluation").option("--json","output as JSON").option("-q, --quiet","suppress output, only use exit status").option("-w, --workspace","Test against workspace permissions instead of global").allowUnknownOption(!0).action(async(Q,X,Y)=>{let U=await Z(Y),V=()=>!1;await RX4({toolName:Q,context:X.context,threadId:X.threadId,json:X.json,settings:U.settings,remainingArgs:Y.args,stdout:X.quiet?{write:V}:process.stdout,stderr:process.stderr,exit:process.exit.bind(process),scope:X.workspace?"workspace":"global"})}).addHelpText("after",["Example: "," # Test permissions of Amp trying to use bash"," amp permissions test Bash --cmd ls"," # ...when running in a subagent"," amp permissions test --context subagent Bash --cmd ls","","See output of:",""," amp tools show","","for all tool schemas."].join(`
6196
- `))}function xN5(J,Z){J.command("edit").summary("Edit permissions").description("Edit permissions interactively in your $EDITOR or from stdin.").option("-w, --workspace","Edit workspace permissions instead of global").action(async(Q,X)=>{let Y=await Z(X);await a30({settings:Y.settings,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,exit:process.exit.bind(process),resolveEditor:ZC,scope:Q.workspace?"workspace":"global"})})}function fN5(J,Z){J.command("add").summary("Add permission rule").description("Add a permission rule to the beginning of the list. Rules are evaluated in order, so newer rules take precedence.").argument("<action>","Permission action: allow, reject, ask, or delegate").option("--to <program>","Program to delegate decision to for delegate action").option("--context <type>","Limit to specific context (thread or subagent)").option("-w, --workspace","Add to workspace permissions instead of global").argument("<tool>",'Tool name (supports globs like "mcp__playwright__*")').allowUnknownOption(!0).action(async(Q,X,Y,U)=>{let V=await Z(U);await LX4({args:U.parent?.args.slice(1)??[],settings:V.settings,stderr:process.stderr,exit:process.exit.bind(process),scope:Y.workspace?"workspace":"global"})})}m0();import{exec as bN5}from"node:child_process";import{platform as hN5}from"node:os";import{stderr as QC}from"node:process";u9();async function CX4(J,Z,Q){let U=(await(await vJ({configService:Z},Q)).messages.create({model:pV,max_tokens:300,system:"You are a classifier that answers yes/no questions. You must use the provided tool to give your answer with reasoning.",messages:[{role:"user",content:J}],tools:[{name:"answer_question",description:"Provide your answer to the yes/no question with reasoning",input_schema:{type:"object",properties:{probability_yes:{type:"number",description:'Probability that the answer is "yes", from 0 to 1. Use 0 for definitely no, 0.5 for uncertain, 1 for definitely yes.'},reasoning:{type:"string",description:"Brief (2-sentence max) explanation of why you gave this probability."}},required:["probability_yes","reasoning"]}}],tool_choice:{type:"tool",name:"answer_question"}},{headers:{"anthropic-beta":"interleaved-thinking-2025-05-14"}})).content.find((q)=>q.type==="tool_use");if(!U||U.type!=="tool_use")throw Error("Expected tool use response from Claude");let V=U.input,D=V.probability_yes??0.5,K=V.reasoning??"No reasoning provided",z;if(D>=0.8)z="yes";else if(D<0.2)z="no";else z="uncertain";return{result:z,probability:D,reason:K}}class Qu0{clientKind="terminal";clientVersion="0.0.1772201356-g024e62";showToast=null;appendToThreadHandler=null;showOpenedURLToast=null;showInputDialog=null;showConfirmDialog=null;configService;constructor(J){this.configService=J.configService}async notify(J){if(this.showToast)this.showToast(J);else P.debug("plugin notification (TUI not loaded): %s",J)}async open(J){let Z=hN5(),Q=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";if(await new Promise((X,Y)=>{bN5(`${Q} ${JSON.stringify(J)}`,(U)=>{if(U)Y(U);else X()})}),this.showOpenedURLToast)this.showOpenedURLToast(J);else QC.write(`
6196
+ `))}function xN5(J,Z){J.command("edit").summary("Edit permissions").description("Edit permissions interactively in your $EDITOR or from stdin.").option("-w, --workspace","Edit workspace permissions instead of global").action(async(Q,X)=>{let Y=await Z(X);await a30({settings:Y.settings,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,exit:process.exit.bind(process),resolveEditor:ZC,scope:Q.workspace?"workspace":"global"})})}function fN5(J,Z){J.command("add").summary("Add permission rule").description("Add a permission rule to the beginning of the list. Rules are evaluated in order, so newer rules take precedence.").argument("<action>","Permission action: allow, reject, ask, or delegate").option("--to <program>","Program to delegate decision to for delegate action").option("--context <type>","Limit to specific context (thread or subagent)").option("-w, --workspace","Add to workspace permissions instead of global").argument("<tool>",'Tool name (supports globs like "mcp__playwright__*")').allowUnknownOption(!0).action(async(Q,X,Y,U)=>{let V=await Z(U);await LX4({args:U.parent?.args.slice(1)??[],settings:V.settings,stderr:process.stderr,exit:process.exit.bind(process),scope:Y.workspace?"workspace":"global"})})}m0();import{exec as bN5}from"node:child_process";import{platform as hN5}from"node:os";import{stderr as QC}from"node:process";u9();async function CX4(J,Z,Q){let U=(await(await vJ({configService:Z},Q)).messages.create({model:pV,max_tokens:300,system:"You are a classifier that answers yes/no questions. You must use the provided tool to give your answer with reasoning.",messages:[{role:"user",content:J}],tools:[{name:"answer_question",description:"Provide your answer to the yes/no question with reasoning",input_schema:{type:"object",properties:{probability_yes:{type:"number",description:'Probability that the answer is "yes", from 0 to 1. Use 0 for definitely no, 0.5 for uncertain, 1 for definitely yes.'},reasoning:{type:"string",description:"Brief (2-sentence max) explanation of why you gave this probability."}},required:["probability_yes","reasoning"]}}],tool_choice:{type:"tool",name:"answer_question"}},{headers:{"anthropic-beta":"interleaved-thinking-2025-05-14"}})).content.find((q)=>q.type==="tool_use");if(!U||U.type!=="tool_use")throw Error("Expected tool use response from Claude");let V=U.input,D=V.probability_yes??0.5,K=V.reasoning??"No reasoning provided",z;if(D>=0.8)z="yes";else if(D<0.2)z="no";else z="uncertain";return{result:z,probability:D,reason:K}}class Qu0{clientKind="terminal";clientVersion="0.0.1772208429-ge4b10a";showToast=null;appendToThreadHandler=null;showOpenedURLToast=null;showInputDialog=null;showConfirmDialog=null;configService;constructor(J){this.configService=J.configService}async notify(J){if(this.showToast)this.showToast(J);else P.debug("plugin notification (TUI not loaded): %s",J)}async open(J){let Z=hN5(),Q=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";if(await new Promise((X,Y)=>{bN5(`${Q} ${JSON.stringify(J)}`,(U)=>{if(U)Y(U);else X()})}),this.showOpenedURLToast)this.showOpenedURLToast(J);else QC.write(`
6197
6197
  Opened URL: ${J}
6198
6198
 
6199
6199
  `)}async input(J){if(this.showInputDialog)return this.showInputDialog(J);QC.write(`
@@ -6840,7 +6840,7 @@ Ctrl-X, Y, Z to unlock`;if(G){let f=z.text.replace(/`([^`]+)`/g,"$1")+`
6840
6840
  `),new T("Ctrl+O",B),new T(" for ",N),new T("help",w),new T(`
6841
6841
 
6842
6842
 
6843
- `,N)])}),A];if(!K&&!G&&z.url){let h=z.url.replace(/^https?:\/\//,"");_.push(new J5({uri:z.url,text:h,style:new b({color:Q.secondary,underline:!0})}))}if(M&&!G)_.push(M);let k=new R0({width:50,child:new u0({crossAxisAlignment:"start",mainAxisSize:"min",children:_})}),u=W?new R0({width:O20,height:E20}):new Nx0({width:O20,height:E20,agentMode:this.widget.agentMode,glow:this._glow,backgroundColor:Q.background,t:q,fps:0,shockwaves:this._shockwaves,onShockwave:this.handleShockwave,onClick:this.handleOrbClick,...V==="disabled"&&{seed:42}});return a1.child(new K1({mainAxisAlignment:"center",crossAxisAlignment:"center",mainAxisSize:"min",children:[u,new R0({width:2}),k]}))}}class gm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new QB4}}class QB4 extends g0{build(J){let Q=f0.of(J).colors,{todos:X,title:Y="TODOs"}=this.widget.props;if(!Array.isArray(X)||X.length===0)return new R0({width:0,height:0});let U=X.map((V)=>this.buildTodoItem(V,Q));return new l0({child:new o0({padding:C0.symmetric(1,0),child:new u0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new Q0({text:new T(Y,new b({bold:!0,color:Q.foreground}))}),...U]})})})}buildTodoItem(J,Z){let Q=this.getStatusIcon(J.status),X=J.status==="completed",Y=new b({bold:J.status==="in-progress",color:Z.foreground,dim:X}),U=new b({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Z.foreground,dim:X});return new K1({crossAxisAlignment:"start",children:[new Q0({text:new T(Q,Y)}),new R0({width:1}),new S1({child:new Q0({text:new T(J.content,U)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class pm0 extends p0{ad;onDismiss;onButtonClick;onImpression;onAdInfoClick;constructor({key:J,ad:Z,onDismiss:Q,onButtonClick:X,onImpression:Y,onAdInfoClick:U}){super({key:J});this.ad=Z,this.onDismiss=Q,this.onButtonClick=X,this.onImpression=Y,this.onAdInfoClick=U}createState(){return new XB4}}class XB4 extends g0{lastTrackedAdId=null;initState(){super.initState(),this.fireImpressionIfNeeded()}didUpdateWidget(J){super.didUpdateWidget(J),this.fireImpressionIfNeeded()}fireImpressionIfNeeded(){let J=this.widget.ad;if(J.id!==this.lastTrackedAdId)this.lastTrackedAdId=J.id,this.widget.onImpression?.(J)}build(J){let Z=f0.of(J),Q=Z.colors.primary,X=Z.colors.foreground,Y=Z.colors.background,U=this.widget.ad;return new l0({decoration:new _4(Y,new h1(new y1(Q,1,"rounded"),new y1(Q,1,"rounded"),void 0,new y1(Q,1,"rounded"))),child:new o0({padding:C0.horizontal(1),child:new u0({children:[new K1({crossAxisAlignment:"start",children:[new S1({child:new Q0({text:new T(U.content,new b({color:X}))})}),new R0({width:4}),new i1({onClick:()=>this.widget.onAdInfoClick?.(),cursor:"pointer",child:new Q0({text:new T("Ad",new b({color:X,dim:!0}))})})]}),new K1({crossAxisAlignment:"start",children:[new om({text:U.buttonLabel,onPressed:()=>this.widget.onButtonClick?.(),padding:C0.horizontal(1),color:Q,reverse:!0}),new R0({width:2}),new Q0({text:new T(U.destinationUrlHostname,new b({color:X,dim:!0}))})]})]})})})}}class dm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new YB4(this.props.autofocus??!0)}}class YB4 extends g0{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=P1.of(J).colorScheme,X=(z)=>{if(z.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(z.ctrlKey&&z.key==="c"||z.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},Y=s1.sizeOf(J),U=Math.min(60,Y.width-4),V=Y.height-4,D=[];if(this.widget.props.title)D.push(new Q0({text:new T(this.widget.props.title,new b({bold:!0,color:Q.primary}))}),new R0({height:1}));if(this.widget.props.message)D.push(new Q0({text:new T(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)D.push(new R0({height:1}));let K=[];if(this.widget.props.showCopyOption)K.push(new Q0({text:new T("Enter to copy",new b({dim:!0}))}));return K.push(new Q0({text:new T("Escape to close",new b({dim:!0}))})),D.push(new K1({children:K.flatMap((z,q)=>q<K.length-1?[z,new R0({width:1}),new Q0({text:new T("•",new b({dim:!0}))}),new R0({width:1})]:[z]),mainAxisSize:"min"})),new a1({child:new l0({constraints:new I1(U,U,0,V),decoration:new _4(Q.background,new h1(new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"))),padding:new C0(2,2,2,2),child:new T4({autofocus:this.autofocus,onKey:X,child:new u0({children:D,mainAxisSize:"min"})})})})}}class cm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new UB4(this.props.autofocus??!0)}}class UB4 extends g0{autofocus;constructor(J){super();this.autofocus=J}build(J){let Z=P1.of(J).colorScheme,Q=(D)=>{if(D.key==="Enter"||D.key==="Escape"||D.ctrlKey&&D.key==="c")return this.widget.props.onClose(),"handled";return"ignored"},X=s1.sizeOf(J),Y=Math.min(60,X.width-4),U=X.height-4,V=[];if(V.push(new Q0({text:new T("Ads make Amp Free possible",new b({bold:!0}))})),this.widget.props.provider)V.push(new R0({height:1}),new Q0({text:new T(`Ad source: ${this.widget.props.provider}`,new b({dim:!0}))}));return V.push(new R0({height:1}),new Q0({text:new T("Escape to close",new b({dim:!0}))})),new a1({child:new l0({constraints:new I1(Y,Y,0,U),decoration:new _4(Z.background,new h1(new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"))),padding:new C0(2,2,2,2),child:new T4({autofocus:this.autofocus,onKey:Q,child:new u0({children:V,mainAxisSize:"min"})})})})}}m0();n9();import{execSync as Mh5}from"node:child_process";oM();WJ();O3();t7();Cw();IY();M$();MZ();EY();iO();c4();ku();Sv();H1();var Xw4=H4(Dz(),1);import{writeFile as eB4}from"fs/promises";import $w4 from"path";m0();M$();class lm0{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1772201356-g024e62"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await us(Z,this.configService)}catch(Z){P.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class _H extends p0{props;constructor(J){super();this.props=J}createState(){return new VB4}}class VB4 extends g0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}class DB4 extends g0{controller=new v7;focusNode=new i4({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:X}=Z,Y=this.widget.props.isRequiredArg??!0,U=this.controller.text.trim().length>0,V=!Y||U,D=h1.all(new y1(Q.foreground,1,"solid")),K=new c$({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(W)=>{let H=W.trim();if(Y&&H.length===0)return;this.widget.props.onSubmit(H)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),z=new K1({children:[new l0({decoration:{color:Q.background},child:new Q0({text:new T(">",new b({color:Q.foreground}))})}),new S1({child:K})]}),q=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("",void 0,[new T("Command: ",new b({color:Q.foreground})),new T(this.widget.props.commandName,new b({color:X.command,bold:!0}))])})}),F=[];if(V)F.push(new T("Enter",new b({color:X.keybind}))),F.push(new T(" to submit, ",new b({color:Q.foreground,dim:!0})));F.push(new T("Esc",new b({color:X.keybind}))),F.push(new T(" to cancel",new b({color:Q.foreground,dim:!0})));let G=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("",void 0,F)})});return new l0({decoration:{border:D,color:Q.background},padding:C0.all(1),child:new u0({children:[q,new R0({height:1}),z,new Z3,G]})})}}class Fp extends p0{props;constructor(J){super();this.props=J}createState(){return new DB4}}import{isDeepStrictEqual as im0}from"node:util";var ob5=/[\\/_ +.#"@[({&]/,rb5=/[\\/_ +.#"@[({&]/g,sb5=/[\s-]/,KB4=/[\s-]/g;function M20(J,Z,Q,X,Y,U,V){if(U===Z.length){if(Y===J.length)return 1;return 0.99}let D=`${Y},${U}`;if(V[D]!==void 0)return V[D];let K=X.charAt(U),z=Q.indexOf(K,Y),q=0,F,G,W,H;while(z>=0){if(F=M20(J,Z,Q,X,z+1,U+1,V),F>q){if(z===Y)F*=1;else if(sb5.test(J.charAt(z-1))){if(F*=0.9,H=J.slice(Y,z-1).match(KB4),H&&Y>0)F*=0.999**H.length}else if(ob5.test(J.charAt(z-1))){if(F*=0.8,W=J.slice(Y,z-1).match(rb5),W&&Y>0)F*=0.999**W.length}else if(F*=0.3,Y>0)F*=0.999**(z-Y);if(J.charAt(z)!==Z.charAt(U))F*=0.9999}if(F<0.1&&(Q.charAt(z-1)===X.charAt(U+1)||X.charAt(U+1)===X.charAt(U)&&Q.charAt(z-1)!==X.charAt(U))){if(G=M20(J,Z,Q,X,z+1,U+2,V),G*0.1>F)F=G*0.1}if(F>q)q=F;z=Q.indexOf(K,z+1)}return V[D]=q,q}function I20(J){return J.toLowerCase().replace(KB4," ")}function zB4(J,Z){let Q=M20(J,Z,I20(J),I20(Z),0,0,{}),X=Z.trim().split(/\s+/);if(X.length>1){let Y=0,U=0;for(let D of X){let K=M20(J,D,I20(J),I20(D),0,0,{});if(K===0)return Q;Y+=K,U+=D.length}let V=Y/X.length*0.95;return Math.max(Q,V)}return Q}class zT{}class qT{}class A20{}class j20{}class qB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new FB4}}class FB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}function tb5(J,Z){if(J==="")return{matches:!0,score:1};let Q=zB4(Z,J);return{matches:Q>0.15,score:Q}}class p9 extends p0{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new GB4}}class GB4 extends g0{textController;focusNode;scrollController=new r6;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){if(this.scrollController.disableFollowMode(),this.textController=new v7(this.widget.props.controller?.query??""),this.focusNode=new i4({debugLabel:this.widget.debugLabel}),this.textController.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let J=this.widget.props.controller;if(J)J.query=this.textController.text;this.syncSelection()}),this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let J=this.cachedFiltered.findIndex((Z)=>im0(Z,this.widget.props.controller?.selectedItem));if(J>=0)this.selectedIndex=J}this.clampSelectedIndex(),this.syncSelection(),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!im0(J.props.items,this.widget.props.items)){if(this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let Z=this.cachedFiltered.findIndex((Q)=>im0(Q,this.widget.props.controller?.selectedItem));if(Z>=0)this.selectedIndex=Z}this.clampSelectedIndex(),this.ensureSelectedItemVisible(),this.syncSelection()}}dispose(){this.widget.props.onSelectionChange?.(null),this.textController.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof zT){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof qT){if(this.getFilteredItems().length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof A20){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length){let Q=Z[this.selectedIndex];if(Q){if(!(this.widget.props.isItemDisabled?.(Q)??!1))this.widget.props.onAccept(Q,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof j20)return this.widget.props.onDismiss?.(),"handled";return"ignored"};syncSelection(){let Z=this.cachedFiltered[this.selectedIndex]??null;if(this.widget.props.controller)this.widget.props.controller.selectedItem=Z;this.widget.props.onSelectionChange?.(Z)}clampSelectedIndex(){let J=this.cachedFiltered.length-1;if(J<0){this.selectedIndex=0;return}this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,J))}recomputeFilteredItems(){let J=this.textController.text,Z=this.widget.props.items,Q=this.widget.props.normalizeQuery?.(J)??J,X=Z.filter((Y)=>!this.widget.props.filterItem||this.widget.props.filterItem(Y,J)).map((Y)=>({item:Y,...tb5(Q,this.widget.props.getLabel(Y))})).filter((Y)=>Y.matches).sort(this.widget.props.sortItems?(Y,U)=>this.widget.props.sortItems(Y,U,J):(Y,U)=>U.score-Y.score).map((Y)=>Y.item);this.cachedQuery=J,this.cachedItemsRef=Z,this.cachedFiltered=this.widget.props.maxRenderItems?X.slice(0,this.widget.props.maxRenderItems):X}getFilteredItems(){let J=this.textController.text,Z=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Z)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,X=Z.size.height;TC(J,{top:Q,bottom:X},{padding:1})}handleScroll=(J)=>{let Z=this.getFilteredItems();if(Z.length===0)return!1;let Q=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++;else return!1;else if(this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--;else return!1;return this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection(),this.selectedIndex!==Q};handleItemClick=(J,Z)=>{let Q=this.getFilteredItems();if(J>=0&&J<Q.length){let X=Q[J],Y=X?this.widget.props.isItemDisabled?.(X)??!1:!1;if(Z===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.syncSelection();else if(Z===2&&!Y){if(X)this.hasUserInteracted=!0,this.widget.props.onAccept(X,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Z=f0.of(J),{colors:Q}=Z,X=this.getFilteredItems(),Y=h1.all(new y1(Q.foreground,1,"solid")),U=this.widget.props.hidePromptWhenLoading&&this.widget.props.isLoading,V=this.widget.props.enabled??!0,D=new c$({controller:this.textController,focusNode:this.focusNode,autofocus:!0,enabled:V,style:{backgroundColor:Q.background,textColor:Q.foreground,cursorColor:Q.cursor,placeholderColor:Q.mutedForeground,border:null},maxLines:1}),K=new H2({shortcuts:new Map([[new t1("ArrowDown"),new zT],[new t1("ArrowUp"),new qT],[new t1("Tab"),new zT],[new t1("Tab",{shift:!0}),new qT],[new t1("n",{ctrl:!0}),new zT],[new t1("p",{ctrl:!0}),new qT],[new t1("Enter"),new A20],[new t1("Escape"),new j20]]),focusNode:this.focusNode,child:D}),z=new M9({actions:new Map([[zT,new n4(this.invoke)],[qT,new n4(this.invoke)],[A20,new n4(this.invoke)],[j20,new n4(this.invoke)]]),child:K}),q=new K1({children:[new l0({decoration:{color:Q.background},child:new Q0({text:new T(">",new b({color:Q.foreground}))})}),new S1({child:z})]});this.itemContexts=[];let F;if(this.widget.props.isLoading){let w=this.widget.props.loadingText??"Loading...";F=new R0({height:10,child:new a1({child:new Q0({text:new T(w,new b({color:Q.foreground}))})})})}else if(X.length===0&&this.widget.props.emptyStateText)F=new S1({child:new a1({child:new Q0({text:new T(this.widget.props.emptyStateText,new b({color:Q.foreground,dim:!0}))})})});else{let w=X.map((N,O)=>{let E=O===this.selectedIndex,L=this.widget.props.isItemDisabled?.(N)??!1,I;if(this.widget.props.renderItem)I=this.widget.props.renderItem(N,E,L,J);else{let M=E?Z.app.selectionBackground:void 0,A=E?Z.app.selectionForeground:Q.foreground;I=new l0({decoration:M?{color:M}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T(this.widget.props.getLabel(N),new b({color:A,dim:L}))})})}return new qB4(new i1({onClick:(M)=>this.handleItemClick(O,M.clickCount),child:I}),(M)=>{this.itemContexts[O]=M})});F=new u0({children:w,crossAxisAlignment:"start"})}let G=new i1({onScroll:this.handleScroll,opaque:!1,child:new O6({controller:this.scrollController,autofocus:!1,child:F})}),W=[];if(this.widget.props.title){let w=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T(this.widget.props.title,new b({color:Z.app.command,bold:!0}))})});W.push(w)}if(!U)W.push(q,new R0({height:1}));if(this.textController.text!==""){let w=X.length>0?X[this.selectedIndex]:void 0,N=w&&this.widget.props.buildDisabledReasonWidget?.(w,J);W.push(new S1({child:new u0({mainAxisAlignment:"spaceBetween",children:[new S1({child:G}),new l0({padding:C0.only({top:1}),child:new a1({child:N??new R0({height:1})})})]})}))}else W.push(new S1({child:G}));if(this.widget.props.footer)W.push(this.widget.props.footer);return new l0({decoration:{border:Y,color:Q.background},padding:C0.symmetric(1,0),child:new u0({children:W})})}}function WB4(J){let Q=new Date().getTime()-J.getTime(),X=Math.floor(Q/60000),Y=Math.floor(Q/3600000),U=Math.floor(Q/86400000);if(X<1)return"just now";if(X<60)return`${X}m ago`;if(Y<24)return`${Y}h ago`;if(U<7)return`${U}d ago`;return J.toLocaleDateString()}class nm0 extends d1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((Y,U)=>U.pubDate.getTime()-Y.pubDate.getTime()),Q=Math.max(0,...Z.map((Y)=>WB4(Y.pubDate).length));return new p9({items:Z,getLabel:(Y)=>Y.title,onAccept:(Y)=>this.props.onSelect?.(Y),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(Y,U,V,D)=>{let K=f0.of(D),{colors:z}=K,q=K.app,F=U?q.selectionBackground:void 0,G=U?q.selectionForeground:z.foreground,W=z.mutedForeground,H=(B,w)=>new R0({width:w,child:K1.end([new Q0({text:new T(B,new b({color:W}))})])});return new l0({decoration:F?{color:F}:void 0,padding:C0.symmetric(2,0),child:new K1({children:[new S1({child:new Q0({text:new T(Y.title,new b({color:G})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),H(WB4(Y.pubDate),Q)]})})}})}}c4();class am0 extends p0{createState(){return new HB4}}class HB4 extends g0{isGreen=!0;timer;initState(){this.timer=setInterval(()=>{this.isGreen=!this.isGreen,this.setState()},700)}dispose(){if(this.timer)clearInterval(this.timer);super.dispose()}build(J){let Q=f0.of(J).colors;return new Q0({text:new T("●",new b({color:this.isGreen?Q.success:Q.mutedForeground,bold:!0})),maxLines:1})}}var eb5=/\/threads\/(T-[^/?#\s<>]+)/i;function $h5(J){let Z=J.trim(),X=Z.match(eb5)?.[1];if(X&&q8(X))return X;let Y=Z.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(q8(Y))return Y;return null}function Jh5(J){let Z=new Map,Q=new Map,X=new Map,Y=[];for(let V of J)Z.set(V.id,V);for(let V of J){let D=V.relationships.find((K)=>K.role==="child"&&Z.has(K.threadID)&&(K.type==="fork"||K.type==="handoff"));if(D){X.set(V.id,D.type);let K=D.threadID,z=Q.get(K)||[];z.push(V),Q.set(K,z)}else Y.push(V)}return c90.flatten(Y,(V)=>Q.get(V.id)).map((V)=>({...V.item,depth:V.depth,isLast:V.isLast,ancestorsAreLast:V.ancestorsAreLast,relationshipType:X.get(V.item.id)}))}function om0(J,Z,Q){return new Q0({text:new T(`${J}${Z}`,new b({color:Q})),maxLines:1})}function Zh5(J,Z,Q,X){return[om0("+",J,X.success),Z3.horizontal(1),om0("~",Z,X.warning),Z3.horizontal(1),om0("-",Q,X.destructive)]}function Qh5(J){return typeof J==="object"&&J!==null&&"then"in J&&typeof J.then==="function"}class R20 extends p0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}createState(){return new BB4}}class BB4 extends g0{spinner=new L3;spinnerInterval=null;isSwitchingThread=!1;get isBusy(){return this.isSwitchingThread||this.widget.props.isLoading===!0}updateSpinnerAnimation(){if(this.isBusy){if(!this.spinnerInterval)this.spinnerInterval=setInterval(()=>{this.spinner.step(),this.setState(()=>{})},100);return}if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null}setSwitchingThread(J){if(this.isSwitchingThread===J)return;this.setState(()=>{this.isSwitchingThread=J}),this.updateSpinnerAnimation()}initState(){super.initState(),this.updateSpinnerAnimation()}didUpdateWidget(J){this.updateSpinnerAnimation()}dispose(){if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null;super.dispose()}build(J){let{props:Z}=this.widget,Q=this.isBusy,X=this.isSwitchingThread?"Switching thread...":"Loading threads...",Y=`${this.spinner.toBraille()} ${X}`,U=Z.filterByWorkspace&&Z.currentWorkspaceURI?Z.threads.filter((O)=>O.workspaceURI===Z.currentWorkspaceURI):Z.threads;if(Z.excludeCurrentThread&&Z.currentThreadID)U=U.filter((O)=>O.id!==Z.currentThreadID);let V=Z.recentThreadIDs||[],D=new Set(V),K=Z.currentThreadID,z=[...U].sort((O,E)=>{if(K){if(O.id===K)return-1;if(E.id===K)return 1}let L=V.indexOf(O.id),I=V.indexOf(E.id);if(L!==-1&&I!==-1)return L-I;if(L!==-1)return-1;if(I!==-1)return 1;return 0}),q=Jh5(z),F=Math.max(0,...q.map((O)=>O.description.timeAgo.length)),G=f0.of(J),W=new o0({padding:C0.symmetric(0,1),child:new a1({child:new Q0({text:new T("",new b({color:G.colors.foreground,dim:!0}),[new T("Ctrl+T",new b({color:G.colors.primary,dim:!0})),new T(Z.filterByWorkspace?" for all workspaces":" to filter by workspace",new b({color:G.colors.foreground,dim:!0}))])})})}),H="",B=null,w=(O)=>{if(O!==H)H=O,B=$h5(O);return B};return new p9({items:q,getLabel:(O)=>`${O.title} ${O.id}`,filterItem:(O,E)=>{let L=w(E);if(L)return O.id.toLowerCase()===L.toLowerCase();return!0},normalizeQuery:(O)=>w(O)?"":O,onAccept:async(O,E)=>{if(!Z.onSelect||this.isSwitchingThread)return;let L=Z.onSelect(O.id,E);if(!Qh5(L))return;this.setSwitchingThread(!0);try{await L}finally{if(this.mounted)this.setSwitchingThread(!1)}},onDismiss:Z.onDismiss,onSelectionChange:(O)=>{if(Z.previewController){if(O)Z.previewController.select(O.id)}},title:Z.title,enabled:!Q,isLoading:Q,hidePromptWhenLoading:!0,loadingText:Y,emptyStateText:"No threads match your filter",maxRenderItems:200,footer:Q?void 0:W,renderItem:(O,E,L,I)=>{let M=f0.of(I),{app:A,colors:R}=M,_=E?A.selectionBackground:void 0,k=E?A.selectionForeground:R.foreground,u=R.mutedForeground,h=($0,B0)=>new R0({width:B0,child:K1.end([new Q0({text:new T($0,new b({color:u}))})])}),f=Z.threadViewStates[O.id],S=[],x=O.relationshipType==="handoff",m=new Ng({connectorColor:R.mutedForeground});if(O.depth>0){let $0=[],B0=O.ancestorsAreLast.slice(1);for(let K0 of B0)$0.push(new T(m.getAncestorPrefix(K0),new b({color:m.connectorColor,dim:m.connectorDim})));let s=O.isLast?m.elbow:m.tee,q0=m.getConnectorText(s);$0.push(new T(q0,new b({color:m.connectorColor,dim:m.connectorDim}))),S.push(new Q0({text:new T("",void 0,$0)}))}let l=[],g=K===O.id?new T("(current) ",new b({color:R.success})):D.has(O.id)?new T("(visited) ",new b({color:R.foreground,dim:!0})):null;if(g)l.push(new Q0({text:g}));if(WO(f))l.push(new am0),l.push(new R0({width:1}));let n=O.title;if(O.relationshipType==="fork"){let $0=n.match(/^Forked\((\d+)\): /);if($0)n=n.slice($0[0].length);else while(n.startsWith("Forked: "))n=n.slice(8);l.push(new Q0({text:new T("[fork] ",new b({color:R.primary}))}))}else if(x)l.push(new Q0({text:new T("[handoff] ",new b({color:R.accent}))}));if(l.push(new S1({child:new Q0({text:new T(n,new b({color:k})),overflow:"ellipsis",maxLines:1})})),l.push(new R0({width:2})),O.diffStats&&(O.diffStats.added>0||O.diffStats.changed>0||O.diffStats.deleted>0)){let $0=E?{success:u,warning:u,destructive:u}:R;l.push(...Zh5(O.diffStats.added,O.diffStats.changed,O.diffStats.deleted,$0)),l.push(new R0({width:2}))}return l.push(h(O.description.timeAgo,F)),new l0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new K1({children:[...S,...l]})})}})}}class NB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new OB4}}class OB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}var wB4=30,Xh5=30;class FT{}class GT{}class P20{}class C20{}class rm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new EB4}}class EB4 extends g0{highlightedIndex=0;controller=new v7;focusNode;scrollController=new r6;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new i4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})})}didUpdateWidget(J){if(J.props.clusters!==this.widget.props.clusters){if(this.recomputeFiltered(),this.highlightedIndex>=this.filteredClusters.length)this.highlightedIndex=Math.max(0,this.filteredClusters.length-1)}}ensureSelectedItemVisible(){let J=this.itemContexts[this.highlightedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,X=Z.size.height;TC(J,{top:Q,bottom:X},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Z}=this.widget.props;if(!J)this.filteredClusters=[...Z];else this.filteredClusters=Z.filter((Q)=>Q.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof FT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof GT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof P20){let Z=this.filteredClusters[this.highlightedIndex];if(Z)this.widget.props.onAccept(Z);return"handled"}if(J instanceof C20)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Z)=>{if(J>=0&&J<this.filteredClusters.length){if(Z===1)this.highlightedIndex=J,this.setState();else if(Z===2){let Q=this.filteredClusters[J];if(Q)this.widget.props.onAccept(Q)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Z=this.highlightedIndex;if(J.direction==="down")if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++;else return!1;else if(this.highlightedIndex>0)this.highlightedIndex--;else return!1;return this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Z};build(J){let{currentThreadID:Z}=this.widget.props,Q=f0.of(J),{colors:X,app:Y}=Q,D=s1.of(J).size.width>=Xh5+wB4,K=h1.all(new y1(X.foreground,1,"solid")),z=this.filteredClusters[this.highlightedIndex]??null,q=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("Select a cluster",new b({color:Y.command,bold:!0}))})}),F=new c$({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:X.foreground,border:null},maxLines:1}),G=new H2({shortcuts:new Map([[new t1("ArrowDown"),new FT],[new t1("ArrowUp"),new GT],[new t1("Tab"),new FT],[new t1("Tab",{shift:!0}),new GT],[new t1("n",{ctrl:!0}),new FT],[new t1("p",{ctrl:!0}),new GT],[new t1("Enter"),new P20],[new t1("Escape"),new C20]]),focusNode:this.focusNode,child:F}),W=new M9({actions:new Map([[FT,new n4(this.invoke)],[GT,new n4(this.invoke)],[P20,new n4(this.invoke)],[C20,new n4(this.invoke)]]),child:G}),H=new K1({children:[new l0({decoration:{color:X.background},child:new Q0({text:new T(">",new b({color:X.foreground}))})}),new S1({child:W})]});this.itemContexts=[];let B=this.filteredClusters.map((I,M)=>{let A=M===this.highlightedIndex,R=Z?I.threads.some((h)=>h.id===Z):!1,_=A?Y.selectionBackground:void 0,k=A?Y.selectionForeground:X.foreground,u=[new T(I.label,new b({color:k})),new T(` (${I.threads.length})`,new b({color:k,dim:!0}))];if(R)u.push(new T(" (current)",new b({color:A?Y.selectionForeground:X.success})));return new NB4(new i1({onClick:(h)=>this.handleItemClick(M,h.clickCount),child:new l0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T("",void 0,u)})})}),(h)=>{this.itemContexts[M]=h})}),w=new u0({children:B,crossAxisAlignment:"start"}),N=new S1({child:new i1({onScroll:this.handleScroll,child:new O6({controller:this.scrollController,autofocus:!1,child:w})})}),O=z?z.threads.map((I)=>({id:I.id,title:I.title,parentID:I.parentID,updatedAt:I.updatedAt})):[],E=z?new l0({padding:C0.all(1),child:new YL({threads:O,autofocus:!1,offsetY:2})}):null,L;if(D){let I=E?new S1({child:E}):new R0({width:wB4});L=new K1({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[N,I]})}else{let I=[new S1({child:new i1({onScroll:this.handleScroll,child:new O6({controller:this.scrollController,autofocus:!1,child:w})})})];if(E)I.push(new S1({child:E}));L=new u0({crossAxisAlignment:"stretch",children:I})}return new l0({decoration:{border:K,color:X.background},padding:C0.symmetric(1,0),child:new u0({children:[q,H,new R0({height:1}),new S1({child:L})]})})}}m0();class LB4 extends g0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let J=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!J.ok){P.error("Failed to load labels",J.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=J.result,this.isLoading=!1,this.setState()}catch(J){P.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],X=this.labels.some((U)=>U.name===Z),Y=Q.includes(Z);return!X&&!Y}build(J){let Z=f0.of(J),{app:Q,colors:X}=Z,Y=this.currentQuery.trim().toLowerCase(),U=Y.length>0?this.getValidationError(Y):null,V=this.getAvailableLabels(),K=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...V];return new p9({title:"Add Label",items:K,getLabel:(z)=>{if("__isCreateMarker"in z)return this.currentQuery.trim().toLowerCase();return z.name},onAccept:(z)=>{if("__isCreateMarker"in z)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(z.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:U||"Type to create a new label",renderItem:(z,q,F,G)=>{let W=q?Q.selectionBackground:void 0,H=q?Q.selectionForeground:X.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let w=this.currentQuery.trim().toLowerCase();return new l0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T("",void 0,[new T("Create new label: ",new b({color:H})),new T(w,new b({color:H,bold:!0}))])})})}return new l0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T(z.name,new b({color:H}))})})},filterItem:(z,q)=>{if(this.currentQuery!==q)this.currentQuery=q,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in z&&z.__isCreateMarker)return this.shouldShowCreateMarker(q);let G=q.trim().toLowerCase();return G.length===0||z.name.includes(G)},sortItems:(z,q,F)=>{let G="__isCreateMarker"in z.item&&z.item.__isCreateMarker,W="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(G&&!W)return-1;if(!G&&W)return 1;return q.score-z.score}})}}class sm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new LB4}}class SH extends p0{props;constructor(J){super();this.props=J}createState(){return new IB4}}class IB4 extends g0{_spinner=new L3;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:X}=Z,Y=h1.all(new y1(Q.foreground,1,"solid")),U=this._spinner.toBraille(),V=new Q0({textAlign:"center",text:new T("",void 0,[new T(U,new b({color:X.processing})),new T(" ",void 0),new T(this.widget.props.message,new b({color:Q.foreground}))])}),K=[new S1({child:new u0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[V]})})];if(this.widget.props.onAbort)K.push(new R0({height:2,child:new l0({padding:C0.symmetric(2,0),child:new Q0({text:new T("",new b({dim:!0}),[new T("Press ",new b({color:Q.foreground})),new T("Esc",new b({color:Q.info})),new T(" to cancel",new b({color:Q.foreground}))])})})}));let z=new l0({decoration:new _4(Q.background,Y),child:new R0({width:60,height:7,child:new u0({mainAxisAlignment:"start",children:K})})});if(this.widget.props.onAbort)return new T4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(q)=>{if(q.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:z});return z}}class VL extends p0{props;constructor(J){super();this.props=J}createState(){return new MB4}}class MB4 extends g0{scrollController=new r6;scrollAreaKey=new _7("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(J){return J instanceof w2}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Z=this.scrollAreaKey.currentElement?.renderObject;if(Z&&"size"in Z){let Q=Z.size;if(typeof Q.height==="number"&&Q.height>0)return this.viewportHeight=Q.height,Q.height}return this.viewportHeight}build(J){let Z=f0.of(J),Q=this.widget.props.message,X=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let q=g90(Q);return{title:q.title,type:q.type,description:q.description}})(),Y=X.type==="error"?Z.app.toolError:Z.app.command,U=h1.all(new y1(Z.colors.border,1,"solid")),V=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T(X.title,new b({color:Y,bold:!0}))})}),D=this.isWidgetMessage(Q)?Q.widget:new Q0({text:new T(X.description,new b({color:Z.colors.foreground})),selectable:!0}),K=new S1({child:new d$({child:new l0({padding:C0.symmetric(1,0),child:new K1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new S1({child:new O6({controller:this.scrollController,autofocus:!0,child:D})}),new A8({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let q=this.scrollController.maxScrollExtent,F=this.scrollController.offset,G=this.getViewportHeight(),W=q+G;return{totalContentHeight:Math.max(W,0),viewportHeight:Math.max(G,1),scrollOffset:Math.max(F,0)}}})]})})})}),z=new l0({padding:C0.symmetric(1,0),child:new Q0({text:(()=>{if(this.widget.props.onRetry)return new T("",void 0,[new T("Press ",new b({color:Z.colors.foreground,dim:!0})),new T("R",new b({color:Z.app.keybind})),new T(" to retry, ",new b({color:Z.colors.foreground,dim:!0})),new T("Esc",new b({color:Z.app.keybind})),new T(" to cancel",new b({color:Z.colors.foreground,dim:!0}))]);let q=this.resolveFooterStyle(this.widget.props.message);if(q==="none")return new T("",new b({color:Z.colors.foreground,dim:!0}));if(q==="help"){let F=new b({color:Z.app.keybind}),G=new b({color:Z.colors.foreground,dim:!0});return new T("",G,[new T("Press ",G),new T("Escape",F),new T(" to close • Use ",G),new T("↑↓",F),new T(" or ",G),new T("j/k",F),new T(" to scroll",G)])}return new T("Press any key to close",new b({color:Z.colors.foreground,dim:!0,italic:!0}))})()})});return new T4({onKey:(q)=>{if(this.widget.props.onRetry&&q.key==="r")return this.widget.props.onRetry(),"handled";if(q.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new l0({decoration:{border:U,color:Z.colors.background},padding:C0.all(1),child:new u0({mainAxisAlignment:"center",children:[V,new R0({height:1}),K,z]})})})}}n9();class AB4 extends p0{props;constructor(J){super();this.props=J}createState(){return new jB4}}class jB4 extends g0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=u8.default(),{colors:Q,app:X}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:X.toolSuccess};case"error":return{icon:"✗",color:X.toolError}}}build(J){let Z=f0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new Q0({text:new T("No plugins found.",new b({dim:!0}))});let X=[],Y=this.plugins.length,U=this.plugins.filter((K)=>K.status==="active").length,V=this.plugins.reduce((K,z)=>K+z.registeredCommands.length,0),D=this.plugins.reduce((K,z)=>K+z.registeredTools.length,0);if(X.push(new T(`${U}/${Y} ${h4(Y,"plugin")} active`,new b({bold:!0}))),V>0||D>0)X.push(new T(` (${V} ${h4(V,"command")}, ${D} ${h4(D,"tool")})`,new b({dim:!0})));X.push(new T(`
6843
+ `,N)])}),A];if(!K&&!G&&z.url){let h=z.url.replace(/^https?:\/\//,"");_.push(new J5({uri:z.url,text:h,style:new b({color:Q.secondary,underline:!0})}))}if(M&&!G)_.push(M);let k=new R0({width:50,child:new u0({crossAxisAlignment:"start",mainAxisSize:"min",children:_})}),u=W?new R0({width:O20,height:E20}):new Nx0({width:O20,height:E20,agentMode:this.widget.agentMode,glow:this._glow,backgroundColor:Q.background,t:q,fps:0,shockwaves:this._shockwaves,onShockwave:this.handleShockwave,onClick:this.handleOrbClick,...V==="disabled"&&{seed:42}});return a1.child(new K1({mainAxisAlignment:"center",crossAxisAlignment:"center",mainAxisSize:"min",children:[u,new R0({width:2}),k]}))}}class gm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new QB4}}class QB4 extends g0{build(J){let Q=f0.of(J).colors,{todos:X,title:Y="TODOs"}=this.widget.props;if(!Array.isArray(X)||X.length===0)return new R0({width:0,height:0});let U=X.map((V)=>this.buildTodoItem(V,Q));return new l0({child:new o0({padding:C0.symmetric(1,0),child:new u0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new Q0({text:new T(Y,new b({bold:!0,color:Q.foreground}))}),...U]})})})}buildTodoItem(J,Z){let Q=this.getStatusIcon(J.status),X=J.status==="completed",Y=new b({bold:J.status==="in-progress",color:Z.foreground,dim:X}),U=new b({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Z.foreground,dim:X});return new K1({crossAxisAlignment:"start",children:[new Q0({text:new T(Q,Y)}),new R0({width:1}),new S1({child:new Q0({text:new T(J.content,U)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class pm0 extends p0{ad;onDismiss;onButtonClick;onImpression;onAdInfoClick;constructor({key:J,ad:Z,onDismiss:Q,onButtonClick:X,onImpression:Y,onAdInfoClick:U}){super({key:J});this.ad=Z,this.onDismiss=Q,this.onButtonClick=X,this.onImpression=Y,this.onAdInfoClick=U}createState(){return new XB4}}class XB4 extends g0{lastTrackedAdId=null;initState(){super.initState(),this.fireImpressionIfNeeded()}didUpdateWidget(J){super.didUpdateWidget(J),this.fireImpressionIfNeeded()}fireImpressionIfNeeded(){let J=this.widget.ad;if(J.id!==this.lastTrackedAdId)this.lastTrackedAdId=J.id,this.widget.onImpression?.(J)}build(J){let Z=f0.of(J),Q=Z.colors.primary,X=Z.colors.foreground,Y=Z.colors.background,U=this.widget.ad;return new l0({decoration:new _4(Y,new h1(new y1(Q,1,"rounded"),new y1(Q,1,"rounded"),void 0,new y1(Q,1,"rounded"))),child:new o0({padding:C0.horizontal(1),child:new u0({children:[new K1({crossAxisAlignment:"start",children:[new S1({child:new Q0({text:new T(U.content,new b({color:X}))})}),new R0({width:4}),new i1({onClick:()=>this.widget.onAdInfoClick?.(),cursor:"pointer",child:new Q0({text:new T("Ad",new b({color:X,dim:!0}))})})]}),new K1({crossAxisAlignment:"start",children:[new om({text:U.buttonLabel,onPressed:()=>this.widget.onButtonClick?.(),padding:C0.horizontal(1),color:Q,reverse:!0}),new R0({width:2}),new Q0({text:new T(U.destinationUrlHostname,new b({color:X,dim:!0}))})]})]})})})}}class dm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new YB4(this.props.autofocus??!0)}}class YB4 extends g0{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=P1.of(J).colorScheme,X=(z)=>{if(z.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(z.ctrlKey&&z.key==="c"||z.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},Y=s1.sizeOf(J),U=Math.min(60,Y.width-4),V=Y.height-4,D=[];if(this.widget.props.title)D.push(new Q0({text:new T(this.widget.props.title,new b({bold:!0,color:Q.primary}))}),new R0({height:1}));if(this.widget.props.message)D.push(new Q0({text:new T(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)D.push(new R0({height:1}));let K=[];if(this.widget.props.showCopyOption)K.push(new Q0({text:new T("Enter to copy",new b({dim:!0}))}));return K.push(new Q0({text:new T("Escape to close",new b({dim:!0}))})),D.push(new K1({children:K.flatMap((z,q)=>q<K.length-1?[z,new R0({width:1}),new Q0({text:new T("•",new b({dim:!0}))}),new R0({width:1})]:[z]),mainAxisSize:"min"})),new a1({child:new l0({constraints:new I1(U,U,0,V),decoration:new _4(Q.background,new h1(new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"))),padding:new C0(2,2,2,2),child:new T4({autofocus:this.autofocus,onKey:X,child:new u0({children:D,mainAxisSize:"min"})})})})}}class cm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new UB4(this.props.autofocus??!0)}}class UB4 extends g0{autofocus;constructor(J){super();this.autofocus=J}build(J){let Z=P1.of(J).colorScheme,Q=(D)=>{if(D.key==="Enter"||D.key==="Escape"||D.ctrlKey&&D.key==="c")return this.widget.props.onClose(),"handled";return"ignored"},X=s1.sizeOf(J),Y=Math.min(60,X.width-4),U=X.height-4,V=[];if(V.push(new Q0({text:new T("Ads make Amp Free possible",new b({bold:!0}))})),this.widget.props.provider)V.push(new R0({height:1}),new Q0({text:new T(`Ad source: ${this.widget.props.provider}`,new b({dim:!0}))}));return V.push(new R0({height:1}),new Q0({text:new T("Escape to close",new b({dim:!0}))})),new a1({child:new l0({constraints:new I1(Y,Y,0,U),decoration:new _4(Z.background,new h1(new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"))),padding:new C0(2,2,2,2),child:new T4({autofocus:this.autofocus,onKey:Q,child:new u0({children:V,mainAxisSize:"min"})})})})}}m0();n9();import{execSync as Mh5}from"node:child_process";oM();WJ();O3();t7();Cw();IY();M$();MZ();EY();iO();c4();ku();Sv();H1();var Xw4=H4(Dz(),1);import{writeFile as eB4}from"fs/promises";import $w4 from"path";m0();M$();class lm0{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1772208429-ge4b10a"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await us(Z,this.configService)}catch(Z){P.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class _H extends p0{props;constructor(J){super();this.props=J}createState(){return new VB4}}class VB4 extends g0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}class DB4 extends g0{controller=new v7;focusNode=new i4({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:X}=Z,Y=this.widget.props.isRequiredArg??!0,U=this.controller.text.trim().length>0,V=!Y||U,D=h1.all(new y1(Q.foreground,1,"solid")),K=new c$({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(W)=>{let H=W.trim();if(Y&&H.length===0)return;this.widget.props.onSubmit(H)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),z=new K1({children:[new l0({decoration:{color:Q.background},child:new Q0({text:new T(">",new b({color:Q.foreground}))})}),new S1({child:K})]}),q=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("",void 0,[new T("Command: ",new b({color:Q.foreground})),new T(this.widget.props.commandName,new b({color:X.command,bold:!0}))])})}),F=[];if(V)F.push(new T("Enter",new b({color:X.keybind}))),F.push(new T(" to submit, ",new b({color:Q.foreground,dim:!0})));F.push(new T("Esc",new b({color:X.keybind}))),F.push(new T(" to cancel",new b({color:Q.foreground,dim:!0})));let G=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("",void 0,F)})});return new l0({decoration:{border:D,color:Q.background},padding:C0.all(1),child:new u0({children:[q,new R0({height:1}),z,new Z3,G]})})}}class Fp extends p0{props;constructor(J){super();this.props=J}createState(){return new DB4}}import{isDeepStrictEqual as im0}from"node:util";var ob5=/[\\/_ +.#"@[({&]/,rb5=/[\\/_ +.#"@[({&]/g,sb5=/[\s-]/,KB4=/[\s-]/g;function M20(J,Z,Q,X,Y,U,V){if(U===Z.length){if(Y===J.length)return 1;return 0.99}let D=`${Y},${U}`;if(V[D]!==void 0)return V[D];let K=X.charAt(U),z=Q.indexOf(K,Y),q=0,F,G,W,H;while(z>=0){if(F=M20(J,Z,Q,X,z+1,U+1,V),F>q){if(z===Y)F*=1;else if(sb5.test(J.charAt(z-1))){if(F*=0.9,H=J.slice(Y,z-1).match(KB4),H&&Y>0)F*=0.999**H.length}else if(ob5.test(J.charAt(z-1))){if(F*=0.8,W=J.slice(Y,z-1).match(rb5),W&&Y>0)F*=0.999**W.length}else if(F*=0.3,Y>0)F*=0.999**(z-Y);if(J.charAt(z)!==Z.charAt(U))F*=0.9999}if(F<0.1&&(Q.charAt(z-1)===X.charAt(U+1)||X.charAt(U+1)===X.charAt(U)&&Q.charAt(z-1)!==X.charAt(U))){if(G=M20(J,Z,Q,X,z+1,U+2,V),G*0.1>F)F=G*0.1}if(F>q)q=F;z=Q.indexOf(K,z+1)}return V[D]=q,q}function I20(J){return J.toLowerCase().replace(KB4," ")}function zB4(J,Z){let Q=M20(J,Z,I20(J),I20(Z),0,0,{}),X=Z.trim().split(/\s+/);if(X.length>1){let Y=0,U=0;for(let D of X){let K=M20(J,D,I20(J),I20(D),0,0,{});if(K===0)return Q;Y+=K,U+=D.length}let V=Y/X.length*0.95;return Math.max(Q,V)}return Q}class zT{}class qT{}class A20{}class j20{}class qB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new FB4}}class FB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}function tb5(J,Z){if(J==="")return{matches:!0,score:1};let Q=zB4(Z,J);return{matches:Q>0.15,score:Q}}class p9 extends p0{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new GB4}}class GB4 extends g0{textController;focusNode;scrollController=new r6;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){if(this.scrollController.disableFollowMode(),this.textController=new v7(this.widget.props.controller?.query??""),this.focusNode=new i4({debugLabel:this.widget.debugLabel}),this.textController.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let J=this.widget.props.controller;if(J)J.query=this.textController.text;this.syncSelection()}),this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let J=this.cachedFiltered.findIndex((Z)=>im0(Z,this.widget.props.controller?.selectedItem));if(J>=0)this.selectedIndex=J}this.clampSelectedIndex(),this.syncSelection(),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!im0(J.props.items,this.widget.props.items)){if(this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let Z=this.cachedFiltered.findIndex((Q)=>im0(Q,this.widget.props.controller?.selectedItem));if(Z>=0)this.selectedIndex=Z}this.clampSelectedIndex(),this.ensureSelectedItemVisible(),this.syncSelection()}}dispose(){this.widget.props.onSelectionChange?.(null),this.textController.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof zT){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof qT){if(this.getFilteredItems().length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof A20){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length){let Q=Z[this.selectedIndex];if(Q){if(!(this.widget.props.isItemDisabled?.(Q)??!1))this.widget.props.onAccept(Q,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof j20)return this.widget.props.onDismiss?.(),"handled";return"ignored"};syncSelection(){let Z=this.cachedFiltered[this.selectedIndex]??null;if(this.widget.props.controller)this.widget.props.controller.selectedItem=Z;this.widget.props.onSelectionChange?.(Z)}clampSelectedIndex(){let J=this.cachedFiltered.length-1;if(J<0){this.selectedIndex=0;return}this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,J))}recomputeFilteredItems(){let J=this.textController.text,Z=this.widget.props.items,Q=this.widget.props.normalizeQuery?.(J)??J,X=Z.filter((Y)=>!this.widget.props.filterItem||this.widget.props.filterItem(Y,J)).map((Y)=>({item:Y,...tb5(Q,this.widget.props.getLabel(Y))})).filter((Y)=>Y.matches).sort(this.widget.props.sortItems?(Y,U)=>this.widget.props.sortItems(Y,U,J):(Y,U)=>U.score-Y.score).map((Y)=>Y.item);this.cachedQuery=J,this.cachedItemsRef=Z,this.cachedFiltered=this.widget.props.maxRenderItems?X.slice(0,this.widget.props.maxRenderItems):X}getFilteredItems(){let J=this.textController.text,Z=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Z)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,X=Z.size.height;TC(J,{top:Q,bottom:X},{padding:1})}handleScroll=(J)=>{let Z=this.getFilteredItems();if(Z.length===0)return!1;let Q=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++;else return!1;else if(this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--;else return!1;return this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection(),this.selectedIndex!==Q};handleItemClick=(J,Z)=>{let Q=this.getFilteredItems();if(J>=0&&J<Q.length){let X=Q[J],Y=X?this.widget.props.isItemDisabled?.(X)??!1:!1;if(Z===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.syncSelection();else if(Z===2&&!Y){if(X)this.hasUserInteracted=!0,this.widget.props.onAccept(X,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Z=f0.of(J),{colors:Q}=Z,X=this.getFilteredItems(),Y=h1.all(new y1(Q.foreground,1,"solid")),U=this.widget.props.hidePromptWhenLoading&&this.widget.props.isLoading,V=this.widget.props.enabled??!0,D=new c$({controller:this.textController,focusNode:this.focusNode,autofocus:!0,enabled:V,style:{backgroundColor:Q.background,textColor:Q.foreground,cursorColor:Q.cursor,placeholderColor:Q.mutedForeground,border:null},maxLines:1}),K=new H2({shortcuts:new Map([[new t1("ArrowDown"),new zT],[new t1("ArrowUp"),new qT],[new t1("Tab"),new zT],[new t1("Tab",{shift:!0}),new qT],[new t1("n",{ctrl:!0}),new zT],[new t1("p",{ctrl:!0}),new qT],[new t1("Enter"),new A20],[new t1("Escape"),new j20]]),focusNode:this.focusNode,child:D}),z=new M9({actions:new Map([[zT,new n4(this.invoke)],[qT,new n4(this.invoke)],[A20,new n4(this.invoke)],[j20,new n4(this.invoke)]]),child:K}),q=new K1({children:[new l0({decoration:{color:Q.background},child:new Q0({text:new T(">",new b({color:Q.foreground}))})}),new S1({child:z})]});this.itemContexts=[];let F;if(this.widget.props.isLoading){let w=this.widget.props.loadingText??"Loading...";F=new R0({height:10,child:new a1({child:new Q0({text:new T(w,new b({color:Q.foreground}))})})})}else if(X.length===0&&this.widget.props.emptyStateText)F=new S1({child:new a1({child:new Q0({text:new T(this.widget.props.emptyStateText,new b({color:Q.foreground,dim:!0}))})})});else{let w=X.map((N,O)=>{let E=O===this.selectedIndex,L=this.widget.props.isItemDisabled?.(N)??!1,I;if(this.widget.props.renderItem)I=this.widget.props.renderItem(N,E,L,J);else{let M=E?Z.app.selectionBackground:void 0,A=E?Z.app.selectionForeground:Q.foreground;I=new l0({decoration:M?{color:M}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T(this.widget.props.getLabel(N),new b({color:A,dim:L}))})})}return new qB4(new i1({onClick:(M)=>this.handleItemClick(O,M.clickCount),child:I}),(M)=>{this.itemContexts[O]=M})});F=new u0({children:w,crossAxisAlignment:"start"})}let G=new i1({onScroll:this.handleScroll,opaque:!1,child:new O6({controller:this.scrollController,autofocus:!1,child:F})}),W=[];if(this.widget.props.title){let w=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T(this.widget.props.title,new b({color:Z.app.command,bold:!0}))})});W.push(w)}if(!U)W.push(q,new R0({height:1}));if(this.textController.text!==""){let w=X.length>0?X[this.selectedIndex]:void 0,N=w&&this.widget.props.buildDisabledReasonWidget?.(w,J);W.push(new S1({child:new u0({mainAxisAlignment:"spaceBetween",children:[new S1({child:G}),new l0({padding:C0.only({top:1}),child:new a1({child:N??new R0({height:1})})})]})}))}else W.push(new S1({child:G}));if(this.widget.props.footer)W.push(this.widget.props.footer);return new l0({decoration:{border:Y,color:Q.background},padding:C0.symmetric(1,0),child:new u0({children:W})})}}function WB4(J){let Q=new Date().getTime()-J.getTime(),X=Math.floor(Q/60000),Y=Math.floor(Q/3600000),U=Math.floor(Q/86400000);if(X<1)return"just now";if(X<60)return`${X}m ago`;if(Y<24)return`${Y}h ago`;if(U<7)return`${U}d ago`;return J.toLocaleDateString()}class nm0 extends d1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((Y,U)=>U.pubDate.getTime()-Y.pubDate.getTime()),Q=Math.max(0,...Z.map((Y)=>WB4(Y.pubDate).length));return new p9({items:Z,getLabel:(Y)=>Y.title,onAccept:(Y)=>this.props.onSelect?.(Y),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(Y,U,V,D)=>{let K=f0.of(D),{colors:z}=K,q=K.app,F=U?q.selectionBackground:void 0,G=U?q.selectionForeground:z.foreground,W=z.mutedForeground,H=(B,w)=>new R0({width:w,child:K1.end([new Q0({text:new T(B,new b({color:W}))})])});return new l0({decoration:F?{color:F}:void 0,padding:C0.symmetric(2,0),child:new K1({children:[new S1({child:new Q0({text:new T(Y.title,new b({color:G})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),H(WB4(Y.pubDate),Q)]})})}})}}c4();class am0 extends p0{createState(){return new HB4}}class HB4 extends g0{isGreen=!0;timer;initState(){this.timer=setInterval(()=>{this.isGreen=!this.isGreen,this.setState()},700)}dispose(){if(this.timer)clearInterval(this.timer);super.dispose()}build(J){let Q=f0.of(J).colors;return new Q0({text:new T("●",new b({color:this.isGreen?Q.success:Q.mutedForeground,bold:!0})),maxLines:1})}}var eb5=/\/threads\/(T-[^/?#\s<>]+)/i;function $h5(J){let Z=J.trim(),X=Z.match(eb5)?.[1];if(X&&q8(X))return X;let Y=Z.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(q8(Y))return Y;return null}function Jh5(J){let Z=new Map,Q=new Map,X=new Map,Y=[];for(let V of J)Z.set(V.id,V);for(let V of J){let D=V.relationships.find((K)=>K.role==="child"&&Z.has(K.threadID)&&(K.type==="fork"||K.type==="handoff"));if(D){X.set(V.id,D.type);let K=D.threadID,z=Q.get(K)||[];z.push(V),Q.set(K,z)}else Y.push(V)}return c90.flatten(Y,(V)=>Q.get(V.id)).map((V)=>({...V.item,depth:V.depth,isLast:V.isLast,ancestorsAreLast:V.ancestorsAreLast,relationshipType:X.get(V.item.id)}))}function om0(J,Z,Q){return new Q0({text:new T(`${J}${Z}`,new b({color:Q})),maxLines:1})}function Zh5(J,Z,Q,X){return[om0("+",J,X.success),Z3.horizontal(1),om0("~",Z,X.warning),Z3.horizontal(1),om0("-",Q,X.destructive)]}function Qh5(J){return typeof J==="object"&&J!==null&&"then"in J&&typeof J.then==="function"}class R20 extends p0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}createState(){return new BB4}}class BB4 extends g0{spinner=new L3;spinnerInterval=null;isSwitchingThread=!1;get isBusy(){return this.isSwitchingThread||this.widget.props.isLoading===!0}updateSpinnerAnimation(){if(this.isBusy){if(!this.spinnerInterval)this.spinnerInterval=setInterval(()=>{this.spinner.step(),this.setState(()=>{})},100);return}if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null}setSwitchingThread(J){if(this.isSwitchingThread===J)return;this.setState(()=>{this.isSwitchingThread=J}),this.updateSpinnerAnimation()}initState(){super.initState(),this.updateSpinnerAnimation()}didUpdateWidget(J){this.updateSpinnerAnimation()}dispose(){if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null;super.dispose()}build(J){let{props:Z}=this.widget,Q=this.isBusy,X=this.isSwitchingThread?"Switching thread...":"Loading threads...",Y=`${this.spinner.toBraille()} ${X}`,U=Z.filterByWorkspace&&Z.currentWorkspaceURI?Z.threads.filter((O)=>O.workspaceURI===Z.currentWorkspaceURI):Z.threads;if(Z.excludeCurrentThread&&Z.currentThreadID)U=U.filter((O)=>O.id!==Z.currentThreadID);let V=Z.recentThreadIDs||[],D=new Set(V),K=Z.currentThreadID,z=[...U].sort((O,E)=>{if(K){if(O.id===K)return-1;if(E.id===K)return 1}let L=V.indexOf(O.id),I=V.indexOf(E.id);if(L!==-1&&I!==-1)return L-I;if(L!==-1)return-1;if(I!==-1)return 1;return 0}),q=Jh5(z),F=Math.max(0,...q.map((O)=>O.description.timeAgo.length)),G=f0.of(J),W=new o0({padding:C0.symmetric(0,1),child:new a1({child:new Q0({text:new T("",new b({color:G.colors.foreground,dim:!0}),[new T("Ctrl+T",new b({color:G.colors.primary,dim:!0})),new T(Z.filterByWorkspace?" for all workspaces":" to filter by workspace",new b({color:G.colors.foreground,dim:!0}))])})})}),H="",B=null,w=(O)=>{if(O!==H)H=O,B=$h5(O);return B};return new p9({items:q,getLabel:(O)=>`${O.title} ${O.id}`,filterItem:(O,E)=>{let L=w(E);if(L)return O.id.toLowerCase()===L.toLowerCase();return!0},normalizeQuery:(O)=>w(O)?"":O,onAccept:async(O,E)=>{if(!Z.onSelect||this.isSwitchingThread)return;let L=Z.onSelect(O.id,E);if(!Qh5(L))return;this.setSwitchingThread(!0);try{await L}finally{if(this.mounted)this.setSwitchingThread(!1)}},onDismiss:Z.onDismiss,onSelectionChange:(O)=>{if(Z.previewController){if(O)Z.previewController.select(O.id)}},title:Z.title,enabled:!Q,isLoading:Q,hidePromptWhenLoading:!0,loadingText:Y,emptyStateText:"No threads match your filter",maxRenderItems:200,footer:Q?void 0:W,renderItem:(O,E,L,I)=>{let M=f0.of(I),{app:A,colors:R}=M,_=E?A.selectionBackground:void 0,k=E?A.selectionForeground:R.foreground,u=R.mutedForeground,h=($0,B0)=>new R0({width:B0,child:K1.end([new Q0({text:new T($0,new b({color:u}))})])}),f=Z.threadViewStates[O.id],S=[],x=O.relationshipType==="handoff",m=new Ng({connectorColor:R.mutedForeground});if(O.depth>0){let $0=[],B0=O.ancestorsAreLast.slice(1);for(let K0 of B0)$0.push(new T(m.getAncestorPrefix(K0),new b({color:m.connectorColor,dim:m.connectorDim})));let s=O.isLast?m.elbow:m.tee,q0=m.getConnectorText(s);$0.push(new T(q0,new b({color:m.connectorColor,dim:m.connectorDim}))),S.push(new Q0({text:new T("",void 0,$0)}))}let l=[],g=K===O.id?new T("(current) ",new b({color:R.success})):D.has(O.id)?new T("(visited) ",new b({color:R.foreground,dim:!0})):null;if(g)l.push(new Q0({text:g}));if(WO(f))l.push(new am0),l.push(new R0({width:1}));let n=O.title;if(O.relationshipType==="fork"){let $0=n.match(/^Forked\((\d+)\): /);if($0)n=n.slice($0[0].length);else while(n.startsWith("Forked: "))n=n.slice(8);l.push(new Q0({text:new T("[fork] ",new b({color:R.primary}))}))}else if(x)l.push(new Q0({text:new T("[handoff] ",new b({color:R.accent}))}));if(l.push(new S1({child:new Q0({text:new T(n,new b({color:k})),overflow:"ellipsis",maxLines:1})})),l.push(new R0({width:2})),O.diffStats&&(O.diffStats.added>0||O.diffStats.changed>0||O.diffStats.deleted>0)){let $0=E?{success:u,warning:u,destructive:u}:R;l.push(...Zh5(O.diffStats.added,O.diffStats.changed,O.diffStats.deleted,$0)),l.push(new R0({width:2}))}return l.push(h(O.description.timeAgo,F)),new l0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new K1({children:[...S,...l]})})}})}}class NB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new OB4}}class OB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}var wB4=30,Xh5=30;class FT{}class GT{}class P20{}class C20{}class rm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new EB4}}class EB4 extends g0{highlightedIndex=0;controller=new v7;focusNode;scrollController=new r6;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new i4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})})}didUpdateWidget(J){if(J.props.clusters!==this.widget.props.clusters){if(this.recomputeFiltered(),this.highlightedIndex>=this.filteredClusters.length)this.highlightedIndex=Math.max(0,this.filteredClusters.length-1)}}ensureSelectedItemVisible(){let J=this.itemContexts[this.highlightedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,X=Z.size.height;TC(J,{top:Q,bottom:X},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Z}=this.widget.props;if(!J)this.filteredClusters=[...Z];else this.filteredClusters=Z.filter((Q)=>Q.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof FT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof GT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof P20){let Z=this.filteredClusters[this.highlightedIndex];if(Z)this.widget.props.onAccept(Z);return"handled"}if(J instanceof C20)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Z)=>{if(J>=0&&J<this.filteredClusters.length){if(Z===1)this.highlightedIndex=J,this.setState();else if(Z===2){let Q=this.filteredClusters[J];if(Q)this.widget.props.onAccept(Q)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Z=this.highlightedIndex;if(J.direction==="down")if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++;else return!1;else if(this.highlightedIndex>0)this.highlightedIndex--;else return!1;return this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Z};build(J){let{currentThreadID:Z}=this.widget.props,Q=f0.of(J),{colors:X,app:Y}=Q,D=s1.of(J).size.width>=Xh5+wB4,K=h1.all(new y1(X.foreground,1,"solid")),z=this.filteredClusters[this.highlightedIndex]??null,q=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("Select a cluster",new b({color:Y.command,bold:!0}))})}),F=new c$({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:X.foreground,border:null},maxLines:1}),G=new H2({shortcuts:new Map([[new t1("ArrowDown"),new FT],[new t1("ArrowUp"),new GT],[new t1("Tab"),new FT],[new t1("Tab",{shift:!0}),new GT],[new t1("n",{ctrl:!0}),new FT],[new t1("p",{ctrl:!0}),new GT],[new t1("Enter"),new P20],[new t1("Escape"),new C20]]),focusNode:this.focusNode,child:F}),W=new M9({actions:new Map([[FT,new n4(this.invoke)],[GT,new n4(this.invoke)],[P20,new n4(this.invoke)],[C20,new n4(this.invoke)]]),child:G}),H=new K1({children:[new l0({decoration:{color:X.background},child:new Q0({text:new T(">",new b({color:X.foreground}))})}),new S1({child:W})]});this.itemContexts=[];let B=this.filteredClusters.map((I,M)=>{let A=M===this.highlightedIndex,R=Z?I.threads.some((h)=>h.id===Z):!1,_=A?Y.selectionBackground:void 0,k=A?Y.selectionForeground:X.foreground,u=[new T(I.label,new b({color:k})),new T(` (${I.threads.length})`,new b({color:k,dim:!0}))];if(R)u.push(new T(" (current)",new b({color:A?Y.selectionForeground:X.success})));return new NB4(new i1({onClick:(h)=>this.handleItemClick(M,h.clickCount),child:new l0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T("",void 0,u)})})}),(h)=>{this.itemContexts[M]=h})}),w=new u0({children:B,crossAxisAlignment:"start"}),N=new S1({child:new i1({onScroll:this.handleScroll,child:new O6({controller:this.scrollController,autofocus:!1,child:w})})}),O=z?z.threads.map((I)=>({id:I.id,title:I.title,parentID:I.parentID,updatedAt:I.updatedAt})):[],E=z?new l0({padding:C0.all(1),child:new YL({threads:O,autofocus:!1,offsetY:2})}):null,L;if(D){let I=E?new S1({child:E}):new R0({width:wB4});L=new K1({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[N,I]})}else{let I=[new S1({child:new i1({onScroll:this.handleScroll,child:new O6({controller:this.scrollController,autofocus:!1,child:w})})})];if(E)I.push(new S1({child:E}));L=new u0({crossAxisAlignment:"stretch",children:I})}return new l0({decoration:{border:K,color:X.background},padding:C0.symmetric(1,0),child:new u0({children:[q,H,new R0({height:1}),new S1({child:L})]})})}}m0();class LB4 extends g0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let J=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!J.ok){P.error("Failed to load labels",J.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=J.result,this.isLoading=!1,this.setState()}catch(J){P.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],X=this.labels.some((U)=>U.name===Z),Y=Q.includes(Z);return!X&&!Y}build(J){let Z=f0.of(J),{app:Q,colors:X}=Z,Y=this.currentQuery.trim().toLowerCase(),U=Y.length>0?this.getValidationError(Y):null,V=this.getAvailableLabels(),K=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...V];return new p9({title:"Add Label",items:K,getLabel:(z)=>{if("__isCreateMarker"in z)return this.currentQuery.trim().toLowerCase();return z.name},onAccept:(z)=>{if("__isCreateMarker"in z)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(z.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:U||"Type to create a new label",renderItem:(z,q,F,G)=>{let W=q?Q.selectionBackground:void 0,H=q?Q.selectionForeground:X.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let w=this.currentQuery.trim().toLowerCase();return new l0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T("",void 0,[new T("Create new label: ",new b({color:H})),new T(w,new b({color:H,bold:!0}))])})})}return new l0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T(z.name,new b({color:H}))})})},filterItem:(z,q)=>{if(this.currentQuery!==q)this.currentQuery=q,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in z&&z.__isCreateMarker)return this.shouldShowCreateMarker(q);let G=q.trim().toLowerCase();return G.length===0||z.name.includes(G)},sortItems:(z,q,F)=>{let G="__isCreateMarker"in z.item&&z.item.__isCreateMarker,W="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(G&&!W)return-1;if(!G&&W)return 1;return q.score-z.score}})}}class sm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new LB4}}class SH extends p0{props;constructor(J){super();this.props=J}createState(){return new IB4}}class IB4 extends g0{_spinner=new L3;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:X}=Z,Y=h1.all(new y1(Q.foreground,1,"solid")),U=this._spinner.toBraille(),V=new Q0({textAlign:"center",text:new T("",void 0,[new T(U,new b({color:X.processing})),new T(" ",void 0),new T(this.widget.props.message,new b({color:Q.foreground}))])}),K=[new S1({child:new u0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[V]})})];if(this.widget.props.onAbort)K.push(new R0({height:2,child:new l0({padding:C0.symmetric(2,0),child:new Q0({text:new T("",new b({dim:!0}),[new T("Press ",new b({color:Q.foreground})),new T("Esc",new b({color:Q.info})),new T(" to cancel",new b({color:Q.foreground}))])})})}));let z=new l0({decoration:new _4(Q.background,Y),child:new R0({width:60,height:7,child:new u0({mainAxisAlignment:"start",children:K})})});if(this.widget.props.onAbort)return new T4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(q)=>{if(q.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:z});return z}}class VL extends p0{props;constructor(J){super();this.props=J}createState(){return new MB4}}class MB4 extends g0{scrollController=new r6;scrollAreaKey=new _7("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(J){return J instanceof w2}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Z=this.scrollAreaKey.currentElement?.renderObject;if(Z&&"size"in Z){let Q=Z.size;if(typeof Q.height==="number"&&Q.height>0)return this.viewportHeight=Q.height,Q.height}return this.viewportHeight}build(J){let Z=f0.of(J),Q=this.widget.props.message,X=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let q=g90(Q);return{title:q.title,type:q.type,description:q.description}})(),Y=X.type==="error"?Z.app.toolError:Z.app.command,U=h1.all(new y1(Z.colors.border,1,"solid")),V=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T(X.title,new b({color:Y,bold:!0}))})}),D=this.isWidgetMessage(Q)?Q.widget:new Q0({text:new T(X.description,new b({color:Z.colors.foreground})),selectable:!0}),K=new S1({child:new d$({child:new l0({padding:C0.symmetric(1,0),child:new K1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new S1({child:new O6({controller:this.scrollController,autofocus:!0,child:D})}),new A8({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let q=this.scrollController.maxScrollExtent,F=this.scrollController.offset,G=this.getViewportHeight(),W=q+G;return{totalContentHeight:Math.max(W,0),viewportHeight:Math.max(G,1),scrollOffset:Math.max(F,0)}}})]})})})}),z=new l0({padding:C0.symmetric(1,0),child:new Q0({text:(()=>{if(this.widget.props.onRetry)return new T("",void 0,[new T("Press ",new b({color:Z.colors.foreground,dim:!0})),new T("R",new b({color:Z.app.keybind})),new T(" to retry, ",new b({color:Z.colors.foreground,dim:!0})),new T("Esc",new b({color:Z.app.keybind})),new T(" to cancel",new b({color:Z.colors.foreground,dim:!0}))]);let q=this.resolveFooterStyle(this.widget.props.message);if(q==="none")return new T("",new b({color:Z.colors.foreground,dim:!0}));if(q==="help"){let F=new b({color:Z.app.keybind}),G=new b({color:Z.colors.foreground,dim:!0});return new T("",G,[new T("Press ",G),new T("Escape",F),new T(" to close • Use ",G),new T("↑↓",F),new T(" or ",G),new T("j/k",F),new T(" to scroll",G)])}return new T("Press any key to close",new b({color:Z.colors.foreground,dim:!0,italic:!0}))})()})});return new T4({onKey:(q)=>{if(this.widget.props.onRetry&&q.key==="r")return this.widget.props.onRetry(),"handled";if(q.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new l0({decoration:{border:U,color:Z.colors.background},padding:C0.all(1),child:new u0({mainAxisAlignment:"center",children:[V,new R0({height:1}),K,z]})})})}}n9();class AB4 extends p0{props;constructor(J){super();this.props=J}createState(){return new jB4}}class jB4 extends g0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=u8.default(),{colors:Q,app:X}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:X.toolSuccess};case"error":return{icon:"✗",color:X.toolError}}}build(J){let Z=f0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new Q0({text:new T("No plugins found.",new b({dim:!0}))});let X=[],Y=this.plugins.length,U=this.plugins.filter((K)=>K.status==="active").length,V=this.plugins.reduce((K,z)=>K+z.registeredCommands.length,0),D=this.plugins.reduce((K,z)=>K+z.registeredTools.length,0);if(X.push(new T(`${U}/${Y} ${h4(Y,"plugin")} active`,new b({bold:!0}))),V>0||D>0)X.push(new T(` (${V} ${h4(V,"command")}, ${D} ${h4(D,"tool")})`,new b({dim:!0})));X.push(new T(`
6844
6844
 
6845
6845
  `));for(let K of this.plugins){let{icon:z,color:q}=this.statusIcon(K.status),F=this.getRelativePath(K.uri.toString());if(X.push(new T(`${z} `,new b({color:q}))),X.push(new T(F,new b({bold:!0}))),X.push(new T(` ${K.status}`,new b({dim:!0}))),X.push(new T(`
6846
6846
  `)),K.status==="active"&&K.registeredEvents.length>0)X.push(new T(" Events: ",new b({dim:!0}))),X.push(new T(K.registeredEvents.join(", "),new b({color:Q.link}))),X.push(new T(`
@@ -7239,7 +7239,7 @@ ${Y}`,Z);this.line=Q,this.column=X,this.codeblock=Y}}/*!
7239
7239
  `)}function nN4(J,Z){J.command("usage").description("Show your current Amp usage and credit balance").action(async(Q,X)=>{let Y=X.optsWithGlobals(),U=await Z(Y),V=await U.settings.get("proxy"),D=BM1({settings:{url:U.ampURL,proxy:V},secrets:{getToken:(z,q)=>U.secrets.get(z,q)}}),K=await x6.userDisplayBalanceInfo({},{config:D});if(!K.ok){if(K.error.code==="auth-required")process.stderr.write(Z1.red("Error: ")+"You must be logged in to view usage. Run `amp login` first.\n"),process.exit(1);process.stderr.write(Z1.red("Error: ")+K.error.message+`
7240
7240
  `),process.exit(1)}process.stdout.write(await mg5(K.result.displayText)+`
7241
7241
  `),process.exit(0)})}var Ui5=pp.join(D$,"logs","headless.log"),ud0=pp.join($C,"device-id.json");function Vi5(){return gK.some((J)=>J.listConfigs().length>0)}try{if(process.platform==="win32")await Promise.resolve().then(() => H4(uT(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){z7.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
7242
- `)}function Di5(J){process.emitWarning=(Z,Q,X,Y)=>{let U=typeof Z==="string"?Z:Z.message||String(Z),V=Q||"Warning",D=!1;J.warn(U,{name:V,code:X})}}function g7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")w7("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")w7("experimental.agentMode",Z.mode)}function OI4(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function Ki5(J){try{return await NI4(J,"utf-8")}catch{return J}}async function EI4(J,Z,Q){let X=OI4(J,Z);if(!X)return;let Y=J3(Q)?Q.features:[],U=J3(Q)?Q.user.email:void 0;if(!Y.some((D)=>D.name===MY.HARNESS_SYSTEM_PROMPT&&D.enabled)&&!LI4(U))throw new M4("You are not allowed to do this.",1);w7("systemPrompt",await Ki5(X))}function LI4(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function II4(J,Z){if(typeof J==="boolean")return J;if(!J3(Z))return!1;return cQ(Z.user.email)}function zi5(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function xd0(J){let X=zi5(J)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new M4(`Couldn't connect to the Amp server at ${J}.`,1,X)}var WI4=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??_X,description:`Custom settings file path (overrides the default location ${_X})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(P).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${KE})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:m9(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"mode",long:"mode",short:"m",type:"option",default:NV.SMART.key,description:`Set the agent mode (${bQ().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:bQ().map((J)=>J.mode).concat("large","deep")},{name:"dtw",long:"dtw",type:"flag",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0}],HI4=(J)=>("deprecated"in J)&&J.deprecated===!0,qi5=(J)=>("hidden"in J)&&J.hidden===!0,Fi5=(J)=>("default"in J),Gi5=(J)=>("default"in J)?J.default:void 0,MI4=[{name:"toggle-skills-count",entryPoint:Xu0}];function Wi5(J,Z){let Q=Z.args[0],X=Z.commands.map((U)=>U.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let U=X.filter((D)=>Q.includes(D)||D.includes(Q)),V="Run amp --help for a list of available commands.";if(U.length>0)V=`Did you mean: ${U.join(", ")}? Or run amp --help for all commands.`;throw new M4(t3.unknownCommand(Q),1,V)}}async function bd0(J){return{...J,getThreadEnvironment:tz,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new mY(J.fileSystem),generateThreadTitle:dj,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>AZ(J.configService),pluginService:J.pluginService}}var a$0=q1.file(Yi5.homedir()),fd0=process.env.XDG_CONFIG_HOME?q1.file(process.env.XDG_CONFIG_HOME):V1.joinPath(a$0,".config");function Hi5(J){return p84({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){g84(Z);let Q=z80(),X=Cu0();if((!Q||X||iX4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(Xq("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(Xq("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(z80()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}function Bi5(){return{sync:async()=>{},uploadThread:async()=>{},discoverThreads:async()=>[],initialSyncComplete:Promise.resolve(),updateThreadMeta:async()=>{},threadSyncInfo:()=>v0.of({}),flushPendingSyncs:async()=>{},dispose:()=>{}}}async function c9(J,Z){KM1("0.0.1772201356-g024e62");let Q=Io({storage:J.settings,secretStorage:J.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:a$0,userConfigDir:fd0});gX4(Q);let X=await Q.getLatest();P.debug("Global configuration initialized",{settingsKeys:Object.keys(X.settings)});let{toolService:Y,dispose:U}=x84({configService:Q}),V=new Map,D=()=>V.clear(),K=new ME0(Q,J.settings.getWorkspaceRootPath()),z=Fb1({configService:Q,filesystem:n6}),q=xk1({configService:Q,trustStore:K,skillMCPServers:z.skillMCPServers,createOAuthProvider:async(m,l,g)=>{let n=`${m}:${l}`,d=V.get(n);if(d)return P.debug("Reusing existing OAuth provider for server",{serverName:m,serverUrl:l}),d;P.debug("Creating OAuth provider for server",{serverName:m,serverUrl:l});let $0=(async()=>{let B0=new YN(J.secrets),s=await B0.getClientInfo(m,l),q0=g?.scopes??s?.scopes,K0=XQ4();P.info("OAuth headless mode check",{useHeadless:K0,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:s6.isTTY});let O0;if(K0)O0=J.executeMode?QQ4():ZQ4(m);let Y0=new pO0({storage:B0,serverName:m,serverUrl:l,clientId:g?.clientId??s?.clientId,clientSecret:g?.clientSecret??s?.clientSecret,authUrl:g?.authUrl??s?.authUrl,tokenUrl:g?.tokenUrl??s?.tokenUrl,scopes:q0,headlessAuthHandler:O0});return P.debug("OAuth provider created",{serverName:m,serverUrl:l,hasManualClientId:!!(g?.clientId??s?.clientId),willUseDCR:!(g?.clientId??s?.clientId),scopes:q0,headlessMode:K0,executeMode:J.executeMode}),Y0})();return V.set(n,$0),$0}}),F=OS0({configService:Q,filesystem:n6,spawn:J50}),G;if(J.executeMode){let m=await e64({toolService:Y,providers:[q,F],initialTimeout:15000});G=m.registrations;for(let[l,g]of m.initErrors)P.warn(`${l} provider initialization slow or failed:`,g)}else G=LS0({toolService:Y,providers:[q,F]});if(Z.jetbrains)xw("JetBrains");else if(Z.ide&&mQ4())xw("VS Code");else if(Z.ide&&gQ4())xw("Neovim");else if(Z.ide&&Vi5()){let m=gK.find((l)=>l.listConfigs().length>0);if(m){let l=Ro(m.ideName);if(l)xw(l)}}if(J.executeMode)zM1(!0);let W,H=_8.status.pipe(B1((m)=>Boolean(m.connected&&m.authenticated&&m.ideName&&RM1(m.ideName))),I4()).subscribe((m)=>{if(m){if(!W)W=Y.registerTool(t64)}else W?.dispose(),W=void 0}),B;if(!J.executeMode){let m=await J.settings.get("fuzzy.alwaysIncludePaths")??[];B=new C30(process.cwd(),{alwaysIncludePaths:m},!0)}else B=new class extends C30{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};{let m=await J.secrets.get("apiKey",J.ampURL);if(P.info("API key lookup before login",{found:Boolean(m),ampURL:J.ampURL}),!m){s6.write(`No API key found. Starting login flow...
7242
+ `)}function Di5(J){process.emitWarning=(Z,Q,X,Y)=>{let U=typeof Z==="string"?Z:Z.message||String(Z),V=Q||"Warning",D=!1;J.warn(U,{name:V,code:X})}}function g7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")w7("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")w7("experimental.agentMode",Z.mode)}function OI4(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function Ki5(J){try{return await NI4(J,"utf-8")}catch{return J}}async function EI4(J,Z,Q){let X=OI4(J,Z);if(!X)return;let Y=J3(Q)?Q.features:[],U=J3(Q)?Q.user.email:void 0;if(!Y.some((D)=>D.name===MY.HARNESS_SYSTEM_PROMPT&&D.enabled)&&!LI4(U))throw new M4("You are not allowed to do this.",1);w7("systemPrompt",await Ki5(X))}function LI4(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function II4(J,Z){if(typeof J==="boolean")return J;if(!J3(Z))return!1;return cQ(Z.user.email)}function zi5(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function xd0(J){let X=zi5(J)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new M4(`Couldn't connect to the Amp server at ${J}.`,1,X)}var WI4=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??_X,description:`Custom settings file path (overrides the default location ${_X})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(P).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${KE})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:m9(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"mode",long:"mode",short:"m",type:"option",default:NV.SMART.key,description:`Set the agent mode (${bQ().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:bQ().map((J)=>J.mode).concat("large","deep")},{name:"dtw",long:"dtw",type:"flag",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0}],HI4=(J)=>("deprecated"in J)&&J.deprecated===!0,qi5=(J)=>("hidden"in J)&&J.hidden===!0,Fi5=(J)=>("default"in J),Gi5=(J)=>("default"in J)?J.default:void 0,MI4=[{name:"toggle-skills-count",entryPoint:Xu0}];function Wi5(J,Z){let Q=Z.args[0],X=Z.commands.map((U)=>U.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let U=X.filter((D)=>Q.includes(D)||D.includes(Q)),V="Run amp --help for a list of available commands.";if(U.length>0)V=`Did you mean: ${U.join(", ")}? Or run amp --help for all commands.`;throw new M4(t3.unknownCommand(Q),1,V)}}async function bd0(J){return{...J,getThreadEnvironment:tz,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new mY(J.fileSystem),generateThreadTitle:dj,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>AZ(J.configService),pluginService:J.pluginService}}var a$0=q1.file(Yi5.homedir()),fd0=process.env.XDG_CONFIG_HOME?q1.file(process.env.XDG_CONFIG_HOME):V1.joinPath(a$0,".config");function Hi5(J){return p84({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){g84(Z);let Q=z80(),X=Cu0();if((!Q||X||iX4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(Xq("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(Xq("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(z80()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}function Bi5(){return{sync:async()=>{},uploadThread:async()=>{},discoverThreads:async()=>[],initialSyncComplete:Promise.resolve(),updateThreadMeta:async()=>{},threadSyncInfo:()=>v0.of({}),flushPendingSyncs:async()=>{},dispose:()=>{}}}async function c9(J,Z){KM1("0.0.1772208429-ge4b10a");let Q=Io({storage:J.settings,secretStorage:J.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:a$0,userConfigDir:fd0});gX4(Q);let X=await Q.getLatest();P.debug("Global configuration initialized",{settingsKeys:Object.keys(X.settings)});let{toolService:Y,dispose:U}=x84({configService:Q}),V=new Map,D=()=>V.clear(),K=new ME0(Q,J.settings.getWorkspaceRootPath()),z=Fb1({configService:Q,filesystem:n6}),q=xk1({configService:Q,trustStore:K,skillMCPServers:z.skillMCPServers,createOAuthProvider:async(m,l,g)=>{let n=`${m}:${l}`,d=V.get(n);if(d)return P.debug("Reusing existing OAuth provider for server",{serverName:m,serverUrl:l}),d;P.debug("Creating OAuth provider for server",{serverName:m,serverUrl:l});let $0=(async()=>{let B0=new YN(J.secrets),s=await B0.getClientInfo(m,l),q0=g?.scopes??s?.scopes,K0=XQ4();P.info("OAuth headless mode check",{useHeadless:K0,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:s6.isTTY});let O0;if(K0)O0=J.executeMode?QQ4():ZQ4(m);let Y0=new pO0({storage:B0,serverName:m,serverUrl:l,clientId:g?.clientId??s?.clientId,clientSecret:g?.clientSecret??s?.clientSecret,authUrl:g?.authUrl??s?.authUrl,tokenUrl:g?.tokenUrl??s?.tokenUrl,scopes:q0,headlessAuthHandler:O0});return P.debug("OAuth provider created",{serverName:m,serverUrl:l,hasManualClientId:!!(g?.clientId??s?.clientId),willUseDCR:!(g?.clientId??s?.clientId),scopes:q0,headlessMode:K0,executeMode:J.executeMode}),Y0})();return V.set(n,$0),$0}}),F=OS0({configService:Q,filesystem:n6,spawn:J50}),G;if(J.executeMode){let m=await e64({toolService:Y,providers:[q,F],initialTimeout:15000});G=m.registrations;for(let[l,g]of m.initErrors)P.warn(`${l} provider initialization slow or failed:`,g)}else G=LS0({toolService:Y,providers:[q,F]});if(Z.jetbrains)xw("JetBrains");else if(Z.ide&&mQ4())xw("VS Code");else if(Z.ide&&gQ4())xw("Neovim");else if(Z.ide&&Vi5()){let m=gK.find((l)=>l.listConfigs().length>0);if(m){let l=Ro(m.ideName);if(l)xw(l)}}if(J.executeMode)zM1(!0);let W,H=_8.status.pipe(B1((m)=>Boolean(m.connected&&m.authenticated&&m.ideName&&RM1(m.ideName))),I4()).subscribe((m)=>{if(m){if(!W)W=Y.registerTool(t64)}else W?.dispose(),W=void 0}),B;if(!J.executeMode){let m=await J.settings.get("fuzzy.alwaysIncludePaths")??[];B=new C30(process.cwd(),{alwaysIncludePaths:m},!0)}else B=new class extends C30{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};{let m=await J.secrets.get("apiKey",J.ampURL);if(P.info("API key lookup before login",{found:Boolean(m),ampURL:J.ampURL}),!m){s6.write(`No API key found. Starting login flow...
7243
7243
  `);let l=await wi5(J),g=await J.secrets.get("apiKey",J.ampURL);if(P.info("Login flow completed",{success:l,storedKeyPresent:Boolean(g),ampURL:J.ampURL}),!l)await $q(),process.exit(1)}}{let m=await Q.getLatest(),l=m.settings.url,g=m.secrets.isSet?.[l];P.info("Config secrets state after login",{configURL:l,apiKeySet:g?.apiKey??!1})}let w=_1(AZ(Q).pipe(d5((m)=>m!=="pending"))),N=await Nb1({isDevelopment:!1}),O=await w;P.info("Server status resolved",{status:"ready",isAuthenticated:J3(O),isError:rA(O),errorMessage:rA(O)?O.error.message:void 0});let E=new _M0(N,Q),L=new MI0(N,{lazy:!0});P.info("Starting Amp background services");let I=II4(Z.dtw,O),M=Boolean(I||Z.headless);if(M)P.info("DTW mode enabled: thread sync service disabled");let A=M?Bi5():nh1({threadService:E,threadHistoryService:L,configService:Q,isExtensionDevelopment:!1}),R;_8.status.subscribe((m)=>{R=m});let _=new mH0({workspaceRoots:[q1.file(process.cwd())],fileSystem:Z.jetbrains||Z.ide?gs:n6,getCurrentFile:()=>{if(!R?.openFile)return;try{return q1.parse(R.openFile)}catch(m){P.warn("Failed to parse current file URI",{uri:R.openFile,error:m});return}},getOpenFiles:()=>{if(!R?.visibleFiles?.length)return[];let m=R.openFile;return R.visibleFiles.filter((l)=>l!==m).map((l)=>{try{return q1.parse(l)}catch(g){return P.warn("Failed to parse visible file URI",{uri:l,error:g}),null}}).filter((l)=>l!==null)}}),k=new Su0,u=process.env.PLUGINS??"off",h=new Qu0({configService:Q}),f=zI0({configService:Q,fileSystem:Z.jetbrains||Z.ide?gs:n6,platform:h,internalPlugins:MI4,pluginFilter:u}),S=kf1({pluginService:f,toolService:Y}),x={codebaseContextService:_,configService:Q,toolService:Y,mcpService:q,skillService:z,toolboxService:F,trustStore:K,threadService:E,threadHistoryService:L,threadSyncService:A,threadStorage:N,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:B,fileSystem:Z.jetbrains||Z.ide?gs:n6,terminal:k,pluginService:f,pluginPlatform:h,serverStatus:O};return{...x,async asyncDispose(){if(x.mcpService.hasAuthenticatingClients())P.info("Waiting for OAuth authentication to complete before exit..."),await x.mcpService.waitForAuthentication();for(let m of G.values())m.dispose();await x.mcpService.dispose(),D(),await x.threadService.asyncDispose(),x.configService.unsubscribe(),U(),x.fuzzyServer.dispose(),x.threadSyncService.dispose(),x.settingsStorage[Symbol.dispose](),H.unsubscribe(),W?.dispose(),S.dispose(),x.pluginService.dispose()}}}async function wi5(J){if(!J.executeMode){if(!await Ju0("Would you like to log in to Amp? [(y)es, (n)o]: "))return s6.write(`Login cancelled. Run the command again to retry.
7244
7244
  `),!1}return await AI4(J)}async function AI4(J){let Z=Zi5(32).toString("hex"),Q=await $u0(J.ampURL,Z),X=new AbortController;try{await LV(Q,X.signal)}catch(U){P.error("Error opening browser",{error:U})}let Y=await $u0(J.ampURL,Z,!1);s6.write(`If your browser does not open automatically, visit:
7245
7245
 
@@ -7247,7 +7247,7 @@ ${Z1.blue.bold(Y)}
7247
7247
 
7248
7248
  `);try{return await zX4(J.ampURL,Z,J.secrets,X),s6.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(U){return P.error("Login failed",{error:U}),z7.write(`
7249
7249
  Login failed: ${U instanceof Error?U.message:String(U)}
7250
- `),!1}}function Ni5(){let J=new RW().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((W)=>{if(W.code==="commander.help"||W.code==="commander.version"||W.exitCode===0)qE(),process.exit(0);let H=W.originalError??W;N30(H)}),J.option("-V, --version","Print the version number and exit",()=>{let H;try{H=`, ${YG(new Date("2026-02-27T14:14:52.407Z"))} ago`}catch{}s6.write(`0.0.1772201356-g024e62 (released 2026-02-27T14:14:52.407Z${H??""})
7250
+ `),!1}}function Ni5(){let J=new RW().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((W)=>{if(W.code==="commander.help"||W.code==="commander.version"||W.exitCode===0)qE(),process.exit(0);let H=W.originalError??W;N30(H)}),J.option("-V, --version","Print the version number and exit",()=>{let H;try{H=`, ${YG(new Date("2026-02-27T16:13:08.868Z"))} ago`}catch{}s6.write(`0.0.1772208429-ge4b10a (released 2026-02-27T16:13:08.868Z${H??""})
7251
7251
  `),process.exit(0)}),J.addHelpText("after",fQ4()),J.configureHelp({formatHelp:bQ4}),J.command("logout").description("Log out by removing stored API key").action(async(W,H)=>{let B=H.optsWithGlobals(),w=await M3(B);await Ri5(w)}),J.command("login").description("Log in to Amp").addHelpText("after","If AMP_URL is set during login, it will be persisted to global settings for future CLI invocations, though AMP_URL will continue to take precedence.").action(async(W,H)=>{let B=H.optsWithGlobals(),w=await M3(B);await ji5(w,await uy0(B,w.settings))}),J.command("git-credential-helper [action]",{hidden:!0}).summary("Git credential helper for GitHub").description("Internal: implements the git credential helper protocol. Used inside sandboxes to authenticate git operations with GitHub.").action(async(W,H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await gZ4(W??"get",N.ampURL,N.secrets),process.exit(process.exitCode??0)}),J.command("sign-commit",{hidden:!0}).summary("Git commit signing helper").description("Internal: implements the gpg signing interface for git commit signing. Used inside sandboxes as gpg.program.").allowUnknownOption().action(async(W,H)=>{let B=H.optsWithGlobals(),w=await M3(B);await pZ4(w.ampURL,w.secrets),process.exit(process.exitCode??0)}),J.command("dtw-curl [threadId] [action] [message...]",{hidden:!0}).summary("DTW helper").description("Internal: helper for DTW one-shot commands.").addHelpText("after",`
7252
7252
  Actions:
7253
7253
  add-message <message> Send a user message and wait for message_added
@@ -7291,7 +7291,7 @@ See: https://ampcode.com/news/stick-a-fork-in-it
7291
7291
  amp threads handoff T-xxx --goal "Continue working on the auth feature"
7292
7292
  amp threads handoff --goal "Fix the remaining tests" # Uses last thread
7293
7293
 
7294
- By default, opens the new thread in the TUI. Use --print to just print the thread ID.`).option("-g, --goal <goal>","Goal/prompt for the handoff (alternative to stdin)").option("-p, --print","Print the thread ID instead of opening the TUI").action(async(W,H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await ki5(w,N,W??null,H.goal,!H.print,B)}),Q.command("markdown <threadId>").alias("md").summary("Render thread as markdown").description("Render a thread as markdown. This outputs the entire conversation history in a readable markdown format.").action(async(W,H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await _i5(w,N,W,B)}),Q.command("export <threadId>",{hidden:!0}).summary("Export a thread as JSON").description("Export a thread as JSON. This outputs the full thread payload.").action(async(W,H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await Si5(w,N,W,B)}),C94(Q,M3,g7,c9,hd0,oH,q3),gY4(J,async(W,H)=>{let B=await M3(H);g7(W,H);let w=await c9(B,H);return{context:B,mcpService:w.mcpService,toolService:w.toolService,toolServices:w.toolService,skillService:w.skillService,threadService:w.threadService,fileSystem:w.fileSystem,getThreadEnvironment:tz,serverStatus:w.serverStatus,toolboxService:w.toolboxService,configService:w.configService,cleanupTerminal:qE,asyncDispose:w.asyncDispose.bind(w)}}),_X4(J,async(W)=>{let H=W.optsWithGlobals(),B=await M3(H);g7(W,H);let w=Io({storage:B.settings,secretStorage:B.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:B.ampURL,homeDir:a$0,userConfigDir:fd0});return{pluginService:zI0({configService:w,fileSystem:n6,platform:{clientKind:"terminal",clientVersion:"0.0.1772201356-g024e62",async notify(E){P.debug("plugin notification (TUI not loaded): %s",E)},async open(E){z7.write(`
7294
+ By default, opens the new thread in the TUI. Use --print to just print the thread ID.`).option("-g, --goal <goal>","Goal/prompt for the handoff (alternative to stdin)").option("-p, --print","Print the thread ID instead of opening the TUI").action(async(W,H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await ki5(w,N,W??null,H.goal,!H.print,B)}),Q.command("markdown <threadId>").alias("md").summary("Render thread as markdown").description("Render a thread as markdown. This outputs the entire conversation history in a readable markdown format.").action(async(W,H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await _i5(w,N,W,B)}),Q.command("export <threadId>",{hidden:!0}).summary("Export a thread as JSON").description("Export a thread as JSON. This outputs the full thread payload.").action(async(W,H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await Si5(w,N,W,B)}),C94(Q,M3,g7,c9,hd0,oH,q3),gY4(J,async(W,H)=>{let B=await M3(H);g7(W,H);let w=await c9(B,H);return{context:B,mcpService:w.mcpService,toolService:w.toolService,toolServices:w.toolService,skillService:w.skillService,threadService:w.threadService,fileSystem:w.fileSystem,getThreadEnvironment:tz,serverStatus:w.serverStatus,toolboxService:w.toolboxService,configService:w.configService,cleanupTerminal:qE,asyncDispose:w.asyncDispose.bind(w)}}),_X4(J,async(W)=>{let H=W.optsWithGlobals(),B=await M3(H);g7(W,H);let w=Io({storage:B.settings,secretStorage:B.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:B.ampURL,homeDir:a$0,userConfigDir:fd0});return{pluginService:zI0({configService:w,fileSystem:n6,platform:{clientKind:"terminal",clientVersion:"0.0.1772208429-ge4b10a",async notify(E){P.debug("plugin notification (TUI not loaded): %s",E)},async open(E){z7.write(`
7295
7295
  ${E}
7296
7296
 
7297
7297
  `)},async input(){return},async confirm(){return!1},async ask(){return{result:"uncertain",probability:0.5,reason:"AI not available"}}},internalPlugins:MI4,emitSessionStart:!1,pluginFilter:process.env.PLUGINS??"off"}),asyncDispose:async()=>{}}}),yX4(J,async(W)=>{let H=W.optsWithGlobals(),B=await M3(H);g7(W,H);let w=await c9(B,H);return{toolService:w.toolService,mcpService:w.mcpService,configService:w.configService,skillService:w.skillService,cleanupTerminal:qE,asyncDispose:w.asyncDispose.bind(w)}}),hX4(J,async(W)=>{let H=W.optsWithGlobals(),B=await M3(H);g7(W,H);let w=await c9(B,H);return{settings:B.settings,configService:w.configService,skillService:w.skillService,asyncDispose:w.asyncDispose.bind(w)}}),PX4(J,async(W)=>{let H=W.optsWithGlobals();return await M3(H)}),BX4(J,async(W)=>{let H=await M3(W);return{settings:H.settings,secretStorage:H.secrets,getThreadDeps:async(B)=>{g7(B,W);let w=await c9(H,W);return{mcpService:w.mcpService,settings:H.settings,asyncDispose:w.asyncDispose.bind(w)}}}}),nN4(J,M3);function U(W,H,B){let N=typeof W.description==="string"?W.description:B===void 0?W.description(!0):W.description(B),O=new LD(H,N),E=Gi5(W);if(E)O.default(E);if(O.hidden=qi5(W)||HI4(W),"choices"in W)O.choices([...W.choices]);return O}for(let W of WI4){switch(W.type){case"flag":{J.addOption(U(W,`--${W.long}`)),J.addOption(U(W,`--no-${W.long}`,!1));break}case"switch":{J.addOption(U(W,`--${W.long}`,!0));break}case"optional-option":{J.addOption(U(W,`${"short"in W?`-${W.short}, `:""}--${W.long} [value]`));break}default:{J.addOption(U(W,`${"short"in W?`-${W.short}, `:""}--${W.long} <value>`));break}}if("aliases"in W&&W.aliases)for(let H of W.aliases){let B=new LD(`--${H}`,W.description);B.hidden=!0,B.implies({[W.name]:!0}),J.addOption(B)}}let V=new LD("-x, --execute [message]","Use execute mode, optionally with user message. In execute mode, agent will execute provided prompt (either as argument, or via stdin). Only last assistant message is printed. Enabled automatically when redirecting stdout.").default(!1);J.addOption(V);let D=new LD("--stream-json","When used with --execute, output in Claude Code-compatible stream JSON format instead of plain text.").default(!1);J.addOption(D);let K=new LD("--stream-json-thinking","Include thinking blocks in stream JSON output (non-Claude Code extension). Implies --stream-json.").default(!1);J.addOption(K);let z=new LD("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(z);let q=new LD("--stats","When used with --execute, output JSON with both result and token usage data (for /evals).").default(!1).hideHelp(!0);J.addOption(q);let F=new LD("--archive","When used with --execute, archive the thread after the command finishes.").default(!1);J.addOption(F);let G=new LD("-l, --label <label>","When used with --execute, add a label to the thread. Can be used multiple times.").argParser((W,H)=>{if(H===void 0)return[W];return[...H,W]});return J.addOption(G),J.action(async(W,H)=>{let B=W,w=await M3(B);if(Object.keys(B).forEach((N)=>{let O=WI4.find((E)=>E.name===N);if(O&&HI4(O)&&!Fi5(O))z7.write(Z1.yellow(`Warning: '--${N}' flag is deprecated
@@ -7299,8 +7299,8 @@ ${E}
7299
7299
 
7300
7300
  This thread belongs to a different user and cannot be continued for security reasons. Set AMP_RESUME_OTHER_USER_THREADS_INSECURE=1 to bypass this check.`)}}async function Oi5(J,{nonBlockingOwnershipCheck:Z=!1,onOwnershipError:Q}={},X){if(!q8(J))throw new M4(t3.invalidThreadId);let Y=Date.now();if(P.info(`[fetchAndStartThread] Begin switch to thread ${J}`),Z)BI4(J,X.configService).catch((z)=>{if(z instanceof M4){if(Q){Q(z,J);return}lh(z,J);return}P.warn("Failed to validate thread ownership in CLI, allowing to open",{error:z})});else try{await BI4(J,X.configService)}catch(z){if(z instanceof M4)throw z;P.warn("Failed to validate thread ownership in CLI, allowing to open",{error:z})}let U=Date.now(),V=await X.threadService.get(J)??void 0;P.info(`[fetchAndStartThread] Loaded thread in ${Date.now()-U}ms`),P.info(`[fetchAndStartThread] Loaded thread ${J}, agentMode: ${V?.agentMode??"undefined"}`);let D=Date.now(),K=await Up0(X.workerDeps,{threadMeta:X.visibility?SD(X.visibility):void 0,agentMode:V?void 0:X.agentMode,thread:V,onFirstAssistantMessage:jI4});return P.info(`[fetchAndStartThread] Started worker in ${Date.now()-D}ms (total ${Date.now()-Y}ms)`),K}async function Ei5(J){if(!J.userEmail||!cQ(J.userEmail))throw new M4("DTW TUI mode is only available for Amp employees",1);let Z=await J.secretStorage.get("apiKey",J.ampURL);P.info("[createDTWRuntime] Creating DTW provider",{threadId:J.threadId,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL,hasApiKey:Boolean(Z)});let Q;try{Q=await uW.create({ampURL:J.ampURL,apiKey:Z,configService:J.configService,threadId:J.threadId,workerUrl:process.env.AMP_WORKER_URL})}catch(X){throw P.error("[createDTWRuntime] Failed to create DTW provider",{threadId:J.threadId,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL,error:X}),X}P.info("[createDTWRuntime] Creating DTW runtime",{threadId:Q.threadId});try{return await oW.create({provider:Q,deps:{threadService:J.threadService,configService:J.configService,toolService:J.toolService,skillService:J.skillService,getThreadEnvironment:tz,fileChangeTrackerStorage:new mY(J.fileSystem),osFileSystem:J.fileSystem,deleteThread:(X)=>J.threadService.delete(X),generateThreadTitle:dj,mcpService:J.mcpService,pluginService:J.pluginService,ampURL:J.ampURL}})}catch(X){throw P.error("[createDTWRuntime] Failed to create DTW runtime",{threadId:Q.threadId,error:X}),X}}async function Li5(J){if(J.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof J.execute==="string"){let Z=(await Gm()).trimEnd();return{userInput:J.execute,stdinInput:Z||null}}return{userInput:(await Gm()).trimEnd(),stdinInput:null}}function Ii5(J,Z,Q){if(J.streamJson&&!Z)throw new M4("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(J.streamJsonInput&&!Z)throw new M4("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(J.streamJsonInput&&!J.streamJson)throw new M4("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(J.stats&&!Z)throw new M4("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(J.archive&&!Z)throw new M4("The --archive flag requires --execute mode",1,'Use: amp --execute "your message" --archive');if(J.streamJsonInput&&typeof J.execute==="string"&&J.execute.trim()!=="")throw new M4("Do not provide a message argument when using --stream-json-input",1,`Supply messages via stdin JSONL instead: echo '{"type":"user","message":{"role":"user","content":[{"type":"text","text":"your message"}]}}' | amp --execute --stream-json --stream-json-input`);if(Z&&Q===""&&!J.streamJsonInput&&!J.headless)throw new M4("User message must be provided through stdin or as argument when using execute mode",1,`Either pass a message as an argument: amp --execute "your message"
7301
7301
  Or pipe via stdin: echo "your message" | amp --execute`)}async function o$0(J,Z,Q){let{userInput:X,stdinInput:Y}=await Li5(Z),U=!!Z.streamJson||!!Z.streamJsonThinking;Ii5({...Z,streamJson:U},J.executeMode,X),g7(Q,Z);let V=await c9(J,Z),D=await bd0(V),{serverStatus:K}=V;if(rA(K)){let S=ch(Error(K.error.message));if(S.message===t3.networkOffline||S.message===t3.networkTimeout)throw xd0(J.ampURL);throw new M4(t3.invalidAPIKey,1)}let z=J3(K)?K.user.email:void 0,q=J3(K)?K.features:[],F=J3(K)?K.workspace:null,G=LI4(z),W=II4(Z.dtw,K);await EI4(Q,Z,K);let H=J3(K)?{...K.user,features:q,team:F??void 0}:null,B=n30(Z,H);if(B instanceof Error)q3(B.message);if((J.executeMode||U)&&P8(Z.mode)&&!G)throw new M4(`Execute mode is not permitted with --mode '${Z.mode}'`,1);if(Z.headless){if(!z||!cQ(z))throw new M4("Headless DTW mode is only available for Amp employees",1);let S=await V.secretStorage.get("apiKey",J.ampURL);if(!S)throw new M4("API key required for headless mode. Please run `amp login` first.",1);let x=typeof Z.headless==="string"&&Z.headless!=="true"?Z.headless:void 0;if(x&&!q8(x))throw new M4(`Invalid thread ID: ${x}`,1);let m=x??await yi5({dependencies:V,visibility:B??void 0}),l=await DQ4(m);if(l.status==="already-running")await V.asyncDispose(),await $q(),process.exit(0);try{await JQ4({ampURL:J.ampURL,apiKey:S,workerUrl:process.env.AMP_WORKER_URL,workspaceRoot:process.cwd(),threadId:m,configService:V.configService,mcpService:V.mcpService,toolService:V.toolService,skillService:V.skillService,fileSystem:V.fileSystem})}finally{await l.release(),await V.asyncDispose()}await $q(),process.exit(0)}let w={threadService:V.threadService,workerDeps:D,createThread:async()=>{let S=await W30(J.settings,process.cwd(),H,B);if(S instanceof Error)q3(S.message);return Up0(D,{threadMeta:S?SD(S):void 0,agentMode:Z.mode,onFirstAssistantMessage:jI4})},switchToThread:(S,x)=>Oi5(S,{nonBlockingOwnershipCheck:x?.nonBlockingOwnershipCheck??!1,onOwnershipError:x?.onOwnershipError},{configService:V.configService,threadService:V.threadService,workerDeps:D,visibility:B,agentMode:Z.mode})},N=async()=>{try{if(W)return Ei5({userEmail:z,secretStorage:V.secretStorage,ampURL:J.ampURL,configService:V.configService,threadService:V.threadService,toolService:V.toolService,skillService:V.skillService,mcpService:V.mcpService,pluginService:V.pluginService,fileSystem:V.fileSystem,threadId:Z.threadId});return hN4(w,Z.threadId,{nonBlockingOwnershipCheck:Z.nonBlockingThreadOwnershipCheck})}catch(S){if(S instanceof M4)throw S;throw await lh(S,Z.threadId),Error("handleError should have called process.exit()")}};if(Z.format==="jsonl")z7.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
7302
- `),await $q(),process.exit(1);let O=(async()=>{try{let S=await V.configService.getLatest(),x=ua(S),m=await x6.getUserFreeTierStatus({},{config:V.configService,signal:AbortSignal.timeout(x)});if(m.ok)return P.info("User free tier status:",m),m.result}catch(S){throw P.error("Failed to fetch free tier status:",S),S}})(),E=await N(),L=Z.notifications!==void 0?Z.notifications:!J.executeMode,I=await V.configService.getLatest();if(Hi5({configService:V.configService,threadService:V.threadService,config:I,useNotificationsForService:L,threadViewStates$:()=>E.threadViewStates$}),J.executeMode){if(EX4(V.mcpService,J.settings),!(E instanceof NT))throw new M4("Execute mode is not supported in DTW runtime",1);let S=E.getWorkerForExecuteMode();if(await RZ4({worker:S,threadID:S.threadID,userInput:X,stdinInput:Y,dependencies:V,streamJson:U,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isDogfooding:G,agentMode:Z.mode,labels:Z.label}),Z.archive)await x6.archiveThread({thread:S.threadID,archived:!0},{config:V.configService});await V.asyncDispose(),process.exit(0)}let M=!1,A=!1,R=!1;if(Z.jetbrains||Z.ide){await SM1();let S=gw({jetbrainsOnly:Z.jetbrains});if(S.length===0){if(Z.jetbrains)A=!await V.configService.get("jetbrains.skipInstall")}else if(S.length===1){let x=S[0];if(x)_8.selectConfig(x)}else R=!0}let _=ey0("0.0.1772201356-g024e62",V.settingsStorage),k=new II0(V.threadStorage),u=new Zu0(V.mcpService,J.settings.getWorkspaceRootPath());if(X)await E.sendMessage({content:[{type:"text",text:X}]});let h=await vD();P.info("Loaded session state:",h);let f={...h,launchCount:h.launchCount+1};kD(f);try{await yN4({codebaseContextService:V.codebaseContextService,stdout:process.stdout,history:new Ey0,fuzzyServer:V.fuzzyServer,settingsStorage:V.settingsStorage,threadService:V.threadService,threadHistoryService:V.threadHistoryService,threadFuzzyIndexer:k,skillService:V.skillService,configService:V.configService,internalAPIClient:x6,ampURL:J.ampURL,runtime:E,ideClient:_8,mcpService:V.mcpService,toolboxService:V.toolboxService,mcpTrustHandler:u,showJetBrainsInstaller:A,showIdePicker:M,showIdePickerHint:R,openThreadSwitcher:Z.openThreadSwitcher,updateService:_,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Z.clientId,sessionState:f,freeTierStatusPromise:O,workspace:F??null,features:q,isDogfooding:G,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-02-27T14:14:52.407Z",pluginPlatform:V.pluginPlatform,pluginService:V.pluginService})}finally{await E.dispose?.()}await V.asyncDispose(),process.exit(0)}async function M3(J){if(P.info("Initializing CLI context",{argv:process.argv,nodeEnv:"production",hasAmpURL:Boolean(process.env.AMP_URL),hasAmpAPIKey:Boolean(process.env.AMP_API_KEY),hasSettingsFile:Boolean(process.env.AMP_SETTINGS_FILE)}),J.interactive)z7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7303
- `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;P.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let X=await pk1({get:async(D)=>{if(D!==py)return;try{let K=await NI4(ud0,"utf-8");return JSON.parse(K).installationID}catch{return}},set:async(D,K)=>{if(D!==py)return;await Qi5(pp.dirname(ud0),{recursive:!0}),await Xi5(ud0,JSON.stringify({installationID:K},null,2),{mode:384})}},{clientType:"cli",platform:lQ()});qM1(X);let Y=await LQ4({...J,workspaceTrust:{current:!0,changes:kv},getHook:process.env.AMP_URL?(D,K)=>{if(D==="url")return Promise.resolve(process.env.AMP_URL);return K()}:void 0});if(J.mcpConfig){let D=await NX4(J.mcpConfig);Y=OX4(Y,D)}let U=pp.dirname(Y.getSettingsFilePath());m84($C,U);let V=await Y.get("url","global");if(!V)V=N7;if(P.info("Resolved Amp URL",{ampURL:V,settingsFile:Y.getSettingsFilePath(),workspaceRoot:Y.getWorkspaceRootPath()}),!xF(V))P.info("Targeting custom Amp server",{ampURL:V});return Y=$M1(Y),{executeMode:Z,isTTY:Q,ampURL:V,settings:Y,secrets:uX4(await uy0(J,Y))}}function Mi5(J){let Z={};for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X?.startsWith("--")){let U=X.slice(2).replace(/-([a-z])/g,(D,K)=>K.toUpperCase()),V=J[Q+1];if(V&&!V.startsWith("--"))Z[U]=V,Q++}}return Z}async function Ai5(){let J=Mi5(process.argv),Z=process.argv.includes("--headless")||process.argv.some((U)=>U.startsWith("--headless="));mJ4({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Z?Ui5:void 0)});let Q=process.argv.includes("--no-color"),X=process.argv.includes("--color"),Y=process.stdout.isTTY&&process.stderr.isTTY;if(Q||!X&&!Y)Z1.level=0;if(Di5(P),P.info("Starting Amp CLI.",{version:"0.0.1772201356-g024e62",buildTimestamp:"2026-02-27T14:14:52.407Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new M4(t3.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Ni5().parseAsync(process.argv)}b84().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await Ai5().catch(lh)});async function ji5(J,Z){let Q=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Q)await J.settings.set("url",process.env.AMP_URL,"global"),s6.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7302
+ `),await $q(),process.exit(1);let O=(async()=>{try{let S=await V.configService.getLatest(),x=ua(S),m=await x6.getUserFreeTierStatus({},{config:V.configService,signal:AbortSignal.timeout(x)});if(m.ok)return P.info("User free tier status:",m),m.result}catch(S){throw P.error("Failed to fetch free tier status:",S),S}})(),E=await N(),L=Z.notifications!==void 0?Z.notifications:!J.executeMode,I=await V.configService.getLatest();if(Hi5({configService:V.configService,threadService:V.threadService,config:I,useNotificationsForService:L,threadViewStates$:()=>E.threadViewStates$}),J.executeMode){if(EX4(V.mcpService,J.settings),!(E instanceof NT))throw new M4("Execute mode is not supported in DTW runtime",1);let S=E.getWorkerForExecuteMode();if(await RZ4({worker:S,threadID:S.threadID,userInput:X,stdinInput:Y,dependencies:V,streamJson:U,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isDogfooding:G,agentMode:Z.mode,labels:Z.label}),Z.archive)await x6.archiveThread({thread:S.threadID,archived:!0},{config:V.configService});await V.asyncDispose(),process.exit(0)}let M=!1,A=!1,R=!1;if(Z.jetbrains||Z.ide){await SM1();let S=gw({jetbrainsOnly:Z.jetbrains});if(S.length===0){if(Z.jetbrains)A=!await V.configService.get("jetbrains.skipInstall")}else if(S.length===1){let x=S[0];if(x)_8.selectConfig(x)}else R=!0}let _=ey0("0.0.1772208429-ge4b10a",V.settingsStorage),k=new II0(V.threadStorage),u=new Zu0(V.mcpService,J.settings.getWorkspaceRootPath());if(X)await E.sendMessage({content:[{type:"text",text:X}]});let h=await vD();P.info("Loaded session state:",h);let f={...h,launchCount:h.launchCount+1};kD(f);try{await yN4({codebaseContextService:V.codebaseContextService,stdout:process.stdout,history:new Ey0,fuzzyServer:V.fuzzyServer,settingsStorage:V.settingsStorage,threadService:V.threadService,threadHistoryService:V.threadHistoryService,threadFuzzyIndexer:k,skillService:V.skillService,configService:V.configService,internalAPIClient:x6,ampURL:J.ampURL,runtime:E,ideClient:_8,mcpService:V.mcpService,toolboxService:V.toolboxService,mcpTrustHandler:u,showJetBrainsInstaller:A,showIdePicker:M,showIdePickerHint:R,openThreadSwitcher:Z.openThreadSwitcher,updateService:_,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Z.clientId,sessionState:f,freeTierStatusPromise:O,workspace:F??null,features:q,isDogfooding:G,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-02-27T16:13:08.868Z",pluginPlatform:V.pluginPlatform,pluginService:V.pluginService})}finally{await E.dispose?.()}await V.asyncDispose(),process.exit(0)}async function M3(J){if(P.info("Initializing CLI context",{argv:process.argv,nodeEnv:"production",hasAmpURL:Boolean(process.env.AMP_URL),hasAmpAPIKey:Boolean(process.env.AMP_API_KEY),hasSettingsFile:Boolean(process.env.AMP_SETTINGS_FILE)}),J.interactive)z7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7303
+ `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;P.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let X=await pk1({get:async(D)=>{if(D!==py)return;try{let K=await NI4(ud0,"utf-8");return JSON.parse(K).installationID}catch{return}},set:async(D,K)=>{if(D!==py)return;await Qi5(pp.dirname(ud0),{recursive:!0}),await Xi5(ud0,JSON.stringify({installationID:K},null,2),{mode:384})}},{clientType:"cli",platform:lQ()});qM1(X);let Y=await LQ4({...J,workspaceTrust:{current:!0,changes:kv},getHook:process.env.AMP_URL?(D,K)=>{if(D==="url")return Promise.resolve(process.env.AMP_URL);return K()}:void 0});if(J.mcpConfig){let D=await NX4(J.mcpConfig);Y=OX4(Y,D)}let U=pp.dirname(Y.getSettingsFilePath());m84($C,U);let V=await Y.get("url","global");if(!V)V=N7;if(P.info("Resolved Amp URL",{ampURL:V,settingsFile:Y.getSettingsFilePath(),workspaceRoot:Y.getWorkspaceRootPath()}),!xF(V))P.info("Targeting custom Amp server",{ampURL:V});return Y=$M1(Y),{executeMode:Z,isTTY:Q,ampURL:V,settings:Y,secrets:uX4(await uy0(J,Y))}}function Mi5(J){let Z={};for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X?.startsWith("--")){let U=X.slice(2).replace(/-([a-z])/g,(D,K)=>K.toUpperCase()),V=J[Q+1];if(V&&!V.startsWith("--"))Z[U]=V,Q++}}return Z}async function Ai5(){let J=Mi5(process.argv),Z=process.argv.includes("--headless")||process.argv.some((U)=>U.startsWith("--headless="));mJ4({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Z?Ui5:void 0)});let Q=process.argv.includes("--no-color"),X=process.argv.includes("--color"),Y=process.stdout.isTTY&&process.stderr.isTTY;if(Q||!X&&!Y)Z1.level=0;if(Di5(P),P.info("Starting Amp CLI.",{version:"0.0.1772208429-ge4b10a",buildTimestamp:"2026-02-27T16:13:08.868Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new M4(t3.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Ni5().parseAsync(process.argv)}b84().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await Ai5().catch(lh)});async function ji5(J,Z){let Q=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Q)await J.settings.set("url",process.env.AMP_URL,"global"),s6.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7304
7304
  `);else if(!xF(J.ampURL))s6.write(`Logging in to ${new URL(J.ampURL).hostname}
7305
7305
  `);let X=process.env.AMP_API_KEY;if(X)s6.write(`API key found in environment variable, storing...
7306
7306
  `),await Z.set("apiKey",X,J.ampURL),s6.write(`API key successfully stored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1772201356-g024e62",
3
+ "version": "0.0.1772208429-ge4b10a",
4
4
  "description": "CLI for Amp, the frontier coding agent.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {