@pensar/apex 2.2.0 → 2.3.0-canary.15ec17ea
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/build/{agent-yayy5x2a.js → agent-00rjnxth.js} +7 -7
- package/build/agent-65jzj95h.js +19 -0
- package/build/{agent-q5hwjdtb.js → agent-q3yvg7qp.js} +9 -9
- package/build/{apps-0es69e2s.js → apps-f3snzs8b.js} +16 -16
- package/build/{auth-q73k9bh9.js → auth-5pqmq5x9.js} +32 -39
- package/build/authentication-cx4fr1jm.js +19 -0
- package/build/blackboxAgent-t4kd841t.js +19 -0
- package/build/{blackboxPentest-h28nykk5.js → blackboxPentest-bwj95jra.js} +14 -14
- package/build/{cli-51dkmt5p.js → cli-3b5rh4nn.js} +1 -1
- package/build/{cli-xbdn034b.js → cli-3q27f7wb.js} +4158 -102
- package/build/{cli-2jn8104w.js → cli-b27w98bz.js} +2 -2
- package/build/{cli-6kx46ck0.js → cli-ef2c0sm6.js} +216 -38
- package/build/{cli-1re2kv5v.js → cli-fkkkkf49.js} +3 -3
- package/build/{cli-tz9yg4ew.js → cli-nsc30rcx.js} +24 -8
- package/build/{cli-vgg6h2ax.js → cli-q7123drf.js} +1 -1
- package/build/{cli-7n43wz82.js → cli-sf878p6j.js} +5 -2
- package/build/{cli-xpn9tsw0.js → cli-v8q0djvy.js} +3 -3
- package/build/{cli-ptzy9ak5.js → cli-vbz5qm07.js} +1 -1
- package/build/{cli-s43t5ay0.js → cli-vfsxxnmr.js} +1 -1
- package/build/{cli-n114n8mk.js → cli-wp59e6eq.js} +2 -2
- package/build/{cli-7e5ad5js.js → cli-x5gd8b11.js} +2 -2
- package/build/{cli-1cf5vy5m.js → cli-x7tqybza.js} +60 -28
- package/build/{cli-4tc6888c.js → cli-xw6xh0c2.js} +51 -2
- package/build/{cli-yz80qkzn.js → cli-ycj65kyw.js} +6 -0
- package/build/{cli-knqx15w6.js → cli-ztk7j1rd.js} +2 -2
- package/build/{cli-1f636vzd.js → cli-ztvkmav5.js} +1 -1
- package/build/cli.js +42 -36
- package/build/{config-xcf7rc6x.js → config-4bxc6cvx.js} +3 -3
- package/build/{doctor-98zperf9.js → doctor-njjx9pc4.js} +7 -6
- package/build/{fastStrike-9tm6bedh.js → fastStrike-zcyrev2c.js} +34 -14
- package/build/{fixes-1dry8j61.js → fixes-4gsx59zz.js} +16 -16
- package/build/{index-f6ttv7np.js → index-05cb7ddj.js} +9 -5
- package/build/{index-34h2nb6x.js → index-0kd686e2.js} +3 -3
- package/build/{index-pxwwcefn.js → index-1swzf5ha.js} +9 -9
- package/build/{index-31rwrakh.js → index-kamp2pwf.js} +2 -2
- package/build/{index-6dbym5jy.js → index-nwx21gnf.js} +29 -12
- package/build/{index-0j880wqc.js → index-tesn1wem.js} +1106 -901
- package/build/{index-4hqbyzf5.js → index-vgp133kt.js} +8 -8
- package/build/{issues-wjakj8yy.js → issues-fdqzva1g.js} +44 -16
- package/build/{logs-ewyzcspy.js → logs-hy3kvx1m.js} +16 -16
- package/build/{offesecAgent-7m9smy0t.js → offesecAgent-x1ap18zc.js} +8 -8
- package/build/pentest-v886reb6.js +29 -0
- package/build/{pentests-1hcqjyk2.js → pentests-38363a42.js} +16 -16
- package/build/{targetedPentest-3x13kqvc.js → targetedPentest-td5hts5a.js} +9 -9
- package/build/{targets-nqz8w37e.js → targets-ys9ezcjn.js} +16 -16
- package/build/threatModel-8ygdfkqx.js +27 -0
- package/build/{uninstall-p1q5pkx2.js → uninstall-pszt5mdd.js} +1 -1
- package/build/{upload-x7etpfp4.js → upload-61bcszx8.js} +6 -6
- package/build/{utils-kw6yh5yn.js → utils-fhqds1ws.js} +11 -7
- package/package.json +1 -1
- package/build/agent-3cdfwxcd.js +0 -19
- package/build/authentication-tqx2brcv.js +0 -19
- package/build/blackboxAgent-d0smgqt7.js +0 -19
- package/build/pentest-1cb5t0dt.js +0 -29
- package/build/threatModel-7f02av7y.js +0 -27
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
detectOSAndEnhancePrompt
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-vfsxxnmr.js";
|
|
4
4
|
import {
|
|
5
5
|
parseTargetUrl
|
|
6
6
|
} from "./cli-c8131c4q.js";
|
|
@@ -32,14 +32,14 @@ import {
|
|
|
32
32
|
streamResponse,
|
|
33
33
|
withSubagentSessionBaggage,
|
|
34
34
|
write
|
|
35
|
-
} from "./cli-
|
|
35
|
+
} from "./cli-ef2c0sm6.js";
|
|
36
36
|
import {
|
|
37
37
|
ensureValidToken,
|
|
38
38
|
getPensarApiUrl,
|
|
39
39
|
init_auth,
|
|
40
40
|
init_constants,
|
|
41
41
|
signGatewayRequest
|
|
42
|
-
} from "./cli-
|
|
42
|
+
} from "./cli-xw6xh0c2.js";
|
|
43
43
|
import {
|
|
44
44
|
_enum,
|
|
45
45
|
_null,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
import {
|
|
71
71
|
config,
|
|
72
72
|
init_config
|
|
73
|
-
} from "./cli-
|
|
73
|
+
} from "./cli-3b5rh4nn.js";
|
|
74
74
|
import {
|
|
75
75
|
__commonJS,
|
|
76
76
|
__require,
|
|
@@ -46340,7 +46340,7 @@ var require_gaxios = __commonJS((exports) => {
|
|
|
46340
46340
|
var retry_js_1 = require_retry();
|
|
46341
46341
|
var stream_1 = __require("stream");
|
|
46342
46342
|
var interceptor_js_1 = require_interceptor();
|
|
46343
|
-
var
|
|
46343
|
+
var randomUUID2 = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
|
|
46344
46344
|
var HTTP_STATUS_NO_CONTENT = 204;
|
|
46345
46345
|
|
|
46346
46346
|
class Gaxios {
|
|
@@ -46551,7 +46551,7 @@ var require_gaxios = __commonJS((exports) => {
|
|
|
46551
46551
|
}
|
|
46552
46552
|
const shouldDirectlyPassData = typeof opts.data === "string" || opts.data instanceof ArrayBuffer || opts.data instanceof Blob || globalThis.File && opts.data instanceof File || opts.data instanceof FormData || opts.data instanceof stream_1.Readable || opts.data instanceof ReadableStream || opts.data instanceof String || opts.data instanceof URLSearchParams || ArrayBuffer.isView(opts.data) || ["Blob", "File", "FormData"].includes(opts.data?.constructor?.name || "");
|
|
46553
46553
|
if (opts.multipart?.length) {
|
|
46554
|
-
const boundary = await
|
|
46554
|
+
const boundary = await randomUUID2();
|
|
46555
46555
|
preparedHeaders.set("content-type", `multipart/related; boundary=${boundary}`);
|
|
46556
46556
|
opts.body = stream_1.Readable.from(this.getMultipartRequest(opts.multipart, boundary));
|
|
46557
46557
|
} else if (shouldDirectlyPassData) {
|
|
@@ -57496,7 +57496,7 @@ var require_apirequest = __commonJS((exports) => {
|
|
|
57496
57496
|
var h2 = require_http2();
|
|
57497
57497
|
var util_1 = require_util6();
|
|
57498
57498
|
var pkg = require_package4();
|
|
57499
|
-
var
|
|
57499
|
+
var randomUUID2 = () => globalThis.crypto?.randomUUID() || __require("crypto").randomUUID();
|
|
57500
57500
|
function isReadableStream(obj) {
|
|
57501
57501
|
return obj !== null && typeof obj === "object" && typeof obj.pipe === "function" && obj.readable !== false && typeof obj._read === "function" && typeof obj._readableState === "object";
|
|
57502
57502
|
}
|
|
@@ -57569,7 +57569,7 @@ var require_apirequest = __commonJS((exports) => {
|
|
|
57569
57569
|
authClient = undefined;
|
|
57570
57570
|
}
|
|
57571
57571
|
function multipartUpload(multipart) {
|
|
57572
|
-
const boundary =
|
|
57572
|
+
const boundary = randomUUID2();
|
|
57573
57573
|
const finale = `--${boundary}--`;
|
|
57574
57574
|
const rStream = new stream.PassThrough({
|
|
57575
57575
|
flush(callback) {
|
|
@@ -57608,7 +57608,7 @@ content-type: ${part["content-type"]}\r
|
|
|
57608
57608
|
options.data = rStream;
|
|
57609
57609
|
}
|
|
57610
57610
|
function browserMultipartUpload(multipart) {
|
|
57611
|
-
const boundary =
|
|
57611
|
+
const boundary = randomUUID2();
|
|
57612
57612
|
const finale = `--${boundary}--`;
|
|
57613
57613
|
headers["content-type"] = `multipart/related; boundary=${boundary}`;
|
|
57614
57614
|
let content = "";
|
|
@@ -99680,13 +99680,18 @@ class AgentEventBus {
|
|
|
99680
99680
|
});
|
|
99681
99681
|
break;
|
|
99682
99682
|
case "reasoning-start":
|
|
99683
|
-
this.emit("reasoning-start", { subagentId });
|
|
99683
|
+
this.emit("reasoning-start", { subagentId, sessionId, messageId });
|
|
99684
99684
|
break;
|
|
99685
99685
|
case "reasoning-delta":
|
|
99686
|
-
this.emit("reasoning-delta", {
|
|
99686
|
+
this.emit("reasoning-delta", {
|
|
99687
|
+
text: chunk.text,
|
|
99688
|
+
subagentId,
|
|
99689
|
+
sessionId,
|
|
99690
|
+
messageId
|
|
99691
|
+
});
|
|
99687
99692
|
break;
|
|
99688
99693
|
case "reasoning-end":
|
|
99689
|
-
this.emit("reasoning-end", { subagentId });
|
|
99694
|
+
this.emit("reasoning-end", { subagentId, sessionId, messageId });
|
|
99690
99695
|
break;
|
|
99691
99696
|
case "tool-input-start":
|
|
99692
99697
|
this.emit("tool-call-start", {
|
|
@@ -99781,10 +99786,10 @@ ${lines.join(`
|
|
|
99781
99786
|
|
|
99782
99787
|
Read these with \`read_file\` and list directory contents with \`list_files provided_files/\` as needed. A \`README.md\` inside \`provided_files/\` may include per-file descriptions supplied by the user — check it first before diving into individual files.`;
|
|
99783
99788
|
}
|
|
99784
|
-
function buildSessionWorkspaceSection(session, agentCwd) {
|
|
99789
|
+
function buildSessionWorkspaceSection(session, agentCwd, activeTools) {
|
|
99785
99790
|
const sandboxMode = agentCwd === session.rootPath;
|
|
99786
99791
|
const providedFilesSection = buildProvidedFilesSection(session.rootPath);
|
|
99787
|
-
const sourceAssessmentSection = buildSourceAssessmentSection(session, agentCwd, sandboxMode);
|
|
99792
|
+
const sourceAssessmentSection = buildSourceAssessmentSection(session, agentCwd, sandboxMode, activeTools);
|
|
99788
99793
|
if (sandboxMode) {
|
|
99789
99794
|
return `
|
|
99790
99795
|
|
|
@@ -99819,14 +99824,33 @@ Session artifacts are stored separately at ${session.rootPath}:
|
|
|
99819
99824
|
|
|
99820
99825
|
Tools like \`document_vulnerability\` and browser evidence capture write to the session directory automatically.${providedFilesSection}${sourceAssessmentSection}`;
|
|
99821
99826
|
}
|
|
99822
|
-
|
|
99827
|
+
var SOURCE_ASSESSMENT_TOOL_NAMES = [
|
|
99828
|
+
"profile_codebase",
|
|
99829
|
+
"query_whitebox_catalog",
|
|
99830
|
+
"run_code_query",
|
|
99831
|
+
"run_whitebox_scan"
|
|
99832
|
+
];
|
|
99833
|
+
var REPO_MUTATION_TOOL_NAMES = [
|
|
99834
|
+
"update_file",
|
|
99835
|
+
"apply_patch",
|
|
99836
|
+
"create_file",
|
|
99837
|
+
"delete_file"
|
|
99838
|
+
];
|
|
99839
|
+
function buildSourceAssessmentSection(session, agentCwd, sandboxMode, activeTools) {
|
|
99823
99840
|
const codebasePath = session.config?.codebasePath;
|
|
99824
99841
|
const hasSourceAccess = Boolean(codebasePath) || !sandboxMode;
|
|
99825
99842
|
if (!hasSourceAccess)
|
|
99826
99843
|
return "";
|
|
99844
|
+
if (activeTools && !SOURCE_ASSESSMENT_TOOL_NAMES.some((name) => activeTools.includes(name))) {
|
|
99845
|
+
return "";
|
|
99846
|
+
}
|
|
99827
99847
|
const sourceRoot = codebasePath ?? agentCwd;
|
|
99828
99848
|
const alignmentNote = codebasePath && codebasePath !== agentCwd ? `
|
|
99829
99849
|
The configured codebase path is ${codebasePath}, while your shell starts in ${agentCwd}. Use the configured codebase path for source analysis unless the user says otherwise.` : "";
|
|
99850
|
+
const mayEditRepo = activeTools?.some((name) => REPO_MUTATION_TOOL_NAMES.includes(name)) ?? false;
|
|
99851
|
+
const repoEditBullet = mayEditRepo ? `
|
|
99852
|
+
- Keep harnesses, generated inputs, and scratch scripts under the session scratchpad. Limit repo edits to the change you were dispatched to make.` : `
|
|
99853
|
+
- Do not modify the target repo by default. Put harnesses, generated inputs, and scratch scripts under the session scratchpad unless the operator approves repo edits.`;
|
|
99830
99854
|
return `
|
|
99831
99855
|
|
|
99832
99856
|
# Source Code Assessment
|
|
@@ -99839,8 +99863,7 @@ Use source access as a force multiplier, not as a rigid workflow:
|
|
|
99839
99863
|
- Prefer sink-first analysis: find dangerous operations, then trace backward to attacker-controlled entry points and trust boundaries.
|
|
99840
99864
|
- Use \`run_code_query\` for batched source searches, \`run_whitebox_scan\` for installed scanners, and \`spawn_coding_agent\` for independent deep dives.
|
|
99841
99865
|
- Track unverified hypotheses with whitebox candidates. Only call \`document_vulnerability\` after a PoC, crash reproducer, or dynamic check confirms exploitability.
|
|
99842
|
-
- Run builds, local servers, sanitizer runs, and microfuzzers through bounded whitebox jobs so logs and crashes are preserved as artifacts
|
|
99843
|
-
- Do not modify the target repo by default. Put harnesses, generated inputs, and scratch scripts under the session scratchpad unless the operator approves repo edits.`;
|
|
99866
|
+
- Run builds, local servers, sanitizer runs, and microfuzzers through bounded whitebox jobs so logs and crashes are preserved as artifacts.${repoEditBullet}`;
|
|
99844
99867
|
}
|
|
99845
99868
|
function buildBaseSystemPrompt(options) {
|
|
99846
99869
|
const sandboxMode = options?.sandboxMode ?? true;
|
|
@@ -100105,6 +100128,7 @@ function askUserQuestions(_ctx) {
|
|
|
100105
100128
|
}
|
|
100106
100129
|
|
|
100107
100130
|
// src/core/agents/offSecAgent/tools/playwrightMcp.ts
|
|
100131
|
+
import { randomUUID } from "node:crypto";
|
|
100108
100132
|
import {
|
|
100109
100133
|
existsSync as existsSync2,
|
|
100110
100134
|
mkdirSync,
|
|
@@ -102697,17 +102721,54 @@ var MEMORY_FIREFOX_PREFS = {
|
|
|
102697
102721
|
"browser.cache.memory.enable": false,
|
|
102698
102722
|
"browser.sessionhistory.max_total_viewers": 0
|
|
102699
102723
|
};
|
|
102700
|
-
|
|
102724
|
+
var ENDPOINT_DISPLAY_BASE = 10;
|
|
102725
|
+
var COMPUTER_USE_VIEWPORT_SIZE = "1920,1080";
|
|
102726
|
+
var ENDPOINT_VIEWPORT_SIZE = "1280,720";
|
|
102727
|
+
function parseViewportSize(viewportSize) {
|
|
102728
|
+
const match = /^(\d+),(\d+)$/.exec(viewportSize.trim());
|
|
102729
|
+
if (!match)
|
|
102730
|
+
return;
|
|
102731
|
+
const width = Number(match[1]);
|
|
102732
|
+
const height = Number(match[2]);
|
|
102733
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
102734
|
+
return;
|
|
102735
|
+
}
|
|
102736
|
+
return [width, height];
|
|
102737
|
+
}
|
|
102738
|
+
function parseDisplayNumber(display) {
|
|
102739
|
+
if (!display)
|
|
102740
|
+
return;
|
|
102741
|
+
const match = /^:(\d+)/.exec(display.trim());
|
|
102742
|
+
if (!match)
|
|
102743
|
+
return;
|
|
102744
|
+
const num = Number(match[1]);
|
|
102745
|
+
return Number.isFinite(num) ? num : undefined;
|
|
102746
|
+
}
|
|
102747
|
+
function camoufoxWindowOptions(window2) {
|
|
102748
|
+
const [width, height] = window2;
|
|
102749
|
+
return {
|
|
102750
|
+
window: [width, height],
|
|
102751
|
+
screen: {
|
|
102752
|
+
minWidth: width,
|
|
102753
|
+
maxWidth: width,
|
|
102754
|
+
minHeight: height,
|
|
102755
|
+
maxHeight: height
|
|
102756
|
+
}
|
|
102757
|
+
};
|
|
102758
|
+
}
|
|
102759
|
+
async function resolveCamoufoxLaunchOptions(headless, opts) {
|
|
102701
102760
|
const { launchOptions: camoufoxLaunchOptions } = await import("camoufox-js");
|
|
102702
|
-
const
|
|
102761
|
+
const windowOpts = opts?.window ? camoufoxWindowOptions(opts.window) : {};
|
|
102762
|
+
const resolved = await camoufoxLaunchOptions({
|
|
102703
102763
|
...CAMOUFOX_OPTIONS,
|
|
102704
|
-
headless
|
|
102764
|
+
headless,
|
|
102765
|
+
...windowOpts
|
|
102705
102766
|
});
|
|
102706
|
-
|
|
102707
|
-
...
|
|
102767
|
+
resolved.firefoxUserPrefs = {
|
|
102768
|
+
...resolved.firefoxUserPrefs,
|
|
102708
102769
|
...MEMORY_FIREFOX_PREFS
|
|
102709
102770
|
};
|
|
102710
|
-
return
|
|
102771
|
+
return resolved;
|
|
102711
102772
|
}
|
|
102712
102773
|
var ensurePromise = null;
|
|
102713
102774
|
function ensureCamoufox(log) {
|
|
@@ -102872,9 +102933,33 @@ function collectDescendantPids(rootPid) {
|
|
|
102872
102933
|
}
|
|
102873
102934
|
return descendants;
|
|
102874
102935
|
}
|
|
102936
|
+
var BROWSER_LAUNCH_ENV = "PENSAR_BROWSER_LAUNCH_ID";
|
|
102937
|
+
function collectPidsByEnvMarker(key, value) {
|
|
102938
|
+
let entries;
|
|
102939
|
+
try {
|
|
102940
|
+
entries = readdirSync2("/proc");
|
|
102941
|
+
} catch {
|
|
102942
|
+
return [];
|
|
102943
|
+
}
|
|
102944
|
+
const needle = `${key}=${value}`;
|
|
102945
|
+
const pids = [];
|
|
102946
|
+
for (const name of entries) {
|
|
102947
|
+
if (!/^\d+$/.test(name))
|
|
102948
|
+
continue;
|
|
102949
|
+
const pid = Number(name);
|
|
102950
|
+
if (pid === process.pid)
|
|
102951
|
+
continue;
|
|
102952
|
+
try {
|
|
102953
|
+
if (readFileSync(`/proc/${pid}/environ`, "utf8").split("\x00").includes(needle)) {
|
|
102954
|
+
pids.push(pid);
|
|
102955
|
+
}
|
|
102956
|
+
} catch {}
|
|
102957
|
+
}
|
|
102958
|
+
return pids;
|
|
102959
|
+
}
|
|
102875
102960
|
var defaultHeadless = true;
|
|
102876
102961
|
var defaultUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
|
|
102877
|
-
var HARDCODED_VIEWPORT_FALLBACK =
|
|
102962
|
+
var HARDCODED_VIEWPORT_FALLBACK = COMPUTER_USE_VIEWPORT_SIZE;
|
|
102878
102963
|
var defaultViewportSize = HARDCODED_VIEWPORT_FALLBACK;
|
|
102879
102964
|
function setHeadlessMode(headless) {
|
|
102880
102965
|
defaultHeadless = headless;
|
|
@@ -102899,12 +102984,20 @@ class PlaywrightMcpSession {
|
|
|
102899
102984
|
display;
|
|
102900
102985
|
mcpConfigPath = null;
|
|
102901
102986
|
cachedCamouOptions = null;
|
|
102987
|
+
currentLaunchId = null;
|
|
102902
102988
|
constructor(options = {}) {
|
|
102903
102989
|
const { headless, userAgent, viewportSize, extraHttpHeaders, display } = options;
|
|
102904
102990
|
this.display = display ?? process.env.DISPLAY ?? undefined;
|
|
102905
102991
|
this.headless = headless ?? (this.display ? false : defaultHeadless);
|
|
102906
102992
|
this.userAgent = userAgent === null ? undefined : userAgent ?? defaultUserAgent;
|
|
102907
|
-
|
|
102993
|
+
if (viewportSize === null) {
|
|
102994
|
+
this.viewportSize = undefined;
|
|
102995
|
+
} else if (viewportSize !== undefined) {
|
|
102996
|
+
this.viewportSize = viewportSize;
|
|
102997
|
+
} else {
|
|
102998
|
+
const displayNum = parseDisplayNumber(this.display);
|
|
102999
|
+
this.viewportSize = displayNum !== undefined && displayNum >= ENDPOINT_DISPLAY_BASE ? ENDPOINT_VIEWPORT_SIZE : defaultViewportSize ?? HARDCODED_VIEWPORT_FALLBACK;
|
|
103000
|
+
}
|
|
102908
103001
|
const headerSource = extraHttpHeaders === null ? undefined : extraHttpHeaders;
|
|
102909
103002
|
this.extraHttpHeaders = headerSource && Object.keys(headerSource).length > 0 ? { ...headerSource } : undefined;
|
|
102910
103003
|
}
|
|
@@ -102928,33 +103021,41 @@ class PlaywrightMcpSession {
|
|
|
102928
103021
|
} catch {}
|
|
102929
103022
|
})();
|
|
102930
103023
|
}
|
|
102931
|
-
forceKillProcess(proc = this.mcpProcess) {
|
|
102932
|
-
if (
|
|
102933
|
-
|
|
102934
|
-
|
|
102935
|
-
|
|
102936
|
-
|
|
102937
|
-
|
|
102938
|
-
|
|
102939
|
-
|
|
102940
|
-
|
|
102941
|
-
|
|
102942
|
-
|
|
102943
|
-
|
|
102944
|
-
|
|
103024
|
+
forceKillProcess(proc = this.mcpProcess, launchId = this.currentLaunchId) {
|
|
103025
|
+
if (proc && proc.exitCode === null) {
|
|
103026
|
+
const rootPid = proc.pid ?? null;
|
|
103027
|
+
const descendants = rootPid != null ? collectDescendantPids(rootPid) : [];
|
|
103028
|
+
const descendantStarts = new Map;
|
|
103029
|
+
for (const pid of descendants) {
|
|
103030
|
+
descendantStarts.set(pid, readProcStartTime(pid));
|
|
103031
|
+
}
|
|
103032
|
+
try {
|
|
103033
|
+
if (rootPid != null) {
|
|
103034
|
+
try {
|
|
103035
|
+
process.kill(-rootPid, "SIGKILL");
|
|
103036
|
+
} catch {
|
|
103037
|
+
proc.kill("SIGKILL");
|
|
103038
|
+
}
|
|
103039
|
+
} else {
|
|
102945
103040
|
proc.kill("SIGKILL");
|
|
102946
103041
|
}
|
|
102947
|
-
}
|
|
102948
|
-
|
|
102949
|
-
|
|
102950
|
-
} catch {}
|
|
102951
|
-
for (const pid of descendants) {
|
|
102952
|
-
const expected = descendantStarts.get(pid);
|
|
102953
|
-
if (expected != null) {
|
|
103042
|
+
} catch {}
|
|
103043
|
+
for (const pid of descendants) {
|
|
103044
|
+
const expected = descendantStarts.get(pid);
|
|
102954
103045
|
const now = readProcStartTime(pid);
|
|
102955
|
-
if (now == null || now !== expected)
|
|
103046
|
+
if (expected == null || now == null || now !== expected)
|
|
102956
103047
|
continue;
|
|
103048
|
+
try {
|
|
103049
|
+
process.kill(pid, "SIGKILL");
|
|
103050
|
+
} catch {}
|
|
102957
103051
|
}
|
|
103052
|
+
}
|
|
103053
|
+
this.reapLaunchedProcesses(launchId);
|
|
103054
|
+
}
|
|
103055
|
+
reapLaunchedProcesses(launchId) {
|
|
103056
|
+
if (!launchId)
|
|
103057
|
+
return;
|
|
103058
|
+
for (const pid of collectPidsByEnvMarker(BROWSER_LAUNCH_ENV, launchId)) {
|
|
102958
103059
|
try {
|
|
102959
103060
|
process.kill(pid, "SIGKILL");
|
|
102960
103061
|
} catch {}
|
|
@@ -102979,7 +103080,8 @@ class PlaywrightMcpSession {
|
|
|
102979
103080
|
const args = [cliPath, "--isolated"];
|
|
102980
103081
|
await ensureCamoufox();
|
|
102981
103082
|
if (!this.cachedCamouOptions) {
|
|
102982
|
-
this.
|
|
103083
|
+
const window2 = this.viewportSize ? parseViewportSize(this.viewportSize) : undefined;
|
|
103084
|
+
this.cachedCamouOptions = await resolveCamoufoxLaunchOptions(this.headless, window2 ? { window: window2 } : undefined);
|
|
102983
103085
|
}
|
|
102984
103086
|
const camou = this.cachedCamouOptions;
|
|
102985
103087
|
const os = await import("node:os");
|
|
@@ -103002,13 +103104,16 @@ class PlaywrightMcpSession {
|
|
|
103002
103104
|
mode: 384
|
|
103003
103105
|
});
|
|
103004
103106
|
args.push("--config", this.mcpConfigPath);
|
|
103107
|
+
const launchId = randomUUID();
|
|
103108
|
+
this.currentLaunchId = launchId;
|
|
103005
103109
|
const transport = new StdioClientTransport({
|
|
103006
103110
|
command: "node",
|
|
103007
103111
|
args,
|
|
103008
103112
|
stderr: "pipe",
|
|
103009
103113
|
env: {
|
|
103010
103114
|
...Object.fromEntries(Object.entries(camou.env).map(([k, v]) => [k, String(v)])),
|
|
103011
|
-
...this.display ? { DISPLAY: this.display } : {}
|
|
103115
|
+
...this.display ? { DISPLAY: this.display } : {},
|
|
103116
|
+
[BROWSER_LAUNCH_ENV]: launchId
|
|
103012
103117
|
}
|
|
103013
103118
|
});
|
|
103014
103119
|
const client = new Client({
|
|
@@ -103025,6 +103130,7 @@ class PlaywrightMcpSession {
|
|
|
103025
103130
|
this.mcpTransport = transport;
|
|
103026
103131
|
client.onclose = () => {
|
|
103027
103132
|
if (this.mcpClient === client) {
|
|
103133
|
+
this.forceKillProcess(this.mcpProcess, launchId);
|
|
103028
103134
|
this.resetState();
|
|
103029
103135
|
}
|
|
103030
103136
|
};
|
|
@@ -104912,13 +105018,35 @@ const fs = require('fs');
|
|
|
104912
105018
|
// detectable headful. Falls back to plain headless, which is still fully
|
|
104913
105019
|
// fingerprint-spoofed (just a weaker stealth posture, never vanilla Chromium).
|
|
104914
105020
|
const __headless = process.env.DISPLAY ? false : true;
|
|
105021
|
+
// Match Camoufox window to the bound Xvfb tier (Console desktopSession /
|
|
105022
|
+
// Xvfb shim: :0–:9 → 1920x1080, :10+ → 1280x720). Constants are inlined
|
|
105023
|
+
// from ./camoufox so host + sandbox stay lockstep.
|
|
105024
|
+
const __ENDPOINT_DISPLAY_BASE = ${ENDPOINT_DISPLAY_BASE};
|
|
105025
|
+
const __endpointWindow = ${JSON.stringify(parseViewportSize(ENDPOINT_VIEWPORT_SIZE))};
|
|
105026
|
+
const __computerUseWindow = ${JSON.stringify(parseViewportSize(COMPUTER_USE_VIEWPORT_SIZE))};
|
|
105027
|
+
const __displayMatch = /^:(\\d+)/.exec(process.env.DISPLAY || '');
|
|
105028
|
+
const __displayNum = __displayMatch ? Number(__displayMatch[1]) : undefined;
|
|
105029
|
+
const __window =
|
|
105030
|
+
__displayNum !== undefined && __displayNum >= __ENDPOINT_DISPLAY_BASE
|
|
105031
|
+
? __endpointWindow
|
|
105032
|
+
: __computerUseWindow;
|
|
104915
105033
|
// Resolve Camoufox options once per sandbox session and cache to disk so
|
|
104916
105034
|
// every tool call presents the same fingerprint on the shared profile dir.
|
|
104917
105035
|
let __camou;
|
|
104918
105036
|
try {
|
|
104919
105037
|
__camou = JSON.parse(fs.readFileSync('${SANDBOX_CAMOU_CACHE}', 'utf-8'));
|
|
104920
105038
|
} catch {
|
|
104921
|
-
__camou = await launchOptions({
|
|
105039
|
+
__camou = await launchOptions({
|
|
105040
|
+
...${JSON.stringify(CAMOUFOX_OPTIONS)},
|
|
105041
|
+
headless: __headless,
|
|
105042
|
+
window: __window,
|
|
105043
|
+
screen: {
|
|
105044
|
+
minWidth: __window[0],
|
|
105045
|
+
maxWidth: __window[0],
|
|
105046
|
+
minHeight: __window[1],
|
|
105047
|
+
maxHeight: __window[1],
|
|
105048
|
+
},
|
|
105049
|
+
});
|
|
104922
105050
|
fs.writeFileSync('${SANDBOX_CAMOU_CACHE}', JSON.stringify(__camou));
|
|
104923
105051
|
}
|
|
104924
105052
|
|
|
@@ -106376,24 +106504,27 @@ function getTaskSummary(tasksDir, preloaded) {
|
|
|
106376
106504
|
|
|
106377
106505
|
// src/core/agents/offSecAgent/tools/createTask.ts
|
|
106378
106506
|
var createTaskInputSchema = exports_external.object({
|
|
106379
|
-
subject: exports_external.string().describe("Short subject line for the task (e.g., 'Test /api/users id param for UNION-based SQLi')"),
|
|
106380
|
-
description: exports_external.string().describe("Detailed description of what to
|
|
106381
|
-
objective: exports_external.string().describe("
|
|
106382
|
-
technique: exports_external.string().describe("
|
|
106383
|
-
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe("Optional metadata (e.g
|
|
106507
|
+
subject: exports_external.string().describe("Short subject line for the task (e.g., 'Apply parameterized query fix in login handler', 'Test /api/users id param for UNION-based SQLi')"),
|
|
106508
|
+
description: exports_external.string().describe("Detailed description of the work — for coding: what to change and how to verify; for testing: payloads, encoding strategies, or bypass techniques"),
|
|
106509
|
+
objective: exports_external.string().optional().describe("Optional higher-level objective this task addresses (e.g. a pentest objective or 'Fix SQL injection in auth'). Defaults to the subject when omitted."),
|
|
106510
|
+
technique: exports_external.string().optional().describe("Optional technique or approach label (e.g. 'parameterized queries', 'UNION-based SQL injection'). Defaults to 'general' when omitted."),
|
|
106511
|
+
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe("Optional metadata (e.g. { priority: 'high', file: 'src/auth.ts', endpoint: '/api/users' })")
|
|
106384
106512
|
});
|
|
106385
106513
|
function createTask2(ctx) {
|
|
106386
106514
|
return tool({
|
|
106387
|
-
description: `Create a
|
|
106515
|
+
description: `Create a task to track your work.
|
|
106516
|
+
|
|
106517
|
+
Use tasks as a lightweight todo list: decompose the job into concrete, atomic steps, create them early, and update status as you go.
|
|
106388
106518
|
|
|
106389
|
-
|
|
106519
|
+
Works for both coding agents (patch/fix/verify steps) and pentest agents (technique × endpoint tests).
|
|
106390
106520
|
|
|
106391
|
-
Call this BEFORE you start
|
|
106521
|
+
Call this BEFORE you start substantive work to build your task list. Add more mid-run when you discover extra work.
|
|
106392
106522
|
|
|
106393
106523
|
Examples of good tasks:
|
|
106394
|
-
- "
|
|
106395
|
-
- "
|
|
106396
|
-
- "
|
|
106524
|
+
- "Read vulnerable login handler and related DB helpers"
|
|
106525
|
+
- "Apply parameterized query fix in src/auth/login.ts"
|
|
106526
|
+
- "Run lint, typecheck, and unit tests"
|
|
106527
|
+
- "Test /api/users id parameter for error-based SQL injection"`,
|
|
106397
106528
|
inputSchema: createTaskInputSchema,
|
|
106398
106529
|
execute: async ({
|
|
106399
106530
|
subject,
|
|
@@ -106412,8 +106543,8 @@ Examples of good tasks:
|
|
|
106412
106543
|
const task = createTask(ctx.tasksDir, {
|
|
106413
106544
|
subject,
|
|
106414
106545
|
description,
|
|
106415
|
-
objective,
|
|
106416
|
-
technique,
|
|
106546
|
+
objective: objective ?? subject,
|
|
106547
|
+
technique: technique ?? "general",
|
|
106417
106548
|
metadata
|
|
106418
106549
|
});
|
|
106419
106550
|
ctx.traceWriter?.appendTaskRecord({
|
|
@@ -106613,7 +106744,7 @@ IMPORTANT: Pass protectedEndpoints in authHints when you've discovered 401/403 e
|
|
|
106613
106744
|
if (credentials) {
|
|
106614
106745
|
ctx.session.credentialManager.addFromAuthCredentials(credentials);
|
|
106615
106746
|
}
|
|
106616
|
-
const { runAuthenticationAgent } = await import("./authentication-
|
|
106747
|
+
const { runAuthenticationAgent } = await import("./authentication-cx4fr1jm.js");
|
|
106617
106748
|
const localBus = new AgentEventBus;
|
|
106618
106749
|
AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
|
|
106619
106750
|
const result = await runAuthenticationAgent({
|
|
@@ -107404,7 +107535,7 @@ async function generateThreatModelForEndpoint(ctx, input) {
|
|
|
107404
107535
|
return threatModelLimiter(async () => {
|
|
107405
107536
|
if (ctx.abortSignal?.aborted)
|
|
107406
107537
|
return null;
|
|
107407
|
-
const { CodeAgent } = await import("./agent-
|
|
107538
|
+
const { CodeAgent } = await import("./agent-65jzj95h.js");
|
|
107408
107539
|
const subagentId = newSessionId();
|
|
107409
107540
|
const subagentName = `Threat Model: ${input.routePath}`;
|
|
107410
107541
|
ctx.eventBus?.emit("subagent-spawn", {
|
|
@@ -109327,7 +109458,7 @@ init_lazyLogger();
|
|
|
109327
109458
|
var log6 = scopedLogger(() => createLogger("FindingJudge"));
|
|
109328
109459
|
async function judgeFinding(input, ctx) {
|
|
109329
109460
|
try {
|
|
109330
|
-
const { FindingJudgeAgent } = await import("./agent-
|
|
109461
|
+
const { FindingJudgeAgent } = await import("./agent-00rjnxth.js");
|
|
109331
109462
|
const agent = new FindingJudgeAgent({
|
|
109332
109463
|
finding: input,
|
|
109333
109464
|
model: ctx.model,
|
|
@@ -112327,6 +112458,8 @@ function createEmailAdapter(inbox) {
|
|
|
112327
112458
|
return new OutlookAdapter(inbox.accessToken, inbox.refreshToken, inbox.clientId, inbox.clientSecret);
|
|
112328
112459
|
case "imap":
|
|
112329
112460
|
return new ImapAdapter(inbox);
|
|
112461
|
+
case "http":
|
|
112462
|
+
return new HttpAdapter(inbox);
|
|
112330
112463
|
default:
|
|
112331
112464
|
throw new Error(`Unsupported email provider: ${inbox.provider}`);
|
|
112332
112465
|
}
|
|
@@ -112942,6 +113075,65 @@ function truncate(s, max) {
|
|
|
112942
113075
|
(truncated)` : s;
|
|
112943
113076
|
}
|
|
112944
113077
|
|
|
113078
|
+
class HttpAdapter {
|
|
113079
|
+
endpoint;
|
|
113080
|
+
token;
|
|
113081
|
+
address;
|
|
113082
|
+
constructor(inbox) {
|
|
113083
|
+
this.endpoint = inbox.endpoint.replace(/\/+$/, "");
|
|
113084
|
+
this.token = inbox.token;
|
|
113085
|
+
this.address = inbox.emailAddress;
|
|
113086
|
+
}
|
|
113087
|
+
async get(path, params) {
|
|
113088
|
+
const url = new URL(`${this.endpoint}${path}`);
|
|
113089
|
+
if (params) {
|
|
113090
|
+
for (const [key, value] of Object.entries(params)) {
|
|
113091
|
+
url.searchParams.set(key, value);
|
|
113092
|
+
}
|
|
113093
|
+
}
|
|
113094
|
+
const res = await fetch(url, {
|
|
113095
|
+
headers: { Authorization: `Bearer ${this.token}` }
|
|
113096
|
+
});
|
|
113097
|
+
if (!res.ok) {
|
|
113098
|
+
throw new Error(`Mailbox HTTP error ${res.status} ${res.statusText} for ${path}`);
|
|
113099
|
+
}
|
|
113100
|
+
return await res.json();
|
|
113101
|
+
}
|
|
113102
|
+
async listMessages(opts) {
|
|
113103
|
+
const params = { address: this.address };
|
|
113104
|
+
if (opts.maxResults !== undefined)
|
|
113105
|
+
params.limit = String(opts.maxResults);
|
|
113106
|
+
if (opts.pageToken)
|
|
113107
|
+
params.cursor = opts.pageToken;
|
|
113108
|
+
const data = await this.get("/messages", params);
|
|
113109
|
+
return { messages: data.messages, nextPageToken: data.nextCursor };
|
|
113110
|
+
}
|
|
113111
|
+
async searchMessages(opts) {
|
|
113112
|
+
const params = {
|
|
113113
|
+
address: this.address,
|
|
113114
|
+
q: opts.query
|
|
113115
|
+
};
|
|
113116
|
+
if (opts.maxResults !== undefined)
|
|
113117
|
+
params.limit = String(opts.maxResults);
|
|
113118
|
+
if (opts.pageToken)
|
|
113119
|
+
params.cursor = opts.pageToken;
|
|
113120
|
+
const data = await this.get("/messages", params);
|
|
113121
|
+
return { messages: data.messages, nextPageToken: data.nextCursor };
|
|
113122
|
+
}
|
|
113123
|
+
async getMessage(messageId, _folder) {
|
|
113124
|
+
return this.get(`/messages/${encodeURIComponent(messageId)}`);
|
|
113125
|
+
}
|
|
113126
|
+
async getAttachments(_messageId, _folder) {
|
|
113127
|
+
return [];
|
|
113128
|
+
}
|
|
113129
|
+
async getAttachmentContent(_messageId, _attachmentId, _folder) {
|
|
113130
|
+
throw new Error("Attachments are not supported by the http mailbox provider");
|
|
113131
|
+
}
|
|
113132
|
+
markAsRead(_messageId, _folder) {
|
|
113133
|
+
return Promise.resolve();
|
|
113134
|
+
}
|
|
113135
|
+
}
|
|
113136
|
+
|
|
112945
113137
|
// src/core/agents/offSecAgent/tools/email/getMessage.ts
|
|
112946
113138
|
function emailGetMessage(ctx) {
|
|
112947
113139
|
return tool({
|
|
@@ -115892,7 +116084,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
115892
116084
|
});
|
|
115893
116085
|
if (cwd) {
|
|
115894
116086
|
try {
|
|
115895
|
-
const { WhiteboxAttackSurfaceAgent } = await import("./index-
|
|
116087
|
+
const { WhiteboxAttackSurfaceAgent } = await import("./index-1swzf5ha.js");
|
|
115896
116088
|
const localBus = new AgentEventBus;
|
|
115897
116089
|
AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
|
|
115898
116090
|
const agent = new WhiteboxAttackSurfaceAgent({
|
|
@@ -115947,7 +116139,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
115947
116139
|
}
|
|
115948
116140
|
}
|
|
115949
116141
|
try {
|
|
115950
|
-
const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-
|
|
116142
|
+
const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-t4kd841t.js");
|
|
115951
116143
|
const localBus = new AgentEventBus;
|
|
115952
116144
|
AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
|
|
115953
116145
|
const agent = new BlackboxAttackSurfaceAgent({
|
|
@@ -116025,7 +116217,7 @@ Omit \`cwd\` for blackbox mode (live target probing only).`,
|
|
|
116025
116217
|
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
|
|
116026
116218
|
}),
|
|
116027
116219
|
execute: async ({ target, cwd }) => {
|
|
116028
|
-
const { runPentestWorkflow: workflow } = await import("./pentest-
|
|
116220
|
+
const { runPentestWorkflow: workflow } = await import("./pentest-v886reb6.js");
|
|
116029
116221
|
if (!ctx.model) {
|
|
116030
116222
|
return {
|
|
116031
116223
|
success: false,
|
|
@@ -117603,7 +117795,7 @@ Returns an array of results with the text output from each agent.`,
|
|
|
117603
117795
|
});
|
|
117604
117796
|
}
|
|
117605
117797
|
async function runSingleCodingAgent(ctx, codebasePath, objective, agentIndex, name) {
|
|
117606
|
-
const { CodeAgent } = await import("./agent-
|
|
117798
|
+
const { CodeAgent } = await import("./agent-65jzj95h.js");
|
|
117607
117799
|
const childSessionId = newSessionId();
|
|
117608
117800
|
const subagentId = childSessionId;
|
|
117609
117801
|
ctx.eventBus?.emit("subagent-spawn", {
|
|
@@ -118120,7 +118312,7 @@ Returns the worker's summary, objective results, and finding count — but NOT t
|
|
|
118120
118312
|
message: "spawn_pentest_agent requires a model in the tool context."
|
|
118121
118313
|
};
|
|
118122
118314
|
}
|
|
118123
|
-
const { TargetedPentestAgent } = await import("./agent-
|
|
118315
|
+
const { TargetedPentestAgent } = await import("./agent-q3yvg7qp.js");
|
|
118124
118316
|
const findingsRegistry = ctx.findingsRegistry ?? FindingsRegistry.fromDirectory(ctx.session.findingsPath, {
|
|
118125
118317
|
model: ctx.model,
|
|
118126
118318
|
authConfig: ctx.authConfig,
|
|
@@ -118254,7 +118446,7 @@ Pass every target you want tested — the swarm handles concurrency automaticall
|
|
|
118254
118446
|
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
|
|
118255
118447
|
}),
|
|
118256
118448
|
execute: async ({ targets }) => {
|
|
118257
|
-
const { runPentestSwarm, DEFAULT_CONCURRENCY: DEFAULT_CONCURRENCY2 } = await import("./pentest-
|
|
118449
|
+
const { runPentestSwarm, DEFAULT_CONCURRENCY: DEFAULT_CONCURRENCY2 } = await import("./pentest-v886reb6.js");
|
|
118258
118450
|
if (!ctx.model) {
|
|
118259
118451
|
return {
|
|
118260
118452
|
success: false,
|
|
@@ -118938,6 +119130,3857 @@ Required plan sections:
|
|
|
118938
119130
|
}
|
|
118939
119131
|
});
|
|
118940
119132
|
}
|
|
119133
|
+
// src/core/agents/offSecAgent/tools/applyPatch.ts
|
|
119134
|
+
init_dist();
|
|
119135
|
+
init_zod();
|
|
119136
|
+
import { mkdir as mkdir4, readFile as readFile7, unlink, writeFile as writeFile6 } from "node:fs/promises";
|
|
119137
|
+
import { dirname as dirname7, isAbsolute as isAbsolute7, relative as relative5, resolve as resolve8 } from "node:path";
|
|
119138
|
+
var applyPatchInputSchema = exports_external.object({
|
|
119139
|
+
patch: exports_external.string().describe("Unified diff to apply. May contain one or more file hunks (---/+++/@@). Paths are relative to the agent working directory unless absolute."),
|
|
119140
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Apply parameterized-query fix across auth handlers')")
|
|
119141
|
+
});
|
|
119142
|
+
function stripPrefix(p) {
|
|
119143
|
+
if (p.startsWith("a/") || p.startsWith("b/"))
|
|
119144
|
+
return p.slice(2);
|
|
119145
|
+
return p;
|
|
119146
|
+
}
|
|
119147
|
+
function parseUnifiedDiff(patch) {
|
|
119148
|
+
const lines = patch.replace(/\r\n/g, `
|
|
119149
|
+
`).split(`
|
|
119150
|
+
`);
|
|
119151
|
+
const files = [];
|
|
119152
|
+
let i = 0;
|
|
119153
|
+
while (i < lines.length) {
|
|
119154
|
+
while (i < lines.length && !lines[i].startsWith("--- ") && !lines[i].startsWith("diff --git ")) {
|
|
119155
|
+
i++;
|
|
119156
|
+
}
|
|
119157
|
+
if (i >= lines.length)
|
|
119158
|
+
break;
|
|
119159
|
+
if (lines[i].startsWith("diff --git ")) {
|
|
119160
|
+
i++;
|
|
119161
|
+
continue;
|
|
119162
|
+
}
|
|
119163
|
+
const oldLine = lines[i];
|
|
119164
|
+
if (!oldLine.startsWith("--- ")) {
|
|
119165
|
+
throw new Error(`Expected "---" file header at line ${i + 1}`);
|
|
119166
|
+
}
|
|
119167
|
+
i++;
|
|
119168
|
+
if (i >= lines.length || !lines[i].startsWith("+++ ")) {
|
|
119169
|
+
throw new Error(`Expected "+++" file header after "---" at line ${i}`);
|
|
119170
|
+
}
|
|
119171
|
+
const newLine = lines[i];
|
|
119172
|
+
i++;
|
|
119173
|
+
const oldPathRaw = oldLine.slice(4).split("\t")[0].trim();
|
|
119174
|
+
const newPathRaw = newLine.slice(4).split("\t")[0].trim();
|
|
119175
|
+
const isNew = oldPathRaw === "/dev/null";
|
|
119176
|
+
const isDelete = newPathRaw === "/dev/null";
|
|
119177
|
+
const oldPath = isNew ? "" : stripPrefix(oldPathRaw);
|
|
119178
|
+
const newPath = isDelete ? "" : stripPrefix(newPathRaw);
|
|
119179
|
+
const hunks = [];
|
|
119180
|
+
while (i < lines.length && lines[i].startsWith("@@ ")) {
|
|
119181
|
+
const header = lines[i];
|
|
119182
|
+
const match = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(header);
|
|
119183
|
+
if (!match) {
|
|
119184
|
+
throw new Error(`Malformed hunk header: ${header}`);
|
|
119185
|
+
}
|
|
119186
|
+
i++;
|
|
119187
|
+
const hunkLines = [];
|
|
119188
|
+
while (i < lines.length && !lines[i].startsWith("@@ ") && !lines[i].startsWith("--- ") && !lines[i].startsWith("diff --git ")) {
|
|
119189
|
+
const l = lines[i];
|
|
119190
|
+
if (l.startsWith(" ") || l.startsWith("+") || l.startsWith("-") || l === "\") {
|
|
119191
|
+
hunkLines.push(l);
|
|
119192
|
+
i++;
|
|
119193
|
+
} else if (l === "") {
|
|
119194
|
+
break;
|
|
119195
|
+
} else {
|
|
119196
|
+
throw new Error(`Unexpected line in hunk: ${l}`);
|
|
119197
|
+
}
|
|
119198
|
+
}
|
|
119199
|
+
hunks.push({
|
|
119200
|
+
oldStart: Number(match[1]),
|
|
119201
|
+
oldCount: match[2] !== undefined ? Number(match[2]) : 1,
|
|
119202
|
+
newStart: Number(match[3]),
|
|
119203
|
+
newCount: match[4] !== undefined ? Number(match[4]) : 1,
|
|
119204
|
+
lines: hunkLines
|
|
119205
|
+
});
|
|
119206
|
+
}
|
|
119207
|
+
if (hunks.length === 0 && !isNew && !isDelete) {
|
|
119208
|
+
throw new Error(`No hunks found for file ${newPath || oldPath || "(unknown)"}`);
|
|
119209
|
+
}
|
|
119210
|
+
files.push({ oldPath, newPath, hunks, isNew, isDelete });
|
|
119211
|
+
}
|
|
119212
|
+
if (files.length === 0) {
|
|
119213
|
+
throw new Error("Patch contained no file diffs");
|
|
119214
|
+
}
|
|
119215
|
+
return files;
|
|
119216
|
+
}
|
|
119217
|
+
function resolveUnderCwd(agentCwd, filePath) {
|
|
119218
|
+
const resolved = isAbsolute7(filePath) ? filePath : resolve8(agentCwd, filePath);
|
|
119219
|
+
const rel = relative5(agentCwd, resolved);
|
|
119220
|
+
if (rel.startsWith("..") || isAbsolute7(rel)) {
|
|
119221
|
+
throw new Error(`Path escapes agent working directory: ${filePath}`);
|
|
119222
|
+
}
|
|
119223
|
+
return resolved;
|
|
119224
|
+
}
|
|
119225
|
+
function applyHunksToContent(content, hunks) {
|
|
119226
|
+
const endsWithNewline = content.endsWith(`
|
|
119227
|
+
`);
|
|
119228
|
+
const lines = content === "" ? [] : content.endsWith(`
|
|
119229
|
+
`) ? content.slice(0, -1).split(`
|
|
119230
|
+
`) : content.split(`
|
|
119231
|
+
`);
|
|
119232
|
+
const ordered = [...hunks].sort((a, b) => b.oldStart - a.oldStart);
|
|
119233
|
+
for (const hunk of ordered) {
|
|
119234
|
+
const startIdx = Math.max(0, hunk.oldStart - 1);
|
|
119235
|
+
let cursor = startIdx;
|
|
119236
|
+
const replacement = [];
|
|
119237
|
+
for (const raw of hunk.lines) {
|
|
119238
|
+
if (raw === "\")
|
|
119239
|
+
continue;
|
|
119240
|
+
const tag = raw[0];
|
|
119241
|
+
const text = raw.slice(1);
|
|
119242
|
+
if (tag === " " || tag === "-") {
|
|
119243
|
+
if (cursor >= lines.length || lines[cursor] !== text) {
|
|
119244
|
+
const actual = cursor < lines.length ? lines[cursor] : "<EOF>";
|
|
119245
|
+
throw new Error(`Hunk context mismatch at line ${cursor + 1}: expected ${JSON.stringify(text)}, got ${JSON.stringify(actual)}`);
|
|
119246
|
+
}
|
|
119247
|
+
if (tag === " ") {
|
|
119248
|
+
replacement.push(text);
|
|
119249
|
+
}
|
|
119250
|
+
cursor++;
|
|
119251
|
+
} else if (tag === "+") {
|
|
119252
|
+
replacement.push(text);
|
|
119253
|
+
} else {
|
|
119254
|
+
throw new Error(`Invalid hunk line prefix: ${raw}`);
|
|
119255
|
+
}
|
|
119256
|
+
}
|
|
119257
|
+
const endIdx = cursor;
|
|
119258
|
+
lines.splice(startIdx, endIdx - startIdx, ...replacement);
|
|
119259
|
+
}
|
|
119260
|
+
if (lines.length === 0)
|
|
119261
|
+
return endsWithNewline ? `
|
|
119262
|
+
` : "";
|
|
119263
|
+
return `${lines.join(`
|
|
119264
|
+
`)}
|
|
119265
|
+
`;
|
|
119266
|
+
}
|
|
119267
|
+
async function readLocal(path) {
|
|
119268
|
+
try {
|
|
119269
|
+
return await readFile7(path, "utf-8");
|
|
119270
|
+
} catch {
|
|
119271
|
+
return null;
|
|
119272
|
+
}
|
|
119273
|
+
}
|
|
119274
|
+
async function writeLocal(path, content) {
|
|
119275
|
+
await mkdir4(dirname7(path), { recursive: true });
|
|
119276
|
+
await writeFile6(path, content, "utf-8");
|
|
119277
|
+
}
|
|
119278
|
+
async function readViaSandbox(sandbox, path) {
|
|
119279
|
+
const result = await sandbox.execute(`test -f "${path}" && cat "${path}" | base64 -w 0`);
|
|
119280
|
+
if (!result.success || !result.stdout.trim()) {
|
|
119281
|
+
const exists = await sandbox.execute(`test -f "${path}"`);
|
|
119282
|
+
if (exists.exitCode !== 0)
|
|
119283
|
+
return null;
|
|
119284
|
+
return "";
|
|
119285
|
+
}
|
|
119286
|
+
return Buffer.from(result.stdout.trim(), "base64").toString("utf-8");
|
|
119287
|
+
}
|
|
119288
|
+
async function writeViaSandbox(sandbox, path, content) {
|
|
119289
|
+
const dir = dirname7(path);
|
|
119290
|
+
await sandbox.execute(`mkdir -p "${dir}"`);
|
|
119291
|
+
const b64 = Buffer.from(content).toString("base64");
|
|
119292
|
+
const result = await sandbox.execute(`echo "${b64}" | base64 -d > "${path}"`);
|
|
119293
|
+
if (!result.success) {
|
|
119294
|
+
throw new Error(result.stderr || `Failed to write ${path} in sandbox`);
|
|
119295
|
+
}
|
|
119296
|
+
}
|
|
119297
|
+
async function deleteViaSandbox(sandbox, path) {
|
|
119298
|
+
const result = await sandbox.execute(`rm "${path}"`);
|
|
119299
|
+
if (!result.success) {
|
|
119300
|
+
throw new Error(result.stderr || `Failed to delete ${path} in sandbox`);
|
|
119301
|
+
}
|
|
119302
|
+
}
|
|
119303
|
+
function applyPatch(ctx) {
|
|
119304
|
+
return tool({
|
|
119305
|
+
description: `Apply a unified diff patch to one or more files.
|
|
119306
|
+
|
|
119307
|
+
Use this for multi-hunk or multi-file edits. For a single small string replace,
|
|
119308
|
+
prefer update_file.
|
|
119309
|
+
|
|
119310
|
+
The patch must be a standard unified diff with ---/+++ headers and @@ hunks.
|
|
119311
|
+
Context lines must match the current file contents exactly — the tool fails
|
|
119312
|
+
loudly on mismatch and does not partially apply remaining files after a failure
|
|
119313
|
+
within a file. Paths must stay under the agent working directory.
|
|
119314
|
+
|
|
119315
|
+
Example:
|
|
119316
|
+
\`\`\`
|
|
119317
|
+
--- a/src/auth.ts
|
|
119318
|
+
+++ b/src/auth.ts
|
|
119319
|
+
@@ -10,7 +10,7 @@
|
|
119320
|
+
function login(user, pass) {
|
|
119321
|
+
- query = "SELECT * FROM users WHERE name='" + user + "'"
|
|
119322
|
+
+ query = db.prepare("SELECT * FROM users WHERE name=?")
|
|
119323
|
+
}
|
|
119324
|
+
\`\`\``,
|
|
119325
|
+
inputSchema: applyPatchInputSchema,
|
|
119326
|
+
execute: async ({ patch }) => {
|
|
119327
|
+
let files;
|
|
119328
|
+
try {
|
|
119329
|
+
files = parseUnifiedDiff(patch);
|
|
119330
|
+
} catch (err) {
|
|
119331
|
+
return {
|
|
119332
|
+
success: false,
|
|
119333
|
+
error: err instanceof Error ? err.message : String(err),
|
|
119334
|
+
files: []
|
|
119335
|
+
};
|
|
119336
|
+
}
|
|
119337
|
+
const results = [];
|
|
119338
|
+
for (const file of files) {
|
|
119339
|
+
const displayPath = file.newPath || file.oldPath;
|
|
119340
|
+
try {
|
|
119341
|
+
const targetPath = resolveUnderCwd(ctx.agentCwd, file.isDelete ? file.oldPath : file.newPath || file.oldPath);
|
|
119342
|
+
if (file.isDelete) {
|
|
119343
|
+
if (ctx.sandbox) {
|
|
119344
|
+
await deleteViaSandbox(ctx.sandbox, targetPath);
|
|
119345
|
+
} else {
|
|
119346
|
+
await unlink(targetPath);
|
|
119347
|
+
}
|
|
119348
|
+
results.push({
|
|
119349
|
+
path: displayPath,
|
|
119350
|
+
success: true,
|
|
119351
|
+
hunksApplied: 0
|
|
119352
|
+
});
|
|
119353
|
+
continue;
|
|
119354
|
+
}
|
|
119355
|
+
const existing = ctx.sandbox ? await readViaSandbox(ctx.sandbox, targetPath) : await readLocal(targetPath);
|
|
119356
|
+
if (file.isNew) {
|
|
119357
|
+
if (existing !== null) {
|
|
119358
|
+
throw new Error(`Cannot create ${targetPath}: file already exists`);
|
|
119359
|
+
}
|
|
119360
|
+
const created = applyHunksToContent("", file.hunks);
|
|
119361
|
+
if (ctx.sandbox) {
|
|
119362
|
+
await writeViaSandbox(ctx.sandbox, targetPath, created);
|
|
119363
|
+
} else {
|
|
119364
|
+
await writeLocal(targetPath, created);
|
|
119365
|
+
}
|
|
119366
|
+
results.push({
|
|
119367
|
+
path: displayPath,
|
|
119368
|
+
success: true,
|
|
119369
|
+
hunksApplied: file.hunks.length
|
|
119370
|
+
});
|
|
119371
|
+
continue;
|
|
119372
|
+
}
|
|
119373
|
+
if (existing === null) {
|
|
119374
|
+
throw new Error(`File not found: ${targetPath}`);
|
|
119375
|
+
}
|
|
119376
|
+
const updated = applyHunksToContent(existing, file.hunks);
|
|
119377
|
+
if (ctx.sandbox) {
|
|
119378
|
+
await writeViaSandbox(ctx.sandbox, targetPath, updated);
|
|
119379
|
+
} else {
|
|
119380
|
+
await writeLocal(targetPath, updated);
|
|
119381
|
+
}
|
|
119382
|
+
results.push({
|
|
119383
|
+
path: displayPath,
|
|
119384
|
+
success: true,
|
|
119385
|
+
hunksApplied: file.hunks.length
|
|
119386
|
+
});
|
|
119387
|
+
} catch (err) {
|
|
119388
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
119389
|
+
results.push({
|
|
119390
|
+
path: displayPath,
|
|
119391
|
+
success: false,
|
|
119392
|
+
error: message
|
|
119393
|
+
});
|
|
119394
|
+
return {
|
|
119395
|
+
success: false,
|
|
119396
|
+
error: `Failed applying patch to ${displayPath}: ${message}`,
|
|
119397
|
+
files: results
|
|
119398
|
+
};
|
|
119399
|
+
}
|
|
119400
|
+
}
|
|
119401
|
+
return {
|
|
119402
|
+
success: true,
|
|
119403
|
+
error: "",
|
|
119404
|
+
files: results
|
|
119405
|
+
};
|
|
119406
|
+
}
|
|
119407
|
+
});
|
|
119408
|
+
}
|
|
119409
|
+
// src/core/agents/offSecAgent/tools/deleteFile.ts
|
|
119410
|
+
init_dist();
|
|
119411
|
+
init_zod();
|
|
119412
|
+
import { unlink as unlink2 } from "node:fs/promises";
|
|
119413
|
+
import { isAbsolute as isAbsolute8, relative as relative6, resolve as resolve9 } from "node:path";
|
|
119414
|
+
var deleteFileInputSchema = exports_external.object({
|
|
119415
|
+
path: exports_external.string().describe("Absolute or relative path to the file to delete"),
|
|
119416
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Remove obsolete insecure helper')")
|
|
119417
|
+
});
|
|
119418
|
+
function resolveUnderCwd2(agentCwd, filePath) {
|
|
119419
|
+
const resolved = isAbsolute8(filePath) ? filePath : resolve9(agentCwd, filePath);
|
|
119420
|
+
const rel = relative6(agentCwd, resolved);
|
|
119421
|
+
if (rel.startsWith("..") || isAbsolute8(rel)) {
|
|
119422
|
+
throw new Error(`Path escapes agent working directory: ${filePath}`);
|
|
119423
|
+
}
|
|
119424
|
+
return resolved;
|
|
119425
|
+
}
|
|
119426
|
+
function deleteFile(ctx) {
|
|
119427
|
+
return tool({
|
|
119428
|
+
description: `Delete a file from the filesystem.
|
|
119429
|
+
|
|
119430
|
+
Only deletes files (not directories). Path must stay within the agent working directory.
|
|
119431
|
+
Fails loudly if the file does not exist.`,
|
|
119432
|
+
inputSchema: deleteFileInputSchema,
|
|
119433
|
+
execute: async ({ path: filePath }) => {
|
|
119434
|
+
let target;
|
|
119435
|
+
try {
|
|
119436
|
+
target = resolveUnderCwd2(ctx.agentCwd, filePath);
|
|
119437
|
+
} catch (err) {
|
|
119438
|
+
return {
|
|
119439
|
+
success: false,
|
|
119440
|
+
error: err instanceof Error ? err.message : String(err),
|
|
119441
|
+
path: filePath
|
|
119442
|
+
};
|
|
119443
|
+
}
|
|
119444
|
+
if (ctx.sandbox) {
|
|
119445
|
+
try {
|
|
119446
|
+
const check = await ctx.sandbox.execute(`test -f "${target}"`);
|
|
119447
|
+
if (check.exitCode !== 0) {
|
|
119448
|
+
return {
|
|
119449
|
+
success: false,
|
|
119450
|
+
error: `File not found: ${target}`,
|
|
119451
|
+
path: target
|
|
119452
|
+
};
|
|
119453
|
+
}
|
|
119454
|
+
const result = await ctx.sandbox.execute(`rm "${target}"`);
|
|
119455
|
+
if (!result.success) {
|
|
119456
|
+
return {
|
|
119457
|
+
success: false,
|
|
119458
|
+
error: result.stderr || "Failed to delete file in sandbox",
|
|
119459
|
+
path: target
|
|
119460
|
+
};
|
|
119461
|
+
}
|
|
119462
|
+
return { success: true, error: "", path: target };
|
|
119463
|
+
} catch (err) {
|
|
119464
|
+
return {
|
|
119465
|
+
success: false,
|
|
119466
|
+
error: err instanceof Error ? err.message : String(err),
|
|
119467
|
+
path: target
|
|
119468
|
+
};
|
|
119469
|
+
}
|
|
119470
|
+
}
|
|
119471
|
+
try {
|
|
119472
|
+
await unlink2(target);
|
|
119473
|
+
return { success: true, error: "", path: target };
|
|
119474
|
+
} catch (err) {
|
|
119475
|
+
return {
|
|
119476
|
+
success: false,
|
|
119477
|
+
error: err instanceof Error ? err.message : String(err),
|
|
119478
|
+
path: target
|
|
119479
|
+
};
|
|
119480
|
+
}
|
|
119481
|
+
}
|
|
119482
|
+
});
|
|
119483
|
+
}
|
|
119484
|
+
// src/core/agents/offSecAgent/tools/gitDiff.ts
|
|
119485
|
+
init_dist();
|
|
119486
|
+
init_zod();
|
|
119487
|
+
|
|
119488
|
+
// src/core/agents/offSecAgent/tools/gitStatus.ts
|
|
119489
|
+
init_dist();
|
|
119490
|
+
init_zod();
|
|
119491
|
+
var gitStatusInputSchema = exports_external.object({
|
|
119492
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Check which files were modified')")
|
|
119493
|
+
});
|
|
119494
|
+
async function runGit2(ctx, args) {
|
|
119495
|
+
const command = `git ${args.map((a) => `'${a.replace(/'/g, `'\\''`)}'`).join(" ")}`;
|
|
119496
|
+
const full = `cd "${ctx.agentCwd}" && ${command}`;
|
|
119497
|
+
if (ctx.sandbox) {
|
|
119498
|
+
const result = await ctx.sandbox.execute(full, { timeout: 30 });
|
|
119499
|
+
return {
|
|
119500
|
+
success: result.success,
|
|
119501
|
+
stdout: result.stdout,
|
|
119502
|
+
stderr: result.stderr
|
|
119503
|
+
};
|
|
119504
|
+
}
|
|
119505
|
+
if (ctx.persistentShell) {
|
|
119506
|
+
const result = await ctx.persistentShell.execute(full, 30, undefined, ctx.abortSignal);
|
|
119507
|
+
return {
|
|
119508
|
+
success: result.exitCode === 0,
|
|
119509
|
+
stdout: result.stdout,
|
|
119510
|
+
stderr: result.stderr
|
|
119511
|
+
};
|
|
119512
|
+
}
|
|
119513
|
+
return {
|
|
119514
|
+
success: false,
|
|
119515
|
+
stdout: "",
|
|
119516
|
+
stderr: "No shell or sandbox available"
|
|
119517
|
+
};
|
|
119518
|
+
}
|
|
119519
|
+
function gitStatus(ctx) {
|
|
119520
|
+
return tool({
|
|
119521
|
+
description: `Show git working-tree status (porcelain) for the agent repository.
|
|
119522
|
+
|
|
119523
|
+
Use this to self-check which files you changed before finalizing.
|
|
119524
|
+
Does not commit, stage, push, or open a PR.`,
|
|
119525
|
+
inputSchema: gitStatusInputSchema,
|
|
119526
|
+
execute: async () => {
|
|
119527
|
+
const result = await runGit2(ctx, ["status", "--porcelain"]);
|
|
119528
|
+
if (!result.success) {
|
|
119529
|
+
return {
|
|
119530
|
+
success: false,
|
|
119531
|
+
error: result.stderr || "git status failed",
|
|
119532
|
+
status: result.stdout,
|
|
119533
|
+
cwd: ctx.agentCwd
|
|
119534
|
+
};
|
|
119535
|
+
}
|
|
119536
|
+
return {
|
|
119537
|
+
success: true,
|
|
119538
|
+
error: "",
|
|
119539
|
+
status: result.stdout.trim() || "(clean)",
|
|
119540
|
+
cwd: ctx.agentCwd
|
|
119541
|
+
};
|
|
119542
|
+
}
|
|
119543
|
+
});
|
|
119544
|
+
}
|
|
119545
|
+
|
|
119546
|
+
// src/core/agents/offSecAgent/tools/gitDiff.ts
|
|
119547
|
+
var gitDiffInputSchema = exports_external.object({
|
|
119548
|
+
path: exports_external.string().optional().describe("Optional path to limit the diff to a single file or directory"),
|
|
119549
|
+
staged: exports_external.boolean().optional().describe("If true, show staged (--cached) diff. Default: unstaged."),
|
|
119550
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Review unstaged patch before finalize')")
|
|
119551
|
+
});
|
|
119552
|
+
var MAX_DIFF = 1e5;
|
|
119553
|
+
function gitDiff(ctx) {
|
|
119554
|
+
return tool({
|
|
119555
|
+
description: `Show the git diff for the agent repository.
|
|
119556
|
+
|
|
119557
|
+
Defaults to unstaged working-tree changes. Set staged=true for the index.
|
|
119558
|
+
Optionally pass path to limit output to one file/directory.
|
|
119559
|
+
Does not commit, stage, push, or open a PR.`,
|
|
119560
|
+
inputSchema: gitDiffInputSchema,
|
|
119561
|
+
execute: async ({ path, staged = false }) => {
|
|
119562
|
+
const args = ["diff"];
|
|
119563
|
+
if (staged)
|
|
119564
|
+
args.push("--cached");
|
|
119565
|
+
if (path)
|
|
119566
|
+
args.push("--", path);
|
|
119567
|
+
const result = await runGit2(ctx, args);
|
|
119568
|
+
if (!result.success) {
|
|
119569
|
+
return {
|
|
119570
|
+
success: false,
|
|
119571
|
+
error: result.stderr || "git diff failed",
|
|
119572
|
+
diff: result.stdout,
|
|
119573
|
+
cwd: ctx.agentCwd
|
|
119574
|
+
};
|
|
119575
|
+
}
|
|
119576
|
+
const raw = result.stdout;
|
|
119577
|
+
const truncated = raw.length > MAX_DIFF;
|
|
119578
|
+
return {
|
|
119579
|
+
success: true,
|
|
119580
|
+
error: truncated ? `Diff truncated to ${MAX_DIFF} characters — narrow with path` : "",
|
|
119581
|
+
diff: truncated ? `${raw.slice(0, MAX_DIFF)}
|
|
119582
|
+
|
|
119583
|
+
(truncated)` : raw || "(no changes)",
|
|
119584
|
+
cwd: ctx.agentCwd
|
|
119585
|
+
};
|
|
119586
|
+
}
|
|
119587
|
+
});
|
|
119588
|
+
}
|
|
119589
|
+
// src/core/agents/offSecAgent/tools/glob.ts
|
|
119590
|
+
init_dist();
|
|
119591
|
+
import { isAbsolute as isAbsolute9, relative as relative7, resolve as resolve10 } from "node:path";
|
|
119592
|
+
|
|
119593
|
+
// node_modules/glob/dist/esm/index.min.js
|
|
119594
|
+
import { fileURLToPath as Wi } from "node:url";
|
|
119595
|
+
import { posix as mi, win32 as re } from "node:path";
|
|
119596
|
+
import { fileURLToPath as gi } from "node:url";
|
|
119597
|
+
import { lstatSync as wi, readdir as yi, readdirSync as bi, readlinkSync as Si, realpathSync as Ei } from "fs";
|
|
119598
|
+
import * as xi from "node:fs";
|
|
119599
|
+
import { lstat as Ci, readdir as Ti, readlink as Ai, realpath as ki } from "node:fs/promises";
|
|
119600
|
+
import { EventEmitter as ee } from "node:events";
|
|
119601
|
+
import Pe from "node:stream";
|
|
119602
|
+
import { StringDecoder as ni } from "node:string_decoder";
|
|
119603
|
+
var Gt = (n, t, e) => {
|
|
119604
|
+
let s = n instanceof RegExp ? ce(n, e) : n, i = t instanceof RegExp ? ce(t, e) : t, r = s !== null && i != null && ss(s, i, e);
|
|
119605
|
+
return r && { start: r[0], end: r[1], pre: e.slice(0, r[0]), body: e.slice(r[0] + s.length, r[1]), post: e.slice(r[1] + i.length) };
|
|
119606
|
+
};
|
|
119607
|
+
var ce = (n, t) => {
|
|
119608
|
+
let e = t.match(n);
|
|
119609
|
+
return e ? e[0] : null;
|
|
119610
|
+
};
|
|
119611
|
+
var ss = (n, t, e) => {
|
|
119612
|
+
let s, i, r, o, h, a = e.indexOf(n), l = e.indexOf(t, a + 1), u = a;
|
|
119613
|
+
if (a >= 0 && l > 0) {
|
|
119614
|
+
if (n === t)
|
|
119615
|
+
return [a, l];
|
|
119616
|
+
for (s = [], r = e.length;u >= 0 && !h; ) {
|
|
119617
|
+
if (u === a)
|
|
119618
|
+
s.push(u), a = e.indexOf(n, u + 1);
|
|
119619
|
+
else if (s.length === 1) {
|
|
119620
|
+
let c = s.pop();
|
|
119621
|
+
c !== undefined && (h = [c, l]);
|
|
119622
|
+
} else
|
|
119623
|
+
i = s.pop(), i !== undefined && i < r && (r = i, o = l), l = e.indexOf(t, u + 1);
|
|
119624
|
+
u = a < l && a >= 0 ? a : l;
|
|
119625
|
+
}
|
|
119626
|
+
s.length && o !== undefined && (h = [r, o]);
|
|
119627
|
+
}
|
|
119628
|
+
return h;
|
|
119629
|
+
};
|
|
119630
|
+
var fe = "\x00SLASH" + Math.random() + "\x00";
|
|
119631
|
+
var ue = "\x00OPEN" + Math.random() + "\x00";
|
|
119632
|
+
var qt = "\x00CLOSE" + Math.random() + "\x00";
|
|
119633
|
+
var de = "\x00COMMA" + Math.random() + "\x00";
|
|
119634
|
+
var pe = "\x00PERIOD" + Math.random() + "\x00";
|
|
119635
|
+
var is = new RegExp(fe, "g");
|
|
119636
|
+
var rs = new RegExp(ue, "g");
|
|
119637
|
+
var ns = new RegExp(qt, "g");
|
|
119638
|
+
var os = new RegExp(de, "g");
|
|
119639
|
+
var hs = new RegExp(pe, "g");
|
|
119640
|
+
var as = /\\\\/g;
|
|
119641
|
+
var ls = /\\{/g;
|
|
119642
|
+
var cs = /\\}/g;
|
|
119643
|
+
var fs = /\\,/g;
|
|
119644
|
+
var us = /\\./g;
|
|
119645
|
+
var ds = 1e5;
|
|
119646
|
+
function Ht(n) {
|
|
119647
|
+
return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
|
|
119648
|
+
}
|
|
119649
|
+
function ps(n) {
|
|
119650
|
+
return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs, de).replace(us, pe);
|
|
119651
|
+
}
|
|
119652
|
+
function ms(n) {
|
|
119653
|
+
return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os, ",").replace(hs, ".");
|
|
119654
|
+
}
|
|
119655
|
+
function me(n) {
|
|
119656
|
+
if (!n)
|
|
119657
|
+
return [""];
|
|
119658
|
+
let t = [], e = Gt("{", "}", n);
|
|
119659
|
+
if (!e)
|
|
119660
|
+
return n.split(",");
|
|
119661
|
+
let { pre: s, body: i, post: r } = e, o = s.split(",");
|
|
119662
|
+
o[o.length - 1] += "{" + i + "}";
|
|
119663
|
+
let h = me(r);
|
|
119664
|
+
return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
|
|
119665
|
+
}
|
|
119666
|
+
function ge(n, t = {}) {
|
|
119667
|
+
if (!n)
|
|
119668
|
+
return [];
|
|
119669
|
+
let { max: e = ds } = t;
|
|
119670
|
+
return n.slice(0, 2) === "{}" && (n = "\\{\\}" + n.slice(2)), ht(ps(n), e, true).map(ms);
|
|
119671
|
+
}
|
|
119672
|
+
function gs(n) {
|
|
119673
|
+
return "{" + n + "}";
|
|
119674
|
+
}
|
|
119675
|
+
function ws(n) {
|
|
119676
|
+
return /^-?0\d/.test(n);
|
|
119677
|
+
}
|
|
119678
|
+
function ys(n, t) {
|
|
119679
|
+
return n <= t;
|
|
119680
|
+
}
|
|
119681
|
+
function bs(n, t) {
|
|
119682
|
+
return n >= t;
|
|
119683
|
+
}
|
|
119684
|
+
function ht(n, t, e) {
|
|
119685
|
+
let s = [], i = Gt("{", "}", n);
|
|
119686
|
+
if (!i)
|
|
119687
|
+
return [n];
|
|
119688
|
+
let r = i.pre, o = i.post.length ? ht(i.post, t, false) : [""];
|
|
119689
|
+
if (/\$$/.test(i.pre))
|
|
119690
|
+
for (let h = 0;h < o.length && h < t; h++) {
|
|
119691
|
+
let a = r + "{" + i.body + "}" + o[h];
|
|
119692
|
+
s.push(a);
|
|
119693
|
+
}
|
|
119694
|
+
else {
|
|
119695
|
+
let h = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body), l = h || a, u = i.body.indexOf(",") >= 0;
|
|
119696
|
+
if (!l && !u)
|
|
119697
|
+
return i.post.match(/,(?!,).*\}/) ? (n = i.pre + "{" + i.body + qt + i.post, ht(n, t, true)) : [n];
|
|
119698
|
+
let c;
|
|
119699
|
+
if (l)
|
|
119700
|
+
c = i.body.split(/\.\./);
|
|
119701
|
+
else if (c = me(i.body), c.length === 1 && c[0] !== undefined && (c = ht(c[0], t, false).map(gs), c.length === 1))
|
|
119702
|
+
return o.map((f) => i.pre + c[0] + f);
|
|
119703
|
+
let d;
|
|
119704
|
+
if (l && c[0] !== undefined && c[1] !== undefined) {
|
|
119705
|
+
let f = Ht(c[0]), m = Ht(c[1]), p = Math.max(c[0].length, c[1].length), w = c.length === 3 && c[2] !== undefined ? Math.abs(Ht(c[2])) : 1, g = ys;
|
|
119706
|
+
m < f && (w *= -1, g = bs);
|
|
119707
|
+
let E = c.some(ws);
|
|
119708
|
+
d = [];
|
|
119709
|
+
for (let y = f;g(y, m); y += w) {
|
|
119710
|
+
let b;
|
|
119711
|
+
if (a)
|
|
119712
|
+
b = String.fromCharCode(y), b === "\\" && (b = "");
|
|
119713
|
+
else if (b = String(y), E) {
|
|
119714
|
+
let z = p - b.length;
|
|
119715
|
+
if (z > 0) {
|
|
119716
|
+
let $ = new Array(z + 1).join("0");
|
|
119717
|
+
y < 0 ? b = "-" + $ + b.slice(1) : b = $ + b;
|
|
119718
|
+
}
|
|
119719
|
+
}
|
|
119720
|
+
d.push(b);
|
|
119721
|
+
}
|
|
119722
|
+
} else {
|
|
119723
|
+
d = [];
|
|
119724
|
+
for (let f = 0;f < c.length; f++)
|
|
119725
|
+
d.push.apply(d, ht(c[f], t, false));
|
|
119726
|
+
}
|
|
119727
|
+
for (let f = 0;f < d.length; f++)
|
|
119728
|
+
for (let m = 0;m < o.length && s.length < t; m++) {
|
|
119729
|
+
let p = r + d[f] + o[m];
|
|
119730
|
+
(!e || l || p) && s.push(p);
|
|
119731
|
+
}
|
|
119732
|
+
}
|
|
119733
|
+
return s;
|
|
119734
|
+
}
|
|
119735
|
+
var at = (n) => {
|
|
119736
|
+
if (typeof n != "string")
|
|
119737
|
+
throw new TypeError("invalid pattern");
|
|
119738
|
+
if (n.length > 65536)
|
|
119739
|
+
throw new TypeError("pattern is too long");
|
|
119740
|
+
};
|
|
119741
|
+
var Ss = { "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true], "[:alpha:]": ["\\p{L}\\p{Nl}", true], "[:ascii:]": ["\\x00-\\x7f", false], "[:blank:]": ["\\p{Zs}\\t", true], "[:cntrl:]": ["\\p{Cc}", true], "[:digit:]": ["\\p{Nd}", true], "[:graph:]": ["\\p{Z}\\p{C}", true, true], "[:lower:]": ["\\p{Ll}", true], "[:print:]": ["\\p{C}", true], "[:punct:]": ["\\p{P}", true], "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true], "[:upper:]": ["\\p{Lu}", true], "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true], "[:xdigit:]": ["A-Fa-f0-9", false] };
|
|
119742
|
+
var lt = (n) => n.replace(/[[\]\\-]/g, "\\$&");
|
|
119743
|
+
var Es = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
119744
|
+
var we = (n) => n.join("");
|
|
119745
|
+
var ye = (n, t) => {
|
|
119746
|
+
let e = t;
|
|
119747
|
+
if (n.charAt(e) !== "[")
|
|
119748
|
+
throw new Error("not in a brace expression");
|
|
119749
|
+
let s = [], i = [], r = e + 1, o = false, h = false, a = false, l = false, u = e, c = "";
|
|
119750
|
+
t:
|
|
119751
|
+
for (;r < n.length; ) {
|
|
119752
|
+
let p = n.charAt(r);
|
|
119753
|
+
if ((p === "!" || p === "^") && r === e + 1) {
|
|
119754
|
+
l = true, r++;
|
|
119755
|
+
continue;
|
|
119756
|
+
}
|
|
119757
|
+
if (p === "]" && o && !a) {
|
|
119758
|
+
u = r + 1;
|
|
119759
|
+
break;
|
|
119760
|
+
}
|
|
119761
|
+
if (o = true, p === "\\" && !a) {
|
|
119762
|
+
a = true, r++;
|
|
119763
|
+
continue;
|
|
119764
|
+
}
|
|
119765
|
+
if (p === "[" && !a) {
|
|
119766
|
+
for (let [w, [g, S, E]] of Object.entries(Ss))
|
|
119767
|
+
if (n.startsWith(w, r)) {
|
|
119768
|
+
if (c)
|
|
119769
|
+
return ["$.", false, n.length - e, true];
|
|
119770
|
+
r += w.length, E ? i.push(g) : s.push(g), h = h || S;
|
|
119771
|
+
continue t;
|
|
119772
|
+
}
|
|
119773
|
+
}
|
|
119774
|
+
if (a = false, c) {
|
|
119775
|
+
p > c ? s.push(lt(c) + "-" + lt(p)) : p === c && s.push(lt(p)), c = "", r++;
|
|
119776
|
+
continue;
|
|
119777
|
+
}
|
|
119778
|
+
if (n.startsWith("-]", r + 1)) {
|
|
119779
|
+
s.push(lt(p + "-")), r += 2;
|
|
119780
|
+
continue;
|
|
119781
|
+
}
|
|
119782
|
+
if (n.startsWith("-", r + 1)) {
|
|
119783
|
+
c = p, r += 2;
|
|
119784
|
+
continue;
|
|
119785
|
+
}
|
|
119786
|
+
s.push(lt(p)), r++;
|
|
119787
|
+
}
|
|
119788
|
+
if (u < r)
|
|
119789
|
+
return ["", false, 0, false];
|
|
119790
|
+
if (!s.length && !i.length)
|
|
119791
|
+
return ["$.", false, n.length - e, true];
|
|
119792
|
+
if (i.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !l) {
|
|
119793
|
+
let p = s[0].length === 2 ? s[0].slice(-1) : s[0];
|
|
119794
|
+
return [Es(p), false, u - e, false];
|
|
119795
|
+
}
|
|
119796
|
+
let d = "[" + (l ? "^" : "") + we(s) + "]", f = "[" + (l ? "" : "^") + we(i) + "]";
|
|
119797
|
+
return [s.length && i.length ? "(" + d + "|" + f + ")" : s.length ? d : f, h, u - e, true];
|
|
119798
|
+
};
|
|
119799
|
+
var W = (n, { windowsPathsNoEscape: t = false, magicalBraces: e = true } = {}) => e ? t ? n.replace(/\[([^\/\\])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1") : t ? n.replace(/\[([^\/\\{}])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
|
|
119800
|
+
var xs = new Set(["!", "?", "+", "*", "@"]);
|
|
119801
|
+
var be = (n) => xs.has(n);
|
|
119802
|
+
var vs = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
119803
|
+
var Ct = "(?!\\.)";
|
|
119804
|
+
var Cs = new Set(["[", "."]);
|
|
119805
|
+
var Ts = new Set(["..", "."]);
|
|
119806
|
+
var As = new Set("().*{}+?[]^$\\!");
|
|
119807
|
+
var ks = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
119808
|
+
var Kt = "[^/]";
|
|
119809
|
+
var Se = Kt + "*?";
|
|
119810
|
+
var Ee = Kt + "+?";
|
|
119811
|
+
var Q = class n {
|
|
119812
|
+
type;
|
|
119813
|
+
#t;
|
|
119814
|
+
#s;
|
|
119815
|
+
#n = false;
|
|
119816
|
+
#r = [];
|
|
119817
|
+
#o;
|
|
119818
|
+
#S;
|
|
119819
|
+
#w;
|
|
119820
|
+
#c = false;
|
|
119821
|
+
#h;
|
|
119822
|
+
#u;
|
|
119823
|
+
#f = false;
|
|
119824
|
+
constructor(t, e, s = {}) {
|
|
119825
|
+
this.type = t, t && (this.#s = true), this.#o = e, this.#t = this.#o ? this.#o.#t : this, this.#h = this.#t === this ? s : this.#t.#h, this.#w = this.#t === this ? [] : this.#t.#w, t === "!" && !this.#t.#c && this.#w.push(this), this.#S = this.#o ? this.#o.#r.length : 0;
|
|
119826
|
+
}
|
|
119827
|
+
get hasMagic() {
|
|
119828
|
+
if (this.#s !== undefined)
|
|
119829
|
+
return this.#s;
|
|
119830
|
+
for (let t of this.#r)
|
|
119831
|
+
if (typeof t != "string" && (t.type || t.hasMagic))
|
|
119832
|
+
return this.#s = true;
|
|
119833
|
+
return this.#s;
|
|
119834
|
+
}
|
|
119835
|
+
toString() {
|
|
119836
|
+
return this.#u !== undefined ? this.#u : this.type ? this.#u = this.type + "(" + this.#r.map((t) => String(t)).join("|") + ")" : this.#u = this.#r.map((t) => String(t)).join("");
|
|
119837
|
+
}
|
|
119838
|
+
#a() {
|
|
119839
|
+
if (this !== this.#t)
|
|
119840
|
+
throw new Error("should only call on root");
|
|
119841
|
+
if (this.#c)
|
|
119842
|
+
return this;
|
|
119843
|
+
this.toString(), this.#c = true;
|
|
119844
|
+
let t;
|
|
119845
|
+
for (;t = this.#w.pop(); ) {
|
|
119846
|
+
if (t.type !== "!")
|
|
119847
|
+
continue;
|
|
119848
|
+
let e = t, s = e.#o;
|
|
119849
|
+
for (;s; ) {
|
|
119850
|
+
for (let i = e.#S + 1;!s.type && i < s.#r.length; i++)
|
|
119851
|
+
for (let r of t.#r) {
|
|
119852
|
+
if (typeof r == "string")
|
|
119853
|
+
throw new Error("string part in extglob AST??");
|
|
119854
|
+
r.copyIn(s.#r[i]);
|
|
119855
|
+
}
|
|
119856
|
+
e = s, s = e.#o;
|
|
119857
|
+
}
|
|
119858
|
+
}
|
|
119859
|
+
return this;
|
|
119860
|
+
}
|
|
119861
|
+
push(...t) {
|
|
119862
|
+
for (let e of t)
|
|
119863
|
+
if (e !== "") {
|
|
119864
|
+
if (typeof e != "string" && !(e instanceof n && e.#o === this))
|
|
119865
|
+
throw new Error("invalid part: " + e);
|
|
119866
|
+
this.#r.push(e);
|
|
119867
|
+
}
|
|
119868
|
+
}
|
|
119869
|
+
toJSON() {
|
|
119870
|
+
let t = this.type === null ? this.#r.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#r.map((e) => e.toJSON())];
|
|
119871
|
+
return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#t || this.#t.#c && this.#o?.type === "!") && t.push({}), t;
|
|
119872
|
+
}
|
|
119873
|
+
isStart() {
|
|
119874
|
+
if (this.#t === this)
|
|
119875
|
+
return true;
|
|
119876
|
+
if (!this.#o?.isStart())
|
|
119877
|
+
return false;
|
|
119878
|
+
if (this.#S === 0)
|
|
119879
|
+
return true;
|
|
119880
|
+
let t = this.#o;
|
|
119881
|
+
for (let e = 0;e < this.#S; e++) {
|
|
119882
|
+
let s = t.#r[e];
|
|
119883
|
+
if (!(s instanceof n && s.type === "!"))
|
|
119884
|
+
return false;
|
|
119885
|
+
}
|
|
119886
|
+
return true;
|
|
119887
|
+
}
|
|
119888
|
+
isEnd() {
|
|
119889
|
+
if (this.#t === this || this.#o?.type === "!")
|
|
119890
|
+
return true;
|
|
119891
|
+
if (!this.#o?.isEnd())
|
|
119892
|
+
return false;
|
|
119893
|
+
if (!this.type)
|
|
119894
|
+
return this.#o?.isEnd();
|
|
119895
|
+
let t = this.#o ? this.#o.#r.length : 0;
|
|
119896
|
+
return this.#S === t - 1;
|
|
119897
|
+
}
|
|
119898
|
+
copyIn(t) {
|
|
119899
|
+
typeof t == "string" ? this.push(t) : this.push(t.clone(this));
|
|
119900
|
+
}
|
|
119901
|
+
clone(t) {
|
|
119902
|
+
let e = new n(this.type, t);
|
|
119903
|
+
for (let s of this.#r)
|
|
119904
|
+
e.copyIn(s);
|
|
119905
|
+
return e;
|
|
119906
|
+
}
|
|
119907
|
+
static #i(t, e, s, i) {
|
|
119908
|
+
let r = false, o = false, h = -1, a = false;
|
|
119909
|
+
if (e.type === null) {
|
|
119910
|
+
let f = s, m = "";
|
|
119911
|
+
for (;f < t.length; ) {
|
|
119912
|
+
let p = t.charAt(f++);
|
|
119913
|
+
if (r || p === "\\") {
|
|
119914
|
+
r = !r, m += p;
|
|
119915
|
+
continue;
|
|
119916
|
+
}
|
|
119917
|
+
if (o) {
|
|
119918
|
+
f === h + 1 ? (p === "^" || p === "!") && (a = true) : p === "]" && !(f === h + 2 && a) && (o = false), m += p;
|
|
119919
|
+
continue;
|
|
119920
|
+
} else if (p === "[") {
|
|
119921
|
+
o = true, h = f, a = false, m += p;
|
|
119922
|
+
continue;
|
|
119923
|
+
}
|
|
119924
|
+
if (!i.noext && be(p) && t.charAt(f) === "(") {
|
|
119925
|
+
e.push(m), m = "";
|
|
119926
|
+
let w = new n(p, e);
|
|
119927
|
+
f = n.#i(t, w, f, i), e.push(w);
|
|
119928
|
+
continue;
|
|
119929
|
+
}
|
|
119930
|
+
m += p;
|
|
119931
|
+
}
|
|
119932
|
+
return e.push(m), f;
|
|
119933
|
+
}
|
|
119934
|
+
let l = s + 1, u = new n(null, e), c = [], d = "";
|
|
119935
|
+
for (;l < t.length; ) {
|
|
119936
|
+
let f = t.charAt(l++);
|
|
119937
|
+
if (r || f === "\\") {
|
|
119938
|
+
r = !r, d += f;
|
|
119939
|
+
continue;
|
|
119940
|
+
}
|
|
119941
|
+
if (o) {
|
|
119942
|
+
l === h + 1 ? (f === "^" || f === "!") && (a = true) : f === "]" && !(l === h + 2 && a) && (o = false), d += f;
|
|
119943
|
+
continue;
|
|
119944
|
+
} else if (f === "[") {
|
|
119945
|
+
o = true, h = l, a = false, d += f;
|
|
119946
|
+
continue;
|
|
119947
|
+
}
|
|
119948
|
+
if (be(f) && t.charAt(l) === "(") {
|
|
119949
|
+
u.push(d), d = "";
|
|
119950
|
+
let m = new n(f, u);
|
|
119951
|
+
u.push(m), l = n.#i(t, m, l, i);
|
|
119952
|
+
continue;
|
|
119953
|
+
}
|
|
119954
|
+
if (f === "|") {
|
|
119955
|
+
u.push(d), d = "", c.push(u), u = new n(null, e);
|
|
119956
|
+
continue;
|
|
119957
|
+
}
|
|
119958
|
+
if (f === ")")
|
|
119959
|
+
return d === "" && e.#r.length === 0 && (e.#f = true), u.push(d), d = "", e.push(...c, u), l;
|
|
119960
|
+
d += f;
|
|
119961
|
+
}
|
|
119962
|
+
return e.type = null, e.#s = undefined, e.#r = [t.substring(s - 1)], l;
|
|
119963
|
+
}
|
|
119964
|
+
static fromGlob(t, e = {}) {
|
|
119965
|
+
let s = new n(null, undefined, e);
|
|
119966
|
+
return n.#i(t, s, 0, e), s;
|
|
119967
|
+
}
|
|
119968
|
+
toMMPattern() {
|
|
119969
|
+
if (this !== this.#t)
|
|
119970
|
+
return this.#t.toMMPattern();
|
|
119971
|
+
let t = this.toString(), [e, s, i, r] = this.toRegExpSource();
|
|
119972
|
+
if (!(i || this.#s || this.#h.nocase && !this.#h.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
|
|
119973
|
+
return s;
|
|
119974
|
+
let h = (this.#h.nocase ? "i" : "") + (r ? "u" : "");
|
|
119975
|
+
return Object.assign(new RegExp(`^${e}$`, h), { _src: e, _glob: t });
|
|
119976
|
+
}
|
|
119977
|
+
get options() {
|
|
119978
|
+
return this.#h;
|
|
119979
|
+
}
|
|
119980
|
+
toRegExpSource(t) {
|
|
119981
|
+
let e = t ?? !!this.#h.dot;
|
|
119982
|
+
if (this.#t === this && this.#a(), !this.type) {
|
|
119983
|
+
let a = this.isStart() && this.isEnd() && !this.#r.some((f) => typeof f != "string"), l = this.#r.map((f) => {
|
|
119984
|
+
let [m, p, w, g] = typeof f == "string" ? n.#E(f, this.#s, a) : f.toRegExpSource(t);
|
|
119985
|
+
return this.#s = this.#s || w, this.#n = this.#n || g, m;
|
|
119986
|
+
}).join(""), u = "";
|
|
119987
|
+
if (this.isStart() && typeof this.#r[0] == "string" && !(this.#r.length === 1 && Ts.has(this.#r[0]))) {
|
|
119988
|
+
let m = Cs, p = e && m.has(l.charAt(0)) || l.startsWith("\\.") && m.has(l.charAt(2)) || l.startsWith("\\.\\.") && m.has(l.charAt(4)), w = !e && !t && m.has(l.charAt(0));
|
|
119989
|
+
u = p ? vs : w ? Ct : "";
|
|
119990
|
+
}
|
|
119991
|
+
let c = "";
|
|
119992
|
+
return this.isEnd() && this.#t.#c && this.#o?.type === "!" && (c = "(?:$|\\/)"), [u + l + c, W(l), this.#s = !!this.#s, this.#n];
|
|
119993
|
+
}
|
|
119994
|
+
let s = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:", r = this.#d(e);
|
|
119995
|
+
if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
|
|
119996
|
+
let a = this.toString();
|
|
119997
|
+
return this.#r = [a], this.type = null, this.#s = undefined, [a, W(this.toString()), false, false];
|
|
119998
|
+
}
|
|
119999
|
+
let o = !s || t || e || !Ct ? "" : this.#d(true);
|
|
120000
|
+
o === r && (o = ""), o && (r = `(?:${r})(?:${o})*?`);
|
|
120001
|
+
let h = "";
|
|
120002
|
+
if (this.type === "!" && this.#f)
|
|
120003
|
+
h = (this.isStart() && !e ? Ct : "") + Ee;
|
|
120004
|
+
else {
|
|
120005
|
+
let a = this.type === "!" ? "))" + (this.isStart() && !e && !t ? Ct : "") + Se + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
|
|
120006
|
+
h = i + r + a;
|
|
120007
|
+
}
|
|
120008
|
+
return [h, W(r), this.#s = !!this.#s, this.#n];
|
|
120009
|
+
}
|
|
120010
|
+
#d(t) {
|
|
120011
|
+
return this.#r.map((e) => {
|
|
120012
|
+
if (typeof e == "string")
|
|
120013
|
+
throw new Error("string type in extglob ast??");
|
|
120014
|
+
let [s, i, r, o] = e.toRegExpSource(t);
|
|
120015
|
+
return this.#n = this.#n || o, s;
|
|
120016
|
+
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
|
|
120017
|
+
}
|
|
120018
|
+
static #E(t, e, s = false) {
|
|
120019
|
+
let i = false, r = "", o = false, h = false;
|
|
120020
|
+
for (let a = 0;a < t.length; a++) {
|
|
120021
|
+
let l = t.charAt(a);
|
|
120022
|
+
if (i) {
|
|
120023
|
+
i = false, r += (As.has(l) ? "\\" : "") + l;
|
|
120024
|
+
continue;
|
|
120025
|
+
}
|
|
120026
|
+
if (l === "*") {
|
|
120027
|
+
if (h)
|
|
120028
|
+
continue;
|
|
120029
|
+
h = true, r += s && /^[*]+$/.test(t) ? Ee : Se, e = true;
|
|
120030
|
+
continue;
|
|
120031
|
+
} else
|
|
120032
|
+
h = false;
|
|
120033
|
+
if (l === "\\") {
|
|
120034
|
+
a === t.length - 1 ? r += "\\\\" : i = true;
|
|
120035
|
+
continue;
|
|
120036
|
+
}
|
|
120037
|
+
if (l === "[") {
|
|
120038
|
+
let [u, c, d, f] = ye(t, a);
|
|
120039
|
+
if (d) {
|
|
120040
|
+
r += u, o = o || c, a += d - 1, e = e || f;
|
|
120041
|
+
continue;
|
|
120042
|
+
}
|
|
120043
|
+
}
|
|
120044
|
+
if (l === "?") {
|
|
120045
|
+
r += Kt, e = true;
|
|
120046
|
+
continue;
|
|
120047
|
+
}
|
|
120048
|
+
r += ks(l);
|
|
120049
|
+
}
|
|
120050
|
+
return [r, W(t), !!e, o];
|
|
120051
|
+
}
|
|
120052
|
+
};
|
|
120053
|
+
var tt = (n2, { windowsPathsNoEscape: t = false, magicalBraces: e = false } = {}) => e ? t ? n2.replace(/[?*()[\]{}]/g, "[$&]") : n2.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? n2.replace(/[?*()[\]]/g, "[$&]") : n2.replace(/[?*()[\]\\]/g, "\\$&");
|
|
120054
|
+
var O = (n2, t, e = {}) => (at(t), !e.nocomment && t.charAt(0) === "#" ? false : new D(t, e).match(n2));
|
|
120055
|
+
var Rs = /^\*+([^+@!?\*\[\(]*)$/;
|
|
120056
|
+
var Os = (n2) => (t) => !t.startsWith(".") && t.endsWith(n2);
|
|
120057
|
+
var Fs = (n2) => (t) => t.endsWith(n2);
|
|
120058
|
+
var Ds = (n2) => (n2 = n2.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n2));
|
|
120059
|
+
var Ms = (n2) => (n2 = n2.toLowerCase(), (t) => t.toLowerCase().endsWith(n2));
|
|
120060
|
+
var Ns = /^\*+\.\*+$/;
|
|
120061
|
+
var _s = (n2) => !n2.startsWith(".") && n2.includes(".");
|
|
120062
|
+
var Ls = (n2) => n2 !== "." && n2 !== ".." && n2.includes(".");
|
|
120063
|
+
var Ws = /^\.\*+$/;
|
|
120064
|
+
var Ps = (n2) => n2 !== "." && n2 !== ".." && n2.startsWith(".");
|
|
120065
|
+
var js = /^\*+$/;
|
|
120066
|
+
var Is = (n2) => n2.length !== 0 && !n2.startsWith(".");
|
|
120067
|
+
var zs = (n2) => n2.length !== 0 && n2 !== "." && n2 !== "..";
|
|
120068
|
+
var Bs = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
120069
|
+
var Us = ([n2, t = ""]) => {
|
|
120070
|
+
let e = Ce([n2]);
|
|
120071
|
+
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
|
|
120072
|
+
};
|
|
120073
|
+
var $s = ([n2, t = ""]) => {
|
|
120074
|
+
let e = Te([n2]);
|
|
120075
|
+
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
|
|
120076
|
+
};
|
|
120077
|
+
var Gs = ([n2, t = ""]) => {
|
|
120078
|
+
let e = Te([n2]);
|
|
120079
|
+
return t ? (s) => e(s) && s.endsWith(t) : e;
|
|
120080
|
+
};
|
|
120081
|
+
var Hs = ([n2, t = ""]) => {
|
|
120082
|
+
let e = Ce([n2]);
|
|
120083
|
+
return t ? (s) => e(s) && s.endsWith(t) : e;
|
|
120084
|
+
};
|
|
120085
|
+
var Ce = ([n2]) => {
|
|
120086
|
+
let t = n2.length;
|
|
120087
|
+
return (e) => e.length === t && !e.startsWith(".");
|
|
120088
|
+
};
|
|
120089
|
+
var Te = ([n2]) => {
|
|
120090
|
+
let t = n2.length;
|
|
120091
|
+
return (e) => e.length === t && e !== "." && e !== "..";
|
|
120092
|
+
};
|
|
120093
|
+
var Ae = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
120094
|
+
var xe = { win32: { sep: "\\" }, posix: { sep: "/" } };
|
|
120095
|
+
var qs = Ae === "win32" ? xe.win32.sep : xe.posix.sep;
|
|
120096
|
+
O.sep = qs;
|
|
120097
|
+
var A = Symbol("globstar **");
|
|
120098
|
+
O.GLOBSTAR = A;
|
|
120099
|
+
var Ks = "[^/]";
|
|
120100
|
+
var Vs = Ks + "*?";
|
|
120101
|
+
var Ys = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
120102
|
+
var Xs = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
120103
|
+
var Js = (n2, t = {}) => (e) => O(e, n2, t);
|
|
120104
|
+
O.filter = Js;
|
|
120105
|
+
var N = (n2, t = {}) => Object.assign({}, n2, t);
|
|
120106
|
+
var Zs = (n2) => {
|
|
120107
|
+
if (!n2 || typeof n2 != "object" || !Object.keys(n2).length)
|
|
120108
|
+
return O;
|
|
120109
|
+
let t = O;
|
|
120110
|
+
return Object.assign((s, i, r = {}) => t(s, i, N(n2, r)), { Minimatch: class extends t.Minimatch {
|
|
120111
|
+
constructor(i, r = {}) {
|
|
120112
|
+
super(i, N(n2, r));
|
|
120113
|
+
}
|
|
120114
|
+
static defaults(i) {
|
|
120115
|
+
return t.defaults(N(n2, i)).Minimatch;
|
|
120116
|
+
}
|
|
120117
|
+
}, AST: class extends t.AST {
|
|
120118
|
+
constructor(i, r, o = {}) {
|
|
120119
|
+
super(i, r, N(n2, o));
|
|
120120
|
+
}
|
|
120121
|
+
static fromGlob(i, r = {}) {
|
|
120122
|
+
return t.AST.fromGlob(i, N(n2, r));
|
|
120123
|
+
}
|
|
120124
|
+
}, unescape: (s, i = {}) => t.unescape(s, N(n2, i)), escape: (s, i = {}) => t.escape(s, N(n2, i)), filter: (s, i = {}) => t.filter(s, N(n2, i)), defaults: (s) => t.defaults(N(n2, s)), makeRe: (s, i = {}) => t.makeRe(s, N(n2, i)), braceExpand: (s, i = {}) => t.braceExpand(s, N(n2, i)), match: (s, i, r = {}) => t.match(s, i, N(n2, r)), sep: t.sep, GLOBSTAR: A });
|
|
120125
|
+
};
|
|
120126
|
+
O.defaults = Zs;
|
|
120127
|
+
var ke = (n2, t = {}) => (at(n2), t.nobrace || !/\{(?:(?!\{).)*\}/.test(n2) ? [n2] : ge(n2, { max: t.braceExpandMax }));
|
|
120128
|
+
O.braceExpand = ke;
|
|
120129
|
+
var Qs = (n2, t = {}) => new D(n2, t).makeRe();
|
|
120130
|
+
O.makeRe = Qs;
|
|
120131
|
+
var ti = (n2, t, e = {}) => {
|
|
120132
|
+
let s = new D(t, e);
|
|
120133
|
+
return n2 = n2.filter((i) => s.match(i)), s.options.nonull && !n2.length && n2.push(t), n2;
|
|
120134
|
+
};
|
|
120135
|
+
O.match = ti;
|
|
120136
|
+
var ve = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
120137
|
+
var ei = (n2) => n2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
120138
|
+
var D = class {
|
|
120139
|
+
options;
|
|
120140
|
+
set;
|
|
120141
|
+
pattern;
|
|
120142
|
+
windowsPathsNoEscape;
|
|
120143
|
+
nonegate;
|
|
120144
|
+
negate;
|
|
120145
|
+
comment;
|
|
120146
|
+
empty;
|
|
120147
|
+
preserveMultipleSlashes;
|
|
120148
|
+
partial;
|
|
120149
|
+
globSet;
|
|
120150
|
+
globParts;
|
|
120151
|
+
nocase;
|
|
120152
|
+
isWindows;
|
|
120153
|
+
platform;
|
|
120154
|
+
windowsNoMagicRoot;
|
|
120155
|
+
regexp;
|
|
120156
|
+
constructor(t, e = {}) {
|
|
120157
|
+
at(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ae, this.isWindows = this.platform === "win32";
|
|
120158
|
+
let s = "allowWindowsEscape";
|
|
120159
|
+
this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === false, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = false, this.nonegate = !!e.nonegate, this.comment = false, this.empty = false, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== undefined ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
120160
|
+
}
|
|
120161
|
+
hasMagic() {
|
|
120162
|
+
if (this.options.magicalBraces && this.set.length > 1)
|
|
120163
|
+
return true;
|
|
120164
|
+
for (let t of this.set)
|
|
120165
|
+
for (let e of t)
|
|
120166
|
+
if (typeof e != "string")
|
|
120167
|
+
return true;
|
|
120168
|
+
return false;
|
|
120169
|
+
}
|
|
120170
|
+
debug(...t) {}
|
|
120171
|
+
make() {
|
|
120172
|
+
let t = this.pattern, e = this.options;
|
|
120173
|
+
if (!e.nocomment && t.charAt(0) === "#") {
|
|
120174
|
+
this.comment = true;
|
|
120175
|
+
return;
|
|
120176
|
+
}
|
|
120177
|
+
if (!t) {
|
|
120178
|
+
this.empty = true;
|
|
120179
|
+
return;
|
|
120180
|
+
}
|
|
120181
|
+
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
|
|
120182
|
+
let s = this.globSet.map((r) => this.slashSplit(r));
|
|
120183
|
+
this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
|
|
120184
|
+
let i = this.globParts.map((r, o, h) => {
|
|
120185
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
120186
|
+
let a = r[0] === "" && r[1] === "" && (r[2] === "?" || !ve.test(r[2])) && !ve.test(r[3]), l = /^[a-z]:/i.test(r[0]);
|
|
120187
|
+
if (a)
|
|
120188
|
+
return [...r.slice(0, 4), ...r.slice(4).map((u) => this.parse(u))];
|
|
120189
|
+
if (l)
|
|
120190
|
+
return [r[0], ...r.slice(1).map((u) => this.parse(u))];
|
|
120191
|
+
}
|
|
120192
|
+
return r.map((a) => this.parse(a));
|
|
120193
|
+
});
|
|
120194
|
+
if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(false) === -1), this.isWindows)
|
|
120195
|
+
for (let r = 0;r < this.set.length; r++) {
|
|
120196
|
+
let o = this.set[r];
|
|
120197
|
+
o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
|
|
120198
|
+
}
|
|
120199
|
+
this.debug(this.pattern, this.set);
|
|
120200
|
+
}
|
|
120201
|
+
preprocess(t) {
|
|
120202
|
+
if (this.options.noglobstar)
|
|
120203
|
+
for (let s = 0;s < t.length; s++)
|
|
120204
|
+
for (let i = 0;i < t[s].length; i++)
|
|
120205
|
+
t[s][i] === "**" && (t[s][i] = "*");
|
|
120206
|
+
let { optimizationLevel: e = 1 } = this.options;
|
|
120207
|
+
return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
|
|
120208
|
+
}
|
|
120209
|
+
adjascentGlobstarOptimize(t) {
|
|
120210
|
+
return t.map((e) => {
|
|
120211
|
+
let s = -1;
|
|
120212
|
+
for (;(s = e.indexOf("**", s + 1)) !== -1; ) {
|
|
120213
|
+
let i = s;
|
|
120214
|
+
for (;e[i + 1] === "**"; )
|
|
120215
|
+
i++;
|
|
120216
|
+
i !== s && e.splice(s, i - s);
|
|
120217
|
+
}
|
|
120218
|
+
return e;
|
|
120219
|
+
});
|
|
120220
|
+
}
|
|
120221
|
+
levelOneOptimize(t) {
|
|
120222
|
+
return t.map((e) => (e = e.reduce((s, i) => {
|
|
120223
|
+
let r = s[s.length - 1];
|
|
120224
|
+
return i === "**" && r === "**" ? s : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (s.pop(), s) : (s.push(i), s);
|
|
120225
|
+
}, []), e.length === 0 ? [""] : e));
|
|
120226
|
+
}
|
|
120227
|
+
levelTwoFileOptimize(t) {
|
|
120228
|
+
Array.isArray(t) || (t = this.slashSplit(t));
|
|
120229
|
+
let e = false;
|
|
120230
|
+
do {
|
|
120231
|
+
if (e = false, !this.preserveMultipleSlashes) {
|
|
120232
|
+
for (let i = 1;i < t.length - 1; i++) {
|
|
120233
|
+
let r = t[i];
|
|
120234
|
+
i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = true, t.splice(i, 1), i--);
|
|
120235
|
+
}
|
|
120236
|
+
t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = true, t.pop());
|
|
120237
|
+
}
|
|
120238
|
+
let s = 0;
|
|
120239
|
+
for (;(s = t.indexOf("..", s + 1)) !== -1; ) {
|
|
120240
|
+
let i = t[s - 1];
|
|
120241
|
+
i && i !== "." && i !== ".." && i !== "**" && (e = true, t.splice(s - 1, 2), s -= 2);
|
|
120242
|
+
}
|
|
120243
|
+
} while (e);
|
|
120244
|
+
return t.length === 0 ? [""] : t;
|
|
120245
|
+
}
|
|
120246
|
+
firstPhasePreProcess(t) {
|
|
120247
|
+
let e = false;
|
|
120248
|
+
do {
|
|
120249
|
+
e = false;
|
|
120250
|
+
for (let s of t) {
|
|
120251
|
+
let i = -1;
|
|
120252
|
+
for (;(i = s.indexOf("**", i + 1)) !== -1; ) {
|
|
120253
|
+
let o = i;
|
|
120254
|
+
for (;s[o + 1] === "**"; )
|
|
120255
|
+
o++;
|
|
120256
|
+
o > i && s.splice(i + 1, o - i);
|
|
120257
|
+
let h = s[i + 1], a = s[i + 2], l = s[i + 3];
|
|
120258
|
+
if (h !== ".." || !a || a === "." || a === ".." || !l || l === "." || l === "..")
|
|
120259
|
+
continue;
|
|
120260
|
+
e = true, s.splice(i, 1);
|
|
120261
|
+
let u = s.slice(0);
|
|
120262
|
+
u[i] = "**", t.push(u), i--;
|
|
120263
|
+
}
|
|
120264
|
+
if (!this.preserveMultipleSlashes) {
|
|
120265
|
+
for (let o = 1;o < s.length - 1; o++) {
|
|
120266
|
+
let h = s[o];
|
|
120267
|
+
o === 1 && h === "" && s[0] === "" || (h === "." || h === "") && (e = true, s.splice(o, 1), o--);
|
|
120268
|
+
}
|
|
120269
|
+
s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = true, s.pop());
|
|
120270
|
+
}
|
|
120271
|
+
let r = 0;
|
|
120272
|
+
for (;(r = s.indexOf("..", r + 1)) !== -1; ) {
|
|
120273
|
+
let o = s[r - 1];
|
|
120274
|
+
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
120275
|
+
e = true;
|
|
120276
|
+
let a = r === 1 && s[r + 1] === "**" ? ["."] : [];
|
|
120277
|
+
s.splice(r - 1, 2, ...a), s.length === 0 && s.push(""), r -= 2;
|
|
120278
|
+
}
|
|
120279
|
+
}
|
|
120280
|
+
}
|
|
120281
|
+
} while (e);
|
|
120282
|
+
return t;
|
|
120283
|
+
}
|
|
120284
|
+
secondPhasePreProcess(t) {
|
|
120285
|
+
for (let e = 0;e < t.length - 1; e++)
|
|
120286
|
+
for (let s = e + 1;s < t.length; s++) {
|
|
120287
|
+
let i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
|
|
120288
|
+
if (i) {
|
|
120289
|
+
t[e] = [], t[s] = i;
|
|
120290
|
+
break;
|
|
120291
|
+
}
|
|
120292
|
+
}
|
|
120293
|
+
return t.filter((e) => e.length);
|
|
120294
|
+
}
|
|
120295
|
+
partsMatch(t, e, s = false) {
|
|
120296
|
+
let i = 0, r = 0, o = [], h = "";
|
|
120297
|
+
for (;i < t.length && r < e.length; )
|
|
120298
|
+
if (t[i] === e[r])
|
|
120299
|
+
o.push(h === "b" ? e[r] : t[i]), i++, r++;
|
|
120300
|
+
else if (s && t[i] === "**" && e[r] === t[i + 1])
|
|
120301
|
+
o.push(t[i]), i++;
|
|
120302
|
+
else if (s && e[r] === "**" && t[i] === e[r + 1])
|
|
120303
|
+
o.push(e[r]), r++;
|
|
120304
|
+
else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
|
|
120305
|
+
if (h === "b")
|
|
120306
|
+
return false;
|
|
120307
|
+
h = "a", o.push(t[i]), i++, r++;
|
|
120308
|
+
} else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
|
|
120309
|
+
if (h === "a")
|
|
120310
|
+
return false;
|
|
120311
|
+
h = "b", o.push(e[r]), i++, r++;
|
|
120312
|
+
} else
|
|
120313
|
+
return false;
|
|
120314
|
+
return t.length === e.length && o;
|
|
120315
|
+
}
|
|
120316
|
+
parseNegate() {
|
|
120317
|
+
if (this.nonegate)
|
|
120318
|
+
return;
|
|
120319
|
+
let t = this.pattern, e = false, s = 0;
|
|
120320
|
+
for (let i = 0;i < t.length && t.charAt(i) === "!"; i++)
|
|
120321
|
+
e = !e, s++;
|
|
120322
|
+
s && (this.pattern = t.slice(s)), this.negate = e;
|
|
120323
|
+
}
|
|
120324
|
+
matchOne(t, e, s = false) {
|
|
120325
|
+
let i = this.options;
|
|
120326
|
+
if (this.isWindows) {
|
|
120327
|
+
let p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), w = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), g = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), S = !g && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), E = w ? 3 : p ? 0 : undefined, y = S ? 3 : g ? 0 : undefined;
|
|
120328
|
+
if (typeof E == "number" && typeof y == "number") {
|
|
120329
|
+
let [b, z] = [t[E], e[y]];
|
|
120330
|
+
b.toLowerCase() === z.toLowerCase() && (e[y] = b, y > E ? e = e.slice(y) : E > y && (t = t.slice(E)));
|
|
120331
|
+
}
|
|
120332
|
+
}
|
|
120333
|
+
let { optimizationLevel: r = 1 } = this.options;
|
|
120334
|
+
r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
|
|
120335
|
+
for (var o = 0, h = 0, a = t.length, l = e.length;o < a && h < l; o++, h++) {
|
|
120336
|
+
this.debug("matchOne loop");
|
|
120337
|
+
var u = e[h], c = t[o];
|
|
120338
|
+
if (this.debug(e, u, c), u === false)
|
|
120339
|
+
return false;
|
|
120340
|
+
if (u === A) {
|
|
120341
|
+
this.debug("GLOBSTAR", [e, u, c]);
|
|
120342
|
+
var d = o, f = h + 1;
|
|
120343
|
+
if (f === l) {
|
|
120344
|
+
for (this.debug("** at the end");o < a; o++)
|
|
120345
|
+
if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".")
|
|
120346
|
+
return false;
|
|
120347
|
+
return true;
|
|
120348
|
+
}
|
|
120349
|
+
for (;d < a; ) {
|
|
120350
|
+
var m = t[d];
|
|
120351
|
+
if (this.debug(`
|
|
120352
|
+
globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s))
|
|
120353
|
+
return this.debug("globstar found match!", d, a, m), true;
|
|
120354
|
+
if (m === "." || m === ".." || !i.dot && m.charAt(0) === ".") {
|
|
120355
|
+
this.debug("dot detected!", t, d, e, f);
|
|
120356
|
+
break;
|
|
120357
|
+
}
|
|
120358
|
+
this.debug("globstar swallow a segment, and continue"), d++;
|
|
120359
|
+
}
|
|
120360
|
+
return !!(s && (this.debug(`
|
|
120361
|
+
>>> no match, partial?`, t, d, e, f), d === a));
|
|
120362
|
+
}
|
|
120363
|
+
let p;
|
|
120364
|
+
if (typeof u == "string" ? (p = c === u, this.debug("string match", u, c, p)) : (p = u.test(c), this.debug("pattern match", u, c, p)), !p)
|
|
120365
|
+
return false;
|
|
120366
|
+
}
|
|
120367
|
+
if (o === a && h === l)
|
|
120368
|
+
return true;
|
|
120369
|
+
if (o === a)
|
|
120370
|
+
return s;
|
|
120371
|
+
if (h === l)
|
|
120372
|
+
return o === a - 1 && t[o] === "";
|
|
120373
|
+
throw new Error("wtf?");
|
|
120374
|
+
}
|
|
120375
|
+
braceExpand() {
|
|
120376
|
+
return ke(this.pattern, this.options);
|
|
120377
|
+
}
|
|
120378
|
+
parse(t) {
|
|
120379
|
+
at(t);
|
|
120380
|
+
let e = this.options;
|
|
120381
|
+
if (t === "**")
|
|
120382
|
+
return A;
|
|
120383
|
+
if (t === "")
|
|
120384
|
+
return "";
|
|
120385
|
+
let s, i = null;
|
|
120386
|
+
(s = t.match(js)) ? i = e.dot ? zs : Is : (s = t.match(Rs)) ? i = (e.nocase ? e.dot ? Ms : Ds : e.dot ? Fs : Os)(s[1]) : (s = t.match(Bs)) ? i = (e.nocase ? e.dot ? $s : Us : e.dot ? Gs : Hs)(s) : (s = t.match(Ns)) ? i = e.dot ? Ls : _s : (s = t.match(Ws)) && (i = Ps);
|
|
120387
|
+
let r = Q.fromGlob(t, this.options).toMMPattern();
|
|
120388
|
+
return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
|
|
120389
|
+
}
|
|
120390
|
+
makeRe() {
|
|
120391
|
+
if (this.regexp || this.regexp === false)
|
|
120392
|
+
return this.regexp;
|
|
120393
|
+
let t = this.set;
|
|
120394
|
+
if (!t.length)
|
|
120395
|
+
return this.regexp = false, this.regexp;
|
|
120396
|
+
let e = this.options, s = e.noglobstar ? Vs : e.dot ? Ys : Xs, i = new Set(e.nocase ? ["i"] : []), r = t.map((a) => {
|
|
120397
|
+
let l = a.map((c) => {
|
|
120398
|
+
if (c instanceof RegExp)
|
|
120399
|
+
for (let d of c.flags.split(""))
|
|
120400
|
+
i.add(d);
|
|
120401
|
+
return typeof c == "string" ? ei(c) : c === A ? A : c._src;
|
|
120402
|
+
});
|
|
120403
|
+
l.forEach((c, d) => {
|
|
120404
|
+
let f = l[d + 1], m = l[d - 1];
|
|
120405
|
+
c !== A || m === A || (m === undefined ? f !== undefined && f !== A ? l[d + 1] = "(?:\\/|" + s + "\\/)?" + f : l[d] = s : f === undefined ? l[d - 1] = m + "(?:\\/|\\/" + s + ")?" : f !== A && (l[d - 1] = m + "(?:\\/|\\/" + s + "\\/)" + f, l[d + 1] = A));
|
|
120406
|
+
});
|
|
120407
|
+
let u = l.filter((c) => c !== A);
|
|
120408
|
+
if (this.partial && u.length >= 1) {
|
|
120409
|
+
let c = [];
|
|
120410
|
+
for (let d = 1;d <= u.length; d++)
|
|
120411
|
+
c.push(u.slice(0, d).join("/"));
|
|
120412
|
+
return "(?:" + c.join("|") + ")";
|
|
120413
|
+
}
|
|
120414
|
+
return u.join("/");
|
|
120415
|
+
}).join("|"), [o, h] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
120416
|
+
r = "^" + o + r + h + "$", this.partial && (r = "^(?:\\/|" + o + r.slice(1, -1) + h + ")$"), this.negate && (r = "^(?!" + r + ").+$");
|
|
120417
|
+
try {
|
|
120418
|
+
this.regexp = new RegExp(r, [...i].join(""));
|
|
120419
|
+
} catch {
|
|
120420
|
+
this.regexp = false;
|
|
120421
|
+
}
|
|
120422
|
+
return this.regexp;
|
|
120423
|
+
}
|
|
120424
|
+
slashSplit(t) {
|
|
120425
|
+
return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
|
|
120426
|
+
}
|
|
120427
|
+
match(t, e = this.partial) {
|
|
120428
|
+
if (this.debug("match", t, this.pattern), this.comment)
|
|
120429
|
+
return false;
|
|
120430
|
+
if (this.empty)
|
|
120431
|
+
return t === "";
|
|
120432
|
+
if (t === "/" && e)
|
|
120433
|
+
return true;
|
|
120434
|
+
let s = this.options;
|
|
120435
|
+
this.isWindows && (t = t.split("\\").join("/"));
|
|
120436
|
+
let i = this.slashSplit(t);
|
|
120437
|
+
this.debug(this.pattern, "split", i);
|
|
120438
|
+
let r = this.set;
|
|
120439
|
+
this.debug(this.pattern, "set", r);
|
|
120440
|
+
let o = i[i.length - 1];
|
|
120441
|
+
if (!o)
|
|
120442
|
+
for (let h = i.length - 2;!o && h >= 0; h--)
|
|
120443
|
+
o = i[h];
|
|
120444
|
+
for (let h = 0;h < r.length; h++) {
|
|
120445
|
+
let a = r[h], l = i;
|
|
120446
|
+
if (s.matchBase && a.length === 1 && (l = [o]), this.matchOne(l, a, e))
|
|
120447
|
+
return s.flipNegate ? true : !this.negate;
|
|
120448
|
+
}
|
|
120449
|
+
return s.flipNegate ? false : this.negate;
|
|
120450
|
+
}
|
|
120451
|
+
static defaults(t) {
|
|
120452
|
+
return O.defaults(t).Minimatch;
|
|
120453
|
+
}
|
|
120454
|
+
};
|
|
120455
|
+
O.AST = Q;
|
|
120456
|
+
O.Minimatch = D;
|
|
120457
|
+
O.escape = tt;
|
|
120458
|
+
O.unescape = W;
|
|
120459
|
+
var si = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
|
|
120460
|
+
var Oe = new Set;
|
|
120461
|
+
var Vt = typeof process == "object" && process ? process : {};
|
|
120462
|
+
var Fe = (n2, t, e, s) => {
|
|
120463
|
+
typeof Vt.emitWarning == "function" ? Vt.emitWarning(n2, t, e, s) : console.error(`[${e}] ${t}: ${n2}`);
|
|
120464
|
+
};
|
|
120465
|
+
var At = globalThis.AbortController;
|
|
120466
|
+
var Re = globalThis.AbortSignal;
|
|
120467
|
+
if (typeof At > "u") {
|
|
120468
|
+
Re = class {
|
|
120469
|
+
onabort;
|
|
120470
|
+
_onabort = [];
|
|
120471
|
+
reason;
|
|
120472
|
+
aborted = false;
|
|
120473
|
+
addEventListener(e, s) {
|
|
120474
|
+
this._onabort.push(s);
|
|
120475
|
+
}
|
|
120476
|
+
}, At = class {
|
|
120477
|
+
constructor() {
|
|
120478
|
+
t();
|
|
120479
|
+
}
|
|
120480
|
+
signal = new Re;
|
|
120481
|
+
abort(e) {
|
|
120482
|
+
if (!this.signal.aborted) {
|
|
120483
|
+
this.signal.reason = e, this.signal.aborted = true;
|
|
120484
|
+
for (let s of this.signal._onabort)
|
|
120485
|
+
s(e);
|
|
120486
|
+
this.signal.onabort?.(e);
|
|
120487
|
+
}
|
|
120488
|
+
}
|
|
120489
|
+
};
|
|
120490
|
+
let n2 = Vt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
|
|
120491
|
+
n2 && (n2 = false, Fe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
|
|
120492
|
+
};
|
|
120493
|
+
}
|
|
120494
|
+
var ii = (n2) => !Oe.has(n2);
|
|
120495
|
+
var q = (n2) => n2 && n2 === Math.floor(n2) && n2 > 0 && isFinite(n2);
|
|
120496
|
+
var De = (n2) => q(n2) ? n2 <= Math.pow(2, 8) ? Uint8Array : n2 <= Math.pow(2, 16) ? Uint16Array : n2 <= Math.pow(2, 32) ? Uint32Array : n2 <= Number.MAX_SAFE_INTEGER ? Tt : null : null;
|
|
120497
|
+
var Tt = class extends Array {
|
|
120498
|
+
constructor(n2) {
|
|
120499
|
+
super(n2), this.fill(0);
|
|
120500
|
+
}
|
|
120501
|
+
};
|
|
120502
|
+
var ri = class ct {
|
|
120503
|
+
heap;
|
|
120504
|
+
length;
|
|
120505
|
+
static #t = false;
|
|
120506
|
+
static create(t) {
|
|
120507
|
+
let e = De(t);
|
|
120508
|
+
if (!e)
|
|
120509
|
+
return [];
|
|
120510
|
+
ct.#t = true;
|
|
120511
|
+
let s = new ct(t, e);
|
|
120512
|
+
return ct.#t = false, s;
|
|
120513
|
+
}
|
|
120514
|
+
constructor(t, e) {
|
|
120515
|
+
if (!ct.#t)
|
|
120516
|
+
throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
120517
|
+
this.heap = new e(t), this.length = 0;
|
|
120518
|
+
}
|
|
120519
|
+
push(t) {
|
|
120520
|
+
this.heap[this.length++] = t;
|
|
120521
|
+
}
|
|
120522
|
+
pop() {
|
|
120523
|
+
return this.heap[--this.length];
|
|
120524
|
+
}
|
|
120525
|
+
};
|
|
120526
|
+
var ft = class Me {
|
|
120527
|
+
#t;
|
|
120528
|
+
#s;
|
|
120529
|
+
#n;
|
|
120530
|
+
#r;
|
|
120531
|
+
#o;
|
|
120532
|
+
#S;
|
|
120533
|
+
#w;
|
|
120534
|
+
#c;
|
|
120535
|
+
get perf() {
|
|
120536
|
+
return this.#c;
|
|
120537
|
+
}
|
|
120538
|
+
ttl;
|
|
120539
|
+
ttlResolution;
|
|
120540
|
+
ttlAutopurge;
|
|
120541
|
+
updateAgeOnGet;
|
|
120542
|
+
updateAgeOnHas;
|
|
120543
|
+
allowStale;
|
|
120544
|
+
noDisposeOnSet;
|
|
120545
|
+
noUpdateTTL;
|
|
120546
|
+
maxEntrySize;
|
|
120547
|
+
sizeCalculation;
|
|
120548
|
+
noDeleteOnFetchRejection;
|
|
120549
|
+
noDeleteOnStaleGet;
|
|
120550
|
+
allowStaleOnFetchAbort;
|
|
120551
|
+
allowStaleOnFetchRejection;
|
|
120552
|
+
ignoreFetchAbort;
|
|
120553
|
+
#h;
|
|
120554
|
+
#u;
|
|
120555
|
+
#f;
|
|
120556
|
+
#a;
|
|
120557
|
+
#i;
|
|
120558
|
+
#d;
|
|
120559
|
+
#E;
|
|
120560
|
+
#b;
|
|
120561
|
+
#p;
|
|
120562
|
+
#R;
|
|
120563
|
+
#m;
|
|
120564
|
+
#C;
|
|
120565
|
+
#T;
|
|
120566
|
+
#g;
|
|
120567
|
+
#y;
|
|
120568
|
+
#x;
|
|
120569
|
+
#A;
|
|
120570
|
+
#e;
|
|
120571
|
+
#_;
|
|
120572
|
+
static unsafeExposeInternals(t) {
|
|
120573
|
+
return { starts: t.#T, ttls: t.#g, autopurgeTimers: t.#y, sizes: t.#C, keyMap: t.#f, keyList: t.#a, valList: t.#i, next: t.#d, prev: t.#E, get head() {
|
|
120574
|
+
return t.#b;
|
|
120575
|
+
}, get tail() {
|
|
120576
|
+
return t.#p;
|
|
120577
|
+
}, free: t.#R, isBackgroundFetch: (e) => t.#l(e), backgroundFetch: (e, s, i, r) => t.#U(e, s, i, r), moveToTail: (e) => t.#W(e), indexes: (e) => t.#F(e), rindexes: (e) => t.#D(e), isStale: (e) => t.#v(e) };
|
|
120578
|
+
}
|
|
120579
|
+
get max() {
|
|
120580
|
+
return this.#t;
|
|
120581
|
+
}
|
|
120582
|
+
get maxSize() {
|
|
120583
|
+
return this.#s;
|
|
120584
|
+
}
|
|
120585
|
+
get calculatedSize() {
|
|
120586
|
+
return this.#u;
|
|
120587
|
+
}
|
|
120588
|
+
get size() {
|
|
120589
|
+
return this.#h;
|
|
120590
|
+
}
|
|
120591
|
+
get fetchMethod() {
|
|
120592
|
+
return this.#S;
|
|
120593
|
+
}
|
|
120594
|
+
get memoMethod() {
|
|
120595
|
+
return this.#w;
|
|
120596
|
+
}
|
|
120597
|
+
get dispose() {
|
|
120598
|
+
return this.#n;
|
|
120599
|
+
}
|
|
120600
|
+
get onInsert() {
|
|
120601
|
+
return this.#r;
|
|
120602
|
+
}
|
|
120603
|
+
get disposeAfter() {
|
|
120604
|
+
return this.#o;
|
|
120605
|
+
}
|
|
120606
|
+
constructor(t) {
|
|
120607
|
+
let { max: e = 0, ttl: s, ttlResolution: i = 1, ttlAutopurge: r, updateAgeOnGet: o, updateAgeOnHas: h, allowStale: a, dispose: l, onInsert: u, disposeAfter: c, noDisposeOnSet: d, noUpdateTTL: f, maxSize: m = 0, maxEntrySize: p = 0, sizeCalculation: w, fetchMethod: g, memoMethod: S, noDeleteOnFetchRejection: E, noDeleteOnStaleGet: y, allowStaleOnFetchRejection: b, allowStaleOnFetchAbort: z, ignoreFetchAbort: $, perf: J } = t;
|
|
120608
|
+
if (J !== undefined && typeof J?.now != "function")
|
|
120609
|
+
throw new TypeError("perf option must have a now() method if specified");
|
|
120610
|
+
if (this.#c = J ?? si, e !== 0 && !q(e))
|
|
120611
|
+
throw new TypeError("max option must be a nonnegative integer");
|
|
120612
|
+
let Z = e ? De(e) : Array;
|
|
120613
|
+
if (!Z)
|
|
120614
|
+
throw new Error("invalid max value: " + e);
|
|
120615
|
+
if (this.#t = e, this.#s = m, this.maxEntrySize = p || this.#s, this.sizeCalculation = w, this.sizeCalculation) {
|
|
120616
|
+
if (!this.#s && !this.maxEntrySize)
|
|
120617
|
+
throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
120618
|
+
if (typeof this.sizeCalculation != "function")
|
|
120619
|
+
throw new TypeError("sizeCalculation set to non-function");
|
|
120620
|
+
}
|
|
120621
|
+
if (S !== undefined && typeof S != "function")
|
|
120622
|
+
throw new TypeError("memoMethod must be a function if defined");
|
|
120623
|
+
if (this.#w = S, g !== undefined && typeof g != "function")
|
|
120624
|
+
throw new TypeError("fetchMethod must be a function if specified");
|
|
120625
|
+
if (this.#S = g, this.#A = !!g, this.#f = new Map, this.#a = new Array(e).fill(undefined), this.#i = new Array(e).fill(undefined), this.#d = new Z(e), this.#E = new Z(e), this.#b = 0, this.#p = 0, this.#R = ri.create(e), this.#h = 0, this.#u = 0, typeof l == "function" && (this.#n = l), typeof u == "function" && (this.#r = u), typeof c == "function" ? (this.#o = c, this.#m = []) : (this.#o = undefined, this.#m = undefined), this.#x = !!this.#n, this.#_ = !!this.#r, this.#e = !!this.#o, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!f, this.noDeleteOnFetchRejection = !!E, this.allowStaleOnFetchRejection = !!b, this.allowStaleOnFetchAbort = !!z, this.ignoreFetchAbort = !!$, this.maxEntrySize !== 0) {
|
|
120626
|
+
if (this.#s !== 0 && !q(this.#s))
|
|
120627
|
+
throw new TypeError("maxSize must be a positive integer if specified");
|
|
120628
|
+
if (!q(this.maxEntrySize))
|
|
120629
|
+
throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
120630
|
+
this.#G();
|
|
120631
|
+
}
|
|
120632
|
+
if (this.allowStale = !!a, this.noDeleteOnStaleGet = !!y, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = q(i) || i === 0 ? i : 1, this.ttlAutopurge = !!r, this.ttl = s || 0, this.ttl) {
|
|
120633
|
+
if (!q(this.ttl))
|
|
120634
|
+
throw new TypeError("ttl must be a positive integer if specified");
|
|
120635
|
+
this.#M();
|
|
120636
|
+
}
|
|
120637
|
+
if (this.#t === 0 && this.ttl === 0 && this.#s === 0)
|
|
120638
|
+
throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
120639
|
+
if (!this.ttlAutopurge && !this.#t && !this.#s) {
|
|
120640
|
+
let $t = "LRU_CACHE_UNBOUNDED";
|
|
120641
|
+
ii($t) && (Oe.add($t), Fe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", $t, Me));
|
|
120642
|
+
}
|
|
120643
|
+
}
|
|
120644
|
+
getRemainingTTL(t) {
|
|
120645
|
+
return this.#f.has(t) ? 1 / 0 : 0;
|
|
120646
|
+
}
|
|
120647
|
+
#M() {
|
|
120648
|
+
let t = new Tt(this.#t), e = new Tt(this.#t);
|
|
120649
|
+
this.#g = t, this.#T = e;
|
|
120650
|
+
let s = this.ttlAutopurge ? new Array(this.#t) : undefined;
|
|
120651
|
+
this.#y = s, this.#j = (o, h, a = this.#c.now()) => {
|
|
120652
|
+
if (e[o] = h !== 0 ? a : 0, t[o] = h, s?.[o] && (clearTimeout(s[o]), s[o] = undefined), h !== 0 && s) {
|
|
120653
|
+
let l = setTimeout(() => {
|
|
120654
|
+
this.#v(o) && this.#O(this.#a[o], "expire");
|
|
120655
|
+
}, h + 1);
|
|
120656
|
+
l.unref && l.unref(), s[o] = l;
|
|
120657
|
+
}
|
|
120658
|
+
}, this.#k = (o) => {
|
|
120659
|
+
e[o] = t[o] !== 0 ? this.#c.now() : 0;
|
|
120660
|
+
}, this.#N = (o, h) => {
|
|
120661
|
+
if (t[h]) {
|
|
120662
|
+
let a = t[h], l = e[h];
|
|
120663
|
+
if (!a || !l)
|
|
120664
|
+
return;
|
|
120665
|
+
o.ttl = a, o.start = l, o.now = i || r();
|
|
120666
|
+
let u = o.now - l;
|
|
120667
|
+
o.remainingTTL = a - u;
|
|
120668
|
+
}
|
|
120669
|
+
};
|
|
120670
|
+
let i = 0, r = () => {
|
|
120671
|
+
let o = this.#c.now();
|
|
120672
|
+
if (this.ttlResolution > 0) {
|
|
120673
|
+
i = o;
|
|
120674
|
+
let h = setTimeout(() => i = 0, this.ttlResolution);
|
|
120675
|
+
h.unref && h.unref();
|
|
120676
|
+
}
|
|
120677
|
+
return o;
|
|
120678
|
+
};
|
|
120679
|
+
this.getRemainingTTL = (o) => {
|
|
120680
|
+
let h = this.#f.get(o);
|
|
120681
|
+
if (h === undefined)
|
|
120682
|
+
return 0;
|
|
120683
|
+
let a = t[h], l = e[h];
|
|
120684
|
+
if (!a || !l)
|
|
120685
|
+
return 1 / 0;
|
|
120686
|
+
let u = (i || r()) - l;
|
|
120687
|
+
return a - u;
|
|
120688
|
+
}, this.#v = (o) => {
|
|
120689
|
+
let h = e[o], a = t[o];
|
|
120690
|
+
return !!a && !!h && (i || r()) - h > a;
|
|
120691
|
+
};
|
|
120692
|
+
}
|
|
120693
|
+
#k = () => {};
|
|
120694
|
+
#N = () => {};
|
|
120695
|
+
#j = () => {};
|
|
120696
|
+
#v = () => false;
|
|
120697
|
+
#G() {
|
|
120698
|
+
let t = new Tt(this.#t);
|
|
120699
|
+
this.#u = 0, this.#C = t, this.#P = (e) => {
|
|
120700
|
+
this.#u -= t[e], t[e] = 0;
|
|
120701
|
+
}, this.#I = (e, s, i, r) => {
|
|
120702
|
+
if (this.#l(s))
|
|
120703
|
+
return 0;
|
|
120704
|
+
if (!q(i))
|
|
120705
|
+
if (r) {
|
|
120706
|
+
if (typeof r != "function")
|
|
120707
|
+
throw new TypeError("sizeCalculation must be a function");
|
|
120708
|
+
if (i = r(s, e), !q(i))
|
|
120709
|
+
throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
120710
|
+
} else
|
|
120711
|
+
throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
120712
|
+
return i;
|
|
120713
|
+
}, this.#L = (e, s, i) => {
|
|
120714
|
+
if (t[e] = s, this.#s) {
|
|
120715
|
+
let r = this.#s - t[e];
|
|
120716
|
+
for (;this.#u > r; )
|
|
120717
|
+
this.#B(true);
|
|
120718
|
+
}
|
|
120719
|
+
this.#u += t[e], i && (i.entrySize = s, i.totalCalculatedSize = this.#u);
|
|
120720
|
+
};
|
|
120721
|
+
}
|
|
120722
|
+
#P = (t) => {};
|
|
120723
|
+
#L = (t, e, s) => {};
|
|
120724
|
+
#I = (t, e, s, i) => {
|
|
120725
|
+
if (s || i)
|
|
120726
|
+
throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
120727
|
+
return 0;
|
|
120728
|
+
};
|
|
120729
|
+
*#F({ allowStale: t = this.allowStale } = {}) {
|
|
120730
|
+
if (this.#h)
|
|
120731
|
+
for (let e = this.#p;!(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#b)); )
|
|
120732
|
+
e = this.#E[e];
|
|
120733
|
+
}
|
|
120734
|
+
*#D({ allowStale: t = this.allowStale } = {}) {
|
|
120735
|
+
if (this.#h)
|
|
120736
|
+
for (let e = this.#b;!(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#p)); )
|
|
120737
|
+
e = this.#d[e];
|
|
120738
|
+
}
|
|
120739
|
+
#z(t) {
|
|
120740
|
+
return t !== undefined && this.#f.get(this.#a[t]) === t;
|
|
120741
|
+
}
|
|
120742
|
+
*entries() {
|
|
120743
|
+
for (let t of this.#F())
|
|
120744
|
+
this.#i[t] !== undefined && this.#a[t] !== undefined && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
|
|
120745
|
+
}
|
|
120746
|
+
*rentries() {
|
|
120747
|
+
for (let t of this.#D())
|
|
120748
|
+
this.#i[t] !== undefined && this.#a[t] !== undefined && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
|
|
120749
|
+
}
|
|
120750
|
+
*keys() {
|
|
120751
|
+
for (let t of this.#F()) {
|
|
120752
|
+
let e = this.#a[t];
|
|
120753
|
+
e !== undefined && !this.#l(this.#i[t]) && (yield e);
|
|
120754
|
+
}
|
|
120755
|
+
}
|
|
120756
|
+
*rkeys() {
|
|
120757
|
+
for (let t of this.#D()) {
|
|
120758
|
+
let e = this.#a[t];
|
|
120759
|
+
e !== undefined && !this.#l(this.#i[t]) && (yield e);
|
|
120760
|
+
}
|
|
120761
|
+
}
|
|
120762
|
+
*values() {
|
|
120763
|
+
for (let t of this.#F())
|
|
120764
|
+
this.#i[t] !== undefined && !this.#l(this.#i[t]) && (yield this.#i[t]);
|
|
120765
|
+
}
|
|
120766
|
+
*rvalues() {
|
|
120767
|
+
for (let t of this.#D())
|
|
120768
|
+
this.#i[t] !== undefined && !this.#l(this.#i[t]) && (yield this.#i[t]);
|
|
120769
|
+
}
|
|
120770
|
+
[Symbol.iterator]() {
|
|
120771
|
+
return this.entries();
|
|
120772
|
+
}
|
|
120773
|
+
[Symbol.toStringTag] = "LRUCache";
|
|
120774
|
+
find(t, e = {}) {
|
|
120775
|
+
for (let s of this.#F()) {
|
|
120776
|
+
let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
120777
|
+
if (r !== undefined && t(r, this.#a[s], this))
|
|
120778
|
+
return this.get(this.#a[s], e);
|
|
120779
|
+
}
|
|
120780
|
+
}
|
|
120781
|
+
forEach(t, e = this) {
|
|
120782
|
+
for (let s of this.#F()) {
|
|
120783
|
+
let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
120784
|
+
r !== undefined && t.call(e, r, this.#a[s], this);
|
|
120785
|
+
}
|
|
120786
|
+
}
|
|
120787
|
+
rforEach(t, e = this) {
|
|
120788
|
+
for (let s of this.#D()) {
|
|
120789
|
+
let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
120790
|
+
r !== undefined && t.call(e, r, this.#a[s], this);
|
|
120791
|
+
}
|
|
120792
|
+
}
|
|
120793
|
+
purgeStale() {
|
|
120794
|
+
let t = false;
|
|
120795
|
+
for (let e of this.#D({ allowStale: true }))
|
|
120796
|
+
this.#v(e) && (this.#O(this.#a[e], "expire"), t = true);
|
|
120797
|
+
return t;
|
|
120798
|
+
}
|
|
120799
|
+
info(t) {
|
|
120800
|
+
let e = this.#f.get(t);
|
|
120801
|
+
if (e === undefined)
|
|
120802
|
+
return;
|
|
120803
|
+
let s = this.#i[e], i = this.#l(s) ? s.__staleWhileFetching : s;
|
|
120804
|
+
if (i === undefined)
|
|
120805
|
+
return;
|
|
120806
|
+
let r = { value: i };
|
|
120807
|
+
if (this.#g && this.#T) {
|
|
120808
|
+
let o = this.#g[e], h = this.#T[e];
|
|
120809
|
+
if (o && h) {
|
|
120810
|
+
let a = o - (this.#c.now() - h);
|
|
120811
|
+
r.ttl = a, r.start = Date.now();
|
|
120812
|
+
}
|
|
120813
|
+
}
|
|
120814
|
+
return this.#C && (r.size = this.#C[e]), r;
|
|
120815
|
+
}
|
|
120816
|
+
dump() {
|
|
120817
|
+
let t = [];
|
|
120818
|
+
for (let e of this.#F({ allowStale: true })) {
|
|
120819
|
+
let s = this.#a[e], i = this.#i[e], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
120820
|
+
if (r === undefined || s === undefined)
|
|
120821
|
+
continue;
|
|
120822
|
+
let o = { value: r };
|
|
120823
|
+
if (this.#g && this.#T) {
|
|
120824
|
+
o.ttl = this.#g[e];
|
|
120825
|
+
let h = this.#c.now() - this.#T[e];
|
|
120826
|
+
o.start = Math.floor(Date.now() - h);
|
|
120827
|
+
}
|
|
120828
|
+
this.#C && (o.size = this.#C[e]), t.unshift([s, o]);
|
|
120829
|
+
}
|
|
120830
|
+
return t;
|
|
120831
|
+
}
|
|
120832
|
+
load(t) {
|
|
120833
|
+
this.clear();
|
|
120834
|
+
for (let [e, s] of t) {
|
|
120835
|
+
if (s.start) {
|
|
120836
|
+
let i = Date.now() - s.start;
|
|
120837
|
+
s.start = this.#c.now() - i;
|
|
120838
|
+
}
|
|
120839
|
+
this.set(e, s.value, s);
|
|
120840
|
+
}
|
|
120841
|
+
}
|
|
120842
|
+
set(t, e, s = {}) {
|
|
120843
|
+
if (e === undefined)
|
|
120844
|
+
return this.delete(t), this;
|
|
120845
|
+
let { ttl: i = this.ttl, start: r, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: a } = s, { noUpdateTTL: l = this.noUpdateTTL } = s, u = this.#I(t, e, s.size || 0, h);
|
|
120846
|
+
if (this.maxEntrySize && u > this.maxEntrySize)
|
|
120847
|
+
return a && (a.set = "miss", a.maxEntrySizeExceeded = true), this.#O(t, "set"), this;
|
|
120848
|
+
let c = this.#h === 0 ? undefined : this.#f.get(t);
|
|
120849
|
+
if (c === undefined)
|
|
120850
|
+
c = this.#h === 0 ? this.#p : this.#R.length !== 0 ? this.#R.pop() : this.#h === this.#t ? this.#B(false) : this.#h, this.#a[c] = t, this.#i[c] = e, this.#f.set(t, c), this.#d[this.#p] = c, this.#E[c] = this.#p, this.#p = c, this.#h++, this.#L(c, u, a), a && (a.set = "add"), l = false, this.#_ && this.#r?.(e, t, "add");
|
|
120851
|
+
else {
|
|
120852
|
+
this.#W(c);
|
|
120853
|
+
let d = this.#i[c];
|
|
120854
|
+
if (e !== d) {
|
|
120855
|
+
if (this.#A && this.#l(d)) {
|
|
120856
|
+
d.__abortController.abort(new Error("replaced"));
|
|
120857
|
+
let { __staleWhileFetching: f } = d;
|
|
120858
|
+
f !== undefined && !o && (this.#x && this.#n?.(f, t, "set"), this.#e && this.#m?.push([f, t, "set"]));
|
|
120859
|
+
} else
|
|
120860
|
+
o || (this.#x && this.#n?.(d, t, "set"), this.#e && this.#m?.push([d, t, "set"]));
|
|
120861
|
+
if (this.#P(c), this.#L(c, u, a), this.#i[c] = e, a) {
|
|
120862
|
+
a.set = "replace";
|
|
120863
|
+
let f = d && this.#l(d) ? d.__staleWhileFetching : d;
|
|
120864
|
+
f !== undefined && (a.oldValue = f);
|
|
120865
|
+
}
|
|
120866
|
+
} else
|
|
120867
|
+
a && (a.set = "update");
|
|
120868
|
+
this.#_ && this.onInsert?.(e, t, e === d ? "update" : "replace");
|
|
120869
|
+
}
|
|
120870
|
+
if (i !== 0 && !this.#g && this.#M(), this.#g && (l || this.#j(c, i, r), a && this.#N(a, c)), !o && this.#e && this.#m) {
|
|
120871
|
+
let d = this.#m, f;
|
|
120872
|
+
for (;f = d?.shift(); )
|
|
120873
|
+
this.#o?.(...f);
|
|
120874
|
+
}
|
|
120875
|
+
return this;
|
|
120876
|
+
}
|
|
120877
|
+
pop() {
|
|
120878
|
+
try {
|
|
120879
|
+
for (;this.#h; ) {
|
|
120880
|
+
let t = this.#i[this.#b];
|
|
120881
|
+
if (this.#B(true), this.#l(t)) {
|
|
120882
|
+
if (t.__staleWhileFetching)
|
|
120883
|
+
return t.__staleWhileFetching;
|
|
120884
|
+
} else if (t !== undefined)
|
|
120885
|
+
return t;
|
|
120886
|
+
}
|
|
120887
|
+
} finally {
|
|
120888
|
+
if (this.#e && this.#m) {
|
|
120889
|
+
let t = this.#m, e;
|
|
120890
|
+
for (;e = t?.shift(); )
|
|
120891
|
+
this.#o?.(...e);
|
|
120892
|
+
}
|
|
120893
|
+
}
|
|
120894
|
+
}
|
|
120895
|
+
#B(t) {
|
|
120896
|
+
let e = this.#b, s = this.#a[e], i = this.#i[e];
|
|
120897
|
+
return this.#A && this.#l(i) ? i.__abortController.abort(new Error("evicted")) : (this.#x || this.#e) && (this.#x && this.#n?.(i, s, "evict"), this.#e && this.#m?.push([i, s, "evict"])), this.#P(e), this.#y?.[e] && (clearTimeout(this.#y[e]), this.#y[e] = undefined), t && (this.#a[e] = undefined, this.#i[e] = undefined, this.#R.push(e)), this.#h === 1 ? (this.#b = this.#p = 0, this.#R.length = 0) : this.#b = this.#d[e], this.#f.delete(s), this.#h--, e;
|
|
120898
|
+
}
|
|
120899
|
+
has(t, e = {}) {
|
|
120900
|
+
let { updateAgeOnHas: s = this.updateAgeOnHas, status: i } = e, r = this.#f.get(t);
|
|
120901
|
+
if (r !== undefined) {
|
|
120902
|
+
let o = this.#i[r];
|
|
120903
|
+
if (this.#l(o) && o.__staleWhileFetching === undefined)
|
|
120904
|
+
return false;
|
|
120905
|
+
if (this.#v(r))
|
|
120906
|
+
i && (i.has = "stale", this.#N(i, r));
|
|
120907
|
+
else
|
|
120908
|
+
return s && this.#k(r), i && (i.has = "hit", this.#N(i, r)), true;
|
|
120909
|
+
} else
|
|
120910
|
+
i && (i.has = "miss");
|
|
120911
|
+
return false;
|
|
120912
|
+
}
|
|
120913
|
+
peek(t, e = {}) {
|
|
120914
|
+
let { allowStale: s = this.allowStale } = e, i = this.#f.get(t);
|
|
120915
|
+
if (i === undefined || !s && this.#v(i))
|
|
120916
|
+
return;
|
|
120917
|
+
let r = this.#i[i];
|
|
120918
|
+
return this.#l(r) ? r.__staleWhileFetching : r;
|
|
120919
|
+
}
|
|
120920
|
+
#U(t, e, s, i) {
|
|
120921
|
+
let r = e === undefined ? undefined : this.#i[e];
|
|
120922
|
+
if (this.#l(r))
|
|
120923
|
+
return r;
|
|
120924
|
+
let o = new At, { signal: h } = s;
|
|
120925
|
+
h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
|
|
120926
|
+
let a = { signal: o.signal, options: s, context: i }, l = (p, w = false) => {
|
|
120927
|
+
let { aborted: g } = o.signal, S = s.ignoreFetchAbort && p !== undefined, E = s.ignoreFetchAbort || !!(s.allowStaleOnFetchAbort && p !== undefined);
|
|
120928
|
+
if (s.status && (g && !w ? (s.status.fetchAborted = true, s.status.fetchError = o.signal.reason, S && (s.status.fetchAbortIgnored = true)) : s.status.fetchResolved = true), g && !S && !w)
|
|
120929
|
+
return c(o.signal.reason, E);
|
|
120930
|
+
let y = f, b = this.#i[e];
|
|
120931
|
+
return (b === f || S && w && b === undefined) && (p === undefined ? y.__staleWhileFetching !== undefined ? this.#i[e] = y.__staleWhileFetching : this.#O(t, "fetch") : (s.status && (s.status.fetchUpdated = true), this.set(t, p, a.options))), p;
|
|
120932
|
+
}, u = (p) => (s.status && (s.status.fetchRejected = true, s.status.fetchError = p), c(p, false)), c = (p, w) => {
|
|
120933
|
+
let { aborted: g } = o.signal, S = g && s.allowStaleOnFetchAbort, E = S || s.allowStaleOnFetchRejection, y = E || s.noDeleteOnFetchRejection, b = f;
|
|
120934
|
+
if (this.#i[e] === f && (!y || !w && b.__staleWhileFetching === undefined ? this.#O(t, "fetch") : S || (this.#i[e] = b.__staleWhileFetching)), E)
|
|
120935
|
+
return s.status && b.__staleWhileFetching !== undefined && (s.status.returnedStale = true), b.__staleWhileFetching;
|
|
120936
|
+
if (b.__returned === b)
|
|
120937
|
+
throw p;
|
|
120938
|
+
}, d = (p, w) => {
|
|
120939
|
+
let g = this.#S?.(t, r, a);
|
|
120940
|
+
g && g instanceof Promise && g.then((S) => p(S === undefined ? undefined : S), w), o.signal.addEventListener("abort", () => {
|
|
120941
|
+
(!s.ignoreFetchAbort || s.allowStaleOnFetchAbort) && (p(undefined), s.allowStaleOnFetchAbort && (p = (S) => l(S, true)));
|
|
120942
|
+
});
|
|
120943
|
+
};
|
|
120944
|
+
s.status && (s.status.fetchDispatched = true);
|
|
120945
|
+
let f = new Promise(d).then(l, u), m = Object.assign(f, { __abortController: o, __staleWhileFetching: r, __returned: undefined });
|
|
120946
|
+
return e === undefined ? (this.set(t, m, { ...a.options, status: undefined }), e = this.#f.get(t)) : this.#i[e] = m, m;
|
|
120947
|
+
}
|
|
120948
|
+
#l(t) {
|
|
120949
|
+
if (!this.#A)
|
|
120950
|
+
return false;
|
|
120951
|
+
let e = t;
|
|
120952
|
+
return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof At;
|
|
120953
|
+
}
|
|
120954
|
+
async fetch(t, e = {}) {
|
|
120955
|
+
let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: a = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: u = this.noUpdateTTL, noDeleteOnFetchRejection: c = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: m = this.allowStaleOnFetchAbort, context: p, forceRefresh: w = false, status: g, signal: S } = e;
|
|
120956
|
+
if (!this.#A)
|
|
120957
|
+
return g && (g.fetch = "get"), this.get(t, { allowStale: s, updateAgeOnGet: i, noDeleteOnStaleGet: r, status: g });
|
|
120958
|
+
let E = { allowStale: s, updateAgeOnGet: i, noDeleteOnStaleGet: r, ttl: o, noDisposeOnSet: h, size: a, sizeCalculation: l, noUpdateTTL: u, noDeleteOnFetchRejection: c, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: m, ignoreFetchAbort: f, status: g, signal: S }, y = this.#f.get(t);
|
|
120959
|
+
if (y === undefined) {
|
|
120960
|
+
g && (g.fetch = "miss");
|
|
120961
|
+
let b = this.#U(t, y, E, p);
|
|
120962
|
+
return b.__returned = b;
|
|
120963
|
+
} else {
|
|
120964
|
+
let b = this.#i[y];
|
|
120965
|
+
if (this.#l(b)) {
|
|
120966
|
+
let Z = s && b.__staleWhileFetching !== undefined;
|
|
120967
|
+
return g && (g.fetch = "inflight", Z && (g.returnedStale = true)), Z ? b.__staleWhileFetching : b.__returned = b;
|
|
120968
|
+
}
|
|
120969
|
+
let z = this.#v(y);
|
|
120970
|
+
if (!w && !z)
|
|
120971
|
+
return g && (g.fetch = "hit"), this.#W(y), i && this.#k(y), g && this.#N(g, y), b;
|
|
120972
|
+
let $ = this.#U(t, y, E, p), J = $.__staleWhileFetching !== undefined && s;
|
|
120973
|
+
return g && (g.fetch = z ? "stale" : "refresh", J && z && (g.returnedStale = true)), J ? $.__staleWhileFetching : $.__returned = $;
|
|
120974
|
+
}
|
|
120975
|
+
}
|
|
120976
|
+
async forceFetch(t, e = {}) {
|
|
120977
|
+
let s = await this.fetch(t, e);
|
|
120978
|
+
if (s === undefined)
|
|
120979
|
+
throw new Error("fetch() returned undefined");
|
|
120980
|
+
return s;
|
|
120981
|
+
}
|
|
120982
|
+
memo(t, e = {}) {
|
|
120983
|
+
let s = this.#w;
|
|
120984
|
+
if (!s)
|
|
120985
|
+
throw new Error("no memoMethod provided to constructor");
|
|
120986
|
+
let { context: i, forceRefresh: r, ...o } = e, h = this.get(t, o);
|
|
120987
|
+
if (!r && h !== undefined)
|
|
120988
|
+
return h;
|
|
120989
|
+
let a = s(t, h, { options: o, context: i });
|
|
120990
|
+
return this.set(t, a, o), a;
|
|
120991
|
+
}
|
|
120992
|
+
get(t, e = {}) {
|
|
120993
|
+
let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, status: o } = e, h = this.#f.get(t);
|
|
120994
|
+
if (h !== undefined) {
|
|
120995
|
+
let a = this.#i[h], l = this.#l(a);
|
|
120996
|
+
return o && this.#N(o, h), this.#v(h) ? (o && (o.get = "stale"), l ? (o && s && a.__staleWhileFetching !== undefined && (o.returnedStale = true), s ? a.__staleWhileFetching : undefined) : (r || this.#O(t, "expire"), o && s && (o.returnedStale = true), s ? a : undefined)) : (o && (o.get = "hit"), l ? a.__staleWhileFetching : (this.#W(h), i && this.#k(h), a));
|
|
120997
|
+
} else
|
|
120998
|
+
o && (o.get = "miss");
|
|
120999
|
+
}
|
|
121000
|
+
#$(t, e) {
|
|
121001
|
+
this.#E[e] = t, this.#d[t] = e;
|
|
121002
|
+
}
|
|
121003
|
+
#W(t) {
|
|
121004
|
+
t !== this.#p && (t === this.#b ? this.#b = this.#d[t] : this.#$(this.#E[t], this.#d[t]), this.#$(this.#p, t), this.#p = t);
|
|
121005
|
+
}
|
|
121006
|
+
delete(t) {
|
|
121007
|
+
return this.#O(t, "delete");
|
|
121008
|
+
}
|
|
121009
|
+
#O(t, e) {
|
|
121010
|
+
let s = false;
|
|
121011
|
+
if (this.#h !== 0) {
|
|
121012
|
+
let i = this.#f.get(t);
|
|
121013
|
+
if (i !== undefined)
|
|
121014
|
+
if (this.#y?.[i] && (clearTimeout(this.#y?.[i]), this.#y[i] = undefined), s = true, this.#h === 1)
|
|
121015
|
+
this.#H(e);
|
|
121016
|
+
else {
|
|
121017
|
+
this.#P(i);
|
|
121018
|
+
let r = this.#i[i];
|
|
121019
|
+
if (this.#l(r) ? r.__abortController.abort(new Error("deleted")) : (this.#x || this.#e) && (this.#x && this.#n?.(r, t, e), this.#e && this.#m?.push([r, t, e])), this.#f.delete(t), this.#a[i] = undefined, this.#i[i] = undefined, i === this.#p)
|
|
121020
|
+
this.#p = this.#E[i];
|
|
121021
|
+
else if (i === this.#b)
|
|
121022
|
+
this.#b = this.#d[i];
|
|
121023
|
+
else {
|
|
121024
|
+
let o = this.#E[i];
|
|
121025
|
+
this.#d[o] = this.#d[i];
|
|
121026
|
+
let h = this.#d[i];
|
|
121027
|
+
this.#E[h] = this.#E[i];
|
|
121028
|
+
}
|
|
121029
|
+
this.#h--, this.#R.push(i);
|
|
121030
|
+
}
|
|
121031
|
+
}
|
|
121032
|
+
if (this.#e && this.#m?.length) {
|
|
121033
|
+
let i = this.#m, r;
|
|
121034
|
+
for (;r = i?.shift(); )
|
|
121035
|
+
this.#o?.(...r);
|
|
121036
|
+
}
|
|
121037
|
+
return s;
|
|
121038
|
+
}
|
|
121039
|
+
clear() {
|
|
121040
|
+
return this.#H("delete");
|
|
121041
|
+
}
|
|
121042
|
+
#H(t) {
|
|
121043
|
+
for (let e of this.#D({ allowStale: true })) {
|
|
121044
|
+
let s = this.#i[e];
|
|
121045
|
+
if (this.#l(s))
|
|
121046
|
+
s.__abortController.abort(new Error("deleted"));
|
|
121047
|
+
else {
|
|
121048
|
+
let i = this.#a[e];
|
|
121049
|
+
this.#x && this.#n?.(s, i, t), this.#e && this.#m?.push([s, i, t]);
|
|
121050
|
+
}
|
|
121051
|
+
}
|
|
121052
|
+
if (this.#f.clear(), this.#i.fill(undefined), this.#a.fill(undefined), this.#g && this.#T) {
|
|
121053
|
+
this.#g.fill(0), this.#T.fill(0);
|
|
121054
|
+
for (let e of this.#y ?? [])
|
|
121055
|
+
e !== undefined && clearTimeout(e);
|
|
121056
|
+
this.#y?.fill(undefined);
|
|
121057
|
+
}
|
|
121058
|
+
if (this.#C && this.#C.fill(0), this.#b = 0, this.#p = 0, this.#R.length = 0, this.#u = 0, this.#h = 0, this.#e && this.#m) {
|
|
121059
|
+
let e = this.#m, s;
|
|
121060
|
+
for (;s = e?.shift(); )
|
|
121061
|
+
this.#o?.(...s);
|
|
121062
|
+
}
|
|
121063
|
+
}
|
|
121064
|
+
};
|
|
121065
|
+
var Ne = typeof process == "object" && process ? process : { stdout: null, stderr: null };
|
|
121066
|
+
var oi = (n2) => !!n2 && typeof n2 == "object" && (n2 instanceof V || n2 instanceof Pe || hi(n2) || ai(n2));
|
|
121067
|
+
var hi = (n2) => !!n2 && typeof n2 == "object" && n2 instanceof ee && typeof n2.pipe == "function" && n2.pipe !== Pe.Writable.prototype.pipe;
|
|
121068
|
+
var ai = (n2) => !!n2 && typeof n2 == "object" && n2 instanceof ee && typeof n2.write == "function" && typeof n2.end == "function";
|
|
121069
|
+
var G = Symbol("EOF");
|
|
121070
|
+
var H = Symbol("maybeEmitEnd");
|
|
121071
|
+
var K = Symbol("emittedEnd");
|
|
121072
|
+
var kt = Symbol("emittingEnd");
|
|
121073
|
+
var ut = Symbol("emittedError");
|
|
121074
|
+
var Rt = Symbol("closed");
|
|
121075
|
+
var _e = Symbol("read");
|
|
121076
|
+
var Ot = Symbol("flush");
|
|
121077
|
+
var Le = Symbol("flushChunk");
|
|
121078
|
+
var P = Symbol("encoding");
|
|
121079
|
+
var et = Symbol("decoder");
|
|
121080
|
+
var v = Symbol("flowing");
|
|
121081
|
+
var dt = Symbol("paused");
|
|
121082
|
+
var st = Symbol("resume");
|
|
121083
|
+
var C = Symbol("buffer");
|
|
121084
|
+
var F = Symbol("pipes");
|
|
121085
|
+
var T = Symbol("bufferLength");
|
|
121086
|
+
var Yt = Symbol("bufferPush");
|
|
121087
|
+
var Ft = Symbol("bufferShift");
|
|
121088
|
+
var k = Symbol("objectMode");
|
|
121089
|
+
var x = Symbol("destroyed");
|
|
121090
|
+
var Xt = Symbol("error");
|
|
121091
|
+
var Jt = Symbol("emitData");
|
|
121092
|
+
var We = Symbol("emitEnd");
|
|
121093
|
+
var Zt = Symbol("emitEnd2");
|
|
121094
|
+
var B = Symbol("async");
|
|
121095
|
+
var Qt = Symbol("abort");
|
|
121096
|
+
var Dt = Symbol("aborted");
|
|
121097
|
+
var pt = Symbol("signal");
|
|
121098
|
+
var Y = Symbol("dataListeners");
|
|
121099
|
+
var M = Symbol("discarded");
|
|
121100
|
+
var mt = (n2) => Promise.resolve().then(n2);
|
|
121101
|
+
var li = (n2) => n2();
|
|
121102
|
+
var ci = (n2) => n2 === "end" || n2 === "finish" || n2 === "prefinish";
|
|
121103
|
+
var fi = (n2) => n2 instanceof ArrayBuffer || !!n2 && typeof n2 == "object" && n2.constructor && n2.constructor.name === "ArrayBuffer" && n2.byteLength >= 0;
|
|
121104
|
+
var ui = (n2) => !Buffer.isBuffer(n2) && ArrayBuffer.isView(n2);
|
|
121105
|
+
var Mt = class {
|
|
121106
|
+
src;
|
|
121107
|
+
dest;
|
|
121108
|
+
opts;
|
|
121109
|
+
ondrain;
|
|
121110
|
+
constructor(t, e, s) {
|
|
121111
|
+
this.src = t, this.dest = e, this.opts = s, this.ondrain = () => t[st](), this.dest.on("drain", this.ondrain);
|
|
121112
|
+
}
|
|
121113
|
+
unpipe() {
|
|
121114
|
+
this.dest.removeListener("drain", this.ondrain);
|
|
121115
|
+
}
|
|
121116
|
+
proxyErrors(t) {}
|
|
121117
|
+
end() {
|
|
121118
|
+
this.unpipe(), this.opts.end && this.dest.end();
|
|
121119
|
+
}
|
|
121120
|
+
};
|
|
121121
|
+
var te = class extends Mt {
|
|
121122
|
+
unpipe() {
|
|
121123
|
+
this.src.removeListener("error", this.proxyErrors), super.unpipe();
|
|
121124
|
+
}
|
|
121125
|
+
constructor(t, e, s) {
|
|
121126
|
+
super(t, e, s), this.proxyErrors = (i) => this.dest.emit("error", i), t.on("error", this.proxyErrors);
|
|
121127
|
+
}
|
|
121128
|
+
};
|
|
121129
|
+
var di = (n2) => !!n2.objectMode;
|
|
121130
|
+
var pi = (n2) => !n2.objectMode && !!n2.encoding && n2.encoding !== "buffer";
|
|
121131
|
+
var V = class extends ee {
|
|
121132
|
+
[v] = false;
|
|
121133
|
+
[dt] = false;
|
|
121134
|
+
[F] = [];
|
|
121135
|
+
[C] = [];
|
|
121136
|
+
[k];
|
|
121137
|
+
[P];
|
|
121138
|
+
[B];
|
|
121139
|
+
[et];
|
|
121140
|
+
[G] = false;
|
|
121141
|
+
[K] = false;
|
|
121142
|
+
[kt] = false;
|
|
121143
|
+
[Rt] = false;
|
|
121144
|
+
[ut] = null;
|
|
121145
|
+
[T] = 0;
|
|
121146
|
+
[x] = false;
|
|
121147
|
+
[pt];
|
|
121148
|
+
[Dt] = false;
|
|
121149
|
+
[Y] = 0;
|
|
121150
|
+
[M] = false;
|
|
121151
|
+
writable = true;
|
|
121152
|
+
readable = true;
|
|
121153
|
+
constructor(...t) {
|
|
121154
|
+
let e = t[0] || {};
|
|
121155
|
+
if (super(), e.objectMode && typeof e.encoding == "string")
|
|
121156
|
+
throw new TypeError("Encoding and objectMode may not be used together");
|
|
121157
|
+
di(e) ? (this[k] = true, this[P] = null) : pi(e) ? (this[P] = e.encoding, this[k] = false) : (this[k] = false, this[P] = null), this[B] = !!e.async, this[et] = this[P] ? new ni(this[P]) : null, e && e.debugExposeBuffer === true && Object.defineProperty(this, "buffer", { get: () => this[C] }), e && e.debugExposePipes === true && Object.defineProperty(this, "pipes", { get: () => this[F] });
|
|
121158
|
+
let { signal: s } = e;
|
|
121159
|
+
s && (this[pt] = s, s.aborted ? this[Qt]() : s.addEventListener("abort", () => this[Qt]()));
|
|
121160
|
+
}
|
|
121161
|
+
get bufferLength() {
|
|
121162
|
+
return this[T];
|
|
121163
|
+
}
|
|
121164
|
+
get encoding() {
|
|
121165
|
+
return this[P];
|
|
121166
|
+
}
|
|
121167
|
+
set encoding(t) {
|
|
121168
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
121169
|
+
}
|
|
121170
|
+
setEncoding(t) {
|
|
121171
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
121172
|
+
}
|
|
121173
|
+
get objectMode() {
|
|
121174
|
+
return this[k];
|
|
121175
|
+
}
|
|
121176
|
+
set objectMode(t) {
|
|
121177
|
+
throw new Error("objectMode must be set at instantiation time");
|
|
121178
|
+
}
|
|
121179
|
+
get async() {
|
|
121180
|
+
return this[B];
|
|
121181
|
+
}
|
|
121182
|
+
set async(t) {
|
|
121183
|
+
this[B] = this[B] || !!t;
|
|
121184
|
+
}
|
|
121185
|
+
[Qt]() {
|
|
121186
|
+
this[Dt] = true, this.emit("abort", this[pt]?.reason), this.destroy(this[pt]?.reason);
|
|
121187
|
+
}
|
|
121188
|
+
get aborted() {
|
|
121189
|
+
return this[Dt];
|
|
121190
|
+
}
|
|
121191
|
+
set aborted(t) {}
|
|
121192
|
+
write(t, e, s) {
|
|
121193
|
+
if (this[Dt])
|
|
121194
|
+
return false;
|
|
121195
|
+
if (this[G])
|
|
121196
|
+
throw new Error("write after end");
|
|
121197
|
+
if (this[x])
|
|
121198
|
+
return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), true;
|
|
121199
|
+
typeof e == "function" && (s = e, e = "utf8"), e || (e = "utf8");
|
|
121200
|
+
let i = this[B] ? mt : li;
|
|
121201
|
+
if (!this[k] && !Buffer.isBuffer(t)) {
|
|
121202
|
+
if (ui(t))
|
|
121203
|
+
t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
|
|
121204
|
+
else if (fi(t))
|
|
121205
|
+
t = Buffer.from(t);
|
|
121206
|
+
else if (typeof t != "string")
|
|
121207
|
+
throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
121208
|
+
}
|
|
121209
|
+
return this[k] ? (this[v] && this[T] !== 0 && this[Ot](true), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : t.length ? (typeof t == "string" && !(e === this[P] && !this[et]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[P] && (t = this[et].write(t)), this[v] && this[T] !== 0 && this[Ot](true), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : (this[T] !== 0 && this.emit("readable"), s && i(s), this[v]);
|
|
121210
|
+
}
|
|
121211
|
+
read(t) {
|
|
121212
|
+
if (this[x])
|
|
121213
|
+
return null;
|
|
121214
|
+
if (this[M] = false, this[T] === 0 || t === 0 || t && t > this[T])
|
|
121215
|
+
return this[H](), null;
|
|
121216
|
+
this[k] && (t = null), this[C].length > 1 && !this[k] && (this[C] = [this[P] ? this[C].join("") : Buffer.concat(this[C], this[T])]);
|
|
121217
|
+
let e = this[_e](t || null, this[C][0]);
|
|
121218
|
+
return this[H](), e;
|
|
121219
|
+
}
|
|
121220
|
+
[_e](t, e) {
|
|
121221
|
+
if (this[k])
|
|
121222
|
+
this[Ft]();
|
|
121223
|
+
else {
|
|
121224
|
+
let s = e;
|
|
121225
|
+
t === s.length || t === null ? this[Ft]() : typeof s == "string" ? (this[C][0] = s.slice(t), e = s.slice(0, t), this[T] -= t) : (this[C][0] = s.subarray(t), e = s.subarray(0, t), this[T] -= t);
|
|
121226
|
+
}
|
|
121227
|
+
return this.emit("data", e), !this[C].length && !this[G] && this.emit("drain"), e;
|
|
121228
|
+
}
|
|
121229
|
+
end(t, e, s) {
|
|
121230
|
+
return typeof t == "function" && (s = t, t = undefined), typeof e == "function" && (s = e, e = "utf8"), t !== undefined && this.write(t, e), s && this.once("end", s), this[G] = true, this.writable = false, (this[v] || !this[dt]) && this[H](), this;
|
|
121231
|
+
}
|
|
121232
|
+
[st]() {
|
|
121233
|
+
this[x] || (!this[Y] && !this[F].length && (this[M] = true), this[dt] = false, this[v] = true, this.emit("resume"), this[C].length ? this[Ot]() : this[G] ? this[H]() : this.emit("drain"));
|
|
121234
|
+
}
|
|
121235
|
+
resume() {
|
|
121236
|
+
return this[st]();
|
|
121237
|
+
}
|
|
121238
|
+
pause() {
|
|
121239
|
+
this[v] = false, this[dt] = true, this[M] = false;
|
|
121240
|
+
}
|
|
121241
|
+
get destroyed() {
|
|
121242
|
+
return this[x];
|
|
121243
|
+
}
|
|
121244
|
+
get flowing() {
|
|
121245
|
+
return this[v];
|
|
121246
|
+
}
|
|
121247
|
+
get paused() {
|
|
121248
|
+
return this[dt];
|
|
121249
|
+
}
|
|
121250
|
+
[Yt](t) {
|
|
121251
|
+
this[k] ? this[T] += 1 : this[T] += t.length, this[C].push(t);
|
|
121252
|
+
}
|
|
121253
|
+
[Ft]() {
|
|
121254
|
+
return this[k] ? this[T] -= 1 : this[T] -= this[C][0].length, this[C].shift();
|
|
121255
|
+
}
|
|
121256
|
+
[Ot](t = false) {
|
|
121257
|
+
do
|
|
121258
|
+
;
|
|
121259
|
+
while (this[Le](this[Ft]()) && this[C].length);
|
|
121260
|
+
!t && !this[C].length && !this[G] && this.emit("drain");
|
|
121261
|
+
}
|
|
121262
|
+
[Le](t) {
|
|
121263
|
+
return this.emit("data", t), this[v];
|
|
121264
|
+
}
|
|
121265
|
+
pipe(t, e) {
|
|
121266
|
+
if (this[x])
|
|
121267
|
+
return t;
|
|
121268
|
+
this[M] = false;
|
|
121269
|
+
let s = this[K];
|
|
121270
|
+
return e = e || {}, t === Ne.stdout || t === Ne.stderr ? e.end = false : e.end = e.end !== false, e.proxyErrors = !!e.proxyErrors, s ? e.end && t.end() : (this[F].push(e.proxyErrors ? new te(this, t, e) : new Mt(this, t, e)), this[B] ? mt(() => this[st]()) : this[st]()), t;
|
|
121271
|
+
}
|
|
121272
|
+
unpipe(t) {
|
|
121273
|
+
let e = this[F].find((s) => s.dest === t);
|
|
121274
|
+
e && (this[F].length === 1 ? (this[v] && this[Y] === 0 && (this[v] = false), this[F] = []) : this[F].splice(this[F].indexOf(e), 1), e.unpipe());
|
|
121275
|
+
}
|
|
121276
|
+
addListener(t, e) {
|
|
121277
|
+
return this.on(t, e);
|
|
121278
|
+
}
|
|
121279
|
+
on(t, e) {
|
|
121280
|
+
let s = super.on(t, e);
|
|
121281
|
+
if (t === "data")
|
|
121282
|
+
this[M] = false, this[Y]++, !this[F].length && !this[v] && this[st]();
|
|
121283
|
+
else if (t === "readable" && this[T] !== 0)
|
|
121284
|
+
super.emit("readable");
|
|
121285
|
+
else if (ci(t) && this[K])
|
|
121286
|
+
super.emit(t), this.removeAllListeners(t);
|
|
121287
|
+
else if (t === "error" && this[ut]) {
|
|
121288
|
+
let i = e;
|
|
121289
|
+
this[B] ? mt(() => i.call(this, this[ut])) : i.call(this, this[ut]);
|
|
121290
|
+
}
|
|
121291
|
+
return s;
|
|
121292
|
+
}
|
|
121293
|
+
removeListener(t, e) {
|
|
121294
|
+
return this.off(t, e);
|
|
121295
|
+
}
|
|
121296
|
+
off(t, e) {
|
|
121297
|
+
let s = super.off(t, e);
|
|
121298
|
+
return t === "data" && (this[Y] = this.listeners("data").length, this[Y] === 0 && !this[M] && !this[F].length && (this[v] = false)), s;
|
|
121299
|
+
}
|
|
121300
|
+
removeAllListeners(t) {
|
|
121301
|
+
let e = super.removeAllListeners(t);
|
|
121302
|
+
return (t === "data" || t === undefined) && (this[Y] = 0, !this[M] && !this[F].length && (this[v] = false)), e;
|
|
121303
|
+
}
|
|
121304
|
+
get emittedEnd() {
|
|
121305
|
+
return this[K];
|
|
121306
|
+
}
|
|
121307
|
+
[H]() {
|
|
121308
|
+
!this[kt] && !this[K] && !this[x] && this[C].length === 0 && this[G] && (this[kt] = true, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Rt] && this.emit("close"), this[kt] = false);
|
|
121309
|
+
}
|
|
121310
|
+
emit(t, ...e) {
|
|
121311
|
+
let s = e[0];
|
|
121312
|
+
if (t !== "error" && t !== "close" && t !== x && this[x])
|
|
121313
|
+
return false;
|
|
121314
|
+
if (t === "data")
|
|
121315
|
+
return !this[k] && !s ? false : this[B] ? (mt(() => this[Jt](s)), true) : this[Jt](s);
|
|
121316
|
+
if (t === "end")
|
|
121317
|
+
return this[We]();
|
|
121318
|
+
if (t === "close") {
|
|
121319
|
+
if (this[Rt] = true, !this[K] && !this[x])
|
|
121320
|
+
return false;
|
|
121321
|
+
let r = super.emit("close");
|
|
121322
|
+
return this.removeAllListeners("close"), r;
|
|
121323
|
+
} else if (t === "error") {
|
|
121324
|
+
this[ut] = s, super.emit(Xt, s);
|
|
121325
|
+
let r = !this[pt] || this.listeners("error").length ? super.emit("error", s) : false;
|
|
121326
|
+
return this[H](), r;
|
|
121327
|
+
} else if (t === "resume") {
|
|
121328
|
+
let r = super.emit("resume");
|
|
121329
|
+
return this[H](), r;
|
|
121330
|
+
} else if (t === "finish" || t === "prefinish") {
|
|
121331
|
+
let r = super.emit(t);
|
|
121332
|
+
return this.removeAllListeners(t), r;
|
|
121333
|
+
}
|
|
121334
|
+
let i = super.emit(t, ...e);
|
|
121335
|
+
return this[H](), i;
|
|
121336
|
+
}
|
|
121337
|
+
[Jt](t) {
|
|
121338
|
+
for (let s of this[F])
|
|
121339
|
+
s.dest.write(t) === false && this.pause();
|
|
121340
|
+
let e = this[M] ? false : super.emit("data", t);
|
|
121341
|
+
return this[H](), e;
|
|
121342
|
+
}
|
|
121343
|
+
[We]() {
|
|
121344
|
+
return this[K] ? false : (this[K] = true, this.readable = false, this[B] ? (mt(() => this[Zt]()), true) : this[Zt]());
|
|
121345
|
+
}
|
|
121346
|
+
[Zt]() {
|
|
121347
|
+
if (this[et]) {
|
|
121348
|
+
let e = this[et].end();
|
|
121349
|
+
if (e) {
|
|
121350
|
+
for (let s of this[F])
|
|
121351
|
+
s.dest.write(e);
|
|
121352
|
+
this[M] || super.emit("data", e);
|
|
121353
|
+
}
|
|
121354
|
+
}
|
|
121355
|
+
for (let e of this[F])
|
|
121356
|
+
e.end();
|
|
121357
|
+
let t = super.emit("end");
|
|
121358
|
+
return this.removeAllListeners("end"), t;
|
|
121359
|
+
}
|
|
121360
|
+
async collect() {
|
|
121361
|
+
let t = Object.assign([], { dataLength: 0 });
|
|
121362
|
+
this[k] || (t.dataLength = 0);
|
|
121363
|
+
let e = this.promise();
|
|
121364
|
+
return this.on("data", (s) => {
|
|
121365
|
+
t.push(s), this[k] || (t.dataLength += s.length);
|
|
121366
|
+
}), await e, t;
|
|
121367
|
+
}
|
|
121368
|
+
async concat() {
|
|
121369
|
+
if (this[k])
|
|
121370
|
+
throw new Error("cannot concat in objectMode");
|
|
121371
|
+
let t = await this.collect();
|
|
121372
|
+
return this[P] ? t.join("") : Buffer.concat(t, t.dataLength);
|
|
121373
|
+
}
|
|
121374
|
+
async promise() {
|
|
121375
|
+
return new Promise((t, e) => {
|
|
121376
|
+
this.on(x, () => e(new Error("stream destroyed"))), this.on("error", (s) => e(s)), this.on("end", () => t());
|
|
121377
|
+
});
|
|
121378
|
+
}
|
|
121379
|
+
[Symbol.asyncIterator]() {
|
|
121380
|
+
this[M] = false;
|
|
121381
|
+
let t = false, e = async () => (this.pause(), t = true, { value: undefined, done: true });
|
|
121382
|
+
return { next: () => {
|
|
121383
|
+
if (t)
|
|
121384
|
+
return e();
|
|
121385
|
+
let i = this.read();
|
|
121386
|
+
if (i !== null)
|
|
121387
|
+
return Promise.resolve({ done: false, value: i });
|
|
121388
|
+
if (this[G])
|
|
121389
|
+
return e();
|
|
121390
|
+
let r, o, h = (c) => {
|
|
121391
|
+
this.off("data", a), this.off("end", l), this.off(x, u), e(), o(c);
|
|
121392
|
+
}, a = (c) => {
|
|
121393
|
+
this.off("error", h), this.off("end", l), this.off(x, u), this.pause(), r({ value: c, done: !!this[G] });
|
|
121394
|
+
}, l = () => {
|
|
121395
|
+
this.off("error", h), this.off("data", a), this.off(x, u), e(), r({ done: true, value: undefined });
|
|
121396
|
+
}, u = () => h(new Error("stream destroyed"));
|
|
121397
|
+
return new Promise((c, d) => {
|
|
121398
|
+
o = d, r = c, this.once(x, u), this.once("error", h), this.once("end", l), this.once("data", a);
|
|
121399
|
+
});
|
|
121400
|
+
}, throw: e, return: e, [Symbol.asyncIterator]() {
|
|
121401
|
+
return this;
|
|
121402
|
+
}, [Symbol.asyncDispose]: async () => {} };
|
|
121403
|
+
}
|
|
121404
|
+
[Symbol.iterator]() {
|
|
121405
|
+
this[M] = false;
|
|
121406
|
+
let t = false, e = () => (this.pause(), this.off(Xt, e), this.off(x, e), this.off("end", e), t = true, { done: true, value: undefined }), s = () => {
|
|
121407
|
+
if (t)
|
|
121408
|
+
return e();
|
|
121409
|
+
let i = this.read();
|
|
121410
|
+
return i === null ? e() : { done: false, value: i };
|
|
121411
|
+
};
|
|
121412
|
+
return this.once("end", e), this.once(Xt, e), this.once(x, e), { next: s, throw: e, return: e, [Symbol.iterator]() {
|
|
121413
|
+
return this;
|
|
121414
|
+
}, [Symbol.dispose]: () => {} };
|
|
121415
|
+
}
|
|
121416
|
+
destroy(t) {
|
|
121417
|
+
if (this[x])
|
|
121418
|
+
return t ? this.emit("error", t) : this.emit(x), this;
|
|
121419
|
+
this[x] = true, this[M] = true, this[C].length = 0, this[T] = 0;
|
|
121420
|
+
let e = this;
|
|
121421
|
+
return typeof e.close == "function" && !this[Rt] && e.close(), t ? this.emit("error", t) : this.emit(x), this;
|
|
121422
|
+
}
|
|
121423
|
+
static get isStream() {
|
|
121424
|
+
return oi;
|
|
121425
|
+
}
|
|
121426
|
+
};
|
|
121427
|
+
var vi = Ei.native;
|
|
121428
|
+
var wt = { lstatSync: wi, readdir: yi, readdirSync: bi, readlinkSync: Si, realpathSync: vi, promises: { lstat: Ci, readdir: Ti, readlink: Ai, realpath: ki } };
|
|
121429
|
+
var Ue = (n2) => !n2 || n2 === wt || n2 === xi ? wt : { ...wt, ...n2, promises: { ...wt.promises, ...n2.promises || {} } };
|
|
121430
|
+
var $e = /^\\\\\?\\([a-z]:)\\?$/i;
|
|
121431
|
+
var Ri = (n2) => n2.replace(/\//g, "\\").replace($e, "$1\\");
|
|
121432
|
+
var Oi = /[\\\/]/;
|
|
121433
|
+
var L = 0;
|
|
121434
|
+
var Ge = 1;
|
|
121435
|
+
var He = 2;
|
|
121436
|
+
var U = 4;
|
|
121437
|
+
var qe = 6;
|
|
121438
|
+
var Ke = 8;
|
|
121439
|
+
var X = 10;
|
|
121440
|
+
var Ve = 12;
|
|
121441
|
+
var _ = 15;
|
|
121442
|
+
var gt = ~_;
|
|
121443
|
+
var se = 16;
|
|
121444
|
+
var je = 32;
|
|
121445
|
+
var yt = 64;
|
|
121446
|
+
var j = 128;
|
|
121447
|
+
var Nt = 256;
|
|
121448
|
+
var Lt = 512;
|
|
121449
|
+
var Ie = yt | j | Lt;
|
|
121450
|
+
var Fi = 1023;
|
|
121451
|
+
var ie = (n2) => n2.isFile() ? Ke : n2.isDirectory() ? U : n2.isSymbolicLink() ? X : n2.isCharacterDevice() ? He : n2.isBlockDevice() ? qe : n2.isSocket() ? Ve : n2.isFIFO() ? Ge : L;
|
|
121452
|
+
var ze = new ft({ max: 2 ** 12 });
|
|
121453
|
+
var bt = (n2) => {
|
|
121454
|
+
let t = ze.get(n2);
|
|
121455
|
+
if (t)
|
|
121456
|
+
return t;
|
|
121457
|
+
let e = n2.normalize("NFKD");
|
|
121458
|
+
return ze.set(n2, e), e;
|
|
121459
|
+
};
|
|
121460
|
+
var Be = new ft({ max: 2 ** 12 });
|
|
121461
|
+
var _t = (n2) => {
|
|
121462
|
+
let t = Be.get(n2);
|
|
121463
|
+
if (t)
|
|
121464
|
+
return t;
|
|
121465
|
+
let e = bt(n2.toLowerCase());
|
|
121466
|
+
return Be.set(n2, e), e;
|
|
121467
|
+
};
|
|
121468
|
+
var Wt = class extends ft {
|
|
121469
|
+
constructor() {
|
|
121470
|
+
super({ max: 256 });
|
|
121471
|
+
}
|
|
121472
|
+
};
|
|
121473
|
+
var ne = class extends ft {
|
|
121474
|
+
constructor(t = 16 * 1024) {
|
|
121475
|
+
super({ maxSize: t, sizeCalculation: (e) => e.length + 1 });
|
|
121476
|
+
}
|
|
121477
|
+
};
|
|
121478
|
+
var Ye = Symbol("PathScurry setAsCwd");
|
|
121479
|
+
var R = class {
|
|
121480
|
+
name;
|
|
121481
|
+
root;
|
|
121482
|
+
roots;
|
|
121483
|
+
parent;
|
|
121484
|
+
nocase;
|
|
121485
|
+
isCWD = false;
|
|
121486
|
+
#t;
|
|
121487
|
+
#s;
|
|
121488
|
+
get dev() {
|
|
121489
|
+
return this.#s;
|
|
121490
|
+
}
|
|
121491
|
+
#n;
|
|
121492
|
+
get mode() {
|
|
121493
|
+
return this.#n;
|
|
121494
|
+
}
|
|
121495
|
+
#r;
|
|
121496
|
+
get nlink() {
|
|
121497
|
+
return this.#r;
|
|
121498
|
+
}
|
|
121499
|
+
#o;
|
|
121500
|
+
get uid() {
|
|
121501
|
+
return this.#o;
|
|
121502
|
+
}
|
|
121503
|
+
#S;
|
|
121504
|
+
get gid() {
|
|
121505
|
+
return this.#S;
|
|
121506
|
+
}
|
|
121507
|
+
#w;
|
|
121508
|
+
get rdev() {
|
|
121509
|
+
return this.#w;
|
|
121510
|
+
}
|
|
121511
|
+
#c;
|
|
121512
|
+
get blksize() {
|
|
121513
|
+
return this.#c;
|
|
121514
|
+
}
|
|
121515
|
+
#h;
|
|
121516
|
+
get ino() {
|
|
121517
|
+
return this.#h;
|
|
121518
|
+
}
|
|
121519
|
+
#u;
|
|
121520
|
+
get size() {
|
|
121521
|
+
return this.#u;
|
|
121522
|
+
}
|
|
121523
|
+
#f;
|
|
121524
|
+
get blocks() {
|
|
121525
|
+
return this.#f;
|
|
121526
|
+
}
|
|
121527
|
+
#a;
|
|
121528
|
+
get atimeMs() {
|
|
121529
|
+
return this.#a;
|
|
121530
|
+
}
|
|
121531
|
+
#i;
|
|
121532
|
+
get mtimeMs() {
|
|
121533
|
+
return this.#i;
|
|
121534
|
+
}
|
|
121535
|
+
#d;
|
|
121536
|
+
get ctimeMs() {
|
|
121537
|
+
return this.#d;
|
|
121538
|
+
}
|
|
121539
|
+
#E;
|
|
121540
|
+
get birthtimeMs() {
|
|
121541
|
+
return this.#E;
|
|
121542
|
+
}
|
|
121543
|
+
#b;
|
|
121544
|
+
get atime() {
|
|
121545
|
+
return this.#b;
|
|
121546
|
+
}
|
|
121547
|
+
#p;
|
|
121548
|
+
get mtime() {
|
|
121549
|
+
return this.#p;
|
|
121550
|
+
}
|
|
121551
|
+
#R;
|
|
121552
|
+
get ctime() {
|
|
121553
|
+
return this.#R;
|
|
121554
|
+
}
|
|
121555
|
+
#m;
|
|
121556
|
+
get birthtime() {
|
|
121557
|
+
return this.#m;
|
|
121558
|
+
}
|
|
121559
|
+
#C;
|
|
121560
|
+
#T;
|
|
121561
|
+
#g;
|
|
121562
|
+
#y;
|
|
121563
|
+
#x;
|
|
121564
|
+
#A;
|
|
121565
|
+
#e;
|
|
121566
|
+
#_;
|
|
121567
|
+
#M;
|
|
121568
|
+
#k;
|
|
121569
|
+
get parentPath() {
|
|
121570
|
+
return (this.parent || this).fullpath();
|
|
121571
|
+
}
|
|
121572
|
+
get path() {
|
|
121573
|
+
return this.parentPath;
|
|
121574
|
+
}
|
|
121575
|
+
constructor(t, e = L, s, i, r, o, h) {
|
|
121576
|
+
this.name = t, this.#C = r ? _t(t) : bt(t), this.#e = e & Fi, this.nocase = r, this.roots = i, this.root = s || this, this.#_ = o, this.#g = h.fullpath, this.#x = h.relative, this.#A = h.relativePosix, this.parent = h.parent, this.parent ? this.#t = this.parent.#t : this.#t = Ue(h.fs);
|
|
121577
|
+
}
|
|
121578
|
+
depth() {
|
|
121579
|
+
return this.#T !== undefined ? this.#T : this.parent ? this.#T = this.parent.depth() + 1 : this.#T = 0;
|
|
121580
|
+
}
|
|
121581
|
+
childrenCache() {
|
|
121582
|
+
return this.#_;
|
|
121583
|
+
}
|
|
121584
|
+
resolve(t) {
|
|
121585
|
+
if (!t)
|
|
121586
|
+
return this;
|
|
121587
|
+
let e = this.getRootString(t), i = t.substring(e.length).split(this.splitSep);
|
|
121588
|
+
return e ? this.getRoot(e).#N(i) : this.#N(i);
|
|
121589
|
+
}
|
|
121590
|
+
#N(t) {
|
|
121591
|
+
let e = this;
|
|
121592
|
+
for (let s of t)
|
|
121593
|
+
e = e.child(s);
|
|
121594
|
+
return e;
|
|
121595
|
+
}
|
|
121596
|
+
children() {
|
|
121597
|
+
let t = this.#_.get(this);
|
|
121598
|
+
if (t)
|
|
121599
|
+
return t;
|
|
121600
|
+
let e = Object.assign([], { provisional: 0 });
|
|
121601
|
+
return this.#_.set(this, e), this.#e &= ~se, e;
|
|
121602
|
+
}
|
|
121603
|
+
child(t, e) {
|
|
121604
|
+
if (t === "" || t === ".")
|
|
121605
|
+
return this;
|
|
121606
|
+
if (t === "..")
|
|
121607
|
+
return this.parent || this;
|
|
121608
|
+
let s = this.children(), i = this.nocase ? _t(t) : bt(t);
|
|
121609
|
+
for (let a of s)
|
|
121610
|
+
if (a.#C === i)
|
|
121611
|
+
return a;
|
|
121612
|
+
let r = this.parent ? this.sep : "", o = this.#g ? this.#g + r + t : undefined, h = this.newChild(t, L, { ...e, parent: this, fullpath: o });
|
|
121613
|
+
return this.canReaddir() || (h.#e |= j), s.push(h), h;
|
|
121614
|
+
}
|
|
121615
|
+
relative() {
|
|
121616
|
+
if (this.isCWD)
|
|
121617
|
+
return "";
|
|
121618
|
+
if (this.#x !== undefined)
|
|
121619
|
+
return this.#x;
|
|
121620
|
+
let t = this.name, e = this.parent;
|
|
121621
|
+
if (!e)
|
|
121622
|
+
return this.#x = this.name;
|
|
121623
|
+
let s = e.relative();
|
|
121624
|
+
return s + (!s || !e.parent ? "" : this.sep) + t;
|
|
121625
|
+
}
|
|
121626
|
+
relativePosix() {
|
|
121627
|
+
if (this.sep === "/")
|
|
121628
|
+
return this.relative();
|
|
121629
|
+
if (this.isCWD)
|
|
121630
|
+
return "";
|
|
121631
|
+
if (this.#A !== undefined)
|
|
121632
|
+
return this.#A;
|
|
121633
|
+
let t = this.name, e = this.parent;
|
|
121634
|
+
if (!e)
|
|
121635
|
+
return this.#A = this.fullpathPosix();
|
|
121636
|
+
let s = e.relativePosix();
|
|
121637
|
+
return s + (!s || !e.parent ? "" : "/") + t;
|
|
121638
|
+
}
|
|
121639
|
+
fullpath() {
|
|
121640
|
+
if (this.#g !== undefined)
|
|
121641
|
+
return this.#g;
|
|
121642
|
+
let t = this.name, e = this.parent;
|
|
121643
|
+
if (!e)
|
|
121644
|
+
return this.#g = this.name;
|
|
121645
|
+
let i = e.fullpath() + (e.parent ? this.sep : "") + t;
|
|
121646
|
+
return this.#g = i;
|
|
121647
|
+
}
|
|
121648
|
+
fullpathPosix() {
|
|
121649
|
+
if (this.#y !== undefined)
|
|
121650
|
+
return this.#y;
|
|
121651
|
+
if (this.sep === "/")
|
|
121652
|
+
return this.#y = this.fullpath();
|
|
121653
|
+
if (!this.parent) {
|
|
121654
|
+
let i = this.fullpath().replace(/\\/g, "/");
|
|
121655
|
+
return /^[a-z]:\//i.test(i) ? this.#y = `//?/${i}` : this.#y = i;
|
|
121656
|
+
}
|
|
121657
|
+
let t = this.parent, e = t.fullpathPosix(), s = e + (!e || !t.parent ? "" : "/") + this.name;
|
|
121658
|
+
return this.#y = s;
|
|
121659
|
+
}
|
|
121660
|
+
isUnknown() {
|
|
121661
|
+
return (this.#e & _) === L;
|
|
121662
|
+
}
|
|
121663
|
+
isType(t) {
|
|
121664
|
+
return this[`is${t}`]();
|
|
121665
|
+
}
|
|
121666
|
+
getType() {
|
|
121667
|
+
return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : this.isSocket() ? "Socket" : "Unknown";
|
|
121668
|
+
}
|
|
121669
|
+
isFile() {
|
|
121670
|
+
return (this.#e & _) === Ke;
|
|
121671
|
+
}
|
|
121672
|
+
isDirectory() {
|
|
121673
|
+
return (this.#e & _) === U;
|
|
121674
|
+
}
|
|
121675
|
+
isCharacterDevice() {
|
|
121676
|
+
return (this.#e & _) === He;
|
|
121677
|
+
}
|
|
121678
|
+
isBlockDevice() {
|
|
121679
|
+
return (this.#e & _) === qe;
|
|
121680
|
+
}
|
|
121681
|
+
isFIFO() {
|
|
121682
|
+
return (this.#e & _) === Ge;
|
|
121683
|
+
}
|
|
121684
|
+
isSocket() {
|
|
121685
|
+
return (this.#e & _) === Ve;
|
|
121686
|
+
}
|
|
121687
|
+
isSymbolicLink() {
|
|
121688
|
+
return (this.#e & X) === X;
|
|
121689
|
+
}
|
|
121690
|
+
lstatCached() {
|
|
121691
|
+
return this.#e & je ? this : undefined;
|
|
121692
|
+
}
|
|
121693
|
+
readlinkCached() {
|
|
121694
|
+
return this.#M;
|
|
121695
|
+
}
|
|
121696
|
+
realpathCached() {
|
|
121697
|
+
return this.#k;
|
|
121698
|
+
}
|
|
121699
|
+
readdirCached() {
|
|
121700
|
+
let t = this.children();
|
|
121701
|
+
return t.slice(0, t.provisional);
|
|
121702
|
+
}
|
|
121703
|
+
canReadlink() {
|
|
121704
|
+
if (this.#M)
|
|
121705
|
+
return true;
|
|
121706
|
+
if (!this.parent)
|
|
121707
|
+
return false;
|
|
121708
|
+
let t = this.#e & _;
|
|
121709
|
+
return !(t !== L && t !== X || this.#e & Nt || this.#e & j);
|
|
121710
|
+
}
|
|
121711
|
+
calledReaddir() {
|
|
121712
|
+
return !!(this.#e & se);
|
|
121713
|
+
}
|
|
121714
|
+
isENOENT() {
|
|
121715
|
+
return !!(this.#e & j);
|
|
121716
|
+
}
|
|
121717
|
+
isNamed(t) {
|
|
121718
|
+
return this.nocase ? this.#C === _t(t) : this.#C === bt(t);
|
|
121719
|
+
}
|
|
121720
|
+
async readlink() {
|
|
121721
|
+
let t = this.#M;
|
|
121722
|
+
if (t)
|
|
121723
|
+
return t;
|
|
121724
|
+
if (this.canReadlink() && this.parent)
|
|
121725
|
+
try {
|
|
121726
|
+
let e = await this.#t.promises.readlink(this.fullpath()), s = (await this.parent.realpath())?.resolve(e);
|
|
121727
|
+
if (s)
|
|
121728
|
+
return this.#M = s;
|
|
121729
|
+
} catch (e) {
|
|
121730
|
+
this.#D(e.code);
|
|
121731
|
+
return;
|
|
121732
|
+
}
|
|
121733
|
+
}
|
|
121734
|
+
readlinkSync() {
|
|
121735
|
+
let t = this.#M;
|
|
121736
|
+
if (t)
|
|
121737
|
+
return t;
|
|
121738
|
+
if (this.canReadlink() && this.parent)
|
|
121739
|
+
try {
|
|
121740
|
+
let e = this.#t.readlinkSync(this.fullpath()), s = this.parent.realpathSync()?.resolve(e);
|
|
121741
|
+
if (s)
|
|
121742
|
+
return this.#M = s;
|
|
121743
|
+
} catch (e) {
|
|
121744
|
+
this.#D(e.code);
|
|
121745
|
+
return;
|
|
121746
|
+
}
|
|
121747
|
+
}
|
|
121748
|
+
#j(t) {
|
|
121749
|
+
this.#e |= se;
|
|
121750
|
+
for (let e = t.provisional;e < t.length; e++) {
|
|
121751
|
+
let s = t[e];
|
|
121752
|
+
s && s.#v();
|
|
121753
|
+
}
|
|
121754
|
+
}
|
|
121755
|
+
#v() {
|
|
121756
|
+
this.#e & j || (this.#e = (this.#e | j) & gt, this.#G());
|
|
121757
|
+
}
|
|
121758
|
+
#G() {
|
|
121759
|
+
let t = this.children();
|
|
121760
|
+
t.provisional = 0;
|
|
121761
|
+
for (let e of t)
|
|
121762
|
+
e.#v();
|
|
121763
|
+
}
|
|
121764
|
+
#P() {
|
|
121765
|
+
this.#e |= Lt, this.#L();
|
|
121766
|
+
}
|
|
121767
|
+
#L() {
|
|
121768
|
+
if (this.#e & yt)
|
|
121769
|
+
return;
|
|
121770
|
+
let t = this.#e;
|
|
121771
|
+
(t & _) === U && (t &= gt), this.#e = t | yt, this.#G();
|
|
121772
|
+
}
|
|
121773
|
+
#I(t = "") {
|
|
121774
|
+
t === "ENOTDIR" || t === "EPERM" ? this.#L() : t === "ENOENT" ? this.#v() : this.children().provisional = 0;
|
|
121775
|
+
}
|
|
121776
|
+
#F(t = "") {
|
|
121777
|
+
t === "ENOTDIR" ? this.parent.#L() : t === "ENOENT" && this.#v();
|
|
121778
|
+
}
|
|
121779
|
+
#D(t = "") {
|
|
121780
|
+
let e = this.#e;
|
|
121781
|
+
e |= Nt, t === "ENOENT" && (e |= j), (t === "EINVAL" || t === "UNKNOWN") && (e &= gt), this.#e = e, t === "ENOTDIR" && this.parent && this.parent.#L();
|
|
121782
|
+
}
|
|
121783
|
+
#z(t, e) {
|
|
121784
|
+
return this.#U(t, e) || this.#B(t, e);
|
|
121785
|
+
}
|
|
121786
|
+
#B(t, e) {
|
|
121787
|
+
let s = ie(t), i = this.newChild(t.name, s, { parent: this }), r = i.#e & _;
|
|
121788
|
+
return r !== U && r !== X && r !== L && (i.#e |= yt), e.unshift(i), e.provisional++, i;
|
|
121789
|
+
}
|
|
121790
|
+
#U(t, e) {
|
|
121791
|
+
for (let s = e.provisional;s < e.length; s++) {
|
|
121792
|
+
let i = e[s];
|
|
121793
|
+
if ((this.nocase ? _t(t.name) : bt(t.name)) === i.#C)
|
|
121794
|
+
return this.#l(t, i, s, e);
|
|
121795
|
+
}
|
|
121796
|
+
}
|
|
121797
|
+
#l(t, e, s, i) {
|
|
121798
|
+
let r = e.name;
|
|
121799
|
+
return e.#e = e.#e & gt | ie(t), r !== t.name && (e.name = t.name), s !== i.provisional && (s === i.length - 1 ? i.pop() : i.splice(s, 1), i.unshift(e)), i.provisional++, e;
|
|
121800
|
+
}
|
|
121801
|
+
async lstat() {
|
|
121802
|
+
if ((this.#e & j) === 0)
|
|
121803
|
+
try {
|
|
121804
|
+
return this.#$(await this.#t.promises.lstat(this.fullpath())), this;
|
|
121805
|
+
} catch (t) {
|
|
121806
|
+
this.#F(t.code);
|
|
121807
|
+
}
|
|
121808
|
+
}
|
|
121809
|
+
lstatSync() {
|
|
121810
|
+
if ((this.#e & j) === 0)
|
|
121811
|
+
try {
|
|
121812
|
+
return this.#$(this.#t.lstatSync(this.fullpath())), this;
|
|
121813
|
+
} catch (t) {
|
|
121814
|
+
this.#F(t.code);
|
|
121815
|
+
}
|
|
121816
|
+
}
|
|
121817
|
+
#$(t) {
|
|
121818
|
+
let { atime: e, atimeMs: s, birthtime: i, birthtimeMs: r, blksize: o, blocks: h, ctime: a, ctimeMs: l, dev: u, gid: c, ino: d, mode: f, mtime: m, mtimeMs: p, nlink: w, rdev: g, size: S, uid: E } = t;
|
|
121819
|
+
this.#b = e, this.#a = s, this.#m = i, this.#E = r, this.#c = o, this.#f = h, this.#R = a, this.#d = l, this.#s = u, this.#S = c, this.#h = d, this.#n = f, this.#p = m, this.#i = p, this.#r = w, this.#w = g, this.#u = S, this.#o = E;
|
|
121820
|
+
let y = ie(t);
|
|
121821
|
+
this.#e = this.#e & gt | y | je, y !== L && y !== U && y !== X && (this.#e |= yt);
|
|
121822
|
+
}
|
|
121823
|
+
#W = [];
|
|
121824
|
+
#O = false;
|
|
121825
|
+
#H(t) {
|
|
121826
|
+
this.#O = false;
|
|
121827
|
+
let e = this.#W.slice();
|
|
121828
|
+
this.#W.length = 0, e.forEach((s) => s(null, t));
|
|
121829
|
+
}
|
|
121830
|
+
readdirCB(t, e = false) {
|
|
121831
|
+
if (!this.canReaddir()) {
|
|
121832
|
+
e ? t(null, []) : queueMicrotask(() => t(null, []));
|
|
121833
|
+
return;
|
|
121834
|
+
}
|
|
121835
|
+
let s = this.children();
|
|
121836
|
+
if (this.calledReaddir()) {
|
|
121837
|
+
let r = s.slice(0, s.provisional);
|
|
121838
|
+
e ? t(null, r) : queueMicrotask(() => t(null, r));
|
|
121839
|
+
return;
|
|
121840
|
+
}
|
|
121841
|
+
if (this.#W.push(t), this.#O)
|
|
121842
|
+
return;
|
|
121843
|
+
this.#O = true;
|
|
121844
|
+
let i = this.fullpath();
|
|
121845
|
+
this.#t.readdir(i, { withFileTypes: true }, (r, o) => {
|
|
121846
|
+
if (r)
|
|
121847
|
+
this.#I(r.code), s.provisional = 0;
|
|
121848
|
+
else {
|
|
121849
|
+
for (let h of o)
|
|
121850
|
+
this.#z(h, s);
|
|
121851
|
+
this.#j(s);
|
|
121852
|
+
}
|
|
121853
|
+
this.#H(s.slice(0, s.provisional));
|
|
121854
|
+
});
|
|
121855
|
+
}
|
|
121856
|
+
#q;
|
|
121857
|
+
async readdir() {
|
|
121858
|
+
if (!this.canReaddir())
|
|
121859
|
+
return [];
|
|
121860
|
+
let t = this.children();
|
|
121861
|
+
if (this.calledReaddir())
|
|
121862
|
+
return t.slice(0, t.provisional);
|
|
121863
|
+
let e = this.fullpath();
|
|
121864
|
+
if (this.#q)
|
|
121865
|
+
await this.#q;
|
|
121866
|
+
else {
|
|
121867
|
+
let s = () => {};
|
|
121868
|
+
this.#q = new Promise((i) => s = i);
|
|
121869
|
+
try {
|
|
121870
|
+
for (let i of await this.#t.promises.readdir(e, { withFileTypes: true }))
|
|
121871
|
+
this.#z(i, t);
|
|
121872
|
+
this.#j(t);
|
|
121873
|
+
} catch (i) {
|
|
121874
|
+
this.#I(i.code), t.provisional = 0;
|
|
121875
|
+
}
|
|
121876
|
+
this.#q = undefined, s();
|
|
121877
|
+
}
|
|
121878
|
+
return t.slice(0, t.provisional);
|
|
121879
|
+
}
|
|
121880
|
+
readdirSync() {
|
|
121881
|
+
if (!this.canReaddir())
|
|
121882
|
+
return [];
|
|
121883
|
+
let t = this.children();
|
|
121884
|
+
if (this.calledReaddir())
|
|
121885
|
+
return t.slice(0, t.provisional);
|
|
121886
|
+
let e = this.fullpath();
|
|
121887
|
+
try {
|
|
121888
|
+
for (let s of this.#t.readdirSync(e, { withFileTypes: true }))
|
|
121889
|
+
this.#z(s, t);
|
|
121890
|
+
this.#j(t);
|
|
121891
|
+
} catch (s) {
|
|
121892
|
+
this.#I(s.code), t.provisional = 0;
|
|
121893
|
+
}
|
|
121894
|
+
return t.slice(0, t.provisional);
|
|
121895
|
+
}
|
|
121896
|
+
canReaddir() {
|
|
121897
|
+
if (this.#e & Ie)
|
|
121898
|
+
return false;
|
|
121899
|
+
let t = _ & this.#e;
|
|
121900
|
+
return t === L || t === U || t === X;
|
|
121901
|
+
}
|
|
121902
|
+
shouldWalk(t, e) {
|
|
121903
|
+
return (this.#e & U) === U && !(this.#e & Ie) && !t.has(this) && (!e || e(this));
|
|
121904
|
+
}
|
|
121905
|
+
async realpath() {
|
|
121906
|
+
if (this.#k)
|
|
121907
|
+
return this.#k;
|
|
121908
|
+
if (!((Lt | Nt | j) & this.#e))
|
|
121909
|
+
try {
|
|
121910
|
+
let t = await this.#t.promises.realpath(this.fullpath());
|
|
121911
|
+
return this.#k = this.resolve(t);
|
|
121912
|
+
} catch {
|
|
121913
|
+
this.#P();
|
|
121914
|
+
}
|
|
121915
|
+
}
|
|
121916
|
+
realpathSync() {
|
|
121917
|
+
if (this.#k)
|
|
121918
|
+
return this.#k;
|
|
121919
|
+
if (!((Lt | Nt | j) & this.#e))
|
|
121920
|
+
try {
|
|
121921
|
+
let t = this.#t.realpathSync(this.fullpath());
|
|
121922
|
+
return this.#k = this.resolve(t);
|
|
121923
|
+
} catch {
|
|
121924
|
+
this.#P();
|
|
121925
|
+
}
|
|
121926
|
+
}
|
|
121927
|
+
[Ye](t) {
|
|
121928
|
+
if (t === this)
|
|
121929
|
+
return;
|
|
121930
|
+
t.isCWD = false, this.isCWD = true;
|
|
121931
|
+
let e = new Set([]), s = [], i = this;
|
|
121932
|
+
for (;i && i.parent; )
|
|
121933
|
+
e.add(i), i.#x = s.join(this.sep), i.#A = s.join("/"), i = i.parent, s.push("..");
|
|
121934
|
+
for (i = t;i && i.parent && !e.has(i); )
|
|
121935
|
+
i.#x = undefined, i.#A = undefined, i = i.parent;
|
|
121936
|
+
}
|
|
121937
|
+
};
|
|
121938
|
+
var Pt = class n2 extends R {
|
|
121939
|
+
sep = "\\";
|
|
121940
|
+
splitSep = Oi;
|
|
121941
|
+
constructor(t, e = L, s, i, r, o, h) {
|
|
121942
|
+
super(t, e, s, i, r, o, h);
|
|
121943
|
+
}
|
|
121944
|
+
newChild(t, e = L, s = {}) {
|
|
121945
|
+
return new n2(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
|
|
121946
|
+
}
|
|
121947
|
+
getRootString(t) {
|
|
121948
|
+
return re.parse(t).root;
|
|
121949
|
+
}
|
|
121950
|
+
getRoot(t) {
|
|
121951
|
+
if (t = Ri(t.toUpperCase()), t === this.root.name)
|
|
121952
|
+
return this.root;
|
|
121953
|
+
for (let [e, s] of Object.entries(this.roots))
|
|
121954
|
+
if (this.sameRoot(t, e))
|
|
121955
|
+
return this.roots[t] = s;
|
|
121956
|
+
return this.roots[t] = new it(t, this).root;
|
|
121957
|
+
}
|
|
121958
|
+
sameRoot(t, e = this.root.name) {
|
|
121959
|
+
return t = t.toUpperCase().replace(/\//g, "\\").replace($e, "$1\\"), t === e;
|
|
121960
|
+
}
|
|
121961
|
+
};
|
|
121962
|
+
var jt = class n3 extends R {
|
|
121963
|
+
splitSep = "/";
|
|
121964
|
+
sep = "/";
|
|
121965
|
+
constructor(t, e = L, s, i, r, o, h) {
|
|
121966
|
+
super(t, e, s, i, r, o, h);
|
|
121967
|
+
}
|
|
121968
|
+
getRootString(t) {
|
|
121969
|
+
return t.startsWith("/") ? "/" : "";
|
|
121970
|
+
}
|
|
121971
|
+
getRoot(t) {
|
|
121972
|
+
return this.root;
|
|
121973
|
+
}
|
|
121974
|
+
newChild(t, e = L, s = {}) {
|
|
121975
|
+
return new n3(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
|
|
121976
|
+
}
|
|
121977
|
+
};
|
|
121978
|
+
var It = class {
|
|
121979
|
+
root;
|
|
121980
|
+
rootPath;
|
|
121981
|
+
roots;
|
|
121982
|
+
cwd;
|
|
121983
|
+
#t;
|
|
121984
|
+
#s;
|
|
121985
|
+
#n;
|
|
121986
|
+
nocase;
|
|
121987
|
+
#r;
|
|
121988
|
+
constructor(t = process.cwd(), e, s, { nocase: i, childrenCacheSize: r = 16 * 1024, fs: o = wt } = {}) {
|
|
121989
|
+
this.#r = Ue(o), (t instanceof URL || t.startsWith("file://")) && (t = gi(t));
|
|
121990
|
+
let h = e.resolve(t);
|
|
121991
|
+
this.roots = Object.create(null), this.rootPath = this.parseRootPath(h), this.#t = new Wt, this.#s = new Wt, this.#n = new ne(r);
|
|
121992
|
+
let a = h.substring(this.rootPath.length).split(s);
|
|
121993
|
+
if (a.length === 1 && !a[0] && a.pop(), i === undefined)
|
|
121994
|
+
throw new TypeError("must provide nocase setting to PathScurryBase ctor");
|
|
121995
|
+
this.nocase = i, this.root = this.newRoot(this.#r), this.roots[this.rootPath] = this.root;
|
|
121996
|
+
let l = this.root, u = a.length - 1, c = e.sep, d = this.rootPath, f = false;
|
|
121997
|
+
for (let m of a) {
|
|
121998
|
+
let p = u--;
|
|
121999
|
+
l = l.child(m, { relative: new Array(p).fill("..").join(c), relativePosix: new Array(p).fill("..").join("/"), fullpath: d += (f ? "" : c) + m }), f = true;
|
|
122000
|
+
}
|
|
122001
|
+
this.cwd = l;
|
|
122002
|
+
}
|
|
122003
|
+
depth(t = this.cwd) {
|
|
122004
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.depth();
|
|
122005
|
+
}
|
|
122006
|
+
childrenCache() {
|
|
122007
|
+
return this.#n;
|
|
122008
|
+
}
|
|
122009
|
+
resolve(...t) {
|
|
122010
|
+
let e = "";
|
|
122011
|
+
for (let r = t.length - 1;r >= 0; r--) {
|
|
122012
|
+
let o = t[r];
|
|
122013
|
+
if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o)))
|
|
122014
|
+
break;
|
|
122015
|
+
}
|
|
122016
|
+
let s = this.#t.get(e);
|
|
122017
|
+
if (s !== undefined)
|
|
122018
|
+
return s;
|
|
122019
|
+
let i = this.cwd.resolve(e).fullpath();
|
|
122020
|
+
return this.#t.set(e, i), i;
|
|
122021
|
+
}
|
|
122022
|
+
resolvePosix(...t) {
|
|
122023
|
+
let e = "";
|
|
122024
|
+
for (let r = t.length - 1;r >= 0; r--) {
|
|
122025
|
+
let o = t[r];
|
|
122026
|
+
if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o)))
|
|
122027
|
+
break;
|
|
122028
|
+
}
|
|
122029
|
+
let s = this.#s.get(e);
|
|
122030
|
+
if (s !== undefined)
|
|
122031
|
+
return s;
|
|
122032
|
+
let i = this.cwd.resolve(e).fullpathPosix();
|
|
122033
|
+
return this.#s.set(e, i), i;
|
|
122034
|
+
}
|
|
122035
|
+
relative(t = this.cwd) {
|
|
122036
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.relative();
|
|
122037
|
+
}
|
|
122038
|
+
relativePosix(t = this.cwd) {
|
|
122039
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.relativePosix();
|
|
122040
|
+
}
|
|
122041
|
+
basename(t = this.cwd) {
|
|
122042
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.name;
|
|
122043
|
+
}
|
|
122044
|
+
dirname(t = this.cwd) {
|
|
122045
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), (t.parent || t).fullpath();
|
|
122046
|
+
}
|
|
122047
|
+
async readdir(t = this.cwd, e = { withFileTypes: true }) {
|
|
122048
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122049
|
+
let { withFileTypes: s } = e;
|
|
122050
|
+
if (t.canReaddir()) {
|
|
122051
|
+
let i = await t.readdir();
|
|
122052
|
+
return s ? i : i.map((r) => r.name);
|
|
122053
|
+
} else
|
|
122054
|
+
return [];
|
|
122055
|
+
}
|
|
122056
|
+
readdirSync(t = this.cwd, e = { withFileTypes: true }) {
|
|
122057
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122058
|
+
let { withFileTypes: s = true } = e;
|
|
122059
|
+
return t.canReaddir() ? s ? t.readdirSync() : t.readdirSync().map((i) => i.name) : [];
|
|
122060
|
+
}
|
|
122061
|
+
async lstat(t = this.cwd) {
|
|
122062
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstat();
|
|
122063
|
+
}
|
|
122064
|
+
lstatSync(t = this.cwd) {
|
|
122065
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstatSync();
|
|
122066
|
+
}
|
|
122067
|
+
async readlink(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
|
|
122068
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
122069
|
+
let s = await t.readlink();
|
|
122070
|
+
return e ? s : s?.fullpath();
|
|
122071
|
+
}
|
|
122072
|
+
readlinkSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
|
|
122073
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
122074
|
+
let s = t.readlinkSync();
|
|
122075
|
+
return e ? s : s?.fullpath();
|
|
122076
|
+
}
|
|
122077
|
+
async realpath(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
|
|
122078
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
122079
|
+
let s = await t.realpath();
|
|
122080
|
+
return e ? s : s?.fullpath();
|
|
122081
|
+
}
|
|
122082
|
+
realpathSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
|
|
122083
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
122084
|
+
let s = t.realpathSync();
|
|
122085
|
+
return e ? s : s?.fullpath();
|
|
122086
|
+
}
|
|
122087
|
+
async walk(t = this.cwd, e = {}) {
|
|
122088
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122089
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
|
|
122090
|
+
(!r || r(t)) && h.push(s ? t : t.fullpath());
|
|
122091
|
+
let a = new Set, l = (c, d) => {
|
|
122092
|
+
a.add(c), c.readdirCB((f, m) => {
|
|
122093
|
+
if (f)
|
|
122094
|
+
return d(f);
|
|
122095
|
+
let p = m.length;
|
|
122096
|
+
if (!p)
|
|
122097
|
+
return d();
|
|
122098
|
+
let w = () => {
|
|
122099
|
+
--p === 0 && d();
|
|
122100
|
+
};
|
|
122101
|
+
for (let g of m)
|
|
122102
|
+
(!r || r(g)) && h.push(s ? g : g.fullpath()), i && g.isSymbolicLink() ? g.realpath().then((S) => S?.isUnknown() ? S.lstat() : S).then((S) => S?.shouldWalk(a, o) ? l(S, w) : w()) : g.shouldWalk(a, o) ? l(g, w) : w();
|
|
122103
|
+
}, true);
|
|
122104
|
+
}, u = t;
|
|
122105
|
+
return new Promise((c, d) => {
|
|
122106
|
+
l(u, (f) => {
|
|
122107
|
+
if (f)
|
|
122108
|
+
return d(f);
|
|
122109
|
+
c(h);
|
|
122110
|
+
});
|
|
122111
|
+
});
|
|
122112
|
+
}
|
|
122113
|
+
walkSync(t = this.cwd, e = {}) {
|
|
122114
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122115
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
|
|
122116
|
+
(!r || r(t)) && h.push(s ? t : t.fullpath());
|
|
122117
|
+
let a = new Set([t]);
|
|
122118
|
+
for (let l of a) {
|
|
122119
|
+
let u = l.readdirSync();
|
|
122120
|
+
for (let c of u) {
|
|
122121
|
+
(!r || r(c)) && h.push(s ? c : c.fullpath());
|
|
122122
|
+
let d = c;
|
|
122123
|
+
if (c.isSymbolicLink()) {
|
|
122124
|
+
if (!(i && (d = c.realpathSync())))
|
|
122125
|
+
continue;
|
|
122126
|
+
d.isUnknown() && d.lstatSync();
|
|
122127
|
+
}
|
|
122128
|
+
d.shouldWalk(a, o) && a.add(d);
|
|
122129
|
+
}
|
|
122130
|
+
}
|
|
122131
|
+
return h;
|
|
122132
|
+
}
|
|
122133
|
+
[Symbol.asyncIterator]() {
|
|
122134
|
+
return this.iterate();
|
|
122135
|
+
}
|
|
122136
|
+
iterate(t = this.cwd, e = {}) {
|
|
122137
|
+
return typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd), this.stream(t, e)[Symbol.asyncIterator]();
|
|
122138
|
+
}
|
|
122139
|
+
[Symbol.iterator]() {
|
|
122140
|
+
return this.iterateSync();
|
|
122141
|
+
}
|
|
122142
|
+
*iterateSync(t = this.cwd, e = {}) {
|
|
122143
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122144
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e;
|
|
122145
|
+
(!r || r(t)) && (yield s ? t : t.fullpath());
|
|
122146
|
+
let h = new Set([t]);
|
|
122147
|
+
for (let a of h) {
|
|
122148
|
+
let l = a.readdirSync();
|
|
122149
|
+
for (let u of l) {
|
|
122150
|
+
(!r || r(u)) && (yield s ? u : u.fullpath());
|
|
122151
|
+
let c = u;
|
|
122152
|
+
if (u.isSymbolicLink()) {
|
|
122153
|
+
if (!(i && (c = u.realpathSync())))
|
|
122154
|
+
continue;
|
|
122155
|
+
c.isUnknown() && c.lstatSync();
|
|
122156
|
+
}
|
|
122157
|
+
c.shouldWalk(h, o) && h.add(c);
|
|
122158
|
+
}
|
|
122159
|
+
}
|
|
122160
|
+
}
|
|
122161
|
+
stream(t = this.cwd, e = {}) {
|
|
122162
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122163
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true });
|
|
122164
|
+
(!r || r(t)) && h.write(s ? t : t.fullpath());
|
|
122165
|
+
let a = new Set, l = [t], u = 0, c = () => {
|
|
122166
|
+
let d = false;
|
|
122167
|
+
for (;!d; ) {
|
|
122168
|
+
let f = l.shift();
|
|
122169
|
+
if (!f) {
|
|
122170
|
+
u === 0 && h.end();
|
|
122171
|
+
return;
|
|
122172
|
+
}
|
|
122173
|
+
u++, a.add(f);
|
|
122174
|
+
let m = (w, g, S = false) => {
|
|
122175
|
+
if (w)
|
|
122176
|
+
return h.emit("error", w);
|
|
122177
|
+
if (i && !S) {
|
|
122178
|
+
let E = [];
|
|
122179
|
+
for (let y of g)
|
|
122180
|
+
y.isSymbolicLink() && E.push(y.realpath().then((b) => b?.isUnknown() ? b.lstat() : b));
|
|
122181
|
+
if (E.length) {
|
|
122182
|
+
Promise.all(E).then(() => m(null, g, true));
|
|
122183
|
+
return;
|
|
122184
|
+
}
|
|
122185
|
+
}
|
|
122186
|
+
for (let E of g)
|
|
122187
|
+
E && (!r || r(E)) && (h.write(s ? E : E.fullpath()) || (d = true));
|
|
122188
|
+
u--;
|
|
122189
|
+
for (let E of g) {
|
|
122190
|
+
let y = E.realpathCached() || E;
|
|
122191
|
+
y.shouldWalk(a, o) && l.push(y);
|
|
122192
|
+
}
|
|
122193
|
+
d && !h.flowing ? h.once("drain", c) : p || c();
|
|
122194
|
+
}, p = true;
|
|
122195
|
+
f.readdirCB(m, true), p = false;
|
|
122196
|
+
}
|
|
122197
|
+
};
|
|
122198
|
+
return c(), h;
|
|
122199
|
+
}
|
|
122200
|
+
streamSync(t = this.cwd, e = {}) {
|
|
122201
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122202
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true }), a = new Set;
|
|
122203
|
+
(!r || r(t)) && h.write(s ? t : t.fullpath());
|
|
122204
|
+
let l = [t], u = 0, c = () => {
|
|
122205
|
+
let d = false;
|
|
122206
|
+
for (;!d; ) {
|
|
122207
|
+
let f = l.shift();
|
|
122208
|
+
if (!f) {
|
|
122209
|
+
u === 0 && h.end();
|
|
122210
|
+
return;
|
|
122211
|
+
}
|
|
122212
|
+
u++, a.add(f);
|
|
122213
|
+
let m = f.readdirSync();
|
|
122214
|
+
for (let p of m)
|
|
122215
|
+
(!r || r(p)) && (h.write(s ? p : p.fullpath()) || (d = true));
|
|
122216
|
+
u--;
|
|
122217
|
+
for (let p of m) {
|
|
122218
|
+
let w = p;
|
|
122219
|
+
if (p.isSymbolicLink()) {
|
|
122220
|
+
if (!(i && (w = p.realpathSync())))
|
|
122221
|
+
continue;
|
|
122222
|
+
w.isUnknown() && w.lstatSync();
|
|
122223
|
+
}
|
|
122224
|
+
w.shouldWalk(a, o) && l.push(w);
|
|
122225
|
+
}
|
|
122226
|
+
}
|
|
122227
|
+
d && !h.flowing && h.once("drain", c);
|
|
122228
|
+
};
|
|
122229
|
+
return c(), h;
|
|
122230
|
+
}
|
|
122231
|
+
chdir(t = this.cwd) {
|
|
122232
|
+
let e = this.cwd;
|
|
122233
|
+
this.cwd = typeof t == "string" ? this.cwd.resolve(t) : t, this.cwd[Ye](e);
|
|
122234
|
+
}
|
|
122235
|
+
};
|
|
122236
|
+
var it = class extends It {
|
|
122237
|
+
sep = "\\";
|
|
122238
|
+
constructor(t = process.cwd(), e = {}) {
|
|
122239
|
+
let { nocase: s = true } = e;
|
|
122240
|
+
super(t, re, "\\", { ...e, nocase: s }), this.nocase = s;
|
|
122241
|
+
for (let i = this.cwd;i; i = i.parent)
|
|
122242
|
+
i.nocase = this.nocase;
|
|
122243
|
+
}
|
|
122244
|
+
parseRootPath(t) {
|
|
122245
|
+
return re.parse(t).root.toUpperCase();
|
|
122246
|
+
}
|
|
122247
|
+
newRoot(t) {
|
|
122248
|
+
return new Pt(this.rootPath, U, undefined, this.roots, this.nocase, this.childrenCache(), { fs: t });
|
|
122249
|
+
}
|
|
122250
|
+
isAbsolute(t) {
|
|
122251
|
+
return t.startsWith("/") || t.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(t);
|
|
122252
|
+
}
|
|
122253
|
+
};
|
|
122254
|
+
var rt = class extends It {
|
|
122255
|
+
sep = "/";
|
|
122256
|
+
constructor(t = process.cwd(), e = {}) {
|
|
122257
|
+
let { nocase: s = false } = e;
|
|
122258
|
+
super(t, mi, "/", { ...e, nocase: s }), this.nocase = s;
|
|
122259
|
+
}
|
|
122260
|
+
parseRootPath(t) {
|
|
122261
|
+
return "/";
|
|
122262
|
+
}
|
|
122263
|
+
newRoot(t) {
|
|
122264
|
+
return new jt(this.rootPath, U, undefined, this.roots, this.nocase, this.childrenCache(), { fs: t });
|
|
122265
|
+
}
|
|
122266
|
+
isAbsolute(t) {
|
|
122267
|
+
return t.startsWith("/");
|
|
122268
|
+
}
|
|
122269
|
+
};
|
|
122270
|
+
var St = class extends rt {
|
|
122271
|
+
constructor(t = process.cwd(), e = {}) {
|
|
122272
|
+
let { nocase: s = true } = e;
|
|
122273
|
+
super(t, { ...e, nocase: s });
|
|
122274
|
+
}
|
|
122275
|
+
};
|
|
122276
|
+
var Cr = process.platform === "win32" ? Pt : jt;
|
|
122277
|
+
var Xe = process.platform === "win32" ? it : process.platform === "darwin" ? St : rt;
|
|
122278
|
+
var Di = (n4) => n4.length >= 1;
|
|
122279
|
+
var Mi = (n4) => n4.length >= 1;
|
|
122280
|
+
var Ni = Symbol.for("nodejs.util.inspect.custom");
|
|
122281
|
+
var nt = class n4 {
|
|
122282
|
+
#t;
|
|
122283
|
+
#s;
|
|
122284
|
+
#n;
|
|
122285
|
+
length;
|
|
122286
|
+
#r;
|
|
122287
|
+
#o;
|
|
122288
|
+
#S;
|
|
122289
|
+
#w;
|
|
122290
|
+
#c;
|
|
122291
|
+
#h;
|
|
122292
|
+
#u = true;
|
|
122293
|
+
constructor(t, e, s, i) {
|
|
122294
|
+
if (!Di(t))
|
|
122295
|
+
throw new TypeError("empty pattern list");
|
|
122296
|
+
if (!Mi(e))
|
|
122297
|
+
throw new TypeError("empty glob list");
|
|
122298
|
+
if (e.length !== t.length)
|
|
122299
|
+
throw new TypeError("mismatched pattern list and glob list lengths");
|
|
122300
|
+
if (this.length = t.length, s < 0 || s >= this.length)
|
|
122301
|
+
throw new TypeError("index out of range");
|
|
122302
|
+
if (this.#t = t, this.#s = e, this.#n = s, this.#r = i, this.#n === 0) {
|
|
122303
|
+
if (this.isUNC()) {
|
|
122304
|
+
let [r, o, h, a, ...l] = this.#t, [u, c, d, f, ...m] = this.#s;
|
|
122305
|
+
l[0] === "" && (l.shift(), m.shift());
|
|
122306
|
+
let p = [r, o, h, a, ""].join("/"), w = [u, c, d, f, ""].join("/");
|
|
122307
|
+
this.#t = [p, ...l], this.#s = [w, ...m], this.length = this.#t.length;
|
|
122308
|
+
} else if (this.isDrive() || this.isAbsolute()) {
|
|
122309
|
+
let [r, ...o] = this.#t, [h, ...a] = this.#s;
|
|
122310
|
+
o[0] === "" && (o.shift(), a.shift());
|
|
122311
|
+
let l = r + "/", u = h + "/";
|
|
122312
|
+
this.#t = [l, ...o], this.#s = [u, ...a], this.length = this.#t.length;
|
|
122313
|
+
}
|
|
122314
|
+
}
|
|
122315
|
+
}
|
|
122316
|
+
[Ni]() {
|
|
122317
|
+
return "Pattern <" + this.#s.slice(this.#n).join("/") + ">";
|
|
122318
|
+
}
|
|
122319
|
+
pattern() {
|
|
122320
|
+
return this.#t[this.#n];
|
|
122321
|
+
}
|
|
122322
|
+
isString() {
|
|
122323
|
+
return typeof this.#t[this.#n] == "string";
|
|
122324
|
+
}
|
|
122325
|
+
isGlobstar() {
|
|
122326
|
+
return this.#t[this.#n] === A;
|
|
122327
|
+
}
|
|
122328
|
+
isRegExp() {
|
|
122329
|
+
return this.#t[this.#n] instanceof RegExp;
|
|
122330
|
+
}
|
|
122331
|
+
globString() {
|
|
122332
|
+
return this.#S = this.#S || (this.#n === 0 ? this.isAbsolute() ? this.#s[0] + this.#s.slice(1).join("/") : this.#s.join("/") : this.#s.slice(this.#n).join("/"));
|
|
122333
|
+
}
|
|
122334
|
+
hasMore() {
|
|
122335
|
+
return this.length > this.#n + 1;
|
|
122336
|
+
}
|
|
122337
|
+
rest() {
|
|
122338
|
+
return this.#o !== undefined ? this.#o : this.hasMore() ? (this.#o = new n4(this.#t, this.#s, this.#n + 1, this.#r), this.#o.#h = this.#h, this.#o.#c = this.#c, this.#o.#w = this.#w, this.#o) : this.#o = null;
|
|
122339
|
+
}
|
|
122340
|
+
isUNC() {
|
|
122341
|
+
let t = this.#t;
|
|
122342
|
+
return this.#c !== undefined ? this.#c : this.#c = this.#r === "win32" && this.#n === 0 && t[0] === "" && t[1] === "" && typeof t[2] == "string" && !!t[2] && typeof t[3] == "string" && !!t[3];
|
|
122343
|
+
}
|
|
122344
|
+
isDrive() {
|
|
122345
|
+
let t = this.#t;
|
|
122346
|
+
return this.#w !== undefined ? this.#w : this.#w = this.#r === "win32" && this.#n === 0 && this.length > 1 && typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]);
|
|
122347
|
+
}
|
|
122348
|
+
isAbsolute() {
|
|
122349
|
+
let t = this.#t;
|
|
122350
|
+
return this.#h !== undefined ? this.#h : this.#h = t[0] === "" && t.length > 1 || this.isDrive() || this.isUNC();
|
|
122351
|
+
}
|
|
122352
|
+
root() {
|
|
122353
|
+
let t = this.#t[0];
|
|
122354
|
+
return typeof t == "string" && this.isAbsolute() && this.#n === 0 ? t : "";
|
|
122355
|
+
}
|
|
122356
|
+
checkFollowGlobstar() {
|
|
122357
|
+
return !(this.#n === 0 || !this.isGlobstar() || !this.#u);
|
|
122358
|
+
}
|
|
122359
|
+
markFollowGlobstar() {
|
|
122360
|
+
return this.#n === 0 || !this.isGlobstar() || !this.#u ? false : (this.#u = false, true);
|
|
122361
|
+
}
|
|
122362
|
+
};
|
|
122363
|
+
var _i = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
|
|
122364
|
+
var ot = class {
|
|
122365
|
+
relative;
|
|
122366
|
+
relativeChildren;
|
|
122367
|
+
absolute;
|
|
122368
|
+
absoluteChildren;
|
|
122369
|
+
platform;
|
|
122370
|
+
mmopts;
|
|
122371
|
+
constructor(t, { nobrace: e, nocase: s, noext: i, noglobstar: r, platform: o = _i }) {
|
|
122372
|
+
this.relative = [], this.absolute = [], this.relativeChildren = [], this.absoluteChildren = [], this.platform = o, this.mmopts = { dot: true, nobrace: e, nocase: s, noext: i, noglobstar: r, optimizationLevel: 2, platform: o, nocomment: true, nonegate: true };
|
|
122373
|
+
for (let h of t)
|
|
122374
|
+
this.add(h);
|
|
122375
|
+
}
|
|
122376
|
+
add(t) {
|
|
122377
|
+
let e = new D(t, this.mmopts);
|
|
122378
|
+
for (let s = 0;s < e.set.length; s++) {
|
|
122379
|
+
let i = e.set[s], r = e.globParts[s];
|
|
122380
|
+
if (!i || !r)
|
|
122381
|
+
throw new Error("invalid pattern object");
|
|
122382
|
+
for (;i[0] === "." && r[0] === "."; )
|
|
122383
|
+
i.shift(), r.shift();
|
|
122384
|
+
let o = new nt(i, r, 0, this.platform), h = new D(o.globString(), this.mmopts), a = r[r.length - 1] === "**", l = o.isAbsolute();
|
|
122385
|
+
l ? this.absolute.push(h) : this.relative.push(h), a && (l ? this.absoluteChildren.push(h) : this.relativeChildren.push(h));
|
|
122386
|
+
}
|
|
122387
|
+
}
|
|
122388
|
+
ignored(t) {
|
|
122389
|
+
let e = t.fullpath(), s = `${e}/`, i = t.relative() || ".", r = `${i}/`;
|
|
122390
|
+
for (let o of this.relative)
|
|
122391
|
+
if (o.match(i) || o.match(r))
|
|
122392
|
+
return true;
|
|
122393
|
+
for (let o of this.absolute)
|
|
122394
|
+
if (o.match(e) || o.match(s))
|
|
122395
|
+
return true;
|
|
122396
|
+
return false;
|
|
122397
|
+
}
|
|
122398
|
+
childrenIgnored(t) {
|
|
122399
|
+
let e = t.fullpath() + "/", s = (t.relative() || ".") + "/";
|
|
122400
|
+
for (let i of this.relativeChildren)
|
|
122401
|
+
if (i.match(s))
|
|
122402
|
+
return true;
|
|
122403
|
+
for (let i of this.absoluteChildren)
|
|
122404
|
+
if (i.match(e))
|
|
122405
|
+
return true;
|
|
122406
|
+
return false;
|
|
122407
|
+
}
|
|
122408
|
+
};
|
|
122409
|
+
var oe = class n5 {
|
|
122410
|
+
store;
|
|
122411
|
+
constructor(t = new Map) {
|
|
122412
|
+
this.store = t;
|
|
122413
|
+
}
|
|
122414
|
+
copy() {
|
|
122415
|
+
return new n5(new Map(this.store));
|
|
122416
|
+
}
|
|
122417
|
+
hasWalked(t, e) {
|
|
122418
|
+
return this.store.get(t.fullpath())?.has(e.globString());
|
|
122419
|
+
}
|
|
122420
|
+
storeWalked(t, e) {
|
|
122421
|
+
let s = t.fullpath(), i = this.store.get(s);
|
|
122422
|
+
i ? i.add(e.globString()) : this.store.set(s, new Set([e.globString()]));
|
|
122423
|
+
}
|
|
122424
|
+
};
|
|
122425
|
+
var he = class {
|
|
122426
|
+
store = new Map;
|
|
122427
|
+
add(t, e, s) {
|
|
122428
|
+
let i = (e ? 2 : 0) | (s ? 1 : 0), r = this.store.get(t);
|
|
122429
|
+
this.store.set(t, r === undefined ? i : i & r);
|
|
122430
|
+
}
|
|
122431
|
+
entries() {
|
|
122432
|
+
return [...this.store.entries()].map(([t, e]) => [t, !!(e & 2), !!(e & 1)]);
|
|
122433
|
+
}
|
|
122434
|
+
};
|
|
122435
|
+
var ae = class {
|
|
122436
|
+
store = new Map;
|
|
122437
|
+
add(t, e) {
|
|
122438
|
+
if (!t.canReaddir())
|
|
122439
|
+
return;
|
|
122440
|
+
let s = this.store.get(t);
|
|
122441
|
+
s ? s.find((i) => i.globString() === e.globString()) || s.push(e) : this.store.set(t, [e]);
|
|
122442
|
+
}
|
|
122443
|
+
get(t) {
|
|
122444
|
+
let e = this.store.get(t);
|
|
122445
|
+
if (!e)
|
|
122446
|
+
throw new Error("attempting to walk unknown path");
|
|
122447
|
+
return e;
|
|
122448
|
+
}
|
|
122449
|
+
entries() {
|
|
122450
|
+
return this.keys().map((t) => [t, this.store.get(t)]);
|
|
122451
|
+
}
|
|
122452
|
+
keys() {
|
|
122453
|
+
return [...this.store.keys()].filter((t) => t.canReaddir());
|
|
122454
|
+
}
|
|
122455
|
+
};
|
|
122456
|
+
var Et = class n6 {
|
|
122457
|
+
hasWalkedCache;
|
|
122458
|
+
matches = new he;
|
|
122459
|
+
subwalks = new ae;
|
|
122460
|
+
patterns;
|
|
122461
|
+
follow;
|
|
122462
|
+
dot;
|
|
122463
|
+
opts;
|
|
122464
|
+
constructor(t, e) {
|
|
122465
|
+
this.opts = t, this.follow = !!t.follow, this.dot = !!t.dot, this.hasWalkedCache = e ? e.copy() : new oe;
|
|
122466
|
+
}
|
|
122467
|
+
processPatterns(t, e) {
|
|
122468
|
+
this.patterns = e;
|
|
122469
|
+
let s = e.map((i) => [t, i]);
|
|
122470
|
+
for (let [i, r] of s) {
|
|
122471
|
+
this.hasWalkedCache.storeWalked(i, r);
|
|
122472
|
+
let o = r.root(), h = r.isAbsolute() && this.opts.absolute !== false;
|
|
122473
|
+
if (o) {
|
|
122474
|
+
i = i.resolve(o === "/" && this.opts.root !== undefined ? this.opts.root : o);
|
|
122475
|
+
let c = r.rest();
|
|
122476
|
+
if (c)
|
|
122477
|
+
r = c;
|
|
122478
|
+
else {
|
|
122479
|
+
this.matches.add(i, true, false);
|
|
122480
|
+
continue;
|
|
122481
|
+
}
|
|
122482
|
+
}
|
|
122483
|
+
if (i.isENOENT())
|
|
122484
|
+
continue;
|
|
122485
|
+
let a, l, u = false;
|
|
122486
|
+
for (;typeof (a = r.pattern()) == "string" && (l = r.rest()); )
|
|
122487
|
+
i = i.resolve(a), r = l, u = true;
|
|
122488
|
+
if (a = r.pattern(), l = r.rest(), u) {
|
|
122489
|
+
if (this.hasWalkedCache.hasWalked(i, r))
|
|
122490
|
+
continue;
|
|
122491
|
+
this.hasWalkedCache.storeWalked(i, r);
|
|
122492
|
+
}
|
|
122493
|
+
if (typeof a == "string") {
|
|
122494
|
+
let c = a === ".." || a === "" || a === ".";
|
|
122495
|
+
this.matches.add(i.resolve(a), h, c);
|
|
122496
|
+
continue;
|
|
122497
|
+
} else if (a === A) {
|
|
122498
|
+
(!i.isSymbolicLink() || this.follow || r.checkFollowGlobstar()) && this.subwalks.add(i, r);
|
|
122499
|
+
let c = l?.pattern(), d = l?.rest();
|
|
122500
|
+
if (!l || (c === "" || c === ".") && !d)
|
|
122501
|
+
this.matches.add(i, h, c === "" || c === ".");
|
|
122502
|
+
else if (c === "..") {
|
|
122503
|
+
let f = i.parent || i;
|
|
122504
|
+
d ? this.hasWalkedCache.hasWalked(f, d) || this.subwalks.add(f, d) : this.matches.add(f, h, true);
|
|
122505
|
+
}
|
|
122506
|
+
} else
|
|
122507
|
+
a instanceof RegExp && this.subwalks.add(i, r);
|
|
122508
|
+
}
|
|
122509
|
+
return this;
|
|
122510
|
+
}
|
|
122511
|
+
subwalkTargets() {
|
|
122512
|
+
return this.subwalks.keys();
|
|
122513
|
+
}
|
|
122514
|
+
child() {
|
|
122515
|
+
return new n6(this.opts, this.hasWalkedCache);
|
|
122516
|
+
}
|
|
122517
|
+
filterEntries(t, e) {
|
|
122518
|
+
let s = this.subwalks.get(t), i = this.child();
|
|
122519
|
+
for (let r of e)
|
|
122520
|
+
for (let o of s) {
|
|
122521
|
+
let h = o.isAbsolute(), a = o.pattern(), l = o.rest();
|
|
122522
|
+
a === A ? i.testGlobstar(r, o, l, h) : a instanceof RegExp ? i.testRegExp(r, a, l, h) : i.testString(r, a, l, h);
|
|
122523
|
+
}
|
|
122524
|
+
return i;
|
|
122525
|
+
}
|
|
122526
|
+
testGlobstar(t, e, s, i) {
|
|
122527
|
+
if ((this.dot || !t.name.startsWith(".")) && (e.hasMore() || this.matches.add(t, i, false), t.canReaddir() && (this.follow || !t.isSymbolicLink() ? this.subwalks.add(t, e) : t.isSymbolicLink() && (s && e.checkFollowGlobstar() ? this.subwalks.add(t, s) : e.markFollowGlobstar() && this.subwalks.add(t, e)))), s) {
|
|
122528
|
+
let r = s.pattern();
|
|
122529
|
+
if (typeof r == "string" && r !== ".." && r !== "" && r !== ".")
|
|
122530
|
+
this.testString(t, r, s.rest(), i);
|
|
122531
|
+
else if (r === "..") {
|
|
122532
|
+
let o = t.parent || t;
|
|
122533
|
+
this.subwalks.add(o, s);
|
|
122534
|
+
} else
|
|
122535
|
+
r instanceof RegExp && this.testRegExp(t, r, s.rest(), i);
|
|
122536
|
+
}
|
|
122537
|
+
}
|
|
122538
|
+
testRegExp(t, e, s, i) {
|
|
122539
|
+
e.test(t.name) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
|
|
122540
|
+
}
|
|
122541
|
+
testString(t, e, s, i) {
|
|
122542
|
+
t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
|
|
122543
|
+
}
|
|
122544
|
+
};
|
|
122545
|
+
var Li = (n7, t) => typeof n7 == "string" ? new ot([n7], t) : Array.isArray(n7) ? new ot(n7, t) : n7;
|
|
122546
|
+
var zt = class {
|
|
122547
|
+
path;
|
|
122548
|
+
patterns;
|
|
122549
|
+
opts;
|
|
122550
|
+
seen = new Set;
|
|
122551
|
+
paused = false;
|
|
122552
|
+
aborted = false;
|
|
122553
|
+
#t = [];
|
|
122554
|
+
#s;
|
|
122555
|
+
#n;
|
|
122556
|
+
signal;
|
|
122557
|
+
maxDepth;
|
|
122558
|
+
includeChildMatches;
|
|
122559
|
+
constructor(t, e, s) {
|
|
122560
|
+
if (this.patterns = t, this.path = e, this.opts = s, this.#n = !s.posix && s.platform === "win32" ? "\\" : "/", this.includeChildMatches = s.includeChildMatches !== false, (s.ignore || !this.includeChildMatches) && (this.#s = Li(s.ignore ?? [], s), !this.includeChildMatches && typeof this.#s.add != "function")) {
|
|
122561
|
+
let i = "cannot ignore child matches, ignore lacks add() method.";
|
|
122562
|
+
throw new Error(i);
|
|
122563
|
+
}
|
|
122564
|
+
this.maxDepth = s.maxDepth || 1 / 0, s.signal && (this.signal = s.signal, this.signal.addEventListener("abort", () => {
|
|
122565
|
+
this.#t.length = 0;
|
|
122566
|
+
}));
|
|
122567
|
+
}
|
|
122568
|
+
#r(t) {
|
|
122569
|
+
return this.seen.has(t) || !!this.#s?.ignored?.(t);
|
|
122570
|
+
}
|
|
122571
|
+
#o(t) {
|
|
122572
|
+
return !!this.#s?.childrenIgnored?.(t);
|
|
122573
|
+
}
|
|
122574
|
+
pause() {
|
|
122575
|
+
this.paused = true;
|
|
122576
|
+
}
|
|
122577
|
+
resume() {
|
|
122578
|
+
if (this.signal?.aborted)
|
|
122579
|
+
return;
|
|
122580
|
+
this.paused = false;
|
|
122581
|
+
let t;
|
|
122582
|
+
for (;!this.paused && (t = this.#t.shift()); )
|
|
122583
|
+
t();
|
|
122584
|
+
}
|
|
122585
|
+
onResume(t) {
|
|
122586
|
+
this.signal?.aborted || (this.paused ? this.#t.push(t) : t());
|
|
122587
|
+
}
|
|
122588
|
+
async matchCheck(t, e) {
|
|
122589
|
+
if (e && this.opts.nodir)
|
|
122590
|
+
return;
|
|
122591
|
+
let s;
|
|
122592
|
+
if (this.opts.realpath) {
|
|
122593
|
+
if (s = t.realpathCached() || await t.realpath(), !s)
|
|
122594
|
+
return;
|
|
122595
|
+
t = s;
|
|
122596
|
+
}
|
|
122597
|
+
let r = t.isUnknown() || this.opts.stat ? await t.lstat() : t;
|
|
122598
|
+
if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
|
|
122599
|
+
let o = await r.realpath();
|
|
122600
|
+
o && (o.isUnknown() || this.opts.stat) && await o.lstat();
|
|
122601
|
+
}
|
|
122602
|
+
return this.matchCheckTest(r, e);
|
|
122603
|
+
}
|
|
122604
|
+
matchCheckTest(t, e) {
|
|
122605
|
+
return t && (this.maxDepth === 1 / 0 || t.depth() <= this.maxDepth) && (!e || t.canReaddir()) && (!this.opts.nodir || !t.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !t.isSymbolicLink() || !t.realpathCached()?.isDirectory()) && !this.#r(t) ? t : undefined;
|
|
122606
|
+
}
|
|
122607
|
+
matchCheckSync(t, e) {
|
|
122608
|
+
if (e && this.opts.nodir)
|
|
122609
|
+
return;
|
|
122610
|
+
let s;
|
|
122611
|
+
if (this.opts.realpath) {
|
|
122612
|
+
if (s = t.realpathCached() || t.realpathSync(), !s)
|
|
122613
|
+
return;
|
|
122614
|
+
t = s;
|
|
122615
|
+
}
|
|
122616
|
+
let r = t.isUnknown() || this.opts.stat ? t.lstatSync() : t;
|
|
122617
|
+
if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
|
|
122618
|
+
let o = r.realpathSync();
|
|
122619
|
+
o && (o?.isUnknown() || this.opts.stat) && o.lstatSync();
|
|
122620
|
+
}
|
|
122621
|
+
return this.matchCheckTest(r, e);
|
|
122622
|
+
}
|
|
122623
|
+
matchFinish(t, e) {
|
|
122624
|
+
if (this.#r(t))
|
|
122625
|
+
return;
|
|
122626
|
+
if (!this.includeChildMatches && this.#s?.add) {
|
|
122627
|
+
let r = `${t.relativePosix()}/**`;
|
|
122628
|
+
this.#s.add(r);
|
|
122629
|
+
}
|
|
122630
|
+
let s = this.opts.absolute === undefined ? e : this.opts.absolute;
|
|
122631
|
+
this.seen.add(t);
|
|
122632
|
+
let i = this.opts.mark && t.isDirectory() ? this.#n : "";
|
|
122633
|
+
if (this.opts.withFileTypes)
|
|
122634
|
+
this.matchEmit(t);
|
|
122635
|
+
else if (s) {
|
|
122636
|
+
let r = this.opts.posix ? t.fullpathPosix() : t.fullpath();
|
|
122637
|
+
this.matchEmit(r + i);
|
|
122638
|
+
} else {
|
|
122639
|
+
let r = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !r.startsWith(".." + this.#n) ? "." + this.#n : "";
|
|
122640
|
+
this.matchEmit(r ? o + r + i : "." + i);
|
|
122641
|
+
}
|
|
122642
|
+
}
|
|
122643
|
+
async match(t, e, s) {
|
|
122644
|
+
let i = await this.matchCheck(t, s);
|
|
122645
|
+
i && this.matchFinish(i, e);
|
|
122646
|
+
}
|
|
122647
|
+
matchSync(t, e, s) {
|
|
122648
|
+
let i = this.matchCheckSync(t, s);
|
|
122649
|
+
i && this.matchFinish(i, e);
|
|
122650
|
+
}
|
|
122651
|
+
walkCB(t, e, s) {
|
|
122652
|
+
this.signal?.aborted && s(), this.walkCB2(t, e, new Et(this.opts), s);
|
|
122653
|
+
}
|
|
122654
|
+
walkCB2(t, e, s, i) {
|
|
122655
|
+
if (this.#o(t))
|
|
122656
|
+
return i();
|
|
122657
|
+
if (this.signal?.aborted && i(), this.paused) {
|
|
122658
|
+
this.onResume(() => this.walkCB2(t, e, s, i));
|
|
122659
|
+
return;
|
|
122660
|
+
}
|
|
122661
|
+
s.processPatterns(t, e);
|
|
122662
|
+
let r = 1, o = () => {
|
|
122663
|
+
--r === 0 && i();
|
|
122664
|
+
};
|
|
122665
|
+
for (let [h, a, l] of s.matches.entries())
|
|
122666
|
+
this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
|
|
122667
|
+
for (let h of s.subwalkTargets()) {
|
|
122668
|
+
if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth)
|
|
122669
|
+
continue;
|
|
122670
|
+
r++;
|
|
122671
|
+
let a = h.readdirCached();
|
|
122672
|
+
h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, u) => this.walkCB3(h, u, s, o), true);
|
|
122673
|
+
}
|
|
122674
|
+
o();
|
|
122675
|
+
}
|
|
122676
|
+
walkCB3(t, e, s, i) {
|
|
122677
|
+
s = s.filterEntries(t, e);
|
|
122678
|
+
let r = 1, o = () => {
|
|
122679
|
+
--r === 0 && i();
|
|
122680
|
+
};
|
|
122681
|
+
for (let [h, a, l] of s.matches.entries())
|
|
122682
|
+
this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
|
|
122683
|
+
for (let [h, a] of s.subwalks.entries())
|
|
122684
|
+
r++, this.walkCB2(h, a, s.child(), o);
|
|
122685
|
+
o();
|
|
122686
|
+
}
|
|
122687
|
+
walkCBSync(t, e, s) {
|
|
122688
|
+
this.signal?.aborted && s(), this.walkCB2Sync(t, e, new Et(this.opts), s);
|
|
122689
|
+
}
|
|
122690
|
+
walkCB2Sync(t, e, s, i) {
|
|
122691
|
+
if (this.#o(t))
|
|
122692
|
+
return i();
|
|
122693
|
+
if (this.signal?.aborted && i(), this.paused) {
|
|
122694
|
+
this.onResume(() => this.walkCB2Sync(t, e, s, i));
|
|
122695
|
+
return;
|
|
122696
|
+
}
|
|
122697
|
+
s.processPatterns(t, e);
|
|
122698
|
+
let r = 1, o = () => {
|
|
122699
|
+
--r === 0 && i();
|
|
122700
|
+
};
|
|
122701
|
+
for (let [h, a, l] of s.matches.entries())
|
|
122702
|
+
this.#r(h) || this.matchSync(h, a, l);
|
|
122703
|
+
for (let h of s.subwalkTargets()) {
|
|
122704
|
+
if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth)
|
|
122705
|
+
continue;
|
|
122706
|
+
r++;
|
|
122707
|
+
let a = h.readdirSync();
|
|
122708
|
+
this.walkCB3Sync(h, a, s, o);
|
|
122709
|
+
}
|
|
122710
|
+
o();
|
|
122711
|
+
}
|
|
122712
|
+
walkCB3Sync(t, e, s, i) {
|
|
122713
|
+
s = s.filterEntries(t, e);
|
|
122714
|
+
let r = 1, o = () => {
|
|
122715
|
+
--r === 0 && i();
|
|
122716
|
+
};
|
|
122717
|
+
for (let [h, a, l] of s.matches.entries())
|
|
122718
|
+
this.#r(h) || this.matchSync(h, a, l);
|
|
122719
|
+
for (let [h, a] of s.subwalks.entries())
|
|
122720
|
+
r++, this.walkCB2Sync(h, a, s.child(), o);
|
|
122721
|
+
o();
|
|
122722
|
+
}
|
|
122723
|
+
};
|
|
122724
|
+
var xt = class extends zt {
|
|
122725
|
+
matches = new Set;
|
|
122726
|
+
constructor(t, e, s) {
|
|
122727
|
+
super(t, e, s);
|
|
122728
|
+
}
|
|
122729
|
+
matchEmit(t) {
|
|
122730
|
+
this.matches.add(t);
|
|
122731
|
+
}
|
|
122732
|
+
async walk() {
|
|
122733
|
+
if (this.signal?.aborted)
|
|
122734
|
+
throw this.signal.reason;
|
|
122735
|
+
return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
|
|
122736
|
+
this.walkCB(this.path, this.patterns, () => {
|
|
122737
|
+
this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
|
|
122738
|
+
});
|
|
122739
|
+
}), this.matches;
|
|
122740
|
+
}
|
|
122741
|
+
walkSync() {
|
|
122742
|
+
if (this.signal?.aborted)
|
|
122743
|
+
throw this.signal.reason;
|
|
122744
|
+
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
|
|
122745
|
+
if (this.signal?.aborted)
|
|
122746
|
+
throw this.signal.reason;
|
|
122747
|
+
}), this.matches;
|
|
122748
|
+
}
|
|
122749
|
+
};
|
|
122750
|
+
var vt = class extends zt {
|
|
122751
|
+
results;
|
|
122752
|
+
constructor(t, e, s) {
|
|
122753
|
+
super(t, e, s), this.results = new V({ signal: this.signal, objectMode: true }), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
|
|
122754
|
+
}
|
|
122755
|
+
matchEmit(t) {
|
|
122756
|
+
this.results.write(t), this.results.flowing || this.pause();
|
|
122757
|
+
}
|
|
122758
|
+
stream() {
|
|
122759
|
+
let t = this.path;
|
|
122760
|
+
return t.isUnknown() ? t.lstat().then(() => {
|
|
122761
|
+
this.walkCB(t, this.patterns, () => this.results.end());
|
|
122762
|
+
}) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
|
|
122763
|
+
}
|
|
122764
|
+
streamSync() {
|
|
122765
|
+
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
|
|
122766
|
+
}
|
|
122767
|
+
};
|
|
122768
|
+
var Pi = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
|
|
122769
|
+
var I = class {
|
|
122770
|
+
absolute;
|
|
122771
|
+
cwd;
|
|
122772
|
+
root;
|
|
122773
|
+
dot;
|
|
122774
|
+
dotRelative;
|
|
122775
|
+
follow;
|
|
122776
|
+
ignore;
|
|
122777
|
+
magicalBraces;
|
|
122778
|
+
mark;
|
|
122779
|
+
matchBase;
|
|
122780
|
+
maxDepth;
|
|
122781
|
+
nobrace;
|
|
122782
|
+
nocase;
|
|
122783
|
+
nodir;
|
|
122784
|
+
noext;
|
|
122785
|
+
noglobstar;
|
|
122786
|
+
pattern;
|
|
122787
|
+
platform;
|
|
122788
|
+
realpath;
|
|
122789
|
+
scurry;
|
|
122790
|
+
stat;
|
|
122791
|
+
signal;
|
|
122792
|
+
windowsPathsNoEscape;
|
|
122793
|
+
withFileTypes;
|
|
122794
|
+
includeChildMatches;
|
|
122795
|
+
opts;
|
|
122796
|
+
patterns;
|
|
122797
|
+
constructor(t, e) {
|
|
122798
|
+
if (!e)
|
|
122799
|
+
throw new TypeError("glob options required");
|
|
122800
|
+
if (this.withFileTypes = !!e.withFileTypes, this.signal = e.signal, this.follow = !!e.follow, this.dot = !!e.dot, this.dotRelative = !!e.dotRelative, this.nodir = !!e.nodir, this.mark = !!e.mark, e.cwd ? (e.cwd instanceof URL || e.cwd.startsWith("file://")) && (e.cwd = Wi(e.cwd)) : this.cwd = "", this.cwd = e.cwd || "", this.root = e.root, this.magicalBraces = !!e.magicalBraces, this.nobrace = !!e.nobrace, this.noext = !!e.noext, this.realpath = !!e.realpath, this.absolute = e.absolute, this.includeChildMatches = e.includeChildMatches !== false, this.noglobstar = !!e.noglobstar, this.matchBase = !!e.matchBase, this.maxDepth = typeof e.maxDepth == "number" ? e.maxDepth : 1 / 0, this.stat = !!e.stat, this.ignore = e.ignore, this.withFileTypes && this.absolute !== undefined)
|
|
122801
|
+
throw new Error("cannot set absolute and withFileTypes:true");
|
|
122802
|
+
if (typeof t == "string" && (t = [t]), this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === false, this.windowsPathsNoEscape && (t = t.map((a) => a.replace(/\\/g, "/"))), this.matchBase) {
|
|
122803
|
+
if (e.noglobstar)
|
|
122804
|
+
throw new TypeError("base matching requires globstar");
|
|
122805
|
+
t = t.map((a) => a.includes("/") ? a : `./**/${a}`);
|
|
122806
|
+
}
|
|
122807
|
+
if (this.pattern = t, this.platform = e.platform || Pi, this.opts = { ...e, platform: this.platform }, e.scurry) {
|
|
122808
|
+
if (this.scurry = e.scurry, e.nocase !== undefined && e.nocase !== e.scurry.nocase)
|
|
122809
|
+
throw new Error("nocase option contradicts provided scurry option");
|
|
122810
|
+
} else {
|
|
122811
|
+
let a = e.platform === "win32" ? it : e.platform === "darwin" ? St : e.platform ? rt : Xe;
|
|
122812
|
+
this.scurry = new a(this.cwd, { nocase: e.nocase, fs: e.fs });
|
|
122813
|
+
}
|
|
122814
|
+
this.nocase = this.scurry.nocase;
|
|
122815
|
+
let s = this.platform === "darwin" || this.platform === "win32", i = { braceExpandMax: 1e4, ...e, dot: this.dot, matchBase: this.matchBase, nobrace: this.nobrace, nocase: this.nocase, nocaseMagicOnly: s, nocomment: true, noext: this.noext, nonegate: true, optimizationLevel: 2, platform: this.platform, windowsPathsNoEscape: this.windowsPathsNoEscape, debug: !!this.opts.debug }, r = this.pattern.map((a) => new D(a, i)), [o, h] = r.reduce((a, l) => (a[0].push(...l.set), a[1].push(...l.globParts), a), [[], []]);
|
|
122816
|
+
this.patterns = o.map((a, l) => {
|
|
122817
|
+
let u = h[l];
|
|
122818
|
+
if (!u)
|
|
122819
|
+
throw new Error("invalid pattern object");
|
|
122820
|
+
return new nt(a, u, 0, this.platform);
|
|
122821
|
+
});
|
|
122822
|
+
}
|
|
122823
|
+
async walk() {
|
|
122824
|
+
return [...await new xt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).walk()];
|
|
122825
|
+
}
|
|
122826
|
+
walkSync() {
|
|
122827
|
+
return [...new xt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).walkSync()];
|
|
122828
|
+
}
|
|
122829
|
+
stream() {
|
|
122830
|
+
return new vt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).stream();
|
|
122831
|
+
}
|
|
122832
|
+
streamSync() {
|
|
122833
|
+
return new vt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).streamSync();
|
|
122834
|
+
}
|
|
122835
|
+
iterateSync() {
|
|
122836
|
+
return this.streamSync()[Symbol.iterator]();
|
|
122837
|
+
}
|
|
122838
|
+
[Symbol.iterator]() {
|
|
122839
|
+
return this.iterateSync();
|
|
122840
|
+
}
|
|
122841
|
+
iterate() {
|
|
122842
|
+
return this.stream()[Symbol.asyncIterator]();
|
|
122843
|
+
}
|
|
122844
|
+
[Symbol.asyncIterator]() {
|
|
122845
|
+
return this.iterate();
|
|
122846
|
+
}
|
|
122847
|
+
};
|
|
122848
|
+
var le = (n7, t = {}) => {
|
|
122849
|
+
Array.isArray(n7) || (n7 = [n7]);
|
|
122850
|
+
for (let e of n7)
|
|
122851
|
+
if (new D(e, t).hasMagic())
|
|
122852
|
+
return true;
|
|
122853
|
+
return false;
|
|
122854
|
+
};
|
|
122855
|
+
function Bt(n7, t = {}) {
|
|
122856
|
+
return new I(n7, t).streamSync();
|
|
122857
|
+
}
|
|
122858
|
+
function Qe(n7, t = {}) {
|
|
122859
|
+
return new I(n7, t).stream();
|
|
122860
|
+
}
|
|
122861
|
+
function ts(n7, t = {}) {
|
|
122862
|
+
return new I(n7, t).walkSync();
|
|
122863
|
+
}
|
|
122864
|
+
async function Je(n7, t = {}) {
|
|
122865
|
+
return new I(n7, t).walk();
|
|
122866
|
+
}
|
|
122867
|
+
function Ut(n7, t = {}) {
|
|
122868
|
+
return new I(n7, t).iterateSync();
|
|
122869
|
+
}
|
|
122870
|
+
function es(n7, t = {}) {
|
|
122871
|
+
return new I(n7, t).iterate();
|
|
122872
|
+
}
|
|
122873
|
+
var ji = Bt;
|
|
122874
|
+
var Ii = Object.assign(Qe, { sync: Bt });
|
|
122875
|
+
var zi = Ut;
|
|
122876
|
+
var Bi = Object.assign(es, { sync: Ut });
|
|
122877
|
+
var Ui = Object.assign(ts, { stream: Bt, iterate: Ut });
|
|
122878
|
+
var Ze = Object.assign(Je, { glob: Je, globSync: ts, sync: Ui, globStream: Qe, stream: Ii, globStreamSync: Bt, streamSync: ji, globIterate: es, iterate: Bi, globIterateSync: Ut, iterateSync: zi, Glob: I, hasMagic: le, escape: tt, unescape: W });
|
|
122879
|
+
Ze.glob = Ze;
|
|
122880
|
+
|
|
122881
|
+
// src/core/agents/offSecAgent/tools/glob.ts
|
|
122882
|
+
init_zod();
|
|
122883
|
+
var DEFAULT_IGNORE = [
|
|
122884
|
+
"**/node_modules/**",
|
|
122885
|
+
"**/.git/**",
|
|
122886
|
+
"**/dist/**",
|
|
122887
|
+
"**/build/**",
|
|
122888
|
+
"**/.next/**",
|
|
122889
|
+
"**/coverage/**",
|
|
122890
|
+
"**/__pycache__/**",
|
|
122891
|
+
"**/.venv/**",
|
|
122892
|
+
"**/venv/**"
|
|
122893
|
+
];
|
|
122894
|
+
var MAX_RESULTS = 200;
|
|
122895
|
+
var globInputSchema = exports_external.object({
|
|
122896
|
+
pattern: exports_external.string().describe('Glob pattern to match files (e.g. "**/*.ts", "src/**/*.tsx", "**/package.json")'),
|
|
122897
|
+
path: exports_external.string().optional().describe("Directory to search from (absolute or relative to agent cwd). Defaults to agent cwd."),
|
|
122898
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Find all TypeScript source files')")
|
|
122899
|
+
});
|
|
122900
|
+
function resolveGlobRoot(agentCwd, path) {
|
|
122901
|
+
const root = path ? isAbsolute9(path) ? path : resolve10(agentCwd, path) : agentCwd;
|
|
122902
|
+
const rel = relative7(agentCwd, root);
|
|
122903
|
+
if (rel.startsWith("..") || isAbsolute9(rel)) {
|
|
122904
|
+
throw new Error(`Path escapes agent working directory: ${path ?? root}`);
|
|
122905
|
+
}
|
|
122906
|
+
return root;
|
|
122907
|
+
}
|
|
122908
|
+
function globFiles(ctx) {
|
|
122909
|
+
return tool({
|
|
122910
|
+
description: `Find files by glob pattern under the agent working directory.
|
|
122911
|
+
|
|
122912
|
+
Examples:
|
|
122913
|
+
- "**/*.ts" — all TypeScript files
|
|
122914
|
+
- "src/**/*.{ts,tsx}" — sources under src/
|
|
122915
|
+
- "**/package.json" — package manifests
|
|
122916
|
+
|
|
122917
|
+
Skips common junk directories (node_modules, .git, dist, build, .next, coverage, venv).
|
|
122918
|
+
Results are capped at ${MAX_RESULTS}; narrow the pattern if truncated.`,
|
|
122919
|
+
inputSchema: globInputSchema,
|
|
122920
|
+
execute: async ({ pattern, path }) => {
|
|
122921
|
+
let root;
|
|
122922
|
+
try {
|
|
122923
|
+
root = resolveGlobRoot(ctx.agentCwd, path);
|
|
122924
|
+
} catch (err) {
|
|
122925
|
+
return {
|
|
122926
|
+
success: false,
|
|
122927
|
+
error: err instanceof Error ? err.message : String(err),
|
|
122928
|
+
files: [],
|
|
122929
|
+
count: 0,
|
|
122930
|
+
pattern,
|
|
122931
|
+
cwd: ctx.agentCwd
|
|
122932
|
+
};
|
|
122933
|
+
}
|
|
122934
|
+
try {
|
|
122935
|
+
if (ctx.sandbox) {
|
|
122936
|
+
const escapedPattern = pattern.replace(/"/g, "\\\"");
|
|
122937
|
+
const cmd = `shopt -s globstar nullglob 2>/dev/null; cd "${root}" && compgen -G "${escapedPattern}" | head -n ${MAX_RESULTS + 1}`;
|
|
122938
|
+
const result = await ctx.sandbox.execute(cmd, { timeout: 30 });
|
|
122939
|
+
const lines = result.stdout.split(`
|
|
122940
|
+
`).map((l) => l.trim()).filter(Boolean);
|
|
122941
|
+
const truncated2 = lines.length > MAX_RESULTS;
|
|
122942
|
+
const files2 = lines.slice(0, MAX_RESULTS);
|
|
122943
|
+
return {
|
|
122944
|
+
success: true,
|
|
122945
|
+
error: truncated2 ? `Showing ${MAX_RESULTS} of at least ${lines.length} matches — narrow the pattern` : "",
|
|
122946
|
+
files: files2,
|
|
122947
|
+
count: files2.length,
|
|
122948
|
+
totalFound: truncated2 ? lines.length : undefined,
|
|
122949
|
+
pattern,
|
|
122950
|
+
cwd: root
|
|
122951
|
+
};
|
|
122952
|
+
}
|
|
122953
|
+
const matches = await Ze(pattern, {
|
|
122954
|
+
cwd: root,
|
|
122955
|
+
nodir: true,
|
|
122956
|
+
dot: false,
|
|
122957
|
+
ignore: DEFAULT_IGNORE,
|
|
122958
|
+
absolute: false
|
|
122959
|
+
});
|
|
122960
|
+
const truncated = matches.length > MAX_RESULTS;
|
|
122961
|
+
const files = matches.slice(0, MAX_RESULTS).sort();
|
|
122962
|
+
return {
|
|
122963
|
+
success: true,
|
|
122964
|
+
error: truncated ? `Showing ${MAX_RESULTS} of ${matches.length} matches — narrow the pattern` : "",
|
|
122965
|
+
files,
|
|
122966
|
+
count: files.length,
|
|
122967
|
+
totalFound: truncated ? matches.length : undefined,
|
|
122968
|
+
pattern,
|
|
122969
|
+
cwd: root
|
|
122970
|
+
};
|
|
122971
|
+
} catch (err) {
|
|
122972
|
+
return {
|
|
122973
|
+
success: false,
|
|
122974
|
+
error: err instanceof Error ? err.message : String(err),
|
|
122975
|
+
files: [],
|
|
122976
|
+
count: 0,
|
|
122977
|
+
pattern,
|
|
122978
|
+
cwd: root
|
|
122979
|
+
};
|
|
122980
|
+
}
|
|
122981
|
+
}
|
|
122982
|
+
});
|
|
122983
|
+
}
|
|
118941
122984
|
// src/core/agents/offSecAgent/tools/listPromptInjections.ts
|
|
118942
122985
|
init_dist();
|
|
118943
122986
|
init_zod();
|
|
@@ -119151,7 +123194,7 @@ Use this instead of asking for the whole playbook. Examples:
|
|
|
119151
123194
|
// src/core/agents/offSecAgent/tools/runCodeQuery.ts
|
|
119152
123195
|
init_dist();
|
|
119153
123196
|
init_zod();
|
|
119154
|
-
import { relative as
|
|
123197
|
+
import { relative as relative8 } from "node:path";
|
|
119155
123198
|
var MAX_INLINE_MATCHES = 40;
|
|
119156
123199
|
var MAX_QUERY_CAPTURE_BYTES = 2 * 1024 * 1024;
|
|
119157
123200
|
var QueryEngineSchema = exports_external.enum(["rg", "grep", "ast-grep", "comby"]);
|
|
@@ -119222,7 +123265,7 @@ instead of flooding context with every match. Output size and runtime are bounde
|
|
|
119222
123265
|
let targetPathForEngine = ".";
|
|
119223
123266
|
try {
|
|
119224
123267
|
const absTarget = resolvePathWithinCodebaseRoot(rootPath, query.path ?? ".");
|
|
119225
|
-
targetPathForEngine =
|
|
123268
|
+
targetPathForEngine = relative8(rootPath, absTarget) || ".";
|
|
119226
123269
|
} catch (error) {
|
|
119227
123270
|
results.push({
|
|
119228
123271
|
engine,
|
|
@@ -119587,10 +123630,10 @@ function listWhiteboxCandidates2(ctx) {
|
|
|
119587
123630
|
// src/core/agents/offSecAgent/tools/whiteboxJobs.ts
|
|
119588
123631
|
init_dist();
|
|
119589
123632
|
init_zod();
|
|
119590
|
-
import { isAbsolute as
|
|
123633
|
+
import { isAbsolute as isAbsolute10, relative as relative9, sep as sep2 } from "node:path";
|
|
119591
123634
|
function displayPath(ctx, path) {
|
|
119592
123635
|
const prefix = ctx.session.rootPath.endsWith(sep2) ? ctx.session.rootPath : `${ctx.session.rootPath}${sep2}`;
|
|
119593
|
-
return path === ctx.session.rootPath || path.startsWith(prefix) ?
|
|
123636
|
+
return path === ctx.session.rootPath || path.startsWith(prefix) ? relative9(ctx.session.rootPath, path) : path;
|
|
119594
123637
|
}
|
|
119595
123638
|
function startWhiteboxJob2(ctx) {
|
|
119596
123639
|
return tool({
|
|
@@ -119725,9 +123768,9 @@ function stopWhiteboxJob2(ctx) {
|
|
|
119725
123768
|
});
|
|
119726
123769
|
}
|
|
119727
123770
|
function normalizeArtifactRelativePath(ctx, userPath) {
|
|
119728
|
-
if (
|
|
119729
|
-
const rel =
|
|
119730
|
-
if (rel.startsWith("..") || rel === ".." ||
|
|
123771
|
+
if (isAbsolute10(userPath)) {
|
|
123772
|
+
const rel = relative9(ctx.session.rootPath, userPath);
|
|
123773
|
+
if (rel.startsWith("..") || rel === ".." || isAbsolute10(rel)) {
|
|
119731
123774
|
throw new Error("Artifact path must be inside the session directory.");
|
|
119732
123775
|
}
|
|
119733
123776
|
return rel.replace(/\\/g, "/");
|
|
@@ -119825,12 +123868,17 @@ function createAllTools(ctx) {
|
|
|
119825
123868
|
document_vulnerability: documentVulnerability(ctx),
|
|
119826
123869
|
read_file: readFile2(ctx),
|
|
119827
123870
|
list_files: listFiles(ctx),
|
|
123871
|
+
glob: globFiles(ctx),
|
|
119828
123872
|
grep: grep(ctx),
|
|
119829
123873
|
profile_codebase: profileCodebase2(ctx),
|
|
119830
123874
|
query_whitebox_catalog: queryWhiteboxCatalog2(ctx),
|
|
119831
123875
|
run_code_query: runCodeQuery(ctx),
|
|
119832
123876
|
create_file: createFile(ctx),
|
|
119833
123877
|
update_file: updateFile(ctx),
|
|
123878
|
+
delete_file: deleteFile(ctx),
|
|
123879
|
+
apply_patch: applyPatch(ctx),
|
|
123880
|
+
git_status: gitStatus(ctx),
|
|
123881
|
+
git_diff: gitDiff(ctx),
|
|
119834
123882
|
document_app: documentApp(ctx),
|
|
119835
123883
|
document_endpoint: documentEndpoint(ctx),
|
|
119836
123884
|
delegate_to_auth_subagent: delegateAuth(ctx),
|
|
@@ -119893,12 +123941,17 @@ var ALL_TOOL_NAMES = [
|
|
|
119893
123941
|
"document_vulnerability",
|
|
119894
123942
|
"read_file",
|
|
119895
123943
|
"list_files",
|
|
123944
|
+
"glob",
|
|
119896
123945
|
"grep",
|
|
119897
123946
|
"profile_codebase",
|
|
119898
123947
|
"query_whitebox_catalog",
|
|
119899
123948
|
"run_code_query",
|
|
119900
123949
|
"create_file",
|
|
119901
123950
|
"update_file",
|
|
123951
|
+
"delete_file",
|
|
123952
|
+
"apply_patch",
|
|
123953
|
+
"git_status",
|
|
123954
|
+
"git_diff",
|
|
119902
123955
|
"document_app",
|
|
119903
123956
|
"document_endpoint",
|
|
119904
123957
|
"delegate_to_auth_subagent",
|
|
@@ -119976,8 +124029,11 @@ var PLAN_MODE_TOOL_NAMES = [
|
|
|
119976
124029
|
"http_request",
|
|
119977
124030
|
"read_file",
|
|
119978
124031
|
"list_files",
|
|
124032
|
+
"glob",
|
|
119979
124033
|
"grep",
|
|
119980
124034
|
"query_whitebox_catalog",
|
|
124035
|
+
"git_status",
|
|
124036
|
+
"git_diff",
|
|
119981
124037
|
"delegate_to_auth_subagent",
|
|
119982
124038
|
"complete_authentication",
|
|
119983
124039
|
"extract_js_endpoints",
|
|
@@ -120010,7 +124066,7 @@ var SKILL_TOOL_NAMES = ["read_skill"];
|
|
|
120010
124066
|
// src/core/agents/offSecAgent/trace.ts
|
|
120011
124067
|
import { createHash as createHash2 } from "node:crypto";
|
|
120012
124068
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync13 } from "node:fs";
|
|
120013
|
-
import { dirname as
|
|
124069
|
+
import { dirname as dirname8 } from "node:path";
|
|
120014
124070
|
var OUTPUT_PREVIEW_LIMIT = 2000;
|
|
120015
124071
|
var INPUT_PREVIEW_LIMIT = 1000;
|
|
120016
124072
|
var SYSTEM_PROMPT_HASH_PREFIX_LENGTH = 12;
|
|
@@ -120071,7 +124127,7 @@ class StepTraceWriter {
|
|
|
120071
124127
|
const now = Date.now();
|
|
120072
124128
|
this.agentStartTime = now;
|
|
120073
124129
|
this.lastStepTime = now;
|
|
120074
|
-
mkdirSync13(
|
|
124130
|
+
mkdirSync13(dirname8(this.tracePath), { recursive: true });
|
|
120075
124131
|
}
|
|
120076
124132
|
writeInit(data) {
|
|
120077
124133
|
const { systemPrompt, ...rest } = data;
|
|
@@ -120211,7 +124267,7 @@ class StepTraceWriter {
|
|
|
120211
124267
|
init_dist();
|
|
120212
124268
|
init_ai();
|
|
120213
124269
|
import { existsSync as existsSync18, mkdirSync as mkdirSync14, readFileSync as readFileSync8 } from "node:fs";
|
|
120214
|
-
import { writeFile as
|
|
124270
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
120215
124271
|
import { join as join27 } from "node:path";
|
|
120216
124272
|
init_id();
|
|
120217
124273
|
init_structured();
|
|
@@ -120264,8 +124320,8 @@ class ApprovalGate extends EventEmitter3 {
|
|
|
120264
124320
|
tier: 1,
|
|
120265
124321
|
timestamp: Date.now()
|
|
120266
124322
|
};
|
|
120267
|
-
return new Promise((
|
|
120268
|
-
const deferred = { approval, resolve:
|
|
124323
|
+
return new Promise((resolve11, reject) => {
|
|
124324
|
+
const deferred = { approval, resolve: resolve11, reject };
|
|
120269
124325
|
this.pendingApprovals.set(approval.id, deferred);
|
|
120270
124326
|
const timeoutMs = this.config.decisionTimeoutMs;
|
|
120271
124327
|
if (timeoutMs !== undefined && timeoutMs > 0) {
|
|
@@ -120521,8 +124577,8 @@ class OffensiveSecurityAgent {
|
|
|
120521
124577
|
_responseToolFired = false;
|
|
120522
124578
|
_resolveResponseCaptured;
|
|
120523
124579
|
_rejectResponseCaptured;
|
|
120524
|
-
responseCaptured = new Promise((
|
|
120525
|
-
this._resolveResponseCaptured =
|
|
124580
|
+
responseCaptured = new Promise((resolve11, reject) => {
|
|
124581
|
+
this._resolveResponseCaptured = resolve11;
|
|
120526
124582
|
this._rejectResponseCaptured = reject;
|
|
120527
124583
|
});
|
|
120528
124584
|
_drainRejection = new Promise(() => {});
|
|
@@ -120741,7 +124797,7 @@ class OffensiveSecurityAgent {
|
|
|
120741
124797
|
if (this.latestMessages) {
|
|
120742
124798
|
const toWrite = this.latestMessages;
|
|
120743
124799
|
this.latestMessages = null;
|
|
120744
|
-
|
|
124800
|
+
writeFile7(messagesPath, JSON.stringify(toWrite)).catch(() => {});
|
|
120745
124801
|
}
|
|
120746
124802
|
}, PERSIST_INTERVAL_MS);
|
|
120747
124803
|
};
|
|
@@ -120754,7 +124810,7 @@ class OffensiveSecurityAgent {
|
|
|
120754
124810
|
const baseSystemPrompt = input.system ?? detectOSAndEnhancePrompt(buildBaseSystemPrompt({
|
|
120755
124811
|
sandboxMode: agentCwd === input.session.rootPath
|
|
120756
124812
|
}));
|
|
120757
|
-
const systemPrompt = baseSystemPrompt + buildSessionWorkspaceSection(input.session, agentCwd);
|
|
124813
|
+
const systemPrompt = baseSystemPrompt + buildSessionWorkspaceSection(input.session, agentCwd, activeTools);
|
|
120758
124814
|
traceWriter.writeInit({
|
|
120759
124815
|
model: input.model,
|
|
120760
124816
|
systemPrompt: baseSystemPrompt,
|
|
@@ -120809,7 +124865,7 @@ class OffensiveSecurityAgent {
|
|
|
120809
124865
|
...initialMessagesRef.current,
|
|
120810
124866
|
...event.response.messages
|
|
120811
124867
|
];
|
|
120812
|
-
await
|
|
124868
|
+
await writeFile7(messagesPath, JSON.stringify(finalMessages)).catch(() => {});
|
|
120813
124869
|
}
|
|
120814
124870
|
await input.onFinish?.(event);
|
|
120815
124871
|
},
|
|
@@ -120922,7 +124978,7 @@ class OffensiveSecurityAgent {
|
|
|
120922
124978
|
const fr = c.finishReason;
|
|
120923
124979
|
rlog.warn(`[response-debug] finish-step finishReason=${fr} responseInFlight=${[
|
|
120924
124980
|
...inFlightTools.entries()
|
|
120925
|
-
].filter(([,
|
|
124981
|
+
].filter(([, n7]) => n7 === RESPONSE_TOOL_NAME).map(([id]) => id).join(",")} responseToolFired=${this._responseToolFired}`);
|
|
120926
124982
|
}
|
|
120927
124983
|
}
|
|
120928
124984
|
}
|
|
@@ -120951,20 +125007,20 @@ class OffensiveSecurityAgent {
|
|
|
120951
125007
|
inFlightTools.set(chunk.toolCallId, chunk.toolName);
|
|
120952
125008
|
break;
|
|
120953
125009
|
case "tool-error": {
|
|
120954
|
-
const
|
|
120955
|
-
inFlightTools.delete(
|
|
120956
|
-
const errMsg =
|
|
125010
|
+
const te2 = chunk;
|
|
125011
|
+
inFlightTools.delete(te2.toolCallId);
|
|
125012
|
+
const errMsg = te2.error instanceof Error ? te2.error.message : typeof te2.error === "string" ? te2.error : (() => {
|
|
120957
125013
|
try {
|
|
120958
|
-
return JSON.stringify(
|
|
125014
|
+
return JSON.stringify(te2.error);
|
|
120959
125015
|
} catch {
|
|
120960
|
-
return String(
|
|
125016
|
+
return String(te2.error);
|
|
120961
125017
|
}
|
|
120962
125018
|
})();
|
|
120963
|
-
const partialArgs =
|
|
120964
|
-
toolErrors.set(
|
|
125019
|
+
const partialArgs = te2.input !== undefined && te2.input !== null && responseArgBytes(te2.input) > 2 ? te2.input : streamedArgText.get(te2.toolCallId) ?? "";
|
|
125020
|
+
toolErrors.set(te2.toolCallId, {
|
|
120965
125021
|
message: errMsg,
|
|
120966
125022
|
input: partialArgs,
|
|
120967
|
-
toolName:
|
|
125023
|
+
toolName: te2.toolName
|
|
120968
125024
|
});
|
|
120969
125025
|
break;
|
|
120970
125026
|
}
|
|
@@ -121092,7 +125148,7 @@ class OffensiveSecurityAgent {
|
|
|
121092
125148
|
}
|
|
121093
125149
|
}));
|
|
121094
125150
|
let rejectDrain;
|
|
121095
|
-
this._drainRejection = new Promise((
|
|
125151
|
+
this._drainRejection = new Promise((_2, reject) => {
|
|
121096
125152
|
rejectDrain = reject;
|
|
121097
125153
|
});
|
|
121098
125154
|
this._drainRejection.catch(() => {});
|
|
@@ -121137,7 +125193,7 @@ class OffensiveSecurityAgent {
|
|
|
121137
125193
|
};
|
|
121138
125194
|
const syntheticParts = [];
|
|
121139
125195
|
if (RESPONSE_DEBUG) {
|
|
121140
|
-
const responseInFlight = [...inFlightTools.entries()].filter(([,
|
|
125196
|
+
const responseInFlight = [...inFlightTools.entries()].filter(([, n7]) => n7 === RESPONSE_TOOL_NAME);
|
|
121141
125197
|
if (responseInFlight.length > 0) {
|
|
121142
125198
|
rlog.warn(`[response-debug] emitSyntheticToolResults closing ${responseInFlight.length} response call(s) ` + `ids=${responseInFlight.map(([id]) => id).join(",")} reason="${reason}" ` + `aborted=${this.abortSignal?.aborted === true} responseToolFired=${this._responseToolFired}`);
|
|
121143
125199
|
}
|
|
@@ -121195,7 +125251,7 @@ class OffensiveSecurityAgent {
|
|
|
121195
125251
|
}
|
|
121196
125252
|
};
|
|
121197
125253
|
if (RESPONSE_DEBUG) {
|
|
121198
|
-
const responseReconstructed = stepTools.filter(([,
|
|
125254
|
+
const responseReconstructed = stepTools.filter(([, n7]) => n7 === RESPONSE_TOOL_NAME).map(([id]) => id);
|
|
121199
125255
|
if (responseReconstructed.length > 0) {
|
|
121200
125256
|
rlog.warn(`[response-debug] step-reconstruction for response call(s) ` + `ids=${responseReconstructed.join(",")} ` + `preservedArgChars=${responseReconstructed.map((id) => streamedArgText?.get(id)?.length ?? 0).join(",")}`);
|
|
121201
125257
|
}
|
|
@@ -121215,7 +125271,7 @@ class OffensiveSecurityAgent {
|
|
|
121215
125271
|
const next = [...base, ...appended];
|
|
121216
125272
|
this.latestMessages = next;
|
|
121217
125273
|
try {
|
|
121218
|
-
await
|
|
125274
|
+
await writeFile7(this.messagesPath, JSON.stringify(next));
|
|
121219
125275
|
this.syntheticsPersisted = true;
|
|
121220
125276
|
} catch {}
|
|
121221
125277
|
}
|