@sourcegraph/amp 0.0.1771286655-gbfdeba → 0.0.1771302820-ga4c3d4

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 +10 -10
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -7601,11 +7601,11 @@ ${U}`))}},error:(z)=>{if(!F)F=!0,q(Error(`Failed to spawn brew: ${z.message}`))}
7601
7601
  ${U}`;if(X==="pnpm"&&U.includes("Unable to find the global bin directory"))D+=`
7602
7602
 
7603
7603
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
7604
- npm install -g @sourcegraph/amp`;q(Error(D))}},error:(z)=>{if(!H)H=!0,q(Error(`Failed to spawn ${X}: ${z.message}`))},complete:()=>{if(!H)H=!0,K()}})})}p1();p1();vj();async function B91(J,Q){let Y=Q||"https://registry.npmjs.org",X=new AbortController,V=setTimeout(()=>X.abort(),5000);try{let K=await fetch(`${Y}/@sourcegraph/amp`,{signal:X.signal});if(!K.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=await K.json(),G=q["dist-tags"]?.latest;if(!G)return{hasUpdate:!1,currentVersion:J,source:"npm"};let W=bZ6(J,G),H=W<0,F,z;if(q.time){let U=q.time[J],D=q.time[G],B=Date.now();if(U)F=Math.floor((B-new Date(U).getTime())/3600000);if(D)z=Math.floor((B-new Date(D).getTime())/3600000)}return T.info("NPM version comparison",{currentVersion:J,latestVersion:G,compareResult:W,hasUpdate:H,currentVersionAge:F,latestVersionAge:z}),{hasUpdate:H,latestVersion:G,currentVersion:J,currentVersionAge:F,latestVersionAge:z,source:"npm"}}catch(K){return T.debug("Error checking npm version",{error:K}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var $z8="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function N91(J){let Q=new AbortController,Z=setTimeout(()=>Q.abort(),5000);try{let Y=await fetch(`${$z8}?t=${Date.now()}`,{signal:Q.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 V=bZ6(J,X),K=V<0;return T.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:V,hasUpdate:K}),{hasUpdate:K,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return T.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Z)}}var Vz8=604800000;function vZ6(J){if(!J)return null;let Q=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Q))return null;let Z=Date.now()-Q;if(Z>Vz8)return{ageMs:Z};return null}function bZ6(J,Q){let Z=(K)=>{let[q,G]=K.split("-");return{parts:q?.split(".").map(Number)||[],label:G}},Y=Z(J),X=Z(Q),V=Math.max(Y.parts.length,X.parts.length);for(let K=0;K<V;K++){let q=Y.parts[K]||0,G=X.parts[K]||0;if(q<G)return-1;if(q>G)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 Yx1(J){try{let Q=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Q)return null;let Z=parseInt(Q[1],10)*1000,Y=Q[2],X=Z!==0?gF(Z):void 0;return{sha:Y,age:X}}catch{return null}}F0();function w91(J,Q){let Z=new w6,Y=Z.pipe(k4({shouldCountRefs:!1}));return setImmediate(async()=>{let X=new oV().scoped("update"),V=Y.subscribe({next:(K)=>{X.debug("emit new state",K)}});try{let K=process.env.AMP_TEST_UPDATE_STATUS;if(K){X.debug("using fake update status for testing",{status:K}),await PL(500),Z.next(K);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){X.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let q=await Q.get("updates.mode");if(q==="disabled"){X.debug("checking disabled");return}let G=await D91(),W=G==="binary"||G==="brew";X.debug("checking",{currentVersion:J,mode:q,packageManager:G,isBinaryDistribution:W});let H=W?await N91(J):await B91(J,QO());if(!(H.latestVersion&&H.hasUpdate)){X.debug("no update available");return}let F=()=>{if(H.currentVersionAge!==void 0&&H.latestVersionAge!==void 0){let z=H.currentVersionAge-H.latestVersionAge,U=0.5;if(Math.abs(z)<0.5)return X.debug("versions too close together, suppressing update warning",{currentVersionAge:H.currentVersionAge,latestVersionAge:H.latestVersionAge,ageDifferenceHours:z}),!0}return!1};if(!q)q=G==="pnpm"?"warn":"auto",X.debug("no configured update mode; selected default based on package manager",{packageManager:G,mode:q});if(G==="brew"){if(!F())Z.next("update-available-brew");return}if(G==="binary"&&process.execPath!==sy1()){if(X.debug("non-standard binary path, showing warning"),!F())Z.next("update-available-unrecognized-path");return}if(q==="warn"){if(!F())Z.next("update-available");return}if(!G){if(X.debug("auto-update not supported, falling back to warn mode"),!F())Z.next("update-available");return}if(G==="binary"&&process.platform==="win32"){if(X.debug("binary auto-update not supported on Windows, falling back to warn mode"),!F())Z.next("update-available");return}try{await iu(H.latestVersion,G);let z=await PU(H.latestVersion),U={from:H.currentVersion,to:H.latestVersion,...z};if(z.status==="same")X.info("success",U),Z.next("updated");else X.warn("success with warning",U),Z.next("updated-with-warning")}catch(z){Z.next("update-error")}}catch(K){X.debug("check failed",{error:K})}finally{await PL(5000),Z.next("hidden"),V.unsubscribe(),Z.complete()}}),{state:Y}}vj();import{stderr as Bq}from"node:process";function fZ6(J){let Q=new qU().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 ny1(Y.force||!1,Y.verbose||!1,"0.0.1771286655-gbfdeba"),process.exit()});J.addCommand(Q,{hidden:!0});let Z=new qU("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--target-version <version>","Update to a specific version").allowUnknownOption(!1).action(async(Y)=>{await Kz8(Y.targetVersion)});J.addCommand(Z)}async function Kz8(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")Bq.write(Z0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
7604
+ npm install -g @sourcegraph/amp`;q(Error(D))}},error:(z)=>{if(!H)H=!0,q(Error(`Failed to spawn ${X}: ${z.message}`))},complete:()=>{if(!H)H=!0,K()}})})}p1();p1();vj();async function B91(J,Q){let Y=Q||"https://registry.npmjs.org",X=new AbortController,V=setTimeout(()=>X.abort(),5000);try{let K=await fetch(`${Y}/@sourcegraph/amp`,{signal:X.signal});if(!K.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let q=await K.json(),G=q["dist-tags"]?.latest;if(!G)return{hasUpdate:!1,currentVersion:J,source:"npm"};let W=bZ6(J,G),H=W<0,F,z;if(q.time){let U=q.time[J],D=q.time[G],B=Date.now();if(U)F=Math.floor((B-new Date(U).getTime())/3600000);if(D)z=Math.floor((B-new Date(D).getTime())/3600000)}return T.info("NPM version comparison",{currentVersion:J,latestVersion:G,compareResult:W,hasUpdate:H,currentVersionAge:F,latestVersionAge:z}),{hasUpdate:H,latestVersion:G,currentVersion:J,currentVersionAge:F,latestVersionAge:z,source:"npm"}}catch(K){return T.debug("Error checking npm version",{error:K}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(V)}}var $z8="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function N91(J){let Q=new AbortController,Z=setTimeout(()=>Q.abort(),5000);try{let Y=await fetch(`${$z8}?t=${Date.now()}`,{signal:Q.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 V=bZ6(J,X),K=V<0;return T.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:V,hasUpdate:K}),{hasUpdate:K,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return T.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Z)}}var Vz8=604800000;function vZ6(J){if(!J)return null;let Q=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Q))return null;let Z=Date.now()-Q;if(Z>Vz8)return{ageMs:Z};return null}function bZ6(J,Q){let Z=(K)=>{let[q,G]=K.split("-");return{parts:q?.split(".").map(Number)||[],label:G}},Y=Z(J),X=Z(Q),V=Math.max(Y.parts.length,X.parts.length);for(let K=0;K<V;K++){let q=Y.parts[K]||0,G=X.parts[K]||0;if(q<G)return-1;if(q>G)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 Yx1(J){try{let Q=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Q)return null;let Z=parseInt(Q[1],10)*1000,Y=Q[2],X=Z!==0?gF(Z):void 0;return{sha:Y,age:X}}catch{return null}}F0();function w91(J,Q){let Z=new w6,Y=Z.pipe(k4({shouldCountRefs:!1}));return setImmediate(async()=>{let X=new oV().scoped("update"),V=Y.subscribe({next:(K)=>{X.debug("emit new state",K)}});try{let K=process.env.AMP_TEST_UPDATE_STATUS;if(K){X.debug("using fake update status for testing",{status:K}),await PL(500),Z.next(K);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){X.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let q=await Q.get("updates.mode");if(q==="disabled"){X.debug("checking disabled");return}let G=await D91(),W=G==="binary"||G==="brew";X.debug("checking",{currentVersion:J,mode:q,packageManager:G,isBinaryDistribution:W});let H=W?await N91(J):await B91(J,QO());if(!(H.latestVersion&&H.hasUpdate)){X.debug("no update available");return}let F=()=>{if(H.currentVersionAge!==void 0&&H.latestVersionAge!==void 0){let z=H.currentVersionAge-H.latestVersionAge,U=0.5;if(Math.abs(z)<0.5)return X.debug("versions too close together, suppressing update warning",{currentVersionAge:H.currentVersionAge,latestVersionAge:H.latestVersionAge,ageDifferenceHours:z}),!0}return!1};if(!q)q=G==="pnpm"?"warn":"auto",X.debug("no configured update mode; selected default based on package manager",{packageManager:G,mode:q});if(G==="brew"){if(!F())Z.next("update-available-brew");return}if(G==="binary"&&process.execPath!==sy1()){if(X.debug("non-standard binary path, showing warning"),!F())Z.next("update-available-unrecognized-path");return}if(q==="warn"){if(!F())Z.next("update-available");return}if(!G){if(X.debug("auto-update not supported, falling back to warn mode"),!F())Z.next("update-available");return}if(G==="binary"&&process.platform==="win32"){if(X.debug("binary auto-update not supported on Windows, falling back to warn mode"),!F())Z.next("update-available");return}try{await iu(H.latestVersion,G);let z=await PU(H.latestVersion),U={from:H.currentVersion,to:H.latestVersion,...z};if(z.status==="same")X.info("success",U),Z.next("updated");else X.warn("success with warning",U),Z.next("updated-with-warning")}catch(z){Z.next("update-error")}}catch(K){X.debug("check failed",{error:K})}finally{await PL(5000),Z.next("hidden"),V.unsubscribe(),Z.complete()}}),{state:Y}}vj();import{stderr as Bq}from"node:process";function fZ6(J){let Q=new qU().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 ny1(Y.force||!1,Y.verbose||!1,"0.0.1771302820-ga4c3d4"),process.exit()});J.addCommand(Q,{hidden:!0});let Z=new qU("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--target-version <version>","Update to a specific version").allowUnknownOption(!1).action(async(Y)=>{await Kz8(Y.targetVersion)});J.addCommand(Z)}async function Kz8(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")Bq.write(Z0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
7605
7605
 
7606
7606
  `));try{if(!J){Bq.write(Z0.blue(`Checking for updates...
7607
- `));let{hasUpdate:Y,latestVersion:X}=ay1()?await N91("0.0.1771286655-gbfdeba"):await B91("0.0.1771286655-gbfdeba",QO());if(!Y){let V=Yx1("0.0.1771286655-gbfdeba"),K=V?.age?`released ${V.age} ago`:`built ${gF(new Date("2026-02-17T00:09:39.809Z"))} ago`;Bq.write(Z0.green(`✓ Amp is already up to date on version ${"0.0.1771286655-gbfdeba"} (${K})
7608
- `));let q=await PU("0.0.1771286655-gbfdeba");if(q.warning)Bq.write(`
7607
+ `));let{hasUpdate:Y,latestVersion:X}=ay1()?await N91("0.0.1771302820-ga4c3d4"):await B91("0.0.1771302820-ga4c3d4",QO());if(!Y){let V=Yx1("0.0.1771302820-ga4c3d4"),K=V?.age?`released ${V.age} ago`:`built ${gF(new Date("2026-02-17T04:39:22.928Z"))} ago`;Bq.write(Z0.green(`✓ Amp is already up to date on version ${"0.0.1771302820-ga4c3d4"} (${K})
7608
+ `));let q=await PU("0.0.1771302820-ga4c3d4");if(q.warning)Bq.write(`
7609
7609
  `+Z0.yellow(q.warning)+`
7610
7610
  `);process.exit(0)}if(!X)Bq.write(Z0.yellow("[WARN] could not find latest version")),process.exit(0);J=X}Bq.write(Z0.blue(`Updating to version ${J}...
7611
7611
  `)),await iu(J,void 0,(Y)=>{Bq.write(Z0.dim(`Running: ${Y}
@@ -8515,7 +8515,7 @@ Ctrl-X, Y, Z to unlock`;if(z){let x=W.text.replace(/`([^`]+)`/g,"$1")+`
8515
8515
  `),new k("Ctrl+O",D),new k(" for ",N),new k("help",B),new k(`
8516
8516
 
8517
8517
 
8518
- `,N)])}),R];if(!G&&!z&&W.url){let _=W.url.replace(/^https?:\/\//,"");P.push(new e4({uri:W.url,text:_,style:new g({color:Z.secondary,underline:!0})}))}if(A&&!z)P.push(A);let C=new I1({width:50,child:new b1({crossAxisAlignment:"start",mainAxisSize:"min",children:P})});return s0.child(new K0({mainAxisAlignment:"center",crossAxisAlignment:"center",mainAxisSize:"min",children:[new Nv1({width:uu1,height:gu1,agentMode:this.widget.agentMode,glow:this._glow,backgroundColor:Z.background,t:H,fps:0,shockwaves:this._shockwaves,onShockwave:O,...K==="disabled"&&{seed:42}}),new I1({width:2}),C]}))}}class mu1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new FU6}}class FU6 extends n1{build(J){let Z=h1.of(J).colors,{todos:Y,title:X="TODOs"}=this.widget.props;if(!Array.isArray(Y)||Y.length===0)return new I1({width:0,height:0});let V=Y.map((K)=>this.buildTodoItem(K,Z));return new c1({child:new a1({padding:C1.symmetric(1,0),child:new b1({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new Q1({text:new k(X,new g({bold:!0,color:Z.foreground}))}),...V]})})})}buildTodoItem(J,Q){let Z=this.getStatusIcon(J.status),Y=J.status==="completed",X=new g({bold:J.status==="in-progress",color:Q.foreground,dim:Y}),V=new g({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Q.foreground,dim:Y});return new K0({crossAxisAlignment:"start",children:[new Q1({text:new k(Z,X)}),new I1({width:1}),new I0({child:new Q1({text:new k(J.content,V)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class pu1 extends o1{ad;onDismiss;onButtonClick;onImpression;onAdInfoClick;constructor({key:J,ad:Q,onDismiss:Z,onButtonClick:Y,onImpression:X,onAdInfoClick:V}){super({key:J});this.ad=Q,this.onDismiss=Z,this.onButtonClick=Y,this.onImpression=X,this.onAdInfoClick=V}createState(){return new zU6}}class zU6 extends n1{lastTrackedAdId=null;initState(){super.initState(),this.fireImpressionIfNeeded()}didUpdateWidget(J){super.didUpdateWidget(J),this.fireImpressionIfNeeded()}fireImpressionIfNeeded(){let J=this.widget.ad;if(J.id!==this.lastTrackedAdId)this.lastTrackedAdId=J.id,this.widget.onImpression?.(J)}build(J){let Q=h1.of(J),Z=Q.colors.primary,Y=Q.colors.foreground,X=Q.colors.background,V=this.widget.ad;return new c1({decoration:new T6(X,new c0(new u0(Z,1,"rounded"),new u0(Z,1,"rounded"),void 0,new u0(Z,1,"rounded"))),child:new a1({padding:C1.horizontal(1),child:new b1({children:[new K0({crossAxisAlignment:"start",children:[new I0({child:new Q1({text:new k(V.content,new g({color:Y}))})}),new I1({width:4}),new o0({onClick:()=>this.widget.onAdInfoClick?.(),cursor:"pointer",child:new Q1({text:new k("Ad",new g({color:Y,dim:!0}))})})]}),new K0({crossAxisAlignment:"start",children:[new Tg({text:V.buttonLabel,onPressed:()=>this.widget.onButtonClick?.(),padding:C1.horizontal(1),color:Z,reverse:!0}),new I1({width:2}),new Q1({text:new k(V.destinationUrlHostname,new g({color:Y,dim:!0}))})]})]})})})}}class du1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new UU6(this.props.autofocus??!0)}}class UU6 extends n1{autofocus;constructor(J){super();this.autofocus=J}build(J){let Z=k0.of(J).colorScheme,Y=(W)=>{if(W.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(W.ctrlKey&&W.key==="c"||W.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},X=Y6.sizeOf(J),V=Math.min(60,X.width-4),K=X.height-4,q=[];if(this.widget.props.title)q.push(new Q1({text:new k(this.widget.props.title,new g({bold:!0,color:Z.primary}))}),new I1({height:1}));if(this.widget.props.message)q.push(new Q1({text:new k(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)q.push(new I1({height:1}));let G=[];if(this.widget.props.showCopyOption)G.push(new Q1({text:new k("Enter to copy",new g({dim:!0}))}));return G.push(new Q1({text:new k("Escape to close",new g({dim:!0}))})),q.push(new K0({children:G.flatMap((W,H)=>H<G.length-1?[W,new I1({width:1}),new Q1({text:new k("•",new g({dim:!0}))}),new I1({width:1})]:[W]),mainAxisSize:"min"})),new s0({child:new c1({constraints:new A0(V,V,0,K),decoration:new T6(Z.background,new c0(new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"))),padding:new C1(2,2,2,2),child:new b6({autofocus:this.autofocus,onKey:Y,child:new b1({children:q,mainAxisSize:"min"})})})})}}class cu1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new DU6(this.props.autofocus??!0)}}class DU6 extends n1{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=k0.of(J).colorScheme,Z=(q)=>{if(q.key==="Enter"||q.key==="Escape"||q.ctrlKey&&q.key==="c")return this.widget.props.onClose(),"handled";return"ignored"},Y=Y6.sizeOf(J),X=Math.min(60,Y.width-4),V=Y.height-4,K=[];if(K.push(new Q1({text:new k("Ads make Amp Free possible",new g({bold:!0}))})),this.widget.props.provider)K.push(new I1({height:1}),new Q1({text:new k(`Ad source: ${this.widget.props.provider}`,new g({dim:!0}))}));return K.push(new I1({height:1}),new Q1({text:new k("Escape to close",new g({dim:!0}))})),new s0({child:new c1({constraints:new A0(X,X,0,V),decoration:new T6(Q.background,new c0(new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"))),padding:new C1(2,2,2,2),child:new b6({autofocus:this.autofocus,onKey:Z,child:new b1({children:K,mainAxisSize:"min"})})})})}}p1();import{execSync as Jx8}from"node:child_process";iT1();YQ();p9();l3();YN();U$();NJ();NZ();z$();JI();c6();xh();kS();F0();var GD6=D6(nG(),1);import{writeFile as XD6}from"fs/promises";import $D6 from"path";p1();NJ();class lu1{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Q){this.enabled=J;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Q,Z])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1771286655-gbfdeba"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await Hs(Q,this.configService)}catch(Q){T.error("Failed to export command telemetry events",Q)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(J)||0;this.commandCounts.set(J,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class UD extends o1{props;constructor(J){super();this.props=J}createState(){return new BU6}}class BU6 extends n1{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Q=(Z)=>{this.setState(()=>{this._state=Z(this._state)})};return this.widget.props.builder(J,Q,this._state)}}class NU6 extends n1{controller=new a2;focusNode=new V4({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 Q=h1.of(J),{colors:Z,app:Y}=Q,X=this.widget.props.isRequiredArg??!0,V=this.controller.text.trim().length>0,K=!X||V,q=c0.all(new u0(Z.foreground,1,"solid")),G=new YY({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:Z.foreground,border:null},maxLines:1}),W=new K0({children:[new c1({decoration:{color:Z.background},child:new Q1({text:new k(">",new g({color:Z.foreground}))})}),new I0({child:G})]}),H=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("",void 0,[new k("Command: ",new g({color:Z.foreground})),new k(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),F=[];if(K)F.push(new k("Enter",new g({color:Y.keybind}))),F.push(new k(" to submit, ",new g({color:Z.foreground,dim:!0})));F.push(new k("Esc",new g({color:Y.keybind}))),F.push(new k(" to cancel",new g({color:Z.foreground,dim:!0})));let z=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("",void 0,F)})});return new c1({decoration:{border:q,color:Z.background},padding:C1.all(1),child:new b1({children:[H,new I1({height:1}),W,new x9,z]})})}}class pm extends o1{props;constructor(J){super();this.props=J}createState(){return new NU6}}import{isDeepStrictEqual as Ty8}from"node:util";var Py8=/[\\/_ +.#"@[({&]/,Iy8=/[\\/_ +.#"@[({&]/g,Cy8=/[\s-]/,wU6=/[\s-]/g;function o31(J,Q,Z,Y,X,V,K){if(V===Q.length){if(X===J.length)return 1;return 0.99}let q=`${X},${V}`;if(K[q]!==void 0)return K[q];let G=Y.charAt(V),W=Z.indexOf(G,X),H=0,F,z,U,D;while(W>=0){if(F=o31(J,Q,Z,Y,W+1,V+1,K),F>H){if(W===X)F*=1;else if(Cy8.test(J.charAt(W-1))){if(F*=0.9,D=J.slice(X,W-1).match(wU6),D&&X>0)F*=0.999**D.length}else if(Py8.test(J.charAt(W-1))){if(F*=0.8,U=J.slice(X,W-1).match(Iy8),U&&X>0)F*=0.999**U.length}else if(F*=0.3,X>0)F*=0.999**(W-X);if(J.charAt(W)!==Q.charAt(V))F*=0.9999}if(F<0.1&&(Z.charAt(W-1)===Y.charAt(V+1)||Y.charAt(V+1)===Y.charAt(V)&&Z.charAt(W-1)!==Y.charAt(V))){if(z=o31(J,Q,Z,Y,W+1,V+2,K),z*0.1>F)F=z*0.1}if(F>H)H=F;W=Z.indexOf(G,W+1)}return K[q]=H,H}function a31(J){return J.toLowerCase().replace(wU6," ")}function LU6(J,Q){let Z=o31(J,Q,a31(J),a31(Q),0,0,{}),Y=Q.trim().split(/\s+/);if(Y.length>1){let X=0,V=0;for(let q of Y){let G=o31(J,q,a31(J),a31(q),0,0,{});if(G===0)return Z;X+=G,V+=q.length}let K=X/Y.length*0.95;return Math.max(Z,K)}return Z}class YT{}class XT{}class r31{}class s31{}class OU6 extends o1{child;onContext;constructor(J,Q){super();this.child=J;this.onContext=Q}createState(){return new MU6}}class MU6 extends n1{build(J){return this.widget.onContext(J),this.widget.child}}function _y8(J,Q){if(J==="")return{matches:!0,score:1};let Z=LU6(Q,J);return{matches:Z>0.15,score:Z}}class h7 extends o1{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new AU6}}class AU6 extends n1{controller=new a2;focusNode;scrollController=new a4;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){this.scrollController.disableFollowMode(),this.focusNode=new V4({debugLabel:this.widget.debugLabel}),this.controller.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let Q=this.cachedFiltered;this.widget.props.onSelectionChange?.(Q[0]??null)}),this.recomputeFilteredItems();let J=this.cachedFiltered;this.widget.props.onSelectionChange?.(J[0]??null),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!Ty8(J.props.items,this.widget.props.items)){this.recomputeFilteredItems(),this.ensureSelectedItemVisible();let Q=this.cachedFiltered;this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null)}}dispose(){this.widget.props.onSelectionChange?.(null),this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof YT){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof XT){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof r31){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length){let Z=Q[this.selectedIndex];if(Z){if(!(this.widget.props.isItemDisabled?.(Z)??!1))this.widget.props.onAccept(Z,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof s31)return this.widget.props.onDismiss?.(),"handled";return"ignored"};recomputeFilteredItems(){let J=this.controller.text,Q=this.widget.props.items,Z=this.widget.props.normalizeQuery?.(J)??J,Y=Q.filter((X)=>!this.widget.props.filterItem||this.widget.props.filterItem(X,J)).map((X)=>({item:X,..._y8(Z,this.widget.props.getLabel(X))})).filter((X)=>X.matches).sort(this.widget.props.sortItems?(X,V)=>this.widget.props.sortItems(X,V,J):(X,V)=>V.score-X.score).map((X)=>X.item);this.cachedQuery=J,this.cachedItemsRef=Q,this.cachedFiltered=this.widget.props.maxRenderItems?Y.slice(0,this.widget.props.maxRenderItems):Y}getFilteredItems(){let J=this.controller.text,Q=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Q)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Q=J.findRenderObject();if(!Q)return;let Z=0,Y=Q.size.height;MC(J,{top:Z,bottom:Y},{padding:1})}handleScroll=(J)=>{let Q=this.getFilteredItems();if(Q.length===0)return!1;let Z=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Q.length-1)this.hasUserInteracted=!0,this.selectedIndex++;else return!1;else if(this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--;else return!1;return this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null),this.selectedIndex!==Z};handleItemClick=(J,Q)=>{let Z=this.getFilteredItems();if(J>=0&&J<Z.length){let Y=Z[J],X=Y?this.widget.props.isItemDisabled?.(Y)??!1:!1;if(Q===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.widget.props.onSelectionChange?.(Z[this.selectedIndex]??null);else if(Q===2&&!X){if(Y)this.hasUserInteracted=!0,this.widget.props.onAccept(Y,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Q=h1.of(J),{colors:Z}=Q,Y=this.getFilteredItems(),X=c0.all(new u0(Z.foreground,1,"solid")),V=this.widget.props.enabled??!0,K=new YY({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:V,style:{backgroundColor:Z.background,textColor:Z.foreground,cursorColor:Z.cursor,placeholderColor:Z.mutedForeground,border:null},maxLines:1}),q=new H2({shortcuts:new Map([[new r0("ArrowDown"),new YT],[new r0("ArrowUp"),new XT],[new r0("Tab"),new YT],[new r0("Tab",{shift:!0}),new XT],[new r0("n",{ctrl:!0}),new YT],[new r0("p",{ctrl:!0}),new XT],[new r0("Enter"),new r31],[new r0("Escape"),new s31]]),focusNode:this.focusNode,child:K}),G=new B7({actions:new Map([[YT,new l6(this.invoke)],[XT,new l6(this.invoke)],[r31,new l6(this.invoke)],[s31,new l6(this.invoke)]]),child:q}),W=new K0({children:[new c1({decoration:{color:Z.background},child:new Q1({text:new k(">",new g({color:Z.foreground}))})}),new I0({child:G})]});this.itemContexts=[];let H;if(this.widget.props.isLoading){let B=this.widget.props.loadingText??"Loading...";H=new I1({height:10,child:new s0({child:new Q1({text:new k(B,new g({color:Z.foreground}))})})})}else if(Y.length===0&&this.widget.props.emptyStateText)H=new I0({child:new s0({child:new Q1({text:new k(this.widget.props.emptyStateText,new g({color:Z.foreground,dim:!0}))})})});else{let B=Y.map((N,w)=>{let L=w===this.selectedIndex,O=this.widget.props.isItemDisabled?.(N)??!1,M;if(this.widget.props.renderItem)M=this.widget.props.renderItem(N,L,O,J);else{let A=L?Q.app.selectionBackground:void 0,R=L?Q.app.selectionForeground:Z.foreground;M=new c1({decoration:A?{color:A}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k(this.widget.props.getLabel(N),new g({color:R,dim:O}))})})}return new OU6(new o0({onClick:(A)=>this.handleItemClick(w,A.clickCount),child:M}),(A)=>{this.itemContexts[w]=A})});H=new b1({children:B,crossAxisAlignment:"start"})}let F=new o0({onScroll:this.handleScroll,opaque:!1,child:new C4({controller:this.scrollController,autofocus:!1,child:H})}),z=[];if(this.widget.props.title){let B=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k(this.widget.props.title,new g({color:Q.app.command,bold:!0}))})});z.push(B)}if(z.push(W,new I1({height:1})),this.controller.text!==""){let B=Y.length>0?Y[this.selectedIndex]:void 0,N=B&&this.widget.props.buildDisabledReasonWidget?.(B,J);z.push(new I0({child:new b1({mainAxisAlignment:"spaceBetween",children:[new I0({child:F}),new c1({padding:C1.only({top:1}),child:new s0({child:N??new I1({height:1})})})]})}))}else z.push(new I0({child:F}));if(this.widget.props.footer)z.push(this.widget.props.footer);return new c1({decoration:{border:X,color:Z.background},padding:C1.symmetric(1,0),child:new b1({children:z})})}}function RU6(J){let Z=new Date().getTime()-J.getTime(),Y=Math.floor(Z/60000),X=Math.floor(Z/3600000),V=Math.floor(Z/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return J.toLocaleDateString()}class iu1 extends m0{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Q=[...this.props.entries].sort((X,V)=>V.pubDate.getTime()-X.pubDate.getTime()),Z=Math.max(0,...Q.map((X)=>RU6(X.pubDate).length));return new h7({items:Q,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,V,K,q)=>{let G=h1.of(q),{colors:W}=G,H=G.app,F=V?H.selectionBackground:void 0,z=V?H.selectionForeground:W.foreground,U=W.mutedForeground,D=(B,N)=>new I1({width:N,child:K0.end([new Q1({text:new k(B,new g({color:U}))})])});return new c1({decoration:F?{color:F}:void 0,padding:C1.symmetric(2,0),child:new K0({children:[new I0({child:new Q1({text:new k(X.title,new g({color:z})),overflow:"ellipsis",maxLines:1})}),new I1({width:2}),D(RU6(X.pubDate),Z)]})})}})}}c6();class nu1 extends o1{createState(){return new jU6}}class jU6 extends n1{isGreen=!0;timer;initState(){this.timer=setInterval(()=>{this.isGreen=!this.isGreen,this.setState()},700)}dispose(){if(this.timer)clearInterval(this.timer);super.dispose()}build(J){let Z=h1.of(J).colors;return new Q1({text:new k("●",new g({color:this.isGreen?Z.success:Z.mutedForeground,bold:!0})),maxLines:1})}}var Sy8=/\/threads\/(T-[^/?#\s<>]+)/i;function ky8(J){let Q=J.trim(),Y=Q.match(Sy8)?.[1];if(Y&&J5(Y))return Y;let X=Q.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(J5(X))return X;return null}function yy8(J){let Q=new Map,Z=new Map,Y=new Map,X=[];for(let K of J)Q.set(K.id,K);for(let K of J){let q=K.relationships.find((G)=>G.role==="child"&&Q.has(G.threadID)&&(G.type==="fork"||G.type==="handoff"));if(q){Y.set(K.id,q.type);let G=q.threadID,W=Z.get(G)||[];W.push(K),Z.set(G,W)}else X.push(K)}return O71.flatten(X,(K)=>Z.get(K.id)).map((K)=>({...K.item,depth:K.depth,isLast:K.isLast,ancestorsAreLast:K.ancestorsAreLast,relationshipType:Y.get(K.item.id)}))}function au1(J,Q,Z){return new Q1({text:new k(`${J}${Q}`,new g({color:Z})),maxLines:1})}function xy8(J,Q,Z,Y){return[au1("+",J,Y.success),x9.horizontal(1),au1("~",Q,Y.warning),x9.horizontal(1),au1("-",Z,Y.destructive)]}class t31 extends m0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}build(J){let Q=this.props.filterByWorkspace&&this.props.currentWorkspaceURI?this.props.threads.filter((D)=>D.workspaceURI===this.props.currentWorkspaceURI):this.props.threads;if(this.props.excludeCurrentThread&&this.props.currentThreadID)Q=Q.filter((D)=>D.id!==this.props.currentThreadID);let Z=this.props.recentThreadIDs||[],Y=new Set(Z),X=this.props.currentThreadID,V=[...Q].sort((D,B)=>{if(X){if(D.id===X)return-1;if(B.id===X)return 1}let N=Z.indexOf(D.id),w=Z.indexOf(B.id);if(N!==-1&&w!==-1)return N-w;if(N!==-1)return-1;if(w!==-1)return 1;return 0}),K=yy8(V),q=Math.max(0,...K.map((D)=>D.description.timeAgo.length)),G=h1.of(J),W=new a1({padding:C1.symmetric(0,1),child:new s0({child:new Q1({text:new k("",new g({color:G.colors.foreground,dim:!0}),[new k("Ctrl+T",new g({color:G.colors.primary,dim:!0})),new k(this.props.filterByWorkspace?" for all workspaces":" to filter by workspace",new g({color:G.colors.foreground,dim:!0}))])})})}),H="",F=null,z=(D)=>{if(D!==H)H=D,F=ky8(D);return F};return new h7({items:K,getLabel:(D)=>`${D.title} ${D.id}`,filterItem:(D,B)=>{let N=z(B);if(N)return D.id.toLowerCase()===N.toLowerCase();return!0},normalizeQuery:(D)=>z(D)?"":D,onAccept:(D,B)=>this.props.onSelect?.(D.id,B),onDismiss:this.props.onDismiss,onSelectionChange:(D)=>{if(this.props.previewController){if(D)this.props.previewController.select(D.id)}},title:this.props.title,isLoading:this.props.isLoading,loadingText:"Loading threads...",emptyStateText:"No threads match your filter",maxRenderItems:200,footer:this.props.isLoading?void 0:W,renderItem:(D,B,N,w)=>{let L=h1.of(w),{app:O,colors:M}=L,A=B?O.selectionBackground:void 0,R=B?O.selectionForeground:M.foreground,j=M.mutedForeground,P=(l,u)=>new I1({width:u,child:K0.end([new Q1({text:new k(l,new g({color:j}))})])}),C=this.props.threadViewStates[D.id],_=[],x=D.relationshipType==="handoff",b=new ag({connectorColor:M.mutedForeground});if(D.depth>0){let l=[],u=D.ancestorsAreLast.slice(1);for(let r of u)l.push(new k(b.getAncestorPrefix(r),new g({color:b.connectorColor,dim:b.connectorDim})));let a=D.isLast?b.elbow:b.tee,d=b.getConnectorText(a);l.push(new k(d,new g({color:b.connectorColor,dim:b.connectorDim}))),_.push(new Q1({text:new k("",void 0,l)}))}let h=[],y=X===D.id?new k("(current) ",new g({color:M.success})):Y.has(D.id)?new k("(visited) ",new g({color:M.foreground,dim:!0})):null;if(y)h.push(new Q1({text:y}));if(jL(C))h.push(new nu1),h.push(new I1({width:1}));let f=D.title;if(D.relationshipType==="fork"){let l=f.match(/^Forked\((\d+)\): /);if(l)f=f.slice(l[0].length);else while(f.startsWith("Forked: "))f=f.slice(8);h.push(new Q1({text:new k("[fork] ",new g({color:M.primary}))}))}else if(x)h.push(new Q1({text:new k("[handoff] ",new g({color:M.accent}))}));if(h.push(new I0({child:new Q1({text:new k(f,new g({color:R})),overflow:"ellipsis",maxLines:1})})),h.push(new I1({width:2})),D.diffStats&&(D.diffStats.added>0||D.diffStats.changed>0||D.diffStats.deleted>0)){let l=B?{success:j,warning:j,destructive:j}:M;h.push(...xy8(D.diffStats.added,D.diffStats.changed,D.diffStats.deleted,l)),h.push(new I1({width:2}))}return h.push(P(D.description.timeAgo,q)),new c1({decoration:A?{color:A}:void 0,padding:C1.symmetric(2,0),child:new K0({children:[..._,...h]})})}})}}class PU6 extends o1{child;onContext;constructor(J,Q){super();this.child=J;this.onContext=Q}createState(){return new IU6}}class IU6 extends n1{build(J){return this.widget.onContext(J),this.widget.child}}var EU6=30,vy8=30;class $T{}class VT{}class e31{}class J21{}class ou1 extends o1{props;constructor(J){super();this.props=J}createState(){return new CU6}}class CU6 extends n1{highlightedIndex=0;controller=new a2;focusNode;scrollController=new a4;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new V4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})})}didUpdateWidget(J){if(J.props.clusters!==this.widget.props.clusters){if(this.recomputeFiltered(),this.highlightedIndex>=this.filteredClusters.length)this.highlightedIndex=Math.max(0,this.filteredClusters.length-1)}}ensureSelectedItemVisible(){let J=this.itemContexts[this.highlightedIndex];if(!J)return;let Q=J.findRenderObject();if(!Q)return;let Z=0,Y=Q.size.height;MC(J,{top:Z,bottom:Y},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Q}=this.widget.props;if(!J)this.filteredClusters=[...Q];else this.filteredClusters=Q.filter((Z)=>Z.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof $T){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof VT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof e31){let Q=this.filteredClusters[this.highlightedIndex];if(Q)this.widget.props.onAccept(Q);return"handled"}if(J instanceof J21)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Q)=>{if(J>=0&&J<this.filteredClusters.length){if(Q===1)this.highlightedIndex=J,this.setState();else if(Q===2){let Z=this.filteredClusters[J];if(Z)this.widget.props.onAccept(Z)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Q=this.highlightedIndex;if(J.direction==="down")if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++;else return!1;else if(this.highlightedIndex>0)this.highlightedIndex--;else return!1;return this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Q};build(J){let{currentThreadID:Q}=this.widget.props,Z=h1.of(J),{colors:Y,app:X}=Z,q=Y6.of(J).size.width>=vy8+EU6,G=c0.all(new u0(Y.foreground,1,"solid")),W=this.filteredClusters[this.highlightedIndex]??null,H=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("Select a cluster",new g({color:X.command,bold:!0}))})}),F=new YY({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:Y.foreground,border:null},maxLines:1}),z=new H2({shortcuts:new Map([[new r0("ArrowDown"),new $T],[new r0("ArrowUp"),new VT],[new r0("Tab"),new $T],[new r0("Tab",{shift:!0}),new VT],[new r0("n",{ctrl:!0}),new $T],[new r0("p",{ctrl:!0}),new VT],[new r0("Enter"),new e31],[new r0("Escape"),new J21]]),focusNode:this.focusNode,child:F}),U=new B7({actions:new Map([[$T,new l6(this.invoke)],[VT,new l6(this.invoke)],[e31,new l6(this.invoke)],[J21,new l6(this.invoke)]]),child:z}),D=new K0({children:[new c1({decoration:{color:Y.background},child:new Q1({text:new k(">",new g({color:Y.foreground}))})}),new I0({child:U})]});this.itemContexts=[];let B=this.filteredClusters.map((A,R)=>{let j=R===this.highlightedIndex,P=Q?A.threads.some((b)=>b.id===Q):!1,C=j?X.selectionBackground:void 0,_=j?X.selectionForeground:Y.foreground,x=[new k(A.label,new g({color:_})),new k(` (${A.threads.length})`,new g({color:_,dim:!0}))];if(P)x.push(new k(" (current)",new g({color:j?X.selectionForeground:Y.success})));return new PU6(new o0({onClick:(b)=>this.handleItemClick(R,b.clickCount),child:new c1({decoration:C?{color:C}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k("",void 0,x)})})}),(b)=>{this.itemContexts[R]=b})}),N=new b1({children:B,crossAxisAlignment:"start"}),w=new I0({child:new o0({onScroll:this.handleScroll,child:new C4({controller:this.scrollController,autofocus:!1,child:N})})}),L=W?W.threads.map((A)=>({id:A.id,title:A.title,parentID:A.parentID,updatedAt:A.updatedAt})):[],O=W?new c1({padding:C1.all(1),child:new dO({threads:L,autofocus:!1,offsetY:2})}):null,M;if(q){let A=O?new I0({child:O}):new I1({width:EU6});M=new K0({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[w,A]})}else{let A=[new I0({child:new o0({onScroll:this.handleScroll,child:new C4({controller:this.scrollController,autofocus:!1,child:N})})})];if(O)A.push(new I0({child:O}));M=new b1({crossAxisAlignment:"stretch",children:A})}return new c1({decoration:{border:G,color:Y.background},padding:C1.symmetric(1,0),child:new b1({children:[H,D,new I1({height:1}),new I0({child:M})]})})}}p1();class TU6 extends n1{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){T.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){T.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Q=J.trim().toLowerCase();if(Q.length===0)return null;if(Q.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Q))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Q)=>!J.includes(Q.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Q=J.trim().toLowerCase();if(!this.isValidLabelName(Q))return!1;let Z=this.widget.props.currentLabels||[],Y=this.labels.some((V)=>V.name===Q),X=Z.includes(Q);return!Y&&!X}build(J){let Q=h1.of(J),{app:Z,colors:Y}=Q,X=this.currentQuery.trim().toLowerCase(),V=X.length>0?this.getValidationError(X):null,K=this.getAvailableLabels(),G=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...K];return new h7({title:"Add Label",items:G,getLabel:(W)=>{if("__isCreateMarker"in W)return this.currentQuery.trim().toLowerCase();return W.name},onAccept:(W)=>{if("__isCreateMarker"in W)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(W.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:V||"Type to create a new label",renderItem:(W,H,F,z)=>{let U=H?Z.selectionBackground:void 0,D=H?Z.selectionForeground:Y.foreground;if("__isCreateMarker"in W&&W.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new c1({decoration:U?{color:U}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k("",void 0,[new k("Create new label: ",new g({color:D})),new k(N,new g({color:D,bold:!0}))])})})}return new c1({decoration:U?{color:U}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k(W.name,new g({color:D}))})})},filterItem:(W,H)=>{if(this.currentQuery!==H)this.currentQuery=H,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in W&&W.__isCreateMarker)return this.shouldShowCreateMarker(H);let z=H.trim().toLowerCase();return z.length===0||W.name.includes(z)},sortItems:(W,H,F)=>{let z="__isCreateMarker"in W.item&&W.item.__isCreateMarker,U="__isCreateMarker"in H.item&&H.item.__isCreateMarker;if(z&&!U)return-1;if(!z&&U)return 1;return H.score-W.score}})}}class ru1 extends o1{props;constructor(J){super();this.props=J}createState(){return new TU6}}class DD extends o1{props;constructor(J){super();this.props=J}createState(){return new _U6}}class _U6 extends n1{_spinner=new x5;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 Q=h1.of(J),{colors:Z,app:Y}=Q,X=c0.all(new u0(Z.foreground,1,"solid")),V=this._spinner.toBraille(),K=new Q1({textAlign:"center",text:new k("",void 0,[new k(V,new g({color:Y.processing})),new k(" ",void 0),new k(this.widget.props.message,new g({color:Z.foreground}))])}),G=[new I0({child:new b1({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[K]})})];if(this.widget.props.onAbort)G.push(new I1({height:2,child:new c1({padding:C1.symmetric(2,0),child:new Q1({text:new k("",new g({dim:!0}),[new k("Press ",new g({color:Z.foreground})),new k("Esc",new g({color:Z.info})),new k(" to cancel",new g({color:Z.foreground}))])})})}));let W=new c1({decoration:new T6(Z.background,X),child:new I1({width:60,height:7,child:new b1({mainAxisAlignment:"start",children:G})})});if(this.widget.props.onAbort)return new b6({debugLabel:"LoadingDialog",autofocus:!0,onKey:(H)=>{if(H.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:W});return W}}class lO extends o1{props;constructor(J){super();this.props=J}createState(){return new SU6}}class SU6 extends n1{scrollController=new a4;scrollAreaKey=new _3("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 $Y}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Q=this.scrollAreaKey.currentElement?.renderObject;if(Q&&"size"in Q){let Z=Q.size;if(typeof Z.height==="number"&&Z.height>0)return this.viewportHeight=Z.height,Z.height}return this.viewportHeight}build(J){let Q=h1.of(J),Z=this.widget.props.message,Y=(()=>{if(this.isWidgetMessage(Z))return{title:Z.title,type:Z.type};if(Z instanceof Error&&Z.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Z.message};if(Z instanceof Error&&Z.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Z.message};let H=N71(Z);return{title:H.title,type:H.type,description:H.description}})(),X=Y.type==="error"?Q.app.toolError:Q.app.command,V=c0.all(new u0(Q.colors.border,1,"solid")),K=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k(Y.title,new g({color:X,bold:!0}))})}),q=this.isWidgetMessage(Z)?Z.widget:new Q1({text:new k(Y.description,new g({color:Q.colors.foreground})),selectable:!0}),G=new I0({child:new bJ({child:new c1({padding:C1.symmetric(1,0),child:new K0({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new I0({child:new C4({controller:this.scrollController,autofocus:!0,child:q})}),new j5({controller:this.scrollController,thumbColor:Q.app.scrollbarThumb,trackColor:Q.app.scrollbarTrack,getScrollInfo:()=>{let H=this.scrollController.maxScrollExtent,F=this.scrollController.offset,z=this.getViewportHeight(),U=H+z;return{totalContentHeight:Math.max(U,0),viewportHeight:Math.max(z,1),scrollOffset:Math.max(F,0)}}})]})})})}),W=new c1({padding:C1.symmetric(1,0),child:new Q1({text:(()=>{if(this.widget.props.onRetry)return new k("",void 0,[new k("Press ",new g({color:Q.colors.foreground,dim:!0})),new k("R",new g({color:Q.app.keybind})),new k(" to retry, ",new g({color:Q.colors.foreground,dim:!0})),new k("Esc",new g({color:Q.app.keybind})),new k(" to cancel",new g({color:Q.colors.foreground,dim:!0}))]);let H=this.resolveFooterStyle(this.widget.props.message);if(H==="none")return new k("",new g({color:Q.colors.foreground,dim:!0}));if(H==="help"){let F=new g({color:Q.app.keybind}),z=new g({color:Q.colors.foreground,dim:!0});return new k("",z,[new k("Press ",z),new k("Escape",F),new k(" to close • Use ",z),new k("↑↓",F),new k(" or ",z),new k("j/k",F),new k(" to scroll",z)])}return new k("Press any key to close",new g({color:Q.colors.foreground,dim:!0,italic:!0}))})()})});return new b6({onKey:(H)=>{if(this.widget.props.onRetry&&H.key==="r")return this.widget.props.onRetry(),"handled";if(H.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 c1({decoration:{border:V,color:Q.colors.background},padding:C1.all(1),child:new b1({mainAxisAlignment:"center",children:[K,new I1({height:1}),G,W]})})})}}class su1 extends m0{build(J){let Q=h1.of(J),{colors:Z,app:Y}=Q;return new s0({child:new Q1({text:new k("",void 0,[new k(`✓ Thread Shared
8518
+ `,N)])}),R];if(!G&&!z&&W.url){let _=W.url.replace(/^https?:\/\//,"");P.push(new e4({uri:W.url,text:_,style:new g({color:Z.secondary,underline:!0})}))}if(A&&!z)P.push(A);let C=new I1({width:50,child:new b1({crossAxisAlignment:"start",mainAxisSize:"min",children:P})});return s0.child(new K0({mainAxisAlignment:"center",crossAxisAlignment:"center",mainAxisSize:"min",children:[new Nv1({width:uu1,height:gu1,agentMode:this.widget.agentMode,glow:this._glow,backgroundColor:Z.background,t:H,fps:0,shockwaves:this._shockwaves,onShockwave:O,...K==="disabled"&&{seed:42}}),new I1({width:2}),C]}))}}class mu1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new FU6}}class FU6 extends n1{build(J){let Z=h1.of(J).colors,{todos:Y,title:X="TODOs"}=this.widget.props;if(!Array.isArray(Y)||Y.length===0)return new I1({width:0,height:0});let V=Y.map((K)=>this.buildTodoItem(K,Z));return new c1({child:new a1({padding:C1.symmetric(1,0),child:new b1({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new Q1({text:new k(X,new g({bold:!0,color:Z.foreground}))}),...V]})})})}buildTodoItem(J,Q){let Z=this.getStatusIcon(J.status),Y=J.status==="completed",X=new g({bold:J.status==="in-progress",color:Q.foreground,dim:Y}),V=new g({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Q.foreground,dim:Y});return new K0({crossAxisAlignment:"start",children:[new Q1({text:new k(Z,X)}),new I1({width:1}),new I0({child:new Q1({text:new k(J.content,V)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class pu1 extends o1{ad;onDismiss;onButtonClick;onImpression;onAdInfoClick;constructor({key:J,ad:Q,onDismiss:Z,onButtonClick:Y,onImpression:X,onAdInfoClick:V}){super({key:J});this.ad=Q,this.onDismiss=Z,this.onButtonClick=Y,this.onImpression=X,this.onAdInfoClick=V}createState(){return new zU6}}class zU6 extends n1{lastTrackedAdId=null;initState(){super.initState(),this.fireImpressionIfNeeded()}didUpdateWidget(J){super.didUpdateWidget(J),this.fireImpressionIfNeeded()}fireImpressionIfNeeded(){let J=this.widget.ad;if(J.id!==this.lastTrackedAdId)this.lastTrackedAdId=J.id,this.widget.onImpression?.(J)}build(J){let Q=h1.of(J),Z=Q.colors.primary,Y=Q.colors.foreground,X=Q.colors.background,V=this.widget.ad;return new c1({decoration:new T6(X,new c0(new u0(Z,1,"rounded"),new u0(Z,1,"rounded"),void 0,new u0(Z,1,"rounded"))),child:new a1({padding:C1.horizontal(1),child:new b1({children:[new K0({crossAxisAlignment:"start",children:[new I0({child:new Q1({text:new k(V.content,new g({color:Y}))})}),new I1({width:4}),new o0({onClick:()=>this.widget.onAdInfoClick?.(),cursor:"pointer",child:new Q1({text:new k("Ad",new g({color:Y,dim:!0}))})})]}),new K0({crossAxisAlignment:"start",children:[new Tg({text:V.buttonLabel,onPressed:()=>this.widget.onButtonClick?.(),padding:C1.horizontal(1),color:Z,reverse:!0}),new I1({width:2}),new Q1({text:new k(V.destinationUrlHostname,new g({color:Y,dim:!0}))})]})]})})})}}class du1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new UU6(this.props.autofocus??!0)}}class UU6 extends n1{autofocus;constructor(J){super();this.autofocus=J}build(J){let Z=k0.of(J).colorScheme,Y=(W)=>{if(W.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(W.ctrlKey&&W.key==="c"||W.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},X=Y6.sizeOf(J),V=Math.min(60,X.width-4),K=X.height-4,q=[];if(this.widget.props.title)q.push(new Q1({text:new k(this.widget.props.title,new g({bold:!0,color:Z.primary}))}),new I1({height:1}));if(this.widget.props.message)q.push(new Q1({text:new k(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)q.push(new I1({height:1}));let G=[];if(this.widget.props.showCopyOption)G.push(new Q1({text:new k("Enter to copy",new g({dim:!0}))}));return G.push(new Q1({text:new k("Escape to close",new g({dim:!0}))})),q.push(new K0({children:G.flatMap((W,H)=>H<G.length-1?[W,new I1({width:1}),new Q1({text:new k("•",new g({dim:!0}))}),new I1({width:1})]:[W]),mainAxisSize:"min"})),new s0({child:new c1({constraints:new A0(V,V,0,K),decoration:new T6(Z.background,new c0(new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"),new u0(Z.primary,1,"rounded"))),padding:new C1(2,2,2,2),child:new b6({autofocus:this.autofocus,onKey:Y,child:new b1({children:q,mainAxisSize:"min"})})})})}}class cu1 extends o1{props;constructor(J){super({key:J.key});this.props=J}createState(){return new DU6(this.props.autofocus??!0)}}class DU6 extends n1{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=k0.of(J).colorScheme,Z=(q)=>{if(q.key==="Enter"||q.key==="Escape"||q.ctrlKey&&q.key==="c")return this.widget.props.onClose(),"handled";return"ignored"},Y=Y6.sizeOf(J),X=Math.min(60,Y.width-4),V=Y.height-4,K=[];if(K.push(new Q1({text:new k("Ads make Amp Free possible",new g({bold:!0}))})),this.widget.props.provider)K.push(new I1({height:1}),new Q1({text:new k(`Ad source: ${this.widget.props.provider}`,new g({dim:!0}))}));return K.push(new I1({height:1}),new Q1({text:new k("Escape to close",new g({dim:!0}))})),new s0({child:new c1({constraints:new A0(X,X,0,V),decoration:new T6(Q.background,new c0(new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"),new u0(Q.primary,1,"rounded"))),padding:new C1(2,2,2,2),child:new b6({autofocus:this.autofocus,onKey:Z,child:new b1({children:K,mainAxisSize:"min"})})})})}}p1();import{execSync as Jx8}from"node:child_process";iT1();YQ();p9();l3();YN();U$();NJ();NZ();z$();JI();c6();xh();kS();F0();var GD6=D6(nG(),1);import{writeFile as XD6}from"fs/promises";import $D6 from"path";p1();NJ();class lu1{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Q){this.enabled=J;this.configService=Q;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Q,Z])=>({feature:"cli.command",action:Q,source:{client:"cli",clientVersion:"0.0.1771302820-ga4c3d4"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await Hs(Q,this.configService)}catch(Q){T.error("Failed to export command telemetry events",Q)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Q=this.commandCounts.get(J)||0;this.commandCounts.set(J,Q+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class UD extends o1{props;constructor(J){super();this.props=J}createState(){return new BU6}}class BU6 extends n1{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Q=(Z)=>{this.setState(()=>{this._state=Z(this._state)})};return this.widget.props.builder(J,Q,this._state)}}class NU6 extends n1{controller=new a2;focusNode=new V4({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 Q=h1.of(J),{colors:Z,app:Y}=Q,X=this.widget.props.isRequiredArg??!0,V=this.controller.text.trim().length>0,K=!X||V,q=c0.all(new u0(Z.foreground,1,"solid")),G=new YY({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:Z.foreground,border:null},maxLines:1}),W=new K0({children:[new c1({decoration:{color:Z.background},child:new Q1({text:new k(">",new g({color:Z.foreground}))})}),new I0({child:G})]}),H=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("",void 0,[new k("Command: ",new g({color:Z.foreground})),new k(this.widget.props.commandName,new g({color:Y.command,bold:!0}))])})}),F=[];if(K)F.push(new k("Enter",new g({color:Y.keybind}))),F.push(new k(" to submit, ",new g({color:Z.foreground,dim:!0})));F.push(new k("Esc",new g({color:Y.keybind}))),F.push(new k(" to cancel",new g({color:Z.foreground,dim:!0})));let z=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("",void 0,F)})});return new c1({decoration:{border:q,color:Z.background},padding:C1.all(1),child:new b1({children:[H,new I1({height:1}),W,new x9,z]})})}}class pm extends o1{props;constructor(J){super();this.props=J}createState(){return new NU6}}import{isDeepStrictEqual as Ty8}from"node:util";var Py8=/[\\/_ +.#"@[({&]/,Iy8=/[\\/_ +.#"@[({&]/g,Cy8=/[\s-]/,wU6=/[\s-]/g;function o31(J,Q,Z,Y,X,V,K){if(V===Q.length){if(X===J.length)return 1;return 0.99}let q=`${X},${V}`;if(K[q]!==void 0)return K[q];let G=Y.charAt(V),W=Z.indexOf(G,X),H=0,F,z,U,D;while(W>=0){if(F=o31(J,Q,Z,Y,W+1,V+1,K),F>H){if(W===X)F*=1;else if(Cy8.test(J.charAt(W-1))){if(F*=0.9,D=J.slice(X,W-1).match(wU6),D&&X>0)F*=0.999**D.length}else if(Py8.test(J.charAt(W-1))){if(F*=0.8,U=J.slice(X,W-1).match(Iy8),U&&X>0)F*=0.999**U.length}else if(F*=0.3,X>0)F*=0.999**(W-X);if(J.charAt(W)!==Q.charAt(V))F*=0.9999}if(F<0.1&&(Z.charAt(W-1)===Y.charAt(V+1)||Y.charAt(V+1)===Y.charAt(V)&&Z.charAt(W-1)!==Y.charAt(V))){if(z=o31(J,Q,Z,Y,W+1,V+2,K),z*0.1>F)F=z*0.1}if(F>H)H=F;W=Z.indexOf(G,W+1)}return K[q]=H,H}function a31(J){return J.toLowerCase().replace(wU6," ")}function LU6(J,Q){let Z=o31(J,Q,a31(J),a31(Q),0,0,{}),Y=Q.trim().split(/\s+/);if(Y.length>1){let X=0,V=0;for(let q of Y){let G=o31(J,q,a31(J),a31(q),0,0,{});if(G===0)return Z;X+=G,V+=q.length}let K=X/Y.length*0.95;return Math.max(Z,K)}return Z}class YT{}class XT{}class r31{}class s31{}class OU6 extends o1{child;onContext;constructor(J,Q){super();this.child=J;this.onContext=Q}createState(){return new MU6}}class MU6 extends n1{build(J){return this.widget.onContext(J),this.widget.child}}function _y8(J,Q){if(J==="")return{matches:!0,score:1};let Z=LU6(Q,J);return{matches:Z>0.15,score:Z}}class h7 extends o1{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new AU6}}class AU6 extends n1{controller=new a2;focusNode;scrollController=new a4;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){this.scrollController.disableFollowMode(),this.focusNode=new V4({debugLabel:this.widget.debugLabel}),this.controller.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let Q=this.cachedFiltered;this.widget.props.onSelectionChange?.(Q[0]??null)}),this.recomputeFilteredItems();let J=this.cachedFiltered;this.widget.props.onSelectionChange?.(J[0]??null),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!Ty8(J.props.items,this.widget.props.items)){this.recomputeFilteredItems(),this.ensureSelectedItemVisible();let Q=this.cachedFiltered;this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null)}}dispose(){this.widget.props.onSelectionChange?.(null),this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof YT){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof XT){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null);return"handled"}if(J instanceof r31){let Q=this.getFilteredItems();if(Q.length>0&&this.selectedIndex<Q.length){let Z=Q[this.selectedIndex];if(Z){if(!(this.widget.props.isItemDisabled?.(Z)??!1))this.widget.props.onAccept(Z,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof s31)return this.widget.props.onDismiss?.(),"handled";return"ignored"};recomputeFilteredItems(){let J=this.controller.text,Q=this.widget.props.items,Z=this.widget.props.normalizeQuery?.(J)??J,Y=Q.filter((X)=>!this.widget.props.filterItem||this.widget.props.filterItem(X,J)).map((X)=>({item:X,..._y8(Z,this.widget.props.getLabel(X))})).filter((X)=>X.matches).sort(this.widget.props.sortItems?(X,V)=>this.widget.props.sortItems(X,V,J):(X,V)=>V.score-X.score).map((X)=>X.item);this.cachedQuery=J,this.cachedItemsRef=Q,this.cachedFiltered=this.widget.props.maxRenderItems?Y.slice(0,this.widget.props.maxRenderItems):Y}getFilteredItems(){let J=this.controller.text,Q=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Q)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Q=J.findRenderObject();if(!Q)return;let Z=0,Y=Q.size.height;MC(J,{top:Z,bottom:Y},{padding:1})}handleScroll=(J)=>{let Q=this.getFilteredItems();if(Q.length===0)return!1;let Z=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Q.length-1)this.hasUserInteracted=!0,this.selectedIndex++;else return!1;else if(this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--;else return!1;return this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.widget.props.onSelectionChange?.(Q[this.selectedIndex]??null),this.selectedIndex!==Z};handleItemClick=(J,Q)=>{let Z=this.getFilteredItems();if(J>=0&&J<Z.length){let Y=Z[J],X=Y?this.widget.props.isItemDisabled?.(Y)??!1:!1;if(Q===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.widget.props.onSelectionChange?.(Z[this.selectedIndex]??null);else if(Q===2&&!X){if(Y)this.hasUserInteracted=!0,this.widget.props.onAccept(Y,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Q=h1.of(J),{colors:Z}=Q,Y=this.getFilteredItems(),X=c0.all(new u0(Z.foreground,1,"solid")),V=this.widget.props.enabled??!0,K=new YY({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:V,style:{backgroundColor:Z.background,textColor:Z.foreground,cursorColor:Z.cursor,placeholderColor:Z.mutedForeground,border:null},maxLines:1}),q=new H2({shortcuts:new Map([[new r0("ArrowDown"),new YT],[new r0("ArrowUp"),new XT],[new r0("Tab"),new YT],[new r0("Tab",{shift:!0}),new XT],[new r0("n",{ctrl:!0}),new YT],[new r0("p",{ctrl:!0}),new XT],[new r0("Enter"),new r31],[new r0("Escape"),new s31]]),focusNode:this.focusNode,child:K}),G=new B7({actions:new Map([[YT,new l6(this.invoke)],[XT,new l6(this.invoke)],[r31,new l6(this.invoke)],[s31,new l6(this.invoke)]]),child:q}),W=new K0({children:[new c1({decoration:{color:Z.background},child:new Q1({text:new k(">",new g({color:Z.foreground}))})}),new I0({child:G})]});this.itemContexts=[];let H;if(this.widget.props.isLoading){let B=this.widget.props.loadingText??"Loading...";H=new I1({height:10,child:new s0({child:new Q1({text:new k(B,new g({color:Z.foreground}))})})})}else if(Y.length===0&&this.widget.props.emptyStateText)H=new I0({child:new s0({child:new Q1({text:new k(this.widget.props.emptyStateText,new g({color:Z.foreground,dim:!0}))})})});else{let B=Y.map((N,w)=>{let L=w===this.selectedIndex,O=this.widget.props.isItemDisabled?.(N)??!1,M;if(this.widget.props.renderItem)M=this.widget.props.renderItem(N,L,O,J);else{let A=L?Q.app.selectionBackground:void 0,R=L?Q.app.selectionForeground:Z.foreground;M=new c1({decoration:A?{color:A}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k(this.widget.props.getLabel(N),new g({color:R,dim:O}))})})}return new OU6(new o0({onClick:(A)=>this.handleItemClick(w,A.clickCount),child:M}),(A)=>{this.itemContexts[w]=A})});H=new b1({children:B,crossAxisAlignment:"start"})}let F=new o0({onScroll:this.handleScroll,opaque:!1,child:new C4({controller:this.scrollController,autofocus:!1,child:H})}),z=[];if(this.widget.props.title){let B=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k(this.widget.props.title,new g({color:Q.app.command,bold:!0}))})});z.push(B)}if(z.push(W,new I1({height:1})),this.controller.text!==""){let B=Y.length>0?Y[this.selectedIndex]:void 0,N=B&&this.widget.props.buildDisabledReasonWidget?.(B,J);z.push(new I0({child:new b1({mainAxisAlignment:"spaceBetween",children:[new I0({child:F}),new c1({padding:C1.only({top:1}),child:new s0({child:N??new I1({height:1})})})]})}))}else z.push(new I0({child:F}));if(this.widget.props.footer)z.push(this.widget.props.footer);return new c1({decoration:{border:X,color:Z.background},padding:C1.symmetric(1,0),child:new b1({children:z})})}}function RU6(J){let Z=new Date().getTime()-J.getTime(),Y=Math.floor(Z/60000),X=Math.floor(Z/3600000),V=Math.floor(Z/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return J.toLocaleDateString()}class iu1 extends m0{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Q=[...this.props.entries].sort((X,V)=>V.pubDate.getTime()-X.pubDate.getTime()),Z=Math.max(0,...Q.map((X)=>RU6(X.pubDate).length));return new h7({items:Q,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,V,K,q)=>{let G=h1.of(q),{colors:W}=G,H=G.app,F=V?H.selectionBackground:void 0,z=V?H.selectionForeground:W.foreground,U=W.mutedForeground,D=(B,N)=>new I1({width:N,child:K0.end([new Q1({text:new k(B,new g({color:U}))})])});return new c1({decoration:F?{color:F}:void 0,padding:C1.symmetric(2,0),child:new K0({children:[new I0({child:new Q1({text:new k(X.title,new g({color:z})),overflow:"ellipsis",maxLines:1})}),new I1({width:2}),D(RU6(X.pubDate),Z)]})})}})}}c6();class nu1 extends o1{createState(){return new jU6}}class jU6 extends n1{isGreen=!0;timer;initState(){this.timer=setInterval(()=>{this.isGreen=!this.isGreen,this.setState()},700)}dispose(){if(this.timer)clearInterval(this.timer);super.dispose()}build(J){let Z=h1.of(J).colors;return new Q1({text:new k("●",new g({color:this.isGreen?Z.success:Z.mutedForeground,bold:!0})),maxLines:1})}}var Sy8=/\/threads\/(T-[^/?#\s<>]+)/i;function ky8(J){let Q=J.trim(),Y=Q.match(Sy8)?.[1];if(Y&&J5(Y))return Y;let X=Q.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(J5(X))return X;return null}function yy8(J){let Q=new Map,Z=new Map,Y=new Map,X=[];for(let K of J)Q.set(K.id,K);for(let K of J){let q=K.relationships.find((G)=>G.role==="child"&&Q.has(G.threadID)&&(G.type==="fork"||G.type==="handoff"));if(q){Y.set(K.id,q.type);let G=q.threadID,W=Z.get(G)||[];W.push(K),Z.set(G,W)}else X.push(K)}return O71.flatten(X,(K)=>Z.get(K.id)).map((K)=>({...K.item,depth:K.depth,isLast:K.isLast,ancestorsAreLast:K.ancestorsAreLast,relationshipType:Y.get(K.item.id)}))}function au1(J,Q,Z){return new Q1({text:new k(`${J}${Q}`,new g({color:Z})),maxLines:1})}function xy8(J,Q,Z,Y){return[au1("+",J,Y.success),x9.horizontal(1),au1("~",Q,Y.warning),x9.horizontal(1),au1("-",Z,Y.destructive)]}class t31 extends m0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}build(J){let Q=this.props.filterByWorkspace&&this.props.currentWorkspaceURI?this.props.threads.filter((D)=>D.workspaceURI===this.props.currentWorkspaceURI):this.props.threads;if(this.props.excludeCurrentThread&&this.props.currentThreadID)Q=Q.filter((D)=>D.id!==this.props.currentThreadID);let Z=this.props.recentThreadIDs||[],Y=new Set(Z),X=this.props.currentThreadID,V=[...Q].sort((D,B)=>{if(X){if(D.id===X)return-1;if(B.id===X)return 1}let N=Z.indexOf(D.id),w=Z.indexOf(B.id);if(N!==-1&&w!==-1)return N-w;if(N!==-1)return-1;if(w!==-1)return 1;return 0}),K=yy8(V),q=Math.max(0,...K.map((D)=>D.description.timeAgo.length)),G=h1.of(J),W=new a1({padding:C1.symmetric(0,1),child:new s0({child:new Q1({text:new k("",new g({color:G.colors.foreground,dim:!0}),[new k("Ctrl+T",new g({color:G.colors.primary,dim:!0})),new k(this.props.filterByWorkspace?" for all workspaces":" to filter by workspace",new g({color:G.colors.foreground,dim:!0}))])})})}),H="",F=null,z=(D)=>{if(D!==H)H=D,F=ky8(D);return F};return new h7({items:K,getLabel:(D)=>`${D.title} ${D.id}`,filterItem:(D,B)=>{let N=z(B);if(N)return D.id.toLowerCase()===N.toLowerCase();return!0},normalizeQuery:(D)=>z(D)?"":D,onAccept:(D,B)=>this.props.onSelect?.(D.id,B),onDismiss:this.props.onDismiss,onSelectionChange:(D)=>{if(this.props.previewController){if(D)this.props.previewController.select(D.id)}},title:this.props.title,isLoading:this.props.isLoading,loadingText:"Loading threads...",emptyStateText:"No threads match your filter",maxRenderItems:200,footer:this.props.isLoading?void 0:W,renderItem:(D,B,N,w)=>{let L=h1.of(w),{app:O,colors:M}=L,A=B?O.selectionBackground:void 0,R=B?O.selectionForeground:M.foreground,j=M.mutedForeground,P=(l,u)=>new I1({width:u,child:K0.end([new Q1({text:new k(l,new g({color:j}))})])}),C=this.props.threadViewStates[D.id],_=[],x=D.relationshipType==="handoff",b=new ag({connectorColor:M.mutedForeground});if(D.depth>0){let l=[],u=D.ancestorsAreLast.slice(1);for(let r of u)l.push(new k(b.getAncestorPrefix(r),new g({color:b.connectorColor,dim:b.connectorDim})));let a=D.isLast?b.elbow:b.tee,d=b.getConnectorText(a);l.push(new k(d,new g({color:b.connectorColor,dim:b.connectorDim}))),_.push(new Q1({text:new k("",void 0,l)}))}let h=[],y=X===D.id?new k("(current) ",new g({color:M.success})):Y.has(D.id)?new k("(visited) ",new g({color:M.foreground,dim:!0})):null;if(y)h.push(new Q1({text:y}));if(jL(C))h.push(new nu1),h.push(new I1({width:1}));let f=D.title;if(D.relationshipType==="fork"){let l=f.match(/^Forked\((\d+)\): /);if(l)f=f.slice(l[0].length);else while(f.startsWith("Forked: "))f=f.slice(8);h.push(new Q1({text:new k("[fork] ",new g({color:M.primary}))}))}else if(x)h.push(new Q1({text:new k("[handoff] ",new g({color:M.accent}))}));if(h.push(new I0({child:new Q1({text:new k(f,new g({color:R})),overflow:"ellipsis",maxLines:1})})),h.push(new I1({width:2})),D.diffStats&&(D.diffStats.added>0||D.diffStats.changed>0||D.diffStats.deleted>0)){let l=B?{success:j,warning:j,destructive:j}:M;h.push(...xy8(D.diffStats.added,D.diffStats.changed,D.diffStats.deleted,l)),h.push(new I1({width:2}))}return h.push(P(D.description.timeAgo,q)),new c1({decoration:A?{color:A}:void 0,padding:C1.symmetric(2,0),child:new K0({children:[..._,...h]})})}})}}class PU6 extends o1{child;onContext;constructor(J,Q){super();this.child=J;this.onContext=Q}createState(){return new IU6}}class IU6 extends n1{build(J){return this.widget.onContext(J),this.widget.child}}var EU6=30,vy8=30;class $T{}class VT{}class e31{}class J21{}class ou1 extends o1{props;constructor(J){super();this.props=J}createState(){return new CU6}}class CU6 extends n1{highlightedIndex=0;controller=new a2;focusNode;scrollController=new a4;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new V4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})})}didUpdateWidget(J){if(J.props.clusters!==this.widget.props.clusters){if(this.recomputeFiltered(),this.highlightedIndex>=this.filteredClusters.length)this.highlightedIndex=Math.max(0,this.filteredClusters.length-1)}}ensureSelectedItemVisible(){let J=this.itemContexts[this.highlightedIndex];if(!J)return;let Q=J.findRenderObject();if(!Q)return;let Z=0,Y=Q.size.height;MC(J,{top:Z,bottom:Y},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Q}=this.widget.props;if(!J)this.filteredClusters=[...Q];else this.filteredClusters=Q.filter((Z)=>Z.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof $T){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof VT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof e31){let Q=this.filteredClusters[this.highlightedIndex];if(Q)this.widget.props.onAccept(Q);return"handled"}if(J instanceof J21)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Q)=>{if(J>=0&&J<this.filteredClusters.length){if(Q===1)this.highlightedIndex=J,this.setState();else if(Q===2){let Z=this.filteredClusters[J];if(Z)this.widget.props.onAccept(Z)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Q=this.highlightedIndex;if(J.direction==="down")if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++;else return!1;else if(this.highlightedIndex>0)this.highlightedIndex--;else return!1;return this.setState(),z4.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Q};build(J){let{currentThreadID:Q}=this.widget.props,Z=h1.of(J),{colors:Y,app:X}=Z,q=Y6.of(J).size.width>=vy8+EU6,G=c0.all(new u0(Y.foreground,1,"solid")),W=this.filteredClusters[this.highlightedIndex]??null,H=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k("Select a cluster",new g({color:X.command,bold:!0}))})}),F=new YY({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:Y.foreground,border:null},maxLines:1}),z=new H2({shortcuts:new Map([[new r0("ArrowDown"),new $T],[new r0("ArrowUp"),new VT],[new r0("Tab"),new $T],[new r0("Tab",{shift:!0}),new VT],[new r0("n",{ctrl:!0}),new $T],[new r0("p",{ctrl:!0}),new VT],[new r0("Enter"),new e31],[new r0("Escape"),new J21]]),focusNode:this.focusNode,child:F}),U=new B7({actions:new Map([[$T,new l6(this.invoke)],[VT,new l6(this.invoke)],[e31,new l6(this.invoke)],[J21,new l6(this.invoke)]]),child:z}),D=new K0({children:[new c1({decoration:{color:Y.background},child:new Q1({text:new k(">",new g({color:Y.foreground}))})}),new I0({child:U})]});this.itemContexts=[];let B=this.filteredClusters.map((A,R)=>{let j=R===this.highlightedIndex,P=Q?A.threads.some((b)=>b.id===Q):!1,C=j?X.selectionBackground:void 0,_=j?X.selectionForeground:Y.foreground,x=[new k(A.label,new g({color:_})),new k(` (${A.threads.length})`,new g({color:_,dim:!0}))];if(P)x.push(new k(" (current)",new g({color:j?X.selectionForeground:Y.success})));return new PU6(new o0({onClick:(b)=>this.handleItemClick(R,b.clickCount),child:new c1({decoration:C?{color:C}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k("",void 0,x)})})}),(b)=>{this.itemContexts[R]=b})}),N=new b1({children:B,crossAxisAlignment:"start"}),w=new I0({child:new o0({onScroll:this.handleScroll,child:new C4({controller:this.scrollController,autofocus:!1,child:N})})}),L=W?W.threads.map((A)=>({id:A.id,title:A.title,parentID:A.parentID,updatedAt:A.updatedAt})):[],O=W?new c1({padding:C1.all(1),child:new dO({threads:L,autofocus:!1,offsetY:2})}):null,M;if(q){let A=O?new I0({child:O}):new I1({width:EU6});M=new K0({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[w,A]})}else{let A=[new I0({child:new o0({onScroll:this.handleScroll,child:new C4({controller:this.scrollController,autofocus:!1,child:N})})})];if(O)A.push(new I0({child:O}));M=new b1({crossAxisAlignment:"stretch",children:A})}return new c1({decoration:{border:G,color:Y.background},padding:C1.symmetric(1,0),child:new b1({children:[H,D,new I1({height:1}),new I0({child:M})]})})}}p1();class TU6 extends n1{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){T.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){T.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Q=J.trim().toLowerCase();if(Q.length===0)return null;if(Q.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Q))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Q)=>!J.includes(Q.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Q=J.trim().toLowerCase();if(!this.isValidLabelName(Q))return!1;let Z=this.widget.props.currentLabels||[],Y=this.labels.some((V)=>V.name===Q),X=Z.includes(Q);return!Y&&!X}build(J){let Q=h1.of(J),{app:Z,colors:Y}=Q,X=this.currentQuery.trim().toLowerCase(),V=X.length>0?this.getValidationError(X):null,K=this.getAvailableLabels(),G=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...K];return new h7({title:"Add Label",items:G,getLabel:(W)=>{if("__isCreateMarker"in W)return this.currentQuery.trim().toLowerCase();return W.name},onAccept:(W)=>{if("__isCreateMarker"in W)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(W.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:V||"Type to create a new label",renderItem:(W,H,F,z)=>{let U=H?Z.selectionBackground:void 0,D=H?Z.selectionForeground:Y.foreground;if("__isCreateMarker"in W&&W.__isCreateMarker){let N=this.currentQuery.trim().toLowerCase();return new c1({decoration:U?{color:U}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k("",void 0,[new k("Create new label: ",new g({color:D})),new k(N,new g({color:D,bold:!0}))])})})}return new c1({decoration:U?{color:U}:void 0,padding:C1.symmetric(2,0),child:new Q1({text:new k(W.name,new g({color:D}))})})},filterItem:(W,H)=>{if(this.currentQuery!==H)this.currentQuery=H,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in W&&W.__isCreateMarker)return this.shouldShowCreateMarker(H);let z=H.trim().toLowerCase();return z.length===0||W.name.includes(z)},sortItems:(W,H,F)=>{let z="__isCreateMarker"in W.item&&W.item.__isCreateMarker,U="__isCreateMarker"in H.item&&H.item.__isCreateMarker;if(z&&!U)return-1;if(!z&&U)return 1;return H.score-W.score}})}}class ru1 extends o1{props;constructor(J){super();this.props=J}createState(){return new TU6}}class DD extends o1{props;constructor(J){super();this.props=J}createState(){return new _U6}}class _U6 extends n1{_spinner=new x5;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 Q=h1.of(J),{colors:Z,app:Y}=Q,X=c0.all(new u0(Z.foreground,1,"solid")),V=this._spinner.toBraille(),K=new Q1({textAlign:"center",text:new k("",void 0,[new k(V,new g({color:Y.processing})),new k(" ",void 0),new k(this.widget.props.message,new g({color:Z.foreground}))])}),G=[new I0({child:new b1({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[K]})})];if(this.widget.props.onAbort)G.push(new I1({height:2,child:new c1({padding:C1.symmetric(2,0),child:new Q1({text:new k("",new g({dim:!0}),[new k("Press ",new g({color:Z.foreground})),new k("Esc",new g({color:Z.info})),new k(" to cancel",new g({color:Z.foreground}))])})})}));let W=new c1({decoration:new T6(Z.background,X),child:new I1({width:60,height:7,child:new b1({mainAxisAlignment:"start",children:G})})});if(this.widget.props.onAbort)return new b6({debugLabel:"LoadingDialog",autofocus:!0,onKey:(H)=>{if(H.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:W});return W}}class lO extends o1{props;constructor(J){super();this.props=J}createState(){return new SU6}}class SU6 extends n1{scrollController=new a4;scrollAreaKey=new _3("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 $Y}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Q=this.scrollAreaKey.currentElement?.renderObject;if(Q&&"size"in Q){let Z=Q.size;if(typeof Z.height==="number"&&Z.height>0)return this.viewportHeight=Z.height,Z.height}return this.viewportHeight}build(J){let Q=h1.of(J),Z=this.widget.props.message,Y=(()=>{if(this.isWidgetMessage(Z))return{title:Z.title,type:Z.type};if(Z instanceof Error&&Z.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Z.message};if(Z instanceof Error&&Z.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Z.message};let H=N71(Z);return{title:H.title,type:H.type,description:H.description}})(),X=Y.type==="error"?Q.app.toolError:Q.app.command,V=c0.all(new u0(Q.colors.border,1,"solid")),K=new c1({padding:C1.symmetric(1,0),child:new Q1({text:new k(Y.title,new g({color:X,bold:!0}))})}),q=this.isWidgetMessage(Z)?Z.widget:new Q1({text:new k(Y.description,new g({color:Q.colors.foreground})),selectable:!0}),G=new I0({child:new bJ({child:new c1({padding:C1.symmetric(1,0),child:new K0({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new I0({child:new C4({controller:this.scrollController,autofocus:!0,child:q})}),new j5({controller:this.scrollController,thumbColor:Q.app.scrollbarThumb,trackColor:Q.app.scrollbarTrack,getScrollInfo:()=>{let H=this.scrollController.maxScrollExtent,F=this.scrollController.offset,z=this.getViewportHeight(),U=H+z;return{totalContentHeight:Math.max(U,0),viewportHeight:Math.max(z,1),scrollOffset:Math.max(F,0)}}})]})})})}),W=new c1({padding:C1.symmetric(1,0),child:new Q1({text:(()=>{if(this.widget.props.onRetry)return new k("",void 0,[new k("Press ",new g({color:Q.colors.foreground,dim:!0})),new k("R",new g({color:Q.app.keybind})),new k(" to retry, ",new g({color:Q.colors.foreground,dim:!0})),new k("Esc",new g({color:Q.app.keybind})),new k(" to cancel",new g({color:Q.colors.foreground,dim:!0}))]);let H=this.resolveFooterStyle(this.widget.props.message);if(H==="none")return new k("",new g({color:Q.colors.foreground,dim:!0}));if(H==="help"){let F=new g({color:Q.app.keybind}),z=new g({color:Q.colors.foreground,dim:!0});return new k("",z,[new k("Press ",z),new k("Escape",F),new k(" to close • Use ",z),new k("↑↓",F),new k(" or ",z),new k("j/k",F),new k(" to scroll",z)])}return new k("Press any key to close",new g({color:Q.colors.foreground,dim:!0,italic:!0}))})()})});return new b6({onKey:(H)=>{if(this.widget.props.onRetry&&H.key==="r")return this.widget.props.onRetry(),"handled";if(H.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 c1({decoration:{border:V,color:Q.colors.background},padding:C1.all(1),child:new b1({mainAxisAlignment:"center",children:[K,new I1({height:1}),G,W]})})})}}class su1 extends m0{build(J){let Q=h1.of(J),{colors:Z,app:Y}=Q;return new s0({child:new Q1({text:new k("",void 0,[new k(`✓ Thread Shared
8519
8519
 
8520
8520
  `,new g({color:Y.toolSuccess,bold:!0})),new k(`This thread has been shared with Amp support for debugging and bug prioritization.
8521
8521
  `,new g({color:Z.foreground})),new k(`This is not a support request.
@@ -8911,7 +8911,7 @@ ${X}`,Q);this.line=Z,this.column=Y,this.codeblock=X}}/*!
8911
8911
 
8912
8912
  To use Sonnet 4.5, use large mode instead: amp --mode large
8913
8913
  Learn more: https://ampcode.com/news/large-mode
8914
- `),process.exit(1);if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")DQ("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")DQ("experimental.agentMode",Q.mode);if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli")DQ("systemPrompt",Q.systemPrompt)}function Rg8(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function jg8(J){try{let Q=new URL(J);return Q.hostname==="localhost"||Q.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function OJ1(J){let Y=jg8(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 $6(`Couldn't connect to the Amp server at ${J}.`,1,Y)}var qO6=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??MX,description:`Custom settings file path (overrides the default location ${MX})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(T).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${nL})`},{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:b7(),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:"useSonnet",long:"use-sonnet",type:"flag",description:(J)=>J?"Use Claude Sonnet 4.5 instead of Claude Opus 4.6":"Use default model (Claude Opus 4.6)",hidden:!0},{name:"mode",long:"mode",short:"m",type:"option",default:QN.SMART.key,description:`Set the agent mode (${TY().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:TY().map((J)=>J.mode).concat("large","deep")},{name:"dtw",long:"dtw",type:"switch",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text to append (SDK use only)",hidden:!0}],GO6=(J)=>("deprecated"in J)&&J.deprecated===!0,Eg8=(J)=>("hidden"in J)&&J.hidden===!0,Pg8=(J)=>("default"in J),Ig8=(J)=>("default"in J)?J.default:void 0;function Cg8(J,Q){let Z=Q.args[0],Y=Q.commands.map((V)=>V.name());if(Z&&!Z.includes(" ")&&Z.length<30&&!/[./\\]/.test(Z)){let V=Y.filter((q)=>Z.includes(q)||q.includes(Z)),K="Run amp --help for a list of available commands.";if(V.length>0)K=`Did you mean: ${V.join(", ")}? Or run amp --help for all commands.`;throw new $6(g8.unknownCommand(Z),1,K)}}var FO6=null;function q77(){return FO6}async function wp(J){return{...J,getThreadEnvironment:UU,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new S$(J.fileSystem),generateThreadTitle:XI,deleteThread:(Q)=>J.threadService.delete(Q),getServerStatus:()=>wZ(J.configService)}}var AJ1=U0.file(Lg8.homedir()),Tp1=process.env.XDG_CONFIG_HOME?U0.file(process.env.XDG_CONFIG_HOME):G0.joinPath(AJ1,".config");function Tg8(J){return H96({playNotificationSound:async(Q)=>{if(J.useNotificationsForService){W96(Q);let Z=b91(),Y=Tx1();if((!Z||Y||MY6())&&J.config.settings["notifications.system.enabled"]!==!1){if(Q==="idle")process.stdout.write(gW("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Q==="requires-user-input")process.stdout.write(gW("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(b91()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function t5(J,Q){aM0("0.0.1771286655-gbfdeba");let Z=ea({storage:J.settings,secretStorage:J.secrets,workspaceRoots:k1.of([U0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:AJ1,userConfigDir:Tp1});BY6(Z);let Y=await Z.getLatest();T.debug("Global configuration initialized",{settingsKeys:Object.keys(Y.settings)});let{toolService:X,dispose:V}=$96({configService:Z}),K=new Map,q=()=>K.clear(),G=new iL1(Z,J.settings.getWorkspaceRootPath()),W=dv0({configService:Z,filesystem:r4}),H=Ok0({configService:Z,trustStore:G,skillMCPServers:W.skillMCPServers,createOAuthProvider:async(_,x,b)=>{let h=`${_}:${x}`,y=K.get(h);if(y)return T.debug("Reusing existing OAuth provider for server",{serverName:_,serverUrl:x}),y;T.debug("Creating OAuth provider for server",{serverName:_,serverUrl:x});let f=(async()=>{let m=new cN(J.secrets),l=await m.getClientInfo(_,x),u=b?.scopes??l?.scopes,a=fQ6();T.info("OAuth headless mode check",{useHeadless:a,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:o4.isTTY});let d;if(a)d=J.executeMode?bQ6():vQ6(_);let r=new HL1({storage:m,serverName:_,serverUrl:x,clientId:b?.clientId??l?.clientId,clientSecret:b?.clientSecret??l?.clientSecret,authUrl:b?.authUrl??l?.authUrl,tokenUrl:b?.tokenUrl??l?.tokenUrl,scopes:u,headlessAuthHandler:d});return T.debug("OAuth provider created",{serverName:_,serverUrl:x,hasManualClientId:!!(b?.clientId??l?.clientId),willUseDCR:!(b?.clientId??l?.clientId),scopes:u,headlessMode:a,executeMode:J.executeMode}),r})();return K.set(h,f),f}}),F=A41({configService:Z,filesystem:r4,spawn:ch}),z;if(J.executeMode){let _=await w66({toolService:X,providers:[H,F],initialTimeout:15000});z=_.registrations;for(let[x,b]of _.initErrors)T.warn(`${x} provider initialization slow or failed:`,b)}else z=k_1({toolService:X,providers:[H,F]});if(Q.jetbrains)MN("JetBrains");else if(Q.ide&&DZ6())MN("VS Code");else if(Q.ide&&BZ6())MN("Neovim");else if(Q.ide&&Mg8()){let _=IG.find((x)=>x.listConfigs().length>0);if(_){let x=Zo(_.ideName);if(x)MN(x)}}if(J.executeMode)oM0(!0);let U,D=W5.status.pipe(N0((_)=>Boolean(_.connected&&_.authenticated)),I6()).subscribe((_)=>{if(_){if(!U)U=X.registerTool(N66)}else U?.dispose(),U=void 0}),B;if(!J.executeMode){let _=await J.settings.get("fuzzy.alwaysIncludePaths")??[];B=new Q91(process.cwd(),{alwaysIncludePaths:_},!0)}else B=new class extends Q91{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};{let _=await J.secrets.get("apiKey",J.ampURL);if(T.info("API key lookup before login",{found:Boolean(_),ampURL:J.ampURL}),!_){o4.write(`No API key found. Starting login flow...
8914
+ `),process.exit(1);if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")DQ("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")DQ("experimental.agentMode",Q.mode);if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli")DQ("systemPrompt",Q.systemPrompt)}function Rg8(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function jg8(J){try{let Q=new URL(J);return Q.hostname==="localhost"||Q.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function OJ1(J){let Y=jg8(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 $6(`Couldn't connect to the Amp server at ${J}.`,1,Y)}var qO6=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??MX,description:`Custom settings file path (overrides the default location ${MX})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(T).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${nL})`},{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:b7(),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:"useSonnet",long:"use-sonnet",type:"flag",description:(J)=>J?"Use Claude Sonnet 4.5 instead of Claude Opus 4.6":"Use default model (Claude Opus 4.6)",hidden:!0},{name:"mode",long:"mode",short:"m",type:"option",default:QN.SMART.key,description:`Set the agent mode (${TY().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:TY().map((J)=>J.mode).concat("large","deep")},{name:"dtw",long:"dtw",type:"switch",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text to append (SDK use only)",hidden:!0}],GO6=(J)=>("deprecated"in J)&&J.deprecated===!0,Eg8=(J)=>("hidden"in J)&&J.hidden===!0,Pg8=(J)=>("default"in J),Ig8=(J)=>("default"in J)?J.default:void 0;function Cg8(J,Q){let Z=Q.args[0],Y=Q.commands.map((V)=>V.name());if(Z&&!Z.includes(" ")&&Z.length<30&&!/[./\\]/.test(Z)){let V=Y.filter((q)=>Z.includes(q)||q.includes(Z)),K="Run amp --help for a list of available commands.";if(V.length>0)K=`Did you mean: ${V.join(", ")}? Or run amp --help for all commands.`;throw new $6(g8.unknownCommand(Z),1,K)}}var FO6=null;function q77(){return FO6}async function wp(J){return{...J,getThreadEnvironment:UU,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new S$(J.fileSystem),generateThreadTitle:XI,deleteThread:(Q)=>J.threadService.delete(Q),getServerStatus:()=>wZ(J.configService)}}var AJ1=U0.file(Lg8.homedir()),Tp1=process.env.XDG_CONFIG_HOME?U0.file(process.env.XDG_CONFIG_HOME):G0.joinPath(AJ1,".config");function Tg8(J){return H96({playNotificationSound:async(Q)=>{if(J.useNotificationsForService){W96(Q);let Z=b91(),Y=Tx1();if((!Z||Y||MY6())&&J.config.settings["notifications.system.enabled"]!==!1){if(Q==="idle")process.stdout.write(gW("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Q==="requires-user-input")process.stdout.write(gW("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(b91()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}async function t5(J,Q){aM0("0.0.1771302820-ga4c3d4");let Z=ea({storage:J.settings,secretStorage:J.secrets,workspaceRoots:k1.of([U0.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:AJ1,userConfigDir:Tp1});BY6(Z);let Y=await Z.getLatest();T.debug("Global configuration initialized",{settingsKeys:Object.keys(Y.settings)});let{toolService:X,dispose:V}=$96({configService:Z}),K=new Map,q=()=>K.clear(),G=new iL1(Z,J.settings.getWorkspaceRootPath()),W=dv0({configService:Z,filesystem:r4}),H=Ok0({configService:Z,trustStore:G,skillMCPServers:W.skillMCPServers,createOAuthProvider:async(_,x,b)=>{let h=`${_}:${x}`,y=K.get(h);if(y)return T.debug("Reusing existing OAuth provider for server",{serverName:_,serverUrl:x}),y;T.debug("Creating OAuth provider for server",{serverName:_,serverUrl:x});let f=(async()=>{let m=new cN(J.secrets),l=await m.getClientInfo(_,x),u=b?.scopes??l?.scopes,a=fQ6();T.info("OAuth headless mode check",{useHeadless:a,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:o4.isTTY});let d;if(a)d=J.executeMode?bQ6():vQ6(_);let r=new HL1({storage:m,serverName:_,serverUrl:x,clientId:b?.clientId??l?.clientId,clientSecret:b?.clientSecret??l?.clientSecret,authUrl:b?.authUrl??l?.authUrl,tokenUrl:b?.tokenUrl??l?.tokenUrl,scopes:u,headlessAuthHandler:d});return T.debug("OAuth provider created",{serverName:_,serverUrl:x,hasManualClientId:!!(b?.clientId??l?.clientId),willUseDCR:!(b?.clientId??l?.clientId),scopes:u,headlessMode:a,executeMode:J.executeMode}),r})();return K.set(h,f),f}}),F=A41({configService:Z,filesystem:r4,spawn:ch}),z;if(J.executeMode){let _=await w66({toolService:X,providers:[H,F],initialTimeout:15000});z=_.registrations;for(let[x,b]of _.initErrors)T.warn(`${x} provider initialization slow or failed:`,b)}else z=k_1({toolService:X,providers:[H,F]});if(Q.jetbrains)MN("JetBrains");else if(Q.ide&&DZ6())MN("VS Code");else if(Q.ide&&BZ6())MN("Neovim");else if(Q.ide&&Mg8()){let _=IG.find((x)=>x.listConfigs().length>0);if(_){let x=Zo(_.ideName);if(x)MN(x)}}if(J.executeMode)oM0(!0);let U,D=W5.status.pipe(N0((_)=>Boolean(_.connected&&_.authenticated)),I6()).subscribe((_)=>{if(_){if(!U)U=X.registerTool(N66)}else U?.dispose(),U=void 0}),B;if(!J.executeMode){let _=await J.settings.get("fuzzy.alwaysIncludePaths")??[];B=new Q91(process.cwd(),{alwaysIncludePaths:_},!0)}else B=new class extends Q91{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};{let _=await J.secrets.get("apiKey",J.ampURL);if(T.info("API key lookup before login",{found:Boolean(_),ampURL:J.ampURL}),!_){o4.write(`No API key found. Starting login flow...
8915
8915
  `);let x=await _g8(J),b=await J.secrets.get("apiKey",J.ampURL);if(T.info("Login flow completed",{success:x,storedKeyPresent:Boolean(b),ampURL:J.ampURL}),!x)await aL(),process.exit(1)}}{let _=await Z.getLatest(),x=_.settings.url,b=_.secrets.isSet?.[x];T.info("Config secrets state after login",{configURL:x,apiKeySet:b?.apiKey??!1})}let N=S0(wZ(Z).pipe($9((_)=>_!=="pending"))),w=await ov0({isDevelopment:!1}),L=await N;T.info("Server status resolved",{status:"ready",isAuthenticated:g5(L),isError:eN(L),errorMessage:eN(L)?L.error.message:void 0});let O=new L_1(w,Z),M=new w_1(w,{lazy:!0});T.info("Starting Amp background services");let A=H16({threadService:O,threadHistoryService:M,configService:Z,isExtensionDevelopment:!1}),R;W5.status.subscribe((_)=>{R=_});let j=new WD1({workspaceRoots:[U0.file(process.cwd())],getCurrentFile:()=>{if(!R?.openFile)return;try{return U0.parse(R.openFile)}catch(_){T.warn("Failed to parse current file URI",{uri:R.openFile,error:_});return}},getOpenFiles:()=>{if(!R?.visibleFiles?.length)return[];let _=R.openFile;return R.visibleFiles.filter((x)=>x!==_).map((x)=>{try{return U0.parse(x)}catch(b){return T.warn("Failed to parse visible file URI",{uri:x,error:b}),null}}).filter((x)=>x!==null)}}),P=new kx1,C={codebaseContextService:j,configService:Z,toolService:X,mcpService:H,skillService:W,toolboxService:F,trustStore:G,threadService:O,threadHistoryService:M,threadSyncService:A,threadStorage:w,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:B,fileSystem:Q.jetbrains||Q.ide?ck0:r4,terminal:P,serverStatus:L};return{...C,async asyncDispose(){if(C.mcpService.hasAuthenticatingClients())T.info("Waiting for OAuth authentication to complete before exit..."),await C.mcpService.waitForAuthentication();for(let _ of z.values())_.dispose();await C.mcpService.dispose(),q(),await C.threadService.asyncDispose(),C.configService.unsubscribe(),V(),C.fuzzyServer.dispose(),C.threadSyncService.dispose(),C.settingsStorage[Symbol.dispose](),D.unsubscribe(),U?.dispose()}}}async function _g8(J){if(!J.executeMode){if(!await $x1("Would you like to log in to Amp? [(y)es, (n)o]: "))return o4.write(`Login cancelled. Run the command again to retry.
8916
8916
  `),!1}return await zO6(J)}async function zO6(J){let Q=Bg8(32).toString("hex"),Z=await Xx1(J.ampURL,Q),Y=new AbortController;try{await HK(Z,Y.signal)}catch(V){T.error("Error opening browser",{error:V})}let X=await Xx1(J.ampURL,Q,!1);o4.write(`If your browser does not open automatically, visit:
8917
8917
 
@@ -8919,7 +8919,7 @@ ${Z0.blue.bold(X)}
8919
8919
 
8920
8920
  `);try{return await uZ6(J.ampURL,Q,J.secrets,Y),o4.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(V){return T.error("Login failed",{error:V}),m7.write(`
8921
8921
  Login failed: ${V instanceof Error?V.message:String(V)}
8922
- `),!1}}function Sg8(){let J=new qU().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((U)=>{if(U.code==="commander.help"||U.code==="commander.version"||U.exitCode===0)rL(),process.exit(0);let D=U.originalError??U;c81(D)}),J.option("-V, --version","Print the version number and exit",()=>{let D;try{D=`, ${gF(new Date("2026-02-17T00:09:39.809Z"))} ago`}catch{}o4.write(`0.0.1771286655-gbfdeba (released 2026-02-17T00:09:39.809Z${D??""})
8922
+ `),!1}}function Sg8(){let J=new qU().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((U)=>{if(U.code==="commander.help"||U.code==="commander.version"||U.exitCode===0)rL(),process.exit(0);let D=U.originalError??U;c81(D)}),J.option("-V, --version","Print the version number and exit",()=>{let D;try{D=`, ${gF(new Date("2026-02-17T04:39:22.928Z"))} ago`}catch{}o4.write(`0.0.1771302820-ga4c3d4 (released 2026-02-17T04:39:22.928Z${D??""})
8923
8923
  `),process.exit(0)}),J.addHelpText("after",FZ6()),J.configureHelp({formatHelp:zZ6}),J.command("logout").description("Log out by removing stored API key").action(async(U,D)=>{let B=D.optsWithGlobals(),N=await Y9(B);await vg8(N)}),J.command("login").description("Log in to Amp").addHelpText("after","If AMP_URL is set during login, it will be persisted to global settings for future CLI invocations, though AMP_URL will continue to take precedence.").action(async(U,D)=>{let B=D.optsWithGlobals(),N=await Y9(B);await xg8(N,await gy1(B,N.settings))}),J.command("git-credential-helper [action]",{hidden:!0}).summary("Git credential helper for GitHub").description("Internal: implements the git credential helper protocol. Used inside sandboxes to authenticate git operations with GitHub.").action(async(U,D,B)=>{let N=B.optsWithGlobals(),w=await Y9(N);await RQ6(U??"get",w.ampURL,w.secrets),process.exit(process.exitCode??0)}),J.command("sign-commit",{hidden:!0}).summary("Git commit signing helper").description("Internal: implements the gpg signing interface for git commit signing. Used inside sandboxes as gpg.program.").allowUnknownOption().action(async(U,D)=>{let B=D.optsWithGlobals(),N=await Y9(B);await jQ6(N.ampURL,N.secrets),process.exit(process.exitCode??0)}),J.command("dtw-curl [threadId] [action] [message...]",{hidden:!0}).summary("DTW helper").description("Internal: helper for DTW one-shot commands.").addHelpText("after",`
8924
8924
  Actions:
8925
8925
  add-message <message> Send a user message and wait for message_added
@@ -8968,12 +8968,12 @@ See: https://ampcode.com/news/stick-a-fork-in-it
8968
8968
  amp threads handoff --goal "Fix the remaining tests" # Uses last thread
8969
8969
 
8970
8970
  By default, opens the new thread in the TUI. Use --print to just print the thread ID.`).option("-g, --goal <goal>","Goal/prompt for the handoff (alternative to stdin)").option("-p, --print","Print the thread ID instead of opening the TUI").action(async(U,D,B)=>{let N=B.optsWithGlobals(),w=await Y9(N);await dg8(N,w,U??null,D.goal,!D.print,B)}),Z.command("markdown <threadId>").alias("md").summary("Render thread as markdown").description("Render a thread as markdown. This outputs the entire conversation history in a readable markdown format.").action(async(U,D,B)=>{let N=B.optsWithGlobals(),w=await Y9(N);await ug8(N,w,U,B)}),Z.command("export <threadId>",{hidden:!0}).summary("Export a thread as JSON").description("Export a thread as JSON. This outputs the full thread payload.").action(async(U,D,B)=>{let N=B.optsWithGlobals(),w=await Y9(N);await gg8(N,w,U,B)}),Z.command("replay <threadId>").alias("p").summary("Replay a thread").description("Replay a thread by downloading it and playing through all interactions. User messages are simulated with variable typing speed.").option("--wpm <wpm>","Typing speed in words per minute (default: 120)","120").option("--no-typing","Disable typing simulation and display messages instantly").option("--message-delay <ms>","Delay between messages in milliseconds (default: 1000)","1000").option("--tool-progress-delay <ms>","Delay to show tool in-progress state in milliseconds (default: 800)","800").option("--exit-delay <seconds>","Delay in seconds before exiting after replay completes (default: 3)").option("--no-indicator","Hide the replay progress indicator").action(async(U,D,B)=>{let N=B.optsWithGlobals(),w=await Y9(N);await mg8(N,w,U,D,B)}),M56(Z,Y9,g7,t5,jJ1,UH,p8),NX6(J,async(U,D)=>{let B=await Y9(D);g7(U,D);let N=await t5(B,D);return{context:B,mcpService:N.mcpService,toolService:N.toolService,toolServices:N.toolService,skillService:N.skillService,toolboxService:N.toolboxService,configService:N.configService,cleanupTerminal:rL,asyncDispose:N.asyncDispose.bind(N)}}),zY6(J,async(U,D)=>{let B=await Y9(D);return g7(U,D),{configService:ea({storage:B.settings,secretStorage:B.secrets,workspaceRoots:k1.of([U0.file(process.cwd())]),defaultAmpURL:B.ampURL,homeDir:AJ1,userConfigDir:Tp1}),asyncDispose:async()=>{}}}),VY6(J,async(U)=>{let D=U.optsWithGlobals(),B=await Y9(D);g7(U,D);let N=await t5(B,D);return{toolService:N.toolService,mcpService:N.mcpService,configService:N.configService,skillService:N.skillService,cleanupTerminal:rL,asyncDispose:N.asyncDispose.bind(N)}}),HY6(J,async(U)=>{let D=U.optsWithGlobals(),B=await Y9(D);g7(U,D);let N=await t5(B,D);return{settings:B.settings,configService:N.configService,skillService:N.skillService,asyncDispose:N.asyncDispose.bind(N)}}),ZY6(J,async(U)=>{let D=U.optsWithGlobals();return await Y9(D)}),lZ6(J,async(U)=>{let D=await Y9(U);return{settings:D.settings,secretStorage:D.secrets,getThreadDeps:async(B)=>{g7(B,U);let N=await t5(D,U);return{mcpService:N.mcpService,settings:D.settings,asyncDispose:N.asyncDispose.bind(N)}}}}),gB6(J,Y9);function V(U,D,B){let w=typeof U.description==="string"?U.description:B===void 0?U.description(!0):U.description(B),L=new qq(D,w),O=Ig8(U);if(O)L.default(O);if(L.hidden=Eg8(U)||GO6(U),"choices"in U)L.choices([...U.choices]);return L}for(let U of qO6){switch(U.type){case"flag":{J.addOption(V(U,`--${U.long}`)),J.addOption(V(U,`--no-${U.long}`,!1));break}case"switch":{J.addOption(V(U,`--${U.long}`,!0));break}case"optional-option":{J.addOption(V(U,`${"short"in U?`-${U.short}, `:""}--${U.long} [value]`));break}default:{J.addOption(V(U,`${"short"in U?`-${U.short}, `:""}--${U.long} <value>`));break}}if("aliases"in U&&U.aliases)for(let D of U.aliases){let B=new qq(`--${D}`,U.description);B.hidden=!0,B.implies({[U.name]:!0}),J.addOption(B)}}let K=new qq("-x, --execute [message]","Use execute mode, optionally with user message. In execute mode, agent will execute provided prompt (either as argument, or via stdin). Only last assistant message is printed. Enabled automatically when redirecting stdout.").default(!1);J.addOption(K);let q=new qq("--stream-json","When used with --execute, output in Claude Code-compatible stream JSON format instead of plain text.").default(!1);J.addOption(q);let G=new qq("--stream-json-thinking","Include thinking blocks in stream JSON output (non-Claude Code extension). Implies --stream-json.").default(!1);J.addOption(G);let W=new qq("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(W);let H=new qq("--stats","When used with --execute, output JSON with both result and token usage data (for /evals).").default(!1).hideHelp(!0);J.addOption(H);let F=new qq("--archive","When used with --execute, archive the thread after the command finishes.").default(!1);J.addOption(F);let z=new qq("-l, --label <label>","When used with --execute, add a label to the thread. Can be used multiple times.").argParser((U,D)=>{if(D===void 0)return[U];return[...D,U]});return J.addOption(z),J.action(async(U,D)=>{let B=U,N=await Y9(B);if(Object.keys(B).forEach((w)=>{let L=qO6.find((O)=>O.name===w);if(L&&GO6(L)&&!Pg8(L))m7.write(Z0.yellow(`Warning: '--${w}' flag is deprecated
8971
- `))}),D.args.length>0)Cg8(N,D);await RJ1(N,B,D)}),fZ6(J),J}async function LJ1(J,Q){let{thread:Z,visibility:Y}=Q,X=Z?.id??i7(),V=await wp(J);if(Z)await J.threadStorage.set(X,Z);let K=await l5.getOrCreateForThread(V,X),q=await J.threadStorage.get(X);if(Q.agentMode&&!q?.agentMode&&(!q||G5(q)===0))await K.handle({type:"agent-mode",mode:Q.agentMode});if(Y)await J.threadSyncService.updateThreadMeta(X,au(Y));let G=J.threadService.observe(X).subscribe(async(W)=>{if(T5(W,"assistant")){let F=await Nq();await wq({...F,lastThreadId:X}),G.unsubscribe()}});return await K.resume(),K}async function RJ1(J,Q,Z){let Y,X=null;if(Q.streamJsonInput)Y="";else if(typeof Q.execute==="string"){Y=Q.execute;let l=(await sI()).trimEnd();if(l)X=l}else Y=(await sI()).trimEnd();let V=!!Q.streamJson||!!Q.streamJsonThinking;if(V&&!J.executeMode)throw new $6("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(Q.streamJsonInput&&!J.executeMode)throw new $6("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.streamJsonInput&&!V)throw new $6("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.stats&&!J.executeMode)throw new $6("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(Q.archive&&!J.executeMode)throw new $6("The --archive flag requires --execute mode",1,'Use: amp --execute "your message" --archive');if(Q.streamJsonInput&&typeof Q.execute==="string"&&Q.execute.trim()!=="")throw new $6("Do not provide a message argument when using --stream-json-input",1,`Supply messages via stdin JSONL instead: echo '{"type":"user","message":{"role":"user","content":[{"type":"text","text":"your message"}]}}' | amp --execute --stream-json --stream-json-input`);if(J.executeMode&&Y===""&&!Q.streamJsonInput&&!Q.headless)throw new $6("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"
8971
+ `))}),D.args.length>0)Cg8(N,D);await RJ1(N,B,D)}),fZ6(J),J}async function LJ1(J,Q){let{thread:Z,visibility:Y}=Q,X=Z?.id??i7(),V=await wp(J);if(Z)await J.threadStorage.set(X,Z);let K=await l5.getOrCreateForThread(V,X),q=await J.threadStorage.get(X);if(Q.agentMode&&!q?.agentMode&&(!q||G5(q)===0))await K.handle({type:"agent-mode",mode:Q.agentMode});if(Y&&Z)await J.threadSyncService.updateThreadMeta(X,au(Y));let G=J.threadService.observe(X).subscribe(async(W)=>{if(T5(W,"assistant")){let F=await Nq();await wq({...F,lastThreadId:X}),G.unsubscribe()}});return await K.resume(),K}async function RJ1(J,Q,Z){let Y,X=null;if(Q.streamJsonInput)Y="";else if(typeof Q.execute==="string"){Y=Q.execute;let l=(await sI()).trimEnd();if(l)X=l}else Y=(await sI()).trimEnd();let V=!!Q.streamJson||!!Q.streamJsonThinking;if(V&&!J.executeMode)throw new $6("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(Q.streamJsonInput&&!J.executeMode)throw new $6("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.streamJsonInput&&!V)throw new $6("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.stats&&!J.executeMode)throw new $6("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(Q.archive&&!J.executeMode)throw new $6("The --archive flag requires --execute mode",1,'Use: amp --execute "your message" --archive');if(Q.streamJsonInput&&typeof Q.execute==="string"&&Q.execute.trim()!=="")throw new $6("Do not provide a message argument when using --stream-json-input",1,`Supply messages via stdin JSONL instead: echo '{"type":"user","message":{"role":"user","content":[{"type":"text","text":"your message"}]}}' | amp --execute --stream-json --stream-json-input`);if(J.executeMode&&Y===""&&!Q.streamJsonInput&&!Q.headless)throw new $6("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"
8972
8972
  Or pipe via stdin: echo "your message" | amp --execute`);g7(Z,Q);let K=await t5(J,Q);FO6=K;let q=await wp(K),{serverStatus:G}=K;if(eN(G)){let l=gI(Error(G.error.message));if(l.message===g8.networkOffline||l.message===g8.networkTimeout)throw OJ1(J.ampURL);throw new $6(g8.invalidAPIKey,1)}let W=g5(G)?G.user.email:void 0,H=g5(G)?G.features:[],F=g5(G)?G.workspace:null,z=Rg8(W),U=g5(G)?{...G.user,features:H,team:F??void 0}:null,D=nu(Q,U);if(D instanceof Error)p8(D.message);if((J.executeMode||V)&&I5(Q.mode)&&!z)throw new $6(`Execute mode is not permitted with --mode '${Q.mode}'`,1);if(Q.headless){if(!W||!SR(W))throw new $6("Headless DTW mode is only available for Amp employees",1);let l=await K.secretStorage.get("apiKey",J.ampURL);if(!l)throw new $6("API key required for headless mode. Please run `amp login` first.",1);let u=typeof Q.headless==="string"&&Q.headless!=="true"?Q.headless:void 0;if(u&&!J5(u))throw new $6(`Invalid thread ID: ${u}`,1);await xQ6({ampURL:J.ampURL,apiKey:l,workerUrl:process.env.AMP_WORKER_URL,workspaceRoot:process.cwd(),threadId:u,configService:K.configService,mcpService:K.mcpService,toolService:K.toolService,skillService:K.skillService,fileSystem:K.fileSystem}),await K.asyncDispose(),process.exit(0)}let B=async(l)=>{let u=await HO6(l,"utf-8"),a=JSON.parse(u);if(!J5(a.id))throw new $6(g8.invalidThreadId);let d=await oL(J.settings,process.cwd(),U,D);if(d instanceof Error)p8(d.message);return LJ1(K,{visibility:d,agentMode:Q.mode,thread:a})},N=async(l)=>{let u=Date.now(),[a,d]=await Promise.all([M4.getThreadLinkInfo({thread:l},{config:K.configService}),M4.getUserInfo({},{config:K.configService})]);if(T.info(`[fetchAndStartThread] Ownership check in ${Date.now()-u}ms`),a.ok&&d.ok){let r=a.result.creatorUserID,w1=d.result.id;if(r&&r!==w1&&!process.env.AMP_RESUME_OTHER_USER_THREADS_INSECURE)throw new $6(`Cannot resume thread created by another user.
8973
8973
 
8974
8974
  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.`)}},w=async(l,{nonBlockingOwnershipCheck:u=!1,onOwnershipError:a}={})=>{if(!J5(l))throw new $6(g8.invalidThreadId);let d=Date.now();if(T.info(`[fetchAndStartThread] Begin switch to thread ${l}`),u)N(l).catch((N1)=>{if(N1 instanceof $6){if(a){a(N1,l);return}mI(N1,l);return}T.warn("Failed to validate thread ownership in CLI, allowing to open",{error:N1})});else try{await N(l)}catch(N1){if(N1 instanceof $6)throw N1;T.warn("Failed to validate thread ownership in CLI, allowing to open",{error:N1})}let r=Date.now(),w1=await K.threadService.get(l)??void 0;T.info(`[fetchAndStartThread] Loaded thread in ${Date.now()-r}ms`),T.info(`[fetchAndStartThread] Loaded thread ${l}, agentMode: ${w1?.agentMode??"undefined"}`);let o=Date.now(),G1=await oL(J.settings,process.cwd(),U,D);if(G1 instanceof Error)p8(G1.message);let q1=await LJ1(K,{visibility:G1,agentMode:w1?void 0:Q.mode,thread:w1});return T.info(`[fetchAndStartThread] Started worker in ${Date.now()-o}ms (total ${Date.now()-d}ms)`),q1},L=async(l)=>{if(!W||!SR(W))throw new $6("DTW TUI mode is only available for Amp employees",1);let u=await K.secretStorage.get("apiKey",J.ampURL);T.info("[createDTWRuntime] Creating DTW provider",{threadId:l,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL,hasApiKey:Boolean(u)});let a;try{a=await RU.create({ampURL:J.ampURL,apiKey:u,configService:K.configService,threadId:l,workerUrl:process.env.AMP_WORKER_URL})}catch(d){throw T.error("[createDTWRuntime] Failed to create DTW provider",{threadId:l,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL,error:d}),d}T.info("[createDTWRuntime] Creating DTW runtime",{threadId:a.threadId});try{return await DC.create({provider:a,deps:{threadService:K.threadService,configService:K.configService,toolService:K.toolService,skillService:K.skillService,threadSyncService:K.threadSyncService,getThreadEnvironment:UU,fileChangeTrackerStorage:new S$(K.fileSystem),osFileSystem:K.fileSystem,deleteThread:(d)=>K.threadService.delete(d),generateThreadTitle:XI,mcpService:K.mcpService,ampURL:J.ampURL}})}catch(d){throw T.error("[createDTWRuntime] Failed to create DTW runtime",{threadId:a.threadId,error:d}),d}},O={threadService:K.threadService,workerDeps:q,createThread:async()=>{let l=await oL(J.settings,process.cwd(),U,D);if(l instanceof Error)p8(l.message);return LJ1(K,{visibility:l,agentMode:Q.mode})},switchToThread:(l,u)=>w(l,{nonBlockingOwnershipCheck:u?.nonBlockingOwnershipCheck??!1,onOwnershipError:u?.onOwnershipError})},M=async()=>{try{if(Q.dtw)return L(Q.threadId);if(Q.threadId){let l=await w(Q.threadId,{nonBlockingOwnershipCheck:Q.nonBlockingThreadOwnershipCheck??!1});return new MD(O,l)}else{let l=await oL(J.settings,process.cwd(),U,D);if(l instanceof Error)p8(l.message);let u=await LJ1(K,{visibility:l,agentMode:Q.mode});return new MD(O,u)}}catch(l){if(l instanceof $6)throw l;throw await mI(l,Q.threadId),Error("handleError should have called process.exit()")}};if(Q.format==="jsonl")m7.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
8975
- `),await aL(),process.exit(1);let A=(async()=>{try{let l=await K.configService.getLatest(),u=Si(l),a=await M4.getUserFreeTierStatus({},{config:K.configService,signal:AbortSignal.timeout(u)});if(a.ok)return T.info("User free tier status:",a),a.result}catch(l){throw T.error("Failed to fetch free tier status:",l),l}})(),R=await M(),j=Q.notifications!==void 0?Q.notifications:!J.executeMode,P=await K.configService.getLatest();if(Tg8({configService:K.configService,threadService:K.threadService,config:P,useNotificationsForService:j,threadViewStates$:()=>R.threadViewStates$}),J.executeMode){if(oZ6(K.mcpService,J.settings),!(R instanceof MD))throw new $6("Execute mode is not supported in DTW runtime",1);let l=R.getWorkerForExecuteMode();if(await qQ6({worker:l,threadID:l.threadID,userInput:Y,stdinInput:X,dependencies:K,streamJson:V,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:J.ampURL,isDogfooding:z,agentMode:Q.mode,labels:Q.label}),Q.archive)await M4.archiveThread({thread:l.threadID,archived:!0},{config:K.configService});await K.asyncDispose(),process.exit(0)}let C=!1,_=!1,x=!1;if(Q.jetbrains||Q.ide){await DA0();let l=PN({jetbrainsOnly:Q.jetbrains});if(l.length===0){if(Q.jetbrains)_=!await K.configService.get("jetbrains.skipInstall")}else if(l.length===1){let u=l[0];if(u)W5.selectConfig(u)}else x=!0}let b=w91("0.0.1771286655-gbfdeba",K.settingsStorage),h=new e61(K.threadStorage),y=new L91(K.mcpService,J.settings.getWorkspaceRootPath());if(Y)await R.sendMessage({content:[{type:"text",text:Y}]});let f=await Nq();T.info("Loaded session state:",f);let m={...f,launchCount:f.launchCount+1};wq(m);try{await Jm1({codebaseContextService:K.codebaseContextService,stdout:process.stdout,history:new a81,fuzzyServer:K.fuzzyServer,settingsStorage:K.settingsStorage,threadService:K.threadService,threadHistoryService:K.threadHistoryService,threadSyncService:K.threadSyncService,threadFuzzyIndexer:h,skillService:K.skillService,configService:K.configService,internalAPIClient:M4,ampURL:J.ampURL,runtime:R,ideClient:W5,mcpService:K.mcpService,toolboxService:K.toolboxService,mcpTrustHandler:y,showJetBrainsInstaller:_,showIdePicker:C,showIdePickerHint:x,openThreadSwitcher:Q.openThreadSwitcher,updateService:b,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:m,freeTierStatusPromise:A,workspace:F??null,features:H,isDogfooding:z,threadDependencies:K,initialAgentMode:Z.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,buildTimestamp:"2026-02-17T00:09:39.809Z"})}finally{await R.dispose?.()}await K.asyncDispose(),process.exit(0)}async function Y9(J){if(T.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)m7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
8976
- `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY;T.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await Ik0({get:async(q)=>{if(q!==KO6)return;try{let G=await HO6(Cp1,"utf-8");return JSON.parse(G).installationID}catch{return}},set:async(q,G)=>{if(q!==KO6)return;await Ng8(MJ1.dirname(Cp1),{recursive:!0}),await wg8(Cp1,JSON.stringify({installationID:G},null,2),{mode:384})}},{clientType:"cli",platform:vY()});rM0(Y);let X=await rQ6({...J,workspaceTrust:{current:!0,changes:xS},getHook:process.env.AMP_URL?(q,G)=>{if(q==="url")return Promise.resolve(process.env.AMP_URL);return G()}:void 0});if(J.mcpConfig){let q=await nZ6(J.mcpConfig);X=aZ6(X,q)}let V=MJ1.dirname(X.getSettingsFilePath());G96(lI,V);let K=await X.get("url","global");if(!K)K=C2;if(T.info("Resolved Amp URL",{ampURL:K,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!BF(K))T.info("Targeting custom Amp server",{ampURL:K});return X=uM0(X),{executeMode:Q,isTTY:Z,ampURL:K,settings:X,secrets:KY6(await gy1(J,X))}}function kg8(J){let Q={};for(let Z=0;Z<J.length;Z++){let Y=J[Z];if(Y?.startsWith("--")){let V=Y.slice(2).replace(/-([a-z])/g,(q,G)=>G.toUpperCase()),K=J[Z+1];if(K&&!K.startsWith("--"))Q[V]=K,Z++}}return Q}async function yg8(){let J=kg8(process.argv),Q=process.argv.includes("--headless")||process.argv.some((V)=>V.startsWith("--headless="));yJ6({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Q?Og8:void 0)});let Z=process.argv.includes("--no-color"),Y=process.argv.includes("--color"),X=process.stdout.isTTY&&process.stderr.isTTY;if(Z||!Y&&!X)Z0.level=0;if(Ag8(T),T.info("Starting Amp CLI.",{version:"0.0.1771286655-gbfdeba",buildTimestamp:"2026-02-17T00:09:39.809Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new $6(g8.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Sg8().parseAsync(process.argv)}K96().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await yg8().catch(mI)});async function xg8(J,Q){let Z=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Z)await J.settings.set("url",process.env.AMP_URL,"global"),o4.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
8975
+ `),await aL(),process.exit(1);let A=(async()=>{try{let l=await K.configService.getLatest(),u=Si(l),a=await M4.getUserFreeTierStatus({},{config:K.configService,signal:AbortSignal.timeout(u)});if(a.ok)return T.info("User free tier status:",a),a.result}catch(l){throw T.error("Failed to fetch free tier status:",l),l}})(),R=await M(),j=Q.notifications!==void 0?Q.notifications:!J.executeMode,P=await K.configService.getLatest();if(Tg8({configService:K.configService,threadService:K.threadService,config:P,useNotificationsForService:j,threadViewStates$:()=>R.threadViewStates$}),J.executeMode){if(oZ6(K.mcpService,J.settings),!(R instanceof MD))throw new $6("Execute mode is not supported in DTW runtime",1);let l=R.getWorkerForExecuteMode();if(await qQ6({worker:l,threadID:l.threadID,userInput:Y,stdinInput:X,dependencies:K,streamJson:V,streamJsonInput:!!Q.streamJsonInput,streamJsonThinking:!!Q.streamJsonThinking,stats:!!Q.stats,ampURL:J.ampURL,isDogfooding:z,agentMode:Q.mode,labels:Q.label}),Q.archive)await M4.archiveThread({thread:l.threadID,archived:!0},{config:K.configService});await K.asyncDispose(),process.exit(0)}let C=!1,_=!1,x=!1;if(Q.jetbrains||Q.ide){await DA0();let l=PN({jetbrainsOnly:Q.jetbrains});if(l.length===0){if(Q.jetbrains)_=!await K.configService.get("jetbrains.skipInstall")}else if(l.length===1){let u=l[0];if(u)W5.selectConfig(u)}else x=!0}let b=w91("0.0.1771302820-ga4c3d4",K.settingsStorage),h=new e61(K.threadStorage),y=new L91(K.mcpService,J.settings.getWorkspaceRootPath());if(Y)await R.sendMessage({content:[{type:"text",text:Y}]});let f=await Nq();T.info("Loaded session state:",f);let m={...f,launchCount:f.launchCount+1};wq(m);try{await Jm1({codebaseContextService:K.codebaseContextService,stdout:process.stdout,history:new a81,fuzzyServer:K.fuzzyServer,settingsStorage:K.settingsStorage,threadService:K.threadService,threadHistoryService:K.threadHistoryService,threadSyncService:K.threadSyncService,threadFuzzyIndexer:h,skillService:K.skillService,configService:K.configService,internalAPIClient:M4,ampURL:J.ampURL,runtime:R,ideClient:W5,mcpService:K.mcpService,toolboxService:K.toolboxService,mcpTrustHandler:y,showJetBrainsInstaller:_,showIdePicker:C,showIdePickerHint:x,openThreadSwitcher:Q.openThreadSwitcher,updateService:b,inspector:Q.inspector,inspectorPort:Q.inspectorPort,jetbrainsMode:Q.jetbrains,clientId:Q.clientId,sessionState:m,freeTierStatusPromise:A,workspace:F??null,features:H,isDogfooding:z,threadDependencies:K,initialAgentMode:Z.getOptionValueSourceWithGlobals("mode")==="cli"?Q.mode:void 0,buildTimestamp:"2026-02-17T04:39:22.928Z"})}finally{await R.dispose?.()}await K.asyncDispose(),process.exit(0)}async function Y9(J){if(T.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)m7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
8976
+ `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=process.stdout.isTTY&&process.stderr.isTTY;T.info("Execution mode resolved",{executeMode:Q,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await Ik0({get:async(q)=>{if(q!==KO6)return;try{let G=await HO6(Cp1,"utf-8");return JSON.parse(G).installationID}catch{return}},set:async(q,G)=>{if(q!==KO6)return;await Ng8(MJ1.dirname(Cp1),{recursive:!0}),await wg8(Cp1,JSON.stringify({installationID:G},null,2),{mode:384})}},{clientType:"cli",platform:vY()});rM0(Y);let X=await rQ6({...J,workspaceTrust:{current:!0,changes:xS},getHook:process.env.AMP_URL?(q,G)=>{if(q==="url")return Promise.resolve(process.env.AMP_URL);return G()}:void 0});if(J.mcpConfig){let q=await nZ6(J.mcpConfig);X=aZ6(X,q)}let V=MJ1.dirname(X.getSettingsFilePath());G96(lI,V);let K=await X.get("url","global");if(!K)K=C2;if(T.info("Resolved Amp URL",{ampURL:K,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!BF(K))T.info("Targeting custom Amp server",{ampURL:K});return X=uM0(X),{executeMode:Q,isTTY:Z,ampURL:K,settings:X,secrets:KY6(await gy1(J,X))}}function kg8(J){let Q={};for(let Z=0;Z<J.length;Z++){let Y=J[Z];if(Y?.startsWith("--")){let V=Y.slice(2).replace(/-([a-z])/g,(q,G)=>G.toUpperCase()),K=J[Z+1];if(K&&!K.startsWith("--"))Q[V]=K,Z++}}return Q}async function yg8(){let J=kg8(process.argv),Q=process.argv.includes("--headless")||process.argv.some((V)=>V.startsWith("--headless="));yJ6({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Q?Og8:void 0)});let Z=process.argv.includes("--no-color"),Y=process.argv.includes("--color"),X=process.stdout.isTTY&&process.stderr.isTTY;if(Z||!Y&&!X)Z0.level=0;if(Ag8(T),T.info("Starting Amp CLI.",{version:"0.0.1771302820-ga4c3d4",buildTimestamp:"2026-02-17T04:39:22.928Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new $6(g8.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Sg8().parseAsync(process.argv)}K96().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await yg8().catch(mI)});async function xg8(J,Q){let Z=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Z)await J.settings.set("url",process.env.AMP_URL,"global"),o4.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
8977
8977
  `);else if(!BF(J.ampURL))o4.write(`Logging in to ${new URL(J.ampURL).hostname}
8978
8978
  `);let Y=process.env.AMP_API_KEY;if(Y)o4.write(`API key found in environment variable, storing...
8979
8979
  `),await Q.set("apiKey",Y,J.ampURL),o4.write(`API key successfully stored.
@@ -8989,7 +8989,7 @@ This thread belongs to a different user and cannot be continued for security rea
8989
8989
  `)),await X.asyncDispose(),process.exit(0)}catch(V){await X.asyncDispose(),p8(`Failed to ${Y?"archive":"unarchive"} thread: ${V instanceof Error?V.message:String(V)}`)}}async function hg8(J,Q,Z){let Y=await t5(Q,J);try{let X=XM(Z);if(!X)$M(Z);await Y.threadService.delete(X),o4.write(Z0.green(`✓ Thread ${X} deleted
8990
8990
  `)),await Y.asyncDispose(),process.exit(0)}catch(X){await Y.asyncDispose(),p8(`Failed to delete thread: ${X instanceof Error?X.message:String(X)}`)}}async function ug8(J,Q,Z,Y){g7(Y,J);let X=await t5(Q,J);try{let V=XM(Z);if(!V)$M(Z);let q=await UH(V,X),G=ZU(q);o4.write(G+`
8991
8991
  `),await X.asyncDispose(),process.exit(0)}catch(V){await X.asyncDispose();let K=`Failed to render thread as markdown: ${V instanceof Error?V.message:String(V)}`;p8(K)}}async function gg8(J,Q,Z,Y){g7(Y,J);let X=await t5(Q,J);try{let V=XM(Z);if(!V)$M(Z);let q=await UH(V,X),G=JSON.stringify(q,null,2);o4.write(G+`
8992
- `),await X.asyncDispose(),process.exit(0)}catch(V){await X.asyncDispose();let K=`Failed to export thread: ${V instanceof Error?V.message:String(V)}`;p8(K)}}async function mg8(J,Q,Z,Y,X){g7(X,J);let V=await t5(Q,J);try{let K=await jJ1(Z),q=await UH(K,V),G=Y.typing!==!1,W=parseInt(Y.wpm||"120",10),H=parseInt(Y.messageDelay||"1000",10),F=parseInt(Y.toolProgressDelay||"800",10),z=parseInt(Y.exitDelay||"3",10)*1000,U=Y.indicator!==!1,D=await wp(V),B=q.id;await V.threadStorage.set(B,q);let N=await l5.getOrCreateForThread(D,B);await N.resume();let w=s61.fromWorker(N),L=new e61(V.threadStorage),O=new L91(V.mcpService,Q.settings.getWorkspaceRootPath()),M=w91("0.0.1771286655-gbfdeba",V.settingsStorage),A=A41({configService:V.configService,filesystem:r4,spawn:ch}),R=new MD({threadService:V.threadService,workerDeps:D,createThread:async()=>w,switchToThread:async()=>w},w);try{await Jm1({codebaseContextService:V.codebaseContextService,stdout:process.stdout,history:new a81,fuzzyServer:V.fuzzyServer,settingsStorage:V.settingsStorage,threadService:V.threadService,threadHistoryService:V.threadHistoryService,threadSyncService:V.threadSyncService,threadFuzzyIndexer:L,skillService:V.skillService,configService:V.configService,internalAPIClient:M4,ampURL:Q.ampURL,runtime:R,ideClient:W5,mcpService:V.mcpService,toolboxService:A,mcpTrustHandler:O,showJetBrainsInstaller:!1,updateService:M,isDogfooding:!1,replayMode:{thread:q,typingEnabled:G,baseWpm:W,messageDelayMs:H,toolProgressDelayMs:F,exitDelayMs:z,showIndicator:U},freeTierStatusPromise:Promise.resolve({canUseAmpFree:!0,isDailyGrantEnabled:!1}),features:[],buildTimestamp:"2026-02-17T00:09:39.809Z"})}finally{await R.dispose?.()}await V.asyncDispose(),process.exit(0)}catch(K){await V.asyncDispose(),await mI(K,Z)}}async function pg8(J,Q,Z,Y,X){g7(Y,J);let V=await t5(Q,J);try{let K=XM(Z);if(!K)$M(Z);let q=K,G=await M4.getUserInfo({},{config:V.configService}),W=G.ok?G.result:null,H=nu(J,W);if(!H&&!X)p8("Must specify either --visibility or --support");if(H&&X)p8("Cannot specify both --visibility and --support at the same time");if(H instanceof Error)p8(H.message);if(H)await V.threadSyncService.updateThreadMeta(q,au(H)),o4.write(Z0.green("✓ ")+`Thread ${q} visibility changed to ${H}.
8992
+ `),await X.asyncDispose(),process.exit(0)}catch(V){await X.asyncDispose();let K=`Failed to export thread: ${V instanceof Error?V.message:String(V)}`;p8(K)}}async function mg8(J,Q,Z,Y,X){g7(X,J);let V=await t5(Q,J);try{let K=await jJ1(Z),q=await UH(K,V),G=Y.typing!==!1,W=parseInt(Y.wpm||"120",10),H=parseInt(Y.messageDelay||"1000",10),F=parseInt(Y.toolProgressDelay||"800",10),z=parseInt(Y.exitDelay||"3",10)*1000,U=Y.indicator!==!1,D=await wp(V),B=q.id;await V.threadStorage.set(B,q);let N=await l5.getOrCreateForThread(D,B);await N.resume();let w=s61.fromWorker(N),L=new e61(V.threadStorage),O=new L91(V.mcpService,Q.settings.getWorkspaceRootPath()),M=w91("0.0.1771302820-ga4c3d4",V.settingsStorage),A=A41({configService:V.configService,filesystem:r4,spawn:ch}),R=new MD({threadService:V.threadService,workerDeps:D,createThread:async()=>w,switchToThread:async()=>w},w);try{await Jm1({codebaseContextService:V.codebaseContextService,stdout:process.stdout,history:new a81,fuzzyServer:V.fuzzyServer,settingsStorage:V.settingsStorage,threadService:V.threadService,threadHistoryService:V.threadHistoryService,threadSyncService:V.threadSyncService,threadFuzzyIndexer:L,skillService:V.skillService,configService:V.configService,internalAPIClient:M4,ampURL:Q.ampURL,runtime:R,ideClient:W5,mcpService:V.mcpService,toolboxService:A,mcpTrustHandler:O,showJetBrainsInstaller:!1,updateService:M,isDogfooding:!1,replayMode:{thread:q,typingEnabled:G,baseWpm:W,messageDelayMs:H,toolProgressDelayMs:F,exitDelayMs:z,showIndicator:U},freeTierStatusPromise:Promise.resolve({canUseAmpFree:!0,isDailyGrantEnabled:!1}),features:[],buildTimestamp:"2026-02-17T04:39:22.928Z"})}finally{await R.dispose?.()}await V.asyncDispose(),process.exit(0)}catch(K){await V.asyncDispose(),await mI(K,Z)}}async function pg8(J,Q,Z,Y,X){g7(Y,J);let V=await t5(Q,J);try{let K=XM(Z);if(!K)$M(Z);let q=K,G=await M4.getUserInfo({},{config:V.configService}),W=G.ok?G.result:null,H=nu(J,W);if(!H&&!X)p8("Must specify either --visibility or --support");if(H&&X)p8("Cannot specify both --visibility and --support at the same time");if(H instanceof Error)p8(H.message);if(H)await V.threadSyncService.updateThreadMeta(q,au(H)),o4.write(Z0.green("✓ ")+`Thread ${q} visibility changed to ${H}.
8993
8993
  `);if(X){await UH(q,V);let F=typeof X==="string"?X:void 0;await Fk0(V.threadService,q,V.configService,F),o4.write(Z0.green("✓ ")+`Thread ${q} has been shared with Amp support. These thread reports will be aggregated and analysed.
8994
8994
  `)}await V.asyncDispose(),process.exit(0)}catch(K){await V.asyncDispose(),p8(`Failed to update thread: ${K instanceof Error?K.message:String(K)}`)}}async function dg8(J,Q,Z,Y,X,V){g7(V,J);let K=await t5(Q,J);try{let q=await jJ1(Z);await UH(q,K);let G=Y;if(!G){let B=(await sI()).trimEnd();if(B)G=B}if(!G)p8(`Goal must be provided via stdin or --goal argument.
8995
8995
  Example: echo "Continue the auth work" | amp threads handoff T-xxx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1771286655-gbfdeba",
3
+ "version": "0.0.1771302820-ga4c3d4",
4
4
  "description": "CLI for Amp, the frontier coding agent.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {