memorix 1.8.6 → 1.8.7

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 (49) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/dist/cli/index.js +2208 -1160
  5. package/dist/dashboard/static/app.js +51 -3
  6. package/dist/dashboard/static/style.css +88 -0
  7. package/dist/index.js +1726 -736
  8. package/dist/maintenance-runner.js +855 -218
  9. package/dist/media-audio-runner.js +856 -219
  10. package/dist/media-video-runner.js +854 -217
  11. package/dist/memcode-runtime/CHANGELOG.md +33 -0
  12. package/dist/sdk.js +1716 -726
  13. package/dist/vector-backfill-runner.js +853 -216
  14. package/docs/1.8.7-CODEGRAPH.md +166 -0
  15. package/docs/API_REFERENCE.md +23 -2
  16. package/docs/ARCHITECTURE.md +13 -0
  17. package/docs/README.md +4 -1
  18. package/package.json +3 -2
  19. package/plugins/antigravity/memorix/plugin.json +1 -1
  20. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  21. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  22. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  23. package/plugins/copilot/memorix/plugin.json +1 -1
  24. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  25. package/plugins/hermes/memorix/plugin.yaml +1 -1
  26. package/plugins/omp/memorix/package.json +1 -1
  27. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  28. package/plugins/pi/memorix/package.json +1 -1
  29. package/server.json +2 -2
  30. package/src/cli/commands/codegraph.ts +25 -11
  31. package/src/cli/commands/doctor.ts +11 -2
  32. package/src/cli/commands/serve-http.ts +27 -1
  33. package/src/codegraph/auto-context.ts +19 -10
  34. package/src/codegraph/context-pack.ts +20 -6
  35. package/src/codegraph/dashboard.ts +82 -0
  36. package/src/codegraph/external-provider.ts +10 -1
  37. package/src/codegraph/freshness.ts +1 -1
  38. package/src/codegraph/lite-provider.ts +81 -0
  39. package/src/codegraph/project-context.ts +18 -5
  40. package/src/codegraph/scip-provider.ts +181 -0
  41. package/src/codegraph/semantic-context.ts +139 -0
  42. package/src/codegraph/semantic-provider.ts +404 -0
  43. package/src/codegraph/store.ts +253 -18
  44. package/src/codegraph/types.ts +25 -3
  45. package/src/dashboard/server.ts +6 -0
  46. package/src/dashboard/static/style.css +88 -0
  47. package/src/knowledge/workset.ts +46 -44
  48. package/src/server/mcp-binding-store.ts +17 -0
  49. package/src/store/sqlite-db.ts +13 -0
@@ -725,6 +725,8 @@ CREATE TABLE IF NOT EXISTS code_files (
725
725
  sizeBytes INTEGER,
726
726
  indexedAt TEXT NOT NULL,
727
727
  gitCommit TEXT,
728
+ source TEXT,
729
+ parserError TEXT,
728
730
  UNIQUE(projectId, path)
729
731
  );
730
732
  `;
@@ -743,6 +745,7 @@ CREATE TABLE IF NOT EXISTS code_symbols (
743
745
  contentHash TEXT,
744
746
  indexedAt TEXT NOT NULL,
745
747
  stale INTEGER NOT NULL DEFAULT 0,
748
+ source TEXT,
746
749
  UNIQUE(projectId, fileId, qualifiedName, kind)
747
750
  );
748
751
  `;
@@ -757,6 +760,7 @@ CREATE TABLE IF NOT EXISTS code_edges (
757
760
  type TEXT NOT NULL,
758
761
  confidence REAL NOT NULL DEFAULT 1.0,
759
762
  evidence TEXT,
763
+ source TEXT,
760
764
  indexedAt TEXT NOT NULL
761
765
  );
762
766
  `;
@@ -1488,6 +1492,15 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_maintenance_jobs_active_dedupe
1488
1492
  db2.exec("CREATE INDEX IF NOT EXISTS idx_memory_feedback_events_candidate ON memory_feedback_events(project_id, candidate_kind, candidate_id, observed_at DESC)");
1489
1493
  db2.exec("CREATE INDEX IF NOT EXISTS idx_mcp_bindings_project ON mcp_bindings(project_id, last_used_at DESC)");
1490
1494
  }
1495
+ },
1496
+ {
1497
+ id: "1.8.7-codegraph-evidence",
1498
+ apply: (db2) => {
1499
+ addColumnIfMissing(db2, "code_files", "source", "source TEXT");
1500
+ addColumnIfMissing(db2, "code_files", "parserError", "parserError TEXT");
1501
+ addColumnIfMissing(db2, "code_symbols", "source", "source TEXT");
1502
+ addColumnIfMissing(db2, "code_edges", "source", "source TEXT");
1503
+ }
1491
1504
  }
1492
1505
  ];
1493
1506
  _dbCache = /* @__PURE__ */ new Map();
@@ -2905,7 +2918,7 @@ function toProviderInput(input, baseUrl) {
2905
2918
  return { type: input.modality, url: input.url };
2906
2919
  }
2907
2920
  function parseCacheJsonInWorker(filePath) {
2908
- return new Promise((resolve, reject) => {
2921
+ return new Promise((resolve2, reject) => {
2909
2922
  void import("worker_threads").then(({ Worker }) => {
2910
2923
  const worker = new Worker(
2911
2924
  `
