@sourcegraph/amp 0.0.1772122503-g916e6d → 0.0.1772136472-g916e6d

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
@@ -5861,11 +5861,11 @@ ${W}`))}},error:(F)=>{if(!G)G=!0,D(Error(`Failed to spawn brew: ${F.message}`))}
5861
5861
  ${W}`;if(Y==="pnpm"&&W.includes("Unable to find the global bin directory"))H+=`
5862
5862
 
5863
5863
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
5864
- 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();oA();async function d30(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=ZX4(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 gw5="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function c30(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let X=await fetch(`${gw5}?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=ZX4(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 pw5=604800000;function JX4(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>pw5)return{ageMs:Q};return null}function ZX4(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 sy0(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?QF(Q):void 0;return{sha:X,age:Y}}catch{return null}}H1();function ty0(J,Z){let Q=new K4,X=Q.pipe(I6({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new XV().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 Dz(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 p30(),z=K==="binary"||K==="brew";Y.debug("checking",{currentVersion:J,mode:D,packageManager:K,isBinaryDistribution:z});let q=z?await c30(J):await d30(J,HE());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!==ly0()){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 Km(q.latestVersion,K);let F=await xW(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 Dz(5000),Q.next("hidden"),U.unsubscribe(),Q.complete()}}),{state:X}}oA();import{stderr as TD}from"node:process";function QX4(J){let Z=new AW().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 gy0(X.force||!1,X.verbose||!1,"0.0.1772122503-g916e6d"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new AW("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 dw5(X.targetVersion)});J.addCommand(Q)}async function dw5(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")TD.write(o0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
5864
+ 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();oA();async function d30(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=ZX4(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 gw5="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function c30(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let X=await fetch(`${gw5}?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=ZX4(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 pw5=604800000;function JX4(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>pw5)return{ageMs:Q};return null}function ZX4(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 sy0(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?QF(Q):void 0;return{sha:X,age:Y}}catch{return null}}H1();function ty0(J,Z){let Q=new K4,X=Q.pipe(I6({shouldCountRefs:!1}));return setImmediate(async()=>{let Y=new XV().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 Dz(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 p30(),z=K==="binary"||K==="brew";Y.debug("checking",{currentVersion:J,mode:D,packageManager:K,isBinaryDistribution:z});let q=z?await c30(J):await d30(J,HE());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!==ly0()){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 Km(q.latestVersion,K);let F=await xW(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 Dz(5000),Q.next("hidden"),U.unsubscribe(),Q.complete()}}),{state:X}}oA();import{stderr as TD}from"node:process";function QX4(J){let Z=new AW().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 gy0(X.force||!1,X.verbose||!1,"0.0.1772136472-g916e6d"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new AW("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 dw5(X.targetVersion)});J.addCommand(Q)}async function dw5(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")TD.write(o0.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
5865
5865
 
5866
5866
  `));try{if(!J){TD.write(o0.blue(`Checking for updates...
5867
- `));let{hasUpdate:X,latestVersion:Y}=py0()?await c30("0.0.1772122503-g916e6d"):await d30("0.0.1772122503-g916e6d",HE());if(!X){let U=sy0("0.0.1772122503-g916e6d"),V=U?.age?`released ${U.age} ago`:`built ${QF(new Date("2026-02-26T16:20:53.983Z"))} ago`;TD.write(o0.green(`✓ Amp is already up to date on version ${"0.0.1772122503-g916e6d"} (${V})
5868
- `));let D=await xW("0.0.1772122503-g916e6d");if(D.warning)TD.write(`
5867
+ `));let{hasUpdate:X,latestVersion:Y}=py0()?await c30("0.0.1772136472-g916e6d"):await d30("0.0.1772136472-g916e6d",HE());if(!X){let U=sy0("0.0.1772136472-g916e6d"),V=U?.age?`released ${U.age} ago`:`built ${QF(new Date("2026-02-26T20:13:24.890Z"))} ago`;TD.write(o0.green(`✓ Amp is already up to date on version ${"0.0.1772136472-g916e6d"} (${V})
5868
+ `));let D=await xW("0.0.1772136472-g916e6d");if(D.warning)TD.write(`
5869
5869
  `+o0.yellow(D.warning)+`
5870
5870
  `);process.exit(0)}if(!Y)TD.write(o0.yellow("[WARN] could not find latest version")),process.exit(0);J=Y}TD.write(o0.blue(`Updating to version ${J}...
5871
5871
  `)),await Km(J,void 0,(X)=>{TD.write(o0.dim(`Running: ${X}
@@ -6189,7 +6189,7 @@ To fix: Add "amp.mcpTrustedWorkspaces": ["${Z.getWorkspaceRootPath()}"] to ${X}
6189
6189
  `)}};function jN5(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 RN5(J){if(J.action==="ask")return 1;if(J.action==="reject")return 2;return 0}async function LX4(J){let Z=J.json?MN5:AN5;try{let Q=jN5(J.remainingArgs),X=await J.settings.get("permissions",J.scope)??[],Y=TG(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 yM(J.toolName,Q,Y.data,J.context,ov,J.threadId,"user");if(!U.matchedEntry)U=await yM(J.toolName,Q,kM,J.context,ov,J.threadId,"built-in");Z.outputResult(J,Q,U),J.exit(RN5(U))}catch(Q){let X={success:!1,error:Q instanceof Error?Q.message:"Unknown error"};Z.outputError(J,{},X),J.exit(1)}}function IX4(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.
6190
6190
 
6191
6191
  See ${o0.underline("https://ampcode.com/manual#permissions")} for more details`).enablePositionalOptions();PN5(Q,Z),CN5(Q,Z),TN5(Q,Z),_N5(Q,Z)}function PN5(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 EX4({builtinOnly:U.builtin??!1,settings:Y.settings,exit:process.exit.bind(process),json:U.json,stdout:process.stdout,scope:U.workspace?"workspace":"global"})})}function CN5(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 LX4({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(`
6192
- `))}function TN5(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 i30({settings:Y.settings,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,exit:process.exit.bind(process),resolveEditor:eP,scope:Q.workspace?"workspace":"global"})})}function _N5(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 BX4({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 SN5}from"node:child_process";import{platform as vN5}from"node:os";import{stderr as $C}from"node:process";u9();async function MX4(J,Z,Q){let U=(await(await vJ({configService:Z},Q)).messages.create({model:pV,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 Zu0{clientKind="terminal";clientVersion="0.0.1772122503-g916e6d";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=vN5(),Q=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";if(await new Promise((X,Y)=>{SN5(`${Q} ${JSON.stringify(J)}`,(U)=>{if(U)Y(U);else X()})}),this.showOpenedURLToast)this.showOpenedURLToast(J);else $C.write(`
6192
+ `))}function TN5(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 i30({settings:Y.settings,stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,exit:process.exit.bind(process),resolveEditor:eP,scope:Q.workspace?"workspace":"global"})})}function _N5(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 BX4({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 SN5}from"node:child_process";import{platform as vN5}from"node:os";import{stderr as $C}from"node:process";u9();async function MX4(J,Z,Q){let U=(await(await vJ({configService:Z},Q)).messages.create({model:pV,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 Zu0{clientKind="terminal";clientVersion="0.0.1772136472-g916e6d";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=vN5(),Q=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";if(await new Promise((X,Y)=>{SN5(`${Q} ${JSON.stringify(J)}`,(U)=>{if(U)Y(U);else X()})}),this.showOpenedURLToast)this.showOpenedURLToast(J);else $C.write(`
6193
6193
  Opened URL: ${J}
6194
6194
 
6195
6195
  `)}async input(J){if(this.showInputDialog)return this.showInputDialog(J);$C.write(`
@@ -6838,7 +6838,7 @@ Ctrl-X, Y, Z to unlock`;if(F){let f=z.text.replace(/`([^`]+)`/g,"$1")+`
6838
6838
  `),new T("Ctrl+O",B),new T(" for ",N),new T("help",w),new T(`
6839
6839
 
6840
6840
 
6841
- `,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:w20,height:N20}):new wx0({width:w20,height:N20,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 mm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new JB4}}class JB4 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 r0({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 gm0 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 ZB4}}class ZB4 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 r0({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 am({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 pm0 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 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 dm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new XB4(this.props.autofocus??!0)}}class XB4 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 Lh5}from"node:child_process";nM();FJ();E3();t7();Rw();IY();I$();CJ();OY();lO();c4();vu();Cv();H1();var Zw4=H4(Vz(),1);import{writeFile as sB4}from"fs/promises";import tB4 from"path";m0();I$();class cm0{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.1772122503-g916e6d"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await ys(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 CH extends p0{props;constructor(J){super();this.props=J}createState(){return new YB4}}class YB4 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 UB4 extends g0{controller=new k7;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 J3,F]})})}}class qp extends p0{props;constructor(J){super();this.props=J}createState(){return new UB4}}import{isDeepStrictEqual as lm0}from"node:util";var nb5=/[\\/_ +.#"@[({&]/,ab5=/[\\/_ +.#"@[({&]/g,ob5=/[\s-]/,VB4=/[\s-]/g;function L20(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=L20(J,Z,Q,X,z+1,U+1,V),G>q){if(z===Y)G*=1;else if(ob5.test(J.charAt(z-1))){if(G*=0.9,H=J.slice(Y,z-1).match(VB4),H&&Y>0)G*=0.999**H.length}else if(nb5.test(J.charAt(z-1))){if(G*=0.8,W=J.slice(Y,z-1).match(ab5),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=L20(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 E20(J){return J.toLowerCase().replace(VB4," ")}function DB4(J,Z){let Q=L20(J,Z,E20(J),E20(Z),0,0,{}),X=Z.trim().split(/\s+/);if(X.length>1){let Y=0,U=0;for(let D of X){let K=L20(J,D,E20(J),E20(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 VT{}class DT{}class I20{}class M20{}class KB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new zB4}}class zB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}function rb5(J,Z){if(J==="")return{matches:!0,score:1};let Q=DB4(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 qB4}}class qB4 extends g0{textController;focusNode;scrollController=new r6;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){if(this.scrollController.disableFollowMode(),this.textController=new k7(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(),q6.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)=>lm0(Z,this.widget.props.controller?.selectedItem));if(J>=0)this.selectedIndex=J}this.clampSelectedIndex(),this.syncSelection(),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!lm0(J.props.items,this.widget.props.items)){if(this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let Z=this.cachedFiltered.findIndex((Q)=>lm0(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 VT){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof DT){if(this.getFilteredItems().length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof I20){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 M20)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,...rb5(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;RC(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(),q6.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 VT],[new t1("ArrowUp"),new DT],[new t1("Tab"),new VT],[new t1("Tab",{shift:!0}),new DT],[new t1("n",{ctrl:!0}),new VT],[new t1("p",{ctrl:!0}),new DT],[new t1("Enter"),new I20],[new t1("Escape"),new M20]]),focusNode:this.focusNode,child:D}),z=new M9({actions:new Map([[VT,new n4(this.invoke)],[DT,new n4(this.invoke)],[I20,new n4(this.invoke)],[M20,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 KB4(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 E6({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 GB4(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 im0 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)=>GB4(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(GB4(Y.pubDate),Q)]})})}})}}c4();class nm0 extends p0{createState(){return new FB4}}class FB4 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 sb5=/\/threads\/(T-[^/?#\s<>]+)/i;function tb5(J){let Z=J.trim(),X=Z.match(sb5)?.[1];if(X&&q8(X))return X;let Y=Z.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(q8(Y))return Y;return null}function eb5(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 p90.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 am0(J,Z,Q){return new Q0({text:new T(`${J}${Z}`,new b({color:Q})),maxLines:1})}function $h5(J,Z,Q,X){return[am0("+",J,X.success),J3.horizontal(1),am0("~",Z,X.warning),J3.horizontal(1),am0("-",Q,X.destructive)]}function Jh5(J){return typeof J==="object"&&J!==null&&"then"in J&&typeof J.then==="function"}class A20 extends p0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}createState(){return new WB4}}class WB4 extends g0{spinner=new I3;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=eb5(z),G=Math.max(0,...q.map((O)=>O.description.timeAgo.length)),F=f0.of(J),W=new r0({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=tb5(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(!Jh5(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:R}=M,_=E?A.selectionBackground:void 0,k=E?A.selectionForeground:R.foreground,y=R.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 wg({connectorColor:R.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 t=O.isLast?m.elbow:m.tee,q0=m.getConnectorText(t);$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:R.success})):D.has(O.id)?new T("(visited) ",new b({color:R.foreground,dim:!0})):null;if(g)l.push(new Q0({text:g}));if(FO(f))l.push(new nm0),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:R.primary}))}))}else if(x)l.push(new Q0({text:new T("[handoff] ",new b({color:R.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}:R;l.push(...$h5(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 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}}var HB4=30,Zh5=30;class KT{}class zT{}class j20{}class R20{}class om0 extends p0{props;constructor(J){super();this.props=J}createState(){return new NB4}}class NB4 extends g0{highlightedIndex=0;controller=new k7;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(),q6.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;RC(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 KT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof zT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof j20){let Z=this.filteredClusters[this.highlightedIndex];if(Z)this.widget.props.onAccept(Z);return"handled"}if(J instanceof R20)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(),q6.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>=Zh5+HB4,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 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 j20],[new t1("Escape"),new R20]]),focusNode:this.focusNode,child:G}),W=new M9({actions:new Map([[KT,new n4(this.invoke)],[zT,new n4(this.invoke)],[j20,new n4(this.invoke)],[R20,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,R=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(R)y.push(new T(" (current)",new b({color:A?Y.selectionForeground:X.success})));return new BB4(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 E6({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 XL({threads:O,autofocus:!1,offsetY:2})}):null,L;if(D){let I=E?new S1({child:E}):new R0({width:HB4});L=new K1({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[N,I]})}else{let I=[new S1({child:new i1({onScroll:this.handleScroll,child:new E6({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 OB4 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 rm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new OB4}}class TH extends p0{props;constructor(J){super();this.props=J}createState(){return new EB4}}class EB4 extends g0{_spinner=new I3;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 UL extends p0{props;constructor(J){super();this.props=J}createState(){return new LB4}}class LB4 extends g0{scrollController=new r6;scrollAreaKey=new S7("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=h90(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 E6({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 IB4 extends p0{props;constructor(J){super();this.props=J}createState(){return new MB4}}class MB4 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(`
6841
+ `,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:w20,height:N20}):new wx0({width:w20,height:N20,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 mm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new JB4}}class JB4 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 r0({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 gm0 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 ZB4}}class ZB4 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 r0({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 am({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 pm0 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 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 dm0 extends p0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new XB4(this.props.autofocus??!0)}}class XB4 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 Lh5}from"node:child_process";nM();FJ();E3();t7();Rw();IY();I$();CJ();OY();lO();c4();vu();Cv();H1();var Zw4=H4(Vz(),1);import{writeFile as sB4}from"fs/promises";import tB4 from"path";m0();I$();class cm0{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.1772136472-g916e6d"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await ys(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 CH extends p0{props;constructor(J){super();this.props=J}createState(){return new YB4}}class YB4 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 UB4 extends g0{controller=new k7;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 J3,F]})})}}class qp extends p0{props;constructor(J){super();this.props=J}createState(){return new UB4}}import{isDeepStrictEqual as lm0}from"node:util";var nb5=/[\\/_ +.#"@[({&]/,ab5=/[\\/_ +.#"@[({&]/g,ob5=/[\s-]/,VB4=/[\s-]/g;function L20(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=L20(J,Z,Q,X,z+1,U+1,V),G>q){if(z===Y)G*=1;else if(ob5.test(J.charAt(z-1))){if(G*=0.9,H=J.slice(Y,z-1).match(VB4),H&&Y>0)G*=0.999**H.length}else if(nb5.test(J.charAt(z-1))){if(G*=0.8,W=J.slice(Y,z-1).match(ab5),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=L20(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 E20(J){return J.toLowerCase().replace(VB4," ")}function DB4(J,Z){let Q=L20(J,Z,E20(J),E20(Z),0,0,{}),X=Z.trim().split(/\s+/);if(X.length>1){let Y=0,U=0;for(let D of X){let K=L20(J,D,E20(J),E20(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 VT{}class DT{}class I20{}class M20{}class KB4 extends p0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new zB4}}class zB4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}function rb5(J,Z){if(J==="")return{matches:!0,score:1};let Q=DB4(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 qB4}}class qB4 extends g0{textController;focusNode;scrollController=new r6;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){if(this.scrollController.disableFollowMode(),this.textController=new k7(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(),q6.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)=>lm0(Z,this.widget.props.controller?.selectedItem));if(J>=0)this.selectedIndex=J}this.clampSelectedIndex(),this.syncSelection(),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!lm0(J.props.items,this.widget.props.items)){if(this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let Z=this.cachedFiltered.findIndex((Q)=>lm0(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 VT){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof DT){if(this.getFilteredItems().length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof I20){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 M20)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,...rb5(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;RC(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(),q6.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 VT],[new t1("ArrowUp"),new DT],[new t1("Tab"),new VT],[new t1("Tab",{shift:!0}),new DT],[new t1("n",{ctrl:!0}),new VT],[new t1("p",{ctrl:!0}),new DT],[new t1("Enter"),new I20],[new t1("Escape"),new M20]]),focusNode:this.focusNode,child:D}),z=new M9({actions:new Map([[VT,new n4(this.invoke)],[DT,new n4(this.invoke)],[I20,new n4(this.invoke)],[M20,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 KB4(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 E6({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 GB4(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 im0 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)=>GB4(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(GB4(Y.pubDate),Q)]})})}})}}c4();class nm0 extends p0{createState(){return new FB4}}class FB4 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 sb5=/\/threads\/(T-[^/?#\s<>]+)/i;function tb5(J){let Z=J.trim(),X=Z.match(sb5)?.[1];if(X&&q8(X))return X;let Y=Z.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(q8(Y))return Y;return null}function eb5(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 p90.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 am0(J,Z,Q){return new Q0({text:new T(`${J}${Z}`,new b({color:Q})),maxLines:1})}function $h5(J,Z,Q,X){return[am0("+",J,X.success),J3.horizontal(1),am0("~",Z,X.warning),J3.horizontal(1),am0("-",Q,X.destructive)]}function Jh5(J){return typeof J==="object"&&J!==null&&"then"in J&&typeof J.then==="function"}class A20 extends p0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}createState(){return new WB4}}class WB4 extends g0{spinner=new I3;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=eb5(z),G=Math.max(0,...q.map((O)=>O.description.timeAgo.length)),F=f0.of(J),W=new r0({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=tb5(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(!Jh5(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:R}=M,_=E?A.selectionBackground:void 0,k=E?A.selectionForeground:R.foreground,y=R.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 wg({connectorColor:R.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 t=O.isLast?m.elbow:m.tee,q0=m.getConnectorText(t);$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:R.success})):D.has(O.id)?new T("(visited) ",new b({color:R.foreground,dim:!0})):null;if(g)l.push(new Q0({text:g}));if(FO(f))l.push(new nm0),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:R.primary}))}))}else if(x)l.push(new Q0({text:new T("[handoff] ",new b({color:R.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}:R;l.push(...$h5(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 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}}var HB4=30,Zh5=30;class KT{}class zT{}class j20{}class R20{}class om0 extends p0{props;constructor(J){super();this.props=J}createState(){return new NB4}}class NB4 extends g0{highlightedIndex=0;controller=new k7;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(),q6.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;RC(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 KT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof zT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),q6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof j20){let Z=this.filteredClusters[this.highlightedIndex];if(Z)this.widget.props.onAccept(Z);return"handled"}if(J instanceof R20)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(),q6.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>=Zh5+HB4,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 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 j20],[new t1("Escape"),new R20]]),focusNode:this.focusNode,child:G}),W=new M9({actions:new Map([[KT,new n4(this.invoke)],[zT,new n4(this.invoke)],[j20,new n4(this.invoke)],[R20,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,R=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(R)y.push(new T(" (current)",new b({color:A?Y.selectionForeground:X.success})));return new BB4(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 E6({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 XL({threads:O,autofocus:!1,offsetY:2})}):null,L;if(D){let I=E?new S1({child:E}):new R0({width:HB4});L=new K1({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[N,I]})}else{let I=[new S1({child:new i1({onScroll:this.handleScroll,child:new E6({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 OB4 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 rm0 extends p0{props;constructor(J){super();this.props=J}createState(){return new OB4}}class TH extends p0{props;constructor(J){super();this.props=J}createState(){return new EB4}}class EB4 extends g0{_spinner=new I3;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 UL extends p0{props;constructor(J){super();this.props=J}createState(){return new LB4}}class LB4 extends g0{scrollController=new r6;scrollAreaKey=new S7("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=h90(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 E6({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 IB4 extends p0{props;constructor(J){super();this.props=J}createState(){return new MB4}}class MB4 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(`
6842
6842
 
6843
6843
  `));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(`
6844
6844
  `)),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(`
@@ -7237,7 +7237,7 @@ ${Y}`,Z);this.line=Q,this.column=X,this.codeblock=Y}}/*!
7237
7237
  `)}function lN4(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=KM1({settings:{url:U.ampURL,proxy:V},secrets:{getToken:(z,q)=>U.secrets.get(z,q)}}),K=await O6.userDisplayBalanceInfo({},{config:D});if(!K.ok){if(K.error.code==="auth-required")process.stderr.write(o0.red("Error: ")+"You must be logged in to view usage. Run `amp login` first.\n"),process.exit(1);process.stderr.write(o0.red("Error: ")+K.error.message+`
7238
7238
  `),process.exit(1)}process.stdout.write(await bg5(K.result.displayText)+`
7239
7239
  `),process.exit(0)})}var Xi5=pp.join(V$,"logs","headless.log"),yd0=pp.join(sP,"device-id.json");function Yi5(){return mK.some((J)=>J.listConfigs().length>0)}try{if(process.platform==="win32")await Promise.resolve().then(() => H4(vT(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){q7.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
7240
- `)}function Ui5(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 z7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")N7("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")N7("experimental.agentMode",Z.mode)}function wI4(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 Vi5(J){try{return await BI4(J,"utf-8")}catch{return J}}async function NI4(J,Z,Q){let X=wI4(J,Z);if(!X)return;let Y=U3(Q)?Q.features:[],U=U3(Q)?Q.user.email:void 0;if(!Y.some((D)=>D.name===MY.HARNESS_SYSTEM_PROMPT&&D.enabled)&&!OI4(U))throw new M4("You are not allowed to do this.",1);N7("systemPrompt",await Vi5(X))}function OI4(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function Di5(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 ud0(J){let X=Di5(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 M4(`Couldn't connect to the Amp server at ${J}.`,1,X)}var GI4=[{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 ${DE})`},{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:NV.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:"switch",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"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}],FI4=(J)=>("deprecated"in J)&&J.deprecated===!0,Ki5=(J)=>("hidden"in J)&&J.hidden===!0,zi5=(J)=>("default"in J),qi5=(J)=>("default"in J)?J.default:void 0,EI4=[{name:"toggle-skills-count",entryPoint:Qu0}];function Gi5(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 M4(t3.unknownCommand(Q),1,V)}}async function xd0(J){return{...J,getThreadEnvironment:sz,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new mY(J.fileSystem),generateThreadTitle:mj,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>IZ(J.configService),pluginService:J.pluginService}}var gp=q1.file(Qi5.homedir()),i$0=process.env.XDG_CONFIG_HOME?q1.file(process.env.XDG_CONFIG_HOME):V1.joinPath(gp,".config");function Fi5(J){return x84({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){u84(Z);let Q=D80(),X=Pu0();if((!Q||X||cX4())&&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(D80()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}function Wi5(){return{sync:async()=>{},uploadThread:async()=>{},discoverThreads:async()=>[],initialSyncComplete:Promise.resolve(),updateThreadMeta:async()=>{},threadSyncInfo:()=>v0.of({}),flushPendingSyncs:async()=>{},dispose:()=>{}}}async function c9(J,Z){ZM1("0.0.1772122503-g916e6d");let Q=Wk({storage:J.settings,secretStorage:J.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:gp,userConfigDir:i$0});hX4(Q);let X=await Q.getLatest();P.debug("Global configuration initialized",{settingsKeys:Object.keys(X.settings)});let{toolService:Y,dispose:U}=_84({configService:Q}),V=new Map,D=()=>V.clear(),K=new OE0(Q,J.settings.getWorkspaceRootPath()),z=Ub1({configService:Q,filesystem:n6}),q=Tk1({configService:Q,trustStore:K,skillMCPServers:z.skillMCPServers,createOAuthProvider:async(x,m,l)=>{let g=`${x}:${m}`,n=V.get(g);if(n)return P.debug("Reusing existing OAuth provider for server",{serverName:x,serverUrl:m}),n;P.debug("Creating OAuth provider for server",{serverName:x,serverUrl:m});let d=(async()=>{let $0=new YN(J.secrets),B0=await $0.getClientInfo(x,m),t=l?.scopes??B0?.scopes,q0=eZ4();P.info("OAuth headless mode check",{useHeadless:q0,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:s6.isTTY});let K0;if(q0)K0=J.executeMode?tZ4():sZ4(x);let O0=new bO0({storage:$0,serverName:x,serverUrl:m,clientId:l?.clientId??B0?.clientId,clientSecret:l?.clientSecret??B0?.clientSecret,authUrl:l?.authUrl??B0?.authUrl,tokenUrl:l?.tokenUrl??B0?.tokenUrl,scopes:t,headlessAuthHandler:K0});return P.debug("OAuth provider created",{serverName:x,serverUrl:m,hasManualClientId:!!(l?.clientId??B0?.clientId),willUseDCR:!(l?.clientId??B0?.clientId),scopes:t,headlessMode:q0,executeMode:J.executeMode}),O0})();return V.set(g,d),d}}),G=OS0({configService:Q,filesystem:n6,spawn:e60}),F;if(J.executeMode){let x=await n64({toolService:Y,providers:[q,G],initialTimeout:15000});F=x.registrations;for(let[m,l]of x.initErrors)P.warn(`${m} provider initialization slow or failed:`,l)}else F=LS0({toolService:Y,providers:[q,G]});if(Z.jetbrains)xw("JetBrains");else if(Z.ide&&uQ4())xw("VS Code");else if(Z.ide&&xQ4())xw("Neovim");else if(Z.ide&&Yi5()){let x=mK.find((m)=>m.listConfigs().length>0);if(x){let m=jo(x.ideName);if(m)xw(m)}}if(J.executeMode)QM1(!0);let W,H=_8.status.pipe(B1((x)=>Boolean(x.connected&&x.authenticated&&x.ideName&&OM1(x.ideName))),I4()).subscribe((x)=>{if(x){if(!W)W=Y.registerTool(i64)}else W?.dispose(),W=void 0}),B;if(!J.executeMode){let x=await J.settings.get("fuzzy.alwaysIncludePaths")??[];B=new R30(process.cwd(),{alwaysIncludePaths:x},!0)}else B=new class extends R30{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};{let x=await J.secrets.get("apiKey",J.ampURL);if(P.info("API key lookup before login",{found:Boolean(x),ampURL:J.ampURL}),!x){s6.write(`No API key found. Starting login flow...
7240
+ `)}function Ui5(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 z7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")N7("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")N7("experimental.agentMode",Z.mode)}function wI4(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 Vi5(J){try{return await BI4(J,"utf-8")}catch{return J}}async function NI4(J,Z,Q){let X=wI4(J,Z);if(!X)return;let Y=U3(Q)?Q.features:[],U=U3(Q)?Q.user.email:void 0;if(!Y.some((D)=>D.name===MY.HARNESS_SYSTEM_PROMPT&&D.enabled)&&!OI4(U))throw new M4("You are not allowed to do this.",1);N7("systemPrompt",await Vi5(X))}function OI4(J){return!!(J&&(J.endsWith("@sourcegraph.com")||J.endsWith("@ampcode.com")||J==="auth-bypass-user@example.com"))}function Di5(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 ud0(J){let X=Di5(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 M4(`Couldn't connect to the Amp server at ${J}.`,1,X)}var GI4=[{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 ${DE})`},{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:NV.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:"switch",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"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}],FI4=(J)=>("deprecated"in J)&&J.deprecated===!0,Ki5=(J)=>("hidden"in J)&&J.hidden===!0,zi5=(J)=>("default"in J),qi5=(J)=>("default"in J)?J.default:void 0,EI4=[{name:"toggle-skills-count",entryPoint:Qu0}];function Gi5(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 M4(t3.unknownCommand(Q),1,V)}}async function xd0(J){return{...J,getThreadEnvironment:sz,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new mY(J.fileSystem),generateThreadTitle:mj,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>IZ(J.configService),pluginService:J.pluginService}}var gp=q1.file(Qi5.homedir()),i$0=process.env.XDG_CONFIG_HOME?q1.file(process.env.XDG_CONFIG_HOME):V1.joinPath(gp,".config");function Fi5(J){return x84({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){u84(Z);let Q=D80(),X=Pu0();if((!Q||X||cX4())&&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(D80()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}function Wi5(){return{sync:async()=>{},uploadThread:async()=>{},discoverThreads:async()=>[],initialSyncComplete:Promise.resolve(),updateThreadMeta:async()=>{},threadSyncInfo:()=>v0.of({}),flushPendingSyncs:async()=>{},dispose:()=>{}}}async function c9(J,Z){ZM1("0.0.1772136472-g916e6d");let Q=Wk({storage:J.settings,secretStorage:J.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:gp,userConfigDir:i$0});hX4(Q);let X=await Q.getLatest();P.debug("Global configuration initialized",{settingsKeys:Object.keys(X.settings)});let{toolService:Y,dispose:U}=_84({configService:Q}),V=new Map,D=()=>V.clear(),K=new OE0(Q,J.settings.getWorkspaceRootPath()),z=Ub1({configService:Q,filesystem:n6}),q=Tk1({configService:Q,trustStore:K,skillMCPServers:z.skillMCPServers,createOAuthProvider:async(x,m,l)=>{let g=`${x}:${m}`,n=V.get(g);if(n)return P.debug("Reusing existing OAuth provider for server",{serverName:x,serverUrl:m}),n;P.debug("Creating OAuth provider for server",{serverName:x,serverUrl:m});let d=(async()=>{let $0=new YN(J.secrets),B0=await $0.getClientInfo(x,m),t=l?.scopes??B0?.scopes,q0=eZ4();P.info("OAuth headless mode check",{useHeadless:q0,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:s6.isTTY});let K0;if(q0)K0=J.executeMode?tZ4():sZ4(x);let O0=new bO0({storage:$0,serverName:x,serverUrl:m,clientId:l?.clientId??B0?.clientId,clientSecret:l?.clientSecret??B0?.clientSecret,authUrl:l?.authUrl??B0?.authUrl,tokenUrl:l?.tokenUrl??B0?.tokenUrl,scopes:t,headlessAuthHandler:K0});return P.debug("OAuth provider created",{serverName:x,serverUrl:m,hasManualClientId:!!(l?.clientId??B0?.clientId),willUseDCR:!(l?.clientId??B0?.clientId),scopes:t,headlessMode:q0,executeMode:J.executeMode}),O0})();return V.set(g,d),d}}),G=OS0({configService:Q,filesystem:n6,spawn:e60}),F;if(J.executeMode){let x=await n64({toolService:Y,providers:[q,G],initialTimeout:15000});F=x.registrations;for(let[m,l]of x.initErrors)P.warn(`${m} provider initialization slow or failed:`,l)}else F=LS0({toolService:Y,providers:[q,G]});if(Z.jetbrains)xw("JetBrains");else if(Z.ide&&uQ4())xw("VS Code");else if(Z.ide&&xQ4())xw("Neovim");else if(Z.ide&&Yi5()){let x=mK.find((m)=>m.listConfigs().length>0);if(x){let m=jo(x.ideName);if(m)xw(m)}}if(J.executeMode)QM1(!0);let W,H=_8.status.pipe(B1((x)=>Boolean(x.connected&&x.authenticated&&x.ideName&&OM1(x.ideName))),I4()).subscribe((x)=>{if(x){if(!W)W=Y.registerTool(i64)}else W?.dispose(),W=void 0}),B;if(!J.executeMode){let x=await J.settings.get("fuzzy.alwaysIncludePaths")??[];B=new R30(process.cwd(),{alwaysIncludePaths:x},!0)}else B=new class extends R30{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};{let x=await J.secrets.get("apiKey",J.ampURL);if(P.info("API key lookup before login",{found:Boolean(x),ampURL:J.ampURL}),!x){s6.write(`No API key found. Starting login flow...
7241
7241
  `);let m=await Hi5(J),l=await J.secrets.get("apiKey",J.ampURL);if(P.info("Login flow completed",{success:m,storedKeyPresent:Boolean(l),ampURL:J.ampURL}),!m)await ez(),process.exit(1)}}{let x=await Q.getLatest(),m=x.settings.url,l=x.secrets.isSet?.[m];P.info("Config secrets state after login",{configURL:m,apiKeySet:l?.apiKey??!1})}let w=_1(IZ(Q).pipe(d5((x)=>x!=="pending"))),N=await Gb1({isDevelopment:!1}),O=await w;P.info("Server status resolved",{status:"ready",isAuthenticated:U3(O),isError:aA(O),errorMessage:aA(O)?O.error.message:void 0});let E=new _M0(N,Q),L=new MI0(N,{lazy:!0});P.info("Starting Amp background services");let I=Boolean(Z.dtw||Z.headless);if(I)P.info("DTW mode enabled: thread sync service disabled");let M=I?Wi5():gh1({threadService:E,threadHistoryService:L,configService:Q,isExtensionDevelopment:!1}),A;_8.status.subscribe((x)=>{A=x});let R=new xH0({workspaceRoots:[q1.file(process.cwd())],fileSystem:Z.jetbrains||Z.ide?ms:n6,getCurrentFile:()=>{if(!A?.openFile)return;try{return q1.parse(A.openFile)}catch(x){P.warn("Failed to parse current file URI",{uri:A.openFile,error:x});return}},getOpenFiles:()=>{if(!A?.visibleFiles?.length)return[];let x=A.openFile;return A.visibleFiles.filter((m)=>m!==x).map((m)=>{try{return q1.parse(m)}catch(l){return P.warn("Failed to parse visible file URI",{uri:m,error:l}),null}}).filter((m)=>m!==null)}}),_=new _u0,k=process.env.PLUGINS??"off",y=new Zu0({configService:Q}),h=zI0({configService:Q,fileSystem:Z.jetbrains||Z.ide?ms:n6,platform:y,internalPlugins:EI4,pluginFilter:k}),f=Pf1({pluginService:h,toolService:Y}),S={codebaseContextService:R,configService:Q,toolService:Y,mcpService:q,skillService:z,toolboxService:G,trustStore:K,threadService:E,threadHistoryService:L,threadSyncService:M,threadStorage:N,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:B,fileSystem:Z.jetbrains||Z.ide?ms:n6,terminal:_,pluginService:h,pluginPlatform:y,serverStatus:O};return{...S,async asyncDispose(){if(S.mcpService.hasAuthenticatingClients())P.info("Waiting for OAuth authentication to complete before exit..."),await S.mcpService.waitForAuthentication();for(let x of F.values())x.dispose();await S.mcpService.dispose(),D(),await S.threadService.asyncDispose(),S.configService.unsubscribe(),U(),S.fuzzyServer.dispose(),S.threadSyncService.dispose(),S.settingsStorage[Symbol.dispose](),H.unsubscribe(),W?.dispose(),f.dispose(),S.pluginService.dispose()}}}async function Hi5(J){if(!J.executeMode){if(!await $u0("Would you like to log in to Amp? [(y)es, (n)o]: "))return s6.write(`Login cancelled. Run the command again to retry.
7242
7242
  `),!1}return await LI4(J)}async function LI4(J){let Z=$i5(32).toString("hex"),Q=await ey0(J.ampURL,Z),X=new AbortController;try{await LV(Q,X.signal)}catch(U){P.error("Error opening browser",{error:U})}let Y=await ey0(J.ampURL,Z,!1);s6.write(`If your browser does not open automatically, visit:
7243
7243
 
@@ -7245,7 +7245,7 @@ ${o0.blue.bold(Y)}
7245
7245
 
7246
7246
  `);try{return await YX4(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}),q7.write(`
7247
7247
  Login failed: ${U instanceof Error?U.message:String(U)}
7248
- `),!1}}function Bi5(){let J=new AW().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((W)=>{if(W.code==="commander.help"||W.code==="commander.version"||W.exitCode===0)zE(),process.exit(0);let H=W.originalError??W;B30(H)}),J.option("-V, --version","Print the version number and exit",()=>{let H;try{H=`, ${QF(new Date("2026-02-26T16:20:53.983Z"))} ago`}catch{}s6.write(`0.0.1772122503-g916e6d (released 2026-02-26T16:20:53.983Z${H??""})
7248
+ `),!1}}function Bi5(){let J=new AW().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((W)=>{if(W.code==="commander.help"||W.code==="commander.version"||W.exitCode===0)zE(),process.exit(0);let H=W.originalError??W;B30(H)}),J.option("-V, --version","Print the version number and exit",()=>{let H;try{H=`, ${QF(new Date("2026-02-26T20:13:24.890Z"))} ago`}catch{}s6.write(`0.0.1772136472-g916e6d (released 2026-02-26T20:13:24.890Z${H??""})
7249
7249
  `),process.exit(0)}),J.addHelpText("after",vQ4()),J.configureHelp({formatHelp:kQ4}),J.command("logout").description("Log out by removing stored API key").action(async(W,H)=>{let B=H.optsWithGlobals(),w=await q3(B);await Ai5(w)}),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(W,H)=>{let B=H.optsWithGlobals(),w=await q3(B);await Mi5(w,await yy0(B,w.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(W,H,B)=>{let w=B.optsWithGlobals(),N=await q3(w);await xZ4(W??"get",N.ampURL,N.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(W,H)=>{let B=H.optsWithGlobals(),w=await q3(B);await fZ4(w.ampURL,w.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",`
7250
7250
  Actions:
7251
7251
  add-message <message> Send a user message and wait for message_added
@@ -7289,7 +7289,7 @@ See: https://ampcode.com/news/stick-a-fork-in-it
7289
7289
  amp threads handoff T-xxx --goal "Continue working on the auth feature"
7290
7290
  amp threads handoff --goal "Fix the remaining tests" # Uses last thread
7291
7291
 
7292
- 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(W,H,B)=>{let w=B.optsWithGlobals(),N=await q3(w);await Si5(w,N,W??null,H.goal,!H.print,B)}),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(W,H,B)=>{let w=B.optsWithGlobals(),N=await q3(w);await Ci5(w,N,W,B)}),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(W,H,B)=>{let w=B.optsWithGlobals(),N=await q3(w);await Ti5(w,N,W,B)}),I94(Q,q3,z7,c9,fd0,nH,G3),hY4(J,async(W,H)=>{let B=await q3(H);z7(W,H);let w=await c9(B,H);return{context:B,mcpService:w.mcpService,toolService:w.toolService,toolServices:w.toolService,skillService:w.skillService,threadService:w.threadService,fileSystem:w.fileSystem,getThreadEnvironment:sz,serverStatus:w.serverStatus,toolboxService:w.toolboxService,configService:w.configService,cleanupTerminal:zE,asyncDispose:w.asyncDispose.bind(w)}}),jX4(J,async(W)=>{let H=W.optsWithGlobals(),B=await q3(H);z7(W,H);let w=Wk({storage:B.settings,secretStorage:B.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:B.ampURL,homeDir:gp,userConfigDir:i$0});return{pluginService:zI0({configService:w,fileSystem:n6,platform:{clientKind:"terminal",clientVersion:"0.0.1772122503-g916e6d",async notify(E){P.debug("plugin notification (TUI not loaded): %s",E)},async open(E){q7.write(`
7292
+ 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(W,H,B)=>{let w=B.optsWithGlobals(),N=await q3(w);await Si5(w,N,W??null,H.goal,!H.print,B)}),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(W,H,B)=>{let w=B.optsWithGlobals(),N=await q3(w);await Ci5(w,N,W,B)}),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(W,H,B)=>{let w=B.optsWithGlobals(),N=await q3(w);await Ti5(w,N,W,B)}),I94(Q,q3,z7,c9,fd0,nH,G3),hY4(J,async(W,H)=>{let B=await q3(H);z7(W,H);let w=await c9(B,H);return{context:B,mcpService:w.mcpService,toolService:w.toolService,toolServices:w.toolService,skillService:w.skillService,threadService:w.threadService,fileSystem:w.fileSystem,getThreadEnvironment:sz,serverStatus:w.serverStatus,toolboxService:w.toolboxService,configService:w.configService,cleanupTerminal:zE,asyncDispose:w.asyncDispose.bind(w)}}),jX4(J,async(W)=>{let H=W.optsWithGlobals(),B=await q3(H);z7(W,H);let w=Wk({storage:B.settings,secretStorage:B.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:B.ampURL,homeDir:gp,userConfigDir:i$0});return{pluginService:zI0({configService:w,fileSystem:n6,platform:{clientKind:"terminal",clientVersion:"0.0.1772136472-g916e6d",async notify(E){P.debug("plugin notification (TUI not loaded): %s",E)},async open(E){q7.write(`
7293
7293
  ${E}
7294
7294
 
7295
7295
  `)},async input(){return},async confirm(){return!1},async ask(){return{result:"uncertain",probability:0.5,reason:"AI not available"}}},internalPlugins:EI4,emitSessionStart:!1,pluginFilter:process.env.PLUGINS??"off"}),asyncDispose:async()=>{}}}),xX4(J,async(W,H)=>{let B=await q3(H);return z7(W,H),{configService:Wk({storage:B.settings,secretStorage:B.secrets,workspaceRoots:v0.of([q1.file(process.cwd())]),defaultAmpURL:B.ampURL,homeDir:gp,userConfigDir:i$0}),asyncDispose:async()=>{}}}),TX4(J,async(W)=>{let H=W.optsWithGlobals(),B=await q3(H);z7(W,H);let w=await c9(B,H);return{toolService:w.toolService,mcpService:w.mcpService,configService:w.configService,skillService:w.skillService,cleanupTerminal:zE,asyncDispose:w.asyncDispose.bind(w)}}),yX4(J,async(W)=>{let H=W.optsWithGlobals(),B=await q3(H);z7(W,H);let w=await c9(B,H);return{settings:B.settings,configService:w.configService,skillService:w.skillService,asyncDispose:w.asyncDispose.bind(w)}}),IX4(J,async(W)=>{let H=W.optsWithGlobals();return await q3(H)}),qX4(J,async(W)=>{let H=await q3(W);return{settings:H.settings,secretStorage:H.secrets,getThreadDeps:async(B)=>{z7(B,W);let w=await c9(H,W);return{mcpService:w.mcpService,settings:H.settings,asyncDispose:w.asyncDispose.bind(w)}}}}),lN4(J,q3);function U(W,H,B){let N=typeof W.description==="string"?W.description:B===void 0?W.description(!0):W.description(B),O=new LD(H,N),E=qi5(W);if(E)O.default(E);if(O.hidden=Ki5(W)||FI4(W),"choices"in W)O.choices([...W.choices]);return O}for(let W of GI4){switch(W.type){case"flag":{J.addOption(U(W,`--${W.long}`)),J.addOption(U(W,`--no-${W.long}`,!1));break}case"switch":{J.addOption(U(W,`--${W.long}`,!0));break}case"optional-option":{J.addOption(U(W,`${"short"in W?`-${W.short}, `:""}--${W.long} [value]`));break}default:{J.addOption(U(W,`${"short"in W?`-${W.short}, `:""}--${W.long} <value>`));break}}if("aliases"in W&&W.aliases)for(let H of W.aliases){let B=new LD(`--${H}`,W.description);B.hidden=!0,B.implies({[W.name]:!0}),J.addOption(B)}}let V=new LD("-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 LD("--stream-json","When used with --execute, output in Claude Code-compatible stream JSON format instead of plain text.").default(!1);J.addOption(D);let K=new LD("--stream-json-thinking","Include thinking blocks in stream JSON output (non-Claude Code extension). Implies --stream-json.").default(!1);J.addOption(K);let z=new LD("--stream-json-input","Read JSON Lines user messages from stdin. Requires both --execute and --stream-json.").default(!1);J.addOption(z);let q=new LD("--stats","When used with --execute, output JSON with both result and token usage data (for /evals).").default(!1).hideHelp(!0);J.addOption(q);let G=new LD("--archive","When used with --execute, archive the thread after the command finishes.").default(!1);J.addOption(G);let F=new LD("-l, --label <label>","When used with --execute, add a label to the thread. Can be used multiple times.").argParser((W,H)=>{if(H===void 0)return[W];return[...H,W]});return J.addOption(F),J.action(async(W,H)=>{let B=W,w=await q3(B);if(Object.keys(B).forEach((N)=>{let O=GI4.find((E)=>E.name===N);if(O&&FI4(O)&&!zi5(O))q7.write(o0.yellow(`Warning: '--${N}' flag is deprecated
@@ -7297,8 +7297,8 @@ ${E}
7297
7297
 
7298
7298
  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 wi5(J,{nonBlockingOwnershipCheck:Z=!1,onOwnershipError:Q}={},X){if(!q8(J))throw new M4(t3.invalidThreadId);let Y=Date.now();if(P.info(`[fetchAndStartThread] Begin switch to thread ${J}`),Z)WI4(J,X.configService).catch((z)=>{if(z instanceof M4){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 WI4(J,X.configService)}catch(z){if(z instanceof M4)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 Yp0(X.workerDeps,{threadMeta:X.visibility?_D(X.visibility):void 0,agentMode:V?void 0:X.agentMode,thread:V,onFirstAssistantMessage:II4});return P.info(`[fetchAndStartThread] Started worker in ${Date.now()-D}ms (total ${Date.now()-Y}ms)`),K}async function Ni5(J){if(!J.userEmail||!LY(J.userEmail))throw new M4("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 kW.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 nW.create({provider:Q,deps:{threadService:J.threadService,configService:J.configService,toolService:J.toolService,skillService:J.skillService,getThreadEnvironment:sz,fileChangeTrackerStorage:new mY(J.fileSystem),osFileSystem:J.fileSystem,deleteThread:(X)=>J.threadService.delete(X),generateThreadTitle:mj,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 Oi5(J){if(J.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof J.execute==="string"){let Z=(await Gm()).trimEnd();return{userInput:J.execute,stdinInput:Z||null}}return{userInput:(await Gm()).trimEnd(),stdinInput:null}}function Ei5(J,Z,Q){if(J.streamJson&&!Z)throw new M4("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(J.streamJsonInput&&!Z)throw new M4("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(J.streamJsonInput&&!J.streamJson)throw new M4("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(J.stats&&!Z)throw new M4("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(J.archive&&!Z)throw new M4("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 M4("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 M4("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"
7299
7299
  Or pipe via stdin: echo "your message" | amp --execute`)}async function n$0(J,Z,Q){let{userInput:X,stdinInput:Y}=await Oi5(Z),U=!!Z.streamJson||!!Z.streamJsonThinking;Ei5({...Z,streamJson:U},J.executeMode,X),z7(Q,Z);let V=await c9(J,Z),D=await xd0(V),{serverStatus:K}=V;if(aA(K)){let f=dh(Error(K.error.message));if(f.message===t3.networkOffline||f.message===t3.networkTimeout)throw ud0(J.ampURL);throw new M4(t3.invalidAPIKey,1)}let z=U3(K)?K.user.email:void 0,q=U3(K)?K.features:[],G=U3(K)?K.workspace:null,F=OI4(z);await NI4(Q,Z,K);let W=U3(K)?{...K.user,features:q,team:G??void 0}:null,H=l30(Z,W);if(H instanceof Error)G3(H.message);if((J.executeMode||U)&&P8(Z.mode)&&!F)throw new M4(`Execute mode is not permitted with --mode '${Z.mode}'`,1);if(Z.headless){if(!z||!LY(z))throw new M4("Headless DTW mode is only available for Amp employees",1);let f=await V.secretStorage.get("apiKey",J.ampURL);if(!f)throw new M4("API key required for headless mode. Please run `amp login` first.",1);let S=typeof Z.headless==="string"&&Z.headless!=="true"?Z.headless:void 0;if(S&&!q8(S))throw new M4(`Invalid thread ID: ${S}`,1);let x=S??await vi5({dependencies:V,visibility:H??void 0}),m=await QQ4(x);if(m.status==="already-running")await V.asyncDispose(),await ez(),process.exit(0);try{await rZ4({ampURL:J.ampURL,apiKey:f,workerUrl:process.env.AMP_WORKER_URL,workspaceRoot:process.cwd(),threadId:x,configService:V.configService,mcpService:V.mcpService,toolService:V.toolService,skillService:V.skillService,fileSystem:V.fileSystem})}finally{await m.release(),await V.asyncDispose()}await ez(),process.exit(0)}let B={threadService:V.threadService,workerDeps:D,createThread:async()=>{let f=await G30(J.settings,process.cwd(),W,H);if(f instanceof Error)G3(f.message);return Yp0(D,{threadMeta:f?_D(f):void 0,agentMode:Z.mode,onFirstAssistantMessage:II4})},switchToThread:(f,S)=>wi5(f,{nonBlockingOwnershipCheck:S?.nonBlockingOwnershipCheck??!1,onOwnershipError:S?.onOwnershipError},{configService:V.configService,threadService:V.threadService,workerDeps:D,visibility:H,agentMode:Z.mode})},w=async()=>{try{if(Z.dtw)return Ni5({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 fN4(B,Z.threadId,{nonBlockingOwnershipCheck:Z.nonBlockingThreadOwnershipCheck})}catch(f){if(f instanceof M4)throw f;throw await ch(f,Z.threadId),Error("handleError should have called process.exit()")}};if(Z.format==="jsonl")q7.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
7300
- `),await ez(),process.exit(1);let N=(async()=>{try{let f=await V.configService.getLatest(),S=ua(f),x=await O6.getUserFreeTierStatus({},{config:V.configService,signal:AbortSignal.timeout(S)});if(x.ok)return P.info("User free tier status:",x),x.result}catch(f){throw P.error("Failed to fetch free tier status:",f),f}})(),O=await w(),E=Z.notifications!==void 0?Z.notifications:!J.executeMode,L=await V.configService.getLatest();if(Fi5({configService:V.configService,threadService:V.threadService,config:L,useNotificationsForService:E,threadViewStates$:()=>O.threadViewStates$}),J.executeMode){if(HX4(V.mcpService,J.settings),!(O instanceof HT))throw new M4("Execute mode is not supported in DTW runtime",1);let f=O.getWorkerForExecuteMode();if(await LZ4({worker:f,threadID:f.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 O6.archiveThread({thread:f.threadID,archived:!0},{config:V.configService});await V.asyncDispose(),process.exit(0)}let I=!1,M=!1,A=!1;if(Z.jetbrains||Z.ide){await AM1();let f=gw({jetbrainsOnly:Z.jetbrains});if(f.length===0){if(Z.jetbrains)M=!await V.configService.get("jetbrains.skipInstall")}else if(f.length===1){let S=f[0];if(S)_8.selectConfig(S)}else A=!0}let R=ty0("0.0.1772122503-g916e6d",V.settingsStorage),_=new II0(V.threadStorage),k=new Ju0(V.mcpService,J.settings.getWorkspaceRootPath());if(X)await O.sendMessage({content:[{type:"text",text:X}]});let y=await SD();P.info("Loaded session state:",y);let h={...y,launchCount:y.launchCount+1};vD(h);try{await vN4({codebaseContextService:V.codebaseContextService,stdout:process.stdout,history:new Oy0,fuzzyServer:V.fuzzyServer,settingsStorage:V.settingsStorage,threadService:V.threadService,threadHistoryService:V.threadHistoryService,threadFuzzyIndexer:_,skillService:V.skillService,configService:V.configService,internalAPIClient:O6,ampURL:J.ampURL,runtime:O,ideClient:_8,mcpService:V.mcpService,toolboxService:V.toolboxService,mcpTrustHandler:k,showJetBrainsInstaller:M,showIdePicker:I,showIdePickerHint:A,openThreadSwitcher:Z.openThreadSwitcher,updateService:R,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Z.clientId,sessionState:h,freeTierStatusPromise:N,workspace:G??null,features:q,isDogfooding:F,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-02-26T16:20:53.983Z",pluginPlatform:V.pluginPlatform,pluginService:V.pluginService})}finally{await O.dispose?.()}await V.asyncDispose(),process.exit(0)}async function q3(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)q7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7301
- `);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 uk1({get:async(D)=>{if(D!==my)return;try{let K=await BI4(yd0,"utf-8");return JSON.parse(K).installationID}catch{return}},set:async(D,K)=>{if(D!==my)return;await Ji5(pp.dirname(yd0),{recursive:!0}),await Zi5(yd0,JSON.stringify({installationID:K},null,2),{mode:384})}},{clientType:"cli",platform:dQ()});XM1(X);let Y=await BQ4({...J,workspaceTrust:{current:!0,changes:_v},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 FX4(J.mcpConfig);Y=WX4(Y,D)}let U=pp.dirname(Y.getSettingsFilePath());y84(sP,U);let V=await Y.get("url","global");if(!V)V=O7;if(P.info("Resolved Amp URL",{ampURL:V,settingsFile:Y.getSettingsFilePath(),workspaceRoot:Y.getWorkspaceRootPath()}),!yG(V))P.info("Targeting custom Amp server",{ampURL:V});return Y=nI1(Y),{executeMode:Z,isTTY:Q,ampURL:V,settings:Y,secrets:_X4(await yy0(J,Y))}}function Li5(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 Ii5(){let J=Li5(process.argv),Z=process.argv.includes("--headless")||process.argv.some((U)=>U.startsWith("--headless="));yJ4({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Z?Xi5: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)o0.level=0;if(Ui5(P),P.info("Starting Amp CLI.",{version:"0.0.1772122503-g916e6d",buildTimestamp:"2026-02-26T16:20:53.983Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new M4(t3.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Bi5().parseAsync(process.argv)}v84().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await Ii5().catch(ch)});async function Mi5(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}
7300
+ `),await ez(),process.exit(1);let N=(async()=>{try{let f=await V.configService.getLatest(),S=ua(f),x=await O6.getUserFreeTierStatus({},{config:V.configService,signal:AbortSignal.timeout(S)});if(x.ok)return P.info("User free tier status:",x),x.result}catch(f){throw P.error("Failed to fetch free tier status:",f),f}})(),O=await w(),E=Z.notifications!==void 0?Z.notifications:!J.executeMode,L=await V.configService.getLatest();if(Fi5({configService:V.configService,threadService:V.threadService,config:L,useNotificationsForService:E,threadViewStates$:()=>O.threadViewStates$}),J.executeMode){if(HX4(V.mcpService,J.settings),!(O instanceof HT))throw new M4("Execute mode is not supported in DTW runtime",1);let f=O.getWorkerForExecuteMode();if(await LZ4({worker:f,threadID:f.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 O6.archiveThread({thread:f.threadID,archived:!0},{config:V.configService});await V.asyncDispose(),process.exit(0)}let I=!1,M=!1,A=!1;if(Z.jetbrains||Z.ide){await AM1();let f=gw({jetbrainsOnly:Z.jetbrains});if(f.length===0){if(Z.jetbrains)M=!await V.configService.get("jetbrains.skipInstall")}else if(f.length===1){let S=f[0];if(S)_8.selectConfig(S)}else A=!0}let R=ty0("0.0.1772136472-g916e6d",V.settingsStorage),_=new II0(V.threadStorage),k=new Ju0(V.mcpService,J.settings.getWorkspaceRootPath());if(X)await O.sendMessage({content:[{type:"text",text:X}]});let y=await SD();P.info("Loaded session state:",y);let h={...y,launchCount:y.launchCount+1};vD(h);try{await vN4({codebaseContextService:V.codebaseContextService,stdout:process.stdout,history:new Oy0,fuzzyServer:V.fuzzyServer,settingsStorage:V.settingsStorage,threadService:V.threadService,threadHistoryService:V.threadHistoryService,threadFuzzyIndexer:_,skillService:V.skillService,configService:V.configService,internalAPIClient:O6,ampURL:J.ampURL,runtime:O,ideClient:_8,mcpService:V.mcpService,toolboxService:V.toolboxService,mcpTrustHandler:k,showJetBrainsInstaller:M,showIdePicker:I,showIdePickerHint:A,openThreadSwitcher:Z.openThreadSwitcher,updateService:R,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Z.clientId,sessionState:h,freeTierStatusPromise:N,workspace:G??null,features:q,isDogfooding:F,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-02-26T20:13:24.890Z",pluginPlatform:V.pluginPlatform,pluginService:V.pluginService})}finally{await O.dispose?.()}await V.asyncDispose(),process.exit(0)}async function q3(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)q7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7301
+ `);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 uk1({get:async(D)=>{if(D!==my)return;try{let K=await BI4(yd0,"utf-8");return JSON.parse(K).installationID}catch{return}},set:async(D,K)=>{if(D!==my)return;await Ji5(pp.dirname(yd0),{recursive:!0}),await Zi5(yd0,JSON.stringify({installationID:K},null,2),{mode:384})}},{clientType:"cli",platform:dQ()});XM1(X);let Y=await BQ4({...J,workspaceTrust:{current:!0,changes:_v},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 FX4(J.mcpConfig);Y=WX4(Y,D)}let U=pp.dirname(Y.getSettingsFilePath());y84(sP,U);let V=await Y.get("url","global");if(!V)V=O7;if(P.info("Resolved Amp URL",{ampURL:V,settingsFile:Y.getSettingsFilePath(),workspaceRoot:Y.getWorkspaceRootPath()}),!yG(V))P.info("Targeting custom Amp server",{ampURL:V});return Y=nI1(Y),{executeMode:Z,isTTY:Q,ampURL:V,settings:Y,secrets:_X4(await yy0(J,Y))}}function Li5(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 Ii5(){let J=Li5(process.argv),Z=process.argv.includes("--headless")||process.argv.some((U)=>U.startsWith("--headless="));yJ4({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Z?Xi5: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)o0.level=0;if(Ui5(P),P.info("Starting Amp CLI.",{version:"0.0.1772136472-g916e6d",buildTimestamp:"2026-02-26T20:13:24.890Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new M4(t3.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await Bi5().parseAsync(process.argv)}v84().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await Ii5().catch(ch)});async function Mi5(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}
7302
7302
  `);else if(!yG(J.ampURL))s6.write(`Logging in to ${new URL(J.ampURL).hostname}
7303
7303
  `);let X=process.env.AMP_API_KEY;if(X)s6.write(`API key found in environment variable, storing...
7304
7304
  `),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.1772122503-g916e6d",
3
+ "version": "0.0.1772136472-g916e6d",
4
4
  "description": "CLI for Amp, the frontier coding agent.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {