MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / aa

Function aa

package/cli.js:5243–5243  ·  view source on GitHub ↗
(q)

Source from the content-addressed store, hash-verified

5241
5242${q}`,z=await hG({promptMessages:[U8({content:_})],cacheSafeParams:K,canUseTool:async()=>({behavior:"deny",message:"Side questions cannot use tools",decisionReason:{type:"other",reason:"side_question"}}),querySource:"side_question",forkLabel:"side_question",maxTurns:1,skipCacheWrite:!0});return{response:KOY(z.messages),usage:z.totalUsage}}function KOY(q){let K=q.flatMap((z)=>z.type==="assistant"?z.message.content:[]);if(K.length>0){let z=L3(K,`
5243
5244`).trim();if(z)return z;let Y=K.find(($)=>$.type==="tool_use");if(Y)return`(The model tried to call ${"name"in Y?Y.name:"a tool"} instead of answering directly. Try rephrasing or ask in the main conversation.)`}let _=q.find((z)=>z.type==="system"&&("subtype"in z)&&z.subtype==="api_error");if(_)return`(API error: ${Qk6(_.error)})`;return null}var qOY;var wg8=y(()=>{Pr();nv();i1();qOY=/^\/btw\b/gi});var oGK={};T8(oGK,{call:()=>wOY});function YOY(q){let K=z6(25),{question:_,context:z,onDone:Y}=q,[$,A]=j56.useState(null),[O,w]=j56.useState(null),[j,H]=j56.useState(0),J=j56.useRef(null),{rows:M}=vE8(t1()),X;if(K[0]===Symbol.for("react.memo_cache_sentinel"))X=()=>H($OY),K[0]=X;else X=K[0];eW(X,$||O?null:80);let P;if(K[1]!==Y)P=function(x){if(x.key==="escape"||x.key==="return"||x.key===" "||x.ctrl&&(x.key==="c"||x.key==="d")){x.preventDefault(),Y(void 0,{display:"skip"});return}if(x.key==="up"||x.ctrl&&x.key==="p")x.preventDefault(),J.current?.scrollBy(-rGK);if(x.key==="down"||x.ctrl&&x.key==="n")x.preventDefault(),J.current?.scrollBy(rGK)},K[1]=Y,K[2]=P;else P=K[2];let W=P,D,f;if(K[3]!==z||K[4]!==_)D=()=>{let R=P3();return async function(){try{let B=await OOY(z),p=await Og8({question:_,cacheSafeParams:B});if(!R.signal.aborted)if(p.response)A(p.response);else w("No response received")}catch(B){let p=B;if(!R.signal.aborted)w(d6(p)||"Failed to get response")}}(),()=>{R.abort()}},f=[_,z],K[3]=z,K[4]=_,K[5]=D,K[6]=f;else D=K[5],f=K[6];j56.useEffect(D,f);let G=Math.max(5,M-_OY-zOY),Z;if(K[7]===Symbol.for("react.memo_cache_sentinel"))Z=MO.createElement(k,{color:"warning",bold:!0},"/btw"," "),K[7]=Z;else Z=K[7];let T;if(K[8]!==_)T=MO.createElement(u,null,Z,MO.createElement(k,{dimColor:!0},_)),K[8]=_,K[9]=T;else T=K[9];let v;if(K[10]!==O||K[11]!==j||K[12]!==$)v=MO.createElement(xh6,{ref:J,flexDirection:"column",flexGrow:1},O?MO.createElement(k,{color:"error"},O):$?MO.createElement(AO,null,$):MO.createElement(u,null,MO.createElement(Ae6,{frame:j,messageColor:"warning"}),MO.createElement(k,{color:"warning"},"Answering..."))),K[10]=O,K[11]=j,K[12]=$,K[13]=v;else v=K[13];let V;if(K[14]!==G||K[15]!==v)V=MO.createElement(u,{marginTop:1,marginLeft:2,maxHeight:G},v),K[14]=G,K[15]=v,K[16]=V;else V=K[16];let E;if(K[17]!==O||K[18]!==$)E=($||O)&&MO.createElement(u,{marginTop:1},MO.createElement(k,{dimColor:!0},jA8,"/",Rh7," to scroll · Space, Enter, or Escape to dismiss")),K[17]=O,K[18]=$,K[19]=E;else E=K[19];let S;if(K[20]!==W||K[21]!==T||K[22]!==V||K[23]!==E)S=MO.createElement(u,{flexDirection:"column",paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:W},T,V,E),K[20]=W,K[21]=T,K[22]=V,K[23]=E,K[24]=S;else S=K[24];return S}function $OY(q){return q+1}function AOY(q){let K=q.at(-1);if(K?.type==="assistant"&&K.message.stop_reason===null)return q.slice(0,-1);return q}async function OOY(q){let K=i2(AOY(q.messages)),_=X18();if(_)return{systemPrompt:_.systemPrompt,userContext:_.userContext,systemContext:_.systemContext,toolUseContext:q,forkContextMessages:K};let[z,Y,$]=await Promise.all([QP(q.options.tools,q.options.mainLoopModel,[],q.options.mcpClients),bO(),tw()]);return{systemPrompt:iK(z),userContext:Y,systemContext:$,toolUseContext:q,forkContextMessages:K}}async function wOY(q,K,_){let z=_?.trim();if(!z)return q("Usage: /btw <your question>",{display:"system"}),null;return b8((Y)=>({...Y,btwUseCount:Y.btwUseCount+1})),MO.createElement(YOY,{question:z,context:K,onDone:q})}var MO,j56,_OY=5,zOY=6,rGK=3;var aGK=y(()=>{q8();dV();xN();EC8();zz();rL();CU();jN();t4();Ag8();s6();B2();V1();y8();nv();i1();wg8();MO=O6(D6(),1),j56=O6(D6(),1)});var jOY,Hq7;var sGK=y(()=>{jOY={type:"local-jsx",name:"btw",description:"Ask a quick side question without interrupting the main conversation",immediate:!0,argumentHint:"<question>",load:()=>Promise.resolve().then(() => (aGK(),oGK))},Hq7=jOY});var tGK;var eGK=y(()=>{tGK={isEnabled:()=>!1,isHidden:!0,name:"stub"}});var qTK;var KTK=y(()=>{qTK={isEnabled:()=>!1,isHidden:!0,name:"stub"}});import{readFile as HOY,stat as JOY}from"fs/promises";function aa(q){let K=q;return K=K.replace(/"(sk-ant[^\s"']{24,})"/g,'"[REDACTED_API_KEY]"'),K=K.replace(/(?<![A-Za-z0-9"'])(sk-ant-?[A-Za-z0-9_-]{10,})(?![A-Za-z0-9"'])/g,"[REDACTED_API_KEY]"),K=K.replace(/AWS key: "(AWS[A-Z0-9]{20,})"/g,'AWS key: "[REDACTED_AWS_KEY]"'),K=K.replace(/(AKIA[A-Z0-9]{16})/g,"[REDACTED_AWS_KEY]"),K=K.replace(/(?<![A-Za-z0-9])(AIza[A-Za-z0-9_-]{35})(?![A-Za-z0-9])/g,"[REDACTED_GCP_KEY]"),K=K.replace(/(?<![A-Za-z0-9])([a-z0-9-]+@[a-z0-9-]+\.iam\.gserviceaccount\.com)(?![A-Za-z0-9])/g,"[REDACTED_GCP_SERVICE_ACCOUNT]"),K=K.replace(/(["']?x-api-key["']?\s*[:=]\s*["']?)[^"',\s)}\]]+/gi,"$1[REDACTED_API_KEY]"),K=K.replace(/(["']?authorization["']?\s*[:=]\s*["']?(bearer\s+)?)[^"',\s)}\]]+/gi,"$1[REDACTED_TOKEN]"),K=K.replace(/(AWS[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,"$1[REDACTED_AWS_VALUE]"),K=K.replace(/(GOOGLE[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,"$1[REDACTED_GCP_VALUE]"),K=K.replace(/((API[-_]?KEY|TOKEN|SECRET|PASSWORD)\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,"$1[REDACTED]"),K}function zTK(){return A_6().map((q)=>{let K={...q};if(K&&typeof K.error==="string")K.error=aa(K.error);return K})}async function XOY(){try{let q=Y$(),{size:K}=await JOY(q);if(K>$78)return N(`Skipping raw transcript read: file too large (${K} bytes)`,{level:"warn"}),null;return await HOY(q,"utf-8")}catch{return null}}function $TK({abortSignal:q,messages:K,initialDescription:_,onDone:z,backgroundTasks:Y={}}){let[$,A]=HR.useState("userInput"),[O,w]=HR.useState(0),[j,H]=HR.useState(_??""),[J,M]=HR.useState(null),[X,P]=HR.useState(null),[W,D]=HR.useState({isGit:!1,gitState:null}),[f,G]=HR.useState(null),Z=t1().columns-4;HR.useEffect(()=>{async function V(){let E=await YJ(),S=null;if(E)S=await u41();D({isGit:E,gitState:S})}V()},[]);let T=HR.useCallback(async()=>{A("submitting"),P(null),M(null);let V=zTK(),S=uP(K)?.requestId??null,[R,x]=await Promise.all([Xq7(),XOY()]),I=Mq7(Y),B={...R,...I},p={latestAssistantMessageId:S,message_count:K.length,datetime:new Date().toISOString(),description:j,platform:a1.platform,gitRepo:W.isGit,terminal:a1.terminal,version:{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://code.claude.com/docs/en/overview",VERSION:"2.1.88",FEEDBACK_CHANNEL:"https://github.com/anthropics/claude-code/issues",BUILD_TIME:"2026-03-30T21:59:52Z"}.VERSION,transcript:bP(K),errors:V,lastApiRequest:Li8(),...Object.keys(B).length>0&&{subagentTranscripts:B},...x&&{rawTranscriptJsonl:x}},[C,g]=await Promise.all([DOY(p,q),WOY(j,q)]);if(G(g),C.success){if(C.feedbackId)M(C.feedbackId),d("tengu_bug_report_submitted",{feedback_id:C.feedbackId,last_assistant_message_id:S}),Tc6("tengu_bug_report_description",{feedback_id:C.feedbackId,description:aa(j)});A("done")}else{if(C.isZdrOrg)P("Feedback collection is not available for organizations with custom data retention policies.");else P("Could not submit feedback. Please try again later.");A("userInput")}},[j,W.isGit,K]),v=HR.useCallback(()=>{if($==="done"){if(X)z("Error submitting feedback / bug report",{display:"system"});else z("Feedback / bug report submitted",{display:"system"});return}z("Feedback / bug report cancelled",{display:"system"})},[$,X,z]);return P1("confirm:no",v,{context:"Settings",isActive:$==="userInput"}),k4((V,E)=>{if($==="done"){if(E.return&&f){let S=POY(J??"",f,j,zTK());m3(S)}if(X)z("Error submitting feedback / bug report",{display:"system"});else z("Feedback / bug report submitted",{display:"system"});return}if(X&&$!=="userInput"){z("Error submitting feedback / bug report",{display:"system"});return}if($==="consent"&&(E.return||V===" "))T()}),K4.createElement(R1,{title:"Submit Feedback / Bug Report",onCancel:v,isCancelActive:$!=="userInput",inputGuide:(V)=>V.pending?K4.createElement(k,null,"Press ",V.keyName," again to exit"):$==="userInput"?K4.createElement(I1,null,K4.createElement(t8,{shortcut:"Enter",action:"continue"}),K4.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancel"})):$==="consent"?K4.createElement(I1,null,K4.createElement(t8,{shortcut:"Enter",action:"submit"}),K4.createElement(W1,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancel"})):null},$==="userInput"&&K4.createElement(u,{flexDirection:"column",gap:1},K4.createElement(k,null,"Describe the issue below:"),K4.createElement(r3,{value:j,onChange:(V)=>{if(H(V),X)P(null)},columns:Z,onSubmit:()=>A("consent"),onExitMessage:()=>z("Feedback cancelled",{display:"system"}),cursorOffset:O,onChangeCursorOffset:w,showCursor:!0}),X&&K4.createElement(u,{flexDirection:"column",gap:1},K4.createElement(k,{color:"error"},X),K4.createElement(k,{dimColor:!0},"Edit and press Enter to retry, or Esc to cancel"))),$==="consent"&&K4.createElement(u,{flexDirection:"column"},K4.createElement(k,null,"This report will include:"),K4.createElement(u,{marginLeft:2,flexDirection:"column"},K4.createElement(k,null,"- Your feedback / bug description:"," ",K4.createElement(k,{dimColor:!0},j)),K4.createElement(k,null,"- Environment info:"," ",K4.createElement(k,{dimColor:!0},a1.platform,", ",a1.terminal,", v",{ISSUES_EXPLAINER:"report the issue at https://github.com/anthropics/claude-code/issues",PACKAGE_URL:"@anthropic-ai/claude-code",README_URL:"https://code.claude.com/docs/en/overview",VERSION:"2.1.88",FEEDBACK_CHANNEL:"https://github.com/anthropics/claude-code/issues",BUILD_TIME:"2026-03-30T21:59:52Z"}.VERSION)),W.gitState&&K4.createElement(k,null,"- Git repo metadata:"," ",K4.createElement(k,{dimColor:!0},W.gitState.branchName,W.gitState.commitHash?`, ${W.gitState.commitHash.slice(0,7)}`:"",W.gitState.remoteUrl?` @ ${W.gitState.remoteUrl}`:"",!W.gitState.isHeadOnRemote&&", not synced",!W.gitState.isClean&&", has local changes")),K4.createElement(k,null,"- Current session transcript")),K4.createElement(u,{marginTop:1},K4.createElement(k,{wrap:"wrap",dimColor:!0},"We will use your feedback to debug related issues or to improve"," ","Claude Code's functionality (eg. to reduce the risk of bugs occurring in the future).")),K4.createElement(u,{marginTop:1},K4.createElement(k,null,"Press ",K4.createElement(k,{bold:!0},"Enter")," to confirm and submit."))),$==="submitting"&&K4.createElement(u,{flexDirection:"row",gap:1},K4.createElement(k,null,"Submitting report…")),$==="done"&&K4.createElement(u,{flexDirection:"column"},X?K4.createElement(k,{color:"error"},X):K4.createElement(k,{color:"success"},"Thank you for your report!"),J&&K4.createElement(k,{dimColor:!0},"Feedback ID: ",J),K4.createElement(u,{marginTop:1},K4.createElement(k,null,"Press "),K4.createElement(k,{bold:!0},"Enter "),K4.createElement(k,null,"to open your browser and draft a GitHub issue, or any other key to close."))))}function POY(q,K,_,z){let Y=aa(K),A=`**Bug Description**
5245${aa(_)}
5246

Callers 5

zTKFunction · 0.85
$TKFunction · 0.85
POYFunction · 0.85
jg8Function · 0.85
xc8Function · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected