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

Function Gc6

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

Source from the content-addressed store, hash-verified

491 }
492 $commands -join [char]0
493 `.trim(),$=await S7("powershell.exe",["-NoProfile","-Command",Y],{timeout:3000});if($.code!==0||!$.stdout?.trim())return[];return $.stdout.split("\x00").filter(Boolean)}let _=`currentpid=${String(q)}; for i in $(seq 1 ${K}); do cmd=$(ps -o command= -p $currentpid 2>/dev/null); if [ -n "$cmd" ]; then printf '%s\\0' "$cmd"; fi; ppid=$(ps -o ppid= -p $currentpid 2>/dev/null | tr -d ' '); if [ -z "$ppid" ] || [ "$ppid" = "0" ] || [ "$ppid" = "1" ]; then break; fi; currentpid=$ppid; done`,z=await S7("sh",["-c",_],{timeout:3000});if(z.code!==0||!z.stdout?.trim())return[];return z.stdout.split("\x00").filter(Boolean)}var u$6=y(()=>{XK()});import{stat as Dj_}from"fs/promises";function Zj_(){return process.platform==="linux"&&i6(process.env.CLAUDE_CODE_BUBBLEWRAP)}function Gj_(){if(process.platform!=="linux")return!1;return VV1??!1}async function tiq(){if(m$6!==void 0)return m$6;if(process.platform==="darwin")return m$6=null,null;try{let q=await siq(process.pid,10);for(let K of q){let _=K.toLowerCase();for(let z of o41)if(_.includes(z))return m$6=z,z}}catch{}return m$6=null,null}async function Tj_(){if(process.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"){if(a1.platform!=="darwin")return await tiq()||"pycharm"}return a1.terminal}function vj_(){if(process.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"){if(a1.platform!=="darwin"){if(m$6!==void 0)return m$6||"pycharm";return"pycharm"}}return a1.terminal}async function NV1(){if(process.env.TERMINAL_EMULATOR==="JetBrains-JediTerm")await tiq()}var fj_,VV1=null,m$6,BV;var J16=y(()=>{F4();y_();m8();XK();u$6();fj_=_1(async()=>{if(process.platform!=="linux")return!1;let{code:q}=await a8("test",["-f","/.dockerenv"]);return q===0});if(process.platform==="linux"){let q=process.arch==="x64"?"x86_64":"aarch64";Dj_(`/lib/libc.musl-${q}.so.1`).then(()=>{VV1=!0},()=>{VV1=!1})}BV={...a1,terminal:vj_(),getIsDocker:fj_,getIsBubblewrapSandbox:Zj_,isMuslEnvironment:Gj_,getTerminalWithJetBrainsDetectionAsync:Tj_,initJetBrainsDetection:NV1}});function kj_(q){try{let K=new URL(q);return K.search="",K.toString().replace(/\/$/,"")}catch{return}}async function qrq(){if(process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC)return;try{let q=await $1.get("https://api.anthropic.com/mcp-registry/v0/servers?version=latest&visibility=commercial",{timeout:5000}),K=new Set;for(let _ of q.data.servers)for(let z of _.server.remotes??[]){let Y=kj_(z.url);if(Y)K.add(Y)}eiq=K,N(`[mcp-registry] Loaded ${K.size} official MCP URLs`)}catch(q){N(`Failed to fetch MCP registry: ${d6(q)}`,{level:"error"})}}function Krq(q){return eiq?.has(q)??!1}var eiq=void 0;var yV1=y(()=>{CK();_8();y8()});function Vj_(){return process.argv.includes("--agent-teams")}function nq(){if(!i6(process.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS)&&!Vj_())return!1;if(!g8("tengu_amber_flint",!0))return!1;return!0}var i$=y(()=>{o1();m8()});import{AsyncLocalStorage as Nj_}from"async_hooks";function Au(){return _rq.getStore()}function KF(q,K){return _rq.run(q,K)}function yj_(q){return q?.agentType==="subagent"}function zrq(){let q=Au();if(!yj_(q)||!q.subagentName)return;return q.isBuiltIn?q.subagentName:"user-defined"}function EV1(){let q=Au();if(!q?.invokingRequestId||q.invocationEmitted)return;return q.invocationEmitted=!0,{invokingRequestId:q.invokingRequestId,invocationKind:q.invocationKind}}var _rq;var Ou=y(()=>{i$();_rq=new Nj_});import{AsyncLocalStorage as Ej_}from"async_hooks";function VP(){return LV1.getStore()}function $f8(q,K){return LV1.run(q,K)}function cW(){return LV1.getStore()!==void 0}function Af8(q){return{...q,isInProcess:!0}}var LV1;var JG=y(()=>{LV1=new Ej_});var SV1={};T8(SV1,{waitForTeammatesToBecomeIdle:()=>hV1,setDynamicTeamContext:()=>Lj_,runWithTeammateContext:()=>$f8,isTeammate:()=>$Y,isTeamLead:()=>MG,isPlanModeRequired:()=>fc6,isInProcessTeammate:()=>cW,hasWorkingInProcessTeammates:()=>RV1,hasActiveInProcessTeammates:()=>Of8,getTeammateContext:()=>VP,getTeammateColor:()=>vj,getTeamName:()=>$9,getParentSessionId:()=>_F,getDynamicTeamContext:()=>Dc6,getAgentName:()=>M_,getAgentId:()=>NP,createTeammateContext:()=>Af8,clearDynamicTeamContext:()=>Rj_});function _F(){let q=VP();if(q)return q.parentSessionId;return zL?.parentSessionId}function Lj_(q){zL=q}function Rj_(){zL=null}function Dc6(){return zL}function NP(){let q=VP();if(q)return q.agentId;return zL?.agentId}function M_(){let q=VP();if(q)return q.agentName;return zL?.agentName}function $9(q){let K=VP();if(K)return K.teamName;if(zL?.teamName)return zL.teamName;return q?.teamName}function $Y(){if(VP())return!0;return!!(zL?.agentId&&zL?.teamName)}function vj(){let q=VP();if(q)return q.color;return zL?.color}function fc6(){let q=VP();if(q)return q.planModeRequired;if(zL!==null)return zL.planModeRequired;return i6(process.env.CLAUDE_CODE_PLAN_MODE_REQUIRED)}function MG(q){if(!q?.leadAgentId)return!1;let K=NP(),_=q.leadAgentId;if(K===_)return!0;if(!K)return!0;return!1}function Of8(q){for(let K of Object.values(q.tasks))if(K.type==="in_process_teammate"&&K.status==="running")return!0;return!1}function RV1(q){for(let K of Object.values(q.tasks))if(K.type==="in_process_teammate"&&K.status==="running"&&!K.isIdle)return!0;return!1}function hV1(q,K){let _=[];for(let[z,Y]of Object.entries(K.tasks))if(Y.type==="in_process_teammate"&&Y.status==="running"&&!Y.isIdle)_.push(z);if(_.length===0)return Promise.resolve();return new Promise((z)=>{let Y=_.length,$=()=>{if(Y--,Y===0)z()};q((A)=>{let O={...A.tasks};for(let w of _){let j=O[w];if(j&&j.type==="in_process_teammate")if(j.isIdle)$();else O[w]={...j,onIdleCallbacks:[...j.onIdleCallbacks??[],$]}}return{...A,tasks:O}})})}var zL=null;var AY=y(()=>{JG();m8();JG()});var dG6={};T8(dG6,{isComputerUseMCPServer:()=>Sj_,getTerminalBundleId:()=>CV1,COMPUTER_USE_MCP_SERVER_NAME:()=>p$6,CLI_HOST_BUNDLE_ID:()=>wf8,CLI_CU_CAPABILITIES:()=>Zc6});function CV1(){let q=process.env.__CFBundleIdentifier;if(q)return q;return hj_[a1.terminal??""]??null}function Sj_(q){return Z2(q)===p$6}var p$6="computer-use",wf8="com.anthropic.claude-code.cli-no-window",hj_,Zc6;var wi=y(()=>{y_();hj_={"iTerm.app":"com.googlecode.iterm2",Apple_Terminal:"com.apple.Terminal",ghostty:"com.mitchellh.ghostty",kitty:"net.kovidgoyal.kitty",WarpTerminal:"dev.warp.Warp-Stable",vscode:"com.microsoft.VSCode"};Zc6={screenshotFiltering:"native",platform:"darwin"}});import{extname as Cj_}from"path";function wK(q){if(q.startsWith("mcp__"))return"mcp_tool";return q}function Jf8(){return i6(process.env.OTEL_LOG_TOOL_DETAILS)}function bj_(q,K){if(process.env.CLAUDE_CODE_ENTRYPOINT==="local-agent")return!0;if(q==="claudeai-proxy")return!0;if(K&&Krq(K))return!0;return!1}function zF(q,K,_){let z=uV1(q);if(!z)return{};if(!xj_.has(z.serverName)&&!bj_(K,_))return{};return{mcpServerName:z.serverName,mcpToolName:z.mcpToolName}}function uV1(q){if(!q.startsWith("mcp__"))return;let K=q.split("__");if(K.length<3)return;let _=K[1],z=K.slice(2).join("__");if(!_||!z)return;return{serverName:_,mcpToolName:z}}function $rq(q,K){if(q!=="Skill")return;if(typeof K==="object"&&K!==null&&"skill"in K&&typeof K.skill==="string")return K.skill;return}function xV1(q,K=0){if(typeof q==="string"){if(q.length>Ij_)return`${q.slice(0,uj_)}…[${q.length} chars]`;return q}if(typeof q==="number"||typeof q==="boolean"||q===null||q===void 0)return q;if(K>=mj_)return"<nested>";if(Array.isArray(q)){let _=q.slice(0,jf8).map((z)=>xV1(z,K+1));if(q.length>jf8)_.push(`…[${q.length} items]`);return _}if(typeof q==="object"){let _=Object.entries(q).filter(([Y])=>!Y.startsWith("_")),z=_.slice(0,jf8).map(([Y,$])=>[Y,xV1($,K+1)]);if(_.length>jf8)z.push(["…",`${_.length} keys`]);return Object.fromEntries(z)}return String(q)}function Arq(q){if(!Jf8())return;let K=xV1(q),_=g6(K);if(_.length>Yrq)_=_.slice(0,Yrq)+"…[truncated]";return _}function M16(q){let K=Cj_(q).toLowerCase();if(!K||K===".")return;let _=K.slice(1);if(_.length>pj_)return"other";return _}function Orq(q,K){if(!q.includes(".")&&!K)return;let _,z=new Set;if(K){let Y=M16(K);if(Y)z.add(Y),_=Y}for(let Y of q.split(gj_)){if(!Y)continue;let $=Y.split(Fj_);if($.length<2)continue;let A=$[0],O=A.lastIndexOf("/"),w=O>=0?A.slice(O+1):A;if(!Bj_.has(w))continue;for(let j=1;j<$.length;j++){let H=$[j];if(H.charCodeAt(0)===45)continue;let J=M16(H);if(J&&!z.has(J))z.add(J),_=_?_+","+J:J}}if(!_)return;return _}function Uj_(){let q=Au();if(q){let O={agentId:q.agentId,parentSessionId:q.parentSessionId,agentType:q.agentType};if(q.agentType==="teammate")O.teamName=q.teamName;return O}let K=NP(),_=_F(),z=$9(),$=$Y()?"teammate":K?"standalone":void 0;if(K||$||_||z)return{...K?{agentId:K}:{},...$?{agentType:$}:{},..._?{parentSessionId:_}:{},...z?{teamName:z}:{}};let A=mn8();if(A)return{parentSessionId:A};return{}}function cj_(){try{let q=process.memoryUsage(),K=process.cpuUsage(),_=Date.now(),z;if(Hf8&&bV1){let Y=_-bV1;if(Y>0){let $=K.user-Hf8.user,A=K.system-Hf8.system;z=($+A)/(Y*1000)*100}}return Hf8=K,bV1=_,{uptime:process.uptime(),rss:q.rss,heapTotal:q.heapTotal,heapUsed:q.heapUsed,external:q.external,arrayBuffers:q.arrayBuffers,constrainedMemory:process.constrainedMemory(),cpuUsage:K,cpuPercent:z}}catch{return}}async function Mf8(q={}){let K=q.model?String(q.model):D5(),_=typeof q.betas==="string"?q.betas:qL(K).join(","),[z,Y]=await Promise.all([dj_(),t$8()]),$=cj_();return{model:K,sessionId:N8(),userType:"external",..._.length>0?{betas:_}:{},envContext:z,...process.env.CLAUDE_CODE_ENTRYPOINT&&{entrypoint:process.env.CLAUDE_CODE_ENTRYPOINT},...process.env.CLAUDE_AGENT_SDK_VERSION&&{agentSdkVersion:process.env.CLAUDE_AGENT_SDK_VERSION},isInteractive:String(ET()),clientType:xX6(),...$&&{processMetrics:$},sweBenchRunId:process.env.SWE_BENCH_RUN_ID||"",sweBenchInstanceId:process.env.SWE_BENCH_INSTANCE_ID||"",sweBenchTaskId:process.env.SWE_BENCH_TASK_ID||"",...Uj_(),...yK()&&{subscriptionType:yK()},...{},...Y&&{rh:Y}}}function wrq(q,K,_={}){let{envContext:z,processMetrics:Y,rh:$,kairosActive:A,skillMode:O,observerMode:w,...j}=q,H={platform:z.platform,platform_raw:z.platformRaw,arch:z.arch,node_version:z.nodeVersion,terminal:z.terminal||"unknown",package_managers:z.packageManagers,runtimes:z.runtimes,is_running_with_bun:z.isRunningWithBun,is_ci:z.isCi,is_claubbit:z.isClaubbit,is_claude_code_remote:z.isClaudeCodeRemote,is_local_agent_mode:z.isLocalAgentMode,is_conductor:z.isConductor,is_github_action:z.isGithubAction,is_claude_code_action:z.isClaudeCodeAction,is_claude_ai_auth:z.isClaudeAiAuth,version:z.version,build_time:z.buildTime,deployment_environment:z.deploymentEnvironment};if(z.remoteEnvironmentType)H.remote_environment_type=z.remoteEnvironmentType;if(z.claudeCodeContainerId)H.claude_code_container_id=z.claudeCodeContainerId;if(z.claudeCodeRemoteSessionId)H.claude_code_remote_session_id=z.claudeCodeRemoteSessionId;if(z.tags)H.tags=z.tags.split(",").map((X)=>X.trim()).filter(Boolean);if(z.githubEventName)H.github_event_name=z.githubEventName;if(z.githubActionsRunnerEnvironment)H.github_actions_runner_environment=z.githubActionsRunnerEnvironment;if(z.githubActionsRunnerOs)H.github_actions_runner_os=z.githubActionsRunnerOs;if(z.githubActionRef)H.github_action_ref=z.githubActionRef;if(z.wslVersion)H.wsl_version=z.wslVersion;if(z.linuxDistroId)H.linux_distro_id=z.linuxDistroId;if(z.linuxDistroVersion)H.linux_distro_version=z.linuxDistroVersion;if(z.linuxKernel)H.linux_kernel=z.linuxKernel;if(z.vcs)H.vcs=z.vcs;if(z.versionBase)H.version_base=z.versionBase;let J={session_id:j.sessionId,model:j.model,user_type:j.userType,is_interactive:j.isInteractive==="true",client_type:j.clientType};if(j.betas)J.betas=j.betas;if(j.entrypoint)J.entrypoint=j.entrypoint;if(j.agentSdkVersion)J.agent_sdk_version=j.agentSdkVersion;if(j.sweBenchRunId)J.swe_bench_run_id=j.sweBenchRunId;if(j.sweBenchInstanceId)J.swe_bench_instance_id=j.sweBenchInstanceId;if(j.sweBenchTaskId)J.swe_bench_task_id=j.sweBenchTaskId;if(j.agentId)J.agent_id=j.agentId;if(j.parentSessionId)J.parent_session_id=j.parentSessionId;if(j.agentType)J.agent_type=j.agentType;if(j.teamName)J.team_name=j.teamName;if(K.githubActionsMetadata){let X=K.githubActionsMetadata;H.github_actions_metadata={actor_id:X.actorId,repository_id:X.repositoryId,repository_owner_id:X.repositoryOwnerId}}let M;if(K.accountUuid||K.organizationUuid)M={account_uuid:K.accountUuid,organization_uuid:K.organizationUuid};return{env:H,...Y&&{process:Buffer.from(g6(Y)).toString("base64")},...M&&{auth:M},core:J,additional:{...$&&{rh:$},...A&&{is_assistant_mode:!0},...O&&{skill_mode:O},...w&&{observer_mode:w},..._}}}var xj_,Ij_=512,uj_=128,Yrq=4096,jf8=20,mj_=2,pj_=10,Bj_,gj_,Fj_,Qj_,dj_,Hf8=null,bV1=null;var kj=y(()=>{F4();y_();J16();HG();aq();v8();m8();yV1();G7();E5();vK();Ou();l8();AY();xj_=new Set([(wi(),Eq(dG6)).COMPUTER_USE_MCP_SERVER_NAME]);Bj_=new Set(["rm","mv","cp","touch","mkdir","chmod","chown","cat","head","tail","sort","stat","diff","wc","grep","rg","sed"]),gj_=/\s*(?:&&|\|\||[;|])\s*/,Fj_=/\s+/;Qj_=_1(()=>{let q={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.match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);return q?q[0]:void 0}),dj_=_1(async()=>{let[q,K,_,z]=await Promise.all([a1.getPackageManagers(),a1.getRuntimes(),eL7(),qR7()]);return{platform:KD6(),platformRaw:process.env.CLAUDE_CODE_HOST_PLATFORM||process.platform,arch:a1.arch,nodeVersion:a1.nodeVersion,terminal:BV.terminal,packageManagers:q.join(","),runtimes:K.join(","),isRunningWithBun:a1.isRunningWithBun(),isCi:i6(!1),isClaubbit:i6(process.env.CLAUBBIT),isClaudeCodeRemote:i6(process.env.CLAUDE_CODE_REMOTE),isLocalAgentMode:process.env.CLAUDE_CODE_ENTRYPOINT==="local-agent",isConductor:a1.isConductor(),...process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE&&{remoteEnvironmentType:process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE},...{},...process.env.CLAUDE_CODE_CONTAINER_ID&&{claudeCodeContainerId:process.env.CLAUDE_CODE_CONTAINER_ID},...process.env.CLAUDE_CODE_REMOTE_SESSION_ID&&{claudeCodeRemoteSessionId:process.env.CLAUDE_CODE_REMOTE_SESSION_ID},...process.env.CLAUDE_CODE_TAGS&&{tags:process.env.CLAUDE_CODE_TAGS},isGithubAction:i6(process.env.GITHUB_ACTIONS),isClaudeCodeAction:i6(process.env.CLAUDE_CODE_ACTION),isClaudeAiAuth:d7(),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,versionBase:Qj_(),buildTime:{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"}.BUILD_TIME,deploymentEnvironment:a1.detectDeploymentEnvironment(),...i6(process.env.GITHUB_ACTIONS)&&{githubEventName:process.env.GITHUB_EVENT_NAME,githubActionsRunnerEnvironment:process.env.RUNNER_ENVIRONMENT,githubActionsRunnerOs:process.env.RUNNER_OS,githubActionRef:process.env.GITHUB_ACTION_PATH?.includes("claude-code-action/")?process.env.GITHUB_ACTION_PATH.split("claude-code-action/")[1]:void 0},...O_6()&&{wslVersion:O_6()},..._??{},...z.length>0?{vcs:z.join(",")}:{}}})});import{randomUUID as lj_}from"crypto";import{appendFile as nj_,mkdir as jrq,readdir as ij_,unlink as Hrq,writeFile as rj_}from"fs/promises";import*as Xf8 from"path";function Gc6(){return Xf8.join(c1(),"telemetry")}class mV1{endpoint;timeout;maxBatchSize;skipAuth;batchDelayMs;baseBackoffDelayMs;maxBackoffDelayMs;maxAttempts;isKilled;pendingExports=[];isShutdown=!1;schedule;cancelBackoff=null;attempts=0;isRetrying=!1;lastExportErrorContext;constructor(q={}){let K=q.baseUrl||(process.env.ANTHROPIC_BASE_URL==="https://api-staging.anthropic.com"?"https://api-staging.anthropic.com":"https://api.anthropic.com");this.endpoint=`${K}${q.path||"/api/event_logging/batch"}`,this.timeout=q.timeout||1e4,this.maxBatchSize=q.maxBatchSize||200,this.skipAuth=q.skipAuth??!1,this.batchDelayMs=q.batchDelayMs||100,this.baseBackoffDelayMs=q.baseBackoffDelayMs||500,this.maxBackoffDelayMs=q.maxBackoffDelayMs||30000,this.maxAttempts=q.maxAttempts??8,this.isKilled=q.isKilled??(()=>!1),this.schedule=q.schedule??((_,z)=>{let Y=setTimeout(_,z);return()=>clearTimeout(Y)}),this.retryPreviousBatches()}async getQueuedEventCount(){return(await this.loadEventsFromCurrentBatch()).length}getCurrentBatchFilePath(){return Xf8.join(Gc6(),`${Mrq}${N8()}.${Jrq}.json`)}async loadEventsFromFile(q){try{return await YA8(q)}catch{return[]}}async loadEventsFromCurrentBatch(){return this.loadEventsFromFile(this.getCurrentBatchFilePath())}async saveEventsToFile(q,K){try{if(K.length===0)try{await Hrq(q)}catch{}else{await jrq(Gc6(),{recursive:!0});let _=K.map((z)=>g6(z)).join(`
494`)+`
495`;await rj_(q,_,"utf8")}}catch(_){H6(_)}}async appendEventsToFile(q,K){if(K.length===0)return;try{await jrq(Gc6(),{recursive:!0});let _=K.map((z)=>g6(z)).join(`
496`)+`

Callers 4

saveEventsToFileMethod · 0.85
appendEventsToFileMethod · 0.85
retryPreviousBatchesMethod · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected