@sourcegraph/amp 0.0.1772280107-g5cb360 → 0.0.1772294494-g9b3cb4

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
@@ -5879,11 +5879,11 @@ ${W}`))}},error:(F)=>{if(!G)G=!0,D(Error(`Failed to spawn brew: ${F.message}`))}
5879
5879
  ${W}`;if(Y==="pnpm"&&W.includes("Unable to find the global bin directory"))H+=`
5880
5880
 
5881
5881
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
5882
- npm install -g @sourcegraph/amp`;D(Error(H))}},error:(F)=>{if(!q)q=!0,D(Error(`Failed to spawn ${Y}: ${F.message}`))},complete:()=>{if(!q)q=!0,V()}})})}m0();m0();rA();async function i30(J,Z){let X=Z||"https://registry.npmjs.org",Y=new AbortController,U=setTimeout(()=>Y.abort(),5000);try{let V=await fetch(`${X}/@sourcegraph/amp`,{signal:Y.signal});if(!V.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let D=await V.json(),K=D["dist-tags"]?.latest;if(!K)return{hasUpdate:!1,currentVersion:J,source:"npm"};let z=UX4(J,K),q=z<0,G,F;if(D.time){let W=D.time[J],H=D.time[K],B=Date.now();if(W)G=Math.floor((B-new Date(W).getTime())/3600000);if(H)F=Math.floor((B-new Date(H).getTime())/3600000)}return P.info("NPM version comparison",{currentVersion:J,latestVersion:K,compareResult:z,hasUpdate:q,currentVersionAge:G,latestVersionAge:F}),{hasUpdate:q,latestVersion:K,currentVersion:J,currentVersionAge:G,latestVersionAge:F,source:"npm"}}catch(V){return P.debug("Error checking npm version",{error:V}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(U)}}var aw5="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function n30(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let X=await fetch(`${aw5}?t=${Date.now()}`,{signal:Z.signal,cache:"no-store"});if(!X.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let Y=(await X.text()).trim();if(!Y||!/^\d+\.\d+\.\d+/.test(Y))return{hasUpdate:!1,currentVersion:J,source:"bin"};let U=UX4(J,Y),V=U<0;return P.info("Bin version comparison",{currentVersion:J,latestVersion:Y,compareResult:U,hasUpdate:V}),{hasUpdate:V,latestVersion:Y,currentVersion:J,source:"bin"}}catch(X){return P.debug("Error checking bin version",{error:X}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var ow5=604800000;function YX4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>ow5)return{ageMs:Q};return null}function UX4(J,Z){let Q=(V)=>{let[D,K]=V.split("-");return{parts:D?.split(".").map(Number)||[],label:K}},X=Q(J),Y=Q(Z),U=Math.max(X.parts.length,Y.parts.length);for(let V=0;V<U;V++){let D=X.parts[V]||0,K=Y.parts[V]||0;if(D<K)return-1;if(D>K)return 1}if(X.label===Y.label)return 0;if(!X.label&&Y.label)return 1;if(X.label&&!Y.label)return-1;if(X.label&&Y.label)return X.label<Y.label?-1:1;return 0}function ey0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,X=Z[2],Y=Q!==0?YF(Q):void 0;return{sha:X,age:Y}}catch{return null}}H1();function $u0(J,Z){let Q=new U4,X=Q.pipe(L6({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new GV().scoped("update"),U=X.subscribe({next:(V)=>{Y.debug("emit new state",V)}});try{let V=process.env.AMP_TEST_UPDATE_STATUS;if(V){Y.debug("using fake update status for testing",{status:V}),await zz(500),Q.next(V);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){Y.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let D=await Z.get("updates.mode");if(D==="disabled"){Y.debug("checking disabled");return}let K=await l30(),z=K==="binary"||K==="brew";Y.debug("checking",{currentVersion:J,mode:D,packageManager:K,isBinaryDistribution:z});let q=z?await n30(J):await i30(J,BE());if(!(q.latestVersion&&q.hasUpdate)){Y.debug("no update available");return}let G=()=>{if(q.currentVersionAge!==void 0&&q.latestVersionAge!==void 0){let F=q.currentVersionAge-q.latestVersionAge,W=0.5;if(Math.abs(F)<0.5)return Y.debug("versions too close together, suppressing update warning",{currentVersionAge:q.currentVersionAge,latestVersionAge:q.latestVersionAge,ageDifferenceHours:F}),!0}return!1};if(!D)D=K==="pnpm"?"warn":"auto",Y.debug("no configured update mode; selected default based on package manager",{packageManager:K,mode:D});if(K==="brew"){if(!G())Q.next("update-available-brew");return}if(K==="binary"&&process.execPath!==ny0()){if(Y.debug("non-standard binary path, showing warning"),!G())Q.next("update-available-unrecognized-path");return}if(D==="warn"){if(!G())Q.next("update-available");return}if(!K){if(Y.debug("auto-update not supported, falling back to warn mode"),!G())Q.next("update-available");return}if(K==="binary"&&process.platform==="win32"){if(Y.debug("binary auto-update not supported on Windows, falling back to warn mode"),!G())Q.next("update-available");return}try{await zm(q.latestVersion,K);let F=await bW(q.latestVersion),W={from:q.currentVersion,to:q.latestVersion,...F};if(F.status==="same")Y.info("success",W),Q.next("updated");else Y.warn("success with warning",W),Q.next("updated-with-warning")}catch(F){Q.next("update-error")}}catch(V){Y.debug("check failed",{error:V})}finally{await zz(5000),Q.next("hidden"),U.unsubscribe(),Q.complete()}}),{state:X}}rA();import{stderr as SD}from"node:process";function VX4(J){let Z=new RW().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(X)=>{await dy0(X.force||!1,X.verbose||!1,"0.0.1772280107-g5cb360"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new RW("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(X)=>{await rw5(X.targetVersion)});J.addCommand(Q)}async function rw5(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")SD.write(Z1.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
5882
+ npm install -g @sourcegraph/amp`;D(Error(H))}},error:(F)=>{if(!q)q=!0,D(Error(`Failed to spawn ${Y}: ${F.message}`))},complete:()=>{if(!q)q=!0,V()}})})}m0();m0();rA();async function i30(J,Z){let X=Z||"https://registry.npmjs.org",Y=new AbortController,U=setTimeout(()=>Y.abort(),5000);try{let V=await fetch(`${X}/@sourcegraph/amp`,{signal:Y.signal});if(!V.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let D=await V.json(),K=D["dist-tags"]?.latest;if(!K)return{hasUpdate:!1,currentVersion:J,source:"npm"};let z=UX4(J,K),q=z<0,G,F;if(D.time){let W=D.time[J],H=D.time[K],B=Date.now();if(W)G=Math.floor((B-new Date(W).getTime())/3600000);if(H)F=Math.floor((B-new Date(H).getTime())/3600000)}return P.info("NPM version comparison",{currentVersion:J,latestVersion:K,compareResult:z,hasUpdate:q,currentVersionAge:G,latestVersionAge:F}),{hasUpdate:q,latestVersion:K,currentVersion:J,currentVersionAge:G,latestVersionAge:F,source:"npm"}}catch(V){return P.debug("Error checking npm version",{error:V}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(U)}}var aw5="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function n30(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let X=await fetch(`${aw5}?t=${Date.now()}`,{signal:Z.signal,cache:"no-store"});if(!X.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let Y=(await X.text()).trim();if(!Y||!/^\d+\.\d+\.\d+/.test(Y))return{hasUpdate:!1,currentVersion:J,source:"bin"};let U=UX4(J,Y),V=U<0;return P.info("Bin version comparison",{currentVersion:J,latestVersion:Y,compareResult:U,hasUpdate:V}),{hasUpdate:V,latestVersion:Y,currentVersion:J,source:"bin"}}catch(X){return P.debug("Error checking bin version",{error:X}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var ow5=604800000;function YX4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>ow5)return{ageMs:Q};return null}function UX4(J,Z){let Q=(V)=>{let[D,K]=V.split("-");return{parts:D?.split(".").map(Number)||[],label:K}},X=Q(J),Y=Q(Z),U=Math.max(X.parts.length,Y.parts.length);for(let V=0;V<U;V++){let D=X.parts[V]||0,K=Y.parts[V]||0;if(D<K)return-1;if(D>K)return 1}if(X.label===Y.label)return 0;if(!X.label&&Y.label)return 1;if(X.label&&!Y.label)return-1;if(X.label&&Y.label)return X.label<Y.label?-1:1;return 0}function ey0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,X=Z[2],Y=Q!==0?YF(Q):void 0;return{sha:X,age:Y}}catch{return null}}H1();function $u0(J,Z){let Q=new U4,X=Q.pipe(L6({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new GV().scoped("update"),U=X.subscribe({next:(V)=>{Y.debug("emit new state",V)}});try{let V=process.env.AMP_TEST_UPDATE_STATUS;if(V){Y.debug("using fake update status for testing",{status:V}),await zz(500),Q.next(V);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){Y.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let D=await Z.get("updates.mode");if(D==="disabled"){Y.debug("checking disabled");return}let K=await l30(),z=K==="binary"||K==="brew";Y.debug("checking",{currentVersion:J,mode:D,packageManager:K,isBinaryDistribution:z});let q=z?await n30(J):await i30(J,BE());if(!(q.latestVersion&&q.hasUpdate)){Y.debug("no update available");return}let G=()=>{if(q.currentVersionAge!==void 0&&q.latestVersionAge!==void 0){let F=q.currentVersionAge-q.latestVersionAge,W=0.5;if(Math.abs(F)<0.5)return Y.debug("versions too close together, suppressing update warning",{currentVersionAge:q.currentVersionAge,latestVersionAge:q.latestVersionAge,ageDifferenceHours:F}),!0}return!1};if(!D)D=K==="pnpm"?"warn":"auto",Y.debug("no configured update mode; selected default based on package manager",{packageManager:K,mode:D});if(K==="brew"){if(!G())Q.next("update-available-brew");return}if(K==="binary"&&process.execPath!==ny0()){if(Y.debug("non-standard binary path, showing warning"),!G())Q.next("update-available-unrecognized-path");return}if(D==="warn"){if(!G())Q.next("update-available");return}if(!K){if(Y.debug("auto-update not supported, falling back to warn mode"),!G())Q.next("update-available");return}if(K==="binary"&&process.platform==="win32"){if(Y.debug("binary auto-update not supported on Windows, falling back to warn mode"),!G())Q.next("update-available");return}try{await zm(q.latestVersion,K);let F=await bW(q.latestVersion),W={from:q.currentVersion,to:q.latestVersion,...F};if(F.status==="same")Y.info("success",W),Q.next("updated");else Y.warn("success with warning",W),Q.next("updated-with-warning")}catch(F){Q.next("update-error")}}catch(V){Y.debug("check failed",{error:V})}finally{await zz(5000),Q.next("hidden"),U.unsubscribe(),Q.complete()}}),{state:X}}rA();import{stderr as SD}from"node:process";function VX4(J){let Z=new RW().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(X)=>{await dy0(X.force||!1,X.verbose||!1,"0.0.1772294494-g9b3cb4"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new RW("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(X)=>{await rw5(X.targetVersion)});J.addCommand(Q)}async function rw5(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")SD.write(Z1.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
5883
5883
 
5884
5884
  `));try{if(!J){SD.write(Z1.blue(`Checking for updates...
5885
- `));let{hasUpdate:X,latestVersion:Y}=cy0()?await n30("0.0.1772280107-g5cb360"):await i30("0.0.1772280107-g5cb360",BE());if(!X){let U=ey0("0.0.1772280107-g5cb360"),V=U?.age?`released ${U.age} ago`:`built ${YF(new Date("2026-02-28T12:07:30.550Z"))} ago`;SD.write(Z1.green(`✓ Amp is already up to date on version ${"0.0.1772280107-g5cb360"} (${V})
5886
- `));let D=await bW("0.0.1772280107-g5cb360");if(D.warning)SD.write(`
5885
+ `));let{hasUpdate:X,latestVersion:Y}=cy0()?await n30("0.0.1772294494-g9b3cb4"):await i30("0.0.1772294494-g9b3cb4",BE());if(!X){let U=ey0("0.0.1772294494-g9b3cb4"),V=U?.age?`released ${U.age} ago`:`built ${YF(new Date("2026-02-28T16:07:19.137Z"))} ago`;SD.write(Z1.green(`✓ Amp is already up to date on version ${"0.0.1772294494-g9b3cb4"} (${V})
5886
+ `));let D=await bW("0.0.1772294494-g9b3cb4");if(D.warning)SD.write(`
5887
5887
  `+Z1.yellow(D.warning)+`
5888
5888
  `);process.exit(0)}if(!Y)SD.write(Z1.yellow("[WARN] could not find latest version")),process.exit(0);J=Y}SD.write(Z1.blue(`Updating to version ${J}...
5889
5889
  `)),await zm(J,void 0,(X)=>{SD.write(Z1.dim(`Running: ${X}
@@ -6207,7 +6207,7 @@ To fix: Add "amp.mcpTrustedWorkspaces": ["${Z.getWorkspaceRootPath()}"] to ${X}
6207
6207
  `)}};function vN5(J){let Z={};for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X&&X.startsWith("--")){let Y=X.slice(2),U=J[Q+1];if(U&&!U.startsWith("--"))Z[Y]=U,Q++}}return Z}function kN5(J){if(J.action==="ask")return 1;if(J.action==="reject")return 2;return 0}async function jX4(J){let Z=J.json?_N5:SN5;try{let Q=vN5(J.remainingArgs),X=await J.settings.get("permissions",J.scope)??[],Y=PG(X);if(!Y.success){let V={success:!1,error:"Invalid permissions configuration",details:Y.error.issues.map((D)=>({path:D.path.join("."),message:D.message,code:D.code}))};Z.outputError(J,Q,V),J.exit(1);return}let U=await kM(J.toolName,Q,Y.data,J.context,rv,J.threadId,"user");if(!U.matchedEntry)U=await kM(J.toolName,Q,vM,J.context,rv,J.threadId,"built-in");Z.outputResult(J,Q,U),J.exit(kN5(U))}catch(Q){let X={success:!1,error:Q instanceof Error?Q.message:"Unknown error"};Z.outputError(J,{},X),J.exit(1)}}function RX4(J,Z){let Q=J.command("permissions").alias("permission").summary("Manage permissions").description(`Configure and test tool permissions to control what actions the AI agent can take.
6208
6208
 
6209
6209
  See ${Z1.underline("https://ampcode.com/manual#permissions")} for more details`).enablePositionalOptions();yN5(Q,Z),uN5(Q,Z),xN5(Q,Z),fN5(Q,Z)}function yN5(J,Z){J.command("list").alias("ls").summary("List permissions").description("List user-configured permissions.").option("--json","output as JSON").option("--builtin","output only builtin permissions").option("-w, --workspace","List workspace permissions instead of global").action(async(Q,X)=>{let Y=await Z(X),U=X.optsWithGlobals();await AX4({builtinOnly:U.builtin??!1,settings:Y.settings,exit:process.exit.bind(process),json:U.json,stdout:process.stdout,scope:U.workspace?"workspace":"global"})})}function uN5(J,Z){J.command("test").summary("Test permissions").description("Test permissions against configured rules without running the tool.").argument("<tool-name>","Name of the tool to test").option("-c, --context <context>","Execution context (thread or subagent)").option("-t, --thread-id <id>","Thread ID for evaluation").option("--json","output as JSON").option("-q, --quiet","suppress output, only use exit status").option("-w, --workspace","Test against workspace permissions instead of global").allowUnknownOption(!0).action(async(Q,X,Y)=>{let U=await Z(Y),V=()=>!1;await jX4({toolName:Q,context:X.context,threadId:X.threadId,json:X.json,settings:U.settings,remainingArgs:Y.args,stdout:X.quiet?{write:V}:process.stdout,stderr:process.stderr,exit:process.exit.bind(process),scope:X.workspace?"workspace":"global"})}).addHelpText("after",["Example: "," # Test permissions of Amp trying to use bash"," amp permissions test Bash --cmd ls"," # ...when running in a subagent"," amp permissions test --context subagent Bash --cmd ls","","See output of:",""," amp tools show","","for all tool schemas."].join(`
6210
- `))}function xN5(J,Z){J.command("edit").summary("Edit permissions").description("Edit permissions interactively in your $EDITOR or from stdin.").option("-w, --workspace","Edit workspace permissions instead of global").action(async(Q,X)=>{let Y=await Z(X);await o30({settings:Y.settings,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,exit:process.exit.bind(process),resolveEditor:JC,scope:Q.workspace?"workspace":"global"})})}function fN5(J,Z){J.command("add").summary("Add permission rule").description("Add a permission rule to the beginning of the list. Rules are evaluated in order, so newer rules take precedence.").argument("<action>","Permission action: allow, reject, ask, or delegate").option("--to <program>","Program to delegate decision to for delegate action").option("--context <type>","Limit to specific context (thread or subagent)").option("-w, --workspace","Add to workspace permissions instead of global").argument("<tool>",'Tool name (supports globs like "mcp__playwright__*")').allowUnknownOption(!0).action(async(Q,X,Y,U)=>{let V=await Z(U);await EX4({args:U.parent?.args.slice(1)??[],settings:V.settings,stderr:process.stderr,exit:process.exit.bind(process),scope:Y.workspace?"workspace":"global"})})}m0();import{exec as bN5}from"node:child_process";import{platform as hN5}from"node:os";import{stderr as ZC}from"node:process";u9();async function PX4(J,Z,Q){let U=(await(await vJ({configService:Z},Q)).messages.create({model:cV,max_tokens:300,system:"You are a classifier that answers yes/no questions. You must use the provided tool to give your answer with reasoning.",messages:[{role:"user",content:J}],tools:[{name:"answer_question",description:"Provide your answer to the yes/no question with reasoning",input_schema:{type:"object",properties:{probability_yes:{type:"number",description:'Probability that the answer is "yes", from 0 to 1. Use 0 for definitely no, 0.5 for uncertain, 1 for definitely yes.'},reasoning:{type:"string",description:"Brief (2-sentence max) explanation of why you gave this probability."}},required:["probability_yes","reasoning"]}}],tool_choice:{type:"tool",name:"answer_question"}},{headers:{"anthropic-beta":"interleaved-thinking-2025-05-14"}})).content.find((q)=>q.type==="tool_use");if(!U||U.type!=="tool_use")throw Error("Expected tool use response from Claude");let V=U.input,D=V.probability_yes??0.5,K=V.reasoning??"No reasoning provided",z;if(D>=0.8)z="yes";else if(D<0.2)z="no";else z="uncertain";return{result:z,probability:D,reason:K}}class Xu0{clientKind="terminal";clientVersion="0.0.1772280107-g5cb360";showToast=null;appendToThreadHandler=null;showOpenedURLToast=null;showInputDialog=null;showConfirmDialog=null;configService;constructor(J){this.configService=J.configService}async notify(J){if(this.showToast)this.showToast(J);else P.debug("plugin notification (TUI not loaded): %s",J)}async open(J){let Z=hN5(),Q=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";if(await new Promise((X,Y)=>{bN5(`${Q} ${JSON.stringify(J)}`,(U)=>{if(U)Y(U);else X()})}),this.showOpenedURLToast)this.showOpenedURLToast(J);else ZC.write(`
6210
+ `))}function xN5(J,Z){J.command("edit").summary("Edit permissions").description("Edit permissions interactively in your $EDITOR or from stdin.").option("-w, --workspace","Edit workspace permissions instead of global").action(async(Q,X)=>{let Y=await Z(X);await o30({settings:Y.settings,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,exit:process.exit.bind(process),resolveEditor:JC,scope:Q.workspace?"workspace":"global"})})}function fN5(J,Z){J.command("add").summary("Add permission rule").description("Add a permission rule to the beginning of the list. Rules are evaluated in order, so newer rules take precedence.").argument("<action>","Permission action: allow, reject, ask, or delegate").option("--to <program>","Program to delegate decision to for delegate action").option("--context <type>","Limit to specific context (thread or subagent)").option("-w, --workspace","Add to workspace permissions instead of global").argument("<tool>",'Tool name (supports globs like "mcp__playwright__*")').allowUnknownOption(!0).action(async(Q,X,Y,U)=>{let V=await Z(U);await EX4({args:U.parent?.args.slice(1)??[],settings:V.settings,stderr:process.stderr,exit:process.exit.bind(process),scope:Y.workspace?"workspace":"global"})})}m0();import{exec as bN5}from"node:child_process";import{platform as hN5}from"node:os";import{stderr as ZC}from"node:process";u9();async function PX4(J,Z,Q){let U=(await(await vJ({configService:Z},Q)).messages.create({model:cV,max_tokens:300,system:"You are a classifier that answers yes/no questions. You must use the provided tool to give your answer with reasoning.",messages:[{role:"user",content:J}],tools:[{name:"answer_question",description:"Provide your answer to the yes/no question with reasoning",input_schema:{type:"object",properties:{probability_yes:{type:"number",description:'Probability that the answer is "yes", from 0 to 1. Use 0 for definitely no, 0.5 for uncertain, 1 for definitely yes.'},reasoning:{type:"string",description:"Brief (2-sentence max) explanation of why you gave this probability."}},required:["probability_yes","reasoning"]}}],tool_choice:{type:"tool",name:"answer_question"}},{headers:{"anthropic-beta":"interleaved-thinking-2025-05-14"}})).content.find((q)=>q.type==="tool_use");if(!U||U.type!=="tool_use")throw Error("Expected tool use response from Claude");let V=U.input,D=V.probability_yes??0.5,K=V.reasoning??"No reasoning provided",z;if(D>=0.8)z="yes";else if(D<0.2)z="no";else z="uncertain";return{result:z,probability:D,reason:K}}class Xu0{clientKind="terminal";clientVersion="0.0.1772294494-g9b3cb4";showToast=null;appendToThreadHandler=null;showOpenedURLToast=null;showInputDialog=null;showConfirmDialog=null;configService;constructor(J){this.configService=J.configService}async notify(J){if(this.showToast)this.showToast(J);else P.debug("plugin notification (TUI not loaded): %s",J)}async open(J){let Z=hN5(),Q=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";if(await new Promise((X,Y)=>{bN5(`${Q} ${JSON.stringify(J)}`,(U)=>{if(U)Y(U);else X()})}),this.showOpenedURLToast)this.showOpenedURLToast(J);else ZC.write(`
6211
6211
  Opened URL: ${J}
6212
6212
 
6213
6213
  `)}async input(J){if(this.showInputDialog)return this.showInputDialog(J);ZC.write(`
@@ -6860,7 +6860,7 @@ Ctrl-X, Y, Z to unlock`;if(F){let f=z.text.replace(/`([^`]+)`/g,"$1")+`
6860
6860
  `),new T("Ctrl+O",B),new T(" for ",N),new T("help",w),new T(`
6861
6861
 
6862
6862
 
6863
- `,N)])}),A];if(!K&&!F&&z.url){let h=z.url.replace(/^https?:\/\//,"");_.push(new J5({uri:z.url,text:h,style:new b({color:Q.secondary,underline:!0})}))}if(M&&!F)_.push(M);let k=new R0({width:50,child:new u0({crossAxisAlignment:"start",mainAxisSize:"min",children:_})}),y=W?new R0({width:L20,height:I20}):new Ox0({width:L20,height:I20,agentMode:this.widget.agentMode,glow:this._glow,backgroundColor:Q.background,t:q,fps:0,shockwaves:this._shockwaves,onShockwave:this.handleShockwave,onClick:this.handleOrbClick,...V==="disabled"&&{seed:42}});return a1.child(new K1({mainAxisAlignment:"center",crossAxisAlignment:"center",mainAxisSize:"min",children:[y,new R0({width:2}),k]}))}}class gm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new DB4}}class DB4 extends g0{build(J){let Q=f0.of(J).colors,{todos:X,title:Y="TODOs"}=this.widget.props;if(!Array.isArray(X)||X.length===0)return new R0({width:0,height:0});let U=X.map((V)=>this.buildTodoItem(V,Q));return new l0({child:new o0({padding:C0.symmetric(1,0),child:new u0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new Q0({text:new T(Y,new b({bold:!0,color:Q.foreground}))}),...U]})})})}buildTodoItem(J,Z){let Q=this.getStatusIcon(J.status),X=J.status==="completed",Y=new b({bold:J.status==="in-progress",color:Z.foreground,dim:X}),U=new b({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Z.foreground,dim:X});return new K1({crossAxisAlignment:"start",children:[new Q0({text:new T(Q,Y)}),new R0({width:1}),new S1({child:new Q0({text:new T(J.content,U)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class pm0 extends p0{ad;onDismiss;onButtonClick;onImpression;onAdInfoClick;constructor({key:J,ad:Z,onDismiss:Q,onButtonClick:X,onImpression:Y,onAdInfoClick:U}){super({key:J});this.ad=Z,this.onDismiss=Q,this.onButtonClick=X,this.onImpression=Y,this.onAdInfoClick=U}createState(){return new KB4}}class KB4 extends g0{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 Z=f0.of(J),Q=Z.colors.primary,X=Z.colors.foreground,Y=Z.colors.background,U=this.widget.ad;return new l0({decoration:new _4(Y,new h1(new y1(Q,1,"rounded"),new y1(Q,1,"rounded"),void 0,new y1(Q,1,"rounded"))),child:new o0({padding:C0.horizontal(1),child:new u0({children:[new K1({crossAxisAlignment:"start",children:[new S1({child:new Q0({text:new T(U.content,new b({color:X}))})}),new R0({width:4}),new i1({onClick:()=>this.widget.onAdInfoClick?.(),cursor:"pointer",child:new Q0({text:new T("Ad",new b({color:X,dim:!0}))})})]}),new K1({crossAxisAlignment:"start",children:[new om({text:U.buttonLabel,onPressed:()=>this.widget.onButtonClick?.(),padding:C0.horizontal(1),color:Q,reverse:!0}),new R0({width:2}),new Q0({text:new T(U.destinationUrlHostname,new b({color:X,dim:!0}))})]})]})})})}}class dm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new zB4(this.props.autofocus??!0)}}class zB4 extends g0{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=P1.of(J).colorScheme,X=(z)=>{if(z.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(z.ctrlKey&&z.key==="c"||z.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},Y=s1.sizeOf(J),U=Math.min(60,Y.width-4),V=Y.height-4,D=[];if(this.widget.props.title)D.push(new Q0({text:new T(this.widget.props.title,new b({bold:!0,color:Q.primary}))}),new R0({height:1}));if(this.widget.props.message)D.push(new Q0({text:new T(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)D.push(new R0({height:1}));let K=[];if(this.widget.props.showCopyOption)K.push(new Q0({text:new T("Enter to copy",new b({dim:!0}))}));return K.push(new Q0({text:new T("Escape to close",new b({dim:!0}))})),D.push(new K1({children:K.flatMap((z,q)=>q<K.length-1?[z,new R0({width:1}),new Q0({text:new T("•",new b({dim:!0}))}),new R0({width:1})]:[z]),mainAxisSize:"min"})),new a1({child:new l0({constraints:new I1(U,U,0,V),decoration:new _4(Q.background,new h1(new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"))),padding:new C0(2,2,2,2),child:new T4({autofocus:this.autofocus,onKey:X,child:new u0({children:D,mainAxisSize:"min"})})})})}}class cm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new qB4(this.props.autofocus??!0)}}class qB4 extends g0{autofocus;constructor(J){super();this.autofocus=J}build(J){let Z=P1.of(J).colorScheme,Q=(D)=>{if(D.key==="Enter"||D.key==="Escape"||D.ctrlKey&&D.key==="c")return this.widget.props.onClose(),"handled";return"ignored"},X=s1.sizeOf(J),Y=Math.min(60,X.width-4),U=X.height-4,V=[];if(V.push(new Q0({text:new T("Ads make Amp Free possible",new b({bold:!0}))})),this.widget.props.provider)V.push(new R0({height:1}),new Q0({text:new T(`Ad source: ${this.widget.props.provider}`,new b({dim:!0}))}));return V.push(new R0({height:1}),new Q0({text:new T("Escape to close",new b({dim:!0}))})),new a1({child:new l0({constraints:new I1(Y,Y,0,U),decoration:new _4(Z.background,new h1(new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"))),padding:new C0(2,2,2,2),child:new T4({autofocus:this.autofocus,onKey:Q,child:new u0({children:V,mainAxisSize:"min"})})})})}}m0();n9();import{execSync as jh5}from"node:child_process";aM();FJ();O3();t7();Rw();LY();I$();CJ();NY();iO();c4();vu();Tv();H1();var Kw4=E4(Kz(),1);import{writeFile as Xw4}from"fs/promises";import Yw4 from"path";m0();I$();class lm0{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1772280107-g5cb360"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await xs(Z,this.configService)}catch(Z){P.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class _H extends p0{props;constructor(J){super();this.props=J}createState(){return new GB4}}class GB4 extends g0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}class FB4 extends g0{controller=new v7;focusNode=new i4({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:X}=Z,Y=this.widget.props.isRequiredArg??!0,U=this.controller.text.trim().length>0,V=!Y||U,D=h1.all(new y1(Q.foreground,1,"solid")),K=new d$({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(W)=>{let H=W.trim();if(Y&&H.length===0)return;this.widget.props.onSubmit(H)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),z=new K1({children:[new l0({decoration:{color:Q.background},child:new Q0({text:new T(">",new b({color:Q.foreground}))})}),new S1({child:K})]}),q=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("",void 0,[new T("Command: ",new b({color:Q.foreground})),new T(this.widget.props.commandName,new b({color:X.command,bold:!0}))])})}),G=[];if(V)G.push(new T("Enter",new b({color:X.keybind}))),G.push(new T(" to submit, ",new b({color:Q.foreground,dim:!0})));G.push(new T("Esc",new b({color:X.keybind}))),G.push(new T(" to cancel",new b({color:Q.foreground,dim:!0})));let F=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("",void 0,G)})});return new l0({decoration:{border:D,color:Q.background},padding:C0.all(1),child:new u0({children:[q,new R0({height:1}),z,new Z3,F]})})}}class Gp extends p0{props;constructor(J){super();this.props=J}createState(){return new FB4}}import{isDeepStrictEqual as im0}from"node:util";var sb5=/[\\/_ +.#"@[({&]/,tb5=/[\\/_ +.#"@[({&]/g,eb5=/[\s-]/,WB4=/[\s-]/g;function j20(J,Z,Q,X,Y,U,V){if(U===Z.length){if(Y===J.length)return 1;return 0.99}let D=`${Y},${U}`;if(V[D]!==void 0)return V[D];let K=X.charAt(U),z=Q.indexOf(K,Y),q=0,G,F,W,H;while(z>=0){if(G=j20(J,Z,Q,X,z+1,U+1,V),G>q){if(z===Y)G*=1;else if(eb5.test(J.charAt(z-1))){if(G*=0.9,H=J.slice(Y,z-1).match(WB4),H&&Y>0)G*=0.999**H.length}else if(sb5.test(J.charAt(z-1))){if(G*=0.8,W=J.slice(Y,z-1).match(tb5),W&&Y>0)G*=0.999**W.length}else if(G*=0.3,Y>0)G*=0.999**(z-Y);if(J.charAt(z)!==Z.charAt(U))G*=0.9999}if(G<0.1&&(Q.charAt(z-1)===X.charAt(U+1)||X.charAt(U+1)===X.charAt(U)&&Q.charAt(z-1)!==X.charAt(U))){if(F=j20(J,Z,Q,X,z+1,U+2,V),F*0.1>G)G=F*0.1}if(G>q)q=G;z=Q.indexOf(K,z+1)}return V[D]=q,q}function A20(J){return J.toLowerCase().replace(WB4," ")}function HB4(J,Z){let Q=j20(J,Z,A20(J),A20(Z),0,0,{}),X=Z.trim().split(/\s+/);if(X.length>1){let Y=0,U=0;for(let D of X){let K=j20(J,D,A20(J),A20(D),0,0,{});if(K===0)return Q;Y+=K,U+=D.length}let V=Y/X.length*0.95;return Math.max(Q,V)}return Q}class KT{}class zT{}class R20{}class P20{}class BB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new wB4}}class wB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}function $h5(J,Z){if(J==="")return{matches:!0,score:1};let Q=HB4(Z,J);return{matches:Q>0.15,score:Q}}class p9 extends p0{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new NB4}}class NB4 extends g0{textController;focusNode;scrollController=new r6;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){if(this.scrollController.disableFollowMode(),this.textController=new v7(this.widget.props.controller?.query??""),this.focusNode=new i4({debugLabel:this.widget.debugLabel}),this.textController.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let J=this.widget.props.controller;if(J)J.query=this.textController.text;this.syncSelection()}),this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let J=this.cachedFiltered.findIndex((Z)=>im0(Z,this.widget.props.controller?.selectedItem));if(J>=0)this.selectedIndex=J}this.clampSelectedIndex(),this.syncSelection(),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!im0(J.props.items,this.widget.props.items)){if(this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let Z=this.cachedFiltered.findIndex((Q)=>im0(Q,this.widget.props.controller?.selectedItem));if(Z>=0)this.selectedIndex=Z}this.clampSelectedIndex(),this.ensureSelectedItemVisible(),this.syncSelection()}}dispose(){this.widget.props.onSelectionChange?.(null),this.textController.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof KT){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof zT){if(this.getFilteredItems().length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof R20){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length){let Q=Z[this.selectedIndex];if(Q){if(!(this.widget.props.isItemDisabled?.(Q)??!1))this.widget.props.onAccept(Q,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof P20)return this.widget.props.onDismiss?.(),"handled";return"ignored"};syncSelection(){let Z=this.cachedFiltered[this.selectedIndex]??null;if(this.widget.props.controller)this.widget.props.controller.selectedItem=Z;this.widget.props.onSelectionChange?.(Z)}clampSelectedIndex(){let J=this.cachedFiltered.length-1;if(J<0){this.selectedIndex=0;return}this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,J))}recomputeFilteredItems(){let J=this.textController.text,Z=this.widget.props.items,Q=this.widget.props.normalizeQuery?.(J)??J,X=Z.filter((Y)=>!this.widget.props.filterItem||this.widget.props.filterItem(Y,J)).map((Y)=>({item:Y,...$h5(Q,this.widget.props.getLabel(Y))})).filter((Y)=>Y.matches).sort(this.widget.props.sortItems?(Y,U)=>this.widget.props.sortItems(Y,U,J):(Y,U)=>U.score-Y.score).map((Y)=>Y.item);this.cachedQuery=J,this.cachedItemsRef=Z,this.cachedFiltered=this.widget.props.maxRenderItems?X.slice(0,this.widget.props.maxRenderItems):X}getFilteredItems(){let J=this.textController.text,Z=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Z)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,X=Z.size.height;CC(J,{top:Q,bottom:X},{padding:1})}handleScroll=(J)=>{let Z=this.getFilteredItems();if(Z.length===0)return!1;let Q=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Z.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(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection(),this.selectedIndex!==Q};handleItemClick=(J,Z)=>{let Q=this.getFilteredItems();if(J>=0&&J<Q.length){let X=Q[J],Y=X?this.widget.props.isItemDisabled?.(X)??!1:!1;if(Z===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.syncSelection();else if(Z===2&&!Y){if(X)this.hasUserInteracted=!0,this.widget.props.onAccept(X,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Z=f0.of(J),{colors:Q}=Z,X=this.getFilteredItems(),Y=h1.all(new y1(Q.foreground,1,"solid")),U=this.widget.props.hidePromptWhenLoading&&this.widget.props.isLoading,V=this.widget.props.enabled??!0,D=new d$({controller:this.textController,focusNode:this.focusNode,autofocus:!0,enabled:V,style:{backgroundColor:Q.background,textColor:Q.foreground,cursorColor:Q.cursor,placeholderColor:Q.mutedForeground,border:null},maxLines:1}),K=new H2({shortcuts:new Map([[new t1("ArrowDown"),new KT],[new t1("ArrowUp"),new zT],[new t1("Tab"),new KT],[new t1("Tab",{shift:!0}),new zT],[new t1("n",{ctrl:!0}),new KT],[new t1("p",{ctrl:!0}),new zT],[new t1("Enter"),new R20],[new t1("Escape"),new P20]]),focusNode:this.focusNode,child:D}),z=new M9({actions:new Map([[KT,new n4(this.invoke)],[zT,new n4(this.invoke)],[R20,new n4(this.invoke)],[P20,new n4(this.invoke)]]),child:K}),q=new K1({children:[new l0({decoration:{color:Q.background},child:new Q0({text:new T(">",new b({color:Q.foreground}))})}),new S1({child:z})]});this.itemContexts=[];let G;if(this.widget.props.isLoading){let w=this.widget.props.loadingText??"Loading...";G=new R0({height:10,child:new a1({child:new Q0({text:new T(w,new b({color:Q.foreground}))})})})}else if(X.length===0&&this.widget.props.emptyStateText)G=new S1({child:new a1({child:new Q0({text:new T(this.widget.props.emptyStateText,new b({color:Q.foreground,dim:!0}))})})});else{let w=X.map((N,O)=>{let E=O===this.selectedIndex,L=this.widget.props.isItemDisabled?.(N)??!1,I;if(this.widget.props.renderItem)I=this.widget.props.renderItem(N,E,L,J);else{let M=E?Z.app.selectionBackground:void 0,A=E?Z.app.selectionForeground:Q.foreground;I=new l0({decoration:M?{color:M}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T(this.widget.props.getLabel(N),new b({color:A,dim:L}))})})}return new BB4(new i1({onClick:(M)=>this.handleItemClick(O,M.clickCount),child:I}),(M)=>{this.itemContexts[O]=M})});G=new u0({children:w,crossAxisAlignment:"start"})}let F=new i1({onScroll:this.handleScroll,opaque:!1,child:new O6({controller:this.scrollController,autofocus:!1,child:G})}),W=[];if(this.widget.props.title){let w=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T(this.widget.props.title,new b({color:Z.app.command,bold:!0}))})});W.push(w)}if(!U)W.push(q,new R0({height:1}));if(this.textController.text!==""){let w=X.length>0?X[this.selectedIndex]:void 0,N=w&&this.widget.props.buildDisabledReasonWidget?.(w,J);W.push(new S1({child:new u0({mainAxisAlignment:"spaceBetween",children:[new S1({child:F}),new l0({padding:C0.only({top:1}),child:new a1({child:N??new R0({height:1})})})]})}))}else W.push(new S1({child:F}));if(this.widget.props.footer)W.push(this.widget.props.footer);return new l0({decoration:{border:Y,color:Q.background},padding:C0.symmetric(1,0),child:new u0({children:W})})}}function OB4(J){let Q=new Date().getTime()-J.getTime(),X=Math.floor(Q/60000),Y=Math.floor(Q/3600000),U=Math.floor(Q/86400000);if(X<1)return"just now";if(X<60)return`${X}m ago`;if(Y<24)return`${Y}h ago`;if(U<7)return`${U}d ago`;return J.toLocaleDateString()}class nm0 extends d1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((Y,U)=>U.pubDate.getTime()-Y.pubDate.getTime()),Q=Math.max(0,...Z.map((Y)=>OB4(Y.pubDate).length));return new p9({items:Z,getLabel:(Y)=>Y.title,onAccept:(Y)=>this.props.onSelect?.(Y),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(Y,U,V,D)=>{let K=f0.of(D),{colors:z}=K,q=K.app,G=U?q.selectionBackground:void 0,F=U?q.selectionForeground:z.foreground,W=z.mutedForeground,H=(B,w)=>new R0({width:w,child:K1.end([new Q0({text:new T(B,new b({color:W}))})])});return new l0({decoration:G?{color:G}:void 0,padding:C0.symmetric(2,0),child:new K1({children:[new S1({child:new Q0({text:new T(Y.title,new b({color:F})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),H(OB4(Y.pubDate),Q)]})})}})}}c4();class am0 extends p0{createState(){return new EB4}}class EB4 extends g0{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 Q=f0.of(J).colors;return new Q0({text:new T("●",new b({color:this.isGreen?Q.success:Q.mutedForeground,bold:!0})),maxLines:1})}}var Jh5=/\/threads\/(T-[^/?#\s<>]+)/i;function Zh5(J){let Z=J.trim(),X=Z.match(Jh5)?.[1];if(X&&q8(X))return X;let Y=Z.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(q8(Y))return Y;return null}function Qh5(J){let Z=new Map,Q=new Map,X=new Map,Y=[];for(let V of J)Z.set(V.id,V);for(let V of J){let D=V.relationships.find((K)=>K.role==="child"&&Z.has(K.threadID)&&(K.type==="fork"||K.type==="handoff"));if(D){X.set(V.id,D.type);let K=D.threadID,z=Q.get(K)||[];z.push(V),Q.set(K,z)}else Y.push(V)}return l90.flatten(Y,(V)=>Q.get(V.id)).map((V)=>({...V.item,depth:V.depth,isLast:V.isLast,ancestorsAreLast:V.ancestorsAreLast,relationshipType:X.get(V.item.id)}))}function om0(J,Z,Q){return new Q0({text:new T(`${J}${Z}`,new b({color:Q})),maxLines:1})}function Xh5(J,Z,Q,X){return[om0("+",J,X.success),Z3.horizontal(1),om0("~",Z,X.warning),Z3.horizontal(1),om0("-",Q,X.destructive)]}function Yh5(J){return typeof J==="object"&&J!==null&&"then"in J&&typeof J.then==="function"}class C20 extends p0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}createState(){return new LB4}}class LB4 extends g0{spinner=new L3;spinnerInterval=null;isSwitchingThread=!1;get isBusy(){return this.isSwitchingThread||this.widget.props.isLoading===!0}updateSpinnerAnimation(){if(this.isBusy){if(!this.spinnerInterval)this.spinnerInterval=setInterval(()=>{this.spinner.step(),this.setState(()=>{})},100);return}if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null}setSwitchingThread(J){if(this.isSwitchingThread===J)return;this.setState(()=>{this.isSwitchingThread=J}),this.updateSpinnerAnimation()}initState(){super.initState(),this.updateSpinnerAnimation()}didUpdateWidget(J){this.updateSpinnerAnimation()}dispose(){if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null;super.dispose()}build(J){let{props:Z}=this.widget,Q=this.isBusy,X=this.isSwitchingThread?"Switching thread...":"Loading threads...",Y=`${this.spinner.toBraille()} ${X}`,U=Z.filterByWorkspace&&Z.currentWorkspaceURI?Z.threads.filter((O)=>O.workspaceURI===Z.currentWorkspaceURI):Z.threads;if(Z.excludeCurrentThread&&Z.currentThreadID)U=U.filter((O)=>O.id!==Z.currentThreadID);let V=Z.recentThreadIDs||[],D=new Set(V),K=Z.currentThreadID,z=[...U].sort((O,E)=>{if(K){if(O.id===K)return-1;if(E.id===K)return 1}let L=V.indexOf(O.id),I=V.indexOf(E.id);if(L!==-1&&I!==-1)return L-I;if(L!==-1)return-1;if(I!==-1)return 1;return 0}),q=Qh5(z),G=Math.max(0,...q.map((O)=>O.description.timeAgo.length)),F=f0.of(J),W=new o0({padding:C0.symmetric(0,1),child:new a1({child:new Q0({text:new T("",new b({color:F.colors.foreground,dim:!0}),[new T("Ctrl+T",new b({color:F.colors.primary,dim:!0})),new T(Z.filterByWorkspace?" for all workspaces":" to filter by workspace",new b({color:F.colors.foreground,dim:!0}))])})})}),H="",B=null,w=(O)=>{if(O!==H)H=O,B=Zh5(O);return B};return new p9({items:q,getLabel:(O)=>`${O.title} ${O.id}`,filterItem:(O,E)=>{let L=w(E);if(L)return O.id.toLowerCase()===L.toLowerCase();return!0},normalizeQuery:(O)=>w(O)?"":O,onAccept:async(O,E)=>{if(!Z.onSelect||this.isSwitchingThread)return;let L=Z.onSelect(O.id,E);if(!Yh5(L))return;this.setSwitchingThread(!0);try{await L}finally{if(this.mounted)this.setSwitchingThread(!1)}},onDismiss:Z.onDismiss,onSelectionChange:(O)=>{if(Z.previewController){if(O)Z.previewController.select(O.id)}},title:Z.title,enabled:!Q,isLoading:Q,hidePromptWhenLoading:!0,loadingText:Y,emptyStateText:"No threads match your filter",maxRenderItems:200,footer:Q?void 0:W,renderItem:(O,E,L,I)=>{let M=f0.of(I),{app:A,colors:j}=M,_=E?A.selectionBackground:void 0,k=E?A.selectionForeground:j.foreground,y=j.mutedForeground,h=($0,B0)=>new R0({width:B0,child:K1.end([new Q0({text:new T($0,new b({color:y}))})])}),f=Z.threadViewStates[O.id],S=[],x=O.relationshipType==="handoff",m=new Ng({connectorColor:j.mutedForeground});if(O.depth>0){let $0=[],B0=O.ancestorsAreLast.slice(1);for(let K0 of B0)$0.push(new T(m.getAncestorPrefix(K0),new b({color:m.connectorColor,dim:m.connectorDim})));let s=O.isLast?m.elbow:m.tee,q0=m.getConnectorText(s);$0.push(new T(q0,new b({color:m.connectorColor,dim:m.connectorDim}))),S.push(new Q0({text:new T("",void 0,$0)}))}let l=[],g=K===O.id?new T("(current) ",new b({color:j.success})):D.has(O.id)?new T("(visited) ",new b({color:j.foreground,dim:!0})):null;if(g)l.push(new Q0({text:g}));if(WO(f))l.push(new am0),l.push(new R0({width:1}));let n=O.title;if(O.relationshipType==="fork"){let $0=n.match(/^Forked\((\d+)\): /);if($0)n=n.slice($0[0].length);else while(n.startsWith("Forked: "))n=n.slice(8);l.push(new Q0({text:new T("[fork] ",new b({color:j.primary}))}))}else if(x)l.push(new Q0({text:new T("[handoff] ",new b({color:j.accent}))}));if(l.push(new S1({child:new Q0({text:new T(n,new b({color:k})),overflow:"ellipsis",maxLines:1})})),l.push(new R0({width:2})),O.diffStats&&(O.diffStats.added>0||O.diffStats.changed>0||O.diffStats.deleted>0)){let $0=E?{success:y,warning:y,destructive:y}:j;l.push(...Xh5(O.diffStats.added,O.diffStats.changed,O.diffStats.deleted,$0)),l.push(new R0({width:2}))}return l.push(h(O.description.timeAgo,G)),new l0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new K1({children:[...S,...l]})})}})}}class MB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new AB4}}class AB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}var IB4=30,Uh5=30;class qT{}class GT{}class T20{}class _20{}class rm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new jB4}}class jB4 extends g0{highlightedIndex=0;controller=new v7;focusNode;scrollController=new r6;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new i4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),z6.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 Z=J.findRenderObject();if(!Z)return;let Q=0,X=Z.size.height;CC(J,{top:Q,bottom:X},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Z}=this.widget.props;if(!J)this.filteredClusters=[...Z];else this.filteredClusters=Z.filter((Q)=>Q.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof qT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof GT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof T20){let Z=this.filteredClusters[this.highlightedIndex];if(Z)this.widget.props.onAccept(Z);return"handled"}if(J instanceof _20)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Z)=>{if(J>=0&&J<this.filteredClusters.length){if(Z===1)this.highlightedIndex=J,this.setState();else if(Z===2){let Q=this.filteredClusters[J];if(Q)this.widget.props.onAccept(Q)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Z=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(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Z};build(J){let{currentThreadID:Z}=this.widget.props,Q=f0.of(J),{colors:X,app:Y}=Q,D=s1.of(J).size.width>=Uh5+IB4,K=h1.all(new y1(X.foreground,1,"solid")),z=this.filteredClusters[this.highlightedIndex]??null,q=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("Select a cluster",new b({color:Y.command,bold:!0}))})}),G=new d$({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:X.foreground,border:null},maxLines:1}),F=new H2({shortcuts:new Map([[new t1("ArrowDown"),new qT],[new t1("ArrowUp"),new GT],[new t1("Tab"),new qT],[new t1("Tab",{shift:!0}),new GT],[new t1("n",{ctrl:!0}),new qT],[new t1("p",{ctrl:!0}),new GT],[new t1("Enter"),new T20],[new t1("Escape"),new _20]]),focusNode:this.focusNode,child:G}),W=new M9({actions:new Map([[qT,new n4(this.invoke)],[GT,new n4(this.invoke)],[T20,new n4(this.invoke)],[_20,new n4(this.invoke)]]),child:F}),H=new K1({children:[new l0({decoration:{color:X.background},child:new Q0({text:new T(">",new b({color:X.foreground}))})}),new S1({child:W})]});this.itemContexts=[];let B=this.filteredClusters.map((I,M)=>{let A=M===this.highlightedIndex,j=Z?I.threads.some((h)=>h.id===Z):!1,_=A?Y.selectionBackground:void 0,k=A?Y.selectionForeground:X.foreground,y=[new T(I.label,new b({color:k})),new T(` (${I.threads.length})`,new b({color:k,dim:!0}))];if(j)y.push(new T(" (current)",new b({color:A?Y.selectionForeground:X.success})));return new MB4(new i1({onClick:(h)=>this.handleItemClick(M,h.clickCount),child:new l0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T("",void 0,y)})})}),(h)=>{this.itemContexts[M]=h})}),w=new u0({children:B,crossAxisAlignment:"start"}),N=new S1({child:new i1({onScroll:this.handleScroll,child:new O6({controller:this.scrollController,autofocus:!1,child:w})})}),O=z?z.threads.map((I)=>({id:I.id,title:I.title,parentID:I.parentID,updatedAt:I.updatedAt})):[],E=z?new l0({padding:C0.all(1),child:new YL({threads:O,autofocus:!1,offsetY:2})}):null,L;if(D){let I=E?new S1({child:E}):new R0({width:IB4});L=new K1({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[N,I]})}else{let I=[new S1({child:new i1({onScroll:this.handleScroll,child:new O6({controller:this.scrollController,autofocus:!1,child:w})})})];if(E)I.push(new S1({child:E}));L=new u0({crossAxisAlignment:"stretch",children:I})}return new l0({decoration:{border:K,color:X.background},padding:C0.symmetric(1,0),child:new u0({children:[q,H,new R0({height:1}),new S1({child:L})]})})}}m0();class RB4 extends g0{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){P.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){P.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],X=this.labels.some((U)=>U.name===Z),Y=Q.includes(Z);return!X&&!Y}build(J){let Z=f0.of(J),{app:Q,colors:X}=Z,Y=this.currentQuery.trim().toLowerCase(),U=Y.length>0?this.getValidationError(Y):null,V=this.getAvailableLabels(),K=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...V];return new p9({title:"Add Label",items:K,getLabel:(z)=>{if("__isCreateMarker"in z)return this.currentQuery.trim().toLowerCase();return z.name},onAccept:(z)=>{if("__isCreateMarker"in z)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(z.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:U||"Type to create a new label",renderItem:(z,q,G,F)=>{let W=q?Q.selectionBackground:void 0,H=q?Q.selectionForeground:X.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let w=this.currentQuery.trim().toLowerCase();return new l0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T("",void 0,[new T("Create new label: ",new b({color:H})),new T(w,new b({color:H,bold:!0}))])})})}return new l0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T(z.name,new b({color:H}))})})},filterItem:(z,q)=>{if(this.currentQuery!==q)this.currentQuery=q,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in z&&z.__isCreateMarker)return this.shouldShowCreateMarker(q);let F=q.trim().toLowerCase();return F.length===0||z.name.includes(F)},sortItems:(z,q,G)=>{let F="__isCreateMarker"in z.item&&z.item.__isCreateMarker,W="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(F&&!W)return-1;if(!F&&W)return 1;return q.score-z.score}})}}class sm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new RB4}}class SH extends p0{props;constructor(J){super();this.props=J}createState(){return new PB4}}class PB4 extends g0{_spinner=new L3;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:X}=Z,Y=h1.all(new y1(Q.foreground,1,"solid")),U=this._spinner.toBraille(),V=new Q0({textAlign:"center",text:new T("",void 0,[new T(U,new b({color:X.processing})),new T(" ",void 0),new T(this.widget.props.message,new b({color:Q.foreground}))])}),K=[new S1({child:new u0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[V]})})];if(this.widget.props.onAbort)K.push(new R0({height:2,child:new l0({padding:C0.symmetric(2,0),child:new Q0({text:new T("",new b({dim:!0}),[new T("Press ",new b({color:Q.foreground})),new T("Esc",new b({color:Q.info})),new T(" to cancel",new b({color:Q.foreground}))])})})}));let z=new l0({decoration:new _4(Q.background,Y),child:new R0({width:60,height:7,child:new u0({mainAxisAlignment:"start",children:K})})});if(this.widget.props.onAbort)return new T4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(q)=>{if(q.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:z});return z}}class VL extends p0{props;constructor(J){super();this.props=J}createState(){return new CB4}}class CB4 extends g0{scrollController=new r6;scrollAreaKey=new _7("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 w2}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Z=this.scrollAreaKey.currentElement?.renderObject;if(Z&&"size"in Z){let Q=Z.size;if(typeof Q.height==="number"&&Q.height>0)return this.viewportHeight=Q.height,Q.height}return this.viewportHeight}build(J){let Z=f0.of(J),Q=this.widget.props.message,X=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let q=p90(Q);return{title:q.title,type:q.type,description:q.description}})(),Y=X.type==="error"?Z.app.toolError:Z.app.command,U=h1.all(new y1(Z.colors.border,1,"solid")),V=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T(X.title,new b({color:Y,bold:!0}))})}),D=this.isWidgetMessage(Q)?Q.widget:new Q0({text:new T(X.description,new b({color:Z.colors.foreground})),selectable:!0}),K=new S1({child:new p$({child:new l0({padding:C0.symmetric(1,0),child:new K1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new S1({child:new O6({controller:this.scrollController,autofocus:!0,child:D})}),new A8({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let q=this.scrollController.maxScrollExtent,G=this.scrollController.offset,F=this.getViewportHeight(),W=q+F;return{totalContentHeight:Math.max(W,0),viewportHeight:Math.max(F,1),scrollOffset:Math.max(G,0)}}})]})})})}),z=new l0({padding:C0.symmetric(1,0),child:new Q0({text:(()=>{if(this.widget.props.onRetry)return new T("",void 0,[new T("Press ",new b({color:Z.colors.foreground,dim:!0})),new T("R",new b({color:Z.app.keybind})),new T(" to retry, ",new b({color:Z.colors.foreground,dim:!0})),new T("Esc",new b({color:Z.app.keybind})),new T(" to cancel",new b({color:Z.colors.foreground,dim:!0}))]);let q=this.resolveFooterStyle(this.widget.props.message);if(q==="none")return new T("",new b({color:Z.colors.foreground,dim:!0}));if(q==="help"){let G=new b({color:Z.app.keybind}),F=new b({color:Z.colors.foreground,dim:!0});return new T("",F,[new T("Press ",F),new T("Escape",G),new T(" to close • Use ",F),new T("↑↓",G),new T(" or ",F),new T("j/k",G),new T(" to scroll",F)])}return new T("Press any key to close",new b({color:Z.colors.foreground,dim:!0,italic:!0}))})()})});return new T4({onKey:(q)=>{if(this.widget.props.onRetry&&q.key==="r")return this.widget.props.onRetry(),"handled";if(q.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new l0({decoration:{border:U,color:Z.colors.background},padding:C0.all(1),child:new u0({mainAxisAlignment:"center",children:[V,new R0({height:1}),K,z]})})})}}n9();class TB4 extends p0{props;constructor(J){super();this.props=J}createState(){return new _B4}}class _B4 extends g0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=u8.default(),{colors:Q,app:X}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:X.toolSuccess};case"error":return{icon:"✗",color:X.toolError}}}build(J){let Z=f0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new Q0({text:new T("No plugins found.",new b({dim:!0}))});let X=[],Y=this.plugins.length,U=this.plugins.filter((K)=>K.status==="active").length,V=this.plugins.reduce((K,z)=>K+z.registeredCommands.length,0),D=this.plugins.reduce((K,z)=>K+z.registeredTools.length,0);if(X.push(new T(`${U}/${Y} ${h4(Y,"plugin")} active`,new b({bold:!0}))),V>0||D>0)X.push(new T(` (${V} ${h4(V,"command")}, ${D} ${h4(D,"tool")})`,new b({dim:!0})));X.push(new T(`
6863
+ `,N)])}),A];if(!K&&!F&&z.url){let h=z.url.replace(/^https?:\/\//,"");_.push(new J5({uri:z.url,text:h,style:new b({color:Q.secondary,underline:!0})}))}if(M&&!F)_.push(M);let k=new R0({width:50,child:new u0({crossAxisAlignment:"start",mainAxisSize:"min",children:_})}),y=W?new R0({width:L20,height:I20}):new Ox0({width:L20,height:I20,agentMode:this.widget.agentMode,glow:this._glow,backgroundColor:Q.background,t:q,fps:0,shockwaves:this._shockwaves,onShockwave:this.handleShockwave,onClick:this.handleOrbClick,...V==="disabled"&&{seed:42}});return a1.child(new K1({mainAxisAlignment:"center",crossAxisAlignment:"center",mainAxisSize:"min",children:[y,new R0({width:2}),k]}))}}class gm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new DB4}}class DB4 extends g0{build(J){let Q=f0.of(J).colors,{todos:X,title:Y="TODOs"}=this.widget.props;if(!Array.isArray(X)||X.length===0)return new R0({width:0,height:0});let U=X.map((V)=>this.buildTodoItem(V,Q));return new l0({child:new o0({padding:C0.symmetric(1,0),child:new u0({crossAxisAlignment:"stretch",mainAxisSize:"min",children:[new Q0({text:new T(Y,new b({bold:!0,color:Q.foreground}))}),...U]})})})}buildTodoItem(J,Z){let Q=this.getStatusIcon(J.status),X=J.status==="completed",Y=new b({bold:J.status==="in-progress",color:Z.foreground,dim:X}),U=new b({bold:J.status==="in-progress",strikethrough:J.status==="completed",color:Z.foreground,dim:X});return new K1({crossAxisAlignment:"start",children:[new Q0({text:new T(Q,Y)}),new R0({width:1}),new S1({child:new Q0({text:new T(J.content,U)})})]})}getStatusIcon(J){return J==="completed"?"✓":"•"}}class pm0 extends p0{ad;onDismiss;onButtonClick;onImpression;onAdInfoClick;constructor({key:J,ad:Z,onDismiss:Q,onButtonClick:X,onImpression:Y,onAdInfoClick:U}){super({key:J});this.ad=Z,this.onDismiss=Q,this.onButtonClick=X,this.onImpression=Y,this.onAdInfoClick=U}createState(){return new KB4}}class KB4 extends g0{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 Z=f0.of(J),Q=Z.colors.primary,X=Z.colors.foreground,Y=Z.colors.background,U=this.widget.ad;return new l0({decoration:new _4(Y,new h1(new y1(Q,1,"rounded"),new y1(Q,1,"rounded"),void 0,new y1(Q,1,"rounded"))),child:new o0({padding:C0.horizontal(1),child:new u0({children:[new K1({crossAxisAlignment:"start",children:[new S1({child:new Q0({text:new T(U.content,new b({color:X}))})}),new R0({width:4}),new i1({onClick:()=>this.widget.onAdInfoClick?.(),cursor:"pointer",child:new Q0({text:new T("Ad",new b({color:X,dim:!0}))})})]}),new K1({crossAxisAlignment:"start",children:[new om({text:U.buttonLabel,onPressed:()=>this.widget.onButtonClick?.(),padding:C0.horizontal(1),color:Q,reverse:!0}),new R0({width:2}),new Q0({text:new T(U.destinationUrlHostname,new b({color:X,dim:!0}))})]})]})})})}}class dm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new zB4(this.props.autofocus??!0)}}class zB4 extends g0{autofocus;constructor(J){super();this.autofocus=J}build(J){let Q=P1.of(J).colorScheme,X=(z)=>{if(z.key==="Enter"&&this.widget.props.showCopyOption)return this.widget.props.onSelect("copy"),"handled";if(z.ctrlKey&&z.key==="c"||z.key==="Escape")return this.widget.props.onSelect(null),"handled";return"ignored"},Y=s1.sizeOf(J),U=Math.min(60,Y.width-4),V=Y.height-4,D=[];if(this.widget.props.title)D.push(new Q0({text:new T(this.widget.props.title,new b({bold:!0,color:Q.primary}))}),new R0({height:1}));if(this.widget.props.message)D.push(new Q0({text:new T(this.widget.props.message,void 0,void 0,{uri:this.widget.props.message,id:"ad-link"})}));if(this.widget.props.message)D.push(new R0({height:1}));let K=[];if(this.widget.props.showCopyOption)K.push(new Q0({text:new T("Enter to copy",new b({dim:!0}))}));return K.push(new Q0({text:new T("Escape to close",new b({dim:!0}))})),D.push(new K1({children:K.flatMap((z,q)=>q<K.length-1?[z,new R0({width:1}),new Q0({text:new T("•",new b({dim:!0}))}),new R0({width:1})]:[z]),mainAxisSize:"min"})),new a1({child:new l0({constraints:new I1(U,U,0,V),decoration:new _4(Q.background,new h1(new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"),new y1(Q.primary,1,"rounded"))),padding:new C0(2,2,2,2),child:new T4({autofocus:this.autofocus,onKey:X,child:new u0({children:D,mainAxisSize:"min"})})})})}}class cm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new qB4(this.props.autofocus??!0)}}class qB4 extends g0{autofocus;constructor(J){super();this.autofocus=J}build(J){let Z=P1.of(J).colorScheme,Q=(D)=>{if(D.key==="Enter"||D.key==="Escape"||D.ctrlKey&&D.key==="c")return this.widget.props.onClose(),"handled";return"ignored"},X=s1.sizeOf(J),Y=Math.min(60,X.width-4),U=X.height-4,V=[];if(V.push(new Q0({text:new T("Ads make Amp Free possible",new b({bold:!0}))})),this.widget.props.provider)V.push(new R0({height:1}),new Q0({text:new T(`Ad source: ${this.widget.props.provider}`,new b({dim:!0}))}));return V.push(new R0({height:1}),new Q0({text:new T("Escape to close",new b({dim:!0}))})),new a1({child:new l0({constraints:new I1(Y,Y,0,U),decoration:new _4(Z.background,new h1(new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"),new y1(Z.primary,1,"rounded"))),padding:new C0(2,2,2,2),child:new T4({autofocus:this.autofocus,onKey:Q,child:new u0({children:V,mainAxisSize:"min"})})})})}}m0();n9();import{execSync as jh5}from"node:child_process";aM();FJ();O3();t7();Rw();LY();I$();CJ();NY();iO();c4();vu();Tv();H1();var Kw4=E4(Kz(),1);import{writeFile as Xw4}from"fs/promises";import Yw4 from"path";m0();I$();class lm0{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1772294494-g9b3cb4"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await xs(Z,this.configService)}catch(Z){P.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class _H extends p0{props;constructor(J){super();this.props=J}createState(){return new GB4}}class GB4 extends g0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}class FB4 extends g0{controller=new v7;focusNode=new i4({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:X}=Z,Y=this.widget.props.isRequiredArg??!0,U=this.controller.text.trim().length>0,V=!Y||U,D=h1.all(new y1(Q.foreground,1,"solid")),K=new d$({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(W)=>{let H=W.trim();if(Y&&H.length===0)return;this.widget.props.onSubmit(H)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),z=new K1({children:[new l0({decoration:{color:Q.background},child:new Q0({text:new T(">",new b({color:Q.foreground}))})}),new S1({child:K})]}),q=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("",void 0,[new T("Command: ",new b({color:Q.foreground})),new T(this.widget.props.commandName,new b({color:X.command,bold:!0}))])})}),G=[];if(V)G.push(new T("Enter",new b({color:X.keybind}))),G.push(new T(" to submit, ",new b({color:Q.foreground,dim:!0})));G.push(new T("Esc",new b({color:X.keybind}))),G.push(new T(" to cancel",new b({color:Q.foreground,dim:!0})));let F=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("",void 0,G)})});return new l0({decoration:{border:D,color:Q.background},padding:C0.all(1),child:new u0({children:[q,new R0({height:1}),z,new Z3,F]})})}}class Gp extends p0{props;constructor(J){super();this.props=J}createState(){return new FB4}}import{isDeepStrictEqual as im0}from"node:util";var sb5=/[\\/_ +.#"@[({&]/,tb5=/[\\/_ +.#"@[({&]/g,eb5=/[\s-]/,WB4=/[\s-]/g;function j20(J,Z,Q,X,Y,U,V){if(U===Z.length){if(Y===J.length)return 1;return 0.99}let D=`${Y},${U}`;if(V[D]!==void 0)return V[D];let K=X.charAt(U),z=Q.indexOf(K,Y),q=0,G,F,W,H;while(z>=0){if(G=j20(J,Z,Q,X,z+1,U+1,V),G>q){if(z===Y)G*=1;else if(eb5.test(J.charAt(z-1))){if(G*=0.9,H=J.slice(Y,z-1).match(WB4),H&&Y>0)G*=0.999**H.length}else if(sb5.test(J.charAt(z-1))){if(G*=0.8,W=J.slice(Y,z-1).match(tb5),W&&Y>0)G*=0.999**W.length}else if(G*=0.3,Y>0)G*=0.999**(z-Y);if(J.charAt(z)!==Z.charAt(U))G*=0.9999}if(G<0.1&&(Q.charAt(z-1)===X.charAt(U+1)||X.charAt(U+1)===X.charAt(U)&&Q.charAt(z-1)!==X.charAt(U))){if(F=j20(J,Z,Q,X,z+1,U+2,V),F*0.1>G)G=F*0.1}if(G>q)q=G;z=Q.indexOf(K,z+1)}return V[D]=q,q}function A20(J){return J.toLowerCase().replace(WB4," ")}function HB4(J,Z){let Q=j20(J,Z,A20(J),A20(Z),0,0,{}),X=Z.trim().split(/\s+/);if(X.length>1){let Y=0,U=0;for(let D of X){let K=j20(J,D,A20(J),A20(D),0,0,{});if(K===0)return Q;Y+=K,U+=D.length}let V=Y/X.length*0.95;return Math.max(Q,V)}return Q}class KT{}class zT{}class R20{}class P20{}class BB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new wB4}}class wB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}function $h5(J,Z){if(J==="")return{matches:!0,score:1};let Q=HB4(Z,J);return{matches:Q>0.15,score:Q}}class p9 extends p0{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new NB4}}class NB4 extends g0{textController;focusNode;scrollController=new r6;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){if(this.scrollController.disableFollowMode(),this.textController=new v7(this.widget.props.controller?.query??""),this.focusNode=new i4({debugLabel:this.widget.debugLabel}),this.textController.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let J=this.widget.props.controller;if(J)J.query=this.textController.text;this.syncSelection()}),this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let J=this.cachedFiltered.findIndex((Z)=>im0(Z,this.widget.props.controller?.selectedItem));if(J>=0)this.selectedIndex=J}this.clampSelectedIndex(),this.syncSelection(),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!im0(J.props.items,this.widget.props.items)){if(this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let Z=this.cachedFiltered.findIndex((Q)=>im0(Q,this.widget.props.controller?.selectedItem));if(Z>=0)this.selectedIndex=Z}this.clampSelectedIndex(),this.ensureSelectedItemVisible(),this.syncSelection()}}dispose(){this.widget.props.onSelectionChange?.(null),this.textController.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof KT){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof zT){if(this.getFilteredItems().length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof R20){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length){let Q=Z[this.selectedIndex];if(Q){if(!(this.widget.props.isItemDisabled?.(Q)??!1))this.widget.props.onAccept(Q,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof P20)return this.widget.props.onDismiss?.(),"handled";return"ignored"};syncSelection(){let Z=this.cachedFiltered[this.selectedIndex]??null;if(this.widget.props.controller)this.widget.props.controller.selectedItem=Z;this.widget.props.onSelectionChange?.(Z)}clampSelectedIndex(){let J=this.cachedFiltered.length-1;if(J<0){this.selectedIndex=0;return}this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,J))}recomputeFilteredItems(){let J=this.textController.text,Z=this.widget.props.items,Q=this.widget.props.normalizeQuery?.(J)??J,X=Z.filter((Y)=>!this.widget.props.filterItem||this.widget.props.filterItem(Y,J)).map((Y)=>({item:Y,...$h5(Q,this.widget.props.getLabel(Y))})).filter((Y)=>Y.matches).sort(this.widget.props.sortItems?(Y,U)=>this.widget.props.sortItems(Y,U,J):(Y,U)=>U.score-Y.score).map((Y)=>Y.item);this.cachedQuery=J,this.cachedItemsRef=Z,this.cachedFiltered=this.widget.props.maxRenderItems?X.slice(0,this.widget.props.maxRenderItems):X}getFilteredItems(){let J=this.textController.text,Z=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Z)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,X=Z.size.height;CC(J,{top:Q,bottom:X},{padding:1})}handleScroll=(J)=>{let Z=this.getFilteredItems();if(Z.length===0)return!1;let Q=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Z.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(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection(),this.selectedIndex!==Q};handleItemClick=(J,Z)=>{let Q=this.getFilteredItems();if(J>=0&&J<Q.length){let X=Q[J],Y=X?this.widget.props.isItemDisabled?.(X)??!1:!1;if(Z===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.syncSelection();else if(Z===2&&!Y){if(X)this.hasUserInteracted=!0,this.widget.props.onAccept(X,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Z=f0.of(J),{colors:Q}=Z,X=this.getFilteredItems(),Y=h1.all(new y1(Q.foreground,1,"solid")),U=this.widget.props.hidePromptWhenLoading&&this.widget.props.isLoading,V=this.widget.props.enabled??!0,D=new d$({controller:this.textController,focusNode:this.focusNode,autofocus:!0,enabled:V,style:{backgroundColor:Q.background,textColor:Q.foreground,cursorColor:Q.cursor,placeholderColor:Q.mutedForeground,border:null},maxLines:1}),K=new H2({shortcuts:new Map([[new t1("ArrowDown"),new KT],[new t1("ArrowUp"),new zT],[new t1("Tab"),new KT],[new t1("Tab",{shift:!0}),new zT],[new t1("n",{ctrl:!0}),new KT],[new t1("p",{ctrl:!0}),new zT],[new t1("Enter"),new R20],[new t1("Escape"),new P20]]),focusNode:this.focusNode,child:D}),z=new M9({actions:new Map([[KT,new n4(this.invoke)],[zT,new n4(this.invoke)],[R20,new n4(this.invoke)],[P20,new n4(this.invoke)]]),child:K}),q=new K1({children:[new l0({decoration:{color:Q.background},child:new Q0({text:new T(">",new b({color:Q.foreground}))})}),new S1({child:z})]});this.itemContexts=[];let G;if(this.widget.props.isLoading){let w=this.widget.props.loadingText??"Loading...";G=new R0({height:10,child:new a1({child:new Q0({text:new T(w,new b({color:Q.foreground}))})})})}else if(X.length===0&&this.widget.props.emptyStateText)G=new S1({child:new a1({child:new Q0({text:new T(this.widget.props.emptyStateText,new b({color:Q.foreground,dim:!0}))})})});else{let w=X.map((N,O)=>{let E=O===this.selectedIndex,L=this.widget.props.isItemDisabled?.(N)??!1,I;if(this.widget.props.renderItem)I=this.widget.props.renderItem(N,E,L,J);else{let M=E?Z.app.selectionBackground:void 0,A=E?Z.app.selectionForeground:Q.foreground;I=new l0({decoration:M?{color:M}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T(this.widget.props.getLabel(N),new b({color:A,dim:L}))})})}return new BB4(new i1({onClick:(M)=>this.handleItemClick(O,M.clickCount),child:I}),(M)=>{this.itemContexts[O]=M})});G=new u0({children:w,crossAxisAlignment:"start"})}let F=new i1({onScroll:this.handleScroll,opaque:!1,child:new O6({controller:this.scrollController,autofocus:!1,child:G})}),W=[];if(this.widget.props.title){let w=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T(this.widget.props.title,new b({color:Z.app.command,bold:!0}))})});W.push(w)}if(!U)W.push(q,new R0({height:1}));if(this.textController.text!==""){let w=X.length>0?X[this.selectedIndex]:void 0,N=w&&this.widget.props.buildDisabledReasonWidget?.(w,J);W.push(new S1({child:new u0({mainAxisAlignment:"spaceBetween",children:[new S1({child:F}),new l0({padding:C0.only({top:1}),child:new a1({child:N??new R0({height:1})})})]})}))}else W.push(new S1({child:F}));if(this.widget.props.footer)W.push(this.widget.props.footer);return new l0({decoration:{border:Y,color:Q.background},padding:C0.symmetric(1,0),child:new u0({children:W})})}}function OB4(J){let Q=new Date().getTime()-J.getTime(),X=Math.floor(Q/60000),Y=Math.floor(Q/3600000),U=Math.floor(Q/86400000);if(X<1)return"just now";if(X<60)return`${X}m ago`;if(Y<24)return`${Y}h ago`;if(U<7)return`${U}d ago`;return J.toLocaleDateString()}class nm0 extends d1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((Y,U)=>U.pubDate.getTime()-Y.pubDate.getTime()),Q=Math.max(0,...Z.map((Y)=>OB4(Y.pubDate).length));return new p9({items:Z,getLabel:(Y)=>Y.title,onAccept:(Y)=>this.props.onSelect?.(Y),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(Y,U,V,D)=>{let K=f0.of(D),{colors:z}=K,q=K.app,G=U?q.selectionBackground:void 0,F=U?q.selectionForeground:z.foreground,W=z.mutedForeground,H=(B,w)=>new R0({width:w,child:K1.end([new Q0({text:new T(B,new b({color:W}))})])});return new l0({decoration:G?{color:G}:void 0,padding:C0.symmetric(2,0),child:new K1({children:[new S1({child:new Q0({text:new T(Y.title,new b({color:F})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),H(OB4(Y.pubDate),Q)]})})}})}}c4();class am0 extends p0{createState(){return new EB4}}class EB4 extends g0{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 Q=f0.of(J).colors;return new Q0({text:new T("●",new b({color:this.isGreen?Q.success:Q.mutedForeground,bold:!0})),maxLines:1})}}var Jh5=/\/threads\/(T-[^/?#\s<>]+)/i;function Zh5(J){let Z=J.trim(),X=Z.match(Jh5)?.[1];if(X&&q8(X))return X;let Y=Z.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(q8(Y))return Y;return null}function Qh5(J){let Z=new Map,Q=new Map,X=new Map,Y=[];for(let V of J)Z.set(V.id,V);for(let V of J){let D=V.relationships.find((K)=>K.role==="child"&&Z.has(K.threadID)&&(K.type==="fork"||K.type==="handoff"));if(D){X.set(V.id,D.type);let K=D.threadID,z=Q.get(K)||[];z.push(V),Q.set(K,z)}else Y.push(V)}return l90.flatten(Y,(V)=>Q.get(V.id)).map((V)=>({...V.item,depth:V.depth,isLast:V.isLast,ancestorsAreLast:V.ancestorsAreLast,relationshipType:X.get(V.item.id)}))}function om0(J,Z,Q){return new Q0({text:new T(`${J}${Z}`,new b({color:Q})),maxLines:1})}function Xh5(J,Z,Q,X){return[om0("+",J,X.success),Z3.horizontal(1),om0("~",Z,X.warning),Z3.horizontal(1),om0("-",Q,X.destructive)]}function Yh5(J){return typeof J==="object"&&J!==null&&"then"in J&&typeof J.then==="function"}class C20 extends p0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}createState(){return new LB4}}class LB4 extends g0{spinner=new L3;spinnerInterval=null;isSwitchingThread=!1;get isBusy(){return this.isSwitchingThread||this.widget.props.isLoading===!0}updateSpinnerAnimation(){if(this.isBusy){if(!this.spinnerInterval)this.spinnerInterval=setInterval(()=>{this.spinner.step(),this.setState(()=>{})},100);return}if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null}setSwitchingThread(J){if(this.isSwitchingThread===J)return;this.setState(()=>{this.isSwitchingThread=J}),this.updateSpinnerAnimation()}initState(){super.initState(),this.updateSpinnerAnimation()}didUpdateWidget(J){this.updateSpinnerAnimation()}dispose(){if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null;super.dispose()}build(J){let{props:Z}=this.widget,Q=this.isBusy,X=this.isSwitchingThread?"Switching thread...":"Loading threads...",Y=`${this.spinner.toBraille()} ${X}`,U=Z.filterByWorkspace&&Z.currentWorkspaceURI?Z.threads.filter((O)=>O.workspaceURI===Z.currentWorkspaceURI):Z.threads;if(Z.excludeCurrentThread&&Z.currentThreadID)U=U.filter((O)=>O.id!==Z.currentThreadID);let V=Z.recentThreadIDs||[],D=new Set(V),K=Z.currentThreadID,z=[...U].sort((O,E)=>{if(K){if(O.id===K)return-1;if(E.id===K)return 1}let L=V.indexOf(O.id),I=V.indexOf(E.id);if(L!==-1&&I!==-1)return L-I;if(L!==-1)return-1;if(I!==-1)return 1;return 0}),q=Qh5(z),G=Math.max(0,...q.map((O)=>O.description.timeAgo.length)),F=f0.of(J),W=new o0({padding:C0.symmetric(0,1),child:new a1({child:new Q0({text:new T("",new b({color:F.colors.foreground,dim:!0}),[new T("Ctrl+T",new b({color:F.colors.primary,dim:!0})),new T(Z.filterByWorkspace?" for all workspaces":" to filter by workspace",new b({color:F.colors.foreground,dim:!0}))])})})}),H="",B=null,w=(O)=>{if(O!==H)H=O,B=Zh5(O);return B};return new p9({items:q,getLabel:(O)=>`${O.title} ${O.id}`,filterItem:(O,E)=>{let L=w(E);if(L)return O.id.toLowerCase()===L.toLowerCase();return!0},normalizeQuery:(O)=>w(O)?"":O,onAccept:async(O,E)=>{if(!Z.onSelect||this.isSwitchingThread)return;let L=Z.onSelect(O.id,E);if(!Yh5(L))return;this.setSwitchingThread(!0);try{await L}finally{if(this.mounted)this.setSwitchingThread(!1)}},onDismiss:Z.onDismiss,onSelectionChange:(O)=>{if(Z.previewController){if(O)Z.previewController.select(O.id)}},title:Z.title,enabled:!Q,isLoading:Q,hidePromptWhenLoading:!0,loadingText:Y,emptyStateText:"No threads match your filter",maxRenderItems:200,footer:Q?void 0:W,renderItem:(O,E,L,I)=>{let M=f0.of(I),{app:A,colors:j}=M,_=E?A.selectionBackground:void 0,k=E?A.selectionForeground:j.foreground,y=j.mutedForeground,h=($0,B0)=>new R0({width:B0,child:K1.end([new Q0({text:new T($0,new b({color:y}))})])}),f=Z.threadViewStates[O.id],S=[],x=O.relationshipType==="handoff",m=new Ng({connectorColor:j.mutedForeground});if(O.depth>0){let $0=[],B0=O.ancestorsAreLast.slice(1);for(let K0 of B0)$0.push(new T(m.getAncestorPrefix(K0),new b({color:m.connectorColor,dim:m.connectorDim})));let s=O.isLast?m.elbow:m.tee,q0=m.getConnectorText(s);$0.push(new T(q0,new b({color:m.connectorColor,dim:m.connectorDim}))),S.push(new Q0({text:new T("",void 0,$0)}))}let l=[],g=K===O.id?new T("(current) ",new b({color:j.success})):D.has(O.id)?new T("(visited) ",new b({color:j.foreground,dim:!0})):null;if(g)l.push(new Q0({text:g}));if(WO(f))l.push(new am0),l.push(new R0({width:1}));let n=O.title;if(O.relationshipType==="fork"){let $0=n.match(/^Forked\((\d+)\): /);if($0)n=n.slice($0[0].length);else while(n.startsWith("Forked: "))n=n.slice(8);l.push(new Q0({text:new T("[fork] ",new b({color:j.primary}))}))}else if(x)l.push(new Q0({text:new T("[handoff] ",new b({color:j.accent}))}));if(l.push(new S1({child:new Q0({text:new T(n,new b({color:k})),overflow:"ellipsis",maxLines:1})})),l.push(new R0({width:2})),O.diffStats&&(O.diffStats.added>0||O.diffStats.changed>0||O.diffStats.deleted>0)){let $0=E?{success:y,warning:y,destructive:y}:j;l.push(...Xh5(O.diffStats.added,O.diffStats.changed,O.diffStats.deleted,$0)),l.push(new R0({width:2}))}return l.push(h(O.description.timeAgo,G)),new l0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new K1({children:[...S,...l]})})}})}}class MB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new AB4}}class AB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}var IB4=30,Uh5=30;class qT{}class GT{}class T20{}class _20{}class rm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new jB4}}class jB4 extends g0{highlightedIndex=0;controller=new v7;focusNode;scrollController=new r6;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new i4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),z6.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 Z=J.findRenderObject();if(!Z)return;let Q=0,X=Z.size.height;CC(J,{top:Q,bottom:X},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Z}=this.widget.props;if(!J)this.filteredClusters=[...Z];else this.filteredClusters=Z.filter((Q)=>Q.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof qT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof GT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof T20){let Z=this.filteredClusters[this.highlightedIndex];if(Z)this.widget.props.onAccept(Z);return"handled"}if(J instanceof _20)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Z)=>{if(J>=0&&J<this.filteredClusters.length){if(Z===1)this.highlightedIndex=J,this.setState();else if(Z===2){let Q=this.filteredClusters[J];if(Q)this.widget.props.onAccept(Q)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Z=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(),z6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Z};build(J){let{currentThreadID:Z}=this.widget.props,Q=f0.of(J),{colors:X,app:Y}=Q,D=s1.of(J).size.width>=Uh5+IB4,K=h1.all(new y1(X.foreground,1,"solid")),z=this.filteredClusters[this.highlightedIndex]??null,q=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T("Select a cluster",new b({color:Y.command,bold:!0}))})}),G=new d$({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:X.foreground,border:null},maxLines:1}),F=new H2({shortcuts:new Map([[new t1("ArrowDown"),new qT],[new t1("ArrowUp"),new GT],[new t1("Tab"),new qT],[new t1("Tab",{shift:!0}),new GT],[new t1("n",{ctrl:!0}),new qT],[new t1("p",{ctrl:!0}),new GT],[new t1("Enter"),new T20],[new t1("Escape"),new _20]]),focusNode:this.focusNode,child:G}),W=new M9({actions:new Map([[qT,new n4(this.invoke)],[GT,new n4(this.invoke)],[T20,new n4(this.invoke)],[_20,new n4(this.invoke)]]),child:F}),H=new K1({children:[new l0({decoration:{color:X.background},child:new Q0({text:new T(">",new b({color:X.foreground}))})}),new S1({child:W})]});this.itemContexts=[];let B=this.filteredClusters.map((I,M)=>{let A=M===this.highlightedIndex,j=Z?I.threads.some((h)=>h.id===Z):!1,_=A?Y.selectionBackground:void 0,k=A?Y.selectionForeground:X.foreground,y=[new T(I.label,new b({color:k})),new T(` (${I.threads.length})`,new b({color:k,dim:!0}))];if(j)y.push(new T(" (current)",new b({color:A?Y.selectionForeground:X.success})));return new MB4(new i1({onClick:(h)=>this.handleItemClick(M,h.clickCount),child:new l0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T("",void 0,y)})})}),(h)=>{this.itemContexts[M]=h})}),w=new u0({children:B,crossAxisAlignment:"start"}),N=new S1({child:new i1({onScroll:this.handleScroll,child:new O6({controller:this.scrollController,autofocus:!1,child:w})})}),O=z?z.threads.map((I)=>({id:I.id,title:I.title,parentID:I.parentID,updatedAt:I.updatedAt})):[],E=z?new l0({padding:C0.all(1),child:new YL({threads:O,autofocus:!1,offsetY:2})}):null,L;if(D){let I=E?new S1({child:E}):new R0({width:IB4});L=new K1({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[N,I]})}else{let I=[new S1({child:new i1({onScroll:this.handleScroll,child:new O6({controller:this.scrollController,autofocus:!1,child:w})})})];if(E)I.push(new S1({child:E}));L=new u0({crossAxisAlignment:"stretch",children:I})}return new l0({decoration:{border:K,color:X.background},padding:C0.symmetric(1,0),child:new u0({children:[q,H,new R0({height:1}),new S1({child:L})]})})}}m0();class RB4 extends g0{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){P.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){P.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],X=this.labels.some((U)=>U.name===Z),Y=Q.includes(Z);return!X&&!Y}build(J){let Z=f0.of(J),{app:Q,colors:X}=Z,Y=this.currentQuery.trim().toLowerCase(),U=Y.length>0?this.getValidationError(Y):null,V=this.getAvailableLabels(),K=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...V];return new p9({title:"Add Label",items:K,getLabel:(z)=>{if("__isCreateMarker"in z)return this.currentQuery.trim().toLowerCase();return z.name},onAccept:(z)=>{if("__isCreateMarker"in z)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(z.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:U||"Type to create a new label",renderItem:(z,q,G,F)=>{let W=q?Q.selectionBackground:void 0,H=q?Q.selectionForeground:X.foreground;if("__isCreateMarker"in z&&z.__isCreateMarker){let w=this.currentQuery.trim().toLowerCase();return new l0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T("",void 0,[new T("Create new label: ",new b({color:H})),new T(w,new b({color:H,bold:!0}))])})})}return new l0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new Q0({text:new T(z.name,new b({color:H}))})})},filterItem:(z,q)=>{if(this.currentQuery!==q)this.currentQuery=q,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in z&&z.__isCreateMarker)return this.shouldShowCreateMarker(q);let F=q.trim().toLowerCase();return F.length===0||z.name.includes(F)},sortItems:(z,q,G)=>{let F="__isCreateMarker"in z.item&&z.item.__isCreateMarker,W="__isCreateMarker"in q.item&&q.item.__isCreateMarker;if(F&&!W)return-1;if(!F&&W)return 1;return q.score-z.score}})}}class sm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new RB4}}class SH extends p0{props;constructor(J){super();this.props=J}createState(){return new PB4}}class PB4 extends g0{_spinner=new L3;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:X}=Z,Y=h1.all(new y1(Q.foreground,1,"solid")),U=this._spinner.toBraille(),V=new Q0({textAlign:"center",text:new T("",void 0,[new T(U,new b({color:X.processing})),new T(" ",void 0),new T(this.widget.props.message,new b({color:Q.foreground}))])}),K=[new S1({child:new u0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[V]})})];if(this.widget.props.onAbort)K.push(new R0({height:2,child:new l0({padding:C0.symmetric(2,0),child:new Q0({text:new T("",new b({dim:!0}),[new T("Press ",new b({color:Q.foreground})),new T("Esc",new b({color:Q.info})),new T(" to cancel",new b({color:Q.foreground}))])})})}));let z=new l0({decoration:new _4(Q.background,Y),child:new R0({width:60,height:7,child:new u0({mainAxisAlignment:"start",children:K})})});if(this.widget.props.onAbort)return new T4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(q)=>{if(q.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:z});return z}}class VL extends p0{props;constructor(J){super();this.props=J}createState(){return new CB4}}class CB4 extends g0{scrollController=new r6;scrollAreaKey=new _7("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 w2}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Z=this.scrollAreaKey.currentElement?.renderObject;if(Z&&"size"in Z){let Q=Z.size;if(typeof Q.height==="number"&&Q.height>0)return this.viewportHeight=Q.height,Q.height}return this.viewportHeight}build(J){let Z=f0.of(J),Q=this.widget.props.message,X=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let q=p90(Q);return{title:q.title,type:q.type,description:q.description}})(),Y=X.type==="error"?Z.app.toolError:Z.app.command,U=h1.all(new y1(Z.colors.border,1,"solid")),V=new l0({padding:C0.symmetric(1,0),child:new Q0({text:new T(X.title,new b({color:Y,bold:!0}))})}),D=this.isWidgetMessage(Q)?Q.widget:new Q0({text:new T(X.description,new b({color:Z.colors.foreground})),selectable:!0}),K=new S1({child:new p$({child:new l0({padding:C0.symmetric(1,0),child:new K1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new S1({child:new O6({controller:this.scrollController,autofocus:!0,child:D})}),new A8({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let q=this.scrollController.maxScrollExtent,G=this.scrollController.offset,F=this.getViewportHeight(),W=q+F;return{totalContentHeight:Math.max(W,0),viewportHeight:Math.max(F,1),scrollOffset:Math.max(G,0)}}})]})})})}),z=new l0({padding:C0.symmetric(1,0),child:new Q0({text:(()=>{if(this.widget.props.onRetry)return new T("",void 0,[new T("Press ",new b({color:Z.colors.foreground,dim:!0})),new T("R",new b({color:Z.app.keybind})),new T(" to retry, ",new b({color:Z.colors.foreground,dim:!0})),new T("Esc",new b({color:Z.app.keybind})),new T(" to cancel",new b({color:Z.colors.foreground,dim:!0}))]);let q=this.resolveFooterStyle(this.widget.props.message);if(q==="none")return new T("",new b({color:Z.colors.foreground,dim:!0}));if(q==="help"){let G=new b({color:Z.app.keybind}),F=new b({color:Z.colors.foreground,dim:!0});return new T("",F,[new T("Press ",F),new T("Escape",G),new T(" to close • Use ",F),new T("↑↓",G),new T(" or ",F),new T("j/k",G),new T(" to scroll",F)])}return new T("Press any key to close",new b({color:Z.colors.foreground,dim:!0,italic:!0}))})()})});return new T4({onKey:(q)=>{if(this.widget.props.onRetry&&q.key==="r")return this.widget.props.onRetry(),"handled";if(q.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new l0({decoration:{border:U,color:Z.colors.background},padding:C0.all(1),child:new u0({mainAxisAlignment:"center",children:[V,new R0({height:1}),K,z]})})})}}n9();class TB4 extends p0{props;constructor(J){super();this.props=J}createState(){return new _B4}}class _B4 extends g0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=u8.default(),{colors:Q,app:X}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:X.toolSuccess};case"error":return{icon:"✗",color:X.toolError}}}build(J){let Z=f0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new Q0({text:new T("No plugins found.",new b({dim:!0}))});let X=[],Y=this.plugins.length,U=this.plugins.filter((K)=>K.status==="active").length,V=this.plugins.reduce((K,z)=>K+z.registeredCommands.length,0),D=this.plugins.reduce((K,z)=>K+z.registeredTools.length,0);if(X.push(new T(`${U}/${Y} ${h4(Y,"plugin")} active`,new b({bold:!0}))),V>0||D>0)X.push(new T(` (${V} ${h4(V,"command")}, ${D} ${h4(D,"tool")})`,new b({dim:!0})));X.push(new T(`
6864
6864
 
6865
6865
  `));for(let K of this.plugins){let{icon:z,color:q}=this.statusIcon(K.status),G=this.getRelativePath(K.uri.toString());if(X.push(new T(`${z} `,new b({color:q}))),X.push(new T(G,new b({bold:!0}))),X.push(new T(` ${K.status}`,new b({dim:!0}))),X.push(new T(`
6866
6866
  `)),K.status==="active"&&K.registeredEvents.length>0)X.push(new T(" Events: ",new b({dim:!0}))),X.push(new T(K.registeredEvents.join(", "),new b({color:Q.link}))),X.push(new T(`
@@ -7259,7 +7259,7 @@ ${Y}`,Z);this.line=Q,this.column=X,this.codeblock=Y}}/*!
7259
7259
  `)}function sN4(J,Z){J.command("usage").description("Show your current Amp usage and credit balance").action(async(Q,X)=>{let Y=X.optsWithGlobals(),U=await Z(Y),V=await U.settings.get("proxy"),D=WM1({settings:{url:U.ampURL,proxy:V},secrets:{getToken:(z,q)=>U.secrets.get(z,q)}}),K=await T6.userDisplayBalanceInfo({},{config:D});if(!K.ok){if(K.error.code==="auth-required")process.stderr.write(Z1.red("Error: ")+"You must be logged in to view usage. Run `amp login` first.\n"),process.exit(1);process.stderr.write(Z1.red("Error: ")+K.error.message+`
7260
7260
  `),process.exit(1)}process.stdout.write(await fg5(K.result.displayText)+`
7261
7261
  `),process.exit(0)})}var Qi5=pp.join(wZ,"logs","headless.log"),ud0=pp.join(eP,"device-id.json");function Xi5(){return pK.some((J)=>J.listConfigs().length>0)}try{if(process.platform==="win32")await Promise.resolve().then(() => E4(yT(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){z7.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
7262
- `)}function Yi5(J){process.emitWarning=(Z,Q,X,Y)=>{let U=typeof Z==="string"?Z:Z.message||String(Z),V=Q||"Warning",D=!1;J.warn(U,{name:V,code:X})}}function g7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")w7("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")w7("experimental.agentMode",Z.mode)}function MI4(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function Ui5(J){try{return await II4(J,"utf-8")}catch{return J}}async function AI4(J,Z,Q){let X=MI4(J,Z);if(!X)return;let Y=J3(Q)?Q.features:[],U=J3(Q)?Q.user.email:void 0;if(!Y.some((D)=>D.name===IY.HARNESS_SYSTEM_PROMPT&&D.enabled)&&!jI4(U))throw new w4("You are not allowed to do this.",1);w7("systemPrompt",await Ui5(X))}function jI4(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function RI4(J,Z){if(typeof J==="boolean")return J;if(!J3(Z))return!1;return dQ(Z.user.email)}function Vi5(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function xd0(J){let X=Vi5(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 w4(`Couldn't connect to the Amp server at ${J}.`,1,X)}var NI4=[{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??TX,description:`Custom settings file path (overrides the default location ${TX})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(P).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${KE})`},{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:m9(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"mode",long:"mode",short:"m",type:"option",default:OV.SMART.key,description:`Set the agent mode (${fQ().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:fQ().map((J)=>J.mode).concat("large","deep")},{name:"dtw",long:"dtw",type:"flag",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:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0}],OI4=(J)=>("deprecated"in J)&&J.deprecated===!0,Di5=(J)=>("hidden"in J)&&J.hidden===!0,Ki5=(J)=>("default"in J),zi5=(J)=>("default"in J)?J.default:void 0,PI4=[{name:"toggle-skills-count",entryPoint:Yu0}];function qi5(J,Z){let Q=Z.args[0],X=Z.commands.map((U)=>U.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let U=X.filter((D)=>Q.includes(D)||D.includes(Q)),V="Run amp --help for a list of available commands.";if(U.length>0)V=`Did you mean: ${U.join(", ")}? Or run amp --help for all commands.`;throw new w4(t3.unknownCommand(Q),1,V)}}async function bd0(J){return{...J,getThreadEnvironment:qU,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new hY(J.fileSystem),generateThreadTitle:pj,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>AZ(J.configService),pluginService:J.pluginService}}var r$0=q1.file(Zi5.homedir()),fd0=process.env.XDG_CONFIG_HOME?q1.file(process.env.XDG_CONFIG_HOME):V1.joinPath(r$0,".config");function Gi5(J){return g84({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){m84(Z);let Q=q80(),X=Tu0();if((!Q||X||iX4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(Xq("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(Xq("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(q80()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}function Fi5(){return{sync:async()=>{},uploadThread:async()=>{},discoverThreads:async()=>[],initialSyncComplete:Promise.resolve(),updateThreadMeta:async()=>{},threadSyncInfo:()=>v0.of({}),flushPendingSyncs:async()=>{},dispose:()=>{}}}async function c9(J,Z){VM1("0.0.1772280107-g5cb360");let Q=Mo({storage:J.settings,secretStorage:J.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:r$0,userConfigDir:fd0});gX4(Q);let X=await Q.getLatest();P.debug("Global configuration initialized",{settingsKeys:Object.keys(X.settings)});let{toolService:Y,dispose:U}=u84({configService:Q}),V=new Map,D=()=>V.clear(),K=new AE0(Q,J.settings.getWorkspaceRootPath()),z=qb1({configService:Q,filesystem:n6}),q=yk1({configService:Q,trustStore:K,skillMCPServers:z.skillMCPServers,createOAuthProvider:async(m,l,g)=>{let n=`${m}:${l}`,d=V.get(n);if(d)return P.debug("Reusing existing OAuth provider for server",{serverName:m,serverUrl:l}),d;P.debug("Creating OAuth provider for server",{serverName:m,serverUrl:l});let $0=(async()=>{let B0=new YN(J.secrets),s=await B0.getClientInfo(m,l),q0=g?.scopes??s?.scopes,K0=QQ4();P.info("OAuth headless mode check",{useHeadless:K0,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:s6.isTTY});let O0;if(K0)O0=J.executeMode?ZQ4():JQ4(m);let Y0=new dO0({storage:B0,serverName:m,serverUrl:l,clientId:g?.clientId??s?.clientId,clientSecret:g?.clientSecret??s?.clientSecret,authUrl:g?.authUrl??s?.authUrl,tokenUrl:g?.tokenUrl??s?.tokenUrl,scopes:q0,headlessAuthHandler:O0});return P.debug("OAuth provider created",{serverName:m,serverUrl:l,hasManualClientId:!!(g?.clientId??s?.clientId),willUseDCR:!(g?.clientId??s?.clientId),scopes:q0,headlessMode:K0,executeMode:J.executeMode}),Y0})();return V.set(n,$0),$0}}),G=ES0({configService:Q,filesystem:n6,spawn:Z50}),F;if(J.executeMode){let m=await t64({toolService:Y,providers:[q,G],initialTimeout:15000});F=m.registrations;for(let[l,g]of m.initErrors)P.warn(`${l} provider initialization slow or failed:`,g)}else F=IS0({toolService:Y,providers:[q,G]});if(Z.jetbrains)xw("JetBrains");else if(Z.ide&&hQ4())xw("VS Code");else if(Z.ide&&mQ4())xw("Neovim");else if(Z.ide&&Xi5()){let m=pK.find((l)=>l.listConfigs().length>0);if(m){let l=Po(m.ideName);if(l)xw(l)}}if(J.executeMode)DM1(!0);let W,H=_8.status.pipe(B1((m)=>Boolean(m.connected&&m.authenticated&&m.ideName&&AM1(m.ideName))),M4()).subscribe((m)=>{if(m){if(!W)W=Y.registerTool(s64)}else W?.dispose(),W=void 0}),B;if(!J.executeMode){let m=await J.settings.get("fuzzy.alwaysIncludePaths")??[];B=new T30(process.cwd(),{alwaysIncludePaths:m},!0)}else B=new class extends T30{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};{let m=await J.secrets.get("apiKey",J.ampURL);if(P.info("API key lookup before login",{found:Boolean(m),ampURL:J.ampURL}),!m){s6.write(`No API key found. Starting login flow...
7262
+ `)}function Yi5(J){process.emitWarning=(Z,Q,X,Y)=>{let U=typeof Z==="string"?Z:Z.message||String(Z),V=Q||"Warning",D=!1;J.warn(U,{name:V,code:X})}}function g7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")w7("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")w7("experimental.agentMode",Z.mode)}function MI4(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function Ui5(J){try{return await II4(J,"utf-8")}catch{return J}}async function AI4(J,Z,Q){let X=MI4(J,Z);if(!X)return;let Y=J3(Q)?Q.features:[],U=J3(Q)?Q.user.email:void 0;if(!Y.some((D)=>D.name===IY.HARNESS_SYSTEM_PROMPT&&D.enabled)&&!jI4(U))throw new w4("You are not allowed to do this.",1);w7("systemPrompt",await Ui5(X))}function jI4(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function RI4(J,Z){if(typeof J==="boolean")return J;if(!J3(Z))return!1;return dQ(Z.user.email)}function Vi5(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function xd0(J){let X=Vi5(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 w4(`Couldn't connect to the Amp server at ${J}.`,1,X)}var NI4=[{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??TX,description:`Custom settings file path (overrides the default location ${TX})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(P).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${KE})`},{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:m9(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"mode",long:"mode",short:"m",type:"option",default:OV.SMART.key,description:`Set the agent mode (${fQ().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:fQ().map((J)=>J.mode).concat("large","deep")},{name:"dtw",long:"dtw",type:"flag",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:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0}],OI4=(J)=>("deprecated"in J)&&J.deprecated===!0,Di5=(J)=>("hidden"in J)&&J.hidden===!0,Ki5=(J)=>("default"in J),zi5=(J)=>("default"in J)?J.default:void 0,PI4=[{name:"toggle-skills-count",entryPoint:Yu0}];function qi5(J,Z){let Q=Z.args[0],X=Z.commands.map((U)=>U.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let U=X.filter((D)=>Q.includes(D)||D.includes(Q)),V="Run amp --help for a list of available commands.";if(U.length>0)V=`Did you mean: ${U.join(", ")}? Or run amp --help for all commands.`;throw new w4(t3.unknownCommand(Q),1,V)}}async function bd0(J){return{...J,getThreadEnvironment:qU,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new hY(J.fileSystem),generateThreadTitle:pj,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>AZ(J.configService),pluginService:J.pluginService}}var r$0=q1.file(Zi5.homedir()),fd0=process.env.XDG_CONFIG_HOME?q1.file(process.env.XDG_CONFIG_HOME):V1.joinPath(r$0,".config");function Gi5(J){return g84({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){m84(Z);let Q=q80(),X=Tu0();if((!Q||X||iX4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(Xq("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(Xq("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(q80()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}function Fi5(){return{sync:async()=>{},uploadThread:async()=>{},discoverThreads:async()=>[],initialSyncComplete:Promise.resolve(),updateThreadMeta:async()=>{},threadSyncInfo:()=>v0.of({}),flushPendingSyncs:async()=>{},dispose:()=>{}}}async function c9(J,Z){VM1("0.0.1772294494-g9b3cb4");let Q=Mo({storage:J.settings,secretStorage:J.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:r$0,userConfigDir:fd0});gX4(Q);let X=await Q.getLatest();P.debug("Global configuration initialized",{settingsKeys:Object.keys(X.settings)});let{toolService:Y,dispose:U}=u84({configService:Q}),V=new Map,D=()=>V.clear(),K=new AE0(Q,J.settings.getWorkspaceRootPath()),z=qb1({configService:Q,filesystem:n6}),q=yk1({configService:Q,trustStore:K,skillMCPServers:z.skillMCPServers,createOAuthProvider:async(m,l,g)=>{let n=`${m}:${l}`,d=V.get(n);if(d)return P.debug("Reusing existing OAuth provider for server",{serverName:m,serverUrl:l}),d;P.debug("Creating OAuth provider for server",{serverName:m,serverUrl:l});let $0=(async()=>{let B0=new YN(J.secrets),s=await B0.getClientInfo(m,l),q0=g?.scopes??s?.scopes,K0=QQ4();P.info("OAuth headless mode check",{useHeadless:K0,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:s6.isTTY});let O0;if(K0)O0=J.executeMode?ZQ4():JQ4(m);let Y0=new dO0({storage:B0,serverName:m,serverUrl:l,clientId:g?.clientId??s?.clientId,clientSecret:g?.clientSecret??s?.clientSecret,authUrl:g?.authUrl??s?.authUrl,tokenUrl:g?.tokenUrl??s?.tokenUrl,scopes:q0,headlessAuthHandler:O0});return P.debug("OAuth provider created",{serverName:m,serverUrl:l,hasManualClientId:!!(g?.clientId??s?.clientId),willUseDCR:!(g?.clientId??s?.clientId),scopes:q0,headlessMode:K0,executeMode:J.executeMode}),Y0})();return V.set(n,$0),$0}}),G=ES0({configService:Q,filesystem:n6,spawn:Z50}),F;if(J.executeMode){let m=await t64({toolService:Y,providers:[q,G],initialTimeout:15000});F=m.registrations;for(let[l,g]of m.initErrors)P.warn(`${l} provider initialization slow or failed:`,g)}else F=IS0({toolService:Y,providers:[q,G]});if(Z.jetbrains)xw("JetBrains");else if(Z.ide&&hQ4())xw("VS Code");else if(Z.ide&&mQ4())xw("Neovim");else if(Z.ide&&Xi5()){let m=pK.find((l)=>l.listConfigs().length>0);if(m){let l=Po(m.ideName);if(l)xw(l)}}if(J.executeMode)DM1(!0);let W,H=_8.status.pipe(B1((m)=>Boolean(m.connected&&m.authenticated&&m.ideName&&AM1(m.ideName))),M4()).subscribe((m)=>{if(m){if(!W)W=Y.registerTool(s64)}else W?.dispose(),W=void 0}),B;if(!J.executeMode){let m=await J.settings.get("fuzzy.alwaysIncludePaths")??[];B=new T30(process.cwd(),{alwaysIncludePaths:m},!0)}else B=new class extends T30{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};{let m=await J.secrets.get("apiKey",J.ampURL);if(P.info("API key lookup before login",{found:Boolean(m),ampURL:J.ampURL}),!m){s6.write(`No API key found. Starting login flow...
7263
7263
  `);let l=await Wi5(J),g=await J.secrets.get("apiKey",J.ampURL);if(P.info("Login flow completed",{success:l,storedKeyPresent:Boolean(g),ampURL:J.ampURL}),!l)await $q(),process.exit(1)}}{let m=await Q.getLatest(),l=m.settings.url,g=m.secrets.isSet?.[l];P.info("Config secrets state after login",{configURL:l,apiKeySet:g?.apiKey??!1})}let w=_1(AZ(Q).pipe(d5((m)=>m!=="pending"))),N=await wb1({isDevelopment:!1}),O=await w;P.info("Server status resolved",{status:"ready",isAuthenticated:J3(O),isError:oA(O),errorMessage:oA(O)?O.error.message:void 0});let E=new SM0(N,Q),L=new AI0(N,{lazy:!0});P.info("Starting Amp background services");let I=RI4(Z.dtw,O),M=Boolean(I||Z.headless);if(M)P.info("DTW mode enabled: thread sync service disabled");let A=M?Fi5():ih1({threadService:E,threadHistoryService:L,configService:Q,isExtensionDevelopment:!1}),j;_8.status.subscribe((m)=>{j=m});let _=new gH0({workspaceRoots:[q1.file(process.cwd())],fileSystem:Z.jetbrains||Z.ide?ps:n6,getCurrentFile:()=>{if(!j?.openFile)return;try{return q1.parse(j.openFile)}catch(m){P.warn("Failed to parse current file URI",{uri:j.openFile,error:m});return}},getOpenFiles:()=>{if(!j?.visibleFiles?.length)return[];let m=j.openFile;return j.visibleFiles.filter((l)=>l!==m).map((l)=>{try{return q1.parse(l)}catch(g){return P.warn("Failed to parse visible file URI",{uri:l,error:g}),null}}).filter((l)=>l!==null)}}),k=new vu0,y=process.env.PLUGINS??"off",h=new Xu0({configService:Q}),f=qI0({configService:Q,fileSystem:Z.jetbrains||Z.ide?ps:n6,platform:h,internalPlugins:PI4,pluginFilter:y}),S=vf1({pluginService:f,toolService:Y}),x={codebaseContextService:_,configService:Q,toolService:Y,mcpService:q,skillService:z,toolboxService:G,trustStore:K,threadService:E,threadHistoryService:L,threadSyncService:A,threadStorage:N,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:B,fileSystem:Z.jetbrains||Z.ide?ps:n6,terminal:k,pluginService:f,pluginPlatform:h,serverStatus:O};return{...x,async asyncDispose(){if(x.mcpService.hasAuthenticatingClients())P.info("Waiting for OAuth authentication to complete before exit..."),await x.mcpService.waitForAuthentication();for(let m of F.values())m.dispose();await x.mcpService.dispose(),D(),await x.threadService.asyncDispose(),x.configService.unsubscribe(),U(),x.fuzzyServer.dispose(),x.threadSyncService.dispose(),x.settingsStorage[Symbol.dispose](),H.unsubscribe(),W?.dispose(),S.dispose(),x.pluginService.dispose()}}}async function Wi5(J){if(!J.executeMode){if(!await Zu0("Would you like to log in to Amp? [(y)es, (n)o]: "))return s6.write(`Login cancelled. Run the command again to retry.
7264
7264
  `),!1}return await CI4(J)}async function CI4(J){let Z=el5(32).toString("hex"),Q=await Ju0(J.ampURL,Z),X=new AbortController;try{await IV(Q,X.signal)}catch(U){P.error("Error opening browser",{error:U})}let Y=await Ju0(J.ampURL,Z,!1);s6.write(`If your browser does not open automatically, visit:
7265
7265
 
@@ -7267,7 +7267,7 @@ ${Z1.blue.bold(Y)}
7267
7267
 
7268
7268
  `);try{return await KX4(J.ampURL,Z,J.secrets,X),s6.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(U){return P.error("Login failed",{error:U}),z7.write(`
7269
7269
  Login failed: ${U instanceof Error?U.message:String(U)}
7270
- `),!1}}function Hi5(){let J=new RW().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((H)=>{if(H.code==="commander.help"||H.code==="commander.version"||H.exitCode===0)qE(),process.exit(0);let B=H.originalError??H;O30(B)}),J.option("-V, --version","Print the version number and exit",()=>{let B;try{B=`, ${YF(new Date("2026-02-28T12:07:30.550Z"))} ago`}catch{}s6.write(`0.0.1772280107-g5cb360 (released 2026-02-28T12:07:30.550Z${B??""})
7270
+ `),!1}}function Hi5(){let J=new RW().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((H)=>{if(H.code==="commander.help"||H.code==="commander.version"||H.exitCode===0)qE(),process.exit(0);let B=H.originalError??H;O30(B)}),J.option("-V, --version","Print the version number and exit",()=>{let B;try{B=`, ${YF(new Date("2026-02-28T16:07:19.137Z"))} ago`}catch{}s6.write(`0.0.1772294494-g9b3cb4 (released 2026-02-28T16:07:19.137Z${B??""})
7271
7271
  `),process.exit(0)}),J.addHelpText("after",xQ4()),J.configureHelp({formatHelp:fQ4}),J.command("logout").description("Log out by removing stored API key").action(async(H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await Mi5(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(H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await Ii5(N,await xy0(w,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(H,B,w)=>{let N=w.optsWithGlobals(),O=await M3(N);await mZ4(H??"get",O.ampURL,O.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(H,B)=>{let w=B.optsWithGlobals(),N=await M3(w);await gZ4(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",`
7272
7272
  Actions:
7273
7273
  add-message <message> Send a user message and wait for message_added
@@ -7311,7 +7311,7 @@ See: https://ampcode.com/news/stick-a-fork-in-it
7311
7311
  amp threads handoff T-xxx --goal "Continue working on the auth feature"
7312
7312
  amp threads handoff --goal "Fix the remaining tests" # Uses last thread
7313
7313
 
7314
- 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(H,B,w)=>{let N=w.optsWithGlobals(),O=await M3(N);await _i5(N,O,H??null,B.goal,!B.print,w)}),Q.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(H,B,w)=>{let N=w.optsWithGlobals(),O=await M3(N);await Pi5(N,O,H,w)}),Q.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(H,B,w)=>{let N=w.optsWithGlobals(),O=await M3(N);await Ci5(N,O,H,w)}),P94(Q,M3,g7,c9,hd0,oH,q3),gY4(J,async(H,B)=>{let w=await M3(B);g7(H,B);let N=await c9(w,B);return{context:w,mcpService:N.mcpService,toolService:N.toolService,toolServices:N.toolService,skillService:N.skillService,threadService:N.threadService,fileSystem:N.fileSystem,getThreadEnvironment:qU,serverStatus:N.serverStatus,toolboxService:N.toolboxService,configService:N.configService,cleanupTerminal:qE,asyncDispose:N.asyncDispose.bind(N)}}),TX4(J,async(H)=>{let B=H.optsWithGlobals(),w=await M3(B);g7(H,B);let N=Mo({storage:w.settings,secretStorage:w.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:w.ampURL,homeDir:r$0,userConfigDir:fd0});return{pluginService:qI0({configService:N,fileSystem:n6,platform:{clientKind:"terminal",clientVersion:"0.0.1772280107-g5cb360",async notify(L){P.debug("plugin notification (TUI not loaded): %s",L)},async open(L){z7.write(`
7314
+ 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(H,B,w)=>{let N=w.optsWithGlobals(),O=await M3(N);await _i5(N,O,H??null,B.goal,!B.print,w)}),Q.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(H,B,w)=>{let N=w.optsWithGlobals(),O=await M3(N);await Pi5(N,O,H,w)}),Q.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(H,B,w)=>{let N=w.optsWithGlobals(),O=await M3(N);await Ci5(N,O,H,w)}),P94(Q,M3,g7,c9,hd0,oH,q3),gY4(J,async(H,B)=>{let w=await M3(B);g7(H,B);let N=await c9(w,B);return{context:w,mcpService:N.mcpService,toolService:N.toolService,toolServices:N.toolService,skillService:N.skillService,threadService:N.threadService,fileSystem:N.fileSystem,getThreadEnvironment:qU,serverStatus:N.serverStatus,toolboxService:N.toolboxService,configService:N.configService,cleanupTerminal:qE,asyncDispose:N.asyncDispose.bind(N)}}),TX4(J,async(H)=>{let B=H.optsWithGlobals(),w=await M3(B);g7(H,B);let N=Mo({storage:w.settings,secretStorage:w.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:w.ampURL,homeDir:r$0,userConfigDir:fd0});return{pluginService:qI0({configService:N,fileSystem:n6,platform:{clientKind:"terminal",clientVersion:"0.0.1772294494-g9b3cb4",async notify(L){P.debug("plugin notification (TUI not loaded): %s",L)},async open(L){z7.write(`
7315
7315
  ${L}
7316
7316
 
7317
7317
  `)},async input(){return},async confirm(){return!1},async ask(){return{result:"uncertain",probability:0.5,reason:"AI not available"}}},internalPlugins:PI4,emitSessionStart:!1,pluginFilter:process.env.PLUGINS??"off"}),asyncDispose:async()=>{}}}),yX4(J,async(H)=>{let B=H.optsWithGlobals(),w=await M3(B);g7(H,B);let N=await c9(w,B);return{toolService:N.toolService,mcpService:N.mcpService,configService:N.configService,skillService:N.skillService,cleanupTerminal:qE,asyncDispose:N.asyncDispose.bind(N)}}),hX4(J,async(H)=>{let B=H.optsWithGlobals(),w=await M3(B);g7(H,B);let N=await c9(w,B);return{settings:w.settings,configService:N.configService,skillService:N.skillService,asyncDispose:N.asyncDispose.bind(N)}}),RX4(J,async(H)=>{let B=H.optsWithGlobals();return await M3(B)}),HX4(J,async(H)=>{let B=await M3(H);return{settings:B.settings,secretStorage:B.secrets,getThreadDeps:async(w)=>{g7(w,H);let N=await c9(B,H);return{mcpService:N.mcpService,settings:B.settings,asyncDispose:N.asyncDispose.bind(N)}}}}),sN4(J,M3);function U(H,B,w){let O=typeof H.description==="string"?H.description:w===void 0?H.description(!0):H.description(w),E=new zU(B,O),L=zi5(H);if(L)E.default(L);if(E.hidden=Di5(H)||OI4(H),"choices"in H)E.choices([...H.choices]);return E}for(let H of NI4){switch(H.type){case"flag":{J.addOption(U(H,`--${H.long}`)),J.addOption(U(H,`--no-${H.long}`,!1));break}case"switch":{J.addOption(U(H,`--${H.long}`,!0));break}case"optional-option":{J.addOption(U(H,`${"short"in H?`-${H.short}, `:""}--${H.long} [value]`));break}default:{J.addOption(U(H,`${"short"in H?`-${H.short}, `:""}--${H.long} <value>`));break}}if("aliases"in H&&H.aliases)for(let B of H.aliases){let w=new zU(`--${B}`,H.description);w.hidden=!0,w.implies({[H.name]:!0}),J.addOption(w)}}let V=new zU("-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(V);let D=new zU("-r, --remote","When used with -x/--execute, execute in an async agent on the Amp server.").default(!1).hideHelp(!0);J.addOption(D);let K=new zU("--stream-json","When used with --execute, output in Claude Code-compatible stream JSON format instead of plain text.").default(!1);J.addOption(K);let z=new zU("--stream-json-thinking","Include thinking blocks in stream JSON output (non-Claude Code extension). Implies --stream-json.").default(!1);J.addOption(z);let q=new zU("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(q);let G=new zU("--stats","When used with --execute, output JSON with both result and token usage data (for /evals).").default(!1).hideHelp(!0);J.addOption(G);let F=new zU("--archive","When used with --execute, archive the thread after the command finishes.").default(!1);J.addOption(F);let W=new zU("-l, --label <label>","When used with --execute, add a label to the thread. Can be used multiple times.").argParser((H,B)=>{if(B===void 0)return[H];return[...B,H]});return J.addOption(W),J.action(async(H,B)=>{let w=H,N=await M3(w);if(Object.keys(w).forEach((O)=>{let E=NI4.find((L)=>L.name===O);if(E&&OI4(E)&&!Ki5(E))z7.write(Z1.yellow(`Warning: '--${O}' flag is deprecated
@@ -7319,8 +7319,8 @@ ${L}
7319
7319
 
7320
7320
  This thread belongs to a different user and cannot be continued for security reasons. Set AMP_RESUME_OTHER_USER_THREADS_INSECURE=1 to bypass this check.`)}}async function Bi5(J,{nonBlockingOwnershipCheck:Z=!1,onOwnershipError:Q}={},X){if(!q8(J))throw new w4(t3.invalidThreadId);let Y=Date.now();if(P.info(`[fetchAndStartThread] Begin switch to thread ${J}`),Z)EI4(J,X.configService).catch((z)=>{if(z instanceof w4){if(Q){Q(z,J);return}ch(z,J);return}P.warn("Failed to validate thread ownership in CLI, allowing to open",{error:z})});else try{await EI4(J,X.configService)}catch(z){if(z instanceof w4)throw z;P.warn("Failed to validate thread ownership in CLI, allowing to open",{error:z})}let U=Date.now(),V=await X.threadService.get(J)??void 0;P.info(`[fetchAndStartThread] Loaded thread in ${Date.now()-U}ms`),P.info(`[fetchAndStartThread] Loaded thread ${J}, agentMode: ${V?.agentMode??"undefined"}`);let D=Date.now(),K=await Up0(X.workerDeps,{threadMeta:X.visibility?vD(X.visibility):void 0,agentMode:V?void 0:X.agentMode,thread:V,onFirstAssistantMessage:TI4});return P.info(`[fetchAndStartThread] Started worker in ${Date.now()-D}ms (total ${Date.now()-Y}ms)`),K}async function wi5(J){if(!J.userEmail||!dQ(J.userEmail))throw new w4("DTW TUI mode is only available for Amp employees",1);let Z=await J.secretStorage.get("apiKey",J.ampURL);P.info("[createDTWRuntime] Creating DTW provider",{threadId:J.threadId,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL,hasApiKey:Boolean(Z)});let Q;try{Q=await uW.create({ampURL:J.ampURL,apiKey:Z,configService:J.configService,threadId:J.threadId,workerUrl:process.env.AMP_WORKER_URL})}catch(X){throw P.error("[createDTWRuntime] Failed to create DTW provider",{threadId:J.threadId,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL,error:X}),X}P.info("[createDTWRuntime] Creating DTW runtime",{threadId:Q.threadId});try{return await oW.create({provider:Q,deps:{threadService:J.threadService,configService:J.configService,toolService:J.toolService,skillService:J.skillService,getThreadEnvironment:qU,fileChangeTrackerStorage:new hY(J.fileSystem),osFileSystem:J.fileSystem,deleteThread:(X)=>J.threadService.delete(X),generateThreadTitle:pj,mcpService:J.mcpService,pluginService:J.pluginService,ampURL:J.ampURL}})}catch(X){throw P.error("[createDTWRuntime] Failed to create DTW runtime",{threadId:Q.threadId,error:X}),X}}async function Ni5(J){if(J.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof J.execute==="string"){let Z=(await Fm()).trimEnd();return{userInput:J.execute,stdinInput:Z||null}}return{userInput:(await Fm()).trimEnd(),stdinInput:null}}function Oi5(J,Z,Q){if(J.remote&&!Z)throw new w4("The -r/--remote flag requires --execute mode",1,'Use: amp --remote --execute "your message"');if(J.streamJson&&!Z)throw new w4("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(J.streamJsonInput&&!Z)throw new w4("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(J.streamJsonInput&&!J.streamJson)throw new w4("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(J.stats&&!Z)throw new w4("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(J.archive&&!Z)throw new w4("The --archive flag requires --execute mode",1,'Use: amp --execute "your message" --archive');if(J.streamJsonInput&&typeof J.execute==="string"&&J.execute.trim()!=="")throw new w4("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(Z&&Q===""&&!J.streamJsonInput&&!J.headless)throw new w4("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"
7321
7321
  Or pipe via stdin: echo "your message" | amp --execute`)}async function s$0(J,Z,Q){let{userInput:X,stdinInput:Y}=await Ni5(Z),U=!!Z.streamJson||!!Z.streamJsonThinking;Oi5({...Z,streamJson:U},J.executeMode,X),g7(Q,Z);let V=await c9(J,Z),D=await bd0(V),{serverStatus:K}=V;if(oA(K)){let S=dh(Error(K.error.message));if(S.message===t3.networkOffline||S.message===t3.networkTimeout)throw xd0(J.ampURL);throw new w4(t3.invalidAPIKey,1)}let z=J3(K)?K.user.email:void 0,q=J3(K)?K.features:[],G=J3(K)?K.workspace:null,F=jI4(z),W=RI4(Z.dtw,K);await AI4(Q,Z,K);let H=J3(K)?{...K.user,features:q,team:G??void 0}:null,B=a30(Z,H);if(B instanceof Error)q3(B.message);if((J.executeMode||U)&&P8(Z.mode)&&!F)throw new w4(`Execute mode is not permitted with --mode '${Z.mode}'`,1);if(J.executeMode&&Z.remote)await _X4(X,Y,V.configService),await V.asyncDispose(),process.exit(0);if(Z.headless){if(!z||!dQ(z))throw new w4("Headless DTW mode is only available for Amp employees",1);let S=await V.secretStorage.get("apiKey",J.ampURL);if(!S)throw new w4("API key required for headless mode. Please run `amp login` first.",1);let x=typeof Z.headless==="string"&&Z.headless!=="true"?Z.headless:void 0;if(x&&!q8(x))throw new w4(`Invalid thread ID: ${x}`,1);let m=x??await Si5({dependencies:V,visibility:B??void 0}),l=await VQ4(m);if(l.status==="already-running")await V.asyncDispose(),await $q(),process.exit(0);try{await $Q4({ampURL:J.ampURL,apiKey:S,workerUrl:process.env.AMP_WORKER_URL,workspaceRoot:process.cwd(),threadId:m,configService:V.configService,mcpService:V.mcpService,toolService:V.toolService,skillService:V.skillService,fileSystem:V.fileSystem})}finally{await l.release(),await V.asyncDispose()}await $q(),process.exit(0)}let w={threadService:V.threadService,workerDeps:D,createThread:async()=>{let S=await H30(J.settings,process.cwd(),H,B);if(S instanceof Error)q3(S.message);return Up0(D,{threadMeta:S?vD(S):void 0,agentMode:Z.mode,onFirstAssistantMessage:TI4})},switchToThread:(S,x)=>Bi5(S,{nonBlockingOwnershipCheck:x?.nonBlockingOwnershipCheck??!1,onOwnershipError:x?.onOwnershipError},{configService:V.configService,threadService:V.threadService,workerDeps:D,visibility:B,agentMode:Z.mode})},N=async()=>{try{if(W)return wi5({userEmail:z,secretStorage:V.secretStorage,ampURL:J.ampURL,configService:V.configService,threadService:V.threadService,toolService:V.toolService,skillService:V.skillService,mcpService:V.mcpService,pluginService:V.pluginService,fileSystem:V.fileSystem,threadId:Z.threadId});return dN4(w,Z.threadId,{nonBlockingOwnershipCheck:Z.nonBlockingThreadOwnershipCheck})}catch(S){if(S instanceof w4)throw S;throw await ch(S,Z.threadId),Error("handleError should have called process.exit()")}};if(Z.format==="jsonl")z7.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
7322
- `),await $q(),process.exit(1);let O=(async()=>{try{let S=await V.configService.getLatest(),x=ya(S),m=await T6.getUserFreeTierStatus({},{config:V.configService,signal:AbortSignal.timeout(x)});if(m.ok)return P.info("User free tier status:",m),m.result}catch(S){throw P.error("Failed to fetch free tier status:",S),S}})(),E=await N(),L=Z.notifications!==void 0?Z.notifications:!J.executeMode,I=await V.configService.getLatest();if(Gi5({configService:V.configService,threadService:V.threadService,config:I,useNotificationsForService:L,threadViewStates$:()=>E.threadViewStates$}),J.executeMode){if(OX4(V.mcpService,J.settings),!(E instanceof wT))throw new w4("Execute mode is not supported in DTW runtime",1);let S=E.getWorkerForExecuteMode();if(await jZ4({worker:S,threadID:S.threadID,userInput:X,stdinInput:Y,dependencies:V,streamJson:U,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isDogfooding:F,agentMode:Z.mode,labels:Z.label}),Z.archive)await T6.archiveThread({thread:S.threadID,archived:!0},{config:V.configService});await V.asyncDispose(),process.exit(0)}let M=!1,A=!1,j=!1;if(Z.jetbrains||Z.ide){await TM1();let S=gw({jetbrainsOnly:Z.jetbrains});if(S.length===0){if(Z.jetbrains)A=!await V.configService.get("jetbrains.skipInstall")}else if(S.length===1){let x=S[0];if(x)_8.selectConfig(x)}else j=!0}let _=$u0("0.0.1772280107-g5cb360",V.settingsStorage),k=new MI0(V.threadStorage),y=new Qu0(V.mcpService,J.settings.getWorkspaceRootPath());if(X)await E.sendMessage({content:[{type:"text",text:X}]});let h=await kD();P.info("Loaded session state:",h);let f={...h,launchCount:h.launchCount+1};yD(f);try{await bN4({codebaseContextService:V.codebaseContextService,stdout:process.stdout,history:new Ly0,fuzzyServer:V.fuzzyServer,settingsStorage:V.settingsStorage,threadService:V.threadService,threadHistoryService:V.threadHistoryService,threadFuzzyIndexer:k,skillService:V.skillService,configService:V.configService,internalAPIClient:T6,ampURL:J.ampURL,runtime:E,ideClient:_8,mcpService:V.mcpService,toolboxService:V.toolboxService,mcpTrustHandler:y,showJetBrainsInstaller:A,showIdePicker:M,showIdePickerHint:j,openThreadSwitcher:Z.openThreadSwitcher,updateService:_,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Z.clientId,sessionState:f,freeTierStatusPromise:O,workspace:G??null,features:q,isDogfooding:F,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-02-28T12:07:30.550Z",pluginPlatform:V.pluginPlatform,pluginService:V.pluginService})}finally{await E.dispose?.()}await V.asyncDispose(),process.exit(0)}async function M3(J){if(P.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)z7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7323
- `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;P.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let X=await mk1({get:async(D)=>{if(D!==gy)return;try{let K=await II4(ud0,"utf-8");return JSON.parse(K).installationID}catch{return}},set:async(D,K)=>{if(D!==gy)return;await $i5(pp.dirname(ud0),{recursive:!0}),await Ji5(ud0,JSON.stringify({installationID:K},null,2),{mode:384})}},{clientType:"cli",platform:cQ()});KM1(X);let Y=await EQ4({...J,workspaceTrust:{current:!0,changes:Sv},getHook:process.env.AMP_URL?(D,K)=>{if(D==="url")return Promise.resolve(process.env.AMP_URL);return K()}:void 0});if(J.mcpConfig){let D=await wX4(J.mcpConfig);Y=NX4(Y,D)}let U=pp.dirname(Y.getSettingsFilePath());h84(eP,U);let V=await Y.get("url","global");if(!V)V=N7;if(P.info("Resolved Amp URL",{ampURL:V,settingsFile:Y.getSettingsFilePath(),workspaceRoot:Y.getWorkspaceRootPath()}),!xG(V))P.info("Targeting custom Amp server",{ampURL:V});return Y=tI1(Y),{executeMode:Z,isTTY:Q,ampURL:V,settings:Y,secrets:uX4(await xy0(J,Y))}}function Ei5(J){let Z={};for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X?.startsWith("--")){let U=X.slice(2).replace(/-([a-z])/g,(D,K)=>K.toUpperCase()),V=J[Q+1];if(V&&!V.startsWith("--"))Z[U]=V,Q++}}return Z}async function Li5(){let J=Ei5(process.argv),Z=process.argv.includes("--headless")||process.argv.some((U)=>U.startsWith("--headless="));hJ4({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Z?Qi5:void 0)});let Q=process.argv.includes("--no-color"),X=process.argv.includes("--color"),Y=process.stdout.isTTY&&process.stderr.isTTY;if(Q||!X&&!Y)Z1.level=0;if(Yi5(P),P.info("Starting Amp CLI.",{version:"0.0.1772280107-g5cb360",buildTimestamp:"2026-02-28T12:07:30.550Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new w4(t3.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Hi5().parseAsync(process.argv)}f84().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await Li5().catch(ch)});async function Ii5(J,Z){let Q=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Q)await J.settings.set("url",process.env.AMP_URL,"global"),s6.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7322
+ `),await $q(),process.exit(1);let O=(async()=>{try{let S=await V.configService.getLatest(),x=ya(S),m=await T6.getUserFreeTierStatus({},{config:V.configService,signal:AbortSignal.timeout(x)});if(m.ok)return P.info("User free tier status:",m),m.result}catch(S){throw P.error("Failed to fetch free tier status:",S),S}})(),E=await N(),L=Z.notifications!==void 0?Z.notifications:!J.executeMode,I=await V.configService.getLatest();if(Gi5({configService:V.configService,threadService:V.threadService,config:I,useNotificationsForService:L,threadViewStates$:()=>E.threadViewStates$}),J.executeMode){if(OX4(V.mcpService,J.settings),!(E instanceof wT))throw new w4("Execute mode is not supported in DTW runtime",1);let S=E.getWorkerForExecuteMode();if(await jZ4({worker:S,threadID:S.threadID,userInput:X,stdinInput:Y,dependencies:V,streamJson:U,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isDogfooding:F,agentMode:Z.mode,labels:Z.label}),Z.archive)await T6.archiveThread({thread:S.threadID,archived:!0},{config:V.configService});await V.asyncDispose(),process.exit(0)}let M=!1,A=!1,j=!1;if(Z.jetbrains||Z.ide){await TM1();let S=gw({jetbrainsOnly:Z.jetbrains});if(S.length===0){if(Z.jetbrains)A=!await V.configService.get("jetbrains.skipInstall")}else if(S.length===1){let x=S[0];if(x)_8.selectConfig(x)}else j=!0}let _=$u0("0.0.1772294494-g9b3cb4",V.settingsStorage),k=new MI0(V.threadStorage),y=new Qu0(V.mcpService,J.settings.getWorkspaceRootPath());if(X)await E.sendMessage({content:[{type:"text",text:X}]});let h=await kD();P.info("Loaded session state:",h);let f={...h,launchCount:h.launchCount+1};yD(f);try{await bN4({codebaseContextService:V.codebaseContextService,stdout:process.stdout,history:new Ly0,fuzzyServer:V.fuzzyServer,settingsStorage:V.settingsStorage,threadService:V.threadService,threadHistoryService:V.threadHistoryService,threadFuzzyIndexer:k,skillService:V.skillService,configService:V.configService,internalAPIClient:T6,ampURL:J.ampURL,runtime:E,ideClient:_8,mcpService:V.mcpService,toolboxService:V.toolboxService,mcpTrustHandler:y,showJetBrainsInstaller:A,showIdePicker:M,showIdePickerHint:j,openThreadSwitcher:Z.openThreadSwitcher,updateService:_,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Z.clientId,sessionState:f,freeTierStatusPromise:O,workspace:G??null,features:q,isDogfooding:F,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-02-28T16:07:19.137Z",pluginPlatform:V.pluginPlatform,pluginService:V.pluginService})}finally{await E.dispose?.()}await V.asyncDispose(),process.exit(0)}async function M3(J){if(P.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)z7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7323
+ `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;P.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let X=await mk1({get:async(D)=>{if(D!==gy)return;try{let K=await II4(ud0,"utf-8");return JSON.parse(K).installationID}catch{return}},set:async(D,K)=>{if(D!==gy)return;await $i5(pp.dirname(ud0),{recursive:!0}),await Ji5(ud0,JSON.stringify({installationID:K},null,2),{mode:384})}},{clientType:"cli",platform:cQ()});KM1(X);let Y=await EQ4({...J,workspaceTrust:{current:!0,changes:Sv},getHook:process.env.AMP_URL?(D,K)=>{if(D==="url")return Promise.resolve(process.env.AMP_URL);return K()}:void 0});if(J.mcpConfig){let D=await wX4(J.mcpConfig);Y=NX4(Y,D)}let U=pp.dirname(Y.getSettingsFilePath());h84(eP,U);let V=await Y.get("url","global");if(!V)V=N7;if(P.info("Resolved Amp URL",{ampURL:V,settingsFile:Y.getSettingsFilePath(),workspaceRoot:Y.getWorkspaceRootPath()}),!xG(V))P.info("Targeting custom Amp server",{ampURL:V});return Y=tI1(Y),{executeMode:Z,isTTY:Q,ampURL:V,settings:Y,secrets:uX4(await xy0(J,Y))}}function Ei5(J){let Z={};for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X?.startsWith("--")){let U=X.slice(2).replace(/-([a-z])/g,(D,K)=>K.toUpperCase()),V=J[Q+1];if(V&&!V.startsWith("--"))Z[U]=V,Q++}}return Z}async function Li5(){let J=Ei5(process.argv),Z=process.argv.includes("--headless")||process.argv.some((U)=>U.startsWith("--headless="));hJ4({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Z?Qi5:void 0)});let Q=process.argv.includes("--no-color"),X=process.argv.includes("--color"),Y=process.stdout.isTTY&&process.stderr.isTTY;if(Q||!X&&!Y)Z1.level=0;if(Yi5(P),P.info("Starting Amp CLI.",{version:"0.0.1772294494-g9b3cb4",buildTimestamp:"2026-02-28T16:07:19.137Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new w4(t3.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Hi5().parseAsync(process.argv)}f84().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await Li5().catch(ch)});async function Ii5(J,Z){let Q=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Q)await J.settings.set("url",process.env.AMP_URL,"global"),s6.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7324
7324
  `);else if(!xG(J.ampURL))s6.write(`Logging in to ${new URL(J.ampURL).hostname}
7325
7325
  `);let X=process.env.AMP_API_KEY;if(X)s6.write(`API key found in environment variable, storing...
7326
7326
  `),await Z.set("apiKey",X,J.ampURL),s6.write(`API key successfully stored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1772280107-g5cb360",
3
+ "version": "0.0.1772294494-g9b3cb4",
4
4
  "description": "CLI for Amp, the frontier coding agent.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {