@sourcegraph/amp 0.0.1759974740-g48b1d2 → 0.0.1759982493-gb3a8ef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +8 -8
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -5846,7 +5846,7 @@ See https://ampcode.com/manual#toolboxes`);return Q[0]||ew}function I56(J,Q){let
5846
5846
  `);J.command("use").argument("<tool-name>","The tool to invoke").summary("Invoke a tool with arguments or JSON input from stdin").description(Z).option("--only <field>","Extract only the specified field from the result").allowUnknownOption(!0).allowExcessArguments(!0).action(async function(X,Y,K){let q=K.optsWithGlobals(),G=await Q(K,q),z=0;await G.mcpService.initialized;let U=K.args.slice(1),W;if(j56()){let F=[];for await(let H of process.stdin)F.push(H);W=Buffer.concat(F).toString("utf-8").trim()}await R56({toolName:X,rawArgs:U,stdinInput:W,only:Y.only,threadDeps:G,stdout:process.stdout,stderr:process.stderr,exit:(F)=>{z=F}}),await G.asyncDispose(),G.cleanupTerminal(),process.exit(z)})}F0();r$();import{homedir as DQ9}from"node:os";import ju from"node:path";hO();J4();$N();P2();I3();r6();S0();function E56(J){let Q=J.trim();if(Q==="quit"||Q==="exit")return"/quit";return J}F0();$N();import T69 from"node:fs";import P56 from"node:path";function T56(J){let Q=J.trim().replace(/^["']|["']$/g,"");if(Q=Q.replace(/\\(.)/g,"$1"),!/\.(png|jpe?g|gif|webp)$/i.test(Q))return null;if(!P56.isAbsolute(Q))return null;return l.debug("Extracted image path",{original:J,extracted:Q}),Q}function C56(J){try{let Q=P56.extname(J).toLowerCase(),Z=hs1(Q);if(!Z)return l.warn("Unsupported image file extension",{ext:Q}),null;try{let X=T69.readFileSync(J);return C69(X,Z)}catch(X){l.error(`Failed to read image file ${J}:`,X)}}catch(Q){l.error("Error handling image file path",{imagePath:J,error:Q})}return null}function C69(J,Q){if(J.length>WO)return l.warn(`Image file too large: ${J.length} bytes (max: ${WO})`),null;return{type:"image",source:{type:"base64",data:J.toString("base64"),mediaType:Q}}}import{execSync as l56}from"node:child_process";import{rmdir as M89}from"node:fs/promises";import{tmpdir as V89}from"node:os";import i56 from"node:path";zO();F0();import{spawn as S69}from"node:child_process";import{promises as v69}from"node:fs";function S56(J){return J.kind==="executable"}function v56(J){return J.kind==="markdown"}var DH=50000,k56=300000;async function hx1(J,Q,Z,X={}){let{timeoutMs:Y=k56,signal:K}=X;try{let q=await Z.getCommand(J);if(!q)return{success:!1,output:"",error:`Command '${J}' not found`};if(!await Z.isCommandAvailable(J))return{success:!1,output:"",error:`Command '${J}' is not available for execution`};if(l.debug("Executing command",{commandName:J,filePath:q.filePath,args:Q}),v56(q))return await k69(q,Q);else if(S56(q))return await _69(q,Q,Y,K);else return{success:!1,output:"",error:"Unsupported command type"}}catch(q){return l.error("Failed to execute command",{commandName:J,error:q}),{success:!1,output:"",error:q instanceof Error?q.message:"Unknown error occurred"}}}async function k69(J,Q){try{if(Q.length>0)return{success:!1,output:"",error:"Markdown commands do not accept arguments"};let Z=await v69.readFile(J.filePath,"utf8");return{success:!0,output:(Z.length>DH?Z.slice(0,DH)+`
5847
5847
  ... (output truncated at ${DH} characters)`:Z).trim(),exitCode:0}}catch(Z){return{success:!1,output:"",error:Z instanceof Error?Z.message:"Failed to read markdown file"}}}async function _69(J,Q,Z=k56,X){return new Promise((Y)=>{let[K,q]=x69(J,Q);l.debug("Spawning command",{spawnCommand:K,spawnArgs:q.slice(0,10),filePath:J.filePath,timeoutMs:Z});let G=xs1(X),z=!1,U=setTimeout(()=>{z=!0,G.abort(),l.warn("Command execution timed out",{commandName:J.name,timeoutMs:Z})},Z),W=S69(K,q,{stdio:["pipe","pipe","pipe"],signal:G.signal,detached:!0}),F=[],H=[],B=0;W.stdout?.on("data",(M)=>{let V=M.toString();if(B+=V.length,B<=DH)F.push(V);else{let N=DH-(B-V.length);if(N>0)F.push(V.slice(0,N))}}),W.stderr?.on("data",(M)=>{let V=M.toString();if(B+=V.length,B<=DH)H.push(V);else{let N=DH-(B-V.length);if(N>0)H.push(V.slice(0,N))}}),W.on("close",(M)=>{if(clearTimeout(U),z){Y({success:!1,output:F.join(""),error:`Command timed out after ${Z}ms`,exitCode:void 0});return}if(G.signal.aborted){Y({success:!1,output:F.join(""),error:"The command was aborted",exitCode:M??void 0});return}let V=M===0||M===1,N=F.join(""),L=H.join(""),A=N;if(!V&&!N.trim()&&L.trim())A=L;else if(L.trim())A+=N?`
5848
5848
  ${L}`:L;if(B>DH)A+=`
