@sourcegraph/amp 0.0.1776542811-g13eef6 → 0.0.1776557243-g13eef6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +8 -8
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -4689,12 +4689,12 @@ ${U}`))}},error:(D)=>{if(!H)H=!0,F(Error(`Failed to spawn brew: ${D.message}`))}
4689
4689
  ${U}`;if(K==="pnpm"&&U.includes("Unable to find the global bin directory"))B+=`
4690
4690
 
4691
4691
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
4692
- npm install -g @sourcegraph/amp`;F(Error(B))}},error:(D)=>{if(!W)W=!0,F(Error(`Failed to spawn ${K}: ${D.message}`))},complete:()=>{if(!W)W=!0,G()}})})}o0();o0();kN();async function KX0(J,Z){let X=`${Z||"https://registry.npmjs.org"}/@sourcegraph/amp/latest`,K=new AbortController,V=setTimeout(()=>K.abort(),5000);try{let G=await fetch(X,{signal:K.signal});if(!G.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let F=await G.json(),z=F.version??F["dist-tags"]?.latest;if(!z)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=mC4(J,z),W=q<0,H,D;if(F.time){let U=F.time[J],B=F.time[z],N=Date.now();if(U)H=Math.floor((N-new Date(U).getTime())/3600000);if(B)D=Math.floor((N-new Date(B).getTime())/3600000)}return S.info("NPM version comparison",{currentVersion:J,latestVersion:z,compareResult:q,hasUpdate:W,currentVersionAge:H,latestVersionAge:D}),{hasUpdate:W,latestVersion:z,currentVersion:J,currentVersionAge:H,latestVersionAge:D,source:"npm"}}catch(G){return S.debug("Error checking npm version",{error:G}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var sX3="https://static.ampcode.com/cli/cli-version.txt";async function VX0(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let Y=await fetch(`${sX3}?t=${Date.now()}`,{signal:Z.signal,cache:"no-store"});if(!Y.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let X=(await Y.text()).trim();if(!X||!/^\d+\.\d+\.\d+/.test(X))return{hasUpdate:!1,currentVersion:J,source:"bin"};let K=mC4(J,X),V=K<0;return S.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:K,hasUpdate:V}),{hasUpdate:V,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return S.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var tX3=604800000;function gC4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>tX3)return{ageMs:Q};return null}function mC4(J,Z){let Q=(V)=>{let[G,F]=V.split("-");return{parts:G?.split(".").map(Number)||[],label:F}},Y=Q(J),X=Q(Z),K=Math.max(Y.parts.length,X.parts.length);for(let V=0;V<K;V++){let G=Y.parts[V]||0,F=X.parts[V]||0;if(G<F)return-1;if(G>F)return 1}if(Y.label===X.label)return 0;if(!Y.label&&X.label)return 1;if(Y.label&&!X.label)return-1;if(Y.label&&X.label)return Y.label<X.label?-1:1;return 0}function zo0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,Y=Z[2],X=Q!==0?yz(Q):void 0;return{sha:Y,age:X}}catch{return null}}R1();function qo0(J,Z,Q={}){let Y=new A6,X=Y.pipe(u6({shouldCountRefs:!1}));return setImmediate(async()=>{let K=new yV().scoped("update"),V=Q.startDelayMs??0;if(V>0)await vz(V);let G=X.subscribe({next:(F)=>{K.debug("emit new state",F)}});try{let F=process.env.AMP_TEST_UPDATE_STATUS;if(F){K.debug("using fake update status for testing",{status:F}),await vz(500),Y.next(F);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){K.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let z=await Z.get("updates.mode");if(z==="disabled"){K.debug("checking disabled");return}let q=await YX0(),W=q==="binary"||q==="brew";K.debug("checking",{currentVersion:J,mode:z,packageManager:q,isBinaryDistribution:W});let H;if(W)H=await VX0(J);else{let U=await gj();H=await KX0(J,U)}if(!(H.latestVersion&&H.hasUpdate)){K.debug("no update available");return}let D=()=>{if(H.currentVersionAge!==void 0&&H.latestVersionAge!==void 0){let U=H.currentVersionAge-H.latestVersionAge,B=0.5;if(Math.abs(U)<0.5)return K.debug("versions too close together, suppressing update warning",{currentVersionAge:H.currentVersionAge,latestVersionAge:H.latestVersionAge,ageDifferenceHours:U}),!0}return!1};if(!z)z=q==="pnpm"?"warn":"auto",K.debug("no configured update mode; selected default based on package manager",{packageManager:q,mode:z});if(q==="brew"){if(!D())Y.next("update-available-brew");return}if(q==="binary"&&process.execPath!==Yo0()){if(K.debug("non-standard binary path, showing warning"),!D())Y.next("update-available-unrecognized-path");return}if(z==="warn"){if(!D())Y.next("update-available");return}if(!q){if(K.debug("auto-update not supported, falling back to warn mode"),!D())Y.next("update-available");return}if(q==="binary"&&process.platform==="win32"){if(K.debug("binary auto-update not supported on Windows, falling back to warn mode"),!D())Y.next("update-available");return}try{await Gn(H.latestVersion,q);let U=await bw(H.latestVersion),B={from:H.currentVersion,to:H.latestVersion,...U};if(U.status==="same")K.info("success",B),Y.next("updated");else K.warn("success with warning",B),Y.next("updated-with-warning")}catch(U){Y.next("update-error")}}catch(F){K.debug("check failed",{error:F})}finally{await vz(5000),Y.next("hidden"),G.unsubscribe(),Y.complete()}}),{state:X}}kN();import{stderr as oG}from"node:process";function pC4(J){let Z=new Zw().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(Y)=>{await sa0(Y.force||!1,Y.verbose||!1,"0.0.1776542811-g13eef6"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new Zw("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(Y)=>{await $K3(Y.targetVersion)});J.addCommand(Q)}function eX3(J){let Z=Boolean(J.isTTY),Q=0,Y=!1;function X(){if(!Z||!Y)return;J.write(`
4692
+ npm install -g @sourcegraph/amp`;F(Error(B))}},error:(D)=>{if(!W)W=!0,F(Error(`Failed to spawn ${K}: ${D.message}`))},complete:()=>{if(!W)W=!0,G()}})})}o0();o0();kN();async function KX0(J,Z){let X=`${Z||"https://registry.npmjs.org"}/@sourcegraph/amp/latest`,K=new AbortController,V=setTimeout(()=>K.abort(),5000);try{let G=await fetch(X,{signal:K.signal});if(!G.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let F=await G.json(),z=F.version??F["dist-tags"]?.latest;if(!z)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=mC4(J,z),W=q<0,H,D;if(F.time){let U=F.time[J],B=F.time[z],N=Date.now();if(U)H=Math.floor((N-new Date(U).getTime())/3600000);if(B)D=Math.floor((N-new Date(B).getTime())/3600000)}return S.info("NPM version comparison",{currentVersion:J,latestVersion:z,compareResult:q,hasUpdate:W,currentVersionAge:H,latestVersionAge:D}),{hasUpdate:W,latestVersion:z,currentVersion:J,currentVersionAge:H,latestVersionAge:D,source:"npm"}}catch(G){return S.debug("Error checking npm version",{error:G}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var sX3="https://static.ampcode.com/cli/cli-version.txt";async function VX0(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let Y=await fetch(`${sX3}?t=${Date.now()}`,{signal:Z.signal,cache:"no-store"});if(!Y.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let X=(await Y.text()).trim();if(!X||!/^\d+\.\d+\.\d+/.test(X))return{hasUpdate:!1,currentVersion:J,source:"bin"};let K=mC4(J,X),V=K<0;return S.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:K,hasUpdate:V}),{hasUpdate:V,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return S.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var tX3=604800000;function gC4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>tX3)return{ageMs:Q};return null}function mC4(J,Z){let Q=(V)=>{let[G,F]=V.split("-");return{parts:G?.split(".").map(Number)||[],label:F}},Y=Q(J),X=Q(Z),K=Math.max(Y.parts.length,X.parts.length);for(let V=0;V<K;V++){let G=Y.parts[V]||0,F=X.parts[V]||0;if(G<F)return-1;if(G>F)return 1}if(Y.label===X.label)return 0;if(!Y.label&&X.label)return 1;if(Y.label&&!X.label)return-1;if(Y.label&&X.label)return Y.label<X.label?-1:1;return 0}function zo0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,Y=Z[2],X=Q!==0?yz(Q):void 0;return{sha:Y,age:X}}catch{return null}}R1();function qo0(J,Z,Q={}){let Y=new A6,X=Y.pipe(u6({shouldCountRefs:!1}));return setImmediate(async()=>{let K=new yV().scoped("update"),V=Q.startDelayMs??0;if(V>0)await vz(V);let G=X.subscribe({next:(F)=>{K.debug("emit new state",F)}});try{let F=process.env.AMP_TEST_UPDATE_STATUS;if(F){K.debug("using fake update status for testing",{status:F}),await vz(500),Y.next(F);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){K.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let z=await Z.get("updates.mode");if(z==="disabled"){K.debug("checking disabled");return}let q=await YX0(),W=q==="binary"||q==="brew";K.debug("checking",{currentVersion:J,mode:z,packageManager:q,isBinaryDistribution:W});let H;if(W)H=await VX0(J);else{let U=await gj();H=await KX0(J,U)}if(!(H.latestVersion&&H.hasUpdate)){K.debug("no update available");return}let D=()=>{if(H.currentVersionAge!==void 0&&H.latestVersionAge!==void 0){let U=H.currentVersionAge-H.latestVersionAge,B=0.5;if(Math.abs(U)<0.5)return K.debug("versions too close together, suppressing update warning",{currentVersionAge:H.currentVersionAge,latestVersionAge:H.latestVersionAge,ageDifferenceHours:U}),!0}return!1};if(!z)z=q==="pnpm"?"warn":"auto",K.debug("no configured update mode; selected default based on package manager",{packageManager:q,mode:z});if(q==="brew"){if(!D())Y.next("update-available-brew");return}if(q==="binary"&&process.execPath!==Yo0()){if(K.debug("non-standard binary path, showing warning"),!D())Y.next("update-available-unrecognized-path");return}if(z==="warn"){if(!D())Y.next("update-available");return}if(!q){if(K.debug("auto-update not supported, falling back to warn mode"),!D())Y.next("update-available");return}if(q==="binary"&&process.platform==="win32"){if(K.debug("binary auto-update not supported on Windows, falling back to warn mode"),!D())Y.next("update-available");return}try{await Gn(H.latestVersion,q);let U=await bw(H.latestVersion),B={from:H.currentVersion,to:H.latestVersion,...U};if(U.status==="same")K.info("success",B),Y.next("updated");else K.warn("success with warning",B),Y.next("updated-with-warning")}catch(U){Y.next("update-error")}}catch(F){K.debug("check failed",{error:F})}finally{await vz(5000),Y.next("hidden"),G.unsubscribe(),Y.complete()}}),{state:X}}kN();import{stderr as oG}from"node:process";function pC4(J){let Z=new Zw().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(Y)=>{await sa0(Y.force||!1,Y.verbose||!1,"0.0.1776557243-g13eef6"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new Zw("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(Y)=>{await $K3(Y.targetVersion)});J.addCommand(Q)}function eX3(J){let Z=Boolean(J.isTTY),Q=0,Y=!1;function X(){if(!Z||!Y)return;J.write(`
4693
4693
  `),Y=!1,Q=0}function K(V){if(!Z)return;let G=V.padEnd(Q," ");J.write(`\r${G}`),Y=!0,Q=G.length}return{flushProgressLine:X,renderProgress:K}}async function $K3(J){let Q=process.platform==="win32"&&hj()?{currentExecutablePath:process.execPath}:void 0,{flushProgressLine:Y,renderProgress:X}=eX3(oG);if(process.env.AMP_SKIP_UPDATE_CHECK==="1")oG.write(n0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
4694
4694
 
4695
4695
  `));try{if(!J){oG.write(n0.blue(`Checking for updates...
4696
- `));let G=!1,F;if(hj()){let z=await VX0("0.0.1776542811-g13eef6");G=z.hasUpdate,F=z.latestVersion}else{let z=await gj(),q=await KX0("0.0.1776542811-g13eef6",z);G=q.hasUpdate,F=q.latestVersion}if(!G){let z=zo0("0.0.1776542811-g13eef6"),q=z?.age?`released ${z.age} ago`:`built ${yz(new Date("2026-04-18T20:10:46.198Z"))} ago`;oG.write(n0.green(`✓ Amp is already up to date on version ${"0.0.1776542811-g13eef6"} (${q})
4697
- `));let W=await bw("0.0.1776542811-g13eef6",Q);if(W.warning)oG.write(`
4696
+ `));let G=!1,F;if(hj()){let z=await VX0("0.0.1776557243-g13eef6");G=z.hasUpdate,F=z.latestVersion}else{let z=await gj(),q=await KX0("0.0.1776557243-g13eef6",z);G=q.hasUpdate,F=q.latestVersion}if(!G){let z=zo0("0.0.1776557243-g13eef6"),q=z?.age?`released ${z.age} ago`:`built ${yz(new Date("2026-04-19T00:10:59.131Z"))} ago`;oG.write(n0.green(`✓ Amp is already up to date on version ${"0.0.1776557243-g13eef6"} (${q})
4697
+ `));let W=await bw("0.0.1776557243-g13eef6",Q);if(W.warning)oG.write(`
4698
4698
  `+n0.yellow(W.warning)+`
4699
4699
  `);process.exit(0)}if(!F)oG.write(n0.yellow("[WARN] could not find latest version")),process.exit(0);J=F}oG.write(n0.blue(`Updating to version ${J}...
4700
4700
  `)),await Gn(J,void 0,(G)=>{Y(),oG.write(n0.dim(`Running: ${G}
@@ -5928,7 +5928,7 @@ ${X}`,Z);this.line=Q,this.column=Y,this.codeblock=X}}/*!
5928
5928
  `),K=[];for(let V=0;V<X.length;V++){let z=X[V].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 q of z)if(q.startsWith("\x00")&&q.endsWith("\x01"))K.push(new P(q.slice(1,-1),new g({color:Y.app.keybind,bold:!0})));else K.push(new P(q,new g({color:Q.colorScheme.foreground})));if(V<X.length-1)K.push(new P(`
5929
5929
  `))}return new l0({decoration:{color:Q.colorScheme.background,border:Y4.all(new Z4(Y.app.keybind,1,"rounded"))},child:new d0({padding:I0.symmetric(0,1),child:new J0({text:new P(void 0,void 0,K)})})})}}class _11 extends W2{chartData;highlightIndex;showAxes;colors;constructor({key:J,chartData:Z,highlightIndex:Q=null,showAxes:Y=!0,colors:X=zF0}){super(J?{key:J}:{});this.chartData=Z,this.highlightIndex=Q,this.showAxes=Y,this.colors=X}createRenderObject(){return new P11({chartData:this.chartData,highlightIndex:this.highlightIndex,showAxes:this.showAxes,colors:this.colors})}updateRenderObject(J){let Z=J;Z.chartData=this.chartData,Z.highlightIndex=this.highlightIndex,Z.showAxes=this.showAxes,Z.colors=this.colors,Z.markNeedsLayout()}}function Up4(J,Z,Q,Y,X,K,V){if(K<=0)return null;switch(J){case"horizontal-bar":{let G=Q;return G>=0&&G<K?G:null}case"bar":case"stacked-bar":{let G=V?O9:0,F=Y-G;if(F<=0)return null;let z=Z-G;if(z<0||z>=F)return null;let q=Math.max(1,Math.floor(F/K)),W=Math.floor(z/q);return W>=0&&W<K?W:null}case"line":case"sparkline":case"stacked-area":{let G=V?O9:0,F=Y-G;if(F<=0)return null;let z=Math.max(0,Math.min(F-1,Z-G));if(K===1)return 0;let q=F/(K-1),W=Math.round(z/q);return Math.max(0,Math.min(K-1,W))}default:return null}}function KT3(J,Z,Q,Y,X,K,V,G){if(X<=0||Z<0||Z>=X)return null;let F=2;switch(J){case"horizontal-bar":return{x:Math.floor(Q/2),y:Z};case"bar":case"stacked-bar":{let z=K?O9:0,q=Q-z,W=Y-(K?F:0);if(q<=0||W<=0)return null;let H=Math.max(1,Math.floor(q/X)),D=z+Z*H+Math.floor(H/2),U=G>0?V/G:0,B=Math.round((1-U)*(W-1));return{x:D,y:B}}case"line":case"sparkline":case"stacked-area":{let z=K?O9:0,q=Q-z,W=Y-(K?F:0);if(q<=0||W<=0)return null;let H=X>1?z+Math.round(Z/(X-1)*(q-1)):z+Math.floor(q/2),D=G>0?V/G:0,U=Math.round((1-D)*(W-1));return{x:H,y:U}}default:return null}}function VT3(J){let Z=0;for(let Q of J)for(let Y of Q.points)if(Y.value>Z)Z=Y.value;return Z||1}function GT3(J,Z,Q,Y,X){if(Q.length<=1){let G=Y(J.value),F=J.meta?` (${J.meta})`:"";return J.label.length+2+G.length+F.length}let K=J.label.length,V=0;for(let G of Q){let F=G.points[Z];if(!F)continue;V+=F.value;let z=2+G.name.length+2+Y(F.value).length;K=Math.max(K,z)}if(X){let G=9+Y(V).length;K=Math.max(K,G)}return K}function FT3(J,Z,Q,Y,X,K,V){let G;try{let U=f1.of(J),B=x0.of(J);G={foreground:U.colorScheme.foreground,background:U.colorScheme.background,border:B.app.keybind}}catch{G={foreground:{type:"index",value:15},background:{type:"index",value:0},border:{type:"index",value:7}}}let F=new g({color:G.foreground,bold:!0}),z=new g({color:G.foreground}),q=new g({color:G.foreground,dim:!0}),W=[],H=new g({color:G.foreground,underline:!0}),D=(U,B)=>new P(B,H,void 0,DX0(U),()=>{F3(J,U)});if(Y.length<=1){if(W.push(new P(`${Z.label}: `,F)),Z.link)W.push(D(Z.link,K(Z.value)));else W.push(new P(K(Z.value),z));if(Z.meta)W.push(new P(` (${Z.meta})`,q))}else{let U=V==="stacked-bar"||V==="stacked-area";W.push(new P(`${Z.label}
5930
5930
  `,F));let B=0;for(let N=0;N<Y.length;N++){let w=Y[N],L=w.points[Q];if(!L)continue;B+=L.value;let O=w.color??X[N%X.length]??G.foreground;if(W.push(new P("● ",new g({color:O}))),W.push(new P(`${w.name}: `,q)),L.link)W.push(D(L.link,K(L.value)));else W.push(new P(K(L.value),z));if(N<Y.length-1||U)W.push(new P(`
5931
- `))}if(U)W.push(new P(" ",q)),W.push(new P("Total: ",q)),W.push(new P(K(B),z))}return new l0({decoration:{color:G.background,border:Y4.all(new Z4(G.border,1,"rounded"))},child:new J0({text:new P(void 0,void 0,W)})})}o0();V9();OE();lJ();t3();A7();cd();bX();oJ();KY();sJ();uA();r4();Fm();oP();R1();o0();oJ();class T11{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1776542811-g13eef6"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await i40(Z,this.configService)}catch(Z){S.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class SL extends g0{props;constructor(J){super();this.props=J}createState(){return new Bp4}}class Bp4 extends h0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}class Np4 extends h0{controller=new c7;focusNode=new L6({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Z=x0.of(J),{colors:Q,app:Y}=Z,X=this.widget.props.isRequiredArg??!0,K=this.controller.text.trim().length>0,V=!X||K,G=Y4.all(new Z4(Q.foreground,1,"solid")),F=new JX({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(D)=>{let U=D.trim();if(X&&U.length===0)return;this.widget.props.onSubmit(U)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),z=new H1({children:[new l0({decoration:{color:Q.background},child:new J0({text:new P(">",new g({color:Q.foreground}))})}),new c1({child:F})]}),q=new l0({padding:I0.symmetric(1,0),child:new J0({text:new P("",void 0,[new P("Command: ",new g({color:Q.foreground})),new P(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),W=[];if(V)W.push(new P("Enter",new g({color:Y.keybind}))),W.push(new P(" to submit, ",new g({color:Q.foreground,dim:!0})));W.push(new P("Esc",new g({color:Y.keybind}))),W.push(new P(" to cancel",new g({color:Q.foreground,dim:!0})));let H=new l0({padding:I0.symmetric(1,0),child:new J0({text:new P("",void 0,W)})});return new l0({decoration:{border:G,color:Q.background},padding:I0.all(1),child:new c0({children:[q,new R0({height:1}),z,new S5,H]})})}}class qo extends g0{props;constructor(J){super();this.props=J}createState(){return new Np4}}sJ();class wp4 extends h0{controller=new c7;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new L6({debugLabel:"CommandMultilinePrompt",onKey:(J)=>{if(J.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(J)=>{if(this.imageAttachments.length>=VY)return!1;let Z=await mq(J);if(typeof Z==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Z],this.imagePaths=[...this.imagePaths,J]}),!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(J){let Z=x0.of(J),{colors:Q,app:Y}=Z,K=O4.of(J).size.height,V=Math.max(Math.floor(K*0.5),10),G=new gD({controller:this.controller,triggers:[new JV],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(D)=>{this.widget.props.onSubmit(D.trim(),this.imageAttachments)},theme:Q,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:l4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),F=new J6({focusNode:this.focusNode,child:G}),z=new l0({constraints:new j1({maxHeight:V}),padding:I0.symmetric(1,0),child:F}),q=new l0({padding:I0.symmetric(1,0),child:new J0({text:new P("",void 0,[new P("Command: ",new g({color:Q.foreground})),new P(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),W=new l0({padding:I0.symmetric(1,0),child:new J0({text:this.isConfirmingClearInput?new P("",void 0,[new P("Esc",new g({color:Y.keybind})),new P(" again to clear input",new g({color:Q.foreground,dim:!0}))]):new P("",void 0,[new P("Press ",new g({color:Q.foreground,dim:!0})),new P("Enter",new g({color:Y.keybind})),new P(" to submit, ",new g({color:Q.foreground,dim:!0})),new P("Esc",new g({color:Y.keybind})),new P(" to clear",new g({color:Q.foreground,dim:!0}))])})}),H=[q,new R0({height:1}),new c1({child:z}),new R0({height:1}),W];return new l0({decoration:{border:Y4.all(new Z4(Q.foreground,1,"solid")),color:Q.background},padding:I0.all(1),child:new c0({children:H})})}}class S11 extends g0{props;constructor(J){super();this.props=J}createState(){return new wp4}}function Lp4(J){let Q=new Date().getTime()-J.getTime(),Y=Math.floor(Q/60000),X=Math.floor(Q/3600000),K=Math.floor(Q/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(K<7)return`${K}d ago`;return J.toLocaleDateString()}class k11 extends x1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((X,K)=>K.pubDate.getTime()-X.pubDate.getTime()),Q=Math.max(0,...Z.map((X)=>Lp4(X.pubDate).length));return new k8({items:Z,getLabel:(X)=>X.title,onAccept:(X)=>this.props.onSelect?.(X),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(X,K,V,G)=>{let F=x0.of(G),{colors:z}=F,q=F.app,W=K?q.selectionBackground:void 0,H=K?q.selectionForeground:z.foreground,D=z.mutedForeground,U=(B,N)=>new R0({width:N,child:H1.end([new J0({text:new P(B,new g({color:D}))})])});return new l0({decoration:W?{color:W}:void 0,padding:I0.symmetric(2,0),child:new H1({children:[new c1({child:new J0({text:new P(X.title,new g({color:H})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),U(Lp4(X.pubDate),Q)]})})}})}}class SJ{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!SJ._instance)SJ._instance=new SJ;return SJ._instance}get allExpanded(){return this._allExpanded}setAllExpanded(J){if(this._allExpanded===J)return;this._allExpanded=J,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(J){return this._listeners.add(J),()=>this.removeListener(J)}removeListener(J){this._listeners.delete(J)}_notifyListeners(){for(let J of this._listeners)J()}}o0();class Op4 extends h0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let J=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!J.ok){S.error("Failed to load labels",J.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=J.result,this.isLoading=!1,this.setState()}catch(J){S.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],Y=this.labels.some((K)=>K.name===Z),X=Q.includes(Z);return!Y&&!X}build(J){let Z=x0.of(J),{app:Q,colors:Y}=Z,X=this.currentQuery.trim().toLowerCase(),K=X.length>0?this.getValidationError(X):null,V=this.getAvailableLabels(),F=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...V];return new k8({title:"Add Label",items:F,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:K||"Type to create a new label",renderItem:(z,q,W,H)=>{let D=q?Q.selectionBackground:void 0,U=q?Q.selectionForeground:Y.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new l0({decoration:D?{color:D}:void 0,padding:I0.symmetric(2,0),child:new J0({text:new P("",void 0,[new P("Create new label: ",new g({color:U})),new P(N,new g({color:U,bold:!0}))])})})}return new l0({decoration:D?{color:D}:void 0,padding:I0.symmetric(2,0),child:new J0({text:new P(z.name,new g({color:U}))})})},filterItem:(z,q)=>{if(this.currentQuery!==q)this.currentQuery=q,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in z&&z.__isCreateMarker)return this.shouldShowCreateMarker(q);let H=q.trim().toLowerCase();return H.length===0||z.name.includes(H)},sortItems:(z,q,W)=>{let H="__isCreateMarker"in z.item&&z.item.__isCreateMarker,D="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(H&&!D)return-1;if(!H&&D)return 1;return q.score-z.score}})}}class v11 extends g0{props;constructor(J){super();this.props=J}createState(){return new Op4}}class KF extends g0{props;constructor(J){super();this.props=J}createState(){return new Ep4}}class Ep4 extends h0{_spinner=new z5;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Z=x0.of(J),{colors:Q,app:Y}=Z,X=Y4.all(new Z4(Q.foreground,1,"solid")),K=this._spinner.toBraille(),V=new J0({textAlign:"center",text:new P("",void 0,[new P(K,new g({color:Y.processing})),new P(" ",void 0),new P(this.widget.props.message,new g({color:Q.foreground}))])}),F=[new c1({child:new c0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[V]})})];if(this.widget.props.onAbort)F.push(new R0({height:2,child:new l0({padding:I0.symmetric(2,0),child:new J0({text:new P("",new g({dim:!0}),[new P("Press ",new g({color:Q.foreground})),new P("Esc",new g({color:Q.info})),new P(" to cancel",new g({color:Q.foreground}))])})})}));let z=new l0({decoration:new Z6(Q.background,X),child:new R0({width:60,height:7,child:new c0({mainAxisAlignment:"start",children:F})})});if(this.widget.props.onAbort)return new J6({debugLabel:"LoadingDialog",autofocus:!0,onKey:(q)=>{if(q.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:z});return z}}var Wo={workspace:{label:"Workspace",pathHint:".amp/settings.json",description:"workspace config"},global:{label:"Global",pathHint:"~/.config/amp/settings.json",description:"global config"},flag:{label:"Flag",pathHint:"CLI flags",description:"flag config"},default:{label:"Default",pathHint:"built-in defaults",description:"default config"},external:{label:"External",pathHint:"extensions / external",description:"external source"},skill:{label:"Skills",pathHint:".agents/skills/",description:"skill source"},other:{label:"Other",pathHint:"",description:"other source"}},WF0=["workspace","global","flag","default","external","skill","other"];function zT3(J){return Array.from(new Set(J))}function Mp4(J){return zT3([...J.skillNames??[],...J.skillName?[J.skillName]:[]])}function ay(J){if(J.isExternal)return"external";switch(J.spec._target){case"workspace":return"workspace";case"global":return"global";case"flag":return"flag";case"default":return"default"}return Mp4(J).length>0?"skill":"other"}function y11(J){return ay(J)==="skill"}function Ap4(J){let Z=Mp4(J);if(Z.length===0)return;let Q=Z.join(", "),Y=ay(J);if(Y==="skill")return`skills: ${Q}`;return`${Z.length===1?"skill source":"skill sources"} overridden by ${Wo[Y].description}: ${Q}`}function jp4(J){return J.spec.meta?.skillNames?Array.from(J.spec.meta.skillNames):[]}var Rp4=process.platform==="win32"?" ":"█",Ip4=process.platform==="win32"?"░":"█";class c9 extends g0{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X=Rp4,thumbChar:K=Ip4,showTrack:V=!0,thumbColor:G,trackColor:F}){super(J?{key:J}:{});this.controller=Z,this.getScrollInfo=Q,this.thickness=Y,this.trackChar=X,this.thumbChar=K,this.showTrack=V,this.thumbColor=G,this.trackColor=F}createState(){return new Pp4}}class Pp4 extends h0{_dragStartY=null;_dragStartOffset=null;_isOverThumb=!1;_isPositionOverThumb(J){let{totalContentHeight:Z,viewportHeight:Q}=this.widget.getScrollInfo(),X=this.context.findRenderObject()?.size.height??0;if(X===0||Z<=Q)return!1;let K=this.widget.getScrollInfo(),V=Math.min(1,Q/Z),G=Math.max(1,X*V),F=Math.max(0,Math.min(1,K.scrollOffset/(Z-Q))),z=X-G,q=Math.max(0,z*F),W=q+G;return J>=q&&J<=W}_handleHover=(J)=>{let Z=this._isOverThumb;if(this._isOverThumb=this._isPositionOverThumb(J.localPosition.y),Z!==this._isOverThumb)this.setState()};_handleDrag=(J)=>{let{totalContentHeight:Z,viewportHeight:Q,scrollOffset:Y}=this.widget.getScrollInfo(),K=this.context.findRenderObject()?.size.height??0;if(K===0||Z<=Q)return;if(this._dragStartY===null)this._dragStartY=J.localPosition.y,this._dragStartOffset=Y;let V=J.localPosition.y-this._dragStartY,G=Math.min(1,Q/Z),F=Math.max(1,K*G),z=K-F;if(z<=0)return;let q=Z-Q,W=z/q,H=V/W,D=Math.max(0,Math.min(q,this._dragStartOffset+H));this.widget.controller.jumpTo(D)};_handleRelease=()=>{this._dragStartY=null,this._dragStartOffset=null};_handleClick=(J)=>{if(J.button!=="left")return;let Z=J.localPosition.y,{totalContentHeight:Q,viewportHeight:Y,scrollOffset:X}=this.widget.getScrollInfo(),V=this.context.findRenderObject()?.size.height??0;if(V===0||Q<=Y)return;let G=Math.min(1,Y/Q),F=Math.max(1,V*G),z=Q-Y,q=V-F,W=Math.max(0,Math.min(1,X/(Q-Y))),H=Math.max(0,q*W),D=H+F;if(Z>=H&&Z<=D)return;if(Z<H)this.widget.controller.animateTo(Math.max(0,X-Y));else this.widget.controller.animateTo(Math.min(z,X+Y))};build(J){return new e1({onClick:this._handleClick,onHover:this._handleHover,onDrag:this._handleDrag,onRelease:this._handleRelease,cursor:this._isOverThumb?G3.POINTER:G3.DEFAULT,child:new Cp4({controller:this.widget.controller,getScrollInfo:this.widget.getScrollInfo,thickness:this.widget.thickness,trackChar:this.widget.trackChar,thumbChar:this.widget.thumbChar,showTrack:this.widget.showTrack,thumbColor:this.widget.thumbColor,trackColor:this.widget.trackColor})})}}class Cp4 extends pw{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X=Rp4,thumbChar:K=Ip4,showTrack:V=!0,thumbColor:G,trackColor:F}){super(J?{key:J}:{});this.controller=Z,this.getScrollInfo=Q,this.thickness=Y,this.trackChar=X,this.thumbChar=K,this.showTrack=V,this.thumbColor=G,this.trackColor=F}createRenderObject(){return new _p4(this)}updateRenderObject(J){J.updateWidget(this)}}class _p4 extends U4{_widget;constructor(J){super();this._widget=J}updateWidget(J){this._widget=J,this.markNeedsLayout()}performLayout(){let J=this._lastConstraints;h4(!!J,"performLayout called without constraints");let Z=Math.min(J.maxWidth,this._widget.thickness),Q=J.maxHeight;this.setSize(Z,Q),super.performLayout()}getMinIntrinsicWidth(J){return this._widget.thickness}getMaxIntrinsicWidth(J){return this._widget.thickness}getMinIntrinsicHeight(J){return 0}getMaxIntrinsicHeight(J){return 0}paint(J,Z,Q){let{thumbStartFloat:Y,thumbSizeFloat:X,showScrollbar:K}=this._calculateScrollbarMetrics();if(!K)return;let V=this._widget.trackColor,G=this._widget.thumbColor,F=process.platform==="win32",z=Y,q=Y+X;if(!F){let W=["▁","▂","▃","▄","▅","▆","▇","█"];for(let H=0;H<this.size.height;H++){let D="█",U=!0;if(H===Math.floor(z)){let B=1-(z-H),N=Math.floor(B*8);D=W[N]||"█",U=!1}else if(H===Math.floor(q)){let B=1-(q-H),N=Math.floor(B*8);D=W[N]||"█"}else if(H>z&&H<q)U=!1;J.setChar(Z,Q+H,D,{fg:G,bg:V,reverse:U},1)}return}for(let W=0;W<this.size.height;W++){let H=W+0.5,D=H>=z&&H<q,U=D?this._widget.thumbChar:this._widget.trackChar;J.setChar(Z,Q+W,U,{fg:D?G:V,bg:V,reverse:!1},1)}}_calculateScrollbarMetrics(){let{totalContentHeight:J,viewportHeight:Z,scrollOffset:Q}=this._widget.getScrollInfo(),Y=this.size.height;if(J<=Z||Y<=0)return{thumbStartFloat:0,thumbSizeFloat:0,showScrollbar:!1};let X=Math.max(0,Math.min(1,Q/(J-Z))),K=Math.min(1,Z/J),V=Math.max(1,Y*K),G=Y-V;return{thumbStartFloat:Math.max(0,G*X),thumbSizeFloat:V,showScrollbar:!0}}}class oD extends g0{props;constructor(J){super();this.props=J}createState(){return new Tp4}}class Tp4 extends h0{scrollController=new q5;scrollAreaKey=new p7("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(J){return J instanceof U7}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Z=this.scrollAreaKey.currentElement?.renderObject;if(Z&&"size"in Z){let Q=Z.size;if(typeof Q.height==="number"&&Q.height>0)return this.viewportHeight=Q.height,Q.height}return this.viewportHeight}build(J){let Z=x0.of(J),Q=this.widget.props.message,Y=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let q=xV0(Q);return{title:q.title,type:q.type,description:q.description}})(),X=Y.type==="error"?Z.app.toolError:Z.app.command,K=Y4.all(new Z4(Z.colors.border,1,"solid")),V=new l0({padding:I0.symmetric(1,0),child:new J0({text:new P(Y.title,new g({color:X,bold:!0}))})}),G=this.isWidgetMessage(Q)?Q.widget:new J0({text:new P(Y.description,new g({color:Z.colors.foreground})),selectable:!0}),F=new c1({child:new U2({child:new l0({padding:I0.symmetric(1,0),child:new H1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new c1({child:new x6({controller:this.scrollController,autofocus:!0,child:G})}),new c9({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let q=this.scrollController.maxScrollExtent,W=this.scrollController.offset,H=this.getViewportHeight(),D=q+H;return{totalContentHeight:Math.max(D,0),viewportHeight:Math.max(H,1),scrollOffset:Math.max(W,0)}}})]})})})}),z=new l0({padding:I0.symmetric(1,0),child:new J0({text:(()=>{if(this.widget.props.onRetry)return new P("",void 0,[new P("Press ",new g({color:Z.colors.foreground,dim:!0})),new P("R",new g({color:Z.app.keybind})),new P(" to retry, ",new g({color:Z.colors.foreground,dim:!0})),new P("Esc",new g({color:Z.app.keybind})),new P(" to cancel",new g({color:Z.colors.foreground,dim:!0}))]);let q=this.resolveFooterStyle(this.widget.props.message);if(q==="none")return new P("",new g({color:Z.colors.foreground,dim:!0}));if(q==="help"){let W=new g({color:Z.app.keybind}),H=new g({color:Z.colors.foreground,dim:!0});return new P("",H,[new P("Press ",H),new P("Escape",W),new P(" to close • Use ",H),new P("↑↓",W),new P(" or ",H),new P("j/k",W),new P(" to scroll",H)])}return new P("Press any key to close",new g({color:Z.colors.foreground,dim:!0,italic:!0}))})()})});return new Q5({fit:"expand",children:[new e1({onClick:()=>{},child:new R0}),new J6({onKey:(q)=>{if(this.widget.props.onRetry&&q.key==="r")return this.widget.props.onRetry(),"handled";if(q.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new l0({decoration:{border:K,color:Z.colors.background},padding:I0.all(1),child:new c0({mainAxisAlignment:"center",children:[V,new R0({height:1}),F,z]})})})]})}}V9();class Sp4 extends g0{props;constructor(J){super();this.props=J}createState(){return new kp4}}class kp4 extends h0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=w9.default(),{colors:Q,app:Y}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:Y.toolSuccess};case"error":return{icon:"✗",color:Y.toolError}}}build(J){let Z=x0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new J0({text:new P("No plugins found.",new g({dim:!0}))});let Y=[],X=this.plugins.length,K=this.plugins.filter((F)=>F.status==="active").length,V=this.plugins.reduce((F,z)=>F+z.registeredCommands.length,0),G=this.plugins.reduce((F,z)=>F+z.registeredTools.length,0);if(Y.push(new P(`${K}/${X} ${_4(X,"plugin")} active`,new g({bold:!0}))),V>0||G>0)Y.push(new P(` (${V} ${_4(V,"command")}, ${G} ${_4(G,"tool")})`,new g({dim:!0})));Y.push(new P(`
5931
+ `))}if(U)W.push(new P(" ",q)),W.push(new P("Total: ",q)),W.push(new P(K(B),z))}return new l0({decoration:{color:G.background,border:Y4.all(new Z4(G.border,1,"rounded"))},child:new J0({text:new P(void 0,void 0,W)})})}o0();V9();OE();lJ();t3();A7();cd();bX();oJ();KY();sJ();uA();r4();Fm();oP();R1();o0();oJ();class T11{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1776557243-g13eef6"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await i40(Z,this.configService)}catch(Z){S.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class SL extends g0{props;constructor(J){super();this.props=J}createState(){return new Bp4}}class Bp4 extends h0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}class Np4 extends h0{controller=new c7;focusNode=new L6({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Z=x0.of(J),{colors:Q,app:Y}=Z,X=this.widget.props.isRequiredArg??!0,K=this.controller.text.trim().length>0,V=!X||K,G=Y4.all(new Z4(Q.foreground,1,"solid")),F=new JX({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(D)=>{let U=D.trim();if(X&&U.length===0)return;this.widget.props.onSubmit(U)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),z=new H1({children:[new l0({decoration:{color:Q.background},child:new J0({text:new P(">",new g({color:Q.foreground}))})}),new c1({child:F})]}),q=new l0({padding:I0.symmetric(1,0),child:new J0({text:new P("",void 0,[new P("Command: ",new g({color:Q.foreground})),new P(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),W=[];if(V)W.push(new P("Enter",new g({color:Y.keybind}))),W.push(new P(" to submit, ",new g({color:Q.foreground,dim:!0})));W.push(new P("Esc",new g({color:Y.keybind}))),W.push(new P(" to cancel",new g({color:Q.foreground,dim:!0})));let H=new l0({padding:I0.symmetric(1,0),child:new J0({text:new P("",void 0,W)})});return new l0({decoration:{border:G,color:Q.background},padding:I0.all(1),child:new c0({children:[q,new R0({height:1}),z,new S5,H]})})}}class qo extends g0{props;constructor(J){super();this.props=J}createState(){return new Np4}}sJ();class wp4 extends h0{controller=new c7;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new L6({debugLabel:"CommandMultilinePrompt",onKey:(J)=>{if(J.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(J)=>{if(this.imageAttachments.length>=VY)return!1;let Z=await mq(J);if(typeof Z==="object")return this.setState(()=>{this.imageAttachments=[...this.imageAttachments,Z],this.imagePaths=[...this.imagePaths,J]}),!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(J){let Z=x0.of(J),{colors:Q,app:Y}=Z,K=O4.of(J).size.height,V=Math.max(Math.floor(K*0.5),10),G=new gD({controller:this.controller,triggers:[new JV],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(D)=>{this.widget.props.onSubmit(D.trim(),this.imageAttachments)},theme:Q,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:l4.instance.tuiInstance.clipboard,autoOverlayPosition:!0,onInsertImage:this.widget.props.onInsertImage??this._handleInsertImage,imageAttachments:this.imageAttachments,popImage:this._handlePopImage}),F=new J6({focusNode:this.focusNode,child:G}),z=new l0({constraints:new j1({maxHeight:V}),padding:I0.symmetric(1,0),child:F}),q=new l0({padding:I0.symmetric(1,0),child:new J0({text:new P("",void 0,[new P("Command: ",new g({color:Q.foreground})),new P(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),W=new l0({padding:I0.symmetric(1,0),child:new J0({text:this.isConfirmingClearInput?new P("",void 0,[new P("Esc",new g({color:Y.keybind})),new P(" again to clear input",new g({color:Q.foreground,dim:!0}))]):new P("",void 0,[new P("Press ",new g({color:Q.foreground,dim:!0})),new P("Enter",new g({color:Y.keybind})),new P(" to submit, ",new g({color:Q.foreground,dim:!0})),new P("Esc",new g({color:Y.keybind})),new P(" to clear",new g({color:Q.foreground,dim:!0}))])})}),H=[q,new R0({height:1}),new c1({child:z}),new R0({height:1}),W];return new l0({decoration:{border:Y4.all(new Z4(Q.foreground,1,"solid")),color:Q.background},padding:I0.all(1),child:new c0({children:H})})}}class S11 extends g0{props;constructor(J){super();this.props=J}createState(){return new wp4}}function Lp4(J){let Q=new Date().getTime()-J.getTime(),Y=Math.floor(Q/60000),X=Math.floor(Q/3600000),K=Math.floor(Q/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(K<7)return`${K}d ago`;return J.toLocaleDateString()}class k11 extends x1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((X,K)=>K.pubDate.getTime()-X.pubDate.getTime()),Q=Math.max(0,...Z.map((X)=>Lp4(X.pubDate).length));return new k8({items:Z,getLabel:(X)=>X.title,onAccept:(X)=>this.props.onSelect?.(X),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(X,K,V,G)=>{let F=x0.of(G),{colors:z}=F,q=F.app,W=K?q.selectionBackground:void 0,H=K?q.selectionForeground:z.foreground,D=z.mutedForeground,U=(B,N)=>new R0({width:N,child:H1.end([new J0({text:new P(B,new g({color:D}))})])});return new l0({decoration:W?{color:W}:void 0,padding:I0.symmetric(2,0),child:new H1({children:[new c1({child:new J0({text:new P(X.title,new g({color:H})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),U(Lp4(X.pubDate),Q)]})})}})}}class SJ{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!SJ._instance)SJ._instance=new SJ;return SJ._instance}get allExpanded(){return this._allExpanded}setAllExpanded(J){if(this._allExpanded===J)return;this._allExpanded=J,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(J){return this._listeners.add(J),()=>this.removeListener(J)}removeListener(J){this._listeners.delete(J)}_notifyListeners(){for(let J of this._listeners)J()}}o0();class Op4 extends h0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let J=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!J.ok){S.error("Failed to load labels",J.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=J.result,this.isLoading=!1,this.setState()}catch(J){S.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],Y=this.labels.some((K)=>K.name===Z),X=Q.includes(Z);return!Y&&!X}build(J){let Z=x0.of(J),{app:Q,colors:Y}=Z,X=this.currentQuery.trim().toLowerCase(),K=X.length>0?this.getValidationError(X):null,V=this.getAvailableLabels(),F=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...V];return new k8({title:"Add Label",items:F,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:K||"Type to create a new label",renderItem:(z,q,W,H)=>{let D=q?Q.selectionBackground:void 0,U=q?Q.selectionForeground:Y.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new l0({decoration:D?{color:D}:void 0,padding:I0.symmetric(2,0),child:new J0({text:new P("",void 0,[new P("Create new label: ",new g({color:U})),new P(N,new g({color:U,bold:!0}))])})})}return new l0({decoration:D?{color:D}:void 0,padding:I0.symmetric(2,0),child:new J0({text:new P(z.name,new g({color:U}))})})},filterItem:(z,q)=>{if(this.currentQuery!==q)this.currentQuery=q,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in z&&z.__isCreateMarker)return this.shouldShowCreateMarker(q);let H=q.trim().toLowerCase();return H.length===0||z.name.includes(H)},sortItems:(z,q,W)=>{let H="__isCreateMarker"in z.item&&z.item.__isCreateMarker,D="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(H&&!D)return-1;if(!H&&D)return 1;return q.score-z.score}})}}class v11 extends g0{props;constructor(J){super();this.props=J}createState(){return new Op4}}class KF extends g0{props;constructor(J){super();this.props=J}createState(){return new Ep4}}class Ep4 extends h0{_spinner=new z5;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Z=x0.of(J),{colors:Q,app:Y}=Z,X=Y4.all(new Z4(Q.foreground,1,"solid")),K=this._spinner.toBraille(),V=new J0({textAlign:"center",text:new P("",void 0,[new P(K,new g({color:Y.processing})),new P(" ",void 0),new P(this.widget.props.message,new g({color:Q.foreground}))])}),F=[new c1({child:new c0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[V]})})];if(this.widget.props.onAbort)F.push(new R0({height:2,child:new l0({padding:I0.symmetric(2,0),child:new J0({text:new P("",new g({dim:!0}),[new P("Press ",new g({color:Q.foreground})),new P("Esc",new g({color:Q.info})),new P(" to cancel",new g({color:Q.foreground}))])})})}));let z=new l0({decoration:new Z6(Q.background,X),child:new R0({width:60,height:7,child:new c0({mainAxisAlignment:"start",children:F})})});if(this.widget.props.onAbort)return new J6({debugLabel:"LoadingDialog",autofocus:!0,onKey:(q)=>{if(q.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:z});return z}}var Wo={workspace:{label:"Workspace",pathHint:".amp/settings.json",description:"workspace config"},global:{label:"Global",pathHint:"~/.config/amp/settings.json",description:"global config"},flag:{label:"Flag",pathHint:"CLI flags",description:"flag config"},default:{label:"Default",pathHint:"built-in defaults",description:"default config"},external:{label:"External",pathHint:"extensions / external",description:"external source"},skill:{label:"Skills",pathHint:".agents/skills/",description:"skill source"},other:{label:"Other",pathHint:"",description:"other source"}},WF0=["workspace","global","flag","default","external","skill","other"];function zT3(J){return Array.from(new Set(J))}function Mp4(J){return zT3([...J.skillNames??[],...J.skillName?[J.skillName]:[]])}function ay(J){if(J.isExternal)return"external";switch(J.spec._target){case"workspace":return"workspace";case"global":return"global";case"flag":return"flag";case"default":return"default"}return Mp4(J).length>0?"skill":"other"}function y11(J){return ay(J)==="skill"}function Ap4(J){let Z=Mp4(J);if(Z.length===0)return;let Q=Z.join(", "),Y=ay(J);if(Y==="skill")return`skills: ${Q}`;return`${Z.length===1?"skill source":"skill sources"} overridden by ${Wo[Y].description}: ${Q}`}function jp4(J){return J.spec.meta?.skillNames?Array.from(J.spec.meta.skillNames):[]}var Rp4=process.platform==="win32"?" ":"█",Ip4=process.platform==="win32"?"░":"█";class c9 extends g0{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X=Rp4,thumbChar:K=Ip4,showTrack:V=!0,thumbColor:G,trackColor:F}){super(J?{key:J}:{});this.controller=Z,this.getScrollInfo=Q,this.thickness=Y,this.trackChar=X,this.thumbChar=K,this.showTrack=V,this.thumbColor=G,this.trackColor=F}createState(){return new Pp4}}class Pp4 extends h0{_dragStartY=null;_dragStartOffset=null;_isOverThumb=!1;_isPositionOverThumb(J){let{totalContentHeight:Z,viewportHeight:Q}=this.widget.getScrollInfo(),X=this.context.findRenderObject()?.size.height??0;if(X===0||Z<=Q)return!1;let K=this.widget.getScrollInfo(),V=Math.min(1,Q/Z),G=Math.max(1,X*V),F=Math.max(0,Math.min(1,K.scrollOffset/(Z-Q))),z=X-G,q=Math.max(0,z*F),W=q+G;return J>=q&&J<=W}_handleHover=(J)=>{let Z=this._isOverThumb;if(this._isOverThumb=this._isPositionOverThumb(J.localPosition.y),Z!==this._isOverThumb)this.setState()};_handleDrag=(J)=>{let{totalContentHeight:Z,viewportHeight:Q,scrollOffset:Y}=this.widget.getScrollInfo(),K=this.context.findRenderObject()?.size.height??0;if(K===0||Z<=Q)return;if(this._dragStartY===null)this._dragStartY=J.localPosition.y,this._dragStartOffset=Y;let V=J.localPosition.y-this._dragStartY,G=Math.min(1,Q/Z),F=Math.max(1,K*G),z=K-F;if(z<=0)return;let q=Z-Q,W=z/q,H=V/W,D=Math.max(0,Math.min(q,this._dragStartOffset+H));this.widget.controller.jumpTo(D)};_handleRelease=()=>{this._dragStartY=null,this._dragStartOffset=null};_handleClick=(J)=>{if(J.button!=="left")return;let Z=J.localPosition.y,{totalContentHeight:Q,viewportHeight:Y,scrollOffset:X}=this.widget.getScrollInfo(),V=this.context.findRenderObject()?.size.height??0;if(V===0||Q<=Y)return;let G=Math.min(1,Y/Q),F=Math.max(1,V*G),z=Q-Y,q=V-F,W=Math.max(0,Math.min(1,X/(Q-Y))),H=Math.max(0,q*W),D=H+F;if(Z>=H&&Z<=D)return;if(Z<H)this.widget.controller.animateTo(Math.max(0,X-Y));else this.widget.controller.animateTo(Math.min(z,X+Y))};build(J){return new e1({onClick:this._handleClick,onHover:this._handleHover,onDrag:this._handleDrag,onRelease:this._handleRelease,cursor:this._isOverThumb?G3.POINTER:G3.DEFAULT,child:new Cp4({controller:this.widget.controller,getScrollInfo:this.widget.getScrollInfo,thickness:this.widget.thickness,trackChar:this.widget.trackChar,thumbChar:this.widget.thumbChar,showTrack:this.widget.showTrack,thumbColor:this.widget.thumbColor,trackColor:this.widget.trackColor})})}}class Cp4 extends pw{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X=Rp4,thumbChar:K=Ip4,showTrack:V=!0,thumbColor:G,trackColor:F}){super(J?{key:J}:{});this.controller=Z,this.getScrollInfo=Q,this.thickness=Y,this.trackChar=X,this.thumbChar=K,this.showTrack=V,this.thumbColor=G,this.trackColor=F}createRenderObject(){return new _p4(this)}updateRenderObject(J){J.updateWidget(this)}}class _p4 extends U4{_widget;constructor(J){super();this._widget=J}updateWidget(J){this._widget=J,this.markNeedsLayout()}performLayout(){let J=this._lastConstraints;h4(!!J,"performLayout called without constraints");let Z=Math.min(J.maxWidth,this._widget.thickness),Q=J.maxHeight;this.setSize(Z,Q),super.performLayout()}getMinIntrinsicWidth(J){return this._widget.thickness}getMaxIntrinsicWidth(J){return this._widget.thickness}getMinIntrinsicHeight(J){return 0}getMaxIntrinsicHeight(J){return 0}paint(J,Z,Q){let{thumbStartFloat:Y,thumbSizeFloat:X,showScrollbar:K}=this._calculateScrollbarMetrics();if(!K)return;let V=this._widget.trackColor,G=this._widget.thumbColor,F=process.platform==="win32",z=Y,q=Y+X;if(!F){let W=["▁","▂","▃","▄","▅","▆","▇","█"];for(let H=0;H<this.size.height;H++){let D="█",U=!0;if(H===Math.floor(z)){let B=1-(z-H),N=Math.floor(B*8);D=W[N]||"█",U=!1}else if(H===Math.floor(q)){let B=1-(q-H),N=Math.floor(B*8);D=W[N]||"█"}else if(H>z&&H<q)U=!1;J.setChar(Z,Q+H,D,{fg:G,bg:V,reverse:U},1)}return}for(let W=0;W<this.size.height;W++){let H=W+0.5,D=H>=z&&H<q,U=D?this._widget.thumbChar:this._widget.trackChar;J.setChar(Z,Q+W,U,{fg:D?G:V,bg:V,reverse:!1},1)}}_calculateScrollbarMetrics(){let{totalContentHeight:J,viewportHeight:Z,scrollOffset:Q}=this._widget.getScrollInfo(),Y=this.size.height;if(J<=Z||Y<=0)return{thumbStartFloat:0,thumbSizeFloat:0,showScrollbar:!1};let X=Math.max(0,Math.min(1,Q/(J-Z))),K=Math.min(1,Z/J),V=Math.max(1,Y*K),G=Y-V;return{thumbStartFloat:Math.max(0,G*X),thumbSizeFloat:V,showScrollbar:!0}}}class oD extends g0{props;constructor(J){super();this.props=J}createState(){return new Tp4}}class Tp4 extends h0{scrollController=new q5;scrollAreaKey=new p7("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(J){return J instanceof U7}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Z=this.scrollAreaKey.currentElement?.renderObject;if(Z&&"size"in Z){let Q=Z.size;if(typeof Q.height==="number"&&Q.height>0)return this.viewportHeight=Q.height,Q.height}return this.viewportHeight}build(J){let Z=x0.of(J),Q=this.widget.props.message,Y=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let q=xV0(Q);return{title:q.title,type:q.type,description:q.description}})(),X=Y.type==="error"?Z.app.toolError:Z.app.command,K=Y4.all(new Z4(Z.colors.border,1,"solid")),V=new l0({padding:I0.symmetric(1,0),child:new J0({text:new P(Y.title,new g({color:X,bold:!0}))})}),G=this.isWidgetMessage(Q)?Q.widget:new J0({text:new P(Y.description,new g({color:Z.colors.foreground})),selectable:!0}),F=new c1({child:new U2({child:new l0({padding:I0.symmetric(1,0),child:new H1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new c1({child:new x6({controller:this.scrollController,autofocus:!0,child:G})}),new c9({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let q=this.scrollController.maxScrollExtent,W=this.scrollController.offset,H=this.getViewportHeight(),D=q+H;return{totalContentHeight:Math.max(D,0),viewportHeight:Math.max(H,1),scrollOffset:Math.max(W,0)}}})]})})})}),z=new l0({padding:I0.symmetric(1,0),child:new J0({text:(()=>{if(this.widget.props.onRetry)return new P("",void 0,[new P("Press ",new g({color:Z.colors.foreground,dim:!0})),new P("R",new g({color:Z.app.keybind})),new P(" to retry, ",new g({color:Z.colors.foreground,dim:!0})),new P("Esc",new g({color:Z.app.keybind})),new P(" to cancel",new g({color:Z.colors.foreground,dim:!0}))]);let q=this.resolveFooterStyle(this.widget.props.message);if(q==="none")return new P("",new g({color:Z.colors.foreground,dim:!0}));if(q==="help"){let W=new g({color:Z.app.keybind}),H=new g({color:Z.colors.foreground,dim:!0});return new P("",H,[new P("Press ",H),new P("Escape",W),new P(" to close • Use ",H),new P("↑↓",W),new P(" or ",H),new P("j/k",W),new P(" to scroll",H)])}return new P("Press any key to close",new g({color:Z.colors.foreground,dim:!0,italic:!0}))})()})});return new Q5({fit:"expand",children:[new e1({onClick:()=>{},child:new R0}),new J6({onKey:(q)=>{if(this.widget.props.onRetry&&q.key==="r")return this.widget.props.onRetry(),"handled";if(q.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new l0({decoration:{border:K,color:Z.colors.background},padding:I0.all(1),child:new c0({mainAxisAlignment:"center",children:[V,new R0({height:1}),F,z]})})})]})}}V9();class Sp4 extends g0{props;constructor(J){super();this.props=J}createState(){return new kp4}}class kp4 extends h0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=w9.default(),{colors:Q,app:Y}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:Y.toolSuccess};case"error":return{icon:"✗",color:Y.toolError}}}build(J){let Z=x0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new J0({text:new P("No plugins found.",new g({dim:!0}))});let Y=[],X=this.plugins.length,K=this.plugins.filter((F)=>F.status==="active").length,V=this.plugins.reduce((F,z)=>F+z.registeredCommands.length,0),G=this.plugins.reduce((F,z)=>F+z.registeredTools.length,0);if(Y.push(new P(`${K}/${X} ${_4(X,"plugin")} active`,new g({bold:!0}))),V>0||G>0)Y.push(new P(` (${V} ${_4(V,"command")}, ${G} ${_4(G,"tool")})`,new g({dim:!0})));Y.push(new P(`
5932
5932
 
5933
5933
  `));for(let F of this.plugins){let{icon:z,color:q}=this.statusIcon(F.status),W=this.getRelativePath(F.uri.toString());if(Y.push(new P(`${z} `,new g({color:q}))),Y.push(new P(W,new g({bold:!0}))),Y.push(new P(` ${F.status}`,new g({dim:!0}))),Y.push(new P(`
5934
5934
  `)),F.status==="active"&&F.registeredEvents.length>0)Y.push(new P(" Events: ",new g({dim:!0}))),Y.push(new P(F.registeredEvents.join(", "),new g({color:Q.link}))),Y.push(new P(`
@@ -6130,7 +6130,7 @@ ${r.content||""}`:r.content||"",_0=[],b0=r.baseDir.startsWith("file://")?lF0(r.b
6130
6130
  `),process.exit(1)}process.stdout.write(await ay3(F.result.displayText)+`
6131
6131
  `),process.exit(0)})}kN();import{stdout as oy3}from"node:process";function ry3({version:J,buildTimestamp:Z,buildType:Q}){let Y=Q==="dev"?"dev":"released",X=Z?new Date(Z):null,K=X&&!Number.isNaN(X.getTime())?`, ${yz(X)} ago`:"";return`${J} (${Y}${Z?` ${Z}`:""}${K})`}function gl4(J){oy3.write(`${ry3(J)}
6132
6132
  `)}function ml4(J,Z){J.option("-V, --version","Print the version number and exit",()=>{gl4(Z),process.exit(0)}),J.command("version").description("Print the version number and exit").action(()=>{gl4(Z),process.exit(0)})}var Uh3=Zr.join(xX,"logs","headless.log"),o51=Zr.join(Tv,"device-id.json"),Bh3=`cli-tui-${Uo4(16).toString("hex")}`;async function Nh3(){for(let J of jE)try{if((await J.listConfigs()).length>0)return J}catch(Z){S.debug("Failed to detect query-based IDE integration",{ideName:J.ideName,error:Z})}return}try{if(process.platform==="win32")await Promise.resolve().then(() => W4(Ox(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){SZ.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
6133
- `)}function wh3(J){process.emitWarning=(Z,Q,Y,X)=>{let K=typeof Z==="string"?Z:Z.message||String(Z),V=Q||"Warning",G=!1;J.warn(K,{name:V,code:Y})}}function E2(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")q$("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")q$("experimental.agentMode",Z.mode);if(J.getOptionValueSourceWithGlobals("model")==="cli"&&Z.model)q$("internal.model",Lh3(Z.model))}function Go4(J){let Z=J.indexOf(":");if(Z===-1)throw new V4(`Invalid model format "${J}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let Q=J.slice(0,Z).trim(),Y=J.slice(Z+1).trim();if(!Q||!Y)throw new V4(`Invalid model format "${J}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function Lh3(J){if(!J.includes("="))return Go4(J),J;let Z={};for(let Q of J.split(",")){let Y=Q.trim();if(!Y)continue;let X=Y.indexOf("=");if(X===-1)throw new V4(`Invalid mode-specific model entry "${Y}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let K=Y.slice(0,X).trim(),V=Y.slice(X+1).trim();if(!K)throw new V4(`Missing mode name in "${Y}". Expected "mode=provider:model".`,1);if(!V)throw new V4(`Missing model value for mode "${K}". Expected "${K}=provider:model".`,1);Go4(V),Z[K]=V}if(Object.keys(Z).length===0)throw new V4("No valid model overrides found in --model flag value.",1);return Z}function Oh3(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function Eh3(J){try{return await Bo4(J,"utf-8")}catch{return J}}async function Fo4(J,Z,Q){let Y=Oh3(J,Z);if(!Y)return;let X=S6(Q)?Q.features:[],K=S6(Q)?Q.user.email:void 0;if(!Jr(X,r7.HARNESS_SYSTEM_PROMPT)&&!(K&&I2(K)))throw new V4("You are not allowed to do this.",1);q$("systemPrompt",await Eh3(Y))}function Jr(J,Z){return J?.some((Q)=>Q.name===Z&&Q.enabled)??!1}function Mh3(J){return J!=="pending"}function Ex(J){if(!S6(J))return null;return{...J.user,features:J.features??[],team:J.workspace??void 0}}function Ah3(J){let Z=Ex(J);if(Z)return Z.id;if(rW(J))throw Error(J.error.message);throw Error("unreachable")}function jh3(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function Rh3(J){let Y=jh3(J)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new V4(`Couldn't connect to the Amp server at ${J}.`,1,Y)}function r51(J,Z){let Q=sn0(Error(J.error.message));if(Q.message===a2.networkOffline||Q.message===a2.networkTimeout)return Rh3(Z);if(Q.message!==a2.internalBug)return new V4(Q.message,1,Q.suggestion);return new V4(J.error.message.replace(/^Error: /,""),1)}var zo4=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH; enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??lK,description:`Custom settings file path (overrides the default location ${lK})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(S).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${xi})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:m7(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"mode",long:"mode",short:"m",type:"option",default:LE.SMART.key,description:`Set the agent mode (${gX({}).map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:gX().map((J)=>J.mode).concat("large","deep","internal")},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable v2 thread mode and use the legacy worker runtime",hidden:!0},{name:"neo",long:"neo",type:"switch",description:"Use the Neo TUI",hidden:!0},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0},{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}],qo4=(J)=>("deprecated"in J)&&J.deprecated===!0,Ih3=(J)=>("hidden"in J)&&J.hidden===!0,Ph3=(J)=>("default"in J),Ch3=(J)=>("default"in J)?J.default:void 0,No4=[{name:"toggle-skills-count",entryPoint:L01}];function _h3(J,Z){let Q=Z.args[0],Y=Z.commands.map((K)=>K.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let K=Y.filter((G)=>Q.includes(G)||G.includes(Q)),V="Run amp --help for a list of available commands.";if(K.length>0)V=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new V4(a2.unknownCommand(Q),1,V)}}async function fz0(J){return{...J,getThreadEnvironment:_G,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new wM(J.fileSystem),generateThreadTitle:h04,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>tZ(J.configService),pluginService:J.pluginService}}function wo4(J){return{toolService:J.toolService,configService:J.configService,skillService:J.skillService,getThreadEnvironment:_G,filesystem:J.fileSystem,threadService:J.threadService}}var yz0=G1.file(Dh3.homedir()),s51=process.env.XDG_CONFIG_HOME?G1.file(process.env.XDG_CONFIG_HOME):F1.joinPath(yz0,".config");function Th3(J){return wW4({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){if(jP4())RP4();else if(process.platform==="darwin"&&Z==="idle"&&J.isTUIVoiceNotifEnabled())NW4();else rm0(Z);let Q=rX0(),Y=Vr0();if((!Q||Y||H_4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(RD("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(RD("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(rX0()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function w7(J,Z,Q){let Y=Q?.deferAuth??!1;Fu1("0.0.1776542811-g13eef6");let X=BC({storage:J.settings,secretStorage:J.secrets,workspaceRoot:v0.of(G1.file(process.cwd())),defaultAmpURL:J.ampURL,homeDir:yz0,userConfigDir:s51});Lh4(X);let K=await X.getLatest();S.debug("Global configuration initialized",{settingsKeys:Object.keys(K.settings)});let V=!1;{let x=await J.secrets.get("apiKey",J.ampURL);if(V=Boolean(x),S.info("API key lookup before login",{found:Boolean(x),ampURL:J.ampURL,deferAuth:Y}),!x)if(Y)S.info("No API key found, continuing startup with deferred auth");else{p5.write(`No API key found. Starting login flow...
6133
+ `)}function wh3(J){process.emitWarning=(Z,Q,Y,X)=>{let K=typeof Z==="string"?Z:Z.message||String(Z),V=Q||"Warning",G=!1;J.warn(K,{name:V,code:Y})}}function E2(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")q$("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")q$("experimental.agentMode",Z.mode);if(J.getOptionValueSourceWithGlobals("model")==="cli"&&Z.model)q$("internal.model",Lh3(Z.model))}function Go4(J){let Z=J.indexOf(":");if(Z===-1)throw new V4(`Invalid model format "${J}". Expected "provider:model" (e.g., "anthropic:claude-sonnet-4-20250514").`,1);let Q=J.slice(0,Z).trim(),Y=J.slice(Z+1).trim();if(!Q||!Y)throw new V4(`Invalid model format "${J}". Both provider and model must be non-empty (e.g., "anthropic:claude-sonnet-4-20250514").`,1)}function Lh3(J){if(!J.includes("="))return Go4(J),J;let Z={};for(let Q of J.split(",")){let Y=Q.trim();if(!Y)continue;let X=Y.indexOf("=");if(X===-1)throw new V4(`Invalid mode-specific model entry "${Y}". Expected "mode=provider:model" (e.g., "smart=anthropic:claude-sonnet-4-20250514").`,1);let K=Y.slice(0,X).trim(),V=Y.slice(X+1).trim();if(!K)throw new V4(`Missing mode name in "${Y}". Expected "mode=provider:model".`,1);if(!V)throw new V4(`Missing model value for mode "${K}". Expected "${K}=provider:model".`,1);Go4(V),Z[K]=V}if(Object.keys(Z).length===0)throw new V4("No valid model overrides found in --model flag value.",1);return Z}function Oh3(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function Eh3(J){try{return await Bo4(J,"utf-8")}catch{return J}}async function Fo4(J,Z,Q){let Y=Oh3(J,Z);if(!Y)return;let X=S6(Q)?Q.features:[],K=S6(Q)?Q.user.email:void 0;if(!Jr(X,r7.HARNESS_SYSTEM_PROMPT)&&!(K&&I2(K)))throw new V4("You are not allowed to do this.",1);q$("systemPrompt",await Eh3(Y))}function Jr(J,Z){return J?.some((Q)=>Q.name===Z&&Q.enabled)??!1}function Mh3(J){return J!=="pending"}function Ex(J){if(!S6(J))return null;return{...J.user,features:J.features??[],team:J.workspace??void 0}}function Ah3(J){let Z=Ex(J);if(Z)return Z.id;if(rW(J))throw Error(J.error.message);throw Error("unreachable")}function jh3(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function Rh3(J){let Y=jh3(J)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new V4(`Couldn't connect to the Amp server at ${J}.`,1,Y)}function r51(J,Z){let Q=sn0(Error(J.error.message));if(Q.message===a2.networkOffline||Q.message===a2.networkTimeout)return Rh3(Z);if(Q.message!==a2.internalBug)return new V4(Q.message,1,Q.suggestion);return new V4(J.error.message.replace(/^Error: /,""),1)}var zo4=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} notification alerts (audio locally, terminal bell over SSH; enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??lK,description:`Custom settings file path (overrides the default location ${lK})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(S).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${xi})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:m7(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"mode",long:"mode",short:"m",type:"option",default:LE.SMART.key,description:`Set the agent mode (${gX({}).map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:gX().map((J)=>J.mode).concat("large","deep","internal")},{name:"takeMeBack",long:"take-me-back",type:"switch",description:"Disable v2 thread mode and use the legacy worker runtime",hidden:!0},{name:"neo",long:"neo",type:"switch",description:"Use the Neo TUI",hidden:!0},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0},{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}],qo4=(J)=>("deprecated"in J)&&J.deprecated===!0,Ih3=(J)=>("hidden"in J)&&J.hidden===!0,Ph3=(J)=>("default"in J),Ch3=(J)=>("default"in J)?J.default:void 0,No4=[{name:"toggle-skills-count",entryPoint:L01}];function _h3(J,Z){let Q=Z.args[0],Y=Z.commands.map((K)=>K.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let K=Y.filter((G)=>Q.includes(G)||G.includes(Q)),V="Run amp --help for a list of available commands.";if(K.length>0)V=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new V4(a2.unknownCommand(Q),1,V)}}async function fz0(J){return{...J,getThreadEnvironment:_G,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new wM(J.fileSystem),generateThreadTitle:h04,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>tZ(J.configService),pluginService:J.pluginService}}function wo4(J){return{toolService:J.toolService,configService:J.configService,skillService:J.skillService,getThreadEnvironment:_G,filesystem:J.fileSystem,threadService:J.threadService}}var yz0=G1.file(Dh3.homedir()),s51=process.env.XDG_CONFIG_HOME?G1.file(process.env.XDG_CONFIG_HOME):F1.joinPath(yz0,".config");function Th3(J){return wW4({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){if(jP4())RP4();else if(process.platform==="darwin"&&Z==="idle"&&J.isTUIVoiceNotifEnabled())NW4();else rm0(Z);let Q=rX0(),Y=Vr0();if((!Q||Y||H_4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(RD("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(RD("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(rX0()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function w7(J,Z,Q){let Y=Q?.deferAuth??!1;Fu1("0.0.1776557243-g13eef6");let X=BC({storage:J.settings,secretStorage:J.secrets,workspaceRoot:v0.of(G1.file(process.cwd())),defaultAmpURL:J.ampURL,homeDir:yz0,userConfigDir:s51});Lh4(X);let K=await X.getLatest();S.debug("Global configuration initialized",{settingsKeys:Object.keys(K.settings)});let V=!1;{let x=await J.secrets.get("apiKey",J.ampURL);if(V=Boolean(x),S.info("API key lookup before login",{found:Boolean(x),ampURL:J.ampURL,deferAuth:Y}),!x)if(Y)S.info("No API key found, continuing startup with deferred auth");else{p5.write(`No API key found. Starting login flow...
6134
6134
  `);let p=await Sh3(J),d=await J.secrets.get("apiKey",J.ampURL);if(S.info("Login flow completed",{success:p,storedKeyPresent:Boolean(d),ampURL:J.ampURL}),!p)await wD(),process.exit(1);V=!0}}{let x=await X.getLatest(),p=x.settings.url,d=x.secrets.isSet?.[p];S.info("Config secrets state after login",{configURL:p,apiKeySet:d?.apiKey??!1})}let G=S1(tZ(X).pipe(b5(Mh3))),F=Y?"pending":await G;if(!Y)S.info("Server status resolved",{status:"ready",isAuthenticated:S6(F),isError:rW(F),errorMessage:rW(F)?F.error.message:void 0});let z=G.then((x)=>Ah3(x));z.catch(()=>{return});let{toolService:q,dispose:W}=vJ0({configService:X}),H=new Map,D=()=>H.clear(),U=new XT0(X,J.settings.getWorkspaceRootPath()),B=D80({configService:X,filesystem:q8}),N=aa1({configService:X,trustStore:U,skillMCPServers:B.skillMCPServers,createOAuthProvider:async(x,p,d)=>{let h=`${x}:${p}`,n=H.get(h);if(n)return S.debug("Reusing existing OAuth provider for server",{serverName:x,serverUrl:p}),n;S.debug("Creating OAuth provider for server",{serverName:x,serverUrl:p});let l=(async()=>{let t=new kE(J.secrets),H0=await t.getClientInfo(x,p),a=d?.scopes??H0?.scopes,Z0=_P4();S.info("OAuth headless mode check",{useHeadless:Z0,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:p5.isTTY});let W0;if(Z0)W0=J.executeMode?CP4():PP4(x);let U0=new gR0({storage:t,serverName:x,serverUrl:p,clientId:d?.clientId??H0?.clientId,clientSecret:d?.clientSecret??H0?.clientSecret,authUrl:d?.authUrl??H0?.authUrl,tokenUrl:d?.tokenUrl??H0?.tokenUrl,scopes:a,headlessAuthHandler:W0});return S.debug("OAuth provider created",{serverName:x,serverUrl:p,hasManualClientId:!!(d?.clientId??H0?.clientId),willUseDCR:!(d?.clientId??H0?.clientId),scopes:a,headlessMode:Z0,executeMode:J.executeMode}),U0})();return H.set(h,l),l}}),w=Ym0({configService:X,filesystem:q8,spawn:JJ0}),L;if(J.executeMode){let x=await AF4({toolService:q,providers:[N,w],initialTimeout:15000});L=x.registrations;for(let[p,d]of x.initErrors)S.warn(`${p} provider initialization slow or failed:`,d)}else L=Xm0({toolService:q,providers:[N,w]});if(Z.jetbrains)EE("JetBrains");else if(Z.ide&&WC4())EE("VS Code");else if(Z.ide&&HC4())EE("Neovim");else if(Z.ide){let x=await Nh3();if(x){let p=G40(x.ideName);if(p)EE(p)}}if(J.executeMode)zu1(!0);let O,E=e$.status.pipe(M1((x)=>Boolean(x.connected&&x.authenticated&&x.ideName&&hu1(x.ideName))),p4()).subscribe((x)=>{if(x){if(!O)O=q.registerTool(MF4)}else O?.dispose(),O=void 0}),M;if(!J.executeMode){let x=await J.settings.get("fuzzy.alwaysIncludePaths")??[];M=new Nv(process.cwd(),{alwaysIncludePaths:x},!0)}else M=new class extends Nv{async start(){}async query(){return[]}async queryCompletions(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};let A=new Fk0(qm(X),{maxThreads:200});S.info("Starting Amp background services");let j=new R01,I=process.env.PLUGINS??"off",T=Z.headless?Zh4():void 0,C=T??new cV0({configService:X}),b=C instanceof cV0?C:void 0;if(b)b.pluginExecutorKind="local";let m=MT0({configService:X,fileSystem:q8,platform:C,internalPlugins:No4,pluginFilter:I}),f=do1({pluginService:m,toolService:q}),v={configService:X,toolService:q,mcpService:N,skillService:B,toolboxService:w,trustStore:U,threadService:A,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:M,fileSystem:q8,terminal:j,pluginService:m,pluginPlatform:b,headlessPluginPlatform:T,serverStatus:F,serverStatusPromise:G,viewerUserIDPromise:z,hasAPIKeyAtStartup:V};return{...v,async asyncDispose(){if(v.mcpService.hasAuthenticatingClients())S.info("Waiting for OAuth authentication to complete before exit..."),await v.mcpService.waitForAuthentication();for(let x of L.values())x.dispose();await v.mcpService.dispose(),D(),await v.threadService.asyncDispose(),v.configService.unsubscribe(),W(),v.fuzzyServer.dispose(),v.settingsStorage[Symbol.dispose](),E.unsubscribe(),O?.dispose(),f.dispose(),await v.pluginService.dispose()}}}async function Sh3(J){if(!J.executeMode){if(!await fX0("Would you like to log in to Amp? [(y)es, (n)o]: "))return p5.write(`Login cancelled. Run the command again to retry.
6135
6135
  `),!1}return await Lo4(J)}async function Lo4(J){let Z=Uo4(32).toString("hex"),Q=await gv(J.ampURL,Z),Y=new AbortController;try{await xV(Q,Y.signal)}catch(K){S.error("Error opening browser",{error:K})}let X=await gv(J.ampURL,Z,!1);p5.write(`If your browser does not open automatically, visit:
6136
6136
 
@@ -6138,7 +6138,7 @@ ${n0.blue.bold(X)}
6138
6138
 
6139
6139
  `);try{return await RT4(J.ampURL,Z,J.secrets,Y),p5.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(K){return S.error("Login failed",{error:K}),SZ.write(`
6140
6140
  Login failed: ${K instanceof Error?K.message:String(K)}
6141
- `),!1}}function kh3(J){let Z=new Zw().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Z.exitOverride((B)=>{if(B.code==="commander.help"||B.code==="commander.version"||B.exitCode===0)kj(),process.exit(0);let N=B.originalError??B;RR4(N)}),ml4(Z,{version:"0.0.1776542811-g13eef6",buildTimestamp:"2026-04-18T20:10:46.198Z",buildType:"'release'"}),Z.addHelpText("after",FC4()),Z.configureHelp({formatHelp:zC4}),Z.command("logout").description("Log out by removing stored API key").action(async(B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);await hh3(L)}),Z.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(B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);await bh3(L,await ei(w,L.settings))}),Z.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(B,N,w)=>{let L=w.optsWithGlobals(),O=await c3(L);await UI4(B??"get",O.ampURL,O.secrets),process.exit(process.exitCode??0)}),Z.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(B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);await BI4(L.ampURL,L.secrets),process.exit(process.exitCode??0)}),Z.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(B)=>{await P_4({raw:B.raw===!0}),process.exit(process.exitCode??0)}),Z.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(`
6141
+ `),!1}}function kh3(J){let Z=new Zw().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});Z.exitOverride((B)=>{if(B.code==="commander.help"||B.code==="commander.version"||B.exitCode===0)kj(),process.exit(0);let N=B.originalError??B;RR4(N)}),ml4(Z,{version:"0.0.1776557243-g13eef6",buildTimestamp:"2026-04-19T00:10:59.131Z",buildType:"'release'"}),Z.addHelpText("after",FC4()),Z.configureHelp({formatHelp:zC4}),Z.command("logout").description("Log out by removing stored API key").action(async(B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);await hh3(L)}),Z.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(B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);await bh3(L,await ei(w,L.settings))}),Z.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(B,N,w)=>{let L=w.optsWithGlobals(),O=await c3(L);await UI4(B??"get",O.ampURL,O.secrets),process.exit(process.exitCode??0)}),Z.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(B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);await BI4(L.ampURL,L.secrets),process.exit(process.exitCode??0)}),Z.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(B)=>{await P_4({raw:B.raw===!0}),process.exit(process.exitCode??0)}),Z.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(`
6142
6142
  `)).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").option("--worker-url <url>","Override DTW worker URL").action(async(B,N,w)=>{if(B&&N.apply)throw new V4("Choose either a positional thread ID/URL or --apply <thread-id>, not both.",1);let L=N.apply??B;if(!L||L.trim().length===0)p5.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.
6143
6143
 
6144
6144
  `),w.outputHelp(),process.exit(0);let O=j9(L)??lY(L),E=w.optsWithGlobals(),M=await c3(E);E2(w,E);let A=await w7(M,E),j=!1;try{if(N.checkout&&N.skipCheckout)throw new V4("Choose either --checkout or --skip-checkout, not both.",1);if(rW(A.serverStatus))throw r51(A.serverStatus,M.ampURL);let I=S6(A.serverStatus)?A.serverStatus.features:void 0;if(!Jr(I,r7.V2))throw new V4("live-sync is not enabled for your user",1);await DT4({ampURL:M.ampURL,threadId:O,configService:A.configService,threadService:A.threadService,apiKey:E.apiKey??process.env.AMP_API_KEY,applyOnce:typeof N.apply==="string",workerURL:N.workerUrl??process.env.AMP_WORKER_URL,checkoutMode:N.checkout?"always":N.skipCheckout?"never":"prompt",promptForYesNo:fX0}),j=!0}finally{if(await A.asyncDispose(),j)process.exit(0)}});let Q=async(B,N,w)=>{BC({storage:N.settings,secretStorage:N.secrets,workspaceRoot:v0.of(G1.file(process.cwd())),defaultAmpURL:N.ampURL,homeDir:yz0,userConfigDir:s51});let L={...N,executeMode:!1};await xz0(L,{...B,openThreadSwitcher:!0},w,J)},Y=Z.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(B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);await Do4(w,L,N)});Y.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(B,N)=>{let w=N.optsWithGlobals(),L=await c3(w);await rh3(w,L,N)}),Y.command("continue [threadIDOrURL]").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.").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(B,N,w)=>{let L=w.optsWithGlobals(),O=await c3(L);if(N.pick)SZ.write(`${n0.yellow("Warning:")} The --pick flag is deprecated. The picker is now shown by default.
@@ -6172,8 +6172,8 @@ ${M}
6172
6172
 
6173
6173
  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 vh3(J){if(J.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof J.execute==="string"){let Z=(await nV0()).trimEnd();return{userInput:J.execute,stdinInput:Z||null}}return{userInput:(await nV0()).trimEnd(),stdinInput:null}}function yh3(J,Z,Q){if(J.remote&&!Z)throw new V4("The -r/--remote flag requires --execute mode",1,'Use: amp --remote --execute "your message"');if(J.streamJson&&!Z)throw new V4("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(J.streamJsonInput&&!Z)throw new V4("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(J.streamJsonInput&&!J.streamJson)throw new V4("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(J.stats&&!Z)throw new V4("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(J.archive&&!Z)throw new V4("The --archive flag requires --execute mode",1,'Use: amp --execute "your message" --archive');if(J.streamJsonInput&&typeof J.execute==="string"&&J.execute.trim()!=="")throw new V4("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(Z&&Q===""&&!J.streamJsonInput&&!J.headless)throw new V4("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"
6174
6174
  Or pipe via stdin: echo "your message" | amp --execute`)}async function xz0(J,Z,Q,Y){let X=process.hrtime.bigint(),K=(e,Y0)=>{let c=Number(process.hrtime.bigint()-Y0)/1e6,o=KE4();S.info("Startup phase",{phase:e,phaseMs:Math.round(c),sinceMainMs:o===null?void 0:Math.round(o)})},{userInput:V,stdinInput:G}=await vh3(Z),F=!!Z.streamJson||!!Z.streamJsonThinking;yh3({...Z,streamJson:F},J.executeMode,V),E2(Q,Z);let z=process.hrtime.bigint(),q=Boolean(await J.secrets.get("apiKey",J.ampURL)),W=!J.executeMode&&!Z.headless&&q;S.info("Interactive auth startup mode",{deferInteractiveAuth:W,hasAPIKeyAtStartup:q,executeMode:J.executeMode,headless:Boolean(Z.headless)});let H=await w7(J,Z,{deferAuth:W});K("runMainThread:createThreadDependencies",z),z=process.hrtime.bigint();let D=await fz0(H);K("runMainThread:createWorkerDeps",z);let{serverStatus:U}=H;if(!W&&rW(U))throw r51(U,J.ampURL);let B=S6(U)?U:null,N=B?.user.email,w=!!(N&&I2(N));if(!W)await Fo4(Q,Z,U);let L=Ex(U),O=L?.features??[],E=L?.team??null,M=dV0(Z,L);if(M instanceof Error)T3(M.message);if(B&&!_b(Z.mode,N))throw new V4(`Agent mode '${Z.mode}' is only available for Amp employees`,1);if(J.executeMode&&Z.remote)await Xh4(V,G,H.configService),await H.asyncDispose(),process.exit(0);if(Z.headless){if(process.env.AMP_EXECUTOR!=="1"&&(!N||!I2(N)))throw new V4("Headless executor mode is only available for Amp employees",1);let Y0=await H.secretStorage.get("apiKey",J.ampURL);if(!Y0)throw new V4("API key required for headless mode. Please run `amp login` first.",1);let c=typeof Z.headless==="string"&&Z.headless!=="true"?Z.headless:void 0;if(c&&!iJ(c))throw new V4(`Invalid thread ID: ${c}`,1);let o=c?void 0:await ah3({dependencies:H,visibility:M??void 0}),r=c??o?.threadId;if(!r)throw new V4("Failed to resolve headless thread ID",1);let $0=await vP4(r);if($0.status==="already-running")await H.asyncDispose(),await wD(),process.exit(0);try{await MP4({ampURL:J.ampURL,apiKey:Y0,workerUrl:process.env.AMP_WORKER_URL,workspaceRoot:process.cwd(),threadId:r,ownerUserId:o?.ownerUserId,threadVersion:o?.threadVersion,agentMode:o?.agentMode,initialToolDiscovery:Promise.all([H.mcpService.initialized,H.toolboxService.initialized]).then(()=>{return}),configService:H.configService,mcpService:H.mcpService,toolService:H.toolService,skillService:H.skillService,fileSystem:H.fileSystem,pluginService:H.pluginService,pluginPlatform:H.headlessPluginPlatform})}finally{await $0.release(),await H.asyncDispose()}await wD(),process.exit(0)}let A=Z.threadId&&iJ(Z.threadId)?Z.threadId:void 0,j=W?await H.serverStatusPromise:U,I=S6(j)&&Jr(j.features,r7.NEO_TUI);if((I||Z.neo||!1)&&!J.executeMode&&!Z.takeMeBack){if(Z.neo&&!I&&(!S6(j)||!I2(j.user.email)))throw new V4("--neo is only available for Amp employees",1);let e=await H.secretStorage.get("apiKey",J.ampURL);if(!e)throw new V4("API key required. Please run `amp login` first.",1);let Y0=qm(H.configService),c=new kR(H.fuzzyServer),o=process.cwd();await w01({ampURL:J.ampURL,apiKey:e,workerURL:process.env.AMP_WORKER_URL??dG(J.ampURL),configService:H.configService,toolService:H.toolService,skillService:H.skillService,mcpService:H.mcpService,readFileSystemDirectory:({uri:r})=>Av({fileSystem:H.fileSystem,workspaceRoot:o},r),completionBuilder:c,listThreads:()=>Y0.listThreads(),getThread:(r)=>Y0.getThread(r),isInternalUser:S6(j)&&I2(j.user.email)},{initialThreadID:A,openThreadPickerOnStart:Z.openThreadSwitcher});return}let C=J.executeMode?void 0:async(e)=>Qr(e,"interactive"),b={threadService:H.threadService,workerDeps:D,createThread:async(e)=>{let Y0=W?await H.serverStatusPromise:U,c=await jY0(J.settings,process.cwd(),Ex(Y0),M);if(c instanceof Error)T3(c.message);return E61(D,{threadMeta:c?mD(c):void 0,agentMode:e??Z.mode,onFirstAssistantMessage:C})},validateThreadOwnership:async(e,Y0)=>{if(Y0?.nonBlockingOwnershipCheck){Wo4(e,H.configService,H.viewerUserIDPromise).catch((c)=>{if(c instanceof V4){if(Y0.onOwnershipError){Y0.onOwnershipError(c,e);return}LD(c,e);return}S.warn("Failed to validate thread ownership in CLI, allowing to open",{error:c})});return}try{await Wo4(e,H.configService,H.viewerUserIDPromise)}catch(c){if(c instanceof V4)throw c;S.warn("Failed to validate thread ownership in CLI, allowing to open",{error:c})}},switchThreadVisibility:M,switchThreadAgentMode:Z.mode,onFirstAssistantMessage:C,handleError:LD},m=async()=>{try{return xl4(b,Z.threadId,{nonBlockingOwnershipCheck:Z.nonBlockingThreadOwnershipCheck})}catch(e){if(e instanceof V4)throw e;throw await LD(e,Z.threadId),Error("handleError should have called process.exit()")}};if(Z.format==="jsonl")SZ.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
6175
- `),await wD(),process.exit(1);let f=(async()=>{if(W){S.info("Skipping initial free tier status fetch until auth is complete");return}try{let e=await H.configService.getLatest(),Y0=Lb(e),c=await h5.getUserFreeTierStatus({},{config:H.configService,signal:AbortSignal.timeout(Y0)});if(c.ok)return S.info("User free tier status:",c),c.result;return}catch(e){S.error("Failed to fetch free tier status:",e);return}})(),x=!J.executeMode?new x01:null,p,d=null;if(x)p=x,d=(async()=>{let e=W?await H.serverStatusPromise:H.serverStatus;if(rW(e))throw r51(e,J.ampURL);await Fo4(Q,Z,e);let Y0=process.hrtime.bigint(),c=await m();if(K("runMainThread:createThreadPool",Y0),x.attach(c),V){let o=await S1(c.threadHandles$);if(!o)throw new V4("No active thread is available yet.",1);await o.sendMessage({content:[{type:"text",text:V}]})}})(),d.catch(async(e)=>{let Y0=e instanceof Error?e:Error(String(e));x.setInitError(Y0),await LD(e,Z.threadId)});else z=process.hrtime.bigint(),p=await m(),K("runMainThread:createThreadPool",z);let h=Z.notifications!==void 0?Z.notifications:!J.executeMode,n=B!==null&&Jr(B.features,r7.TUI_VOICE_NOTIF);if(W)H.serverStatusPromise.then((e)=>{n=S6(e)&&Jr(e.features,r7.TUI_VOICE_NOTIF)}).catch((e)=>{S.debug("Failed to resolve TUI voice notification feature flag",{error:e})});z=process.hrtime.bigint();let l=await H.configService.getLatest();if(K("runMainThread:configService.getLatest",z),z=process.hrtime.bigint(),Th3({configService:H.configService,threadService:H.threadService,config:l,useNotificationsForService:h,isTUIVoiceNotifEnabled:()=>n,threadViewStates$:()=>p.threadHandles$.pipe(v4((e)=>{if(!e)return v0.of({});return O5(e.thread$,e.threadViewState$).pipe(M1(([Y0,c])=>({[Y0.id]:c})))}))}),K("runMainThread:createCliNotificationService",z),J.executeMode){uT4(H.mcpService,J.settings);let e={userInput:V,stdinInput:G,dependencies:H,streamJson:F,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isInternalUser:w,agentMode:Z.mode,labels:Z.label},Y0=await hR4({threadPool:p,...e});if(await Qr(Y0,"execute"),Z.archive)await H.threadService.archive(Y0,!0),await Yr(H.threadService,Y0);await H.asyncDispose(),process.exit(0)}let t=!1,H0=!1;if(Z.jetbrains||Z.ide){await lu1();let e=await RE({jetbrainsOnly:Z.jetbrains});if(e.length===0){if(Z.jetbrains)t=!await H.configService.get("jetbrains.skipInstall")}else if(e.length===1){let Y0=e[0];if(Y0)e$.selectConfig(Y0)}else H0=!0}z=process.hrtime.bigint();let a=qo0("0.0.1776542811-g13eef6",H.settingsStorage,{startDelayMs:3000});K("runMainThread:createUpdateService",z),z=process.hrtime.bigint();let Z0=new io0(H.mcpService,J.settings.getWorkspaceRootPath());if(K("runMainThread:createMcpTrustHandler",z),V&&J.executeMode){let e=await S1(p.threadHandles$);if(!e)throw new V4("No active thread is available yet.",1);await e.sendMessage({content:[{type:"text",text:V}]})}z=process.hrtime.bigint();let W0=await mX0();K("runMainThread:loadSessionState",z),S.info("Loaded session state:",W0);let U0={...W0,launchCount:W0.launchCount+1};PD((e)=>({...e,launchCount:e.launchCount+1}));try{if(z=process.hrtime.bigint(),await Ig4({history:new $a0,fuzzyServer:H.fuzzyServer,settingsStorage:H.settingsStorage,threadService:H.threadService,skillService:H.skillService,configService:H.configService,secretStorage:H.secretStorage,internalAPIClient:h5,threadPool:p,createSystemPromptDeps:async()=>wo4(H),ideClient:e$,mcpService:H.mcpService,toolboxService:H.toolboxService,mcpTrustHandler:Z0,updateService:a,pluginPlatform:H.pluginPlatform,pluginService:H.pluginService},{initialServerStatus:H.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:H.hasAPIKeyAtStartup,ampURL:J.ampURL,startupThreadID:A,showJetBrainsInstaller:t,showIdePickerHint:H0,openThreadSwitcher:Z.openThreadSwitcher,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Bh3,logFile:{path:Y},sessionState:U0,freeTierStatusPromise:f,workspace:E??null,features:O,isInternalUser:w,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-04-18T20:10:46.198Z"},(e)=>new p01({...e,threadPool:e.threadPool},(Y0)=>new L61({...Y0,threadState:Y0.threadState}))),K("runMainThread:mountApp-returned",z),d)await d}finally{await p.dispose().catch((e)=>{S.error("Failed to dispose thread pool during shutdown",e)})}await H.asyncDispose(),K("runMainThread:dependencies.asyncDispose",X),process.exit(0)}async function c3(J){if(S.info("Initializing CLI context",{argv:process.argv,nodeEnv:"production",hasAmpURL:Boolean(process.env.AMP_URL),hasAmpAPIKey:Boolean(process.env.AMP_API_KEY),hasSettingsFile:Boolean(process.env.AMP_SETTINGS_FILE)}),J.interactive)SZ.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6176
- `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;S.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await ea1({get:async(G)=>{if(G!==Og)return;try{let F=await Bo4(o51,"utf-8");return JSON.parse(F).installationID}catch{return}},set:async(G,F)=>{if(G!==Og)return;await Wh3(Zr.dirname(o51),{recursive:!0}),await Hh3(o51,JSON.stringify({installationID:F},null,2),{mode:384})}},{clientType:"cli",platform:o50()});qu1(Y);let X=await $X0({...J,workspaceTrust:{current:!0,changes:Hj0},getHook:process.env.AMP_URL?(G,F)=>{if(G==="url")return Promise.resolve(process.env.AMP_URL);return F()}:void 0});if(J.mcpConfig){let G=await xT4(J.mcpConfig);X=fT4(X,G)}let K=Zr.dirname(X.getSettingsFilePath());BW4(Tv,K),X=cx1(X);let V=await X.get("url","global");if(!V)V=t9;if(S.info("Resolved Amp URL",{ampURL:V,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!sU(V))S.info("Targeting custom Amp server",{ampURL:V});return{executeMode:Z,isTTY:Q,ampURL:V,settings:X,secrets:hX0(await ei(J,X))}}function xh3(J){let Z={};for(let Q=0;Q<J.length;Q++){let Y=J[Q];if(Y?.startsWith("--")){let K=Y.slice(2).replace(/-([a-z])/g,(G,F)=>F.toUpperCase()),V=J[Q+1];if(V&&!V.startsWith("--"))Z[K]=V,Q++}}return Z}function fh3(J,Z){let Q=J.includes("--headless")||J.some((X)=>X.startsWith("--headless=")),Y=Zr.resolve(Z.logFile??process.env.AMP_LOG_FILE??(Q?Uh3:xi));return{logLevel:Z.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:Y}}async function uh3(){XE4();let J=xh3(process.argv),Z=fh3(process.argv,J),Q=UR4(Z),Y=process.argv.includes("--no-color"),X=process.argv.includes("--color"),K=process.stdout.isTTY&&process.stderr.isTTY;if(Y||!X&&!K)n0.level=0;if(wh3(S),S.info("Starting Amp CLI.",{version:"0.0.1776542811-g13eef6",buildTimestamp:"2026-04-18T20:10:46.198Z"}),process.platform==="win32"&&hj())SC4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new V4(a2.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await kh3(Q).parseAsync(process.argv)}DW4().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await uh3().catch(LD)});async function bh3(J,Z){let Q=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Q)await J.settings.set("url",process.env.AMP_URL,"global"),p5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6175
+ `),await wD(),process.exit(1);let f=(async()=>{if(W){S.info("Skipping initial free tier status fetch until auth is complete");return}try{let e=await H.configService.getLatest(),Y0=Lb(e),c=await h5.getUserFreeTierStatus({},{config:H.configService,signal:AbortSignal.timeout(Y0)});if(c.ok)return S.info("User free tier status:",c),c.result;return}catch(e){S.error("Failed to fetch free tier status:",e);return}})(),x=!J.executeMode?new x01:null,p,d=null;if(x)p=x,d=(async()=>{let e=W?await H.serverStatusPromise:H.serverStatus;if(rW(e))throw r51(e,J.ampURL);await Fo4(Q,Z,e);let Y0=process.hrtime.bigint(),c=await m();if(K("runMainThread:createThreadPool",Y0),x.attach(c),V){let o=await S1(c.threadHandles$);if(!o)throw new V4("No active thread is available yet.",1);await o.sendMessage({content:[{type:"text",text:V}]})}})(),d.catch(async(e)=>{let Y0=e instanceof Error?e:Error(String(e));x.setInitError(Y0),await LD(e,Z.threadId)});else z=process.hrtime.bigint(),p=await m(),K("runMainThread:createThreadPool",z);let h=Z.notifications!==void 0?Z.notifications:!J.executeMode,n=B!==null&&Jr(B.features,r7.TUI_VOICE_NOTIF);if(W)H.serverStatusPromise.then((e)=>{n=S6(e)&&Jr(e.features,r7.TUI_VOICE_NOTIF)}).catch((e)=>{S.debug("Failed to resolve TUI voice notification feature flag",{error:e})});z=process.hrtime.bigint();let l=await H.configService.getLatest();if(K("runMainThread:configService.getLatest",z),z=process.hrtime.bigint(),Th3({configService:H.configService,threadService:H.threadService,config:l,useNotificationsForService:h,isTUIVoiceNotifEnabled:()=>n,threadViewStates$:()=>p.threadHandles$.pipe(v4((e)=>{if(!e)return v0.of({});return O5(e.thread$,e.threadViewState$).pipe(M1(([Y0,c])=>({[Y0.id]:c})))}))}),K("runMainThread:createCliNotificationService",z),J.executeMode){uT4(H.mcpService,J.settings);let e={userInput:V,stdinInput:G,dependencies:H,streamJson:F,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isInternalUser:w,agentMode:Z.mode,labels:Z.label},Y0=await hR4({threadPool:p,...e});if(await Qr(Y0,"execute"),Z.archive)await H.threadService.archive(Y0,!0),await Yr(H.threadService,Y0);await H.asyncDispose(),process.exit(0)}let t=!1,H0=!1;if(Z.jetbrains||Z.ide){await lu1();let e=await RE({jetbrainsOnly:Z.jetbrains});if(e.length===0){if(Z.jetbrains)t=!await H.configService.get("jetbrains.skipInstall")}else if(e.length===1){let Y0=e[0];if(Y0)e$.selectConfig(Y0)}else H0=!0}z=process.hrtime.bigint();let a=qo0("0.0.1776557243-g13eef6",H.settingsStorage,{startDelayMs:3000});K("runMainThread:createUpdateService",z),z=process.hrtime.bigint();let Z0=new io0(H.mcpService,J.settings.getWorkspaceRootPath());if(K("runMainThread:createMcpTrustHandler",z),V&&J.executeMode){let e=await S1(p.threadHandles$);if(!e)throw new V4("No active thread is available yet.",1);await e.sendMessage({content:[{type:"text",text:V}]})}z=process.hrtime.bigint();let W0=await mX0();K("runMainThread:loadSessionState",z),S.info("Loaded session state:",W0);let U0={...W0,launchCount:W0.launchCount+1};PD((e)=>({...e,launchCount:e.launchCount+1}));try{if(z=process.hrtime.bigint(),await Ig4({history:new $a0,fuzzyServer:H.fuzzyServer,settingsStorage:H.settingsStorage,threadService:H.threadService,skillService:H.skillService,configService:H.configService,secretStorage:H.secretStorage,internalAPIClient:h5,threadPool:p,createSystemPromptDeps:async()=>wo4(H),ideClient:e$,mcpService:H.mcpService,toolboxService:H.toolboxService,mcpTrustHandler:Z0,updateService:a,pluginPlatform:H.pluginPlatform,pluginService:H.pluginService},{initialServerStatus:H.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:H.hasAPIKeyAtStartup,ampURL:J.ampURL,startupThreadID:A,showJetBrainsInstaller:t,showIdePickerHint:H0,openThreadSwitcher:Z.openThreadSwitcher,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Bh3,logFile:{path:Y},sessionState:U0,freeTierStatusPromise:f,workspace:E??null,features:O,isInternalUser:w,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-04-19T00:10:59.131Z"},(e)=>new p01({...e,threadPool:e.threadPool},(Y0)=>new L61({...Y0,threadState:Y0.threadState}))),K("runMainThread:mountApp-returned",z),d)await d}finally{await p.dispose().catch((e)=>{S.error("Failed to dispose thread pool during shutdown",e)})}await H.asyncDispose(),K("runMainThread:dependencies.asyncDispose",X),process.exit(0)}async function c3(J){if(S.info("Initializing CLI context",{argv:process.argv,nodeEnv:"production",hasAmpURL:Boolean(process.env.AMP_URL),hasAmpAPIKey:Boolean(process.env.AMP_API_KEY),hasSettingsFile:Boolean(process.env.AMP_SETTINGS_FILE)}),J.interactive)SZ.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6176
+ `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;S.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await ea1({get:async(G)=>{if(G!==Og)return;try{let F=await Bo4(o51,"utf-8");return JSON.parse(F).installationID}catch{return}},set:async(G,F)=>{if(G!==Og)return;await Wh3(Zr.dirname(o51),{recursive:!0}),await Hh3(o51,JSON.stringify({installationID:F},null,2),{mode:384})}},{clientType:"cli",platform:o50()});qu1(Y);let X=await $X0({...J,workspaceTrust:{current:!0,changes:Hj0},getHook:process.env.AMP_URL?(G,F)=>{if(G==="url")return Promise.resolve(process.env.AMP_URL);return F()}:void 0});if(J.mcpConfig){let G=await xT4(J.mcpConfig);X=fT4(X,G)}let K=Zr.dirname(X.getSettingsFilePath());BW4(Tv,K),X=cx1(X);let V=await X.get("url","global");if(!V)V=t9;if(S.info("Resolved Amp URL",{ampURL:V,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!sU(V))S.info("Targeting custom Amp server",{ampURL:V});return{executeMode:Z,isTTY:Q,ampURL:V,settings:X,secrets:hX0(await ei(J,X))}}function xh3(J){let Z={};for(let Q=0;Q<J.length;Q++){let Y=J[Q];if(Y?.startsWith("--")){let K=Y.slice(2).replace(/-([a-z])/g,(G,F)=>F.toUpperCase()),V=J[Q+1];if(V&&!V.startsWith("--"))Z[K]=V,Q++}}return Z}function fh3(J,Z){let Q=J.includes("--headless")||J.some((X)=>X.startsWith("--headless=")),Y=Zr.resolve(Z.logFile??process.env.AMP_LOG_FILE??(Q?Uh3:xi));return{logLevel:Z.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:Y}}async function uh3(){XE4();let J=xh3(process.argv),Z=fh3(process.argv,J),Q=UR4(Z),Y=process.argv.includes("--no-color"),X=process.argv.includes("--color"),K=process.stdout.isTTY&&process.stderr.isTTY;if(Y||!X&&!K)n0.level=0;if(wh3(S),S.info("Starting Amp CLI.",{version:"0.0.1776557243-g13eef6",buildTimestamp:"2026-04-19T00:10:59.131Z"}),process.platform==="win32"&&hj())SC4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new V4(a2.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await kh3(Q).parseAsync(process.argv)}DW4().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await uh3().catch(LD)});async function bh3(J,Z){let Q=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Q)await J.settings.set("url",process.env.AMP_URL,"global"),p5.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6177
6177
  `);else if(!sU(J.ampURL))p5.write(`Logging in to ${new URL(J.ampURL).hostname}
6178
6178
  `);let Y=process.env.AMP_API_KEY;if(Y)p5.write(`API key found in environment variable, storing...
6179
6179
  `),await Z.set("apiKey",Y,J.ampURL),p5.write(`API key successfully stored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1776542811-g13eef6",
3
+ "version": "0.0.1776557243-g13eef6",
4
4
  "description": "CLI for Amp, the frontier coding agent.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {