hybrid 2.0.0 → 2.0.1

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 (2) hide show
  1. package/dist/server/index.cjs +324 -2539
  2. package/package.json +3 -3
@@ -7854,8 +7854,8 @@ async function listMemoryFiles(workspaceDir, extraPaths, userId, conversationId)
7854
7854
  const hybridMemoryDir = import_node_path.default.join(workspaceDir, ".hybrid", "memory");
7855
7855
  const addMarkdownFile = async (absPath) => {
7856
7856
  try {
7857
- const stat5 = await import_promises.default.lstat(absPath);
7858
- if (stat5.isSymbolicLink() || !stat5.isFile()) {
7857
+ const stat2 = await import_promises.default.lstat(absPath);
7858
+ if (stat2.isSymbolicLink() || !stat2.isFile()) {
7859
7859
  return;
7860
7860
  }
7861
7861
  if (!absPath.endsWith(".md")) {
@@ -7888,15 +7888,15 @@ async function listMemoryFiles(workspaceDir, extraPaths, userId, conversationId)
7888
7888
  if (normalizedExtraPaths.length > 0) {
7889
7889
  for (const inputPath of normalizedExtraPaths) {
7890
7890
  try {
7891
- const stat5 = await import_promises.default.lstat(inputPath);
7892
- if (stat5.isSymbolicLink()) {
7891
+ const stat2 = await import_promises.default.lstat(inputPath);
7892
+ if (stat2.isSymbolicLink()) {
7893
7893
  continue;
7894
7894
  }
7895
- if (stat5.isDirectory()) {
7895
+ if (stat2.isDirectory()) {
7896
7896
  await walkDir(inputPath, result);
7897
7897
  continue;
7898
7898
  }
7899
- if (stat5.isFile() && inputPath.endsWith(".md")) {
7899
+ if (stat2.isFile() && inputPath.endsWith(".md")) {
7900
7900
  result.push(inputPath);
7901
7901
  }
7902
7902
  } catch {
@@ -7940,9 +7940,9 @@ function extractUserIdFromPath(absPath, workspaceDir) {
7940
7940
  return null;
7941
7941
  }
7942
7942
  async function buildFileEntry(absPath, workspaceDir, userId, conversationId) {
7943
- let stat5;
7943
+ let stat2;
7944
7944
  try {
7945
- stat5 = await import_promises.default.stat(absPath);
7945
+ stat2 = await import_promises.default.stat(absPath);
7946
7946
  } catch (err) {
7947
7947
  if (isFileMissingError(err)) {
7948
7948
  return null;
@@ -7964,8 +7964,8 @@ async function buildFileEntry(absPath, workspaceDir, userId, conversationId) {
7964
7964
  return {
7965
7965
  path: import_node_path.default.relative(workspaceDir, absPath).replace(/\\/g, "/"),
7966
7966
  absPath,
7967
- mtimeMs: stat5.mtimeMs,
7968
- size: stat5.size,
7967
+ mtimeMs: stat2.mtimeMs,
7968
+ size: stat2.size,
7969
7969
  hash: hash2,
7970
7970
  userId: effectiveUserId,
7971
7971
  conversationId
@@ -8699,7 +8699,7 @@ var require_tr46 = __commonJS({
8699
8699
  TRANSITIONAL: 0,
8700
8700
  NONTRANSITIONAL: 1
8701
8701
  };
8702
- function normalize2(str2) {
8702
+ function normalize(str2) {
8703
8703
  return str2.split("\0").map(function(s2) {
8704
8704
  return s2.normalize("NFC");
8705
8705
  }).join("\0");
@@ -8779,7 +8779,7 @@ var require_tr46 = __commonJS({
8779
8779
  processing_option = PROCESSING_OPTIONS.NONTRANSITIONAL;
8780
8780
  }
8781
8781
  var error48 = false;
8782
- if (normalize2(label) !== label || label[3] === "-" && label[4] === "-" || label[0] === "-" || label[label.length - 1] === "-" || label.indexOf(".") !== -1 || label.search(combiningMarksRegex) === 0) {
8782
+ if (normalize(label) !== label || label[3] === "-" && label[4] === "-" || label[0] === "-" || label[label.length - 1] === "-" || label.indexOf(".") !== -1 || label.search(combiningMarksRegex) === 0) {
8783
8783
  error48 = true;
8784
8784
  }
8785
8785
  var len = countSymbols(label);
@@ -8797,7 +8797,7 @@ var require_tr46 = __commonJS({
8797
8797
  }
8798
8798
  function processing(domain_name, useSTD3, processing_option) {
8799
8799
  var result = mapChars(domain_name, useSTD3, processing_option);
8800
- result.string = normalize2(result.string);
8800
+ result.string = normalize(result.string);
8801
8801
  var labels = result.string.split(".");
8802
8802
  for (var i2 = 0; i2 < labels.length; ++i2) {
8803
8803
  try {
@@ -9240,14 +9240,14 @@ var require_url_state_machine = __commonJS({
9240
9240
  return url2.replace(/\u0009|\u000A|\u000D/g, "");
9241
9241
  }
9242
9242
  function shortenPath(url2) {
9243
- const path6 = url2.path;
9244
- if (path6.length === 0) {
9243
+ const path4 = url2.path;
9244
+ if (path4.length === 0) {
9245
9245
  return;
9246
9246
  }
9247
- if (url2.scheme === "file" && path6.length === 1 && isNormalizedWindowsDriveLetter(path6[0])) {
9247
+ if (url2.scheme === "file" && path4.length === 1 && isNormalizedWindowsDriveLetter(path4[0])) {
9248
9248
  return;
9249
9249
  }
9250
- path6.pop();
9250
+ path4.pop();
9251
9251
  }
9252
9252
  function includesCredentials(url2) {
9253
9253
  return url2.username !== "" || url2.password !== "";
@@ -10291,7 +10291,7 @@ var require_lib2 = __commonJS({
10291
10291
  var whatwgUrl = _interopDefault(require_public_api());
10292
10292
  var https = _interopDefault(require("https"));
10293
10293
  var zlib = _interopDefault(require("zlib"));
10294
- var Readable3 = Stream2.Readable;
10294
+ var Readable2 = Stream2.Readable;
10295
10295
  var BUFFER = /* @__PURE__ */ Symbol("buffer");
10296
10296
  var TYPE = /* @__PURE__ */ Symbol("type");
10297
10297
  var Blob3 = class _Blob {
@@ -10343,7 +10343,7 @@ var require_lib2 = __commonJS({
10343
10343
  return Promise.resolve(ab);
10344
10344
  }
10345
10345
  stream() {
10346
- const readable = new Readable3();
10346
+ const readable = new Readable2();
10347
10347
  readable._read = function() {
10348
10348
  };
10349
10349
  readable.push(this[BUFFER]);
@@ -10567,7 +10567,7 @@ var require_lib2 = __commonJS({
10567
10567
  let accum = [];
10568
10568
  let accumBytes = 0;
10569
10569
  let abort = false;
10570
- return new Body.Promise(function(resolve6, reject) {
10570
+ return new Body.Promise(function(resolve4, reject) {
10571
10571
  let resTimeout;
10572
10572
  if (_this4.timeout) {
10573
10573
  resTimeout = setTimeout(function() {
@@ -10601,7 +10601,7 @@ var require_lib2 = __commonJS({
10601
10601
  }
10602
10602
  clearTimeout(resTimeout);
10603
10603
  try {
10604
- resolve6(Buffer.concat(accum, accumBytes));
10604
+ resolve4(Buffer.concat(accum, accumBytes));
10605
10605
  } catch (err) {
10606
10606
  reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
10607
10607
  }
@@ -11276,7 +11276,7 @@ var require_lib2 = __commonJS({
11276
11276
  throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
11277
11277
  }
11278
11278
  Body.Promise = fetch3.Promise;
11279
- return new fetch3.Promise(function(resolve6, reject) {
11279
+ return new fetch3.Promise(function(resolve4, reject) {
11280
11280
  const request = new Request3(url2, opts);
11281
11281
  const options = getNodeRequestOptions(request);
11282
11282
  const send = (options.protocol === "https:" ? https : http).request;
@@ -11409,7 +11409,7 @@ var require_lib2 = __commonJS({
11409
11409
  requestOpts.body = void 0;
11410
11410
  requestOpts.headers.delete("content-length");
11411
11411
  }
11412
- resolve6(fetch3(new Request3(locationURL, requestOpts)));
11412
+ resolve4(fetch3(new Request3(locationURL, requestOpts)));
11413
11413
  finalize2();
11414
11414
  return;
11415
11415
  }
@@ -11430,7 +11430,7 @@ var require_lib2 = __commonJS({
11430
11430
  const codings = headers.get("Content-Encoding");
11431
11431
  if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
11432
11432
  response = new Response4(body, response_options);
11433
- resolve6(response);
11433
+ resolve4(response);
11434
11434
  return;
11435
11435
  }
11436
11436
  const zlibOptions = {
@@ -11440,7 +11440,7 @@ var require_lib2 = __commonJS({
11440
11440
  if (codings == "gzip" || codings == "x-gzip") {
11441
11441
  body = body.pipe(zlib.createGunzip(zlibOptions));
11442
11442
  response = new Response4(body, response_options);
11443
- resolve6(response);
11443
+ resolve4(response);
11444
11444
  return;
11445
11445
  }
11446
11446
  if (codings == "deflate" || codings == "x-deflate") {
@@ -11452,12 +11452,12 @@ var require_lib2 = __commonJS({
11452
11452
  body = body.pipe(zlib.createInflateRaw());
11453
11453
  }
11454
11454
  response = new Response4(body, response_options);
11455
- resolve6(response);
11455
+ resolve4(response);
11456
11456
  });
11457
11457
  raw.on("end", function() {
11458
11458
  if (!response) {
11459
11459
  response = new Response4(body, response_options);
11460
- resolve6(response);
11460
+ resolve4(response);
11461
11461
  }
11462
11462
  });
11463
11463
  return;
@@ -11465,11 +11465,11 @@ var require_lib2 = __commonJS({
11465
11465
  if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
11466
11466
  body = body.pipe(zlib.createBrotliDecompress());
11467
11467
  response = new Response4(body, response_options);
11468
- resolve6(response);
11468
+ resolve4(response);
11469
11469
  return;
11470
11470
  }
11471
11471
  response = new Response4(body, response_options);
11472
- resolve6(response);
11472
+ resolve4(response);
11473
11473
  });
11474
11474
  writeToStream(req, request);
11475
11475
  });
@@ -15231,14 +15231,14 @@ __export(fileFromPath_exports, {
15231
15231
  fileFromPathSync: () => fileFromPathSync,
15232
15232
  isFile: () => isFile
15233
15233
  });
15234
- function createFileFromPath(path6, { mtimeMs, size }, filenameOrOptions, options = {}) {
15234
+ function createFileFromPath(path4, { mtimeMs, size }, filenameOrOptions, options = {}) {
15235
15235
  let filename;
15236
15236
  if (isPlainObject_default2(filenameOrOptions)) {
15237
15237
  [options, filename] = [filenameOrOptions, void 0];
15238
15238
  } else {
15239
15239
  filename = filenameOrOptions;
15240
15240
  }
15241
- const file2 = new FileFromPath({ path: path6, size, lastModified: mtimeMs });
15241
+ const file2 = new FileFromPath({ path: path4, size, lastModified: mtimeMs });
15242
15242
  if (!filename) {
15243
15243
  filename = file2.name;
15244
15244
  }
@@ -15247,13 +15247,13 @@ function createFileFromPath(path6, { mtimeMs, size }, filenameOrOptions, options
15247
15247
  lastModified: file2.lastModified
15248
15248
  });
15249
15249
  }
15250
- function fileFromPathSync(path6, filenameOrOptions, options = {}) {
15251
- const stats = (0, import_fs2.statSync)(path6);
15252
- return createFileFromPath(path6, stats, filenameOrOptions, options);
15250
+ function fileFromPathSync(path4, filenameOrOptions, options = {}) {
15251
+ const stats = (0, import_fs2.statSync)(path4);
15252
+ return createFileFromPath(path4, stats, filenameOrOptions, options);
15253
15253
  }
15254
- async function fileFromPath2(path6, filenameOrOptions, options) {
15255
- const stats = await import_fs2.promises.stat(path6);
15256
- return createFileFromPath(path6, stats, filenameOrOptions, options);
15254
+ async function fileFromPath2(path4, filenameOrOptions, options) {
15255
+ const stats = await import_fs2.promises.stat(path4);
15256
+ return createFileFromPath(path4, stats, filenameOrOptions, options);
15257
15257
  }
15258
15258
  var import_fs2, import_path2, import_node_domexception, __classPrivateFieldSet4, __classPrivateFieldGet5, _FileFromPath_path, _FileFromPath_start, MESSAGE, FileFromPath;
15259
15259
  var init_fileFromPath = __esm({
@@ -15314,13 +15314,13 @@ var init_fileFromPath = __esm({
15314
15314
  });
15315
15315
 
15316
15316
  // ../../node_modules/.pnpm/openai@4.104.0_ws@8.18.3_bufferutil@4.0.9_utf-8-validate@5.0.10__zod@3.25.76/node_modules/openai/_shims/node-runtime.mjs
15317
- async function fileFromPath3(path6, ...args) {
15317
+ async function fileFromPath3(path4, ...args) {
15318
15318
  const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
15319
15319
  if (!fileFromPathWarned) {
15320
- console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path6)}) instead`);
15320
+ console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path4)}) instead`);
15321
15321
  fileFromPathWarned = true;
15322
15322
  }
15323
- return await _fileFromPath(path6, ...args);
15323
+ return await _fileFromPath(path4, ...args);
15324
15324
  }
15325
15325
  async function getMultipartRequestOptions2(form, opts) {
15326
15326
  const encoder = new FormDataEncoder(form);
@@ -16150,8 +16150,8 @@ var init_core = __esm({
16150
16150
  init();
16151
16151
  APIPromise = class _APIPromise extends Promise {
16152
16152
  constructor(responsePromise, parseResponse2 = defaultParseResponse) {
16153
- super((resolve6) => {
16154
- resolve6(null);
16153
+ super((resolve4) => {
16154
+ resolve4(null);
16155
16155
  });
16156
16156
  this.responsePromise = responsePromise;
16157
16157
  this.parseResponse = parseResponse2;
@@ -16253,29 +16253,29 @@ var init_core = __esm({
16253
16253
  defaultIdempotencyKey() {
16254
16254
  return `stainless-node-retry-${uuid42()}`;
16255
16255
  }
16256
- get(path6, opts) {
16257
- return this.methodRequest("get", path6, opts);
16256
+ get(path4, opts) {
16257
+ return this.methodRequest("get", path4, opts);
16258
16258
  }
16259
- post(path6, opts) {
16260
- return this.methodRequest("post", path6, opts);
16259
+ post(path4, opts) {
16260
+ return this.methodRequest("post", path4, opts);
16261
16261
  }
16262
- patch(path6, opts) {
16263
- return this.methodRequest("patch", path6, opts);
16262
+ patch(path4, opts) {
16263
+ return this.methodRequest("patch", path4, opts);
16264
16264
  }
16265
- put(path6, opts) {
16266
- return this.methodRequest("put", path6, opts);
16265
+ put(path4, opts) {
16266
+ return this.methodRequest("put", path4, opts);
16267
16267
  }
16268
- delete(path6, opts) {
16269
- return this.methodRequest("delete", path6, opts);
16268
+ delete(path4, opts) {
16269
+ return this.methodRequest("delete", path4, opts);
16270
16270
  }
16271
- methodRequest(method, path6, opts) {
16271
+ methodRequest(method, path4, opts) {
16272
16272
  return this.request(Promise.resolve(opts).then(async (opts2) => {
16273
16273
  const body = opts2 && isBlobLike(opts2?.body) ? new DataView(await opts2.body.arrayBuffer()) : opts2?.body instanceof DataView ? opts2.body : opts2?.body instanceof ArrayBuffer ? new DataView(opts2.body) : opts2 && ArrayBuffer.isView(opts2?.body) ? new DataView(opts2.body.buffer) : opts2?.body;
16274
- return { method, path: path6, ...opts2, body };
16274
+ return { method, path: path4, ...opts2, body };
16275
16275
  }));
16276
16276
  }
16277
- getAPIList(path6, Page2, opts) {
16278
- return this.requestAPIList(Page2, { method: "get", path: path6, ...opts });
16277
+ getAPIList(path4, Page2, opts) {
16278
+ return this.requestAPIList(Page2, { method: "get", path: path4, ...opts });
16279
16279
  }
16280
16280
  calculateContentLength(body) {
16281
16281
  if (typeof body === "string") {
@@ -16294,10 +16294,10 @@ var init_core = __esm({
16294
16294
  }
16295
16295
  buildRequest(inputOptions, { retryCount = 0 } = {}) {
16296
16296
  const options = { ...inputOptions };
16297
- const { method, path: path6, query: query2, headers = {} } = options;
16297
+ const { method, path: path4, query: query2, headers = {} } = options;
16298
16298
  const body = ArrayBuffer.isView(options.body) || options.__binaryRequest && typeof options.body === "string" ? options.body : isMultipartBody(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null;
16299
16299
  const contentLength = this.calculateContentLength(body);
16300
- const url2 = this.buildURL(path6, query2);
16300
+ const url2 = this.buildURL(path4, query2);
16301
16301
  if ("timeout" in options)
16302
16302
  validatePositiveInteger("timeout", options.timeout);
16303
16303
  options.timeout = options.timeout ?? this.timeout;
@@ -16413,8 +16413,8 @@ var init_core = __esm({
16413
16413
  const request = this.makeRequest(options, null);
16414
16414
  return new PagePromise(this, request, Page2);
16415
16415
  }
16416
- buildURL(path6, query2) {
16417
- const url2 = isAbsoluteURL(path6) ? new URL(path6) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path6.startsWith("/") ? path6.slice(1) : path6));
16416
+ buildURL(path4, query2) {
16417
+ const url2 = isAbsoluteURL(path4) ? new URL(path4) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path4.startsWith("/") ? path4.slice(1) : path4));
16418
16418
  const defaultQuery = this.defaultQuery();
16419
16419
  if (!isEmptyObj(defaultQuery)) {
16420
16420
  query2 = { ...defaultQuery, ...query2 };
@@ -16702,7 +16702,7 @@ var init_core = __esm({
16702
16702
  isAbsoluteURL = (url2) => {
16703
16703
  return startsWithSchemeRegexp.test(url2);
16704
16704
  };
16705
- sleep = (ms) => new Promise((resolve6) => setTimeout(resolve6, ms));
16705
+ sleep = (ms) => new Promise((resolve4) => setTimeout(resolve4, ms));
16706
16706
  validatePositiveInteger = (name, n2) => {
16707
16707
  if (typeof n2 !== "number" || !Number.isInteger(n2)) {
16708
16708
  throw new OpenAIError(`${name} must be an integer`);
@@ -17163,12 +17163,12 @@ var init_EventStream = __esm({
17163
17163
  _EventStream_errored.set(this, false);
17164
17164
  _EventStream_aborted.set(this, false);
17165
17165
  _EventStream_catchingPromiseCreated.set(this, false);
17166
- __classPrivateFieldSet7(this, _EventStream_connectedPromise, new Promise((resolve6, reject) => {
17167
- __classPrivateFieldSet7(this, _EventStream_resolveConnectedPromise, resolve6, "f");
17166
+ __classPrivateFieldSet7(this, _EventStream_connectedPromise, new Promise((resolve4, reject) => {
17167
+ __classPrivateFieldSet7(this, _EventStream_resolveConnectedPromise, resolve4, "f");
17168
17168
  __classPrivateFieldSet7(this, _EventStream_rejectConnectedPromise, reject, "f");
17169
17169
  }), "f");
17170
- __classPrivateFieldSet7(this, _EventStream_endPromise, new Promise((resolve6, reject) => {
17171
- __classPrivateFieldSet7(this, _EventStream_resolveEndPromise, resolve6, "f");
17170
+ __classPrivateFieldSet7(this, _EventStream_endPromise, new Promise((resolve4, reject) => {
17171
+ __classPrivateFieldSet7(this, _EventStream_resolveEndPromise, resolve4, "f");
17172
17172
  __classPrivateFieldSet7(this, _EventStream_rejectEndPromise, reject, "f");
17173
17173
  }), "f");
17174
17174
  __classPrivateFieldGet8(this, _EventStream_connectedPromise, "f").catch(() => {
@@ -17252,11 +17252,11 @@ var init_EventStream = __esm({
17252
17252
  * const message = await stream.emitted('message') // rejects if the stream errors
17253
17253
  */
17254
17254
  emitted(event) {
17255
- return new Promise((resolve6, reject) => {
17255
+ return new Promise((resolve4, reject) => {
17256
17256
  __classPrivateFieldSet7(this, _EventStream_catchingPromiseCreated, true, "f");
17257
17257
  if (event !== "error")
17258
17258
  this.once("error", reject);
17259
- this.once(event, resolve6);
17259
+ this.once(event, resolve4);
17260
17260
  });
17261
17261
  }
17262
17262
  async done() {
@@ -17398,7 +17398,7 @@ var init_AssistantStream = __esm({
17398
17398
  if (done) {
17399
17399
  return { value: void 0, done: true };
17400
17400
  }
17401
- return new Promise((resolve6, reject) => readQueue.push({ resolve: resolve6, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
17401
+ return new Promise((resolve4, reject) => readQueue.push({ resolve: resolve4, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
17402
17402
  }
17403
17403
  const chunk = pushQueue.shift();
17404
17404
  return { value: chunk, done: false };
@@ -19141,7 +19141,7 @@ var init_ChatCompletionStream = __esm({
19141
19141
  if (done) {
19142
19142
  return { value: void 0, done: true };
19143
19143
  }
19144
- return new Promise((resolve6, reject) => readQueue.push({ resolve: resolve6, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
19144
+ return new Promise((resolve4, reject) => readQueue.push({ resolve: resolve4, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
19145
19145
  }
19146
19146
  const chunk = pushQueue.shift();
19147
19147
  return { value: chunk, done: false };
@@ -20994,7 +20994,7 @@ var init_ResponseStream = __esm({
20994
20994
  if (done) {
20995
20995
  return { value: void 0, done: true };
20996
20996
  }
20997
- return new Promise((resolve6, reject) => readQueue.push({ resolve: resolve6, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
20997
+ return new Promise((resolve4, reject) => readQueue.push({ resolve: resolve4, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
20998
20998
  }
20999
20999
  const event = pushQueue.shift();
21000
21000
  return { value: event, done: false };
@@ -22863,1960 +22863,18 @@ var init_manager = __esm({
22863
22863
  }
22864
22864
  });
22865
22865
 
22866
- // ../../node_modules/.pnpm/readdirp@4.1.2/node_modules/readdirp/esm/index.js
22867
- function readdirp(root, options = {}) {
22868
- let type = options.entryType || options.type;
22869
- if (type === "both")
22870
- type = EntryTypes.FILE_DIR_TYPE;
22871
- if (type)
22872
- options.type = type;
22873
- if (!root) {
22874
- throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
22875
- } else if (typeof root !== "string") {
22876
- throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
22877
- } else if (type && !ALL_TYPES.includes(type)) {
22878
- throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
22879
- }
22880
- options.root = root;
22881
- return new ReaddirpStream(options);
22882
- }
22883
- var import_promises3, import_node_stream2, import_node_path3, EntryTypes, defaultOptions2, RECURSIVE_ERROR_CODE, NORMAL_FLOW_ERRORS, ALL_TYPES, DIR_TYPES, FILE_TYPES, isNormalFlowError, wantBigintFsStats, emptyFn, normalizeFilter, ReaddirpStream;
22884
- var init_esm3 = __esm({
22885
- "../../node_modules/.pnpm/readdirp@4.1.2/node_modules/readdirp/esm/index.js"() {
22886
- import_promises3 = require("node:fs/promises");
22887
- import_node_stream2 = require("node:stream");
22888
- import_node_path3 = require("node:path");
22889
- EntryTypes = {
22890
- FILE_TYPE: "files",
22891
- DIR_TYPE: "directories",
22892
- FILE_DIR_TYPE: "files_directories",
22893
- EVERYTHING_TYPE: "all"
22894
- };
22895
- defaultOptions2 = {
22896
- root: ".",
22897
- fileFilter: (_entryInfo) => true,
22898
- directoryFilter: (_entryInfo) => true,
22899
- type: EntryTypes.FILE_TYPE,
22900
- lstat: false,
22901
- depth: 2147483648,
22902
- alwaysStat: false,
22903
- highWaterMark: 4096
22904
- };
22905
- Object.freeze(defaultOptions2);
22906
- RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
22907
- NORMAL_FLOW_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
22908
- ALL_TYPES = [
22909
- EntryTypes.DIR_TYPE,
22910
- EntryTypes.EVERYTHING_TYPE,
22911
- EntryTypes.FILE_DIR_TYPE,
22912
- EntryTypes.FILE_TYPE
22913
- ];
22914
- DIR_TYPES = /* @__PURE__ */ new Set([
22915
- EntryTypes.DIR_TYPE,
22916
- EntryTypes.EVERYTHING_TYPE,
22917
- EntryTypes.FILE_DIR_TYPE
22918
- ]);
22919
- FILE_TYPES = /* @__PURE__ */ new Set([
22920
- EntryTypes.EVERYTHING_TYPE,
22921
- EntryTypes.FILE_DIR_TYPE,
22922
- EntryTypes.FILE_TYPE
22923
- ]);
22924
- isNormalFlowError = (error48) => NORMAL_FLOW_ERRORS.has(error48.code);
22925
- wantBigintFsStats = process.platform === "win32";
22926
- emptyFn = (_entryInfo) => true;
22927
- normalizeFilter = (filter) => {
22928
- if (filter === void 0)
22929
- return emptyFn;
22930
- if (typeof filter === "function")
22931
- return filter;
22932
- if (typeof filter === "string") {
22933
- const fl = filter.trim();
22934
- return (entry) => entry.basename === fl;
22935
- }
22936
- if (Array.isArray(filter)) {
22937
- const trItems = filter.map((item) => item.trim());
22938
- return (entry) => trItems.some((f2) => entry.basename === f2);
22939
- }
22940
- return emptyFn;
22941
- };
22942
- ReaddirpStream = class extends import_node_stream2.Readable {
22943
- constructor(options = {}) {
22944
- super({
22945
- objectMode: true,
22946
- autoDestroy: true,
22947
- highWaterMark: options.highWaterMark
22948
- });
22949
- const opts = { ...defaultOptions2, ...options };
22950
- const { root, type } = opts;
22951
- this._fileFilter = normalizeFilter(opts.fileFilter);
22952
- this._directoryFilter = normalizeFilter(opts.directoryFilter);
22953
- const statMethod = opts.lstat ? import_promises3.lstat : import_promises3.stat;
22954
- if (wantBigintFsStats) {
22955
- this._stat = (path6) => statMethod(path6, { bigint: true });
22956
- } else {
22957
- this._stat = statMethod;
22958
- }
22959
- this._maxDepth = opts.depth ?? defaultOptions2.depth;
22960
- this._wantsDir = type ? DIR_TYPES.has(type) : false;
22961
- this._wantsFile = type ? FILE_TYPES.has(type) : false;
22962
- this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
22963
- this._root = (0, import_node_path3.resolve)(root);
22964
- this._isDirent = !opts.alwaysStat;
22965
- this._statsProp = this._isDirent ? "dirent" : "stats";
22966
- this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
22967
- this.parents = [this._exploreDir(root, 1)];
22968
- this.reading = false;
22969
- this.parent = void 0;
22970
- }
22971
- async _read(batch) {
22972
- if (this.reading)
22973
- return;
22974
- this.reading = true;
22975
- try {
22976
- while (!this.destroyed && batch > 0) {
22977
- const par = this.parent;
22978
- const fil = par && par.files;
22979
- if (fil && fil.length > 0) {
22980
- const { path: path6, depth } = par;
22981
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path6));
22982
- const awaited = await Promise.all(slice);
22983
- for (const entry of awaited) {
22984
- if (!entry)
22985
- continue;
22986
- if (this.destroyed)
22987
- return;
22988
- const entryType = await this._getEntryType(entry);
22989
- if (entryType === "directory" && this._directoryFilter(entry)) {
22990
- if (depth <= this._maxDepth) {
22991
- this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
22992
- }
22993
- if (this._wantsDir) {
22994
- this.push(entry);
22995
- batch--;
22996
- }
22997
- } else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
22998
- if (this._wantsFile) {
22999
- this.push(entry);
23000
- batch--;
23001
- }
23002
- }
23003
- }
23004
- } else {
23005
- const parent = this.parents.pop();
23006
- if (!parent) {
23007
- this.push(null);
23008
- break;
23009
- }
23010
- this.parent = await parent;
23011
- if (this.destroyed)
23012
- return;
23013
- }
23014
- }
23015
- } catch (error48) {
23016
- this.destroy(error48);
23017
- } finally {
23018
- this.reading = false;
23019
- }
23020
- }
23021
- async _exploreDir(path6, depth) {
23022
- let files;
23023
- try {
23024
- files = await (0, import_promises3.readdir)(path6, this._rdOptions);
23025
- } catch (error48) {
23026
- this._onError(error48);
23027
- }
23028
- return { files, depth, path: path6 };
23029
- }
23030
- async _formatEntry(dirent, path6) {
23031
- let entry;
23032
- const basename4 = this._isDirent ? dirent.name : dirent;
23033
- try {
23034
- const fullPath = (0, import_node_path3.resolve)((0, import_node_path3.join)(path6, basename4));
23035
- entry = { path: (0, import_node_path3.relative)(this._root, fullPath), fullPath, basename: basename4 };
23036
- entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
23037
- } catch (err) {
23038
- this._onError(err);
23039
- return;
23040
- }
23041
- return entry;
23042
- }
23043
- _onError(err) {
23044
- if (isNormalFlowError(err) && !this.destroyed) {
23045
- this.emit("warn", err);
23046
- } else {
23047
- this.destroy(err);
23048
- }
23049
- }
23050
- async _getEntryType(entry) {
23051
- if (!entry && this._statsProp in entry) {
23052
- return "";
23053
- }
23054
- const stats = entry[this._statsProp];
23055
- if (stats.isFile())
23056
- return "file";
23057
- if (stats.isDirectory())
23058
- return "directory";
23059
- if (stats && stats.isSymbolicLink()) {
23060
- const full = entry.fullPath;
23061
- try {
23062
- const entryRealPath = await (0, import_promises3.realpath)(full);
23063
- const entryRealPathStats = await (0, import_promises3.lstat)(entryRealPath);
23064
- if (entryRealPathStats.isFile()) {
23065
- return "file";
23066
- }
23067
- if (entryRealPathStats.isDirectory()) {
23068
- const len = entryRealPath.length;
23069
- if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path3.sep) {
23070
- const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
23071
- recursiveError.code = RECURSIVE_ERROR_CODE;
23072
- return this._onError(recursiveError);
23073
- }
23074
- return "directory";
23075
- }
23076
- } catch (error48) {
23077
- this._onError(error48);
23078
- return "";
23079
- }
23080
- }
23081
- }
23082
- _includeAsFile(entry) {
23083
- const stats = entry && entry[this._statsProp];
23084
- return stats && this._wantsEverything && !stats.isDirectory();
23085
- }
23086
- };
23087
- }
23088
- });
23089
-
23090
- // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/handler.js
23091
- function createFsWatchInstance(path6, options, listener, errHandler, emitRaw) {
23092
- const handleEvent = (rawEvent, evPath) => {
23093
- listener(path6);
23094
- emitRaw(rawEvent, evPath, { watchedPath: path6 });
23095
- if (evPath && path6 !== evPath) {
23096
- fsWatchBroadcast(sysPath.resolve(path6, evPath), KEY_LISTENERS, sysPath.join(path6, evPath));
23097
- }
23098
- };
23099
- try {
23100
- return (0, import_fs3.watch)(path6, {
23101
- persistent: options.persistent
23102
- }, handleEvent);
23103
- } catch (error48) {
23104
- errHandler(error48);
23105
- return void 0;
23106
- }
23107
- }
23108
- var import_fs3, import_promises4, sysPath, import_os, STR_DATA, STR_END, STR_CLOSE, EMPTY_FN, pl, isWindows, isMacos, isLinux, isFreeBSD, isIBMi, EVENTS, EV, THROTTLE_MODE_WATCH, statMethods, KEY_LISTENERS, KEY_ERR, KEY_RAW, HANDLER_KEYS, binaryExtensions, isBinaryPath, foreach, addAndConvert, clearItem, delFromSet, isEmptySet, FsWatchInstances, fsWatchBroadcast, setFsWatchListener, FsWatchFileInstances, setFsWatchFileListener, NodeFsHandler;
23109
- var init_handler = __esm({
23110
- "../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/handler.js"() {
23111
- import_fs3 = require("fs");
23112
- import_promises4 = require("fs/promises");
23113
- sysPath = __toESM(require("path"), 1);
23114
- import_os = require("os");
23115
- STR_DATA = "data";
23116
- STR_END = "end";
23117
- STR_CLOSE = "close";
23118
- EMPTY_FN = () => {
23119
- };
23120
- pl = process.platform;
23121
- isWindows = pl === "win32";
23122
- isMacos = pl === "darwin";
23123
- isLinux = pl === "linux";
23124
- isFreeBSD = pl === "freebsd";
23125
- isIBMi = (0, import_os.type)() === "OS400";
23126
- EVENTS = {
23127
- ALL: "all",
23128
- READY: "ready",
23129
- ADD: "add",
23130
- CHANGE: "change",
23131
- ADD_DIR: "addDir",
23132
- UNLINK: "unlink",
23133
- UNLINK_DIR: "unlinkDir",
23134
- RAW: "raw",
23135
- ERROR: "error"
23136
- };
23137
- EV = EVENTS;
23138
- THROTTLE_MODE_WATCH = "watch";
23139
- statMethods = { lstat: import_promises4.lstat, stat: import_promises4.stat };
23140
- KEY_LISTENERS = "listeners";
23141
- KEY_ERR = "errHandlers";
23142
- KEY_RAW = "rawEmitters";
23143
- HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
23144
- binaryExtensions = /* @__PURE__ */ new Set([
23145
- "3dm",
23146
- "3ds",
23147
- "3g2",
23148
- "3gp",
23149
- "7z",
23150
- "a",
23151
- "aac",
23152
- "adp",
23153
- "afdesign",
23154
- "afphoto",
23155
- "afpub",
23156
- "ai",
23157
- "aif",
23158
- "aiff",
23159
- "alz",
23160
- "ape",
23161
- "apk",
23162
- "appimage",
23163
- "ar",
23164
- "arj",
23165
- "asf",
23166
- "au",
23167
- "avi",
23168
- "bak",
23169
- "baml",
23170
- "bh",
23171
- "bin",
23172
- "bk",
23173
- "bmp",
23174
- "btif",
23175
- "bz2",
23176
- "bzip2",
23177
- "cab",
23178
- "caf",
23179
- "cgm",
23180
- "class",
23181
- "cmx",
23182
- "cpio",
23183
- "cr2",
23184
- "cur",
23185
- "dat",
23186
- "dcm",
23187
- "deb",
23188
- "dex",
23189
- "djvu",
23190
- "dll",
23191
- "dmg",
23192
- "dng",
23193
- "doc",
23194
- "docm",
23195
- "docx",
23196
- "dot",
23197
- "dotm",
23198
- "dra",
23199
- "DS_Store",
23200
- "dsk",
23201
- "dts",
23202
- "dtshd",
23203
- "dvb",
23204
- "dwg",
23205
- "dxf",
23206
- "ecelp4800",
23207
- "ecelp7470",
23208
- "ecelp9600",
23209
- "egg",
23210
- "eol",
23211
- "eot",
23212
- "epub",
23213
- "exe",
23214
- "f4v",
23215
- "fbs",
23216
- "fh",
23217
- "fla",
23218
- "flac",
23219
- "flatpak",
23220
- "fli",
23221
- "flv",
23222
- "fpx",
23223
- "fst",
23224
- "fvt",
23225
- "g3",
23226
- "gh",
23227
- "gif",
23228
- "graffle",
23229
- "gz",
23230
- "gzip",
23231
- "h261",
23232
- "h263",
23233
- "h264",
23234
- "icns",
23235
- "ico",
23236
- "ief",
23237
- "img",
23238
- "ipa",
23239
- "iso",
23240
- "jar",
23241
- "jpeg",
23242
- "jpg",
23243
- "jpgv",
23244
- "jpm",
23245
- "jxr",
23246
- "key",
23247
- "ktx",
23248
- "lha",
23249
- "lib",
23250
- "lvp",
23251
- "lz",
23252
- "lzh",
23253
- "lzma",
23254
- "lzo",
23255
- "m3u",
23256
- "m4a",
23257
- "m4v",
23258
- "mar",
23259
- "mdi",
23260
- "mht",
23261
- "mid",
23262
- "midi",
23263
- "mj2",
23264
- "mka",
23265
- "mkv",
23266
- "mmr",
23267
- "mng",
23268
- "mobi",
23269
- "mov",
23270
- "movie",
23271
- "mp3",
23272
- "mp4",
23273
- "mp4a",
23274
- "mpeg",
23275
- "mpg",
23276
- "mpga",
23277
- "mxu",
23278
- "nef",
23279
- "npx",
23280
- "numbers",
23281
- "nupkg",
23282
- "o",
23283
- "odp",
23284
- "ods",
23285
- "odt",
23286
- "oga",
23287
- "ogg",
23288
- "ogv",
23289
- "otf",
23290
- "ott",
23291
- "pages",
23292
- "pbm",
23293
- "pcx",
23294
- "pdb",
23295
- "pdf",
23296
- "pea",
23297
- "pgm",
23298
- "pic",
23299
- "png",
23300
- "pnm",
23301
- "pot",
23302
- "potm",
23303
- "potx",
23304
- "ppa",
23305
- "ppam",
23306
- "ppm",
23307
- "pps",
23308
- "ppsm",
23309
- "ppsx",
23310
- "ppt",
23311
- "pptm",
23312
- "pptx",
23313
- "psd",
23314
- "pya",
23315
- "pyc",
23316
- "pyo",
23317
- "pyv",
23318
- "qt",
23319
- "rar",
23320
- "ras",
23321
- "raw",
23322
- "resources",
23323
- "rgb",
23324
- "rip",
23325
- "rlc",
23326
- "rmf",
23327
- "rmvb",
23328
- "rpm",
23329
- "rtf",
23330
- "rz",
23331
- "s3m",
23332
- "s7z",
23333
- "scpt",
23334
- "sgi",
23335
- "shar",
23336
- "snap",
23337
- "sil",
23338
- "sketch",
23339
- "slk",
23340
- "smv",
23341
- "snk",
23342
- "so",
23343
- "stl",
23344
- "suo",
23345
- "sub",
23346
- "swf",
23347
- "tar",
23348
- "tbz",
23349
- "tbz2",
23350
- "tga",
23351
- "tgz",
23352
- "thmx",
23353
- "tif",
23354
- "tiff",
23355
- "tlz",
23356
- "ttc",
23357
- "ttf",
23358
- "txz",
23359
- "udf",
23360
- "uvh",
23361
- "uvi",
23362
- "uvm",
23363
- "uvp",
23364
- "uvs",
23365
- "uvu",
23366
- "viv",
23367
- "vob",
23368
- "war",
23369
- "wav",
23370
- "wax",
23371
- "wbmp",
23372
- "wdp",
23373
- "weba",
23374
- "webm",
23375
- "webp",
23376
- "whl",
23377
- "wim",
23378
- "wm",
23379
- "wma",
23380
- "wmv",
23381
- "wmx",
23382
- "woff",
23383
- "woff2",
23384
- "wrm",
23385
- "wvx",
23386
- "xbm",
23387
- "xif",
23388
- "xla",
23389
- "xlam",
23390
- "xls",
23391
- "xlsb",
23392
- "xlsm",
23393
- "xlsx",
23394
- "xlt",
23395
- "xltm",
23396
- "xltx",
23397
- "xm",
23398
- "xmind",
23399
- "xpi",
23400
- "xpm",
23401
- "xwd",
23402
- "xz",
23403
- "z",
23404
- "zip",
23405
- "zipx"
23406
- ]);
23407
- isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
23408
- foreach = (val, fn) => {
23409
- if (val instanceof Set) {
23410
- val.forEach(fn);
23411
- } else {
23412
- fn(val);
23413
- }
23414
- };
23415
- addAndConvert = (main, prop, item) => {
23416
- let container = main[prop];
23417
- if (!(container instanceof Set)) {
23418
- main[prop] = container = /* @__PURE__ */ new Set([container]);
23419
- }
23420
- container.add(item);
23421
- };
23422
- clearItem = (cont) => (key) => {
23423
- const set2 = cont[key];
23424
- if (set2 instanceof Set) {
23425
- set2.clear();
23426
- } else {
23427
- delete cont[key];
23428
- }
23429
- };
23430
- delFromSet = (main, prop, item) => {
23431
- const container = main[prop];
23432
- if (container instanceof Set) {
23433
- container.delete(item);
23434
- } else if (container === item) {
23435
- delete main[prop];
23436
- }
23437
- };
23438
- isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
23439
- FsWatchInstances = /* @__PURE__ */ new Map();
23440
- fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
23441
- const cont = FsWatchInstances.get(fullPath);
23442
- if (!cont)
23443
- return;
23444
- foreach(cont[listenerType], (listener) => {
23445
- listener(val1, val2, val3);
23446
- });
23447
- };
23448
- setFsWatchListener = (path6, fullPath, options, handlers) => {
23449
- const { listener, errHandler, rawEmitter } = handlers;
23450
- let cont = FsWatchInstances.get(fullPath);
23451
- let watcher;
23452
- if (!options.persistent) {
23453
- watcher = createFsWatchInstance(path6, options, listener, errHandler, rawEmitter);
23454
- if (!watcher)
23455
- return;
23456
- return watcher.close.bind(watcher);
23457
- }
23458
- if (cont) {
23459
- addAndConvert(cont, KEY_LISTENERS, listener);
23460
- addAndConvert(cont, KEY_ERR, errHandler);
23461
- addAndConvert(cont, KEY_RAW, rawEmitter);
23462
- } else {
23463
- watcher = createFsWatchInstance(
23464
- path6,
23465
- options,
23466
- fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
23467
- errHandler,
23468
- // no need to use broadcast here
23469
- fsWatchBroadcast.bind(null, fullPath, KEY_RAW)
23470
- );
23471
- if (!watcher)
23472
- return;
23473
- watcher.on(EV.ERROR, async (error48) => {
23474
- const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
23475
- if (cont)
23476
- cont.watcherUnusable = true;
23477
- if (isWindows && error48.code === "EPERM") {
23478
- try {
23479
- const fd = await (0, import_promises4.open)(path6, "r");
23480
- await fd.close();
23481
- broadcastErr(error48);
23482
- } catch (err) {
23483
- }
23484
- } else {
23485
- broadcastErr(error48);
23486
- }
23487
- });
23488
- cont = {
23489
- listeners: listener,
23490
- errHandlers: errHandler,
23491
- rawEmitters: rawEmitter,
23492
- watcher
23493
- };
23494
- FsWatchInstances.set(fullPath, cont);
23495
- }
23496
- return () => {
23497
- delFromSet(cont, KEY_LISTENERS, listener);
23498
- delFromSet(cont, KEY_ERR, errHandler);
23499
- delFromSet(cont, KEY_RAW, rawEmitter);
23500
- if (isEmptySet(cont.listeners)) {
23501
- cont.watcher.close();
23502
- FsWatchInstances.delete(fullPath);
23503
- HANDLER_KEYS.forEach(clearItem(cont));
23504
- cont.watcher = void 0;
23505
- Object.freeze(cont);
23506
- }
23507
- };
23508
- };
23509
- FsWatchFileInstances = /* @__PURE__ */ new Map();
23510
- setFsWatchFileListener = (path6, fullPath, options, handlers) => {
23511
- const { listener, rawEmitter } = handlers;
23512
- let cont = FsWatchFileInstances.get(fullPath);
23513
- const copts = cont && cont.options;
23514
- if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
23515
- (0, import_fs3.unwatchFile)(fullPath);
23516
- cont = void 0;
23517
- }
23518
- if (cont) {
23519
- addAndConvert(cont, KEY_LISTENERS, listener);
23520
- addAndConvert(cont, KEY_RAW, rawEmitter);
23521
- } else {
23522
- cont = {
23523
- listeners: listener,
23524
- rawEmitters: rawEmitter,
23525
- options,
23526
- watcher: (0, import_fs3.watchFile)(fullPath, options, (curr, prev) => {
23527
- foreach(cont.rawEmitters, (rawEmitter2) => {
23528
- rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
23529
- });
23530
- const currmtime = curr.mtimeMs;
23531
- if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
23532
- foreach(cont.listeners, (listener2) => listener2(path6, curr));
23533
- }
23534
- })
23535
- };
23536
- FsWatchFileInstances.set(fullPath, cont);
23537
- }
23538
- return () => {
23539
- delFromSet(cont, KEY_LISTENERS, listener);
23540
- delFromSet(cont, KEY_RAW, rawEmitter);
23541
- if (isEmptySet(cont.listeners)) {
23542
- FsWatchFileInstances.delete(fullPath);
23543
- (0, import_fs3.unwatchFile)(fullPath);
23544
- cont.options = cont.watcher = void 0;
23545
- Object.freeze(cont);
23546
- }
23547
- };
23548
- };
23549
- NodeFsHandler = class {
23550
- constructor(fsW) {
23551
- this.fsw = fsW;
23552
- this._boundHandleError = (error48) => fsW._handleError(error48);
23553
- }
23554
- /**
23555
- * Watch file for changes with fs_watchFile or fs_watch.
23556
- * @param path to file or dir
23557
- * @param listener on fs change
23558
- * @returns closer for the watcher instance
23559
- */
23560
- _watchWithNodeFs(path6, listener) {
23561
- const opts = this.fsw.options;
23562
- const directory = sysPath.dirname(path6);
23563
- const basename4 = sysPath.basename(path6);
23564
- const parent = this.fsw._getWatchedDir(directory);
23565
- parent.add(basename4);
23566
- const absolutePath = sysPath.resolve(path6);
23567
- const options = {
23568
- persistent: opts.persistent
23569
- };
23570
- if (!listener)
23571
- listener = EMPTY_FN;
23572
- let closer;
23573
- if (opts.usePolling) {
23574
- const enableBin = opts.interval !== opts.binaryInterval;
23575
- options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
23576
- closer = setFsWatchFileListener(path6, absolutePath, options, {
23577
- listener,
23578
- rawEmitter: this.fsw._emitRaw
23579
- });
23580
- } else {
23581
- closer = setFsWatchListener(path6, absolutePath, options, {
23582
- listener,
23583
- errHandler: this._boundHandleError,
23584
- rawEmitter: this.fsw._emitRaw
23585
- });
23586
- }
23587
- return closer;
23588
- }
23589
- /**
23590
- * Watch a file and emit add event if warranted.
23591
- * @returns closer for the watcher instance
23592
- */
23593
- _handleFile(file2, stats, initialAdd) {
23594
- if (this.fsw.closed) {
23595
- return;
23596
- }
23597
- const dirname7 = sysPath.dirname(file2);
23598
- const basename4 = sysPath.basename(file2);
23599
- const parent = this.fsw._getWatchedDir(dirname7);
23600
- let prevStats = stats;
23601
- if (parent.has(basename4))
23602
- return;
23603
- const listener = async (path6, newStats) => {
23604
- if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
23605
- return;
23606
- if (!newStats || newStats.mtimeMs === 0) {
23607
- try {
23608
- const newStats2 = await (0, import_promises4.stat)(file2);
23609
- if (this.fsw.closed)
23610
- return;
23611
- const at2 = newStats2.atimeMs;
23612
- const mt2 = newStats2.mtimeMs;
23613
- if (!at2 || at2 <= mt2 || mt2 !== prevStats.mtimeMs) {
23614
- this.fsw._emit(EV.CHANGE, file2, newStats2);
23615
- }
23616
- if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
23617
- this.fsw._closeFile(path6);
23618
- prevStats = newStats2;
23619
- const closer2 = this._watchWithNodeFs(file2, listener);
23620
- if (closer2)
23621
- this.fsw._addPathCloser(path6, closer2);
23622
- } else {
23623
- prevStats = newStats2;
23624
- }
23625
- } catch (error48) {
23626
- this.fsw._remove(dirname7, basename4);
23627
- }
23628
- } else if (parent.has(basename4)) {
23629
- const at2 = newStats.atimeMs;
23630
- const mt2 = newStats.mtimeMs;
23631
- if (!at2 || at2 <= mt2 || mt2 !== prevStats.mtimeMs) {
23632
- this.fsw._emit(EV.CHANGE, file2, newStats);
23633
- }
23634
- prevStats = newStats;
23635
- }
23636
- };
23637
- const closer = this._watchWithNodeFs(file2, listener);
23638
- if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file2)) {
23639
- if (!this.fsw._throttle(EV.ADD, file2, 0))
23640
- return;
23641
- this.fsw._emit(EV.ADD, file2, stats);
23642
- }
23643
- return closer;
23644
- }
23645
- /**
23646
- * Handle symlinks encountered while reading a dir.
23647
- * @param entry returned by readdirp
23648
- * @param directory path of dir being read
23649
- * @param path of this item
23650
- * @param item basename of this item
23651
- * @returns true if no more processing is needed for this entry.
23652
- */
23653
- async _handleSymlink(entry, directory, path6, item) {
23654
- if (this.fsw.closed) {
23655
- return;
23656
- }
23657
- const full = entry.fullPath;
23658
- const dir = this.fsw._getWatchedDir(directory);
23659
- if (!this.fsw.options.followSymlinks) {
23660
- this.fsw._incrReadyCount();
23661
- let linkPath;
23662
- try {
23663
- linkPath = await (0, import_promises4.realpath)(path6);
23664
- } catch (e2) {
23665
- this.fsw._emitReady();
23666
- return true;
23667
- }
23668
- if (this.fsw.closed)
23669
- return;
23670
- if (dir.has(item)) {
23671
- if (this.fsw._symlinkPaths.get(full) !== linkPath) {
23672
- this.fsw._symlinkPaths.set(full, linkPath);
23673
- this.fsw._emit(EV.CHANGE, path6, entry.stats);
23674
- }
23675
- } else {
23676
- dir.add(item);
23677
- this.fsw._symlinkPaths.set(full, linkPath);
23678
- this.fsw._emit(EV.ADD, path6, entry.stats);
23679
- }
23680
- this.fsw._emitReady();
23681
- return true;
23682
- }
23683
- if (this.fsw._symlinkPaths.has(full)) {
23684
- return true;
23685
- }
23686
- this.fsw._symlinkPaths.set(full, true);
23687
- }
23688
- _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
23689
- directory = sysPath.join(directory, "");
23690
- throttler = this.fsw._throttle("readdir", directory, 1e3);
23691
- if (!throttler)
23692
- return;
23693
- const previous = this.fsw._getWatchedDir(wh.path);
23694
- const current = /* @__PURE__ */ new Set();
23695
- let stream = this.fsw._readdirp(directory, {
23696
- fileFilter: (entry) => wh.filterPath(entry),
23697
- directoryFilter: (entry) => wh.filterDir(entry)
23698
- });
23699
- if (!stream)
23700
- return;
23701
- stream.on(STR_DATA, async (entry) => {
23702
- if (this.fsw.closed) {
23703
- stream = void 0;
23704
- return;
23705
- }
23706
- const item = entry.path;
23707
- let path6 = sysPath.join(directory, item);
23708
- current.add(item);
23709
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path6, item)) {
23710
- return;
23711
- }
23712
- if (this.fsw.closed) {
23713
- stream = void 0;
23714
- return;
23715
- }
23716
- if (item === target || !target && !previous.has(item)) {
23717
- this.fsw._incrReadyCount();
23718
- path6 = sysPath.join(dir, sysPath.relative(dir, path6));
23719
- this._addToNodeFs(path6, initialAdd, wh, depth + 1);
23720
- }
23721
- }).on(EV.ERROR, this._boundHandleError);
23722
- return new Promise((resolve6, reject) => {
23723
- if (!stream)
23724
- return reject();
23725
- stream.once(STR_END, () => {
23726
- if (this.fsw.closed) {
23727
- stream = void 0;
23728
- return;
23729
- }
23730
- const wasThrottled = throttler ? throttler.clear() : false;
23731
- resolve6(void 0);
23732
- previous.getChildren().filter((item) => {
23733
- return item !== directory && !current.has(item);
23734
- }).forEach((item) => {
23735
- this.fsw._remove(directory, item);
23736
- });
23737
- stream = void 0;
23738
- if (wasThrottled)
23739
- this._handleRead(directory, false, wh, target, dir, depth, throttler);
23740
- });
23741
- });
23742
- }
23743
- /**
23744
- * Read directory to add / remove files from `@watched` list and re-read it on change.
23745
- * @param dir fs path
23746
- * @param stats
23747
- * @param initialAdd
23748
- * @param depth relative to user-supplied path
23749
- * @param target child path targeted for watch
23750
- * @param wh Common watch helpers for this path
23751
- * @param realpath
23752
- * @returns closer for the watcher instance.
23753
- */
23754
- async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
23755
- const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
23756
- const tracked = parentDir.has(sysPath.basename(dir));
23757
- if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
23758
- this.fsw._emit(EV.ADD_DIR, dir, stats);
23759
- }
23760
- parentDir.add(sysPath.basename(dir));
23761
- this.fsw._getWatchedDir(dir);
23762
- let throttler;
23763
- let closer;
23764
- const oDepth = this.fsw.options.depth;
23765
- if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath2)) {
23766
- if (!target) {
23767
- await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
23768
- if (this.fsw.closed)
23769
- return;
23770
- }
23771
- closer = this._watchWithNodeFs(dir, (dirPath, stats2) => {
23772
- if (stats2 && stats2.mtimeMs === 0)
23773
- return;
23774
- this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
23775
- });
23776
- }
23777
- return closer;
23778
- }
23779
- /**
23780
- * Handle added file, directory, or glob pattern.
23781
- * Delegates call to _handleFile / _handleDir after checks.
23782
- * @param path to file or ir
23783
- * @param initialAdd was the file added at watch instantiation?
23784
- * @param priorWh depth relative to user-supplied path
23785
- * @param depth Child path actually targeted for watch
23786
- * @param target Child path actually targeted for watch
23787
- */
23788
- async _addToNodeFs(path6, initialAdd, priorWh, depth, target) {
23789
- const ready = this.fsw._emitReady;
23790
- if (this.fsw._isIgnored(path6) || this.fsw.closed) {
23791
- ready();
23792
- return false;
23793
- }
23794
- const wh = this.fsw._getWatchHelpers(path6);
23795
- if (priorWh) {
23796
- wh.filterPath = (entry) => priorWh.filterPath(entry);
23797
- wh.filterDir = (entry) => priorWh.filterDir(entry);
23798
- }
23799
- try {
23800
- const stats = await statMethods[wh.statMethod](wh.watchPath);
23801
- if (this.fsw.closed)
23802
- return;
23803
- if (this.fsw._isIgnored(wh.watchPath, stats)) {
23804
- ready();
23805
- return false;
23806
- }
23807
- const follow = this.fsw.options.followSymlinks;
23808
- let closer;
23809
- if (stats.isDirectory()) {
23810
- const absPath = sysPath.resolve(path6);
23811
- const targetPath = follow ? await (0, import_promises4.realpath)(path6) : path6;
23812
- if (this.fsw.closed)
23813
- return;
23814
- closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
23815
- if (this.fsw.closed)
23816
- return;
23817
- if (absPath !== targetPath && targetPath !== void 0) {
23818
- this.fsw._symlinkPaths.set(absPath, targetPath);
23819
- }
23820
- } else if (stats.isSymbolicLink()) {
23821
- const targetPath = follow ? await (0, import_promises4.realpath)(path6) : path6;
23822
- if (this.fsw.closed)
23823
- return;
23824
- const parent = sysPath.dirname(wh.watchPath);
23825
- this.fsw._getWatchedDir(parent).add(wh.watchPath);
23826
- this.fsw._emit(EV.ADD, wh.watchPath, stats);
23827
- closer = await this._handleDir(parent, stats, initialAdd, depth, path6, wh, targetPath);
23828
- if (this.fsw.closed)
23829
- return;
23830
- if (targetPath !== void 0) {
23831
- this.fsw._symlinkPaths.set(sysPath.resolve(path6), targetPath);
23832
- }
23833
- } else {
23834
- closer = this._handleFile(wh.watchPath, stats, initialAdd);
23835
- }
23836
- ready();
23837
- if (closer)
23838
- this.fsw._addPathCloser(path6, closer);
23839
- return false;
23840
- } catch (error48) {
23841
- if (this.fsw._handleError(error48)) {
23842
- ready();
23843
- return path6;
23844
- }
23845
- }
23846
- }
23847
- };
23848
- }
23849
- });
23850
-
23851
- // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
23852
- function arrify(item) {
23853
- return Array.isArray(item) ? item : [item];
23854
- }
23855
- function createPattern(matcher) {
23856
- if (typeof matcher === "function")
23857
- return matcher;
23858
- if (typeof matcher === "string")
23859
- return (string4) => matcher === string4;
23860
- if (matcher instanceof RegExp)
23861
- return (string4) => matcher.test(string4);
23862
- if (typeof matcher === "object" && matcher !== null) {
23863
- return (string4) => {
23864
- if (matcher.path === string4)
23865
- return true;
23866
- if (matcher.recursive) {
23867
- const relative3 = sysPath2.relative(matcher.path, string4);
23868
- if (!relative3) {
23869
- return false;
23870
- }
23871
- return !relative3.startsWith("..") && !sysPath2.isAbsolute(relative3);
23872
- }
23873
- return false;
23874
- };
23875
- }
23876
- return () => false;
23877
- }
23878
- function normalizePath(path6) {
23879
- if (typeof path6 !== "string")
23880
- throw new Error("string expected");
23881
- path6 = sysPath2.normalize(path6);
23882
- path6 = path6.replace(/\\/g, "/");
23883
- let prepend = false;
23884
- if (path6.startsWith("//"))
23885
- prepend = true;
23886
- const DOUBLE_SLASH_RE2 = /\/\//;
23887
- while (path6.match(DOUBLE_SLASH_RE2))
23888
- path6 = path6.replace(DOUBLE_SLASH_RE2, "/");
23889
- if (prepend)
23890
- path6 = "/" + path6;
23891
- return path6;
23892
- }
23893
- function matchPatterns(patterns, testString, stats) {
23894
- const path6 = normalizePath(testString);
23895
- for (let index = 0; index < patterns.length; index++) {
23896
- const pattern = patterns[index];
23897
- if (pattern(path6, stats)) {
23898
- return true;
23899
- }
23900
- }
23901
- return false;
23902
- }
23903
- function anymatch(matchers, testString) {
23904
- if (matchers == null) {
23905
- throw new TypeError("anymatch: specify first argument");
23906
- }
23907
- const matchersArray = arrify(matchers);
23908
- const patterns = matchersArray.map((matcher) => createPattern(matcher));
23909
- if (testString == null) {
23910
- return (testString2, stats) => {
23911
- return matchPatterns(patterns, testString2, stats);
23912
- };
23913
- }
23914
- return matchPatterns(patterns, testString);
23915
- }
23916
- function watch(paths, options = {}) {
23917
- const watcher = new FSWatcher(options);
23918
- watcher.add(paths);
23919
- return watcher;
23920
- }
23921
- var import_fs4, import_promises5, import_events, sysPath2, SLASH, SLASH_SLASH, ONE_DOT, TWO_DOTS, STRING_TYPE, BACK_SLASH_RE, DOUBLE_SLASH_RE, DOT_RE, REPLACER_RE, isMatcherObject, unifyPaths, toUnix, normalizePathToUnix, normalizeIgnored, getAbsolutePath, EMPTY_SET, DirEntry, STAT_METHOD_F, STAT_METHOD_L, WatchHelper, FSWatcher, esm_default;
23922
- var init_esm4 = __esm({
23923
- "../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"() {
23924
- import_fs4 = require("fs");
23925
- import_promises5 = require("fs/promises");
23926
- import_events = require("events");
23927
- sysPath2 = __toESM(require("path"), 1);
23928
- init_esm3();
23929
- init_handler();
23930
- SLASH = "/";
23931
- SLASH_SLASH = "//";
23932
- ONE_DOT = ".";
23933
- TWO_DOTS = "..";
23934
- STRING_TYPE = "string";
23935
- BACK_SLASH_RE = /\\/g;
23936
- DOUBLE_SLASH_RE = /\/\//;
23937
- DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
23938
- REPLACER_RE = /^\.[/\\]/;
23939
- isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
23940
- unifyPaths = (paths_) => {
23941
- const paths = arrify(paths_).flat();
23942
- if (!paths.every((p2) => typeof p2 === STRING_TYPE)) {
23943
- throw new TypeError(`Non-string provided as watch path: ${paths}`);
23944
- }
23945
- return paths.map(normalizePathToUnix);
23946
- };
23947
- toUnix = (string4) => {
23948
- let str2 = string4.replace(BACK_SLASH_RE, SLASH);
23949
- let prepend = false;
23950
- if (str2.startsWith(SLASH_SLASH)) {
23951
- prepend = true;
23952
- }
23953
- while (str2.match(DOUBLE_SLASH_RE)) {
23954
- str2 = str2.replace(DOUBLE_SLASH_RE, SLASH);
23955
- }
23956
- if (prepend) {
23957
- str2 = SLASH + str2;
23958
- }
23959
- return str2;
23960
- };
23961
- normalizePathToUnix = (path6) => toUnix(sysPath2.normalize(toUnix(path6)));
23962
- normalizeIgnored = (cwd = "") => (path6) => {
23963
- if (typeof path6 === "string") {
23964
- return normalizePathToUnix(sysPath2.isAbsolute(path6) ? path6 : sysPath2.join(cwd, path6));
23965
- } else {
23966
- return path6;
23967
- }
23968
- };
23969
- getAbsolutePath = (path6, cwd) => {
23970
- if (sysPath2.isAbsolute(path6)) {
23971
- return path6;
23972
- }
23973
- return sysPath2.join(cwd, path6);
23974
- };
23975
- EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
23976
- DirEntry = class {
23977
- constructor(dir, removeWatcher) {
23978
- this.path = dir;
23979
- this._removeWatcher = removeWatcher;
23980
- this.items = /* @__PURE__ */ new Set();
23981
- }
23982
- add(item) {
23983
- const { items } = this;
23984
- if (!items)
23985
- return;
23986
- if (item !== ONE_DOT && item !== TWO_DOTS)
23987
- items.add(item);
23988
- }
23989
- async remove(item) {
23990
- const { items } = this;
23991
- if (!items)
23992
- return;
23993
- items.delete(item);
23994
- if (items.size > 0)
23995
- return;
23996
- const dir = this.path;
23997
- try {
23998
- await (0, import_promises5.readdir)(dir);
23999
- } catch (err) {
24000
- if (this._removeWatcher) {
24001
- this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
24002
- }
24003
- }
24004
- }
24005
- has(item) {
24006
- const { items } = this;
24007
- if (!items)
24008
- return;
24009
- return items.has(item);
24010
- }
24011
- getChildren() {
24012
- const { items } = this;
24013
- if (!items)
24014
- return [];
24015
- return [...items.values()];
24016
- }
24017
- dispose() {
24018
- this.items.clear();
24019
- this.path = "";
24020
- this._removeWatcher = EMPTY_FN;
24021
- this.items = EMPTY_SET;
24022
- Object.freeze(this);
24023
- }
24024
- };
24025
- STAT_METHOD_F = "stat";
24026
- STAT_METHOD_L = "lstat";
24027
- WatchHelper = class {
24028
- constructor(path6, follow, fsw) {
24029
- this.fsw = fsw;
24030
- const watchPath = path6;
24031
- this.path = path6 = path6.replace(REPLACER_RE, "");
24032
- this.watchPath = watchPath;
24033
- this.fullWatchPath = sysPath2.resolve(watchPath);
24034
- this.dirParts = [];
24035
- this.dirParts.forEach((parts) => {
24036
- if (parts.length > 1)
24037
- parts.pop();
24038
- });
24039
- this.followSymlinks = follow;
24040
- this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
24041
- }
24042
- entryPath(entry) {
24043
- return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath, entry.fullPath));
24044
- }
24045
- filterPath(entry) {
24046
- const { stats } = entry;
24047
- if (stats && stats.isSymbolicLink())
24048
- return this.filterDir(entry);
24049
- const resolvedPath = this.entryPath(entry);
24050
- return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
24051
- }
24052
- filterDir(entry) {
24053
- return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
24054
- }
24055
- };
24056
- FSWatcher = class extends import_events.EventEmitter {
24057
- // Not indenting methods for history sake; for now.
24058
- constructor(_opts = {}) {
24059
- super();
24060
- this.closed = false;
24061
- this._closers = /* @__PURE__ */ new Map();
24062
- this._ignoredPaths = /* @__PURE__ */ new Set();
24063
- this._throttled = /* @__PURE__ */ new Map();
24064
- this._streams = /* @__PURE__ */ new Set();
24065
- this._symlinkPaths = /* @__PURE__ */ new Map();
24066
- this._watched = /* @__PURE__ */ new Map();
24067
- this._pendingWrites = /* @__PURE__ */ new Map();
24068
- this._pendingUnlinks = /* @__PURE__ */ new Map();
24069
- this._readyCount = 0;
24070
- this._readyEmitted = false;
24071
- const awf = _opts.awaitWriteFinish;
24072
- const DEF_AWF = { stabilityThreshold: 2e3, pollInterval: 100 };
24073
- const opts = {
24074
- // Defaults
24075
- persistent: true,
24076
- ignoreInitial: false,
24077
- ignorePermissionErrors: false,
24078
- interval: 100,
24079
- binaryInterval: 300,
24080
- followSymlinks: true,
24081
- usePolling: false,
24082
- // useAsync: false,
24083
- atomic: true,
24084
- // NOTE: overwritten later (depends on usePolling)
24085
- ..._opts,
24086
- // Change format
24087
- ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
24088
- awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? { ...DEF_AWF, ...awf } : false
24089
- };
24090
- if (isIBMi)
24091
- opts.usePolling = true;
24092
- if (opts.atomic === void 0)
24093
- opts.atomic = !opts.usePolling;
24094
- const envPoll = process.env.CHOKIDAR_USEPOLLING;
24095
- if (envPoll !== void 0) {
24096
- const envLower = envPoll.toLowerCase();
24097
- if (envLower === "false" || envLower === "0")
24098
- opts.usePolling = false;
24099
- else if (envLower === "true" || envLower === "1")
24100
- opts.usePolling = true;
24101
- else
24102
- opts.usePolling = !!envLower;
24103
- }
24104
- const envInterval = process.env.CHOKIDAR_INTERVAL;
24105
- if (envInterval)
24106
- opts.interval = Number.parseInt(envInterval, 10);
24107
- let readyCalls = 0;
24108
- this._emitReady = () => {
24109
- readyCalls++;
24110
- if (readyCalls >= this._readyCount) {
24111
- this._emitReady = EMPTY_FN;
24112
- this._readyEmitted = true;
24113
- process.nextTick(() => this.emit(EVENTS.READY));
24114
- }
24115
- };
24116
- this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
24117
- this._boundRemove = this._remove.bind(this);
24118
- this.options = opts;
24119
- this._nodeFsHandler = new NodeFsHandler(this);
24120
- Object.freeze(opts);
24121
- }
24122
- _addIgnoredPath(matcher) {
24123
- if (isMatcherObject(matcher)) {
24124
- for (const ignored of this._ignoredPaths) {
24125
- if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) {
24126
- return;
24127
- }
24128
- }
24129
- }
24130
- this._ignoredPaths.add(matcher);
24131
- }
24132
- _removeIgnoredPath(matcher) {
24133
- this._ignoredPaths.delete(matcher);
24134
- if (typeof matcher === "string") {
24135
- for (const ignored of this._ignoredPaths) {
24136
- if (isMatcherObject(ignored) && ignored.path === matcher) {
24137
- this._ignoredPaths.delete(ignored);
24138
- }
24139
- }
24140
- }
24141
- }
24142
- // Public methods
24143
- /**
24144
- * Adds paths to be watched on an existing FSWatcher instance.
24145
- * @param paths_ file or file list. Other arguments are unused
24146
- */
24147
- add(paths_, _origAdd, _internal) {
24148
- const { cwd } = this.options;
24149
- this.closed = false;
24150
- this._closePromise = void 0;
24151
- let paths = unifyPaths(paths_);
24152
- if (cwd) {
24153
- paths = paths.map((path6) => {
24154
- const absPath = getAbsolutePath(path6, cwd);
24155
- return absPath;
24156
- });
24157
- }
24158
- paths.forEach((path6) => {
24159
- this._removeIgnoredPath(path6);
24160
- });
24161
- this._userIgnored = void 0;
24162
- if (!this._readyCount)
24163
- this._readyCount = 0;
24164
- this._readyCount += paths.length;
24165
- Promise.all(paths.map(async (path6) => {
24166
- const res = await this._nodeFsHandler._addToNodeFs(path6, !_internal, void 0, 0, _origAdd);
24167
- if (res)
24168
- this._emitReady();
24169
- return res;
24170
- })).then((results) => {
24171
- if (this.closed)
24172
- return;
24173
- results.forEach((item) => {
24174
- if (item)
24175
- this.add(sysPath2.dirname(item), sysPath2.basename(_origAdd || item));
24176
- });
24177
- });
24178
- return this;
24179
- }
24180
- /**
24181
- * Close watchers or start ignoring events from specified paths.
24182
- */
24183
- unwatch(paths_) {
24184
- if (this.closed)
24185
- return this;
24186
- const paths = unifyPaths(paths_);
24187
- const { cwd } = this.options;
24188
- paths.forEach((path6) => {
24189
- if (!sysPath2.isAbsolute(path6) && !this._closers.has(path6)) {
24190
- if (cwd)
24191
- path6 = sysPath2.join(cwd, path6);
24192
- path6 = sysPath2.resolve(path6);
24193
- }
24194
- this._closePath(path6);
24195
- this._addIgnoredPath(path6);
24196
- if (this._watched.has(path6)) {
24197
- this._addIgnoredPath({
24198
- path: path6,
24199
- recursive: true
24200
- });
24201
- }
24202
- this._userIgnored = void 0;
24203
- });
24204
- return this;
24205
- }
24206
- /**
24207
- * Close watchers and remove all listeners from watched paths.
24208
- */
24209
- close() {
24210
- if (this._closePromise) {
24211
- return this._closePromise;
24212
- }
24213
- this.closed = true;
24214
- this.removeAllListeners();
24215
- const closers = [];
24216
- this._closers.forEach((closerList) => closerList.forEach((closer) => {
24217
- const promise2 = closer();
24218
- if (promise2 instanceof Promise)
24219
- closers.push(promise2);
24220
- }));
24221
- this._streams.forEach((stream) => stream.destroy());
24222
- this._userIgnored = void 0;
24223
- this._readyCount = 0;
24224
- this._readyEmitted = false;
24225
- this._watched.forEach((dirent) => dirent.dispose());
24226
- this._closers.clear();
24227
- this._watched.clear();
24228
- this._streams.clear();
24229
- this._symlinkPaths.clear();
24230
- this._throttled.clear();
24231
- this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
24232
- return this._closePromise;
24233
- }
24234
- /**
24235
- * Expose list of watched paths
24236
- * @returns for chaining
24237
- */
24238
- getWatched() {
24239
- const watchList = {};
24240
- this._watched.forEach((entry, dir) => {
24241
- const key = this.options.cwd ? sysPath2.relative(this.options.cwd, dir) : dir;
24242
- const index = key || ONE_DOT;
24243
- watchList[index] = entry.getChildren().sort();
24244
- });
24245
- return watchList;
24246
- }
24247
- emitWithAll(event, args) {
24248
- this.emit(event, ...args);
24249
- if (event !== EVENTS.ERROR)
24250
- this.emit(EVENTS.ALL, event, ...args);
24251
- }
24252
- // Common helpers
24253
- // --------------
24254
- /**
24255
- * Normalize and emit events.
24256
- * Calling _emit DOES NOT MEAN emit() would be called!
24257
- * @param event Type of event
24258
- * @param path File or directory path
24259
- * @param stats arguments to be passed with event
24260
- * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
24261
- */
24262
- async _emit(event, path6, stats) {
24263
- if (this.closed)
24264
- return;
24265
- const opts = this.options;
24266
- if (isWindows)
24267
- path6 = sysPath2.normalize(path6);
24268
- if (opts.cwd)
24269
- path6 = sysPath2.relative(opts.cwd, path6);
24270
- const args = [path6];
24271
- if (stats != null)
24272
- args.push(stats);
24273
- const awf = opts.awaitWriteFinish;
24274
- let pw;
24275
- if (awf && (pw = this._pendingWrites.get(path6))) {
24276
- pw.lastChange = /* @__PURE__ */ new Date();
24277
- return this;
24278
- }
24279
- if (opts.atomic) {
24280
- if (event === EVENTS.UNLINK) {
24281
- this._pendingUnlinks.set(path6, [event, ...args]);
24282
- setTimeout(() => {
24283
- this._pendingUnlinks.forEach((entry, path7) => {
24284
- this.emit(...entry);
24285
- this.emit(EVENTS.ALL, ...entry);
24286
- this._pendingUnlinks.delete(path7);
24287
- });
24288
- }, typeof opts.atomic === "number" ? opts.atomic : 100);
24289
- return this;
24290
- }
24291
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path6)) {
24292
- event = EVENTS.CHANGE;
24293
- this._pendingUnlinks.delete(path6);
24294
- }
24295
- }
24296
- if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
24297
- const awfEmit = (err, stats2) => {
24298
- if (err) {
24299
- event = EVENTS.ERROR;
24300
- args[0] = err;
24301
- this.emitWithAll(event, args);
24302
- } else if (stats2) {
24303
- if (args.length > 1) {
24304
- args[1] = stats2;
24305
- } else {
24306
- args.push(stats2);
24307
- }
24308
- this.emitWithAll(event, args);
24309
- }
24310
- };
24311
- this._awaitWriteFinish(path6, awf.stabilityThreshold, event, awfEmit);
24312
- return this;
24313
- }
24314
- if (event === EVENTS.CHANGE) {
24315
- const isThrottled = !this._throttle(EVENTS.CHANGE, path6, 50);
24316
- if (isThrottled)
24317
- return this;
24318
- }
24319
- if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
24320
- const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path6) : path6;
24321
- let stats2;
24322
- try {
24323
- stats2 = await (0, import_promises5.stat)(fullPath);
24324
- } catch (err) {
24325
- }
24326
- if (!stats2 || this.closed)
24327
- return;
24328
- args.push(stats2);
24329
- }
24330
- this.emitWithAll(event, args);
24331
- return this;
24332
- }
24333
- /**
24334
- * Common handler for errors
24335
- * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
24336
- */
24337
- _handleError(error48) {
24338
- const code = error48 && error48.code;
24339
- if (error48 && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) {
24340
- this.emit(EVENTS.ERROR, error48);
24341
- }
24342
- return error48 || this.closed;
24343
- }
24344
- /**
24345
- * Helper utility for throttling
24346
- * @param actionType type being throttled
24347
- * @param path being acted upon
24348
- * @param timeout duration of time to suppress duplicate actions
24349
- * @returns tracking object or false if action should be suppressed
24350
- */
24351
- _throttle(actionType, path6, timeout) {
24352
- if (!this._throttled.has(actionType)) {
24353
- this._throttled.set(actionType, /* @__PURE__ */ new Map());
24354
- }
24355
- const action = this._throttled.get(actionType);
24356
- if (!action)
24357
- throw new Error("invalid throttle");
24358
- const actionPath = action.get(path6);
24359
- if (actionPath) {
24360
- actionPath.count++;
24361
- return false;
24362
- }
24363
- let timeoutObject;
24364
- const clear = () => {
24365
- const item = action.get(path6);
24366
- const count = item ? item.count : 0;
24367
- action.delete(path6);
24368
- clearTimeout(timeoutObject);
24369
- if (item)
24370
- clearTimeout(item.timeoutObject);
24371
- return count;
24372
- };
24373
- timeoutObject = setTimeout(clear, timeout);
24374
- const thr = { timeoutObject, clear, count: 0 };
24375
- action.set(path6, thr);
24376
- return thr;
24377
- }
24378
- _incrReadyCount() {
24379
- return this._readyCount++;
24380
- }
24381
- /**
24382
- * Awaits write operation to finish.
24383
- * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
24384
- * @param path being acted upon
24385
- * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
24386
- * @param event
24387
- * @param awfEmit Callback to be called when ready for event to be emitted.
24388
- */
24389
- _awaitWriteFinish(path6, threshold, event, awfEmit) {
24390
- const awf = this.options.awaitWriteFinish;
24391
- if (typeof awf !== "object")
24392
- return;
24393
- const pollInterval = awf.pollInterval;
24394
- let timeoutHandler;
24395
- let fullPath = path6;
24396
- if (this.options.cwd && !sysPath2.isAbsolute(path6)) {
24397
- fullPath = sysPath2.join(this.options.cwd, path6);
24398
- }
24399
- const now = /* @__PURE__ */ new Date();
24400
- const writes = this._pendingWrites;
24401
- function awaitWriteFinishFn(prevStat) {
24402
- (0, import_fs4.stat)(fullPath, (err, curStat) => {
24403
- if (err || !writes.has(path6)) {
24404
- if (err && err.code !== "ENOENT")
24405
- awfEmit(err);
24406
- return;
24407
- }
24408
- const now2 = Number(/* @__PURE__ */ new Date());
24409
- if (prevStat && curStat.size !== prevStat.size) {
24410
- writes.get(path6).lastChange = now2;
24411
- }
24412
- const pw = writes.get(path6);
24413
- const df = now2 - pw.lastChange;
24414
- if (df >= threshold) {
24415
- writes.delete(path6);
24416
- awfEmit(void 0, curStat);
24417
- } else {
24418
- timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
24419
- }
24420
- });
24421
- }
24422
- if (!writes.has(path6)) {
24423
- writes.set(path6, {
24424
- lastChange: now,
24425
- cancelWait: () => {
24426
- writes.delete(path6);
24427
- clearTimeout(timeoutHandler);
24428
- return event;
24429
- }
24430
- });
24431
- timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
24432
- }
24433
- }
24434
- /**
24435
- * Determines whether user has asked to ignore this path.
24436
- */
24437
- _isIgnored(path6, stats) {
24438
- if (this.options.atomic && DOT_RE.test(path6))
24439
- return true;
24440
- if (!this._userIgnored) {
24441
- const { cwd } = this.options;
24442
- const ign = this.options.ignored;
24443
- const ignored = (ign || []).map(normalizeIgnored(cwd));
24444
- const ignoredPaths = [...this._ignoredPaths];
24445
- const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
24446
- this._userIgnored = anymatch(list, void 0);
24447
- }
24448
- return this._userIgnored(path6, stats);
24449
- }
24450
- _isntIgnored(path6, stat5) {
24451
- return !this._isIgnored(path6, stat5);
24452
- }
24453
- /**
24454
- * Provides a set of common helpers and properties relating to symlink handling.
24455
- * @param path file or directory pattern being watched
24456
- */
24457
- _getWatchHelpers(path6) {
24458
- return new WatchHelper(path6, this.options.followSymlinks, this);
24459
- }
24460
- // Directory helpers
24461
- // -----------------
24462
- /**
24463
- * Provides directory tracking objects
24464
- * @param directory path of the directory
24465
- */
24466
- _getWatchedDir(directory) {
24467
- const dir = sysPath2.resolve(directory);
24468
- if (!this._watched.has(dir))
24469
- this._watched.set(dir, new DirEntry(dir, this._boundRemove));
24470
- return this._watched.get(dir);
24471
- }
24472
- // File helpers
24473
- // ------------
24474
- /**
24475
- * Check for read permissions: https://stackoverflow.com/a/11781404/1358405
24476
- */
24477
- _hasReadPermissions(stats) {
24478
- if (this.options.ignorePermissionErrors)
24479
- return true;
24480
- return Boolean(Number(stats.mode) & 256);
24481
- }
24482
- /**
24483
- * Handles emitting unlink events for
24484
- * files and directories, and via recursion, for
24485
- * files and directories within directories that are unlinked
24486
- * @param directory within which the following item is located
24487
- * @param item base path of item/directory
24488
- */
24489
- _remove(directory, item, isDirectory) {
24490
- const path6 = sysPath2.join(directory, item);
24491
- const fullPath = sysPath2.resolve(path6);
24492
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path6) || this._watched.has(fullPath);
24493
- if (!this._throttle("remove", path6, 100))
24494
- return;
24495
- if (!isDirectory && this._watched.size === 1) {
24496
- this.add(directory, item, true);
24497
- }
24498
- const wp = this._getWatchedDir(path6);
24499
- const nestedDirectoryChildren = wp.getChildren();
24500
- nestedDirectoryChildren.forEach((nested) => this._remove(path6, nested));
24501
- const parent = this._getWatchedDir(directory);
24502
- const wasTracked = parent.has(item);
24503
- parent.remove(item);
24504
- if (this._symlinkPaths.has(fullPath)) {
24505
- this._symlinkPaths.delete(fullPath);
24506
- }
24507
- let relPath = path6;
24508
- if (this.options.cwd)
24509
- relPath = sysPath2.relative(this.options.cwd, path6);
24510
- if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
24511
- const event = this._pendingWrites.get(relPath).cancelWait();
24512
- if (event === EVENTS.ADD)
24513
- return;
24514
- }
24515
- this._watched.delete(path6);
24516
- this._watched.delete(fullPath);
24517
- const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
24518
- if (wasTracked && !this._isIgnored(path6))
24519
- this._emit(eventName, path6);
24520
- this._closePath(path6);
24521
- }
24522
- /**
24523
- * Closes all watchers for a path
24524
- */
24525
- _closePath(path6) {
24526
- this._closeFile(path6);
24527
- const dir = sysPath2.dirname(path6);
24528
- this._getWatchedDir(dir).remove(sysPath2.basename(path6));
24529
- }
24530
- /**
24531
- * Closes only file-specific watchers
24532
- */
24533
- _closeFile(path6) {
24534
- const closers = this._closers.get(path6);
24535
- if (!closers)
24536
- return;
24537
- closers.forEach((closer) => closer());
24538
- this._closers.delete(path6);
24539
- }
24540
- _addPathCloser(path6, closer) {
24541
- if (!closer)
24542
- return;
24543
- let list = this._closers.get(path6);
24544
- if (!list) {
24545
- list = [];
24546
- this._closers.set(path6, list);
24547
- }
24548
- list.push(closer);
24549
- }
24550
- _readdirp(root, opts) {
24551
- if (this.closed)
24552
- return;
24553
- const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
24554
- let stream = readdirp(root, options);
24555
- this._streams.add(stream);
24556
- stream.once(STR_CLOSE, () => {
24557
- stream = void 0;
24558
- });
24559
- stream.once(STR_END, () => {
24560
- if (stream) {
24561
- this._streams.delete(stream);
24562
- stream = void 0;
24563
- }
24564
- });
24565
- return stream;
24566
- }
24567
- };
24568
- esm_default = { watch, FSWatcher };
24569
- }
24570
- });
24571
-
24572
22866
  // ../memory/src/watcher.ts
24573
- function shouldIgnorePath(watchPath) {
24574
- const normalized = import_node_path4.default.normalize(watchPath);
24575
- const parts = normalized.split(import_node_path4.default.sep).map((s2) => s2.trim().toLowerCase());
24576
- return parts.some((s2) => IGNORED_DIRS.has(s2));
24577
- }
24578
- function createMemoryWatcher(params) {
24579
- const watchPaths = /* @__PURE__ */ new Set([
24580
- import_node_path4.default.join(params.workspaceDir, "MEMORY.md"),
24581
- import_node_path4.default.join(params.workspaceDir, "memory.md"),
24582
- import_node_path4.default.join(params.workspaceDir, "memory", "**", "*.md")
24583
- ]);
24584
- const normalizedExtra = normalizeExtraMemoryPaths(
24585
- params.workspaceDir,
24586
- params.extraPaths
24587
- );
24588
- for (const extra of normalizedExtra) {
24589
- watchPaths.add(extra);
24590
- }
24591
- const watcher = esm_default.watch(Array.from(watchPaths), {
24592
- ignoreInitial: true,
24593
- ignored: (p2) => shouldIgnorePath(String(p2)),
24594
- awaitWriteFinish: {
24595
- stabilityThreshold: params.debounceMs,
24596
- pollInterval: 100
24597
- }
24598
- });
24599
- let debounceTimer = null;
24600
- const markDirty = () => {
24601
- if (debounceTimer) {
24602
- clearTimeout(debounceTimer);
24603
- }
24604
- debounceTimer = setTimeout(() => {
24605
- debounceTimer = null;
24606
- params.onChange();
24607
- }, params.debounceMs);
24608
- };
24609
- watcher.on("add", markDirty);
24610
- watcher.on("change", markDirty);
24611
- watcher.on("unlink", markDirty);
24612
- return watcher;
24613
- }
24614
- async function closeWatcher(watcher) {
24615
- if (!watcher) {
24616
- return;
24617
- }
24618
- await watcher.close();
24619
- }
24620
- function createWatcherHandle(watcher) {
24621
- return {
24622
- close: () => closeWatcher(watcher)
24623
- };
24624
- }
24625
- var import_node_path4, IGNORED_DIRS;
24626
22867
  var init_watcher = __esm({
24627
22868
  "../memory/src/watcher.ts"() {
24628
22869
  "use strict";
24629
- import_node_path4 = __toESM(require("node:path"), 1);
24630
- init_esm4();
24631
22870
  init_internal();
24632
- IGNORED_DIRS = /* @__PURE__ */ new Set([
24633
- ".git",
24634
- "node_modules",
24635
- ".pnpm-store",
24636
- ".venv",
24637
- "venv",
24638
- ".tox",
24639
- "__pycache__"
24640
- ]);
24641
22871
  }
24642
22872
  });
24643
22873
 
24644
22874
  // ../memory/src/conversations.ts
24645
- async function saveConversation(params) {
24646
- const dir = import_node_path5.default.join(params.dir, "conversations", params.userId);
24647
- await import_promises6.default.mkdir(dir, { recursive: true });
24648
- const now = Date.now();
24649
- const entry = {
24650
- id: params.conversationId,
24651
- userId: params.userId,
24652
- conversationId: params.conversationId,
24653
- messages: params.messages,
24654
- createdAt: now,
24655
- updatedAt: now
24656
- };
24657
- const filePath = import_node_path5.default.join(dir, `${params.conversationId}.json`);
24658
- await import_promises6.default.writeFile(filePath, JSON.stringify(entry, null, 2), "utf-8");
24659
- return entry;
24660
- }
24661
- async function loadConversation(params) {
24662
- const filePath = import_node_path5.default.join(
24663
- params.dir,
24664
- "conversations",
24665
- params.userId,
24666
- `${params.conversationId}.json`
24667
- );
24668
- try {
24669
- const content = await import_promises6.default.readFile(filePath, "utf-8");
24670
- const entry = JSON.parse(content);
24671
- return entry;
24672
- } catch {
24673
- return null;
24674
- }
24675
- }
24676
- async function listConversations(params) {
24677
- const baseDir = params.userId ? import_node_path5.default.join(params.dir, "conversations", params.userId) : import_node_path5.default.join(params.dir, "conversations");
24678
- try {
24679
- const entries = await import_promises6.default.readdir(baseDir, { withFileTypes: true });
24680
- const conversations = [];
24681
- for (const entry of entries) {
24682
- if (!entry.isDirectory()) {
24683
- continue;
24684
- }
24685
- const userDir = import_node_path5.default.join(baseDir, entry.name);
24686
- const files = await import_promises6.default.readdir(userDir);
24687
- for (const file2 of files) {
24688
- if (!file2.endsWith(".json")) {
24689
- continue;
24690
- }
24691
- try {
24692
- const content = await import_promises6.default.readFile(import_node_path5.default.join(userDir, file2), "utf-8");
24693
- const conv = JSON.parse(content);
24694
- conversations.push(conv);
24695
- } catch {
24696
- }
24697
- }
24698
- }
24699
- return conversations.sort((a2, b2) => b2.updatedAt - a2.updatedAt);
24700
- } catch {
24701
- return [];
24702
- }
24703
- }
24704
- function normalizeConversationText(content) {
24705
- if (typeof content === "string") {
24706
- const normalized = content.replace(/\s*\n+\s*/g, " ").replace(/\s+/g, " ").trim();
24707
- return normalized || null;
24708
- }
24709
- if (!Array.isArray(content)) {
24710
- return null;
24711
- }
24712
- const parts = [];
24713
- for (const block of content) {
24714
- if (!block || typeof block !== "object") {
24715
- continue;
24716
- }
24717
- const record2 = block;
24718
- if (record2.type !== "text" || typeof record2.text !== "string") {
24719
- continue;
24720
- }
24721
- const normalized = record2.text.replace(/\s*\n+\s*/g, " ").replace(/\s+/g, " ").trim();
24722
- if (normalized) {
24723
- parts.push(normalized);
24724
- }
24725
- }
24726
- if (parts.length === 0) {
24727
- return null;
24728
- }
24729
- return parts.join(" ");
24730
- }
24731
- function extractConversationContent(messages) {
24732
- const collected = [];
24733
- for (const msg of messages) {
24734
- const normalized = normalizeConversationText(msg.content);
24735
- if (!normalized) {
24736
- continue;
24737
- }
24738
- const label = msg.role === "user" ? "User" : "Assistant";
24739
- collected.push(`${label}: ${normalized}`);
24740
- }
24741
- return collected.join("\n");
24742
- }
24743
- function conversationToMemoryChunks(params) {
24744
- const content = extractConversationContent(params.entry.messages);
24745
- const lines = content.split("\n");
24746
- if (lines.length === 0) {
24747
- return [];
24748
- }
24749
- const maxChars = Math.max(32, params.chunking.tokens * 4);
24750
- const chunks = [];
24751
- let currentLines = [];
24752
- let startMsg = 0;
24753
- const flush = () => {
24754
- if (currentLines.length === 0) {
24755
- return;
24756
- }
24757
- const text = currentLines.join("\n");
24758
- chunks.push({
24759
- text,
24760
- hash: hashText(text),
24761
- startMessage: startMsg,
24762
- endMessage: startMsg + currentLines.length - 1
24763
- });
24764
- currentLines = [];
24765
- };
24766
- for (let i2 = 0; i2 < lines.length; i2++) {
24767
- const line = lines[i2];
24768
- const lineSize = line.length + 1;
24769
- if (currentLines.length > 0 && currentLines.join("\n").length + lineSize > maxChars) {
24770
- flush();
24771
- startMsg = i2;
24772
- }
24773
- currentLines.push(line);
24774
- }
24775
- flush();
24776
- return chunks;
24777
- }
24778
- function buildConversationEntry(absPath) {
24779
- try {
24780
- const raw = import_node_fs3.default.readFileSync(absPath, "utf-8");
24781
- const entry = JSON.parse(raw);
24782
- return entry;
24783
- } catch {
24784
- return null;
24785
- }
24786
- }
24787
- function conversationPathForFile(absPath, baseDir) {
24788
- return import_node_path5.default.relative(baseDir, absPath).replace(/\\/g, "/");
24789
- }
24790
- async function listConversationFiles(dir, userId) {
24791
- const baseDir = userId ? import_node_path5.default.join(dir, "conversations", userId) : import_node_path5.default.join(dir, "conversations");
24792
- const result = [];
24793
- async function walk(dirPath) {
24794
- try {
24795
- const entries = await import_promises6.default.readdir(dirPath, { withFileTypes: true });
24796
- for (const entry of entries) {
24797
- const full = import_node_path5.default.join(dirPath, entry.name);
24798
- if (entry.isDirectory()) {
24799
- await walk(full);
24800
- } else if (entry.isFile() && entry.name.endsWith(".json")) {
24801
- result.push(full);
24802
- }
24803
- }
24804
- } catch {
24805
- }
24806
- }
24807
- try {
24808
- await walk(baseDir);
24809
- } catch {
24810
- }
24811
- return result;
24812
- }
24813
- var import_node_fs3, import_promises6, import_node_path5;
24814
22875
  var init_conversations = __esm({
24815
22876
  "../memory/src/conversations.ts"() {
24816
22877
  "use strict";
24817
- import_node_fs3 = __toESM(require("node:fs"), 1);
24818
- import_promises6 = __toESM(require("node:fs/promises"), 1);
24819
- import_node_path5 = __toESM(require("node:path"), 1);
24820
22878
  init_internal();
24821
22879
  }
24822
22880
  });
@@ -24826,13 +22884,13 @@ function clamp(value, min, max) {
24826
22884
  return Math.max(min, Math.min(max, value));
24827
22885
  }
24828
22886
  function resolveStorePath(agentId, raw) {
24829
- const stateDir = import_node_path6.default.join(import_node_os2.default.homedir(), ".hybrid", "memory");
24830
- const fallback = import_node_path6.default.join(stateDir, `${agentId}.sqlite`);
22887
+ const stateDir = import_node_path3.default.join(import_node_os2.default.homedir(), ".hybrid", "memory");
22888
+ const fallback = import_node_path3.default.join(stateDir, `${agentId}.sqlite`);
24831
22889
  if (!raw) {
24832
22890
  return fallback;
24833
22891
  }
24834
22892
  const withToken = raw.includes("{agentId}") ? raw.replaceAll("{agentId}", agentId) : raw;
24835
- return withToken.startsWith("~") ? import_node_path6.default.join(import_node_os2.default.homedir(), withToken.slice(1)) : import_node_path6.default.isAbsolute(withToken) ? withToken : import_node_path6.default.resolve(withToken);
22893
+ return withToken.startsWith("~") ? import_node_path3.default.join(import_node_os2.default.homedir(), withToken.slice(1)) : import_node_path3.default.isAbsolute(withToken) ? withToken : import_node_path3.default.resolve(withToken);
24836
22894
  }
24837
22895
  function resolveMemoryConfig(input, agentId) {
24838
22896
  const enabled = input.enabled ?? true;
@@ -24944,15 +23002,12 @@ function resolveMemoryConfig(input, agentId) {
24944
23002
  cache
24945
23003
  };
24946
23004
  }
24947
- function getDefaultMemoryConfig() {
24948
- return resolveMemoryConfig({}, "default");
24949
- }
24950
- var import_node_os2, import_node_path6, DEFAULT_CHUNK_TOKENS, DEFAULT_CHUNK_OVERLAP, DEFAULT_WATCH_DEBOUNCE_MS, DEFAULT_MAX_RESULTS, DEFAULT_MIN_SCORE, DEFAULT_HYBRID_ENABLED, DEFAULT_HYBRID_VECTOR_WEIGHT, DEFAULT_HYBRID_TEXT_WEIGHT, DEFAULT_CACHE_ENABLED;
23005
+ var import_node_os2, import_node_path3, DEFAULT_CHUNK_TOKENS, DEFAULT_CHUNK_OVERLAP, DEFAULT_WATCH_DEBOUNCE_MS, DEFAULT_MAX_RESULTS, DEFAULT_MIN_SCORE, DEFAULT_HYBRID_ENABLED, DEFAULT_HYBRID_VECTOR_WEIGHT, DEFAULT_HYBRID_TEXT_WEIGHT, DEFAULT_CACHE_ENABLED;
24951
23006
  var init_config = __esm({
24952
23007
  "../memory/src/config.ts"() {
24953
23008
  "use strict";
24954
23009
  import_node_os2 = __toESM(require("node:os"), 1);
24955
- import_node_path6 = __toESM(require("node:path"), 1);
23010
+ import_node_path3 = __toESM(require("node:path"), 1);
24956
23011
  DEFAULT_CHUNK_TOKENS = 400;
24957
23012
  DEFAULT_CHUNK_OVERLAP = 80;
24958
23013
  DEFAULT_WATCH_DEBOUNCE_MS = 1500;
@@ -24967,16 +23022,10 @@ var init_config = __esm({
24967
23022
 
24968
23023
  // ../memory/src/paths.ts
24969
23024
  function getCredentialsPath(workspaceDir) {
24970
- return (0, import_node_path7.join)(workspaceDir, "credentials");
24971
- }
24972
- function getProjectHash(workspaceDir) {
24973
- return (0, import_node_crypto2.createHash)("sha256").update(workspaceDir).digest("hex").slice(0, 16);
23025
+ return (0, import_node_path4.join)(workspaceDir, "credentials");
24974
23026
  }
24975
23027
  function getMemoryRoot(workspaceDir) {
24976
- return (0, import_node_path7.join)(workspaceDir, "memory");
24977
- }
24978
- function getSharedMemoryPath(workspaceDir) {
24979
- return getMemoryRoot(workspaceDir);
23028
+ return (0, import_node_path4.join)(workspaceDir, "memory");
24980
23029
  }
24981
23030
  function sanitizeUserId(userId) {
24982
23031
  const sanitized = userId.replace(/[\/\\]/g, "_").replace(/\.\./g, "_").trim();
@@ -24987,39 +23036,36 @@ function sanitizeUserId(userId) {
24987
23036
  }
24988
23037
  function getUserMemoryPath(workspaceDir, userId) {
24989
23038
  const memoryRoot = getMemoryRoot(workspaceDir);
24990
- const usersDir = (0, import_node_path7.join)(memoryRoot, "users");
24991
- const result = (0, import_node_path7.join)(usersDir, sanitizeUserId(userId));
24992
- const resolved = (0, import_node_path7.resolve)(result);
24993
- const resolvedUsersDir = (0, import_node_path7.resolve)(usersDir);
23039
+ const usersDir = (0, import_node_path4.join)(memoryRoot, "users");
23040
+ const result = (0, import_node_path4.join)(usersDir, sanitizeUserId(userId));
23041
+ const resolved = (0, import_node_path4.resolve)(result);
23042
+ const resolvedUsersDir = (0, import_node_path4.resolve)(usersDir);
24994
23043
  if (!resolved.startsWith(resolvedUsersDir + "/") && resolved !== resolvedUsersDir) {
24995
23044
  throw new Error("Invalid userId: path traversal detected");
24996
23045
  }
24997
23046
  return result;
24998
23047
  }
24999
- function getProjectMemoryPath(workspaceDir) {
25000
- return (0, import_node_path7.join)(workspaceDir, "memory");
25001
- }
25002
23048
  function getParaRoot(workspaceDir) {
25003
- return (0, import_node_path7.join)(getMemoryRoot(workspaceDir), "life");
23049
+ return (0, import_node_path4.join)(getMemoryRoot(workspaceDir), "life");
25004
23050
  }
25005
23051
  function getProjectsPath(workspaceDir) {
25006
- return (0, import_node_path7.join)(getParaRoot(workspaceDir), "projects");
23052
+ return (0, import_node_path4.join)(getParaRoot(workspaceDir), "projects");
25007
23053
  }
25008
23054
  function getAreasPath(workspaceDir) {
25009
- return (0, import_node_path7.join)(getParaRoot(workspaceDir), "areas");
23055
+ return (0, import_node_path4.join)(getParaRoot(workspaceDir), "areas");
25010
23056
  }
25011
23057
  function getResourcesPath(workspaceDir) {
25012
- return (0, import_node_path7.join)(getParaRoot(workspaceDir), "resources");
23058
+ return (0, import_node_path4.join)(getParaRoot(workspaceDir), "resources");
25013
23059
  }
25014
23060
  function getArchivesPath(workspaceDir) {
25015
- return (0, import_node_path7.join)(getParaRoot(workspaceDir), "archives");
23061
+ return (0, import_node_path4.join)(getParaRoot(workspaceDir), "archives");
25016
23062
  }
25017
23063
  function getLogsPath(workspaceDir) {
25018
- return (0, import_node_path7.join)(getMemoryRoot(workspaceDir), "logs");
23064
+ return (0, import_node_path4.join)(getMemoryRoot(workspaceDir), "logs");
25019
23065
  }
25020
23066
  function getDailyLogPath(workspaceDir, date5) {
25021
23067
  const logDate = date5 || (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
25022
- return (0, import_node_path7.join)(getLogsPath(workspaceDir), `${logDate}.md`);
23068
+ return (0, import_node_path4.join)(getLogsPath(workspaceDir), `${logDate}.md`);
25023
23069
  }
25024
23070
  function getMemoryPaths(workspaceDir, userId, role) {
25025
23071
  const userPath = getUserMemoryPath(workspaceDir, userId);
@@ -25034,30 +23080,29 @@ function getMemoryPaths(workspaceDir, userId, role) {
25034
23080
  write: userPath
25035
23081
  };
25036
23082
  }
25037
- var import_node_crypto2, import_node_path7;
23083
+ var import_node_path4;
25038
23084
  var init_paths = __esm({
25039
23085
  "../memory/src/paths.ts"() {
25040
23086
  "use strict";
25041
- import_node_crypto2 = require("node:crypto");
25042
- import_node_path7 = require("node:path");
23087
+ import_node_path4 = require("node:path");
25043
23088
  }
25044
23089
  });
25045
23090
 
25046
23091
  // ../memory/src/auto-memory.ts
25047
23092
  function ensureDir2(dir) {
25048
- if (!(0, import_node_fs4.existsSync)(dir)) {
25049
- (0, import_node_fs4.mkdirSync)(dir, { recursive: true });
23093
+ if (!(0, import_node_fs3.existsSync)(dir)) {
23094
+ (0, import_node_fs3.mkdirSync)(dir, { recursive: true });
25050
23095
  }
25051
23096
  }
25052
23097
  async function appendToMemory(workspaceDir, entry, userId, role) {
25053
23098
  const paths = getMemoryPaths(workspaceDir, userId, role);
25054
23099
  const memoryDir = paths.write;
25055
- const memoryPath = (0, import_node_path8.join)(memoryDir, "MEMORY.md");
23100
+ const memoryPath = (0, import_node_path5.join)(memoryDir, "MEMORY.md");
25056
23101
  ensureDir2(memoryDir);
25057
- if (!(0, import_node_fs4.existsSync)(memoryPath)) {
25058
- await (0, import_promises7.writeFile)(memoryPath, DEFAULT_TEMPLATE, "utf-8");
23102
+ if (!(0, import_node_fs3.existsSync)(memoryPath)) {
23103
+ await (0, import_promises3.writeFile)(memoryPath, DEFAULT_TEMPLATE, "utf-8");
25059
23104
  }
25060
- const content = await (0, import_promises7.readFile)(memoryPath, "utf-8");
23105
+ const content = await (0, import_promises3.readFile)(memoryPath, "utf-8");
25061
23106
  const categoryHeader = CATEGORY_HEADERS[entry.category];
25062
23107
  const timestamp = entry.timestamp || (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
25063
23108
  const line = `- ${entry.content} (${timestamp})`;
@@ -25068,7 +23113,7 @@ ${categoryHeader}
25068
23113
 
25069
23114
  ${line}
25070
23115
  `;
25071
- await (0, import_promises7.writeFile)(memoryPath, updatedContent, "utf-8");
23116
+ await (0, import_promises3.writeFile)(memoryPath, updatedContent, "utf-8");
25072
23117
  return { success: true, message: `Added to new section: ${entry.category}` };
25073
23118
  }
25074
23119
  const lines = content.split("\n");
@@ -25106,7 +23151,7 @@ ${afterInsertContent}`;
25106
23151
  ${line}
25107
23152
  ${afterInsertContent}`;
25108
23153
  }
25109
- await (0, import_promises7.writeFile)(memoryPath, newContent, "utf-8");
23154
+ await (0, import_promises3.writeFile)(memoryPath, newContent, "utf-8");
25110
23155
  return { success: true, message: `Added to ${entry.category}` };
25111
23156
  }
25112
23157
  async function readMemorySection(workspaceDir, category, userId, role) {
@@ -25114,11 +23159,11 @@ async function readMemorySection(workspaceDir, category, userId, role) {
25114
23159
  const allEntries = [];
25115
23160
  const seen = /* @__PURE__ */ new Set();
25116
23161
  for (const memoryDir of paths.read) {
25117
- const memoryPath = (0, import_node_path8.join)(memoryDir, "MEMORY.md");
25118
- if (!(0, import_node_fs4.existsSync)(memoryPath)) {
23162
+ const memoryPath = (0, import_node_path5.join)(memoryDir, "MEMORY.md");
23163
+ if (!(0, import_node_fs3.existsSync)(memoryPath)) {
25119
23164
  continue;
25120
23165
  }
25121
- const content = await (0, import_promises7.readFile)(memoryPath, "utf-8");
23166
+ const content = await (0, import_promises3.readFile)(memoryPath, "utf-8");
25122
23167
  const categoryHeader = CATEGORY_HEADERS[category];
25123
23168
  const lines = content.split("\n");
25124
23169
  let inTargetSection = false;
@@ -25141,40 +23186,13 @@ async function readMemorySection(workspaceDir, category, userId, role) {
25141
23186
  }
25142
23187
  return allEntries;
25143
23188
  }
25144
- async function clearMemorySection(workspaceDir, category, userId, role) {
25145
- const paths = getMemoryPaths(workspaceDir, userId, role);
25146
- const memoryDir = paths.write;
25147
- const memoryPath = (0, import_node_path8.join)(memoryDir, "MEMORY.md");
25148
- if (!(0, import_node_fs4.existsSync)(memoryPath)) {
25149
- return;
25150
- }
25151
- const content = await (0, import_promises7.readFile)(memoryPath, "utf-8");
25152
- const categoryHeader = CATEGORY_HEADERS[category];
25153
- const lines = content.split("\n");
25154
- const newLines = [];
25155
- let inTargetSection = false;
25156
- for (const line of lines) {
25157
- if (line.trim() === categoryHeader) {
25158
- inTargetSection = true;
25159
- newLines.push(line);
25160
- continue;
25161
- }
25162
- if (inTargetSection && line.startsWith("## ")) {
25163
- inTargetSection = false;
25164
- }
25165
- if (!inTargetSection || !line.startsWith("- ")) {
25166
- newLines.push(line);
25167
- }
25168
- }
25169
- await (0, import_promises7.writeFile)(memoryPath, newLines.join("\n"), "utf-8");
25170
- }
25171
- var import_node_fs4, import_promises7, import_node_path8, CATEGORY_HEADERS, DEFAULT_TEMPLATE;
23189
+ var import_node_fs3, import_promises3, import_node_path5, CATEGORY_HEADERS, DEFAULT_TEMPLATE;
25172
23190
  var init_auto_memory = __esm({
25173
23191
  "../memory/src/auto-memory.ts"() {
25174
23192
  "use strict";
25175
- import_node_fs4 = require("node:fs");
25176
- import_promises7 = require("node:fs/promises");
25177
- import_node_path8 = require("node:path");
23193
+ import_node_fs3 = require("node:fs");
23194
+ import_promises3 = require("node:fs/promises");
23195
+ import_node_path5 = require("node:path");
25178
23196
  init_paths();
25179
23197
  CATEGORY_HEADERS = {
25180
23198
  preferences: "## User Preferences",
@@ -25207,14 +23225,6 @@ function isValidWalletAddress(address) {
25207
23225
  function normalizeWalletAddress(address) {
25208
23226
  return address.toLowerCase();
25209
23227
  }
25210
- function validateWalletAddress(address) {
25211
- if (!isValidWalletAddress(address)) {
25212
- throw new Error(
25213
- `Invalid wallet address: ${address}. Must be 0x followed by 40 hex characters.`
25214
- );
25215
- }
25216
- return normalizeWalletAddress(address);
25217
- }
25218
23228
  var WALLET_REGEX;
25219
23229
  var init_validate = __esm({
25220
23230
  "../memory/src/validate.ts"() {
@@ -25225,15 +23235,15 @@ var init_validate = __esm({
25225
23235
 
25226
23236
  // ../memory/src/acl.ts
25227
23237
  function getAllowFromPath(workspaceDir) {
25228
- return (0, import_node_path9.join)(getCredentialsPath(workspaceDir), `${CHANNEL}-allowFrom.json`);
23238
+ return (0, import_node_path6.join)(getCredentialsPath(workspaceDir), `${CHANNEL}-allowFrom.json`);
25229
23239
  }
25230
23240
  function getPairingPath(workspaceDir) {
25231
- return (0, import_node_path9.join)(getCredentialsPath(workspaceDir), `${CHANNEL}-pairing.json`);
23241
+ return (0, import_node_path6.join)(getCredentialsPath(workspaceDir), `${CHANNEL}-pairing.json`);
25232
23242
  }
25233
23243
  function randomCode() {
25234
23244
  let out = "";
25235
23245
  for (let i2 = 0; i2 < PAIRING_CODE_LENGTH; i2++) {
25236
- const idx = (0, import_node_crypto3.randomInt)(0, PAIRING_CODE_ALPHABET.length);
23246
+ const idx = (0, import_node_crypto2.randomInt)(0, PAIRING_CODE_ALPHABET.length);
25237
23247
  out += PAIRING_CODE_ALPHABET[idx];
25238
23248
  }
25239
23249
  return out;
@@ -25307,13 +23317,13 @@ function pruneExcessRequests(reqs, maxPending) {
25307
23317
  return { requests: sorted.slice(-maxPending), removed: true };
25308
23318
  }
25309
23319
  async function ensureDir3(dir) {
25310
- if (!(0, import_node_fs5.existsSync)(dir)) {
25311
- (0, import_node_fs5.mkdirSync)(dir, { recursive: true });
23320
+ if (!(0, import_node_fs4.existsSync)(dir)) {
23321
+ (0, import_node_fs4.mkdirSync)(dir, { recursive: true });
25312
23322
  }
25313
23323
  }
25314
23324
  async function readJsonFile(filePath, fallback) {
25315
23325
  try {
25316
- const raw = await (0, import_promises8.readFile)(filePath, "utf-8");
23326
+ const raw = await (0, import_promises4.readFile)(filePath, "utf-8");
25317
23327
  const parsed = JSON.parse(raw);
25318
23328
  return { value: parsed, exists: true };
25319
23329
  } catch (err) {
@@ -25326,16 +23336,16 @@ async function readJsonFile(filePath, fallback) {
25326
23336
  }
25327
23337
  async function writeJsonFileAtomic(filePath, value) {
25328
23338
  const tempPath = `${filePath}.tmp`;
25329
- await (0, import_promises8.writeFile)(tempPath, JSON.stringify(value, null, 2), "utf-8");
25330
- await import("node:fs/promises").then((fs5) => fs5.rename(tempPath, filePath));
23339
+ await (0, import_promises4.writeFile)(tempPath, JSON.stringify(value, null, 2), "utf-8");
23340
+ await import("node:fs/promises").then((fs4) => fs4.rename(tempPath, filePath));
25331
23341
  }
25332
23342
  function parseACL(workspaceDir) {
25333
23343
  const aclPath = getAllowFromPath(workspaceDir);
25334
- if (!(0, import_node_fs5.existsSync)(aclPath)) {
23344
+ if (!(0, import_node_fs4.existsSync)(aclPath)) {
25335
23345
  return null;
25336
23346
  }
25337
23347
  try {
25338
- const content = (0, import_node_fs5.readFileSync)(aclPath, "utf-8");
23348
+ const content = (0, import_node_fs4.readFileSync)(aclPath, "utf-8");
25339
23349
  const parsed = JSON.parse(content);
25340
23350
  if (parsed.version !== 1 || !Array.isArray(parsed.allowFrom)) {
25341
23351
  return null;
@@ -25416,7 +23426,7 @@ async function removeACLAllowFromEntry(workspaceDir, entry) {
25416
23426
  }
25417
23427
  async function listACLPendingRequests(workspaceDir) {
25418
23428
  const filePath = getPairingPath(workspaceDir);
25419
- if (!(0, import_node_fs5.existsSync)(filePath)) {
23429
+ if (!(0, import_node_fs4.existsSync)(filePath)) {
25420
23430
  return [];
25421
23431
  }
25422
23432
  const { value } = await readJsonFile(filePath, {
@@ -25581,14 +23591,14 @@ async function removeOwner(workspaceDir, userId) {
25581
23591
  return { success: false, message: String(err) };
25582
23592
  }
25583
23593
  }
25584
- var import_node_crypto3, import_node_fs5, import_promises8, import_node_path9, CHANNEL, PAIRING_CODE_LENGTH, PAIRING_CODE_ALPHABET, PAIRING_PENDING_TTL_MS, PAIRING_PENDING_MAX;
23594
+ var import_node_crypto2, import_node_fs4, import_promises4, import_node_path6, CHANNEL, PAIRING_CODE_LENGTH, PAIRING_CODE_ALPHABET, PAIRING_PENDING_TTL_MS, PAIRING_PENDING_MAX;
25585
23595
  var init_acl = __esm({
25586
23596
  "../memory/src/acl.ts"() {
25587
23597
  "use strict";
25588
- import_node_crypto3 = require("node:crypto");
25589
- import_node_fs5 = require("node:fs");
25590
- import_promises8 = require("node:fs/promises");
25591
- import_node_path9 = require("node:path");
23598
+ import_node_crypto2 = require("node:crypto");
23599
+ import_node_fs4 = require("node:fs");
23600
+ import_promises4 = require("node:fs/promises");
23601
+ import_node_path6 = require("node:path");
25592
23602
  init_paths();
25593
23603
  init_validate();
25594
23604
  CHANNEL = "xmtp";
@@ -25601,8 +23611,8 @@ var init_acl = __esm({
25601
23611
 
25602
23612
  // ../memory/src/para.ts
25603
23613
  function ensureDir4(dir) {
25604
- if (!(0, import_node_fs6.existsSync)(dir)) {
25605
- (0, import_node_fs6.mkdirSync)(dir, { recursive: true });
23614
+ if (!(0, import_node_fs5.existsSync)(dir)) {
23615
+ (0, import_node_fs5.mkdirSync)(dir, { recursive: true });
25606
23616
  }
25607
23617
  }
25608
23618
  function getBucketPath(workspaceDir, bucket) {
@@ -25622,8 +23632,8 @@ function generateId() {
25622
23632
  }
25623
23633
  async function createEntity(workspaceDir, name, bucket, category) {
25624
23634
  const bucketPath = getBucketPath(workspaceDir, bucket);
25625
- const entityPath = category ? (0, import_node_path10.join)(bucketPath, category, name) : (0, import_node_path10.join)(bucketPath, name);
25626
- if ((0, import_node_fs6.existsSync)(entityPath)) {
23635
+ const entityPath = category ? (0, import_node_path7.join)(bucketPath, category, name) : (0, import_node_path7.join)(bucketPath, name);
23636
+ if ((0, import_node_fs5.existsSync)(entityPath)) {
25627
23637
  return {
25628
23638
  success: false,
25629
23639
  message: `Entity already exists: ${name}`,
@@ -25641,13 +23651,13 @@ async function createEntity(workspaceDir, name, bucket, category) {
25641
23651
  updatedAt: now,
25642
23652
  items: []
25643
23653
  };
25644
- await (0, import_promises9.writeFile)(
25645
- (0, import_node_path10.join)(entityPath, "items.json"),
23654
+ await (0, import_promises5.writeFile)(
23655
+ (0, import_node_path7.join)(entityPath, "items.json"),
25646
23656
  JSON.stringify(itemsFile, null, 2),
25647
23657
  "utf-8"
25648
23658
  );
25649
- await (0, import_promises9.writeFile)(
25650
- (0, import_node_path10.join)(entityPath, "summary.md"),
23659
+ await (0, import_promises5.writeFile)(
23660
+ (0, import_node_path7.join)(entityPath, "summary.md"),
25651
23661
  `# ${name}
25652
23662
 
25653
23663
  *No active facts yet.*
@@ -25657,11 +23667,11 @@ async function createEntity(workspaceDir, name, bucket, category) {
25657
23667
  return { success: true, message: `Created entity: ${name}`, path: entityPath };
25658
23668
  }
25659
23669
  async function addFact(workspaceDir, entityPath, fact, category, relatedEntities = []) {
25660
- const itemsPath = (0, import_node_path10.join)(entityPath, "items.json");
25661
- if (!(0, import_node_fs6.existsSync)(itemsPath)) {
23670
+ const itemsPath = (0, import_node_path7.join)(entityPath, "items.json");
23671
+ if (!(0, import_node_fs5.existsSync)(itemsPath)) {
25662
23672
  return { success: false, message: "Entity not found", factId: "" };
25663
23673
  }
25664
- const content = await (0, import_promises9.readFile)(itemsPath, "utf-8");
23674
+ const content = await (0, import_promises5.readFile)(itemsPath, "utf-8");
25665
23675
  const itemsFile = JSON.parse(content);
25666
23676
  const now = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
25667
23677
  const newFact = {
@@ -25677,50 +23687,9 @@ async function addFact(workspaceDir, entityPath, fact, category, relatedEntities
25677
23687
  };
25678
23688
  itemsFile.items.push(newFact);
25679
23689
  itemsFile.updatedAt = now;
25680
- await (0, import_promises9.writeFile)(itemsPath, JSON.stringify(itemsFile, null, 2), "utf-8");
23690
+ await (0, import_promises5.writeFile)(itemsPath, JSON.stringify(itemsFile, null, 2), "utf-8");
25681
23691
  return { success: true, message: `Added fact to entity`, factId: newFact.id };
25682
23692
  }
25683
- async function supersedeFact(workspaceDir, entityPath, factId, newFact) {
25684
- const itemsPath = (0, import_node_path10.join)(entityPath, "items.json");
25685
- if (!(0, import_node_fs6.existsSync)(itemsPath)) {
25686
- return { success: false, message: "Entity not found" };
25687
- }
25688
- const content = await (0, import_promises9.readFile)(itemsPath, "utf-8");
25689
- const itemsFile = JSON.parse(content);
25690
- const oldFactIndex = itemsFile.items.findIndex((f2) => f2.id === factId);
25691
- if (oldFactIndex === -1) {
25692
- return { success: false, message: "Fact not found" };
25693
- }
25694
- const now = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
25695
- const newFactRecord = {
25696
- id: generateId(),
25697
- fact: newFact,
25698
- category: itemsFile.items[oldFactIndex].category,
25699
- timestamp: now,
25700
- source: now,
25701
- status: "active",
25702
- relatedEntities: itemsFile.items[oldFactIndex].relatedEntities,
25703
- lastAccessed: now,
25704
- accessCount: 0
25705
- };
25706
- itemsFile.items[oldFactIndex].status = "superseded";
25707
- itemsFile.items[oldFactIndex].supersededBy = newFactRecord.id;
25708
- itemsFile.items.push(newFactRecord);
25709
- itemsFile.updatedAt = now;
25710
- await (0, import_promises9.writeFile)(itemsPath, JSON.stringify(itemsFile, null, 2), "utf-8");
25711
- return { success: true, message: "Fact superseded" };
25712
- }
25713
- async function accessFact(entityPath, factId) {
25714
- const itemsPath = (0, import_node_path10.join)(entityPath, "items.json");
25715
- if (!(0, import_node_fs6.existsSync)(itemsPath)) return;
25716
- const content = await (0, import_promises9.readFile)(itemsPath, "utf-8");
25717
- const itemsFile = JSON.parse(content);
25718
- const fact = itemsFile.items.find((f2) => f2.id === factId);
25719
- if (!fact) return;
25720
- fact.lastAccessed = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
25721
- fact.accessCount += 1;
25722
- await (0, import_promises9.writeFile)(itemsPath, JSON.stringify(itemsFile, null, 2), "utf-8");
25723
- }
25724
23693
  function computeDecayTier(fact, now = /* @__PURE__ */ new Date()) {
25725
23694
  const lastAccessed = new Date(fact.lastAccessed);
25726
23695
  const daysSinceAccess = Math.floor(
@@ -25740,87 +23709,20 @@ function computeDecayTier(fact, now = /* @__PURE__ */ new Date()) {
25740
23709
  }
25741
23710
  return "cold";
25742
23711
  }
25743
- async function generateSummary(entityPath, entityName) {
25744
- const itemsPath = (0, import_node_path10.join)(entityPath, "items.json");
25745
- if (!(0, import_node_fs6.existsSync)(itemsPath)) {
25746
- return `# ${entityName}
25747
-
25748
- *No facts recorded.*
25749
- `;
25750
- }
25751
- const content = await (0, import_promises9.readFile)(itemsPath, "utf-8");
25752
- const itemsFile = JSON.parse(content);
25753
- const activeFacts = itemsFile.items.filter((f2) => f2.status === "active");
25754
- const hotFacts = [];
25755
- const warmFacts = [];
25756
- for (const fact of activeFacts) {
25757
- const tier = computeDecayTier(fact);
25758
- if (tier === "hot") hotFacts.push(fact);
25759
- else if (tier === "warm") warmFacts.push(fact);
25760
- }
25761
- hotFacts.sort((a2, b2) => b2.accessCount - a2.accessCount);
25762
- warmFacts.sort((a2, b2) => b2.accessCount - a2.accessCount);
25763
- let summary = `# ${entityName}
25764
-
25765
- `;
25766
- if (hotFacts.length > 0) {
25767
- summary += `## Current
25768
-
25769
- `;
25770
- for (const fact of hotFacts) {
25771
- summary += `- ${fact.fact}
25772
- `;
25773
- }
25774
- summary += "\n";
25775
- }
25776
- if (warmFacts.length > 0) {
25777
- summary += `## Background
25778
-
25779
- `;
25780
- for (const fact of warmFacts) {
25781
- summary += `- ${fact.fact}
25782
- `;
25783
- }
25784
- summary += "\n";
25785
- }
25786
- if (hotFacts.length === 0 && warmFacts.length === 0) {
25787
- summary += `*No active facts in current context.*
25788
- `;
25789
- }
25790
- return summary;
25791
- }
25792
- async function rewriteSummaries(workspaceDir) {
25793
- const paraRoot = getParaRoot(workspaceDir);
25794
- let count = 0;
25795
- const buckets = ["projects", "areas", "resources", "archives"];
25796
- for (const bucket of buckets) {
25797
- const bucketPath = getBucketPath(workspaceDir, bucket);
25798
- if (!(0, import_node_fs6.existsSync)(bucketPath)) continue;
25799
- const entries = await (0, import_promises9.readdir)(bucketPath, { withFileTypes: true });
25800
- for (const entry of entries) {
25801
- if (!entry.isDirectory()) continue;
25802
- const entityPath = (0, import_node_path10.join)(bucketPath, entry.name);
25803
- const summary = await generateSummary(entityPath, entry.name);
25804
- await (0, import_promises9.writeFile)((0, import_node_path10.join)(entityPath, "summary.md"), summary, "utf-8");
25805
- count++;
25806
- }
25807
- }
25808
- return { count };
25809
- }
25810
23712
  async function searchFacts(workspaceDir, query2, options) {
25811
23713
  const results = [];
25812
23714
  const buckets = options?.bucket ? [options.bucket] : ["projects", "areas", "resources", "archives"];
25813
23715
  const queryLower = query2.toLowerCase();
25814
23716
  for (const bucket of buckets) {
25815
23717
  const bucketPath = getBucketPath(workspaceDir, bucket);
25816
- if (!(0, import_node_fs6.existsSync)(bucketPath)) continue;
25817
- const entries = await (0, import_promises9.readdir)(bucketPath, { withFileTypes: true });
23718
+ if (!(0, import_node_fs5.existsSync)(bucketPath)) continue;
23719
+ const entries = await (0, import_promises5.readdir)(bucketPath, { withFileTypes: true });
25818
23720
  for (const entry of entries) {
25819
23721
  if (!entry.isDirectory()) continue;
25820
- const entityPath = (0, import_node_path10.join)(bucketPath, entry.name);
25821
- const itemsPath = (0, import_node_path10.join)(entityPath, "items.json");
25822
- if (!(0, import_node_fs6.existsSync)(itemsPath)) continue;
25823
- const content = await (0, import_promises9.readFile)(itemsPath, "utf-8");
23722
+ const entityPath = (0, import_node_path7.join)(bucketPath, entry.name);
23723
+ const itemsPath = (0, import_node_path7.join)(entityPath, "items.json");
23724
+ if (!(0, import_node_fs5.existsSync)(itemsPath)) continue;
23725
+ const content = await (0, import_promises5.readFile)(itemsPath, "utf-8");
25824
23726
  const itemsFile = JSON.parse(content);
25825
23727
  for (const fact of itemsFile.items) {
25826
23728
  if (fact.status !== "active") continue;
@@ -25838,21 +23740,21 @@ async function searchFacts(workspaceDir, query2, options) {
25838
23740
  }
25839
23741
  return results;
25840
23742
  }
25841
- var import_node_fs6, import_promises9, import_node_path10;
23743
+ var import_node_fs5, import_promises5, import_node_path7;
25842
23744
  var init_para = __esm({
25843
23745
  "../memory/src/para.ts"() {
25844
23746
  "use strict";
25845
- import_node_fs6 = require("node:fs");
25846
- import_promises9 = require("node:fs/promises");
25847
- import_node_path10 = require("node:path");
23747
+ import_node_fs5 = require("node:fs");
23748
+ import_promises5 = require("node:fs/promises");
23749
+ import_node_path7 = require("node:path");
25848
23750
  init_paths();
25849
23751
  }
25850
23752
  });
25851
23753
 
25852
23754
  // ../memory/src/daily-log.ts
25853
23755
  function ensureDir5(dir) {
25854
- if (!(0, import_node_fs7.existsSync)(dir)) {
25855
- (0, import_node_fs7.mkdirSync)(dir, { recursive: true });
23756
+ if (!(0, import_node_fs6.existsSync)(dir)) {
23757
+ (0, import_node_fs6.mkdirSync)(dir, { recursive: true });
25856
23758
  }
25857
23759
  }
25858
23760
  function formatTime() {
@@ -25864,8 +23766,8 @@ async function appendToLog(workspaceDir, entry) {
25864
23766
  ensureDir5(logsPath);
25865
23767
  const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
25866
23768
  const logPath = getDailyLogPath(workspaceDir, today);
25867
- if (!(0, import_node_fs7.existsSync)(logPath)) {
25868
- await (0, import_promises10.writeFile)(logPath, `# ${today}
23769
+ if (!(0, import_node_fs6.existsSync)(logPath)) {
23770
+ await (0, import_promises6.writeFile)(logPath, `# ${today}
25869
23771
 
25870
23772
  `, "utf-8");
25871
23773
  }
@@ -25875,14 +23777,7 @@ async function appendToLog(workspaceDir, entry) {
25875
23777
  - ${typeLabel} ${entry.content}
25876
23778
 
25877
23779
  `;
25878
- await (0, import_promises10.appendFile)(logPath, line, "utf-8");
25879
- }
25880
- async function logEvent(workspaceDir, content) {
25881
- await appendToLog(workspaceDir, {
25882
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
25883
- type: "event",
25884
- content
25885
- });
23780
+ await (0, import_promises6.appendFile)(logPath, line, "utf-8");
25886
23781
  }
25887
23782
  async function logFact(workspaceDir, content) {
25888
23783
  await appendToLog(workspaceDir, {
@@ -25898,124 +23793,17 @@ async function logDecision(workspaceDir, content) {
25898
23793
  content
25899
23794
  });
25900
23795
  }
25901
- async function logAction(workspaceDir, content) {
25902
- await appendToLog(workspaceDir, {
25903
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
25904
- type: "action",
25905
- content
25906
- });
25907
- }
25908
- async function readLog(workspaceDir, date5) {
25909
- const logPath = getDailyLogPath(workspaceDir, date5);
25910
- if (!(0, import_node_fs7.existsSync)(logPath)) {
25911
- return "";
25912
- }
25913
- return (0, import_promises10.readFile)(logPath, "utf-8");
25914
- }
25915
- async function extractFactsFromLog(workspaceDir, date5) {
25916
- const log = await readLog(workspaceDir, date5);
25917
- const facts = [];
25918
- const lines = log.split("\n");
25919
- for (const line of lines) {
25920
- if (line.includes("[FACT]")) {
25921
- const fact = line.replace(/\[FACT\]/, "").replace(/^- /, "").trim();
25922
- if (fact) facts.push(fact);
25923
- }
25924
- }
25925
- return facts;
25926
- }
25927
- async function extractDecisionsFromLog(workspaceDir, date5) {
25928
- const log = await readLog(workspaceDir, date5);
25929
- const decisions = [];
25930
- const lines = log.split("\n");
25931
- for (const line of lines) {
25932
- if (line.includes("[DECISION]")) {
25933
- const decision = line.replace(/\[DECISION\]/, "").replace(/^- /, "").trim();
25934
- if (decision) decisions.push(decision);
25935
- }
25936
- }
25937
- return decisions;
25938
- }
25939
- var import_node_fs7, import_promises10;
23796
+ var import_node_fs6, import_promises6;
25940
23797
  var init_daily_log = __esm({
25941
23798
  "../memory/src/daily-log.ts"() {
25942
23799
  "use strict";
25943
- import_node_fs7 = require("node:fs");
25944
- import_promises10 = require("node:fs/promises");
23800
+ import_node_fs6 = require("node:fs");
23801
+ import_promises6 = require("node:fs/promises");
25945
23802
  init_paths();
25946
23803
  }
25947
23804
  });
25948
23805
 
25949
23806
  // ../memory/src/index.ts
25950
- var src_exports = {};
25951
- __export(src_exports, {
25952
- MemoryIndexManager: () => MemoryIndexManager,
25953
- accessFact: () => accessFact,
25954
- addACLAllowFromEntry: () => addACLAllowFromEntry,
25955
- addFact: () => addFact,
25956
- addOwner: () => addOwner,
25957
- appendToLog: () => appendToLog,
25958
- appendToMemory: () => appendToMemory,
25959
- approveACLPairingCode: () => approveACLPairingCode,
25960
- buildConversationEntry: () => buildConversationEntry,
25961
- chunkMarkdown: () => chunkMarkdown,
25962
- clearMemorySection: () => clearMemorySection,
25963
- closeWatcher: () => closeWatcher,
25964
- computeDecayTier: () => computeDecayTier,
25965
- conversationPathForFile: () => conversationPathForFile,
25966
- conversationToMemoryChunks: () => conversationToMemoryChunks,
25967
- createEmbeddingProvider: () => createEmbeddingProvider,
25968
- createEntity: () => createEntity,
25969
- createMemoryWatcher: () => createMemoryWatcher,
25970
- createWatcherHandle: () => createWatcherHandle,
25971
- extractConversationContent: () => extractConversationContent,
25972
- extractDecisionsFromLog: () => extractDecisionsFromLog,
25973
- extractFactsFromLog: () => extractFactsFromLog,
25974
- generateSummary: () => generateSummary,
25975
- getArchivesPath: () => getArchivesPath,
25976
- getAreasPath: () => getAreasPath,
25977
- getDailyLogPath: () => getDailyLogPath,
25978
- getDefaultMemoryConfig: () => getDefaultMemoryConfig,
25979
- getLogsPath: () => getLogsPath,
25980
- getMemoryPaths: () => getMemoryPaths,
25981
- getMemoryRoot: () => getMemoryRoot,
25982
- getParaRoot: () => getParaRoot,
25983
- getProjectHash: () => getProjectHash,
25984
- getProjectMemoryPath: () => getProjectMemoryPath,
25985
- getProjectsPath: () => getProjectsPath,
25986
- getResourcesPath: () => getResourcesPath,
25987
- getRole: () => getRole,
25988
- getSharedMemoryPath: () => getSharedMemoryPath,
25989
- getUserMemoryPath: () => getUserMemoryPath,
25990
- hashText: () => hashText,
25991
- isValidWalletAddress: () => isValidWalletAddress,
25992
- listACLPendingRequests: () => listACLPendingRequests,
25993
- listConversationFiles: () => listConversationFiles,
25994
- listConversations: () => listConversations,
25995
- listMemoryFiles: () => listMemoryFiles,
25996
- listOwners: () => listOwners,
25997
- loadConversation: () => loadConversation,
25998
- logAction: () => logAction,
25999
- logDecision: () => logDecision,
26000
- logEvent: () => logEvent,
26001
- logFact: () => logFact,
26002
- normalizeConversationText: () => normalizeConversationText,
26003
- normalizeWalletAddress: () => normalizeWalletAddress,
26004
- parseACL: () => parseACL,
26005
- readACLAllowFrom: () => readACLAllowFrom,
26006
- readLog: () => readLog,
26007
- readMemorySection: () => readMemorySection,
26008
- rejectACLPairingCode: () => rejectACLPairingCode,
26009
- removeACLAllowFromEntry: () => removeACLAllowFromEntry,
26010
- removeOwner: () => removeOwner,
26011
- resolveMemoryConfig: () => resolveMemoryConfig,
26012
- rewriteSummaries: () => rewriteSummaries,
26013
- saveConversation: () => saveConversation,
26014
- searchFacts: () => searchFacts,
26015
- supersedeFact: () => supersedeFact,
26016
- upsertACLPendingRequest: () => upsertACLPendingRequest,
26017
- validateWalletAddress: () => validateWalletAddress
26018
- });
26019
23807
  var init_src = __esm({
26020
23808
  "../memory/src/index.ts"() {
26021
23809
  "use strict";
@@ -26041,9 +23829,9 @@ var require_picocolors = __commonJS({
26041
23829
  var argv = p2.argv || [];
26042
23830
  var env = p2.env || {};
26043
23831
  var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p2.platform === "win32" || (p2.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
26044
- var formatter = (open2, close, replace = open2) => (input) => {
26045
- let string4 = "" + input, index = string4.indexOf(close, open2.length);
26046
- return ~index ? open2 + replaceClose(string4, close, replace, index) + close : open2 + string4 + close;
23832
+ var formatter = (open, close, replace = open) => (input) => {
23833
+ let string4 = "" + input, index = string4.indexOf(close, open.length);
23834
+ return ~index ? open + replaceClose(string4, close, replace, index) + close : open + string4 + close;
26047
23835
  };
26048
23836
  var replaceClose = (string4, close, replace, index) => {
26049
23837
  let result = "", cursor = 0;
@@ -26260,16 +24048,16 @@ async function handleRemoveSkill(c2) {
26260
24048
  }
26261
24049
  }
26262
24050
  function getSkills() {
26263
- const skillsDir = (0, import_node_path19.resolve)(PROJECT_ROOT2, "skills");
26264
- if (!(0, import_node_fs12.existsSync)(skillsDir)) return [];
24051
+ const skillsDir = (0, import_node_path16.resolve)(PROJECT_ROOT2, "skills");
24052
+ if (!(0, import_node_fs11.existsSync)(skillsDir)) return [];
26265
24053
  const skills = [];
26266
24054
  const lockfile = loadLockfile();
26267
- const entries = (0, import_node_fs12.readdirSync)(skillsDir, { withFileTypes: true });
24055
+ const entries = (0, import_node_fs11.readdirSync)(skillsDir, { withFileTypes: true });
26268
24056
  for (const entry of entries) {
26269
24057
  if (!entry.isDirectory()) continue;
26270
24058
  if (entry.name.startsWith(".")) continue;
26271
- const skillMdPath = (0, import_node_path19.join)(skillsDir, entry.name, "SKILL.md");
26272
- if (!(0, import_node_fs12.existsSync)(skillMdPath)) continue;
24059
+ const skillMdPath = (0, import_node_path16.join)(skillsDir, entry.name, "SKILL.md");
24060
+ if (!(0, import_node_fs11.existsSync)(skillMdPath)) continue;
26273
24061
  const skillInfo = parseSkillMd(skillMdPath, entry.name);
26274
24062
  if (skillInfo) {
26275
24063
  const lockEntry = lockfile[entry.name];
@@ -26282,10 +24070,10 @@ function getSkills() {
26282
24070
  return skills;
26283
24071
  }
26284
24072
  function loadLockfile() {
26285
- const lockfilePath = (0, import_node_path19.resolve)(PROJECT_ROOT2, "skills-lock.json");
26286
- if (!(0, import_node_fs12.existsSync)(lockfilePath)) return {};
24073
+ const lockfilePath = (0, import_node_path16.resolve)(PROJECT_ROOT2, "skills-lock.json");
24074
+ if (!(0, import_node_fs11.existsSync)(lockfilePath)) return {};
26287
24075
  try {
26288
- const content = (0, import_node_fs12.readFileSync)(lockfilePath, "utf-8");
24076
+ const content = (0, import_node_fs11.readFileSync)(lockfilePath, "utf-8");
26289
24077
  return JSON.parse(content);
26290
24078
  } catch {
26291
24079
  return {};
@@ -26293,7 +24081,7 @@ function loadLockfile() {
26293
24081
  }
26294
24082
  function parseSkillMd(filePath, defaultName) {
26295
24083
  try {
26296
- const content = (0, import_node_fs12.readFileSync)(filePath, "utf-8");
24084
+ const content = (0, import_node_fs11.readFileSync)(filePath, "utf-8");
26297
24085
  const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
26298
24086
  if (!frontmatterMatch) return null;
26299
24087
  const frontmatter = frontmatterMatch[1];
@@ -26309,10 +24097,10 @@ function parseSkillMd(filePath, defaultName) {
26309
24097
  }
26310
24098
  }
26311
24099
  async function installSkill(source) {
26312
- const projectSkillsDir = (0, import_node_path19.resolve)(PROJECT_ROOT2, "skills");
26313
- const lockfilePath = (0, import_node_path19.resolve)(PROJECT_ROOT2, "skills-lock.json");
26314
- if (!(0, import_node_fs12.existsSync)(projectSkillsDir)) {
26315
- (0, import_node_fs12.mkdirSync)(projectSkillsDir, { recursive: true });
24100
+ const projectSkillsDir = (0, import_node_path16.resolve)(PROJECT_ROOT2, "skills");
24101
+ const lockfilePath = (0, import_node_path16.resolve)(PROJECT_ROOT2, "skills-lock.json");
24102
+ if (!(0, import_node_fs11.existsSync)(projectSkillsDir)) {
24103
+ (0, import_node_fs11.mkdirSync)(projectSkillsDir, { recursive: true });
26316
24104
  }
26317
24105
  let skillName;
26318
24106
  let skillDir = null;
@@ -26326,8 +24114,8 @@ async function installSkill(source) {
26326
24114
  return { success: false, error: "Invalid GitHub repository name" };
26327
24115
  }
26328
24116
  skillName = parts[2] || parts[1];
26329
- const tempDir = (0, import_node_path19.resolve)(projectSkillsDir, ".temp", "install");
26330
- (0, import_node_fs12.rmSync)(tempDir, { recursive: true, force: true });
24117
+ const tempDir = (0, import_node_path16.resolve)(projectSkillsDir, ".temp", "install");
24118
+ (0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
26331
24119
  try {
26332
24120
  (0, import_node_child_process2.execFileSync)(
26333
24121
  "git",
@@ -26341,27 +24129,27 @@ async function installSkill(source) {
26341
24129
  return { success: false, error: "Failed to clone repository" };
26342
24130
  }
26343
24131
  skillDir = findSkillDir(tempDir, skillName);
26344
- if (!skillDir || !(0, import_node_fs12.existsSync)((0, import_node_path19.resolve)(skillDir, "SKILL.md"))) {
26345
- (0, import_node_fs12.rmSync)(tempDir, { recursive: true, force: true });
24132
+ if (!skillDir || !(0, import_node_fs11.existsSync)((0, import_node_path16.resolve)(skillDir, "SKILL.md"))) {
24133
+ (0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
26346
24134
  return { success: false, error: "No SKILL.md found in repository" };
26347
24135
  }
26348
- const destPath = (0, import_node_path19.resolve)(projectSkillsDir, skillName);
26349
- (0, import_node_fs12.cpSync)(skillDir, destPath, { recursive: true });
26350
- (0, import_node_fs12.rmSync)(tempDir, { recursive: true, force: true });
24136
+ const destPath = (0, import_node_path16.resolve)(projectSkillsDir, skillName);
24137
+ (0, import_node_fs11.cpSync)(skillDir, destPath, { recursive: true });
24138
+ (0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
26351
24139
  } else if (source.startsWith("./") || source.startsWith("../")) {
26352
- const localPath = (0, import_node_path19.resolve)(PROJECT_ROOT2, source);
26353
- if (!(0, import_node_fs12.existsSync)((0, import_node_path19.resolve)(localPath, "SKILL.md"))) {
24140
+ const localPath = (0, import_node_path16.resolve)(PROJECT_ROOT2, source);
24141
+ if (!(0, import_node_fs11.existsSync)((0, import_node_path16.resolve)(localPath, "SKILL.md"))) {
26354
24142
  return { success: false, error: "No SKILL.md found at local path" };
26355
24143
  }
26356
24144
  skillName = source.split("/").pop() || source;
26357
- const destPath = (0, import_node_path19.resolve)(projectSkillsDir, skillName);
26358
- (0, import_node_fs12.cpSync)(localPath, destPath, { recursive: true });
24145
+ const destPath = (0, import_node_path16.resolve)(projectSkillsDir, skillName);
24146
+ (0, import_node_fs11.cpSync)(localPath, destPath, { recursive: true });
26359
24147
  } else {
26360
24148
  if (!NPM_PACKAGE_RE.test(source)) {
26361
24149
  return { success: false, error: "Invalid npm package name" };
26362
24150
  }
26363
24151
  skillName = source.split("/").pop() || source;
26364
- const tempDir = (0, import_node_path19.resolve)(projectSkillsDir, ".temp", "npm-install");
24152
+ const tempDir = (0, import_node_path16.resolve)(projectSkillsDir, ".temp", "npm-install");
26365
24153
  try {
26366
24154
  (0, import_node_child_process2.execFileSync)("npm", ["install", source, "--prefix", tempDir], {
26367
24155
  stdio: "pipe",
@@ -26370,36 +24158,36 @@ async function installSkill(source) {
26370
24158
  } catch {
26371
24159
  return { success: false, error: "Failed to install npm package" };
26372
24160
  }
26373
- const installedDir = (0, import_node_path19.resolve)(tempDir, "node_modules", source);
26374
- if (!(0, import_node_fs12.existsSync)((0, import_node_path19.resolve)(installedDir, "SKILL.md"))) {
26375
- (0, import_node_fs12.rmSync)(tempDir, { recursive: true, force: true });
24161
+ const installedDir = (0, import_node_path16.resolve)(tempDir, "node_modules", source);
24162
+ if (!(0, import_node_fs11.existsSync)((0, import_node_path16.resolve)(installedDir, "SKILL.md"))) {
24163
+ (0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
26376
24164
  return { success: false, error: "No SKILL.md found in npm package" };
26377
24165
  }
26378
- const destPath = (0, import_node_path19.resolve)(projectSkillsDir, skillName);
26379
- (0, import_node_fs12.cpSync)(installedDir, destPath, { recursive: true });
26380
- (0, import_node_fs12.rmSync)(tempDir, { recursive: true, force: true });
24166
+ const destPath = (0, import_node_path16.resolve)(projectSkillsDir, skillName);
24167
+ (0, import_node_fs11.cpSync)(installedDir, destPath, { recursive: true });
24168
+ (0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
26381
24169
  }
26382
24170
  const lockfile = loadLockfile();
26383
24171
  lockfile[skillName] = {
26384
24172
  source,
26385
24173
  installedAt: (/* @__PURE__ */ new Date()).toISOString()
26386
24174
  };
26387
- (0, import_node_fs12.writeFileSync)(lockfilePath, JSON.stringify(lockfile, null, 2));
24175
+ (0, import_node_fs11.writeFileSync)(lockfilePath, JSON.stringify(lockfile, null, 2));
26388
24176
  return { success: true, skill: skillName };
26389
24177
  }
26390
24178
  async function uninstallSkill(name) {
26391
- const projectSkillsDir = (0, import_node_path19.resolve)(PROJECT_ROOT2, "skills");
26392
- const lockfilePath = (0, import_node_path19.resolve)(PROJECT_ROOT2, "skills-lock.json");
26393
- const skillPath = (0, import_node_path19.resolve)(projectSkillsDir, name);
26394
- if (!(0, import_node_fs12.existsSync)(skillPath)) {
24179
+ const projectSkillsDir = (0, import_node_path16.resolve)(PROJECT_ROOT2, "skills");
24180
+ const lockfilePath = (0, import_node_path16.resolve)(PROJECT_ROOT2, "skills-lock.json");
24181
+ const skillPath = (0, import_node_path16.resolve)(projectSkillsDir, name);
24182
+ if (!(0, import_node_fs11.existsSync)(skillPath)) {
26395
24183
  return { success: false, error: `Skill '${name}' not found` };
26396
24184
  }
26397
- (0, import_node_fs12.rmSync)(skillPath, { recursive: true, force: true });
26398
- if ((0, import_node_fs12.existsSync)(lockfilePath)) {
24185
+ (0, import_node_fs11.rmSync)(skillPath, { recursive: true, force: true });
24186
+ if ((0, import_node_fs11.existsSync)(lockfilePath)) {
26399
24187
  try {
26400
- const parsed = JSON.parse((0, import_node_fs12.readFileSync)(lockfilePath, "utf-8"));
24188
+ const parsed = JSON.parse((0, import_node_fs11.readFileSync)(lockfilePath, "utf-8"));
26401
24189
  delete parsed[name];
26402
- (0, import_node_fs12.writeFileSync)(lockfilePath, JSON.stringify(parsed, null, 2));
24190
+ (0, import_node_fs11.writeFileSync)(lockfilePath, JSON.stringify(parsed, null, 2));
26403
24191
  } catch {
26404
24192
  }
26405
24193
  }
@@ -26408,24 +24196,24 @@ async function uninstallSkill(name) {
26408
24196
  function findSkillDir(baseDir, skillName) {
26409
24197
  const searchPaths = [
26410
24198
  baseDir,
26411
- (0, import_node_path19.resolve)(baseDir, "skills", skillName),
26412
- (0, import_node_path19.resolve)(baseDir, skillName),
26413
- (0, import_node_path19.resolve)(baseDir, ".agents", "skills", skillName)
24199
+ (0, import_node_path16.resolve)(baseDir, "skills", skillName),
24200
+ (0, import_node_path16.resolve)(baseDir, skillName),
24201
+ (0, import_node_path16.resolve)(baseDir, ".agents", "skills", skillName)
26414
24202
  ];
26415
- for (const path6 of searchPaths) {
26416
- if ((0, import_node_fs12.existsSync)((0, import_node_path19.resolve)(path6, "SKILL.md"))) {
26417
- return path6;
24203
+ for (const path4 of searchPaths) {
24204
+ if ((0, import_node_fs11.existsSync)((0, import_node_path16.resolve)(path4, "SKILL.md"))) {
24205
+ return path4;
26418
24206
  }
26419
24207
  }
26420
24208
  return null;
26421
24209
  }
26422
- var import_node_child_process2, import_node_fs12, import_node_path19, PROJECT_ROOT2, GITHUB_REPO_RE, NPM_PACKAGE_RE;
24210
+ var import_node_child_process2, import_node_fs11, import_node_path16, PROJECT_ROOT2, GITHUB_REPO_RE, NPM_PACKAGE_RE;
26423
24211
  var init_skills = __esm({
26424
24212
  "../agent/src/server/routes/skills.ts"() {
26425
24213
  "use strict";
26426
24214
  import_node_child_process2 = require("node:child_process");
26427
- import_node_fs12 = require("node:fs");
26428
- import_node_path19 = require("node:path");
24215
+ import_node_fs11 = require("node:fs");
24216
+ import_node_path16 = require("node:path");
26429
24217
  init_registry2();
26430
24218
  init_auth();
26431
24219
  PROJECT_ROOT2 = process.env.AGENT_PROJECT_ROOT || process.cwd();
@@ -26440,8 +24228,8 @@ __export(index_exports, {
26440
24228
  default: () => index_default
26441
24229
  });
26442
24230
  module.exports = __toCommonJS(index_exports);
26443
- var import_node_fs13 = require("node:fs");
26444
- var import_node_path20 = require("node:path");
24231
+ var import_node_fs12 = require("node:fs");
24232
+ var import_node_path17 = require("node:path");
26445
24233
  var import_node_url = require("node:url");
26446
24234
  var import_claude_agent_sdk4 = require("@anthropic-ai/claude-agent-sdk");
26447
24235
  var import_node_server = require("@hono/node-server");
@@ -27221,10 +25009,10 @@ function mergeDefs(...defs) {
27221
25009
  function cloneDef(schema) {
27222
25010
  return mergeDefs(schema._zod.def);
27223
25011
  }
27224
- function getElementAtPath(obj, path6) {
27225
- if (!path6)
25012
+ function getElementAtPath(obj, path4) {
25013
+ if (!path4)
27226
25014
  return obj;
27227
- return path6.reduce((acc, key) => acc?.[key], obj);
25015
+ return path4.reduce((acc, key) => acc?.[key], obj);
27228
25016
  }
27229
25017
  function promiseAllObject(promisesObj) {
27230
25018
  const keys = Object.keys(promisesObj);
@@ -27607,11 +25395,11 @@ function aborted(x2, startIndex = 0) {
27607
25395
  }
27608
25396
  return false;
27609
25397
  }
27610
- function prefixIssues(path6, issues) {
25398
+ function prefixIssues(path4, issues) {
27611
25399
  return issues.map((iss) => {
27612
25400
  var _a3;
27613
25401
  (_a3 = iss).path ?? (_a3.path = []);
27614
- iss.path.unshift(path6);
25402
+ iss.path.unshift(path4);
27615
25403
  return iss;
27616
25404
  });
27617
25405
  }
@@ -27794,7 +25582,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
27794
25582
  }
27795
25583
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
27796
25584
  const result = { errors: [] };
27797
- const processError = (error49, path6 = []) => {
25585
+ const processError = (error49, path4 = []) => {
27798
25586
  var _a3, _b;
27799
25587
  for (const issue2 of error49.issues) {
27800
25588
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -27804,7 +25592,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
27804
25592
  } else if (issue2.code === "invalid_element") {
27805
25593
  processError({ issues: issue2.issues }, issue2.path);
27806
25594
  } else {
27807
- const fullpath = [...path6, ...issue2.path];
25595
+ const fullpath = [...path4, ...issue2.path];
27808
25596
  if (fullpath.length === 0) {
27809
25597
  result.errors.push(mapper(issue2));
27810
25598
  continue;
@@ -27836,8 +25624,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
27836
25624
  }
27837
25625
  function toDotPath(_path) {
27838
25626
  const segs = [];
27839
- const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
27840
- for (const seg of path6) {
25627
+ const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
25628
+ for (const seg of path4) {
27841
25629
  if (typeof seg === "number")
27842
25630
  segs.push(`[${seg}]`);
27843
25631
  else if (typeof seg === "symbol")
@@ -39814,13 +37602,13 @@ function resolveRef(ref, ctx) {
39814
37602
  if (!ref.startsWith("#")) {
39815
37603
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
39816
37604
  }
39817
- const path6 = ref.slice(1).split("/").filter(Boolean);
39818
- if (path6.length === 0) {
37605
+ const path4 = ref.slice(1).split("/").filter(Boolean);
37606
+ if (path4.length === 0) {
39819
37607
  return ctx.rootSchema;
39820
37608
  }
39821
37609
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
39822
- if (path6[0] === defsKey) {
39823
- const key = path6[1];
37610
+ if (path4[0] === defsKey) {
37611
+ const key = path4[1];
39824
37612
  if (!key || !ctx.defs[key]) {
39825
37613
  throw new Error(`Reference not found: ${ref}`);
39826
37614
  }
@@ -41301,15 +39089,15 @@ var import_picocolors = __toESM(require_picocolors(), 1);
41301
39089
  var import_accounts = require("viem/accounts");
41302
39090
 
41303
39091
  // ../agent/src/lib/secret-store.ts
41304
- var import_node_fs8 = require("node:fs");
41305
- var import_node_path11 = require("node:path");
39092
+ var import_node_fs7 = require("node:fs");
39093
+ var import_node_path8 = require("node:path");
41306
39094
  var secrets = /* @__PURE__ */ new Map();
41307
39095
  function getSecretsDir() {
41308
39096
  const dataRoot = process.env.DATA_ROOT;
41309
39097
  if (!dataRoot) {
41310
39098
  return "";
41311
39099
  }
41312
- return (0, import_node_path11.join)(dataRoot, "secrets");
39100
+ return (0, import_node_path8.join)(dataRoot, "secrets");
41313
39101
  }
41314
39102
  function getSecretPaths() {
41315
39103
  const secretsDir = getSecretsDir();
@@ -41319,14 +39107,14 @@ function getSecretPaths() {
41319
39107
  };
41320
39108
  }
41321
39109
  return {
41322
- AGENT_WALLET_KEY: (0, import_node_path11.join)(secretsDir, "wallet.key")
39110
+ AGENT_WALLET_KEY: (0, import_node_path8.join)(secretsDir, "wallet.key")
41323
39111
  };
41324
39112
  }
41325
39113
  function loadSecrets() {
41326
39114
  const secretPaths = getSecretPaths();
41327
- for (const [name, path6] of Object.entries(secretPaths)) {
41328
- if ((0, import_node_fs8.existsSync)(path6)) {
41329
- const content = (0, import_node_fs8.readFileSync)(path6, "utf-8").trim();
39115
+ for (const [name, path4] of Object.entries(secretPaths)) {
39116
+ if ((0, import_node_fs7.existsSync)(path4)) {
39117
+ const content = (0, import_node_fs7.readFileSync)(path4, "utf-8").trim();
41330
39118
  secrets.set(name, content);
41331
39119
  }
41332
39120
  }
@@ -41345,34 +39133,34 @@ function hasSecret(name) {
41345
39133
  }
41346
39134
 
41347
39135
  // ../agent/src/lib/workspace.ts
41348
- var import_node_fs9 = require("node:fs");
41349
- var import_promises11 = require("node:fs/promises");
41350
- var import_node_path12 = require("node:path");
39136
+ var import_node_fs8 = require("node:fs");
39137
+ var import_promises7 = require("node:fs/promises");
39138
+ var import_node_path9 = require("node:path");
41351
39139
  function getProjectRoot() {
41352
39140
  return process.env.AGENT_PROJECT_ROOT || process.cwd();
41353
39141
  }
41354
- async function exists(path6) {
39142
+ async function exists(path4) {
41355
39143
  try {
41356
- await (0, import_promises11.access)(path6);
39144
+ await (0, import_promises7.access)(path4);
41357
39145
  return true;
41358
39146
  } catch {
41359
39147
  return false;
41360
39148
  }
41361
39149
  }
41362
39150
  async function createSymlinkIfNotExists(target, link, type = "file") {
41363
- const linkDir = (0, import_node_path12.join)(link, "..");
41364
- await (0, import_promises11.mkdir)(linkDir, { recursive: true });
39151
+ const linkDir = (0, import_node_path9.join)(link, "..");
39152
+ await (0, import_promises7.mkdir)(linkDir, { recursive: true });
41365
39153
  try {
41366
- await (0, import_promises11.symlink)(target, link, type);
39154
+ await (0, import_promises7.symlink)(target, link, type);
41367
39155
  } catch (err) {
41368
39156
  if (err.code !== "EEXIST") {
41369
39157
  throw err;
41370
39158
  }
41371
39159
  }
41372
39160
  }
41373
- async function createDirIfNotExists(path6) {
41374
- if (!await exists(path6)) {
41375
- await (0, import_promises11.mkdir)(path6, { recursive: true });
39161
+ async function createDirIfNotExists(path4) {
39162
+ if (!await exists(path4)) {
39163
+ await (0, import_promises7.mkdir)(path4, { recursive: true });
41376
39164
  }
41377
39165
  }
41378
39166
  function sanitizeUserId2(userId) {
@@ -41381,15 +39169,15 @@ function sanitizeUserId2(userId) {
41381
39169
  async function getOrCreateUserWorkspace(userId) {
41382
39170
  const sanitizedUserId = sanitizeUserId2(userId);
41383
39171
  const projectRoot = getProjectRoot();
41384
- const workspaceDir = (0, import_node_path12.join)(projectRoot, "workspace", sanitizedUserId);
41385
- const userMemoryDir = (0, import_node_path12.join)(projectRoot, "memory", "users", sanitizedUserId);
39172
+ const workspaceDir = (0, import_node_path9.join)(projectRoot, "workspace", sanitizedUserId);
39173
+ const userMemoryDir = (0, import_node_path9.join)(projectRoot, "memory", "users", sanitizedUserId);
41386
39174
  const userWorkspaceDir = workspaceDir;
41387
39175
  await createDirIfNotExists(workspaceDir);
41388
39176
  await createDirIfNotExists(userMemoryDir);
41389
39177
  const readOnlyLinks = [
41390
39178
  {
41391
- target: (0, import_node_path12.join)(projectRoot, "dist"),
41392
- link: (0, import_node_path12.join)(workspaceDir, "dist"),
39179
+ target: (0, import_node_path9.join)(projectRoot, "dist"),
39180
+ link: (0, import_node_path9.join)(workspaceDir, "dist"),
41393
39181
  type: "dir"
41394
39182
  }
41395
39183
  ];
@@ -41398,17 +39186,17 @@ async function getOrCreateUserWorkspace(userId) {
41398
39186
  }
41399
39187
  await createSymlinkIfNotExists(
41400
39188
  userMemoryDir,
41401
- (0, import_node_path12.join)(workspaceDir, "memory"),
39189
+ (0, import_node_path9.join)(workspaceDir, "memory"),
41402
39190
  "dir"
41403
39191
  );
41404
39192
  return { workspaceDir, userMemoryDir, userWorkspaceDir };
41405
39193
  }
41406
39194
  function validatePathInWorkspace(params) {
41407
39195
  const { workspaceRoot, userId, requestedPath } = params;
41408
- const userWorkspace = (0, import_node_path12.join)(workspaceRoot, "workspace", sanitizeUserId2(userId));
41409
- if ((0, import_node_fs9.existsSync)(userWorkspace)) {
39196
+ const userWorkspace = (0, import_node_path9.join)(workspaceRoot, "workspace", sanitizeUserId2(userId));
39197
+ if ((0, import_node_fs8.existsSync)(userWorkspace)) {
41410
39198
  try {
41411
- const realUserWorkspace = (0, import_node_fs9.realpathSync)(userWorkspace);
39199
+ const realUserWorkspace = (0, import_node_fs8.realpathSync)(userWorkspace);
41412
39200
  if (realUserWorkspace !== userWorkspace) {
41413
39201
  return { valid: false, error: "Workspace cannot be a symlink" };
41414
39202
  }
@@ -41419,17 +39207,17 @@ function validatePathInWorkspace(params) {
41419
39207
  if (requestedPath.includes("..")) {
41420
39208
  return { valid: false, error: "Directory traversal not allowed" };
41421
39209
  }
41422
- if ((0, import_node_path12.isAbsolute)(requestedPath)) {
39210
+ if ((0, import_node_path9.isAbsolute)(requestedPath)) {
41423
39211
  return { valid: false, error: "Only relative paths allowed" };
41424
39212
  }
41425
- const resolvedPath = (0, import_node_path12.resolve)(userWorkspace, requestedPath);
39213
+ const resolvedPath = (0, import_node_path9.resolve)(userWorkspace, requestedPath);
41426
39214
  if (resolvedPath !== userWorkspace && !resolvedPath.startsWith(`${userWorkspace}/`)) {
41427
39215
  return { valid: false, error: "Path escapes workspace" };
41428
39216
  }
41429
- if ((0, import_node_fs9.existsSync)(resolvedPath)) {
39217
+ if ((0, import_node_fs8.existsSync)(resolvedPath)) {
41430
39218
  try {
41431
- const realPath = (0, import_node_fs9.realpathSync)(resolvedPath);
41432
- const realWorkspace = (0, import_node_fs9.realpathSync)(userWorkspace);
39219
+ const realPath = (0, import_node_fs8.realpathSync)(resolvedPath);
39220
+ const realWorkspace = (0, import_node_fs8.realpathSync)(userWorkspace);
41433
39221
  if (!realPath.startsWith(`${realWorkspace}/`) && realPath !== realWorkspace) {
41434
39222
  return { valid: false, error: "Symlink escapes workspace" };
41435
39223
  }
@@ -41441,17 +39229,17 @@ function validatePathInWorkspace(params) {
41441
39229
  }
41442
39230
 
41443
39231
  // ../agent/src/lib/workspace-state.ts
41444
- var import_node_fs10 = require("node:fs");
41445
- var import_node_path13 = require("node:path");
39232
+ var import_node_fs9 = require("node:fs");
39233
+ var import_node_path10 = require("node:path");
41446
39234
  var WORKSPACE_STATE_VERSION = 1;
41447
39235
  var STATE_DIR = ".hybrid";
41448
39236
  var STATE_FILE = "workspace-state.json";
41449
39237
  function resolveWorkspaceStatePath(workspaceDir) {
41450
- return (0, import_node_path13.join)(workspaceDir, STATE_DIR, STATE_FILE);
39238
+ return (0, import_node_path10.join)(workspaceDir, STATE_DIR, STATE_FILE);
41451
39239
  }
41452
39240
  function readWorkspaceState(statePath) {
41453
39241
  try {
41454
- const raw = (0, import_node_fs10.readFileSync)(statePath, "utf-8");
39242
+ const raw = (0, import_node_fs9.readFileSync)(statePath, "utf-8");
41455
39243
  const parsed = JSON.parse(raw);
41456
39244
  return {
41457
39245
  version: parsed.version ?? WORKSPACE_STATE_VERSION,
@@ -41463,11 +39251,11 @@ function readWorkspaceState(statePath) {
41463
39251
  }
41464
39252
  }
41465
39253
  function writeWorkspaceState(statePath, state) {
41466
- const dir = (0, import_node_path13.dirname)(statePath);
41467
- if (!(0, import_node_fs10.existsSync)(dir)) {
41468
- (0, import_node_fs10.mkdirSync)(dir, { recursive: true });
39254
+ const dir = (0, import_node_path10.dirname)(statePath);
39255
+ if (!(0, import_node_fs9.existsSync)(dir)) {
39256
+ (0, import_node_fs9.mkdirSync)(dir, { recursive: true });
41469
39257
  }
41470
- (0, import_node_fs10.writeFileSync)(statePath, JSON.stringify(state, null, 2), "utf-8");
39258
+ (0, import_node_fs9.writeFileSync)(statePath, JSON.stringify(state, null, 2), "utf-8");
41471
39259
  }
41472
39260
  function isOnboardingComplete(workspaceDir, bootstrapExists) {
41473
39261
  const statePath = resolveWorkspaceStatePath(workspaceDir);
@@ -41502,18 +39290,18 @@ var import_claude_agent_sdk2 = require("@anthropic-ai/claude-agent-sdk");
41502
39290
  init_src();
41503
39291
 
41504
39292
  // ../agent/src/tools/file.ts
41505
- var import_node_fs11 = require("node:fs");
41506
- var import_node_path18 = require("node:path");
39293
+ var import_node_fs10 = require("node:fs");
39294
+ var import_node_path15 = require("node:path");
41507
39295
  var import_claude_agent_sdk = require("@anthropic-ai/claude-agent-sdk");
41508
39296
 
41509
39297
  // ../agent/src/file-operations/edit.ts
41510
- var import_promises12 = require("node:fs/promises");
41511
- var import_node_path14 = require("node:path");
39298
+ var import_promises8 = require("node:fs/promises");
39299
+ var import_node_path11 = require("node:path");
41512
39300
  async function editFileInWorkspace(params) {
41513
- const filePath = (0, import_node_path14.join)(params.workspacePath, params.path);
39301
+ const filePath = (0, import_node_path11.join)(params.workspacePath, params.path);
41514
39302
  let content;
41515
39303
  try {
41516
- content = await (0, import_promises12.readFile)(filePath, "utf-8");
39304
+ content = await (0, import_promises8.readFile)(filePath, "utf-8");
41517
39305
  } catch {
41518
39306
  return {
41519
39307
  success: false,
@@ -41540,7 +39328,7 @@ async function editFileInWorkspace(params) {
41540
39328
  }
41541
39329
  }
41542
39330
  if (editsApplied.length > 0) {
41543
- await (0, import_promises12.writeFile)(filePath, content, "utf-8");
39331
+ await (0, import_promises8.writeFile)(filePath, content, "utf-8");
41544
39332
  }
41545
39333
  return {
41546
39334
  success: editsFailed.length === 0,
@@ -41551,8 +39339,8 @@ async function editFileInWorkspace(params) {
41551
39339
  }
41552
39340
 
41553
39341
  // ../agent/src/file-operations/patch.ts
41554
- var import_promises13 = require("node:fs/promises");
41555
- var import_node_path15 = require("node:path");
39342
+ var import_promises9 = require("node:fs/promises");
39343
+ var import_node_path12 = require("node:path");
41556
39344
  function applyUnifiedDiff(content, patch) {
41557
39345
  const lines = content.split("\n");
41558
39346
  const patchLines = patch.split("\n");
@@ -41628,10 +39416,10 @@ function applyUnifiedDiff(content, patch) {
41628
39416
  };
41629
39417
  }
41630
39418
  async function applyPatchToWorkspace(params) {
41631
- const filePath = (0, import_node_path15.join)(params.workspacePath, params.path);
39419
+ const filePath = (0, import_node_path12.join)(params.workspacePath, params.path);
41632
39420
  let content;
41633
39421
  try {
41634
- content = await (0, import_promises13.readFile)(filePath, "utf-8");
39422
+ content = await (0, import_promises9.readFile)(filePath, "utf-8");
41635
39423
  } catch {
41636
39424
  return {
41637
39425
  success: false,
@@ -41642,7 +39430,7 @@ async function applyPatchToWorkspace(params) {
41642
39430
  }
41643
39431
  const result = applyUnifiedDiff(content, params.patch);
41644
39432
  if (result.success && result.result) {
41645
- await (0, import_promises13.writeFile)(filePath, result.result, "utf-8");
39433
+ await (0, import_promises9.writeFile)(filePath, result.result, "utf-8");
41646
39434
  }
41647
39435
  return {
41648
39436
  success: result.success,
@@ -41653,8 +39441,8 @@ async function applyPatchToWorkspace(params) {
41653
39441
  }
41654
39442
 
41655
39443
  // ../agent/src/file-operations/read.ts
41656
- var import_promises14 = require("node:fs/promises");
41657
- var import_node_path16 = require("node:path");
39444
+ var import_promises10 = require("node:fs/promises");
39445
+ var import_node_path13 = require("node:path");
41658
39446
 
41659
39447
  // ../agent/src/file-operations/types.ts
41660
39448
  var DEFAULT_PAGE_SIZE = 50 * 1024;
@@ -41663,8 +39451,8 @@ var MAX_LINES = 2e3;
41663
39451
  var MAX_IMAGE_BYTES = 10 * 1024 * 1024;
41664
39452
 
41665
39453
  // ../agent/src/file-operations/read.ts
41666
- function isBinaryFileExtension(path6) {
41667
- const binaryExtensions2 = [
39454
+ function isBinaryFileExtension(path4) {
39455
+ const binaryExtensions = [
41668
39456
  ".png",
41669
39457
  ".jpg",
41670
39458
  ".jpeg",
@@ -41684,11 +39472,11 @@ function isBinaryFileExtension(path6) {
41684
39472
  ".avi",
41685
39473
  ".mov"
41686
39474
  ];
41687
- const ext = path6.toLowerCase();
41688
- return binaryExtensions2.some((e2) => ext.endsWith(e2));
39475
+ const ext = path4.toLowerCase();
39476
+ return binaryExtensions.some((e2) => ext.endsWith(e2));
41689
39477
  }
41690
39478
  async function readFileWithPaging(filePath, offset, limit2) {
41691
- const content = await (0, import_promises14.readFile)(filePath, "utf-8");
39479
+ const content = await (0, import_promises10.readFile)(filePath, "utf-8");
41692
39480
  const lines = content.split("\n");
41693
39481
  const startLine = (offset ?? 1) - 1;
41694
39482
  const maxLines = limit2 ?? MAX_LINES;
@@ -41714,8 +39502,8 @@ async function readFileWithPaging(filePath, offset, limit2) {
41714
39502
  };
41715
39503
  }
41716
39504
  async function readFileFromWorkspace(params) {
41717
- const filePath = (0, import_node_path16.join)(params.workspacePath, params.path);
41718
- const stats = await (0, import_promises14.stat)(filePath);
39505
+ const filePath = (0, import_node_path13.join)(params.workspacePath, params.path);
39506
+ const stats = await (0, import_promises10.stat)(filePath);
41719
39507
  if (isBinaryFileExtension(params.path)) {
41720
39508
  throw new Error(
41721
39509
  `Cannot read binary file: ${params.path}. Use appropriate tool for binary files.`
@@ -41725,7 +39513,7 @@ async function readFileFromWorkspace(params) {
41725
39513
  if (usePaging || params.offset || params.limit) {
41726
39514
  return readFileWithPaging(filePath, params.offset, params.limit);
41727
39515
  }
41728
- const content = await (0, import_promises14.readFile)(filePath, "utf-8");
39516
+ const content = await (0, import_promises10.readFile)(filePath, "utf-8");
41729
39517
  const lines = content.split("\n");
41730
39518
  return {
41731
39519
  content,
@@ -41735,21 +39523,21 @@ async function readFileFromWorkspace(params) {
41735
39523
  }
41736
39524
 
41737
39525
  // ../agent/src/file-operations/write.ts
41738
- var import_promises15 = require("node:fs/promises");
41739
- var import_node_path17 = require("node:path");
39526
+ var import_promises11 = require("node:fs/promises");
39527
+ var import_node_path14 = require("node:path");
41740
39528
  async function writeFileToWorkspace(params) {
41741
- const filePath = (0, import_node_path17.join)(params.workspacePath, params.path);
39529
+ const filePath = (0, import_node_path14.join)(params.workspacePath, params.path);
41742
39530
  const tempPath = `${filePath}.tmp`;
41743
- await (0, import_promises15.mkdir)((0, import_node_path17.dirname)(filePath), { recursive: true });
41744
- await (0, import_promises15.writeFile)(tempPath, params.content, "utf-8");
39531
+ await (0, import_promises11.mkdir)((0, import_node_path14.dirname)(filePath), { recursive: true });
39532
+ await (0, import_promises11.writeFile)(tempPath, params.content, "utf-8");
41745
39533
  try {
41746
- await (0, import_promises15.rename)(tempPath, filePath);
39534
+ await (0, import_promises11.rename)(tempPath, filePath);
41747
39535
  } catch {
41748
39536
  try {
41749
- await (0, import_promises15.unlink)(filePath);
39537
+ await (0, import_promises11.unlink)(filePath);
41750
39538
  } catch {
41751
39539
  }
41752
- await (0, import_promises15.rename)(tempPath, filePath);
39540
+ await (0, import_promises11.rename)(tempPath, filePath);
41753
39541
  }
41754
39542
  const bytesWritten = Buffer.byteLength(params.content, "utf-8");
41755
39543
  return {
@@ -41803,7 +39591,7 @@ function createFileTools(params) {
41803
39591
  isError: true
41804
39592
  };
41805
39593
  }
41806
- const userWorkspacePath = (0, import_node_path18.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
39594
+ const userWorkspacePath = (0, import_node_path15.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
41807
39595
  try {
41808
39596
  const result = await readFileFromWorkspace({
41809
39597
  workspacePath: userWorkspacePath,
@@ -41849,8 +39637,8 @@ function createFileTools(params) {
41849
39637
  const baseName = args.path.split("/").pop();
41850
39638
  if (baseName && args.path === baseName && PROJECT_CONFIG_FILES.includes(baseName)) {
41851
39639
  try {
41852
- const configPath = (0, import_node_path18.join)(projectRoot, baseName);
41853
- (0, import_node_fs11.writeFileSync)(configPath, args.content, "utf-8");
39640
+ const configPath = (0, import_node_path15.join)(projectRoot, baseName);
39641
+ (0, import_node_fs10.writeFileSync)(configPath, args.content, "utf-8");
41854
39642
  return {
41855
39643
  content: [
41856
39644
  {
@@ -41882,7 +39670,7 @@ function createFileTools(params) {
41882
39670
  isError: true
41883
39671
  };
41884
39672
  }
41885
- const userWorkspacePath = (0, import_node_path18.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
39673
+ const userWorkspacePath = (0, import_node_path15.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
41886
39674
  try {
41887
39675
  const result = await writeFileToWorkspace({
41888
39676
  workspacePath: userWorkspacePath,
@@ -41937,8 +39725,8 @@ function createFileTools(params) {
41937
39725
  const baseName = args.path.split("/").pop();
41938
39726
  if (baseName && args.path === baseName && PROJECT_CONFIG_FILES.includes(baseName)) {
41939
39727
  try {
41940
- const configPath = (0, import_node_path18.join)(projectRoot, baseName);
41941
- if (!(0, import_node_fs11.existsSync)(configPath)) {
39728
+ const configPath = (0, import_node_path15.join)(projectRoot, baseName);
39729
+ if (!(0, import_node_fs10.existsSync)(configPath)) {
41942
39730
  return {
41943
39731
  content: [
41944
39732
  {
@@ -41950,7 +39738,7 @@ function createFileTools(params) {
41950
39738
  };
41951
39739
  }
41952
39740
  let content = await import("node:fs/promises").then(
41953
- (fs5) => fs5.readFile(configPath, "utf-8")
39741
+ (fs4) => fs4.readFile(configPath, "utf-8")
41954
39742
  );
41955
39743
  let applied = 0;
41956
39744
  const failed = [];
@@ -41963,7 +39751,7 @@ function createFileTools(params) {
41963
39751
  failed.push({ oldText: edit.oldText, reason: "Text not found" });
41964
39752
  }
41965
39753
  }
41966
- (0, import_node_fs11.writeFileSync)(configPath, content, "utf-8");
39754
+ (0, import_node_fs10.writeFileSync)(configPath, content, "utf-8");
41967
39755
  if (failed.length > 0) {
41968
39756
  return {
41969
39757
  content: [
@@ -42006,7 +39794,7 @@ function createFileTools(params) {
42006
39794
  isError: true
42007
39795
  };
42008
39796
  }
42009
- const userWorkspacePath = (0, import_node_path18.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
39797
+ const userWorkspacePath = (0, import_node_path15.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
42010
39798
  try {
42011
39799
  const result = await editFileInWorkspace({
42012
39800
  workspacePath: userWorkspacePath,
@@ -42077,7 +39865,7 @@ ${failedText}`
42077
39865
  isError: true
42078
39866
  };
42079
39867
  }
42080
- const userWorkspacePath = (0, import_node_path18.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
39868
+ const userWorkspacePath = (0, import_node_path15.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
42081
39869
  try {
42082
39870
  const result = await applyPatchToWorkspace({
42083
39871
  workspacePath: userWorkspacePath,
@@ -42137,8 +39925,8 @@ ${failedText}`
42137
39925
  const baseName = args.path.split("/").pop();
42138
39926
  if (baseName && args.path === baseName && PROJECT_CONFIG_FILES.includes(baseName)) {
42139
39927
  try {
42140
- const configPath = (0, import_node_path18.join)(projectRoot, baseName);
42141
- if (!(0, import_node_fs11.existsSync)(configPath)) {
39928
+ const configPath = (0, import_node_path15.join)(projectRoot, baseName);
39929
+ if (!(0, import_node_fs10.existsSync)(configPath)) {
42142
39930
  return {
42143
39931
  content: [
42144
39932
  {
@@ -42149,7 +39937,7 @@ ${failedText}`
42149
39937
  isError: true
42150
39938
  };
42151
39939
  }
42152
- (0, import_node_fs11.rmSync)(configPath, { force: true });
39940
+ (0, import_node_fs10.rmSync)(configPath, { force: true });
42153
39941
  return {
42154
39942
  content: [
42155
39943
  {
@@ -42181,10 +39969,10 @@ ${failedText}`
42181
39969
  isError: true
42182
39970
  };
42183
39971
  }
42184
- const userWorkspacePath = (0, import_node_path18.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
42185
- const fullPath = (0, import_node_path18.join)(userWorkspacePath, args.path);
39972
+ const userWorkspacePath = (0, import_node_path15.join)(projectRoot, "workspace", userId.replace(/[^a-zA-Z0-9_-]/g, "_"));
39973
+ const fullPath = (0, import_node_path15.join)(userWorkspacePath, args.path);
42186
39974
  try {
42187
- if (!(0, import_node_fs11.existsSync)(fullPath)) {
39975
+ if (!(0, import_node_fs10.existsSync)(fullPath)) {
42188
39976
  return {
42189
39977
  content: [
42190
39978
  {
@@ -42196,8 +39984,8 @@ ${failedText}`
42196
39984
  };
42197
39985
  }
42198
39986
  const { statSync: statSync2 } = await import("node:fs");
42199
- const stat5 = statSync2(fullPath);
42200
- if (stat5.isDirectory()) {
39987
+ const stat2 = statSync2(fullPath);
39988
+ if (stat2.isDirectory()) {
42201
39989
  return {
42202
39990
  content: [
42203
39991
  {
@@ -42208,7 +39996,7 @@ ${failedText}`
42208
39996
  isError: true
42209
39997
  };
42210
39998
  }
42211
- (0, import_node_fs11.rmSync)(fullPath);
39999
+ (0, import_node_fs10.rmSync)(fullPath);
42212
40000
  return {
42213
40001
  content: [
42214
40002
  {
@@ -42749,28 +40537,28 @@ Fact Categories:
42749
40537
  };
42750
40538
  }
42751
40539
  try {
42752
- const { join: join18 } = await import("node:path");
40540
+ const { join: join16 } = await import("node:path");
42753
40541
  const {
42754
40542
  getProjectsPath: getProjectsPath2,
42755
40543
  getAreasPath: getAreasPath2,
42756
40544
  getResourcesPath: getResourcesPath2,
42757
40545
  getArchivesPath: getArchivesPath2
42758
- } = await Promise.resolve().then(() => (init_src(), src_exports));
40546
+ } = await import("@hybrid/memory");
42759
40547
  let entityPath;
42760
40548
  if (args.bucket === "projects") {
42761
- entityPath = join18(getProjectsPath2(workspaceDir), args.entityName);
40549
+ entityPath = join16(getProjectsPath2(workspaceDir), args.entityName);
42762
40550
  } else if (args.bucket === "areas" && args.category) {
42763
- entityPath = join18(
40551
+ entityPath = join16(
42764
40552
  getAreasPath2(workspaceDir),
42765
40553
  args.category,
42766
40554
  args.entityName
42767
40555
  );
42768
40556
  } else if (args.bucket === "areas") {
42769
- entityPath = join18(getAreasPath2(workspaceDir), args.entityName);
40557
+ entityPath = join16(getAreasPath2(workspaceDir), args.entityName);
42770
40558
  } else if (args.bucket === "resources") {
42771
- entityPath = join18(getResourcesPath2(workspaceDir), args.entityName);
40559
+ entityPath = join16(getResourcesPath2(workspaceDir), args.entityName);
42772
40560
  } else {
42773
- entityPath = join18(getArchivesPath2(workspaceDir), args.entityName);
40561
+ entityPath = join16(getArchivesPath2(workspaceDir), args.entityName);
42774
40562
  }
42775
40563
  const result = await addFact(
42776
40564
  workspaceDir,
@@ -43152,7 +40940,7 @@ Returns skills matching the query with descriptions.`,
43152
40940
 
43153
40941
  // ../agent/src/server/index.ts
43154
40942
  var import_meta = {};
43155
- var _dirname = typeof __dirname !== "undefined" ? __dirname : (0, import_node_path20.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
40943
+ var _dirname = typeof __dirname !== "undefined" ? __dirname : (0, import_node_path17.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
43156
40944
  loadSecrets();
43157
40945
  var PROJECT_ROOT4 = process.env.AGENT_PROJECT_ROOT || process.cwd();
43158
40946
  if (process.env.OPENROUTER_API_KEY && (!process.env.ANTHROPIC_API_KEY || process.env.ANTHROPIC_API_KEY === "" || process.env.ANTHROPIC_API_KEY.includes("your_"))) {
@@ -43199,7 +40987,7 @@ function resolveClaudeCodeCliPath() {
43199
40987
  }
43200
40988
  const possiblePaths = [
43201
40989
  // Docker container: /app/server -> /app/node_modules
43202
- (0, import_node_path20.join)(
40990
+ (0, import_node_path17.join)(
43203
40991
  _dirname,
43204
40992
  "..",
43205
40993
  "node_modules",
@@ -43209,7 +40997,7 @@ function resolveClaudeCodeCliPath() {
43209
40997
  ),
43210
40998
  // Dev/prod mode: from packages/agent/src/server or packages/agent/dist/server
43211
40999
  // both need 4 levels up to reach monorepo root node_modules
43212
- (0, import_node_path20.join)(
41000
+ (0, import_node_path17.join)(
43213
41001
  _dirname,
43214
41002
  "..",
43215
41003
  "..",
@@ -43221,7 +41009,7 @@ function resolveClaudeCodeCliPath() {
43221
41009
  "cli.js"
43222
41010
  ),
43223
41011
  // pnpm hoisted location (dev)
43224
- (0, import_node_path20.join)(
41012
+ (0, import_node_path17.join)(
43225
41013
  _dirname,
43226
41014
  "..",
43227
41015
  "..",
@@ -43240,7 +41028,7 @@ function resolveClaudeCodeCliPath() {
43240
41028
  "/usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js"
43241
41029
  ];
43242
41030
  for (const p2 of possiblePaths) {
43243
- if ((0, import_node_fs13.existsSync)(p2)) {
41031
+ if ((0, import_node_fs12.existsSync)(p2)) {
43244
41032
  return p2;
43245
41033
  }
43246
41034
  }
@@ -43251,7 +41039,7 @@ function resolveClaudeCodeCliPath() {
43251
41039
  function resolveClaudeCodeExecutable() {
43252
41040
  const realCliPath = resolveClaudeCodeCliPath();
43253
41041
  try {
43254
- (0, import_node_fs13.readFileSync)(CLAUDE_WRAPPER_PATH, "utf-8");
41042
+ (0, import_node_fs12.readFileSync)(CLAUDE_WRAPPER_PATH, "utf-8");
43255
41043
  return {
43256
41044
  executablePath: CLAUDE_WRAPPER_PATH,
43257
41045
  realCliPath,
@@ -43265,10 +41053,10 @@ function resolveClaudeCodeExecutable() {
43265
41053
  };
43266
41054
  }
43267
41055
  }
43268
- var SCHEDULER_DB_PATH = process.env.SCHEDULER_DB_PATH || (0, import_node_path20.join)(PROJECT_ROOT4, "data", "scheduler.db");
41056
+ var SCHEDULER_DB_PATH = process.env.SCHEDULER_DB_PATH || (0, import_node_path17.join)(PROJECT_ROOT4, "data", "scheduler.db");
43269
41057
  function loadMarkdownFile(relativePath) {
43270
41058
  try {
43271
- return (0, import_node_fs13.readFileSync)((0, import_node_path20.join)(PROJECT_ROOT4, relativePath), "utf-8").trim();
41059
+ return (0, import_node_fs12.readFileSync)((0, import_node_path17.join)(PROJECT_ROOT4, relativePath), "utf-8").trim();
43272
41060
  } catch {
43273
41061
  return "";
43274
41062
  }
@@ -43276,7 +41064,7 @@ function loadMarkdownFile(relativePath) {
43276
41064
  function loadUserMarkdown(userId) {
43277
41065
  if (!userId) return loadMarkdownFile("USER.md");
43278
41066
  const sanitizedId = userId.replace(/[^a-zA-Z0-9_-]/g, "_");
43279
- const userPath = (0, import_node_path20.join)("users", sanitizedId, "USER.md");
41067
+ const userPath = (0, import_node_path17.join)("users", sanitizedId, "USER.md");
43280
41068
  const userFile = loadMarkdownFile(userPath);
43281
41069
  return userFile || loadMarkdownFile("USER.md");
43282
41070
  }
@@ -43332,8 +41120,8 @@ async function initScheduler() {
43332
41120
  }
43333
41121
  try {
43334
41122
  const { mkdirSync: mkdirSync7, existsSync: existsSync11 } = await import("node:fs");
43335
- const { dirname: dirname7 } = await import("node:path");
43336
- const dbDir = dirname7(SCHEDULER_DB_PATH);
41123
+ const { dirname: dirname5 } = await import("node:path");
41124
+ const dbDir = dirname5(SCHEDULER_DB_PATH);
43337
41125
  if (!existsSync11(dbDir)) {
43338
41126
  mkdirSync7(dbDir, { recursive: true });
43339
41127
  }
@@ -44033,7 +41821,4 @@ humanize-ms/index.js:
44033
41821
 
44034
41822
  node-domexception/index.js:
44035
41823
  (*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
44036
-
44037
- chokidar/esm/index.js:
44038
- (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
44039
41824
  */