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