@@ -2926,7 +2939,7 @@ function parseCacheJsonInWorker(filePath) {
2926
2939
  worker.once("message", (msg) => {
2927
2940
  void worker.terminate();
2928
2941
  if (msg?.ok && Array.isArray(msg.entries)) {
2929
- resolve(msg.entries);
2942
+ resolve2(msg.entries);
2930
2943
  return;
2931
2944
  }
2932
2945
  reject(new Error(msg?.error || "embedding cache worker parse failed"));
@@ -2990,8 +3003,8 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
2990
3003
  let count2 = 0;
2991
3004
  const writeLine = async (line) => {
2992
3005
  if (!out.write(line)) {
2993
- await new Promise((resolve, reject) => {
2994
- out.once("drain", resolve);
3006
+ await new Promise((resolve2, reject) => {
3007
+ out.once("drain", resolve2);
2995
3008
  out.once("error", reject);
2996
3009
  });
2997
3010
  }
@@ -3023,7 +3036,7 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
3023
3036
  `);
3024
3037
  count2 += 1;
3025
3038
  if (count2 % 50 === 0) {
3026
- await new Promise((resolve) => setImmediate(resolve));
3039
+ await new Promise((resolve2) => setImmediate(resolve2));
3027
3040
  }
3028
3041
  }
3029
3042
  }
@@ -3032,8 +3045,8 @@ async function streamJsonArrayToJsonl(filePath, tmpPath) {
3032
3045
  }
3033
3046
  }
3034
3047
  } finally {
3035
- await new Promise((resolve, reject) => {
3036
- out.end(() => resolve());
3048
+ await new Promise((resolve2, reject) => {
3049
+ out.end(() => resolve2());
3037
3050
  out.once("error", reject);
3038
3051
  });
3039
3052
  }
@@ -3078,7 +3091,7 @@ async function loadCacheJsonl(filePath) {
3078
3091
  } catch {
3079
3092
  }
3080
3093
  if (onDiskCount % 250 === 0) {
3081
- await new Promise((resolve) => setImmediate(resolve));
3094
+ await new Promise((resolve2) => setImmediate(resolve2));
3082
3095
  }
3083
3096
  }
3084
3097
  diskCacheEntryCount = onDiskCount;
@@ -3323,7 +3336,7 @@ async function saveDiskCacheNow() {
3323
3336
  return;
3324
3337
  }
3325
3338
  const tmpPath = `${jsonlPath}.tmp`;
3326
- await new Promise((resolve, reject) => {
3339
+ await new Promise((resolve2, reject) => {
3327
3340
  const out = createWriteStream(tmpPath);
3328
3341
  const entries = cache3.entries();
3329
3342
  const writeBatch = () => {
@@ -3342,7 +3355,7 @@ async function saveDiskCacheNow() {
3342
3355
  }
3343
3356
  setImmediate(writeBatch);
3344
3357
  };
3345
- out.on("finish", resolve);
3358
+ out.on("finish", resolve2);
3346
3359
  out.on("error", reject);
3347
3360
  writeBatch();
3348
3361
  });
@@ -3446,7 +3459,7 @@ function abortError() {
3446
3459
  }
3447
3460
  function raceWithAbort(promise, signal) {
3448
3461
  if (signal.aborted) return Promise.reject(abortError());
3449
- return new Promise((resolve, reject) => {
3462
+ return new Promise((resolve2, reject) => {
3450
3463
  const onAbort = () => {
3451
3464
  signal.removeEventListener("abort", onAbort);
3452
3465
  reject(abortError());
@@ -3455,7 +3468,7 @@ function raceWithAbort(promise, signal) {
3455
3468
  promise.then(
3456
3469
  (value) => {
3457
3470
  signal.removeEventListener("abort", onAbort);
3458
- resolve(value);
3471
+ resolve2(value);
3459
3472
  },
3460
3473
  (error) => {
3461
3474
  signal.removeEventListener("abort", onAbort);
@@ -3466,12 +3479,12 @@ function raceWithAbort(promise, signal) {
3466
3479
  }
3467
3480
  async function waitForRetry(waitMs, signal) {
3468
3481
  if (!signal) {
3469
- await new Promise((resolve) => setTimeout(resolve, waitMs));
3482
+ await new Promise((resolve2) => setTimeout(resolve2, waitMs));
3470
3483
  return;
3471
3484
  }
3472
3485
  const abortSignal = signal;
3473
3486
  if (abortSignal.aborted) throw new Error("Embedding API retry aborted");
3474
- await new Promise((resolve, reject) => {
3487
+ await new Promise((resolve2, reject) => {
3475
3488
  const timer = setTimeout(done, waitMs);
3476
3489
  const onAbort = () => {
3477
3490
  clearTimeout(timer);
@@ -3480,7 +3493,7 @@ async function waitForRetry(waitMs, signal) {
3480
3493
  };
3481
3494
  function done() {
3482
3495
  abortSignal.removeEventListener("abort", onAbort);
3483
- resolve();
3496
+ resolve2();
3484
3497
  }
3485
3498
  abortSignal.addEventListener("abort", onAbort, { once: true });
3486
3499
  });
@@ -5289,12 +5302,12 @@ var init_policy = __esm({
5289
5302
 
5290
5303
  // src/timeout.ts
5291
5304
  function withTimeout(promise, ms, label) {
5292
- return new Promise((resolve, reject) => {
5305
+ return new Promise((resolve2, reject) => {
5293
5306
  const timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
5294
5307
  promise.then(
5295
5308
  (value) => {
5296
5309
  clearTimeout(timer);
5297
- resolve(value);
5310
+ resolve2(value);
5298
5311
  },
5299
5312
  (error) => {
5300
5313
  clearTimeout(timer);
@@ -5306,7 +5319,7 @@ function withTimeout(promise, ms, label) {
5306
5319
  function withTimeoutSignal(operation, ms, label, parentSignal) {
5307
5320
  const controller = new AbortController();
5308
5321
  const signal = parentSignal ? AbortSignal.any([parentSignal, controller.signal]) : controller.signal;
5309
- return new Promise((resolve, reject) => {
5322
+ return new Promise((resolve2, reject) => {
5310
5323
  let settled = false;
5311
5324
  let timedOut = false;
5312
5325
  let timer;
@@ -5343,7 +5356,7 @@ function withTimeoutSignal(operation, ms, label, parentSignal) {
5343
5356
  if (settled) return;
5344
5357
  settled = true;
5345
5358
  cleanup();
5346
- resolve(value);
5359
+ resolve2(value);
5347
5360
  },
5348
5361
  (error) => {
5349
5362
  if (settled) return;
@@ -6176,7 +6189,7 @@ async function attachCachedVectors(database, candidates) {
6176
6189
  } catch {
6177
6190
  }
6178
6191
  if (index % 50 === 0) {
6179
- await new Promise((resolve) => setImmediate(resolve));
6192
+ await new Promise((resolve2) => setImmediate(resolve2));
6180
6193
  }
6181
6194
  }
6182
6195
  }
@@ -6252,7 +6265,7 @@ async function hydrateIndex(observations2, options = {}) {
6252
6265
  }
6253
6266
  }
6254
6267
  }
6255
- await new Promise((resolve) => setImmediate(resolve));
6268
+ await new Promise((resolve2) => setImmediate(resolve2));
6256
6269
  }
6257
6270
  deferredCachedVectorHydration = options.skipCachedVectors ? null : deferCachedVectors ? attachCachedVectors(database, candidates).catch(() => {
6258
6271
  }) : null;
@@ -8360,6 +8373,8 @@ function rowToFile(row) {
8360
8373
  ...row.sizeBytes != null ? { sizeBytes: row.sizeBytes } : {},
8361
8374
  indexedAt: row.indexedAt,
8362
8375
  ...row.gitCommit ? { gitCommit: row.gitCommit } : {},
8376
+ ...row.source ? { source: row.source } : {},
8377
+ ...row.parserError ? { parserError: row.parserError } : {},
8363
8378
  ...row.snapshotId ? { snapshotId: row.snapshotId } : {},
8364
8379
  ...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
8365
8380
  };
@@ -8379,6 +8394,7 @@ function rowToSymbol(row) {
8379
8394
  ...row.contentHash ? { contentHash: row.contentHash } : {},
8380
8395
  indexedAt: row.indexedAt,
8381
8396
  stale: !!row.stale,
8397
+ ...row.source ? { source: row.source } : {},
8382
8398
  ...row.snapshotId ? { snapshotId: row.snapshotId } : {},
8383
8399
  ...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
8384
8400
  };
@@ -8394,6 +8410,7 @@ function rowToEdge(row) {
8394
8410
  type: row.type,
8395
8411
  confidence: row.confidence,
8396
8412
  ...row.evidence ? { evidence: row.evidence } : {},
8413
+ ...row.source ? { source: row.source } : {},
8397
8414
  indexedAt: row.indexedAt,
8398
8415
  ...row.snapshotId ? { snapshotId: row.snapshotId } : {},
8399
8416
  ...row.sourceEpoch != null ? { sourceEpoch: Number(row.sourceEpoch) } : {}
@@ -8514,9 +8531,9 @@ var init_store = __esm({
8514
8531
  if (files.length === 0) return;
8515
8532
  const stmt = this.db.prepare(`
8516
8533
  INSERT OR REPLACE INTO code_files
8517
- (id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
8534
+ (id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
8518
8535
  VALUES
8519
- (@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
8536
+ (@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
8520
8537
  `);
8521
8538
  const tx = this.db.transaction((items) => {
8522
8539
  for (const file of items) {
@@ -8529,7 +8546,9 @@ var init_store = __esm({
8529
8546
  mtimeMs: file.mtimeMs ?? null,
8530
8547
  sizeBytes: file.sizeBytes ?? null,
8531
8548
  indexedAt: file.indexedAt,
8532
- gitCommit: file.gitCommit ?? null
8549
+ gitCommit: file.gitCommit ?? null,
8550
+ source: file.source ?? null,
8551
+ parserError: file.parserError ?? null
8533
8552
  });
8534
8553
  }
8535
8554
  });
@@ -8539,9 +8558,9 @@ var init_store = __esm({
8539
8558
  if (symbols.length === 0) return;
8540
8559
  const stmt = this.db.prepare(`
8541
8560
  INSERT OR REPLACE INTO code_symbols
8542
- (id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
8561
+ (id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
8543
8562
  VALUES
8544
- (@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
8563
+ (@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
8545
8564
  `);
8546
8565
  const tx = this.db.transaction((items) => {
8547
8566
  for (const symbol of items) {
@@ -8558,7 +8577,8 @@ var init_store = __esm({
8558
8577
  signature: symbol.signature ?? null,
8559
8578
  contentHash: symbol.contentHash ?? null,
8560
8579
  indexedAt: symbol.indexedAt,
8561
- stale: symbol.stale ? 1 : 0
8580
+ stale: symbol.stale ? 1 : 0,
8581
+ source: symbol.source ?? null
8562
8582
  });
8563
8583
  }
8564
8584
  });
@@ -8568,9 +8588,9 @@ var init_store = __esm({
8568
8588
  if (edges.length === 0) return;
8569
8589
  const stmt = this.db.prepare(`
8570
8590
  INSERT OR REPLACE INTO code_edges
8571
- (id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
8591
+ (id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
8572
8592
  VALUES
8573
- (@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
8593
+ (@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
8574
8594
  `);
8575
8595
  const tx = this.db.transaction((items) => {
8576
8596
  for (const edge of items) {
@@ -8584,7 +8604,8 @@ var init_store = __esm({
8584
8604
  type: edge.type,
8585
8605
  confidence: edge.confidence,
8586
8606
  evidence: edge.evidence ?? null,
8587
- indexedAt: edge.indexedAt
8607
+ indexedAt: edge.indexedAt,
8608
+ source: edge.source ?? null
8588
8609
  });
8589
8610
  }
8590
8611
  });
@@ -8596,21 +8617,21 @@ var init_store = __esm({
8596
8617
  const deleteFiles = this.db.prepare(`DELETE FROM code_files WHERE projectId = ?`);
8597
8618
  const insertFile = this.db.prepare(`
8598
8619
  INSERT OR REPLACE INTO code_files
8599
- (id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
8620
+ (id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
8600
8621
  VALUES
8601
- (@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
8622
+ (@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
8602
8623
  `);
8603
8624
  const insertSymbol = this.db.prepare(`
8604
8625
  INSERT OR REPLACE INTO code_symbols
8605
- (id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
8626
+ (id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
8606
8627
  VALUES
8607
- (@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
8628
+ (@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
8608
8629
  `);
8609
8630
  const insertEdge = this.db.prepare(`
8610
8631
  INSERT OR REPLACE INTO code_edges
8611
- (id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
8632
+ (id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
8612
8633
  VALUES
8613
- (@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
8634
+ (@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
8614
8635
  `);
8615
8636
  const tx = this.db.transaction(() => {
8616
8637
  deleteEdges.run(projectId);
@@ -8626,7 +8647,9 @@ var init_store = __esm({
8626
8647
  mtimeMs: file.mtimeMs ?? null,
8627
8648
  sizeBytes: file.sizeBytes ?? null,
8628
8649
  indexedAt: file.indexedAt,
8629
- gitCommit: file.gitCommit ?? null
8650
+ gitCommit: file.gitCommit ?? null,
8651
+ source: file.source ?? null,
8652
+ parserError: file.parserError ?? null
8630
8653
  });
8631
8654
  }
8632
8655
  for (const symbol of index.symbols) {
@@ -8643,7 +8666,8 @@ var init_store = __esm({
8643
8666
  signature: symbol.signature ?? null,
8644
8667
  contentHash: symbol.contentHash ?? null,
8645
8668
  indexedAt: symbol.indexedAt,
8646
- stale: 0
8669
+ stale: 0,
8670
+ source: symbol.source ?? null
8647
8671
  });
8648
8672
  }
8649
8673
  for (const edge of index.edges) {
@@ -8657,7 +8681,8 @@ var init_store = __esm({
8657
8681
  type: edge.type,
8658
8682
  confidence: edge.confidence,
8659
8683
  evidence: edge.evidence ?? null,
8660
- indexedAt: edge.indexedAt
8684
+ indexedAt: edge.indexedAt,
8685
+ source: edge.source ?? null
8661
8686
  });
8662
8687
  }
8663
8688
  });
@@ -8702,21 +8727,21 @@ var init_store = __esm({
8702
8727
  const deleteFile = this.db.prepare(`DELETE FROM code_files WHERE projectId = ? AND id = ?`);
8703
8728
  const upsertFile = this.db.prepare(`
8704
8729
  INSERT OR REPLACE INTO code_files
8705
- (id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit)
8730
+ (id, projectId, path, language, contentHash, mtimeMs, sizeBytes, indexedAt, gitCommit, source, parserError)
8706
8731
  VALUES
8707
- (@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit)
8732
+ (@id, @projectId, @path, @language, @contentHash, @mtimeMs, @sizeBytes, @indexedAt, @gitCommit, @source, @parserError)
8708
8733
  `);
8709
8734
  const upsertSymbol = this.db.prepare(`
8710
8735
  INSERT OR REPLACE INTO code_symbols
8711
- (id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale)
8736
+ (id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
8712
8737
  VALUES
8713
- (@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale)
8738
+ (@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
8714
8739
  `);
8715
8740
  const upsertEdge = this.db.prepare(`
8716
8741
  INSERT OR REPLACE INTO code_edges
8717
- (id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt)
8742
+ (id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
8718
8743
  VALUES
8719
- (@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt)
8744
+ (@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
8720
8745
  `);
8721
8746
  const writeFile5 = (file) => upsertFile.run({
8722
8747
  id: file.id,
@@ -8727,7 +8752,9 @@ var init_store = __esm({
8727
8752
  mtimeMs: file.mtimeMs ?? null,
8728
8753
  sizeBytes: file.sizeBytes ?? null,
8729
8754
  indexedAt: file.indexedAt,
8730
- gitCommit: file.gitCommit ?? null
8755
+ gitCommit: file.gitCommit ?? null,
8756
+ source: file.source ?? null,
8757
+ parserError: file.parserError ?? null
8731
8758
  });
8732
8759
  const tx = this.db.transaction(() => {
8733
8760
  const staleAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -8761,7 +8788,8 @@ var init_store = __esm({
8761
8788
  signature: symbol.signature ?? null,
8762
8789
  contentHash: symbol.contentHash ?? null,
8763
8790
  indexedAt: symbol.indexedAt,
8764
- stale: symbol.stale ? 1 : 0
8791
+ stale: symbol.stale ? 1 : 0,
8792
+ source: symbol.source ?? null
8765
8793
  });
8766
8794
  }
8767
8795
  for (const edge of delta.edges) {
@@ -8775,7 +8803,8 @@ var init_store = __esm({
8775
8803
  type: edge.type,
8776
8804
  confidence: edge.confidence,
8777
8805
  evidence: edge.evidence ?? null,
8778
- indexedAt: edge.indexedAt
8806
+ indexedAt: edge.indexedAt,
8807
+ source: edge.source ?? null
8779
8808
  });
8780
8809
  }
8781
8810
  }
@@ -8923,6 +8952,202 @@ var init_store = __esm({
8923
8952
  listEdges(projectId) {
8924
8953
  return this.db.prepare(`SELECT * FROM code_edges WHERE projectId = ? ORDER BY type, id`).all(projectId).map(rowToEdge);
8925
8954
  }
8955
+ /** Return direct importers before a refresh clears their old target IDs. */
8956
+ listImportDependentPaths(projectId, paths, candidatePaths = []) {
8957
+ const normalized = [...new Set(paths.map(normalizeCodePath).filter(Boolean))];
8958
+ if (normalized.length === 0) return [];
8959
+ const files = this.listFiles(projectId);
8960
+ const fileIds = files.filter((file) => normalized.includes(file.path)).map((file) => file.id);
8961
+ const fileById = new Map(files.map((file) => [file.id, file]));
8962
+ const fileByPath = new Map(files.map((file) => [file.path, file]));
8963
+ for (const path21 of candidatePaths.map(normalizeCodePath).filter(Boolean)) {
8964
+ if (!fileByPath.has(path21)) {
8965
+ fileByPath.set(path21, {
8966
+ id: `candidate:${path21}`,
8967
+ projectId,
8968
+ path: path21,
8969
+ contentHash: "",
8970
+ indexedAt: ""
8971
+ });
8972
+ }
8973
+ }
8974
+ const rows = this.db.prepare(`
8975
+ SELECT DISTINCT fromFileId, evidence
8976
+ FROM code_edges
8977
+ WHERE projectId = ? AND type = 'imports'
8978
+ `).all(projectId);
8979
+ const wanted = new Set(normalized);
8980
+ const dependents = /* @__PURE__ */ new Set();
8981
+ const queue = [...normalized];
8982
+ while (queue.length > 0) {
8983
+ const targetPath = queue.shift();
8984
+ for (const row of rows) {
8985
+ const source = row.fromFileId ? fileById.get(row.fromFileId) : void 0;
8986
+ if (!source || source.path === targetPath || dependents.has(source.path)) continue;
8987
+ const target = resolveRelativeImportTarget(source.path, row.evidence, fileByPath);
8988
+ if (!target || !wanted.has(target.path)) continue;
8989
+ dependents.add(source.path);
8990
+ if (!wanted.has(source.path)) {
8991
+ wanted.add(source.path);
8992
+ queue.push(source.path);
8993
+ }
8994
+ }
8995
+ }
8996
+ if (fileIds.length > 0) {
8997
+ const placeholders = fileIds.map(() => "?").join(", ");
8998
+ const exactRows = this.db.prepare(`
8999
+ SELECT DISTINCT fromFileId
9000
+ FROM code_edges
9001
+ WHERE projectId = ? AND type = 'imports' AND toFileId IN (${placeholders})
9002
+ `).all(projectId, ...fileIds);
9003
+ for (const row of exactRows) {
9004
+ const source = row.fromFileId ? fileById.get(row.fromFileId) : void 0;
9005
+ if (source) dependents.add(source.path);
9006
+ }
9007
+ }
9008
+ return [...dependents].sort();
9009
+ }
9010
+ /** Replace only the semantic slice touched by a change, in one transaction. */
9011
+ replaceSemanticSlice(projectId, affectedPaths, input) {
9012
+ const normalizedPaths = [...new Set(affectedPaths.map(normalizeCodePath).filter(Boolean))];
9013
+ if (normalizedPaths.length === 0) return;
9014
+ const fileRows = this.listFiles(projectId).filter((file) => normalizedPaths.includes(file.path));
9015
+ const fileIds = fileRows.map((file) => file.id);
9016
+ const placeholders = fileIds.map(() => "?").join(", ");
9017
+ if (fileIds.length === 0) return;
9018
+ const staleRefs = this.db.prepare(`
9019
+ UPDATE observation_code_refs SET status = 'stale', updatedAt = ?
9020
+ WHERE projectId = ? AND (fileId IN (${placeholders}) OR symbolId IN (
9021
+ SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})
9022
+ ))
9023
+ `);
9024
+ const deleteEdges = this.db.prepare(`
9025
+ DELETE FROM code_edges
9026
+ WHERE projectId = ? AND (source IS NULL OR source IN ('lite-regex', 'typescript-compiler'))
9027
+ AND (fromFileId IN (${placeholders}) OR toFileId IN (${placeholders})
9028
+ OR fromSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders}))
9029
+ OR toSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})))
9030
+ `);
9031
+ const deleteSymbols = this.db.prepare(`DELETE FROM code_symbols WHERE projectId = ? AND fileId IN (${placeholders})`);
9032
+ const updateFile = this.db.prepare("UPDATE code_files SET source = ?, parserError = ? WHERE projectId = ? AND id = ?");
9033
+ const insertSymbol = this.db.prepare(`
9034
+ INSERT OR REPLACE INTO code_symbols
9035
+ (id, projectId, fileId, path, name, qualifiedName, kind, startLine, endLine, signature, contentHash, indexedAt, stale, source)
9036
+ VALUES
9037
+ (@id, @projectId, @fileId, @path, @name, @qualifiedName, @kind, @startLine, @endLine, @signature, @contentHash, @indexedAt, @stale, @source)
9038
+ `);
9039
+ const insertEdge = this.db.prepare(`
9040
+ INSERT OR REPLACE INTO code_edges
9041
+ (id, projectId, fromSymbolId, toSymbolId, fromFileId, toFileId, type, confidence, evidence, indexedAt, source)
9042
+ VALUES
9043
+ (@id, @projectId, @fromSymbolId, @toSymbolId, @fromFileId, @toFileId, @type, @confidence, @evidence, @indexedAt, @source)
9044
+ `);
9045
+ const diagnosticsByPath = new Map((input.diagnostics ?? []).map((item) => [normalizeCodePath(item.path), item.message]));
9046
+ const symbolFileIds = new Set(fileIds);
9047
+ const tx = this.db.transaction(() => {
9048
+ const now3 = (/* @__PURE__ */ new Date()).toISOString();
9049
+ staleRefs.run(now3, projectId, ...fileIds, projectId, ...fileIds);
9050
+ deleteEdges.run(projectId, ...fileIds, ...fileIds, projectId, ...fileIds, projectId, ...fileIds);
9051
+ deleteSymbols.run(projectId, ...fileIds);
9052
+ for (const file of fileRows) {
9053
+ const diagnostic = diagnosticsByPath.get(file.path);
9054
+ updateFile.run(diagnostic ? "typescript-compiler" : "typescript-compiler", diagnostic ?? null, projectId, file.id);
9055
+ }
9056
+ for (const symbol of input.symbols.filter((symbol2) => symbolFileIds.has(symbol2.fileId))) {
9057
+ insertSymbol.run({
9058
+ id: symbol.id,
9059
+ projectId: symbol.projectId,
9060
+ fileId: symbol.fileId,
9061
+ path: normalizeCodePath(symbol.path),
9062
+ name: symbol.name,
9063
+ qualifiedName: symbol.qualifiedName,
9064
+ kind: symbol.kind,
9065
+ startLine: symbol.startLine ?? null,
9066
+ endLine: symbol.endLine ?? null,
9067
+ signature: symbol.signature ?? null,
9068
+ contentHash: symbol.contentHash ?? null,
9069
+ indexedAt: symbol.indexedAt,
9070
+ stale: symbol.stale ? 1 : 0,
9071
+ source: symbol.source ?? "typescript-compiler"
9072
+ });
9073
+ }
9074
+ for (const edge of input.edges) {
9075
+ insertEdge.run({
9076
+ id: edge.id,
9077
+ projectId: edge.projectId,
9078
+ fromSymbolId: edge.fromSymbolId ?? null,
9079
+ toSymbolId: edge.toSymbolId ?? null,
9080
+ fromFileId: edge.fromFileId ?? null,
9081
+ toFileId: edge.toFileId ?? null,
9082
+ type: edge.type,
9083
+ confidence: edge.confidence,
9084
+ evidence: edge.evidence ?? null,
9085
+ indexedAt: edge.indexedAt,
9086
+ source: edge.source ?? "typescript-compiler"
9087
+ });
9088
+ }
9089
+ });
9090
+ tx();
9091
+ }
9092
+ /** Record a semantic refresh failure without presenting the old facts as current. */
9093
+ markSemanticSliceFailed(projectId, affectedPaths, message) {
9094
+ const normalizedPaths = [...new Set(affectedPaths.map(normalizeCodePath).filter(Boolean))];
9095
+ const fileRows = this.listFiles(projectId).filter((file) => normalizedPaths.includes(file.path));
9096
+ const fileIds = fileRows.map((file) => file.id);
9097
+ const filePlaceholders = fileIds.map(() => "?").join(", ");
9098
+ const staleRefs = fileIds.length > 0 ? this.db.prepare(`
9099
+ UPDATE observation_code_refs SET status = 'stale', updatedAt = ?
9100
+ WHERE projectId = ? AND (fileId IN (${filePlaceholders}) OR symbolId IN (
9101
+ SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders})
9102
+ ))
9103
+ `) : void 0;
9104
+ const staleSymbols = fileIds.length > 0 ? this.db.prepare(`
9105
+ UPDATE code_symbols SET stale = 1
9106
+ WHERE projectId = ? AND source = 'typescript-compiler' AND fileId IN (${filePlaceholders})
9107
+ `) : void 0;
9108
+ const updateFiles = fileIds.length > 0 ? this.db.prepare(`
9109
+ UPDATE code_files SET parserError = ?
9110
+ WHERE projectId = ? AND id IN (${filePlaceholders})
9111
+ `) : void 0;
9112
+ const affectedEdgeClause = fileIds.length > 0 ? `
9113
+ OR fromFileId IN (${filePlaceholders})
9114
+ OR toFileId IN (${filePlaceholders})
9115
+ OR fromSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders}))
9116
+ OR toSymbolId IN (SELECT id FROM code_symbols WHERE projectId = ? AND fileId IN (${filePlaceholders}))
9117
+ ` : "";
9118
+ const deleteEdges = this.db.prepare(`
9119
+ DELETE FROM code_edges
9120
+ WHERE projectId = ? AND source = 'typescript-compiler'
9121
+ AND (
9122
+ (fromSymbolId IS NOT NULL AND NOT EXISTS (
9123
+ SELECT 1 FROM code_symbols WHERE projectId = ? AND id = fromSymbolId
9124
+ ))
9125
+ OR (toSymbolId IS NOT NULL AND NOT EXISTS (
9126
+ SELECT 1 FROM code_symbols WHERE projectId = ? AND id = toSymbolId
9127
+ ))
9128
+ ${affectedEdgeClause}
9129
+ )
9130
+ `);
9131
+ const tx = this.db.transaction(() => {
9132
+ const failure = `semantic indexing failed: ${message.slice(0, 500)}`;
9133
+ if (updateFiles) updateFiles.run(failure, projectId, ...fileIds);
9134
+ if (staleRefs) staleRefs.run((/* @__PURE__ */ new Date()).toISOString(), projectId, ...fileIds, projectId, ...fileIds);
9135
+ if (staleSymbols) staleSymbols.run(projectId, ...fileIds);
9136
+ const edgeParams = [projectId, projectId, projectId];
9137
+ if (fileIds.length > 0) {
9138
+ edgeParams.push(
9139
+ ...fileIds,
9140
+ ...fileIds,
9141
+ projectId,
9142
+ ...fileIds,
9143
+ projectId,
9144
+ ...fileIds
9145
+ );
9146
+ }
9147
+ deleteEdges.run(...edgeParams);
9148
+ });
9149
+ tx();
9150
+ }
8926
9151
  listObservationRefs(projectId, observationId2) {
8927
9152
  return this.db.prepare(`
8928
9153
  SELECT * FROM observation_code_refs
@@ -9124,6 +9349,9 @@ var init_store = __esm({
9124
9349
  const symbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0`).get(projectId).count;
9125
9350
  const edges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ?`).get(projectId).count;
9126
9351
  const refs = this.db.prepare(`SELECT COUNT(*) AS count FROM observation_code_refs WHERE projectId = ?`).get(projectId).count;
9352
+ const semanticSymbols = this.db.prepare(`SELECT COUNT(*) AS count FROM code_symbols WHERE projectId = ? AND stale = 0 AND source = 'typescript-compiler'`).get(projectId).count;
9353
+ const semanticEdges = this.db.prepare(`SELECT COUNT(*) AS count FROM code_edges WHERE projectId = ? AND source = 'typescript-compiler'`).get(projectId).count;
9354
+ const parserErrors = this.db.prepare(`SELECT COUNT(*) AS count FROM code_files WHERE projectId = ? AND parserError IS NOT NULL`).get(projectId).count;
9127
9355
  const latest = this.db.prepare(`SELECT MAX(indexedAt) AS indexedAt FROM code_files WHERE projectId = ?`).get(projectId);
9128
9356
  const latestSnapshot = this.latestSnapshot(projectId);
9129
9357
  return {
@@ -9132,6 +9360,9 @@ var init_store = __esm({
9132
9360
  symbols,
9133
9361
  edges,
9134
9362
  refs,
9363
+ semanticSymbols,
9364
+ semanticEdges,
9365
+ parserErrors,
9135
9366
  ...latest?.indexedAt ? { indexedAt: latest.indexedAt } : {},
9136
9367
  ...latestSnapshot ? { latestSnapshot } : {}
9137
9368
  };
@@ -10544,8 +10775,8 @@ function localWorkspacePath(dataDir, projectId) {
10544
10775
  return path9.join(path9.resolve(dataDir), "knowledge-workspaces", hash(projectId).slice(0, 24));
10545
10776
  }
10546
10777
  function isWithin(root, candidate) {
10547
- const relative2 = path9.relative(root, candidate);
10548
- return relative2 !== "" && !relative2.startsWith(".." + path9.sep) && relative2 !== ".." && !path9.isAbsolute(relative2);
10778
+ const relative3 = path9.relative(root, candidate);
10779
+ return relative3 !== "" && !relative3.startsWith(".." + path9.sep) && relative3 !== ".." && !path9.isAbsolute(relative3);
10549
10780
  }
10550
10781
  function ensureVersionedPath(projectRoot, rootPath) {
10551
10782
  if (!path9.isAbsolute(rootPath)) {
@@ -10563,8 +10794,8 @@ function ensureVersionedPath(projectRoot, rootPath) {
10563
10794
  return resolvedWorkspace;
10564
10795
  }
10565
10796
  async function isIgnoredByGit(projectRoot, workspaceRoot) {
10566
- const relative2 = path9.relative(projectRoot, workspaceRoot).split(path9.sep).join("/");
10567
- const probes = [relative2, relative2.replace(/\/+$/, "") + "/.memorix-workspace-probe"];
10797
+ const relative3 = path9.relative(projectRoot, workspaceRoot).split(path9.sep).join("/");
10798
+ const probes = [relative3, relative3.replace(/\/+$/, "") + "/.memorix-workspace-probe"];
10568
10799
  for (const probe of probes) {
10569
10800
  try {
10570
10801
  await execFileAsync("git", ["-C", projectRoot, "check-ignore", "--quiet", "--no-index", "--", probe], {
@@ -11680,8 +11911,8 @@ function projectStorageKey(projectId) {
11680
11911
  }
11681
11912
  function validateUnderRoot(root, candidate) {
11682
11913
  const resolved = path10.resolve(candidate);
11683
- const relative2 = path10.relative(root, resolved);
11684
- if (relative2.startsWith("..") || path10.isAbsolute(relative2)) {
11914
+ const relative3 = path10.relative(root, resolved);
11915
+ if (relative3.startsWith("..") || path10.isAbsolute(relative3)) {
11685
11916
  throw new Error("Media storage path escaped the Memorix data directory");
11686
11917
  }
11687
11918
  return resolved;
@@ -11725,8 +11956,8 @@ function detectMedia(bytes) {
11725
11956
  throw new Error("Unsupported or unrecognized media format");
11726
11957
  }
11727
11958
  function destinationFor(root, projectId, sha256, extension3) {
11728
- const relative2 = path10.join("assets", projectStorageKey(projectId), sha256.slice(0, 2), `${sha256}${extension3}`);
11729
- return { relative: relative2, absolute: validateUnderRoot(root, path10.join(root, relative2)) };
11959
+ const relative3 = path10.join("assets", projectStorageKey(projectId), sha256.slice(0, 2), `${sha256}${extension3}`);
11960
+ return { relative: relative3, absolute: validateUnderRoot(root, path10.join(root, relative3)) };
11730
11961
  }
11731
11962
  async function destinationExists(destination) {
11732
11963
  try {
@@ -20256,7 +20487,7 @@ var init_sleep = __esm({
20256
20487
  "node_modules/openai/internal/utils/sleep.mjs"() {
20257
20488
  "use strict";
20258
20489
  init_esm_shims();
20259
- sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
20490
+ sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
20260
20491
  }
20261
20492
  });
20262
20493
 
@@ -21445,8 +21676,8 @@ var init_api_promise = __esm({
21445
21676
  init_parse();
21446
21677
  APIPromise = class _APIPromise extends Promise {
21447
21678
  constructor(client, responsePromise, parseResponse2 = defaultParseResponse) {
21448
- super((resolve) => {
21449
- resolve(null);
21679
+ super((resolve2) => {
21680
+ resolve2(null);
21450
21681
  });
21451
21682
  this.responsePromise = responsePromise;
21452
21683
  this.parseResponse = parseResponse2;
@@ -22090,12 +22321,12 @@ var init_EventStream = __esm({
22090
22321
  _EventStream_errored.set(this, false);
22091
22322
  _EventStream_aborted.set(this, false);
22092
22323
  _EventStream_catchingPromiseCreated.set(this, false);
22093
- __classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((resolve, reject) => {
22094
- __classPrivateFieldSet(this, _EventStream_resolveConnectedPromise, resolve, "f");
22324
+ __classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((resolve2, reject) => {
22325
+ __classPrivateFieldSet(this, _EventStream_resolveConnectedPromise, resolve2, "f");
22095
22326
  __classPrivateFieldSet(this, _EventStream_rejectConnectedPromise, reject, "f");
22096
22327
  }), "f");
22097
- __classPrivateFieldSet(this, _EventStream_endPromise, new Promise((resolve, reject) => {
22098
- __classPrivateFieldSet(this, _EventStream_resolveEndPromise, resolve, "f");
22328
+ __classPrivateFieldSet(this, _EventStream_endPromise, new Promise((resolve2, reject) => {
22329
+ __classPrivateFieldSet(this, _EventStream_resolveEndPromise, resolve2, "f");
22099
22330
  __classPrivateFieldSet(this, _EventStream_rejectEndPromise, reject, "f");
22100
22331
  }), "f");
22101
22332
  __classPrivateFieldGet(this, _EventStream_connectedPromise, "f").catch(() => {
@@ -22179,11 +22410,11 @@ var init_EventStream = __esm({
22179
22410
  * const message = await stream.emitted('message') // rejects if the stream errors
22180
22411
  */
22181
22412
  emitted(event) {
22182
- return new Promise((resolve, reject) => {
22413
+ return new Promise((resolve2, reject) => {
22183
22414
  __classPrivateFieldSet(this, _EventStream_catchingPromiseCreated, true, "f");
22184
22415
  if (event !== "error")
22185
22416
  this.once("error", reject);
22186
- this.once(event, resolve);
22417
+ this.once(event, resolve2);
22187
22418
  });
22188
22419
  }
22189
22420
  async done() {
@@ -23252,7 +23483,7 @@ var init_ChatCompletionStream = __esm({
23252
23483
  if (done) {
23253
23484
  return { value: void 0, done: true };
23254
23485
  }
23255
- return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
23486
+ return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
23256
23487
  }
23257
23488
  const chunk = pushQueue.shift();
23258
23489
  return { value: chunk, done: false };
@@ -24235,7 +24466,7 @@ var init_AssistantStream = __esm({
24235
24466
  if (done) {
24236
24467
  return { value: void 0, done: true };
24237
24468
  }
24238
- return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
24469
+ return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
24239
24470
  }
24240
24471
  const chunk = pushQueue.shift();
24241
24472
  return { value: chunk, done: false };
@@ -26524,7 +26755,7 @@ var init_ResponseStream = __esm({
26524
26755
  if (done) {
26525
26756
  return { value: void 0, done: true };
26526
26757
  }
26527
- return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
26758
+ return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
26528
26759
  }
26529
26760
  const event = pushQueue.shift();
26530
26761
  return { value: event, done: false };
@@ -46723,8 +46954,8 @@ var init_event_stream = __esm({
46723
46954
  constructor(isComplete, extractResult) {
46724
46955
  this.isComplete = isComplete;
46725
46956
  this.extractResult = extractResult;
46726
- this.finalResultPromise = new Promise((resolve) => {
46727
- this.resolveFinalResult = resolve;
46957
+ this.finalResultPromise = new Promise((resolve2) => {
46958
+ this.resolveFinalResult = resolve2;
46728
46959
  });
46729
46960
  }
46730
46961
  push(event) {
@@ -46758,7 +46989,7 @@ var init_event_stream = __esm({
46758
46989
  } else if (this.done) {
46759
46990
  return;
46760
46991
  } else {
46761
- const result = await new Promise((resolve) => this.waiting.push(resolve));
46992
+ const result = await new Promise((resolve2) => this.waiting.push(resolve2));
46762
46993
  if (result.done)
46763
46994
  return;
46764
46995
  yield result.value;
@@ -47029,7 +47260,7 @@ var init_sleep2 = __esm({
47029
47260
  "node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs"() {
47030
47261
  "use strict";
47031
47262
  init_esm_shims();
47032
- sleep2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
47263
+ sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
47033
47264
  }
47034
47265
  });
47035
47266
 
@@ -47829,8 +48060,8 @@ var init_api_promise2 = __esm({
47829
48060
  init_parse2();
47830
48061
  APIPromise2 = class _APIPromise extends Promise {
47831
48062
  constructor(client, responsePromise, parseResponse2 = defaultParseResponse2) {
47832
- super((resolve) => {
47833
- resolve(null);
48063
+ super((resolve2) => {
48064
+ resolve2(null);
47834
48065
  });
47835
48066
  this.responsePromise = responsePromise;
47836
48067
  this.parseResponse = parseResponse2;
@@ -49791,12 +50022,12 @@ var init_BetaMessageStream = __esm({
49791
50022
  }
49792
50023
  return this._emit("error", new AnthropicError(String(error)));
49793
50024
  });
49794
- __classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((resolve, reject) => {
49795
- __classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise, resolve, "f");
50025
+ __classPrivateFieldSet2(this, _BetaMessageStream_connectedPromise, new Promise((resolve2, reject) => {
50026
+ __classPrivateFieldSet2(this, _BetaMessageStream_resolveConnectedPromise, resolve2, "f");
49796
50027
  __classPrivateFieldSet2(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
49797
50028
  }), "f");
49798
- __classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((resolve, reject) => {
49799
- __classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise, resolve, "f");
50029
+ __classPrivateFieldSet2(this, _BetaMessageStream_endPromise, new Promise((resolve2, reject) => {
50030
+ __classPrivateFieldSet2(this, _BetaMessageStream_resolveEndPromise, resolve2, "f");
49800
50031
  __classPrivateFieldSet2(this, _BetaMessageStream_rejectEndPromise, reject, "f");
49801
50032
  }), "f");
49802
50033
  __classPrivateFieldGet2(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
@@ -49966,11 +50197,11 @@ var init_BetaMessageStream = __esm({
49966
50197
  * const message = await stream.emitted('message') // rejects if the stream errors
49967
50198
  */
49968
50199
  emitted(event) {
49969
- return new Promise((resolve, reject) => {
50200
+ return new Promise((resolve2, reject) => {
49970
50201
  __classPrivateFieldSet2(this, _BetaMessageStream_catchingPromiseCreated, true, "f");
49971
50202
  if (event !== "error")
49972
50203
  this.once("error", reject);
49973
- this.once(event, resolve);
50204
+ this.once(event, resolve2);
49974
50205
  });
49975
50206
  }
49976
50207
  async done() {
@@ -50313,7 +50544,7 @@ var init_BetaMessageStream = __esm({
50313
50544
  if (done) {
50314
50545
  return { value: void 0, done: true };
50315
50546
  }
50316
- return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
50547
+ return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
50317
50548
  }
50318
50549
  const chunk = pushQueue.shift();
50319
50550
  return { value: chunk, done: false };
@@ -50388,13 +50619,13 @@ Wrap your summary in <summary></summary> tags.`;
50388
50619
 
50389
50620
  // node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs
50390
50621
  function promiseWithResolvers() {
50391
- let resolve;
50622
+ let resolve2;
50392
50623
  let reject;
50393
50624
  const promise = new Promise((res, rej) => {
50394
- resolve = res;
50625
+ resolve2 = res;
50395
50626
  reject = rej;
50396
50627
  });
50397
- return { promise, resolve, reject };
50628
+ return { promise, resolve: resolve2, reject };
50398
50629
  }
50399
50630
  async function generateToolResponse(params, lastMessage = params.messages.at(-1), requestOptions) {
50400
50631
  if (!lastMessage || lastMessage.role !== "assistant" || !lastMessage.content || typeof lastMessage.content === "string") {
@@ -52252,12 +52483,12 @@ var init_MessageStream = __esm({
52252
52483
  }
52253
52484
  return this._emit("error", new AnthropicError(String(error)));
52254
52485
  });
52255
- __classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((resolve, reject) => {
52256
- __classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise, resolve, "f");
52486
+ __classPrivateFieldSet2(this, _MessageStream_connectedPromise, new Promise((resolve2, reject) => {
52487
+ __classPrivateFieldSet2(this, _MessageStream_resolveConnectedPromise, resolve2, "f");
52257
52488
  __classPrivateFieldSet2(this, _MessageStream_rejectConnectedPromise, reject, "f");
52258
52489
  }), "f");
52259
- __classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((resolve, reject) => {
52260
- __classPrivateFieldSet2(this, _MessageStream_resolveEndPromise, resolve, "f");
52490
+ __classPrivateFieldSet2(this, _MessageStream_endPromise, new Promise((resolve2, reject) => {
52491
+ __classPrivateFieldSet2(this, _MessageStream_resolveEndPromise, resolve2, "f");
52261
52492
  __classPrivateFieldSet2(this, _MessageStream_rejectEndPromise, reject, "f");
52262
52493
  }), "f");
52263
52494
  __classPrivateFieldGet2(this, _MessageStream_connectedPromise, "f").catch(() => {
@@ -52427,11 +52658,11 @@ var init_MessageStream = __esm({
52427
52658
  * const message = await stream.emitted('message') // rejects if the stream errors
52428
52659
  */
52429
52660
  emitted(event) {
52430
- return new Promise((resolve, reject) => {
52661
+ return new Promise((resolve2, reject) => {
52431
52662
  __classPrivateFieldSet2(this, _MessageStream_catchingPromiseCreated, true, "f");
52432
52663
  if (event !== "error")
52433
52664
  this.once("error", reject);
52434
- this.once(event, resolve);
52665
+ this.once(event, resolve2);
52435
52666
  });
52436
52667
  }
52437
52668
  async done() {
@@ -52749,7 +52980,7 @@ var init_MessageStream = __esm({
52749
52980
  if (done) {
52750
52981
  return { value: void 0, done: true };
52751
52982
  }
52752
- return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
52983
+ return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
52753
52984
  }
52754
52985
  const chunk = pushQueue.shift();
52755
52986
  return { value: chunk, done: false };
@@ -56127,7 +56358,7 @@ var require_p_retry = __commonJS({
56127
56358
  return error;
56128
56359
  };
56129
56360
  var isNetworkError = (errorMessage) => networkErrorMsgs.includes(errorMessage);
56130
- var pRetry2 = (input, options) => new Promise((resolve, reject) => {
56361
+ var pRetry2 = (input, options) => new Promise((resolve2, reject) => {
56131
56362
  options = {
56132
56363
  onFailedAttempt: () => {
56133
56364
  },
@@ -56137,7 +56368,7 @@ var require_p_retry = __commonJS({
56137
56368
  const operation = retry2.operation(options);
56138
56369
  operation.attempt(async (attemptNumber) => {
56139
56370
  try {
56140
- resolve(await input(attemptNumber));
56371
+ resolve2(await input(attemptNumber));
56141
56372
  } catch (error) {
56142
56373
  if (!(error instanceof Error)) {
56143
56374
  reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
@@ -56675,8 +56906,8 @@ var require_retry3 = __commonJS({
56675
56906
  }
56676
56907
  const delay2 = getNextRetryDelay(config);
56677
56908
  err.config.retryConfig.currentRetryAttempt += 1;
56678
- const backoff = config.retryBackoff ? config.retryBackoff(err, delay2) : new Promise((resolve) => {
56679
- setTimeout(resolve, delay2);
56909
+ const backoff = config.retryBackoff ? config.retryBackoff(err, delay2) : new Promise((resolve2) => {
56910
+ setTimeout(resolve2, delay2);
56680
56911
  });
56681
56912
  if (config.onRetryAttempt) {
56682
56913
  await config.onRetryAttempt(err);
@@ -57593,8 +57824,8 @@ var require_helpers = __commonJS({
57593
57824
  function req(url, opts = {}) {
57594
57825
  const href = typeof url === "string" ? url : url.href;
57595
57826
  const req2 = (href.startsWith("https:") ? https2 : http3).request(url, opts);
57596
- const promise = new Promise((resolve, reject) => {
57597
- req2.once("response", resolve).once("error", reject).end();
57827
+ const promise = new Promise((resolve2, reject) => {
57828
+ req2.once("response", resolve2).once("error", reject).end();
57598
57829
  });
57599
57830
  req2.then = promise.then.bind(promise);
57600
57831
  return req2;
@@ -57773,7 +58004,7 @@ var require_parse_proxy_response = __commonJS({
57773
58004
  var debug_1 = __importDefault(require_src());
57774
58005
  var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
57775
58006
  function parseProxyResponse(socket) {
57776
- return new Promise((resolve, reject) => {
58007
+ return new Promise((resolve2, reject) => {
57777
58008
  let buffersLength = 0;
57778
58009
  const buffers = [];
57779
58010
  function read() {
@@ -57839,7 +58070,7 @@ var require_parse_proxy_response = __commonJS({
57839
58070
  }
57840
58071
  debug("got proxy server response: %o %o", firstLine, headers);
57841
58072
  cleanup();
57842
- resolve({
58073
+ resolve2({
57843
58074
  connect: {
57844
58075
  statusCode,
57845
58076
  statusText,
@@ -58086,7 +58317,7 @@ var require_ponyfill_es2018 = __commonJS({
58086
58317
  return new originalPromise(executor);
58087
58318
  }
58088
58319
  function promiseResolvedWith(value) {
58089
- return newPromise((resolve) => resolve(value));
58320
+ return newPromise((resolve2) => resolve2(value));
58090
58321
  }
58091
58322
  function promiseRejectedWith(reason) {
58092
58323
  return originalPromiseReject(reason);
@@ -58256,8 +58487,8 @@ var require_ponyfill_es2018 = __commonJS({
58256
58487
  return new TypeError("Cannot " + name + " a stream using a released reader");
58257
58488
  }
58258
58489
  function defaultReaderClosedPromiseInitialize(reader) {
58259
- reader._closedPromise = newPromise((resolve, reject) => {
58260
- reader._closedPromise_resolve = resolve;
58490
+ reader._closedPromise = newPromise((resolve2, reject) => {
58491
+ reader._closedPromise_resolve = resolve2;
58261
58492
  reader._closedPromise_reject = reject;
58262
58493
  });
58263
58494
  }
@@ -58431,8 +58662,8 @@ var require_ponyfill_es2018 = __commonJS({
58431
58662
  }
58432
58663
  let resolvePromise;
58433
58664
  let rejectPromise;
58434
- const promise = newPromise((resolve, reject) => {
58435
- resolvePromise = resolve;
58665
+ const promise = newPromise((resolve2, reject) => {
58666
+ resolvePromise = resolve2;
58436
58667
  rejectPromise = reject;
58437
58668
  });
58438
58669
  const readRequest = {
@@ -58537,8 +58768,8 @@ var require_ponyfill_es2018 = __commonJS({
58537
58768
  const reader = this._reader;
58538
58769
  let resolvePromise;
58539
58770
  let rejectPromise;
58540
- const promise = newPromise((resolve, reject) => {
58541
- resolvePromise = resolve;
58771
+ const promise = newPromise((resolve2, reject) => {
58772
+ resolvePromise = resolve2;
58542
58773
  rejectPromise = reject;
58543
58774
  });
58544
58775
  const readRequest = {
@@ -59557,8 +59788,8 @@ var require_ponyfill_es2018 = __commonJS({
59557
59788
  }
59558
59789
  let resolvePromise;
59559
59790
  let rejectPromise;
59560
- const promise = newPromise((resolve, reject) => {
59561
- resolvePromise = resolve;
59791
+ const promise = newPromise((resolve2, reject) => {
59792
+ resolvePromise = resolve2;
59562
59793
  rejectPromise = reject;
59563
59794
  });
59564
59795
  const readIntoRequest = {
@@ -59870,10 +60101,10 @@ var require_ponyfill_es2018 = __commonJS({
59870
60101
  wasAlreadyErroring = true;
59871
60102
  reason = void 0;
59872
60103
  }
59873
- const promise = newPromise((resolve, reject) => {
60104
+ const promise = newPromise((resolve2, reject) => {
59874
60105
  stream2._pendingAbortRequest = {
59875
60106
  _promise: void 0,
59876
- _resolve: resolve,
60107
+ _resolve: resolve2,
59877
60108
  _reject: reject,
59878
60109
  _reason: reason,
59879
60110
  _wasAlreadyErroring: wasAlreadyErroring
@@ -59890,9 +60121,9 @@ var require_ponyfill_es2018 = __commonJS({
59890
60121
  if (state === "closed" || state === "errored") {
59891
60122
  return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
59892
60123
  }
59893
- const promise = newPromise((resolve, reject) => {
60124
+ const promise = newPromise((resolve2, reject) => {
59894
60125
  const closeRequest = {
59895
- _resolve: resolve,
60126
+ _resolve: resolve2,
59896
60127
  _reject: reject
59897
60128
  };
59898
60129
  stream2._closeRequest = closeRequest;
@@ -59905,9 +60136,9 @@ var require_ponyfill_es2018 = __commonJS({
59905
60136
  return promise;
59906
60137
  }
59907
60138
  function WritableStreamAddWriteRequest(stream2) {
59908
- const promise = newPromise((resolve, reject) => {
60139
+ const promise = newPromise((resolve2, reject) => {
59909
60140
  const writeRequest = {
59910
- _resolve: resolve,
60141
+ _resolve: resolve2,
59911
60142
  _reject: reject
59912
60143
  };
59913
60144
  stream2._writeRequests.push(writeRequest);
@@ -60523,8 +60754,8 @@ var require_ponyfill_es2018 = __commonJS({
60523
60754
  return new TypeError("Cannot " + name + " a stream using a released writer");
60524
60755
  }
60525
60756
  function defaultWriterClosedPromiseInitialize(writer) {
60526
- writer._closedPromise = newPromise((resolve, reject) => {
60527
- writer._closedPromise_resolve = resolve;
60757
+ writer._closedPromise = newPromise((resolve2, reject) => {
60758
+ writer._closedPromise_resolve = resolve2;
60528
60759
  writer._closedPromise_reject = reject;
60529
60760
  writer._closedPromiseState = "pending";
60530
60761
  });
@@ -60560,8 +60791,8 @@ var require_ponyfill_es2018 = __commonJS({
60560
60791
  writer._closedPromiseState = "resolved";
60561
60792
  }
60562
60793
  function defaultWriterReadyPromiseInitialize(writer) {
60563
- writer._readyPromise = newPromise((resolve, reject) => {
60564
- writer._readyPromise_resolve = resolve;
60794
+ writer._readyPromise = newPromise((resolve2, reject) => {
60795
+ writer._readyPromise_resolve = resolve2;
60565
60796
  writer._readyPromise_reject = reject;
60566
60797
  });
60567
60798
  writer._readyPromiseState = "pending";
@@ -60648,7 +60879,7 @@ var require_ponyfill_es2018 = __commonJS({
60648
60879
  source._disturbed = true;
60649
60880
  let shuttingDown = false;
60650
60881
  let currentWrite = promiseResolvedWith(void 0);
60651
- return newPromise((resolve, reject) => {
60882
+ return newPromise((resolve2, reject) => {
60652
60883
  let abortAlgorithm;
60653
60884
  if (signal !== void 0) {
60654
60885
  abortAlgorithm = () => {
@@ -60793,7 +61024,7 @@ var require_ponyfill_es2018 = __commonJS({
60793
61024
  if (isError) {
60794
61025
  reject(error);
60795
61026
  } else {
60796
- resolve(void 0);
61027
+ resolve2(void 0);
60797
61028
  }
60798
61029
  return null;
60799
61030
  }
@@ -61074,8 +61305,8 @@ var require_ponyfill_es2018 = __commonJS({
61074
61305
  let branch1;
61075
61306
  let branch2;
61076
61307
  let resolveCancelPromise;
61077
- const cancelPromise = newPromise((resolve) => {
61078
- resolveCancelPromise = resolve;
61308
+ const cancelPromise = newPromise((resolve2) => {
61309
+ resolveCancelPromise = resolve2;
61079
61310
  });
61080
61311
  function pullAlgorithm() {
61081
61312
  if (reading) {
@@ -61166,8 +61397,8 @@ var require_ponyfill_es2018 = __commonJS({
61166
61397
  let branch1;
61167
61398
  let branch2;
61168
61399
  let resolveCancelPromise;
61169
- const cancelPromise = newPromise((resolve) => {
61170
- resolveCancelPromise = resolve;
61400
+ const cancelPromise = newPromise((resolve2) => {
61401
+ resolveCancelPromise = resolve2;
61171
61402
  });
61172
61403
  function forwardReaderError(thisReader) {
61173
61404
  uponRejection(thisReader._closedPromise, (r2) => {
@@ -61947,8 +62178,8 @@ var require_ponyfill_es2018 = __commonJS({
61947
62178
  const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
61948
62179
  const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
61949
62180
  let startPromise_resolve;
61950
- const startPromise = newPromise((resolve) => {
61951
- startPromise_resolve = resolve;
62181
+ const startPromise = newPromise((resolve2) => {
62182
+ startPromise_resolve = resolve2;
61952
62183
  });
61953
62184
  InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
61954
62185
  SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
@@ -62041,8 +62272,8 @@ var require_ponyfill_es2018 = __commonJS({
62041
62272
  if (stream2._backpressureChangePromise !== void 0) {
62042
62273
  stream2._backpressureChangePromise_resolve();
62043
62274
  }
62044
- stream2._backpressureChangePromise = newPromise((resolve) => {
62045
- stream2._backpressureChangePromise_resolve = resolve;
62275
+ stream2._backpressureChangePromise = newPromise((resolve2) => {
62276
+ stream2._backpressureChangePromise_resolve = resolve2;
62046
62277
  });
62047
62278
  stream2._backpressure = backpressure;
62048
62279
  }
@@ -62210,8 +62441,8 @@ var require_ponyfill_es2018 = __commonJS({
62210
62441
  return controller._finishPromise;
62211
62442
  }
62212
62443
  const readable = stream2._readable;
62213
- controller._finishPromise = newPromise((resolve, reject) => {
62214
- controller._finishPromise_resolve = resolve;
62444
+ controller._finishPromise = newPromise((resolve2, reject) => {
62445
+ controller._finishPromise_resolve = resolve2;
62215
62446
  controller._finishPromise_reject = reject;
62216
62447
  });
62217
62448
  const cancelPromise = controller._cancelAlgorithm(reason);
@@ -62237,8 +62468,8 @@ var require_ponyfill_es2018 = __commonJS({
62237
62468
  return controller._finishPromise;
62238
62469
  }
62239
62470
  const readable = stream2._readable;
62240
- controller._finishPromise = newPromise((resolve, reject) => {
62241
- controller._finishPromise_resolve = resolve;
62471
+ controller._finishPromise = newPromise((resolve2, reject) => {
62472
+ controller._finishPromise_resolve = resolve2;
62242
62473
  controller._finishPromise_reject = reject;
62243
62474
  });
62244
62475
  const flushPromise = controller._flushAlgorithm();
@@ -62268,8 +62499,8 @@ var require_ponyfill_es2018 = __commonJS({
62268
62499
  return controller._finishPromise;
62269
62500
  }
62270
62501
  const writable = stream2._writable;
62271
- controller._finishPromise = newPromise((resolve, reject) => {
62272
- controller._finishPromise_resolve = resolve;
62502
+ controller._finishPromise = newPromise((resolve2, reject) => {
62503
+ controller._finishPromise_resolve = resolve2;
62273
62504
  controller._finishPromise_reject = reject;
62274
62505
  });
62275
62506
  const cancelPromise = controller._cancelAlgorithm(reason);
@@ -64256,7 +64487,7 @@ import zlib from "zlib";
64256
64487
  import Stream4, { PassThrough as PassThrough2, pipeline as pump } from "stream";
64257
64488
  import { Buffer as Buffer3 } from "buffer";
64258
64489
  async function fetch2(url, options_) {
64259
- return new Promise((resolve, reject) => {
64490
+ return new Promise((resolve2, reject) => {
64260
64491
  const request = new Request2(url, options_);
64261
64492
  const { parsedURL, options } = getNodeRequestOptions(request);
64262
64493
  if (!supportedSchemas.has(parsedURL.protocol)) {
@@ -64265,7 +64496,7 @@ async function fetch2(url, options_) {
64265
64496
  if (parsedURL.protocol === "data:") {
64266
64497
  const data = dist_default(request.url);
64267
64498
  const response2 = new Response2(data, { headers: { "Content-Type": data.typeFull } });
64268
- resolve(response2);
64499
+ resolve2(response2);
64269
64500
  return;
64270
64501
  }
64271
64502
  const send = (parsedURL.protocol === "https:" ? https : http2).request;
@@ -64387,7 +64618,7 @@ async function fetch2(url, options_) {
64387
64618
  if (responseReferrerPolicy) {
64388
64619
  requestOptions.referrerPolicy = responseReferrerPolicy;
64389
64620
  }
64390
- resolve(fetch2(new Request2(locationURL, requestOptions)));
64621
+ resolve2(fetch2(new Request2(locationURL, requestOptions)));
64391
64622
  finalize();
64392
64623
  return;
64393
64624
  }
@@ -64420,7 +64651,7 @@ async function fetch2(url, options_) {
64420
64651
  const codings = headers.get("Content-Encoding");
64421
64652
  if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
64422
64653
  response = new Response2(body, responseOptions);
64423
- resolve(response);
64654
+ resolve2(response);
64424
64655
  return;
64425
64656
  }
64426
64657
  const zlibOptions = {
@@ -64434,7 +64665,7 @@ async function fetch2(url, options_) {
64434
64665
  }
64435
64666
  });
64436
64667
  response = new Response2(body, responseOptions);
64437
- resolve(response);
64668
+ resolve2(response);
64438
64669
  return;
64439
64670
  }
64440
64671
  if (codings === "deflate" || codings === "x-deflate") {
@@ -64458,12 +64689,12 @@ async function fetch2(url, options_) {
64458
64689
  });
64459
64690
  }
64460
64691
  response = new Response2(body, responseOptions);
64461
- resolve(response);
64692
+ resolve2(response);
64462
64693
  });
64463
64694
  raw.once("end", () => {
64464
64695
  if (!response) {
64465
64696
  response = new Response2(body, responseOptions);
64466
- resolve(response);
64697
+ resolve2(response);
64467
64698
  }
64468
64699
  });
64469
64700
  return;
@@ -64475,11 +64706,11 @@ async function fetch2(url, options_) {
64475
64706
  }
64476
64707
  });
64477
64708
  response = new Response2(body, responseOptions);
64478
- resolve(response);
64709
+ resolve2(response);
64479
64710
  return;
64480
64711
  }
64481
64712
  response = new Response2(body, responseOptions);
64482
- resolve(response);
64713
+ resolve2(response);
64483
64714
  });
64484
64715
  writeToStream(request_, request).catch(reject);
64485
64716
  });
@@ -70602,7 +70833,7 @@ var require_jwtaccess = __commonJS({
70602
70833
  }
70603
70834
  }
70604
70835
  fromStreamAsync(inputStream) {
70605
- return new Promise((resolve, reject) => {
70836
+ return new Promise((resolve2, reject) => {
70606
70837
  if (!inputStream) {
70607
70838
  reject(new Error("Must pass in a stream containing the service account auth settings."));
70608
70839
  }
@@ -70611,7 +70842,7 @@ var require_jwtaccess = __commonJS({
70611
70842
  try {
70612
70843
  const data = JSON.parse(s2);
70613
70844
  this.fromJSON(data);
70614
- resolve();
70845
+ resolve2();
70615
70846
  } catch (err) {
70616
70847
  reject(err);
70617
70848
  }
@@ -70851,7 +71082,7 @@ var require_jwtclient = __commonJS({
70851
71082
  }
70852
71083
  }
70853
71084
  fromStreamAsync(inputStream) {
70854
- return new Promise((resolve, reject) => {
71085
+ return new Promise((resolve2, reject) => {
70855
71086
  if (!inputStream) {
70856
71087
  throw new Error("Must pass in a stream containing the service account auth settings.");
70857
71088
  }
@@ -70860,7 +71091,7 @@ var require_jwtclient = __commonJS({
70860
71091
  try {
70861
71092
  const data = JSON.parse(s2);
70862
71093
  this.fromJSON(data);
70863
- resolve();
71094
+ resolve2();
70864
71095
  } catch (e2) {
70865
71096
  reject(e2);
70866
71097
  }
@@ -70994,7 +71225,7 @@ var require_refreshclient = __commonJS({
70994
71225
  }
70995
71226
  }
70996
71227
  async fromStreamAsync(inputStream) {
70997
- return new Promise((resolve, reject) => {
71228
+ return new Promise((resolve2, reject) => {
70998
71229
  if (!inputStream) {
70999
71230
  return reject(new Error("Must pass in a stream containing the user refresh token."));
71000
71231
  }
@@ -71003,7 +71234,7 @@ var require_refreshclient = __commonJS({
71003
71234
  try {
71004
71235
  const data = JSON.parse(s2);
71005
71236
  this.fromJSON(data);
71006
- return resolve();
71237
+ return resolve2();
71007
71238
  } catch (err) {
71008
71239
  return reject(err);
71009
71240
  }
@@ -72849,7 +73080,7 @@ var require_pluggable_auth_handler = __commonJS({
72849
73080
  * @return A promise that resolves with the executable response.
72850
73081
  */
72851
73082
  retrieveResponseFromExecutable(envMap) {
72852
- return new Promise((resolve, reject) => {
73083
+ return new Promise((resolve2, reject) => {
72853
73084
  const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
72854
73085
  env: { ...process.env, ...Object.fromEntries(envMap) }
72855
73086
  });
@@ -72871,7 +73102,7 @@ var require_pluggable_auth_handler = __commonJS({
72871
73102
  try {
72872
73103
  const responseJson = JSON.parse(output);
72873
73104
  const response = new executable_response_1.ExecutableResponse(responseJson);
72874
- return resolve(response);
73105
+ return resolve2(response);
72875
73106
  } catch (error) {
72876
73107
  if (error instanceof executable_response_1.ExecutableResponseError) {
72877
73108
  return reject(error);
@@ -74066,7 +74297,7 @@ var require_googleauth = __commonJS({
74066
74297
  }
74067
74298
  }
74068
74299
  fromStreamAsync(inputStream, options) {
74069
- return new Promise((resolve, reject) => {
74300
+ return new Promise((resolve2, reject) => {
74070
74301
  if (!inputStream) {
74071
74302
  throw new Error("Must pass in a stream containing the Google auth settings.");
74072
74303
  }
@@ -74076,7 +74307,7 @@ var require_googleauth = __commonJS({
74076
74307
  try {
74077
74308
  const data = JSON.parse(chunks.join(""));
74078
74309
  const r2 = this._cacheClientFromJSON(data, options);
74079
- return resolve(r2);
74310
+ return resolve2(r2);
74080
74311
  } catch (err) {
74081
74312
  if (!this.keyFilename)
74082
74313
  throw err;
@@ -74086,7 +74317,7 @@ var require_googleauth = __commonJS({
74086
74317
  });
74087
74318
  this.cachedCredential = client;
74088
74319
  this.setGapicJWTValues(client);
74089
- return resolve(client);
74320
+ return resolve2(client);
74090
74321
  }
74091
74322
  } catch (err) {
74092
74323
  return reject(err);
@@ -74122,17 +74353,17 @@ var require_googleauth = __commonJS({
74122
74353
  * Run the Google Cloud SDK command that prints the default project ID
74123
74354
  */
74124
74355
  async getDefaultServiceProjectId() {
74125
- return new Promise((resolve) => {
74356
+ return new Promise((resolve2) => {
74126
74357
  (0, child_process_1.exec)("gcloud config config-helper --format json", (err, stdout) => {
74127
74358
  if (!err && stdout) {
74128
74359
  try {
74129
74360
  const projectId = JSON.parse(stdout).configuration.properties.core.project;
74130
- resolve(projectId);
74361
+ resolve2(projectId);
74131
74362
  return;
74132
74363
  } catch (e2) {
74133
74364
  }
74134
74365
  }
74135
- resolve(null);
74366
+ resolve2(null);
74136
74367
  });
74137
74368
  });
74138
74369
  }
@@ -77054,7 +77285,7 @@ var require_websocket = __commonJS({
77054
77285
  var http3 = __require("http");
77055
77286
  var net = __require("net");
77056
77287
  var tls = __require("tls");
77057
- var { randomBytes, createHash: createHash14 } = __require("crypto");
77288
+ var { randomBytes, createHash: createHash15 } = __require("crypto");
77058
77289
  var { Duplex, Readable: Readable2 } = __require("stream");
77059
77290
  var { URL: URL2 } = __require("url");
77060
77291
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -77722,7 +77953,7 @@ var require_websocket = __commonJS({
77722
77953
  abortHandshake(websocket, socket, "Invalid Upgrade header");
77723
77954
  return;
77724
77955
  }
77725
- const digest2 = createHash14("sha1").update(key + GUID).digest("base64");
77956
+ const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
77726
77957
  if (res.headers["sec-websocket-accept"] !== digest2) {
77727
77958
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
77728
77959
  return;
@@ -78094,7 +78325,7 @@ var require_websocket_server = __commonJS({
78094
78325
  var EventEmitter = __require("events");
78095
78326
  var http3 = __require("http");
78096
78327
  var { Duplex } = __require("stream");
78097
- var { createHash: createHash14 } = __require("crypto");
78328
+ var { createHash: createHash15 } = __require("crypto");
78098
78329
  var extension3 = require_extension();
78099
78330
  var PerMessageDeflate2 = require_permessage_deflate();
78100
78331
  var subprotocol2 = require_subprotocol();
@@ -78401,7 +78632,7 @@ var require_websocket_server = __commonJS({
78401
78632
  );
78402
78633
  }
78403
78634
  if (this._state > RUNNING) return abortHandshake(socket, 503);
78404
- const digest2 = createHash14("sha1").update(key + GUID).digest("base64");
78635
+ const digest2 = createHash15("sha1").update(key + GUID).digest("base64");
78405
78636
  const headers = [
78406
78637
  "HTTP/1.1 101 Switching Protocols",
78407
78638
  "Upgrade: websocket",
@@ -81810,14 +82041,14 @@ function __asyncValues(o) {
81810
82041
  }, i2);
81811
82042
  function verb(n) {
81812
82043
  i2[n] = o[n] && function(v) {
81813
- return new Promise(function(resolve, reject) {
81814
- v = o[n](v), settle(resolve, reject, v.done, v.value);
82044
+ return new Promise(function(resolve2, reject) {
82045
+ v = o[n](v), settle(resolve2, reject, v.done, v.value);
81815
82046
  });
81816
82047
  };
81817
82048
  }
81818
- function settle(resolve, reject, d, v) {
82049
+ function settle(resolve2, reject, d, v) {
81819
82050
  Promise.resolve(v).then(function(v2) {
81820
- resolve({ value: v2, done: d });
82051
+ resolve2({ value: v2, done: d });
81821
82052
  }, reject);
81822
82053
  }
81823
82054
  }
@@ -92187,8 +92418,8 @@ var init_node = __esm({
92187
92418
  const url = `${websocketBaseUrl}/ws/google.ai.generativelanguage.${apiVersion}.GenerativeService.BidiGenerateMusic?key=${apiKey}`;
92188
92419
  let onopenResolve = () => {
92189
92420
  };
92190
- const onopenPromise = new Promise((resolve) => {
92191
- onopenResolve = resolve;
92421
+ const onopenPromise = new Promise((resolve2) => {
92422
+ onopenResolve = resolve2;
92192
92423
  });
92193
92424
  const callbacks = params.callbacks;
92194
92425
  const onopenAwaitedCallback = function() {
@@ -92394,8 +92625,8 @@ var init_node = __esm({
92394
92625
  }
92395
92626
  let onopenResolve = () => {
92396
92627
  };
92397
- const onopenPromise = new Promise((resolve) => {
92398
- onopenResolve = resolve;
92628
+ const onopenPromise = new Promise((resolve2) => {
92629
+ onopenResolve = resolve2;
92399
92630
  });
92400
92631
  const callbacks = params.callbacks;
92401
92632
  const onopenAwaitedCallback = function() {
@@ -94743,7 +94974,7 @@ var init_node = __esm({
94743
94974
  return void 0;
94744
94975
  }
94745
94976
  };
94746
- sleep$1 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
94977
+ sleep$1 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
94747
94978
  FallbackEncoder3 = ({ headers, body }) => {
94748
94979
  return {
94749
94980
  bodyHeaders: {
@@ -95252,8 +95483,8 @@ ${underline}`);
95252
95483
  };
95253
95484
  APIPromise3 = class _APIPromise extends Promise {
95254
95485
  constructor(client, responsePromise, parseResponse2 = defaultParseResponse3) {
95255
- super((resolve) => {
95256
- resolve(null);
95486
+ super((resolve2) => {
95487
+ resolve2(null);
95257
95488
  });
95258
95489
  this.responsePromise = responsePromise;
95259
95490
  this.parseResponse = parseResponse2;
@@ -98484,7 +98715,7 @@ function retryIntervalFromResponse(res) {
98484
98715
  return 0;
98485
98716
  }
98486
98717
  async function delay(delay2) {
98487
- return new Promise((resolve) => setTimeout(resolve, delay2));
98718
+ return new Promise((resolve2) => setTimeout(resolve2, delay2));
98488
98719
  }
98489
98720
  var defaultBackoff, PermanentError, TemporaryError, codeRangeRE2;
98490
98721
  var init_retries = __esm({
@@ -136063,12 +136294,12 @@ function capRetryDelayMs(delayMs, options) {
136063
136294
  return maxRetryDelayMs > 0 ? Math.min(delayMs, maxRetryDelayMs) : delayMs;
136064
136295
  }
136065
136296
  function sleep4(ms, signal) {
136066
- return new Promise((resolve, reject) => {
136297
+ return new Promise((resolve2, reject) => {
136067
136298
  if (signal?.aborted) {
136068
136299
  reject(new Error("Request was aborted"));
136069
136300
  return;
136070
136301
  }
136071
- const timeout = setTimeout(resolve, ms);
136302
+ const timeout = setTimeout(resolve2, ms);
136072
136303
  signal?.addEventListener("abort", () => {
136073
136304
  clearTimeout(timeout);
136074
136305
  reject(new Error("Request was aborted"));
@@ -136400,7 +136631,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
136400
136631
  }
136401
136632
  const wsHeaders = headersToRecord(headers);
136402
136633
  delete wsHeaders["OpenAI-Beta"];
136403
- return new Promise((resolve, reject) => {
136634
+ return new Promise((resolve2, reject) => {
136404
136635
  let settled = false;
136405
136636
  let timeout;
136406
136637
  let socket;
@@ -136435,7 +136666,7 @@ async function connectWebSocket(url, headers, signal, connectTimeoutMs = DEFAULT
136435
136666
  return;
136436
136667
  settled = true;
136437
136668
  cleanup();
136438
- resolve(socket);
136669
+ resolve2(socket);
136439
136670
  };
136440
136671
  const onError = (event) => {
136441
136672
  fail2(extractWebSocketError(event));
@@ -136592,9 +136823,9 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
136592
136823
  const wake = () => {
136593
136824
  if (!pending)
136594
136825
  return;
136595
- const resolve = pending;
136826
+ const resolve2 = pending;
136596
136827
  pending = null;
136597
- resolve();
136828
+ resolve2();
136598
136829
  };
136599
136830
  const onMessage = (event) => {
136600
136831
  void (async () => {
@@ -136661,8 +136892,8 @@ async function* parseWebSocket(socket, signal, idleTimeoutMs) {
136661
136892
  if (done)
136662
136893
  break;
136663
136894
  let timeout;
136664
- await new Promise((resolve, reject) => {
136665
- pending = resolve;
136895
+ await new Promise((resolve2, reject) => {
136896
+ pending = resolve2;
136666
136897
  if (idleTimeoutMs !== void 0 && idleTimeoutMs > 0) {
136667
136898
  timeout = setTimeout(() => {
136668
136899
  const error = new Error(`WebSocket idle timeout after ${idleTimeoutMs}ms`);
@@ -147072,6 +147303,350 @@ var init_exclude3 = __esm({
147072
147303
  }
147073
147304
  });
147074
147305
 
147306
+ // src/codegraph/semantic-provider.ts
147307
+ import { createHash as createHash8 } from "crypto";
147308
+ import "fs";
147309
+ import { resolve } from "path";
147310
+ import ts from "typescript";
147311
+ function hashText(value) {
147312
+ return createHash8("sha256").update(value).digest("hex");
147313
+ }
147314
+ function canonicalPath(value) {
147315
+ const normalized = resolve(value).replace(/\\/g, "/");
147316
+ return process.platform === "win32" ? normalized.toLowerCase() : normalized;
147317
+ }
147318
+ function isInside(root, candidate) {
147319
+ const rootPath = canonicalPath(root).replace(/\/$/, "");
147320
+ const candidatePath = canonicalPath(candidate);
147321
+ return candidatePath === rootPath || candidatePath.startsWith(`${rootPath}/`);
147322
+ }
147323
+ function scriptKind(path21) {
147324
+ if (path21.endsWith(".tsx")) return ts.ScriptKind.TSX;
147325
+ if (path21.endsWith(".jsx")) return ts.ScriptKind.JSX;
147326
+ if (path21.endsWith(".json")) return ts.ScriptKind.JSON;
147327
+ if (path21.endsWith(".js") || path21.endsWith(".mjs") || path21.endsWith(".cjs")) return ts.ScriptKind.JS;
147328
+ return ts.ScriptKind.TS;
147329
+ }
147330
+ function isTestPath(path21) {
147331
+ return /(^|[/\\])__tests__([/\\])|(?:\.test|\.spec)\.[^.]+$/i.test(path21);
147332
+ }
147333
+ function declarationName(node) {
147334
+ const named = node;
147335
+ const name = named.name;
147336
+ return name && ts.isIdentifier(name) ? name.text : void 0;
147337
+ }
147338
+ function symbolKind(node) {
147339
+ if (ts.isFunctionDeclaration(node)) return "function";
147340
+ if (ts.isClassDeclaration(node)) return "class";
147341
+ if (ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isConstructorDeclaration(node) || ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node)) return "method";
147342
+ if (ts.isInterfaceDeclaration(node)) return "interface";
147343
+ if (ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node)) return "type";
147344
+ if (ts.isEnumMember(node)) return "constant";
147345
+ if (ts.isPropertyDeclaration(node) || ts.isPropertySignature(node)) return "property";
147346
+ if (ts.isVariableDeclaration(node)) return node.initializer && (ts.isFunctionExpression(node.initializer) || ts.isArrowFunction(node.initializer)) ? "function" : "constant";
147347
+ return void 0;
147348
+ }
147349
+ function isDeclarationNode(node) {
147350
+ return Boolean(symbolKind(node) && declarationName(node));
147351
+ }
147352
+ function qualifiedName(node, name, ordinalByKey) {
147353
+ const parts = [name];
147354
+ let parent = node.parent;
147355
+ while (parent && !ts.isSourceFile(parent)) {
147356
+ if (isDeclarationNode(parent)) {
147357
+ const parentName = declarationName(parent);
147358
+ if (parentName) parts.unshift(parentName);
147359
+ }
147360
+ parent = parent.parent;
147361
+ }
147362
+ const base = parts.join("::");
147363
+ const key = `${base}
147364
+ ${symbolKind(node)}`;
147365
+ const ordinal = ordinalByKey.get(key) ?? 0;
147366
+ ordinalByKey.set(key, ordinal + 1);
147367
+ return ordinal === 0 ? base : `${base}#${ordinal + 1}`;
147368
+ }
147369
+ function lineAt(sourceFile, position) {
147370
+ return sourceFile.getLineAndCharacterOfPosition(position).line + 1;
147371
+ }
147372
+ function signatureFor(checker, node, sourceFile) {
147373
+ const signature = ts.isFunctionLike(node) ? checker.getSignatureFromDeclaration(node) : void 0;
147374
+ if (signature) {
147375
+ try {
147376
+ return checker.signatureToString(signature, node, ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope).slice(0, 240);
147377
+ } catch {
147378
+ }
147379
+ }
147380
+ const text2 = sourceFile.text.slice(node.getStart(sourceFile), Math.min(node.end, node.getStart(sourceFile) + 240));
147381
+ return text2.replace(/\s+/g, " ").trim() || void 0;
147382
+ }
147383
+ function makeCompilerOptions(projectRoot) {
147384
+ const configPath = ts.findConfigFile(projectRoot, ts.sys.fileExists, "tsconfig.json");
147385
+ let options = {
147386
+ allowJs: true,
147387
+ checkJs: false,
147388
+ noEmit: true,
147389
+ noLib: true,
147390
+ skipLibCheck: true,
147391
+ module: ts.ModuleKind.ESNext,
147392
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
147393
+ target: ts.ScriptTarget.ES2022,
147394
+ jsx: ts.JsxEmit.Preserve,
147395
+ types: []
147396
+ };
147397
+ if (configPath) {
147398
+ try {
147399
+ const config = ts.readConfigFile(configPath, ts.sys.readFile);
147400
+ if (!config.error) {
147401
+ const parsed = ts.parseJsonConfigFileContent(config.config, ts.sys, projectRoot);
147402
+ options = { ...options, ...parsed.options, noEmit: true, noLib: true, skipLibCheck: true, allowJs: true, checkJs: false, types: [] };
147403
+ }
147404
+ } catch {
147405
+ }
147406
+ }
147407
+ return options;
147408
+ }
147409
+ function resolveLocalFile(projectRoot, filesByCanonicalPath, resolvedFileName) {
147410
+ if (!resolvedFileName || !isInside(projectRoot, resolvedFileName)) return void 0;
147411
+ return filesByCanonicalPath.get(canonicalPath(resolvedFileName));
147412
+ }
147413
+ function isSemanticLanguage(language) {
147414
+ return Boolean(language && SUPPORTED_LANGUAGES.has(language));
147415
+ }
147416
+ function buildTypeScriptSemanticIndex(input) {
147417
+ const started = Date.now();
147418
+ const semanticFiles = input.files.filter((file) => isSemanticLanguage(file.language) && !isCodeGraphExcludedPath(file.path, input.exclude));
147419
+ if (semanticFiles.length === 0) {
147420
+ return { symbols: [], edges: [], parsedFiles: 0, parserErrors: 0, unresolvedCalls: 0, durationMs: Date.now() - started, diagnostics: [] };
147421
+ }
147422
+ const projectRoot = resolve(input.projectRoot);
147423
+ const filesByCanonicalPath = new Map(semanticFiles.map((file) => [canonicalPath(resolve(projectRoot, file.path)), file]));
147424
+ const includePaths = input.includePaths ? new Set(input.includePaths.map(normalizeCodePath)) : void 0;
147425
+ const includedFileIds = new Set(
147426
+ semanticFiles.filter((file) => !includePaths || includePaths.has(normalizeCodePath(file.path))).map((file) => file.id)
147427
+ );
147428
+ const rootNames = semanticFiles.map((file) => resolve(projectRoot, file.path));
147429
+ const baseHost = ts.createCompilerHost(makeCompilerOptions(projectRoot), true);
147430
+ const compilerOptions = makeCompilerOptions(projectRoot);
147431
+ const host = {
147432
+ ...baseHost,
147433
+ getCurrentDirectory: () => projectRoot,
147434
+ fileExists: (fileName) => isInside(projectRoot, fileName) && baseHost.fileExists(fileName),
147435
+ readFile: (fileName) => isInside(projectRoot, fileName) ? baseHost.readFile(fileName) : void 0,
147436
+ realpath: (fileName) => fileName,
147437
+ getSourceFile: (fileName, languageVersion, onError, shouldCreateNewSourceFile) => {
147438
+ if (!isInside(projectRoot, fileName)) return void 0;
147439
+ const text2 = baseHost.readFile(fileName);
147440
+ if (text2 === void 0) return void 0;
147441
+ return ts.createSourceFile(fileName, text2, languageVersion, true, scriptKind(fileName));
147442
+ }
147443
+ };
147444
+ const program = ts.createProgram({ rootNames, options: compilerOptions, host });
147445
+ const checker = program.getTypeChecker();
147446
+ const symbols = [];
147447
+ const allSymbols = [];
147448
+ const declarationToRecord = /* @__PURE__ */ new Map();
147449
+ const checkerToRecord = /* @__PURE__ */ new Map();
147450
+ const declarationNameNodes = /* @__PURE__ */ new Set();
147451
+ const ordinalByKey = /* @__PURE__ */ new Map();
147452
+ const sourceFiles = program.getSourceFiles().filter((sourceFile) => filesByCanonicalPath.has(canonicalPath(sourceFile.fileName)));
147453
+ for (const sourceFile of sourceFiles) {
147454
+ const file = filesByCanonicalPath.get(canonicalPath(sourceFile.fileName));
147455
+ if (!file) continue;
147456
+ const visitDeclarations = (node) => {
147457
+ if (isDeclarationNode(node)) {
147458
+ const name = declarationName(node);
147459
+ const kind = symbolKind(node);
147460
+ if (name && kind) {
147461
+ const qName = qualifiedName(node, name, ordinalByKey);
147462
+ const start = node.getStart(sourceFile);
147463
+ const symbol = {
147464
+ id: makeCodeSymbolId({ projectId: input.projectId, path: file.path, qualifiedName: qName, kind }),
147465
+ projectId: input.projectId,
147466
+ fileId: file.id || makeCodeFileId(input.projectId, file.path),
147467
+ path: file.path,
147468
+ name,
147469
+ qualifiedName: qName,
147470
+ kind,
147471
+ startLine: lineAt(sourceFile, start),
147472
+ endLine: lineAt(sourceFile, node.end),
147473
+ signature: signatureFor(checker, node, sourceFile),
147474
+ contentHash: hashText(sourceFile.text.slice(start, node.end)),
147475
+ indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
147476
+ source: SEMANTIC_SOURCE
147477
+ };
147478
+ const namedNode = node;
147479
+ const checkerSymbol = namedNode.name ? checker.getSymbolAtLocation(namedNode.name) : void 0;
147480
+ const record80 = { node, symbol, ...checkerSymbol ? { checkerSymbol } : {} };
147481
+ allSymbols.push(symbol);
147482
+ if (!includePaths || includePaths.has(normalizeCodePath(file.path))) symbols.push(symbol);
147483
+ declarationToRecord.set(node, record80);
147484
+ if (checkerSymbol) {
147485
+ checkerToRecord.set(checkerSymbol, record80);
147486
+ for (const declaration of checkerSymbol.declarations ?? []) declarationToRecord.set(declaration, record80);
147487
+ }
147488
+ if (namedNode.name) declarationNameNodes.add(namedNode.name);
147489
+ }
147490
+ }
147491
+ node.forEachChild(visitDeclarations);
147492
+ };
147493
+ visitDeclarations(sourceFile);
147494
+ }
147495
+ const edges = /* @__PURE__ */ new Map();
147496
+ const addEdge = (inputEdge) => {
147497
+ const from = inputEdge.fromSymbolId ?? inputEdge.fromFileId ?? "";
147498
+ const to = inputEdge.toSymbolId ?? inputEdge.toFileId ?? (inputEdge.type === "imports" && inputEdge.evidence ? `unresolved:${inputEdge.evidence}` : "");
147499
+ if (!from || !to) return;
147500
+ if (includePaths) {
147501
+ const endpointFileIds = /* @__PURE__ */ new Set();
147502
+ if (inputEdge.fromFileId) endpointFileIds.add(inputEdge.fromFileId);
147503
+ if (inputEdge.toFileId) endpointFileIds.add(inputEdge.toFileId);
147504
+ for (const symbol of allSymbols) {
147505
+ if (symbol.id === inputEdge.fromSymbolId || symbol.id === inputEdge.toSymbolId) endpointFileIds.add(symbol.fileId);
147506
+ }
147507
+ if (![...endpointFileIds].some((fileId) => includedFileIds.has(fileId))) return;
147508
+ }
147509
+ const id = makeCodeEdgeId(input.projectId, from, inputEdge.type, to);
147510
+ if (edges.has(id)) return;
147511
+ edges.set(id, {
147512
+ ...inputEdge,
147513
+ id,
147514
+ projectId: input.projectId,
147515
+ indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
147516
+ source: SEMANTIC_SOURCE
147517
+ });
147518
+ };
147519
+ const resolveRecord = (symbol) => {
147520
+ if (!symbol) return void 0;
147521
+ let target = symbol;
147522
+ if (target.flags & ts.SymbolFlags.Alias) {
147523
+ try {
147524
+ target = checker.getAliasedSymbol(target);
147525
+ } catch {
147526
+ }
147527
+ }
147528
+ return checkerToRecord.get(target) ?? (target.declarations ?? []).map((declaration) => declarationToRecord.get(declaration)).find(Boolean);
147529
+ };
147530
+ const currentRecord = (node) => {
147531
+ let parent = node;
147532
+ while (parent) {
147533
+ const record80 = declarationToRecord.get(parent);
147534
+ if (record80) return record80;
147535
+ parent = parent.parent;
147536
+ }
147537
+ return void 0;
147538
+ };
147539
+ const fileForSource = (sourceFile) => filesByCanonicalPath.get(canonicalPath(sourceFile.fileName));
147540
+ const addFileRelation = (sourceFile, target, type, node, evidence) => {
147541
+ const source = fileForSource(sourceFile);
147542
+ if (!source || source.id === target?.id) return;
147543
+ addEdge({
147544
+ fromFileId: source.id,
147545
+ ...target ? { toFileId: target.id } : {},
147546
+ type,
147547
+ confidence: target ? 0.99 : 0.55,
147548
+ evidence: evidence ?? `${type} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
147549
+ });
147550
+ };
147551
+ const moduleTarget = (sourceFile, moduleName) => {
147552
+ const resolvedModule = ts.resolveModuleName(moduleName, sourceFile.fileName, compilerOptions, host).resolvedModule;
147553
+ return resolveLocalFile(projectRoot, filesByCanonicalPath, resolvedModule?.resolvedFileName);
147554
+ };
147555
+ let unresolvedCalls = 0;
147556
+ for (const sourceFile of sourceFiles) {
147557
+ const file = fileForSource(sourceFile);
147558
+ if (!file) continue;
147559
+ const visit = (node) => {
147560
+ const owner = currentRecord(node);
147561
+ if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
147562
+ addFileRelation(sourceFile, moduleTarget(sourceFile, node.moduleSpecifier.text), "imports", node, `imports ${node.moduleSpecifier.text} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`);
147563
+ } else if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
147564
+ addFileRelation(sourceFile, moduleTarget(sourceFile, node.moduleSpecifier.text), "exports", node, `exports ${node.moduleSpecifier.text} at line ${lineAt(sourceFile, node.getStart(sourceFile))}`);
147565
+ } else if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
147566
+ const signature = checker.getResolvedSignature(node);
147567
+ const declarationNameNode = signature?.declaration ? signature.declaration.name : void 0;
147568
+ const target = resolveRecord(declarationNameNode ? checker.getSymbolAtLocation(declarationNameNode) : void 0) ?? (signature?.declaration ? declarationToRecord.get(signature.declaration) : void 0) ?? resolveRecord(checker.getSymbolAtLocation(node.expression));
147569
+ if (target) {
147570
+ const from = owner?.symbol.id;
147571
+ addEdge({
147572
+ ...from ? { fromSymbolId: from } : { fromFileId: file.id },
147573
+ toSymbolId: target.symbol.id,
147574
+ type: "calls",
147575
+ confidence: 0.98,
147576
+ evidence: `resolved call at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
147577
+ });
147578
+ if (isTestPath(file.path)) {
147579
+ addEdge({
147580
+ ...from ? { fromSymbolId: from } : { fromFileId: file.id },
147581
+ toSymbolId: target.symbol.id,
147582
+ type: "tests",
147583
+ confidence: 0.97,
147584
+ evidence: `resolved test call at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
147585
+ });
147586
+ }
147587
+ } else {
147588
+ unresolvedCalls++;
147589
+ }
147590
+ } else if (ts.isIdentifier(node) && !declarationNameNodes.has(node) && !ts.isImportSpecifier(node.parent) && !ts.isExportSpecifier(node.parent)) {
147591
+ const target = resolveRecord(checker.getSymbolAtLocation(node));
147592
+ if (target) {
147593
+ addEdge({
147594
+ ...owner?.symbol.id ? { fromSymbolId: owner.symbol.id } : { fromFileId: file.id },
147595
+ toSymbolId: target.symbol.id,
147596
+ type: "references",
147597
+ confidence: 0.95,
147598
+ evidence: `resolved reference at line ${lineAt(sourceFile, node.getStart(sourceFile))}`
147599
+ });
147600
+ }
147601
+ } else if (ts.isHeritageClause(node)) {
147602
+ const ownerRecord = currentRecord(node);
147603
+ for (const type of node.types) {
147604
+ const target = resolveRecord(checker.getSymbolAtLocation(type.expression));
147605
+ if (ownerRecord && target) {
147606
+ addEdge({
147607
+ fromSymbolId: ownerRecord.symbol.id,
147608
+ toSymbolId: target.symbol.id,
147609
+ type: node.token === ts.SyntaxKind.ExtendsKeyword ? "extends" : "implements",
147610
+ confidence: 0.99,
147611
+ evidence: `compiler-resolved heritage at line ${lineAt(sourceFile, type.getStart(sourceFile))}`
147612
+ });
147613
+ }
147614
+ }
147615
+ }
147616
+ node.forEachChild(visit);
147617
+ };
147618
+ visit(sourceFile);
147619
+ }
147620
+ const diagnostics = sourceFiles.flatMap((sourceFile) => {
147621
+ const file = fileForSource(sourceFile);
147622
+ if (!file || includePaths && !includePaths.has(normalizeCodePath(file.path))) return [];
147623
+ return program.getSyntacticDiagnostics(sourceFile).slice(0, 4).map((diagnostic) => ({
147624
+ path: file.path,
147625
+ message: ts.flattenDiagnosticMessageText(diagnostic.messageText, " ").slice(0, 240)
147626
+ }));
147627
+ });
147628
+ return {
147629
+ symbols,
147630
+ edges: [...edges.values()],
147631
+ parsedFiles: sourceFiles.length,
147632
+ parserErrors: diagnostics.length,
147633
+ unresolvedCalls,
147634
+ durationMs: Date.now() - started,
147635
+ diagnostics
147636
+ };
147637
+ }
147638
+ var SEMANTIC_SOURCE, SUPPORTED_LANGUAGES;
147639
+ var init_semantic_provider = __esm({
147640
+ "src/codegraph/semantic-provider.ts"() {
147641
+ "use strict";
147642
+ init_esm_shims();
147643
+ init_exclude3();
147644
+ init_ids();
147645
+ SEMANTIC_SOURCE = "typescript-compiler";
147646
+ SUPPORTED_LANGUAGES = /* @__PURE__ */ new Set(["typescript", "javascript"]);
147647
+ }
147648
+ });
147649
+
147075
147650
  // src/codegraph/lite-provider.ts
147076
147651
  var lite_provider_exports = {};
147077
147652
  __export(lite_provider_exports, {
@@ -147079,11 +147654,11 @@ __export(lite_provider_exports, {
147079
147654
  indexProjectLite: () => indexProjectLite,
147080
147655
  refreshProjectLite: () => refreshProjectLite
147081
147656
  });
147082
- import { createHash as createHash8 } from "crypto";
147083
- import { readdirSync as readdirSync2, readFileSync as readFileSync7, statSync as statSync3 } from "fs";
147084
- import { join as join4, relative } from "path";
147085
- function hashText(text2) {
147086
- return createHash8("sha256").update(text2).digest("hex");
147657
+ import { createHash as createHash9 } from "crypto";
147658
+ import { readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
147659
+ import { join as join4, relative as relative2 } from "path";
147660
+ function hashText2(text2) {
147661
+ return createHash9("sha256").update(text2).digest("hex");
147087
147662
  }
147088
147663
  function extension2(path21) {
147089
147664
  const index = path21.lastIndexOf(".");
@@ -147109,7 +147684,7 @@ function walk(root, exclude, maxFiles) {
147109
147684
  }
147110
147685
  for (const entry of entries) {
147111
147686
  const abs = join4(dir, entry.name);
147112
- const rel = normalizeCodePath(relative(root, abs));
147687
+ const rel = normalizeCodePath(relative2(root, abs));
147113
147688
  if (isCodeGraphExcludedPath(rel, exclude)) continue;
147114
147689
  if (entry.isDirectory()) {
147115
147690
  if (entry.name === ".git" || entry.name === ".worktrees" || entry.name === ".tmp" || entry.name === "node_modules") continue;
@@ -147152,8 +147727,9 @@ function extractSymbols(projectId, file, text2, indexedAt) {
147152
147727
  startLine,
147153
147728
  endLine: startLine,
147154
147729
  signature: match2[0].slice(0, 160),
147155
- contentHash: hashText(match2[0]),
147156
- indexedAt
147730
+ contentHash: hashText2(match2[0]),
147731
+ indexedAt,
147732
+ source: "lite-regex"
147157
147733
  });
147158
147734
  }
147159
147735
  }
@@ -147178,7 +147754,8 @@ function extractImportEdges(projectId, file, text2, indexedAt) {
147178
147754
  type: "imports",
147179
147755
  confidence: 0.7,
147180
147756
  evidence: line,
147181
- indexedAt
147757
+ indexedAt,
147758
+ source: "lite-regex"
147182
147759
  });
147183
147760
  }
147184
147761
  continue;
@@ -147191,28 +147768,30 @@ function extractImportEdges(projectId, file, text2, indexedAt) {
147191
147768
  type: "imports",
147192
147769
  confidence: 0.7,
147193
147770
  evidence: target,
147194
- indexedAt
147771
+ indexedAt,
147772
+ source: "lite-regex"
147195
147773
  });
147196
147774
  }
147197
147775
  }
147198
147776
  return edges;
147199
147777
  }
147200
147778
  function indexFileLite(projectId, projectRoot, abs, indexedAt, fileStat) {
147201
- const rel = normalizeCodePath(relative(projectRoot, abs));
147779
+ const rel = normalizeCodePath(relative2(projectRoot, abs));
147202
147780
  try {
147203
- const text2 = readFileSync7(abs, "utf-8");
147781
+ const text2 = readFileSync8(abs, "utf-8");
147204
147782
  const stat5 = fileStat ?? statSync3(abs);
147205
147783
  const file = {
147206
147784
  id: makeCodeFileId(projectId, rel),
147207
147785
  projectId,
147208
147786
  path: rel,
147209
147787
  language: languageForPath(rel),
147210
- contentHash: hashText(text2),
147788
+ contentHash: hashText2(text2),
147211
147789
  // Preserve filesystem precision. Rounding here made same-size edits in
147212
147790
  // a short Windows timestamp window indistinguishable to refresh.
147213
147791
  mtimeMs: Number(stat5.mtimeMs),
147214
147792
  sizeBytes: Number(stat5.size),
147215
- indexedAt
147793
+ indexedAt,
147794
+ source: "lite-regex"
147216
147795
  };
147217
147796
  return {
147218
147797
  delta: {
@@ -147267,6 +147846,7 @@ async function refreshProjectLite(store, options) {
147267
147846
  const indexedAt = (/* @__PURE__ */ new Date()).toISOString();
147268
147847
  const paths = walk(options.projectRoot, exclude, maxFiles);
147269
147848
  const existingByPath = new Map(store.listFiles(options.projectId).map((file) => [file.path, file]));
147849
+ const changedPaths = /* @__PURE__ */ new Set();
147270
147850
  const changed = [];
147271
147851
  const metadataOnly = [];
147272
147852
  const seenPaths = /* @__PURE__ */ new Set();
@@ -147275,7 +147855,7 @@ async function refreshProjectLite(store, options) {
147275
147855
  let skippedOversizedFiles = 0;
147276
147856
  let unreadableFiles = 0;
147277
147857
  for (const abs of paths) {
147278
- const rel = normalizeCodePath(relative(options.projectRoot, abs));
147858
+ const rel = normalizeCodePath(relative2(options.projectRoot, abs));
147279
147859
  seenPaths.add(rel);
147280
147860
  let stat5;
147281
147861
  try {
@@ -147290,6 +147870,7 @@ async function refreshProjectLite(store, options) {
147290
147870
  if (sizeBytes > maxFileBytes) {
147291
147871
  skippedOversizedFiles++;
147292
147872
  if (existing) oversizedExistingFileIds.add(existing.id);
147873
+ changedPaths.add(rel);
147293
147874
  continue;
147294
147875
  }
147295
147876
  if (existing && existing.mtimeMs === mtimeMs && existing.sizeBytes === sizeBytes) {
@@ -147307,6 +147888,7 @@ async function refreshProjectLite(store, options) {
147307
147888
  unchangedFiles++;
147308
147889
  } else {
147309
147890
  changed.push(delta);
147891
+ changedPaths.add(rel);
147310
147892
  }
147311
147893
  }
147312
147894
  const removalScanDeferred = paths.length >= maxFiles;
@@ -147314,11 +147896,64 @@ async function refreshProjectLite(store, options) {
147314
147896
  ...oversizedExistingFileIds,
147315
147897
  ...removalScanDeferred ? [] : [...existingByPath.values()].filter((file) => !seenPaths.has(file.path)).map((file) => file.id)
147316
147898
  ])];
147899
+ for (const file of existingByPath.values()) {
147900
+ if (removedFileIds.includes(file.id)) changedPaths.add(file.path);
147901
+ }
147902
+ const affectedSemanticPaths = /* @__PURE__ */ new Set([
147903
+ ...changedPaths,
147904
+ ...store.listImportDependentPaths(
147905
+ options.projectId,
147906
+ [...changedPaths],
147907
+ changed.map((delta) => delta.file.path)
147908
+ )
147909
+ ]);
147317
147910
  store.applyFileDeltas(options.projectId, {
147318
147911
  changed,
147319
147912
  metadataOnly,
147320
147913
  removedFileIds
147321
147914
  });
147915
+ const currentFiles = store.listFiles(options.projectId);
147916
+ const beforeSemantic = store.status(options.projectId).semanticSymbols;
147917
+ const semanticPaths = beforeSemantic === 0 ? currentFiles.filter((file) => isSemanticLanguage(file.language)).map((file) => file.path) : currentFiles.filter((file) => isSemanticLanguage(file.language) && affectedSemanticPaths.has(file.path)).map((file) => file.path);
147918
+ let semanticSummary;
147919
+ if (semanticPaths.length > 0) {
147920
+ const semanticIndexer = options.semanticIndexer ?? buildTypeScriptSemanticIndex;
147921
+ const semanticInput = {
147922
+ projectId: options.projectId,
147923
+ projectRoot: options.projectRoot,
147924
+ files: currentFiles,
147925
+ exclude,
147926
+ includePaths: semanticPaths
147927
+ };
147928
+ try {
147929
+ const semantic = semanticIndexer(semanticInput);
147930
+ store.replaceSemanticSlice(options.projectId, semanticPaths, semantic);
147931
+ semanticSummary = {
147932
+ state: semantic.parserErrors > 0 ? "partial" : "ready",
147933
+ parsedFiles: semantic.parsedFiles,
147934
+ affectedFiles: semanticPaths.length,
147935
+ symbols: semantic.symbols.length,
147936
+ edges: semantic.edges.length,
147937
+ parserErrors: semantic.parserErrors,
147938
+ unresolvedCalls: semantic.unresolvedCalls,
147939
+ durationMs: semantic.durationMs
147940
+ };
147941
+ } catch (error) {
147942
+ const message = error instanceof Error ? error.message : String(error);
147943
+ store.markSemanticSliceFailed(options.projectId, semanticPaths, message);
147944
+ semanticSummary = {
147945
+ state: "failed",
147946
+ parsedFiles: 0,
147947
+ affectedFiles: semanticPaths.length,
147948
+ symbols: 0,
147949
+ edges: 0,
147950
+ parserErrors: semanticPaths.length,
147951
+ unresolvedCalls: 0,
147952
+ durationMs: 0,
147953
+ error: message.slice(0, 500)
147954
+ };
147955
+ }
147956
+ }
147322
147957
  const completeness = {
147323
147958
  scannedFiles: paths.length,
147324
147959
  maxFiles,
@@ -147348,7 +147983,8 @@ async function refreshProjectLite(store, options) {
147348
147983
  skippedOversizedFiles,
147349
147984
  unreadableFiles,
147350
147985
  removalScanDeferred,
147351
- snapshot
147986
+ snapshot,
147987
+ ...semanticSummary ? { semantic: semanticSummary } : {}
147352
147988
  };
147353
147989
  }
147354
147990
  var DEFAULT_CODEGRAPH_MAX_FILE_BYTES, LANGUAGE_BY_EXTENSION, SUPPORTED_EXTENSIONS, identifier, languageProfiles;
@@ -147359,6 +147995,7 @@ var init_lite_provider = __esm({
147359
147995
  init_code_state();
147360
147996
  init_ids();
147361
147997
  init_exclude3();
147998
+ init_semantic_provider();
147362
147999
  DEFAULT_CODEGRAPH_MAX_FILE_BYTES = 2 * 1024 * 1024;
147363
148000
  LANGUAGE_BY_EXTENSION = /* @__PURE__ */ new Map([
147364
148001
  [".ts", "typescript"],
@@ -147493,7 +148130,7 @@ var claim_store_exports = {};
147493
148130
  __export(claim_store_exports, {
147494
148131
  ClaimStore: () => ClaimStore
147495
148132
  });
147496
- import { createHash as createHash9, randomUUID as randomUUID12 } from "crypto";
148133
+ import { createHash as createHash10, randomUUID as randomUUID12 } from "crypto";
147497
148134
  function optionalText3(value) {
147498
148135
  return typeof value === "string" && value ? value : void 0;
147499
148136
  }
@@ -147546,7 +148183,7 @@ function rowToEvent3(row) {
147546
148183
  };
147547
148184
  }
147548
148185
  function evidenceKey(input) {
147549
- return createHash9("sha256").update(JSON.stringify([
148186
+ return createHash10("sha256").update(JSON.stringify([
147550
148187
  input.evidenceKind,
147551
148188
  input.evidenceId,
147552
148189
  input.relation,
@@ -147744,7 +148381,7 @@ __export(claims_exports, {
147744
148381
  supersedeClaim: () => supersedeClaim,
147745
148382
  writeClaim: () => writeClaim
147746
148383
  });
147747
- import { createHash as createHash10, randomUUID as randomUUID13 } from "crypto";
148384
+ import { createHash as createHash11, randomUUID as randomUUID13 } from "crypto";
147748
148385
  function compactText2(value, field) {
147749
148386
  if (typeof value !== "string") throw new Error("Claim " + field + " must be text");
147750
148387
  const sanitized = sanitizeCredentials(value).trim().replace(/\s+/g, " ");
@@ -147756,7 +148393,7 @@ function normalizedTerm(value) {
147756
148393
  return compactText2(value, "identity").toLocaleLowerCase("en-US");
147757
148394
  }
147758
148395
  function hashIdentity(parts) {
147759
- return createHash10("sha256").update(parts.join(String.fromCharCode(31))).digest("hex");
148396
+ return createHash11("sha256").update(parts.join(String.fromCharCode(31))).digest("hex");
147760
148397
  }
147761
148398
  function buildClaimIdentity(input) {
147762
148399
  const subject = normalizedTerm(input.subject);
@@ -147997,7 +148634,7 @@ function supersedeClaim(store, input) {
147997
148634
  });
147998
148635
  }
147999
148636
  function hashObservation(observation) {
148000
- return createHash10("sha256").update(JSON.stringify([
148637
+ return createHash11("sha256").update(JSON.stringify([
148001
148638
  observation.title,
148002
148639
  observation.narrative,
148003
148640
  observation.facts,
@@ -148241,11 +148878,11 @@ var init_frontmatter = __esm({
148241
148878
  });
148242
148879
 
148243
148880
  // src/knowledge/markdown.ts
148244
- import { createHash as createHash11 } from "crypto";
148881
+ import { createHash as createHash12 } from "crypto";
148245
148882
  import { promises as fs10 } from "fs";
148246
148883
  import path17 from "path";
148247
148884
  function hashContent(content) {
148248
- return createHash11("sha256").update(content).digest("hex");
148885
+ return createHash12("sha256").update(content).digest("hex");
148249
148886
  }
148250
148887
  function stringField(data, key) {
148251
148888
  const value = data[key];
@@ -148371,11 +149008,11 @@ __export(wiki_exports, {
148371
149008
  lintKnowledgeWorkspace: () => lintKnowledgeWorkspace,
148372
149009
  readKnowledgePage: () => readKnowledgePage
148373
149010
  });
148374
- import { createHash as createHash12 } from "crypto";
149011
+ import { createHash as createHash13 } from "crypto";
148375
149012
  import { promises as fs11 } from "fs";
148376
149013
  import path18 from "path";
148377
149014
  function hash2(value) {
148378
- return createHash12("sha256").update(value).digest("hex");
149015
+ return createHash13("sha256").update(value).digest("hex");
148379
149016
  }
148380
149017
  function now() {
148381
149018
  return (/* @__PURE__ */ new Date()).toISOString();
@@ -148529,8 +149166,8 @@ async function writeIndex(workspace, store) {
148529
149166
  lines.push("No pending proposals.");
148530
149167
  } else {
148531
149168
  for (const proposal of pending) {
148532
- const relative2 = path18.relative(paths.root, proposal.proposalPath).split(path18.sep).join("/");
148533
- lines.push("- [" + path18.basename(proposal.proposalPath, ".md") + "](" + relative2 + ")");
149169
+ const relative3 = path18.relative(paths.root, proposal.proposalPath).split(path18.sep).join("/");
149170
+ lines.push("- [" + path18.basename(proposal.proposalPath, ".md") + "](" + relative3 + ")");
148534
149171
  }
148535
149172
  }
148536
149173
  lines.push("");
@@ -149232,11 +149869,11 @@ __export(workflows_exports, {
149232
149869
  syncCanonicalWorkflows: () => syncCanonicalWorkflows,
149233
149870
  writeCanonicalWorkflow: () => writeCanonicalWorkflow
149234
149871
  });
149235
- import { createHash as createHash13 } from "crypto";
149872
+ import { createHash as createHash14 } from "crypto";
149236
149873
  import { promises as fs12 } from "fs";
149237
149874
  import path19 from "path";
149238
149875
  function hash3(value) {
149239
- return createHash13("sha256").update(value).digest("hex");
149876
+ return createHash14("sha256").update(value).digest("hex");
149240
149877
  }
149241
149878
  function now2() {
149242
149879
  return (/* @__PURE__ */ new Date()).toISOString();
@@ -149670,8 +150307,8 @@ async function importWindsurfWorkflows(input) {
149670
150307
  return { imported, skipped };
149671
150308
  }
149672
150309
  function isWithin2(root, candidate) {
149673
- const relative2 = path19.relative(root, candidate);
149674
- return relative2 !== "" && relative2 !== ".." && !relative2.startsWith(".." + path19.sep) && !path19.isAbsolute(relative2);
150310
+ const relative3 = path19.relative(root, candidate);
150311
+ return relative3 !== "" && relative3 !== ".." && !relative3.startsWith(".." + path19.sep) && !path19.isAbsolute(relative3);
149675
150312
  }
149676
150313
  function adapterRelativePath(workflow, agent) {
149677
150314
  const name = "memorix-workflow-" + slug(workflow.id.replace(/^workflow:/, ""));
@@ -150410,7 +151047,7 @@ __export(vector_backfill_runner_exports, {
150410
151047
  resolveVectorBackfillRunnerPath: () => resolveVectorBackfillRunnerPath
150411
151048
  });
150412
151049
  import { spawn as spawn3 } from "child_process";
150413
- import { existsSync as existsSync10 } from "fs";
151050
+ import { existsSync as existsSync11 } from "fs";
150414
151051
  import path20 from "path";
150415
151052
  import { fileURLToPath as fileURLToPath4 } from "url";
150416
151053
  function isNonEmptyString(value) {
@@ -150439,7 +151076,7 @@ function parseVectorBackfillRequest(raw) {
150439
151076
  }
150440
151077
  function launchDetachedVectorBackfill(request, options = {}) {
150441
151078
  const runnerPath = options.runnerPath ?? resolveVectorBackfillRunnerPath();
150442
- const exists = options.exists ?? existsSync10;
151079
+ const exists = options.exists ?? existsSync11;
150443
151080
  if (!exists(runnerPath)) return false;
150444
151081
  try {
150445
151082
  const child = (options.spawn ?? spawn3)(process.execPath, [runnerPath], {
@@ -150477,14 +151114,14 @@ async function executeVectorBackfill(request) {
150477
151114
  return worker.runOnce();
150478
151115
  }
150479
151116
  async function readStdin() {
150480
- return new Promise((resolve, reject) => {
151117
+ return new Promise((resolve2, reject) => {
150481
151118
  let raw = "";
150482
151119
  process.stdin.setEncoding("utf8");
150483
151120
  process.stdin.on("data", (chunk) => {
150484
151121
  raw += chunk;
150485
151122
  });
150486
151123
  process.stdin.once("error", reject);
150487
- process.stdin.once("end", () => resolve(raw));
151124
+ process.stdin.once("end", () => resolve2(raw));
150488
151125
  });
150489
151126
  }
150490
151127
  async function main() {