duclaw-cli 1.9.2 → 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -115,7 +115,7 @@ var require_package = __commonJS({
115
115
  var require_main = __commonJS({
116
116
  "node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.js"(exports2, module2) {
117
117
  var fs3 = require("fs");
118
- var path21 = require("path");
118
+ var path20 = require("path");
119
119
  var os = require("os");
120
120
  var crypto2 = require("crypto");
121
121
  var packageJson = require_package();
@@ -261,7 +261,7 @@ var require_main = __commonJS({
261
261
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
262
262
  }
263
263
  } else {
264
- possibleVaultPath = path21.resolve(process.cwd(), ".env.vault");
264
+ possibleVaultPath = path20.resolve(process.cwd(), ".env.vault");
265
265
  }
266
266
  if (fs3.existsSync(possibleVaultPath)) {
267
267
  return possibleVaultPath;
@@ -269,7 +269,7 @@ var require_main = __commonJS({
269
269
  return null;
270
270
  }
271
271
  function _resolveHome(envPath) {
272
- return envPath[0] === "~" ? path21.join(os.homedir(), envPath.slice(1)) : envPath;
272
+ return envPath[0] === "~" ? path20.join(os.homedir(), envPath.slice(1)) : envPath;
273
273
  }
274
274
  function _configVault(options) {
275
275
  const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
@@ -286,7 +286,7 @@ var require_main = __commonJS({
286
286
  return { parsed };
287
287
  }
288
288
  function configDotenv(options) {
289
- const dotenvPath = path21.resolve(process.cwd(), ".env");
289
+ const dotenvPath = path20.resolve(process.cwd(), ".env");
290
290
  let encoding = "utf8";
291
291
  let processEnv = process.env;
292
292
  if (options && options.processEnv != null) {
@@ -314,13 +314,13 @@ var require_main = __commonJS({
314
314
  }
315
315
  let lastError;
316
316
  const parsedAll = {};
317
- for (const path22 of optionPaths) {
317
+ for (const path21 of optionPaths) {
318
318
  try {
319
- const parsed = DotenvModule.parse(fs3.readFileSync(path22, { encoding }));
319
+ const parsed = DotenvModule.parse(fs3.readFileSync(path21, { encoding }));
320
320
  DotenvModule.populate(parsedAll, parsed, options);
321
321
  } catch (e) {
322
322
  if (debug) {
323
- _debug(`Failed to load ${path22} ${e.message}`);
323
+ _debug(`Failed to load ${path21} ${e.message}`);
324
324
  }
325
325
  lastError = e;
326
326
  }
@@ -333,7 +333,7 @@ var require_main = __commonJS({
333
333
  const shortPaths = [];
334
334
  for (const filePath of optionPaths) {
335
335
  try {
336
- const relative4 = path21.relative(process.cwd(), filePath);
336
+ const relative4 = path20.relative(process.cwd(), filePath);
337
337
  shortPaths.push(relative4);
338
338
  } catch (e) {
339
339
  if (debug) {
@@ -8237,8 +8237,8 @@ var require_MODULE_LOAD = __commonJS({
8237
8237
  * @param moduleArguments - Optional arguments to pass to the module
8238
8238
  * @see https://redis.io/commands/module-load/
8239
8239
  */
8240
- parseCommand(parser, path21, moduleArguments) {
8241
- parser.push("MODULE", "LOAD", path21);
8240
+ parseCommand(parser, path20, moduleArguments) {
8241
+ parser.push("MODULE", "LOAD", path20);
8242
8242
  if (moduleArguments) {
8243
8243
  parser.push(...moduleArguments);
8244
8244
  }
@@ -23539,10 +23539,10 @@ var require_ARRAPPEND = __commonJS({
23539
23539
  * @param json - The first value to append
23540
23540
  * @param jsons - Additional values to append
23541
23541
  */
23542
- parseCommand(parser, key, path21, json, ...jsons) {
23542
+ parseCommand(parser, key, path20, json, ...jsons) {
23543
23543
  parser.push("JSON.ARRAPPEND");
23544
23544
  parser.pushKey(key);
23545
- parser.push(path21, (0, generic_transformers_1.transformRedisJsonArgument)(json));
23545
+ parser.push(path20, (0, generic_transformers_1.transformRedisJsonArgument)(json));
23546
23546
  for (let i = 0; i < jsons.length; i++) {
23547
23547
  parser.push((0, generic_transformers_1.transformRedisJsonArgument)(jsons[i]));
23548
23548
  }
@@ -23572,10 +23572,10 @@ var require_ARRINDEX = __commonJS({
23572
23572
  * @param options.range.start - Starting index for the search
23573
23573
  * @param options.range.stop - Optional ending index for the search
23574
23574
  */
23575
- parseCommand(parser, key, path21, json, options) {
23575
+ parseCommand(parser, key, path20, json, options) {
23576
23576
  parser.push("JSON.ARRINDEX");
23577
23577
  parser.pushKey(key);
23578
- parser.push(path21, (0, generic_transformers_1.transformRedisJsonArgument)(json));
23578
+ parser.push(path20, (0, generic_transformers_1.transformRedisJsonArgument)(json));
23579
23579
  if (options?.range) {
23580
23580
  parser.push(options.range.start.toString());
23581
23581
  if (options.range.stop !== void 0) {
@@ -23607,10 +23607,10 @@ var require_ARRINSERT = __commonJS({
23607
23607
  * @param json - The first value to insert
23608
23608
  * @param jsons - Additional values to insert
23609
23609
  */
23610
- parseCommand(parser, key, path21, index, json, ...jsons) {
23610
+ parseCommand(parser, key, path20, index, json, ...jsons) {
23611
23611
  parser.push("JSON.ARRINSERT");
23612
23612
  parser.pushKey(key);
23613
- parser.push(path21, index.toString(), (0, generic_transformers_1.transformRedisJsonArgument)(json));
23613
+ parser.push(path20, index.toString(), (0, generic_transformers_1.transformRedisJsonArgument)(json));
23614
23614
  for (let i = 0; i < jsons.length; i++) {
23615
23615
  parser.push((0, generic_transformers_1.transformRedisJsonArgument)(jsons[i]));
23616
23616
  }
@@ -23700,10 +23700,10 @@ var require_ARRTRIM = __commonJS({
23700
23700
  * @param start - Starting index (inclusive)
23701
23701
  * @param stop - Ending index (inclusive)
23702
23702
  */
23703
- parseCommand(parser, key, path21, start, stop) {
23703
+ parseCommand(parser, key, path20, start, stop) {
23704
23704
  parser.push("JSON.ARRTRIM");
23705
23705
  parser.pushKey(key);
23706
- parser.push(path21, start.toString(), stop.toString());
23706
+ parser.push(path20, start.toString(), stop.toString());
23707
23707
  },
23708
23708
  transformReply: void 0
23709
23709
  };
@@ -23868,10 +23868,10 @@ var require_MERGE3 = __commonJS({
23868
23868
  * @param path - Path to merge into
23869
23869
  * @param value - JSON value to merge
23870
23870
  */
23871
- parseCommand(parser, key, path21, value) {
23871
+ parseCommand(parser, key, path20, value) {
23872
23872
  parser.push("JSON.MERGE");
23873
23873
  parser.pushKey(key);
23874
- parser.push(path21, (0, generic_transformers_1.transformRedisJsonArgument)(value));
23874
+ parser.push(path20, (0, generic_transformers_1.transformRedisJsonArgument)(value));
23875
23875
  },
23876
23876
  transformReply: void 0
23877
23877
  };
@@ -23894,10 +23894,10 @@ var require_MGET2 = __commonJS({
23894
23894
  * @param keys - Array of keys containing JSON documents
23895
23895
  * @param path - Path to retrieve from each document
23896
23896
  */
23897
- parseCommand(parser, keys, path21) {
23897
+ parseCommand(parser, keys, path20) {
23898
23898
  parser.push("JSON.MGET");
23899
23899
  parser.pushKeys(keys);
23900
- parser.push(path21);
23900
+ parser.push(path20);
23901
23901
  },
23902
23902
  transformReply(reply) {
23903
23903
  return reply.map((json) => (0, generic_transformers_1.transformRedisJsonNullReply)(json));
@@ -23952,10 +23952,10 @@ var require_NUMINCRBY = __commonJS({
23952
23952
  * @param path - Path to the numeric value
23953
23953
  * @param by - Amount to increment by
23954
23954
  */
23955
- parseCommand(parser, key, path21, by) {
23955
+ parseCommand(parser, key, path20, by) {
23956
23956
  parser.push("JSON.NUMINCRBY");
23957
23957
  parser.pushKey(key);
23958
- parser.push(path21, by.toString());
23958
+ parser.push(path20, by.toString());
23959
23959
  },
23960
23960
  transformReply: {
23961
23961
  2: (reply) => {
@@ -23987,10 +23987,10 @@ var require_NUMMULTBY = __commonJS({
23987
23987
  * @param path - Path to the numeric value
23988
23988
  * @param by - Amount to multiply by
23989
23989
  */
23990
- parseCommand(parser, key, path21, by) {
23990
+ parseCommand(parser, key, path20, by) {
23991
23991
  parser.push("JSON.NUMMULTBY");
23992
23992
  parser.pushKey(key);
23993
- parser.push(path21, by.toString());
23993
+ parser.push(path20, by.toString());
23994
23994
  },
23995
23995
  transformReply: NUMINCRBY_1.default.transformReply
23996
23996
  };
@@ -24074,10 +24074,10 @@ var require_SET2 = __commonJS({
24074
24074
  * @deprecated options.NX - Use options.condition instead
24075
24075
  * @deprecated options.XX - Use options.condition instead
24076
24076
  */
24077
- parseCommand(parser, key, path21, json, options) {
24077
+ parseCommand(parser, key, path20, json, options) {
24078
24078
  parser.push("JSON.SET");
24079
24079
  parser.pushKey(key);
24080
- parser.push(path21, (0, generic_transformers_1.transformRedisJsonArgument)(json));
24080
+ parser.push(path20, (0, generic_transformers_1.transformRedisJsonArgument)(json));
24081
24081
  if (options?.condition) {
24082
24082
  parser.push(options?.condition);
24083
24083
  } else if (options?.NX) {
@@ -24165,10 +24165,10 @@ var require_TOGGLE = __commonJS({
24165
24165
  * @param key - The key containing the JSON document
24166
24166
  * @param path - Path to the boolean value
24167
24167
  */
24168
- parseCommand(parser, key, path21) {
24168
+ parseCommand(parser, key, path20) {
24169
24169
  parser.push("JSON.TOGGLE");
24170
24170
  parser.pushKey(key);
24171
- parser.push(path21);
24171
+ parser.push(path20);
24172
24172
  },
24173
24173
  transformReply: void 0
24174
24174
  };
@@ -30242,7 +30242,7 @@ function printHelp() {
30242
30242
  `);
30243
30243
  }
30244
30244
  function printVersion() {
30245
- console.log(`duclaw-cli v${true ? "1.9.2" : "unknown"}`);
30245
+ console.log(`duclaw-cli v${true ? "1.9.4" : "unknown"}`);
30246
30246
  }
30247
30247
  function getDuclawTemplate() {
30248
30248
  return {
@@ -31627,7 +31627,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
31627
31627
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
31628
31628
  const statMethod = opts.lstat ? import_promises3.lstat : import_promises3.stat;
31629
31629
  if (wantBigintFsStats) {
31630
- this._stat = (path21) => statMethod(path21, { bigint: true });
31630
+ this._stat = (path20) => statMethod(path20, { bigint: true });
31631
31631
  } else {
31632
31632
  this._stat = statMethod;
31633
31633
  }
@@ -31652,8 +31652,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
31652
31652
  const par = this.parent;
31653
31653
  const fil = par && par.files;
31654
31654
  if (fil && fil.length > 0) {
31655
- const { path: path21, depth } = par;
31656
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path21));
31655
+ const { path: path20, depth } = par;
31656
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path20));
31657
31657
  const awaited = await Promise.all(slice);
31658
31658
  for (const entry of awaited) {
31659
31659
  if (!entry)
@@ -31693,20 +31693,20 @@ var ReaddirpStream = class extends import_node_stream.Readable {
31693
31693
  this.reading = false;
31694
31694
  }
31695
31695
  }
31696
- async _exploreDir(path21, depth) {
31696
+ async _exploreDir(path20, depth) {
31697
31697
  let files;
31698
31698
  try {
31699
- files = await (0, import_promises3.readdir)(path21, this._rdOptions);
31699
+ files = await (0, import_promises3.readdir)(path20, this._rdOptions);
31700
31700
  } catch (error) {
31701
31701
  this._onError(error);
31702
31702
  }
31703
- return { files, depth, path: path21 };
31703
+ return { files, depth, path: path20 };
31704
31704
  }
31705
- async _formatEntry(dirent, path21) {
31705
+ async _formatEntry(dirent, path20) {
31706
31706
  let entry;
31707
31707
  const basename4 = this._isDirent ? dirent.name : dirent;
31708
31708
  try {
31709
- const fullPath = (0, import_node_path4.resolve)((0, import_node_path4.join)(path21, basename4));
31709
+ const fullPath = (0, import_node_path4.resolve)((0, import_node_path4.join)(path20, basename4));
31710
31710
  entry = { path: (0, import_node_path4.relative)(this._root, fullPath), fullPath, basename: basename4 };
31711
31711
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
31712
31712
  } catch (err) {
@@ -32106,16 +32106,16 @@ var delFromSet = (main2, prop, item) => {
32106
32106
  };
32107
32107
  var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
32108
32108
  var FsWatchInstances = /* @__PURE__ */ new Map();
32109
- function createFsWatchInstance(path21, options, listener, errHandler, emitRaw) {
32109
+ function createFsWatchInstance(path20, options, listener, errHandler, emitRaw) {
32110
32110
  const handleEvent = (rawEvent, evPath) => {
32111
- listener(path21);
32112
- emitRaw(rawEvent, evPath, { watchedPath: path21 });
32113
- if (evPath && path21 !== evPath) {
32114
- fsWatchBroadcast(sp.resolve(path21, evPath), KEY_LISTENERS, sp.join(path21, evPath));
32111
+ listener(path20);
32112
+ emitRaw(rawEvent, evPath, { watchedPath: path20 });
32113
+ if (evPath && path20 !== evPath) {
32114
+ fsWatchBroadcast(sp.resolve(path20, evPath), KEY_LISTENERS, sp.join(path20, evPath));
32115
32115
  }
32116
32116
  };
32117
32117
  try {
32118
- return (0, import_node_fs.watch)(path21, {
32118
+ return (0, import_node_fs.watch)(path20, {
32119
32119
  persistent: options.persistent
32120
32120
  }, handleEvent);
32121
32121
  } catch (error) {
@@ -32131,12 +32131,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
32131
32131
  listener(val1, val2, val3);
32132
32132
  });
32133
32133
  };
32134
- var setFsWatchListener = (path21, fullPath, options, handlers) => {
32134
+ var setFsWatchListener = (path20, fullPath, options, handlers) => {
32135
32135
  const { listener, errHandler, rawEmitter } = handlers;
32136
32136
  let cont = FsWatchInstances.get(fullPath);
32137
32137
  let watcher;
32138
32138
  if (!options.persistent) {
32139
- watcher = createFsWatchInstance(path21, options, listener, errHandler, rawEmitter);
32139
+ watcher = createFsWatchInstance(path20, options, listener, errHandler, rawEmitter);
32140
32140
  if (!watcher)
32141
32141
  return;
32142
32142
  return watcher.close.bind(watcher);
@@ -32147,7 +32147,7 @@ var setFsWatchListener = (path21, fullPath, options, handlers) => {
32147
32147
  addAndConvert(cont, KEY_RAW, rawEmitter);
32148
32148
  } else {
32149
32149
  watcher = createFsWatchInstance(
32150
- path21,
32150
+ path20,
32151
32151
  options,
32152
32152
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
32153
32153
  errHandler,
@@ -32162,7 +32162,7 @@ var setFsWatchListener = (path21, fullPath, options, handlers) => {
32162
32162
  cont.watcherUnusable = true;
32163
32163
  if (isWindows && error.code === "EPERM") {
32164
32164
  try {
32165
- const fd = await (0, import_promises4.open)(path21, "r");
32165
+ const fd = await (0, import_promises4.open)(path20, "r");
32166
32166
  await fd.close();
32167
32167
  broadcastErr(error);
32168
32168
  } catch (err) {
@@ -32193,7 +32193,7 @@ var setFsWatchListener = (path21, fullPath, options, handlers) => {
32193
32193
  };
32194
32194
  };
32195
32195
  var FsWatchFileInstances = /* @__PURE__ */ new Map();
32196
- var setFsWatchFileListener = (path21, fullPath, options, handlers) => {
32196
+ var setFsWatchFileListener = (path20, fullPath, options, handlers) => {
32197
32197
  const { listener, rawEmitter } = handlers;
32198
32198
  let cont = FsWatchFileInstances.get(fullPath);
32199
32199
  const copts = cont && cont.options;
@@ -32215,7 +32215,7 @@ var setFsWatchFileListener = (path21, fullPath, options, handlers) => {
32215
32215
  });
32216
32216
  const currmtime = curr.mtimeMs;
32217
32217
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
32218
- foreach(cont.listeners, (listener2) => listener2(path21, curr));
32218
+ foreach(cont.listeners, (listener2) => listener2(path20, curr));
32219
32219
  }
32220
32220
  })
32221
32221
  };
@@ -32245,13 +32245,13 @@ var NodeFsHandler = class {
32245
32245
  * @param listener on fs change
32246
32246
  * @returns closer for the watcher instance
32247
32247
  */
32248
- _watchWithNodeFs(path21, listener) {
32248
+ _watchWithNodeFs(path20, listener) {
32249
32249
  const opts = this.fsw.options;
32250
- const directory = sp.dirname(path21);
32251
- const basename4 = sp.basename(path21);
32250
+ const directory = sp.dirname(path20);
32251
+ const basename4 = sp.basename(path20);
32252
32252
  const parent = this.fsw._getWatchedDir(directory);
32253
32253
  parent.add(basename4);
32254
- const absolutePath = sp.resolve(path21);
32254
+ const absolutePath = sp.resolve(path20);
32255
32255
  const options = {
32256
32256
  persistent: opts.persistent
32257
32257
  };
@@ -32261,12 +32261,12 @@ var NodeFsHandler = class {
32261
32261
  if (opts.usePolling) {
32262
32262
  const enableBin = opts.interval !== opts.binaryInterval;
32263
32263
  options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
32264
- closer = setFsWatchFileListener(path21, absolutePath, options, {
32264
+ closer = setFsWatchFileListener(path20, absolutePath, options, {
32265
32265
  listener,
32266
32266
  rawEmitter: this.fsw._emitRaw
32267
32267
  });
32268
32268
  } else {
32269
- closer = setFsWatchListener(path21, absolutePath, options, {
32269
+ closer = setFsWatchListener(path20, absolutePath, options, {
32270
32270
  listener,
32271
32271
  errHandler: this._boundHandleError,
32272
32272
  rawEmitter: this.fsw._emitRaw
@@ -32288,7 +32288,7 @@ var NodeFsHandler = class {
32288
32288
  let prevStats = stats;
32289
32289
  if (parent.has(basename4))
32290
32290
  return;
32291
- const listener = async (path21, newStats) => {
32291
+ const listener = async (path20, newStats) => {
32292
32292
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
32293
32293
  return;
32294
32294
  if (!newStats || newStats.mtimeMs === 0) {
@@ -32302,11 +32302,11 @@ var NodeFsHandler = class {
32302
32302
  this.fsw._emit(EV.CHANGE, file, newStats2);
32303
32303
  }
32304
32304
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
32305
- this.fsw._closeFile(path21);
32305
+ this.fsw._closeFile(path20);
32306
32306
  prevStats = newStats2;
32307
32307
  const closer2 = this._watchWithNodeFs(file, listener);
32308
32308
  if (closer2)
32309
- this.fsw._addPathCloser(path21, closer2);
32309
+ this.fsw._addPathCloser(path20, closer2);
32310
32310
  } else {
32311
32311
  prevStats = newStats2;
32312
32312
  }
@@ -32338,7 +32338,7 @@ var NodeFsHandler = class {
32338
32338
  * @param item basename of this item
32339
32339
  * @returns true if no more processing is needed for this entry.
32340
32340
  */
32341
- async _handleSymlink(entry, directory, path21, item) {
32341
+ async _handleSymlink(entry, directory, path20, item) {
32342
32342
  if (this.fsw.closed) {
32343
32343
  return;
32344
32344
  }
@@ -32348,7 +32348,7 @@ var NodeFsHandler = class {
32348
32348
  this.fsw._incrReadyCount();
32349
32349
  let linkPath;
32350
32350
  try {
32351
- linkPath = await (0, import_promises4.realpath)(path21);
32351
+ linkPath = await (0, import_promises4.realpath)(path20);
32352
32352
  } catch (e) {
32353
32353
  this.fsw._emitReady();
32354
32354
  return true;
@@ -32358,12 +32358,12 @@ var NodeFsHandler = class {
32358
32358
  if (dir.has(item)) {
32359
32359
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
32360
32360
  this.fsw._symlinkPaths.set(full, linkPath);
32361
- this.fsw._emit(EV.CHANGE, path21, entry.stats);
32361
+ this.fsw._emit(EV.CHANGE, path20, entry.stats);
32362
32362
  }
32363
32363
  } else {
32364
32364
  dir.add(item);
32365
32365
  this.fsw._symlinkPaths.set(full, linkPath);
32366
- this.fsw._emit(EV.ADD, path21, entry.stats);
32366
+ this.fsw._emit(EV.ADD, path20, entry.stats);
32367
32367
  }
32368
32368
  this.fsw._emitReady();
32369
32369
  return true;
@@ -32393,9 +32393,9 @@ var NodeFsHandler = class {
32393
32393
  return;
32394
32394
  }
32395
32395
  const item = entry.path;
32396
- let path21 = sp.join(directory, item);
32396
+ let path20 = sp.join(directory, item);
32397
32397
  current.add(item);
32398
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path21, item)) {
32398
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path20, item)) {
32399
32399
  return;
32400
32400
  }
32401
32401
  if (this.fsw.closed) {
@@ -32404,8 +32404,8 @@ var NodeFsHandler = class {
32404
32404
  }
32405
32405
  if (item === target || !target && !previous.has(item)) {
32406
32406
  this.fsw._incrReadyCount();
32407
- path21 = sp.join(dir, sp.relative(dir, path21));
32408
- this._addToNodeFs(path21, initialAdd, wh, depth + 1);
32407
+ path20 = sp.join(dir, sp.relative(dir, path20));
32408
+ this._addToNodeFs(path20, initialAdd, wh, depth + 1);
32409
32409
  }
32410
32410
  }).on(EV.ERROR, this._boundHandleError);
32411
32411
  return new Promise((resolve11, reject) => {
@@ -32474,13 +32474,13 @@ var NodeFsHandler = class {
32474
32474
  * @param depth Child path actually targeted for watch
32475
32475
  * @param target Child path actually targeted for watch
32476
32476
  */
32477
- async _addToNodeFs(path21, initialAdd, priorWh, depth, target) {
32477
+ async _addToNodeFs(path20, initialAdd, priorWh, depth, target) {
32478
32478
  const ready = this.fsw._emitReady;
32479
- if (this.fsw._isIgnored(path21) || this.fsw.closed) {
32479
+ if (this.fsw._isIgnored(path20) || this.fsw.closed) {
32480
32480
  ready();
32481
32481
  return false;
32482
32482
  }
32483
- const wh = this.fsw._getWatchHelpers(path21);
32483
+ const wh = this.fsw._getWatchHelpers(path20);
32484
32484
  if (priorWh) {
32485
32485
  wh.filterPath = (entry) => priorWh.filterPath(entry);
32486
32486
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -32496,8 +32496,8 @@ var NodeFsHandler = class {
32496
32496
  const follow = this.fsw.options.followSymlinks;
32497
32497
  let closer;
32498
32498
  if (stats.isDirectory()) {
32499
- const absPath = sp.resolve(path21);
32500
- const targetPath = follow ? await (0, import_promises4.realpath)(path21) : path21;
32499
+ const absPath = sp.resolve(path20);
32500
+ const targetPath = follow ? await (0, import_promises4.realpath)(path20) : path20;
32501
32501
  if (this.fsw.closed)
32502
32502
  return;
32503
32503
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -32507,29 +32507,29 @@ var NodeFsHandler = class {
32507
32507
  this.fsw._symlinkPaths.set(absPath, targetPath);
32508
32508
  }
32509
32509
  } else if (stats.isSymbolicLink()) {
32510
- const targetPath = follow ? await (0, import_promises4.realpath)(path21) : path21;
32510
+ const targetPath = follow ? await (0, import_promises4.realpath)(path20) : path20;
32511
32511
  if (this.fsw.closed)
32512
32512
  return;
32513
32513
  const parent = sp.dirname(wh.watchPath);
32514
32514
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
32515
32515
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
32516
- closer = await this._handleDir(parent, stats, initialAdd, depth, path21, wh, targetPath);
32516
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path20, wh, targetPath);
32517
32517
  if (this.fsw.closed)
32518
32518
  return;
32519
32519
  if (targetPath !== void 0) {
32520
- this.fsw._symlinkPaths.set(sp.resolve(path21), targetPath);
32520
+ this.fsw._symlinkPaths.set(sp.resolve(path20), targetPath);
32521
32521
  }
32522
32522
  } else {
32523
32523
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
32524
32524
  }
32525
32525
  ready();
32526
32526
  if (closer)
32527
- this.fsw._addPathCloser(path21, closer);
32527
+ this.fsw._addPathCloser(path20, closer);
32528
32528
  return false;
32529
32529
  } catch (error) {
32530
32530
  if (this.fsw._handleError(error)) {
32531
32531
  ready();
32532
- return path21;
32532
+ return path20;
32533
32533
  }
32534
32534
  }
32535
32535
  }
@@ -32572,24 +32572,24 @@ function createPattern(matcher) {
32572
32572
  }
32573
32573
  return () => false;
32574
32574
  }
32575
- function normalizePath(path21) {
32576
- if (typeof path21 !== "string")
32575
+ function normalizePath(path20) {
32576
+ if (typeof path20 !== "string")
32577
32577
  throw new Error("string expected");
32578
- path21 = sp2.normalize(path21);
32579
- path21 = path21.replace(/\\/g, "/");
32578
+ path20 = sp2.normalize(path20);
32579
+ path20 = path20.replace(/\\/g, "/");
32580
32580
  let prepend = false;
32581
- if (path21.startsWith("//"))
32581
+ if (path20.startsWith("//"))
32582
32582
  prepend = true;
32583
- path21 = path21.replace(DOUBLE_SLASH_RE, "/");
32583
+ path20 = path20.replace(DOUBLE_SLASH_RE, "/");
32584
32584
  if (prepend)
32585
- path21 = "/" + path21;
32586
- return path21;
32585
+ path20 = "/" + path20;
32586
+ return path20;
32587
32587
  }
32588
32588
  function matchPatterns(patterns, testString, stats) {
32589
- const path21 = normalizePath(testString);
32589
+ const path20 = normalizePath(testString);
32590
32590
  for (let index = 0; index < patterns.length; index++) {
32591
32591
  const pattern = patterns[index];
32592
- if (pattern(path21, stats)) {
32592
+ if (pattern(path20, stats)) {
32593
32593
  return true;
32594
32594
  }
32595
32595
  }
@@ -32627,19 +32627,19 @@ var toUnix = (string) => {
32627
32627
  }
32628
32628
  return str;
32629
32629
  };
32630
- var normalizePathToUnix = (path21) => toUnix(sp2.normalize(toUnix(path21)));
32631
- var normalizeIgnored = (cwd = "") => (path21) => {
32632
- if (typeof path21 === "string") {
32633
- return normalizePathToUnix(sp2.isAbsolute(path21) ? path21 : sp2.join(cwd, path21));
32630
+ var normalizePathToUnix = (path20) => toUnix(sp2.normalize(toUnix(path20)));
32631
+ var normalizeIgnored = (cwd = "") => (path20) => {
32632
+ if (typeof path20 === "string") {
32633
+ return normalizePathToUnix(sp2.isAbsolute(path20) ? path20 : sp2.join(cwd, path20));
32634
32634
  } else {
32635
- return path21;
32635
+ return path20;
32636
32636
  }
32637
32637
  };
32638
- var getAbsolutePath = (path21, cwd) => {
32639
- if (sp2.isAbsolute(path21)) {
32640
- return path21;
32638
+ var getAbsolutePath = (path20, cwd) => {
32639
+ if (sp2.isAbsolute(path20)) {
32640
+ return path20;
32641
32641
  }
32642
- return sp2.join(cwd, path21);
32642
+ return sp2.join(cwd, path20);
32643
32643
  };
32644
32644
  var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
32645
32645
  var DirEntry = class {
@@ -32704,10 +32704,10 @@ var WatchHelper = class {
32704
32704
  dirParts;
32705
32705
  followSymlinks;
32706
32706
  statMethod;
32707
- constructor(path21, follow, fsw) {
32707
+ constructor(path20, follow, fsw) {
32708
32708
  this.fsw = fsw;
32709
- const watchPath = path21;
32710
- this.path = path21 = path21.replace(REPLACER_RE, "");
32709
+ const watchPath = path20;
32710
+ this.path = path20 = path20.replace(REPLACER_RE, "");
32711
32711
  this.watchPath = watchPath;
32712
32712
  this.fullWatchPath = sp2.resolve(watchPath);
32713
32713
  this.dirParts = [];
@@ -32847,20 +32847,20 @@ var FSWatcher = class extends import_node_events.EventEmitter {
32847
32847
  this._closePromise = void 0;
32848
32848
  let paths = unifyPaths(paths_);
32849
32849
  if (cwd) {
32850
- paths = paths.map((path21) => {
32851
- const absPath = getAbsolutePath(path21, cwd);
32850
+ paths = paths.map((path20) => {
32851
+ const absPath = getAbsolutePath(path20, cwd);
32852
32852
  return absPath;
32853
32853
  });
32854
32854
  }
32855
- paths.forEach((path21) => {
32856
- this._removeIgnoredPath(path21);
32855
+ paths.forEach((path20) => {
32856
+ this._removeIgnoredPath(path20);
32857
32857
  });
32858
32858
  this._userIgnored = void 0;
32859
32859
  if (!this._readyCount)
32860
32860
  this._readyCount = 0;
32861
32861
  this._readyCount += paths.length;
32862
- Promise.all(paths.map(async (path21) => {
32863
- const res = await this._nodeFsHandler._addToNodeFs(path21, !_internal, void 0, 0, _origAdd);
32862
+ Promise.all(paths.map(async (path20) => {
32863
+ const res = await this._nodeFsHandler._addToNodeFs(path20, !_internal, void 0, 0, _origAdd);
32864
32864
  if (res)
32865
32865
  this._emitReady();
32866
32866
  return res;
@@ -32882,17 +32882,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
32882
32882
  return this;
32883
32883
  const paths = unifyPaths(paths_);
32884
32884
  const { cwd } = this.options;
32885
- paths.forEach((path21) => {
32886
- if (!sp2.isAbsolute(path21) && !this._closers.has(path21)) {
32885
+ paths.forEach((path20) => {
32886
+ if (!sp2.isAbsolute(path20) && !this._closers.has(path20)) {
32887
32887
  if (cwd)
32888
- path21 = sp2.join(cwd, path21);
32889
- path21 = sp2.resolve(path21);
32888
+ path20 = sp2.join(cwd, path20);
32889
+ path20 = sp2.resolve(path20);
32890
32890
  }
32891
- this._closePath(path21);
32892
- this._addIgnoredPath(path21);
32893
- if (this._watched.has(path21)) {
32891
+ this._closePath(path20);
32892
+ this._addIgnoredPath(path20);
32893
+ if (this._watched.has(path20)) {
32894
32894
  this._addIgnoredPath({
32895
- path: path21,
32895
+ path: path20,
32896
32896
  recursive: true
32897
32897
  });
32898
32898
  }
@@ -32956,38 +32956,38 @@ var FSWatcher = class extends import_node_events.EventEmitter {
32956
32956
  * @param stats arguments to be passed with event
32957
32957
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
32958
32958
  */
32959
- async _emit(event, path21, stats) {
32959
+ async _emit(event, path20, stats) {
32960
32960
  if (this.closed)
32961
32961
  return;
32962
32962
  const opts = this.options;
32963
32963
  if (isWindows)
32964
- path21 = sp2.normalize(path21);
32964
+ path20 = sp2.normalize(path20);
32965
32965
  if (opts.cwd)
32966
- path21 = sp2.relative(opts.cwd, path21);
32967
- const args = [path21];
32966
+ path20 = sp2.relative(opts.cwd, path20);
32967
+ const args = [path20];
32968
32968
  if (stats != null)
32969
32969
  args.push(stats);
32970
32970
  const awf = opts.awaitWriteFinish;
32971
32971
  let pw;
32972
- if (awf && (pw = this._pendingWrites.get(path21))) {
32972
+ if (awf && (pw = this._pendingWrites.get(path20))) {
32973
32973
  pw.lastChange = /* @__PURE__ */ new Date();
32974
32974
  return this;
32975
32975
  }
32976
32976
  if (opts.atomic) {
32977
32977
  if (event === EVENTS.UNLINK) {
32978
- this._pendingUnlinks.set(path21, [event, ...args]);
32978
+ this._pendingUnlinks.set(path20, [event, ...args]);
32979
32979
  setTimeout(() => {
32980
- this._pendingUnlinks.forEach((entry, path22) => {
32980
+ this._pendingUnlinks.forEach((entry, path21) => {
32981
32981
  this.emit(...entry);
32982
32982
  this.emit(EVENTS.ALL, ...entry);
32983
- this._pendingUnlinks.delete(path22);
32983
+ this._pendingUnlinks.delete(path21);
32984
32984
  });
32985
32985
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
32986
32986
  return this;
32987
32987
  }
32988
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path21)) {
32988
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path20)) {
32989
32989
  event = EVENTS.CHANGE;
32990
- this._pendingUnlinks.delete(path21);
32990
+ this._pendingUnlinks.delete(path20);
32991
32991
  }
32992
32992
  }
32993
32993
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -33005,16 +33005,16 @@ var FSWatcher = class extends import_node_events.EventEmitter {
33005
33005
  this.emitWithAll(event, args);
33006
33006
  }
33007
33007
  };
33008
- this._awaitWriteFinish(path21, awf.stabilityThreshold, event, awfEmit);
33008
+ this._awaitWriteFinish(path20, awf.stabilityThreshold, event, awfEmit);
33009
33009
  return this;
33010
33010
  }
33011
33011
  if (event === EVENTS.CHANGE) {
33012
- const isThrottled = !this._throttle(EVENTS.CHANGE, path21, 50);
33012
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path20, 50);
33013
33013
  if (isThrottled)
33014
33014
  return this;
33015
33015
  }
33016
33016
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
33017
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path21) : path21;
33017
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path20) : path20;
33018
33018
  let stats2;
33019
33019
  try {
33020
33020
  stats2 = await (0, import_promises5.stat)(fullPath);
@@ -33045,23 +33045,23 @@ var FSWatcher = class extends import_node_events.EventEmitter {
33045
33045
  * @param timeout duration of time to suppress duplicate actions
33046
33046
  * @returns tracking object or false if action should be suppressed
33047
33047
  */
33048
- _throttle(actionType, path21, timeout) {
33048
+ _throttle(actionType, path20, timeout) {
33049
33049
  if (!this._throttled.has(actionType)) {
33050
33050
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
33051
33051
  }
33052
33052
  const action = this._throttled.get(actionType);
33053
33053
  if (!action)
33054
33054
  throw new Error("invalid throttle");
33055
- const actionPath = action.get(path21);
33055
+ const actionPath = action.get(path20);
33056
33056
  if (actionPath) {
33057
33057
  actionPath.count++;
33058
33058
  return false;
33059
33059
  }
33060
33060
  let timeoutObject;
33061
33061
  const clear = () => {
33062
- const item = action.get(path21);
33062
+ const item = action.get(path20);
33063
33063
  const count = item ? item.count : 0;
33064
- action.delete(path21);
33064
+ action.delete(path20);
33065
33065
  clearTimeout(timeoutObject);
33066
33066
  if (item)
33067
33067
  clearTimeout(item.timeoutObject);
@@ -33069,7 +33069,7 @@ var FSWatcher = class extends import_node_events.EventEmitter {
33069
33069
  };
33070
33070
  timeoutObject = setTimeout(clear, timeout);
33071
33071
  const thr = { timeoutObject, clear, count: 0 };
33072
- action.set(path21, thr);
33072
+ action.set(path20, thr);
33073
33073
  return thr;
33074
33074
  }
33075
33075
  _incrReadyCount() {
@@ -33083,44 +33083,44 @@ var FSWatcher = class extends import_node_events.EventEmitter {
33083
33083
  * @param event
33084
33084
  * @param awfEmit Callback to be called when ready for event to be emitted.
33085
33085
  */
33086
- _awaitWriteFinish(path21, threshold, event, awfEmit) {
33086
+ _awaitWriteFinish(path20, threshold, event, awfEmit) {
33087
33087
  const awf = this.options.awaitWriteFinish;
33088
33088
  if (typeof awf !== "object")
33089
33089
  return;
33090
33090
  const pollInterval = awf.pollInterval;
33091
33091
  let timeoutHandler;
33092
- let fullPath = path21;
33093
- if (this.options.cwd && !sp2.isAbsolute(path21)) {
33094
- fullPath = sp2.join(this.options.cwd, path21);
33092
+ let fullPath = path20;
33093
+ if (this.options.cwd && !sp2.isAbsolute(path20)) {
33094
+ fullPath = sp2.join(this.options.cwd, path20);
33095
33095
  }
33096
33096
  const now = /* @__PURE__ */ new Date();
33097
33097
  const writes = this._pendingWrites;
33098
33098
  function awaitWriteFinishFn(prevStat) {
33099
33099
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
33100
- if (err || !writes.has(path21)) {
33100
+ if (err || !writes.has(path20)) {
33101
33101
  if (err && err.code !== "ENOENT")
33102
33102
  awfEmit(err);
33103
33103
  return;
33104
33104
  }
33105
33105
  const now2 = Number(/* @__PURE__ */ new Date());
33106
33106
  if (prevStat && curStat.size !== prevStat.size) {
33107
- writes.get(path21).lastChange = now2;
33107
+ writes.get(path20).lastChange = now2;
33108
33108
  }
33109
- const pw = writes.get(path21);
33109
+ const pw = writes.get(path20);
33110
33110
  const df = now2 - pw.lastChange;
33111
33111
  if (df >= threshold) {
33112
- writes.delete(path21);
33112
+ writes.delete(path20);
33113
33113
  awfEmit(void 0, curStat);
33114
33114
  } else {
33115
33115
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
33116
33116
  }
33117
33117
  });
33118
33118
  }
33119
- if (!writes.has(path21)) {
33120
- writes.set(path21, {
33119
+ if (!writes.has(path20)) {
33120
+ writes.set(path20, {
33121
33121
  lastChange: now,
33122
33122
  cancelWait: () => {
33123
- writes.delete(path21);
33123
+ writes.delete(path20);
33124
33124
  clearTimeout(timeoutHandler);
33125
33125
  return event;
33126
33126
  }
@@ -33131,8 +33131,8 @@ var FSWatcher = class extends import_node_events.EventEmitter {
33131
33131
  /**
33132
33132
  * Determines whether user has asked to ignore this path.
33133
33133
  */
33134
- _isIgnored(path21, stats) {
33135
- if (this.options.atomic && DOT_RE.test(path21))
33134
+ _isIgnored(path20, stats) {
33135
+ if (this.options.atomic && DOT_RE.test(path20))
33136
33136
  return true;
33137
33137
  if (!this._userIgnored) {
33138
33138
  const { cwd } = this.options;
@@ -33142,17 +33142,17 @@ var FSWatcher = class extends import_node_events.EventEmitter {
33142
33142
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
33143
33143
  this._userIgnored = anymatch(list, void 0);
33144
33144
  }
33145
- return this._userIgnored(path21, stats);
33145
+ return this._userIgnored(path20, stats);
33146
33146
  }
33147
- _isntIgnored(path21, stat11) {
33148
- return !this._isIgnored(path21, stat11);
33147
+ _isntIgnored(path20, stat11) {
33148
+ return !this._isIgnored(path20, stat11);
33149
33149
  }
33150
33150
  /**
33151
33151
  * Provides a set of common helpers and properties relating to symlink handling.
33152
33152
  * @param path file or directory pattern being watched
33153
33153
  */
33154
- _getWatchHelpers(path21) {
33155
- return new WatchHelper(path21, this.options.followSymlinks, this);
33154
+ _getWatchHelpers(path20) {
33155
+ return new WatchHelper(path20, this.options.followSymlinks, this);
33156
33156
  }
33157
33157
  // Directory helpers
33158
33158
  // -----------------
@@ -33184,63 +33184,63 @@ var FSWatcher = class extends import_node_events.EventEmitter {
33184
33184
  * @param item base path of item/directory
33185
33185
  */
33186
33186
  _remove(directory, item, isDirectory) {
33187
- const path21 = sp2.join(directory, item);
33188
- const fullPath = sp2.resolve(path21);
33189
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path21) || this._watched.has(fullPath);
33190
- if (!this._throttle("remove", path21, 100))
33187
+ const path20 = sp2.join(directory, item);
33188
+ const fullPath = sp2.resolve(path20);
33189
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path20) || this._watched.has(fullPath);
33190
+ if (!this._throttle("remove", path20, 100))
33191
33191
  return;
33192
33192
  if (!isDirectory && this._watched.size === 1) {
33193
33193
  this.add(directory, item, true);
33194
33194
  }
33195
- const wp = this._getWatchedDir(path21);
33195
+ const wp = this._getWatchedDir(path20);
33196
33196
  const nestedDirectoryChildren = wp.getChildren();
33197
- nestedDirectoryChildren.forEach((nested) => this._remove(path21, nested));
33197
+ nestedDirectoryChildren.forEach((nested) => this._remove(path20, nested));
33198
33198
  const parent = this._getWatchedDir(directory);
33199
33199
  const wasTracked = parent.has(item);
33200
33200
  parent.remove(item);
33201
33201
  if (this._symlinkPaths.has(fullPath)) {
33202
33202
  this._symlinkPaths.delete(fullPath);
33203
33203
  }
33204
- let relPath = path21;
33204
+ let relPath = path20;
33205
33205
  if (this.options.cwd)
33206
- relPath = sp2.relative(this.options.cwd, path21);
33206
+ relPath = sp2.relative(this.options.cwd, path20);
33207
33207
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
33208
33208
  const event = this._pendingWrites.get(relPath).cancelWait();
33209
33209
  if (event === EVENTS.ADD)
33210
33210
  return;
33211
33211
  }
33212
- this._watched.delete(path21);
33212
+ this._watched.delete(path20);
33213
33213
  this._watched.delete(fullPath);
33214
33214
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
33215
- if (wasTracked && !this._isIgnored(path21))
33216
- this._emit(eventName, path21);
33217
- this._closePath(path21);
33215
+ if (wasTracked && !this._isIgnored(path20))
33216
+ this._emit(eventName, path20);
33217
+ this._closePath(path20);
33218
33218
  }
33219
33219
  /**
33220
33220
  * Closes all watchers for a path
33221
33221
  */
33222
- _closePath(path21) {
33223
- this._closeFile(path21);
33224
- const dir = sp2.dirname(path21);
33225
- this._getWatchedDir(dir).remove(sp2.basename(path21));
33222
+ _closePath(path20) {
33223
+ this._closeFile(path20);
33224
+ const dir = sp2.dirname(path20);
33225
+ this._getWatchedDir(dir).remove(sp2.basename(path20));
33226
33226
  }
33227
33227
  /**
33228
33228
  * Closes only file-specific watchers
33229
33229
  */
33230
- _closeFile(path21) {
33231
- const closers = this._closers.get(path21);
33230
+ _closeFile(path20) {
33231
+ const closers = this._closers.get(path20);
33232
33232
  if (!closers)
33233
33233
  return;
33234
33234
  closers.forEach((closer) => closer());
33235
- this._closers.delete(path21);
33235
+ this._closers.delete(path20);
33236
33236
  }
33237
- _addPathCloser(path21, closer) {
33237
+ _addPathCloser(path20, closer) {
33238
33238
  if (!closer)
33239
33239
  return;
33240
- let list = this._closers.get(path21);
33240
+ let list = this._closers.get(path20);
33241
33241
  if (!list) {
33242
33242
  list = [];
33243
- this._closers.set(path21, list);
33243
+ this._closers.set(path20, list);
33244
33244
  }
33245
33245
  list.push(closer);
33246
33246
  }
@@ -34704,12 +34704,12 @@ function encodeURIPath(str) {
34704
34704
  return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
34705
34705
  }
34706
34706
  var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
34707
- var createPathTagFunction = (pathEncoder = encodeURIPath) => function path21(statics, ...params) {
34707
+ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path20(statics, ...params) {
34708
34708
  if (statics.length === 1)
34709
34709
  return statics[0];
34710
34710
  let postPath = false;
34711
34711
  const invalidSegments = [];
34712
- const path22 = statics.reduce((previousValue, currentValue, index) => {
34712
+ const path21 = statics.reduce((previousValue, currentValue, index) => {
34713
34713
  if (/[?#]/.test(currentValue)) {
34714
34714
  postPath = true;
34715
34715
  }
@@ -34726,7 +34726,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path21(sta
34726
34726
  }
34727
34727
  return previousValue + currentValue + (index === params.length ? "" : encoded);
34728
34728
  }, "");
34729
- const pathOnly = path22.split(/[?#]/, 1)[0];
34729
+ const pathOnly = path21.split(/[?#]/, 1)[0];
34730
34730
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
34731
34731
  let match2;
34732
34732
  while ((match2 = invalidSegmentPattern.exec(pathOnly)) !== null) {
@@ -34747,10 +34747,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path21(sta
34747
34747
  }, "");
34748
34748
  throw new AnthropicError(`Path parameters result in path with invalid segments:
34749
34749
  ${invalidSegments.map((e) => e.error).join("\n")}
34750
- ${path22}
34750
+ ${path21}
34751
34751
  ${underline}`);
34752
34752
  }
34753
- return path22;
34753
+ return path21;
34754
34754
  };
34755
34755
  var path5 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
34756
34756
 
@@ -37861,9 +37861,9 @@ var BaseAnthropic = class {
37861
37861
  makeStatusError(status, error, message, headers) {
37862
37862
  return APIError.generate(status, error, message, headers);
37863
37863
  }
37864
- buildURL(path21, query, defaultBaseURL) {
37864
+ buildURL(path20, query, defaultBaseURL) {
37865
37865
  const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
37866
- const url = isAbsoluteURL(path21) ? new URL(path21) : new URL(baseURL + (baseURL.endsWith("/") && path21.startsWith("/") ? path21.slice(1) : path21));
37866
+ const url = isAbsoluteURL(path20) ? new URL(path20) : new URL(baseURL + (baseURL.endsWith("/") && path20.startsWith("/") ? path20.slice(1) : path20));
37867
37867
  const defaultQuery = this.defaultQuery();
37868
37868
  if (!isEmptyObj(defaultQuery)) {
37869
37869
  query = { ...defaultQuery, ...query };
@@ -37894,24 +37894,24 @@ var BaseAnthropic = class {
37894
37894
  */
37895
37895
  async prepareRequest(request, { url, options }) {
37896
37896
  }
37897
- get(path21, opts) {
37898
- return this.methodRequest("get", path21, opts);
37897
+ get(path20, opts) {
37898
+ return this.methodRequest("get", path20, opts);
37899
37899
  }
37900
- post(path21, opts) {
37901
- return this.methodRequest("post", path21, opts);
37900
+ post(path20, opts) {
37901
+ return this.methodRequest("post", path20, opts);
37902
37902
  }
37903
- patch(path21, opts) {
37904
- return this.methodRequest("patch", path21, opts);
37903
+ patch(path20, opts) {
37904
+ return this.methodRequest("patch", path20, opts);
37905
37905
  }
37906
- put(path21, opts) {
37907
- return this.methodRequest("put", path21, opts);
37906
+ put(path20, opts) {
37907
+ return this.methodRequest("put", path20, opts);
37908
37908
  }
37909
- delete(path21, opts) {
37910
- return this.methodRequest("delete", path21, opts);
37909
+ delete(path20, opts) {
37910
+ return this.methodRequest("delete", path20, opts);
37911
37911
  }
37912
- methodRequest(method, path21, opts) {
37912
+ methodRequest(method, path20, opts) {
37913
37913
  return this.request(Promise.resolve(opts).then((opts2) => {
37914
- return { method, path: path21, ...opts2 };
37914
+ return { method, path: path20, ...opts2 };
37915
37915
  }));
37916
37916
  }
37917
37917
  request(options, remainingRetries = null) {
@@ -38015,8 +38015,8 @@ var BaseAnthropic = class {
38015
38015
  }));
38016
38016
  return { response, options, controller, requestLogID, retryOfRequestLogID, startTime: startTime2 };
38017
38017
  }
38018
- getAPIList(path21, Page2, opts) {
38019
- return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path21, ...opts2 })) : { method: "get", path: path21, ...opts });
38018
+ getAPIList(path20, Page2, opts) {
38019
+ return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path20, ...opts2 })) : { method: "get", path: path20, ...opts });
38020
38020
  }
38021
38021
  requestAPIList(Page2, options) {
38022
38022
  const request = this.makeRequest(options, null, void 0);
@@ -38104,8 +38104,8 @@ var BaseAnthropic = class {
38104
38104
  }
38105
38105
  async buildRequest(inputOptions, { retryCount = 0 } = {}) {
38106
38106
  const options = { ...inputOptions };
38107
- const { method, path: path21, query, defaultBaseURL } = options;
38108
- const url = this.buildURL(path21, query, defaultBaseURL);
38107
+ const { method, path: path20, query, defaultBaseURL } = options;
38108
+ const url = this.buildURL(path20, query, defaultBaseURL);
38109
38109
  if ("timeout" in options)
38110
38110
  validatePositiveInteger("timeout", options.timeout);
38111
38111
  options.timeout = options.timeout ?? this.timeout;
@@ -38927,6 +38927,19 @@ async function reportRuntimeActivity(input) {
38927
38927
  }
38928
38928
  }
38929
38929
 
38930
+ // src/tools/UserRecoverableToolError.ts
38931
+ var UserRecoverableToolError = class extends Error {
38932
+ userMessage;
38933
+ code;
38934
+ constructor(code, userMessage2, detail) {
38935
+ super(detail ? `${code}: ${detail}` : code);
38936
+ this.name = "UserRecoverableToolError";
38937
+ this.code = code;
38938
+ this.userMessage = userMessage2;
38939
+ }
38940
+ };
38941
+ var isUserRecoverableToolError = (error) => error instanceof UserRecoverableToolError || typeof error === "object" && error !== null && error.name === "UserRecoverableToolError" && typeof error.userMessage === "string";
38942
+
38930
38943
  // src/tools/ToolExecutor.ts
38931
38944
  var createToolExecutor = (registry2) => {
38932
38945
  return {
@@ -38979,6 +38992,9 @@ var createToolExecutor = (registry2) => {
38979
38992
  error: err.message
38980
38993
  }
38981
38994
  });
38995
+ if (isUserRecoverableToolError(error)) {
38996
+ throw error;
38997
+ }
38982
38998
  return `\u5DE5\u5177\u6267\u884C\u5931\u8D25 [${name}], reason: ${err.message}`;
38983
38999
  }
38984
39000
  },
@@ -40210,16 +40226,16 @@ var Diff = class {
40210
40226
  }
40211
40227
  }
40212
40228
  }
40213
- addToPath(path21, added, removed, oldPosInc, options) {
40214
- const last = path21.lastComponent;
40229
+ addToPath(path20, added, removed, oldPosInc, options) {
40230
+ const last = path20.lastComponent;
40215
40231
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
40216
40232
  return {
40217
- oldPos: path21.oldPos + oldPosInc,
40233
+ oldPos: path20.oldPos + oldPosInc,
40218
40234
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
40219
40235
  };
40220
40236
  } else {
40221
40237
  return {
40222
- oldPos: path21.oldPos + oldPosInc,
40238
+ oldPos: path20.oldPos + oldPosInc,
40223
40239
  lastComponent: { count: 1, added, removed, previousComponent: last }
40224
40240
  };
40225
40241
  }
@@ -41354,7 +41370,6 @@ var cronUpdate = {
41354
41370
 
41355
41371
  // src/tools/tools/ImageUnderstand.ts
41356
41372
  var import_fs9 = __toESM(require("fs"));
41357
- var import_path15 = __toESM(require("path"));
41358
41373
 
41359
41374
  // src/types/builders.ts
41360
41375
  var text = (text2) => ({
@@ -41532,36 +41547,74 @@ var guessMediaTypeFromHeader = (contentType) => {
41532
41547
  if (contentType.includes("image/webp")) return "image/webp";
41533
41548
  return null;
41534
41549
  };
41535
- var guessMediaTypeFromExt = (filePath) => {
41536
- const ext = import_path15.default.extname(filePath).toLowerCase();
41537
- if (ext === ".jpg" || ext === ".jpeg") return "image/jpeg";
41538
- if (ext === ".png") return "image/png";
41539
- if (ext === ".gif") return "image/gif";
41540
- if (ext === ".webp") return "image/webp";
41541
- return null;
41550
+ var controlPlaneBaseUrl = () => {
41551
+ return process.env.DUCLAW_CONTROL_PLANE_BASE_URL?.replace(/\/$/, "");
41552
+ };
41553
+ var USER_IMAGE_REUPLOAD_MESSAGE = `\u8FD9\u5F20\u56FE\u7247\u6682\u65F6\u65E0\u6CD5\u6309\u56FE\u7247\u683C\u5F0F\u89E3\u6790\u3002\u8BF7\u91CD\u65B0\u53D1\u9001 JPG/PNG/WebP \u56FE\u7247\uFF0C\u6216\u8005\u5728\u624B\u673A\u4E0A\u622A\u56FE\u540E\u518D\u53D1\u4E00\u6B21\u3002`;
41554
+ var normalizeRuntimeAttachmentUrl = (input) => {
41555
+ return input.replace("/api/mobile/attachments/", "/internal/runtime/mobile/attachments/");
41556
+ };
41557
+ var resolveRemoteUrl = (input) => {
41558
+ if (/^https?:\/\//i.test(input)) return normalizeRuntimeAttachmentUrl(input);
41559
+ const baseUrl = controlPlaneBaseUrl();
41560
+ if (baseUrl && (input.startsWith("/internal/") || input.startsWith("/api/mobile/attachments/"))) {
41561
+ return `${baseUrl}${normalizeRuntimeAttachmentUrl(input)}`;
41562
+ }
41563
+ return void 0;
41564
+ };
41565
+ var shouldAttachRuntimeAuth = (url) => {
41566
+ const baseUrl = controlPlaneBaseUrl();
41567
+ if (!baseUrl || !url.includes("/internal/runtime/mobile/attachments/")) return false;
41568
+ try {
41569
+ return new URL(url).origin === new URL(baseUrl).origin;
41570
+ } catch {
41571
+ return false;
41572
+ }
41573
+ };
41574
+ var unsupportedImageFormatError = (detail) => new UserRecoverableToolError("unsupported_image_format", USER_IMAGE_REUPLOAD_MESSAGE, detail);
41575
+ var imageBlockFromBuffer = (buffer, contentType, sourceHint) => {
41576
+ const base64Data = buffer.toString("base64");
41577
+ const mediaType = guessMediaTypeFromData(base64Data) ?? guessMediaTypeFromHeader(contentType);
41578
+ if (!mediaType) {
41579
+ throw unsupportedImageFormatError(`${sourceHint} content-type=${contentType || "unknown"}`);
41580
+ }
41581
+ console.log(`[ImageUnderstand] \u63A8\u65AD\u5A92\u4F53\u7C7B\u578B: ${mediaType} (content-type: ${contentType || "unknown"})`);
41582
+ return imageBase64(base64Data, mediaType);
41583
+ };
41584
+ var isUnsupportedProviderImageError = (error) => {
41585
+ const message = error instanceof Error ? error.message : String(error);
41586
+ return /unsupported image format|application\/octet-stream|invalid image/i.test(message);
41542
41587
  };
41543
41588
  var resolveImageBlock = async (input) => {
41544
- if (input.startsWith("http://") || input.startsWith("https://")) {
41545
- console.log(`[ImageUnderstand] \u4E0B\u8F7D\u56FE\u7247: ${input.substring(0, 80)}...`);
41546
- const res = await fetch(input);
41589
+ const remoteUrl = resolveRemoteUrl(input);
41590
+ if (remoteUrl) {
41591
+ console.log(`[ImageUnderstand] \u4E0B\u8F7D\u56FE\u7247: ${remoteUrl.substring(0, 80)}...`);
41592
+ const headers = {};
41593
+ const runtimeToken = process.env.DUCLAW_CONTROL_PLANE_METERING_TOKEN;
41594
+ if (runtimeToken && shouldAttachRuntimeAuth(remoteUrl)) {
41595
+ headers.authorization = `Bearer ${runtimeToken}`;
41596
+ }
41597
+ const res = await fetch(remoteUrl, { headers });
41547
41598
  if (!res.ok) throw new Error(`[ImageUnderstand] \u56FE\u7247\u4E0B\u8F7D\u5931\u8D25: ${res.status} ${res.statusText}`);
41548
41599
  const contentType = res.headers.get("content-type") || "";
41549
41600
  const buffer = Buffer.from(await res.arrayBuffer());
41550
- const base64Data = buffer.toString("base64");
41551
- const mediaType2 = guessMediaTypeFromData(base64Data) ?? guessMediaTypeFromHeader(contentType) ?? "image/png";
41552
- console.log(`[ImageUnderstand] \u63A8\u65AD\u5A92\u4F53\u7C7B\u578B: ${mediaType2} (content-type: ${contentType})`);
41553
- return imageBase64(base64Data, mediaType2);
41601
+ return imageBlockFromBuffer(buffer, contentType, remoteUrl);
41554
41602
  }
41555
41603
  if (input.startsWith("/") || input.startsWith(".") || /^[A-Za-z]:[\\/]/.test(input)) {
41556
41604
  if (!import_fs9.default.existsSync(input)) throw new Error(`[ImageUnderstand] \u672C\u5730\u6587\u4EF6\u4E0D\u5B58\u5728: ${input}`);
41557
41605
  console.log(`[ImageUnderstand] \u8BFB\u53D6\u672C\u5730\u6587\u4EF6: ${input}`);
41558
41606
  const buffer = import_fs9.default.readFileSync(input);
41559
- const base64Data = buffer.toString("base64");
41560
- const mediaType2 = guessMediaTypeFromExt(input) ?? guessMediaTypeFromData(base64Data) ?? "image/png";
41607
+ const mediaType2 = guessMediaTypeFromData(buffer.toString("base64"));
41608
+ if (!mediaType2) {
41609
+ throw unsupportedImageFormatError(input);
41610
+ }
41561
41611
  console.log(`[ImageUnderstand] \u63A8\u65AD\u5A92\u4F53\u7C7B\u578B: ${mediaType2}`);
41562
- return imageBase64(base64Data, mediaType2);
41612
+ return imageBase64(buffer.toString("base64"), mediaType2);
41613
+ }
41614
+ const mediaType = guessMediaTypeFromData(input);
41615
+ if (!mediaType) {
41616
+ throw unsupportedImageFormatError("base64 data magic bytes not recognized");
41563
41617
  }
41564
- const mediaType = guessMediaTypeFromData(input) ?? "image/png";
41565
41618
  return imageBase64(input, mediaType);
41566
41619
  };
41567
41620
  var imageUnderstand = {
@@ -41608,7 +41661,12 @@ var imageUnderstand = {
41608
41661
  const response = await llmClient.chat(
41609
41662
  [imageMessage],
41610
41663
  system
41611
- );
41664
+ ).catch((error) => {
41665
+ if (isUnsupportedProviderImageError(error)) {
41666
+ throw unsupportedImageFormatError(error instanceof Error ? error.message : String(error));
41667
+ }
41668
+ throw error;
41669
+ });
41612
41670
  const resultText = extractText(response.content);
41613
41671
  await reportImageUnderstandUsage({
41614
41672
  baseUrl: process.env.DUCLAW_CONTROL_PLANE_BASE_URL,
@@ -41631,18 +41689,18 @@ var imageUnderstand = {
41631
41689
  // src/skill/SkillRegistry.ts
41632
41690
  var import_fs11 = require("fs");
41633
41691
  var import_os3 = require("os");
41634
- var import_path17 = __toESM(require("path"));
41692
+ var import_path16 = __toESM(require("path"));
41635
41693
 
41636
41694
  // src/runtime/paths.ts
41637
41695
  var import_fs10 = require("fs");
41638
- var import_path16 = __toESM(require("path"));
41696
+ var import_path15 = __toESM(require("path"));
41639
41697
  var findProjectRoot = (filename = "duclaw.json", startDir = process.cwd()) => {
41640
41698
  let currentDir = startDir;
41641
41699
  while (true) {
41642
- if ((0, import_fs10.existsSync)((0, import_path16.join)(currentDir, filename))) {
41700
+ if ((0, import_fs10.existsSync)((0, import_path15.join)(currentDir, filename))) {
41643
41701
  return currentDir;
41644
41702
  }
41645
- const parentDir = (0, import_path16.dirname)(currentDir);
41703
+ const parentDir = (0, import_path15.dirname)(currentDir);
41646
41704
  if (parentDir === currentDir) {
41647
41705
  return null;
41648
41706
  }
@@ -41651,12 +41709,12 @@ var findProjectRoot = (filename = "duclaw.json", startDir = process.cwd()) => {
41651
41709
  };
41652
41710
  var resolveCoreRoot = () => {
41653
41711
  const candidates = [
41654
- import_path16.default.resolve(__dirname_m, ".."),
41655
- import_path16.default.resolve(__dirname_m, "..", ".."),
41712
+ import_path15.default.resolve(__dirname_m, ".."),
41713
+ import_path15.default.resolve(__dirname_m, "..", ".."),
41656
41714
  process.cwd()
41657
41715
  ];
41658
41716
  for (const candidate of candidates) {
41659
- if ((0, import_fs10.existsSync)(import_path16.default.join(candidate, "web", "dist", "index.html"))) {
41717
+ if ((0, import_fs10.existsSync)(import_path15.default.join(candidate, "web", "dist", "index.html"))) {
41660
41718
  return candidate;
41661
41719
  }
41662
41720
  }
@@ -41665,11 +41723,11 @@ var resolveCoreRoot = () => {
41665
41723
  var resolveWebDistRoot = () => {
41666
41724
  const coreRoot = resolveCoreRoot();
41667
41725
  const candidates = [
41668
- import_path16.default.join(coreRoot, "dist", "web"),
41669
- import_path16.default.join(coreRoot, "web", "dist")
41726
+ import_path15.default.join(coreRoot, "dist", "web"),
41727
+ import_path15.default.join(coreRoot, "web", "dist")
41670
41728
  ];
41671
41729
  for (const candidate of candidates) {
41672
- if ((0, import_fs10.existsSync)(import_path16.default.join(candidate, "index.html"))) {
41730
+ if ((0, import_fs10.existsSync)(import_path15.default.join(candidate, "index.html"))) {
41673
41731
  return candidate;
41674
41732
  }
41675
41733
  }
@@ -41679,14 +41737,14 @@ var resolveWebDistRoot = () => {
41679
41737
  // src/skill/SkillRegistry.ts
41680
41738
  var getProjectSkillsPath = () => {
41681
41739
  const projectRoot = findProjectRoot();
41682
- return projectRoot ? (0, import_path17.join)(projectRoot, "skills") : null;
41740
+ return projectRoot ? (0, import_path16.join)(projectRoot, "skills") : null;
41683
41741
  };
41684
41742
  var getSkillPaths = () => {
41685
41743
  const paths = [];
41686
41744
  const seenPaths = /* @__PURE__ */ new Set();
41687
41745
  const pushPath = (candidate) => {
41688
41746
  if (!(0, import_fs11.existsSync)(candidate) || !(0, import_fs11.statSync)(candidate).isDirectory()) return;
41689
- const normalized = import_path17.default.resolve(candidate);
41747
+ const normalized = import_path16.default.resolve(candidate);
41690
41748
  if (seenPaths.has(normalized)) return;
41691
41749
  seenPaths.add(normalized);
41692
41750
  paths.push(normalized);
@@ -41695,12 +41753,12 @@ var getSkillPaths = () => {
41695
41753
  if (projectSkillsPath) {
41696
41754
  pushPath(projectSkillsPath);
41697
41755
  }
41698
- pushPath((0, import_path17.join)((0, import_os3.homedir)(), ".duclaw", "skills"));
41699
- pushPath((0, import_path17.join)((0, import_os3.homedir)(), ".agents", "skills"));
41756
+ pushPath((0, import_path16.join)((0, import_os3.homedir)(), ".duclaw", "skills"));
41757
+ pushPath((0, import_path16.join)((0, import_os3.homedir)(), ".agents", "skills"));
41700
41758
  return paths;
41701
41759
  };
41702
41760
  var getDirectories = (dirPath) => {
41703
- return (0, import_fs11.readdirSync)(dirPath).filter((name) => (0, import_fs11.statSync)((0, import_path17.join)(dirPath, name)).isDirectory());
41761
+ return (0, import_fs11.readdirSync)(dirPath).filter((name) => (0, import_fs11.statSync)((0, import_path16.join)(dirPath, name)).isDirectory());
41704
41762
  };
41705
41763
  var parseSkill = (mdPath, skillDir) => {
41706
41764
  if (!(0, import_fs11.existsSync)(mdPath)) return null;
@@ -41720,14 +41778,14 @@ var parseSkill = (mdPath, skillDir) => {
41720
41778
  }
41721
41779
  }
41722
41780
  if (!name) {
41723
- name = import_path17.default.basename(import_path17.default.dirname(mdPath));
41781
+ name = import_path16.default.basename(import_path16.default.dirname(mdPath));
41724
41782
  }
41725
41783
  if (!description && body) {
41726
41784
  description = body.split("\n")[0].replace(/^#+\s*/, "").trim();
41727
41785
  }
41728
41786
  const projectSkillsPath = getProjectSkillsPath();
41729
- const normalizedSkillDir = import_path17.default.resolve(skillDir);
41730
- const deletable = projectSkillsPath ? normalizedSkillDir === import_path17.default.resolve(projectSkillsPath, import_path17.default.basename(normalizedSkillDir)) && normalizedSkillDir.startsWith(import_path17.default.resolve(projectSkillsPath) + import_path17.default.sep) : false;
41787
+ const normalizedSkillDir = import_path16.default.resolve(skillDir);
41788
+ const deletable = projectSkillsPath ? normalizedSkillDir === import_path16.default.resolve(projectSkillsPath, import_path16.default.basename(normalizedSkillDir)) && normalizedSkillDir.startsWith(import_path16.default.resolve(projectSkillsPath) + import_path16.default.sep) : false;
41731
41789
  return {
41732
41790
  name,
41733
41791
  description,
@@ -41749,8 +41807,8 @@ var loadSkill = () => {
41749
41807
  for (const skillPath of skillPaths) {
41750
41808
  const dirs = getDirectories(skillPath);
41751
41809
  for (const skillName of dirs) {
41752
- const eachSkillPath = (0, import_path17.join)(skillPath, skillName);
41753
- const eachSkillMdPath = (0, import_path17.join)(eachSkillPath, "SKILL.md");
41810
+ const eachSkillPath = (0, import_path16.join)(skillPath, skillName);
41811
+ const eachSkillMdPath = (0, import_path16.join)(eachSkillPath, "SKILL.md");
41754
41812
  const skill = parseSkill(eachSkillMdPath, eachSkillPath);
41755
41813
  if (skill && !seen.has(skill.name)) {
41756
41814
  seen.add(skill.name);
@@ -42378,29 +42436,29 @@ var listMailboxEvents = (params) => {
42378
42436
 
42379
42437
  // src/department/DepartmentMember.ts
42380
42438
  var import_fs13 = require("fs");
42381
- var import_path19 = __toESM(require("path"));
42439
+ var import_path18 = __toESM(require("path"));
42382
42440
 
42383
42441
  // src/department/Department.ts
42384
- var import_path18 = __toESM(require("path"));
42442
+ var import_path17 = __toESM(require("path"));
42385
42443
  var import_fs12 = require("fs");
42386
42444
  var legacyMigrationChecked = false;
42387
42445
  var getDepartmentBaseDir = () => {
42388
- return import_path18.default.join(getDuclawHomeDir(), "department");
42446
+ return import_path17.default.join(getDuclawHomeDir(), "department");
42389
42447
  };
42390
42448
  var getLegacyTeamBaseDir = () => {
42391
- return import_path18.default.join(getDuclawHomeDir(), "team");
42449
+ return import_path17.default.join(getDuclawHomeDir(), "team");
42392
42450
  };
42393
42451
  var getDepartmentWorkSpaceDir = (departmentName) => {
42394
- return import_path18.default.join(getDepartmentBaseDir(), "workspace", departmentName);
42452
+ return import_path17.default.join(getDepartmentBaseDir(), "workspace", departmentName);
42395
42453
  };
42396
42454
  var getLegacyTeamWorkSpaceDir = (teamName) => {
42397
- return import_path18.default.join(getLegacyTeamBaseDir(), "workspace", teamName);
42455
+ return import_path17.default.join(getLegacyTeamBaseDir(), "workspace", teamName);
42398
42456
  };
42399
42457
  var getDepartmentJsonPath = (departmentName) => {
42400
- return import_path18.default.join(getDepartmentWorkSpaceDir(departmentName), "department.json");
42458
+ return import_path17.default.join(getDepartmentWorkSpaceDir(departmentName), "department.json");
42401
42459
  };
42402
42460
  var getLegacyTeamJsonPath = (teamName) => {
42403
- return import_path18.default.join(getLegacyTeamWorkSpaceDir(teamName), "team.json");
42461
+ return import_path17.default.join(getLegacyTeamWorkSpaceDir(teamName), "team.json");
42404
42462
  };
42405
42463
  var mapLegacyRole = (role) => {
42406
42464
  return role === "team_manager" ? "department_head" : "executor";
@@ -42429,7 +42487,7 @@ var mapLegacyDepartment = (legacy) => {
42429
42487
  var migrateLegacyTeamsToDepartments = () => {
42430
42488
  if (legacyMigrationChecked) return;
42431
42489
  legacyMigrationChecked = true;
42432
- const legacyWorkspaceDir = import_path18.default.join(getLegacyTeamBaseDir(), "workspace");
42490
+ const legacyWorkspaceDir = import_path17.default.join(getLegacyTeamBaseDir(), "workspace");
42433
42491
  if (!(0, import_fs12.existsSync)(legacyWorkspaceDir)) return;
42434
42492
  for (const legacyName of (0, import_fs12.readdirSync)(legacyWorkspaceDir)) {
42435
42493
  const legacyJsonPath = getLegacyTeamJsonPath(legacyName);
@@ -42462,7 +42520,7 @@ var getDepartment = (name) => {
42462
42520
  };
42463
42521
  var listDepartments = () => {
42464
42522
  migrateLegacyTeamsToDepartments();
42465
- const workspaceDir = import_path18.default.join(getDepartmentBaseDir(), "workspace");
42523
+ const workspaceDir = import_path17.default.join(getDepartmentBaseDir(), "workspace");
42466
42524
  if (!(0, import_fs12.existsSync)(workspaceDir)) return [];
42467
42525
  const departments = [];
42468
42526
  for (const departmentName of (0, import_fs12.readdirSync)(workspaceDir)) {
@@ -42507,7 +42565,7 @@ var createDepartmentMember = (departmentMemberDefinition) => {
42507
42565
  const { name, departmentId, workspaceId } = departmentMemberDefinition;
42508
42566
  const department = getDepartmentById(departmentId);
42509
42567
  if (!department) throw new Error(`[createDepartmentMember] \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 department: ${departmentId}`);
42510
- const memberPath = import_path19.default.join(getDepartmentWorkSpaceDir(department.name), name);
42568
+ const memberPath = import_path18.default.join(getDepartmentWorkSpaceDir(department.name), name);
42511
42569
  (0, import_fs13.mkdirSync)(memberPath, { recursive: true });
42512
42570
  const workspace = {
42513
42571
  id: getWorkspaceId(department.name, departmentMemberDefinition.name),
@@ -46699,6 +46757,7 @@ ${memoryInjection}` : "") + dreamInjection;
46699
46757
  if (toolUses.length > 0) {
46700
46758
  await addMessage(storage, userId, assistantMessageFromResponse(response), beijingTime, job?.title);
46701
46759
  if (toolExecutor) {
46760
+ const userRecoverableMessages = [];
46702
46761
  const toolResultPromises = toolUses.map(async (useBlock) => {
46703
46762
  if (signal.aborted) {
46704
46763
  return toolResult(useBlock.id, `\u5DE5\u5177\u6267\u884C\u88AB\u4E2D\u65AD`);
@@ -46755,6 +46814,10 @@ ${memoryInjection}` : "") + dreamInjection;
46755
46814
  return toolResult(useBlock.id, result);
46756
46815
  } catch (error) {
46757
46816
  const err = error;
46817
+ if (isUserRecoverableToolError(error)) {
46818
+ userRecoverableMessages.push(error.userMessage);
46819
+ return toolResult(useBlock.id, `${useBlock.name}\u5DE5\u5177\u9700\u8981\u7528\u6237\u8865\u5145\u8F93\u5165,reason: ${err.message}`);
46820
+ }
46758
46821
  return toolResult(useBlock.id, `${useBlock.name}\u5DE5\u5177\u6267\u884C\u9519\u8BEF,reason: ${err.message}`);
46759
46822
  }
46760
46823
  });
@@ -46762,6 +46825,30 @@ ${memoryInjection}` : "") + dreamInjection;
46762
46825
  if (toolResults.length > 0) {
46763
46826
  await addMessage(storage, userId, { role: "user", content: toolResults }, beijingTime, job?.title);
46764
46827
  }
46828
+ const userRecoverableMessage = userRecoverableMessages[0]?.trim();
46829
+ if (userRecoverableMessage) {
46830
+ let recoverableMessageSent = false;
46831
+ if (config2.channelPlugin && !internalOnly) {
46832
+ if (claimOutboundSend(request.userId, userRecoverableMessage)) {
46833
+ await config2.channelPlugin.outbound.sendText({
46834
+ cfg: {},
46835
+ to: request.userId,
46836
+ text: userRecoverableMessage,
46837
+ accountId: request.requestId,
46838
+ metadata: request.metadata
46839
+ });
46840
+ recoverableMessageSent = true;
46841
+ } else {
46842
+ console.log(`[outbound-dedup] \u8DF3\u8FC7\u5BF9\u7528\u6237 ${request.userId} \u7684\u8FD1\u91CD\u590D\u53EF\u6062\u590D\u9519\u8BEF\u63D0\u793A`);
46843
+ }
46844
+ }
46845
+ await addMessage(storage, userId, assistantMessage(text(userRecoverableMessage)), beijingTime, job?.title);
46846
+ markAgentEventsHandled([...injectedEventIds]);
46847
+ return {
46848
+ content: userRecoverableMessage,
46849
+ alreadySent: recoverableMessageSent
46850
+ };
46851
+ }
46765
46852
  }
46766
46853
  continue;
46767
46854
  }
@@ -48311,26 +48398,26 @@ var handleParsingNestedValues = (form, key, value) => {
48311
48398
  };
48312
48399
 
48313
48400
  // node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/utils/url.js
48314
- var splitPath = (path21) => {
48315
- const paths = path21.split("/");
48401
+ var splitPath = (path20) => {
48402
+ const paths = path20.split("/");
48316
48403
  if (paths[0] === "") {
48317
48404
  paths.shift();
48318
48405
  }
48319
48406
  return paths;
48320
48407
  };
48321
48408
  var splitRoutingPath = (routePath) => {
48322
- const { groups, path: path21 } = extractGroupsFromPath(routePath);
48323
- const paths = splitPath(path21);
48409
+ const { groups, path: path20 } = extractGroupsFromPath(routePath);
48410
+ const paths = splitPath(path20);
48324
48411
  return replaceGroupMarks(paths, groups);
48325
48412
  };
48326
- var extractGroupsFromPath = (path21) => {
48413
+ var extractGroupsFromPath = (path20) => {
48327
48414
  const groups = [];
48328
- path21 = path21.replace(/\{[^}]+\}/g, (match2, index) => {
48415
+ path20 = path20.replace(/\{[^}]+\}/g, (match2, index) => {
48329
48416
  const mark = `@${index}`;
48330
48417
  groups.push([mark, match2]);
48331
48418
  return mark;
48332
48419
  });
48333
- return { groups, path: path21 };
48420
+ return { groups, path: path20 };
48334
48421
  };
48335
48422
  var replaceGroupMarks = (paths, groups) => {
48336
48423
  for (let i = groups.length - 1; i >= 0; i--) {
@@ -48387,8 +48474,8 @@ var getPath = (request) => {
48387
48474
  const queryIndex = url.indexOf("?", i);
48388
48475
  const hashIndex = url.indexOf("#", i);
48389
48476
  const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
48390
- const path21 = url.slice(start, end);
48391
- return tryDecodeURI(path21.includes("%25") ? path21.replace(/%25/g, "%2525") : path21);
48477
+ const path20 = url.slice(start, end);
48478
+ return tryDecodeURI(path20.includes("%25") ? path20.replace(/%25/g, "%2525") : path20);
48392
48479
  } else if (charCode === 63 || charCode === 35) {
48393
48480
  break;
48394
48481
  }
@@ -48405,11 +48492,11 @@ var mergePath = (base, sub, ...rest) => {
48405
48492
  }
48406
48493
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
48407
48494
  };
48408
- var checkOptionalParameter = (path21) => {
48409
- if (path21.charCodeAt(path21.length - 1) !== 63 || !path21.includes(":")) {
48495
+ var checkOptionalParameter = (path20) => {
48496
+ if (path20.charCodeAt(path20.length - 1) !== 63 || !path20.includes(":")) {
48410
48497
  return null;
48411
48498
  }
48412
- const segments = path21.split("/");
48499
+ const segments = path20.split("/");
48413
48500
  const results = [];
48414
48501
  let basePath = "";
48415
48502
  segments.forEach((segment) => {
@@ -48550,9 +48637,9 @@ var HonoRequest = class {
48550
48637
  */
48551
48638
  path;
48552
48639
  bodyCache = {};
48553
- constructor(request, path21 = "/", matchResult = [[]]) {
48640
+ constructor(request, path20 = "/", matchResult = [[]]) {
48554
48641
  this.raw = request;
48555
- this.path = path21;
48642
+ this.path = path20;
48556
48643
  this.#matchResult = matchResult;
48557
48644
  this.#validatedData = {};
48558
48645
  }
@@ -49289,8 +49376,8 @@ var Hono = class _Hono {
49289
49376
  return this;
49290
49377
  };
49291
49378
  });
49292
- this.on = (method, path21, ...handlers) => {
49293
- for (const p of [path21].flat()) {
49379
+ this.on = (method, path20, ...handlers) => {
49380
+ for (const p of [path20].flat()) {
49294
49381
  this.#path = p;
49295
49382
  for (const m of [method].flat()) {
49296
49383
  handlers.map((handler) => {
@@ -49347,8 +49434,8 @@ var Hono = class _Hono {
49347
49434
  * app.route("/api", app2) // GET /api/user
49348
49435
  * ```
49349
49436
  */
49350
- route(path21, app) {
49351
- const subApp = this.basePath(path21);
49437
+ route(path20, app) {
49438
+ const subApp = this.basePath(path20);
49352
49439
  app.routes.map((r) => {
49353
49440
  let handler;
49354
49441
  if (app.errorHandler === errorHandler) {
@@ -49374,9 +49461,9 @@ var Hono = class _Hono {
49374
49461
  * const api = new Hono().basePath('/api')
49375
49462
  * ```
49376
49463
  */
49377
- basePath(path21) {
49464
+ basePath(path20) {
49378
49465
  const subApp = this.#clone();
49379
- subApp._basePath = mergePath(this._basePath, path21);
49466
+ subApp._basePath = mergePath(this._basePath, path20);
49380
49467
  return subApp;
49381
49468
  }
49382
49469
  /**
@@ -49450,7 +49537,7 @@ var Hono = class _Hono {
49450
49537
  * })
49451
49538
  * ```
49452
49539
  */
49453
- mount(path21, applicationHandler, options) {
49540
+ mount(path20, applicationHandler, options) {
49454
49541
  let replaceRequest;
49455
49542
  let optionHandler;
49456
49543
  if (options) {
@@ -49477,7 +49564,7 @@ var Hono = class _Hono {
49477
49564
  return [c.env, executionContext];
49478
49565
  };
49479
49566
  replaceRequest ||= (() => {
49480
- const mergedPath = mergePath(this._basePath, path21);
49567
+ const mergedPath = mergePath(this._basePath, path20);
49481
49568
  const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
49482
49569
  return (request) => {
49483
49570
  const url = new URL(request.url);
@@ -49492,14 +49579,14 @@ var Hono = class _Hono {
49492
49579
  }
49493
49580
  await next();
49494
49581
  };
49495
- this.#addRoute(METHOD_NAME_ALL, mergePath(path21, "*"), handler);
49582
+ this.#addRoute(METHOD_NAME_ALL, mergePath(path20, "*"), handler);
49496
49583
  return this;
49497
49584
  }
49498
- #addRoute(method, path21, handler) {
49585
+ #addRoute(method, path20, handler) {
49499
49586
  method = method.toUpperCase();
49500
- path21 = mergePath(this._basePath, path21);
49501
- const r = { basePath: this._basePath, path: path21, method, handler };
49502
- this.router.add(method, path21, [handler, r]);
49587
+ path20 = mergePath(this._basePath, path20);
49588
+ const r = { basePath: this._basePath, path: path20, method, handler };
49589
+ this.router.add(method, path20, [handler, r]);
49503
49590
  this.routes.push(r);
49504
49591
  }
49505
49592
  #handleError(err, c) {
@@ -49512,10 +49599,10 @@ var Hono = class _Hono {
49512
49599
  if (method === "HEAD") {
49513
49600
  return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
49514
49601
  }
49515
- const path21 = this.getPath(request, { env });
49516
- const matchResult = this.router.match(method, path21);
49602
+ const path20 = this.getPath(request, { env });
49603
+ const matchResult = this.router.match(method, path20);
49517
49604
  const c = new Context(request, {
49518
- path: path21,
49605
+ path: path20,
49519
49606
  matchResult,
49520
49607
  env,
49521
49608
  executionCtx,
@@ -49615,7 +49702,7 @@ var Hono = class _Hono {
49615
49702
 
49616
49703
  // node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/matcher.js
49617
49704
  var emptyParam = [];
49618
- function match(method, path21) {
49705
+ function match(method, path20) {
49619
49706
  const matchers = this.buildAllMatchers();
49620
49707
  const match2 = ((method2, path22) => {
49621
49708
  const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
@@ -49631,7 +49718,7 @@ function match(method, path21) {
49631
49718
  return [matcher[1][index], match3];
49632
49719
  });
49633
49720
  this.match = match2;
49634
- return match2(method, path21);
49721
+ return match2(method, path20);
49635
49722
  }
49636
49723
 
49637
49724
  // node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/node.js
@@ -49746,12 +49833,12 @@ var Node = class _Node {
49746
49833
  var Trie = class {
49747
49834
  #context = { varIndex: 0 };
49748
49835
  #root = new Node();
49749
- insert(path21, index, pathErrorCheckOnly) {
49836
+ insert(path20, index, pathErrorCheckOnly) {
49750
49837
  const paramAssoc = [];
49751
49838
  const groups = [];
49752
49839
  for (let i = 0; ; ) {
49753
49840
  let replaced = false;
49754
- path21 = path21.replace(/\{[^}]+\}/g, (m) => {
49841
+ path20 = path20.replace(/\{[^}]+\}/g, (m) => {
49755
49842
  const mark = `@\\${i}`;
49756
49843
  groups[i] = [mark, m];
49757
49844
  i++;
@@ -49762,7 +49849,7 @@ var Trie = class {
49762
49849
  break;
49763
49850
  }
49764
49851
  }
49765
- const tokens = path21.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
49852
+ const tokens = path20.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
49766
49853
  for (let i = groups.length - 1; i >= 0; i--) {
49767
49854
  const [mark] = groups[i];
49768
49855
  for (let j = tokens.length - 1; j >= 0; j--) {
@@ -49801,9 +49888,9 @@ var Trie = class {
49801
49888
  // node_modules/.pnpm/hono@4.12.9/node_modules/hono/dist/router/reg-exp-router/router.js
49802
49889
  var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
49803
49890
  var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
49804
- function buildWildcardRegExp(path21) {
49805
- return wildcardRegExpCache[path21] ??= new RegExp(
49806
- path21 === "*" ? "" : `^${path21.replace(
49891
+ function buildWildcardRegExp(path20) {
49892
+ return wildcardRegExpCache[path20] ??= new RegExp(
49893
+ path20 === "*" ? "" : `^${path20.replace(
49807
49894
  /\/\*$|([.\\+*[^\]$()])/g,
49808
49895
  (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
49809
49896
  )}$`
@@ -49825,17 +49912,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
49825
49912
  );
49826
49913
  const staticMap = /* @__PURE__ */ Object.create(null);
49827
49914
  for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
49828
- const [pathErrorCheckOnly, path21, handlers] = routesWithStaticPathFlag[i];
49915
+ const [pathErrorCheckOnly, path20, handlers] = routesWithStaticPathFlag[i];
49829
49916
  if (pathErrorCheckOnly) {
49830
- staticMap[path21] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
49917
+ staticMap[path20] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
49831
49918
  } else {
49832
49919
  j++;
49833
49920
  }
49834
49921
  let paramAssoc;
49835
49922
  try {
49836
- paramAssoc = trie.insert(path21, j, pathErrorCheckOnly);
49923
+ paramAssoc = trie.insert(path20, j, pathErrorCheckOnly);
49837
49924
  } catch (e) {
49838
- throw e === PATH_ERROR ? new UnsupportedPathError(path21) : e;
49925
+ throw e === PATH_ERROR ? new UnsupportedPathError(path20) : e;
49839
49926
  }
49840
49927
  if (pathErrorCheckOnly) {
49841
49928
  continue;
@@ -49869,12 +49956,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
49869
49956
  }
49870
49957
  return [regexp, handlerMap, staticMap];
49871
49958
  }
49872
- function findMiddleware(middleware, path21) {
49959
+ function findMiddleware(middleware, path20) {
49873
49960
  if (!middleware) {
49874
49961
  return void 0;
49875
49962
  }
49876
49963
  for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
49877
- if (buildWildcardRegExp(k).test(path21)) {
49964
+ if (buildWildcardRegExp(k).test(path20)) {
49878
49965
  return [...middleware[k]];
49879
49966
  }
49880
49967
  }
@@ -49888,7 +49975,7 @@ var RegExpRouter = class {
49888
49975
  this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
49889
49976
  this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
49890
49977
  }
49891
- add(method, path21, handler) {
49978
+ add(method, path20, handler) {
49892
49979
  const middleware = this.#middleware;
49893
49980
  const routes = this.#routes;
49894
49981
  if (!middleware || !routes) {
@@ -49903,18 +49990,18 @@ var RegExpRouter = class {
49903
49990
  });
49904
49991
  });
49905
49992
  }
49906
- if (path21 === "/*") {
49907
- path21 = "*";
49993
+ if (path20 === "/*") {
49994
+ path20 = "*";
49908
49995
  }
49909
- const paramCount = (path21.match(/\/:/g) || []).length;
49910
- if (/\*$/.test(path21)) {
49911
- const re = buildWildcardRegExp(path21);
49996
+ const paramCount = (path20.match(/\/:/g) || []).length;
49997
+ if (/\*$/.test(path20)) {
49998
+ const re = buildWildcardRegExp(path20);
49912
49999
  if (method === METHOD_NAME_ALL) {
49913
50000
  Object.keys(middleware).forEach((m) => {
49914
- middleware[m][path21] ||= findMiddleware(middleware[m], path21) || findMiddleware(middleware[METHOD_NAME_ALL], path21) || [];
50001
+ middleware[m][path20] ||= findMiddleware(middleware[m], path20) || findMiddleware(middleware[METHOD_NAME_ALL], path20) || [];
49915
50002
  });
49916
50003
  } else {
49917
- middleware[method][path21] ||= findMiddleware(middleware[method], path21) || findMiddleware(middleware[METHOD_NAME_ALL], path21) || [];
50004
+ middleware[method][path20] ||= findMiddleware(middleware[method], path20) || findMiddleware(middleware[METHOD_NAME_ALL], path20) || [];
49918
50005
  }
49919
50006
  Object.keys(middleware).forEach((m) => {
49920
50007
  if (method === METHOD_NAME_ALL || method === m) {
@@ -49932,7 +50019,7 @@ var RegExpRouter = class {
49932
50019
  });
49933
50020
  return;
49934
50021
  }
49935
- const paths = checkOptionalParameter(path21) || [path21];
50022
+ const paths = checkOptionalParameter(path20) || [path20];
49936
50023
  for (let i = 0, len = paths.length; i < len; i++) {
49937
50024
  const path22 = paths[i];
49938
50025
  Object.keys(routes).forEach((m) => {
@@ -49959,13 +50046,13 @@ var RegExpRouter = class {
49959
50046
  const routes = [];
49960
50047
  let hasOwnRoute = method === METHOD_NAME_ALL;
49961
50048
  [this.#middleware, this.#routes].forEach((r) => {
49962
- const ownRoute = r[method] ? Object.keys(r[method]).map((path21) => [path21, r[method][path21]]) : [];
50049
+ const ownRoute = r[method] ? Object.keys(r[method]).map((path20) => [path20, r[method][path20]]) : [];
49963
50050
  if (ownRoute.length !== 0) {
49964
50051
  hasOwnRoute ||= true;
49965
50052
  routes.push(...ownRoute);
49966
50053
  } else if (method !== METHOD_NAME_ALL) {
49967
50054
  routes.push(
49968
- ...Object.keys(r[METHOD_NAME_ALL]).map((path21) => [path21, r[METHOD_NAME_ALL][path21]])
50055
+ ...Object.keys(r[METHOD_NAME_ALL]).map((path20) => [path20, r[METHOD_NAME_ALL][path20]])
49969
50056
  );
49970
50057
  }
49971
50058
  });
@@ -49985,13 +50072,13 @@ var SmartRouter = class {
49985
50072
  constructor(init) {
49986
50073
  this.#routers = init.routers;
49987
50074
  }
49988
- add(method, path21, handler) {
50075
+ add(method, path20, handler) {
49989
50076
  if (!this.#routes) {
49990
50077
  throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
49991
50078
  }
49992
- this.#routes.push([method, path21, handler]);
50079
+ this.#routes.push([method, path20, handler]);
49993
50080
  }
49994
- match(method, path21) {
50081
+ match(method, path20) {
49995
50082
  if (!this.#routes) {
49996
50083
  throw new Error("Fatal error");
49997
50084
  }
@@ -50006,7 +50093,7 @@ var SmartRouter = class {
50006
50093
  for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
50007
50094
  router.add(...routes[i2]);
50008
50095
  }
50009
- res = router.match(method, path21);
50096
+ res = router.match(method, path20);
50010
50097
  } catch (e) {
50011
50098
  if (e instanceof UnsupportedPathError) {
50012
50099
  continue;
@@ -50056,10 +50143,10 @@ var Node2 = class _Node2 {
50056
50143
  }
50057
50144
  this.#patterns = [];
50058
50145
  }
50059
- insert(method, path21, handler) {
50146
+ insert(method, path20, handler) {
50060
50147
  this.#order = ++this.#order;
50061
50148
  let curNode = this;
50062
- const parts = splitRoutingPath(path21);
50149
+ const parts = splitRoutingPath(path20);
50063
50150
  const possibleKeys = [];
50064
50151
  for (let i = 0, len = parts.length; i < len; i++) {
50065
50152
  const p = parts[i];
@@ -50108,12 +50195,12 @@ var Node2 = class _Node2 {
50108
50195
  }
50109
50196
  }
50110
50197
  }
50111
- search(method, path21) {
50198
+ search(method, path20) {
50112
50199
  const handlerSets = [];
50113
50200
  this.#params = emptyParams;
50114
50201
  const curNode = this;
50115
50202
  let curNodes = [curNode];
50116
- const parts = splitPath(path21);
50203
+ const parts = splitPath(path20);
50117
50204
  const curNodesQueue = [];
50118
50205
  const len = parts.length;
50119
50206
  let partOffsets = null;
@@ -50155,13 +50242,13 @@ var Node2 = class _Node2 {
50155
50242
  if (matcher instanceof RegExp) {
50156
50243
  if (partOffsets === null) {
50157
50244
  partOffsets = new Array(len);
50158
- let offset = path21[0] === "/" ? 1 : 0;
50245
+ let offset = path20[0] === "/" ? 1 : 0;
50159
50246
  for (let p = 0; p < len; p++) {
50160
50247
  partOffsets[p] = offset;
50161
50248
  offset += parts[p].length + 1;
50162
50249
  }
50163
50250
  }
50164
- const restPathString = path21.substring(partOffsets[i]);
50251
+ const restPathString = path20.substring(partOffsets[i]);
50165
50252
  const m = matcher.exec(restPathString);
50166
50253
  if (m) {
50167
50254
  params[name] = m[0];
@@ -50214,18 +50301,18 @@ var TrieRouter = class {
50214
50301
  constructor() {
50215
50302
  this.#node = new Node2();
50216
50303
  }
50217
- add(method, path21, handler) {
50218
- const results = checkOptionalParameter(path21);
50304
+ add(method, path20, handler) {
50305
+ const results = checkOptionalParameter(path20);
50219
50306
  if (results) {
50220
50307
  for (let i = 0, len = results.length; i < len; i++) {
50221
50308
  this.#node.insert(method, results[i], handler);
50222
50309
  }
50223
50310
  return;
50224
50311
  }
50225
- this.#node.insert(method, path21, handler);
50312
+ this.#node.insert(method, path20, handler);
50226
50313
  }
50227
- match(method, path21) {
50228
- return this.#node.search(method, path21);
50314
+ match(method, path20) {
50315
+ return this.#node.search(method, path20);
50229
50316
  }
50230
50317
  };
50231
50318
 
@@ -50890,7 +50977,7 @@ var baseMimes = _baseMimes;
50890
50977
 
50891
50978
  // node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.9/node_modules/@hono/node-server/dist/serve-static.mjs
50892
50979
  var import_fs15 = require("fs");
50893
- var import_path20 = require("path");
50980
+ var import_path19 = require("path");
50894
50981
  var import_process = require("process");
50895
50982
  var import_stream2 = require("stream");
50896
50983
  var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
@@ -50927,10 +51014,10 @@ var createStreamBody = (stream) => {
50927
51014
  });
50928
51015
  return body;
50929
51016
  };
50930
- var getStats = (path21) => {
51017
+ var getStats = (path20) => {
50931
51018
  let stats;
50932
51019
  try {
50933
- stats = (0, import_fs15.statSync)(path21);
51020
+ stats = (0, import_fs15.statSync)(path20);
50934
51021
  } catch {
50935
51022
  }
50936
51023
  return stats;
@@ -50973,21 +51060,21 @@ var serveStatic = (options = { root: "" }) => {
50973
51060
  return next();
50974
51061
  }
50975
51062
  }
50976
- let path21 = (0, import_path20.join)(
51063
+ let path20 = (0, import_path19.join)(
50977
51064
  root,
50978
51065
  !optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename
50979
51066
  );
50980
- let stats = getStats(path21);
51067
+ let stats = getStats(path20);
50981
51068
  if (stats && stats.isDirectory()) {
50982
51069
  const indexFile = options.index ?? "index.html";
50983
- path21 = (0, import_path20.join)(path21, indexFile);
50984
- stats = getStats(path21);
51070
+ path20 = (0, import_path19.join)(path20, indexFile);
51071
+ stats = getStats(path20);
50985
51072
  }
50986
51073
  if (!stats) {
50987
- await options.onNotFound?.(path21, c);
51074
+ await options.onNotFound?.(path20, c);
50988
51075
  return next();
50989
51076
  }
50990
- const mimeType = getMimeType(path21);
51077
+ const mimeType = getMimeType(path20);
50991
51078
  c.header("Content-Type", mimeType || "application/octet-stream");
50992
51079
  if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
50993
51080
  const acceptEncodingSet = new Set(
@@ -50997,12 +51084,12 @@ var serveStatic = (options = { root: "" }) => {
50997
51084
  if (!acceptEncodingSet.has(encoding)) {
50998
51085
  continue;
50999
51086
  }
51000
- const precompressedStats = getStats(path21 + ENCODINGS[encoding]);
51087
+ const precompressedStats = getStats(path20 + ENCODINGS[encoding]);
51001
51088
  if (precompressedStats) {
51002
51089
  c.header("Content-Encoding", encoding);
51003
51090
  c.header("Vary", "Accept-Encoding", { append: true });
51004
51091
  stats = precompressedStats;
51005
- path21 = path21 + ENCODINGS[encoding];
51092
+ path20 = path20 + ENCODINGS[encoding];
51006
51093
  break;
51007
51094
  }
51008
51095
  }
@@ -51016,7 +51103,7 @@ var serveStatic = (options = { root: "" }) => {
51016
51103
  result = c.body(null);
51017
51104
  } else if (!range) {
51018
51105
  c.header("Content-Length", size.toString());
51019
- result = c.body(createStreamBody((0, import_fs15.createReadStream)(path21)), 200);
51106
+ result = c.body(createStreamBody((0, import_fs15.createReadStream)(path20)), 200);
51020
51107
  } else {
51021
51108
  c.header("Accept-Ranges", "bytes");
51022
51109
  c.header("Date", stats.birthtime.toUTCString());
@@ -51027,12 +51114,12 @@ var serveStatic = (options = { root: "" }) => {
51027
51114
  end = size - 1;
51028
51115
  }
51029
51116
  const chunksize = end - start + 1;
51030
- const stream = (0, import_fs15.createReadStream)(path21, { start, end });
51117
+ const stream = (0, import_fs15.createReadStream)(path20, { start, end });
51031
51118
  c.header("Content-Length", chunksize.toString());
51032
51119
  c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
51033
51120
  result = c.body(createStreamBody(stream), 206);
51034
51121
  }
51035
- await options.onFound?.(path21, c);
51122
+ await options.onFound?.(path20, c);
51036
51123
  return result;
51037
51124
  };
51038
51125
  };
@@ -51132,13 +51219,13 @@ var import_node_path17 = __toESM(require("node:path"));
51132
51219
  // src/git/worktree.ts
51133
51220
  var import_child_process2 = require("child_process");
51134
51221
  var import_util = require("util");
51135
- var import_path21 = __toESM(require("path"));
51222
+ var import_path20 = __toESM(require("path"));
51136
51223
  var import_fs16 = require("fs");
51137
51224
  var execFileAsync = (0, import_util.promisify)(import_child_process2.execFile);
51138
51225
  var getProjectRoot = () => process.cwd();
51139
51226
  var getWorktreeBaseDir = () => getDuclawWorktreesDir();
51140
51227
  var getDisplayWorktreePath = (goalId, taskId) => `~/.duclaw/worktrees/${goalId}/${taskId}`;
51141
- var getWorktreePath = (goalId, taskId) => import_path21.default.join(getWorktreeBaseDir(), goalId, taskId);
51228
+ var getWorktreePath = (goalId, taskId) => import_path20.default.join(getWorktreeBaseDir(), goalId, taskId);
51142
51229
  var getBranchName = (taskId) => `task/${taskId}`;
51143
51230
  async function git(args, cwd) {
51144
51231
  const { stdout } = await execFileAsync("git", args, {
@@ -51150,7 +51237,7 @@ async function git(args, cwd) {
51150
51237
  async function createWorktree(taskId, goalId, baseBranch = "main") {
51151
51238
  const wtPath = getWorktreePath(goalId, taskId);
51152
51239
  const branch = getBranchName(taskId);
51153
- const parentDir = import_path21.default.dirname(wtPath);
51240
+ const parentDir = import_path20.default.dirname(wtPath);
51154
51241
  if (!(0, import_fs16.existsSync)(parentDir)) {
51155
51242
  (0, import_fs16.mkdirSync)(parentDir, { recursive: true });
51156
51243
  }
@@ -51256,8 +51343,8 @@ async function listWorktrees() {
51256
51343
  const fullBranch = branchLine.replace("branch refs/heads/", "");
51257
51344
  if (!fullBranch.startsWith("task/")) continue;
51258
51345
  const taskId = fullBranch.replace("task/", "");
51259
- const relPath = import_path21.default.relative(getProjectRoot(), wtPath);
51260
- const parts = relPath.split(import_path21.default.sep);
51346
+ const relPath = import_path20.default.relative(getProjectRoot(), wtPath);
51347
+ const parts = relPath.split(import_path20.default.sep);
51261
51348
  const worktreeIdx = parts.indexOf(".worktrees");
51262
51349
  const goalId = worktreeIdx >= 0 && parts.length > worktreeIdx + 1 ? parts[worktreeIdx + 1] : "";
51263
51350
  worktrees.push({
@@ -53086,7 +53173,7 @@ var systemRoutes = new Hono2();
53086
53173
  var startTime = Date.now();
53087
53174
  systemRoutes.get("/system/info", (c) => {
53088
53175
  return c.json({
53089
- version: true ? "1.9.2" : "unknown",
53176
+ version: true ? "1.9.4" : "unknown",
53090
53177
  uptime: Math.floor((Date.now() - startTime) / 1e3),
53091
53178
  env: process.env.NODE_ENV || "development",
53092
53179
  nodeVersion: process.version