@anthropic-ai/claude-agent-sdk 0.3.324 → 0.3.326
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.
- package/README.md +1 -1
- package/bridge.mjs +96 -96
- package/browser-sdk.d.ts +7 -0
- package/browser-sdk.js +73 -71
- package/core-2h2qc9qv.mjs +18 -0
- package/core-9sxfsmzx.mjs +18 -0
- package/{core-qe0dk8na.mjs → core-ba5rrckm.mjs} +2 -2
- package/core-dnsvg8nc.mjs +53 -0
- package/{core-hjrk2537.mjs → core-h6r54bwv.mjs} +2 -2
- package/core-k67vj6j9.mjs +20 -0
- package/core-qbjntcdf.mjs +18 -0
- package/core-qj4dtgyt.mjs +17 -0
- package/core-rn7tc54w.mjs +17 -0
- package/core-sstebd83.mjs +18 -0
- package/core-td7rt8zt.mjs +17 -0
- package/{core-mjr5v0tc.mjs → core-tf03rfab.mjs} +3 -3
- package/core-x4kwpwv9.mjs +16 -0
- package/core-y6bhrwmk.mjs +47 -0
- package/{core-nbx2rjdx.mjs → core-ya1m7gzj.mjs} +3 -3
- package/core.d.ts +1 -0
- package/core.mjs +11 -11
- package/manifest.json +22 -22
- package/manifest.zst.json +26 -26
- package/package.json +25 -21
- package/sdk-tools.d.ts +7 -6
- package/sdk.d.ts +175 -123
- package/sdk.mjs +88 -85
- package/core-4tdxk2rb.mjs +0 -16
- package/core-7sc5aw3j.mjs +0 -17
- package/core-de9edyhn.mjs +0 -19
- package/core-dtdat34e.mjs +0 -45
- package/core-qkncpzfw.mjs +0 -42
- package/core-s4as5f4b.mjs +0 -18
- package/core-ttsjec9g.mjs +0 -17
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
|
|
2
|
+
|
|
3
|
+
// Version: 0.3.326
|
|
4
|
+
|
|
5
|
+
//! symbol-dispose-prelude: defines Symbol.dispose and Symbol.asyncDispose if missing, for this bundle's `using`.
|
|
6
|
+
if (typeof Symbol.dispose !== 'symbol') {
|
|
7
|
+
try {
|
|
8
|
+
Symbol.dispose = Symbol.for('Symbol.dispose')
|
|
9
|
+
} catch {}
|
|
10
|
+
}
|
|
11
|
+
if (typeof Symbol.asyncDispose !== 'symbol') {
|
|
12
|
+
try {
|
|
13
|
+
Symbol.asyncDispose = Symbol.for('Symbol.asyncDispose')
|
|
14
|
+
} catch {}
|
|
15
|
+
}
|
|
16
|
+
import{createRequire as gd}from"node:module";var dd=Object.defineProperty;var cd=(e)=>e;function pd(e,m){this[e]=cd.bind(null,m)}var K=(e,m)=>{for(var P in m)dd(e,P,{get:m[P],enumerable:!0,configurable:!0,set:pd.bind(m,P)})};var Zn=gd(import.meta.url),fd=Symbol.dispose||Symbol.for("Symbol.dispose"),hd=Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose"),y=(e,m,P)=>{if(m!=null){if(typeof m!=="object"&&typeof m!=="function")throw TypeError('Object expected to be assigned to "using" declaration');var J;if(P)J=m[hd];if(J===void 0)J=m[fd];if(typeof J!=="function")throw TypeError("Object not disposable");e.push([P,J,m])}else if(P)e.push([P]);return m},b=(e,m,P)=>{var J=typeof SuppressedError==="function"?SuppressedError:function(fe,ve,xe,Re){return Re=Error(xe),Re.name="SuppressedError",Re.error=fe,Re.suppressed=ve,Re},Z=(fe)=>m=P?new J(fe,m,"An error was suppressed during disposal"):(P=!0,fe),pe=(fe)=>{while(fe=e.pop())try{var ve=fe[1]&&fe[1].call(fe[2]);if(fe[0])return Promise.resolve(ve).then(pe,(xe)=>(Z(xe),pe()))}catch(xe){Z(xe)}if(P)throw m};return pe()};function Fo(e){return e}function k(e){return Fo(e)}function te(e){return Fo(e)}function No(e){return Fo(e)}class u extends Error{telemetryMessage;errorClass;constructor(e,m,P){super(e);this.name="TelemetrySafeError",this.telemetryMessage=m??e,this.errorClass=P}}class Mt extends u{}var hn=(e,m)=>{try{if(e!==null&&typeof e==="object"&&!("telemetryMessage"in e)&&Object.isExtensible(e))Object.assign(e,{telemetryMessage:m})}catch{}return e},md=["AggregateError","Error","EvalError","RangeError","ReferenceError","SuppressedError","SyntaxError","TypeError","URIError"],Mh=new Set(md);var D=(e,m)=>{try{if(e!==null&&typeof e==="object"&&Object.isExtensible(e)){let P=e,J=Object.entries(m).filter(([Z,pe])=>pe!==void 0&&!(Z in P));Object.assign(P,Object.fromEntries(J))}}catch{}return e},Fh=Symbol("telemetryChildExitStatus");function _n(e){try{if(e!==null&&typeof e==="object"&&"telemetryMessage"in e&&typeof e.telemetryMessage==="string")return e.telemetryMessage}catch{}return}function U(e){return e instanceof Error?e:Error(String(e))}function E(e){return e instanceof Error?e.message:String(e)}function r(e){if(e&&typeof e==="object"&&"code"in e&&typeof e.code==="string")return e.code;return}function Ge(e){return Sd(r(e))}function Sd(e){return e&&/^[A-Z][A-Z0-9_]{0,63}$/.test(e)?No(e):void 0}function Uo(e){if(typeof e!=="string")return;return/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(e)?No(e):k("nonconforming")}function h(e){return r(e)==="ENOENT"}function me(e){let m=r(e);return m==="ENOENT"||m==="ENOTDIR"}function Ho(e){return r(e)==="EISDIR"}function Sn(e){let m=e.message?`${e.name}: ${e.message}`:e.name,P=e.stack;if(!P)return m;if(P.startsWith(m))return P;let J=P.split(`
|
|
17
|
+
`),Z=J[0]??"",pe=Z===e.name||Z.startsWith(`${e.name}:`)?J.slice(1):J;return[m,...pe].join(`
|
|
18
|
+
`)}var yd=new Set(["ENOENT","EACCES","EPERM","ENOTDIR","ELOOP","ENAMETOOLONG","EROFS"]);function Nt(e){return _d(r(e))}function _d(e){return e!==void 0&&yd.has(e)}function a(e,m){return e}var Wi=globalThis.process?.getBuiltinModule?.("async_hooks"),gr=Wi?(e)=>Wi.AsyncResource.bind(e):(e)=>e;function d(e){if(!e)return!1;if(typeof e==="boolean")return e;let m=String(e).toLowerCase().trim();return["1","true","yes","on"].includes(m)}function ee(e){if(e===void 0)return!1;if(typeof e==="boolean")return!e;let m=String(e).toLowerCase().trim();return["0","false","no","off"].includes(m)}function p(){let e=new Set;return{subscribe(m){let P=gr(m);return e.add(P),()=>{e.delete(P)}},emit(...m){let P;for(let J of e)try{J(...m)}catch(Z){(P??=[]).push(Z)}if(P)throw P.length===1?P[0]:AggregateError(P,"Signal listener(s) threw")},clear(){e.clear()}}}import{appendFile as Di,lstat as zg,mkdir as Lu,rename as Iu,stat as Jg,symlink as Yg,unlink as Mi}from"fs/promises";import{basename as Xg,dirname as Pr,isAbsolute as Zg,join as pr,resolve as Bu}from"path";import{createHash as Gi,randomBytes as bd,randomUUID as Q}from"crypto";function Bo(e){return e}var $i="[\\w-]{1,63}",kd=new RegExp(`^${$i}$`);var tm=new RegExp(`^a(?:${$i}-)?[0-9a-f]{16}$`);function Vi(e,m){let P=Buffer.from(m.replace(/-/g,""),"hex"),J=Gi("sha1").update(P).update(Buffer.from(e,"utf8")).digest();J[6]=J[6]&15|80,J[8]=J[8]&63|128;let Z=J.subarray(0,16).toString("hex");return`${Z.slice(0,8)}-${Z.slice(8,12)}-${Z.slice(12,16)}-${Z.slice(16,20)}-${Z.slice(20,32)}`}var xd="3ab19d7e-9f35-45c2-926e-75e271cc60b3";function qi(){let e=process.env.CLAUDE_CODE_REMOTE_SESSION_ID?.trim();return e?Vi(e,xd):null}function Ed(){if(!d(process.env.CLAUDE_CODE_CHILD_SESSION)||qi()===null)return!1;let e=process.argv??[],m=e.indexOf("--");return!e.slice(0,m===-1?void 0:m).some((J,Z)=>J==="--sdk-url"?Boolean(e[Z+1]):J.startsWith("--sdk-url=")&&J!=="--sdk-url=")&&!(e[2]==="mcp"&&e[3]==="serve")}function zi(){return Ed()&&!d(process.env.CLAUDE_CODE_DISABLE_NESTED_SESSION_ID)?null:qi()}function Ie(e,m){let P=0;for(let J of e)P+=+!!m(J);return P}function f(e){return[...new Set(e)]}import{basename as Qi,dirname as $o,join as Td}from"path";var Cd;function c(){return Cd===!0}class s{#e;#t=new WeakMap;constructor(e){this.#e=e}of(e){let m=this.#t.get(e);if(m!==void 0)return m;let P=this.#e();return this.#t.set(e,P),P}}function Ji(e){return typeof e==="object"&&e!==null}function C(e,m){return wd(e,m,Object.entries,!0)}function wd(e,m,P,J){let Z=new Map,pe=[[e,m]];while(pe.length>0){let[fe,ve]=pe.pop();if(!Ji(fe)||!Ji(ve)){if(fe!==ve)return!1;continue}let xe=Z.get(fe);if(xe!==void 0){if(xe.has(ve))continue;if(!J)return!1;xe.add(ve)}else Z.set(fe,new Set([ve]));let Re=new Map(P(ve)),Ae=P(fe);if(!Rd(fe,ve)||Ae.length!==Re.size)return!1;for(let[De,Ke]of Ae){if(!Re.has(De))return!1;pe.push([Ke,Re.get(De)])}}return!0}function Rd(e,m){if(Array.isArray(e)||Array.isArray(m))return Array.isArray(e)&&Array.isArray(m)&&e.length===m.length;return Yi(e)&&Yi(m)}function Yi(e){let m=Object.getPrototypeOf(e);return m===Object.prototype||m===null}class Ko{walked=new Map;folderIsLink=new Map;managedMcp=null;clearWalk(){this.walked.clear(),this.folderIsLink.clear()}noteWalked(e,m,P){if(!this.walked.has(e)){let J=P();this.walked.set(e,J===null?null:{link:J,read:m})}}forgetWalked(e){this.walked.delete(e)}linkOf(e){return this.walked.get(e)?.link??null}isLinked(e){return this.linkOf(e)!==null}all(){return[...this.walked.values(),this.managedMcp].filter((e)=>e!==null)}}function gn({file:e,folder:m,linked:P,posix:J}){if(!J)return"not_evaluated";if(e===void 0||m===void 0)return P?"symlinked":"unknown";if(e.uid!==0||m.uid!==0)return"not_admin_owned";let Z=e.mode|m.mode;if((Z&2)!==0)return"other_writable";if((Z&16)!==0)return"group_writable";return P?"symlinked":"protected"}function mn({file:e,folder:m,euid:P,groups:J,posix:Z}){if(!Z||P===void 0)return;if(P===0)return!0;let pe=[e,m].filter((ve)=>ve!==void 0),fe=pe.map((ve)=>{if(ve.uid===P||(ve.mode&2)!==0)return!0;if((ve.mode&16)===0)return!1;return ve.gid===void 0?void 0:J().includes(ve.gid)});if(fe.includes(!0))return!0;return pe.length<2||fe.includes(void 0)?void 0:!1}class jo{documents=new Map;folderOwners=new Map;siblingRecords=new Map;setsOrgPin=!1;clear(){this.documents.clear(),this.folderOwners.clear(),this.siblingRecords.clear(),this.setsOrgPin=!1}note(e,m){this.documents.set(e,m)}all(){return[...this.documents]}}function Xi(){return{answers:null,computed:null,pass:Promise.resolve(),queuedFor:void 0,isAnnouncing:!1,askedOf:"",askedAbout:null,visited:[],unsettled:new Set}}class Go{holders=0;tiers;baseline;lingering;tier(e){if(this.holders===0&&this.lingering!==void 0){let m=this.lingering();if(m===void 0)this.lingering=void 0;this.tiers=m}return this.tiers?.get(e)}engage(e,m){let P;if(this.holders===0){let Z=e(),pe=m?.()??Z;if(this.lingering!==void 0)P={tiers:this.tiers,lingering:this.lingering},this.lingering=void 0;this.tiers=Z,this.baseline=pe}this.holders++;let J=!1;return{release:()=>{if(J)return{last:!1};if(J=!0,this.holders--,this.holders>0)return{last:!1};return this.tiers=void 0,this.lingering=void 0,this.baseline=void 0,{last:!0}},abandon:()=>{if(J)return;if(J=!0,this.holders--,this.holders===0)this.tiers=P?.tiers,this.lingering=P?.lingering,this.baseline=void 0}}}replace(e){if(this.holders!==1)throw Error("the held copy is shared");this.tiers=e(),this.baseline=this.tiers}whileLive(e){let m=this.tiers,P=this.lingering;this.tiers=void 0,this.lingering=void 0;try{return e()}finally{this.tiers=m,this.lingering=P}}baselineTier(e){return this.baseline?.get(e)}differingTiers(e){return this.baseline===void 0?[]:Ad(this.baseline,e)}rebaseline(e,m){if(this.baseline===void 0)return;let P=new Map(this.baseline);for(let J of m){let Z=e.get(J);if(Z===void 0)P.delete(J);else P.set(J,Z)}this.baseline=P}linger(e,m){if(this.holders===0)this.tiers=e,this.lingering=m,this.baseline=void 0}isHeld(){return this.holders>0}}function Wo(e){return e!==null&&Object.keys(e).length===0?null:e}function Zi(e){return{...e,settings:Wo(e.settings),unfiltered:Wo(e.unfiltered),...e.legacy!==void 0&&{legacy:Wo(e.legacy)}}}function Ad(e,m){return[...e.keys(),...[...m.keys()].filter((P)=>!e.has(P))].filter((P)=>{let J=e.get(P),Z=m.get(P);return!C(J&&Zi(J),Z&&Zi(Z))})}var lt=["forceLoginOrgUUID","forceLoginMethod","forceLoginGatewayUrl"];class ge{mergedSettings=null;perSource=new Map;parsedFiles=new Map;readBefore=new Set;failedAtFirstRead=new Set;lastReadSettings=new Map;keptCopiesServed=new Set;failedRereads;firstReads=new Map;ownWritesBeforeFirstCheck=new Map;firstReadsChecked=!1;hasGivenSettings=new Map;readsDisagreed=!1;comparison;namesLastListed=new Map;listingFailed=!1;isChangeNoticeWithheld=!1;hasStateSubscriber=!1;managedDocumentLinks=new Ko;managedFileProtections=new jo;folderListings=new Map;rawFolderListings=new Map;frozenMembership=void 0;policyLayerEpoch=0;managedReread=void 0;managedRereadGaveUp=!1;managedFileReads=new Map;primedFiles=new Set;policyWalks=0;walkedFolders=new Map;policy={};lastPolicyEnvComposition=null;isLoadingFromDisk=!1;autoModeUntrustedSourceWarned=!1;parentLeftOutReason=null;changed=p();internalWrites=new Map;hookBlockedFiles=new Set;hookVerdictRuns=new Map;configChangeGate;enabledSources;inlineFlagParse;repoTierFreeze;constructor(e){this.repoTierFreeze=e?.repoTierFreeze??new Go}hookedMerge=Xi();pluginBase;pluginAgentSettingProvider;subagentStatusLinePluginContext;epoch=0;systemSpaceServingLogged=!1;systemAttestationContradicted=!1;backendReadResetTail=Promise.resolve();backgroundWorkTail=Promise.resolve();invalidated=p();pluginBaseLoaded=!1;primer;lastSeededUserLayer;localStoreProbes=new ea;retained=new Map;retainedListings=new Map;noteRead(e,m,P){let J=m.settings===null?m.errors.find((Z)=>Z.errorClass==="unreadable"):void 0;if(J!==void 0){let Z=!this.readBefore.has(e);if(!Z||!this.failedAtFirstRead.has(e))this.failedRereads?.count(J,P,Z);if(Z)this.failedAtFirstRead.add(e);if(J.errno==="ERR_FILE_TOO_LARGE")this.lastReadSettings.delete(e);return}if(this.failedAtFirstRead.delete(e),this.keptCopiesServed.delete(e),m.settings===null)this.lastReadSettings.delete(e);else this.lastReadSettings.set(e,m.settings);if(m.loadState==="absent")this.readBefore.delete(e);else this.readBefore.add(e)}settingsAtLastRead(e){return this.lastReadSettings.get(e)}noteSaved(e,m){this.keptCopiesServed.delete(e),this.lastReadSettings.set(e,m)}forgetLastRead(e){return this.lastReadSettings.delete(e),this.keptCopiesServed.delete(e)}noteKeptCopyServed(e){this.keptCopiesServed.add(e)}noteFirstRead(e,m){if(!this.firstReadsChecked&&!this.firstReads.has(e))this.firstReads.set(e,m)}noteReadFromDisk(e,m){let P=this.hasGivenSettings.get(e);if(P===void 0||m)this.readsDisagreed||=P===!1,this.hasGivenSettings.set(e,m);else if(P)if(this.comparison===void 0)this.readsDisagreed=!0;else this.comparison.lostAFile=!0}noteFolderListed(e,m){let P=new Set(m==="failed"?[]:m);for(let Z of this.hasGivenSettings.keys())if($o(Z)===e&&!P.has(Qi(Z)))this.noteReadFromDisk(Z,!1);let J=this.namesLastListed.get(e);if(J!==void 0)for(let Z of P){let pe=Td(e,Z);if(!J.has(Z)&&!this.hasGivenSettings.has(pe))this.hasGivenSettings.set(pe,!1)}this.namesLastListed.set(e,P),this.listingFailed||=m==="failed"}takeMisread(e){if(this.mergedSettings!==null&&!this.readsDisagreed&&!this.listingFailed)return!1;let m={lostAFile:!1};this.comparison=m;let P=this.listingFailed;this.listingFailed=!1;try{this.invalidateAll(),e()}catch(Z){throw this.listingFailed||=P,Z}finally{this.comparison=void 0}if(m.lostAFile)return this.invalidateAll(),!1;let J=this.readsDisagreed;if(this.readsDisagreed=!1,this.listingFailed)this.invalidateAll();return J}managedRereadInFlight(){return this.managedReread}beginManagedReread(e){this.managedReread=e}releaseManagedReread(e){if(this.managedReread===e)this.managedReread=void 0}giveUpManagedReread(){this.managedRereadGaveUp=!0}managedRereadGivenUp(){return this.managedRereadGaveUp}noteRawFolderListing(e,m){let P=this.rawFolderListings.get(e),J=new Set(P?.names),Z=P?.common,pe=Z;if(m!=="failed"){let fe=m==="absent"?[]:m;for(let ve of fe)J.add(ve);pe=new Set(Z===void 0?fe:fe.filter((ve)=>Z.has(ve)))}this.rawFolderListings.set(e,{names:J,common:pe,failed:(P?.failed??!1)||m==="failed"})}rawFolderListing(e){return this.rawFolderListings.get(e)}frozenFolderMembership(e){let m=this.frozenMembership?.get(e);if(m===void 0)return;return f([...m,...this.rawFolderListings.get(e)?.names??[]]).sort()}freezeManagedFolderMembership(e){let m=new Map;for(let P of f([...this.rawFolderListings.keys(),...this.folderListings.keys(),...e.keys()]))m.set(P,f([...this.rawFolderListings.get(P)?.names??[],...this.primedFolderListing(P)??[],...e.get(P)??[]]).sort());this.frozenMembership=m,this.dropDerivedCaches("policySettings")}installRereadPolicyDocument(e,m){this.parsedFiles.set(e,m),this.noteReadFromDisk(e,m.settings!==null),this.primedFiles.delete(e),this.managedDocumentLinks.forgetWalked(e),this.dropDerivedCaches("policySettings")}noteOwnWrite(e,m){if(!this.firstReadsChecked)this.ownWritesBeforeFirstCheck.set(e,{writes:(this.ownWritesBeforeFirstCheck.get(e)?.writes??0)+1,contentHash:m})}withdrawOwnWrite(e){let m=this.ownWritesBeforeFirstCheck.get(e);if(m!==void 0&&m.writes>1)this.ownWritesBeforeFirstCheck.set(e,{...m,writes:m.writes-1});else this.ownWritesBeforeFirstCheck.delete(e)}forgetFirstReads({checkAgain:e=!1}={}){if(this.firstReads.clear(),this.ownWritesBeforeFirstCheck.clear(),e)this.firstReadsChecked=!1,this.hasGivenSettings.clear(),this.namesLastListed.clear(),this.readsDisagreed=!1,this.listingFailed=!1,this.isChangeNoticeWithheld=!1,this.readBefore.clear(),this.failedAtFirstRead.clear(),this.lastReadSettings.clear(),this.keptCopiesServed.clear()}setPluginBase(e){this.pluginBase=e,this.pluginBaseLoaded=!0}clearPluginBase(){this.pluginBase=void 0,this.pluginAgentSettingProvider=void 0,this.subagentStatusLinePluginContext=void 0}invalidateAll(e){if(this.epoch++,this.mergedSettings=null,this.perSource.clear(),this.parsedFiles.clear(),this.managedDocumentLinks.clearWalk(),this.managedFileProtections.clear(),this.primedFiles.clear(),this.policyWalks=0,this.walkedFolders.clear(),this.folderListings.clear(),this.rawFolderListings.clear(),this.frozenMembership=void 0,this.policyLayerEpoch++,this.managedReread=void 0,this.managedRereadGaveUp=!1,this.policy={},e?.userLayer==="retain"&&c()&&this.primer!==void 0){for(let[m,P]of this.retained)this.parsedFiles.set(m,P.parsed),this.primedFiles.add(m);for(let[m,P]of this.retainedListings)this.folderListings.set(m,P.names)}else this.retained.clear(),this.retainedListings.clear();this.invalidated.emit()}invalidatePolicyLayer(){this.mergedSettings=null,this.perSource.delete("policySettings"),this.policy={},this.frozenMembership=void 0,this.managedReread=void 0,this.policyLayerEpoch++}onInvalidate(e){return this.invalidated.subscribe(e)}seedParsedFile(e,m,P,J){if(J!==this.epoch)return!1;let Z=this.parsedFiles.get(e),pe=Z!==void 0&&Vo(Z,P),fe=!pe,ve=pe?Z:P;if(this.parsedFiles.set(e,ve),this.noteRead(e,ve,m==="policySettings"),m==="userSettings")this.lastSeededUserLayer={path:e,parsed:ve};if(fe||this.primedFiles.has(e))this.primedFiles.add(e);let xe=this.retained.get(e);if(xe!==void 0)xe.parsed=ve;if(fe)this.dropDerivedCaches(m);return!0}walkReadDiffers(e,m){let P=this.parsedFiles.get(e);return P!==void 0&&!this.primedFiles.has(e)&&!C(P,m)}unseedParsedFile(e,m,P){if(P!==this.epoch)return;if(this.retained.delete(e),!this.primedFiles.has(e)||m==="policySettings"&&this.policyWalks>0)return;this.primedFiles.delete(e),this.parsedFiles.delete(e),this.dropDerivedCaches(m)}dropDerivedCaches(e){if(this.perSource.delete(e),this.mergedSettings=null,e==="policySettings")this.policy={}}primedFolderListing(e){return c()?this.folderListings.get(e):void 0}folderListingForPolicyWalk(e){if(!c())return;this.policyWalks++;let m=this.folderListings.get(e);if(!this.walkedFolders.has(e)||m!==void 0)this.walkedFolders.set(e,m??null);return m}noteWalkListing(e,m){if(!c())return;this.walkedFolders.set(e,m)}get policyWalkCount(){return this.policyWalks}policyInstallVerdict(e,m,P){let J=this.parsedFiles.get(e);if(J===void 0||Vo(J,m))return"install";if(!this.primedFiles.has(e))return"raced";if(this.policyWalks===0)return"install";return this.policyWalks>P?"raced":"deferred"}folderInstallVerdict(e,m,P){if(!this.walkedFolders.has(e))return this.hasParsedDropInOutside(e,m)?"raced":"install";let J=this.walkedFolders.get(e);if(J!==null&&J!==void 0&&C(J,m))return"install";return this.policyWalks>P?"raced":"deferred"}seedFolderListing(e,m,P){if(P!==this.epoch)return!1;let J=this.folderListings.get(e);this.folderListings.set(e,m);let Z=this.retainedListings.get(e);if(Z!==void 0)Z.names=m;if(J!==void 0&&!C(J,m))this.dropDerivedCaches("policySettings");return!0}walkReadManagedFileIn(e,m){for(let[P,J]of this.parsedFiles)if(!P.includes("\x00")&&!this.primedFiles.has(P)&&(J.settings!==null||J.errors.length>0)&&(P===e||$o(P)===m))return!0;return!1}walkRead(e){return this.parsedFiles.has(e)&&!this.primedFiles.has(e)}parsedDropInNames(e){let m=[];for(let P of this.parsedFiles.keys())if(!P.includes("\x00")&&!this.primedFiles.has(P)&&$o(P)===e)m.push(Qi(P));return m}hasParsedDropInOutside(e,m){let P=new Set(m);return this.parsedDropInNames(e).some((J)=>!P.has(J))}clearFolderListing(e,m){if(m!==this.epoch)return;if(this.retainedListings.delete(e),!this.folderListings.has(e)||this.walkedFolders.has(e))return;this.folderListings.delete(e),this.dropDerivedCaches("policySettings")}retainLayer(e,m){let P=this.parsedFiles.get(e),J={parsed:P!==void 0&&Vo(P,m)?P:m};return this.retained.set(e,J),()=>{if(this.retained.get(e)===J)this.retained.delete(e)}}dropRetainedLayer(e){this.retained.delete(e)}retainFolderListing(e,m){let P={names:m};return this.retainedListings.set(e,P),()=>{if(this.retainedListings.get(e)===P)this.retainedListings.delete(e)}}}class ea{ownerUidsByRoot=new Map;realHomeDir=void 0;canonicalRootOwnerUids(e,m){let P=this.ownerUidsByRoot.get(e);if(P!==void 0)return P;let J=m(e);return this.ownerUidsByRoot.set(e,J),J}hasCanonicalRootOwnerUids(e){return this.ownerUidsByRoot.has(e)}primeCanonicalRootOwnerUids(e,m){if(this.ownerUidsByRoot.has(e))return!1;return this.ownerUidsByRoot.set(e,m),!0}clearCanonicalRootOwnerUids(){this.ownerUidsByRoot.clear()}normalizedRealHomeDir(e){return this.realHomeDir??=e(),this.realHomeDir}clearNormalizedRealHomeDir(){this.realHomeDir=void 0}}var qo=new s(()=>new ge);function Vo(e,m){return C({...e,fileOwner:void 0},{...m,fileOwner:void 0})}var Pd=a({value:!1},(e)=>{e.value=!1}),Od=a({value:void 0},(e)=>{e.value=void 0}),Ld=a({value:void 0},(e)=>{e.value=void 0});function Qr(){return{sent:new Set,rejected:new Set,declaredTools:void 0,noChannelTools:void 0,turnDeniedTools:void 0,declaredToolsDecided:!1,leadingTools:void 0,nameOnlyAnnouncements:new Set,surfacedOnWire:new Set,definedByValue:new Set,inlineToolsRefusal:{rejectedHeader:void 0,announcementsByName:new Set},advisorHeld:void 0,wireShapeSeed:void 0,webSearchHistoryRejected:!1,mediaItemCap:void 0,refusedToolSchemas:new Map,systemMessagesAcceptedBy:new Set,nameOnlyEntries:{held:new Set,refused:!1,reported:void 0}}}function Id(e,m){for(let P of m.sent)Fd(e,P);for(let P of m.rejected)ta(e,P);e.wireShapeSeed=m}function zo(e){let m=Qr();if(m.declaredTools=e.declaredTools,m.noChannelTools=e.noChannelTools,m.turnDeniedTools=e.turnDeniedTools,m.declaredToolsDecided=e.declaredToolsDecided,m.leadingTools=e.leadingTools,m.advisorHeld=e.advisorHeld,e.wireShapeSeed!==void 0)Id(m,e.wireShapeSeed);let{rejectedHeader:P,announcementsByName:J}=e.inlineToolsRefusal;if(P!==void 0)Dd(m,P);Md(m,J),m.webSearchHistoryRejected=e.webSearchHistoryRejected,m.mediaItemCap=e.mediaItemCap;for(let[Z,pe]of e.refusedToolSchemas)m.refusedToolSchemas.set(Z,pe);return m.nameOnlyEntries.refused=e.nameOnlyEntries.refused,m.nameOnlyEntries.reported=e.nameOnlyEntries.reported,m}function Dd(e,m){ta(e,m),e.inlineToolsRefusal.rejectedHeader=m}function Md(e,m){for(let P of m)e.inlineToolsRefusal.announcementsByName.add(P),e.nameOnlyAnnouncements.add(P)}function Fd(e,m){if(!e.rejected.has(m))e.sent.add(m)}function ta(e,m){e.sent.delete(m),e.rejected.add(m)}import{realpathSync as na}from"node:fs";import{cwd as Nd}from"node:process";function Jo(e){return process.platform==="darwin"?e.normalize("NFC"):e}function Ud(e){if(process.platform==="linux"||e==="/")return e;return na(e)}function Xo(){let e="";if(typeof process<"u"&&typeof process.cwd==="function"&&typeof na==="function")try{let m=Nd();try{e=Jo(Ud(m))}catch{e=Jo(m)}}catch{}return e}var ra=Xo(),Yo=(()=>{if(typeof process>"u"||typeof process.cwd!=="function")return null;try{return process.cwd()}catch{return null}})();function Zo(){if(Yo===null)return null;let e=process.env.CLAUDE_CODE_SESSION_KIND;return e!==void 0&&String(e).trim()==="bg"?null:Yo}class Qo{spawner=void 0;pairings=new Map;mainEnsureInFlight=!1;mainSlotBlocked=!1;mainPointers=new Map;mainBlockedTypes=new Set;mainAtGate=new Set;allPairings(){return[...this.pairings.values()].flat()}}var Hd=/^[A-Za-z0-9_.:-]{1,256}$/,to="unreadable-tools-used-before-summary";function fr(e){return Hd.test(e)?e:to}function eo(e){let m=e.tool_use_id!==void 0?e.inner_call_index===void 0?`call
|
|
19
|
+
${e.tool_use_id}
|
|
20
|
+
`:`call
|
|
21
|
+
${e.tool_use_id}
|
|
22
|
+
${e.inner_call_index}
|
|
23
|
+
${e.tool_name??""}`:e.event_id!==void 0?`event
|
|
24
|
+
${e.event_id}
|
|
25
|
+
${e.tool_name??""}
|
|
26
|
+
${e.inner_call_index??""}`:void 0;if(m===void 0)return;return[m,e.source?.type??"",e.source?.id??"",e.touched?.kind??"",e.touched?.id??"",e.touched?.action??"",e.touched?.to??""].join(`
|
|
27
|
+
`)}function br(e){return JSON.stringify([e.tool_name??null,e.server??null,e.mcp_tool_name??null,e.carried===!0,e.implicit===!0,e.source===void 0?null:[e.source.type,e.source.id],e.touched===void 0?null:[e.touched.kind,e.touched.id,e.touched.action,e.touched.to??null]])}function Ir(e){return`${e.type}
|
|
28
|
+
${e.id??""}
|
|
29
|
+
${e.via}
|
|
30
|
+
${e.started??""}`}var Bd=256;function kr(e){return e??""}class es{#e=new Set;#t=0;#n=!1;#s;#r;#o=!1;#a=new Set;#u=!1;#d;#g=new Set;#c=new Map;#l=new Map;#p=new Map;#i=new Map;#f=new Set;#S=new WeakMap;#m=!1;#y=!1;#b=!1;#h=new Set;#_;#k=[];#x=new Set;#C=0;#A=[];#w=[];#v=!1;#E=!1;#P=new Map;#T=new Map;#R=[];#O;record(e){let m=!1;for(let P of e){if(typeof P!=="string"||P==="")continue;let J=fr(P);for(let Z of this.#g)Z.push(J);if(!this.#e.has(J))this.#e.add(J),m=!0}if(m)this.#t++,this.#_?.();return m}recordForSession(e){let m=this.#h.size;for(let P of e)this.#h.add(fr(P));if(this.#h.size>m)this.#t++}holdsNamesForSession(){return this.#h.size>0}isForSession(e){return this.#h.has(e)}has(e){return this.#h.has(e)||this.#e.has(e)}recordCall(e,m,P,J,Z={}){if(P==="")return;this.#L(e,{tool_name:m,tool_use_id:P,...J!==void 0&&{server:J},...Z.mcpToolName!==void 0&&{mcp_tool_name:Z.mcpToolName},...Z.noMessage===!0&&{no_message:!0},...Z.carried===!0&&{carried:!0}},J===void 0&&Z.carried!==!0&&Z.owed!==!0&&Z.noMessage!==!0)}markNoMessage(e,m){if(m.length===0)return;let P=new Set(m),J=this.#I(e);J.records.forEach((Z,pe)=>{if(P.has(Z.tool_use_id??Z.event_id)&&Z.no_message!==!0){if(J.records[pe]={...Z,no_message:!0},J.inFile[pe]===!0)J.inFile[pe]=!1,J.owed++}})}recordEvent(e,m,P={}){if(m!==void 0&&(typeof m!=="string"||m===""))return;let J=this.#I(e),Z=m===void 0?void 0:fr(m);if(J.eventEdges.has(br({tool_name:Z,...P})))return;let pe=`event_${Q()}`;return this.#L(e,{...Z!==void 0&&{tool_name:Z},event_id:pe,...P},!1),pe}noteResumedInProcess(){this.#y=!0}needsNoticeEvent(e){let m=fr(e);return this.#y||this.#b&&![...this.#l.values()].some(({records:P})=>P.some(({tool_name:J,touched:Z,source:pe,server:fe,mcp_tool_name:ve})=>J===m&&Z===void 0&&pe===void 0&&(fe===void 0||ve!==void 0)))}recordScriptCall(e,m,P,J={}){let Z=this.#p.get(m)??0;return this.#p.set(m,Z+1),this.#L(e,{tool_name:P,tool_use_id:m,inner_call_index:Z,...J},!1),Z}recordSessionEvent(e,m={}){this.recordEvent(void 0,e,m),this.#a.add(br({...e!==void 0&&{tool_name:fr(e)},...m}))}list(e){let m=this.#I(e);return{records:()=>m.records,isIncomplete:()=>m.incomplete}}noteSessionDiskLook(){this.#o=!0}isSessionDiskLooked(){return this.#o}holdsSessionEvent(e){return this.#a.has(br({tool_name:fr(e)}))}sessionEvents(){return this.records(void 0).filter((e)=>e.event_id!==void 0&&this.#a.has(br(e)))}recordTouch(e,m,P,J){this.#L(e,{...P!==void 0&&{tool_name:P},..."toolUseId"in m?{tool_use_id:m.toolUseId,...m.innerCallIndex!==void 0&&{inner_call_index:m.innerCallIndex}}:{event_id:m.eventId},touched:J},!1)}#L(e,m,P,J=!1){let Z=this.#I(e),pe=m.tool_name===void 0?m:{...m,tool_name:fr(m.tool_name)},fe=eo(pe);if(fe!==void 0){if(Z.keys.has(fe)){let ve=pe.carried===!0?void 0:Z.carried.get(fe);if(ve!==void 0){if(Z.inFile[ve]===!0)Z.owed++;if(Z.records[ve]=pe,Z.inFile[ve]=!1,Z.carried.delete(fe),this.#i.set(fe,pe),pe.tool_name===to)this.markIncomplete(e)}return}if(!this.#i.has(fe)&&(!J||pe.no_message===!0))this.#i.set(fe,pe);if(Z.keys.add(fe),pe.carried===!0)Z.carried.set(fe,Z.records.length)}if(Z.records.push(pe),Z.inFile.push(P),pe.event_id!==void 0)Z.eventEdges.add(br(pe));if(!P)Z.owed++;if(pe.tool_name===to)this.markIncomplete(e);if(pe.tool_use_id!==void 0&&pe.inner_call_index!==void 0){let ve=this.#p.get(pe.tool_use_id)??0;if(pe.inner_call_index>=ve)this.#p.set(pe.tool_use_id,pe.inner_call_index+1)}}#I(e){let m=kr(e),P=this.#l.get(m);if(P===void 0)P={records:[],inFile:[],keys:new Set,eventEdges:new Set,carried:new Map,incomplete:!1,owed:0},this.#l.set(m,P);return P}records(e){return[...this.#l.get(kr(e))?.records??[],...this.#D(e,!0)]}#D(e,m){let P=this.#O===void 0?{}:{mark_sent_by:this.#O};return e===void 0?[...this.#T].flatMap(([J,Z])=>m||!Z?[{response_id:J,...P}]:[]):[]}recordResponse(e,m=[],P){if(P!==void 0&&this.isIncomplete(void 0))this.#O=P;for(let J of m){if(this.#T.get(J)===!0)this.#R.push(J);this.#T.delete(J)}this.#T.set(e,!1)}responsesToList(){return[...this.#T.keys()]}unreported(e,m){return{responses:this.responsesToList(),incomplete:this.isIncomplete(void 0)&&(m||this.#O!==e)}}keepUnreported({responses:e,incomplete:m}){if(e.forEach((P)=>this.recordResponse(P)),m)this.markIncomplete(void 0)}owesResponses(){return this.#D(void 0,!1).length>0}takeRecordsForEntry(e,m){let P=this.#D(e,m),[J]=P;if(J!==void 0){if(!m&&this.#R.length>0)J.listed=this.#R;this.#R=[],this.#T.forEach((fe,ve)=>this.#T.set(ve,!0))}let Z=this.#l.get(kr(e));if(Z===void 0)return P;if(!m&&Z.owed===0)return P;let pe=[];return Z.records.forEach((fe,ve)=>{if(m||!Z.inFile[ve])pe.push(fe);Z.inFile[ve]=!0}),Z.owed=0,[...pe,...P]}unsent(){return[...this.#i.values()]}noteBuilt(e,m){this.#m=!0,this.#S.set(e,m)}noteSent(e){let{own:m=[],others:P=[]}=this.#S.get(e)??{};P.forEach((J)=>this.#f.add(J));for(let J of m){let Z=eo(J);if(Z!==void 0&&this.#i.get(Z)===J)this.#i.delete(Z)}}oweUnsent(){if(!this.#m)return;let e=this.unsent();for(let m of e)this.#L(void 0,m,!1);this.markNoMessage(void 0,e.flatMap((m)=>m.tool_use_id??m.event_id??[]))}recordsNotInFile(e){let m=this.#l.get(kr(e));return[...m?.records.filter((P,J)=>!m.inFile[J])??[],...this.#D(e,!1)]}restoreRecords(e,m,P=[]){let J=this.#I(e),{records:Z,inFile:pe}=J;J.records=[],J.inFile=[],J.keys=new Set,J.eventEdges=new Set,J.carried=new Map,J.owed=0;let fe=new Set(P.map(eo));for(let xe of m){let{response_id:Re}=xe;if(Re!==void 0){if(e===void 0)this.#T.set(Re,!P.some((De)=>De.response_id===Re)),this.#O=xe.mark_sent_by??this.#O;continue}let Ae=eo(xe);this.#L(e,xe,Ae===void 0||!fe.has(Ae),!0)}let ve=new Set(J.eventEdges);Z.forEach((xe,Re)=>{if(xe.event_id!==void 0&&ve.has(br(xe)))return;this.#L(e,xe,pe[Re]===!0,!0)})}agentsOwing(){let e=[];for(let[m,P]of this.#l)if(m!==""&&(P.owed>0||P.incomplete))e.push(m);return e}isIncomplete(e){return this.#l.get(kr(e))?.incomplete===!0}derivedFrom(){return[...this.#k]}derivedFromGeneration(){return this.#C}recordDerivedFrom(e){let m=!1;for(let P of e){let J=Ir(P);if(!this.#x.has(J)){if(this.#x.add(J),this.#k.push(P),P.started===void 0)this.#P.set(J,P);m=!0}}if(m)this.#C++;return m}recordDerivedFromForSession(e){this.recordDerivedFrom([e]);let m=Ir(e);if(this.#A.some((P)=>Ir(P)===m))return!1;return this.#A.push(e),!0}derivedFromForSession(){return[...this.#w,...this.#A]}noteAnswered(e){e?.forEach((m)=>this.#P.delete(Ir(m))),this.#E||=e!==void 0||!this.#v}noteSessionLeft(e,m){let P=[...this.#P.values(),...this.#E?[e]:[]];this.#w=P.filter(({id:J})=>J!==m),this.#P=new Map(this.#w.map((J)=>[Ir(J),J])),this.#E=this.#w.length<P.length,this.#v=e.via==="fork"}replaceDerivedFrom(e){this.#k=[],this.#x.clear(),this.#C++,this.recordDerivedFrom([...e,...this.derivedFromForSession()])}markIncomplete(e){this.#I(e).incomplete=!0,this.#I(void 0).incomplete=!0}noteDelivered(e,m){this.#c.delete(e),this.#c.set(e,m);for(let P of this.#c.keys()){if(this.#c.size<=Bd)break;this.#c.delete(P)}}takeDelivered(e){let m=this.#c.get(e);return this.#c.delete(e),m}names(){return[...this.#h,...[...this.#e].filter((e)=>!this.#h.has(e))]}namesOfConversation(){return[...this.#e].filter((e)=>e===to||!this.#h.has(e))}size(){return this.#e.size}generation(){return this.#t}raiseHeaderSizeSteps(e){let m=this.#s;if(m&&e.count<=m.count&&e.bytes<=m.bytes&&(m.capped||!e.capped))return!1;return this.#s={count:Math.max(e.count,m?.count??0),bytes:Math.max(e.bytes,m?.bytes??0),capped:e.capped||m?.capped===!0},!0}reportTruncationOnce(){if(this.#n)return!1;return this.#n=!0,!0}connectorDownloadsInReach(){return this.#r}noteConnectorDownloadsInReach(e){if(this.#r!=="found")this.#r=e}connectorDataFromEarlierDownload(){return this.#u}noteConnectorDataFromEarlierDownload(){this.#u=!0}lastingConnectorDownloads(){try{return this.#d?.()}catch{return"held"}}setLastingConnectorDownloadsReader(e){this.#d=e}captureRecords(){let e=[];return this.#g.add(e),e}endCapture(e){this.#g.delete(e)}replace(e){this.clear(),this.record(e)}clear(){this.#e.clear(),this.#t++,this.#n=!1,this.#r=void 0,this.#u=!1,this.#b=!0,this.#a.clear(),this.#o=!1,this.#l.delete(kr(void 0));for(let[e,m]of this.#i)if(!this.#m||this.#f.has(m))this.#i.delete(e);this.#f.clear(),this.#T.clear(),this.#R=[],this.#O=void 0,this.#k=[],this.#x.clear(),this.#C++,this.#_?.()}setOnChange(e){this.#_=e}}class ts{#e=Qr();#t=void 0;#n;toolsUsed=new es;stickyBetas(){return this.#e}unlatchStickyBetas(){this.#e=zo(this.#e)}atisLatch(){return this.#t}replaceAtisLatch(e){this.#t=e,this.#n?.(e)}watchAtisLatch(e){this.#n=e}reset(){this.#e=Qr(),this.#t=void 0,this.toolsUsed.clear()}}var ns={inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0};function vr(e){let m=Object.create(null);return Object.assign(m,e)}function oa(e){let m=vr();for(let[P,J]of Object.entries(e))m[P]={...J};return m}class rs{#e=0;#t=0;#n=0;#s=0;#r=Date.now();#o=void 0;#a=0;#u=0;#d=0;#g=ns;#c=0;#l=0;#p=new Map;#i=ns;#f=!1;#S=0;#m=vr();#y=void 0;#b=null;#h=null;#_=null;spendRecorded=p();totalCostUSD(){return this.#e}restoredCostUSD(){return this.#d}restoredTokens(){return this.#g}sideQueryCostUSD(){return this.#c}modelCallCostUSD(){return this.#l}agentSpend(e){return this.#p.get(e)}totalAPIDuration(){return this.#t}totalAPIDurationWithoutRetries(){return this.#n}totalToolDuration(){return this.#s}totalDuration(){return Math.max(0,Date.now()-this.#r)}sessionStartTime(){return this.#o??this.#r}totalLinesAdded(){return this.#a}totalLinesRemoved(){return this.#u}hasUnknownModelCost(){return this.#f}safetyStops(){return this.#S}modelUsage(){return this.#m}usageForModel(e){return this.#m[e]}trackUsageSinceLastResult(){this.#y??=vr()}usageSinceLastResult(){return this.#y}takeUsageSinceLastResult(){let e=this.#y;if(e!==void 0)this.#y=vr();return e}totalInputTokens(){return this.#k("inputTokens")}totalOutputTokens(){return this.#k("outputTokens")}totalCacheReadInputTokens(){return this.#k("cacheReadInputTokens")}totalCacheCreationInputTokens(){return this.#k("cacheCreationInputTokens")}totalWebSearchRequests(){return this.#k("webSearchRequests")}#k(e){let m=0;for(let P of Object.values(this.#m))m+=P[e];return m}recordApiDuration(e,m){this.#t+=e,this.#n+=m}spentTokens(){return this.#i}recordSpentTokens(e){let m=this.#i;this.#i={inputTokens:m.inputTokens+e.inputTokens,outputTokens:m.outputTokens+e.outputTokens,cacheReadInputTokens:m.cacheReadInputTokens+e.cacheReadInputTokens,cacheCreationInputTokens:m.cacheCreationInputTokens+e.cacheCreationInputTokens},this.spendRecorded.emit()}recordCost(e,m,P){this.#m[P]=m,this.#e+=e,this.spendRecorded.emit()}recordSideQueryCost(e){if(Number.isFinite(e)&&e>=0)this.#c+=e,this.spendRecorded.emit()}recordModelCallCost(e){if(Number.isFinite(e)&&e>=0)this.#l+=e}replaceAgentSpend(e,m){this.#p.set(e,m)}recordToolDuration(e){this.#s+=e}recordLinesChanged(e,m){this.#a+=e,this.#u+=m}markUnknownModelCost(){this.#f=!0}recordSafetyStop(){this.#S+=1}zeroDurationsAndCostForTests(){this.#t=0,this.#n=0,this.#e=0,this.#d=0,this.#l=0}restartClock(){this.#r=Date.now(),this.anchorLogicalStart(void 0)}anchorLogicalStart(e){this.#o=e===void 0?void 0:Math.min(e,this.#r)}restore({totalCostUSD:e,totalAPIDuration:m,totalAPIDurationWithoutRetries:P,totalToolDuration:J,totalLinesAdded:Z,totalLinesRemoved:pe,lastDuration:fe,startTime:ve,modelUsage:xe,hasUnknownModelCost:Re,modelCallCostUSD:Ae},De){if(this.#_=De,this.#e=e,this.#d=e,this.#t=m,this.#n=P,this.#s=J,this.#a=Z,this.#u=pe,this.#f=Re??!1,this.#l=Ae??0,this.#p.clear(),xe)this.#m=vr(xe);if(this.#g={inputTokens:this.totalInputTokens(),outputTokens:this.totalOutputTokens(),cacheReadInputTokens:this.totalCacheReadInputTokens(),cacheCreationInputTokens:this.totalCacheCreationInputTokens()},fe!==void 0)this.#r=Date.now()-fe;this.anchorLogicalStart(ve)}registerSaver(e){this.#b=e}runSaver(e,m){(this.#b??(m?m.#b:null))?.(e)}registerTranscriptRecorder(e){this.#h=e}runTranscriptRecorder(e,m,P){(this.#h??(P?P.#h:null))?.(e,m)}snapshot(){return{ownerSessionId:this.#_,totalCostUSD:this.#e,totalAPIDuration:this.#t,totalAPIDurationWithoutRetries:this.#n,totalToolDuration:this.#s,startTime:this.#r,sessionLogicalStartTime:this.#o,totalLinesAdded:this.#a,totalLinesRemoved:this.#u,restoredCostUSD:this.#d,restoredTokens:this.#g,hasUnknownModelCost:this.#f,modelCallCostUSD:this.#l,safetyStops:this.#S,modelUsage:oa(this.#m),agentSpend:new Map(this.#p)}}restoreSnapshot(e){this.#_=e.ownerSessionId,this.#e=e.totalCostUSD,this.#t=e.totalAPIDuration,this.#n=e.totalAPIDurationWithoutRetries,this.#s=e.totalToolDuration,this.#r=e.startTime,this.#o=e.sessionLogicalStartTime,this.#a=e.totalLinesAdded,this.#u=e.totalLinesRemoved,this.#d=e.restoredCostUSD,this.#g=e.restoredTokens,this.#f=e.hasUnknownModelCost,this.#l=e.modelCallCostUSD,this.#S=e.safetyStops,this.#m=oa(e.modelUsage),this.#p=new Map(e.agentSpend)}claim(e){this.#_??=e}scopeTo(e){this.#_=e}ownerSessionId(){return this.#_}belongsTo(e){return this.#_===e}reset(e){this.#_=e,this.#e=0,this.#d=0,this.#g=ns,this.#t=0,this.#n=0,this.#s=0,this.#r=Date.now(),this.anchorLogicalStart(void 0),this.#a=0,this.#u=0,this.#f=!1,this.#l=0,this.#S=0,this.#m=vr(),this.#p.clear()}}class os{#e=new Set;#t=new Map;openQuestion=new Map;lastSwitch=new Map;stoppedUnder=new Map;consentSessionFallback(e){return this.#e.has(e)}replaceConsentSessionFallback(e,m){if(m)this.#e.add(e);else this.#e.delete(e)}sessionConsentKey(e){return this.#t.get(e)??null}replaceSessionConsentKey(e,m){if(m===null)this.#t.delete(e);else this.#t.set(e,m)}reset(){this.#e.clear(),this.#t.clear(),this.openQuestion.clear(),this.lastSwitch.clear(),this.stoppedUnder.clear()}}class ss{#e={registeredHooks:null};#t=void 0;#n=void 0;holder(){return this.#e}mainThreadAgentType(){return this.#t}replaceMainThreadAgentType(e){this.#t=e}mainThreadAgentHooks(){return this.#n}replaceMainThreadAgentHooks(e){this.#n=e}reset(){this.#e={registeredHooks:null},this.#t=void 0,this.#n=void 0}}class is{#e=new Map;skills(){return this.#e}lookup(e){return this.#e.get(e)}record(e,m){this.#e.set(e,m)}forget(e){this.#e.delete(e)}forgetAll(){this.#e.clear()}reset(){this.#e=new Map}}class as{#e=[];#t;#n;#s;#r;#o;approvedServers(){return this.#e}approveServers(e,m){for(let P of m)if(!this.#e.some((J)=>J.name===P&&J.workspaceKey===e))this.#e.push({name:P,workspaceKey:e})}registerClientsAccessor(e){this.#t=e}acquireClientsAccessor(e){if(this.#t)return()=>{};return this.#t=e,()=>{if(this.#t===e)this.#t=void 0}}clientsFromAccessor(){return this.#t?.()}registerTenantClients(e){this.#n=e}clientsFromAccessorOrTenant(){return(this.#t??this.#n)?.()}registerConnectedClientWiring(e){this.#s=e}connectedClientWiring(){return this.#s}registerToolsSwapper(e){this.#r=e}acquireToolsSwapper(e){if(this.#r)return()=>{};return this.#r=e,()=>{if(this.#r===e)this.#r=void 0}}swapServerTools(e,m,P){if(!this.#r)return!1;return this.#r(e,m,P)}registerConnections(e){this.#o=e}acquireConnections(e){if(this.#o)return()=>{};return this.#o=e,()=>{if(this.#o===e)this.#o=void 0}}connections(){return this.#o}reset(){this.#e=[],this.#t=void 0}}class ls{#e=void 0;#t=void 0;#n=void 0;#s=void 0;#r=void 0;#o=void 0;#a=!1;#u=!1;#d=void 0;#g=!1;#c=void 0;#l=void 0;#p=void 0;mainLoopModelOverride(){return this.#e}overrideMainLoopModel(e){this.#e=e}mainLoopEffortState(){return this.#t}replaceMainLoopEffortState(e){this.#t=e}initialMainLoopModel(){return this.#n}replaceInitialMainLoopModel(e){this.#n=e}initialModelSettingLayer(){return this.#s}replaceInitialModelSettingLayer(e){this.#s=e}resolvedOrgDefault(){return this.#r}replaceResolvedOrgDefault(e){this.#r=e}initialEnvDefaultModel(){return this.#o}replaceInitialEnvDefaultModel(e){this.#o=e}refusalFallbackOccurred(){return this.#a}markRefusalFallbackOccurred(e){this.#a=!0,this.#d??=e}refusalFallbackHeaderArmed(){return this.#u}armRefusalFallbackHeader(e){this.#u=!0,this.#d??=e}refusalFallbackLatchOriginRequestId(){return this.#d}silentLaneServerArmed(){return this.#g}armSilentLaneFromServer(){this.#g=!0}forgetRefusalFallbackOccurred(){this.#a=!1,this.#u=!1,this.#g=!1,this.#d=void 0}refusalFallbackModelLatch(){return this.#c}replaceRefusalFallbackModelLatch(e,m="superseded"){if(this.#c?.carriedEffort!==void 0&&e?.carriedEffort===void 0)this.#l=m;this.#c=e}unlatchRefusalFallbackModel(e){this.replaceRefusalFallbackModelLatch(void 0,e)}takeCarriedEffortEnd(){let e=this.#l;return this.#l=void 0,e}availabilityFallbackChain(){return this.#p}replaceAvailabilityFallbackChain(e){this.#p=e}reset(){this.#e=void 0,this.#t=void 0,this.#n=void 0,this.#s=void 0,this.#r=void 0,this.#o=void 0,this.#a=!1,this.#u=!1,this.#g=!1,this.#d=void 0,this.#c=void 0,this.#l=void 0,this.#p=void 0}}class us{#e=new Map;#t=0;#n=void 0;sections(){return this.#e}recordSection(e,m){this.#e.set(e,m)}forgetAllSections(){this.#e.clear()}noteInvalidation(e="other"){this.#t+=1,this.#n=e}epoch(){return this.#t}lastInvalidationReason(){return this.#n}reset(){this.#e=new Map}}class ds{#e=null;#t=null;#n=null;#s=null;#r=null;#o=0;#a=null;#u=void 0;#d=0;#g=void 0;#c=null;#l=null;#p=null;#i=null;#f=null;#S=!1;#m=null;#y=null;#b=!1;lastAPIRequest(){return this.#e}replaceLastAPIRequest(e){this.#e=e}lastCancelledAPIMessageId(){return this.#t}replaceLastCancelledAPIMessageId(e){this.#t=e}lastAPIRequestMessages(){return this.#n}replaceLastAPIRequestMessages(e){this.#n=e}lastClassifierRequests(){return this.#s}replaceLastClassifierRequests(e){this.#s=e}promptId(){return this.#r}replacePromptId(e){this.#r=e}promptIndex(){return this.#o}replacePromptIndex(e){this.#o=e}incrementPromptIndex(){return this.#o++,this.#o}lastPersonPrompt(){return this.#a}replaceLastPersonPrompt(e){this.#a=e}lastMainRequestId(){return this.#u}replaceLastMainRequestId(e,m){if(this.#u=e,this.#g=m,e===void 0)this.#d+=1}lastMainResponse(){return this.#g}mainChainReleaseCount(){return this.#d}lastMainThreadCacheTtlMs(){return this.#c}replaceLastMainThreadCacheTtlMs(e,m,P=!1){this.#c=e,this.#i=Date.now(),this.#p={ttlMs:e,model:m,requestAt:this.#i,askedAt:P?this.#p?.askedAt??this.#i:this.#i},this.#f=this.#i,this.#S=!0}isLastMainThreadAskLive(e,m){let P=this.#p;return P!==null&&P.requestAt===this.#i&&P.ttlMs===e&&P.model===m&&Date.now()-P.askedAt<e}adjustLastMainThreadCacheTtlMs(e){this.#c=e}recordLastMainThreadCacheRenewal(e){if(this.#i!==null)this.#l={requestAt:this.#i,at:Math.max(e,this.lastMainThreadCacheRenewedAt()??-1/0)}}lastMainThreadCacheRenewedAt(){let e=this.#l;return e!==null&&e.requestAt===this.#i?e.at:null}lastLiveMainThreadRequestAt(){return this.#f}lastMainThreadRequestAt(){return this.#i}mainThreadRequestedInProcess(){return this.#S}recordMainThreadTurnStart(){this.#S=!0}replaceLastMainThreadRequest(e,m){this.#i=e,this.#c=m}lastMainThreadContextTokens(){return this.#m}replaceLastMainThreadContextTokens(e){this.#m=e}stageResumeSeed(e){this.#h=e}applyResumeSeed(e){this.#h=null,this.#c=e.ttlMs,this.#i=e.requestAt,this.#p=sa(e),this.#m=e.contextTokens}#h=null;clearLastMainThreadRequest(e){let m=e!==void 0&&this.#h?.sessionId===e?this.#h:null;this.#h=null,this.#c=m?.ttlMs??null,this.#i=m?.requestAt??null,this.#p=sa(m),this.#m=m?.contextTokens??null,this.#f=null,this.#S=!1}lastApiCompletionTimestamp(){return this.#y}replaceLastApiCompletionTimestamp(e){this.#y=e}pendingPostCompaction(){return this.#b}replacePendingPostCompaction(e){this.#b=e}reset(){this.#e=null,this.#t=null,this.#n=null,this.#s=null,this.#r=null,this.#o=0,this.#a=null,this.#u=void 0,this.#g=void 0,this.#d+=1,this.#c=null,this.#i=null,this.#f=null,this.#S=!1,this.#m=null,this.#h=null,this.#y=null,this.#b=!1}}function sa(e){return e?.ask!==void 0&&e.requestAt!==null&&e.requestAt<=Date.now()?{...e.ask,requestAt:e.requestAt,askedAt:e.requestAt}:null}class cs{#e=[];#t=Object.create(null);#n=null;#s=void 0;#r=0;#o=!1;#a=0;changed=p();pendingLoopWakeup=p();tasks(){return this.#e}schedule(e){this.#e.push(e)}replaceTasks(e){this.#e=e}chainStartedAt(e){return this.#t[e]}recordChainStart(e,m){this.#t[e]=m}forgetChainStart(e){delete this.#t[e]}tickInFlightPrompt(){return this.#n}tickInFlightPlugin(){return this.#s}replaceTickInFlightPrompt(e,m){this.#n=e,this.#s=e===null?void 0:m}consecutiveKeepalives(){return this.#r}replaceConsecutiveKeepalives(e){this.#r=e}ended(){return this.#o}replaceEnded(e){this.#o=e}wakeFires(){return this.#a}recordWakeFire(){this.#a++}resetWakeFires(){this.#a=0}reset(){this.#e=[],this.#t=Object.create(null),this.#n=null,this.#s=void 0,this.#r=0,this.#o=!1,this.#a=0}}class ps{#e=!1;#t=!1;#n=!1;#s=!1;#r=!1;#o=!1;#a=!1;#u=!1;#d=!1;#g=!1;#c=!1;#l=void 0;#p=!1;#i=void 0;#f=!1;#S=!1;#m=null;#y=null;#b=null;#h=!1;#_=null;#k=!1;#x=!1;#C=!1;#A=!1;#w=!1;#v=void 0;#E=void 0;#P=void 0;#T=void 0;#R=null;#O=null;onboardingShownThisSession(){return this.#e}replaceOnboardingShownThisSession(e){this.#e=e}lspRecommendationShownThisSession(){return this.#t}replaceLspRecommendationShownThisSession(e){this.#t=e}sessionTrustAccepted(){return this.#n}replaceSessionTrustAccepted(e){this.#n=e}homeTrustDialogAccepted(){return this.#s}replaceHomeTrustDialogAccepted(e){this.#s=e}hasExitedPlanMode(){return this.#r}replaceHasExitedPlanMode(e){this.#r=e}needsPlanModeExitAttachment(){return this.#o}replaceNeedsPlanModeExitAttachment(e){this.#o=e}needsAutoModeExitAttachment(){return this.#a}replaceNeedsAutoModeExitAttachment(e){this.#a=e}memoryToggledOff(){return this.#u}replaceMemoryToggledOff(e){this.#u=e}autoMemoryOffThisSession(){return this.#d}replaceAutoMemoryOffThisSession(e){this.#d=e}memoryPausedByCommand(){return this.#c}replaceMemoryPausedByCommand(e){this.#c=e}accountMemorySessionMode(){return this.#l}replaceAccountMemorySessionMode(e,m=!1){this.#l=e,this.#p=m&&e!==void 0}accountMemorySessionModeRestored(){return this.#p}accountMemoryLaunchMode(){return this.#i}replaceAccountMemoryLaunchMode(e){this.#i=e}restoredMemoryPause(){return this.#f}replaceRestoredMemoryPause(e){this.#f=e}restoredAutoMemoryOff(){return this.#g}replaceRestoredAutoMemoryOff(e){this.#g=e}teardownUnwindRequested(){return this.#h}replaceTeardownUnwindRequested(e){this.#h=e}backgroundAutoModeSetupInFlight(){return this.#S}replaceBackgroundAutoModeSetupInFlight(e){this.#S=e}deferredToolStubGateLatch(){return this.#m}replaceDeferredToolStubGateLatch(e){this.#m=e}verifySkillRolloutGateLatch(){return this.#y}replaceVerifySkillRolloutGateLatch(e){this.#y=e}commitSkillRolloutGateLatch(){return this.#b}replaceCommitSkillRolloutGateLatch(e){this.#b=e}memoryToolsShapeLatch(){return this.#_}replaceMemoryToolsShapeLatch(e){this.#_=e}proposeGoalAvailabilityLogged(){return this.#k}markProposeGoalAvailabilityLogged(){this.#k=!0}activeRoutine(){return this.#P}replaceActiveRoutine(e){this.#P=e}inheritedTeamName(){return this.#T}replaceInheritedTeamName(e){this.#T=e}teleportedSessionInfo(){return this.#R}replaceTeleportedSessionInfo(e){this.#R=e}markFirstTeleportMessageLogged(){if(this.#R)this.#R.hasLoggedFirstMessage=!0}cachedClaudeMdContent(){return this.#O}replaceCachedClaudeMdContent(e){this.#O=e}accountSkillsSyncEnabled(){return this.#x}replaceAccountSkillsSyncEnabled(e){this.#x=e}skillsSyncVetoed(){return this.#C}replaceSkillsSyncVetoed(e){this.#C=e}accountPluginsSyncEnabled(){return this.#A}replaceAccountPluginsSyncEnabled(e){this.#A=e}pluginsSyncVetoed(){return this.#w}replacePluginsSyncVetoed(e){this.#w=e}armPendingContextCompacted(e,m){this.#v=e,this.#E=m}consumePendingContextCompacted(){let e=this.#v;return this.#v=void 0,e}forgetPendingContextCompacted(){this.#v=void 0,this.#E=void 0}responseBeforeCompaction(){return this.#E}forgetResponseBeforeCompaction(){this.#E=void 0}reset(){this.#x=!1,this.#C=!1,this.#A=!1,this.#w=!1,this.#e=!1,this.#t=!1,this.#n=!1,this.#s=!1,this.#r=!1,this.#o=!1,this.#a=!1,this.#u=!1,this.#d=!1,this.#c=!1,this.#l=void 0,this.#p=!1,this.#i=void 0,this.#f=!1,this.#g=!1,this.#h=!1,this.#S=!1,this.#m=null,this.#y=null,this.#b=null,this.#_=null,this.#k=!1,this.#P=void 0,this.#T=void 0,this.#R=null,this.#O=null,this.#v=void 0,this.#E=void 0}}function ia(){return{messagesArriving:0,lastInLine:Promise.resolve(),gaveUpOn:void 0,besideLine:0,lastBesideLine:Promise.resolve(),gaveUpOnBeside:void 0,pathsArrivingBeside:new Map,toolCallsWaiting:0,pathsArriving:new Map,messagesInLine:[]}}class gs{#e=new Map;#t=new Map;#n=null;#s=new Map;#r=new Set;#o=new Set;#a=new Set;#u=new Set;#d=new Set;#g=new Set;#c=new Set;#l=new Set;#p=new Set;#i=new Set;#f=new Map;#S=new Map;#m=new Map;#y;#b={byFileUuid:new Map,recentPrefetchStarts:[]};#h=ia();#_=new Set;#k=void 0;#x=void 0;#C=void 0;#A=void 0;#w=void 0;#v=void 0;#E=new Set;planSlugCache(){return this.#e}forgetPlanSlug(e){this.#e.delete(e)}pendingBranchLinks(){return this.#t}replacePendingBranchLinks(){this.#t=new Map}vimSharedState(){return this.#n}replaceVimSharedState(e){this.#n=e}agentColorMap(){return this.#s}sessionCreatedTeams(){return this.#r}sessionSpawnedTeammatePanes(){return this.#o}surfacedHookSpawnFailures(){return this.#a}bareMcpServerMatchersWarned(){return this.#u}pendingConversationEditKinds(){return this.#d}clientTruncatedAssistantIds(){return this.#g}heldStatelessReplyIds(){return this.#c}unsupportedThreadKeys(){return this.#l}pendingPrLinks(){return this.#p}policyPredicateTelemetryEmitted(){return this.#i}humanAttachmentDigests(){return this.#f}inboundAttachmentFiles(){return this.#S}filesPlacedByName(){return this.#m}filesPlacedByNameRead(){return this.#y}setFilesPlacedByNameRead(e){this.#y=e}inboundAttachmentDownloads(){return this.#b}arrivingInboundFiles(){return this.#h}chromeAvailabilityStagesLogged(){return this.#_}replaceChromeAvailabilityStagesLogged(e){if(this.#_=new Set,e)this.#k=Date.now()}chromeAvailabilityAnchorMs(){return this.#k}pendingGoalIdleCheckin(){return this.#x}replacePendingGoalIdleCheckin(e){this.#x=e}pendingGoalReprompt(){return this.#C}replacePendingGoalReprompt(e){this.#C=e}goalInterruptionStreak(){return this.#A}replaceGoalInterruptionStreak(e){this.#A=e}workerCheckin(){return this.#w}replaceWorkerCheckin(e){this.#w=e}earlierSessionIds(e){return this.#v?.sessionId===e?this.#v.ids:[]}sessionIdsHandedOnFrom(e){return this.#E.has(e)?[]:[...this.earlierSessionIds(e),e]}replaceEarlierSessionIds(e,m,P){if(this.#v={sessionId:e,ids:m},P)this.#E.delete(e);else this.#E.add(e)}reset(){this.#e=new Map,this.#t=new Map,this.#n=null,this.#s=new Map,this.#r=new Set,this.#o=new Set,this.#a=new Set,this.#u=new Set,this.#d=new Set,this.#g=new Set,this.#c=new Set,this.#l=new Set,this.#p=new Set,this.#i=new Set,this.#f=new Map,this.#S=new Map,this.#m=new Map,this.#y=void 0;for(let e of this.#b.byFileUuid.values())clearTimeout(e.expiry),e.abort.abort(),e.modelCopy?.abort.abort();for(let e of this.#b.originalsStillDownloading??[])e.abort();this.#b={byFileUuid:new Map,recentPrefetchStarts:[]},this.#h=ia(),this.#_=new Set,this.#k=void 0,clearTimeout(this.#x),this.#x=void 0,clearTimeout(this.#C),this.#C=void 0,this.#A=void 0,clearInterval(this.#w?.timer),this.#w=void 0,this.#v=void 0,this.#E.clear()}}var aa={renderTarget:"ink",workspace:"local",canDrive:!0,transcriptSource:"local-jsonl",remote:null};class fs{#e=!1;#t=void 0;#n=void 0;#s=void 0;#r=void 0;#o=void 0;#a=void 0;#u=null;#d=!1;#g={keep:"none"};#c=void 0;#l=aa;#p=!1;#i="idle";#f=null;attacherCapsChanged=p();rvSupervisorLinkChanged=p();programStatusViewersChanged=p();cloudCwdChanged=p();sdkDialogHostActive(){return this.#e}markSdkDialogHostActive(e){this.#e=e}sdkSupportedDialogKinds(){return this.#t}sdkSupportedDialogKindsSource(){return this.#n}declareDialogKinds(e,m){this.#t=e,this.#n=e===void 0?void 0:m}sdkPerTaskStopAffordance(){return this.#s}declarePerTaskStopAffordance(e){this.#s=e}sdkRapidFollowupPreempt(){return this.#r}declareRapidFollowupPreempt(e){this.#r=e}sdkForwardNestedSubagentToolCalls(){return this.#o}declareForwardNestedSubagentToolCalls(e){this.#o=e}hostRendersChromeSetupOffer(){return this.#a}declareHostRendersChromeSetupOffer(e){this.#a=e}attacherCaps(){return this.#u}replaceAttacherCaps(e){this.#u=e,this.attacherCapsChanged.emit()}rvSupervisorLinkLive(){return this.#d}replaceRvSupervisorLinkLive(e){if(this.#d===e)return;if(this.#d=e,this.rvSupervisorLinkChanged.emit(),!e)this.replaceProgramStatusViewers({keep:"none"})}programStatusViewers(){return this.#g}replaceProgramStatusViewers(e){this.#g=e,this.programStatusViewersChanged.emit()}sdkBetas(){return this.#c}replaceSdkBetas(e){this.#c=e}caps(){return this.#l}replaceCaps(e){this.#l=e}markRemote(e){this.#l={...this.#l,workspace:e?"remote":"local"}}cloudCwdOfSession(e){return this.#l.workspace==="remote"&&this.#f?.sessionId===e?this.#f.cwd:null}replaceCloudCwd(e){this.#f=e,this.cloudCwdChanged.emit()}replBridgeActive(){return this.#p}replaceReplBridgeActive(e){if(this.#p===e)return;this.#p=e}mainLoopBusy(){return this.#i!=="idle"}mainQueryRunning(){return this.#i==="running"}replaceMainLoopStatus(e){this.#i=e}reset(){this.#e=!1,this.#t=void 0,this.#n=void 0,this.#s=void 0,this.#r=void 0,this.#o=void 0,this.#a=void 0,this.#u=null,this.#c=void 0,this.#l=aa,this.#p=!1,this.#i="idle",this.#d=!1,this.#g={keep:"none"},this.#f=null,this.attacherCapsChanged.clear(),this.rvSupervisorLinkChanged.clear(),this.programStatusViewersChanged.clear(),this.cloudCwdChanged.clear()}}var la=150,Kd=60000;class hs{#e=Date.now();#t=!1;#n=0;#s=-1/0;#r=-1/0;#o=!1;interactionFired=p();#a=void 0;terminalFocusFired=p();#u=!1;#d;lastInteractionTime(){return this.#e}lastSubmitTime(){return this.#n}recordSubmit(){this.#n=Date.now()}personWroteAt(){return this.#s}notePersonWrote(){this.#s=performance.now(),this.notePersonIsHere()}notePersonIsHere(){this.#r=performance.now(),this.#o=!1}nobodyIsHere(){return this.#o}noteWhoseTurn(e){this.#o=e&&performance.now()-this.#r>=Kd}recordInteraction(e){if(e)this.#g();else this.#t=!0}flushIfDirty(){if(this.#t)this.#g()}#g(){this.#e=Date.now(),this.#t=!1,this.interactionFired.emit()}resetBaseline(){this.#e=Date.now(),this.#t=!1}terminalFocus(){return this.#a}updateTerminalFocus(e){this.#a=e,this.terminalFocusFired.emit()}scrollDraining(){return this.#u}markScrollActivity(){if(this.#u=!0,this.#d)clearTimeout(this.#d);this.#d=setTimeout(()=>{this.#u=!1,this.#d=void 0},la),this.#d.unref?.()}async waitForScrollIdle(){while(this.#u)await new Promise((e)=>setTimeout(e,la))}reset(){this.#e=Date.now(),this.#n=0,this.#s=-1/0,this.#r=-1/0,this.#o=!1,this.#a=void 0,this.interactionFired.clear(),this.terminalFocusFired.clear()}}var jd=["sdk_single_prompt_gate","subagent_estimate","subagent_final_turn","rows_unreadable"],Wd=8;class ms{byAgent=new Map;attemptsByAgent=new Map;cappedFailuresByAgent=new Map;armGateEventEmitted=new Set;vetoedUnderPrompt=new Map;sidecarIo=Promise.resolve();rehydrateAttemptedSessions=new Set;sidecarReadsAhead=new Map;get(e){return this.byAgent.get(e)}has(e){return this.byAgent.has(e)}put(e,m){this.byAgent.set(e,m)}remove(e){this.byAgent.delete(e)}nextAttemptNumber(e){let m=(this.attemptsByAgent.get(e)??0)+1;return this.attemptsByAgent.set(e,m),m}consecutiveCountedFailures(e){return this.cappedFailuresByAgent.get(e)??0}recordCountedFailure(e){let m=(this.cappedFailuresByAgent.get(e)??0)+1;return this.cappedFailuresByAgent.set(e,m),m}clearCountedFailures(e){this.cappedFailuresByAgent.delete(e)}recordVeto(e,m){this.vetoedUnderPrompt.set(e,m)}isVetoedUnder(e,m){return this.vetoedUnderPrompt.get(e)===m}latchArmGateEvent(e){if(this.armGateEventEmitted.has(e))return!1;return this.armGateEventEmitted.add(e),!0}enqueueSidecarIo(e,m){return this.sidecarIo=this.sidecarIo.then(e,e).catch(m),this.sidecarIo}sidecarIoSettled(){return this.sidecarIo}hasAttemptedRehydrate(e){return this.rehydrateAttemptedSessions.has(e)}markRehydrateAttempted(e){this.rehydrateAttemptedSessions.add(e)}keepSidecarReadAhead(e,m){this.sidecarReadsAhead.delete(e);while(this.sidecarReadsAhead.size>=Wd){let P=this.sidecarReadsAhead.keys().next().value;if(P===void 0)break;this.sidecarReadsAhead.delete(P)}this.sidecarReadsAhead.set(e,m)}takeSidecarReadAhead(e){let m=this.sidecarReadsAhead.get(e);return this.sidecarReadsAhead.delete(e),m}dropSidecarReadAhead(e){this.sidecarReadsAhead.delete(e)}forgetSubagentTelemetry(e){this.attemptsByAgent.delete(e),this.cappedFailuresByAgent.delete(e),this.vetoedUnderPrompt.delete(e);for(let m of jd)this.armGateEventEmitted.delete(`${e}:${m}`)}}class Ss{#e=void 0;get current(){return this.#e}adopt(e){this.#e=e}}class ys{#e=null;#t=null;mainAgentId(e){return this.#e??=Bo(e),this.#e}projectDir(){return this.#t}replaceProjectDir(e){this.#t=e}}class _s{openToolUseId;answeredThisSession=!1;get answered(){return this.answeredThisSession}markAnswered(){this.answeredThisSession=!0}isOpenElsewhere(e){return this.openToolUseId!==void 0&&this.openToolUseId!==e}open(e){this.openToolUseId=e}closeFor(e){if(e!==void 0&&this.openToolUseId===e)this.openToolUseId=void 0}}class bs{granted=!1;isGranted(){return this.granted}grant(){this.granted=!0}}class ks{inFlight=null;startedForTurnEnd=!1;reset(){this.inFlight?.abort(),this.inFlight=null,this.startedForTurnEnd=!1}}class vs{firstSyncPromise=null;lastRoundNoChanges=void 0;accountListing="pending";requiredOwed=!1;syncErrors=[];lastRoundListed=!1;listedStamp=null;changesLanded=0;changesReloaded=0;reloadsCompleted=0;holdsSet=0;reloadHeld=!1;lastCompleteList=null;lastSyncedLaneLoad=null;syncedLaneOpened=!1;syncedDirsLoadedHere=new Set;dirsNewHere=new Set;awaitsFirstRun=!1;removalsDeferredHere=new Set;pendingTrashRemovals=[];ensureBucketRoot=null;deferredRelist=null;missingEntry={resync:null,resyncAt:-1/0,swept:!1,longWaitSpent:!1};settingsInstall={current:null,next:null,loaded:null};holdReload(){this.reloadHeld=!0,this.holdsSet++}endHoldSetBefore(e){this.reloadHeld&&=this.holdsSet!==e}reloaded(e){this.changesReloaded=Math.max(this.changesReloaded,e),this.reloadsCompleted++}}class xs{abortController=null;eligibleTurns=0;unusedInARow=0;personSeenAt=0;unattendedTurns=0;askOnNextTurn(){this.eligibleTurns=0}reset(){this.abortController?.abort(),this.abortController=null}arm(){let e=new AbortController;return this.abortController=e,e}}class Es{#e=void 0;#t=void 0;ccrSessionID(){return this.#e}latchCcrSessionID(e){this.#e=e}syncEnabled(){return this.#t}latchSyncEnabled(e){return this.#t=e,e}}class Cs{autonomousPreambleDelivered=!1;lastLoopFileDelivered=null;reset(){this.autonomousPreambleDelivered=!1,this.lastLoopFileDelivered=null}}class ws{exchanges=[];replace(e){this.exchanges=e}append(e,m,P,J){this.exchanges=[...this.exchanges,{question:e,response:m,...P&&{fallbackNotice:P},...J&&{agentId:J}}].slice(-20)}pendingReopen=null;reopenAway=!1;get reopenPending(){return this.pendingReopen!==null}armReopen(e,m){if(this.pendingReopen){this.pendingReopen.owners.add(e);return}this.pendingReopen={owners:new Set([e]),cancel:m()}}clearPendingReopen(e){let m=this.pendingReopen;if(!m){this.reopenAway=!1;return}if(e!==void 0){if(m.owners.delete(e),m.owners.size>0)return}m.cancel(),this.pendingReopen=null,this.reopenAway=!1}reopener=null;setReopener(e){this.reopener=e}get hasReopener(){return this.reopener!==null}reopenNow(){return this.reopener?.()??!1}inFlightQuestions=[];get inFlight(){return this.inFlightQuestions.at(-1)??null}pendingBesidesTop(){return this.inFlightQuestions.slice(0,-1)}setInFlight(e){if(!this.inFlightQuestions.includes(e))this.inFlightQuestions=[...this.inFlightQuestions,e]}clearInFlight(e){if(this.inFlightQuestions.includes(e))this.inFlightQuestions=this.inFlightQuestions.filter((m)=>m!==e)}}import{lstatSync as va,readFileSync as Vd,readlinkSync as Ns,realpath as FS,realpathSync as xa,statSync as ua}from"fs";class no{now(){return Date.now()}monotonicNow(){return performance.now()}setTimeout(e,m,P){let J=setTimeout(e,m);if(P?.unref)J.unref();return()=>clearTimeout(J)}}var Pe=new no;function x(e,m,P){return new Promise((J,Z)=>{if(m?.aborted){if(P?.throwOnAbort||P?.abortError)Z(P.abortError?.()??Error("aborted"));else J();return}let pe=(P?.clock??Pe).setTimeout(()=>{m?.removeEventListener("abort",fe),J()},e,{unref:P?.unref});function fe(){if(pe(),P?.throwOnAbort||P?.abortError)Z(P.abortError?.()??Error("aborted"));else J()}m?.addEventListener("abort",fe,{once:!0})})}function Gd(e,m){e(Error(m))}function F(e,m,P){let J,Z=new Promise((pe,fe)=>{J=setTimeout(Gd,m,fe,P)});return Promise.race([e,Z]).finally(()=>{if(J!==void 0)clearTimeout(J)})}var $d=(e,m)=>{let P=setTimeout(e,m);return()=>clearTimeout(P)};function he(e,m,P=$d){let J=()=>{},Z=new Promise((pe)=>{J=P(()=>pe(void 0),m)});return Promise.race([e,Z]).finally(J)}function Rs(e){let m=e.indexOf("."),P=(m===-1?e:e.slice(0,m)).replace(/ +$/,"");return/^(con|prn|aux|nul|com[0-9¹²³]|lpt[0-9¹²³])$/i.test(P)}import{homedir as Ea}from"os";import{basename as GS,dirname as lr,isAbsolute as xr,join as Ls,parse as hr,relative as da,resolve as rr,sep as Xn}from"path";import*as Is from"path";function _(e){return process.platform==="darwin"?e.normalize("NFC"):e}function cn(e){return/^[\\/]{2}/.test(e)||co(e)}function je(e){return/(^|[\\/])\.\.([\\/]|$)/.test(e)}function Us(e){return/^[\\/]\?\?[\\/]/.test(e)}function ca(e){if(/^[\\/]{2}[?.][\\/](?!unc[\\/])/i.test(e))return null;return e.match(/^[\\/]{2}(?:[?.][\\/]unc[\\/])?([^\\/]+)/i)?.[1]?.replace(/[A-Z]/g,(m)=>m.toLowerCase())??null}function dn(e){return/(^|[\\/])\.{1,2}[. ]*([\\/]|$)/.test(e)}function ne(e){return/^[\\/]{2}[?.][\\/]/.test(e)}function re(e){if(!/\/\.(?:vol|file|nofollow|resolve)(?:\/|$)/i.test(e))return!1;if(!e.startsWith("/"))return!1;let m=[];for(let P of e.split("/")){if(P===""||P===".")continue;if(P===".."){m.pop();continue}if(m.push(P),m.length===1&&/^\.(?:vol|file|nofollow|resolve)$/i.test(P))return!0}return!1}function Ca(e){return/^[\\/](GLOBAL\?\?|GLOBALROOT|DosDevices|Device)[\\/]/i.test(e)}function wa(e,m){if(!cn(e))return!1;if(ne(e)||co(e))return!0;if(dn(e))return!0;let P=ca(e);return P===null||P!==ca(m)}function Ra(e){return e.length===2&&As(e[0])==="net"||e.length===3&&As(e[0])==="network"&&As(e[1])==="servers"}function Mr(e){if(process.platform==="win32"||!e.startsWith("/"))return null;let m=[];for(let P of e.split("/")){if(P===""||P===".")continue;if(P===".."){m.pop();continue}if(m.push(P),Ra(m))return io(P)}return null}function io(e){return e.replace(/[A-Z]/g,(m)=>m.toLowerCase())}function As(e){return e.replace(/[\u200c-\u200f\u202a-\u202e\u206a-\u206f\ufeff]/g,"").toUpperCase().toLowerCase()}function Hs(e,m){if(re(e))return!0;if(pn(e)){let P=Mr(e);if(P===null||P!==Mr(m))return!0}return qd(e,m)}function qd(e,m,P=process.platform,J=P==="darwin"&&(process.platform!=="darwin"||Aa())){if(P!=="darwin"||!Yd(e,P,J))return!1;let Z=Ds(m,P,J).complete[0]??null,{complete:pe,partial:fe}=Ds(e,P,J);if(pe.length===0&&fe.length===0)return!0;if(Z===null)return!0;return pe.some((ve)=>ve!==Z)||fe.some((ve)=>!Z.startsWith(ve))}var Ts=a({value:void 0},(e)=>{e.value=void 0});function Aa(e=pa){let m=e===pa;if(m&&Ts.value!==void 0)return Ts.value;let P;try{let J=!1;try{J=e.readAutoMaster().split(`
|
|
31
|
+
`).some((Z)=>{let pe=Z.replace(/#.*$/,"").trim().split(/\s+/);return pe.length>=2&&pe[0].toLowerCase()==="/home"})}catch(Z){if(!h(Z))throw Z}P=J||e.homeIsOwnMount()}catch{return!0}if(m)Ts.value=P;return P}var pa={readAutoMaster:()=>Vd("/etc/auto_master","utf8"),homeIsOwnMount:()=>{let e;try{e=ua("/home")}catch(m){if(h(m))return!0;throw m}return e.dev!==ua("/Users").dev}},zd=6;function Ds(e,m,P){let J=[],Z=[];if(!e.startsWith("/"))return{complete:J,partial:Z};let pe=[];for(let fe of e.split("/")){if(fe===""||fe===".")continue;if(fe===".."){pe.pop();continue}if(pe.push(fe),pe.length>zd)continue;let ve="/"+pe.join("/"),Re=(m==="darwin"?Ua(ve):ve).split("/").filter((De)=>De!==""),Ae=Re[0]?.toLowerCase();if(Ae==="network"){if(Re.length===1)Z.push("/network/");else if(Re.length===2)Z.push(`/network/${io(Re[1])}/`);else if(Re.length===3)J.push(`/network/${io(Re[1])}/${io(Re[2])}`)}else if(P&&Ae==="home"&&Re.length===2)J.push(`/home/${Re[1]}`)}return{complete:J,partial:Z}}function pn(e){if(process.platform==="win32")return!1;return V(e)}function En(e){return cn(e)||pn(e)||Nr(e)||re(e)}function V(e){return lo(e)!==null}var Ta=1024,Pa=4096,ro=new Map,oo=new Map;function lo(e){if(!e.startsWith("/"))return null;if(e.length>Pa)return ga(e);let m=ro.get(e);if(m===void 0){if(m=ga(e),ro.size>=Ta)ro.clear();ro.set(e,m)}return m}function ga(e){let m=[];for(let P of e.split("/")){if(P===""||P===".")continue;if(P===".."){m.pop();continue}if(m.push(P),Ra(m))return"/"+m.join("/")}return null}function ur(e){if(!e.startsWith("/"))return!1;let m=[];for(let P of e.split("/")){if(P===""||P===".")continue;if(P===".."){m.pop();continue}m.push(P)}return m.length===1&&m[0].toLowerCase()==="net"}function sr(e){if(!e.startsWith("/"))return!1;if(e.length>Pa)return fa(e);let m=oo.get(e);if(m===void 0){if(m=fa(e),oo.size>=Ta)oo.clear();oo.set(e,m)}return m}function fa(e){let m=[];for(let P of e.split("/")){if(P===""||P===".")continue;if(P===".."){m.pop();continue}if(m.push(P),m.length===1&&m[0].toLowerCase()==="network")return!0}return!1}function Nr(e){if(process.platform!=="darwin")return!1;return sr(e)}function Jd(e){return V(e)||ur(e)||sr(e)||re(e)}function Yd(e,m=process.platform,P=m==="darwin"&&(process.platform!=="darwin"||Aa())){if(m!=="darwin")return!1;if(sr(e)||re(e))return!0;if(!e.startsWith("/"))return!1;let{complete:J,partial:Z}=Ds(e,m,P);if(Z.length>0)return!0;if(J.some((fe)=>fe.startsWith("/network/")))return!0;let pe=J.filter((fe)=>fe.startsWith("/home/"));if(pe.length>0){let fe=Xd();if(pe.some((ve)=>ve!==fe))return!0}return!1}function Xd(){let e;try{e=Ea()}catch{return null}let m=/^\/home\/([^/]+)/.exec(Ua(e));return m?`/home/${m[1]}`:null}function Y(e){return Zd(e)||sr(e)}function Zd(e){return Le(e)||V(e)||ur(e)||ne(e)||co(e)||Ca(e)||re(e)}function H(e){let m=/^[\\/]{2}wsl(?:\$|\.localhost)[\\/]([^\\/]*)/i.exec(e);return m!==null&&!/^\.{0,2}[. ]*$/.test(m[1]??"")}function Le(e){return cn(e)&&!H(e)}function oe(e){if(e.startsWith("\\\\?\\UNC\\"))return"\\\\"+e.slice(8);if(e.startsWith("\\\\?\\")&&e.length>=7&&e[5]===":")return e.slice(4);return e}function Oa(e){if(/^\\\\\?\\volume\{/i.test(e))return ha(e);if(co(e))return!0;let m=oe(e);if(m!==e&&ha(m))return!0;return cn(m)&&!H(m)}function ha(e){return dn(e)||e.includes("/")}function dt(e){try{return oe(xa.native(e))}catch{return null}}var Qd=new Set(["EPERM","EBUSY","EACCES"]),La=4,Ia=50,$S=Ia*(La-1),ma;function Fr(e){return ac(e).real??null}function Ut(e,m,P){if(Sa(lr(rr(e)).toLowerCase(),rr(m).toLowerCase(),"lexical"))return!0;if(ec(e,P))return!0;let J=Fr(lr(rr(e)))?.toLowerCase();if(J!=null&&Y(J)&&Ha(hr(rr(e)).root))return!0;let Z=Fr(m)?.toLowerCase();if(Z==null)return!1;if(J==null)return!0;return Sa(J,Z,"canonical")}function ec(e,m){let P=rr(e);if(Ft(lr(P)))return!1;let J=!1;if(m!==void 0)J=m?.isSymbolicLink()===!0;else{let Z=Cr(()=>va(P));if(Z.value===void 0)return Z.code!=="ENOENT"&&Z.code!=="ENOTDIR";J=Z.value.isSymbolicLink()}return J&&ic(P)}function Ft(e){return Ma().includes(rr(e).toLowerCase())}function Sa(e,m,P){return e===m||nc(e,m)||rc(e,m,P)}var tc=new Set(["node_modules",".venv","venv","env",".env","virtualenv",".tox",".nox",".direnv","__pypackages__"]);function nc(e,m){if(!e.startsWith(ao(m)+Xn))return!1;return e.split(Xn).some((P)=>tc.has(P))}function ao(e){return e.endsWith(Xn)?e.slice(0,-1):e}var Ps;function rc(e,m,P){let{rawHome:J,rawLocal:Z}=Da();if(P==="lexical")return Os(Ma(),e,m);let pe=J+"\x00"+Z;if(Ps?.key===pe)return Os(Ps.aliasDirs,e,m);let fe=!0,ve=Fa(J,Z,(xe)=>{if(!Na(xe))return rr(xe).toLowerCase();let Re=Fr(xe)?.toLowerCase();if(Re==null)return fe=!1,rr(xe).toLowerCase();return Re});if(fe)Ps={key:pe,aliasDirs:ve};return Os(ve,e,m)}function Da(){let e=(process.env.LOCALAPPDATA??"").trim();return{rawHome:Ea(),rawLocal:e}}function Ma(){let{rawHome:e,rawLocal:m}=Da();return Fa(e,m,(P)=>rr(P).toLowerCase())}function Fa(e,m,P){let J=[];if(e)J.push(ao(P(e))+Xn+["appdata","local","microsoft","windowsapps"].join(Xn));if(m){let Z=ao(P(m))+Xn+["microsoft","windowsapps"].join(Xn);if(!J.includes(Z))J.push(Z)}return J}function Na(e){return process.platform==="win32"?oc(e):e.startsWith("/")&&!cn(e)}function oc(e){return/^[A-Za-z]:[\\/](?![\\/])/.test(e)}function Os(e,m,P){let J=ao(P);for(let Z of e){if(!(Z===J||Z.startsWith(J+Xn)))continue;if(m===Z||m.startsWith(Z+Xn))return!0}return!1}var sc=["usr/local","usr/libexec/cups","usr/share/snmp","AppleInternal","Applications","Library","Users","Volumes","cores","home","media","mnt","opt","pkg","private","sw"];function Ua(e){let m=e.split("/");if(m.length<5||m[0]!==""||Dr(m[1]??"")!=="system"||Dr(m[2]??"")!=="volumes"||Dr(m[3]??"")!=="data")return e;let P=m.slice(4);for(let J of sc){let Z=J.split("/");if(P.length<Z.length)continue;if(Z.every((pe,fe)=>Dr(P[fe]??"")===Dr(pe)))return"/"+P.join("/")}return e}function Dr(e){return e.toUpperCase().toLowerCase()}function ct(e){if(process.platform!=="win32")return!1;let m=We(e);return H(m)&&!dn(m)}function Ms(e){let m=We(e);return pc(m)||Jd(m)||Ca(m)}function ya(e,{allowLocalWsl:m=!1,eisdirIsFolder:P=!1,report:J,singleTry:Z=!1}={}){let pe=We(e);if(!xr(pe))return!0;if(J!==void 0)J.chain=[],J.metLink=!1,J.endedMissing=!1;let{root:fe}=hr(pe);return Er(fe,mr(pe.slice(fe.length)),0,m,{eisdirIsFolder:P,report:J,singleTry:Z})}function ic(e,m=lr(e)){let P=Cr(()=>Ns(e));if(P.value===void 0)return P.code!=="ENOENT"&&P.code!=="EINVAL";let J=process.platform==="win32"?P.value:P.value.replace(/^\/{2,}/,"/");if(Ba(J))return!0;let Z=process.platform==="win32"&&/^[\\/](?![\\/])/.test(J);if(Z&&dn(J))return!0;let pe=Z?Ls(hr(m).root,J):J,fe={trustedStart:!0,trustedRoot:m};if(xr(pe)){let Re=da(m,pe);if(!dn(pe)&&Re!==""&&!ba(Re)&&!xr(Re))return Er(m,mr(Re),1,!1,fe);return Ms(pe)||Ht(pe)}if(Ms(pe))return!0;let ve=da(m,lr(e)),xe=!ba(ve)&&!xr(ve);return Er(xe?m:lr(e),[...xe?mr(ve):[],...mr(pe)],1,!1,fe)}function Ht(e,m={}){return ya(e,m)||dn(e)&&ya(rr(e),m)}var _a=40;function Ha(e){let m=Fr(e);return m!==null&&!Ka(m)}function mr(e){return e.split(process.platform==="win32"?/[\\/]+/:/\/+/).filter(Boolean)}function so(e,m){return Ms(e)&&!(m&&ct(e))}function ba(e){return e===".."||/^\.\.[\\/]/.test(e)}function Ba(e){return process.platform==="win32"&&/^[A-Za-z]:(?![\\/])/.test(e)}function Er(e,m,P,J,{trustedStart:Z=!1,trustedRoot:pe=e,eisdirIsFolder:fe=!1,report:ve,singleTry:xe=!1}={}){let Re=(xt)=>{if(ve!==void 0)ve.unclassifiable=xt??"UNKNOWN";return!0},Ae=(xt,st)=>{ve?.chain?.push({path:xt,dev:st.dev,ino:st.ino})},De=()=>{if(ve!==void 0)ve.metLink=!0},Ke=pe.endsWith(Xn)?pe:pe+Xn,Be=(xt)=>Z&&(xt===pe||xt.startsWith(Ke)),ot=e;if(!Be(ot)&&so(ot,J))return!0;let at;for(let xt=0;xt<m.length;xt++){let st=m[xt];if(st===".")continue;if(st===".."){ot=lr(ot);continue}let kt=Ls(ot,st);if(!Be(kt)&&so(kt,J))return!0;let it=(xe?Fs:Cr)(()=>va(kt,{bigint:!0}));if(it.value===void 0){if(it.code!=="ENOENT"&&it.code!=="ENOTDIR")return Re(it.code);if(ve!==void 0)ve.endedMissing=!0;let It=kt;for(let vt of m.slice(xt+1))if(It=vt===".."?lr(It):vt==="."?It:Ls(It,vt),!Be(It)&&so(It,J))return!0;return!1}let un;if(it.value.isSymbolicLink()){if(De(),P>=_a)return!0;let It=(xe?Fs:Cr)(()=>Ns(kt));if(un=It.value,un===void 0)return Re(It.code)}else if(process.platform==="win32"&&it.value.isDirectory()){let It=cc(kt,xe);if(It.kind==="junction"){if(De(),P>=_a)return!0;un=It.target}else if(It.kind==="directory"){Ae(kt,it.value),ot=kt;continue}else if(fe!==!1&&It.kind==="error"&&It.code==="EISDIR"&&(ct(kt)?J&&fe==="onAnyDrive":at??=fe==="onAnyDrive"?Na(hr(kt).root):Ha(hr(kt).root))){Ae(kt,it.value),ot=kt;continue}else return Re(It.kind==="absent"?"ENOENT":It.code)}else{if(it.value.isDirectory())Ae(kt,it.value);ot=kt;continue}let Dt=process.platform==="win32"?un:un.replace(/^\/{2,}/,"/");if(!(Z&&xr(Dt)&&!dn(Dt)&&Be(Dt))&&so(Dt,J))return!0;let fn=m.slice(xt+1);if(Ba(Dt))return!0;if(xr(Dt)){if(Z&&!dn(Dt)&&Be(Dt))return Er(pe,[...mr(Dt.slice(Ke.length)),...fn],P+1,J,{trustedStart:!0,trustedRoot:pe,eisdirIsFolder:fe,report:ve,singleTry:xe});let It=hr(Dt).root,vt=process.platform==="win32"&&/^[\\/]$/.test(It)?hr(ot).root:It;return Er(vt,[...mr(Dt.slice(It.length)),...fn],P+1,J,{eisdirIsFolder:fe,report:ve,singleTry:xe})}return Er(ot,[...mr(Dt),...fn],P+1,J,{trustedStart:Be(ot),trustedRoot:pe,eisdirIsFolder:fe,report:ve,singleTry:xe})}return!1}function ac(e){let m=Cr(()=>oe(xa.native(e)));return{real:m.value,code:m.code}}function uo(e){return e!=null&&typeof e==="object"&&"code"in e&&typeof e.code==="string"?e.code:void 0}function Cr(e){try{return{value:lc(e)}}catch(m){return{code:uo(m)}}}function Fs(e){try{return{value:e()}}catch(m){return{code:uo(m)}}}function lc(e){return uc(e,()=>!0)}function uc(e,m){for(let P=0;;P++)try{return e()}catch(J){let Z=uo(J);if(Z===void 0||process.platform!=="win32"||!Qd.has(Z)||P>=La-1||!m())throw J;ma??=new Int32Array(new SharedArrayBuffer(4)),Atomics.wait(ma,0,0,Ia)}}function dc(e){let m=uo(e);return m==="EINVAL"?{kind:"directory"}:m==="ENOENT"?{kind:"absent"}:{kind:"error",code:m,error:e}}function cc(e,m=!1){let P,J=(m?Fs:Cr)(()=>{try{return Ns(e)}catch(Z){throw P=Z,Z}});return J.value!==void 0?{kind:"junction",target:J.value}:dc(P)}function pc(e){return Ka(e)||V(e)}function gc(e){return dn(e)||/[. :](?=[\\/]|$)/.test(e)||e.split(/[\\/]/).some((m)=>Rs(m)||Rs(m.slice(0,Math.max(0,m.indexOf(":")))))}function We(e){let m=(process.platform==="win32"?/^(?:[\\/][\\/][?.][\\/]|[\\/]\?\?[\\/])(?=[A-Za-z]:[\\/])/:/^(?:\\\\[?.]\\|\\\?\?\\)(?=[A-Za-z]:[\\/])/).exec(e);if(!m)return e;let P=e.slice(m[0].length),J=P.slice(2);return m[0].includes("\\")&&J.includes("/")||gc(J)?e:P}function Ka(e){return cn(e)}function co(e){return ka.test(e)||e.includes("??")&&ka.test(fc(e))}var ka=/^[\\/]\?\?[\\/]/;function fc(e){return Is.win32?Is.win32.normalize(e):e}var hc=16;class Bs{pending=null;shownThisSession=!1;changed=p();submitted=[];submittedChanged=p();subscribe=this.changed.subscribe;getSnapshot=()=>this.pending;subscribeSubmitted=this.submittedChanged.subscribe;submit(e){if(this.shownThisSession)return;if(this.submitted.length>=hc)this.submitted.shift();this.submitted.push(e),this.submittedChanged.emit()}takeSubmitted(){let e=this.submitted;return this.submitted=[],e}offer(e){if(this.shownThisSession)return;this.pending=e,this.changed.emit()}dismiss(){if(this.pending!==null)this.pending=null,this.changed.emit()}markShown(){this.shownThisSession=!0}}var mc=Symbol("permission-stash-evicted");class js{entriesCap;evictedKeysCap;lanes={write:new Map,read:new Map};evicted={write:new Set,read:new Set};poisoned={write:!1,read:!1};identities=new Map;identitiesEvicted=new Set;identitiesPoisoned=!1;constructor(e=256,m=1048576){this.entriesCap=e;this.evictedKeysCap=m}stash(e,m,P,J="write"){if(e===void 0)return;let Z=this.lanes[J],pe=this.evicted[J],fe=Ks(e,m);if(pe.has(fe))return;let ve=Z.get(fe);if(ve!==void 0){let xe=new Set(P);Z.set(fe,ve.filter((Re)=>xe.has(Re)));return}if(Z.size>=this.entriesCap){let xe=Z.keys().next().value;if(xe!==void 0){if(Z.delete(xe),pe.add(xe),pe.size>this.evictedKeysCap){this.poisoned[J]=!0;let Re=pe.values().next().value;if(Re!==void 0)pe.delete(Re)}}}Z.set(fe,P)}holds(e,m,P="write"){return e!==void 0&&this.lanes[P].has(Ks(e,m))}stashIdentity(e,m,P){if(e===void 0)return;let J=this.identities.get(e),Z=J?.get(m);if(J!==void 0&&Z!==void 0){if(Z===null||P===null||Z.dev!==P.dev||Z.ino!==P.ino)J.set(m,null);return}let pe=this.identitiesEvicted.has(e)||this.identitiesPoisoned;if(J===void 0){if(!pe&&this.identities.size>=this.entriesCap){let fe=this.identities.keys().next().value;if(fe!==void 0){if(this.identities.delete(fe),this.identitiesEvicted.add(fe),this.identitiesEvicted.size>this.evictedKeysCap){this.identitiesPoisoned=!0;let ve=this.identitiesEvicted.values().next().value;if(ve!==void 0)this.identitiesEvicted.delete(ve)}}}J=new Map,this.identities.set(e,J)}J.set(m,pe?null:P)}takeIdentity(e,m){if(e===void 0)return;let P=this.identities.get(e),J=P?.get(m);if(P?.delete(m)&&P.size===0)this.identities.delete(e);return J}consume(e,m,P="write"){if(e===void 0)return;let J=this.lanes[P],Z=Ks(e,m),pe=J.get(Z),fe=pe===void 0&&(this.evicted[P].delete(Z)||this.poisoned[P]),ve=`${e}\x00`;for(let xe of J.keys())if(xe.startsWith(ve))J.delete(xe);if(P==="read")this.identities.delete(e),this.identitiesEvicted.delete(e);if(fe)return mc;return pe}}function Ks(e,m){return`${e}\x00${m}`}var Sc="NoProjectDirectoryError",ja=new s(()=>({}));var Wa=()=>{};function Ga(e){Wa=e}class ze extends Error{name=Sc;constructor(){super("This session has no working directory.");try{Wa(this)}catch{}}}function po(e){let{project:m}=e;if(m===null)throw new ze;return m}function $a(e){return Va({kind:"root",host:e.host,id:e.id,parentId:e.parentId},e.project,e.project?.isolationRoot)}function go(e,m){let P=m.originalCwd??e?.originalCwd,J=m.projectRoot??e?.projectRoot,Z=m.cwd??e?.cwd;if(P===void 0&&J===void 0&&Z===void 0)return null;if(P===void 0||J===void 0||Z===void 0)throw new ze;return{originalCwd:_(P),projectRoot:_(J),cwd:_(Z)}}function Va(e,m,P){let J={project:m===null?null:go(null,m)},Z=P,pe=p(),fe=e.kind==="fork"?e.root.observers:new Qo,ve=e.kind==="fork"?e.root.autonomousLoopPreamble:new Cs,xe=e.kind==="fork"?e.root.precompute:new ms,Re={get originalCwd(){return po(J).originalCwd},get projectRoot(){return po(J).projectRoot},get cwd(){return po(J).cwd},get isolationRoot(){return Z}},Ae={host:e.kind==="fork"?e.root.host:e.host,get id(){return e.kind==="fork"?e.root.id:e.id},get parentId(){return e.kind==="fork"?e.root.parentId:e.parentId},get root(){return e.kind==="fork"?e.root:Ae},get project(){return J.project===null?null:Re},observers:fe,autonomousLoopPreamble:ve,btwHistory:e.kind==="fork"?e.root.btwHistory:new ws,ccrRecap:e.kind==="fork"?e.root.ccrRecap:new ks,conversationLatches:e.kind==="fork"?e.root.conversationLatches:new ts,costLedger:e.kind==="fork"?e.root.costLedger:new rs,engineStore:e.kind==="fork"?e.root.engineStore:new Ss,usageCreditsOnlyModelConsentSlots:e.kind==="fork"?e.root.usageCreditsOnlyModelConsentSlots:new os,hookRegistry:e.kind==="fork"?e.root.hookRegistry:new ss,identity:e.kind==="fork"?e.root.identity:new ys,invokedSkills:e.kind==="fork"?e.root.invokedSkills:new is,mcpSessionWiring:e.kind==="fork"?e.root.mcpSessionWiring:new as,modelSelection:e.kind==="fork"?e.root.modelSelection:new ls,promptAssembly:e.kind==="fork"?e.root.promptAssembly:new us,promptSuggestion:e.kind==="fork"?e.root.promptSuggestion:new xs,pendingHint:e.kind==="fork"?e.root.pendingHint:new Bs,pluginsSync:e.kind==="fork"?e.root.pluginsSync:new vs,precompute:xe,requestJournal:e.kind==="fork"?e.root.requestJournal:new ds,sessionCron:e.kind==="fork"?e.root.sessionCron:new cs,sessionFlags:e.kind==="fork"?e.root.sessionFlags:new ps,sessionRefsGate:e.kind==="fork"?e.root.sessionRefsGate:new Es,sessionScratch:e.kind==="fork"?e.root.sessionScratch:new gs,surfaceCapabilities:e.kind==="fork"?e.root.surfaceCapabilities:new fs,userPresence:e.kind==="fork"?e.root.userPresence:new hs,workflowUsageConsent:e.kind==="fork"?e.root.workflowUsageConsent:new bs,outsideReadPrompt:e.kind==="fork"?e.root.outsideReadPrompt:new _s,writePermissionStash:e.kind==="fork"?e.root.writePermissionStash:new js,subscribe(De){let Ke=pe.subscribe(De);if(e.kind!=="fork")return Ke;let Be=e.root,{id:ot,parentId:at}=Be,xt=Be.subscribe(()=>{if(Be.id===ot&&Be.parentId===at)return;ot=Be.id,at=Be.parentId,De()});return()=>{Ke(),xt()}},setCwd(De){Ae.update({project:{cwd:De}})},setIsolationRoot(De){if(De!==Z)Z=De,pe.emit()},withProject(De){return Va({kind:"fork",root:Ae.root},go(J.project,De),De.isolationRoot??Z)},update(De){let Ke=De.project===void 0?J.project:De.project===null?null:go(J.project,De.project),Be=!1;if(De.id!==void 0||"parentId"in De){if(e.kind==="fork")throw Error("A withProject fork cannot re-identify the session — update the root session instead");if(De.id!==void 0&&De.id!==e.id)e.id=De.id,Be=!0;if("parentId"in De&&De.parentId!==e.parentId)e.parentId=De.parentId,Be=!0}if(Ke?.originalCwd!==J.project?.originalCwd||Ke?.projectRoot!==J.project?.projectRoot||Ke?.cwd!==J.project?.cwd)J.project=Ke,Be=!0;let ot=De.project?.isolationRoot;if(ot!==void 0&&ot!==Z)Z=ot,Be=!0;if(Be)pe.emit()}};return Ae}class _e{#e;#t=new WeakMap;constructor(e){this.#e=e}peek(e){return this.#t.get(e.root)}of(e){let m=e.root,P=this.#t.get(m);if(P!==void 0)return P;let J=this.#e();return this.#t.set(m,J),J}drop(e){this.#t.delete(e.root)}}var qa={isDiskless:()=>!1,isDisklessProcess:()=>!1,reportBuilt:()=>{}};function za(e){qa=e}function fo(){return qa.isDiskless()}var Ja=new s(()=>({}));var yc="NoConfigHomeError";function Bt(e){try{return typeof e==="object"&&e!==null&&"name"in e&&e.name===yc}catch{return!1}}class Ws{#e=!1;#t=!1;#n=!1;#s=null;#r=!1;#o=void 0;#a=!1;#u=!1;#d=!1;#g=!1;#c=void 0;#l=!1;#p=!1;#i="";#f=null;#S=null;#m=new Map;#y="cli";#b="fresh";#h=void 0;#_=!1;#k=!1;#x=[];#C=!1;#A=!1;#w=!1;#v=new Set;#E=!1;#P=!1;#T=!1;#R=!1;#O=!1;#L="none";#I=!1;#D=!1;#U=!1;#M=!1;#H=!1;#F=void 0;#B=void 0;#K=void 0;#j=!1;#N=!1;#W=void 0;#G=void 0;#$=void 0;#V=void 0;#z=!1;#J=!1;#Y=!1;#X=void 0;#Z=!1;#Q=!1;#ee=!1;#te=null;#ne=null;#re=!0;#oe=null;#q=!1;#fe=p();#se=null;#ie=!1;#ae=!1;#le=!1;#ue={};#de=void 0;#ce=null;#pe="none";#ge=void 0;isInteractive(){return this.#e}isInteractivityDecided(){return this.#t}isNoDialogLaunch(){return this.#n}markNoDialogLaunch(){this.#n=!0}replaceIsInteractive(e){this.#e=e,this.#t=!0}printOutputFormat(){return this.#s}replacePrintOutputFormat(e){this.#s=e}thinkingDisplayExplicit(){return this.#r}replaceThinkingDisplayExplicit(e){this.#r=e}permissionPromptToolName(){return this.#o}replacePermissionPromptToolName(e){this.#o=e}hasStreamingInput(){return this.#a}replaceHasStreamingInput(e){this.#a=e}singleShotPrintSession(){return this.#u}replaceSingleShotPrintSession(e){this.#u=e}printInputClosed(){return this.#d}markPrintInputClosed(){this.#d=!0}modelOverrideOptOutForSession(){return this.#g}replaceModelOverrideOptOutForSession(e){this.#g=e}rendererMode(){return this.#c}replaceRendererMode(e){this.#c=e}strictToolResultPairing(){return this.#l}replaceStrictToolResultPairing(e){this.#l=e}restrictedSession(){return this.#p}replaceRestrictedSession(e){this.#p=e}antLaunchKind(){return this.#i}replaceAntLaunchKind(e){this.#i=e}workspaceRestrictionState(){return this.#f}replaceWorkspaceRestrictionState(e){this.#f=e}replaceWorkspaceRestrictionUnsubscribe(e){this.#S?.(),this.#S=e}restrictedWorkspaceRoots(){return this.#m}addRestrictedWorkspaceRoot(e,m){this.#m.set(e,m)}clearRestrictedWorkspaceRoots(){this.#m=new Map}clientType(){return this.#y}replaceClientType(e){this.#y=e}sessionStartType(){return this.#b}replaceSessionStartType(e){this.#b=e}questionPreviewFormat(){return this.#h}replaceQuestionPreviewFormat(e){this.#h=e}extendedQuestionsEnabled(){return this.#_}replaceExtendedQuestionsEnabled(e){this.#_=e}questionOptionDescriptionsOptional(){return this.#k}replaceQuestionOptionDescriptionsOptional(e){this.#k=e}replConfigArgv(){return this.#x}replaceReplConfigArgv(e){this.#x=e}userMsgOptIn(){return this.#C}replaceUserMsgOptIn(e){this.#C=e}searchToolsOptIn(){return this.#A}replaceSearchToolsOptIn(e){this.#A=e}todoToolsOptIn(){return this.#w}replaceTodoToolsOptIn(e){this.#w=e}toolsOmittedByLaunchList(){return this.#v}replaceToolsOmittedByLaunchList(e){this.#v=e}wizardOperatorToolsEnabled(){return this.#E}replaceWizardOperatorToolsEnabled(e){this.#E=e}runnerDeclaredNestedRepositoryDiff(){return this.#P}replaceRunnerDeclaredNestedRepositoryDiff(e){this.#P=e}runnerDeclaredNoRepositoryCheckedOut(){return this.#T}replaceRunnerDeclaredNoRepositoryCheckedOut(e){this.#T=e}runnerDeclaredFreshMachinePerSession(){return this.#R}replaceRunnerDeclaredFreshMachinePerSession(e){this.#R=e}runnerDeclaredBuiltInGh(){return this.#O}replaceRunnerDeclaredBuiltInGh(e){this.#O=e}pollEventIngress(){return this.#L}markPollEventIngress(e){this.#L=e}ownEventDeliveryRequested(){return this.#I&&!this.#D}replaceOwnEventDeliveryHeld(e){this.#D=e}markOwnEventDeliveryRequested(){this.#I=!0}sdkAgentProgressSummariesEnabled(){return this.#U}replaceSdkAgentProgressSummariesEnabled(e){this.#U=e}sessionPersistenceDisabled(){return this.#M}replaceSessionPersistenceDisabled(e){this.#M=e}diskless(){return this.#H}replaceDiskless(e){this.#H=e}ccrSessionUrl(){return this.#F}replaceCcrSessionUrl(e){this.#F=e}ccrDerivedSurface(){return this.#B}replaceCcrDerivedSurface(e){this.#B=e}ccrClaudeCodeSurface(){return this.#K}replaceCcrClaudeCodeSurface(e){this.#K=e}autoCompactWindowSurface(){return this.#G}replaceAutoCompactWindowSurface(e){this.#G=e}wrapUpOffered(){return this.#j}replaceWrapUpOffered(e){this.#j=e}wrapUpFromPhone(){return this.#N}replaceWrapUpFromPhone(e){this.#N=e}entrypointOnRequests(){return this.#W}replaceEntrypointOnRequests(e){this.#W=e}coworkEnrollment(){return this.#$}replaceCoworkEnrollment(e){this.#$=e}chatConversationUuid(){return this.#V}replaceChatConversationUuid(e){this.#V=e}ccrSessionLimited(){return this.#z}replaceCcrSessionLimited(e){this.#z=e}ccrBlockLimitShowsCard(){return this.#J}replaceCcrBlockLimitShowsCard(e){this.#J=e}toolsMayBeOnHost(){return this.#Y}replaceToolsMayBeOnHost(e){this.#Y=e}toolsMachine(){return this.#X}replaceToolsMachine(e){this.#X=e}sessionBypassPermissionsMode(){return this.#Z}replaceSessionBypassPermissionsMode(e){this.#Z=e}disableSlashCommands(){return this.#Q}replaceDisableSlashCommands(e){this.#Q=e}disableFileMentions(){return this.#ee}replaceDisableFileMentions(e){this.#ee=e}sessionUploadsDir(){return this.#te}replaceSessionUploadsDir(e){this.#te=e}localUploadsRoot(){return this.#ne}replaceLocalUploadsRoot(e){this.#ne=e}mayForwardHomeSettings(){return this.#re}replaceMayForwardHomeSettings(e){this.#re=e}homeSettingsHostConsent(){return this.#oe}replaceHomeSettingsHostConsent(e){this.#oe=e}scheduledTasksEnabled(){return this.#q}replaceScheduledTasksEnabled(e){let m=e&&!this.#q;if(this.#q=e,m)this.#fe.emit()}onScheduledTasksEnabled(e){return this.#fe.subscribe(e)}initJsonSchema(){return this.#se}replaceInitJsonSchema(e){this.#se=e}cliSessionConfigCarried(){return this.#ie}replaceCliSessionConfigCarried(e){this.#ie=e}cloudLaunchCarriesOnlyModel(){return this.#ae}replaceCloudLaunchCarriesOnlyModel(e){this.#ae=e}forkRestrictedLaunchConfig(){return this.#le}replaceForkRestrictedLaunchConfig(e){this.#le=e}forkReplayLaunchConfig(){return this.#ue}spareClaimState(){return this.#pe}replaceSpareClaimState(e){this.#pe=e}spareParkedAtMs(){return this.#ge}replaceSpareParkedAtMs(e){this.#ge=e}replaceForkReplayLaunchConfig(e){this.#ue=e}spareClaim(){return this.#de}replaceSpareClaim(e){this.#de=e}projectConfigRoot(){return this.#ce}replaceProjectConfigRoot(e){this.#ce=e}reset(){this.#e=!1,this.#t=!1,this.#n=!1,this.#s=null,this.#pe="none",this.#ge=void 0,this.#r=!1,this.#o=void 0,this.#a=!1,this.#de=void 0,this.#u=!1,this.#d=!1,this.#g=!1,this.#c=void 0,this.#l=!1,this.#p=!1,this.#i="",this.#f=null,this.replaceWorkspaceRestrictionUnsubscribe(null),this.#m=new Map,this.#y="cli",this.#b="fresh",this.#h=void 0,this.#_=!1,this.#k=!1,this.#x=[],this.#C=!1,this.#A=!1,this.#w=!1,this.#v=new Set,this.#E=!1,this.#P=!1,this.#T=!1,this.#R=!1,this.#O=!1,this.#L="none",this.#I=!1,this.#D=!1,this.#U=!1,this.#M=!1,this.#H=!1,this.#F=void 0,this.#B=void 0,this.#K=void 0,this.#G=void 0,this.#j=!1,this.#N=!1,this.#W=void 0,this.#$=void 0,this.#V=void 0,this.#z=!1,this.#J=!1,this.#Y=!1,this.#X=void 0,this.#Z=!1,this.#Q=!1,this.#ee=!1,this.#te=null,this.#ne=null,this.#re=!0,this.#oe=null,this.#q=!1,this.#se=null,this.#ie=!1,this.#ae=!1,this.#le=!1,this.#ue={},this.#ce=null}}class Gs{#e=void 0;#t=[];#n=[];#s=void 0;#r=void 0;#o=null;#a=null;#u=!1;#d=null;#g=!1;#c=Ya();#l=null;#p=!1;flagSettingsPath(){return this.#e}replaceFlagSettingsPath(e){this.#e=e}flagAgentsFilePaths(){return this.#t}replaceFlagAgentsFilePaths(e){this.#t=e}flagMcpConfigFilePaths(){return this.#n}replaceFlagMcpConfigFilePaths(e){this.#n=e}flagSettingsExpectedContent(){return this.#s}replaceFlagSettingsExpectedContent(e){this.#s=e}flagSettingsFilePinnedContent(){return this.#r}replaceFlagSettingsFilePinnedContent(e){this.#r=e}flagSettingsInline(){return this.#o}replaceFlagSettingsInline(e){this.#o=e}parentManagedSettings(){return this.#a}replaceParentManagedSettings(e,m=null,P=!1){this.#a=e,this.#d=m,this.#g=P}hostPolicyVerdict(){return this.#g}parentManagedSettingsInvalid(){return this.#u}replaceParentManagedSettingsInvalid(e){this.#u=e}parentOrganizationSettings(){return this.#d}allowedSettingSources(){return this.#c}replaceAllowedSettingSources(e){this.#c=e}allowedSettingSourcesWithoutRepoDirSources(){let e=this.#c;if(this.#l?.of!==e)this.#l={of:e,result:e.filter((m)=>m!=="projectSettings"&&m!=="localSettings")};return this.#l.result}useCoworkPlugins(){return this.#p}replaceUseCoworkPlugins(e){this.#p=e}reset(){this.#e=void 0,this.#t=[],this.#n=[],this.#s=void 0,this.#r=void 0,this.#o=null,this.#a=null,this.#u=!1,this.#d=null,this.#g=!1,this.#c=Ya(),this.#l=null,this.#p=!1}}function Ya(){return["userSettings","projectSettings","localSettings","flagSettings","policySettings"]}class $s{#e=[];#t=[];#n=new Set;#s=[];#r=void 0;#o=new Map;#a=new Map;#u=new Map;#d=[];#g=void 0;#c=[];#l=!1;#p=void 0;#i=void 0;#f=void 0;inlinePlugins(){return this.#e}replaceInlinePlugins(e){this.#e=e}inlinePluginsNoMcp(){return this.#t}replaceInlinePluginsNoMcp(e){this.#t=e}organizationPluginKeys(){return this.#n}replaceOrganizationPluginKeys(e){this.#n=e}inlinePluginUrls(){return this.#s}replaceInlinePluginUrls(e){this.#s=e}syncedPluginDirs(){return this.#r??[]}syncedPluginDirsRegistered(){return this.#r!==void 0}syncedPluginAttestation(e){return this.#o.get(e)}syncedPluginRowId(e){return this.#a.get(e)}replaceSyncedPluginDirs(e,m=new Map,P=new Map){this.#r=e,this.#o=m,this.#a=P,this.#u=this.#S(this.#u)}clearSyncedPluginDirs(){this.#r=void 0,this.#o=new Map,this.#a=new Map,this.#u=new Map}attestedOfficialPluginMarketplace(e){return this.#u.get(e)}replaceAttestedOfficialPluginIds(e){this.#u=this.#S(e)}#S(e){let m=new Set([...this.#o.values()].map((P)=>`${P.pluginName}@${P.marketplace}`));return new Map([...e].filter(([P,J])=>m.has(`${P.slice(0,P.lastIndexOf("@"))}@${J}`)))}additionalDirectoriesForClaudeMd(){return this.#d}replaceAdditionalDirectoriesForClaudeMd(e){this.#d=e}claudeMdAdditionalDirectoriesAsked(){return this.#g}askClaudeMdAdditionalDirectories(e){this.#g=e}allowedChannels(){return this.#c}replaceAllowedChannels(e){this.#c=e}hasDevChannels(){return this.#l}replaceHasDevChannels(e){this.#l=e}sessionSkillAllowlist(){return this.#p}replaceSessionSkillAllowlist(e){this.#p=e}chromeFlagOverride(){return this.#i}replaceChromeFlagOverride(e){this.#i=e}teammateAgentId(){return this.#f}replaceTeammateAgentId(e){this.#f=e}reset(){this.#e=[],this.#t=[],this.#n=new Set,this.#s=[],this.clearSyncedPluginDirs(),this.#d=[],this.#g=void 0,this.#c=[],this.#l=!1,this.#p=void 0,this.#i=void 0,this.#f=void 0}}class Vs{#e=null;#t=null;#n=new Set;modelStrings(){return this.#e}replaceModelStrings(e){this.#e=e}invalidate(){this.#e=null,this.#n=new Set}admin3PSteeringSnapshot(){return this.#t}recordAdmin3PSteeringSnapshot(e){this.#t=e}probeRefutedDocumentDefaults(){return this.#n}recordProbeRefutedDocumentDefault(e){this.#n.add(e)}reset(){this.#e=null,this.#t=null,this.#n=new Set}}var Xa=[];class qs{#e=[];#t=[];#n=void 0;errorLog(){return this.#e}recordError(e){if(this.#e.length>=100)this.#e.shift();this.#e.push(e)}recordSlowOperation(e,m){return}slowOperations(){if(this.#t.length===0)return Xa;let e=Date.now();if(this.#t.some((m)=>e-m.timestamp>=1e4)){if(this.#t=this.#t.filter((m)=>e-m.timestamp<1e4),this.#t.length===0)return Xa}return this.#t}recordDevBarAlert(e){return}devBarAlert(){let e=this.#n;if(e&&Date.now()-e.timestamp>=60000){this.#n=void 0;return}return e}reset(){this.#e=[],this.#t=[],this.#n=void 0}}function Za(){return{direct:{strict:null,customer:null},proxied:{strict:null,customer:null}}}function Qa(){return{rateTokens:null,rateLastRefillMs:null,featureOkLogged:!1,reportedDropReasons:new Set}}class zs{#e=null;#t=null;#n=null;#s=null;#r=null;#o=null;#a=null;#u=null;#d=null;#g=null;#c=null;#l=null;#p=null;#i=[];#f=null;#S=Qa();#m=null;#y=null;#b=null;#h=Za();#_=null;#k=null;installMeter(e,m,{omitUnits:P=!1}={}){this.#e=e;let J=(Z)=>P?void 0:Z;this.#t=m("claude_code.session.count",{description:"Count of CLI sessions started"}),this.#n=m("claude_code.lines_of_code.count",{description:"Count of lines of code modified, with the 'type' attribute indicating whether lines were added or removed and the 'model' attribute indicating which model made the change"}),this.#s=m("claude_code.pull_request.count",{description:"Number of pull requests created"}),this.#r=m("claude_code.commit.count",{description:"Number of git commits created"}),this.#o=m("claude_code.cost.usage",{description:"Cost of the Claude Code session",unit:J("USD")}),this.#a=m("claude_code.token.usage",{description:"Number of tokens used",unit:J("tokens")}),this.#u=m("claude_code.code_edit_tool.decision",{description:"Count of code editing tool permission decisions (accept/reject) for Edit, Write, and NotebookEdit tools"}),this.#d=m("claude_code.active_time.total",{description:"Total active time in seconds",unit:J("s")})}meter(){return this.#e}sessionCounter(){return this.#t}locCounter(){return this.#n}prCounter(){return this.#s}commitCounter(){return this.#r}costCounter(){return this.#o}tokenCounter(){return this.#a}codeEditToolDecisionCounter(){return this.#u}activeTimeCounter(){return this.#d}statsStore(){return this.#g}replaceStatsStore(e){this.#g=e}loggerProvider(){return this.#c}replaceLoggerProvider(e){this.#c=e}eventLogger(){return this.#l}eventLoggerOwner(){return this.#p}attachEventLogger(e,m){if(this.#l=e,this.#p=e?m:null,!e)return;let P=this.#i;if(this.#i=null,P)for(let J of P)e.emit(J)}bufferPendingEvent(e){if(this.#i===null||this.#i.length>=100)return!1;return this.#i.push(e),!0}closeWindow(e){this.#i=null,this.#f=e}windowCloseCause(){return this.#f}isWindowOpen(){return this.#i!==null}hostOtel(){return this.#S}meterProvider(){return this.#m}replaceMeterProvider(e){this.#m=e}tracerProvider(){return this.#y}replaceTracerProvider(e){this.#y=e}cachedTelemetryResource(){return this.#b}replaceCachedTelemetryResource(e){this.#b=e}cachedOtlpHttpAgentFactory(e,m){return this.#h[e?"proxied":"direct"][m]}replaceCachedOtlpHttpAgentFactory(e,m,P){this.#h[e?"proxied":"direct"][m]=P}inClusterOtlpTrustRoots(){return this.#_}replaceInClusterOtlpTrustRoots(e){this.#_=e}inClusterOtlpAgentFactory(){return this.#k}replaceInClusterOtlpAgentFactory(e){this.#k=e}reset(){this.#e=null,this.#t=null,this.#n=null,this.#s=null,this.#r=null,this.#o=null,this.#a=null,this.#u=null,this.#d=null,this.#g=null,this.#c=null,this.#l=null,this.#p=null,this.#i=[],this.#f=null,this.#S=Qa(),this.#m=null,this.#y=null,this.#b=null,this.#h=Za(),this.#_=null,this.#k=null}}function el(e,m){return e.accountUuid===m.accountUuid&&e.emailAddress===m.emailAddress&&e.organizationUuid===m.organizationUuid}class Js{#e=void 0;#t=null;#n=void 0;#s=!1;#r=null;#o=null;#a=void 0;#u=void 0;#d=new Set;#g=new Map;#c=void 0;#l=null;#p=new Set;#i=null;#f=0;#S=null;#m=null;#y=null;#b=!1;#h=[];#_="single";#k=null;#x=!1;#C=!1;#A=()=>!1;#w=null;#v=void 0;#E=null;#P=null;sessionIngressToken(){return this.#e}replaceSessionIngressToken(e){this.#e=e}inferenceRequestToken(){return this.#t}replaceInferenceRequestToken(e){this.#t=e}oauthTokenFromFd(){return this.#n}replaceOauthTokenFromFd(e){this.#n=e}oauthTokenFromBgSnapshot(){return this.#s}replaceOauthTokenFromBgSnapshot(e){this.#s=e}loginStashedInTokenSlot(){return this.#r}replaceLoginStashedInTokenSlot(e){this.#r=e}oauthOrgFromBgSnapshot(){return this.#o}replaceOauthOrgFromBgSnapshot(e){this.#o=e}oauthScopesFromFd(){return this.#a}replaceOauthScopesFromFd(e){this.#a=e}apiKeyFromFd(){return this.#u}replaceApiKeyFromFd(e){this.#u=e}descriptorAnnouncementConsumed(e){return this.#d.has(e)}markDescriptorAnnouncementConsumed(e){this.#d.add(e)}credentialRoad(e){return this.#g.get(e)}noteCredentialRoad(e,m,P){if(P!==null&&!this.#g.has(e))this.#g.set(e,m)}gatewayTokenFromDescriptor(){return this.#c}replaceGatewayTokenFromDescriptor(e){this.#c=e}resetFdCredentialState(){this.#e=void 0,this.#n=void 0,this.#s=!1,this.#r=null,this.#o=null,this.#a=void 0,this.#u=void 0}gatewayAuth(){return this.#l}replaceGatewayAuth(e){this.#l=e}isGatewayHostHeldStrict(e){return this.#p.has(e)}holdGatewayHostStrict(e){this.#p.add(e)}releaseGatewayHost(e){this.#p.delete(e)}gatewayServerProcess(){return this.#C}replaceGatewayServerProcess(e){this.#C=e}gatewayRequiredByHostPolicy(){return this.#A()}replaceGatewayRequiredByHostPolicyReader(e){this.#A=e}authenticatedAccount(){return this.#i}authenticatedAccountEpoch(){return this.#f}stampAuthenticatedAccount(e){let m=this.#i;if(e!==null&&m!==null&&el(e,m)){if(e.seatTier!==m.seatTier)this.#i=e;return}this.#f+=1,this.#i=e,this.#S=null;let P=e!==null&&this.#y!==null&&el(e,this.#y);if(this.#y=null,this.#b=!1,this.#x=!1,!P)this.#m=null,this.#h=[],this.#_="single",this.#k=null}dropAuthenticatedAccountForNewToken(e){let m=this.#i??this.#y,P=!e||this.#i===null&&this.#b,J=this.#m,Z=this.#h,pe=this.#_,fe=this.#k;this.stampAuthenticatedAccount(null),this.#y=m,this.#b=P,this.#m=J,this.#h=Z,this.#_=pe,this.#k=fe,this.#x=!0}tokenAdoptedSinceStamp(){return this.#x}programUseCaseOwner(){return this.#b?null:this.#y}programUseCaseAwaitsAccount(){return this.#b}bearerPlan(){return this.#S}replaceBearerPlan(e){this.#S=e}programUseCaseId(){return this.#m}replaceProgramUseCaseId(e){this.#m=e}programUseCaseChoices(){return this.#h}replaceProgramUseCaseChoices(e){this.#h=e}programUseCaseChoiceMode(){return this.#_}replaceProgramUseCaseChoiceMode(e){this.#_=e}programUseCaseRefusal(){return this.#k}replaceProgramUseCaseRefusal(e){this.#k=e}startupPolicySnapshot(){return this.#v}replaceStartupPolicySnapshot(e){this.#v=e}gatewayRefreshInFlight(){return this.#w}replaceGatewayRefreshInFlight(e){this.#w=e}sdkOAuthTokenRefreshCallback(){return this.#E}replaceSdkOAuthTokenRefreshCallback(e){this.#E=e}hostAuthTokenRefreshCallback(){return this.#P}replaceHostAuthTokenRefreshCallback(e){this.#P=e}resetForTests(){this.#e=null,this.#t=null,this.#n=null,this.#s=!1,this.#r=null,this.#a=void 0,this.#u=null,this.#d.clear(),this.#g.clear(),this.#c=void 0,this.#l=null,this.#p.clear(),this.#i=null,this.#f=0,this.#S=null,this.#y=null,this.#b=!1,this.#m=null,this.#h=[],this.#_="single",this.#k=null,this.#x=!1,this.#C=!1,this.#A=()=>!1,this.#w=null,this.#v=void 0,this.#E=null,this.#P=null}}class Ys{#e=void 0;#t=!1;#n=!1;#s;directConnectServerUrl(){return this.#e}replaceDirectConnectServerUrl(e){this.#e=e}connectNonBlocking(){return this.#t}replaceConnectNonBlocking(e){this.#t=e}strictConfig(){return this.#n}replaceStrictConfig(e){this.#n=e}registerEnsureConnectedClient(e){this.#s=e}ensureConnectedClient(){return this.#s}reset(){this.#e=void 0,this.#t=!1,this.#n=!1}}class Xs{#e=null;#t=new Map;#n=new Map;#s=new Set;#r=new Set;#o=new Set;#a=new Map;#u=new Map;#d=new Map;#g=!1;#c=!1;#l=!1;#p=!1;#i=!1;#f=!1;#S=!1;#m=!1;#y=!1;#b=!1;#h=!1;#_=!1;#k=new Set;#x=!1;#C=new Set;#A=!1;#w=!1;#v=!1;#E=!1;#P=!1;#T=!1;#R=new Map;#O=void 0;#L=void 0;#I=!1;#D=void 0;#U=!1;#M=!1;#H=!1;#F=!1;#B=!1;#K=!1;#j=void 0;#N=void 0;#W=void 0;#G=!1;#$=new Map;#V=new Map;promptCache1hAllowlist(){return this.#e}replacePromptCache1hAllowlist(e){this.#e=e}thinkingTypeOverrides(){return this.#t}recordThinkingTypeOverride(e,m){this.#t.set(e,m)}servedModelsByRequestedModel(){return this.#n}recordServedModels(e,m){this.#n.set(e,m)}effortUnsupportedModels(){return this.#s}markEffortUnsupported(e){this.#s.add(e)}structuredOutputsUnsupportedModels(){return this.#r}markStructuredOutputsUnsupported(e){this.#r.add(e)}clearStructuredOutputsUnsupported(){this.#r=new Set}context1mRefusedModels(){return this.#o}markContext1mRefused(e){this.#o.add(e)}clearContext1mRefused(){this.#o=new Set}learnedMaxTokens(){return this.#a}refusedBetas(e){return this.#u.get(e)??[]}markBetaRefused(e,m){let P=this.#u.get(e);if(P)P.add(m);else this.#u.set(e,new Set([m]))}learnedEffortCaps(){return this.#d}midConvCachePromotionRejected(){return this.#g}markMidConvCachePromotionRejected(){this.#g=!0}toolProvenanceServerUrlRefused(){return this.#c}markToolProvenanceServerUrlRefused(){this.#c=!0}perTurnEffortOkEmitted(){return this.#l}markPerTurnEffortOkEmitted(){this.#l=!0}lateToolAdditionsOkEmitted(){return this.#p}markLateToolAdditionsOkEmitted(){this.#p=!0}toolResultScreeningOkEmitted(){return this.#i}markToolResultScreeningOkEmitted(){this.#i=!0}toolChangeHeaderRefused(){return this.#f}markToolChangeHeaderRefused(){this.#f=!0}promptEndMarkRefused(){return this.#S}markPromptEndMarkRefused(){this.#S=!0}inlineToolsRefused(){return this.#m}markInlineToolsRefused(){this.#m=!0}inlineToolsOkEmitted(){return this.#y}markInlineToolsOkEmitted(){this.#y=!0}thinkingResumptionRefused(){return this.#b}markThinkingResumptionRefused(){this.#b=!0}toolSearchNotAllowed(){return this.#h}markToolSearchNotAllowed(){this.#h=!0}everyTurnDenyHolds(){return this.#_}markEveryTurnDenyHolds(){this.#_=!0}refusedBetaHeaders(){return this.#k}markBetaHeaderRefused(e){this.#k.add(e)}unmarkBetaHeaderRefused(e){this.#k.delete(e)}thinkingHighlightsRefused(){return this.#x}markThinkingHighlightsRefused(){this.#x=!0}toolChangeUnsupportedModels(){return this.#C}markToolChangeUnsupportedModel(e){this.#C.add(e)}internalModelFieldsRefused(){return this.#A}markInternalModelFieldsRefused(){this.#A=!0}internalModelFieldsRefusalAnnounced(){return this.#w}markInternalModelFieldsRefusalAnnounced(){this.#w=!0}thirdPartyServerClassifierRefused(){return this.#v}markThirdPartyServerClassifierRefused(){this.#v=!0}releaseThirdPartyServerClassifierRefusal(){this.#v=!1}serverCheckEntryAnswered(){return this.#E}markServerCheckEntryAnswered(){this.#E=!0}serverCheckRefusalSuspected(){return this.#P}markServerCheckRefusalSuspected(){this.#P=!0}threadsHeldForServerClassifier(){return this.#T}markThreadsHeldForServerClassifier(){this.#T=!0}autoModeUnavailableResponse(e){return this.#R.get(e)}autoModeUnavailableResponsesInARow(e,{noCheckOnly:m=!1}={}){let P=0;for(let J of this.#R.values())if(J.runKey===e&&(!m||J.noCheck))P++;return P}dropAutoModeUnavailableResponsesOfOtherTurns(e,m){for(let[P,J]of this.#R)if(J.runKey===e&&J.turn!==void 0&&J.turn!==m)this.#R.delete(P)}noteAutoModeUnavailableResponse(e,m){this.#R.set(e,m)}clearAutoModeUnavailableResponses(e){for(let[m,P]of this.#R)if(P.runKey===e)this.#R.delete(m)}setAutoModeUnavailableStopNotice(e){this.#O=e}autoModeUnavailableStopNotice(){return this.#O}setLocalCommandExitCode(e){this.#L=e}localCommandExitCode(){return this.#L}observedGateway(){return this.#j}serverClassifierFallbackChoice(){return this.#N}setServerClassifierFallbackChoice(e){this.#N=e}clearServerClassifierFallbackChoice(){this.#N=void 0}openAutoModeEndOffer(){return this.#W}setOpenAutoModeEndOffer(e){this.#W=e}keepsLocalClassifierFallback(){return this.#G}keepLocalClassifierFallback(){this.#G=!0}noteObservedGateway(e){this.#j??=e}takeServerClassifierFallbackAnnouncement(){if(!this.#v||this.#I)return!1;return this.#I=!0,!0}takeFallbackUnacknowledgedAnnouncement(){if(!this.#v||this.#K)return!1;return this.#K=!0,!0}noteNoServerCheck(e){if(this.#D!==void 0)return!1;return this.#D=e,!0}noteNoServerCheckStoppedTurn(){this.#M=!0}takeNoServerCheckStoppedTurn(){let e=this.#M;return this.#M=!1,e}serverCheckDeclined(){return this.#H}setServerCheckDeclined(e){this.#H=e}noteRefusedStreakStoppedTurn(){this.#F=!0}takeRefusedStreakStoppedTurn(){let e=this.#F;return this.#F=!1,e}blockLimitStopHeld(){return this.#B}setBlockLimitStopHeld(e){this.#B=e}takeNoServerCheckAnnouncement(){if(this.#U||this.#D===void 0)return;return this.#U=!0,this.#D}inferenceProfileBackingModels(){return this.#$}recordInferenceProfileBackingModel(e,m){this.#$.set(e,m)}foundryDeploymentCapabilities(){return this.#V}reset(){this.#e=null,this.#t=new Map,this.#n=new Map,this.#s=new Set,this.#r=new Set,this.#o=new Set,this.#a=new Map,this.#u=new Map,this.#d=new Map,this.#g=!1,this.#c=!1,this.#l=!1,this.#p=!1,this.#i=!1,this.#f=!1,this.#S=!1,this.#m=!1,this.#y=!1,this.#b=!1,this.#h=!1,this.#_=!1,this.#k=new Set,this.#x=!1,this.#C=new Set,this.#A=!1,this.#w=!1,this.#v=!1,this.#E=!1,this.#P=!1,this.#T=!1,this.#R.clear(),this.#O=void 0,this.#L=void 0,this.#I=!1,this.#K=!1,this.#D=void 0,this.#U=!1,this.#M=!1,this.#H=!1,this.#F=!1,this.#B=!1,this.#j=void 0,this.#N=void 0,this.#W=void 0,this.#G=!1,this.#$=new Map,this.#V=new Map}}class Zs{#e=!1;#t=!1;longContext1mCreditsBlocked(){return this.#e}replaceLongContext1mCreditsBlocked(e){this.#e=e}usageCreditsRequired(){return this.#t}replaceUsageCreditsRequired(e){this.#t=e}reset(){this.#e=!1,this.#t=!1}}class Qs{#e=!1;#t=!1;#n=tl;#s=p();selectorGate(){return this.#e}selectorGateEverOn(){return this.#t}replaceSelectorGate(e){this.#e=e,this.#t||=e}inheritSelectorGateEverOn(){this.#t=!0}resampleSelectorGate(e){let m=this.#e;if(this.#e=e,this.#t||=e,m!==e)this.#s.emit(e)}subscribeSelectorGateChanged(e){return this.#s.subscribe(e)}replaceHostGateSubscription(e){let m=this.#n;this.#n=e,m()}dropHostGateSubscription(){this.replaceHostGateSubscription(tl)}}function tl(){}class ei{started=!1;stagingFilesRemoved=!1;claim(){if(this.started)return!1;return this.started=!0,!0}claimStagingFilesRemoval(){if(this.stagingFilesRemoved)return!1;return this.stagingFilesRemoved=!0,!0}}class ti{clock;backgroundHousekeeping;launchOptions;settingsSource;extensionsConfig;modelStringsCache;diagnostics;telemetryHandles;credentialSlots;mcpProcessWiring;requestLatches;accountCreditLatches;proactivity;constructor(e){this.clock=e.clock,this.backgroundHousekeeping=e.backgroundHousekeeping,this.launchOptions=e.launchOptions,this.settingsSource=e.settingsSource,this.extensionsConfig=e.extensionsConfig,this.modelStringsCache=e.modelStringsCache,this.diagnostics=e.diagnostics,this.telemetryHandles=e.telemetryHandles,this.credentialSlots=e.credentialSlots,this.mcpProcessWiring=e.mcpProcessWiring,this.requestLatches=e.requestLatches,this.accountCreditLatches=e.accountCreditLatches,this.proactivity=e.proactivity}}function nl(){return new ti({clock:new no,backgroundHousekeeping:new ei,launchOptions:new Ws,settingsSource:new Gs,extensionsConfig:new $s,modelStringsCache:new Vs,diagnostics:new qs,telemetryHandles:new zs,credentialSlots:new Js,mcpProcessWiring:new Ys,requestLatches:new Xs,accountCreditLatches:new Zs,proactivity:new Qs})}function _c(e=Xo()){return $a({host:nl(),id:zi()??Q(),project:{originalCwd:e,projectRoot:e,cwd:e}})}var ho=_c(ra);function A(){return ir()}function ir(){return rl()?.session??ho}function q(e){return e.of(ho.host)}var rl=()=>{return};Ga((e)=>ja.of(ir().host).reporter?.(e));za({isDiskless:()=>g(),isDisklessProcess:()=>Gt(),reportBuilt:(e)=>Ja.of(ir().host).reporter?.(e)});function ol(){let e=rl();if(e?.session)return e.session.id;return e?.sessionId??ho.id}var v_=new _e(()=>p());var x_=new _e(()=>p());function yn(){return ir().host.launchOptions.isInteractive()}function bn(){return ir().host.launchOptions.isInteractivityDecided()}function Cn(){return ir().host.launchOptions.isNoDialogLaunch()}var E_=new _e(()=>p());var C_=new _e(()=>p());function An(){return ir().host.credentialSlots.gatewayAuth()}function g(){return Kt()}function Kt(){return ir().host.launchOptions.diskless()}function Gt(){return ho.host.launchOptions.diskless()}function Rn(){return ir().host.launchOptions.ccrDerivedSurface()}var w_=new s(()=>p());function i(e,m){return{code:"InvalidArgument",argument:e,...m!==void 0&&{reason:m}}}var ht={home:(e)=>({space:"home",path:e}),workspace:(e)=>({space:"workspace",path:e}),system:(e)=>({space:"system",path:e}),userNamed:(e)=>({space:"userNamed",path:e})};var ni=globalThis.process?.getBuiltinModule?.("async_hooks"),sl=ni!==void 0,ri=ni?new ni.AsyncLocalStorage:{run:(e,m)=>m(),getStore:()=>{return}};function il({writeBatch:e,sizeOf:m,flushIntervalMs:P=1000,maxBufferSize:J=100,maxBufferBytes:Z=1/0,immediateMode:pe=!1}){let fe=[],ve=0,xe=null,Re=null;function Ae(){if(xe)clearTimeout(xe),xe=null}function De(at){try{e(at)}catch{}}function Ke(){if(Re)De(Re),Re=null;if(fe.length===0)return;De(fe),fe=[],ve=0,Ae()}function Be(){if(!xe)xe=setTimeout(Ke,P)}function ot(){if(Re){Re.push(...fe),fe=[],ve=0,Ae();return}let at=fe;fe=[],ve=0,Ae(),Re=at,setImmediate(()=>{let xt=Re;if(Re=null,xt)De(xt)})}return{write(at){if(pe){De([at]);return}if(fe.push(at),ve+=m(at),Be(),fe.length>=J||ve>=Z)ot()},flush:Ke,dispose(){Ke()}}}function bc(e){if(typeof e==="function")return e;if(Symbol.asyncDispose in e)return()=>e[Symbol.asyncDispose]();return()=>e[Symbol.dispose]()}class oi{#e=new Set;#t=!1;get drainStarted(){return this.#t}register(e){let m=bc(e);this.#e.add(m);let P=()=>{this.#e.delete(m)};return Object.assign(P,{[Symbol.dispose]:P})}async drain(){this.#t=!0;let e=Array.from(this.#e);this.#e.clear();let P=(await Promise.allSettled(e.map(async(J)=>J()))).find((J)=>J.status==="rejected");if(P!==void 0)throw P.reason}async[Symbol.asyncDispose](){await this.drain()}get sizeForTesting(){return this.#e.size}}class al{cleanup=new oi;preExitFlush=new oi;preExitFlushWaits=new Map}var kc=new s(()=>new al);function vc(){return q(kc)}function _t(e){return vc().cleanup.register(e)}var xc=a({read:void 0},(e)=>{e.read=void 0});function ll(){return xc.read}class dl{parsed=new Map;lookup(e){return this.parsed.get(e)}remember(e,m){this.parsed.set(e,m)}reset(){this.parsed.clear()}}var ul=new dl;function cl(e){let m=ul.lookup(e);if(m!==void 0)return m;let P=Ec(e);return ul.remember(e,P),P}function Ec(e){if(!e||e.trim()==="")return null;let m=e.split(",").map((pe)=>pe.trim()).filter(Boolean);if(m.length===0)return null;let P=m.some((pe)=>pe.startsWith("!")),J=m.some((pe)=>!pe.startsWith("!"));if(P&&J)return null;let Z=m.map((pe)=>pe.replace(/^!/,"").toLowerCase());return{include:P?[]:Z,exclude:P?Z:[],isExclusive:P}}function Cc(e){let m=[],P=e.match(/^MCP server ["']([^"']+)["']/);if(P&&P[1])m.push("mcp"),m.push(P[1].toLowerCase());else{let pe=e.match(/^([^:[]+):/);if(pe&&pe[1])m.push(pe[1].trim().toLowerCase())}let J=e.match(/^\[([^\]]+)]/);if(J&&J[1])m.push(J[1].trim().toLowerCase());if(e.toLowerCase().includes("1p event:"))m.push("1p");let Z=e.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(Z&&Z[1]){let pe=Z[1].trim().toLowerCase();if(pe.length<30&&!pe.includes(" "))m.push(pe)}return Array.from(new Set(m))}function wc(e,m){if(!m)return!0;if(e.length===0)return!1;if(m.isExclusive)return!e.some((P)=>m.exclude.includes(P));else return e.some((P)=>m.include.includes(P))}function pl(e,m){if(!m)return!0;let P=Cc(e);return wc(P,m)}import{homedir as Pc}from"os";import{basename as tb,dirname as nb,join as Oc,resolve as gl}from"path";var Rc=/^[+-]?(\d+(\.\d*)?|\.\d+)[eE][+-]?\d+$/,Ac=/^[+-]?\d{1,3}([_,\u00A0\u202F ])\d{3}(?:\1\d{3})*$/,Tc=/[_,\u00A0\u202F ]/g;function $t(e){if(e.length<=32){if(Rc.test(e)){let m=Number(e);return Number.isInteger(m)?m:NaN}if(Ac.test(e))return parseInt(e.replace(Tc,""),10)}return}function Me(e){let m=String(e).trim();return $t(m)??parseInt(m,10)}var gt=[["claude-3-5-sonnet","VERTEX_REGION_CLAUDE_3_5_SONNET"],["claude-3-7-sonnet","VERTEX_REGION_CLAUDE_3_7_SONNET"],["claude-sonnet-4-5","VERTEX_REGION_CLAUDE_4_5_SONNET"],["claude-sonnet-4-6","VERTEX_REGION_CLAUDE_4_6_SONNET"],["claude-sonnet-5-5","VERTEX_REGION_CLAUDE_5_5_SONNET"],["claude-3-5-haiku","VERTEX_REGION_CLAUDE_3_5_HAIKU"],["claude-fable-5-1","VERTEX_REGION_CLAUDE_FABLE_5_1"],["claude-fable-5-2","VERTEX_REGION_CLAUDE_FABLE_5_2"],["claude-haiku-4-5","VERTEX_REGION_CLAUDE_HAIKU_4_5"],["claude-haiku-5-5","VERTEX_REGION_CLAUDE_HAIKU_5_5"],["claude-opus-4-1","VERTEX_REGION_CLAUDE_4_1_OPUS"],["claude-opus-4-5","VERTEX_REGION_CLAUDE_4_5_OPUS"],["claude-opus-4-6","VERTEX_REGION_CLAUDE_4_6_OPUS"],["claude-opus-4-7","VERTEX_REGION_CLAUDE_4_7_OPUS"],["claude-opus-4-8","VERTEX_REGION_CLAUDE_4_8_OPUS"],["claude-opus-5-5","VERTEX_REGION_CLAUDE_5_5_OPUS"],["claude-sonnet-4","VERTEX_REGION_CLAUDE_4_0_SONNET"],["claude-sonnet-5","VERTEX_REGION_CLAUDE_5_SONNET"],["claude-fable-5","VERTEX_REGION_CLAUDE_FABLE_5"],["claude-opus-4","VERTEX_REGION_CLAUDE_4_0_OPUS"],["claude-opus-5","VERTEX_REGION_CLAUDE_5_OPUS"]];function Ur(){return process.env.CLAUDE_CONFIG_DIR}function G(e){let m=e==="CLAUDE_CONFIG_DIR"?Ur():process.env[e];if(m===void 0)return;let P=String(m).trim();return P?P:void 0}function mt(e){return d(process.env[e])}function fl(e,m){let P=a(new Map,(Z)=>Z.clear());function J(){let Z=m(),pe=P.get(Z);if(pe)return pe.value;let fe=e();return P.set(Z,{value:fe}),fe}return Object.assign(J,{cache:P})}var R=fl(()=>(Ur()??Oc(Pc(),".claude")).normalize("NFC"),Ur);function Ee(){return fo()?null:R()}function Dn(e){let m=Ee();return m===null||e===null?m===e:gl(m)===gl(e)}function hl(){return process.env.CLAUDE_CODE_PROJECT_DIR_NAME}var Lc=/^[A-Za-z0-9_-]{1,64}$/,Ic=/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/i;function si(e){if(!e||!Lc.test(e)||Ic.test(e))return;return e}function Dc(){return`${fo()}\x00${Ur()??""}\x00${hl()??""}`}var ml=fl(()=>Ur()||fo()?si(hl()):void 0,Dc);import*as Pt from"fs";import{appendFile as Hc,copyFile as Bc,link as Kc,lstat as ui,mkdir as jc,open as mo,readdir as Wc,readFile as _l,readlink as Gc,realpath as $c,rename as Vc,rmdir as qc,rm as zc,stat as bl,unlink as Jc}from"fs/promises";import*as Lt from"path";function ie(){return process.versions.bun!==void 0}var Mc=0xffffffffffffffffn;function qe(e){let m=BigInt(e);return m===0n||m===-1n||m===Mc||m===1n<<64n}function xn(e,m){return!qe(e.ino)&&!qe(m.ino)&&e.ino!==m.ino}var ii=[];function ai(){return ii.pop()??Buffer.allocUnsafeSlow(65536)}function li(e,m){if(e.fill(0,0,Math.min(m,e.length)),ii.length<2)ii.push(e)}var bb=(()=>{let e=process.env.CLAUDE_CODE_SLOW_OPERATION_THRESHOLD_MS;if(e!==void 0){let m=Number(e);if(!Number.isNaN(m)&&m>=0)return m}return 1/0})();var Nc={[Symbol.dispose](){}};function Uc(){return Nc}var O=Uc;function o(e,m,P){return JSON.stringify(e,m,P)}var S=(e,m)=>{let J=[];try{const P=y(J,O`JSON.parse(${yl(e)})`,0);return typeof m>"u"?JSON.parse(e):JSON.parse(e,m)}catch(Z){var pe=Z,fe=1}finally{b(J,pe,fe)}};function vn(e){return JSON.parse(e)}function L(e,m){let J=[];try{const P=y(J,O`structuredClone(${yl(e)})`,0);return structuredClone(e,m)}catch(Z){var pe=Z,fe=1}finally{b(J,pe,fe)}}function yl(e){return typeof e==="string"?e.length:e}var Yc="→";function Xc(){return process.platform==="win32"?0:Pt.constants.O_NOFOLLOW|Pt.constants.O_NONBLOCK}function St(){return process.platform==="win32"?"r":Pt.constants.O_RDONLY|Pt.constants.O_NONBLOCK|Pt.constants.O_NOCTTY}var wr=process.platform==="win32"?/[\\/]+/:/\/+/;function Vt(e,m){let P=(ve)=>ve.split(wr).filter(Boolean),J=Lt.resolve(e),Z=Lt.resolve(m),pe=P(J),fe=P(Z);return Lt.parse(J).root===Lt.parse(Z).root&&pe.length<fe.length&&pe.every((ve,xe)=>ve===fe[xe])}function di(e){let m="";for(let J of e.split(/([\\/]+)/)){if(J==="."||J==="..")break;m+=J}let P=m.replace(/(?<=[^\\/])[\\/]+$/,"");return P===""?e:P}function Zc(e,m){if(process.platform==="win32"||m?.surfaceNetworkRaw===!0||!ie()||e.includes("�"))return e;let P=[];for(let J of e.split(Lt.sep)){if(J===".."&&P.length>1)break;if(J==="..")P.pop();else if(J!==""&&J!==".")P.push(J)}return Lt.sep+P.join(Lt.sep)}function Qc(e){let m=Lt.join(e).replace(/(?<=[^\\/])[\\/]+$/,"");if(cn(m)&&!H(m))return m;return di(e)}function ep(e){if(e.startsWith("\\\\"))return di(e);let m=e.replace(/^\/+/,"/"),P=lo(m);if(P!==null)return P;return di(e)}var Cl=process.platform==="win32"?Qc:ep;function yo(e,m,P){let J=dn(e);if(m.length===0||J||m.some((Z)=>Z==="."||Z==="..")){if(P!==void 0&&(m.length>0||J))P(Lt.join(e,...m));return J?Cl(e):e}return Lt.join(e,...m)}var j="\x00unverified-ancestry",Xe="\x00opaque-link-text";function tp(e){return je(Lt.isAbsolute(e)?e:e.replace(/^(?:\.\.(?:[\\/]+|$))+/,""))}function np(e,m=process.platform==="win32"){return e.includes("�")||tp(e)||m&&(/^(?:[A-Za-z]:(?![\\/])|[\\/](?![\\/]))/.test(e)||/^[\\/]{2}\?[\\/]/.test(e)&&!/^[\\/]{2}\?[\\/](?:[A-Za-z]:[\\/]|UNC[\\/])/i.test(e)||e.split(/[\\/]/).some((P)=>P!=="."&&P!==".."&&/[. ]$/.test(P)))}function kl(e,m,P=!1,J=!1,Z=!1){if(m?.unreadableAncestry!=="unverified")return;let pe=e!==void 0&&typeof e==="object"&&"errno"in e?e.errno:void 0;if(pe==="ENOENT"||pe==="ENOTDIR")return;if(pe==="ENAMETOOLONG"&&!P&&!J&&!Z)return;return j}function Kr(e){return sr(e)}function So(e,m){return m!==void 0&&m.some((P)=>sr(P)&&!Hs(e,P)&&(ci(e,P)||pn(e)))}function vl(e,m){return m!==void 0&&m.some((P)=>sr(P)&&ci(P,e))}function ci(e,m){let P=(pe)=>pe.length>1?pe.replace(/\/+$/,""):pe,[J,Z]=[P(e),P(m)];return J===Z||J.startsWith(Z==="/"?Z:Z+"/")}function Hr(e,m){return m===void 0||m.every((P)=>Hs(e,P))}function xl(e,m){return m===void 0||m.every((P)=>wa(e,P))}function El(e,m,P){let J=pn(e)?lo(e):null;if(J===null||!Hr(J,m))return;let Z=Lt.join(e);if(pn(Z)&&Mr(Z)===Mr(J))return Z;return yo(e,[],P)}function rp(e){if(e?.anchors!==void 0&&e.anchors.length>0)return e.anchors;return e?.anchor!==void 0?[e.anchor]:void 0}async function Yt(e,m=Al){return je(e)||Le(e)||V(e)||ur(e)||await Et(m,e,{surfaceNetworkRaw:!0,unreadableAncestry:"unverified"})!==void 0}function Ne(e,m,P){return op(wl(m,P),(J)=>{if(J.kind==="lstat")return e.lstatSync(J.path);if(J.kind==="opendirNofollow")return e.openDirNoFollowSync(J.path),"ok";return e.readlinkSync(J.path)})}function Et(e,m,P,J,Z){return sp(wl(m,P),J,async(pe)=>{if(pe.kind==="lstat"){if(Z===void 0)return e.lstat(pe.path);let fe;try{fe=await e.lstatBigint(pe.path)}catch(ve){throw Z(pe.path,void 0),ve}return Z(pe.path,fe),fe}if(pe.kind==="opendirNofollow")return await e.openDirNoFollow(pe.path),"ok";return e.readlink(pe.path)})}function op(e,m){let P;for(;;){let J=e.next(P);if(J.done)return J.value;try{P=m(J.value)}catch(Z){P={errno:r(Z)}}}}async function sp(e,m,P){let J;for(;;){let Z=e.next(J);if(Z.done)return Z.value;if(m?.aborted===!0)return j;try{J=await P(Z.value)}catch(pe){J={errno:r(pe)}}}}function*wl(e,m){let P=rp(m),J=(st)=>Kr(st)&&(m?.surfaceNetworkRaw===!0||P!==void 0||Nr(st)||pn(st));if(J(e)&&!So(e,P))return e;if(cn(e)&&!H(e)&&xl(e,P)||pn(e)&&Hr(e,P))return;let Z=Lt.resolve(e),pe=Lt.parse(Z).root,fe=pe,ve=Z.slice(pe.length).split(wr).filter(Boolean),xe=0,Re,Ae=ve.length,De=!1,Ke=!1,Be,ot=64,at=()=>ve.some((st)=>dn(st)),xt=()=>/[. ]$/.test(ve[0]);while(ve.length>0&&xe<ot){if(De&&dn(ve[0]))return j;let st=Lt.join(fe,ve[0]);if(pn(st)&&Hr(st,P)||J(st)&&!(So(st,P)||vl(st,P)))return yo(st,ve.slice(1),m?.onCollapsedLanding);if(re(st)){if(m?.surfaceNetworkRaw===!0||m?.unreadableAncestry==="unverified")return j;return yo(st,ve.slice(1),m?.onCollapsedLanding)}let kt=process.platform==="darwin"&&st!=="/dev/fd"&&ci(st,"/dev/fd");if(kt&&Lt.dirname(st)==="/dev/fd"&&ve.some((qn,_r)=>_r>0&&(qn===".."||qn==="."))){ve.shift();while(ve[0]==="."&&ve.length>1)ve.shift();fe=st;continue}let it=kt?{errno:"ENOENT"}:yield{kind:"lstat",path:st};if(it===void 0||typeof it==="string"||"errno"in it){if(process.platform!=="win32"&&typeof it==="object"&&"errno"in it&&it.errno!==void 0&&it.errno!=="ENOENT"&&it.errno!=="ENOTDIR"&&it.errno!=="ENAMETOOLONG"){if(typeof(yield{kind:"opendirNofollow",path:st})==="string"){Ke=!0,ve.shift(),fe=st;continue}}if(m?.launchAncestry&&!Ke&&typeof it==="object"&&"errno"in it&&(it.errno==="EPERM"||it.errno==="EACCES")&&Vt(st,m.launchAncestry)){De=!0,ve.shift(),fe=st;continue}if(typeof it==="object"&&"errno"in it&&(it.errno==="ENOENT"||it.errno==="ENOTDIR"))m?.onOutcome?.({kind:"absent",at:fe,remaining:[...ve],fromLinkTarget:ve.length>Ae,...it.errno==="ENOTDIR"&&{notAFolder:!0}});return kl(it,m,xe>0,at(),xt())}let un=it;if(Ke=!0,!un.isSymbolicLink()){ve.shift(),fe=st;continue}xe++;let Dt=st+"\x00"+ve.join("\x00");if((Be??=new Set).has(Dt))return;Be.add(Dt);let fn=yield{kind:"readlink",path:st};if(typeof fn!=="string")return kl(fn,m,xe>0,at(),xt());let It=fn;if(m?.literalLinkText!==void 0&&(m.literalLinkText==="opaque"?np(It):It.includes("�")))return Xe;if(Re!==void 0&&It.includes("�"))return Re;if(!Lt.isAbsolute(It)){let qn=It.split(wr).filter(Boolean);if(m?.surfaceNetworkRaw===!0){let _r=El((fe.endsWith(Lt.sep)?fe:fe+Lt.sep)+[...qn,...ve.slice(1)].join(Lt.sep),P,m?.onCollapsedLanding);if(_r!==void 0)return _r}ve.shift(),m?.onHop?.({composed:Lt.resolve(fe,It,...ve),leaf:ve.length===0,text:It}),Ae=Math.min(Ae,ve.length),ve=[...qn,...ve];continue}let vt=It;if(m?.surfaceNetworkRaw===!0&&ve.length>1&&ur(vt)){let qn=El([vt,...ve.slice(1)].join(Lt.sep),P,m?.onCollapsedLanding);if(qn!==void 0)return qn}if(cn(vt)&&!H(vt)&&xl(vt,P)||pn(Zc(vt,m))&&Hr(vt,P)||!dn(vt)&&J(vt)&&!(So(vt,P)||ve.length>1&&vl(vt,P)))return ve.shift(),yo(vt,ve,m?.onCollapsedLanding);if(pn(vt)||Kr(vt))m?.onCollapsedLanding?.(Lt.join(vt,...ve.slice(1)));if(pn(vt)&&Hr(vt,P))Re??=Cl(vt);else if(Nr(vt))Re??="/Network";if(Re!==void 0&&It.includes("�"))return Re;if(m?.surfaceNetworkRaw===!0&&dn(vt)&&(cn(vt)||V(vt)||sr(vt)||ur(vt)))return ve.shift(),ve.length===0?vt:vt+Lt.sep+ve.join(Lt.sep);ve.shift();let or=Lt.parse(vt).root||Lt.sep,ar=Lt.parse(st).root,Lr=/^[\\/]$/.test(or)&&ar!==""&&!/^[\\/]$/.test(ar);if(Lr&&(m?.surfaceNetworkRaw===!0||m?.unreadableAncestry==="unverified"))return j;m?.onHop?.({composed:ve.length===0?vt:Lt.resolve(vt,...ve),leaf:ve.length===0,text:It}),fe=Lr?ar:or,Ke=!1,Ae=Math.min(Ae,ve.length),ve=[...vt.slice(or.length).split(wr).filter(Boolean),...ve]}if(ve.length>0&&m?.literalLinkText==="opaque")return Xe;if(ve.length>0)return j;if(xe>0&&ur(fe))return fe;if(J(fe)&&!So(fe,P))return fe;m?.onOutcome?.({kind:"resolved",path:fe});return}function ye(e,m){if(cn(m)&&!H(m)||pn(m)||Nr(m))return{resolvedPath:m,isSymlink:!1,isCanonical:!1};let P=Ne(e,m);if(P===j)return{resolvedPath:m,isSymlink:!1,isCanonical:!1};if(P!==void 0)return{resolvedPath:P,isSymlink:!0,isCanonical:!1};try{let J=ip(e,m);return{resolvedPath:J,isSymlink:J!==m,isCanonical:!0}}catch(J){return{resolvedPath:m,isSymlink:!1,isCanonical:!1}}}function Rl(e){let m=Zo();if(m===null)return null;try{let P=Lt.resolve(m),J=Lt.resolve(e.cwd()),Z=Lt.parse(P).root;if(Z!==Lt.parse(J).root)return null;let pe=P.slice(Z.length).split(wr).filter(Boolean),fe=J.slice(Z.length).split(wr).filter(Boolean),ve=0;while(ve<pe.length&&ve<fe.length&&pe[ve]===fe[ve])ve++;return ve>0?Lt.join(Z,...pe.slice(0,ve)):null}catch{return null}}function ip(e,m){try{return e.realpathSync(m)}catch(P){let J=r(P);if(J!=="EPERM"&&J!=="EACCES")throw P;let Z,pe=Rl(e);if(Ne(e,m,{unreadableAncestry:"unverified",surfaceNetworkRaw:!0,launchAncestry:pe,onOutcome:(ve)=>{Z=ve}})!==void 0||Z===void 0)throw P;if(Z.kind==="absent")throw Object.assign(Error("ENOENT: no such file or directory"),{code:"ENOENT",syscall:"realpath",path:m});return _(Z.path)}}var Br="ERR_SYMLINK_TO_NETWORK_PATH";function Je(e,m,P){let{asWritten:J,opts:Z}=up(e,m,P),pe,fe;return cp(Ne(e,J,{...Z,onOutcome:(ve)=>{pe=ap(ve),fe=lp(ve)}}),m,J),{...dp(J),linksResolvedPath:pe,absentAt:fe}}function ap(e){return e.kind==="resolved"?_(e.path):void 0}function lp(e){return e.kind==="absent"?{at:e.at,remaining:e.remaining,fromLinkTarget:e.fromLinkTarget,...e.notAFolder&&{notAFolder:!0}}:void 0}function up(e,m,P){let J=oe(m);if(ne(J)||Us(J))throw Object.assign(Error("Refusing to read a file whose path could not be vetted (a device-namespace spelling; use the plain drive or share path)"),{code:Br,path:m,reason:"unexamined"});let Z=Lt.isAbsolute(J)?Lt.resolve(J):Lt.resolve(process.cwd(),J),pe=oe(Z);if(ne(pe)||Us(pe))throw Object.assign(Error("Refusing to read a file whose path could not be vetted (a device-namespace spelling; use the plain drive or share path)"),{code:Br,path:m,reason:"unexamined"});let fe=Kr(pe)||pn(pe)||cn(pe)&&!H(pe);return{asWritten:pe,ownHost:fe,opts:{...fe&&{anchors:[pe]},surfaceNetworkRaw:!0,literalLinkText:process.platform==="win32"?"opaque":"undecodable",...(!fe||P?.failClosed)&&{unreadableAncestry:"unverified",launchAncestry:Rl(e)}}}}function dp(e){return{resolvedPath:e,isSymlink:!1,isCanonical:!1}}function cp(e,m,P){if(e===void 0)return;let J=(pe)=>Object.assign(Error("Refusing to read a file whose path could not be vetted (a component that could not be examined, or a symbolic link chain too long to follow)"),{code:Br,path:m,reason:pe});if(e===j)throw J("unexamined");if(e===Xe)throw Object.assign(Error('Refusing to read a file whose path could not be vetted: a symbolic link on its path has a target that may lead to a different folder than the one that was checked (such as a target that is not valid UTF-8, or, on Windows, one with ".." after a folder name), or the path runs through too many links. Replace that link, or the chain of links, with a regular folder or file.'),{code:Br,path:m,reason:"unexamined"});if(Kr(P)&&e===P)return;if(!(cn(e)||V(e)||Kr(e)||ur(e)))throw J("unexamined");throw Object.assign(Error("Refusing to read a file through a symbolic link that leads onto a network share or automount path; replace the link with a regular file to use it"),{code:Br,path:m,reason:"network"})}var Al={cwd(){return process.cwd()},existsSync(e){let P=[];try{const m=y(P,O`fs.existsSync(${e})`,0);return Pt.existsSync(e)}catch(J){var Z=J,pe=1}finally{b(P,Z,pe)}},async stat(e){return bl(e)},async lstat(e){return ui(e)},async openDirNoFollow(e){if(process.platform==="win32")throw Error("openDirNoFollow is a POSIX-only examination probe");await(await mo(e,Pt.constants.O_DIRECTORY|Pt.constants.O_NOFOLLOW)).close()},openDirNoFollowSync(e){if(process.platform==="win32")throw Error("openDirNoFollowSync is a POSIX-only examination probe");let m=Pt.openSync(e,Pt.constants.O_DIRECTORY|Pt.constants.O_NOFOLLOW);Pt.closeSync(m)},async lstatBigint(e){return ui(e,{bigint:!0})},async statBigint(e){return bl(e,{bigint:!0})},async readdir(e){return Wc(e,{withFileTypes:!0})},async unlink(e){return Jc(e)},async rmdir(e){return qc(e)},async rm(e,m){return zc(e,m)},async mkdir(e,m){try{await jc(e,{recursive:!0,...m})}catch(P){if(r(P)!=="EEXIST")throw P}},async readFile(e,m){return _l(e,{encoding:m.encoding})},async rename(e,m){return Vc(e,m)},async realpath(e){return _(await $c(e))},async readlink(e){return Gc(e)},async copyFile(e,m){return Bc(e,m)},async appendFile(e,m,P){if(P?.mode!==void 0)try{let J=await mo(e,"ax",P.mode);try{await J.appendFile(m)}finally{await J.close()}return}catch(J){if(r(J)!=="EEXIST")throw J}return Hc(e,m)},async link(e,m){return Kc(e,m)},statSync(e){let P=[];try{const m=y(P,O`fs.statSync(${e})`,0);return Pt.statSync(e)}catch(J){var Z=J,pe=1}finally{b(P,Z,pe)}},lstatSync(e){let P=[];try{const m=y(P,O`fs.lstatSync(${e})`,0);return Pt.lstatSync(e)}catch(J){var Z=J,pe=1}finally{b(P,Z,pe)}},lstatBigintSync(e){let P=[];try{const m=y(P,O`fs.lstatSync(${e})`,0);return Pt.lstatSync(e,{bigint:!0})}catch(J){var Z=J,pe=1}finally{b(P,Z,pe)}},readFileSync(e,m){let J=[];try{const P=y(J,O`fs.readFileSync(${e})`,0);return Pt.readFileSync(e,{encoding:m.encoding})}catch(Z){var pe=Z,fe=1}finally{b(J,pe,fe)}},readSync(e,m){let Z=[];try{const P=y(Z,O`fs.readSync(${e}, ${m.length} bytes)`,0);let J=Pt.openSync(e,"r");try{let xe=qt(J,m.length,"file");return{buffer:xe,bytesRead:xe.length}}finally{Pt.closeSync(J)}}catch(pe){var fe=pe,ve=1}finally{b(Z,fe,ve)}},appendFileSync(e,m,P){let Z=[];try{const J=y(Z,O`fs.appendFileSync(${e}, ${m.length} chars)`,0);if(P?.mode!==void 0)try{let xe=Pt.openSync(e,"ax",P.mode);try{Pt.appendFileSync(xe,m)}finally{Pt.closeSync(xe)}return}catch(xe){if(r(xe)!=="EEXIST")throw xe}Pt.appendFileSync(e,m)}catch(pe){var fe=pe,ve=1}finally{b(Z,fe,ve)}},unlinkSync(e){let P=[];try{const m=y(P,O`fs.unlinkSync(${e})`,0);Pt.unlinkSync(e)}catch(J){var Z=J,pe=1}finally{b(P,Z,pe)}},renameSync(e,m){let J=[];try{const P=y(J,O`fs.renameSync(${e} ${Yc} ${m})`,0);Pt.renameSync(e,m)}catch(Z){var pe=Z,fe=1}finally{b(J,pe,fe)}},readlinkSync(e){let P=[];try{const m=y(P,O`fs.readlinkSync(${e})`,0);return Pt.readlinkSync(e)}catch(J){var Z=J,pe=1}finally{b(P,Z,pe)}},realpathSync(e){let P=[];try{const m=y(P,O`fs.realpathSync(${e})`,0);return _(Pt.realpathSync(e))}catch(J){var Z=J,pe=1}finally{b(P,Z,pe)}},mkdirSync(e,m){let Z=[];try{const P=y(Z,O`fs.mkdirSync(${e})`,0);let J={recursive:!0};if(m?.mode!==void 0)J.mode=m.mode;try{Pt.mkdirSync(e,J)}catch(xe){if(r(xe)!=="EEXIST")throw xe}}catch(pe){var fe=pe,ve=1}finally{b(Z,fe,ve)}},readdirSync(e){let P=[];try{const m=y(P,O`fs.readdirSync(${e})`,0);return Pt.readdirSync(e,{withFileTypes:!0})}catch(J){var Z=J,pe=1}finally{b(P,Z,pe)}},rmSync(e,m){let J=[];try{const P=y(J,O`fs.rmSync(${e})`,0);Pt.rmSync(e,m)}catch(Z){var pe=Z,fe=1}finally{b(J,pe,fe)}},createWriteStream(e){return Pt.createWriteStream(e)},async readFileBytes(e,m){if(m===void 0)return _l(e);let P=await mo(e,St());try{if(!(await P.stat()).isFile())return Buffer.alloc(0);return await yt(P,m,"file")}finally{await P.close()}},async readFileFdGated(e,m){try{let P=Xc();if(P===0){if(!(await ui(e)).isFile())return null}let J=await mo(e,Pt.constants.O_RDONLY|P);try{let Z=await J.stat();if(!Z.isFile()||Z.size>m)return null;let pe=Number(Z.size),fe=Buffer.allocUnsafe(pe),ve=0;while(ve<pe){let{bytesRead:xe}=await J.read(fe,ve,pe-ve,ve);if(xe===0)break;ve+=xe}return{content:(ve<pe?fe.subarray(0,ve):fe).toString("utf8"),stats:Z}}finally{await J.close()}}catch{return null}}};function l(){return Al}var Fb=a({hasThrown:!1},(e)=>{e.hasThrown=!1});async function yt(e,m,P){let J=P!==void 0?P==="file":(await e.stat()).isFile(),Z=[],pe=0,fe=ai();try{while(pe<m){let ve=fe.subarray(0,m-pe),{bytesRead:xe}=await e.read(ve,0,ve.length,J?pe:null);if(xe===0)break;Z.push(Buffer.from(ve.subarray(0,xe))),pe+=xe}}finally{li(fe,pe)}return Buffer.concat(Z,pe)}function qt(e,m,P){let J=[],Z=0,pe=ai();try{while(Z<m){let fe=pe.subarray(0,m-Z),ve=Pt.readSync(e,fe,0,fe.length,P==="file"?Z:null);if(ve===0)break;J.push(Buffer.from(fe.subarray(0,ve))),Z+=ve}}finally{li(pe,Z)}return Buffer.concat(J,Z)}function pp(e,m,P){if(e.destroyed||e.writableEnded)return"dropped";return e.write(m,P)===!1?"backed-up":"accepted"}class pi{everWritten=!1;drainPromise=void 0;bytesQueued=0;bytesFlushed=0;notifyFlushProgress=void 0;notifyExternallyClocked=void 0;externallyClockedPromise=void 0;externallyClocked=!1;errored=!1;flushConfirmedPromise=void 0;flushCloseListener=void 0;markEverWritten(){this.everWritten=!0}recordQueued(e){this.bytesQueued+=e}recordFlushed(e){this.bytesFlushed+=e,this.notifyFlushProgress?.()}markErrored(){this.errored=!0,this.notifyFlushProgress?.()}outstandingBytes(){return process.stdout.destroyed||this.errored?0:this.bytesQueued-this.bytesFlushed}endStdoutOnce(){if(this.drainPromise===void 0){let e=process.stdout;if(e.isTTY||e.destroyed||e.writableEnded||!this.everWritten)return;this.drainPromise=new Promise((m)=>e.end(m))}return this.drainPromise}fullyFlushed(){if(this.flushConfirmedPromise===void 0)this.flushConfirmedPromise=new Promise((e)=>{let m=()=>{if(this.outstandingBytes()<=0)this.notifyFlushProgress=void 0,e()};this.notifyFlushProgress=m,this.flushCloseListener=m,process.stdout.once("close",m),m()});return this.flushConfirmedPromise}isExternallyClocked(){return this.externallyClocked}ensureExternallyClockedPromise(){return this.externallyClockedPromise??=new Promise((e)=>{this.notifyExternallyClocked=e})}markExternallyClocked(){this.externallyClocked=!0,this.ensureExternallyClockedPromise(),this.notifyExternallyClocked?.(),this.notifyExternallyClocked=void 0}reset(){if(this.flushCloseListener!==void 0)process.stdout.removeListener("close",this.flushCloseListener);Object.assign(this,new pi)}}var qb=new pi;var Tl=1048576,gp=1e4,fp=gr((e)=>e());class gi{unflushed={length:0,since:0};droppedCount=0;droppedTotal=0;write(e,m){let P=this.unflushed;if(m&&P.length>=Tl&&(this.droppedCount>0||Date.now()-P.since>=gp)){this.droppedCount++,this.droppedTotal++;return}let J="writing",Z=()=>{let fe=J==="unflushed";if(J="flushed",fe)P.length-=e.length,this.reportDropped()};if(fp(()=>pp(process.stderr,e,Z))==="backed-up"&&J==="writing"){if(J="unflushed",P.length===0)P.since=Date.now();P.length+=e.length}}giveUpOnUnflushed(){this.unflushed={length:0,since:0},this.reportDropped()}getDroppedTotal(){return this.droppedTotal}reset(){Object.assign(this,new gi)}reportDropped(){if(this.droppedCount>0&&this.unflushed.length<Tl){let e=this.droppedCount;this.droppedCount=0,this.write(`[stderr messages dropped before this line: ${e}. Whatever reads this stderr had not caught up for over 10 s and 1 MiB of output.]
|
|
32
|
+
`,!1)}}}var hp=a(new gi,(e)=>e.reset());function Pl(e,{mayDrop:m=!1}={}){hp.write(e,m)}function $e(e){return e.charAt(0).toUpperCase()+e.slice(1)}function se(e,m,P=m+"s"){return e===1?m:P}function jt(e){let m=0;for(let P=0;P<e.length;P++){let J=e.charCodeAt(P);if(J>=55296&&J<=56319&&P+1<e.length){let Z=e.charCodeAt(P+1);if(Z>=56320&&Z<=57343)P++}m++}return m}function Se(e,m){if(m<=0)return"";if(e.length<=m)return e;let P=e.slice(0,m),J=P.charCodeAt(m-1);return Ll(J>=55296&&J<=56319?P.slice(0,-1):P)}function Wt(e,m){if(m<=0)return"";if(e.length<=m)return e;let P=e.slice(-m),J=P.charCodeAt(0);return Ll(J>=56320&&J<=57343?P.slice(1):P)}function Ll(e){if(typeof Buffer<"u")return Buffer.from(e,"utf16le").toString("utf16le");return mp(e)}function mp(e){let P=[];for(let J=0;J<e.length;J+=8192){let Z=Math.min(J+8192,e.length),pe=new Uint16Array(Z-J);for(let fe=J;fe<Z;fe++)pe[fe-J]=e.charCodeAt(fe);P.push(String.fromCharCode(...pe))}return P.join("")}var Sp=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/,Il=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,_o=typeof String.prototype.isWellFormed==="function"?Function.prototype.call.bind(String.prototype.isWellFormed):void 0,Ol=typeof String.prototype.toWellFormed==="function"?Function.prototype.call.bind(String.prototype.toWellFormed):void 0;function Oe(e){if(_o)return _o(e);return!Sp.test(e)}function On(e){if(Ol)return Ol(e);return e.replace(Il,"�")}function Ve(e){if(_o&&_o(e))return e;return e.replace(Il,"")}function ut(e,m){let P=e.indexOf(m);return P===-1?e:e.slice(0,P)}function Tn(e,m){return e.endsWith(m)?e.slice(0,e.length-m.length):e}function wn(e,m,P=0){let J=0,Z=e.indexOf(m,P);while(Z!==-1)J++,Z=e.indexOf(m,Z+1);return J}var Dl=/[\x00-\x08\x0E-\x1F\x7F-\x9F]/g;function Ml(e){return e.replace(Dl,"").replace(/\s+/g," ").trim()}var yp=/[\t\n\v\f\r\u2028\u2029]/g,Jb=new RegExp(`${Dl.source}|${yp.source}`);function _p(e){return e.replace(/[\p{Cc}\p{Cf}\p{Cs}\p{Default_Ignorable_Code_Point}\u2028\u2029]/gu,"")}var bp=/[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d/#&.:=?%@~_]*)*)?(?:\u0007|\u001B\u005C|\u009C))|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))/g;function kp(e){let m=/[\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}\u2028\u2029]/gu;if(!m.test(e))return e;let P="";for(let{segment:J}of new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(e)){let Z=/\p{Extended_Pictographic}|\p{Regional_Indicator}|^[#*0-9]\uFE0F?\u20E3$/u.test(J),pe=/^\u{1F3F4}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,6}\u{E007F}$/u.test(J);m.lastIndex=0,P+=J.replace(m,(fe,ve)=>{if(fe===`
|
|
33
|
+
`||fe==="\t")return fe;let xe=fe.codePointAt(0)??0;if(Z&&(fe==="️"||fe==="︎"||fe==="⃣"||fe===""&&ve+fe.length<J.length||pe&&xe>=917536&&xe<=917631))return fe;if(xe===27)return"␛";if(xe<32)return String.fromCodePoint(9216+xe);if(xe===127)return"␡";return`\\u{${xe.toString(16).toUpperCase()}}`})}return P}function pt(e){return kp(e).replace(/\n/g,"").replace(/\t/g,"␉")}function v(e){return _p(Ml(e.replace(bp,""))).trim()}var vp=8;function zt(e,m=0){if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e)){if(m>=vp)return;let P=[];for(let J of e){let Z=J===null||J===void 0?"":zt(J,m+1);if(Z===void 0)return;P.push(Z)}return P.join(",")}return typeof e==="object"&&e!==null&&Object.getPrototypeOf(e)===Object.prototype&&!Object.hasOwn(e,"toString")?"[object Object]":void 0}var xp=/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF]|[\uDC00-\uDFFF]/g;function Ep(e){return e.replace(xp,(m)=>m.length===2?m:"")}var Cp=/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Default_Ignorable_Code_Point}\u2800]|(?!\u0020)\p{Zs}/gu;function In(e){if(typeof e!=="string")return"";let m=e;for(let P=0;P<64;P++){let J=Ep(m).replace(Cp,"");if(J===m)return J;m=J}return""}function Fl(e){return/^(?:0|[1-9]\d{0,9})$/.test(e)&&Number(e)<4294967295}var wp=16,Qb=6*wp;var Nl=a({},(e)=>{e.limits=void 0});function Rp(){return Nl.limits!==void 0}function Ul(e){return Nl.limits?.onPast(e),Rp()}var Ap="\\u05C8\\u05C9\\u1ADE\\u1ADF\\u1AEC-\\u1AF0\\u{10ECB}-\\u{10ECF}\\u{10EF0}-\\u{10EF9}\\u{1D127}\\u{1D128}\\u{1D250}-\\u{1D252}\\u{1D25B}\\u{1D25C}\\u{1D25F}\\u{1D280}\\u{1D281}",Kl=`[\\p{M}\\uFF9E\\uFF9F${Ap}]`,Tp=new RegExp(`${Kl}{32,}`,"gu"),Pp=new RegExp(Kl,"u");var fi=new Map,Rr=[],hi=new Map;function bo(e,m){return e!==m&&(e+m).normalize("NFD")===m+e}function jl(e){let m=fi.get(e);if(m!==void 0)return m;let P=String.fromCodePoint(e),J=null;if(P==="̴"||bo(P,"̴")||bo("ͅ",P)){let Z=0,pe=Rr.length;while(Z<pe&&J===null){let fe=Z+pe>>1,ve=Rr[fe];if(bo(P,ve.sample))Z=fe+1;else if(bo(ve.sample,P))pe=fe;else J=ve}if(J===null){J={order:Z,sample:P},Rr.splice(Z,0,J);for(let fe=Z+1;fe<Rr.length;fe++)Rr[fe].order=fe}}return fi.set(e,J),J}function Wl(e){let m=hi.get(e);if(m===void 0)m=Array.from(String.fromCodePoint(e).normalize("NFKD"),(P)=>P.codePointAt(0)),hi.set(e,m);return m}var Hl=4096;function Op(e,m){let P="";for(let J=0;J<m;J+=Hl)P+=String.fromCodePoint(...e.subarray(J,Math.min(J+Hl,m)));return P}function Lp(e){let m=new Int32Array(e.length+16),P=0;for(let fe=0;fe<e.length;){let ve=e.codePointAt(fe);fe+=ve>65535?2:1;for(let xe of Wl(ve)){if(P===m.length){let Re=new Int32Array(m.length*2);Re.set(m),m=Re}m[P++]=xe,jl(xe)}}let J=new Int16Array(P);for(let fe=0;fe<P;fe++)J[fe]=fi.get(m[fe])?.order??-1;let Z=m.slice(0,P),pe=new Int32Array(Rr.length);for(let fe=0;fe<P;){let ve=fe,xe=!0;while(ve<P&&J[ve]>=0)xe&&=ve===fe||J[ve-1]<=J[ve],ve++;if(xe){fe=ve+1;continue}pe.fill(0);for(let Ae=fe;Ae<ve;Ae++)pe[J[Ae]]++;let Re=fe;for(let Ae=0;Ae<pe.length;Ae++){let De=pe[Ae];pe[Ae]=Re,Re+=De}for(let Ae=fe;Ae<ve;Ae++)Z[pe[J[Ae]]++]=m[Ae];fe=ve}return Op(Z,P)}function Ip(e){return e.length<32?e:e.replace(Tp,Lp)}var Bl=128;function Gl(e){if(e<768)return!0;let m=hi.get(e);if(m===void 0&&!Pp.test(String.fromCodePoint(e)))return!0;return jl((m??Wl(e))[0])===null}function Dp(e,m){let P=m;if(P<e.length&&(e.charCodeAt(P)&64512)===56320&&(e.charCodeAt(P-1)&64512)===55296)P++;while(P<e.length){let J=e.codePointAt(P);if(Gl(J))break;P+=J>65535?2:1}return Math.min(P,e.length)}function Mp(e){let m=e.length;while(m>0){if(m--,m>0&&(e.charCodeAt(m)&64512)===56320&&(e.charCodeAt(m-1)&64512)===55296)m--;if(Gl(e.codePointAt(m)))return m}return 0}function Fp(e,m){let P=Ip(e);if(P.length<=Bl)return P.normalize(m);let J=[],Z="";for(let pe=0;pe<P.length;){let fe=Dp(P,pe+Bl),ve=(Z+P.slice(pe,fe)).normalize(m),xe=fe===P.length?ve.length:Mp(ve);J.push(ve.slice(0,xe)),Z=ve.slice(xe),pe=fe}return J.join("")}function mi(e){return Fp(e,"NFKC")}var $l="˹-˼⌌-⌏⌜-⌟⎛-⏌⏜-⏡⸀-⸍⸜⸝─-╿",Np=new Map([["˂","<"],["˃",">"],["ᐳ",">"],["ᐸ","<"],["ᚲ","<"],["‹","<"],["›",">"],["≮","<"],["≯",">"],["≺","<"],["≻",">"],["⊀","<"],["⊁",">"],["⋖","<"],["⋗",">"],["〈","<"],["〉",">"],["❬","<"],["❭",">"],["❮","<"],["❯",">"],["❰","<"],["❱",">"],["⟨","<"],["⟩",">"],["⦑","<"],["⦒",">"],["⦓","<"],["⦔",">"],["⧼","<"],["⧽",">"],["⩹","<"],["⩺",">"],["⪦","<"],["⪧",">"],["〈","<"],["〉",">"],["︿","<"],["﹀",">"],["﹤","<"],["﹥",">"],["<","<"],[">",">"],["\uD81B\uDF3F",">"],["\uD834\uDE36","<"],["\uD834\uDE37",">"]]);var Si=new Map([...Np,...Array.from("≪⋘⪡⫷⟪︽",(e)=>[e,"<"]),...Array.from("≫⋙⪢⫸⟫︾",(e)=>[e,">"])]),Up=new Map([...Si,["《","<"],["》",">"]]),ik=new Set(`⦒⦔⩺⪧${"≫⋙⪢⫸⟫︾"}`);function Pn(e){let m=e;for(let[P,J]of Up)if(J===e)m+=P;return m}var dk=new RegExp(`[${$l}]|(?![\\x00-\\x7f])[\\p{Sm}\\p{Sk}\\p{So}]`,"gu"),ck=new RegExp(`[${[...Si.keys()].join("")}]`,"gu");var ql="\\p{Default_Ignorable_Code_Point}\\u2800",W=`\\p{Cc}\\p{Cf}\\p{Cs}\\p{Co}\\p{Cn}\\u2028\\u2029${ql}`,Wr=String.raw`\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180f\u200b-\u200f\u202a-\u202e\u2060-\u206f\u2800\u3164\ufe00-\ufe0f\uffa0\ufff0-\ufffb\uDC00-\uDFFF\uDB40-\uDB43`,zl=String.raw`\u0600-\u0605\u06dd\u070f\u0890\u0891\u08e2`,Ar=`[${Wr}${zl}\\ufeff]*`,Ck=new RegExp(`[${Wr}${zl}\\ufeff]`);function Gr(e){return e.replace(/([a-z)])(?=[a-z(\[])/gi,`$1${Ar}`).replace(/\[_-\]\?/g,`(?:[_-]${Ar})?`)}var wk=new RegExp(`[${W}]+`,"gu"),yi="\\u200D\\uFE0E\\uFE0F",Rk=new RegExp(`(?:(?![${yi}])[${W}])+`,"gu"),Ak=new RegExp(`(?:(?![${yi}\\n])[${W}])+`,"gu"),Tk=new RegExp(`(?<!\\S)[${yi}]+`,"gu");var Pk=new RegExp(`[${W}]`,"u");var jr="[\\p{M}\\u1160-\\u11FF\\uD7B0-\\uD7FF]",Ok=new RegExp(`(?<![\\p{L}\\p{N}\\p{M}])${jr}|${jr}{9}|\\p{Soft_Dotted}\\p{M}*\\u0307|[\\u0131\\u0237]\\p{M}|(?<=[\\p{sc=Latin}\\p{sc=Common}]${jr}*)(?!\\p{sc=Inherited})${jr}`,"u"),Hp=String.raw`\u0620\u0626\u0628\u062A-\u062E\u0633-\u063F\u0641-\u0647\u0649\u064A\u066E\u066F\u0678-\u0687\u069A-\u06BF\u06C1\u06C2\u06CC\u06CE\u06D0\u06D1\u06FA-\u06FC\u06FF\u0750-\u0758\u075C-\u076A\u076D-\u0770\u0772\u0775-\u0777\u077A-\u077F\u0886\u0889-\u088D\u088F\u08A0-\u08A9\u08AF\u08B0\u08B3-\u08B8\u08BA-\u08C8`,Bp=String.raw`\u0620\u0622-\u063F\u0641-\u064A\u066E\u066F\u0671-\u0673\u0675-\u06D3\u06D5\u06EE\u06EF\u06FA-\u06FC\u06FF\u0750-\u077F\u0870-\u0882\u0886\u0889-\u088F\u08A0-\u08AC\u08AE-\u08C8`,Kp=[2304,2432,2688,2816,3072,3200,3328].map(jp),Vl=String.raw`[\u0D9A-\u0DC6]`,Lk=new RegExp([...Kp,`\\u200D(?<=${Vl}\\u0DCA.)(?=${Vl})`,`\\u200C(?<=[${Hp}](?:(?=[\\p{sc=Arabic}\\p{sc=Inherited}])(?!\\p{Default_Ignorable_Code_Point})\\p{Mn}){0,8}.)(?=[${Bp}])`].join("|"),"gu"),Ik=new RegExp(`\\u20E3|\\u263A${jr}`,"u");function jp(e){let m=`[${ko(e+21)}-${ko(e+57)}]`,P=e===3328?"":`${ko(e+60)}?`;return`[\\u200C\\u200D](?<=${m}${P}${ko(e+77)}.)(?=${m})`}function ko(e){return`\\u{${e.toString(16)}}`}var Wp=new RegExp(`[\\p{Cf}\\p{Co}\\p{Cn}\\u2028\\u2029\\u007F-\\u009F${ql}]`,"gu");function Gp(e){let m=e.replace(/[\p{Cf}\p{Co}\p{Cn}]/gu,"");return m=m.replace(/[\u200B-\u200F]/g,"").replace(/[\u202A-\u202E]/g,"").replace(/[\u2066-\u2069]/g,"").replace(/[\uFEFF]/g,"").replace(/[\uE000-\uF8FF]/g,""),m}function $p(e){let m=Ve(e);for(let P=0;P<10;P++){let J=Gp(m);if(J===m)return m;m=J}return m}function Vp(e){return!/[^\0-\x7f]/.test(e)}function qp(e){if(Vp(e))return e;let m=e,P="",J=0,Z=10;while(m!==P&&J<Z)P=m,m=mi(m),m=$p(m),J++;if(J>=Z)throw Error(`Unicode sanitization reached maximum iterations (${Z}) for input: ${e.slice(0,100)}`);return m}function Te(e){if(typeof e==="string")return qp(e);if(Array.isArray(e))return e.map(Te);if(e!==null&&typeof e==="object"){let m={};for(let[P,J]of Object.entries(e)){let Z=Te(P);if(Z!=="__proto__"&&(Z===P||!Fl(Z)||Number(Z)<64||!Ul("cleaned_key")))m[Z]=Te(J)}return m}return e}function Ze(e){return e.replace(/[\p{Cc}\p{Cf}\u2028\u2029]+/gu," ")}function Jl(e){return e.replace(Wp,(m)=>Array.from({length:m.length},(P,J)=>`\\u${m.charCodeAt(J).toString(16).padStart(4,"0")}`).join(""))}function Yl(e){return e.split("").map((m)=>"\\u"+m.charCodeAt(0).toString(16).padStart(4,"0")).join("")}function Xl(e){let m=new Int32Array(e.length);for(let P=0;P<e.length;P++)m[P]=P;return{text:e,origin:m}}function Zl(e,m,P){let J=[];for(let Z of e.text.matchAll(m)){let{keep:pe,insert:fe,keepEnd:ve=0}=P(Z),xe=Z.index??0,Re=Z[0].length,Ae=Math.min(Math.max(pe|0,0),Re),De=Math.min(Math.max(ve|0,0),Re-Ae);J.push([xe+Ae,xe+Re-De,fe])}return vo(e,J)}function vo(e,m){if(m.length===0)return e;let{text:P,origin:J}=e,Z=P.length;for(let[Re,Ae,De]of m)Z+=De.length-(Ae-Re);let pe=new Int32Array(Z),fe=[],ve=0,xe=0;for(let[Re,Ae,De]of m)fe.push(P.slice(ve,Re)),pe.set(J.subarray(ve,Re),xe),xe+=Re-ve,fe.push(De),pe.fill(-1,xe,xe+De.length),xe+=De.length,ve=Ae;return fe.push(P.slice(ve)),pe.set(J.subarray(ve),xe),{text:fe.join(""),origin:pe}}function Ue(e){let m=0;while(m<e.length&&e.charCodeAt(m)<=32)m++;let P=e.slice(m),J=/^([A-Za-z0-9][A-Za-z0-9+.-]*):\/\//.exec(P),Z=J?.[1]?.toLowerCase(),pe=J?P.slice(J[0].length):P,fe=pe.indexOf(":"),ve=pe.indexOf("/");if(!(Z!==void 0?Z!=="file":fe!==-1&&(ve===-1||fe<ve)&&!/^[A-Za-z]:/.test(pe))){let Ke=J?$r(pe):pe;return Ke.includes("@[")||Ke.startsWith("[")}let Re=$r(pe),Ae=J?/^(?:[^@/?#\\[\]]+@)?(\[[0-9A-Fa-f:.]+\])(?::\d*)?(?=\/|$)/.exec(Re):/^[^@:/[\]]+@(\[[0-9A-Fa-f:.]+\])(?=:)/.exec(Re),De=Ae!==null&&!!ae(`ssh://${Ae[1]}/`)?.hostname;return/[[\]]/.test(Re.slice(De?Ae[0].length:0))}function ae(e){try{return new URL(e)}catch{return null}}function $r(e){return e.replace(/%([0-9A-Fa-f]{2})/g,(m,P)=>{let J=parseInt(P,16);return J===0?m:String.fromCharCode(J)})}function Fe(e,{asRewritten:m=!1}={}){let P=e.trimStart(),J=/^([A-Za-z][A-Za-z0-9+.-]*):\/\//.exec(P);if(J){let Z=J[1]?.toLowerCase();if(Z==="file")return null;if(Z==="http"||Z==="https"){let pe=ae(P);return pe?.hostname?{host:pe.hostname,path:pe.pathname}:null}return Ql(Qe(P.slice(J[0].length)),"/")}return Ql(m?Qe(P):P,":")}function tu(e,m){let P=e.indexOf("@["),J=P===-1?0:P+1,Z=e[J]==="["?J:-1,pe=Z===-1?-1:e.indexOf("]",Z+1),fe=e.indexOf(m,pe===-1?0:pe+1);return{open:Z,close:pe,cut:fe}}function Ql(e,m){let{open:P,close:J,cut:Z}=tu(e,m),pe=P===-1?0:P,fe=e.indexOf("/");if(m===":"&&(Z===-1||fe!==-1&&fe<e.indexOf(":")))return null;let ve=Z===-1?"":e.slice(m===":"?Z+1:Z);if(J!==-1){let De=e.slice(J+1,Z===-1?e.length:Z),Ke=e.slice(0,pe)+e.slice(pe+1,J),Be=eu(De)!==De?Ke:eu(Ke),ot=Be.slice(Be.lastIndexOf("@")+1),at=ae(`ssh://[${ot}]/`)?.hostname;return ot?{host:at||ot,path:ve}:null}let xe=Z===-1?e:e.slice(0,Z),Re=xe.slice(xe.lastIndexOf("@")+1);if(Re.startsWith("["))return null;let Ae=m==="/"?Re.replace(/:\d*$/,""):Re;return Ae?{host:Ae,path:ve}:null}function nu(e){let{text:m,from:P}=zp(e),{close:J,cut:Z}=tu(m,"/"),pe=Z===-1?m.length:Z,fe=[],ve=(xe,Re)=>{let Ae=m.lastIndexOf("@",Re-1);if(Ae>=xe)fe.push([P(xe),P(Ae)])};if(J===-1)ve(0,pe);else ve(0,J),ve(J+1,pe);return fe}function Qe(e){return e.replace(/(?:%(?!00)[0-9A-Fa-f]{2})+/g,(m)=>{try{return decodeURIComponent(m)}catch{return $r(m)}})}function zp(e){if(!e.includes("%"))return{text:e,from:(Z)=>Z};let m=[],P="",J=0;for(let Z of e.matchAll(/(?:%(?!00)[0-9A-Fa-f]{2})+/g)){for(let Re=J;Re<Z.index;Re++)m.push(Re);P+=e.slice(J,Z.index);let pe,fe;try{pe=decodeURIComponent(Z[0]),fe=Array.from(pe,(Re)=>{let Ae=Re.codePointAt(0);return Ae<128?1:Ae<2048?2:Ae<65536?3:4})}catch{pe=$r(Z[0]),fe=Array.from(pe,()=>1)}let ve=Z.index,xe=0;for(let Re of fe){let Ae=pe.codePointAt(xe)>65535?2:1;for(let De=0;De<Ae;De++)m.push(ve);xe+=Ae,ve+=3*Re}P+=pe,J=Z.index+Z[0].length}for(let Z=J;Z<=e.length;Z++)m.push(Z);return{text:P+e.slice(J),from:(Z)=>m[Z]}}function eu(e){let m=e.indexOf(":"),P=e.slice(m+1);if(m===-1||!/^[ \t\n\v\f\r]*[+-]?\d+$/.test(P))return e;let J=Number.parseInt(P.trim(),10);return J>=0&&J<65536?e.slice(0,m):e}var Jp=/\s/g,Yp=/[\n\r\u2028\u2029]/g,Xp=/(?:@|%40)(?:\[|%5B)/gi,Zp=/^(?:\[|%5B)/i,Qp=/\]|%5D/gi,eg=/(?:^|[^A-Za-z0-9+.-])(?:https?|wss?|ftps?)$/i,iu=/(?:^|[^A-Za-z0-9+.-])(?:ssh|git|git\+ssh|ssh\+git)$/i,tg=/[,;|&]/g,ng=/(?:^|[^A-Za-z0-9+.-])[A-Za-z][A-Za-z0-9+.-]{0,31}$/,rg=/["'`|,;&<>()[\]\\@/?#]|%40|%5B/i,og=/["'`]/,sg=/[;|&\n]/g,au=/\[REDACTED|\*\*\*:\*\*\*/g,lu=`@|%40|${au.source}`,ig=64,ag=2048,lg=/[\s"'`]/g;function uu(e){let m=[],P=ln(e,lg),J=0;for(let Z=e.indexOf("://");Z!==-1;){let pe=Z+3;if(Z>=J&&iu.test(e.slice(Math.max(0,Z-8),Z))){J=Math.min(P(pe),pe+ag);for(let[fe,ve]of nu(e.slice(pe,J)))m.push([pe+fe,pe+ve])}Z=e.indexOf("://",pe)}return m}function ug(e){let m=[],P=[],J=ln(e,Jp),Z=ln(e,/\//g),pe=_i(e,Xp),fe=ln(e,Qp),ve=ln(e,/\//g),xe=ln(e,sg),Re=ln(e,/[/?#]/g),Ae=ln(e,tg),De=ln(e,/@/g),Ke=ln(e,/%40/gi),Be=ln(e,au),ot=ln(e,/[:%]/g),at=ln(e,/["'`,;|&<>{}()]/g),xt=su(e,!1),st=su(e,!0);for(let kt=e.indexOf("://");kt!==-1;){let it=kt+3,un=e.indexOf("://",it),Dt=J(it),fn=De(it),It;if(eg.test(e.slice(Math.max(0,kt-8),kt))){let vt=Math.min(Re(it),Dt),yr=Math.min(Ae(it),vt);if(It=fn<vt?Math.max(xt(it,vt),st(fn,vt)):Math.max(xt(it,Math.min(Z(it),Dt)),st(it,yr)),It<=it){let or=Math.min(vt,xe(it));P.push({start:it,fieldEnd:Math.min(yr,or),lastEncodedAt:st(it,or)})}}else{let vt=Math.min(Z(it),Dt),yr=Math.min(Dt,un===-1?e.length:un),or=iu.test(e.slice(Math.max(0,kt-8),kt)),ar=or?pe(it):null,Lr=or?Zp.exec(e.slice(it,it+3)):null,Ki=[[Lr!==null?it+Lr[0].length:-1,yr],[ar!==null&&ar.index<yr?ar.index+ar[0].length:-1,Dt]];for(let[qn,_r]of Ki){let ji=qn===-1?Dt:fe(qn);if(ji<_r)vt=Math.max(vt,Math.min(ve(ji),Dt))}It=Math.max(xt(it,vt),st(it,vt))}if(It>it)m.push({start:it,end:It,separatorEnd:It+(e[It]==="@"?1:3),loginEnd:fn<=It?fn:Math.min(Ke(it),It)});else{let vt=Be(it);if(vt>it&&vt<Math.min(Dt,Z(it),at(it))&&ot(it)<vt)m.push({start:it,end:vt,separatorEnd:vt,loginEnd:vt})}kt=un}return{spans:m,hostParts:P}}function du(e,m){let{spans:P,hostParts:J}=ug(e);if(P.length===0&&J.length===0)return[];let Z=ln(e,/[\s"'>}|,;&`)\]]/g),pe=ln(e,/\s/g),fe=[],ve=[];for(let Be of P)fe.push({start:Be.start,end:Be.end,loginEnd:Be.loginEnd}),ve.push({...Be,userinfo:Be});let xe=xo(e,m);for(let Be of J){let ot=xe(Be.start)[0];if(ot&&ot.keyStart<Be.fieldEnd&&e.slice(Be.start,ot.keyStart).includes("%")){let at=Be.lastEncodedAt>ot.keyStart?Be.lastEncodedAt:ot.valueStart;fe.push({start:Be.start,end:at,loginEnd:at}),ve.push(at>ot.valueStart?{start:Be.start,end:at,userinfo:{start:Be.start,end:at,separatorEnd:at+3,loginEnd:at}}:{start:Be.start,end:at})}}if(ve.length===0)return[];fe.sort((Be,ot)=>Be.start-ot.start);let Re=xo(e,m),Ae=0;for(let Be=0,ot=Re(Be);ot[0]!==void 0;){let at,xt=null;for(let kt of ot)if(xt=kt.valueEnd(),xt!==null){at=kt;break}if(at===void 0||xt===null){Be=ot[0].keyStart+1,ot=Re(Be);continue}while(Ae<fe.length&&fe[Ae].start<=at.keyStart)Ae++;let st=fe[Ae];if(st!==void 0&&st.start<xt){let kt=e[at.valueStart]??"",un=(kt==='"'||kt==="'")&&xt-1>at.valueStart&&e[xt-1]===kt?Math.max(xt,st.end):pe(Math.max(xt,st.end,Z(st.loginEnd+1)));ve.push({start:at.valueStart,end:un})}Be=xt,ot=Re(Be)}let De={nextKey:xo(e,m),plainKeys:xo(e,m),nextLineEnd:ln(e,Yp),span:0,lineEnd:-1,resumeAt:0,overflowEnd:pg(e,()=>De.lineEnd)},Ke=[];for(let Be of fg(ve)){let ot=Ke.at(-1);Ke.push(ot!==void 0&&Be.start<ot.end?ou(e,{start:Ke.pop().start,end:Math.max(ot.end,Be.end)},De):ou(e,Be,De))}return Ke.map((Be)=>Be.userinfo?Be:gg(e,Be))}var ru=new WeakMap;function dg(e){let m=ru.get(e);if(!m)m={word:new RegExp(e.word,"gi"),notTail:new RegExp(`(?!${e.tail})[^]`,"gi"),separator:new RegExp(e.separator,"iy"),value:new RegExp(e.value,"iy")},ru.set(e,m);return m}function xo(e,m){let P=m.map((J)=>{let{word:Z,notTail:pe,separator:fe,value:ve}=dg(J),xe=_i(e,Z),Re=ln(e,pe),Ae=-1,De=-1,Ke=-1,Be=null,ot=(kt)=>{if(kt!==Ke)Ke=kt,ve.lastIndex=kt,Be=ve.test(e)?ve.lastIndex:null;return Be},at=(kt)=>{if(kt!==Ae)Ae=kt,fe.lastIndex=kt,De=fe.test(e)?fe.lastIndex:-1;return De},xt=-1,st=null;return(kt)=>{if(xt!==-1&&kt>=xt&&(st===null||kt<=st.keyStart))return st;xt=kt,st=null;for(let it=xe(kt);it!==null;){let un=it.index+it[0].length,Dt=at(J.tail?Re(un):un);if(Dt!==-1){st={keyStart:it.index,valueStart:Dt,valueEnd:()=>ot(Dt)};break}it=xe(it.index+1)}return st}});return(J)=>{let Z=[];for(let pe of P){let fe=pe(J);if(fe&&(!Z[0]||fe.keyStart<=Z[0].keyStart))Z=Z[0]&&fe.keyStart===Z[0].keyStart?[...Z,fe]:[fe]}return Z}}function ou(e,m,P){if(m.userinfo&&cg(e,m.userinfo,P))return m;let J=m.end;P.resumeAt=Math.max(P.resumeAt,m.start);for(let Z=P.nextKey(P.resumeAt);Z[0]!==void 0&&Z[0].keyStart<J;){let pe=Z[0].keyStart;if(pe>P.lineEnd){let Re=P.nextLineEnd(pe);P.span=ig*(Re-P.lineEnd),P.lineEnd=Re}let fe=null,ve=Z[0];for(let Re of Z)if(fe=Re.valueEnd(),fe!==null){ve=Re;break}let xe=fe??ve.valueStart;if(P.span-=xe-pe,P.span<0)return{start:m.start,end:Math.max(J,P.overflowEnd(m.start))};J=Math.max(J,xe),P.resumeAt=ve.valueStart,Z=P.nextKey(P.resumeAt)}return J===m.end?m:{start:m.start,end:J}}function cg(e,m,P){if(e[m.end]!=="@"||rg.test(e.slice(m.start,m.end))||!ng.test(e.slice(Math.max(0,m.start-36),m.start-3)))return!1;for(let J=P.plainKeys(m.start);J[0]!==void 0&&J[0].keyStart<m.end;J=P.plainKeys(J[0].keyStart+1))if(J.some((Z)=>Z.valueStart===m.end))return!1;return!0}function pg(e,m){let P=ln(e,/["'`]/g),J=-1,Z=e.length;return(pe)=>{if(m()!==J)J=m(),Z=P(pe)<J?e.length:J;return Z}}function gg(e,m){let P=e[m.end-1];if(P===void 0||!og.test(P))return m;return(e.slice(m.start,m.end).split(P).length-1)%2===1?{start:m.start,end:m.end-1}:m}function fg(e){e.sort((P,J)=>P.start-J.start||J.end-P.end);let m=[];for(let P of e){let J=m.at(-1);if(J===void 0||P.start>=J.end)m.push(P);else m[m.length-1]={start:J.start,end:Math.max(J.end,P.end)}}return m}function ln(e,m){let P=_i(e,m);return(J)=>P(J)?.index??e.length}function _i(e,m){let P=-1,J=null;return(Z)=>{if(P===-1||Z<P||J!==null&&Z>J.index)m.lastIndex=Z,J=m.exec(e),P=Z;return J}}function su(e,m){let P=null;return(J,Z)=>{if(P===null){P=new Int32Array(e.length+1);let fe=-1;for(let ve=0;ve<=e.length;ve++){if(m){if(ve>=3&&e.startsWith("%40",ve-3))fe=ve-3}else if(ve>=1&&e[ve-1]==="@")fe=ve-1;P[ve]=fe}}let pe=P[Math.min(Z,e.length)];return pe>=J?pe:-1}}var Ro=String.raw`api[_-]?key|secret|token|password|passwd|credential|bearer|authorization|auth[_-]?header|memory[_-]?request[_-]?mac|cookie|session[_-]?(?:id|key)|connection[_-]?string|(?:private|ssh|encryption|signing|access|deploy|master|license)[_-]?key|client[_-]?secret`,_u=new RegExp(Gr(Ro),"i"),Tr=`[\\s\\u0085${Wr}]`,Ti="Bearer|Basic",Sr=`(?:${Gr(Ti)})[${Wr}]*[\\s\\u0085]+`,cu="[^\\s\\u0085,;&}\\])]+",pu="(?![\\w\\[({$/+=~!@%^?\\\\-])",Ao="\\n\\r\\x0b\\x0c\\u0085\\u2028\\u2029",cr="[\\s\\u0085]",Jk=new RegExp(Tr),Yk=new RegExp(`(?:[=:]|["']|\\b(?:${Gr("bearer|basic")}))$`,"i"),hg=`\\\\+(?:"[^"${Ao}]*(?<!\\\\)(?=\\\\+")|'[^'${Ao}]*(?<!\\\\)(?=\\\\+'))`,gu=`[^\\s\\u0085,;&})"'\\\\]+`,Po=`"[^"${Ao}]*"|'[^'${Ao}]*'|"[^"]*"${pu}|'[^']*'${pu}|[^\\s-]{0,4}\\[REDACTED\\]['"\`]?|${Sr}(?:\\[REDACTED\\]|${cu})|${cu}`,mg={word:`\\b(?:${Ti})`,tail:"",separator:`${cr}+`,value:"[A-Za-z0-9+/=._~-]{20,}"},Sg={word:`(?:${_u.source})`,tail:"[\\w.-]",separator:`["']?${cr}*[=:]${cr}*`,value:Po},Pi="AWS|GOOGLE|GCP|GCLOUD|AZURE",yg={word:`\\b(?:${Pi})_\\w`,tail:"\\w",separator:`${cr}*[=:]${cr}*`,value:Po},_g=[Sg,yg,mg],Jn="[\\w=-]",tr=`${Jn}{20,}(?:\\.[0-9a-z]{9})?`,bg="[\\w.-]{0,256}(?![\\w.-])",bu=`${cr}*(?!${cr})`,Oi=`(?:${_u.source})${bg}`,ku=`\\b(?:${Gr(Pi)})${Ar}_\\w+`,Ei=`${Oi}(?:${Ar}["'])?${Tr}*[=:]${bu}(${Po})`,Ci=`${ku}${Tr}*[=:]${cr}*(${Po})`,vu=/\\["']/,xu=`${Oi}${Ar}\\\\+["']${Tr}*[=:]${bu}(${hg}|${Sr}${gu}|${gu}|\\\\+["'][^\\s\\u0085,;&})"'\\\\]*)`,dr=`[^\\s\\u0085,;&}\\])"']{0,64}?(?:${Oi}|${ku})`,kg=`(?:${Sr})?(?:[{[(]{0,8}(?:"${dr}"|'${dr}')|${dr})${Tr}*[=:]`,vg=`(?:${Sr})?(?:[{[(]{0,8}(?:"${dr}"|'${dr}'|\\\\+"${dr}\\\\+"|\\\\+'${dr}\\\\+')|${dr})${Tr}*[=:]`,Eu="\\][^\\s\"'>}|,;&`)\\]]*",zr="[A-Za-z0-9_-]",wi=`${zr}{10}${zr}*`,fu=`\\.${wi}\\.${wi}`,Li=`(?<!${zr})(?=${zr}+${fu})(?:${zr}*?-)??(eyJ${wi}${fu})`,Cu=`(?:${Pi})_`,Vr="\\[REDACTED\\]",Ii=[{id:"url-userinfo",needs:"@",needsUrl:!0,source:`:\\/\\/((["'])[^/@\\s]*\\2(?=@)|(?:[^/@\\s"'|,;&\`]+(?=@))|[^/@\\s"'|,;&\`]*["'|,;&\`][^/@\\s]*@)@?`,confidence:"low"},{id:"gcp-service-account",needs:"\\.iam\\.gserviceaccount\\.com",source:"\\b([a-z0-9-]{1,64}@[a-z0-9-]+\\.iam\\.gserviceaccount\\.com)\\b",flags:"i",confidence:"low"},{id:"loose-anthropic-key",needs:"sk-",source:"\\b(sk-ant-?[\\w-]{10,})",confidence:"low"},{id:"http-auth-scheme",needs:Ti,source:`\\b${Sr}([A-Za-z0-9+/=._~-]{20,})`,flags:"i",confidence:"low"},{id:"loose-jwt",needs:"eyJ",prefilter:/eyJ/,source:Li,confidence:"low"},{id:"sensitive-assign",needs:Ro,source:Ei,flags:"i",confidence:"low"},{id:"cloud-env-var",needs:Cu,source:Ci,flags:"i",confidence:"low"},{id:"url-userinfo-tail",needs:Vr,source:":\\/\\/(\\[REDACTED\\](?!@|%40[^\\s\"'>}|,;&`)\\]@/]*(?:[\\s\"'>}|,;&`)\\]/]|$))[^\\s\"'>}|,;&`)\\]]*?(?=[\\s\"'>}|,;&`)\\]]|:\\/\\/|$))",confidence:"low"},{id:"url-userinfo-later-at",needs:Vr,source:":\\/\\/(\\[REDACTED\\]@(?:[^\\s:/?#\"'>}|,;&`)\\]]|:(?!\\/\\/)){0,256})(?=@|%40)",confidence:"low"},{id:"url-userinfo-encoded",needs:`%40|${Vr}`,needsUrl:!0,source:":\\/\\/((?:\\[REDACTED\\]@)?(?:(?:[^/?#@\\s\"',;&<>|)\\]{}`[]*[\"'`<>{}[\\]][^/?#@\\s,;&|{}\"'`<>[\\]()]*(?=%40))|[^/?#@\\s\"',;&<>|)\\]}`[]+(?=%40)|(?=[^/?#@\\s\"',;&<>|)\\]}`[]*?(?:%|:[^/?#@\\s\"',;&<>|)\\]}`[]))[^/?#@\\s\"',;&<>|)\\]}`[]+(?=\\[REDACTED\\])))",confidence:"low"},{id:"masked-value-rest",needs:Vr,source:`\\[REDACTED\\](${Eu})`,confidence:"low"},{id:"anthropic-signed-key-rest",needs:Vr,redactOnly:!0,prefilter:/\[REDACTED\]\.eyJ/,source:"\\[REDACTED\\]\\.(eyJ[\\w-]+\\.[\\w-]+)",confidence:"low"},{id:"sensitive-assign-escaped",needs:Ro,redactOnly:!0,prefilter:vu,source:xu,flags:"i",confidence:"low"},{id:"aws-access-token",needs:"A3T|AKIA|ASIA|ABIA|ACCA",source:"\\b((?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z2-7]{16})\\b",confidence:"high"},{id:"gcp-api-key",needs:"AIza",source:"\\b(AIza[\\w-]{35})(?![\\w-])",confidence:"high"},{id:"google-oauth-client-secret",needs:"GOCSPX-",source:"\\bGOCSPX-[\\w-]{28}(?![\\w-])",confidence:"high"},{id:"azure-ad-client-secret",needs:"Q~",source:`(?:^|[\\\\'"\\x60\\s>=:(,)])([a-zA-Z0-9_~.]{3}\\dQ~[a-zA-Z0-9_~.-]{31,34})(?:$|[\\\\'"\\x60\\s<),])`,confidence:"high"},{id:"digitalocean-pat",needs:"dop_v1_",source:`\\b(dop_v1_[a-f0-9]{64})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"digitalocean-access-token",needs:"doo_v1_",source:`\\b(doo_v1_[a-f0-9]{64})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"anthropic-api-key",needs:"sk-",source:`\\b(sk[-]ant[-]api03-[a-zA-Z0-9_\\-]{93}AA)(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"anthropic-admin-api-key",needs:"sk-",source:`\\b(sk-ant-admin01-[a-zA-Z0-9_\\-]{93}AA)(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"anthropic-oauth-token",needs:"sk-",source:`\\b(sk-ant-(?:oat|ort)\\d{2}-[\\w-]{20,})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,run:"[\\w-]",confidence:"high"},{id:"openai-api-key",needs:"sk-",source:"sk-[A-Za-z0-9_-]{8,200}T3BlbkFJ[A-Za-z0-9_-]{8,200}",confidence:"high"},{id:"openai-legacy-api-key",needs:"sk-",source:"\\bsk-[a-zA-Z0-9]{48}(?![a-zA-Z0-9])",confidence:"high"},{id:"huggingface-access-token",needs:"hf_",source:`\\b(hf_[a-zA-Z]{34})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"supabase-secret-key",needs:"sb_secret_",source:"\\bsb_secret_[A-Za-z0-9_-]{20,}",confidence:"high"},{id:"supabase-access-token",needs:"sbp_",source:"\\bsbp_[a-z0-9]{40,}",confidence:"high"},{id:"github-pat",needs:"ghp_",source:"ghp_[0-9a-zA-Z]{36}",confidence:"high"},{id:"github-fine-grained-pat",needs:"github_pat_",source:"github_pat_\\w{82}",confidence:"high"},{id:"github-app-token",needs:"ghu_|ghs_",source:"(?:ghu|ghs)_[0-9a-zA-Z]{36}",confidence:"high"},{id:"github-oauth",needs:"gho_",source:"gho_[0-9a-zA-Z]{36}",confidence:"high"},{id:"github-refresh-token",needs:"ghr_",source:"ghr_[0-9a-zA-Z]{36}",confidence:"high"},{id:"gitlab-pat",needs:"glpat-",source:`glpat-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-deploy-token",needs:"gldt-",source:`gldt-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-runner-authentication-token",needs:"glrt-",source:`glrt-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-oauth-app-secret",needs:"gloas-",source:`gloas-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-pipeline-trigger-token",needs:"glptt-",source:`glptt-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-kubernetes-agent-token",needs:"glagent-",source:`glagent-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-incoming-mail-token",needs:"glimt-",source:`glimt-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-scim-oauth-token",needs:"glsoat-",source:`glsoat-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-ci-build-token",needs:"glcbt-",source:`glcbt-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-feed-token",needs:"glft-",source:`glft-${tr}`,displayRun:Jn,confidence:"high"},{id:"gitlab-feature-flag-client-token",needs:"glffct-",source:`glffct-${tr}`,displayRun:Jn,confidence:"high"},{id:"slack-bot-token",needs:"xox",source:"xoxb-[0-9]{10,13}-[0-9]{10,13}[a-zA-Z0-9-]*",confidence:"high"},{id:"slack-user-token",needs:"xox",source:"xox[a-z](?:-[0-9]{10,13}){3}-[a-zA-Z0-9-]{28,34}",confidence:"high"},{id:"slack-rotation-token",needs:"xox",source:"xoxe(?:\\.xox[a-z])?-[0-9]-[A-Za-z0-9-]{28,}",confidence:"high"},{id:"slack-app-token",needs:"xapp-",source:"xapp-\\d-[A-Z0-9]+-\\d+-[a-z0-9]+",flags:"i",confidence:"high"},{id:"slack-workflow-token",needs:"xwfp-",source:"\\bxwfp-[a-zA-Z0-9-]{20,}",confidence:"high"},{id:"slack-webhook-url",needs:"hooks\\.slack\\.com/",source:"(?:https?://)?hooks\\.slack\\.com/(?:services|workflows|triggers)/[A-Za-z0-9+/_-]{40,}",flags:"i",confidence:"high"},{id:"twilio-api-key",needs:"SK[0-9a-fA-F]",source:"SK[0-9a-fA-F]{32}",confidence:"high"},{id:"sendgrid-api-token",needs:"SG\\.",source:`\\b(SG\\.[a-zA-Z0-9=_\\-.]{66})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"npm-access-token",needs:"npm_",source:`\\b(npm_[a-zA-Z0-9]{36})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"pypi-upload-token",needs:"pypi-AgEIcHlwaS5vcmc",source:"pypi-AgEIcHlwaS5vcmc[\\w-]{50,1000}",confidence:"high"},{id:"databricks-api-token",needs:"dapi[a-f0-9]",source:`\\b(dapi[a-f0-9]{32}(?:-\\d)?)(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"hashicorp-tf-api-token",needs:"\\.atlasv1\\.",source:"[a-zA-Z0-9]{14}\\.atlasv1\\.[a-zA-Z0-9\\-_=]{60,70}",confidence:"high"},{id:"pulumi-api-token",needs:"pul-",source:`\\b(pul-[a-f0-9]{40})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"postman-api-token",needs:"PMAK-",source:`\\b(PMAK-[a-fA-F0-9]{24}-[a-fA-F0-9]{34})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"grafana-api-key",needs:"eyJ",source:`\\b(eyJrIjoi[A-Za-z0-9+/]{70,400}={0,3})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"grafana-cloud-api-token",needs:"glc_",source:`\\b(glc_[A-Za-z0-9+/]{32,400}={0,3})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"grafana-service-account-token",needs:"glsa_",source:`\\b(glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"sentry-user-token",needs:"sntryu_",source:`\\b(sntryu_[a-f0-9]{64})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"sentry-org-token",needs:"sntrys_",source:"\\bsntrys_eyJpYXQiO[a-zA-Z0-9+/]{10,200}(?:LCJyZWdpb25fdXJs|InJlZ2lvbl91cmwi|cmVnaW9uX3VybCI6)[a-zA-Z0-9+/]{10,200}={0,2}_[a-zA-Z0-9+/]{43}",confidence:"high"},{id:"stripe-access-token",needs:"(?:sk|rk)_(?:test|live|prod)_",source:`\\b((?:sk|rk)_(?:test|live|prod)_[a-zA-Z0-9]{10,99})(?:[\\x60'"\\s;]|\\\\[nr]|$)`,confidence:"high"},{id:"shopify-access-token",needs:"shpat_",source:"shpat_[a-fA-F0-9]{32}",confidence:"high"},{id:"shopify-shared-secret",needs:"shpss_",source:"shpss_[a-fA-F0-9]{32}",confidence:"high"}],xg=64,Eo="-----",Co="BEGIN";function Ri(e,m,P){let J=P?/(?:-----BEGIN[ A-Z0-9_-]{0,100}?|\[REDACTED(?:-[A-Z]{1,20})?\](?:-{1,4}BEGIN)?([ A-Z0-9_-]{0,100}?))PRIVATE KEY(?: BLOCK)?-----/gi:/-----BEGIN[ A-Z0-9_-]{0,100}?PRIVATE KEY(?: BLOCK)?-----/gi,Z=P?/(?:-----END[ A-Z0-9_-]{0,100}?|\[REDACTED(?:-[A-Z]{1,20})?\](?:-{1,4}END)?([ A-Z0-9_-]{0,100}?))PRIVATE KEY(?: BLOCK)?-----/gi:/-----END[ A-Z0-9_-]{0,100}?PRIVATE KEY(?: BLOCK)?-----/gi;J.lastIndex=m;let pe=bi(J,e);if(!pe)return null;Z.lastIndex=pe.index+pe[0].length+xg;let fe=bi(Z,e);if(!fe)return null;while(fe[0].startsWith("[")){let ve=bi(Z,e);if(!ve)break;fe=ve}return{start:pe.index,end:fe.index+fe[0].length}}function bi(e,m){let P=e.exec(m);while(P?.[1]!==void 0&&/^-|--/.test(P[1]))e.lastIndex=P.index+1,P=e.exec(m);return P}function Eg(e){return Ri(e,0,!0)!==null}function Cg(e){let m=wu(e);if(m.length===0)return e;let P="",J=0;for(let Z of m)P+=e.slice(J,Z.start)+"[REDACTED]",J=Z.end;return P+e.slice(J)}function wg(e){let m=[];if(!/\[REDACTED/i.test(e))return m;for(let{start:P,end:J}of Ru(e,0,!0)){let Z=P;for(let pe of e.slice(P,J).matchAll(/-----(?:BEGIN|END)[ A-Z0-9_-]{0,100}?PRIVATE KEY(?: BLOCK)?-----/gi))m.push({start:Z,end:P+pe.index}),Z=P+pe.index+pe[0].length;m.push({start:Z,end:J})}return m.filter((P)=>P.end-P.start>=10)}function wu(e){let m=Eo.length,P=e.indexOf(Eo);while(P!==-1){while(e.charCodeAt(P+m)===45)P++;let J=0;while(J<Co.length&&(e.charCodeAt(P+m+J)|32)===(Co.charCodeAt(J)|32))J++;if(J===Co.length)break;P=e.indexOf(Eo,P+m)}return P===-1?[]:Ru(e,P,!1)}function Ru(e,m,P){let J=[];for(let Z=Ri(e,m,P);Z;Z=Ri(e,Z.end,P))J.push(Z);return J}var Ai=`(?:[\\x60'"\\s;]|\\\\[nr]|$)`,ki="(?=[^a-zA-Z0-9_\\-+=]|$)",hu="(?<![a-zA-Z0-9_\\-])";function Rg(){return Ii.map(({id:e,confidence:m,source:P,flags:J="",displayRun:Z})=>{let pe={id:e,confidence:m},fe=J.replace("g","")+"g";if(m!=="high")return{...pe,re:new RegExp(P,fe)};let ve=Au(P);if(Z===void 0)return{...pe,re:new RegExp(hu+ve+ki,fe)};return{...pe,prefilter:new RegExp(ve,J.replace("g","")),re:new RegExp(`(?<!${Z})(?=${Z}+${ki})${Z}*?${hu}(${ve})${ki}`,fe)}})}function qr(e){return Ii.map((m)=>{let P=(m.flags??"").replace("g",""),J={id:m.id,confidence:m.confidence,...m.redactOnly===!0&&{redactOnly:m.redactOnly},...m.prefilter!==void 0&&{prefilter:m.prefilter}};if(m.run===void 0)return{...J,re:new RegExp(m.source,e?P+"g":m.flags??"")};return{...J,prefilter:new RegExp(Au(m.source),P),re:new RegExp(`(?:(?<!${m.run})|(?<=\\\\[nr]))(?=${m.run}+${Ai})${m.run}*?${m.source}`,e?P+"g":P)}})}function Au(e){return e.endsWith(Ai)?e.slice(0,-Ai.length):e}function wo(e,m){if(typeof m!=="string")return"[REDACTED]";let P=m.length>=2&&(m[0]==='"'||m[0]==="'")&&m.at(-1)===m[0]?m[0]:"",J=e.lastIndexOf(m);return`${e.slice(0,J)}${P}[REDACTED]${P}${e.slice(J+m.length)}`}function Ag(e){let m=e[1];if(typeof m!=="string")return{keep:0,insert:"[REDACTED]"};let P=m.length>=2&&(m[0]==='"'||m[0]==="'")&&m.at(-1)===m[0]?1:0,J=e[0].lastIndexOf(m);return{keep:J+P,insert:"[REDACTED]",keepEnd:e[0].length-J-m.length+P}}function mu(e){let m=du(e,_g).map(({start:pe,end:fe})=>{let ve=/^(["'])[^]*\1$/.test(e.slice(pe,fe))?1:0;return[pe+ve,fe-ve]}),P=uu(e),J=Og(e),Z=wg(e).map(({start:pe,end:fe})=>[pe,fe]);return P.length===0&&J.length===0&&Z.length===0?m:Lg([...m,...P,...J,...Z])}var vi,Tg=new RegExp(Eu,"y"),Pg=512;function Og(e){vi??={plain:{assign:new RegExp(`${Ei}|${Ci}`,"gi"),nextKey:new RegExp(kg,"iy"),valueWithWhitespace:new RegExp(`["']|${Sr}`,"iy"),skipsStrays:!1},escaped:{assign:new RegExp(`${Ei}|${Ci}|${xu}`,"gi"),nextKey:new RegExp(vg,"iy"),valueWithWhitespace:new RegExp(`\\\\*["']|${Sr}`,"iy"),skipsStrays:!0}};let m=Su(e,vi.plain);return vu.test(e)?[...m,...Su(e,vi.escaped)]:m}function Su(e,{assign:m,nextKey:P,valueWithWhitespace:J,skipsStrays:Z}){let pe=[],fe,ve=0,xe=Tg;m.lastIndex=0;for(let Re=m.exec(e);Re!==null;Re=m.exec(e)){let Ae=Re[1]??Re[2]??Re[3],De=Re.index+Re[0].length,Ke=De-Ae.length;P.lastIndex=Ke;let Be=Ae.length<=Pg&&P.test(e)?P.lastIndex:void 0;if(Be!==void 0&&Be<De){if(J.lastIndex=Be,!J.test(e))Be=void 0}if(Z&&fe!==void 0&&Re.index>=fe&&Re.index<ve&&Be===void 0){fe=void 0,m.lastIndex=ve;continue}if(fe!==void 0&&Re.index<fe){let ot=/^(["'])[^]*\1$/.test(Ae),at=ot&&ve<=Ke?1:0;xe.lastIndex=De,pe.push([Ke+at,!ot&&xe.test(e)?xe.lastIndex:De-at])}if(ve=De,fe=Be,fe!==void 0)m.lastIndex=Ke}return pe}function Lg(e){let m=e.filter(([J,Z])=>Z>J).sort((J,Z)=>J[0]-Z[0]),P=[];for(let[J,Z]of m){let pe=P.at(-1);if(pe!==void 0&&J<=pe[1])pe[1]=Math.max(pe[1],Z);else P.push([J,Z])}return P}function yu(e,m){let{text:P,origin:J}=e,Z=[],pe=0;for(let fe=0;fe<P.length;){let ve=J[fe];while(pe<m.length&&m[pe][1]<=ve)pe++;let xe=m[pe];if(ve<0||xe===void 0||ve<xe[0]){fe++;continue}let Re=fe;while(Re>0&&J[Re-1]<0)Re--;while(fe<P.length&&(J[fe]<0||J[fe]>=xe[0]&&J[fe]<xe[1]))fe++;let Ae=Z.at(-1);if(Ae!==void 0&&Ae[1]>=Re)Ae[1]=fe;else Z.push([Re,fe,"[REDACTED]"])}return vo(e,Z)}var Ig=512,Dg=512,Mg=[{needs:lu,needsUrl:!0},{needs:`${Eo}${Co}|\\[REDACTED`,flags:"i"},{needs:Ro,flags:"i"},{needs:Cu,flags:"i"}],Fg=1e4;function Ng(){let e=new Set(["[^\\x00-\\x7f]"]),m=new Set,P=new Set;for(let{needs:J,needsUrl:Z,flags:pe}of[...Ii,...Mg])if(Z===!0)P.add(J);else if(pe?.includes("i")===!0)m.add(J);else e.add(J);return{exactCase:new RegExp([...e].join("|")),anyCase:new RegExp([...m].join("|"),"i"),inUrl:new RegExp([...P].join("|"),"i")}}class Tu{testRules=null;redactRules=null;displayRules=null;needs=null;resultCache=new Map;mayHoldSecret(e){return this.needs??=Ng(),typeof e!=="string"||e.length>Fg||this.needs.exactCase.test(e)||this.needs.anyCase.test(e)||e.includes("://")&&this.needs.inUrl.test(e)}scan(e){this.testRules??=qr(!1);let m=[];for(let P of this.testRules)if(P.confidence==="high"&&P.prefilter?.test(e)!==!1&&P.re.test(e))m.push({ruleId:P.id,label:P.id.split("-").map((J)=>qg[J]??$e(J)).join(" ")});if(Eg(e))m.push({ruleId:"private-key",label:"Private Key"});return m}redactContext(e,m=!1){this.redactRules??=qr(!0);let P=Cg(e);for(let J of this.redactRules)if(J.confidence==="low"&&xi(J,m,P))P=P.replace(J.re,wo);return P}redactTokens(e){this.redactRules??=qr(!0);let m=e;for(let P of this.redactRules)if(P.confidence==="high"&&P.prefilter?.test(m)!==!1)m=m.replace(P.re,wo);return m}trackedByRules(e,m=!1){return this.trackedTokens(this.trackedContext(e,m))}trackedContext(e,m=!1){let P=vo(Xl(e),wu(e).map(({start:J,end:Z})=>[J,Z,"[REDACTED]"]));return this.trackedRules(P,"low",m)}redactOnlyRules(e){this.redactRules??=qr(!0);let m=e;for(let P of this.redactRules)if(P.redactOnly===!0&&xi(P,!0,m))m=m.replace(P.re,wo);return m}trackedTokens(e){return this.trackedRules(e,"high")}trackedRules(e,m,P=!1){this.redactRules??=qr(!0);let J=e;for(let Z of this.redactRules)if(Z.confidence===m&&xi(Z,P,J.text))Z.re.lastIndex=0,J=Zl(J,Z.re,Ag);return J}redactWithUrlRanges(e){let m=mu(e);return m.length===0?this.redactTokens(this.redactContext(e,!0)):yu(this.trackedByRules(e,!0),m).text}redactTracked(e){return yu(this.trackedByRules(e,!0),mu(e))}redact(e){if(!this.mayHoldSecret(e))return e;let m=e.length<=Ig;if(m){let J=this.resultCache.get(e);if(J!==void 0)return J}let P=this.redactWithUrlRanges(e);if(m){if(this.resultCache.size>=Dg)this.resultCache.delete(this.resultCache.keys().next().value);this.resultCache.set(e,P)}return P}redactForDisplay(e){this.displayRules??=Rg();let m=e;for(let P of this.displayRules){if(P.confidence!=="high"||P.prefilter?.test(m)===!1)continue;m=m.replace(P.re,$g)}return m}}var Ug=new Tu;var Hg="[hidden for privacy]",Bg=a({reporter:void 0},(e)=>{e.reporter=void 0});function Kg(e){try{Bg.reporter?.(e)}catch{}}function jg(e){try{return Ug.redact(e)}catch(m){Kg(m);return}}function Pu(e){return jg(e)??Hg}var Xk=new RegExp(Li),Zk=new RegExp(Li,"g");var Wg=/[$\x60|;&<>()\s]/,Gg=/[/.@:~*?\\]/;function $g(e,m){let P=typeof m==="string"?m:e;if(Wg.test(P)||Gg.test(P))return e;return wo(e,m)}var To="(^|[^a-z0-9+.-]|%[0-9a-f]{2})",Vg="https?|wss?|ftps?",Ou="ssh\\+git|git\\+ssh|ssh|git",Qk=new RegExp(`[a-z](?:[a-z0-9+.-]{1,31}:\\/+|:\\/\\/)|(?:https?|ftps?):(?!\\/)|${To}(?:wss?|file):(?!\\/)|${To}(?:${Ou}):(?!\\/)(?=[^@/?#\\s]*?(?::|%3a))`,"i");var ev=new RegExp(`${To}(?:${Vg}):(?!\\/\\/)|${To}(?:${Ou}):(?!\\/\\/)`,"gi");function xi(e,m,P){return(m||e.redactOnly!==!0)&&(e.prefilter===void 0||e.prefilter.test(P))}var qg={aws:"AWS",gcp:"GCP",api:"API",pat:"PAT",ad:"AD",tf:"TF",oauth:"OAuth",npm:"NPM",pypi:"PyPI",jwt:"JWT",ci:"CI",scim:"SCIM",github:"GitHub",gitlab:"GitLab",openai:"OpenAI",digitalocean:"DigitalOcean",huggingface:"HuggingFace",hashicorp:"HashiCorp",sendgrid:"SendGrid"};var Ni={verbose:0,debug:1,info:2,warn:3,error:4},Qg=new RegExp(`(?!\\t)[${W}]`,"gu"),ef=10485760,Du=1048576,tf=1e4,nf=262144,rf=5000,Mu=100,of=gr((e)=>e());function sf(e){return Object.hasOwn(Ni,e)}function Fu(e){return Oa(e)?null:Bu(e)}function Nu(){}var af={arm:"v5",target:null};function lf(e,m){e.stuck=e.appendSince===m?"yes":"no"}var uf={sessionId:"",fromBackend:!1};function Uu(e,m,P,J){let Z=pr(m,"debug"),pe=pr(Z,`${e.sessionId}.txt`),fe;if(P===null)fe=pe;else if(J!==null&&P===J)fe=pr(J,`${e.sessionId}.txt`);else fe=P;let ve=!e.fromBackend&&fe===pe?"v5":"raw";return{target:fe,arm:ve,configHome:m,rotate:ve==="raw"&&!(Pr(fe)===Z&&fe.endsWith(".txt")),pointLatest:ve==="raw"&&fe!==pe}}function Fi(e){return ht.userNamed(Zg(e)?e:Bu(e))}function df(e){return e.code==="Failed"&&e.telemetryCode==="ENOENT"}function cf(e,m=sl){return m?e:void 0}async function Hu(e,m,P,J){let Z={namespace:"log",sessionId:m,channel:"debug"},pe=await ri.run(!0,()=>e.append(Z,[{data:P}],J?{markLatest:!0}:void 0));if(pe.ok)return"landed";return J&&pe.error.code==="InvalidArgument"&&pe.error.argument==="opts.markLatest"?"refused":"dropped"}class Ku{deps;minLevel;filter;toStderr;filePath;runtimeDebugEnabled=!1;hasFormattedOutput=!1;debugFromLaunch;storageV5;writer=null;redirect=null;unflushedChunks=[];backlog={chain:Promise.resolve(),length:0,appendSince:0,stuck:"no",droppedCount:0,droppedTotal:0};appendOldest=this.appendOldestChunks.bind(this);backendLinesLogged=0;exiting=!1;exitHandlerRegistered=!1;successor=null;writtenBytes=-1;rotating=!1;resolvedLogPath=null;overrideDirectory=null;rotationTarget=null;latestMarked=!1;latestRefused=!1;constructor(e){this.deps=e;if(this.storageV5=cf(e.storageV5),e.launchIdentity!==void 0){this.minLevel=e.launchIdentity.minLevel,this.filter=e.launchIdentity.filter,this.toStderr=e.launchIdentity.toStderr,this.filePath=e.launchIdentity.filePath,this.debugFromLaunch=e.launchIdentity.debugFromLaunch;return}let m=Array.isArray(e.argv)?e.argv:[],P=ll(),J;if(P!==void 0)J=P(m);else{let ve=m.indexOf("--");J=ve===-1?m:m.slice(0,ve)}let Z=e.env.CLAUDE_CODE_DEBUG_LOG_LEVEL?.toLowerCase().trim();this.minLevel=Z&&sf(Z)?Z:"debug";let pe=J.find((ve)=>ve.startsWith("--debug="));this.filter=pe?cl(pe.substring(8)):null,this.toStderr=J.includes("--debug-to-stderr")||J.includes("-d2e");let fe=null;for(let ve=0;ve<J.length;ve++){let xe=J[ve];if(xe.startsWith("--debug-file=")){fe=Fu(xe.substring(13));break}if(xe==="--debug-file"&&ve+1<J.length){fe=Fu(J[ve+1]);break}}this.filePath=fe,this.debugFromLaunch=d(e.env.DEBUG)||d(e.env.DEBUG_SDK)||J.includes("--debug")||J.includes("-d")||this.toStderr||pe!==void 0||this.filePath!==null}isDebugMode(){return this.runtimeDebugEnabled||this.debugFromLaunch}mayWrite(e){return this.takesLevel(e)&&(this.deps.isAnt||this.isDebugMode())}drainsSyncAtExit(){return!(c()&&this.storageV5!==void 0&&this.deps.syncExitDrain===!1)}launchIdentity(){return{minLevel:this.minLevel,filter:this.filter,toStderr:this.toStderr,filePath:this.filePath,debugFromLaunch:this.debugFromLaunch,isAnt:this.deps.isAnt,isTestEnvironment:this.deps.isTestEnvironment}}enableDebugLogging(){let e=this.isDebugMode()||this.deps.isAnt;return this.runtimeDebugEnabled=!0,e}logPath(){return this.filePath??(this.overrideDirectory!==null&&this.overrideDirectory===this.deps.env.CLAUDE_CODE_DEBUG_LOGS_DIR?pr(this.overrideDirectory,`${this.deps.sessionId()}.txt`):null)??this.resolvedLogPath??this.deps.env.CLAUDE_CODE_DEBUG_LOGS_DIR??this.defaultLogPath()}defaultLogPath(e=this.deps.sessionId()){return pr(this.deps.configHomeDir(),"debug",`${e}.txt`)}learnedOverrideDirectory(){return this.overrideDirectory}isArmed(){return this.storageV5!==void 0}takesLevel(e){return Ni[e]>=Ni[this.minLevel]}log(e,{level:m}={level:"debug"}){if(!this.takesLevel(m))return;let P=this.deps.limits?.();if(P===void 0){this.emit(e,m);return}let J=e.length>P.maxMessageLength?`debug message not logged: it has ${e.length} characters, over this log's fixed limit of ${P.maxMessageLength} per message`:e,{admitted:Z,leftOutBefore:pe}=P.admit(J.length);if(!Z)return;P.timed(()=>{if(pe>0)this.emit(`debug messages not logged: ${pe} since this log's last line, over its fixed limit on how much it logs at a time`,m);this.emit(J,m)})}emit(e,m){if(!this.shouldLog(e))return;let P=Pu(e.trim());P=P.includes(`
|
|
34
|
+
`)?Jl(o(P)):P.replace(Qg,Yl);let Z=`${new Date().toISOString()} [${m.toUpperCase()}] ${P}
|
|
35
|
+
`;if(this.toStderr){this.deps.writeToStderr(Z);return}this.write(Z)}write(e){let m=this.getWriter(),P=uf;if(this.storageV5!==void 0){if(P={sessionId:this.deps.sessionId(),fromBackend:ri.getStore()===!0},P.fromBackend)this.backendLinesLogged++}if(m.write({origin:P,content:e}),this.exiting)m.flush()}async flush(){let e=this.backendLinesLogged;if(this.writer?.flush(),await this.drained(),this.storageV5!==void 0&&this.successor)return this.successor.flush();for(let m=0;this.backendLinesLogged!==e&&m<3;m++)e=this.backendLinesLogged,this.writer?.flush(),await this.drained();if(this.backlog.droppedCount>0&&this.backlog.length===0&&!this.successor)this.write(""),this.writer?.flush(),await this.drained()}async drained(){if(this.isAppendStuck())return;let e=this.backlog.chain.then(()=>!0);do if(await he(e,Mu))return;while(!this.isAppendStuck())}isAppendStuck(){let e=this.backlog,{appendSince:m}=e;if(e.stuck==="no"&&m!==0&&Date.now()-m>=rf)e.stuck="suspected",setTimeout(lf,Mu,e,m).unref();return e.stuck==="yes"}dispose(e){this.redirect=e;try{this.writer?.dispose()}finally{this.redirect=null,this.writer=null}}succeed(e){this.runtimeDebugEnabled=e.runtimeDebugEnabled,this.hasFormattedOutput=e.hasFormattedOutput,this.unflushedChunks=e.unflushedChunks,this.backlog=e.backlog,this.exitHandlerRegistered=e.exitHandlerRegistered,e.successor=this,e.dispose((m)=>{this.write(m)})}handleExit(){if(this.successor){this.successor.handleExit();return}if(this.exiting=!0,this.backlog.droppedCount>0)try{this.write("")}catch{}this.writer?.flush(),this.drainSync()}async maybeRotate(e,m,P=ef){let J=c()&&this.storageV5!==void 0?this.storageV5.hostFiles:void 0;if(this.writtenBytes<0)if(J){let Z=await J.stat(Fi(e));this.writtenBytes=Z.ok&&Z.value.kind!=="absent"?Z.value.size:0}else this.writtenBytes=await Jg(e).then((Z)=>Z.size).catch(()=>0);else this.writtenBytes+=m;if(this.writtenBytes<=P||this.rotating)return;this.rotating=!0;try{let Z=e.endsWith(".txt")?`${e.slice(0,-4)}.1.txt`:`${e}.1`;if(J){let pe=Fi(e),fe=Fi(Z),ve=await J.rename(pe,fe);if(!ve.ok&&!df(ve.error)){if(await J.delete(fe,{missingOk:!0}),!(await J.rename(pe,fe)).ok)await J.delete(pe,{missingOk:!0})}}else try{await Iu(e,Z)}catch(pe){if(!h(pe))await Mi(Z).catch(()=>{}),await Iu(e,Z).catch(()=>Mi(e).catch(()=>{}))}this.writtenBytes=0}finally{this.rotating=!1}}shouldLog(e){if(this.deps.isTestEnvironment&&!this.toStderr&&this.filePath===null)return!1;if(!this.deps.isAnt&&!this.isDebugMode())return!1;if(typeof process>"u"||typeof process.versions>"u"||typeof process.versions.node>"u")return!1;return pl(e,this.filter)}resolveDirToFile(e){return this.resolvedLogPath=pr(e,`${this.deps.sessionId()}.txt`),this.resolvedLogPath}async appendGroup(e,m,P,J){if(this.storageV5!==void 0&&e.arm==="v5"){await this.appendV5AndMark(this.storageV5,m,P);return}if(e.target===null||!this.writesFiles())return;if(J)await Lu(Pr(e.target),{recursive:!0}).catch(()=>{});let Z=e;try{await Di(e.target,P)}catch(pe){if(!Ho(pe))throw pe;if(this.storageV5===void 0)Z={...e,target:this.resolveDirToFile(e.target)},await Di(Z.target,P);else{if(this.overrideDirectory=e.target,Z=Uu(m,e.configHome,e.target,e.target),Z.arm==="v5"){await this.appendV5AndMark(this.storageV5,m,P);return}await Lu(Pr(Z.target),{recursive:!0}).catch(()=>{});try{await Di(Z.target,P)}catch{return}}}if(Z.rotate){if(this.storageV5!==void 0&&Z.target!==this.rotationTarget)this.rotationTarget=Z.target,this.writtenBytes=-1;await this.maybeRotate(Z.target,Buffer.byteLength(P)).catch(Nu)}if(Z.pointLatest)this.markLatestSymlink()}async appendV5AndMark(e,m,P){let J=c(),Z=J&&!this.latestMarked&&!this.latestRefused,pe=await Hu(e,m.sessionId,P,Z);if(pe==="refused")this.latestRefused=!0,pe=await Hu(e,m.sessionId,P,!1),this.log("debug log: the storage backend refused markLatest; <debug folder>/latest is not pointed in this process",{level:"warn"});if(pe!=="landed")return;if(Z&&!this.latestRefused)this.latestMarked=!0;else if(!J)this.markLatestSymlink()}markLatestSymlink(){if(!this.latestMarked&&this.writesFiles())this.latestMarked=!0,this.updateLatestSymlink()}isSessionDiskless(){try{return this.deps.diskless?.()===!0}catch{return!0}}writesFiles(){if(this.isSessionDiskless())return!1;try{return this.deps.defaultFile?.()!==!1||this.filePath!==null||this.deps.env.CLAUDE_CODE_DEBUG_LOGS_DIR!==void 0}catch{return!1}}async appendOldestChunks(){let e=this.backlog,m=this.unflushedChunks[0],P=m?.queued;if(P===void 0)return;let J=0,Z=0,pe=!1;for(let{content:fe,queued:ve}of this.unflushedChunks){if(ve===void 0||ve.owner!==P.owner||ve.decision.arm!==P.decision.arm||ve.decision.target!==P.decision.target||ve.origin.sessionId!==P.origin.sessionId||ve.origin.fromBackend!==P.origin.fromBackend||J>0&&Z+fe.length>nf)break;J++,Z+=fe.length,pe||=ve.needMkdir}if(e.appendSince=Date.now(),await P.owner.appendGroup(P.decision,P.origin,this.unflushedChunks.slice(0,J).map((fe)=>fe.content).join(""),pe).catch(Nu),e.appendSince=0,e.stuck="no",this.unflushedChunks[0]===m)this.unflushedChunks.splice(0,J),e.length-=Z}drainSync(){if(this.unflushedChunks.length===0)return;if(this.backlog.length=0,!this.drainsSyncAtExit()||!this.writesFiles()||this.isAppendStuck()){this.unflushedChunks.length=0;return}let e=[];for(let m of this.unflushedChunks.splice(0)){if(m.target===null)continue;let P=e.at(-1);if(P!==void 0&&P.armed===m.armed&&(!m.armed||P.target===m.target))P.parts.push(m);else e.push({target:m.target,armed:m.armed,parts:[m]})}for(let{target:m,armed:P,parts:J}of e){let Z=P?m:this.logPath(),pe=J.map((fe)=>fe.content).join("");try{l().mkdirSync(Pr(Z))}catch{}try{l().appendFileSync(Z,pe)}catch(fe){if(Ho(fe))try{if(!P)l().appendFileSync(this.resolveDirToFile(Z),pe);else{let ve=(Ae,De)=>{try{l().appendFileSync(pr(Z,`${Ae}.txt`),De)}catch{}},xe=J[0]?.sessionId,Re="";for(let Ae of J){if(Ae.sessionId!==xe)ve(xe,Re),xe=Ae.sessionId,Re="";Re+=Ae.content}ve(xe,Re)}}catch{}}}}droppedLineTotal(){return this.backlog.droppedTotal}takeDroppedNote(){let{droppedCount:e}=this.backlog;if(e===0)return"";return this.backlog.droppedCount=0,`${new Date().toISOString()} [WARN] debug messages not logged: ${e} since the line above, because writes to this log were over 10 s behind, with over 1 MiB waiting
|
|
36
|
+
`}groupLines(e){let m=e[0];if(m===void 0)return[];let P=this.filePath??this.deps.env.CLAUDE_CODE_DEBUG_LOGS_DIR??null,J=this.isSessionDiskless();if(J&&(this.storageV5===void 0||P!==null))return[];if(this.storageV5===void 0)return[{decision:{target:this.logPath(),arm:"raw",configHome:"",rotate:!0,pointLatest:!0},origin:m.origin,lines:e}];let Z=[];for(let pe of e){if(J&&pe.origin.fromBackend)continue;let fe=Z.at(-1);if(fe!==void 0&&fe.origin.sessionId===pe.origin.sessionId&&fe.origin.fromBackend===pe.origin.fromBackend)fe.lines.push(pe);else Z.push({decision:J?af:Uu(pe.origin,this.deps.configHomeDir(),P,this.overrideDirectory),origin:pe.origin,lines:[pe]})}return Z}getWriter(){if(this.writer)return this.writer;let e=null,m=this.storageV5!==void 0;if(this.writer=il({writeBatch:(P)=>{if(this.redirect){this.redirect(P.map((pe)=>pe.content).join(""));return}if(this.exiting){for(let pe of this.groupLines(P))this.unflushedChunks.push({target:pe.decision.target,sessionId:pe.origin.sessionId,armed:m,content:this.takeDroppedNote()+pe.lines.map((fe)=>fe.content).join("")});this.drainSync();return}let J=this.writesFiles(),Z=this.backlog;this.isAppendStuck();for(let pe of this.groupLines(P)){if(pe.decision.arm==="raw"&&!J)continue;if(Z.droppedCount>0?Z.length>=Du/2:Z.length>=Du&&Date.now()-(this.unflushedChunks[0]?.queued?.at??1/0)>=tf){Z.droppedCount+=pe.lines.length,Z.droppedTotal+=pe.lines.length;continue}let fe=this.takeDroppedNote()+pe.lines.map((Re)=>Re.content).join("");if(fe==="")continue;let ve=pe.decision.arm==="raw"?Pr(pe.decision.target):null,xe=ve!==null&&(pe.origin.fromBackend||e!==ve);if(ve!==null)e=ve;this.unflushedChunks.push({target:pe.decision.target,sessionId:pe.origin.sessionId,armed:m,content:fe,queued:{at:Date.now(),owner:this,decision:pe.decision,origin:pe.origin,needMkdir:xe}}),Z.length+=fe.length,Z.chain=of(()=>Z.chain.then(this.appendOldest))}},sizeOf:(P)=>P.content.length,flushIntervalMs:1000,maxBufferSize:100,immediateMode:this.isDebugMode()}),this.deps.registerCleanup(async()=>{this.writer?.dispose(),await this.drained()}),!this.exitHandlerRegistered)this.exitHandlerRegistered=!0,this.deps.onExit(this.handleExit.bind(this));return this.writer}async updateLatestSymlink(){try{let e=this.logPath();if(Xg(e).toLowerCase()==="latest")return;let m=pr(Pr(e),"latest");if((await zg(m).catch(()=>null))?.isSymbolicLink())await Mi(m).catch(()=>{});await Yg(e,m)}catch{}}}class ju{instance=void 0;init={};defaultFile=!0;limits=void 0;setInstance(e){this.instance=e}setInit(e){this.init=e}disableDefaultFile(){this.defaultFile=!1}setLimits(e){this.limits=e}}var pf=new s(()=>new ju);function gf(){return q(pf)}function ff(e,m){return new Ku({argv:process.argv,env:process.env,sessionId:()=>ol(),configHomeDir:()=>R(),onExit:(P)=>{process.on("exit",P)},registerCleanup:(P)=>{_t(P)},writeToStderr:(P)=>{Pl(P,{mayDrop:!0})},isAnt:m?.isAnt??!1,isTestEnvironment:m?.isTestEnvironment??!1,launchIdentity:m,storageV5:e.init.storageV5!==void 0&&e.init.configHome===Ee()?e.init.storageV5:void 0,syncExitDrain:e.init.syncExitDrain,diskless:()=>g(),defaultFile:()=>e.defaultFile,limits:()=>e.limits})}function Wu(){let e=gf(),m=e.instance;if(m)return m;let P=ff(e);return e.setInstance(P),P}function Ln(){return Wu().mayWrite("debug")}function t(e,m={level:"debug"}){Wu().log(e,m)}function Gu(e){let m=0;for(let P=0;P<e.length;P++)m=(m<<5)-m+e.charCodeAt(P)|0;return m}function hf(e){return`</pasted_content id="${e}">
|
|
37
|
+
`}function mf(e){if(e.length!==4)return!1;for(let m=0;m<e.length;m++){let P=e.charCodeAt(m);if(!(P>=48&&P<=57||P>=97&&P<=102))return!1}return!0}function Sf(e){let m=[],P=0,J=0;for(;;){let Z=e.indexOf('<pasted_content id="',J);if(Z===-1)break;let pe=Z+20,fe=e.slice(pe,pe+4);if(!mf(fe)||!e.startsWith(`">
|
|
38
|
+
`,pe+4)){J=pe;continue}let ve=pe+4+3,Re=hf(fe).slice(0,-1),Ae=e.indexOf(`
|
|
39
|
+
${Re}`,ve-1)+1;if(Ae===0)break;let De=Z;for(let Ke=0;Ke<2&&De>P&&e[De-1]===`
|
|
40
|
+
`;Ke++)De--;if(De>P)m.push({kind:"text",text:e.slice(P,De)});P=Ae+Re.length;for(let Ke=0;Ke<2&&e[P]===`
|
|
41
|
+
`;Ke++)P++;m.push({kind:"block",id:fe,body:e.slice(ve,Ae-1),raw:e.slice(De,P)}),J=P}if(P<e.length)m.push({kind:"text",text:e.slice(P)});return m}function $u(e){let m=Sf(e);if(m.length===1&&m[0].kind==="text")return e;return m.map((P)=>P.kind==="text"?P.text:P.body).join("")}var X=["PreToolUse","PostToolUse","PostToolUseFailure","PostToolBatch","Notification","UserPromptSubmit","UserPromptExpansion","SessionStart","SessionEnd","Stop","StopFailure","SubagentStart","SubagentStop","PreCompact","PostCompact","PreModelSwitch","PostModelSwitch","PermissionRequest","PermissionDenied","Setup","TeammateIdle","TaskCreated","TaskCompleted","Elicitation","ElicitationResult","ConfigChange","WorktreeCreate","WorktreeRemove","InstructionsLoaded","CwdChanged","FileChanged","DirectoryAdded","MessageDisplay"],Qn=["clear","resume","logout","prompt_input_exit","other"],er="__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__";var yf=`
|
|
42
|
+
|
|
43
|
+
This is how Claude Code surfaces a prompt a plugin submits between `+"turns — it starts this turn in the user's place. Address the message above.";var _f=(e)=>`Prompt from the ${e} plugin`;var bf=(e)=>typeof e==="object"&&e!==null&&("text"in e)&&typeof e.text==="string"&&e.text!=="",kf=(e)=>e.length>28&&e.startsWith("The ")&&e.endsWith(` plugin sent a message:
|
|
44
|
+
`);function vf(e,m){let P=e.slice(0,e.indexOf(`
|
|
45
|
+
`)+1);return bf(m)&&kf(P)&&e===P+m.text+yf?{label:P.slice(4,-24),text:m.text}:void 0}function xf(e,m,P){let J=vf(e,m);if(J===void 0)return e;return`${_f(J.label)}${P}${J.text}`}var Vu=(e,m)=>xf(e,m,": ");var Ef=/^(?:\s*<[a-z][\w-]*[\s>]|\[Request interrupted by user[^\]]*\])/,Cf=/<command-name>(.*?)<\/command-name>/;function ft(e,m,P="stored"){if(e.type!=="user")return;if(e.isMeta===!0||e.isCompactSummary===!0)return;let J=e.message;if(!J)return;let Z=J.content,pe=P==="shown"&&typeof Z==="string"?Vu(Z,e.pluginPrompt):Z,fe=pe!==Z,ve=[];if(typeof pe==="string")ve.push(pe);else if(Array.isArray(Z))for(let xe of Z){if(!xe||typeof xe!=="object")continue;if(xe.type==="tool_result")return;if(xe.type==="text"&&typeof xe.text==="string")ve.push(xe.text)}for(let xe of ve){let Re=$u(xe).replaceAll(`
|
|
46
|
+
`," ").trim();if(!Re)continue;let Ae=fe?null:Cf.exec(Re);if(Ae){if(!m.commandFallback)m.commandFallback=Ae[1];continue}let De=fe?null:/<bash-input>([\s\S]*?)<\/bash-input>/.exec(Re);if(De)return`! ${De[1].trim()}`;if(Ef.test(Re))continue;if(Re.length>200)Re=Se(Re,200).trim()+"…";return Re}return}var kn=["Agent","Artifact","AskUserQuestion","Bash","ClaudeDesign","CronCreate","CronDelete","CronList","Edit","EndConversation","EnterPlanMode","EnterWorktree","ExitPlanMode","ExitWorktree","Glob","Grep","ListAgents","ListMcpResourcesTool","LSP","Monitor","NotebookEdit","OfferChromeSetup","PowerShell","Projects","propose_skills","PushNotification","Read","ReadMcpResourceDirTool","ReadMcpResourceTool","ReadNotifications","RemoteTrigger","ReportFindings","ScheduleWakeup","SendFeedback","SendMessage","SendUserFile","SendUserMessage","SetGoal","ShareOnboardingGuide","ShowOnboardingRolePicker","Skill","SubagentHandback","TaskCreate","TaskGet","TaskList","TaskStop","TaskUpdate","TodoWrite","ToolSearch","WaitForMcpServers","WebFetch","WebSearch","Workflow","Write"],Ye={Task:"Agent",KillShell:"TaskStop",KillBash:"TaskStop",ListPeers:"ListAgents",Brief:"SendUserMessage",ListMcpResources:"ListMcpResourcesTool",ReadMcpResource:"ReadMcpResourceTool",ReadMcpResourceDir:"ReadMcpResourceDirTool",ProposeGoal:"SetGoal"};function M(e){if(typeof e!=="object"||e===null)return!1;let m=Object.getPrototypeOf(e);return m===Object.prototype||m===null}var we=2147483647;var wf=1000;function Rf(){return{eventQueue:[],sink:null,droppedEventCount:0}}function Af(e,m){if(e.eventQueue.length>=wf)e.eventQueue.shift(),e.droppedEventCount++;e.eventQueue.push(m)}class qu{state=Rf()}var Tf=new s(()=>new qu);function Pf(){return q(Tf)}function le(e,m){let P=Pf().state;if(P.sink===null){Af(P,{eventName:e,metadata:m,async:!1});return}P.sink.logEvent(e,m)}function bt(e,m){le("tengu_feature_ok",{...m,feature_name:te(e)})}function Of(e,m,P){le("tengu_feature_bad",{...P,feature_name:te(e),error_code:Uo(m)})}function et(e,m,P){le("tengu_feature_sad",{...P,feature_name:te(e),error_code:Uo(m)})}async function w(e,m,P){try{let J=await m();return bt(e),J}catch(J){throw Of(e,P?.(J)??"error"),J}}function n(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Lf(e){if(e.length!==22)return;let m=BigInt(58),P=0n;for(let J of e){let Z="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".indexOf(J);if(Z<0)return;P=P*m+BigInt(Z)}return P}function zu(e){let m=e.lastIndexOf("_");if(m<0)return;let P=e.slice(m+1);if(!P.startsWith("01"))return;let J=Lf(P.slice(2));if(J===void 0)return;let Z=J.toString(16).padStart(32,"0");if(Z.length!==32)return;return`${Z.slice(0,8)}-${Z.slice(8,12)}-${Z.slice(12,16)}-${Z.slice(16,20)}-${Z.slice(20,32)}`}function Ju(e){return zu(e)??e}function Yu(e){if(!n(e))return;let{id:m,directory_id:P,transport:J,plugin_id_hash:Z}=e;switch(e.type){case"anthropic":return Oo(m)?{type:"anthropic",id:m}:void 0;case"claude_ai_connector":return Oo(m)&&(P===null||Oo(P))?{type:"claude_ai_connector",id:Ju(m),directory_id:P}:void 0;case"client_configured":return(J==="stdio"||J==="http"||J==="in_process")&&(Z===void 0||Oo(Z))?{type:"client_configured",transport:J,...Z!==void 0&&{plugin_id_hash:Z}}:void 0;default:return}}var If=256;function Oo(e){return typeof e==="string"&&e.length>0&&e.length<=If&&!/[\x00-\x1f\x7f]/.test(e)}function Ct(e){return typeof e==="number"&&Number.isInteger(e)&&e>0?e:void 0}var Df={always_allow:!0,always_ask:!0,always_deny:!0};function Mf(e){return typeof e==="string"&&Object.hasOwn(Df,e)}function Xu(e){if(!n(e)||typeof e.name!=="string")return;let{name:m,permission_policy:P}=e;if(P===void 0)return{policy:{name:m},rewritten:!1};return Mf(P)?{policy:{name:m,permission_policy:P},rewritten:!1}:{policy:{name:m,permission_policy:"always_ask"},rewritten:!0}}function Mn(e,m){if(e===void 0||m===void 0)return e===m;return e.length===m.length&&e.every((P,J)=>P.name===m[J]?.name&&P.permission_policy===m[J]?.permission_policy)}var Ff=64,Nf=128;function Xt(e){if(!n(e))return{settings:{},ignored:[]};let{timeout:m,disableAutoBackground:P,tools:J,connectorId:Z,autoModeVerdictTools:pe,dataFlowServer:fe,onPersonsMachine:ve}=e,xe=Ct(m),Re=[];if(m!==void 0&&xe===void 0)Re.push("timeout");if(P!==void 0&&typeof P!=="boolean")Re.push("disableAutoBackground");let Ae=Uf(J);if(Jt(e)!==void 0)Re.push("tools");let De=typeof Z==="string"&&Z!=="";if(Z!==void 0&&!De)Re.push("connectorId");let Ke=Array.isArray(pe)?pe.filter((kt)=>typeof kt==="string"&&kt.length<=Nf):[],Be=Array.isArray(pe)&&pe.length<=Ff&&Ke.length===pe.length;if(pe!==void 0&&!Be)Re.push("autoModeVerdictTools");let ot=Yu(fe),at=Z===void 0||ot?.type==="claude_ai_connector"?ot:void 0;if(fe!==void 0&&at===void 0)Re.push("dataFlowServer");let xt=n(ve)?ve.exceptTools:void 0,st=Array.isArray(xt)&&xt.every((kt)=>typeof kt==="string")?[...xt]:[];return{settings:{...xe!==void 0&&{timeout:xe},...P===!0&&{disableAutoBackground:P},...Ae!==void 0&&{tools:Ae},...De&&{connectorId:Z},...Be&&{autoModeVerdictTools:Ke},...at!==void 0&&{dataFlowServer:at},...ve!==void 0&&{onPersonsMachine:{exceptTools:st}}},ignored:Re}}function Jt(e){let m=n(e)?e.tools:void 0;if(m===void 0)return;if(!Array.isArray(m))return{kind:"not_a_list"};let P=0,J=0;for(let Z of m){let pe=Xu(Z);if(pe===void 0)P++;else if(pe.rewritten)J++}return P+J>0?{kind:"entries",dropped:P,rewritten:J,kept:m.length-P}:void 0}function Nn(e){if(e.kind==="not_a_list")return"tools[] is not a list; no per-tool policy taken";let m=[];if(e.dropped>0)m.push(`dropped ${e.dropped} malformed tools[] ${e.dropped===1?"entry":"entries"}`);if(e.rewritten>0)m.push(`read ${e.rewritten} tools[] ${e.rewritten===1?"entry":"entries"} with an invalid permission_policy as always_ask`);return`${m.join(", ")}; kept ${e.kept}`}function Uf(e){if(!Array.isArray(e))return;let m=[];for(let P of e){let J=Xu(P);if(J!==void 0)m.push(J.policy)}return m}function be(e){return e.startsWith("\uFEFF")?e.slice(1):e}function Qu(){return"prod"}var Un=["","-staging-oauth","-local-oauth","-custom-oauth"];function Zt(){if(process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL)return"-custom-oauth";switch(Qu()){case"local":return"-local-oauth";case"staging":return"-staging-oauth";case"prod":return""}}function Fn(){return Zt()==="-staging-oauth"}var Bf=31536000;var ax=Math.round(Bf/86400);var Zu={BASE_API_URL:"https://api.anthropic.com",CONSOLE_AUTHORIZE_URL:"https://platform.claude.com/oauth/authorize",CLAUDE_AI_AUTHORIZE_URL:"https://claude.com/cai/oauth/authorize",CLAUDE_AI_ORIGIN:"https://claude.ai",TOKEN_URL:"https://platform.claude.com/v1/oauth/token",API_KEY_URL:"https://api.anthropic.com/api/oauth/claude_cli/create_api_key",ROLES_URL:"https://api.anthropic.com/api/oauth/claude_cli/roles",CONSOLE_SUCCESS_URL:"https://platform.claude.com/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code",CLAUDEAI_SUCCESS_URL:"https://platform.claude.com/oauth/code/success?app=claude-code",MANUAL_REDIRECT_URL:"https://platform.claude.com/oauth/code/callback",CLIENT_ID:"9d1c250a-e61b-44d9-88ed-5944d1962f5e",DESIGN_CLIENT_ID:"59637612-477b-4836-a601-b0589eda7704",OAUTH_FILE_SUFFIX:"",PLUGINS_SCOPE_REGISTERED:!0,PROJECTS_SCOPES_REGISTERED:!0,PRIVACY_CONSENTS_SCOPE_REGISTERED:!0,HYBRID_SETTINGS_SCOPE_REGISTERED:!0,MCP_PROXY_URL:"https://mcp-proxy.anthropic.com",MCP_PROXY_PATH:"/v1/mcp/{server_id}"};var Kf=void 0;function jf(){let e=process.env.CLAUDE_LOCAL_OAUTH_API_BASE?.replace(/\/$/,"")??"http://localhost:8000",m=process.env.CLAUDE_LOCAL_OAUTH_APPS_BASE?.replace(/\/$/,"")??"http://localhost:4000",P=process.env.CLAUDE_LOCAL_OAUTH_CONSOLE_BASE?.replace(/\/$/,"")??"http://localhost:3000";return{BASE_API_URL:e,CONSOLE_AUTHORIZE_URL:`${P}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${m}/oauth/authorize`,CLAUDE_AI_ORIGIN:m,TOKEN_URL:`${e}/v1/oauth/token`,API_KEY_URL:`${e}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${e}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${P}/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`${P}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${P}/oauth/code/callback`,CLIENT_ID:"22422756-60c9-4084-8eb7-27705fd5cf9a",DESIGN_CLIENT_ID:"00000000-0000-4000-8000-000000000000",OAUTH_FILE_SUFFIX:"-local-oauth",PLUGINS_SCOPE_REGISTERED:!0,PROJECTS_SCOPES_REGISTERED:!0,PRIVACY_CONSENTS_SCOPE_REGISTERED:!0,HYBRID_SETTINGS_SCOPE_REGISTERED:!0,MCP_PROXY_URL:"http://localhost:8205",MCP_PROXY_PATH:"/v1/toolbox/shttp/mcp/{server_id}"}}var Wf=["https://beacon.claude-ai.staging.ant.dev","https://claude.fedstart.com","https://claude-staging.fedstart.com"];function Gf(){switch(Qu()){case"local":return jf();case"staging":return Kf??Zu;case"prod":return Zu}}function Hn(){let e=Gf(),m=process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL;if(m){let J=m.replace(/\/$/,"");if(!Wf.includes(J))throw Error("CLAUDE_CODE_CUSTOM_OAUTH_URL is not an approved endpoint.");e={...e,BASE_API_URL:J,CONSOLE_AUTHORIZE_URL:`${J}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${J}/oauth/authorize`,CLAUDE_AI_ORIGIN:J,TOKEN_URL:`${J}/v1/oauth/token`,API_KEY_URL:`${J}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${J}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${J}/oauth/code/success?app=claude-code`,CLAUDEAI_SUCCESS_URL:`${J}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${J}/oauth/code/callback`,OAUTH_FILE_SUFFIX:"-custom-oauth",PLUGINS_SCOPE_REGISTERED:!1,PROJECTS_SCOPES_REGISTERED:!1,PRIVACY_CONSENTS_SCOPE_REGISTERED:!1,HYBRID_SETTINGS_SCOPE_REGISTERED:!1,SCOPES_CLEARED_BY:["CLAUDE_CODE_CUSTOM_OAUTH_URL"]}}let P=process.env.CLAUDE_CODE_OAUTH_CLIENT_ID;if(P)e={...e,CLIENT_ID:P,PLUGINS_SCOPE_REGISTERED:!1,PROJECTS_SCOPES_REGISTERED:!1,PRIVACY_CONSENTS_SCOPE_REGISTERED:!1,HYBRID_SETTINGS_SCOPE_REGISTERED:!1,SCOPES_CLEARED_BY:[...e.SCOPES_CLEARED_BY??[],"CLAUDE_CODE_OAUTH_CLIENT_ID"]};return e}var $f=String.fromCharCode(0),Vf=/^\.[0-9a-f]{16}\.aside$/;function qf(e){if(e.charCodeAt(0)!==46)return!1;return ce(e).some((m)=>Vf.test(m))}function zf(e){return typeof e==="string"&&/^[. ]+$/.test(e)}function de(e){return!(typeof e!=="string"||e.length===0||zf(e)||e.includes("/")||e.includes("\\")||e.includes($f)||qf(e))}function Qt(e){return e.length>0&&e.every(de)}function tt(e){return ce(e).some((m)=>m.endsWith(".jsonl"))}function ce(e){let m=Lo.get(e);if(m!==void 0)return m;let P=Object.freeze(Jf(e));if(Lo.size>=Yf)Lo.clear();return Lo.set(e,P),P}function Jf(e){let m=e.toLowerCase(),P=m.indexOf(":");return P===-1?[Ui(m)]:[Ui(m),Ui(m.slice(0,P))]}var Lo=new Map,Yf=32768;function Ui(e){let m=e.length;while(m>0){let P=e.charCodeAt(m-1);if(P!==46&&P!==32)break;m-=1}return m===e.length?e:e.slice(0,m)}function Io(e,m,P){return P===void 0?e:{...e,[m]:P}}function Xf(e,m,P,J){let pe=Io({namespace:"transcript",projectKey:e,sessionId:m},"agentId",P);return Io(pe,"agentRelPath",J)}function Zf(e,m,P){let Z=Io({namespace:"log",sessionId:e,channel:m},"agentId",P?.agentId);return Io(Z,"runId",P?.runId)}var N={transcript:Xf,journal:(e,m,P)=>({namespace:"transcript",projectKey:e,sessionId:m,agentRelPath:P,journal:!0}),sessionJournal:(e,m,P)=>({namespace:"transcript",projectKey:e,sessionId:m,sessionJournal:P}),history:()=>({namespace:"history"}),log:Zf,globalConfig:()=>({namespace:"globalConfig"}),globalConfigCopy:(e,m)=>({namespace:"globalConfig",kind:e,stamp:m}),userSettings:()=>({namespace:"settings",layer:"user"}),projectSettings:(e)=>({namespace:"settings",layer:"project",projectKey:e}),localSettings:(e)=>({namespace:"settings",layer:"local",consentRootKey:e}),task:(e,m)=>({namespace:"task",listId:e,taskId:m}),taskListMeta:(e)=>({namespace:"task",listId:e,meta:!0}),taskListHighWaterMark:(e)=>({namespace:"task",listId:e,highWaterMark:!0}),memory:(e,m)=>({namespace:"memory",projectKey:e,relPath:m}),pluginRegistry:(e)=>({namespace:"pluginRegistry",file:e}),marketplaceCache:(e,m)=>({namespace:"marketplaceCache",marketplace:e,form:m}),marketplaceTree:(e,m)=>({namespace:"marketplaceCache",marketplace:e,relPath:m}),pluginCache:(e,m,P,J)=>({namespace:"pluginCache",marketplace:e,plugin:m,version:P,relPath:J}),cache:(e,m)=>({namespace:"cache",store:e,id:m}),paste:(e)=>({namespace:"paste",id:e}),state:(e)=>({namespace:"state",id:e}),pluginAssetCache:(e)=>({namespace:"pluginAssetCache",digest:e}),plan:(e)=>({namespace:"plan",name:e}),daemon:(e)=>({namespace:"daemon",relPath:e}),feedbackDraft:(e)=>({namespace:"feedbackDraft",draftId:e}),agentMemory:(e,m)=>({namespace:"agentMemory",layer:"user",agentType:e,relPath:m}),identity:()=>({namespace:"identity"}),team:(e)=>({namespace:"team",team:e}),sidecar:(e,m,P)=>({namespace:"sidecar",projectKey:e,sessionId:m,relPath:P}),mailbox:(e,m)=>({namespace:"mailbox",team:e,teammate:m}),scratch:(e,m)=>({namespace:"scratch",sessionId:e,relPath:m}),userConfigDir:(e,m)=>({namespace:"userConfigDir",dir:e,relPath:m}),fileHistory:(e,m)=>({namespace:"fileHistory",sessionId:e,backupFileName:m}),job:(e,m)=>({namespace:"job",jobId:e,relPath:m}),jobTimeline:(e)=>({namespace:"jobTimeline",jobId:e}),recording:(e,m,P)=>({namespace:"recording",projectKey:e,sessionId:m,stamp:P}),sessionLog:(e,m,P)=>({namespace:"sessionLog",projectKey:e,year:m.year,month:m.month,day:m.day,logName:P}),jobPins:()=>({namespace:"jobsRoot",file:"pins"}),jobDraft:(e)=>({namespace:"jobsRoot",draftKey:e}),session:(e)=>({namespace:"session",file:e}),bridgePointer:(e)=>({namespace:"bridgePointer",projectKey:e}),sessionAliases:(e)=>({namespace:"sessionAliases",projectKey:e}),dirSyncRecord:(e,m)=>({namespace:"dirSyncRecord",projectKey:e,sessionId:m})};async function Do(e,m,P){let J=Math.max(1,Math.floor(P?.maxPages??1e4)),Z;for(let pe=0;pe<J;pe++){if(P?.budget!==void 0){if(P.budget.pagesLeft<1)return{status:"capped"};P.budget.pagesLeft--}let fe=await e(Z);if(!fe.ok)return{status:"error",error:fe.error};if(await m(fe.value.items),P?.until?.())return{status:"done"};if(Z=fe.value.cursor,!Z)return{status:"done"}}return{status:"capped"}}var ed='"subtype":"voice_call_talk"';import{once as td}from"events";import{closeSync as Sx,constants as Jr,createWriteStream as Qf,fstatSync as yx,lstatSync as _x,openSync as bx,readSync as kx}from"fs";import{lstat as eh,open as th,lstat as xx,readdir as Yr,realpath as nh,rename as Ex,stat as rh}from"fs/promises";import{basename as oh,dirname as sh,isAbsolute as wx,join as nr}from"path";var z=65536;var ih=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function T(e){if(typeof e!=="string")return null;return ih.test(e)?e:null}function id(e){if(!e.includes("\\"))return e;try{return JSON.parse(`"${e}"`)}catch{return e}}function At(e,m){let P=[`"${m}":"`,`"${m}": "`];for(let J of P){let Z=e.indexOf(J);if(Z<0)continue;let pe=Z+J.length,fe=pe;while(fe<e.length){if(e[fe]==="\\"){fe+=2;continue}if(e[fe]==='"')return id(e.slice(pe,fe));fe++}}return}function Bn(e,m){let P=[`"${m}":"`,`"${m}": "`],J,Z=-1;for(let pe of P){let fe=0;while(!0){let ve=e.indexOf(pe,fe);if(ve<0)break;let xe=ve+pe.length,Re=xe;while(Re<e.length){if(e[Re]==="\\"){Re+=2;continue}if(e[Re]==='"'){if(ve>Z)J=id(e.slice(xe,Re)),Z=ve;break}Re++}fe=Re+1}}return J}function en(e,m,P){return Hi(e,P,m)}var ah={"custom-title":"customTitle","ai-title":"aiTitle",tag:"tag"};function Ce(e,m,P="older"){return Hi(e,ah[m],m,P)}function nd(e,m,P){try{let J=JSON.parse(e);if(typeof J==="object"&&J!==null&&(P===void 0||J.type===P)){let Z=J[m];if(typeof Z==="string")return Z}return}catch{return null}}function Hi(e,m,P,J){let Z=P===void 0?void 0:J===void 0?[`"type":"${P}"`]:[`"type":"${P}"`,`"type": "${P}"`],pe=`"${m}":`,fe=e.length;while(fe>0){let ve=e.lastIndexOf(`
|
|
47
|
+
`,fe-1),xe=e.slice(ve+1,fe);if(fe=ve,(xe.includes(pe)||J==="none")&&(Z===void 0||Z.some((Re)=>xe.includes(Re)))){let Re=nd(xe,m,P);if(Re===null&&J!==void 0){let Ae=xe.lastIndexOf(`{${Z?.[0]}`);if(Re=Ae>0&&!":,[".includes(xe.charAt(Ae-1))?nd(xe.slice(Ae),m,P):null,Re===null&&J==="none")return}if(typeof Re==="string")return Re}if(ve<0)break}return}function lh(e,m){let P=`"${m}":`,J=0;while(J<e.length){let Z=e.indexOf(`
|
|
48
|
+
`,J),pe=Z<0?e.slice(J):e.slice(J,Z);if(J=Z<0?e.length:Z+1,pe.includes(P))try{let fe=JSON.parse(pe);if(typeof fe==="object"&&fe!==null){let ve=fe[m];if(typeof ve==="string")return ve}}catch{}}return}function tn(e,m){return Hi(e,m)}function Rt(e,m){return e?.realWorkspacePath===void 0?void 0:{hoverRestOn:m,realPath:e.realWorkspacePath}}async function nn(e,m,P){return dh(e,m,"w",P)}var uh=262144;async function dh(e,m,P,J){if(J!==void 0&&J.hoverRestOn&&(P==="w"||m.length>0))return ch(J.source,m,P);let Z=Qf(e,{mode:384,flags:P});try{let pe="";for(let fe of m)if(pe+=JSON.stringify(fe)+`
|
|
49
|
+
`,pe.length>=uh){let ve=Z.write(pe);if(pe="",!ve)await td(Z,"drain")}if(pe!=="")Z.write(pe);Z.end(),await td(Z,"finish")}catch(pe){throw Z.destroy(),pe}}async function ch(e,m,P){let{backend:J,key:Z}=e,pe=m.map((ve)=>({data:JSON.stringify(ve)+`
|
|
50
|
+
`}));if(P==="w"){let ve=await J.replaceRecords(Z,pe,{publishDiscipline:"inPlace",mode:384});if(!ve.ok)throw Error("transcript stream replace failed",{cause:ve.error});return}let fe=await J.append(Z,pe);if(!fe.ok)throw Error("transcript stream append failed",{cause:fe.error})}function Kn(e,m="stored"){let P=0,J={commandFallback:""};while(P<e.length){let Z=e.indexOf(`
|
|
51
|
+
`,P),pe=Z>=0?e.slice(P,Z):e.slice(P);if(P=Z>=0?Z+1:e.length,!pe.includes('"type":"user"')&&!pe.includes('"type": "user"'))continue;if(pe.includes('"tool_result"'))continue;if(pe.includes('"isMeta":true')||pe.includes('"isMeta": true'))continue;if(pe.includes('"isCompactSummary":true')||pe.includes('"isCompactSummary": true'))continue;try{let fe=JSON.parse(pe),ve=ft(fe,J,m);if(ve!==void 0)return ve}catch{continue}}return J.commandFallback}function Gn(e){let m=0;while(m<e.length){let P=e.indexOf(`
|
|
52
|
+
`,m),J=P>=0?e.slice(m,P):e.slice(m);if(m=P>=0?P+1:e.length,!J.includes('"type":"user"')&&!J.includes('"type": "user"'))continue;if(J.includes('"tool_result"'))continue;if(J.includes('"isMeta":true')||J.includes('"isMeta": true'))continue;if(J.includes('"type":"image"')||J.includes('"type": "image"'))return"Image";if(J.includes('"type":"document"')||J.includes('"type": "document"'))return"Document"}return""}var rd=process.platform==="win32"?Jr.O_RDONLY:Jr.O_RDONLY|Jr.O_NOFOLLOW|Jr.O_NONBLOCK;async function od(e,m,P){let J=0;while(J<z){let{bytesRead:Z}=await e.read(m,J,z-J,P+J);if(Z<=0)break;J+=Z}return J}async function ph(e){let{backend:m,key:P}=e;try{let J=await m.read([{key:P,offset:0,length:z},{key:P,tail:z}]);if(!J.ok)return null;let[Z,pe]=J.value.items;if(!Z.found||Z.value.length===0)return null;let fe=sd(Z.value),ve=pe.found&&pe.value.length>0?sd(pe.value):fe;return{head:fe,tail:ve,mtimeMs:Z.mtimeMs,totalBytes:Z.totalBytes}}catch{return null}}function sd(e){return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8")}var Mx=Buffer.from('"type":"user"'),Fx=Buffer.from('"type":"assistant"'),Nx=Buffer.from(ed);function Ot(e,m){if(e.kind!=="scope"||e.scope.namespace!=="transcript"||e.scope.projectKey===void 0||e.scope.sessionId!==void 0||!m(e.scope.projectKey))return;return e.scope.projectKey}function ad(e){return{skipScopeStats:!0,skipKeyStats:!0,...e!==void 0&&{cursor:e}}}function gh(e){let m=new Map,P=new Proxy(e.backend,{get(J,Z,pe){let fe=Reflect.get(J,Z,pe);if(Z!=="listEntries")return typeof fe==="function"?fe.bind(J):fe;return(xe,Re)=>{if(!(xe.namespace==="transcript"&&!("projectKey"in xe)&&Object.keys(Re??{}).every((Be)=>Be==="cursor"||Be==="skipScopeStats"||Be==="skipKeyStats")))return J.listEntries(xe,Re);let De=[Re?.cursor??"",Re?.skipScopeStats,Re?.skipKeyStats].map(String).join("\x00"),Ke=m.get(De);if(Ke===void 0){Ke=J.listEntries(xe,Re),m.set(De,Ke);let Be=()=>{m.delete(De)};Ke.then((ot)=>{if(!ot.ok)Be()},Be)}return Ke}}});return{...e,backend:P}}async function nt(e,m){if(m!==void 0&&m.hoverRestOn)return ld(m.source);try{if(rd===Jr.O_RDONLY){if(!(await eh(e)).isFile())return null}let P=await th(e,rd);try{let J=await P.stat();if(!J.isFile())return null;let Z=Buffer.allocUnsafe(z),pe=await od(P,Z,0);if(pe===0)return null;let fe=Z.toString("utf8",0,pe),ve=Math.max(0,J.size-z),xe=fe;if(ve>0)xe=Z.toString("utf8",0,await od(P,Z,ve));return{mtime:J.mtime.getTime(),size:J.size,head:fe,tail:xe}}finally{await P.close()}}catch{return null}}async function ld(e){let m=await ph(e);if(m===null)return null;return{mtime:Math.trunc(m.mtimeMs),size:m.totalBytes,head:m.head,tail:m.tail}}var Or=200;function fh(e){return Math.abs(Gu(e)).toString(36)}function Mo(e){return e.replace(/[^a-zA-Z0-9]/g,"-")}function Xr(e){let m=Mo(e);if(m.length<=Or)return m;return`${m.slice(0,Or)}-${fh(e)}`}function I(){return nr(R(),"projects")}function Zr(e){return ml()??Xr(e)}function Bi(e){let m=Xr(e);return m===Zr(e)?void 0:m}function He(e,m=I()){return nr(m,Zr(e))}function rt(e,m){let P=oh(e);return sh(e)===I()&&m(P)?P:void 0}async function Tt(e,m){try{if(m!==void 0&&m.hoverRestOn){let P=await m.realPath(e);return _(P.ok&&P.value.found?P.value.path:e)}return _(await nh(e))}catch{return _(e)}}function hh(e,m){if(process.platform!=="win32")return[m];let P=/^([A-Za-z]):[\\/]+(.*)$/s.exec(e);if(P===null)return[m];let[,J="",Z=""]=P,pe=Z.replace(/[\\/]+$/,""),fe=pe===""?[]:pe.split(/[\\/]+/),ve=m.replace(/[\\/]+$/,"").split(/[\\/]+/),xe=ve.length-fe.length,Re=(Ae,De)=>Ae!==void 0&&De!==void 0&&Ae.length===De.length&&Ae.toLowerCase()===De.toLowerCase();if(xe<1||!fe.every((Ae,De)=>Re(Ae,ve[xe+De]))||xe===1&&Re(ve[0],`${J}:`))return[m];return[m,`${J}:\\${fe.join("\\")}`]}async function wt(e,m,P,J){let Z=J!==void 0&&J.hoverRestOn?J.source:void 0,pe=Z===void 0?void 0:rt(e,Z.isKeySegment);if(Z!==void 0&&pe!==void 0){let xe=await mh(pe,m,P,Z);if(xe!==void 0)return xe}if(g())return!1;let fe=Mo(m),ve;try{ve=await Yr(e,{withFileTypes:!0})}catch{return!1}for(let xe of ve){if(!xe.isFile()||!xe.name.endsWith(".jsonl"))continue;let Re=await nt(nr(e,xe.name));if(Re===null)continue;if(ud(Re,fe,P))return!0}return!1}function ud(e,m,P){let J=en(e.tail,"relocated","relocatedCwd")??lh(e.head,"cwd");if(J===void 0)return!1;let Z=Mo(_(J));return P?Z.toLowerCase()===m.toLowerCase():Z===m}async function mh(e,m,P,J){let{backend:Z,transcriptKey:pe,isKeySegment:fe}=J,ve=Mo(m),xe=!1,Re=new Set;try{let Ae=await Do((De)=>Z.listEntries({namespace:"transcript",projectKey:e},ad(De)),async(De)=>{for(let Ke of De){if(Ke.kind!=="key"||Ke.key.namespace!=="transcript"||Ke.key.projectKey!==e||Ke.key.agentId!==void 0||!fe(Ke.key.sessionId)||Re.has(Ke.key.sessionId))continue;let Be=Ke.key.sessionId,ot=await ld({backend:Z,key:pe(e,Be)});if(ot===null)continue;if(Re.add(Be),ud(ot,ve,P)){xe=!0;return}}},{until:()=>xe});if(xe)return!0;if(Ae.status!=="done")return}catch{return}return!1}async function ke(e,m,P=I()){if(m!==void 0&&m.hoverRestOn)return Sh(e,m);if(g())return[];let J=He(e,P),Z=[];try{await Yr(J),Z.push(J)}catch{}let pe=Bi(e);if(pe!==void 0){let De=nr(P,pe);try{await Yr(De),Z.push(De)}catch{}return Z}let fe=Xr(e);if(fe.length<=Or)return Z;let ve=process.platform==="win32",xe=(De)=>ve?De.toLowerCase():De,Re=xe(fe.slice(0,Or)+"-"),Ae=xe(J);try{for(let De of await Yr(P,{withFileTypes:!0})){if(!De.isDirectory()||!xe(De.name).startsWith(Re))continue;let Ke=nr(P,De.name);if(xe(Ke)!==Ae&&await wt(Ke,e,ve))Z.push(Ke)}}catch{}return Z}async function Sh(e,m){let P=await yh(m.source);if(P===null){let J=Bi(e);return[He(e),...J!==void 0?[nr(I(),J)]:[]]}return _h(e,P,process.platform==="win32",m)}async function yh(e){let{backend:m,isKeySegment:P}=e,J=[],Z=new Set,pe=0;try{if((await Do((ve)=>m.listEntries({namespace:"transcript"},ad(ve)),(ve)=>{for(let xe of ve){let Re=Ot(xe,P);if(Re!==void 0&&!Z.has(Re))Z.add(Re),J.push(Re)}pe++})).status==="error")return pe===0?null:J}catch{return pe===0?null:J}return J}async function _h(e,m,P,J){let Z=Zr(e),pe=He(e),fe=Bi(e),ve=fe===void 0&&Z.length>Or?Z.slice(0,Or)+"-":void 0,xe=I(),Re=(st)=>P?st.toLowerCase():st,Ae=ve!==void 0?Re(ve):void 0,De=Re(Z),Ke=!1,Be,ot=[],at=new Set;for(let st of m)if(st===Z)Ke=!0;else if(fe!==void 0){if(Be===void 0&&Re(st)===Re(fe))Be=nr(xe,st)}else if(Ae!==void 0&&Re(st).startsWith(Ae)&&Re(st)!==De&&!at.has(Re(st)))at.add(Re(st)),ot.push(st);let xt=[];for(let st of ot){let kt=nr(xe,st);if(await wt(kt,e,P,J))xt.push(kt)}return[...Ke?[pe]:[],...Be!==void 0?[Be]:[],...xt]}async function bh(e,m,P=I()){let J=[],{getWorktreePathsPortable:Z}=await import("./core-h6r54bwv.mjs");for(let pe of await Z(e)){if(pe===e)continue;let fe=await ke(pe,m,P);if(m!==void 0&&m.hoverRestOn){let ve=He(pe);if(!fe.includes(ve))fe.push(ve)}for(let ve of fe)J.push({worktreePath:pe,projectDir:ve})}return J}async function jn(...e){for await(let m of rn(...e))return m;return}async function*rn(e,m,P,J,Z=I()){let pe=`${e}.jsonl`,fe=J&&P!==void 0&&P.isKeySegment(e)?gh(P):void 0,ve=fe===void 0?void 0:{source:fe,hoverRestOn:J};async function xe(Ae,De){let Ke=nr(Ae,pe);if(fe){let Be=rt(Ae,fe.isKeySegment);if(Be!==void 0){try{let ot=await fe.backend.stat(fe.transcriptKey(Be,e));if(ot.ok){let at=ot.value.storedBytes??ot.value.size;if(at>0)return{filePath:Ke,projectPath:De,fileSize:at}}}catch{}return}}try{let Be=await rh(Ke);if(Be.size>0)return{filePath:Ke,projectPath:De,fileSize:Be.size}}catch{}return}if(m){let Ae=await Tt(m,Rt(P,J)),De=new Set;for(let Ke of hh(m,Ae))for(let Be of await ke(Ke,ve,Z)){let ot=process.platform==="win32"?Be.toLowerCase():Be;if(De.has(ot))continue;De.add(ot);let at=await xe(Be,Ke);if(at)yield at}for(let{worktreePath:Ke,projectDir:Be}of await bh(Ae,ve,Z)){let ot=await xe(Be,Ke);if(ot)yield ot}return}if(fe){let Ae=new Map;try{if((await Do((Be)=>fe.backend.listEntries({namespace:"transcript"},Be!==void 0?{cursor:Be}:void 0),(Be)=>{for(let ot of Be){let at=Ot(ot,fe.isKeySegment);if(at===void 0)continue;let xt=ot.kind==="scope"&&ot.mtimeMs!==void 0?ot.mtimeMs:Number.NEGATIVE_INFINITY,st=Ae.get(at);if(st===void 0)Ae.set(at,{projectKey:at,mtimeMs:xt});else if(xt>st.mtimeMs)st.mtimeMs=xt}})).status==="error")return}catch{return}let De=[...Ae.values()];De.sort((Ke,Be)=>Ke.mtimeMs!==Be.mtimeMs?Be.mtimeMs-Ke.mtimeMs:Ke.projectKey<Be.projectKey?-1:Ke.projectKey>Be.projectKey?1:0);for(let{projectKey:Ke}of De){let Be=await xe(nr(Z,Ke),void 0);if(Be)yield Be}return}let Re;try{Re=await Yr(Z)}catch{return}for(let Ae of Re){let De=await xe(nr(Z,Ae),void 0);if(De)yield De}}var Ux=Buffer.from('"compact_boundary"');var Hx=Buffer.from('{"type":"attribution-snapshot"'),Bx=Buffer.from('{"type":"system"'),kh=10,Kx=Buffer.from([kh]);var Wn=/^[0-9a-f]{16}(?:[0-9a-f]{48})?@v\d+$/;import{realpathSync as vh}from"fs";import{isAbsolute as xh,relative as Eh,resolve as Ch,sep as wh}from"path";function Rh(e){let m=Ch(e??"."),P;try{P=vh(m)}catch{P=m}return _(P)}function B(e,m){let P=Rh(e);if(m===void 0)return Zr(P);return(m.CLAUDE_CONFIG_DIR?si(m.CLAUDE_CODE_PROJECT_DIR_NAME):void 0)??Xr(P)}function zn(e){return typeof e==="object"&&e!==null&&"type"in e&&e.type==="agent_metadata"}function on(e,m){let P=Eh(m,e),J=P.split(wh);if(J[0]===".."||xh(P))return null;if(J.length<2)return null;let Z=J[0],pe=J[1];if(J.length===2&&pe.endsWith(".jsonl"))return{projectKey:Z,sessionId:pe.replace(/\.jsonl$/,"")};if(J.length>=4){let fe=J.slice(2),ve=fe.length-1;return fe[ve]=fe.at(-1).replace(/\.jsonl$/,""),{projectKey:Z,sessionId:pe,subpath:fe.join("/")}}return null}function ue(){return qo.of(A().host)}function sn(e){ue().invalidateAll(e)}var $n=["userSettings","projectSettings","localSettings","flagSettings","policySettings"];var Ah=["userSettings","projectSettings","localSettings"],Th=["projectSettings","localSettings"],aE=new Set(Th),Ph={userSettings:"user",projectSettings:"project",localSettings:"local"},lE=Ah.map((e)=>[Ph[e],e]);var Vn="--settings (inline JSON)",Yn=["auto","bypassPermissions"],an="organizationFreeFormSettings";
|
|
53
|
+
export{K,Zn,y,b,Q,d,ee,p,Ie,f,c,s,C,gn,mn,lt,ge,a,k,te,u,Mt,hn,D,_n,U,E,r,Ge,h,me,Sn,Nt,Pe,x,F,he,_,je,ne,re,En,V,Y,H,Le,oe,dt,Ut,Ft,ct,Ht,We,ze,_e,Bt,A,q,yn,bn,Cn,An,g,Kt,Gt,Rn,X,Qn,er,$e,se,jt,Se,Wt,Oe,On,Ve,ut,Tn,wn,pt,v,zt,ft,kn,Ye,ie,$t,Me,gt,G,mt,R,Ee,Dn,i,ht,_t,qe,xn,O,o,S,vn,L,St,Vt,j,Xe,Yt,Ne,Et,ye,Je,l,yt,qt,In,Pn,W,Te,Ze,Ue,ae,Fe,Qe,Ln,t,M,we,le,bt,et,w,n,Ct,Mn,Xt,Jt,Nn,be,Un,Zt,Fn,Hn,de,Qt,tt,ce,N,z,T,At,Bn,en,Ce,tn,Rt,nn,Kn,Gn,Ot,nt,I,He,rt,Tt,wt,ke,jn,rn,Wn,B,zn,on,ue,sn,$n,Vn,Yn,an};
|