dorkos 0.9.0 → 0.10.0

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.
@@ -9504,11 +9504,11 @@ var require_mime_types = __commonJS({
9504
9504
  }
9505
9505
  return exts[0];
9506
9506
  }
9507
- function lookup(path29) {
9508
- if (!path29 || typeof path29 !== "string") {
9507
+ function lookup(path30) {
9508
+ if (!path30 || typeof path30 !== "string") {
9509
9509
  return false;
9510
9510
  }
9511
- var extension2 = extname2("x." + path29).toLowerCase().substr(1);
9511
+ var extension2 = extname2("x." + path30).toLowerCase().substr(1);
9512
9512
  if (!extension2) {
9513
9513
  return false;
9514
9514
  }
@@ -10017,19 +10017,19 @@ var require_utils = __commonJS({
10017
10017
  if (decode)
10018
10018
  return decode(data, hint);
10019
10019
  }
10020
- function basename4(path29) {
10021
- if (typeof path29 !== "string")
10020
+ function basename4(path30) {
10021
+ if (typeof path30 !== "string")
10022
10022
  return "";
10023
- for (let i2 = path29.length - 1; i2 >= 0; --i2) {
10024
- switch (path29.charCodeAt(i2)) {
10023
+ for (let i2 = path30.length - 1; i2 >= 0; --i2) {
10024
+ switch (path30.charCodeAt(i2)) {
10025
10025
  case 47:
10026
10026
  // '/'
10027
10027
  case 92:
10028
- path29 = path29.slice(i2 + 1);
10029
- return path29 === ".." || path29 === "." ? "" : path29;
10028
+ path30 = path30.slice(i2 + 1);
10029
+ return path30 === ".." || path30 === "." ? "" : path30;
10030
10030
  }
10031
10031
  }
10032
- return path29 === ".." || path29 === "." ? "" : path29;
10032
+ return path30 === ".." || path30 === "." ? "" : path30;
10033
10033
  }
10034
10034
  var TOKEN = [
10035
10035
  0,
@@ -13874,7 +13874,7 @@ var require_disk = __commonJS({
13874
13874
  "../../node_modules/.pnpm/multer@2.1.1/node_modules/multer/storage/disk.js"(exports, module) {
13875
13875
  var fs20 = __require("fs");
13876
13876
  var os7 = __require("os");
13877
- var path29 = __require("path");
13877
+ var path30 = __require("path");
13878
13878
  var crypto7 = __require("crypto");
13879
13879
  function getFilename(req, file, cb) {
13880
13880
  crypto7.randomBytes(16, function(err, raw) {
@@ -13901,7 +13901,7 @@ var require_disk = __commonJS({
13901
13901
  if (err) return cb(err);
13902
13902
  that.getFilename(req, file, function(err2, filename) {
13903
13903
  if (err2) return cb(err2);
13904
- var finalPath = path29.join(destination, filename);
13904
+ var finalPath = path30.join(destination, filename);
13905
13905
  var outStream = fs20.createWriteStream(finalPath);
13906
13906
  file.stream.pipe(outStream);
13907
13907
  outStream.on("error", cb);
@@ -13917,11 +13917,11 @@ var require_disk = __commonJS({
13917
13917
  });
13918
13918
  };
13919
13919
  DiskStorage.prototype._removeFile = function _removeFile(req, file, cb) {
13920
- var path30 = file.path;
13920
+ var path31 = file.path;
13921
13921
  delete file.destination;
13922
13922
  delete file.filename;
13923
13923
  delete file.path;
13924
- fs20.unlink(path30, cb);
13924
+ fs20.unlink(path31, cb);
13925
13925
  };
13926
13926
  module.exports = function(opts) {
13927
13927
  return new DiskStorage(opts);
@@ -22440,14 +22440,14 @@ var require_url_state_machine = __commonJS({
22440
22440
  return url.replace(/\u0009|\u000A|\u000D/g, "");
22441
22441
  }
22442
22442
  function shortenPath(url) {
22443
- const path29 = url.path;
22444
- if (path29.length === 0) {
22443
+ const path30 = url.path;
22444
+ if (path30.length === 0) {
22445
22445
  return;
22446
22446
  }
22447
- if (url.scheme === "file" && path29.length === 1 && isNormalizedWindowsDriveLetter(path29[0])) {
22447
+ if (url.scheme === "file" && path30.length === 1 && isNormalizedWindowsDriveLetter(path30[0])) {
22448
22448
  return;
22449
22449
  }
22450
- path29.pop();
22450
+ path30.pop();
22451
22451
  }
22452
22452
  function includesCredentials(url) {
22453
22453
  return url.username !== "" || url.password !== "";
@@ -35879,8 +35879,8 @@ var require_utils3 = __commonJS({
35879
35879
  }
35880
35880
  return ind;
35881
35881
  }
35882
- function removeDotSegments(path29) {
35883
- let input = path29;
35882
+ function removeDotSegments(path30) {
35883
+ let input = path30;
35884
35884
  const output = [];
35885
35885
  let nextSlash = -1;
35886
35886
  let len = 0;
@@ -36079,8 +36079,8 @@ var require_schemes = __commonJS({
36079
36079
  wsComponent.secure = void 0;
36080
36080
  }
36081
36081
  if (wsComponent.resourceName) {
36082
- const [path29, query2] = wsComponent.resourceName.split("?");
36083
- wsComponent.path = path29 && path29 !== "/" ? path29 : void 0;
36082
+ const [path30, query2] = wsComponent.resourceName.split("?");
36083
+ wsComponent.path = path30 && path30 !== "/" ? path30 : void 0;
36084
36084
  wsComponent.query = query2;
36085
36085
  wsComponent.resourceName = void 0;
36086
36086
  }
@@ -39456,12 +39456,12 @@ var require_dist = __commonJS({
39456
39456
  });
39457
39457
 
39458
39458
  // ../../apps/server/src/index.ts
39459
- import path28 from "path";
39459
+ import path29 from "path";
39460
39460
 
39461
39461
  // ../../apps/server/src/app.ts
39462
39462
  import express from "express";
39463
39463
  import cors from "cors";
39464
- import path8 from "path";
39464
+ import path9 from "path";
39465
39465
  import { fileURLToPath as fileURLToPath2 } from "url";
39466
39466
  import { apiReference } from "@scalar/express-api-reference";
39467
39467
 
@@ -39823,7 +39823,9 @@ var HealthResponseSchema = z.object({
39823
39823
  }).openapi("HealthResponse");
39824
39824
  var ServerConfigSchema = z.object({
39825
39825
  version: z.string().openapi({ description: "Current server version" }),
39826
- latestVersion: z.string().nullable().openapi({ description: "Latest available version from npm, or null if unknown" }),
39826
+ latestVersion: z.string().nullable().openapi({ description: "Latest available version from npm, or null if dev mode or unknown" }),
39827
+ isDevMode: z.boolean().openapi({ description: "Whether the server is running a development build" }),
39828
+ dismissedUpgradeVersions: z.array(z.string()).openapi({ description: "Versions the user has dismissed upgrade notifications for" }),
39827
39829
  port: z.number().int(),
39828
39830
  uptime: z.number(),
39829
39831
  workingDirectory: z.string(),
@@ -40105,7 +40107,7 @@ var serverEnvSchema = z3.object({
40105
40107
  DORKOS_BOUNDARY: z3.string().optional(),
40106
40108
  DORKOS_LOG_LEVEL: z3.coerce.number().int().min(0).max(5).optional(),
40107
40109
  DORK_HOME: z3.string().optional(),
40108
- DORKOS_VERSION: z3.string().optional(),
40110
+ DORKOS_VERSION_OVERRIDE: z3.string().optional(),
40109
40111
  CLIENT_DIST_PATH: z3.string().optional(),
40110
40112
  // MCP external server — optional API key for authenticated access
40111
40113
  MCP_API_KEY: z3.string().optional(),
@@ -41700,7 +41702,20 @@ var TunnelManager = class extends EventEmitter {
41700
41702
  var tunnelManager = new TunnelManager();
41701
41703
 
41702
41704
  // ../../apps/server/src/lib/version.ts
41703
- var SERVER_VERSION = true ? "0.9.0" : createRequire(import.meta.url)("../../package.json").version;
41705
+ import { createRequire } from "module";
41706
+ var DEV_VERSION_PATTERN = /^0\.0\.0/;
41707
+ var SERVER_VERSION = resolveVersion();
41708
+ var IS_DEV_BUILD = checkDevBuild(SERVER_VERSION);
41709
+ function resolveVersion() {
41710
+ if (env.DORKOS_VERSION_OVERRIDE) return env.DORKOS_VERSION_OVERRIDE;
41711
+ if (true) return "0.10.0";
41712
+ return createRequire(import.meta.url)("../../package.json").version;
41713
+ }
41714
+ function checkDevBuild(version2) {
41715
+ if (env.DORKOS_VERSION_OVERRIDE) return false;
41716
+ if (true) return false;
41717
+ return DEV_VERSION_PATTERN.test(version2);
41718
+ }
41704
41719
 
41705
41720
  // ../../apps/server/src/routes/health.ts
41706
41721
  var router3 = Router3();
@@ -41838,8 +41853,9 @@ var UserConfigSchema = z5.object({
41838
41853
  auth: z5.string().nullable().default(null)
41839
41854
  }).default(() => ({ enabled: false, domain: null, authtoken: null, auth: null })),
41840
41855
  ui: z5.object({
41841
- theme: z5.enum(["light", "dark", "system"]).default("system")
41842
- }).default(() => ({ theme: "system" })),
41856
+ theme: z5.enum(["light", "dark", "system"]).default("system"),
41857
+ dismissedUpgradeVersions: z5.array(z5.string()).default(() => []).describe("Version strings the user has dismissed upgrade notifications for")
41858
+ }).default(() => ({ theme: "system", dismissedUpgradeVersions: [] })),
41843
41859
  logging: LoggingConfigSchema.default(() => ({ level: "info", maxLogSizeKb: 500, maxLogFiles: 14 })),
41844
41860
  relay: z5.object({
41845
41861
  enabled: z5.boolean().default(true),
@@ -42004,6 +42020,7 @@ var FETCH_TIMEOUT = 5e3;
42004
42020
  var cachedLatest = null;
42005
42021
  var lastChecked = 0;
42006
42022
  async function getLatestVersion() {
42023
+ if (IS_DEV_BUILD) return null;
42007
42024
  if (Date.now() - lastChecked < CACHE_TTL) return cachedLatest;
42008
42025
  try {
42009
42026
  const controller = new AbortController();
@@ -42077,6 +42094,8 @@ router5.get("/", async (_req, res) => {
42077
42094
  res.json({
42078
42095
  version: SERVER_VERSION,
42079
42096
  latestVersion,
42097
+ isDevMode: IS_DEV_BUILD,
42098
+ dismissedUpgradeVersions: configManager.get("ui")?.dismissedUpgradeVersions ?? [],
42080
42099
  port: env.DORKOS_PORT,
42081
42100
  uptime: process.uptime(),
42082
42101
  workingDirectory: process.cwd(),
@@ -42535,6 +42554,7 @@ var capabilities_default = router10;
42535
42554
 
42536
42555
  // ../../apps/server/src/routes/uploads.ts
42537
42556
  var import_multer2 = __toESM(require_multer(), 1);
42557
+ import path8 from "path";
42538
42558
  import { Router as Router11 } from "express";
42539
42559
 
42540
42560
  // ../../apps/server/src/services/core/upload-handler.ts
@@ -42629,6 +42649,33 @@ router11.post("/", async (req, res) => {
42629
42649
  throw err;
42630
42650
  }
42631
42651
  });
42652
+ router11.get("/:filename", async (req, res) => {
42653
+ try {
42654
+ const cwd = req.query.cwd;
42655
+ if (!cwd || typeof cwd !== "string") {
42656
+ return res.status(400).json({ error: "Missing required parameter: cwd" });
42657
+ }
42658
+ const validatedCwd = await validateBoundary(cwd);
42659
+ const filename = path8.basename(req.params.filename);
42660
+ const filePath = path8.join(uploadHandler.getUploadDir(validatedCwd), filename);
42661
+ const resolvedPath = path8.resolve(filePath);
42662
+ const uploadDir = path8.resolve(uploadHandler.getUploadDir(validatedCwd));
42663
+ if (!resolvedPath.startsWith(uploadDir + path8.sep) && resolvedPath !== uploadDir) {
42664
+ return res.status(403).json({ error: "Access denied" });
42665
+ }
42666
+ res.sendFile(resolvedPath, (err) => {
42667
+ if (err && !res.headersSent) {
42668
+ const status = err.code === "ENOENT" ? 404 : 500;
42669
+ res.status(status).json({ error: status === 404 ? "File not found" : "Internal error" });
42670
+ }
42671
+ });
42672
+ } catch (err) {
42673
+ if (err instanceof BoundaryError) {
42674
+ return res.status(403).json({ error: err.message, code: err.code });
42675
+ }
42676
+ throw err;
42677
+ }
42678
+ });
42632
42679
  var uploads_default = router11;
42633
42680
 
42634
42681
  // ../../apps/server/src/services/core/openapi-registry.ts
@@ -44108,7 +44155,7 @@ function requestLogger(req, res, next) {
44108
44155
  }
44109
44156
 
44110
44157
  // ../../apps/server/src/app.ts
44111
- var __dirname = path8.dirname(fileURLToPath2(import.meta.url));
44158
+ var __dirname = path9.dirname(fileURLToPath2(import.meta.url));
44112
44159
  function buildCorsOrigin() {
44113
44160
  const envOrigin = process.env.DORKOS_CORS_ORIGIN;
44114
44161
  if (envOrigin === "*") return "*";
@@ -44161,10 +44208,10 @@ function finalizeApp(app) {
44161
44208
  });
44162
44209
  app.use(errorHandler);
44163
44210
  if (env.NODE_ENV === "production") {
44164
- const distPath = env.CLIENT_DIST_PATH ?? path8.join(__dirname, "../../client/dist");
44211
+ const distPath = env.CLIENT_DIST_PATH ?? path9.join(__dirname, "../../client/dist");
44165
44212
  app.use(express.static(distPath));
44166
44213
  app.get("*", (_req, res) => {
44167
- res.sendFile(path8.join(distPath, "index.html"));
44214
+ res.sendFile(path9.join(distPath, "index.html"));
44168
44215
  });
44169
44216
  }
44170
44217
  }
@@ -44255,7 +44302,7 @@ var SessionLockManager = class {
44255
44302
 
44256
44303
  // ../../apps/server/src/services/runtimes/claude-code/transcript-reader.ts
44257
44304
  import fs7 from "fs/promises";
44258
- import path9 from "path";
44305
+ import path10 from "path";
44259
44306
  import os2 from "os";
44260
44307
 
44261
44308
  // ../../apps/server/src/services/runtimes/claude-code/transcript-parser.ts
@@ -44570,7 +44617,7 @@ var TranscriptReader = class {
44570
44617
  /** Resolve the SDK transcripts directory for a given vault root. */
44571
44618
  getTranscriptsDir(vaultRoot2) {
44572
44619
  const slug = this.getProjectSlug(vaultRoot2);
44573
- return path9.join(os2.homedir(), ".claude", "projects", slug);
44620
+ return path10.join(os2.homedir(), ".claude", "projects", slug);
44574
44621
  }
44575
44622
  /**
44576
44623
  * List all sessions by scanning SDK JSONL transcript files.
@@ -44588,7 +44635,7 @@ var TranscriptReader = class {
44588
44635
  const sessions = [];
44589
44636
  for (const file of files) {
44590
44637
  const sessionId = file.replace(".jsonl", "");
44591
- const filePath = path9.join(transcriptsDir, file);
44638
+ const filePath = path10.join(transcriptsDir, file);
44592
44639
  try {
44593
44640
  const fileStat = await fs7.stat(filePath);
44594
44641
  const cached = this.metaCache.get(sessionId);
@@ -44611,7 +44658,7 @@ var TranscriptReader = class {
44611
44658
  */
44612
44659
  async getSession(vaultRoot2, sessionId) {
44613
44660
  await validateBoundary(vaultRoot2);
44614
- const filePath = path9.join(this.getTranscriptsDir(vaultRoot2), `${sessionId}.jsonl`);
44661
+ const filePath = path10.join(this.getTranscriptsDir(vaultRoot2), `${sessionId}.jsonl`);
44615
44662
  try {
44616
44663
  const session = await this.extractSessionMeta(filePath, sessionId);
44617
44664
  const tailStatus = await this.readTailStatus(filePath);
@@ -44767,7 +44814,7 @@ var TranscriptReader = class {
44767
44814
  async readTranscript(vaultRoot2, sessionId) {
44768
44815
  await validateBoundary(vaultRoot2);
44769
44816
  const transcriptsDir = this.getTranscriptsDir(vaultRoot2);
44770
- const filePath = path9.join(transcriptsDir, `${sessionId}.jsonl`);
44817
+ const filePath = path10.join(transcriptsDir, `${sessionId}.jsonl`);
44771
44818
  let content;
44772
44819
  try {
44773
44820
  content = await fs7.readFile(filePath, "utf-8");
@@ -44793,7 +44840,7 @@ var TranscriptReader = class {
44793
44840
  /** Get an ETag for a session transcript (mtime + size) for HTTP caching. */
44794
44841
  async getTranscriptETag(vaultRoot2, sessionId) {
44795
44842
  await validateBoundary(vaultRoot2);
44796
- const filePath = path9.join(this.getTranscriptsDir(vaultRoot2), `${sessionId}.jsonl`);
44843
+ const filePath = path10.join(this.getTranscriptsDir(vaultRoot2), `${sessionId}.jsonl`);
44797
44844
  try {
44798
44845
  const stat5 = await fs7.stat(filePath);
44799
44846
  return `"${stat5.mtimeMs}-${stat5.size}"`;
@@ -44808,7 +44855,7 @@ var TranscriptReader = class {
44808
44855
  async readTasks(vaultRoot2, sessionId) {
44809
44856
  await validateBoundary(vaultRoot2);
44810
44857
  const transcriptsDir = this.getTranscriptsDir(vaultRoot2);
44811
- const filePath = path9.join(transcriptsDir, `${sessionId}.jsonl`);
44858
+ const filePath = path10.join(transcriptsDir, `${sessionId}.jsonl`);
44812
44859
  let content;
44813
44860
  try {
44814
44861
  content = await fs7.readFile(filePath, "utf-8");
@@ -44824,7 +44871,7 @@ var TranscriptReader = class {
44824
44871
  */
44825
44872
  async readFromOffset(vaultRoot2, sessionId, fromOffset) {
44826
44873
  await validateBoundary(vaultRoot2);
44827
- const filePath = path9.join(this.getTranscriptsDir(vaultRoot2), `${sessionId}.jsonl`);
44874
+ const filePath = path10.join(this.getTranscriptsDir(vaultRoot2), `${sessionId}.jsonl`);
44828
44875
  const stat5 = await fs7.stat(filePath);
44829
44876
  if (stat5.size <= fromOffset) {
44830
44877
  return { content: "", newOffset: fromOffset };
@@ -44920,7 +44967,7 @@ var ReaddirpStream = class extends Readable {
44920
44967
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
44921
44968
  const statMethod = opts.lstat ? lstat : stat;
44922
44969
  if (wantBigintFsStats) {
44923
- this._stat = (path29) => statMethod(path29, { bigint: true });
44970
+ this._stat = (path30) => statMethod(path30, { bigint: true });
44924
44971
  } else {
44925
44972
  this._stat = statMethod;
44926
44973
  }
@@ -44945,8 +44992,8 @@ var ReaddirpStream = class extends Readable {
44945
44992
  const par = this.parent;
44946
44993
  const fil = par && par.files;
44947
44994
  if (fil && fil.length > 0) {
44948
- const { path: path29, depth } = par;
44949
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path29));
44995
+ const { path: path30, depth } = par;
44996
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path30));
44950
44997
  const awaited = await Promise.all(slice);
44951
44998
  for (const entry of awaited) {
44952
44999
  if (!entry)
@@ -44986,20 +45033,20 @@ var ReaddirpStream = class extends Readable {
44986
45033
  this.reading = false;
44987
45034
  }
44988
45035
  }
44989
- async _exploreDir(path29, depth) {
45036
+ async _exploreDir(path30, depth) {
44990
45037
  let files;
44991
45038
  try {
44992
- files = await readdir(path29, this._rdOptions);
45039
+ files = await readdir(path30, this._rdOptions);
44993
45040
  } catch (error) {
44994
45041
  this._onError(error);
44995
45042
  }
44996
- return { files, depth, path: path29 };
45043
+ return { files, depth, path: path30 };
44997
45044
  }
44998
- async _formatEntry(dirent, path29) {
45045
+ async _formatEntry(dirent, path30) {
44999
45046
  let entry;
45000
45047
  const basename4 = this._isDirent ? dirent.name : dirent;
45001
45048
  try {
45002
- const fullPath = presolve(pjoin(path29, basename4));
45049
+ const fullPath = presolve(pjoin(path30, basename4));
45003
45050
  entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
45004
45051
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
45005
45052
  } catch (err) {
@@ -45399,16 +45446,16 @@ var delFromSet = (main, prop, item) => {
45399
45446
  };
45400
45447
  var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
45401
45448
  var FsWatchInstances = /* @__PURE__ */ new Map();
45402
- function createFsWatchInstance(path29, options, listener, errHandler, emitRaw) {
45449
+ function createFsWatchInstance(path30, options, listener, errHandler, emitRaw) {
45403
45450
  const handleEvent = (rawEvent, evPath) => {
45404
- listener(path29);
45405
- emitRaw(rawEvent, evPath, { watchedPath: path29 });
45406
- if (evPath && path29 !== evPath) {
45407
- fsWatchBroadcast(sysPath.resolve(path29, evPath), KEY_LISTENERS, sysPath.join(path29, evPath));
45451
+ listener(path30);
45452
+ emitRaw(rawEvent, evPath, { watchedPath: path30 });
45453
+ if (evPath && path30 !== evPath) {
45454
+ fsWatchBroadcast(sysPath.resolve(path30, evPath), KEY_LISTENERS, sysPath.join(path30, evPath));
45408
45455
  }
45409
45456
  };
45410
45457
  try {
45411
- return fs_watch(path29, {
45458
+ return fs_watch(path30, {
45412
45459
  persistent: options.persistent
45413
45460
  }, handleEvent);
45414
45461
  } catch (error) {
@@ -45424,12 +45471,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
45424
45471
  listener(val1, val2, val3);
45425
45472
  });
45426
45473
  };
45427
- var setFsWatchListener = (path29, fullPath, options, handlers) => {
45474
+ var setFsWatchListener = (path30, fullPath, options, handlers) => {
45428
45475
  const { listener, errHandler, rawEmitter } = handlers;
45429
45476
  let cont = FsWatchInstances.get(fullPath);
45430
45477
  let watcher;
45431
45478
  if (!options.persistent) {
45432
- watcher = createFsWatchInstance(path29, options, listener, errHandler, rawEmitter);
45479
+ watcher = createFsWatchInstance(path30, options, listener, errHandler, rawEmitter);
45433
45480
  if (!watcher)
45434
45481
  return;
45435
45482
  return watcher.close.bind(watcher);
@@ -45440,7 +45487,7 @@ var setFsWatchListener = (path29, fullPath, options, handlers) => {
45440
45487
  addAndConvert(cont, KEY_RAW, rawEmitter);
45441
45488
  } else {
45442
45489
  watcher = createFsWatchInstance(
45443
- path29,
45490
+ path30,
45444
45491
  options,
45445
45492
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
45446
45493
  errHandler,
@@ -45455,7 +45502,7 @@ var setFsWatchListener = (path29, fullPath, options, handlers) => {
45455
45502
  cont.watcherUnusable = true;
45456
45503
  if (isWindows2 && error.code === "EPERM") {
45457
45504
  try {
45458
- const fd = await open(path29, "r");
45505
+ const fd = await open(path30, "r");
45459
45506
  await fd.close();
45460
45507
  broadcastErr(error);
45461
45508
  } catch (err) {
@@ -45486,7 +45533,7 @@ var setFsWatchListener = (path29, fullPath, options, handlers) => {
45486
45533
  };
45487
45534
  };
45488
45535
  var FsWatchFileInstances = /* @__PURE__ */ new Map();
45489
- var setFsWatchFileListener = (path29, fullPath, options, handlers) => {
45536
+ var setFsWatchFileListener = (path30, fullPath, options, handlers) => {
45490
45537
  const { listener, rawEmitter } = handlers;
45491
45538
  let cont = FsWatchFileInstances.get(fullPath);
45492
45539
  const copts = cont && cont.options;
@@ -45508,7 +45555,7 @@ var setFsWatchFileListener = (path29, fullPath, options, handlers) => {
45508
45555
  });
45509
45556
  const currmtime = curr.mtimeMs;
45510
45557
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
45511
- foreach(cont.listeners, (listener2) => listener2(path29, curr));
45558
+ foreach(cont.listeners, (listener2) => listener2(path30, curr));
45512
45559
  }
45513
45560
  })
45514
45561
  };
@@ -45536,13 +45583,13 @@ var NodeFsHandler = class {
45536
45583
  * @param listener on fs change
45537
45584
  * @returns closer for the watcher instance
45538
45585
  */
45539
- _watchWithNodeFs(path29, listener) {
45586
+ _watchWithNodeFs(path30, listener) {
45540
45587
  const opts = this.fsw.options;
45541
- const directory = sysPath.dirname(path29);
45542
- const basename4 = sysPath.basename(path29);
45588
+ const directory = sysPath.dirname(path30);
45589
+ const basename4 = sysPath.basename(path30);
45543
45590
  const parent = this.fsw._getWatchedDir(directory);
45544
45591
  parent.add(basename4);
45545
- const absolutePath = sysPath.resolve(path29);
45592
+ const absolutePath = sysPath.resolve(path30);
45546
45593
  const options = {
45547
45594
  persistent: opts.persistent
45548
45595
  };
@@ -45552,12 +45599,12 @@ var NodeFsHandler = class {
45552
45599
  if (opts.usePolling) {
45553
45600
  const enableBin = opts.interval !== opts.binaryInterval;
45554
45601
  options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
45555
- closer = setFsWatchFileListener(path29, absolutePath, options, {
45602
+ closer = setFsWatchFileListener(path30, absolutePath, options, {
45556
45603
  listener,
45557
45604
  rawEmitter: this.fsw._emitRaw
45558
45605
  });
45559
45606
  } else {
45560
- closer = setFsWatchListener(path29, absolutePath, options, {
45607
+ closer = setFsWatchListener(path30, absolutePath, options, {
45561
45608
  listener,
45562
45609
  errHandler: this._boundHandleError,
45563
45610
  rawEmitter: this.fsw._emitRaw
@@ -45579,7 +45626,7 @@ var NodeFsHandler = class {
45579
45626
  let prevStats = stats;
45580
45627
  if (parent.has(basename4))
45581
45628
  return;
45582
- const listener = async (path29, newStats) => {
45629
+ const listener = async (path30, newStats) => {
45583
45630
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
45584
45631
  return;
45585
45632
  if (!newStats || newStats.mtimeMs === 0) {
@@ -45593,11 +45640,11 @@ var NodeFsHandler = class {
45593
45640
  this.fsw._emit(EV.CHANGE, file, newStats2);
45594
45641
  }
45595
45642
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
45596
- this.fsw._closeFile(path29);
45643
+ this.fsw._closeFile(path30);
45597
45644
  prevStats = newStats2;
45598
45645
  const closer2 = this._watchWithNodeFs(file, listener);
45599
45646
  if (closer2)
45600
- this.fsw._addPathCloser(path29, closer2);
45647
+ this.fsw._addPathCloser(path30, closer2);
45601
45648
  } else {
45602
45649
  prevStats = newStats2;
45603
45650
  }
@@ -45629,7 +45676,7 @@ var NodeFsHandler = class {
45629
45676
  * @param item basename of this item
45630
45677
  * @returns true if no more processing is needed for this entry.
45631
45678
  */
45632
- async _handleSymlink(entry, directory, path29, item) {
45679
+ async _handleSymlink(entry, directory, path30, item) {
45633
45680
  if (this.fsw.closed) {
45634
45681
  return;
45635
45682
  }
@@ -45639,7 +45686,7 @@ var NodeFsHandler = class {
45639
45686
  this.fsw._incrReadyCount();
45640
45687
  let linkPath;
45641
45688
  try {
45642
- linkPath = await fsrealpath(path29);
45689
+ linkPath = await fsrealpath(path30);
45643
45690
  } catch (e2) {
45644
45691
  this.fsw._emitReady();
45645
45692
  return true;
@@ -45649,12 +45696,12 @@ var NodeFsHandler = class {
45649
45696
  if (dir.has(item)) {
45650
45697
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
45651
45698
  this.fsw._symlinkPaths.set(full, linkPath);
45652
- this.fsw._emit(EV.CHANGE, path29, entry.stats);
45699
+ this.fsw._emit(EV.CHANGE, path30, entry.stats);
45653
45700
  }
45654
45701
  } else {
45655
45702
  dir.add(item);
45656
45703
  this.fsw._symlinkPaths.set(full, linkPath);
45657
- this.fsw._emit(EV.ADD, path29, entry.stats);
45704
+ this.fsw._emit(EV.ADD, path30, entry.stats);
45658
45705
  }
45659
45706
  this.fsw._emitReady();
45660
45707
  return true;
@@ -45683,9 +45730,9 @@ var NodeFsHandler = class {
45683
45730
  return;
45684
45731
  }
45685
45732
  const item = entry.path;
45686
- let path29 = sysPath.join(directory, item);
45733
+ let path30 = sysPath.join(directory, item);
45687
45734
  current.add(item);
45688
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path29, item)) {
45735
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path30, item)) {
45689
45736
  return;
45690
45737
  }
45691
45738
  if (this.fsw.closed) {
@@ -45694,8 +45741,8 @@ var NodeFsHandler = class {
45694
45741
  }
45695
45742
  if (item === target || !target && !previous.has(item)) {
45696
45743
  this.fsw._incrReadyCount();
45697
- path29 = sysPath.join(dir, sysPath.relative(dir, path29));
45698
- this._addToNodeFs(path29, initialAdd, wh, depth + 1);
45744
+ path30 = sysPath.join(dir, sysPath.relative(dir, path30));
45745
+ this._addToNodeFs(path30, initialAdd, wh, depth + 1);
45699
45746
  }
45700
45747
  }).on(EV.ERROR, this._boundHandleError);
45701
45748
  return new Promise((resolve4, reject) => {
@@ -45764,13 +45811,13 @@ var NodeFsHandler = class {
45764
45811
  * @param depth Child path actually targeted for watch
45765
45812
  * @param target Child path actually targeted for watch
45766
45813
  */
45767
- async _addToNodeFs(path29, initialAdd, priorWh, depth, target) {
45814
+ async _addToNodeFs(path30, initialAdd, priorWh, depth, target) {
45768
45815
  const ready = this.fsw._emitReady;
45769
- if (this.fsw._isIgnored(path29) || this.fsw.closed) {
45816
+ if (this.fsw._isIgnored(path30) || this.fsw.closed) {
45770
45817
  ready();
45771
45818
  return false;
45772
45819
  }
45773
- const wh = this.fsw._getWatchHelpers(path29);
45820
+ const wh = this.fsw._getWatchHelpers(path30);
45774
45821
  if (priorWh) {
45775
45822
  wh.filterPath = (entry) => priorWh.filterPath(entry);
45776
45823
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -45786,8 +45833,8 @@ var NodeFsHandler = class {
45786
45833
  const follow = this.fsw.options.followSymlinks;
45787
45834
  let closer;
45788
45835
  if (stats.isDirectory()) {
45789
- const absPath = sysPath.resolve(path29);
45790
- const targetPath = follow ? await fsrealpath(path29) : path29;
45836
+ const absPath = sysPath.resolve(path30);
45837
+ const targetPath = follow ? await fsrealpath(path30) : path30;
45791
45838
  if (this.fsw.closed)
45792
45839
  return;
45793
45840
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -45797,29 +45844,29 @@ var NodeFsHandler = class {
45797
45844
  this.fsw._symlinkPaths.set(absPath, targetPath);
45798
45845
  }
45799
45846
  } else if (stats.isSymbolicLink()) {
45800
- const targetPath = follow ? await fsrealpath(path29) : path29;
45847
+ const targetPath = follow ? await fsrealpath(path30) : path30;
45801
45848
  if (this.fsw.closed)
45802
45849
  return;
45803
45850
  const parent = sysPath.dirname(wh.watchPath);
45804
45851
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
45805
45852
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
45806
- closer = await this._handleDir(parent, stats, initialAdd, depth, path29, wh, targetPath);
45853
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path30, wh, targetPath);
45807
45854
  if (this.fsw.closed)
45808
45855
  return;
45809
45856
  if (targetPath !== void 0) {
45810
- this.fsw._symlinkPaths.set(sysPath.resolve(path29), targetPath);
45857
+ this.fsw._symlinkPaths.set(sysPath.resolve(path30), targetPath);
45811
45858
  }
45812
45859
  } else {
45813
45860
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
45814
45861
  }
45815
45862
  ready();
45816
45863
  if (closer)
45817
- this.fsw._addPathCloser(path29, closer);
45864
+ this.fsw._addPathCloser(path30, closer);
45818
45865
  return false;
45819
45866
  } catch (error) {
45820
45867
  if (this.fsw._handleError(error)) {
45821
45868
  ready();
45822
- return path29;
45869
+ return path30;
45823
45870
  }
45824
45871
  }
45825
45872
  }
@@ -45862,26 +45909,26 @@ function createPattern(matcher) {
45862
45909
  }
45863
45910
  return () => false;
45864
45911
  }
45865
- function normalizePath(path29) {
45866
- if (typeof path29 !== "string")
45912
+ function normalizePath(path30) {
45913
+ if (typeof path30 !== "string")
45867
45914
  throw new Error("string expected");
45868
- path29 = sysPath2.normalize(path29);
45869
- path29 = path29.replace(/\\/g, "/");
45915
+ path30 = sysPath2.normalize(path30);
45916
+ path30 = path30.replace(/\\/g, "/");
45870
45917
  let prepend = false;
45871
- if (path29.startsWith("//"))
45918
+ if (path30.startsWith("//"))
45872
45919
  prepend = true;
45873
45920
  const DOUBLE_SLASH_RE2 = /\/\//;
45874
- while (path29.match(DOUBLE_SLASH_RE2))
45875
- path29 = path29.replace(DOUBLE_SLASH_RE2, "/");
45921
+ while (path30.match(DOUBLE_SLASH_RE2))
45922
+ path30 = path30.replace(DOUBLE_SLASH_RE2, "/");
45876
45923
  if (prepend)
45877
- path29 = "/" + path29;
45878
- return path29;
45924
+ path30 = "/" + path30;
45925
+ return path30;
45879
45926
  }
45880
45927
  function matchPatterns(patterns, testString, stats) {
45881
- const path29 = normalizePath(testString);
45928
+ const path30 = normalizePath(testString);
45882
45929
  for (let index = 0; index < patterns.length; index++) {
45883
45930
  const pattern = patterns[index];
45884
- if (pattern(path29, stats)) {
45931
+ if (pattern(path30, stats)) {
45885
45932
  return true;
45886
45933
  }
45887
45934
  }
@@ -45921,19 +45968,19 @@ var toUnix = (string2) => {
45921
45968
  }
45922
45969
  return str;
45923
45970
  };
45924
- var normalizePathToUnix = (path29) => toUnix(sysPath2.normalize(toUnix(path29)));
45925
- var normalizeIgnored = (cwd = "") => (path29) => {
45926
- if (typeof path29 === "string") {
45927
- return normalizePathToUnix(sysPath2.isAbsolute(path29) ? path29 : sysPath2.join(cwd, path29));
45971
+ var normalizePathToUnix = (path30) => toUnix(sysPath2.normalize(toUnix(path30)));
45972
+ var normalizeIgnored = (cwd = "") => (path30) => {
45973
+ if (typeof path30 === "string") {
45974
+ return normalizePathToUnix(sysPath2.isAbsolute(path30) ? path30 : sysPath2.join(cwd, path30));
45928
45975
  } else {
45929
- return path29;
45976
+ return path30;
45930
45977
  }
45931
45978
  };
45932
- var getAbsolutePath = (path29, cwd) => {
45933
- if (sysPath2.isAbsolute(path29)) {
45934
- return path29;
45979
+ var getAbsolutePath = (path30, cwd) => {
45980
+ if (sysPath2.isAbsolute(path30)) {
45981
+ return path30;
45935
45982
  }
45936
- return sysPath2.join(cwd, path29);
45983
+ return sysPath2.join(cwd, path30);
45937
45984
  };
45938
45985
  var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
45939
45986
  var DirEntry = class {
@@ -45988,10 +46035,10 @@ var DirEntry = class {
45988
46035
  var STAT_METHOD_F = "stat";
45989
46036
  var STAT_METHOD_L = "lstat";
45990
46037
  var WatchHelper = class {
45991
- constructor(path29, follow, fsw) {
46038
+ constructor(path30, follow, fsw) {
45992
46039
  this.fsw = fsw;
45993
- const watchPath = path29;
45994
- this.path = path29 = path29.replace(REPLACER_RE, "");
46040
+ const watchPath = path30;
46041
+ this.path = path30 = path30.replace(REPLACER_RE, "");
45995
46042
  this.watchPath = watchPath;
45996
46043
  this.fullWatchPath = sysPath2.resolve(watchPath);
45997
46044
  this.dirParts = [];
@@ -46113,20 +46160,20 @@ var FSWatcher = class extends EventEmitter2 {
46113
46160
  this._closePromise = void 0;
46114
46161
  let paths = unifyPaths(paths_);
46115
46162
  if (cwd) {
46116
- paths = paths.map((path29) => {
46117
- const absPath = getAbsolutePath(path29, cwd);
46163
+ paths = paths.map((path30) => {
46164
+ const absPath = getAbsolutePath(path30, cwd);
46118
46165
  return absPath;
46119
46166
  });
46120
46167
  }
46121
- paths.forEach((path29) => {
46122
- this._removeIgnoredPath(path29);
46168
+ paths.forEach((path30) => {
46169
+ this._removeIgnoredPath(path30);
46123
46170
  });
46124
46171
  this._userIgnored = void 0;
46125
46172
  if (!this._readyCount)
46126
46173
  this._readyCount = 0;
46127
46174
  this._readyCount += paths.length;
46128
- Promise.all(paths.map(async (path29) => {
46129
- const res = await this._nodeFsHandler._addToNodeFs(path29, !_internal, void 0, 0, _origAdd);
46175
+ Promise.all(paths.map(async (path30) => {
46176
+ const res = await this._nodeFsHandler._addToNodeFs(path30, !_internal, void 0, 0, _origAdd);
46130
46177
  if (res)
46131
46178
  this._emitReady();
46132
46179
  return res;
@@ -46148,17 +46195,17 @@ var FSWatcher = class extends EventEmitter2 {
46148
46195
  return this;
46149
46196
  const paths = unifyPaths(paths_);
46150
46197
  const { cwd } = this.options;
46151
- paths.forEach((path29) => {
46152
- if (!sysPath2.isAbsolute(path29) && !this._closers.has(path29)) {
46198
+ paths.forEach((path30) => {
46199
+ if (!sysPath2.isAbsolute(path30) && !this._closers.has(path30)) {
46153
46200
  if (cwd)
46154
- path29 = sysPath2.join(cwd, path29);
46155
- path29 = sysPath2.resolve(path29);
46201
+ path30 = sysPath2.join(cwd, path30);
46202
+ path30 = sysPath2.resolve(path30);
46156
46203
  }
46157
- this._closePath(path29);
46158
- this._addIgnoredPath(path29);
46159
- if (this._watched.has(path29)) {
46204
+ this._closePath(path30);
46205
+ this._addIgnoredPath(path30);
46206
+ if (this._watched.has(path30)) {
46160
46207
  this._addIgnoredPath({
46161
- path: path29,
46208
+ path: path30,
46162
46209
  recursive: true
46163
46210
  });
46164
46211
  }
@@ -46222,38 +46269,38 @@ var FSWatcher = class extends EventEmitter2 {
46222
46269
  * @param stats arguments to be passed with event
46223
46270
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
46224
46271
  */
46225
- async _emit(event, path29, stats) {
46272
+ async _emit(event, path30, stats) {
46226
46273
  if (this.closed)
46227
46274
  return;
46228
46275
  const opts = this.options;
46229
46276
  if (isWindows2)
46230
- path29 = sysPath2.normalize(path29);
46277
+ path30 = sysPath2.normalize(path30);
46231
46278
  if (opts.cwd)
46232
- path29 = sysPath2.relative(opts.cwd, path29);
46233
- const args = [path29];
46279
+ path30 = sysPath2.relative(opts.cwd, path30);
46280
+ const args = [path30];
46234
46281
  if (stats != null)
46235
46282
  args.push(stats);
46236
46283
  const awf = opts.awaitWriteFinish;
46237
46284
  let pw;
46238
- if (awf && (pw = this._pendingWrites.get(path29))) {
46285
+ if (awf && (pw = this._pendingWrites.get(path30))) {
46239
46286
  pw.lastChange = /* @__PURE__ */ new Date();
46240
46287
  return this;
46241
46288
  }
46242
46289
  if (opts.atomic) {
46243
46290
  if (event === EVENTS.UNLINK) {
46244
- this._pendingUnlinks.set(path29, [event, ...args]);
46291
+ this._pendingUnlinks.set(path30, [event, ...args]);
46245
46292
  setTimeout(() => {
46246
- this._pendingUnlinks.forEach((entry, path30) => {
46293
+ this._pendingUnlinks.forEach((entry, path31) => {
46247
46294
  this.emit(...entry);
46248
46295
  this.emit(EVENTS.ALL, ...entry);
46249
- this._pendingUnlinks.delete(path30);
46296
+ this._pendingUnlinks.delete(path31);
46250
46297
  });
46251
46298
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
46252
46299
  return this;
46253
46300
  }
46254
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path29)) {
46301
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path30)) {
46255
46302
  event = EVENTS.CHANGE;
46256
- this._pendingUnlinks.delete(path29);
46303
+ this._pendingUnlinks.delete(path30);
46257
46304
  }
46258
46305
  }
46259
46306
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -46271,16 +46318,16 @@ var FSWatcher = class extends EventEmitter2 {
46271
46318
  this.emitWithAll(event, args);
46272
46319
  }
46273
46320
  };
46274
- this._awaitWriteFinish(path29, awf.stabilityThreshold, event, awfEmit);
46321
+ this._awaitWriteFinish(path30, awf.stabilityThreshold, event, awfEmit);
46275
46322
  return this;
46276
46323
  }
46277
46324
  if (event === EVENTS.CHANGE) {
46278
- const isThrottled = !this._throttle(EVENTS.CHANGE, path29, 50);
46325
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path30, 50);
46279
46326
  if (isThrottled)
46280
46327
  return this;
46281
46328
  }
46282
46329
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
46283
- const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path29) : path29;
46330
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path30) : path30;
46284
46331
  let stats2;
46285
46332
  try {
46286
46333
  stats2 = await stat3(fullPath);
@@ -46311,23 +46358,23 @@ var FSWatcher = class extends EventEmitter2 {
46311
46358
  * @param timeout duration of time to suppress duplicate actions
46312
46359
  * @returns tracking object or false if action should be suppressed
46313
46360
  */
46314
- _throttle(actionType, path29, timeout) {
46361
+ _throttle(actionType, path30, timeout) {
46315
46362
  if (!this._throttled.has(actionType)) {
46316
46363
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
46317
46364
  }
46318
46365
  const action = this._throttled.get(actionType);
46319
46366
  if (!action)
46320
46367
  throw new Error("invalid throttle");
46321
- const actionPath = action.get(path29);
46368
+ const actionPath = action.get(path30);
46322
46369
  if (actionPath) {
46323
46370
  actionPath.count++;
46324
46371
  return false;
46325
46372
  }
46326
46373
  let timeoutObject;
46327
46374
  const clear = () => {
46328
- const item = action.get(path29);
46375
+ const item = action.get(path30);
46329
46376
  const count2 = item ? item.count : 0;
46330
- action.delete(path29);
46377
+ action.delete(path30);
46331
46378
  clearTimeout(timeoutObject);
46332
46379
  if (item)
46333
46380
  clearTimeout(item.timeoutObject);
@@ -46335,7 +46382,7 @@ var FSWatcher = class extends EventEmitter2 {
46335
46382
  };
46336
46383
  timeoutObject = setTimeout(clear, timeout);
46337
46384
  const thr = { timeoutObject, clear, count: 0 };
46338
- action.set(path29, thr);
46385
+ action.set(path30, thr);
46339
46386
  return thr;
46340
46387
  }
46341
46388
  _incrReadyCount() {
@@ -46349,44 +46396,44 @@ var FSWatcher = class extends EventEmitter2 {
46349
46396
  * @param event
46350
46397
  * @param awfEmit Callback to be called when ready for event to be emitted.
46351
46398
  */
46352
- _awaitWriteFinish(path29, threshold, event, awfEmit) {
46399
+ _awaitWriteFinish(path30, threshold, event, awfEmit) {
46353
46400
  const awf = this.options.awaitWriteFinish;
46354
46401
  if (typeof awf !== "object")
46355
46402
  return;
46356
46403
  const pollInterval = awf.pollInterval;
46357
46404
  let timeoutHandler;
46358
- let fullPath = path29;
46359
- if (this.options.cwd && !sysPath2.isAbsolute(path29)) {
46360
- fullPath = sysPath2.join(this.options.cwd, path29);
46405
+ let fullPath = path30;
46406
+ if (this.options.cwd && !sysPath2.isAbsolute(path30)) {
46407
+ fullPath = sysPath2.join(this.options.cwd, path30);
46361
46408
  }
46362
46409
  const now = /* @__PURE__ */ new Date();
46363
46410
  const writes = this._pendingWrites;
46364
46411
  function awaitWriteFinishFn(prevStat) {
46365
46412
  statcb(fullPath, (err, curStat) => {
46366
- if (err || !writes.has(path29)) {
46413
+ if (err || !writes.has(path30)) {
46367
46414
  if (err && err.code !== "ENOENT")
46368
46415
  awfEmit(err);
46369
46416
  return;
46370
46417
  }
46371
46418
  const now2 = Number(/* @__PURE__ */ new Date());
46372
46419
  if (prevStat && curStat.size !== prevStat.size) {
46373
- writes.get(path29).lastChange = now2;
46420
+ writes.get(path30).lastChange = now2;
46374
46421
  }
46375
- const pw = writes.get(path29);
46422
+ const pw = writes.get(path30);
46376
46423
  const df = now2 - pw.lastChange;
46377
46424
  if (df >= threshold) {
46378
- writes.delete(path29);
46425
+ writes.delete(path30);
46379
46426
  awfEmit(void 0, curStat);
46380
46427
  } else {
46381
46428
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
46382
46429
  }
46383
46430
  });
46384
46431
  }
46385
- if (!writes.has(path29)) {
46386
- writes.set(path29, {
46432
+ if (!writes.has(path30)) {
46433
+ writes.set(path30, {
46387
46434
  lastChange: now,
46388
46435
  cancelWait: () => {
46389
- writes.delete(path29);
46436
+ writes.delete(path30);
46390
46437
  clearTimeout(timeoutHandler);
46391
46438
  return event;
46392
46439
  }
@@ -46397,8 +46444,8 @@ var FSWatcher = class extends EventEmitter2 {
46397
46444
  /**
46398
46445
  * Determines whether user has asked to ignore this path.
46399
46446
  */
46400
- _isIgnored(path29, stats) {
46401
- if (this.options.atomic && DOT_RE.test(path29))
46447
+ _isIgnored(path30, stats) {
46448
+ if (this.options.atomic && DOT_RE.test(path30))
46402
46449
  return true;
46403
46450
  if (!this._userIgnored) {
46404
46451
  const { cwd } = this.options;
@@ -46408,17 +46455,17 @@ var FSWatcher = class extends EventEmitter2 {
46408
46455
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
46409
46456
  this._userIgnored = anymatch(list, void 0);
46410
46457
  }
46411
- return this._userIgnored(path29, stats);
46458
+ return this._userIgnored(path30, stats);
46412
46459
  }
46413
- _isntIgnored(path29, stat5) {
46414
- return !this._isIgnored(path29, stat5);
46460
+ _isntIgnored(path30, stat5) {
46461
+ return !this._isIgnored(path30, stat5);
46415
46462
  }
46416
46463
  /**
46417
46464
  * Provides a set of common helpers and properties relating to symlink handling.
46418
46465
  * @param path file or directory pattern being watched
46419
46466
  */
46420
- _getWatchHelpers(path29) {
46421
- return new WatchHelper(path29, this.options.followSymlinks, this);
46467
+ _getWatchHelpers(path30) {
46468
+ return new WatchHelper(path30, this.options.followSymlinks, this);
46422
46469
  }
46423
46470
  // Directory helpers
46424
46471
  // -----------------
@@ -46450,63 +46497,63 @@ var FSWatcher = class extends EventEmitter2 {
46450
46497
  * @param item base path of item/directory
46451
46498
  */
46452
46499
  _remove(directory, item, isDirectory) {
46453
- const path29 = sysPath2.join(directory, item);
46454
- const fullPath = sysPath2.resolve(path29);
46455
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path29) || this._watched.has(fullPath);
46456
- if (!this._throttle("remove", path29, 100))
46500
+ const path30 = sysPath2.join(directory, item);
46501
+ const fullPath = sysPath2.resolve(path30);
46502
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path30) || this._watched.has(fullPath);
46503
+ if (!this._throttle("remove", path30, 100))
46457
46504
  return;
46458
46505
  if (!isDirectory && this._watched.size === 1) {
46459
46506
  this.add(directory, item, true);
46460
46507
  }
46461
- const wp = this._getWatchedDir(path29);
46508
+ const wp = this._getWatchedDir(path30);
46462
46509
  const nestedDirectoryChildren = wp.getChildren();
46463
- nestedDirectoryChildren.forEach((nested) => this._remove(path29, nested));
46510
+ nestedDirectoryChildren.forEach((nested) => this._remove(path30, nested));
46464
46511
  const parent = this._getWatchedDir(directory);
46465
46512
  const wasTracked = parent.has(item);
46466
46513
  parent.remove(item);
46467
46514
  if (this._symlinkPaths.has(fullPath)) {
46468
46515
  this._symlinkPaths.delete(fullPath);
46469
46516
  }
46470
- let relPath = path29;
46517
+ let relPath = path30;
46471
46518
  if (this.options.cwd)
46472
- relPath = sysPath2.relative(this.options.cwd, path29);
46519
+ relPath = sysPath2.relative(this.options.cwd, path30);
46473
46520
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
46474
46521
  const event = this._pendingWrites.get(relPath).cancelWait();
46475
46522
  if (event === EVENTS.ADD)
46476
46523
  return;
46477
46524
  }
46478
- this._watched.delete(path29);
46525
+ this._watched.delete(path30);
46479
46526
  this._watched.delete(fullPath);
46480
46527
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
46481
- if (wasTracked && !this._isIgnored(path29))
46482
- this._emit(eventName, path29);
46483
- this._closePath(path29);
46528
+ if (wasTracked && !this._isIgnored(path30))
46529
+ this._emit(eventName, path30);
46530
+ this._closePath(path30);
46484
46531
  }
46485
46532
  /**
46486
46533
  * Closes all watchers for a path
46487
46534
  */
46488
- _closePath(path29) {
46489
- this._closeFile(path29);
46490
- const dir = sysPath2.dirname(path29);
46491
- this._getWatchedDir(dir).remove(sysPath2.basename(path29));
46535
+ _closePath(path30) {
46536
+ this._closeFile(path30);
46537
+ const dir = sysPath2.dirname(path30);
46538
+ this._getWatchedDir(dir).remove(sysPath2.basename(path30));
46492
46539
  }
46493
46540
  /**
46494
46541
  * Closes only file-specific watchers
46495
46542
  */
46496
- _closeFile(path29) {
46497
- const closers = this._closers.get(path29);
46543
+ _closeFile(path30) {
46544
+ const closers = this._closers.get(path30);
46498
46545
  if (!closers)
46499
46546
  return;
46500
46547
  closers.forEach((closer) => closer());
46501
- this._closers.delete(path29);
46548
+ this._closers.delete(path30);
46502
46549
  }
46503
- _addPathCloser(path29, closer) {
46550
+ _addPathCloser(path30, closer) {
46504
46551
  if (!closer)
46505
46552
  return;
46506
- let list = this._closers.get(path29);
46553
+ let list = this._closers.get(path30);
46507
46554
  if (!list) {
46508
46555
  list = [];
46509
- this._closers.set(path29, list);
46556
+ this._closers.set(path30, list);
46510
46557
  }
46511
46558
  list.push(closer);
46512
46559
  }
@@ -46971,7 +47018,7 @@ data: ${JSON.stringify(event)}
46971
47018
 
46972
47019
  // ../../apps/server/src/services/runtimes/claude-code/command-registry.ts
46973
47020
  import fs8 from "fs/promises";
46974
- import path10 from "path";
47021
+ import path11 from "path";
46975
47022
  import matter from "gray-matter";
46976
47023
  function parseFrontmatterFallback(content) {
46977
47024
  const match = content.match(/^---\n([\s\S]*?)\n---/);
@@ -46994,7 +47041,7 @@ var CommandRegistryService = class _CommandRegistryService {
46994
47041
  commandsDir;
46995
47042
  /** @param vaultRoot - Must be pre-validated against directory boundary by caller */
46996
47043
  constructor(vaultRoot2) {
46997
- this.commandsDir = path10.join(vaultRoot2, ".claude", "commands");
47044
+ this.commandsDir = path11.join(vaultRoot2, ".claude", "commands");
46998
47045
  }
46999
47046
  async getCommands(forceRefresh = false) {
47000
47047
  const cacheExpired = Date.now() - this.cacheTime > _CommandRegistryService.CACHE_TTL_MS;
@@ -47006,11 +47053,11 @@ var CommandRegistryService = class _CommandRegistryService {
47006
47053
  });
47007
47054
  for (const entry of entries) {
47008
47055
  if (!entry.isDirectory()) continue;
47009
- const nsPath = path10.join(this.commandsDir, entry.name);
47056
+ const nsPath = path11.join(this.commandsDir, entry.name);
47010
47057
  const files = await fs8.readdir(nsPath);
47011
47058
  for (const file of files) {
47012
47059
  if (!file.endsWith(".md")) continue;
47013
- const filePath = path10.join(nsPath, file);
47060
+ const filePath = path11.join(nsPath, file);
47014
47061
  try {
47015
47062
  const content = await fs8.readFile(filePath, "utf-8");
47016
47063
  let frontmatter;
@@ -47028,7 +47075,7 @@ var CommandRegistryService = class _CommandRegistryService {
47028
47075
  description: frontmatter.description || "",
47029
47076
  argumentHint: frontmatter["argument-hint"],
47030
47077
  allowedTools: typeof allowedToolsRaw === "string" ? allowedToolsRaw.split(",").map((t2) => t2.trim()) : allowedToolsRaw,
47031
- filePath: path10.relative(process.cwd(), filePath)
47078
+ filePath: path11.relative(process.cwd(), filePath)
47032
47079
  });
47033
47080
  } catch (fileErr) {
47034
47081
  logger.warn(
@@ -47351,12 +47398,12 @@ import os3 from "node:os";
47351
47398
 
47352
47399
  // ../shared/dist/manifest.js
47353
47400
  import fs9 from "fs/promises";
47354
- import path11 from "path";
47401
+ import path12 from "path";
47355
47402
  import { randomUUID as randomUUID2 } from "crypto";
47356
47403
  var MANIFEST_DIR = ".dork";
47357
47404
  var MANIFEST_FILE = "agent.json";
47358
47405
  async function readManifest(projectPath) {
47359
- const manifestPath = path11.join(projectPath, MANIFEST_DIR, MANIFEST_FILE);
47406
+ const manifestPath = path12.join(projectPath, MANIFEST_DIR, MANIFEST_FILE);
47360
47407
  try {
47361
47408
  const content = await fs9.readFile(manifestPath, "utf-8");
47362
47409
  const parsed = JSON.parse(content);
@@ -47367,17 +47414,17 @@ async function readManifest(projectPath) {
47367
47414
  }
47368
47415
  }
47369
47416
  async function writeManifest(projectPath, manifest) {
47370
- const dorkDir = path11.join(projectPath, MANIFEST_DIR);
47417
+ const dorkDir = path12.join(projectPath, MANIFEST_DIR);
47371
47418
  await fs9.mkdir(dorkDir, { recursive: true });
47372
- const manifestPath = path11.join(dorkDir, MANIFEST_FILE);
47373
- const tempPath = path11.join(dorkDir, `.agent-${randomUUID2()}.tmp`);
47419
+ const manifestPath = path12.join(dorkDir, MANIFEST_FILE);
47420
+ const tempPath = path12.join(dorkDir, `.agent-${randomUUID2()}.tmp`);
47374
47421
  const content = JSON.stringify(manifest, null, 2) + "\n";
47375
47422
  await fs9.writeFile(tempPath, content, "utf-8");
47376
47423
  await fs9.rename(tempPath, manifestPath);
47377
47424
  }
47378
47425
  async function removeManifest(projectPath) {
47379
47426
  try {
47380
- await fs9.unlink(path11.join(projectPath, MANIFEST_DIR, MANIFEST_FILE));
47427
+ await fs9.unlink(path12.join(projectPath, MANIFEST_DIR, MANIFEST_FILE));
47381
47428
  } catch {
47382
47429
  }
47383
47430
  }
@@ -47566,7 +47613,7 @@ async function buildEnvBlock(cwd) {
47566
47613
  const lines = [
47567
47614
  `Working directory: ${cwd}`,
47568
47615
  `Product: DorkOS`,
47569
- `Version: ${env.DORKOS_VERSION ?? "development"}`,
47616
+ `Version: ${SERVER_VERSION}`,
47570
47617
  `Port: ${env.DORKOS_PORT}`,
47571
47618
  `Platform: ${os3.platform()}`,
47572
47619
  `OS Version: ${os3.release()}`,
@@ -48276,7 +48323,7 @@ async function handleGetServerInfo(args) {
48276
48323
  const info = {
48277
48324
  product: "DorkOS",
48278
48325
  port: env.DORKOS_PORT,
48279
- version: env.DORKOS_VERSION ?? "development"
48326
+ version: SERVER_VERSION
48280
48327
  };
48281
48328
  if (args.include_uptime) {
48282
48329
  info.uptime_seconds = Math.floor(process.uptime());
@@ -50620,7 +50667,7 @@ var QueryPromise = class {
50620
50667
  function mapResultRow(columns, row, joinsNotNullableMap) {
50621
50668
  const nullifyMap = {};
50622
50669
  const result2 = columns.reduce(
50623
- (result22, { path: path29, field }, columnIndex) => {
50670
+ (result22, { path: path30, field }, columnIndex) => {
50624
50671
  let decoder;
50625
50672
  if (is(field, Column)) {
50626
50673
  decoder = field;
@@ -50630,8 +50677,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
50630
50677
  decoder = field.sql.decoder;
50631
50678
  }
50632
50679
  let node = result22;
50633
- for (const [pathChunkIndex, pathChunk] of path29.entries()) {
50634
- if (pathChunkIndex < path29.length - 1) {
50680
+ for (const [pathChunkIndex, pathChunk] of path30.entries()) {
50681
+ if (pathChunkIndex < path30.length - 1) {
50635
50682
  if (!(pathChunk in node)) {
50636
50683
  node[pathChunk] = {};
50637
50684
  }
@@ -50639,8 +50686,8 @@ function mapResultRow(columns, row, joinsNotNullableMap) {
50639
50686
  } else {
50640
50687
  const rawValue = row[columnIndex];
50641
50688
  const value = node[pathChunk] = rawValue === null ? null : decoder.mapFromDriverValue(rawValue);
50642
- if (joinsNotNullableMap && is(field, Column) && path29.length === 2) {
50643
- const objectName = path29[0];
50689
+ if (joinsNotNullableMap && is(field, Column) && path30.length === 2) {
50690
+ const objectName = path30[0];
50644
50691
  if (!(objectName in nullifyMap)) {
50645
50692
  nullifyMap[objectName] = value === null ? getTableName(field.table) : false;
50646
50693
  } else if (typeof nullifyMap[objectName] === "string" && nullifyMap[objectName] !== getTableName(field.table)) {
@@ -54502,9 +54549,9 @@ var rateLimitBuckets = sqliteTable(
54502
54549
  );
54503
54550
 
54504
54551
  // ../db/src/index.ts
54505
- import path12 from "path";
54552
+ import path13 from "path";
54506
54553
  import { fileURLToPath as fileURLToPath3 } from "url";
54507
- var __dirname2 = path12.dirname(fileURLToPath3(import.meta.url));
54554
+ var __dirname2 = path13.dirname(fileURLToPath3(import.meta.url));
54508
54555
  function createDb(dbPath) {
54509
54556
  const sqlite = new Database(dbPath);
54510
54557
  sqlite.pragma("journal_mode = WAL");
@@ -54514,7 +54561,7 @@ function createDb(dbPath) {
54514
54561
  return drizzle(sqlite, { schema: schema_exports });
54515
54562
  }
54516
54563
  function runMigrations(db) {
54517
- const migrationsFolder = path12.join(__dirname2, "../drizzle");
54564
+ const migrationsFolder = path13.join(__dirname2, "../drizzle");
54518
54565
  migrate(db, { migrationsFolder });
54519
54566
  }
54520
54567
 
@@ -55954,7 +56001,7 @@ import { Router as Router12 } from "express";
55954
56001
 
55955
56002
  // ../../apps/server/src/services/pulse/pulse-presets.ts
55956
56003
  import { readFile, writeFile, mkdir } from "node:fs/promises";
55957
- import path13 from "node:path";
56004
+ import path14 from "node:path";
55958
56005
  var DEFAULT_PRESETS = [
55959
56006
  {
55960
56007
  id: "health-check",
@@ -55994,7 +56041,7 @@ var DEFAULT_PRESETS = [
55994
56041
  }
55995
56042
  ];
55996
56043
  function resolvePresetsPath(dorkHome) {
55997
- return path13.join(dorkHome, "pulse", "presets.json");
56044
+ return path14.join(dorkHome, "pulse", "presets.json");
55998
56045
  }
55999
56046
  async function loadPresets(dorkHome) {
56000
56047
  const presetsPath = resolvePresetsPath(dorkHome);
@@ -56129,7 +56176,7 @@ function createPulseRouter(store, scheduler, meshCore2) {
56129
56176
  }
56130
56177
 
56131
56178
  // ../relay/dist/relay-core.js
56132
- import * as path18 from "node:path";
56179
+ import * as path19 from "node:path";
56133
56180
  import * as os4 from "node:os";
56134
56181
  import fs14 from "node:fs";
56135
56182
 
@@ -56649,7 +56696,7 @@ var noopHandler = () => {
56649
56696
 
56650
56697
  // ../relay/dist/maildir-store.js
56651
56698
  import * as fs11 from "node:fs/promises";
56652
- import * as path14 from "node:path";
56699
+ import * as path15 from "node:path";
56653
56700
  import { constants } from "node:fs";
56654
56701
  var DIR_MODE = 448;
56655
56702
  var FILE_MODE = 384;
@@ -56673,7 +56720,7 @@ var MaildirStore = class {
56673
56720
  async ensureMaildir(endpointHash) {
56674
56721
  const base = this.endpointDir(endpointHash);
56675
56722
  for (const subdir of MAILDIR_SUBDIRS) {
56676
- await fs11.mkdir(path14.join(base, subdir), { recursive: true, mode: DIR_MODE });
56723
+ await fs11.mkdir(path15.join(base, subdir), { recursive: true, mode: DIR_MODE });
56677
56724
  }
56678
56725
  }
56679
56726
  // --- Delivery ---
@@ -56695,8 +56742,8 @@ var MaildirStore = class {
56695
56742
  const messageId = generateUlid2();
56696
56743
  const filename = messageId + FILE_EXT;
56697
56744
  const base = this.endpointDir(endpointHash);
56698
- const tmpPath = path14.join(base, "tmp", filename);
56699
- const newPath = path14.join(base, "new", filename);
56745
+ const tmpPath = path15.join(base, "tmp", filename);
56746
+ const newPath = path15.join(base, "new", filename);
56700
56747
  try {
56701
56748
  const data = JSON.stringify(envelope, null, 2);
56702
56749
  await writeFileExclusive(tmpPath, data);
@@ -56722,8 +56769,8 @@ var MaildirStore = class {
56722
56769
  async claim(endpointHash, messageId) {
56723
56770
  const filename = messageId + FILE_EXT;
56724
56771
  const base = this.endpointDir(endpointHash);
56725
- const newPath = path14.join(base, "new", filename);
56726
- const curPath = path14.join(base, "cur", filename);
56772
+ const newPath = path15.join(base, "new", filename);
56773
+ const curPath = path15.join(base, "cur", filename);
56727
56774
  try {
56728
56775
  await fs11.rename(newPath, curPath);
56729
56776
  const data = await fs11.readFile(curPath, "utf-8");
@@ -56743,7 +56790,7 @@ var MaildirStore = class {
56743
56790
  */
56744
56791
  async complete(endpointHash, messageId) {
56745
56792
  const filename = messageId + FILE_EXT;
56746
- const curPath = path14.join(this.endpointDir(endpointHash), "cur", filename);
56793
+ const curPath = path15.join(this.endpointDir(endpointHash), "cur", filename);
56747
56794
  await fs11.unlink(curPath);
56748
56795
  }
56749
56796
  // --- Fail ---
@@ -56761,8 +56808,8 @@ var MaildirStore = class {
56761
56808
  async fail(endpointHash, messageId, reason) {
56762
56809
  const filename = messageId + FILE_EXT;
56763
56810
  const base = this.endpointDir(endpointHash);
56764
- const curPath = path14.join(base, "cur", filename);
56765
- const failedPath = path14.join(base, "failed", filename);
56811
+ const curPath = path15.join(base, "cur", filename);
56812
+ const failedPath = path15.join(base, "failed", filename);
56766
56813
  try {
56767
56814
  await fs11.rename(curPath, failedPath);
56768
56815
  const data = await fs11.readFile(failedPath, "utf-8");
@@ -56773,7 +56820,7 @@ var MaildirStore = class {
56773
56820
  failedAt: (/* @__PURE__ */ new Date()).toISOString(),
56774
56821
  endpointHash
56775
56822
  };
56776
- const reasonPath = path14.join(base, "failed", `${messageId}.reason.json`);
56823
+ const reasonPath = path15.join(base, "failed", `${messageId}.reason.json`);
56777
56824
  await writeFileExclusive(reasonPath, JSON.stringify(deadLetter, null, 2));
56778
56825
  return { ok: true, path: failedPath };
56779
56826
  } catch (err) {
@@ -56796,7 +56843,7 @@ var MaildirStore = class {
56796
56843
  const messageId = envelope.id;
56797
56844
  const filename = messageId + FILE_EXT;
56798
56845
  const base = this.endpointDir(endpointHash);
56799
- const failedPath = path14.join(base, "failed", filename);
56846
+ const failedPath = path15.join(base, "failed", filename);
56800
56847
  try {
56801
56848
  await writeFileExclusive(failedPath, JSON.stringify(envelope, null, 2));
56802
56849
  const deadLetter = {
@@ -56805,7 +56852,7 @@ var MaildirStore = class {
56805
56852
  failedAt: (/* @__PURE__ */ new Date()).toISOString(),
56806
56853
  endpointHash
56807
56854
  };
56808
- const reasonPath = path14.join(base, "failed", `${messageId}.reason.json`);
56855
+ const reasonPath = path15.join(base, "failed", `${messageId}.reason.json`);
56809
56856
  await writeFileExclusive(reasonPath, JSON.stringify(deadLetter, null, 2));
56810
56857
  return { ok: true, path: failedPath };
56811
56858
  } catch (err) {
@@ -56856,7 +56903,7 @@ var MaildirStore = class {
56856
56903
  */
56857
56904
  async readEnvelope(endpointHash, subdir, messageId) {
56858
56905
  const filename = messageId + FILE_EXT;
56859
- const filePath = path14.join(this.endpointDir(endpointHash), subdir, filename);
56906
+ const filePath = path15.join(this.endpointDir(endpointHash), subdir, filename);
56860
56907
  try {
56861
56908
  const data = await fs11.readFile(filePath, "utf-8");
56862
56909
  return JSON.parse(data);
@@ -56872,7 +56919,7 @@ var MaildirStore = class {
56872
56919
  * @returns The parsed DeadLetter, or null if not found.
56873
56920
  */
56874
56921
  async readDeadLetter(endpointHash, messageId) {
56875
- const reasonPath = path14.join(this.endpointDir(endpointHash), "failed", `${messageId}.reason.json`);
56922
+ const reasonPath = path15.join(this.endpointDir(endpointHash), "failed", `${messageId}.reason.json`);
56876
56923
  try {
56877
56924
  const data = await fs11.readFile(reasonPath, "utf-8");
56878
56925
  return JSON.parse(data);
@@ -56887,7 +56934,7 @@ var MaildirStore = class {
56887
56934
  * @param endpointHash - The hash identifying the endpoint.
56888
56935
  */
56889
56936
  endpointDir(endpointHash) {
56890
- return path14.join(this.rootDir, endpointHash);
56937
+ return path15.join(this.rootDir, endpointHash);
56891
56938
  }
56892
56939
  /**
56893
56940
  * List message IDs in a given Maildir subdirectory.
@@ -56899,7 +56946,7 @@ var MaildirStore = class {
56899
56946
  * @param subdir - The subdirectory to list.
56900
56947
  */
56901
56948
  async listSubdir(endpointHash, subdir) {
56902
- const dirPath = path14.join(this.endpointDir(endpointHash), subdir);
56949
+ const dirPath = path15.join(this.endpointDir(endpointHash), subdir);
56903
56950
  try {
56904
56951
  const entries = await fs11.readdir(dirPath);
56905
56952
  return entries.filter((f4) => f4.endsWith(FILE_EXT) && !f4.endsWith(".reason.json")).map((f4) => f4.slice(0, -FILE_EXT.length)).sort();
@@ -57201,7 +57248,7 @@ async function listMessageIds(store, hash, subdir) {
57201
57248
 
57202
57249
  // ../relay/dist/dead-letter-queue.js
57203
57250
  import * as fs12 from "node:fs/promises";
57204
- import * as path15 from "node:path";
57251
+ import * as path16 from "node:path";
57205
57252
  var DeadLetterQueue = class {
57206
57253
  maildirStore;
57207
57254
  sqliteIndex;
@@ -57416,9 +57463,9 @@ var DeadLetterQueue = class {
57416
57463
  * @param messageId - The message ID to remove.
57417
57464
  */
57418
57465
  async removeDeadLetter(endpointHash, messageId) {
57419
- const failedDir = path15.join(this.rootDir, endpointHash, "failed");
57420
- await silentUnlink2(path15.join(failedDir, `${messageId}.json`));
57421
- await silentUnlink2(path15.join(failedDir, `${messageId}.reason.json`));
57466
+ const failedDir = path16.join(this.rootDir, endpointHash, "failed");
57467
+ await silentUnlink2(path16.join(failedDir, `${messageId}.json`));
57468
+ await silentUnlink2(path16.join(failedDir, `${messageId}.reason.json`));
57422
57469
  this.sqliteIndex.insertMessage({
57423
57470
  id: messageId,
57424
57471
  subject: "",
@@ -57439,7 +57486,7 @@ async function silentUnlink2(filePath) {
57439
57486
 
57440
57487
  // ../relay/dist/access-control.js
57441
57488
  import fs13 from "node:fs";
57442
- import path16 from "node:path";
57489
+ import path17 from "node:path";
57443
57490
  var RULES_FILENAME = "access-rules.json";
57444
57491
  function byPriorityDesc(a2, b3) {
57445
57492
  return b3.priority - a2.priority;
@@ -57468,7 +57515,7 @@ var AccessControl = class {
57468
57515
  * @param dataDir - Directory containing (or to contain) `access-rules.json`
57469
57516
  */
57470
57517
  constructor(dataDir) {
57471
- this.rulesPath = path16.join(dataDir, RULES_FILENAME);
57518
+ this.rulesPath = path17.join(dataDir, RULES_FILENAME);
57472
57519
  this.loadRules();
57473
57520
  this.startWatcher();
57474
57521
  }
@@ -58078,7 +58125,7 @@ var AdapterDelivery = class _AdapterDelivery {
58078
58125
  };
58079
58126
 
58080
58127
  // ../relay/dist/watcher-manager.js
58081
- import * as path17 from "node:path";
58128
+ import * as path18 from "node:path";
58082
58129
  var WatcherManager = class {
58083
58130
  maildirStore;
58084
58131
  subscriptionRegistry;
@@ -58116,7 +58163,7 @@ var WatcherManager = class {
58116
58163
  startWatcher(endpoint) {
58117
58164
  if (this.watchers.has(endpoint.hash))
58118
58165
  return Promise.resolve();
58119
- const newDir = path17.join(endpoint.maildirPath, "new");
58166
+ const newDir = path18.join(endpoint.maildirPath, "new");
58120
58167
  const watcher = esm_default.watch(newDir, {
58121
58168
  persistent: true,
58122
58169
  ignoreInitial: true
@@ -58164,7 +58211,7 @@ var WatcherManager = class {
58164
58211
  * @param filePath - The path to the new message file
58165
58212
  */
58166
58213
  async handleNewMessage(endpoint, filePath) {
58167
- const filename = path17.basename(filePath);
58214
+ const filename = path18.basename(filePath);
58168
58215
  if (!filename.endsWith(".json"))
58169
58216
  return;
58170
58217
  const messageId = filename.slice(0, -5);
@@ -58203,7 +58250,7 @@ function inferEndpointType2(subject) {
58203
58250
  }
58204
58251
 
58205
58252
  // ../relay/dist/relay-core.js
58206
- var DEFAULT_DATA_DIR = path18.join(os4.homedir(), ".dork", "relay");
58253
+ var DEFAULT_DATA_DIR = path19.join(os4.homedir(), ".dork", "relay");
58207
58254
  var DEFAULT_TTL_MS2 = 36e5;
58208
58255
  var DEFAULT_MAX_HOPS2 = 5;
58209
58256
  var DEFAULT_CALL_BUDGET2 = 10;
@@ -58241,14 +58288,14 @@ var RelayCore = class {
58241
58288
  defaultCallBudget: options?.defaultCallBudget ?? DEFAULT_CALL_BUDGET2
58242
58289
  };
58243
58290
  fs14.mkdirSync(dataDir, { recursive: true });
58244
- const mailboxesDir = path18.join(dataDir, "mailboxes");
58291
+ const mailboxesDir = path19.join(dataDir, "mailboxes");
58245
58292
  this.endpointRegistry = new EndpointRegistry(dataDir);
58246
58293
  this.subscriptionRegistry = new SubscriptionRegistry(dataDir);
58247
58294
  this.maildirStore = new MaildirStore({ rootDir: mailboxesDir });
58248
58295
  if (options?.db) {
58249
58296
  this.sqliteIndex = new SqliteIndex(options.db);
58250
58297
  } else {
58251
- const dbPath = path18.join(dataDir, "index.db");
58298
+ const dbPath = path19.join(dataDir, "index.db");
58252
58299
  const legacyDb = createDb(dbPath);
58253
58300
  runMigrations(legacyDb);
58254
58301
  this.sqliteIndex = new SqliteIndex(legacyDb);
@@ -58280,7 +58327,7 @@ var RelayCore = class {
58280
58327
  this.adapterDelivery = new AdapterDelivery(options?.adapterRegistry, this.sqliteIndex);
58281
58328
  this.watcherManager = new WatcherManager(this.maildirStore, this.subscriptionRegistry, this.sqliteIndex, this.circuitBreaker);
58282
58329
  this.watcherManager.setWasDispatched((id) => this.deliveryPipeline.wasDispatched(id));
58283
- this.configPath = path18.join(dataDir, "config.json");
58330
+ this.configPath = path19.join(dataDir, "config.json");
58284
58331
  this.loadReliabilityConfig();
58285
58332
  this.startConfigWatcher();
58286
58333
  this.dispatchInboxTtlMs = options?.dispatchInboxTtlMs ?? 30 * 60 * 1e3;
@@ -59945,13 +59992,15 @@ var ClaudeCodeAdapter = class {
59945
59992
  error: null
59946
59993
  };
59947
59994
  this.deps.traceStore.insertSpan(span);
59995
+ const payloadCwd = typeof envelope.payload === "object" && envelope.payload !== null ? envelope.payload.cwd : void 0;
59948
59996
  const agentCwd = context?.agent?.directory;
59997
+ const effectiveCwd = payloadCwd ?? agentCwd;
59949
59998
  const log = this.deps.logger ?? console;
59950
- log.debug?.(`[CCA] handleAgentMessage agentId=${agentId} ccaSessionKey=${ccaSessionKey}, context.agent.directory=${context?.agent?.directory ?? "(none)"}, resolvedCwd=${agentCwd ?? "(deferred to session)"}`);
59999
+ log.debug?.(`[CCA] handleAgentMessage agentId=${agentId} ccaSessionKey=${ccaSessionKey}, payloadCwd=${payloadCwd ?? "(none)"}, context.agent.directory=${context?.agent?.directory ?? "(none)"}, resolvedCwd=${effectiveCwd ?? "(deferred to session)"}`);
59951
60000
  this.deps.agentManager.ensureSession(ccaSessionKey, {
59952
60001
  permissionMode: "default",
59953
60002
  hasStarted: true,
59954
- ...agentCwd ? { cwd: agentCwd } : {}
60003
+ ...effectiveCwd ? { cwd: effectiveCwd } : {}
59955
60004
  });
59956
60005
  this.deps.traceStore.updateSpan(envelope.id, {
59957
60006
  status: "delivered",
@@ -59991,7 +60040,7 @@ var ClaudeCodeAdapter = class {
59991
60040
  const timeout = setTimeout(() => controller.abort(), timeoutMs);
59992
60041
  const isInboxReplyTo = envelope.replyTo?.startsWith("relay.inbox.");
59993
60042
  const eventStream = this.deps.agentManager.sendMessage(ccaSessionKey, prompt2, {
59994
- ...agentCwd ? { cwd: agentCwd } : {}
60043
+ ...effectiveCwd ? { cwd: effectiveCwd } : {}
59995
60044
  });
59996
60045
  let eventCount = 0;
59997
60046
  let collectedText = "";
@@ -62125,7 +62174,7 @@ var TraceStore = class {
62125
62174
  };
62126
62175
 
62127
62176
  // ../mesh/dist/mesh-core.js
62128
- import path25 from "path";
62177
+ import path26 from "path";
62129
62178
  import os5 from "os";
62130
62179
 
62131
62180
  // ../mesh/dist/health.js
@@ -62558,7 +62607,7 @@ var DenialList = class {
62558
62607
  };
62559
62608
 
62560
62609
  // ../mesh/dist/relay-bridge.js
62561
- import path19 from "path";
62610
+ import path20 from "path";
62562
62611
  var SAME_NAMESPACE_ALLOW_PRIORITY = 100;
62563
62612
  var CROSS_NAMESPACE_DENY_PRIORITY = 10;
62564
62613
  var RelayBridge = class {
@@ -62587,7 +62636,7 @@ var RelayBridge = class {
62587
62636
  async registerAgent(agent, projectPath, namespace, _scanRoot) {
62588
62637
  if (!this.relayCore)
62589
62638
  return null;
62590
- const ns = namespace || path19.basename(projectPath);
62639
+ const ns = namespace || path20.basename(projectPath);
62591
62640
  const subject = `relay.agent.${ns}.${agent.id}`;
62592
62641
  try {
62593
62642
  await this.relayCore.registerEndpoint(subject);
@@ -62813,7 +62862,7 @@ var TopologyManager = class {
62813
62862
  };
62814
62863
 
62815
62864
  // ../mesh/dist/namespace-resolver.js
62816
- import path20 from "path";
62865
+ import path21 from "path";
62817
62866
  var MAX_NAMESPACE_LENGTH = 64;
62818
62867
  function normalizeNamespace(raw) {
62819
62868
  return raw.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
@@ -62836,8 +62885,8 @@ function resolveNamespace(projectPath, scanRoot, manifestNamespace) {
62836
62885
  }
62837
62886
  return normalized2;
62838
62887
  }
62839
- const relative3 = path20.relative(scanRoot, projectPath);
62840
- const firstSegment = relative3.split(path20.sep)[0];
62888
+ const relative3 = path21.relative(scanRoot, projectPath);
62889
+ const firstSegment = relative3.split(path21.sep)[0];
62841
62890
  if (!firstSegment) {
62842
62891
  throw new Error(`Cannot derive namespace: projectPath '${projectPath}' is at or above scanRoot '${scanRoot}'`);
62843
62892
  }
@@ -62851,21 +62900,21 @@ function resolveNamespace(projectPath, scanRoot, manifestNamespace) {
62851
62900
 
62852
62901
  // ../mesh/dist/strategies/claude-code-strategy.js
62853
62902
  import fs15 from "fs/promises";
62854
- import path21 from "path";
62903
+ import path22 from "path";
62855
62904
  var MAX_CLAUDEMD_BYTES = 4096;
62856
62905
  var ClaudeCodeStrategy = class {
62857
62906
  name = "claude-code";
62858
62907
  runtime = "claude-code";
62859
62908
  async detect(dir) {
62860
62909
  try {
62861
- const stat5 = await fs15.stat(path21.join(dir, "CLAUDE.md"));
62910
+ const stat5 = await fs15.stat(path22.join(dir, "CLAUDE.md"));
62862
62911
  return stat5.isFile();
62863
62912
  } catch {
62864
62913
  return false;
62865
62914
  }
62866
62915
  }
62867
62916
  async extractHints(dir) {
62868
- const suggestedName = path21.basename(dir);
62917
+ const suggestedName = path22.basename(dir);
62869
62918
  const description = await this.extractDescription(dir);
62870
62919
  return {
62871
62920
  suggestedName,
@@ -62881,7 +62930,7 @@ var ClaudeCodeStrategy = class {
62881
62930
  */
62882
62931
  async extractDescription(dir) {
62883
62932
  try {
62884
- const claudeMdPath = path21.join(dir, "CLAUDE.md");
62933
+ const claudeMdPath = path22.join(dir, "CLAUDE.md");
62885
62934
  const fd = await fs15.open(claudeMdPath, "r");
62886
62935
  try {
62887
62936
  const buf = Buffer.alloc(MAX_CLAUDEMD_BYTES);
@@ -62925,13 +62974,13 @@ function extractFirstParagraph(content) {
62925
62974
 
62926
62975
  // ../mesh/dist/strategies/cursor-strategy.js
62927
62976
  import fs16 from "fs/promises";
62928
- import path22 from "path";
62977
+ import path23 from "path";
62929
62978
  var CursorStrategy = class {
62930
62979
  name = "cursor";
62931
62980
  runtime = "cursor";
62932
62981
  async detect(dir) {
62933
62982
  try {
62934
- const stat5 = await fs16.stat(path22.join(dir, ".cursor"));
62983
+ const stat5 = await fs16.stat(path23.join(dir, ".cursor"));
62935
62984
  return stat5.isDirectory();
62936
62985
  } catch {
62937
62986
  return false;
@@ -62939,7 +62988,7 @@ var CursorStrategy = class {
62939
62988
  }
62940
62989
  async extractHints(dir) {
62941
62990
  return {
62942
- suggestedName: path22.basename(dir),
62991
+ suggestedName: path23.basename(dir),
62943
62992
  detectedRuntime: "cursor",
62944
62993
  inferredCapabilities: ["code"]
62945
62994
  };
@@ -62948,13 +62997,13 @@ var CursorStrategy = class {
62948
62997
 
62949
62998
  // ../mesh/dist/strategies/codex-strategy.js
62950
62999
  import fs17 from "fs/promises";
62951
- import path23 from "path";
63000
+ import path24 from "path";
62952
63001
  var CodexStrategy = class {
62953
63002
  name = "codex";
62954
63003
  runtime = "codex";
62955
63004
  async detect(dir) {
62956
63005
  try {
62957
- const stat5 = await fs17.stat(path23.join(dir, ".codex"));
63006
+ const stat5 = await fs17.stat(path24.join(dir, ".codex"));
62958
63007
  return stat5.isDirectory();
62959
63008
  } catch {
62960
63009
  return false;
@@ -62962,7 +63011,7 @@ var CodexStrategy = class {
62962
63011
  }
62963
63012
  async extractHints(dir) {
62964
63013
  return {
62965
- suggestedName: path23.basename(dir),
63014
+ suggestedName: path24.basename(dir),
62966
63015
  detectedRuntime: "codex",
62967
63016
  inferredCapabilities: ["code"]
62968
63017
  };
@@ -62972,7 +63021,7 @@ var CodexStrategy = class {
62972
63021
  // ../mesh/dist/discovery/unified-scanner.js
62973
63022
  import fs18 from "fs/promises";
62974
63023
  import { realpathSync as realpathSync2 } from "fs";
62975
- import path24 from "path";
63024
+ import path25 from "path";
62976
63025
 
62977
63026
  // ../mesh/dist/discovery/types.js
62978
63027
  var UNIFIED_EXCLUDE_PATTERNS = /* @__PURE__ */ new Set([
@@ -63029,7 +63078,7 @@ async function* unifiedScan(options, strategies, registry2, denialList) {
63029
63078
  if (!item)
63030
63079
  continue;
63031
63080
  const { dir, depth } = item;
63032
- const dirName = path24.basename(dir);
63081
+ const dirName = path25.basename(dir);
63033
63082
  if (UNIFIED_EXCLUDE_PATTERNS.has(dirName) || extraExcludes.has(dirName))
63034
63083
  continue;
63035
63084
  if (dirName.startsWith(".") && !ALLOWED_DOT_DIRS.has(dirName))
@@ -63096,7 +63145,7 @@ async function* unifiedScan(options, strategies, registry2, denialList) {
63096
63145
  continue;
63097
63146
  if (isSymlink && !followSymlinks)
63098
63147
  continue;
63099
- queue2.push({ dir: path24.join(dir, entry.name), depth: depth + 1 });
63148
+ queue2.push({ dir: path25.join(dir, entry.name), depth: depth + 1 });
63100
63149
  }
63101
63150
  }
63102
63151
  }
@@ -63384,7 +63433,7 @@ var MeshCore = class {
63384
63433
  return;
63385
63434
  await removeManifest(agent.projectPath);
63386
63435
  const namespace = agent.namespace;
63387
- const subject = `relay.agent.${namespace || path25.basename(agent.projectPath)}.${agent.id}`;
63436
+ const subject = `relay.agent.${namespace || path26.basename(agent.projectPath)}.${agent.id}`;
63388
63437
  await this.relayBridge.unregisterAgent(subject, agent.id, agent.name);
63389
63438
  this.registry.remove(agentId);
63390
63439
  for (const cb of this.onUnregisterCallbacks) {
@@ -63620,7 +63669,7 @@ var MeshCore = class {
63620
63669
  if (!health)
63621
63670
  return void 0;
63622
63671
  const manifest = this.toManifest(entry);
63623
- const ns = entry.namespace || path25.basename(entry.projectPath);
63672
+ const ns = entry.namespace || path26.basename(entry.projectPath);
63624
63673
  const relaySubject = `relay.agent.${ns}.${agentId}`;
63625
63674
  return { agent: manifest, health, relaySubject };
63626
63675
  }
@@ -64024,7 +64073,7 @@ function createMeshRouter(deps) {
64024
64073
 
64025
64074
  // ../../apps/server/src/routes/agents.ts
64026
64075
  import { Router as Router15 } from "express";
64027
- import path26 from "path";
64076
+ import path27 from "path";
64028
64077
  function createAgentsRouter(meshCore2) {
64029
64078
  const router12 = Router15();
64030
64079
  router12.get("/current", async (req, res) => {
@@ -64084,7 +64133,7 @@ function createAgentsRouter(meshCore2) {
64084
64133
  }
64085
64134
  const manifest = {
64086
64135
  id: ulid(),
64087
- name: name ?? path26.basename(agentPath),
64136
+ name: name ?? path27.basename(agentPath),
64088
64137
  description: description ?? "",
64089
64138
  runtime: runtime ?? "claude-code",
64090
64139
  capabilities: [],
@@ -72349,13 +72398,13 @@ function validateMcpOrigin(req, res, next) {
72349
72398
 
72350
72399
  // ../../apps/server/src/lib/dork-home.ts
72351
72400
  import os6 from "os";
72352
- import path27 from "path";
72401
+ import path28 from "path";
72353
72402
  function resolveDorkHome() {
72354
72403
  if (process.env.DORK_HOME) return process.env.DORK_HOME;
72355
72404
  if (process.env.NODE_ENV !== "production") {
72356
- return path27.join(process.cwd(), ".temp", ".dork");
72405
+ return path28.join(process.cwd(), ".temp", ".dork");
72357
72406
  }
72358
- return path27.join(os6.homedir(), ".dork");
72407
+ return path28.join(os6.homedir(), ".dork");
72359
72408
  }
72360
72409
 
72361
72410
  // ../../apps/server/src/index.ts
@@ -72373,18 +72422,18 @@ async function start() {
72373
72422
  process.env.DORK_HOME = dorkHome;
72374
72423
  console.log(`[DorkOS] Data directory: ${dorkHome}`);
72375
72424
  const logLevel = env.DORKOS_LOG_LEVEL;
72376
- initLogger({ level: logLevel, logDir: path28.join(dorkHome, "logs") });
72425
+ initLogger({ level: logLevel, logDir: path29.join(dorkHome, "logs") });
72377
72426
  initConfigManager(dorkHome);
72378
72427
  const loggingConfig = configManager.get("logging");
72379
72428
  if (loggingConfig?.maxLogSizeKb || loggingConfig?.maxLogFiles) {
72380
72429
  initLogger({
72381
72430
  level: logLevel,
72382
- logDir: path28.join(dorkHome, "logs"),
72431
+ logDir: path29.join(dorkHome, "logs"),
72383
72432
  maxLogSize: (loggingConfig.maxLogSizeKb ?? 500) * 1024,
72384
72433
  maxLogFiles: loggingConfig.maxLogFiles ?? 14
72385
72434
  });
72386
72435
  }
72387
- const dbPath = path28.join(dorkHome, "dork.db");
72436
+ const dbPath = path29.join(dorkHome, "dork.db");
72388
72437
  const db = createDb(dbPath);
72389
72438
  runMigrations(db);
72390
72439
  logger.info(`[DB] Consolidated database ready at ${dbPath}`);
@@ -72409,7 +72458,7 @@ async function start() {
72409
72458
  }
72410
72459
  const relayConfig = configManager.get("relay");
72411
72460
  const relayEnabled = env.DORKOS_RELAY_ENABLED || relayConfig?.enabled;
72412
- const relayDataDir = relayConfig?.dataDir ?? path28.join(dorkHome, "relay");
72461
+ const relayDataDir = relayConfig?.dataDir ?? path29.join(dorkHome, "relay");
72413
72462
  if (relayEnabled) {
72414
72463
  try {
72415
72464
  adapterRegistry = new AdapterRegistry();
@@ -72451,7 +72500,7 @@ async function start() {
72451
72500
  }
72452
72501
  if (relayEnabled && relayCore && adapterRegistry && traceStore) {
72453
72502
  try {
72454
- const adapterConfigPath = path28.join(dorkHome, "relay", "adapters.json");
72503
+ const adapterConfigPath = path29.join(dorkHome, "relay", "adapters.json");
72455
72504
  adapterManager = new AdapterManager(adapterRegistry, adapterConfigPath, {
72456
72505
  agentManager: claudeRuntime,
72457
72506
  traceStore,