@pensar/apex 2.2.0 → 2.3.0-canary.9edb404e

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