@sourcegraph/amp 0.0.1776269877-gac06d1 → 0.0.1776284074-g53a1f8

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
@@ -4683,12 +4683,12 @@ ${D}`))}},error:(U)=>{if(!H)H=!0,F(Error(`Failed to spawn brew: ${U.message}`))}
4683
4683
  ${D}`;if(K==="pnpm"&&D.includes("Unable to find the global bin directory"))B+=`
4684
4684
 
4685
4685
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
4686
- npm install -g @sourcegraph/amp`;F(Error(B))}},error:(U)=>{if(!W)W=!0,F(Error(`Failed to spawn ${K}: ${U.message}`))},complete:()=>{if(!W)W=!0,G()}})})}n0();n0();dH();async function EX0(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=AC4(J,z),W=q<0,H,U;if(F.time){let D=F.time[J],B=F.time[z],N=Date.now();if(D)H=Math.floor((N-new Date(D).getTime())/3600000);if(B)U=Math.floor((N-new Date(B).getTime())/3600000)}return _.info("NPM version comparison",{currentVersion:J,latestVersion:z,compareResult:q,hasUpdate:W,currentVersionAge:H,latestVersionAge:U}),{hasUpdate:W,latestVersion:z,currentVersion:J,currentVersionAge:H,latestVersionAge:U,source:"npm"}}catch(G){return _.debug("Error checking npm version",{error:G}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var JX3="https://static.ampcode.com/cli/cli-version.txt";async function MX0(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let Y=await fetch(`${JX3}?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=AC4(J,X),V=K<0;return _.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:K,hasUpdate:V}),{hasUpdate:V,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return _.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var ZX3=604800000;function MC4(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>ZX3)return{ageMs:Q};return null}function AC4(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 _o0(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?hz(Q):void 0;return{sha:Y,age:X}}catch{return null}}E1();function To0(J,Z,Q={}){let Y=new q4,X=Y.pipe(h6({shouldCountRefs:!1}));return setImmediate(async()=>{let K=new cF().scoped("update"),V=Q.startDelayMs??0;if(V>0)await bz(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 bz(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 LX0(),W=q==="binary"||q==="brew";K.debug("checking",{currentVersion:J,mode:z,packageManager:q,isBinaryDistribution:W});let H;if(W)H=await MX0(J);else{let D=await nj();H=await EX0(J,D)}if(!(H.latestVersion&&H.hasUpdate)){K.debug("no update available");return}let U=()=>{if(H.currentVersionAge!==void 0&&H.latestVersionAge!==void 0){let D=H.currentVersionAge-H.latestVersionAge,B=0.5;if(Math.abs(D)<0.5)return K.debug("versions too close together, suppressing update warning",{currentVersionAge:H.currentVersionAge,latestVersionAge:H.latestVersionAge,ageDifferenceHours:D}),!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(!U())Y.next("update-available-brew");return}if(q==="binary"&&process.execPath!==Ao0()){if(K.debug("non-standard binary path, showing warning"),!U())Y.next("update-available-unrecognized-path");return}if(z==="warn"){if(!U())Y.next("update-available");return}if(!q){if(K.debug("auto-update not supported, falling back to warn mode"),!U())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"),!U())Y.next("update-available");return}try{await Fn(H.latestVersion,q);let D=await uw(H.latestVersion),B={from:H.currentVersion,to:H.latestVersion,...D};if(D.status==="same")K.info("success",B),Y.next("updated");else K.warn("success with warning",B),Y.next("updated-with-warning")}catch(D){Y.next("update-error")}}catch(F){K.debug("check failed",{error:F})}finally{await bz(5000),Y.next("hidden"),G.unsubscribe(),Y.complete()}}),{state:X}}dH();import{stderr as aG}from"node:process";function jC4(J){let Z=new eN().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 Bo0(Y.force||!1,Y.verbose||!1,"0.0.1776269877-gac06d1"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new eN("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 YX3(Y.targetVersion)});J.addCommand(Q)}function QX3(J){let Z=Boolean(J.isTTY),Q=0,Y=!1;function X(){if(!Z||!Y)return;J.write(`
4686
+ npm install -g @sourcegraph/amp`;F(Error(B))}},error:(U)=>{if(!W)W=!0,F(Error(`Failed to spawn ${K}: ${U.message}`))},complete:()=>{if(!W)W=!0,G()}})})}n0();n0();dH();async function EX0(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=AC4(J,z),W=q<0,H,U;if(F.time){let D=F.time[J],B=F.time[z],N=Date.now();if(D)H=Math.floor((N-new Date(D).getTime())/3600000);if(B)U=Math.floor((N-new Date(B).getTime())/3600000)}return _.info("NPM version comparison",{currentVersion:J,latestVersion:z,compareResult:q,hasUpdate:W,currentVersionAge:H,latestVersionAge:U}),{hasUpdate:W,latestVersion:z,currentVersion:J,currentVersionAge:H,latestVersionAge:U,source:"npm"}}catch(G){return _.debug("Error checking npm version",{error:G}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var JX3="https://static.ampcode.com/cli/cli-version.txt";async function MX0(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let Y=await fetch(`${JX3}?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=AC4(J,X),V=K<0;return _.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:K,hasUpdate:V}),{hasUpdate:V,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return _.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var ZX3=604800000;function MC4(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>ZX3)return{ageMs:Q};return null}function AC4(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 _o0(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?hz(Q):void 0;return{sha:Y,age:X}}catch{return null}}E1();function To0(J,Z,Q={}){let Y=new q4,X=Y.pipe(h6({shouldCountRefs:!1}));return setImmediate(async()=>{let K=new cF().scoped("update"),V=Q.startDelayMs??0;if(V>0)await bz(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 bz(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 LX0(),W=q==="binary"||q==="brew";K.debug("checking",{currentVersion:J,mode:z,packageManager:q,isBinaryDistribution:W});let H;if(W)H=await MX0(J);else{let D=await nj();H=await EX0(J,D)}if(!(H.latestVersion&&H.hasUpdate)){K.debug("no update available");return}let U=()=>{if(H.currentVersionAge!==void 0&&H.latestVersionAge!==void 0){let D=H.currentVersionAge-H.latestVersionAge,B=0.5;if(Math.abs(D)<0.5)return K.debug("versions too close together, suppressing update warning",{currentVersionAge:H.currentVersionAge,latestVersionAge:H.latestVersionAge,ageDifferenceHours:D}),!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(!U())Y.next("update-available-brew");return}if(q==="binary"&&process.execPath!==Ao0()){if(K.debug("non-standard binary path, showing warning"),!U())Y.next("update-available-unrecognized-path");return}if(z==="warn"){if(!U())Y.next("update-available");return}if(!q){if(K.debug("auto-update not supported, falling back to warn mode"),!U())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"),!U())Y.next("update-available");return}try{await Fn(H.latestVersion,q);let D=await uw(H.latestVersion),B={from:H.currentVersion,to:H.latestVersion,...D};if(D.status==="same")K.info("success",B),Y.next("updated");else K.warn("success with warning",B),Y.next("updated-with-warning")}catch(D){Y.next("update-error")}}catch(F){K.debug("check failed",{error:F})}finally{await bz(5000),Y.next("hidden"),G.unsubscribe(),Y.complete()}}),{state:X}}dH();import{stderr as aG}from"node:process";function jC4(J){let Z=new eN().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 Bo0(Y.force||!1,Y.verbose||!1,"0.0.1776284074-g53a1f8"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new eN("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 YX3(Y.targetVersion)});J.addCommand(Q)}function QX3(J){let Z=Boolean(J.isTTY),Q=0,Y=!1;function X(){if(!Z||!Y)return;J.write(`
4687
4687
  `),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 YX3(J){let Q=process.platform==="win32"&&ij()?{currentExecutablePath:process.execPath}:void 0,{flushProgressLine:Y,renderProgress:X}=QX3(aG);if(process.env.AMP_SKIP_UPDATE_CHECK==="1")aG.write(o0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
4688
4688
 
4689
4689
  `));try{if(!J){aG.write(o0.blue(`Checking for updates...
4690
- `));let G=!1,F;if(ij()){let z=await MX0("0.0.1776269877-gac06d1");G=z.hasUpdate,F=z.latestVersion}else{let z=await nj(),q=await EX0("0.0.1776269877-gac06d1",z);G=q.hasUpdate,F=q.latestVersion}if(!G){let z=_o0("0.0.1776269877-gac06d1"),q=z?.age?`released ${z.age} ago`:`built ${hz(new Date("2026-04-15T16:22:21.572Z"))} ago`;aG.write(o0.green(`✓ Amp is already up to date on version ${"0.0.1776269877-gac06d1"} (${q})
4691
- `));let W=await uw("0.0.1776269877-gac06d1",Q);if(W.warning)aG.write(`
4690
+ `));let G=!1,F;if(ij()){let z=await MX0("0.0.1776284074-g53a1f8");G=z.hasUpdate,F=z.latestVersion}else{let z=await nj(),q=await EX0("0.0.1776284074-g53a1f8",z);G=q.hasUpdate,F=q.latestVersion}if(!G){let z=_o0("0.0.1776284074-g53a1f8"),q=z?.age?`released ${z.age} ago`:`built ${hz(new Date("2026-04-15T20:18:30.508Z"))} ago`;aG.write(o0.green(`✓ Amp is already up to date on version ${"0.0.1776284074-g53a1f8"} (${q})
4691
+ `));let W=await uw("0.0.1776284074-g53a1f8",Q);if(W.warning)aG.write(`
4692
4692
  `+o0.yellow(W.warning)+`
4693
4693
  `);process.exit(0)}if(!F)aG.write(o0.yellow("[WARN] could not find latest version")),process.exit(0);J=F}aG.write(o0.blue(`Updating to version ${J}...
4694
4694
  `)),await Fn(J,void 0,(G)=>{Y(),aG.write(o0.dim(`Running: ${G}
@@ -5885,7 +5885,7 @@ ${X}`,Z);this.line=Q,this.column=Y,this.codeblock=X}}/*!
5885
5885
  `),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(`
5886
5886
  `))}return new l0({decoration:{color:Q.colorScheme.background,border:X4.all(new Q4(Y.app.keybind,1,"rounded"))},child:new c0({padding:P0.symmetric(0,1),child:new $0({text:new P(void 0,void 0,K)})})})}}class a11 extends N2{chartData;highlightIndex;showAxes;colors;constructor({key:J,chartData:Z,highlightIndex:Q=null,showAxes:Y=!0,colors:X=jF0}){super(J?{key:J}:{});this.chartData=Z,this.highlightIndex=Q,this.showAxes=Y,this.colors=X}createRenderObject(){return new i11({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 sm4(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?j9: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?j9: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 h_3(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?j9: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)),U=z+Z*H+Math.floor(H/2),D=G>0?V/G:0,B=Math.round((1-D)*(W-1));return{x:U,y:B}}case"line":case"sparkline":case"stacked-area":{let z=K?j9: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),U=G>0?V/G:0,D=Math.round((1-U)*(W-1));return{x:H,y:D}}default:return null}}function g_3(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 m_3(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 p_3(J,Z,Q,Y,X,K,V){let G;try{let D=h1.of(J),B=y0.of(J);G={foreground:D.colorScheme.foreground,background:D.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}),U=(D,B)=>new P(B,H,void 0,_X0(D),()=>{c3(J,D)});if(Y.length<=1){if(W.push(new P(`${Z.label}: `,F)),Z.link)W.push(U(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 D=V==="stacked-bar"||V==="stacked-area";W.push(new P(`${Z.label}
5887
5887
  `,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(U(L.link,K(L.value)));else W.push(new P(K(L.value),z));if(N<Y.length-1||D)W.push(new P(`
5888
- `))}if(D)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:X4.all(new Q4(G.border,1,"rounded"))},child:new $0({text:new P(void 0,void 0,W)})})}n0();W9();AE();nJ();e3();S2();cd();uX();rJ();KY();tJ();mA();c4();Vm();JC();E1();n0();rJ();class o11{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.1776269877-gac06d1"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await $60(Z,this.configService)}catch(Z){_.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 u0{props;constructor(J){super();this.props=J}createState(){return new tm4}}class tm4 extends f0{_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 em4 extends f0{controller=new i7;focusNode=new E6({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=y0.of(J),{colors:Q,app:Y}=Z,X=this.widget.props.isRequiredArg??!0,K=this.controller.text.trim().length>0,V=!X||K,G=X4.all(new Q4(Q.foreground,1,"solid")),F=new JX({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(U)=>{let D=U.trim();if(X&&D.length===0)return;this.widget.props.onSubmit(D)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),z=new W1({children:[new l0({decoration:{color:Q.background},child:new $0({text:new P(">",new g({color:Q.foreground}))})}),new c1({child:F})]}),q=new l0({padding:P0.symmetric(1,0),child:new $0({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:P0.symmetric(1,0),child:new $0({text:new P("",void 0,W)})});return new l0({decoration:{border:G,color:Q.background},padding:P0.all(1),child:new d0({children:[q,new R0({height:1}),z,new y5,H]})})}}class Bo extends u0{props;constructor(J){super();this.props=J}createState(){return new em4}}tJ();class $p4 extends f0{controller=new i7;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new E6({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 iq(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=y0.of(J),{colors:Q,app:Y}=Z,K=O4.of(J).size.height,V=Math.max(Math.floor(K*0.5),10),G=new dU({controller:this.controller,triggers:[new eK],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(U)=>{this.widget.props.onSubmit(U.trim(),this.imageAttachments)},theme:Q,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:r4.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 M1({maxHeight:V}),padding:P0.symmetric(1,0),child:F}),q=new l0({padding:P0.symmetric(1,0),child:new $0({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:P0.symmetric(1,0),child:new $0({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:X4.all(new Q4(Q.foreground,1,"solid")),color:Q.background},padding:P0.all(1),child:new d0({children:H})})}}class r11 extends u0{props;constructor(J){super();this.props=J}createState(){return new $p4}}function Jp4(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 s11 extends u1{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)=>Jp4(X.pubDate).length));return new y8({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=y0.of(G),{colors:z}=F,q=F.app,W=K?q.selectionBackground:void 0,H=K?q.selectionForeground:z.foreground,U=z.mutedForeground,D=(B,N)=>new R0({width:N,child:W1.end([new $0({text:new P(B,new g({color:U}))})])});return new l0({decoration:W?{color:W}:void 0,padding:P0.symmetric(2,0),child:new W1({children:[new c1({child:new $0({text:new P(X.title,new g({color:H})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),D(Jp4(X.pubDate),Q)]})})}})}}class vJ{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!vJ._instance)vJ._instance=new vJ;return vJ._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()}}n0();class Zp4 extends f0{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){_.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){_.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=y0.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 y8({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 U=q?Q.selectionBackground:void 0,D=q?Q.selectionForeground:Y.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new l0({decoration:U?{color:U}:void 0,padding:P0.symmetric(2,0),child:new $0({text:new P("",void 0,[new P("Create new label: ",new g({color:D})),new P(N,new g({color:D,bold:!0}))])})})}return new l0({decoration:U?{color:U}:void 0,padding:P0.symmetric(2,0),child:new $0({text:new P(z.name,new g({color:D}))})})},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,U="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(H&&!U)return-1;if(!H&&U)return 1;return q.score-z.score}})}}class t11 extends u0{props;constructor(J){super();this.props=J}createState(){return new Zp4}}class KF extends u0{props;constructor(J){super();this.props=J}createState(){return new Qp4}}class Qp4 extends f0{_spinner=new j5;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=y0.of(J),{colors:Q,app:Y}=Z,X=X4.all(new Q4(Q.foreground,1,"solid")),K=this._spinner.toBraille(),V=new $0({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 d0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[V]})})];if(this.widget.props.onAbort)F.push(new R0({height:2,child:new l0({padding:P0.symmetric(2,0),child:new $0({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 d0({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 No={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"}},IF0=["workspace","global","flag","default","external","skill","other"];function d_3(J){return Array.from(new Set(J))}function Yp4(J){return d_3([...J.skillNames??[],...J.skillName?[J.skillName]:[]])}function ty(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 Yp4(J).length>0?"skill":"other"}function e11(J){return ty(J)==="skill"}function Xp4(J){let Z=Yp4(J);if(Z.length===0)return;let Q=Z.join(", "),Y=ty(J);if(Y==="skill")return`skills: ${Q}`;return`${Z.length===1?"skill source":"skill sources"} overridden by ${No[Y].description}: ${Q}`}function Kp4(J){return J.spec.meta?.skillNames?Array.from(J.spec.meta.skillNames):[]}var Vp4=process.platform==="win32"?" ":"█",Gp4=process.platform==="win32"?"░":"█";class l9 extends u0{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X=Vp4,thumbChar:K=Gp4,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 Fp4}}class Fp4 extends f0{_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,U=Math.max(0,Math.min(q,this._dragStartOffset+H));this.widget.controller.jumpTo(U)};_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),U=H+F;if(Z>=H&&Z<=U)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?q3.POINTER:q3.DEFAULT,child:new zp4({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 zp4 extends mw{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X=Vp4,thumbChar:K=Gp4,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 qp4(this)}updateRenderObject(J){J.updateWidget(this)}}class qp4 extends D4{_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 U="█",D=!0;if(H===Math.floor(z)){let B=1-(z-H),N=Math.floor(B*8);U=W[N]||"█",D=!1}else if(H===Math.floor(q)){let B=1-(q-H),N=Math.floor(B*8);U=W[N]||"█"}else if(H>z&&H<q)D=!1;J.setChar(Z,Q+H,U,{fg:G,bg:V,reverse:D},1)}return}for(let W=0;W<this.size.height;W++){let H=W+0.5,U=H>=z&&H<q,D=U?this._widget.thumbChar:this._widget.trackChar;J.setChar(Z,Q+W,D,{fg:U?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 sU extends u0{props;constructor(J){super();this.props=J}createState(){return new Wp4}}class Wp4 extends f0{scrollController=new H5;scrollAreaKey=new c7("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 w7}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=y0.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=aV0(Q);return{title:q.title,type:q.type,description:q.description}})(),X=Y.type==="error"?Z.app.toolError:Z.app.command,K=X4.all(new Q4(Z.colors.border,1,"solid")),V=new l0({padding:P0.symmetric(1,0),child:new $0({text:new P(Y.title,new g({color:X,bold:!0}))})}),G=this.isWidgetMessage(Q)?Q.widget:new $0({text:new P(Y.description,new g({color:Z.colors.foreground})),selectable:!0}),F=new c1({child:new O2({child:new l0({padding:P0.symmetric(1,0),child:new W1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new c1({child:new u6({controller:this.scrollController,autofocus:!0,child:G})}),new l9({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let q=this.scrollController.maxScrollExtent,W=this.scrollController.offset,H=this.getViewportHeight(),U=q+H;return{totalContentHeight:Math.max(U,0),viewportHeight:Math.max(H,1),scrollOffset:Math.max(W,0)}}})]})})})}),z=new l0({padding:P0.symmetric(1,0),child:new $0({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 X5({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:P0.all(1),child:new d0({mainAxisAlignment:"center",children:[V,new R0({height:1}),F,z]})})})]})}}W9();class Hp4 extends u0{props;constructor(J){super();this.props=J}createState(){return new Up4}}class Up4 extends f0{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=M9.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=y0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new $0({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} ${S4(X,"plugin")} active`,new g({bold:!0}))),V>0||G>0)Y.push(new P(` (${V} ${S4(V,"command")}, ${G} ${S4(G,"tool")})`,new g({dim:!0})));Y.push(new P(`
5888
+ `))}if(D)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:X4.all(new Q4(G.border,1,"rounded"))},child:new $0({text:new P(void 0,void 0,W)})})}n0();W9();AE();nJ();e3();S2();cd();uX();rJ();KY();tJ();mA();c4();Vm();JC();E1();n0();rJ();class o11{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.1776284074-g53a1f8"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await $60(Z,this.configService)}catch(Z){_.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 u0{props;constructor(J){super();this.props=J}createState(){return new tm4}}class tm4 extends f0{_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 em4 extends f0{controller=new i7;focusNode=new E6({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=y0.of(J),{colors:Q,app:Y}=Z,X=this.widget.props.isRequiredArg??!0,K=this.controller.text.trim().length>0,V=!X||K,G=X4.all(new Q4(Q.foreground,1,"solid")),F=new JX({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(U)=>{let D=U.trim();if(X&&D.length===0)return;this.widget.props.onSubmit(D)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),z=new W1({children:[new l0({decoration:{color:Q.background},child:new $0({text:new P(">",new g({color:Q.foreground}))})}),new c1({child:F})]}),q=new l0({padding:P0.symmetric(1,0),child:new $0({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:P0.symmetric(1,0),child:new $0({text:new P("",void 0,W)})});return new l0({decoration:{border:G,color:Q.background},padding:P0.all(1),child:new d0({children:[q,new R0({height:1}),z,new y5,H]})})}}class Bo extends u0{props;constructor(J){super();this.props=J}createState(){return new em4}}tJ();class $p4 extends f0{controller=new i7;imageAttachments=[];imagePaths=[];isConfirmingClearInput=!1;clearInputConfirmTimeout=null;focusNode=new E6({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 iq(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=y0.of(J),{colors:Q,app:Y}=Z,K=O4.of(J).size.height,V=Math.max(Math.floor(K*0.5),10),G=new dU({controller:this.controller,triggers:[new eK],completionBuilder:this.widget.props.completionBuilder,onSubmitted:(U)=>{this.widget.props.onSubmit(U.trim(),this.imageAttachments)},theme:Q,placeholder:this.widget.props.placeholder||"Enter your message...",enabled:this.widget.props.enabled??!0,autofocus:!0,clipboard:r4.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 M1({maxHeight:V}),padding:P0.symmetric(1,0),child:F}),q=new l0({padding:P0.symmetric(1,0),child:new $0({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:P0.symmetric(1,0),child:new $0({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:X4.all(new Q4(Q.foreground,1,"solid")),color:Q.background},padding:P0.all(1),child:new d0({children:H})})}}class r11 extends u0{props;constructor(J){super();this.props=J}createState(){return new $p4}}function Jp4(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 s11 extends u1{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)=>Jp4(X.pubDate).length));return new y8({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=y0.of(G),{colors:z}=F,q=F.app,W=K?q.selectionBackground:void 0,H=K?q.selectionForeground:z.foreground,U=z.mutedForeground,D=(B,N)=>new R0({width:N,child:W1.end([new $0({text:new P(B,new g({color:U}))})])});return new l0({decoration:W?{color:W}:void 0,padding:P0.symmetric(2,0),child:new W1({children:[new c1({child:new $0({text:new P(X.title,new g({color:H})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),D(Jp4(X.pubDate),Q)]})})}})}}class vJ{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!vJ._instance)vJ._instance=new vJ;return vJ._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()}}n0();class Zp4 extends f0{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){_.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){_.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=y0.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 y8({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 U=q?Q.selectionBackground:void 0,D=q?Q.selectionForeground:Y.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new l0({decoration:U?{color:U}:void 0,padding:P0.symmetric(2,0),child:new $0({text:new P("",void 0,[new P("Create new label: ",new g({color:D})),new P(N,new g({color:D,bold:!0}))])})})}return new l0({decoration:U?{color:U}:void 0,padding:P0.symmetric(2,0),child:new $0({text:new P(z.name,new g({color:D}))})})},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,U="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(H&&!U)return-1;if(!H&&U)return 1;return q.score-z.score}})}}class t11 extends u0{props;constructor(J){super();this.props=J}createState(){return new Zp4}}class KF extends u0{props;constructor(J){super();this.props=J}createState(){return new Qp4}}class Qp4 extends f0{_spinner=new j5;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=y0.of(J),{colors:Q,app:Y}=Z,X=X4.all(new Q4(Q.foreground,1,"solid")),K=this._spinner.toBraille(),V=new $0({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 d0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[V]})})];if(this.widget.props.onAbort)F.push(new R0({height:2,child:new l0({padding:P0.symmetric(2,0),child:new $0({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 d0({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 No={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"}},IF0=["workspace","global","flag","default","external","skill","other"];function d_3(J){return Array.from(new Set(J))}function Yp4(J){return d_3([...J.skillNames??[],...J.skillName?[J.skillName]:[]])}function ty(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 Yp4(J).length>0?"skill":"other"}function e11(J){return ty(J)==="skill"}function Xp4(J){let Z=Yp4(J);if(Z.length===0)return;let Q=Z.join(", "),Y=ty(J);if(Y==="skill")return`skills: ${Q}`;return`${Z.length===1?"skill source":"skill sources"} overridden by ${No[Y].description}: ${Q}`}function Kp4(J){return J.spec.meta?.skillNames?Array.from(J.spec.meta.skillNames):[]}var Vp4=process.platform==="win32"?" ":"█",Gp4=process.platform==="win32"?"░":"█";class l9 extends u0{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X=Vp4,thumbChar:K=Gp4,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 Fp4}}class Fp4 extends f0{_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,U=Math.max(0,Math.min(q,this._dragStartOffset+H));this.widget.controller.jumpTo(U)};_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),U=H+F;if(Z>=H&&Z<=U)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?q3.POINTER:q3.DEFAULT,child:new zp4({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 zp4 extends mw{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X=Vp4,thumbChar:K=Gp4,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 qp4(this)}updateRenderObject(J){J.updateWidget(this)}}class qp4 extends D4{_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 U="█",D=!0;if(H===Math.floor(z)){let B=1-(z-H),N=Math.floor(B*8);U=W[N]||"█",D=!1}else if(H===Math.floor(q)){let B=1-(q-H),N=Math.floor(B*8);U=W[N]||"█"}else if(H>z&&H<q)D=!1;J.setChar(Z,Q+H,U,{fg:G,bg:V,reverse:D},1)}return}for(let W=0;W<this.size.height;W++){let H=W+0.5,U=H>=z&&H<q,D=U?this._widget.thumbChar:this._widget.trackChar;J.setChar(Z,Q+W,D,{fg:U?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 sU extends u0{props;constructor(J){super();this.props=J}createState(){return new Wp4}}class Wp4 extends f0{scrollController=new H5;scrollAreaKey=new c7("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 w7}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=y0.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=aV0(Q);return{title:q.title,type:q.type,description:q.description}})(),X=Y.type==="error"?Z.app.toolError:Z.app.command,K=X4.all(new Q4(Z.colors.border,1,"solid")),V=new l0({padding:P0.symmetric(1,0),child:new $0({text:new P(Y.title,new g({color:X,bold:!0}))})}),G=this.isWidgetMessage(Q)?Q.widget:new $0({text:new P(Y.description,new g({color:Z.colors.foreground})),selectable:!0}),F=new c1({child:new O2({child:new l0({padding:P0.symmetric(1,0),child:new W1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new c1({child:new u6({controller:this.scrollController,autofocus:!0,child:G})}),new l9({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let q=this.scrollController.maxScrollExtent,W=this.scrollController.offset,H=this.getViewportHeight(),U=q+H;return{totalContentHeight:Math.max(U,0),viewportHeight:Math.max(H,1),scrollOffset:Math.max(W,0)}}})]})})})}),z=new l0({padding:P0.symmetric(1,0),child:new $0({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 X5({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:P0.all(1),child:new d0({mainAxisAlignment:"center",children:[V,new R0({height:1}),F,z]})})})]})}}W9();class Hp4 extends u0{props;constructor(J){super();this.props=J}createState(){return new Up4}}class Up4 extends f0{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=M9.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=y0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new $0({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} ${S4(X,"plugin")} active`,new g({bold:!0}))),V>0||G>0)Y.push(new P(` (${V} ${S4(V,"command")}, ${G} ${S4(G,"tool")})`,new g({dim:!0})));Y.push(new P(`
5889
5889
 
5890
5890
  `));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(`
5891
5891
  `)),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(`
@@ -6101,7 +6101,7 @@ ${e.content||""}`:e.content||"",_0=[],m0=e.baseDir.startsWith("file://")?Kz0(e.b
6101
6101
  `),process.exit(1)}process.stdout.write(await My3(F.result.displayText)+`
6102
6102
  `),process.exit(0)})}dH();import{stdout as Ay3}from"node:process";function jy3({version:J,buildTimestamp:Z,buildType:Q}){let Y=Q==="dev"?"dev":"released",X=Z?new Date(Z):null,K=X&&!Number.isNaN(X.getTime())?`, ${hz(X)} ago`:"";return`${J} (${Y}${Z?` ${Z}`:""}${K})`}function El4(J){Ay3.write(`${jy3(J)}
6103
6103
  `)}function Ml4(J,Z){J.option("-V, --version","Print the version number and exit",()=>{El4(Z),process.exit(0)}),J.command("version").description("Print the version number and exit").action(()=>{El4(Z),process.exit(0)})}var cb3=rL.join(yX,"logs","headless.log"),H31=rL.join(kv,"device-id.json"),ca4=`cli-tui-${$o4(16).toString("hex")}`;async function lb3(){for(let J of _E)try{if((await J.listConfigs()).length>0)return J}catch(Z){_.debug("Failed to detect query-based IDE integration",{ideName:J.ideName,error:Z})}return}try{if(process.platform==="win32")await Promise.resolve().then(() => B4(jx(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){n$.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
6104
- `)}function ib3(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 E7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")T2("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")T2("experimental.agentMode",Z.mode)}function Yo4(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 nb3(J){try{return await Zo4(J,"utf-8")}catch{return J}}async function U31(J,Z,Q){let Y=Yo4(J,Z);if(!Y)return;let X=R6(Q)?Q.features:[],K=R6(Q)?Q.user.email:void 0;if(!VI(X,$7.HARNESS_SYSTEM_PROMPT)&&!(K&&o7(K)))throw new x1("You are not allowed to do this.",1);T2("systemPrompt",await nb3(Y))}function VI(J,Z){return J?.some((Q)=>Q.name===Z&&Q.enabled)??!1}function Xo4(J){return VI(J,$7.THREAD_ACTORS_TUI)}function D31(J){return(J.userEmail?o7(J.userEmail):!1)||Xo4(J.features)||VI(J.features,$7.DTW_TUI)}function la4(J){if(J.dtwEnabled&&!J.hasV2TUIAccess)throw new x1("This TUI mode is not enabled for your user;",1)}function B31(J,Z){if(typeof J==="boolean")return J;if(!R6(Z))return!1;return D31({userEmail:Z.user.email,features:Z.features})}function ia4(J,Z){if(typeof J==="boolean")return J;if(!R6(Z))return!1;return Xo4(Z.features)}function ab3(J){return J!=="pending"}function Rx(J){if(!R6(J))return null;return{...J.user,features:J.features??[],team:J.workspace??void 0}}function ob3(J){let Z=Rx(J);if(Z)return Z.id;if(gV(J))throw Error(J.error.message);throw Error("unreachable")}function rb3(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 sb3(J){let Y=rb3(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 x1(`Couldn't connect to the Amp server at ${J}.`,1,Y)}function Kr(J,Z){let Q=xa0(Error(J.error.message));if(Q.message===r2.networkOffline||Q.message===r2.networkTimeout)return sb3(Z);if(Q.message!==r2.internalBug)return new x1(Q.message,1,Q.suggestion);return new x1(J.error.message.replace(/^Error: /,""),1)}async function na4(J){if(!n6.write(J))await gb3(n6,"drain")}var aa4=[{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??cK,description:`Custom settings file path (overrides the default location ${cK})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(_).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${ki})`},{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:d7(),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:oF.SMART.key,description:`Set the agent mode (${hX({}).map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:hX().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:"threadActors",long:"thread-actors",type:"switch",description:"Connect to the thread-actors counter service. Optionally provide a thread ID.",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}],oa4=(J)=>("deprecated"in J)&&J.deprecated===!0,tb3=(J)=>("hidden"in J)&&J.hidden===!0,eb3=(J)=>("default"in J),$h3=(J)=>("default"in J)?J.default:void 0,Ko4=[{name:"toggle-skills-count",entryPoint:y01}];function Jh3(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 x1(r2.unknownCommand(Q),1,V)}}async function w31(J){return{...J,getThreadEnvironment:UZ,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new $G(J.fileSystem),generateThreadTitle:A90,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>eZ(J.configService),pluginService:J.pluginService}}function Vo4(J){return{toolService:J.toolService,configService:J.configService,skillService:J.skillService,getThreadEnvironment:UZ,filesystem:J.fileSystem,threadService:J.threadService}}var oz0=Y1.file(Qo4.homedir()),N31=process.env.XDG_CONFIG_HOME?Y1.file(process.env.XDG_CONFIG_HOME):K1.joinPath(oz0,".config");function Zh3(J){return XW4({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){if(KP4())VP4();else if(process.platform==="darwin"&&Z==="idle"&&J.isTUIVoiceNotifEnabled())YW4();else Vp0(Z);let Q=zK0(),Y=Rr0();if((!Q||Y||oC4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(_U("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(_U("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(zK0()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function P9(J,Z,Q){let Y=Q?.deferAuth??!1;Iu1("0.0.1776269877-gac06d1");let X=AC({storage:J.settings,secretStorage:J.secrets,workspaceRoot:k0.of(Y1.file(process.cwd())),defaultAmpURL:J.ampURL,homeDir:oz0,userConfigDir:N31});lb4(X);let K=await X.getLatest();_.debug("Global configuration initialized",{settingsKeys:Object.keys(K.settings)});let V=!1;{let m=await J.secrets.get("apiKey",J.ampURL);if(V=Boolean(m),_.info("API key lookup before login",{found:Boolean(m),ampURL:J.ampURL,deferAuth:Y}),!m)if(Y)_.info("No API key found, continuing startup with deferred auth");else{n6.write(`No API key found. Starting login flow...
6104
+ `)}function ib3(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 E7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")T2("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")T2("experimental.agentMode",Z.mode)}function Yo4(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 nb3(J){try{return await Zo4(J,"utf-8")}catch{return J}}async function U31(J,Z,Q){let Y=Yo4(J,Z);if(!Y)return;let X=R6(Q)?Q.features:[],K=R6(Q)?Q.user.email:void 0;if(!VI(X,$7.HARNESS_SYSTEM_PROMPT)&&!(K&&o7(K)))throw new x1("You are not allowed to do this.",1);T2("systemPrompt",await nb3(Y))}function VI(J,Z){return J?.some((Q)=>Q.name===Z&&Q.enabled)??!1}function Xo4(J){return VI(J,$7.THREAD_ACTORS_TUI)}function D31(J){return(J.userEmail?o7(J.userEmail):!1)||Xo4(J.features)||VI(J.features,$7.DTW_TUI)}function la4(J){if(J.dtwEnabled&&!J.hasV2TUIAccess)throw new x1("This TUI mode is not enabled for your user;",1)}function B31(J,Z){if(typeof J==="boolean")return J;if(!R6(Z))return!1;return D31({userEmail:Z.user.email,features:Z.features})}function ia4(J,Z){if(typeof J==="boolean")return J;if(!R6(Z))return!1;return Xo4(Z.features)}function ab3(J){return J!=="pending"}function Rx(J){if(!R6(J))return null;return{...J.user,features:J.features??[],team:J.workspace??void 0}}function ob3(J){let Z=Rx(J);if(Z)return Z.id;if(gV(J))throw Error(J.error.message);throw Error("unreachable")}function rb3(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 sb3(J){let Y=rb3(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 x1(`Couldn't connect to the Amp server at ${J}.`,1,Y)}function Kr(J,Z){let Q=xa0(Error(J.error.message));if(Q.message===r2.networkOffline||Q.message===r2.networkTimeout)return sb3(Z);if(Q.message!==r2.internalBug)return new x1(Q.message,1,Q.suggestion);return new x1(J.error.message.replace(/^Error: /,""),1)}async function na4(J){if(!n6.write(J))await gb3(n6,"drain")}var aa4=[{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??cK,description:`Custom settings file path (overrides the default location ${cK})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(_).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${ki})`},{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:d7(),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:oF.SMART.key,description:`Set the agent mode (${hX({}).map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:hX().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:"threadActors",long:"thread-actors",type:"switch",description:"Connect to the thread-actors counter service. Optionally provide a thread ID.",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}],oa4=(J)=>("deprecated"in J)&&J.deprecated===!0,tb3=(J)=>("hidden"in J)&&J.hidden===!0,eb3=(J)=>("default"in J),$h3=(J)=>("default"in J)?J.default:void 0,Ko4=[{name:"toggle-skills-count",entryPoint:y01}];function Jh3(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 x1(r2.unknownCommand(Q),1,V)}}async function w31(J){return{...J,getThreadEnvironment:UZ,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new $G(J.fileSystem),generateThreadTitle:A90,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>eZ(J.configService),pluginService:J.pluginService}}function Vo4(J){return{toolService:J.toolService,configService:J.configService,skillService:J.skillService,getThreadEnvironment:UZ,filesystem:J.fileSystem,threadService:J.threadService}}var oz0=Y1.file(Qo4.homedir()),N31=process.env.XDG_CONFIG_HOME?Y1.file(process.env.XDG_CONFIG_HOME):K1.joinPath(oz0,".config");function Zh3(J){return XW4({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){if(KP4())VP4();else if(process.platform==="darwin"&&Z==="idle"&&J.isTUIVoiceNotifEnabled())YW4();else Vp0(Z);let Q=zK0(),Y=Rr0();if((!Q||Y||oC4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(_U("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(_U("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(zK0()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function P9(J,Z,Q){let Y=Q?.deferAuth??!1;Iu1("0.0.1776284074-g53a1f8");let X=AC({storage:J.settings,secretStorage:J.secrets,workspaceRoot:k0.of(Y1.file(process.cwd())),defaultAmpURL:J.ampURL,homeDir:oz0,userConfigDir:N31});lb4(X);let K=await X.getLatest();_.debug("Global configuration initialized",{settingsKeys:Object.keys(K.settings)});let V=!1;{let m=await J.secrets.get("apiKey",J.ampURL);if(V=Boolean(m),_.info("API key lookup before login",{found:Boolean(m),ampURL:J.ampURL,deferAuth:Y}),!m)if(Y)_.info("No API key found, continuing startup with deferred auth");else{n6.write(`No API key found. Starting login flow...
6105
6105
  `);let h=await Qh3(J),i=await J.secrets.get("apiKey",J.ampURL);if(_.info("Login flow completed",{success:h,storedKeyPresent:Boolean(i),ampURL:J.ampURL}),!h)await MU(),process.exit(1);V=!0}}{let m=await X.getLatest(),h=m.settings.url,i=m.secrets.isSet?.[h];_.info("Config secrets state after login",{configURL:h,apiKeySet:i?.apiKey??!1})}let G=_1(eZ(X).pipe(m5(ab3))),F=Y?"pending":await G;if(!Y)_.info("Server status resolved",{status:"ready",isAuthenticated:R6(F),isError:gV(F),errorMessage:gV(F)?F.error.message:void 0});let z=G.then((m)=>ob3(m));z.catch(()=>{return});let{toolService:q,dispose:W}=gJ0({configService:X}),H=new Map,U=()=>H.clear(),D=new OT0(X,J.settings.getWorkspaceRootPath()),B=Ne1({configService:X,filesystem:I8}),N=qo1({configService:X,trustStore:D,skillMCPServers:B.skillMCPServers,createOAuthProvider:async(m,h,i)=>{let c=`${m}:${h}`,r=H.get(c);if(r)return _.debug("Reusing existing OAuth provider for server",{serverName:m,serverUrl:h}),r;_.debug("Creating OAuth provider for server",{serverName:m,serverUrl:h});let W0=(async()=>{let s=new uE(J.secrets),z0=await s.getClientInfo(m,h),L0=i?.scopes??z0?.scopes,N0=qP4();_.info("OAuth headless mode check",{useHeadless:N0,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:n6.isTTY});let Z0;if(N0)Z0=J.executeMode?zP4():FP4(m);let F0=new eR0({storage:s,serverName:m,serverUrl:h,clientId:i?.clientId??z0?.clientId,clientSecret:i?.clientSecret??z0?.clientSecret,authUrl:i?.authUrl??z0?.authUrl,tokenUrl:i?.tokenUrl??z0?.tokenUrl,scopes:L0,headlessAuthHandler:Z0});return _.debug("OAuth provider created",{serverName:m,serverUrl:h,hasManualClientId:!!(i?.clientId??z0?.clientId),willUseDCR:!(i?.clientId??z0?.clientId),scopes:L0,headlessMode:N0,executeMode:J.executeMode}),F0})();return H.set(c,W0),W0}}),w=Dm0({configService:X,filesystem:I8,spawn:VJ0}),L;if(J.executeMode){let m=await zF4({toolService:q,providers:[N,w],initialTimeout:15000});L=m.registrations;for(let[h,i]of m.initErrors)_.warn(`${h} provider initialization slow or failed:`,i)}else L=Bm0({toolService:q,providers:[N,w]});if(Z.jetbrains)IE("JetBrains");else if(Z.ide&&aP4())IE("VS Code");else if(Z.ide&&oP4())IE("Neovim");else if(Z.ide){let m=await lb3();if(m){let h=B40(m.ideName);if(h)IE(h)}}if(J.executeMode)Pu1(!0);let O,E=JJ.status.pipe(L1((m)=>Boolean(m.connected&&m.authenticated&&m.ideName&&Zb1(m.ideName))),m4()).subscribe((m)=>{if(m){if(!O)O=q.registerTool(FF4)}else O?.dispose(),O=void 0}),M;if(!J.executeMode){let m=await J.settings.get("fuzzy.alwaysIncludePaths")??[];M=new jv(process.cwd(),{alwaysIncludePaths:m},!0)}else M=new class extends jv{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};let A=new Ak0(Fm(X),{maxThreads:200});_.info("Starting Amp background services");let j=Z.takeMeBack?!1:Z.threadActors?!0:void 0,R=B31(j,F),T=new g01,C=process.env.PLUGINS??"off",b=Z.headless?_b4():void 0,p=b??new ZG0({configService:X}),x=p instanceof ZG0?p:void 0;if(x)x.pluginExecutorKind=R?"local":"unknown";let v=uT0({configService:X,fileSystem:I8,platform:p,internalPlugins:Ko4,pluginFilter:C}),f=Kr1({pluginService:v,toolService:q}),d={configService:X,toolService:q,mcpService:N,skillService:B,toolboxService:w,trustStore:D,threadService:A,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:M,fileSystem:I8,terminal:T,pluginService:v,pluginPlatform:x,headlessPluginPlatform:b,serverStatus:F,serverStatusPromise:G,viewerUserIDPromise:z,hasAPIKeyAtStartup:V};return{...d,async asyncDispose(){if(d.mcpService.hasAuthenticatingClients())_.info("Waiting for OAuth authentication to complete before exit..."),await d.mcpService.waitForAuthentication();for(let m of L.values())m.dispose();await d.mcpService.dispose(),U(),await d.threadService.asyncDispose(),d.configService.unsubscribe(),W(),d.fuzzyServer.dispose(),d.settingsStorage[Symbol.dispose](),E.unsubscribe(),O?.dispose(),f.dispose(),await d.pluginService.dispose()}}}async function Qh3(J){if(!J.executeMode){if(!await tX0("Would you like to log in to Amp? [(y)es, (n)o]: "))return n6.write(`Login cancelled. Run the command again to retry.
6106
6106
  `),!1}return await Go4(J)}async function Go4(J){let Z=$o4(32).toString("hex"),Q=await mv(J.ampURL,Z),Y=new AbortController;try{await kV(Q,Y.signal)}catch(K){_.error("Error opening browser",{error:K})}let X=await mv(J.ampURL,Z,!1);n6.write(`If your browser does not open automatically, visit:
6107
6107
 
@@ -6109,7 +6109,7 @@ ${o0.blue.bold(X)}
6109
6109
 
6110
6110
  `);try{return await VT4(J.ampURL,Z,J.secrets,Y),n6.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(K){return _.error("Login failed",{error:K}),n$.write(`
6111
6111
  Login failed: ${K instanceof Error?K.message:String(K)}
6112
- `),!1}}function ra4(J){if(!J||J.length===0)return;let Z=J.join(" ").trim();return Z.length>0?Z:void 0}async function Yh3(J){let Z={...J.agentMode?{agentMode:J.agentMode}:{},...J.repositoryURL?{repositoryURL:J.repositoryURL}:{}},Q=await fetch(`${J.ampURL}/api/durable-thread-workers`,{method:"POST",headers:{Authorization:`Bearer ${J.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(Z)});if(!Q.ok){let X=await Q.text();throw new x1(`Create request failed (${Q.status}): ${X}`,1)}let Y=await Q.json();if(!Y.threadId||!J7(Y.threadId))throw new x1("Create response did not include a valid thread ID",1);return Y.threadId}function Xh3(J){return typeof J==="object"&&J!==null&&"durableObjectId"in J&&typeof J.durableObjectId==="string"&&J.durableObjectId.length>0}async function Kh3(J){let Z=await fetch(new URL(`/threads/${J.threadID}/durable-object-id`,J.workerURL),{method:"GET",headers:{Authorization:`Bearer ${J.apiKey}`}});if(!Z.ok){let Y=await Z.text();throw new x1(`Durable object ID request failed (${Z.status}): ${Y}`,1)}let Q=await Z.json();if(!Xh3(Q))throw new x1("Durable object ID response did not include a durableObjectId",1);return Q.durableObjectId}function Vh3(J){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(J)}async function Gh3(J){let Z=await fetch(`${J.workerURL}/threads/${J.threadID}/spawn`,{method:"POST",headers:{Authorization:`Bearer ${J.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({repositoryURL:J.repositoryURL,...J.projectID?{projectID:J.projectID}:{}})});if(!Z.ok){let Q=await Z.text();throw new x1(`Spawn request failed (${Z.status}): ${Q}`,1)}}function Fh3(J){let Z=new eN().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)gj(),process.exit(0);let N=B.originalError??B;nR4(N)}),Ml4(Z,{version:"0.0.1776269877-gac06d1",buildTimestamp:"2026-04-15T16:22:21.572Z",buildType:"'release'"}),Z.addHelpText("after",lP4()),Z.configureHelp({formatHelp:iP4}),Z.command("logout").description("Log out by removing stored API key").action(async(B,N)=>{let w=N.optsWithGlobals(),L=await _3(w);await Nh3(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 _3(w);await Bh3(L,await $n(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 _3(L);await RI4(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 _3(w);await II4(L.ampURL,L.secrets),process.exit(process.exitCode??0)}),Z.command("dtw-curl [threadId] [action] [message...]",{hidden:!0}).summary("DTW helper").description("Internal: helper for DTW one-shot commands.").addHelpText("after",`
6112
+ `),!1}}function ra4(J){if(!J||J.length===0)return;let Z=J.join(" ").trim();return Z.length>0?Z:void 0}async function Yh3(J){let Z={...J.agentMode?{agentMode:J.agentMode}:{},...J.repositoryURL?{repositoryURL:J.repositoryURL}:{}},Q=await fetch(`${J.ampURL}/api/durable-thread-workers`,{method:"POST",headers:{Authorization:`Bearer ${J.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(Z)});if(!Q.ok){let X=await Q.text();throw new x1(`Create request failed (${Q.status}): ${X}`,1)}let Y=await Q.json();if(!Y.threadId||!J7(Y.threadId))throw new x1("Create response did not include a valid thread ID",1);return Y.threadId}function Xh3(J){return typeof J==="object"&&J!==null&&"durableObjectId"in J&&typeof J.durableObjectId==="string"&&J.durableObjectId.length>0}async function Kh3(J){let Z=await fetch(new URL(`/threads/${J.threadID}/durable-object-id`,J.workerURL),{method:"GET",headers:{Authorization:`Bearer ${J.apiKey}`}});if(!Z.ok){let Y=await Z.text();throw new x1(`Durable object ID request failed (${Z.status}): ${Y}`,1)}let Q=await Z.json();if(!Xh3(Q))throw new x1("Durable object ID response did not include a durableObjectId",1);return Q.durableObjectId}function Vh3(J){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(J)}async function Gh3(J){let Z=await fetch(`${J.workerURL}/threads/${J.threadID}/spawn`,{method:"POST",headers:{Authorization:`Bearer ${J.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({repositoryURL:J.repositoryURL,...J.projectID?{projectID:J.projectID}:{}})});if(!Z.ok){let Q=await Z.text();throw new x1(`Spawn request failed (${Z.status}): ${Q}`,1)}}function Fh3(J){let Z=new eN().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)gj(),process.exit(0);let N=B.originalError??B;nR4(N)}),Ml4(Z,{version:"0.0.1776284074-g53a1f8",buildTimestamp:"2026-04-15T20:18:30.508Z",buildType:"'release'"}),Z.addHelpText("after",lP4()),Z.configureHelp({formatHelp:iP4}),Z.command("logout").description("Log out by removing stored API key").action(async(B,N)=>{let w=N.optsWithGlobals(),L=await _3(w);await Nh3(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 _3(w);await Bh3(L,await $n(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 _3(L);await RI4(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 _3(w);await II4(L.ampURL,L.secrets),process.exit(process.exitCode??0)}),Z.command("dtw-curl [threadId] [action] [message...]",{hidden:!0}).summary("DTW helper").description("Internal: helper for DTW one-shot commands.").addHelpText("after",`
6113
6113
  Actions:
6114
6114
  create Create a new DTW thread and print its ID
6115
6115
  add-message <message> Send a user message and wait for message_added
@@ -6174,8 +6174,8 @@ ${M}
6174
6174
 
6175
6175
  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 zh3(J){_.info("[createDTWThreadPool] Creating DTW thread pool",{threadId:J.threadId,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL});try{let Z=new Qo({threadService:J.threadService,configService:J.configService,mcpService:J.mcpService,clientID:J.clientID,initialToolDiscovery:Promise.all([J.mcpService.initialized,J.toolboxService.initialized]).then(()=>{return}),toolService:J.toolService,skillService:J.skillService,getThreadEnvironment:UZ,osFileSystem:J.fileSystem,fileChangeTrackerStorage:new $G(J.fileSystem),ampURL:J.ampURL,useThreadActors:J.useThreadActors});if(J.threadId)await Z.switchThread(J.threadId);else await Z.createThread();return Z}catch(Z){throw _.error("[createDTWThreadPool] Failed to create DTW thread pool",{threadId:J.threadId,error:Z}),Z}}async function qh3(J){if(J.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof J.execute==="string"){let Z=(await _y()).trimEnd();return{userInput:J.execute,stdinInput:Z||null}}return{userInput:(await _y()).trimEnd(),stdinInput:null}}function Wh3(J,Z,Q){if(J.remote&&!Z)throw new x1("The -r/--remote flag requires --execute mode",1,'Use: amp --remote --execute "your message"');if(J.streamJson&&!Z)throw new x1("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(J.streamJsonInput&&!Z)throw new x1("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(J.streamJsonInput&&!J.streamJson)throw new x1("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(J.stats&&!Z)throw new x1("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(J.archive&&!Z)throw new x1("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 x1("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 x1("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"
6176
6176
  Or pipe via stdin: echo "your message" | amp --execute`)}async function rz0(J,Z,Q,Y){let X=process.hrtime.bigint(),K=(t,X0)=>{let J0=Number(process.hrtime.bigint()-X0)/1e6,D0=tO4();_.info("Startup phase",{phase:t,phaseMs:Math.round(J0),sinceMainMs:D0===null?void 0:Math.round(D0)})},{userInput:V,stdinInput:G}=await qh3(Z),F=!!Z.streamJson||!!Z.streamJsonThinking;Wh3({...Z,streamJson:F},J.executeMode,V),E7(Q,Z);let z=process.hrtime.bigint(),q=Boolean(await J.secrets.get("apiKey",J.ampURL)),W=!J.executeMode&&!Z.headless&&!Z.threadActors&&q;_.info("Interactive auth startup mode",{deferInteractiveAuth:W,hasAPIKeyAtStartup:q,executeMode:J.executeMode,headless:Boolean(Z.headless)});let H=await P9(J,Z,{deferAuth:W});K("runMainThread:createThreadDependencies",z),z=process.hrtime.bigint();let U=await w31(H);K("runMainThread:createWorkerDeps",z);let{serverStatus:D}=H;if(!W&&gV(D))throw Kr(D,J.ampURL);let B=R6(D)?D:null,N=B?.user.email,w=!!(N&&o7(N)),L=D31({userEmail:N,features:B?.features}),O=Z.takeMeBack?!1:Z.threadActors?!0:void 0,E=Z.takeMeBack?!1:Z.threadActors?!0:void 0,M=B!==null&&B31(O,B),A=B!==null&&ia4(E,B);if(!W)await U31(Q,Z,D);let j=Rx(D),R=j?.features??[],T=j?.team??null,C=JG0(Z,j);if(C instanceof Error)T3(C.message);if(B&&!ME(Z.mode,N))throw new x1(`Agent mode '${Z.mode}' is only available for Amp employees`,1);if(J.executeMode&&Z.remote)await kb4(V,G,H.configService),await H.asyncDispose(),process.exit(0);if(Z.headless){if(process.env.AMP_EXECUTOR!=="1"&&(!N||!o7(N)))throw new x1("Headless DTW mode is only available for Amp employees",1);let X0=await H.secretStorage.get("apiKey",J.ampURL);if(!X0)throw new x1("API key required for headless mode. Please run `amp login` first.",1);let J0=typeof Z.headless==="string"&&Z.headless!=="true"?Z.headless:void 0;if(J0&&!J7(J0))throw new x1(`Invalid thread ID: ${J0}`,1);let D0=J0?void 0:await Ih3({dependencies:H,visibility:C??void 0,usesThreadActors:A?!0:void 0}),U0=J0??D0?.threadId;if(!U0)throw new x1("Failed to resolve headless thread ID",1);let V0=await DP4(U0);if(V0.status==="already-running")await H.asyncDispose(),await MU(),process.exit(0);try{await YP4({ampURL:J.ampURL,apiKey:X0,workerUrl:process.env.AMP_WORKER_URL,workspaceRoot:process.cwd(),threadId:U0,ownerUserId:D0?.ownerUserId,threadVersion:D0?.threadVersion,agentMode:D0?.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,useThreadActors:A?!0:void 0})}finally{await V0.release(),await H.asyncDispose()}await MU(),process.exit(0)}let b=Z.threadId&&J7(Z.threadId)?Z.threadId:void 0,p=W?await H.serverStatusPromise:D,x=R6(p)&&VI(p.features,$7.NEO_TUI);if((x||Z.neo)&&!J.executeMode&&!Z.takeMeBack){if(Z.neo&&!x&&(!R6(p)||!o7(p.user.email)))throw new x1("--neo is only available for Amp employees",1);let t=await H.secretStorage.get("apiKey",J.ampURL);if(!t)throw new x1("API key required. Please run `amp login` first.",1);let X0=Fm(H.configService),J0=new xR(H.fuzzyServer),D0=process.cwd();await v01({ampURL:J.ampURL,apiKey:t,workerURL:process.env.AMP_WORKER_URL??U7(J.ampURL),configService:H.configService,toolService:H.toolService,skillService:H.skillService,mcpService:H.mcpService,readFileSystemDirectory:({uri:U0})=>Sw({fileSystem:H.fileSystem,workspaceRoot:D0},U0),completionBuilder:J0,listThreads:()=>X0.listThreads(),getThread:(U0)=>X0.getThread(U0)},{initialThreadID:b,openThreadPickerOnStart:Z.openThreadSwitcher});return}let f=J.executeMode?void 0:async(t)=>Vr(t,"interactive"),d={threadService:H.threadService,workerDeps:U,createThread:async(t)=>{let X0=W?await H.serverStatusPromise:D,J0=await TY0(J.settings,process.cwd(),Rx(X0),C);if(J0 instanceof Error)T3(J0.message);return $11(U,{threadMeta:J0?QF(J0):void 0,agentMode:t??Z.mode,onFirstAssistantMessage:f})},validateThreadOwnership:async(t,X0)=>{if(X0?.nonBlockingOwnershipCheck){sa4(t,H.configService,H.viewerUserIDPromise).catch((J0)=>{if(J0 instanceof x1){if(X0.onOwnershipError){X0.onOwnershipError(J0,t);return}AU(J0,t);return}_.warn("Failed to validate thread ownership in CLI, allowing to open",{error:J0})});return}try{await sa4(t,H.configService,H.viewerUserIDPromise)}catch(J0){if(J0 instanceof x1)throw J0;_.warn("Failed to validate thread ownership in CLI, allowing to open",{error:J0})}},switchThreadVisibility:C,switchThreadAgentMode:Z.mode,onFirstAssistantMessage:f,handleError:AU},m=async(t,X0)=>{try{if(t==="dtw")return zh3({ampURL:J.ampURL,configService:H.configService,threadService:H.threadService,mcpService:H.mcpService,clientID:ca4,toolboxService:H.toolboxService,toolService:H.toolService,skillService:H.skillService,fileSystem:H.fileSystem,threadId:Z.threadId,useThreadActors:X0?.useThreadActors});return Ih4(d,Z.threadId,{nonBlockingOwnershipCheck:Z.nonBlockingThreadOwnershipCheck})}catch(J0){if(J0 instanceof x1)throw J0;throw await AU(J0,Z.threadId),Error("handleError should have called process.exit()")}};if(Z.format==="jsonl")n$.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
6177
- `),await MU(),process.exit(1);let h=(async()=>{if(W){_.info("Skipping initial free tier status fetch until auth is complete");return}try{let t=await H.configService.getLatest(),X0=Ob(t),J0=await n5.getUserFreeTierStatus({},{config:H.configService,signal:AbortSignal.timeout(X0)});if(J0.ok)return _.info("User free tier status:",J0),J0.result;return}catch(t){_.error("Failed to fetch free tier status:",t);return}})(),c=!J.executeMode?new r01:null,r,W0=null;if(c)r=c,W0=(async()=>{let t=W?await H.serverStatusPromise:H.serverStatus;if(gV(t))throw Kr(t,J.ampURL);await U31(Q,Z,t);let X0=process.hrtime.bigint(),J0=B31(O,t),D0=ia4(E,t),U0=R6(t)?D31({userEmail:t.user.email,features:t.features}):!1;la4({dtwEnabled:J0,hasV2TUIAccess:U0});let V0=await m(J0?"dtw":"worker",{useThreadActors:D0?!0:void 0});if(K("runMainThread:createThreadPool",X0),c.attach(V0),V){let Q0=await _1(V0.threadHandles$);if(!Q0)throw new x1("No active thread is available yet.",1);await Q0.sendMessage({content:[{type:"text",text:V}]})}})(),W0.catch(async(t)=>{let X0=t instanceof Error?t:Error(String(t));c.setInitError(X0),await AU(t,Z.threadId)});else z=process.hrtime.bigint(),la4({dtwEnabled:M,hasV2TUIAccess:L}),r=await m(M?"dtw":"worker",{useThreadActors:A?!0:void 0}),K("runMainThread:createThreadPool",z);let s=Z.notifications!==void 0?Z.notifications:!J.executeMode,z0=B!==null&&VI(B.features,$7.TUI_VOICE_NOTIF);if(W)H.serverStatusPromise.then((t)=>{z0=R6(t)&&VI(t.features,$7.TUI_VOICE_NOTIF)}).catch((t)=>{_.debug("Failed to resolve TUI voice notification feature flag",{error:t})});z=process.hrtime.bigint();let L0=await H.configService.getLatest();if(K("runMainThread:configService.getLatest",z),z=process.hrtime.bigint(),Zh3({configService:H.configService,threadService:H.threadService,config:L0,useNotificationsForService:s,isTUIVoiceNotifEnabled:()=>z0,threadViewStates$:()=>r.threadHandles$.pipe(_4((t)=>{if(!t)return k0.of({});return F5(t.thread$,t.threadViewState$).pipe(L1(([X0,J0])=>({[X0.id]:J0})))}))}),K("runMainThread:createCliNotificationService",z),J.executeMode){LT4(H.mcpService,J.settings);let t={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},X0=await VI4({threadPool:r,...t});if(await Vr(X0,"execute"),Z.archive)await H.threadService.archive(X0,!0),await Gr(H.threadService,X0);await H.asyncDispose(),process.exit(0)}let N0=!1,Z0=!1;if(Z.jetbrains||Z.ide){await Gb1();let t=await TE({jetbrainsOnly:Z.jetbrains});if(t.length===0){if(Z.jetbrains)N0=!await H.configService.get("jetbrains.skipInstall")}else if(t.length===1){let X0=t[0];if(X0)JJ.selectConfig(X0)}else Z0=!0}z=process.hrtime.bigint();let F0=To0("0.0.1776269877-gac06d1",H.settingsStorage,{startDelayMs:3000});K("runMainThread:createUpdateService",z),z=process.hrtime.bigint();let n=new qr0(H.mcpService,J.settings.getWorkspaceRootPath());if(K("runMainThread:createMcpTrustHandler",z),V&&J.executeMode){let t=await _1(r.threadHandles$);if(!t)throw new x1("No active thread is available yet.",1);await t.sendMessage({content:[{type:"text",text:V}]})}z=process.hrtime.bigint();let a=await QG0();K("runMainThread:loadSessionState",z),_.info("Loaded session state:",a);let e={...a,launchCount:a.launchCount+1};uR((t)=>({...t,launchCount:t.launchCount+1}));try{if(z=process.hrtime.bigint(),await Gg4({history:new ba0,fuzzyServer:H.fuzzyServer,settingsStorage:H.settingsStorage,threadService:H.threadService,skillService:H.skillService,configService:H.configService,secretStorage:H.secretStorage,internalAPIClient:n5,threadPool:r,createSystemPromptDeps:async()=>Vo4(H),ideClient:JJ,mcpService:H.mcpService,toolboxService:H.toolboxService,mcpTrustHandler:n,updateService:F0,pluginPlatform:H.pluginPlatform,pluginService:H.pluginService},{initialServerStatus:H.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:H.hasAPIKeyAtStartup,ampURL:J.ampURL,startupThreadID:b,showJetBrainsInstaller:N0,showIdePickerHint:Z0,openThreadSwitcher:Z.openThreadSwitcher,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:ca4,logFile:{path:Y},sessionState:e,freeTierStatusPromise:h,workspace:T??null,features:R,isInternalUser:w,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-04-15T16:22:21.572Z"},(t)=>new G11({...t,threadPool:t.threadPool},(X0)=>new b61({...X0,threadState:X0.threadState}))),K("runMainThread:mountApp-returned",z),W0)await W0}finally{await r.dispose().catch((t)=>{_.error("Failed to dispose thread pool during shutdown",t)})}await H.asyncDispose(),K("runMainThread:dependencies.asyncDispose",X),process.exit(0)}async function _3(J){if(_.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)n$.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6178
- `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;_.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await Bo1({get:async(G)=>{if(G!==Og)return;try{let F=await Zo4(H31,"utf-8");return JSON.parse(F).installationID}catch{return}},set:async(G,F)=>{if(G!==Og)return;await Jo4(rL.dirname(H31),{recursive:!0}),await mb3(H31,JSON.stringify({installationID:F},null,2),{mode:384})}},{clientType:"cli",platform:Q30()});Cu1(Y);let X=await DX0({...J,workspaceTrust:{current:!0,changes:Ij0},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 NT4(J.mcpConfig);X=wT4(X,G)}let K=rL.dirname(X.getSettingsFilePath());QW4(kv,K);let V=await X.get("url","global");if(!V)V=e9;if(_.info("Resolved Amp URL",{ampURL:V,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!uW(V))_.info("Targeting custom Amp server",{ampURL:V});return X=qf1(X),{executeMode:Z,isTTY:Q,ampURL:V,settings:X,secrets:JK0(await $n(J,X))}}function Hh3(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 Uh3(J,Z){let Q=J.includes("--headless")||J.some((X)=>X.startsWith("--headless=")),Y=rL.resolve(Z.logFile??process.env.AMP_LOG_FILE??(Q?cb3:ki));return{logLevel:Z.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:Y}}async function Dh3(){sO4();let J=Hh3(process.argv),Z=Uh3(process.argv,J),Q=VR4(Z),Y=process.argv.includes("--no-color"),X=process.argv.includes("--color"),K=process.stdout.isTTY&&process.stderr.isTTY;if(Y||!X&&!K)o0.level=0;if(ib3(_),_.info("Starting Amp CLI.",{version:"0.0.1776269877-gac06d1",buildTimestamp:"2026-04-15T16:22:21.572Z"}),process.platform==="win32"&&ij())HC4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new x1(r2.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Fh3(Q).parseAsync(process.argv)}JW4().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await Dh3().catch(AU)});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"),n6.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6177
+ `),await MU(),process.exit(1);let h=(async()=>{if(W){_.info("Skipping initial free tier status fetch until auth is complete");return}try{let t=await H.configService.getLatest(),X0=Ob(t),J0=await n5.getUserFreeTierStatus({},{config:H.configService,signal:AbortSignal.timeout(X0)});if(J0.ok)return _.info("User free tier status:",J0),J0.result;return}catch(t){_.error("Failed to fetch free tier status:",t);return}})(),c=!J.executeMode?new r01:null,r,W0=null;if(c)r=c,W0=(async()=>{let t=W?await H.serverStatusPromise:H.serverStatus;if(gV(t))throw Kr(t,J.ampURL);await U31(Q,Z,t);let X0=process.hrtime.bigint(),J0=B31(O,t),D0=ia4(E,t),U0=R6(t)?D31({userEmail:t.user.email,features:t.features}):!1;la4({dtwEnabled:J0,hasV2TUIAccess:U0});let V0=await m(J0?"dtw":"worker",{useThreadActors:D0?!0:void 0});if(K("runMainThread:createThreadPool",X0),c.attach(V0),V){let Q0=await _1(V0.threadHandles$);if(!Q0)throw new x1("No active thread is available yet.",1);await Q0.sendMessage({content:[{type:"text",text:V}]})}})(),W0.catch(async(t)=>{let X0=t instanceof Error?t:Error(String(t));c.setInitError(X0),await AU(t,Z.threadId)});else z=process.hrtime.bigint(),la4({dtwEnabled:M,hasV2TUIAccess:L}),r=await m(M?"dtw":"worker",{useThreadActors:A?!0:void 0}),K("runMainThread:createThreadPool",z);let s=Z.notifications!==void 0?Z.notifications:!J.executeMode,z0=B!==null&&VI(B.features,$7.TUI_VOICE_NOTIF);if(W)H.serverStatusPromise.then((t)=>{z0=R6(t)&&VI(t.features,$7.TUI_VOICE_NOTIF)}).catch((t)=>{_.debug("Failed to resolve TUI voice notification feature flag",{error:t})});z=process.hrtime.bigint();let L0=await H.configService.getLatest();if(K("runMainThread:configService.getLatest",z),z=process.hrtime.bigint(),Zh3({configService:H.configService,threadService:H.threadService,config:L0,useNotificationsForService:s,isTUIVoiceNotifEnabled:()=>z0,threadViewStates$:()=>r.threadHandles$.pipe(_4((t)=>{if(!t)return k0.of({});return F5(t.thread$,t.threadViewState$).pipe(L1(([X0,J0])=>({[X0.id]:J0})))}))}),K("runMainThread:createCliNotificationService",z),J.executeMode){LT4(H.mcpService,J.settings);let t={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},X0=await VI4({threadPool:r,...t});if(await Vr(X0,"execute"),Z.archive)await H.threadService.archive(X0,!0),await Gr(H.threadService,X0);await H.asyncDispose(),process.exit(0)}let N0=!1,Z0=!1;if(Z.jetbrains||Z.ide){await Gb1();let t=await TE({jetbrainsOnly:Z.jetbrains});if(t.length===0){if(Z.jetbrains)N0=!await H.configService.get("jetbrains.skipInstall")}else if(t.length===1){let X0=t[0];if(X0)JJ.selectConfig(X0)}else Z0=!0}z=process.hrtime.bigint();let F0=To0("0.0.1776284074-g53a1f8",H.settingsStorage,{startDelayMs:3000});K("runMainThread:createUpdateService",z),z=process.hrtime.bigint();let n=new qr0(H.mcpService,J.settings.getWorkspaceRootPath());if(K("runMainThread:createMcpTrustHandler",z),V&&J.executeMode){let t=await _1(r.threadHandles$);if(!t)throw new x1("No active thread is available yet.",1);await t.sendMessage({content:[{type:"text",text:V}]})}z=process.hrtime.bigint();let a=await QG0();K("runMainThread:loadSessionState",z),_.info("Loaded session state:",a);let e={...a,launchCount:a.launchCount+1};uR((t)=>({...t,launchCount:t.launchCount+1}));try{if(z=process.hrtime.bigint(),await Gg4({history:new ba0,fuzzyServer:H.fuzzyServer,settingsStorage:H.settingsStorage,threadService:H.threadService,skillService:H.skillService,configService:H.configService,secretStorage:H.secretStorage,internalAPIClient:n5,threadPool:r,createSystemPromptDeps:async()=>Vo4(H),ideClient:JJ,mcpService:H.mcpService,toolboxService:H.toolboxService,mcpTrustHandler:n,updateService:F0,pluginPlatform:H.pluginPlatform,pluginService:H.pluginService},{initialServerStatus:H.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:H.hasAPIKeyAtStartup,ampURL:J.ampURL,startupThreadID:b,showJetBrainsInstaller:N0,showIdePickerHint:Z0,openThreadSwitcher:Z.openThreadSwitcher,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:ca4,logFile:{path:Y},sessionState:e,freeTierStatusPromise:h,workspace:T??null,features:R,isInternalUser:w,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-04-15T20:18:30.508Z"},(t)=>new G11({...t,threadPool:t.threadPool},(X0)=>new b61({...X0,threadState:X0.threadState}))),K("runMainThread:mountApp-returned",z),W0)await W0}finally{await r.dispose().catch((t)=>{_.error("Failed to dispose thread pool during shutdown",t)})}await H.asyncDispose(),K("runMainThread:dependencies.asyncDispose",X),process.exit(0)}async function _3(J){if(_.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)n$.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6178
+ `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;_.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await Bo1({get:async(G)=>{if(G!==Og)return;try{let F=await Zo4(H31,"utf-8");return JSON.parse(F).installationID}catch{return}},set:async(G,F)=>{if(G!==Og)return;await Jo4(rL.dirname(H31),{recursive:!0}),await mb3(H31,JSON.stringify({installationID:F},null,2),{mode:384})}},{clientType:"cli",platform:Q30()});Cu1(Y);let X=await DX0({...J,workspaceTrust:{current:!0,changes:Ij0},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 NT4(J.mcpConfig);X=wT4(X,G)}let K=rL.dirname(X.getSettingsFilePath());QW4(kv,K);let V=await X.get("url","global");if(!V)V=e9;if(_.info("Resolved Amp URL",{ampURL:V,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!uW(V))_.info("Targeting custom Amp server",{ampURL:V});return X=qf1(X),{executeMode:Z,isTTY:Q,ampURL:V,settings:X,secrets:JK0(await $n(J,X))}}function Hh3(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 Uh3(J,Z){let Q=J.includes("--headless")||J.some((X)=>X.startsWith("--headless=")),Y=rL.resolve(Z.logFile??process.env.AMP_LOG_FILE??(Q?cb3:ki));return{logLevel:Z.logLevel??process.env.AMP_LOG_LEVEL??"info",logFile:Y}}async function Dh3(){sO4();let J=Hh3(process.argv),Z=Uh3(process.argv,J),Q=VR4(Z),Y=process.argv.includes("--no-color"),X=process.argv.includes("--color"),K=process.stdout.isTTY&&process.stderr.isTTY;if(Y||!X&&!K)o0.level=0;if(ib3(_),_.info("Starting Amp CLI.",{version:"0.0.1776284074-g53a1f8",buildTimestamp:"2026-04-15T20:18:30.508Z"}),process.platform==="win32"&&ij())HC4();if(parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new x1(r2.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Fh3(Q).parseAsync(process.argv)}JW4().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await Dh3().catch(AU)});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"),n6.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6179
6179
  `);else if(!uW(J.ampURL))n6.write(`Logging in to ${new URL(J.ampURL).hostname}
6180
6180
  `);let Y=process.env.AMP_API_KEY;if(Y)n6.write(`API key found in environment variable, storing...
6181
6181
  `),await Z.set("apiKey",Y,J.ampURL),n6.write(`API key successfully stored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1776269877-gac06d1",
3
+ "version": "0.0.1776284074-g53a1f8",
4
4
  "description": "CLI for Amp, the frontier coding agent.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {