@wiscale/velesdb-sdk 1.15.0 → 1.18.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/index.d.mts CHANGED
@@ -470,14 +470,16 @@ interface SearchResult {
470
470
  * @packageDocumentation
471
471
  */
472
472
 
473
+ /** Graph node/edge ID. Large u64 IDs may be returned as strings to preserve precision. */
474
+ type GraphNodeId = number | string;
473
475
  /** Graph edge representing a relationship between nodes */
474
476
  interface GraphEdge {
475
477
  /** Unique edge ID */
476
- id: number;
478
+ id: GraphNodeId;
477
479
  /** Source node ID */
478
- source: number;
480
+ source: GraphNodeId;
479
481
  /** Target node ID */
480
- target: number;
482
+ target: GraphNodeId;
481
483
  /** Edge label (relationship type, e.g., "KNOWS", "FOLLOWS") */
482
484
  label: string;
483
485
  /** Edge properties */
@@ -504,7 +506,7 @@ interface GetEdgesOptions {
504
506
  /** Request for graph traversal (EPIC-016 US-050) */
505
507
  interface TraverseRequest {
506
508
  /** Source node ID to start traversal from */
507
- source: number;
509
+ source: GraphNodeId;
508
510
  /** Traversal strategy: 'bfs' or 'dfs' */
509
511
  strategy?: 'bfs' | 'dfs';
510
512
  /** Maximum traversal depth */
@@ -519,7 +521,7 @@ interface TraverseRequest {
519
521
  /** Request for multi-source parallel BFS traversal */
520
522
  interface TraverseParallelRequest {
521
523
  /** Source node IDs to start traversal from */
522
- sources: number[];
524
+ sources: GraphNodeId[];
523
525
  /** Maximum traversal depth */
524
526
  maxDepth?: number;
525
527
  /** Maximum number of results to return */
@@ -530,11 +532,11 @@ interface TraverseParallelRequest {
530
532
  /** A single traversal result item */
531
533
  interface TraversalResultItem {
532
534
  /** Target node ID reached */
533
- targetId: number;
535
+ targetId: GraphNodeId;
534
536
  /** Depth of traversal (number of hops from source) */
535
537
  depth: number;
536
538
  /** Path taken (list of edge IDs) */
537
- path: number[];
539
+ path: GraphNodeId[];
538
540
  }
539
541
  /** Statistics from traversal operation */
540
542
  interface TraversalStats {
@@ -607,6 +609,14 @@ interface ProceduralPattern {
607
609
  name: string;
608
610
  /** Ordered steps */
609
611
  steps: string[];
612
+ /**
613
+ * Embedding vector for the pattern.
614
+ *
615
+ * Required so that `matchProceduralPatterns` (a vector search) can
616
+ * recall the pattern — a point stored without a vector is invisible
617
+ * to similarity search.
618
+ */
619
+ embedding: number[];
610
620
  /** Optional metadata */
611
621
  metadata?: Record<string, unknown>;
612
622
  }
@@ -648,8 +658,8 @@ interface ColumnStatsDetail {
648
658
  name: string;
649
659
  nullCount: number;
650
660
  distinctCount: number;
651
- minValue: unknown | null;
652
- maxValue: unknown | null;
661
+ minValue: unknown;
662
+ maxValue: unknown;
653
663
  avgSizeBytes: number;
654
664
  histogramBuckets: number | null;
655
665
  histogramStale: boolean | null;
@@ -944,6 +954,7 @@ declare const WASM_CAPABILITIES: Readonly<CapabilityMap>;
944
954
  * aggregate, match query, graph node operations, and graph search.
945
955
  * @packageDocumentation
946
956
  */
957
+
947
958
  /** Result of `POST /collections/{name}/index/rebuild`. */
948
959
  interface RebuildIndexResponse {
949
960
  /** Informational message from the server. */
@@ -975,8 +986,8 @@ interface GuardRailsConfigResponse {
975
986
  }
976
987
  /** Options for `listNodes`. */
977
988
  interface ListNodesResponse {
978
- /** Node IDs in insertion order. */
979
- nodeIds: number[];
989
+ /** Node IDs in insertion order (string|number to preserve u64 precision). */
990
+ nodeIds: GraphNodeId[];
980
991
  /** Total count -- matches `nodeIds.length`. */
981
992
  count: number;
982
993
  }
@@ -990,7 +1001,7 @@ interface GetNodeEdgesOptions {
990
1001
  /** Result of `GET /collections/{name}/graph/nodes/{id}/payload`. */
991
1002
  interface NodePayloadResponse {
992
1003
  /** Node ID. */
993
- nodeId: number;
1004
+ nodeId: GraphNodeId;
994
1005
  /** Stored payload -- `null` if no payload has been set. */
995
1006
  payload: Record<string, unknown> | null;
996
1007
  }
@@ -1004,7 +1015,7 @@ interface GraphSearchRequest {
1004
1015
  /** Single result item from `graphSearch`. */
1005
1016
  interface GraphSearchResultItem {
1006
1017
  /** Node ID. */
1007
- id: number;
1018
+ id: GraphNodeId;
1008
1019
  /** Similarity score. */
1009
1020
  score: number;
1010
1021
  /** Optional node payload (mirror of `GraphSearchResultItem.payload`). */
@@ -1044,7 +1055,7 @@ interface MatchQueryResponse {
1044
1055
  /** Single row of a `MatchQueryResponse`. */
1045
1056
  interface MatchQueryResultItem {
1046
1057
  /** Variable-binding map from the MATCH pattern. */
1047
- bindings: Record<string, number>;
1058
+ bindings: Record<string, GraphNodeId>;
1048
1059
  /** Similarity score, present only when `similarity()` was used. */
1049
1060
  score?: number;
1050
1061
  /** Traversal depth reached to produce this row. */
@@ -1228,12 +1239,12 @@ interface IVelesDBBackend {
1228
1239
  storeSemanticFact(collection: string, entry: SemanticEntry): Promise<void>;
1229
1240
  /** Search semantic memory */
1230
1241
  searchSemanticMemory(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1231
- /** Record an episodic event */
1232
- recordEpisodicEvent(collection: string, event: EpisodicEvent): Promise<void>;
1242
+ /** Record an episodic event. Returns the generated point ID. */
1243
+ recordEpisodicEvent(collection: string, event: EpisodicEvent): Promise<number>;
1233
1244
  /** Recall episodic events */
1234
1245
  recallEpisodicEvents(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1235
- /** Store a procedural pattern */
1236
- storeProceduralPattern(collection: string, pattern: ProceduralPattern): Promise<void>;
1246
+ /** Store a procedural pattern. Returns the generated point ID. */
1247
+ storeProceduralPattern(collection: string, pattern: ProceduralPattern): Promise<number>;
1237
1248
  /** Match procedural patterns */
1238
1249
  matchProceduralPatterns(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1239
1250
  /** Rebuild a collection's HNSW index (compacts tombstones). */
@@ -1302,20 +1313,31 @@ declare class AgentMemoryClient {
1302
1313
  private readonly backend;
1303
1314
  private readonly config?;
1304
1315
  constructor(backend: IVelesDBBackend, config?: AgentMemoryConfig | undefined);
1305
- /** Configured embedding dimension (default: 384) */
1316
+ /**
1317
+ * Advisory embedding dimension passed at construction (default: 384).
1318
+ *
1319
+ * This value is **not** enforced and does not create or size any
1320
+ * collection — the dimension that actually governs storage and search
1321
+ * is the one fixed when the collection was created
1322
+ * (`db.createCollection(name, { dimension, metric: 'cosine' })`).
1323
+ * Embeddings you pass to `storeFact` / `recordEvent` / `learnProcedure`
1324
+ * must match that collection dimension.
1325
+ */
1306
1326
  get dimension(): number;
1307
1327
  /** Store a semantic fact */
1308
1328
  storeFact(collection: string, entry: SemanticEntry): Promise<void>;
1309
1329
  /** Search semantic memory */
1310
1330
  searchFacts(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1311
- /** Record an episodic event */
1312
- recordEvent(collection: string, event: EpisodicEvent): Promise<void>;
1331
+ /** Record an episodic event. Returns the generated point ID. */
1332
+ recordEvent(collection: string, event: EpisodicEvent): Promise<number>;
1313
1333
  /** Recall episodic events */
1314
1334
  recallEvents(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1315
- /** Store a procedural pattern */
1316
- learnProcedure(collection: string, pattern: ProceduralPattern): Promise<void>;
1335
+ /** Store a procedural pattern. Returns the generated point ID. */
1336
+ learnProcedure(collection: string, pattern: ProceduralPattern): Promise<number>;
1317
1337
  /** Match procedural patterns */
1318
1338
  recallProcedures(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1339
+ /** Delete a memory entry (fact, event, or procedure) by its point ID. */
1340
+ deleteMemory(collection: string, id: number): Promise<boolean>;
1319
1341
  }
1320
1342
 
1321
1343
  /**
@@ -1492,9 +1514,9 @@ declare class WasmBackend implements IVelesDBBackend {
1492
1514
  }>>;
1493
1515
  storeSemanticFact(c: string, e: SemanticEntry): Promise<void>;
1494
1516
  searchSemanticMemory(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1495
- recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<void>;
1517
+ recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<number>;
1496
1518
  recallEpisodicEvents(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1497
- storeProceduralPattern(c: string, p: ProceduralPattern): Promise<void>;
1519
+ storeProceduralPattern(c: string, p: ProceduralPattern): Promise<number>;
1498
1520
  matchProceduralPatterns(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1499
1521
  rebuildIndex(c: string): Promise<RebuildIndexResponse>;
1500
1522
  getGuardrails(): Promise<GuardRailsConfigResponse>;
@@ -1593,9 +1615,9 @@ declare class RestBackend implements IVelesDBBackend {
1593
1615
  streamUpsertPoints(c: string, d: VectorDocument[]): Promise<StreamUpsertResponse>;
1594
1616
  storeSemanticFact(c: string, e: SemanticEntry): Promise<void>;
1595
1617
  searchSemanticMemory(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1596
- recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<void>;
1618
+ recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<number>;
1597
1619
  recallEpisodicEvents(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1598
- storeProceduralPattern(c: string, p: ProceduralPattern): Promise<void>;
1620
+ storeProceduralPattern(c: string, p: ProceduralPattern): Promise<number>;
1599
1621
  matchProceduralPatterns(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1600
1622
  }
1601
1623
 
@@ -2046,4 +2068,45 @@ type VelesErrorCode = (typeof VELES_ERROR_CODES)[number];
2046
2068
  */
2047
2069
  declare function parseVelesError(code: string | null | undefined, message: string): VelesError;
2048
2070
 
2049
- export { type ActualStats, type AddEdgeRequest, AgentMemoryClient, type AgentMemoryConfig, type AggregateQueryOptions, type AggregateResponse, type AggregationQueryResponse, AllocationFailedError, type AsyncIndexBuilderOptions, type BackendType, BackpressureError, type CapabilityMap, type Collection, type CollectionConfig, type CollectionConfigResponse, CollectionExistsError, CollectionNotFoundError, type CollectionSanityChecks, type CollectionSanityDiagnostics, type CollectionSanityResponse, type CollectionStatsResponse, type CollectionType, type ColumnStatsDetail, ColumnStoreError, type CompareOp, type Condition, ConfigError, ConnectionError, type CreateIndexOptions, DatabaseLockedError, type DeferredIndexerOptions, type DegreeResponse, DimensionMismatchError, type DistanceMetric, EdgeExistsError, EdgeNotFoundError, type EdgesResponse, type EpisodicEvent, EpochMismatchError, type ExplainCost, type ExplainFeatures, type ExplainPlanStep, type ExplainResponse, type Filter, type FilterInput, type FusionOptions, type FusionStrategy, type GetEdgesOptions, type GetNodeEdgesOptions, GpuError, type GraphCollectionConfig, type GraphEdge, GraphNotSupportedError, type GraphSchemaMode, type GraphSearchRequest, type GraphSearchResponse, type GraphSearchResultItem, GuardRailError, type GuardRailsConfigResponse, type GuardRailsUpdateRequest, type HnswParams, type IVelesDBBackend, IncompatibleSchemaVersionError, IndexCorruptedError, IndexError, type IndexInfo, type IndexType, InternalError, InvalidCollectionNameError, InvalidDimensionError, InvalidEdgeLabelError, InvalidQuantizerConfigError, InvalidVectorError, IoError, type JsonValue, type ListNodesResponse, type MatchQueryOptions, type MatchQueryResponse, type MatchQueryResultItem, type MultiQuerySearchOptions, type NearVectorOptions, NodeNotFoundError, type NodePayloadResponse, type NodeStats, NotFoundError, OverflowError, PointNotFoundError, type PqTrainOptions, type ProceduralPattern, type QueryApiResponse, QueryError, type QueryOptions, type QueryResponse, type QueryResult, type QueryStats, REST_CAPABILITIES, type RebuildIndexResponse, type RelDirection, type RelOptions, RestBackend, type RestPointId, SchemaValidationError, type ScrollRequest, type ScrollResponse, SearchNotSupportedError, type SearchOptions, type SearchQuality, type SearchQualityWire, type SearchResult, type SemanticEntry, SerializationError, SnapshotBuildFailedError, SparseIndexError, type SparseSearchNamedOptions, type SparseVector, StorageError, type StorageMode, type StreamUpsertResponse, TrainingFailedError, type TraversalResultItem, type TraversalStats, type TraverseParallelRequest, type TraverseRequest, type TraverseResponse, VELES_ERROR_CODES, ValidationError, type VectorDocument, VectorNotAllowedError, VectorRequiredError, VelesDB, type VelesDBConfig, VelesDBError, VelesError, type VelesErrorCode, VelesQLBuilder, WASM_CAPABILITIES, WasmBackend, f, isTypedFilter, normalizeFilter, parseVelesError, searchQualityToMode, velesql };
2071
+ /**
2072
+ * Optional embedding helpers for the VelesDB TypeScript SDK.
2073
+ *
2074
+ * A thin {@link Embedder} interface plus an adapter for OpenAI-compatible
2075
+ * endpoints. The adapter uses the global `fetch` API (Node ≥ 18, browsers,
2076
+ * Deno) and has no additional runtime dependencies.
2077
+ *
2078
+ * @example
2079
+ * ```typescript
2080
+ * import { VelesDB, OpenAIEmbedder } from '@wiscale/velesdb-sdk';
2081
+ *
2082
+ * const embedder = new OpenAIEmbedder({ apiKey: process.env.OPENAI_API_KEY! });
2083
+ * const db = new VelesDB({ backend: 'wasm' });
2084
+ * await db.init();
2085
+ * await db.createCollection('docs', { dimension: embedder.dimension ?? 1536 });
2086
+ * const vectors = await embedder.embed(['hello world', 'vector search']);
2087
+ * ```
2088
+ */
2089
+ interface Embedder {
2090
+ /** Embedding dimension, or `0` if not yet known (determined after first call). */
2091
+ readonly dimension: number;
2092
+ embed(texts: string[]): Promise<number[][]>;
2093
+ }
2094
+ interface OpenAIEmbedderOptions {
2095
+ model?: string;
2096
+ apiKey: string;
2097
+ /** Override the base URL for Azure OpenAI, vLLM, or any compatible endpoint. */
2098
+ baseUrl?: string;
2099
+ /** Request a specific output dimension (requires a model that supports it). */
2100
+ dimensions?: number;
2101
+ }
2102
+ declare class OpenAIEmbedder implements Embedder {
2103
+ private readonly model;
2104
+ private readonly apiKey;
2105
+ private readonly baseUrl;
2106
+ private readonly requestedDimensions;
2107
+ dimension: number;
2108
+ constructor(options: OpenAIEmbedderOptions);
2109
+ embed(texts: string[]): Promise<number[][]>;
2110
+ }
2111
+
2112
+ export { type ActualStats, type AddEdgeRequest, AgentMemoryClient, type AgentMemoryConfig, type AggregateQueryOptions, type AggregateResponse, type AggregationQueryResponse, AllocationFailedError, type AsyncIndexBuilderOptions, type BackendType, BackpressureError, type CapabilityMap, type Collection, type CollectionConfig, type CollectionConfigResponse, CollectionExistsError, CollectionNotFoundError, type CollectionSanityChecks, type CollectionSanityDiagnostics, type CollectionSanityResponse, type CollectionStatsResponse, type CollectionType, type ColumnStatsDetail, ColumnStoreError, type CompareOp, type Condition, ConfigError, ConnectionError, type CreateIndexOptions, DatabaseLockedError, type DeferredIndexerOptions, type DegreeResponse, DimensionMismatchError, type DistanceMetric, EdgeExistsError, EdgeNotFoundError, type EdgesResponse, type Embedder, type EpisodicEvent, EpochMismatchError, type ExplainCost, type ExplainFeatures, type ExplainPlanStep, type ExplainResponse, type Filter, type FilterInput, type FusionOptions, type FusionStrategy, type GetEdgesOptions, type GetNodeEdgesOptions, GpuError, type GraphCollectionConfig, type GraphEdge, type GraphNodeId, GraphNotSupportedError, type GraphSchemaMode, type GraphSearchRequest, type GraphSearchResponse, type GraphSearchResultItem, GuardRailError, type GuardRailsConfigResponse, type GuardRailsUpdateRequest, type HnswParams, type IVelesDBBackend, IncompatibleSchemaVersionError, IndexCorruptedError, IndexError, type IndexInfo, type IndexType, InternalError, InvalidCollectionNameError, InvalidDimensionError, InvalidEdgeLabelError, InvalidQuantizerConfigError, InvalidVectorError, IoError, type JsonValue, type ListNodesResponse, type MatchQueryOptions, type MatchQueryResponse, type MatchQueryResultItem, type MultiQuerySearchOptions, type NearVectorOptions, NodeNotFoundError, type NodePayloadResponse, type NodeStats, NotFoundError, OpenAIEmbedder, type OpenAIEmbedderOptions, OverflowError, PointNotFoundError, type PqTrainOptions, type ProceduralPattern, type QueryApiResponse, QueryError, type QueryOptions, type QueryResponse, type QueryResult, type QueryStats, REST_CAPABILITIES, type RebuildIndexResponse, type RelDirection, type RelOptions, RestBackend, type RestPointId, SchemaValidationError, type ScrollRequest, type ScrollResponse, SearchNotSupportedError, type SearchOptions, type SearchQuality, type SearchQualityWire, type SearchResult, type SemanticEntry, SerializationError, SnapshotBuildFailedError, SparseIndexError, type SparseSearchNamedOptions, type SparseVector, StorageError, type StorageMode, type StreamUpsertResponse, TrainingFailedError, type TraversalResultItem, type TraversalStats, type TraverseParallelRequest, type TraverseRequest, type TraverseResponse, VELES_ERROR_CODES, ValidationError, type VectorDocument, VectorNotAllowedError, VectorRequiredError, VelesDB, type VelesDBConfig, VelesDBError, VelesError, type VelesErrorCode, VelesQLBuilder, WASM_CAPABILITIES, WasmBackend, f, isTypedFilter, normalizeFilter, parseVelesError, searchQualityToMode, velesql };
package/dist/index.d.ts CHANGED
@@ -470,14 +470,16 @@ interface SearchResult {
470
470
  * @packageDocumentation
471
471
  */
472
472
 
473
+ /** Graph node/edge ID. Large u64 IDs may be returned as strings to preserve precision. */
474
+ type GraphNodeId = number | string;
473
475
  /** Graph edge representing a relationship between nodes */
474
476
  interface GraphEdge {
475
477
  /** Unique edge ID */
476
- id: number;
478
+ id: GraphNodeId;
477
479
  /** Source node ID */
478
- source: number;
480
+ source: GraphNodeId;
479
481
  /** Target node ID */
480
- target: number;
482
+ target: GraphNodeId;
481
483
  /** Edge label (relationship type, e.g., "KNOWS", "FOLLOWS") */
482
484
  label: string;
483
485
  /** Edge properties */
@@ -504,7 +506,7 @@ interface GetEdgesOptions {
504
506
  /** Request for graph traversal (EPIC-016 US-050) */
505
507
  interface TraverseRequest {
506
508
  /** Source node ID to start traversal from */
507
- source: number;
509
+ source: GraphNodeId;
508
510
  /** Traversal strategy: 'bfs' or 'dfs' */
509
511
  strategy?: 'bfs' | 'dfs';
510
512
  /** Maximum traversal depth */
@@ -519,7 +521,7 @@ interface TraverseRequest {
519
521
  /** Request for multi-source parallel BFS traversal */
520
522
  interface TraverseParallelRequest {
521
523
  /** Source node IDs to start traversal from */
522
- sources: number[];
524
+ sources: GraphNodeId[];
523
525
  /** Maximum traversal depth */
524
526
  maxDepth?: number;
525
527
  /** Maximum number of results to return */
@@ -530,11 +532,11 @@ interface TraverseParallelRequest {
530
532
  /** A single traversal result item */
531
533
  interface TraversalResultItem {
532
534
  /** Target node ID reached */
533
- targetId: number;
535
+ targetId: GraphNodeId;
534
536
  /** Depth of traversal (number of hops from source) */
535
537
  depth: number;
536
538
  /** Path taken (list of edge IDs) */
537
- path: number[];
539
+ path: GraphNodeId[];
538
540
  }
539
541
  /** Statistics from traversal operation */
540
542
  interface TraversalStats {
@@ -607,6 +609,14 @@ interface ProceduralPattern {
607
609
  name: string;
608
610
  /** Ordered steps */
609
611
  steps: string[];
612
+ /**
613
+ * Embedding vector for the pattern.
614
+ *
615
+ * Required so that `matchProceduralPatterns` (a vector search) can
616
+ * recall the pattern — a point stored without a vector is invisible
617
+ * to similarity search.
618
+ */
619
+ embedding: number[];
610
620
  /** Optional metadata */
611
621
  metadata?: Record<string, unknown>;
612
622
  }
@@ -648,8 +658,8 @@ interface ColumnStatsDetail {
648
658
  name: string;
649
659
  nullCount: number;
650
660
  distinctCount: number;
651
- minValue: unknown | null;
652
- maxValue: unknown | null;
661
+ minValue: unknown;
662
+ maxValue: unknown;
653
663
  avgSizeBytes: number;
654
664
  histogramBuckets: number | null;
655
665
  histogramStale: boolean | null;
@@ -944,6 +954,7 @@ declare const WASM_CAPABILITIES: Readonly<CapabilityMap>;
944
954
  * aggregate, match query, graph node operations, and graph search.
945
955
  * @packageDocumentation
946
956
  */
957
+
947
958
  /** Result of `POST /collections/{name}/index/rebuild`. */
948
959
  interface RebuildIndexResponse {
949
960
  /** Informational message from the server. */
@@ -975,8 +986,8 @@ interface GuardRailsConfigResponse {
975
986
  }
976
987
  /** Options for `listNodes`. */
977
988
  interface ListNodesResponse {
978
- /** Node IDs in insertion order. */
979
- nodeIds: number[];
989
+ /** Node IDs in insertion order (string|number to preserve u64 precision). */
990
+ nodeIds: GraphNodeId[];
980
991
  /** Total count -- matches `nodeIds.length`. */
981
992
  count: number;
982
993
  }
@@ -990,7 +1001,7 @@ interface GetNodeEdgesOptions {
990
1001
  /** Result of `GET /collections/{name}/graph/nodes/{id}/payload`. */
991
1002
  interface NodePayloadResponse {
992
1003
  /** Node ID. */
993
- nodeId: number;
1004
+ nodeId: GraphNodeId;
994
1005
  /** Stored payload -- `null` if no payload has been set. */
995
1006
  payload: Record<string, unknown> | null;
996
1007
  }
@@ -1004,7 +1015,7 @@ interface GraphSearchRequest {
1004
1015
  /** Single result item from `graphSearch`. */
1005
1016
  interface GraphSearchResultItem {
1006
1017
  /** Node ID. */
1007
- id: number;
1018
+ id: GraphNodeId;
1008
1019
  /** Similarity score. */
1009
1020
  score: number;
1010
1021
  /** Optional node payload (mirror of `GraphSearchResultItem.payload`). */
@@ -1044,7 +1055,7 @@ interface MatchQueryResponse {
1044
1055
  /** Single row of a `MatchQueryResponse`. */
1045
1056
  interface MatchQueryResultItem {
1046
1057
  /** Variable-binding map from the MATCH pattern. */
1047
- bindings: Record<string, number>;
1058
+ bindings: Record<string, GraphNodeId>;
1048
1059
  /** Similarity score, present only when `similarity()` was used. */
1049
1060
  score?: number;
1050
1061
  /** Traversal depth reached to produce this row. */
@@ -1228,12 +1239,12 @@ interface IVelesDBBackend {
1228
1239
  storeSemanticFact(collection: string, entry: SemanticEntry): Promise<void>;
1229
1240
  /** Search semantic memory */
1230
1241
  searchSemanticMemory(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1231
- /** Record an episodic event */
1232
- recordEpisodicEvent(collection: string, event: EpisodicEvent): Promise<void>;
1242
+ /** Record an episodic event. Returns the generated point ID. */
1243
+ recordEpisodicEvent(collection: string, event: EpisodicEvent): Promise<number>;
1233
1244
  /** Recall episodic events */
1234
1245
  recallEpisodicEvents(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1235
- /** Store a procedural pattern */
1236
- storeProceduralPattern(collection: string, pattern: ProceduralPattern): Promise<void>;
1246
+ /** Store a procedural pattern. Returns the generated point ID. */
1247
+ storeProceduralPattern(collection: string, pattern: ProceduralPattern): Promise<number>;
1237
1248
  /** Match procedural patterns */
1238
1249
  matchProceduralPatterns(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1239
1250
  /** Rebuild a collection's HNSW index (compacts tombstones). */
@@ -1302,20 +1313,31 @@ declare class AgentMemoryClient {
1302
1313
  private readonly backend;
1303
1314
  private readonly config?;
1304
1315
  constructor(backend: IVelesDBBackend, config?: AgentMemoryConfig | undefined);
1305
- /** Configured embedding dimension (default: 384) */
1316
+ /**
1317
+ * Advisory embedding dimension passed at construction (default: 384).
1318
+ *
1319
+ * This value is **not** enforced and does not create or size any
1320
+ * collection — the dimension that actually governs storage and search
1321
+ * is the one fixed when the collection was created
1322
+ * (`db.createCollection(name, { dimension, metric: 'cosine' })`).
1323
+ * Embeddings you pass to `storeFact` / `recordEvent` / `learnProcedure`
1324
+ * must match that collection dimension.
1325
+ */
1306
1326
  get dimension(): number;
1307
1327
  /** Store a semantic fact */
1308
1328
  storeFact(collection: string, entry: SemanticEntry): Promise<void>;
1309
1329
  /** Search semantic memory */
1310
1330
  searchFacts(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1311
- /** Record an episodic event */
1312
- recordEvent(collection: string, event: EpisodicEvent): Promise<void>;
1331
+ /** Record an episodic event. Returns the generated point ID. */
1332
+ recordEvent(collection: string, event: EpisodicEvent): Promise<number>;
1313
1333
  /** Recall episodic events */
1314
1334
  recallEvents(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1315
- /** Store a procedural pattern */
1316
- learnProcedure(collection: string, pattern: ProceduralPattern): Promise<void>;
1335
+ /** Store a procedural pattern. Returns the generated point ID. */
1336
+ learnProcedure(collection: string, pattern: ProceduralPattern): Promise<number>;
1317
1337
  /** Match procedural patterns */
1318
1338
  recallProcedures(collection: string, embedding: number[], k?: number): Promise<SearchResult[]>;
1339
+ /** Delete a memory entry (fact, event, or procedure) by its point ID. */
1340
+ deleteMemory(collection: string, id: number): Promise<boolean>;
1319
1341
  }
1320
1342
 
1321
1343
  /**
@@ -1492,9 +1514,9 @@ declare class WasmBackend implements IVelesDBBackend {
1492
1514
  }>>;
1493
1515
  storeSemanticFact(c: string, e: SemanticEntry): Promise<void>;
1494
1516
  searchSemanticMemory(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1495
- recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<void>;
1517
+ recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<number>;
1496
1518
  recallEpisodicEvents(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1497
- storeProceduralPattern(c: string, p: ProceduralPattern): Promise<void>;
1519
+ storeProceduralPattern(c: string, p: ProceduralPattern): Promise<number>;
1498
1520
  matchProceduralPatterns(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1499
1521
  rebuildIndex(c: string): Promise<RebuildIndexResponse>;
1500
1522
  getGuardrails(): Promise<GuardRailsConfigResponse>;
@@ -1593,9 +1615,9 @@ declare class RestBackend implements IVelesDBBackend {
1593
1615
  streamUpsertPoints(c: string, d: VectorDocument[]): Promise<StreamUpsertResponse>;
1594
1616
  storeSemanticFact(c: string, e: SemanticEntry): Promise<void>;
1595
1617
  searchSemanticMemory(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1596
- recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<void>;
1618
+ recordEpisodicEvent(c: string, e: EpisodicEvent): Promise<number>;
1597
1619
  recallEpisodicEvents(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1598
- storeProceduralPattern(c: string, p: ProceduralPattern): Promise<void>;
1620
+ storeProceduralPattern(c: string, p: ProceduralPattern): Promise<number>;
1599
1621
  matchProceduralPatterns(c: string, e: number[], k?: number): Promise<SearchResult[]>;
1600
1622
  }
1601
1623
 
@@ -2046,4 +2068,45 @@ type VelesErrorCode = (typeof VELES_ERROR_CODES)[number];
2046
2068
  */
2047
2069
  declare function parseVelesError(code: string | null | undefined, message: string): VelesError;
2048
2070
 
2049
- export { type ActualStats, type AddEdgeRequest, AgentMemoryClient, type AgentMemoryConfig, type AggregateQueryOptions, type AggregateResponse, type AggregationQueryResponse, AllocationFailedError, type AsyncIndexBuilderOptions, type BackendType, BackpressureError, type CapabilityMap, type Collection, type CollectionConfig, type CollectionConfigResponse, CollectionExistsError, CollectionNotFoundError, type CollectionSanityChecks, type CollectionSanityDiagnostics, type CollectionSanityResponse, type CollectionStatsResponse, type CollectionType, type ColumnStatsDetail, ColumnStoreError, type CompareOp, type Condition, ConfigError, ConnectionError, type CreateIndexOptions, DatabaseLockedError, type DeferredIndexerOptions, type DegreeResponse, DimensionMismatchError, type DistanceMetric, EdgeExistsError, EdgeNotFoundError, type EdgesResponse, type EpisodicEvent, EpochMismatchError, type ExplainCost, type ExplainFeatures, type ExplainPlanStep, type ExplainResponse, type Filter, type FilterInput, type FusionOptions, type FusionStrategy, type GetEdgesOptions, type GetNodeEdgesOptions, GpuError, type GraphCollectionConfig, type GraphEdge, GraphNotSupportedError, type GraphSchemaMode, type GraphSearchRequest, type GraphSearchResponse, type GraphSearchResultItem, GuardRailError, type GuardRailsConfigResponse, type GuardRailsUpdateRequest, type HnswParams, type IVelesDBBackend, IncompatibleSchemaVersionError, IndexCorruptedError, IndexError, type IndexInfo, type IndexType, InternalError, InvalidCollectionNameError, InvalidDimensionError, InvalidEdgeLabelError, InvalidQuantizerConfigError, InvalidVectorError, IoError, type JsonValue, type ListNodesResponse, type MatchQueryOptions, type MatchQueryResponse, type MatchQueryResultItem, type MultiQuerySearchOptions, type NearVectorOptions, NodeNotFoundError, type NodePayloadResponse, type NodeStats, NotFoundError, OverflowError, PointNotFoundError, type PqTrainOptions, type ProceduralPattern, type QueryApiResponse, QueryError, type QueryOptions, type QueryResponse, type QueryResult, type QueryStats, REST_CAPABILITIES, type RebuildIndexResponse, type RelDirection, type RelOptions, RestBackend, type RestPointId, SchemaValidationError, type ScrollRequest, type ScrollResponse, SearchNotSupportedError, type SearchOptions, type SearchQuality, type SearchQualityWire, type SearchResult, type SemanticEntry, SerializationError, SnapshotBuildFailedError, SparseIndexError, type SparseSearchNamedOptions, type SparseVector, StorageError, type StorageMode, type StreamUpsertResponse, TrainingFailedError, type TraversalResultItem, type TraversalStats, type TraverseParallelRequest, type TraverseRequest, type TraverseResponse, VELES_ERROR_CODES, ValidationError, type VectorDocument, VectorNotAllowedError, VectorRequiredError, VelesDB, type VelesDBConfig, VelesDBError, VelesError, type VelesErrorCode, VelesQLBuilder, WASM_CAPABILITIES, WasmBackend, f, isTypedFilter, normalizeFilter, parseVelesError, searchQualityToMode, velesql };
2071
+ /**
2072
+ * Optional embedding helpers for the VelesDB TypeScript SDK.
2073
+ *
2074
+ * A thin {@link Embedder} interface plus an adapter for OpenAI-compatible
2075
+ * endpoints. The adapter uses the global `fetch` API (Node ≥ 18, browsers,
2076
+ * Deno) and has no additional runtime dependencies.
2077
+ *
2078
+ * @example
2079
+ * ```typescript
2080
+ * import { VelesDB, OpenAIEmbedder } from '@wiscale/velesdb-sdk';
2081
+ *
2082
+ * const embedder = new OpenAIEmbedder({ apiKey: process.env.OPENAI_API_KEY! });
2083
+ * const db = new VelesDB({ backend: 'wasm' });
2084
+ * await db.init();
2085
+ * await db.createCollection('docs', { dimension: embedder.dimension ?? 1536 });
2086
+ * const vectors = await embedder.embed(['hello world', 'vector search']);
2087
+ * ```
2088
+ */
2089
+ interface Embedder {
2090
+ /** Embedding dimension, or `0` if not yet known (determined after first call). */
2091
+ readonly dimension: number;
2092
+ embed(texts: string[]): Promise<number[][]>;
2093
+ }
2094
+ interface OpenAIEmbedderOptions {
2095
+ model?: string;
2096
+ apiKey: string;
2097
+ /** Override the base URL for Azure OpenAI, vLLM, or any compatible endpoint. */
2098
+ baseUrl?: string;
2099
+ /** Request a specific output dimension (requires a model that supports it). */
2100
+ dimensions?: number;
2101
+ }
2102
+ declare class OpenAIEmbedder implements Embedder {
2103
+ private readonly model;
2104
+ private readonly apiKey;
2105
+ private readonly baseUrl;
2106
+ private readonly requestedDimensions;
2107
+ dimension: number;
2108
+ constructor(options: OpenAIEmbedderOptions);
2109
+ embed(texts: string[]): Promise<number[][]>;
2110
+ }
2111
+
2112
+ export { type ActualStats, type AddEdgeRequest, AgentMemoryClient, type AgentMemoryConfig, type AggregateQueryOptions, type AggregateResponse, type AggregationQueryResponse, AllocationFailedError, type AsyncIndexBuilderOptions, type BackendType, BackpressureError, type CapabilityMap, type Collection, type CollectionConfig, type CollectionConfigResponse, CollectionExistsError, CollectionNotFoundError, type CollectionSanityChecks, type CollectionSanityDiagnostics, type CollectionSanityResponse, type CollectionStatsResponse, type CollectionType, type ColumnStatsDetail, ColumnStoreError, type CompareOp, type Condition, ConfigError, ConnectionError, type CreateIndexOptions, DatabaseLockedError, type DeferredIndexerOptions, type DegreeResponse, DimensionMismatchError, type DistanceMetric, EdgeExistsError, EdgeNotFoundError, type EdgesResponse, type Embedder, type EpisodicEvent, EpochMismatchError, type ExplainCost, type ExplainFeatures, type ExplainPlanStep, type ExplainResponse, type Filter, type FilterInput, type FusionOptions, type FusionStrategy, type GetEdgesOptions, type GetNodeEdgesOptions, GpuError, type GraphCollectionConfig, type GraphEdge, type GraphNodeId, GraphNotSupportedError, type GraphSchemaMode, type GraphSearchRequest, type GraphSearchResponse, type GraphSearchResultItem, GuardRailError, type GuardRailsConfigResponse, type GuardRailsUpdateRequest, type HnswParams, type IVelesDBBackend, IncompatibleSchemaVersionError, IndexCorruptedError, IndexError, type IndexInfo, type IndexType, InternalError, InvalidCollectionNameError, InvalidDimensionError, InvalidEdgeLabelError, InvalidQuantizerConfigError, InvalidVectorError, IoError, type JsonValue, type ListNodesResponse, type MatchQueryOptions, type MatchQueryResponse, type MatchQueryResultItem, type MultiQuerySearchOptions, type NearVectorOptions, NodeNotFoundError, type NodePayloadResponse, type NodeStats, NotFoundError, OpenAIEmbedder, type OpenAIEmbedderOptions, OverflowError, PointNotFoundError, type PqTrainOptions, type ProceduralPattern, type QueryApiResponse, QueryError, type QueryOptions, type QueryResponse, type QueryResult, type QueryStats, REST_CAPABILITIES, type RebuildIndexResponse, type RelDirection, type RelOptions, RestBackend, type RestPointId, SchemaValidationError, type ScrollRequest, type ScrollResponse, SearchNotSupportedError, type SearchOptions, type SearchQuality, type SearchQualityWire, type SearchResult, type SemanticEntry, SerializationError, SnapshotBuildFailedError, SparseIndexError, type SparseSearchNamedOptions, type SparseVector, StorageError, type StorageMode, type StreamUpsertResponse, TrainingFailedError, type TraversalResultItem, type TraversalStats, type TraverseParallelRequest, type TraverseRequest, type TraverseResponse, VELES_ERROR_CODES, ValidationError, type VectorDocument, VectorNotAllowedError, VectorRequiredError, VelesDB, type VelesDBConfig, VelesDBError, VelesError, type VelesErrorCode, VelesQLBuilder, WASM_CAPABILITIES, WasmBackend, f, isTypedFilter, normalizeFilter, parseVelesError, searchQualityToMode, velesql };