@zokizuan/satori-core 0.2.0 → 1.1.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.
@@ -1,4 +1,4 @@
1
- export { VectorDocument, SearchOptions, VectorSearchResult, VectorDatabase, CollectionDetails, VectorStoreBackendInfo, HybridSearchRequest, HybridSearchOptions, HybridSearchResult, RerankStrategy, COLLECTION_LIMIT_MESSAGE } from './types';
1
+ export { VectorDocument, SearchOptions, VectorSearchResult, VectorDatabase, CollectionDetails, VectorStoreBackendInfo, HybridSearchRequest, HybridSearchOptions, HybridSearchResult, RerankStrategy, IndexCompletionFingerprint, IndexCompletionMarkerDocument, INDEX_COMPLETION_MARKER_DOC_ID, INDEX_COMPLETION_MARKER_FILE_EXTENSION, INDEX_COMPLETION_MARKER_RELATIVE_PATH, COLLECTION_LIMIT_MESSAGE } from './types';
2
2
  export { MilvusRestfulVectorDatabase, MilvusRestfulConfig } from './milvus-restful-vectordb';
3
3
  export { MilvusVectorDatabase, MilvusConfig } from './milvus-vectordb';
4
4
  export { ClusterManager, ZillizConfig, Project, Cluster, CreateFreeClusterRequest, CreateFreeClusterResponse, CreateFreeClusterWithDetailsResponse, DescribeClusterResponse } from './zilliz-utils';
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClusterManager = exports.MilvusVectorDatabase = exports.MilvusRestfulVectorDatabase = exports.COLLECTION_LIMIT_MESSAGE = void 0;
3
+ exports.ClusterManager = exports.MilvusVectorDatabase = exports.MilvusRestfulVectorDatabase = exports.COLLECTION_LIMIT_MESSAGE = exports.INDEX_COMPLETION_MARKER_RELATIVE_PATH = exports.INDEX_COMPLETION_MARKER_FILE_EXTENSION = exports.INDEX_COMPLETION_MARKER_DOC_ID = void 0;
4
4
  // Re-export types and interfaces
5
5
  var types_1 = require("./types");
6
+ Object.defineProperty(exports, "INDEX_COMPLETION_MARKER_DOC_ID", { enumerable: true, get: function () { return types_1.INDEX_COMPLETION_MARKER_DOC_ID; } });
7
+ Object.defineProperty(exports, "INDEX_COMPLETION_MARKER_FILE_EXTENSION", { enumerable: true, get: function () { return types_1.INDEX_COMPLETION_MARKER_FILE_EXTENSION; } });
8
+ Object.defineProperty(exports, "INDEX_COMPLETION_MARKER_RELATIVE_PATH", { enumerable: true, get: function () { return types_1.INDEX_COMPLETION_MARKER_RELATIVE_PATH; } });
6
9
  Object.defineProperty(exports, "COLLECTION_LIMIT_MESSAGE", { enumerable: true, get: function () { return types_1.COLLECTION_LIMIT_MESSAGE; } });
7
10
  // Implementation class exports
8
11
  var milvus_restful_vectordb_1 = require("./milvus-restful-vectordb");
@@ -69,11 +69,6 @@ export declare class MilvusRestfulVectorDatabase implements VectorDatabase {
69
69
  private createHybridIndexes;
70
70
  insertHybrid(collectionName: string, documents: VectorDocument[]): Promise<void>;
71
71
  hybridSearch(collectionName: string, searchRequests: HybridSearchRequest[], options?: HybridSearchOptions): Promise<HybridSearchResult[]>;
72
- /**
73
- * Check collection limit
74
- * Returns true if collection can be created, false if limit exceeded
75
- * TODO: Implement proper collection limit checking for REST API
76
- */
77
72
  checkCollectionLimit(): Promise<boolean>;
78
73
  }
79
74
  //# sourceMappingURL=milvus-restful-vectordb.d.ts.map
@@ -444,7 +444,7 @@ class MilvusRestfulVectorDatabase {
444
444
  score: item.distance || 0
445
445
  };
446
446
  });
447
- return results;
447
+ return results.filter((result) => options?.threshold === undefined || result.score >= options.threshold);
448
448
  }
449
449
  catch (error) {
450
450
  console.error(`[MilvusRestfulDB] ❌ Failed to search in collection '${collectionName}':`, error);
@@ -720,7 +720,8 @@ class MilvusRestfulVectorDatabase {
720
720
  const results = response.data || [];
721
721
  console.log(`[MilvusRestfulDB] ✅ Found ${results.length} results from hybrid search`);
722
722
  // Transform response to HybridSearchResult format
723
- return results.map((result) => ({
723
+ return results
724
+ .map((result) => ({
724
725
  document: {
725
726
  id: result.id,
726
727
  content: result.content,
@@ -733,23 +734,54 @@ class MilvusRestfulVectorDatabase {
733
734
  metadata: JSON.parse(result.metadata || '{}'),
734
735
  },
735
736
  score: result.score || result.distance || 0,
736
- }));
737
+ }))
738
+ .filter((result) => options?.threshold === undefined || result.score >= options.threshold);
737
739
  }
738
740
  catch (error) {
739
741
  console.error(`[MilvusRestfulDB] ❌ Failed to perform hybrid search on collection '${collectionName}':`, error);
740
742
  throw error;
741
743
  }
742
744
  }
743
- /**
744
- * Check collection limit
745
- * Returns true if collection can be created, false if limit exceeded
746
- * TODO: Implement proper collection limit checking for REST API
747
- */
748
745
  async checkCollectionLimit() {
749
- // TODO: Implement REST API version of collection limit checking
750
- // For now, always return true to maintain compatibility
751
- console.warn('[MilvusRestfulDB] ⚠️ checkCollectionLimit not implemented for REST API - returning true');
752
- return true;
746
+ await this.ensureInitialized();
747
+ const restfulConfig = this.config;
748
+ const collectionName = `dummy_collection_${Date.now()}`;
749
+ const collectionSchema = {
750
+ collectionName,
751
+ dbName: restfulConfig.database,
752
+ schema: {
753
+ enableDynamicField: false,
754
+ fields: [
755
+ {
756
+ fieldName: "id",
757
+ dataType: "VarChar",
758
+ isPrimary: true,
759
+ elementTypeParams: {
760
+ max_length: 512
761
+ }
762
+ },
763
+ {
764
+ fieldName: "vector",
765
+ dataType: "FloatVector",
766
+ elementTypeParams: {
767
+ dim: 128
768
+ }
769
+ }
770
+ ]
771
+ }
772
+ };
773
+ try {
774
+ await createCollectionWithLimitCheck(this.makeRequest.bind(this), collectionSchema);
775
+ await this.dropCollection(collectionName);
776
+ return true;
777
+ }
778
+ catch (error) {
779
+ const message = error instanceof Error ? error.message : String(error);
780
+ if (message === types_1.COLLECTION_LIMIT_MESSAGE) {
781
+ return false;
782
+ }
783
+ throw error;
784
+ }
753
785
  }
754
786
  }
755
787
  exports.MilvusRestfulVectorDatabase = MilvusRestfulVectorDatabase;
