@prosdevlab/dev-agent 0.8.5 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1516,7 +1516,7 @@ var require_command = __commonJS({
1516
1516
  var EventEmitter2 = require("events").EventEmitter;
1517
1517
  var childProcess = require("child_process");
1518
1518
  var path16 = require("path");
1519
- var fs14 = require("fs");
1519
+ var fs13 = require("fs");
1520
1520
  var process15 = require("process");
1521
1521
  var { Argument, humanReadableArgName } = require_argument();
1522
1522
  var { CommanderError } = require_error();
@@ -2449,10 +2449,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2449
2449
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2450
2450
  function findFile(baseDir, baseName) {
2451
2451
  const localBin = path16.resolve(baseDir, baseName);
2452
- if (fs14.existsSync(localBin)) return localBin;
2452
+ if (fs13.existsSync(localBin)) return localBin;
2453
2453
  if (sourceExt.includes(path16.extname(baseName))) return void 0;
2454
2454
  const foundExt = sourceExt.find(
2455
- (ext) => fs14.existsSync(`${localBin}${ext}`)
2455
+ (ext) => fs13.existsSync(`${localBin}${ext}`)
2456
2456
  );
2457
2457
  if (foundExt) return `${localBin}${foundExt}`;
2458
2458
  return void 0;
@@ -2464,7 +2464,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2464
2464
  if (this._scriptPath) {
2465
2465
  let resolvedScriptPath;
2466
2466
  try {
2467
- resolvedScriptPath = fs14.realpathSync(this._scriptPath);
2467
+ resolvedScriptPath = fs13.realpathSync(this._scriptPath);
2468
2468
  } catch (err) {
2469
2469
  resolvedScriptPath = this._scriptPath;
2470
2470
  }
@@ -4590,11 +4590,11 @@ var init_change_frequency = __esm({
4590
4590
 
4591
4591
  // ../core/src/metrics/collector.ts
4592
4592
  async function countFileLines(repositoryPath, filePath) {
4593
- const fs14 = await import("fs/promises");
4593
+ const fs13 = await import("fs/promises");
4594
4594
  const path16 = await import("path");
4595
4595
  try {
4596
4596
  const fullPath = path16.join(repositoryPath, filePath);
4597
- const content3 = await fs14.readFile(fullPath, "utf-8");
4597
+ const content3 = await fs13.readFile(fullPath, "utf-8");
4598
4598
  return content3.split("\n").length;
4599
4599
  } catch {
4600
4600
  return 0;
@@ -13127,8 +13127,8 @@ var init_is_plain_obj = __esm({
13127
13127
  // ../../node_modules/.pnpm/trough@2.2.0/node_modules/trough/lib/index.js
13128
13128
  function trough() {
13129
13129
  const fns = [];
13130
- const pipeline2 = { run, use };
13131
- return pipeline2;
13130
+ const pipeline = { run, use };
13131
+ return pipeline;
13132
13132
  function run(...values) {
13133
13133
  let middlewareIndex = -1;
13134
13134
  const callback = values.pop();
@@ -13163,7 +13163,7 @@ function trough() {
13163
13163
  );
13164
13164
  }
13165
13165
  fns.push(middelware);
13166
- return pipeline2;
13166
+ return pipeline;
13167
13167
  }
13168
13168
  }
13169
13169
  function wrap(middleware, callback) {
@@ -18300,8 +18300,8 @@ var require_utils3 = __commonJS({
18300
18300
  exports2.array = array2;
18301
18301
  var errno = require_errno();
18302
18302
  exports2.errno = errno;
18303
- var fs14 = require_fs();
18304
- exports2.fs = fs14;
18303
+ var fs13 = require_fs();
18304
+ exports2.fs = fs13;
18305
18305
  var path16 = require_path();
18306
18306
  exports2.path = path16;
18307
18307
  var pattern = require_pattern();
@@ -18425,7 +18425,7 @@ var require_async = __commonJS({
18425
18425
  callSuccessCallback(callback, lstat);
18426
18426
  return;
18427
18427
  }
18428
- settings.fs.stat(path16, (statError, stat4) => {
18428
+ settings.fs.stat(path16, (statError, stat3) => {
18429
18429
  if (statError !== null) {
18430
18430
  if (settings.throwErrorOnBrokenSymbolicLink) {
18431
18431
  callFailureCallback(callback, statError);
@@ -18435,9 +18435,9 @@ var require_async = __commonJS({
18435
18435
  return;
18436
18436
  }
18437
18437
  if (settings.markSymbolicLink) {
18438
- stat4.isSymbolicLink = () => true;
18438
+ stat3.isSymbolicLink = () => true;
18439
18439
  }
18440
- callSuccessCallback(callback, stat4);
18440
+ callSuccessCallback(callback, stat3);
18441
18441
  });
18442
18442
  });
18443
18443
  }
@@ -18463,11 +18463,11 @@ var require_sync = __commonJS({
18463
18463
  return lstat;
18464
18464
  }
18465
18465
  try {
18466
- const stat4 = settings.fs.statSync(path16);
18466
+ const stat3 = settings.fs.statSync(path16);
18467
18467
  if (settings.markSymbolicLink) {
18468
- stat4.isSymbolicLink = () => true;
18468
+ stat3.isSymbolicLink = () => true;
18469
18469
  }
18470
- return stat4;
18470
+ return stat3;
18471
18471
  } catch (error46) {
18472
18472
  if (!settings.throwErrorOnBrokenSymbolicLink) {
18473
18473
  return lstat;
@@ -18485,12 +18485,12 @@ var require_fs2 = __commonJS({
18485
18485
  "use strict";
18486
18486
  Object.defineProperty(exports2, "__esModule", { value: true });
18487
18487
  exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = void 0;
18488
- var fs14 = require("fs");
18488
+ var fs13 = require("fs");
18489
18489
  exports2.FILE_SYSTEM_ADAPTER = {
18490
- lstat: fs14.lstat,
18491
- stat: fs14.stat,
18492
- lstatSync: fs14.lstatSync,
18493
- statSync: fs14.statSync
18490
+ lstat: fs13.lstat,
18491
+ stat: fs13.stat,
18492
+ lstatSync: fs13.lstatSync,
18493
+ statSync: fs13.statSync
18494
18494
  };
18495
18495
  function createFileSystemAdapter(fsMethods) {
18496
18496
  if (fsMethods === void 0) {
@@ -18507,12 +18507,12 @@ var require_settings = __commonJS({
18507
18507
  "../../node_modules/.pnpm/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.js"(exports2) {
18508
18508
  "use strict";
18509
18509
  Object.defineProperty(exports2, "__esModule", { value: true });
18510
- var fs14 = require_fs2();
18510
+ var fs13 = require_fs2();
18511
18511
  var Settings = class {
18512
18512
  constructor(_options = {}) {
18513
18513
  this._options = _options;
18514
18514
  this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
18515
- this.fs = fs14.createFileSystemAdapter(this._options.fs);
18515
+ this.fs = fs13.createFileSystemAdapter(this._options.fs);
18516
18516
  this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
18517
18517
  this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
18518
18518
  }
@@ -18534,14 +18534,14 @@ var require_out = __commonJS({
18534
18534
  var sync = require_sync();
18535
18535
  var settings_1 = require_settings();
18536
18536
  exports2.Settings = settings_1.default;
18537
- function stat4(path16, optionsOrSettingsOrCallback, callback) {
18537
+ function stat3(path16, optionsOrSettingsOrCallback, callback) {
18538
18538
  if (typeof optionsOrSettingsOrCallback === "function") {
18539
18539
  async.read(path16, getSettings(), optionsOrSettingsOrCallback);
18540
18540
  return;
18541
18541
  }
18542
18542
  async.read(path16, getSettings(optionsOrSettingsOrCallback), callback);
18543
18543
  }
18544
- exports2.stat = stat4;
18544
+ exports2.stat = stat3;
18545
18545
  function statSync(path16, optionsOrSettings) {
18546
18546
  const settings = getSettings(optionsOrSettings);
18547
18547
  return sync.read(path16, settings);
@@ -18669,8 +18669,8 @@ var require_utils4 = __commonJS({
18669
18669
  "use strict";
18670
18670
  Object.defineProperty(exports2, "__esModule", { value: true });
18671
18671
  exports2.fs = void 0;
18672
- var fs14 = require_fs3();
18673
- exports2.fs = fs14;
18672
+ var fs13 = require_fs3();
18673
+ exports2.fs = fs13;
18674
18674
  }
18675
18675
  });
18676
18676
 
@@ -18865,14 +18865,14 @@ var require_fs4 = __commonJS({
18865
18865
  "use strict";
18866
18866
  Object.defineProperty(exports2, "__esModule", { value: true });
18867
18867
  exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = void 0;
18868
- var fs14 = require("fs");
18868
+ var fs13 = require("fs");
18869
18869
  exports2.FILE_SYSTEM_ADAPTER = {
18870
- lstat: fs14.lstat,
18871
- stat: fs14.stat,
18872
- lstatSync: fs14.lstatSync,
18873
- statSync: fs14.statSync,
18874
- readdir: fs14.readdir,
18875
- readdirSync: fs14.readdirSync
18870
+ lstat: fs13.lstat,
18871
+ stat: fs13.stat,
18872
+ lstatSync: fs13.lstatSync,
18873
+ statSync: fs13.statSync,
18874
+ readdir: fs13.readdir,
18875
+ readdirSync: fs13.readdirSync
18876
18876
  };
18877
18877
  function createFileSystemAdapter(fsMethods) {
18878
18878
  if (fsMethods === void 0) {
@@ -18891,12 +18891,12 @@ var require_settings2 = __commonJS({
18891
18891
  Object.defineProperty(exports2, "__esModule", { value: true });
18892
18892
  var path16 = require("path");
18893
18893
  var fsStat = require_out();
18894
- var fs14 = require_fs4();
18894
+ var fs13 = require_fs4();
18895
18895
  var Settings = class {
18896
18896
  constructor(_options = {}) {
18897
18897
  this._options = _options;
18898
18898
  this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
18899
- this.fs = fs14.createFileSystemAdapter(this._options.fs);
18899
+ this.fs = fs13.createFileSystemAdapter(this._options.fs);
18900
18900
  this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path16.sep);
18901
18901
  this.stats = this._getValue(this._options.stats, false);
18902
18902
  this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
@@ -20254,16 +20254,16 @@ var require_settings4 = __commonJS({
20254
20254
  "use strict";
20255
20255
  Object.defineProperty(exports2, "__esModule", { value: true });
20256
20256
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
20257
- var fs14 = require("fs");
20257
+ var fs13 = require("fs");
20258
20258
  var os4 = require("os");
20259
20259
  var CPU_COUNT = Math.max(os4.cpus().length, 1);
20260
20260
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = {
20261
- lstat: fs14.lstat,
20262
- lstatSync: fs14.lstatSync,
20263
- stat: fs14.stat,
20264
- statSync: fs14.statSync,
20265
- readdir: fs14.readdir,
20266
- readdirSync: fs14.readdirSync
20261
+ lstat: fs13.lstat,
20262
+ lstatSync: fs13.lstatSync,
20263
+ stat: fs13.stat,
20264
+ statSync: fs13.statSync,
20265
+ readdir: fs13.readdir,
20266
+ readdirSync: fs13.readdirSync
20267
20267
  };
20268
20268
  var Settings = class {
20269
20269
  constructor(_options = {}) {
@@ -22695,363 +22695,1472 @@ var init_scanner = __esm({
22695
22695
  }
22696
22696
  });
22697
22697
 
22698
- // ../core/src/vector/embedder.ts
22699
- var import_transformers, TransformersEmbedder;
22700
- var init_embedder = __esm({
22701
- "../core/src/vector/embedder.ts"() {
22702
- "use strict";
22703
- import_transformers = require("@xenova/transformers");
22704
- TransformersEmbedder = class {
22705
- modelName;
22706
- dimension;
22707
- pipeline = null;
22708
- batchSize = 32;
22709
- constructor(modelName = "Xenova/all-MiniLM-L6-v2", dimension = 384) {
22710
- this.modelName = modelName;
22711
- this.dimension = dimension;
22698
+ // ../../node_modules/.pnpm/openapi-fetch@0.17.0/node_modules/openapi-fetch/dist/index.mjs
22699
+ function randomID() {
22700
+ return Math.random().toString(36).slice(2, 11);
22701
+ }
22702
+ function createClient(clientOptions) {
22703
+ let {
22704
+ baseUrl = "",
22705
+ Request: CustomRequest = globalThis.Request,
22706
+ fetch: baseFetch = globalThis.fetch,
22707
+ querySerializer: globalQuerySerializer,
22708
+ bodySerializer: globalBodySerializer,
22709
+ pathSerializer: globalPathSerializer,
22710
+ headers: baseHeaders,
22711
+ requestInitExt = void 0,
22712
+ ...baseOptions
22713
+ } = { ...clientOptions };
22714
+ requestInitExt = supportsRequestInitExt() ? requestInitExt : void 0;
22715
+ baseUrl = removeTrailingSlash(baseUrl);
22716
+ const globalMiddlewares = [];
22717
+ async function coreFetch(schemaPath, fetchOptions) {
22718
+ const {
22719
+ baseUrl: localBaseUrl,
22720
+ fetch: fetch2 = baseFetch,
22721
+ Request = CustomRequest,
22722
+ headers,
22723
+ params = {},
22724
+ parseAs = "json",
22725
+ querySerializer: requestQuerySerializer,
22726
+ bodySerializer = globalBodySerializer ?? defaultBodySerializer,
22727
+ pathSerializer: requestPathSerializer,
22728
+ body,
22729
+ middleware: requestMiddlewares = [],
22730
+ ...init
22731
+ } = fetchOptions || {};
22732
+ let finalBaseUrl = baseUrl;
22733
+ if (localBaseUrl) {
22734
+ finalBaseUrl = removeTrailingSlash(localBaseUrl) ?? baseUrl;
22735
+ }
22736
+ let querySerializer = typeof globalQuerySerializer === "function" ? globalQuerySerializer : createQuerySerializer(globalQuerySerializer);
22737
+ if (requestQuerySerializer) {
22738
+ querySerializer = typeof requestQuerySerializer === "function" ? requestQuerySerializer : createQuerySerializer({
22739
+ ...typeof globalQuerySerializer === "object" ? globalQuerySerializer : {},
22740
+ ...requestQuerySerializer
22741
+ });
22742
+ }
22743
+ const pathSerializer = requestPathSerializer || globalPathSerializer || defaultPathSerializer;
22744
+ const serializedBody = body === void 0 ? void 0 : bodySerializer(
22745
+ body,
22746
+ // Note: we declare mergeHeaders() both here and below because it’s a bit of a chicken-or-egg situation:
22747
+ // bodySerializer() needs all headers so we aren’t dropping ones set by the user, however,
22748
+ // the result of this ALSO sets the lowest-priority content-type header. So we re-merge below,
22749
+ // setting the content-type at the very beginning to be overwritten.
22750
+ // Lastly, based on the way headers work, it’s not a simple “present-or-not” check becauase null intentionally un-sets headers.
22751
+ mergeHeaders(baseHeaders, headers, params.header)
22752
+ );
22753
+ const finalHeaders = mergeHeaders(
22754
+ // with no body, we should not to set Content-Type
22755
+ serializedBody === void 0 || // if serialized body is FormData; browser will correctly set Content-Type & boundary expression
22756
+ serializedBody instanceof FormData ? {} : {
22757
+ "Content-Type": "application/json"
22758
+ },
22759
+ baseHeaders,
22760
+ headers,
22761
+ params.header
22762
+ );
22763
+ const finalMiddlewares = [...globalMiddlewares, ...requestMiddlewares];
22764
+ const requestInit = {
22765
+ redirect: "follow",
22766
+ ...baseOptions,
22767
+ ...init,
22768
+ body: serializedBody,
22769
+ headers: finalHeaders
22770
+ };
22771
+ let id;
22772
+ let options;
22773
+ let request = new Request(
22774
+ createFinalURL(schemaPath, { baseUrl: finalBaseUrl, params, querySerializer, pathSerializer }),
22775
+ requestInit
22776
+ );
22777
+ let response;
22778
+ for (const key in init) {
22779
+ if (!(key in request)) {
22780
+ request[key] = init[key];
22781
+ }
22782
+ }
22783
+ if (finalMiddlewares.length) {
22784
+ id = randomID();
22785
+ options = Object.freeze({
22786
+ baseUrl: finalBaseUrl,
22787
+ fetch: fetch2,
22788
+ parseAs,
22789
+ querySerializer,
22790
+ bodySerializer,
22791
+ pathSerializer
22792
+ });
22793
+ for (const m of finalMiddlewares) {
22794
+ if (m && typeof m === "object" && typeof m.onRequest === "function") {
22795
+ const result = await m.onRequest({
22796
+ request,
22797
+ schemaPath,
22798
+ params,
22799
+ options,
22800
+ id
22801
+ });
22802
+ if (result) {
22803
+ if (result instanceof Request) {
22804
+ request = result;
22805
+ } else if (result instanceof Response) {
22806
+ response = result;
22807
+ break;
22808
+ } else {
22809
+ throw new Error("onRequest: must return new Request() or Response() when modifying the request");
22810
+ }
22811
+ }
22812
+ }
22712
22813
  }
22713
- /**
22714
- * Initialize the embedding model
22715
- * Downloads and caches the model on first run
22716
- */
22717
- async initialize() {
22718
- if (this.pipeline) {
22719
- return;
22814
+ }
22815
+ if (!response) {
22816
+ try {
22817
+ response = await fetch2(request, requestInitExt);
22818
+ } catch (error210) {
22819
+ let errorAfterMiddleware = error210;
22820
+ if (finalMiddlewares.length) {
22821
+ for (let i = finalMiddlewares.length - 1; i >= 0; i--) {
22822
+ const m = finalMiddlewares[i];
22823
+ if (m && typeof m === "object" && typeof m.onError === "function") {
22824
+ const result = await m.onError({
22825
+ request,
22826
+ error: errorAfterMiddleware,
22827
+ schemaPath,
22828
+ params,
22829
+ options,
22830
+ id
22831
+ });
22832
+ if (result) {
22833
+ if (result instanceof Response) {
22834
+ errorAfterMiddleware = void 0;
22835
+ response = result;
22836
+ break;
22837
+ }
22838
+ if (result instanceof Error) {
22839
+ errorAfterMiddleware = result;
22840
+ continue;
22841
+ }
22842
+ throw new Error("onError: must return new Response() or instance of Error");
22843
+ }
22844
+ }
22845
+ }
22720
22846
  }
22721
- try {
22722
- this.pipeline = await (0, import_transformers.pipeline)(
22723
- "feature-extraction",
22724
- this.modelName
22847
+ if (errorAfterMiddleware) {
22848
+ throw errorAfterMiddleware;
22849
+ }
22850
+ }
22851
+ if (finalMiddlewares.length) {
22852
+ for (let i = finalMiddlewares.length - 1; i >= 0; i--) {
22853
+ const m = finalMiddlewares[i];
22854
+ if (m && typeof m === "object" && typeof m.onResponse === "function") {
22855
+ const result = await m.onResponse({
22856
+ request,
22857
+ response,
22858
+ schemaPath,
22859
+ params,
22860
+ options,
22861
+ id
22862
+ });
22863
+ if (result) {
22864
+ if (!(result instanceof Response)) {
22865
+ throw new Error("onResponse: must return new Response() when modifying the response");
22866
+ }
22867
+ response = result;
22868
+ }
22869
+ }
22870
+ }
22871
+ }
22872
+ }
22873
+ const contentLength = response.headers.get("Content-Length");
22874
+ if (response.status === 204 || request.method === "HEAD" || contentLength === "0" && !response.headers.get("Transfer-Encoding")?.includes("chunked")) {
22875
+ return response.ok ? { data: void 0, response } : { error: void 0, response };
22876
+ }
22877
+ if (response.ok) {
22878
+ const getResponseData = async () => {
22879
+ if (parseAs === "stream") {
22880
+ return response.body;
22881
+ }
22882
+ if (parseAs === "json" && !contentLength) {
22883
+ const raw = await response.text();
22884
+ return raw ? JSON.parse(raw) : void 0;
22885
+ }
22886
+ return await response[parseAs]();
22887
+ };
22888
+ return { data: await getResponseData(), response };
22889
+ }
22890
+ let error46 = await response.text();
22891
+ try {
22892
+ error46 = JSON.parse(error46);
22893
+ } catch {
22894
+ }
22895
+ return { error: error46, response };
22896
+ }
22897
+ return {
22898
+ request(method, url2, init) {
22899
+ return coreFetch(url2, { ...init, method: method.toUpperCase() });
22900
+ },
22901
+ /** Call a GET endpoint */
22902
+ GET(url2, init) {
22903
+ return coreFetch(url2, { ...init, method: "GET" });
22904
+ },
22905
+ /** Call a PUT endpoint */
22906
+ PUT(url2, init) {
22907
+ return coreFetch(url2, { ...init, method: "PUT" });
22908
+ },
22909
+ /** Call a POST endpoint */
22910
+ POST(url2, init) {
22911
+ return coreFetch(url2, { ...init, method: "POST" });
22912
+ },
22913
+ /** Call a DELETE endpoint */
22914
+ DELETE(url2, init) {
22915
+ return coreFetch(url2, { ...init, method: "DELETE" });
22916
+ },
22917
+ /** Call a OPTIONS endpoint */
22918
+ OPTIONS(url2, init) {
22919
+ return coreFetch(url2, { ...init, method: "OPTIONS" });
22920
+ },
22921
+ /** Call a HEAD endpoint */
22922
+ HEAD(url2, init) {
22923
+ return coreFetch(url2, { ...init, method: "HEAD" });
22924
+ },
22925
+ /** Call a PATCH endpoint */
22926
+ PATCH(url2, init) {
22927
+ return coreFetch(url2, { ...init, method: "PATCH" });
22928
+ },
22929
+ /** Call a TRACE endpoint */
22930
+ TRACE(url2, init) {
22931
+ return coreFetch(url2, { ...init, method: "TRACE" });
22932
+ },
22933
+ /** Register middleware */
22934
+ use(...middleware) {
22935
+ for (const m of middleware) {
22936
+ if (!m) {
22937
+ continue;
22938
+ }
22939
+ if (typeof m !== "object" || !("onRequest" in m || "onResponse" in m || "onError" in m)) {
22940
+ throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");
22941
+ }
22942
+ globalMiddlewares.push(m);
22943
+ }
22944
+ },
22945
+ /** Unregister middleware */
22946
+ eject(...middleware) {
22947
+ for (const m of middleware) {
22948
+ const i = globalMiddlewares.indexOf(m);
22949
+ if (i !== -1) {
22950
+ globalMiddlewares.splice(i, 1);
22951
+ }
22952
+ }
22953
+ }
22954
+ };
22955
+ }
22956
+ function serializePrimitiveParam(name, value, options) {
22957
+ if (value === void 0 || value === null) {
22958
+ return "";
22959
+ }
22960
+ if (typeof value === "object") {
22961
+ throw new Error(
22962
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
22963
+ );
22964
+ }
22965
+ return `${name}=${options?.allowReserved === true ? value : encodeURIComponent(value)}`;
22966
+ }
22967
+ function serializeObjectParam(name, value, options) {
22968
+ if (!value || typeof value !== "object") {
22969
+ return "";
22970
+ }
22971
+ const values = [];
22972
+ const joiner = {
22973
+ simple: ",",
22974
+ label: ".",
22975
+ matrix: ";"
22976
+ }[options.style] || "&";
22977
+ if (options.style !== "deepObject" && options.explode === false) {
22978
+ for (const k in value) {
22979
+ values.push(k, options.allowReserved === true ? value[k] : encodeURIComponent(value[k]));
22980
+ }
22981
+ const final2 = values.join(",");
22982
+ switch (options.style) {
22983
+ case "form": {
22984
+ return `${name}=${final2}`;
22985
+ }
22986
+ case "label": {
22987
+ return `.${final2}`;
22988
+ }
22989
+ case "matrix": {
22990
+ return `;${name}=${final2}`;
22991
+ }
22992
+ default: {
22993
+ return final2;
22994
+ }
22995
+ }
22996
+ }
22997
+ for (const k in value) {
22998
+ const finalName = options.style === "deepObject" ? `${name}[${k}]` : k;
22999
+ values.push(serializePrimitiveParam(finalName, value[k], options));
23000
+ }
23001
+ const final = values.join(joiner);
23002
+ return options.style === "label" || options.style === "matrix" ? `${joiner}${final}` : final;
23003
+ }
23004
+ function serializeArrayParam(name, value, options) {
23005
+ if (!Array.isArray(value)) {
23006
+ return "";
23007
+ }
23008
+ if (options.explode === false) {
23009
+ const joiner2 = { form: ",", spaceDelimited: "%20", pipeDelimited: "|" }[options.style] || ",";
23010
+ const final = (options.allowReserved === true ? value : value.map((v) => encodeURIComponent(v))).join(joiner2);
23011
+ switch (options.style) {
23012
+ case "simple": {
23013
+ return final;
23014
+ }
23015
+ case "label": {
23016
+ return `.${final}`;
23017
+ }
23018
+ case "matrix": {
23019
+ return `;${name}=${final}`;
23020
+ }
23021
+ // case "spaceDelimited":
23022
+ // case "pipeDelimited":
23023
+ default: {
23024
+ return `${name}=${final}`;
23025
+ }
23026
+ }
23027
+ }
23028
+ const joiner = { simple: ",", label: ".", matrix: ";" }[options.style] || "&";
23029
+ const values = [];
23030
+ for (const v of value) {
23031
+ if (options.style === "simple" || options.style === "label") {
23032
+ values.push(options.allowReserved === true ? v : encodeURIComponent(v));
23033
+ } else {
23034
+ values.push(serializePrimitiveParam(name, v, options));
23035
+ }
23036
+ }
23037
+ return options.style === "label" || options.style === "matrix" ? `${joiner}${values.join(joiner)}` : values.join(joiner);
23038
+ }
23039
+ function createQuerySerializer(options) {
23040
+ return function querySerializer(queryParams) {
23041
+ const search2 = [];
23042
+ if (queryParams && typeof queryParams === "object") {
23043
+ for (const name in queryParams) {
23044
+ const value = queryParams[name];
23045
+ if (value === void 0 || value === null) {
23046
+ continue;
23047
+ }
23048
+ if (Array.isArray(value)) {
23049
+ if (value.length === 0) {
23050
+ continue;
23051
+ }
23052
+ search2.push(
23053
+ serializeArrayParam(name, value, {
23054
+ style: "form",
23055
+ explode: true,
23056
+ ...options?.array,
23057
+ allowReserved: options?.allowReserved || false
23058
+ })
22725
23059
  );
22726
- } catch (error46) {
22727
- throw new Error(
22728
- `Failed to initialize embedding model ${this.modelName}: ${error46 instanceof Error ? error46.message : String(error46)}`
23060
+ continue;
23061
+ }
23062
+ if (typeof value === "object") {
23063
+ search2.push(
23064
+ serializeObjectParam(name, value, {
23065
+ style: "deepObject",
23066
+ explode: true,
23067
+ ...options?.object,
23068
+ allowReserved: options?.allowReserved || false
23069
+ })
22729
23070
  );
23071
+ continue;
22730
23072
  }
23073
+ search2.push(serializePrimitiveParam(name, value, options));
23074
+ }
23075
+ }
23076
+ return search2.join("&");
23077
+ };
23078
+ }
23079
+ function defaultPathSerializer(pathname, pathParams) {
23080
+ let nextURL = pathname;
23081
+ for (const match of pathname.match(PATH_PARAM_RE) ?? []) {
23082
+ let name = match.substring(1, match.length - 1);
23083
+ let explode = false;
23084
+ let style = "simple";
23085
+ if (name.endsWith("*")) {
23086
+ explode = true;
23087
+ name = name.substring(0, name.length - 1);
23088
+ }
23089
+ if (name.startsWith(".")) {
23090
+ style = "label";
23091
+ name = name.substring(1);
23092
+ } else if (name.startsWith(";")) {
23093
+ style = "matrix";
23094
+ name = name.substring(1);
23095
+ }
23096
+ if (!pathParams || pathParams[name] === void 0 || pathParams[name] === null) {
23097
+ continue;
23098
+ }
23099
+ const value = pathParams[name];
23100
+ if (Array.isArray(value)) {
23101
+ nextURL = nextURL.replace(match, serializeArrayParam(name, value, { style, explode }));
23102
+ continue;
23103
+ }
23104
+ if (typeof value === "object") {
23105
+ nextURL = nextURL.replace(match, serializeObjectParam(name, value, { style, explode }));
23106
+ continue;
23107
+ }
23108
+ if (style === "matrix") {
23109
+ nextURL = nextURL.replace(match, `;${serializePrimitiveParam(name, value)}`);
23110
+ continue;
23111
+ }
23112
+ nextURL = nextURL.replace(match, style === "label" ? `.${encodeURIComponent(value)}` : encodeURIComponent(value));
23113
+ }
23114
+ return nextURL;
23115
+ }
23116
+ function defaultBodySerializer(body, headers) {
23117
+ if (body instanceof FormData) {
23118
+ return body;
23119
+ }
23120
+ if (headers) {
23121
+ const contentType = headers.get instanceof Function ? headers.get("Content-Type") ?? headers.get("content-type") : headers["Content-Type"] ?? headers["content-type"];
23122
+ if (contentType === "application/x-www-form-urlencoded") {
23123
+ return new URLSearchParams(body).toString();
23124
+ }
23125
+ }
23126
+ return JSON.stringify(body);
23127
+ }
23128
+ function createFinalURL(pathname, options) {
23129
+ let finalURL = `${options.baseUrl}${pathname}`;
23130
+ if (options.params?.path) {
23131
+ finalURL = options.pathSerializer(finalURL, options.params.path);
23132
+ }
23133
+ let search2 = options.querySerializer(options.params.query ?? {});
23134
+ if (search2.startsWith("?")) {
23135
+ search2 = search2.substring(1);
23136
+ }
23137
+ if (search2) {
23138
+ finalURL += `?${search2}`;
23139
+ }
23140
+ return finalURL;
23141
+ }
23142
+ function mergeHeaders(...allHeaders) {
23143
+ const finalHeaders = new Headers();
23144
+ for (const h of allHeaders) {
23145
+ if (!h || typeof h !== "object") {
23146
+ continue;
23147
+ }
23148
+ const iterator = h instanceof Headers ? h.entries() : Object.entries(h);
23149
+ for (const [k, v] of iterator) {
23150
+ if (v === null) {
23151
+ finalHeaders.delete(k);
23152
+ } else if (Array.isArray(v)) {
23153
+ for (const v2 of v) {
23154
+ finalHeaders.append(k, v2);
23155
+ }
23156
+ } else if (v !== void 0) {
23157
+ finalHeaders.set(k, v);
23158
+ }
23159
+ }
23160
+ }
23161
+ return finalHeaders;
23162
+ }
23163
+ function removeTrailingSlash(url2) {
23164
+ if (url2.endsWith("/")) {
23165
+ return url2.substring(0, url2.length - 1);
23166
+ }
23167
+ return url2;
23168
+ }
23169
+ var PATH_PARAM_RE, supportsRequestInitExt;
23170
+ var init_dist = __esm({
23171
+ "../../node_modules/.pnpm/openapi-fetch@0.17.0/node_modules/openapi-fetch/dist/index.mjs"() {
23172
+ "use strict";
23173
+ PATH_PARAM_RE = /\{[^{}]+\}/g;
23174
+ supportsRequestInitExt = () => {
23175
+ return typeof process === "object" && Number.parseInt(process?.versions?.node?.substring(0, 2)) >= 18 && process.versions.undici;
23176
+ };
23177
+ }
23178
+ });
23179
+
23180
+ // ../../node_modules/.pnpm/@antfly+sdk@0.0.14/node_modules/@antfly/sdk/dist/index.js
23181
+ var AntflyClient;
23182
+ var init_dist2 = __esm({
23183
+ "../../node_modules/.pnpm/@antfly+sdk@0.0.14/node_modules/@antfly/sdk/dist/index.js"() {
23184
+ "use strict";
23185
+ init_dist();
23186
+ AntflyClient = class {
23187
+ constructor(config2) {
23188
+ this.tables = {
23189
+ /**
23190
+ * List all tables
23191
+ */
23192
+ list: async (params) => {
23193
+ const { data, error: error46 } = await this.client.GET("/tables", {
23194
+ params: params ? { query: params } : void 0
23195
+ });
23196
+ if (error46) throw new Error(`Failed to list tables: ${error46.error}`);
23197
+ return data;
23198
+ },
23199
+ /**
23200
+ * Get table details and status
23201
+ */
23202
+ get: async (tableName) => {
23203
+ const { data, error: error46 } = await this.client.GET("/tables/{tableName}", {
23204
+ params: { path: { tableName } }
23205
+ });
23206
+ if (error46) throw new Error(`Failed to get table: ${error46.error}`);
23207
+ return data;
23208
+ },
23209
+ /**
23210
+ * Create a new table
23211
+ */
23212
+ create: async (tableName, config3 = {}) => {
23213
+ const { data, error: error46 } = await this.client.POST("/tables/{tableName}", {
23214
+ params: { path: { tableName } },
23215
+ body: config3
23216
+ });
23217
+ if (error46) throw new Error(`Failed to create table: ${error46.error}`);
23218
+ return data;
23219
+ },
23220
+ /**
23221
+ * Drop a table
23222
+ */
23223
+ drop: async (tableName) => {
23224
+ const { error: error46 } = await this.client.DELETE("/tables/{tableName}", {
23225
+ params: { path: { tableName } }
23226
+ });
23227
+ if (error46) throw new Error(`Failed to drop table: ${error46.error}`);
23228
+ return true;
23229
+ },
23230
+ /**
23231
+ * Update schema for a table
23232
+ */
23233
+ updateSchema: async (tableName, config3) => {
23234
+ const { data, error: error46 } = await this.client.PUT("/tables/{tableName}/schema", {
23235
+ params: { path: { tableName } },
23236
+ body: config3
23237
+ });
23238
+ if (error46) throw new Error(`Failed to update table schema: ${error46.error}`);
23239
+ return data;
23240
+ },
23241
+ /**
23242
+ * Query a specific table
23243
+ */
23244
+ query: async (tableName, request) => {
23245
+ return this.performQuery("/tables/{tableName}/query", request, tableName);
23246
+ },
23247
+ /**
23248
+ * Execute multiple queries on a specific table
23249
+ */
23250
+ multiquery: async (tableName, requests) => {
23251
+ return this.performMultiquery("/tables/{tableName}/query", requests, tableName);
23252
+ },
23253
+ /**
23254
+ * Perform batch operations on a table
23255
+ */
23256
+ batch: async (tableName, request) => {
23257
+ const { data, error: error46 } = await this.client.POST("/tables/{tableName}/batch", {
23258
+ params: { path: { tableName } },
23259
+ // @ts-expect-error Our BatchRequest type allows any object shape for inserts
23260
+ body: request
23261
+ });
23262
+ if (error46) throw new Error(`Batch operation failed: ${error46.error}`);
23263
+ return data;
23264
+ },
23265
+ /**
23266
+ * Backup a table
23267
+ */
23268
+ backup: async (tableName, request) => {
23269
+ const { data, error: error46 } = await this.client.POST("/tables/{tableName}/backup", {
23270
+ params: { path: { tableName } },
23271
+ body: request
23272
+ });
23273
+ if (error46) throw new Error(`Backup failed: ${error46.error}`);
23274
+ return data;
23275
+ },
23276
+ /**
23277
+ * Restore a table from backup
23278
+ */
23279
+ restore: async (tableName, request) => {
23280
+ const { data, error: error46 } = await this.client.POST("/tables/{tableName}/restore", {
23281
+ params: { path: { tableName } },
23282
+ body: request
23283
+ });
23284
+ if (error46) throw new Error(`Restore failed: ${error46.error}`);
23285
+ return data;
23286
+ },
23287
+ /**
23288
+ * Lookup a specific key in a table
23289
+ * @param tableName - Name of the table
23290
+ * @param key - Key of the record to lookup
23291
+ * @param options - Optional parameters
23292
+ * @param options.fields - Comma-separated list of fields to include (e.g., "title,author,metadata.tags")
23293
+ */
23294
+ lookup: async (tableName, key, options) => {
23295
+ const { data, error: error46 } = await this.client.GET("/tables/{tableName}/lookup/{key}", {
23296
+ params: {
23297
+ path: { tableName, key },
23298
+ query: options?.fields ? { fields: options.fields } : void 0
23299
+ }
23300
+ });
23301
+ if (error46) throw new Error(`Key lookup failed: ${error46.error}`);
23302
+ return data;
23303
+ },
23304
+ /**
23305
+ * Scan keys in a table within a key range
23306
+ * Returns documents as an async iterable, streaming results as NDJSON.
23307
+ * @param tableName - Name of the table
23308
+ * @param request - Scan request with optional key range, field projection, and filtering
23309
+ * @returns AsyncGenerator yielding documents with their keys
23310
+ */
23311
+ scan: (tableName, request) => {
23312
+ const config3 = this.config;
23313
+ const authHeader = this.getAuthHeader();
23314
+ async function* scanGenerator() {
23315
+ const headers = {
23316
+ "Content-Type": "application/json",
23317
+ Accept: "application/x-ndjson"
23318
+ };
23319
+ if (authHeader) {
23320
+ headers.Authorization = authHeader;
23321
+ }
23322
+ Object.assign(headers, config3.headers);
23323
+ const response = await fetch(`${config3.baseUrl}/tables/${tableName}/lookup`, {
23324
+ method: "POST",
23325
+ headers,
23326
+ body: JSON.stringify(request || {})
23327
+ });
23328
+ if (!response.ok) {
23329
+ const errorText = await response.text();
23330
+ throw new Error(`Scan failed: ${response.status} ${errorText}`);
23331
+ }
23332
+ if (!response.body) {
23333
+ throw new Error("Response body is null");
23334
+ }
23335
+ const reader = response.body.getReader();
23336
+ const decoder = new TextDecoder();
23337
+ let buffer = "";
23338
+ while (true) {
23339
+ const { done, value } = await reader.read();
23340
+ if (done) break;
23341
+ buffer += decoder.decode(value, { stream: true });
23342
+ const lines = buffer.split("\n");
23343
+ buffer = lines.pop() || "";
23344
+ for (const line of lines) {
23345
+ if (line.trim()) {
23346
+ yield JSON.parse(line);
23347
+ }
23348
+ }
23349
+ }
23350
+ if (buffer.trim()) {
23351
+ yield JSON.parse(buffer);
23352
+ }
23353
+ }
23354
+ return scanGenerator();
23355
+ },
23356
+ /**
23357
+ * Scan keys in a table and collect all results into an array
23358
+ * Convenience method that consumes the scan AsyncGenerator
23359
+ * @param tableName - Name of the table
23360
+ * @param request - Scan request with optional key range, field projection, and filtering
23361
+ * @returns Promise with array of all matching documents
23362
+ */
23363
+ scanAll: async (tableName, request) => {
23364
+ const results = [];
23365
+ for await (const doc of this.tables.scan(tableName, request)) {
23366
+ results.push(doc);
23367
+ }
23368
+ return results;
23369
+ }
23370
+ };
23371
+ this.indexes = {
23372
+ /**
23373
+ * List all indexes for a table
23374
+ */
23375
+ list: async (tableName) => {
23376
+ const { data, error: error46 } = await this.client.GET("/tables/{tableName}/indexes", {
23377
+ params: { path: { tableName } }
23378
+ });
23379
+ if (error46) throw new Error(`Failed to list indexes: ${error46.error}`);
23380
+ return data;
23381
+ },
23382
+ /**
23383
+ * Get index details
23384
+ */
23385
+ get: async (tableName, indexName) => {
23386
+ const { data, error: error46 } = await this.client.GET("/tables/{tableName}/indexes/{indexName}", {
23387
+ params: { path: { tableName, indexName } }
23388
+ });
23389
+ if (error46) throw new Error(`Failed to get index: ${error46.error}`);
23390
+ return data;
23391
+ },
23392
+ /**
23393
+ * Create a new index
23394
+ */
23395
+ create: async (tableName, config3) => {
23396
+ const { error: error46 } = await this.client.POST("/tables/{tableName}/indexes/{indexName}", {
23397
+ params: { path: { tableName, indexName: config3.name } },
23398
+ body: config3
23399
+ });
23400
+ if (error46) throw new Error(`Failed to create index: ${error46.error}`);
23401
+ return true;
23402
+ },
23403
+ /**
23404
+ * Drop an index
23405
+ */
23406
+ drop: async (tableName, indexName) => {
23407
+ const { error: error46 } = await this.client.DELETE("/tables/{tableName}/indexes/{indexName}", {
23408
+ params: { path: { tableName, indexName } }
23409
+ });
23410
+ if (error46) throw new Error(`Failed to drop index: ${error46.error}`);
23411
+ return true;
23412
+ }
23413
+ };
23414
+ this.users = {
23415
+ /**
23416
+ * Get current authenticated user
23417
+ */
23418
+ getCurrentUser: async () => {
23419
+ const { data, error: error46 } = await this.client.GET("/users/me");
23420
+ if (error46) throw new Error(`Failed to get current user: ${error46.error}`);
23421
+ return data;
23422
+ },
23423
+ /**
23424
+ * List all users
23425
+ */
23426
+ list: async () => {
23427
+ const { data, error: error46 } = await this.client.GET("/users");
23428
+ if (error46) throw new Error(`Failed to list users: ${error46.error}`);
23429
+ return data;
23430
+ },
23431
+ /**
23432
+ * Get user details
23433
+ */
23434
+ get: async (userName) => {
23435
+ const { data, error: error46 } = await this.client.GET("/users/{userName}", {
23436
+ params: { path: { userName } }
23437
+ });
23438
+ if (error46) throw new Error(`Failed to get user: ${error46.error}`);
23439
+ return data;
23440
+ },
23441
+ /**
23442
+ * Create a new user
23443
+ */
23444
+ create: async (userName, request) => {
23445
+ const { data, error: error46 } = await this.client.POST("/users/{userName}", {
23446
+ params: { path: { userName } },
23447
+ body: request
23448
+ });
23449
+ if (error46) throw new Error(`Failed to create user: ${error46.error}`);
23450
+ return data;
23451
+ },
23452
+ /**
23453
+ * Delete a user
23454
+ */
23455
+ delete: async (userName) => {
23456
+ const { error: error46 } = await this.client.DELETE("/users/{userName}", {
23457
+ params: { path: { userName } }
23458
+ });
23459
+ if (error46) throw new Error(`Failed to delete user: ${error46.error}`);
23460
+ return true;
23461
+ },
23462
+ /**
23463
+ * Update user password
23464
+ */
23465
+ updatePassword: async (userName, newPassword) => {
23466
+ const { data, error: error46 } = await this.client.PUT("/users/{userName}/password", {
23467
+ params: { path: { userName } },
23468
+ body: { new_password: newPassword }
23469
+ });
23470
+ if (error46) throw new Error(`Failed to update password: ${error46.error}`);
23471
+ return data;
23472
+ },
23473
+ /**
23474
+ * Get user permissions
23475
+ */
23476
+ getPermissions: async (userName) => {
23477
+ const { data, error: error46 } = await this.client.GET("/users/{userName}/permissions", {
23478
+ params: { path: { userName } }
23479
+ });
23480
+ if (error46) throw new Error(`Failed to get permissions: ${error46.error}`);
23481
+ return data;
23482
+ },
23483
+ /**
23484
+ * Add permission to user
23485
+ */
23486
+ addPermission: async (userName, permission) => {
23487
+ const { data, error: error46 } = await this.client.POST("/users/{userName}/permissions", {
23488
+ params: { path: { userName } },
23489
+ body: permission
23490
+ });
23491
+ if (error46) throw new Error(`Failed to add permission: ${error46.error}`);
23492
+ return data;
23493
+ },
23494
+ /**
23495
+ * Remove permission from user
23496
+ */
23497
+ removePermission: async (userName, resource, resourceType) => {
23498
+ const { error: error46 } = await this.client.DELETE("/users/{userName}/permissions", {
23499
+ params: {
23500
+ path: { userName },
23501
+ query: { resource, resourceType }
23502
+ }
23503
+ });
23504
+ if (error46) throw new Error(`Failed to remove permission: ${error46.error}`);
23505
+ return true;
23506
+ }
23507
+ };
23508
+ this.config = config2;
23509
+ this.client = this.buildClient();
22731
23510
  }
22732
23511
  /**
22733
- * Generate embedding for a single text
23512
+ * Build the Authorization header value from the auth config.
23513
+ * Returns undefined if no auth is configured.
22734
23514
  */
22735
- async embed(text3) {
22736
- if (!this.pipeline) {
22737
- throw new Error("Embedder not initialized. Call initialize() first.");
22738
- }
22739
- try {
22740
- const options = {
22741
- pooling: "mean",
22742
- // Mean pooling
22743
- normalize: true
22744
- // L2 normalization
22745
- };
22746
- const output = await this.pipeline(text3, options);
22747
- const tensorOutput = output;
22748
- if (tensorOutput?.data) {
22749
- return Array.from(tensorOutput.data);
23515
+ getAuthHeader() {
23516
+ const auth = this.config.auth;
23517
+ if (!auth) return void 0;
23518
+ if ("type" in auth) {
23519
+ switch (auth.type) {
23520
+ case "basic":
23521
+ return `Basic ${btoa(`${auth.username}:${auth.password}`)}`;
23522
+ case "apiKey":
23523
+ return `ApiKey ${btoa(`${auth.keyId}:${auth.keySecret}`)}`;
23524
+ case "bearer":
23525
+ return `Bearer ${auth.token}`;
22750
23526
  }
22751
- throw new Error("Unexpected output format from embedding model");
22752
- } catch (error46) {
22753
- throw new Error(
22754
- `Failed to generate embedding: ${error46 instanceof Error ? error46.message : String(error46)}`
22755
- );
22756
23527
  }
23528
+ return `Basic ${btoa(`${auth.username}:${auth.password}`)}`;
22757
23529
  }
22758
23530
  /**
22759
- * Generate embeddings for multiple texts (batched for efficiency)
23531
+ * Build the openapi-fetch client with current config.
22760
23532
  */
22761
- async embedBatch(texts) {
22762
- if (!this.pipeline) {
22763
- throw new Error("Embedder not initialized. Call initialize() first.");
22764
- }
22765
- if (texts.length === 0) {
22766
- return [];
23533
+ buildClient() {
23534
+ const headers = {
23535
+ "Content-Type": "application/json",
23536
+ ...this.config.headers
23537
+ };
23538
+ const authHeader = this.getAuthHeader();
23539
+ if (authHeader) {
23540
+ headers.Authorization = authHeader;
22767
23541
  }
22768
- try {
22769
- const embeddings = [];
22770
- for (let i = 0; i < texts.length; i += this.batchSize) {
22771
- const batch = texts.slice(i, i + this.batchSize);
22772
- const batchEmbeddings = await Promise.all(batch.map((text3) => this.embed(text3)));
22773
- embeddings.push(...batchEmbeddings);
23542
+ return createClient({
23543
+ baseUrl: this.config.baseUrl,
23544
+ headers,
23545
+ bodySerializer: (body) => {
23546
+ if (typeof body === "string") {
23547
+ return body;
23548
+ }
23549
+ return JSON.stringify(body);
22774
23550
  }
22775
- return embeddings;
22776
- } catch (error46) {
22777
- throw new Error(
22778
- `Failed to generate batch embeddings: ${error46 instanceof Error ? error46.message : String(error46)}`
22779
- );
23551
+ });
23552
+ }
23553
+ setAuth(authOrUsername, password) {
23554
+ if (typeof authOrUsername === "string" && password !== void 0) {
23555
+ this.config.auth = { username: authOrUsername, password };
23556
+ } else {
23557
+ this.config.auth = authOrUsername;
22780
23558
  }
23559
+ this.client = this.buildClient();
23560
+ }
23561
+ /**
23562
+ * Get cluster status
23563
+ */
23564
+ async getStatus() {
23565
+ const { data, error: error46 } = await this.client.GET("/status");
23566
+ if (error46) throw new Error(`Failed to get status: ${error46.error}`);
23567
+ return data;
22781
23568
  }
22782
23569
  /**
22783
- * Set batch size for batch processing
23570
+ * Private helper for query requests to avoid code duplication
22784
23571
  */
22785
- setBatchSize(size) {
22786
- if (size < 1) {
22787
- throw new Error("Batch size must be at least 1");
23572
+ async performQuery(path16, request, tableName) {
23573
+ if (path16 === "/tables/{tableName}/query" && tableName) {
23574
+ const { data, error: error46 } = await this.client.POST("/tables/{tableName}/query", {
23575
+ params: { path: { tableName } },
23576
+ body: request
23577
+ });
23578
+ if (error46) throw new Error(`Table query failed: ${error46.error}`);
23579
+ return data;
23580
+ } else {
23581
+ const { data, error: error46 } = await this.client.POST("/query", {
23582
+ body: request
23583
+ });
23584
+ if (error46) throw new Error(`Query failed: ${error46.error}`);
23585
+ return data;
22788
23586
  }
22789
- this.batchSize = size;
22790
23587
  }
22791
23588
  /**
22792
- * Get current batch size
23589
+ * Private helper for multiquery requests to avoid code duplication
22793
23590
  */
22794
- getBatchSize() {
22795
- return this.batchSize;
23591
+ async performMultiquery(path16, requests, tableName) {
23592
+ const ndjson = `${requests.map((request) => JSON.stringify(request)).join("\n")}
23593
+ `;
23594
+ if (path16 === "/tables/{tableName}/query" && tableName) {
23595
+ const { data, error: error46 } = await this.client.POST("/tables/{tableName}/query", {
23596
+ params: { path: { tableName } },
23597
+ body: ndjson,
23598
+ headers: {
23599
+ "Content-Type": "application/x-ndjson"
23600
+ }
23601
+ });
23602
+ if (error46) throw new Error(`Table multi-query failed: ${error46.error}`);
23603
+ return data;
23604
+ } else {
23605
+ const { data, error: error46 } = await this.client.POST("/query", {
23606
+ body: ndjson,
23607
+ headers: {
23608
+ "Content-Type": "application/x-ndjson"
23609
+ }
23610
+ });
23611
+ if (error46) throw new Error(`Multi-query failed: ${error46.error}`);
23612
+ return data;
23613
+ }
22796
23614
  }
22797
- };
22798
- }
22799
- });
22800
-
22801
- // ../core/src/vector/store.ts
22802
- var lancedb, LanceDBVectorStore;
22803
- var init_store = __esm({
22804
- "../core/src/vector/store.ts"() {
22805
- "use strict";
22806
- lancedb = __toESM(require("@lancedb/lancedb"));
22807
- LanceDBVectorStore = class {
22808
- path;
22809
- tableName = "documents";
22810
- connection = null;
22811
- table = null;
22812
- constructor(path16, _dimension = 384) {
22813
- this.path = path16;
23615
+ /**
23616
+ * Global query operations
23617
+ */
23618
+ async query(request) {
23619
+ const data = await this.performQuery("/query", request);
23620
+ return data?.responses?.[0];
22814
23621
  }
22815
23622
  /**
22816
- * Initialize the vector store
23623
+ * Execute multiple queries in a single request
22817
23624
  */
22818
- async initialize() {
22819
- if (this.connection) {
22820
- return;
22821
- }
22822
- try {
22823
- this.connection = await lancedb.connect(this.path);
22824
- const tableNames = await this.connection.tableNames();
22825
- if (tableNames.includes(this.tableName)) {
22826
- this.table = await this.connection.openTable(this.tableName);
22827
- }
22828
- } catch (error46) {
22829
- throw new Error(
22830
- `Failed to initialize LanceDB at ${this.path}: ${error46 instanceof Error ? error46.message : String(error46)}`
22831
- );
22832
- }
23625
+ async multiquery(requests) {
23626
+ return this.performMultiquery("/query", requests);
22833
23627
  }
22834
23628
  /**
22835
- * Add documents to the store using upsert (prevents duplicates)
23629
+ * Private helper for Retrieval Agent requests to handle streaming and non-streaming responses
22836
23630
  */
22837
- async add(documents, embeddings) {
22838
- if (!this.connection) {
22839
- throw new Error("Store not initialized. Call initialize() first.");
23631
+ async performRetrievalAgent(request, callbacks) {
23632
+ const headers = {
23633
+ "Content-Type": "application/json",
23634
+ Accept: "text/event-stream, application/json"
23635
+ };
23636
+ const authHeader = this.getAuthHeader();
23637
+ if (authHeader) {
23638
+ headers.Authorization = authHeader;
23639
+ }
23640
+ Object.assign(headers, this.config.headers);
23641
+ const abortController = new AbortController();
23642
+ const response = await fetch(`${this.config.baseUrl}/agents/retrieval`, {
23643
+ method: "POST",
23644
+ headers,
23645
+ body: JSON.stringify(request),
23646
+ signal: abortController.signal
23647
+ });
23648
+ if (!response.ok) {
23649
+ const errorText = await response.text();
23650
+ throw new Error(`Retrieval agent request failed: ${response.status} ${errorText}`);
22840
23651
  }
22841
- if (documents.length !== embeddings.length) {
22842
- throw new Error("Number of documents must match number of embeddings");
23652
+ if (!response.body) {
23653
+ throw new Error("Response body is null");
22843
23654
  }
22844
- if (documents.length === 0) {
22845
- return;
23655
+ const contentType = response.headers.get("content-type") || "";
23656
+ const isJSON = contentType.includes("application/json");
23657
+ if (isJSON) {
23658
+ const result = await response.json();
23659
+ return result;
22846
23660
  }
22847
- try {
22848
- const data = documents.map((doc, i) => ({
22849
- id: doc.id,
22850
- text: doc.text,
22851
- vector: embeddings[i],
22852
- metadata: JSON.stringify(doc.metadata)
22853
- }));
22854
- if (!this.table) {
23661
+ if (callbacks) {
23662
+ const reader = response.body.getReader();
23663
+ const decoder = new TextDecoder();
23664
+ let buffer = "";
23665
+ let currentEvent = "";
23666
+ (async () => {
22855
23667
  try {
22856
- this.table = await this.connection.createTable(this.tableName, data);
22857
- await this.ensureIdIndex();
22858
- } catch (createError) {
22859
- if (createError instanceof Error && createError.message.includes("already exists")) {
22860
- this.table = await this.connection.openTable(this.tableName);
22861
- await this.table.mergeInsert("id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(data);
22862
- } else {
22863
- throw createError;
23668
+ while (true) {
23669
+ const { done, value } = await reader.read();
23670
+ if (done) break;
23671
+ buffer += decoder.decode(value, { stream: true });
23672
+ const lines = buffer.split("\n");
23673
+ buffer = lines.pop() || "";
23674
+ for (const line of lines) {
23675
+ if (!line.trim()) {
23676
+ currentEvent = "";
23677
+ continue;
23678
+ }
23679
+ if (line.startsWith("event: ")) {
23680
+ currentEvent = line.slice(7).trim();
23681
+ } else if (line.startsWith("data: ")) {
23682
+ const data = line.slice(6).trim();
23683
+ try {
23684
+ switch (currentEvent) {
23685
+ case "classification":
23686
+ if (callbacks.onClassification) {
23687
+ callbacks.onClassification(JSON.parse(data));
23688
+ }
23689
+ break;
23690
+ case "reasoning":
23691
+ if (callbacks.onReasoning) {
23692
+ callbacks.onReasoning(JSON.parse(data));
23693
+ }
23694
+ break;
23695
+ case "clarification_required":
23696
+ if (callbacks.onClarificationRequired) {
23697
+ callbacks.onClarificationRequired(JSON.parse(data));
23698
+ }
23699
+ break;
23700
+ case "filter_applied":
23701
+ if (callbacks.onFilterApplied) {
23702
+ callbacks.onFilterApplied(JSON.parse(data));
23703
+ }
23704
+ break;
23705
+ case "search_executed":
23706
+ if (callbacks.onSearchExecuted) {
23707
+ callbacks.onSearchExecuted(JSON.parse(data));
23708
+ }
23709
+ break;
23710
+ case "hit":
23711
+ if (callbacks.onHit) {
23712
+ callbacks.onHit(JSON.parse(data));
23713
+ }
23714
+ break;
23715
+ case "generation":
23716
+ if (callbacks.onGeneration) {
23717
+ callbacks.onGeneration(JSON.parse(data));
23718
+ }
23719
+ break;
23720
+ case "step_started":
23721
+ if (callbacks.onStepStarted) {
23722
+ callbacks.onStepStarted(JSON.parse(data));
23723
+ }
23724
+ break;
23725
+ case "step_progress":
23726
+ if (callbacks.onStepProgress) {
23727
+ callbacks.onStepProgress(JSON.parse(data));
23728
+ }
23729
+ break;
23730
+ case "step_completed":
23731
+ if (callbacks.onStepCompleted) {
23732
+ callbacks.onStepCompleted(JSON.parse(data));
23733
+ }
23734
+ break;
23735
+ case "confidence":
23736
+ if (callbacks.onConfidence) {
23737
+ callbacks.onConfidence(JSON.parse(data));
23738
+ }
23739
+ break;
23740
+ case "followup":
23741
+ if (callbacks.onFollowup) {
23742
+ callbacks.onFollowup(JSON.parse(data));
23743
+ }
23744
+ break;
23745
+ case "eval":
23746
+ if (callbacks.onEvalResult) {
23747
+ callbacks.onEvalResult(JSON.parse(data));
23748
+ }
23749
+ break;
23750
+ case "done":
23751
+ if (callbacks.onDone) {
23752
+ callbacks.onDone(JSON.parse(data));
23753
+ }
23754
+ return;
23755
+ case "error":
23756
+ if (callbacks.onError) {
23757
+ callbacks.onError(JSON.parse(data));
23758
+ }
23759
+ throw new Error(data);
23760
+ }
23761
+ } catch (e) {
23762
+ console.warn("Failed to parse SSE data:", currentEvent, data, e);
23763
+ }
23764
+ }
23765
+ }
23766
+ }
23767
+ } catch (error46) {
23768
+ if (error46.name !== "AbortError") {
23769
+ console.error("Retrieval agent streaming error:", error46);
22864
23770
  }
22865
23771
  }
22866
- } else {
22867
- await this.table.mergeInsert("id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(data);
22868
- }
22869
- } catch (error46) {
22870
- throw new Error(
22871
- `Failed to add documents: ${error46 instanceof Error ? error46.message : String(error46)}`
22872
- );
23772
+ })();
22873
23773
  }
23774
+ return abortController;
22874
23775
  }
22875
23776
  /**
22876
- * Search for similar documents
23777
+ * Retrieval Agent - Unified retrieval pipeline with optional classification, generation, and eval
23778
+ * Supports pipeline mode (structured queries) and agentic mode (tool-calling with LLM)
23779
+ * Configure steps.classification, steps.answer, steps.eval to enable additional pipeline stages
23780
+ * @param request - Retrieval agent request with query, mode, and optional step configs
23781
+ * @param callbacks - Optional callbacks for SSE events (classification, reasoning, hit, answer, citation, confidence, followup_question, eval, done, error)
23782
+ * @returns Promise with RetrievalAgentResult (JSON) or AbortController (when streaming)
22877
23783
  */
22878
- async search(queryEmbedding, options = {}) {
22879
- if (!this.table) {
22880
- return [];
22881
- }
22882
- const { limit = 10, scoreThreshold = 0 } = options;
22883
- try {
22884
- const results = await this.table.search(queryEmbedding).limit(limit).toArray();
22885
- return results.map((result) => {
22886
- const distance = result._distance !== void 0 ? result._distance : Number.POSITIVE_INFINITY;
22887
- const score = Math.exp(-(distance * distance));
22888
- return {
22889
- id: result.id,
22890
- score,
22891
- metadata: JSON.parse(result.metadata)
22892
- };
22893
- }).filter((result) => result.score >= scoreThreshold);
22894
- } catch (error46) {
22895
- throw new Error(
22896
- `Failed to search: ${error46 instanceof Error ? error46.message : String(error46)}`
23784
+ async retrievalAgent(request, callbacks) {
23785
+ return this.performRetrievalAgent(request, callbacks);
23786
+ }
23787
+ /**
23788
+ * Chat Agent - Multi-turn conversational retrieval with message history management.
23789
+ * Wraps the retrieval agent with automatic message accumulation.
23790
+ * @param userMessage - The user's message for this turn
23791
+ * @param config - Chat configuration (generator, table, indexes, etc.)
23792
+ * @param history - Previous conversation messages (pass result.messages from prior turns)
23793
+ * @param callbacks - Optional streaming callbacks including chat-specific events
23794
+ * @returns For streaming: { abortController, messages } where messages is a Promise.
23795
+ * For non-streaming: { result, messages }
23796
+ */
23797
+ async chatAgent(userMessage, config2, history = [], callbacks) {
23798
+ const request = {
23799
+ query: userMessage,
23800
+ queries: [
23801
+ {
23802
+ table: config2.table,
23803
+ semantic_search: userMessage,
23804
+ indexes: config2.semanticIndexes,
23805
+ limit: config2.limit ?? 10
23806
+ }
23807
+ ],
23808
+ generator: config2.generator,
23809
+ messages: [...history, { role: "user", content: userMessage }],
23810
+ max_iterations: config2.maxIterations ?? 5,
23811
+ stream: !!callbacks,
23812
+ agent_knowledge: config2.agentKnowledge
23813
+ };
23814
+ if (config2.steps) {
23815
+ request.steps = config2.steps;
23816
+ }
23817
+ if (callbacks) {
23818
+ let answerText = "";
23819
+ let resolveMessages;
23820
+ const messagesPromise = new Promise((resolve4) => {
23821
+ resolveMessages = resolve4;
23822
+ });
23823
+ const wrappedCallbacks = {
23824
+ ...callbacks,
23825
+ onGeneration: (chunk) => {
23826
+ answerText += chunk;
23827
+ callbacks.onGeneration?.(chunk);
23828
+ },
23829
+ onDone: (data) => {
23830
+ const updatedMessages2 = [
23831
+ ...history,
23832
+ { role: "user", content: userMessage },
23833
+ { role: "assistant", content: answerText }
23834
+ ];
23835
+ callbacks.onAssistantMessage?.(answerText);
23836
+ callbacks.onMessagesUpdated?.(updatedMessages2);
23837
+ callbacks.onDone?.(data);
23838
+ resolveMessages(updatedMessages2);
23839
+ }
23840
+ };
23841
+ const abortController = await this.performRetrievalAgent(
23842
+ request,
23843
+ wrappedCallbacks
22897
23844
  );
23845
+ return { abortController, messages: messagesPromise };
22898
23846
  }
23847
+ const result = await this.performRetrievalAgent(request);
23848
+ const updatedMessages = result.messages?.length ? result.messages : [
23849
+ ...history,
23850
+ { role: "user", content: userMessage },
23851
+ ...result.generation ? [{ role: "assistant", content: result.generation }] : []
23852
+ ];
23853
+ return { result, messages: updatedMessages };
22899
23854
  }
22900
23855
  /**
22901
- * Get all documents without semantic search (fast scan)
22902
- * Use this when you need all documents and don't need relevance ranking
23856
+ * Query Builder Agent - Translates natural language into structured search queries
23857
+ * Uses an LLM to generate optimized Bleve queries from user intent
23858
+ * @param request - Query builder request with intent and optional table/schema context
23859
+ * @returns Promise with QueryBuilderResult containing the generated query, explanation, and confidence
22903
23860
  */
22904
- async getAll(options = {}) {
22905
- if (!this.table) {
22906
- return [];
22907
- }
22908
- const { limit = 1e4 } = options;
23861
+ async queryBuilderAgent(request) {
23862
+ const { data, error: error46 } = await this.client.POST("/agents/query-builder", {
23863
+ body: request
23864
+ });
23865
+ if (error46) throw new Error(`Query builder agent failed: ${error46.error}`);
23866
+ return data;
23867
+ }
23868
+ /**
23869
+ * Standalone evaluation for testing evaluators without running a query.
23870
+ * Evaluates a generated output against ground truth using LLM-as-judge metrics.
23871
+ * @param request - Eval request with evaluators, judge config, query, output, and ground truth
23872
+ * @returns Evaluation result with scores for each evaluator
23873
+ */
23874
+ async evaluate(request) {
23875
+ const { data, error: error46 } = await this.client.POST("/eval", {
23876
+ body: request
23877
+ });
23878
+ if (error46) throw new Error(`Evaluation failed: ${error46.error}`);
23879
+ return data;
23880
+ }
23881
+ /**
23882
+ * Get the underlying OpenAPI client for advanced use cases
23883
+ */
23884
+ getRawClient() {
23885
+ return this.client;
23886
+ }
23887
+ };
23888
+ }
23889
+ });
23890
+
23891
+ // ../core/src/vector/antfly-store.ts
23892
+ var MODEL_DIMENSIONS, DEFAULT_MODEL, DEFAULT_BASE_URL, BATCH_SIZE, AntflyVectorStore;
23893
+ var init_antfly_store = __esm({
23894
+ "../core/src/vector/antfly-store.ts"() {
23895
+ "use strict";
23896
+ init_dist2();
23897
+ MODEL_DIMENSIONS = {
23898
+ "BAAI/bge-small-en-v1.5": 384,
23899
+ "mxbai-embed-large-v1": 1024,
23900
+ "nomic-ai/nomic-embed-text-v1.5": 768,
23901
+ "openai/clip-vit-base-patch32": 512
23902
+ };
23903
+ DEFAULT_MODEL = "BAAI/bge-small-en-v1.5";
23904
+ DEFAULT_BASE_URL = process.env.ANTFLY_URL ?? "http://localhost:18080/api/v1";
23905
+ BATCH_SIZE = 500;
23906
+ AntflyVectorStore = class {
23907
+ path;
23908
+ cfg;
23909
+ client;
23910
+ initialized = false;
23911
+ constructor(config2) {
23912
+ this.cfg = {
23913
+ baseUrl: config2.baseUrl ?? DEFAULT_BASE_URL,
23914
+ table: config2.table,
23915
+ indexName: config2.indexName ?? "content",
23916
+ template: config2.template ?? "{{text}}",
23917
+ model: config2.model ?? DEFAULT_MODEL
23918
+ };
23919
+ this.path = `${this.cfg.baseUrl}/${this.cfg.table}`;
23920
+ this.client = new AntflyClient({ baseUrl: this.cfg.baseUrl });
23921
+ }
23922
+ async initialize() {
23923
+ if (this.initialized) return;
22909
23924
  try {
22910
- const results = await this.table.query().select(["id", "text", "metadata"]).limit(limit).toArray();
22911
- return results.map((result) => ({
22912
- id: result.id,
22913
- score: 1,
22914
- // No relevance score for full scan
22915
- metadata: JSON.parse(result.metadata)
22916
- }));
23925
+ const tableNames = await this.listTableNames();
23926
+ if (tableNames.includes(this.cfg.table)) {
23927
+ await this.checkModelMismatch();
23928
+ } else {
23929
+ await this.createTableWithIndex();
23930
+ }
23931
+ this.initialized = true;
22917
23932
  } catch (error46) {
23933
+ if (error46 instanceof Error && error46.message.includes("Model mismatch")) throw error46;
22918
23934
  throw new Error(
22919
- `Failed to get all documents: ${error46 instanceof Error ? error46.message : String(error46)}`
23935
+ `Failed to initialize Antfly store (${this.cfg.table}): ${error46 instanceof Error ? error46.message : String(error46)}`
22920
23936
  );
22921
23937
  }
22922
23938
  }
22923
23939
  /**
22924
- * Find similar documents to a given document by ID
22925
- * Uses the document's existing embedding for efficient similarity search
23940
+ * Add documents. Embeddings param is ignored Antfly auto-embeds via Termite.
22926
23941
  */
22927
- async searchByDocumentId(documentId, options = {}) {
22928
- if (!this.table) {
22929
- return [];
23942
+ async add(documents, _embeddings) {
23943
+ if (documents.length === 0) return;
23944
+ this.assertReady();
23945
+ for (let i = 0; i < documents.length; i += BATCH_SIZE) {
23946
+ const batch = documents.slice(i, i + BATCH_SIZE);
23947
+ const inserts = {};
23948
+ for (const doc of batch) {
23949
+ inserts[doc.id] = { text: doc.text, metadata: JSON.stringify(doc.metadata) };
23950
+ }
23951
+ try {
23952
+ await this.batchOp({ inserts });
23953
+ } catch (error46) {
23954
+ throw new Error(
23955
+ `Failed to add documents (batch ${Math.floor(i / BATCH_SIZE) + 1}): ${error46 instanceof Error ? error46.message : String(error46)}`
23956
+ );
23957
+ }
22930
23958
  }
23959
+ }
23960
+ /**
23961
+ * VectorStore interface method — throws. Use searchText() instead.
23962
+ */
23963
+ async search(_queryEmbedding, _options) {
23964
+ throw new Error(
23965
+ "AntflyVectorStore.search() does not accept pre-computed embeddings. Use searchText(query, options) instead \u2014 Antfly handles embedding internally."
23966
+ );
23967
+ }
23968
+ /**
23969
+ * Search by text using Antfly's hybrid search (BM25 + vector + RRF).
23970
+ */
23971
+ async searchText(query, options = {}) {
23972
+ this.assertReady();
23973
+ const { limit = 10, scoreThreshold = 0 } = options;
22931
23974
  try {
22932
- const results = await this.table.query().where(`id = '${documentId}'`).select(["id", "vector"]).limit(1).toArray();
22933
- if (results.length === 0) {
22934
- return [];
22935
- }
22936
- const documentEmbedding = results[0].vector;
22937
- return this.search(documentEmbedding, options);
23975
+ const resp = await this.queryTable({
23976
+ semantic_search: query,
23977
+ indexes: [this.cfg.indexName],
23978
+ limit
23979
+ });
23980
+ return this.extractHits(resp).map((hit) => ({
23981
+ id: hit._id,
23982
+ score: hit._score,
23983
+ metadata: this.parseMetadata(hit._source)
23984
+ })).filter((r) => r.score >= scoreThreshold);
22938
23985
  } catch (error46) {
22939
23986
  throw new Error(
22940
- `Failed to search by document ID: ${error46 instanceof Error ? error46.message : String(error46)}`
23987
+ `Failed to search: ${error46 instanceof Error ? error46.message : String(error46)}`
22941
23988
  );
22942
23989
  }
22943
23990
  }
22944
- /**
22945
- * Get a document by ID
22946
- */
22947
23991
  async get(id) {
22948
- if (!this.table) {
22949
- return null;
22950
- }
23992
+ this.assertReady();
22951
23993
  try {
22952
- const dummyVector = new Array(384).fill(0);
22953
- const results = await this.table.search(dummyVector).limit(1e4).toArray();
22954
- const result = results.find((r) => r.id === id);
22955
- if (!result) {
22956
- return null;
22957
- }
23994
+ const result = await this.client.tables.lookup(this.cfg.table, id);
23995
+ if (!result) return null;
22958
23996
  return {
22959
- id: result.id,
22960
- text: result.text,
22961
- metadata: JSON.parse(result.metadata)
23997
+ id,
23998
+ text: result.text ?? "",
23999
+ metadata: this.parseRawMetadata(result.metadata)
22962
24000
  };
22963
24001
  } catch (error46) {
24002
+ if (String(error46).includes("404") || String(error46).includes("not found")) return null;
22964
24003
  throw new Error(
22965
24004
  `Failed to get document: ${error46 instanceof Error ? error46.message : String(error46)}`
22966
24005
  );
22967
24006
  }
22968
24007
  }
22969
- /**
22970
- * Delete documents by ID
22971
- */
22972
24008
  async delete(ids) {
22973
- if (!this.table || ids.length === 0) {
22974
- return;
22975
- }
24009
+ this.assertReady();
24010
+ if (ids.length === 0) return;
22976
24011
  try {
22977
- const escapedIds = ids.map((id) => id.replace(/'/g, "''"));
22978
- const predicate = `id IN ('${escapedIds.join("', '")}')`;
22979
- await this.table.delete(predicate);
24012
+ await this.batchOp({ deletes: ids });
22980
24013
  } catch (error46) {
22981
24014
  throw new Error(
22982
24015
  `Failed to delete documents: ${error46 instanceof Error ? error46.message : String(error46)}`
22983
24016
  );
22984
24017
  }
22985
24018
  }
22986
- /**
22987
- * Clear all documents from the store (destructive operation)
22988
- */
22989
- async clear() {
22990
- if (!this.connection) {
22991
- return;
24019
+ async count() {
24020
+ this.assertReady();
24021
+ try {
24022
+ const resp = await this.queryTable({ limit: 1 });
24023
+ return resp?.hits?.total ?? 0;
24024
+ } catch {
24025
+ return 0;
22992
24026
  }
24027
+ }
24028
+ async getAll(options = {}) {
24029
+ this.assertReady();
24030
+ const { limit = 1e4 } = options;
22993
24031
  try {
22994
- if (this.table) {
22995
- await this.connection.dropTable("documents");
22996
- this.table = null;
22997
- }
24032
+ const resp = await this.queryTable({ limit });
24033
+ return this.extractHits(resp).map((hit) => ({
24034
+ id: hit._id,
24035
+ score: 1,
24036
+ metadata: this.parseMetadata(hit._source)
24037
+ }));
22998
24038
  } catch (error46) {
22999
24039
  throw new Error(
23000
- `Failed to clear vector store: ${error46 instanceof Error ? error46.message : String(error46)}`
24040
+ `Failed to get all documents: ${error46 instanceof Error ? error46.message : String(error46)}`
23001
24041
  );
23002
24042
  }
23003
24043
  }
23004
- /**
23005
- * Count total documents
23006
- */
23007
- async count() {
23008
- if (!this.table) {
23009
- return 0;
23010
- }
24044
+ async searchByDocumentId(documentId, options = {}) {
24045
+ this.assertReady();
24046
+ const doc = await this.get(documentId);
24047
+ if (!doc) return [];
24048
+ return this.searchText(doc.text, options);
24049
+ }
24050
+ async clear() {
24051
+ this.assertReady();
23011
24052
  try {
23012
- return await this.table.countRows();
24053
+ await this.client.tables.drop(this.cfg.table);
24054
+ await this.createTableWithIndex();
23013
24055
  } catch (error46) {
23014
24056
  throw new Error(
23015
- `Failed to count documents: ${error46 instanceof Error ? error46.message : String(error46)}`
24057
+ `Failed to clear store: ${error46 instanceof Error ? error46.message : String(error46)}`
23016
24058
  );
23017
24059
  }
23018
24060
  }
23019
- /**
23020
- * Optimize the vector store (compact fragments, update indices)
23021
- */
23022
24061
  async optimize() {
23023
- if (!this.table) {
23024
- return;
23025
- }
24062
+ }
24063
+ async close() {
24064
+ this.initialized = false;
24065
+ }
24066
+ getModelInfo() {
24067
+ return {
24068
+ dimension: MODEL_DIMENSIONS[this.cfg.model] ?? 384,
24069
+ modelName: this.cfg.model
24070
+ };
24071
+ }
24072
+ async getStorageSize() {
23026
24073
  try {
23027
- await this.table.optimize();
23028
- } catch (error46) {
23029
- throw new Error(
23030
- `Failed to optimize: ${error46 instanceof Error ? error46.message : String(error46)}`
23031
- );
24074
+ const info = await this.getTableInfo();
24075
+ return info?.storage_status?.disk_usage ?? 0;
24076
+ } catch {
24077
+ return 0;
23032
24078
  }
23033
24079
  }
23034
- /**
23035
- * Ensure scalar index exists on 'id' column for fast upsert operations
23036
- */
23037
- async ensureIdIndex() {
23038
- if (!this.table) {
23039
- return;
24080
+ // ── SDK boundary layer ──
24081
+ // These methods isolate the SDK's loosely-typed API behind our own types.
24082
+ async listTableNames() {
24083
+ const raw = await this.client.tables.list();
24084
+ const tables = raw;
24085
+ if (!Array.isArray(tables)) return [];
24086
+ return tables.map((t) => typeof t === "string" ? t : t.name);
24087
+ }
24088
+ async createTableWithIndex() {
24089
+ const body = {
24090
+ indexes: {
24091
+ [this.cfg.indexName]: {
24092
+ type: "embeddings",
24093
+ template: this.cfg.template,
24094
+ embedder: { provider: "termite", model: this.cfg.model }
24095
+ }
24096
+ }
24097
+ };
24098
+ await this.client.tables.create(this.cfg.table, body);
24099
+ }
24100
+ async getTableInfo() {
24101
+ const raw = await this.client.tables.get(this.cfg.table);
24102
+ return raw ?? null;
24103
+ }
24104
+ async queryTable(params) {
24105
+ const raw = await this.client.query({
24106
+ table: this.cfg.table,
24107
+ ...params
24108
+ });
24109
+ return raw;
24110
+ }
24111
+ async batchOp(body) {
24112
+ await this.client.tables.batch(this.cfg.table, body);
24113
+ }
24114
+ // ── Helpers ──
24115
+ assertReady() {
24116
+ if (!this.initialized) {
24117
+ throw new Error("Store not initialized. Call initialize() first.");
23040
24118
  }
24119
+ }
24120
+ async checkModelMismatch() {
23041
24121
  try {
23042
- await this.table.createIndex("id");
24122
+ const info = await this.getTableInfo();
24123
+ const embeddingIndex = info?.indexes?.[this.cfg.indexName];
24124
+ if (embeddingIndex?.embedder?.model && embeddingIndex.embedder.model !== this.cfg.model) {
24125
+ throw new Error(
24126
+ `Model mismatch: table "${this.cfg.table}" uses "${embeddingIndex.embedder.model}" but config specifies "${this.cfg.model}". Run \`dev index . --force\` to re-index with the new model.`
24127
+ );
24128
+ }
23043
24129
  } catch (error46) {
23044
- console.warn(
23045
- `Could not create index on 'id' column: ${error46 instanceof Error ? error46.message : String(error46)}`
23046
- );
24130
+ if (error46 instanceof Error && error46.message.includes("Model mismatch")) throw error46;
23047
24131
  }
23048
24132
  }
23049
- /**
23050
- * Close the store
23051
- */
23052
- async close() {
23053
- this.table = null;
23054
- this.connection = null;
24133
+ extractHits(resp) {
24134
+ return resp?.hits?.hits ?? [];
24135
+ }
24136
+ parseMetadata(source) {
24137
+ if (!source) return {};
24138
+ const metadataField = source.metadata;
24139
+ if (typeof metadataField === "string") {
24140
+ try {
24141
+ return JSON.parse(metadataField);
24142
+ } catch {
24143
+ return {};
24144
+ }
24145
+ }
24146
+ if (metadataField && typeof metadataField === "object") {
24147
+ return metadataField;
24148
+ }
24149
+ const { text: _, metadata: __, _timestamp: ___, ...rest } = source;
24150
+ return rest;
24151
+ }
24152
+ parseRawMetadata(metadata) {
24153
+ if (typeof metadata === "string") {
24154
+ try {
24155
+ return JSON.parse(metadata);
24156
+ } catch {
24157
+ return {};
24158
+ }
24159
+ }
24160
+ if (metadata && typeof metadata === "object") {
24161
+ return metadata;
24162
+ }
24163
+ return {};
23055
24164
  }
23056
24165
  };
23057
24166
  }
@@ -23067,160 +24176,117 @@ var init_types2 = __esm({
23067
24176
  // ../core/src/vector/index.ts
23068
24177
  var vector_exports = {};
23069
24178
  __export(vector_exports, {
23070
- LanceDBVectorStore: () => LanceDBVectorStore,
23071
- TransformersEmbedder: () => TransformersEmbedder,
24179
+ AntflyVectorStore: () => AntflyVectorStore,
23072
24180
  VectorStorage: () => VectorStorage
23073
24181
  });
23074
- var fs6, VectorStorage;
24182
+ function deriveTableName(storePath) {
24183
+ const parts = storePath.replace(/\/$/, "").split("/");
24184
+ const last = parts.at(-1) ?? "code";
24185
+ const projectDir = parts.at(-2) ?? "default";
24186
+ const project = projectDir.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
24187
+ if (last === "vectors") return `dev-agent-${project}-code`;
24188
+ if (last === "vectors-git") return `dev-agent-${project}-git`;
24189
+ if (last === "vectors-github") return `dev-agent-${project}-github`;
24190
+ return `dev-agent-${project}-${last.replace(/[^a-zA-Z0-9-]/g, "-")}`;
24191
+ }
24192
+ var VectorStorage;
23075
24193
  var init_vector = __esm({
23076
24194
  "../core/src/vector/index.ts"() {
23077
24195
  "use strict";
23078
- init_embedder();
23079
- init_store();
24196
+ init_antfly_store();
23080
24197
  init_types2();
23081
- fs6 = __toESM(require("fs/promises"));
23082
- init_embedder();
23083
- init_store();
24198
+ init_antfly_store();
23084
24199
  VectorStorage = class {
23085
- embedder;
23086
24200
  store;
23087
24201
  initialized = false;
23088
24202
  constructor(config2) {
23089
- const { storePath, embeddingModel = "Xenova/all-MiniLM-L6-v2", dimension = 384 } = config2;
23090
- this.embedder = new TransformersEmbedder(embeddingModel, dimension);
23091
- this.store = new LanceDBVectorStore(storePath, dimension);
24203
+ const antflyConfig = {
24204
+ table: deriveTableName(config2.storePath),
24205
+ model: config2.embeddingModel
24206
+ };
24207
+ this.store = new AntflyVectorStore(antflyConfig);
23092
24208
  }
23093
24209
  /**
23094
- * Initialize both embedder and store
23095
- * @param options Optional initialization options
23096
- * @param options.skipEmbedder Skip embedder initialization (useful for read-only operations)
24210
+ * Initialize the storage.
24211
+ *
24212
+ * The skipEmbedder option is accepted for backward compatibility but
24213
+ * has no effect — Antfly handles embeddings internally.
23097
24214
  */
23098
- async initialize(options) {
23099
- if (this.initialized) {
23100
- return;
23101
- }
23102
- const { skipEmbedder = false } = options || {};
23103
- if (skipEmbedder) {
23104
- await this.store.initialize();
23105
- } else {
23106
- await Promise.all([this.embedder.initialize(), this.store.initialize()]);
23107
- }
24215
+ async initialize(_options) {
24216
+ if (this.initialized) return;
24217
+ await this.store.initialize();
23108
24218
  this.initialized = true;
23109
24219
  }
23110
24220
  /**
23111
- * Ensure embedder is initialized (lazy initialization for search operations)
23112
- */
23113
- async ensureEmbedder() {
23114
- if (!this.embedder) {
23115
- throw new Error("Embedder not available");
23116
- }
23117
- await this.embedder.initialize();
23118
- }
23119
- /**
23120
- * Add documents to the store (automatically generates embeddings)
24221
+ * Add documents (Antfly generates embeddings automatically via Termite)
23121
24222
  */
23122
24223
  async addDocuments(documents) {
23123
- if (!this.initialized) {
23124
- throw new Error("VectorStorage not initialized. Call initialize() first.");
23125
- }
23126
- if (documents.length === 0) {
23127
- return;
23128
- }
23129
- const texts = documents.map((doc) => doc.text);
23130
- const embeddings = await this.embedder.embedBatch(texts);
23131
- await this.store.add(documents, embeddings);
24224
+ this.assertReady();
24225
+ if (documents.length === 0) return;
24226
+ await this.store.add(documents);
23132
24227
  }
23133
24228
  /**
23134
- * Search for similar documents using natural language query
24229
+ * Search using hybrid search (BM25 + vector + RRF)
23135
24230
  */
23136
24231
  async search(query, options) {
23137
- if (!this.initialized) {
23138
- throw new Error("VectorStorage not initialized. Call initialize() first.");
23139
- }
23140
- await this.ensureEmbedder();
23141
- const queryEmbedding = await this.embedder.embed(query);
23142
- return this.store.search(queryEmbedding, options);
24232
+ this.assertReady();
24233
+ return this.store.searchText(query, options);
23143
24234
  }
23144
24235
  /**
23145
- * Find similar documents to a given document by ID
23146
- * More efficient than search() as it reuses the document's existing embedding
24236
+ * Find documents similar to a given document by ID
23147
24237
  */
23148
24238
  async searchByDocumentId(documentId, options) {
23149
- if (!this.initialized) {
23150
- throw new Error("VectorStorage not initialized. Call initialize() first.");
23151
- }
24239
+ this.assertReady();
23152
24240
  return this.store.searchByDocumentId(documentId, options);
23153
24241
  }
23154
24242
  /**
23155
- * Get all documents without semantic search (fast scan)
23156
- * Use this when you need all documents and don't need relevance ranking
23157
- * This is 10-20x faster than search() as it skips embedding generation
24243
+ * Get all documents without semantic search (full scan)
23158
24244
  */
23159
24245
  async getAll(options) {
23160
- if (!this.initialized) {
23161
- throw new Error("VectorStorage not initialized. Call initialize() first.");
23162
- }
24246
+ this.assertReady();
23163
24247
  return this.store.getAll(options);
23164
24248
  }
23165
24249
  /**
23166
24250
  * Get a document by ID
23167
24251
  */
23168
24252
  async getDocument(id) {
23169
- if (!this.initialized) {
23170
- throw new Error("VectorStorage not initialized. Call initialize() first.");
23171
- }
24253
+ this.assertReady();
23172
24254
  return this.store.get(id);
23173
24255
  }
23174
24256
  /**
23175
24257
  * Delete documents by ID
23176
24258
  */
23177
24259
  async deleteDocuments(ids) {
23178
- if (!this.initialized) {
23179
- throw new Error("VectorStorage not initialized. Call initialize() first.");
23180
- }
24260
+ this.assertReady();
23181
24261
  await this.store.delete(ids);
23182
24262
  }
23183
24263
  /**
23184
- * Clear all documents from the store (destructive operation)
23185
- * Used for force re-indexing
24264
+ * Clear all documents (destructive used for force re-indexing)
23186
24265
  */
23187
24266
  async clear() {
23188
- if (!this.initialized) {
23189
- throw new Error("VectorStorage not initialized. Call initialize() first.");
23190
- }
24267
+ this.assertReady();
23191
24268
  await this.store.clear();
23192
24269
  }
23193
24270
  /**
23194
24271
  * Get statistics about the vector store
23195
24272
  */
23196
24273
  async getStats() {
23197
- if (!this.initialized) {
23198
- throw new Error("VectorStorage not initialized. Call initialize() first.");
23199
- }
24274
+ this.assertReady();
24275
+ const modelInfo = this.store.getModelInfo();
23200
24276
  const totalDocuments = await this.store.count();
23201
- let storageSize = 0;
23202
- try {
23203
- const storePath = this.store.path;
23204
- const stats = await fs6.stat(storePath);
23205
- storageSize = stats.size;
23206
- } catch {
23207
- storageSize = 0;
23208
- }
24277
+ const storageSize = await this.store.getStorageSize();
23209
24278
  return {
23210
24279
  totalDocuments,
23211
24280
  storageSize,
23212
- dimension: this.embedder.dimension,
23213
- modelName: this.embedder.modelName
24281
+ dimension: modelInfo.dimension,
24282
+ modelName: modelInfo.modelName
23214
24283
  };
23215
24284
  }
23216
24285
  /**
23217
- * Optimize the vector store (compact fragments, update indices)
23218
- * Call this after bulk indexing operations for better performance
24286
+ * Optimize the store (no-op for Antfly — manages compaction internally)
23219
24287
  */
23220
24288
  async optimize() {
23221
- if (!this.initialized) {
23222
- throw new Error("VectorStorage not initialized. Call initialize() first.");
23223
- }
24289
+ this.assertReady();
23224
24290
  await this.store.optimize();
23225
24291
  }
23226
24292
  /**
@@ -23230,6 +24296,11 @@ var init_vector = __esm({
23230
24296
  await this.store.close();
23231
24297
  this.initialized = false;
23232
24298
  }
24299
+ assertReady() {
24300
+ if (!this.initialized) {
24301
+ throw new Error("VectorStorage not initialized. Call initialize() first.");
24302
+ }
24303
+ }
23233
24304
  };
23234
24305
  }
23235
24306
  });
@@ -37297,12 +38368,12 @@ var indexer_exports = {};
37297
38368
  __export(indexer_exports, {
37298
38369
  RepositoryIndexer: () => RepositoryIndexer
37299
38370
  });
37300
- var crypto, fs7, path9, INDEXER_VERSION, DEFAULT_STATE_PATH, RepositoryIndexer;
38371
+ var crypto, fs6, path9, INDEXER_VERSION, DEFAULT_STATE_PATH, RepositoryIndexer;
37301
38372
  var init_indexer2 = __esm({
37302
38373
  "../core/src/indexer/index.ts"() {
37303
38374
  "use strict";
37304
38375
  crypto = __toESM(require("crypto"));
37305
- fs7 = __toESM(require("fs/promises"));
38376
+ fs6 = __toESM(require("fs/promises"));
37306
38377
  path9 = __toESM(require("path"));
37307
38378
  init_collector();
37308
38379
  init_scanner();
@@ -37921,7 +38992,7 @@ var init_indexer2 = __esm({
37921
38992
  */
37922
38993
  async loadState() {
37923
38994
  try {
37924
- const stateContent = await fs7.readFile(this.config.statePath, "utf-8");
38995
+ const stateContent = await fs6.readFile(this.config.statePath, "utf-8");
37925
38996
  const data = JSON.parse(stateContent);
37926
38997
  const validation = validateIndexerState(data);
37927
38998
  if (!validation.success) {
@@ -37950,8 +39021,8 @@ var init_indexer2 = __esm({
37950
39021
  if (!validation.success) {
37951
39022
  console.warn(`Indexer state validation warning: ${validation.error}`);
37952
39023
  }
37953
- await fs7.mkdir(path9.dirname(this.config.statePath), { recursive: true });
37954
- await fs7.writeFile(this.config.statePath, JSON.stringify(this.state, null, 2), "utf-8");
39024
+ await fs6.mkdir(path9.dirname(this.config.statePath), { recursive: true });
39025
+ await fs6.writeFile(this.config.statePath, JSON.stringify(this.state, null, 2), "utf-8");
37955
39026
  }
37956
39027
  /**
37957
39028
  * Update state with newly indexed documents
@@ -37981,11 +39052,11 @@ var init_indexer2 = __esm({
37981
39052
  }
37982
39053
  for (const [filePath, docs] of fileMap) {
37983
39054
  const fullPath = path9.join(this.config.repositoryPath, filePath);
37984
- let stat4;
39055
+ let stat3;
37985
39056
  let hash2 = "";
37986
39057
  try {
37987
- stat4 = await fs7.stat(fullPath);
37988
- const content3 = await fs7.readFile(fullPath, "utf-8");
39058
+ stat3 = await fs6.stat(fullPath);
39059
+ const content3 = await fs6.readFile(fullPath, "utf-8");
37989
39060
  hash2 = crypto.createHash("sha256").update(content3).digest("hex");
37990
39061
  } catch {
37991
39062
  continue;
@@ -37993,10 +39064,10 @@ var init_indexer2 = __esm({
37993
39064
  const metadata = {
37994
39065
  path: filePath,
37995
39066
  hash: hash2,
37996
- lastModified: stat4.mtime,
39067
+ lastModified: stat3.mtime,
37997
39068
  lastIndexed: /* @__PURE__ */ new Date(),
37998
39069
  documentIds: docs.map((d) => d.id),
37999
- size: stat4.size,
39070
+ size: stat3.size,
38000
39071
  language: docs[0]?.language || "unknown"
38001
39072
  };
38002
39073
  this.state.files[filePath] = metadata;
@@ -38031,11 +39102,11 @@ var init_indexer2 = __esm({
38031
39102
  for (const [filePath, metadata] of Object.entries(this.state.files)) {
38032
39103
  const fullPath = path9.join(this.config.repositoryPath, filePath);
38033
39104
  try {
38034
- const stat4 = await fs7.stat(fullPath);
38035
- if (since && stat4.mtime <= since) {
39105
+ const stat3 = await fs6.stat(fullPath);
39106
+ if (since && stat3.mtime <= since) {
38036
39107
  continue;
38037
39108
  }
38038
- const content3 = await fs7.readFile(fullPath, "utf-8");
39109
+ const content3 = await fs6.readFile(fullPath, "utf-8");
38039
39110
  const currentHash = crypto.createHash("sha256").update(content3).digest("hex");
38040
39111
  if (currentHash !== metadata.hash) {
38041
39112
  changed.push(filePath);
@@ -38711,7 +39782,7 @@ __export(store_exports, {
38711
39782
  MetricsStore: () => MetricsStore
38712
39783
  });
38713
39784
  var crypto2, import_better_sqlite3, MetricsStore;
38714
- var init_store2 = __esm({
39785
+ var init_store = __esm({
38715
39786
  "../core/src/metrics/store.ts"() {
38716
39787
  "use strict";
38717
39788
  crypto2 = __toESM(require("crypto"));
@@ -39036,7 +40107,7 @@ var init_metrics = __esm({
39036
40107
  init_analytics();
39037
40108
  init_collector();
39038
40109
  init_schema();
39039
- init_store2();
40110
+ init_store();
39040
40111
  init_types5();
39041
40112
  }
39042
40113
  });
@@ -41684,11 +42755,11 @@ var init_utils3 = __esm({
41684
42755
  });
41685
42756
 
41686
42757
  // ../subagents/src/github/indexer.ts
41687
- var fs8, path11, INDEXER_VERSION2, DEFAULT_STATE_PATH2, DEFAULT_STALE_THRESHOLD, GitHubIndexer;
42758
+ var fs7, path11, INDEXER_VERSION2, DEFAULT_STATE_PATH2, DEFAULT_STALE_THRESHOLD, GitHubIndexer;
41688
42759
  var init_indexer4 = __esm({
41689
42760
  "../subagents/src/github/indexer.ts"() {
41690
42761
  "use strict";
41691
- fs8 = __toESM(require("fs/promises"));
42762
+ fs7 = __toESM(require("fs/promises"));
41692
42763
  path11 = __toESM(require("path"));
41693
42764
  init_src3();
41694
42765
  init_utils3();
@@ -41996,7 +43067,7 @@ ${doc.body}`,
41996
43067
  */
41997
43068
  async loadState() {
41998
43069
  try {
41999
- const stateContent = await fs8.readFile(this.statePath, "utf-8");
43070
+ const stateContent = await fs7.readFile(this.statePath, "utf-8");
42000
43071
  this.state = JSON.parse(stateContent);
42001
43072
  if (this.state?.version !== INDEXER_VERSION2) {
42002
43073
  console.warn(`State version mismatch: ${this.state?.version} !== ${INDEXER_VERSION2}`);
@@ -42013,8 +43084,8 @@ ${doc.body}`,
42013
43084
  if (!this.state) {
42014
43085
  return;
42015
43086
  }
42016
- await fs8.mkdir(path11.dirname(this.statePath), { recursive: true });
42017
- await fs8.writeFile(this.statePath, JSON.stringify(this.state, null, 2), "utf-8");
43087
+ await fs7.mkdir(path11.dirname(this.statePath), { recursive: true });
43088
+ await fs7.writeFile(this.statePath, JSON.stringify(this.state, null, 2), "utf-8");
42018
43089
  }
42019
43090
  };
42020
43091
  }
@@ -43395,7 +44466,7 @@ async function getStoragePath(repositoryPath) {
43395
44466
  return path12.join(baseStorageDir, pathHash);
43396
44467
  }
43397
44468
  async function ensureStorageDirectory(storagePath) {
43398
- await fs9.mkdir(storagePath, { recursive: true });
44469
+ await fs8.mkdir(storagePath, { recursive: true });
43399
44470
  }
43400
44471
  function getStorageFilePaths(storagePath) {
43401
44472
  return {
@@ -43406,13 +44477,13 @@ function getStorageFilePaths(storagePath) {
43406
44477
  metrics: path12.join(storagePath, "metrics.db")
43407
44478
  };
43408
44479
  }
43409
- var import_node_child_process6, crypto3, fs9, os2, path12;
44480
+ var import_node_child_process6, crypto3, fs8, os2, path12;
43410
44481
  var init_path = __esm({
43411
44482
  "../core/src/storage/path.ts"() {
43412
44483
  "use strict";
43413
44484
  import_node_child_process6 = require("child_process");
43414
44485
  crypto3 = __toESM(require("crypto"));
43415
- fs9 = __toESM(require("fs/promises"));
44486
+ fs8 = __toESM(require("fs/promises"));
43416
44487
  os2 = __toESM(require("os"));
43417
44488
  path12 = __toESM(require("path"));
43418
44489
  }
@@ -43687,7 +44758,7 @@ var init_health_service = __esm({
43687
44758
  });
43688
44759
  }
43689
44760
  defaultMetricsStoreFactory(path16, logger) {
43690
- const { MetricsStore: Store } = (init_store2(), __toCommonJS(store_exports));
44761
+ const { MetricsStore: Store } = (init_store(), __toCommonJS(store_exports));
43691
44762
  return new Store(path16, logger);
43692
44763
  }
43693
44764
  /**
@@ -43811,7 +44882,7 @@ var init_metrics_service = __esm({
43811
44882
  * Default factory that creates a real MetricsStore
43812
44883
  */
43813
44884
  defaultStoreFactory(path16, logger) {
43814
- const { MetricsStore: Store } = (init_store2(), __toCommonJS(store_exports));
44885
+ const { MetricsStore: Store } = (init_store(), __toCommonJS(store_exports));
43815
44886
  return new Store(path16, logger);
43816
44887
  }
43817
44888
  /**
@@ -43939,28 +45010,28 @@ async function findTestFile(sourcePath, repositoryPath) {
43939
45010
  for (const testPath of patterns) {
43940
45011
  const fullPath = path13.join(repositoryPath, testPath);
43941
45012
  try {
43942
- await fs10.access(fullPath);
45013
+ await fs9.access(fullPath);
43943
45014
  return testPath;
43944
45015
  } catch {
43945
45016
  }
43946
45017
  }
43947
45018
  return null;
43948
45019
  }
43949
- var fs10, path13;
45020
+ var fs9, path13;
43950
45021
  var init_test_utils = __esm({
43951
45022
  "../core/src/utils/test-utils.ts"() {
43952
45023
  "use strict";
43953
- fs10 = __toESM(require("fs/promises"));
45024
+ fs9 = __toESM(require("fs/promises"));
43954
45025
  path13 = __toESM(require("path"));
43955
45026
  }
43956
45027
  });
43957
45028
 
43958
45029
  // ../core/src/services/pattern-analysis-service.ts
43959
- var fs11, path14, PatternAnalysisService;
45030
+ var fs10, path14, PatternAnalysisService;
43960
45031
  var init_pattern_analysis_service = __esm({
43961
45032
  "../core/src/services/pattern-analysis-service.ts"() {
43962
45033
  "use strict";
43963
- fs11 = __toESM(require("fs/promises"));
45034
+ fs10 = __toESM(require("fs/promises"));
43964
45035
  path14 = __toESM(require("path"));
43965
45036
  init_scanner();
43966
45037
  init_test_utils();
@@ -44047,12 +45118,12 @@ var init_pattern_analysis_service = __esm({
44047
45118
  */
44048
45119
  async analyzeFileWithDocs(filePath, documents) {
44049
45120
  const fullPath = path14.join(this.config.repositoryPath, filePath);
44050
- const [stat4, content3] = await Promise.all([fs11.stat(fullPath), fs11.readFile(fullPath, "utf-8")]);
45121
+ const [stat3, content3] = await Promise.all([fs10.stat(fullPath), fs10.readFile(fullPath, "utf-8")]);
44051
45122
  const lines = content3.split("\n").length;
44052
45123
  return {
44053
45124
  fileSize: {
44054
45125
  lines,
44055
- bytes: stat4.size
45126
+ bytes: stat3.size
44056
45127
  },
44057
45128
  testing: await this.analyzeTesting(filePath),
44058
45129
  importStyle: await this.analyzeImportsFromFile(filePath, documents),
@@ -44085,7 +45156,7 @@ var init_pattern_analysis_service = __esm({
44085
45156
  */
44086
45157
  async analyzeImportsFromFile(filePath, _documents) {
44087
45158
  const fullPath = path14.join(this.config.repositoryPath, filePath);
44088
- const content3 = await fs11.readFile(fullPath, "utf-8");
45159
+ const content3 = await fs10.readFile(fullPath, "utf-8");
44089
45160
  return this.analyzeImportsFromContent(content3);
44090
45161
  }
44091
45162
  /**
@@ -44643,7 +45714,7 @@ function getLastCommit(repositoryPath) {
44643
45714
  async function loadMetadata(storagePath) {
44644
45715
  const metadataPath = path15.join(storagePath, "metadata.json");
44645
45716
  try {
44646
- const content3 = await fs12.readFile(metadataPath, "utf-8");
45717
+ const content3 = await fs11.readFile(metadataPath, "utf-8");
44647
45718
  const data = JSON.parse(content3);
44648
45719
  const validated = validateRepositoryMetadata(data);
44649
45720
  return validated;
@@ -44670,8 +45741,8 @@ async function saveMetadata(storagePath, repositoryPath, updates) {
44670
45741
  ...updates?.repository
44671
45742
  }
44672
45743
  };
44673
- await fs12.mkdir(storagePath, { recursive: true });
44674
- await fs12.writeFile(metadataPath, JSON.stringify(metadata, null, 2), "utf-8");
45744
+ await fs11.mkdir(storagePath, { recursive: true });
45745
+ await fs11.writeFile(metadataPath, JSON.stringify(metadata, null, 2), "utf-8");
44675
45746
  return metadata;
44676
45747
  }
44677
45748
  async function updateIndexedStats(storagePath, stats) {
@@ -44683,12 +45754,12 @@ async function updateIndexedStats(storagePath, stats) {
44683
45754
  }
44684
45755
  });
44685
45756
  }
44686
- var import_node_child_process7, fs12, path15, METADATA_VERSION;
45757
+ var import_node_child_process7, fs11, path15, METADATA_VERSION;
44687
45758
  var init_metadata2 = __esm({
44688
45759
  "../core/src/storage/metadata.ts"() {
44689
45760
  "use strict";
44690
45761
  import_node_child_process7 = require("child_process");
44691
- fs12 = __toESM(require("fs/promises"));
45762
+ fs11 = __toESM(require("fs/promises"));
44692
45763
  path15 = __toESM(require("path"));
44693
45764
  init_path();
44694
45765
  init_validation2();
@@ -44832,6 +45903,7 @@ var init_utils5 = __esm({
44832
45903
  // ../core/src/index.ts
44833
45904
  var src_exports3 = {};
44834
45905
  __export(src_exports3, {
45906
+ AntflyVectorStore: () => AntflyVectorStore,
44835
45907
  ApiServer: () => ApiServer,
44836
45908
  AsyncEventBus: () => AsyncEventBus,
44837
45909
  CodeMetadataSchema: () => CodeMetadataSchema,
@@ -44846,7 +45918,6 @@ __export(src_exports3, {
44846
45918
  GoScanner: () => GoScanner,
44847
45919
  HealthService: () => HealthService,
44848
45920
  HotspotSchema: () => HotspotSchema,
44849
- LanceDBVectorStore: () => LanceDBVectorStore,
44850
45921
  LocalGitExtractor: () => LocalGitExtractor,
44851
45922
  METRICS_SCHEMA_V1: () => METRICS_SCHEMA_V1,
44852
45923
  MarkdownScanner: () => MarkdownScanner,
@@ -44865,7 +45936,6 @@ __export(src_exports3, {
44865
45936
  SnapshotQuerySchema: () => SnapshotQuerySchema,
44866
45937
  StatsAggregator: () => StatsAggregator,
44867
45938
  StatsService: () => StatsService,
44868
- TransformersEmbedder: () => TransformersEmbedder,
44869
45939
  TypeScriptScanner: () => TypeScriptScanner,
44870
45940
  VectorStorage: () => VectorStorage,
44871
45941
  aggregateChangeFrequency: () => aggregateChangeFrequency,
@@ -47706,7 +48776,7 @@ var require_config = __commonJS({
47706
48776
  exports2.saveConfig = saveConfig;
47707
48777
  exports2.getDefaultConfig = getDefaultConfig;
47708
48778
  exports2.mergeConfigWithDefaults = mergeConfigWithDefaults;
47709
- var fs14 = __importStar(require("fs/promises"));
48779
+ var fs13 = __importStar(require("fs/promises"));
47710
48780
  var path16 = __importStar(require("path"));
47711
48781
  var logger_js_1 = require_logger();
47712
48782
  var CONFIG_FILE_NAME = ".dev-agent/config.json";
@@ -47770,7 +48840,7 @@ var require_config = __commonJS({
47770
48840
  while (currentDir !== root) {
47771
48841
  const configPath = path16.join(currentDir, CONFIG_FILE_NAME);
47772
48842
  try {
47773
- await fs14.access(configPath);
48843
+ await fs13.access(configPath);
47774
48844
  return configPath;
47775
48845
  } catch {
47776
48846
  currentDir = path16.dirname(currentDir);
@@ -47784,7 +48854,7 @@ var require_config = __commonJS({
47784
48854
  if (!finalPath) {
47785
48855
  return null;
47786
48856
  }
47787
- const content3 = await fs14.readFile(finalPath, "utf-8");
48857
+ const content3 = await fs13.readFile(finalPath, "utf-8");
47788
48858
  const parsed = JSON.parse(content3);
47789
48859
  validateConfig(parsed);
47790
48860
  const resolved = resolveEnvVars(parsed);
@@ -47802,8 +48872,8 @@ var require_config = __commonJS({
47802
48872
  const configDir = path16.join(targetDir, ".dev-agent");
47803
48873
  const configPath = path16.join(configDir, "config.json");
47804
48874
  try {
47805
- await fs14.mkdir(configDir, { recursive: true });
47806
- await fs14.writeFile(configPath, JSON.stringify(config2, null, 2), "utf-8");
48875
+ await fs13.mkdir(configDir, { recursive: true });
48876
+ await fs13.writeFile(configPath, JSON.stringify(config2, null, 2), "utf-8");
47807
48877
  } catch (error46) {
47808
48878
  throw new Error(`Failed to save config: ${error46 instanceof Error ? error46.message : String(error46)}`);
47809
48879
  }
@@ -47933,7 +49003,7 @@ var require_file = __commonJS({
47933
49003
  exports2.prepareFileForSearch = prepareFileForSearch;
47934
49004
  exports2.getDirectorySize = getDirectorySize;
47935
49005
  exports2.formatBytes = formatBytes;
47936
- var fs14 = __importStar(require("fs/promises"));
49006
+ var fs13 = __importStar(require("fs/promises"));
47937
49007
  var path16 = __importStar(require("path"));
47938
49008
  function resolveFilePath(repositoryPath, filePath) {
47939
49009
  return path16.resolve(repositoryPath, filePath);
@@ -47943,11 +49013,11 @@ var require_file = __commonJS({
47943
49013
  }
47944
49014
  async function readFileContent(filePath) {
47945
49015
  try {
47946
- await fs14.access(filePath);
49016
+ await fs13.access(filePath);
47947
49017
  } catch {
47948
49018
  throw new Error(`File not found: ${filePath}`);
47949
49019
  }
47950
- const content3 = await fs14.readFile(filePath, "utf-8");
49020
+ const content3 = await fs13.readFile(filePath, "utf-8");
47951
49021
  if (content3.trim().length === 0) {
47952
49022
  throw new Error(`File is empty: ${filePath}`);
47953
49023
  }
@@ -47965,19 +49035,19 @@ var require_file = __commonJS({
47965
49035
  }
47966
49036
  async function getDirectorySize(dirPath) {
47967
49037
  try {
47968
- const stats = await fs14.stat(dirPath);
49038
+ const stats = await fs13.stat(dirPath);
47969
49039
  if (!stats.isDirectory()) {
47970
49040
  return stats.size;
47971
49041
  }
47972
- const entries = await fs14.readdir(dirPath, { withFileTypes: true });
49042
+ const entries = await fs13.readdir(dirPath, { withFileTypes: true });
47973
49043
  let size = 0;
47974
49044
  for (const entry of entries) {
47975
49045
  const fullPath = path16.join(dirPath, entry.name);
47976
49046
  if (entry.isDirectory()) {
47977
49047
  size += await getDirectorySize(fullPath);
47978
49048
  } else {
47979
- const stat4 = await fs14.stat(fullPath);
47980
- size += stat4.size;
49049
+ const stat3 = await fs13.stat(fullPath);
49050
+ size += stat3.size;
47981
49051
  }
47982
49052
  }
47983
49053
  return size;
@@ -50951,7 +52021,7 @@ var require_clean = __commonJS({
50951
52021
  };
50952
52022
  Object.defineProperty(exports2, "__esModule", { value: true });
50953
52023
  exports2.cleanCommand = void 0;
50954
- var fs14 = __importStar(require("fs/promises"));
52024
+ var fs13 = __importStar(require("fs/promises"));
50955
52025
  var path16 = __importStar(require("path"));
50956
52026
  var dev_agent_core_1 = (init_src3(), __toCommonJS(src_exports3));
50957
52027
  var commander_12 = require_commander();
@@ -50980,8 +52050,8 @@ var require_clean = __commonJS({
50980
52050
  { name: "Metadata", path: filePaths.metadata }
50981
52051
  ].map(async (file2) => {
50982
52052
  try {
50983
- const stat4 = await fs14.stat(file2.path);
50984
- const size = stat4.isDirectory() ? await (0, file_js_1.getDirectorySize)(file2.path) : stat4.size;
52053
+ const stat3 = await fs13.stat(file2.path);
52054
+ const size = stat3.isDirectory() ? await (0, file_js_1.getDirectorySize)(file2.path) : stat3.size;
50985
52055
  return { ...file2, size };
50986
52056
  } catch {
50987
52057
  return { ...file2, size: null };
@@ -50998,7 +52068,7 @@ var require_clean = __commonJS({
50998
52068
  }
50999
52069
  const spinner = (0, ora_1.default)("Cleaning indexed data...").start();
51000
52070
  try {
51001
- await fs14.rm(storagePath, { recursive: true, force: true });
52071
+ await fs13.rm(storagePath, { recursive: true, force: true });
51002
52072
  spinner.succeed("Cleaned successfully");
51003
52073
  (0, output_js_1.printCleanSuccess)({ totalSize });
51004
52074
  } catch (error46) {
@@ -51173,7 +52243,7 @@ var require_stats = __commonJS({
51173
52243
  };
51174
52244
  Object.defineProperty(exports2, "__esModule", { value: true });
51175
52245
  exports2.statsCommand = void 0;
51176
- var fs14 = __importStar(require("fs/promises"));
52246
+ var fs13 = __importStar(require("fs/promises"));
51177
52247
  var path16 = __importStar(require("path"));
51178
52248
  var dev_agent_core_1 = (init_src3(), __toCommonJS(src_exports3));
51179
52249
  var chalk_12 = __importDefault2((init_source(), __toCommonJS(source_exports)));
@@ -51194,7 +52264,7 @@ var require_stats = __commonJS({
51194
52264
  const filePaths = (0, dev_agent_core_1.getStorageFilePaths)(storagePath);
51195
52265
  let stats = null;
51196
52266
  try {
51197
- const stateContent = await fs14.readFile(filePaths.indexerState, "utf-8");
52267
+ const stateContent = await fs13.readFile(filePaths.indexerState, "utf-8");
51198
52268
  const state = JSON.parse(stateContent);
51199
52269
  stats = {
51200
52270
  ...state.stats,
@@ -51211,7 +52281,7 @@ var require_stats = __commonJS({
51211
52281
  }
51212
52282
  let metadata = null;
51213
52283
  try {
51214
- const metadataContent = await fs14.readFile(path16.join(storagePath, "metadata.json"), "utf-8");
52284
+ const metadataContent = await fs13.readFile(path16.join(storagePath, "metadata.json"), "utf-8");
51215
52285
  const meta3 = JSON.parse(metadataContent);
51216
52286
  let storageSize = meta3.indexed?.size || 0;
51217
52287
  if (storageSize === 0) {
@@ -51227,7 +52297,7 @@ var require_stats = __commonJS({
51227
52297
  }
51228
52298
  let githubStats = null;
51229
52299
  try {
51230
- const stateContent = await fs14.readFile(filePaths.githubState, "utf-8");
52300
+ const stateContent = await fs13.readFile(filePaths.githubState, "utf-8");
51231
52301
  const state = JSON.parse(stateContent);
51232
52302
  githubStats = {
51233
52303
  repository: state.repository,
@@ -69555,7 +70625,7 @@ var require_health_adapter = __commonJS({
69555
70625
  })();
69556
70626
  Object.defineProperty(exports2, "__esModule", { value: true });
69557
70627
  exports2.HealthAdapter = void 0;
69558
- var fs14 = __importStar(require("fs/promises"));
70628
+ var fs13 = __importStar(require("fs/promises"));
69559
70629
  var index_js_12 = require_schemas3();
69560
70630
  var tool_adapter_1 = require_tool_adapter();
69561
70631
  var validation_js_1 = require_validation();
@@ -69646,14 +70716,14 @@ ${content3}`
69646
70716
  }
69647
70717
  async checkVectorStorage(verbose) {
69648
70718
  try {
69649
- const stats = await fs14.stat(this.config.vectorStorePath);
70719
+ const stats = await fs13.stat(this.config.vectorStorePath);
69650
70720
  if (!stats.isDirectory()) {
69651
70721
  return {
69652
70722
  status: "fail",
69653
70723
  message: "Vector storage path is not a directory"
69654
70724
  };
69655
70725
  }
69656
- const files = await fs14.readdir(this.config.vectorStorePath);
70726
+ const files = await fs13.readdir(this.config.vectorStorePath);
69657
70727
  const hasData = files.length > 0;
69658
70728
  if (!hasData) {
69659
70729
  return {
@@ -69677,7 +70747,7 @@ ${content3}`
69677
70747
  }
69678
70748
  async checkRepository(verbose) {
69679
70749
  try {
69680
- const stats = await fs14.stat(this.config.repositoryPath);
70750
+ const stats = await fs13.stat(this.config.repositoryPath);
69681
70751
  if (!stats.isDirectory()) {
69682
70752
  return {
69683
70753
  status: "fail",
@@ -69685,7 +70755,7 @@ ${content3}`
69685
70755
  };
69686
70756
  }
69687
70757
  try {
69688
- await fs14.stat(`${this.config.repositoryPath}/.git`);
70758
+ await fs13.stat(`${this.config.repositoryPath}/.git`);
69689
70759
  return {
69690
70760
  status: "pass",
69691
70761
  message: "Repository accessible and is a Git repository",
@@ -69714,7 +70784,7 @@ ${content3}`
69714
70784
  };
69715
70785
  }
69716
70786
  try {
69717
- const content3 = await fs14.readFile(this.config.githubStatePath, "utf-8");
70787
+ const content3 = await fs13.readFile(this.config.githubStatePath, "utf-8");
69718
70788
  const state = JSON.parse(content3);
69719
70789
  const lastIndexed = state.lastIndexed ? new Date(state.lastIndexed) : null;
69720
70790
  const itemCount = state.items?.length ?? 0;
@@ -71394,7 +72464,7 @@ var require_related_files = __commonJS({
71394
72464
  exports2.findTestFile = findTestFile2;
71395
72465
  exports2.findRelatedTestFiles = findRelatedTestFiles;
71396
72466
  exports2.formatRelatedFiles = formatRelatedFiles;
71397
- var fs14 = __importStar(require("fs/promises"));
72467
+ var fs13 = __importStar(require("fs/promises"));
71398
72468
  var path16 = __importStar(require("path"));
71399
72469
  exports2.DEFAULT_TEST_PATTERNS = [
71400
72470
  // Same directory: foo.ts -> foo.test.ts, foo.spec.ts
@@ -71403,7 +72473,7 @@ var require_related_files = __commonJS({
71403
72473
  ];
71404
72474
  async function fileExists(filePath) {
71405
72475
  try {
71406
- await fs14.access(filePath);
72476
+ await fs13.access(filePath);
71407
72477
  return true;
71408
72478
  } catch {
71409
72479
  return false;
@@ -71668,7 +72738,7 @@ var require_status_adapter = __commonJS({
71668
72738
  })();
71669
72739
  Object.defineProperty(exports2, "__esModule", { value: true });
71670
72740
  exports2.StatusAdapter = void 0;
71671
- var fs14 = __importStar(require("fs"));
72741
+ var fs13 = __importStar(require("fs"));
71672
72742
  var path16 = __importStar(require("path"));
71673
72743
  var utils_1 = require_utils6();
71674
72744
  var index_js_12 = require_schemas3();
@@ -71707,7 +72777,7 @@ var require_status_adapter = __commonJS({
71707
72777
  if (this.githubService) {
71708
72778
  this.githubStatePath = path16.join(this.repositoryPath, ".dev-agent/github-state.json");
71709
72779
  try {
71710
- const stats = await fs14.promises.stat(this.githubStatePath);
72780
+ const stats = await fs13.promises.stat(this.githubStatePath);
71711
72781
  this.lastStateFileModTime = stats.mtimeMs;
71712
72782
  } catch {
71713
72783
  }
@@ -71722,7 +72792,7 @@ var require_status_adapter = __commonJS({
71722
72792
  return false;
71723
72793
  }
71724
72794
  try {
71725
- const stats = await fs14.promises.stat(this.githubStatePath);
72795
+ const stats = await fs13.promises.stat(this.githubStatePath);
71726
72796
  const currentModTime = stats.mtimeMs;
71727
72797
  return currentModTime > this.lastStateFileModTime;
71728
72798
  } catch {
@@ -71738,7 +72808,7 @@ var require_status_adapter = __commonJS({
71738
72808
  return;
71739
72809
  }
71740
72810
  try {
71741
- const stats = await fs14.promises.stat(this.githubStatePath);
72811
+ const stats = await fs13.promises.stat(this.githubStatePath);
71742
72812
  this.lastStateFileModTime = stats.mtimeMs;
71743
72813
  } catch {
71744
72814
  }
@@ -72036,7 +73106,7 @@ var require_status_adapter = __commonJS({
72036
73106
  async checkHealth() {
72037
73107
  const checks = [];
72038
73108
  try {
72039
- await fs14.promises.access(this.repositoryPath, fs14.constants.R_OK);
73109
+ await fs13.promises.access(this.repositoryPath, fs13.constants.R_OK);
72040
73110
  checks.push({
72041
73111
  name: "Repository Access",
72042
73112
  status: "ok",
@@ -72114,14 +73184,14 @@ var require_status_adapter = __commonJS({
72114
73184
  checkHealthSync() {
72115
73185
  const checks = [];
72116
73186
  try {
72117
- fs14.accessSync(this.repositoryPath, fs14.constants.R_OK);
73187
+ fs13.accessSync(this.repositoryPath, fs13.constants.R_OK);
72118
73188
  checks.push({ name: "Repository", status: "ok", message: "Accessible" });
72119
73189
  } catch {
72120
73190
  checks.push({ name: "Repository", status: "error", message: "Not accessible" });
72121
73191
  }
72122
73192
  try {
72123
73193
  const vectorDir = path16.dirname(this.vectorStorePath);
72124
- fs14.accessSync(vectorDir, fs14.constants.R_OK);
73194
+ fs13.accessSync(vectorDir, fs13.constants.R_OK);
72125
73195
  checks.push({ name: "Vector Storage", status: "ok", message: "Available" });
72126
73196
  } catch {
72127
73197
  checks.push({ name: "Vector Storage", status: "warning", message: "Not initialized" });
@@ -72135,11 +73205,11 @@ var require_status_adapter = __commonJS({
72135
73205
  try {
72136
73206
  const getDirectorySize = async (dirPath) => {
72137
73207
  try {
72138
- const stats = await fs14.promises.stat(dirPath);
73208
+ const stats = await fs13.promises.stat(dirPath);
72139
73209
  if (!stats.isDirectory()) {
72140
73210
  return stats.size;
72141
73211
  }
72142
- const files = await fs14.promises.readdir(dirPath);
73212
+ const files = await fs13.promises.readdir(dirPath);
72143
73213
  const sizes = await Promise.all(files.map((file2) => getDirectorySize(path16.join(dirPath, file2))));
72144
73214
  return sizes.reduce((acc, size) => acc + size, 0);
72145
73215
  } catch {
@@ -73274,7 +74344,7 @@ var require_cursor_config = __commonJS({
73274
74344
  exports2.addCursorServer = addCursorServer;
73275
74345
  exports2.removeCursorServer = removeCursorServer;
73276
74346
  exports2.listCursorServers = listCursorServers;
73277
- var fs14 = __importStar(require("fs/promises"));
74347
+ var fs13 = __importStar(require("fs/promises"));
73278
74348
  var os4 = __importStar(require("os"));
73279
74349
  var path16 = __importStar(require("path"));
73280
74350
  function getCursorConfigPath() {
@@ -73283,7 +74353,7 @@ var require_cursor_config = __commonJS({
73283
74353
  async function readCursorConfig() {
73284
74354
  const configPath = getCursorConfigPath();
73285
74355
  try {
73286
- const content3 = await fs14.readFile(configPath, "utf-8");
74356
+ const content3 = await fs13.readFile(configPath, "utf-8");
73287
74357
  return JSON.parse(content3);
73288
74358
  } catch (error46) {
73289
74359
  if (error46.code === "ENOENT") {
@@ -73295,8 +74365,8 @@ var require_cursor_config = __commonJS({
73295
74365
  async function writeCursorConfig(config2) {
73296
74366
  const configPath = getCursorConfigPath();
73297
74367
  const configDir = path16.dirname(configPath);
73298
- await fs14.mkdir(configDir, { recursive: true });
73299
- await fs14.writeFile(configPath, JSON.stringify(config2, null, 2), "utf-8");
74368
+ await fs13.mkdir(configDir, { recursive: true });
74369
+ await fs13.writeFile(configPath, JSON.stringify(config2, null, 2), "utf-8");
73300
74370
  }
73301
74371
  function generateServerName(repositoryPath, existingNames) {
73302
74372
  const repoName = path16.basename(repositoryPath);
@@ -73426,7 +74496,7 @@ var require_mcp = __commonJS({
73426
74496
  Object.defineProperty(exports2, "__esModule", { value: true });
73427
74497
  exports2.mcpCommand = void 0;
73428
74498
  var node_child_process_1 = require("child_process");
73429
- var fs14 = __importStar(require("fs/promises"));
74499
+ var fs13 = __importStar(require("fs/promises"));
73430
74500
  var path16 = __importStar(require("path"));
73431
74501
  var dev_agent_core_1 = (init_src3(), __toCommonJS(src_exports3));
73432
74502
  var dev_agent_mcp_1 = require_src();
@@ -73457,7 +74527,7 @@ Available Tools (9):
73457
74527
  try {
73458
74528
  const storagePath = await (0, dev_agent_core_1.getStoragePath)(repositoryPath);
73459
74529
  const { vectors } = (0, dev_agent_core_1.getStorageFilePaths)(storagePath);
73460
- const vectorsExist = await fs14.access(vectors).then(() => true).catch(() => false);
74530
+ const vectorsExist = await fs13.access(vectors).then(() => true).catch(() => false);
73461
74531
  if (!vectorsExist) {
73462
74532
  logger_1.logger.error(`Repository not indexed. Run: ${chalk_12.default.yellow("dev index .")}`);
73463
74533
  process.exit(1);
@@ -73601,7 +74671,7 @@ Available Tools (9):
73601
74671
  try {
73602
74672
  const storagePath = await (0, dev_agent_core_1.getStoragePath)(repositoryPath);
73603
74673
  const { vectors } = (0, dev_agent_core_1.getStorageFilePaths)(storagePath);
73604
- const vectorsExist = await fs14.access(vectors).then(() => true).catch(() => false);
74674
+ const vectorsExist = await fs13.access(vectors).then(() => true).catch(() => false);
73605
74675
  if (!vectorsExist) {
73606
74676
  spinner.fail(`Repository not indexed. Run: ${chalk_12.default.yellow("dev index .")}`);
73607
74677
  process.exit(1);
@@ -74104,6 +75174,286 @@ var require_search = __commonJS({
74104
75174
  }
74105
75175
  });
74106
75176
 
75177
+ // ../cli/dist/utils/antfly.js
75178
+ var require_antfly = __commonJS({
75179
+ "../cli/dist/utils/antfly.js"(exports2) {
75180
+ "use strict";
75181
+ Object.defineProperty(exports2, "__esModule", { value: true });
75182
+ exports2.ensureAntfly = ensureAntfly;
75183
+ exports2.getAntflyUrl = getAntflyUrl;
75184
+ exports2.hasDocker = hasDocker;
75185
+ exports2.hasNativeBinary = hasNativeBinary;
75186
+ exports2.isContainerExists = isContainerExists;
75187
+ exports2.isServerReady = isServerReady;
75188
+ exports2.getNativeVersion = getNativeVersion;
75189
+ exports2.pullModel = pullModel;
75190
+ exports2.hasModel = hasModel;
75191
+ var node_child_process_1 = require("child_process");
75192
+ var logger_js_1 = require_logger();
75193
+ var DEFAULT_ANTFLY_URL = process.env.ANTFLY_URL ?? "http://localhost:18080/api/v1";
75194
+ var CONTAINER_NAME = "dev-agent-antfly";
75195
+ var DOCKER_IMAGE = "ghcr.io/antflydb/antfly:latest";
75196
+ var DOCKER_PORT = 18080;
75197
+ var STARTUP_TIMEOUT_MS = 3e4;
75198
+ var POLL_INTERVAL_MS = 500;
75199
+ async function ensureAntfly(options) {
75200
+ const url2 = getAntflyUrl();
75201
+ if (await isServerReady(url2)) {
75202
+ return url2;
75203
+ }
75204
+ if (hasDocker()) {
75205
+ if (isContainerExists()) {
75206
+ if (!options?.quiet)
75207
+ logger_js_1.logger.info("Starting Antfly container...");
75208
+ (0, node_child_process_1.execSync)(`docker start ${CONTAINER_NAME}`, { stdio: "pipe" });
75209
+ } else {
75210
+ if (!options?.quiet)
75211
+ logger_js_1.logger.info("Starting Antfly via Docker...");
75212
+ (0, node_child_process_1.execSync)(`docker run -d --name ${CONTAINER_NAME} -p ${DOCKER_PORT}:8080 --platform linux/amd64 ${DOCKER_IMAGE} swarm`, { stdio: "pipe" });
75213
+ }
75214
+ await waitForServer(url2);
75215
+ if (!options?.quiet)
75216
+ logger_js_1.logger.info(`Antfly running on ${url2}`);
75217
+ return url2;
75218
+ }
75219
+ if (hasNativeBinary()) {
75220
+ if (!options?.quiet)
75221
+ logger_js_1.logger.info("Starting Antfly server...");
75222
+ const child = (0, node_child_process_1.spawn)("antfly", ["swarm"], {
75223
+ detached: true,
75224
+ stdio: "ignore"
75225
+ });
75226
+ child.unref();
75227
+ await waitForServer(url2);
75228
+ if (!options?.quiet)
75229
+ logger_js_1.logger.info(`Antfly running on ${url2}`);
75230
+ return url2;
75231
+ }
75232
+ throw new Error("Antfly is not installed. Run `dev setup` to install, or:\n Docker: docker pull ghcr.io/antflydb/antfly:latest\n Native: brew install --cask antflydb/antfly/antfly");
75233
+ }
75234
+ function getAntflyUrl() {
75235
+ return process.env.ANTFLY_URL ?? DEFAULT_ANTFLY_URL;
75236
+ }
75237
+ function hasDocker() {
75238
+ try {
75239
+ (0, node_child_process_1.execSync)("docker info", { stdio: "pipe", timeout: 5e3 });
75240
+ return true;
75241
+ } catch {
75242
+ return false;
75243
+ }
75244
+ }
75245
+ function hasNativeBinary() {
75246
+ try {
75247
+ (0, node_child_process_1.execSync)("antfly --version", { stdio: "pipe", timeout: 5e3 });
75248
+ return true;
75249
+ } catch {
75250
+ return false;
75251
+ }
75252
+ }
75253
+ function isContainerExists() {
75254
+ try {
75255
+ const result = (0, node_child_process_1.execSync)(`docker ps -a --filter name=${CONTAINER_NAME} --format "{{.Names}}"`, {
75256
+ encoding: "utf-8",
75257
+ stdio: ["pipe", "pipe", "pipe"]
75258
+ });
75259
+ return result.trim() === CONTAINER_NAME;
75260
+ } catch {
75261
+ return false;
75262
+ }
75263
+ }
75264
+ async function isServerReady(url2) {
75265
+ const baseUrl = (url2 ?? getAntflyUrl()).replace("/api/v1", "");
75266
+ try {
75267
+ const resp = await fetch(`${baseUrl}/api/v1/tables`, { signal: AbortSignal.timeout(3e3) });
75268
+ return resp.ok;
75269
+ } catch {
75270
+ return false;
75271
+ }
75272
+ }
75273
+ async function waitForServer(url2) {
75274
+ const start = Date.now();
75275
+ while (Date.now() - start < STARTUP_TIMEOUT_MS) {
75276
+ if (await isServerReady(url2))
75277
+ return;
75278
+ await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
75279
+ }
75280
+ throw new Error(`Antfly server did not start within ${STARTUP_TIMEOUT_MS / 1e3}s. Check: docker logs ${CONTAINER_NAME}`);
75281
+ }
75282
+ function getNativeVersion() {
75283
+ try {
75284
+ return (0, node_child_process_1.execSync)("antfly --version", {
75285
+ encoding: "utf-8",
75286
+ stdio: ["pipe", "pipe", "pipe"]
75287
+ }).trim();
75288
+ } catch {
75289
+ return null;
75290
+ }
75291
+ }
75292
+ function pullModel(model) {
75293
+ (0, node_child_process_1.execSync)(`antfly termite pull ${model}`, { stdio: "inherit" });
75294
+ }
75295
+ function hasModel(model) {
75296
+ try {
75297
+ const output = (0, node_child_process_1.execSync)("antfly termite list", {
75298
+ encoding: "utf-8",
75299
+ stdio: ["pipe", "pipe", "pipe"]
75300
+ });
75301
+ const shortName = model.split("/").pop() ?? model;
75302
+ return output.includes(shortName);
75303
+ } catch {
75304
+ return false;
75305
+ }
75306
+ }
75307
+ }
75308
+ });
75309
+
75310
+ // ../cli/dist/commands/setup.js
75311
+ var require_setup = __commonJS({
75312
+ "../cli/dist/commands/setup.js"(exports2) {
75313
+ "use strict";
75314
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
75315
+ if (k2 === void 0) k2 = k;
75316
+ var desc = Object.getOwnPropertyDescriptor(m, k);
75317
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
75318
+ desc = { enumerable: true, get: function() {
75319
+ return m[k];
75320
+ } };
75321
+ }
75322
+ Object.defineProperty(o, k2, desc);
75323
+ }) : (function(o, m, k, k2) {
75324
+ if (k2 === void 0) k2 = k;
75325
+ o[k2] = m[k];
75326
+ }));
75327
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
75328
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
75329
+ }) : function(o, v) {
75330
+ o["default"] = v;
75331
+ });
75332
+ var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
75333
+ var ownKeys = function(o) {
75334
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
75335
+ var ar = [];
75336
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
75337
+ return ar;
75338
+ };
75339
+ return ownKeys(o);
75340
+ };
75341
+ return function(mod) {
75342
+ if (mod && mod.__esModule) return mod;
75343
+ var result = {};
75344
+ if (mod != null) {
75345
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
75346
+ }
75347
+ __setModuleDefault(result, mod);
75348
+ return result;
75349
+ };
75350
+ })();
75351
+ var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
75352
+ return mod && mod.__esModule ? mod : { "default": mod };
75353
+ };
75354
+ Object.defineProperty(exports2, "__esModule", { value: true });
75355
+ exports2.setupCommand = void 0;
75356
+ var node_child_process_1 = require("child_process");
75357
+ var readline = __importStar(require("readline"));
75358
+ var commander_12 = require_commander();
75359
+ var ora_1 = __importDefault2((init_ora(), __toCommonJS(ora_exports)));
75360
+ var antfly_js_1 = require_antfly();
75361
+ var logger_js_1 = require_logger();
75362
+ var DEFAULT_MODEL2 = "BAAI/bge-small-en-v1.5";
75363
+ async function confirm(question) {
75364
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
75365
+ return new Promise((resolve4) => {
75366
+ rl.question(`${question} (Y/n) `, (answer) => {
75367
+ rl.close();
75368
+ resolve4(answer.toLowerCase() !== "n");
75369
+ });
75370
+ });
75371
+ }
75372
+ exports2.setupCommand = new commander_12.Command("setup").description("One-time setup: install search backend and embedding model").option("--model <name>", "Termite embedding model", DEFAULT_MODEL2).action(async (options) => {
75373
+ const model = options.model;
75374
+ const spinner = (0, ora_1.default)();
75375
+ try {
75376
+ if ((0, antfly_js_1.hasDocker)()) {
75377
+ logger_js_1.logger.info("Docker found");
75378
+ if (await (0, antfly_js_1.isServerReady)()) {
75379
+ logger_js_1.logger.info("Antfly server already running");
75380
+ logger_js_1.logger.log("\n Nothing to do \u2014 you're all set!\n");
75381
+ logger_js_1.logger.log(" Next steps:");
75382
+ logger_js_1.logger.log(" dev index . Index your repository");
75383
+ logger_js_1.logger.log(" dev mcp install --cursor Connect to Cursor\n");
75384
+ return;
75385
+ }
75386
+ spinner.start("Pulling Antfly image...");
75387
+ try {
75388
+ (0, node_child_process_1.execSync)(`docker pull --platform linux/amd64 ${getDockerImage()}`, { stdio: "pipe" });
75389
+ spinner.succeed("Antfly image ready");
75390
+ } catch {
75391
+ spinner.succeed("Antfly image available");
75392
+ }
75393
+ spinner.start("Starting Antfly server...");
75394
+ await (0, antfly_js_1.ensureAntfly)({ quiet: true });
75395
+ spinner.succeed(`Antfly running on ${(0, antfly_js_1.getAntflyUrl)()}`);
75396
+ } else if ((0, antfly_js_1.hasNativeBinary)()) {
75397
+ const version2 = (0, antfly_js_1.getNativeVersion)();
75398
+ logger_js_1.logger.info(`Antfly ${version2} found (native)`);
75399
+ logger_js_1.logger.info("Docker not found \u2014 using native binary");
75400
+ if (await (0, antfly_js_1.isServerReady)()) {
75401
+ logger_js_1.logger.info("Antfly server already running");
75402
+ } else {
75403
+ if (!(0, antfly_js_1.hasModel)(model)) {
75404
+ spinner.start(`Pulling embedding model: ${model}...`);
75405
+ (0, antfly_js_1.pullModel)(model);
75406
+ spinner.succeed(`Embedding model ready: ${model}`);
75407
+ } else {
75408
+ logger_js_1.logger.info(`Embedding model ready: ${model}`);
75409
+ }
75410
+ spinner.start("Starting Antfly server...");
75411
+ await (0, antfly_js_1.ensureAntfly)({ quiet: true });
75412
+ spinner.succeed(`Antfly running on ${(0, antfly_js_1.getAntflyUrl)()}`);
75413
+ }
75414
+ } else {
75415
+ const platform2 = process.platform;
75416
+ const installCmd = platform2 === "darwin" ? "brew install --cask antflydb/antfly/antfly" : "curl -fsSL https://releases.antfly.io/antfly/latest/install.sh | sh -s -- --omni";
75417
+ if (antfly_js_1.hasDocker === void 0) {
75418
+ logger_js_1.logger.error("No runtime found.");
75419
+ }
75420
+ const shouldInstall = await confirm("\nAntfly is not installed. Install it now?");
75421
+ if (shouldInstall) {
75422
+ spinner.start(`Installing via ${platform2 === "darwin" ? "Homebrew" : "install script"}...`);
75423
+ (0, node_child_process_1.execSync)(installCmd, { stdio: "inherit" });
75424
+ spinner.succeed("Antfly installed");
75425
+ if (!(0, antfly_js_1.hasModel)(model)) {
75426
+ spinner.start(`Pulling embedding model: ${model}...`);
75427
+ (0, antfly_js_1.pullModel)(model);
75428
+ spinner.succeed(`Embedding model ready: ${model}`);
75429
+ }
75430
+ spinner.start("Starting Antfly server...");
75431
+ await (0, antfly_js_1.ensureAntfly)({ quiet: true });
75432
+ spinner.succeed(`Antfly running on ${(0, antfly_js_1.getAntflyUrl)()}`);
75433
+ } else {
75434
+ logger_js_1.logger.log("\nInstall manually, then run `dev setup` again:");
75435
+ logger_js_1.logger.log(` Docker: https://docker.com/get-started`);
75436
+ logger_js_1.logger.log(` Native: ${installCmd}
75437
+ `);
75438
+ return;
75439
+ }
75440
+ }
75441
+ logger_js_1.logger.log("\n Setup complete!\n");
75442
+ logger_js_1.logger.log(" Next steps:");
75443
+ logger_js_1.logger.log(" dev index . Index your repository");
75444
+ logger_js_1.logger.log(" dev mcp install --cursor Connect to Cursor\n");
75445
+ } catch (error46) {
75446
+ spinner.fail("Setup failed");
75447
+ logger_js_1.logger.error(error46 instanceof Error ? error46.message : String(error46));
75448
+ process.exit(1);
75449
+ }
75450
+ });
75451
+ function getDockerImage() {
75452
+ return "ghcr.io/antflydb/antfly:latest";
75453
+ }
75454
+ }
75455
+ });
75456
+
74107
75457
  // ../cli/dist/commands/storage.js
74108
75458
  var require_storage = __commonJS({
74109
75459
  "../cli/dist/commands/storage.js"(exports2) {
@@ -74150,7 +75500,7 @@ var require_storage = __commonJS({
74150
75500
  };
74151
75501
  Object.defineProperty(exports2, "__esModule", { value: true });
74152
75502
  exports2.storageCommand = void 0;
74153
- var fs14 = __importStar(require("fs/promises"));
75503
+ var fs13 = __importStar(require("fs/promises"));
74154
75504
  var path16 = __importStar(require("path"));
74155
75505
  var readline = __importStar(require("readline"));
74156
75506
  var dev_agent_core_1 = (init_src3(), __toCommonJS(src_exports3));
@@ -74172,17 +75522,17 @@ var require_storage = __commonJS({
74172
75522
  githubState: null
74173
75523
  };
74174
75524
  try {
74175
- await fs14.access(vectorsPath);
75525
+ await fs13.access(vectorsPath);
74176
75526
  result.vectors = vectorsPath;
74177
75527
  } catch {
74178
75528
  }
74179
75529
  try {
74180
- await fs14.access(indexerStatePath);
75530
+ await fs13.access(indexerStatePath);
74181
75531
  result.indexerState = indexerStatePath;
74182
75532
  } catch {
74183
75533
  }
74184
75534
  try {
74185
- await fs14.access(githubStatePath);
75535
+ await fs13.access(githubStatePath);
74186
75536
  result.githubState = githubStatePath;
74187
75537
  } catch {
74188
75538
  }
@@ -74242,7 +75592,7 @@ What's Stored:
74242
75592
  const filePaths = (0, dev_agent_core_1.getStorageFilePaths)(storagePath);
74243
75593
  let centralizedExists = false;
74244
75594
  try {
74245
- await fs14.access(filePaths.vectors);
75595
+ await fs13.access(filePaths.vectors);
74246
75596
  centralizedExists = true;
74247
75597
  } catch {
74248
75598
  }
@@ -74265,28 +75615,28 @@ What's Stored:
74265
75615
  logger_js_1.logger.log(` ${chalk_12.default.gray(`Size: ${(0, file_js_1.formatBytes)(size)}`)}`);
74266
75616
  }
74267
75617
  if (localIndexes.indexerState) {
74268
- const stat4 = await fs14.stat(localIndexes.indexerState);
74269
- totalSize += stat4.size;
75618
+ const stat3 = await fs13.stat(localIndexes.indexerState);
75619
+ totalSize += stat3.size;
74270
75620
  filesToMigrate.push({
74271
75621
  from: localIndexes.indexerState,
74272
75622
  to: filePaths.indexerState,
74273
- size: stat4.size
75623
+ size: stat3.size
74274
75624
  });
74275
75625
  logger_js_1.logger.log(` ${chalk_12.default.cyan("Indexer state:")} ${localIndexes.indexerState}`);
74276
75626
  logger_js_1.logger.log(` ${chalk_12.default.gray(`\u2192 ${filePaths.indexerState}`)}`);
74277
- logger_js_1.logger.log(` ${chalk_12.default.gray(`Size: ${(0, file_js_1.formatBytes)(stat4.size)}`)}`);
75627
+ logger_js_1.logger.log(` ${chalk_12.default.gray(`Size: ${(0, file_js_1.formatBytes)(stat3.size)}`)}`);
74278
75628
  }
74279
75629
  if (localIndexes.githubState) {
74280
- const stat4 = await fs14.stat(localIndexes.githubState);
74281
- totalSize += stat4.size;
75630
+ const stat3 = await fs13.stat(localIndexes.githubState);
75631
+ totalSize += stat3.size;
74282
75632
  filesToMigrate.push({
74283
75633
  from: localIndexes.githubState,
74284
75634
  to: filePaths.githubState,
74285
- size: stat4.size
75635
+ size: stat3.size
74286
75636
  });
74287
75637
  logger_js_1.logger.log(` ${chalk_12.default.cyan("GitHub state:")} ${localIndexes.githubState}`);
74288
75638
  logger_js_1.logger.log(` ${chalk_12.default.gray(`\u2192 ${filePaths.githubState}`)}`);
74289
- logger_js_1.logger.log(` ${chalk_12.default.gray(`Size: ${(0, file_js_1.formatBytes)(stat4.size)}`)}`);
75639
+ logger_js_1.logger.log(` ${chalk_12.default.gray(`Size: ${(0, file_js_1.formatBytes)(stat3.size)}`)}`);
74290
75640
  }
74291
75641
  logger_js_1.logger.log("");
74292
75642
  logger_js_1.logger.log(` ${chalk_12.default.bold("Total size:")} ${(0, file_js_1.formatBytes)(totalSize)}`);
@@ -74316,8 +75666,8 @@ What's Stored:
74316
75666
  spinner.start("Migrating indexes...");
74317
75667
  for (const file2 of filesToMigrate) {
74318
75668
  try {
74319
- await fs14.mkdir(path16.dirname(file2.to), { recursive: true });
74320
- await fs14.rename(file2.from, file2.to);
75669
+ await fs13.mkdir(path16.dirname(file2.to), { recursive: true });
75670
+ await fs13.rename(file2.from, file2.to);
74321
75671
  spinner.text = `Migrated ${path16.basename(file2.from)}`;
74322
75672
  } catch (error46) {
74323
75673
  spinner.fail(`Failed to migrate ${path16.basename(file2.from)}`);
@@ -74338,9 +75688,9 @@ What's Stored:
74338
75688
  }
74339
75689
  try {
74340
75690
  const localDevAgentDir = path16.join(resolvedRepoPath, ".dev-agent");
74341
- const entries = await fs14.readdir(localDevAgentDir);
75691
+ const entries = await fs13.readdir(localDevAgentDir);
74342
75692
  if (entries.length === 0) {
74343
- await fs14.rmdir(localDevAgentDir);
75693
+ await fs13.rmdir(localDevAgentDir);
74344
75694
  }
74345
75695
  } catch {
74346
75696
  }
@@ -74375,7 +75725,7 @@ What's Stored:
74375
75725
  let storageExists = false;
74376
75726
  let totalSize = 0;
74377
75727
  try {
74378
- await fs14.access(storagePath);
75728
+ await fs13.access(storagePath);
74379
75729
  storageExists = true;
74380
75730
  totalSize = await (0, file_js_1.getDirectorySize)(storagePath);
74381
75731
  } catch {
@@ -74388,8 +75738,8 @@ What's Stored:
74388
75738
  ];
74389
75739
  const files = await Promise.all(fileList.map(async (file2) => {
74390
75740
  try {
74391
- const stat4 = await fs14.stat(file2.path);
74392
- const size = stat4.isDirectory() ? await (0, file_js_1.getDirectorySize)(file2.path) : stat4.size;
75741
+ const stat3 = await fs13.stat(file2.path);
75742
+ const size = stat3.isDirectory() ? await (0, file_js_1.getDirectorySize)(file2.path) : stat3.size;
74393
75743
  return {
74394
75744
  name: file2.name,
74395
75745
  path: file2.path,
@@ -74645,10 +75995,11 @@ var map_js_1 = require_map();
74645
75995
  var mcp_js_1 = require_mcp();
74646
75996
  var plan_js_1 = require_plan();
74647
75997
  var search_js_1 = require_search();
75998
+ var setup_js_1 = require_setup();
74648
75999
  var stats_js_1 = require_stats();
74649
76000
  var storage_js_1 = require_storage();
74650
76001
  var update_js_1 = require_update();
74651
- var VERSION = true ? "0.8.5" : "0.0.0-dev";
76002
+ var VERSION = true ? "0.9.0" : "0.0.0-dev";
74652
76003
  var program = new commander_1.Command();
74653
76004
  program.name("dev").description(chalk_1.default.cyan("\u{1F916} Dev-Agent - Multi-agent code intelligence platform")).version(VERSION);
74654
76005
  program.addCommand(init_js_1.initCommand);
@@ -74666,6 +76017,7 @@ program.addCommand(compact_js_1.compactCommand);
74666
76017
  program.addCommand(clean_js_1.cleanCommand);
74667
76018
  program.addCommand(storage_js_1.storageCommand);
74668
76019
  program.addCommand(mcp_js_1.mcpCommand);
76020
+ program.addCommand(setup_js_1.setupCommand);
74669
76021
  if (process.argv.length === 2) {
74670
76022
  program.outputHelp();
74671
76023
  }