@sourcegraph/amp 0.0.1779179243-g4e6089 → 0.0.1779190035-gd08a72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +10 -10
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -4791,13 +4791,13 @@ ${K}`))}},error:(z)=>{if(!V)V=!0,Z(Error(`Failed to spawn brew: ${z.message}`))}
|
|
|
4791
4791
|
${K}`;if(E==="pnpm"&&K.includes("Unable to find the global bin directory"))I+=`
|
|
4792
4792
|
|
|
4793
4793
|
Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
|
|
4794
|
-
npm install -g ${J}`;Z(Error(I))}},error:(z)=>{if(!G)G=!0,Z(Error(`Failed to spawn ${E}: ${z.message}`))},complete:()=>{if(!G)G=!0,Y()}})})}i0();i0();sz();var uH3="@ampcode/cli";async function dF0(A,Q,$=uH3){let D=`${Q||"https://registry.npmjs.org"}/${$}/latest`,J=new AbortController,E=setTimeout(()=>J.abort(),5000);try{let F=await fetch(D,{signal:J.signal});if(!F.ok)return{hasUpdate:!1,currentVersion:A,source:"npm"};let Y=await F.json(),Z=Y.version??Y["dist-tags"]?.latest;if(!Z)return{hasUpdate:!1,currentVersion:A,source:"npm"};let U=Uo(A,Z),X=U<0,G,V;if(Y.time){let z=Y.time[A],K=Y.time[Z],I=Date.now();if(z)G=Math.floor((I-new Date(z).getTime())/3600000);if(K)V=Math.floor((I-new Date(K).getTime())/3600000)}return u.info("NPM version comparison",{currentVersion:A,latestVersion:Z,compareResult:U,hasUpdate:X,currentVersionAge:G,latestVersionAge:V}),{hasUpdate:X,latestVersion:Z,currentVersion:A,currentVersionAge:G,latestVersionAge:V,source:"npm"}}catch(F){return u.debug("Error checking npm version",{error:F}),{hasUpdate:!1,currentVersion:A,source:"npm"}}finally{clearTimeout(E)}}var PH3="https://static.ampcode.com/cli/cli-version.txt";async function pF0(A){let Q=new AbortController,$=setTimeout(()=>Q.abort(),5000);try{let B=await fetch(`${PH3}?t=${Date.now()}`,{signal:Q.signal,cache:"no-store"});if(!B.ok)return{hasUpdate:!1,currentVersion:A,source:"bin"};let D=(await B.text()).trim();if(!D||!/^\d+\.\d+\.\d+/.test(D))return{hasUpdate:!1,currentVersion:A,source:"bin"};let J=Uo(A,D),E=J<0;return u.info("Bin version comparison",{currentVersion:A,latestVersion:D,compareResult:J,hasUpdate:E}),{hasUpdate:E,latestVersion:D,currentVersion:A,source:"bin"}}catch(B){return u.debug("Error checking bin version",{error:B}),{hasUpdate:!1,currentVersion:A,source:"bin"}}finally{clearTimeout($)}}var _H3=604800000;function Ky4(A){if(!A)return null;let Q=typeof A==="number"?A:new Date(A).getTime();if(isNaN(Q))return null;let $=Date.now()-Q;if($>_H3)return{ageMs:$};return null}function Uo(A,Q){let $=(E)=>{let[F,Y]=E.split("-");return{parts:F?.split(".").map(Number)||[],label:Y}},B=$(A),D=$(Q),J=Math.max(B.parts.length,D.parts.length);for(let E=0;E<J;E++){let F=B.parts[E]||0,Y=D.parts[E]||0;if(F<Y)return-1;if(F>Y)return 1}if(B.label===D.label)return 0;if(!B.label&&D.label)return 1;if(B.label&&!D.label)return-1;if(B.label&&D.label)return B.label<D.label?-1:1;return 0}function Xo(A){try{let Q=A.match(/^0\.0\.(\d+)(?:-(.+))?/);if(!Q)return null;let $=parseInt(Q[1],10),B=$!==0?$*1000:void 0,J=Q[2]?.match(/^g?([a-f0-9]+)$/)?.[1],E=B!==void 0?zF(B):void 0;return{sha:J,timestamp:B,age:E}}catch{return null}}u1();i0();import{readFile as TH3,realpath as vH3}from"node:fs/promises";import{dirname as Iy4,join as kH3}from"node:path";async function Wy4(A){switch(A){case"binary":case"brew":return SH3(Yo());case"npm":case"pnpm":case"yarn":case"bun":return fH3()}}async function SH3(A){let Q=await BN(A,["--version"],5000);if(Q.reason!=="success")return u.debug("failed to read version from binary",{binaryPath:A,result:Q}),null;return Q.output.trim().split(/\s+/)[0]||null}async function fH3(){try{let A=process.argv[1];if(!A)return null;let Q=await vH3(A),$=Iy4(Iy4(Q));return await yH3(kH3($,"package.json"))}catch(A){return u.debug("failed to read installed version from package.json",{error:A}),null}}async function yH3(A){let Q=await TH3(A,"utf8"),$=JSON.parse(Q);if(!$.name||!wt0($.name))return u.debug("package.json name mismatch",{pkgJsonPath:A,name:$.name}),null;return $.version||null}i0();import{spawn as xH3}from"node:child_process";function ut0(A){if(A=A.replace(/\/$/,""),!A.startsWith("http://")&&!A.startsWith("https://"))A=`https://${A}`;try{return new URL(A),A}catch{return u.warn(`Invalid registry URL: ${A}, falling back to npmjs.org`),"https://registry.npmjs.org"}}var cF0=null,Go=null;function Hy4(A){return new Promise((Q)=>{let $=xH3("npm",["config","get",A],{stdio:["ignore","pipe","ignore"],timeout:5000,shell:process.platform==="win32"}),B="";$.stdout.on("data",(D)=>{B+=D.toString()}),$.on("close",(D,J)=>{if(D!==0||J==="SIGTERM"){Q(null);return}let E=B.trim();Q(E&&E!=="undefined"?E:null)}),$.on("error",()=>{Q(null)})})}async function lF0(){if(cF0)return cF0;if(Go)return Go;Go=(async()=>{let A=process.env.NPM_CONFIG_REGISTRY??process.env.npm_config_registry;if(A)return ut0(A);let Q=await Hy4("@sourcegraph:registry");if(Q)return ut0(Q);let $=await Hy4("registry");if($)return ut0($);return"https://registry.npmjs.org"})();try{return cF0=await Go,cF0}finally{Go=null}}var bH3=3600000,hH3=5000;function iF0(A,Q,$={}){let B=new p4,D=B.pipe(s6({shouldCountRefs:!1})),J=$.startDelayMs??0,E=$.checkIntervalMs??bH3,F=!1,Y=()=>{F=!0};return setImmediate(async()=>{let Z=u.getChild("update");if(J>0){if(await pX(J),F)return}let U=D.subscribe({next:(G)=>{Z.debug("emit new state",G)}}),X=A;try{while(!F){let G=await gH3(X,Q,Z,B);if(G.stop)return;if(G.updatedTo)X=G.updatedTo;if(G.emittedVisibleState){if(await pX(hH3),F)return;B.next("hidden")}if(E<=0)return;let V=1000,z=E;while(z>0&&!F){let K=Math.min(V,z);await pX(K),z-=K}}}finally{U.unsubscribe(),B.complete()}}),{state:D,dispose:Y}}async function gH3(A,Q,$,B){let D={stop:!1,emittedVisibleState:!1};try{if(process.env.AMP_SKIP_UPDATE_CHECK==="1")return $.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable"),D.stop=!0,D;let J=await Q.get("updates.mode");if(J==="disabled")return $.debug("checking disabled"),D.stop=!0,D;let E=await IG(),F=E==="binary"||E==="brew",Y=F?void 0:await DN();$.debug("checking",{currentVersion:A,mode:J,packageManager:E,isBinaryDistribution:F,npmPackageName:Y});let Z;if(F)Z=await pF0(A);else{let G=await lF0();Z=await dF0(A,G,Y)}if(!(Z.latestVersion&&Z.hasUpdate))return $.debug("no update available"),D;let U=(G)=>{B.next(G),D.emittedVisibleState=!0};if(E){let G=await Wy4(E);if(G&&Uo(G,Z.latestVersion)>=0){if($.debug("on-disk version already up to date",{currentVersion:A,installedVersion:G,latestVersion:Z.latestVersion}),D.updatedTo=G,Uo(A,G)<0){let V=await LK(G),z={from:A,to:G,externallyUpdated:!0,...V};if(V.status==="same")$.info("on-disk already updated by another instance",z),U("updated");else $.warn("on-disk already updated by another instance, with PATH warning",z),U("updated-with-warning")}return D}}let X=()=>{if(Z.currentVersionAge!==void 0&&Z.latestVersionAge!==void 0){let G=Z.currentVersionAge-Z.latestVersionAge,V=0.5;if(Math.abs(G)<0.5)return $.debug("versions too close together, suppressing update warning",{currentVersionAge:Z.currentVersionAge,latestVersionAge:Z.latestVersionAge,ageDifferenceHours:G}),!0}return!1};if(!J)J=E==="pnpm"?"warn":"auto",$.debug("no configured update mode; selected default based on package manager",{packageManager:E,mode:J});if(E==="brew"){if(!X())U("update-available-brew");return D}if(E==="binary"&&process.execPath!==Yo()){if($.debug("non-standard binary path, showing warning"),!X())U("update-available-unrecognized-path");return D}if(J==="warn"){if(!X())U("update-available");return D}if(!E){if($.debug("auto-update not supported, falling back to warn mode"),!X())U("update-available");return D}try{await Zo(Z.latestVersion,E),D.updatedTo=Z.latestVersion;let G=await LK(Z.latestVersion),V={from:Z.currentVersion,to:Z.latestVersion,...G};if(G.status==="same")$.info("success",V),U("updated");else $.warn("success with warning",V),U("updated-with-warning")}catch(G){U("update-error")}return D}catch(J){return $.debug("check failed",{error:J}),D}}sz();import{stderr as kF}from"node:process";function qy4(A){let Q=new bq().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(B)=>{await qt0(B.force||!1,B.verbose||!1,"0.0.
|
|
4794
|
+
npm install -g ${J}`;Z(Error(I))}},error:(z)=>{if(!G)G=!0,Z(Error(`Failed to spawn ${E}: ${z.message}`))},complete:()=>{if(!G)G=!0,Y()}})})}i0();i0();sz();var uH3="@ampcode/cli";async function dF0(A,Q,$=uH3){let D=`${Q||"https://registry.npmjs.org"}/${$}/latest`,J=new AbortController,E=setTimeout(()=>J.abort(),5000);try{let F=await fetch(D,{signal:J.signal});if(!F.ok)return{hasUpdate:!1,currentVersion:A,source:"npm"};let Y=await F.json(),Z=Y.version??Y["dist-tags"]?.latest;if(!Z)return{hasUpdate:!1,currentVersion:A,source:"npm"};let U=Uo(A,Z),X=U<0,G,V;if(Y.time){let z=Y.time[A],K=Y.time[Z],I=Date.now();if(z)G=Math.floor((I-new Date(z).getTime())/3600000);if(K)V=Math.floor((I-new Date(K).getTime())/3600000)}return u.info("NPM version comparison",{currentVersion:A,latestVersion:Z,compareResult:U,hasUpdate:X,currentVersionAge:G,latestVersionAge:V}),{hasUpdate:X,latestVersion:Z,currentVersion:A,currentVersionAge:G,latestVersionAge:V,source:"npm"}}catch(F){return u.debug("Error checking npm version",{error:F}),{hasUpdate:!1,currentVersion:A,source:"npm"}}finally{clearTimeout(E)}}var PH3="https://static.ampcode.com/cli/cli-version.txt";async function pF0(A){let Q=new AbortController,$=setTimeout(()=>Q.abort(),5000);try{let B=await fetch(`${PH3}?t=${Date.now()}`,{signal:Q.signal,cache:"no-store"});if(!B.ok)return{hasUpdate:!1,currentVersion:A,source:"bin"};let D=(await B.text()).trim();if(!D||!/^\d+\.\d+\.\d+/.test(D))return{hasUpdate:!1,currentVersion:A,source:"bin"};let J=Uo(A,D),E=J<0;return u.info("Bin version comparison",{currentVersion:A,latestVersion:D,compareResult:J,hasUpdate:E}),{hasUpdate:E,latestVersion:D,currentVersion:A,source:"bin"}}catch(B){return u.debug("Error checking bin version",{error:B}),{hasUpdate:!1,currentVersion:A,source:"bin"}}finally{clearTimeout($)}}var _H3=604800000;function Ky4(A){if(!A)return null;let Q=typeof A==="number"?A:new Date(A).getTime();if(isNaN(Q))return null;let $=Date.now()-Q;if($>_H3)return{ageMs:$};return null}function Uo(A,Q){let $=(E)=>{let[F,Y]=E.split("-");return{parts:F?.split(".").map(Number)||[],label:Y}},B=$(A),D=$(Q),J=Math.max(B.parts.length,D.parts.length);for(let E=0;E<J;E++){let F=B.parts[E]||0,Y=D.parts[E]||0;if(F<Y)return-1;if(F>Y)return 1}if(B.label===D.label)return 0;if(!B.label&&D.label)return 1;if(B.label&&!D.label)return-1;if(B.label&&D.label)return B.label<D.label?-1:1;return 0}function Xo(A){try{let Q=A.match(/^0\.0\.(\d+)(?:-(.+))?/);if(!Q)return null;let $=parseInt(Q[1],10),B=$!==0?$*1000:void 0,J=Q[2]?.match(/^g?([a-f0-9]+)$/)?.[1],E=B!==void 0?zF(B):void 0;return{sha:J,timestamp:B,age:E}}catch{return null}}u1();i0();import{readFile as TH3,realpath as vH3}from"node:fs/promises";import{dirname as Iy4,join as kH3}from"node:path";async function Wy4(A){switch(A){case"binary":case"brew":return SH3(Yo());case"npm":case"pnpm":case"yarn":case"bun":return fH3()}}async function SH3(A){let Q=await BN(A,["--version"],5000);if(Q.reason!=="success")return u.debug("failed to read version from binary",{binaryPath:A,result:Q}),null;return Q.output.trim().split(/\s+/)[0]||null}async function fH3(){try{let A=process.argv[1];if(!A)return null;let Q=await vH3(A),$=Iy4(Iy4(Q));return await yH3(kH3($,"package.json"))}catch(A){return u.debug("failed to read installed version from package.json",{error:A}),null}}async function yH3(A){let Q=await TH3(A,"utf8"),$=JSON.parse(Q);if(!$.name||!wt0($.name))return u.debug("package.json name mismatch",{pkgJsonPath:A,name:$.name}),null;return $.version||null}i0();import{spawn as xH3}from"node:child_process";function ut0(A){if(A=A.replace(/\/$/,""),!A.startsWith("http://")&&!A.startsWith("https://"))A=`https://${A}`;try{return new URL(A),A}catch{return u.warn(`Invalid registry URL: ${A}, falling back to npmjs.org`),"https://registry.npmjs.org"}}var cF0=null,Go=null;function Hy4(A){return new Promise((Q)=>{let $=xH3("npm",["config","get",A],{stdio:["ignore","pipe","ignore"],timeout:5000,shell:process.platform==="win32"}),B="";$.stdout.on("data",(D)=>{B+=D.toString()}),$.on("close",(D,J)=>{if(D!==0||J==="SIGTERM"){Q(null);return}let E=B.trim();Q(E&&E!=="undefined"?E:null)}),$.on("error",()=>{Q(null)})})}async function lF0(){if(cF0)return cF0;if(Go)return Go;Go=(async()=>{let A=process.env.NPM_CONFIG_REGISTRY??process.env.npm_config_registry;if(A)return ut0(A);let Q=await Hy4("@sourcegraph:registry");if(Q)return ut0(Q);let $=await Hy4("registry");if($)return ut0($);return"https://registry.npmjs.org"})();try{return cF0=await Go,cF0}finally{Go=null}}var bH3=3600000,hH3=5000;function iF0(A,Q,$={}){let B=new p4,D=B.pipe(s6({shouldCountRefs:!1})),J=$.startDelayMs??0,E=$.checkIntervalMs??bH3,F=!1,Y=()=>{F=!0};return setImmediate(async()=>{let Z=u.getChild("update");if(J>0){if(await pX(J),F)return}let U=D.subscribe({next:(G)=>{Z.debug("emit new state",G)}}),X=A;try{while(!F){let G=await gH3(X,Q,Z,B);if(G.stop)return;if(G.updatedTo)X=G.updatedTo;if(G.emittedVisibleState){if(await pX(hH3),F)return;B.next("hidden")}if(E<=0)return;let V=1000,z=E;while(z>0&&!F){let K=Math.min(V,z);await pX(K),z-=K}}}finally{U.unsubscribe(),B.complete()}}),{state:D,dispose:Y}}async function gH3(A,Q,$,B){let D={stop:!1,emittedVisibleState:!1};try{if(process.env.AMP_SKIP_UPDATE_CHECK==="1")return $.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable"),D.stop=!0,D;let J=await Q.get("updates.mode");if(J==="disabled")return $.debug("checking disabled"),D.stop=!0,D;let E=await IG(),F=E==="binary"||E==="brew",Y=F?void 0:await DN();$.debug("checking",{currentVersion:A,mode:J,packageManager:E,isBinaryDistribution:F,npmPackageName:Y});let Z;if(F)Z=await pF0(A);else{let G=await lF0();Z=await dF0(A,G,Y)}if(!(Z.latestVersion&&Z.hasUpdate))return $.debug("no update available"),D;let U=(G)=>{B.next(G),D.emittedVisibleState=!0};if(E){let G=await Wy4(E);if(G&&Uo(G,Z.latestVersion)>=0){if($.debug("on-disk version already up to date",{currentVersion:A,installedVersion:G,latestVersion:Z.latestVersion}),D.updatedTo=G,Uo(A,G)<0){let V=await LK(G),z={from:A,to:G,externallyUpdated:!0,...V};if(V.status==="same")$.info("on-disk already updated by another instance",z),U("updated");else $.warn("on-disk already updated by another instance, with PATH warning",z),U("updated-with-warning")}return D}}let X=()=>{if(Z.currentVersionAge!==void 0&&Z.latestVersionAge!==void 0){let G=Z.currentVersionAge-Z.latestVersionAge,V=0.5;if(Math.abs(G)<0.5)return $.debug("versions too close together, suppressing update warning",{currentVersionAge:Z.currentVersionAge,latestVersionAge:Z.latestVersionAge,ageDifferenceHours:G}),!0}return!1};if(!J)J=E==="pnpm"?"warn":"auto",$.debug("no configured update mode; selected default based on package manager",{packageManager:E,mode:J});if(E==="brew"){if(!X())U("update-available-brew");return D}if(E==="binary"&&process.execPath!==Yo()){if($.debug("non-standard binary path, showing warning"),!X())U("update-available-unrecognized-path");return D}if(J==="warn"){if(!X())U("update-available");return D}if(!E){if($.debug("auto-update not supported, falling back to warn mode"),!X())U("update-available");return D}try{await Zo(Z.latestVersion,E),D.updatedTo=Z.latestVersion;let G=await LK(Z.latestVersion),V={from:Z.currentVersion,to:Z.latestVersion,...G};if(G.status==="same")$.info("success",V),U("updated");else $.warn("success with warning",V),U("updated-with-warning")}catch(G){U("update-error")}return D}catch(J){return $.debug("check failed",{error:J}),D}}sz();import{stderr as kF}from"node:process";function qy4(A){let Q=new bq().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(B)=>{await qt0(B.force||!1,B.verbose||!1,"0.0.1779190035-gd08a72"),process.exit()});A.addCommand(Q,{hidden:!0});let $=new bq("update").alias("up").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(B)=>{await pH3(B.targetVersion)});A.addCommand($)}function mH3(A){let Q=Boolean(A.isTTY),$=0,B=!1;function D(){if(!Q||!B)return;A.write(`
|
|
4795
4795
|
`),B=!1,$=0}function J(E){if(!Q)return;let F=E.padEnd($," ");A.write(`\r${F}`),B=!0,$=F.length}return{flushProgressLine:D,renderProgress:J}}function dH3(A){if(A.source==="npm"&&A.latestVersionAge!==void 0&&A.latestVersionAge>36)kF.write(t0.yellow(`The latest Amp CLI version reported by npm is older than expected. Be aware that you may be using an npm proxy with a corporate policy to delay package updates.
|
|
4796
4796
|
`))}async function pH3(A){let $=process.platform==="win32"&&Gj()?{currentExecutablePath:process.execPath}:void 0,{flushProgressLine:B,renderProgress:D}=mH3(kF);if(process.env.AMP_SKIP_UPDATE_CHECK==="1")kF.write(t0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
|
|
4797
4797
|
|
|
4798
4798
|
`));try{if(!A){kF.write(t0.blue(`Checking for updates...
|
|
4799
|
-
`));let F=!1,Y;if(Gj()){let Z=await pF0("0.0.
|
|
4800
|
-
`));let X=await LK("0.0.
|
|
4799
|
+
`));let F=!1,Y;if(Gj()){let Z=await pF0("0.0.1779190035-gd08a72");F=Z.hasUpdate,Y=Z.latestVersion}else{let Z=await lF0(),U=await DN(),X=await dF0("0.0.1779190035-gd08a72",Z,U);dH3(X),F=X.hasUpdate,Y=X.latestVersion}if(!F){let Z=Xo("0.0.1779190035-gd08a72"),U=Z?.age?`released ${Z.age} ago`:`built ${zF(new Date("2026-05-19T11:32:14.941Z"))} ago`;kF.write(t0.green(`✓ Amp is already up to date on version ${"0.0.1779190035-gd08a72"} (${U})
|
|
4800
|
+
`));let X=await LK("0.0.1779190035-gd08a72",$);if(X.warning)kF.write(`
|
|
4801
4801
|
`+t0.yellow(X.warning)+`
|
|
4802
4802
|
`);process.exit(0)}if(!Y)kF.write(t0.yellow("[WARN] could not find latest version")),process.exit(0);A=Y}kF.write(t0.blue(`Updating to version ${A}...
|
|
4803
4803
|
`)),await Zo(A,void 0,(F)=>{B(),kF.write(t0.dim(`Running: ${F}
|
|
@@ -5223,7 +5223,7 @@ ${B}`).join(`
|
|
|
5223
5223
|
`).length,D=new d({text:new C(A,new T({color:$}))});if(B<=IU0)return D;return new X0({width:1/0,height:IU0,child:new g8({autofocus:!1,controller:Q,child:D})})}function AS3(){return new Map([[G1.key("PageUp"),new WU0],[G1.key("PageDown"),new W41],[G1.ctrl("u"),new WU0],[G1.shift("Home"),new H41],[G1.shift("End"),new q41]])}function QS3(A,Q,$){return Math.max(Q,Math.min(A,$))}var N41=8,Ui4=1,Xi4=N41-1;class w41 extends X4{}class C41 extends X4{}class HU0 extends X4{}class qU0 extends X4{}class M41 extends X4{}class L41 extends X4{}class O41 extends u0{props;constructor(A){super(A.key===void 0?{}:{key:A.key});this.props=A}createState(){return new Gi4}}class Gi4 extends R0{messageScroll=new S6;initState(){super.initState(),this.messageScroll.followMode=!1,this.messageScroll.jumpTo(0)}dispose(){this.messageScroll.dispose(),super.dispose()}build(A){let Q=this.widget.props,$=$S3(Q,this.messageScroll),B=BS3(Q.options.message),D=B?new y4({actions:this.buildScrollActions(),child:new TA({debugLabel:"NeoSelectDialogScrollShortcuts",shortcuts:JS3(),child:$})}):$,J=[{keys:["↑/↓","j/k"],label:"move"},{keys:["Enter"],label:"select"}];if(B)J.push({keys:["Ctrl+E","Ctrl+Y"],label:"scroll"});return J.push({keys:["Esc"],label:"cancel"}),new w6({header:Q.options.title,minWidth:64,maxWidth:80,footer:J,autofocus:!1,onDismiss:Q.onCancel,child:D})}buildScrollActions(){let A=(Q)=>{let $=ES3(this.messageScroll.offset+Q,0,this.messageScroll.maxScrollExtent);this.messageScroll.jumpTo($)};return new Map([[w41,new T1(()=>A(-Ui4))],[C41,new T1(()=>A(Ui4))],[HU0,new T1(()=>A(-Xi4))],[qU0,new T1(()=>A(Xi4))],[M41,new T1(()=>this.messageScroll.jumpTo(0))],[L41,new T1(()=>this.messageScroll.jumpTo(this.messageScroll.maxScrollExtent))]])}}function $S3(A,Q){let $=A.options.options.map((D)=>({value:D,label:D})),B=Math.max(0,$.findIndex((D)=>D.value===A.options.initialValue));return new U8({options:$,selectedIndex:B,body:DS3(A.options.message,Q),onSelect:(D)=>{if(D===null){A.onCancel();return}A.onSelect(D)},padding:V0.all(0),showBorder:!1,showDismissalMessage:!1,enableMouseInteraction:!1})}function BS3(A){if(A===void 0)return!1;return A.split(`
|
|
5224
5224
|
`).length>N41}function DS3(A,Q){if(A===void 0)return;let $=A.split(`
|
|
5225
5225
|
`).length,B=Math.min($,N41);return new X0({width:1/0,height:B,child:new g8({autofocus:!1,controller:Q,child:new d({text:new C(A)})})})}function JS3(){return new Map([[G1.key("PageUp"),new HU0],[G1.key("PageDown"),new qU0],[G1.ctrl("u"),new HU0],[G1.ctrl("d"),new qU0],[G1.ctrl("y"),new w41],[G1.ctrl("e"),new C41],[G1.shift("Home"),new M41],[G1.shift("End"),new L41]])}function ES3(A,Q,$){return Math.max(Q,Math.min(A,$))}var FS3=3,YS3=new R6("NeoPluginDialogOverlay");class j41{options;unregisterPluginCommands=null;pluginCommandSubscriptions=[];pluginErrorToastKeys=new Set;activeDialog=null;queuedDialogs=[];resolvingDialog=null;statusItems=new Map;disposed=!1;constructor(A){this.options=A}init(){this.disposed=!1,this.configurePluginPlatform(),this.subscribePluginCommands()}dispose(){this.disposed=!0,this.unregisterPluginCommands?.(),this.unregisterPluginCommands=null;for(let A of this.pluginCommandSubscriptions)A.unsubscribe();this.pluginCommandSubscriptions=[],this.cancelPendingDialogs(),this.statusItems.clear(),this.clearPluginPlatformStatusHandlers()}hasBlockingDialog(){return this.activeDialog!==null}buildDialogLayers(){let A=this.activeDialog;if(!A)return[];return[new h4({key:YS3,debugLabel:"PluginDialogOverlay",autofocus:!1,canRequestFocus:!0,child:this.buildActiveDialog(A)})]}buildActiveDialog(A){switch(A.kind){case"input":return new Bs({key:new RK(A),header:A.options.title??"Input",helpText:A.options.helpText,initialValue:A.options.initialValue,isRequired:!1,onSubmit:(Q)=>this.resolveInputDialog(A,Q),onDismiss:()=>this.resolveInputDialog(A,void 0)});case"confirm":return new I41({key:new RK(A),options:A.options,onConfirm:()=>this.resolveConfirmDialog(A,!0),onCancel:()=>this.resolveConfirmDialog(A,!1)});case"select":return new O41({key:new RK(A),options:A.options,onSelect:(Q)=>this.resolveSelectDialog(A,Q),onCancel:()=>this.resolveSelectDialog(A,void 0)})}}getStatusItems(){return[...this.statusItems.values()].flatMap((A)=>A.value===void 0?[]:[{pluginURI:A.pluginURI,id:A.id,value:A.value}])}configurePluginPlatform(){let A=this.options.neoContext.pluginPlatform;if(!A)return;A.showToast=(Q)=>this.options.toastController.show(Q,"success"),A.showOpenedURLToast=(Q)=>{this.options.toastController.show(`Opened URL: ${Q}`,"success",8000)},A.appendToThreadHandler=this.options.neoContext.observerOnly?async()=>{throw Error("thread.append is only available from an executor-owned plugin runtime")}:this.options.appendToThread,A.showInputDialog=this.showInputDialog,A.showConfirmDialog=this.showConfirmDialog,A.showSelectDialog=this.showSelectDialog,A.createStatusItemHandler=this.createStatusItem,A.updateStatusItemHandler=this.updateStatusItem,A.removeStatusItemHandler=this.removeStatusItem}clearPluginPlatformStatusHandlers(){let A=this.options.neoContext.pluginPlatform;if(!A)return;if(A.createStatusItemHandler===this.createStatusItem)A.createStatusItemHandler=null;if(A.updateStatusItemHandler===this.updateStatusItem)A.updateStatusItemHandler=null;if(A.removeStatusItemHandler===this.removeStatusItem)A.removeStatusItemHandler=null}subscribePluginCommands(){let A=this.options.neoContext.pluginService;if(!A)return;this.refreshPluginCommands(A.commands.list()),this.pluginCommandSubscriptions=[A.plugins.subscribe((Q)=>{this.removeInactivePluginStatusItems(Q),this.showNewPluginErrorToasts(Q),this.refreshPluginCommands(A.commands.list())}),A.commands.changed.subscribe(()=>{this.refreshPluginCommands(A.commands.list())})]}refreshPluginCommands(A){this.unregisterPluginCommands?.();let $=A.map((B)=>this.createPluginCommand(B)).map((B)=>this.options.commandRegistry.register(B));this.unregisterPluginCommands=()=>{for(let B of $)B()}}showNewPluginErrorToasts(A){let Q=new Set;for(let $ of A){if($.status!=="error")continue;if(hp($.errorMessage))continue;let B=`${$.uri.toString()}
|
|
5226
|
-
${$.errorMessage??""}`;if(Q.add(B),this.pluginErrorToastKeys.has(B))continue;this.options.toastController.show(this.formatPluginErrorToast($),"error",8000)}this.pluginErrorToastKeys=Q}removeInactivePluginStatusItems(A){let Q=new Set(A.filter((B)=>B.status==="active").map((B)=>B.uri.toString())),$=[];for(let[B,D]of this.statusItems){if(Q.has(D.pluginURI))continue;$.push(B)}if($.length===0)return;this.updateStatusItemState(()=>{for(let B of $)this.statusItems.delete(B)})}formatPluginErrorToast(A){let Q=A.uri.toString();return`Plugin failed: ${Q.split("/").pop()??Q}. See logs: ${this.options.neoContext.logFilePath}`}createPluginCommand(A){return{id:A.id,noun:A.category,verb:A.title,description:A.description??`Run plugin command ${A.category}: ${A.title}`,keywords:["plugin",A.pluginName,A.id],status:A.availability,run:async(Q,$,B)=>{B();try{await this.options.neoContext.pluginService?.commands.execute(A.pluginName,A.id,{threadID:this.options.getActiveThreadID()})}catch(D){u.error("Neo plugin command failed",{error:D,command:A}),this.options.toastController.show(D instanceof Error?D.message:String(D),"error",5000)}}}}showInputDialog=(A)=>{return new Promise((Q)=>{if(this.disposed||!this.options.state.mounted){Q(void 0);return}this.enqueueDialog({kind:"input",options:A,resolve:Q})})};showConfirmDialog=(A)=>{return new Promise((Q)=>{if(this.disposed||!this.options.state.mounted){Q(!1);return}this.enqueueDialog({kind:"confirm",options:A,resolve:Q})})};showSelectDialog=(A)=>{return new Promise((Q)=>{if(this.disposed||!this.options.state.mounted){Q(void 0);return}this.enqueueDialog({kind:"select",options:A,resolve:Q})})};createStatusItem=(A,Q,$)=>{if(this.disposed)return;this.updateStatusItemState(()=>{let B=this.statusItemKey(A,Q),D={pluginURI:A,id:Q};if($!==void 0)D.value=$;this.statusItems.set(B,D)})};updateStatusItem=(A,Q,$)=>{if(this.disposed)return;this.updateStatusItemState(()=>{this.statusItems.set(this.statusItemKey(A,Q),{pluginURI:A,id:Q,value:$})})};removeStatusItem=(A,Q)=>{if(this.disposed)return;this.updateStatusItemState(()=>{this.statusItems.delete(this.statusItemKey(A,Q))})};updateStatusItemState(A){if(this.options.state.mounted)this.options.state.setState(A);else A()}statusItemKey(A,Q){return`${A}\x00${Q}`}cancelPendingDialogs(){let A=[];if(this.activeDialog)A.push(this.activeDialog);A.push(...this.queuedDialogs),this.activeDialog=null,this.queuedDialogs=[],this.resolvingDialog=null;for(let Q of A)this.cancelDialog(Q)}cancelDialog(A){switch(A.kind){case"input":A.resolve(void 0);return;case"confirm":A.resolve(!1);return;case"select":A.resolve(void 0);return}}enqueueDialog(A){if(this.activeDialog){if(this.queuedDialogs.push(A),this.resolvingDialog===this.activeDialog)this.advanceResolvingDialog(this.activeDialog);return}this.options.commandPalette.disable(),this.options.state.setState(()=>{this.activeDialog=A})}resolveInputDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveConfirmDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveSelectDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveDialog(A,Q){if(this.activeDialog!==A||this.resolvingDialog===A)return;this.resolvingDialog=A,Q(),this.scheduleResolvingDialogAdvance(A,FS3)}scheduleResolvingDialogAdvance(A,Q){h6.instance.addPostFrameCallback(()=>{if(this.activeDialog!==A)return;if(this.queuedDialogs.length>0||Q<=1){this.advanceResolvingDialog(A);return}this.scheduleResolvingDialogAdvance(A,Q-1)},"NeoPluginIntegration.advanceDialog")}advanceResolvingDialog(A){if(this.resolvingDialog===A)this.resolvingDialog=null;if(this.activeDialog!==A)return;this.advanceDialog()}advanceDialog(){this.updateDialogState(()=>{this.activeDialog=this.queuedDialogs.shift()??null})}updateDialogState(A){if(this.options.state.mounted)this.options.state.setState(A);else A()}}var ZS3=48;class R41{visible=!1;onClick=void 0;listeners=new Set;show(A){this.visible=!0,this.onClick=A,this.notifyListeners()}activate(){this.onClick?.()}get isVisible(){return this.visible}dismiss(){this.visible=!1,this.onClick=void 0,this.notifyListeners()}addListener(A){this.listeners.add(A)}removeListener(A){this.listeners.delete(A)}buildComplexToast(){if(!this.visible||!this.onClick)return null;return new er({width:ZS3,title:"Relaunch to Update Amp",message:"Your threads will resume.",variant:"success",mouseBehavior:"click-anywhere",action:{keyboardShortcut:"Ctrl+O",command:"amp: relaunch",confirmShortcut:"Enter",label:"relaunch",onAction:()=>this.activate()}})}notifyListeners(){for(let A of this.listeners)A()}}i0();import{spawnSync as US3}from"node:child_process";import gK from"node:process";var Vi4={options:new Set(["settings-file","log-level","log-file","mcp-config"]),booleans:new Set(["color","dangerously-allow-all","ide","jetbrains","neo-orb","notifications"])};function Ds(A){let Q=A.getRelaunchThreadIDs();if(A.onRelaunchRequested?.(Q),A.stop)A.stop();else H4.instance.stop()}function zi4(A){return{noun:"amp",verb:"Relaunch (Quit, then Reopen & Resume Thread)",description:"Quit, reopen Amp, and resume active threads",keywords:["restart","update","resume","reopen"],shortcut:gK.env.NODE_ENV==="development"&&gK.platform==="darwin"?G1.meta("r"):void 0,status:{type:"enabled"},sortBoost:90,run:(Q,$,B)=>{B(),Ds(A)}}}function XS3(A,Q){u.info("Relaunching Amp; threads will be resumed",{threadIDs:A});let{command:$,args:B}=GS3(A),D=US3($,B,{cwd:Q,env:gK.env,stdio:"inherit"});if(D.error)return u.error("Failed to relaunch Amp",{error:D.error}),1;return D.status??1}class u41{relaunchRequested=!1;requestedThreadIDs=[];request=(A)=>{u.info("Relaunch requested; threads will be resumed",{threadIDs:A}),this.relaunchRequested=!0,this.requestedThreadIDs=A};get shouldShowExitSummary(){return!this.relaunchRequested}relaunchIfRequested(A){if(!this.relaunchRequested)return;return XS3(this.requestedThreadIDs,A)}}function GS3(A){let Q=A.length>0?["threads","continue",...A]:[],$=VS3(gK.argv),B=KS3();if(B)return{command:B.command,args:[...B.args,...$,...Q]};let D=gK.argv[1],J=D&&zS3(D)?[D]:[];return{command:gK.execPath,args:[...J,...$,...Q]}}function VS3(A){let Q=[],$=A.slice(2);for(let B=0;B<$.length;B+=1){let D=$[B];if(!D?.startsWith("--"))continue;let[J,E]=D.split("=",2);if(!J)continue;let F=J.slice(2),Y=F.startsWith("no-")?F.slice(3):F;if(Vi4.booleans.has(Y)){Q.push(D);continue}if(!Vi4.options.has(F))continue;if(E!==void 0){Q.push(D);continue}let Z=$[B+1];if(Z===void 0||Z.startsWith("--"))continue;Q.push(D,Z),B+=1}return Q}function zS3(A){return A!==gK.execPath&&!A.startsWith("/$bunfs/")}function KS3(){if(gK.env.NODE_ENV!=="development")return null;let A=gK.env.AMP_DEV_RELAUNCH_COMMAND?.trim();if(!A)return null;let Q=IS3(A),$=Q[0];if(!$)return null;return{command:$,args:Q.slice(1)}}function IS3(A){if(A.startsWith("["))try{let Q=JSON.parse(A);if(Array.isArray(Q)&&Q.every(($)=>typeof $==="string"))return Q}catch{return[]}return A.split(/\s+/).filter(Boolean)}var WS3=18000000;class P41{options;subscription=null;relaunchNotificationShown=!1;relaunchNotificationPending=!1;relaunchNotificationTimer=null;openedAt=Date.now();constructor(A){this.options=A}init(){if(this.subscription=this.options.updateService?.state.subscribe((A)=>{this.handleUpdateState(A)})??null,process.env.DEV_SHOW_RELAUNCH_NOTIF_ON_STARTUP==="1")this.showUpdateRelaunchNotification(!0)}dispose(){if(this.subscription?.unsubscribe(),this.subscription=null,this.relaunchNotificationTimer)clearTimeout(this.relaunchNotificationTimer),this.relaunchNotificationTimer=null}handleUpdateState(A){if(A!=="updated")return;this.showUpdateRelaunchNotification()}showUpdateRelaunchNotification(A=!1){if(this.relaunchNotificationShown)return;let $=(this.options.minimumOpenDurationMs??WS3)-(Date.now()-this.openedAt);if($>0&&!A){if(this.relaunchNotificationPending=!0,!this.relaunchNotificationTimer)this.relaunchNotificationTimer=setTimeout(()=>{if(this.relaunchNotificationTimer=null,!this.relaunchNotificationPending)return;this.relaunchNotificationPending=!1,this.showUpdateRelaunchNotification()},$),this.relaunchNotificationTimer.unref();return}this.relaunchNotificationPending=!1,this.relaunchNotificationShown=!0,this.options.relaunchNotificationController.show(()=>Ds(this.options))}}Gl();r2();import{readFile as HS3}from"node:fs/promises";import _41 from"node:os";function qS3(A=new Date){return A.toISOString().replaceAll("-","").replaceAll(":","").slice(0,15)+"Z"}async function Ki4(A,Q){try{return{path:Q,contents:hh0(await HS3(A,"utf8"))}}catch{return null}}async function NU0(A,Q){let $=[],B=qS3(),D=await r4.getThread({thread:Q},{config:A.configService}),J=D.ok?D.result.thread.data:null;$.push({path:`${B}/thread.json`,contents:JSON.stringify($D(J),null,2)});let E=await Ki4(xS(Q),`${B}/logs/${Q}.log`);if(E)$.push(E);let F=await Ki4(A.settingsFilePath,`${B}/settings/global.json`);if(F)$.push(F);let Y=await IG()??"unknown",Z=await r4.sendReport({threadID:Q,files:$,metadata:{clientVersion:"0.0.1779179243-g4e6089",clientOS:`${_41.platform()} ${_41.release()} ${_41.arch()}`,installMethod:Y}},{config:A.configService});if(!Z.ok)throw Error(`Failed to submit report: ${Z.error.message}`);return Z.result.reportID}class T41{backStack=[];forwardStack=[];canNavigateBack(){return this.backStack.length>0}canNavigateForward(){return this.forwardStack.length>0}recordNavigation(A){if(!A)return;this.backStack.push(A),this.forwardStack.length=0}startBackNavigation(A){let Q=this.backStack.pop();if(!Q)return null;let $=Boolean(A);if(A)this.forwardStack.push(A);return{targetThreadID:Q,rollback:()=>{if($)this.forwardStack.pop();this.backStack.push(Q)}}}startForwardNavigation(A){let Q=this.forwardStack.pop();if(!Q)return null;let $=Boolean(A);if(A)this.backStack.push(A);return{targetThreadID:Q,rollback:()=>{if($)this.backStack.pop();this.forwardStack.push(Q)}}}}class wU0 extends C3{offstage;constructor({key:A,offstage:Q=!0,child:$}){super({key:A,child:$});this.offstage=Q}createRenderObject(){return new v41(this.offstage)}updateRenderObject(A){if(A instanceof v41)A.offstage=this.offstage}}class v41 extends t1{_offstage;constructor(A){super();this._offstage=A}get offstage(){return this._offstage}set offstage(A){if(A===this._offstage)return;this._offstage=A,this.markNeedsLayout()}getMinIntrinsicWidth(A){if(this._offstage)return 0;return this.children[0]?.getMinIntrinsicWidth(A)??0}getMaxIntrinsicWidth(A){if(this._offstage)return 0;return this.children[0]?.getMaxIntrinsicWidth(A)??0}getMinIntrinsicHeight(A){if(this._offstage)return 0;return this.children[0]?.getMinIntrinsicHeight(A)??0}getMaxIntrinsicHeight(A){if(this._offstage)return 0;return this.children[0]?.getMaxIntrinsicHeight(A)??0}performLayout(){let A=this._lastConstraints;N4(!!A,"performLayout called without constraints");let Q=this.children[0];if(this._offstage){if(this.setSize(0,0),Q)Q.layout(A),Q.setOffset(0,0)}else if(Q){Q.layout(A);let $=A.constrain(Q.size.width,Q.size.height);this.setSize($.width,$.height),Q.setOffset(0,0)}else{let $=A.smallest;this.setSize($.width,$.height)}super.performLayout()}paint(A,Q,$){if(this._offstage)return;super.paint(A,Q,$)}hitTest(A,Q,$,B){if(this._offstage)return!1;return super.hitTest(A,Q,$,B)}}class Js{_state=null;_attach(A){this._state=A}_detach(){this._state=null}push(A){this._state?.push(A)}pushWithDismiss(A){this._state?.pushWithDismiss(A)}pop(){return this._state?.pop()??!1}get canPop(){return this._state?.canPop??!1}}class k41 extends u0{root;controller;constructor(A){super();this.root=A.root,this.controller=A.controller}createState(){return new Ii4}}class Ii4 extends R0{entries=[];initState(){this.widget.controller._attach(this)}didUpdateWidget(A){if(A.controller!==this.widget.controller)A.controller._detach(),this.widget.controller._attach(this)}dispose(){this.widget.controller._detach(),super.dispose()}push(A){let Q=new Hj,$=this.makeScopedDismiss(Q);this.setState(()=>{this.entries.push({key:Q,widget:A,dismiss:$})})}pushWithDismiss(A){let Q=new Hj,$=this.makeScopedDismiss(Q),B=A($);this.setState(()=>{this.entries.push({key:Q,widget:B,dismiss:$})})}pop(){if(this.entries.length===0)return!1;return this.setState(()=>{this.entries.pop()}),!0}get canPop(){return this.entries.length>0}makeScopedDismiss(A){return()=>{if(!this.mounted)return;let Q=this.entries[this.entries.length-1];if(!Q||Q.key!==A)return;this.setState(()=>{this.entries.pop()})}}build(A){let Q=[];Q.push(new wU0({offstage:this.entries.length>0,child:this.widget.root}));for(let $=0;$<this.entries.length;$++){let B=this.entries[$],D=$===this.entries.length-1,J=D?new h4({autofocus:!0,debugLabel:`ModalStackEntry[${$}]`,onKey:(E)=>{if(E.key!=="Escape")return"ignored";return B.dismiss(),"handled"},child:B.widget}):B.widget;Q.push(new wU0({key:B.key,offstage:!D,child:J}))}return new t4({fit:"expand",children:Q})}}import Wi4 from"node:process";class f41 extends q1{props;constructor(A){super();this.props=A}build(A){let Q=this.props.commands.filter((B)=>B.status.type!=="hidden"),$=NS3(Q);return new w6({header:"Command Palette",autofocus:!1,barrierOpaque:!1,chromePadding:V0.only({left:1,top:1,right:1}),footer:"none",onDismiss:this.props.onDismiss,child:new pA({items:Q,showBorder:!1,getLabel:(B)=>{let D=S41(B);return B.keywords&&B.keywords.length>0?`${D} ${B.keywords.join(" ").toLowerCase()}`:D},sortItems:(B,D,J)=>{if(J===""){let U=B.item.status.type==="disabled"?1:0,X=D.item.status.type==="disabled"?1:0;if(U!==X)return U-X;let G=B.item.sortBoost??0,V=D.item.sortBoost??0;if(G!==V)return V-G;let z=B.item.noun?.toLowerCase()??"",K=D.item.noun?.toLowerCase()??"";if(z!==K)return z<K?-1:1;return 0}let E=bj(B.item.verb.toLowerCase(),J),F=bj(D.item.verb.toLowerCase(),J);if(E!==F)return F-E;let Y=bj(S41(B.item),J),Z=bj(S41(D.item),J);if(Y!==Z)return Z-Y;return D.score-B.score},isItemDisabled:(B)=>B.status.type==="disabled",buildDisabledReasonWidget:(B,D)=>{if(B.status.type!=="disabled")return;let{colors:J}=O0.of(D);return new d({text:new C(B.status.reason,new T({color:J.mutedForeground,dim:!0})),textAlign:"center"})},renderItem:(B,D,J,E)=>new Hi4({command:B,isSelected:D,isDisabled:J,categoryWidth:$,buildContext:E}),onAccept:(B)=>{this.props.onAccept(B)},onDismiss:this.props.onDismiss})})}}class Hi4 extends q1{props;constructor(A){super();this.props=A}build(A){let{command:Q,isSelected:$,isDisabled:B,categoryWidth:D,buildContext:J}=this.props,E=O0.of(J),{colors:F,app:Y}=E,Z=$?Y.selectionBackground:void 0,U=$?Y.selectionForeground:F.foreground,X=$?U:F.mutedForeground,G=new d({text:new C(Q.noun?.toLowerCase()??"",new T({color:X,dim:B||!$})),textAlign:"right"}),V=[new C(Q.verb.toLowerCase(),new T({color:U,bold:!0,dim:B}))];if(B)V.push(new C(" (unavailable)",new T({color:U,dim:!0})));let z=d.spans(V),K=[{child:G,fixedWidth:D},{child:z,expanded:!0}];if(Q.shortcut)K.push({child:wS3(Q.shortcut,E,B)});return new qi4({columns:K,padding:V0.horizontal(1),backgroundColor:Z})}}function S41(A){return A.noun?`${A.noun.toLowerCase()} ${A.verb.toLowerCase()}`:A.verb.toLowerCase()}function NS3(A){return A.reduce((Q,$)=>{return $.noun?Math.max(Q,L4($.noun)):Q},0)}function wS3(A,Q,$){let{colors:B,app:D}=Q,J=new T({color:B.mutedForeground,dim:$}),E=[];for(let F of A.modifiers()){if(E.length>0)E.push(new C(" ",J));E.push(new C(CS3(F),new T({color:D.keybind,bold:!0,dim:$})))}if(E.length>0)E.push(new C(" ",J));return E.push(new C(MS3(A),new T({color:D.keybind,bold:!0,dim:$}))),d.spans(E)}function CS3(A){return A==="Meta"&&Wi4.platform==="darwin"?"Cmd":A}function MS3(A){return A.meta&&Wi4.platform==="darwin"?A.key.toUpperCase():A.key}class qi4 extends q1{props;constructor(A){super();this.props=A}build(A){let{columns:Q,gap:$=2,padding:B,backgroundColor:D}=this.props,J=[];for(let F=0;F<Q.length;F++){let Y=Q[F];if(F>0&&$>0)J.push(new X0({width:$}));if(Y.fixedWidth!==void 0)J.push(new X0({width:Y.fixedWidth,child:Y.child}));else if(Y.expanded)J.push(new R1({child:Y.child}));else J.push(Y.child)}let E=new r0({crossAxisAlignment:"start",children:J});if(!B&&!D)return E;return new b0({decoration:D?{color:D}:void 0,padding:B,child:E})}}class y41{#A=[];#Q=new Set;get commands(){return this.#A}register(A){return this.#A.push(A),this.#$(),()=>{let Q=this.#A.indexOf(A);if(Q===-1)return;this.#A.splice(Q,1),this.#$()}}findByID(A){return this.#A.find((Q)=>Q.id===A)}runByID(A,Q){let $=this.findByID(A);if(!$||$.status.type!=="enabled")return!1;return $.run(new Js,Q,()=>{}),!0}addListener(A){this.#Q.add(A)}removeListener(A){this.#Q.delete(A)}#$(){for(let A of this.#Q)A()}}class W9 extends GA{commandRegistry;constructor({commandRegistry:A,child:Q}){super({child:Q});this.commandRegistry=A}updateShouldNotify(A){return!1}static of(A){let Q=W9.maybeOf(A);if(!Q)throw Error("No NeoCommandRegistryProvider found in widget tree");return Q}static maybeOf(A){return A.dependOnInheritedWidgetOfExactType(W9)?.commandRegistry??null}}class x41 extends u0{onDismiss;constructor(A){super();this.onDismiss=A.onDismiss}createState(){return new Ni4}}class Ni4 extends R0{modalStack=new Js;commandRegistry=null;initState(){super.initState(),queueMicrotask(()=>{if(!this.mounted)return;let A=W9.of(this.context);this.commandRegistry=A,A.addListener(this.onCommandsChanged)})}dispose(){this.commandRegistry?.removeListener(this.onCommandsChanged),this.commandRegistry=null,super.dispose()}onCommandsChanged=()=>{this.setState()};build(A){let Q=W9.of(A).commands,$=new f41({commands:Q,onAccept:(B)=>{B.run(this.modalStack,A,this.widget.onDismiss)},onDismiss:()=>{if(this.modalStack.canPop)this.modalStack.pop();else this.widget.onDismiss()}});return new k41({root:$,controller:this.modalStack})}}var b41=[{description:"Move cursor up/down",methods:[{keys:["↑"]},{keys:["↓"]}]},{description:"Move cursor left/right",methods:[{keys:["←"]},{keys:["→"]},{input:"B",keys:["Ctrl"]},{input:"F",keys:["Ctrl"]}]},{description:"Insert newline",methods:[{keys:["Shift","Enter"]},{keys:["Alt","Enter"]},{input:"J",keys:["Ctrl"]}],submitOnEnterOnly:!0},{description:"Insert newline",methods:[{keys:["Enter"]},{keys:["Shift","Enter"]},{keys:["Alt","Enter"]},{input:"J",keys:["Ctrl"]}],submitOnEnterOnly:!1},{description:"Submit message",methods:[{keys:["Enter"]}],submitOnEnterOnly:!0},{description:"Submit message",methods:[{keys:["Ctrl/Cmd","Enter"]}],submitOnEnterOnly:!1},{description:"Clear input",methods:[{keys:["Escape"]}]},{description:"Edit prompt in $EDITOR",methods:[{input:"G",keys:["Ctrl"]}]},{description:"Navigate history (previous/next)",methods:[{input:"P",keys:["Ctrl"]},{input:"N",keys:["Ctrl"]}]},{description:"Jump to start of line",methods:[{keys:["Cmd","←"]},{input:"A",keys:["Ctrl"]}]},{description:"Jump to end of line",methods:[{keys:["Cmd","→"]},{input:"E",keys:["Ctrl"]}]},{description:"Jump to previous word",methods:[{keys:["Alt","←"]},{keys:["Ctrl","←"]},{input:"B",keys:["Alt"]}]},{description:"Jump to next word",methods:[{keys:["Alt","→"]},{keys:["Ctrl","→"]},{input:"F",keys:["Alt"]}]},{description:"Delete character backward",methods:[{keys:["Backspace"]},{input:"H",keys:["Ctrl"]}]},{description:"Delete word backward",methods:[{keys:["Alt","Backspace"]},{input:"W",keys:["Ctrl"]}]},{description:"Delete character forward",methods:[{keys:["Delete"]},{input:"D",keys:["Ctrl"]}]},{description:"Delete to start of line",methods:[{keys:["Cmd","Backspace"]},{input:"U",keys:["Ctrl"]}]},{description:"Delete to end of line",methods:[{input:"K",keys:["Ctrl"]}]},{description:"Yank (paste deleted text)",methods:[{input:"Y",keys:["Ctrl"]}]},{description:"Paste image from clipboard",methods:[{input:"V",keys:["Ctrl"]}]},{description:"Switch agent mode",methods:[{input:"S",keys:["Ctrl"]}]},{description:"Toggle reasoning effort",methods:[{input:"D",keys:["Alt"]}]},{description:"Open command palette",methods:[{input:"O",keys:["Ctrl"]}]},{description:"Mention files",methods:[{keys:["@"]}]},{description:"Mention threads",methods:[{keys:["@@"]}]},{description:"Show prompt history",methods:[{input:"R",keys:["Ctrl"]}]},{description:"Toggle inline shortcuts help",methods:[{keys:["?"]}]},{description:"Toggle thinking/dense view",methods:[{input:"T",keys:["Alt"]}]}],h41=[{description:"Page scroll",methods:[{keys:["Pg Up"]},{keys:["Pg Down"]}]},{description:"Half-page scroll",methods:[{input:"K",keys:["Alt"]},{input:"J",keys:["Alt"]}]},{description:"Mouse wheel scroll",methods:[{keys:["Mouse Wheel"]}]},{description:"Jump to first message",methods:[{keys:["Home"]}]},{description:"Jump to bottom of screen",methods:[{keys:["End"]}]},{description:"Navigate to previous messages",methods:[{keys:["Tab"]},{keys:["Shift","Tab"]}]}];class CU0 extends q1{items;renderRow;constructor({items:A,renderRow:Q}){super();this.items=A,this.renderRow=Q}build(A){let $=l1.of(A).size.width,B=50,D=$<50,J=[];for(let E of this.items){let[F,Y]=this.renderRow(E),Z;if(D)Z=new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:[F,new f0({padding:V0.only({left:4}),child:Y})]});else Z=new r0({crossAxisAlignment:"start",children:[new R1({flex:1,child:F}),new X0({width:1}),new R1({flex:1,child:Y})]});J.push(new f0({padding:V0.horizontal(6),child:Z}))}return new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:J})}}class g41 extends u0{commands;submitOnEnter;constructor({key:A,commands:Q,submitOnEnter:$}){super(A?{key:A}:{});this.commands=Q,this.submitOnEnter=$??!0}createState(){return new wi4}}class wi4 extends R0{scrollController;initState(){this.scrollController=new S6,this.scrollController.disableFollowMode(),this.scrollController.jumpTo(0)}dispose(){}build(A){let $=L1.of(A).colorScheme,D=O0.of(A).app,J=l1.of(A),E=new T({color:$.primary,bold:!0}),F=new T({color:$.secondary,bold:!0}),Y=new T({color:D.keybind}),Z=new T({color:D.command}),U=new T({color:$.foreground}),X=new T({color:$.foreground}),G=J.size.width,V=J.size.height,z=G-4,K=V-4,I=Math.max(40,Math.min(80,z)),W=new Set(["permissions-disable"]),q=[...this.widget.commands.filter((L)=>{let j=L.noun?.toLowerCase();return j!=="dev"&&j!=="debug"&&!L.id.startsWith("debug-")&&!W.has(L.id)})].sort((L,j)=>{let k=(L.noun??"").toLowerCase(),_=(j.noun??"").toLowerCase(),f=k.localeCompare(_);if(f!==0)return f;let g=L.verb.toLowerCase(),b=j.verb.toLowerCase(),v=g.localeCompare(b);if(v!==0)return v;return L.id.localeCompare(j.id)}),N=new f6({autofocus:!0,controller:this.scrollController,child:new b0({constraints:new M1(I,I,0,Number.POSITIVE_INFINITY),child:new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:[new $4({child:new d({text:new C(`Amp CLI - Help & Keyboard Shortcuts
|
|
5226
|
+
${$.errorMessage??""}`;if(Q.add(B),this.pluginErrorToastKeys.has(B))continue;this.options.toastController.show(this.formatPluginErrorToast($),"error",8000)}this.pluginErrorToastKeys=Q}removeInactivePluginStatusItems(A){let Q=new Set(A.filter((B)=>B.status==="active").map((B)=>B.uri.toString())),$=[];for(let[B,D]of this.statusItems){if(Q.has(D.pluginURI))continue;$.push(B)}if($.length===0)return;this.updateStatusItemState(()=>{for(let B of $)this.statusItems.delete(B)})}formatPluginErrorToast(A){let Q=A.uri.toString();return`Plugin failed: ${Q.split("/").pop()??Q}. See logs: ${this.options.neoContext.logFilePath}`}createPluginCommand(A){return{id:A.id,noun:A.category,verb:A.title,description:A.description??`Run plugin command ${A.category}: ${A.title}`,keywords:["plugin",A.pluginName,A.id],status:A.availability,run:async(Q,$,B)=>{B();try{await this.options.neoContext.pluginService?.commands.execute(A.pluginName,A.id,{threadID:this.options.getActiveThreadID()})}catch(D){u.error("Neo plugin command failed",{error:D,command:A}),this.options.toastController.show(D instanceof Error?D.message:String(D),"error",5000)}}}}showInputDialog=(A)=>{return new Promise((Q)=>{if(this.disposed||!this.options.state.mounted){Q(void 0);return}this.enqueueDialog({kind:"input",options:A,resolve:Q})})};showConfirmDialog=(A)=>{return new Promise((Q)=>{if(this.disposed||!this.options.state.mounted){Q(!1);return}this.enqueueDialog({kind:"confirm",options:A,resolve:Q})})};showSelectDialog=(A)=>{return new Promise((Q)=>{if(this.disposed||!this.options.state.mounted){Q(void 0);return}this.enqueueDialog({kind:"select",options:A,resolve:Q})})};createStatusItem=(A,Q,$)=>{if(this.disposed)return;this.updateStatusItemState(()=>{let B=this.statusItemKey(A,Q),D={pluginURI:A,id:Q};if($!==void 0)D.value=$;this.statusItems.set(B,D)})};updateStatusItem=(A,Q,$)=>{if(this.disposed)return;this.updateStatusItemState(()=>{this.statusItems.set(this.statusItemKey(A,Q),{pluginURI:A,id:Q,value:$})})};removeStatusItem=(A,Q)=>{if(this.disposed)return;this.updateStatusItemState(()=>{this.statusItems.delete(this.statusItemKey(A,Q))})};updateStatusItemState(A){if(this.options.state.mounted)this.options.state.setState(A);else A()}statusItemKey(A,Q){return`${A}\x00${Q}`}cancelPendingDialogs(){let A=[];if(this.activeDialog)A.push(this.activeDialog);A.push(...this.queuedDialogs),this.activeDialog=null,this.queuedDialogs=[],this.resolvingDialog=null;for(let Q of A)this.cancelDialog(Q)}cancelDialog(A){switch(A.kind){case"input":A.resolve(void 0);return;case"confirm":A.resolve(!1);return;case"select":A.resolve(void 0);return}}enqueueDialog(A){if(this.activeDialog){if(this.queuedDialogs.push(A),this.resolvingDialog===this.activeDialog)this.advanceResolvingDialog(this.activeDialog);return}this.options.commandPalette.disable(),this.options.state.setState(()=>{this.activeDialog=A})}resolveInputDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveConfirmDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveSelectDialog(A,Q){this.resolveDialog(A,()=>A.resolve(Q))}resolveDialog(A,Q){if(this.activeDialog!==A||this.resolvingDialog===A)return;this.resolvingDialog=A,Q(),this.scheduleResolvingDialogAdvance(A,FS3)}scheduleResolvingDialogAdvance(A,Q){h6.instance.addPostFrameCallback(()=>{if(this.activeDialog!==A)return;if(this.queuedDialogs.length>0||Q<=1){this.advanceResolvingDialog(A);return}this.scheduleResolvingDialogAdvance(A,Q-1)},"NeoPluginIntegration.advanceDialog")}advanceResolvingDialog(A){if(this.resolvingDialog===A)this.resolvingDialog=null;if(this.activeDialog!==A)return;this.advanceDialog()}advanceDialog(){this.updateDialogState(()=>{this.activeDialog=this.queuedDialogs.shift()??null})}updateDialogState(A){if(this.options.state.mounted)this.options.state.setState(A);else A()}}var ZS3=48;class R41{visible=!1;onClick=void 0;listeners=new Set;show(A){this.visible=!0,this.onClick=A,this.notifyListeners()}activate(){this.onClick?.()}get isVisible(){return this.visible}dismiss(){this.visible=!1,this.onClick=void 0,this.notifyListeners()}addListener(A){this.listeners.add(A)}removeListener(A){this.listeners.delete(A)}buildComplexToast(){if(!this.visible||!this.onClick)return null;return new er({width:ZS3,title:"Relaunch to Update Amp",message:"Your threads will resume.",variant:"success",mouseBehavior:"click-anywhere",action:{keyboardShortcut:"Ctrl+O",command:"amp: relaunch",confirmShortcut:"Enter",label:"relaunch",onAction:()=>this.activate()}})}notifyListeners(){for(let A of this.listeners)A()}}i0();import{spawnSync as US3}from"node:child_process";import gK from"node:process";var Vi4={options:new Set(["settings-file","log-level","log-file","mcp-config"]),booleans:new Set(["color","dangerously-allow-all","ide","jetbrains","neo-orb","notifications"])};function Ds(A){let Q=A.getRelaunchThreadIDs();if(A.onRelaunchRequested?.(Q),A.stop)A.stop();else H4.instance.stop()}function zi4(A){return{noun:"amp",verb:"Relaunch (Quit, then Reopen & Resume Thread)",description:"Quit, reopen Amp, and resume active threads",keywords:["restart","update","resume","reopen"],shortcut:gK.env.NODE_ENV==="development"&&gK.platform==="darwin"?G1.meta("r"):void 0,status:{type:"enabled"},sortBoost:90,run:(Q,$,B)=>{B(),Ds(A)}}}function XS3(A,Q){u.info("Relaunching Amp; threads will be resumed",{threadIDs:A});let{command:$,args:B}=GS3(A),D=US3($,B,{cwd:Q,env:gK.env,stdio:"inherit"});if(D.error)return u.error("Failed to relaunch Amp",{error:D.error}),1;return D.status??1}class u41{relaunchRequested=!1;requestedThreadIDs=[];request=(A)=>{u.info("Relaunch requested; threads will be resumed",{threadIDs:A}),this.relaunchRequested=!0,this.requestedThreadIDs=A};get shouldShowExitSummary(){return!this.relaunchRequested}relaunchIfRequested(A){if(!this.relaunchRequested)return;return XS3(this.requestedThreadIDs,A)}}function GS3(A){let Q=A.length>0?["threads","continue",...A]:[],$=VS3(gK.argv),B=KS3();if(B)return{command:B.command,args:[...B.args,...$,...Q]};let D=gK.argv[1],J=D&&zS3(D)?[D]:[];return{command:gK.execPath,args:[...J,...$,...Q]}}function VS3(A){let Q=[],$=A.slice(2);for(let B=0;B<$.length;B+=1){let D=$[B];if(!D?.startsWith("--"))continue;let[J,E]=D.split("=",2);if(!J)continue;let F=J.slice(2),Y=F.startsWith("no-")?F.slice(3):F;if(Vi4.booleans.has(Y)){Q.push(D);continue}if(!Vi4.options.has(F))continue;if(E!==void 0){Q.push(D);continue}let Z=$[B+1];if(Z===void 0||Z.startsWith("--"))continue;Q.push(D,Z),B+=1}return Q}function zS3(A){return A!==gK.execPath&&!A.startsWith("/$bunfs/")}function KS3(){if(gK.env.NODE_ENV!=="development")return null;let A=gK.env.AMP_DEV_RELAUNCH_COMMAND?.trim();if(!A)return null;let Q=IS3(A),$=Q[0];if(!$)return null;return{command:$,args:Q.slice(1)}}function IS3(A){if(A.startsWith("["))try{let Q=JSON.parse(A);if(Array.isArray(Q)&&Q.every(($)=>typeof $==="string"))return Q}catch{return[]}return A.split(/\s+/).filter(Boolean)}var WS3=18000000;class P41{options;subscription=null;relaunchNotificationShown=!1;relaunchNotificationPending=!1;relaunchNotificationTimer=null;openedAt=Date.now();constructor(A){this.options=A}init(){if(this.subscription=this.options.updateService?.state.subscribe((A)=>{this.handleUpdateState(A)})??null,process.env.DEV_SHOW_RELAUNCH_NOTIF_ON_STARTUP==="1")this.showUpdateRelaunchNotification(!0)}dispose(){if(this.subscription?.unsubscribe(),this.subscription=null,this.relaunchNotificationTimer)clearTimeout(this.relaunchNotificationTimer),this.relaunchNotificationTimer=null}handleUpdateState(A){if(A!=="updated")return;this.showUpdateRelaunchNotification()}showUpdateRelaunchNotification(A=!1){if(this.relaunchNotificationShown)return;let $=(this.options.minimumOpenDurationMs??WS3)-(Date.now()-this.openedAt);if($>0&&!A){if(this.relaunchNotificationPending=!0,!this.relaunchNotificationTimer)this.relaunchNotificationTimer=setTimeout(()=>{if(this.relaunchNotificationTimer=null,!this.relaunchNotificationPending)return;this.relaunchNotificationPending=!1,this.showUpdateRelaunchNotification()},$),this.relaunchNotificationTimer.unref();return}this.relaunchNotificationPending=!1,this.relaunchNotificationShown=!0,this.options.relaunchNotificationController.show(()=>Ds(this.options))}}Gl();r2();import{readFile as HS3}from"node:fs/promises";import _41 from"node:os";function qS3(A=new Date){return A.toISOString().replaceAll("-","").replaceAll(":","").slice(0,15)+"Z"}async function Ki4(A,Q){try{return{path:Q,contents:hh0(await HS3(A,"utf8"))}}catch{return null}}async function NU0(A,Q){let $=[],B=qS3(),D=await r4.getThread({thread:Q},{config:A.configService}),J=D.ok?D.result.thread.data:null;$.push({path:`${B}/thread.json`,contents:JSON.stringify($D(J),null,2)});let E=await Ki4(xS(Q),`${B}/logs/${Q}.log`);if(E)$.push(E);let F=await Ki4(A.settingsFilePath,`${B}/settings/global.json`);if(F)$.push(F);let Y=await IG()??"unknown",Z=await r4.sendReport({threadID:Q,files:$,metadata:{clientVersion:"0.0.1779190035-gd08a72",clientOS:`${_41.platform()} ${_41.release()} ${_41.arch()}`,installMethod:Y}},{config:A.configService});if(!Z.ok)throw Error(`Failed to submit report: ${Z.error.message}`);return Z.result.reportID}class T41{backStack=[];forwardStack=[];canNavigateBack(){return this.backStack.length>0}canNavigateForward(){return this.forwardStack.length>0}recordNavigation(A){if(!A)return;this.backStack.push(A),this.forwardStack.length=0}startBackNavigation(A){let Q=this.backStack.pop();if(!Q)return null;let $=Boolean(A);if(A)this.forwardStack.push(A);return{targetThreadID:Q,rollback:()=>{if($)this.forwardStack.pop();this.backStack.push(Q)}}}startForwardNavigation(A){let Q=this.forwardStack.pop();if(!Q)return null;let $=Boolean(A);if(A)this.backStack.push(A);return{targetThreadID:Q,rollback:()=>{if($)this.backStack.pop();this.forwardStack.push(Q)}}}}class wU0 extends C3{offstage;constructor({key:A,offstage:Q=!0,child:$}){super({key:A,child:$});this.offstage=Q}createRenderObject(){return new v41(this.offstage)}updateRenderObject(A){if(A instanceof v41)A.offstage=this.offstage}}class v41 extends t1{_offstage;constructor(A){super();this._offstage=A}get offstage(){return this._offstage}set offstage(A){if(A===this._offstage)return;this._offstage=A,this.markNeedsLayout()}getMinIntrinsicWidth(A){if(this._offstage)return 0;return this.children[0]?.getMinIntrinsicWidth(A)??0}getMaxIntrinsicWidth(A){if(this._offstage)return 0;return this.children[0]?.getMaxIntrinsicWidth(A)??0}getMinIntrinsicHeight(A){if(this._offstage)return 0;return this.children[0]?.getMinIntrinsicHeight(A)??0}getMaxIntrinsicHeight(A){if(this._offstage)return 0;return this.children[0]?.getMaxIntrinsicHeight(A)??0}performLayout(){let A=this._lastConstraints;N4(!!A,"performLayout called without constraints");let Q=this.children[0];if(this._offstage){if(this.setSize(0,0),Q)Q.layout(A),Q.setOffset(0,0)}else if(Q){Q.layout(A);let $=A.constrain(Q.size.width,Q.size.height);this.setSize($.width,$.height),Q.setOffset(0,0)}else{let $=A.smallest;this.setSize($.width,$.height)}super.performLayout()}paint(A,Q,$){if(this._offstage)return;super.paint(A,Q,$)}hitTest(A,Q,$,B){if(this._offstage)return!1;return super.hitTest(A,Q,$,B)}}class Js{_state=null;_attach(A){this._state=A}_detach(){this._state=null}push(A){this._state?.push(A)}pushWithDismiss(A){this._state?.pushWithDismiss(A)}pop(){return this._state?.pop()??!1}get canPop(){return this._state?.canPop??!1}}class k41 extends u0{root;controller;constructor(A){super();this.root=A.root,this.controller=A.controller}createState(){return new Ii4}}class Ii4 extends R0{entries=[];initState(){this.widget.controller._attach(this)}didUpdateWidget(A){if(A.controller!==this.widget.controller)A.controller._detach(),this.widget.controller._attach(this)}dispose(){this.widget.controller._detach(),super.dispose()}push(A){let Q=new Hj,$=this.makeScopedDismiss(Q);this.setState(()=>{this.entries.push({key:Q,widget:A,dismiss:$})})}pushWithDismiss(A){let Q=new Hj,$=this.makeScopedDismiss(Q),B=A($);this.setState(()=>{this.entries.push({key:Q,widget:B,dismiss:$})})}pop(){if(this.entries.length===0)return!1;return this.setState(()=>{this.entries.pop()}),!0}get canPop(){return this.entries.length>0}makeScopedDismiss(A){return()=>{if(!this.mounted)return;let Q=this.entries[this.entries.length-1];if(!Q||Q.key!==A)return;this.setState(()=>{this.entries.pop()})}}build(A){let Q=[];Q.push(new wU0({offstage:this.entries.length>0,child:this.widget.root}));for(let $=0;$<this.entries.length;$++){let B=this.entries[$],D=$===this.entries.length-1,J=D?new h4({autofocus:!0,debugLabel:`ModalStackEntry[${$}]`,onKey:(E)=>{if(E.key!=="Escape")return"ignored";return B.dismiss(),"handled"},child:B.widget}):B.widget;Q.push(new wU0({key:B.key,offstage:!D,child:J}))}return new t4({fit:"expand",children:Q})}}import Wi4 from"node:process";class f41 extends q1{props;constructor(A){super();this.props=A}build(A){let Q=this.props.commands.filter((B)=>B.status.type!=="hidden"),$=NS3(Q);return new w6({header:"Command Palette",autofocus:!1,barrierOpaque:!1,chromePadding:V0.only({left:1,top:1,right:1}),footer:"none",onDismiss:this.props.onDismiss,child:new pA({items:Q,showBorder:!1,getLabel:(B)=>{let D=S41(B);return B.keywords&&B.keywords.length>0?`${D} ${B.keywords.join(" ").toLowerCase()}`:D},sortItems:(B,D,J)=>{if(J===""){let U=B.item.status.type==="disabled"?1:0,X=D.item.status.type==="disabled"?1:0;if(U!==X)return U-X;let G=B.item.sortBoost??0,V=D.item.sortBoost??0;if(G!==V)return V-G;let z=B.item.noun?.toLowerCase()??"",K=D.item.noun?.toLowerCase()??"";if(z!==K)return z<K?-1:1;return 0}let E=bj(B.item.verb.toLowerCase(),J),F=bj(D.item.verb.toLowerCase(),J);if(E!==F)return F-E;let Y=bj(S41(B.item),J),Z=bj(S41(D.item),J);if(Y!==Z)return Z-Y;return D.score-B.score},isItemDisabled:(B)=>B.status.type==="disabled",buildDisabledReasonWidget:(B,D)=>{if(B.status.type!=="disabled")return;let{colors:J}=O0.of(D);return new d({text:new C(B.status.reason,new T({color:J.mutedForeground,dim:!0})),textAlign:"center"})},renderItem:(B,D,J,E)=>new Hi4({command:B,isSelected:D,isDisabled:J,categoryWidth:$,buildContext:E}),onAccept:(B)=>{this.props.onAccept(B)},onDismiss:this.props.onDismiss})})}}class Hi4 extends q1{props;constructor(A){super();this.props=A}build(A){let{command:Q,isSelected:$,isDisabled:B,categoryWidth:D,buildContext:J}=this.props,E=O0.of(J),{colors:F,app:Y}=E,Z=$?Y.selectionBackground:void 0,U=$?Y.selectionForeground:F.foreground,X=$?U:F.mutedForeground,G=new d({text:new C(Q.noun?.toLowerCase()??"",new T({color:X,dim:B||!$})),textAlign:"right"}),V=[new C(Q.verb.toLowerCase(),new T({color:U,bold:!0,dim:B}))];if(B)V.push(new C(" (unavailable)",new T({color:U,dim:!0})));let z=d.spans(V),K=[{child:G,fixedWidth:D},{child:z,expanded:!0}];if(Q.shortcut)K.push({child:wS3(Q.shortcut,E,B)});return new qi4({columns:K,padding:V0.horizontal(1),backgroundColor:Z})}}function S41(A){return A.noun?`${A.noun.toLowerCase()} ${A.verb.toLowerCase()}`:A.verb.toLowerCase()}function NS3(A){return A.reduce((Q,$)=>{return $.noun?Math.max(Q,L4($.noun)):Q},0)}function wS3(A,Q,$){let{colors:B,app:D}=Q,J=new T({color:B.mutedForeground,dim:$}),E=[];for(let F of A.modifiers()){if(E.length>0)E.push(new C(" ",J));E.push(new C(CS3(F),new T({color:D.keybind,bold:!0,dim:$})))}if(E.length>0)E.push(new C(" ",J));return E.push(new C(MS3(A),new T({color:D.keybind,bold:!0,dim:$}))),d.spans(E)}function CS3(A){return A==="Meta"&&Wi4.platform==="darwin"?"Cmd":A}function MS3(A){return A.meta&&Wi4.platform==="darwin"?A.key.toUpperCase():A.key}class qi4 extends q1{props;constructor(A){super();this.props=A}build(A){let{columns:Q,gap:$=2,padding:B,backgroundColor:D}=this.props,J=[];for(let F=0;F<Q.length;F++){let Y=Q[F];if(F>0&&$>0)J.push(new X0({width:$}));if(Y.fixedWidth!==void 0)J.push(new X0({width:Y.fixedWidth,child:Y.child}));else if(Y.expanded)J.push(new R1({child:Y.child}));else J.push(Y.child)}let E=new r0({crossAxisAlignment:"start",children:J});if(!B&&!D)return E;return new b0({decoration:D?{color:D}:void 0,padding:B,child:E})}}class y41{#A=[];#Q=new Set;get commands(){return this.#A}register(A){return this.#A.push(A),this.#$(),()=>{let Q=this.#A.indexOf(A);if(Q===-1)return;this.#A.splice(Q,1),this.#$()}}findByID(A){return this.#A.find((Q)=>Q.id===A)}runByID(A,Q){let $=this.findByID(A);if(!$||$.status.type!=="enabled")return!1;return $.run(new Js,Q,()=>{}),!0}addListener(A){this.#Q.add(A)}removeListener(A){this.#Q.delete(A)}#$(){for(let A of this.#Q)A()}}class W9 extends GA{commandRegistry;constructor({commandRegistry:A,child:Q}){super({child:Q});this.commandRegistry=A}updateShouldNotify(A){return!1}static of(A){let Q=W9.maybeOf(A);if(!Q)throw Error("No NeoCommandRegistryProvider found in widget tree");return Q}static maybeOf(A){return A.dependOnInheritedWidgetOfExactType(W9)?.commandRegistry??null}}class x41 extends u0{onDismiss;constructor(A){super();this.onDismiss=A.onDismiss}createState(){return new Ni4}}class Ni4 extends R0{modalStack=new Js;commandRegistry=null;initState(){super.initState(),queueMicrotask(()=>{if(!this.mounted)return;let A=W9.of(this.context);this.commandRegistry=A,A.addListener(this.onCommandsChanged)})}dispose(){this.commandRegistry?.removeListener(this.onCommandsChanged),this.commandRegistry=null,super.dispose()}onCommandsChanged=()=>{this.setState()};build(A){let Q=W9.of(A).commands,$=new f41({commands:Q,onAccept:(B)=>{B.run(this.modalStack,A,this.widget.onDismiss)},onDismiss:()=>{if(this.modalStack.canPop)this.modalStack.pop();else this.widget.onDismiss()}});return new k41({root:$,controller:this.modalStack})}}var b41=[{description:"Move cursor up/down",methods:[{keys:["↑"]},{keys:["↓"]}]},{description:"Move cursor left/right",methods:[{keys:["←"]},{keys:["→"]},{input:"B",keys:["Ctrl"]},{input:"F",keys:["Ctrl"]}]},{description:"Insert newline",methods:[{keys:["Shift","Enter"]},{keys:["Alt","Enter"]},{input:"J",keys:["Ctrl"]}],submitOnEnterOnly:!0},{description:"Insert newline",methods:[{keys:["Enter"]},{keys:["Shift","Enter"]},{keys:["Alt","Enter"]},{input:"J",keys:["Ctrl"]}],submitOnEnterOnly:!1},{description:"Submit message",methods:[{keys:["Enter"]}],submitOnEnterOnly:!0},{description:"Submit message",methods:[{keys:["Ctrl/Cmd","Enter"]}],submitOnEnterOnly:!1},{description:"Clear input",methods:[{keys:["Escape"]}]},{description:"Edit prompt in $EDITOR",methods:[{input:"G",keys:["Ctrl"]}]},{description:"Navigate history (previous/next)",methods:[{input:"P",keys:["Ctrl"]},{input:"N",keys:["Ctrl"]}]},{description:"Jump to start of line",methods:[{keys:["Cmd","←"]},{input:"A",keys:["Ctrl"]}]},{description:"Jump to end of line",methods:[{keys:["Cmd","→"]},{input:"E",keys:["Ctrl"]}]},{description:"Jump to previous word",methods:[{keys:["Alt","←"]},{keys:["Ctrl","←"]},{input:"B",keys:["Alt"]}]},{description:"Jump to next word",methods:[{keys:["Alt","→"]},{keys:["Ctrl","→"]},{input:"F",keys:["Alt"]}]},{description:"Delete character backward",methods:[{keys:["Backspace"]},{input:"H",keys:["Ctrl"]}]},{description:"Delete word backward",methods:[{keys:["Alt","Backspace"]},{input:"W",keys:["Ctrl"]}]},{description:"Delete character forward",methods:[{keys:["Delete"]},{input:"D",keys:["Ctrl"]}]},{description:"Delete to start of line",methods:[{keys:["Cmd","Backspace"]},{input:"U",keys:["Ctrl"]}]},{description:"Delete to end of line",methods:[{input:"K",keys:["Ctrl"]}]},{description:"Yank (paste deleted text)",methods:[{input:"Y",keys:["Ctrl"]}]},{description:"Paste image from clipboard",methods:[{input:"V",keys:["Ctrl"]}]},{description:"Switch agent mode",methods:[{input:"S",keys:["Ctrl"]}]},{description:"Toggle reasoning effort",methods:[{input:"D",keys:["Alt"]}]},{description:"Open command palette",methods:[{input:"O",keys:["Ctrl"]}]},{description:"Mention files",methods:[{keys:["@"]}]},{description:"Mention threads",methods:[{keys:["@@"]}]},{description:"Show prompt history",methods:[{input:"R",keys:["Ctrl"]}]},{description:"Toggle inline shortcuts help",methods:[{keys:["?"]}]},{description:"Toggle thinking/dense view",methods:[{input:"T",keys:["Alt"]}]}],h41=[{description:"Page scroll",methods:[{keys:["Pg Up"]},{keys:["Pg Down"]}]},{description:"Half-page scroll",methods:[{input:"K",keys:["Alt"]},{input:"J",keys:["Alt"]}]},{description:"Mouse wheel scroll",methods:[{keys:["Mouse Wheel"]}]},{description:"Jump to first message",methods:[{keys:["Home"]}]},{description:"Jump to bottom of screen",methods:[{keys:["End"]}]},{description:"Navigate to previous messages",methods:[{keys:["Tab"]},{keys:["Shift","Tab"]}]}];class CU0 extends q1{items;renderRow;constructor({items:A,renderRow:Q}){super();this.items=A,this.renderRow=Q}build(A){let $=l1.of(A).size.width,B=50,D=$<50,J=[];for(let E of this.items){let[F,Y]=this.renderRow(E),Z;if(D)Z=new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:[F,new f0({padding:V0.only({left:4}),child:Y})]});else Z=new r0({crossAxisAlignment:"start",children:[new R1({flex:1,child:F}),new X0({width:1}),new R1({flex:1,child:Y})]});J.push(new f0({padding:V0.horizontal(6),child:Z}))}return new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:J})}}class g41 extends u0{commands;submitOnEnter;constructor({key:A,commands:Q,submitOnEnter:$}){super(A?{key:A}:{});this.commands=Q,this.submitOnEnter=$??!0}createState(){return new wi4}}class wi4 extends R0{scrollController;initState(){this.scrollController=new S6,this.scrollController.disableFollowMode(),this.scrollController.jumpTo(0)}dispose(){}build(A){let $=L1.of(A).colorScheme,D=O0.of(A).app,J=l1.of(A),E=new T({color:$.primary,bold:!0}),F=new T({color:$.secondary,bold:!0}),Y=new T({color:D.keybind}),Z=new T({color:D.command}),U=new T({color:$.foreground}),X=new T({color:$.foreground}),G=J.size.width,V=J.size.height,z=G-4,K=V-4,I=Math.max(40,Math.min(80,z)),W=new Set(["permissions-disable"]),q=[...this.widget.commands.filter((L)=>{let j=L.noun?.toLowerCase();return j!=="dev"&&j!=="debug"&&!L.id.startsWith("debug-")&&!W.has(L.id)})].sort((L,j)=>{let k=(L.noun??"").toLowerCase(),_=(j.noun??"").toLowerCase(),f=k.localeCompare(_);if(f!==0)return f;let g=L.verb.toLowerCase(),b=j.verb.toLowerCase(),v=g.localeCompare(b);if(v!==0)return v;return L.id.localeCompare(j.id)}),N=new f6({autofocus:!0,controller:this.scrollController,child:new b0({constraints:new M1(I,I,0,Number.POSITIVE_INFINITY),child:new S0({crossAxisAlignment:"start",mainAxisSize:"min",children:[new $4({child:new d({text:new C(`Amp CLI - Help & Keyboard Shortcuts
|
|
5227
5227
|
`,E)})}),new X0({height:1}),new f0({padding:V0.horizontal(2),child:new d({text:new C(`Editor Shortcuts
|
|
5228
5228
|
`,F)})}),new CU0({items:b41.filter((L)=>L.submitOnEnterOnly===void 0||L.submitOnEnterOnly===this.widget.submitOnEnter),renderRow:(L)=>{let j=[];for(let _ of L.methods){let f=this.buildCleanKeyCombination(_);j.push(f)}let k=j.join(", ");return[new d({text:new C(k,Y)}),new d({text:new C(L.description,U)})]}}),new X0({height:1}),new f0({padding:V0.horizontal(2),child:new d({text:new C(`Scrolling & Navigation
|
|
5229
5229
|
`,F)})}),new CU0({items:h41,renderRow:(L)=>{let j=[];for(let _ of L.methods){let f=this.buildCleanKeyCombination(_);j.push(f)}let k=j.join(", ");return[new d({text:new C(k,Y)}),new d({text:new C(L.description,U)})]}}),new X0({height:1}),new f0({padding:V0.horizontal(2),child:new d({text:new C(`Command Palette Commands
|
|
@@ -5313,7 +5313,7 @@ Ctrl-X, Y, Z to unlock`;if(this.widget.centerContent)g=this.widget.centerContent
|
|
|
5313
5313
|
`))}return E}function bh3(A,Q,$){let{colors:B,app:D}=$,J=hh3(Q.status,$);if(A.push(new C(` ${J.icon} `,new T({color:J.color}))),A.push(new C(Q.name,new T({color:Q.status==="pending"?B.warning:D.command}))),Q.status==="pending")A.push(new C(" discovering...",new T({color:B.foreground,dim:!0})));else if(Q.description)A.push(new C(` ${$r4(Q.description,50)}`,new T({color:B.foreground,dim:!0})));if(Q.error)A.push(new C(` ${$r4(Q.error,40)}`,new T({color:D.toolError})));A.push(new C(`
|
|
5314
5314
|
`))}function hh3(A,Q){let{colors:$,app:B}=Q;switch(A){case"pending":return{icon:"◌",color:$.warning};case"registered":return{icon:"•",color:$.mutedForeground};case"failed":return{icon:"✗",color:B.toolError};case"duplicate":return{icon:"◇",color:$.warning};default:return{icon:"?",color:$.foreground}}}function $r4(A,Q){let $=A.replace(/\s+/g," ").trim();if(L4($)<=Q)return $;let B="...",D=L4(B);if(Q<=D)return VD(B,Q);return`${VD($,Q-D,!0,"")}${B}`}var OA1="https://ampcode.com/news/neo",jA1=[{title:"Meet the new Amp CLI",body:[]},{title:"Rebuilt From The Ground Up",body:["Same close-up terminal workflow. Completely different underneath."]},{title:"Just Keep Typing",body:["Context is summarized automatically at ~90%.","No handoff flow. No context percentage to babysit."]},{title:"Queueing and Steering",body:["Sending a message now queues by default instead of cancelling tools.","Use steering when you want the agent to see something sooner."]},{title:"Remote Control",body:["Start a thread in the CLI, then keep going from ampcode.com.","Watch live updates and queue follow-ups from any device."]},{title:"Customize Amp with Amp",body:[{text:"Amp now has a ",linkText:"complete plugin API",href:"https://ampcode.com/manual/plugin-api",textAfter:"."},"Add tools, commands, control UI, and hook into events."]},{title:"Permissions",body:[{text:"By default (when no ",highlightText:"amp.permissions",textAfterHighlight:" setting is present), Amp no longer asks for confirmation before running any tools and commands. And you can now implement your own custom permission logic with ",linkText:"plugins",href:"https://ampcode.com/manual/plugin-api",textAfter:"."}]},{title:null,body:["Check out the full news post for more:",{text:OA1,href:OA1},"","",{text:"Need old Amp for a bit? Use ",keybind:"amp --take-me-back"}]}];function gh3(A){return[{title:"Upgrade your Amp CLI",body:[{text:"This npm-based distribution of Amp CLI has been deprecated. To use the ",linkText:"new Amp CLI",href:OA1,textAfter:" you'll need to switch to the binary install:",linkWidget:!0},"",{codeBlock:["npm uninstall -g @sourcegraph/amp",A]}]}]}function mh3(){if(process.platform==="win32")return'powershell -c "irm https://ampcode.com/install.ps1 | iex"';return"curl -fsSL https://ampcode.com/install.sh | bash"}var jy=50,QR=40,MA1=1000,dh3=420,ph3=760,ch3=-250,lh3=1100,AX0=33,Er4=0.999,ih3=2.1,nh3=720,ah3=420,zr4="Meet the new",Kr4="Amp",Ir4="CLI",RA1=C4(zr4).length,oh3=C4(Kr4).length,rh3=C4(Ir4).length,QX0={primary:{r:140,g:38,b:0},secondary:{r:255,g:225,b:102}},Fr4={primary:{r:10,g:42,b:18},secondary:{r:200,g:230,b:68}},Yr4={primary:{r:18,g:0,b:107},secondary:{r:103,g:255,b:168}},Zr4=[QX0,Fr4,Yr4,QX0,Fr4,Yr4,QX0],sh3=QX0;class uA1 extends u0{onDismiss;onQuit;animationProgress;animationsEnabled;variant;binaryInstallCommand;introStages;dismissible;constructor(A){super();this.onDismiss=A.onDismiss,this.onQuit=A.onQuit,this.animationProgress=A.animationProgress,this.animationsEnabled=A.animationsEnabled??!0,this.variant=A.variant??"intro",this.binaryInstallCommand=A.binaryInstallCommand??mh3(),this.introStages=this.variant==="npm-migration"?gh3(this.binaryInstallCommand):jA1,this.dismissible=this.variant!=="npm-migration"}createState(){return new Wr4}}class Wr4 extends R0{startedAt=performance.now();animationTimer=null;stageTransitionTimer=null;firstStageTitleTimer=null;firstStageHintTimer=null;firstStageRevealTimer=null;firstStageTitleRevealStartedAt=null;firstStageHintRevealStartedAt=null;stageTransitionStartedAt=performance.now();animationStartProgress=0;animationTargetProgress=1;animationDurationMs=MA1;onAnimationComplete=null;animationProgress=0;introStage=0;previousIntroStage=null;stageTransitionProgress=1;stageTransitionDirection=1;firstStageTitleVisible=!1;firstStageHintVisible=!1;firstStageTitleRevealProgress=0;firstStageHintRevealProgress=0;dismissTimer=null;dismissStartedAt=performance.now();dismissProgress=0;isDismissing=!1;splashOrbGlow=new d9(42);initState(){super.initState(),this.startAnimationIfNeeded()}didUpdateWidget(A){if(super.didUpdateWidget(A),A.animationProgress!==this.widget.animationProgress||A.animationsEnabled!==this.widget.animationsEnabled)this.startAnimationIfNeeded()}dispose(){this.stopAnimation(),this.stopStageTransitionTimer(),this.stopFirstStageRevealTimers(),this.stopDismissAnimation(),super.dispose()}startAnimationIfNeeded(){if(this.stopAnimation(),this.stopFirstStageRevealTimers(),this.widget.animationProgress!==void 0){this.animationProgress=nJ(this.widget.animationProgress),this.firstStageTitleVisible=this.animationProgress>=Er4,this.firstStageHintVisible=this.animationProgress>=Er4,this.firstStageTitleRevealProgress=this.firstStageTitleVisible?1:0,this.firstStageHintRevealProgress=this.firstStageHintVisible?1:0;return}if(!this.widget.animationsEnabled){this.stopStageTransitionTimer(),this.stopDismissAnimation(),this.animationProgress=1,this.isDismissing=!1,this.dismissProgress=0,this.firstStageTitleVisible=!0,this.firstStageHintVisible=!0,this.firstStageTitleRevealProgress=1,this.firstStageHintRevealProgress=1,this.previousIntroStage=null,this.stageTransitionProgress=1;return}if(this.firstStageTitleVisible=!1,this.firstStageHintVisible=!1,this.firstStageTitleRevealProgress=0,this.firstStageHintRevealProgress=0,this.startProgressAnimation({from:0,to:1,durationMs:MA1,onComplete:()=>{if(!this.widget.dismissible)this.setState(()=>{this.firstStageTitleVisible=!0,this.firstStageHintVisible=!0,this.firstStageTitleRevealProgress=1,this.firstStageHintRevealProgress=1})}}),this.widget.dismissible)this.startFirstStageRevealSequence()}startDismissAnimation(){if(this.isDismissing)return;if(!this.widget.animationsEnabled){this.widget.onDismiss();return}this.stopFirstStageRevealTimers(),this.stopStageTransitionTimer(),this.dismissStartedAt=performance.now(),this.setState(()=>{this.isDismissing=!0,this.dismissProgress=0}),this.dismissTimer=setInterval(()=>{let A=performance.now()-this.dismissStartedAt,Q=nJ(A/ph3);if(this.setState(()=>{this.dismissProgress=Q}),Q>=1)this.stopDismissAnimation(),this.widget.onDismiss()},AX0)}canNavigateIntroStage(){if(this.isDismissing)return!1;if(!this.firstStageHintVisible)return!1;if(this.introStage===0&&this.firstStageHintRevealProgress<1)return!1;return!0}advanceIntroStage(){if(!this.canNavigateIntroStage())return;if(this.isFinalIntroStage()){if(this.widget.dismissible)this.startDismissAnimation();return}this.moveIntroStage(1)}dismissFromFinalIntroStage(){if(!this.widget.dismissible||!this.canNavigateIntroStage()||!this.isFinalIntroStage())return!1;return this.startDismissAnimation(),!0}nextIntroStage(){if(!this.canNavigateIntroStage()||this.isFinalIntroStage())return;this.moveIntroStage(1)}goToPreviousIntroStage(){if(!this.canNavigateIntroStage()||this.introStage<=0)return;this.moveIntroStage(-1)}isFinalIntroStage(){return this.introStage>=this.widget.introStages.length-1}moveIntroStage(A){let Q=this.introStage+A;if(this.stopStageTransitionTimer(),this.stageTransitionStartedAt=performance.now(),this.setState(()=>{this.previousIntroStage=this.introStage,this.introStage=Q,this.stageTransitionDirection=A}),this.widget.animationProgress!==void 0||!this.widget.animationsEnabled){this.setState(()=>{this.previousIntroStage=null,this.stageTransitionProgress=1});return}this.setState(()=>{this.stageTransitionProgress=0}),this.stageTransitionTimer=setInterval(()=>{let $=performance.now()-this.stageTransitionStartedAt,B=nJ($/dh3);if(this.setState(()=>{if(this.stageTransitionProgress=B,B>=1)this.previousIntroStage=null}),B>=1)this.stopStageTransitionTimer()},AX0)}startProgressAnimation({from:A,to:Q,durationMs:$,onComplete:B}){this.stopAnimation(),this.startedAt=performance.now(),this.animationStartProgress=A,this.animationTargetProgress=Q,this.animationDurationMs=$,this.onAnimationComplete=B,this.animationProgress=A,this.animationTimer=setInterval(()=>{let D=performance.now()-this.startedAt,J=nJ(D/this.animationDurationMs),E=this.animationStartProgress+(this.animationTargetProgress-this.animationStartProgress)*Ry(J);if(this.setState(()=>{this.animationProgress=E}),J>=1)this.stopAnimation(),this.onAnimationComplete?.(),this.onAnimationComplete=null},AX0)}stopAnimation(){if(this.animationTimer)clearInterval(this.animationTimer),this.animationTimer=null}stopStageTransitionTimer(){if(this.stageTransitionTimer)clearInterval(this.stageTransitionTimer),this.stageTransitionTimer=null}startFirstStageRevealSequence(){if(this.stopFirstStageRevealTimers(),!this.widget.animationsEnabled){this.setState(()=>{this.firstStageTitleVisible=!0,this.firstStageHintVisible=!0,this.firstStageTitleRevealProgress=1,this.firstStageHintRevealProgress=1});return}this.setState(()=>{this.firstStageTitleVisible=!1,this.firstStageHintVisible=!1,this.firstStageTitleRevealProgress=0,this.firstStageHintRevealProgress=0});let A=Math.max(0,MA1+ch3),Q=A+lh3;this.firstStageTitleTimer=setTimeout(()=>{this.firstStageTitleRevealStartedAt=performance.now(),this.setState(()=>{this.firstStageTitleVisible=!0,this.firstStageTitleRevealProgress=0}),this.startFirstStageRevealTimer()},A),this.firstStageHintTimer=setTimeout(()=>{this.firstStageHintRevealStartedAt=performance.now(),this.setState(()=>{this.firstStageHintVisible=!0,this.firstStageHintRevealProgress=0}),this.startFirstStageRevealTimer()},Q)}startFirstStageRevealTimer(){if(this.firstStageRevealTimer)return;this.firstStageRevealTimer=setInterval(()=>{let A=performance.now(),Q=this.firstStageTitleRevealStartedAt?nJ((A-this.firstStageTitleRevealStartedAt)/nh3):this.firstStageTitleRevealProgress,$=this.firstStageHintRevealStartedAt?nJ((A-this.firstStageHintRevealStartedAt)/ah3):this.firstStageHintRevealProgress;if(this.setState(()=>{this.firstStageTitleRevealProgress=Q,this.firstStageHintRevealProgress=$}),Q>=1&&$>=1)this.stopFirstStageRevealTimer()},AX0)}stopFirstStageRevealTimers(){if(this.stopFirstStageRevealTimer(),this.firstStageTitleRevealStartedAt=null,this.firstStageHintRevealStartedAt=null,this.firstStageTitleTimer)clearTimeout(this.firstStageTitleTimer),this.firstStageTitleTimer=null;if(this.firstStageHintTimer)clearTimeout(this.firstStageHintTimer),this.firstStageHintTimer=null}stopFirstStageRevealTimer(){if(this.firstStageRevealTimer)clearInterval(this.firstStageRevealTimer),this.firstStageRevealTimer=null}stopDismissAnimation(){if(this.dismissTimer)clearInterval(this.dismissTimer),this.dismissTimer=null}currentOrbPalette(){let A=Ur4(this.introStage),Q=this.previousIntroStage===null||this.stageTransitionProgress>=1?A:Xr4(Ur4(this.previousIntroStage),A,Ry(this.stageTransitionProgress));return this.dismissProgress>0?Xr4(Q,sh3,Ry(this.dismissProgress)):Q}build(A){let Q=L1.of(A).colorScheme,$=O0.of(A),B=this.currentOrbPalette(),D=sQ(1,"frontier",B),J=l1.of(A).size,F=this.widget.animationProgress??this.animationProgress,Y=Math.max(J.width/jy,J.height/QR)*ih3,Z=Y+(1-Y)*F,U=Ry(this.dismissProgress),X=Math.max(jy,Math.round(jy*Z)),G=Math.max(QR,Math.round(QR*Z)),V=Math.round((J.width-X)/2),z=Math.round((J.height-G)/2),K=Math.max(0,Math.floor((J.width-jy)/2)),I=-Math.floor(QR/2),W=Math.round(V+(K-V)*F),H=Math.round(z+(I-z)*F),q=W+X/2,N=H+G/2,w=th3({dismissProgress:this.dismissProgress,easedDismissProgress:U,introOrbScale:Z,normalOrbCenterX:q,normalOrbCenterY:N,size:J}),O=Math.max(jy,Math.round(jy*w.orbScale)),L=Math.max(QR,Math.round(QR*w.orbScale)),j=w.orbCenterX,k=w.orbCenterY,_=Math.round(j-O/2),f=Math.round(k-L/2),g=Math.max(3,Math.min(J.height-5,Math.floor(QR/2)+2)),b=Math.max(g+3,J.height-3),v=w.textDissolveProgress,y=this.isFinalIntroStage()?w.backdropDissolveProgress:0,p=this.firstStageTitleVisible&&v<1,c=p&&this.firstStageHintVisible,h=c&&this.widget.dismissible&&this.introStage>0&&!this.isFinalIntroStage(),i=this.introStage===0?this.firstStageTitleRevealProgress:1,r=this.introStage===0?this.firstStageHintRevealProgress:1,$0=Math.max(24,Math.min(74,J.width-4)),w0=Math.min(12,Math.max(8,J.height-g-6)),Y0=Math.max(0,Math.floor((J.width-$0)/2)),W0=Math.max(0,Math.min(J.height-w0,Math.floor(J.height*0.55-w0/2))),j0=this.widget.animationProgress!==void 0||!this.widget.animationsEnabled?new If({width:O,height:L,agentMode:"frontier",visualStyle:"neo",neoGlyphSet:"dotField",backgroundColor:Q.background,primaryColor:B.primary,secondaryColor:B.secondary,glow:this.splashOrbGlow,seed:42,fps:0,onClick:()=>{}}):new If({width:O,height:L,agentMode:"frontier",visualStyle:"neo",neoGlyphSet:"dotField",backgroundColor:Q.background,primaryColor:B.primary,secondaryColor:B.secondary,glow:this.splashOrbGlow,onClick:()=>{}});return new h4({autofocus:!0,canRequestFocus:!0,debugLabel:"NeoWelcomeTakeover",onKey:(Q0)=>{if(Q0.key==="Enter")return this.advanceIntroStage(),"handled";if(!this.widget.dismissible&&Q0.key==="c"&&Q0.ctrlKey)return this.widget.onQuit?.(),"handled";if(!this.widget.dismissible&&Q0.key==="q")return this.widget.onQuit?.(),"handled";if((Q0.key===" "||Q0.key==="Space")&&!this.isFinalIntroStage())return this.advanceIntroStage(),"handled";if(Q0.key==="Escape"||Q0.key==="Esc"){if(!this.widget.dismissible)return this.widget.onQuit?.(),"handled";return this.dismissFromFinalIntroStage()?"handled":"ignored"}if(Q0.key==="ArrowRight")return this.nextIntroStage(),"handled";if(Q0.key==="ArrowLeft")return this.goToPreviousIntroStage(),"handled";return"ignored"},child:new t4({fit:"expand",children:[new Hr4({color:Q.background,dissolveProgress:y}),new t4({fit:"expand",children:[new j1({onClick:()=>{},child:X0.expand()}),new B6({left:_,top:f,width:O,height:L,child:j0}),...p?[new B6({left:Y0,top:W0,width:$0,height:w0,child:Ag3({introStages:this.widget.introStages,stage:this.introStage,previousStage:this.previousIntroStage,progress:this.stageTransitionProgress,direction:this.stageTransitionDirection,width:$0,height:w0,foreground:Q.foreground,mutedForeground:Q.mutedForeground,accent:D,link:$.app.link,keybind:$.app.keybind,titleRevealProgress:i,dissolveProgress:v,context:A})})]:[],...c?[...h?[new B6({left:Y0,top:Math.max(0,b-1),width:$0,height:1,child:new d({text:Eg3({stage:this.introStage,featureStageCount:Math.max(0,this.widget.introStages.length-2),foreground:Q.mutedForeground,dissolveProgress:v}),textAlign:"center"})})]:[],new B6({left:Y0,top:b,width:$0,height:1,child:Yg3({finalStage:this.isFinalIntroStage(),dismissible:this.widget.dismissible,foreground:Q.mutedForeground,keybind:$.app.keybind,revealProgress:r,dissolveProgress:v,context:A})})]:[]]})]})})}}class Hr4 extends X2{color;dissolveProgress;constructor({color:A,dissolveProgress:Q}){super();this.color=A,this.dissolveProgress=Q}createRenderObject(){return new qr4(this.color,this.dissolveProgress)}updateRenderObject(A){A.update(this.color,this.dissolveProgress)}}class qr4 extends t1{color;dissolveProgress;constructor(A,Q){super();this.color=A,this.dissolveProgress=Q}update(A,Q){this.color=A,this.dissolveProgress=Q,this.markNeedsPaint()}performLayout(){let A=this._lastConstraints;N4(!!A,"performLayout called without constraints");let Q=A.constrain(A.biggest.width,A.biggest.height);this.setSize(Q.width,Q.height),super.performLayout()}paint(A,Q=0,$=0){let B=Math.floor(Q+this.offset.x),D=Math.floor($+this.offset.y),J=Math.floor(this.size.width),E=Math.floor(this.size.height),F={bg:this.color},Y=nJ(this.dissolveProgress);if(Y<=0){A.fill(B,D,J,E," ",F);return}if(Y>=1)return;for(let Z=0;Z<E;Z++)for(let U=0;U<J;U++)if(!eh3(U,Z,J,E,Y))A.fill(B+U,D+Z,1,1," ",F)}}function nJ(A){return Math.min(1,Math.max(0,A))}function Ry(A){return 1-(1-A)**3}function Ur4(A){return Zr4[A]??Zr4[0]}function Xr4(A,Q,$){return{primary:qj(A.primary,Q.primary,$),secondary:qj(A.secondary,Q.secondary,$)}}function th3({dismissProgress:A,easedDismissProgress:Q,introOrbScale:$,normalOrbCenterX:B,normalOrbCenterY:D,size:J}){return{orbScale:$+($*0.86-$)*Q,orbCenterX:B+(J.width*0.54-B)*Q,orbCenterY:D-J.height*0.44*Q,textDissolveProgress:nJ(A/0.52),backdropDissolveProgress:Ry(nJ((A-0.12)/0.88))}}function eh3(A,Q,$,B,D){let J=B<=1?0:Q/(B-1),E=Nr4(A+Q*Math.max(1,$));return(1-J)*0.72+E*0.28<D}function Ag3({introStages:A,stage:Q,previousStage:$,progress:B,direction:D,width:J,height:E,foreground:F,mutedForeground:Y,accent:Z,link:U,keybind:X,titleRevealProgress:G,dissolveProgress:V,context:z}){if($===null||B>=1)return LA1({introStages:A,stage:Q,foreground:F,mutedForeground:Y,accent:Z,link:U,keybind:X,titleRevealProgress:G,dissolveProgress:V,context:z});let K=Ry(B),I=D*Math.round((1-K)*J),W=-D*Math.round(K*J);return new TK(new t4({fit:"expand",children:[new B6({left:W,top:0,width:J,height:E,child:LA1({introStages:A,stage:$,foreground:F,mutedForeground:Y,accent:Z,link:U,keybind:X,titleRevealProgress:$===0?1:G,dissolveProgress:V,context:z})}),new B6({left:I,top:0,width:J,height:E,child:LA1({introStages:A,stage:Q,foreground:F,mutedForeground:Y,accent:Z,link:U,keybind:X,titleRevealProgress:G,dissolveProgress:V,context:z})})]}))}function LA1({introStages:A,stage:Q,foreground:$,mutedForeground:B,accent:D,link:J,keybind:E,titleRevealProgress:F,dissolveProgress:Y,context:Z}){let U=A[Q]??A[0]??jA1[0],X=new T({color:D,bold:!0}),G=new T({color:$}),V=A===jA1&&Q===0,z=[...U.title===null?[]:[new d({text:V?$X0(Bg3({progress:F,foreground:D,pulseColor:D}),Y):new C(FB(U.title,Y),X),textAlign:"center"})],...U.body.length>0?[Qg3()]:[],...U.body.map((K)=>$g3(K,G,B,J,E,Y,Z))];return new $4({child:new f0({padding:V0.horizontal(1),child:new S0({crossAxisAlignment:"stretch",mainAxisAlignment:"center",mainAxisSize:"min",children:z})})})}function Qg3(){return X0.height(1)}function $g3(A,Q,$,B,D,J,E){if(typeof A==="string")return new d({text:new C(FB(A,J),Q),textAlign:"center"});if("codeBlock"in A)return new Z5({onCopy:(F,Y)=>{if(Y)M3.success(E,"Copied to clipboard",2000)},child:new S0({mainAxisSize:"min",children:A.codeBlock.map((F)=>new d({text:new C(FB(F,J),new T({color:D})),textAlign:"center",selectable:!0}))})});if("keybind"in A){let F=new d({text:new C("",void 0,[new C(FB(A.text,J),new T({color:$,dim:!0})),new C(FB(A.keybind,J,C4(A.text).length),new T({color:D}))]),textAlign:"center",selectable:"selectable"in A?A.selectable:!1});if("selectable"in A)return new $4({child:new Z5({child:F})});return F}if("highlightText"in A){let F=T6.createSpan(A.href,A.linkText,new T({color:B,underline:!0})),Y=hZ.of(E),Z=new C("",void 0,[new C(A.text,Q),new C(A.highlightText,new T({color:D})),new C(A.textAfterHighlight,Q),new C(F.text,F.style,F.children,F.hyperlink,()=>{i6(E,A.href,{forceExternal:!1,onShowImagePreview:Y})}),new C(A.textAfter,Q)]);return new d({text:$X0(Z,J),textAlign:"center"})}if("linkText"in A){if(A.linkWidget)return new S0({mainAxisSize:"min",children:[new d({text:new C(FB(A.text,J),Q),textAlign:"center"}),new $4({child:new r0({mainAxisSize:"min",children:[T6.createWidget(E,A.href,FB(A.linkText,J),new T({color:B,underline:!0})),new d({text:new C(FB(A.textAfter,J),Q)})]})})]});let F=T6.createSpan(A.href,A.linkText,new T({color:B,underline:!0})),Y=hZ.of(E),Z=new C("",void 0,[new C(A.text,Q),new C(F.text,F.style,F.children,F.hyperlink,()=>{i6(E,A.href,{forceExternal:!1,onShowImagePreview:Y})}),new C(A.textAfter,Q)]);return new d({text:$X0(Z,J),textAlign:"center"})}if(J>0)return new d({text:new C(FB(A.text,J),new T({color:B,underline:!0})),textAlign:"center"});return new $4({child:T6.createWidget(E,A.href,A.text,new T({color:B,underline:!0}))})}function Bg3({progress:A,foreground:Q,pulseColor:$}){let B=new T({color:Q,bold:!0}),D=new T({color:Jg3({progress:A,foreground:Q,pulseColor:$}),bold:!0});return new C("",void 0,[new C(Dg3(A).padEnd(RA1," "),B),new C(" ",B),new C(Gr4(Kr4,oh3,A,0.72),B),new C(" ",B),new C(Gr4(Ir4,rh3,A,0.88),D)])}function Dg3(A){let Q=C4(zr4),$=Math.min(RA1,Math.ceil(nJ(A/0.62)*RA1));return Q.slice(0,$).join("")}function Gr4(A,Q,$,B){return $>=B?A:"".padEnd(Q," ")}function Jg3({progress:A,foreground:Q,pulseColor:$}){if(A<0.88||A>=1)return Q;let B=nJ((A-0.88)/0.12);return Math.cos(B*Math.PI*4)*(1-B)>0.12?$:Q}function Eg3({stage:A,featureStageCount:Q,foreground:$,dissolveProgress:B}){return new C(FB(`${A}/${Q}`,B),new T({color:$,dim:!0}))}function Fg3({finalStage:A,dismissible:Q,foreground:$,keybind:B,revealProgress:D,dissolveProgress:J}){let E=new T({color:B}),F=new T({color:$,dim:!0}),Y=Q?A?"Enter":"Space":"Esc",Z=Q?A?" to get started":" to continue":" to quit, or use ",U=Q?"":"amp --take-me-back",X=Q?"":" to use the old version",G=`${Z}${U}${X}`;if(!Q)return new C("",void 0,[new C(Y,E),new C(Z,F),new C(U,E),new C(X,F)]);let V=Vr4(Y,D),z=Vr4(G,nJ((D*(C4(Y).length+C4(G).length)-C4(Y).length)/C4(G).length));return new C("",void 0,[new C(FB(V,J),E),new C(FB(z.slice(0,Z.length),J),F),new C(FB(z.slice(Z.length,Z.length+U.length),J),E),new C(FB(z.slice(Z.length+U.length),J),F)])}function Yg3({finalStage:A,dismissible:Q,foreground:$,keybind:B,revealProgress:D,dissolveProgress:J,context:E}){if(Q)return new d({text:Fg3({finalStage:A,dismissible:Q,foreground:$,keybind:B,revealProgress:D,dissolveProgress:J}),textAlign:"center"});let F=new T({color:B}),Y=new T({color:$,dim:!0});return new Z5({onCopy:(Z,U)=>{if(U)M3.success(E,"Copied to clipboard",2000)},child:new d({text:new C("",void 0,[new C("q",F),new C(" to quit, or use ",Y),new C("amp --take-me-back",F),new C(" to use the old version",Y)]),textAlign:"center",selectable:!0})})}function Vr4(A,Q){let $=C4(A),B=Math.min($.length,Math.ceil(nJ(Q)*$.length));return $.slice(0,B).join("").padEnd($.length," ")}function $X0(A,Q,$=0){if(Q<=0)return A;let B=$+C4(A.text??"").length,D=A.children?.map((J)=>{let E=$X0(J,Q,B);return B+=C4(J.toPlainText()).length,E});return new C(A.text?FB(A.text,Q,$):A.text,A.style,D,A.hyperlink,A.onClick)}function FB(A,Q,$=0){if(Q<=0)return A;return C4(A).map((D,J)=>{if(D.trim()==="")return D;return Nr4($+J)<Q?" ":D}).join("")}function Nr4(A){let Q=Math.sin((A+1)*12.9898)*43758.5453;return Q-Math.floor(Q)}i0();r2();function dN(A,Q){let{colors:$,dim:B}=Q,D=[];if(A.totalCostUSD===null)return D;let J=A.costBreakdown,E=J?.freeUSD??0,F=J?.paidUSD??0;if(E===0&&F===0)return D;let Z={decimalPlaces:"more-if-tiny",intent:"cost"};if(F===0)D.push(new C(SG(E,Z),new T({color:$.foreground,dim:B}))),D.push(new C(" (free)",new T({color:$.foreground,dim:B})));else if(E>0)D.push(new C(SG(E,Z),new T({color:$.foreground,dim:B}))),D.push(new C(" (free)",new T({color:$.foreground,dim:B}))),D.push(new C(" + ",new T({color:$.foreground,dim:B}))),D.push(new C(SG(F,Z),new T({color:$.foreground,dim:B,bold:!B})));else D.push(new C(SG(F,Z),new T({color:$.foreground,dim:B,bold:!B})));return D}class PA1 extends X4{}class _A1 extends X4{}function Zg3(A,Q){if(Q.code==="auth-required")return"You must be logged in to view thread usage. Run `amp login` first.";if(Q.code==="thread-not-found")return`Thread ${A} not found.`;return`Failed to load thread usage: ${Q.message??Q.code}`}function Ug3(A,Q){let $=O0.of(Q),{colors:B}=$,D=dN(A,{colors:{foreground:B.foreground}}),J=[];if(D.length>0)J.push(new C("Total: ",new T({color:B.mutedForeground}))),J.push(...D);else if(A.totalCostUSD===null)J.push(new C("Usage information is currently unavailable."));else J.push(new C("No usage recorded for this thread yet."));if(A.costBreakdownURL)J.push(new C(`
|
|
5315
5315
|
|
|
5316
|
-
`)),J.push(new C("Details: ",new T({color:B.mutedForeground}))),J.push(new C(A.costBreakdownURL,new T({color:$.app.link})));return new d({text:new C("",void 0,J)})}function Xg3(A,Q,$){let B=Ug3(A,Q);if(!A.costBreakdownURL)return new w6({header:"Thread Cost",minWidth:80,maxWidth:100,onDismiss:$,child:B});let D=A.costBreakdownURL,J=new T1(()=>{return y4.maybeInvoke(Q,new G8(D,"Cost breakdown URL copied to clipboard","Failed to copy cost breakdown URL")),"handled"}),E=new T1(()=>{return i6(Q,D),"handled"});return new w6({header:"Thread Cost",minWidth:80,maxWidth:100,autofocus:!1,footer:[{keys:["Esc"],label:"close"},{keys:["o"],label:"open in browser"},{keys:["y"],label:"copy url"}],onDismiss:$,child:new y4({actions:new Map([[PA1,J],[_A1,E]]),child:new TA({debugLabel:"ThreadCostShortcuts",shortcuts:new Map([[G1.key("o"),new _A1],[G1.key("y"),new PA1]]),child:new v4({autofocus:!0,debugLabel:"ThreadCostBody",child:B})})})})}function wr4(A){return{noun:"thread",verb:"show cost",description:"Show usage cost for the active thread",keywords:["usage","credits","billing","spend"],get status(){return A.getActiveThreadID()?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:async(Q,$,B)=>{let D=A.getActiveThreadID();if(!D)return;try{let J=await r4.threadDisplayCostInfo({threadID:D},{config:A.configService});if(!J.ok){A.toastController.show(Zg3(D,J.error),"error",5000),B();return}Q.push(Xg3(J.result,$,B))}catch(J){u.error("Failed to load Neo thread cost",{error:J,threadID:D}),A.toastController.show(`Failed to show thread cost: ${J instanceof Error?J.message:String(J)}`,"error",5000),B()}}}}i0();M9();Q4();class cK extends X4{direction;constructor(A){super();this.direction=A}}class BX0 extends X4{}class Ls extends X4{}class DX0 extends X4{index;constructor(A){super();this.index=A}}function TA1(A){return A.length+2}class vA1 extends u0{props;constructor(A){super();this.props=A}createState(){return new Cr4}}class Cr4 extends R0{selectedIndex=0;initState(){super.initState(),this.selectedIndex=this.findSelectableIndex(this.widget.props.initialSelectedIndex??0)}didUpdateWidget(A){this.selectedIndex=this.findSelectableIndex(this.selectedIndex)}isSelectable(A){let Q=this.widget.props.entries[A];return Q?.type==="item"&&(Q.enabled??!0)}findSelectableIndex(A){let{entries:Q}=this.widget.props;if(Q.length===0)return 0;let $=Math.max(0,Math.min(A,Q.length-1));if(this.isSelectable($))return $;for(let B=1;B<Q.length;B++){let D=$+B;if(D<Q.length&&this.isSelectable(D))return D;let J=$-B;if(J>=0&&this.isSelectable(J))return J}return 0}moveSelection(A){let Q=this.findNextSelectableIndex(A);if(Q===this.selectedIndex)return;this.setState(()=>{this.selectedIndex=Q})}findNextSelectableIndex(A){let{entries:Q}=this.widget.props;for(let $=this.selectedIndex+A;$>=0&&$<Q.length;$+=A)if(this.isSelectable($))return $;return this.selectedIndex}acceptIndex(A){let Q=this.widget.props.entries[A];if(Q?.type!=="item"||!(Q.enabled??!0))return;this.setState(()=>{this.selectedIndex=A}),this.widget.props.onAccept(Q.value)}invoke=(A)=>{if(A instanceof cK)return this.moveSelection(A.direction),"handled";if(A instanceof BX0)return this.acceptIndex(this.selectedIndex),"handled";if(A instanceof Ls)return this.widget.props.onDismiss(),"handled";if(A instanceof DX0)return this.acceptIndex(A.index),"handled";return"ignored"};buildShortcuts(){let A=new Map([[G1.key("ArrowDown"),new cK(1)],[G1.key("j"),new cK(1)],[G1.ctrl("n"),new cK(1)],[G1.key("ArrowUp"),new cK(-1)],[G1.key("k"),new cK(-1)],[G1.ctrl("p"),new cK(-1)],[G1.key("Enter"),new BX0],[G1.key("Escape"),new Ls],[G1.ctrl("."),new Ls]]);return this.widget.props.entries.forEach((Q,$)=>{if(Q.type==="item"&&Q.shortcut)A.set(Q.shortcut,new DX0($))}),A}buildActions(){return new Map([[cK,new T1(this.invoke)],[BX0,new T1(this.invoke)],[Ls,new T1(this.invoke)],[DX0,new T1(this.invoke)]])}build(A){let Q=O0.of(A),$=Gg3(this.widget.props.entries,l1.of(A).supportsEmojiWidth);return new b0({width:this.widget.props.width,height:TA1(this.widget.props.entries),decoration:new R4(Q.colors.background,m1.all(new d1(Q.colors.border,1,"solid"))),child:new y4({actions:this.buildActions(),child:new TA({debugLabel:"NeoContextPickerShortcuts",shortcuts:this.buildShortcuts(),child:new v4({autofocus:!0,debugLabel:"NeoContextPicker",child:new S0({mainAxisSize:"min",crossAxisAlignment:"stretch",children:this.widget.props.entries.map((B,D)=>this.buildEntry(B,D,$,Q))})})})})})}buildEntry(A,Q,$,B){if(A.type==="separator")return new b0({height:1,decoration:{border:new m1(new d1(B.colors.border,1,"solid"))}});let D=Q===this.selectedIndex,J=A.enabled??!0,E=new T({color:D?B.app.selectionForeground:B.colors.foreground,dim:!J}),F=new T({color:D?B.app.selectionForeground:B.app.keybind,bold:!0,dim:!J});return new j1({onClick:()=>this.acceptIndex(Q),child:new b0({padding:V0.symmetric(1,0),decoration:D?new R4(B.app.selectionBackground):void 0,child:new r0({crossAxisAlignment:"start",children:[new R1({child:new d({text:new C(A.label,E),maxLines:1,overflow:"ellipsis"})}),new X0({width:1}),new X0({width:$,child:new d({text:new C(Mr4(A),F),textAlign:"right",maxLines:1,overflow:"ellipsis"})})]})})})}}function Gg3(A,Q){return A.reduce(($,B)=>{return B.type==="item"?Math.max($,L4(Mr4(B),Q)):$},0)}function Mr4(A){return A.shortcutLabel??A.shortcut?.toString().toLowerCase()??""}var Vg3=36,zg3=24,Kg3=72;class Lr4 extends u0{child;onContext;constructor(A,Q){super();this.child=A;this.onContext=Q}createState(){return new Or4}}class Or4 extends R0{build(A){return this.widget.onContext(A),this.widget.child}}function jr4(A){return A.replace(/ ago$/,"")}function JX0(A){return A.reduce((Q,$)=>Math.max(Q,L4(jr4($.description.timeAgo))),0)}function Rr4(A){return Math.max(zg3,Math.min(A,Kg3))}class kA1 extends X4{}class SA1 extends X4{}class fA1{options;visibility;width=Vg3;constructor(A){this.options=A;this.visibility=new so(A.state)}isVisible(){return this.visibility.isEnabled()}buildBody(A){return new r0({crossAxisAlignment:"stretch",children:[this.buildSlot(),new R1({child:A})]})}buildSlot(){if(!this.options.isAvailable()||this.visibility.isDisabled())return new X0({width:0});return new X0({width:this.width,child:new h4({debugLabel:"ThreadListSidebar",child:new ur4({activeThreadID:this.options.getActiveThreadID(),currentWorkspaceURI:s1(l0.file(this.options.getWorkspaceRoot())),width:this.width,loadThreads:this.options.loadThreads,onSelectThread:this.options.onSelectThread,onDismiss:this.close,onResizeWidth:this.resize})})})}commands(){if(!this.options.isAvailable())return[];return[{noun:"thread",verb:"toggle sidebar",description:"Show or hide the thread sidebar",keywords:["sidebar","recent","history","threads"],shortcut:G1.alt("s"),status:{type:"enabled"},run:(A,Q,$)=>{$(),this.toggle()}}]}shortcutEntries(){return this.options.isAvailable()?[[G1.alt("s"),new YU0]]:[]}actionEntries(){if(!this.options.isAvailable())return[];return[[YU0,new T1(()=>this.toggle())]]}toggle=()=>{if(!this.options.isAvailable())return"ignored";if(this.visibility.isDisabled()&&this.options.isBlocked())return"ignored";return this.visibility.toggle(),"handled"};close=()=>{this.visibility.disable()};resize=(A)=>{let Q=Rr4(A);if(Q===this.width)return;this.options.state.setState(()=>{this.width=Q})}}class ur4 extends u0{props;constructor(A){super();this.props=A}createState(){return new Pr4}}class Pr4 extends R0{threads=[];isLoading=!0;isSwitchingThread=!1;hasError=!1;filterByWorkspace=!0;timeColWidth=0;contextMenu=null;pendingThreadMutations=new Map;resizeSession=null;isResizeHandleHovered=!1;pickerController=new Kr;threadItemContexts=new Map;shortcuts=new Map([[G1.alt("w"),new kA1],[G1.ctrl("."),new SA1]]);actions=new Map([[kA1,new T1(()=>{return this.setState(()=>{this.filterByWorkspace=!this.filterByWorkspace,this.contextMenu=null}),"handled"})],[SA1,new T1(()=>this.openContextMenu())]]);get isBusy(){return this.isLoading||this.isSwitchingThread}get isResizeActive(){return this.resizeSession!==null||this.isResizeHandleHovered}didUpdateWidget(A){if(this.contextMenu&&(A.props.width!==this.widget.props.width||A.props.currentWorkspaceURI!==this.widget.props.currentWorkspaceURI))this.contextMenu=null}initState(){super.initState(),this.loadThreadSummaries()}async loadThreadSummaries(){try{let A=await this.widget.props.loadThreads(),Q=M61(A);if(!this.mounted)return;this.setState(()=>{this.pickerController.selectedItem=Q.find(($)=>$.id===this.widget.props.activeThreadID)??null,this.threads=Q,this.timeColWidth=JX0(Q),this.isLoading=!1,this.hasError=!1})}catch(A){if(u.error("Failed to load threads for Neo sidebar",{error:A}),!this.mounted)return;this.setState(()=>{this.isLoading=!1,this.hasError=!0})}}handleSelectThread=async(A)=>{if(this.isSwitchingThread)return;this.setState(()=>{this.isSwitchingThread=!0});try{await this.widget.props.onSelectThread(A),this.widget.props.onDismiss()}catch(Q){u.error("Failed to switch thread from Neo sidebar",{error:Q,threadID:A})}finally{if(this.mounted)this.setState(()=>{this.isSwitchingThread=!1})}};getOptimisticThreads(){return this.threads.flatMap((A)=>{if(this.pendingThreadMutations.get(A.id)?.kind==="archive")return[];return[A]})}getThreadsForDisplay(){let A=this.getOptimisticThreads();return this.filterByWorkspace?A.filter((Q)=>!Q.workspaceURI||Q.workspaceURI===this.widget.props.currentWorkspaceURI):A}buildContextMenuEntries(){return[{type:"item",value:"archive",label:"Archive Thread",shortcut:G1.key("a"),shortcutLabel:"a"},{type:"separator"},{type:"item",value:"copy-id",label:"Copy ID",shortcut:G1.ctrl("c"),shortcutLabel:"ctrl+c"},{type:"item",value:"copy-url",label:"Copy URL",shortcut:new G1("c",{shift:!0,ctrl:!0}),shortcutLabel:"shift+ctrl+c"}]}openContextMenu(){let A=this.pickerController.selectedItem;if(!A||this.isBusy||this.hasError)return"ignored";let Q=this.buildContextMenuEntries(),$=TA1(Q),B=this.getContextMenuWidth(),D=this.getContextMenuPosition(A.id,$,B);return this.setState(()=>{this.contextMenu={threadID:A.id,left:D.left,top:D.top,width:B,height:$}}),"handled"}getContextMenuWidth(){let A=Math.max(24,this.widget.props.width-3);return Math.max(1,Math.min(A,this.widget.props.width-2))}getContextMenuPosition(A,Q,$){let B=Math.max(0,Math.min(2,this.widget.props.width-$)),D=1,J=this.threadItemContexts.get(A)?.findRenderObject(),E=this.context.findRenderObject();if(!(J instanceof t1)||!(E instanceof t1))return{left:B,top:1};let F=J.localToGlobal({x:0,y:0}),Y=E.localToGlobal({x:0,y:0}),Z=F.y-Y.y,U=Z+J.size.height,X=l1.sizeOf(this.context).height,G=Math.max(1,Math.min(E.size.height,X-Y.y)),K=G-U>=Q||Z<G/2?U:Z-Q,I=Math.max(0,G-Q);return{left:B,top:Math.max(0,Math.min(K,I))}}closeContextMenu=()=>{if(!this.contextMenu)return;this.setState(()=>{this.contextMenu=null})};handleContextMenuAccept=(A)=>{let Q=this.contextMenu?.threadID;if(!Q)return;if(this.closeContextMenu(),A==="archive"){this.archiveContextMenuThread(Q);return}if(A==="copy-id"){y4.maybeInvoke(this.context,new G8(Q,"Thread ID copied to clipboard","Failed to copy thread ID"));return}y4.maybeInvoke(this.context,new G8(this.getThreadURL(Q),"Thread URL copied to clipboard","Failed to copy thread URL"))};beginOptimisticArchive(A){if(this.pendingThreadMutations.has(A))return!1;if(!this.threads.some(($)=>$.id===A))return!1;let Q={kind:"archive",fallbackSelectedThreadID:null};return this.setState(()=>{this.pendingThreadMutations.set(A,Q),this.timeColWidth=JX0(this.getOptimisticThreads())}),h6.instance.addPostFrameCallback(()=>{if(!this.mounted)return;let $=this.pendingThreadMutations.get(A);if($?.kind!=="archive")return;$.fallbackSelectedThreadID=this.pickerController.selectedItem?.id??null}),!0}commitOptimisticArchive(A){if(this.pendingThreadMutations.get(A)?.kind!=="archive")return;this.pendingThreadMutations.delete(A),this.threads=this.threads.filter(($)=>$.id!==A),this.timeColWidth=JX0(this.getOptimisticThreads())}rollbackOptimisticArchive(A){let Q=this.pendingThreadMutations.get(A);if(Q?.kind!=="archive")return;let $=this.threads.find((B)=>B.id===A);if(!$){this.pendingThreadMutations.delete(A);return}this.setState(()=>{this.pendingThreadMutations.delete(A),this.timeColWidth=JX0(this.getOptimisticThreads());let B=this.pickerController.selectedItem?.id??null;if(B===null||B===Q.fallbackSelectedThreadID)this.pickerController.selectedItem=$})}async archiveContextMenuThread(A){let Q=M3.maybeOf(this.context),{configService:$}=X5.of(this.context);if(!this.beginOptimisticArchive(A))return;try{let B=await GZ0({configService:$},A);if(!this.mounted)return;if(B){this.rollbackOptimisticArchive(A),Q?.show(B.message,"error");return}this.commitOptimisticArchive(A)}catch(B){if(u.error("Failed to archive thread from Neo sidebar context menu",{error:B,threadID:A}),!this.mounted)return;this.rollbackOptimisticArchive(A),Q?.show("Failed to archive thread","error")}}getThreadURL(A){return u$(new URL(X5.of(this.context).ampURL),A).toString()}buildContextMenuOverlay(){let A=this.contextMenu;if(!A||!this.getThreadsForDisplay().some((Q)=>Q.id===A.threadID))return null;return new B6({left:A.left,top:A.top,width:A.width,height:A.height,child:new h4({debugLabel:"ThreadListSidebarContextMenu",onFocusChange:(Q)=>{if(!Q)this.closeContextMenu()},child:new vA1({entries:this.buildContextMenuEntries(),width:A.width,onAccept:this.handleContextMenuAccept,onDismiss:this.closeContextMenu})})})}buildContextMenuBackdrop(){return new B6({left:0,top:0,right:0,bottom:0,child:new j1({onClick:()=>this.closeContextMenu(),child:X0.expand()})})}buildThreadItem(A,Q,$,B){let D=O0.of(B),{app:J,colors:E}=D,F=!Q,Y=Q?J.selectionForeground:E.foreground,Z=Q?J.selectionForeground:E.mutedForeground,X=A.id===this.widget.props.activeThreadID?new d({text:new C("*",new T({color:Q?J.selectionForeground:E.success,dim:F}))}):void 0,G=jr4(A.description.timeAgo);return new Lr4(new b0({padding:V0.symmetric(1,0),child:new r0({children:[new X0({width:2,child:X}),new R1({child:new d({text:new C(A.title,new T({color:Y,dim:F})),overflow:"ellipsis",maxLines:1})}),new X0({width:2}),new X0({width:$,child:r0.end([new d({text:new C(G,new T({color:Z,dim:F}))})])})]})}),(V)=>{this.threadItemContexts.set(A.id,V)})}handleResizeHandlePress=(A)=>{if(A.button!=="left")return;this.setState(()=>{this.resizeSession={baseWidthColumns:this.widget.props.width,startColumn:Math.floor(A.position.x)}})};handleResizeHandleDrag=(A)=>{if(A.button!=="left"||this.resizeSession===null)return;let Q=Math.floor(A.position.x)-this.resizeSession.startColumn,$=Rr4(this.resizeSession.baseWidthColumns+Q);if($!==this.widget.props.width)this.widget.props.onResizeWidth($)};handleResizeHandleRelease=(A)=>{if(A.button!=="left"||this.resizeSession===null)return;this.setState(()=>{this.resizeSession=null})};handleResizeHandleEnter=()=>{if(this.isResizeHandleHovered)return;this.setState(()=>{this.isResizeHandleHovered=!0})};handleResizeHandleExit=()=>{if(!this.isResizeHandleHovered)return;this.setState(()=>{this.isResizeHandleHovered=!1})};buildResizeHandle(){return new B6({top:0,right:0,bottom:0,width:1,child:new j1({cursor:FA.EW_RESIZE,onClick:this.handleResizeHandlePress,onDrag:this.handleResizeHandleDrag,onRelease:this.handleResizeHandleRelease,onEnter:this.handleResizeHandleEnter,onExit:this.handleResizeHandleExit,child:new X0({width:1})})})}build(A){let Q=O0.of(A),$=this.getThreadsForDisplay(),B=this.hasError?[]:$;this.threadItemContexts.clear();let D=this.isSwitchingThread?"Switching thread...":"Loading threads...",J=this.hasError?"Failed to load threads":"No threads match your filter",E=this.isResizeActive?2:1,F=new m1(void 0,new d1(Q.colors.border,E),void 0,void 0),Y=this.buildContextMenuOverlay(),Z=[new b0({decoration:new R4(Q.colors.background,F),child:new y4({actions:this.actions,child:new TA({shortcuts:this.shortcuts,debugLabel:"ThreadListSidebarFilter",child:new pA({items:B,getLabel:(U)=>`${U.title} ${U.id}`,controller:this.pickerController,onAccept:(U)=>void this.handleSelectThread(U.id),onDismiss:this.widget.props.onDismiss,renderItem:(U,X,G,V)=>this.buildThreadItem(U,X,this.timeColWidth,V),enabled:!this.isBusy,isLoading:this.isBusy,hidePromptWhenLoading:!0,loadingText:D,emptyStateText:J,maxRenderItems:200,showBorder:!1})})})}),this.buildResizeHandle()];if(Y)Z.push(this.buildContextMenuBackdrop()),Z.push(Y);return new b0({width:this.widget.props.width,child:new t4({fit:"expand",children:Z})})}}class yA1 extends u0{listSkillsForThread;clientPool;completionBuilder;history;ideManager;configService;updateService;initialThreadIDs;showNeoWelcome;neoWelcomeVariant;onNeoWelcomeDismissed;notificationService;mcpTrustHandler;onThreadArchived;onActiveThreadChange;onRelaunchRequested;onFirstFrame;initialUserInput;getDefaultNewThreadVisibility;openThreadPickerOnStart;workspaceSettingsFilePath;neoContext;constructor(A){super();this.listSkillsForThread=A.listSkillsForThread,this.clientPool=A.clientPool,this.completionBuilder=A.completionBuilder,this.history=A.history,this.ideManager=A.ideManager,this.configService=A.configService,this.updateService=A.updateService,this.initialThreadIDs=A.initialThreadIDs??[],this.showNeoWelcome=A.showNeoWelcome??!1,this.neoWelcomeVariant=A.neoWelcomeVariant??"intro",this.onNeoWelcomeDismissed=A.onNeoWelcomeDismissed,this.notificationService=A.notificationService,this.mcpTrustHandler=A.mcpTrustHandler,this.onThreadArchived=A.onThreadArchived,this.onActiveThreadChange=A.onActiveThreadChange,this.onRelaunchRequested=A.onRelaunchRequested,this.onFirstFrame=A.onFirstFrame,this.initialUserInput=A.initialUserInput,this.getDefaultNewThreadVisibility=A.getDefaultNewThreadVisibility,this.openThreadPickerOnStart=A.openThreadPickerOnStart??!1,this.workspaceSettingsFilePath=A.workspaceSettingsFilePath,this.neoContext=A.neoContext}createState(){return new Tr4}}class Tr4 extends R0{editorController=new u2;commandPalette=new so(this);commandRegistry=new y41;toastController=new te0;relaunchNotificationController=new R41;exitHintTimer=new ro(this,1000);ideStatus=new Z8(this,{});threadNavigationHistory=new T41;draftThreadSettings={};draftThreadSettingsSeed={};hasDraftThreadSettingsSeed=!1;draftThreadSettingsInitPromise=null;activeThreadContext=null;activeThreadIDSubscription=null;connectionErrorsSubscription=null;configSubscription=null;connectingToThreadID=null;executorAlreadyConnectedDialog=null;switchThreadPickerVisible=!1;neoWelcomeVisible=!1;debugOverlayVisible=!1;focusDebugVisible=!1;unregisterCommands=null;pluginIntegration=null;mcpTrustIntegration=null;updateRelaunchIntegration=null;noticesPollingTimeout=null;notices;loadThreads=async()=>{return this.widget.neoContext.listThreads()};analyzeContextForThread=async(A,Q)=>{return ih4({ampURL:this.widget.neoContext.ampURL,configService:this.widget.configService,threadID:A,signal:Q})};onSwitchThread=(A)=>{return this.connectToExistingThread(A,{recordNavigation:!0,rethrowError:!0})};threadListSidebar=new fA1({state:this,isAvailable:()=>this.widget.neoContext.isInternalUser,isBlocked:()=>this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal(),getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??null,getWorkspaceRoot:()=>this.widget.neoContext.workspaceRoot,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread});sendFeedbackReport=async(A)=>NU0({configService:this.widget.configService,settingsFilePath:this.widget.neoContext.settingsFilePath},A);archiveThread=async(A)=>{let Q=await GZ0({configService:this.widget.configService},A);if(Q===null)this.widget.onThreadArchived?.(A);return Q};addThreadLabel=async(A,Q)=>{let $=await ed4({configService:this.widget.configService},A,Q);if($ instanceof Error)return $;return this.toastController.show($.message,$.type,2000),null};removeThreadLabel=async(A,Q)=>{let $=await Ap4({configService:this.widget.configService},A,Q);if($ instanceof Error)return $;return this.toastController.show($.message,$.type,2000),null};initState(){if(e$.getInstance().interceptConsole(),this.notices=new V41(this.widget.configService,($)=>this.setState($)),h6.instance.addPostFrameCallback(()=>{setTimeout(()=>this.widget.onFirstFrame?.(),0),this.noticesPollingTimeout=setTimeout(()=>{this.noticesPollingTimeout=null,this.notices.startPolling()},500)},"Neo notices polling"),this.widget.showNeoWelcome)this.neoWelcomeVisible=!0;if(this.connectionErrorsSubscription=this.widget.clientPool.connectionErrors$.subscribe(({threadID:$,error:B})=>{if(u.error("Neo failed to connect to thread",{threadID:$,error:B}),!$)this.toastController.show(`Connection failed: ${B.message}`,"error",4000)}),this.configSubscription=this.widget.configService.config.subscribe(($)=>{this.applyDraftThreadSettingsSeed(this.applySessionDefaultsToThreadSettings(R50($.settings)))}),this.updateRelaunchIntegration=new P41({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested,relaunchNotificationController:this.relaunchNotificationController,updateService:this.widget.updateService}),this.updateRelaunchIntegration.init(),this.ideStatus.subscribe(this.widget.ideManager.status),this.widget.openThreadPickerOnStart)this.switchThreadPickerVisible=!0;this.ensureDraftThreadSettingsInitialized();let A=this.widget.initialUserInput,Q=this.widget.initialThreadIDs[0];if(Q){let $={};if(A)$.initialUserInput=A;this.connectToInitialThreads(Q,$)}else if(A)this.onNewThread([{type:"text",text:A}],this.widget.neoContext.sessionAgentMode);this.pluginIntegration=new j41({state:this,commandPalette:this.commandPalette,commandRegistry:this.commandRegistry,toastController:this.toastController,neoContext:this.widget.neoContext,getActiveThreadID:this.getActiveThreadID,appendToThread:this.appendPluginMessagesToThread}),this.pluginIntegration.init(),this.mcpTrustIntegration=new G41({state:this,mcpTrustHandler:this.widget.mcpTrustHandler,toastController:this.toastController,workspaceSettingsFilePath:this.widget.workspaceSettingsFilePath}),this.mcpTrustIntegration.init(),this.unregisterCommands=this.registerAppCommands(),queueMicrotask(()=>{if(!this.mounted)return;this.replayEarlyInputToEditor()})}replayEarlyInputToEditor(){let A=H4.instance.tuiInstance.getEarlyInputText();if(!A)return;this.editorController.insertText(A)}registerAppCommands(){let A=this,Q=this.widget.neoContext.pluginService?Ei4({pluginService:this.widget.neoContext.pluginService,workspaceRoot:this.widget.neoContext.workspaceRoot,logFilePath:this.widget.neoContext.logFilePath,toastController:this.toastController}):[],B=[zi4({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested}),{noun:"thread",verb:"switch",description:"Switch to existing thread",keywords:["recent","history","open","resume","change"],status:{type:"enabled"},sortBoost:100,run:(D,J,E)=>{D.pushWithDismiss((F)=>L61({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:F,onThreadSelected:E}))}},...this.threadListSidebar.commands(),{noun:"thread",verb:"switch to previous",description:"Switch to previous thread",keywords:["back"],get status(){return A.threadNavigationHistory.canNavigateBack()?{type:"enabled"}:{type:"disabled",reason:"Cannot use thread: switch to previous with no previous thread"}},run:(D,J,E)=>{A.navigateBack(),E()}},wr4({configService:this.widget.configService,getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??void 0,toastController:this.toastController}),{noun:"thread",verb:"switch to next",description:"Switch to next thread",keywords:["forward"],get status(){return A.threadNavigationHistory.canNavigateForward()?{type:"enabled"}:{type:"disabled",reason:"Cannot use thread: switch to next with no next thread"}},run:(D,J,E)=>{A.navigateForward(),E()}},{noun:"mcp",verb:"info",description:"Show MCP servers and tools",keywords:["servers","tools","plugins","integrations"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new a41({mcpServers:this.widget.neoContext.mcpServers,onDismiss:E}))}},{noun:"toolbox",verb:"list",description:"List all toolboxes and their tools",keywords:["tools","toolbox"],status:{type:"enabled"},run:(D)=>{D.pushWithDismiss((J)=>new CA1({toolboxes:this.widget.neoContext.toolboxes,onDismiss:J}))}},{noun:"news",verb:"open",description:"Open Amp Chronicle in browser",keywords:["chronicle","updates","blog","announcements"],status:{type:"enabled"},run:async(D,J,E)=>{try{await i6(J,"https://ampcode.com/chronicle")}finally{E()}}},{noun:"settings",verb:"open in editor",description:"Open CLI settings in $EDITOR",keywords:["config","preferences","edit"],status:{type:"enabled"},run:()=>{eQ(this.widget.neoContext.settingsFilePath).catch((D)=>{u.error("Failed to open settings file in editor",{error:D})})}},{noun:"IDE",verb:"connect",description:"Connect to an IDE",keywords:["vscode","cursor","jetbrains","editor","attach"],status:{type:"enabled"},run:(D,J,E)=>{D.pushWithDismiss((F)=>new i41({onCancel:F,onSelect:(Y)=>{this.handleIdeSelection(Y),E()}}))}},{noun:"amp",verb:"help",description:"Show help & keyboard shortcuts",keywords:["shortcuts","keybindings","docs","manual","?"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new m41({commands:W9.of(J).commands,onDismiss:E}))}},{noun:"amp",verb:"show welcome",description:"Show the welcome message again",keywords:["intro","onboarding","getting started"],status:{type:"enabled"},run:(D,J,E)=>{E(),A.showNeoWelcome()}},{noun:"amp",verb:"show version",description:"Show current Amp version",keywords:["about","release","build"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new w6({header:"Amp Version",maxWidth:72,onDismiss:E,child:new d({text:new C(gY0({version:"0.0.1779179243-g4e6089",buildTimestamp:"2026-05-19T08:32:48.320Z",buildType:"release"}))})}))}},{noun:"amp",verb:"quit",description:"Exit application",keywords:["exit","close","leave","bye"],shortcut:G1.ctrl("c"),status:{type:"enabled"},run:(D,J)=>{y4.maybeInvoke(J,new Zy)}},...Q,...dl4(this.widget.neoContext.logFilePath)].map((D)=>this.commandRegistry.register(D));return()=>{for(let D of B)D()}}build(A){let Q=this.buildHints(),$=this.ideStatus.getValue(),B=this.notices.current,D=new wA1({initialAgentMode:this.widget.neoContext.sessionAgentMode,analyzeContextForThread:this.analyzeContextForThread,listSkillsForThread:this.widget.listSkillsForThread,threadContext:this.activeThreadContext,draftThreadSettings:this.draftThreadSettings,editorController:this.editorController,history:this.widget.history,updateDraftThreadSettings:this.updateDraftThreadSettings,onNewThread:this.onNewThread,sendFeedbackReport:this.sendFeedbackReport,archiveThread:this.archiveThread,addThreadLabel:this.addThreadLabel,removeThreadLabel:this.removeThreadLabel,configService:this.widget.configService,hints:Q,ideStatus:$,statusItems:this.pluginIntegration?.getStatusItems()??[],notificationService:this.widget.notificationService,notice:this.activeThreadContext||this.neoWelcomeVisible?null:B,onDismissNotice:(U)=>this.notices.dismiss(U)}),J=l1.of(A),E=J.capabilities.animationSupport!=="disabled",Y=[new b0({constraints:M1.tight(J.size.width,J.size.height),child:this.threadListSidebar.buildBody(D)})];if(this.commandPalette.isEnabled())Y.push(new h4({debugLabel:"CommandPaletteOverlay",onFocusChange:this.closeCommandPaletteOnFocusLoss,child:new x41({onDismiss:this.commandPalette.disable})}));if(this.switchThreadPickerVisible&&!this.neoWelcomeVisible)Y.push(L61({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:this.closeSwitchThreadPicker,onThreadSelected:this.closeSwitchThreadPicker}));if(this.neoWelcomeVisible)Y.push(new h4({debugLabel:"NeoWelcomeDialogOverlay",child:new uA1({onDismiss:this.dismissNeoWelcome,onQuit:()=>H4.instance.stop(),animationsEnabled:E,variant:this.widget.neoWelcomeVariant})}));let Z=this.executorAlreadyConnectedDialog;if(Z)Y.push(new h4({debugLabel:"NeoExecutorAlreadyConnectedDialogOverlay",child:new c41({existingExecutorPid:Z.existingExecutorPid,onChoice:this.handleExecutorAlreadyConnectedChoice})}));if(Y.push(...this.mcpTrustIntegration?.buildDialogLayers()??[]),Y.push(...this.pluginIntegration?.buildDialogLayers()??[]),this.widget.neoContext.isInternalUser)Y.push(new p41({top:this.focusDebugVisible?33:1,visible:this.debugOverlayVisible,pid:EX0.pid,activeThreadID:this.activeThreadContext?.client.getThreadId()??null,connectionInfo$:this.activeThreadContext?.observer.connectionInfo()??null}));if(this.focusDebugVisible)Y.push(new l41);return new X5({neoContext:this.widget.neoContext,child:new W9({commandRegistry:this.commandRegistry,child:new Gy({completionBuilder:this.widget.completionBuilder,child:new M3({controller:this.toastController,child:new y4({actions:this.buildActions(),child:new TA({debugLabel:"NeoAppShortcuts",shortcuts:this.buildShortcuts(),child:new v4({debugLabel:"AppShellFocus",child:new ee0({controller:this.toastController,complexToastControllers:[this.relaunchNotificationController,...B&&this.activeThreadContext&&!this.neoWelcomeVisible?[this.notices]:[]],child:new d41({configReloadEvents:this.widget.configService.configReloadEvents,toastController:this.toastController,child:new t4({children:Y})})})})})})})})})})}buildShortcuts(){let A=new Map([[G1.ctrl("c"),new BU0],[G1.ctrl("o"),new JU0],[G1.alt("i"),new FU0],[G1.alt("p"),new IN],[G1.ctrl("."),new UU0],[G1.ctrl("t"),new VU0],...this.threadListSidebar.shortcutEntries()]);if(EX0.env.NODE_ENV==="development"&&EX0.platform==="darwin")A.set(G1.meta("r"),new DU0);return A}buildActions(){let A=new T1(()=>{if(WD.hasAnyCopyableSelection())return WD.tryCopyAnyActiveSelection(),"handled";return this.onExitPressed(),"handled"}),Q=new T1(()=>{if(!this.commandPalette.isEnabled()&&this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.toggle(),"handled"}),$=new T1(()=>{if(this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.enable(),"handled"}),B=new T1(()=>{return this.startNewDraftThread(),"handled"}),D=new T1(()=>{return H4.instance.stop(),"handled"}),J=new T1(()=>{return Ds({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested}),"handled"}),E=new T1((G)=>{if(!G.text)return"ignored";return H4.instance.tuiInstance.clipboard.writeText(G.text).then((V)=>{if(V.ok)this.toastController.show(G.successMessage,"success",2000);else this.toastController.show(`${G.failureMessage}: ${V.userFacingErrorMessage}`,"error",4000)}).catch((V)=>{u.error("Failed to copy Neo text to clipboard",{error:V}),this.toastController.show(G.failureMessage,"error",2000)}),"handled"}),F=new T1(()=>{return H4.instance.toggleFrameStatsOverlay(),"handled"}),Y=new T1(()=>this.notices.dismissCurrent()?"handled":"ignored"),Z=new T1(()=>{if(!this.widget.neoContext.isInternalUser)return"ignored";return this.setState(()=>{this.debugOverlayVisible=!this.debugOverlayVisible}),"handled"}),U=Oi4({getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??null,neoContext:this.widget.neoContext,toastController:this.toastController,startNewDraftThread:this.startNewDraftThread,sendFeedbackReport:this.sendFeedbackReport}),X=new T1(()=>{return this.setState(()=>{this.focusDebugVisible=!this.focusDebugVisible}),"handled"});return new Map([[BU0,A],[ar,B],[Zy,D],[DU0,J],[G8,E],[tr,$],[JU0,Q],[FU0,Z],...this.threadListSidebar.actionEntries(),[UU0,Y],...U,[IN,F],[VU0,X]])}startNewDraftThread(A={}){let Q=this.activeThreadContext?.client.getThreadId();if(this.commandPalette.disable(),this.threadNavigationHistory.recordNavigation(Q),this.setState(()=>{if(this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=null,this.activeThreadContext=null,this.connectingToThreadID=null,A.hideDebugOverlay)this.debugOverlayVisible=!1}),this.widget.onActiveThreadChange?.(null),A.prompt!==void 0)this.editorController.text=A.prompt}closeCommandPaletteOnFocusLoss=(A)=>{if(A||!this.commandPalette.isEnabled())return;this.commandPalette.disable()};ensureDraftThreadSettingsInitialized(){if(this.hasDraftThreadSettingsSeed)return Promise.resolve();if(!this.draftThreadSettingsInitPromise)this.draftThreadSettingsInitPromise=this.initDraftThreadSettings();return this.draftThreadSettingsInitPromise}async initDraftThreadSettings(){try{let A=this.applySessionDefaultsToThreadSettings(await Mf(this.widget.configService));this.applyDraftThreadSettingsSeed(A)}catch(A){u.warn("Failed to initialize Neo draft thread settings",{error:A instanceof Error?A.message:String(A)})}}applySessionDefaultsToThreadSettings(A){let Q=this.widget.neoContext.sessionAgentMode,$=A,B=AB(Q),D=RY0(this.widget.neoContext,Q);if(B!==void 0&&D!==void 0)$={...$,[B]:D};return jY0($,{agentMode:Q,explicitEffort:this.widget.neoContext.explicitReasoningEffort,sessionState:this.widget.neoContext})}applyDraftThreadSettingsSeed(A){if(!this.mounted)return;if(!this.hasDraftThreadSettingsSeed){this.setState(()=>{this.hasDraftThreadSettingsSeed=!0,this.draftThreadSettings=_r4(this.draftThreadSettings,{},A),this.draftThreadSettingsSeed={...A}});return}if(vE(this.draftThreadSettingsSeed,A))return;this.setState(()=>{this.draftThreadSettings=_r4(this.draftThreadSettings,this.draftThreadSettingsSeed,A),this.draftThreadSettingsSeed={...A}})}buildHints(){let A=new Set;if(this.connectingToThreadID)A.add(vN);if(this.exitHintTimer.isActive())A.add(Dy);return A}onExitPressed=()=>{if(this.exitHintTimer.isActive())this.exitHintTimer.clear(),H4.instance.stop();else this.exitHintTimer.activate()};dismissNeoWelcome=()=>{if(!this.neoWelcomeVisible)return;this.setState(()=>{this.neoWelcomeVisible=!1}),this.widget.onNeoWelcomeDismissed?.()};showNeoWelcome=()=>{if(this.neoWelcomeVisible)return;this.setState(()=>{this.neoWelcomeVisible=!0})};promptExecutorAlreadyConnected(A){return new Promise((Q)=>{this.setState(()=>{this.executorAlreadyConnectedDialog={existingExecutorPid:A.existingExecutorPid,resolve:($)=>{Q($==="watch"?"observe":"disconnect")}}})})}handleExecutorAlreadyConnectedChoice=(A)=>{if(this.resolveExecutorAlreadyConnectedDialog(A),A==="exit")H4.instance.stop()};resolveExecutorAlreadyConnectedDialog(A){let Q=this.executorAlreadyConnectedDialog;if(!Q)return;this.setState(()=>{this.executorAlreadyConnectedDialog=null}),Q.resolve(A)}closeSwitchThreadPicker=()=>{if(!this.switchThreadPickerVisible)return;this.setState(()=>{this.switchThreadPickerVisible=!1})};updateDraftThreadSettings=(A)=>{this.setState(()=>{this.draftThreadSettings=A(this.draftThreadSettings)})};onNewThread=async(A,Q,$=null,B)=>{await this.ensureDraftThreadSettingsInitialized();let D=this.activeThreadContext?.client.getThreadId(),J=A.find(H50);if(J)this.widget.history.add(J.text,EX0.cwd()),this.widget.history.reset();let E=$?void 0:await this.widget.getDefaultNewThreadVisibility?.(),F=$??E??null,Y=this.widget.clientPool.createNewThread(Q,this.draftThreadSettings,F??void 0);this.sendUserMessage(Y,A,Q,B),this.rememberSessionDefaultsForNewMessage(Q,this.draftThreadSettings),this.threadNavigationHistory.recordNavigation(D),this.setActiveClient(Y)};rememberSessionDefaultsForNewMessage(A,Q){this.widget.neoContext.sessionAgentMode=A;let $=Q["reasoning.effort"];if($!==void 0)this.widget.neoContext.lastReasoningEffortByMode={...this.widget.neoContext.lastReasoningEffortByMode??{},[A]:$};let B=AB(A),D=B?Q[B]:void 0;if(D!==void 0)this.widget.neoContext.lastSpeedByMode={...this.widget.neoContext.lastSpeedByMode??{},[A]:D};tQ((J)=>{let E={...J,agentMode:A};if($!==void 0)E={...E,lastReasoningEffortByMode:{...E.lastReasoningEffortByMode??{},[A]:$}};if(D!==void 0)E={...E,lastSpeedByMode:{...E.lastSpeedByMode??{},[A]:D}};return E}).catch((J)=>{u.warn("Failed to persist Neo session defaults for new message",{error:J instanceof Error?J.message:String(J)})})}sendUserMessage(A,Q,$,B){let D=CJ0(this.ideStatus.getValue());if(B===void 0){A.client.sendUserMessage(Q,$,{userState:D});return}A.client.sendUserMessage(Q,$,{reasoningEffort:B,userState:D})}getActiveThreadID=()=>{return this.activeThreadContext?.client.getThreadId()??void 0};getRelaunchThreadIDs=()=>{let A=new Set,Q=this.getActiveThreadID();if(Q)A.add(Q);for(let $ of this.widget.clientPool.activeThreadIDs)A.add($);return[...A]};appendPluginMessagesToThread=async(A,Q)=>{let $=this.activeThreadContext;if(!$)throw Error("appendToThread is not available - no active thread");let B=$.client.getThreadId();if(Q&&B!==Q)throw Error("thread.append is only available for the active executor thread");for(let D of A)this.sendUserMessage($,[{type:"text",text:D.content}])};async connectToExistingThread(A,Q={}){let $=this.activeThreadContext?.client.getThreadId();this.setState(()=>{this.connectingToThreadID=A});try{let B=await this.widget.clientPool.connectToThread(A,{observerOnly:this.widget.neoContext.observerOnly,onExecutorAlreadyConnected:(D)=>this.promptExecutorAlreadyConnected(D)});if(this.setActiveClient(B),Q.recordNavigation&&$!==A)this.threadNavigationHistory.recordNavigation($);if(Q.initialUserInput)this.sendUserMessage(B,[{type:"text",text:Q.initialUserInput}])}catch(B){if(u.error("Failed to load thread",{error:B,threadID:A}),this.toastController.show(`Failed to load ${A}: ${B instanceof Error?B.message:String(B)}`,"error",4000),Q.rethrowError)throw B}finally{this.setState(()=>{this.connectingToThreadID=null})}}async connectToInitialThreads(A,Q={}){await this.connectToExistingThread(A,Q);let $=this.widget.initialThreadIDs.filter((B)=>B!==A);await Promise.all($.map((B)=>this.resumeBackgroundThread(B)))}async resumeBackgroundThread(A){try{await this.widget.clientPool.connectToThread(A,{observerOnly:this.widget.neoContext.observerOnly,onExecutorAlreadyConnected:async()=>"observe"})}catch(Q){u.error("Failed to resume background thread",{error:Q,threadID:A}),this.toastController.show(`Failed to resume ${A}: ${Q instanceof Error?Q.message:String(Q)}`,"error",4000)}}async navigateBack(){let A=this.threadNavigationHistory.startBackNavigation(this.activeThreadContext?.client.getThreadId());if(!A)return;await this.navigateToThread(A)}async navigateForward(){let A=this.threadNavigationHistory.startForwardNavigation(this.activeThreadContext?.client.getThreadId());if(!A)return;await this.navigateToThread(A)}async navigateToThread(A){try{await this.connectToExistingThread(A.targetThreadID,{rethrowError:!0})}catch{A.rollback()}}setActiveClient({client:A,observer:Q}){this.setState(()=>{this.activeThreadContext={client:A,observer:Q}}),this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=Q.threadID().subscribe(($)=>{this.widget.onActiveThreadChange?.($)})}handleIdeSelection=async(A)=>{try{await this.widget.ideManager.connect(A)}catch(Q){u.error("Failed to connect to IDE",{error:Q});let $=Q instanceof Error?Q.message:String(Q);this.toastController.show(`IDE connection failed: ${$}`,"error",4000)}};dispose(){if(this.unregisterCommands?.(),this.unregisterCommands=null,this.pluginIntegration?.dispose(),this.pluginIntegration=null,this.mcpTrustIntegration?.dispose(),this.mcpTrustIntegration=null,this.updateRelaunchIntegration?.dispose(),this.updateRelaunchIntegration=null,this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=null,this.noticesPollingTimeout)clearTimeout(this.noticesPollingTimeout),this.noticesPollingTimeout=null;this.connectionErrorsSubscription?.unsubscribe(),this.configSubscription?.unsubscribe(),this.configSubscription=null,this.notices.dispose(),this.widget.notificationService.detach(),this.toastController.dispose(),super.dispose()}hasBlockingTopLevelModal(){return this.switchThreadPickerVisible||this.executorAlreadyConnectedDialog!==null||this.neoWelcomeVisible||(this.mcpTrustIntegration?.hasBlockingDialog()??!1)||(this.pluginIntegration?.hasBlockingDialog()??!1)}}function _r4(A,Q,$){let B={...A};for(let D of Ig3(Q,$)){if(!vE(A[D],Q[D]))continue;let J=$[D];if(J===void 0)delete B[D];else B[D]=J}return B}function Ig3(...A){return Array.from(new Set(A.flatMap((Q)=>Object.keys(Q))))}n4();function vr4(A,Q,$,B){let D=g_(A),J="\x1B[0m",E="\x1B[34m",F="\x1B[90m",Y="\x1B[2m",Z=[];if(A.archived)Z.push("\x1B[90m\x1B[2mArchived\x1B[0m");Z.push(`${D}`),Z.push(`\x1B[34m${Q}\x1B[0m`),Z.push(`\x1B[90mamp threads continue ${A.id}\x1B[0m`);let U=14,X=7,G=new gJ(U,X),V=new d9(42),z=new XN(U,X,U,X,U,X,0,A.agentMode??"smart","intensity","classic","braille",void 0,void 0,z0.default(),V);z.layout(M1.tight(U,X)),z.paint(G,0,0);let K=G.getBuffer().getCells(),I=0;for(let j=0;j<X;j++)if(K[j].some((k)=>k.char!==" ")){I=j;break}let W=X-1;for(let j=X-1;j>=0;j--)if(K[j].some((k)=>k.char!==" ")){W=j;break}function H(j,k){if(!j)return"";if(j.type==="rgb"){let{r:_,g:f,b:g}=j.value;if($.getColorDepth()>=24)return`\x1B[${k?38:48};2;${_};${f};${g}m`;let b=Ij(_,f,g);return`\x1B[${k?38:48};5;${b}m`}return""}let q=[];if(W>=I)for(let j=I;j<=W;j++){let k="";for(let _=0;_<U;_++){let f=K[j][_],g=f.char,b=H(f.style.fg,!0);k+=b+g+"\x1B[0m"}q.push(k)}let N=q.length,w=Math.max(N,Z.length),O=Math.floor((w-N)/2),L=Math.floor((w-Z.length)/2);for(let j=0;j<w;j++){let k=" ".repeat(U);if(j>=O&&j<O+N)k=q[j-O];let _=" ",f="";if(j>=L&&j<L+Z.length)f=Z[j-L];$.write(k+_+f+`
|
|
5316
|
+
`)),J.push(new C("Details: ",new T({color:B.mutedForeground}))),J.push(new C(A.costBreakdownURL,new T({color:$.app.link})));return new d({text:new C("",void 0,J)})}function Xg3(A,Q,$){let B=Ug3(A,Q);if(!A.costBreakdownURL)return new w6({header:"Thread Cost",minWidth:80,maxWidth:100,onDismiss:$,child:B});let D=A.costBreakdownURL,J=new T1(()=>{return y4.maybeInvoke(Q,new G8(D,"Cost breakdown URL copied to clipboard","Failed to copy cost breakdown URL")),"handled"}),E=new T1(()=>{return i6(Q,D),"handled"});return new w6({header:"Thread Cost",minWidth:80,maxWidth:100,autofocus:!1,footer:[{keys:["Esc"],label:"close"},{keys:["o"],label:"open in browser"},{keys:["y"],label:"copy url"}],onDismiss:$,child:new y4({actions:new Map([[PA1,J],[_A1,E]]),child:new TA({debugLabel:"ThreadCostShortcuts",shortcuts:new Map([[G1.key("o"),new _A1],[G1.key("y"),new PA1]]),child:new v4({autofocus:!0,debugLabel:"ThreadCostBody",child:B})})})})}function wr4(A){return{noun:"thread",verb:"show cost",description:"Show usage cost for the active thread",keywords:["usage","credits","billing","spend"],get status(){return A.getActiveThreadID()?{type:"enabled"}:{type:"disabled",reason:"No active thread"}},run:async(Q,$,B)=>{let D=A.getActiveThreadID();if(!D)return;try{let J=await r4.threadDisplayCostInfo({threadID:D},{config:A.configService});if(!J.ok){A.toastController.show(Zg3(D,J.error),"error",5000),B();return}Q.push(Xg3(J.result,$,B))}catch(J){u.error("Failed to load Neo thread cost",{error:J,threadID:D}),A.toastController.show(`Failed to show thread cost: ${J instanceof Error?J.message:String(J)}`,"error",5000),B()}}}}i0();M9();Q4();class cK extends X4{direction;constructor(A){super();this.direction=A}}class BX0 extends X4{}class Ls extends X4{}class DX0 extends X4{index;constructor(A){super();this.index=A}}function TA1(A){return A.length+2}class vA1 extends u0{props;constructor(A){super();this.props=A}createState(){return new Cr4}}class Cr4 extends R0{selectedIndex=0;initState(){super.initState(),this.selectedIndex=this.findSelectableIndex(this.widget.props.initialSelectedIndex??0)}didUpdateWidget(A){this.selectedIndex=this.findSelectableIndex(this.selectedIndex)}isSelectable(A){let Q=this.widget.props.entries[A];return Q?.type==="item"&&(Q.enabled??!0)}findSelectableIndex(A){let{entries:Q}=this.widget.props;if(Q.length===0)return 0;let $=Math.max(0,Math.min(A,Q.length-1));if(this.isSelectable($))return $;for(let B=1;B<Q.length;B++){let D=$+B;if(D<Q.length&&this.isSelectable(D))return D;let J=$-B;if(J>=0&&this.isSelectable(J))return J}return 0}moveSelection(A){let Q=this.findNextSelectableIndex(A);if(Q===this.selectedIndex)return;this.setState(()=>{this.selectedIndex=Q})}findNextSelectableIndex(A){let{entries:Q}=this.widget.props;for(let $=this.selectedIndex+A;$>=0&&$<Q.length;$+=A)if(this.isSelectable($))return $;return this.selectedIndex}acceptIndex(A){let Q=this.widget.props.entries[A];if(Q?.type!=="item"||!(Q.enabled??!0))return;this.setState(()=>{this.selectedIndex=A}),this.widget.props.onAccept(Q.value)}invoke=(A)=>{if(A instanceof cK)return this.moveSelection(A.direction),"handled";if(A instanceof BX0)return this.acceptIndex(this.selectedIndex),"handled";if(A instanceof Ls)return this.widget.props.onDismiss(),"handled";if(A instanceof DX0)return this.acceptIndex(A.index),"handled";return"ignored"};buildShortcuts(){let A=new Map([[G1.key("ArrowDown"),new cK(1)],[G1.key("j"),new cK(1)],[G1.ctrl("n"),new cK(1)],[G1.key("ArrowUp"),new cK(-1)],[G1.key("k"),new cK(-1)],[G1.ctrl("p"),new cK(-1)],[G1.key("Enter"),new BX0],[G1.key("Escape"),new Ls],[G1.ctrl("."),new Ls]]);return this.widget.props.entries.forEach((Q,$)=>{if(Q.type==="item"&&Q.shortcut)A.set(Q.shortcut,new DX0($))}),A}buildActions(){return new Map([[cK,new T1(this.invoke)],[BX0,new T1(this.invoke)],[Ls,new T1(this.invoke)],[DX0,new T1(this.invoke)]])}build(A){let Q=O0.of(A),$=Gg3(this.widget.props.entries,l1.of(A).supportsEmojiWidth);return new b0({width:this.widget.props.width,height:TA1(this.widget.props.entries),decoration:new R4(Q.colors.background,m1.all(new d1(Q.colors.border,1,"solid"))),child:new y4({actions:this.buildActions(),child:new TA({debugLabel:"NeoContextPickerShortcuts",shortcuts:this.buildShortcuts(),child:new v4({autofocus:!0,debugLabel:"NeoContextPicker",child:new S0({mainAxisSize:"min",crossAxisAlignment:"stretch",children:this.widget.props.entries.map((B,D)=>this.buildEntry(B,D,$,Q))})})})})})}buildEntry(A,Q,$,B){if(A.type==="separator")return new b0({height:1,decoration:{border:new m1(new d1(B.colors.border,1,"solid"))}});let D=Q===this.selectedIndex,J=A.enabled??!0,E=new T({color:D?B.app.selectionForeground:B.colors.foreground,dim:!J}),F=new T({color:D?B.app.selectionForeground:B.app.keybind,bold:!0,dim:!J});return new j1({onClick:()=>this.acceptIndex(Q),child:new b0({padding:V0.symmetric(1,0),decoration:D?new R4(B.app.selectionBackground):void 0,child:new r0({crossAxisAlignment:"start",children:[new R1({child:new d({text:new C(A.label,E),maxLines:1,overflow:"ellipsis"})}),new X0({width:1}),new X0({width:$,child:new d({text:new C(Mr4(A),F),textAlign:"right",maxLines:1,overflow:"ellipsis"})})]})})})}}function Gg3(A,Q){return A.reduce(($,B)=>{return B.type==="item"?Math.max($,L4(Mr4(B),Q)):$},0)}function Mr4(A){return A.shortcutLabel??A.shortcut?.toString().toLowerCase()??""}var Vg3=36,zg3=24,Kg3=72;class Lr4 extends u0{child;onContext;constructor(A,Q){super();this.child=A;this.onContext=Q}createState(){return new Or4}}class Or4 extends R0{build(A){return this.widget.onContext(A),this.widget.child}}function jr4(A){return A.replace(/ ago$/,"")}function JX0(A){return A.reduce((Q,$)=>Math.max(Q,L4(jr4($.description.timeAgo))),0)}function Rr4(A){return Math.max(zg3,Math.min(A,Kg3))}class kA1 extends X4{}class SA1 extends X4{}class fA1{options;visibility;width=Vg3;constructor(A){this.options=A;this.visibility=new so(A.state)}isVisible(){return this.visibility.isEnabled()}buildBody(A){return new r0({crossAxisAlignment:"stretch",children:[this.buildSlot(),new R1({child:A})]})}buildSlot(){if(!this.options.isAvailable()||this.visibility.isDisabled())return new X0({width:0});return new X0({width:this.width,child:new h4({debugLabel:"ThreadListSidebar",child:new ur4({activeThreadID:this.options.getActiveThreadID(),currentWorkspaceURI:s1(l0.file(this.options.getWorkspaceRoot())),width:this.width,loadThreads:this.options.loadThreads,onSelectThread:this.options.onSelectThread,onDismiss:this.close,onResizeWidth:this.resize})})})}commands(){if(!this.options.isAvailable())return[];return[{noun:"thread",verb:"toggle sidebar",description:"Show or hide the thread sidebar",keywords:["sidebar","recent","history","threads"],shortcut:G1.alt("s"),status:{type:"enabled"},run:(A,Q,$)=>{$(),this.toggle()}}]}shortcutEntries(){return this.options.isAvailable()?[[G1.alt("s"),new YU0]]:[]}actionEntries(){if(!this.options.isAvailable())return[];return[[YU0,new T1(()=>this.toggle())]]}toggle=()=>{if(!this.options.isAvailable())return"ignored";if(this.visibility.isDisabled()&&this.options.isBlocked())return"ignored";return this.visibility.toggle(),"handled"};close=()=>{this.visibility.disable()};resize=(A)=>{let Q=Rr4(A);if(Q===this.width)return;this.options.state.setState(()=>{this.width=Q})}}class ur4 extends u0{props;constructor(A){super();this.props=A}createState(){return new Pr4}}class Pr4 extends R0{threads=[];isLoading=!0;isSwitchingThread=!1;hasError=!1;filterByWorkspace=!0;timeColWidth=0;contextMenu=null;pendingThreadMutations=new Map;resizeSession=null;isResizeHandleHovered=!1;pickerController=new Kr;threadItemContexts=new Map;shortcuts=new Map([[G1.alt("w"),new kA1],[G1.ctrl("."),new SA1]]);actions=new Map([[kA1,new T1(()=>{return this.setState(()=>{this.filterByWorkspace=!this.filterByWorkspace,this.contextMenu=null}),"handled"})],[SA1,new T1(()=>this.openContextMenu())]]);get isBusy(){return this.isLoading||this.isSwitchingThread}get isResizeActive(){return this.resizeSession!==null||this.isResizeHandleHovered}didUpdateWidget(A){if(this.contextMenu&&(A.props.width!==this.widget.props.width||A.props.currentWorkspaceURI!==this.widget.props.currentWorkspaceURI))this.contextMenu=null}initState(){super.initState(),this.loadThreadSummaries()}async loadThreadSummaries(){try{let A=await this.widget.props.loadThreads(),Q=M61(A);if(!this.mounted)return;this.setState(()=>{this.pickerController.selectedItem=Q.find(($)=>$.id===this.widget.props.activeThreadID)??null,this.threads=Q,this.timeColWidth=JX0(Q),this.isLoading=!1,this.hasError=!1})}catch(A){if(u.error("Failed to load threads for Neo sidebar",{error:A}),!this.mounted)return;this.setState(()=>{this.isLoading=!1,this.hasError=!0})}}handleSelectThread=async(A)=>{if(this.isSwitchingThread)return;this.setState(()=>{this.isSwitchingThread=!0});try{await this.widget.props.onSelectThread(A),this.widget.props.onDismiss()}catch(Q){u.error("Failed to switch thread from Neo sidebar",{error:Q,threadID:A})}finally{if(this.mounted)this.setState(()=>{this.isSwitchingThread=!1})}};getOptimisticThreads(){return this.threads.flatMap((A)=>{if(this.pendingThreadMutations.get(A.id)?.kind==="archive")return[];return[A]})}getThreadsForDisplay(){let A=this.getOptimisticThreads();return this.filterByWorkspace?A.filter((Q)=>!Q.workspaceURI||Q.workspaceURI===this.widget.props.currentWorkspaceURI):A}buildContextMenuEntries(){return[{type:"item",value:"archive",label:"Archive Thread",shortcut:G1.key("a"),shortcutLabel:"a"},{type:"separator"},{type:"item",value:"copy-id",label:"Copy ID",shortcut:G1.ctrl("c"),shortcutLabel:"ctrl+c"},{type:"item",value:"copy-url",label:"Copy URL",shortcut:new G1("c",{shift:!0,ctrl:!0}),shortcutLabel:"shift+ctrl+c"}]}openContextMenu(){let A=this.pickerController.selectedItem;if(!A||this.isBusy||this.hasError)return"ignored";let Q=this.buildContextMenuEntries(),$=TA1(Q),B=this.getContextMenuWidth(),D=this.getContextMenuPosition(A.id,$,B);return this.setState(()=>{this.contextMenu={threadID:A.id,left:D.left,top:D.top,width:B,height:$}}),"handled"}getContextMenuWidth(){let A=Math.max(24,this.widget.props.width-3);return Math.max(1,Math.min(A,this.widget.props.width-2))}getContextMenuPosition(A,Q,$){let B=Math.max(0,Math.min(2,this.widget.props.width-$)),D=1,J=this.threadItemContexts.get(A)?.findRenderObject(),E=this.context.findRenderObject();if(!(J instanceof t1)||!(E instanceof t1))return{left:B,top:1};let F=J.localToGlobal({x:0,y:0}),Y=E.localToGlobal({x:0,y:0}),Z=F.y-Y.y,U=Z+J.size.height,X=l1.sizeOf(this.context).height,G=Math.max(1,Math.min(E.size.height,X-Y.y)),K=G-U>=Q||Z<G/2?U:Z-Q,I=Math.max(0,G-Q);return{left:B,top:Math.max(0,Math.min(K,I))}}closeContextMenu=()=>{if(!this.contextMenu)return;this.setState(()=>{this.contextMenu=null})};handleContextMenuAccept=(A)=>{let Q=this.contextMenu?.threadID;if(!Q)return;if(this.closeContextMenu(),A==="archive"){this.archiveContextMenuThread(Q);return}if(A==="copy-id"){y4.maybeInvoke(this.context,new G8(Q,"Thread ID copied to clipboard","Failed to copy thread ID"));return}y4.maybeInvoke(this.context,new G8(this.getThreadURL(Q),"Thread URL copied to clipboard","Failed to copy thread URL"))};beginOptimisticArchive(A){if(this.pendingThreadMutations.has(A))return!1;if(!this.threads.some(($)=>$.id===A))return!1;let Q={kind:"archive",fallbackSelectedThreadID:null};return this.setState(()=>{this.pendingThreadMutations.set(A,Q),this.timeColWidth=JX0(this.getOptimisticThreads())}),h6.instance.addPostFrameCallback(()=>{if(!this.mounted)return;let $=this.pendingThreadMutations.get(A);if($?.kind!=="archive")return;$.fallbackSelectedThreadID=this.pickerController.selectedItem?.id??null}),!0}commitOptimisticArchive(A){if(this.pendingThreadMutations.get(A)?.kind!=="archive")return;this.pendingThreadMutations.delete(A),this.threads=this.threads.filter(($)=>$.id!==A),this.timeColWidth=JX0(this.getOptimisticThreads())}rollbackOptimisticArchive(A){let Q=this.pendingThreadMutations.get(A);if(Q?.kind!=="archive")return;let $=this.threads.find((B)=>B.id===A);if(!$){this.pendingThreadMutations.delete(A);return}this.setState(()=>{this.pendingThreadMutations.delete(A),this.timeColWidth=JX0(this.getOptimisticThreads());let B=this.pickerController.selectedItem?.id??null;if(B===null||B===Q.fallbackSelectedThreadID)this.pickerController.selectedItem=$})}async archiveContextMenuThread(A){let Q=M3.maybeOf(this.context),{configService:$}=X5.of(this.context);if(!this.beginOptimisticArchive(A))return;try{let B=await GZ0({configService:$},A);if(!this.mounted)return;if(B){this.rollbackOptimisticArchive(A),Q?.show(B.message,"error");return}this.commitOptimisticArchive(A)}catch(B){if(u.error("Failed to archive thread from Neo sidebar context menu",{error:B,threadID:A}),!this.mounted)return;this.rollbackOptimisticArchive(A),Q?.show("Failed to archive thread","error")}}getThreadURL(A){return u$(new URL(X5.of(this.context).ampURL),A).toString()}buildContextMenuOverlay(){let A=this.contextMenu;if(!A||!this.getThreadsForDisplay().some((Q)=>Q.id===A.threadID))return null;return new B6({left:A.left,top:A.top,width:A.width,height:A.height,child:new h4({debugLabel:"ThreadListSidebarContextMenu",onFocusChange:(Q)=>{if(!Q)this.closeContextMenu()},child:new vA1({entries:this.buildContextMenuEntries(),width:A.width,onAccept:this.handleContextMenuAccept,onDismiss:this.closeContextMenu})})})}buildContextMenuBackdrop(){return new B6({left:0,top:0,right:0,bottom:0,child:new j1({onClick:()=>this.closeContextMenu(),child:X0.expand()})})}buildThreadItem(A,Q,$,B){let D=O0.of(B),{app:J,colors:E}=D,F=!Q,Y=Q?J.selectionForeground:E.foreground,Z=Q?J.selectionForeground:E.mutedForeground,X=A.id===this.widget.props.activeThreadID?new d({text:new C("*",new T({color:Q?J.selectionForeground:E.success,dim:F}))}):void 0,G=jr4(A.description.timeAgo);return new Lr4(new b0({padding:V0.symmetric(1,0),child:new r0({children:[new X0({width:2,child:X}),new R1({child:new d({text:new C(A.title,new T({color:Y,dim:F})),overflow:"ellipsis",maxLines:1})}),new X0({width:2}),new X0({width:$,child:r0.end([new d({text:new C(G,new T({color:Z,dim:F}))})])})]})}),(V)=>{this.threadItemContexts.set(A.id,V)})}handleResizeHandlePress=(A)=>{if(A.button!=="left")return;this.setState(()=>{this.resizeSession={baseWidthColumns:this.widget.props.width,startColumn:Math.floor(A.position.x)}})};handleResizeHandleDrag=(A)=>{if(A.button!=="left"||this.resizeSession===null)return;let Q=Math.floor(A.position.x)-this.resizeSession.startColumn,$=Rr4(this.resizeSession.baseWidthColumns+Q);if($!==this.widget.props.width)this.widget.props.onResizeWidth($)};handleResizeHandleRelease=(A)=>{if(A.button!=="left"||this.resizeSession===null)return;this.setState(()=>{this.resizeSession=null})};handleResizeHandleEnter=()=>{if(this.isResizeHandleHovered)return;this.setState(()=>{this.isResizeHandleHovered=!0})};handleResizeHandleExit=()=>{if(!this.isResizeHandleHovered)return;this.setState(()=>{this.isResizeHandleHovered=!1})};buildResizeHandle(){return new B6({top:0,right:0,bottom:0,width:1,child:new j1({cursor:FA.EW_RESIZE,onClick:this.handleResizeHandlePress,onDrag:this.handleResizeHandleDrag,onRelease:this.handleResizeHandleRelease,onEnter:this.handleResizeHandleEnter,onExit:this.handleResizeHandleExit,child:new X0({width:1})})})}build(A){let Q=O0.of(A),$=this.getThreadsForDisplay(),B=this.hasError?[]:$;this.threadItemContexts.clear();let D=this.isSwitchingThread?"Switching thread...":"Loading threads...",J=this.hasError?"Failed to load threads":"No threads match your filter",E=this.isResizeActive?2:1,F=new m1(void 0,new d1(Q.colors.border,E),void 0,void 0),Y=this.buildContextMenuOverlay(),Z=[new b0({decoration:new R4(Q.colors.background,F),child:new y4({actions:this.actions,child:new TA({shortcuts:this.shortcuts,debugLabel:"ThreadListSidebarFilter",child:new pA({items:B,getLabel:(U)=>`${U.title} ${U.id}`,controller:this.pickerController,onAccept:(U)=>void this.handleSelectThread(U.id),onDismiss:this.widget.props.onDismiss,renderItem:(U,X,G,V)=>this.buildThreadItem(U,X,this.timeColWidth,V),enabled:!this.isBusy,isLoading:this.isBusy,hidePromptWhenLoading:!0,loadingText:D,emptyStateText:J,maxRenderItems:200,showBorder:!1})})})}),this.buildResizeHandle()];if(Y)Z.push(this.buildContextMenuBackdrop()),Z.push(Y);return new b0({width:this.widget.props.width,child:new t4({fit:"expand",children:Z})})}}class yA1 extends u0{listSkillsForThread;clientPool;completionBuilder;history;ideManager;configService;updateService;initialThreadIDs;showNeoWelcome;neoWelcomeVariant;onNeoWelcomeDismissed;notificationService;mcpTrustHandler;onThreadArchived;onActiveThreadChange;onRelaunchRequested;onFirstFrame;initialUserInput;getDefaultNewThreadVisibility;openThreadPickerOnStart;workspaceSettingsFilePath;neoContext;constructor(A){super();this.listSkillsForThread=A.listSkillsForThread,this.clientPool=A.clientPool,this.completionBuilder=A.completionBuilder,this.history=A.history,this.ideManager=A.ideManager,this.configService=A.configService,this.updateService=A.updateService,this.initialThreadIDs=A.initialThreadIDs??[],this.showNeoWelcome=A.showNeoWelcome??!1,this.neoWelcomeVariant=A.neoWelcomeVariant??"intro",this.onNeoWelcomeDismissed=A.onNeoWelcomeDismissed,this.notificationService=A.notificationService,this.mcpTrustHandler=A.mcpTrustHandler,this.onThreadArchived=A.onThreadArchived,this.onActiveThreadChange=A.onActiveThreadChange,this.onRelaunchRequested=A.onRelaunchRequested,this.onFirstFrame=A.onFirstFrame,this.initialUserInput=A.initialUserInput,this.getDefaultNewThreadVisibility=A.getDefaultNewThreadVisibility,this.openThreadPickerOnStart=A.openThreadPickerOnStart??!1,this.workspaceSettingsFilePath=A.workspaceSettingsFilePath,this.neoContext=A.neoContext}createState(){return new Tr4}}class Tr4 extends R0{editorController=new u2;commandPalette=new so(this);commandRegistry=new y41;toastController=new te0;relaunchNotificationController=new R41;exitHintTimer=new ro(this,1000);ideStatus=new Z8(this,{});threadNavigationHistory=new T41;draftThreadSettings={};draftThreadSettingsSeed={};hasDraftThreadSettingsSeed=!1;draftThreadSettingsInitPromise=null;activeThreadContext=null;activeThreadIDSubscription=null;connectionErrorsSubscription=null;configSubscription=null;connectingToThreadID=null;executorAlreadyConnectedDialog=null;switchThreadPickerVisible=!1;neoWelcomeVisible=!1;debugOverlayVisible=!1;focusDebugVisible=!1;unregisterCommands=null;pluginIntegration=null;mcpTrustIntegration=null;updateRelaunchIntegration=null;noticesPollingTimeout=null;notices;loadThreads=async()=>{return this.widget.neoContext.listThreads()};analyzeContextForThread=async(A,Q)=>{return ih4({ampURL:this.widget.neoContext.ampURL,configService:this.widget.configService,threadID:A,signal:Q})};onSwitchThread=(A)=>{return this.connectToExistingThread(A,{recordNavigation:!0,rethrowError:!0})};threadListSidebar=new fA1({state:this,isAvailable:()=>this.widget.neoContext.isInternalUser,isBlocked:()=>this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal(),getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??null,getWorkspaceRoot:()=>this.widget.neoContext.workspaceRoot,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread});sendFeedbackReport=async(A)=>NU0({configService:this.widget.configService,settingsFilePath:this.widget.neoContext.settingsFilePath},A);archiveThread=async(A)=>{let Q=await GZ0({configService:this.widget.configService},A);if(Q===null)this.widget.onThreadArchived?.(A);return Q};addThreadLabel=async(A,Q)=>{let $=await ed4({configService:this.widget.configService},A,Q);if($ instanceof Error)return $;return this.toastController.show($.message,$.type,2000),null};removeThreadLabel=async(A,Q)=>{let $=await Ap4({configService:this.widget.configService},A,Q);if($ instanceof Error)return $;return this.toastController.show($.message,$.type,2000),null};initState(){if(e$.getInstance().interceptConsole(),this.notices=new V41(this.widget.configService,($)=>this.setState($)),h6.instance.addPostFrameCallback(()=>{setTimeout(()=>this.widget.onFirstFrame?.(),0),this.noticesPollingTimeout=setTimeout(()=>{this.noticesPollingTimeout=null,this.notices.startPolling()},500)},"Neo notices polling"),this.widget.showNeoWelcome)this.neoWelcomeVisible=!0;if(this.connectionErrorsSubscription=this.widget.clientPool.connectionErrors$.subscribe(({threadID:$,error:B})=>{if(u.error("Neo failed to connect to thread",{threadID:$,error:B}),!$)this.toastController.show(`Connection failed: ${B.message}`,"error",4000)}),this.configSubscription=this.widget.configService.config.subscribe(($)=>{this.applyDraftThreadSettingsSeed(this.applySessionDefaultsToThreadSettings(R50($.settings)))}),this.updateRelaunchIntegration=new P41({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested,relaunchNotificationController:this.relaunchNotificationController,updateService:this.widget.updateService}),this.updateRelaunchIntegration.init(),this.ideStatus.subscribe(this.widget.ideManager.status),this.widget.openThreadPickerOnStart)this.switchThreadPickerVisible=!0;this.ensureDraftThreadSettingsInitialized();let A=this.widget.initialUserInput,Q=this.widget.initialThreadIDs[0];if(Q){let $={};if(A)$.initialUserInput=A;this.connectToInitialThreads(Q,$)}else if(A)this.onNewThread([{type:"text",text:A}],this.widget.neoContext.sessionAgentMode);this.pluginIntegration=new j41({state:this,commandPalette:this.commandPalette,commandRegistry:this.commandRegistry,toastController:this.toastController,neoContext:this.widget.neoContext,getActiveThreadID:this.getActiveThreadID,appendToThread:this.appendPluginMessagesToThread}),this.pluginIntegration.init(),this.mcpTrustIntegration=new G41({state:this,mcpTrustHandler:this.widget.mcpTrustHandler,toastController:this.toastController,workspaceSettingsFilePath:this.widget.workspaceSettingsFilePath}),this.mcpTrustIntegration.init(),this.unregisterCommands=this.registerAppCommands(),queueMicrotask(()=>{if(!this.mounted)return;this.replayEarlyInputToEditor()})}replayEarlyInputToEditor(){let A=H4.instance.tuiInstance.getEarlyInputText();if(!A)return;this.editorController.insertText(A)}registerAppCommands(){let A=this,Q=this.widget.neoContext.pluginService?Ei4({pluginService:this.widget.neoContext.pluginService,workspaceRoot:this.widget.neoContext.workspaceRoot,logFilePath:this.widget.neoContext.logFilePath,toastController:this.toastController}):[],B=[zi4({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested}),{noun:"thread",verb:"switch",description:"Switch to existing thread",keywords:["recent","history","open","resume","change"],status:{type:"enabled"},sortBoost:100,run:(D,J,E)=>{D.pushWithDismiss((F)=>L61({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:F,onThreadSelected:E}))}},...this.threadListSidebar.commands(),{noun:"thread",verb:"switch to previous",description:"Switch to previous thread",keywords:["back"],get status(){return A.threadNavigationHistory.canNavigateBack()?{type:"enabled"}:{type:"disabled",reason:"Cannot use thread: switch to previous with no previous thread"}},run:(D,J,E)=>{A.navigateBack(),E()}},wr4({configService:this.widget.configService,getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??void 0,toastController:this.toastController}),{noun:"thread",verb:"switch to next",description:"Switch to next thread",keywords:["forward"],get status(){return A.threadNavigationHistory.canNavigateForward()?{type:"enabled"}:{type:"disabled",reason:"Cannot use thread: switch to next with no next thread"}},run:(D,J,E)=>{A.navigateForward(),E()}},{noun:"mcp",verb:"info",description:"Show MCP servers and tools",keywords:["servers","tools","plugins","integrations"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new a41({mcpServers:this.widget.neoContext.mcpServers,onDismiss:E}))}},{noun:"toolbox",verb:"list",description:"List all toolboxes and their tools",keywords:["tools","toolbox"],status:{type:"enabled"},run:(D)=>{D.pushWithDismiss((J)=>new CA1({toolboxes:this.widget.neoContext.toolboxes,onDismiss:J}))}},{noun:"news",verb:"open",description:"Open Amp Chronicle in browser",keywords:["chronicle","updates","blog","announcements"],status:{type:"enabled"},run:async(D,J,E)=>{try{await i6(J,"https://ampcode.com/chronicle")}finally{E()}}},{noun:"settings",verb:"open in editor",description:"Open CLI settings in $EDITOR",keywords:["config","preferences","edit"],status:{type:"enabled"},run:()=>{eQ(this.widget.neoContext.settingsFilePath).catch((D)=>{u.error("Failed to open settings file in editor",{error:D})})}},{noun:"IDE",verb:"connect",description:"Connect to an IDE",keywords:["vscode","cursor","jetbrains","editor","attach"],status:{type:"enabled"},run:(D,J,E)=>{D.pushWithDismiss((F)=>new i41({onCancel:F,onSelect:(Y)=>{this.handleIdeSelection(Y),E()}}))}},{noun:"amp",verb:"help",description:"Show help & keyboard shortcuts",keywords:["shortcuts","keybindings","docs","manual","?"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new m41({commands:W9.of(J).commands,onDismiss:E}))}},{noun:"amp",verb:"show welcome",description:"Show the welcome message again",keywords:["intro","onboarding","getting started"],status:{type:"enabled"},run:(D,J,E)=>{E(),A.showNeoWelcome()}},{noun:"amp",verb:"show version",description:"Show current Amp version",keywords:["about","release","build"],status:{type:"enabled"},run:(D,J,E)=>{D.push(new w6({header:"Amp Version",maxWidth:72,onDismiss:E,child:new d({text:new C(gY0({version:"0.0.1779190035-gd08a72",buildTimestamp:"2026-05-19T11:32:14.941Z",buildType:"release"}))})}))}},{noun:"amp",verb:"quit",description:"Exit application",keywords:["exit","close","leave","bye"],shortcut:G1.ctrl("c"),status:{type:"enabled"},run:(D,J)=>{y4.maybeInvoke(J,new Zy)}},...Q,...dl4(this.widget.neoContext.logFilePath)].map((D)=>this.commandRegistry.register(D));return()=>{for(let D of B)D()}}build(A){let Q=this.buildHints(),$=this.ideStatus.getValue(),B=this.notices.current,D=new wA1({initialAgentMode:this.widget.neoContext.sessionAgentMode,analyzeContextForThread:this.analyzeContextForThread,listSkillsForThread:this.widget.listSkillsForThread,threadContext:this.activeThreadContext,draftThreadSettings:this.draftThreadSettings,editorController:this.editorController,history:this.widget.history,updateDraftThreadSettings:this.updateDraftThreadSettings,onNewThread:this.onNewThread,sendFeedbackReport:this.sendFeedbackReport,archiveThread:this.archiveThread,addThreadLabel:this.addThreadLabel,removeThreadLabel:this.removeThreadLabel,configService:this.widget.configService,hints:Q,ideStatus:$,statusItems:this.pluginIntegration?.getStatusItems()??[],notificationService:this.widget.notificationService,notice:this.activeThreadContext||this.neoWelcomeVisible?null:B,onDismissNotice:(U)=>this.notices.dismiss(U)}),J=l1.of(A),E=J.capabilities.animationSupport!=="disabled",Y=[new b0({constraints:M1.tight(J.size.width,J.size.height),child:this.threadListSidebar.buildBody(D)})];if(this.commandPalette.isEnabled())Y.push(new h4({debugLabel:"CommandPaletteOverlay",onFocusChange:this.closeCommandPaletteOnFocusLoss,child:new x41({onDismiss:this.commandPalette.disable})}));if(this.switchThreadPickerVisible&&!this.neoWelcomeVisible)Y.push(L61({activeThreadID:this.activeThreadContext?.client.getThreadId()??null,loadThreads:this.loadThreads,onSelectThread:this.onSwitchThread,onDismiss:this.closeSwitchThreadPicker,onThreadSelected:this.closeSwitchThreadPicker}));if(this.neoWelcomeVisible)Y.push(new h4({debugLabel:"NeoWelcomeDialogOverlay",child:new uA1({onDismiss:this.dismissNeoWelcome,onQuit:()=>H4.instance.stop(),animationsEnabled:E,variant:this.widget.neoWelcomeVariant})}));let Z=this.executorAlreadyConnectedDialog;if(Z)Y.push(new h4({debugLabel:"NeoExecutorAlreadyConnectedDialogOverlay",child:new c41({existingExecutorPid:Z.existingExecutorPid,onChoice:this.handleExecutorAlreadyConnectedChoice})}));if(Y.push(...this.mcpTrustIntegration?.buildDialogLayers()??[]),Y.push(...this.pluginIntegration?.buildDialogLayers()??[]),this.widget.neoContext.isInternalUser)Y.push(new p41({top:this.focusDebugVisible?33:1,visible:this.debugOverlayVisible,pid:EX0.pid,activeThreadID:this.activeThreadContext?.client.getThreadId()??null,connectionInfo$:this.activeThreadContext?.observer.connectionInfo()??null}));if(this.focusDebugVisible)Y.push(new l41);return new X5({neoContext:this.widget.neoContext,child:new W9({commandRegistry:this.commandRegistry,child:new Gy({completionBuilder:this.widget.completionBuilder,child:new M3({controller:this.toastController,child:new y4({actions:this.buildActions(),child:new TA({debugLabel:"NeoAppShortcuts",shortcuts:this.buildShortcuts(),child:new v4({debugLabel:"AppShellFocus",child:new ee0({controller:this.toastController,complexToastControllers:[this.relaunchNotificationController,...B&&this.activeThreadContext&&!this.neoWelcomeVisible?[this.notices]:[]],child:new d41({configReloadEvents:this.widget.configService.configReloadEvents,toastController:this.toastController,child:new t4({children:Y})})})})})})})})})})}buildShortcuts(){let A=new Map([[G1.ctrl("c"),new BU0],[G1.ctrl("o"),new JU0],[G1.alt("i"),new FU0],[G1.alt("p"),new IN],[G1.ctrl("."),new UU0],[G1.ctrl("t"),new VU0],...this.threadListSidebar.shortcutEntries()]);if(EX0.env.NODE_ENV==="development"&&EX0.platform==="darwin")A.set(G1.meta("r"),new DU0);return A}buildActions(){let A=new T1(()=>{if(WD.hasAnyCopyableSelection())return WD.tryCopyAnyActiveSelection(),"handled";return this.onExitPressed(),"handled"}),Q=new T1(()=>{if(!this.commandPalette.isEnabled()&&this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.toggle(),"handled"}),$=new T1(()=>{if(this.commandPalette.isEnabled()||this.hasBlockingTopLevelModal())return"ignored";return this.commandPalette.enable(),"handled"}),B=new T1(()=>{return this.startNewDraftThread(),"handled"}),D=new T1(()=>{return H4.instance.stop(),"handled"}),J=new T1(()=>{return Ds({getRelaunchThreadIDs:this.getRelaunchThreadIDs,onRelaunchRequested:this.widget.onRelaunchRequested}),"handled"}),E=new T1((G)=>{if(!G.text)return"ignored";return H4.instance.tuiInstance.clipboard.writeText(G.text).then((V)=>{if(V.ok)this.toastController.show(G.successMessage,"success",2000);else this.toastController.show(`${G.failureMessage}: ${V.userFacingErrorMessage}`,"error",4000)}).catch((V)=>{u.error("Failed to copy Neo text to clipboard",{error:V}),this.toastController.show(G.failureMessage,"error",2000)}),"handled"}),F=new T1(()=>{return H4.instance.toggleFrameStatsOverlay(),"handled"}),Y=new T1(()=>this.notices.dismissCurrent()?"handled":"ignored"),Z=new T1(()=>{if(!this.widget.neoContext.isInternalUser)return"ignored";return this.setState(()=>{this.debugOverlayVisible=!this.debugOverlayVisible}),"handled"}),U=Oi4({getActiveThreadID:()=>this.activeThreadContext?.client.getThreadId()??null,neoContext:this.widget.neoContext,toastController:this.toastController,startNewDraftThread:this.startNewDraftThread,sendFeedbackReport:this.sendFeedbackReport}),X=new T1(()=>{return this.setState(()=>{this.focusDebugVisible=!this.focusDebugVisible}),"handled"});return new Map([[BU0,A],[ar,B],[Zy,D],[DU0,J],[G8,E],[tr,$],[JU0,Q],[FU0,Z],...this.threadListSidebar.actionEntries(),[UU0,Y],...U,[IN,F],[VU0,X]])}startNewDraftThread(A={}){let Q=this.activeThreadContext?.client.getThreadId();if(this.commandPalette.disable(),this.threadNavigationHistory.recordNavigation(Q),this.setState(()=>{if(this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=null,this.activeThreadContext=null,this.connectingToThreadID=null,A.hideDebugOverlay)this.debugOverlayVisible=!1}),this.widget.onActiveThreadChange?.(null),A.prompt!==void 0)this.editorController.text=A.prompt}closeCommandPaletteOnFocusLoss=(A)=>{if(A||!this.commandPalette.isEnabled())return;this.commandPalette.disable()};ensureDraftThreadSettingsInitialized(){if(this.hasDraftThreadSettingsSeed)return Promise.resolve();if(!this.draftThreadSettingsInitPromise)this.draftThreadSettingsInitPromise=this.initDraftThreadSettings();return this.draftThreadSettingsInitPromise}async initDraftThreadSettings(){try{let A=this.applySessionDefaultsToThreadSettings(await Mf(this.widget.configService));this.applyDraftThreadSettingsSeed(A)}catch(A){u.warn("Failed to initialize Neo draft thread settings",{error:A instanceof Error?A.message:String(A)})}}applySessionDefaultsToThreadSettings(A){let Q=this.widget.neoContext.sessionAgentMode,$=A,B=AB(Q),D=RY0(this.widget.neoContext,Q);if(B!==void 0&&D!==void 0)$={...$,[B]:D};return jY0($,{agentMode:Q,explicitEffort:this.widget.neoContext.explicitReasoningEffort,sessionState:this.widget.neoContext})}applyDraftThreadSettingsSeed(A){if(!this.mounted)return;if(!this.hasDraftThreadSettingsSeed){this.setState(()=>{this.hasDraftThreadSettingsSeed=!0,this.draftThreadSettings=_r4(this.draftThreadSettings,{},A),this.draftThreadSettingsSeed={...A}});return}if(vE(this.draftThreadSettingsSeed,A))return;this.setState(()=>{this.draftThreadSettings=_r4(this.draftThreadSettings,this.draftThreadSettingsSeed,A),this.draftThreadSettingsSeed={...A}})}buildHints(){let A=new Set;if(this.connectingToThreadID)A.add(vN);if(this.exitHintTimer.isActive())A.add(Dy);return A}onExitPressed=()=>{if(this.exitHintTimer.isActive())this.exitHintTimer.clear(),H4.instance.stop();else this.exitHintTimer.activate()};dismissNeoWelcome=()=>{if(!this.neoWelcomeVisible)return;this.setState(()=>{this.neoWelcomeVisible=!1}),this.widget.onNeoWelcomeDismissed?.()};showNeoWelcome=()=>{if(this.neoWelcomeVisible)return;this.setState(()=>{this.neoWelcomeVisible=!0})};promptExecutorAlreadyConnected(A){return new Promise((Q)=>{this.setState(()=>{this.executorAlreadyConnectedDialog={existingExecutorPid:A.existingExecutorPid,resolve:($)=>{Q($==="watch"?"observe":"disconnect")}}})})}handleExecutorAlreadyConnectedChoice=(A)=>{if(this.resolveExecutorAlreadyConnectedDialog(A),A==="exit")H4.instance.stop()};resolveExecutorAlreadyConnectedDialog(A){let Q=this.executorAlreadyConnectedDialog;if(!Q)return;this.setState(()=>{this.executorAlreadyConnectedDialog=null}),Q.resolve(A)}closeSwitchThreadPicker=()=>{if(!this.switchThreadPickerVisible)return;this.setState(()=>{this.switchThreadPickerVisible=!1})};updateDraftThreadSettings=(A)=>{this.setState(()=>{this.draftThreadSettings=A(this.draftThreadSettings)})};onNewThread=async(A,Q,$=null,B)=>{await this.ensureDraftThreadSettingsInitialized();let D=this.activeThreadContext?.client.getThreadId(),J=A.find(H50);if(J)this.widget.history.add(J.text,EX0.cwd()),this.widget.history.reset();let E=$?void 0:await this.widget.getDefaultNewThreadVisibility?.(),F=$??E??null,Y=this.widget.clientPool.createNewThread(Q,this.draftThreadSettings,F??void 0);this.sendUserMessage(Y,A,Q,B),this.rememberSessionDefaultsForNewMessage(Q,this.draftThreadSettings),this.threadNavigationHistory.recordNavigation(D),this.setActiveClient(Y)};rememberSessionDefaultsForNewMessage(A,Q){this.widget.neoContext.sessionAgentMode=A;let $=Q["reasoning.effort"];if($!==void 0)this.widget.neoContext.lastReasoningEffortByMode={...this.widget.neoContext.lastReasoningEffortByMode??{},[A]:$};let B=AB(A),D=B?Q[B]:void 0;if(D!==void 0)this.widget.neoContext.lastSpeedByMode={...this.widget.neoContext.lastSpeedByMode??{},[A]:D};tQ((J)=>{let E={...J,agentMode:A};if($!==void 0)E={...E,lastReasoningEffortByMode:{...E.lastReasoningEffortByMode??{},[A]:$}};if(D!==void 0)E={...E,lastSpeedByMode:{...E.lastSpeedByMode??{},[A]:D}};return E}).catch((J)=>{u.warn("Failed to persist Neo session defaults for new message",{error:J instanceof Error?J.message:String(J)})})}sendUserMessage(A,Q,$,B){let D=CJ0(this.ideStatus.getValue());if(B===void 0){A.client.sendUserMessage(Q,$,{userState:D});return}A.client.sendUserMessage(Q,$,{reasoningEffort:B,userState:D})}getActiveThreadID=()=>{return this.activeThreadContext?.client.getThreadId()??void 0};getRelaunchThreadIDs=()=>{let A=new Set,Q=this.getActiveThreadID();if(Q)A.add(Q);for(let $ of this.widget.clientPool.activeThreadIDs)A.add($);return[...A]};appendPluginMessagesToThread=async(A,Q)=>{let $=this.activeThreadContext;if(!$)throw Error("appendToThread is not available - no active thread");let B=$.client.getThreadId();if(Q&&B!==Q)throw Error("thread.append is only available for the active executor thread");for(let D of A)this.sendUserMessage($,[{type:"text",text:D.content}])};async connectToExistingThread(A,Q={}){let $=this.activeThreadContext?.client.getThreadId();this.setState(()=>{this.connectingToThreadID=A});try{let B=await this.widget.clientPool.connectToThread(A,{observerOnly:this.widget.neoContext.observerOnly,onExecutorAlreadyConnected:(D)=>this.promptExecutorAlreadyConnected(D)});if(this.setActiveClient(B),Q.recordNavigation&&$!==A)this.threadNavigationHistory.recordNavigation($);if(Q.initialUserInput)this.sendUserMessage(B,[{type:"text",text:Q.initialUserInput}])}catch(B){if(u.error("Failed to load thread",{error:B,threadID:A}),this.toastController.show(`Failed to load ${A}: ${B instanceof Error?B.message:String(B)}`,"error",4000),Q.rethrowError)throw B}finally{this.setState(()=>{this.connectingToThreadID=null})}}async connectToInitialThreads(A,Q={}){await this.connectToExistingThread(A,Q);let $=this.widget.initialThreadIDs.filter((B)=>B!==A);await Promise.all($.map((B)=>this.resumeBackgroundThread(B)))}async resumeBackgroundThread(A){try{await this.widget.clientPool.connectToThread(A,{observerOnly:this.widget.neoContext.observerOnly,onExecutorAlreadyConnected:async()=>"observe"})}catch(Q){u.error("Failed to resume background thread",{error:Q,threadID:A}),this.toastController.show(`Failed to resume ${A}: ${Q instanceof Error?Q.message:String(Q)}`,"error",4000)}}async navigateBack(){let A=this.threadNavigationHistory.startBackNavigation(this.activeThreadContext?.client.getThreadId());if(!A)return;await this.navigateToThread(A)}async navigateForward(){let A=this.threadNavigationHistory.startForwardNavigation(this.activeThreadContext?.client.getThreadId());if(!A)return;await this.navigateToThread(A)}async navigateToThread(A){try{await this.connectToExistingThread(A.targetThreadID,{rethrowError:!0})}catch{A.rollback()}}setActiveClient({client:A,observer:Q}){this.setState(()=>{this.activeThreadContext={client:A,observer:Q}}),this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=Q.threadID().subscribe(($)=>{this.widget.onActiveThreadChange?.($)})}handleIdeSelection=async(A)=>{try{await this.widget.ideManager.connect(A)}catch(Q){u.error("Failed to connect to IDE",{error:Q});let $=Q instanceof Error?Q.message:String(Q);this.toastController.show(`IDE connection failed: ${$}`,"error",4000)}};dispose(){if(this.unregisterCommands?.(),this.unregisterCommands=null,this.pluginIntegration?.dispose(),this.pluginIntegration=null,this.mcpTrustIntegration?.dispose(),this.mcpTrustIntegration=null,this.updateRelaunchIntegration?.dispose(),this.updateRelaunchIntegration=null,this.activeThreadIDSubscription?.unsubscribe(),this.activeThreadIDSubscription=null,this.noticesPollingTimeout)clearTimeout(this.noticesPollingTimeout),this.noticesPollingTimeout=null;this.connectionErrorsSubscription?.unsubscribe(),this.configSubscription?.unsubscribe(),this.configSubscription=null,this.notices.dispose(),this.widget.notificationService.detach(),this.toastController.dispose(),super.dispose()}hasBlockingTopLevelModal(){return this.switchThreadPickerVisible||this.executorAlreadyConnectedDialog!==null||this.neoWelcomeVisible||(this.mcpTrustIntegration?.hasBlockingDialog()??!1)||(this.pluginIntegration?.hasBlockingDialog()??!1)}}function _r4(A,Q,$){let B={...A};for(let D of Ig3(Q,$)){if(!vE(A[D],Q[D]))continue;let J=$[D];if(J===void 0)delete B[D];else B[D]=J}return B}function Ig3(...A){return Array.from(new Set(A.flatMap((Q)=>Object.keys(Q))))}n4();function vr4(A,Q,$,B){let D=g_(A),J="\x1B[0m",E="\x1B[34m",F="\x1B[90m",Y="\x1B[2m",Z=[];if(A.archived)Z.push("\x1B[90m\x1B[2mArchived\x1B[0m");Z.push(`${D}`),Z.push(`\x1B[34m${Q}\x1B[0m`),Z.push(`\x1B[90mamp threads continue ${A.id}\x1B[0m`);let U=14,X=7,G=new gJ(U,X),V=new d9(42),z=new XN(U,X,U,X,U,X,0,A.agentMode??"smart","intensity","classic","braille",void 0,void 0,z0.default(),V);z.layout(M1.tight(U,X)),z.paint(G,0,0);let K=G.getBuffer().getCells(),I=0;for(let j=0;j<X;j++)if(K[j].some((k)=>k.char!==" ")){I=j;break}let W=X-1;for(let j=X-1;j>=0;j--)if(K[j].some((k)=>k.char!==" ")){W=j;break}function H(j,k){if(!j)return"";if(j.type==="rgb"){let{r:_,g:f,b:g}=j.value;if($.getColorDepth()>=24)return`\x1B[${k?38:48};2;${_};${f};${g}m`;let b=Ij(_,f,g);return`\x1B[${k?38:48};5;${b}m`}return""}let q=[];if(W>=I)for(let j=I;j<=W;j++){let k="";for(let _=0;_<U;_++){let f=K[j][_],g=f.char,b=H(f.style.fg,!0);k+=b+g+"\x1B[0m"}q.push(k)}let N=q.length,w=Math.max(N,Z.length),O=Math.floor((w-N)/2),L=Math.floor((w-Z.length)/2);for(let j=0;j<w;j++){let k=" ".repeat(U);if(j>=O&&j<O+N)k=q[j-O];let _=" ",f="";if(j>=L&&j<L+Z.length)f=Z[j-L];$.write(k+_+f+`
|
|
5317
5317
|
`)}if(B)$.write(`
|
|
5318
5318
|
\x1B[90m${B}\x1B[0m
|
|
5319
5319
|
`)}i0();i0();import{exec as $R}from"node:child_process";function FX0(A="idle"){try{if(A==="idle"){if(process.platform==="darwin")$R("afplay /System/Library/Sounds/Submarine.aiff");else if(process.platform==="win32")$R("powershell [console]::beep(800,200)");else if(process.platform==="linux")$R("paplay /usr/share/sounds/freedesktop/stereo/message.oga || beep")}else if(A==="idle-review"){if(process.platform==="darwin")$R("afplay /System/Library/Sounds/Glass.aiff")}else if(A==="requires-user-input"){if(process.platform==="darwin")$R("afplay /System/Library/Sounds/Ping.aiff");else if(process.platform==="win32")$R("powershell [console]::beep(1000,300)");else if(process.platform==="linux")$R("paplay /usr/share/sounds/freedesktop/stereo/dialog-information.oga || beep -f 1000 -l 100")}}catch(Q){u.error(`Failed to play notification sound (${A}):`,Q)}}xY0();var Wg3=2000,Hg3="Agent is ready",qg3="Waiting for approval";function kr4(A){let Q=!0,$=!0,B=A.configService.config.subscribe((W)=>{Q=W.settings["notifications.enabled"]??!0,$=W.settings["notifications.system.enabled"]!==!1}),D=0,J=()=>{let W=V?.prepareTerminalTitleForNotification();if(W!==void 0)process.stdout.write($Y0(W))},E=(W)=>{if(!Q)return;let H=Date.now();if(H-D<Wg3)return;if(D=H,Lj())return;if(fF0())J(),setTimeout(yF0,wo);else FX0(W)},F=()=>{E("idle"),z(Hg3)},Y=()=>{E("requires-user-input"),z(qg3)},Z=(W)=>W?.attempt===void 0||W.attempt===0,U=null,X=null,G=null,V,z=(W)=>{if(!Q||!$)return;if(Lj()&&!mo()&&!Vf())return;J(),setTimeout(()=>{process.stdout.write(Co(W))},wo)},K=()=>{U?.unsubscribe(),X?.unsubscribe(),U=null,X=null,G=null,V=void 0};return{attach:(W,H,q)=>{if(K(),V=q,H)X=H.subscribe({next:(N)=>{if(N===null)return;if(!Z(N))return;F()},error:(N)=>{u.debug("Neo notification active error stream errored",{error:N})}});U=W.subscribe({next:(N)=>{try{let w=G!==null&&pQ(G),O=G==="awaiting_approval",L=w||O;if(N==="awaiting_approval"&&!O)Y();else if(N==="idle"&&L)F()}catch(w){u.debug("Neo notification handling failed",{error:w})}finally{G=N}},error:(N)=>{u.debug("Neo notification agent state stream errored",{error:N})}})},detach:K,unsubscribe(){K(),B.unsubscribe()}}}function Ng3({initialUserInput:A,showNeoWelcome:Q,hideNeoWelcome:$,neoWelcomeVariant:B,neoWelcomeDismissed:D}){if($)return{show:!1,markDismissedOnDismiss:!1};if(B==="npm-migration")return{show:!0,markDismissedOnDismiss:!1};if(Q)return{show:!0,markDismissedOnDismiss:!0};let J=!A&&!D;return{show:J,markDismissedOnDismiss:J}}async function wg3(A){await tQ((Q)=>Of(Q,A,"interactive"))}async function Sr4(A,Q={}){let{initialThreadIDs:$=[],initialUserInput:B,getDefaultNewThreadVisibility:D,openThreadPickerOnStart:J=!1,observerOnly:E=!1,initialAgentMode:F,initialReasoningEffort:Y,onFirstFrame:Z,showNeoWelcome:U=!1,hideNeoWelcome:X=!1,neoWelcomeVariant:G="intro"}=Q,V=G==="npm-migration";if($.length>1)u.info("Resuming multiple initial threads",{threadIDs:$});let z=async(_)=>{let f=await A.getThreadFromServer(_);if(!f)return null;return OF0(f)},K=async(_)=>{let f=await A.getThreadFromServer(_);if(!f)throw Error(`Thread ${_} not found`);let g=await h9(_,A.configService,A.apiKey,{usesThreadActors:!0}),y=await zG({endpoint:A.rivetEndpoint,poolName:g.poolName}).threadActor.getOrCreate([_],{params:{wsToken:g.wsToken},createWithInput:{threadId:g.threadId,threadVersion:g.threadVersion,ownerUserId:g.ownerUserId,...g.agentMode?{agentMode:g.agentMode}:{}}}).fetch("/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({thread:KS4(f)}),skipReadyWait:!0});if(!y.ok&&y.status!==409)throw Error(`Thread import failed (${y.status}): ${await y.text()}`);try{await pS4(_,A.configService,A.apiKey,{executorType:"local-client"})}catch(p){u.warn("failed to mark thread as imported on server",{threadID:_,error:p instanceof Error?p.message:String(p)})}},I=new Oe0(A.rivetEndpoint,A.apiKey,A.configService,{clientID:pq.parse(`neo-${crypto.randomUUID()}`),toolService:A.toolService,skillService:A.skillService,requestPluginToolCall:(_)=>A.pluginService.event.toolCall(_),requestPluginToolResult:(_)=>A.pluginService.event.toolResult(_),pluginService:A.pluginService,invokeTool:async(_,f)=>{let g=typeof f.args==="object"&&f.args!==null?f.args:{},b=await QN({toolName:f.toolName,configService:A.configService,toolService:A.toolService,mcpService:A.mcpService,skillService:A.skillService,toolUseID:f.toolCallId,threadId:_});return A.toolService.invokeTool(f.toolName,{args:g},b)},persistLastThreadID:wg3,readFileSystemDirectory:A.readFileSystemDirectory},z,K),W=await _K(),H=Ng3({initialUserInput:B,showNeoWelcome:U,hideNeoWelcome:X,neoWelcomeVariant:G,neoWelcomeDismissed:W.neoWelcomeDismissed}),q={ampURL:A.ampURL,configService:A.configService,getThreadMarkdown:async(_)=>{let f=await A.getThreadFromServer(_);return f?LX(f):null},isInternalUser:A.isInternalUser,listThreads:A.listThreads,logFilePath:za,mcpServers:A.mcpService.servers,pluginPlatform:A.pluginPlatform,pluginService:A.pluginService,toolboxes:A.toolboxes,observerOnly:V?!1:E,sessionAgentMode:F??W.agentMode,explicitReasoningEffort:Y,lastReasoningEffortByMode:W.lastReasoningEffortByMode,lastSpeedByMode:W.lastSpeedByMode,settingsFilePath:A.settingsFilePath,splashOrbVisualStyle:Q.splashOrbVisualStyle??"neo",workspaceRoot:A.workspaceRoot},N=(_,f)=>{return tb4({ampURL:A.ampURL,configService:A.configService,threadID:_,signal:f})},w=new le0,O=kr4({configService:A.configService}),L=await A.configService.getLatest();H4.instance.tuiInstance.setOptions({queryOptions:{animationDisabled:L.settings["terminal.animation"]===!1}});let j=new Set,k=new u41;try{await po(new yA1({clientPool:I,listSkillsForThread:N,completionBuilder:A.completionBuilder,history:new ea,ideManager:w,configService:A.configService,updateService:A.updateService,initialThreadIDs:V?[]:$,notificationService:O,mcpTrustHandler:A.mcpTrustHandler,initialUserInput:V?void 0:B,getDefaultNewThreadVisibility:D,openThreadPickerOnStart:V?!1:J,workspaceSettingsFilePath:A.workspaceSettingsFilePath,neoContext:q,showNeoWelcome:H.show,neoWelcomeVariant:G,onActiveThreadChange:A.setActiveThreadID,onRelaunchRequested:k.request,onNeoWelcomeDismissed:H.markDismissedOnDismiss?()=>{tQ(Qh4).catch((f)=>{u.warn("Failed to mark Neo welcome as dismissed",{error:f})})}:void 0,onThreadArchived:(f)=>{j.add(f)},onFirstFrame:Z}));let _=I.lastActiveObservingClient;if(_&&k.shouldShowExitSummary){let{client:f,observer:g}=_,b=f.getThreadId();if(b){let v={id:b,title:g.title().getValue(),agentMode:g.agentMode,archived:j.has(b)},y=`${A.ampURL.replace(/\/$/,"")}/threads/${b}`;vr4(v,y,process.stdout)}}}finally{process.stdout.write(FN("")),O.unsubscribe(),I.dispose(),await A.dispose?.()}process.exit(k.relaunchIfRequested(A.workspaceRoot)??0)}F5();function uy(A){let Q=[],$={meta:{visibility:"private",sharedGroupIDs:[]}};if(A.workspace?.disablePrivateThreads)$.disabledReason="Disabled by workspace policy";if(Q.push($),A.workspace?.groups&&A.workspace.groups.length>0){let E={meta:{visibility:"private",shareWithAllCreatorGroups:!0}};if(A.creatorIsViewer===!1)E.disabledReason="Can only be set by thread creator";Q.push(E)}if(A.workspace)Q.push({meta:{visibility:"thread_workspace_shared"}});let B=A.workspace?.disablePublicSharing?"Disabled by workspace policy":void 0,D={meta:{visibility:"public_unlisted"}},J={meta:{visibility:"public_discoverable"}};if(B)D.disabledReason=B,J.disabledReason=B;return Q.push(D,J),Q}function fr4(A){if(A.visibility!=="private")return!0;if("shareWithAllCreatorGroups"in A&&A.shareWithAllCreatorGroups)return!0;return"sharedGroupIDs"in A&&A.sharedGroupIDs.length>0}function BR(A,Q={}){switch(A.visibility){case"thread_workspace_shared":return{text:"Workspace",description:"Visible to all members of the workspace"};case"public_discoverable":return{text:"Public",description:"Visible on public profile & publicly searchable"};case"public_unlisted":return{text:"Unlisted",description:"Visible to anyone on the Internet who has the link"};case"private":{let $="shareWithAllCreatorGroups"in A&&A.shareWithAllCreatorGroups,D=($?Q.workspace?.groups.map((J)=>J.id)??[]:("sharedGroupIDs"in A)?A.sharedGroupIDs:[]).reduce((J,E)=>{let F=Q.workspace?.groups.find((Y)=>Y.id===E)?.name;if(F)J.push(`'${F}'`);return J},[]);if(D.length>0)return{text:"Group",description:`Shared with ${Z4(D.length,"group")} ${D.join(", ")} and workspace admins`};if($)return{text:"Group",description:"Shared with creator groups and workspace admins"};return{text:"Private",description:Q.workspace?"Only visible to you and workspace admins":"Only you can see this thread"}}}}function YX0(A){if(A.visibility==="private")return"shareWithAllCreatorGroups"in A?"group":"private";if(A.visibility==="thread_workspace_shared")return"workspace";if(A.visibility==="public_unlisted")return"unlisted";return"public"}function Py(A,Q=null){let $=A!==null&&typeof A==="object"&&"visibility"in A?A.visibility:void 0;if(!$||typeof $!=="string")return;let D=uy({workspace:Q?.team??void 0}).filter((J)=>!J.disabledReason).map((J)=>YX0(J.meta));if(D.includes($))return Cg3($);if($==="group"&&!D.includes("group")){if(Q?.team?.groups!==void 0)return Error(`Group visibility is not available. You are not a member of any group in this workspace.
|
|
@@ -7075,7 +7075,7 @@ ${D}`,Q);this.line=$,this.column=B,this.codeblock=D}}/*!
|
|
|
7075
7075
|
`),J=[];for(let E=0;E<D.length;E++){let Z=D[E].replace(/\b(SELECT|FROM|WHERE|GROUP BY|ORDER BY|HAVING|LIMIT|JOIN|LEFT JOIN|RIGHT JOIN|INNER JOIN|ON|AND|OR|AS|IN|NOT|NULL|IS|BETWEEN|LIKE|EXISTS|UNION|DISTINCT|COUNT|SUM|AVG|MIN|MAX|DATE|TIMESTAMP_TRUNC|TIMESTAMP_SUB|CURRENT_TIMESTAMP|INTERVAL|CASE|WHEN|THEN|ELSE|END|WITH|INSERT|UPDATE|DELETE|SET|VALUES|INTO|CREATE|ALTER|DROP|TRUE|FALSE|ASC|DESC)\b/gi,"\x00$1\x01").split(/(\x00[^\x01]+\x01)/);for(let U of Z)if(U.startsWith("\x00")&&U.endsWith("\x01"))J.push(new C(U.slice(1,-1),new T({color:B.app.keybind,bold:!0})));else J.push(new C(U,new T({color:$.colorScheme.foreground})));if(E<D.length-1)J.push(new C(`
|
|
7076
7076
|
`))}return new b0({decoration:{color:$.colorScheme.background,border:m1.all(new d1(B.app.keybind,1,"rounded"))},child:new f0({padding:V0.symmetric(0,1),child:new d({text:new C(void 0,void 0,J)})})})}}class i31 extends X2{chartData;highlightIndex;showAxes;colors;constructor({key:A,chartData:Q,highlightIndex:$=null,showAxes:B=!0,colors:D=LG0}){super(A?{key:A}:{});this.chartData=Q,this.highlightIndex=$,this.showAxes=B,this.colors=D}createRenderObject(){return new c31({chartData:this.chartData,highlightIndex:this.highlightIndex,showAxes:this.showAxes,colors:this.colors})}updateRenderObject(A){let Q=A;Q.chartData=this.chartData,Q.highlightIndex=this.highlightIndex,Q.showAxes=this.showAxes,Q.colors=this.colors,Q.markNeedsLayout()}}function K06(A,Q,$,B,D,J,E){if(J<=0)return null;switch(A){case"horizontal-bar":{let F=$;return F>=0&&F<J?F:null}case"bar":case"stacked-bar":{let F=E?d2:0,Y=B-F;if(Y<=0)return null;let Z=Q-F;if(Z<0||Z>=Y)return null;let U=Math.max(1,Math.floor(Y/J)),X=Math.floor(Z/U);return X>=0&&X<J?X:null}case"line":case"sparkline":case"stacked-area":{let F=E?d2:0,Y=B-F;if(Y<=0)return null;let Z=Math.max(0,Math.min(Y-1,Q-F));if(J===1)return 0;let U=Y/(J-1),X=Math.round(Z/U);return Math.max(0,Math.min(J-1,X))}default:return null}}function ii3(A,Q,$,B,D,J,E,F){if(D<=0||Q<0||Q>=D)return null;let Y=2;switch(A){case"horizontal-bar":return{x:Math.floor($/2),y:Q};case"bar":case"stacked-bar":{let Z=J?d2:0,U=$-Z,X=B-(J?Y:0);if(U<=0||X<=0)return null;let G=Math.max(1,Math.floor(U/D)),V=Z+Q*G+Math.floor(G/2),z=F>0?E/F:0,K=Math.round((1-z)*(X-1));return{x:V,y:K}}case"line":case"sparkline":case"stacked-area":{let Z=J?d2:0,U=$-Z,X=B-(J?Y:0);if(U<=0||X<=0)return null;let G=D>1?Z+Math.round(Q/(D-1)*(U-1)):Z+Math.floor(U/2),V=F>0?E/F:0,z=Math.round((1-V)*(X-1));return{x:G,y:z}}default:return null}}function ni3(A){let Q=0;for(let $ of A)for(let B of $.points)if(B.value>Q)Q=B.value;return Q||1}function ai3(A,Q,$,B,D){if($.length<=1){let F=B(A.value),Y=A.meta?` (${A.meta})`:"";return A.label.length+2+F.length+Y.length}let J=A.label.length,E=0;for(let F of $){let Y=F.points[Q];if(!Y)continue;E+=Y.value;let Z=2+F.name.length+2+B(Y.value).length;J=Math.max(J,Z)}if(D){let F=9+B(E).length;J=Math.max(J,F)}return J}function oi3(A,Q,$,B,D,J,E){let F;try{let z=L1.of(A),K=O0.of(A);F={foreground:z.colorScheme.foreground,background:z.colorScheme.background,border:K.app.keybind}}catch{F={foreground:{type:"index",value:15},background:{type:"index",value:0},border:{type:"index",value:7}}}let Y=new T({color:F.foreground,bold:!0}),Z=new T({color:F.foreground}),U=new T({color:F.foreground,dim:!0}),X=[],G=new T({color:F.foreground,underline:!0}),V=(z,K)=>new C(K,G,void 0,OK(z),()=>{i6(A,z)});if(B.length<=1){if(X.push(new C(`${Q.label}: `,Y)),Q.link)X.push(V(Q.link,J(Q.value)));else X.push(new C(J(Q.value),Z));if(Q.meta)X.push(new C(` (${Q.meta})`,U))}else{let z=E==="stacked-bar"||E==="stacked-area";X.push(new C(`${Q.label}
|
|
7077
7077
|
`,Y));let K=0;for(let I=0;I<B.length;I++){let W=B[I],H=W.points[$];if(!H)continue;K+=H.value;let q=W.color??D[I%D.length]??F.foreground;if(X.push(new C("● ",new T({color:q}))),X.push(new C(`${W.name}: `,U)),H.link)X.push(V(H.link,J(H.value)));else X.push(new C(J(H.value),Z));if(I<B.length-1||z)X.push(new C(`
|
|
7078
|
-
`))}if(z)X.push(new C(" ",U)),X.push(new C("Total: ",U)),X.push(new C(J(K),Z))}return new b0({decoration:{color:F.background,border:m1.all(new d1(F.border,1,"rounded"))},child:new d({text:new C(void 0,void 0,X)})})}i0();function I06(A){return A.length===0?A:A[0].toLowerCase()+A.slice(1)}F5();l5();k5();T$();M9();r2();uQ();xH();n4();kv();E_();u1();i0();M9();class n31{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(A,Q){this.enabled=A;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let A=Array.from(this.commandCounts.entries()).map(([Q,$])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1779179243-g4e6089"},parameters:{metadata:{count:$}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(A);await C50(Q,this.configService)}catch(Q){u.error("Failed to export command telemetry events",Q)}}async submit(A){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(A)||0;this.commandCounts.set(A,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class Qw extends u0{props;constructor(A){super();this.props=A}createState(){return new W06}}class W06 extends R0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(A){let Q=($)=>{this.setState(()=>{this._state=$(this._state)})};return this.widget.props.builder(A,Q,this._state)}}class H06 extends R0{controller=new u2;focusNode=new o6({debugLabel:"CommandArgumentPrompt",onKey:(A)=>{if(A.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(A){let Q=O0.of(A),{colors:$,app:B}=Q,D=this.widget.props.isRequiredArg??!0,J=this.controller.text.trim().length>0,E=!D||J,F=m1.all(new d1($.foreground,1,"solid")),Y=new $B({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(V)=>{let z=V.trim();if(D&&z.length===0)return;this.widget.props.onSubmit(z)},autofocus:!0,style:{textColor:$.foreground,border:null},maxLines:1}),Z=new r0({children:[new b0({decoration:{color:$.background},child:new d({text:new C(">",new T({color:$.foreground}))})}),new R1({child:Y})]}),U=new b0({padding:V0.symmetric(1,0),child:new d({text:this.widget.props.title?new C(this.widget.props.title,new T({color:B.command,bold:!0})):new C("",void 0,[new C("Command: ",new T({color:$.foreground})),new C(this.widget.props.commandName,new T({color:B.command,bold:!0}))])})}),X=[];if(E)X.push(new C("Enter",new T({color:B.keybind}))),X.push(new C(" to submit, ",new T({color:$.foreground,dim:!0})));X.push(new C("Esc",new T({color:B.keybind}))),X.push(new C(" to cancel",new T({color:$.foreground,dim:!0})));let G=new b0({padding:V0.symmetric(1,0),child:new d({text:new C("",void 0,X)})});return new b0({decoration:{border:F,color:$.background},padding:V0.all(1),child:new S0({children:[U,new X0({height:1}),Z,new U3,G]})})}}class ps extends u0{props;constructor(A){super();this.props=A}createState(){return new H06}}uQ();class q06 extends R0{controller=new u2;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new o6({debugLabel:"CommandMultilinePrompt",onKey:(A)=>{if(A.key==="Escape"){if(this.isConfirmingClearInput){if(this.controller.clear(),this.setState(()=>{this.isConfirmingClearInput=!1,this.imageAttachments=[],this.imagePaths=[]}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;return"handled"}if(this.controller.text.trim()!==""||this.imageAttachments.length>0){if(this.setState(()=>{this.isConfirmingClearInput=!0}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout);return this.clearInputConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingClearInput=!1}),this.clearInputConfirmTimeout=null},1000),"handled"}return this.widget.props.onDismiss(),"handled"}return"ignored"}});initState(){if(this.widget.props.initialText)this.controller.text=this.widget.props.initialText;if(this.widget.props.initialImages)this.imageAttachments=[...this.widget.props.initialImages];this.focusNode.requestFocus()}_handleInsertImage=async(A)=>{if(this.imageAttachments.length>=O9)return!1;let Q=await TG(A);if(typeof Q==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Q],this.imagePaths=[...this.imagePaths,A]}),!1;return!1};_handlePopImage=()=>{if(this.imageAttachments.length>0)this.setState(()=>{this.imageAttachments=this.imageAttachments.slice(0,-1),this.imagePaths=this.imagePaths.slice(0,-1)})};dispose(){if(this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;this.focusNode.dispose(),this.controller.dispose()}build(A){let Q=O0.of(A),{colors:$,app:B}=Q,J=l1.of(A).size.height,E=Math.max(Math.floor(J*0.5),10),F=new dK({controller:this.controller,triggers:[new lF],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(V)=>{this.widget.props.onSubmit(V.trim(),this.imageAttachments)},theme:$,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:H4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),Y=new v4({debugLabel:"CommandMultilinePrompt",focusNode:this.focusNode,child:F}),Z=new b0({constraints:new M1({maxHeight:E}),padding:V0.symmetric(1,0),child:Y}),U=new b0({padding:V0.symmetric(1,0),child:new d({text:new C("",void 0,[new C("Command: ",new T({color:$.foreground})),new C(this.widget.props.commandName,new T({color:B.command,bold:!0}))])})}),X=new b0({padding:V0.symmetric(1,0),child:new d({text:this.isConfirmingClearInput?new C("",void 0,[new C("Esc",new T({color:B.keybind})),new C(" again to clear input",new T({color:$.foreground,dim:!0}))]):new C("",void 0,[new C("Press ",new T({color:$.foreground,dim:!0})),new C("Enter",new T({color:B.keybind})),new C(" to submit, ",new T({color:$.foreground,dim:!0})),new C("Esc",new T({color:B.keybind})),new C(" to clear",new T({color:$.foreground,dim:!0}))])})}),G=[U,new X0({height:1}),new R1({child:Z}),new X0({height:1}),X];return new b0({decoration:{border:m1.all(new d1($.foreground,1,"solid")),color:$.background},padding:V0.all(1),child:new S0({children:G})})}}class a31 extends u0{props;constructor(A){super();this.props=A}createState(){return new q06}}function N06(A){let $=new Date().getTime()-A.getTime(),B=Math.floor($/60000),D=Math.floor($/3600000),J=Math.floor($/86400000);if(B<1)return"just now";if(B<60)return`${B}m ago`;if(D<24)return`${D}h ago`;if(J<7)return`${J}d ago`;return A.toLocaleDateString()}class o31 extends q1{props;debugLabel="NewsFeedPicker";constructor(A){super();this.props=A}build(A){let Q=[...this.props.entries].sort((D,J)=>J.pubDate.getTime()-D.pubDate.getTime()),$=Math.max(0,...Q.map((D)=>N06(D.pubDate).length));return new pA({items:Q,getLabel:(D)=>D.title,onAccept:(D)=>this.props.onSelect?.(D),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(D,J,E,F)=>{let Y=O0.of(F),{colors:Z}=Y,U=Y.app,X=J?U.selectionBackground:void 0,G=J?U.selectionForeground:Z.foreground,V=Z.mutedForeground,z=(K,I)=>new X0({width:I,child:r0.end([new d({text:new C(K,new T({color:V}))})])});return new b0({decoration:X?{color:X}:void 0,padding:V0.symmetric(2,0),child:new r0({children:[new R1({child:new d({text:new C(D.title,new T({color:G})),overflow:"ellipsis",maxLines:1})}),new X0({width:2}),z(N06(D.pubDate),$)]})})}})}}class Z${static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!Z$._instance)Z$._instance=new Z$;return Z$._instance}get allExpanded(){return this._allExpanded}setAllExpanded(A){if(this._allExpanded===A)return;this._allExpanded=A,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(A){return this._listeners.add(A),()=>this.removeListener(A)}removeListener(A){this._listeners.delete(A)}_notifyListeners(){for(let A of this._listeners)A()}}i0();class w06 extends R0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let A=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!A.ok){u.error("Failed to load labels",A.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=A.result,this.isLoading=!1,this.setState()}catch(A){u.error("Failed to load labels",A),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(A){let Q=A.trim().toLowerCase();if(Q.length===0)return null;if(Q.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Q))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(A){return this.getValidationError(A)===null&&A.length>0}getAvailableLabels(){let A=this.widget.props.currentLabels||[];return this.labels.filter((Q)=>!A.includes(Q.name))}shouldShowCreateMarker(A){if(A.length===0||this.isLoading)return!1;let Q=A.trim().toLowerCase();if(!this.isValidLabelName(Q))return!1;let $=this.widget.props.currentLabels||[],B=this.labels.some((J)=>J.name===Q),D=$.includes(Q);return!B&&!D}build(A){let Q=O0.of(A),{app:$,colors:B}=Q,D=this.currentQuery.trim().toLowerCase(),J=D.length>0?this.getValidationError(D):null,E=this.getAvailableLabels(),Y=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...E];return new pA({title:"Add Label",items:Y,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:J||"Type to create a new label",renderItem:(Z,U,X,G)=>{let V=U?$.selectionBackground:void 0,z=U?$.selectionForeground:B.foreground;if("__isCreateMarker"in Z&&Z.__isCreateMarker){let I=this.currentQuery.trim().toLowerCase();return new b0({decoration:V?{color:V}:void 0,padding:V0.symmetric(2,0),child:new d({text:new C("",void 0,[new C("Create new label: ",new T({color:z})),new C(I,new T({color:z,bold:!0}))])})})}return new b0({decoration:V?{color:V}:void 0,padding:V0.symmetric(2,0),child:new d({text:new C(Z.name,new T({color:z}))})})},filterItem:(Z,U)=>{if(this.currentQuery!==U)this.currentQuery=U,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in Z&&Z.__isCreateMarker)return this.shouldShowCreateMarker(U);let G=U.trim().toLowerCase();return G.length===0||Z.name.includes(G)},sortItems:(Z,U,X)=>{let G="__isCreateMarker"in Z.item&&Z.item.__isCreateMarker,V="__isCreateMarker"in U.item&&U.item.__isCreateMarker;if(G&&!V)return-1;if(!G&&V)return 1;return U.score-Z.score}})}}class r31 extends u0{props;constructor(A){super();this.props=A}createState(){return new w06}}class cZ extends u0{props;constructor(A){super();this.props=A}createState(){return new C06}}class C06 extends R0{_spinner=new HA;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(A){let Q=O0.of(A),{colors:$,app:B}=Q,D=m1.all(new d1($.foreground,1,"solid")),J=this._spinner.toBraille(),E=new d({textAlign:"center",text:new C("",void 0,[new C(J,new T({color:B.processing})),new C(" ",void 0),new C(this.widget.props.message,new T({color:$.foreground}))])}),Y=[new R1({child:new S0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[E]})})];if(this.widget.props.onAbort)Y.push(new X0({height:2,child:new b0({padding:V0.symmetric(2,0),child:new d({text:new C("",new T({dim:!0}),[new C("Press ",new T({color:$.foreground})),new C("Esc",new T({color:$.info})),new C(" to cancel",new T({color:$.foreground}))])})})}));let Z=new b0({decoration:new R4($.background,D),child:new X0({width:60,height:7,child:new S0({mainAxisAlignment:"start",children:Y})})});if(this.widget.props.onAbort)return new h4({debugLabel:"LoadingDialog",child:new v4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(U)=>{if(U.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:Z})});return Z}}class xG extends u0{props;constructor(A){super();this.props=A}createState(){return new M06}}class M06 extends R0{scrollController=new S6;scrollAreaKey=new E8("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(A){return A instanceof h8}resolveFooterStyle(A){if(this.isWidgetMessage(A))return A.footerStyle;return"default"}getViewportHeight(){let Q=this.scrollAreaKey.currentElement?.renderObject;if(Q&&"size"in Q){let $=Q.size;if(typeof $.height==="number"&&$.height>0)return this.viewportHeight=$.height,$.height}return this.viewportHeight}build(A){let Q=O0.of(A),$=this.widget.props.message,B=(()=>{if(this.isWidgetMessage($))return{title:$.title,type:$.type};if($ instanceof Error&&$.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:$.message};if($ instanceof Error&&$.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:$.message};let U=WZ0($);return{title:U.title,type:U.type,description:U.description}})(),D=B.type==="error"?Q.app.toolError:Q.app.command,J=m1.all(new d1(Q.colors.border,1,"solid")),E=new b0({padding:V0.symmetric(1,0),child:new d({text:new C(B.title,new T({color:D,bold:!0}))})}),F=this.isWidgetMessage($)?$.widget:new d({text:new C(B.description,new T({color:Q.colors.foreground})),selectable:!0}),Y=new R1({child:new Z5({child:new b0({padding:V0.symmetric(1,0),child:new r0({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new R1({child:new f6({controller:this.scrollController,autofocus:!0,child:F})}),new V8({controller:this.scrollController,thumbColor:Q.app.scrollbarThumb,trackColor:Q.app.scrollbarTrack,getScrollInfo:()=>{let U=this.scrollController.maxScrollExtent,X=this.scrollController.offset,G=this.getViewportHeight(),V=U+G;return{totalContentHeight:Math.max(V,0),viewportHeight:Math.max(G,1),scrollOffset:Math.max(X,0)}}})]})})})}),Z=new b0({padding:V0.symmetric(1,0),child:new d({text:(()=>{if(this.widget.props.onRetry)return new C("",void 0,[new C("Press ",new T({color:Q.colors.foreground,dim:!0})),new C("R",new T({color:Q.app.keybind})),new C(" to retry, ",new T({color:Q.colors.foreground,dim:!0})),new C("Esc",new T({color:Q.app.keybind})),new C(" to cancel",new T({color:Q.colors.foreground,dim:!0}))]);let U=this.resolveFooterStyle(this.widget.props.message);if(U==="none")return new C("",new T({color:Q.colors.foreground,dim:!0}));if(U==="help"){let X=new T({color:Q.app.keybind}),G=new T({color:Q.colors.foreground,dim:!0});return new C("",G,[new C("Press ",G),new C("Escape",X),new C(" to close • Use ",G),new C("↑↓",X),new C(" or ",G),new C("j/k",X),new C(" to scroll",G)])}return new C("Press any key to close",new T({color:Q.colors.foreground,dim:!0,italic:!0}))})()})});return new h4({debugLabel:"MessageDialog",child:new t4({fit:"expand",children:[new j1({onClick:()=>{},child:new X0}),new v4({onKey:(U)=>{if(this.widget.props.onRetry&&U.key==="r")return this.widget.props.onRetry(),"handled";if(U.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 b0({decoration:{border:J,color:Q.colors.background},padding:V0.all(1),child:new S0({mainAxisAlignment:"center",children:[E,new X0({height:1}),Y,Z]})})})]})})}}F5();Q4();class L06 extends u0{props;constructor(A){super();this.props=A}createState(){return new O06}}class O06 extends R0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((A)=>{this.plugins=A,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(A){let Q=l0.file(this.widget.props.cwd),$=B1.relativePath(Q,UA(A));if($!==null&&$!==""&&$!==".."&&!$.startsWith("../"))return $;return p3(A)}statusIcon(A){let Q=g2.default(),{colors:$,app:B}=Q;switch(A){case"loading":return{icon:"◌",color:$.warning};case"active":return{icon:"✓",color:B.toolSuccess};case"error":return{icon:"✗",color:B.toolError}}}build(A){let Q=O0.of(A),{app:$}=Q;if(this.plugins.length===0)return new d({text:new C("No plugins found.",new T({dim:!0}))});let B=[],D=this.plugins.length,J=this.plugins.filter((Y)=>Y.status==="active").length,E=this.plugins.reduce((Y,Z)=>Y+Z.registeredCommands.length,0),F=this.plugins.reduce((Y,Z)=>Y+Z.registeredTools.length,0);if(B.push(new C(`${J}/${D} ${Z4(D,"plugin")} active`,new T({bold:!0}))),E>0||F>0)B.push(new C(` (${E} ${Z4(E,"command")}, ${F} ${Z4(F,"tool")})`,new T({dim:!0})));B.push(new C(`
|
|
7078
|
+
`))}if(z)X.push(new C(" ",U)),X.push(new C("Total: ",U)),X.push(new C(J(K),Z))}return new b0({decoration:{color:F.background,border:m1.all(new d1(F.border,1,"rounded"))},child:new d({text:new C(void 0,void 0,X)})})}i0();function I06(A){return A.length===0?A:A[0].toLowerCase()+A.slice(1)}F5();l5();k5();T$();M9();r2();uQ();xH();n4();kv();E_();u1();i0();M9();class n31{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(A,Q){this.enabled=A;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let A=Array.from(this.commandCounts.entries()).map(([Q,$])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1779190035-gd08a72"},parameters:{metadata:{count:$}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(A);await C50(Q,this.configService)}catch(Q){u.error("Failed to export command telemetry events",Q)}}async submit(A){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(A)||0;this.commandCounts.set(A,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class Qw extends u0{props;constructor(A){super();this.props=A}createState(){return new W06}}class W06 extends R0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(A){let Q=($)=>{this.setState(()=>{this._state=$(this._state)})};return this.widget.props.builder(A,Q,this._state)}}class H06 extends R0{controller=new u2;focusNode=new o6({debugLabel:"CommandArgumentPrompt",onKey:(A)=>{if(A.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(A){let Q=O0.of(A),{colors:$,app:B}=Q,D=this.widget.props.isRequiredArg??!0,J=this.controller.text.trim().length>0,E=!D||J,F=m1.all(new d1($.foreground,1,"solid")),Y=new $B({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(V)=>{let z=V.trim();if(D&&z.length===0)return;this.widget.props.onSubmit(z)},autofocus:!0,style:{textColor:$.foreground,border:null},maxLines:1}),Z=new r0({children:[new b0({decoration:{color:$.background},child:new d({text:new C(">",new T({color:$.foreground}))})}),new R1({child:Y})]}),U=new b0({padding:V0.symmetric(1,0),child:new d({text:this.widget.props.title?new C(this.widget.props.title,new T({color:B.command,bold:!0})):new C("",void 0,[new C("Command: ",new T({color:$.foreground})),new C(this.widget.props.commandName,new T({color:B.command,bold:!0}))])})}),X=[];if(E)X.push(new C("Enter",new T({color:B.keybind}))),X.push(new C(" to submit, ",new T({color:$.foreground,dim:!0})));X.push(new C("Esc",new T({color:B.keybind}))),X.push(new C(" to cancel",new T({color:$.foreground,dim:!0})));let G=new b0({padding:V0.symmetric(1,0),child:new d({text:new C("",void 0,X)})});return new b0({decoration:{border:F,color:$.background},padding:V0.all(1),child:new S0({children:[U,new X0({height:1}),Z,new U3,G]})})}}class ps extends u0{props;constructor(A){super();this.props=A}createState(){return new H06}}uQ();class q06 extends R0{controller=new u2;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new o6({debugLabel:"CommandMultilinePrompt",onKey:(A)=>{if(A.key==="Escape"){if(this.isConfirmingClearInput){if(this.controller.clear(),this.setState(()=>{this.isConfirmingClearInput=!1,this.imageAttachments=[],this.imagePaths=[]}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;return"handled"}if(this.controller.text.trim()!==""||this.imageAttachments.length>0){if(this.setState(()=>{this.isConfirmingClearInput=!0}),this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout);return this.clearInputConfirmTimeout=setTimeout(()=>{this.setState(()=>{this.isConfirmingClearInput=!1}),this.clearInputConfirmTimeout=null},1000),"handled"}return this.widget.props.onDismiss(),"handled"}return"ignored"}});initState(){if(this.widget.props.initialText)this.controller.text=this.widget.props.initialText;if(this.widget.props.initialImages)this.imageAttachments=[...this.widget.props.initialImages];this.focusNode.requestFocus()}_handleInsertImage=async(A)=>{if(this.imageAttachments.length>=O9)return!1;let Q=await TG(A);if(typeof Q==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Q],this.imagePaths=[...this.imagePaths,A]}),!1;return!1};_handlePopImage=()=>{if(this.imageAttachments.length>0)this.setState(()=>{this.imageAttachments=this.imageAttachments.slice(0,-1),this.imagePaths=this.imagePaths.slice(0,-1)})};dispose(){if(this.clearInputConfirmTimeout)clearTimeout(this.clearInputConfirmTimeout),this.clearInputConfirmTimeout=null;this.focusNode.dispose(),this.controller.dispose()}build(A){let Q=O0.of(A),{colors:$,app:B}=Q,J=l1.of(A).size.height,E=Math.max(Math.floor(J*0.5),10),F=new dK({controller:this.controller,triggers:[new lF],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(V)=>{this.widget.props.onSubmit(V.trim(),this.imageAttachments)},theme:$,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:H4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),Y=new v4({debugLabel:"CommandMultilinePrompt",focusNode:this.focusNode,child:F}),Z=new b0({constraints:new M1({maxHeight:E}),padding:V0.symmetric(1,0),child:Y}),U=new b0({padding:V0.symmetric(1,0),child:new d({text:new C("",void 0,[new C("Command: ",new T({color:$.foreground})),new C(this.widget.props.commandName,new T({color:B.command,bold:!0}))])})}),X=new b0({padding:V0.symmetric(1,0),child:new d({text:this.isConfirmingClearInput?new C("",void 0,[new C("Esc",new T({color:B.keybind})),new C(" again to clear input",new T({color:$.foreground,dim:!0}))]):new C("",void 0,[new C("Press ",new T({color:$.foreground,dim:!0})),new C("Enter",new T({color:B.keybind})),new C(" to submit, ",new T({color:$.foreground,dim:!0})),new C("Esc",new T({color:B.keybind})),new C(" to clear",new T({color:$.foreground,dim:!0}))])})}),G=[U,new X0({height:1}),new R1({child:Z}),new X0({height:1}),X];return new b0({decoration:{border:m1.all(new d1($.foreground,1,"solid")),color:$.background},padding:V0.all(1),child:new S0({children:G})})}}class a31 extends u0{props;constructor(A){super();this.props=A}createState(){return new q06}}function N06(A){let $=new Date().getTime()-A.getTime(),B=Math.floor($/60000),D=Math.floor($/3600000),J=Math.floor($/86400000);if(B<1)return"just now";if(B<60)return`${B}m ago`;if(D<24)return`${D}h ago`;if(J<7)return`${J}d ago`;return A.toLocaleDateString()}class o31 extends q1{props;debugLabel="NewsFeedPicker";constructor(A){super();this.props=A}build(A){let Q=[...this.props.entries].sort((D,J)=>J.pubDate.getTime()-D.pubDate.getTime()),$=Math.max(0,...Q.map((D)=>N06(D.pubDate).length));return new pA({items:Q,getLabel:(D)=>D.title,onAccept:(D)=>this.props.onSelect?.(D),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(D,J,E,F)=>{let Y=O0.of(F),{colors:Z}=Y,U=Y.app,X=J?U.selectionBackground:void 0,G=J?U.selectionForeground:Z.foreground,V=Z.mutedForeground,z=(K,I)=>new X0({width:I,child:r0.end([new d({text:new C(K,new T({color:V}))})])});return new b0({decoration:X?{color:X}:void 0,padding:V0.symmetric(2,0),child:new r0({children:[new R1({child:new d({text:new C(D.title,new T({color:G})),overflow:"ellipsis",maxLines:1})}),new X0({width:2}),z(N06(D.pubDate),$)]})})}})}}class Z${static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!Z$._instance)Z$._instance=new Z$;return Z$._instance}get allExpanded(){return this._allExpanded}setAllExpanded(A){if(this._allExpanded===A)return;this._allExpanded=A,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(A){return this._listeners.add(A),()=>this.removeListener(A)}removeListener(A){this._listeners.delete(A)}_notifyListeners(){for(let A of this._listeners)A()}}i0();class w06 extends R0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let A=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!A.ok){u.error("Failed to load labels",A.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=A.result,this.isLoading=!1,this.setState()}catch(A){u.error("Failed to load labels",A),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(A){let Q=A.trim().toLowerCase();if(Q.length===0)return null;if(Q.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Q))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(A){return this.getValidationError(A)===null&&A.length>0}getAvailableLabels(){let A=this.widget.props.currentLabels||[];return this.labels.filter((Q)=>!A.includes(Q.name))}shouldShowCreateMarker(A){if(A.length===0||this.isLoading)return!1;let Q=A.trim().toLowerCase();if(!this.isValidLabelName(Q))return!1;let $=this.widget.props.currentLabels||[],B=this.labels.some((J)=>J.name===Q),D=$.includes(Q);return!B&&!D}build(A){let Q=O0.of(A),{app:$,colors:B}=Q,D=this.currentQuery.trim().toLowerCase(),J=D.length>0?this.getValidationError(D):null,E=this.getAvailableLabels(),Y=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...E];return new pA({title:"Add Label",items:Y,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:J||"Type to create a new label",renderItem:(Z,U,X,G)=>{let V=U?$.selectionBackground:void 0,z=U?$.selectionForeground:B.foreground;if("__isCreateMarker"in Z&&Z.__isCreateMarker){let I=this.currentQuery.trim().toLowerCase();return new b0({decoration:V?{color:V}:void 0,padding:V0.symmetric(2,0),child:new d({text:new C("",void 0,[new C("Create new label: ",new T({color:z})),new C(I,new T({color:z,bold:!0}))])})})}return new b0({decoration:V?{color:V}:void 0,padding:V0.symmetric(2,0),child:new d({text:new C(Z.name,new T({color:z}))})})},filterItem:(Z,U)=>{if(this.currentQuery!==U)this.currentQuery=U,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in Z&&Z.__isCreateMarker)return this.shouldShowCreateMarker(U);let G=U.trim().toLowerCase();return G.length===0||Z.name.includes(G)},sortItems:(Z,U,X)=>{let G="__isCreateMarker"in Z.item&&Z.item.__isCreateMarker,V="__isCreateMarker"in U.item&&U.item.__isCreateMarker;if(G&&!V)return-1;if(!G&&V)return 1;return U.score-Z.score}})}}class r31 extends u0{props;constructor(A){super();this.props=A}createState(){return new w06}}class cZ extends u0{props;constructor(A){super();this.props=A}createState(){return new C06}}class C06 extends R0{_spinner=new HA;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(A){let Q=O0.of(A),{colors:$,app:B}=Q,D=m1.all(new d1($.foreground,1,"solid")),J=this._spinner.toBraille(),E=new d({textAlign:"center",text:new C("",void 0,[new C(J,new T({color:B.processing})),new C(" ",void 0),new C(this.widget.props.message,new T({color:$.foreground}))])}),Y=[new R1({child:new S0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[E]})})];if(this.widget.props.onAbort)Y.push(new X0({height:2,child:new b0({padding:V0.symmetric(2,0),child:new d({text:new C("",new T({dim:!0}),[new C("Press ",new T({color:$.foreground})),new C("Esc",new T({color:$.info})),new C(" to cancel",new T({color:$.foreground}))])})})}));let Z=new b0({decoration:new R4($.background,D),child:new X0({width:60,height:7,child:new S0({mainAxisAlignment:"start",children:Y})})});if(this.widget.props.onAbort)return new h4({debugLabel:"LoadingDialog",child:new v4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(U)=>{if(U.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:Z})});return Z}}class xG extends u0{props;constructor(A){super();this.props=A}createState(){return new M06}}class M06 extends R0{scrollController=new S6;scrollAreaKey=new E8("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(A){return A instanceof h8}resolveFooterStyle(A){if(this.isWidgetMessage(A))return A.footerStyle;return"default"}getViewportHeight(){let Q=this.scrollAreaKey.currentElement?.renderObject;if(Q&&"size"in Q){let $=Q.size;if(typeof $.height==="number"&&$.height>0)return this.viewportHeight=$.height,$.height}return this.viewportHeight}build(A){let Q=O0.of(A),$=this.widget.props.message,B=(()=>{if(this.isWidgetMessage($))return{title:$.title,type:$.type};if($ instanceof Error&&$.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:$.message};if($ instanceof Error&&$.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:$.message};let U=WZ0($);return{title:U.title,type:U.type,description:U.description}})(),D=B.type==="error"?Q.app.toolError:Q.app.command,J=m1.all(new d1(Q.colors.border,1,"solid")),E=new b0({padding:V0.symmetric(1,0),child:new d({text:new C(B.title,new T({color:D,bold:!0}))})}),F=this.isWidgetMessage($)?$.widget:new d({text:new C(B.description,new T({color:Q.colors.foreground})),selectable:!0}),Y=new R1({child:new Z5({child:new b0({padding:V0.symmetric(1,0),child:new r0({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new R1({child:new f6({controller:this.scrollController,autofocus:!0,child:F})}),new V8({controller:this.scrollController,thumbColor:Q.app.scrollbarThumb,trackColor:Q.app.scrollbarTrack,getScrollInfo:()=>{let U=this.scrollController.maxScrollExtent,X=this.scrollController.offset,G=this.getViewportHeight(),V=U+G;return{totalContentHeight:Math.max(V,0),viewportHeight:Math.max(G,1),scrollOffset:Math.max(X,0)}}})]})})})}),Z=new b0({padding:V0.symmetric(1,0),child:new d({text:(()=>{if(this.widget.props.onRetry)return new C("",void 0,[new C("Press ",new T({color:Q.colors.foreground,dim:!0})),new C("R",new T({color:Q.app.keybind})),new C(" to retry, ",new T({color:Q.colors.foreground,dim:!0})),new C("Esc",new T({color:Q.app.keybind})),new C(" to cancel",new T({color:Q.colors.foreground,dim:!0}))]);let U=this.resolveFooterStyle(this.widget.props.message);if(U==="none")return new C("",new T({color:Q.colors.foreground,dim:!0}));if(U==="help"){let X=new T({color:Q.app.keybind}),G=new T({color:Q.colors.foreground,dim:!0});return new C("",G,[new C("Press ",G),new C("Escape",X),new C(" to close • Use ",G),new C("↑↓",X),new C(" or ",G),new C("j/k",X),new C(" to scroll",G)])}return new C("Press any key to close",new T({color:Q.colors.foreground,dim:!0,italic:!0}))})()})});return new h4({debugLabel:"MessageDialog",child:new t4({fit:"expand",children:[new j1({onClick:()=>{},child:new X0}),new v4({onKey:(U)=>{if(this.widget.props.onRetry&&U.key==="r")return this.widget.props.onRetry(),"handled";if(U.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 b0({decoration:{border:J,color:Q.colors.background},padding:V0.all(1),child:new S0({mainAxisAlignment:"center",children:[E,new X0({height:1}),Y,Z]})})})]})})}}F5();Q4();class L06 extends u0{props;constructor(A){super();this.props=A}createState(){return new O06}}class O06 extends R0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((A)=>{this.plugins=A,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(A){let Q=l0.file(this.widget.props.cwd),$=B1.relativePath(Q,UA(A));if($!==null&&$!==""&&$!==".."&&!$.startsWith("../"))return $;return p3(A)}statusIcon(A){let Q=g2.default(),{colors:$,app:B}=Q;switch(A){case"loading":return{icon:"◌",color:$.warning};case"active":return{icon:"✓",color:B.toolSuccess};case"error":return{icon:"✗",color:B.toolError}}}build(A){let Q=O0.of(A),{app:$}=Q;if(this.plugins.length===0)return new d({text:new C("No plugins found.",new T({dim:!0}))});let B=[],D=this.plugins.length,J=this.plugins.filter((Y)=>Y.status==="active").length,E=this.plugins.reduce((Y,Z)=>Y+Z.registeredCommands.length,0),F=this.plugins.reduce((Y,Z)=>Y+Z.registeredTools.length,0);if(B.push(new C(`${J}/${D} ${Z4(D,"plugin")} active`,new T({bold:!0}))),E>0||F>0)B.push(new C(` (${E} ${Z4(E,"command")}, ${F} ${Z4(F,"tool")})`,new T({dim:!0})));B.push(new C(`
|
|
7079
7079
|
|
|
7080
7080
|
`));for(let Y of this.plugins){let{icon:Z,color:U}=this.statusIcon(Y.status),X=this.getRelativePath(Y.uri);if(B.push(new C(`${Z} `,new T({color:U}))),B.push(new C(X,new T({bold:!0}))),B.push(new C(` ${Y.status}`,new T({dim:!0}))),B.push(new C(`
|
|
7081
7081
|
`)),Y.status==="active"&&Y.registeredEvents.length>0)B.push(new C(" Events: ",new T({dim:!0}))),B.push(new C(Y.registeredEvents.join(", "),new T({color:$.link}))),B.push(new C(`
|
|
@@ -7253,7 +7253,7 @@ ${t.content||""}`:t.content||"",y0=[],m0=t.baseDir.startsWith("file://")?tG0(t.b
|
|
|
7253
7253
|
`)}function E66(A,Q){A.command("usage").description("Show your current Amp usage and credit balance").action(async($,B)=>{let D=B.optsWithGlobals(),J=await Q(D),E=await J.settings.get("proxy"),F=G04({settings:{url:J.ampURL,proxy:E},secrets:{getToken:(Z,U)=>J.secrets.get(Z,U)}}),Y=await r4.userDisplayBalanceInfo({},{config:F});if(!Y.ok){if(Y.error.code==="auth-required")process.stderr.write(t0.red("Error: ")+"You must be logged in to view usage. Run `amp login` first.\n"),process.exit(1);process.stderr.write(t0.red("Error: ")+Y.error.message+`
|
|
7254
7254
|
`),process.exit(1)}process.stdout.write(await Kr3(Y.result.displayText)+`
|
|
7255
7255
|
`),process.exit(0)})}var x05=Rt.join(xB,"logs","headless.log"),e81=Rt.join(Zd,"device-id.json"),b05=`cli-tui-${S56(16).toString("hex")}`;async function h05(){let A=await Promise.all(kM.map(async(Q)=>{try{return{query:Q,hasConfigs:(await Q.listConfigs()).length>0}}catch($){return u.debug("Failed to detect query-based IDE integration",{ideName:Q.ideName,error:$}),{query:Q,hasConfigs:!1}}}));for(let Q of A)if(Q.hasConfigs)return Q.query;return}function y56(){h05().then((A)=>{if(A){let Q=p50(A.ideName);if(Q)jM(Q)}})}try{if(process.platform==="win32")await Promise.resolve().then(() => g4(Hx(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(A){U$.write(`Failed to change directory to ${process.env.AMP_PWD}: ${A}
|
|
7256
|
-
`)}function g05(A){process.emitWarning=(Q,$,B,D)=>{let J=typeof Q==="string"?Q:Q.message||String(Q),E=$||"Warning",F=!1;A.warn(J,{name:E,code:B})}}function c8(A,Q){if(A.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")EJ("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(A.getOptionValueSourceWithGlobals("mode")==="cli")EJ("experimental.agentMode",Q.mode);if(A.getOptionValueSourceWithGlobals("model")==="cli"&&Q.model)EJ("internal.model",p05(Q.model))}function R56(A){let Q=A.indexOf(":");if(Q===-1)throw new i1(`Invalid model format "${A}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let $=A.slice(0,Q).trim(),B=A.slice(Q+1).trim();if(!$||!B)throw new i1(`Invalid model format "${A}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function m05(A){if(A===void 0)return;let Q=A.trim();if(le1(Q))return Q;throw new i1(`Invalid effort "${A}". Expected one of: none, minimal, low, medium, high, xhigh, max.`,1)}function d05(A,Q){if(q2(A,Q))return;let $=pB(A)?.levels,B=$?` Allowed for ${A}: ${$.join(", ")}.`:"";throw new i1(`Reasoning effort "${Q}" is not available for ${A} mode.${B}`,1)}function p05(A){if(!A.includes("="))return R56(A),A;let Q={};for(let $ of A.split(",")){let B=$.trim();if(!B)continue;let D=B.indexOf("=");if(D===-1)throw new i1(`Invalid mode-specific model entry "${B}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let J=B.slice(0,D).trim(),E=B.slice(D+1).trim();if(!J)throw new i1(`Missing mode name in "${B}". Expected "mode=provider:model".`,1);if(!E)throw new i1(`Missing model value for mode "${J}". Expected "${J}=provider:model".`,1);R56(E),Q[J]=E}if(Object.keys(Q).length===0)throw new i1("No valid model overrides found in --model flag value.",1);return Q}function c05(A,Q){if(A.getOptionValueSourceWithGlobals("sp")==="cli"&&Q.sp)return Q.sp;if(A.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Q.systemPrompt)return Q.systemPrompt;return}async function l05(A){try{return await f56(A,"utf-8")}catch{return A}}async function A91(A,Q,$){let B=c05(A,Q);if(!B)return;let D=e6($)?$.features:[],J=e6($)?$.user.email:void 0;if(!_t(D,j$.HARNESS_SYSTEM_PROMPT)&&!(J&&y7(J)))throw new i1("You are not allowed to do this.",1);EJ("systemPrompt",await l05(B))}function _t(A,Q){return A?.some(($)=>$.name===Q&&$.enabled)??!1}function i05(A){return A!=="pending"}function UI(A){if(!e6(A))return null;return{...A.user,features:A.features??[],team:A.workspace??void 0}}function n05(A){let Q=UI(A);if(Q)return Q.id;if(PY(A))throw Error(A.error.message);throw Error("unreachable")}function a05(A){try{let Q=new URL(A);return Q.hostname==="localhost"||Q.hostname==="127.0.0.1"}catch{return A.includes("localhost")||A.includes("127.0.0.1")}}function o05(A){let B=a05(A)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new i1(`Couldn't connect to the Amp server at ${A}.`,1,B)}function ut(A,Q){let $=yo0(Error(A.error.message));if($.message===y9.networkOffline||$.message===y9.networkTimeout)return o05(Q);if($.message!==y9.internalBug)return new i1($.message,1,$.suggestion);return new i1(A.error.message.replace(/^Error: /,""),1)}async function r05(){if(process.versions.bun)return!1;try{return await IG()==="npm"}catch(A){return u.debug("Failed to detect package manager for Neo npm migration welcome",{error:A}),!1}}var u56=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH or with AMP_FORCE_BEL; enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(A)=>`${A?"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??TY,description:`Custom settings file path (overrides the default location ${TY})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(u).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${za})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","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:K9(),description:(A)=>A?"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:(A)=>A?"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:(A)=>A?"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:_M.SMART.key,description:`Set the agent mode (${dB({}).map((A)=>A.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:Array.from(new Set(dB().map((A)=>A.mode))),hiddenChoices:["frontier"]},{name:"effort",long:"effort",type:"option",description:"Set reasoning effort for the new thread, when supported by the selected mode",choices:["none","minimal","low","medium","high","xhigh","max"]},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable thread-actors mode and use the legacy worker runtime",hidden:!0},{name:"neoOrb",long:"neo-orb",type:"switch",description:"Use the experimental Neo splash orb",hidden:!0},{name:"hideWelcome",long:"hide-welcome",type:"switch",description:"Skip the welcome experience on startup",hidden:!0},{name:"showWelcome",long:"show-welcome",type:"switch",description:"Show the welcome experience on startup",hidden:!0},{name:"observe",long:"observe",type:"option",description:"Open the Neo TUI as an observer of an existing thread (thread ID or URL)",hidden:!0},{name:"headless",long:"headless",type:"optional-option",description:"Run headless thread-actor executor (no TUI). Optionally provide a thread ID to connect to existing thread, otherwise create one.",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},{name:"model",long:"model",type:"option",description:'Override the model. Use "provider:model" for all modes, or "mode=provider:model,mode=provider:model" for mode-specific overrides',hidden:!0}],P56=(A)=>("deprecated"in A)&&A.deprecated===!0,s05=(A)=>("hidden"in A)&&A.hidden===!0,t05=(A)=>("default"in A),e05=(A)=>("default"in A)?A.default:void 0;function mV0(A,Q){if(A.getOptionValueSourceWithGlobals("effort")!=="cli")return;let $=m05(Q.effort);if($!==void 0)d05(Q.mode,$);return $}function A15(A,Q){let $=Q.args[0],B=Q.commands.map((J)=>J.name());if($&&!$.includes(" ")&&$.length<30&&!/[./\\]/.test($)){let J=B.filter((F)=>$.includes(F)||F.includes($)),E="Run amp --help for a list of available commands.";if(J.length>0)E=`Did you mean: ${J.join(", ")}? Or run amp --help for all commands.`;throw new i1(y9.unknownCommand($),1,E)}}async function cV0(A){return{...A,getThreadEnvironment:zK,getEnvironmentData:(Q,$)=>vz(Q,$),skillService:A.skillService,fileChangeTrackerStorage:new HL,generateThreadTitle:IF4,deleteThread:(Q)=>A.threadService.delete(Q),getServerStatus:()=>xE(A.configService),pluginService:A.pluginService}}function x56(A){return{toolService:A.toolService,configService:A.configService,skillService:A.skillService,getThreadEnvironment:zK,getEnvironmentData:(Q,$)=>vz(Q,$)}}var dV0=l0.file(y05.homedir()),Q91=process.env.XDG_CONFIG_HOME?l0.file(process.env.XDG_CONFIG_HOME):B1.joinPath(dV0,".config");async function p2(A,Q,$){let B=$?.deferAuth??!1,D=$?.skipToolProviders??!1;ye1("0.0.
|
|
7256
|
+
`)}function g05(A){process.emitWarning=(Q,$,B,D)=>{let J=typeof Q==="string"?Q:Q.message||String(Q),E=$||"Warning",F=!1;A.warn(J,{name:E,code:B})}}function c8(A,Q){if(A.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")EJ("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(A.getOptionValueSourceWithGlobals("mode")==="cli")EJ("experimental.agentMode",Q.mode);if(A.getOptionValueSourceWithGlobals("model")==="cli"&&Q.model)EJ("internal.model",p05(Q.model))}function R56(A){let Q=A.indexOf(":");if(Q===-1)throw new i1(`Invalid model format "${A}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let $=A.slice(0,Q).trim(),B=A.slice(Q+1).trim();if(!$||!B)throw new i1(`Invalid model format "${A}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function m05(A){if(A===void 0)return;let Q=A.trim();if(le1(Q))return Q;throw new i1(`Invalid effort "${A}". Expected one of: none, minimal, low, medium, high, xhigh, max.`,1)}function d05(A,Q){if(q2(A,Q))return;let $=pB(A)?.levels,B=$?` Allowed for ${A}: ${$.join(", ")}.`:"";throw new i1(`Reasoning effort "${Q}" is not available for ${A} mode.${B}`,1)}function p05(A){if(!A.includes("="))return R56(A),A;let Q={};for(let $ of A.split(",")){let B=$.trim();if(!B)continue;let D=B.indexOf("=");if(D===-1)throw new i1(`Invalid mode-specific model entry "${B}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let J=B.slice(0,D).trim(),E=B.slice(D+1).trim();if(!J)throw new i1(`Missing mode name in "${B}". Expected "mode=provider:model".`,1);if(!E)throw new i1(`Missing model value for mode "${J}". Expected "${J}=provider:model".`,1);R56(E),Q[J]=E}if(Object.keys(Q).length===0)throw new i1("No valid model overrides found in --model flag value.",1);return Q}function c05(A,Q){if(A.getOptionValueSourceWithGlobals("sp")==="cli"&&Q.sp)return Q.sp;if(A.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Q.systemPrompt)return Q.systemPrompt;return}async function l05(A){try{return await f56(A,"utf-8")}catch{return A}}async function A91(A,Q,$){let B=c05(A,Q);if(!B)return;let D=e6($)?$.features:[],J=e6($)?$.user.email:void 0;if(!_t(D,j$.HARNESS_SYSTEM_PROMPT)&&!(J&&y7(J)))throw new i1("You are not allowed to do this.",1);EJ("systemPrompt",await l05(B))}function _t(A,Q){return A?.some(($)=>$.name===Q&&$.enabled)??!1}function i05(A){return A!=="pending"}function UI(A){if(!e6(A))return null;return{...A.user,features:A.features??[],team:A.workspace??void 0}}function n05(A){let Q=UI(A);if(Q)return Q.id;if(PY(A))throw Error(A.error.message);throw Error("unreachable")}function a05(A){try{let Q=new URL(A);return Q.hostname==="localhost"||Q.hostname==="127.0.0.1"}catch{return A.includes("localhost")||A.includes("127.0.0.1")}}function o05(A){let B=a05(A)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new i1(`Couldn't connect to the Amp server at ${A}.`,1,B)}function ut(A,Q){let $=yo0(Error(A.error.message));if($.message===y9.networkOffline||$.message===y9.networkTimeout)return o05(Q);if($.message!==y9.internalBug)return new i1($.message,1,$.suggestion);return new i1(A.error.message.replace(/^Error: /,""),1)}async function r05(){if(process.versions.bun)return!1;try{return await IG()==="npm"}catch(A){return u.debug("Failed to detect package manager for Neo npm migration welcome",{error:A}),!1}}var u56=[{name:"notifications",long:"notifications",type:"flag",description:(A)=>`${A?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH or with AMP_FORCE_BEL; enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(A)=>`${A?"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??TY,description:`Custom settings file path (overrides the default location ${TY})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(u).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${za})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","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:K9(),description:(A)=>A?"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:(A)=>A?"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:(A)=>A?"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:_M.SMART.key,description:`Set the agent mode (${dB({}).map((A)=>A.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:Array.from(new Set(dB().map((A)=>A.mode))),hiddenChoices:["frontier"]},{name:"effort",long:"effort",type:"option",description:"Set reasoning effort for the new thread, when supported by the selected mode",choices:["none","minimal","low","medium","high","xhigh","max"]},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable thread-actors mode and use the legacy worker runtime",hidden:!0},{name:"neoOrb",long:"neo-orb",type:"switch",description:"Use the experimental Neo splash orb",hidden:!0},{name:"hideWelcome",long:"hide-welcome",type:"switch",description:"Skip the welcome experience on startup",hidden:!0},{name:"showWelcome",long:"show-welcome",type:"switch",description:"Show the welcome experience on startup",hidden:!0},{name:"observe",long:"observe",type:"option",description:"Open the Neo TUI as an observer of an existing thread (thread ID or URL)",hidden:!0},{name:"headless",long:"headless",type:"optional-option",description:"Run headless thread-actor executor (no TUI). Optionally provide a thread ID to connect to existing thread, otherwise create one.",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},{name:"model",long:"model",type:"option",description:'Override the model. Use "provider:model" for all modes, or "mode=provider:model,mode=provider:model" for mode-specific overrides',hidden:!0}],P56=(A)=>("deprecated"in A)&&A.deprecated===!0,s05=(A)=>("hidden"in A)&&A.hidden===!0,t05=(A)=>("default"in A),e05=(A)=>("default"in A)?A.default:void 0;function mV0(A,Q){if(A.getOptionValueSourceWithGlobals("effort")!=="cli")return;let $=m05(Q.effort);if($!==void 0)d05(Q.mode,$);return $}function A15(A,Q){let $=Q.args[0],B=Q.commands.map((J)=>J.name());if($&&!$.includes(" ")&&$.length<30&&!/[./\\]/.test($)){let J=B.filter((F)=>$.includes(F)||F.includes($)),E="Run amp --help for a list of available commands.";if(J.length>0)E=`Did you mean: ${J.join(", ")}? Or run amp --help for all commands.`;throw new i1(y9.unknownCommand($),1,E)}}async function cV0(A){return{...A,getThreadEnvironment:zK,getEnvironmentData:(Q,$)=>vz(Q,$),skillService:A.skillService,fileChangeTrackerStorage:new HL,generateThreadTitle:IF4,deleteThread:(Q)=>A.threadService.delete(Q),getServerStatus:()=>xE(A.configService),pluginService:A.pluginService}}function x56(A){return{toolService:A.toolService,configService:A.configService,skillService:A.skillService,getThreadEnvironment:zK,getEnvironmentData:(Q,$)=>vz(Q,$)}}var dV0=l0.file(y05.homedir()),Q91=process.env.XDG_CONFIG_HOME?l0.file(process.env.XDG_CONFIG_HOME):B1.joinPath(dV0,".config");async function p2(A,Q,$){let B=$?.deferAuth??!1,D=$?.skipToolProviders??!1;ye1("0.0.1779190035-gd08a72");let J=f50({storage:A.settings,secretStorage:A.secrets,workspaceRoot:h0.of(l0.file(process.cwd())),defaultAmpURL:A.ampURL,homeDir:dV0,userConfigDir:Q91}),E=A.secrets.get("apiKey",A.ampURL),F=xE(J),Y=null,Z=()=>{return},U=new Promise((Q0)=>{Z=Q0}),X=E.then(async(Q0)=>{if(!Q0&&!B)await U;return Y??=F.subscribe(()=>{}),k1(F.pipe(c3(i05)))});X.catch(()=>{return}),Is4(J);let G=await J.getLatest();u.debug("Global configuration initialized",{settingsKeys:Object.keys(G.settings)});let V=!1;{let Q0=await E;if(V=Boolean(Q0),u.info("API key lookup before login",{found:Boolean(Q0),ampURL:A.ampURL,deferAuth:B}),!Q0)if(B)u.info("No API key found, continuing startup with deferred auth");else{A3.write(`No API key found. Starting login flow...
|
|
7257
7257
|
`);let M0=await Q15(A),n=await A.secrets.get("apiKey",A.ampURL);if(u.info("Login flow completed",{success:M0,storedKeyPresent:Boolean(n),ampURL:A.ampURL}),!M0)await VK(),process.exit(1);V=!0,Z()}}{let Q0=await J.getLatest(),M0=Q0.settings.url,n=Q0.secrets.isSet?.[M0];u.info("Config secrets state after login",{configURL:M0,apiKeySet:n?.apiKey??!1})}let z=B?"pending":await X;if(!B)u.info("Server status resolved",{status:"ready",isAuthenticated:e6(z),isError:PY(z),errorMessage:PY(z)?z.error.message:void 0});let K=X.then((Q0)=>n05(Q0));K.catch(()=>{return});let I=!Q.takeMeBack&&e6(z)&&_t(z.features,j$.THREAD_ACTORS_TUI),W=!1;if(process.env.AMP_DISABLE_PLUGINS==="1")u.warn("Ignoring AMP_DISABLE_PLUGINS outside development");let H=W?"off":I?"all":process.env.PLUGINS??"permissions",{toolService:q,dispose:N}=FR4({configService:J}),w=new Map,O=()=>w.clear(),L=new hy0(J,A.settings.getWorkspaceRootPath()),j=lD4({configService:J}),k=u74({configService:J,trustStore:L,skillMCPServers:j.skillMCPServers,uploadImageAttachments:I,createOAuthProvider:async(Q0,M0,n)=>{let a=`${Q0}:${M0}`,t=w.get(a);if(t)return u.debug("Reusing existing OAuth provider for server",{serverName:Q0,serverUrl:M0}),t;u.debug("Creating OAuth provider for server",{serverName:Q0,serverUrl:M0});let e=(async()=>{let E0=new hM(A.secrets),J0=await E0.getClientInfo(Q0,M0),N0=n?.scopes??J0?.scopes,C0=qf4();u.info("OAuth headless mode check",{useHeadless:C0,executeMode:A.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:A3.isTTY});let _0;if(C0)_0=A.executeMode?Hf4():Wf4(Q0);let U0=new ov0({storage:E0,serverName:Q0,serverUrl:M0,clientId:n?.clientId??J0?.clientId,clientSecret:n?.clientSecret??J0?.clientSecret,authUrl:n?.authUrl??J0?.authUrl,tokenUrl:n?.tokenUrl??J0?.tokenUrl,scopes:N0,headlessAuthHandler:_0});return u.debug("OAuth provider created",{serverName:Q0,serverUrl:M0,hasManualClientId:!!(n?.clientId??J0?.clientId),willUseDCR:!(n?.clientId??J0?.clientId),scopes:N0,headlessMode:C0,executeMode:A.executeMode}),U0})();return w.set(a,e),e}}),_=mn0({configService:J,spawn:RJ0}),f=Q.headless?dr4():void 0,g=f??new ZX0({configService:J}),b=g instanceof ZX0?g:void 0;if(b)b.pluginExecutorKind="local";let v=new a1(null),y=null,p=I&&!W?[...lr4(G.settings)?[{name:"permissions",entryPoint:gA1}]:[],{name:"thread-visibility",entryPoint:ar4(J,()=>X.then(UI),()=>y,(Q0)=>{y=Q0}),alwaysLoad:!0}]:[],c=Ax0({configService:J,platform:g,loadGlobalPlugins:Qt0(J),pluginFilter:H,activeThread$:v,internalPlugins:p}),h=wQ4(c),i=[k,_,h],r;if(D)r=new Map;else if(A.executeMode){let Q0=await KO4({toolService:q,providers:i,initialTimeout:15000});r=Q0.registrations;for(let[M0,n]of Q0.initErrors)u.warn(`${M0} provider initialization slow or failed:`,n)}else r=dn0({toolService:q,providers:i});if(Q.jetbrains)jM("JetBrains");else if(Q.ide&&cf4())jM("VS Code");else if(Q.ide&&lf4())jM("Neovim");else if(Q.ide&&(!I||A.executeMode||Q.takeMeBack))y56();if(A.executeMode)xe1(!0);let $0,w0=i5.status.pipe(N1((Q0)=>Boolean(Q0.connected&&Q0.authenticated&&Q0.ideName&&m04(Q0.ideName))),T4()).subscribe((Q0)=>{if(Q0){if(!$0)$0=q.registerTool(zO4)}else $0?.dispose(),$0=void 0}),Y0;if(!A.executeMode){let Q0=await A.settings.get("fuzzy.alwaysIncludePaths")??[];Y0=new vF0(process.cwd(),{alwaysIncludePaths:Q0},!0)}else Y0=new class extends vF0{async start(){}async query(){return[]}async queryCompletions(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};let W0=new $g0(Cl(J,{usesThreadActors:!1}),{maxThreads:200});u.info("Starting Amp background services");let A0=new iA1,j0={configService:J,toolService:q,mcpService:k,skillService:j,toolboxService:_,trustStore:L,threadService:W0,secretStorage:A.secrets,settingsStorage:A.settings,fuzzyServer:Y0,terminal:A0,pluginService:c,pluginPlatform:b,headlessPluginPlatform:f,activeThread$:v,serverStatus:z,serverStatusPromise:X,viewerUserIDPromise:K,hasAPIKeyAtStartup:V,consumeDraftNewThreadVisibility:()=>{let Q0=y;return y=null,Q0}};return{...j0,async asyncDispose(){if(j0.mcpService.hasAuthenticatingClients())u.info("Waiting for OAuth authentication to complete before exit..."),await j0.mcpService.waitForAuthentication();for(let Q0 of r.values())Q0.dispose();await j0.mcpService.dispose(),O(),await j0.threadService.asyncDispose(),j0.configService.unsubscribe(),Y?.unsubscribe(),N(),j0.fuzzyServer.dispose(),j0.settingsStorage[Symbol.dispose](),w0.unsubscribe(),$0?.dispose(),await j0.pluginService.dispose()}}}async function Q15(A){if(!A.executeMode){if(!await MY0("Would you like to log in to Amp? [(y)es, (n)o]: "))return A3.write(`Login cancelled. Run the command again to retry.
|
|
7258
7258
|
`),!1}return await b56(A)}async function b56(A){let Q=S56(32).toString("hex"),$=await Cf(A.ampURL,Q),B=new AbortController;try{await RY($,B.signal)}catch(J){u.error("Error opening browser",{error:J})}let D=await Cf(A.ampURL,Q,!1);A3.write(`If your browser does not open automatically, visit:
|
|
7259
7259
|
|
|
@@ -7261,7 +7261,7 @@ ${t0.blue.bold(D)}
|
|
|
7261
7261
|
|
|
7262
7262
|
`);try{return await Jb4(A.ampURL,Q,A.secrets,B),A3.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(J){return u.error("Login failed",{error:J}),U$.write(`
|
|
7263
7263
|
Login failed: ${J instanceof Error?J.message:String(J)}
|
|
7264
|
-
`),!1}}async function $15(A,Q,$){let B=await Q.get("apiKey",A);if(!B)throw new i1("No Amp API key found. Run `amp login` first.",1);let D=k05("curl",["-H",`Authorization: Bearer ${B}`,...$],{stdio:"inherit"});process.exitCode=await new Promise((J,E)=>{D.on("error",E),D.on("close",(F)=>J(F??1))})}function B15(A){let Q=new bq().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Q.exitOverride((I)=>{if(I.code==="commander.help"||I.code==="commander.version"||I.exitCode===0)lO(),process.exit(0);let W=I.originalError??I;R_4(W)}),ah4(Q,{version:"0.0.
|
|
7264
|
+
`),!1}}async function $15(A,Q,$){let B=await Q.get("apiKey",A);if(!B)throw new i1("No Amp API key found. Run `amp login` first.",1);let D=k05("curl",["-H",`Authorization: Bearer ${B}`,...$],{stdio:"inherit"});process.exitCode=await new Promise((J,E)=>{D.on("error",E),D.on("close",(F)=>J(F??1))})}function B15(A){let Q=new bq().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Q.exitOverride((I)=>{if(I.code==="commander.help"||I.code==="commander.version"||I.exitCode===0)lO(),process.exit(0);let W=I.originalError??I;R_4(W)}),ah4(Q,{version:"0.0.1779190035-gd08a72",buildTimestamp:"2026-05-19T11:32:14.941Z",buildType:"release"}),Q.addHelpText("after",mf4()),Q.configureHelp({formatHelp:df4}),Q.command("logout").description("Log out by removing stored API key").action(async(I,W)=>{let H=W.optsWithGlobals(),q=await g3(H);await V15(q)}),Q.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(I,W)=>{let H=W.optsWithGlobals(),q=await g3(H);await G15(q,await dA1(H,q.settings))}),L_4(Q,g3);let B=Q.command("internal",{hidden:!0}).description("Internal commands").command("curl [args...]").description("Internal: run curl with the current Amp API key as a bearer token").allowUnknownOption(!0).allowExcessArguments(!0).action(async(...I)=>{let W=I.find((w)=>typeof w==="object"&&w!==null&&typeof w.optsWithGlobals==="function")??B,H=I.filter((w)=>w!==W).flatMap((w)=>Array.isArray(w)?w:typeof w==="string"?[w]:[]),q=W.optsWithGlobals(),N=await g3(q);await $15(N.ampURL,N.secrets,H),process.exit(process.exitCode??0)});Q.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(I,W,H)=>{let q=H.optsWithGlobals(),N=await g3(q);await Zf4(I??"get",N.ampURL,N.secrets),process.exit(process.exitCode??0)}),Q.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(I,W)=>{let H=W.optsWithGlobals(),q=await g3(H);await Uf4(q.ampURL,q.secrets),process.exit(process.exitCode??0)}),Q.command("keyboard-tester",{hidden:!0}).summary("Keyboard input tester").description("Internal: stream parsed terminal input events as JSONL.").option("--raw","Log raw incoming terminal bytes before parsing").action(async(I)=>{await Dx4({raw:I.raw===!0}),process.exit(process.exitCode??0)}),Q.command("live-sync [threadIDOrURL]",{hidden:!0}).summary("Mirror live DTW thread changes into the current checkout").description("Experimental: watch a v2 thread URL or ID and mirror its live working-tree changes into your local checkout, or apply the current snapshot once and exit.").addHelpText("after",["","Examples:"," amp live-sync T-5928a90d-d53b-488f-a829-4e36442142ee"," amp live-sync --apply T-5928a90d-d53b-488f-a829-4e36442142ee"," amp live-sync https://ampcode.com/threads/T-5928a90d-d53b-488f-a829-4e36442142ee"].join(`
|
|
7265
7265
|
`)).option("--apply <threadIDOrURL>","Apply the current DTW thread snapshot once and exit").option("--checkout","Automatically check out the thread commit when it differs").option("--skip-checkout","Skip the startup checkout prompt when commits differ").action(async(I,W,H)=>{if(I&&W.apply)throw new i1("Choose either a positional thread ID/URL or --apply <thread-id>, not both.",1);let q=W.apply??I;if(!q||q.trim().length===0)A3.write(`live-sync watches a v2 thread and mirrors its live changes locally. Use --apply <thread-id> to materialize the current snapshot once and exit.
|
|
7266
7266
|
|
|
7267
7267
|
`),H.outputHelp(),process.exit(0);let N=R8(q)??r$(q),w=H.optsWithGlobals(),O=await g3(w);c8(H,w);let L=await p2(O,w),j=!1;try{if(W.checkout&&W.skipCheckout)throw new i1("Choose either --checkout or --skip-checkout, not both.",1);if(PY(L.serverStatus))throw ut(L.serverStatus,O.ampURL);let k=e6(L.serverStatus)?L.serverStatus.features:void 0;if(!_t(k,j$.V2))throw new i1("live-sync is not enabled for your user",1);await ax4({ampURL:O.ampURL,threadId:N,configService:L.configService,threadService:L.threadService,apiKey:process.env.AMP_API_KEY,applyOnce:typeof W.apply==="string",checkoutMode:W.checkout?"always":W.skipCheckout?"never":"prompt",promptForYesNo:MY0}),j=!0}finally{if(await L.asyncDispose(),j)process.exit(0)}});let D=async(I,W,H)=>{f50({storage:W.settings,secretStorage:W.secrets,workspaceRoot:h0.of(l0.file(process.cwd())),defaultAmpURL:W.ampURL,homeDir:dV0,userConfigDir:Q91});let q={...W,executeMode:!1};await pV0(q,{...I,openThreadSwitcher:!0},H,A)},J=Q.command("threads").alias("t").alias("thread").summary("Manage threads").description("Thread management commands. When no subcommand is provided, defaults to listing threads.").option("--include-archived","Include archived threads in the list").action(async(I,W)=>{let H=W.optsWithGlobals(),q=await g3(H);await k56(H,q,W)});J.command("new").alias("n").summary("Create a new thread").description("Create a new thread and print its ID. The thread will be empty. You can set the visibility using the --visibility option.").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").action(async(I,W)=>{let H=W.optsWithGlobals(),q=await g3(H);await j15(H,q,W)}),J.command("continue [threadIDOrURLs...]").alias("c").summary("Continue an existing thread").description("Continue an existing thread by resuming the conversation. By default, interactive mode shows a picker. Use --last to continue the last thread for the current mode directly. When multiple thread are given, all are resumed and the first is shown in the foreground.").option("--last","Continue the last thread for the current mode directly").option("--pick","Pick a thread interactively from a list (DEPRECATED: picker is now the default)").action(async(I,W,H)=>{let q=H.optsWithGlobals(),N=await g3(q),w=Array.isArray(I)?I:[];if(W.pick)U$.write(`${t0.yellow("Warning:")} The --pick flag is deprecated. The picker is now shown by default.
|
|
@@ -7294,8 +7294,8 @@ ${O}
|
|
|
7294
7294
|
`))}),W.args.length>0)A15(q,W);await pV0(q,H,W,A)}),qy4(Q),Q}async function Pt(A,Q){await tQ(($)=>Of($,A,Q))}async function _56(A,Q,$){let B=Date.now(),[D,J]=await Promise.all([r4.getThreadLinkInfo({thread:A},{config:Q}),$]);if(u.getChild("fetchAndStartThread").info(`Ownership check in ${Date.now()-B}ms`),D.ok){let E=D.result.creatorUserID;if(E&&E!==J&&!process.env.AMP_RESUME_OTHER_USER_THREADS_INSECURE)throw new i1(`Cannot resume thread created by another user.
|
|
7295
7295
|
|
|
7296
7296
|
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 h56(A){if(A.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof A.execute==="string"){let Q=(await zX0()).trimEnd();return{userInput:A.execute,stdinInput:Q||null}}return{userInput:(await zX0()).trimEnd(),stdinInput:null}}function g56(A,Q,$){if(A.streamJson&&!Q)throw new i1("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(A.streamJsonInput&&!Q)throw new i1("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(A.streamJsonInput&&!A.streamJson)throw new i1("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(A.stats&&A.streamJson)throw new i1("The --stats and --stream-json flags are mutually exclusive output formats",1,'Use one or the other: amp --execute "your message" --stats OR amp --execute "your message" --stream-json');if(A.stats&&!Q)throw new i1("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(A.archive&&!Q)throw new i1("The --archive flag requires --execute mode",1,'Use: amp --execute "your message" --archive');if(A.streamJsonInput&&typeof A.execute==="string"&&A.execute.trim()!=="")throw new i1("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"},{"type":"image","source":{"type":"base64","media_type":"image/png","data":"..."}}]}}' | amp --execute --stream-json --stream-json-input`);if(Q&&$===""&&!A.streamJsonInput&&!A.headless)throw new i1("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"
|
|
7297
|
-
Or pipe via stdin: echo "your message" | amp --execute`)}function D15(){S64([v50.parse({tool:"*",action:"allow"})]),F64({bypass:!0})}function J15(A){if(A.threadId&&!C9(A.threadId))delete A.threadId}async function pV0(A,Q,$,B){if(Q.headless)return E15(A,Q,$);let D=await p2(A,Q),J=await D.serverStatusPromise,E=e6(J)&&_t(J.features,j$.THREAD_ACTORS_TUI),F=E&&!Q.takeMeBack;if(Q.showWelcome&&Q.hideWelcome)throw await D.asyncDispose(),new i1("Cannot use --show-welcome and --hide-welcome together",1);if(Q.showWelcome&&!E)throw await D.asyncDispose(),new i1("--show-welcome is only available with the new Amp CLI feature flag",1);if(F){let Y=!A.executeMode&&await r05();return D15(),J15(Q),F15(A,Q,$,D,{showNpmMigrationWelcome:Y})}else{if(Q.threadId&&C9(Q.threadId)){let Y=await r4.getThreadLinkInfo({thread:Q.threadId},{config:D.configService}).catch(()=>null);if(Y?.ok&&Y.result.usesThreadActors)throw await D.asyncDispose(),new i1(`Thread ${Q.threadId} was created with the Neo TUI and cannot be continued in the legacy CLI.`,1,"Re-run without --take-me-back to continue this thread.")}return Y15(A,Q,$,B,{dependencies:D})}}async function E15(A,Q,$){let B=(W,H)=>{let q=Number(process.hrtime.bigint()-H)/1e6,N=jo0();u.info("Startup phase",{phase:W,phaseMs:Math.round(q),sinceMainMs:N===null?void 0:Math.round(N)})};c8($,Q);let D=process.hrtime.bigint(),J=await p2(A,Q);B("runMainThread:createThreadDependencies",D);let{serverStatus:E}=J;if(PY(E))throw ut(E,A.ampURL);let F=e6(E)?E:null,Y=F?.user.email;await A91($,Q,E);let Z=UI(E),U=Py(Q,Z);if(U instanceof Error)R3(U.message);if(F&&!PM(Q.mode,Y))throw new i1(`Agent mode '${Q.mode}' is only available for Amp employees`,1);if(process.env.AMP_EXECUTOR!=="1"&&(!Y||!y7(Y)))throw new i1("Headless executor mode is only available for Amp employees",1);fE0();let G=await J.secretStorage.get("apiKey",A.ampURL);if(!G)throw new i1("API key required for headless mode. Please run `amp login` first.",1);let V=typeof Q.headless==="string"&&Q.headless!=="true"?Q.headless:void 0;if(V&&!C9(V))throw new i1(`Invalid thread ID: ${V}`,1);let z=V?void 0:await L15({dependencies:J,apiKey:G,visibility:U??void 0}),K=V??z?.threadId;if(!K)throw new i1("Failed to resolve headless thread ID",1);let I=await Mf4(K);if(I.status==="already-running")await J.asyncDispose(),await VK(),process.exit(0);try{await zf4({ampURL:A.ampURL,apiKey:G,workspaceRoot:process.cwd(),threadId:K,ownerUserId:z?.ownerUserId,threadVersion:z?.threadVersion,agentMode:z?.agentMode,initialToolDiscovery:Promise.all([J.mcpService.initialized,J.toolboxService.initialized,J.pluginService.initialized]).then(()=>{return}),configService:J.configService,mcpService:J.mcpService,toolService:J.toolService,skillService:J.skillService,pluginService:J.pluginService,pluginPlatform:J.headlessPluginPlatform})}finally{await I.release(),await J.asyncDispose()}await VK(),process.exit(0)}async function F15(A,Q,$,B,D){let{userInput:J,stdinInput:E}=await h56(Q),F=!!Q.streamJson||!!Q.streamJsonThinking;g56({...Q,streamJson:F},A.executeMode,J),c8($,Q),X_4(),fE0();let Y=Q.threadId,Z=Q.resumeThreadIDs??(Y?[Y]:[]),U=Q.observe?R8(Q.observe)??r$(Q.observe):void 0,X=await B.serverStatusPromise;if(PY(X))throw ut(X,A.ampURL);let G=UI(X),V=Py(Q,G);if(V instanceof Error)R3(V.message);let z=null,K=async()=>{let H=B.consumeDraftNewThreadVisibility();if(H!==null)return H;return z??=(async()=>{let q=await Ka(A.settings,process.cwd(),G,V);if(q instanceof Error)R3(q.message);return q})(),z},I=await B.secretStorage.get("apiKey",A.ampURL);if(!I)throw new i1("API key required. Please run `amp login` first.",1);let W=e6(X)&&y7(X.user.email);if(A.executeMode){if(Z.length>1)throw new i1("Execute mode can only resume one thread.",1);Ye0(B.mcpService,A.settings);try{let H=mV0($,Q),q=await _K(),N=Y?H:OY0({agentMode:Q.mode,explicitEffort:H,sessionState:q}),w=Y?void 0:jY0(await Mf(B.configService),{agentMode:Q.mode,explicitEffort:H,sessionState:q}),O=Y?void 0:await K(),L=await rS4({apiKey:I,ampURL:A.ampURL,workspaceRoot:process.cwd(),dependencies:B,userInput:J,stdinInput:E,stats:!!Q.stats,streamJson:F,streamJsonThinking:!!Q.streamJsonThinking,streamJsonInput:!!Q.streamJsonInput,stdin:process.stdin,agentMode:Q.mode,reasoningEffort:N,labels:Q.label,initialThreadID:Y,initialThreadMeta:O,initialSettings:w});if(await Pt(L,"execute"),Q.archive)await B.threadService.archive(L,!0)}finally{await B.asyncDispose()}await VK(),process.exit(0)}else{let H=mV0($,Q),q=D.showNpmMigrationWelcome?"npm-migration":"intro",N=iF0("0.0.1779179243-g4e6089",B.settingsStorage,{startDelayMs:3000}),w=new LY0(B.mcpService,A.settings.getWorkspaceRootPath()),O=Cl(B.configService),L=new cs(B.fuzzyServer),j=process.cwd();await Sr4({ampURL:A.ampURL,apiKey:I,rivetEndpoint:process.env.RIVET_PUBLIC_ENDPOINT??bJ(A.ampURL),configService:B.configService,toolService:B.toolService,pluginPlatform:B.pluginPlatform,pluginService:B.pluginService,skillService:B.skillService,mcpService:B.mcpService,readFileSystemDirectory:({uri:k})=>Df({workspaceRoot:j},k),completionBuilder:L,updateService:N,workspaceRoot:j,listThreads:()=>O.listThreads(),getThreadFromServer:(k)=>O.getThread(k),toolboxes:B.toolboxService.toolboxes,isInternalUser:W,settingsFilePath:B.settingsStorage.getSettingsFilePath(),workspaceSettingsFilePath:B.settingsStorage.getWorkspaceSettingsPath(),mcpTrustHandler:w,setActiveThreadID:(k)=>B.activeThread$.next(k),dispose:()=>{return w.dispose(),N.dispose(),B.asyncDispose()}},{initialThreadIDs:U?[U]:Z,initialUserInput:J||void 0,getDefaultNewThreadVisibility:K,onFirstFrame:Q.ide?y56:void 0,openThreadPickerOnStart:Q.openThreadSwitcher,observerOnly:!!U,splashOrbVisualStyle:"neo",hideNeoWelcome:!!Q.hideWelcome,showNeoWelcome:Q.showWelcome,neoWelcomeVariant:q,initialAgentMode:$.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,initialReasoningEffort:H}),process.exit(0)}}async function Y15(A,Q,$,B,D){let J=process.hrtime.bigint(),E=(A0,j0)=>{let Q0=Number(process.hrtime.bigint()-j0)/1e6,M0=jo0();u.info("Startup phase",{phase:A0,phaseMs:Math.round(Q0),sinceMainMs:M0===null?void 0:Math.round(M0)})},{userInput:F,stdinInput:Y}=await h56(Q),Z=!!Q.streamJson||!!Q.streamJsonThinking;g56({...Q,streamJson:Z},A.executeMode,F),c8($,Q);let U=process.hrtime.bigint(),X=D?.dependencies??await p2(A,Q),G=X.hasAPIKeyAtStartup,V=X.serverStatus==="pending";if(u.info("Interactive auth startup mode",{deferInteractiveAuth:V,hasAPIKeyAtStartup:G,executeMode:A.executeMode,headless:Boolean(Q.headless)}),!D)E("runMainThread:createThreadDependencies",U);let{serverStatus:z}=X;if(!V&&PY(z))throw ut(z,A.ampURL);let K=e6(z)?z:null,I=K?.user.email,W=!!(I&&y7(I));if(W)fE0();if(!V)await A91($,Q,z);let H=UI(z),q=H?.features??[],N=H?.team??null,w=Py(Q,H);if(w instanceof Error)R3(w.message);if(K&&!PM(Q.mode,I))throw new i1(`Agent mode '${Q.mode}' is only available for Amp employees`,1);let O=Q.threadId&&C9(Q.threadId)?Q.threadId:void 0;U=process.hrtime.bigint();let L=await cV0(X);E("runMainThread:createWorkerDeps",U);let j=A.executeMode?void 0:async(A0)=>Pt(A0,"interactive"),k={threadService:X.threadService,workerDeps:L,createThread:async(A0)=>{let j0=V?await X.serverStatusPromise:z,Q0=await Ka(A.settings,process.cwd(),UI(j0),w);if(Q0 instanceof Error)R3(Q0.message);return j21(L,{threadMeta:Q0,agentMode:A0??Q.mode,onFirstAssistantMessage:j})},validateThreadOwnership:async(A0,j0)=>{if(j0?.nonBlockingOwnershipCheck){_56(A0,X.configService,X.viewerUserIDPromise).catch((Q0)=>{if(Q0 instanceof i1){if(j0.onOwnershipError){j0.onOwnershipError(Q0,A0);return}KK(Q0,A0);return}u.warn("Failed to validate thread ownership in CLI, allowing to open",{error:Q0})});return}try{await _56(A0,X.configService,X.viewerUserIDPromise)}catch(Q0){if(Q0 instanceof i1)throw Q0;u.warn("Failed to validate thread ownership in CLI, allowing to open",{error:Q0})}},switchThreadVisibility:w,switchThreadAgentMode:Q.mode,onFirstAssistantMessage:j,handleError:KK},_=async()=>{try{return $66(k,Q.threadId,{nonBlockingOwnershipCheck:Q.nonBlockingThreadOwnershipCheck})}catch(A0){if(A0 instanceof i1)throw A0;throw await KK(A0,Q.threadId),Error("handleError should have called process.exit()")}},f=(async()=>{if(V){u.info("Skipping initial free tier status fetch until auth is complete");return}try{let A0=await X.configService.getLatest(),j0=Lm(A0),Q0=await r4.getUserFreeTierStatus({},{config:X.configService,signal:AbortSignal.timeout(j0)});if(Q0.ok)return u.info("User free tier status:",Q0),Q0.result;return}catch(A0){u.error("Failed to fetch free tier status:",A0);return}})(),b=!A.executeMode?new sA1:null,v,y=null;if(b)v=b,y=(async()=>{let A0=V?await X.serverStatusPromise:X.serverStatus;if(PY(A0))throw ut(A0,A.ampURL);await A91($,Q,A0);let j0=process.hrtime.bigint(),Q0=await _();if(E("runMainThread:createThreadPool",j0),b.attach(Q0),F){let M0=await k1(Q0.threadHandles$);if(!M0)throw new i1("No active thread is available yet.",1);await M0.sendMessage({content:[{type:"text",text:F}]})}})(),y.catch(async(A0)=>{let j0=A0 instanceof Error?A0:Error(String(A0));b.setInitError(j0),await KK(A0,Q.threadId)});else U=process.hrtime.bigint(),v=await _(),E("runMainThread:createThreadPool",U);let p=Q.notifications!==void 0?Q.notifications:!A.executeMode;U=process.hrtime.bigint();let c=await X.configService.getLatest();if(E("runMainThread:configService.getLatest",U),U=process.hrtime.bigint(),ds4({configService:X.configService,threadService:X.threadService,threadPool:v,config:c,useNotifications:p}),E("runMainThread:createLegacyTuiNotificationService",U),A.executeMode){Ye0(X.mcpService,A.settings);let A0=mV0($,Q),j0=await _K(),Q0=O?A0:OY0({agentMode:Q.mode,explicitEffort:A0,sessionState:j0}),M0={userInput:F,stdinInput:Y,dependencies:X,streamJson:Z,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:A.ampURL,isInternalUser:W,agentMode:Q.mode,reasoningEffort:Q0,labels:Q.label},n=await a_4({threadPool:v,...M0});if(await Pt(n,"execute"),Q.archive)await X.threadService.archive(n,!0);await X.asyncDispose(),process.exit(0)}let h=!1,i=!1;if(Q.jetbrains||Q.ide){await l50();let A0=await kY({jetbrainsOnly:Q.jetbrains});if(A0.length===0){if(Q.jetbrains)h=!await X.configService.get("jetbrains.skipInstall")}else if(A0.length===1){let j0=A0[0];if(j0)i5.selectConfig(j0)}else i=!0}U=process.hrtime.bigint();let r=iF0("0.0.1779179243-g4e6089",X.settingsStorage,{startDelayMs:3000});E("runMainThread:createUpdateService",U),U=process.hrtime.bigint();let $0=new LY0(X.mcpService,A.settings.getWorkspaceRootPath());if(E("runMainThread:createMcpTrustHandler",U),F&&A.executeMode){let A0=await k1(v.threadHandles$);if(!A0)throw new i1("No active thread is available yet.",1);await A0.sendMessage({content:[{type:"text",text:F}]})}U=process.hrtime.bigint();let w0=await _K();E("runMainThread:loadSessionState",U),u.info("Loaded session state:",w0);let Y0=mV0($,Q),W0={...w0,launchCount:w0.launchCount+1,lastReasoningEffortByMode:Y0?{...w0.lastReasoningEffortByMode,[Q.mode]:Y0}:w0.lastReasoningEffortByMode};tQ((A0)=>({...A0,launchCount:A0.launchCount+1}));try{if(U=process.hrtime.bigint(),await Kt4({history:new ea,fuzzyServer:X.fuzzyServer,settingsStorage:X.settingsStorage,threadService:X.threadService,skillService:X.skillService,configService:X.configService,secretStorage:X.secretStorage,internalAPIClient:r4,threadPool:v,createSystemPromptDeps:async()=>x56(X),ideClient:i5,mcpService:X.mcpService,toolboxService:X.toolboxService,mcpTrustHandler:$0,updateService:r,pluginPlatform:X.pluginPlatform,pluginService:X.pluginService},{initialServerStatus:X.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:X.hasAPIKeyAtStartup,ampURL:A.ampURL,startupThreadID:O,showJetBrainsInstaller:h,showIdePickerHint:i,openThreadSwitcher:Q.openThreadSwitcher,jetbrainsMode:Q.jetbrains,clientId:b05,logFile:{path:B},sessionState:W0,freeTierStatusPromise:f,workspace:N??null,features:q,isInternalUser:W,initialAgentMode:$.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,splashOrbVisualStyle:Q.neoOrb?"neo":"classic",buildTimestamp:"2026-05-19T08:32:48.320Z"},(A0)=>new D31({...A0,threadPool:A0.threadPool},(j0)=>new L21({...j0,threadState:j0.threadState}))),E("runMainThread:mountApp-returned",U),y)await y}finally{await v.dispose().catch((A0)=>{u.error("Failed to dispose thread pool during shutdown",A0)})}await X.asyncDispose(),E("runMainThread:dependencies.asyncDispose",J),process.exit(0)}async function g3(A){if(u.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)}),A.interactive)U$.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
|
|
7298
|
-
`);let Q=!!A.execute||!process.stdout.isTTY&&!A.streamJson,$=process.stdout.isTTY&&process.stderr.isTTY;u.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:A.streamJson,executeFlag:A.execute});let B=await k74({get:async(F)=>{if(F!==Tp)return;try{let Y=await f56(e81,"utf-8");return JSON.parse(Y).installationID}catch{return}},set:async(F,Y)=>{if(F!==Tp)return;await S05(Rt.dirname(e81),{recursive:!0}),await f05(e81,JSON.stringify({installationID:Y},null,2),{mode:384})}},{clientType:"cli",platform:Z90()});be1(B);let D=await Gs4({...A,workspaceTrust:{current:!0,changes:Om},getHook:process.env.AMP_URL?(F,Y)=>{if(F==="url")return Promise.resolve(process.env.AMP_URL);return Y()}:void 0});if(A.mcpConfig){let F=await Kb4(A.mcpConfig);D=Ib4(D,F)}let J=Rt.dirname(D.getSettingsFilePath());XR4(Zd,J),D=Gs1(D);let E=await D.get("url","admin")??await D.get("url","global");if(!E)E=m7;if(u.info("Resolved Amp URL",{ampURL:E,settingsFile:D.getSettingsFilePath(),workspaceRoot:D.getWorkspaceRootPath()}),!yW(E))u.info("Targeting custom Amp server",{ampURL:E});return{executeMode:Q,isTTY:$,ampURL:E,settings:D,secrets:Es4(await dA1(A,D))}}function Z15(A){let Q={};for(let $=0;$<A.length;$++){let B=A[$];if(B?.startsWith("--")){let J=B.slice(2).replace(/-([a-z])/g,(F,Y)=>Y.toUpperCase()),E=A[$+1];if(E&&!E.startsWith("--"))Q[J]=E,$++}}return Q}function U15(A,Q){let $=A.includes("--headless")||A.some((D)=>D.startsWith("--headless=")),B=Rt.resolve(Q.logFile??process.env.AMP_LOG_FILE??($?x05:za));return{logLevel:Q.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:B}}async function X15(){J_4();let A=Z15(process.argv),Q=U15(process.argv,A),$=G_4(Q);RE0("silent");let B=process.argv.includes("--no-color"),D=process.argv.includes("--color"),J=process.stdout.isTTY&&process.stderr.isTTY;if(B||!D&&!J)t0.level=0;if(g05(u),u.info("Starting Amp CLI.",{version:"0.0.
|
|
7297
|
+
Or pipe via stdin: echo "your message" | amp --execute`)}function D15(){S64([v50.parse({tool:"*",action:"allow"})]),F64({bypass:!0})}function J15(A){if(A.threadId&&!C9(A.threadId))delete A.threadId}async function pV0(A,Q,$,B){if(Q.headless)return E15(A,Q,$);let D=await p2(A,Q),J=await D.serverStatusPromise,E=e6(J)&&_t(J.features,j$.THREAD_ACTORS_TUI),F=E&&!Q.takeMeBack;if(Q.showWelcome&&Q.hideWelcome)throw await D.asyncDispose(),new i1("Cannot use --show-welcome and --hide-welcome together",1);if(Q.showWelcome&&!E)throw await D.asyncDispose(),new i1("--show-welcome is only available with the new Amp CLI feature flag",1);if(F){let Y=!A.executeMode&&await r05();return D15(),J15(Q),F15(A,Q,$,D,{showNpmMigrationWelcome:Y})}else{if(Q.threadId&&C9(Q.threadId)){let Y=await r4.getThreadLinkInfo({thread:Q.threadId},{config:D.configService}).catch(()=>null);if(Y?.ok&&Y.result.usesThreadActors)throw await D.asyncDispose(),new i1(`Thread ${Q.threadId} was created with the Neo TUI and cannot be continued in the legacy CLI.`,1,"Re-run without --take-me-back to continue this thread.")}return Y15(A,Q,$,B,{dependencies:D})}}async function E15(A,Q,$){let B=(W,H)=>{let q=Number(process.hrtime.bigint()-H)/1e6,N=jo0();u.info("Startup phase",{phase:W,phaseMs:Math.round(q),sinceMainMs:N===null?void 0:Math.round(N)})};c8($,Q);let D=process.hrtime.bigint(),J=await p2(A,Q);B("runMainThread:createThreadDependencies",D);let{serverStatus:E}=J;if(PY(E))throw ut(E,A.ampURL);let F=e6(E)?E:null,Y=F?.user.email;await A91($,Q,E);let Z=UI(E),U=Py(Q,Z);if(U instanceof Error)R3(U.message);if(F&&!PM(Q.mode,Y))throw new i1(`Agent mode '${Q.mode}' is only available for Amp employees`,1);if(process.env.AMP_EXECUTOR!=="1"&&(!Y||!y7(Y)))throw new i1("Headless executor mode is only available for Amp employees",1);fE0();let G=await J.secretStorage.get("apiKey",A.ampURL);if(!G)throw new i1("API key required for headless mode. Please run `amp login` first.",1);let V=typeof Q.headless==="string"&&Q.headless!=="true"?Q.headless:void 0;if(V&&!C9(V))throw new i1(`Invalid thread ID: ${V}`,1);let z=V?void 0:await L15({dependencies:J,apiKey:G,visibility:U??void 0}),K=V??z?.threadId;if(!K)throw new i1("Failed to resolve headless thread ID",1);let I=await Mf4(K);if(I.status==="already-running")await J.asyncDispose(),await VK(),process.exit(0);try{await zf4({ampURL:A.ampURL,apiKey:G,workspaceRoot:process.cwd(),threadId:K,ownerUserId:z?.ownerUserId,threadVersion:z?.threadVersion,agentMode:z?.agentMode,initialToolDiscovery:Promise.all([J.mcpService.initialized,J.toolboxService.initialized,J.pluginService.initialized]).then(()=>{return}),configService:J.configService,mcpService:J.mcpService,toolService:J.toolService,skillService:J.skillService,pluginService:J.pluginService,pluginPlatform:J.headlessPluginPlatform})}finally{await I.release(),await J.asyncDispose()}await VK(),process.exit(0)}async function F15(A,Q,$,B,D){let{userInput:J,stdinInput:E}=await h56(Q),F=!!Q.streamJson||!!Q.streamJsonThinking;g56({...Q,streamJson:F},A.executeMode,J),c8($,Q),X_4(),fE0();let Y=Q.threadId,Z=Q.resumeThreadIDs??(Y?[Y]:[]),U=Q.observe?R8(Q.observe)??r$(Q.observe):void 0,X=await B.serverStatusPromise;if(PY(X))throw ut(X,A.ampURL);let G=UI(X),V=Py(Q,G);if(V instanceof Error)R3(V.message);let z=null,K=async()=>{let H=B.consumeDraftNewThreadVisibility();if(H!==null)return H;return z??=(async()=>{let q=await Ka(A.settings,process.cwd(),G,V);if(q instanceof Error)R3(q.message);return q})(),z},I=await B.secretStorage.get("apiKey",A.ampURL);if(!I)throw new i1("API key required. Please run `amp login` first.",1);let W=e6(X)&&y7(X.user.email);if(A.executeMode){if(Z.length>1)throw new i1("Execute mode can only resume one thread.",1);Ye0(B.mcpService,A.settings);try{let H=mV0($,Q),q=await _K(),N=Y?H:OY0({agentMode:Q.mode,explicitEffort:H,sessionState:q}),w=Y?void 0:jY0(await Mf(B.configService),{agentMode:Q.mode,explicitEffort:H,sessionState:q}),O=Y?void 0:await K(),L=await rS4({apiKey:I,ampURL:A.ampURL,workspaceRoot:process.cwd(),dependencies:B,userInput:J,stdinInput:E,stats:!!Q.stats,streamJson:F,streamJsonThinking:!!Q.streamJsonThinking,streamJsonInput:!!Q.streamJsonInput,stdin:process.stdin,agentMode:Q.mode,reasoningEffort:N,labels:Q.label,initialThreadID:Y,initialThreadMeta:O,initialSettings:w});if(await Pt(L,"execute"),Q.archive)await B.threadService.archive(L,!0)}finally{await B.asyncDispose()}await VK(),process.exit(0)}else{let H=mV0($,Q),q=D.showNpmMigrationWelcome?"npm-migration":"intro",N=iF0("0.0.1779190035-gd08a72",B.settingsStorage,{startDelayMs:3000}),w=new LY0(B.mcpService,A.settings.getWorkspaceRootPath()),O=Cl(B.configService),L=new cs(B.fuzzyServer),j=process.cwd();await Sr4({ampURL:A.ampURL,apiKey:I,rivetEndpoint:process.env.RIVET_PUBLIC_ENDPOINT??bJ(A.ampURL),configService:B.configService,toolService:B.toolService,pluginPlatform:B.pluginPlatform,pluginService:B.pluginService,skillService:B.skillService,mcpService:B.mcpService,readFileSystemDirectory:({uri:k})=>Df({workspaceRoot:j},k),completionBuilder:L,updateService:N,workspaceRoot:j,listThreads:()=>O.listThreads(),getThreadFromServer:(k)=>O.getThread(k),toolboxes:B.toolboxService.toolboxes,isInternalUser:W,settingsFilePath:B.settingsStorage.getSettingsFilePath(),workspaceSettingsFilePath:B.settingsStorage.getWorkspaceSettingsPath(),mcpTrustHandler:w,setActiveThreadID:(k)=>B.activeThread$.next(k),dispose:()=>{return w.dispose(),N.dispose(),B.asyncDispose()}},{initialThreadIDs:U?[U]:Z,initialUserInput:J||void 0,getDefaultNewThreadVisibility:K,onFirstFrame:Q.ide?y56:void 0,openThreadPickerOnStart:Q.openThreadSwitcher,observerOnly:!!U,splashOrbVisualStyle:"neo",hideNeoWelcome:!!Q.hideWelcome,showNeoWelcome:Q.showWelcome,neoWelcomeVariant:q,initialAgentMode:$.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,initialReasoningEffort:H}),process.exit(0)}}async function Y15(A,Q,$,B,D){let J=process.hrtime.bigint(),E=(A0,j0)=>{let Q0=Number(process.hrtime.bigint()-j0)/1e6,M0=jo0();u.info("Startup phase",{phase:A0,phaseMs:Math.round(Q0),sinceMainMs:M0===null?void 0:Math.round(M0)})},{userInput:F,stdinInput:Y}=await h56(Q),Z=!!Q.streamJson||!!Q.streamJsonThinking;g56({...Q,streamJson:Z},A.executeMode,F),c8($,Q);let U=process.hrtime.bigint(),X=D?.dependencies??await p2(A,Q),G=X.hasAPIKeyAtStartup,V=X.serverStatus==="pending";if(u.info("Interactive auth startup mode",{deferInteractiveAuth:V,hasAPIKeyAtStartup:G,executeMode:A.executeMode,headless:Boolean(Q.headless)}),!D)E("runMainThread:createThreadDependencies",U);let{serverStatus:z}=X;if(!V&&PY(z))throw ut(z,A.ampURL);let K=e6(z)?z:null,I=K?.user.email,W=!!(I&&y7(I));if(W)fE0();if(!V)await A91($,Q,z);let H=UI(z),q=H?.features??[],N=H?.team??null,w=Py(Q,H);if(w instanceof Error)R3(w.message);if(K&&!PM(Q.mode,I))throw new i1(`Agent mode '${Q.mode}' is only available for Amp employees`,1);let O=Q.threadId&&C9(Q.threadId)?Q.threadId:void 0;U=process.hrtime.bigint();let L=await cV0(X);E("runMainThread:createWorkerDeps",U);let j=A.executeMode?void 0:async(A0)=>Pt(A0,"interactive"),k={threadService:X.threadService,workerDeps:L,createThread:async(A0)=>{let j0=V?await X.serverStatusPromise:z,Q0=await Ka(A.settings,process.cwd(),UI(j0),w);if(Q0 instanceof Error)R3(Q0.message);return j21(L,{threadMeta:Q0,agentMode:A0??Q.mode,onFirstAssistantMessage:j})},validateThreadOwnership:async(A0,j0)=>{if(j0?.nonBlockingOwnershipCheck){_56(A0,X.configService,X.viewerUserIDPromise).catch((Q0)=>{if(Q0 instanceof i1){if(j0.onOwnershipError){j0.onOwnershipError(Q0,A0);return}KK(Q0,A0);return}u.warn("Failed to validate thread ownership in CLI, allowing to open",{error:Q0})});return}try{await _56(A0,X.configService,X.viewerUserIDPromise)}catch(Q0){if(Q0 instanceof i1)throw Q0;u.warn("Failed to validate thread ownership in CLI, allowing to open",{error:Q0})}},switchThreadVisibility:w,switchThreadAgentMode:Q.mode,onFirstAssistantMessage:j,handleError:KK},_=async()=>{try{return $66(k,Q.threadId,{nonBlockingOwnershipCheck:Q.nonBlockingThreadOwnershipCheck})}catch(A0){if(A0 instanceof i1)throw A0;throw await KK(A0,Q.threadId),Error("handleError should have called process.exit()")}},f=(async()=>{if(V){u.info("Skipping initial free tier status fetch until auth is complete");return}try{let A0=await X.configService.getLatest(),j0=Lm(A0),Q0=await r4.getUserFreeTierStatus({},{config:X.configService,signal:AbortSignal.timeout(j0)});if(Q0.ok)return u.info("User free tier status:",Q0),Q0.result;return}catch(A0){u.error("Failed to fetch free tier status:",A0);return}})(),b=!A.executeMode?new sA1:null,v,y=null;if(b)v=b,y=(async()=>{let A0=V?await X.serverStatusPromise:X.serverStatus;if(PY(A0))throw ut(A0,A.ampURL);await A91($,Q,A0);let j0=process.hrtime.bigint(),Q0=await _();if(E("runMainThread:createThreadPool",j0),b.attach(Q0),F){let M0=await k1(Q0.threadHandles$);if(!M0)throw new i1("No active thread is available yet.",1);await M0.sendMessage({content:[{type:"text",text:F}]})}})(),y.catch(async(A0)=>{let j0=A0 instanceof Error?A0:Error(String(A0));b.setInitError(j0),await KK(A0,Q.threadId)});else U=process.hrtime.bigint(),v=await _(),E("runMainThread:createThreadPool",U);let p=Q.notifications!==void 0?Q.notifications:!A.executeMode;U=process.hrtime.bigint();let c=await X.configService.getLatest();if(E("runMainThread:configService.getLatest",U),U=process.hrtime.bigint(),ds4({configService:X.configService,threadService:X.threadService,threadPool:v,config:c,useNotifications:p}),E("runMainThread:createLegacyTuiNotificationService",U),A.executeMode){Ye0(X.mcpService,A.settings);let A0=mV0($,Q),j0=await _K(),Q0=O?A0:OY0({agentMode:Q.mode,explicitEffort:A0,sessionState:j0}),M0={userInput:F,stdinInput:Y,dependencies:X,streamJson:Z,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:A.ampURL,isInternalUser:W,agentMode:Q.mode,reasoningEffort:Q0,labels:Q.label},n=await a_4({threadPool:v,...M0});if(await Pt(n,"execute"),Q.archive)await X.threadService.archive(n,!0);await X.asyncDispose(),process.exit(0)}let h=!1,i=!1;if(Q.jetbrains||Q.ide){await l50();let A0=await kY({jetbrainsOnly:Q.jetbrains});if(A0.length===0){if(Q.jetbrains)h=!await X.configService.get("jetbrains.skipInstall")}else if(A0.length===1){let j0=A0[0];if(j0)i5.selectConfig(j0)}else i=!0}U=process.hrtime.bigint();let r=iF0("0.0.1779190035-gd08a72",X.settingsStorage,{startDelayMs:3000});E("runMainThread:createUpdateService",U),U=process.hrtime.bigint();let $0=new LY0(X.mcpService,A.settings.getWorkspaceRootPath());if(E("runMainThread:createMcpTrustHandler",U),F&&A.executeMode){let A0=await k1(v.threadHandles$);if(!A0)throw new i1("No active thread is available yet.",1);await A0.sendMessage({content:[{type:"text",text:F}]})}U=process.hrtime.bigint();let w0=await _K();E("runMainThread:loadSessionState",U),u.info("Loaded session state:",w0);let Y0=mV0($,Q),W0={...w0,launchCount:w0.launchCount+1,lastReasoningEffortByMode:Y0?{...w0.lastReasoningEffortByMode,[Q.mode]:Y0}:w0.lastReasoningEffortByMode};tQ((A0)=>({...A0,launchCount:A0.launchCount+1}));try{if(U=process.hrtime.bigint(),await Kt4({history:new ea,fuzzyServer:X.fuzzyServer,settingsStorage:X.settingsStorage,threadService:X.threadService,skillService:X.skillService,configService:X.configService,secretStorage:X.secretStorage,internalAPIClient:r4,threadPool:v,createSystemPromptDeps:async()=>x56(X),ideClient:i5,mcpService:X.mcpService,toolboxService:X.toolboxService,mcpTrustHandler:$0,updateService:r,pluginPlatform:X.pluginPlatform,pluginService:X.pluginService},{initialServerStatus:X.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:X.hasAPIKeyAtStartup,ampURL:A.ampURL,startupThreadID:O,showJetBrainsInstaller:h,showIdePickerHint:i,openThreadSwitcher:Q.openThreadSwitcher,jetbrainsMode:Q.jetbrains,clientId:b05,logFile:{path:B},sessionState:W0,freeTierStatusPromise:f,workspace:N??null,features:q,isInternalUser:W,initialAgentMode:$.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,splashOrbVisualStyle:Q.neoOrb?"neo":"classic",buildTimestamp:"2026-05-19T11:32:14.941Z"},(A0)=>new D31({...A0,threadPool:A0.threadPool},(j0)=>new L21({...j0,threadState:j0.threadState}))),E("runMainThread:mountApp-returned",U),y)await y}finally{await v.dispose().catch((A0)=>{u.error("Failed to dispose thread pool during shutdown",A0)})}await X.asyncDispose(),E("runMainThread:dependencies.asyncDispose",J),process.exit(0)}async function g3(A){if(u.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)}),A.interactive)U$.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
|
|
7298
|
+
`);let Q=!!A.execute||!process.stdout.isTTY&&!A.streamJson,$=process.stdout.isTTY&&process.stderr.isTTY;u.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:A.streamJson,executeFlag:A.execute});let B=await k74({get:async(F)=>{if(F!==Tp)return;try{let Y=await f56(e81,"utf-8");return JSON.parse(Y).installationID}catch{return}},set:async(F,Y)=>{if(F!==Tp)return;await S05(Rt.dirname(e81),{recursive:!0}),await f05(e81,JSON.stringify({installationID:Y},null,2),{mode:384})}},{clientType:"cli",platform:Z90()});be1(B);let D=await Gs4({...A,workspaceTrust:{current:!0,changes:Om},getHook:process.env.AMP_URL?(F,Y)=>{if(F==="url")return Promise.resolve(process.env.AMP_URL);return Y()}:void 0});if(A.mcpConfig){let F=await Kb4(A.mcpConfig);D=Ib4(D,F)}let J=Rt.dirname(D.getSettingsFilePath());XR4(Zd,J),D=Gs1(D);let E=await D.get("url","admin")??await D.get("url","global");if(!E)E=m7;if(u.info("Resolved Amp URL",{ampURL:E,settingsFile:D.getSettingsFilePath(),workspaceRoot:D.getWorkspaceRootPath()}),!yW(E))u.info("Targeting custom Amp server",{ampURL:E});return{executeMode:Q,isTTY:$,ampURL:E,settings:D,secrets:Es4(await dA1(A,D))}}function Z15(A){let Q={};for(let $=0;$<A.length;$++){let B=A[$];if(B?.startsWith("--")){let J=B.slice(2).replace(/-([a-z])/g,(F,Y)=>Y.toUpperCase()),E=A[$+1];if(E&&!E.startsWith("--"))Q[J]=E,$++}}return Q}function U15(A,Q){let $=A.includes("--headless")||A.some((D)=>D.startsWith("--headless=")),B=Rt.resolve(Q.logFile??process.env.AMP_LOG_FILE??($?x05:za));return{logLevel:Q.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:B}}async function X15(){J_4();let A=Z15(process.argv),Q=U15(process.argv,A),$=G_4(Q);RE0("silent");let B=process.argv.includes("--no-color"),D=process.argv.includes("--color"),J=process.stdout.isTTY&&process.stderr.isTTY;if(B||!D&&!J)t0.level=0;if(g05(u),u.info("Starting Amp CLI.",{version:"0.0.1779190035-gd08a72",buildTimestamp:"2026-05-19T11:32:14.941Z"}),process.platform==="win32"&&Gj())Vy4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new i1(y9.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await B15($).parseAsync(process.argv)}ZR4().startActiveSpan("main",async(A)=>{process.on("exit",()=>A.end()),await X15().catch(KK)});async function G15(A,Q){let $=A.ampURL.includes("localhost")||A.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!$)await A.settings.set("url",process.env.AMP_URL,"global"),A3.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
|
|
7299
7299
|
`);else if(!yW(A.ampURL))A3.write(`Logging in to ${new URL(A.ampURL).hostname}
|
|
7300
7300
|
`);let B=process.env.AMP_API_KEY;if(B)A3.write(`API key found in environment variable, storing...
|
|
7301
7301
|
`),await Q.set("apiKey",B,A.ampURL),A3.write(`API key successfully stored.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sourcegraph/amp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1779190035-gd08a72",
|
|
4
4
|
"description": "Renamed to @ampcode/cli - see https://ampcode.com/news/npm-package-changes",
|
|
5
5
|
"homepage": "https://ampcode.com/",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"amp": "node_modules/@ampcode/cli/bin/amp.exe"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@ampcode/cli": "0.0.
|
|
11
|
+
"@ampcode/cli": "0.0.1779190035-gd08a72"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist/main.js",
|