@lobehub/cli 0.0.18 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +1673 -1577
  2. package/man/man1/lh.1 +1 -1
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3028,7 +3028,7 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3028
3028
  }));
3029
3029
 
3030
3030
  //#endregion
3031
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/objectSpread2-BvkFp-_Y.mjs
3031
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/objectSpread2-BvkFp-_Y.mjs
3032
3032
  var import_picocolors = /* @__PURE__ */ __toESM$2(require_picocolors(), 1);
3033
3033
  var __create$1 = Object.create;
3034
3034
  var __defProp$1 = Object.defineProperty;
@@ -3126,7 +3126,7 @@ var require_objectSpread2$1 = __commonJS$1({ "../../node_modules/.pnpm/@oxc-proj
3126
3126
  } });
3127
3127
 
3128
3128
  //#endregion
3129
- //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-UMO3vUa_.mjs
3129
+ //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-UMO3vUa_.mjs
3130
3130
  /** @public */
3131
3131
  function observable(subscribe) {
3132
3132
  const self = {
@@ -3209,7 +3209,7 @@ function observableToPromise(observable$1) {
3209
3209
  }
3210
3210
 
3211
3211
  //#endregion
3212
- //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-CUiPknO-.mjs
3212
+ //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-CUiPknO-.mjs
3213
3213
  function share(_opts) {
3214
3214
  return (source) => {
3215
3215
  let refCount = 0;
@@ -3289,7 +3289,7 @@ function behaviorSubject(initialValue) {
3289
3289
  }
3290
3290
 
3291
3291
  //#endregion
3292
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/splitLink-B7Cuf2c_.mjs
3292
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/splitLink-B7Cuf2c_.mjs
3293
3293
  /** @internal */
3294
3294
  function createChain(opts) {
3295
3295
  return observable((observer) => {
@@ -3308,7 +3308,7 @@ function createChain(opts) {
3308
3308
  }
3309
3309
 
3310
3310
  //#endregion
3311
- //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/codes-DagpWZLc.mjs
3311
+ //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/codes-DagpWZLc.mjs
3312
3312
  /**
3313
3313
  * Check that value is object
3314
3314
  * @internal
@@ -3364,7 +3364,7 @@ const retryableRpcCodes = [
3364
3364
  ];
3365
3365
 
3366
3366
  //#endregion
3367
- //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/getErrorShape-BPSzUA7W.mjs
3367
+ //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/getErrorShape-vC8mUXJD.mjs
3368
3368
  var __create = Object.create;
3369
3369
  var __defProp = Object.defineProperty;
3370
3370
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -3402,7 +3402,6 @@ function createInnerProxy(callback, path, memo) {
3402
3402
  },
3403
3403
  apply(_1, _2, args) {
3404
3404
  const lastOfPath = path[path.length - 1];
3405
- if (lastOfPath === "valueOf" || lastOfPath === "toString" || lastOfPath === "toJSON") return `tRPC.proxy(${path.slice(0, -1).join(".")})`;
3406
3405
  let opts = {
3407
3406
  args,
3408
3407
  path
@@ -3513,7 +3512,7 @@ var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+
3513
3512
  var import_objectSpread2$11 = __toESM(require_objectSpread2(), 1);
3514
3513
 
3515
3514
  //#endregion
3516
- //#region node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/tracked-DWInO6EQ.mjs
3515
+ //#region node_modules/.pnpm/@trpc+server@11.16.0_typescript@5.9.3/node_modules/@trpc/server/dist/tracked-DiE3uR1B.mjs
3517
3516
  var import_defineProperty$6 = __toESM(require_defineProperty(), 1);
3518
3517
  var import_objectSpread2$1$11 = __toESM(require_objectSpread2(), 1);
3519
3518
  /** @internal */
@@ -3556,7 +3555,7 @@ function transformResult(response, transformer) {
3556
3555
  var import_objectSpread2$12 = __toESM(require_objectSpread2(), 1);
3557
3556
 
3558
3557
  //#endregion
3559
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/TRPCClientError-apv8gw59.mjs
3558
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/TRPCClientError-apv8gw59.mjs
3560
3559
  var import_defineProperty$5 = __toESM$1(require_defineProperty$1(), 1);
3561
3560
  var import_objectSpread2$10 = __toESM$1(require_objectSpread2$1(), 1);
3562
3561
  function isTRPCClientError(cause) {
@@ -3601,7 +3600,7 @@ var TRPCClientError = class TRPCClientError extends Error {
3601
3600
  };
3602
3601
 
3603
3602
  //#endregion
3604
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/unstable-internals-Bg7n9BBj.mjs
3603
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/unstable-internals-Bg7n9BBj.mjs
3605
3604
  /**
3606
3605
  * @internal
3607
3606
  */
@@ -3628,7 +3627,7 @@ function getTransformer(transformer) {
3628
3627
  }
3629
3628
 
3630
3629
  //#endregion
3631
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpUtils-pyf5RF99.mjs
3630
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpUtils-BNq9QC3d.mjs
3632
3631
  const isFunction$1 = (fn) => typeof fn === "function";
3633
3632
  function getFetch(customFetchImpl) {
3634
3633
  if (customFetchImpl) return customFetchImpl;
@@ -3636,7 +3635,7 @@ function getFetch(customFetchImpl) {
3636
3635
  if (typeof globalThis !== "undefined" && isFunction$1(globalThis.fetch)) return globalThis.fetch;
3637
3636
  throw new Error("No fetch implementation found");
3638
3637
  }
3639
- var import_objectSpread2$9 = __toESM$1(require_objectSpread2$1(), 1);
3638
+ var import_objectSpread2$9 = __toESM$1(require_objectSpread2$1());
3640
3639
  function resolveHTTPLinkOptions(opts) {
3641
3640
  return {
3642
3641
  url: opts.url.toString(),
@@ -3738,7 +3737,7 @@ async function httpRequest(opts) {
3738
3737
  }
3739
3738
 
3740
3739
  //#endregion
3741
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpLink-lG_6juPY.mjs
3740
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpLink-oiU8eqFi.mjs
3742
3741
  function isOctetType(input) {
3743
3742
  return input instanceof Uint8Array || input instanceof Blob;
3744
3743
  }
@@ -3814,15 +3813,15 @@ function httpLink(opts) {
3814
3813
  }
3815
3814
 
3816
3815
  //#endregion
3817
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpBatchLink-LhidKAPw.mjs
3816
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpBatchLink-CaWjh1oW.mjs
3818
3817
  var import_objectSpread2$7 = __toESM$1(require_objectSpread2$1(), 1);
3819
3818
 
3820
3819
  //#endregion
3821
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/loggerLink-ineCN1PO.mjs
3820
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/loggerLink-ineCN1PO.mjs
3822
3821
  var import_objectSpread2$6 = __toESM$1(require_objectSpread2$1(), 1);
3823
3822
 
3824
3823
  //#endregion
3825
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/wsLink-DSf4KOdW.mjs
3824
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/wsLink-DSf4KOdW.mjs
3826
3825
  /**
3827
3826
  * Get the result of a value or function that returns a value
3828
3827
  * It also optionally accepts typesafe arguments for the function
@@ -3998,7 +3997,7 @@ var import_defineProperty$4 = __toESM$1(require_defineProperty$1(), 1);
3998
3997
  var import_objectSpread2$5 = __toESM$1(require_objectSpread2$1(), 1);
3999
3998
 
4000
3999
  //#endregion
4001
- //#region node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/index.mjs
4000
+ //#region node_modules/.pnpm/@trpc+client@11.16.0_@trpc+server@11.16.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/index.mjs
4002
4001
  var import_defineProperty = __toESM$1(require_defineProperty$1(), 1);
4003
4002
  var import_objectSpread2$4 = __toESM$1(require_objectSpread2$1(), 1);
4004
4003
  var TRPCUntypedClient = class {
@@ -12724,7 +12723,7 @@ function registerConfigCommand(program) {
12724
12723
  }
12725
12724
 
12726
12725
  //#endregion
12727
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/constants.js
12726
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/constants.js
12728
12727
  var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12729
12728
  const BINARY_TYPES = [
12730
12729
  "nodebuffer",
@@ -12748,7 +12747,7 @@ var require_constants$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12748
12747
  }));
12749
12748
 
12750
12749
  //#endregion
12751
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/buffer-util.js
12750
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/buffer-util.js
12752
12751
  var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12753
12752
  const { EMPTY_BUFFER } = require_constants$4();
12754
12753
  const FastBuffer = Buffer[Symbol.species];
@@ -12849,7 +12848,7 @@ var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12849
12848
  }));
12850
12849
 
12851
12850
  //#endregion
12852
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/limiter.js
12851
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/limiter.js
12853
12852
  var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12854
12853
  const kDone = Symbol("kDone");
12855
12854
  const kRun = Symbol("kRun");
@@ -12901,7 +12900,7 @@ var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12901
12900
  }));
12902
12901
 
12903
12902
  //#endregion
12904
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/permessage-deflate.js
12903
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js
12905
12904
  var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12906
12905
  const zlib$2 = __require("zlib");
12907
12906
  const bufferUtil = require_buffer_util();
@@ -13235,7 +13234,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
13235
13234
  }));
13236
13235
 
13237
13236
  //#endregion
13238
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/validation.js
13237
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/validation.js
13239
13238
  var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13240
13239
  const { isUtf8 } = __require("buffer");
13241
13240
  const { hasBlob } = require_constants$4();
@@ -13432,7 +13431,7 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13432
13431
  }));
13433
13432
 
13434
13433
  //#endregion
13435
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/receiver.js
13434
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/receiver.js
13436
13435
  var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13437
13436
  const { Writable: Writable$2 } = __require("stream");
13438
13437
  const PerMessageDeflate = require_permessage_deflate();
@@ -13880,11 +13879,10 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13880
13879
  }));
13881
13880
 
13882
13881
  //#endregion
13883
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/sender.js
13882
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/sender.js
13884
13883
  var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13885
13884
  const { Duplex: Duplex$3 } = __require("stream");
13886
13885
  const { randomFillSync } = __require("crypto");
13887
- const { types: { isUint8Array } } = __require("util");
13888
13886
  const PerMessageDeflate = require_permessage_deflate();
13889
13887
  const { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants$4();
13890
13888
  const { isBlob, isValidStatusCode } = require_validation();
@@ -14031,8 +14029,7 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14031
14029
  buf = Buffer.allocUnsafe(2 + length);
14032
14030
  buf.writeUInt16BE(code, 0);
14033
14031
  if (typeof data === "string") buf.write(data, 2);
14034
- else if (isUint8Array(data)) buf.set(data, 2);
14035
- else throw new TypeError("Second argument must be a string or a Uint8Array");
14032
+ else buf.set(data, 2);
14036
14033
  }
14037
14034
  const options = {
14038
14035
  [kByteLength]: buf.length,
@@ -14379,7 +14376,7 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14379
14376
  }));
14380
14377
 
14381
14378
  //#endregion
14382
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/event-target.js
14379
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/event-target.js
14383
14380
  var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14384
14381
  const { kForOnEventAttribute, kListener } = require_constants$4();
14385
14382
  const kCode = Symbol("kCode");
@@ -14618,7 +14615,7 @@ var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14618
14615
  }));
14619
14616
 
14620
14617
  //#endregion
14621
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/extension.js
14618
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/extension.js
14622
14619
  var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14623
14620
  const { tokenChars } = require_validation();
14624
14621
  /**
@@ -14762,7 +14759,7 @@ var require_extension = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14762
14759
  }));
14763
14760
 
14764
14761
  //#endregion
14765
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/websocket.js
14762
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket.js
14766
14763
  var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14767
14764
  const EventEmitter$6 = __require("events");
14768
14765
  const https = __require("https");
@@ -15738,7 +15735,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15738
15735
  }));
15739
15736
 
15740
15737
  //#endregion
15741
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/stream.js
15738
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/stream.js
15742
15739
  var require_stream$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15743
15740
  require_websocket();
15744
15741
  const { Duplex: Duplex$1 } = __require("stream");
@@ -15855,7 +15852,7 @@ var require_stream$6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15855
15852
  }));
15856
15853
 
15857
15854
  //#endregion
15858
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/subprotocol.js
15855
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/subprotocol.js
15859
15856
  var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15860
15857
  const { tokenChars } = require_validation();
15861
15858
  /**
@@ -15895,7 +15892,7 @@ var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15895
15892
  }));
15896
15893
 
15897
15894
  //#endregion
15898
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/lib/websocket-server.js
15895
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket-server.js
15899
15896
  var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {
15900
15897
  const EventEmitter$5 = __require("events");
15901
15898
  const http = __require("http");
@@ -16274,7 +16271,7 @@ var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module)
16274
16271
  }));
16275
16272
 
16276
16273
  //#endregion
16277
- //#region node_modules/.pnpm/ws@8.20.1/node_modules/ws/wrapper.mjs
16274
+ //#region node_modules/.pnpm/ws@8.20.0/node_modules/ws/wrapper.mjs
16278
16275
  var import_stream = /* @__PURE__ */ __toESM$2(require_stream$6(), 1);
16279
16276
  var import_extension = /* @__PURE__ */ __toESM$2(require_extension(), 1);
16280
16277
  var import_permessage_deflate = /* @__PURE__ */ __toESM$2(require_permessage_deflate(), 1);
@@ -16709,6 +16706,9 @@ function removeTask(taskId) {
16709
16706
  delete registry[taskId];
16710
16707
  writeRegistry(registry);
16711
16708
  }
16709
+ function listTasks() {
16710
+ return Object.values(readRegistry());
16711
+ }
16712
16712
 
16713
16713
  //#endregion
16714
16714
  //#region src/tools/heteroTask.ts
@@ -16721,26 +16721,6 @@ function resolveLhPath() {
16721
16721
  return "lh";
16722
16722
  }
16723
16723
  }
16724
- /**
16725
- * Check whether an openclaw session already exists for the given topicId.
16726
- * The session key format is `agent:<agentId>:explicit:<sessionId>`.
16727
- * Returns false on any error so that callers default to injecting the full protocol.
16728
- */
16729
- function openclawSessionExists(agentId, topicId) {
16730
- try {
16731
- const raw = execFileSync("openclaw", [
16732
- "sessions",
16733
- "--agent",
16734
- agentId,
16735
- "--json"
16736
- ], { encoding: "utf8" });
16737
- const data = JSON.parse(raw);
16738
- const expectedKey = `agent:${agentId}:explicit:${topicId}`;
16739
- return data.sessions?.some((s) => s.key === expectedKey) ?? false;
16740
- } catch {
16741
- return false;
16742
- }
16743
- }
16744
16724
  function getHermesPort() {
16745
16725
  const env = process.env.HERMES_GATEWAY_PORT;
16746
16726
  if (env) {
@@ -16824,6 +16804,13 @@ async function runHeteroTask(params) {
16824
16804
  const lhPath = resolveLhPath();
16825
16805
  if (agentType === "openclaw") {
16826
16806
  const openclawAgent = process.env.OPENCLAW_AGENT_ID ?? "main";
16807
+ const enrichedPrompt = `${prompt}\n\n${buildNotifyProtocol(lhPath, topicId)}`;
16808
+ for (const existing of listTasks()) if (existing.topicId === topicId && existing.agentType === "openclaw") {
16809
+ try {
16810
+ process.kill(existing.pid, "SIGTERM");
16811
+ } catch {}
16812
+ removeTask(existing.taskId);
16813
+ }
16827
16814
  const child = spawn("openclaw", [
16828
16815
  "agent",
16829
16816
  "--agent",
@@ -16831,7 +16818,7 @@ async function runHeteroTask(params) {
16831
16818
  "--session-id",
16832
16819
  topicId,
16833
16820
  "--message",
16834
- !openclawSessionExists(openclawAgent, topicId) ? `${prompt}\n\n${buildNotifyProtocol(lhPath, topicId)}` : prompt,
16821
+ enrichedPrompt,
16835
16822
  "--local"
16836
16823
  ], {
16837
16824
  cwd: workDir,
@@ -16987,736 +16974,742 @@ async function checkPlatformCapability(params) {
16987
16974
  }
16988
16975
 
16989
16976
  //#endregion
16990
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/base.js
16991
- var Diff = class {
16992
- diff(oldStr, newStr, options = {}) {
16993
- let callback;
16994
- if (typeof options === "function") {
16995
- callback = options;
16996
- options = {};
16997
- } else if ("callback" in options) callback = options.callback;
16998
- const oldString = this.castInput(oldStr, options);
16999
- const newString = this.castInput(newStr, options);
17000
- const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
17001
- const newTokens = this.removeEmpty(this.tokenize(newString, options));
17002
- return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
17003
- }
17004
- diffWithOptionsObj(oldTokens, newTokens, options, callback) {
17005
- var _a;
17006
- const done = (value) => {
17007
- value = this.postProcess(value, options);
17008
- if (callback) {
17009
- setTimeout(function() {
17010
- callback(value);
17011
- }, 0);
17012
- return;
17013
- } else return value;
17014
- };
17015
- const newLen = newTokens.length, oldLen = oldTokens.length;
17016
- let editLength = 1;
17017
- let maxEditLength = newLen + oldLen;
17018
- if (options.maxEditLength != null) maxEditLength = Math.min(maxEditLength, options.maxEditLength);
17019
- const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
17020
- const abortAfterTimestamp = Date.now() + maxExecutionTime;
17021
- const bestPath = [{
17022
- oldPos: -1,
17023
- lastComponent: void 0
17024
- }];
17025
- let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
17026
- if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
17027
- let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
17028
- const execEditLength = () => {
17029
- for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
17030
- let basePath;
17031
- const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
17032
- if (removePath) bestPath[diagonalPath - 1] = void 0;
17033
- let canAdd = false;
17034
- if (addPath) {
17035
- const addPathNewPos = addPath.oldPos - diagonalPath;
17036
- canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
17037
- }
17038
- const canRemove = removePath && removePath.oldPos + 1 < oldLen;
17039
- if (!canAdd && !canRemove) {
17040
- bestPath[diagonalPath] = void 0;
17041
- continue;
17042
- }
17043
- if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) basePath = this.addToPath(addPath, true, false, 0, options);
17044
- else basePath = this.addToPath(removePath, false, true, 1, options);
17045
- newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
17046
- if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
17047
- else {
17048
- bestPath[diagonalPath] = basePath;
17049
- if (basePath.oldPos + 1 >= oldLen) maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
17050
- if (newPos + 1 >= newLen) minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
17051
- }
17052
- }
17053
- editLength++;
17054
- };
17055
- if (callback) (function exec() {
17056
- setTimeout(function() {
17057
- if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) return callback(void 0);
17058
- if (!execEditLength()) exec();
17059
- }, 0);
17060
- })();
17061
- else while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
17062
- const ret = execEditLength();
17063
- if (ret) return ret;
17064
- }
17065
- }
17066
- addToPath(path, added, removed, oldPosInc, options) {
17067
- const last = path.lastComponent;
17068
- if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) return {
17069
- oldPos: path.oldPos + oldPosInc,
17070
- lastComponent: {
17071
- count: last.count + 1,
17072
- added,
17073
- removed,
17074
- previousComponent: last.previousComponent
17075
- }
17076
- };
17077
- else return {
17078
- oldPos: path.oldPos + oldPosInc,
17079
- lastComponent: {
17080
- count: 1,
17081
- added,
17082
- removed,
17083
- previousComponent: last
17084
- }
17085
- };
17086
- }
17087
- extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
17088
- const newLen = newTokens.length, oldLen = oldTokens.length;
17089
- let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
17090
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
17091
- newPos++;
17092
- oldPos++;
17093
- commonCount++;
17094
- if (options.oneChangePerToken) basePath.lastComponent = {
17095
- count: 1,
17096
- previousComponent: basePath.lastComponent,
17097
- added: false,
17098
- removed: false
17099
- };
16977
+ //#region node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
16978
+ var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
16979
+ /**
16980
+ * Helpers.
16981
+ */
16982
+ var s = 1e3;
16983
+ var m = s * 60;
16984
+ var h = m * 60;
16985
+ var d = h * 24;
16986
+ var w = d * 7;
16987
+ var y = d * 365.25;
16988
+ /**
16989
+ * Parse or format the given `val`.
16990
+ *
16991
+ * Options:
16992
+ *
16993
+ * - `long` verbose formatting [false]
16994
+ *
16995
+ * @param {String|Number} val
16996
+ * @param {Object} [options]
16997
+ * @throws {Error} throw an error if val is not a non-empty string or a number
16998
+ * @return {String|Number}
16999
+ * @api public
17000
+ */
17001
+ module.exports = function(val, options) {
17002
+ options = options || {};
17003
+ var type = typeof val;
17004
+ if (type === "string" && val.length > 0) return parse(val);
17005
+ else if (type === "number" && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
17006
+ throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
17007
+ };
17008
+ /**
17009
+ * Parse the given `str` and return milliseconds.
17010
+ *
17011
+ * @param {String} str
17012
+ * @return {Number}
17013
+ * @api private
17014
+ */
17015
+ function parse(str) {
17016
+ str = String(str);
17017
+ if (str.length > 100) return;
17018
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
17019
+ if (!match) return;
17020
+ var n = parseFloat(match[1]);
17021
+ switch ((match[2] || "ms").toLowerCase()) {
17022
+ case "years":
17023
+ case "year":
17024
+ case "yrs":
17025
+ case "yr":
17026
+ case "y": return n * y;
17027
+ case "weeks":
17028
+ case "week":
17029
+ case "w": return n * w;
17030
+ case "days":
17031
+ case "day":
17032
+ case "d": return n * d;
17033
+ case "hours":
17034
+ case "hour":
17035
+ case "hrs":
17036
+ case "hr":
17037
+ case "h": return n * h;
17038
+ case "minutes":
17039
+ case "minute":
17040
+ case "mins":
17041
+ case "min":
17042
+ case "m": return n * m;
17043
+ case "seconds":
17044
+ case "second":
17045
+ case "secs":
17046
+ case "sec":
17047
+ case "s": return n * s;
17048
+ case "milliseconds":
17049
+ case "millisecond":
17050
+ case "msecs":
17051
+ case "msec":
17052
+ case "ms": return n;
17053
+ default: return;
17100
17054
  }
17101
- if (commonCount && !options.oneChangePerToken) basePath.lastComponent = {
17102
- count: commonCount,
17103
- previousComponent: basePath.lastComponent,
17104
- added: false,
17105
- removed: false
17106
- };
17107
- basePath.oldPos = oldPos;
17108
- return newPos;
17109
- }
17110
- equals(left, right, options) {
17111
- if (options.comparator) return options.comparator(left, right);
17112
- else return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
17113
- }
17114
- removeEmpty(array) {
17115
- const ret = [];
17116
- for (let i = 0; i < array.length; i++) if (array[i]) ret.push(array[i]);
17117
- return ret;
17118
- }
17119
- castInput(value, options) {
17120
- return value;
17121
- }
17122
- tokenize(value, options) {
17123
- return Array.from(value);
17124
17055
  }
17125
- join(chars) {
17126
- return chars.join("");
17056
+ /**
17057
+ * Short format for `ms`.
17058
+ *
17059
+ * @param {Number} ms
17060
+ * @return {String}
17061
+ * @api private
17062
+ */
17063
+ function fmtShort(ms) {
17064
+ var msAbs = Math.abs(ms);
17065
+ if (msAbs >= d) return Math.round(ms / d) + "d";
17066
+ if (msAbs >= h) return Math.round(ms / h) + "h";
17067
+ if (msAbs >= m) return Math.round(ms / m) + "m";
17068
+ if (msAbs >= s) return Math.round(ms / s) + "s";
17069
+ return ms + "ms";
17127
17070
  }
17128
- postProcess(changeObjects, options) {
17129
- return changeObjects;
17071
+ /**
17072
+ * Long format for `ms`.
17073
+ *
17074
+ * @param {Number} ms
17075
+ * @return {String}
17076
+ * @api private
17077
+ */
17078
+ function fmtLong(ms) {
17079
+ var msAbs = Math.abs(ms);
17080
+ if (msAbs >= d) return plural(ms, msAbs, d, "day");
17081
+ if (msAbs >= h) return plural(ms, msAbs, h, "hour");
17082
+ if (msAbs >= m) return plural(ms, msAbs, m, "minute");
17083
+ if (msAbs >= s) return plural(ms, msAbs, s, "second");
17084
+ return ms + " ms";
17130
17085
  }
17131
- get useLongestToken() {
17132
- return false;
17086
+ /**
17087
+ * Pluralization helper.
17088
+ */
17089
+ function plural(ms, msAbs, n, name) {
17090
+ var isPlural = msAbs >= n * 1.5;
17091
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
17133
17092
  }
17134
- buildValues(lastComponent, newTokens, oldTokens) {
17135
- const components = [];
17136
- let nextComponent;
17137
- while (lastComponent) {
17138
- components.push(lastComponent);
17139
- nextComponent = lastComponent.previousComponent;
17140
- delete lastComponent.previousComponent;
17141
- lastComponent = nextComponent;
17093
+ }));
17094
+
17095
+ //#endregion
17096
+ //#region node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
17097
+ var require_common$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17098
+ /**
17099
+ * This is the common logic for both the Node.js and web browser
17100
+ * implementations of `debug()`.
17101
+ */
17102
+ function setup(env) {
17103
+ createDebug.debug = createDebug;
17104
+ createDebug.default = createDebug;
17105
+ createDebug.coerce = coerce;
17106
+ createDebug.disable = disable;
17107
+ createDebug.enable = enable;
17108
+ createDebug.enabled = enabled;
17109
+ createDebug.humanize = require_ms();
17110
+ createDebug.destroy = destroy;
17111
+ Object.keys(env).forEach((key) => {
17112
+ createDebug[key] = env[key];
17113
+ });
17114
+ /**
17115
+ * The currently active debug mode names, and names to skip.
17116
+ */
17117
+ createDebug.names = [];
17118
+ createDebug.skips = [];
17119
+ /**
17120
+ * Map of special "%n" handling functions, for the debug "format" argument.
17121
+ *
17122
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
17123
+ */
17124
+ createDebug.formatters = {};
17125
+ /**
17126
+ * Selects a color for a debug namespace
17127
+ * @param {String} namespace The namespace string for the debug instance to be colored
17128
+ * @return {Number|String} An ANSI color code for the given namespace
17129
+ * @api private
17130
+ */
17131
+ function selectColor(namespace) {
17132
+ let hash = 0;
17133
+ for (let i = 0; i < namespace.length; i++) {
17134
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
17135
+ hash |= 0;
17136
+ }
17137
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
17142
17138
  }
17143
- components.reverse();
17144
- const componentLen = components.length;
17145
- let componentPos = 0, newPos = 0, oldPos = 0;
17146
- for (; componentPos < componentLen; componentPos++) {
17147
- const component = components[componentPos];
17148
- if (!component.removed) {
17149
- if (!component.added && this.useLongestToken) {
17150
- let value = newTokens.slice(newPos, newPos + component.count);
17151
- value = value.map(function(value, i) {
17152
- const oldValue = oldTokens[oldPos + i];
17153
- return oldValue.length > value.length ? oldValue : value;
17154
- });
17155
- component.value = this.join(value);
17156
- } else component.value = this.join(newTokens.slice(newPos, newPos + component.count));
17157
- newPos += component.count;
17158
- if (!component.added) oldPos += component.count;
17159
- } else {
17160
- component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
17161
- oldPos += component.count;
17139
+ createDebug.selectColor = selectColor;
17140
+ /**
17141
+ * Create a debugger with the given `namespace`.
17142
+ *
17143
+ * @param {String} namespace
17144
+ * @return {Function}
17145
+ * @api public
17146
+ */
17147
+ function createDebug(namespace) {
17148
+ let prevTime;
17149
+ let enableOverride = null;
17150
+ let namespacesCache;
17151
+ let enabledCache;
17152
+ function debug(...args) {
17153
+ if (!debug.enabled) return;
17154
+ const self = debug;
17155
+ const curr = Number(/* @__PURE__ */ new Date());
17156
+ self.diff = curr - (prevTime || curr);
17157
+ self.prev = prevTime;
17158
+ self.curr = curr;
17159
+ prevTime = curr;
17160
+ args[0] = createDebug.coerce(args[0]);
17161
+ if (typeof args[0] !== "string") args.unshift("%O");
17162
+ let index = 0;
17163
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
17164
+ if (match === "%%") return "%";
17165
+ index++;
17166
+ const formatter = createDebug.formatters[format];
17167
+ if (typeof formatter === "function") {
17168
+ const val = args[index];
17169
+ match = formatter.call(self, val);
17170
+ args.splice(index, 1);
17171
+ index--;
17172
+ }
17173
+ return match;
17174
+ });
17175
+ createDebug.formatArgs.call(self, args);
17176
+ (self.log || createDebug.log).apply(self, args);
17162
17177
  }
17178
+ debug.namespace = namespace;
17179
+ debug.useColors = createDebug.useColors();
17180
+ debug.color = createDebug.selectColor(namespace);
17181
+ debug.extend = extend;
17182
+ debug.destroy = createDebug.destroy;
17183
+ Object.defineProperty(debug, "enabled", {
17184
+ enumerable: true,
17185
+ configurable: false,
17186
+ get: () => {
17187
+ if (enableOverride !== null) return enableOverride;
17188
+ if (namespacesCache !== createDebug.namespaces) {
17189
+ namespacesCache = createDebug.namespaces;
17190
+ enabledCache = createDebug.enabled(namespace);
17191
+ }
17192
+ return enabledCache;
17193
+ },
17194
+ set: (v) => {
17195
+ enableOverride = v;
17196
+ }
17197
+ });
17198
+ if (typeof createDebug.init === "function") createDebug.init(debug);
17199
+ return debug;
17163
17200
  }
17164
- return components;
17165
- }
17166
- };
17167
-
17168
- //#endregion
17169
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/character.js
17170
- var CharacterDiff = class extends Diff {};
17171
- const characterDiff = new CharacterDiff();
17172
-
17173
- //#endregion
17174
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/util/string.js
17175
- function longestCommonPrefix(str1, str2) {
17176
- let i;
17177
- for (i = 0; i < str1.length && i < str2.length; i++) if (str1[i] != str2[i]) return str1.slice(0, i);
17178
- return str1.slice(0, i);
17179
- }
17180
- function longestCommonSuffix(str1, str2) {
17181
- let i;
17182
- if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) return "";
17183
- for (i = 0; i < str1.length && i < str2.length; i++) if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) return str1.slice(-i);
17184
- return str1.slice(-i);
17185
- }
17186
- function replacePrefix(string, oldPrefix, newPrefix) {
17187
- if (string.slice(0, oldPrefix.length) != oldPrefix) throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
17188
- return newPrefix + string.slice(oldPrefix.length);
17189
- }
17190
- function replaceSuffix(string, oldSuffix, newSuffix) {
17191
- if (!oldSuffix) return string + newSuffix;
17192
- if (string.slice(-oldSuffix.length) != oldSuffix) throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
17193
- return string.slice(0, -oldSuffix.length) + newSuffix;
17194
- }
17195
- function removePrefix(string, oldPrefix) {
17196
- return replacePrefix(string, oldPrefix, "");
17197
- }
17198
- function removeSuffix(string, oldSuffix) {
17199
- return replaceSuffix(string, oldSuffix, "");
17200
- }
17201
- function maximumOverlap(string1, string2) {
17202
- return string2.slice(0, overlapCount(string1, string2));
17203
- }
17204
- function overlapCount(a, b) {
17205
- let startA = 0;
17206
- if (a.length > b.length) startA = a.length - b.length;
17207
- let endB = b.length;
17208
- if (a.length < b.length) endB = a.length;
17209
- const map = Array(endB);
17210
- let k = 0;
17211
- map[0] = 0;
17212
- for (let j = 1; j < endB; j++) {
17213
- if (b[j] == b[k]) map[j] = map[k];
17214
- else map[j] = k;
17215
- while (k > 0 && b[j] != b[k]) k = map[k];
17216
- if (b[j] == b[k]) k++;
17217
- }
17218
- k = 0;
17219
- for (let i = startA; i < a.length; i++) {
17220
- while (k > 0 && a[i] != b[k]) k = map[k];
17221
- if (a[i] == b[k]) k++;
17222
- }
17223
- return k;
17224
- }
17225
- /**
17226
- * Split a string into segments using a word segmenter, merging consecutive
17227
- * segments if they are both whitespace segments. Whitespace segments can
17228
- * appear adjacent to one another for two reasons:
17229
- * - newlines always get their own segment
17230
- * - where a diacritic is attached to a whitespace character in the text, the
17231
- * segment ends after the diacritic, so e.g. " \u0300 " becomes two segments.
17232
- * This function therefore runs the segmenter's .segment() method and then
17233
- * merges consecutive segments of whitespace into a single part.
17234
- */
17235
- function segment(string, segmenter) {
17236
- const parts = [];
17237
- for (const segmentObj of Array.from(segmenter.segment(string))) {
17238
- const segment = segmentObj.segment;
17239
- if (parts.length && /\s/.test(parts[parts.length - 1]) && /\s/.test(segment)) parts[parts.length - 1] += segment;
17240
- else parts.push(segment);
17241
- }
17242
- return parts;
17243
- }
17244
- function trailingWs(string, segmenter) {
17245
- if (segmenter) return leadingAndTrailingWs(string, segmenter)[1];
17246
- let i;
17247
- for (i = string.length - 1; i >= 0; i--) if (!string[i].match(/\s/)) break;
17248
- return string.substring(i + 1);
17249
- }
17250
- function leadingWs(string, segmenter) {
17251
- if (segmenter) return leadingAndTrailingWs(string, segmenter)[0];
17252
- const match = string.match(/^\s*/);
17253
- return match ? match[0] : "";
17254
- }
17255
- function leadingAndTrailingWs(string, segmenter) {
17256
- if (!segmenter) return [leadingWs(string), trailingWs(string)];
17257
- if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
17258
- const segments = segment(string, segmenter);
17259
- const firstSeg = segments[0];
17260
- const lastSeg = segments[segments.length - 1];
17261
- return [/\s/.test(firstSeg) ? firstSeg : "", /\s/.test(lastSeg) ? lastSeg : ""];
17262
- }
17263
-
17264
- //#endregion
17265
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/word.js
17266
- const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
17267
- const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
17268
- var WordDiff = class extends Diff {
17269
- equals(left, right, options) {
17270
- if (options.ignoreCase) {
17271
- left = left.toLowerCase();
17272
- right = right.toLowerCase();
17201
+ function extend(namespace, delimiter) {
17202
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
17203
+ newDebug.log = this.log;
17204
+ return newDebug;
17273
17205
  }
17274
- return left.trim() === right.trim();
17275
- }
17276
- tokenize(value, options = {}) {
17277
- let parts;
17278
- if (options.intlSegmenter) {
17279
- const segmenter = options.intlSegmenter;
17280
- if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
17281
- parts = segment(value, segmenter);
17282
- } else parts = value.match(tokenizeIncludingWhitespace) || [];
17283
- const tokens = [];
17284
- let prevPart = null;
17285
- parts.forEach((part) => {
17286
- if (/\s/.test(part)) if (prevPart == null) tokens.push(part);
17287
- else tokens.push(tokens.pop() + part);
17288
- else if (prevPart != null && /\s/.test(prevPart)) if (tokens[tokens.length - 1] == prevPart) tokens.push(tokens.pop() + part);
17289
- else tokens.push(prevPart + part);
17290
- else tokens.push(part);
17291
- prevPart = part;
17292
- });
17293
- return tokens;
17294
- }
17295
- join(tokens) {
17296
- return tokens.map((token, i) => {
17297
- if (i == 0) return token;
17298
- else return token.replace(/^\s+/, "");
17299
- }).join("");
17300
- }
17301
- postProcess(changes, options) {
17302
- if (!changes || options.oneChangePerToken) return changes;
17303
- let lastKeep = null;
17304
- let insertion = null;
17305
- let deletion = null;
17306
- changes.forEach((change) => {
17307
- if (change.added) insertion = change;
17308
- else if (change.removed) deletion = change;
17309
- else {
17310
- if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change, options.intlSegmenter);
17311
- lastKeep = change;
17312
- insertion = null;
17313
- deletion = null;
17206
+ /**
17207
+ * Enables a debug mode by namespaces. This can include modes
17208
+ * separated by a colon and wildcards.
17209
+ *
17210
+ * @param {String} namespaces
17211
+ * @api public
17212
+ */
17213
+ function enable(namespaces) {
17214
+ createDebug.save(namespaces);
17215
+ createDebug.namespaces = namespaces;
17216
+ createDebug.names = [];
17217
+ createDebug.skips = [];
17218
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
17219
+ for (const ns of split) if (ns[0] === "-") createDebug.skips.push(ns.slice(1));
17220
+ else createDebug.names.push(ns);
17221
+ }
17222
+ /**
17223
+ * Checks if the given string matches a namespace template, honoring
17224
+ * asterisks as wildcards.
17225
+ *
17226
+ * @param {String} search
17227
+ * @param {String} template
17228
+ * @return {Boolean}
17229
+ */
17230
+ function matchesTemplate(search, template) {
17231
+ let searchIndex = 0;
17232
+ let templateIndex = 0;
17233
+ let starIndex = -1;
17234
+ let matchIndex = 0;
17235
+ while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
17236
+ starIndex = templateIndex;
17237
+ matchIndex = searchIndex;
17238
+ templateIndex++;
17239
+ } else {
17240
+ searchIndex++;
17241
+ templateIndex++;
17314
17242
  }
17315
- });
17316
- if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null, options.intlSegmenter);
17317
- return changes;
17318
- }
17319
- };
17320
- const wordDiff = new WordDiff();
17321
- function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep, segmenter) {
17322
- if (deletion && insertion) {
17323
- const [oldWsPrefix, oldWsSuffix] = leadingAndTrailingWs(deletion.value, segmenter);
17324
- const [newWsPrefix, newWsSuffix] = leadingAndTrailingWs(insertion.value, segmenter);
17325
- if (startKeep) {
17326
- const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
17327
- startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
17328
- deletion.value = removePrefix(deletion.value, commonWsPrefix);
17329
- insertion.value = removePrefix(insertion.value, commonWsPrefix);
17243
+ else if (starIndex !== -1) {
17244
+ templateIndex = starIndex + 1;
17245
+ matchIndex++;
17246
+ searchIndex = matchIndex;
17247
+ } else return false;
17248
+ while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
17249
+ return templateIndex === template.length;
17330
17250
  }
17331
- if (endKeep) {
17332
- const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
17333
- endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
17334
- deletion.value = removeSuffix(deletion.value, commonWsSuffix);
17335
- insertion.value = removeSuffix(insertion.value, commonWsSuffix);
17251
+ /**
17252
+ * Disable debug output.
17253
+ *
17254
+ * @return {String} namespaces
17255
+ * @api public
17256
+ */
17257
+ function disable() {
17258
+ const namespaces = [...createDebug.names, ...createDebug.skips.map((namespace) => "-" + namespace)].join(",");
17259
+ createDebug.enable("");
17260
+ return namespaces;
17336
17261
  }
17337
- } else if (insertion) {
17338
- if (startKeep) {
17339
- const ws = leadingWs(insertion.value, segmenter);
17340
- insertion.value = insertion.value.substring(ws.length);
17262
+ /**
17263
+ * Returns true if the given mode name is enabled, false otherwise.
17264
+ *
17265
+ * @param {String} name
17266
+ * @return {Boolean}
17267
+ * @api public
17268
+ */
17269
+ function enabled(name) {
17270
+ for (const skip of createDebug.skips) if (matchesTemplate(name, skip)) return false;
17271
+ for (const ns of createDebug.names) if (matchesTemplate(name, ns)) return true;
17272
+ return false;
17341
17273
  }
17342
- if (endKeep) {
17343
- const ws = leadingWs(endKeep.value, segmenter);
17344
- endKeep.value = endKeep.value.substring(ws.length);
17274
+ /**
17275
+ * Coerce `val`.
17276
+ *
17277
+ * @param {Mixed} val
17278
+ * @return {Mixed}
17279
+ * @api private
17280
+ */
17281
+ function coerce(val) {
17282
+ if (val instanceof Error) return val.stack || val.message;
17283
+ return val;
17345
17284
  }
17346
- } else if (startKeep && endKeep) {
17347
- const newWsFull = leadingWs(endKeep.value, segmenter), [delWsStart, delWsEnd] = leadingAndTrailingWs(deletion.value, segmenter);
17348
- const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
17349
- deletion.value = removePrefix(deletion.value, newWsStart);
17350
- const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
17351
- deletion.value = removeSuffix(deletion.value, newWsEnd);
17352
- endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
17353
- startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
17354
- } else if (endKeep) {
17355
- const endKeepWsPrefix = leadingWs(endKeep.value, segmenter);
17356
- const overlap = maximumOverlap(trailingWs(deletion.value, segmenter), endKeepWsPrefix);
17357
- deletion.value = removeSuffix(deletion.value, overlap);
17358
- } else if (startKeep) {
17359
- const overlap = maximumOverlap(trailingWs(startKeep.value, segmenter), leadingWs(deletion.value, segmenter));
17360
- deletion.value = removePrefix(deletion.value, overlap);
17361
- }
17362
- }
17363
- var WordsWithSpaceDiff = class extends Diff {
17364
- tokenize(value) {
17365
- const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
17366
- return value.match(regex) || [];
17367
- }
17368
- };
17369
- const wordsWithSpaceDiff = new WordsWithSpaceDiff();
17370
-
17371
- //#endregion
17372
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/line.js
17373
- var LineDiff = class extends Diff {
17374
- constructor() {
17375
- super(...arguments);
17376
- this.tokenize = tokenize;
17377
- }
17378
- equals(left, right, options) {
17379
- if (options.ignoreWhitespace) {
17380
- if (!options.newlineIsToken || !left.includes("\n")) left = left.trim();
17381
- if (!options.newlineIsToken || !right.includes("\n")) right = right.trim();
17382
- } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
17383
- if (left.endsWith("\n")) left = left.slice(0, -1);
17384
- if (right.endsWith("\n")) right = right.slice(0, -1);
17285
+ /**
17286
+ * XXX DO NOT USE. This is a temporary stub function.
17287
+ * XXX It WILL be removed in the next major release.
17288
+ */
17289
+ function destroy() {
17290
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
17385
17291
  }
17386
- return super.equals(left, right, options);
17387
- }
17388
- };
17389
- const lineDiff = new LineDiff();
17390
- function diffLines(oldStr, newStr, options) {
17391
- return lineDiff.diff(oldStr, newStr, options);
17392
- }
17393
- function tokenize(value, options) {
17394
- if (options.stripTrailingCr) value = value.replace(/\r\n/g, "\n");
17395
- const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
17396
- if (!linesAndNewlines[linesAndNewlines.length - 1]) linesAndNewlines.pop();
17397
- for (let i = 0; i < linesAndNewlines.length; i++) {
17398
- const line = linesAndNewlines[i];
17399
- if (i % 2 && !options.newlineIsToken) retLines[retLines.length - 1] += line;
17400
- else retLines.push(line);
17292
+ createDebug.enable(createDebug.load());
17293
+ return createDebug;
17401
17294
  }
17402
- return retLines;
17403
- }
17295
+ module.exports = setup;
17296
+ }));
17404
17297
 
17405
17298
  //#endregion
17406
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/sentence.js
17407
- function isSentenceEndPunct(char) {
17408
- return char == "." || char == "!" || char == "?";
17409
- }
17410
- var SentenceDiff = class extends Diff {
17411
- tokenize(value) {
17412
- var _a;
17413
- const result = [];
17414
- let tokenStartI = 0;
17415
- for (let i = 0; i < value.length; i++) {
17416
- if (i == value.length - 1) {
17417
- result.push(value.slice(tokenStartI));
17418
- break;
17419
- }
17420
- if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
17421
- result.push(value.slice(tokenStartI, i + 1));
17422
- i = tokenStartI = i + 1;
17423
- while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\s/)) i++;
17424
- result.push(value.slice(tokenStartI, i + 1));
17425
- tokenStartI = i + 1;
17299
+ //#region node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
17300
+ var require_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17301
+ /**
17302
+ * This is the web browser implementation of `debug()`.
17303
+ */
17304
+ exports.formatArgs = formatArgs;
17305
+ exports.save = save;
17306
+ exports.load = load;
17307
+ exports.useColors = useColors;
17308
+ exports.storage = localstorage();
17309
+ exports.destroy = (() => {
17310
+ let warned = false;
17311
+ return () => {
17312
+ if (!warned) {
17313
+ warned = true;
17314
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
17426
17315
  }
17427
- }
17428
- return result;
17429
- }
17430
- };
17431
- const sentenceDiff = new SentenceDiff();
17432
-
17433
- //#endregion
17434
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/css.js
17435
- var CssDiff = class extends Diff {
17436
- tokenize(value) {
17437
- return value.split(/([{}:;,]|\s+)/);
17438
- }
17439
- };
17440
- const cssDiff = new CssDiff();
17441
-
17442
- //#endregion
17443
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/json.js
17444
- var JsonDiff = class extends Diff {
17445
- constructor() {
17446
- super(...arguments);
17447
- this.tokenize = tokenize;
17316
+ };
17317
+ })();
17318
+ /**
17319
+ * Colors.
17320
+ */
17321
+ exports.colors = [
17322
+ "#0000CC",
17323
+ "#0000FF",
17324
+ "#0033CC",
17325
+ "#0033FF",
17326
+ "#0066CC",
17327
+ "#0066FF",
17328
+ "#0099CC",
17329
+ "#0099FF",
17330
+ "#00CC00",
17331
+ "#00CC33",
17332
+ "#00CC66",
17333
+ "#00CC99",
17334
+ "#00CCCC",
17335
+ "#00CCFF",
17336
+ "#3300CC",
17337
+ "#3300FF",
17338
+ "#3333CC",
17339
+ "#3333FF",
17340
+ "#3366CC",
17341
+ "#3366FF",
17342
+ "#3399CC",
17343
+ "#3399FF",
17344
+ "#33CC00",
17345
+ "#33CC33",
17346
+ "#33CC66",
17347
+ "#33CC99",
17348
+ "#33CCCC",
17349
+ "#33CCFF",
17350
+ "#6600CC",
17351
+ "#6600FF",
17352
+ "#6633CC",
17353
+ "#6633FF",
17354
+ "#66CC00",
17355
+ "#66CC33",
17356
+ "#9900CC",
17357
+ "#9900FF",
17358
+ "#9933CC",
17359
+ "#9933FF",
17360
+ "#99CC00",
17361
+ "#99CC33",
17362
+ "#CC0000",
17363
+ "#CC0033",
17364
+ "#CC0066",
17365
+ "#CC0099",
17366
+ "#CC00CC",
17367
+ "#CC00FF",
17368
+ "#CC3300",
17369
+ "#CC3333",
17370
+ "#CC3366",
17371
+ "#CC3399",
17372
+ "#CC33CC",
17373
+ "#CC33FF",
17374
+ "#CC6600",
17375
+ "#CC6633",
17376
+ "#CC9900",
17377
+ "#CC9933",
17378
+ "#CCCC00",
17379
+ "#CCCC33",
17380
+ "#FF0000",
17381
+ "#FF0033",
17382
+ "#FF0066",
17383
+ "#FF0099",
17384
+ "#FF00CC",
17385
+ "#FF00FF",
17386
+ "#FF3300",
17387
+ "#FF3333",
17388
+ "#FF3366",
17389
+ "#FF3399",
17390
+ "#FF33CC",
17391
+ "#FF33FF",
17392
+ "#FF6600",
17393
+ "#FF6633",
17394
+ "#FF9900",
17395
+ "#FF9933",
17396
+ "#FFCC00",
17397
+ "#FFCC33"
17398
+ ];
17399
+ /**
17400
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
17401
+ * and the Firebug extension (any Firefox version) are known
17402
+ * to support "%c" CSS customizations.
17403
+ *
17404
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
17405
+ */
17406
+ function useColors() {
17407
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return true;
17408
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return false;
17409
+ let m;
17410
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
17448
17411
  }
17449
- get useLongestToken() {
17450
- return true;
17412
+ /**
17413
+ * Colorize log arguments if enabled.
17414
+ *
17415
+ * @api public
17416
+ */
17417
+ function formatArgs(args) {
17418
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
17419
+ if (!this.useColors) return;
17420
+ const c = "color: " + this.color;
17421
+ args.splice(1, 0, c, "color: inherit");
17422
+ let index = 0;
17423
+ let lastC = 0;
17424
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
17425
+ if (match === "%%") return;
17426
+ index++;
17427
+ if (match === "%c") lastC = index;
17428
+ });
17429
+ args.splice(lastC, 0, c);
17451
17430
  }
17452
- castInput(value, options) {
17453
- const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
17454
- return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
17431
+ /**
17432
+ * Invokes `console.debug()` when available.
17433
+ * No-op when `console.debug` is not a "function".
17434
+ * If `console.debug` is not available, falls back
17435
+ * to `console.log`.
17436
+ *
17437
+ * @api public
17438
+ */
17439
+ exports.log = console.debug || console.log || (() => {});
17440
+ /**
17441
+ * Save `namespaces`.
17442
+ *
17443
+ * @param {String} namespaces
17444
+ * @api private
17445
+ */
17446
+ function save(namespaces) {
17447
+ try {
17448
+ if (namespaces) exports.storage.setItem("debug", namespaces);
17449
+ else exports.storage.removeItem("debug");
17450
+ } catch (error) {}
17455
17451
  }
17456
- equals(left, right, options) {
17457
- return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
17452
+ /**
17453
+ * Load `namespaces`.
17454
+ *
17455
+ * @return {String} returns the previously persisted debug modes
17456
+ * @api private
17457
+ */
17458
+ function load() {
17459
+ let r;
17460
+ try {
17461
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
17462
+ } catch (error) {}
17463
+ if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
17464
+ return r;
17458
17465
  }
17459
- };
17460
- const jsonDiff = new JsonDiff();
17461
- function canonicalize(obj, stack, replacementStack, replacer, key) {
17462
- stack = stack || [];
17463
- replacementStack = replacementStack || [];
17464
- if (replacer) obj = replacer(key === void 0 ? "" : key, obj);
17465
- let i;
17466
- for (i = 0; i < stack.length; i += 1) if (stack[i] === obj) return replacementStack[i];
17467
- let canonicalizedObj;
17468
- if ("[object Array]" === Object.prototype.toString.call(obj)) {
17469
- stack.push(obj);
17470
- canonicalizedObj = new Array(obj.length);
17471
- replacementStack.push(canonicalizedObj);
17472
- for (i = 0; i < obj.length; i += 1) canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
17473
- stack.pop();
17474
- replacementStack.pop();
17475
- return canonicalizedObj;
17466
+ /**
17467
+ * Localstorage attempts to return the localstorage.
17468
+ *
17469
+ * This is necessary because safari throws
17470
+ * when a user disables cookies/localstorage
17471
+ * and you attempt to access it.
17472
+ *
17473
+ * @return {LocalStorage}
17474
+ * @api private
17475
+ */
17476
+ function localstorage() {
17477
+ try {
17478
+ return localStorage;
17479
+ } catch (error) {}
17476
17480
  }
17477
- if (obj && obj.toJSON) obj = obj.toJSON();
17478
- if (typeof obj === "object" && obj !== null) {
17479
- stack.push(obj);
17480
- canonicalizedObj = {};
17481
- replacementStack.push(canonicalizedObj);
17482
- const sortedKeys = [];
17483
- let key;
17484
- for (key in obj)
17485
- /* istanbul ignore else */
17486
- if (Object.prototype.hasOwnProperty.call(obj, key)) sortedKeys.push(key);
17487
- sortedKeys.sort();
17488
- for (i = 0; i < sortedKeys.length; i += 1) {
17489
- key = sortedKeys[i];
17490
- canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);
17481
+ module.exports = require_common$3()(exports);
17482
+ const { formatters } = module.exports;
17483
+ /**
17484
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
17485
+ */
17486
+ formatters.j = function(v) {
17487
+ try {
17488
+ return JSON.stringify(v);
17489
+ } catch (error) {
17490
+ return "[UnexpectedJSONParseError]: " + error.message;
17491
17491
  }
17492
- stack.pop();
17493
- replacementStack.pop();
17494
- } else canonicalizedObj = obj;
17495
- return canonicalizedObj;
17496
- }
17492
+ };
17493
+ }));
17497
17494
 
17498
17495
  //#endregion
17499
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/array.js
17500
- var ArrayDiff = class extends Diff {
17501
- tokenize(value) {
17502
- return value.slice();
17503
- }
17504
- join(value) {
17505
- return value;
17506
- }
17507
- removeEmpty(value) {
17508
- return value;
17496
+ //#region node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
17497
+ var require_node$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17498
+ /**
17499
+ * Module dependencies.
17500
+ */
17501
+ const tty = __require("tty");
17502
+ const util$8 = __require("util");
17503
+ /**
17504
+ * This is the Node.js implementation of `debug()`.
17505
+ */
17506
+ exports.init = init;
17507
+ exports.log = log;
17508
+ exports.formatArgs = formatArgs;
17509
+ exports.save = save;
17510
+ exports.load = load;
17511
+ exports.useColors = useColors;
17512
+ exports.destroy = util$8.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
17513
+ /**
17514
+ * Colors.
17515
+ */
17516
+ exports.colors = [
17517
+ 6,
17518
+ 2,
17519
+ 3,
17520
+ 4,
17521
+ 5,
17522
+ 1
17523
+ ];
17524
+ try {
17525
+ const supportsColor = __require("supports-color");
17526
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) exports.colors = [
17527
+ 20,
17528
+ 21,
17529
+ 26,
17530
+ 27,
17531
+ 32,
17532
+ 33,
17533
+ 38,
17534
+ 39,
17535
+ 40,
17536
+ 41,
17537
+ 42,
17538
+ 43,
17539
+ 44,
17540
+ 45,
17541
+ 56,
17542
+ 57,
17543
+ 62,
17544
+ 63,
17545
+ 68,
17546
+ 69,
17547
+ 74,
17548
+ 75,
17549
+ 76,
17550
+ 77,
17551
+ 78,
17552
+ 79,
17553
+ 80,
17554
+ 81,
17555
+ 92,
17556
+ 93,
17557
+ 98,
17558
+ 99,
17559
+ 112,
17560
+ 113,
17561
+ 128,
17562
+ 129,
17563
+ 134,
17564
+ 135,
17565
+ 148,
17566
+ 149,
17567
+ 160,
17568
+ 161,
17569
+ 162,
17570
+ 163,
17571
+ 164,
17572
+ 165,
17573
+ 166,
17574
+ 167,
17575
+ 168,
17576
+ 169,
17577
+ 170,
17578
+ 171,
17579
+ 172,
17580
+ 173,
17581
+ 178,
17582
+ 179,
17583
+ 184,
17584
+ 185,
17585
+ 196,
17586
+ 197,
17587
+ 198,
17588
+ 199,
17589
+ 200,
17590
+ 201,
17591
+ 202,
17592
+ 203,
17593
+ 204,
17594
+ 205,
17595
+ 206,
17596
+ 207,
17597
+ 208,
17598
+ 209,
17599
+ 214,
17600
+ 215,
17601
+ 220,
17602
+ 221
17603
+ ];
17604
+ } catch (error) {}
17605
+ /**
17606
+ * Build up the default `inspectOpts` object from the environment variables.
17607
+ *
17608
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
17609
+ */
17610
+ exports.inspectOpts = Object.keys(process.env).filter((key) => {
17611
+ return /^debug_/i.test(key);
17612
+ }).reduce((obj, key) => {
17613
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
17614
+ return k.toUpperCase();
17615
+ });
17616
+ let val = process.env[key];
17617
+ if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
17618
+ else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
17619
+ else if (val === "null") val = null;
17620
+ else val = Number(val);
17621
+ obj[prop] = val;
17622
+ return obj;
17623
+ }, {});
17624
+ /**
17625
+ * Is stdout a TTY? Colored output is enabled when `true`.
17626
+ */
17627
+ function useColors() {
17628
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
17509
17629
  }
17510
- };
17511
- const arrayDiff = new ArrayDiff();
17512
-
17513
- //#endregion
17514
- //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/patch/create.js
17515
- const INCLUDE_HEADERS = {
17516
- includeIndex: true,
17517
- includeUnderline: true,
17518
- includeFileHeaders: true
17519
- };
17520
- function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
17521
- let optionsObj;
17522
- if (!options) optionsObj = {};
17523
- else if (typeof options === "function") optionsObj = { callback: options };
17524
- else optionsObj = options;
17525
- if (typeof optionsObj.context === "undefined") optionsObj.context = 4;
17526
- const context = optionsObj.context;
17527
- if (optionsObj.newlineIsToken) throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
17528
- if (!optionsObj.callback) return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
17529
- else {
17530
- const { callback } = optionsObj;
17531
- diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
17532
- callback(diffLinesResultToPatch(diff));
17533
- } }));
17630
+ /**
17631
+ * Adds ANSI color escape codes if enabled.
17632
+ *
17633
+ * @api public
17634
+ */
17635
+ function formatArgs(args) {
17636
+ const { namespace: name, useColors } = this;
17637
+ if (useColors) {
17638
+ const c = this.color;
17639
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
17640
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
17641
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
17642
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
17643
+ } else args[0] = getDate() + name + " " + args[0];
17534
17644
  }
17535
- function diffLinesResultToPatch(diff) {
17536
- if (!diff) return;
17537
- diff.push({
17538
- value: "",
17539
- lines: []
17540
- });
17541
- function contextLines(lines) {
17542
- return lines.map(function(entry) {
17543
- return " " + entry;
17544
- });
17545
- }
17546
- const hunks = [];
17547
- let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
17548
- for (let i = 0; i < diff.length; i++) {
17549
- const current = diff[i], lines = current.lines || splitLines(current.value);
17550
- current.lines = lines;
17551
- if (current.added || current.removed) {
17552
- if (!oldRangeStart) {
17553
- const prev = diff[i - 1];
17554
- oldRangeStart = oldLine;
17555
- newRangeStart = newLine;
17556
- if (prev) {
17557
- curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
17558
- oldRangeStart -= curRange.length;
17559
- newRangeStart -= curRange.length;
17560
- }
17561
- }
17562
- for (const line of lines) curRange.push((current.added ? "+" : "-") + line);
17563
- if (current.added) newLine += lines.length;
17564
- else oldLine += lines.length;
17565
- } else {
17566
- if (oldRangeStart) if (lines.length <= context * 2 && i < diff.length - 2) for (const line of contextLines(lines)) curRange.push(line);
17567
- else {
17568
- const contextSize = Math.min(lines.length, context);
17569
- for (const line of contextLines(lines.slice(0, contextSize))) curRange.push(line);
17570
- const hunk = {
17571
- oldStart: oldRangeStart,
17572
- oldLines: oldLine - oldRangeStart + contextSize,
17573
- newStart: newRangeStart,
17574
- newLines: newLine - newRangeStart + contextSize,
17575
- lines: curRange
17576
- };
17577
- hunks.push(hunk);
17578
- oldRangeStart = 0;
17579
- newRangeStart = 0;
17580
- curRange = [];
17581
- }
17582
- oldLine += lines.length;
17583
- newLine += lines.length;
17584
- }
17585
- }
17586
- for (const hunk of hunks) for (let i = 0; i < hunk.lines.length; i++) if (hunk.lines[i].endsWith("\n")) hunk.lines[i] = hunk.lines[i].slice(0, -1);
17587
- else {
17588
- hunk.lines.splice(i + 1, 0, "\");
17589
- i++;
17590
- }
17591
- return {
17592
- oldFileName,
17593
- newFileName,
17594
- oldHeader,
17595
- newHeader,
17596
- hunks
17597
- };
17645
+ function getDate() {
17646
+ if (exports.inspectOpts.hideDate) return "";
17647
+ return (/* @__PURE__ */ new Date()).toISOString() + " ";
17598
17648
  }
17599
- }
17600
- /**
17601
- * creates a unified diff patch.
17602
- * @param patch either a single structured patch object (as returned by `structuredPatch`) or an array of them (as returned by `parsePatch`)
17603
- */
17604
- function formatPatch(patch, headerOptions) {
17605
- if (!headerOptions) headerOptions = INCLUDE_HEADERS;
17606
- if (Array.isArray(patch)) {
17607
- if (patch.length > 1 && !headerOptions.includeFileHeaders) throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");
17608
- return patch.map((p) => formatPatch(p, headerOptions)).join("\n");
17649
+ /**
17650
+ * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
17651
+ */
17652
+ function log(...args) {
17653
+ return process.stderr.write(util$8.formatWithOptions(exports.inspectOpts, ...args) + "\n");
17609
17654
  }
17610
- const ret = [];
17611
- if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName) ret.push("Index: " + patch.oldFileName);
17612
- if (headerOptions.includeUnderline) ret.push("===================================================================");
17613
- if (headerOptions.includeFileHeaders) {
17614
- ret.push("--- " + patch.oldFileName + (typeof patch.oldHeader === "undefined" ? "" : " " + patch.oldHeader));
17615
- ret.push("+++ " + patch.newFileName + (typeof patch.newHeader === "undefined" ? "" : " " + patch.newHeader));
17655
+ /**
17656
+ * Save `namespaces`.
17657
+ *
17658
+ * @param {String} namespaces
17659
+ * @api private
17660
+ */
17661
+ function save(namespaces) {
17662
+ if (namespaces) process.env.DEBUG = namespaces;
17663
+ else delete process.env.DEBUG;
17616
17664
  }
17617
- for (let i = 0; i < patch.hunks.length; i++) {
17618
- const hunk = patch.hunks[i];
17619
- if (hunk.oldLines === 0) hunk.oldStart -= 1;
17620
- if (hunk.newLines === 0) hunk.newStart -= 1;
17621
- ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
17622
- for (const line of hunk.lines) ret.push(line);
17665
+ /**
17666
+ * Load `namespaces`.
17667
+ *
17668
+ * @return {String} returns the previously persisted debug modes
17669
+ * @api private
17670
+ */
17671
+ function load() {
17672
+ return process.env.DEBUG;
17623
17673
  }
17624
- return ret.join("\n") + "\n";
17625
- }
17626
- function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
17627
- if (typeof options === "function") options = { callback: options };
17628
- if (!(options === null || options === void 0 ? void 0 : options.callback)) {
17629
- const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
17630
- if (!patchObj) return;
17631
- return formatPatch(patchObj, options === null || options === void 0 ? void 0 : options.headerOptions);
17632
- } else {
17633
- const { callback } = options;
17634
- structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
17635
- if (!patchObj) callback(void 0);
17636
- else callback(formatPatch(patchObj, options.headerOptions));
17637
- } }));
17674
+ /**
17675
+ * Init logic for `debug` instances.
17676
+ *
17677
+ * Create a new `inspectOpts` object in case `useColors` is set
17678
+ * differently for a particular `debug` instance.
17679
+ */
17680
+ function init(debug) {
17681
+ debug.inspectOpts = {};
17682
+ const keys = Object.keys(exports.inspectOpts);
17683
+ for (let i = 0; i < keys.length; i++) debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
17638
17684
  }
17639
- }
17640
- function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
17641
- return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
17642
- }
17643
- /**
17644
- * Split `text` into an array of lines, including the trailing newline character (where present)
17645
- */
17646
- function splitLines(text) {
17647
- const hasTrailingNl = text.endsWith("\n");
17648
- const result = text.split("\n").map((line) => line + "\n");
17649
- if (hasTrailingNl) result.pop();
17650
- else result.push(result.pop().slice(0, -1));
17651
- return result;
17652
- }
17653
-
17654
- //#endregion
17655
- //#region ../../packages/local-file-shell/src/file/expandTilde.ts
17656
- /**
17657
- * Expand a leading `~` (or `~/...`, `~\...`) to the user's home directory.
17658
- * Pass-through for any other input — the shell normally handles `~` expansion,
17659
- * but Node fs APIs do not, so paths supplied by the LLM (or pasted by users)
17660
- * would otherwise fail with ENOENT.
17661
- */
17662
- const expandTilde = (input) => {
17663
- if (!input) return input;
17664
- if (input === "~") return os.homedir();
17665
- if (input.startsWith("~/") || input.startsWith("~\\")) return path.join(os.homedir(), input.slice(2));
17666
- return input;
17667
- };
17685
+ module.exports = require_common$3()(exports);
17686
+ const { formatters } = module.exports;
17687
+ /**
17688
+ * Map %o to `util.inspect()`, all on a single line.
17689
+ */
17690
+ formatters.o = function(v) {
17691
+ this.inspectOpts.colors = this.useColors;
17692
+ return util$8.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
17693
+ };
17694
+ /**
17695
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
17696
+ */
17697
+ formatters.O = function(v) {
17698
+ this.inspectOpts.colors = this.useColors;
17699
+ return util$8.inspect(v, this.inspectOpts);
17700
+ };
17701
+ }));
17668
17702
 
17669
17703
  //#endregion
17670
- //#region ../../packages/local-file-shell/src/file/edit.ts
17671
- async function editLocalFile({ file_path: rawPath, old_string, new_string, replace_all = false }) {
17672
- const filePath = expandTilde(rawPath) ?? rawPath;
17673
- try {
17674
- const content = await readFile(filePath, "utf8");
17675
- if (!content.includes(old_string)) return {
17676
- error: "The specified old_string was not found in the file",
17677
- replacements: 0,
17678
- success: false
17679
- };
17680
- let newContent;
17681
- let replacements;
17682
- if (replace_all) {
17683
- const regex = new RegExp(old_string.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&"), "g");
17684
- const matches = content.match(regex);
17685
- replacements = matches ? matches.length : 0;
17686
- newContent = content.replaceAll(old_string, new_string);
17687
- } else {
17688
- const index = content.indexOf(old_string);
17689
- if (index === -1) return {
17690
- error: "Old string not found",
17691
- replacements: 0,
17692
- success: false
17693
- };
17694
- newContent = content.slice(0, index) + new_string + content.slice(index + old_string.length);
17695
- replacements = 1;
17696
- }
17697
- await writeFile(filePath, newContent, "utf8");
17698
- const patch = createPatch(filePath, content, newContent, "", "");
17699
- const diffText = `diff --git a${filePath} b${filePath}\n${patch}`;
17700
- const patchLines = patch.split("\n");
17701
- let linesAdded = 0;
17702
- let linesDeleted = 0;
17703
- for (const line of patchLines) if (line.startsWith("+") && !line.startsWith("+++")) linesAdded++;
17704
- else if (line.startsWith("-") && !line.startsWith("---")) linesDeleted++;
17705
- return {
17706
- diffText,
17707
- linesAdded,
17708
- linesDeleted,
17709
- replacements,
17710
- success: true
17711
- };
17712
- } catch (error) {
17713
- return {
17714
- error: error.message,
17715
- replacements: 0,
17716
- success: false
17717
- };
17718
- }
17719
- }
17704
+ //#region node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
17705
+ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17706
+ /**
17707
+ * Detect Electron renderer / nwjs process, which is node, but we should
17708
+ * treat as a browser.
17709
+ */
17710
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) module.exports = require_browser();
17711
+ else module.exports = require_node$1();
17712
+ }));
17720
17713
 
17721
17714
  //#endregion
17722
17715
  //#region node_modules/.pnpm/fast-glob@3.3.3/node_modules/fast-glob/out/utils/array.js
@@ -18327,7 +18320,7 @@ var require_to_regex_range = /* @__PURE__ */ __commonJSMin(((exports, module) =>
18327
18320
  * Licensed under the MIT License.
18328
18321
  */
18329
18322
  var require_fill_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18330
- const util$8 = __require("util");
18323
+ const util$7 = __require("util");
18331
18324
  const toRegexRange = require_to_regex_range();
18332
18325
  const isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
18333
18326
  const transform = (toNumber) => {
@@ -18399,7 +18392,7 @@ var require_fill_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18399
18392
  return toRegexRange(start, end, options);
18400
18393
  };
18401
18394
  const rangeError = (...args) => {
18402
- return /* @__PURE__ */ new RangeError("Invalid range arguments: " + util$8.inspect(...args));
18395
+ return /* @__PURE__ */ new RangeError("Invalid range arguments: " + util$7.inspect(...args));
18403
18396
  };
18404
18397
  const invalidRange = (start, end, options) => {
18405
18398
  if (options.strictRanges === true) throw rangeError([start, end]);
@@ -20941,7 +20934,7 @@ var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20941
20934
  //#endregion
20942
20935
  //#region node_modules/.pnpm/micromatch@4.0.8/node_modules/micromatch/index.js
20943
20936
  var require_micromatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20944
- const util$7 = __require("util");
20937
+ const util$6 = __require("util");
20945
20938
  const braces = require_braces();
20946
20939
  const picomatch = require_picomatch();
20947
20940
  const utils = require_utils$3();
@@ -21097,7 +21090,7 @@ var require_micromatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21097
21090
  * @api public
21098
21091
  */
21099
21092
  micromatch.contains = (str, pattern, options) => {
21100
- if (typeof str !== "string") throw new TypeError(`Expected a string: "${util$7.inspect(str)}"`);
21093
+ if (typeof str !== "string") throw new TypeError(`Expected a string: "${util$6.inspect(str)}"`);
21101
21094
  if (Array.isArray(pattern)) return pattern.some((p) => micromatch.contains(str, p, options));
21102
21095
  if (typeof pattern === "string") {
21103
21096
  if (isEmptyString(str) || isEmptyString(pattern)) return false;
@@ -21218,7 +21211,7 @@ var require_micromatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21218
21211
  * @api public
21219
21212
  */
21220
21213
  micromatch.all = (str, patterns, options) => {
21221
- if (typeof str !== "string") throw new TypeError(`Expected a string: "${util$7.inspect(str)}"`);
21214
+ if (typeof str !== "string") throw new TypeError(`Expected a string: "${util$6.inspect(str)}"`);
21222
21215
  return [].concat(patterns).every((p) => picomatch(p, options)(str));
21223
21216
  };
21224
21217
  /**
@@ -21990,7 +21983,7 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
21990
21983
 
21991
21984
  //#endregion
21992
21985
  //#region node_modules/.pnpm/@nodelib+fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/providers/common.js
21993
- var require_common$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
21986
+ var require_common$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
21994
21987
  Object.defineProperty(exports, "__esModule", { value: true });
21995
21988
  exports.joinPathSegments = void 0;
21996
21989
  function joinPathSegments(a, b, separator) {
@@ -22012,7 +22005,7 @@ var require_async$5 = /* @__PURE__ */ __commonJSMin(((exports) => {
22012
22005
  const rpl = require_run_parallel();
22013
22006
  const constants_1 = require_constants$1();
22014
22007
  const utils = require_utils$1();
22015
- const common = require_common$3();
22008
+ const common = require_common$2();
22016
22009
  function read(directory, settings, callback) {
22017
22010
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
22018
22011
  readdirWithFileTypes(directory, settings, callback);
@@ -22115,7 +22108,7 @@ var require_sync$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
22115
22108
  const fsStat = require_out$3();
22116
22109
  const constants_1 = require_constants$1();
22117
22110
  const utils = require_utils$1();
22118
- const common = require_common$3();
22111
+ const common = require_common$2();
22119
22112
  function read(directory, settings) {
22120
22113
  if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) return readdirWithFileTypes(directory, settings);
22121
22114
  return readdir(directory, settings);
@@ -22519,7 +22512,7 @@ var require_queue$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
22519
22512
 
22520
22513
  //#endregion
22521
22514
  //#region node_modules/.pnpm/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/readers/common.js
22522
- var require_common$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
22515
+ var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
22523
22516
  Object.defineProperty(exports, "__esModule", { value: true });
22524
22517
  exports.joinPathSegments = exports.replacePathSegmentSeparator = exports.isAppliedFilter = exports.isFatalError = void 0;
22525
22518
  function isFatalError(settings, error) {
@@ -22550,7 +22543,7 @@ var require_common$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
22550
22543
  //#region node_modules/.pnpm/@nodelib+fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/readers/reader.js
22551
22544
  var require_reader$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
22552
22545
  Object.defineProperty(exports, "__esModule", { value: true });
22553
- const common = require_common$2();
22546
+ const common = require_common$1();
22554
22547
  var Reader = class {
22555
22548
  constructor(_root, _settings) {
22556
22549
  this._root = _root;
@@ -22568,7 +22561,7 @@ var require_async$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
22568
22561
  const events_1 = __require("events");
22569
22562
  const fsScandir = require_out$2();
22570
22563
  const fastq = require_queue$1();
22571
- const common = require_common$2();
22564
+ const common = require_common$1();
22572
22565
  const reader_1 = require_reader$2();
22573
22566
  var AsyncReader = class extends reader_1.default {
22574
22567
  constructor(_root, _settings) {
@@ -22722,7 +22715,7 @@ var require_stream$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
22722
22715
  var require_sync$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
22723
22716
  Object.defineProperty(exports, "__esModule", { value: true });
22724
22717
  const fsScandir = require_out$2();
22725
- const common = require_common$2();
22718
+ const common = require_common$1();
22726
22719
  const reader_1 = require_reader$2();
22727
22720
  var SyncReader = class extends reader_1.default {
22728
22721
  constructor() {
@@ -23539,6 +23532,738 @@ var require_out = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23539
23532
  module.exports = FastGlob;
23540
23533
  }));
23541
23534
 
23535
+ //#endregion
23536
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/base.js
23537
+ var Diff = class {
23538
+ diff(oldStr, newStr, options = {}) {
23539
+ let callback;
23540
+ if (typeof options === "function") {
23541
+ callback = options;
23542
+ options = {};
23543
+ } else if ("callback" in options) callback = options.callback;
23544
+ const oldString = this.castInput(oldStr, options);
23545
+ const newString = this.castInput(newStr, options);
23546
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
23547
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
23548
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
23549
+ }
23550
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
23551
+ var _a;
23552
+ const done = (value) => {
23553
+ value = this.postProcess(value, options);
23554
+ if (callback) {
23555
+ setTimeout(function() {
23556
+ callback(value);
23557
+ }, 0);
23558
+ return;
23559
+ } else return value;
23560
+ };
23561
+ const newLen = newTokens.length, oldLen = oldTokens.length;
23562
+ let editLength = 1;
23563
+ let maxEditLength = newLen + oldLen;
23564
+ if (options.maxEditLength != null) maxEditLength = Math.min(maxEditLength, options.maxEditLength);
23565
+ const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
23566
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
23567
+ const bestPath = [{
23568
+ oldPos: -1,
23569
+ lastComponent: void 0
23570
+ }];
23571
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
23572
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
23573
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
23574
+ const execEditLength = () => {
23575
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
23576
+ let basePath;
23577
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
23578
+ if (removePath) bestPath[diagonalPath - 1] = void 0;
23579
+ let canAdd = false;
23580
+ if (addPath) {
23581
+ const addPathNewPos = addPath.oldPos - diagonalPath;
23582
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
23583
+ }
23584
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
23585
+ if (!canAdd && !canRemove) {
23586
+ bestPath[diagonalPath] = void 0;
23587
+ continue;
23588
+ }
23589
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) basePath = this.addToPath(addPath, true, false, 0, options);
23590
+ else basePath = this.addToPath(removePath, false, true, 1, options);
23591
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
23592
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
23593
+ else {
23594
+ bestPath[diagonalPath] = basePath;
23595
+ if (basePath.oldPos + 1 >= oldLen) maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
23596
+ if (newPos + 1 >= newLen) minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
23597
+ }
23598
+ }
23599
+ editLength++;
23600
+ };
23601
+ if (callback) (function exec() {
23602
+ setTimeout(function() {
23603
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) return callback(void 0);
23604
+ if (!execEditLength()) exec();
23605
+ }, 0);
23606
+ })();
23607
+ else while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
23608
+ const ret = execEditLength();
23609
+ if (ret) return ret;
23610
+ }
23611
+ }
23612
+ addToPath(path, added, removed, oldPosInc, options) {
23613
+ const last = path.lastComponent;
23614
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) return {
23615
+ oldPos: path.oldPos + oldPosInc,
23616
+ lastComponent: {
23617
+ count: last.count + 1,
23618
+ added,
23619
+ removed,
23620
+ previousComponent: last.previousComponent
23621
+ }
23622
+ };
23623
+ else return {
23624
+ oldPos: path.oldPos + oldPosInc,
23625
+ lastComponent: {
23626
+ count: 1,
23627
+ added,
23628
+ removed,
23629
+ previousComponent: last
23630
+ }
23631
+ };
23632
+ }
23633
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
23634
+ const newLen = newTokens.length, oldLen = oldTokens.length;
23635
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
23636
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
23637
+ newPos++;
23638
+ oldPos++;
23639
+ commonCount++;
23640
+ if (options.oneChangePerToken) basePath.lastComponent = {
23641
+ count: 1,
23642
+ previousComponent: basePath.lastComponent,
23643
+ added: false,
23644
+ removed: false
23645
+ };
23646
+ }
23647
+ if (commonCount && !options.oneChangePerToken) basePath.lastComponent = {
23648
+ count: commonCount,
23649
+ previousComponent: basePath.lastComponent,
23650
+ added: false,
23651
+ removed: false
23652
+ };
23653
+ basePath.oldPos = oldPos;
23654
+ return newPos;
23655
+ }
23656
+ equals(left, right, options) {
23657
+ if (options.comparator) return options.comparator(left, right);
23658
+ else return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
23659
+ }
23660
+ removeEmpty(array) {
23661
+ const ret = [];
23662
+ for (let i = 0; i < array.length; i++) if (array[i]) ret.push(array[i]);
23663
+ return ret;
23664
+ }
23665
+ castInput(value, options) {
23666
+ return value;
23667
+ }
23668
+ tokenize(value, options) {
23669
+ return Array.from(value);
23670
+ }
23671
+ join(chars) {
23672
+ return chars.join("");
23673
+ }
23674
+ postProcess(changeObjects, options) {
23675
+ return changeObjects;
23676
+ }
23677
+ get useLongestToken() {
23678
+ return false;
23679
+ }
23680
+ buildValues(lastComponent, newTokens, oldTokens) {
23681
+ const components = [];
23682
+ let nextComponent;
23683
+ while (lastComponent) {
23684
+ components.push(lastComponent);
23685
+ nextComponent = lastComponent.previousComponent;
23686
+ delete lastComponent.previousComponent;
23687
+ lastComponent = nextComponent;
23688
+ }
23689
+ components.reverse();
23690
+ const componentLen = components.length;
23691
+ let componentPos = 0, newPos = 0, oldPos = 0;
23692
+ for (; componentPos < componentLen; componentPos++) {
23693
+ const component = components[componentPos];
23694
+ if (!component.removed) {
23695
+ if (!component.added && this.useLongestToken) {
23696
+ let value = newTokens.slice(newPos, newPos + component.count);
23697
+ value = value.map(function(value, i) {
23698
+ const oldValue = oldTokens[oldPos + i];
23699
+ return oldValue.length > value.length ? oldValue : value;
23700
+ });
23701
+ component.value = this.join(value);
23702
+ } else component.value = this.join(newTokens.slice(newPos, newPos + component.count));
23703
+ newPos += component.count;
23704
+ if (!component.added) oldPos += component.count;
23705
+ } else {
23706
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
23707
+ oldPos += component.count;
23708
+ }
23709
+ }
23710
+ return components;
23711
+ }
23712
+ };
23713
+
23714
+ //#endregion
23715
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/character.js
23716
+ var CharacterDiff = class extends Diff {};
23717
+ const characterDiff = new CharacterDiff();
23718
+
23719
+ //#endregion
23720
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/util/string.js
23721
+ function longestCommonPrefix(str1, str2) {
23722
+ let i;
23723
+ for (i = 0; i < str1.length && i < str2.length; i++) if (str1[i] != str2[i]) return str1.slice(0, i);
23724
+ return str1.slice(0, i);
23725
+ }
23726
+ function longestCommonSuffix(str1, str2) {
23727
+ let i;
23728
+ if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) return "";
23729
+ for (i = 0; i < str1.length && i < str2.length; i++) if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) return str1.slice(-i);
23730
+ return str1.slice(-i);
23731
+ }
23732
+ function replacePrefix(string, oldPrefix, newPrefix) {
23733
+ if (string.slice(0, oldPrefix.length) != oldPrefix) throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
23734
+ return newPrefix + string.slice(oldPrefix.length);
23735
+ }
23736
+ function replaceSuffix(string, oldSuffix, newSuffix) {
23737
+ if (!oldSuffix) return string + newSuffix;
23738
+ if (string.slice(-oldSuffix.length) != oldSuffix) throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
23739
+ return string.slice(0, -oldSuffix.length) + newSuffix;
23740
+ }
23741
+ function removePrefix(string, oldPrefix) {
23742
+ return replacePrefix(string, oldPrefix, "");
23743
+ }
23744
+ function removeSuffix(string, oldSuffix) {
23745
+ return replaceSuffix(string, oldSuffix, "");
23746
+ }
23747
+ function maximumOverlap(string1, string2) {
23748
+ return string2.slice(0, overlapCount(string1, string2));
23749
+ }
23750
+ function overlapCount(a, b) {
23751
+ let startA = 0;
23752
+ if (a.length > b.length) startA = a.length - b.length;
23753
+ let endB = b.length;
23754
+ if (a.length < b.length) endB = a.length;
23755
+ const map = Array(endB);
23756
+ let k = 0;
23757
+ map[0] = 0;
23758
+ for (let j = 1; j < endB; j++) {
23759
+ if (b[j] == b[k]) map[j] = map[k];
23760
+ else map[j] = k;
23761
+ while (k > 0 && b[j] != b[k]) k = map[k];
23762
+ if (b[j] == b[k]) k++;
23763
+ }
23764
+ k = 0;
23765
+ for (let i = startA; i < a.length; i++) {
23766
+ while (k > 0 && a[i] != b[k]) k = map[k];
23767
+ if (a[i] == b[k]) k++;
23768
+ }
23769
+ return k;
23770
+ }
23771
+ /**
23772
+ * Split a string into segments using a word segmenter, merging consecutive
23773
+ * segments if they are both whitespace segments. Whitespace segments can
23774
+ * appear adjacent to one another for two reasons:
23775
+ * - newlines always get their own segment
23776
+ * - where a diacritic is attached to a whitespace character in the text, the
23777
+ * segment ends after the diacritic, so e.g. " \u0300 " becomes two segments.
23778
+ * This function therefore runs the segmenter's .segment() method and then
23779
+ * merges consecutive segments of whitespace into a single part.
23780
+ */
23781
+ function segment(string, segmenter) {
23782
+ const parts = [];
23783
+ for (const segmentObj of Array.from(segmenter.segment(string))) {
23784
+ const segment = segmentObj.segment;
23785
+ if (parts.length && /\s/.test(parts[parts.length - 1]) && /\s/.test(segment)) parts[parts.length - 1] += segment;
23786
+ else parts.push(segment);
23787
+ }
23788
+ return parts;
23789
+ }
23790
+ function trailingWs(string, segmenter) {
23791
+ if (segmenter) return leadingAndTrailingWs(string, segmenter)[1];
23792
+ let i;
23793
+ for (i = string.length - 1; i >= 0; i--) if (!string[i].match(/\s/)) break;
23794
+ return string.substring(i + 1);
23795
+ }
23796
+ function leadingWs(string, segmenter) {
23797
+ if (segmenter) return leadingAndTrailingWs(string, segmenter)[0];
23798
+ const match = string.match(/^\s*/);
23799
+ return match ? match[0] : "";
23800
+ }
23801
+ function leadingAndTrailingWs(string, segmenter) {
23802
+ if (!segmenter) return [leadingWs(string), trailingWs(string)];
23803
+ if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
23804
+ const segments = segment(string, segmenter);
23805
+ const firstSeg = segments[0];
23806
+ const lastSeg = segments[segments.length - 1];
23807
+ return [/\s/.test(firstSeg) ? firstSeg : "", /\s/.test(lastSeg) ? lastSeg : ""];
23808
+ }
23809
+
23810
+ //#endregion
23811
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/word.js
23812
+ const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
23813
+ const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
23814
+ var WordDiff = class extends Diff {
23815
+ equals(left, right, options) {
23816
+ if (options.ignoreCase) {
23817
+ left = left.toLowerCase();
23818
+ right = right.toLowerCase();
23819
+ }
23820
+ return left.trim() === right.trim();
23821
+ }
23822
+ tokenize(value, options = {}) {
23823
+ let parts;
23824
+ if (options.intlSegmenter) {
23825
+ const segmenter = options.intlSegmenter;
23826
+ if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
23827
+ parts = segment(value, segmenter);
23828
+ } else parts = value.match(tokenizeIncludingWhitespace) || [];
23829
+ const tokens = [];
23830
+ let prevPart = null;
23831
+ parts.forEach((part) => {
23832
+ if (/\s/.test(part)) if (prevPart == null) tokens.push(part);
23833
+ else tokens.push(tokens.pop() + part);
23834
+ else if (prevPart != null && /\s/.test(prevPart)) if (tokens[tokens.length - 1] == prevPart) tokens.push(tokens.pop() + part);
23835
+ else tokens.push(prevPart + part);
23836
+ else tokens.push(part);
23837
+ prevPart = part;
23838
+ });
23839
+ return tokens;
23840
+ }
23841
+ join(tokens) {
23842
+ return tokens.map((token, i) => {
23843
+ if (i == 0) return token;
23844
+ else return token.replace(/^\s+/, "");
23845
+ }).join("");
23846
+ }
23847
+ postProcess(changes, options) {
23848
+ if (!changes || options.oneChangePerToken) return changes;
23849
+ let lastKeep = null;
23850
+ let insertion = null;
23851
+ let deletion = null;
23852
+ changes.forEach((change) => {
23853
+ if (change.added) insertion = change;
23854
+ else if (change.removed) deletion = change;
23855
+ else {
23856
+ if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change, options.intlSegmenter);
23857
+ lastKeep = change;
23858
+ insertion = null;
23859
+ deletion = null;
23860
+ }
23861
+ });
23862
+ if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null, options.intlSegmenter);
23863
+ return changes;
23864
+ }
23865
+ };
23866
+ const wordDiff = new WordDiff();
23867
+ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep, segmenter) {
23868
+ if (deletion && insertion) {
23869
+ const [oldWsPrefix, oldWsSuffix] = leadingAndTrailingWs(deletion.value, segmenter);
23870
+ const [newWsPrefix, newWsSuffix] = leadingAndTrailingWs(insertion.value, segmenter);
23871
+ if (startKeep) {
23872
+ const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
23873
+ startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
23874
+ deletion.value = removePrefix(deletion.value, commonWsPrefix);
23875
+ insertion.value = removePrefix(insertion.value, commonWsPrefix);
23876
+ }
23877
+ if (endKeep) {
23878
+ const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
23879
+ endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
23880
+ deletion.value = removeSuffix(deletion.value, commonWsSuffix);
23881
+ insertion.value = removeSuffix(insertion.value, commonWsSuffix);
23882
+ }
23883
+ } else if (insertion) {
23884
+ if (startKeep) {
23885
+ const ws = leadingWs(insertion.value, segmenter);
23886
+ insertion.value = insertion.value.substring(ws.length);
23887
+ }
23888
+ if (endKeep) {
23889
+ const ws = leadingWs(endKeep.value, segmenter);
23890
+ endKeep.value = endKeep.value.substring(ws.length);
23891
+ }
23892
+ } else if (startKeep && endKeep) {
23893
+ const newWsFull = leadingWs(endKeep.value, segmenter), [delWsStart, delWsEnd] = leadingAndTrailingWs(deletion.value, segmenter);
23894
+ const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
23895
+ deletion.value = removePrefix(deletion.value, newWsStart);
23896
+ const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
23897
+ deletion.value = removeSuffix(deletion.value, newWsEnd);
23898
+ endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
23899
+ startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
23900
+ } else if (endKeep) {
23901
+ const endKeepWsPrefix = leadingWs(endKeep.value, segmenter);
23902
+ const overlap = maximumOverlap(trailingWs(deletion.value, segmenter), endKeepWsPrefix);
23903
+ deletion.value = removeSuffix(deletion.value, overlap);
23904
+ } else if (startKeep) {
23905
+ const overlap = maximumOverlap(trailingWs(startKeep.value, segmenter), leadingWs(deletion.value, segmenter));
23906
+ deletion.value = removePrefix(deletion.value, overlap);
23907
+ }
23908
+ }
23909
+ var WordsWithSpaceDiff = class extends Diff {
23910
+ tokenize(value) {
23911
+ const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
23912
+ return value.match(regex) || [];
23913
+ }
23914
+ };
23915
+ const wordsWithSpaceDiff = new WordsWithSpaceDiff();
23916
+
23917
+ //#endregion
23918
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/line.js
23919
+ var LineDiff = class extends Diff {
23920
+ constructor() {
23921
+ super(...arguments);
23922
+ this.tokenize = tokenize;
23923
+ }
23924
+ equals(left, right, options) {
23925
+ if (options.ignoreWhitespace) {
23926
+ if (!options.newlineIsToken || !left.includes("\n")) left = left.trim();
23927
+ if (!options.newlineIsToken || !right.includes("\n")) right = right.trim();
23928
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
23929
+ if (left.endsWith("\n")) left = left.slice(0, -1);
23930
+ if (right.endsWith("\n")) right = right.slice(0, -1);
23931
+ }
23932
+ return super.equals(left, right, options);
23933
+ }
23934
+ };
23935
+ const lineDiff = new LineDiff();
23936
+ function diffLines(oldStr, newStr, options) {
23937
+ return lineDiff.diff(oldStr, newStr, options);
23938
+ }
23939
+ function tokenize(value, options) {
23940
+ if (options.stripTrailingCr) value = value.replace(/\r\n/g, "\n");
23941
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
23942
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) linesAndNewlines.pop();
23943
+ for (let i = 0; i < linesAndNewlines.length; i++) {
23944
+ const line = linesAndNewlines[i];
23945
+ if (i % 2 && !options.newlineIsToken) retLines[retLines.length - 1] += line;
23946
+ else retLines.push(line);
23947
+ }
23948
+ return retLines;
23949
+ }
23950
+
23951
+ //#endregion
23952
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/sentence.js
23953
+ function isSentenceEndPunct(char) {
23954
+ return char == "." || char == "!" || char == "?";
23955
+ }
23956
+ var SentenceDiff = class extends Diff {
23957
+ tokenize(value) {
23958
+ var _a;
23959
+ const result = [];
23960
+ let tokenStartI = 0;
23961
+ for (let i = 0; i < value.length; i++) {
23962
+ if (i == value.length - 1) {
23963
+ result.push(value.slice(tokenStartI));
23964
+ break;
23965
+ }
23966
+ if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
23967
+ result.push(value.slice(tokenStartI, i + 1));
23968
+ i = tokenStartI = i + 1;
23969
+ while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\s/)) i++;
23970
+ result.push(value.slice(tokenStartI, i + 1));
23971
+ tokenStartI = i + 1;
23972
+ }
23973
+ }
23974
+ return result;
23975
+ }
23976
+ };
23977
+ const sentenceDiff = new SentenceDiff();
23978
+
23979
+ //#endregion
23980
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/css.js
23981
+ var CssDiff = class extends Diff {
23982
+ tokenize(value) {
23983
+ return value.split(/([{}:;,]|\s+)/);
23984
+ }
23985
+ };
23986
+ const cssDiff = new CssDiff();
23987
+
23988
+ //#endregion
23989
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/json.js
23990
+ var JsonDiff = class extends Diff {
23991
+ constructor() {
23992
+ super(...arguments);
23993
+ this.tokenize = tokenize;
23994
+ }
23995
+ get useLongestToken() {
23996
+ return true;
23997
+ }
23998
+ castInput(value, options) {
23999
+ const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
24000
+ return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
24001
+ }
24002
+ equals(left, right, options) {
24003
+ return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
24004
+ }
24005
+ };
24006
+ const jsonDiff = new JsonDiff();
24007
+ function canonicalize(obj, stack, replacementStack, replacer, key) {
24008
+ stack = stack || [];
24009
+ replacementStack = replacementStack || [];
24010
+ if (replacer) obj = replacer(key === void 0 ? "" : key, obj);
24011
+ let i;
24012
+ for (i = 0; i < stack.length; i += 1) if (stack[i] === obj) return replacementStack[i];
24013
+ let canonicalizedObj;
24014
+ if ("[object Array]" === Object.prototype.toString.call(obj)) {
24015
+ stack.push(obj);
24016
+ canonicalizedObj = new Array(obj.length);
24017
+ replacementStack.push(canonicalizedObj);
24018
+ for (i = 0; i < obj.length; i += 1) canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
24019
+ stack.pop();
24020
+ replacementStack.pop();
24021
+ return canonicalizedObj;
24022
+ }
24023
+ if (obj && obj.toJSON) obj = obj.toJSON();
24024
+ if (typeof obj === "object" && obj !== null) {
24025
+ stack.push(obj);
24026
+ canonicalizedObj = {};
24027
+ replacementStack.push(canonicalizedObj);
24028
+ const sortedKeys = [];
24029
+ let key;
24030
+ for (key in obj)
24031
+ /* istanbul ignore else */
24032
+ if (Object.prototype.hasOwnProperty.call(obj, key)) sortedKeys.push(key);
24033
+ sortedKeys.sort();
24034
+ for (i = 0; i < sortedKeys.length; i += 1) {
24035
+ key = sortedKeys[i];
24036
+ canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);
24037
+ }
24038
+ stack.pop();
24039
+ replacementStack.pop();
24040
+ } else canonicalizedObj = obj;
24041
+ return canonicalizedObj;
24042
+ }
24043
+
24044
+ //#endregion
24045
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/diff/array.js
24046
+ var ArrayDiff = class extends Diff {
24047
+ tokenize(value) {
24048
+ return value.slice();
24049
+ }
24050
+ join(value) {
24051
+ return value;
24052
+ }
24053
+ removeEmpty(value) {
24054
+ return value;
24055
+ }
24056
+ };
24057
+ const arrayDiff = new ArrayDiff();
24058
+
24059
+ //#endregion
24060
+ //#region node_modules/.pnpm/diff@8.0.4/node_modules/diff/libesm/patch/create.js
24061
+ const INCLUDE_HEADERS = {
24062
+ includeIndex: true,
24063
+ includeUnderline: true,
24064
+ includeFileHeaders: true
24065
+ };
24066
+ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
24067
+ let optionsObj;
24068
+ if (!options) optionsObj = {};
24069
+ else if (typeof options === "function") optionsObj = { callback: options };
24070
+ else optionsObj = options;
24071
+ if (typeof optionsObj.context === "undefined") optionsObj.context = 4;
24072
+ const context = optionsObj.context;
24073
+ if (optionsObj.newlineIsToken) throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
24074
+ if (!optionsObj.callback) return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
24075
+ else {
24076
+ const { callback } = optionsObj;
24077
+ diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
24078
+ callback(diffLinesResultToPatch(diff));
24079
+ } }));
24080
+ }
24081
+ function diffLinesResultToPatch(diff) {
24082
+ if (!diff) return;
24083
+ diff.push({
24084
+ value: "",
24085
+ lines: []
24086
+ });
24087
+ function contextLines(lines) {
24088
+ return lines.map(function(entry) {
24089
+ return " " + entry;
24090
+ });
24091
+ }
24092
+ const hunks = [];
24093
+ let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
24094
+ for (let i = 0; i < diff.length; i++) {
24095
+ const current = diff[i], lines = current.lines || splitLines(current.value);
24096
+ current.lines = lines;
24097
+ if (current.added || current.removed) {
24098
+ if (!oldRangeStart) {
24099
+ const prev = diff[i - 1];
24100
+ oldRangeStart = oldLine;
24101
+ newRangeStart = newLine;
24102
+ if (prev) {
24103
+ curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
24104
+ oldRangeStart -= curRange.length;
24105
+ newRangeStart -= curRange.length;
24106
+ }
24107
+ }
24108
+ for (const line of lines) curRange.push((current.added ? "+" : "-") + line);
24109
+ if (current.added) newLine += lines.length;
24110
+ else oldLine += lines.length;
24111
+ } else {
24112
+ if (oldRangeStart) if (lines.length <= context * 2 && i < diff.length - 2) for (const line of contextLines(lines)) curRange.push(line);
24113
+ else {
24114
+ const contextSize = Math.min(lines.length, context);
24115
+ for (const line of contextLines(lines.slice(0, contextSize))) curRange.push(line);
24116
+ const hunk = {
24117
+ oldStart: oldRangeStart,
24118
+ oldLines: oldLine - oldRangeStart + contextSize,
24119
+ newStart: newRangeStart,
24120
+ newLines: newLine - newRangeStart + contextSize,
24121
+ lines: curRange
24122
+ };
24123
+ hunks.push(hunk);
24124
+ oldRangeStart = 0;
24125
+ newRangeStart = 0;
24126
+ curRange = [];
24127
+ }
24128
+ oldLine += lines.length;
24129
+ newLine += lines.length;
24130
+ }
24131
+ }
24132
+ for (const hunk of hunks) for (let i = 0; i < hunk.lines.length; i++) if (hunk.lines[i].endsWith("\n")) hunk.lines[i] = hunk.lines[i].slice(0, -1);
24133
+ else {
24134
+ hunk.lines.splice(i + 1, 0, "\");
24135
+ i++;
24136
+ }
24137
+ return {
24138
+ oldFileName,
24139
+ newFileName,
24140
+ oldHeader,
24141
+ newHeader,
24142
+ hunks
24143
+ };
24144
+ }
24145
+ }
24146
+ /**
24147
+ * creates a unified diff patch.
24148
+ * @param patch either a single structured patch object (as returned by `structuredPatch`) or an array of them (as returned by `parsePatch`)
24149
+ */
24150
+ function formatPatch(patch, headerOptions) {
24151
+ if (!headerOptions) headerOptions = INCLUDE_HEADERS;
24152
+ if (Array.isArray(patch)) {
24153
+ if (patch.length > 1 && !headerOptions.includeFileHeaders) throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");
24154
+ return patch.map((p) => formatPatch(p, headerOptions)).join("\n");
24155
+ }
24156
+ const ret = [];
24157
+ if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName) ret.push("Index: " + patch.oldFileName);
24158
+ if (headerOptions.includeUnderline) ret.push("===================================================================");
24159
+ if (headerOptions.includeFileHeaders) {
24160
+ ret.push("--- " + patch.oldFileName + (typeof patch.oldHeader === "undefined" ? "" : " " + patch.oldHeader));
24161
+ ret.push("+++ " + patch.newFileName + (typeof patch.newHeader === "undefined" ? "" : " " + patch.newHeader));
24162
+ }
24163
+ for (let i = 0; i < patch.hunks.length; i++) {
24164
+ const hunk = patch.hunks[i];
24165
+ if (hunk.oldLines === 0) hunk.oldStart -= 1;
24166
+ if (hunk.newLines === 0) hunk.newStart -= 1;
24167
+ ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
24168
+ for (const line of hunk.lines) ret.push(line);
24169
+ }
24170
+ return ret.join("\n") + "\n";
24171
+ }
24172
+ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
24173
+ if (typeof options === "function") options = { callback: options };
24174
+ if (!(options === null || options === void 0 ? void 0 : options.callback)) {
24175
+ const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
24176
+ if (!patchObj) return;
24177
+ return formatPatch(patchObj, options === null || options === void 0 ? void 0 : options.headerOptions);
24178
+ } else {
24179
+ const { callback } = options;
24180
+ structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
24181
+ if (!patchObj) callback(void 0);
24182
+ else callback(formatPatch(patchObj, options.headerOptions));
24183
+ } }));
24184
+ }
24185
+ }
24186
+ function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
24187
+ return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
24188
+ }
24189
+ /**
24190
+ * Split `text` into an array of lines, including the trailing newline character (where present)
24191
+ */
24192
+ function splitLines(text) {
24193
+ const hasTrailingNl = text.endsWith("\n");
24194
+ const result = text.split("\n").map((line) => line + "\n");
24195
+ if (hasTrailingNl) result.pop();
24196
+ else result.push(result.pop().slice(0, -1));
24197
+ return result;
24198
+ }
24199
+
24200
+ //#endregion
24201
+ //#region ../../packages/local-file-shell/src/file/expandTilde.ts
24202
+ /**
24203
+ * Expand a leading `~` (or `~/...`, `~\...`) to the user's home directory.
24204
+ * Pass-through for any other input — the shell normally handles `~` expansion,
24205
+ * but Node fs APIs do not, so paths supplied by the LLM (or pasted by users)
24206
+ * would otherwise fail with ENOENT.
24207
+ */
24208
+ const expandTilde = (input) => {
24209
+ if (!input) return input;
24210
+ if (input === "~") return os.homedir();
24211
+ if (input.startsWith("~/") || input.startsWith("~\\")) return path.join(os.homedir(), input.slice(2));
24212
+ return input;
24213
+ };
24214
+
24215
+ //#endregion
24216
+ //#region ../../packages/local-file-shell/src/file/edit.ts
24217
+ async function editLocalFile({ file_path: rawPath, old_string, new_string, replace_all = false }) {
24218
+ const filePath = expandTilde(rawPath) ?? rawPath;
24219
+ try {
24220
+ const content = await readFile(filePath, "utf8");
24221
+ if (!content.includes(old_string)) return {
24222
+ error: "The specified old_string was not found in the file",
24223
+ replacements: 0,
24224
+ success: false
24225
+ };
24226
+ let newContent;
24227
+ let replacements;
24228
+ if (replace_all) {
24229
+ const regex = new RegExp(old_string.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&"), "g");
24230
+ const matches = content.match(regex);
24231
+ replacements = matches ? matches.length : 0;
24232
+ newContent = content.replaceAll(old_string, new_string);
24233
+ } else {
24234
+ const index = content.indexOf(old_string);
24235
+ if (index === -1) return {
24236
+ error: "Old string not found",
24237
+ replacements: 0,
24238
+ success: false
24239
+ };
24240
+ newContent = content.slice(0, index) + new_string + content.slice(index + old_string.length);
24241
+ replacements = 1;
24242
+ }
24243
+ await writeFile(filePath, newContent, "utf8");
24244
+ const patch = createPatch(filePath, content, newContent, "", "");
24245
+ const diffText = `diff --git a${filePath} b${filePath}\n${patch}`;
24246
+ const patchLines = patch.split("\n");
24247
+ let linesAdded = 0;
24248
+ let linesDeleted = 0;
24249
+ for (const line of patchLines) if (line.startsWith("+") && !line.startsWith("+++")) linesAdded++;
24250
+ else if (line.startsWith("-") && !line.startsWith("---")) linesDeleted++;
24251
+ return {
24252
+ diffText,
24253
+ linesAdded,
24254
+ linesDeleted,
24255
+ replacements,
24256
+ success: true
24257
+ };
24258
+ } catch (error) {
24259
+ return {
24260
+ error: error.message,
24261
+ replacements: 0,
24262
+ success: false
24263
+ };
24264
+ }
24265
+ }
24266
+
23542
24267
  //#endregion
23543
24268
  //#region ../../packages/local-file-shell/src/file/hasHiddenSegment.ts
23544
24269
  /**
@@ -23556,29 +24281,49 @@ const hasHiddenSegment = (pattern) => !!pattern && HIDDEN_SEGMENT_RE.test(patter
23556
24281
  //#endregion
23557
24282
  //#region ../../packages/local-file-shell/src/file/glob.ts
23558
24283
  var import_out = /* @__PURE__ */ __toESM$2(require_out());
23559
- async function globLocalFiles({ pattern, cwd }) {
24284
+ /**
24285
+ * Lightweight glob — backed by `fast-glob` only. For the platform-aware
24286
+ * version that prefers `fd` / `find` / `mdfind` when present, use
24287
+ * `createFileSearchModule()` from `@lobechat/local-file-shell/fileSearch`.
24288
+ */
24289
+ async function globLocalFiles({ pattern, cwd, scope }) {
23560
24290
  try {
23561
24291
  const wantsHidden = hasHiddenSegment(pattern);
23562
24292
  const files = await (0, import_out.default)(pattern, {
23563
- cwd: expandTilde(cwd) || process.cwd(),
24293
+ cwd: expandTilde(scope ?? cwd) || process.cwd(),
23564
24294
  dot: wantsHidden,
23565
24295
  ignore: ["**/node_modules/**", "**/.git/**"]
23566
24296
  });
23567
- if (wantsHidden) return {
24297
+ const base = {
24298
+ engine: "fast-glob",
23568
24299
  files,
24300
+ success: true,
24301
+ total_files: files.length
24302
+ };
24303
+ if (wantsHidden) return {
24304
+ ...base,
23569
24305
  hint: `Auto-enabled hidden-file matching because pattern contains a dot-prefixed segment.`
23570
24306
  };
23571
- return { files };
24307
+ return base;
23572
24308
  } catch (error) {
23573
24309
  return {
24310
+ engine: "fast-glob",
23574
24311
  error: error.message,
23575
- files: []
24312
+ files: [],
24313
+ success: false,
24314
+ total_files: 0
23576
24315
  };
23577
24316
  }
23578
24317
  }
23579
24318
 
23580
24319
  //#endregion
23581
24320
  //#region ../../packages/local-file-shell/src/file/grep.ts
24321
+ /**
24322
+ * Lightweight grep — spawns `rg` directly and returns the raw `--json`
24323
+ * events. For the platform-aware fallback chain (rg → ag → grep → nodejs)
24324
+ * with rich `output_mode` / `-A/-B/-C` support, use
24325
+ * `createContentSearchImpl()` from `@lobechat/local-file-shell/contentSearch`.
24326
+ */
23582
24327
  async function grepContent({ pattern, cwd, filePattern }) {
23583
24328
  const wantsHidden = hasHiddenSegment(filePattern);
23584
24329
  const hint = wantsHidden ? `Auto-enabled hidden-file matching because filePattern contains a dot-prefixed segment.` : void 0;
@@ -23596,37 +24341,46 @@ async function grepContent({ pattern, cwd, filePattern }) {
23596
24341
  child.on("close", (code) => {
23597
24342
  if (code !== 0 && code !== 1) {
23598
24343
  resolve({
24344
+ engine: "rg",
23599
24345
  hint,
23600
24346
  matches: [],
23601
- success: false
24347
+ success: false,
24348
+ total_matches: 0
23602
24349
  });
23603
24350
  return;
23604
24351
  }
23605
24352
  try {
24353
+ const matches = stdout.split("\n").filter(Boolean).map((line) => {
24354
+ try {
24355
+ return JSON.parse(line);
24356
+ } catch {
24357
+ return null;
24358
+ }
24359
+ }).filter(Boolean);
23606
24360
  resolve({
24361
+ engine: "rg",
23607
24362
  hint,
23608
- matches: stdout.split("\n").filter(Boolean).map((line) => {
23609
- try {
23610
- return JSON.parse(line);
23611
- } catch {
23612
- return null;
23613
- }
23614
- }).filter(Boolean),
23615
- success: true
24363
+ matches,
24364
+ success: true,
24365
+ total_matches: matches.length
23616
24366
  });
23617
24367
  } catch {
23618
24368
  resolve({
24369
+ engine: "rg",
23619
24370
  hint,
23620
24371
  matches: [],
23621
- success: true
24372
+ success: true,
24373
+ total_matches: 0
23622
24374
  });
23623
24375
  }
23624
24376
  });
23625
24377
  child.on("error", () => {
23626
24378
  resolve({
24379
+ engine: "rg",
23627
24380
  hint,
23628
24381
  matches: [],
23629
- success: false
24382
+ success: false,
24383
+ total_matches: 0
23630
24384
  });
23631
24385
  });
23632
24386
  });
@@ -23651,744 +24405,6 @@ const SYSTEM_FILES_TO_IGNORE = [
23651
24405
  ".Trashes"
23652
24406
  ];
23653
24407
 
23654
- //#endregion
23655
- //#region node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
23656
- var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23657
- /**
23658
- * Helpers.
23659
- */
23660
- var s = 1e3;
23661
- var m = s * 60;
23662
- var h = m * 60;
23663
- var d = h * 24;
23664
- var w = d * 7;
23665
- var y = d * 365.25;
23666
- /**
23667
- * Parse or format the given `val`.
23668
- *
23669
- * Options:
23670
- *
23671
- * - `long` verbose formatting [false]
23672
- *
23673
- * @param {String|Number} val
23674
- * @param {Object} [options]
23675
- * @throws {Error} throw an error if val is not a non-empty string or a number
23676
- * @return {String|Number}
23677
- * @api public
23678
- */
23679
- module.exports = function(val, options) {
23680
- options = options || {};
23681
- var type = typeof val;
23682
- if (type === "string" && val.length > 0) return parse(val);
23683
- else if (type === "number" && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
23684
- throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
23685
- };
23686
- /**
23687
- * Parse the given `str` and return milliseconds.
23688
- *
23689
- * @param {String} str
23690
- * @return {Number}
23691
- * @api private
23692
- */
23693
- function parse(str) {
23694
- str = String(str);
23695
- if (str.length > 100) return;
23696
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
23697
- if (!match) return;
23698
- var n = parseFloat(match[1]);
23699
- switch ((match[2] || "ms").toLowerCase()) {
23700
- case "years":
23701
- case "year":
23702
- case "yrs":
23703
- case "yr":
23704
- case "y": return n * y;
23705
- case "weeks":
23706
- case "week":
23707
- case "w": return n * w;
23708
- case "days":
23709
- case "day":
23710
- case "d": return n * d;
23711
- case "hours":
23712
- case "hour":
23713
- case "hrs":
23714
- case "hr":
23715
- case "h": return n * h;
23716
- case "minutes":
23717
- case "minute":
23718
- case "mins":
23719
- case "min":
23720
- case "m": return n * m;
23721
- case "seconds":
23722
- case "second":
23723
- case "secs":
23724
- case "sec":
23725
- case "s": return n * s;
23726
- case "milliseconds":
23727
- case "millisecond":
23728
- case "msecs":
23729
- case "msec":
23730
- case "ms": return n;
23731
- default: return;
23732
- }
23733
- }
23734
- /**
23735
- * Short format for `ms`.
23736
- *
23737
- * @param {Number} ms
23738
- * @return {String}
23739
- * @api private
23740
- */
23741
- function fmtShort(ms) {
23742
- var msAbs = Math.abs(ms);
23743
- if (msAbs >= d) return Math.round(ms / d) + "d";
23744
- if (msAbs >= h) return Math.round(ms / h) + "h";
23745
- if (msAbs >= m) return Math.round(ms / m) + "m";
23746
- if (msAbs >= s) return Math.round(ms / s) + "s";
23747
- return ms + "ms";
23748
- }
23749
- /**
23750
- * Long format for `ms`.
23751
- *
23752
- * @param {Number} ms
23753
- * @return {String}
23754
- * @api private
23755
- */
23756
- function fmtLong(ms) {
23757
- var msAbs = Math.abs(ms);
23758
- if (msAbs >= d) return plural(ms, msAbs, d, "day");
23759
- if (msAbs >= h) return plural(ms, msAbs, h, "hour");
23760
- if (msAbs >= m) return plural(ms, msAbs, m, "minute");
23761
- if (msAbs >= s) return plural(ms, msAbs, s, "second");
23762
- return ms + " ms";
23763
- }
23764
- /**
23765
- * Pluralization helper.
23766
- */
23767
- function plural(ms, msAbs, n, name) {
23768
- var isPlural = msAbs >= n * 1.5;
23769
- return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
23770
- }
23771
- }));
23772
-
23773
- //#endregion
23774
- //#region node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
23775
- var require_common$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23776
- /**
23777
- * This is the common logic for both the Node.js and web browser
23778
- * implementations of `debug()`.
23779
- */
23780
- function setup(env) {
23781
- createDebug.debug = createDebug;
23782
- createDebug.default = createDebug;
23783
- createDebug.coerce = coerce;
23784
- createDebug.disable = disable;
23785
- createDebug.enable = enable;
23786
- createDebug.enabled = enabled;
23787
- createDebug.humanize = require_ms();
23788
- createDebug.destroy = destroy;
23789
- Object.keys(env).forEach((key) => {
23790
- createDebug[key] = env[key];
23791
- });
23792
- /**
23793
- * The currently active debug mode names, and names to skip.
23794
- */
23795
- createDebug.names = [];
23796
- createDebug.skips = [];
23797
- /**
23798
- * Map of special "%n" handling functions, for the debug "format" argument.
23799
- *
23800
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
23801
- */
23802
- createDebug.formatters = {};
23803
- /**
23804
- * Selects a color for a debug namespace
23805
- * @param {String} namespace The namespace string for the debug instance to be colored
23806
- * @return {Number|String} An ANSI color code for the given namespace
23807
- * @api private
23808
- */
23809
- function selectColor(namespace) {
23810
- let hash = 0;
23811
- for (let i = 0; i < namespace.length; i++) {
23812
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
23813
- hash |= 0;
23814
- }
23815
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
23816
- }
23817
- createDebug.selectColor = selectColor;
23818
- /**
23819
- * Create a debugger with the given `namespace`.
23820
- *
23821
- * @param {String} namespace
23822
- * @return {Function}
23823
- * @api public
23824
- */
23825
- function createDebug(namespace) {
23826
- let prevTime;
23827
- let enableOverride = null;
23828
- let namespacesCache;
23829
- let enabledCache;
23830
- function debug(...args) {
23831
- if (!debug.enabled) return;
23832
- const self = debug;
23833
- const curr = Number(/* @__PURE__ */ new Date());
23834
- self.diff = curr - (prevTime || curr);
23835
- self.prev = prevTime;
23836
- self.curr = curr;
23837
- prevTime = curr;
23838
- args[0] = createDebug.coerce(args[0]);
23839
- if (typeof args[0] !== "string") args.unshift("%O");
23840
- let index = 0;
23841
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
23842
- if (match === "%%") return "%";
23843
- index++;
23844
- const formatter = createDebug.formatters[format];
23845
- if (typeof formatter === "function") {
23846
- const val = args[index];
23847
- match = formatter.call(self, val);
23848
- args.splice(index, 1);
23849
- index--;
23850
- }
23851
- return match;
23852
- });
23853
- createDebug.formatArgs.call(self, args);
23854
- (self.log || createDebug.log).apply(self, args);
23855
- }
23856
- debug.namespace = namespace;
23857
- debug.useColors = createDebug.useColors();
23858
- debug.color = createDebug.selectColor(namespace);
23859
- debug.extend = extend;
23860
- debug.destroy = createDebug.destroy;
23861
- Object.defineProperty(debug, "enabled", {
23862
- enumerable: true,
23863
- configurable: false,
23864
- get: () => {
23865
- if (enableOverride !== null) return enableOverride;
23866
- if (namespacesCache !== createDebug.namespaces) {
23867
- namespacesCache = createDebug.namespaces;
23868
- enabledCache = createDebug.enabled(namespace);
23869
- }
23870
- return enabledCache;
23871
- },
23872
- set: (v) => {
23873
- enableOverride = v;
23874
- }
23875
- });
23876
- if (typeof createDebug.init === "function") createDebug.init(debug);
23877
- return debug;
23878
- }
23879
- function extend(namespace, delimiter) {
23880
- const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
23881
- newDebug.log = this.log;
23882
- return newDebug;
23883
- }
23884
- /**
23885
- * Enables a debug mode by namespaces. This can include modes
23886
- * separated by a colon and wildcards.
23887
- *
23888
- * @param {String} namespaces
23889
- * @api public
23890
- */
23891
- function enable(namespaces) {
23892
- createDebug.save(namespaces);
23893
- createDebug.namespaces = namespaces;
23894
- createDebug.names = [];
23895
- createDebug.skips = [];
23896
- const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
23897
- for (const ns of split) if (ns[0] === "-") createDebug.skips.push(ns.slice(1));
23898
- else createDebug.names.push(ns);
23899
- }
23900
- /**
23901
- * Checks if the given string matches a namespace template, honoring
23902
- * asterisks as wildcards.
23903
- *
23904
- * @param {String} search
23905
- * @param {String} template
23906
- * @return {Boolean}
23907
- */
23908
- function matchesTemplate(search, template) {
23909
- let searchIndex = 0;
23910
- let templateIndex = 0;
23911
- let starIndex = -1;
23912
- let matchIndex = 0;
23913
- while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
23914
- starIndex = templateIndex;
23915
- matchIndex = searchIndex;
23916
- templateIndex++;
23917
- } else {
23918
- searchIndex++;
23919
- templateIndex++;
23920
- }
23921
- else if (starIndex !== -1) {
23922
- templateIndex = starIndex + 1;
23923
- matchIndex++;
23924
- searchIndex = matchIndex;
23925
- } else return false;
23926
- while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
23927
- return templateIndex === template.length;
23928
- }
23929
- /**
23930
- * Disable debug output.
23931
- *
23932
- * @return {String} namespaces
23933
- * @api public
23934
- */
23935
- function disable() {
23936
- const namespaces = [...createDebug.names, ...createDebug.skips.map((namespace) => "-" + namespace)].join(",");
23937
- createDebug.enable("");
23938
- return namespaces;
23939
- }
23940
- /**
23941
- * Returns true if the given mode name is enabled, false otherwise.
23942
- *
23943
- * @param {String} name
23944
- * @return {Boolean}
23945
- * @api public
23946
- */
23947
- function enabled(name) {
23948
- for (const skip of createDebug.skips) if (matchesTemplate(name, skip)) return false;
23949
- for (const ns of createDebug.names) if (matchesTemplate(name, ns)) return true;
23950
- return false;
23951
- }
23952
- /**
23953
- * Coerce `val`.
23954
- *
23955
- * @param {Mixed} val
23956
- * @return {Mixed}
23957
- * @api private
23958
- */
23959
- function coerce(val) {
23960
- if (val instanceof Error) return val.stack || val.message;
23961
- return val;
23962
- }
23963
- /**
23964
- * XXX DO NOT USE. This is a temporary stub function.
23965
- * XXX It WILL be removed in the next major release.
23966
- */
23967
- function destroy() {
23968
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
23969
- }
23970
- createDebug.enable(createDebug.load());
23971
- return createDebug;
23972
- }
23973
- module.exports = setup;
23974
- }));
23975
-
23976
- //#endregion
23977
- //#region node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
23978
- var require_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
23979
- /**
23980
- * This is the web browser implementation of `debug()`.
23981
- */
23982
- exports.formatArgs = formatArgs;
23983
- exports.save = save;
23984
- exports.load = load;
23985
- exports.useColors = useColors;
23986
- exports.storage = localstorage();
23987
- exports.destroy = (() => {
23988
- let warned = false;
23989
- return () => {
23990
- if (!warned) {
23991
- warned = true;
23992
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
23993
- }
23994
- };
23995
- })();
23996
- /**
23997
- * Colors.
23998
- */
23999
- exports.colors = [
24000
- "#0000CC",
24001
- "#0000FF",
24002
- "#0033CC",
24003
- "#0033FF",
24004
- "#0066CC",
24005
- "#0066FF",
24006
- "#0099CC",
24007
- "#0099FF",
24008
- "#00CC00",
24009
- "#00CC33",
24010
- "#00CC66",
24011
- "#00CC99",
24012
- "#00CCCC",
24013
- "#00CCFF",
24014
- "#3300CC",
24015
- "#3300FF",
24016
- "#3333CC",
24017
- "#3333FF",
24018
- "#3366CC",
24019
- "#3366FF",
24020
- "#3399CC",
24021
- "#3399FF",
24022
- "#33CC00",
24023
- "#33CC33",
24024
- "#33CC66",
24025
- "#33CC99",
24026
- "#33CCCC",
24027
- "#33CCFF",
24028
- "#6600CC",
24029
- "#6600FF",
24030
- "#6633CC",
24031
- "#6633FF",
24032
- "#66CC00",
24033
- "#66CC33",
24034
- "#9900CC",
24035
- "#9900FF",
24036
- "#9933CC",
24037
- "#9933FF",
24038
- "#99CC00",
24039
- "#99CC33",
24040
- "#CC0000",
24041
- "#CC0033",
24042
- "#CC0066",
24043
- "#CC0099",
24044
- "#CC00CC",
24045
- "#CC00FF",
24046
- "#CC3300",
24047
- "#CC3333",
24048
- "#CC3366",
24049
- "#CC3399",
24050
- "#CC33CC",
24051
- "#CC33FF",
24052
- "#CC6600",
24053
- "#CC6633",
24054
- "#CC9900",
24055
- "#CC9933",
24056
- "#CCCC00",
24057
- "#CCCC33",
24058
- "#FF0000",
24059
- "#FF0033",
24060
- "#FF0066",
24061
- "#FF0099",
24062
- "#FF00CC",
24063
- "#FF00FF",
24064
- "#FF3300",
24065
- "#FF3333",
24066
- "#FF3366",
24067
- "#FF3399",
24068
- "#FF33CC",
24069
- "#FF33FF",
24070
- "#FF6600",
24071
- "#FF6633",
24072
- "#FF9900",
24073
- "#FF9933",
24074
- "#FFCC00",
24075
- "#FFCC33"
24076
- ];
24077
- /**
24078
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
24079
- * and the Firebug extension (any Firefox version) are known
24080
- * to support "%c" CSS customizations.
24081
- *
24082
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
24083
- */
24084
- function useColors() {
24085
- if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return true;
24086
- if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return false;
24087
- let m;
24088
- return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
24089
- }
24090
- /**
24091
- * Colorize log arguments if enabled.
24092
- *
24093
- * @api public
24094
- */
24095
- function formatArgs(args) {
24096
- args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
24097
- if (!this.useColors) return;
24098
- const c = "color: " + this.color;
24099
- args.splice(1, 0, c, "color: inherit");
24100
- let index = 0;
24101
- let lastC = 0;
24102
- args[0].replace(/%[a-zA-Z%]/g, (match) => {
24103
- if (match === "%%") return;
24104
- index++;
24105
- if (match === "%c") lastC = index;
24106
- });
24107
- args.splice(lastC, 0, c);
24108
- }
24109
- /**
24110
- * Invokes `console.debug()` when available.
24111
- * No-op when `console.debug` is not a "function".
24112
- * If `console.debug` is not available, falls back
24113
- * to `console.log`.
24114
- *
24115
- * @api public
24116
- */
24117
- exports.log = console.debug || console.log || (() => {});
24118
- /**
24119
- * Save `namespaces`.
24120
- *
24121
- * @param {String} namespaces
24122
- * @api private
24123
- */
24124
- function save(namespaces) {
24125
- try {
24126
- if (namespaces) exports.storage.setItem("debug", namespaces);
24127
- else exports.storage.removeItem("debug");
24128
- } catch (error) {}
24129
- }
24130
- /**
24131
- * Load `namespaces`.
24132
- *
24133
- * @return {String} returns the previously persisted debug modes
24134
- * @api private
24135
- */
24136
- function load() {
24137
- let r;
24138
- try {
24139
- r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
24140
- } catch (error) {}
24141
- if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
24142
- return r;
24143
- }
24144
- /**
24145
- * Localstorage attempts to return the localstorage.
24146
- *
24147
- * This is necessary because safari throws
24148
- * when a user disables cookies/localstorage
24149
- * and you attempt to access it.
24150
- *
24151
- * @return {LocalStorage}
24152
- * @api private
24153
- */
24154
- function localstorage() {
24155
- try {
24156
- return localStorage;
24157
- } catch (error) {}
24158
- }
24159
- module.exports = require_common$1()(exports);
24160
- const { formatters } = module.exports;
24161
- /**
24162
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
24163
- */
24164
- formatters.j = function(v) {
24165
- try {
24166
- return JSON.stringify(v);
24167
- } catch (error) {
24168
- return "[UnexpectedJSONParseError]: " + error.message;
24169
- }
24170
- };
24171
- }));
24172
-
24173
- //#endregion
24174
- //#region node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
24175
- var require_node$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
24176
- /**
24177
- * Module dependencies.
24178
- */
24179
- const tty = __require("tty");
24180
- const util$6 = __require("util");
24181
- /**
24182
- * This is the Node.js implementation of `debug()`.
24183
- */
24184
- exports.init = init;
24185
- exports.log = log;
24186
- exports.formatArgs = formatArgs;
24187
- exports.save = save;
24188
- exports.load = load;
24189
- exports.useColors = useColors;
24190
- exports.destroy = util$6.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
24191
- /**
24192
- * Colors.
24193
- */
24194
- exports.colors = [
24195
- 6,
24196
- 2,
24197
- 3,
24198
- 4,
24199
- 5,
24200
- 1
24201
- ];
24202
- try {
24203
- const supportsColor = __require("supports-color");
24204
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) exports.colors = [
24205
- 20,
24206
- 21,
24207
- 26,
24208
- 27,
24209
- 32,
24210
- 33,
24211
- 38,
24212
- 39,
24213
- 40,
24214
- 41,
24215
- 42,
24216
- 43,
24217
- 44,
24218
- 45,
24219
- 56,
24220
- 57,
24221
- 62,
24222
- 63,
24223
- 68,
24224
- 69,
24225
- 74,
24226
- 75,
24227
- 76,
24228
- 77,
24229
- 78,
24230
- 79,
24231
- 80,
24232
- 81,
24233
- 92,
24234
- 93,
24235
- 98,
24236
- 99,
24237
- 112,
24238
- 113,
24239
- 128,
24240
- 129,
24241
- 134,
24242
- 135,
24243
- 148,
24244
- 149,
24245
- 160,
24246
- 161,
24247
- 162,
24248
- 163,
24249
- 164,
24250
- 165,
24251
- 166,
24252
- 167,
24253
- 168,
24254
- 169,
24255
- 170,
24256
- 171,
24257
- 172,
24258
- 173,
24259
- 178,
24260
- 179,
24261
- 184,
24262
- 185,
24263
- 196,
24264
- 197,
24265
- 198,
24266
- 199,
24267
- 200,
24268
- 201,
24269
- 202,
24270
- 203,
24271
- 204,
24272
- 205,
24273
- 206,
24274
- 207,
24275
- 208,
24276
- 209,
24277
- 214,
24278
- 215,
24279
- 220,
24280
- 221
24281
- ];
24282
- } catch (error) {}
24283
- /**
24284
- * Build up the default `inspectOpts` object from the environment variables.
24285
- *
24286
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
24287
- */
24288
- exports.inspectOpts = Object.keys(process.env).filter((key) => {
24289
- return /^debug_/i.test(key);
24290
- }).reduce((obj, key) => {
24291
- const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
24292
- return k.toUpperCase();
24293
- });
24294
- let val = process.env[key];
24295
- if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
24296
- else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
24297
- else if (val === "null") val = null;
24298
- else val = Number(val);
24299
- obj[prop] = val;
24300
- return obj;
24301
- }, {});
24302
- /**
24303
- * Is stdout a TTY? Colored output is enabled when `true`.
24304
- */
24305
- function useColors() {
24306
- return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
24307
- }
24308
- /**
24309
- * Adds ANSI color escape codes if enabled.
24310
- *
24311
- * @api public
24312
- */
24313
- function formatArgs(args) {
24314
- const { namespace: name, useColors } = this;
24315
- if (useColors) {
24316
- const c = this.color;
24317
- const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
24318
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
24319
- args[0] = prefix + args[0].split("\n").join("\n" + prefix);
24320
- args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
24321
- } else args[0] = getDate() + name + " " + args[0];
24322
- }
24323
- function getDate() {
24324
- if (exports.inspectOpts.hideDate) return "";
24325
- return (/* @__PURE__ */ new Date()).toISOString() + " ";
24326
- }
24327
- /**
24328
- * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
24329
- */
24330
- function log(...args) {
24331
- return process.stderr.write(util$6.formatWithOptions(exports.inspectOpts, ...args) + "\n");
24332
- }
24333
- /**
24334
- * Save `namespaces`.
24335
- *
24336
- * @param {String} namespaces
24337
- * @api private
24338
- */
24339
- function save(namespaces) {
24340
- if (namespaces) process.env.DEBUG = namespaces;
24341
- else delete process.env.DEBUG;
24342
- }
24343
- /**
24344
- * Load `namespaces`.
24345
- *
24346
- * @return {String} returns the previously persisted debug modes
24347
- * @api private
24348
- */
24349
- function load() {
24350
- return process.env.DEBUG;
24351
- }
24352
- /**
24353
- * Init logic for `debug` instances.
24354
- *
24355
- * Create a new `inspectOpts` object in case `useColors` is set
24356
- * differently for a particular `debug` instance.
24357
- */
24358
- function init(debug) {
24359
- debug.inspectOpts = {};
24360
- const keys = Object.keys(exports.inspectOpts);
24361
- for (let i = 0; i < keys.length; i++) debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
24362
- }
24363
- module.exports = require_common$1()(exports);
24364
- const { formatters } = module.exports;
24365
- /**
24366
- * Map %o to `util.inspect()`, all on a single line.
24367
- */
24368
- formatters.o = function(v) {
24369
- this.inspectOpts.colors = this.useColors;
24370
- return util$6.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
24371
- };
24372
- /**
24373
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
24374
- */
24375
- formatters.O = function(v) {
24376
- this.inspectOpts.colors = this.useColors;
24377
- return util$6.inspect(v, this.inspectOpts);
24378
- };
24379
- }));
24380
-
24381
- //#endregion
24382
- //#region node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
24383
- var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
24384
- /**
24385
- * Detect Electron renderer / nwjs process, which is node, but we should
24386
- * treat as a browser.
24387
- */
24388
- if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) module.exports = require_browser();
24389
- else module.exports = require_node$1();
24390
- }));
24391
-
24392
24408
  //#endregion
24393
24409
  //#region ../../packages/file-loaders/src/utils/detectUtf16.ts
24394
24410
  const HEURISTIC_SAMPLE_BYTES = 512;
@@ -205219,24 +205235,29 @@ var require_concat_stream = /* @__PURE__ */ __commonJSMin(((exports, module) =>
205219
205235
  }));
205220
205236
 
205221
205237
  //#endregion
205222
- //#region node_modules/.pnpm/yauzl@3.3.1/node_modules/yauzl/fd-slicer.js
205238
+ //#region node_modules/.pnpm/yauzl@3.3.0/node_modules/yauzl/fd-slicer.js
205223
205239
  var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205224
205240
  var fs$3 = __require("fs");
205225
205241
  var util$1 = __require("util");
205226
205242
  var stream = __require("stream");
205227
205243
  var Readable = stream.Readable;
205244
+ var Writable = stream.Writable;
205228
205245
  var PassThrough = stream.PassThrough;
205229
205246
  var Pend = require_pend();
205230
205247
  var EventEmitter$2 = __require("events").EventEmitter;
205248
+ exports.createFromBuffer = createFromBuffer;
205249
+ exports.createFromFd = createFromFd;
205231
205250
  exports.BufferSlicer = BufferSlicer;
205232
205251
  exports.FdSlicer = FdSlicer;
205233
205252
  util$1.inherits(FdSlicer, EventEmitter$2);
205234
- function FdSlicer(fd) {
205253
+ function FdSlicer(fd, options) {
205254
+ options = options || {};
205235
205255
  EventEmitter$2.call(this);
205236
205256
  this.fd = fd;
205237
205257
  this.pend = new Pend();
205238
205258
  this.pend.max = 1;
205239
205259
  this.refCount = 0;
205260
+ this.autoClose = !!options.autoClose;
205240
205261
  }
205241
205262
  FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
205242
205263
  var self = this;
@@ -205247,18 +205268,30 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205247
205268
  });
205248
205269
  });
205249
205270
  };
205271
+ FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
205272
+ var self = this;
205273
+ self.pend.go(function(cb) {
205274
+ fs$3.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
205275
+ cb();
205276
+ callback(err, written, buffer);
205277
+ });
205278
+ });
205279
+ };
205250
205280
  FdSlicer.prototype.createReadStream = function(options) {
205251
205281
  return new ReadStream(this, options);
205252
205282
  };
205283
+ FdSlicer.prototype.createWriteStream = function(options) {
205284
+ return new WriteStream(this, options);
205285
+ };
205253
205286
  FdSlicer.prototype.ref = function() {
205254
205287
  this.refCount += 1;
205255
205288
  };
205256
205289
  FdSlicer.prototype.unref = function() {
205257
205290
  var self = this;
205258
205291
  self.refCount -= 1;
205259
- if (self.refCount < 0) throw new Error("invalid unref");
205260
205292
  if (self.refCount > 0) return;
205261
- fs$3.close(self.fd, onCloseDone);
205293
+ if (self.refCount < 0) throw new Error("invalid unref");
205294
+ if (self.autoClose) fs$3.close(self.fd, onCloseDone);
205262
205295
  function onCloseDone(err) {
205263
205296
  if (err) self.emit("error", err);
205264
205297
  else self.emit("close");
@@ -205273,23 +205306,28 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205273
205306
  this.start = options.start || 0;
205274
205307
  this.endOffset = options.end;
205275
205308
  this.pos = this.start;
205309
+ this.destroyed = false;
205276
205310
  }
205277
205311
  ReadStream.prototype._read = function(n) {
205278
205312
  var self = this;
205313
+ if (self.destroyed) return;
205279
205314
  var toRead = Math.min(self._readableState.highWaterMark, n);
205280
205315
  if (self.endOffset != null) toRead = Math.min(toRead, self.endOffset - self.pos);
205281
205316
  if (toRead <= 0) {
205317
+ self.destroyed = true;
205282
205318
  self.push(null);
205283
- this._cleanup();
205319
+ self.context.unref();
205284
205320
  return;
205285
205321
  }
205286
205322
  self.context.pend.go(function(cb) {
205323
+ if (self.destroyed) return cb();
205287
205324
  var buffer = Buffer.allocUnsafe(toRead);
205288
205325
  fs$3.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
205289
205326
  if (err) self.destroy(err);
205290
205327
  else if (bytesRead === 0) {
205328
+ self.destroyed = true;
205291
205329
  self.push(null);
205292
- this._cleanup();
205330
+ self.context.unref();
205293
205331
  } else {
205294
205332
  self.pos += bytesRead;
205295
205333
  self.push(buffer.slice(0, bytesRead));
@@ -205298,21 +205336,65 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205298
205336
  });
205299
205337
  });
205300
205338
  };
205301
- ReadStream.prototype._destroy = function(err, cb) {
205302
- this._cleanup();
205303
- cb(err);
205339
+ ReadStream.prototype.destroy = function(err) {
205340
+ if (this.destroyed) return;
205341
+ err = err || /* @__PURE__ */ new Error("stream destroyed");
205342
+ this.destroyed = true;
205343
+ this.emit("error", err);
205344
+ this.context.unref();
205304
205345
  };
205305
- ReadStream.prototype._cleanup = function() {
205306
- if (this.context != null) {
205307
- this.context.unref();
205308
- this.context = null;
205346
+ util$1.inherits(WriteStream, Writable);
205347
+ function WriteStream(context, options) {
205348
+ options = options || {};
205349
+ Writable.call(this, options);
205350
+ this.context = context;
205351
+ this.context.ref();
205352
+ this.start = options.start || 0;
205353
+ this.endOffset = options.end == null ? Infinity : +options.end;
205354
+ this.bytesWritten = 0;
205355
+ this.pos = this.start;
205356
+ this.destroyed = false;
205357
+ this.on("finish", this.destroy.bind(this));
205358
+ }
205359
+ WriteStream.prototype._write = function(buffer, encoding, callback) {
205360
+ var self = this;
205361
+ if (self.destroyed) return;
205362
+ if (self.pos + buffer.length > self.endOffset) {
205363
+ var err = /* @__PURE__ */ new Error("maximum file length exceeded");
205364
+ err.code = "ETOOBIG";
205365
+ self.destroy();
205366
+ callback(err);
205367
+ return;
205309
205368
  }
205369
+ self.context.pend.go(function(cb) {
205370
+ if (self.destroyed) return cb();
205371
+ fs$3.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
205372
+ if (err) {
205373
+ self.destroy();
205374
+ cb();
205375
+ callback(err);
205376
+ } else {
205377
+ self.bytesWritten += bytes;
205378
+ self.pos += bytes;
205379
+ self.emit("progress");
205380
+ cb();
205381
+ callback();
205382
+ }
205383
+ });
205384
+ });
205385
+ };
205386
+ WriteStream.prototype.destroy = function() {
205387
+ if (this.destroyed) return;
205388
+ this.destroyed = true;
205389
+ this.context.unref();
205310
205390
  };
205311
205391
  util$1.inherits(BufferSlicer, EventEmitter$2);
205312
- function BufferSlicer(buffer) {
205392
+ function BufferSlicer(buffer, options) {
205313
205393
  EventEmitter$2.call(this);
205394
+ options = options || {};
205314
205395
  this.refCount = 0;
205315
205396
  this.buffer = buffer;
205397
+ this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
205316
205398
  }
205317
205399
  BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
205318
205400
  if (!(0 <= offset && offset <= buffer.length)) throw new RangeError("offset outside buffer: 0 <= " + offset + " <= " + buffer.length);
@@ -205330,17 +205412,23 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205330
205412
  callback(null, length);
205331
205413
  });
205332
205414
  };
205415
+ BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
205416
+ buffer.copy(this.buffer, position, offset, offset + length);
205417
+ setImmediate(function() {
205418
+ callback(null, length, buffer);
205419
+ });
205420
+ };
205333
205421
  BufferSlicer.prototype.createReadStream = function(options) {
205334
205422
  options = options || {};
205335
205423
  var readStream = new PassThrough(options);
205424
+ readStream.destroyed = false;
205336
205425
  readStream.start = options.start || 0;
205337
205426
  readStream.endOffset = options.end;
205338
205427
  readStream.pos = readStream.endOffset || this.buffer.length;
205339
205428
  var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
205340
- var maxChunkSize = 65536;
205341
205429
  var offset = 0;
205342
205430
  while (true) {
205343
- var nextOffset = offset + maxChunkSize;
205431
+ var nextOffset = offset + this.maxChunkSize;
205344
205432
  if (nextOffset >= entireSlice.length) {
205345
205433
  if (offset < entireSlice.length) readStream.write(entireSlice.slice(offset, entireSlice.length));
205346
205434
  break;
@@ -205349,8 +205437,41 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205349
205437
  offset = nextOffset;
205350
205438
  }
205351
205439
  readStream.end();
205440
+ readStream.destroy = function() {
205441
+ readStream.destroyed = true;
205442
+ };
205352
205443
  return readStream;
205353
205444
  };
205445
+ BufferSlicer.prototype.createWriteStream = function(options) {
205446
+ var bufferSlicer = this;
205447
+ options = options || {};
205448
+ var writeStream = new Writable(options);
205449
+ writeStream.start = options.start || 0;
205450
+ writeStream.endOffset = options.end == null ? this.buffer.length : +options.end;
205451
+ writeStream.bytesWritten = 0;
205452
+ writeStream.pos = writeStream.start;
205453
+ writeStream.destroyed = false;
205454
+ writeStream._write = function(buffer, encoding, callback) {
205455
+ if (writeStream.destroyed) return;
205456
+ var end = writeStream.pos + buffer.length;
205457
+ if (end > writeStream.endOffset) {
205458
+ var err = /* @__PURE__ */ new Error("maximum file length exceeded");
205459
+ err.code = "ETOOBIG";
205460
+ writeStream.destroyed = true;
205461
+ callback(err);
205462
+ return;
205463
+ }
205464
+ buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
205465
+ writeStream.bytesWritten += buffer.length;
205466
+ writeStream.pos = end;
205467
+ writeStream.emit("progress");
205468
+ callback();
205469
+ };
205470
+ writeStream.destroy = function() {
205471
+ writeStream.destroyed = true;
205472
+ };
205473
+ return writeStream;
205474
+ };
205354
205475
  BufferSlicer.prototype.ref = function() {
205355
205476
  this.refCount += 1;
205356
205477
  };
@@ -205358,10 +205479,16 @@ var require_fd_slicer = /* @__PURE__ */ __commonJSMin(((exports) => {
205358
205479
  this.refCount -= 1;
205359
205480
  if (this.refCount < 0) throw new Error("invalid unref");
205360
205481
  };
205482
+ function createFromBuffer(buffer, options) {
205483
+ return new BufferSlicer(buffer, options);
205484
+ }
205485
+ function createFromFd(fd, options) {
205486
+ return new FdSlicer(fd, options);
205487
+ }
205361
205488
  }));
205362
205489
 
205363
205490
  //#endregion
205364
- //#region node_modules/.pnpm/yauzl@3.3.1/node_modules/yauzl/index.js
205491
+ //#region node_modules/.pnpm/yauzl@3.3.0/node_modules/yauzl/index.js
205365
205492
  var require_yauzl = /* @__PURE__ */ __commonJSMin(((exports) => {
205366
205493
  var fs$2 = __require("fs");
205367
205494
  var zlib = __require("zlib");
@@ -205408,7 +205535,7 @@ var require_yauzl = /* @__PURE__ */ __commonJSMin(((exports) => {
205408
205535
  if (callback == null) callback = defaultCallback;
205409
205536
  fs$2.fstat(fd, function(err, stats) {
205410
205537
  if (err) return callback(err);
205411
- fromRandomAccessReader(new fd_slicer.FdSlicer(fd), stats.size, options, callback);
205538
+ fromRandomAccessReader(fd_slicer.createFromFd(fd, { autoClose: true }), stats.size, options, callback);
205412
205539
  });
205413
205540
  }
205414
205541
  function fromBuffer(buffer, options, callback) {
@@ -205422,7 +205549,7 @@ var require_yauzl = /* @__PURE__ */ __commonJSMin(((exports) => {
205422
205549
  if (options.decodeStrings == null) options.decodeStrings = true;
205423
205550
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
205424
205551
  if (options.strictFileNames == null) options.strictFileNames = false;
205425
- fromRandomAccessReader(new fd_slicer.BufferSlicer(buffer), buffer.length, options, callback);
205552
+ fromRandomAccessReader(fd_slicer.createFromBuffer(buffer, { maxChunkSize: 65536 }), buffer.length, options, callback);
205426
205553
  }
205427
205554
  function fromRandomAccessReader(reader, totalSize, options, callback) {
205428
205555
  if (typeof options === "function") {
@@ -206785,9 +206912,15 @@ async function readLocalFile({ path: rawPath, loc, fullContent }) {
206785
206912
 
206786
206913
  //#endregion
206787
206914
  //#region ../../packages/local-file-shell/src/file/search.ts
206788
- async function searchLocalFiles({ keywords, directory, contentContains, limit = 30 }) {
206915
+ /**
206916
+ * Lightweight filename search — backed by `fast-glob` only. For the
206917
+ * platform-aware version that prefers Spotlight (`mdfind`) on macOS and
206918
+ * `fd` / `find` elsewhere, use `createFileSearchModule()` from
206919
+ * `@lobechat/local-file-shell/fileSearch`.
206920
+ */
206921
+ async function searchLocalFiles({ keywords, directory, onlyIn, contentContains, limit = 30 }) {
206789
206922
  try {
206790
- const cwd = expandTilde(directory) || process.cwd();
206923
+ const cwd = expandTilde(onlyIn ?? directory) || process.cwd();
206791
206924
  const wantsHidden = keywords.startsWith(".");
206792
206925
  let results = (await (0, import_out.default)(`**/*${keywords}*`, {
206793
206926
  cwd,
@@ -208783,21 +208916,6 @@ const toUsageData$1 = (raw) => {
208783
208916
  totalTokens: totalInputTokens + totalOutputTokens
208784
208917
  };
208785
208918
  };
208786
- const claudeCodePreset = {
208787
- baseArgs: [
208788
- "-p",
208789
- "--input-format",
208790
- "stream-json",
208791
- "--output-format",
208792
- "stream-json",
208793
- "--verbose",
208794
- "--include-partial-messages",
208795
- "--permission-mode",
208796
- "acceptEdits"
208797
- ],
208798
- promptMode: "stdin",
208799
- resumeArgs: (sessionId) => ["--resume", sessionId]
208800
- };
208801
208919
  var ClaudeCodeAdapter = class {
208802
208920
  sessionId;
208803
208921
  pendingRateLimitInfo;
@@ -209644,22 +209762,6 @@ const getCodexTerminalErrorMessage = (raw) => {
209644
209762
  const getCodexTerminalErrorStderr = (raw) => {
209645
209763
  return getStringValue(raw?.message) || getStringValue(raw?.error?.message) || getStringValue(raw?.error) || getStringValue(raw?.result) || (raw?.error && typeof raw.error === "object" ? JSON.stringify(raw.error) : void 0);
209646
209764
  };
209647
- const codexPreset = {
209648
- baseArgs: [
209649
- "exec",
209650
- "--json",
209651
- "--skip-git-repo-check",
209652
- "--full-auto"
209653
- ],
209654
- promptMode: "stdin",
209655
- resumeArgs: (sessionId) => [
209656
- "exec",
209657
- "resume",
209658
- "--json",
209659
- "--skip-git-repo-check",
209660
- sessionId
209661
- ]
209662
- };
209663
209765
  var CodexAdapter = class {
209664
209766
  currentAgentMessageItemId;
209665
209767
  currentModel;
@@ -209814,18 +209916,12 @@ var CodexAdapter = class {
209814
209916
  /**
209815
209917
  * Agent Adapter Registry
209816
209918
  *
209817
- * Maps agent type keys to their adapter constructors and CLI presets.
209818
- * New agents are added by registering here — no other code changes needed.
209919
+ * Maps agent type keys to their adapter constructors. New agents are added
209920
+ * by registering here — no other code changes needed.
209819
209921
  */
209820
209922
  const registry = {
209821
- "claude-code": {
209822
- createAdapter: () => new ClaudeCodeAdapter(),
209823
- preset: claudeCodePreset
209824
- },
209825
- "codex": {
209826
- createAdapter: () => new CodexAdapter(),
209827
- preset: codexPreset
209828
- }
209923
+ "claude-code": { createAdapter: () => new ClaudeCodeAdapter() },
209924
+ "codex": { createAdapter: () => new CodexAdapter() }
209829
209925
  };
209830
209926
  /**
209831
209927
  * Create an adapter instance for the given agent type.