5849
- ... (output truncated at ${DH} characters)`;Y({success:V,output:A.trim(),error:!V?L.trim()||"Command failed":void 0,exitCode:M??void 0})}),W.on("error",(M)=>{clearTimeout(U);let V=M.message;if(z)V=`Command timed out after ${Z}ms`;else if(M.message.includes("operation was aborted")||M.name==="AbortError")V="The command was aborted";Y({success:!1,output:F.join(""),error:V})})})}function x69(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return y69(Z,X?[...X]:null,Y,Q);else return b69(Z,X?[...X]:null,Y,Q)}function b69(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function y69(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];switch(Z.toLowerCase()){case".bat":case".cmd":return["cmd.exe",["/c",J,...X]];case".ps1":return["powershell.exe",["-ExecutionPolicy","Bypass","-File",J,...X]];case".exe":return[J,X];default:return[J,X]}}F0();r$();hO();J4();oV();iK();FW();r6();S0();import{mkdtemp as N89,readFile as L89,unlink as A89,writeFile as YU2}from"fs/promises";var v41={};L6(v41,{scrollUp:()=>Z89,scrollDown:()=>X89,link:()=>U89,image:()=>W89,iTerm:()=>F89,exitAlternativeScreen:()=>G89,eraseUp:()=>Q89,eraseStartLine:()=>e69,eraseScreen:()=>gx1,eraseLines:()=>o69,eraseLine:()=>y56,eraseEndLine:()=>t69,eraseDown:()=>J89,enterAlternativeScreen:()=>q89,cursorUp:()=>x56,cursorTo:()=>g69,cursorShow:()=>s69,cursorSavePosition:()=>c69,cursorRestorePosition:()=>l69,cursorPrevLine:()=>n69,cursorNextLine:()=>a69,cursorMove:()=>m69,cursorLeft:()=>b56,cursorHide:()=>r69,cursorGetPosition:()=>i69,cursorForward:()=>p69,cursorDown:()=>u69,cursorBackward:()=>d69,clearTerminal:()=>K89,clearScreen:()=>Y89,beep:()=>z89});import mx1 from"node:process";var S41=globalThis.window?.document!==void 0,Fz2=globalThis.process?.versions?.node!==void 0,Hz2=globalThis.process?.versions?.bun!==void 0,Bz2=globalThis.Deno?.version?.deno!==void 0,Dz2=globalThis.process?.versions?.electron!==void 0,Mz2=globalThis.navigator?.userAgent?.includes("jsdom")===!0,Vz2=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,Nz2=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,Lz2=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,Az2=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Tm=globalThis.navigator?.userAgentData?.platform,wz2=Tm==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",Rz2=Tm==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",Oz2=Tm==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",jz2=Tm==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),$z2=Tm==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var q2="\x1B[",Sm="\x1B]",RT="\x07",Cm=";",_56=!S41&&mx1.env.TERM_PROGRAM==="Apple_Terminal",f69=!S41&&mx1.platform==="win32",h69=S41?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:mx1.cwd,g69=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");if(typeof Q!=="number")return q2+(J+1)+"G";return q2+(Q+1)+Cm+(J+1)+"H"},m69=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");let Z="";if(J<0)Z+=q2+-J+"D";else if(J>0)Z+=q2+J+"C";if(Q<0)Z+=q2+-Q+"A";else if(Q>0)Z+=q2+Q+"B";return Z},x56=(J=1)=>q2+J+"A",u69=(J=1)=>q2+J+"B",p69=(J=1)=>q2+J+"C",d69=(J=1)=>q2+J+"D",b56=q2+"G",c69=_56?"\x1B7":q2+"s",l69=_56?"\x1B8":q2+"u",i69=q2+"6n",a69=q2+"E",n69=q2+"F",r69=q2+"?25l",s69=q2+"?25h",o69=(J)=>{let Q="";for(let Z=0;Z<J;Z++)Q+=y56+(Z<J-1?x56():"");if(J)Q+=b56;return Q},t69=q2+"K",e69=q2+"1K",y56=q2+"2K",J89=q2+"J",Q89=q2+"1J",gx1=q2+"2J",Z89=q2+"S",X89=q2+"T",Y89="\x1Bc",K89=f69?`${gx1}${q2}0f`:`${gx1}${q2}3J${q2}H`,q89=q2+"?1049h",G89=q2+"?1049l",z89=RT,U89=(J,Q)=>[Sm,"8",Cm,Cm,Q,RT,J,Sm,"8",Cm,Cm,RT].join(""),W89=(J,Q={})=>{let Z=`${Sm}1337;File=inline=1`;if(Q.width)Z+=`;width=${Q.width}`;if(Q.height)Z+=`;height=${Q.height}`;if(Q.preserveAspectRatio===!1)Z+=";preserveAspectRatio=0";return Z+":"+Buffer.from(J).toString("base64")+RT},F89={setCwd:(J=h69())=>`${Sm}50;CurrentDir=${J}${RT}`,annotation(J,Q={}){let Z=`${Sm}1337;`,X=Q.x!==void 0,Y=Q.y!==void 0;if((X||Y)&&!(X&&Y&&Q.length!==void 0))throw Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");if(J=J.replaceAll("|",""),Z+=Q.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",Q.length>0)Z+=(X?[J,Q.length,Q.x,Q.y]:[Q.length,J]).join("|");else Z+=J;return Z+RT}};var k41=m6(d56(),1);function UV(J,Q,{target:Z="stdout",...X}={}){if(!k41.default[Z]){if(X.fallback===!1)return J;return typeof X.fallback==="function"?X.fallback(J,Q):`${J} (​${Q}​)`}return v41.link(J,Q)}UV.isSupported=k41.default.stdout;UV.stderr=(J,Q,Z={})=>UV(J,Q,{target:"stderr",...Z});UV.stderr.isSupported=k41.default.stderr;F0();iK();class lx1{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.1759974740-g48b1d2"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await q00(Q,this.configService)}catch(Q){l.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}}F0();class _41 extends Error{constructor(J="Thread has no messages to compact"){super(J);this.name="NoMessagesToCompactError"}}class YQ{message;name;constructor(J){this.message=J;this.name="InformationMessage"}}function c56(J){if(J instanceof _41)return{title:"Cannot compact thread",description:"Thread has no messages to compact.",type:"error"};if(J instanceof YQ)return{title:"Info",description:J.message,type:"info"};return l.warn("Unknown error type encountered",{name:J.name,message:J.message,stack:J.stack}),{title:"Error",description:J.message||"An unexpected error occurred.",type:"error"}}var WV=null,w89={connect:{name:"connect",description:"Connect CLI to web interface for current thread access",execute:async(J,Q)=>{try{if(WV)return Error("Already connected. Use /disconnect first to reconnect.");let{connectedClientsService:Z}=J;await Z.start({clientId:J.clientId,currentThreadID:J.worker.thread.id});let Y=Z.getCurrentStatus().clientID||"unknown",{connectBackground:K}=await Promise.resolve().then(() => (Yx1(),$46)),q=await K({worker:J.worker},J.configService,{clientId:J.clientId,onUserDisconnect:()=>{WV=null,Z.sendStatus({connected:!1,enabled:!1,errorMessage:"Disconnected by user via web interface"})}});return WV=q,q.promise.then(()=>{Z.sendStatus({connected:!0,errorMessage:void 0})}).catch((G)=>{WV=null,Z.sendStatus({connected:!1,errorMessage:G.message})}),new YQ(`Started connecting to Amp web interface
5849
+ ... (output truncated at ${DH} characters)`;Y({success:V,output:A.trim(),error:!V?L.trim()||"Command failed":void 0,exitCode:M??void 0})}),W.on("error",(M)=>{clearTimeout(U);let V=M.message;if(z)V=`Command timed out after ${Z}ms`;else if(M.message.includes("operation was aborted")||M.name==="AbortError")V="The command was aborted";Y({success:!1,output:F.join(""),error:V})})})}function x69(J,Q){let{filePath:Z,interpreter:X,extension:Y}=J;if(process.platform==="win32")return y69(Z,X?[...X]:null,Y,Q);else return b69(Z,X?[...X]:null,Y,Q)}function b69(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];else return[J,X]}function y69(J,Q,Z,X){if(Q&&Q.length>0&&Q[0])return[Q[0],[...Q.slice(1),J,...X]];switch(Z.toLowerCase()){case".bat":case".cmd":return["cmd.exe",["/c",J,...X]];case".ps1":return["powershell.exe",["-ExecutionPolicy","Bypass","-File",J,...X]];case".exe":return[J,X];default:return[J,X]}}F0();r$();hO();J4();oV();iK();FW();r6();S0();import{mkdtemp as N89,readFile as L89,unlink as A89,writeFile as YU2}from"fs/promises";var v41={};L6(v41,{scrollUp:()=>Z89,scrollDown:()=>X89,link:()=>U89,image:()=>W89,iTerm:()=>F89,exitAlternativeScreen:()=>G89,eraseUp:()=>Q89,eraseStartLine:()=>e69,eraseScreen:()=>gx1,eraseLines:()=>o69,eraseLine:()=>y56,eraseEndLine:()=>t69,eraseDown:()=>J89,enterAlternativeScreen:()=>q89,cursorUp:()=>x56,cursorTo:()=>g69,cursorShow:()=>s69,cursorSavePosition:()=>c69,cursorRestorePosition:()=>l69,cursorPrevLine:()=>n69,cursorNextLine:()=>a69,cursorMove:()=>m69,cursorLeft:()=>b56,cursorHide:()=>r69,cursorGetPosition:()=>i69,cursorForward:()=>p69,cursorDown:()=>u69,cursorBackward:()=>d69,clearTerminal:()=>K89,clearScreen:()=>Y89,beep:()=>z89});import mx1 from"node:process";var S41=globalThis.window?.document!==void 0,Fz2=globalThis.process?.versions?.node!==void 0,Hz2=globalThis.process?.versions?.bun!==void 0,Bz2=globalThis.Deno?.version?.deno!==void 0,Dz2=globalThis.process?.versions?.electron!==void 0,Mz2=globalThis.navigator?.userAgent?.includes("jsdom")===!0,Vz2=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,Nz2=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,Lz2=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,Az2=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Tm=globalThis.navigator?.userAgentData?.platform,wz2=Tm==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",Rz2=Tm==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",Oz2=Tm==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",jz2=Tm==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),$z2=Tm==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var q2="\x1B[",Sm="\x1B]",RT="\x07",Cm=";",_56=!S41&&mx1.env.TERM_PROGRAM==="Apple_Terminal",f69=!S41&&mx1.platform==="win32",h69=S41?()=>{throw Error("`process.cwd()` only works in Node.js, not the browser.")}:mx1.cwd,g69=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");if(typeof Q!=="number")return q2+(J+1)+"G";return q2+(Q+1)+Cm+(J+1)+"H"},m69=(J,Q)=>{if(typeof J!=="number")throw TypeError("The `x` argument is required");let Z="";if(J<0)Z+=q2+-J+"D";else if(J>0)Z+=q2+J+"C";if(Q<0)Z+=q2+-Q+"A";else if(Q>0)Z+=q2+Q+"B";return Z},x56=(J=1)=>q2+J+"A",u69=(J=1)=>q2+J+"B",p69=(J=1)=>q2+J+"C",d69=(J=1)=>q2+J+"D",b56=q2+"G",c69=_56?"\x1B7":q2+"s",l69=_56?"\x1B8":q2+"u",i69=q2+"6n",a69=q2+"E",n69=q2+"F",r69=q2+"?25l",s69=q2+"?25h",o69=(J)=>{let Q="";for(let Z=0;Z<J;Z++)Q+=y56+(Z<J-1?x56():"");if(J)Q+=b56;return Q},t69=q2+"K",e69=q2+"1K",y56=q2+"2K",J89=q2+"J",Q89=q2+"1J",gx1=q2+"2J",Z89=q2+"S",X89=q2+"T",Y89="\x1Bc",K89=f69?`${gx1}${q2}0f`:`${gx1}${q2}3J${q2}H`,q89=q2+"?1049h",G89=q2+"?1049l",z89=RT,U89=(J,Q)=>[Sm,"8",Cm,Cm,Q,RT,J,Sm,"8",Cm,Cm,RT].join(""),W89=(J,Q={})=>{let Z=`${Sm}1337;File=inline=1`;if(Q.width)Z+=`;width=${Q.width}`;if(Q.height)Z+=`;height=${Q.height}`;if(Q.preserveAspectRatio===!1)Z+=";preserveAspectRatio=0";return Z+":"+Buffer.from(J).toString("base64")+RT},F89={setCwd:(J=h69())=>`${Sm}50;CurrentDir=${J}${RT}`,annotation(J,Q={}){let Z=`${Sm}1337;`,X=Q.x!==void 0,Y=Q.y!==void 0;if((X||Y)&&!(X&&Y&&Q.length!==void 0))throw Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");if(J=J.replaceAll("|",""),Z+=Q.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",Q.length>0)Z+=(X?[J,Q.length,Q.x,Q.y]:[Q.length,J]).join("|");else Z+=J;return Z+RT}};var k41=m6(d56(),1);function UV(J,Q,{target:Z="stdout",...X}={}){if(!k41.default[Z]){if(X.fallback===!1)return J;return typeof X.fallback==="function"?X.fallback(J,Q):`${J} (​${Q}​)`}return v41.link(J,Q)}UV.isSupported=k41.default.stdout;UV.stderr=(J,Q,Z={})=>UV(J,Q,{target:"stderr",...Z});UV.stderr.isSupported=k41.default.stderr;F0();iK();class lx1{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.1759982493-gb3a8ef"},parameters:{metadata:{count:Z}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Q=JSON.stringify(J);await q00(Q,this.configService)}catch(Q){l.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}}F0();class _41 extends Error{constructor(J="Thread has no messages to compact"){super(J);this.name="NoMessagesToCompactError"}}class YQ{message;name;constructor(J){this.message=J;this.name="InformationMessage"}}function c56(J){if(J instanceof _41)return{title:"Cannot compact thread",description:"Thread has no messages to compact.",type:"error"};if(J instanceof YQ)return{title:"Info",description:J.message,type:"info"};return l.warn("Unknown error type encountered",{name:J.name,message:J.message,stack:J.stack}),{title:"Error",description:J.message||"An unexpected error occurred.",type:"error"}}var WV=null,w89={connect:{name:"connect",description:"Connect CLI to web interface for current thread access",execute:async(J,Q)=>{try{if(WV)return Error("Already connected. Use /disconnect first to reconnect.");let{connectedClientsService:Z}=J;await Z.start({clientId:J.clientId,currentThreadID:J.worker.thread.id});let Y=Z.getCurrentStatus().clientID||"unknown",{connectBackground:K}=await Promise.resolve().then(() => (Yx1(),$46)),q=await K({worker:J.worker},J.configService,{clientId:J.clientId,onUserDisconnect:()=>{WV=null,Z.sendStatus({connected:!1,enabled:!1,errorMessage:"Disconnected by user via web interface"})}});return WV=q,q.promise.then(()=>{Z.sendStatus({connected:!0,errorMessage:void 0})}).catch((G)=>{WV=null,Z.sendStatus({connected:!1,errorMessage:G.message})}),new YQ(`Started connecting to Amp web interface
5850
5850
  Client ID: ${Y}
5851
5851
  You can now send messages from the web interface to this thread`)}catch(Z){return J.connectedClientsService.sendStatus({connected:!1,errorMessage:Z.message}),Error(`Failed to start connection: ${Z.message}`)}}},disconnect:{name:"disconnect",description:"Disconnect from web interface",execute:async(J,Q)=>{if(!WV)return new YQ("Not connected to Amp web interface");try{WV.disconnect();let Z=WV.clientID;return WV=null,J.connectedClientsService.sendStatus({connected:!1,enabled:!1,errorMessage:void 0}),new YQ(`Disconnected from Amp web interface
5852
5852
  Client ID: ${Z}
@@ -6042,7 +6042,7 @@ ${Q}`),this.textController.clear(),this.textController.insertText(this.pendingTr
6042
6042
  `),J.stdout.write(`Thread: ${H}
6043
6043
  `),J.stdout.write(`Continue this thread with: amp threads continue ${W}
6044
6044
  `)}}function _Y6(J){let Q=0;for(let Y=0;Y<J.length;Y++){let K=J.charCodeAt(Y);Q=(Q<<5)-Q+K,Q=Q&Q}let Z=[9,10,11,12,13,14,15,208,209,210,211,212,213,214,215],X=Math.abs(Q)%Z.length;return x1.index(Z[X])}Bb1();if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){s2.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
6045
- `)}var wh1=Ah1.join(ru1||Ah1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function wQ9(J){process.emitWarning=function(Q,Z,X,Y){let K=typeof Q==="string"?Q:Q.message||String(Q),q=Z||"Warning",G=!1;J.warn(K,{name:q,code:X})}}function PV(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")vU("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new V2("The --try-gpt5 flag has been removed.",1,`GPT-5 is now available as the oracle. Read why: ${Z8.blue("https://ampcode.com/news/gpt-5-oracle")}`);if(J.getOptionValueSourceWithGlobals("agentMode")==="cli")vU("experimental.agentMode",Q.agentMode)}var RQ9=L0.union([L0.object({command:L0.string(),args:L0.array(L0.string()).optional(),env:L0.record(L0.string(),L0.string()).optional()}).strict(),L0.object({url:L0.string()}).strict()]),OQ9=L0.record(L0.string(),RQ9);async function Oh1(J){try{await NQ9(Ah1.dirname(wh1),{recursive:!0}),await LQ9(wh1,J,"utf-8")}catch(Q){l.debug("Failed to save last thread ID",Q)}}async function jQ9(){try{return(await mY6(wh1,"utf-8")).trim()}catch(J){return null}}async function $Q9(J){let Q;try{Q=JSON.parse(J)}catch(Z){throw Error(`Failed to parse --mcp-config as JSON: ${Z instanceof Error?Z.message:String(Z)}`)}try{return OQ9.parse(Q)}catch(Z){if(Z instanceof L0.ZodError){let X=Z.issues.map((Y)=>`${Y.path.join(".")}: ${Y.message}`).join(", ");throw Error(`Invalid MCP server configuration: ${X}`)}throw Error(`Failed to validate MCP server configuration: ${String(Z)}`)}}function IQ9(J,Q){return{...J,async get(Z){if(Z==="mcpServers"){let X=await J.get(Z)||{},Y={};if(typeof X==="object")for(let[K,q]of Object.entries(X))Y[K]={...q,_target:"global"};for(let[K,q]of Object.entries(Q))Y[K]={...q,_target:"workspace"};return Y}return J.get(Z)},async keys(){let Z=await J.keys();if(!Z.includes("mcpServers"))Z.push("mcpServers");return Z},[Symbol.dispose](){J[Symbol.dispose]()}}}var fY6=[{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)`,deprecated:!0},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??D5,description:`Custom settings file path (overrides the default location ${D5})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(l).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${a_1})`},{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:zG(),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:Ex1(),hidden:!0,description:(J)=>J?"Enable IDE connection. 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:"tryGpt5",long:"try-gpt5",type:"switch",default:!1,description:"[DEPRECATED] Try GPT-5 as the primary agent model (see https://ampcode.com/news/gpt-5-oracle)",deprecated:!0},{name:"agentMode",long:"agent-mode",type:"option",description:"Set the experimental agent mode configuration",hidden:!0,choices:KN}],hY6=(J)=>("deprecated"in J)&&J.deprecated===!0,EQ9=(J)=>("hidden"in J)&&J.hidden===!0,PQ9=(J)=>("default"in J),TQ9=(J)=>("default"in J)?J.default:void 0;function CQ9(J,Q){let Z=Q.args[0],X=Q.commands.map((K)=>K.name());if(Z&&!Z.includes(" ")&&Z.length<30&&!/[./\\]/.test(Z)){let K=X.filter((G)=>Z.includes(G)||G.includes(Z)),q="Run amp --help for a list of available commands.";if(K.length>0)q=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new V2(OK.unknownCommand(Z),1,q)}}var uY6=null;function _y2(){return uY6}function q51(J){return{...J,getThreadEnvironment:J41,vfs:Z80({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new Uk(J.fileSystem),generateThreadTitle:LY0,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var jh1=v0.file(AQ9.homedir()),pY6=process.env.XDG_CONFIG_HOME?v0.file(process.env.XDG_CONFIG_HOME):p0.joinPath(jh1,".config");async function TV(J,Q){sd1("0.0.1759974740-g48b1d2");let Z=UQ1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:Q0.of([v0.file(process.cwd())]),defaultAmpURL:J.ampURL,defaultCacheDirectory:i_1,homeDir:jh1,userConfigDir:pY6}),X=await Z.getLatest();l.debug("Global configuration initialized",{hasCacheDirectory:!!X.settings.cacheDirectory,settingsKeys:Object.keys(X.settings)});let Y=bi(jR({configService:Z})),K=k60({configService:Z,toolService:Y}),q=$L0(Y,x9,Wt).catch((N)=>{l.warn("Toolbox registration failed, continuing anyway:",N)}),G=K.initialized.catch((N)=>{l.warn("MCP service initialization failed, continuing anyway:",N)});if(J.executeMode)await Promise.all([G,q]);if(Q.jetbrains)od1(!0);if(Q.ide&&Ex1())td1(!0);if(j06(Y,{configService:Z}),Q.jetbrains||Q.ide)Y.registerTool(Sn);let z;if(!J.executeMode)z=new D41(process.cwd(),{},!0);else z=new class extends D41{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(g2.write(`No API key found. Starting login flow...
6045
+ `)}var wh1=Ah1.join(ru1||Ah1.join(process.env.HOME||process.cwd(),".local","state"),"amp","last-thread-id");function wQ9(J){process.emitWarning=function(Q,Z,X,Y){let K=typeof Q==="string"?Q:Q.message||String(Q),q=Z||"Warning",G=!1;J.warn(K,{name:q,code:X})}}function PV(J,Q){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")vU("dangerouslyAllowAll",Q.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("tryGpt5")==="cli")throw new V2("The --try-gpt5 flag has been removed.",1,`GPT-5 is now available as the oracle. Read why: ${Z8.blue("https://ampcode.com/news/gpt-5-oracle")}`);if(J.getOptionValueSourceWithGlobals("agentMode")==="cli")vU("experimental.agentMode",Q.agentMode)}var RQ9=L0.union([L0.object({command:L0.string(),args:L0.array(L0.string()).optional(),env:L0.record(L0.string(),L0.string()).optional()}).strict(),L0.object({url:L0.string()}).strict()]),OQ9=L0.record(L0.string(),RQ9);async function Oh1(J){try{await NQ9(Ah1.dirname(wh1),{recursive:!0}),await LQ9(wh1,J,"utf-8")}catch(Q){l.debug("Failed to save last thread ID",Q)}}async function jQ9(){try{return(await mY6(wh1,"utf-8")).trim()}catch(J){return null}}async function $Q9(J){let Q;try{Q=JSON.parse(J)}catch(Z){throw Error(`Failed to parse --mcp-config as JSON: ${Z instanceof Error?Z.message:String(Z)}`)}try{return OQ9.parse(Q)}catch(Z){if(Z instanceof L0.ZodError){let X=Z.issues.map((Y)=>`${Y.path.join(".")}: ${Y.message}`).join(", ");throw Error(`Invalid MCP server configuration: ${X}`)}throw Error(`Failed to validate MCP server configuration: ${String(Z)}`)}}function IQ9(J,Q){return{...J,async get(Z){if(Z==="mcpServers"){let X=await J.get(Z)||{},Y={};if(typeof X==="object")for(let[K,q]of Object.entries(X))Y[K]={...q,_target:"global"};for(let[K,q]of Object.entries(Q))Y[K]={...q,_target:"workspace"};return Y}return J.get(Z)},async keys(){let Z=await J.keys();if(!Z.includes("mcpServers"))Z.push("mcpServers");return Z},[Symbol.dispose](){J[Symbol.dispose]()}}}var fY6=[{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)`,deprecated:!0},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??D5,description:`Custom settings file path (overrides the default location ${D5})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(l).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${a_1})`},{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:zG(),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:Ex1(),hidden:!0,description:(J)=>J?"Enable IDE connection. 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:"tryGpt5",long:"try-gpt5",type:"switch",default:!1,description:"[DEPRECATED] Try GPT-5 as the primary agent model (see https://ampcode.com/news/gpt-5-oracle)",deprecated:!0},{name:"agentMode",long:"agent-mode",type:"option",description:"Set the experimental agent mode configuration",hidden:!0,choices:KN}],hY6=(J)=>("deprecated"in J)&&J.deprecated===!0,EQ9=(J)=>("hidden"in J)&&J.hidden===!0,PQ9=(J)=>("default"in J),TQ9=(J)=>("default"in J)?J.default:void 0;function CQ9(J,Q){let Z=Q.args[0],X=Q.commands.map((K)=>K.name());if(Z&&!Z.includes(" ")&&Z.length<30&&!/[./\\]/.test(Z)){let K=X.filter((G)=>Z.includes(G)||G.includes(Z)),q="Run amp --help for a list of available commands.";if(K.length>0)q=`Did you mean: ${K.join(", ")}? Or run amp --help for all commands.`;throw new V2(OK.unknownCommand(Z),1,q)}}var uY6=null;function _y2(){return uY6}function q51(J){return{...J,getThreadEnvironment:J41,vfs:Z80({os:J.fileSystem},J.configService.config),fileChangeTrackerStorage:new Uk(J.fileSystem),generateThreadTitle:LY0,deleteThread:(Q)=>J.threadHistoryService.delete(Q)}}var jh1=v0.file(AQ9.homedir()),pY6=process.env.XDG_CONFIG_HOME?v0.file(process.env.XDG_CONFIG_HOME):p0.joinPath(jh1,".config");async function TV(J,Q){sd1("0.0.1759982493-gb3a8ef");let Z=UQ1({storage:J.settings,secretStorage:J.secrets,workspaceRoots:Q0.of([v0.file(process.cwd())]),defaultAmpURL:J.ampURL,defaultCacheDirectory:i_1,homeDir:jh1,userConfigDir:pY6}),X=await Z.getLatest();l.debug("Global configuration initialized",{hasCacheDirectory:!!X.settings.cacheDirectory,settingsKeys:Object.keys(X.settings)});let Y=bi(jR({configService:Z})),K=k60({configService:Z,toolService:Y}),q=$L0(Y,x9,Wt).catch((N)=>{l.warn("Toolbox registration failed, continuing anyway:",N)}),G=K.initialized.catch((N)=>{l.warn("MCP service initialization failed, continuing anyway:",N)});if(J.executeMode)await Promise.all([G,q]);if(Q.jetbrains)od1(!0);if(Q.ide&&Ex1())td1(!0);if(j06(Y,{configService:Z}),Q.jetbrains||Q.ide)Y.registerTool(Sn);let z;if(!J.executeMode)z=new D41(process.cwd(),{},!0);else z=new class extends D41{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};if(!await J.secrets.get("apiKey",J.ampURL)){if(g2.write(`No API key found. Starting login flow...
6046
6046
  `),!await SQ9(J))await Dw(),process.exit(1)}let U=await G80({isDevelopment:!1}),W=new rW1(U),F=new aW1(U,{lazy:!0}),H=Q.notifications!==void 0?Q.notifications:!J.executeMode,B=I06({playNotificationSound:async(N)=>{if(H){$06(N);let L=Fb1(),A=Hb1();if((!L||A)&&X.settings["notifications.system.enabled"]!==!1){if(N==="idle")process.stdout.write("\x1B]777;notify;Amp;Agent is ready\x1B\\");else if(N==="requires-user-input")process.stdout.write("\x1B]777;notify;Amp;Waiting for approval\x1B\\")}}},windowFocused:()=>Promise.resolve(!1),threadService:W,configService:Z});l.info("Starting Amp background services");let M=M80({threadService:W,threadHistoryService:F,configService:Z,isExtensionDevelopment:!1}),V={configService:Z,toolService:Y,mcpService:K,threadService:W,threadHistoryService:F,threadSyncService:M,threadStorage:U,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:z,notificationService:B,fileSystem:Q.jetbrains||Q.ide?e60:x9};return{...V,async asyncDispose(){await V.mcpService.dispose(),await V.threadService.asyncDispose(),V.configService.unsubscribe(),V.toolService.dispose(),V.fuzzyServer.dispose(),V.threadSyncService.dispose(),V.settingsStorage[Symbol.dispose]()}}}async function SQ9(J){if(!J.executeMode){if(!await xx1("Would you like to log in to Amp? [(y)es, (n)o]: "))return g2.write(`Login cancelled. Run the command again to retry.
6047
6047
  `),!1}return await dY6(J)}async function dY6(J){let Q=VQ9(32).toString("hex"),Z=await _x1(J.ampURL,Q);try{await RU(Z)}catch(Y){l.error("Failed to open browser",{error:Y})}let X=await _x1(J.ampURL,Q,!1);g2.write(`If your browser did not open automatically, visit:
6048
6048
 
@@ -6052,12 +6052,12 @@ ${Z8.blue.bold(X)}
6052
6052
  Login successful! You can now use the Amp CLI.
6053
6053
  `),!0}catch(Y){return l.error("Login failed",{error:Y}),s2.write(`
6054
6054
  Login failed: ${Y instanceof Error?Y.message:String(Y)}
6055
- `),!1}}function vQ9(){let J=new fg().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((F)=>{if(F.code==="commander.help"||F.code==="commander.version"||F.exitCode===0)Vw(),process.exit(0);let H=F.originalError??F;P46(H)}),J.option("-V, --version","output the version number",()=>{g2.write(`0.0.1759974740-g48b1d2 (released 2025-10-09T01:57:33.023Z)
6056
- `),process.exit(0)}),J.addHelpText("after",P76()),J.configureHelp({formatHelp:T76}),J.command("logout").description("Log out by removing stored API key").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await bQ9(M)}),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(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await xQ9(M,await wx1(B,M.settings))});let Q=async(F,H,B)=>{UQ1({storage:H.settings,secretStorage:H.secrets,workspaceRoots:Q0.of([v0.file(process.cwd())]),defaultAmpURL:H.ampURL,homeDir:jh1,userConfigDir:pY6});let M={...H,executeMode:!1};await Rh1(M,{...F,startWithPicker:!0},B)},Z=J.command("threads").alias("t").alias("thread").summary("Manage threads").description("Thread management commands. When no subcommand is provided, defaults to listing threads.").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await gY6(B,M,H)});Z.command("new").alias("n").summary("Create a new thread").description("Create a new thread and print its ID. The thread will be empty. You can set the visibility using the --visibility option.").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await pQ9(B,M,H)}),Z.command("continue [threadId]").alias("c").summary("Continue an existing thread").description("Continue an existing thread by resuming the conversation. If no thread ID is provided, the most recently used thread will be continued.").option("--pick","Pick a thread interactively from a list").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await JY(M);if(H.pick)await Q(M,V,B);else await uQ9(M,V,F,B)}),Z.command("fork [threadId]").alias("f").summary("Fork an existing thread").description("Create a new thread by forking an existing one. This copies the conversation history up to the current point and creates a new thread where you can explore different directions. If no thread ID is provided, the most recently used thread will be forked.").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await JY(M);await mQ9(M,V,F,B)}),Z.command("list").alias("l").alias("ls").summary("List all threads").description("List all your threads with their IDs, names, and last modified times.").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await gY6(B,M,H)}),Z.command("share <threadId>").summary("Share a thread").description("Change thread visibility (private, public, workspace, group) or share with Amp support for debugging. Use --visibility to change who can access the thread, or --support to share with the Amp team for troubleshooting.").alias("s").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").option("--support","Share thread with Amp support for debugging").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await JY(M);await gQ9(M,V,F,B,H.support)}),Z.command("compact <threadId>").alias("co").summary("Compact a thread").description("Compact a thread by creating a summary of the conversation history. This reduces the thread size while preserving the key information and context, making it more token efficient for future use.").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await JY(M);await hQ9(M,V,F,B)}),I56(J,async(F,H)=>{let B=await JY(H);PV(F,H);let M=await TV(B,H);return{context:B,mcpService:M.mcpService,toolService:M.toolService,cleanupTerminal:Vw,asyncDispose:M.asyncDispose.bind(M)}}),Q56(J),n76(J,async(F)=>{return(await JY(F)).settings}),J.command("connect").description("Connect CLI to web interface for multi-thread management").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);PV(H,B);let V=await TV(M,B);try{await Xx1(V,V.configService,{})}finally{await V.asyncDispose(),await Vw()}});let X=new fg().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(F)=>{await Tx1(F.force||!1,F.verbose||!1,"0.0.1759974740-g48b1d2"),process.exit()});J.addCommand(X,{hidden:!0});function Y(F,H,B){let V=typeof F.description==="string"?F.description:B===void 0?F.description(!0):F.description(B),N=new sM(H,V),L=TQ9(F);if(L)N.default(L);if(N.hidden=EQ9(F)||hY6(F),"choices"in F)N.choices([...F.choices]);return N}for(let F of fY6)switch(F.type){case"flag":{J.addOption(Y(F,`--${F.long}`)),J.addOption(Y(F,`--no-${F.long}`,!1));break}case"switch":{J.addOption(Y(F,`--${F.long}`,!0));break}default:{J.addOption(Y(F,`--${F.long} <value>`));break}}let K=new sM("-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);if(J.addOption(K),process.env.AMP_CLI_REMOTE){let F=new sM("-r, --remote","When used with -x/--execute, execute in an async agent on the Amp server.").default(!1);J.addOption(F)}let q=new sM("--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 sM("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(G);let z=new sM("--stats","When used with --execute, output JSON with both result and token usage data (for /evals).").default(!1).hideHelp(!0);if(J.addOption(z),process.env.AMP_CONNECT==="1"){let F=new sM("--client-id <clientId>","Override the client ID for connect functionality (default: amp-<pid>@<hostname>)");J.addOption(F)}J.action(async(F,H)=>{let B=F,M=await JY(B);if(Object.keys(B).forEach((V)=>{let N=fY6.find((L)=>L.name===V);if(N&&hY6(N)&&!PQ9(N))s2.write(Z8.yellow(`Warning: '--${V}' flag is deprecated
6055
+ `),!1}}function vQ9(){let J=new fg().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((F)=>{if(F.code==="commander.help"||F.code==="commander.version"||F.exitCode===0)Vw(),process.exit(0);let H=F.originalError??F;P46(H)}),J.option("-V, --version","output the version number",()=>{g2.write(`0.0.1759982493-gb3a8ef (released 2025-10-09T04:07:23.446Z)
6056
+ `),process.exit(0)}),J.addHelpText("after",P76()),J.configureHelp({formatHelp:T76}),J.command("logout").description("Log out by removing stored API key").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await bQ9(M)}),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(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await xQ9(M,await wx1(B,M.settings))});let Q=async(F,H,B)=>{UQ1({storage:H.settings,secretStorage:H.secrets,workspaceRoots:Q0.of([v0.file(process.cwd())]),defaultAmpURL:H.ampURL,homeDir:jh1,userConfigDir:pY6});let M={...H,executeMode:!1};await Rh1(M,{...F,startWithPicker:!0},B)},Z=J.command("threads").alias("t").alias("thread").summary("Manage threads").description("Thread management commands. When no subcommand is provided, defaults to listing threads.").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await gY6(B,M,H)});Z.command("new").alias("n").summary("Create a new thread").description("Create a new thread and print its ID. The thread will be empty. You can set the visibility using the --visibility option.").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await pQ9(B,M,H)}),Z.command("continue [threadId]").alias("c").summary("Continue an existing thread").description("Continue an existing thread by resuming the conversation. If no thread ID is provided, the most recently used thread will be continued.").option("--pick","Pick a thread interactively from a list").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await JY(M);if(H.pick)await Q(M,V,B);else await uQ9(M,V,F,B)}),Z.command("fork [threadId]").alias("f").summary("Fork an existing thread").description("Create a new thread by forking an existing one. This copies the conversation history up to the current point and creates a new thread where you can explore different directions. If no thread ID is provided, the most recently used thread will be forked.").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await JY(M);await mQ9(M,V,F,B)}),Z.command("list").alias("l").alias("ls").summary("List all threads").description("List all your threads with their IDs, names, and last modified times.").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);await gY6(B,M,H)}),Z.command("share <threadId>").summary("Share a thread").description("Change thread visibility (private, public, workspace, group) or share with Amp support for debugging. Use --visibility to change who can access the thread, or --support to share with the Amp team for troubleshooting.").alias("s").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").option("--support","Share thread with Amp support for debugging").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await JY(M);await gQ9(M,V,F,B,H.support)}),Z.command("compact <threadId>").alias("co").summary("Compact a thread").description("Compact a thread by creating a summary of the conversation history. This reduces the thread size while preserving the key information and context, making it more token efficient for future use.").action(async(F,H,B)=>{let M=B.optsWithGlobals(),V=await JY(M);await hQ9(M,V,F,B)}),I56(J,async(F,H)=>{let B=await JY(H);PV(F,H);let M=await TV(B,H);return{context:B,mcpService:M.mcpService,toolService:M.toolService,cleanupTerminal:Vw,asyncDispose:M.asyncDispose.bind(M)}}),Q56(J),n76(J,async(F)=>{return(await JY(F)).settings}),J.command("connect").description("Connect CLI to web interface for multi-thread management").action(async(F,H)=>{let B=H.optsWithGlobals(),M=await JY(B);PV(H,B);let V=await TV(M,B);try{await Xx1(V,V.configService,{})}finally{await V.asyncDispose(),await Vw()}});let X=new fg().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(F)=>{await Tx1(F.force||!1,F.verbose||!1,"0.0.1759982493-gb3a8ef"),process.exit()});J.addCommand(X,{hidden:!0});function Y(F,H,B){let V=typeof F.description==="string"?F.description:B===void 0?F.description(!0):F.description(B),N=new sM(H,V),L=TQ9(F);if(L)N.default(L);if(N.hidden=EQ9(F)||hY6(F),"choices"in F)N.choices([...F.choices]);return N}for(let F of fY6)switch(F.type){case"flag":{J.addOption(Y(F,`--${F.long}`)),J.addOption(Y(F,`--no-${F.long}`,!1));break}case"switch":{J.addOption(Y(F,`--${F.long}`,!0));break}default:{J.addOption(Y(F,`--${F.long} <value>`));break}}let K=new sM("-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);if(J.addOption(K),process.env.AMP_CLI_REMOTE){let F=new sM("-r, --remote","When used with -x/--execute, execute in an async agent on the Amp server.").default(!1);J.addOption(F)}let q=new sM("--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 sM("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(G);let z=new sM("--stats","When used with --execute, output JSON with both result and token usage data (for /evals).").default(!1).hideHelp(!0);if(J.addOption(z),process.env.AMP_CONNECT==="1"){let F=new sM("--client-id <clientId>","Override the client ID for connect functionality (default: amp-<pid>@<hostname>)");J.addOption(F)}J.action(async(F,H)=>{let B=F,M=await JY(B);if(Object.keys(B).forEach((V)=>{let N=fY6.find((L)=>L.name===V);if(N&&hY6(N)&&!PQ9(N))s2.write(Z8.yellow(`Warning: '--${V}' flag is deprecated
6057
6057
  `))}),H.args.length>0)CQ9(M,H);await Rh1(M,B,H)});let U=new fg("doctor").summary("Generate support bundle").description("Generate a support bundle for troubleshooting issues. This collects logs, configuration, and system information into a file that can be shared with Amp support for debugging.").option("--output-dir <path>","Directory to save the support bundle",process.cwd()).option("--include-full-logs","Include full log history",!1).allowUnknownOption(!1).action(async(F)=>{await fQ9(F.outputDir,F.includeFullLogs)});J.addCommand(U);let W=new fg("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("--version <version>","Update to a specific version").allowUnknownOption(!1).action(async(F)=>{await yQ9(F.version)});return J.addCommand(W),J}async function K51(J,Q){let{thread:Z,visibility:X}=Q,Y=Z?.id??yK(),K=q51(J);if(Z)await J.threadStorage.set(Y,Z);let q=await _J.getOrCreateForThread(K,Y);if(X)await J.threadSyncService.updateThreadMeta(Y,I41(X));let G=J.threadService.observe(Y).subscribe(async(z)=>{if(u7(z,"assistant"))await Oh1(Y),G.unsubscribe()});return await q.resume(),q}async function Rh1(J,Q,Z){let X=$41(Q);if(X instanceof Error)JX(X.message);let Y,K=null;if(Q.streamJsonInput)Y="";else if(typeof Q.execute==="string"){Y=Q.execute;let w=(await bx1()).trimEnd();if(w)K=w}else Y=(await bx1()).trimEnd();if(Q.remote&&!J.executeMode)throw new V2("The -r/--remote flag currently only works with --execute mode",1,'Use: amp --remote --execute "your message"');if(Q.streamJson&&!J.executeMode)throw new V2("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(Q.streamJsonInput&&!J.executeMode)throw new V2("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.streamJsonInput&&!Q.streamJson)throw new V2("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(Q.stats&&!J.executeMode)throw new V2("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(Q.streamJsonInput&&typeof Q.execute==="string"&&Q.execute.trim()!=="")throw new V2("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)throw new V2("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"
6058
6058
  Or pipe via stdin: echo "your message" | amp --execute`);PV(Z,Q);let q=await TV(J,Q);uY6=q;let G=q51(q),z=async(w)=>{let R=await mY6(w,"utf-8"),O=JSON.parse(R);if(!fU(O.id))throw new V2(OK.invalidThreadId);return K51(q,{visibility:X,thread:O})},U=async(w)=>{if(!fU(w))throw new V2(OK.invalidThreadId);let R=await q.threadService.get(w)??void 0;return K51(q,{visibility:X,thread:R})},W=async()=>{try{if(Q.threadId)return U(Q.threadId);else return K51(q,{visibility:X})}catch(w){if(w instanceof V2)throw w;throw await q41(w,Q.threadId),Error("handleError should have called process.exit()")}},F=async()=>{return K51(q,{visibility:X})};if(Q.format==="jsonl")s2.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
6059
- `),await Dw(),process.exit(1);if(J.executeMode&&Q.remote)await Z56(Y,K,q.configService),await q.asyncDispose(),process.exit(0);let H=await W();if(J.executeMode)await h46(H,H.threadID,Y,K,q,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await q.asyncDispose(),process.exit(0);let B=!1,M=!1;if(Q.jetbrains||Q.ide){await Ai1();let w=await mR({jetbrainsOnly:Q.jetbrains});if(w.length===0)if(Q.jetbrains)M=!await q.configService.get("jetbrains.skipInstall");else O5.sendStatus({enabled:!0,connected:!1,authenticated:!1});else if(w.length===1){let R=w[0];if(R)O5.selectConfig(R)}else B=!0}let V=vx1("0.0.1759974740-g48b1d2",q.settingsStorage),N=Q0.of([v0.file(process.cwd())]),L=rT(void 0,N);if(Y)H.handle({type:"user:message",message:{content:[{type:"text",text:Y}]}});let A=await q.configService.getLatest();await yY6({stdout:process.stdout,history:new Gx1,fuzzyServer:q.fuzzyServer,settingsStorage:q.settingsStorage,threadService:q.threadService,threadSyncService:q.threadSyncService,threadID:H.threadID,worker:H,workerDeps:G,configService:q.configService,internalAPIClient:CJ,ampURL:J.ampURL,startNewThread:F,pickAndContinueThread:async()=>{l.info("Thread picker requested - not yet implemented in TUI")},switchToThread:U,ideClient:O5,connectedClientsService:new Ip,commandRegistry:L,showJetBrainsInstaller:M,showIdePicker:B,startWithPicker:Q.startWithPicker,updateService:V,debugWidgetTree:Q.debugWidgetTree,jetbrainsMode:Q.jetbrains,clientId:Q.clientId}),await q.asyncDispose(),process.exit(0)}async function JY(J){if(J.interactive)s2.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6060
- `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=!1,X=process.stdout.isTTY&&process.stderr.isTTY,Y=await LU(J.settingsFile),K=AU({...J,settingsFile:Y,getHook:process.env.AMP_URL?(z,U)=>{if(z==="url")return Promise.resolve(process.env.AMP_URL);return U()}:void 0});if(await Y56(K),await K56(K),J.mcpConfig){let z=await $Q9(J.mcpConfig);K=IQ9(K,z)}let q=await K.get("url","global");if(!q)q=eQ;if(!yH(q))l.info("Targeting custom Amp server",{ampURL:q});if(K=Np1(K),await K.get("debug.httpLogging"))Dp1();return{executeMode:Q,streamJsonMode:Z,isTTY:X,ampURL:q,settings:K,secrets:X56(await wx1(J,K))}}function kQ9(J){let Q={};for(let Z=0;Z<J.length;Z++){let X=J[Z];if(X?.startsWith("--")){let K=X.slice(2).replace(/-([a-z])/g,(G,z)=>z.toUpperCase()),q=J[Z+1];if(q&&!q.startsWith("--"))Q[K]=q,Z++}}return Q}async function _Q9(){let J=kQ9(process.argv);if(U46({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),wQ9(l),l.info("Starting Amp CLI.",{version:"0.0.1759974740-g48b1d2",buildTimestamp:"2025-10-09T01:57:33.023Z",buildType:"'release'"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new V2(OK.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await vQ9().parseAsync(process.argv)}_Q9().catch(q41);async function xQ9(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),g2.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6059
+ `),await Dw(),process.exit(1);if(J.executeMode&&Q.remote)await Z56(Y,K,q.configService),await q.asyncDispose(),process.exit(0);let H=await W();if(J.executeMode)await h46(H,H.threadID,Y,K,q,!!Q.streamJson,!!Q.streamJsonInput,!!Q.stats,J.ampURL),await q.asyncDispose(),process.exit(0);let B=!1,M=!1;if(Q.jetbrains||Q.ide){await Ai1();let w=await mR({jetbrainsOnly:Q.jetbrains});if(w.length===0)if(Q.jetbrains)M=!await q.configService.get("jetbrains.skipInstall");else O5.sendStatus({enabled:!0,connected:!1,authenticated:!1});else if(w.length===1){let R=w[0];if(R)O5.selectConfig(R)}else B=!0}let V=vx1("0.0.1759982493-gb3a8ef",q.settingsStorage),N=Q0.of([v0.file(process.cwd())]),L=rT(void 0,N);if(Y)H.handle({type:"user:message",message:{content:[{type:"text",text:Y}]}});let A=await q.configService.getLatest();await yY6({stdout:process.stdout,history:new Gx1,fuzzyServer:q.fuzzyServer,settingsStorage:q.settingsStorage,threadService:q.threadService,threadSyncService:q.threadSyncService,threadID:H.threadID,worker:H,workerDeps:G,configService:q.configService,internalAPIClient:CJ,ampURL:J.ampURL,startNewThread:F,pickAndContinueThread:async()=>{l.info("Thread picker requested - not yet implemented in TUI")},switchToThread:U,ideClient:O5,connectedClientsService:new Ip,commandRegistry:L,showJetBrainsInstaller:M,showIdePicker:B,startWithPicker:Q.startWithPicker,updateService:V,debugWidgetTree:Q.debugWidgetTree,jetbrainsMode:Q.jetbrains,clientId:Q.clientId}),await q.asyncDispose(),process.exit(0)}async function JY(J){if(J.interactive)s2.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
6060
+ `);let Q=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Z=!1,X=process.stdout.isTTY&&process.stderr.isTTY,Y=await LU(J.settingsFile),K=AU({...J,settingsFile:Y,getHook:process.env.AMP_URL?(z,U)=>{if(z==="url")return Promise.resolve(process.env.AMP_URL);return U()}:void 0});if(await Y56(K),await K56(K),J.mcpConfig){let z=await $Q9(J.mcpConfig);K=IQ9(K,z)}let q=await K.get("url","global");if(!q)q=eQ;if(!yH(q))l.info("Targeting custom Amp server",{ampURL:q});if(K=Np1(K),await K.get("debug.httpLogging"))Dp1();return{executeMode:Q,streamJsonMode:Z,isTTY:X,ampURL:q,settings:K,secrets:X56(await wx1(J,K))}}function kQ9(J){let Q={};for(let Z=0;Z<J.length;Z++){let X=J[Z];if(X?.startsWith("--")){let K=X.slice(2).replace(/-([a-z])/g,(G,z)=>z.toUpperCase()),q=J[Z+1];if(q&&!q.startsWith("--"))Q[K]=q,Z++}}return Q}async function _Q9(){let J=kQ9(process.argv);if(U46({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE}),wQ9(l),l.info("Starting Amp CLI.",{version:"0.0.1759982493-gb3a8ef",buildTimestamp:"2025-10-09T04:07:23.446Z",buildType:"'release'"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new V2(OK.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await vQ9().parseAsync(process.argv)}_Q9().catch(q41);async function xQ9(J,Q){if(process.env.AMP_URL)await J.settings.set("url",process.env.AMP_URL,"global"),g2.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
6061
6061
  `);else if(!yH(J.ampURL))g2.write(`Logging in to ${new URL(J.ampURL).hostname}
6062
6062
  `);let Z=process.env.AMP_API_KEY;if(Z)g2.write(`API key found in environment variable, storing...
6063
6063
  `),await Q.set("apiKey",Z,J.ampURL),g2.write(`API key successfully stored.
@@ -6073,7 +6073,7 @@ Or pipe via stdin: echo "your message" | amp --execute`);PV(Z,Q);let q=await TV(
6073
6073
  `));try{let Q;if(J)Q=J,s2.write(Z8.blue(`Updating to version ${J}...
6074
6074
  `)),await NT(J),s2.write(Z8.green(`✓ Successfully updated to version ${J}
6075
6075
  `));else{s2.write(Z8.blue(`Checking for updates...
6076
- `));let{hasUpdate:X,latestVersion:Y}=await aO("0.0.1759974740-g48b1d2");if(!X)s2.write(Z8.green(`✓ Amp CLI is already up to date.
6076
+ `));let{hasUpdate:X,latestVersion:Y}=await aO("0.0.1759982493-gb3a8ef");if(!X)s2.write(Z8.green(`✓ Amp CLI is already up to date.
6077
6077
  `)),process.exit(0);if(!Y)s2.write(Z8.yellow("[WARN] could not find latest version")),process.exit(0);Q=Y,s2.write(Z8.blue(`Updating to version ${Y}...
6078
6078
  `)),await NT(Y),s2.write(Z8.green(`✓ Successfully updated to version ${Y}
6079
6079
  `))}let Z=await ww(Q);if(Z.warning)s2.write(`
@@ -6092,7 +6092,7 @@ Summary: ${B}
6092
6092
  `)}await K.asyncDispose(),process.exit(0)}catch(q){await K.asyncDispose(),JX(`Failed to update thread: ${q instanceof Error?q.message:String(q)}`)}}async function mQ9(J,Q,Z,X){PV(X,J);let Y=await TV(Q,J),K=q51(Y);try{let q=await cY6(Z),G=await P5(`/api/threads/${q}`,void 0,Y.configService);if(!G.ok)s2.write(`Failed to load thread ${q}: ${await G.text()}
6093
6093
  `),process.exit(1);let z=await G.json(),U=z.messages.length-1;await Y.threadStorage.set(q,z);let W=await _J.getOrCreateForThread(K,q),F=await AY0(W,Y.threadSyncService,U);await Promise.all([Y.threadSyncService.uploadThread(q),Y.threadSyncService.uploadThread(F)]),await Oh1(F),g2.write(`${F}
6094
6094
  `),await Y.asyncDispose(),process.exit(0)}catch(q){s2.write(`Error forking thread: ${q instanceof Error?q.message:String(q)}
6095
- `),await Y.asyncDispose(),process.exit(1)}}async function cY6(J){let Q=J;if(!Q){if(Q=await jQ9(),!Q)throw new V2("No thread ID provided and no previously used thread found.",1,"Provide a thread ID as an argument or run a thread first.")}else{let Z=$h1(Q);if(!Z)Ih1(Q);Q=Z}if(!fU(Q))throw new V2(OK.invalidThreadId);return Q}function $h1(J){if(fU(J))return J;let Q=J.match(/\/threads\/(T-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);if(Q?.[1]&&fU(Q[1]))return Q[1];return null}function Ih1(J){throw new V2(`Invalid thread ID or URL: ${J}`,1,"Provide a valid thread ID (e.g., T-5928a90d-d53b-488f-a829-4e36442142ee) or thread URL (e.g., https://ampcode.com/threads/T-5928a90d-d53b-488f-a829-4e36442142ee)")}async function uQ9(J,Q,Z,X){let Y=await cY6(Z);try{await Rh1(Q,{...J,threadId:Y},X)}catch(K){await q41(K,Y)}}async function pQ9(J,Q,Z){PV(Z,J);let X=await TV(Q,J),Y=$41(J);if(Y instanceof Error)JX(Y.message);try{let K=yK(),q={id:K,messages:[],created:Date.now(),v:0};X.threadStorage.set(K,q);let G=await CJ.uploadThread({thread:q,createdOnServer:!1});if(!G.ok)throw Error(`Failed to create thread on server: ${G.error.code}`);if(await Oh1(K),Y)await X.threadSyncService.updateThreadMeta(K,I41(Y));g2.write(`${K}
6095
+ `),await Y.asyncDispose(),process.exit(1)}}async function cY6(J){let Q=J;if(!Q){if(Q=await jQ9(),!Q)throw new V2("No thread ID provided and no previously used thread found.",1,"Provide a thread ID as an argument or run a thread first.")}else{let Z=$h1(Q);if(!Z)Ih1(Q);Q=Z}if(!fU(Q))throw new V2(OK.invalidThreadId);return Q}function $h1(J){if(fU(J))return J;let Q=J.match(/\/threads\/(T-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);if(Q?.[1]&&fU(Q[1]))return Q[1];return null}function Ih1(J){throw new V2(`Invalid thread ID or URL: ${J}`,1,"Provide a valid thread ID (e.g., T-5928a90d-d53b-488f-a829-4e36442142ee) or thread URL (e.g., https://ampcode.com/threads/T-5928a90d-d53b-488f-a829-4e36442142ee)")}async function uQ9(J,Q,Z,X){let Y=await cY6(Z);try{await Rh1(Q,{...J,threadId:Y},X)}catch(K){await q41(K,Y)}}async function pQ9(J,Q,Z){PV(Z,J);let X=await TV(Q,J),Y=$41(J);if(Y instanceof Error)JX(Y.message);try{let K=yK(),q={id:K,messages:[],created:Date.now(),v:0};X.threadStorage.set(K,q);let G=await CJ.uploadThread({thread:q,createdOnServer:!1},{config:X.configService});if(!G.ok)throw Error(`Failed to create thread on server: ${G.error.code}`);if(await Oh1(K),Y)await X.threadSyncService.updateThreadMeta(K,I41(Y));g2.write(`${K}
6096
6096
  `),await X.asyncDispose(),process.exit(0)}catch(K){s2.write(`Error creating thread: ${K instanceof Error?K.message:String(K)}
6097
6097
  `),await X.asyncDispose(),process.exit(1)}}async function gY6(J,Q,Z){PV(Z,J);let X=await TV(Q,J);try{let Y=await P5("/api/user",void 0,X.configService);if(!Y.ok)s2.write(`Failed to get user info: ${Y.status} ${await Y.text()}
6098
6098
  `),process.exit(1);let q=(await Y.json()).id,G=await P5(`/api/threads?createdByUserID=${q}`,void 0,X.configService);if(!G.ok)s2.write(`Failed to load threads: ${G.status} ${await G.text()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1759974740-g48b1d2",
3
+ "version": "0.0.1759982493-gb3a8ef",
4
4
  "description": "CLI for Amp, an agentic coding tool in research preview from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {