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

Function P77

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

Source from the content-addressed store, hash-verified

5090- List the paths of files to be modified and what changes in each (one bullet per file)
5091- Reference existing functions to reuse, with file:line
5092- End with the single verification command
5093- **Hard limit: 40 lines.** If the plan is longer, delete prose — not file paths.`;var i1=y(()=>{NT();cl6();k8();kj();wR1();TU();rw();o1();SC();eq6();i$();lP();NX();U7();pK6();l8();di6();vx1();Pk8();Z$();vU();p0();R88();LK6();IY();ka();qM();v8();RY();Pj6();Bq();$p();fH6();V1();_8();bW6();ju();U7();ck8();vO();E8();Gf();pK6();gj();RC();i76=new Set([fq6,j0,Dj6,fj6,$j6]);za={siblingToolUseIDs:new Map,progressMessagesByToolUseID:new Map,inProgressHookCounts:new Map,resolvedHookCounts:new Map,toolResultByToolUseID:new Map,toolUseByToolUseID:new Map,normalizedMessageCount:0,resolvedToolUseIDs:new Set,erroredToolUseIDs:new Set},LB8=Object.freeze(new Set);QYY=/<(commit_analysis|context|function_analysis|pr_analysis)>.*?<\/\1>\n?/gs});function so(q){return q.startsWith(dP)||q.startsWith(`Please run /login · ${dP}`)}function y87(q){if(!q.isApiErrorMessage)return!1;let K=q.message.content;if(!Array.isArray(K))return!1;return K.some((_)=>_.type==="text"&&_.text.startsWith(Um))}function fF1(q){let K=q.match(/prompt is too long[^0-9]*(\d+)\s*tokens?\s*>\s*(\d+)/i);return{actualTokens:K?parseInt(K[1],10):void 0,limitTokens:K?parseInt(K[2],10):void 0}}function HDK(q){if(!y87(q)||!q.errorDetails)return;let{actualTokens:K,limitTokens:_}=fF1(q.errorDetails);if(K===void 0||_===void 0)return;let z=K-_;return z>0?z:void 0}function J77(){let q=`max ${_j4} pages, ${m4(Lk6)}`;return i7()?`PDF too large (${q}). Try reading the file a different way (e.g., extract text with pdftotext).`:`PDF too large (${q}). Double press esc to go back and try again, or use pdftotext to convert to text first.`}function M77(){return i7()?"PDF is password protected. Try using a CLI tool to extract or convert the PDF.":"PDF is password protected. Please double press esc to edit your message and try again."}function X77(){return i7()?"The PDF file was not valid. Try converting it to text first (e.g., pdftotext).":"The PDF file was not valid. Double press esc to go back and try again with a different file."}function CB8(){return i7()?"Image was too large. Try resizing the image or using a different approach.":"Image was too large. Double press esc to go back and try again with a smaller image."}function P77(){let q=`max ${m4(Lk6)}`;return i7()?`Request too large (${q}). Try with a smaller file.`:`Request too large (${q}). Double press esc to go back and try with a smaller file.`}function O$Y(){return i7()?"Your account does not have access to Claude. Please login again or contact your administrator.":vb8}function w$Y(){return i7()?"Your organization does not have access to Claude. Please login again or contact your administrator.":A$Y}function AZK(){return i6(process.env.CLAUDE_CODE_REMOTE)}function j$Y(q,K,_){try{let z=-1;for(let O=0;O<_.length;O++){let w=_[O];if(!w)continue;let j=w.message.content;if(Array.isArray(j)){for(let H of j)if(H.type==="tool_use"&&"id"in H&&H.id===q){z=O;break}}if(z!==-1)break}let Y=-1;for(let O=0;O<K.length;O++){let w=K[O];if(!w)continue;if(w.type==="assistant"&&"message"in w){let j=w.message.content;if(Array.isArray(j)){for(let H of j)if(H.type==="tool_use"&&"id"in H&&H.id===q){Y=O;break}}}if(Y!==-1)break}let $=[];for(let O=z+1;O<_.length;O++){let w=_[O];if(!w)continue;let j=w.message.content;if(Array.isArray(j))for(let H of j){let J=w.message.role;if(H.type==="tool_use"&&"id"in H)$.push(`${J}:tool_use:${H.id}`);else if(H.type==="tool_result"&&"tool_use_id"in H)$.push(`${J}:tool_result:${H.tool_use_id}`);else if(H.type==="text")$.push(`${J}:text`);else if(H.type==="thinking")$.push(`${J}:thinking`);else if(H.type==="image")$.push(`${J}:image`);else $.push(`${J}:${H.type}`)}else if(typeof j==="string")$.push(`${w.message.role}:string_content`)}let A=[];for(let O=Y+1;O<K.length;O++){let w=K[O];if(!w)continue;switch(w.type){case"user":case"assistant":{if("message"in w){let j=w.message.content;if(Array.isArray(j))for(let H of j){let J=w.message.role;if(H.type==="tool_use"&&"id"in H)A.push(`${J}:tool_use:${H.id}`);else if(H.type==="tool_result"&&"tool_use_id"in H)A.push(`${J}:tool_result:${H.tool_use_id}`);else if(H.type==="text")A.push(`${J}:text`);else if(H.type==="thinking")A.push(`${J}:thinking`);else if(H.type==="image")A.push(`${J}:image`);else A.push(`${J}:${H.type}`)}else if(typeof j==="string")A.push(`${w.message.role}:string_content`)}break}case"attachment":if("attachment"in w)A.push(`attachment:${w.attachment.type}`);break;case"system":if("subtype"in w)A.push(`system:${w.subtype}`);break;case"progress":if("progress"in w&&w.progress&&typeof w.progress==="object"&&"type"in w.progress)A.push(`progress:${w.progress.type??"unknown"}`);else A.push("progress:unknown");break}}d("tengu_tool_use_tool_result_mismatch_error",{toolUseId:q,normalizedSequence:$.join(", "),preNormalizedSequence:A.join(", "),normalizedMessageCount:_.length,originalMessageCount:K.length,normalizedToolUseIndex:z,originalToolUseIndex:Y})}catch(z){}}function bB8(q,K,_){if(q instanceof KB||q instanceof wf&&q.message.toLowerCase().includes("timeout"))return q_({content:kb8,error:"unknown"});if(q instanceof dk6||q instanceof wU)return q_({content:CB8()});if(q instanceof Error&&q.message.includes(Aj6))return q_({content:Aj6,error:"rate_limit"});if(q instanceof Qq&&q.status===429&&Uk6(d7())){let z=q.headers?.get?.("anthropic-ratelimit-unified-representative-claim"),Y=q.headers?.get?.("anthropic-ratelimit-unified-overage-status");if(z||Y){let w={status:"rejected",unifiedRateLimitFallbackAvailable:!1,isUsingOverage:!1},j=q.headers?.get?.("anthropic-ratelimit-unified-reset");if(j)w.resetsAt=Number(j);if(z)w.rateLimitType=z;if(Y)w.overageStatus=Y;let H=q.headers?.get?.("anthropic-ratelimit-unified-overage-reset");if(H)w.overageResetsAt=Number(H);let J=q.headers?.get?.("anthropic-ratelimit-unified-overage-disabled-reason");if(J)w.overageDisabledReason=J;let M=Sm1(w,K);if(M)return q_({content:M,error:"rate_limit"});return q_({content:$j6,error:"rate_limit"})}if(q.message.includes("Extra usage is required for long context")){let w=i7()?"enable extra usage at claude.ai/settings/usage, or use --model to switch to standard context":"run /extra-usage to enable, or /model to switch to standard context";return q_({content:`${dP}: Extra usage is required for 1M context · ${w}`,error:"rate_limit"})}let $=q.message.replace(/^429\s+/,""),O=$.match(/"message"\s*:\s*"([^"]*)"/)?.[1]||$;return q_({content:`${dP}: Request rejected (429) · ${O||"this may be a temporary capacity issue — check status.anthropic.com"}`,error:"rate_limit"})}if(q instanceof Error&&q.message.toLowerCase().includes("prompt is too long"))return q_({content:Um,error:"invalid_request",errorDetails:q.message});if(q instanceof Error&&/maximum of \d+ PDF pages/.test(q.message))return q_({content:J77(),error:"invalid_request",errorDetails:q.message});if(q instanceof Error&&q.message.includes("The PDF specified is password protected"))return q_({content:M77(),error:"invalid_request"});if(q instanceof Error&&q.message.includes("The PDF specified was not valid"))return q_({content:X77(),error:"invalid_request"});if(q instanceof Qq&&q.status===400&&q.message.includes("image exceeds")&&q.message.includes("maximum"))return q_({content:CB8(),errorDetails:q.message});if(q instanceof Qq&&q.status===400&&q.message.includes("image dimensions exceed")&&q.message.includes("many-image"))return q_({content:i7()?"An image in the conversation exceeds the dimension limit for many-image requests (2000px). Start a new session with fewer images.":"An image in the conversation exceeds the dimension limit for many-image requests (2000px). Run /compact to remove old images from context, or start a new session.",error:"invalid_request",errorDetails:q.message});if(x06&&q instanceof Qq&&q.status===400&&q.message.includes(x06)&&q.message.includes("anthropic-beta"))return q_({content:"Auto mode is unavailable for your plan",error:"invalid_request"});if(q instanceof Qq&&q.status===413)return q_({content:P77(),error:"invalid_request"});if(q instanceof Qq&&q.status===400&&q.message.includes("`tool_use` ids were found without `tool_result` blocks immediately after")){if(_?.messages&&_?.messagesForAPI){let z=q.message.match(/toolu_[a-zA-Z0-9]+/),Y=z?z[0]:null;if(Y)j$Y(Y,_.messages,_.messagesForAPI)}{let Y=i7()?"":" Run /rewind to recover the conversation.";return q_({content:"API Error: 400 due to tool use concurrency issues."+Y,error:"invalid_request"})}}if(q instanceof Qq&&q.status===400&&q.message.includes("unexpected `tool_use_id` found in `tool_result`"))d("tengu_unexpected_tool_result",{});if(q instanceof Qq&&q.status===400&&q.message.includes("`tool_use` ids must be unique")){d("tengu_duplicate_tool_use_id",{});let z=i7()?"":" Run /rewind to recover the conversation.";return q_({content:`API Error: 400 duplicate tool_use ID in conversation history.${z}`,error:"invalid_request",errorDetails:q.message})}if(d7()&&q instanceof Qq&&q.status===400&&q.message.toLowerCase().includes("invalid model name")&&(Uz6(K)||K==="opus"))return q_({content:"Claude Opus is not available with the Claude Pro plan. If you have updated your subscription plan recently, run /logout and /login for the plan to take effect.",error:"invalid_request"});if(q instanceof Error&&q.message.includes("Your credit balance is too low"))return q_({content:Vb8,error:"billing_error"});if(q instanceof Qq&&q.status===400&&q.message.toLowerCase().includes("organization has been disabled")){let{source:z}=Ow();if(z==="ANTHROPIC_API_KEY"&&process.env.ANTHROPIC_API_KEY&&!d7()){let Y=Kq()?.accessToken!=null;return q_({error:"invalid_request",content:Y?jr1:Hr1})}}if(q instanceof Error&&q.message.toLowerCase().includes("x-api-key")){if(AZK())return q_({error:"authentication_failed",content:$ZK});let{source:z}=Ow();return q_({error:"authentication_failed",content:z==="ANTHROPIC_API_KEY"||z==="apiKeyHelper"?Tb8:Nb8})}if(q instanceof Qq&&q.status===403&&q.message.includes("OAuth token has been revoked"))return q_({error:"authentication_failed",content:O$Y()});if(q instanceof Qq&&(q.status===401||q.status===403)&&q.message.includes("OAuth authentication is currently not allowed for this organization"))return q_({error:"authentication_failed",content:w$Y()});if(q instanceof Qq&&(q.status===401||q.status===403)){if(AZK())return q_({error:"authentication_failed",content:$ZK});return q_({error:"authentication_failed",content:i7()?`Failed to authenticate. ${dP}: ${q.message}`:`Please run /login · ${dP}: ${q.message}`})}if(i6(process.env.CLAUDE_CODE_USE_BEDROCK)&&q instanceof Error&&q.message.toLowerCase().includes("model id")){let z=i7()?"--model":"/model",Y=OZK(K);return q_({content:Y?`${dP} (${K}): ${q.message}. Try ${z} to switch to ${Y}.`:`${dP} (${K}): ${q.message}. Run ${z} to pick a different model.`,error:"invalid_request"})}if(q instanceof Qq&&q.status===404){let z=i7()?"--model":"/model",Y=OZK(K);return q_({content:Y?`The model ${K} is not available on your ${E7()} deployment. Try ${z} to switch to ${Y}, or ask your admin to enable this model.`:`There's an issue with the selected model (${K}). It may not exist or you may not have access to it. Run ${z} to pick a different model.`,error:"invalid_request"})}if(q instanceof wf)return q_({content:`${dP}: ${Qk6(q)}`,error:"unknown"});if(q instanceof Error)return q_({content:`${dP}: ${q.message}`,error:"unknown"});return q_({content:dP,error:"unknown"})}function OZK(q){if(E7()==="firstParty")return;let K=q.toLowerCase();if(K.includes("opus-4-6")||K.includes("opus_4_6"))return n9().opus41;if(K.includes("sonnet-4-6")||K.includes("sonnet_4_6"))return n9().sonnet45;if(K.includes("sonnet-4-5")||K.includes("sonnet_4_5"))return n9().sonnet40;return}function FWK(q){if(q instanceof Error&&q.message==="Request was aborted.")return"aborted";if(q instanceof KB||q instanceof wf&&q.message.toLowerCase().includes("timeout"))return"api_timeout";if(q instanceof Error&&q.message.includes(VI1))return"repeated_529";if(q instanceof Error&&q.message.includes(Aj6))return"capacity_off_switch";if(q instanceof Qq&&q.status===429)return"rate_limit";if(q instanceof Qq&&(q.status===529||q.message?.includes('"type":"overloaded_error"')))return"server_overload";if(q instanceof Error&&q.message.toLowerCase().includes(Um.toLowerCase()))return"prompt_too_long";if(q instanceof Error&&/maximum of \d+ PDF pages/.test(q.message))return"pdf_too_large";if(q instanceof Error&&q.message.includes("The PDF specified is password protected"))return"pdf_password_protected";if(q instanceof Qq&&q.status===400&&q.message.includes("image exceeds")&&q.message.includes("maximum"))return"image_too_large";if(q instanceof Qq&&q.status===400&&q.message.includes("image dimensions exceed")&&q.message.includes("many-image"))return"image_too_large";if(q instanceof Qq&&q.status===400&&q.message.includes("`tool_use` ids were found without `tool_result` blocks immediately after"))return"tool_use_mismatch";if(q instanceof Qq&&q.status===400&&q.message.includes("unexpected `tool_use_id` found in `tool_result`"))return"unexpected_tool_result";if(q instanceof Qq&&q.status===400&&q.message.includes("`tool_use` ids must be unique"))return"duplicate_tool_use_id";if(q instanceof Qq&&q.status===400&&q.message.toLowerCase().includes("invalid model name"))return"invalid_model";if(q instanceof Error&&q.message.toLowerCase().includes(Vb8.toLowerCase()))return"credit_balance_low";if(q instanceof Error&&q.message.toLowerCase().includes("x-api-key"))return"invalid_api_key";if(q instanceof Qq&&q.status===403&&q.message.includes("OAuth token has been revoked"))return"token_revoked";if(q instanceof Qq&&(q.status===401||q.status===403)&&q.message.includes("OAuth authentication is currently not allowed for this organization"))return"oauth_org_not_allowed";if(q instanceof Qq&&(q.status===401||q.status===403))return"auth_error";if(i6(process.env.CLAUDE_CODE_USE_BEDROCK)&&q instanceof Error&&q.message.toLowerCase().includes("model id"))return"bedrock_model_access";if(q instanceof Qq){let K=q.status;if(K>=500)return"server_error";if(K>=400)return"client_error"}if(q instanceof wf){if(o76(q)?.isSSLError)return"ssl_cert_error";return"connection_error"}return"unknown"}function wZK(q){if(q.status===529||q.message?.includes('"type":"overloaded_error"'))return"rate_limit";if(q.status===429)return"rate_limit";if(q.status===401||q.status===403)return"authentication_failed";if(q.status!==void 0&&q.status>=408)return"server_error";return"unknown"}function jZK(q,K){if(q!=="refusal")return;d("tengu_refusal_api_response",{});let _=i7()?`${dP}: Claude Code is unable to respond to this request, which appears to violate our Usage Policy (https://www.anthropic.com/legal/aup). Try rephrasing the request or attempting a different approach.`:`${dP}: Claude Code is unable to respond to this request, which appears to violate our Usage Policy (https://www.anthropic.com/legal/aup). Please double press esc to edit your last message or start a new session for Claude Code to assist with a different task.`;return q_({content:_+(K!=="claude-sonnet-4-20250514"?" If you are seeing this refusal repeatedly, try running /model claude-sonnet-4-20250514 to switch models.":""),error:"invalid_request"})}var dP="API Error",Um="Prompt is too long",Vb8="Credit balance is too low",Nb8="Not logged in · Please run /login",Tb8="Invalid API key · Fix external API key",jr1="Your ANTHROPIC_API_KEY belongs to a disabled organization · Unset the environment variable to use your subscription instead",Hr1="Your ANTHROPIC_API_KEY belongs to a disabled organization · Update or unset the environment variable",vb8="OAuth token revoked · Please run /login",$ZK="Authentication error · This may be a temporary network issue, please try again",VI1="Repeated 529 Overloaded errors",Aj6="Opus is experiencing high load, please use /model to switch to Sonnet",kb8="Request timed out",A$Y="Your account does not have access to Claude Code. Please run /login.";var SC=y(()=>{LZ();e66();G7();i1();aq();Yn();Az();v8();m8();U7();RL();ck8();k8();ZU();vr6();Pr()});function HZK(q){let{toolName:K,policySpec:_,eventName:z,querySource:Y,preCheck:$}=q,A=HP((O,w,j)=>{let H=J$Y(O,w,j,K,_,z,Y,$);return H.catch(()=>{if(A.cache.get(O)===H)A.cache.delete(O)}),H},(O)=>O,200);return A}function JZK(q,K){let _=HP((z,Y,$)=>{let A=M$Y(z,Y,$,q,K);return A.catch(()=>{if(_.cache.get(z)===A)_.cache.delete(z)}),A},(z)=>z,200);return _}async function J$Y(q,K,_,z,Y,$,A,O){if(O){let J=O(q);if(J!==null)return J}let w,j=Date.now(),H=null;try{w=setTimeout((W,D)=>{let f=`[${W}Tool] Pre-flight check is taking longer than expected. Run with ANTHROPIC_LOG=debug to check for failed or slow API requests.`;if(D)process.stderr.write(g6({level:"warn",message:f})+`
5094`);else console.warn($8.yellow(`⚠️ ${f}`))},1e4,z,_);let J=g8("tengu_cork_m4q",!1),M=await RG({systemPrompt:iK(J?[`Your task is to process ${z} commands that an AI coding agent wants to run.
5095

Callers 2

bPFunction · 0.85
bB8Function · 0.85

Calls 2

m4Function · 0.85
i7Function · 0.85

Tested by

no test coverage detected