MCPcopy Create free account
hub / github.com/ChinaSiro/claude-code-sourcemap / Q$6

Function Q$6

package/cli.js:497–510  ·  view source on GitHub ↗
(q,K,_)

Source from the content-addressed store, hash-verified

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`)+`
497`;await nj_(q,_,"utf8")}catch(_){H6(_)}}async deleteFile(q){try{await Hrq(q)}catch{}}async retryPreviousBatches(){try{let q=`${Mrq}${N8()}.`,K;try{K=(await ij_(Gc6())).filter((_)=>_.startsWith(q)&&_.endsWith(".json")).filter((_)=>!_.includes(Jrq))}catch(_){if(e3(_))return;throw _}for(let _ of K){let z=Xf8.join(Gc6(),_);this.retryFileInBackground(z)}}catch(q){H6(q)}}async retryFileInBackground(q){if(this.attempts>=this.maxAttempts){await this.deleteFile(q);return}let K=await this.loadEventsFromFile(q);if(K.length===0){await this.deleteFile(q);return}let _=await this.sendEventsInBatches(K);if(_.length===0)await this.deleteFile(q);else await this.saveEventsToFile(q,_)}async export(q,K){if(this.isShutdown){K({code:X16.ExportResultCode.FAILED,error:Error("Exporter has been shutdown")});return}let _=this.doExport(q,K);this.pendingExports.push(_),_.finally(()=>{let z=this.pendingExports.indexOf(_);if(z>-1)this.pendingExports.splice(z,1)})}async doExport(q,K){try{let _=q.filter(($)=>$.instrumentationScope?.name==="com.anthropic.claude_code.events");if(_.length===0){K({code:X16.ExportResultCode.SUCCESS});return}let z=this.transformLogsToEvents(_).events;if(z.length===0){K({code:X16.ExportResultCode.SUCCESS});return}if(this.attempts>=this.maxAttempts){K({code:X16.ExportResultCode.FAILED,error:Error(`Dropped ${z.length} events: max attempts (${this.maxAttempts}) reached`)});return}let Y=await this.sendEventsInBatches(z);if(this.attempts++,Y.length>0){await this.queueFailedEvents(Y),this.scheduleBackoffRetry();let $=this.lastExportErrorContext?` (${this.lastExportErrorContext})`:"";K({code:X16.ExportResultCode.FAILED,error:Error(`Failed to export ${Y.length} events${$}`)});return}if(this.resetBackoff(),await this.getQueuedEventCount()>0&&!this.isRetrying)this.retryFailedEvents();K({code:X16.ExportResultCode.SUCCESS})}catch(_){H6(_),K({code:X16.ExportResultCode.FAILED,error:x1(_)})}}async sendEventsInBatches(q){let K=[];for(let Y=0;Y<q.length;Y+=this.maxBatchSize)K.push(q.slice(Y,Y+this.maxBatchSize));let _=[],z;for(let Y=0;Y<K.length;Y++){let $=K[Y];try{await this.sendBatchWithRetry({events:$})}catch(A){z=oj_(A);for(let O=Y;O<K.length;O++)_.push(...K[O]);break}if(Y<K.length-1&&this.batchDelayMs>0)await R7(this.batchDelayMs)}if(_.length>0&&z)this.lastExportErrorContext=z;return _}async queueFailedEvents(q){let K=this.getCurrentBatchFilePath();await this.appendEventsToFile(K,q);let _=this.lastExportErrorContext?` (${this.lastExportErrorContext})`:"",z=`1P event logging: ${q.length} events failed to export${_}`;H6(Error(z))}scheduleBackoffRetry(){if(this.cancelBackoff||this.isRetrying||this.isShutdown)return;let q=Math.min(this.baseBackoffDelayMs*this.attempts*this.attempts,this.maxBackoffDelayMs);this.cancelBackoff=this.schedule(async()=>{this.cancelBackoff=null,await this.retryFailedEvents()},q)}async retryFailedEvents(){let q=this.getCurrentBatchFilePath();while(!this.isShutdown){let K=await this.loadEventsFromFile(q);if(K.length===0)break;if(this.attempts>=this.maxAttempts){await this.deleteFile(q),this.resetBackoff();return}this.isRetrying=!0,await this.deleteFile(q);let _=await this.sendEventsInBatches(K);if(this.attempts++,this.isRetrying=!1,_.length>0){await this.saveEventsToFile(q,_),this.scheduleBackoffRetry();return}this.resetBackoff()}}resetBackoff(){if(this.attempts=0,this.cancelBackoff)this.cancelBackoff(),this.cancelBackoff=null}async sendBatchWithRetry(q){if(this.isKilled())throw Error("firstParty sink killswitch active");let K={"Content-Type":"application/json","User-Agent":n$(),"x-service-name":"claude-code"},_=l$()||i7(),z=this.skipAuth||!_;if(!z&&d7()){let O=Kq();if(!BW())z=!0;else if(O&&Gg(O.expiresAt))z=!0}let Y=z?{headers:{},error:"trust not established or Oauth token expired"}:DJ(),$=!Y.error,A=$?{...K,...Y.headers}:K;try{let O=await $1.post(this.endpoint,q,{timeout:this.timeout,headers:A});this.logSuccess(q.events.length,$,O.data);return}catch(O){if($&&$1.isAxiosError(O)&&O.response?.status===401){let w=await $1.post(this.endpoint,q,{timeout:this.timeout,headers:K});this.logSuccess(q.events.length,!1,w.data);return}throw O}}logSuccess(q,K,_){}hrTimeToDate(q){let[K,_]=q;return new Date(K*1000+_/1e6)}transformLogsToEvents(q){let K=[];for(let _ of q){let z=_.attributes||{};if(z.event_type==="GrowthbookExperimentEvent"){let P=this.hrTimeToDate(_.hrTime),W=z.account_uuid,D=z.organization_uuid;K.push({event_type:"GrowthbookExperimentEvent",event_data:kV1.toJSON({event_id:z.event_id,timestamp:P,experiment_id:z.experiment_id,variation_id:z.variation_id,environment:z.environment,user_attributes:z.user_attributes,experiment_metadata:z.experiment_metadata,device_id:z.device_id,session_id:z.session_id,auth:W||D?{account_uuid:W,organization_uuid:D}:void 0})});continue}let Y=z.event_name||_.body||"unknown",$=z.core_metadata,A=z.user_metadata,O=z.event_metadata||{};if(!$){K.push({event_type:"ClaudeCodeInternalEvent",event_data:Yf8.toJSON({event_id:z.event_id,event_name:Y,client_timestamp:this.hrTimeToDate(_.hrTime),session_id:N8(),additional_metadata:Buffer.from(g6({transform_error:"core_metadata attribute is missing"})).toString("base64")})});continue}let w=wrq($,A,O),{_PROTO_skill_name:j,_PROTO_plugin_name:H,_PROTO_marketplace_name:J,...M}=w.additional,X=f38(M);K.push({event_type:"ClaudeCodeInternalEvent",event_data:Yf8.toJSON({event_id:z.event_id,event_name:Y,client_timestamp:this.hrTimeToDate(_.hrTime),device_id:z.user_id,email:A?.email,auth:w.auth,...w.core,env:w.env,process:w.process,skill_name:typeof j==="string"?j:void 0,plugin_name:typeof H==="string"?H:void 0,marketplace_name:typeof J==="string"?J:void 0,additional_metadata:Object.keys(X).length>0?Buffer.from(g6(X)).toString("base64"):void 0})})}return{events:K}}async shutdown(){this.isShutdown=!0,this.resetBackoff(),await this.forceFlush()}async forceFlush(){await Promise.all(this.pendingExports)}}function oj_(q){if(!$1.isAxiosError(q))return d6(q);let K=[],_=q.response?.headers?.["request-id"];if(_)K.push(`request-id=${_}`);if(q.response?.status)K.push(`status=${q.response.status}`);if(q.code)K.push(`code=${q.code}`);if(q.message)K.push(q.message);return K.join(", ")}var X16,Jrq,Mrq="1p_failed_events.";var Xrq=y(()=>{CK();v8();iiq();riq();G7();V1();_8();m8();y8();jG();vO();E8();l8();pW();k8();kj();X16=O6(Oz(),1),Jrq=lj_()});function cG6(q){return XG(aj_,{})?.[q]===!0}var aj_="tengu_frond_boric";var pV1=y(()=>{o1()});var Trq={};T8(Trq,{shutdown1PEventLogging:()=>ji,shouldSampleEvent:()=>BV1,reinitialize1PEventLoggingIfConfigChanged:()=>YH_,logGrowthBookExperimentTo1P:()=>gV1,logEventTo1P:()=>Tc6,is1PEventLoggingEnabled:()=>B$6,initialize1PEventLogging:()=>Grq,getEventSamplingConfig:()=>Drq});import{randomUUID as Wrq}from"crypto";function Drq(){return XG(sj_,{})}function BV1(q){let _=Drq()[q];if(!_)return null;let z=_.sample_rate;if(typeof z!=="number"||z<0||z>1)return null;if(z>=1)return null;if(z<=0)return 0;return Math.random()<z?z:0}function frq(){return XG(tj_,{})}async function ji(){if(!P16)return;try{await P16.shutdown()}catch{}}function B$6(){return!j16()}async function ej_(q,K,_={}){try{let z=await Mf8({model:_.model,betas:_.betas}),Y={event_name:K,event_id:Wrq(),core_metadata:z,user_metadata:SG6(!0),event_metadata:_},$=CS();if($)Y.user_id=$;q.emit({body:K,attributes:Y})}catch(z){}}function Tc6(q,K={}){if(!B$6())return;if(!W16||cG6("firstParty"))return;ej_(W16,q,K)}function qH_(){return"production"}function gV1(q){if(!B$6())return;if(!W16||cG6("firstParty"))return;let K=CS(),{accountUuid:_,organizationUuid:z}=SG6(!0),Y={event_type:"GrowthbookExperimentEvent",event_id:Wrq(),experiment_id:q.experimentId,variation_id:q.variationId,...K&&{device_id:K},..._&&{account_uuid:_},...z&&{organization_uuid:z},...q.userAttributes&&{session_id:q.userAttributes.sessionId,user_attributes:g6(q.userAttributes)},...q.experimentMetadata&&{experiment_metadata:g6(q.experimentMetadata)},environment:qH_()};W16.emit({body:"growthbook_experiment",attributes:Y})}function Grq(){if(U4("1p_event_logging_start"),!B$6())return;let K=frq();Zrq=K,U4("1p_event_after_growthbook_config");let _=K.scheduledDelayMillis||parseInt(process.env.OTEL_LOGS_EXPORT_INTERVAL||KH_.toString()),z=K.maxExportBatchSize||_H_,Y=K.maxQueueSize||zH_,$=Z1(),A={[Wf8.ATTR_SERVICE_NAME]:"claude-code",[Wf8.ATTR_SERVICE_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};if($==="wsl"){let j=O_6();if(j)A["wsl.version"]=j}let O=Prq.resourceFromAttributes(A),w=new mV1({maxBatchSize:z,skipAuth:K.skipAuth,maxAttempts:K.maxAttempts,path:K.path,baseUrl:K.baseUrl,isKilled:()=>cG6("firstParty")});P16=new Pf8.LoggerProvider({resource:O,processors:[new Pf8.BatchLogRecordProcessor(w,{scheduledDelayMillis:_,maxExportBatchSize:z,maxQueueSize:Y})]}),W16=P16.getLogger("com.anthropic.claude_code.events",{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)}async function YH_(){if(!B$6()||!P16)return;let q=frq();if(QJ(q,Zrq))return;let K=P16,_=W16;W16=null;try{await K.forceFlush()}catch{}P16=null;try{Grq()}catch(z){P16=K,W16=_,H6(z);return}K.shutdown().catch(()=>{})}var Prq,Pf8,Wf8,sj_="tengu_event_sampling_config",tj_="tengu_1p_event_batch_config",W16=null,P16=null,Zrq=null,KH_=1e4,_H_=200,zH_=8192;var Hi=y(()=>{VW6();V1();_8();E8();vK();l8();Cx();f$6();H16();Xrq();o1();kj();pV1();Prq=O6(pG6(),1),Pf8=O6(ZV1(),1),Wf8=O6(L$6(),1)});var Srq={};T8(Srq,{stopPeriodicGrowthBookRefresh:()=>lV1,setupPeriodicGrowthBookRefresh:()=>hrq,setGrowthBookConfigOverride:()=>wH_,resetGrowthBook:()=>Ec6,refreshGrowthBookFeatures:()=>Rrq,refreshGrowthBookAfterAuthChange:()=>U$6,onGrowthBookRefresh:()=>Nc6,initializeGrowthBook:()=>Xi,hasGrowthBookEnvOverride:()=>$H_,getGrowthBookConfigOverrides:()=>OH_,getFeatureValue_DEPRECATED:()=>Df8,getFeatureValue_CACHED_WITH_REFRESH:()=>gV,getFeatureValue_CACHED_MAY_BE_STALE:()=>g8,getDynamicConfig_CACHED_MAY_BE_STALE:()=>XG,getDynamicConfig_BLOCKS_ON_INIT:()=>gS,getApiBaseUrlHost:()=>yrq,getAllGrowthBookFeatures:()=>AH_,clearGrowthBookConfigOverrides:()=>jH_,checkStatsigFeatureGate_CACHED_MAY_BE_STALE:()=>tY,checkSecurityRestrictionGate:()=>cV1,checkGate_CACHED_OR_BLOCKING:()=>FV});function vrq(q){try{Promise.resolve(q()).catch((K)=>{H6(K)})}catch(K){H6(K)}}function Nc6(q){let K=!0,_=iG6.subscribe(()=>vrq(q));if(BS.size>0)queueMicrotask(()=>{if(K&&BS.size>0)vrq(q)});return()=>{K=!1,_()}}function rG6(){if(!UV1)UV1=!0;return krq}function $H_(q){let K=rG6();return K!==null&&q in K}function oG6(){return}function AH_(){if(BS.size>0)return Object.fromEntries(BS);return j8().cachedGrowthBookFeatures??{}}function OH_(){return oG6()??{}}function wH_(q,K){return}function jH_(){return}function yc6(q){if(FV1.has(q))return;let K=F$6.get(q);if(K)FV1.add(q),gV1({experimentId:K.experimentId,variationId:K.variationId,userAttributes:Erq(),experimentMetadata:{feature_id:q}})}async function Vrq(q){let K=q.getPayload();if(!K?.features||Object.keys(K.features).length===0)return!1;F$6.clear();let _={};for(let[z,Y]of Object.entries(K.features)){let $=Y;if("value"in $&&!("defaultValue"in $))_[z]={...$,defaultValue:$.value};else _[z]=$;if($.source==="experiment"&&$.experimentResult){let{experimentResult:A,experiment:O}=$;if(O?.key&&A.variationId!==void 0)F$6.set(z,{experimentId:O.key,variationId:A.variationId})}}await q.setPayload({...K,features:_}),BS.clear();for(let[z,Y]of Object.entries(_)){let $="value"in Y?Y.value:Y.defaultValue;if($!==void 0)BS.set(z,$)}return!0}function Nrq(){let q=Object.fromEntries(BS),K=j8();if(QJ(K.cachedGrowthBookFeatures,q))return;b8((_)=>({..._,cachedGrowthBookFeatures:q}))}function Mi(){return B$6()}function yrq(){let q=process.env.ANTHROPIC_BASE_URL;if(!q)return;try{let K=new URL(q).host;if(K==="api.anthropic.com")return;return K}catch{return}}function Erq(){let q=qbq(),K=q.email,_=yrq();return{id:q.deviceId,sessionId:q.sessionId,deviceID:q.deviceId,platform:q.platform,..._&&{apiBaseUrlHost:_},...q.organizationUuid&&{organizationUUID:q.organizationUuid},...q.accountUuid&&{accountUUID:q.accountUuid},...q.userType&&{userType:q.userType},...q.subscriptionType&&{subscriptionType:q.subscriptionType},...q.rateLimitTier&&{rateLimitTier:q.rateLimitTier},...q.firstTokenTime&&{firstTokenTime:q.firstTokenTime},...K&&{email:K},...q.appVersion&&{appVersion:q.appVersion},...q.githubActionsMetadata&&{githubActionsMetadata:q.githubActionsMetadata}}}async function Lrq(q,K,_){let z=rG6();if(z&&q in z)return z[q];let Y=oG6();if(Y&&q in Y)return Y[q];if(!Mi())return K;let $=await Xi();if(!$)return K;let A;if(BS.has(q))A=BS.get(q);else A=$.getFeatureValue(q,K);if(_)yc6(q);return A}async function Df8(q,K){return Lrq(q,K,!0)}function g8(q,K){let _=rG6();if(_&&q in _)return _[q];let z=oG6();if(z&&q in z)return z[q];if(!Mi())return K;if(F$6.has(q))yc6(q);else nG6.add(q);if(BS.has(q))return BS.get(q);try{let Y=j8().cachedGrowthBookFeatures?.[q];return Y!==void 0?Y:K}catch{return K}}function gV(q,K,_){return g8(q,K)}function tY(q){let K=rG6();if(K&&q in K)return Boolean(K[q]);let _=oG6();if(_&&q in _)return Boolean(_[q]);if(!Mi())return!1;if(F$6.has(q))yc6(q);else nG6.add(q);let z=j8(),Y=z.cachedGrowthBookFeatures?.[q];if(Y!==void 0)return Boolean(Y);return z.cachedStatsigGates?.[q]??!1}async function cV1(q){let K=rG6();if(K&&q in K)return Boolean(K[q]);let _=oG6();if(_&&q in _)return Boolean(_[q]);if(!Mi())return!1;if(Vc6)await Vc6;let z=j8(),Y=z.cachedStatsigGates?.[q];if(Y!==void 0)return Boolean(Y);let $=z.cachedGrowthBookFeatures?.[q];if($!==void 0)return Boolean($);return!1}async function FV(q){let K=rG6();if(K&&q in K)return Boolean(K[q]);let _=oG6();if(_&&q in _)return Boolean(_[q]);if(!Mi())return!1;if(j8().cachedGrowthBookFeatures?.[q]===!0){if(F$6.has(q))yc6(q);else nG6.add(q);return!0}return Lrq(q,!1,!0)}function U$6(){if(!Mi())return;try{Ec6(),iG6.emit(),Vc6=Xi().catch((q)=>{return H6(x1(q)),null}).finally(()=>{Vc6=null})}catch(q){H6(x1(q))}}function Ec6(){if(lV1(),vc6)process.off("beforeExit",vc6),vc6=null;if(kc6)process.off("exit",kc6),kc6=null;Ji?.destroy(),Ji=null,dV1=!1,Vc6=null,F$6.clear(),nG6.clear(),FV1.clear(),BS.clear(),QV1.cache?.clear?.(),Xi.cache?.clear?.(),krq=null,UV1=!1}async function Rrq(){if(!Mi())return;try{let q=await Xi();if(!q)return;if(await q.refreshFeatures(),q!==Ji)return;let K=await Vrq(q);if(q!==Ji)return;if(K)Nrq(),iG6.emit()}catch(q){H6(x1(q))}}function hrq(){if(!Mi())return;if(g$6)clearInterval(g$6);if(g$6=setInterval(()=>{Rrq()},HH_),g$6.unref?.(),!lG6)lG6=()=>{lV1()},process.once("beforeExit",lG6)}function lV1(){if(g$6)clearInterval(g$6),g$6=null;if(lG6)process.removeListener("beforeExit",lG6),lG6=null}async function gS(q,K){return Df8(q,K)}function XG(q,K){return g8(q,K)}var Ji=null,vc6=null,kc6=null,dV1=!1,F$6,BS,nG6,FV1,Vc6=null,iG6,krq=null,UV1=!1,QV1,Xi,HH_=21600000,g$6=null,lG6=null;var o1=y(()=>{UN7();VW6();v8();dN7();V1();_8();y8();jG();E8();l8();f$6();Hi();F$6=new Map,BS=new Map,nG6=new Set,FV1=new Set,iG6=Dz();QV1=_1(()=>{if(!Mi())return null;let q=Erq(),K=QN7(),_="https://api.anthropic.com/",Y=l$()||mX6()||i7()?DJ():{headers:{},error:"trust not established"},$=!Y.error;dV1=$;let A=new sY8({apiHost:_,clientKey:K,attributes:q,remoteEval:!0,cacheKeyAttributes:["id","organizationUUID"],...Y.error?{}:{apiHostRequestHeaders:Y.headers},...{}});if(Ji=A,!$)return{client:A,initialized:Promise.resolve()};let O=A.init({timeout:5000}).then(async(w)=>{if(Ji!==A)return;let j=await Vrq(A);if(Ji!==A)return;if(j){for(let H of nG6)yc6(H);nG6.clear(),Nrq(),iG6.emit()}}).catch((w)=>{});return vc6=()=>Ji?.destroy(),kc6=()=>Ji?.destroy(),process.on("beforeExit",vc6),process.on("exit",kc6),{client:A,initialized:O}}),Xi=_1(async()=>{let q=QV1();if(!q)return null;if(!dV1){if(l$()||mX6()||i7()){if(!DJ().error){if(Ec6(),q=QV1(),!q)return null}}}return await q.initialized,hrq(),q.client})});import{homedir as JH_}from"os";import{isAbsolute as MH_,join as ff8,normalize as nV1,sep as Crq}from"path";function l3(){let q=process.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY;if(i6(q))return!1;if(k_(q))return!0;if(i6(process.env.CLAUDE_CODE_SIMPLE))return!1;if(i6(process.env.CLAUDE_CODE_REMOTE)&&!process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR)return!1;let K=N7();if(K.autoMemoryEnabled!==void 0)return K.autoMemoryEnabled;return!0}function Zf8(){if(!g8("tengu_passport_quail",!1))return!1;return!i7()||g8("tengu_slate_thimble",!1)}function D16(){if(process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR)return process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR;return c1()}function brq(q,K){if(!q)return;let _=q;if(K&&(_.startsWith("~/")||_.startsWith("~\\"))){let Y=_.slice(2),$=nV1(Y||".");if($==="."||$==="..")return;_=ff8(JH_(),Y)}let z=nV1(_).replace(/[/\\]+$/,"");if(!MH_(z)||z.length<3||/^[A-Za-z]:$/.test(z)||z.startsWith("\\\\")||z.startsWith("//")||z.includes("\x00"))return;return(z+Crq).normalize("NFC")}function xrq(){return brq(process.env.CLAUDE_COWORK_MEMORY_PATH_OVERRIDE,!1)}function WH_(){let q=v1("policySettings")?.autoMemoryDirectory??v1("flagSettings")?.autoMemoryDirectory??v1("localSettings")?.autoMemoryDirectory??v1("userSettings")?.autoMemoryDirectory;return brq(q,!0)}function Gf8(){return xrq()!==void 0}function DH_(){return jH(Fz())??Fz()}function Tf8(){return ff8(Vj(),PH_)}function f16(q){return nV1(q).startsWith(Vj())}var XH_="memory",PH_="MEMORY.md",Vj;var rw=y(()=>{F4();v8();o1();m8();E5();dz();U1();Vj=_1(()=>{let q=xrq()??WH_();if(q)return q;let K=ff8(D16(),"projects");return(ff8(K,JP(DH_()),XH_)+Crq).normalize("NFC")},()=>Fz())});var vf8,kf8,Irq;var iV1=y(()=>{vf8=["auto","iterm2","iterm2_with_bell","terminal_bell","kitty","ghostty","notifications_disabled"],kf8=["normal","vim"],Irq=["auto","tmux","in-process"]});var Pi={};T8(Pi,{validateTeamMemWritePath:()=>TH_,validateTeamMemKey:()=>aV1,isTeamMemoryEnabled:()=>Nf8,isTeamMemPath:()=>grq,isTeamMemFile:()=>Lc6,getTeamMemPath:()=>wu,getTeamMemEntrypoint:()=>GH_,PathTraversalError:()=>lW});import{lstat as fH_,realpath as mrq}from"fs/promises";import{dirname as urq,join as Vf8,resolve as rV1,sep as oV1}from"path";function ZH_(q){if(q.includes("\x00"))throw new lW(`Null byte in path key: "${q}"`);let K;try{K=decodeURIComponent(q)}catch{K=q}if(K!==q&&(K.includes("..")||K.includes("/")))throw new lW(`URL-encoded traversal in path key: "${q}"`);let _=q.normalize("NFKC");if(_!==q&&(_.includes("..")||_.includes("/")||_.includes("\\")||_.includes("\x00")))throw new lW(`Unicode-normalized traversal in path key: "${q}"`);if(q.includes("\\"))throw new lW(`Backslash in path key: "${q}"`);if(q.startsWith("/"))throw new lW(`Absolute path key: "${q}"`);return q}function Nf8(){if(!l3())return!1;return g8("tengu_herring_clock",!1)}function wu(){return(Vf8(Vj(),"team")+oV1).normalize("NFC")}function GH_(){return Vf8(Vj(),"team","MEMORY.md")}async function prq(q){let K=[],_=q;for(let z=urq(_);_!==z;z=urq(_))try{let Y=await mrq(_);return K.length===0?Y:Vf8(Y,...K.reverse())}catch(Y){let $=s1(Y);if($==="ENOENT")try{if((await fH_(_)).isSymbolicLink())throw new lW(`Dangling symlink detected (target does not exist): "${_}"`)}catch(A){if(A instanceof lW)throw A}else if($==="ELOOP")throw new lW(`Symlink loop detected in path: "${_}"`);else if($!=="ENOTDIR"&&$!=="ENAMETOOLONG")throw new lW(`Cannot verify path containment (${$}): "${_}"`);K.push(_.slice(z.length+oV1.length)),_=z}return q}async function Brq(q){let K;try{K=await mrq(wu().replace(/[/\\]+$/,""))}catch(_){let z=s1(_);if(z==="ENOENT"||z==="ENOTDIR")return!0;return!1}if(q===K)return!0;return q.startsWith(K+oV1)}function grq(q){let K=rV1(q),_=wu();return K.startsWith(_)}async function TH_(q){if(q.includes("\x00"))throw new lW(`Null byte in path: "${q}"`);let K=rV1(q),_=wu();if(!K.startsWith(_))throw new lW(`Path escapes team memory directory: "${q}"`);let z=await prq(K);if(!await Brq(z))throw new lW(`Path escapes team memory directory via symlink: "${q}"`);return K}async function aV1(q){ZH_(q);let K=wu(),_=Vf8(K,q),z=rV1(_);if(!z.startsWith(K))throw new lW(`Key escapes team memory directory: "${q}"`);let Y=await prq(z);if(!await Brq(Y))throw new lW(`Key escapes team memory directory via symlink: "${q}"`);return z}function Lc6(q){return Nf8()&&grq(q)}var lW;var YL=y(()=>{o1();y8();rw();lW=class lW extends Error{constructor(q){super(q);this.name="PathTraversalError"}}});var G16={};T8(G16,{shouldSkipPluginAutoupdate:()=>aG6,saveGlobalConfig:()=>b8,saveCurrentProjectConfig:()=>jw,resetTrustDialogAcceptedCacheForTesting:()=>EH_,recordFirstStartTime:()=>$N1,isProjectConfigKey:()=>hH_,isPathTrusted:()=>RH_,isGlobalConfigKey:()=>yH_,isAutoUpdaterDisabled:()=>AF,getUserClaudeRulesDir:()=>bf8,getRemoteControlAtStartup:()=>$F,getProjectPathForConfig:()=>Sf8,getOrCreateUserID:()=>CS,getMemoryPath:()=>l$6,getManagedClaudeRulesDir:()=>Cf8,getGlobalConfigWriteCount:()=>SH_,getGlobalConfig:()=>j8,getCustomApiKeyStatus:()=>Sc6,getCurrentProjectConfig:()=>ww,getAutoUpdaterDisabledReason:()=>c$6,formatAutoUpdaterDisabledReason:()=>Cc6,enableConfigs:()=>d$6,checkHasTrustDialogAccepted:()=>l$,_wouldLoseAuthStateForTesting:()=>mH_,_setGlobalConfigCacheForTesting:()=>pH_,_getConfigForTesting:()=>uH_,PROJECT_CONFIG_KEYS:()=>crq,NOTIFICATION_CHANNELS:()=>vf8,GLOBAL_CONFIG_KEYS:()=>drq,EDITOR_MODES:()=>kf8,DEFAULT_GLOBAL_CONFIG:()=>Rf8,CONFIG_WRITE_DISPLAY_THRESHOLD:()=>CH_});import{randomBytes as vH_}from"crypto";import{unwatchFile as kH_,watchFile as VH_}from"fs";import{basename as KN1,dirname as _N1,join as $L,resolve as Ef8}from"path";function Wi(){return{numStartups:0,installMethod:void 0,autoUpdates:void 0,theme:"dark",preferredNotifChannel:"auto",verbose:!1,editorMode:"normal",autoCompactEnabled:!0,showTurnDuration:!0,hasSeenTasksHint:!1,hasUsedStash:!1,hasUsedBackgroundTask:!1,queuedCommandUpHintCount:0,diffTool:"auto",customApiKeyResponses:{approved:[],rejected:[]},env:{},tipsHistory:{},memoryUsageCount:0,promptQueueUseCount:0,btwUseCount:0,todoFeatureEnabled:!0,showExpandedTodos:!1,messageIdleNotifThresholdMs:60000,autoConnectIde:!1,autoInstallIdeExtension:!0,fileCheckpointingEnabled:!0,terminalProgressBarEnabled:!0,cachedStatsigGates:{},cachedDynamicConfigs:{},cachedGrowthBookFeatures:{},respectGitignore:!0,copyFullResponse:!1}}function yH_(q){return drq.includes(q)}function EH_(){lrq=!1}function l$(){return lrq||=LH_()}function LH_(){if(mX6())return!0;let q=j8(),K=Sf8();if(q.projects?.[K]?.hasTrustDialogAccepted)return!0;let z=H_6(Z8());while(!0){if(q.projects?.[z]?.hasTrustDialogAccepted)return!0;let $=H_6(Ef8(z,".."));if($===z)break;z=$}return!1}function RH_(q){let K=j8(),_=H_6(Ef8(q));while(!0){if(K.projects?.[_]?.hasTrustDialogAccepted)return!0;let z=H_6(Ef8(_,".."));if(z===_)return!1;_=z}}function hH_(q){return crq.includes(q)}function hf8(q){let K=YF.config;if(!K)return!1;let _=K.oauthAccount!==void 0&&q.oauthAccount===void 0,z=K.hasCompletedOnboarding===!0&&q.hasCompletedOnboarding!==!0;return _||z}function b8(q){let K=null;try{if(irq(XP(),Wi,(z)=>{let Y=q(z);if(Y===z)return z;return K={...Y,projects:Frq(z.projects)},K})&&K)Lf8(K)}catch(_){N(`Failed to save config with lock: ${_}`,{level:"error"});let z=Q$6(XP(),Wi);if(hf8(z)){N("saveGlobalConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.",{level:"error"}),d("tengu_config_auth_loss_prevented",{});return}let Y=q(z);if(Y===z)return;K={...Y,projects:Frq(z.projects)},nrq(XP(),K,Rf8),Lf8(K)}}function SH_(){return zN1}function bH_(){let q=Rc6+yf8;if(q>0)d("tengu_config_cache_stats",{cache_hits:Rc6,cache_misses:yf8,hit_rate:Rc6/q});Rc6=0,yf8=0}function eV1(q){if(q.installMethod!==void 0)return q;let K=q,_="unknown",z=q.autoUpdates??!0;switch(K.autoUpdaterStatus){case"migrated":_="local";break;case"installed":_="native";break;case"disabled":z=!1;break;case"enabled":case"no_permissions":case"not_configured":_="global";break;case void 0:break}return{...q,installMethod:_,autoUpdates:z}}function Frq(q){if(!q)return q;let K={},_=!1;for(let[z,Y]of Object.entries(q)){let $=Y;if($.history!==void 0){_=!0;let{history:A,...O}=$;K[z]=O}else K[z]=Y}return _?K:q}function IH_(){if(tV1)return;tV1=!0;let q=XP();VH_(q,{interval:xH_,persistent:!1},(K)=>{if(K.mtimeMs<=YF.mtime)return;X8().readFile(q,{encoding:"utf-8"}).then((_)=>{if(K.mtimeMs<=YF.mtime)return;let z=m5(kB(_));if(z===null||typeof z!=="object")return;YF={config:eV1({...Wi(),...z}),mtime:K.mtimeMs},Z16={mtime:K.mtimeMs,size:K.size}}).catch(()=>{})}),pq(async()=>{kH_(q),tV1=!1})}function Lf8(q){YF={config:q,mtime:Date.now()},Z16=null}function j8(){if(YF.config)return Rc6++,YF.config;yf8++;try{let q=null;try{q=X8().statSync(XP())}catch{}let K=eV1(Q$6(XP(),Wi));return YF={config:K,mtime:q?.mtimeMs??Date.now()},Z16=q?{mtime:q.mtimeMs,size:q.size}:null,IH_(),K}catch{return eV1(Q$6(XP(),Wi))}}function $F(){let q=j8().remoteControlAtStartup;if(q!==void 0)return q;return!1}function Sc6(q){let K=j8();if(K.customApiKeyResponses?.approved?.includes(q))return"approved";if(K.customApiKeyResponses?.rejected?.includes(q))return"rejected";return"new"}function nrq(q,K,_){let z=_N1(q);X8().mkdirSync(z);let $=Sm6(K,(A,O)=>g6(A)!==g6(_[O]));if(lW6(q,g6($,null,2),{encoding:"utf-8",mode:384}),q===XP())zN1++}function irq(q,K,_){let z=K(),Y=_N1(q),$=X8();$.mkdirSync(Y);let A;try{let O=`${q}.lock`,w=Date.now();A=ECq(q,{lockfilePath:O,onCompromised:(X)=>{N(`Config lock compromised: ${X}`,{level:"error"})}});let j=Date.now()-w;if(j>100)N("Lock acquisition took longer than expected - another Claude instance may be running"),d("tengu_config_lock_contention",{lock_time_ms:j});if(Z16&&q===XP())try{let X=$.statSync(q);if(X.mtimeMs!==Z16.mtime||X.size!==Z16.size)d("tengu_config_stale_write",{read_mtime:Z16.mtime,write_mtime:X.mtimeMs,read_size:Z16.size,write_size:X.size})}catch(X){if(s1(X)!=="ENOENT")throw X}let H=Q$6(q,K);if(q===XP()&&hf8(H))return N("saveConfigWithLock: re-read config is missing auth that cache has; refusing to write to avoid wiping ~/.claude.json. See GH #3117.",{level:"error"}),d("tengu_config_auth_loss_prevented",{}),!1;let J=_(H);if(J===H)return!1;let M=Sm6(J,(X,P)=>g6(X)!==g6(z[P]));try{let X=KN1(q),P=YN1();try{$.mkdirSync(P)}catch(V){if(s1(V)!=="EEXIST")throw V}let W=60000,D=$.readdirStringSync(P).filter((V)=>V.startsWith(`${X}.backup.`)).sort().reverse(),f=D[0],G=f?Number(f.split(".backup.").pop()):0,Z=Number.isNaN(G)||Date.now()-G>=W;if(Z){let V=$L(P,`${X}.backup.${Date.now()}`);$.copyFileSync(q,V)}let T=5,v=Z?$.readdirStringSync(P).filter((V)=>V.startsWith(`${X}.backup.`)).sort().reverse():D;for(let V of v.slice(T))try{$.unlinkSync($L(P,V))}catch{}}catch(X){if(s1(X)!=="ENOENT")N(`Failed to backup config: ${X}`,{level:"error"})}if(lW6(q,g6(M,null,2),{encoding:"utf-8",mode:384}),q===XP())zN1++;return!0}finally{if(A)A()}}function d$6(){if(qN1)return;let q=Date.now();c8("info","enable_configs_started"),qN1=!0,Q$6(XP(),Wi,!0),c8("info","enable_configs_completed",{duration_ms:Date.now()-q})}function YN1(){return $L(c1(),"backups")}function Urq(q){let K=X8(),_=KN1(q),z=YN1();try{let A=K.readdirStringSync(z).filter((O)=>O.startsWith(`${_}.backup.`)).sort().at(-1);if(A)return $L(z,A)}catch{}let Y=_N1(q);try{let A=K.readdirStringSync(Y).filter((w)=>w.startsWith(`${_}.backup.`)).sort().at(-1);if(A)return $L(Y,A);let O=`${q}.backup`;try{return K.statSync(O),O}catch{}}catch{}return null}function Q$6(q,K,_){if(!qN1)throw Error("Config accessed before allowed.");let z=X8();try{let Y=z.readFileSync(q,{encoding:"utf-8"});try{let $=r8(kB(Y));return{...K(),...$}}catch($){let A=$ instanceof Error?$.message:String($);throw new hT(A,q,K())}}catch(Y){if(s1(Y)==="ENOENT"){let A=Urq(q);if(A)process.stderr.write(`
498Claude configuration file not found at: ${q}
499A backup file exists at: ${A}
500You can manually restore it by running: cp "${A}" "${q}"
501
502`);return K()}if(Y instanceof hT&&_)throw Y;if(Y instanceof hT){if(N(`Config file corrupted, resetting to defaults: ${Y.message}`,{level:"error"}),!sV1){sV1=!0;try{H6(Y);let X=!1;try{z.statSync(`${q}.backup`),X=!0}catch{}d("tengu_config_parse_error",{has_backup:X})}finally{sV1=!1}}process.stderr.write(`
503Claude configuration file at ${q} is corrupted: ${Y.message}
504`);let A=KN1(q),O=YN1();try{z.mkdirSync(O)}catch(X){if(s1(X)!=="EEXIST")throw X}let w=z.readdirStringSync(O).filter((X)=>X.startsWith(`${A}.corrupted.`)),j,H=!1,J=z.readFileSync(q,{encoding:"utf-8"});for(let X of w)try{let P=z.readFileSync($L(O,X),{encoding:"utf-8"});if(J===P){H=!0;break}}catch{}if(!H){j=$L(O,`${A}.corrupted.${Date.now()}`);try{z.copyFileSync(q,j),N(`Corrupted config backed up to: ${j}`,{level:"error"})}catch{}}let M=Urq(q);if(j)process.stderr.write(`The corrupted file has been backed up to: ${j}
505`);else if(H)process.stderr.write(`The corrupted file has already been backed up.
506`);if(M)process.stderr.write(`A backup file exists at: ${M}
507You can manually restore it by running: cp "${M}" "${q}"
508
509`);else process.stderr.write(`
510`)}return K()}}function ww(){let q=Sf8(),K=j8();if(!K.projects)return hc6;let _=K.projects[q]??hc6;if(typeof _.allowedTools==="string")_.allowedTools=m5(_.allowedTools)??[];return _}function jw(q){let K=Sf8(),_=null;try{if(irq(XP(),Wi,(Y)=>{let $=Y.projects?.[K]??hc6,A=q($);if(A===$)return Y;return _={...Y,projects:{...Y.projects,[K]:A}},_})&&_)Lf8(_)}catch(z){N(`Failed to save config with lock: ${z}`,{level:"error"});let Y=Q$6(XP(),Wi);if(hf8(Y)){N("saveCurrentProjectConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.",{level:"error"}),d("tengu_config_auth_loss_prevented",{});return}let $=Y.projects?.[K]??hc6,A=q($);if(A===$)return;_={...Y,projects:{...Y.projects,[K]:A}},nrq(XP(),_,Rf8),Lf8(_)}}function AF(){return c$6()!==null}function aG6(){return AF()&&!i6(process.env.FORCE_AUTOUPDATE_PLUGINS)}function Cc6(q){switch(q.type){case"development":return"development build";case"env":return`${q.envVar} set`;case"config":return"config"}}function c$6(){if(i6(process.env.DISABLE_AUTOUPDATER))return{type:"env",envVar:"DISABLE_AUTOUPDATER"};let q=fL7();if(q)return{type:"env",envVar:q};let K=j8();if(K.autoUpdates===!1&&(K.installMethod!=="native"||K.autoUpdatesProtectedForNative!==!0))return{type:"config"};return null}function CS(){let q=j8();if(q.userID)return q.userID;let K=vH_(32).toString("hex");return b8((_)=>({..._,userID:K})),K}function $N1(){if(!j8().firstStartTime){let K=new Date().toISOString();b8((_)=>({..._,firstStartTime:_.firstStartTime??K}))}}function l$6(q){let K=r1();switch(q){case"User":return $L(c1(),"CLAUDE.md");case"Local":return $L(K,"CLAUDE.local.md");case"Project":return $L(K,"CLAUDE.md");case"Managed":return $L(MP(),"CLAUDE.md");case"AutoMem":return Tf8()}return NH_.getTeamMemEntrypoint()}function Cf8(){return $L(MP(),".claude","rules")}function bf8(){return $L(c1(),"rules")}function pH_(q){YF.config=q,YF.mtime=q?Date.now():0}var NH_,sV1=!1,hc6,Rf8,drq,crq,lrq=!1,NNA,yNA,YF,Z16=null,Rc6=0,yf8=0,zN1=0,CH_=20,xH_=1000,tV1=!1,qN1=!1,Sf8,uH_,mH_;var V1=y(()=>{F4();c71();v8();rw();k8();I7();c9();_8();oY();y_();m8();y8();bK();e7();E5();vO();E8();dz();qI();l8();iV1();NH_=(YL(),Eq(Pi)),hc6={allowedTools:[],mcpContextUris:[],mcpServers:{},enabledMcpjsonServers:[],disabledMcpjsonServers:[],hasTrustDialogAccepted:!1,projectOnboardingSeenCount:0,hasClaudeMdExternalIncludesApproved:!1,hasClaudeMdExternalIncludesWarningShown:!1};Rf8=Wi(),drq=["apiKeyHelper","installMethod","autoUpdates","autoUpdatesProtectedForNative","theme","verbose","preferredNotifChannel","shiftEnterKeyBindingInstalled","editorMode","hasUsedBackslashReturn","autoCompactEnabled","showTurnDuration","diffTool","env","tipsHistory","todoFeatureEnabled","showExpandedTodos","messageIdleNotifThresholdMs","autoConnectIde","autoInstallIdeExtension","fileCheckpointingEnabled","terminalProgressBarEnabled","showStatusInTerminalTab","taskCompleteNotifEnabled","inputNeededNotifEnabled","agentPushNotifEnabled","respectGitignore","claudeInChromeDefaultEnabled","hasCompletedClaudeInChromeOnboarding","lspRecommendationDisabled","lspRecommendationNeverPlugins","lspRecommendationIgnoredCount","copyFullResponse","copyOnSelect","permissionExplainerEnabled","prStatusFooterEnabled","remoteControlAtStartup","remoteDialogSeen"];crq=["allowedTools","hasTrustDialogAccepted","hasCompletedProjectOnboarding"];NNA={...Rf8,autoUpdates:!1},yNA={...hc6};YF={config:null,mtime:0};pq(async()=>{bH_()});Sf8=_1(()=>{let q=r1(),K=jH(q);if(K)return H_6(K);return H_6(Ef8(q))});uH_=Q$6,mH_=hf8});import{createHash as BH_}from"crypto";function rrq(q){return q.replace(/[A-Z]/g,(K)=>`_${K.toLowerCase()}`)}async function AN1(){if(bc6.length===0)return;let q=bc6;bc6=[];try{await $1.post(gH_,q,{headers:{"Content-Type":"application/json","DD-API-KEY":FH_},timeout:dH_})}catch(K){H6(K)}}function nH_(){if(Di)return;Di=setTimeout(()=>{Di=null,AN1()},aH_()).unref()}async function T16(){if(Di)clearTimeout(Di),Di=null;await AN1()}async function orq(q,K){if(E7()!=="firstParty")return;let _=xf8;if(_===null)_=await iH_();if(!_||!cH_.has(q))return;try{let z=await Mf8({model:K.model,betas:K.betas}),{envContext:Y,...$}=z,A={...$,...Y,...K,userBucket:oH_()};if(typeof A.toolName==="string"&&A.toolName.startsWith("mcp__"))A.toolName="mcp";if(typeof A.model==="string"){let H=bY(A.model.replace(/\[1m]$/i,""));A.model=H in UJ8?H:"other"}if(typeof A.version==="string")A.version=A.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,"$1");if(A.status!==void 0&&A.status!==null){let H=String(A.status);A.http_status=H;let J=H.charAt(0);if(J>="1"&&J<="5")A.http_status_range=`${J}xx`;delete A.status}let O=A,j={ddsource:"nodejs",ddtags:[`event:${q}`,...lH_.filter((H)=>O[H]!==void 0&&O[H]!==null).map((H)=>`${rrq(H)}:${O[H]}`)].join(","),message:q,service:"claude-code",hostname:"claude-code",env:"external"};for(let[H,J]of Object.entries(A))if(J!==void 0&&J!==null)j[rrq(H)]=J;if(bc6.push(j),bc6.length>=QH_){if(Di)clearTimeout(Di),Di=null;AN1()}else nH_()}catch(z){H6(z)}}function aH_(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||"",10)||UH_}var gH_="https://http-intake.logs.us5.datadoghq.com/api/v2/logs",FH_="pubbbf48e6d78dae54bceaa4acf463299bf",UH_=15000,QH_=100,dH_=5000,cH_,lH_,bc6,Di=null,xf8=null,iH_,rH_=30,oH_;var sG6=y(()=>{CK();F4();V1();E8();aq();Az();wn();H16();kj();cH_=new Set(["chrome_bridge_connection_succeeded","chrome_bridge_connection_failed","chrome_bridge_disconnected","chrome_bridge_tool_call_completed","chrome_bridge_tool_call_error","chrome_bridge_tool_call_started","chrome_bridge_tool_call_timeout","tengu_api_error","tengu_api_success","tengu_brief_mode_enabled","tengu_brief_mode_toggled","tengu_brief_send","tengu_cancel","tengu_compact_failed","tengu_exit","tengu_flicker","tengu_init","tengu_model_fallback_triggered","tengu_oauth_error","tengu_oauth_success","tengu_oauth_token_refresh_failure","tengu_oauth_token_refresh_success","tengu_oauth_token_refresh_lock_acquiring","tengu_oauth_token_refresh_lock_acquired","tengu_oauth_token_refresh_starting","tengu_oauth_token_refresh_completed","tengu_oauth_token_refresh_lock_releasing","tengu_oauth_token_refresh_lock_released","tengu_query_error","tengu_session_file_read","tengu_started","tengu_tool_use_error","tengu_tool_use_granted_in_prompt_permanent","tengu_tool_use_granted_in_prompt_temporary","tengu_tool_use_rejected_in_prompt","tengu_tool_use_success","tengu_uncaught_exception","tengu_unhandled_rejection","tengu_voice_recording_started","tengu_voice_toggled","tengu_team_mem_sync_pull","tengu_team_mem_sync_push","tengu_team_mem_sync_started","tengu_team_mem_entries_capped"]),lH_=["arch","clientType","errorType","http_status_range","http_status","kairosActive","model","platform","provider","skillMode","subscriptionType","toolName","userBucket","userType","version","versionBase"];bc6=[];iH_=_1(async()=>{if(j16())return xf8=!1,!1;try{return xf8=!0,!0}catch(q){return H6(q),xf8=!1,!1}});oH_=_1(()=>{let q=CS(),K=BH_("sha256").update(q).digest("hex");return parseInt(K.slice(0,8),16)%rH_})});function sH_(){if(cG6("datadog"))return!1;if(ON1!==void 0)return ON1;try{return tY(arq)}catch{return!1}}function srq(q,K){let _=BV1(q);if(_===0)return;let z=_!==null?{...K,sample_rate:_}:K;if(sH_())orq(q,f38(z));Tc6(q,z)}function tH_(q,K){return srq(q,K),Promise.resolve()}function trq(){ON1=tY(arq)}function tG6(){Cj7({logEvent:srq,logEventAsync:tH_})}var arq="tengu_log_datadog_events",ON1=void 0;var xc6=y(()=>{sG6();Hi();o1();k8();pV1()});function uf8(q){if(E7()==="vertex")return wN1;if(q?.isNonInteractive){if(q.hasAppendSystemPrompt)return erq;return qoq}return wN1}function qJ_(){if(k_(process.env.CLAUDE_CODE_ATTRIBUTION_HEADER))return!1;return g8("tengu_attribution_header",!0)}function mf8(q){if(!qJ_())return"";let K=`${{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}.${q}`,_=process.env.CLAUDE_CODE_ENTRYPOINT??"unknown",z=" cch=00000;",Y=RD8(),$=Y?` cc_workload=${Y};`:"",A=`x-anthropic-billing-header: cc_version=${K}; cc_entrypoint=${_};${z}${$}`;return N(`attribution header ${A}`),A}var wN1="You are Claude Code, Anthropic's official CLI for Claude.",erq="You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK.",qoq="You are a Claude agent, built on Anthropic's Claude Agent SDK.",eH_,If8;var pf8=y(()=>{o1();_8();m8();Az();D$6();eH_=[wN1,erq,qoq],If8=new Set(eH_)});function v16(q){return q.filter((K)=>K.data?.type!=="hook_progress")}function g_(q,K){return q.name===K||(q.aliases?.includes(K)??!1)}function L5(q,K){return q.find((_)=>g_(_,K))}function sq(q){return{...KJ_,userFacingName:()=>q.name,...q}}var MX=()=>({mode:"default",additionalWorkingDirectories:new Map,alwaysAllowRules:{},alwaysDenyRules:{},alwaysAskRules:{},isBypassPermissionsModeAvailable:!1}),KJ_;var Bq=y(()=>{KJ_={isEnabled:()=>!0,isConcurrencySafe:(q)=>!1,isReadOnly:(q)=>!1,isDestructive:(q)=>!1,checkPermissions:(q,K)=>Promise.resolve({behavior:"allow",updatedInput:q}),toAutoClassifierInput:(q)=>"",userFacingName:(q)=>""}});var n$6=m((eNA,Ff8)=>{function zoq(q){return Array.isArray(q)?q:[q]}var _J_=void 0,HN1="",Koq=" ",jN1="\\",zJ_=/^\s+$/,YJ_=/(?:[^\\]|^)\\$/,$J_=/^\\!/,AJ_=/^\\#/,OJ_=/\r?\n/g,wJ_=/^\.{0,2}\/|^\.{1,2}$/,jJ_=/\/$/,eG6="/",Yoq="node-ignore";if(typeof Symbol<"u")Yoq=Symbol.for("node-ignore");var $oq=Yoq,qT6=(q,K,_)=>{return Object.defineProperty(q,K,{value:_}),_},HJ_=/([0-z])-([0-z])/g,Aoq=()=>!1,JJ_=(q)=>q.replace(HJ_,(K,_,z)=>_.charCodeAt(0)<=z.charCodeAt(0)?K:HN1),MJ_=(q)=>{let{length:K}=q;return q.slice(0,K-K%2)},XJ_=[[/^\uFEFF/,()=>HN1],[/((?:\\\\)*?)(\\?\s+)$/,(q,K,_)=>K+(_.indexOf("\\")===0?Koq:HN1)],[/(\\+?)\s/g,(q,K)=>{let{length:_}=K;return K.slice(0,_-_%2)+Koq}],[/[\\$.|*+(){^]/g,(q)=>`\\${q}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return!/\/(?!$)/.test(this)?"(?:^|\\/)":"^"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(q,K,_)=>K+6<_.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(q,K,_)=>{let z=_.replace(/\\\*/g,"[^\\/]*");return K+z}],[/\\\\\\(?=[$.|*+(){^])/g,()=>jN1],[/\\\\/g,()=>jN1],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(q,K,_,z,Y)=>K===jN1?`\\[${_}${MJ_(z)}${Y}`:Y==="]"?z.length%2===0?`[${JJ_(_)}${z}]`:"[]":"[]"],[/(?:[^*])$/,(q)=>/\/$/.test(q)?`${q}$`:`${q}(?=$|\\/$)`]],PJ_=/(^|\\\/)?\\\*$/,Ic6="regex",Bf8="checkRegex",_oq="_",WJ_={[Ic6](q,K){return`${K?`${K}[^/]+`:"[^/]*"}(?=$|\\/$)`},[Bf8](q,K){return`${K?`${K}[^/]*`:"[^/]*"}(?=$|\\/$)`}},DJ_=(q)=>XJ_.reduce((K,[_,z])=>K.replace(_,z.bind(q)),q),gf8=(q)=>typeof q==="string",fJ_=(q)=>q&&gf8(q)&&!zJ_.test(q)&&!YJ_.test(q)&&q.indexOf("#")!==0,ZJ_=(q)=>q.split(OJ_).filter(Boolean);class Ooq{constructor(q,K,_,z,Y,$){this.pattern=q,this.mark=K,this.negative=Y,qT6(this,"body",_),qT6(this,"ignoreCase",z),qT6(this,"regexPrefix",$)}get regex(){let q=_oq+Ic6;if(this[q])return this[q];return this._make(Ic6,q)}get checkRegex(){let q=_oq+Bf8;if(this[q])return this[q];return this._make(Bf8,q)}_make(q,K){let _=this.regexPrefix.replace(PJ_,WJ_[q]),z=this.ignoreCase?new RegExp(_,"i"):new RegExp(_);return qT6(this,K,z)}}var GJ_=({pattern:q,mark:K},_)=>{let z=!1,Y=q;if(Y.indexOf("!")===0)z=!0,Y=Y.substr(1);Y=Y.replace($J_,"!").replace(AJ_,"#");let $=DJ_(Y);return new Ooq(q,K,Y,_,z,$)};class woq{constructor(q){this._ignoreCase=q,this._rules=[]}_add(q){if(q&&q[$oq]){this._rules=this._rules.concat(q._rules._rules),this._added=!0;return}if(gf8(q))q={pattern:q};if(fJ_(q.pattern)){let K=GJ_(q,this._ignoreCase);this._added=!0,this._rules.push(K)}}add(q){return this._added=!1,zoq(gf8(q)?ZJ_(q):q).forEach(this._add,this),this._added}test(q,K,_){let z=!1,Y=!1,$;this._rules.forEach((O)=>{let{negative:w}=O;if(Y===w&&z!==Y||w&&!z&&!Y&&!K)return;if(!O[_].test(q))return;z=!w,Y=w,$=w?_J_:O});let A={ignored:z,unignored:Y};if($)A.rule=$;return A}}var TJ_=(q,K)=>{throw new K(q)},fi=(q,K,_)=>{if(!gf8(q))return _(`path must be a string, but got \`${K}\``,TypeError);if(!q)return _("path must not be empty",TypeError);if(fi.isNotRelative(q))return _(`path should be a \`path.relative()\`d string, but got "${K}"`,RangeError);return!0},joq=(q)=>wJ_.test(q);fi.isNotRelative=joq;fi.convert=(q)=>q;class Hoq{constructor({ignorecase:q=!0,ignoreCase:K=q,allowRelativePaths:_=!1}={}){qT6(this,$oq,!0),this._rules=new woq(K),this._strictPathCheck=!_,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(q){if(this._rules.add(q))this._initCache();return this}addPattern(q){return this.add(q)}_test(q,K,_,z){let Y=q&&fi.convert(q);return fi(Y,q,this._strictPathCheck?TJ_:Aoq),this._t(Y,K,_,z)}checkIgnore(q){if(!jJ_.test(q))return this.test(q);let K=q.split(eG6).filter(Boolean);if(K.pop(),K.length){let _=this._t(K.join(eG6)+eG6,this._testCache,!0,K);if(_.ignored)return _}return this._rules.test(q,!1,Bf8)}_t(q,K,_,z){if(q in K)return K[q];if(!z)z=q.split(eG6).filter(Boolean);if(z.pop(),!z.length)return K[q]=this._rules.test(q,_,Ic6);let Y=this._t(z.join(eG6)+eG6,K,_,z);return K[q]=Y.ignored?Y:this._rules.test(q,_,Ic6)}ignores(q){return this._test(q,this._ignoreCache,!1).ignored}createFilter(){return(q)=>!this.ignores(q)}filter(q){return zoq(q).filter(this.createFilter())}test(q){return this._test(q,this._testCache,!0)}}var JN1=(q)=>new Hoq(q),vJ_=(q)=>fi(q&&fi.convert(q),q,Aoq),Joq=()=>{let q=(_)=>/^\\\\\?\\/.test(_)||/["<>|\u0000-\u001F]+/u.test(_)?_:_.replace(/\\/g,"/");fi.convert=q;let K=/^[a-z]:\//i;fi.isNotRelative=(_)=>K.test(_)||joq(_)};if(typeof process<"u"&&process.platform==="win32")Joq();Ff8.exports=JN1;JN1.default=JN1;Ff8.exports.isPathValid=vJ_;qT6(Ff8.exports,Symbol.for("setupWindows"),Joq)});var foq=m((qyA,Doq)=>{var Woq=U6("child_process"),Moq=Woq.spawn,kJ_=Woq.exec;Doq.exports=function(q,K,_){if(typeof K==="function"&&_===void 0)_=K,K=void 0;if(q=parseInt(q),Number.isNaN(q))if(_)return _(Error("pid must be a number"));else throw Error("pid must be a number");var z={},Y={};switch(z[q]=[],Y[q]=1,process.platform){case"win32":kJ_("taskkill /pid "+q+" /T /F",_);break;case"darwin":MN1(q,z,Y,function($){return Moq("pgrep",["-P",$])},function(){Xoq(z,K,_)});break;default:MN1(q,z,Y,function($){return Moq("ps",["-o","pid","--no-headers","--ppid",$])},function(){Xoq(z,K,_)});break}};function Xoq(q,K,_){var z={};try{Object.keys(q).forEach(function(Y){if(q[Y].forEach(function($){if(!z[$])Poq($,K),z[$]=1}),!z[Y])Poq(Y,K),z[Y]=1})}catch(Y){if(_)return _(Y);else throw Y}if(_)return _()}function Poq(q,K){try{process.kill(parseInt(q,10),K)}catch(_){if(_.code!=="ESRCH")throw _}}function MN1(q,K,_,z,Y){var $=z(q),A="";$.stdout.on("data",function(j){var j=j.toString("ascii");A+=j});var O=function(w){if(delete _[q],w!=0){if(Object.keys(_).length==0)Y();return}A.match(/\d+/g).forEach(function(j){j=parseInt(j,10),K[q].push(j),K[j]=[],_[j]=1,MN1(j,K,_,z,Y)})};$.on("close",O)}});var _q="Bash";function XN1(){return`A powerful search tool built on ripgrep
511
512 Usage:
513 - ALWAYS use ${n3} for search tasks. NEVER invoke \`grep\` or \`rg\` as a ${_q} command. The ${n3} tool has been optimized for correct permissions and access.

Callers 5

b8Function · 0.85
j8Function · 0.85
irqFunction · 0.85
d$6Function · 0.85
jwFunction · 0.85

Calls 14

X8Function · 0.85
r8Function · 0.85
kBFunction · 0.85
s1Function · 0.85
UrqFunction · 0.85
NFunction · 0.85
H6Function · 0.85
dFunction · 0.85
YN1Function · 0.85
filterMethod · 0.80
nowMethod · 0.80
KFunction · 0.70

Tested by

no test coverage detected