@anthropic-ai/claude-agent-sdk 0.3.323 → 0.3.324

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/core-72zgz5fc.mjs DELETED
@@ -1,28 +0,0 @@
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.323
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{be,s,u,o,wt,a,kt,t,p,vt,re,g,w,ve,Pt,k,j,W,yn,je,Lt,H,B,rt,ce,oe,Mt,v,Nt,z,Cn,E,K,Rn,m,y,Ce,jt,vn}from"./core-1tccd4gq.mjs";import{createRequire as Ii}from"node:module";var Di=Object.defineProperty;var vi=(c)=>c;function Oi(c,l){this[c]=vi.bind(null,l)}var L=(c,l)=>{for(var d in l)Di(c,d,{get:l[d],enumerable:!0,configurable:!0,set:Oi.bind(l,d)})};var Mn=Ii(import.meta.url),Pi=Symbol.dispose||Symbol.for("Symbol.dispose"),Li=Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose"),_=(c,l,d)=>{if(l!=null){if(typeof l!=="object"&&typeof l!=="function")throw TypeError('Object expected to be assigned to "using" declaration');var f;if(d)f=l[Li];if(f===void 0)f=l[Pi];if(typeof f!=="function")throw TypeError("Object not disposable");c.push([d,f,l])}else if(d)c.push([d]);return l},S=(c,l,d)=>{var f=typeof SuppressedError==="function"?SuppressedError:function(T,D,O,P){return P=Error(O),P.name="SuppressedError",P.error=T,P.suppressed=D,P},h=(T)=>l=d?new f(T,l,"An error was suppressed during disposal"):(d=!0,T),R=(T)=>{while(T=c.pop())try{var D=T[1]&&T[1].call(T[2]);if(T[0])return Promise.resolve(D).then(R,(O)=>(h(O),R()))}catch(O){h(O)}if(d)throw l};return R()};import{appendFile as xr,lstat as su,mkdir as ei,rename as ti,stat as iu,symlink as ou,unlink as Ar}from"fs/promises";import{basename as au,dirname as Ut,isAbsolute as uu,join as it,resolve as ui}from"path";var Or={home:(c)=>({space:"home",path:c}),workspace:(c)=>({space:"workspace",path:c}),system:(c)=>({space:"system",path:c}),userNamed:(c)=>({space:"userNamed",path:c})};var jn=globalThis.process?.getBuiltinModule?.("async_hooks"),Ir=jn!==void 0,Vn=jn?new jn.AsyncLocalStorage:{run:(c,l)=>l(),getStore:()=>{return}};function Pr({writeBatch:c,sizeOf:l,flushIntervalMs:d=1000,maxBufferSize:f=100,maxBufferBytes:h=1/0,immediateMode:R=!1}){let T=[],D=0,O=null,P=null;function F(){if(O)clearTimeout(O),O=null}function Y(te){try{c(te)}catch{}}function ie(){if(P)Y(P),P=null;if(T.length===0)return;Y(T),T=[],D=0,F()}function V(){if(!O)O=setTimeout(ie,d)}function ae(){if(P){P.push(...T),T=[],D=0,F();return}let te=T;T=[],D=0,F(),P=te,setImmediate(()=>{let fe=P;if(P=null,fe)Y(fe)})}return{write(te){if(R){Y([te]);return}if(T.push(te),D+=l(te),V(),T.length>=f||D>=h)ae()},flush:ie,dispose(){ie()}}}function Mi(c){if(typeof c==="function")return c;if(Symbol.asyncDispose in c)return()=>c[Symbol.asyncDispose]();return()=>c[Symbol.dispose]()}class zn{#e=new Set;#t=!1;get drainStarted(){return this.#t}register(c){let l=Mi(c);this.#e.add(l);let d=()=>{this.#e.delete(l)};return Object.assign(d,{[Symbol.dispose]:d})}async drain(){this.#t=!0;let c=Array.from(this.#e);this.#e.clear();let d=(await Promise.allSettled(c.map(async(f)=>f()))).find((f)=>f.status==="rejected");if(d!==void 0)throw d.reason}async[Symbol.asyncDispose](){await this.drain()}get sizeForTesting(){return this.#e.size}}class Lr{cleanup=new zn;preExitFlush=new zn;preExitFlushWaits=new Map}var Fi=new o(()=>new Lr);function Ki(){return K(Fi)}function Xe(c){return Ki().cleanup.register(c)}var Bi=a({read:void 0},(c)=>{c.read=void 0});function Ur(){return Bi.read}class Mr{parsed=new Map;lookup(c){return this.parsed.get(c)}remember(c,l){this.parsed.set(c,l)}reset(){this.parsed.clear()}}var Nr=new Mr;function Fr(c){let l=Nr.lookup(c);if(l!==void 0)return l;let d=Hi(c);return Nr.remember(c,d),d}function Hi(c){if(!c||c.trim()==="")return null;let l=c.split(",").map((R)=>R.trim()).filter(Boolean);if(l.length===0)return null;let d=l.some((R)=>R.startsWith("!")),f=l.some((R)=>!R.startsWith("!"));if(d&&f)return null;let h=l.map((R)=>R.replace(/^!/,"").toLowerCase());return{include:d?[]:h,exclude:d?h:[],isExclusive:d}}function $i(c){let l=[],d=c.match(/^MCP server ["']([^"']+)["']/);if(d&&d[1])l.push("mcp"),l.push(d[1].toLowerCase());else{let R=c.match(/^([^:[]+):/);if(R&&R[1])l.push(R[1].trim().toLowerCase())}let f=c.match(/^\[([^\]]+)]/);if(f&&f[1])l.push(f[1].trim().toLowerCase());if(c.toLowerCase().includes("1p event:"))l.push("1p");let h=c.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(h&&h[1]){let R=h[1].trim().toLowerCase();if(R.length<30&&!R.includes(" "))l.push(R)}return Array.from(new Set(l))}function Wi(c,l){if(!l)return!0;if(c.length===0)return!1;if(l.isExclusive)return!c.some((d)=>l.exclude.includes(d));else return c.some((d)=>l.include.includes(d))}function Kr(c,l){if(!l)return!0;let d=$i(c);return Wi(d,l)}import*as se from"fs";import{appendFile as Ji,copyFile as qi,link as Yi,lstat as Xn,mkdir as Zi,open as Sn,readdir as Xi,readFile as $r,readlink as Qi,realpath as eo,rename as to,rmdir as no,rm as ro,stat as Wr,unlink as so}from"fs/promises";import*as le from"path";function me(){return process.versions.bun!==void 0}var Gi=0xffffffffffffffffn;function Jn(c){let l=BigInt(c);return l===0n||l===-1n||l===Gi||l===1n<<64n}function Zt(c,l){return!Jn(c.ino)&&!Jn(l.ino)&&c.ino!==l.ino}var qn=[];function Yn(){return qn.pop()??Buffer.allocUnsafeSlow(65536)}function Zn(c,l){if(c.fill(0,0,Math.min(l,c.length)),qn.length<2)qn.push(c)}var zc=(()=>{let c=process.env.CLAUDE_CODE_SLOW_OPERATION_THRESHOLD_MS;if(c!==void 0){let l=Number(c);if(!Number.isNaN(l)&&l>=0)return l}return 1/0})();var Vi={[Symbol.dispose](){}};function zi(){return Vi}var C=zi;function r(c,l,d){return JSON.stringify(c,l,d)}var b=(c,l)=>{let f=[];try{const d=_(f,C`JSON.parse(${Hr(c)})`,0);return typeof l>"u"?JSON.parse(c):JSON.parse(c,l)}catch(h){var R=h,T=1}finally{S(f,R,T)}};function I(c,l){let f=[];try{const d=_(f,C`structuredClone(${Hr(c)})`,0);return structuredClone(c,l)}catch(h){var R=h,T=1}finally{S(f,R,T)}}function Hr(c){return typeof c==="string"?c.length:c}var io="→";function oo(){return process.platform==="win32"?0:se.constants.O_NOFOLLOW|se.constants.O_NONBLOCK}function Je(){return process.platform==="win32"?"r":se.constants.O_RDONLY|se.constants.O_NONBLOCK|se.constants.O_NOCTTY}var xt=process.platform==="win32"?/[\\/]+/:/\/+/;function ft(c,l){let d=(D)=>D.split(xt).filter(Boolean),f=le.resolve(c),h=le.resolve(l),R=d(f),T=d(h);return le.parse(f).root===le.parse(h).root&&R.length<T.length&&R.every((D,O)=>D===T[O])}function Qn(c){let l="";for(let f of c.split(/([\\/]+)/)){if(f==="."||f==="..")break;l+=f}let d=l.replace(/(?<=[^\\/])[\\/]+$/,"");return d===""?c:d}function ao(c){let l=le.join(c).replace(/(?<=[^\\/])[\\/]+$/,"");if(w(l)&&!v(l))return l;return Qn(c)}function uo(c){if(c.startsWith("\\\\"))return Qn(c);let l=c.replace(/^\/+/,"/"),d=rt(l);if(d!==null)return d;return Qn(c)}var co=process.platform==="win32"?ao:uo;function En(c,l,d){let f=k(c);if(l.length===0||f||l.some((h)=>h==="."||h==="..")){if(d!==void 0&&(l.length>0||f))d(le.join(c,...l));return f?co(c):c}return le.join(c,...l)}var M="\x00unverified-ancestry",Ue="\x00opaque-link-text";function lo(c){return ve(le.isAbsolute(c)?c:c.replace(/^(?:\.\.(?:[\\/]+|$))+/,""))}function po(c,l=process.platform==="win32"){return c.includes("�")||lo(c)||l&&(/^(?:[A-Za-z]:(?![\\/])|[\\/](?![\\/]))/.test(c)||/^[\\/]{2}\?[\\/]/.test(c)&&!/^[\\/]{2}\?[\\/](?:[A-Za-z]:[\\/]|UNC[\\/])/i.test(c)||c.split(/[\\/]/).some((d)=>d!=="."&&d!==".."&&/[. ]$/.test(d)))}function Gr(c,l,d=!1,f=!1,h=!1){if(l?.unreadableAncestry!=="unverified")return;let R=c!==void 0&&typeof c==="object"&&"errno"in c?c.errno:void 0;if(R==="ENOENT"||R==="ENOTDIR")return;if(R==="ENAMETOOLONG"&&!d&&!f&&!h)return;return M}function at(c){return oe(c)}function bn(c,l){return l!==void 0&&l.some((d)=>oe(d)&&!Lt(c,d)&&(er(c,d)||H(c)))}function jr(c,l){return l!==void 0&&l.some((d)=>oe(d)&&er(d,c))}function er(c,l){let d=(R)=>R.length>1?R.replace(/\/+$/,""):R,[f,h]=[d(c),d(l)];return f===h||f.startsWith(h==="/"?h:h+"/")}function kn(c,l){return l===void 0||l.every((d)=>Lt(c,d))}function Vr(c,l){return l===void 0||l.every((d)=>yn(c,d))}function zr(c,l,d){let f=H(c)?rt(c):null;if(f===null||!kn(f,l))return;let h=le.join(c);if(H(h)&&je(h)===je(f))return h;return En(c,[],d)}function go(c){if(c?.anchors!==void 0&&c.anchors.length>0)return c.anchors;return c?.anchor!==void 0?[c.anchor]:void 0}async function gt(c,l=Yr){return ve(c)||Nt(c)||B(c)||ce(c)||await Ze(l,c,{surfaceNetworkRaw:!0,unreadableAncestry:"unverified"})!==void 0}function Te(c,l,d){return fo(Jr(l,d),(f)=>{if(f.kind==="lstat")return c.lstatSync(f.path);if(f.kind==="opendirNofollow")return c.openDirNoFollowSync(f.path),"ok";return c.readlinkSync(f.path)})}function Ze(c,l,d,f,h){return mo(Jr(l,d),f,async(R)=>{if(R.kind==="lstat"){if(h===void 0)return c.lstat(R.path);let T;try{T=await c.lstatBigint(R.path)}catch(D){throw h(R.path,void 0),D}return h(R.path,T),T}if(R.kind==="opendirNofollow")return await c.openDirNoFollow(R.path),"ok";return c.readlink(R.path)})}function fo(c,l){let d;for(;;){let f=c.next(d);if(f.done)return f.value;try{d=l(f.value)}catch(h){d={errno:t(h)}}}}async function mo(c,l,d){let f;for(;;){let h=c.next(f);if(h.done)return h.value;if(l?.aborted===!0)return M;try{f=await d(h.value)}catch(R){f={errno:t(R)}}}}function*Jr(c,l){let d=go(l);if(at(c)&&!bn(c,d))return c;if(w(c)&&!v(c)&&Vr(c,d)||H(c)&&kn(c,d))return;let f=le.resolve(c),h=le.parse(f).root,R=h,T=f.slice(h.length).split(xt).filter(Boolean),D=0,O=T.length,P=!1,F=!1,Y,ie=64,V=()=>T.some((te)=>k(te)),ae=()=>/[. ]$/.test(T[0]);while(T.length>0&&D<ie){if(P&&k(T[0]))return M;let te=le.join(R,T[0]);if(H(te)&&kn(te,d)||at(te)&&!(bn(te,d)||jr(te,d)))return En(te,T.slice(1),l?.onCollapsedLanding);if(W(te)){if(l?.surfaceNetworkRaw===!0||l?.unreadableAncestry==="unverified")return M;return En(te,T.slice(1),l?.onCollapsedLanding)}let fe=process.platform==="darwin"&&te!=="/dev/fd"&&er(te,"/dev/fd");if(fe&&le.dirname(te)==="/dev/fd"&&T.some((Ie,dt)=>dt>0&&(Ie===".."||Ie==="."))){T.shift();while(T[0]==="."&&T.length>1)T.shift();R=te;continue}let ne=fe?{errno:"ENOENT"}:yield{kind:"lstat",path:te};if(ne===void 0||typeof ne==="string"||"errno"in ne){if(process.platform!=="win32"&&typeof ne==="object"&&"errno"in ne&&ne.errno!==void 0&&ne.errno!=="ENOENT"&&ne.errno!=="ENOTDIR"&&ne.errno!=="ENAMETOOLONG"){if(typeof(yield{kind:"opendirNofollow",path:te})==="string"){F=!0,T.shift(),R=te;continue}}if(l?.launchAncestry&&!F&&typeof ne==="object"&&"errno"in ne&&(ne.errno==="EPERM"||ne.errno==="EACCES")&&ft(te,l.launchAncestry)){P=!0,T.shift(),R=te;continue}if(typeof ne==="object"&&"errno"in ne&&(ne.errno==="ENOENT"||ne.errno==="ENOTDIR"))l?.onOutcome?.({kind:"absent",at:R,remaining:[...T],fromLinkTarget:T.length>O,...ne.errno==="ENOTDIR"&&{notAFolder:!0}});return Gr(ne,l,D>0,V(),ae())}let de=ne;if(F=!0,!de.isSymbolicLink()){T.shift(),R=te;continue}D++;let ue=te+"\x00"+T.join("\x00");if((Y??=new Set).has(ue))return;Y.add(ue);let De=yield{kind:"readlink",path:te};if(typeof De!=="string")return Gr(De,l,D>0,V(),ae());let xe=De;if(l?.literalLinkText!==void 0&&(l.literalLinkText==="opaque"?po(xe):xe.includes("�")))return Ue;if(!le.isAbsolute(xe)){let Ie=xe.split(xt).filter(Boolean);if(l?.surfaceNetworkRaw===!0){let dt=zr((R.endsWith(le.sep)?R:R+le.sep)+[...Ie,...T.slice(1)].join(le.sep),d,l?.onCollapsedLanding);if(dt!==void 0)return dt}T.shift(),l?.onHop?.({composed:le.resolve(R,xe,...T),leaf:T.length===0,text:xe}),O=Math.min(O,T.length),T=[...Ie,...T];continue}let pe=xe;if(l?.surfaceNetworkRaw===!0&&T.length>1&&ce(pe)){let Ie=zr([pe,...T.slice(1)].join(le.sep),d,l?.onCollapsedLanding);if(Ie!==void 0)return Ie}if(w(pe)&&!v(pe)&&Vr(pe,d)||H(pe)&&kn(pe,d)||at(pe)&&!(bn(pe,d)||T.length>1&&jr(pe,d)))return T.shift(),En(pe,T,l?.onCollapsedLanding);if(l?.surfaceNetworkRaw===!0&&k(pe)&&(w(pe)||B(pe)||oe(pe)||ce(pe)))return T.shift(),T.length===0?pe:pe+le.sep+T.join(le.sep);T.shift();let Ae=le.parse(pe).root||le.sep,Ge=le.parse(te).root,Ve=/^[\\/]$/.test(Ae)&&Ge!==""&&!/^[\\/]$/.test(Ge);if(Ve&&(l?.surfaceNetworkRaw===!0||l?.unreadableAncestry==="unverified"))return M;l?.onHop?.({composed:T.length===0?pe:le.resolve(pe,...T),leaf:T.length===0,text:xe}),R=Ve?Ge:Ae,F=!1,O=Math.min(O,T.length),T=[...pe.slice(Ae.length).split(xt).filter(Boolean),...T]}if(T.length>0&&l?.literalLinkText==="opaque")return Ue;if(T.length>0)return M;if(D>0&&ce(R))return R;if(at(R)&&!bn(R,d))return R;l?.onOutcome?.({kind:"resolved",path:R});return}function he(c,l){if(w(l)&&!v(l)||H(l)||Mt(l))return{resolvedPath:l,isSymlink:!1,isCanonical:!1};let d=Te(c,l);if(d===M)return{resolvedPath:l,isSymlink:!1,isCanonical:!1};if(d!==void 0)return{resolvedPath:d,isSymlink:!0,isCanonical:!1};try{let f=_o(c,l);return{resolvedPath:f,isSymlink:f!==l,isCanonical:!0}}catch(f){return{resolvedPath:l,isSymlink:!1,isCanonical:!1}}}function qr(c){let l=kt();if(l===null)return null;try{let d=le.resolve(l),f=le.resolve(c.cwd()),h=le.parse(d).root;if(h!==le.parse(f).root)return null;let R=d.slice(h.length).split(xt).filter(Boolean),T=f.slice(h.length).split(xt).filter(Boolean),D=0;while(D<R.length&&D<T.length&&R[D]===T[D])D++;return D>0?le.join(h,...R.slice(0,D)):null}catch{return null}}function _o(c,l){try{return c.realpathSync(l)}catch(d){let f=t(d);if(f!=="EPERM"&&f!=="EACCES")throw d;let h,R=qr(c);if(Te(c,l,{unreadableAncestry:"unverified",surfaceNetworkRaw:!0,launchAncestry:R,onOutcome:(D)=>{h=D}})!==void 0||h===void 0)throw d;if(h.kind==="absent")throw Object.assign(Error("ENOENT: no such file or directory"),{code:"ENOENT",syscall:"realpath",path:l});return g(h.path)}}var Ht="ERR_SYMLINK_TO_NETWORK_PATH";function Fe(c,l,d){let{asWritten:f,opts:h}=So(c,l,d),R,T;return Eo(Te(c,f,{...h,onOutcome:(D)=>{R=ho(D),T=yo(D)}}),l,f),{...bo(f),linksResolvedPath:R,absentAt:T}}function ho(c){return c.kind==="resolved"?g(c.path):void 0}function yo(c){return c.kind==="absent"?{at:c.at,remaining:c.remaining,fromLinkTarget:c.fromLinkTarget,...c.notAFolder&&{notAFolder:!0}}:void 0}function So(c,l,d){let f=z(l);if(j(f)||Pt(f))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:Ht,path:l,reason:"unexamined"});let h=le.isAbsolute(f)?le.resolve(f):le.resolve(process.cwd(),f),R=z(h);if(j(R)||Pt(R))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:Ht,path:l,reason:"unexamined"});let T=at(R)||H(R)||w(R)&&!v(R);return{asWritten:R,ownHost:T,opts:{...T&&{anchors:[R]},surfaceNetworkRaw:!0,literalLinkText:process.platform==="win32"?"opaque":"undecodable",...(!T||d?.failClosed)&&{unreadableAncestry:"unverified",launchAncestry:qr(c)}}}}function bo(c){return{resolvedPath:c,isSymlink:!1,isCanonical:!1}}function Eo(c,l,d){if(c===void 0)return;let f=(R)=>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:Ht,path:l,reason:R});if(c===M)throw f("unexamined");if(c===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:Ht,path:l,reason:"unexamined"});if(at(d)&&c===d)return;if(!(w(c)||B(c)||at(c)||ce(c)))throw f("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:Ht,path:l,reason:"network"})}var Yr={cwd(){return process.cwd()},existsSync(c){let d=[];try{const l=_(d,C`fs.existsSync(${c})`,0);return se.existsSync(c)}catch(f){var h=f,R=1}finally{S(d,h,R)}},async stat(c){return Wr(c)},async lstat(c){return Xn(c)},async openDirNoFollow(c){if(process.platform==="win32")throw Error("openDirNoFollow is a POSIX-only examination probe");await(await Sn(c,se.constants.O_DIRECTORY|se.constants.O_NOFOLLOW)).close()},openDirNoFollowSync(c){if(process.platform==="win32")throw Error("openDirNoFollowSync is a POSIX-only examination probe");let l=se.openSync(c,se.constants.O_DIRECTORY|se.constants.O_NOFOLLOW);se.closeSync(l)},async lstatBigint(c){return Xn(c,{bigint:!0})},async statBigint(c){return Wr(c,{bigint:!0})},async readdir(c){return Xi(c,{withFileTypes:!0})},async unlink(c){return so(c)},async rmdir(c){return no(c)},async rm(c,l){return ro(c,l)},async mkdir(c,l){try{await Zi(c,{recursive:!0,...l})}catch(d){if(t(d)!=="EEXIST")throw d}},async readFile(c,l){return $r(c,{encoding:l.encoding})},async rename(c,l){return to(c,l)},async realpath(c){return g(await eo(c))},async readlink(c){return Qi(c)},async copyFile(c,l){return qi(c,l)},async appendFile(c,l,d){if(d?.mode!==void 0)try{let f=await Sn(c,"ax",d.mode);try{await f.appendFile(l)}finally{await f.close()}return}catch(f){if(t(f)!=="EEXIST")throw f}return Ji(c,l)},async link(c,l){return Yi(c,l)},statSync(c){let d=[];try{const l=_(d,C`fs.statSync(${c})`,0);return se.statSync(c)}catch(f){var h=f,R=1}finally{S(d,h,R)}},lstatSync(c){let d=[];try{const l=_(d,C`fs.lstatSync(${c})`,0);return se.lstatSync(c)}catch(f){var h=f,R=1}finally{S(d,h,R)}},readFileSync(c,l){let f=[];try{const d=_(f,C`fs.readFileSync(${c})`,0);return se.readFileSync(c,{encoding:l.encoding})}catch(h){var R=h,T=1}finally{S(f,R,T)}},readSync(c,l){let h=[];try{const d=_(h,C`fs.readSync(${c}, ${l.length} bytes)`,0);let f=se.openSync(c,"r");try{let O=mt(f,l.length,"file");return{buffer:O,bytesRead:O.length}}finally{se.closeSync(f)}}catch(R){var T=R,D=1}finally{S(h,T,D)}},appendFileSync(c,l,d){let h=[];try{const f=_(h,C`fs.appendFileSync(${c}, ${l.length} chars)`,0);if(d?.mode!==void 0)try{let O=se.openSync(c,"ax",d.mode);try{se.appendFileSync(O,l)}finally{se.closeSync(O)}return}catch(O){if(t(O)!=="EEXIST")throw O}se.appendFileSync(c,l)}catch(R){var T=R,D=1}finally{S(h,T,D)}},unlinkSync(c){let d=[];try{const l=_(d,C`fs.unlinkSync(${c})`,0);se.unlinkSync(c)}catch(f){var h=f,R=1}finally{S(d,h,R)}},renameSync(c,l){let f=[];try{const d=_(f,C`fs.renameSync(${c} ${io} ${l})`,0);se.renameSync(c,l)}catch(h){var R=h,T=1}finally{S(f,R,T)}},readlinkSync(c){let d=[];try{const l=_(d,C`fs.readlinkSync(${c})`,0);return se.readlinkSync(c)}catch(f){var h=f,R=1}finally{S(d,h,R)}},realpathSync(c){let d=[];try{const l=_(d,C`fs.realpathSync(${c})`,0);return g(se.realpathSync(c))}catch(f){var h=f,R=1}finally{S(d,h,R)}},mkdirSync(c,l){let h=[];try{const d=_(h,C`fs.mkdirSync(${c})`,0);let f={recursive:!0};if(l?.mode!==void 0)f.mode=l.mode;try{se.mkdirSync(c,f)}catch(O){if(t(O)!=="EEXIST")throw O}}catch(R){var T=R,D=1}finally{S(h,T,D)}},readdirSync(c){let d=[];try{const l=_(d,C`fs.readdirSync(${c})`,0);return se.readdirSync(c,{withFileTypes:!0})}catch(f){var h=f,R=1}finally{S(d,h,R)}},rmSync(c,l){let f=[];try{const d=_(f,C`fs.rmSync(${c})`,0);se.rmSync(c,l)}catch(h){var R=h,T=1}finally{S(f,R,T)}},createWriteStream(c){return se.createWriteStream(c)},async readFileBytes(c,l){if(l===void 0)return $r(c);let d=await Sn(c,Je());try{if(!(await d.stat()).isFile())return Buffer.alloc(0);return await Qe(d,l,"file")}finally{await d.close()}},async readFileFdGated(c,l){try{let d=oo();if(d===0){if(!(await Xn(c)).isFile())return null}let f=await Sn(c,se.constants.O_RDONLY|d);try{let h=await f.stat();if(!h.isFile()||h.size>l)return null;let R=Number(h.size),T=Buffer.allocUnsafe(R),D=0;while(D<R){let{bytesRead:O}=await f.read(T,D,R-D,D);if(O===0)break;D+=O}return{content:(D<R?T.subarray(0,D):T).toString("utf8"),stats:h}}finally{await f.close()}}catch{return null}}};function i(){return Yr}var cl=a({hasThrown:!1},(c)=>{c.hasThrown=!1});async function Qe(c,l,d){let f=d!==void 0?d==="file":(await c.stat()).isFile(),h=[],R=0,T=Yn();try{while(R<l){let D=T.subarray(0,l-R),{bytesRead:O}=await c.read(D,0,D.length,f?R:null);if(O===0)break;h.push(Buffer.from(D.subarray(0,O))),R+=O}}finally{Zn(T,R)}return Buffer.concat(h,R)}function mt(c,l,d){let f=[],h=0,R=Yn();try{while(h<l){let T=R.subarray(0,l-h),D=se.readSync(c,T,0,T.length,d==="file"?h:null);if(D===0)break;f.push(Buffer.from(T.subarray(0,D))),h+=D}}finally{Zn(R,h)}return Buffer.concat(f,h)}function ko(c,l,d){if(c.destroyed||c.writableEnded)return"dropped";return c.write(l,d)===!1?"backed-up":"accepted"}class tr{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(c){this.bytesQueued+=c}recordFlushed(c){this.bytesFlushed+=c,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 c=process.stdout;if(c.isTTY||c.destroyed||c.writableEnded||!this.everWritten)return;this.drainPromise=new Promise((l)=>c.end(l))}return this.drainPromise}fullyFlushed(){if(this.flushConfirmedPromise===void 0)this.flushConfirmedPromise=new Promise((c)=>{let l=()=>{if(this.outstandingBytes()<=0)this.notifyFlushProgress=void 0,c()};this.notifyFlushProgress=l,this.flushCloseListener=l,process.stdout.once("close",l),l()});return this.flushConfirmedPromise}isExternallyClocked(){return this.externallyClocked}ensureExternallyClockedPromise(){return this.externallyClockedPromise??=new Promise((c)=>{this.notifyExternallyClocked=c})}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 tr)}}var kl=new tr;var Zr=1048576,xo=1e4,Ao=be((c)=>c());class nr{unflushed={length:0,since:0};droppedCount=0;droppedTotal=0;write(c,l){let d=this.unflushed;if(l&&d.length>=Zr&&(this.droppedCount>0||Date.now()-d.since>=xo)){this.droppedCount++,this.droppedTotal++;return}let f="writing",h=()=>{let T=f==="unflushed";if(f="flushed",T)d.length-=c.length,this.reportDropped()};if(Ao(()=>ko(process.stderr,c,h))==="backed-up"&&f==="writing"){if(f="unflushed",d.length===0)d.since=Date.now();d.length+=c.length}}giveUpOnUnflushed(){this.unflushed={length:0,since:0},this.reportDropped()}getDroppedTotal(){return this.droppedTotal}reset(){Object.assign(this,new nr)}reportDropped(){if(this.droppedCount>0&&this.unflushed.length<Zr){let c=this.droppedCount;this.droppedCount=0,this.write(`[stderr messages dropped before this line: ${c}. Whatever reads this stderr had not caught up for over 10 s and 1 MiB of output.]
17
- `,!1)}}}var wo=a(new nr,(c)=>c.reset());function Xr(c,{mayDrop:l=!1}={}){wo.write(c,l)}function Le(c){return c.charAt(0).toUpperCase()+c.slice(1)}function q(c,l,d=l+"s"){return c===1?l:d}function ct(c){let l=0;for(let d=0;d<c.length;d++){let f=c.charCodeAt(d);if(f>=55296&&f<=56319&&d+1<c.length){let h=c.charCodeAt(d+1);if(h>=56320&&h<=57343)d++}l++}return l}function ge(c,l){if(l<=0)return"";if(c.length<=l)return c;let d=c.slice(0,l),f=d.charCodeAt(l-1);return es(f>=55296&&f<=56319?d.slice(0,-1):d)}function ut(c,l){if(l<=0)return"";if(c.length<=l)return c;let d=c.slice(-l),f=d.charCodeAt(0);return es(f>=56320&&f<=57343?d.slice(1):d)}function es(c){if(typeof Buffer<"u")return Buffer.from(c,"utf16le").toString("utf16le");return Ro(c)}function Ro(c){let d=[];for(let f=0;f<c.length;f+=8192){let h=Math.min(f+8192,c.length),R=new Uint16Array(h-f);for(let T=f;T<h;T++)R[T-f]=c.charCodeAt(T);d.push(String.fromCharCode(...R))}return d.join("")}var Co=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/,ts=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,xn=typeof String.prototype.isWellFormed==="function"?Function.prototype.call.bind(String.prototype.isWellFormed):void 0,Qr=typeof String.prototype.toWellFormed==="function"?Function.prototype.call.bind(String.prototype.toWellFormed):void 0;function Oe(c){if(xn)return xn(c);return!Co.test(c)}function Yt(c){if(Qr)return Qr(c);return c.replace(ts,"�")}function Me(c){if(xn&&xn(c))return c;return c.replace(ts,"")}function Ye(c,l){let d=c.indexOf(l);return d===-1?c:c.slice(0,d)}function qt(c,l){return c.endsWith(l)?c.slice(0,c.length-l.length):c}function Xt(c,l,d=0){let f=0,h=c.indexOf(l,d);while(h!==-1)f++,h=c.indexOf(l,h+1);return f}var ns=/[\x00-\x08\x0E-\x1F\x7F-\x9F]/g;function rs(c){return c.replace(ns,"").replace(/\s+/g," ").trim()}var To=/[\t\n\v\f\r\u2028\u2029]/g,Al=new RegExp(`${ns.source}|${To.source}`);function Do(c){return c.replace(/[\p{Cc}\p{Cf}\p{Cs}\p{Default_Ignorable_Code_Point}\u2028\u2029]/gu,"")}var vo=/[\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 Oo(c){let l=/[\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}\u2028\u2029]/gu;if(!l.test(c))return c;let d="";for(let{segment:f}of new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(c)){let h=/\p{Extended_Pictographic}|\p{Regional_Indicator}|^[#*0-9]\uFE0F?\u20E3$/u.test(f),R=/^\u{1F3F4}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,6}\u{E007F}$/u.test(f);l.lastIndex=0,d+=f.replace(l,(T,D)=>{if(T===`
18
- `||T==="\t")return T;let O=T.codePointAt(0)??0;if(h&&(T==="️"||T==="︎"||T==="⃣"||T==="‍"&&D+T.length<f.length||R&&O>=917536&&O<=917631))return T;if(O===27)return"␛";if(O<32)return String.fromCodePoint(9216+O);if(O===127)return"␡";return`\\u{${O.toString(16).toUpperCase()}}`})}return d}function qe(c){return Oo(c).replace(/\n/g,"␤").replace(/\t/g,"␉")}function A(c){return Do(rs(c.replace(vo,""))).trim()}var Io=8;function pt(c,l=0){if(typeof c==="string")return c;if(typeof c==="number"||typeof c==="boolean")return String(c);if(Array.isArray(c)){if(l>=Io)return;let d=[];for(let f of c){let h=f===null||f===void 0?"":pt(f,l+1);if(h===void 0)return;d.push(h)}return d.join(",")}return typeof c==="object"&&c!==null&&Object.getPrototypeOf(c)===Object.prototype&&!Object.hasOwn(c,"toString")?"[object Object]":void 0}var Po=/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF]|[\uDC00-\uDFFF]/g;function Lo(c){return c.replace(Po,(l)=>l.length===2?l:"")}var Uo=/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Default_Ignorable_Code_Point}\u2800]|(?!\u0020)\p{Zs}/gu;function Qt(c){if(typeof c!=="string")return"";let l=c;for(let d=0;d<64;d++){let f=Lo(l).replace(Uo,"");if(f===l)return f;l=f}return""}function ss(c){return/^(?:0|[1-9]\d{0,9})$/.test(c)&&Number(c)<4294967295}var No=16,Tl=6*No;var is=a({},(c)=>{c.limits=void 0});function Mo(){return is.limits!==void 0}function os(c){return is.limits?.onPast(c),Mo()}var Fo="\\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}",cs=`[\\p{M}\\uFF9E\\uFF9F${Fo}]`,Ko=new RegExp(`${cs}{32,}`,"gu"),Bo=new RegExp(cs,"u");var rr=new Map,Tt=[],sr=new Map;function An(c,l){return c!==l&&(c+l).normalize("NFD")===l+c}function ls(c){let l=rr.get(c);if(l!==void 0)return l;let d=String.fromCodePoint(c),f=null;if(d==="̴"||An(d,"̴")||An("ͅ",d)){let h=0,R=Tt.length;while(h<R&&f===null){let T=h+R>>1,D=Tt[T];if(An(d,D.sample))h=T+1;else if(An(D.sample,d))R=T;else f=D}if(f===null){f={order:h,sample:d},Tt.splice(h,0,f);for(let T=h+1;T<Tt.length;T++)Tt[T].order=T}}return rr.set(c,f),f}function ds(c){let l=sr.get(c);if(l===void 0)l=Array.from(String.fromCodePoint(c).normalize("NFKD"),(d)=>d.codePointAt(0)),sr.set(c,l);return l}var as=4096;function Ho(c,l){let d="";for(let f=0;f<l;f+=as)d+=String.fromCodePoint(...c.subarray(f,Math.min(f+as,l)));return d}function $o(c){let l=new Int32Array(c.length+16),d=0;for(let T=0;T<c.length;){let D=c.codePointAt(T);T+=D>65535?2:1;for(let O of ds(D)){if(d===l.length){let P=new Int32Array(l.length*2);P.set(l),l=P}l[d++]=O,ls(O)}}let f=new Int16Array(d);for(let T=0;T<d;T++)f[T]=rr.get(l[T])?.order??-1;let h=l.slice(0,d),R=new Int32Array(Tt.length);for(let T=0;T<d;){let D=T,O=!0;while(D<d&&f[D]>=0)O&&=D===T||f[D-1]<=f[D],D++;if(O){T=D+1;continue}R.fill(0);for(let F=T;F<D;F++)R[f[F]]++;let P=T;for(let F=0;F<R.length;F++){let Y=R[F];R[F]=P,P+=Y}for(let F=T;F<D;F++)h[R[f[F]]++]=l[F];T=D}return Ho(h,d)}function Wo(c){return c.length<32?c:c.replace(Ko,$o)}var us=128;function ps(c){if(c<768)return!0;let l=sr.get(c);if(l===void 0&&!Bo.test(String.fromCodePoint(c)))return!0;return ls((l??ds(c))[0])===null}function Go(c,l){let d=l;if(d<c.length&&(c.charCodeAt(d)&64512)===56320&&(c.charCodeAt(d-1)&64512)===55296)d++;while(d<c.length){let f=c.codePointAt(d);if(ps(f))break;d+=f>65535?2:1}return Math.min(d,c.length)}function jo(c){let l=c.length;while(l>0){if(l--,l>0&&(c.charCodeAt(l)&64512)===56320&&(c.charCodeAt(l-1)&64512)===55296)l--;if(ps(c.codePointAt(l)))return l}return 0}function Vo(c,l){let d=Wo(c);if(d.length<=us)return d.normalize(l);let f=[],h="";for(let R=0;R<d.length;){let T=Go(d,R+us),D=(h+d.slice(R,T)).normalize(l),O=T===d.length?D.length:jo(D);f.push(D.slice(0,O)),h=D.slice(O),R=T}return f.join("")}function ir(c){return Vo(c,"NFKC")}var gs="˹-˼⌌-⌏⌜-⌟⎛-⏌⏜-⏡⸀-⸍⸜⸝─-╿",zo=new Map([["˂","<"],["˃",">"],["ᐳ",">"],["ᐸ","<"],["ᚲ","<"],["‹","<"],["›",">"],["≮","<"],["≯",">"],["≺","<"],["≻",">"],["⊀","<"],["⊁",">"],["⋖","<"],["⋗",">"],["〈","<"],["〉",">"],["❬","<"],["❭",">"],["❮","<"],["❯",">"],["❰","<"],["❱",">"],["⟨","<"],["⟩",">"],["⦑","<"],["⦒",">"],["⦓","<"],["⦔",">"],["⧼","<"],["⧽",">"],["⩹","<"],["⩺",">"],["⪦","<"],["⪧",">"],["〈","<"],["〉",">"],["︿","<"],["﹀",">"],["﹤","<"],["﹥",">"],["<","<"],[">",">"],["\uD81B\uDF3F",">"],["\uD834\uDE36","<"],["\uD834\uDE37",">"]]);var or=new Map([...zo,...Array.from("≪⋘⪡⫷⟪︽",(c)=>[c,"<"]),...Array.from("≫⋙⪢⫸⟫︾",(c)=>[c,">"])]),Jo=new Map([...or,["《","<"],["》",">"]]),Ul=new Set(`⦒⦔⩺⪧${"≫⋙⪢⫸⟫︾"}`);function en(c){let l=c;for(let[d,f]of Jo)if(f===c)l+=d;return l}var Kl=new RegExp(`[${gs}]|(?![\\x00-\\x7f])[\\p{Sm}\\p{Sk}\\p{So}]`,"gu"),Bl=new RegExp(`[${[...or.keys()].join("")}]`,"gu");var ms="\\p{Default_Ignorable_Code_Point}\\u2800",N=`\\p{Cc}\\p{Cf}\\p{Cs}\\p{Co}\\p{Cn}\\u2028\\u2029${ms}`,Wt=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`,_s=String.raw`\u0600-\u0605\u06dd\u070f\u0890\u0891\u08e2`,Dt=`[${Wt}${_s}\\ufeff]*`,ed=new RegExp(`[${Wt}${_s}\\ufeff]`);function Gt(c){return c.replace(/([a-z)])(?=[a-z(\[])/gi,`$1${Dt}`).replace(/\[_-\]\?/g,`(?:[_-]${Dt})?`)}var td=new RegExp(`[${N}]+`,"gu"),ar="\\u200D\\uFE0E\\uFE0F",nd=new RegExp(`(?:(?![${ar}])[${N}])+`,"gu"),rd=new RegExp(`(?:(?![${ar}\\n])[${N}])+`,"gu"),sd=new RegExp(`(?<!\\S)[${ar}]+`,"gu");var id=new RegExp(`[${N}]`,"u");var $t="[\\p{M}\\u1160-\\u11FF\\uD7B0-\\uD7FF]",od=new RegExp(`(?<![\\p{L}\\p{N}\\p{M}])${$t}|${$t}{9}|\\p{Soft_Dotted}\\p{M}*\\u0307|[\\u0131\\u0237]\\p{M}|(?<=[\\p{sc=Latin}\\p{sc=Common}]${$t}*)(?!\\p{sc=Inherited})${$t}`,"u"),qo=String.raw`\u0620\u0626\u0628\u062A-\u062E\u0633-\u063F\u0641-\u0647\u0649\u064A\u066E\u066F\u0678-\u0687\u069A-\u06BF\u06C1\u06C2\u06CC\u06CE\u06D0\u06D1\u06FA-\u06FC\u06FF\u0750-\u0758\u075C-\u076A\u076D-\u0770\u0772\u0775-\u0777\u077A-\u077F\u0886\u0889-\u088D\u088F\u08A0-\u08A9\u08AF\u08B0\u08B3-\u08B8\u08BA-\u08C8`,Yo=String.raw`\u0620\u0622-\u063F\u0641-\u064A\u066E\u066F\u0671-\u0673\u0675-\u06D3\u06D5\u06EE\u06EF\u06FA-\u06FC\u06FF\u0750-\u077F\u0870-\u0882\u0886\u0889-\u088F\u08A0-\u08AC\u08AE-\u08C8`,Zo=[2304,2432,2688,2816,3072,3200,3328].map(Xo),fs=String.raw`[\u0D9A-\u0DC6]`,ad=new RegExp([...Zo,`\\u200D(?<=${fs}\\u0DCA.)(?=${fs})`,`\\u200C(?<=[${qo}](?:(?=[\\p{sc=Arabic}\\p{sc=Inherited}])(?!\\p{Default_Ignorable_Code_Point})\\p{Mn}){0,8}.)(?=[${Yo}])`].join("|"),"gu"),ud=new RegExp(`\\u20E3|\\u263A${$t}`,"u");function Xo(c){let l=`[${wn(c+21)}-${wn(c+57)}]`,d=c===3328?"":`${wn(c+60)}?`;return`[\\u200C\\u200D](?<=${l}${d}${wn(c+77)}.)(?=${l})`}function wn(c){return`\\u{${c.toString(16)}}`}var Qo=new RegExp(`[\\p{Cf}\\p{Co}\\p{Cn}\\u2028\\u2029\\u007F-\\u009F${ms}]`,"gu");function ea(c){let l=c.replace(/[\p{Cf}\p{Co}\p{Cn}]/gu,"");return l=l.replace(/[\u200B-\u200F]/g,"").replace(/[\u202A-\u202E]/g,"").replace(/[\u2066-\u2069]/g,"").replace(/[\uFEFF]/g,"").replace(/[\uE000-\uF8FF]/g,""),l}function ta(c){let l=Me(c);for(let d=0;d<10;d++){let f=ea(l);if(f===l)return l;l=f}return l}function na(c){return!/[^\0-\x7f]/.test(c)}function ra(c){if(na(c))return c;let l=c,d="",f=0,h=10;while(l!==d&&f<h)d=l,l=ir(l),l=ta(l),f++;if(f>=h)throw Error(`Unicode sanitization reached maximum iterations (${h}) for input: ${c.slice(0,100)}`);return l}function _e(c){if(typeof c==="string")return ra(c);if(Array.isArray(c))return c.map(_e);if(c!==null&&typeof c==="object"){let l={};for(let[d,f]of Object.entries(c)){let h=_e(d);if(h!=="__proto__"&&(h===d||!ss(h)||Number(h)<64||!os("cleaned_key")))l[h]=_e(f)}return l}return c}function tn(c){return c.replace(/[\p{Cc}\p{Cf}\u2028\u2029]+/gu," ")}function hs(c){return c.replace(Qo,(l)=>Array.from({length:l.length},(d,f)=>`\\u${l.charCodeAt(f).toString(16).padStart(4,"0")}`).join(""))}function ys(c){return c.split("").map((l)=>"\\u"+l.charCodeAt(0).toString(16).padStart(4,"0")).join("")}function Ss(c){let l=new Int32Array(c.length);for(let d=0;d<c.length;d++)l[d]=d;return{text:c,origin:l}}function bs(c,l,d){let f=[];for(let h of c.text.matchAll(l)){let{keep:R,insert:T,keepEnd:D=0}=d(h),O=h.index??0,P=h[0].length,F=Math.min(Math.max(R|0,0),P),Y=Math.min(Math.max(D|0,0),P-F);f.push([O+F,O+P-Y,T])}return Tn(c,f)}function Tn(c,l){if(l.length===0)return c;let{text:d,origin:f}=c,h=d.length;for(let[P,F,Y]of l)h+=Y.length-(F-P);let R=new Int32Array(h),T=[],D=0,O=0;for(let[P,F,Y]of l)T.push(d.slice(D,P)),R.set(f.subarray(D,P),O),O+=P-D,T.push(Y),R.fill(-1,O,O+Y.length),O+=Y.length,D=F;return T.push(d.slice(D)),R.set(f.subarray(D),O),{text:T.join(""),origin:R}}function we(c){let l=0;while(l<c.length&&c.charCodeAt(l)<=32)l++;let d=c.slice(l),f=/^([A-Za-z0-9][A-Za-z0-9+.-]*):\/\//.exec(d),h=f?.[1]?.toLowerCase(),R=f?d.slice(f[0].length):d,T=R.indexOf(":"),D=R.indexOf("/");if(!(h!==void 0?h!=="file":T!==-1&&(D===-1||T<D)&&!/^[A-Za-z]:/.test(R))){let ie=f?Vt(R):R;return ie.includes("@[")||ie.startsWith("[")}let P=Vt(R),F=f?/^(?:[^@/?#\\[\]]+@)?(\[[0-9A-Fa-f:.]+\])(?::\d*)?(?=\/|$)/.exec(P):/^[^@:/[\]]+@(\[[0-9A-Fa-f:.]+\])(?=:)/.exec(P),Y=F!==null&&!!X(`ssh://${F[1]}/`)?.hostname;return/[[\]]/.test(P.slice(Y?F[0].length:0))}function X(c){try{return new URL(c)}catch{return null}}function Vt(c){return c.replace(/%([0-9A-Fa-f]{2})/g,(l,d)=>{let f=parseInt(d,16);return f===0?l:String.fromCharCode(f)})}function ke(c,{asRewritten:l=!1}={}){let d=c.trimStart(),f=/^([A-Za-z][A-Za-z0-9+.-]*):\/\//.exec(d);if(f){let h=f[1]?.toLowerCase();if(h==="file")return null;if(h==="http"||h==="https"){let R=X(d);return R?.hostname?{host:R.hostname,path:R.pathname}:null}return Es(He(d.slice(f[0].length)),"/")}return Es(l?He(d):d,":")}function xs(c,l){let d=c.indexOf("@["),f=d===-1?0:d+1,h=c[f]==="["?f:-1,R=h===-1?-1:c.indexOf("]",h+1),T=c.indexOf(l,R===-1?0:R+1);return{open:h,close:R,cut:T}}function Es(c,l){let{open:d,close:f,cut:h}=xs(c,l),R=d===-1?0:d,T=c.indexOf("/");if(l===":"&&(h===-1||T!==-1&&T<c.indexOf(":")))return null;let D=h===-1?"":c.slice(l===":"?h+1:h);if(f!==-1){let Y=c.slice(f+1,h===-1?c.length:h),ie=c.slice(0,R)+c.slice(R+1,f),V=ks(Y)!==Y?ie:ks(ie),ae=V.slice(V.lastIndexOf("@")+1),te=X(`ssh://[${ae}]/`)?.hostname;return ae?{host:te||ae,path:D}:null}let O=h===-1?c:c.slice(0,h),P=O.slice(O.lastIndexOf("@")+1);if(P.startsWith("["))return null;let F=l==="/"?P.replace(/:\d*$/,""):P;return F?{host:F,path:D}:null}function As(c){let{text:l,from:d}=sa(c),{close:f,cut:h}=xs(l,"/"),R=h===-1?l.length:h,T=[],D=(O,P)=>{let F=l.lastIndexOf("@",P-1);if(F>=O)T.push([d(O),d(F)])};if(f===-1)D(0,R);else D(0,f),D(f+1,R);return T}function He(c){return c.replace(/(?:%(?!00)[0-9A-Fa-f]{2})+/g,(l)=>{try{return decodeURIComponent(l)}catch{return Vt(l)}})}function sa(c){if(!c.includes("%"))return{text:c,from:(h)=>h};let l=[],d="",f=0;for(let h of c.matchAll(/(?:%(?!00)[0-9A-Fa-f]{2})+/g)){for(let P=f;P<h.index;P++)l.push(P);d+=c.slice(f,h.index);let R,T;try{R=decodeURIComponent(h[0]),T=Array.from(R,(P)=>{let F=P.codePointAt(0);return F<128?1:F<2048?2:F<65536?3:4})}catch{R=Vt(h[0]),T=Array.from(R,()=>1)}let D=h.index,O=0;for(let P of T){let F=R.codePointAt(O)>65535?2:1;for(let Y=0;Y<F;Y++)l.push(D);O+=F,D+=3*P}d+=R,f=h.index+h[0].length}for(let h=f;h<=c.length;h++)l.push(h);return{text:d+c.slice(f),from:(h)=>l[h]}}function ks(c){let l=c.indexOf(":"),d=c.slice(l+1);if(l===-1||!/^[ \t\n\v\f\r]*[+-]?\d+$/.test(d))return c;let f=Number.parseInt(d.trim(),10);return f>=0&&f<65536?c.slice(0,l):c}var ia=/\s/g,oa=/[\n\r\u2028\u2029]/g,aa=/(?:@|%40)(?:\[|%5B)/gi,ua=/^(?:\[|%5B)/i,ca=/\]|%5D/gi,la=/(?:^|[^A-Za-z0-9+.-])(?:https?|wss?|ftps?)$/i,Ts=/(?:^|[^A-Za-z0-9+.-])(?:ssh|git|git\+ssh|ssh\+git)$/i,da=/[,;|&]/g,pa=/(?:^|[^A-Za-z0-9+.-])[A-Za-z][A-Za-z0-9+.-]{0,31}$/,ga=/["'`|,;&<>()[\]\\@/?#]|%40|%5B/i,fa=/["'`]/,ma=/[;|&\n]/g,Ds=/\[REDACTED|\*\*\*:\*\*\*/g,vs=`@|%40|${Ds.source}`,_a=64,ha=2048,ya=/[\s"'`]/g;function Os(c){let l=[],d=Re(c,ya),f=0;for(let h=c.indexOf("://");h!==-1;){let R=h+3;if(h>=f&&Ts.test(c.slice(Math.max(0,h-8),h))){f=Math.min(d(R),R+ha);for(let[T,D]of As(c.slice(R,f)))l.push([R+T,R+D])}h=c.indexOf("://",R)}return l}function Sa(c){let l=[],d=[],f=Re(c,ia),h=Re(c,/\//g),R=ur(c,aa),T=Re(c,ca),D=Re(c,/\//g),O=Re(c,ma),P=Re(c,/[/?#]/g),F=Re(c,da),Y=Re(c,/@/g),ie=Re(c,/%40/gi),V=Re(c,Ds),ae=Re(c,/[:%]/g),te=Re(c,/["'`,;|&<>{}()]/g),fe=Cs(c,!1),ne=Cs(c,!0);for(let de=c.indexOf("://");de!==-1;){let ue=de+3,De=c.indexOf("://",ue),xe=f(ue),pe=Y(ue),We;if(la.test(c.slice(Math.max(0,de-8),de))){let Ae=Math.min(P(ue),xe),Ge=Math.min(F(ue),Ae);if(We=pe<Ae?Math.max(fe(ue,Ae),ne(pe,Ae)):Math.max(fe(ue,Math.min(h(ue),xe)),ne(ue,Ge)),We<=ue){let Ve=Math.min(Ae,O(ue));d.push({start:ue,fieldEnd:Math.min(Ge,Ve),lastEncodedAt:ne(ue,Ve)})}}else{let Ae=Math.min(h(ue),xe),Ge=Math.min(xe,De===-1?c.length:De),Ve=Ts.test(c.slice(Math.max(0,de-8),de)),Bt=Ve?R(ue):null,Ie=Ve?ua.exec(c.slice(ue,ue+3)):null,dt=[[Ie!==null?ue+Ie[0].length:-1,Ge],[Bt!==null&&Bt.index<Ge?Bt.index+Bt[0].length:-1,xe]];for(let[Dr,Ti]of dt){let vr=Dr===-1?xe:T(Dr);if(vr<Ti)Ae=Math.max(Ae,Math.min(D(vr),xe))}We=Math.max(fe(ue,Ae),ne(ue,Ae))}if(We>ue)l.push({start:ue,end:We,separatorEnd:We+(c[We]==="@"?1:3),loginEnd:pe<=We?pe:Math.min(ie(ue),We)});else{let Ae=V(ue);if(Ae>ue&&Ae<Math.min(xe,h(ue),te(ue))&&ae(ue)<Ae)l.push({start:ue,end:Ae,separatorEnd:Ae,loginEnd:Ae})}de=De}return{spans:l,hostParts:d}}function Is(c,l){let{spans:d,hostParts:f}=Sa(c);if(d.length===0&&f.length===0)return[];let h=Re(c,/[\s"'>}|,;&`)\]]/g),R=Re(c,/\s/g),T=[],D=[];for(let V of d)T.push({start:V.start,end:V.end,loginEnd:V.loginEnd}),D.push({...V,userinfo:V});let O=Dn(c,l);for(let V of f){let ae=O(V.start)[0];if(ae&&ae.keyStart<V.fieldEnd&&c.slice(V.start,ae.keyStart).includes("%")){let te=V.lastEncodedAt>ae.keyStart?V.lastEncodedAt:ae.valueStart;T.push({start:V.start,end:te,loginEnd:te}),D.push(te>ae.valueStart?{start:V.start,end:te,userinfo:{start:V.start,end:te,separatorEnd:te+3,loginEnd:te}}:{start:V.start,end:te})}}if(D.length===0)return[];T.sort((V,ae)=>V.start-ae.start);let P=Dn(c,l),F=0;for(let V=0,ae=P(V);ae[0]!==void 0;){let te,fe=null;for(let de of ae)if(fe=de.valueEnd(),fe!==null){te=de;break}if(te===void 0||fe===null){V=ae[0].keyStart+1,ae=P(V);continue}while(F<T.length&&T[F].start<=te.keyStart)F++;let ne=T[F];if(ne!==void 0&&ne.start<fe){let de=c[te.valueStart]??"",De=(de==='"'||de==="'")&&fe-1>te.valueStart&&c[fe-1]===de?Math.max(fe,ne.end):R(Math.max(fe,ne.end,h(ne.loginEnd+1)));D.push({start:te.valueStart,end:De})}V=fe,ae=P(V)}let Y={nextKey:Dn(c,l),plainKeys:Dn(c,l),nextLineEnd:Re(c,oa),span:0,lineEnd:-1,resumeAt:0,overflowEnd:ka(c,()=>Y.lineEnd)},ie=[];for(let V of Aa(D)){let ae=ie.at(-1);ie.push(ae!==void 0&&V.start<ae.end?Rs(c,{start:ie.pop().start,end:Math.max(ae.end,V.end)},Y):Rs(c,V,Y))}return ie.map((V)=>V.userinfo?V:xa(c,V))}var ws=new WeakMap;function ba(c){let l=ws.get(c);if(!l)l={word:new RegExp(c.word,"gi"),notTail:new RegExp(`(?!${c.tail})[^]`,"gi"),separator:new RegExp(c.separator,"iy"),value:new RegExp(c.value,"iy")},ws.set(c,l);return l}function Dn(c,l){let d=l.map((f)=>{let{word:h,notTail:R,separator:T,value:D}=ba(f),O=ur(c,h),P=Re(c,R),F=-1,Y=-1,ie=-1,V=null,ae=(de)=>{if(de!==ie)ie=de,D.lastIndex=de,V=D.test(c)?D.lastIndex:null;return V},te=(de)=>{if(de!==F)F=de,T.lastIndex=de,Y=T.test(c)?T.lastIndex:-1;return Y},fe=-1,ne=null;return(de)=>{if(fe!==-1&&de>=fe&&(ne===null||de<=ne.keyStart))return ne;fe=de,ne=null;for(let ue=O(de);ue!==null;){let De=ue.index+ue[0].length,xe=te(f.tail?P(De):De);if(xe!==-1){ne={keyStart:ue.index,valueStart:xe,valueEnd:()=>ae(xe)};break}ue=O(ue.index+1)}return ne}});return(f)=>{let h=[];for(let R of d){let T=R(f);if(T&&(!h[0]||T.keyStart<=h[0].keyStart))h=h[0]&&T.keyStart===h[0].keyStart?[...h,T]:[T]}return h}}function Rs(c,l,d){if(l.userinfo&&Ea(c,l.userinfo,d))return l;let f=l.end;d.resumeAt=Math.max(d.resumeAt,l.start);for(let h=d.nextKey(d.resumeAt);h[0]!==void 0&&h[0].keyStart<f;){let R=h[0].keyStart;if(R>d.lineEnd){let P=d.nextLineEnd(R);d.span=_a*(P-d.lineEnd),d.lineEnd=P}let T=null,D=h[0];for(let P of h)if(T=P.valueEnd(),T!==null){D=P;break}let O=T??D.valueStart;if(d.span-=O-R,d.span<0)return{start:l.start,end:Math.max(f,d.overflowEnd(l.start))};f=Math.max(f,O),d.resumeAt=D.valueStart,h=d.nextKey(d.resumeAt)}return f===l.end?l:{start:l.start,end:f}}function Ea(c,l,d){if(c[l.end]!=="@"||ga.test(c.slice(l.start,l.end))||!pa.test(c.slice(Math.max(0,l.start-36),l.start-3)))return!1;for(let f=d.plainKeys(l.start);f[0]!==void 0&&f[0].keyStart<l.end;f=d.plainKeys(f[0].keyStart+1))if(f.some((h)=>h.valueStart===l.end))return!1;return!0}function ka(c,l){let d=Re(c,/["'`]/g),f=-1,h=c.length;return(R)=>{if(l()!==f)f=l(),h=d(R)<f?c.length:f;return h}}function xa(c,l){let d=c[l.end-1];if(d===void 0||!fa.test(d))return l;return(c.slice(l.start,l.end).split(d).length-1)%2===1?{start:l.start,end:l.end-1}:l}function Aa(c){c.sort((d,f)=>d.start-f.start||f.end-d.end);let l=[];for(let d of c){let f=l.at(-1);if(f===void 0||d.start>=f.end)l.push(d);else l[l.length-1]={start:f.start,end:Math.max(f.end,d.end)}}return l}function Re(c,l){let d=ur(c,l);return(f)=>d(f)?.index??c.length}function ur(c,l){let d=-1,f=null;return(h)=>{if(d===-1||h<d||f!==null&&h>f.index)l.lastIndex=h,f=l.exec(c),d=h;return f}}function Cs(c,l){let d=null;return(f,h)=>{if(d===null){d=new Int32Array(c.length+1);let T=-1;for(let D=0;D<=c.length;D++){if(l){if(D>=3&&c.startsWith("%40",D-3))T=D-3}else if(D>=1&&c[D-1]==="@")T=D-1;d[D]=T}}let R=d[Math.min(h,c.length)];return R>=f?R:-1}}var Ln=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`,Hs=new RegExp(Gt(Ln),"i"),It=`[\\s\\u0085${Wt}]`,yr="Bearer|Basic",lt=`(?:${Gt(yr)})[${Wt}]*[\\s\\u0085]+`,Ps="[^\\s\\u0085,;&}\\])]+",Ls="(?![\\w\\[({$/+=~!@%^?\\\\-])",Fn="\\n\\r\\x0b\\x0c\\u0085\\u2028\\u2029",st="[\\s\\u0085]",Ad=new RegExp(It),wd=new RegExp(`(?:[=:]|["']|\\b(?:${Gt("bearer|basic")}))$`,"i"),wa=`\\\\+(?:"[^"${Fn}]*(?<!\\\\)(?=\\\\+")|'[^'${Fn}]*(?<!\\\\)(?=\\\\+'))`,Us=`[^\\s\\u0085,;&})"'\\\\]+`,Bn=`"[^"${Fn}]*"|'[^'${Fn}]*'|"[^"]*"${Ls}|'[^']*'${Ls}|[^\\s-]{0,4}\\[REDACTED\\]['"\`]?|${lt}(?:\\[REDACTED\\]|${Ps})|${Ps}`,Ra={word:`\\b(?:${yr})`,tail:"",separator:`${st}+`,value:"[A-Za-z0-9+/=._~-]{20,}"},Ca={word:`(?:${Hs.source})`,tail:"[\\w.-]",separator:`["']?${st}*[=:]${st}*`,value:Bn},Sr="AWS|GOOGLE|GCP|GCLOUD|AZURE",Ta={word:`\\b(?:${Sr})_\\w`,tail:"\\w",separator:`${st}*[=:]${st}*`,value:Bn},Da=[Ca,Ta,Ra],Pe="[\\w=-]",$e=`${Pe}{20,}(?:\\.[0-9a-z]{9})?`,va="[\\w.-]{0,256}(?![\\w.-])",$s=`${st}*(?!${st})`,br=`(?:${Hs.source})${va}`,Ws=`\\b(?:${Gt(Sr)})${Dt}_\\w+`,gr=`${br}(?:${Dt}["'])?${It}*[=:]${$s}(${Bn})`,fr=`${Ws}${It}*[=:]${st}*(${Bn})`,Gs=/\\["']/,js=`${br}${Dt}\\\\+["']${It}*[=:]${$s}(${wa}|${lt}${Us}|${Us}|\\\\+["'][^\\s\\u0085,;&})"'\\\\]*)`,ze=`[^\\s\\u0085,;&}\\])"']{0,64}?(?:${br}|${Ws})`,Oa=`(?:${lt})?(?:[{[(]{0,8}(?:"${ze}"|'${ze}')|${ze})${It}*[=:]`,Ia=`(?:${lt})?(?:[{[(]{0,8}(?:"${ze}"|'${ze}'|\\\\+"${ze}\\\\+"|\\\\+'${ze}\\\\+')|${ze})${It}*[=:]`,Vs="\\][^\\s\"'>}|,;&`)\\]]*",fn="[A-Za-z0-9_-]",mr=`${fn}{10}${fn}*`,Ns=`\\.${mr}\\.${mr}`,Er=`(?<!${fn})(?=${fn}+${Ns})(?:${fn}*?-)??(eyJ${mr}${Ns})`,zs=`(?:${Sr})_`,zt="\\[REDACTED\\]",kr=[{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:yr,source:`\\b${lt}([A-Za-z0-9+/=._~-]{20,})`,flags:"i",confidence:"low"},{id:"loose-jwt",needs:"eyJ",prefilter:/eyJ/,source:Er,confidence:"low"},{id:"sensitive-assign",needs:Ln,source:gr,flags:"i",confidence:"low"},{id:"cloud-env-var",needs:zs,source:fr,flags:"i",confidence:"low"},{id:"url-userinfo-tail",needs:zt,source:":\\/\\/(\\[REDACTED\\](?!@|%40[^\\s\"'>}|,;&`)\\]@/]*(?:[\\s\"'>}|,;&`)\\]/]|$))[^\\s\"'>}|,;&`)\\]]*?(?=[\\s\"'>}|,;&`)\\]]|:\\/\\/|$))",confidence:"low"},{id:"url-userinfo-later-at",needs:zt,source:":\\/\\/(\\[REDACTED\\]@(?:[^\\s:/?#\"'>}|,;&`)\\]]|:(?!\\/\\/)){0,256})(?=@|%40)",confidence:"low"},{id:"url-userinfo-encoded",needs:`%40|${zt}`,needsUrl:!0,source:":\\/\\/((?:\\[REDACTED\\]@)?(?:(?:[^/?#@\\s\"',;&<>|)\\]{}`[]*[\"'`<>{}[\\]][^/?#@\\s,;&|{}\"'`<>[\\]()]*(?=%40))|[^/?#@\\s\"',;&<>|)\\]}`[]+(?=%40)|(?=[^/?#@\\s\"',;&<>|)\\]}`[]*?(?:%|:[^/?#@\\s\"',;&<>|)\\]}`[]))[^/?#@\\s\"',;&<>|)\\]}`[]+(?=\\[REDACTED\\])))",confidence:"low"},{id:"masked-value-rest",needs:zt,source:`\\[REDACTED\\](${Vs})`,confidence:"low"},{id:"anthropic-signed-key-rest",needs:zt,redactOnly:!0,prefilter:/\[REDACTED\]\.eyJ/,source:"\\[REDACTED\\]\\.(eyJ[\\w-]+\\.[\\w-]+)",confidence:"low"},{id:"sensitive-assign-escaped",needs:Ln,redactOnly:!0,prefilter:Gs,source:js,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-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-deploy-token",needs:"gldt-",source:`gldt-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-runner-authentication-token",needs:"glrt-",source:`glrt-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-oauth-app-secret",needs:"gloas-",source:`gloas-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-pipeline-trigger-token",needs:"glptt-",source:`glptt-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-kubernetes-agent-token",needs:"glagent-",source:`glagent-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-incoming-mail-token",needs:"glimt-",source:`glimt-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-scim-oauth-token",needs:"glsoat-",source:`glsoat-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-ci-build-token",needs:"glcbt-",source:`glcbt-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-feed-token",needs:"glft-",source:`glft-${$e}`,displayRun:Pe,confidence:"high"},{id:"gitlab-feature-flag-client-token",needs:"glffct-",source:`glffct-${$e}`,displayRun:Pe,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"}],Pa=64,On="-----",In="BEGIN";function _r(c,l,d){let f=d?/(?:-----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,h=d?/(?:-----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;f.lastIndex=l;let R=cr(f,c);if(!R)return null;h.lastIndex=R.index+R[0].length+Pa;let T=cr(h,c);if(!T)return null;while(T[0].startsWith("[")){let D=cr(h,c);if(!D)break;T=D}return{start:R.index,end:T.index+T[0].length}}function cr(c,l){let d=c.exec(l);while(d?.[1]!==void 0&&/^-|--/.test(d[1]))c.lastIndex=d.index+1,d=c.exec(l);return d}function La(c){return _r(c,0,!0)!==null}function Ua(c){let l=Js(c);if(l.length===0)return c;let d="",f=0;for(let h of l)d+=c.slice(f,h.start)+"[REDACTED]",f=h.end;return d+c.slice(f)}function Na(c){let l=[];if(!/\[REDACTED/i.test(c))return l;for(let{start:d,end:f}of qs(c,0,!0)){let h=d;for(let R of c.slice(d,f).matchAll(/-----(?:BEGIN|END)[ A-Z0-9_-]{0,100}?PRIVATE KEY(?: BLOCK)?-----/gi))l.push({start:h,end:d+R.index}),h=d+R.index+R[0].length;l.push({start:h,end:f})}return l.filter((d)=>d.end-d.start>=10)}function Js(c){let l=On.length,d=c.indexOf(On);while(d!==-1){while(c.charCodeAt(d+l)===45)d++;let f=0;while(f<In.length&&(c.charCodeAt(d+l+f)|32)===(In.charCodeAt(f)|32))f++;if(f===In.length)break;d=c.indexOf(On,d+l)}return d===-1?[]:qs(c,d,!1)}function qs(c,l,d){let f=[];for(let h=_r(c,l,d);h;h=_r(c,h.end,d))f.push(h);return f}var hr=`(?:[\\x60'"\\s;]|\\\\[nr]|$)`,lr="(?=[^a-zA-Z0-9_\\-+=]|$)",Ms="(?<![a-zA-Z0-9_\\-])";function Ma(){return kr.map(({id:c,confidence:l,source:d,flags:f="",displayRun:h})=>{let R={id:c,confidence:l},T=f.replace("g","")+"g";if(l!=="high")return{...R,re:new RegExp(d,T)};let D=Ys(d);if(h===void 0)return{...R,re:new RegExp(Ms+D+lr,T)};return{...R,prefilter:new RegExp(D,f.replace("g","")),re:new RegExp(`(?<!${h})(?=${h}+${lr})${h}*?${Ms}(${D})${lr}`,T)}})}function gn(c){return kr.map((l)=>{let d=(l.flags??"").replace("g",""),f={id:l.id,confidence:l.confidence,...l.redactOnly===!0&&{redactOnly:l.redactOnly},...l.prefilter!==void 0&&{prefilter:l.prefilter}};if(l.run===void 0)return{...f,re:new RegExp(l.source,c?d+"g":l.flags??"")};return{...f,prefilter:new RegExp(Ys(l.source),d),re:new RegExp(`(?:(?<!${l.run})|(?<=\\\\[nr]))(?=${l.run}+${hr})${l.run}*?${l.source}`,c?d+"g":d)}})}function Ys(c){return c.endsWith(hr)?c.slice(0,-hr.length):c}function Pn(c,l){if(typeof l!=="string")return"[REDACTED]";let d=l.length>=2&&(l[0]==='"'||l[0]==="'")&&l.at(-1)===l[0]?l[0]:"",f=c.lastIndexOf(l);return`${c.slice(0,f)}${d}[REDACTED]${d}${c.slice(f+l.length)}`}function Fa(c){let l=c[1];if(typeof l!=="string")return{keep:0,insert:"[REDACTED]"};let d=l.length>=2&&(l[0]==='"'||l[0]==="'")&&l.at(-1)===l[0]?1:0,f=c[0].lastIndexOf(l);return{keep:f+d,insert:"[REDACTED]",keepEnd:c[0].length-f-l.length+d}}function Fs(c){let l=Is(c,Da).map(({start:R,end:T})=>{let D=/^(["'])[^]*\1$/.test(c.slice(R,T))?1:0;return[R+D,T-D]}),d=Os(c),f=Ha(c),h=Na(c).map(({start:R,end:T})=>[R,T]);return d.length===0&&f.length===0&&h.length===0?l:$a([...l,...d,...f,...h])}var dr,Ka=new RegExp(Vs,"y"),Ba=512;function Ha(c){dr??={plain:{assign:new RegExp(`${gr}|${fr}`,"gi"),nextKey:new RegExp(Oa,"iy"),valueWithWhitespace:new RegExp(`["']|${lt}`,"iy"),skipsStrays:!1},escaped:{assign:new RegExp(`${gr}|${fr}|${js}`,"gi"),nextKey:new RegExp(Ia,"iy"),valueWithWhitespace:new RegExp(`\\\\*["']|${lt}`,"iy"),skipsStrays:!0}};let l=Ks(c,dr.plain);return Gs.test(c)?[...l,...Ks(c,dr.escaped)]:l}function Ks(c,{assign:l,nextKey:d,valueWithWhitespace:f,skipsStrays:h}){let R=[],T,D=0,O=Ka;l.lastIndex=0;for(let P=l.exec(c);P!==null;P=l.exec(c)){let F=P[1]??P[2]??P[3],Y=P.index+P[0].length,ie=Y-F.length;d.lastIndex=ie;let V=F.length<=Ba&&d.test(c)?d.lastIndex:void 0;if(V!==void 0&&V<Y){if(f.lastIndex=V,!f.test(c))V=void 0}if(h&&T!==void 0&&P.index>=T&&P.index<D&&V===void 0){T=void 0,l.lastIndex=D;continue}if(T!==void 0&&P.index<T){let ae=/^(["'])[^]*\1$/.test(F),te=ae&&D<=ie?1:0;O.lastIndex=Y,R.push([ie+te,!ae&&O.test(c)?O.lastIndex:Y-te])}if(D=Y,T=V,T!==void 0)l.lastIndex=ie}return R}function $a(c){let l=c.filter(([f,h])=>h>f).sort((f,h)=>f[0]-h[0]),d=[];for(let[f,h]of l){let R=d.at(-1);if(R!==void 0&&f<=R[1])R[1]=Math.max(R[1],h);else d.push([f,h])}return d}function Bs(c,l){let{text:d,origin:f}=c,h=[],R=0;for(let T=0;T<d.length;){let D=f[T];while(R<l.length&&l[R][1]<=D)R++;let O=l[R];if(D<0||O===void 0||D<O[0]){T++;continue}let P=T;while(P>0&&f[P-1]<0)P--;while(T<d.length&&(f[T]<0||f[T]>=O[0]&&f[T]<O[1]))T++;let F=h.at(-1);if(F!==void 0&&F[1]>=P)F[1]=T;else h.push([P,T,"[REDACTED]"])}return Tn(c,h)}var Wa=512,Ga=512,ja=[{needs:vs,needsUrl:!0},{needs:`${On}${In}|\\[REDACTED`,flags:"i"},{needs:Ln,flags:"i"},{needs:zs,flags:"i"}],Va=1e4;function za(){let c=new Set(["[^\\x00-\\x7f]"]),l=new Set,d=new Set;for(let{needs:f,needsUrl:h,flags:R}of[...kr,...ja])if(h===!0)d.add(f);else if(R?.includes("i")===!0)l.add(f);else c.add(f);return{exactCase:new RegExp([...c].join("|")),anyCase:new RegExp([...l].join("|"),"i"),inUrl:new RegExp([...d].join("|"),"i")}}class Zs{testRules=null;redactRules=null;displayRules=null;needs=null;resultCache=new Map;mayHoldSecret(c){return this.needs??=za(),typeof c!=="string"||c.length>Va||this.needs.exactCase.test(c)||this.needs.anyCase.test(c)||c.includes("://")&&this.needs.inUrl.test(c)}scan(c){this.testRules??=gn(!1);let l=[];for(let d of this.testRules)if(d.confidence==="high"&&d.prefilter?.test(c)!==!1&&d.re.test(c))l.push({ruleId:d.id,label:d.id.split("-").map((f)=>ru[f]??Le(f)).join(" ")});if(La(c))l.push({ruleId:"private-key",label:"Private Key"});return l}redactContext(c,l=!1){this.redactRules??=gn(!0);let d=Ua(c);for(let f of this.redactRules)if(f.confidence==="low"&&pr(f,l,d))d=d.replace(f.re,Pn);return d}redactTokens(c){this.redactRules??=gn(!0);let l=c;for(let d of this.redactRules)if(d.confidence==="high"&&d.prefilter?.test(l)!==!1)l=l.replace(d.re,Pn);return l}trackedByRules(c,l=!1){return this.trackedTokens(this.trackedContext(c,l))}trackedContext(c,l=!1){let d=Tn(Ss(c),Js(c).map(({start:f,end:h})=>[f,h,"[REDACTED]"]));return this.trackedRules(d,"low",l)}redactOnlyRules(c){this.redactRules??=gn(!0);let l=c;for(let d of this.redactRules)if(d.redactOnly===!0&&pr(d,!0,l))l=l.replace(d.re,Pn);return l}trackedTokens(c){return this.trackedRules(c,"high")}trackedRules(c,l,d=!1){this.redactRules??=gn(!0);let f=c;for(let h of this.redactRules)if(h.confidence===l&&pr(h,d,f.text))h.re.lastIndex=0,f=bs(f,h.re,Fa);return f}redactWithUrlRanges(c){let l=Fs(c);return l.length===0?this.redactTokens(this.redactContext(c,!0)):Bs(this.trackedByRules(c,!0),l).text}redactTracked(c){return Bs(this.trackedByRules(c,!0),Fs(c))}redact(c){if(!this.mayHoldSecret(c))return c;let l=c.length<=Wa;if(l){let f=this.resultCache.get(c);if(f!==void 0)return f}let d=this.redactWithUrlRanges(c);if(l){if(this.resultCache.size>=Ga)this.resultCache.delete(this.resultCache.keys().next().value);this.resultCache.set(c,d)}return d}redactForDisplay(c){this.displayRules??=Ma();let l=c;for(let d of this.displayRules){if(d.confidence!=="high"||d.prefilter?.test(l)===!1)continue;l=l.replace(d.re,tu)}return l}}var Ja=new Zs;var qa="[hidden for privacy]",Ya=a({reporter:void 0},(c)=>{c.reporter=void 0});function Za(c){try{Ya.reporter?.(c)}catch{}}function Xa(c){try{return Ja.redact(c)}catch(l){Za(l);return}}function Xs(c){return Xa(c)??qa}var Rd=new RegExp(Er),Cd=new RegExp(Er,"g");var Qa=/[$\x60|;&<>()\s]/,eu=/[/.@:~*?\\]/;function tu(c,l){let d=typeof l==="string"?l:c;if(Qa.test(d)||eu.test(d))return c;return Pn(c,l)}var Kn="(^|[^a-z0-9+.-]|%[0-9a-f]{2})",nu="https?|wss?|ftps?",Qs="ssh\\+git|git\\+ssh|ssh|git",Td=new RegExp(`[a-z](?:[a-z0-9+.-]{1,31}:\\/+|:\\/\\/)|(?:https?|ftps?):(?!\\/)|${Kn}(?:wss?|file):(?!\\/)|${Kn}(?:${Qs}):(?!\\/)(?=[^@/?#\\s]*?(?::|%3a))`,"i");var Dd=new RegExp(`${Kn}(?:${nu}):(?!\\/\\/)|${Kn}(?:${Qs}):(?!\\/\\/)`,"gi");function pr(c,l,d){return(l||c.redactOnly!==!0)&&(c.prefilter===void 0||c.prefilter.test(d))}var ru={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 Rr={verbose:0,debug:1,info:2,warn:3,error:4},cu=new RegExp(`(?!\\t)[${N}]`,"gu"),lu=10485760,ni=1048576,du=1e4,pu=262144,gu=5000,ri=100,fu=be((c)=>c());function mu(c){return Object.hasOwn(Rr,c)}function si(c){return Cn(c)?null:ui(c)}function ii(){}var _u={arm:"v5",target:null};function hu(c,l){c.stuck=c.appendSince===l?"yes":"no"}var yu={sessionId:"",fromBackend:!1};function oi(c,l,d,f){let h=it(l,"debug"),R=it(h,`${c.sessionId}.txt`),T;if(d===null)T=R;else if(f!==null&&d===f)T=it(f,`${c.sessionId}.txt`);else T=d;let D=!c.fromBackend&&T===R?"v5":"raw";return{target:T,arm:D,configHome:l,rotate:D==="raw"&&!(Ut(T)===h&&T.endsWith(".txt")),pointLatest:D==="raw"&&T!==R}}function wr(c){return Or.userNamed(uu(c)?c:ui(c))}function Su(c){return c.code==="Failed"&&c.telemetryCode==="ENOENT"}function bu(c,l=Ir){return l?c:void 0}async function ai(c,l,d,f){let h={namespace:"log",sessionId:l,channel:"debug"},R=await Vn.run(!0,()=>c.append(h,[{data:d}],f?{markLatest:!0}:void 0));if(R.ok)return"landed";return f&&R.error.code==="InvalidArgument"&&R.error.argument==="opts.markLatest"?"refused":"dropped"}class ci{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(c){this.deps=c;if(this.storageV5=bu(c.storageV5),c.launchIdentity!==void 0){this.minLevel=c.launchIdentity.minLevel,this.filter=c.launchIdentity.filter,this.toStderr=c.launchIdentity.toStderr,this.filePath=c.launchIdentity.filePath,this.debugFromLaunch=c.launchIdentity.debugFromLaunch;return}let l=Array.isArray(c.argv)?c.argv:[],d=Ur(),f;if(d!==void 0)f=d(l);else{let D=l.indexOf("--");f=D===-1?l:l.slice(0,D)}let h=c.env.CLAUDE_CODE_DEBUG_LOG_LEVEL?.toLowerCase().trim();this.minLevel=h&&mu(h)?h:"debug";let R=f.find((D)=>D.startsWith("--debug="));this.filter=R?Fr(R.substring(8)):null,this.toStderr=f.includes("--debug-to-stderr")||f.includes("-d2e");let T=null;for(let D=0;D<f.length;D++){let O=f[D];if(O.startsWith("--debug-file=")){T=si(O.substring(13));break}if(O==="--debug-file"&&D+1<f.length){T=si(f[D+1]);break}}this.filePath=T,this.debugFromLaunch=s(c.env.DEBUG)||s(c.env.DEBUG_SDK)||f.includes("--debug")||f.includes("-d")||this.toStderr||R!==void 0||this.filePath!==null}isDebugMode(){return this.runtimeDebugEnabled||this.debugFromLaunch}mayWrite(c){return this.takesLevel(c)&&(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 c=this.isDebugMode()||this.deps.isAnt;return this.runtimeDebugEnabled=!0,c}logPath(){return this.filePath??(this.overrideDirectory!==null&&this.overrideDirectory===this.deps.env.CLAUDE_CODE_DEBUG_LOGS_DIR?it(this.overrideDirectory,`${this.deps.sessionId()}.txt`):null)??this.resolvedLogPath??this.deps.env.CLAUDE_CODE_DEBUG_LOGS_DIR??this.defaultLogPath()}defaultLogPath(c=this.deps.sessionId()){return it(this.deps.configHomeDir(),"debug",`${c}.txt`)}learnedOverrideDirectory(){return this.overrideDirectory}isArmed(){return this.storageV5!==void 0}takesLevel(c){return Rr[c]>=Rr[this.minLevel]}log(c,{level:l}={level:"debug"}){if(!this.takesLevel(l))return;let d=this.deps.limits?.();if(d===void 0){this.emit(c,l);return}let f=c.length>d.maxMessageLength?`debug message not logged: it has ${c.length} characters, over this log's fixed limit of ${d.maxMessageLength} per message`:c,{admitted:h,leftOutBefore:R}=d.admit(f.length);if(!h)return;d.timed(()=>{if(R>0)this.emit(`debug messages not logged: ${R} since this log's last line, over its fixed limit on how much it logs at a time`,l);this.emit(f,l)})}emit(c,l){if(!this.shouldLog(c))return;let d=Xs(c.trim());d=d.includes(`
19
- `)?hs(r(d)):d.replace(cu,ys);let h=`${new Date().toISOString()} [${l.toUpperCase()}] ${d}
20
- `;if(this.toStderr){this.deps.writeToStderr(h);return}this.write(h)}write(c){let l=this.getWriter(),d=yu;if(this.storageV5!==void 0){if(d={sessionId:this.deps.sessionId(),fromBackend:Vn.getStore()===!0},d.fromBackend)this.backendLinesLogged++}if(l.write({origin:d,content:c}),this.exiting)l.flush()}async flush(){let c=this.backendLinesLogged;if(this.writer?.flush(),await this.drained(),this.storageV5!==void 0&&this.successor)return this.successor.flush();for(let l=0;this.backendLinesLogged!==c&&l<3;l++)c=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 c=this.backlog.chain.then(()=>!0);do if(await re(c,ri))return;while(!this.isAppendStuck())}isAppendStuck(){let c=this.backlog,{appendSince:l}=c;if(c.stuck==="no"&&l!==0&&Date.now()-l>=gu)c.stuck="suspected",setTimeout(hu,ri,c,l).unref();return c.stuck==="yes"}dispose(c){this.redirect=c;try{this.writer?.dispose()}finally{this.redirect=null,this.writer=null}}succeed(c){this.runtimeDebugEnabled=c.runtimeDebugEnabled,this.hasFormattedOutput=c.hasFormattedOutput,this.unflushedChunks=c.unflushedChunks,this.backlog=c.backlog,this.exitHandlerRegistered=c.exitHandlerRegistered,c.successor=this,c.dispose((l)=>{this.write(l)})}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(c,l,d=lu){let f=u()&&this.storageV5!==void 0?this.storageV5.hostFiles:void 0;if(this.writtenBytes<0)if(f){let h=await f.stat(wr(c));this.writtenBytes=h.ok&&h.value.kind!=="absent"?h.value.size:0}else this.writtenBytes=await iu(c).then((h)=>h.size).catch(()=>0);else this.writtenBytes+=l;if(this.writtenBytes<=d||this.rotating)return;this.rotating=!0;try{let h=c.endsWith(".txt")?`${c.slice(0,-4)}.1.txt`:`${c}.1`;if(f){let R=wr(c),T=wr(h),D=await f.rename(R,T);if(!D.ok&&!Su(D.error)){if(await f.delete(T,{missingOk:!0}),!(await f.rename(R,T)).ok)await f.delete(R,{missingOk:!0})}}else try{await ti(c,h)}catch(R){if(!p(R))await Ar(h).catch(()=>{}),await ti(c,h).catch(()=>Ar(c).catch(()=>{}))}this.writtenBytes=0}finally{this.rotating=!1}}shouldLog(c){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 Kr(c,this.filter)}resolveDirToFile(c){return this.resolvedLogPath=it(c,`${this.deps.sessionId()}.txt`),this.resolvedLogPath}async appendGroup(c,l,d,f){if(this.storageV5!==void 0&&c.arm==="v5"){await this.appendV5AndMark(this.storageV5,l,d);return}if(c.target===null||!this.writesFiles())return;if(f)await ei(Ut(c.target),{recursive:!0}).catch(()=>{});let h=c;try{await xr(c.target,d)}catch(R){if(!vt(R))throw R;if(this.storageV5===void 0)h={...c,target:this.resolveDirToFile(c.target)},await xr(h.target,d);else{if(this.overrideDirectory=c.target,h=oi(l,c.configHome,c.target,c.target),h.arm==="v5"){await this.appendV5AndMark(this.storageV5,l,d);return}await ei(Ut(h.target),{recursive:!0}).catch(()=>{});try{await xr(h.target,d)}catch{return}}}if(h.rotate){if(this.storageV5!==void 0&&h.target!==this.rotationTarget)this.rotationTarget=h.target,this.writtenBytes=-1;await this.maybeRotate(h.target,Buffer.byteLength(d)).catch(ii)}if(h.pointLatest)this.markLatestSymlink()}async appendV5AndMark(c,l,d){let f=u(),h=f&&!this.latestMarked&&!this.latestRefused,R=await ai(c,l.sessionId,d,h);if(R==="refused")this.latestRefused=!0,R=await ai(c,l.sessionId,d,!1),this.log("debug log: the storage backend refused markLatest; <debug folder>/latest is not pointed in this process",{level:"warn"});if(R!=="landed")return;if(h&&!this.latestRefused)this.latestMarked=!0;else if(!f)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 c=this.backlog,l=this.unflushedChunks[0],d=l?.queued;if(d===void 0)return;let f=0,h=0,R=!1;for(let{content:T,queued:D}of this.unflushedChunks){if(D===void 0||D.owner!==d.owner||D.decision.arm!==d.decision.arm||D.decision.target!==d.decision.target||D.origin.sessionId!==d.origin.sessionId||D.origin.fromBackend!==d.origin.fromBackend||f>0&&h+T.length>pu)break;f++,h+=T.length,R||=D.needMkdir}if(c.appendSince=Date.now(),await d.owner.appendGroup(d.decision,d.origin,this.unflushedChunks.slice(0,f).map((T)=>T.content).join(""),R).catch(ii),c.appendSince=0,c.stuck="no",this.unflushedChunks[0]===l)this.unflushedChunks.splice(0,f),c.length-=h}drainSync(){if(this.unflushedChunks.length===0)return;if(this.backlog.length=0,!this.drainsSyncAtExit()||!this.writesFiles()||this.isAppendStuck()){this.unflushedChunks.length=0;return}let c=[];for(let l of this.unflushedChunks.splice(0)){if(l.target===null)continue;let d=c.at(-1);if(d!==void 0&&d.armed===l.armed&&(!l.armed||d.target===l.target))d.parts.push(l);else c.push({target:l.target,armed:l.armed,parts:[l]})}for(let{target:l,armed:d,parts:f}of c){let h=d?l:this.logPath(),R=f.map((T)=>T.content).join("");try{i().mkdirSync(Ut(h))}catch{}try{i().appendFileSync(h,R)}catch(T){if(vt(T))try{if(!d)i().appendFileSync(this.resolveDirToFile(h),R);else{let D=(F,Y)=>{try{i().appendFileSync(it(h,`${F}.txt`),Y)}catch{}},O=f[0]?.sessionId,P="";for(let F of f){if(F.sessionId!==O)D(O,P),O=F.sessionId,P="";P+=F.content}D(O,P)}}catch{}}}}droppedLineTotal(){return this.backlog.droppedTotal}takeDroppedNote(){let{droppedCount:c}=this.backlog;if(c===0)return"";return this.backlog.droppedCount=0,`${new Date().toISOString()} [WARN] debug messages not logged: ${c} since the line above, because writes to this log were over 10 s behind, with over 1 MiB waiting
21
- `}groupLines(c){let l=c[0];if(l===void 0)return[];let d=this.filePath??this.deps.env.CLAUDE_CODE_DEBUG_LOGS_DIR??null,f=this.isSessionDiskless();if(f&&(this.storageV5===void 0||d!==null))return[];if(this.storageV5===void 0)return[{decision:{target:this.logPath(),arm:"raw",configHome:"",rotate:!0,pointLatest:!0},origin:l.origin,lines:c}];let h=[];for(let R of c){if(f&&R.origin.fromBackend)continue;let T=h.at(-1);if(T!==void 0&&T.origin.sessionId===R.origin.sessionId&&T.origin.fromBackend===R.origin.fromBackend)T.lines.push(R);else h.push({decision:f?_u:oi(R.origin,this.deps.configHomeDir(),d,this.overrideDirectory),origin:R.origin,lines:[R]})}return h}getWriter(){if(this.writer)return this.writer;let c=null,l=this.storageV5!==void 0;if(this.writer=Pr({writeBatch:(d)=>{if(this.redirect){this.redirect(d.map((R)=>R.content).join(""));return}if(this.exiting){for(let R of this.groupLines(d))this.unflushedChunks.push({target:R.decision.target,sessionId:R.origin.sessionId,armed:l,content:this.takeDroppedNote()+R.lines.map((T)=>T.content).join("")});this.drainSync();return}let f=this.writesFiles(),h=this.backlog;this.isAppendStuck();for(let R of this.groupLines(d)){if(R.decision.arm==="raw"&&!f)continue;if(h.droppedCount>0?h.length>=ni/2:h.length>=ni&&Date.now()-(this.unflushedChunks[0]?.queued?.at??1/0)>=du){h.droppedCount+=R.lines.length,h.droppedTotal+=R.lines.length;continue}let T=this.takeDroppedNote()+R.lines.map((P)=>P.content).join("");if(T==="")continue;let D=R.decision.arm==="raw"?Ut(R.decision.target):null,O=D!==null&&(R.origin.fromBackend||c!==D);if(D!==null)c=D;this.unflushedChunks.push({target:R.decision.target,sessionId:R.origin.sessionId,armed:l,content:T,queued:{at:Date.now(),owner:this,decision:R.decision,origin:R.origin,needMkdir:O}}),h.length+=T.length,h.chain=fu(()=>h.chain.then(this.appendOldest))}},sizeOf:(d)=>d.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 c=this.logPath();if(au(c).toLowerCase()==="latest")return;let l=it(Ut(c),"latest");if((await su(l).catch(()=>null))?.isSymbolicLink())await Ar(l).catch(()=>{});await ou(c,l)}catch{}}}class li{instance=void 0;init={};defaultFile=!0;limits=void 0;setInstance(c){this.instance=c}setInit(c){this.init=c}disableDefaultFile(){this.defaultFile=!1}setLimits(c){this.limits=c}}var Eu=new o(()=>new li);function ku(){return K(Eu)}function xu(c,l){return new ci({argv:process.argv,env:process.env,sessionId:()=>Rn(),configHomeDir:()=>y(),onExit:(d)=>{process.on("exit",d)},registerCleanup:(d)=>{Xe(d)},writeToStderr:(d)=>{Xr(d,{mayDrop:!0})},isAnt:l?.isAnt??!1,isTestEnvironment:l?.isTestEnvironment??!1,launchIdentity:l,storageV5:c.init.storageV5!==void 0&&c.init.configHome===Ce()?c.init.storageV5:void 0,syncExitDrain:c.init.syncExitDrain,diskless:()=>m(),defaultFile:()=>c.defaultFile,limits:()=>c.limits})}function di(){let c=ku(),l=c.instance;if(l)return l;let d=xu(c);return c.setInstance(d),d}function nn(){return di().mayWrite("debug")}function e(c,l={level:"debug"}){di().log(c,l)}function pi(c){let l=0;for(let d=0;d<c.length;d++)l=(l<<5)-l+c.charCodeAt(d)|0;return l}var G=["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"],Nn=["clear","resume","logout","prompt_input_exit","other"],Un="__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__";var sp=`
22
-
23
- 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 Jt=["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","ProposeGoal","PushNotification","Read","ReadMcpResourceDirTool","ReadMcpResourceTool","ReadNotifications","RemoteTrigger","ReportFindings","ScheduleWakeup","SendFeedback","SendMessage","SendUserFile","SendUserMessage","ShareOnboardingGuide","ShowOnboardingRolePicker","Skill","SubagentHandback","TaskCreate","TaskGet","TaskList","TaskStop","TaskUpdate","TodoWrite","ToolSearch","WaitForMcpServers","WebFetch","WebSearch","Workflow","Write"],Ne={Task:"Agent",KillShell:"TaskStop",KillBash:"TaskStop",ListPeers:"ListAgents",Brief:"SendUserMessage",ListMcpResources:"ListMcpResourcesTool",ReadMcpResource:"ReadMcpResourceTool",ReadMcpResourceDir:"ReadMcpResourceDirTool"};function x(c){if(typeof c!=="object"||c===null)return!1;let l=Object.getPrototypeOf(c);return l===Object.prototype||l===null}var Se=2147483647;var Au=1000;function wu(){return{eventQueue:[],sink:null,droppedEventCount:0}}function Ru(c,l){if(c.eventQueue.length>=Au)c.eventQueue.shift(),c.droppedEventCount++;c.eventQueue.push(l)}class gi{state=wu()}var Cu=new o(()=>new gi);function Tu(){return K(Cu)}function J(c,l){let d=Tu().state;if(d.sink===null){Ru(d,{eventName:c,metadata:l,async:!1});return}d.sink.logEvent(c,l)}function n(c){return typeof c==="object"&&c!==null&&!Array.isArray(c)}function Du(c){if(c.length!==22)return;let l=BigInt(58),d=0n;for(let f of c){let h="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".indexOf(f);if(h<0)return;d=d*l+BigInt(h)}return d}function fi(c){let l=c.lastIndexOf("_");if(l<0)return;let d=c.slice(l+1);if(!d.startsWith("01"))return;let f=Du(d.slice(2));if(f===void 0)return;let h=f.toString(16).padStart(32,"0");if(h.length!==32)return;return`${h.slice(0,8)}-${h.slice(8,12)}-${h.slice(12,16)}-${h.slice(16,20)}-${h.slice(20,32)}`}function mi(c){return fi(c)??c}function _i(c){if(!n(c))return;let{id:l,directory_id:d,transport:f,plugin_id_hash:h}=c;switch(c.type){case"anthropic":return Hn(l)?{type:"anthropic",id:l}:void 0;case"claude_ai_connector":return Hn(l)&&(d===null||Hn(d))?{type:"claude_ai_connector",id:mi(l),directory_id:d}:void 0;case"client_configured":return(f==="stdio"||f==="http"||f==="in_process")&&(h===void 0||Hn(h))?{type:"client_configured",transport:f,...h!==void 0&&{plugin_id_hash:h}}:void 0;default:return}}var vu=256;function Hn(c){return typeof c==="string"&&c.length>0&&c.length<=vu&&!/[\x00-\x1f\x7f]/.test(c)}function et(c){return typeof c==="number"&&Number.isInteger(c)&&c>0?c:void 0}var Ou={always_allow:!0,always_ask:!0,always_deny:!0};function Iu(c){return typeof c==="string"&&Object.hasOwn(Ou,c)}function hi(c){if(!n(c)||typeof c.name!=="string")return;let{name:l,permission_policy:d}=c;if(d===void 0)return{policy:{name:l},rewritten:!1};return Iu(d)?{policy:{name:l,permission_policy:d},rewritten:!1}:{policy:{name:l,permission_policy:"always_ask"},rewritten:!0}}function rn(c,l){if(c===void 0||l===void 0)return c===l;return c.length===l.length&&c.every((d,f)=>d.name===l[f]?.name&&d.permission_policy===l[f]?.permission_policy)}var Pu=64,Lu=128;function ht(c){if(!n(c))return{settings:{},ignored:[]};let{timeout:l,disableAutoBackground:d,tools:f,connectorId:h,autoModeVerdictTools:R,dataFlowServer:T}=c,D=et(l),O=[];if(l!==void 0&&D===void 0)O.push("timeout");if(d!==void 0&&typeof d!=="boolean")O.push("disableAutoBackground");let P=Uu(f);if(_t(c)!==void 0)O.push("tools");let F=typeof h==="string"&&h!=="";if(h!==void 0&&!F)O.push("connectorId");let Y=Array.isArray(R)?R.filter((ae)=>typeof ae==="string"&&ae.length<=Lu):[],ie=Array.isArray(R)&&R.length<=Pu&&Y.length===R.length;if(R!==void 0&&!ie)O.push("autoModeVerdictTools");let V=T===void 0?void 0:_i(T);if(T!==void 0&&V===void 0)O.push("dataFlowServer");return{settings:{...D!==void 0&&{timeout:D},...d===!0&&{disableAutoBackground:d},...P!==void 0&&{tools:P},...F&&{connectorId:h},...ie&&{autoModeVerdictTools:Y},...V!==void 0&&{dataFlowServer:V}},ignored:O}}function _t(c){let l=n(c)?c.tools:void 0;if(l===void 0)return;if(!Array.isArray(l))return{kind:"not_a_list"};let d=0,f=0;for(let h of l){let R=hi(h);if(R===void 0)d++;else if(R.rewritten)f++}return d+f>0?{kind:"entries",dropped:d,rewritten:f,kept:l.length-d}:void 0}function on(c){if(c.kind==="not_a_list")return"tools[] is not a list; no per-tool policy taken";let l=[];if(c.dropped>0)l.push(`dropped ${c.dropped} malformed tools[] ${c.dropped===1?"entry":"entries"}`);if(c.rewritten>0)l.push(`read ${c.rewritten} tools[] ${c.rewritten===1?"entry":"entries"} with an invalid permission_policy as always_ask`);return`${l.join(", ")}; kept ${c.kept}`}function Uu(c){if(!Array.isArray(c))return;let l=[];for(let d of c){let f=hi(d);if(f!==void 0)l.push(f.policy)}return l}function Ee(c){return c.startsWith("\uFEFF")?c.slice(1):c}function Si(){return"prod"}var sn=["","-staging-oauth","-local-oauth","-custom-oauth"];function St(){if(process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL)return"-custom-oauth";switch(Si()){case"local":return"-local-oauth";case"staging":return"-staging-oauth";case"prod":return""}}function an(){return St()==="-staging-oauth"}var Mu=31536000;var Dp=Math.round(Mu/86400);var yi={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:!1,HYBRID_SETTINGS_SCOPE_REGISTERED:!0,MCP_PROXY_URL:"https://mcp-proxy.anthropic.com",MCP_PROXY_PATH:"/v1/mcp/{server_id}"};var Fu=void 0;function Ku(){let c=process.env.CLAUDE_LOCAL_OAUTH_API_BASE?.replace(/\/$/,"")??"http://localhost:8000",l=process.env.CLAUDE_LOCAL_OAUTH_APPS_BASE?.replace(/\/$/,"")??"http://localhost:4000",d=process.env.CLAUDE_LOCAL_OAUTH_CONSOLE_BASE?.replace(/\/$/,"")??"http://localhost:3000";return{BASE_API_URL:c,CONSOLE_AUTHORIZE_URL:`${d}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${l}/oauth/authorize`,CLAUDE_AI_ORIGIN:l,TOKEN_URL:`${c}/v1/oauth/token`,API_KEY_URL:`${c}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${c}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${d}/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`${d}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${d}/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:!1,HYBRID_SETTINGS_SCOPE_REGISTERED:!0,MCP_PROXY_URL:"http://localhost:8205",MCP_PROXY_PATH:"/v1/toolbox/shttp/mcp/{server_id}"}}var Bu=["https://beacon.claude-ai.staging.ant.dev","https://claude.fedstart.com","https://claude-staging.fedstart.com"];function Hu(){switch(Si()){case"local":return Ku();case"staging":return Fu??yi;case"prod":return yi}}function ln(){let c=Hu(),l=process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL;if(l){let f=l.replace(/\/$/,"");if(!Bu.includes(f))throw Error("CLAUDE_CODE_CUSTOM_OAUTH_URL is not an approved endpoint.");c={...c,BASE_API_URL:f,CONSOLE_AUTHORIZE_URL:`${f}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${f}/oauth/authorize`,CLAUDE_AI_ORIGIN:f,TOKEN_URL:`${f}/v1/oauth/token`,API_KEY_URL:`${f}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${f}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${f}/oauth/code/success?app=claude-code`,CLAUDEAI_SUCCESS_URL:`${f}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${f}/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 d=process.env.CLAUDE_CODE_OAUTH_CLIENT_ID;if(d)c={...c,CLIENT_ID:d,PLUGINS_SCOPE_REGISTERED:!1,PROJECTS_SCOPES_REGISTERED:!1,PRIVACY_CONSENTS_SCOPE_REGISTERED:!1,HYBRID_SETTINGS_SCOPE_REGISTERED:!1,SCOPES_CLEARED_BY:[...c.SCOPES_CLEARED_BY??[],"CLAUDE_CODE_OAUTH_CLIENT_ID"]};return c}var Ip=String.fromCharCode(0);function $n(c,l,d){return d===void 0?c:{...c,[l]:d}}function $u(c,l,d,f){let R=$n({namespace:"transcript",projectKey:c,sessionId:l},"agentId",d);return $n(R,"agentRelPath",f)}function Wu(c,l,d){let h=$n({namespace:"log",sessionId:c,channel:l},"agentId",d?.agentId);return $n(h,"runId",d?.runId)}var ye={transcript:$u,journal:(c,l,d)=>({namespace:"transcript",projectKey:c,sessionId:l,agentRelPath:d,journal:!0}),sessionJournal:(c,l,d)=>({namespace:"transcript",projectKey:c,sessionId:l,sessionJournal:d}),history:()=>({namespace:"history"}),log:Wu,globalConfig:()=>({namespace:"globalConfig"}),globalConfigCopy:(c,l)=>({namespace:"globalConfig",kind:c,stamp:l}),userSettings:()=>({namespace:"settings",layer:"user"}),projectSettings:(c)=>({namespace:"settings",layer:"project",projectKey:c}),localSettings:(c)=>({namespace:"settings",layer:"local",consentRootKey:c}),task:(c,l)=>({namespace:"task",listId:c,taskId:l}),taskListMeta:(c)=>({namespace:"task",listId:c,meta:!0}),taskListHighWaterMark:(c)=>({namespace:"task",listId:c,highWaterMark:!0}),memory:(c,l)=>({namespace:"memory",projectKey:c,relPath:l}),pluginRegistry:(c)=>({namespace:"pluginRegistry",file:c}),marketplaceCache:(c,l)=>({namespace:"marketplaceCache",marketplace:c,form:l}),marketplaceTree:(c,l)=>({namespace:"marketplaceCache",marketplace:c,relPath:l}),pluginCache:(c,l,d,f)=>({namespace:"pluginCache",marketplace:c,plugin:l,version:d,relPath:f}),cache:(c,l)=>({namespace:"cache",store:c,id:l}),paste:(c)=>({namespace:"paste",id:c}),state:(c)=>({namespace:"state",id:c}),pluginAssetCache:(c)=>({namespace:"pluginAssetCache",digest:c}),plan:(c)=>({namespace:"plan",name:c}),daemon:(c)=>({namespace:"daemon",relPath:c}),feedbackDraft:(c)=>({namespace:"feedbackDraft",draftId:c}),agentMemory:(c,l)=>({namespace:"agentMemory",layer:"user",agentType:c,relPath:l}),identity:()=>({namespace:"identity"}),team:(c)=>({namespace:"team",team:c}),sidecar:(c,l,d)=>({namespace:"sidecar",projectKey:c,sessionId:l,relPath:d}),mailbox:(c,l)=>({namespace:"mailbox",team:c,teammate:l}),scratch:(c,l)=>({namespace:"scratch",sessionId:c,relPath:l}),userConfigDir:(c,l)=>({namespace:"userConfigDir",dir:c,relPath:l}),fileHistory:(c,l)=>({namespace:"fileHistory",sessionId:c,backupFileName:l}),job:(c,l)=>({namespace:"job",jobId:c,relPath:l}),jobTimeline:(c)=>({namespace:"jobTimeline",jobId:c}),recording:(c,l,d)=>({namespace:"recording",projectKey:c,sessionId:l,stamp:d}),sessionLog:(c,l,d)=>({namespace:"sessionLog",projectKey:c,year:l.year,month:l.month,day:l.day,logName:d}),jobPins:()=>({namespace:"jobsRoot",file:"pins"}),jobDraft:(c)=>({namespace:"jobsRoot",draftKey:c}),session:(c)=>({namespace:"session",file:c}),bridgePointer:(c)=>({namespace:"bridgePointer",projectKey:c}),sessionAliases:(c)=>({namespace:"sessionAliases",projectKey:c}),dirSyncRecord:(c,l)=>({namespace:"dirSyncRecord",projectKey:c,sessionId:l})};async function Cr(c,l,d){let f=Math.max(1,Math.floor(d?.maxPages??1e4)),h;for(let R=0;R<f;R++){if(d?.budget!==void 0){if(d.budget.pagesLeft<1)return{status:"capped"};d.budget.pagesLeft--}let T=await c(h);if(!T.ok)return{status:"error",error:T.error};if(await l(T.value.items),d?.until?.())return{status:"done"};if(h=T.value.cursor,!h)return{status:"done"}}return{status:"capped"}}var bi='"subtype":"voice_call_talk"';import{once as Ei}from"events";import{constants as mn,createWriteStream as Gu}from"fs";import{lstat as ju,open as Vu,lstat as qp,readdir as Wn,realpath as zu,rename as Yp,stat as Zp}from"fs/promises";import{basename as Ju,dirname as qu,isAbsolute as Qp,join as ot}from"path";var Ft=65536;var Yu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function U(c){if(typeof c!=="string")return null;return Yu.test(c)?c:null}function Zu(c,l,d){return Xu(c,d,l)}function ki(c,l,d){try{let f=JSON.parse(c);if(typeof f==="object"&&f!==null&&(d===void 0||f.type===d)){let h=f[l];if(typeof h==="string")return h}return}catch{return null}}function Xu(c,l,d,f){let h=d===void 0?void 0:f===void 0?[`"type":"${d}"`]:[`"type":"${d}"`,`"type": "${d}"`],R=`"${l}":`,T=c.length;while(T>0){let D=c.lastIndexOf(`
24
- `,T-1),O=c.slice(D+1,T);if(T=D,(O.includes(R)||f==="none")&&(h===void 0||h.some((P)=>O.includes(P)))){let P=ki(O,l,d);if(P===null&&f!==void 0){let F=O.lastIndexOf(`{${h?.[0]}`);if(P=F>0&&!":,[".includes(O.charAt(F-1))?ki(O.slice(F),l,d):null,P===null&&f==="none")return}if(typeof P==="string")return P}if(D<0)break}return}function Qu(c,l){let d=`"${l}":`,f=0;while(f<c.length){let h=c.indexOf(`
25
- `,f),R=h<0?c.slice(f):c.slice(f,h);if(f=h<0?c.length:h+1,R.includes(d))try{let T=JSON.parse(R);if(typeof T==="object"&&T!==null){let D=T[l];if(typeof D==="string")return D}}catch{}}return}function Et(c,l){return c?.realWorkspacePath===void 0?void 0:{hoverRestOn:l,realPath:c.realWorkspacePath}}async function yt(c,l,d){return tc(c,l,"w",d)}var ec=262144;async function tc(c,l,d,f){if(f!==void 0&&f.hoverRestOn&&(d==="w"||l.length>0))return nc(f.source,l,d);let h=Gu(c,{mode:384,flags:d});try{let R="";for(let T of l)if(R+=JSON.stringify(T)+`
26
- `,R.length>=ec){let D=h.write(R);if(R="",!D)await Ei(h,"drain")}if(R!=="")h.write(R);h.end(),await Ei(h,"finish")}catch(R){throw h.destroy(),R}}async function nc(c,l,d){let{backend:f,key:h}=c,R=l.map((D)=>({data:JSON.stringify(D)+`
27
- `}));if(d==="w"){let D=await f.replaceRecords(h,R,{publishDiscipline:"inPlace",mode:384});if(!D.ok)throw Error("transcript stream replace failed",{cause:D.error});return}let T=await f.append(h,R);if(!T.ok)throw Error("transcript stream append failed",{cause:T.error})}var xi=process.platform==="win32"?mn.O_RDONLY:mn.O_RDONLY|mn.O_NOFOLLOW|mn.O_NONBLOCK;async function rc(c){let{backend:l,key:d}=c;try{let f=await l.read([{key:d,offset:0,length:Ft},{key:d,tail:Ft}]);if(!f.ok)return null;let[h,R]=f.value.items;if(!h.found||h.value.length===0)return null;let T=Ai(h.value),D=R.found&&R.value.length>0?Ai(R.value):T;return{head:T,tail:D,mtimeMs:h.mtimeMs,totalBytes:h.totalBytes}}catch{return null}}function Ai(c){return Buffer.from(c.buffer,c.byteOffset,c.byteLength).toString("utf8")}var ug=Buffer.from('"type":"user"'),cg=Buffer.from('"type":"assistant"'),lg=Buffer.from(bi);function bt(c,l){if(c.kind!=="scope"||c.scope.namespace!=="transcript"||c.scope.projectKey===void 0||c.scope.sessionId!==void 0||!l(c.scope.projectKey))return;return c.scope.projectKey}function wi(c){return{skipScopeStats:!0,skipKeyStats:!0,...c!==void 0&&{cursor:c}}}async function sc(c,l){if(l!==void 0&&l.hoverRestOn)return Ri(l.source);try{if(xi===mn.O_RDONLY){if(!(await ju(c)).isFile())return null}let d=await Vu(c,xi);try{let f=await d.stat();if(!f.isFile())return null;let h=Buffer.allocUnsafe(Ft),R=await d.read(h,0,Ft,0);if(R.bytesRead===0)return null;let T=h.toString("utf8",0,R.bytesRead),D=Math.max(0,f.size-Ft),O=T;if(D>0){let P=await d.read(h,0,Ft,D);O=h.toString("utf8",0,P.bytesRead)}return{mtime:f.mtime.getTime(),size:f.size,head:T,tail:O}}finally{await d.close()}}catch{return null}}async function Ri(c){let l=await rc(c);if(l===null)return null;return{mtime:Math.trunc(l.mtimeMs),size:l.totalBytes,head:l.head,tail:l.tail}}var Kt=200;function ic(c){return Math.abs(pi(c)).toString(36)}function Gn(c){return c.replace(/[^a-zA-Z0-9]/g,"-")}function _n(c){let l=Gn(c);if(l.length<=Kt)return l;return`${l.slice(0,Kt)}-${ic(c)}`}function Z(){return ot(y(),"projects")}function hn(c){return vn()??_n(c)}function Tr(c){let l=_n(c);return l===hn(c)?void 0:l}function Be(c,l=Z()){return ot(l,hn(c))}function tt(c,l){let d=Ju(c);return qu(c)===Z()&&l(d)?d:void 0}async function Ct(c,l){try{if(l!==void 0&&l.hoverRestOn){let d=await l.realPath(c);return g(d.ok&&d.value.found?d.value.path:c)}return g(await zu(c))}catch{return g(c)}}async function nt(c,l,d,f){let h=f!==void 0&&f.hoverRestOn?f.source:void 0,R=h===void 0?void 0:tt(c,h.isKeySegment);if(h!==void 0&&R!==void 0){let O=await oc(R,l,d,h);if(O!==void 0)return O}if(m())return!1;let T=Gn(l),D;try{D=await Wn(c,{withFileTypes:!0})}catch{return!1}for(let O of D){if(!O.isFile()||!O.name.endsWith(".jsonl"))continue;let P=await sc(ot(c,O.name));if(P===null)continue;if(Ci(P,T,d))return!0}return!1}function Ci(c,l,d){let f=Zu(c.tail,"relocated","relocatedCwd")??Qu(c.head,"cwd");if(f===void 0)return!1;let h=Gn(g(f));return d?h.toLowerCase()===l.toLowerCase():h===l}async function oc(c,l,d,f){let{backend:h,transcriptKey:R,isKeySegment:T}=f,D=Gn(l),O=!1,P=new Set;try{let F=await Cr((Y)=>h.listEntries({namespace:"transcript",projectKey:c},wi(Y)),async(Y)=>{for(let ie of Y){if(ie.kind!=="key"||ie.key.namespace!=="transcript"||ie.key.projectKey!==c||ie.key.agentId!==void 0||!T(ie.key.sessionId)||P.has(ie.key.sessionId))continue;let V=ie.key.sessionId,ae=await Ri({backend:h,key:R(c,V)});if(ae===null)continue;if(P.add(V),Ci(ae,D,d)){O=!0;return}}},{until:()=>O});if(O)return!0;if(F.status!=="done")return}catch{return}return!1}async function Ke(c,l,d=Z()){if(l!==void 0&&l.hoverRestOn)return ac(c,l);if(m())return[];let f=Be(c,d),h=[];try{await Wn(f),h.push(f)}catch{}let R=Tr(c);if(R!==void 0){let Y=ot(d,R);try{await Wn(Y),h.push(Y)}catch{}return h}let T=_n(c);if(T.length<=Kt)return h;let D=process.platform==="win32",O=(Y)=>D?Y.toLowerCase():Y,P=O(T.slice(0,Kt)+"-"),F=O(f);try{for(let Y of await Wn(d,{withFileTypes:!0})){if(!Y.isDirectory()||!O(Y.name).startsWith(P))continue;let ie=ot(d,Y.name);if(O(ie)!==F&&await nt(ie,c,D))h.push(ie)}}catch{}return h}async function ac(c,l){let d=await uc(l.source);if(d===null){let f=Tr(c);return[Be(c),...f!==void 0?[ot(Z(),f)]:[]]}return cc(c,d,process.platform==="win32",l)}async function uc(c){let{backend:l,isKeySegment:d}=c,f=[],h=new Set,R=0;try{if((await Cr((D)=>l.listEntries({namespace:"transcript"},wi(D)),(D)=>{for(let O of D){let P=bt(O,d);if(P!==void 0&&!h.has(P))h.add(P),f.push(P)}R++})).status==="error")return R===0?null:f}catch{return R===0?null:f}return f}async function cc(c,l,d,f){let h=hn(c),R=Be(c),T=Tr(c),D=T===void 0&&h.length>Kt?h.slice(0,Kt)+"-":void 0,O=Z(),P=(ne)=>d?ne.toLowerCase():ne,F=D!==void 0?P(D):void 0,Y=P(h),ie=!1,V,ae=[],te=new Set;for(let ne of l)if(ne===h)ie=!0;else if(T!==void 0){if(V===void 0&&P(ne)===P(T))V=ot(O,ne)}else if(F!==void 0&&P(ne).startsWith(F)&&P(ne)!==Y&&!te.has(P(ne)))te.add(P(ne)),ae.push(ne);let fe=[];for(let ne of ae){let de=ot(O,ne);if(await nt(de,c,d,f))fe.push(de)}return[...ie?[R]:[],...V!==void 0?[V]:[],...fe]}var dg=Buffer.from('"compact_boundary"');var pg=Buffer.from('{"type":"attribution-snapshot"'),gg=Buffer.from('{"type":"system"'),lc=10,fg=Buffer.from([lc]);import{realpathSync as dc}from"fs";import{isAbsolute as pc,relative as gc,resolve as fc,sep as mc}from"path";function _c(c){let l=fc(c??"."),d;try{d=dc(l)}catch{d=l}return g(d)}function Q(c,l){let d=_c(c);if(l===void 0)return hn(d);return(l.CLAUDE_CONFIG_DIR?jt(l.CLAUDE_CODE_PROJECT_DIR_NAME):void 0)??_n(d)}function dn(c){return typeof c==="object"&&c!==null&&"type"in c&&c.type==="agent_metadata"}function At(c,l){let d=gc(l,c),f=d.split(mc);if(f[0]===".."||pc(d))return null;if(f.length<2)return null;let h=f[0],R=f[1];if(f.length===2&&R.endsWith(".jsonl"))return{projectKey:h,sessionId:R.replace(/\.jsonl$/,"")};if(f.length>=4){let T=f.slice(2),D=T.length-1;return T[D]=T.at(-1).replace(/\.jsonl$/,""),{projectKey:h,sessionId:R,subpath:T.join("/")}}return null}function ee(){return wt.of(E().host)}function Rt(c){ee().invalidateAll(c)}var cn=["userSettings","projectSettings","localSettings","flagSettings","policySettings"];var hc=["userSettings","projectSettings","localSettings"],yc=["projectSettings","localSettings"],Lg=new Set(yc),Sc={userSettings:"user",projectSettings:"project",localSettings:"local"},Ug=hc.map((c)=>[Sc[c],c]);var un="--settings (inline JSON)",pn=["auto","bypassPermissions"],Ot="organizationFreeFormSettings";
28
- export{L,Mn,_,S,G,Nn,Un,Le,q,ct,ge,ut,Oe,Yt,Me,Ye,qt,Xt,qe,A,pt,Jt,Ne,me,Xe,Zt,C,r,b,I,Je,ft,M,Ue,gt,Te,Ze,he,Fe,i,Qe,mt,Qt,en,N,_e,tn,we,X,ke,He,nn,e,x,Se,J,n,et,rn,ht,_t,on,Ee,sn,St,an,ln,ye,U,Et,yt,bt,Z,Be,tt,Ct,nt,Ke,Q,dn,At,ee,Rt,cn,un,pn,Ot};