@pensar/apex 2.2.0 → 2.3.0-canary.545f12fe

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