@agentuity/core 0.0.48 → 0.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/services/_util.d.ts +2 -2
  2. package/dist/services/_util.d.ts.map +1 -1
  3. package/dist/services/_util.js +10 -10
  4. package/dist/services/_util.js.map +1 -1
  5. package/dist/services/adapter.d.ts +1 -1
  6. package/dist/services/adapter.d.ts.map +1 -1
  7. package/dist/services/evalrun.d.ts +40 -5
  8. package/dist/services/evalrun.d.ts.map +1 -1
  9. package/dist/services/exception.d.ts +2 -1
  10. package/dist/services/exception.d.ts.map +1 -1
  11. package/dist/services/exception.js +3 -1
  12. package/dist/services/exception.js.map +1 -1
  13. package/dist/services/keyvalue.d.ts +72 -0
  14. package/dist/services/keyvalue.d.ts.map +1 -1
  15. package/dist/services/keyvalue.js +103 -3
  16. package/dist/services/keyvalue.js.map +1 -1
  17. package/dist/services/objectstore.d.ts +100 -0
  18. package/dist/services/objectstore.d.ts.map +1 -1
  19. package/dist/services/objectstore.js +169 -4
  20. package/dist/services/objectstore.js.map +1 -1
  21. package/dist/services/session.d.ts +43 -5
  22. package/dist/services/session.d.ts.map +1 -1
  23. package/dist/services/stream.d.ts +60 -8
  24. package/dist/services/stream.d.ts.map +1 -1
  25. package/dist/services/stream.js +3 -3
  26. package/dist/services/stream.js.map +1 -1
  27. package/dist/services/vector.d.ts +103 -22
  28. package/dist/services/vector.d.ts.map +1 -1
  29. package/dist/services/vector.js +4 -4
  30. package/dist/services/vector.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/services/_util.ts +15 -9
  33. package/src/services/adapter.ts +1 -1
  34. package/src/services/evalrun.ts +40 -5
  35. package/src/services/exception.ts +3 -1
  36. package/src/services/keyvalue.ts +193 -3
  37. package/src/services/objectstore.ts +319 -4
  38. package/src/services/session.ts +43 -5
  39. package/src/services/stream.ts +63 -11
  40. package/src/services/vector.ts +107 -26
@@ -184,24 +184,58 @@ export type VectorResult<T extends Record<string, unknown> = Record<string, unkn
184
184
  | VectorResultNotFound;
185
185
 
186
186
  /**
187
- * Vector storage service for managing vector embeddings
187
+ * Vector storage service for managing vector embeddings and semantic search
188
188
  */
189
189
  export interface VectorStorage {
190
190
  /**
191
- * upsert a vector into the vector storage
191
+ * Upsert vectors into the vector storage. You can provide either pre-computed embeddings
192
+ * or text documents that will be automatically embedded.
192
193
  *
193
- * @param name - the name of the vector storage
194
- * @param documents - the documents for the vector upsert
194
+ * @param name - the name of the vector storage namespace
195
+ * @param documents - one or more documents to upsert
195
196
  * @returns array of results with key-to-id mappings for the upserted vectors
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * // Upsert with automatic embedding
201
+ * const results = await vectorStore.upsert('products',
202
+ * {
203
+ * key: 'chair-001',
204
+ * document: 'Comfortable office chair with lumbar support',
205
+ * metadata: { category: 'furniture', price: 299 }
206
+ * },
207
+ * {
208
+ * key: 'desk-001',
209
+ * document: 'Standing desk with adjustable height',
210
+ * metadata: { category: 'furniture', price: 599 }
211
+ * }
212
+ * );
213
+ *
214
+ * // Upsert with pre-computed embeddings
215
+ * await vectorStore.upsert('products', {
216
+ * key: 'lamp-001',
217
+ * embeddings: [0.1, 0.2, 0.3, ...], // Your pre-computed vector
218
+ * metadata: { category: 'lighting', price: 49 }
219
+ * });
220
+ * ```
196
221
  */
197
222
  upsert(name: string, ...documents: VectorUpsertParams[]): Promise<VectorUpsertResult[]>;
198
223
 
199
224
  /**
200
- * get a vector from the vector storage by key
225
+ * Get a single vector by its key
201
226
  *
202
- * @param name - the name of the vector storage
203
- * @param key - the key of the vector to get
227
+ * @param name - the name of the vector storage namespace
228
+ * @param key - the key of the vector to retrieve
204
229
  * @returns VectorResult with exists field for type-safe checking
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * const result = await vectorStore.get('products', 'chair-001');
234
+ * if (result.exists) {
235
+ * console.log('Found:', result.data.metadata);
236
+ * console.log('Embeddings:', result.data.embeddings);
237
+ * }
238
+ * ```
205
239
  */
206
240
  get<T extends Record<string, unknown> = Record<string, unknown>>(
207
241
  name: string,
@@ -209,11 +243,19 @@ export interface VectorStorage {
209
243
  ): Promise<VectorResult<T>>;
210
244
 
211
245
  /**
212
- * get multiple vectors from the vector storage by keys
246
+ * Get multiple vectors by their keys in a single request
213
247
  *
214
- * @param name - the name of the vector storage
215
- * @param keys - the keys of the vectors to get
216
- * @returns a Map of key to vector data for found vectors
248
+ * @param name - the name of the vector storage namespace
249
+ * @param keys - the keys of the vectors to retrieve
250
+ * @returns a Map of key to vector data (only includes found vectors)
251
+ *
252
+ * @example
253
+ * ```typescript
254
+ * const vectors = await vectorStore.getMany('products', 'chair-001', 'desk-001', 'lamp-001');
255
+ * for (const [key, data] of vectors) {
256
+ * console.log(`${key}:`, data.metadata);
257
+ * }
258
+ * ```
217
259
  */
218
260
  getMany<T extends Record<string, unknown> = Record<string, unknown>>(
219
261
  name: string,
@@ -221,11 +263,33 @@ export interface VectorStorage {
221
263
  ): Promise<Map<string, VectorSearchResultWithDocument<T>>>;
222
264
 
223
265
  /**
224
- * search for vectors in the vector storage
266
+ * Search for semantically similar vectors using natural language queries
267
+ *
268
+ * @param name - the name of the vector storage namespace
269
+ * @param params - search parameters including query, filters, and limits
270
+ * @returns array of search results ordered by similarity (highest first)
225
271
  *
226
- * @param name - the name of the vector storage
227
- * @param params - the parameters for the vector search
228
- * @returns the results of the vector search with type-safe metadata
272
+ * @example
273
+ * ```typescript
274
+ * // Basic semantic search
275
+ * const results = await vectorStore.search('products', {
276
+ * query: 'comfortable seating for office',
277
+ * limit: 5
278
+ * });
279
+ *
280
+ * // Search with metadata filters and similarity threshold
281
+ * const filteredResults = await vectorStore.search('products', {
282
+ * query: 'ergonomic furniture',
283
+ * limit: 10,
284
+ * similarity: 0.7, // Only results with 70%+ similarity
285
+ * metadata: { category: 'furniture', inStock: true }
286
+ * });
287
+ *
288
+ * for (const result of filteredResults) {
289
+ * console.log(`${result.key}: ${result.similarity * 100}% match`);
290
+ * console.log('Metadata:', result.metadata);
291
+ * }
292
+ * ```
229
293
  */
230
294
  search<T extends Record<string, unknown> = Record<string, unknown>>(
231
295
  name: string,
@@ -233,19 +297,36 @@ export interface VectorStorage {
233
297
  ): Promise<VectorSearchResult<T>[]>;
234
298
 
235
299
  /**
236
- * delete vectors from the vector storage
300
+ * Delete one or more vectors by their keys
301
+ *
302
+ * @param name - the name of the vector storage namespace
303
+ * @param keys - one or more keys of vectors to delete
304
+ * @returns the number of vectors that were deleted
237
305
  *
238
- * @param name - the name of the vector storage
239
- * @param keys - the keys of the vectors to delete
240
- * @returns the number of vector objects that were deleted
306
+ * @example
307
+ * ```typescript
308
+ * // Delete a single vector
309
+ * const deleted = await vectorStore.delete('products', 'chair-001');
310
+ * console.log(`Deleted ${deleted} vector(s)`);
311
+ *
312
+ * // Delete multiple vectors
313
+ * await vectorStore.delete('products', 'chair-001', 'desk-001', 'lamp-001');
314
+ * ```
241
315
  */
242
316
  delete(name: string, ...keys: string[]): Promise<number>;
243
317
 
244
318
  /**
245
- * check if a vector storage exists
319
+ * Check if a vector storage namespace exists
320
+ *
321
+ * @param name - the name of the vector storage namespace
322
+ * @returns true if the namespace exists, false otherwise
246
323
  *
247
- * @param name - the name of the vector storage
248
- * @returns true if the storage exists, false otherwise
324
+ * @example
325
+ * ```typescript
326
+ * if (await vectorStore.exists('products')) {
327
+ * console.log('Products namespace exists');
328
+ * }
329
+ * ```
249
330
  */
250
331
  exists(name: string): Promise<boolean>;
251
332
  }
@@ -367,7 +448,7 @@ export class VectorStorageService implements VectorStorage {
367
448
  }
368
449
  }
369
450
 
370
- throw await toServiceException(url, res.response);
451
+ throw await toServiceException(url, 'PUT', res.response);
371
452
  }
372
453
 
373
454
  async get<T extends Record<string, unknown> = Record<string, unknown>>(
@@ -416,7 +497,7 @@ export class VectorStorageService implements VectorStorage {
416
497
  }
417
498
  }
418
499
 
419
- throw await toServiceException(url, res.response);
500
+ throw await toServiceException(url, 'DELETE', res.response);
420
501
  }
421
502
 
422
503
  async getMany<T extends Record<string, unknown> = Record<string, unknown>>(
@@ -521,7 +602,7 @@ export class VectorStorageService implements VectorStorage {
521
602
  }
522
603
  }
523
604
 
524
- throw await toServiceException(url, res.response);
605
+ throw await toServiceException(url, 'POST', res.response);
525
606
  }
526
607
 
527
608
  async delete(name: string, ...keys: string[]): Promise<number> {
@@ -575,7 +656,7 @@ export class VectorStorageService implements VectorStorage {
575
656
  }
576
657
  }
577
658
 
578
- throw await toServiceException(url, res.response);
659
+ throw await toServiceException(url, 'DELETE', res.response);
579
660
  }
580
661
 
581
662
  async exists(name: string): Promise<boolean> {