@@ -442,7 +442,8 @@ class MilvusVectorDatabase {
442
442
  if (!searchResult.results || searchResult.results.length === 0) {
443
443
  return [];
444
444
  }
445
- return searchResult.results.map((result) => ({
445
+ return searchResult.results
446
+ .map((result) => ({
446
447
  document: {
447
448
  id: result.id,
448
449
  vector: queryVector,
@@ -454,7 +455,8 @@ class MilvusVectorDatabase {
454
455
  metadata: JSON.parse(result.metadata || '{}'),
455
456
  },
456
457
  score: result.score,
457
- }));
458
+ }))
459
+ .filter((result) => options?.threshold === undefined || result.score >= options.threshold);
458
460
  }
459
461
  async delete(collectionName, ids) {
460
462
  await this.ensureInitialized();
@@ -700,7 +702,8 @@ class MilvusVectorDatabase {
700
702
  }
701
703
  console.log(`[MilvusDB] ✅ Found ${searchResult.results.length} results from hybrid search`);
702
704
  // Transform results to HybridSearchResult format
703
- return searchResult.results.map((result) => ({
705
+ return searchResult.results
706
+ .map((result) => ({
704
707
  document: {
705
708
  id: result.id,
706
709
  content: result.content,
@@ -713,7 +716,8 @@ class MilvusVectorDatabase {
713
716
  metadata: JSON.parse(result.metadata || '{}'),
714
717
  },
715
718
  score: result.score,
716
- }));
719
+ }))
720
+ .filter((result) => options?.threshold === undefined || result.score >= options.threshold);
717
721
  }
718
722
  catch (error) {
719
723
  console.error(`[MilvusDB] ❌ Failed to perform hybrid search on collection '${collectionName}':`, error);
@@ -23,6 +23,7 @@ export interface HybridSearchRequest {
23
23
  export interface HybridSearchOptions {
24
24
  rerank?: RerankStrategy;
25
25
  limit?: number;
26
+ threshold?: number;
26
27
  filterExpr?: string;
27
28
  }
28
29
  export interface RerankStrategy {
@@ -46,6 +47,25 @@ export interface VectorStoreBackendInfo {
46
47
  transport: 'grpc' | 'rest';
47
48
  address?: string;
48
49
  }
50
+ export interface IndexCompletionFingerprint {
51
+ embeddingProvider: string;
52
+ embeddingModel: string;
53
+ embeddingDimension: number;
54
+ vectorStoreProvider: string;
55
+ schemaVersion: string;
56
+ }
57
+ export interface IndexCompletionMarkerDocument {
58
+ kind: 'satori_index_completion_v1';
59
+ codebasePath: string;
60
+ fingerprint: IndexCompletionFingerprint;
61
+ indexedFiles: number;
62
+ totalChunks: number;
63
+ completedAt: string;
64
+ runId: string;
65
+ }
66
+ export declare const INDEX_COMPLETION_MARKER_DOC_ID = "__satori_index_completion_marker_v1__";
67
+ export declare const INDEX_COMPLETION_MARKER_FILE_EXTENSION = ".satori_meta";
68
+ export declare const INDEX_COMPLETION_MARKER_RELATIVE_PATH = ".__satori__/index_completion_marker.json";
49
69
  export interface VectorDatabase {
50
70
  /**
51
71
  * Create collection
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COLLECTION_LIMIT_MESSAGE = void 0;
3
+ exports.COLLECTION_LIMIT_MESSAGE = exports.INDEX_COMPLETION_MARKER_RELATIVE_PATH = exports.INDEX_COMPLETION_MARKER_FILE_EXTENSION = exports.INDEX_COMPLETION_MARKER_DOC_ID = void 0;
4
+ exports.INDEX_COMPLETION_MARKER_DOC_ID = '__satori_index_completion_marker_v1__';
5
+ exports.INDEX_COMPLETION_MARKER_FILE_EXTENSION = '.satori_meta';
6
+ exports.INDEX_COMPLETION_MARKER_RELATIVE_PATH = '.__satori__/index_completion_marker.json';
4
7
  /**
5
8
  * Special error message for collection limit exceeded
6
9
  * This allows us to distinguish it from other errors across all Milvus implementations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zokizuan/satori-core",
3
- "version": "0.2.0",
3
+ "version": "1.1.0",
4
4
  "description": "Core semantic indexing engine for Satori's insight-first retrieval",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",