@pensar/apex 2.2.0 → 2.3.0-canary.5102978

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.
Files changed (54) hide show
  1. package/build/{agent-yayy5x2a.js → agent-43tdnbzm.js} +7 -7
  2. package/build/{agent-q5hwjdtb.js → agent-kp087zrv.js} +9 -9
  3. package/build/agent-ysdy35bg.js +19 -0
  4. package/build/{apps-0es69e2s.js → apps-vcz9jbfy.js} +16 -16
  5. package/build/{auth-q73k9bh9.js → auth-4t4fd22m.js} +32 -39
  6. package/build/authentication-dghzj4y6.js +19 -0
  7. package/build/blackboxAgent-dj3q90tf.js +19 -0
  8. package/build/{blackboxPentest-h28nykk5.js → blackboxPentest-55cng7t3.js} +14 -14
  9. package/build/{cli-51dkmt5p.js → cli-022qqs0v.js} +1 -1
  10. package/build/{cli-2jn8104w.js → cli-20vj7vb5.js} +2 -2
  11. package/build/{cli-4tc6888c.js → cli-21jc2hzb.js} +51 -2
  12. package/build/{cli-n114n8mk.js → cli-4qhqjw2c.js} +2 -2
  13. package/build/{cli-knqx15w6.js → cli-5skkqa07.js} +2 -2
  14. package/build/{cli-xpn9tsw0.js → cli-75zv3493.js} +3 -3
  15. package/build/{cli-tz9yg4ew.js → cli-7sn6b2zw.js} +8 -8
  16. package/build/{cli-1cf5vy5m.js → cli-7tra3j0n.js} +60 -28
  17. package/build/{cli-1re2kv5v.js → cli-cvarnmfs.js} +3 -3
  18. package/build/{cli-vgg6h2ax.js → cli-ev4e8g7a.js} +1 -1
  19. package/build/{cli-xbdn034b.js → cli-fqgastnm.js} +4081 -92
  20. package/build/{cli-7n43wz82.js → cli-gdyzgxkm.js} +4 -2
  21. package/build/{cli-s43t5ay0.js → cli-k3er0c60.js} +1 -1
  22. package/build/{cli-7e5ad5js.js → cli-mqvsx788.js} +2 -2
  23. package/build/{cli-1f636vzd.js → cli-v56t0jqg.js} +1 -1
  24. package/build/{cli-6kx46ck0.js → cli-wd2nc4pv.js} +19 -6
  25. package/build/{cli-ptzy9ak5.js → cli-xprt7ev2.js} +1 -1
  26. package/build/cli.js +41 -36
  27. package/build/{config-xcf7rc6x.js → config-kypy09wh.js} +3 -3
  28. package/build/{doctor-98zperf9.js → doctor-kg26ymam.js} +6 -6
  29. package/build/{fastStrike-9tm6bedh.js → fastStrike-2t3hy8gs.js} +9 -9
  30. package/build/{fixes-1dry8j61.js → fixes-d3b10qbh.js} +16 -16
  31. package/build/{index-34h2nb6x.js → index-0e6ce585.js} +3 -3
  32. package/build/{index-6dbym5jy.js → index-b01pd00k.js} +21 -8
  33. package/build/{index-4hqbyzf5.js → index-eekzgpqm.js} +8 -8
  34. package/build/{index-f6ttv7np.js → index-js1nqqaa.js} +9 -5
  35. package/build/{index-31rwrakh.js → index-sr54gvh2.js} +2 -2
  36. package/build/{index-0j880wqc.js → index-tvnmy35p.js} +1080 -898
  37. package/build/{index-pxwwcefn.js → index-zagn856g.js} +9 -9
  38. package/build/{issues-wjakj8yy.js → issues-c50pp7bq.js} +44 -16
  39. package/build/{logs-ewyzcspy.js → logs-9stvk5yq.js} +16 -16
  40. package/build/{offesecAgent-7m9smy0t.js → offesecAgent-81t5mjc7.js} +8 -8
  41. package/build/pentest-00zkwz6t.js +29 -0
  42. package/build/{pentests-1hcqjyk2.js → pentests-8jzq9wr7.js} +16 -16
  43. package/build/{targetedPentest-3x13kqvc.js → targetedPentest-9wmdjjst.js} +9 -9
  44. package/build/{targets-nqz8w37e.js → targets-3qsfr4yr.js} +16 -16
  45. package/build/threatModel-2ah5p448.js +27 -0
  46. package/build/{uninstall-p1q5pkx2.js → uninstall-wkm626qv.js} +1 -1
  47. package/build/{upload-x7etpfp4.js → upload-xyfs0efr.js} +6 -6
  48. package/build/{utils-kw6yh5yn.js → utils-6t4yqref.js} +5 -5
  49. package/package.json +1 -1
  50. package/build/agent-3cdfwxcd.js +0 -19
  51. package/build/authentication-tqx2brcv.js +0 -19
  52. package/build/blackboxAgent-d0smgqt7.js +0 -19
  53. package/build/pentest-1cb5t0dt.js +0 -29
  54. package/build/threatModel-7f02av7y.js +0 -27
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  detectOSAndEnhancePrompt
3
- } from "./cli-s43t5ay0.js";
3
+ } from "./cli-k3er0c60.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-6kx46ck0.js";
35
+ } from "./cli-wd2nc4pv.js";
36
36
  import {
37
37
  ensureValidToken,
38
38
  getPensarApiUrl,
39
39
  init_auth,
40
40
  init_constants,
41
41
  signGatewayRequest
42
- } from "./cli-4tc6888c.js";
42
+ } from "./cli-21jc2hzb.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-51dkmt5p.js";
73
+ } from "./cli-022qqs0v.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 randomUUID = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
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 randomUUID();
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 randomUUID = () => globalThis.crypto?.randomUUID() || __require("crypto").randomUUID();
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 = randomUUID();
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 = randomUUID();
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", { text: chunk.text, subagentId });
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
- function buildSourceAssessmentSection(session, agentCwd, sandboxMode) {
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,
@@ -102872,6 +102896,30 @@ function collectDescendantPids(rootPid) {
102872
102896
  }
102873
102897
  return descendants;
102874
102898
  }
102899
+ var BROWSER_LAUNCH_ENV = "PENSAR_BROWSER_LAUNCH_ID";
102900
+ function collectPidsByEnvMarker(key, value) {
102901
+ let entries;
102902
+ try {
102903
+ entries = readdirSync2("/proc");
102904
+ } catch {
102905
+ return [];
102906
+ }
102907
+ const needle = `${key}=${value}`;
102908
+ const pids = [];
102909
+ for (const name of entries) {
102910
+ if (!/^\d+$/.test(name))
102911
+ continue;
102912
+ const pid = Number(name);
102913
+ if (pid === process.pid)
102914
+ continue;
102915
+ try {
102916
+ if (readFileSync(`/proc/${pid}/environ`, "utf8").split("\x00").includes(needle)) {
102917
+ pids.push(pid);
102918
+ }
102919
+ } catch {}
102920
+ }
102921
+ return pids;
102922
+ }
102875
102923
  var defaultHeadless = true;
102876
102924
  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
102925
  var HARDCODED_VIEWPORT_FALLBACK = "1920,1080";
@@ -102899,6 +102947,7 @@ class PlaywrightMcpSession {
102899
102947
  display;
102900
102948
  mcpConfigPath = null;
102901
102949
  cachedCamouOptions = null;
102950
+ currentLaunchId = null;
102902
102951
  constructor(options = {}) {
102903
102952
  const { headless, userAgent, viewportSize, extraHttpHeaders, display } = options;
102904
102953
  this.display = display ?? process.env.DISPLAY ?? undefined;
@@ -102928,33 +102977,41 @@ class PlaywrightMcpSession {
102928
102977
  } catch {}
102929
102978
  })();
102930
102979
  }
102931
- forceKillProcess(proc = this.mcpProcess) {
102932
- if (!proc || proc.exitCode !== null)
102933
- return;
102934
- const rootPid = proc.pid ?? null;
102935
- const descendants = rootPid != null ? collectDescendantPids(rootPid) : [];
102936
- const descendantStarts = new Map;
102937
- for (const pid of descendants) {
102938
- descendantStarts.set(pid, readProcStartTime(pid));
102939
- }
102940
- try {
102941
- if (rootPid != null) {
102942
- try {
102943
- process.kill(-rootPid, "SIGKILL");
102944
- } catch {
102980
+ forceKillProcess(proc = this.mcpProcess, launchId = this.currentLaunchId) {
102981
+ if (proc && proc.exitCode === null) {
102982
+ const rootPid = proc.pid ?? null;
102983
+ const descendants = rootPid != null ? collectDescendantPids(rootPid) : [];
102984
+ const descendantStarts = new Map;
102985
+ for (const pid of descendants) {
102986
+ descendantStarts.set(pid, readProcStartTime(pid));
102987
+ }
102988
+ try {
102989
+ if (rootPid != null) {
102990
+ try {
102991
+ process.kill(-rootPid, "SIGKILL");
102992
+ } catch {
102993
+ proc.kill("SIGKILL");
102994
+ }
102995
+ } else {
102945
102996
  proc.kill("SIGKILL");
102946
102997
  }
102947
- } else {
102948
- proc.kill("SIGKILL");
102949
- }
102950
- } catch {}
102951
- for (const pid of descendants) {
102952
- const expected = descendantStarts.get(pid);
102953
- if (expected != null) {
102998
+ } catch {}
102999
+ for (const pid of descendants) {
103000
+ const expected = descendantStarts.get(pid);
102954
103001
  const now = readProcStartTime(pid);
102955
- if (now == null || now !== expected)
103002
+ if (expected == null || now == null || now !== expected)
102956
103003
  continue;
103004
+ try {
103005
+ process.kill(pid, "SIGKILL");
103006
+ } catch {}
102957
103007
  }
103008
+ }
103009
+ this.reapLaunchedProcesses(launchId);
103010
+ }
103011
+ reapLaunchedProcesses(launchId) {
103012
+ if (!launchId)
103013
+ return;
103014
+ for (const pid of collectPidsByEnvMarker(BROWSER_LAUNCH_ENV, launchId)) {
102958
103015
  try {
102959
103016
  process.kill(pid, "SIGKILL");
102960
103017
  } catch {}
@@ -103002,13 +103059,16 @@ class PlaywrightMcpSession {
103002
103059
  mode: 384
103003
103060
  });
103004
103061
  args.push("--config", this.mcpConfigPath);
103062
+ const launchId = randomUUID();
103063
+ this.currentLaunchId = launchId;
103005
103064
  const transport = new StdioClientTransport({
103006
103065
  command: "node",
103007
103066
  args,
103008
103067
  stderr: "pipe",
103009
103068
  env: {
103010
103069
  ...Object.fromEntries(Object.entries(camou.env).map(([k, v]) => [k, String(v)])),
103011
- ...this.display ? { DISPLAY: this.display } : {}
103070
+ ...this.display ? { DISPLAY: this.display } : {},
103071
+ [BROWSER_LAUNCH_ENV]: launchId
103012
103072
  }
103013
103073
  });
103014
103074
  const client = new Client({
@@ -103025,6 +103085,7 @@ class PlaywrightMcpSession {
103025
103085
  this.mcpTransport = transport;
103026
103086
  client.onclose = () => {
103027
103087
  if (this.mcpClient === client) {
103088
+ this.forceKillProcess(this.mcpProcess, launchId);
103028
103089
  this.resetState();
103029
103090
  }
103030
103091
  };
@@ -106376,24 +106437,27 @@ function getTaskSummary(tasksDir, preloaded) {
106376
106437
 
106377
106438
  // src/core/agents/offSecAgent/tools/createTask.ts
106378
106439
  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 test and how — include specific payloads, encoding strategies, or bypass techniques to try"),
106381
- objective: exports_external.string().describe("The testing objective this task addresses (from your assigned objectives)"),
106382
- technique: exports_external.string().describe("The specific attack technique (e.g., 'UNION-based SQL injection', 'reflected XSS via search parameter', 'time-based blind SQLi')"),
106383
- metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe("Optional metadata (e.g., { priority: 'high', endpoint: '/api/users', parameter: 'id' })")
106440
+ 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')"),
106441
+ 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"),
106442
+ 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."),
106443
+ technique: exports_external.string().optional().describe("Optional technique or approach label (e.g. 'parameterized queries', 'UNION-based SQL injection'). Defaults to 'general' when omitted."),
106444
+ 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
106445
  });
106385
106446
  function createTask2(ctx) {
106386
106447
  return tool({
106387
- description: `Create a testing task to track your work.
106448
+ description: `Create a task to track your work.
106388
106449
 
106389
- Decompose each objective into concrete, atomic testing tasks — one task per technique × endpoint combination. Tasks track what you've planned, what you're doing, and what's done.
106450
+ Use tasks as a lightweight todo list: decompose the job into concrete, atomic steps, create them early, and update status as you go.
106390
106451
 
106391
- Call this BEFORE you start testing to build your task list. You can also add tasks mid-run when you discover new attack vectors.
106452
+ Works for both coding agents (patch/fix/verify steps) and pentest agents (technique × endpoint tests).
106453
+
106454
+ Call this BEFORE you start substantive work to build your task list. Add more mid-run when you discover extra work.
106392
106455
 
106393
106456
  Examples of good tasks:
106394
- - "Test /api/users id parameter for error-based SQL injection"
106395
- - "Test /search q parameter for reflected XSS with event handler payloads"
106396
- - "Test /api/auth for JWT signature bypass via algorithm confusion"`,
106457
+ - "Read vulnerable login handler and related DB helpers"
106458
+ - "Apply parameterized query fix in src/auth/login.ts"
106459
+ - "Run lint, typecheck, and unit tests"
106460
+ - "Test /api/users id parameter for error-based SQL injection"`,
106397
106461
  inputSchema: createTaskInputSchema,
106398
106462
  execute: async ({
106399
106463
  subject,
@@ -106412,8 +106476,8 @@ Examples of good tasks:
106412
106476
  const task = createTask(ctx.tasksDir, {
106413
106477
  subject,
106414
106478
  description,
106415
- objective,
106416
- technique,
106479
+ objective: objective ?? subject,
106480
+ technique: technique ?? "general",
106417
106481
  metadata
106418
106482
  });
106419
106483
  ctx.traceWriter?.appendTaskRecord({
@@ -106613,7 +106677,7 @@ IMPORTANT: Pass protectedEndpoints in authHints when you've discovered 401/403 e
106613
106677
  if (credentials) {
106614
106678
  ctx.session.credentialManager.addFromAuthCredentials(credentials);
106615
106679
  }
106616
- const { runAuthenticationAgent } = await import("./authentication-tqx2brcv.js");
106680
+ const { runAuthenticationAgent } = await import("./authentication-dghzj4y6.js");
106617
106681
  const localBus = new AgentEventBus;
106618
106682
  AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
106619
106683
  const result = await runAuthenticationAgent({
@@ -107404,7 +107468,7 @@ async function generateThreatModelForEndpoint(ctx, input) {
107404
107468
  return threatModelLimiter(async () => {
107405
107469
  if (ctx.abortSignal?.aborted)
107406
107470
  return null;
107407
- const { CodeAgent } = await import("./agent-3cdfwxcd.js");
107471
+ const { CodeAgent } = await import("./agent-ysdy35bg.js");
107408
107472
  const subagentId = newSessionId();
107409
107473
  const subagentName = `Threat Model: ${input.routePath}`;
107410
107474
  ctx.eventBus?.emit("subagent-spawn", {
@@ -109327,7 +109391,7 @@ init_lazyLogger();
109327
109391
  var log6 = scopedLogger(() => createLogger("FindingJudge"));
109328
109392
  async function judgeFinding(input, ctx) {
109329
109393
  try {
109330
- const { FindingJudgeAgent } = await import("./agent-yayy5x2a.js");
109394
+ const { FindingJudgeAgent } = await import("./agent-43tdnbzm.js");
109331
109395
  const agent = new FindingJudgeAgent({
109332
109396
  finding: input,
109333
109397
  model: ctx.model,
@@ -112327,6 +112391,8 @@ function createEmailAdapter(inbox) {
112327
112391
  return new OutlookAdapter(inbox.accessToken, inbox.refreshToken, inbox.clientId, inbox.clientSecret);
112328
112392
  case "imap":
112329
112393
  return new ImapAdapter(inbox);
112394
+ case "http":
112395
+ return new HttpAdapter(inbox);
112330
112396
  default:
112331
112397
  throw new Error(`Unsupported email provider: ${inbox.provider}`);
112332
112398
  }
@@ -112942,6 +113008,65 @@ function truncate(s, max) {
112942
113008
  (truncated)` : s;
112943
113009
  }
112944
113010
 
113011
+ class HttpAdapter {
113012
+ endpoint;
113013
+ token;
113014
+ address;
113015
+ constructor(inbox) {
113016
+ this.endpoint = inbox.endpoint.replace(/\/+$/, "");
113017
+ this.token = inbox.token;
113018
+ this.address = inbox.emailAddress;
113019
+ }
113020
+ async get(path, params) {
113021
+ const url = new URL(`${this.endpoint}${path}`);
113022
+ if (params) {
113023
+ for (const [key, value] of Object.entries(params)) {
113024
+ url.searchParams.set(key, value);
113025
+ }
113026
+ }
113027
+ const res = await fetch(url, {
113028
+ headers: { Authorization: `Bearer ${this.token}` }
113029
+ });
113030
+ if (!res.ok) {
113031
+ throw new Error(`Mailbox HTTP error ${res.status} ${res.statusText} for ${path}`);
113032
+ }
113033
+ return await res.json();
113034
+ }
113035
+ async listMessages(opts) {
113036
+ const params = { address: this.address };
113037
+ if (opts.maxResults !== undefined)
113038
+ params.limit = String(opts.maxResults);
113039
+ if (opts.pageToken)
113040
+ params.cursor = opts.pageToken;
113041
+ const data = await this.get("/messages", params);
113042
+ return { messages: data.messages, nextPageToken: data.nextCursor };
113043
+ }
113044
+ async searchMessages(opts) {
113045
+ const params = {
113046
+ address: this.address,
113047
+ q: opts.query
113048
+ };
113049
+ if (opts.maxResults !== undefined)
113050
+ params.limit = String(opts.maxResults);
113051
+ if (opts.pageToken)
113052
+ params.cursor = opts.pageToken;
113053
+ const data = await this.get("/messages", params);
113054
+ return { messages: data.messages, nextPageToken: data.nextCursor };
113055
+ }
113056
+ async getMessage(messageId, _folder) {
113057
+ return this.get(`/messages/${encodeURIComponent(messageId)}`);
113058
+ }
113059
+ async getAttachments(_messageId, _folder) {
113060
+ return [];
113061
+ }
113062
+ async getAttachmentContent(_messageId, _attachmentId, _folder) {
113063
+ throw new Error("Attachments are not supported by the http mailbox provider");
113064
+ }
113065
+ markAsRead(_messageId, _folder) {
113066
+ return Promise.resolve();
113067
+ }
113068
+ }
113069
+
112945
113070
  // src/core/agents/offSecAgent/tools/email/getMessage.ts
112946
113071
  function emailGetMessage(ctx) {
112947
113072
  return tool({
@@ -115892,7 +116017,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
115892
116017
  });
115893
116018
  if (cwd) {
115894
116019
  try {
115895
- const { WhiteboxAttackSurfaceAgent } = await import("./index-pxwwcefn.js");
116020
+ const { WhiteboxAttackSurfaceAgent } = await import("./index-zagn856g.js");
115896
116021
  const localBus = new AgentEventBus;
115897
116022
  AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
115898
116023
  const agent = new WhiteboxAttackSurfaceAgent({
@@ -115947,7 +116072,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
115947
116072
  }
115948
116073
  }
115949
116074
  try {
115950
- const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-d0smgqt7.js");
116075
+ const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-dj3q90tf.js");
115951
116076
  const localBus = new AgentEventBus;
115952
116077
  AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
115953
116078
  const agent = new BlackboxAttackSurfaceAgent({
@@ -116025,7 +116150,7 @@ Omit \`cwd\` for blackbox mode (live target probing only).`,
116025
116150
  toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
116026
116151
  }),
116027
116152
  execute: async ({ target, cwd }) => {
116028
- const { runPentestWorkflow: workflow } = await import("./pentest-1cb5t0dt.js");
116153
+ const { runPentestWorkflow: workflow } = await import("./pentest-00zkwz6t.js");
116029
116154
  if (!ctx.model) {
116030
116155
  return {
116031
116156
  success: false,
@@ -117603,7 +117728,7 @@ Returns an array of results with the text output from each agent.`,
117603
117728
  });
117604
117729
  }
117605
117730
  async function runSingleCodingAgent(ctx, codebasePath, objective, agentIndex, name) {
117606
- const { CodeAgent } = await import("./agent-3cdfwxcd.js");
117731
+ const { CodeAgent } = await import("./agent-ysdy35bg.js");
117607
117732
  const childSessionId = newSessionId();
117608
117733
  const subagentId = childSessionId;
117609
117734
  ctx.eventBus?.emit("subagent-spawn", {
@@ -118120,7 +118245,7 @@ Returns the worker's summary, objective results, and finding count — but NOT t
118120
118245
  message: "spawn_pentest_agent requires a model in the tool context."
118121
118246
  };
118122
118247
  }
118123
- const { TargetedPentestAgent } = await import("./agent-q5hwjdtb.js");
118248
+ const { TargetedPentestAgent } = await import("./agent-kp087zrv.js");
118124
118249
  const findingsRegistry = ctx.findingsRegistry ?? FindingsRegistry.fromDirectory(ctx.session.findingsPath, {
118125
118250
  model: ctx.model,
118126
118251
  authConfig: ctx.authConfig,
@@ -118254,7 +118379,7 @@ Pass every target you want tested — the swarm handles concurrency automaticall
118254
118379
  toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
118255
118380
  }),
118256
118381
  execute: async ({ targets }) => {
118257
- const { runPentestSwarm, DEFAULT_CONCURRENCY: DEFAULT_CONCURRENCY2 } = await import("./pentest-1cb5t0dt.js");
118382
+ const { runPentestSwarm, DEFAULT_CONCURRENCY: DEFAULT_CONCURRENCY2 } = await import("./pentest-00zkwz6t.js");
118258
118383
  if (!ctx.model) {
118259
118384
  return {
118260
118385
  success: false,
@@ -118938,6 +119063,3857 @@ Required plan sections:
118938
119063
  }
118939
119064
  });
118940
119065
  }
119066
+ // src/core/agents/offSecAgent/tools/applyPatch.ts
119067
+ init_dist();
119068
+ init_zod();
119069
+ import { mkdir as mkdir4, readFile as readFile7, unlink, writeFile as writeFile6 } from "node:fs/promises";
119070
+ import { dirname as dirname7, isAbsolute as isAbsolute7, relative as relative5, resolve as resolve8 } from "node:path";
119071
+ var applyPatchInputSchema = exports_external.object({
119072
+ 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."),
119073
+ 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')")
119074
+ });
119075
+ function stripPrefix(p) {
119076
+ if (p.startsWith("a/") || p.startsWith("b/"))
119077
+ return p.slice(2);
119078
+ return p;
119079
+ }
119080
+ function parseUnifiedDiff(patch) {
119081
+ const lines = patch.replace(/\r\n/g, `
119082
+ `).split(`
119083
+ `);
119084
+ const files = [];
119085
+ let i = 0;
119086
+ while (i < lines.length) {
119087
+ while (i < lines.length && !lines[i].startsWith("--- ") && !lines[i].startsWith("diff --git ")) {
119088
+ i++;
119089
+ }
119090
+ if (i >= lines.length)
119091
+ break;
119092
+ if (lines[i].startsWith("diff --git ")) {
119093
+ i++;
119094
+ continue;
119095
+ }
119096
+ const oldLine = lines[i];
119097
+ if (!oldLine.startsWith("--- ")) {
119098
+ throw new Error(`Expected "---" file header at line ${i + 1}`);
119099
+ }
119100
+ i++;
119101
+ if (i >= lines.length || !lines[i].startsWith("+++ ")) {
119102
+ throw new Error(`Expected "+++" file header after "---" at line ${i}`);
119103
+ }
119104
+ const newLine = lines[i];
119105
+ i++;
119106
+ const oldPathRaw = oldLine.slice(4).split("\t")[0].trim();
119107
+ const newPathRaw = newLine.slice(4).split("\t")[0].trim();
119108
+ const isNew = oldPathRaw === "/dev/null";
119109
+ const isDelete = newPathRaw === "/dev/null";
119110
+ const oldPath = isNew ? "" : stripPrefix(oldPathRaw);
119111
+ const newPath = isDelete ? "" : stripPrefix(newPathRaw);
119112
+ const hunks = [];
119113
+ while (i < lines.length && lines[i].startsWith("@@ ")) {
119114
+ const header = lines[i];
119115
+ const match = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(header);
119116
+ if (!match) {
119117
+ throw new Error(`Malformed hunk header: ${header}`);
119118
+ }
119119
+ i++;
119120
+ const hunkLines = [];
119121
+ while (i < lines.length && !lines[i].startsWith("@@ ") && !lines[i].startsWith("--- ") && !lines[i].startsWith("diff --git ")) {
119122
+ const l = lines[i];
119123
+ if (l.startsWith(" ") || l.startsWith("+") || l.startsWith("-") || l === "\") {
119124
+ hunkLines.push(l);
119125
+ i++;
119126
+ } else if (l === "") {
119127
+ break;
119128
+ } else {
119129
+ throw new Error(`Unexpected line in hunk: ${l}`);
119130
+ }
119131
+ }
119132
+ hunks.push({
119133
+ oldStart: Number(match[1]),
119134
+ oldCount: match[2] !== undefined ? Number(match[2]) : 1,
119135
+ newStart: Number(match[3]),
119136
+ newCount: match[4] !== undefined ? Number(match[4]) : 1,
119137
+ lines: hunkLines
119138
+ });
119139
+ }
119140
+ if (hunks.length === 0 && !isNew && !isDelete) {
119141
+ throw new Error(`No hunks found for file ${newPath || oldPath || "(unknown)"}`);
119142
+ }
119143
+ files.push({ oldPath, newPath, hunks, isNew, isDelete });
119144
+ }
119145
+ if (files.length === 0) {
119146
+ throw new Error("Patch contained no file diffs");
119147
+ }
119148
+ return files;
119149
+ }
119150
+ function resolveUnderCwd(agentCwd, filePath) {
119151
+ const resolved = isAbsolute7(filePath) ? filePath : resolve8(agentCwd, filePath);
119152
+ const rel = relative5(agentCwd, resolved);
119153
+ if (rel.startsWith("..") || isAbsolute7(rel)) {
119154
+ throw new Error(`Path escapes agent working directory: ${filePath}`);
119155
+ }
119156
+ return resolved;
119157
+ }
119158
+ function applyHunksToContent(content, hunks) {
119159
+ const endsWithNewline = content.endsWith(`
119160
+ `);
119161
+ const lines = content === "" ? [] : content.endsWith(`
119162
+ `) ? content.slice(0, -1).split(`
119163
+ `) : content.split(`
119164
+ `);
119165
+ const ordered = [...hunks].sort((a, b) => b.oldStart - a.oldStart);
119166
+ for (const hunk of ordered) {
119167
+ const startIdx = Math.max(0, hunk.oldStart - 1);
119168
+ let cursor = startIdx;
119169
+ const replacement = [];
119170
+ for (const raw of hunk.lines) {
119171
+ if (raw === "\")
119172
+ continue;
119173
+ const tag = raw[0];
119174
+ const text = raw.slice(1);
119175
+ if (tag === " " || tag === "-") {
119176
+ if (cursor >= lines.length || lines[cursor] !== text) {
119177
+ const actual = cursor < lines.length ? lines[cursor] : "<EOF>";
119178
+ throw new Error(`Hunk context mismatch at line ${cursor + 1}: expected ${JSON.stringify(text)}, got ${JSON.stringify(actual)}`);
119179
+ }
119180
+ if (tag === " ") {
119181
+ replacement.push(text);
119182
+ }
119183
+ cursor++;
119184
+ } else if (tag === "+") {
119185
+ replacement.push(text);
119186
+ } else {
119187
+ throw new Error(`Invalid hunk line prefix: ${raw}`);
119188
+ }
119189
+ }
119190
+ const endIdx = cursor;
119191
+ lines.splice(startIdx, endIdx - startIdx, ...replacement);
119192
+ }
119193
+ if (lines.length === 0)
119194
+ return endsWithNewline ? `
119195
+ ` : "";
119196
+ return `${lines.join(`
119197
+ `)}
119198
+ `;
119199
+ }
119200
+ async function readLocal(path) {
119201
+ try {
119202
+ return await readFile7(path, "utf-8");
119203
+ } catch {
119204
+ return null;
119205
+ }
119206
+ }
119207
+ async function writeLocal(path, content) {
119208
+ await mkdir4(dirname7(path), { recursive: true });
119209
+ await writeFile6(path, content, "utf-8");
119210
+ }
119211
+ async function readViaSandbox(sandbox, path) {
119212
+ const result = await sandbox.execute(`test -f "${path}" && cat "${path}" | base64 -w 0`);
119213
+ if (!result.success || !result.stdout.trim()) {
119214
+ const exists = await sandbox.execute(`test -f "${path}"`);
119215
+ if (exists.exitCode !== 0)
119216
+ return null;
119217
+ return "";
119218
+ }
119219
+ return Buffer.from(result.stdout.trim(), "base64").toString("utf-8");
119220
+ }
119221
+ async function writeViaSandbox(sandbox, path, content) {
119222
+ const dir = dirname7(path);
119223
+ await sandbox.execute(`mkdir -p "${dir}"`);
119224
+ const b64 = Buffer.from(content).toString("base64");
119225
+ const result = await sandbox.execute(`echo "${b64}" | base64 -d > "${path}"`);
119226
+ if (!result.success) {
119227
+ throw new Error(result.stderr || `Failed to write ${path} in sandbox`);
119228
+ }
119229
+ }
119230
+ async function deleteViaSandbox(sandbox, path) {
119231
+ const result = await sandbox.execute(`rm "${path}"`);
119232
+ if (!result.success) {
119233
+ throw new Error(result.stderr || `Failed to delete ${path} in sandbox`);
119234
+ }
119235
+ }
119236
+ function applyPatch(ctx) {
119237
+ return tool({
119238
+ description: `Apply a unified diff patch to one or more files.
119239
+
119240
+ Use this for multi-hunk or multi-file edits. For a single small string replace,
119241
+ prefer update_file.
119242
+
119243
+ The patch must be a standard unified diff with ---/+++ headers and @@ hunks.
119244
+ Context lines must match the current file contents exactly — the tool fails
119245
+ loudly on mismatch and does not partially apply remaining files after a failure
119246
+ within a file. Paths must stay under the agent working directory.
119247
+
119248
+ Example:
119249
+ \`\`\`
119250
+ --- a/src/auth.ts
119251
+ +++ b/src/auth.ts
119252
+ @@ -10,7 +10,7 @@
119253
+ function login(user, pass) {
119254
+ - query = "SELECT * FROM users WHERE name='" + user + "'"
119255
+ + query = db.prepare("SELECT * FROM users WHERE name=?")
119256
+ }
119257
+ \`\`\``,
119258
+ inputSchema: applyPatchInputSchema,
119259
+ execute: async ({ patch }) => {
119260
+ let files;
119261
+ try {
119262
+ files = parseUnifiedDiff(patch);
119263
+ } catch (err) {
119264
+ return {
119265
+ success: false,
119266
+ error: err instanceof Error ? err.message : String(err),
119267
+ files: []
119268
+ };
119269
+ }
119270
+ const results = [];
119271
+ for (const file of files) {
119272
+ const displayPath = file.newPath || file.oldPath;
119273
+ try {
119274
+ const targetPath = resolveUnderCwd(ctx.agentCwd, file.isDelete ? file.oldPath : file.newPath || file.oldPath);
119275
+ if (file.isDelete) {
119276
+ if (ctx.sandbox) {
119277
+ await deleteViaSandbox(ctx.sandbox, targetPath);
119278
+ } else {
119279
+ await unlink(targetPath);
119280
+ }
119281
+ results.push({
119282
+ path: displayPath,
119283
+ success: true,
119284
+ hunksApplied: 0
119285
+ });
119286
+ continue;
119287
+ }
119288
+ const existing = ctx.sandbox ? await readViaSandbox(ctx.sandbox, targetPath) : await readLocal(targetPath);
119289
+ if (file.isNew) {
119290
+ if (existing !== null) {
119291
+ throw new Error(`Cannot create ${targetPath}: file already exists`);
119292
+ }
119293
+ const created = applyHunksToContent("", file.hunks);
119294
+ if (ctx.sandbox) {
119295
+ await writeViaSandbox(ctx.sandbox, targetPath, created);
119296
+ } else {
119297
+ await writeLocal(targetPath, created);
119298
+ }
119299
+ results.push({
119300
+ path: displayPath,
119301
+ success: true,
119302
+ hunksApplied: file.hunks.length
119303
+ });
119304
+ continue;
119305
+ }
119306
+ if (existing === null) {
119307
+ throw new Error(`File not found: ${targetPath}`);
119308
+ }
119309
+ const updated = applyHunksToContent(existing, file.hunks);
119310
+ if (ctx.sandbox) {
119311
+ await writeViaSandbox(ctx.sandbox, targetPath, updated);
119312
+ } else {
119313
+ await writeLocal(targetPath, updated);
119314
+ }
119315
+ results.push({
119316
+ path: displayPath,
119317
+ success: true,
119318
+ hunksApplied: file.hunks.length
119319
+ });
119320
+ } catch (err) {
119321
+ const message = err instanceof Error ? err.message : String(err);
119322
+ results.push({
119323
+ path: displayPath,
119324
+ success: false,
119325
+ error: message
119326
+ });
119327
+ return {
119328
+ success: false,
119329
+ error: `Failed applying patch to ${displayPath}: ${message}`,
119330
+ files: results
119331
+ };
119332
+ }
119333
+ }
119334
+ return {
119335
+ success: true,
119336
+ error: "",
119337
+ files: results
119338
+ };
119339
+ }
119340
+ });
119341
+ }
119342
+ // src/core/agents/offSecAgent/tools/deleteFile.ts
119343
+ init_dist();
119344
+ init_zod();
119345
+ import { unlink as unlink2 } from "node:fs/promises";
119346
+ import { isAbsolute as isAbsolute8, relative as relative6, resolve as resolve9 } from "node:path";
119347
+ var deleteFileInputSchema = exports_external.object({
119348
+ path: exports_external.string().describe("Absolute or relative path to the file to delete"),
119349
+ toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Remove obsolete insecure helper')")
119350
+ });
119351
+ function resolveUnderCwd2(agentCwd, filePath) {
119352
+ const resolved = isAbsolute8(filePath) ? filePath : resolve9(agentCwd, filePath);
119353
+ const rel = relative6(agentCwd, resolved);
119354
+ if (rel.startsWith("..") || isAbsolute8(rel)) {
119355
+ throw new Error(`Path escapes agent working directory: ${filePath}`);
119356
+ }
119357
+ return resolved;
119358
+ }
119359
+ function deleteFile(ctx) {
119360
+ return tool({
119361
+ description: `Delete a file from the filesystem.
119362
+
119363
+ Only deletes files (not directories). Path must stay within the agent working directory.
119364
+ Fails loudly if the file does not exist.`,
119365
+ inputSchema: deleteFileInputSchema,
119366
+ execute: async ({ path: filePath }) => {
119367
+ let target;
119368
+ try {
119369
+ target = resolveUnderCwd2(ctx.agentCwd, filePath);
119370
+ } catch (err) {
119371
+ return {
119372
+ success: false,
119373
+ error: err instanceof Error ? err.message : String(err),
119374
+ path: filePath
119375
+ };
119376
+ }
119377
+ if (ctx.sandbox) {
119378
+ try {
119379
+ const check = await ctx.sandbox.execute(`test -f "${target}"`);
119380
+ if (check.exitCode !== 0) {
119381
+ return {
119382
+ success: false,
119383
+ error: `File not found: ${target}`,
119384
+ path: target
119385
+ };
119386
+ }
119387
+ const result = await ctx.sandbox.execute(`rm "${target}"`);
119388
+ if (!result.success) {
119389
+ return {
119390
+ success: false,
119391
+ error: result.stderr || "Failed to delete file in sandbox",
119392
+ path: target
119393
+ };
119394
+ }
119395
+ return { success: true, error: "", path: target };
119396
+ } catch (err) {
119397
+ return {
119398
+ success: false,
119399
+ error: err instanceof Error ? err.message : String(err),
119400
+ path: target
119401
+ };
119402
+ }
119403
+ }
119404
+ try {
119405
+ await unlink2(target);
119406
+ return { success: true, error: "", path: target };
119407
+ } catch (err) {
119408
+ return {
119409
+ success: false,
119410
+ error: err instanceof Error ? err.message : String(err),
119411
+ path: target
119412
+ };
119413
+ }
119414
+ }
119415
+ });
119416
+ }
119417
+ // src/core/agents/offSecAgent/tools/gitDiff.ts
119418
+ init_dist();
119419
+ init_zod();
119420
+
119421
+ // src/core/agents/offSecAgent/tools/gitStatus.ts
119422
+ init_dist();
119423
+ init_zod();
119424
+ var gitStatusInputSchema = exports_external.object({
119425
+ toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Check which files were modified')")
119426
+ });
119427
+ async function runGit2(ctx, args) {
119428
+ const command = `git ${args.map((a) => `'${a.replace(/'/g, `'\\''`)}'`).join(" ")}`;
119429
+ const full = `cd "${ctx.agentCwd}" && ${command}`;
119430
+ if (ctx.sandbox) {
119431
+ const result = await ctx.sandbox.execute(full, { timeout: 30 });
119432
+ return {
119433
+ success: result.success,
119434
+ stdout: result.stdout,
119435
+ stderr: result.stderr
119436
+ };
119437
+ }
119438
+ if (ctx.persistentShell) {
119439
+ const result = await ctx.persistentShell.execute(full, 30, undefined, ctx.abortSignal);
119440
+ return {
119441
+ success: result.exitCode === 0,
119442
+ stdout: result.stdout,
119443
+ stderr: result.stderr
119444
+ };
119445
+ }
119446
+ return {
119447
+ success: false,
119448
+ stdout: "",
119449
+ stderr: "No shell or sandbox available"
119450
+ };
119451
+ }
119452
+ function gitStatus(ctx) {
119453
+ return tool({
119454
+ description: `Show git working-tree status (porcelain) for the agent repository.
119455
+
119456
+ Use this to self-check which files you changed before finalizing.
119457
+ Does not commit, stage, push, or open a PR.`,
119458
+ inputSchema: gitStatusInputSchema,
119459
+ execute: async () => {
119460
+ const result = await runGit2(ctx, ["status", "--porcelain"]);
119461
+ if (!result.success) {
119462
+ return {
119463
+ success: false,
119464
+ error: result.stderr || "git status failed",
119465
+ status: result.stdout,
119466
+ cwd: ctx.agentCwd
119467
+ };
119468
+ }
119469
+ return {
119470
+ success: true,
119471
+ error: "",
119472
+ status: result.stdout.trim() || "(clean)",
119473
+ cwd: ctx.agentCwd
119474
+ };
119475
+ }
119476
+ });
119477
+ }
119478
+
119479
+ // src/core/agents/offSecAgent/tools/gitDiff.ts
119480
+ var gitDiffInputSchema = exports_external.object({
119481
+ path: exports_external.string().optional().describe("Optional path to limit the diff to a single file or directory"),
119482
+ staged: exports_external.boolean().optional().describe("If true, show staged (--cached) diff. Default: unstaged."),
119483
+ toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Review unstaged patch before finalize')")
119484
+ });
119485
+ var MAX_DIFF = 1e5;
119486
+ function gitDiff(ctx) {
119487
+ return tool({
119488
+ description: `Show the git diff for the agent repository.
119489
+
119490
+ Defaults to unstaged working-tree changes. Set staged=true for the index.
119491
+ Optionally pass path to limit output to one file/directory.
119492
+ Does not commit, stage, push, or open a PR.`,
119493
+ inputSchema: gitDiffInputSchema,
119494
+ execute: async ({ path, staged = false }) => {
119495
+ const args = ["diff"];
119496
+ if (staged)
119497
+ args.push("--cached");
119498
+ if (path)
119499
+ args.push("--", path);
119500
+ const result = await runGit2(ctx, args);
119501
+ if (!result.success) {
119502
+ return {
119503
+ success: false,
119504
+ error: result.stderr || "git diff failed",
119505
+ diff: result.stdout,
119506
+ cwd: ctx.agentCwd
119507
+ };
119508
+ }
119509
+ const raw = result.stdout;
119510
+ const truncated = raw.length > MAX_DIFF;
119511
+ return {
119512
+ success: true,
119513
+ error: truncated ? `Diff truncated to ${MAX_DIFF} characters — narrow with path` : "",
119514
+ diff: truncated ? `${raw.slice(0, MAX_DIFF)}
119515
+
119516
+ (truncated)` : raw || "(no changes)",
119517
+ cwd: ctx.agentCwd
119518
+ };
119519
+ }
119520
+ });
119521
+ }
119522
+ // src/core/agents/offSecAgent/tools/glob.ts
119523
+ init_dist();
119524
+ import { isAbsolute as isAbsolute9, relative as relative7, resolve as resolve10 } from "node:path";
119525
+
119526
+ // node_modules/glob/dist/esm/index.min.js
119527
+ import { fileURLToPath as Wi } from "node:url";
119528
+ import { posix as mi, win32 as re } from "node:path";
119529
+ import { fileURLToPath as gi } from "node:url";
119530
+ import { lstatSync as wi, readdir as yi, readdirSync as bi, readlinkSync as Si, realpathSync as Ei } from "fs";
119531
+ import * as xi from "node:fs";
119532
+ import { lstat as Ci, readdir as Ti, readlink as Ai, realpath as ki } from "node:fs/promises";
119533
+ import { EventEmitter as ee } from "node:events";
119534
+ import Pe from "node:stream";
119535
+ import { StringDecoder as ni } from "node:string_decoder";
119536
+ var Gt = (n, t, e) => {
119537
+ 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);
119538
+ 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) };
119539
+ };
119540
+ var ce = (n, t) => {
119541
+ let e = t.match(n);
119542
+ return e ? e[0] : null;
119543
+ };
119544
+ var ss = (n, t, e) => {
119545
+ let s, i, r, o, h, a = e.indexOf(n), l = e.indexOf(t, a + 1), u = a;
119546
+ if (a >= 0 && l > 0) {
119547
+ if (n === t)
119548
+ return [a, l];
119549
+ for (s = [], r = e.length;u >= 0 && !h; ) {
119550
+ if (u === a)
119551
+ s.push(u), a = e.indexOf(n, u + 1);
119552
+ else if (s.length === 1) {
119553
+ let c = s.pop();
119554
+ c !== undefined && (h = [c, l]);
119555
+ } else
119556
+ i = s.pop(), i !== undefined && i < r && (r = i, o = l), l = e.indexOf(t, u + 1);
119557
+ u = a < l && a >= 0 ? a : l;
119558
+ }
119559
+ s.length && o !== undefined && (h = [r, o]);
119560
+ }
119561
+ return h;
119562
+ };
119563
+ var fe = "\x00SLASH" + Math.random() + "\x00";
119564
+ var ue = "\x00OPEN" + Math.random() + "\x00";
119565
+ var qt = "\x00CLOSE" + Math.random() + "\x00";
119566
+ var de = "\x00COMMA" + Math.random() + "\x00";
119567
+ var pe = "\x00PERIOD" + Math.random() + "\x00";
119568
+ var is = new RegExp(fe, "g");
119569
+ var rs = new RegExp(ue, "g");
119570
+ var ns = new RegExp(qt, "g");
119571
+ var os = new RegExp(de, "g");
119572
+ var hs = new RegExp(pe, "g");
119573
+ var as = /\\\\/g;
119574
+ var ls = /\\{/g;
119575
+ var cs = /\\}/g;
119576
+ var fs = /\\,/g;
119577
+ var us = /\\./g;
119578
+ var ds = 1e5;
119579
+ function Ht(n) {
119580
+ return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
119581
+ }
119582
+ function ps(n) {
119583
+ return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs, de).replace(us, pe);
119584
+ }
119585
+ function ms(n) {
119586
+ return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os, ",").replace(hs, ".");
119587
+ }
119588
+ function me(n) {
119589
+ if (!n)
119590
+ return [""];
119591
+ let t = [], e = Gt("{", "}", n);
119592
+ if (!e)
119593
+ return n.split(",");
119594
+ let { pre: s, body: i, post: r } = e, o = s.split(",");
119595
+ o[o.length - 1] += "{" + i + "}";
119596
+ let h = me(r);
119597
+ return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
119598
+ }
119599
+ function ge(n, t = {}) {
119600
+ if (!n)
119601
+ return [];
119602
+ let { max: e = ds } = t;
119603
+ return n.slice(0, 2) === "{}" && (n = "\\{\\}" + n.slice(2)), ht(ps(n), e, true).map(ms);
119604
+ }
119605
+ function gs(n) {
119606
+ return "{" + n + "}";
119607
+ }
119608
+ function ws(n) {
119609
+ return /^-?0\d/.test(n);
119610
+ }
119611
+ function ys(n, t) {
119612
+ return n <= t;
119613
+ }
119614
+ function bs(n, t) {
119615
+ return n >= t;
119616
+ }
119617
+ function ht(n, t, e) {
119618
+ let s = [], i = Gt("{", "}", n);
119619
+ if (!i)
119620
+ return [n];
119621
+ let r = i.pre, o = i.post.length ? ht(i.post, t, false) : [""];
119622
+ if (/\$$/.test(i.pre))
119623
+ for (let h = 0;h < o.length && h < t; h++) {
119624
+ let a = r + "{" + i.body + "}" + o[h];
119625
+ s.push(a);
119626
+ }
119627
+ else {
119628
+ 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;
119629
+ if (!l && !u)
119630
+ return i.post.match(/,(?!,).*\}/) ? (n = i.pre + "{" + i.body + qt + i.post, ht(n, t, true)) : [n];
119631
+ let c;
119632
+ if (l)
119633
+ c = i.body.split(/\.\./);
119634
+ else if (c = me(i.body), c.length === 1 && c[0] !== undefined && (c = ht(c[0], t, false).map(gs), c.length === 1))
119635
+ return o.map((f) => i.pre + c[0] + f);
119636
+ let d;
119637
+ if (l && c[0] !== undefined && c[1] !== undefined) {
119638
+ 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;
119639
+ m < f && (w *= -1, g = bs);
119640
+ let E = c.some(ws);
119641
+ d = [];
119642
+ for (let y = f;g(y, m); y += w) {
119643
+ let b;
119644
+ if (a)
119645
+ b = String.fromCharCode(y), b === "\\" && (b = "");
119646
+ else if (b = String(y), E) {
119647
+ let z = p - b.length;
119648
+ if (z > 0) {
119649
+ let $ = new Array(z + 1).join("0");
119650
+ y < 0 ? b = "-" + $ + b.slice(1) : b = $ + b;
119651
+ }
119652
+ }
119653
+ d.push(b);
119654
+ }
119655
+ } else {
119656
+ d = [];
119657
+ for (let f = 0;f < c.length; f++)
119658
+ d.push.apply(d, ht(c[f], t, false));
119659
+ }
119660
+ for (let f = 0;f < d.length; f++)
119661
+ for (let m = 0;m < o.length && s.length < t; m++) {
119662
+ let p = r + d[f] + o[m];
119663
+ (!e || l || p) && s.push(p);
119664
+ }
119665
+ }
119666
+ return s;
119667
+ }
119668
+ var at = (n) => {
119669
+ if (typeof n != "string")
119670
+ throw new TypeError("invalid pattern");
119671
+ if (n.length > 65536)
119672
+ throw new TypeError("pattern is too long");
119673
+ };
119674
+ 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] };
119675
+ var lt = (n) => n.replace(/[[\]\\-]/g, "\\$&");
119676
+ var Es = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
119677
+ var we = (n) => n.join("");
119678
+ var ye = (n, t) => {
119679
+ let e = t;
119680
+ if (n.charAt(e) !== "[")
119681
+ throw new Error("not in a brace expression");
119682
+ let s = [], i = [], r = e + 1, o = false, h = false, a = false, l = false, u = e, c = "";
119683
+ t:
119684
+ for (;r < n.length; ) {
119685
+ let p = n.charAt(r);
119686
+ if ((p === "!" || p === "^") && r === e + 1) {
119687
+ l = true, r++;
119688
+ continue;
119689
+ }
119690
+ if (p === "]" && o && !a) {
119691
+ u = r + 1;
119692
+ break;
119693
+ }
119694
+ if (o = true, p === "\\" && !a) {
119695
+ a = true, r++;
119696
+ continue;
119697
+ }
119698
+ if (p === "[" && !a) {
119699
+ for (let [w, [g, S, E]] of Object.entries(Ss))
119700
+ if (n.startsWith(w, r)) {
119701
+ if (c)
119702
+ return ["$.", false, n.length - e, true];
119703
+ r += w.length, E ? i.push(g) : s.push(g), h = h || S;
119704
+ continue t;
119705
+ }
119706
+ }
119707
+ if (a = false, c) {
119708
+ p > c ? s.push(lt(c) + "-" + lt(p)) : p === c && s.push(lt(p)), c = "", r++;
119709
+ continue;
119710
+ }
119711
+ if (n.startsWith("-]", r + 1)) {
119712
+ s.push(lt(p + "-")), r += 2;
119713
+ continue;
119714
+ }
119715
+ if (n.startsWith("-", r + 1)) {
119716
+ c = p, r += 2;
119717
+ continue;
119718
+ }
119719
+ s.push(lt(p)), r++;
119720
+ }
119721
+ if (u < r)
119722
+ return ["", false, 0, false];
119723
+ if (!s.length && !i.length)
119724
+ return ["$.", false, n.length - e, true];
119725
+ if (i.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !l) {
119726
+ let p = s[0].length === 2 ? s[0].slice(-1) : s[0];
119727
+ return [Es(p), false, u - e, false];
119728
+ }
119729
+ let d = "[" + (l ? "^" : "") + we(s) + "]", f = "[" + (l ? "" : "^") + we(i) + "]";
119730
+ return [s.length && i.length ? "(" + d + "|" + f + ")" : s.length ? d : f, h, u - e, true];
119731
+ };
119732
+ 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");
119733
+ var xs = new Set(["!", "?", "+", "*", "@"]);
119734
+ var be = (n) => xs.has(n);
119735
+ var vs = "(?!(?:^|/)\\.\\.?(?:$|/))";
119736
+ var Ct = "(?!\\.)";
119737
+ var Cs = new Set(["[", "."]);
119738
+ var Ts = new Set(["..", "."]);
119739
+ var As = new Set("().*{}+?[]^$\\!");
119740
+ var ks = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
119741
+ var Kt = "[^/]";
119742
+ var Se = Kt + "*?";
119743
+ var Ee = Kt + "+?";
119744
+ var Q = class n {
119745
+ type;
119746
+ #t;
119747
+ #s;
119748
+ #n = false;
119749
+ #r = [];
119750
+ #o;
119751
+ #S;
119752
+ #w;
119753
+ #c = false;
119754
+ #h;
119755
+ #u;
119756
+ #f = false;
119757
+ constructor(t, e, s = {}) {
119758
+ 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;
119759
+ }
119760
+ get hasMagic() {
119761
+ if (this.#s !== undefined)
119762
+ return this.#s;
119763
+ for (let t of this.#r)
119764
+ if (typeof t != "string" && (t.type || t.hasMagic))
119765
+ return this.#s = true;
119766
+ return this.#s;
119767
+ }
119768
+ toString() {
119769
+ 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("");
119770
+ }
119771
+ #a() {
119772
+ if (this !== this.#t)
119773
+ throw new Error("should only call on root");
119774
+ if (this.#c)
119775
+ return this;
119776
+ this.toString(), this.#c = true;
119777
+ let t;
119778
+ for (;t = this.#w.pop(); ) {
119779
+ if (t.type !== "!")
119780
+ continue;
119781
+ let e = t, s = e.#o;
119782
+ for (;s; ) {
119783
+ for (let i = e.#S + 1;!s.type && i < s.#r.length; i++)
119784
+ for (let r of t.#r) {
119785
+ if (typeof r == "string")
119786
+ throw new Error("string part in extglob AST??");
119787
+ r.copyIn(s.#r[i]);
119788
+ }
119789
+ e = s, s = e.#o;
119790
+ }
119791
+ }
119792
+ return this;
119793
+ }
119794
+ push(...t) {
119795
+ for (let e of t)
119796
+ if (e !== "") {
119797
+ if (typeof e != "string" && !(e instanceof n && e.#o === this))
119798
+ throw new Error("invalid part: " + e);
119799
+ this.#r.push(e);
119800
+ }
119801
+ }
119802
+ toJSON() {
119803
+ let t = this.type === null ? this.#r.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#r.map((e) => e.toJSON())];
119804
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#t || this.#t.#c && this.#o?.type === "!") && t.push({}), t;
119805
+ }
119806
+ isStart() {
119807
+ if (this.#t === this)
119808
+ return true;
119809
+ if (!this.#o?.isStart())
119810
+ return false;
119811
+ if (this.#S === 0)
119812
+ return true;
119813
+ let t = this.#o;
119814
+ for (let e = 0;e < this.#S; e++) {
119815
+ let s = t.#r[e];
119816
+ if (!(s instanceof n && s.type === "!"))
119817
+ return false;
119818
+ }
119819
+ return true;
119820
+ }
119821
+ isEnd() {
119822
+ if (this.#t === this || this.#o?.type === "!")
119823
+ return true;
119824
+ if (!this.#o?.isEnd())
119825
+ return false;
119826
+ if (!this.type)
119827
+ return this.#o?.isEnd();
119828
+ let t = this.#o ? this.#o.#r.length : 0;
119829
+ return this.#S === t - 1;
119830
+ }
119831
+ copyIn(t) {
119832
+ typeof t == "string" ? this.push(t) : this.push(t.clone(this));
119833
+ }
119834
+ clone(t) {
119835
+ let e = new n(this.type, t);
119836
+ for (let s of this.#r)
119837
+ e.copyIn(s);
119838
+ return e;
119839
+ }
119840
+ static #i(t, e, s, i) {
119841
+ let r = false, o = false, h = -1, a = false;
119842
+ if (e.type === null) {
119843
+ let f = s, m = "";
119844
+ for (;f < t.length; ) {
119845
+ let p = t.charAt(f++);
119846
+ if (r || p === "\\") {
119847
+ r = !r, m += p;
119848
+ continue;
119849
+ }
119850
+ if (o) {
119851
+ f === h + 1 ? (p === "^" || p === "!") && (a = true) : p === "]" && !(f === h + 2 && a) && (o = false), m += p;
119852
+ continue;
119853
+ } else if (p === "[") {
119854
+ o = true, h = f, a = false, m += p;
119855
+ continue;
119856
+ }
119857
+ if (!i.noext && be(p) && t.charAt(f) === "(") {
119858
+ e.push(m), m = "";
119859
+ let w = new n(p, e);
119860
+ f = n.#i(t, w, f, i), e.push(w);
119861
+ continue;
119862
+ }
119863
+ m += p;
119864
+ }
119865
+ return e.push(m), f;
119866
+ }
119867
+ let l = s + 1, u = new n(null, e), c = [], d = "";
119868
+ for (;l < t.length; ) {
119869
+ let f = t.charAt(l++);
119870
+ if (r || f === "\\") {
119871
+ r = !r, d += f;
119872
+ continue;
119873
+ }
119874
+ if (o) {
119875
+ l === h + 1 ? (f === "^" || f === "!") && (a = true) : f === "]" && !(l === h + 2 && a) && (o = false), d += f;
119876
+ continue;
119877
+ } else if (f === "[") {
119878
+ o = true, h = l, a = false, d += f;
119879
+ continue;
119880
+ }
119881
+ if (be(f) && t.charAt(l) === "(") {
119882
+ u.push(d), d = "";
119883
+ let m = new n(f, u);
119884
+ u.push(m), l = n.#i(t, m, l, i);
119885
+ continue;
119886
+ }
119887
+ if (f === "|") {
119888
+ u.push(d), d = "", c.push(u), u = new n(null, e);
119889
+ continue;
119890
+ }
119891
+ if (f === ")")
119892
+ return d === "" && e.#r.length === 0 && (e.#f = true), u.push(d), d = "", e.push(...c, u), l;
119893
+ d += f;
119894
+ }
119895
+ return e.type = null, e.#s = undefined, e.#r = [t.substring(s - 1)], l;
119896
+ }
119897
+ static fromGlob(t, e = {}) {
119898
+ let s = new n(null, undefined, e);
119899
+ return n.#i(t, s, 0, e), s;
119900
+ }
119901
+ toMMPattern() {
119902
+ if (this !== this.#t)
119903
+ return this.#t.toMMPattern();
119904
+ let t = this.toString(), [e, s, i, r] = this.toRegExpSource();
119905
+ if (!(i || this.#s || this.#h.nocase && !this.#h.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
119906
+ return s;
119907
+ let h = (this.#h.nocase ? "i" : "") + (r ? "u" : "");
119908
+ return Object.assign(new RegExp(`^${e}$`, h), { _src: e, _glob: t });
119909
+ }
119910
+ get options() {
119911
+ return this.#h;
119912
+ }
119913
+ toRegExpSource(t) {
119914
+ let e = t ?? !!this.#h.dot;
119915
+ if (this.#t === this && this.#a(), !this.type) {
119916
+ let a = this.isStart() && this.isEnd() && !this.#r.some((f) => typeof f != "string"), l = this.#r.map((f) => {
119917
+ let [m, p, w, g] = typeof f == "string" ? n.#E(f, this.#s, a) : f.toRegExpSource(t);
119918
+ return this.#s = this.#s || w, this.#n = this.#n || g, m;
119919
+ }).join(""), u = "";
119920
+ if (this.isStart() && typeof this.#r[0] == "string" && !(this.#r.length === 1 && Ts.has(this.#r[0]))) {
119921
+ 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));
119922
+ u = p ? vs : w ? Ct : "";
119923
+ }
119924
+ let c = "";
119925
+ return this.isEnd() && this.#t.#c && this.#o?.type === "!" && (c = "(?:$|\\/)"), [u + l + c, W(l), this.#s = !!this.#s, this.#n];
119926
+ }
119927
+ let s = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:", r = this.#d(e);
119928
+ if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
119929
+ let a = this.toString();
119930
+ return this.#r = [a], this.type = null, this.#s = undefined, [a, W(this.toString()), false, false];
119931
+ }
119932
+ let o = !s || t || e || !Ct ? "" : this.#d(true);
119933
+ o === r && (o = ""), o && (r = `(?:${r})(?:${o})*?`);
119934
+ let h = "";
119935
+ if (this.type === "!" && this.#f)
119936
+ h = (this.isStart() && !e ? Ct : "") + Ee;
119937
+ else {
119938
+ let a = this.type === "!" ? "))" + (this.isStart() && !e && !t ? Ct : "") + Se + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
119939
+ h = i + r + a;
119940
+ }
119941
+ return [h, W(r), this.#s = !!this.#s, this.#n];
119942
+ }
119943
+ #d(t) {
119944
+ return this.#r.map((e) => {
119945
+ if (typeof e == "string")
119946
+ throw new Error("string type in extglob ast??");
119947
+ let [s, i, r, o] = e.toRegExpSource(t);
119948
+ return this.#n = this.#n || o, s;
119949
+ }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
119950
+ }
119951
+ static #E(t, e, s = false) {
119952
+ let i = false, r = "", o = false, h = false;
119953
+ for (let a = 0;a < t.length; a++) {
119954
+ let l = t.charAt(a);
119955
+ if (i) {
119956
+ i = false, r += (As.has(l) ? "\\" : "") + l;
119957
+ continue;
119958
+ }
119959
+ if (l === "*") {
119960
+ if (h)
119961
+ continue;
119962
+ h = true, r += s && /^[*]+$/.test(t) ? Ee : Se, e = true;
119963
+ continue;
119964
+ } else
119965
+ h = false;
119966
+ if (l === "\\") {
119967
+ a === t.length - 1 ? r += "\\\\" : i = true;
119968
+ continue;
119969
+ }
119970
+ if (l === "[") {
119971
+ let [u, c, d, f] = ye(t, a);
119972
+ if (d) {
119973
+ r += u, o = o || c, a += d - 1, e = e || f;
119974
+ continue;
119975
+ }
119976
+ }
119977
+ if (l === "?") {
119978
+ r += Kt, e = true;
119979
+ continue;
119980
+ }
119981
+ r += ks(l);
119982
+ }
119983
+ return [r, W(t), !!e, o];
119984
+ }
119985
+ };
119986
+ var tt = (n2, { windowsPathsNoEscape: t = false, magicalBraces: e = false } = {}) => e ? t ? n2.replace(/[?*()[\]{}]/g, "[$&]") : n2.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? n2.replace(/[?*()[\]]/g, "[$&]") : n2.replace(/[?*()[\]\\]/g, "\\$&");
119987
+ var O = (n2, t, e = {}) => (at(t), !e.nocomment && t.charAt(0) === "#" ? false : new D(t, e).match(n2));
119988
+ var Rs = /^\*+([^+@!?\*\[\(]*)$/;
119989
+ var Os = (n2) => (t) => !t.startsWith(".") && t.endsWith(n2);
119990
+ var Fs = (n2) => (t) => t.endsWith(n2);
119991
+ var Ds = (n2) => (n2 = n2.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n2));
119992
+ var Ms = (n2) => (n2 = n2.toLowerCase(), (t) => t.toLowerCase().endsWith(n2));
119993
+ var Ns = /^\*+\.\*+$/;
119994
+ var _s = (n2) => !n2.startsWith(".") && n2.includes(".");
119995
+ var Ls = (n2) => n2 !== "." && n2 !== ".." && n2.includes(".");
119996
+ var Ws = /^\.\*+$/;
119997
+ var Ps = (n2) => n2 !== "." && n2 !== ".." && n2.startsWith(".");
119998
+ var js = /^\*+$/;
119999
+ var Is = (n2) => n2.length !== 0 && !n2.startsWith(".");
120000
+ var zs = (n2) => n2.length !== 0 && n2 !== "." && n2 !== "..";
120001
+ var Bs = /^\?+([^+@!?\*\[\(]*)?$/;
120002
+ var Us = ([n2, t = ""]) => {
120003
+ let e = Ce([n2]);
120004
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
120005
+ };
120006
+ var $s = ([n2, t = ""]) => {
120007
+ let e = Te([n2]);
120008
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
120009
+ };
120010
+ var Gs = ([n2, t = ""]) => {
120011
+ let e = Te([n2]);
120012
+ return t ? (s) => e(s) && s.endsWith(t) : e;
120013
+ };
120014
+ var Hs = ([n2, t = ""]) => {
120015
+ let e = Ce([n2]);
120016
+ return t ? (s) => e(s) && s.endsWith(t) : e;
120017
+ };
120018
+ var Ce = ([n2]) => {
120019
+ let t = n2.length;
120020
+ return (e) => e.length === t && !e.startsWith(".");
120021
+ };
120022
+ var Te = ([n2]) => {
120023
+ let t = n2.length;
120024
+ return (e) => e.length === t && e !== "." && e !== "..";
120025
+ };
120026
+ var Ae = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
120027
+ var xe = { win32: { sep: "\\" }, posix: { sep: "/" } };
120028
+ var qs = Ae === "win32" ? xe.win32.sep : xe.posix.sep;
120029
+ O.sep = qs;
120030
+ var A = Symbol("globstar **");
120031
+ O.GLOBSTAR = A;
120032
+ var Ks = "[^/]";
120033
+ var Vs = Ks + "*?";
120034
+ var Ys = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
120035
+ var Xs = "(?:(?!(?:\\/|^)\\.).)*?";
120036
+ var Js = (n2, t = {}) => (e) => O(e, n2, t);
120037
+ O.filter = Js;
120038
+ var N = (n2, t = {}) => Object.assign({}, n2, t);
120039
+ var Zs = (n2) => {
120040
+ if (!n2 || typeof n2 != "object" || !Object.keys(n2).length)
120041
+ return O;
120042
+ let t = O;
120043
+ return Object.assign((s, i, r = {}) => t(s, i, N(n2, r)), { Minimatch: class extends t.Minimatch {
120044
+ constructor(i, r = {}) {
120045
+ super(i, N(n2, r));
120046
+ }
120047
+ static defaults(i) {
120048
+ return t.defaults(N(n2, i)).Minimatch;
120049
+ }
120050
+ }, AST: class extends t.AST {
120051
+ constructor(i, r, o = {}) {
120052
+ super(i, r, N(n2, o));
120053
+ }
120054
+ static fromGlob(i, r = {}) {
120055
+ return t.AST.fromGlob(i, N(n2, r));
120056
+ }
120057
+ }, 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 });
120058
+ };
120059
+ O.defaults = Zs;
120060
+ var ke = (n2, t = {}) => (at(n2), t.nobrace || !/\{(?:(?!\{).)*\}/.test(n2) ? [n2] : ge(n2, { max: t.braceExpandMax }));
120061
+ O.braceExpand = ke;
120062
+ var Qs = (n2, t = {}) => new D(n2, t).makeRe();
120063
+ O.makeRe = Qs;
120064
+ var ti = (n2, t, e = {}) => {
120065
+ let s = new D(t, e);
120066
+ return n2 = n2.filter((i) => s.match(i)), s.options.nonull && !n2.length && n2.push(t), n2;
120067
+ };
120068
+ O.match = ti;
120069
+ var ve = /[?*]|[+@!]\(.*?\)|\[|\]/;
120070
+ var ei = (n2) => n2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
120071
+ var D = class {
120072
+ options;
120073
+ set;
120074
+ pattern;
120075
+ windowsPathsNoEscape;
120076
+ nonegate;
120077
+ negate;
120078
+ comment;
120079
+ empty;
120080
+ preserveMultipleSlashes;
120081
+ partial;
120082
+ globSet;
120083
+ globParts;
120084
+ nocase;
120085
+ isWindows;
120086
+ platform;
120087
+ windowsNoMagicRoot;
120088
+ regexp;
120089
+ constructor(t, e = {}) {
120090
+ at(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ae, this.isWindows = this.platform === "win32";
120091
+ let s = "allowWindowsEscape";
120092
+ 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();
120093
+ }
120094
+ hasMagic() {
120095
+ if (this.options.magicalBraces && this.set.length > 1)
120096
+ return true;
120097
+ for (let t of this.set)
120098
+ for (let e of t)
120099
+ if (typeof e != "string")
120100
+ return true;
120101
+ return false;
120102
+ }
120103
+ debug(...t) {}
120104
+ make() {
120105
+ let t = this.pattern, e = this.options;
120106
+ if (!e.nocomment && t.charAt(0) === "#") {
120107
+ this.comment = true;
120108
+ return;
120109
+ }
120110
+ if (!t) {
120111
+ this.empty = true;
120112
+ return;
120113
+ }
120114
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
120115
+ let s = this.globSet.map((r) => this.slashSplit(r));
120116
+ this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
120117
+ let i = this.globParts.map((r, o, h) => {
120118
+ if (this.isWindows && this.windowsNoMagicRoot) {
120119
+ let a = r[0] === "" && r[1] === "" && (r[2] === "?" || !ve.test(r[2])) && !ve.test(r[3]), l = /^[a-z]:/i.test(r[0]);
120120
+ if (a)
120121
+ return [...r.slice(0, 4), ...r.slice(4).map((u) => this.parse(u))];
120122
+ if (l)
120123
+ return [r[0], ...r.slice(1).map((u) => this.parse(u))];
120124
+ }
120125
+ return r.map((a) => this.parse(a));
120126
+ });
120127
+ if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(false) === -1), this.isWindows)
120128
+ for (let r = 0;r < this.set.length; r++) {
120129
+ let o = this.set[r];
120130
+ o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
120131
+ }
120132
+ this.debug(this.pattern, this.set);
120133
+ }
120134
+ preprocess(t) {
120135
+ if (this.options.noglobstar)
120136
+ for (let s = 0;s < t.length; s++)
120137
+ for (let i = 0;i < t[s].length; i++)
120138
+ t[s][i] === "**" && (t[s][i] = "*");
120139
+ let { optimizationLevel: e = 1 } = this.options;
120140
+ return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
120141
+ }
120142
+ adjascentGlobstarOptimize(t) {
120143
+ return t.map((e) => {
120144
+ let s = -1;
120145
+ for (;(s = e.indexOf("**", s + 1)) !== -1; ) {
120146
+ let i = s;
120147
+ for (;e[i + 1] === "**"; )
120148
+ i++;
120149
+ i !== s && e.splice(s, i - s);
120150
+ }
120151
+ return e;
120152
+ });
120153
+ }
120154
+ levelOneOptimize(t) {
120155
+ return t.map((e) => (e = e.reduce((s, i) => {
120156
+ let r = s[s.length - 1];
120157
+ return i === "**" && r === "**" ? s : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (s.pop(), s) : (s.push(i), s);
120158
+ }, []), e.length === 0 ? [""] : e));
120159
+ }
120160
+ levelTwoFileOptimize(t) {
120161
+ Array.isArray(t) || (t = this.slashSplit(t));
120162
+ let e = false;
120163
+ do {
120164
+ if (e = false, !this.preserveMultipleSlashes) {
120165
+ for (let i = 1;i < t.length - 1; i++) {
120166
+ let r = t[i];
120167
+ i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = true, t.splice(i, 1), i--);
120168
+ }
120169
+ t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = true, t.pop());
120170
+ }
120171
+ let s = 0;
120172
+ for (;(s = t.indexOf("..", s + 1)) !== -1; ) {
120173
+ let i = t[s - 1];
120174
+ i && i !== "." && i !== ".." && i !== "**" && (e = true, t.splice(s - 1, 2), s -= 2);
120175
+ }
120176
+ } while (e);
120177
+ return t.length === 0 ? [""] : t;
120178
+ }
120179
+ firstPhasePreProcess(t) {
120180
+ let e = false;
120181
+ do {
120182
+ e = false;
120183
+ for (let s of t) {
120184
+ let i = -1;
120185
+ for (;(i = s.indexOf("**", i + 1)) !== -1; ) {
120186
+ let o = i;
120187
+ for (;s[o + 1] === "**"; )
120188
+ o++;
120189
+ o > i && s.splice(i + 1, o - i);
120190
+ let h = s[i + 1], a = s[i + 2], l = s[i + 3];
120191
+ if (h !== ".." || !a || a === "." || a === ".." || !l || l === "." || l === "..")
120192
+ continue;
120193
+ e = true, s.splice(i, 1);
120194
+ let u = s.slice(0);
120195
+ u[i] = "**", t.push(u), i--;
120196
+ }
120197
+ if (!this.preserveMultipleSlashes) {
120198
+ for (let o = 1;o < s.length - 1; o++) {
120199
+ let h = s[o];
120200
+ o === 1 && h === "" && s[0] === "" || (h === "." || h === "") && (e = true, s.splice(o, 1), o--);
120201
+ }
120202
+ s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = true, s.pop());
120203
+ }
120204
+ let r = 0;
120205
+ for (;(r = s.indexOf("..", r + 1)) !== -1; ) {
120206
+ let o = s[r - 1];
120207
+ if (o && o !== "." && o !== ".." && o !== "**") {
120208
+ e = true;
120209
+ let a = r === 1 && s[r + 1] === "**" ? ["."] : [];
120210
+ s.splice(r - 1, 2, ...a), s.length === 0 && s.push(""), r -= 2;
120211
+ }
120212
+ }
120213
+ }
120214
+ } while (e);
120215
+ return t;
120216
+ }
120217
+ secondPhasePreProcess(t) {
120218
+ for (let e = 0;e < t.length - 1; e++)
120219
+ for (let s = e + 1;s < t.length; s++) {
120220
+ let i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
120221
+ if (i) {
120222
+ t[e] = [], t[s] = i;
120223
+ break;
120224
+ }
120225
+ }
120226
+ return t.filter((e) => e.length);
120227
+ }
120228
+ partsMatch(t, e, s = false) {
120229
+ let i = 0, r = 0, o = [], h = "";
120230
+ for (;i < t.length && r < e.length; )
120231
+ if (t[i] === e[r])
120232
+ o.push(h === "b" ? e[r] : t[i]), i++, r++;
120233
+ else if (s && t[i] === "**" && e[r] === t[i + 1])
120234
+ o.push(t[i]), i++;
120235
+ else if (s && e[r] === "**" && t[i] === e[r + 1])
120236
+ o.push(e[r]), r++;
120237
+ else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
120238
+ if (h === "b")
120239
+ return false;
120240
+ h = "a", o.push(t[i]), i++, r++;
120241
+ } else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
120242
+ if (h === "a")
120243
+ return false;
120244
+ h = "b", o.push(e[r]), i++, r++;
120245
+ } else
120246
+ return false;
120247
+ return t.length === e.length && o;
120248
+ }
120249
+ parseNegate() {
120250
+ if (this.nonegate)
120251
+ return;
120252
+ let t = this.pattern, e = false, s = 0;
120253
+ for (let i = 0;i < t.length && t.charAt(i) === "!"; i++)
120254
+ e = !e, s++;
120255
+ s && (this.pattern = t.slice(s)), this.negate = e;
120256
+ }
120257
+ matchOne(t, e, s = false) {
120258
+ let i = this.options;
120259
+ if (this.isWindows) {
120260
+ 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;
120261
+ if (typeof E == "number" && typeof y == "number") {
120262
+ let [b, z] = [t[E], e[y]];
120263
+ b.toLowerCase() === z.toLowerCase() && (e[y] = b, y > E ? e = e.slice(y) : E > y && (t = t.slice(E)));
120264
+ }
120265
+ }
120266
+ let { optimizationLevel: r = 1 } = this.options;
120267
+ r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
120268
+ for (var o = 0, h = 0, a = t.length, l = e.length;o < a && h < l; o++, h++) {
120269
+ this.debug("matchOne loop");
120270
+ var u = e[h], c = t[o];
120271
+ if (this.debug(e, u, c), u === false)
120272
+ return false;
120273
+ if (u === A) {
120274
+ this.debug("GLOBSTAR", [e, u, c]);
120275
+ var d = o, f = h + 1;
120276
+ if (f === l) {
120277
+ for (this.debug("** at the end");o < a; o++)
120278
+ if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".")
120279
+ return false;
120280
+ return true;
120281
+ }
120282
+ for (;d < a; ) {
120283
+ var m = t[d];
120284
+ if (this.debug(`
120285
+ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s))
120286
+ return this.debug("globstar found match!", d, a, m), true;
120287
+ if (m === "." || m === ".." || !i.dot && m.charAt(0) === ".") {
120288
+ this.debug("dot detected!", t, d, e, f);
120289
+ break;
120290
+ }
120291
+ this.debug("globstar swallow a segment, and continue"), d++;
120292
+ }
120293
+ return !!(s && (this.debug(`
120294
+ >>> no match, partial?`, t, d, e, f), d === a));
120295
+ }
120296
+ let p;
120297
+ 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)
120298
+ return false;
120299
+ }
120300
+ if (o === a && h === l)
120301
+ return true;
120302
+ if (o === a)
120303
+ return s;
120304
+ if (h === l)
120305
+ return o === a - 1 && t[o] === "";
120306
+ throw new Error("wtf?");
120307
+ }
120308
+ braceExpand() {
120309
+ return ke(this.pattern, this.options);
120310
+ }
120311
+ parse(t) {
120312
+ at(t);
120313
+ let e = this.options;
120314
+ if (t === "**")
120315
+ return A;
120316
+ if (t === "")
120317
+ return "";
120318
+ let s, i = null;
120319
+ (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);
120320
+ let r = Q.fromGlob(t, this.options).toMMPattern();
120321
+ return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
120322
+ }
120323
+ makeRe() {
120324
+ if (this.regexp || this.regexp === false)
120325
+ return this.regexp;
120326
+ let t = this.set;
120327
+ if (!t.length)
120328
+ return this.regexp = false, this.regexp;
120329
+ let e = this.options, s = e.noglobstar ? Vs : e.dot ? Ys : Xs, i = new Set(e.nocase ? ["i"] : []), r = t.map((a) => {
120330
+ let l = a.map((c) => {
120331
+ if (c instanceof RegExp)
120332
+ for (let d of c.flags.split(""))
120333
+ i.add(d);
120334
+ return typeof c == "string" ? ei(c) : c === A ? A : c._src;
120335
+ });
120336
+ l.forEach((c, d) => {
120337
+ let f = l[d + 1], m = l[d - 1];
120338
+ 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));
120339
+ });
120340
+ let u = l.filter((c) => c !== A);
120341
+ if (this.partial && u.length >= 1) {
120342
+ let c = [];
120343
+ for (let d = 1;d <= u.length; d++)
120344
+ c.push(u.slice(0, d).join("/"));
120345
+ return "(?:" + c.join("|") + ")";
120346
+ }
120347
+ return u.join("/");
120348
+ }).join("|"), [o, h] = t.length > 1 ? ["(?:", ")"] : ["", ""];
120349
+ r = "^" + o + r + h + "$", this.partial && (r = "^(?:\\/|" + o + r.slice(1, -1) + h + ")$"), this.negate && (r = "^(?!" + r + ").+$");
120350
+ try {
120351
+ this.regexp = new RegExp(r, [...i].join(""));
120352
+ } catch {
120353
+ this.regexp = false;
120354
+ }
120355
+ return this.regexp;
120356
+ }
120357
+ slashSplit(t) {
120358
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
120359
+ }
120360
+ match(t, e = this.partial) {
120361
+ if (this.debug("match", t, this.pattern), this.comment)
120362
+ return false;
120363
+ if (this.empty)
120364
+ return t === "";
120365
+ if (t === "/" && e)
120366
+ return true;
120367
+ let s = this.options;
120368
+ this.isWindows && (t = t.split("\\").join("/"));
120369
+ let i = this.slashSplit(t);
120370
+ this.debug(this.pattern, "split", i);
120371
+ let r = this.set;
120372
+ this.debug(this.pattern, "set", r);
120373
+ let o = i[i.length - 1];
120374
+ if (!o)
120375
+ for (let h = i.length - 2;!o && h >= 0; h--)
120376
+ o = i[h];
120377
+ for (let h = 0;h < r.length; h++) {
120378
+ let a = r[h], l = i;
120379
+ if (s.matchBase && a.length === 1 && (l = [o]), this.matchOne(l, a, e))
120380
+ return s.flipNegate ? true : !this.negate;
120381
+ }
120382
+ return s.flipNegate ? false : this.negate;
120383
+ }
120384
+ static defaults(t) {
120385
+ return O.defaults(t).Minimatch;
120386
+ }
120387
+ };
120388
+ O.AST = Q;
120389
+ O.Minimatch = D;
120390
+ O.escape = tt;
120391
+ O.unescape = W;
120392
+ var si = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
120393
+ var Oe = new Set;
120394
+ var Vt = typeof process == "object" && process ? process : {};
120395
+ var Fe = (n2, t, e, s) => {
120396
+ typeof Vt.emitWarning == "function" ? Vt.emitWarning(n2, t, e, s) : console.error(`[${e}] ${t}: ${n2}`);
120397
+ };
120398
+ var At = globalThis.AbortController;
120399
+ var Re = globalThis.AbortSignal;
120400
+ if (typeof At > "u") {
120401
+ Re = class {
120402
+ onabort;
120403
+ _onabort = [];
120404
+ reason;
120405
+ aborted = false;
120406
+ addEventListener(e, s) {
120407
+ this._onabort.push(s);
120408
+ }
120409
+ }, At = class {
120410
+ constructor() {
120411
+ t();
120412
+ }
120413
+ signal = new Re;
120414
+ abort(e) {
120415
+ if (!this.signal.aborted) {
120416
+ this.signal.reason = e, this.signal.aborted = true;
120417
+ for (let s of this.signal._onabort)
120418
+ s(e);
120419
+ this.signal.onabort?.(e);
120420
+ }
120421
+ }
120422
+ };
120423
+ let n2 = Vt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
120424
+ 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));
120425
+ };
120426
+ }
120427
+ var ii = (n2) => !Oe.has(n2);
120428
+ var q = (n2) => n2 && n2 === Math.floor(n2) && n2 > 0 && isFinite(n2);
120429
+ 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;
120430
+ var Tt = class extends Array {
120431
+ constructor(n2) {
120432
+ super(n2), this.fill(0);
120433
+ }
120434
+ };
120435
+ var ri = class ct {
120436
+ heap;
120437
+ length;
120438
+ static #t = false;
120439
+ static create(t) {
120440
+ let e = De(t);
120441
+ if (!e)
120442
+ return [];
120443
+ ct.#t = true;
120444
+ let s = new ct(t, e);
120445
+ return ct.#t = false, s;
120446
+ }
120447
+ constructor(t, e) {
120448
+ if (!ct.#t)
120449
+ throw new TypeError("instantiate Stack using Stack.create(n)");
120450
+ this.heap = new e(t), this.length = 0;
120451
+ }
120452
+ push(t) {
120453
+ this.heap[this.length++] = t;
120454
+ }
120455
+ pop() {
120456
+ return this.heap[--this.length];
120457
+ }
120458
+ };
120459
+ var ft = class Me {
120460
+ #t;
120461
+ #s;
120462
+ #n;
120463
+ #r;
120464
+ #o;
120465
+ #S;
120466
+ #w;
120467
+ #c;
120468
+ get perf() {
120469
+ return this.#c;
120470
+ }
120471
+ ttl;
120472
+ ttlResolution;
120473
+ ttlAutopurge;
120474
+ updateAgeOnGet;
120475
+ updateAgeOnHas;
120476
+ allowStale;
120477
+ noDisposeOnSet;
120478
+ noUpdateTTL;
120479
+ maxEntrySize;
120480
+ sizeCalculation;
120481
+ noDeleteOnFetchRejection;
120482
+ noDeleteOnStaleGet;
120483
+ allowStaleOnFetchAbort;
120484
+ allowStaleOnFetchRejection;
120485
+ ignoreFetchAbort;
120486
+ #h;
120487
+ #u;
120488
+ #f;
120489
+ #a;
120490
+ #i;
120491
+ #d;
120492
+ #E;
120493
+ #b;
120494
+ #p;
120495
+ #R;
120496
+ #m;
120497
+ #C;
120498
+ #T;
120499
+ #g;
120500
+ #y;
120501
+ #x;
120502
+ #A;
120503
+ #e;
120504
+ #_;
120505
+ static unsafeExposeInternals(t) {
120506
+ 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() {
120507
+ return t.#b;
120508
+ }, get tail() {
120509
+ return t.#p;
120510
+ }, 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) };
120511
+ }
120512
+ get max() {
120513
+ return this.#t;
120514
+ }
120515
+ get maxSize() {
120516
+ return this.#s;
120517
+ }
120518
+ get calculatedSize() {
120519
+ return this.#u;
120520
+ }
120521
+ get size() {
120522
+ return this.#h;
120523
+ }
120524
+ get fetchMethod() {
120525
+ return this.#S;
120526
+ }
120527
+ get memoMethod() {
120528
+ return this.#w;
120529
+ }
120530
+ get dispose() {
120531
+ return this.#n;
120532
+ }
120533
+ get onInsert() {
120534
+ return this.#r;
120535
+ }
120536
+ get disposeAfter() {
120537
+ return this.#o;
120538
+ }
120539
+ constructor(t) {
120540
+ 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;
120541
+ if (J !== undefined && typeof J?.now != "function")
120542
+ throw new TypeError("perf option must have a now() method if specified");
120543
+ if (this.#c = J ?? si, e !== 0 && !q(e))
120544
+ throw new TypeError("max option must be a nonnegative integer");
120545
+ let Z = e ? De(e) : Array;
120546
+ if (!Z)
120547
+ throw new Error("invalid max value: " + e);
120548
+ if (this.#t = e, this.#s = m, this.maxEntrySize = p || this.#s, this.sizeCalculation = w, this.sizeCalculation) {
120549
+ if (!this.#s && !this.maxEntrySize)
120550
+ throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
120551
+ if (typeof this.sizeCalculation != "function")
120552
+ throw new TypeError("sizeCalculation set to non-function");
120553
+ }
120554
+ if (S !== undefined && typeof S != "function")
120555
+ throw new TypeError("memoMethod must be a function if defined");
120556
+ if (this.#w = S, g !== undefined && typeof g != "function")
120557
+ throw new TypeError("fetchMethod must be a function if specified");
120558
+ 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) {
120559
+ if (this.#s !== 0 && !q(this.#s))
120560
+ throw new TypeError("maxSize must be a positive integer if specified");
120561
+ if (!q(this.maxEntrySize))
120562
+ throw new TypeError("maxEntrySize must be a positive integer if specified");
120563
+ this.#G();
120564
+ }
120565
+ 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) {
120566
+ if (!q(this.ttl))
120567
+ throw new TypeError("ttl must be a positive integer if specified");
120568
+ this.#M();
120569
+ }
120570
+ if (this.#t === 0 && this.ttl === 0 && this.#s === 0)
120571
+ throw new TypeError("At least one of max, maxSize, or ttl is required");
120572
+ if (!this.ttlAutopurge && !this.#t && !this.#s) {
120573
+ let $t = "LRU_CACHE_UNBOUNDED";
120574
+ ii($t) && (Oe.add($t), Fe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", $t, Me));
120575
+ }
120576
+ }
120577
+ getRemainingTTL(t) {
120578
+ return this.#f.has(t) ? 1 / 0 : 0;
120579
+ }
120580
+ #M() {
120581
+ let t = new Tt(this.#t), e = new Tt(this.#t);
120582
+ this.#g = t, this.#T = e;
120583
+ let s = this.ttlAutopurge ? new Array(this.#t) : undefined;
120584
+ this.#y = s, this.#j = (o, h, a = this.#c.now()) => {
120585
+ if (e[o] = h !== 0 ? a : 0, t[o] = h, s?.[o] && (clearTimeout(s[o]), s[o] = undefined), h !== 0 && s) {
120586
+ let l = setTimeout(() => {
120587
+ this.#v(o) && this.#O(this.#a[o], "expire");
120588
+ }, h + 1);
120589
+ l.unref && l.unref(), s[o] = l;
120590
+ }
120591
+ }, this.#k = (o) => {
120592
+ e[o] = t[o] !== 0 ? this.#c.now() : 0;
120593
+ }, this.#N = (o, h) => {
120594
+ if (t[h]) {
120595
+ let a = t[h], l = e[h];
120596
+ if (!a || !l)
120597
+ return;
120598
+ o.ttl = a, o.start = l, o.now = i || r();
120599
+ let u = o.now - l;
120600
+ o.remainingTTL = a - u;
120601
+ }
120602
+ };
120603
+ let i = 0, r = () => {
120604
+ let o = this.#c.now();
120605
+ if (this.ttlResolution > 0) {
120606
+ i = o;
120607
+ let h = setTimeout(() => i = 0, this.ttlResolution);
120608
+ h.unref && h.unref();
120609
+ }
120610
+ return o;
120611
+ };
120612
+ this.getRemainingTTL = (o) => {
120613
+ let h = this.#f.get(o);
120614
+ if (h === undefined)
120615
+ return 0;
120616
+ let a = t[h], l = e[h];
120617
+ if (!a || !l)
120618
+ return 1 / 0;
120619
+ let u = (i || r()) - l;
120620
+ return a - u;
120621
+ }, this.#v = (o) => {
120622
+ let h = e[o], a = t[o];
120623
+ return !!a && !!h && (i || r()) - h > a;
120624
+ };
120625
+ }
120626
+ #k = () => {};
120627
+ #N = () => {};
120628
+ #j = () => {};
120629
+ #v = () => false;
120630
+ #G() {
120631
+ let t = new Tt(this.#t);
120632
+ this.#u = 0, this.#C = t, this.#P = (e) => {
120633
+ this.#u -= t[e], t[e] = 0;
120634
+ }, this.#I = (e, s, i, r) => {
120635
+ if (this.#l(s))
120636
+ return 0;
120637
+ if (!q(i))
120638
+ if (r) {
120639
+ if (typeof r != "function")
120640
+ throw new TypeError("sizeCalculation must be a function");
120641
+ if (i = r(s, e), !q(i))
120642
+ throw new TypeError("sizeCalculation return invalid (expect positive integer)");
120643
+ } else
120644
+ throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
120645
+ return i;
120646
+ }, this.#L = (e, s, i) => {
120647
+ if (t[e] = s, this.#s) {
120648
+ let r = this.#s - t[e];
120649
+ for (;this.#u > r; )
120650
+ this.#B(true);
120651
+ }
120652
+ this.#u += t[e], i && (i.entrySize = s, i.totalCalculatedSize = this.#u);
120653
+ };
120654
+ }
120655
+ #P = (t) => {};
120656
+ #L = (t, e, s) => {};
120657
+ #I = (t, e, s, i) => {
120658
+ if (s || i)
120659
+ throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
120660
+ return 0;
120661
+ };
120662
+ *#F({ allowStale: t = this.allowStale } = {}) {
120663
+ if (this.#h)
120664
+ for (let e = this.#p;!(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#b)); )
120665
+ e = this.#E[e];
120666
+ }
120667
+ *#D({ allowStale: t = this.allowStale } = {}) {
120668
+ if (this.#h)
120669
+ for (let e = this.#b;!(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#p)); )
120670
+ e = this.#d[e];
120671
+ }
120672
+ #z(t) {
120673
+ return t !== undefined && this.#f.get(this.#a[t]) === t;
120674
+ }
120675
+ *entries() {
120676
+ for (let t of this.#F())
120677
+ this.#i[t] !== undefined && this.#a[t] !== undefined && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
120678
+ }
120679
+ *rentries() {
120680
+ for (let t of this.#D())
120681
+ this.#i[t] !== undefined && this.#a[t] !== undefined && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
120682
+ }
120683
+ *keys() {
120684
+ for (let t of this.#F()) {
120685
+ let e = this.#a[t];
120686
+ e !== undefined && !this.#l(this.#i[t]) && (yield e);
120687
+ }
120688
+ }
120689
+ *rkeys() {
120690
+ for (let t of this.#D()) {
120691
+ let e = this.#a[t];
120692
+ e !== undefined && !this.#l(this.#i[t]) && (yield e);
120693
+ }
120694
+ }
120695
+ *values() {
120696
+ for (let t of this.#F())
120697
+ this.#i[t] !== undefined && !this.#l(this.#i[t]) && (yield this.#i[t]);
120698
+ }
120699
+ *rvalues() {
120700
+ for (let t of this.#D())
120701
+ this.#i[t] !== undefined && !this.#l(this.#i[t]) && (yield this.#i[t]);
120702
+ }
120703
+ [Symbol.iterator]() {
120704
+ return this.entries();
120705
+ }
120706
+ [Symbol.toStringTag] = "LRUCache";
120707
+ find(t, e = {}) {
120708
+ for (let s of this.#F()) {
120709
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
120710
+ if (r !== undefined && t(r, this.#a[s], this))
120711
+ return this.get(this.#a[s], e);
120712
+ }
120713
+ }
120714
+ forEach(t, e = this) {
120715
+ for (let s of this.#F()) {
120716
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
120717
+ r !== undefined && t.call(e, r, this.#a[s], this);
120718
+ }
120719
+ }
120720
+ rforEach(t, e = this) {
120721
+ for (let s of this.#D()) {
120722
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
120723
+ r !== undefined && t.call(e, r, this.#a[s], this);
120724
+ }
120725
+ }
120726
+ purgeStale() {
120727
+ let t = false;
120728
+ for (let e of this.#D({ allowStale: true }))
120729
+ this.#v(e) && (this.#O(this.#a[e], "expire"), t = true);
120730
+ return t;
120731
+ }
120732
+ info(t) {
120733
+ let e = this.#f.get(t);
120734
+ if (e === undefined)
120735
+ return;
120736
+ let s = this.#i[e], i = this.#l(s) ? s.__staleWhileFetching : s;
120737
+ if (i === undefined)
120738
+ return;
120739
+ let r = { value: i };
120740
+ if (this.#g && this.#T) {
120741
+ let o = this.#g[e], h = this.#T[e];
120742
+ if (o && h) {
120743
+ let a = o - (this.#c.now() - h);
120744
+ r.ttl = a, r.start = Date.now();
120745
+ }
120746
+ }
120747
+ return this.#C && (r.size = this.#C[e]), r;
120748
+ }
120749
+ dump() {
120750
+ let t = [];
120751
+ for (let e of this.#F({ allowStale: true })) {
120752
+ let s = this.#a[e], i = this.#i[e], r = this.#l(i) ? i.__staleWhileFetching : i;
120753
+ if (r === undefined || s === undefined)
120754
+ continue;
120755
+ let o = { value: r };
120756
+ if (this.#g && this.#T) {
120757
+ o.ttl = this.#g[e];
120758
+ let h = this.#c.now() - this.#T[e];
120759
+ o.start = Math.floor(Date.now() - h);
120760
+ }
120761
+ this.#C && (o.size = this.#C[e]), t.unshift([s, o]);
120762
+ }
120763
+ return t;
120764
+ }
120765
+ load(t) {
120766
+ this.clear();
120767
+ for (let [e, s] of t) {
120768
+ if (s.start) {
120769
+ let i = Date.now() - s.start;
120770
+ s.start = this.#c.now() - i;
120771
+ }
120772
+ this.set(e, s.value, s);
120773
+ }
120774
+ }
120775
+ set(t, e, s = {}) {
120776
+ if (e === undefined)
120777
+ return this.delete(t), this;
120778
+ 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);
120779
+ if (this.maxEntrySize && u > this.maxEntrySize)
120780
+ return a && (a.set = "miss", a.maxEntrySizeExceeded = true), this.#O(t, "set"), this;
120781
+ let c = this.#h === 0 ? undefined : this.#f.get(t);
120782
+ if (c === undefined)
120783
+ 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");
120784
+ else {
120785
+ this.#W(c);
120786
+ let d = this.#i[c];
120787
+ if (e !== d) {
120788
+ if (this.#A && this.#l(d)) {
120789
+ d.__abortController.abort(new Error("replaced"));
120790
+ let { __staleWhileFetching: f } = d;
120791
+ f !== undefined && !o && (this.#x && this.#n?.(f, t, "set"), this.#e && this.#m?.push([f, t, "set"]));
120792
+ } else
120793
+ o || (this.#x && this.#n?.(d, t, "set"), this.#e && this.#m?.push([d, t, "set"]));
120794
+ if (this.#P(c), this.#L(c, u, a), this.#i[c] = e, a) {
120795
+ a.set = "replace";
120796
+ let f = d && this.#l(d) ? d.__staleWhileFetching : d;
120797
+ f !== undefined && (a.oldValue = f);
120798
+ }
120799
+ } else
120800
+ a && (a.set = "update");
120801
+ this.#_ && this.onInsert?.(e, t, e === d ? "update" : "replace");
120802
+ }
120803
+ 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) {
120804
+ let d = this.#m, f;
120805
+ for (;f = d?.shift(); )
120806
+ this.#o?.(...f);
120807
+ }
120808
+ return this;
120809
+ }
120810
+ pop() {
120811
+ try {
120812
+ for (;this.#h; ) {
120813
+ let t = this.#i[this.#b];
120814
+ if (this.#B(true), this.#l(t)) {
120815
+ if (t.__staleWhileFetching)
120816
+ return t.__staleWhileFetching;
120817
+ } else if (t !== undefined)
120818
+ return t;
120819
+ }
120820
+ } finally {
120821
+ if (this.#e && this.#m) {
120822
+ let t = this.#m, e;
120823
+ for (;e = t?.shift(); )
120824
+ this.#o?.(...e);
120825
+ }
120826
+ }
120827
+ }
120828
+ #B(t) {
120829
+ let e = this.#b, s = this.#a[e], i = this.#i[e];
120830
+ 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;
120831
+ }
120832
+ has(t, e = {}) {
120833
+ let { updateAgeOnHas: s = this.updateAgeOnHas, status: i } = e, r = this.#f.get(t);
120834
+ if (r !== undefined) {
120835
+ let o = this.#i[r];
120836
+ if (this.#l(o) && o.__staleWhileFetching === undefined)
120837
+ return false;
120838
+ if (this.#v(r))
120839
+ i && (i.has = "stale", this.#N(i, r));
120840
+ else
120841
+ return s && this.#k(r), i && (i.has = "hit", this.#N(i, r)), true;
120842
+ } else
120843
+ i && (i.has = "miss");
120844
+ return false;
120845
+ }
120846
+ peek(t, e = {}) {
120847
+ let { allowStale: s = this.allowStale } = e, i = this.#f.get(t);
120848
+ if (i === undefined || !s && this.#v(i))
120849
+ return;
120850
+ let r = this.#i[i];
120851
+ return this.#l(r) ? r.__staleWhileFetching : r;
120852
+ }
120853
+ #U(t, e, s, i) {
120854
+ let r = e === undefined ? undefined : this.#i[e];
120855
+ if (this.#l(r))
120856
+ return r;
120857
+ let o = new At, { signal: h } = s;
120858
+ h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
120859
+ let a = { signal: o.signal, options: s, context: i }, l = (p, w = false) => {
120860
+ let { aborted: g } = o.signal, S = s.ignoreFetchAbort && p !== undefined, E = s.ignoreFetchAbort || !!(s.allowStaleOnFetchAbort && p !== undefined);
120861
+ 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)
120862
+ return c(o.signal.reason, E);
120863
+ let y = f, b = this.#i[e];
120864
+ 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;
120865
+ }, u = (p) => (s.status && (s.status.fetchRejected = true, s.status.fetchError = p), c(p, false)), c = (p, w) => {
120866
+ let { aborted: g } = o.signal, S = g && s.allowStaleOnFetchAbort, E = S || s.allowStaleOnFetchRejection, y = E || s.noDeleteOnFetchRejection, b = f;
120867
+ if (this.#i[e] === f && (!y || !w && b.__staleWhileFetching === undefined ? this.#O(t, "fetch") : S || (this.#i[e] = b.__staleWhileFetching)), E)
120868
+ return s.status && b.__staleWhileFetching !== undefined && (s.status.returnedStale = true), b.__staleWhileFetching;
120869
+ if (b.__returned === b)
120870
+ throw p;
120871
+ }, d = (p, w) => {
120872
+ let g = this.#S?.(t, r, a);
120873
+ g && g instanceof Promise && g.then((S) => p(S === undefined ? undefined : S), w), o.signal.addEventListener("abort", () => {
120874
+ (!s.ignoreFetchAbort || s.allowStaleOnFetchAbort) && (p(undefined), s.allowStaleOnFetchAbort && (p = (S) => l(S, true)));
120875
+ });
120876
+ };
120877
+ s.status && (s.status.fetchDispatched = true);
120878
+ let f = new Promise(d).then(l, u), m = Object.assign(f, { __abortController: o, __staleWhileFetching: r, __returned: undefined });
120879
+ return e === undefined ? (this.set(t, m, { ...a.options, status: undefined }), e = this.#f.get(t)) : this.#i[e] = m, m;
120880
+ }
120881
+ #l(t) {
120882
+ if (!this.#A)
120883
+ return false;
120884
+ let e = t;
120885
+ return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof At;
120886
+ }
120887
+ async fetch(t, e = {}) {
120888
+ 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;
120889
+ if (!this.#A)
120890
+ return g && (g.fetch = "get"), this.get(t, { allowStale: s, updateAgeOnGet: i, noDeleteOnStaleGet: r, status: g });
120891
+ 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);
120892
+ if (y === undefined) {
120893
+ g && (g.fetch = "miss");
120894
+ let b = this.#U(t, y, E, p);
120895
+ return b.__returned = b;
120896
+ } else {
120897
+ let b = this.#i[y];
120898
+ if (this.#l(b)) {
120899
+ let Z = s && b.__staleWhileFetching !== undefined;
120900
+ return g && (g.fetch = "inflight", Z && (g.returnedStale = true)), Z ? b.__staleWhileFetching : b.__returned = b;
120901
+ }
120902
+ let z = this.#v(y);
120903
+ if (!w && !z)
120904
+ return g && (g.fetch = "hit"), this.#W(y), i && this.#k(y), g && this.#N(g, y), b;
120905
+ let $ = this.#U(t, y, E, p), J = $.__staleWhileFetching !== undefined && s;
120906
+ return g && (g.fetch = z ? "stale" : "refresh", J && z && (g.returnedStale = true)), J ? $.__staleWhileFetching : $.__returned = $;
120907
+ }
120908
+ }
120909
+ async forceFetch(t, e = {}) {
120910
+ let s = await this.fetch(t, e);
120911
+ if (s === undefined)
120912
+ throw new Error("fetch() returned undefined");
120913
+ return s;
120914
+ }
120915
+ memo(t, e = {}) {
120916
+ let s = this.#w;
120917
+ if (!s)
120918
+ throw new Error("no memoMethod provided to constructor");
120919
+ let { context: i, forceRefresh: r, ...o } = e, h = this.get(t, o);
120920
+ if (!r && h !== undefined)
120921
+ return h;
120922
+ let a = s(t, h, { options: o, context: i });
120923
+ return this.set(t, a, o), a;
120924
+ }
120925
+ get(t, e = {}) {
120926
+ let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, status: o } = e, h = this.#f.get(t);
120927
+ if (h !== undefined) {
120928
+ let a = this.#i[h], l = this.#l(a);
120929
+ 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));
120930
+ } else
120931
+ o && (o.get = "miss");
120932
+ }
120933
+ #$(t, e) {
120934
+ this.#E[e] = t, this.#d[t] = e;
120935
+ }
120936
+ #W(t) {
120937
+ 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);
120938
+ }
120939
+ delete(t) {
120940
+ return this.#O(t, "delete");
120941
+ }
120942
+ #O(t, e) {
120943
+ let s = false;
120944
+ if (this.#h !== 0) {
120945
+ let i = this.#f.get(t);
120946
+ if (i !== undefined)
120947
+ if (this.#y?.[i] && (clearTimeout(this.#y?.[i]), this.#y[i] = undefined), s = true, this.#h === 1)
120948
+ this.#H(e);
120949
+ else {
120950
+ this.#P(i);
120951
+ let r = this.#i[i];
120952
+ 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)
120953
+ this.#p = this.#E[i];
120954
+ else if (i === this.#b)
120955
+ this.#b = this.#d[i];
120956
+ else {
120957
+ let o = this.#E[i];
120958
+ this.#d[o] = this.#d[i];
120959
+ let h = this.#d[i];
120960
+ this.#E[h] = this.#E[i];
120961
+ }
120962
+ this.#h--, this.#R.push(i);
120963
+ }
120964
+ }
120965
+ if (this.#e && this.#m?.length) {
120966
+ let i = this.#m, r;
120967
+ for (;r = i?.shift(); )
120968
+ this.#o?.(...r);
120969
+ }
120970
+ return s;
120971
+ }
120972
+ clear() {
120973
+ return this.#H("delete");
120974
+ }
120975
+ #H(t) {
120976
+ for (let e of this.#D({ allowStale: true })) {
120977
+ let s = this.#i[e];
120978
+ if (this.#l(s))
120979
+ s.__abortController.abort(new Error("deleted"));
120980
+ else {
120981
+ let i = this.#a[e];
120982
+ this.#x && this.#n?.(s, i, t), this.#e && this.#m?.push([s, i, t]);
120983
+ }
120984
+ }
120985
+ if (this.#f.clear(), this.#i.fill(undefined), this.#a.fill(undefined), this.#g && this.#T) {
120986
+ this.#g.fill(0), this.#T.fill(0);
120987
+ for (let e of this.#y ?? [])
120988
+ e !== undefined && clearTimeout(e);
120989
+ this.#y?.fill(undefined);
120990
+ }
120991
+ 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) {
120992
+ let e = this.#m, s;
120993
+ for (;s = e?.shift(); )
120994
+ this.#o?.(...s);
120995
+ }
120996
+ }
120997
+ };
120998
+ var Ne = typeof process == "object" && process ? process : { stdout: null, stderr: null };
120999
+ var oi = (n2) => !!n2 && typeof n2 == "object" && (n2 instanceof V || n2 instanceof Pe || hi(n2) || ai(n2));
121000
+ var hi = (n2) => !!n2 && typeof n2 == "object" && n2 instanceof ee && typeof n2.pipe == "function" && n2.pipe !== Pe.Writable.prototype.pipe;
121001
+ var ai = (n2) => !!n2 && typeof n2 == "object" && n2 instanceof ee && typeof n2.write == "function" && typeof n2.end == "function";
121002
+ var G = Symbol("EOF");
121003
+ var H = Symbol("maybeEmitEnd");
121004
+ var K = Symbol("emittedEnd");
121005
+ var kt = Symbol("emittingEnd");
121006
+ var ut = Symbol("emittedError");
121007
+ var Rt = Symbol("closed");
121008
+ var _e = Symbol("read");
121009
+ var Ot = Symbol("flush");
121010
+ var Le = Symbol("flushChunk");
121011
+ var P = Symbol("encoding");
121012
+ var et = Symbol("decoder");
121013
+ var v = Symbol("flowing");
121014
+ var dt = Symbol("paused");
121015
+ var st = Symbol("resume");
121016
+ var C = Symbol("buffer");
121017
+ var F = Symbol("pipes");
121018
+ var T = Symbol("bufferLength");
121019
+ var Yt = Symbol("bufferPush");
121020
+ var Ft = Symbol("bufferShift");
121021
+ var k = Symbol("objectMode");
121022
+ var x = Symbol("destroyed");
121023
+ var Xt = Symbol("error");
121024
+ var Jt = Symbol("emitData");
121025
+ var We = Symbol("emitEnd");
121026
+ var Zt = Symbol("emitEnd2");
121027
+ var B = Symbol("async");
121028
+ var Qt = Symbol("abort");
121029
+ var Dt = Symbol("aborted");
121030
+ var pt = Symbol("signal");
121031
+ var Y = Symbol("dataListeners");
121032
+ var M = Symbol("discarded");
121033
+ var mt = (n2) => Promise.resolve().then(n2);
121034
+ var li = (n2) => n2();
121035
+ var ci = (n2) => n2 === "end" || n2 === "finish" || n2 === "prefinish";
121036
+ var fi = (n2) => n2 instanceof ArrayBuffer || !!n2 && typeof n2 == "object" && n2.constructor && n2.constructor.name === "ArrayBuffer" && n2.byteLength >= 0;
121037
+ var ui = (n2) => !Buffer.isBuffer(n2) && ArrayBuffer.isView(n2);
121038
+ var Mt = class {
121039
+ src;
121040
+ dest;
121041
+ opts;
121042
+ ondrain;
121043
+ constructor(t, e, s) {
121044
+ this.src = t, this.dest = e, this.opts = s, this.ondrain = () => t[st](), this.dest.on("drain", this.ondrain);
121045
+ }
121046
+ unpipe() {
121047
+ this.dest.removeListener("drain", this.ondrain);
121048
+ }
121049
+ proxyErrors(t) {}
121050
+ end() {
121051
+ this.unpipe(), this.opts.end && this.dest.end();
121052
+ }
121053
+ };
121054
+ var te = class extends Mt {
121055
+ unpipe() {
121056
+ this.src.removeListener("error", this.proxyErrors), super.unpipe();
121057
+ }
121058
+ constructor(t, e, s) {
121059
+ super(t, e, s), this.proxyErrors = (i) => this.dest.emit("error", i), t.on("error", this.proxyErrors);
121060
+ }
121061
+ };
121062
+ var di = (n2) => !!n2.objectMode;
121063
+ var pi = (n2) => !n2.objectMode && !!n2.encoding && n2.encoding !== "buffer";
121064
+ var V = class extends ee {
121065
+ [v] = false;
121066
+ [dt] = false;
121067
+ [F] = [];
121068
+ [C] = [];
121069
+ [k];
121070
+ [P];
121071
+ [B];
121072
+ [et];
121073
+ [G] = false;
121074
+ [K] = false;
121075
+ [kt] = false;
121076
+ [Rt] = false;
121077
+ [ut] = null;
121078
+ [T] = 0;
121079
+ [x] = false;
121080
+ [pt];
121081
+ [Dt] = false;
121082
+ [Y] = 0;
121083
+ [M] = false;
121084
+ writable = true;
121085
+ readable = true;
121086
+ constructor(...t) {
121087
+ let e = t[0] || {};
121088
+ if (super(), e.objectMode && typeof e.encoding == "string")
121089
+ throw new TypeError("Encoding and objectMode may not be used together");
121090
+ 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] });
121091
+ let { signal: s } = e;
121092
+ s && (this[pt] = s, s.aborted ? this[Qt]() : s.addEventListener("abort", () => this[Qt]()));
121093
+ }
121094
+ get bufferLength() {
121095
+ return this[T];
121096
+ }
121097
+ get encoding() {
121098
+ return this[P];
121099
+ }
121100
+ set encoding(t) {
121101
+ throw new Error("Encoding must be set at instantiation time");
121102
+ }
121103
+ setEncoding(t) {
121104
+ throw new Error("Encoding must be set at instantiation time");
121105
+ }
121106
+ get objectMode() {
121107
+ return this[k];
121108
+ }
121109
+ set objectMode(t) {
121110
+ throw new Error("objectMode must be set at instantiation time");
121111
+ }
121112
+ get async() {
121113
+ return this[B];
121114
+ }
121115
+ set async(t) {
121116
+ this[B] = this[B] || !!t;
121117
+ }
121118
+ [Qt]() {
121119
+ this[Dt] = true, this.emit("abort", this[pt]?.reason), this.destroy(this[pt]?.reason);
121120
+ }
121121
+ get aborted() {
121122
+ return this[Dt];
121123
+ }
121124
+ set aborted(t) {}
121125
+ write(t, e, s) {
121126
+ if (this[Dt])
121127
+ return false;
121128
+ if (this[G])
121129
+ throw new Error("write after end");
121130
+ if (this[x])
121131
+ return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), true;
121132
+ typeof e == "function" && (s = e, e = "utf8"), e || (e = "utf8");
121133
+ let i = this[B] ? mt : li;
121134
+ if (!this[k] && !Buffer.isBuffer(t)) {
121135
+ if (ui(t))
121136
+ t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
121137
+ else if (fi(t))
121138
+ t = Buffer.from(t);
121139
+ else if (typeof t != "string")
121140
+ throw new Error("Non-contiguous data written to non-objectMode stream");
121141
+ }
121142
+ 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]);
121143
+ }
121144
+ read(t) {
121145
+ if (this[x])
121146
+ return null;
121147
+ if (this[M] = false, this[T] === 0 || t === 0 || t && t > this[T])
121148
+ return this[H](), null;
121149
+ this[k] && (t = null), this[C].length > 1 && !this[k] && (this[C] = [this[P] ? this[C].join("") : Buffer.concat(this[C], this[T])]);
121150
+ let e = this[_e](t || null, this[C][0]);
121151
+ return this[H](), e;
121152
+ }
121153
+ [_e](t, e) {
121154
+ if (this[k])
121155
+ this[Ft]();
121156
+ else {
121157
+ let s = e;
121158
+ 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);
121159
+ }
121160
+ return this.emit("data", e), !this[C].length && !this[G] && this.emit("drain"), e;
121161
+ }
121162
+ end(t, e, s) {
121163
+ 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;
121164
+ }
121165
+ [st]() {
121166
+ 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"));
121167
+ }
121168
+ resume() {
121169
+ return this[st]();
121170
+ }
121171
+ pause() {
121172
+ this[v] = false, this[dt] = true, this[M] = false;
121173
+ }
121174
+ get destroyed() {
121175
+ return this[x];
121176
+ }
121177
+ get flowing() {
121178
+ return this[v];
121179
+ }
121180
+ get paused() {
121181
+ return this[dt];
121182
+ }
121183
+ [Yt](t) {
121184
+ this[k] ? this[T] += 1 : this[T] += t.length, this[C].push(t);
121185
+ }
121186
+ [Ft]() {
121187
+ return this[k] ? this[T] -= 1 : this[T] -= this[C][0].length, this[C].shift();
121188
+ }
121189
+ [Ot](t = false) {
121190
+ do
121191
+ ;
121192
+ while (this[Le](this[Ft]()) && this[C].length);
121193
+ !t && !this[C].length && !this[G] && this.emit("drain");
121194
+ }
121195
+ [Le](t) {
121196
+ return this.emit("data", t), this[v];
121197
+ }
121198
+ pipe(t, e) {
121199
+ if (this[x])
121200
+ return t;
121201
+ this[M] = false;
121202
+ let s = this[K];
121203
+ 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;
121204
+ }
121205
+ unpipe(t) {
121206
+ let e = this[F].find((s) => s.dest === t);
121207
+ 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());
121208
+ }
121209
+ addListener(t, e) {
121210
+ return this.on(t, e);
121211
+ }
121212
+ on(t, e) {
121213
+ let s = super.on(t, e);
121214
+ if (t === "data")
121215
+ this[M] = false, this[Y]++, !this[F].length && !this[v] && this[st]();
121216
+ else if (t === "readable" && this[T] !== 0)
121217
+ super.emit("readable");
121218
+ else if (ci(t) && this[K])
121219
+ super.emit(t), this.removeAllListeners(t);
121220
+ else if (t === "error" && this[ut]) {
121221
+ let i = e;
121222
+ this[B] ? mt(() => i.call(this, this[ut])) : i.call(this, this[ut]);
121223
+ }
121224
+ return s;
121225
+ }
121226
+ removeListener(t, e) {
121227
+ return this.off(t, e);
121228
+ }
121229
+ off(t, e) {
121230
+ let s = super.off(t, e);
121231
+ return t === "data" && (this[Y] = this.listeners("data").length, this[Y] === 0 && !this[M] && !this[F].length && (this[v] = false)), s;
121232
+ }
121233
+ removeAllListeners(t) {
121234
+ let e = super.removeAllListeners(t);
121235
+ return (t === "data" || t === undefined) && (this[Y] = 0, !this[M] && !this[F].length && (this[v] = false)), e;
121236
+ }
121237
+ get emittedEnd() {
121238
+ return this[K];
121239
+ }
121240
+ [H]() {
121241
+ !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);
121242
+ }
121243
+ emit(t, ...e) {
121244
+ let s = e[0];
121245
+ if (t !== "error" && t !== "close" && t !== x && this[x])
121246
+ return false;
121247
+ if (t === "data")
121248
+ return !this[k] && !s ? false : this[B] ? (mt(() => this[Jt](s)), true) : this[Jt](s);
121249
+ if (t === "end")
121250
+ return this[We]();
121251
+ if (t === "close") {
121252
+ if (this[Rt] = true, !this[K] && !this[x])
121253
+ return false;
121254
+ let r = super.emit("close");
121255
+ return this.removeAllListeners("close"), r;
121256
+ } else if (t === "error") {
121257
+ this[ut] = s, super.emit(Xt, s);
121258
+ let r = !this[pt] || this.listeners("error").length ? super.emit("error", s) : false;
121259
+ return this[H](), r;
121260
+ } else if (t === "resume") {
121261
+ let r = super.emit("resume");
121262
+ return this[H](), r;
121263
+ } else if (t === "finish" || t === "prefinish") {
121264
+ let r = super.emit(t);
121265
+ return this.removeAllListeners(t), r;
121266
+ }
121267
+ let i = super.emit(t, ...e);
121268
+ return this[H](), i;
121269
+ }
121270
+ [Jt](t) {
121271
+ for (let s of this[F])
121272
+ s.dest.write(t) === false && this.pause();
121273
+ let e = this[M] ? false : super.emit("data", t);
121274
+ return this[H](), e;
121275
+ }
121276
+ [We]() {
121277
+ return this[K] ? false : (this[K] = true, this.readable = false, this[B] ? (mt(() => this[Zt]()), true) : this[Zt]());
121278
+ }
121279
+ [Zt]() {
121280
+ if (this[et]) {
121281
+ let e = this[et].end();
121282
+ if (e) {
121283
+ for (let s of this[F])
121284
+ s.dest.write(e);
121285
+ this[M] || super.emit("data", e);
121286
+ }
121287
+ }
121288
+ for (let e of this[F])
121289
+ e.end();
121290
+ let t = super.emit("end");
121291
+ return this.removeAllListeners("end"), t;
121292
+ }
121293
+ async collect() {
121294
+ let t = Object.assign([], { dataLength: 0 });
121295
+ this[k] || (t.dataLength = 0);
121296
+ let e = this.promise();
121297
+ return this.on("data", (s) => {
121298
+ t.push(s), this[k] || (t.dataLength += s.length);
121299
+ }), await e, t;
121300
+ }
121301
+ async concat() {
121302
+ if (this[k])
121303
+ throw new Error("cannot concat in objectMode");
121304
+ let t = await this.collect();
121305
+ return this[P] ? t.join("") : Buffer.concat(t, t.dataLength);
121306
+ }
121307
+ async promise() {
121308
+ return new Promise((t, e) => {
121309
+ this.on(x, () => e(new Error("stream destroyed"))), this.on("error", (s) => e(s)), this.on("end", () => t());
121310
+ });
121311
+ }
121312
+ [Symbol.asyncIterator]() {
121313
+ this[M] = false;
121314
+ let t = false, e = async () => (this.pause(), t = true, { value: undefined, done: true });
121315
+ return { next: () => {
121316
+ if (t)
121317
+ return e();
121318
+ let i = this.read();
121319
+ if (i !== null)
121320
+ return Promise.resolve({ done: false, value: i });
121321
+ if (this[G])
121322
+ return e();
121323
+ let r, o, h = (c) => {
121324
+ this.off("data", a), this.off("end", l), this.off(x, u), e(), o(c);
121325
+ }, a = (c) => {
121326
+ this.off("error", h), this.off("end", l), this.off(x, u), this.pause(), r({ value: c, done: !!this[G] });
121327
+ }, l = () => {
121328
+ this.off("error", h), this.off("data", a), this.off(x, u), e(), r({ done: true, value: undefined });
121329
+ }, u = () => h(new Error("stream destroyed"));
121330
+ return new Promise((c, d) => {
121331
+ o = d, r = c, this.once(x, u), this.once("error", h), this.once("end", l), this.once("data", a);
121332
+ });
121333
+ }, throw: e, return: e, [Symbol.asyncIterator]() {
121334
+ return this;
121335
+ }, [Symbol.asyncDispose]: async () => {} };
121336
+ }
121337
+ [Symbol.iterator]() {
121338
+ this[M] = false;
121339
+ 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 = () => {
121340
+ if (t)
121341
+ return e();
121342
+ let i = this.read();
121343
+ return i === null ? e() : { done: false, value: i };
121344
+ };
121345
+ return this.once("end", e), this.once(Xt, e), this.once(x, e), { next: s, throw: e, return: e, [Symbol.iterator]() {
121346
+ return this;
121347
+ }, [Symbol.dispose]: () => {} };
121348
+ }
121349
+ destroy(t) {
121350
+ if (this[x])
121351
+ return t ? this.emit("error", t) : this.emit(x), this;
121352
+ this[x] = true, this[M] = true, this[C].length = 0, this[T] = 0;
121353
+ let e = this;
121354
+ return typeof e.close == "function" && !this[Rt] && e.close(), t ? this.emit("error", t) : this.emit(x), this;
121355
+ }
121356
+ static get isStream() {
121357
+ return oi;
121358
+ }
121359
+ };
121360
+ var vi = Ei.native;
121361
+ var wt = { lstatSync: wi, readdir: yi, readdirSync: bi, readlinkSync: Si, realpathSync: vi, promises: { lstat: Ci, readdir: Ti, readlink: Ai, realpath: ki } };
121362
+ var Ue = (n2) => !n2 || n2 === wt || n2 === xi ? wt : { ...wt, ...n2, promises: { ...wt.promises, ...n2.promises || {} } };
121363
+ var $e = /^\\\\\?\\([a-z]:)\\?$/i;
121364
+ var Ri = (n2) => n2.replace(/\//g, "\\").replace($e, "$1\\");
121365
+ var Oi = /[\\\/]/;
121366
+ var L = 0;
121367
+ var Ge = 1;
121368
+ var He = 2;
121369
+ var U = 4;
121370
+ var qe = 6;
121371
+ var Ke = 8;
121372
+ var X = 10;
121373
+ var Ve = 12;
121374
+ var _ = 15;
121375
+ var gt = ~_;
121376
+ var se = 16;
121377
+ var je = 32;
121378
+ var yt = 64;
121379
+ var j = 128;
121380
+ var Nt = 256;
121381
+ var Lt = 512;
121382
+ var Ie = yt | j | Lt;
121383
+ var Fi = 1023;
121384
+ 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;
121385
+ var ze = new ft({ max: 2 ** 12 });
121386
+ var bt = (n2) => {
121387
+ let t = ze.get(n2);
121388
+ if (t)
121389
+ return t;
121390
+ let e = n2.normalize("NFKD");
121391
+ return ze.set(n2, e), e;
121392
+ };
121393
+ var Be = new ft({ max: 2 ** 12 });
121394
+ var _t = (n2) => {
121395
+ let t = Be.get(n2);
121396
+ if (t)
121397
+ return t;
121398
+ let e = bt(n2.toLowerCase());
121399
+ return Be.set(n2, e), e;
121400
+ };
121401
+ var Wt = class extends ft {
121402
+ constructor() {
121403
+ super({ max: 256 });
121404
+ }
121405
+ };
121406
+ var ne = class extends ft {
121407
+ constructor(t = 16 * 1024) {
121408
+ super({ maxSize: t, sizeCalculation: (e) => e.length + 1 });
121409
+ }
121410
+ };
121411
+ var Ye = Symbol("PathScurry setAsCwd");
121412
+ var R = class {
121413
+ name;
121414
+ root;
121415
+ roots;
121416
+ parent;
121417
+ nocase;
121418
+ isCWD = false;
121419
+ #t;
121420
+ #s;
121421
+ get dev() {
121422
+ return this.#s;
121423
+ }
121424
+ #n;
121425
+ get mode() {
121426
+ return this.#n;
121427
+ }
121428
+ #r;
121429
+ get nlink() {
121430
+ return this.#r;
121431
+ }
121432
+ #o;
121433
+ get uid() {
121434
+ return this.#o;
121435
+ }
121436
+ #S;
121437
+ get gid() {
121438
+ return this.#S;
121439
+ }
121440
+ #w;
121441
+ get rdev() {
121442
+ return this.#w;
121443
+ }
121444
+ #c;
121445
+ get blksize() {
121446
+ return this.#c;
121447
+ }
121448
+ #h;
121449
+ get ino() {
121450
+ return this.#h;
121451
+ }
121452
+ #u;
121453
+ get size() {
121454
+ return this.#u;
121455
+ }
121456
+ #f;
121457
+ get blocks() {
121458
+ return this.#f;
121459
+ }
121460
+ #a;
121461
+ get atimeMs() {
121462
+ return this.#a;
121463
+ }
121464
+ #i;
121465
+ get mtimeMs() {
121466
+ return this.#i;
121467
+ }
121468
+ #d;
121469
+ get ctimeMs() {
121470
+ return this.#d;
121471
+ }
121472
+ #E;
121473
+ get birthtimeMs() {
121474
+ return this.#E;
121475
+ }
121476
+ #b;
121477
+ get atime() {
121478
+ return this.#b;
121479
+ }
121480
+ #p;
121481
+ get mtime() {
121482
+ return this.#p;
121483
+ }
121484
+ #R;
121485
+ get ctime() {
121486
+ return this.#R;
121487
+ }
121488
+ #m;
121489
+ get birthtime() {
121490
+ return this.#m;
121491
+ }
121492
+ #C;
121493
+ #T;
121494
+ #g;
121495
+ #y;
121496
+ #x;
121497
+ #A;
121498
+ #e;
121499
+ #_;
121500
+ #M;
121501
+ #k;
121502
+ get parentPath() {
121503
+ return (this.parent || this).fullpath();
121504
+ }
121505
+ get path() {
121506
+ return this.parentPath;
121507
+ }
121508
+ constructor(t, e = L, s, i, r, o, h) {
121509
+ 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);
121510
+ }
121511
+ depth() {
121512
+ return this.#T !== undefined ? this.#T : this.parent ? this.#T = this.parent.depth() + 1 : this.#T = 0;
121513
+ }
121514
+ childrenCache() {
121515
+ return this.#_;
121516
+ }
121517
+ resolve(t) {
121518
+ if (!t)
121519
+ return this;
121520
+ let e = this.getRootString(t), i = t.substring(e.length).split(this.splitSep);
121521
+ return e ? this.getRoot(e).#N(i) : this.#N(i);
121522
+ }
121523
+ #N(t) {
121524
+ let e = this;
121525
+ for (let s of t)
121526
+ e = e.child(s);
121527
+ return e;
121528
+ }
121529
+ children() {
121530
+ let t = this.#_.get(this);
121531
+ if (t)
121532
+ return t;
121533
+ let e = Object.assign([], { provisional: 0 });
121534
+ return this.#_.set(this, e), this.#e &= ~se, e;
121535
+ }
121536
+ child(t, e) {
121537
+ if (t === "" || t === ".")
121538
+ return this;
121539
+ if (t === "..")
121540
+ return this.parent || this;
121541
+ let s = this.children(), i = this.nocase ? _t(t) : bt(t);
121542
+ for (let a of s)
121543
+ if (a.#C === i)
121544
+ return a;
121545
+ let r = this.parent ? this.sep : "", o = this.#g ? this.#g + r + t : undefined, h = this.newChild(t, L, { ...e, parent: this, fullpath: o });
121546
+ return this.canReaddir() || (h.#e |= j), s.push(h), h;
121547
+ }
121548
+ relative() {
121549
+ if (this.isCWD)
121550
+ return "";
121551
+ if (this.#x !== undefined)
121552
+ return this.#x;
121553
+ let t = this.name, e = this.parent;
121554
+ if (!e)
121555
+ return this.#x = this.name;
121556
+ let s = e.relative();
121557
+ return s + (!s || !e.parent ? "" : this.sep) + t;
121558
+ }
121559
+ relativePosix() {
121560
+ if (this.sep === "/")
121561
+ return this.relative();
121562
+ if (this.isCWD)
121563
+ return "";
121564
+ if (this.#A !== undefined)
121565
+ return this.#A;
121566
+ let t = this.name, e = this.parent;
121567
+ if (!e)
121568
+ return this.#A = this.fullpathPosix();
121569
+ let s = e.relativePosix();
121570
+ return s + (!s || !e.parent ? "" : "/") + t;
121571
+ }
121572
+ fullpath() {
121573
+ if (this.#g !== undefined)
121574
+ return this.#g;
121575
+ let t = this.name, e = this.parent;
121576
+ if (!e)
121577
+ return this.#g = this.name;
121578
+ let i = e.fullpath() + (e.parent ? this.sep : "") + t;
121579
+ return this.#g = i;
121580
+ }
121581
+ fullpathPosix() {
121582
+ if (this.#y !== undefined)
121583
+ return this.#y;
121584
+ if (this.sep === "/")
121585
+ return this.#y = this.fullpath();
121586
+ if (!this.parent) {
121587
+ let i = this.fullpath().replace(/\\/g, "/");
121588
+ return /^[a-z]:\//i.test(i) ? this.#y = `//?/${i}` : this.#y = i;
121589
+ }
121590
+ let t = this.parent, e = t.fullpathPosix(), s = e + (!e || !t.parent ? "" : "/") + this.name;
121591
+ return this.#y = s;
121592
+ }
121593
+ isUnknown() {
121594
+ return (this.#e & _) === L;
121595
+ }
121596
+ isType(t) {
121597
+ return this[`is${t}`]();
121598
+ }
121599
+ getType() {
121600
+ 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";
121601
+ }
121602
+ isFile() {
121603
+ return (this.#e & _) === Ke;
121604
+ }
121605
+ isDirectory() {
121606
+ return (this.#e & _) === U;
121607
+ }
121608
+ isCharacterDevice() {
121609
+ return (this.#e & _) === He;
121610
+ }
121611
+ isBlockDevice() {
121612
+ return (this.#e & _) === qe;
121613
+ }
121614
+ isFIFO() {
121615
+ return (this.#e & _) === Ge;
121616
+ }
121617
+ isSocket() {
121618
+ return (this.#e & _) === Ve;
121619
+ }
121620
+ isSymbolicLink() {
121621
+ return (this.#e & X) === X;
121622
+ }
121623
+ lstatCached() {
121624
+ return this.#e & je ? this : undefined;
121625
+ }
121626
+ readlinkCached() {
121627
+ return this.#M;
121628
+ }
121629
+ realpathCached() {
121630
+ return this.#k;
121631
+ }
121632
+ readdirCached() {
121633
+ let t = this.children();
121634
+ return t.slice(0, t.provisional);
121635
+ }
121636
+ canReadlink() {
121637
+ if (this.#M)
121638
+ return true;
121639
+ if (!this.parent)
121640
+ return false;
121641
+ let t = this.#e & _;
121642
+ return !(t !== L && t !== X || this.#e & Nt || this.#e & j);
121643
+ }
121644
+ calledReaddir() {
121645
+ return !!(this.#e & se);
121646
+ }
121647
+ isENOENT() {
121648
+ return !!(this.#e & j);
121649
+ }
121650
+ isNamed(t) {
121651
+ return this.nocase ? this.#C === _t(t) : this.#C === bt(t);
121652
+ }
121653
+ async readlink() {
121654
+ let t = this.#M;
121655
+ if (t)
121656
+ return t;
121657
+ if (this.canReadlink() && this.parent)
121658
+ try {
121659
+ let e = await this.#t.promises.readlink(this.fullpath()), s = (await this.parent.realpath())?.resolve(e);
121660
+ if (s)
121661
+ return this.#M = s;
121662
+ } catch (e) {
121663
+ this.#D(e.code);
121664
+ return;
121665
+ }
121666
+ }
121667
+ readlinkSync() {
121668
+ let t = this.#M;
121669
+ if (t)
121670
+ return t;
121671
+ if (this.canReadlink() && this.parent)
121672
+ try {
121673
+ let e = this.#t.readlinkSync(this.fullpath()), s = this.parent.realpathSync()?.resolve(e);
121674
+ if (s)
121675
+ return this.#M = s;
121676
+ } catch (e) {
121677
+ this.#D(e.code);
121678
+ return;
121679
+ }
121680
+ }
121681
+ #j(t) {
121682
+ this.#e |= se;
121683
+ for (let e = t.provisional;e < t.length; e++) {
121684
+ let s = t[e];
121685
+ s && s.#v();
121686
+ }
121687
+ }
121688
+ #v() {
121689
+ this.#e & j || (this.#e = (this.#e | j) & gt, this.#G());
121690
+ }
121691
+ #G() {
121692
+ let t = this.children();
121693
+ t.provisional = 0;
121694
+ for (let e of t)
121695
+ e.#v();
121696
+ }
121697
+ #P() {
121698
+ this.#e |= Lt, this.#L();
121699
+ }
121700
+ #L() {
121701
+ if (this.#e & yt)
121702
+ return;
121703
+ let t = this.#e;
121704
+ (t & _) === U && (t &= gt), this.#e = t | yt, this.#G();
121705
+ }
121706
+ #I(t = "") {
121707
+ t === "ENOTDIR" || t === "EPERM" ? this.#L() : t === "ENOENT" ? this.#v() : this.children().provisional = 0;
121708
+ }
121709
+ #F(t = "") {
121710
+ t === "ENOTDIR" ? this.parent.#L() : t === "ENOENT" && this.#v();
121711
+ }
121712
+ #D(t = "") {
121713
+ let e = this.#e;
121714
+ e |= Nt, t === "ENOENT" && (e |= j), (t === "EINVAL" || t === "UNKNOWN") && (e &= gt), this.#e = e, t === "ENOTDIR" && this.parent && this.parent.#L();
121715
+ }
121716
+ #z(t, e) {
121717
+ return this.#U(t, e) || this.#B(t, e);
121718
+ }
121719
+ #B(t, e) {
121720
+ let s = ie(t), i = this.newChild(t.name, s, { parent: this }), r = i.#e & _;
121721
+ return r !== U && r !== X && r !== L && (i.#e |= yt), e.unshift(i), e.provisional++, i;
121722
+ }
121723
+ #U(t, e) {
121724
+ for (let s = e.provisional;s < e.length; s++) {
121725
+ let i = e[s];
121726
+ if ((this.nocase ? _t(t.name) : bt(t.name)) === i.#C)
121727
+ return this.#l(t, i, s, e);
121728
+ }
121729
+ }
121730
+ #l(t, e, s, i) {
121731
+ let r = e.name;
121732
+ 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;
121733
+ }
121734
+ async lstat() {
121735
+ if ((this.#e & j) === 0)
121736
+ try {
121737
+ return this.#$(await this.#t.promises.lstat(this.fullpath())), this;
121738
+ } catch (t) {
121739
+ this.#F(t.code);
121740
+ }
121741
+ }
121742
+ lstatSync() {
121743
+ if ((this.#e & j) === 0)
121744
+ try {
121745
+ return this.#$(this.#t.lstatSync(this.fullpath())), this;
121746
+ } catch (t) {
121747
+ this.#F(t.code);
121748
+ }
121749
+ }
121750
+ #$(t) {
121751
+ 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;
121752
+ 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;
121753
+ let y = ie(t);
121754
+ this.#e = this.#e & gt | y | je, y !== L && y !== U && y !== X && (this.#e |= yt);
121755
+ }
121756
+ #W = [];
121757
+ #O = false;
121758
+ #H(t) {
121759
+ this.#O = false;
121760
+ let e = this.#W.slice();
121761
+ this.#W.length = 0, e.forEach((s) => s(null, t));
121762
+ }
121763
+ readdirCB(t, e = false) {
121764
+ if (!this.canReaddir()) {
121765
+ e ? t(null, []) : queueMicrotask(() => t(null, []));
121766
+ return;
121767
+ }
121768
+ let s = this.children();
121769
+ if (this.calledReaddir()) {
121770
+ let r = s.slice(0, s.provisional);
121771
+ e ? t(null, r) : queueMicrotask(() => t(null, r));
121772
+ return;
121773
+ }
121774
+ if (this.#W.push(t), this.#O)
121775
+ return;
121776
+ this.#O = true;
121777
+ let i = this.fullpath();
121778
+ this.#t.readdir(i, { withFileTypes: true }, (r, o) => {
121779
+ if (r)
121780
+ this.#I(r.code), s.provisional = 0;
121781
+ else {
121782
+ for (let h of o)
121783
+ this.#z(h, s);
121784
+ this.#j(s);
121785
+ }
121786
+ this.#H(s.slice(0, s.provisional));
121787
+ });
121788
+ }
121789
+ #q;
121790
+ async readdir() {
121791
+ if (!this.canReaddir())
121792
+ return [];
121793
+ let t = this.children();
121794
+ if (this.calledReaddir())
121795
+ return t.slice(0, t.provisional);
121796
+ let e = this.fullpath();
121797
+ if (this.#q)
121798
+ await this.#q;
121799
+ else {
121800
+ let s = () => {};
121801
+ this.#q = new Promise((i) => s = i);
121802
+ try {
121803
+ for (let i of await this.#t.promises.readdir(e, { withFileTypes: true }))
121804
+ this.#z(i, t);
121805
+ this.#j(t);
121806
+ } catch (i) {
121807
+ this.#I(i.code), t.provisional = 0;
121808
+ }
121809
+ this.#q = undefined, s();
121810
+ }
121811
+ return t.slice(0, t.provisional);
121812
+ }
121813
+ readdirSync() {
121814
+ if (!this.canReaddir())
121815
+ return [];
121816
+ let t = this.children();
121817
+ if (this.calledReaddir())
121818
+ return t.slice(0, t.provisional);
121819
+ let e = this.fullpath();
121820
+ try {
121821
+ for (let s of this.#t.readdirSync(e, { withFileTypes: true }))
121822
+ this.#z(s, t);
121823
+ this.#j(t);
121824
+ } catch (s) {
121825
+ this.#I(s.code), t.provisional = 0;
121826
+ }
121827
+ return t.slice(0, t.provisional);
121828
+ }
121829
+ canReaddir() {
121830
+ if (this.#e & Ie)
121831
+ return false;
121832
+ let t = _ & this.#e;
121833
+ return t === L || t === U || t === X;
121834
+ }
121835
+ shouldWalk(t, e) {
121836
+ return (this.#e & U) === U && !(this.#e & Ie) && !t.has(this) && (!e || e(this));
121837
+ }
121838
+ async realpath() {
121839
+ if (this.#k)
121840
+ return this.#k;
121841
+ if (!((Lt | Nt | j) & this.#e))
121842
+ try {
121843
+ let t = await this.#t.promises.realpath(this.fullpath());
121844
+ return this.#k = this.resolve(t);
121845
+ } catch {
121846
+ this.#P();
121847
+ }
121848
+ }
121849
+ realpathSync() {
121850
+ if (this.#k)
121851
+ return this.#k;
121852
+ if (!((Lt | Nt | j) & this.#e))
121853
+ try {
121854
+ let t = this.#t.realpathSync(this.fullpath());
121855
+ return this.#k = this.resolve(t);
121856
+ } catch {
121857
+ this.#P();
121858
+ }
121859
+ }
121860
+ [Ye](t) {
121861
+ if (t === this)
121862
+ return;
121863
+ t.isCWD = false, this.isCWD = true;
121864
+ let e = new Set([]), s = [], i = this;
121865
+ for (;i && i.parent; )
121866
+ e.add(i), i.#x = s.join(this.sep), i.#A = s.join("/"), i = i.parent, s.push("..");
121867
+ for (i = t;i && i.parent && !e.has(i); )
121868
+ i.#x = undefined, i.#A = undefined, i = i.parent;
121869
+ }
121870
+ };
121871
+ var Pt = class n2 extends R {
121872
+ sep = "\\";
121873
+ splitSep = Oi;
121874
+ constructor(t, e = L, s, i, r, o, h) {
121875
+ super(t, e, s, i, r, o, h);
121876
+ }
121877
+ newChild(t, e = L, s = {}) {
121878
+ return new n2(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
121879
+ }
121880
+ getRootString(t) {
121881
+ return re.parse(t).root;
121882
+ }
121883
+ getRoot(t) {
121884
+ if (t = Ri(t.toUpperCase()), t === this.root.name)
121885
+ return this.root;
121886
+ for (let [e, s] of Object.entries(this.roots))
121887
+ if (this.sameRoot(t, e))
121888
+ return this.roots[t] = s;
121889
+ return this.roots[t] = new it(t, this).root;
121890
+ }
121891
+ sameRoot(t, e = this.root.name) {
121892
+ return t = t.toUpperCase().replace(/\//g, "\\").replace($e, "$1\\"), t === e;
121893
+ }
121894
+ };
121895
+ var jt = class n3 extends R {
121896
+ splitSep = "/";
121897
+ sep = "/";
121898
+ constructor(t, e = L, s, i, r, o, h) {
121899
+ super(t, e, s, i, r, o, h);
121900
+ }
121901
+ getRootString(t) {
121902
+ return t.startsWith("/") ? "/" : "";
121903
+ }
121904
+ getRoot(t) {
121905
+ return this.root;
121906
+ }
121907
+ newChild(t, e = L, s = {}) {
121908
+ return new n3(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
121909
+ }
121910
+ };
121911
+ var It = class {
121912
+ root;
121913
+ rootPath;
121914
+ roots;
121915
+ cwd;
121916
+ #t;
121917
+ #s;
121918
+ #n;
121919
+ nocase;
121920
+ #r;
121921
+ constructor(t = process.cwd(), e, s, { nocase: i, childrenCacheSize: r = 16 * 1024, fs: o = wt } = {}) {
121922
+ this.#r = Ue(o), (t instanceof URL || t.startsWith("file://")) && (t = gi(t));
121923
+ let h = e.resolve(t);
121924
+ this.roots = Object.create(null), this.rootPath = this.parseRootPath(h), this.#t = new Wt, this.#s = new Wt, this.#n = new ne(r);
121925
+ let a = h.substring(this.rootPath.length).split(s);
121926
+ if (a.length === 1 && !a[0] && a.pop(), i === undefined)
121927
+ throw new TypeError("must provide nocase setting to PathScurryBase ctor");
121928
+ this.nocase = i, this.root = this.newRoot(this.#r), this.roots[this.rootPath] = this.root;
121929
+ let l = this.root, u = a.length - 1, c = e.sep, d = this.rootPath, f = false;
121930
+ for (let m of a) {
121931
+ let p = u--;
121932
+ l = l.child(m, { relative: new Array(p).fill("..").join(c), relativePosix: new Array(p).fill("..").join("/"), fullpath: d += (f ? "" : c) + m }), f = true;
121933
+ }
121934
+ this.cwd = l;
121935
+ }
121936
+ depth(t = this.cwd) {
121937
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.depth();
121938
+ }
121939
+ childrenCache() {
121940
+ return this.#n;
121941
+ }
121942
+ resolve(...t) {
121943
+ let e = "";
121944
+ for (let r = t.length - 1;r >= 0; r--) {
121945
+ let o = t[r];
121946
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o)))
121947
+ break;
121948
+ }
121949
+ let s = this.#t.get(e);
121950
+ if (s !== undefined)
121951
+ return s;
121952
+ let i = this.cwd.resolve(e).fullpath();
121953
+ return this.#t.set(e, i), i;
121954
+ }
121955
+ resolvePosix(...t) {
121956
+ let e = "";
121957
+ for (let r = t.length - 1;r >= 0; r--) {
121958
+ let o = t[r];
121959
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o)))
121960
+ break;
121961
+ }
121962
+ let s = this.#s.get(e);
121963
+ if (s !== undefined)
121964
+ return s;
121965
+ let i = this.cwd.resolve(e).fullpathPosix();
121966
+ return this.#s.set(e, i), i;
121967
+ }
121968
+ relative(t = this.cwd) {
121969
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relative();
121970
+ }
121971
+ relativePosix(t = this.cwd) {
121972
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relativePosix();
121973
+ }
121974
+ basename(t = this.cwd) {
121975
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.name;
121976
+ }
121977
+ dirname(t = this.cwd) {
121978
+ return typeof t == "string" && (t = this.cwd.resolve(t)), (t.parent || t).fullpath();
121979
+ }
121980
+ async readdir(t = this.cwd, e = { withFileTypes: true }) {
121981
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
121982
+ let { withFileTypes: s } = e;
121983
+ if (t.canReaddir()) {
121984
+ let i = await t.readdir();
121985
+ return s ? i : i.map((r) => r.name);
121986
+ } else
121987
+ return [];
121988
+ }
121989
+ readdirSync(t = this.cwd, e = { withFileTypes: true }) {
121990
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
121991
+ let { withFileTypes: s = true } = e;
121992
+ return t.canReaddir() ? s ? t.readdirSync() : t.readdirSync().map((i) => i.name) : [];
121993
+ }
121994
+ async lstat(t = this.cwd) {
121995
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstat();
121996
+ }
121997
+ lstatSync(t = this.cwd) {
121998
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstatSync();
121999
+ }
122000
+ async readlink(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
122001
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
122002
+ let s = await t.readlink();
122003
+ return e ? s : s?.fullpath();
122004
+ }
122005
+ readlinkSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
122006
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
122007
+ let s = t.readlinkSync();
122008
+ return e ? s : s?.fullpath();
122009
+ }
122010
+ async realpath(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
122011
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
122012
+ let s = await t.realpath();
122013
+ return e ? s : s?.fullpath();
122014
+ }
122015
+ realpathSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
122016
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
122017
+ let s = t.realpathSync();
122018
+ return e ? s : s?.fullpath();
122019
+ }
122020
+ async walk(t = this.cwd, e = {}) {
122021
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
122022
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
122023
+ (!r || r(t)) && h.push(s ? t : t.fullpath());
122024
+ let a = new Set, l = (c, d) => {
122025
+ a.add(c), c.readdirCB((f, m) => {
122026
+ if (f)
122027
+ return d(f);
122028
+ let p = m.length;
122029
+ if (!p)
122030
+ return d();
122031
+ let w = () => {
122032
+ --p === 0 && d();
122033
+ };
122034
+ for (let g of m)
122035
+ (!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();
122036
+ }, true);
122037
+ }, u = t;
122038
+ return new Promise((c, d) => {
122039
+ l(u, (f) => {
122040
+ if (f)
122041
+ return d(f);
122042
+ c(h);
122043
+ });
122044
+ });
122045
+ }
122046
+ walkSync(t = this.cwd, e = {}) {
122047
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
122048
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
122049
+ (!r || r(t)) && h.push(s ? t : t.fullpath());
122050
+ let a = new Set([t]);
122051
+ for (let l of a) {
122052
+ let u = l.readdirSync();
122053
+ for (let c of u) {
122054
+ (!r || r(c)) && h.push(s ? c : c.fullpath());
122055
+ let d = c;
122056
+ if (c.isSymbolicLink()) {
122057
+ if (!(i && (d = c.realpathSync())))
122058
+ continue;
122059
+ d.isUnknown() && d.lstatSync();
122060
+ }
122061
+ d.shouldWalk(a, o) && a.add(d);
122062
+ }
122063
+ }
122064
+ return h;
122065
+ }
122066
+ [Symbol.asyncIterator]() {
122067
+ return this.iterate();
122068
+ }
122069
+ iterate(t = this.cwd, e = {}) {
122070
+ return typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd), this.stream(t, e)[Symbol.asyncIterator]();
122071
+ }
122072
+ [Symbol.iterator]() {
122073
+ return this.iterateSync();
122074
+ }
122075
+ *iterateSync(t = this.cwd, e = {}) {
122076
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
122077
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e;
122078
+ (!r || r(t)) && (yield s ? t : t.fullpath());
122079
+ let h = new Set([t]);
122080
+ for (let a of h) {
122081
+ let l = a.readdirSync();
122082
+ for (let u of l) {
122083
+ (!r || r(u)) && (yield s ? u : u.fullpath());
122084
+ let c = u;
122085
+ if (u.isSymbolicLink()) {
122086
+ if (!(i && (c = u.realpathSync())))
122087
+ continue;
122088
+ c.isUnknown() && c.lstatSync();
122089
+ }
122090
+ c.shouldWalk(h, o) && h.add(c);
122091
+ }
122092
+ }
122093
+ }
122094
+ stream(t = this.cwd, e = {}) {
122095
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
122096
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true });
122097
+ (!r || r(t)) && h.write(s ? t : t.fullpath());
122098
+ let a = new Set, l = [t], u = 0, c = () => {
122099
+ let d = false;
122100
+ for (;!d; ) {
122101
+ let f = l.shift();
122102
+ if (!f) {
122103
+ u === 0 && h.end();
122104
+ return;
122105
+ }
122106
+ u++, a.add(f);
122107
+ let m = (w, g, S = false) => {
122108
+ if (w)
122109
+ return h.emit("error", w);
122110
+ if (i && !S) {
122111
+ let E = [];
122112
+ for (let y of g)
122113
+ y.isSymbolicLink() && E.push(y.realpath().then((b) => b?.isUnknown() ? b.lstat() : b));
122114
+ if (E.length) {
122115
+ Promise.all(E).then(() => m(null, g, true));
122116
+ return;
122117
+ }
122118
+ }
122119
+ for (let E of g)
122120
+ E && (!r || r(E)) && (h.write(s ? E : E.fullpath()) || (d = true));
122121
+ u--;
122122
+ for (let E of g) {
122123
+ let y = E.realpathCached() || E;
122124
+ y.shouldWalk(a, o) && l.push(y);
122125
+ }
122126
+ d && !h.flowing ? h.once("drain", c) : p || c();
122127
+ }, p = true;
122128
+ f.readdirCB(m, true), p = false;
122129
+ }
122130
+ };
122131
+ return c(), h;
122132
+ }
122133
+ streamSync(t = this.cwd, e = {}) {
122134
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
122135
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true }), a = new Set;
122136
+ (!r || r(t)) && h.write(s ? t : t.fullpath());
122137
+ let l = [t], u = 0, c = () => {
122138
+ let d = false;
122139
+ for (;!d; ) {
122140
+ let f = l.shift();
122141
+ if (!f) {
122142
+ u === 0 && h.end();
122143
+ return;
122144
+ }
122145
+ u++, a.add(f);
122146
+ let m = f.readdirSync();
122147
+ for (let p of m)
122148
+ (!r || r(p)) && (h.write(s ? p : p.fullpath()) || (d = true));
122149
+ u--;
122150
+ for (let p of m) {
122151
+ let w = p;
122152
+ if (p.isSymbolicLink()) {
122153
+ if (!(i && (w = p.realpathSync())))
122154
+ continue;
122155
+ w.isUnknown() && w.lstatSync();
122156
+ }
122157
+ w.shouldWalk(a, o) && l.push(w);
122158
+ }
122159
+ }
122160
+ d && !h.flowing && h.once("drain", c);
122161
+ };
122162
+ return c(), h;
122163
+ }
122164
+ chdir(t = this.cwd) {
122165
+ let e = this.cwd;
122166
+ this.cwd = typeof t == "string" ? this.cwd.resolve(t) : t, this.cwd[Ye](e);
122167
+ }
122168
+ };
122169
+ var it = class extends It {
122170
+ sep = "\\";
122171
+ constructor(t = process.cwd(), e = {}) {
122172
+ let { nocase: s = true } = e;
122173
+ super(t, re, "\\", { ...e, nocase: s }), this.nocase = s;
122174
+ for (let i = this.cwd;i; i = i.parent)
122175
+ i.nocase = this.nocase;
122176
+ }
122177
+ parseRootPath(t) {
122178
+ return re.parse(t).root.toUpperCase();
122179
+ }
122180
+ newRoot(t) {
122181
+ return new Pt(this.rootPath, U, undefined, this.roots, this.nocase, this.childrenCache(), { fs: t });
122182
+ }
122183
+ isAbsolute(t) {
122184
+ return t.startsWith("/") || t.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(t);
122185
+ }
122186
+ };
122187
+ var rt = class extends It {
122188
+ sep = "/";
122189
+ constructor(t = process.cwd(), e = {}) {
122190
+ let { nocase: s = false } = e;
122191
+ super(t, mi, "/", { ...e, nocase: s }), this.nocase = s;
122192
+ }
122193
+ parseRootPath(t) {
122194
+ return "/";
122195
+ }
122196
+ newRoot(t) {
122197
+ return new jt(this.rootPath, U, undefined, this.roots, this.nocase, this.childrenCache(), { fs: t });
122198
+ }
122199
+ isAbsolute(t) {
122200
+ return t.startsWith("/");
122201
+ }
122202
+ };
122203
+ var St = class extends rt {
122204
+ constructor(t = process.cwd(), e = {}) {
122205
+ let { nocase: s = true } = e;
122206
+ super(t, { ...e, nocase: s });
122207
+ }
122208
+ };
122209
+ var Cr = process.platform === "win32" ? Pt : jt;
122210
+ var Xe = process.platform === "win32" ? it : process.platform === "darwin" ? St : rt;
122211
+ var Di = (n4) => n4.length >= 1;
122212
+ var Mi = (n4) => n4.length >= 1;
122213
+ var Ni = Symbol.for("nodejs.util.inspect.custom");
122214
+ var nt = class n4 {
122215
+ #t;
122216
+ #s;
122217
+ #n;
122218
+ length;
122219
+ #r;
122220
+ #o;
122221
+ #S;
122222
+ #w;
122223
+ #c;
122224
+ #h;
122225
+ #u = true;
122226
+ constructor(t, e, s, i) {
122227
+ if (!Di(t))
122228
+ throw new TypeError("empty pattern list");
122229
+ if (!Mi(e))
122230
+ throw new TypeError("empty glob list");
122231
+ if (e.length !== t.length)
122232
+ throw new TypeError("mismatched pattern list and glob list lengths");
122233
+ if (this.length = t.length, s < 0 || s >= this.length)
122234
+ throw new TypeError("index out of range");
122235
+ if (this.#t = t, this.#s = e, this.#n = s, this.#r = i, this.#n === 0) {
122236
+ if (this.isUNC()) {
122237
+ let [r, o, h, a, ...l] = this.#t, [u, c, d, f, ...m] = this.#s;
122238
+ l[0] === "" && (l.shift(), m.shift());
122239
+ let p = [r, o, h, a, ""].join("/"), w = [u, c, d, f, ""].join("/");
122240
+ this.#t = [p, ...l], this.#s = [w, ...m], this.length = this.#t.length;
122241
+ } else if (this.isDrive() || this.isAbsolute()) {
122242
+ let [r, ...o] = this.#t, [h, ...a] = this.#s;
122243
+ o[0] === "" && (o.shift(), a.shift());
122244
+ let l = r + "/", u = h + "/";
122245
+ this.#t = [l, ...o], this.#s = [u, ...a], this.length = this.#t.length;
122246
+ }
122247
+ }
122248
+ }
122249
+ [Ni]() {
122250
+ return "Pattern <" + this.#s.slice(this.#n).join("/") + ">";
122251
+ }
122252
+ pattern() {
122253
+ return this.#t[this.#n];
122254
+ }
122255
+ isString() {
122256
+ return typeof this.#t[this.#n] == "string";
122257
+ }
122258
+ isGlobstar() {
122259
+ return this.#t[this.#n] === A;
122260
+ }
122261
+ isRegExp() {
122262
+ return this.#t[this.#n] instanceof RegExp;
122263
+ }
122264
+ globString() {
122265
+ 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("/"));
122266
+ }
122267
+ hasMore() {
122268
+ return this.length > this.#n + 1;
122269
+ }
122270
+ rest() {
122271
+ 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;
122272
+ }
122273
+ isUNC() {
122274
+ let t = this.#t;
122275
+ 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];
122276
+ }
122277
+ isDrive() {
122278
+ let t = this.#t;
122279
+ 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]);
122280
+ }
122281
+ isAbsolute() {
122282
+ let t = this.#t;
122283
+ return this.#h !== undefined ? this.#h : this.#h = t[0] === "" && t.length > 1 || this.isDrive() || this.isUNC();
122284
+ }
122285
+ root() {
122286
+ let t = this.#t[0];
122287
+ return typeof t == "string" && this.isAbsolute() && this.#n === 0 ? t : "";
122288
+ }
122289
+ checkFollowGlobstar() {
122290
+ return !(this.#n === 0 || !this.isGlobstar() || !this.#u);
122291
+ }
122292
+ markFollowGlobstar() {
122293
+ return this.#n === 0 || !this.isGlobstar() || !this.#u ? false : (this.#u = false, true);
122294
+ }
122295
+ };
122296
+ var _i = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
122297
+ var ot = class {
122298
+ relative;
122299
+ relativeChildren;
122300
+ absolute;
122301
+ absoluteChildren;
122302
+ platform;
122303
+ mmopts;
122304
+ constructor(t, { nobrace: e, nocase: s, noext: i, noglobstar: r, platform: o = _i }) {
122305
+ 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 };
122306
+ for (let h of t)
122307
+ this.add(h);
122308
+ }
122309
+ add(t) {
122310
+ let e = new D(t, this.mmopts);
122311
+ for (let s = 0;s < e.set.length; s++) {
122312
+ let i = e.set[s], r = e.globParts[s];
122313
+ if (!i || !r)
122314
+ throw new Error("invalid pattern object");
122315
+ for (;i[0] === "." && r[0] === "."; )
122316
+ i.shift(), r.shift();
122317
+ let o = new nt(i, r, 0, this.platform), h = new D(o.globString(), this.mmopts), a = r[r.length - 1] === "**", l = o.isAbsolute();
122318
+ l ? this.absolute.push(h) : this.relative.push(h), a && (l ? this.absoluteChildren.push(h) : this.relativeChildren.push(h));
122319
+ }
122320
+ }
122321
+ ignored(t) {
122322
+ let e = t.fullpath(), s = `${e}/`, i = t.relative() || ".", r = `${i}/`;
122323
+ for (let o of this.relative)
122324
+ if (o.match(i) || o.match(r))
122325
+ return true;
122326
+ for (let o of this.absolute)
122327
+ if (o.match(e) || o.match(s))
122328
+ return true;
122329
+ return false;
122330
+ }
122331
+ childrenIgnored(t) {
122332
+ let e = t.fullpath() + "/", s = (t.relative() || ".") + "/";
122333
+ for (let i of this.relativeChildren)
122334
+ if (i.match(s))
122335
+ return true;
122336
+ for (let i of this.absoluteChildren)
122337
+ if (i.match(e))
122338
+ return true;
122339
+ return false;
122340
+ }
122341
+ };
122342
+ var oe = class n5 {
122343
+ store;
122344
+ constructor(t = new Map) {
122345
+ this.store = t;
122346
+ }
122347
+ copy() {
122348
+ return new n5(new Map(this.store));
122349
+ }
122350
+ hasWalked(t, e) {
122351
+ return this.store.get(t.fullpath())?.has(e.globString());
122352
+ }
122353
+ storeWalked(t, e) {
122354
+ let s = t.fullpath(), i = this.store.get(s);
122355
+ i ? i.add(e.globString()) : this.store.set(s, new Set([e.globString()]));
122356
+ }
122357
+ };
122358
+ var he = class {
122359
+ store = new Map;
122360
+ add(t, e, s) {
122361
+ let i = (e ? 2 : 0) | (s ? 1 : 0), r = this.store.get(t);
122362
+ this.store.set(t, r === undefined ? i : i & r);
122363
+ }
122364
+ entries() {
122365
+ return [...this.store.entries()].map(([t, e]) => [t, !!(e & 2), !!(e & 1)]);
122366
+ }
122367
+ };
122368
+ var ae = class {
122369
+ store = new Map;
122370
+ add(t, e) {
122371
+ if (!t.canReaddir())
122372
+ return;
122373
+ let s = this.store.get(t);
122374
+ s ? s.find((i) => i.globString() === e.globString()) || s.push(e) : this.store.set(t, [e]);
122375
+ }
122376
+ get(t) {
122377
+ let e = this.store.get(t);
122378
+ if (!e)
122379
+ throw new Error("attempting to walk unknown path");
122380
+ return e;
122381
+ }
122382
+ entries() {
122383
+ return this.keys().map((t) => [t, this.store.get(t)]);
122384
+ }
122385
+ keys() {
122386
+ return [...this.store.keys()].filter((t) => t.canReaddir());
122387
+ }
122388
+ };
122389
+ var Et = class n6 {
122390
+ hasWalkedCache;
122391
+ matches = new he;
122392
+ subwalks = new ae;
122393
+ patterns;
122394
+ follow;
122395
+ dot;
122396
+ opts;
122397
+ constructor(t, e) {
122398
+ this.opts = t, this.follow = !!t.follow, this.dot = !!t.dot, this.hasWalkedCache = e ? e.copy() : new oe;
122399
+ }
122400
+ processPatterns(t, e) {
122401
+ this.patterns = e;
122402
+ let s = e.map((i) => [t, i]);
122403
+ for (let [i, r] of s) {
122404
+ this.hasWalkedCache.storeWalked(i, r);
122405
+ let o = r.root(), h = r.isAbsolute() && this.opts.absolute !== false;
122406
+ if (o) {
122407
+ i = i.resolve(o === "/" && this.opts.root !== undefined ? this.opts.root : o);
122408
+ let c = r.rest();
122409
+ if (c)
122410
+ r = c;
122411
+ else {
122412
+ this.matches.add(i, true, false);
122413
+ continue;
122414
+ }
122415
+ }
122416
+ if (i.isENOENT())
122417
+ continue;
122418
+ let a, l, u = false;
122419
+ for (;typeof (a = r.pattern()) == "string" && (l = r.rest()); )
122420
+ i = i.resolve(a), r = l, u = true;
122421
+ if (a = r.pattern(), l = r.rest(), u) {
122422
+ if (this.hasWalkedCache.hasWalked(i, r))
122423
+ continue;
122424
+ this.hasWalkedCache.storeWalked(i, r);
122425
+ }
122426
+ if (typeof a == "string") {
122427
+ let c = a === ".." || a === "" || a === ".";
122428
+ this.matches.add(i.resolve(a), h, c);
122429
+ continue;
122430
+ } else if (a === A) {
122431
+ (!i.isSymbolicLink() || this.follow || r.checkFollowGlobstar()) && this.subwalks.add(i, r);
122432
+ let c = l?.pattern(), d = l?.rest();
122433
+ if (!l || (c === "" || c === ".") && !d)
122434
+ this.matches.add(i, h, c === "" || c === ".");
122435
+ else if (c === "..") {
122436
+ let f = i.parent || i;
122437
+ d ? this.hasWalkedCache.hasWalked(f, d) || this.subwalks.add(f, d) : this.matches.add(f, h, true);
122438
+ }
122439
+ } else
122440
+ a instanceof RegExp && this.subwalks.add(i, r);
122441
+ }
122442
+ return this;
122443
+ }
122444
+ subwalkTargets() {
122445
+ return this.subwalks.keys();
122446
+ }
122447
+ child() {
122448
+ return new n6(this.opts, this.hasWalkedCache);
122449
+ }
122450
+ filterEntries(t, e) {
122451
+ let s = this.subwalks.get(t), i = this.child();
122452
+ for (let r of e)
122453
+ for (let o of s) {
122454
+ let h = o.isAbsolute(), a = o.pattern(), l = o.rest();
122455
+ a === A ? i.testGlobstar(r, o, l, h) : a instanceof RegExp ? i.testRegExp(r, a, l, h) : i.testString(r, a, l, h);
122456
+ }
122457
+ return i;
122458
+ }
122459
+ testGlobstar(t, e, s, i) {
122460
+ 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) {
122461
+ let r = s.pattern();
122462
+ if (typeof r == "string" && r !== ".." && r !== "" && r !== ".")
122463
+ this.testString(t, r, s.rest(), i);
122464
+ else if (r === "..") {
122465
+ let o = t.parent || t;
122466
+ this.subwalks.add(o, s);
122467
+ } else
122468
+ r instanceof RegExp && this.testRegExp(t, r, s.rest(), i);
122469
+ }
122470
+ }
122471
+ testRegExp(t, e, s, i) {
122472
+ e.test(t.name) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
122473
+ }
122474
+ testString(t, e, s, i) {
122475
+ t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
122476
+ }
122477
+ };
122478
+ var Li = (n7, t) => typeof n7 == "string" ? new ot([n7], t) : Array.isArray(n7) ? new ot(n7, t) : n7;
122479
+ var zt = class {
122480
+ path;
122481
+ patterns;
122482
+ opts;
122483
+ seen = new Set;
122484
+ paused = false;
122485
+ aborted = false;
122486
+ #t = [];
122487
+ #s;
122488
+ #n;
122489
+ signal;
122490
+ maxDepth;
122491
+ includeChildMatches;
122492
+ constructor(t, e, s) {
122493
+ 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")) {
122494
+ let i = "cannot ignore child matches, ignore lacks add() method.";
122495
+ throw new Error(i);
122496
+ }
122497
+ this.maxDepth = s.maxDepth || 1 / 0, s.signal && (this.signal = s.signal, this.signal.addEventListener("abort", () => {
122498
+ this.#t.length = 0;
122499
+ }));
122500
+ }
122501
+ #r(t) {
122502
+ return this.seen.has(t) || !!this.#s?.ignored?.(t);
122503
+ }
122504
+ #o(t) {
122505
+ return !!this.#s?.childrenIgnored?.(t);
122506
+ }
122507
+ pause() {
122508
+ this.paused = true;
122509
+ }
122510
+ resume() {
122511
+ if (this.signal?.aborted)
122512
+ return;
122513
+ this.paused = false;
122514
+ let t;
122515
+ for (;!this.paused && (t = this.#t.shift()); )
122516
+ t();
122517
+ }
122518
+ onResume(t) {
122519
+ this.signal?.aborted || (this.paused ? this.#t.push(t) : t());
122520
+ }
122521
+ async matchCheck(t, e) {
122522
+ if (e && this.opts.nodir)
122523
+ return;
122524
+ let s;
122525
+ if (this.opts.realpath) {
122526
+ if (s = t.realpathCached() || await t.realpath(), !s)
122527
+ return;
122528
+ t = s;
122529
+ }
122530
+ let r = t.isUnknown() || this.opts.stat ? await t.lstat() : t;
122531
+ if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
122532
+ let o = await r.realpath();
122533
+ o && (o.isUnknown() || this.opts.stat) && await o.lstat();
122534
+ }
122535
+ return this.matchCheckTest(r, e);
122536
+ }
122537
+ matchCheckTest(t, e) {
122538
+ 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;
122539
+ }
122540
+ matchCheckSync(t, e) {
122541
+ if (e && this.opts.nodir)
122542
+ return;
122543
+ let s;
122544
+ if (this.opts.realpath) {
122545
+ if (s = t.realpathCached() || t.realpathSync(), !s)
122546
+ return;
122547
+ t = s;
122548
+ }
122549
+ let r = t.isUnknown() || this.opts.stat ? t.lstatSync() : t;
122550
+ if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
122551
+ let o = r.realpathSync();
122552
+ o && (o?.isUnknown() || this.opts.stat) && o.lstatSync();
122553
+ }
122554
+ return this.matchCheckTest(r, e);
122555
+ }
122556
+ matchFinish(t, e) {
122557
+ if (this.#r(t))
122558
+ return;
122559
+ if (!this.includeChildMatches && this.#s?.add) {
122560
+ let r = `${t.relativePosix()}/**`;
122561
+ this.#s.add(r);
122562
+ }
122563
+ let s = this.opts.absolute === undefined ? e : this.opts.absolute;
122564
+ this.seen.add(t);
122565
+ let i = this.opts.mark && t.isDirectory() ? this.#n : "";
122566
+ if (this.opts.withFileTypes)
122567
+ this.matchEmit(t);
122568
+ else if (s) {
122569
+ let r = this.opts.posix ? t.fullpathPosix() : t.fullpath();
122570
+ this.matchEmit(r + i);
122571
+ } else {
122572
+ let r = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !r.startsWith(".." + this.#n) ? "." + this.#n : "";
122573
+ this.matchEmit(r ? o + r + i : "." + i);
122574
+ }
122575
+ }
122576
+ async match(t, e, s) {
122577
+ let i = await this.matchCheck(t, s);
122578
+ i && this.matchFinish(i, e);
122579
+ }
122580
+ matchSync(t, e, s) {
122581
+ let i = this.matchCheckSync(t, s);
122582
+ i && this.matchFinish(i, e);
122583
+ }
122584
+ walkCB(t, e, s) {
122585
+ this.signal?.aborted && s(), this.walkCB2(t, e, new Et(this.opts), s);
122586
+ }
122587
+ walkCB2(t, e, s, i) {
122588
+ if (this.#o(t))
122589
+ return i();
122590
+ if (this.signal?.aborted && i(), this.paused) {
122591
+ this.onResume(() => this.walkCB2(t, e, s, i));
122592
+ return;
122593
+ }
122594
+ s.processPatterns(t, e);
122595
+ let r = 1, o = () => {
122596
+ --r === 0 && i();
122597
+ };
122598
+ for (let [h, a, l] of s.matches.entries())
122599
+ this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
122600
+ for (let h of s.subwalkTargets()) {
122601
+ if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth)
122602
+ continue;
122603
+ r++;
122604
+ let a = h.readdirCached();
122605
+ h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, u) => this.walkCB3(h, u, s, o), true);
122606
+ }
122607
+ o();
122608
+ }
122609
+ walkCB3(t, e, s, i) {
122610
+ s = s.filterEntries(t, e);
122611
+ let r = 1, o = () => {
122612
+ --r === 0 && i();
122613
+ };
122614
+ for (let [h, a, l] of s.matches.entries())
122615
+ this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
122616
+ for (let [h, a] of s.subwalks.entries())
122617
+ r++, this.walkCB2(h, a, s.child(), o);
122618
+ o();
122619
+ }
122620
+ walkCBSync(t, e, s) {
122621
+ this.signal?.aborted && s(), this.walkCB2Sync(t, e, new Et(this.opts), s);
122622
+ }
122623
+ walkCB2Sync(t, e, s, i) {
122624
+ if (this.#o(t))
122625
+ return i();
122626
+ if (this.signal?.aborted && i(), this.paused) {
122627
+ this.onResume(() => this.walkCB2Sync(t, e, s, i));
122628
+ return;
122629
+ }
122630
+ s.processPatterns(t, e);
122631
+ let r = 1, o = () => {
122632
+ --r === 0 && i();
122633
+ };
122634
+ for (let [h, a, l] of s.matches.entries())
122635
+ this.#r(h) || this.matchSync(h, a, l);
122636
+ for (let h of s.subwalkTargets()) {
122637
+ if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth)
122638
+ continue;
122639
+ r++;
122640
+ let a = h.readdirSync();
122641
+ this.walkCB3Sync(h, a, s, o);
122642
+ }
122643
+ o();
122644
+ }
122645
+ walkCB3Sync(t, e, s, i) {
122646
+ s = s.filterEntries(t, e);
122647
+ let r = 1, o = () => {
122648
+ --r === 0 && i();
122649
+ };
122650
+ for (let [h, a, l] of s.matches.entries())
122651
+ this.#r(h) || this.matchSync(h, a, l);
122652
+ for (let [h, a] of s.subwalks.entries())
122653
+ r++, this.walkCB2Sync(h, a, s.child(), o);
122654
+ o();
122655
+ }
122656
+ };
122657
+ var xt = class extends zt {
122658
+ matches = new Set;
122659
+ constructor(t, e, s) {
122660
+ super(t, e, s);
122661
+ }
122662
+ matchEmit(t) {
122663
+ this.matches.add(t);
122664
+ }
122665
+ async walk() {
122666
+ if (this.signal?.aborted)
122667
+ throw this.signal.reason;
122668
+ return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
122669
+ this.walkCB(this.path, this.patterns, () => {
122670
+ this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
122671
+ });
122672
+ }), this.matches;
122673
+ }
122674
+ walkSync() {
122675
+ if (this.signal?.aborted)
122676
+ throw this.signal.reason;
122677
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
122678
+ if (this.signal?.aborted)
122679
+ throw this.signal.reason;
122680
+ }), this.matches;
122681
+ }
122682
+ };
122683
+ var vt = class extends zt {
122684
+ results;
122685
+ constructor(t, e, s) {
122686
+ 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());
122687
+ }
122688
+ matchEmit(t) {
122689
+ this.results.write(t), this.results.flowing || this.pause();
122690
+ }
122691
+ stream() {
122692
+ let t = this.path;
122693
+ return t.isUnknown() ? t.lstat().then(() => {
122694
+ this.walkCB(t, this.patterns, () => this.results.end());
122695
+ }) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
122696
+ }
122697
+ streamSync() {
122698
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
122699
+ }
122700
+ };
122701
+ var Pi = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
122702
+ var I = class {
122703
+ absolute;
122704
+ cwd;
122705
+ root;
122706
+ dot;
122707
+ dotRelative;
122708
+ follow;
122709
+ ignore;
122710
+ magicalBraces;
122711
+ mark;
122712
+ matchBase;
122713
+ maxDepth;
122714
+ nobrace;
122715
+ nocase;
122716
+ nodir;
122717
+ noext;
122718
+ noglobstar;
122719
+ pattern;
122720
+ platform;
122721
+ realpath;
122722
+ scurry;
122723
+ stat;
122724
+ signal;
122725
+ windowsPathsNoEscape;
122726
+ withFileTypes;
122727
+ includeChildMatches;
122728
+ opts;
122729
+ patterns;
122730
+ constructor(t, e) {
122731
+ if (!e)
122732
+ throw new TypeError("glob options required");
122733
+ 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)
122734
+ throw new Error("cannot set absolute and withFileTypes:true");
122735
+ if (typeof t == "string" && (t = [t]), this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === false, this.windowsPathsNoEscape && (t = t.map((a) => a.replace(/\\/g, "/"))), this.matchBase) {
122736
+ if (e.noglobstar)
122737
+ throw new TypeError("base matching requires globstar");
122738
+ t = t.map((a) => a.includes("/") ? a : `./**/${a}`);
122739
+ }
122740
+ if (this.pattern = t, this.platform = e.platform || Pi, this.opts = { ...e, platform: this.platform }, e.scurry) {
122741
+ if (this.scurry = e.scurry, e.nocase !== undefined && e.nocase !== e.scurry.nocase)
122742
+ throw new Error("nocase option contradicts provided scurry option");
122743
+ } else {
122744
+ let a = e.platform === "win32" ? it : e.platform === "darwin" ? St : e.platform ? rt : Xe;
122745
+ this.scurry = new a(this.cwd, { nocase: e.nocase, fs: e.fs });
122746
+ }
122747
+ this.nocase = this.scurry.nocase;
122748
+ 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), [[], []]);
122749
+ this.patterns = o.map((a, l) => {
122750
+ let u = h[l];
122751
+ if (!u)
122752
+ throw new Error("invalid pattern object");
122753
+ return new nt(a, u, 0, this.platform);
122754
+ });
122755
+ }
122756
+ async walk() {
122757
+ 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()];
122758
+ }
122759
+ walkSync() {
122760
+ 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()];
122761
+ }
122762
+ stream() {
122763
+ 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();
122764
+ }
122765
+ streamSync() {
122766
+ 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();
122767
+ }
122768
+ iterateSync() {
122769
+ return this.streamSync()[Symbol.iterator]();
122770
+ }
122771
+ [Symbol.iterator]() {
122772
+ return this.iterateSync();
122773
+ }
122774
+ iterate() {
122775
+ return this.stream()[Symbol.asyncIterator]();
122776
+ }
122777
+ [Symbol.asyncIterator]() {
122778
+ return this.iterate();
122779
+ }
122780
+ };
122781
+ var le = (n7, t = {}) => {
122782
+ Array.isArray(n7) || (n7 = [n7]);
122783
+ for (let e of n7)
122784
+ if (new D(e, t).hasMagic())
122785
+ return true;
122786
+ return false;
122787
+ };
122788
+ function Bt(n7, t = {}) {
122789
+ return new I(n7, t).streamSync();
122790
+ }
122791
+ function Qe(n7, t = {}) {
122792
+ return new I(n7, t).stream();
122793
+ }
122794
+ function ts(n7, t = {}) {
122795
+ return new I(n7, t).walkSync();
122796
+ }
122797
+ async function Je(n7, t = {}) {
122798
+ return new I(n7, t).walk();
122799
+ }
122800
+ function Ut(n7, t = {}) {
122801
+ return new I(n7, t).iterateSync();
122802
+ }
122803
+ function es(n7, t = {}) {
122804
+ return new I(n7, t).iterate();
122805
+ }
122806
+ var ji = Bt;
122807
+ var Ii = Object.assign(Qe, { sync: Bt });
122808
+ var zi = Ut;
122809
+ var Bi = Object.assign(es, { sync: Ut });
122810
+ var Ui = Object.assign(ts, { stream: Bt, iterate: Ut });
122811
+ 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 });
122812
+ Ze.glob = Ze;
122813
+
122814
+ // src/core/agents/offSecAgent/tools/glob.ts
122815
+ init_zod();
122816
+ var DEFAULT_IGNORE = [
122817
+ "**/node_modules/**",
122818
+ "**/.git/**",
122819
+ "**/dist/**",
122820
+ "**/build/**",
122821
+ "**/.next/**",
122822
+ "**/coverage/**",
122823
+ "**/__pycache__/**",
122824
+ "**/.venv/**",
122825
+ "**/venv/**"
122826
+ ];
122827
+ var MAX_RESULTS = 200;
122828
+ var globInputSchema = exports_external.object({
122829
+ pattern: exports_external.string().describe('Glob pattern to match files (e.g. "**/*.ts", "src/**/*.tsx", "**/package.json")'),
122830
+ path: exports_external.string().optional().describe("Directory to search from (absolute or relative to agent cwd). Defaults to agent cwd."),
122831
+ toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Find all TypeScript source files')")
122832
+ });
122833
+ function resolveGlobRoot(agentCwd, path) {
122834
+ const root = path ? isAbsolute9(path) ? path : resolve10(agentCwd, path) : agentCwd;
122835
+ const rel = relative7(agentCwd, root);
122836
+ if (rel.startsWith("..") || isAbsolute9(rel)) {
122837
+ throw new Error(`Path escapes agent working directory: ${path ?? root}`);
122838
+ }
122839
+ return root;
122840
+ }
122841
+ function globFiles(ctx) {
122842
+ return tool({
122843
+ description: `Find files by glob pattern under the agent working directory.
122844
+
122845
+ Examples:
122846
+ - "**/*.ts" — all TypeScript files
122847
+ - "src/**/*.{ts,tsx}" — sources under src/
122848
+ - "**/package.json" — package manifests
122849
+
122850
+ Skips common junk directories (node_modules, .git, dist, build, .next, coverage, venv).
122851
+ Results are capped at ${MAX_RESULTS}; narrow the pattern if truncated.`,
122852
+ inputSchema: globInputSchema,
122853
+ execute: async ({ pattern, path }) => {
122854
+ let root;
122855
+ try {
122856
+ root = resolveGlobRoot(ctx.agentCwd, path);
122857
+ } catch (err) {
122858
+ return {
122859
+ success: false,
122860
+ error: err instanceof Error ? err.message : String(err),
122861
+ files: [],
122862
+ count: 0,
122863
+ pattern,
122864
+ cwd: ctx.agentCwd
122865
+ };
122866
+ }
122867
+ try {
122868
+ if (ctx.sandbox) {
122869
+ const escapedPattern = pattern.replace(/"/g, "\\\"");
122870
+ const cmd = `shopt -s globstar nullglob 2>/dev/null; cd "${root}" && compgen -G "${escapedPattern}" | head -n ${MAX_RESULTS + 1}`;
122871
+ const result = await ctx.sandbox.execute(cmd, { timeout: 30 });
122872
+ const lines = result.stdout.split(`
122873
+ `).map((l) => l.trim()).filter(Boolean);
122874
+ const truncated2 = lines.length > MAX_RESULTS;
122875
+ const files2 = lines.slice(0, MAX_RESULTS);
122876
+ return {
122877
+ success: true,
122878
+ error: truncated2 ? `Showing ${MAX_RESULTS} of at least ${lines.length} matches — narrow the pattern` : "",
122879
+ files: files2,
122880
+ count: files2.length,
122881
+ totalFound: truncated2 ? lines.length : undefined,
122882
+ pattern,
122883
+ cwd: root
122884
+ };
122885
+ }
122886
+ const matches = await Ze(pattern, {
122887
+ cwd: root,
122888
+ nodir: true,
122889
+ dot: false,
122890
+ ignore: DEFAULT_IGNORE,
122891
+ absolute: false
122892
+ });
122893
+ const truncated = matches.length > MAX_RESULTS;
122894
+ const files = matches.slice(0, MAX_RESULTS).sort();
122895
+ return {
122896
+ success: true,
122897
+ error: truncated ? `Showing ${MAX_RESULTS} of ${matches.length} matches — narrow the pattern` : "",
122898
+ files,
122899
+ count: files.length,
122900
+ totalFound: truncated ? matches.length : undefined,
122901
+ pattern,
122902
+ cwd: root
122903
+ };
122904
+ } catch (err) {
122905
+ return {
122906
+ success: false,
122907
+ error: err instanceof Error ? err.message : String(err),
122908
+ files: [],
122909
+ count: 0,
122910
+ pattern,
122911
+ cwd: root
122912
+ };
122913
+ }
122914
+ }
122915
+ });
122916
+ }
118941
122917
  // src/core/agents/offSecAgent/tools/listPromptInjections.ts
118942
122918
  init_dist();
118943
122919
  init_zod();
@@ -119151,7 +123127,7 @@ Use this instead of asking for the whole playbook. Examples:
119151
123127
  // src/core/agents/offSecAgent/tools/runCodeQuery.ts
119152
123128
  init_dist();
119153
123129
  init_zod();
119154
- import { relative as relative5 } from "node:path";
123130
+ import { relative as relative8 } from "node:path";
119155
123131
  var MAX_INLINE_MATCHES = 40;
119156
123132
  var MAX_QUERY_CAPTURE_BYTES = 2 * 1024 * 1024;
119157
123133
  var QueryEngineSchema = exports_external.enum(["rg", "grep", "ast-grep", "comby"]);
@@ -119222,7 +123198,7 @@ instead of flooding context with every match. Output size and runtime are bounde
119222
123198
  let targetPathForEngine = ".";
119223
123199
  try {
119224
123200
  const absTarget = resolvePathWithinCodebaseRoot(rootPath, query.path ?? ".");
119225
- targetPathForEngine = relative5(rootPath, absTarget) || ".";
123201
+ targetPathForEngine = relative8(rootPath, absTarget) || ".";
119226
123202
  } catch (error) {
119227
123203
  results.push({
119228
123204
  engine,
@@ -119587,10 +123563,10 @@ function listWhiteboxCandidates2(ctx) {
119587
123563
  // src/core/agents/offSecAgent/tools/whiteboxJobs.ts
119588
123564
  init_dist();
119589
123565
  init_zod();
119590
- import { isAbsolute as isAbsolute7, relative as relative6, sep as sep2 } from "node:path";
123566
+ import { isAbsolute as isAbsolute10, relative as relative9, sep as sep2 } from "node:path";
119591
123567
  function displayPath(ctx, path) {
119592
123568
  const prefix = ctx.session.rootPath.endsWith(sep2) ? ctx.session.rootPath : `${ctx.session.rootPath}${sep2}`;
119593
- return path === ctx.session.rootPath || path.startsWith(prefix) ? relative6(ctx.session.rootPath, path) : path;
123569
+ return path === ctx.session.rootPath || path.startsWith(prefix) ? relative9(ctx.session.rootPath, path) : path;
119594
123570
  }
119595
123571
  function startWhiteboxJob2(ctx) {
119596
123572
  return tool({
@@ -119725,9 +123701,9 @@ function stopWhiteboxJob2(ctx) {
119725
123701
  });
119726
123702
  }
119727
123703
  function normalizeArtifactRelativePath(ctx, userPath) {
119728
- if (isAbsolute7(userPath)) {
119729
- const rel = relative6(ctx.session.rootPath, userPath);
119730
- if (rel.startsWith("..") || rel === ".." || isAbsolute7(rel)) {
123704
+ if (isAbsolute10(userPath)) {
123705
+ const rel = relative9(ctx.session.rootPath, userPath);
123706
+ if (rel.startsWith("..") || rel === ".." || isAbsolute10(rel)) {
119731
123707
  throw new Error("Artifact path must be inside the session directory.");
119732
123708
  }
119733
123709
  return rel.replace(/\\/g, "/");
@@ -119825,12 +123801,17 @@ function createAllTools(ctx) {
119825
123801
  document_vulnerability: documentVulnerability(ctx),
119826
123802
  read_file: readFile2(ctx),
119827
123803
  list_files: listFiles(ctx),
123804
+ glob: globFiles(ctx),
119828
123805
  grep: grep(ctx),
119829
123806
  profile_codebase: profileCodebase2(ctx),
119830
123807
  query_whitebox_catalog: queryWhiteboxCatalog2(ctx),
119831
123808
  run_code_query: runCodeQuery(ctx),
119832
123809
  create_file: createFile(ctx),
119833
123810
  update_file: updateFile(ctx),
123811
+ delete_file: deleteFile(ctx),
123812
+ apply_patch: applyPatch(ctx),
123813
+ git_status: gitStatus(ctx),
123814
+ git_diff: gitDiff(ctx),
119834
123815
  document_app: documentApp(ctx),
119835
123816
  document_endpoint: documentEndpoint(ctx),
119836
123817
  delegate_to_auth_subagent: delegateAuth(ctx),
@@ -119893,12 +123874,17 @@ var ALL_TOOL_NAMES = [
119893
123874
  "document_vulnerability",
119894
123875
  "read_file",
119895
123876
  "list_files",
123877
+ "glob",
119896
123878
  "grep",
119897
123879
  "profile_codebase",
119898
123880
  "query_whitebox_catalog",
119899
123881
  "run_code_query",
119900
123882
  "create_file",
119901
123883
  "update_file",
123884
+ "delete_file",
123885
+ "apply_patch",
123886
+ "git_status",
123887
+ "git_diff",
119902
123888
  "document_app",
119903
123889
  "document_endpoint",
119904
123890
  "delegate_to_auth_subagent",
@@ -119976,8 +123962,11 @@ var PLAN_MODE_TOOL_NAMES = [
119976
123962
  "http_request",
119977
123963
  "read_file",
119978
123964
  "list_files",
123965
+ "glob",
119979
123966
  "grep",
119980
123967
  "query_whitebox_catalog",
123968
+ "git_status",
123969
+ "git_diff",
119981
123970
  "delegate_to_auth_subagent",
119982
123971
  "complete_authentication",
119983
123972
  "extract_js_endpoints",
@@ -120010,7 +123999,7 @@ var SKILL_TOOL_NAMES = ["read_skill"];
120010
123999
  // src/core/agents/offSecAgent/trace.ts
120011
124000
  import { createHash as createHash2 } from "node:crypto";
120012
124001
  import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync13 } from "node:fs";
120013
- import { dirname as dirname7 } from "node:path";
124002
+ import { dirname as dirname8 } from "node:path";
120014
124003
  var OUTPUT_PREVIEW_LIMIT = 2000;
120015
124004
  var INPUT_PREVIEW_LIMIT = 1000;
120016
124005
  var SYSTEM_PROMPT_HASH_PREFIX_LENGTH = 12;
@@ -120071,7 +124060,7 @@ class StepTraceWriter {
120071
124060
  const now = Date.now();
120072
124061
  this.agentStartTime = now;
120073
124062
  this.lastStepTime = now;
120074
- mkdirSync13(dirname7(this.tracePath), { recursive: true });
124063
+ mkdirSync13(dirname8(this.tracePath), { recursive: true });
120075
124064
  }
120076
124065
  writeInit(data) {
120077
124066
  const { systemPrompt, ...rest } = data;
@@ -120211,7 +124200,7 @@ class StepTraceWriter {
120211
124200
  init_dist();
120212
124201
  init_ai();
120213
124202
  import { existsSync as existsSync18, mkdirSync as mkdirSync14, readFileSync as readFileSync8 } from "node:fs";
120214
- import { writeFile as writeFile6 } from "node:fs/promises";
124203
+ import { writeFile as writeFile7 } from "node:fs/promises";
120215
124204
  import { join as join27 } from "node:path";
120216
124205
  init_id();
120217
124206
  init_structured();
@@ -120264,8 +124253,8 @@ class ApprovalGate extends EventEmitter3 {
120264
124253
  tier: 1,
120265
124254
  timestamp: Date.now()
120266
124255
  };
120267
- return new Promise((resolve8, reject) => {
120268
- const deferred = { approval, resolve: resolve8, reject };
124256
+ return new Promise((resolve11, reject) => {
124257
+ const deferred = { approval, resolve: resolve11, reject };
120269
124258
  this.pendingApprovals.set(approval.id, deferred);
120270
124259
  const timeoutMs = this.config.decisionTimeoutMs;
120271
124260
  if (timeoutMs !== undefined && timeoutMs > 0) {
@@ -120521,8 +124510,8 @@ class OffensiveSecurityAgent {
120521
124510
  _responseToolFired = false;
120522
124511
  _resolveResponseCaptured;
120523
124512
  _rejectResponseCaptured;
120524
- responseCaptured = new Promise((resolve8, reject) => {
120525
- this._resolveResponseCaptured = resolve8;
124513
+ responseCaptured = new Promise((resolve11, reject) => {
124514
+ this._resolveResponseCaptured = resolve11;
120526
124515
  this._rejectResponseCaptured = reject;
120527
124516
  });
120528
124517
  _drainRejection = new Promise(() => {});
@@ -120741,7 +124730,7 @@ class OffensiveSecurityAgent {
120741
124730
  if (this.latestMessages) {
120742
124731
  const toWrite = this.latestMessages;
120743
124732
  this.latestMessages = null;
120744
- writeFile6(messagesPath, JSON.stringify(toWrite)).catch(() => {});
124733
+ writeFile7(messagesPath, JSON.stringify(toWrite)).catch(() => {});
120745
124734
  }
120746
124735
  }, PERSIST_INTERVAL_MS);
120747
124736
  };
@@ -120754,7 +124743,7 @@ class OffensiveSecurityAgent {
120754
124743
  const baseSystemPrompt = input.system ?? detectOSAndEnhancePrompt(buildBaseSystemPrompt({
120755
124744
  sandboxMode: agentCwd === input.session.rootPath
120756
124745
  }));
120757
- const systemPrompt = baseSystemPrompt + buildSessionWorkspaceSection(input.session, agentCwd);
124746
+ const systemPrompt = baseSystemPrompt + buildSessionWorkspaceSection(input.session, agentCwd, activeTools);
120758
124747
  traceWriter.writeInit({
120759
124748
  model: input.model,
120760
124749
  systemPrompt: baseSystemPrompt,
@@ -120809,7 +124798,7 @@ class OffensiveSecurityAgent {
120809
124798
  ...initialMessagesRef.current,
120810
124799
  ...event.response.messages
120811
124800
  ];
120812
- await writeFile6(messagesPath, JSON.stringify(finalMessages)).catch(() => {});
124801
+ await writeFile7(messagesPath, JSON.stringify(finalMessages)).catch(() => {});
120813
124802
  }
120814
124803
  await input.onFinish?.(event);
120815
124804
  },
@@ -120922,7 +124911,7 @@ class OffensiveSecurityAgent {
120922
124911
  const fr = c.finishReason;
120923
124912
  rlog.warn(`[response-debug] finish-step finishReason=${fr} responseInFlight=${[
120924
124913
  ...inFlightTools.entries()
120925
- ].filter(([, n]) => n === RESPONSE_TOOL_NAME).map(([id]) => id).join(",")} responseToolFired=${this._responseToolFired}`);
124914
+ ].filter(([, n7]) => n7 === RESPONSE_TOOL_NAME).map(([id]) => id).join(",")} responseToolFired=${this._responseToolFired}`);
120926
124915
  }
120927
124916
  }
120928
124917
  }
@@ -120951,20 +124940,20 @@ class OffensiveSecurityAgent {
120951
124940
  inFlightTools.set(chunk.toolCallId, chunk.toolName);
120952
124941
  break;
120953
124942
  case "tool-error": {
120954
- const te = chunk;
120955
- inFlightTools.delete(te.toolCallId);
120956
- const errMsg = te.error instanceof Error ? te.error.message : typeof te.error === "string" ? te.error : (() => {
124943
+ const te2 = chunk;
124944
+ inFlightTools.delete(te2.toolCallId);
124945
+ const errMsg = te2.error instanceof Error ? te2.error.message : typeof te2.error === "string" ? te2.error : (() => {
120957
124946
  try {
120958
- return JSON.stringify(te.error);
124947
+ return JSON.stringify(te2.error);
120959
124948
  } catch {
120960
- return String(te.error);
124949
+ return String(te2.error);
120961
124950
  }
120962
124951
  })();
120963
- const partialArgs = te.input !== undefined && te.input !== null && responseArgBytes(te.input) > 2 ? te.input : streamedArgText.get(te.toolCallId) ?? "";
120964
- toolErrors.set(te.toolCallId, {
124952
+ const partialArgs = te2.input !== undefined && te2.input !== null && responseArgBytes(te2.input) > 2 ? te2.input : streamedArgText.get(te2.toolCallId) ?? "";
124953
+ toolErrors.set(te2.toolCallId, {
120965
124954
  message: errMsg,
120966
124955
  input: partialArgs,
120967
- toolName: te.toolName
124956
+ toolName: te2.toolName
120968
124957
  });
120969
124958
  break;
120970
124959
  }
@@ -121092,7 +125081,7 @@ class OffensiveSecurityAgent {
121092
125081
  }
121093
125082
  }));
121094
125083
  let rejectDrain;
121095
- this._drainRejection = new Promise((_, reject) => {
125084
+ this._drainRejection = new Promise((_2, reject) => {
121096
125085
  rejectDrain = reject;
121097
125086
  });
121098
125087
  this._drainRejection.catch(() => {});
@@ -121137,7 +125126,7 @@ class OffensiveSecurityAgent {
121137
125126
  };
121138
125127
  const syntheticParts = [];
121139
125128
  if (RESPONSE_DEBUG) {
121140
- const responseInFlight = [...inFlightTools.entries()].filter(([, n]) => n === RESPONSE_TOOL_NAME);
125129
+ const responseInFlight = [...inFlightTools.entries()].filter(([, n7]) => n7 === RESPONSE_TOOL_NAME);
121141
125130
  if (responseInFlight.length > 0) {
121142
125131
  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
125132
  }
@@ -121195,7 +125184,7 @@ class OffensiveSecurityAgent {
121195
125184
  }
121196
125185
  };
121197
125186
  if (RESPONSE_DEBUG) {
121198
- const responseReconstructed = stepTools.filter(([, n]) => n === RESPONSE_TOOL_NAME).map(([id]) => id);
125187
+ const responseReconstructed = stepTools.filter(([, n7]) => n7 === RESPONSE_TOOL_NAME).map(([id]) => id);
121199
125188
  if (responseReconstructed.length > 0) {
121200
125189
  rlog.warn(`[response-debug] step-reconstruction for response call(s) ` + `ids=${responseReconstructed.join(",")} ` + `preservedArgChars=${responseReconstructed.map((id) => streamedArgText?.get(id)?.length ?? 0).join(",")}`);
121201
125190
  }
@@ -121215,7 +125204,7 @@ class OffensiveSecurityAgent {
121215
125204
  const next = [...base, ...appended];
121216
125205
  this.latestMessages = next;
121217
125206
  try {
121218
- await writeFile6(this.messagesPath, JSON.stringify(next));
125207
+ await writeFile7(this.messagesPath, JSON.stringify(next));
121219
125208
  this.syntheticsPersisted = true;
121220
125209
  } catch {}
121221
125210
  }