@anthropic-ai/claude-agent-sdk
Version:
SDK for building AI agents with Claude Code's capabilities. Programmatically interact with Claude to build autonomous agents that can understand codebases, edit files, and execute workflows.
29 lines • 201 kB
JavaScript
// (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
// Version: 0.3.333
//! symbol-dispose-prelude: defines Symbol.dispose and Symbol.asyncDispose if missing, for this bundle's `using`.
if (typeof Symbol.dispose !== 'symbol') {
try {
Symbol.dispose = Symbol.for('Symbol.dispose')
} catch {}
}
if (typeof Symbol.asyncDispose !== 'symbol') {
try {
Symbol.asyncDispose = Symbol.for('Symbol.asyncDispose')
} catch {}
}
import{createRequire as Zu}from"node:module";var Ju=Object.defineProperty;var Yu=(e)=>e;function Xu(e,u){this[e]=Yu.bind(null,u)}var Te=(e,u)=>{for(var h in u)Ju(e,h,{get:u[h],enumerable:!0,configurable:!0,set:Xu.bind(u,h)})};var Lr=Zu(import.meta.url),Qu=Symbol.dispose||Symbol.for("Symbol.dispose"),ed=Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose"),E=(e,u,h)=>{if(u!=null){if(typeof u!=="object"&&typeof u!=="function")throw TypeError('Object expected to be assigned to "using" declaration');var P;if(h)P=u[ed];if(P===void 0)P=u[Qu];if(typeof P!=="function")throw TypeError("Object not disposable");e.push([h,P,u])}else if(h)e.push([h]);return u},y=(e,u,h)=>{var P=typeof SuppressedError==="function"?SuppressedError:function(V,z,ae,le){return le=Error(ae),le.name="SuppressedError",le.error=V,le.suppressed=z,le},U=(V)=>u=h?new P(V,u,"An error was suppressed during disposal"):(h=!0,V),H=(V)=>{while(V=e.pop())try{var z=V[1]&&V[1].call(V[2]);if(V[0])return Promise.resolve(z).then(H,(ae)=>(U(ae),H()))}catch(ae){U(ae)}if(h)throw u};return H()};function Ao(e){return e}function L(e){return Ao(e)}function ce(e){return Ao(e)}function qr(e){return Ao(e)}class c extends Error{telemetryMessage;errorClass;constructor(e,u,h){super(e);this.name="TelemetrySafeError",this.telemetryMessage=u??e,this.errorClass=h}}class mn extends c{}var rr=(e,u)=>{try{if(e!==null&&typeof e==="object"&&!("telemetryMessage"in e)&&Object.isExtensible(e))Object.assign(e,{telemetryMessage:u})}catch{}return e},td=["AggregateError","Error","EvalError","RangeError","ReferenceError","SuppressedError","SyntaxError","TypeError","URIError"],Zf=new Set(td);var N=(e,u)=>{try{if(e!==null&&typeof e==="object"&&Object.isExtensible(e)){let h=e,P=Object.entries(u).filter(([U,H])=>H!==void 0&&!(U in h));Object.assign(h,Object.fromEntries(P))}}catch{}return e},Qf=Symbol("telemetryChildExitStatus");function or(e){try{if(e!==null&&typeof e==="object"&&"telemetryMessage"in e&&typeof e.telemetryMessage==="string")return e.telemetryMessage}catch{}return}function W(e){return e instanceof Error?e:Error(String(e))}function b(e){return e instanceof Error?e.message:String(e)}function n(e){if(e&&typeof e==="object"&&"code"in e&&typeof e.code==="string")return e.code;return}function Qe(e){return nd(n(e))}function nd(e){return e&&/^[A-Z][A-Z0-9_]{0,63}$/.test(e)?qr(e):void 0}function rd(e){let u=e?.name;return typeof u==="string"&&/^[A-Z][a-zA-Z]{0,63}$/.test(u)?qr(u):void 0}function sr(e){return Qe(e)??rd(e)}function To(e){if(typeof e!=="string")return;return/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(e)?qr(e):L("nonconforming")}function S(e){return n(e)==="ENOENT"}function He(e){let u=n(e);return u==="ENOENT"||u==="ENOTDIR"}function Oo(e){return n(e)==="EISDIR"}function ir(e){let u=e.message&&e.name!==""?`${e.name}: ${e.message}`:e.message||e.name,h=e.stack;if(!h)return u;if(h.startsWith(u))return h;let P=h.split(`
`),U=P[0]??"",H=U===e.name||U.startsWith(`${e.name}:`)?P.slice(1):P;return[u,...H].join(`
`)}var od=new Set(["ENOENT","EACCES","EPERM","ENOTDIR","ELOOP","ENAMETOOLONG","EROFS"]);function hn(e){return sd(n(e))}function sd(e){return e!==void 0&&od.has(e)}function a(e,u){return e}var Di=globalThis.process?.getBuiltinModule?.("async_hooks"),gn=Di?(e)=>Di.AsyncResource.bind(e):(e)=>e;function d(e){if(!e)return!1;if(typeof e==="boolean")return e;let u=String(e).toLowerCase().trim();return["1","true","yes","on"].includes(u)}function ee(e){if(e===void 0)return!1;if(typeof e==="boolean")return!e;let u=String(e).toLowerCase().trim();return["0","false","no","off"].includes(u)}function m(){let e=new Set;return{subscribe(u){let h=gn(u);return e.add(h),()=>{e.delete(h)}},emit(...u){let h;for(let P of e)try{P(...u)}catch(U){(h??=[]).push(U)}if(h)throw h.length===1?h[0]:AggregateError(h,"Signal listener(s) threw")},clear(){e.clear()}}}import{appendFile as Ei,lstat as Vg,mkdir as Du,rename as Iu,stat as qg,symlink as zg,unlink as Ri}from"fs/promises";import{basename as Jg,dirname as Vn,isAbsolute as Yg,join as pn,resolve as Ku}from"path";import{createHash as Ii,randomBytes as id,randomUUID as Fe}from"crypto";function Po(e){return e}var Mi="[\\w-]{1,63}",ad=new RegExp(`^${Mi}$`);var Ah=new RegExp(`^a(?:${Mi}-)?[0-9a-f]{16}$`);function Fi(e,u){let h=Buffer.from(u.replace(/-/g,""),"hex"),P=Ii("sha1").update(h).update(Buffer.from(e,"utf8")).digest();P[6]=P[6]&15|80,P[8]=P[8]&63|128;let U=P.subarray(0,16).toString("hex");return`${U.slice(0,8)}-${U.slice(8,12)}-${U.slice(12,16)}-${U.slice(16,20)}-${U.slice(20,32)}`}var ud="3ab19d7e-9f35-45c2-926e-75e271cc60b3";function Ni(){let e=process.env.CLAUDE_CODE_REMOTE_SESSION_ID?.trim();return e?Fi(e,ud):null}function dd(){if(!d(process.env.CLAUDE_CODE_CHILD_SESSION)||Ni()===null)return!1;let e=process.argv??[],u=e.indexOf("--");return!e.slice(0,u===-1?void 0:u).some((P,U)=>P==="--sdk-url"?Boolean(e[U+1]):P.startsWith("--sdk-url=")&&P!=="--sdk-url=")&&!(e[2]==="mcp"&&e[3]==="serve")}function Ui(){return dd()&&!d(process.env.CLAUDE_CODE_DISABLE_NESTED_SESSION_ID)?null:Ni()}function Ze(e,u){let h=0;for(let P of e)h+=+!!u(P);return h}function f(e){return[...new Set(e)]}function er(e,u){let h=new Set,P=[];for(let U of e){let H=u(U);if(!h.has(H))h.add(H),P.push(U)}return P}import{basename as ji,dirname as No,join as hd}from"path";var cd;function p(){return cd===!0}class s{#e;#t;#n;#r;constructor(e){this.#e=e}of(e){if(e===this.#n&&this.#r!==void 0)return this.#r;let u=this.#t?.get(e);if(u===void 0)u=this.#e(),this.#t??=new WeakMap,this.#t.set(e,u);if(e.livesWithProcess)this.#n=e,this.#r=u;return u}}function Hi(e){return typeof e==="object"&&e!==null}function k(e,u){return pd(e,u,Object.entries,!0)}function pd(e,u,h,P){let U=[];if(!Lo(e,u,U))return!1;let H=new Map,V;while(U.length>0){let z=U.pop(),ae=U.pop(),le=H.get(ae);if(le===z)continue;if(le===void 0)H.set(ae,z);else{if(!P)return!1;V??=new Map;let Ae=V.get(ae)??new Set;if(Ae.has(z))continue;V.set(ae,Ae.add(z))}if(!gd(ae,z))return!1;let we=Object.keys(ae),Re=Object.keys(z);if(we.length===Re.length&&we.every((Ae,Ve)=>Ae===Re[Ve])){for(let Ae of we)if(!Lo(Reflect.get(ae,Ae),Reflect.get(z,Ae),U))return!1;continue}let Ie=new Map(h(z)),Me=h(ae);if(Me.length!==Ie.size)return!1;for(let[Ae,Ve]of Me)if(!Ie.has(Ae)||!Lo(Ve,Ie.get(Ae),U))return!1}return!0}function Lo(e,u,h){if(Hi(e)&&Hi(u))return h.push(e,u),!0;return e===u}function gd(e,u){if(Array.isArray(e)||Array.isArray(u))return Array.isArray(e)&&Array.isArray(u)&&e.length===u.length;return Bi(e)&&Bi(u)}function Bi(e){let u=Object.getPrototypeOf(e);return u===Object.prototype||u===null}class Do{walked=new Map;folderIsLink=new Map;managedMcp=null;clearWalk(){this.walked.clear(),this.folderIsLink.clear()}noteWalked(e,u,h){if(!this.walked.has(e)){let P=h();this.walked.set(e,P===null?null:{link:P,read:u})}}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 tr({file:e,folder:u,linked:h,posix:P}){if(!P)return"not_evaluated";if(e===void 0||u===void 0)return h?"symlinked":"unknown";if(e.uid!==0||u.uid!==0)return"not_admin_owned";let U=e.mode|u.mode;if((U&2)!==0)return"other_writable";if((U&16)!==0)return"group_writable";return h?"symlinked":"protected"}function nr({file:e,folder:u,euid:h,groups:P,posix:U}){if(!U||h===void 0)return;if(h===0)return!0;let H=[e,u].filter((z)=>z!==void 0),V=H.map((z)=>{if(z.uid===h||(z.mode&2)!==0)return!0;if((z.mode&16)===0)return!1;return z.gid===void 0?void 0:P().includes(z.gid)});if(V.includes(!0))return!0;return H.length<2||V.includes(void 0)?void 0:!1}class Io{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,u){this.documents.set(e,u)}all(){return[...this.documents]}}function Ki(){return{answers:null,computed:null,pass:Promise.resolve(),queuedFor:void 0,isAnnouncing:!1,askedOf:"",askedAbout:null,visited:[],unsettled:new Set}}class Fo{holders=0;tiers;baseline;lingering;tier(e){if(this.holders===0&&this.lingering!==void 0){let u=this.lingering();if(u===void 0)this.lingering=void 0;this.tiers=u}return this.tiers?.get(e)}engage(e,u){let h;if(this.holders===0){let U=e(),H=u?.()??U;if(this.lingering!==void 0)h={tiers:this.tiers,lingering:this.lingering},this.lingering=void 0;this.tiers=U,this.baseline=H}this.holders++;let P=!1;return{release:()=>{if(P)return{last:!1};if(P=!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(P)return;if(P=!0,this.holders--,this.holders===0)this.tiers=h?.tiers,this.lingering=h?.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 u=this.tiers,h=this.lingering;this.tiers=void 0,this.lingering=void 0;try{return e()}finally{this.tiers=u,this.lingering=h}}baselineTier(e){return this.baseline?.get(e)}differingTiers(e){return this.baseline===void 0?[]:fd(this.baseline,e)}rebaseline(e,u){if(this.baseline===void 0)return;let h=new Map(this.baseline);for(let P of u){let U=e.get(P);if(U===void 0)h.delete(P);else h.set(P,U)}this.baseline=h}linger(e,u){if(this.holders===0)this.tiers=e,this.lingering=u,this.baseline=void 0}isHeld(){return this.holders>0}}function Mo(e){return e!==null&&Object.keys(e).length===0?null:e}function Wi(e){return{...e,settings:Mo(e.settings),unfiltered:Mo(e.unfiltered),...e.legacy!==void 0&&{legacy:Mo(e.legacy)}}}function fd(e,u){return[...e.keys(),...[...u.keys()].filter((h)=>!e.has(h))].filter((h)=>{let P=e.get(h),U=u.get(h);return!k(P&&Wi(P),U&&Wi(U))})}var Bt=["forceLoginOrgUUID","forceLoginMethod","forceLoginGatewayUrl"];class de{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 Do;managedFileProtections=new Io;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;autoModeHostedSourcesWarned=new Set;changed=m();saveFailed=m();internalWrites=new Map;hookBlockedFiles=new Set;hookVerdictRuns=new Map;configChangeGate;enabledSources;inlineFlagParse;repoTierFreeze;constructor(e){this.repoTierFreeze=e?.repoTierFreeze??new Fo}hookedMerge=Ki();pluginBase;userBase={};pluginAgentSettingProvider;subagentStatusLinePluginContext;epoch=0;systemSpaceServingLogged=!1;systemAttestationContradicted=!1;backendReadResetTail=Promise.resolve();backgroundWorkTail=Promise.resolve();invalidated=m();pluginBaseLoaded=!1;primer;lastSeededUserLayer;localStoreProbes=new Gi;retained=new Map;retainedListings=new Map;noteRead(e,u,h){let P=u.settings===null?u.errors.find((U)=>U.errorClass==="unreadable"):void 0;if(P!==void 0){let U=!this.readBefore.has(e);if(!U||!this.failedAtFirstRead.has(e))this.failedRereads?.count(P,h,U);if(U)this.failedAtFirstRead.add(e);if(P.errno==="ERR_FILE_TOO_LARGE")this.lastReadSettings.delete(e);return}if(this.failedAtFirstRead.delete(e),this.keptCopiesServed.delete(e),u.settings===null)this.lastReadSettings.delete(e);else this.lastReadSettings.set(e,u.settings);if(u.loadState==="absent")this.readBefore.delete(e);else this.readBefore.add(e)}settingsAtLastRead(e){return this.lastReadSettings.get(e)}noteSaved(e,u){this.keptCopiesServed.delete(e),this.lastReadSettings.set(e,u)}forgetLastRead(e){return this.lastReadSettings.delete(e),this.keptCopiesServed.delete(e)}noteKeptCopyServed(e){this.keptCopiesServed.add(e)}noteFirstRead(e,u){if(!this.firstReadsChecked&&!this.firstReads.has(e))this.firstReads.set(e,u)}noteReadFromDisk(e,u){let h=this.hasGivenSettings.get(e);if(h===void 0||u)this.readsDisagreed||=h===!1,this.hasGivenSettings.set(e,u);else if(h)if(this.comparison===void 0)this.readsDisagreed=!0;else this.comparison.lostAFile=!0}noteFolderListed(e,u){let h=new Set(u==="failed"?[]:u);for(let U of this.hasGivenSettings.keys())if(No(U)===e&&!h.has(ji(U)))this.noteReadFromDisk(U,!1);let P=this.namesLastListed.get(e);if(P!==void 0)for(let U of h){let H=hd(e,U);if(!P.has(U)&&!this.hasGivenSettings.has(H))this.hasGivenSettings.set(H,!1)}this.namesLastListed.set(e,h),this.listingFailed||=u==="failed"}takeMisread(e){if(this.mergedSettings!==null&&!this.readsDisagreed&&!this.listingFailed)return!1;let u={lostAFile:!1};this.comparison=u;let h=this.listingFailed;this.listingFailed=!1;try{this.invalidateAll(),e()}catch(U){throw this.listingFailed||=h,U}finally{this.comparison=void 0}if(u.lostAFile)return this.invalidateAll(),!1;let P=this.readsDisagreed;if(this.readsDisagreed=!1,this.listingFailed)this.invalidateAll();return P}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,u){let h=this.rawFolderListings.get(e),P=new Set(h?.names),U=h?.common,H=U;if(u!=="failed"){let V=u==="absent"?[]:u;for(let z of V)P.add(z);H=new Set(U===void 0?V:V.filter((z)=>U.has(z)))}this.rawFolderListings.set(e,{names:P,common:H,failed:(h?.failed??!1)||u==="failed"})}rawFolderListing(e){return this.rawFolderListings.get(e)}frozenFolderMembership(e){let u=this.frozenMembership?.get(e);if(u===void 0)return;return f([...u,...this.rawFolderListings.get(e)?.names??[]]).sort()}freezeManagedFolderMembership(e){let u=new Map;for(let h of f([...this.rawFolderListings.keys(),...this.folderListings.keys(),...e.keys()]))u.set(h,f([...this.rawFolderListings.get(h)?.names??[],...this.primedFolderListing(h)??[],...e.get(h)??[]]).sort());this.frozenMembership=u,this.dropDerivedCaches("policySettings")}installRereadPolicyDocument(e,u){this.parsedFiles.set(e,u),this.noteReadFromDisk(e,u.settings!==null),this.primedFiles.delete(e),this.managedDocumentLinks.forgetWalked(e),this.dropDerivedCaches("policySettings")}noteOwnWrite(e,u){if(!this.firstReadsChecked)this.ownWritesBeforeFirstCheck.set(e,{writes:(this.ownWritesBeforeFirstCheck.get(e)?.writes??0)+1,contentHash:u})}withdrawOwnWrite(e){let u=this.ownWritesBeforeFirstCheck.get(e);if(u!==void 0&&u.writes>1)this.ownWritesBeforeFirstCheck.set(e,{...u,writes:u.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}setUserBase(e){this.userBase=e,this.mergedSettings=null}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"&&p()&&this.primer!==void 0){for(let[u,h]of this.retained)this.parsedFiles.set(u,h.parsed),this.primedFiles.add(u);for(let[u,h]of this.retainedListings)this.folderListings.set(u,h.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++}invalidateFlagSource(){this.perSource.delete("flagSettings")}onInvalidate(e){return this.invalidated.subscribe(e)}seedParsedFile(e,u,h,P){if(P!==this.epoch)return!1;let U=this.parsedFiles.get(e),H=U!==void 0&&Uo(U,h),V=!H,z=H?U:h;if(this.parsedFiles.set(e,z),this.noteRead(e,z,u==="policySettings"),u==="userSettings")this.lastSeededUserLayer={path:e,parsed:z};if(V||this.primedFiles.has(e))this.primedFiles.add(e);let ae=this.retained.get(e);if(ae!==void 0)ae.parsed=z;if(V)this.dropDerivedCaches(u);return!0}walkReadDiffers(e,u){let h=this.parsedFiles.get(e);return h!==void 0&&!this.primedFiles.has(e)&&!k(h,u)}unseedParsedFile(e,u,h){if(h!==this.epoch)return;if(this.retained.delete(e),!this.primedFiles.has(e)||u==="policySettings"&&this.policyWalks>0)return;this.primedFiles.delete(e),this.parsedFiles.delete(e),this.dropDerivedCaches(u)}dropDerivedCaches(e){if(this.perSource.delete(e),this.mergedSettings=null,e==="policySettings")this.policy={}}primedFolderListing(e){return p()?this.folderListings.get(e):void 0}folderListingForPolicyWalk(e){if(!p())return;this.policyWalks++;let u=this.folderListings.get(e);if(!this.walkedFolders.has(e)||u!==void 0)this.walkedFolders.set(e,u??null);return u}noteWalkListing(e,u){if(!p())return;this.walkedFolders.set(e,u)}get policyWalkCount(){return this.policyWalks}policyInstallVerdict(e,u,h){let P=this.parsedFiles.get(e);if(P===void 0||Uo(P,u))return"install";if(!this.primedFiles.has(e))return"raced";if(this.policyWalks===0)return"install";return this.policyWalks>h?"raced":"deferred"}folderInstallVerdict(e,u,h){if(!this.walkedFolders.has(e))return this.hasParsedDropInOutside(e,u)?"raced":"install";let P=this.walkedFolders.get(e);if(P!==null&&P!==void 0&&k(P,u))return"install";return this.policyWalks>h?"raced":"deferred"}seedFolderListing(e,u,h){if(h!==this.epoch)return!1;let P=this.folderListings.get(e);this.folderListings.set(e,u);let U=this.retainedListings.get(e);if(U!==void 0)U.names=u;if(P!==void 0&&!k(P,u))this.dropDerivedCaches("policySettings");return!0}walkReadManagedFileIn(e,u){for(let[h,P]of this.parsedFiles)if(!h.includes("\x00")&&!this.primedFiles.has(h)&&(P.settings!==null||P.errors.length>0)&&(h===e||No(h)===u))return!0;return!1}walkRead(e){return this.parsedFiles.has(e)&&!this.primedFiles.has(e)}parsedDropInNames(e){let u=[];for(let h of this.parsedFiles.keys())if(!h.includes("\x00")&&!this.primedFiles.has(h)&&No(h)===e)u.push(ji(h));return u}hasParsedDropInOutside(e,u){let h=new Set(u);return this.parsedDropInNames(e).some((P)=>!h.has(P))}clearFolderListing(e,u){if(u!==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,u){let h=this.parsedFiles.get(e),P={parsed:h!==void 0&&Uo(h,u)?h:u};return this.retained.set(e,P),()=>{if(this.retained.get(e)===P)this.retained.delete(e)}}dropRetainedLayer(e){this.retained.delete(e)}retainFolderListing(e,u){let h={names:u};return this.retainedListings.set(e,h),()=>{if(this.retainedListings.get(e)===h)this.retainedListings.delete(e)}}}class Gi{ownerUidsByRoot=new Map;realHomeDir=void 0;canonicalRootOwnerUids(e,u){let h=this.ownerUidsByRoot.get(e);if(h!==void 0)return h;let P=u(e);return this.ownerUidsByRoot.set(e,P),P}hasCanonicalRootOwnerUids(e){return this.ownerUidsByRoot.has(e)}primeCanonicalRootOwnerUids(e,u){if(this.ownerUidsByRoot.has(e))return!1;return this.ownerUidsByRoot.set(e,u),!0}clearCanonicalRootOwnerUids(){this.ownerUidsByRoot.clear()}normalizedRealHomeDir(e){return this.realHomeDir??=e(),this.realHomeDir}clearNormalizedRealHomeDir(){this.realHomeDir=void 0}}var Ho=new s(()=>new de);function Uo(e,u){return k({...e,fileOwner:void 0},{...u,fileOwner:void 0})}var md=a({value:!1},(e)=>{e.value=!1}),Sd=a({value:void 0},(e)=>{e.value=void 0}),yd=a({value:void 0},(e)=>{e.value=void 0});function zr(){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,heldRemoteDeviceTools:void 0,declaresGitStatusCheck:!1,wireShapeSeed:void 0,webSearchHistoryRejected:!1,mediaItemCap:void 0,refusedToolSchemas:new Map,systemMessagesAcceptedBy:new Set,nameOnlyEntries:{held:new Set,refused:!1,reported:void 0},toolOffers:void 0}}function _d(e,u){for(let h of u.sent)vd(e,h);for(let h of u.rejected)$i(e,h);e.wireShapeSeed=u}function Bo(e){let u=zr();if(u.declaredTools=e.declaredTools,u.noChannelTools=e.noChannelTools,u.turnDeniedTools=e.turnDeniedTools,u.declaredToolsDecided=e.declaredToolsDecided,u.leadingTools=e.leadingTools,u.advisorHeld=e.advisorHeld,u.heldRemoteDeviceTools=e.heldRemoteDeviceTools,u.declaresGitStatusCheck=e.declaresGitStatusCheck,e.wireShapeSeed!==void 0)_d(u,e.wireShapeSeed);let{rejectedHeader:h,announcementsByName:P}=e.inlineToolsRefusal;if(h!==void 0)bd(u,h);kd(u,P),u.webSearchHistoryRejected=e.webSearchHistoryRejected,u.mediaItemCap=e.mediaItemCap;for(let[U,H]of e.refusedToolSchemas)u.refusedToolSchemas.set(U,H);return u.nameOnlyEntries.refused=e.nameOnlyEntries.refused,u.nameOnlyEntries.reported=e.nameOnlyEntries.reported,u.toolOffers=e.toolOffers,u}function bd(e,u){$i(e,u),e.inlineToolsRefusal.rejectedHeader=u}function kd(e,u){for(let h of u)e.inlineToolsRefusal.announcementsByName.add(h),e.nameOnlyAnnouncements.add(h)}function vd(e,u){if(!e.rejected.has(u))e.sent.add(u)}function $i(e,u){e.sent.delete(u),e.rejected.add(u)}import{lstatSync as xd,readlinkSync as Cd,realpathSync as qi}from"node:fs";import{dirname as Ed,join as Vi,parse as Rd,resolve as wd,sep as Ad}from"node:path";import{cwd as Td}from"node:process";function zn(e){return process.platform==="darwin"?e.normalize("NFC"):e}function Od(e){if(process.platform==="linux"||e==="/")return e;return qi(e)}function Ko(){let e="";if(typeof process<"u"&&typeof process.cwd==="function"&&typeof qi==="function")try{let u=Td();try{e=zn(Od(u))}catch{e=zn(u)}}catch{}return e}var zi=Ko(),Hn=(()=>{if(typeof process>"u"||typeof process.cwd!=="function")return null;try{return process.cwd()}catch{return null}})();function Wo(){if(Hn===null)return null;let e=process.env.CLAUDE_CODE_SESSION_KIND;return e!==void 0&&String(e).trim()==="bg"?null:Hn}function Pd(e,u){let{root:h}=Rd(e),P=[],U=h,H=h;for(let V of e.slice(h.length).split(Ad).filter(Boolean)){U=Vi(U,V),H=Vi(H,V);let z=u(U);if(z!==void 0){let ae=wd(Ed(H),z);H=ae.startsWith("\\\\?\\UNC\\")?`\\\\${ae.slice(8)}`:/^\\\\\?\\[A-Za-z]:\\/.test(ae)?ae.slice(4):ae,P.push(H)}}return P}var cm=(()=>{if(Hn===null||process.platform==="linux")return Object.freeze([]);try{return Object.freeze(Pd(Hn,(e)=>{try{if(!xd(e).isSymbolicLink())return;return Cd(e)}catch{return}}))}catch{return Object.freeze([])}})();function Ji(){return Hn}var pm=Object.freeze([]);class jo{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()}}class Go{#e=zr();#t=void 0;#n;toolsUsed=void 0;stickyBetas(){return this.#e}unlatchStickyBetas(){this.#e=Bo(this.#e)}atisLatch(){return this.#t}replaceAtisLatch(e){this.#t=e,this.#n?.(e)}watchAtisLatch(e){this.#n=e}reset(){this.#e=zr(),this.#t=void 0,this.toolsUsed?.clear()}}var $o={inputTokens:0,outputTokens:0,cacheReadInputTokens:0,cacheCreationInputTokens:0};function Bn(e){let u=Object.create(null);return Object.assign(u,e)}function Yi(e){let u=Bn();for(let[h,P]of Object.entries(e))u[h]={...P};return u}class Vo{#e=0;#t=0;#n=0;#r=0;#o=Date.now();#s=void 0;#a=0;#l=0;#c=0;#d=$o;#p=0;#i=0;#g=new Map;#u=$o;#f=!1;#m=0;#h=Bn();#S=void 0;#k=null;#y=null;#_=null;spendRecorded=m();totalCostUSD(){return this.#e}restoredCostUSD(){return this.#c}restoredTokens(){return this.#d}sideQueryCostUSD(){return this.#p}modelCallCostUSD(){return this.#i}agentSpend(e){return this.#g.get(e)}totalAPIDuration(){return this.#t}totalAPIDurationWithoutRetries(){return this.#n}totalToolDuration(){return this.#r}totalDuration(){return Math.max(0,Date.now()-this.#o)}sessionStartTime(){return this.#s??this.#o}totalLinesAdded(){return this.#a}totalLinesRemoved(){return this.#l}hasUnknownModelCost(){return this.#f}safetyStops(){return this.#m}modelUsage(){return this.#h}usageForModel(e){return this.#h[e]}trackUsageSinceLastResult(){this.#S??=Bn()}usageSinceLastResult(){return this.#S}takeUsageSinceLastResult(){let e=this.#S;if(e!==void 0)this.#S=Bn();return e}totalInputTokens(){return this.#b("inputTokens")}totalOutputTokens(){return this.#b("outputTokens")}totalCacheReadInputTokens(){return this.#b("cacheReadInputTokens")}totalCacheCreationInputTokens(){return this.#b("cacheCreationInputTokens")}totalWebSearchRequests(){return this.#b("webSearchRequests")}#b(e){let u=0;for(let h of Object.values(this.#h))u+=h[e];return u}recordApiDuration(e,u){this.#t+=e,this.#n+=u}spentTokens(){return this.#u}recordSpentTokens(e){let u=this.#u;this.#u={inputTokens:u.inputTokens+e.inputTokens,outputTokens:u.outputTokens+e.outputTokens,cacheReadInputTokens:u.cacheReadInputTokens+e.cacheReadInputTokens,cacheCreationInputTokens:u.cacheCreationInputTokens+e.cacheCreationInputTokens},this.spendRecorded.emit()}recordCost(e,u,h){this.#h[h]=u,this.#e+=e,this.spendRecorded.emit()}recordSideQueryCost(e){if(Number.isFinite(e)&&e>=0)this.#p+=e,this.spendRecorded.emit()}recordModelCallCost(e){if(Number.isFinite(e)&&e>=0)this.#i+=e}replaceAgentSpend(e,u){this.#g.set(e,u)}recordToolDuration(e){this.#r+=e}recordLinesChanged(e,u){this.#a+=e,this.#l+=u}markUnknownModelCost(){this.#f=!0}recordSafetyStop(){this.#m+=1}zeroDurationsAndCostForTests(){this.#t=0,this.#n=0,this.#e=0,this.#c=0,this.#i=0}restartClock(){this.#o=Date.now(),this.anchorLogicalStart(void 0)}anchorLogicalStart(e){this.#s=e===void 0?void 0:Math.min(e,this.#o)}restore({totalCostUSD:e,totalAPIDuration:u,totalAPIDurationWithoutRetries:h,totalToolDuration:P,totalLinesAdded:U,totalLinesRemoved:H,lastDuration:V,startTime:z,modelUsage:ae,hasUnknownModelCost:le,modelCallCostUSD:we},Re){if(this.#_=Re,this.#e=e,this.#c=e,this.#t=u,this.#n=h,this.#r=P,this.#a=U,this.#l=H,this.#f=le??!1,this.#i=we??0,this.#g.clear(),ae)this.#h=Bn(ae);if(this.#d={inputTokens:this.totalInputTokens(),outputTokens:this.totalOutputTokens(),cacheReadInputTokens:this.totalCacheReadInputTokens(),cacheCreationInputTokens:this.totalCacheCreationInputTokens()},V!==void 0)this.#o=Date.now()-V;this.anchorLogicalStart(z)}registerSaver(e){this.#k=e}runSaver(e,u){(this.#k??(u?u.#k:null))?.(e)}registerTranscriptRecorder(e){this.#y=e}runTranscriptRecorder(e,u,h){(this.#y??(h?h.#y:null))?.(e,u)}snapshot(){return{ownerSessionId:this.#_,totalCostUSD:this.#e,totalAPIDuration:this.#t,totalAPIDurationWithoutRetries:this.#n,totalToolDuration:this.#r,startTime:this.#o,sessionLogicalStartTime:this.#s,totalLinesAdded:this.#a,totalLinesRemoved:this.#l,restoredCostUSD:this.#c,restoredTokens:this.#d,hasUnknownModelCost:this.#f,modelCallCostUSD:this.#i,safetyStops:this.#m,modelUsage:Yi(this.#h),agentSpend:new Map(this.#g)}}restoreSnapshot(e){this.#_=e.ownerSessionId,this.#e=e.totalCostUSD,this.#t=e.totalAPIDuration,this.#n=e.totalAPIDurationWithoutRetries,this.#r=e.totalToolDuration,this.#o=e.startTime,this.#s=e.sessionLogicalStartTime,this.#a=e.totalLinesAdded,this.#l=e.totalLinesRemoved,this.#c=e.restoredCostUSD,this.#d=e.restoredTokens,this.#f=e.hasUnknownModelCost,this.#i=e.modelCallCostUSD,this.#m=e.safetyStops,this.#h=Yi(e.modelUsage),this.#g=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.#c=0,this.#d=$o,this.#t=0,this.#n=0,this.#r=0,this.#o=Date.now(),this.anchorLogicalStart(void 0),this.#a=0,this.#l=0,this.#f=!1,this.#i=0,this.#m=0,this.#h=Bn(),this.#g.clear()}}class qo{#e=new Set;#t=new Map;openQuestion=new Map;lastSwitch=new Map;stoppedUnder=new Map;consentSessionFallback(e){return this.#e.has(e)}replaceConsentSessionFallback(e,u){if(u)this.#e.add(e);else this.#e.delete(e)}sessionConsentKey(e){return this.#t.get(e)??null}replaceSessionConsentKey(e,u){if(u===null)this.#t.delete(e);else this.#t.set(e,u)}reset(){this.#e.clear(),this.#t.clear(),this.openQuestion.clear(),this.lastSwitch.clear(),this.stoppedUnder.clear()}}class zo{#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 Jo{#e=new Map;#t=new WeakMap;skills(){return this.#e}lookup(e){return this.#e.get(e)}record(e,u){this.#e.set(e,u)}forget(e){this.#e.delete(e)}forgetUntilRecall(e,u){let h=new Map;for(let P of e){let U=this.#e.get(P);if(U!==void 0)h.set(P,U),this.#e.delete(P)}this.#t.set(u,h)}recall(e){for(let[u,h]of this.#t.get(e)??[])this.#e.set(u,h);this.#t.delete(e)}forgetAll(){this.#e.clear()}reset(){this.#e=new Map}}class Yo{#e=[];#t;#n;#r;#o;#s;mainToolsAndModel;approvedServers(){return this.#e}approveServers(e,u){for(let h of u)if(!this.#e.some((P)=>P.name===h&&P.workspaceKey===e))this.#e.push({name:h,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.#r=e}connectedClientWiring(){return this.#r}registerToolsSwapper(e){this.#o=e}acquireToolsSwapper(e){if(this.#o)return()=>{};return this.#o=e,()=>{if(this.#o===e)this.#o=void 0}}swapServerTools(e,u,h){if(!this.#o)return!1;return this.#o(e,u,h)}registerConnections(e){this.#s=e}acquireConnections(e){if(this.#s)return()=>{};return this.#s=e,()=>{if(this.#s===e)this.#s=void 0}}connections(){return this.#s}reset(){this.#e=[],this.#t=void 0}}class Xo{#e=void 0;#t=void 0;#n=void 0;#r=void 0;#o=void 0;#s=void 0;#a=void 0;#l=!1;#c=!1;#d=void 0;#p=!1;#i=void 0;#g=void 0;#u=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.#r}replaceInitialModelSettingLayer(e){this.#r=e}initialModelRequest(){return this.#o}replaceInitialModelRequest(e){this.#o=e}resolvedOrgDefault(){return this.#s}replaceResolvedOrgDefault(e){this.#s=e}initialEnvDefaultModel(){return this.#a}replaceInitialEnvDefaultModel(e){this.#a=e}refusalFallbackOccurred(){return this.#l}markRefusalFallbackOccurred(e){this.#l=!0,this.#d??=e}refusalFallbackHeaderArmed(){return this.#c}armRefusalFallbackHeader(e){this.#c=!0,this.#d??=e}refusalFallbackLatchOriginRequestId(){return this.#d}silentLaneServerArmed(){return this.#p}armSilentLaneFromServer(){this.#p=!0}forgetRefusalFallbackOccurred(){this.#l=!1,this.#c=!1,this.#p=!1,this.#d=void 0}refusalFallbackModelLatch(){return this.#i}replaceRefusalFallbackModelLatch(e,u="superseded"){if(this.#i?.carriedEffort!==void 0&&e?.carriedEffort===void 0)this.#g=u;this.#i=e}unlatchRefusalFallbackModel(e){this.replaceRefusalFallbackModelLatch(void 0,e)}takeCarriedEffortEnd(){let e=this.#g;return this.#g=void 0,e}availabilityFallbackChain(){return this.#u}replaceAvailabilityFallbackChain(e){this.#u=e}reset(){this.#e=void 0,this.#t=void 0,this.#n=void 0,this.#r=void 0,this.#o=void 0,this.#s=void 0,this.#a=void 0,this.#l=!1,this.#c=!1,this.#p=!1,this.#d=void 0,this.#i=void 0,this.#g=void 0,this.#u=void 0}}class Zo{#e=new Map;#t=0;#n=void 0;#r=void 0;#o=0;sections(){return this.#e}recordSection(e,u){this.#e.set(e,u)}forgetAllSections(){this.#e.clear(),this.#r=void 0}fillFor(e,u){if(u&&(this.#r??e)!==e)this.forgetAllSections(),this.#o+=1;this.#r??=e}fillEpoch(){return this.#t+this.#o}noteInvalidation(e="other"){this.#t+=1,this.#n=e}epoch(){return this.#t}lastInvalidationReason(){return this.#n}reset(){this.#e=new Map,this.#r=void 0}}class Qo{#e=null;#t=null;#n=null;#r=void 0;#o=null;#s=null;#a=0;#l=null;#c=void 0;#d=0;#p=void 0;#i=null;#g=null;#u=null;#f=null;#m=!1;#h=null;#S=null;#k=!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}lastAPIRequestWithheld(){return this.#r}replaceLastAPIRequestWithheld(e){if(this.#r=e,e!==void 0)this.#e=null,this.#n=null}lastClassifierRequests(){return this.#o}replaceLastClassifierRequests(e){this.#o=e}promptId(){return this.#s}replacePromptId(e){this.#s=e}promptIndex(){return this.#a}replacePromptIndex(e){this.#a=e}incrementPromptIndex(){return this.#a++,this.#a}lastPersonPrompt(){return this.#l}replaceLastPersonPrompt(e){this.#l=e}lastMainRequestId(){return this.#c}replaceLastMainRequestId(e,u){if(this.#c=e,this.#p=u,e===void 0)this.#d+=1}lastMainResponse(){return this.#p}mainChainReleaseCount(){return this.#d}lastMainThreadCacheTtlMs(){return this.#i}replaceLastMainThreadCacheTtlMs(e){this.#i=e,this.#u=Date.now(),this.#f=this.#u,this.#m=!0}adjustLastMainThreadCacheTtlMs(e){this.#i=e}recordLastMainThreadCacheRenewal(e){if(this.#u!==null)this.#g={requestAt:this.#u,at:Math.max(e,this.lastMainThreadCacheRenewedAt()??-1/0)}}lastMainThreadCacheRenewedAt(){let e=this.#g;return e!==null&&e.requestAt===this.#u?e.at:null}lastLiveMainThreadRequestAt(){return this.#f}lastMainThreadRequestAt(){return this.#u}mainThreadRequestedInProcess(){return this.#m}recordMainThreadTurnStart(){this.#m=!0}replaceLastMainThreadRequest(e,u){this.#u=e,this.#i=u}lastMainThreadContextTokens(){return this.#h}replaceLastMainThreadContextTokens(e){this.#h=e}stageResumeSeed(e){this.#y=e}applyResumeSeed(e){this.#y=null,this.#i=e.ttlMs,this.#u=e.requestAt,this.#h=e.contextTokens}#y=null;clearLastMainThreadRequest(e){let u=e!==void 0&&this.#y?.sessionId===e?this.#y:null;this.#y=null,this.#i=u?.ttlMs??null,this.#u=u?.requestAt??null,this.#h=u?.contextTokens??null,this.#f=null,this.#m=!1}lastApiCompletionTimestamp(){return this.#S}replaceLastApiCompletionTimestamp(e){this.#S=e}pendingPostCompaction(){return this.#k}replacePendingPostCompaction(e){this.#k=e}reset(){this.#e=null,this.#t=null,this.#n=null,this.#r=void 0,this.#o=null,this.#s=null,this.#a=0,this.#l=null,this.#c=void 0,this.#p=void 0,this.#d+=1,this.#i=null,this.#u=null,this.#f=null,this.#m=!1,this.#h=null,this.#y=null,this.#S=null,this.#k=!1}}class es{#e=[];#t=Object.create(null);#n=null;#r=void 0;#o=0;#s=!1;#a=0;changed=m();pendingLoopWakeup=m();tasks(){return this.#e}schedule(e){this.#e.push(e)}replaceTasks(e){this.#e=e}chainStartedAt(e){return this.#t[e]}recordChainStart(e,u){this.#t[e]=u}forgetChainStart(e){delete this.#t[e]}tickInFlightPrompt(){return this.#n}tickInFlightPlugin(){return this.#r}replaceTickInFlightPrompt(e,u){this.#n=e,this.#r=e===null?void 0:u}consecutiveKeepalives(){return this.#o}replaceConsecutiveKeepalives(e){this.#o=e}ended(){return this.#s}replaceEnded(e){this.#s=e}wakeFires(){return this.#a}recordWakeFire(){this.#a++}resetWakeFires(){this.#a=0}reset(){this.#e=[],this.#t=Object.create(null),this.#n=null,this.#r=void 0,this.#o=0,this.#s=!1,this.#a=0}}class ts{#e=!1;#t=!1;#n=!1;#r=!1;#o=!1;#s=!1;#a=!1;#l=!1;#c=!1;#d=!1;#p=!1;#i=!1;#g=void 0;#u=!1;#f=void 0;#m=!1;#h=!1;#S=null;#k=null;#y=null;#_=!1;#b=null;#v=!1;#x=!1;#E=!1;#R=!1;#C=!1;#w=void 0;#A=void 0;#P=void 0;#T=void 0;#O=null;#L=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.#r}replaceHomeTrustDialogAccepted(e){this.#r=e}hasExitedPlanMode(){return this.#o}replaceHasExitedPlanMode(e){this.#o=e}hasLeftPlanMode(){return this.#s}noteLeftPlanMode(){this.#s=!0}needsPlanModeExitAttachment(){return this.#a}replaceNeedsPlanModeExitAttachment(e){this.#a=e}needsAutoModeExitAttachment(){return this.#l}replaceNeedsAutoModeExitAttachment(e){this.#l=e}memoryToggledOff(){return this.#c}replaceMemoryToggledOff(e){this.#c=e}autoMemoryOffThisSession(){return this.#d}replaceAutoMemoryOffThisSession(e){this.#d=e}memoryPausedByCommand(){return this.#i}replaceMemoryPausedByCommand(e){this.#i=e}accountMemorySessionMode(){return this.#g}replaceAccountMemorySessionMode(e,u=!1){this.#g=e,this.#u=u&&e!==void 0}accountMemorySessionModeRestored(){return this.#u}accountMemoryLaunchMode(){return this.#f}replaceAccountMemoryLaunchMode(e){this.#f=e}restoredMemoryPause(){return this.#m}replaceRestoredMemoryPause(e){this.#m=e}restoredAutoMemoryOff(){return this.#p}replaceRestoredAutoMemoryOff(e){this.#p=e}teardownUnwindRequested(){return this.#_}replaceTeardownUnwindRequested(e){this.#_=e}backgroundAutoModeSetupInFlight(){return this.#h}replaceBackgroundAutoModeSetupInFlight(e){this.#h=e}deferredToolStubGateLatch(){return this.#S}replaceDeferredToolStubGateLatch(e){this.#S=e}verifySkillRolloutGateLatch(){return this.#k}replaceVerifySkillRolloutGateLatch(e){this.#k=e}commitSkillRolloutGateLatch(){return this.#y}replaceCommitSkillRolloutGateLatch(e){this.#y=e}memoryToolsShapeLatch(){return this.#b}replaceMemoryToolsShapeLatch(e){this.#b=e}proposeGoalAvailabilityLogged(){return this.#v}markProposeGoalAvailabilityLogged(){this.#v=!0}activeRoutine(){return this.#P}replaceActiveRoutine(e){this.#P=e}inheritedTeamName(){return this.#T}replaceInheritedTeamName(e){this.#T=e}teleportedSessionInfo(){return this.#O}replaceTeleportedSessionInfo(e){this.#O=e}markFirstTeleportMessageLogged(){if(this.#O)this.#O.hasLoggedFirstMessage=!0}cachedClaudeMdContent(){return this.#L}replaceCachedClaudeMdContent(e){this.#L=e}accountSkillsSyncEnabled(){return this.#x}replaceAccountSkillsSyncEnabled(e){this.#x=e}skillsSyncVetoed(){return this.#E}replaceSkillsSyncVetoed(e){this.#E=e}accountPluginsSyncEnabled(){return this.#R}replaceAccountPluginsSyncEnabled(e){this.#R=e}pluginsSyncVetoed(){return this.#C}replacePluginsSyncVetoed(e){this.#C=e}armPendingContextCompacted(e,u){this.#w=e,this.#A=u}consumePendingContextCompacted(){let e=this.#w;return this.#w=void 0,e}forgetPendingContextCompacted(){this.#w=void 0,this.#A=void 0}responseBeforeCompaction(){return this.#A}forgetResponseBeforeCompaction(){this.#A=void 0}reset(){this.#x=!1,this.#E=!1,this.#R=!1,this.#C=!1,this.#e=!1,this.#t=!1,this.#n=!1,this.#r=!1,this.#o=!1,this.#s=!1,this.#a=!1,this.#l=!1,this.#c=!1,this.#d=!1,this.#i=!1,this.#g=void 0,this.#u=!1,this.#f=void 0,this.#m=!1,this.#p=!1,this.#_=!1,this.#h=!1,this.#S=null,this.#k=null,this.#y=null,this.#b=null,this.#v=!1,this.#P=void 0,this.#T=void 0,this.#O=null,this.#L=null,this.#w=void 0,this.#A=void 0}}function Xi(){return{messagesArriving:0,lastInLine:Promise.resolve(),gaveUpOn:void 0,besideLine:0,lastBesideLine:Promise.resolve(),gaveUpOnBeside:void 0,pathsArrivingBeside:new Map,toolCallsWaiting:0,afterToolCallWait:void 0,pathsArriving:new Map,messagesInLine:[]}}class ns{#e=new Map;#t=new Map;#n=null;#r=new Map;#o=new Set;#s=new Set;#a=new Set;#l=new Set;#c=new Set;#d=new Set;#p=new Set;#i=new Set;#g=new Set;#u=new Map;#f=new Map;#m=new Map;#h;#S={byFileUuid:new Map,recentPrefetchStarts:[]};#k=Xi();#y=new Set;#_=void 0;#b=void 0;#v=void 0;#x=void 0;#E=void 0;#R=void 0;#C=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.#r}sessionCreatedTeams(){return this.#o}sessionSpawnedTeammatePanes(){return this.#s}surfacedHookSpawnFailures(){return this.#a}pendingConversationEditKinds(){return this.#l}clientTruncatedAssistantIds(){return this.#c}heldStatelessReplyIds(){return this.#d}unsupportedThreadKeys(){return this.#p}pendingPrLinks(){return this.#i}policyPredicateTelemetryEmitted(){return this.#g}humanAttachmentDigests(){return this.#u}inboundAttachmentFiles(){return this.#f}filesPlacedByName(){return this.#m}filesPlacedByNameRead(){return this.#h}setFilesPlacedByNameRead(e){this.#h=e}inboundAttachmentDownloads(){return this.#S}arrivingInboundFiles(){return this.#k}chromeAvailabilityStagesLogged(){return this.#y}replaceChromeAvailabilityStagesLogged(e){if(this.#y=new Set,e)this.#_=Date.now()}chromeAvailabilityAnchorMs(){return this.#_}pendingGoalIdleCheckin(){return this.#b}replacePendingGoalIdleCheckin(e){this.#b=e}pendingGoalReprompt(){return this.#v}replacePendingGoalReprompt(e){this.#v=e}goalInterruptionStreak(){return this.#x}replaceGoalInterruptionStreak(e){this.#x=e}workerCheckin(){return this.#E}replaceWorkerCheckin(e){this.#E=e}earlierSessionIds(e){return this.#R?.sessionId===e?this.#R.ids:[]}sessionIdsHandedOnFrom(e){return this.#C.has(e)?[]:[...this.earlierSessionIds(e),e]}replaceEarlierSessionIds(e,u,h){if(this.#R={sessionId:e,ids:u},h)this.#C.delete(e);else this.#C.add(e)}reset(){this.#e=new Map,this.#t=new Map,this.#n=null,this.#r=new Map,this.#o=new Set,this.#s=new Set,this.#a=new Set,this.#l=new Set,this.#c=new Set,this.#d=new Set,this.#p=new Set,this.#i=new Set,this.#g=new Set,this.#u=new Map,this.#f=new Map,this.#m=new Map,this.#h=void 0;for(let e of this.#S.byFileUuid.values())clearTimeout(e.expiry),e.abort.abort(),e.modelCopy?.abort.abort();for(let e of this.#S.originalsStillDownloading?.keys()??[])e.abort();this.#S={byFileUuid:new Map,recentPrefetchStarts:[]},this.#k=Xi(),this.#y=new Set,this.#_=void 0,clearTimeout(this.#b),this.#b=void 0,clearTimeout(this.#v),this.#v=void 0,this.#x=void 0,clearInterval(this.#E?.timer),this.#E=void 0,this.#R=void 0,this.#C.clear()}}var Zi={workspace:"local",canDrive:!0,transcriptSource:"local-jsonl",remote:null};class rs{#e=!1;#t=void 0;#n=void 0;#r=void 0;#o=void 0;#s=void 0;#a=void 0;#l=null;#c=!1;#d={keep:"none"};#p=void 0;#i=Zi;#g=!1;#u=new Set;#f="idle";#m=null;attachedClientCapabilitiesChanged=m();rvSupervisorLinkChanged=m();programStatusViewersChanged=m();cloudCwdChanged=m();sdkDialogHostActive(){return this.#e}markSdkDialogHostActive(e){this.#e=e}sdkSupportedDialogKinds(){return this.#t}sdkSupportedDialogKindsSource(){return this.#n}declareDialogKinds(e,u){this.#t=e,this.#n=e===void 0?void 0:u}sdkPerTaskStopAffordance(){return this.#r}declarePerTaskStopAffordance(e){this.#r=e}sdkRapidFollowupPreempt(){return this.#o}declareRapidFollowupPreempt(e){this.#o=e}sdkForwardNestedSubagentToolCalls(){return this.#s}declareForwardNestedSubagentToolCalls(e){this.#s=e}hostRendersChromeSetupOffer(){return this.#a}declareHostRendersChromeSetupOffer(e){this.#a=e}attachedClientCapabilities(){return this.#l}replaceAttachedClientCapabilities(e){this.#l=e,this.attachedClientCapabilitiesChanged.emit()}rvSupervisorLinkLive(){return this.#c}replaceRvSupervisorLinkLive(e){if(this.#c===e)return;if(this.#c=e,this.rvSupervisorLinkChanged.emit(),!e)this.replaceProgramStatusViewers({keep:"none"})}programStatusViewers(){return this.#d}replaceProgramStatusViewers(e){this.#d=e,this.programStatusViewersChanged.emit()}sdkBetas(){return this.#p}replaceSdkBetas(e){this.#p=e}caps(){return this.#i}replaceCaps(e){this.#i=e}markRemote(e){this.#i={...this.#i,workspace:e?"remote":"local"}}cloudCwdOfSession(e){return this.#i.workspace==="remote"&&this.#m?.sessionId===e?this.#m.cwd:null}replaceCloudCwd(e){this.#m=e,this.cloudCwdChanged.emit()}replBridgeActive(){return this.#g}replaceReplBridgeActive(e){if(this.#g===e)return;this.#g=e}replBridgeConnecting(){return this.#u.size>0}trackReplBridgeEnable(e){this.#u.add(e),e.finally(()=>this.#u.delete(e)).catch(()=>{})}mainLoopBusy(){return this.#f!=="idle"}mainQueryRunning(){return this.#f==="running"}replaceMainLoopStatus(e){this.#f=e}reset(){this.#e=!1,this.#t=void 0,this.#n=void 0,this.#r=void 0,this.#o=void 0,this.#s=void 0,this.#a=void 0,this.#l=null,this.#p=void 0,this.#i=Zi,this.#g=!1,this.#u.clear(),this.#f="idle",this.#c=!1,this.#d={keep:"none"},this.#m=null,this.attachedClientCapabilitiesChanged.clear(),this.rvSupervisorLinkChanged.clear(),this.programStatusViewersChanged.clear(),this.cloudCwdChanged.clear()}}var Qi=150,Ld=60000;class os{#e=Date.now();#t=!1;#n=!1;#r=0;#o=-1/0;#s=-1/0;#a=!1;interactionFired=m();#l=void 0;terminalFocusFired=m();#c=!1;#d;lastInteractionTime(){return this.#e}hasInteracted(){return this.#t}lastSubmitTime(){return this.#r}recordSubmit(){this.#r=Date.now()}personWroteAt(){return this.#o}notePersonWrote(){this.#o=performance.now(),this.notePersonIsHere()}notePersonIsHere(){this.#s=performance.now(),this.#a=!1}nobodyIsHere(){return this.#a}noteWhoseTurn(e){this.#a=e&&performance.now()-this.#s>=Ld}isRemoteDriven=!1;recordInteraction(e){if(e)this.#p();else this.#n=!0}flushIfDirty(){if(this.#n)this.#p()}#p(){this.#e=Date.now(),this.#t=!0,this.#n=!1,this.interactionFired.emit()}resetBaseline(){this.#e=Date.now(),this.#n=!1}terminalFocus(){return this.#l}updateTerminalFocus(e){this.#l=e,this.terminalFocusFired.emit()}scrollDraining(){return this.#c}markScrollActivity(){if(this.#c=!0,this.#d)clearTimeout(this.#d);this.#d=setTimeout(()=>{this.#c=!1,this.#d=void 0},Qi),this.#d.unref?.()}async waitForScrollIdle(){while(this.#c)await new Promise((e)=>setTimeout(e,Qi))}reset(){this.#e=Date.now(),this.#t=!1,this.#r=0,this.#o=-1/0,this.#s=-1/0,this.#a=!1,this.#l=void 0,this.interactionFired.clear(),this.terminalFocusFired.clear()}}var Dd=["sdk_single_prompt_gate","subagent_estimate","subagent_final_turn","rows_unreadable"],Id=8;class ss{byAgent=new Map;attemptsByAgent=new Map;cappedFailuresByAgent=new Map;armGateEventEmitted=new Set;vetoedUnderPrompt=new Map;sidecarIo=Promise.resolve();rehydrateAttemptedSessions=new Set;sidecarReadsAhead=new Map;keptSummaryLoader;reachesNextWorker;setKeptSummaryLoader(e){this.keptSummaryLoader=e}takeKeptSummaryLoader(){let e=this.keptSummaryLoader;return this.keptSummaryLoader=void 0,e}setSummaryReachesNextWorker(e){this.reachesNextWorker=e}summaryReachesNextWorker(){return this.reachesNextWorker?.()===!0}get(e){return this.byAgent.get(e)}has(e){return this.byAgent.has(e)}put(e,u){this.byAgent.set(e,u)}remove(e){this.byAgent.delete(e)}nextAttemptNumber(e){let u=(this.attemptsByAgent.get(e)??0)+1;return this.attemptsByAgent.set(e,u),u}consecutiveCountedFailures(e){return this.cappedFailuresByAgent.get(e)??0}recordCountedFailure(e){let u=(this.cappedFailuresByAgent.get(e)??0)+1;return this.cappedFailuresByAgent.set(e,u),u}clearCountedFailures(e){this.cappedFailuresByAgent.delete(e)}recordVeto(e,u){this.vetoedUnderPrompt.set(e,u)}isVetoedUnder(e,u){return this.vetoedUnderPrompt.get(e)===u}latchArmGateEvent(e){if(this.armGateEventEmitted.has(e))return!1;return this.armGateEventEmitted.add(e),!0}enqueueSidecarIo(e,u){return this.sidecarIo=this.sidecarIo.then(e,e).catch(u),this.sidecarIo}sidecarIoSettled(){return this.sidecarIo}hasAttemptedRehydrate(e){return this.rehydrateAttemptedSessions.has(e)}markRehydrateAttempted(e){this.rehydrateAttemptedSessions.add(e)}keepSidecarReadAhead(e,u){this.sidecarReadsAhead.delete(e);while(this.sidecarReadsAhead.size>=Id){let h=this.sidecarReadsAhead.keys().next().value;if(h===void 0)break;this.sidecarReadsAhead.delete(h)}this.sidecarReadsAhead.set(e,u)}takeSidecarReadAhead(e){let u=this.sidecarReadsAhead.get(e);return this.sidecarReadsAhead.delete(e),u}dropSidecarReadAhead(e){this.sidecarReadsAhead.delete(e)}forgetSubagentTelemetry(e){this.attemptsByAgent.delete(e),this.cappedFailuresByAgent.delete(e),this.vetoedUnderPrompt.delete(e);for(let u of Dd)this.armGateEventEmitted.delete(`${e}:${u}`)}}class is{#e=void 0;get current(){return this.#e}adopt(e){this.#e=e}}class as{#e=null;#t=null;mainAgentId(e){return this.#e??=Po(e),this.#e}projectDir(){return this.#t}replaceProjectDir(e){this.#t=e}}class ls{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 us{granted=!1;isGranted(){return this.granted}grant(){this.granted=!0}}class ds{inFlight=null;startedForTurnEnd=!1;reset(){this.inFlight?.abort(),this.inFlight=null,this.startedForTurnEnd=!1}}class cs{relay=null;firstSyncPromise=null;lastRoundNoChanges=void 0;accountListing="pending";isRelistFutile=!1;requiredOwed=!1;registeredAhead=new Set;syncErrors=[];requiredNotLanded=new Set;lastRoundListed=!1;lastListAskedAt;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,sweptAhead:0,longWaitSpent:!1};settingsInstall={current:null,next:null,asked:0,broughtIn:0,loaded:null};requiredAlone=!1;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 ps{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 gs{#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 fs{autonomousPreambleDelivered=!1;lastLoopFileDelivered=null;reset(){this.autonomousPreambleDelivered=!1,this.lastLoopFileDelivered=null}}class hs{exchanges=[];replace(e){this.exchanges=e}append(e,u,h,P,U){this.exchanges=[...this.exchanges,{question:e,response:u,...h&&{fallbackNotice:h},...P&&{agentId:P},...U&&{madeOn:U}}].slice(-20)}pendingReopen=null;reopenAway=!1;get reopenPending(){return this.pendingReopen!==null}armReopen(e,u){if(this.pendingReopen){this.pendingReopen.owners.add(e);return}this.pendingReopen={owners:new Set([e]),cancel:u()}}clearPendingReopen(e){let u=this.pendingReopen;if(!u){this.reopenAway=!1;return}if(e!==void 0){if(u.owners.delete(e),u.owners.size>0)return}u.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((u)=>u!==e)}}import{lstatSync as xa,readFileSync as qd,readlinkSync as Os,realpath as gS,realpathSync as Ca,statSync as ua}from"fs";import{readlink as zd}from"fs/promises";class ea{port=null}var Md=new ea;function Wt(){return Md.port}function Fd(e,u){return e.value===!u&&e.source==="payload"&&e.defaultHost?!u:u}function M(e,u){let h=Wt();if(!h)return u;try{return Fd(h.protectionRead(e,u),u)}catch{return u}}class Jr{now(){return Date.now()}monotonicNow(){return performance.now()}setTimeout(e,u,h){let P=setTimeout(e,u);if(h?.unref)P.unref();return()=>clearTimeout(P)}}var et=new Jr;function I(e,u,h){return new Promise((P,U)=>{if(u?.aborted){if(h?.throwOnAbort||h?.abortError)U(h.abortError?.()??Error("aborted"));else P();return}let H=(h?.clock??et).setTimeout(()=>{u?.removeEventListener("abort",V),P()},e,{unref:h?.unref});function V(){if(H(),h?.throwOnAbort||h?.abortError)U(h.abortError?.()??Error("aborted"));else P()}u?.addEventListener("abort",V,{once:!0})})}function Nd(e,u){e(Error(u))}function K(e,u,h){let P,U=new Promise((H,V)=>{P=setTimeout(Nd,u,V,h)});return Promise.race([e,U]).finally(()=>{if(P!==void 0)clearTimeout(P)})}var Ud=(e,u)=>{let h=setTimeout(e,u);return()=>clearTimeout(h)};function ue(e,u,h=Ud){let P=()=>{},U=new Promise((H)=>{P=h(()=>H(void 0),u)});return Promise.race([e,U]).finally(P)}function Yr(e){let u=e.indexOf("."),h=u===-1?e.length:u;while(h>0&&e.charCodeAt(h-1)===32)h--;return/^(con|prn|aux|nul|com[0-9¹²³]|lpt[0-9¹²³])$/i.test(e.slice(0,h))}function ta(e){let u=e.length;for(let P of[".",":"]){let U=e.indexOf(P);if(U!==-1&&U<u)u=U}let h=e.slice(0,u);return Yr(h)||/^con(?:in|out)\$ *$/i.test(h)}import{homedir as Ea}from"os";import{basename as Jd,dirname as rn,isAbsolute as un,join as Cs,parse as an,relative as Es,resolve as pt,sep as dt}from"path";import*as to from"path";var Hd="\\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}",oa=`[\\p{M}\\uFF9E\\uFF9F${Hd}]`,Bd=new RegExp(`${oa}{32,}`,"gu"),Kd=new RegExp(oa,"u");var ms=new Map,Kn=[],Ss={NFD:new Map,NFKD:new Map};function Xr(e,u){return e!==u&&(e+u).normalize("NFD")===u+e}function sa(e){let u=ms.get(e);if(u!==void 0)return u;let h=String.fromCodePoint(e),P=null;if(h==="̴"||Xr(h,"̴")||Xr("ͅ",h)){let U=0,H=Kn.length;while(U<H&&P===null){let V=U+H>>1,z=Kn[V];if(Xr(h,z.sample))U=V+1;else if(Xr(z.sample,h))H=V;else P=z}if(P===null){P={order:U,sample:h},Kn.splice(U,0,P);for(let V=U+1;V<Kn.length;V++)Kn[V].order=V}}return ms.set(e,P),P}function ia(e,u){let h=Ss[u].get(e);if(h===void 0)h=Array.from(String.fromCodePoint(e).normalize(u),(P)=>P.codePointAt(0)),Ss[u].set(e,h);return h}var na=4096;function Wd(e,u){let h="";for(let P=0;P<u;P+=na)h+=String.fromCodePoint(...e.subarray(P,Math.min(P+na,u)));return h}function jd(e,u){let h=new Int32Array(e.length+16),P=0;for(let z=0;z<e.length;){let ae=e.codePointAt(z);z+=ae>65535?2:1;for(let le of ia(ae,u)){if(P===h.length){let we=new Int32Array(h.length*2);we.set(h),h=we}h[P++]=le,sa(le)}}let U=new Int16Array(P);for(let z=0;z<P;z++)U[z]=ms.get(h[z])?.order??-1;let H=h.slice(0,P),V=new Int32Array(Kn.length);for(let z=0;z<P;){let ae=z,le=!0;while(ae<P&&U[ae]>=0)le&&=ae===z||U[ae-1]<=U[ae],ae++;if(le){z=ae+1;continue}V.fill(0);for(let Re=z;Re<ae;Re++)V[U[Re]]++;let we=z;for(let Re=0;Re<V.length;Re++){let Ie=V[Re];V[Re]=we,we+=Ie}for(let Re=z;Re<ae;Re++)H[V[U[Re]]++]=h[Re];z=ae}return Wd(H,P)}function Gd(e,u){return e.length<32?e:e.replace(Bd,(h)=>jd(h,u))}var ra=128;function aa(e,u){if(e<768)return!0;let h=Ss[u].get(e);if(h===void 0&&!Kd.test(String.fromCodePoint(e)))return!0;return sa((h??ia(e,u))[0])===null}function $d(e,u,h){let P=u;if(P<e.length&&(e.charCodeAt(P)&64512)===56320&&(e.charCodeAt(P-1)&64512)===55296)P++;while(P<e.length){let U=e.codePointAt(P);if(aa(U,h))break;P+=U>65535?2:1}return Math.min(P,e.length)}function Vd(e,u){let h=e.length;while(h>0){if(h--,h>0&&(e.charCodeAt(h)&64512)===56320&&(e.charCodeAt(h-1)&64512)===55296)h--;if(aa(e.codePointAt(h),u))return h}return 0}function la(e,u){if(typeof Buffer<"u"&&Buffer.byteLength(e)===e.length)return e;let h=u==="NFC"||u==="NFD"?"NFD":"NFKD",P=Gd(e,h);if(P.length<=ra)return P.normalize(u);let U=[],H="";for(let V=0;V<P.length;){let z=$d(P,V+ra,h),ae=(H+P.slice(V,z)).normalize(u),le=z===P.length?ae.length:Vd(ae,h);U.push(ae.slice(0,le)),H=ae.slice(le),V=z}return U.join("")}function ys(e){return la(e,"NFKC")}function Be(e){return la(e,"NFC")}function _(e){return process.platform==="darwin"?Be(e.valueOf()):e}function Dt(e){return/^[\\/]{2}/.test(e)||oo(e)}function ft(e){return/(^|[\\/])\.\.([\\/]|$)/.test(e)}var Yd=/^\/(?:dev\/fd|proc\/(?:self|thread-self|\d+)(?:\/task\/\d+)?\/(?:root|cwd|exe|fd|map_files))(?:\/|$)/i;function Ra(e){return Yd.test(e)}function Ps(e){return/^[\\/]\?\?[\\/]/.test(e)}function da(e){if(/^[\\/]{2}[?.][\\/](?!unc[\\/])/i.test(e))return null;return e.match(/^[\\/]{2}(?:[?.][\\/]unc[\\/])?([^\\/]+)/i)?.[1]?.replace(/[A-Z]/g,(u)=>u.toLowerCase())??null}function Pt(e){return/(^|[\\/])\.{1,2}[. ]*([\\/]|$)/.test(e)}function pe(e){return/^[\\/]{2}[?.][\\/]/.test(e)}function fe(e){if(!/\/\.(?:vol|file|nofollow|resolve)(?:\/|$)/i.test(e))return!1;if(!e.startsWith("/"))return!1;let u=[];for(let h of e.split("/")){if(h===""||h===".")continue;if(h===".."){u.pop();continue}if(u.push(h),u.length===1&&/^\.(?:vol|file|nofollow|resolve)$/i.test(h))return!0}return!1}function wa(e){return/^[\\/](GLOBAL\?\?|GLOBALROOT|DosDevices|Device)[\\/]/i.test(e)}function Aa(e,u){if(!Dt(e))return!1;if(pe(e)||oo(e))return!0;if(Pt(e))return!0;let h=da(e);return h===null||h!==da(u)}function Ta(e){return e.length===2&&e[0]!==void 0&&_s(e[0])==="net"||e.length===3&&e[0]!==void 0&&e[1]!==void 0&&_s(e[0])==="network"&&_s(e[1])==="servers"}function Xn(e){if(process.platform==="win32"||!e.startsWith("/"))return null;let u=[];for(let h of e.split("/")){if(h===""||h===".")continue;if(h===".."){u.pop();continue}if(u.push(h),Ta(u))return eo(h)}return null}function eo(e){return e.replace(/[A-Z]/g,(u)=>u.toLowerCase())}function _s(e){return e.replace(/[\u200c-\u200f\u202a-\u202e\u206a-\u206f\ufeff]/g,"").toUpperCase().toLowerCase()}function Ls(e,u){if(fe(e))return!0;if(It(e)){let h=Xn(e);if(h===null||h!==Xn(u))return!0}return Xd(e,u)}function Xd(e,u,h=process.platform,P=h==="darwin"&&(process.platform!=="darwin"||Oa())){if(h!=="darwin"||!ec(e,h,P))return!1;let U=Rs(u,h,P).complete[0]??null,{complete:H,partial:V}=Rs(e,h,P);if(H.length===0&&V.length===0)return!0;if(U===null)return!0;return H.some((z)=>z!==U)||V.some((z)=>!U.startsWith(z))}var bs=a({value:void 0},(e)=>{e.value=void 0});function Oa(e=ca){let u=e===ca;if(u&&bs.value!==void 0)return bs.value;let h;try{let P=!1;try{P=e.readAutoMaster().split(`
`).some((U)=>{let H=U.replace(/#.*$/,"").trim().split(/\s+/);return H.length>=2&&H[0]!==void 0&&H[0].toLowerCase()==="/home"})}catch(U){if(!S(U))throw U}h=P||e.homeIsOwnMount()}catch{return!0}if(u)bs.value=h;return h}var ca={readAutoMaster:()=>qd("/etc/auto_master","utf8"),homeIsOwnMount:()=>{let e;try{e=ua("/home")}catch(u){if(S(u))return!0;throw u}return e.dev!==ua("/Users").dev}},Zd=6;function Rs(e,u,h){let P=[],U=[];if(!e.startsWith("/"))return{complete:P,partial:U};let H=[];for(let V of e.split("/")){if(V===""||V===".")continue;if(V===".."){H.pop();continue}if(H.push(V),H.length>Zd)continue;let z="/"+H.join("/"),le=(u==="darwin"?Ka(z):z).split("/").filter((Re)=>Re!==""),we=le[0]?.toLowerCase();if(we==="network"){if(le.length===1)U.push("/network/");else if(le.length===2&&le[1]!==void 0)U.push(`/network/${eo(le[1])}/`);else if(le.length===3&&le[1]!==void 0&&le[2]!==void 0)P.push(`/network/${eo(le[1])}/${eo(le[2])}`)}else if(h&&we==="home"&&le.length===2)P.push(`/home/${le[1]}`)}return{complete:P,partial:U}}function It(e){if(process.platform==="win32")return!1;return Y(e)}function ar(e){return Dt(e)||It(e)||Zn(e)||fe(e)}function Y(e){return ro(e)!==null}var Pa=1024,La=4096,Zr=new Map,Qr=new Map;function ro(e){if(!e.startsWith("/"))return null;if(e.length>La)return pa(e);let u=Zr.get(e);if(u===void 0){if(u=pa(e),Zr.size>=Pa)Zr.clear();Zr.set(e,u)}return u}function pa(e){let u=[];for(let h of e.split("/")){if(h===""||h===".")continue;if(h===".."){u.pop();continue}if(u.push(h),Ta(u))return"/"+u.join("/")}return null}function dn(e){if(!e.startsWith("/"))return!1;let u=[];for(let h of e.split("/")){if(h===""||h===".")continue;if(h===".."){u.pop();continue}u.push(h)}return u.length===1&&u[0]!==void 0&&u[0].toLowerCase()==="net"}function on(e){if(!e.startsWith("/"))return!1;if(e.length>La)return ga(e);let u=Qr.get(e);if(u===void 0){if(u=ga(e),Qr.size>=Pa)Qr.clear();Qr.set(e,u)}return u}function ga(e){let u=[];for(let h of e.split("/")){if(h===""||h===".")continue;if(h===".."){u.pop();continue}if(u.push(h),u.length===1&&u[0]!==void 0&&u[0].toLowerCase()==="network")return!0}return!1}function Zn(e){if(process.platform!=="darwin")return!1;return on(e)}function Qd(e){return Y(e)||dn(e)||on(e)||fe(e)}function ec(e,u=process.platform,h=u==="darwin"&&(process.platform!=="darwin"||Oa())){if(u!=="darwin")return!1;if(on(e)||fe(e))return!0;if(!e.startsWith("/"))return!1;let{complete:P,partial:U}=Rs(e,u,h);if(U.length>0)return!0;if(P.some((V)=>V.startsWith("/network/")))return!0;let H=P.filter((V)=>V.startsWith("/home/"));if(H.length>0){let V=tc();if(H.some((z)=>z!==V))return!0}return!1}function tc(){let e;try{e=Ea()}catch{return null}let u=/^\/home\/([^/]+)/.exec(Ka(e));return u?`/home/${u[1]}`:null}function ge(e){return nc(e)||on(e)}function nc(e){return gt(e)||Y(e)||dn(e)||pe(e)||oo(e)||wa(e)||fe(e)}function q(e){let u=/^[\\/]{2}wsl(?:\$|\.localhost)[\\/]([^\\/]*)/i.exec(e);return u!==null&&!/^\.{0,2}[. ]*$/.test(u[1]??"")}function gt(e){return Dt(e)&&!q(e)}function me(e){if(e.startsWith("\\\\?\\UNC\\"))return"\\\\"+e.slice(8);if(e.startsWith("\\\\?\\")&&e.length>=7&&e[5]===":")return e.slice(4);return e}function Da(e){if(/^\\\\\?\\volume\{/i.test(e))return fa(e);if(oo(e))return!0;let u=me(e);if(u!==e&&fa(u))return!0;return Dt(u)&&!q(u)}function fa(e){return Pt(e)||e.includes("/")}function We(e){try{return me(Ca.native(e))}catch{return null}}var Ia=new Set(["EPERM","EBUSY","EACCES"]),Ds=4,Is=50,CS=Is*(Ds-1),ha;function jn(e){return cc(e).real??null}function _n(e,u,h){let P=rn(pt(e)).toLowerCase(),U=pt(u).toLowerCase();if(ma(P,U,"lexical")||ks(P,U,"lexical"))return!0;if(rc(e,h))return!0;let H=jn(rn(pt(e)))?.toLowerCase();if(H!=null&&ge(H)&&Wa(an(pt(e)).root))return!0;let V=jn(u)?.toLowerCase();if(V==null)return H!=null&&ks(H,void 0,"canonical");if(H==null)return!0;return ma(H,V,"canonical")||ks(H,V,"canonical")}function rc(e,u){let h=pt(e);if(Sn(rn(h)))return!1;let P=!1;if(u!==void 0)P=u?.isSymbolicLink()===!0;else{let U=Gn(()=>xa(h));if(U.value===void 0)return U.code!=="ENOENT"&&U.code!=="ENOTDIR";P=U.value.isSymbolicLink()}return P&&uc(h)}function Sn(e){return Ua().includes(pt(e).toLowerCase())}function ma(e,u,h){return e===u||Ma(e,u)||ic(e,u,h)}var oc=new Set(["node_modules",".venv","venv","env",".env","virtualenv",".tox",".nox",".direnv","__pypackages__"]);function Ma(e,u){if(!e.startsWith(no(u)+dt))return!1;return Fa(e)}function Fa(e){return e.split(dt).some((u)=>oc.has(u))}var sc="tengu_valiant_sparrow";function ks(e,u,h){if(!Fa(e))return!1;let P=Ji(),U=P===null?void 0:(h==="lexical"?pt(P):jn(P))?.toLowerCase();return[U,Sa(U),Sa(u)].some((H)=>H!==void 0&&(e===H||Ma(e,H)))&&M(sc,!0)}function Sa(e){let u=e?.indexOf(`${dt}.claude${dt}worktrees${dt}`)??-1;return u<0?void 0:e?.slice(0,u)}function no(e){return e.endsWith(dt)?e.slice(0,-1):e}var vs;function ic(e,u,h){let{rawHome:P,rawLocal:U}=Na();if(h==="lexical")return xs(Ua(),e,u);let H=P+"\x00"+U;if(vs?.key===H)return xs(vs.aliasDirs,e,u);let V=!0,z=Ha(P,U,(ae)=>{if(!Ba(ae))return pt(ae).toLowerCase();let le=jn(ae)?.toLowerCase();if(le==null)return V=!1,pt(ae).toLowerCase();return le});if(V)vs={key:H,aliasDirs:z};return xs(z,e,u)}function Na(){let e=(process.env.LOCALAPPDATA??"").trim();return{rawHome:Ea(),rawLocal:e}}function Ua(){let{rawHome:e,rawLocal:u}=Na();return Ha(e,u,(h)=>pt(h).toLowerCase())}function Ha(e,u,h){let P=[];if(e)P.push(no(h(e))+dt+["appdata","local","microsoft","windowsapps"].join(dt));if(u){let U=no(h(u))+dt+["microsoft","windowsapps"].join(dt);if(!P.includes(U))P.push(U)}return P}function Ba(e){return process.platform==="win32"?ac(e):e.startsWith("/")&&!Dt(e)}function ac(e){return/^[A-Za-z]:[\\/](?![\\/])/.test(e)}function xs(e,u,h){let P=no(h);for(let U of e){if(!(U===P||U.startsWith(P+dt)))continue;if(u===U||u.startsWith(U+dt))return!0}return!1}var lc=["usr/local","usr/libexec/cups","usr/share/snmp","AppleInternal","Applications","Library","Users","Volumes","cores","home","media","mnt","opt","pkg","private","sw"];function Ka(e){let u=e.split("/");if(u.length<5||u[0]!==""||Jn(u[1]??"")!=="system"||Jn(u[2]??"")!=="volumes"||Jn(u[3]??"")!=="data")return e;let h=u.slice(4);for(let P of lc){let U=P.split("/");if(h.length<U.length)continue;if(U.every((H,V)=>Jn(h[V]??"")===Jn(H)))return"/"+h.join("/")}return e}function Jn(e){return e.toUpperCase().toLowerCase()}function mt(e){if(process.platform!=="win32")return!1;let u=tt(e);return q(u)&&!Pt(u)}function ws(e){return process.platform==="win32"?e.replace(/^([\\/]{2})wsl\$(?=[\\/])/i,"$1wsl.localhost"):e}var En=/^\/mnt\/[a-z](?:\/|$)/i;function As(e){let u=tt(e);return mc(u)||Qd(u)||wa(u)}function ya(e,{allowLocalWsl:u=!1,eisdirIsFolder:h=!1,report:P,singleTry:U=!1}={}){let H=tt(e);if(!un(H))return!0;if(P!==void 0)P.chain=[],P.metLink=!1,P.endedMissing=!1;let{root:V}=an(H);return Wn(V,ln(H.slice(V.length)),0,u,{eisdirIsFolder:h,report:P,singleTry:U})}function uc(e,u=rn(e)){let h=Gn(()=>Os(e));if(h.value===void 0)return h.code!=="ENOENT"&&h.code!=="EINVAL";let P=process.platform==="win32"?h.value:h.value.replace(/^\/{2,}/,"/");if(ja(P))return!0;let U=process.platform==="win32"&&/^[\\/](?![\\/])/.test(P);if(U&&Pt(P))return!0;let H=U?Cs(an(u).root,P):P,V={trustedStart:!0,trustedRoot:u};if(un(H)){let le=Es(u,H);if(!Pt(H)&&le!==""&&!ba(le)&&!un(le))return Wn(u,ln(le),1,!1,V);return As(H)||Kt(H)}if(As(H))return!0;let z=Es(u,rn(e)),ae=!ba(z)&&!un(z);return Wn(ae?u:rn(e),[...ae?ln(z):[],...ln(H)],1,!1,V)}function Kt(e,u={}){return ya(e,u)||Pt(e)&&ya(pt(e),u)}var _a=40;function Wa(e){let u=jn(e);return u!==null&&!Ms(u)}function ln(e){return e.split(process.platform==="win32"?/[\\/]+/:/\/+/).filter(Boolean)}var dc=3;function Yn(e,u){return As(e)&&!(u&&mt(e))}function ba(e){return e===".."||/^\.\.[\\/]/.test(e)}function ja(e){return process.platform==="win32"&&/^[A-Za-z]:(?![\\/])/.test(e)}function Wn(e,u,h,P,{trustedStart:U=!1,trustedRoot:H=e,eisdirIsFolder:V=!1,report:z,singleTry:ae=!1}={}){let le=(Je)=>{if(z!==void 0)z.unclassifiable=Je??"UNKNOWN";return!0},we=(Je,Pe)=>{z?.chain?.push({path:Je,dev:Pe.dev,ino:Pe.ino})},Re=()=>{if(z!==void 0)z.metLink=!0},Ie=H.endsWith(dt)?H:H+dt,Me=(Je)=>U&&(Je===H||Je.startsWith(Ie)),Ae=e;if(!Me(Ae)&&Yn(Ae,P))return!0;let Ve;for(let[Je,Pe]of u.entries()){if(Pe===".")continue;if(Pe===".."){Ae=rn(Ae);continue}let Ue=Cs(Ae,Pe);if(!Me(Ue)&&Yn(Ue,P))return!0;let Oe=(ae?Ts:Gn)(()=>xa(Ue,{bigint:!0}));if(Oe.value===void 0){if(Oe.code!=="ENOENT"&&Oe.code!=="ENOTDIR")return le(Oe.code);if(z!==void 0)z.endedMissing=!0;let Ye=u.slice(Je+1);if(process.platform!=="win32"&&!Ue.includes("??")&&!Ye.some((ct)=>ct.includes("??"))){let{root:ct}=an(Ue),Lt=ln(Ue.slice(ct.length));for(let Ft of Ye){if(Ft==="..")Lt.pop();else if(Ft!==".")Lt.push(Ft);if(Yn(ct+Lt.slice(0,dc).join(dt),P)&&!Me(ct+Lt.join(dt)))return!0}return!1}let Le=Ue;for(let ct of Ye)if(Le=ct===".."?rn(Le):ct==="."?Le:Cs(Le,ct),!Me(Le)&&Yn(Le,P))return!0;return!1}let xt;if(Oe.value.isSymbolicLink()){if(Re(),h>=_a)return!0;let Ye=(ae?Ts:Gn)(()=>Os(Ue));if(xt=Ye.value,xt===void 0)return le(Ye.code)}else if(process.platform==="win32"&&Oe.value.isDirectory()){let Ye=fc(Ue,ae);if(Ye.kind==="junction"){if(Re(),h>=_a)return!0;xt=Ye.target}else if(Ye.kind==="directory"){we(Ue,Oe.value),Ae=Ue;continue}else if(V!==!1&&Ye.kind==="error"&&Ye.code==="EISDIR"&&(mt(Ue)?P&&V==="onAnyDrive":Ve??=V==="onAnyDrive"?Ba(an(Ue).root):Wa(an(Ue).root))){we(Ue,Oe.value),Ae=Ue;continue}else return le(Ye.kind==="absent"?"ENOENT":Ye.code)}else{if(Oe.value.isDirectory())we(Ue,Oe.value);Ae=Ue;continue}let Xe=process.platform==="win32"?xt:xt.replace(/^\/{2,}/,"/");if(!(U&&un(Xe)&&!Pt(Xe)&&Me(Xe))&&Yn(Xe,P))return!0;let Mt=u.slice(Je+1);if(ja(Xe))return!0;if(un(Xe)){if(U&&!Pt(Xe)&&Me(Xe))return Wn(H,[...ln(Xe.slice(Ie.length)),...Mt],h+1,P,{trustedStart:!0,trustedRoot:H,eisdirIsFolder:V,report:z,singleTry:ae});let Ye=an(Xe).root,Le=process.platform==="win32"&&/^[\\/]$/.test(Ye)?an(Ae).root:Ye;return Wn(Le,[...ln(Xe.slice(Ye.length)),...Mt],h+1,P,{eisdirIsFolder:V,report:z,singleTry:ae})}return Wn(Ae,[...ln(Xe),...Mt],h+1,P,{trustedStart:Me(Ae),trustedRoot:H,eisdirIsFolder:V,report:z,singleTry:ae})}return!1}function cc(e){let u=Gn(()=>me(Ca.native(e)));return{real:u.value,code:u.code}}function Qn(e){return e!=null&&typeof e==="object"&&"code"in e&&typeof e.code==="string"?e.code:void 0}function Gn(e){try{return{value:pc(e)}}catch(u){return{code:Qn(u)}}}function Ts(e){try{return{value:e()}}catch(u){return{code:Qn(u)}}}function pc(e){return gc(e,()=>!0)}function gc(e,u){for(let h=0;;h++)try{return e()}catch(P){let U=Qn(P);if(U===void 0||process.platform!=="win32"||!Ia.has(U)||h>=Ds-1||!u())throw P;ha??=new Int32Array(new SharedArrayBuffer(4)),Atomics.wait(ha,0,0,Is)}}function Ga(e){let u=Qn(e);return u==="EINVAL"?{kind:"directory"}:u==="ENOENT"?{kind:"absent"}:{kind:"error",code:u,error:e}}function fc(e,u=!1){let h,P=(u?Ts:Gn)(()=>{try{return Os(e)}catch(U){throw h=U,U}});return P.value!==void 0?{kind:"junction",target:P.value}:Ga(h)}async function ht(e){let u,h=await hc(async()=>{try{return await zd(e)}catch(P){throw u=P,P}});return h.value!==void 0?{kind:"junction",target:h.value}:Ga(u)}async function hc(e){for(let u=0;;u++)try{return{value:await e()}}catch(h){let P=Qn(h);if(P===void 0||process.platform!=="win32"||!Ia.has(P)||u>=Ds-1)return{code:P};await I(Is)}}function mc(e){return Ms(e)||Y(e)}function Sc(e){return Pt(e)||/[. :](?=[\\/]|$)/.test(e)||e.split(/[\\/]/).some((u)=>Yr(u)||Yr(u.slice(0,Math.max(0,u.indexOf(":")))))}function tt(e){let u=(process.platform==="win32"?/^(?:[\\/][\\/][?.][\\/]|[\\/]\?\?[\\/])(?=[A-Za-z]:[\\/])/:/^(?:\\\\[?.]\\|\\\?\?\\)(?=[A-Za-z]:[\\/])/).exec(e);if(!u)return e;let h=e.slice(u[0].length),P=h.slice(2);return u[0].includes("\\")&&P.includes("/")||Sc(P)?e:h}function yc(e,u){let h=Be(ws(pt(ws(e))));return u?h.toLowerCase():h}function ka(e,{foldCase:u,knownNotSuspect:h=!1,eisdirIsFolder:P}={}){if(u??=process.platform==="darwin"||process.platform==="win32",e=tt(e),Ms(e)||Y(e))return yc(e,u);if(!h&&Kt(un(e)?e:pt(e),{eisdirIsFolder:P})){let ae=Be(pt(e));return u?ae.toLowerCase():ae}let U=pt(e),H=[],V=We(U);while(V===null&&rn(U)!==U)H.unshift(Jd(U)),U=rn(U),V=We(U);V=H.length>0?pt(V??U,...H):V??U;let z=Be(ws(V));return u?z.toLowerCase():z}function _t(e,u,{alreadyComparable:h=!1,foldCase:P}={}){let U=Es(h?e:ka(e,{foldCase:P}),h?u:ka(u,{foldCase:P}));return U===""||!un(U)&&U!==".."&&!U.startsWith(`..${dt}`)}function Ms(e){return Dt(e)}function oo(e){return va.test(e)||e.includes("??")&&va.test(_c(e))}var va=/^[\\/]\?\?[\\/]/;function _c(e){return to.win32?to.win32.normalize(e):e}var bc=16;class Fs{pending=null;shownThisSession=!1;changed=m();submitted=[];submittedChanged=m();subscribe=this.changed.subscribe;getSnapshot=()=>this.pending;subscribeSubmitted=this.submittedChanged.subscribe;submit(e){if(this.shownThisSession)return;if(this.submitted.length>=bc)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 kc=Symbol("permission-stash-evicted");class Ns{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,u=1048576){this.entriesCap=e;this.evictedKeysCap=u}stash(e,u,h,P="write"){if(e===void 0)return;let U=this.lanes[P],H=this.evicted[P],V=so(e,u);if(H.has(V))return;let z=U.get(V);if(z!==void 0){let ae=new Set(h);U.set(V,z.filter((le)=>ae.has(le)));return}if(U.size>=this.entriesCap){let ae=U.keys().next().value;if(ae!==void 0){if(U.delete(ae),H.add(ae),H.size>this.evictedKeysCap){this.poisoned[P]=!0;let le=H.values().next().value;if(le!==void 0)H.delete(le)}}}U.set(V,h)}holds(e,u,h="write"){return e!==void 0&&this.lanes[h].has(so(e,u))}spellings(e,u){let h=so(e,u);return this.lanes.write.get(h)??this.lanes.read.get(h)}stashIdentity(e,u,h){if(e===void 0)return;let P=this.identities.get(e),U=P?.get(u);if(P!==void 0&&U!==void 0){if(U===null||h===null||U.dev!==h.dev||U.ino!==h.ino)P.set(u,null);return}let H=this.identitiesEvicted.has(e)||this.identitiesPoisoned;if(P===void 0){if(!H&&this.identities.size>=this.entriesCap){let V=this.identities.keys().next().value;if(V!==void 0){if(this.identities.delete(V),this.identitiesEvicted.add(V),this.identitiesEvicted.size>this.evictedKeysCap){this.identitiesPoisoned=!0;let z=this.identitiesEvicted.values().next().value;if(z!==void 0)this.identitiesEvicted.delete(z)}}}P=new Map,this.identities.set(e,P)}P.set(u,H?null:h)}takeIdentity(e,u){if(e===void 0)return;let h=this.identities.get(e),P=h?.get(u);if(h?.delete(u)&&h.size===0)this.identities.delete(e);return P}consume(e,u,h="write"){if(e===void 0)return;let P=this.lanes[h],U=so(e,u),H=P.get(U),V=H===void 0&&(this.evicted[h].delete(U)||this.poisoned[h]),z=`${e}\x00`;for(let ae of P.keys())if(ae.startsWith(z))P.delete(ae);if(h==="read")this.identities.delete(e),this.identitiesEvicted.delete(e);if(V)return kc;return H}}function so(e,u){return`${e}\x00${u}`}var vc="NoProjectDirectoryError",$a=new s(()=>({}));var Va=()=>{};function qa(e){Va=e}class St extends Error{name=vc;constructor(){super("This session has no working directory.");try{Va(this)}catch{}}}function io(e){let{project:u}=e;if(u===null)throw new St;return u}function za(e){return Ja({kind:"root",host:e.host,id:e.id,parentId:e.parentId,livesWithProcess:e.livesWithProcess===!0},e.project,e.project?.isolationRoot)}function ao(e,u){let h=u.originalCwd??e?.originalCwd,P=u.projectRoot??e?.projectRoot,U=u.cwd??e?.cwd;if(h===void 0&&P===void 0&&U===void 0)return null;if(h===void 0||P===void 0||U===void 0)throw new St;return{originalCwd:_(h),projectRoot:_(P),cwd:_(U)}}function Ja(e,u,h){let P={project:u===null?null:ao(null,u)},U=h,H=m(),V=e.kind==="fork"?e.root.observers:new jo,z=e.kind==="fork"?e.root.autonomousLoopPreamble:new fs,ae=e.kind==="fork"?e.root.precompute:new ss,le={get originalCwd(){return io(P).originalCwd},get projectRoot(){return io(P).projectRoot},get cwd(){return io(P).cwd},get isolationRoot(){return U}},we={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:we},livesWithProcess:e.kind==="root"&&e.livesWithProcess,get project(){return P.project===null?null:le},observers:V,autonomousLoopPreamble:z,btwHistory:e.kind==="fork"?e.root.btwHistory:new hs,ccrRecap:e.kind==="fork"?e.root.ccrRecap:new ds,conversationLatches:e.kind==="fork"?e.root.conversationLatches:new Go,costLedger:e.kind==="fork"?e.root.costLedger:new Vo,engineStore:e.kind==="fork"?e.root.engineStore:new is,usageCreditsOnlyModelConsentSlots:e.kind==="fork"?e.root.usageCreditsOnlyModelConsentSlots:new qo,hookRegistry:e.kind==="fork"?e.root.hookRegistry:new zo,identity:e.kind==="fork"?e.root.identity:new as,invokedSkills:e.kind==="fork"?e.root.invokedSkills:new Jo,mcpSessionWiring:e.kind==="fork"?e.root.mcpSessionWiring:new Yo,modelSelection:e.kind==="fork"?e.root.modelSelection:new Xo,promptAssembly:e.kind==="fork"?e.root.promptAssembly:new Zo,promptSuggestion:e.kind==="fork"?e.root.promptSuggestion:new ps,pendingHint:e.kind==="fork"?e.root.pendingHint:new Fs,pluginsSync:e.kind==="fork"?e.root.pluginsSync:new cs,precompute:ae,requestJournal:e.kind==="fork"?e.root.requestJournal:new Qo,sessionCron:e.kind==="fork"?e.root.sessionCron:new es,sessionFlags:e.kind==="fork"?e.root.sessionFlags:new ts,sessionRefsGate:e.kind==="fork"?e.root.sessionRefsGate:new gs,sessionScratch:e.kind==="fork"?e.root.sessionScratch:new ns,surfaceCapabilities:e.kind==="fork"?e.root.surfaceCapabilities:new rs,userPresence:e.kind==="fork"?e.root.userPresence:new os,workflowUsageConsent:e.kind==="fork"?e.root.workflowUsageConsent:new us,outsideReadPrompt:e.kind==="fork"?e.root.outsideReadPrompt:new ls,writePermissionStash:e.kind==="fork"?e.root.writePermissionStash:new Ns,subscribe(Re){let Ie=H.subscribe(Re);if(e.kind!=="fork")return Ie;let Me=e.root,{id:Ae,parentId:Ve}=Me,Je=Me.subscribe(()=>{if(Me.id===Ae&&Me.parentId===Ve)return;Ae=Me.id,Ve=Me.parentId,Re()});return()=>{Ie(),Je()}},setCwd(Re){we.update({project:{cwd:Re}})},setIsolationRoot(Re){if(Re!==U)U=Re,H.emit()},withProject(Re){return Ja({kind:"fork",root:we.root},ao(P.project,Re),Re.isolationRoot??U)},update(Re){let Ie=Re.project===void 0?P.project:Re.project===null?null:ao(P.project,Re.project),Me=!1;if(Re.id!==void 0||"parentId"in Re){if(e.kind==="fork")throw Error("A withProject fork cannot re-identify the session — update the root session instead");if(Re.id!==void 0&&Re.id!==e.id)e.id=Re.id,Me=!0;if("parentId"in Re&&Re.parentId!==e.parentId)e.parentId=Re.parentId,Me=!0}if(Ie?.originalCwd!==P.project?.originalCwd||Ie?.projectRoot!==P.project?.projectRoot||Ie?.cwd!==P.project?.cwd)P.project=Ie,Me=!0;let Ae=Re.project?.isolationRoot;if(Ae!==void 0&&Ae!==U)U=Ae,Me=!0;if(Me)H.emit()}};return we}class te{#e;#t;#n;#r;constructor(e){this.#e=e}peek(e){let u=e.root;return this.#t?.get(u)}of(e){if(e===this.#n&&this.#r!==void 0)return this.#r;let u=e.root,h=this.#t?.get(u);if(h===void 0)h=this.#e(),this.#t??=new WeakMap,this.#t.set(u,h);if(u.livesWithProcess)this.#n=u,this.#r=h;return h}drop(e){let u=e.root;if(this.#t?.delete(u),u===this.#n)this.#n=void 0,this.#r=void 0}}var Us={isDiskless:()=>!1,isDisklessProcess:()=>!1,reportBuilt:()=>{}};function Ya(e){Us=e}function lo(){return Us.isDiskless()}function Hs(){return Us.isDisklessProcess()}var xc="NoConfigHomeError";function yn(e){try{return typeof e==="object"&&e!==null&&"name"in e&&e.name===xc}catch{return!1}}class Bs{#e=!1;#t=!1;#n=!1;#r=void 0;#o=null;#s=!1;#a=void 0;#l=!1;#c=!1;#d=!1;#p=!1;#i=void 0;#g=!1;#u=!1;#f="";#m=null;#h=null;#S=new Map;#k="cli";#y="fresh";#_=void 0;#b=!1;#v=!1;#x=[];#E=!1;#R=!1;#C=!1;#w=new Set;#A=!1;#P=!1;#T=!1;#O=!1;#L=!1;#N="none";#D=!1;#U=!1;#I=!1;#H=!1;#M=!1;#B=void 0;#K=void 0;#W=void 0;#F=!1;#j=!1;#G=!1;#$=void 0;#V=void 0;#J=void 0;#Y=void 0;#X=!1;#Z=!1;#Q=!1;#ee=!1;#te=!1;#ne=void 0;#re=!1;#oe=!1;#se=!1;#ie=null;#ae=null;#le=!0;#ue=null;#q=!1;#Ee=m();#de=null;#ce=!1;#pe=!1;#ge=!1;#fe={};#he=void 0;#me=null;#Se="none";#ye=!1;#_e=!1;#be=!1;#ke=void 0;#z=new Set;#ve=!1;#xe=void 0;#Ce={};isInteractive(){return this.#e}isInteractivityDecided(){return this.#t}isNoDialogLaunch(){return this.#n}markNoDialogLaunch(){this.#n=!0}classicHooksLeaveOut(){return this.#r}leaveOutOfClassicHooks(e){this.#r=e}replaceIsInteractive(e){this.#e=e,this.#t=!0}printOutputFormat(){return this.#o}replacePrintOutputFormat(e){this.#o=e}thinkingDisplayExplicit(){return this.#s}replaceThinkingDisplayExplicit(e){this.#s=e}permissionPromptToolName(){return this.#a}replacePermissionPromptToolName(e){this.#a=e}hasStreamingInput(){return this.#l}replaceHasStreamingInput(e){this.#l=e}singleShotPrintSession(){return this.#c}replaceSingleShotPrintSession(e){this.#c=e}printInputClosed(){return this.#d}markPrintInputClosed(){this.#d=!0}modelOverrideOptOutForSession(){return this.#p}replaceModelOverrideOptOutForSession(e){this.#p=e}rendererMode(){return this.#i}replaceRendererMode(e){this.#i=e}strictToolResultPairing(){return this.#g}replaceStrictToolResultPairing(e){this.#g=e}restrictedSession(){return this.#u}replaceRestrictedSession(e){this.#u=e}antLaunchKind(){return this.#f}replaceAntLaunchKind(e){this.#f=e}workspaceRestrictionState(){return this.#m}replaceWorkspaceRestrictionState(e){this.#m=e}replaceWorkspaceRestrictionUnsubscribe(e){this.#h?.(),this.#h=e}restrictedWorkspaceRoots(){return this.#S}addRestrictedWorkspaceRoot(e,u){this.#S.set(e,u)}clearRestrictedWorkspaceRoots(){this.#S=new Map}clientType(){return this.#k}replaceClientType(e){this.#k=e}sessionStartType(){return this.#y}replaceSessionStartType(e){this.#y=e}questionPreviewFormat(){return this.#_}replaceQuestionPreviewFormat(e){this.#_=e}extendedQuestionsEnabled(){return this.#b}replaceExtendedQuestionsEnabled(e){this.#b=e}questionOptionDescriptionsOptional(){return this.#v}replaceQuestionOptionDescriptionsOptional(e){this.#v=e}replConfigArgv(){return this.#x}replaceReplConfigArgv(e){this.#x=e}userMsgOptIn(){return this.#E}replaceUserMsgOptIn(e){this.#E=e}searchToolsOptIn(){return this.#R}replaceSearchToolsOptIn(e){this.#R=e}todoToolsOptIn(){return this.#C}replaceTodoToolsOptIn(e){this.#C=e}toolsOmittedByLaunchList(){return this.#w}replaceToolsOmittedByLaunchList(e){this.#w=e}wizardOperatorToolsEnabled(){return this.#A}replaceWizardOperatorToolsEnabled(e){this.#A=e}runnerDeclaredNestedRepositoryDiff(){return this.#P}replaceRunnerDeclaredNestedRepositoryDiff(e){this.#P=e}runnerDeclaredNoRepositoryCheckedOut(){return this.#T}replaceRunnerDeclaredNoRepositoryCheckedOut(e){this.#T=e}runnerDeclaredFreshMachinePerSession(){return this.#O}replaceRunnerDeclaredFreshMachinePerSession(e){this.#O=e}runnerDeclaredBuiltInGh(){return this.#L}replaceRunnerDeclaredBuiltInGh(e){this.#L=e}pollEventIngress(){return this.#N}markPollEventIngress(e){this.#N=e}ownEventDeliveryRequested(){return this.#D&&!this.#U}replaceOwnEventDeliveryHeld(e){this.#U=e}markOwnEventDeliveryRequested(){this.#D=!0}sdkAgentProgressSummariesEnabled(){return this.#I}replaceSdkAgentProgressSummariesEnabled(e){this.#I=e}sessionPersistenceDisabled(){return this.#H}replaceSessionPersistenceDisabled(e){this.#H=e}diskless(){return this.#M}replaceDiskless(e){this.#M=e}ccrSessionUrl(){return this.#B}replaceCcrSessionUrl(e){this.#B=e}ccrDerivedSurface(){return this.#K}replaceCcrDerivedSurface(e){this.#K=e}ccrClaudeCodeSurface(){return this.#W}replaceCcrClaudeCodeSurface(e){this.#W=e}desktopAppHostsTenant(){return this.#F}replaceDesktopAppHostsTenant(e){this.#F=e}autoCompactWindowSurface(){return this.#V}replaceAutoCompactWindowSurface(e){this.#V=e}wrapUpOffered(){return this.#j}replaceWrapUpOffered(e){this.#j=e}wrapUpFromPhone(){return this.#G}replaceWrapUpFromPhone(e){this.#G=e}entrypointOnRequests(){return this.#$}replaceEntrypointOnRequests(e){this.#$=e}coworkEnrollment(){return this.#J}replaceCoworkEnrollment(e){this.#J=e}chatConversationUuid(){return this.#Y}replaceChatConversationUuid(e){this.#Y=e}ccrSessionLimited(){return this.#X}replaceCcrSessionLimited(e){this.#X=e}ccrBlockLimitShowsCard(){return this.#Z}replaceCcrBlockLimitShowsCard(e){this.#Z=e}ccrRunByService(){return this.#Q}replaceCcrRunByService(e){this.#Q=e}toolsMayBeOnHost(){return this.#ee}replaceToolsMayBeOnHost(e){this.#ee=e}toolsConfirmedOnHost(){return this.#te}replaceToolsConfirmedOnHost(e){this.#te=e}toolsMachine(){return this.#ne}replaceToolsMachine(e){this.#ne=e}sessionBypassPermissionsMode(){return this.#re}replaceSessionBypassPermissionsMode(e){this.#re=e}disableSlashCommands(){return this.#oe}replaceDisableSlashCommands(e){this.#oe=e}disableFileMentions(){return this.#se}replaceDisableFileMentions(e){this.#se=e}sessionUploadsDir(){return this.#ie}replaceSessionUploadsDir(e){this.#ie=e}localUploadsRoot(){return this.#ae}replaceLocalUploadsRoot(e){this.#ae=e}mayForwardHomeSettings(){return this.#le}replaceMayForwardHomeSettings(e){this.#le=e}homeSettingsHostConsent(){return this.#ue}replaceHomeSettingsHostConsent(e){this.#ue=e}scheduledTasksEnabled(){return this.#q}replaceScheduledTasksEnabled(e){let u=e&&!this.#q;if(this.#q=e,u)this.#Ee.emit()}onScheduledTasksEnabled(e){return this.#Ee.subscribe(e)}initJsonSchema(){return this.#de}replaceInitJsonSchema(e){this.#de=e}cliSessionConfigCarried(){return this.#ce}replaceCliSessionConfigCarried(e){this.#ce=e}cloudLaunchCarriesOnlyModel(){return this.#pe}replaceCloudLaunchCarriesOnlyModel(e){this.#pe=e}forkRestrictedLaunchConfig(){return this.#ge}replaceForkRestrictedLaunchConfig(e){this.#ge=e}forkReplayLaunchConfig(){return this.#fe}spareClaimState(){return this.#Se}replaceSpareClaimState(e){this.#Se=e}spareRelocated(){return this.#ye}replaceSpareRelocated(e){this.#ye=e}leavesStartingFolderAlone(){return this.#_e}markLeavesStartingFolderAlone(){this.#_e=!0}runsSubcommand(){return this.#be}markRunsSubcommand(){this.#be=!0}spareHeldSettingsAgent(){return this.#ke}replaceSpareHeldSettingsAgent(e){this.#ke=e}spareHeldPluginIds(){return this.#z}spareHeldRequiredPlugin(){return this.#ve}replaceSpareHeldRequiredPlugin(e){this.#ve=e}addSpareHeldPluginId(e){this.#z=new Set([...this.#z,e])}spareParkedAtMs(){return this.#xe}replaceSpareParkedAtMs(e){this.#xe=e}spareHeldMcpServers(){return this.#Ce}replaceSpareHeldMcpServers(e){this.#Ce=e}replaceForkReplayLaunchConfig(e){this.#fe=e}spareClaim(){return this.#he}replaceSpareClaim(e){this.#he=e}projectConfigRoot(){return this.#me}replaceProjectConfigRoot(e){this.#me=e}reset(){this.#e=!1,this.#t=!1,this.#n=!1,this.#r=void 0,this.#o=null,this.#Se="none",this.#ye=!1,this.#_e=!1,this.#be=!1,this.#ke=void 0,this.#z=new Set,this.#ve=!1,this.#xe=void 0,this.#Ce={},this.#s=!1,this.#a=void 0,this.#l=!1,this.#he=void 0,this.#c=!1,this.#d=!1,this.#p=!1,this.#i=void 0,this.#g=!1,this.#u=!1,this.#f="",this.#m=null,this.replaceWorkspaceRestrictionUnsubscribe(null),this.#S=new Map,this.#k="cli",this.#y="fresh",this.#_=void 0,this.#b=!1,this.#v=!1,this.#x=[],this.#E=!1,this.#R=!1,this.#C=!1,this.#w=new Set,this.#A=!1,this.#P=!1,this.#T=!1,this.#O=!1,this.#L=!1,this.#N="none",this.#D=!1,this.#U=!1,this.#I=!1,this.#H=!1,this.#M=!1,this.#B=void 0,this.#K=void 0,this.#W=void 0,this.#F=!1,this.#V=void 0,this.#j=!1,this.#G=!1,this.#$=void 0,this.#J=void 0,this.#Y=void 0,this.#X=!1,this.#Z=!1,this.#Q=!1,this.#ee=!1,this.#te=!1,this.#ne=void 0,this.#re=!1,this.#oe=!1,this.#se=!1,this.#ie=null,this.#ae=null,this.#le=!0,this.#ue=null,this.#q=!1,this.#de=null,this.#ce=!1,this.#pe=!1,this.#ge=!1,this.#fe={},this.#me=null}}class Ks{#e=void 0;#t=[];#n=[];#r=void 0;#o=void 0;#s=null;#a=null;#l=!1;#c=null;#d=!1;#p=Xa();#i=null;#g=!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.#r}replaceFlagSettingsExpectedContent(e){this.#r=e}flagSettingsFilePinnedContent(){return this.#o}replaceFlagSettingsFilePinnedContent(e){this.#o=e}flagSettingsInline(){return this.#s}replaceFlagSettingsInline(e){this.#s=e}parentManagedSettings(){return this.#a}replaceParentManagedSettings(e,u=null,h=!1){this.#a=e,this.#c=u,this.#d=h}hostPolicyVerdict(){return this.#d}parentManagedSettingsInvalid(){return this.#l}replaceParentManagedSettingsInvalid(e){this.#l=e}parentOrganizationSettings(){return this.#c}allowedSettingSources(){return this.#p}replaceAllowedSettingSources(e){this.#p=e}allowedSettingSourcesWithoutRepoDirSources(){let e=this.#p;if(this.#i?.of!==e)this.#i={of:e,result:e.filter((u)=>u!=="projectSettings"&&u!=="localSettings")};return this.#i.result}useCoworkPlugins(){return this.#g}replaceUseCoworkPlugins(e){this.#g=e}reset(){this.#e=void 0,this.#t=[],this.#n=[],this.#r=void 0,this.#o=void 0,this.#s=null,this.#a=null,this.#l=!1,this.#c=null,this.#d=!1,this.#p=Xa(),this.#i=null,this.#g=!1}}function Xa(){return["userSettings","projectSettings","localSettings","flagSettings","policySettings"]}function xr(e){return zn(e).toUpperCase().toLowerCase()}class Ws{#e=[];#t=[];#n=new Set;#r=[];#o=void 0;#s=new Map;#a=new Map;#l=new Map;#c=[];#d=new Set;#p=new Map;#i=new Set;#g=new Map;#u=new Map;#f=new Map;#m=void 0;#h=[];#S=[];#k=!1;#y=void 0;#_=void 0;#b=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.#r}replaceInlinePluginUrls(e){this.#r=e}syncedPluginDirs(){return this.#o??[]}syncedPluginDirsRegistered(){return this.#o!==void 0}syncedPluginAttestation(e){return this.#s.get(e)}syncedPluginRowId(e){return this.#a.get(e)}replaceSyncedPluginDirs(e,u=new Map,h=new Map){this.#o=e,this.#s=u,this.#a=h,this.#l=this.#v(this.#l)}clearSyncedPluginDirs(){this.#o=void 0,this.#s=new Map,this.#a=new Map,this.#l=new Map}attestedOfficialPluginMarketplace(e){return this.#l.get(e)}replaceAttestedOfficialPluginIds(e){this.#l=this.#v(e)}#v(e){let u=new Set([...this.#s.values()].map((h)=>`${h.pluginName}@${h.marketplace}`));return new Map([...e].filter(([h,P])=>u.has(`${h.slice(0,h.lastIndexOf("@"))}@${P}`)))}additionalDirectoriesForClaudeMd(){return this.#c}hasAdditionalDirectoryForClaudeMd(e){return this.#d.has(e)}replaceAdditionalDirectoriesForClaudeMd(e){this.#c=e,this.#d=new Set(e)}directoriesListedWithNoGrant(e){return this.#p.get(xr(e))??new Set}allDirectoriesListedWithNoGrant(){return new Set([...this.#p.values()].flatMap((e)=>[...e]))}noteDirectoryListedWithNoGrant(e,u){let h=new Map(this.#p);for(let P of[xr(u),xr(e)])h.set(P,new Set([...h.get(P)??[],e]));if(this.#p=h,[...this.#i].some((P)=>xr(P)===xr(u)))this.noteDirectoryAttachedMidSession(e)}directoriesAttachedMidSession(){return this.#i}noteDirectoryAttachedMidSession(e){this.#i=new Set([...this.#i,e])}addedFolderConfigRoots(){return this.#g}withheldFolderRealPaths(){return this.#u}retiredConfigRoots(){return this.#f}claudeMdAdditionalDirectoriesAsked(){return this.#m}askClaudeMdAdditionalDirectories(e){this.#m=e}instructionDirectories(){return this.#h}replaceInstructionDirectories(e){this.#h=e}allowedChannels(){return this.#S}replaceAllowedChannels(e){this.#S=e}hasDevChannels(){return this.#k}replaceHasDevChannels(e){this.#k=e}sessionSkillAllowlist(){return this.#y}replaceSessionSkillAllowlist(e){this.#y=e}chromeFlagOverride(){return this.#_}replaceChromeFlagOverride(e){this.#_=e}teammateAgentId(){return this.#b}replaceTeammateAgentId(e){this.#b=e}reset(){this.#e=[],this.#t=[],this.#n=new Set,this.#r=[],this.clearSyncedPluginDirs(),this.#c=[],this.#d=new Set,this.#p=new Map,this.#i=new Set,this.#g=new Map,this.#u=new Map,this.#f=new Map,this.#m=void 0,this.#h=[],this.#S=[],this.#k=!1,this.#y=void 0,this.#_=void 0,this.#b=void 0}}class js{#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 Za=[];class Gs{#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,u){return}slowOperations(){if(this.#t.length===0)return Za;let e=Date.now();if(this.#t.some((u)=>e-u.timestamp>=1e4)){if(this.#t=this.#t.filter((u)=>e-u.timestamp<1e4),this.#t.length===0)return Za}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 Qa(){return{direct:{strict:null,customer:null},proxied:{strict:null,customer:null}}}function el(){return{rateTokens:null,rateLastRefillMs:null,featureOkLogged:!1,reportedDropReasons:new Set}}class $s{#e=null;#t=null;#n=null;#r=null;#o=null;#s=null;#a=null;#l=null;#c=null;#d=null;#p=null;#i=null;#g=null;#u=[];#f=[];#m=!1;#h=null;#S=el();#k=null;#y=null;#_=null;#b=Qa();#v=null;#x=null;installMeter(e,u,{omitUnits:h=!1}={}){this.#e=e;let P=(U)=>h?void 0:U;this.#t=u("claude_code.session.count",{description:"Count of CLI sessions started"}),this.#n=u("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.#r=u("claude_code.pull_request.count",{description:"Number of pull requests created"}),this.#o=u("claude_code.commit.count",{description:"Number of git commits created"}),this.#s=u("claude_code.cost.usage",{description:"Cost of the Claude Code session",unit:P("USD")}),this.#a=u("claude_code.token.usage",{description:"Number of tokens used",unit:P("tokens")}),this.#l=u("claude_code.code_edit_tool.decision",{description:"Count of code editing tool permission decisions (accept/reject) for Edit, Write, and NotebookEdit tools"}),this.#c=u("claude_code.active_time.total",{description:"Total active time in seconds",unit:P("s")})}meter(){return this.#e}sessionCounter(){return this.#t}locCounter(){return this.#n}prCounter(){return this.#r}commitCounter(){return this.#o}costCounter(){return this.#s}tokenCounter(){return this.#a}codeEditToolDecisionCounter(){return this.#l}activeTimeCounter(){return this.#c}statsStore(){return this.#d}replaceStatsStore(e){this.#d=e}loggerProvider(){return this.#p}replaceLoggerProvider(e){this.#p=e}eventLogger(){return this.#i}eventLoggerOwner(){return this.#g}attachEventLogger(e,u,h=!1){if(this.#i=e,this.#m=h,this.#g=e?u:null,!e)return;let P=this.#u;if(this.#u=null,P)for(let U of P)e.emit(U);for(let U of this.#f.splice(0))this.emitPluginRecord(U)}emitPluginRecord(e){if(this.#i!==null){if(this.#m)this.#i.emit(e())}else if(this.isWindowOpen()&&this.#f.length<1500)this.#f.push(e)}bufferPendingEvent(e){if(this.#u===null||this.#u.length>=100)return!1;return this.#u.push(e),!0}closeWindow(e){this.#u=null,this.#f=[],this.#h=e}windowCloseCause(){return this.#h}isWindowOpen(){return this.#u!==null}hostOtel(){return this.#S}meterProvider(){return this.#k}replaceMeterProvider(e){this.#k=e}tracerProvider(){return this.#y}replaceTracerProvider(e){this.#y=e}cachedTelemetryResource(){return this.#_}replaceCachedTelemetryResource(e){this.#_=e}cachedOtlpHttpAgentFactory(e,u){return this.#b[e?"proxied":"direct"][u]}replaceCachedOtlpHttpAgentFactory(e,u,h){this.#b[e?"proxied":"direct"][u]=h}inClusterOtlpTrustRoots(){return this.#v}replaceInClusterOtlpTrustRoots(e){this.#v=e}inClusterOtlpAgentFactory(){return this.#x}replaceInClusterOtlpAgentFactory(e){this.#x=e}reset(){this.#e=null,this.#t=null,this.#n=null,this.#r=null,this.#o=null,this.#s=null,this.#a=null,this.#l=null,this.#c=null,this.#d=null,this.#p=null,this.#i=null,this.#g=null,this.#u=[],this.#f=[],this.#h=null,this.#S=el(),this.#k=null,this.#y=null,this.#_=null,this.#b=Qa(),this.#v=null,this.#x=null}}function tl(e,u){return e.accountUuid===u.accountUuid&&e.emailAddress===u.emailAddress&&e.organizationUuid===u.organizationUuid}class Vs{#e=void 0;#t=null;#n=void 0;#r=!1;#o=null;#s=null;#a=void 0;#l=void 0;#c=new Set;#d=new Map;#p=void 0;#i=null;#g=new Set;#u=null;#f=0;#m=null;#h=null;#S=null;#k=!1;#y=[];#_="single";#b=null;#v=!1;#x=!1;#E=()=>!1;#R=null;#C=void 0;#w=null;#A=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}oauthTokenFromBackgroundSnapshot(){return this.#r}replaceOauthTokenFromBackgroundSnapshot(e){this.#r=e}loginStashedInTokenSlot(){return this.#o}replaceLoginStashedInTokenSlot(e){this.#o=e}oauthOrgFromBackgroundSnapshot(){return this.#s}replaceOauthOrgFromBackgroundSnapshot(e){this.#s=e}oauthScopesFromFd(){return this.#a}replaceOauthScopesFromFd(e){this.#a=e}apiKeyFromFd(){return this.#l}replaceApiKeyFromFd(e){this.#l=e}descriptorAnnouncementConsumed(e){return this.#c.has(e)}markDescriptorAnnouncementConsumed(e){this.#c.add(e)}credentialRoad(e){return this.#d.get(e)}noteCredentialRoad(e,u,h){if(h!==null&&!this.#d.has(e))this.#d.set(e,u)}gatewayTokenFromDescriptor(){return this.#p}replaceGatewayTokenFromDescriptor(e){this.#p=e}resetFdCredentialState(){this.#e=void 0,this.#n=void 0,this.#r=!1,this.#o=null,this.#s=null,this.#a=void 0,this.#l=void 0}gatewayAuth(){return this.#i}replaceGatewayAuth(e){this.#i=e}isGatewayHostHeldStrict(e){return this.#g.has(e)}holdGatewayHostStrict(e){this.#g.add(e)}releaseGatewayHost(e){this.#g.delete(e)}gatewayServerProcess(){return this.#x}replaceGatewayServerProcess(e){this.#x=e}gatewayRequiredByHostPolicy(e){return this.#E(e)}replaceGatewayRequiredByHostPolicyReader(e){this.#E=e}authenticatedAccount(){return this.#u}authenticatedAccountEpoch(){return this.#f}stampAuthenticatedAccount(e){let u=this.#u;if(e!==null&&u!==null&&tl(e,u)){if(e.seatTier!==u.seatTier)this.#u=e;return}this.#f+=1,this.#u=e,this.#m=null;let h=e!==null&&this.#S!==null&&tl(e,this.#S);if(this.#S=null,this.#k=!1,this.#v=!1,!h)this.#h=null,this.#y=[],this.#_="single",this.#b=null}dropAuthenticatedAccountForNewToken(e){let u=this.#u??this.#S,h=!e||this.#u===null&&this.#k,P=this.#h,U=this.#y,H=this.#_,V=this.#b;this.stampAuthenticatedAccount(null),this.#S=u,this.#k=h,this.#h=P,this.#y=U,this.#_=H,this.#b=V,this.#v=!0}tokenAdoptedSinceStamp(){return this.#v}programUseCaseOwner(){return this.#k?null:this.#S}programUseCaseAwaitsAccount(){return this.#k}bearerPlan(){return this.#m}replaceBearerPlan(e){this.#m=e}programUseCaseId(){return this.#h}replaceProgramUseCaseId(e){this.#h=e}programUseCaseChoices(){return this.#y}replaceProgramUseCaseChoices(e){this.#y=e}programUseCaseChoiceMode(){return this.#_}replaceProgramUseCaseChoiceMode(e){this.#_=e}programUseCaseRefusal(){return this.#b}replaceProgramUseCaseRefusal(e){this.#b=e}startupPolicySnapshot(){return this.#C}replaceStartupPolicySnapshot(e){this.#C=e}gatewayRefreshInFlight(){return this.#R}replaceGatewayRefreshInFlight(e){this.#R=e}sdkOAuthTokenRefreshCallback(){return this.#w}replaceSdkOAuthTokenRefreshCallback(e){this.#w=e}hostAuthTokenRefreshCallback(){return this.#A}replaceHostAuthTokenRefreshCallback(e){this.#A=e}resetForTests(){this.#e=null,this.#t=null,this.#n=null,this.#r=!1,this.#o=null,this.#a=void 0,this.#l=null,this.#c.clear(),this.#d.clear(),this.#p=void 0,this.#i=null,this.#g.clear(),this.#u=null,this.#f=0,this.#m=null,this.#S=null,this.#k=!1,this.#h=null,this.#y=[],this.#_="single",this.#b=null,this.#v=!1,this.#x=!1,this.#E=()=>!1,this.#R=null,this.#C=void 0,this.#w=null,this.#A=null}}class qs{#e=void 0;#t=!1;#n=!1;#r;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.#r=e}ensureConnectedClient(){return this.#r}reset(){this.#e=void 0,this.#t=!1,this.#n=!1}}class zs{#e=null;#t=new Map;#n=new Map;#r=new Set;#o=new Set;#s=new Set;#a=new Map;#l=new Map;#c=new Map;#d=!1;#p=!1;#i=!1;#g=!1;#u=!1;#f=!1;#m=!1;#h=!1;#S=!1;#k=!1;#y=!1;#_=!1;#b=new Set;#v=!1;#x=new Set;#E=!1;#R=!1;#C=!1;#w=!1;#A=!1;#P=!1;#T=new Map;#O=void 0;#L=void 0;#N=!1;#D=void 0;#U=!1;#I=!1;#H=!1;#M=!1;#B=!1;#K=!1;#W=void 0;#F=void 0;#j=void 0;#G=!1;#$=new Map;#V=new Map;promptCache1hAllowlist(){return this.#e}replacePromptCache1hAllowlist(e){this.#e=e}thinkingTypeOverrides(){return this.#t}recordThinkingTypeOverride(e,u){this.#t.set(e,u)}servedModelsByRequestedModel(){return this.#n}recordServedModels(e,u){this.#n.set(e,u)}effortUnsupportedModels(){return this.#r}markEffortUnsupported(e){this.#r.add(e)}structuredOutputsUnsupportedModels(){return this.#o}markStructuredOutputsUnsupported(e){this.#o.add(e)}clearStructuredOutputsUnsupported(){this.#o=new Set}context1mRefusedModels(){return this.#s}markContext1mRefused(e){this.#s.add(e)}clearContext1mRefused(){this.#s=new Set}learnedMaxTokens(){return this.#a}refusedBetas(e){return this.#l.get(e)??[]}markBetaRefused(e,u){let h=this.#l.get(e);if(h)h.add(u);else this.#l.set(e,new Set([u]))}learnedEffortCaps(){return this.#c}midConvCachePromotionRejected(){return this.#d}markMidConvCachePromotionRejected(){this.#d=!0}toolProvenanceServerUrlRefused(){return this.#p}markToolProvenanceServerUrlRefused(){this.#p=!0}perTurnEffortOkEmitted(){return this.#i}markPerTurnEffortOkEmitted(){this.#i=!0}lateToolAdditionsOkEmitted(){return this.#g}markLateToolAdditionsOkEmitted(){this.#g=!0}toolResultScreeningOkEmitted(){return this.#u}markToolResultScreeningOkEmitted(){this.#u=!0}toolChangeHeaderRefused(){return this.#f}markToolChangeHeaderRefused(){this.#f=!0}promptEndMarkRefused(){return this.#m}markPromptEndMarkRefused(){this.#m=!0}inlineToolsRefused(){return this.#h}markInlineToolsRefused(){this.#h=!0}inlineToolsOkEmitted(){return this.#S}markInlineToolsOkEmitted(){this.#S=!0}thinkingResumptionRefused(){return this.#k}markThinkingResumptionRefused(){this.#k=!0}toolSearchNotAllowed(){return this.#y}markToolSearchNotAllowed(){this.#y=!0}everyTurnDenyHolds(){return this.#_}markEveryTurnDenyHolds(){this.#_=!0}refusedBetaHeaders(){return this.#b}markBetaHeaderRefused(e){this.#b.add(e)}unmarkBetaHeaderRefused(e){this.#b.delete(e)}thinkingHighlightsRefused(){return this.#v}markThinkingHighlightsRefused(){this.#v=!0}toolChangeUnsupportedModels(){return this.#x}markToolChangeUnsupportedModel(e){this.#x.add(e)}internalModelFieldsRefused(){return this.#E}markInternalModelFieldsRefused(){this.#E=!0}internalModelFieldsRefusalAnnounced(){return this.#R}markInternalModelFieldsRefusalAnnounced(){this.#R=!0}thirdPartyServerClassifierRefused(){return this.#C}markThirdPartyServerClassifierRefused(){this.#C=!0}releaseThirdPartyServerClassifierRefusal(){this.#C=!1}serverCheckEntryAnswered(){return this.#w}markServerCheckEntryAnswered(){this.#w=!0}serverCheckRefusalSuspected(){return this.#A}markServerCheckRefusalSuspected(){this.#A=!0}threadsHeldForServerClassifier(){return this.#P}markThreadsHeldForServerClassifier(){this.#P=!0}autoModeUnavailableResponse(e){return this.#T.get(e)}autoModeUnavailableResponsesInARow(e,{noCheckOnly:u=!1}={}){let h=0;for(let P of this.#T.values())if(P.runKey===e&&(!u||P.noCheck))h++;return h}dropAutoModeUnavailableResponsesOfOtherTurns(e,u){for(let[h,P]of this.#T)if(P.runKey===e&&P.turn!==void 0&&P.turn!==u)this.#T.delete(h)}noteAutoModeUnavailableResponse(e,u){this.#T.set(e,u)}clearAutoModeUnavailableResponses(e){for(let[u,h]of this.#T)if(h.runKey===e)this.#T.delete(u)}setAutoModeUnavailableStopNotice(e){this.#O=e}autoModeUnavailableStopNotice(){return this.#O}setLocalCommandExitCode(e){this.#L=e}localCommandExitCode(){return this.#L}observedGateway(){return this.#W}serverClassifierFallbackChoice(){return this.#F}setServerClassifierFallbackChoice(e){this.#F=e}clearServerClassifierFallbackChoice(){this.#F=void 0}openAutoModeEndOffer(){return this.#j}setOpenAutoModeEndOffer(e){this.#j=e}keepsLocalClassifierFallback(){return this.#G}keepLocalClassifierFallback(){this.#G=!0}noteObservedGateway(e){this.#W??=e}takeServerClassifierFallbackAnnouncement(){if(!this.#C||this.#N)return!1;return this.#N=!0,!0}takeFallbackUnacknowledgedAnnouncement(){if(!this.#C||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.#I=!0}takeNoServerCheckStoppedTurn(){let e=this.#I;return this.#I=!1,e}serverCheckDeclined(){return this.#H}setServerCheckDeclined(e){this.#H=e}noteRefusedStreakStoppedTurn(){this.#M=!0}takeRefusedStreakStoppedTurn(){let e=this.#M;return this.#M=!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,u){this.#$.set(e,u)}foundryDeploymentCapabilities(){return this.#V}reset(){this.#e=null,this.#t=new Map,this.#n=new Map,this.#r=new Set,this.#o=new Set,this.#s=new Set,this.#a=new Map,this.#l=new Map,this.#c=new Map,this.#d=!1,this.#p=!1,this.#i=!1,this.#g=!1,this.#u=!1,this.#f=!1,this.#m=!1,this.#h=!1,this.#S=!1,this.#k=!1,this.#y=!1,this.#_=!1,this.#b=new Set,this.#v=!1,this.#x=new Set,this.#E=!1,this.#R=!1,this.#C=!1,this.#w=!1,this.#A=!1,this.#P=!1,this.#T.clear(),this.#O=void 0,this.#L=void 0,this.#N=!1,this.#K=!1,this.#D=void 0,this.#U=!1,this.#I=!1,this.#H=!1,this.#M=!1,this.#B=!1,this.#W=void 0,this.#F=void 0,this.#j=void 0,this.#G=!1,this.#$=new Map,this.#V=new Map}}class Js{#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 Ys{#e=!1;#t=!1;#n=nl;#r=m();selectorGate(){return this.#e}selectorGateEverOn(){return this.#t}replaceSelectorGate(e){this.#e=e,this.#t||=e}inheritSelectorGateEverOn(){this.#t=!0}resampleSelectorGate(e){let u=this.#e;if(this.#e=e,this.#t||=e,u!==e)this.#r.emit(e)}subscribeSelectorGateChanged(e){return this.#r.subscribe(e)}replaceHostGateSubscription(e){let u=this.#n;this.#n=e,u()}dropHostGateSubscription(){this.replaceHostGateSubscription(nl)}}function nl(){}class Xs{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 Zs{clock;backgroundHousekeeping;launchOptions;settingsSource;extensionsConfig;modelStringsCache;diagnostics;telemetryHandles;credentialSlots;mcpProcessWiring;requestLatches;accountCreditLatches;proactivity;livesWithProcess;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.livesWithProcess=e.livesWithProcess,this.proactivity=e.proactivity}}function rl(e=!1){return new Zs({clock:new Jr,backgroundHousekeeping:new Xs,launchOptions:new Bs,settingsSource:new Ks,extensionsConfig:new Ws,modelStringsCache:new js,diagnostics:new Gs,telemetryHandles:new $s,credentialSlots:new Vs,mcpProcessWiring:new qs,requestLatches:new zs,accountCreditLatches:new Js,proactivity:new Ys,livesWithProcess:e})}function Cc(e=Ko(),u=!1){return za({host:rl(u),livesWithProcess:u,id:Ui()??Fe(),project:{originalCwd:e,projectRoot:e,cwd:e}})}var uo=Cc(zi,!0);function A(){return sn()}function sn(){return ol?.()?.session??uo}function ne(e){return e.of(uo.host)}var ol;qa((e)=>$a.of(sn().host).reporter?.(e));var Ec=new s(()=>({}));Ya({isDiskless:()=>g(),isDisklessProcess:()=>bn(),reportBuilt:(e)=>Ec.of(sn().host).reporter?.(e)});function sl(){let e=ol?.();if(e?.session)return e.session.id;return e?.sessionId??uo.id}var r_=new te(()=>m());var o_=new te(()=>m());function lr(){return sn().host.launchOptions.isInteractive()}function dr(){return sn().host.launchOptions.isInteractivityDecided()}function cr(){return sn().host.launchOptions.isNoDialogLaunch()}var s_=new te(()=>m());var i_=new te(()=>m());function ur(){return sn().host.credentialSlots.gatewayAuth()}function g(){return jt()}function jt(){return sn().host.launchOptions.diskless()}function bn(){return uo.host.launchOptions.diskless()}function pr(){return sn().host.launchOptions.ccrDerivedSurface()}var a_=new s(()=>m());var l_=new s(()=>m());function l(e,u){return{code:"InvalidArgument",argument:e,...u!==void 0&&{reason:u}}}var ve="OtherNames";var An="LeafMoved",On="HardeningUnavailable";function $t(e){return{ok:!0,value:e}}function he(e){return{ok:!1,error:e}}var Vt={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 Qs=globalThis.process?.getBuiltinModule?.("async_hooks"),il=Qs!==void 0,ei=Qs?new Qs.AsyncLocalStorage:{run:(e,u)=>u(),getStore:()=>{return}};function al({writeBatch:e,sizeOf:u,flushIntervalMs:h=1000,maxBufferSize:P=100,maxBufferBytes:U=1/0,immediateMode:H=!1}){let V=[],z=0,ae=null,le=null;function we(){if(ae)clearTimeout(ae),ae=null}function Re(Ve){try{e(Ve)}catch{}}function Ie(){if(le)Re(le),le=null;if(V.length===0)return;Re(V),V=[],z=0,we()}function Me(){if(!ae)ae=setTimeout(Ie,h)}function Ae(){if(le){le.push(...V),V=[],z=0,we();return}let Ve=V;V=[],z=0,we(),le=Ve,setImmediate(()=>{let Je=le;if(le=null,Je)Re(Je)})}return{write(Ve){if(H){Re([Ve]);return}if(V.push(Ve),z+=u(Ve),Me(),V.length>=P||z>=U)Ae()},flush:Ie,dispose(){Ie()}}}function Rc(e){if(typeof e==="function")return e;if(Symbol.asyncDispose in e)return()=>e[Symbol.asyncDispose]();return()=>e[Symbol.dispose]()}class co{#e=new Set;#t=!1;get drainStarted(){return this.#t}register(e){let u=Rc(e);this.#e.add(u);let h=()=>{this.#e.delete(u)};return Object.assign(h,{[Symbol.dispose]:h})}async drain(){this.#t=!0;let e=Array.from(this.#e);this.#e.clear();let h=(await Promise.allSettled(e.map(async(P)=>P()))).find((P)=>P.status==="rejected");if(h!==void 0)throw h.reason}async[Symbol.asyncDispose](){await this.drain()}get sizeForTesting(){return this.#e.size}}class ll{cleanup=new co;preExitFlush=new co;preExitFlushWaits=new Map;sends=new co;sendsInFlight=Promise.resolve()}var wc=new s(()=>new ll);function Ac(){return ne(wc)}function Yt(e){return Ac().cleanup.register(e)}var Tc=a({read:void 0},(e)=>{e.read=void 0});function ul(){return Tc.read}class cl{parsed=new Map;lookup(e){return this.parsed.get(e)}remember(e,u){this.parsed.set(e,u)}reset(){this.parsed.clear()}}var dl=new cl;function pl(e){let u=dl.lookup(e);if(u!==void 0)return u;let h=Oc(e);return dl.remember(e,h),h}function Oc(e){if(!e||e.trim()==="")return null;let u=e.split(",").map((H)=>H.trim()).filter(Boolean);if(u.length===0)return null;let h=u.some((H)=>H.startsWith("!")),P=u.some((H)=>!H.startsWith("!"));if(h&&P)return null;let U=u.map((H)=>H.replace(/^!/,"").toLowerCase());return{include:h?[]:U,exclude:h?U:[],isExclusive:h}}function Pc(e){let u=[],h=e.match(/^MCP server ["']([^"']+)["']/);if(h&&h[1])u.push("mcp"),u.push(h[1].toLowerCase());else{let H=e.match(/^([^:[]+):/);if(H&&H[1])u.push(H[1].trim().toLowerCase())}let P=e.match(/^\[([^\]]+)]/);if(P&&P[1])u.push(P[1].trim().toLowerCase());if(e.toLowerCase().includes("1p event:"))u.push("1p");let U=e.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(U&&U[1]){let H=U[1].trim().toLowerCase();if(H.length<30&&!H.includes(" "))u.push(H)}return Array.from(new Set(u))}function Lc(e,u){if(!u)return!0;if(e.length===0)return!1;if(u.isExclusive)return!e.some((h)=>u.exclude.includes(h));else return e.some((h)=>u.include.includes(h))}function gl(e,u){if(!u)return!0;let h=Pc(e);return Lc(h,u)}import{homedir as Fc}from"os";import{basename as N_,dirname as U_,join as Nc,resolve as fl}from"path";var Dc=/^[+-]?(\d+(\.\d*)?|\.\d+)[eE][+-]?\d+$/,Ic=/^[+-]?\d{1,3}([_,\u00A0\u202F ])\d{3}(?:\1\d{3})*$/,Mc=/[_,\u00A0\u202F ]/g;function Cn(e){if(e.length<=32){if(Dc.test(e)){let u=Number(e);return Number.isInteger(u)?u:NaN}if(Ic.test(e))return parseInt(e.replace(Mc,""),10)}return}function nt(e){let u=String(e).trim();return Cn(u)??parseInt(u,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 Pr(){return process.env.CLAUDE_CONFIG_DIR}function oe(e){let u=e==="CLAUDE_CONFIG_DIR"?Pr():process.env[e];if(u===void 0)return;let h=String(u).trim();return h?h:void 0}function zt(e){return d(process.env[e])}function hl(e,u){let h=a(new Map,(U)=>U.clear());function P(){let U=u(),H=h.get(U);if(H)return H.value;let V=e();return h.set(U,{value:V}),V}return Object.assign(P,{cache:h})}var R=hl(()=>(Pr()??Nc(Fc(),".claude")).normalize("NFC"),Pr);function ke(){return lo()?null:R()}function fr(e){let u=ke();return u===null||e===null?u===e:fl(u)===fl(e)}function ml(){return process.env.CLAUDE_CODE_PROJECT_DIR_NAME}var Uc=/^[A-Za-z0-9_-]{1,64}$/,Hc=/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/i;function ti(e){if(!e||!Uc.test(e)||Hc.test(e))return;return e}function Bc(){return`${lo()}\x00${Pr()??""}\x00${ml()??""}`}var Sl=hl(()=>Pr()||lo()?ti(ml()):void 0,Bc);import*as Ne from"fs";import{appendFile as qc,copyFile as zc,link as Jc,lstat as ii,mkdir as Yc,open as po,readdir as Xc,readFile as bl,readlink as Zc,realpath as Qc,rename as ep,rmdir as tp,rm as np,stat as kl,unlink as rp}from"fs/promises";import*as qe from"path";function re(){return process.versions?.bun!==void 0}function r(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function O(e){return typeof e==="object"&&e!==null}function Et(e){return Array.isArray(e)}function rt(e,u){return e===void 0||e===null?void 0:Reflect.get(Object(e),u,e)}var Kc=0xffffffffffffffffn,Wc="tengu_sorted_snowflake",ni=0x0000ffff00000000n;function _e(e){let u=BigInt(e);return u===0n||u===-1n||u===Kc||u===1n<<64n}function ot(e,u){return!_e(e.ino)&&!_e(u.ino)&&e.ino!==u.ino&&!(process.platform==="win32"&&jc(e.ino,u.ino)&&M(Wc,!0))}function jc(e,u){return(e|u)>>60n===0n&&((e^u)&~ni)===0n&&((e&ni)===0n||(u&ni)===0n)}var ri=[];function oi(){return ri.pop()??Buffer.allocUnsafeSlow(65536)}function si(e,u){if(e.fill(0,0,Math.min(u,e.length)),ri.length<2)ri.push(e)}var sb=(()=>{let e=process.env.CLAUDE_CODE_SLOW_OPERATION_THRESHOLD_MS;if(e!==void 0){let u=Number(e);if(!Number.isNaN(u)&&u>=0)return u}return 1/0})();var $c={[Symbol.dispose](){}};function Vc(){return $c}var w=Vc;function o(e,u,h){return JSON.stringify(e,u,h)}var C=(e,u)=>{let P=[];try{const h=E(P,w`JSON.parse(${_l(e)})`,0);return typeof u>"u"?JSON.parse(e):JSON.parse(e,u)}catch(U){var H=U,V=1}finally{y(P,H,V)}};function gr(e){return JSON.parse(e)}function J(e,u){let P=[];try{const h=E(P,w`structuredClone(${_l(e)})`,0);return structuredClone(e,u)}catch(U){var H=U,V=1}finally{y(P,H,V)}}function _l(e){return typeof e==="string"?e.length:e}var op="→";function sp(){return process.platform==="win32"?0:Ne.constants.O_NOFOLLOW|Ne.constants.O_NONBLOCK}function qt(){return process.platform==="win32"?"r":Ne.constants.O_RDONLY|Ne.constants.O_NONBLOCK|Ne.constants.O_NOCTTY}var $n=process.platform==="win32"?/[\\/]+/:/\/+/;function Rn(e,u){let h=(z)=>z.split($n).filter(Boolean),P=qe.resolve(e),U=qe.resolve(u),H=h(P),V=h(U);return qe.parse(P).root===qe.parse(U).root&&H.length<V.length&&H.every((z,ae)=>z===V[ae])}function ai(e){let u="";for(let P of e.split(/([\\/]+)/)){if(P==="."||P==="..")break;u+=P}let h=u.replace(/(?<=[^\\/])[\\/]+$/,"");return h===""?e:h}function ip(e,u){if(process.platform==="win32"||u?.surfaceNetworkRaw===!0||!re()||e.includes("�"))return e;let h=[];for(let P of e.split(qe.sep)){if(P===".."&&h.length>1)break;if(P==="..")h.pop();else if(P!==""&&P!==".")h.push(P)}return qe.sep+h.join(qe.sep)}function ap(e){let u=qe.join(e).replace(/(?<=[^\\/])[\\/]+$/,"");if(Dt(u)&&!q(u))return u;return ai(e)}function lp(e){if(e.startsWith("\\\\"))return ai(e);let u=e.replace(/^\/+/,"/"),h=ro(u);if(h!==null)return h;return ai(e)}var Rl=process.platform==="win32"?ap:lp;function fo(e,u,h){let P=Pt(e);if(u.length===0||P||u.some((U)=>U==="."||U==="..")){if(h!==void 0&&(u.length>0||P))h(qe.join(e,...u));return P?Rl(e):e}return qe.join(e,...u)}var X="\x00unverified-ancestry",Ke="\x00opaque-link-text";function up(e){return ft(qe.isAbsolute(e)?e:e.replace(/^(?:\.\.(?:[\\/]+|$))+/,""))}function dp(e,u=process.platform==="win32",h=!0){return e.includes("�")||up(e)||u&&(/^(?:[A-Za-z]:(?![\\/])|[\\/](?![\\/]))/.test(e)||/^[\\/]{2}\?[\\/]/.test(e)&&!/^[\\/]{2}\?[\\/](?:[A-Za-z]:[\\/]|UNC[\\/])/i.test(e)||e.split(/[\\/]/).some((P)=>P!=="."&&P!==".."&&(/[. ]$/.test(P)||h&&ta(P))))}function vl(e,u,h=!1,P=!1,U=!1){if(u?.unreadableAncestry!=="unverified")return;let H=e!==void 0&&typeof e==="object"&&"errno"in e?e.errno:void 0;if(H==="ENOENT"||H==="ENOTDIR")return;if(H==="ENAMETOOLONG"&&!h&&!P&&!U)return;return X}function Fr(e){return on(e)}function go(e,u){return u!==void 0&&u.some((h)=>on(h)&&!Ls(e,h)&&(li(e,h)||It(e)))}function xl(e,u){return u!==void 0&&u.some((h)=>on(h)&&li(h,e))}function li(e,u){let h=(H)=>H.length>1?H.replace(/\/+$/,""):H,[P,U]=[h(e),h(u)];return P===U||P.startsWith(U==="/"?U:U+"/")}function Dr(e,u){return u===void 0||u.every((h)=>Ls(e,h))}function Cl(e,u){return u===void 0||u.every((h)=>Aa(e,h))}function El(e,u,h){let P=It(e)?ro(e):null;if(P===null||!Dr(P,u))return;let U=qe.join(e);if(It(U)&&Xn(U)===Xn(P))return U;return fo(e,[],h)}function cp(e){if(e?.anchors!==void 0&&e.anchors.length>0)return e.anchors;return e?.anchor!==void 0?[e.anchor]:void 0}async function wn(e,u=Pl){return ft(e)||gt(e)||Y(e)||dn(e)||await Jt(u,e,wl())!==void 0}function wl(){return{surfaceNetworkRaw:!0,unreadableAncestry:"unverified",...Al()}}function Al(){return{literalLinkText:process.platform==="win32"?"opaque":"undecodable"}}function yt(e,u,h){return fp(Tl(u,h),(P)=>{if(P.kind==="lstat")return e.lstatSync(P.path,pp)??gp;if(P.kind==="opendirNofollow")return e.openDirNoFollowSync(P.path),"ok";return e.readlinkSync(P.path)})}function Jt(e,u,h,P,U){return hp(Tl(u,h),P,async(H)=>{if(H.kind==="lstat"){if(U===void 0)return e.lstat(H.path);let V;try{V=await e.lstatBigint(H.path)}catch(z){throw U(H.path,void 0),z}return U(H.path,V),V}if(H.kind==="opendirNofollow")return await e.openDirNoFollow(H.path),"ok";return e.readlink(H.path)})}var pp={throwIfNoEntry:!1},gp={errno:"ENOENT"};function fp(e,u){let h;for(;;){let P=e.next(h);if(P.done)return P.value;try{h=u(P.value)}catch(U){h={errno:n(U)}}}}async function hp(e,u,h){let P;for(;;){let U=e.next(P);if(U.done)return U.value;if(u?.aborted===!0)return X;try{P=await h(U.value)}catch(H){P={errno:n(H)}}}}function*Tl(e,u){let h=cp(u),P=(Pe)=>Fr(Pe)&&(u?.surfaceNetworkRaw===!0||h!==void 0||Zn(Pe)||It(Pe));if(P(e)&&!go(e,h))return e;if(Dt(e)&&!q(e)&&Cl(e,h)||It(e)&&Dr(e,h))return;let U=qe.resolve(e),H=qe.parse(U).root,V=H,z=U.slice(H.length).split($n).filter(Boolean),ae=0,le,we=z.length,Re=!1,Ie=!1,Me,Ae=64,Ve=()=>z.some((Pe)=>Pt(Pe)),Je=()=>/[. ]$/.test(z[0]);while(z[0]!==void 0&&ae<Ae){if(Re&&Pt(z[0]))return X;let Pe=qe.join(V,z[0]);if(It(Pe)&&Dr(Pe,h)||P(Pe)&&!(go(Pe,h)||xl(Pe,h)))return fo(Pe,z.slice(1),u?.onCollapsedLanding);if(fe(Pe)){if(u?.surfaceNetworkRaw===!0||u?.unreadableAncestry==="unverified")return X;return fo(Pe,z.slice(1),u?.onCollapsedLanding)}let Ue=process.platform==="darwin"&&Pe!=="/dev/fd"&&li(Pe,"/dev/fd");if(Ue&&qe.dirname(Pe)==="/dev/fd"&&z.some((Nt,fn)=>fn>0&&(Nt===".."||Nt==="."))){z.shift();while(z[0]==="."&&z.length>1)z.shift();V=Pe;continue}let Oe=Ue?{errno:"ENOENT"}:yield{kind:"lstat",path:Pe};if(Oe===void 0||typeof Oe==="string"||"errno"in Oe){if(process.platform!=="win32"&&typeof Oe==="object"&&"errno"in Oe&&Oe.errno!==void 0&&Oe.errno!=="ENOENT"&&Oe.errno!=="ENOTDIR"&&Oe.errno!=="ENAMETOOLONG"){if(typeof(yield{kind:"opendirNofollow",path:Pe})==="string"){Ie=!0,z.shift(),V=Pe;continue}}if(u?.launchAncestry&&!Ie&&typeof Oe==="object"&&"errno"in Oe&&(Oe.errno==="EPERM"||Oe.errno==="EACCES")&&Rn(Pe,u.launchAncestry)){Re=!0,z.shift(),V=Pe;continue}if(typeof Oe==="object"&&"errno"in Oe&&(Oe.errno==="ENOENT"||Oe.errno==="ENOTDIR"))u?.onOutcome?.({kind:"absent",at:V,remaining:[...z],fromLinkTarget:z.length>we,...Oe.errno==="ENOTDIR"&&{notAFolder:!0}});return vl(Oe,u,ae>0,Ve(),Je())}let xt=Oe;if(Ie=!0,!xt.isSymbolicLink()){z.shift(),V=Pe;continue}ae++;let Xe=Pe+"\x00"+z.join("\x00");if((Me??=new Set).has(Xe))return;Me.add(Xe);let Mt=yield{kind:"readlink",path:Pe};if(typeof Mt!=="string")return vl(Mt,u,ae>0,Ve(),Je());let Ye=Mt;if(u?.literalLinkText!==void 0&&(u.literalLinkText==="undecodable"?Ye.includes("�"):dp(Ye,void 0,u.literalLinkText==="opaque")))return Ke;if(le!==void 0&&Ye.includes("�"))return le;if(!qe.isAbsolute(Ye)){let Nt=Ye.split($n).filter(Boolean);if(u?.surfaceNetworkRaw===!0){let fn=El((V.endsWith(qe.sep)?V:V+qe.sep)+[...Nt,...z.slice(1)].join(qe.sep),h,u?.onCollapsedLanding);if(fn!==void 0)return fn}z.shift(),u?.onHop?.({composed:qe.resolve(V,Ye,...z),leaf:z.length===0,text:Ye,link:Pe}),we=Math.min(we,z.length),z=[...Nt,...z];continue}let Le=Ye;if(u?.surfaceNetworkRaw===!0&&z.length>1&&dn(Le)){let Nt=El([Le,...z.slice(1)].join(qe.sep),h,u?.onCollapsedLanding);if(Nt!==void 0)return Nt}if(Dt(Le)&&!q(Le)&&Cl(Le,h)||It(ip(Le,u))&&Dr(Le,h)||!Pt(Le)&&P(Le)&&!(go(Le,h)||z.length>1&&xl(Le,h)))return z.shift(),fo(Le,z,u?.onCollapsedLanding);if(It(Le)||Fr(Le))u?.onCollapsedLanding?.(qe.join(Le,...z.slice(1)));if(It(Le)&&Dr(Le,h))le??=Rl(Le);else if(Zn(Le))le??="/Network";if(le!==void 0&&Ye.includes("�"))return le;if(u?.surfaceNetworkRaw===!0&&Pt(Le)&&(Dt(Le)||Y(Le)||on(Le)||dn(Le)))return z.shift(),z.length===0?Le:Le+qe.sep+z.join(qe.sep);z.shift();let Lt=qe.parse(Le).root||qe.sep,Ft=qe.parse(Pe).root,qn=/^[\\/]$/.test(Lt)&&Ft!==""&&!/^[\\/]$/.test(Ft);if(qn&&(u?.surfaceNetworkRaw===!0||u?.unreadableAncestry==="unverified"))return X;u?.onHop?.({composed:z.length===0?Le:qe.resolve(Le,...z),leaf:z.length===0,text:Ye,link:Pe}),V=qn?Ft:Lt,Ie=!1,we=Math.min(we,z.length),z=[...Le.slice(Lt.length).split($n).filter(Boolean),...z]}if(z.length>0&&(u?.literalLinkText==="opaque"||u?.literalLinkText==="opaque-except-devices"))return Ke;if(z.length>0)return X;if(ae>0&&dn(V))return V;if(P(V)&&!go(V,h))return V;u?.onOutcome?.({kind:"resolved",path:V});return}function j(e,u,h){if(Dt(u)&&!q(u)||It(u)||Zn(u))return{resolvedPath:u,isSymlink:!1,isCanonical:!1};let P=!1,U=!1,H=!1,V=yt(e,u,h?.judged?{literalLinkText:process.platform==="win32"||!re()?"opaque":"undecodable",onHop:({link:z})=>{P=!0,U||=Ra(z)},onOutcome:(z)=>{H=!U&&(z.kind==="resolved"||!z.fromLinkTarget)}}:void 0);if(V===X)return{resolvedPath:u,isSymlink:h?.judged===!0,isCanonical:!1};if(V===Ke||V===void 0&&P&&!H)return{resolvedPath:u,isSymlink:!0,isCanonical:!1};if(V!==void 0)return{resolvedPath:V,isSymlink:!0,isCanonical:!1};try{let z=mp(e,u);return{resolvedPath:z,isSymlink:z!==u,isCanonical:!0}}catch(z){let ae=n(z);return{resolvedPath:u,isSymlink:h?.judged===!0&&ae!=="ENOENT"&&ae!=="ENOTDIR"&&(P||!H),isCanonical:!1}}}function Ol(e){let u=Wo();if(u===null)return null;try{let h=qe.resolve(u),P=qe.resolve(e.cwd()),U=qe.parse(h).root;if(U!==qe.parse(P).root)return null;let H=h.slice(U.length).split($n).filter(Boolean),V=P.slice(U.length).split($n).filter(Boolean),z=0;while(z<H.length&&z<V.length&&H[z]===V[z])z++;return z>0?qe.join(U,...H.slice(0,z)):null}catch{return null}}function mp(e,u){try{return e.realpathSync(u)}catch(h){let P=n(h);if(P!=="EPERM"&&P!=="EACCES")throw h;let U,H=Ol(e);if(yt(e,u,{...wl(),launchAncestry:H,onOutcome:(z)=>{U=z}})!==void 0||U===void 0)throw h;if(U.kind==="absent")throw Object.assign(Error("ENOENT: no such file or directory"),{code:"ENOENT",syscall:"realpath",path:u});return _(U.path)}}var Ir="ERR_SYMLINK_TO_NETWORK_PATH";function st(e,u,h){let{asWritten:P,opts:U}=_p(e,u,h),H,V;return kp(yt(e,P,{...U,onOutcome:(z)=>{H=Sp(z),V=yp(z)}}),u,P),{...bp(P),linksResolvedPath:H,absentAt:V}}function Sp(e){return e.kind==="resolved"?_(e.path):void 0}function yp(e){return e.kind==="absent"?{at:e.at,remaining:e.remaining,fromLinkTarget:e.fromLinkTarget,...e.notAFolder&&{notAFolder:!0}}:void 0}function _p(e,u,h){let P=me(u);if(pe(P)||Ps(P))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:Ir,path:u,reason:"unexamined"});let U=qe.isAbsolute(P)?qe.resolve(P):qe.resolve(process.cwd(),P),H=me(U);if(pe(H)||Ps(H))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:Ir,path:u,reason:"unexamined"});let V=Fr(H)||It(H)||Dt(H)&&!q(H);return{asWritten:H,ownHost:V,opts:{...V&&{anchors:[H]},surfaceNetworkRaw:!0,...Al(),...(!V||h?.failClosed)&&{unreadableAncestry:"unverified",launchAncestry:Ol(e)}}}}function bp(e){return{resolvedPath:e,isSymlink:!1,isCanonical:!1}}function kp(e,u,h){if(e===void 0)return;let P=(H)=>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:Ir,path:u,reason:H});if(e===X)throw P("unexamined");if(e===Ke)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:Ir,path:u,reason:"unexamined"});if(Fr(h)&&e===h)return;if(!(Dt(e)||Y(e)||Fr(e)||dn(e)))throw P("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:Ir,path:u,reason:"network"})}var Pl={cwd(){return process.cwd()},existsSync(e){let h=[];try{const u=E(h,w`fs.existsSync(${e})`,0);return Ne.existsSync(e)}catch(P){var U=P,H=1}finally{y(h,U,H)}},async stat(e){return kl(e)},async lstat(e){return ii(e)},async openDirNoFollow(e){if(process.platform==="win32")throw Error("openDirNoFollow is a POSIX-only examination probe");await(await po(e,Ne.constants.O_DIRECTORY|Ne.constants.O_NOFOLLOW)).close()},openDirNoFollowSync(e){if(process.platform==="win32")throw Error("openDirNoFollowSync is a POSIX-only examination probe");let u=Ne.openSync(e,Ne.constants.O_DIRECTORY|Ne.constants.O_NOFOLLOW);Ne.closeSync(u)},async lstatBigint(e){return ii(e,{bigint:!0})},async statBigint(e){return kl(e,{bigint:!0})},async readdir(e){return Xc(e,{withFileTypes:!0})},async unlink(e){return rp(e)},async rmdir(e){return tp(e)},async rm(e,u){return np(e,u)},async mkdir(e,u){try{await Yc(e,{recursive:!0,...u})}catch(h){if(n(h)!=="EEXIST")throw h}},async readFile(e,u){return bl(e,{encoding:u.encoding})},async rename(e,u){return ep(e,u)},async realpath(e){return _(await Qc(e))},async readlink(e){return Zc(e)},async copyFile(e,u){return zc(e,u)},async appendFile(e,u,h){if(h?.mode!==void 0)try{let P=await po(e,"ax",h.mode);try{await P.appendFile(u)}finally{await P.close()}return}catch(P){if(n(P)!=="EEXIST")throw P}return qc(e,u)},async link(e,u){return Jc(e,u)},statSync(e){let h=[];try{const u=E(h,w`fs.statSync(${e})`,0);return Ne.statSync(e)}catch(P){var U=P,H=1}finally{y(h,U,H)}},lstatSync:xp,lstatBigintSync(e){let h=[];try{const u=E(h,w`fs.lstatSync(${e})`,0);return Ne.lstatSync(e,{bigint:!0})}catch(P){var U=P,H=1}finally{y(h,U,H)}},readFileSync(e,u){let P=[];try{const h=E(P,w`fs.readFileSync(${e})`,0);return Ne.readFileSync(e,{encoding:u.encoding})}catch(U){var H=U,V=1}finally{y(P,H,V)}},readSync(e,u){let U=[];try{const h=E(U,w`fs.readSync(${e}, ${u.length} bytes)`,0);let P=Ne.openSync(e,"r");try{let ae=Tn(P,u.length,"file");return{buffer:ae,bytesRead:ae.length}}finally{Ne.closeSync(P)}}catch(H){var V=H,z=1}finally{y(U,V,z)}},appendFileSync(e,u,h){let U=[];try{const P=E(U,w`fs.appendFileSync(${e}, ${u.length} chars)`,0);if(h?.mode!==void 0)try{let ae=Ne.openSync(e,"ax",h.mode);try{Ne.appendFileSync(ae,u)}finally{Ne.closeSync(ae)}return}catch(ae){if(n(ae)!=="EEXIST")throw ae}Ne.appendFileSync(e,u)}catch(H){var V=H,z=1}finally{y(U,V,z)}},unlinkSync(e){let h=[];try{const u=E(h,w`fs.unlinkSync(${e})`,0);Ne.unlinkSync(e)}catch(P){var U=P,H=1}finally{y(h,U,H)}},renameSync(e,u){let P=[];try{const h=E(P,w`fs.renameSync(${e} ${op} ${u})`,0);Ne.renameSync(e,u)}catch(U){var H=U,V=1}finally{y(P,H,V)}},readlinkSync(e){let h=[];try{const u=E(h,w`fs.readlinkSync(${e})`,0);return Ne.readlinkSync(e)}catch(P){var U=P,H=1}finally{y(h,U,H)}},realpathSync(e){let h=[];try{const u=E(h,w`fs.realpathSync(${e})`,0);return _(Ne.realpathSync(e))}catch(P){var U=P,H=1}finally{y(h,U,H)}},mkdirSync(e,u){let U=[];try{const h=E(U,w`fs.mkdirSync(${e})`,0);let P={recursive:!0};if(u?.mode!==void 0)P.mode=u.mode;try{Ne.mkdirSync(e,P)}catch(ae){if(n(ae)!=="EEXIST")throw ae}}catch(H){var V=H,z=1}finally{y(U,V,z)}},readdirSync(e){let h=[];try{const u=E(h,w`fs.readdirSync(${e})`,0);return Ne.readdirSync(e,{withFileTypes:!0})}catch(P){var U=P,H=1}finally{y(h,U,H)}},rmSync(e,u){let P=[];try{const h=E(P,w`fs.rmSync(${e})`,0);Ne.rmSync(e,u)}catch(U){var H=U,V=1}finally{y(P,H,V)}},createWriteStream(e){return Ne.createWriteStream(e)},async readFileBytes(e,u){if(u===void 0)return bl(e);let h=await po(e,qt());try{if(!(await h.stat()).isFile())return Buffer.alloc(0);return await bt(h,u,"file")}finally{await h.close()}},async readFileFdGated(e,u){try{let h=sp();if(h===0){if(!(await ii(e)).isFile())return null}let P=await po(e,Ne.constants.O_RDONLY|h);try{let U=await P.stat();if(!U.isFile()||U.size>u)return null;let H=Number(U.size),V=Buffer.allocUnsafe(H),z=0;while(z<H){let{bytesRead:ae}=await P.read(V,z,H-z,z);if(ae===0)break;z+=ae}return{content:(z<H?V.subarray(0,z):V).toString("utf8"),stats:U}}finally{await P.close()}}catch{return null}}};function i(){return Pl}var Eb=a({hasThrown:!1},(e)=>{e.hasThrown=!1}),Rb=a(new Set,(e)=>e.clear()),wb=a({},(e)=>{e.directory=void 0});var vp=524288;async function bt(e,u,h,P=0){let U=h!==void 0?h==="file":(await e.stat()).isFile(),H=[],V=0,z=oi();try{let ae=U&&P>z.length?Buffer.alloc(Math.min(P,u)):void 0;while(V<u){let le=ae!==void 0&&V<ae.length,we=le?ae.subarray(V,V+vp):z.subarray(0,u-V),{bytesRead:Re}=await e.read(we,0,we.length,U?V:null);if(Re===0)break;if(!le)H.push(Buffer.from(we.subarray(0,Re)));V+=Re}if(ae!==void 0){if(H.length===0)return ae.subarray(0,V);H.unshift(ae)}}finally{si(z,V)}return Buffer.concat(H,V)}function Tn(e,u,h){let P=[],U=0,H=oi();try{while(U<u){let V=H.subarray(0,u-U),z=Ne.readSync(e,V,0,V.length,h==="file"?U:null);if(z===0)break;P.push(Buffer.from(V.subarray(0,z))),U+=z}}finally{si(H,U)}return Buffer.concat(P,U)}function xp(e,u){let P=[];try{const h=E(P,w`fs.lstatSync(${e})`,0);return u?Ne.lstatSync(e,u):Ne.lstatSync(e)}catch(U){var H=U,V=1}finally{y(P,H,V)}}var Cp=new Set(["EPIPE","EIO","ENXIO","EBADF"]);var Ep=new Set([...Cp,"ECONNABORTED","ECONNRESET","ENOTCONN","EOF"]);function Rp(e,u,h){if(e.destroyed||e.writableEnded)return"dropped";return e.write(u,h)===!1?"backed-up":"accepted"}class ui{everWritten=!1;drainPromise=void 0;bytesQueued=0;bytesFlushed=0;notifyFlushProgress=void 0;notifyExternallyClocked=void 0;externallyClockedPromise=void 0;externallyClocked=!1;errored=!1;fullDiskCode=void 0;readerGoneAt=null;flushConfirmedPromise=void 0;flushCloseListener=void 0;frameBeingWritten=void 0;markEverWritten(){this.everWritten=!0}recordQueued(e){this.bytesQueued+=e}recordFlushed(e){this.bytesFlushed+=e,this.notifyFlushProgress?.()}markErrored(e){if(this.errored=!0,e==="ENOSPC"||e==="EDQUOT")this.fullDiskCode??=e;if(e!==void 0&&Ep.has(e))this.readerGoneAt??=Date.now();this.notifyFlushProgress?.()}getFullDiskCode(){return this.fullDiskCode}getReaderGoneAt(){return this.readerGoneAt}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((u)=>e.end(u))}return this.drainPromise}fullyFlushed(){if(this.flushConfirmedPromise===void 0)this.flushConfirmedPromise=new Promise((e)=>{let u=()=>{if(this.outstandingBytes()<=0)this.notifyFlushProgress=void 0,e()};this.notifyFlushProgress=u,this.flushCloseListener=u,process.stdout.once("close",u),u()});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 ui)}}var Nb=new ui;var Ll=1048576,wp=1e4,Ap=gn((e)=>e());class di{unflushed={length:0,since:0};droppedCount=0;droppedTotal=0;write(e,u){let h=this.unflushed;if(u&&h.length>=Ll&&(this.droppedCount>0||Date.now()-h.since>=wp)){this.droppedCount++,this.droppedTotal++;return}let P="writing",U=()=>{let V=P==="unflushed";if(P="flushed",V)h.length-=e.length,this.reportDropped()};if(Ap(()=>Rp(process.stderr,e,U))==="backed-up"&&P==="writing"){if(P="unflushed",h.length===0)h.since=Date.now();h.length+=e.length}}giveUpOnUnflushed(){this.unflushed={length:0,since:0},this.reportDropped()}getDroppedTotal(){return this.droppedTotal}reset(){Object.assign(this,new di)}reportDropped(){if(this.droppedCount>0&&this.unflushed.length<Ll){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.]
`,!1)}}}var Tp=a(new di,(e)=>e.reset());function Dl(e,{mayDrop:u=!1}={}){Tp.write(e,u)}function mr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ct(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Z(e,u,h=u+"s"){return e===1?u:h}function kn(e){let u=0;for(let h=0;h<e.length;h++){let P=e.charCodeAt(h);if(P>=55296&&P<=56319&&h+1<e.length){let U=e.charCodeAt(h+1);if(U>=56320&&U<=57343)h++}u++}return u}function se(e,u){if(u<=0)return"";if(e.length<=u)return e;let h=e.slice(0,u),P=h.charCodeAt(u-1);return At(P>=55296&&P<=56319?h.slice(0,-1):h)}function vn(e,u){if(u<=0)return"";if(e.length<=u)return e;let h=e.slice(-u),P=h.charCodeAt(0);return At(P>=56320&&P<=57343?h.slice(1):h)}function At(e){if(typeof Buffer<"u")return Buffer.from(e,"utf16le").toString("utf16le");return Op(e)}function Op(e){let h=[];for(let P=0;P<e.length;P+=8192){let U=Math.min(P+8192,e.length),H=new Uint16Array(U-P);for(let V=P;V<U;V++)H[V-P]=e.charCodeAt(V);h.push(String.fromCharCode(...H))}return h.join("")}var Pp=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/,Ml=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,ho=typeof String.prototype.isWellFormed==="function"?Function.prototype.call.bind(String.prototype.isWellFormed):void 0,Il=typeof String.prototype.toWellFormed==="function"?Function.prototype.call.bind(String.prototype.toWellFormed):void 0;function it(e){if(ho)return ho(e);return!Pp.test(e)}function hr(e){if(Il)return Il(e);return e.replace(Ml,"�")}function Ot(e){if(ho&&ho(e))return e;return e.replace(Ml,"")}function Xt(e,u){let h=e.indexOf(u);return h===-1?e:e.slice(0,h)}function xn(e,u){let h=e.length;while(h>0&&u.includes(e[h-1]))h--;return e.slice(0,h)}function _r(e){let u=Math.max(e.lastIndexOf(`
`),e.lastIndexOf("\r"),e.lastIndexOf("\u2028"),e.lastIndexOf("\u2029")),h=e.indexOf(":",u+1);return h===-1?e:e.slice(0,h)}function Sr(e,u){return e.endsWith(u)?e.slice(0,e.length-u.length):e}function Er(e,u,h=0){let P=0,U=e.indexOf(u,h);while(U!==-1)P++,U=e.indexOf(u,U+1);return P}var Fl=/[\x00-\x08\x0E-\x1F\x7F-\x9F]/g;function Nl(e){return e.replace(Fl,"").replace(/\s+/g," ").trim()}var Lp=/[\t\n\v\f\r\u2028\u2029]/g,Hb=new RegExp(`${Fl.source}|${Lp.source}`);function Dp(e){return e.replace(/[\p{Cc}\p{Cf}\p{Cs}\p{Default_Ignorable_Code_Point}\u2028\u2029]/gu,"")}var Ip=/[\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 Mp(e){if(!/[\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}\u2028\u2029]/gu.test(e))return e;let h=/(^\u{1F3F4}\u{E0067}\u{E0062}(?:\u{E0065}\u{E006E}\u{E0067}|\u{E0073}\u{E0063}\u{E0074}|\u{E0077}\u{E006C}\u{E0073})\u{E007F}$|\p{Extended_Pictographic}(?:\uFE0E|[\uFE0F\u{1F3FB}-\u{1F3FF}]?(?:\u200D(?=\p{Extended_Pictographic}))?)|^[#*0-9]\uFE0F(?=\u20E3$))|[\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}\u2028\u2029]/gu,P="";for(let{segment:U}of new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(e))P+=U.replace(h,(H,V)=>{if(V!==void 0||H===`
`||H==="\t")return H;let z=H.codePointAt(0)??0;if(z===27)return"␛";if(z<32)return String.fromCodePoint(9216+z);if(z===127)return"␡";return`\\u{${z.toString(16).toUpperCase()}}`});return P}function Zt(e){return Mp(e).replace(/\n/g,"").replace(/\t/g,"␉")}function yr(e,u){return se(v(e),u)}function v(e){return Dp(Nl(e.replace(Ip,""))).trim()}var Fp=8;function Dn(e,u=0){if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e)){if(u>=Fp)return;let h=[];for(let P of e){let U=P===null||P===void 0?"":Dn(P,u+1);if(U===void 0)return;h.push(U)}return h.join(",")}return typeof e==="object"&&e!==null&&Object.getPrototypeOf(e)===Object.prototype&&!Object.hasOwn(e,"toString")?"[object Object]":void 0}function Ul(e){return/^(?:0|[1-9]\d{0,9})$/.test(e)&&Number(e)<4294967295}var Np=16,jb=6*Np;var Hl=a({},(e)=>{e.limits=void 0});function Up(){return Hl.limits!==void 0}function Bl(e){return Hl.limits?.onPast(e),Up()}var Kl="˹-˼⌌-⌏⌜-⌟⎛-⏌⏜-⏡⸀-⸍⸜⸝─-╿",Hp=new Map([["˂","<"],["˃",">"],["ᐳ",">"],["ᐸ","<"],["ᚲ","<"],["‹","<"],["›",">"],["≮","<"],["≯",">"],["≺","<"],["≻",">"],["⊀","<"],["⊁",">"],["⋖","<"],["⋗",">"],["〈","<"],["〉",">"],["❬","<"],["❭",">"],["❮","<"],["❯",">"],["❰","<"],["❱",">"],["⟨","<"],["⟩",">"],["⦑","<"],["⦒",">"],["⦓","<"],["⦔",">"],["⧼","<"],["⧽",">"],["⩹","<"],["⩺",">"],["⪦","<"],["⪧",">"],["〈","<"],["〉",">"],["︿","<"],["﹀",">"],["﹤","<"],["﹥",">"],["<","<"],[">",">"],["\uD81B\uDF3F",">"],["\uD834\uDE36","<"],["\uD834\uDE37",">"]]);var ci=new Map([...Hp,...Array.from("≪⋘⪡⫷⟪︽",(e)=>[e,"<"]),...Array.from("≫⋙⪢⫸⟫︾",(e)=>[e,">"])]),Bp=new Map([...ci,["《","<"],["》",">"]]),Jb=new Set(`⦒⦔⩺⪧${"≫⋙⪢⫸⟫︾"}`);function br(e){let u=e;for(let[h,P]of Bp)if(P===e)u+=h;return u}var Qb=new RegExp(`[${Kl}]|(?![\\x00-\\x7f])[\\p{Sm}\\p{Sk}\\p{So}]`,"gu"),ek=new RegExp(`[${[...ci.keys()].join("")}]`,"gu");var Kp=[[173,173],[847,847],[1564,1564],[4447,4448],[6068,6069],[6155,6159],[8203,8207],[8234,8238],[8288,8303],[12644,12644],[65024,65039],[65279,65279],[65440,65440],[65520,65531],[69759,69759],[78896,78911],[94180,94180],[113824,113827],[119155,119162],[917504,921599]],Qt=Kp.map(([e,u])=>e===u?`\\u{${e.toString(16)}}`:`\\u{${e.toString(16)}}-\\u{${u.toString(16)}}`).join("");var Wl=`${Qt}\\u2800`,Q=`\\p{Cc}\\p{Cf}\\p{Cs}\\p{Co}\\p{Cn}\\u2028\\u2029${Wl}`,mo=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`,jl=String.raw`\u0600-\u0605\u06dd\u070f\u0890\u0891\u08e2`,pi=`[${mo}${jl}\\ufeff]*`,Gl=new RegExp(`[${mo}${jl}\\ufeff]`);function Br(e,u=pi){return e.replace(/([a-z)])(?=[a-z(\[])/gi,`$1${u}`).replace(/\[_-\]\?/g,`(?:[_-]${u})?`)}var mk=new RegExp(`[${Q}]+`,"gu"),gi="\\u200D\\uFE0E\\uFE0F",Sk=new RegExp(`(?:(?![${gi}])[${Q}])+`,"gu"),yk=new RegExp(`(?:(?![${gi}\\n])[${Q}])+`,"gu"),_k=new RegExp(`(?<!\\S)[${gi}]+`,"gu");var bk=new RegExp(`[${Q}]`,"u");var Hr="[\\p{M}\\u1160-\\u11FF\\uD7B0-\\uD7FF]",kk=new RegExp(`(?<![\\p{L}\\p{N}\\p{M}])${Hr}|${Hr}{9}|\\p{Soft_Dotted}\\p{M}*\\u0307|[\\u0131\\u0237]\\p{M}|(?<=[\\p{sc=Latin}\\p{sc=Common}]${Hr}*)(?!\\p{sc=Inherited})${Hr}`,"u");var vk=new RegExp(`\\u20E3|\\u263A${Hr}`,"u");var Wp=new RegExp(`[\\p{Cf}\\p{Co}\\p{Cn}\\u2028\\u2029\\u007F-\\u009F${Wl}]`,"gu");function jp(e){let u=e.replace(/[\p{Cf}\p{Co}\p{Cn}]/gu,"");return u=u.replace(/[\u200B-\u200F]/g,"").replace(/[\u202A-\u202E]/g,"").replace(/[\u2066-\u2069]/g,"").replace(/[\uFEFF]/g,"").replace(/[\uE000-\uF8FF]/g,""),u}function Gp(e){let u=Ot(e);for(let h=0;h<10;h++){let P=jp(u);if(P===u)return u;u=P}return u}function $p(e){return!/[^\0-\x7f]/.test(e)}function Vp(e){if($p(e))return e;let u=e,h="",P=0,U=10;while(u!==h&&P<U)h=u,u=ys(u),u=Gp(u),P++;if(P>=U)throw Error(`Unicode sanitization reached maximum iterations (${U}) for input: ${e.slice(0,100)}`);return u}function je(e){if(typeof e==="string")return Vp(e);if(Array.isArray(e))return e.map(je);if(e!==null&&typeof e==="object"){let u={};for(let[h,P]of Object.entries(e)){let U=je(h);if(U!=="__proto__"&&(U===h||!Ul(U)||Number(U)<64||!Bl("cleaned_key")))u[U]=je(P)}return u}return e}function Rt(e){return e.replace(/[\p{Cc}\p{Cf}\u2028\u2029]+/gu," ")}function $l(e){return e.replace(Wp,(u)=>Array.from({length:u.length},(h,P)=>`\\u${u.charCodeAt(P).toString(16).padStart(4,"0")}`).join(""))}function Vl(e){return e.split("").map((u)=>"\\u"+u.charCodeAt(0).toString(16).padStart(4,"0")).join("")}function ql(e){let u=new Int32Array(e.length);for(let h=0;h<e.length;h++)u[h]=h;return{text:e,origin:u}}function zl(e,u,h){let P=[];for(let U of e.text.matchAll(u)){let{keep:H,insert:V,keepEnd:z=0}=h(U),ae=U.index??0,le=U[0].length,we=Math.min(Math.max(H|0,0),le),Re=Math.min(Math.max(z|0,0),le-we);P.push([ae+we,ae+le-Re,V])}return So(e,P)}function So(e,u){if(u.length===0)return e;let{text:h,origin:P}=e,U=h.length;for(let[le,we,Re]of u)U+=Re.length-(we-le);let H=new Int32Array(U),V=[],z=0,ae=0;for(let[le,we,Re]of u)V.push(h.slice(z,le)),H.set(P.subarray(z,le),ae),ae+=le-z,V.push(Re),H.fill(-1,ae,ae+Re.length),ae+=Re.length,z=we;return V.push(h.slice(z)),H.set(P.subarray(z),ae),{text:V.join(""),origin:H}}function T(e,u){let h=e[u];if(h===void 0){let P=TypeError("Read an index that holds nothing");throw Error.captureStackTrace?.(P,T),P}return h}function qp(e){return T(e,e.length-1)}function Jl(e){let u=qp(e);return e.pop(),u}function at(e){let u=0;while(u<e.length&&e.charCodeAt(u)<=32)u++;let h=e.slice(u),P=/^([A-Za-z0-9][A-Za-z0-9+.-]*):\/\//.exec(h),U=P?.[1]?.toLowerCase(),H=P?h.slice(P[0].length):h,V=H.indexOf(":"),z=H.indexOf("/");if(!(U!==void 0?U!=="file":V!==-1&&(z===-1||V<z)&&!/^[A-Za-z]:/.test(H))){let Ie=P?Kr(H):H;return Ie.includes("@[")||Ie.startsWith("[")}let le=Kr(H),we=P?/^(?:[^@/?#\\[\]]+@)?(\[[0-9A-Fa-f:.]+\])(?::\d*)?(?=\/|$)/.exec(le):/^[^@:/[\]]+@(\[[0-9A-Fa-f:.]+\])(?=:)/.exec(le),Re=we!==null&&!!Se(`ssh://${we[1]}/`)?.hostname;return/[[\]]/.test(le.slice(Re?we[0].length:0))}function Se(e){try{return new URL(e)}catch{return null}}function Kr(e){return e.replace(/%([0-9A-Fa-f]{2})/g,(u,h)=>{let P=parseInt(h,16);return P===0?u:String.fromCharCode(P)})}function lt(e,{asRewritten:u=!1}={}){let h=e.trimStart(),P=/^([A-Za-z][A-Za-z0-9+.-]*):\/\//.exec(h);if(P){let U=P[1]?.toLowerCase();if(U==="file")return null;if(U==="http"||U==="https"){let H=Se(h);return H?.hostname?{host:H.hostname,path:H.pathname}:null}return Yl(wt(h.slice(P[0].length)),"/")}return Yl(u?wt(h):h,":")}function Zl(e,u){let h=e.indexOf("@["),P=h===-1?0:h+1,U=e[P]==="["?P:-1,H=U===-1?-1:e.indexOf("]",U+1),V=e.indexOf(u,H===-1?0:H+1);return{open:U,close:H,cut:V}}function Yl(e,u){let{open:h,close:P,cut:U}=Zl(e,u),H=h===-1?0:h,V=e.indexOf("/");if(u===":"&&(U===-1||V!==-1&&V<e.indexOf(":")))return null;let z=U===-1?"":e.slice(u===":"?U+1:U);if(P!==-1){let Re=e.slice(P+1,U===-1?e.length:U),Ie=e.slice(0,H)+e.slice(H+1,P),Me=Xl(Re)!==Re?Ie:Xl(Ie),Ae=Me.slice(Me.lastIndexOf("@")+1),Ve=Se(`ssh://[${Ae}]/`)?.hostname;return Ae?{host:Ve||Ae,path:z}:null}let ae=U===-1?e:e.slice(0,U),le=ae.slice(ae.lastIndexOf("@")+1);if(le.startsWith("["))return null;let we=u==="/"?le.replace(/:\d*$/,""):le;return we?{host:we,path:z}:null}function Ql(e){let{text:u,from:h}=zp(e),{close:P,cut:U}=Zl(u,"/"),H=U===-1?u.length:U,V=[],z=(ae,le)=>{let we=u.lastIndexOf("@",le-1);if(we>=ae)V.push([h(ae),h(we)])};if(P===-1)z(0,H);else z(0,P),z(P+1,H);return V}function wt(e){return e.replace(/(?:%(?!00)[0-9A-Fa-f]{2})+/g,(u)=>{try{return decodeURIComponent(u)}catch{return Kr(u)}})}function zp(e){if(!e.includes("%"))return{text:e,from:(U)=>U};let u=[],h="",P=0;for(let U of e.matchAll(/(?:%(?!00)[0-9A-Fa-f]{2})+/g)){for(let le=P;le<U.index;le++)u.push(le);h+=e.slice(P,U.index);let H,V;try{H=decodeURIComponent(U[0]),V=Array.from(H,(le)=>{let we=le.codePointAt(0);return we<128?1:we<2048?2:we<65536?3:4})}catch{H=Kr(U[0]),V=Array.from(H,()=>1)}let z=U.index,ae=0;for(let le of V){let we=H.codePointAt(ae)>65535?2:1;for(let Re=0;Re<we;Re++)u.push(z);ae+=we,z+=3*le}h+=H,P=U.index+U[0].length}for(let U=P;U<=e.length;U++)u.push(U);return{text:h+e.slice(P),from:(U)=>u[U]}}function Xl(e){let u=e.indexOf(":"),h=e.slice(u+1);if(u===-1||!/^[ \t\n\v\f\r]*[+-]?\d+$/.test(h))return e;let P=Number.parseInt(h.trim(),10);return P>=0&&P<65536?e.slice(0,u):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,ru=/(?:^|[^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,ou=/\[REDACTED|\*\*\*:\*\*\*/g,su=`@|%40|${ou.source}`,ig=64,ag=2048,lg=/[\s"'`]/g;function iu(e){let u=[],h=ut(e,lg),P=0;for(let U=e.indexOf("://");U!==-1;){let H=U+3;if(U>=P&&ru.test(e.slice(Math.max(0,U-8),U))){P=Math.min(h(H),H+ag);for(let[V,z]of Ql(e.slice(H,P)))u.push([H+V,H+z])}U=e.indexOf("://",H)}return u}function ug(e){let u=[],h=[];if(!e.includes("://"))return{spans:u,hostParts:h};let P=ut(e,Jp),U=ut(e,/\//g),H=fi(e,Xp),V=ut(e,Qp),z=ut(e,/\//g),ae=ut(e,sg),le=ut(e,/[/?#]/g),we=ut(e,tg),Re=ut(e,/@/g),Ie=ut(e,/%40/gi),Me=ut(e,ou),Ae=ut(e,/[:%]/g),Ve=ut(e,/["'`,;|&<>{}()]/g),Je=nu(e,!1),Pe=nu(e,!0);for(let Ue=e.indexOf("://");Ue!==-1;){let Oe=Ue+3,xt=e.indexOf("://",Oe),Xe=P(Oe),Mt=Re(Oe),Ye;if(eg.test(e.slice(Math.max(0,Ue-8),Ue))){let Le=Math.min(le(Oe),Xe),ct=Math.min(we(Oe),Le);if(Ye=Mt<Le?Math.max(Je(Oe,Le),Pe(Mt,Le)):Math.max(Je(Oe,Math.min(U(Oe),Xe)),Pe(Oe,ct)),Ye<=Oe){let Lt=Math.min(Le,ae(Oe));h.push({start:Oe,fieldEnd:Math.min(ct,Lt),lastEncodedAt:Pe(Oe,Lt)})}}else{let Le=Math.min(U(Oe),Xe),ct=Math.min(Xe,xt===-1?e.length:xt),Lt=ru.test(e.slice(Math.max(0,Ue-8),Ue)),Ft=Lt?H(Oe):null,qn=Lt?Zp.exec(e.slice(Oe,Oe+3)):null,Pi=[[qn!==null?Oe+qn[0].length:-1,ct],[Ft!==null&&Ft.index<ct?Ft.index+Ft[0].length:-1,Xe]];for(let[Nt,fn]of Pi){let Li=Nt===-1?Xe:V(Nt);if(Li<fn)Le=Math.max(Le,Math.min(z(Li),Xe))}Ye=Math.max(Je(Oe,Le),Pe(Oe,Le))}if(Ye>Oe)u.push({start:Oe,end:Ye,separatorEnd:Ye+(e[Ye]==="@"?1:3),loginEnd:Mt<=Ye?Mt:Math.min(Ie(Oe),Ye)});else{let Le=Me(Oe);if(Le>Oe&&Le<Math.min(Xe,U(Oe),Ve(Oe))&&Ae(Oe)<Le)u.push({start:Oe,end:Le,separatorEnd:Le,loginEnd:Le})}Ue=xt}return{spans:u,hostParts:h}}function au(e,u){let{spans:h,hostParts:P}=ug(e);if(h.length===0&&P.length===0)return[];let U=u(),H=ut(e,/[\s"'>}|,;&`)\]]/g),V=ut(e,/\s/g),z=[],ae=[];for(let Ae of h)z.push({start:Ae.start,end:Ae.end,loginEnd:Ae.loginEnd}),ae.push({...Ae,userinfo:Ae});let le=yo(e,U);for(let Ae of P){let Ve=le(Ae.start)[0];if(Ve&&Ve.keyStart<Ae.fieldEnd&&e.slice(Ae.start,Ve.keyStart).includes("%")){let Je=Ae.lastEncodedAt>Ve.keyStart?Ae.lastEncodedAt:Ve.valueStart;z.push({start:Ae.start,end:Je,loginEnd:Je}),ae.push(Je>Ve.valueStart?{start:Ae.start,end:Je,userinfo:{start:Ae.start,end:Je,separatorEnd:Je+3,loginEnd:Je}}:{start:Ae.start,end:Je})}}if(ae.length===0)return[];z.sort((Ae,Ve)=>Ae.start-Ve.start);let we=yo(e,U),Re=0;for(let Ae=0,Ve=we(Ae);Ve[0]!==void 0;){let Je,Pe=null;for(let Oe of Ve)if(Pe=Oe.valueEnd(),Pe!==null){Je=Oe;break}if(Je===void 0||Pe===null){Ae=Ve[0].keyStart+1,Ve=we(Ae);continue}while(Re<z.length&&T(z,Re).start<=Je.keyStart)Re++;let Ue=z[Re];if(Ue!==void 0&&Ue.start<Pe){let Oe=e[Je.valueStart]??"",Xe=(Oe==='"'||Oe==="'")&&Pe-1>Je.valueStart&&e[Pe-1]===Oe?Math.max(Pe,Ue.end):V(Math.max(Pe,Ue.end,H(Ue.loginEnd+1)));ae.push({start:Je.valueStart,end:Xe})}Ae=Pe,Ve=we(Ae)}let Ie={nextKey:yo(e,U),plainKeys:yo(e,U),nextLineEnd:ut(e,Yp),span:0,lineEnd:-1,resumeAt:0,overflowEnd:pg(e,()=>Ie.lineEnd)},Me=[];for(let Ae of fg(ae)){let Ve=Me.at(-1);Me.push(Ve!==void 0&&Ae.start<Ve.end?tu(e,{start:Jl(Me).start,end:Math.max(Ve.end,Ae.end)},Ie):tu(e,Ae,Ie))}return Me.map((Ae)=>Ae.userinfo?Ae:gg(e,Ae))}var eu=new WeakMap;function dg(e){let u=eu.get(e);if(!u)u={word:new RegExp(e.word,"gi"),notTail:new RegExp(`(?!${e.tail})[^]`,"gi"),separator:new RegExp(e.separator,"iy"),value:new RegExp(e.value,"iy")},eu.set(e,u);return u}function yo(e,u){let h=u.map((P)=>{let{word:U,notTail:H,separator:V,value:z}=dg(P),ae=fi(e,U),le=ut(e,H),we=-1,Re=-1,Ie=-1,Me=null,Ae=(Ue)=>{if(Ue!==Ie)Ie=Ue,z.lastIndex=Ue,Me=z.test(e)?z.lastIndex:null;return Me},Ve=(Ue)=>{if(Ue!==we)we=Ue,V.lastIndex=Ue,Re=V.test(e)?V.lastIndex:-1;return Re},Je=-1,Pe=null;return(Ue)=>{if(Je!==-1&&Ue>=Je&&(Pe===null||Ue<=Pe.keyStart))return Pe;Je=Ue,Pe=null;for(let Oe=ae(Ue);Oe!==null;){let xt=Oe.index+Oe[0].length,Xe=Ve(P.tail?le(xt):xt);if(Xe!==-1){Pe={keyStart:Oe.index,valueStart:Xe,valueEnd:()=>Ae(Xe)};break}Oe=ae(Oe.index+1)}return Pe}});return(P)=>{let U=[];for(let H of h){let V=H(P);if(V&&(!U[0]||V.keyStart<=U[0].keyStart))U=U[0]&&V.keyStart===U[0].keyStart?[...U,V]:[V]}return U}}function tu(e,u,h){if(u.userinfo&&cg(e,u.userinfo,h))return u;let P=u.end;h.resumeAt=Math.max(h.resumeAt,u.start);for(let U=h.nextKey(h.resumeAt);U[0]!==void 0&&U[0].keyStart<P;){let H=U[0].keyStart;if(H>h.lineEnd){let le=h.nextLineEnd(H);h.span=ig*(le-h.lineEnd),h.lineEnd=le}let V=null,z=U[0];for(let le of U)if(V=le.valueEnd(),V!==null){z=le;break}let ae=V??z.valueStart;if(h.span-=ae-H,h.span<0)return{start:u.start,end:Math.max(P,h.overflowEnd(u.start))};P=Math.max(P,ae),h.resumeAt=z.valueStart,U=h.nextKey(h.resumeAt)}return P===u.end?u:{start:u.start,end:P}}function cg(e,u,h){if(e[u.end]!=="@"||rg.test(e.slice(u.start,u.end))||!ng.test(e.slice(Math.max(0,u.start-36),u.start-3)))return!1;for(let P=h.plainKeys(u.start);P[0]!==void 0&&P[0].keyStart<u.end;P=h.plainKeys(P[0].keyStart+1))if(P.some((U)=>U.valueStart===u.end))return!1;return!0}function pg(e,u){let h=ut(e,/["'`]/g),P=-1,U=e.length;return(H)=>{if(u()!==P)P=u(),U=h(H)<P?e.length:P;return U}}function gg(e,u){let h=e[u.end-1];if(h===void 0||!og.test(h))return u;return(e.slice(u.start,u.end).split(h).length-1)%2===1?{start:u.start,end:u.end-1}:u}function fg(e){e.sort((h,P)=>h.start-P.start||P.end-h.end);let u=[];for(let h of e){let P=u.at(-1);if(P===void 0||h.start>=P.end)u.push(h);else u[u.length-1]={start:P.start,end:Math.max(P.end,h.end)}}return u}function ut(e,u){let h=fi(e,u);return(P)=>h(P)?.index??e.length}function fi(e,u){let h=-1,P=null;return(U)=>{if(h===-1||U<h||P!==null&&U>P.index)u.lastIndex=U,P=u.exec(e),h=U;return P}}function nu(e,u){let h=u?"%40":"@",P=new Int32Array(16),U=0,H=0;return(V,z)=>{let ae=Math.min(z,e.length)-h.length;while(H<=ae){let Ie=e.indexOf(h,H);if(Ie===-1){H=e.length;break}if(U===P.length){let Me=new Int32Array(U*2);Me.set(P),P=Me}P[U++]=Ie,H=Ie+1}let le=0,we=U;while(le<we){let Ie=le+we>>>1;if(P[Ie]<=ae)le=Ie+1;else we=Ie}let Re=le===0?-1:P[le-1];return Re>=V?Re:-1}}class hi{heads=new Uint32Array(1024);rows=Array(1024);takesEveryText=!1;constructor(e,u){for(let[h,P]of[[e,!1],[u,!0]])for(let U of h){let H=hg(U);this.takesEveryText||=H===null;for(let V of H??[]){let z=(V.charCodeAt(0)&31)<<5|V.charCodeAt(1)&31;this.heads[z]|=V.length===2?4294967295:1<<(V.charCodeAt(2)&31),(this.rows[z]??=[]).push({text:P?V.toLowerCase():V,isAnyCase:P})}}}test(e){if(this.takesEveryText)return!0;let{heads:u}=this,{length:h}=e,P=0;for(let U=0;U<h;U++){let H=e.charCodeAt(U);if(H>127||(u[P]>>>(H&31)&1)!==0&&this.standsAt(P,e,U-2))return!0;P=(P<<5|H&31)&1023}return u[P]===4294967295&&this.standsAt(P,e,h-2)}standsAt(e,u,h){for(let P of this.rows[e]){let U=P.text.length-1;while(U>=0){let H=u.charCodeAt(h+U);if((P.isAnyCase&&H>=65&&H<=90?H+32:H)!==P.text.charCodeAt(U))break;U--}if(U<0)return!0}return!1}}function hg(e){let u={source:e,at:0},h=lu(u);return h!==null&&u.at===e.length&&h.every((P)=>P.length>=2)?h:null}function lu(e){let u=[],h=[""];for(;;){let P=e.source[e.at];if(P===void 0||P===")"||P==="|"){if(u.push(...h),P!=="|")return u;e.at++,h=[""];continue}let U=mg(e);if(U===null)return null;if(e.source[e.at]==="?")e.at++,U.push("");h=h.flatMap((H)=>U.map((V)=>H+V))}}function mg(e){let{source:u}=e;if(u.startsWith("(?:",e.at)){e.at+=3;let U=lu(e);return u[e.at++]===")"?U:null}if(u[e.at]==="["){let U=u.indexOf("]",e.at),H=[];for(let V=e.at+1;V<U;V++){let z=u.charCodeAt(V);if(u[V+1]==="-"&&V+2<U)V+=2;for(let ae=z;ae<=u.charCodeAt(V);ae++)H.push(String.fromCharCode(ae));if("\\^[".includes(String.fromCharCode(z))||"\\^[".includes(u[V])||u.charCodeAt(V)>127)return null}return e.at=U+1,H.length>0?H:null}let h=e.at;while(h<u.length&&!"\\^$.*+?()[]{}|".includes(u.charAt(h))&&u.charCodeAt(h)<=127)h++;if(u[h]==="?"&&h-e.at>1)h--;if(h>e.at){let U=u.slice(e.at,h);return e.at=h,[U]}let P=u[e.at+1]??"";if(u[e.at]!=="\\"||!"\\^$.*+?()[]{}|/-".includes(P))return null;return e.at+=2,P===""?null:[P]}function uu(e){let u=e.keys().next();if(!u.done)e.delete(u.value)}var vo=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`,_i="Bearer|Basic",du={operations:33792,code:16605},Sg=2097152,vu={run:pi,members:mo,room:{operations:384912,code:425553},roomForEscapedKeys:{operations:577280,code:638329}},yg={run:"",members:"",room:{operations:114048,code:24907},roomForEscapedKeys:{operations:171072,code:37360}},_g=new RegExp(`[\\x00-\\x7f\\s\\u0085]${Gl.source}`);class Ht{build;roomOf;withoutInvisibles;withInvisibles;static thisRun;constructor(e,u=(h)=>h.room){this.build=e;this.roomOf=u}for(e){return _g.test(e)?this.withInvisibles??=this.make(vu):this.withoutInvisibles??=this.make(yg)}make(e){let u=this.roomOf(e);if(u===void 0||typeof Bun>"u"||!("transfer"in ArrayBuffer.prototype)||Hs())return this.build(e);if(Ht.thisRun?.refusal!==void 0)throw Ht.thisRun.refusal;let h=this.build(e),P=[],U;try{for(let[H,V]of[[du.operations,u.operations],[du.code,u.code]])for(let z=H;;z=Math.floor(z*1.5))if(P.push(new ArrayBuffer(Math.min(z,V))),z>=V)break;if(Ht.thisRun===void 0)P.push(new ArrayBuffer(Sg))}catch(H){U=H}for(let H of P)H.transfer(0);if(Ht.thisRun===void 0)queueMicrotask(()=>{Ht.thisRun=void 0});if(Ht.thisRun={refusal:U},U!==void 0)throw U;return h}}function xu({members:e}){return`[\\s\\u0085${e}]`}var cu="[^\\s\\u0085,;&}\\])]+",pu="(?![\\w\\[({$/+=~!@%^?\\\\-])",xo="\\n\\r\\x0b\\x0c\\u0085\\u2028\\u2029",cn="[\\s\\u0085]",zk=new RegExp(xu(vu)),Jk=new RegExp(`(?:[=:]|["']|\\b(?:${Br("bearer|basic")}))$`,"i"),bg=`\\\\+(?:"[^"${xo}]*(?<!\\\\)(?=\\\\+")|'[^'${xo}]*(?<!\\\\)(?=\\\\+'))`,gu=`[^\\s\\u0085,;&})"'\\\\]+`,bi="AWS|GOOGLE|GCP|GCLOUD|AZURE",Ut="[\\w=-]",nn=`${Ut}{20,}(?:\\.[0-9a-z]{9})?`,kg="[\\w.-]{0,256}(?![\\w.-])",fu=`${cn}*(?!${cn})`;function Gr(e){let{run:u,members:h}=e,P=Br(vo,u),U=xu(e),H=`(?:${Br(_i,u)})${h&&`[${h}]*`}[\\s\\u0085]+`,V=`"[^"${xo}]*"|'[^'${xo}]*'|"[^"]*"${pu}|'[^']*'${pu}|[^\\s-]{0,4}\\[REDACTED\\]['"\`]?|${H}(?:\\[REDACTED\\]|${cu})|${cu}`,z=`(?:${P})${kg}`,ae=`\\b(?:${Br(bi,u)})${u}_\\w+`,le=`[^\\s\\u0085,;&}\\])"']{0,64}?(?:${z}|${ae})`;return{sensitiveKeyWord:P,authScheme:H,sensitiveAssign:`${z}(?:${u}["'])?${U}*[=:]${fu}(${V})`,cloudEnvVar:`${ae}${U}*[=:]${cn}*(${V})`,sensitiveAssignEscaped:`${z}${u}\\\\+["']${U}*[=:]${fu}(${bg}|${H}${gu}|${gu}|\\\\+["'][^\\s\\u0085,;&})"'\\\\]*)`,nextKey:`(?:${H})?(?:[{[(]{0,8}(?:"${le}"|'${le}')|${le})${U}*[=:]`,nextKeyOrEscaped:`(?:${H})?(?:[{[(]{0,8}(?:"${le}"|'${le}'|\\\\+"${le}\\\\+"|\\\\+'${le}\\\\+')|${le})${U}*[=:]`,urlKeyRules:[{word:`(?:${P})`,tail:"[\\w.-]",separator:`["']?${cn}*[=:]${cn}*`,value:V},{word:`\\b(?:${bi})_\\w`,tail:"\\w",separator:`${cn}*[=:]${cn}*`,value:V},{word:`\\b(?:${_i})`,tail:"",separator:`${cn}+`,value:"[A-Za-z0-9+/=._~-]{20,}"}]}}var Cu=/\\["']/,Eu="\\][^\\s\"'>}|,;&`)\\]]*",$r="[A-Za-z0-9_-]",ki=`${$r}{10}${$r}*`,hu=`\\.${ki}\\.${ki}`,Ci=`(?<!${$r})(?=${$r}+${hu})(?:${$r}*?-)??(eyJ${ki}${hu})`,Ru=`(?:${bi})_`,Wr="\\[REDACTED\\]",Co=[{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:_i,source:(e)=>`\\b${e.authScheme}([A-Za-z0-9+/=._~-]{20,})`,flags:"i",confidence:"low"},{id:"loose-jwt",needs:"eyJ",prefilter:/eyJ/,source:Ci,confidence:"low"},{id:"sensitive-assign",needs:vo,source:(e)=>e.sensitiveAssign,flags:"i",confidence:"low"},{id:"cloud-env-var",needs:Ru,source:(e)=>e.cloudEnvVar,flags:"i",confidence:"low"},{id:"url-userinfo-tail",needs:Wr,source:":\\/\\/(\\[REDACTED\\](?!@|%40[^\\s\"'>}|,;&`)\\]@/]*(?:[\\s\"'>}|,;&`)\\]/]|$))[^\\s\"'>}|,;&`)\\]]*?(?=[\\s\"'>}|,;&`)\\]]|:\\/\\/|$))",confidence:"low"},{id:"url-userinfo-later-at",needs:Wr,source:":\\/\\/(\\[REDACTED\\]@(?:[^\\s:/?#\"'>}|,;&`)\\]]|:(?!\\/\\/)){0,256})(?=@|%40)",confidence:"low"},{id:"url-userinfo-encoded",needs:`%40|${Wr}`,needsUrl:!0,source:":\\/\\/((?:\\[REDACTED\\]@)?(?:(?:[^/?#@\\s\"',;&<>|)\\]{}`[]*[\"'`<>{}[\\]][^/?#@\\s,;&|{}\"'`<>[\\]()]*(?=%40))|[^/?#@\\s\"',;&<>|)\\]}`[]+(?=%40)|(?=[^/?#@\\s\"',;&<>|)\\]}`[]*?(?:%|:[^/?#@\\s\"',;&<>|)\\]}`[]))[^/?#@\\s\"',;&<>|)\\]}`[]+(?=\\[REDACTED\\])))",confidence:"low"},{id:"masked-value-rest",needs:Wr,source:`\\[REDACTED\\](${Eu})`,confidence:"low"},{id:"anthropic-signed-key-rest",needs:Wr,redactOnly:!0,prefilter:/\[REDACTED\]\.eyJ/,source:"\\[REDACTED\\]\\.(eyJ[\\w-]+\\.[\\w-]+)",confidence:"low"},{id:"sensitive-assign-escaped",needs:vo,redactOnly:!0,prefilter:Cu,source:(e)=>e.sensitiveAssignEscaped,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-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-deploy-token",needs:"gldt-",source:`gldt-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-runner-authentication-token",needs:"glrt-",source:`glrt-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-oauth-app-secret",needs:"gloas-",source:`gloas-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-pipeline-trigger-token",needs:"glptt-",source:`glptt-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-kubernetes-agent-token",needs:"glagent-",source:`glagent-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-incoming-mail-token",needs:"glimt-",source:`glimt-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-scim-oauth-token",needs:"glsoat-",source:`glsoat-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-ci-build-token",needs:"glcbt-",source:`glcbt-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-feed-token",needs:"glft-",source:`glft-${nn}`,displayRun:Ut,confidence:"high"},{id:"gitlab-feature-flag-client-token",needs:"glffct-",source:`glffct-${nn}`,displayRun:Ut,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"}],vg=64,_o="-----",bo="BEGIN";function vi(e,u,h){let P=h?/(?:-----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,U=h?/(?:-----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;P.lastIndex=u;let H=mi(P,e);if(!H)return null;U.lastIndex=H.index+H[0].length+vg;let V=mi(U,e);if(!V)return null;while(V[0].startsWith("[")){let z=mi(U,e);if(!z)break;V=z}return{start:H.index,end:V.index+V[0].length}}function mi(e,u){let h=e.exec(u);while(h?.[1]!==void 0&&/^-|--/.test(h[1]))e.lastIndex=h.index+1,h=e.exec(u);return h}function xg(e){return vi(e,0,!0)!==null}function Cg(e){let u=wu(e);if(u.length===0)return e;let h="",P=0;for(let U of u)h+=e.slice(P,U.start)+"[REDACTED]",P=U.end;return h+e.slice(P)}function Eg(e){let u=[];if(!/\[REDACTED/i.test(e))return u;for(let{start:h,end:P}of Au(e,0,!0)){let U=h;for(let H of e.slice(h,P).matchAll(/-----(?:BEGIN|END)[ A-Z0-9_-]{0,100}?PRIVATE KEY(?: BLOCK)?-----/gi))u.push({start:U,end:h+H.index}),U=h+H.index+H[0].length;u.push({start:U,end:P})}return u.filter((h)=>h.end-h.start>=10)}function wu(e){let u=_o.length,h=e.indexOf(_o);while(h!==-1){while(e.charCodeAt(h+u)===45)h++;let P=0;while(P<bo.length&&(e.charCodeAt(h+u+P)|32)===(bo.charCodeAt(P)|32))P++;if(P===bo.length)break;h=e.indexOf(_o,h+u)}return h===-1?[]:Au(e,h,!1)}function Au(e,u,h){let P=[];for(let U=vi(e,u,h);U;U=vi(e,U.end,h))P.push(U);return P}var xi=`(?:[\\x60'"\\s;]|\\\\[nr]|$)`,Si="(?=[^a-zA-Z0-9_\\-+=]|$)",mu="(?<![a-zA-Z0-9_\\-])";function Rg(){return Co.map(({id:e,confidence:u,source:h,flags:P="",displayRun:U})=>{let H={id:e,confidence:u},V=P.replace("g","")+"g";if(u!=="high"||typeof h!=="string")return{...H,regexFor:Vr(h,V)};let z=Tu(h);if(U===void 0)return{...H,regexFor:Vr(mu+z+Si,V)};return{...H,prefilter:new RegExp(z,P.replace("g","")),regexFor:Vr(`(?<!${U})(?=${U}+${Si})${U}*?${mu}(${z})${Si}`,V)}})}function jr(e){return Co.map((u)=>{let h=(u.flags??"").replace("g",""),P={id:u.id,confidence:u.confidence,...u.redactOnly===!0&&{redactOnly:u.redactOnly},...u.prefilter!==void 0&&{prefilter:u.prefilter}};if(u.run===void 0||typeof u.source!=="string")return{...P,regexFor:Vr(u.source,e?h+"g":u.flags??"")};return{...P,prefilter:new RegExp(Tu(u.source),h),regexFor:Vr(`(?:(?<!${u.run})|(?<=\\\\[nr]))(?=${u.run}+${xi})${u.run}*?${u.source}`,e?h+"g":h)}})}function Vr(e,u){if(typeof e==="string"){let P;return()=>P??=new RegExp(e,u)}let h=new Ht((P)=>new RegExp(e(Gr(P)),u),()=>{return});return(P)=>h.for(P)}function Tu(e){return e.endsWith(xi)?e.slice(0,-xi.length):e}function ko(e,u){if(typeof u!=="string")return"[REDACTED]";let h=u.length>=2&&(u[0]==='"'||u[0]==="'")&&u.at(-1)===u[0]?u[0]:"",P=e.lastIndexOf(u);return`${e.slice(0,P)}${h}[REDACTED]${h}${e.slice(P+u.length)}`}function wg(e){let u=e[1];if(typeof u!=="string")return{keep:0,insert:"[REDACTED]"};let h=u.length>=2&&(u[0]==='"'||u[0]==="'")&&u.at(-1)===u[0]?1:0,P=e[0].lastIndexOf(u);return{keep:P+h,insert:"[REDACTED]",keepEnd:e[0].length-P-u.length+h}}function Su(e,u){let h=Og(e,u),P=au(e,()=>u.urlKeyRules.for(e)).map(({start:V,end:z})=>{let ae=/^(["'])[^]*\1$/.test(e.slice(V,z))?1:0;return[V+ae,z-ae]}),U=iu(e),H=Eg(e).map(({start:V,end:z})=>[V,z]);return U.length===0&&h.length===0&&H.length===0?P:Pg([...P,...U,...h,...H])}var Ag=new RegExp(Eu,"y"),Tg=512;function Og(e,{emptyKeys:u,escapedEmptyKeys:h}){let P=yu(e,u.for(e));return Cu.test(e)?[...P,...yu(e,h.for(e))]:P}function yu(e,{assign:u,nextKey:h,valueWithWhitespace:P,skipsStrays:U}){let H=[],V,z=0,ae=Ag;u.lastIndex=0;for(let le=u.exec(e);le!==null;le=u.exec(e)){let we=le[1]??le[2]??le[3],Re=le.index+le[0].length,Ie=Re-we.length;h.lastIndex=Ie;let Me=we.length<=Tg&&h.test(e)?h.lastIndex:void 0;if(Me!==void 0&&Me<Re){if(P.lastIndex=Me,!P.test(e))Me=void 0}if(U&&V!==void 0&&le.index>=V&&le.index<z&&Me===void 0){V=void 0,u.lastIndex=z;continue}if(V!==void 0&&le.index<V){let Ae=/^(["'])[^]*\1$/.test(we),Ve=Ae&&z<=Ie?1:0;ae.lastIndex=Re,H.push([Ie+Ve,!Ae&&ae.test(e)?ae.lastIndex:Re-Ve])}if(z=Re,V=Me,V!==void 0)u.lastIndex=Ie}return H}function Pg(e){let u=e.filter(([P,U])=>U>P).sort((P,U)=>P[0]-U[0]),h=[];for(let[P,U]of u){let H=h.at(-1);if(H!==void 0&&P<=H[1])H[1]=Math.max(H[1],U);else h.push([P,U])}return h}function _u(e,u){let{text:h,origin:P}=e,U=[],H=0;for(let V=0;V<h.length;){let z=P[V];while(H<u.length&&u[H][1]<=z)H++;let ae=u[H];if(z<0||ae===void 0||z<ae[0]){V++;continue}let le=V;while(le>0&&P[le-1]<0)le--;while(V<h.length&&(P[V]<0||P[V]>=ae[0]&&P[V]<ae[1]))V++;let we=U.at(-1);if(we!==void 0&&we[1]>=le)we[1]=V;else U.push([le,V,"[REDACTED]"])}return So(e,U)}var Lg=512,Dg=512,Ig=[{needs:su,needsUrl:!0},{needs:`${_o}${bo}|\\[REDACTED`,flags:"i"},{needs:vo,flags:"i"},{needs:Ru,flags:"i"}],Mg=1e4;function bu(e){let u=new Set,h=new Set,P=new Set;for(let{needs:U,needsUrl:H,flags:V}of e)if(H===!0)P.add(U);else if(V?.includes("i")===!0)h.add(U);else u.add(U);return{anywhere:new hi(u,h),inUrl:P.size>0?new RegExp([...P].join("|"),"i"):null}}function ku(e,u){return typeof u!=="string"||u.length>Mg||e.anywhere.test(u)||u.includes("://")&&e.inUrl?.test(u)===!0}class Ou{testRules=null;redactRules=null;displayRules=null;keyScans={urlKeyRules:new Ht((e)=>Gr(e).urlKeyRules),emptyKeys:new Ht((e)=>{let u=Gr(e);return{assign:new RegExp(`${u.sensitiveAssign}|${u.cloudEnvVar}`,"gi"),nextKey:new RegExp(u.nextKey,"iy"),valueWithWhitespace:new RegExp(`["']|${u.authScheme}`,"iy"),skipsStrays:!1}}),escapedEmptyKeys:new Ht((e)=>{let u=Gr(e);return{assign:new RegExp(`${u.sensitiveAssign}|${u.cloudEnvVar}|${u.sensitiveAssignEscaped}`,"gi"),nextKey:new RegExp(u.nextKeyOrEscaped,"iy"),valueWithWhitespace:new RegExp(`\\\\*["']|${u.authScheme}`,"iy"),skipsStrays:!0}},(e)=>e.roomForEscapedKeys)};sensitiveKeyWord=new Ht((e)=>new RegExp(Gr(e).sensitiveKeyWord,"i"),()=>{return});needs=null;tokenNeeds=null;resultCache=new Map;mayHoldSecret(e){return this.needs??=bu([...Co,...Ig]),ku(this.needs,e)}mayHoldToken(e){return this.tokenNeeds??=bu(Co.filter((u)=>u.confidence==="high")),ku(this.tokenNeeds,e)}scan(e){this.testRules??=jr(!1);let u=[];for(let h of this.testRules)if(h.confidence==="high"&&h.prefilter?.test(e)!==!1&&h.regexFor(e).test(e))u.push({ruleId:h.id,label:h.id.split("-").map((P)=>$g[P]??Ct(P)).join(" ")});if(xg(e))u.push({ruleId:"private-key",label:"Private Key"});return u}redactContext(e,u=!1){this.redactRules??=jr(!0);let h=Cg(e);for(let P of this.redactRules)if(P.confidence==="low"&&yi(P,u,h))h=h.replace(P.regexFor(h),ko);return h}redactTokens(e){this.redactRules??=jr(!0);let u=e;for(let h of this.redactRules)if(h.confidence==="high"&&h.prefilter?.test(u)!==!1)u=u.replace(h.regexFor(u),ko);return u}trackedByRules(e,u=!1){return this.trackedTokens(this.trackedContext(e,u))}trackedContext(e,u=!1){let h=So(ql(e),wu(e).map(({start:P,end:U})=>[P,U,"[REDACTED]"]));return this.trackedRules(h,"low",u)}redactOnlyRules(e){this.redactRules??=jr(!0);let u=e;for(let h of this.redactRules)if(h.redactOnly===!0&&yi(h,!0,u))u=u.replace(h.regexFor(u),ko);return u}trackedTokens(e){return this.trackedRules(e,"high")}trackedRules(e,u,h=!1){this.redactRules??=jr(!0);let P=e;for(let U of this.redactRules)if(U.confidence===u&&yi(U,h,P.text)){let H=U.regexFor(P.text);H.lastIndex=0,P=zl(P,H,wg)}return P}redactWithUrlRanges(e){let u=Su(e,this.keyScans);if(u.length>0)return _u(this.trackedByRules(e,!0),u).text;let h=this.redactContext(e,!0);return this.mayHoldToken(h)?this.redactTokens(h):h}redactTracked(e){return _u(this.trackedByRules(e,!0),Su(e,this.keyScans))}redact(e){if(!this.mayHoldSecret(e))return e;let u=e.length<=Lg;if(u){let P=this.resultCache.get(e);if(P!==void 0)return P}let h=this.redactWithUrlRanges(e);if(u){if(this.resultCache.size>=Dg)uu(this.resultCache);this.resultCache.set(e,h)}return h}redactForDisplay(e){this.displayRules??=Rg();let u=e;for(let h of this.displayRules){if(h.confidence!=="high"||h.prefilter?.test(u)===!1)continue;u=u.replace(h.regexFor(u),jg)}return u}}var Fg=new Ou;var Ng="[hidden for privacy]",Ug=a({reporter:void 0},(e)=>{e.reporter=void 0});function Hg(e){try{Ug.reporter?.(e)}catch{}}function Bg(e){try{return Fg.redact(e)}catch(u){Hg(u);return}}function Pu(e){return Bg(e)??Ng}var Yk=new RegExp(Ci),Xk=new RegExp(Ci,"g");var Kg=/[$\x60|;&<>()\s]/,Wg=/[/.@:~*?\\]/;function jg(e,u){let h=typeof u==="string"?u:e;if(Kg.test(h)||Wg.test(h))return e;return ko(e,u)}var Eo="(^|[^a-z0-9+.-]|%[0-9a-f]{2})",Gg="https?|wss?|ftps?",Lu="ssh\\+git|git\\+ssh|ssh|git",Zk=new RegExp(`[a-z](?:[a-z0-9+.-]{1,31}:\\/+|:\\/\\/)|(?:https?|ftps?):(?!\\/)|${Eo}(?:wss?|file):(?!\\/)|${Eo}(?:${Lu}):(?!\\/)(?=[^@/?#\\s]*?(?::|%3a))`,"i");var Qk=new RegExp(`${Eo}(?:${Gg}):(?!\\/\\/)|${Eo}(?:${Lu}):(?!\\/\\/)`,"gi");function yi(e,u,h){return(u||e.redactOnly!==!0)&&(e.prefilter===void 0||e.prefilter.test(h))}var $g={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 Ai={verbose:0,debug:1,info:2,warn:3,error:4},Xg=new RegExp(`(?!\\t)[${Q}]`,"gu"),Zg=10485760,Mu=1048576,Qg=1e4,ef=262144,tf=5000,Fu=100,nf=gn((e)=>e());function rf(e){return Object.hasOwn(Ai,e)}function Nu(e){return Da(e)?null:Ku(e)}function Uu(){}var of={arm:"v5",target:null};function sf(e,u){e.stuck=e.appendSince===u?"yes":"no"}var af={sessionId:"",fromBackend:!1};function Hu(e,u,h,P){let U=pn(u,"debug"),H=pn(U,`${e.sessionId}.txt`),V;if(h===null)V=H;else if(P!==null&&h===P)V=pn(P,`${e.sessionId}.txt`);else V=h;let z=!e.fromBackend&&V===H?"v5":"raw";return{target:V,arm:z,configHome:u,rotate:z==="raw"&&!(Vn(V)===U&&V.endsWith(".txt")),pointLatest:z==="raw"&&V!==H}}function wi(e){return Vt.userNamed(Yg(e)?e:Ku(e))}function lf(e){return e.code==="Failed"&&e.telemetryCode==="ENOENT"}function uf(e,u=il){return u?e:void 0}async function Bu(e,u,h,P){let U={namespace:"log",sessionId:u,channel:"debug"},H=await ei.run(!0,()=>e.append(U,[{data:h}],P?{markLatest:!0}:void 0));if(H.ok)return"landed";return P&&H.error.code==="InvalidArgument"&&H.error.argument==="opts.markLatest"?"refused":"dropped"}class Wu{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=uf(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 u=Array.isArray(e.argv)?e.argv:[],h=ul(),P;if(h!==void 0)P=h(u);else{let z=u.indexOf("--");P=z===-1?u:u.slice(0,z)}let U=e.env.CLAUDE_CODE_DEBUG_LOG_LEVEL?.toLowerCase().trim();this.minLevel=U&&rf(U)?U:"debug";let H=P.find((z)=>z.startsWith("--debug="));this.filter=H?pl(H.substring(8)):null,this.toStderr=P.includes("--debug-to-stderr")||P.includes("-d2e");let V=null;for(let[z,ae]of P.entries()){if(ae.startsWith("--debug-file=")){V=Nu(ae.substring(13));break}if(ae==="--debug-file"&&z+1<P.length){V=Nu(P[z+1]);break}}this.filePath=V,this.debugFromLaunch=d(e.env.DEBUG)||d(e.env.DEBUG_SDK)||P.includes("--debug")||P.includes("-d")||this.toStderr||H!==void 0||this.filePath!==null}isDebugMode(){return this.runtimeDebugEnabled||this.debugFromLaunch}mayWrite(e){return this.takesLevel(e)&&(this.deps.isAnt||this.isDebugMode())}drainsSyncAtExit(){return!(p()&&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?pn(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 pn(this.deps.configHomeDir(),"debug",`${e}.txt`)}learnedOverrideDirectory(){return this.overrideDirectory}isArmed(){return this.storageV5!==void 0}takesLevel(e){return Ai[e]>=Ai[this.minLevel]}log(e,{level:u}={level:"debug"}){if(!this.takesLevel(u))return;let h=this.deps.limits?.();if(h===void 0){this.emit(e,u);return}let P=e.length>h.maxMessageLength?`debug message not logged: it has ${e.length} characters, over this log's fixed limit of ${h.maxMessageLength} per message`:e,{admitted:U,leftOutBefore:H}=h.admit(P.length);if(!U)return;h.timed(()=>{if(H>0)this.emit(`debug messages not logged: ${H} since this log's last line, over its fixed limit on how much it logs at a time`,u);this.emit(P,u)})}emit(e,u){if(!this.shouldLog(e))return;let h=Pu(e.trim());h=h.includes(`
`)?$l(o(h)):h.replace(Xg,Vl);let U=`${new Date().toISOString()} [${u.toUpperCase()}] ${h}
`;if(this.toStderr){this.deps.writeToStderr(U);return}this.write(U)}write(e){let u=this.getWriter(),h=af;if(this.storageV5!==void 0){if(h={sessionId:this.deps.sessionId(),fromBackend:ei.getStore()===!0},h.fromBackend)this.backendLinesLogged++}if(u.write({origin:h,content:e}),this.exiting)u.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 u=0;this.backendLinesLogged!==e&&u<3;u++)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 ue(e,Fu))return;while(!this.isAppendStuck())}isAppendStuck(){let e=this.backlog,{appendSince:u}=e;if(e.stuck==="no"&&u!==0&&Date.now()-u>=tf)e.stuck="suspected",setTimeout(sf,Fu,e,u).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((u)=>{this.write(u)})}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,u,h=Zg){let P=p()&&this.storageV5!==void 0?this.storageV5.hostFiles:void 0;if(this.writtenBytes<0)if(P){let U=await P.stat(wi(e));this.writtenBytes=U.ok&&U.value.kind!=="absent"?U.value.size:0}else this.writtenBytes=await qg(e).then((U)=>U.size).catch(()=>0);else this.writtenBytes+=u;if(this.writtenBytes<=h||this.rotating)return;this.rotating=!0;try{let U=e.endsWith(".txt")?`${e.slice(0,-4)}.1.txt`:`${e}.1`;if(P){let H=wi(e),V=wi(U),z=await P.rename(H,V);if(!z.ok&&!lf(z.error)){if(await P.delete(V,{missingOk:!0}),!(await P.rename(H,V)).ok)await P.delete(H,{missingOk:!0})}}else try{await Iu(e,U)}catch(H){if(!S(H))await Ri(U).catch(()=>{}),await Iu(e,U).catch(()=>Ri(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 gl(e,this.filter)}resolveDirToFile(e){return this.resolvedLogPath=pn(e,`${this.deps.sessionId()}.txt`),this.resolvedLogPath}async appendGroup(e,u,h,P){if(this.storageV5!==void 0&&e.arm==="v5"){await this.appendV5AndMark(this.storageV5,u,h);return}if(e.target===null||!this.writesFiles())return;if(P)await Du(Vn(e.target),{recursive:!0}).catch(()=>{});let U=e;try{await Ei(e.target,h)}catch(H){if(!Oo(H))throw H;if(this.storageV5===void 0)U={...e,target:this.resolveDirToFile(e.target)},await Ei(U.target,h);else{if(this.overrideDirectory=e.target,U=Hu(u,e.configHome,e.target,e.target),U.arm==="v5"){await this.appendV5AndMark(this.storageV5,u,h);return}await Du(Vn(U.target),{recursive:!0}).catch(()=>{});try{await Ei(U.target,h)}catch{return}}}if(U.rotate){if(this.storageV5!==void 0&&U.target!==this.rotationTarget)this.rotationTarget=U.target,this.writtenBytes=-1;await this.maybeRotate(U.target,Buffer.byteLength(h)).catch(Uu)}if(U.pointLatest)this.markLatestSymlink()}async appendV5AndMark(e,u,h){let P=p(),U=P&&!this.latestMarked&&!this.latestRefused,H=await Bu(e,u.sessionId,h,U);if(H==="refused")this.latestRefused=!0,H=await Bu(e,u.sessionId,h,!1),this.log("debug log: the storage backend refused markLatest; <debug folder>/latest is not pointed in this process",{level:"warn"});if(H!=="landed")return;if(U&&!this.latestRefused)this.latestMarked=!0;else if(!P)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,u=this.unflushedChunks[0],h=u?.queued;if(h===void 0)return;let P=0,U=0,H=!1;for(let{content:V,queued:z}of this.unflushedChunks){if(z===void 0||z.owner!==h.owner||z.decision.arm!==h.decision.arm||z.decision.target!==h.decision.target||z.origin.sessionId!==h.origin.sessionId||z.origin.fromBackend!==h.origin.fromBackend||P>0&&U+V.length>ef)break;P++,U+=V.length,H||=z.needMkdir}if(e.appendSince=Date.now(),await h.owner.appendGroup(h.decision,h.origin,this.unflushedChunks.slice(0,P).map((V)=>V.content).join(""),H).catch(Uu),e.appendSince=0,e.stuck="no",this.unflushedChunks[0]===u)this.unflushedChunks.splice(0,P),e.length-=U}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 u of this.unflushedChunks.splice(0)){if(u.target===null)continue;let h=e.at(-1);if(h!==void 0&&h.armed===u.armed&&(!u.armed||h.target===u.target))h.parts.push(u);else e.push({target:u.target,armed:u.armed,parts:[u]})}for(let{target:u,armed:h,parts:P}of e){let U=h?u:this.logPath(),H=P.map((V)=>V.content).join("");try{i().mkdirSync(Vn(U))}catch{}try{i().appendFileSync(U,H)}catch(V){if(Oo(V))try{if(!h)i().appendFileSync(this.resolveDirToFile(U),H);else{let z=(we,Re)=>{try{i().appendFileSync(pn(U,`${we}.txt`),Re)}catch{}},ae=P[0]?.sessionId,le="";for(let we of P){if(we.sessionId!==ae)z(ae,le),ae=we.sessionId,le="";le+=we.content}z(ae,le)}}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
`}groupLines(e){let u=e[0];if(u===void 0)return[];let h=this.filePath??this.deps.env.CLAUDE_CODE_DEBUG_LOGS_DIR??null,P=this.isSessionDiskless();if(P&&(this.storageV5===void 0||h!==null))return[];if(this.storageV5===void 0)return[{decision:{target:this.logPath(),arm:"raw",configHome:"",rotate:!0,pointLatest:!0},origin:u.origin,lines:e}];let U=[];for(let H of e){if(P&&H.origin.fromBackend)continue;let V=U.at(-1);if(V!==void 0&&V.origin.sessionId===H.origin.sessionId&&V.origin.fromBackend===H.origin.fromBackend)V.lines.push(H);else U.push({decision:P?of:Hu(H.origin,this.deps.configHomeDir(),h,this.overrideDirectory),origin:H.origin,lines:[H]})}return U}getWriter(){if(this.writer)return this.writer;let e=null,u=this.storageV5!==void 0;if(this.writer=al({writeBatch:(h)=>{if(this.redirect){this.redirect(h.map((H)=>H.content).join(""));return}if(this.exiting){for(let H of this.groupLines(h))this.unflushedChunks.push({target:H.decision.target,sessionId:H.origin.sessionId,armed:u,content:this.takeDroppedNote()+H.lines.map((V)=>V.content).join("")});this.drainSync();return}let P=this.writesFiles(),U=this.backlog;this.isAppendStuck();for(let H of this.groupLines(h)){if(H.decision.arm==="raw"&&!P)continue;if(U.droppedCount>0?U.length>=Mu/2:U.length>=Mu&&Date.now()-(this.unflushedChunks[0]?.queued?.at??1/0)>=Qg){U.droppedCount+=H.lines.length,U.droppedTotal+=H.lines.length;continue}let V=this.takeDroppedNote()+H.lines.map((le)=>le.content).join("");if(V==="")continue;let z=H.decision.arm==="raw"?Vn(H.decision.target):null,ae=z!==null&&(H.origin.fromBackend||e!==z);if(z!==null)e=z;this.unflushedChunks.push({target:H.decision.target,sessionId:H.origin.sessionId,armed:u,content:V,queued:{at:Date.now(),owner:this,decision:H.decision,origin:H.origin,needMkdir:ae}}),U.length+=V.length,U.chain=nf(()=>U.chain.then(this.appendOldest))}},sizeOf:(h)=>h.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(Jg(e).toLowerCase()==="latest")return;let u=pn(Vn(e),"latest");if((await Vg(u).catch(()=>null))?.isSymbolicLink())await Ri(u).catch(()=>{});await zg(e,u)}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 df=new s(()=>new ju);function cf(){return ne(df)}function pf(e,u){return new Wu({argv:process.argv,env:process.env,sessionId:()=>sl(),configHomeDir:()=>R(),onExit:(h)=>{process.on("exit",h)},registerCleanup:(h)=>{Yt(h)},writeToStderr:(h)=>{Dl(h,{mayDrop:!0})},isAnt:u?.isAnt??!1,isTestEnvironment:u?.isTestEnvironment??!1,launchIdentity:u,storageV5:e.init.storageV5!==void 0&&e.init.configHome===ke()?e.init.storageV5:void 0,syncExitDrain:e.init.syncExitDrain,diskless:()=>g(),defaultFile:()=>e.defaultFile,limits:()=>e.limits})}function Gu(){let e=cf(),u=e.instance;if(u)return u;let h=pf(e);return e.setInstance(h),h}function Cr(){return Gu().mayWrite("debug")}function t(e,u={level:"debug"}){Gu().log(e,u)}function $u(e){let u=0;for(let h=0;h<e.length;h++)u=(u<<5)-u+e.charCodeAt(h)|0;return u}function F(e){if(typeof e!=="object"||e===null)return!1;let u=Object.getPrototypeOf(e);return u===Object.prototype||u===null}var Ge=2147483647;var gf=1000;function ff(){return{eventQueue:[],sink:null,droppedEventCount:0}}function hf(e,u){if(e.eventQueue.length>=gf)e.eventQueue.shift(),e.droppedEventCount++;e.eventQueue.push(u)}class Vu{state=ff()}var mf=new s(()=>new Vu);function Sf(){return ne(mf)}function Ee(e,u){let h=Sf().state;if(h.sink===null){hf(h,{eventName:e,metadata:u,async:!1});return}h.sink.logEvent(e,u)}function en(e,u){Ee("tengu_feature_ok",{...u,feature_name:ce(e)})}function yf(e,u,h){Ee("tengu_feature_bad",{...h,feature_name:ce(e),error_code:To(u)})}function Tt(e,u,h){Ee("tengu_feature_sad",{...h,feature_name:ce(e),error_code:To(u)})}async function x(e,u,h){try{let P=await u();return en(e),P}catch(P){throw yf(e,h?.(P)??"error"),P}}function _f(e){if(e.length!==22)return;let u=BigInt(58),h=0n;for(let P of e){let U="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".indexOf(P);if(U<0)return;h=h*u+BigInt(U)}return h}function Ar(e){let u=e.lastIndexOf("_");if(u<0)return;let h=e.slice(u+1);if(!h.startsWith("01"))return;let P=_f(h.slice(2));if(P===void 0)return;let U=P.toString(16).padStart(32,"0");if(U.length!==32)return;return`${U.slice(0,8)}-${U.slice(8,12)}-${U.slice(12,16)}-${U.slice(16,20)}-${U.slice(20,32)}`}function xe(e){return e.startsWith("\uFEFF")?e.slice(1):e}function qu(){return"prod"}var In=["","-staging-oauth","-local-oauth","-custom-oauth"];function Pn(){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 Or(){return Pn()==="-staging-oauth"}var kf=31536000;var jv=Math.round(kf/86400);var Ti={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",CHATS_CLIENT_ID:"00000000-0000-4000-8000-00000000c4a9",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 vf=void 0;var xf=["https://beacon.claude-ai.staging.ant.dev","https://claude.fedstart.com","https://claude-staging.fedstart.com"];function Cf(){switch(qu()){case"local":return Ti;case"staging":return vf??Ti;case"prod":return Ti}}function Rr(){let e=Cf(),u=process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL;if(u){let P=u.replace(/\/$/,"");if(!xf.includes(P))throw Error("CLAUDE_CODE_CUSTOM_OAUTH_URL is not an approved endpoint.");e={...e,BASE_API_URL:P,CONSOLE_AUTHORIZE_URL:`${P}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${P}/oauth/authorize`,CLAUDE_AI_ORIGIN:P,TOKEN_URL:`${P}/v1/oauth/token`,API_KEY_URL:`${P}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${P}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${P}/oauth/code/success?app=claude-code`,CLAUDEAI_SUCCESS_URL:`${P}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${P}/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 h=process.env.CLAUDE_CODE_OAUTH_CLIENT_ID;if(h)e={...e,CLIENT_ID:h,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 Ef=String.fromCharCode(0),Rf=/^\.[0-9a-f]{16}\.aside$/;function wf(e){if(e.charCodeAt(0)!==46)return!1;return be(e).some((u)=>Rf.test(u))}function Af(e){return typeof e==="string"&&/^[. ]+$/.test(e)}function ye(e){return!(typeof e!=="string"||e.length===0||Af(e)||e.includes("/")||e.includes("\\")||e.includes(Ef)||wf(e))}function Ln(e){return e.length>0&&e.every(ye)}function kt(e){return be(e).some((u)=>u.endsWith(".jsonl"))}function be(e){let u=Ro.get(e);if(u!==void 0)return u;let h=Object.freeze(Tf(e));if(Ro.size>=Of)Ro.clear();return Ro.set(e,h),h}function Tf(e){let u=e.toLowerCase(),h=u.indexOf(":");return h===-1?[Oi(u)]:[Oi(u),Oi(u.slice(0,h))]}var Ro=new Map,Of=32768;function Oi(e){let u=e.length;while(u>0){let h=e.charCodeAt(u-1);if(h!==46&&h!==32)break;u-=1}return u===e.length?e:e.slice(0,u)}function wo(e,u,h){return h===void 0?e:{...e,[u]:h}}function Pf(e,u,h,P){let H=wo({namespace:"transcript",projectKey:e,sessionId:u},"agentId",h);return wo(H,"agentRelPath",P)}function Lf(e,u,h){let U=wo({namespace:"log",sessionId:e,channel:u},"agentId",h?.agentId);return wo(U,"runId",h?.runId)}var B={transcript:Pf,journal:(e,u,h)=>({namespace:"transcript",projectKey:e,sessionId:u,agentRelPath:h,journal:!0}),sessionJournal:(e,u,h)=>({namespace:"transcript",projectKey:e,sessionId:u,sessionJournal:h}),history:()=>({namespace:"history"}),log:Lf,globalConfig:()=>({namespace:"globalConfig"}),globalConfigCopy:(e,u)=>({namespace:"globalConfig",kind:e,stamp:u}),userSettings:()=>({namespace:"settings",layer:"user"}),projectSettings:(e)=>({namespace:"settings",layer:"project",projectKey:e}),localSettings:(e)=>({namespace:"settings",layer:"local",consentRootKey:e}),task:(e,u)=>({namespace:"task",listId:e,taskId:u}),taskListMeta:(e)=>({namespace:"task",listId:e,meta:!0}),taskListHighWaterMark:(e)=>({namespace:"task",listId:e,highWaterMark:!0}),memory:(e,u)=>({namespace:"memory",projectKey:e,relPath:u}),pluginRegistry:(e)=>({namespace:"pluginRegistry",file:e}),marketplaceCache:(e,u)=>({namespace:"marketplaceCache",marketplace:e,form:u}),marketplaceTree:(e,u)=>({namespace:"marketplaceCache",marketplace:e,relPath:u}),pluginCache:(e,u,h,P)=>({namespace:"pluginCache",marketplace:e,plugin:u,version:h,relPath:P}),cache:(e,u)=>({namespace:"cache",store:e,id:u}),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,u)=>({namespace:"agentMemory",layer:"user",agentType:e,relPath:u}),identity:()=>({namespace:"identity"}),team:(e)=>({namespace:"team",team:e}),sidecar:(e,u,h)=>({namespace:"sidecar",projectKey:e,sessionId:u,relPath:h}),mailbox:(e,u)=>({namespace:"mailbox",team:e,teammate:u}),scratch:(e,u)=>({namespace:"scratch",sessionId:e,relPath:u}),userConfigDir:(e,u)=>({namespace:"userConfigDir",dir:e,relPath:u}),fileHistory:(e,u)=>({namespace:"fileHistory",sessionId:e,backupFileName:u}),job:(e,u)=>({namespace:"job",jobId:e,relPath:u}),jobTimeline:(e)=>({namespace:"jobTimeline",jobId:e}),recording:(e,u,h)=>({namespace:"recording",projectKey:e,sessionId:u,stamp:h}),sessionLog:(e,u,h)=>({namespace:"sessionLog",projectKey:e,year:u.year,month:u.month,day:u.day,logName:h}),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,u)=>({namespace:"dirSyncRecord",projectKey:e,sessionId:u})};import{once as zu}from"events";import{createWriteStream as Df}from"fs";var If=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function D(e){if(typeof e!=="string")return null;return If.test(e)?e:null}async function Nn(e,u,h){return Ff(e,u,"w",h)}var Mf=262144;async function Ff(e,u,h,P){if(P!==void 0&&P.hoverRestOn&&(h==="w"||u.length>0))return Nf(P.source,u,h);let U=Df(e,{mode:384,flags:h});try{let H="";for(let V of u)if(H+=JSON.stringify(V)+`
`,H.length>=Mf){let z=U.write(H);if(H="",!z)await zu(U,"drain")}if(H!=="")U.write(H);U.end(),await zu(U,"finish")}catch(H){throw U.destroy(),H}}async function Nf(e,u,h){let{backend:P,key:U}=e,H=u.map((z)=>({data:JSON.stringify(z)+`
`}));if(h==="w"){let z=await P.replaceRecords(U,H,{publishDiscipline:"inPlace",mode:384});if(!z.ok)throw Error("transcript stream replace failed",{cause:z.error});return}let V=await P.append(U,H);if(!V.ok)throw Error("transcript stream append failed",{cause:V.error})}var De=200;function Uf(e){return Math.abs($u(e)).toString(36)}function vt(e){return e.replace(/[^a-zA-Z0-9]/g,"-")}function ze(e){let u=vt(e);if(u.length<=De)return u;return`${u.slice(0,De)}-${Uf(e)}`}function $e(e){return Sl()??ze(e)}import{realpathSync as Hf}from"fs";import{isAbsolute as Bf,relative as Kf,resolve as Wf,sep as jf}from"path";function Gf(e){let u=Wf(e??"."),h;try{h=Hf(u)}catch{h=u}return _(h)}function G(e,u){let h=Gf(e);if(u===void 0)return $e(h);return(u.CLAUDE_CONFIG_DIR?ti(u.CLAUDE_CODE_PROJECT_DIR_NAME):void 0)??ze(h)}function wr(e){return typeof e==="object"&&e!==null&&"type"in e&&e.type==="agent_metadata"}function Mn(e,u){let h=Kf(u,e),P=h.split(jf);if(P[0]===".."||Bf(h))return null;if(P.length<2||P[0]===void 0||P[1]===void 0)return null;let U=P[0],H=P[1];if(P.length===2&&H.endsWith(".jsonl"))return{projectKey:U,sessionId:H.replace(/\.jsonl$/,"")};if(P.length>=4){let V=P.slice(2),z=V.length-1;return V[z]=T(V,V.length-1).replace(/\.jsonl$/,""),{projectKey:U,sessionId:H,subpath:V.join("/")}}return null}function Ce(){return Ho.of(A().host)}function Un(e){Ce().invalidateAll(e)}var ie=["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","PreSkillShellCommand"],Nr=["clear","resume","logout","prompt_input_exit","other"],Mr="__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__";var Ur=["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"],tn={Task:"Agent",KillShell:"TaskStop",KillBash:"TaskStop",ListPeers:"ListAgents",Brief:"SendUserMessage",ListMcpResources:"ListMcpResourcesTool",ReadMcpResource:"ReadMcpResourceTool",ReadMcpResourceDir:"ReadMcpResourceDirTool",ProposeGoal:"SetGoal"};var Tr=["userSettings","projectSettings","localSettings","flagSettings","policySettings"];var $f=["userSettings","projectSettings","localSettings"],Vf=["projectSettings","localSettings"],bx=new Set(Vf),qf={userSettings:"user",projectSettings:"project",localSettings:"local"},kx=$f.map((e)=>[qf[e],e]);var kr="--settings (inline JSON)",vr=["auto","bypassPermissions"],Fn="organizationFreeFormSettings";
export{Te,Lr,E,y,Fe,d,ee,m,Ze,f,er,p,s,k,tr,nr,Bt,de,a,L,ce,c,mn,rr,N,or,W,b,n,Qe,sr,S,He,ir,hn,Wt,M,et,I,K,ue,Be,_,ft,pe,fe,ar,Y,ge,q,gt,me,We,_n,Sn,mt,En,Kt,ht,tt,_t,St,te,yn,A,ne,lr,dr,cr,ur,g,jt,bn,pr,re,Cn,nt,Gt,oe,zt,R,ke,fr,l,ve,An,On,$t,he,Vt,Yt,r,O,Et,rt,_e,ot,w,o,C,gr,J,qt,Rn,X,Ke,wn,yt,Jt,j,st,i,bt,Tn,mr,Ct,Z,kn,se,vn,At,it,hr,Ot,Xt,xn,_r,Sr,Er,Zt,yr,v,Dn,br,Qt,Q,je,Rt,T,at,Se,lt,wt,Cr,t,F,Ge,Ee,en,Tt,x,Ar,xe,In,Pn,Or,Rr,ye,Ln,kt,be,B,D,Nn,De,vt,ze,$e,G,wr,Mn,Ce,Un,ie,Nr,Mr,Ur,tn,Tr,kr,vr,Fn};