@agentuity/core 0.1.16 → 0.1.18

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.
@@ -260,6 +260,46 @@ export interface VectorNamespaceStatsWithSamples extends VectorNamespaceStats {
260
260
  sampledResults?: Record<string, VectorItemStats>;
261
261
  }
262
262
 
263
+ /**
264
+ * Parameters for getting all namespace statistics with optional pagination
265
+ */
266
+ export interface VectorGetAllStatsParams {
267
+ /**
268
+ * Maximum number of namespaces to return (default: 100, max: 1000)
269
+ */
270
+ limit?: number;
271
+ /**
272
+ * Number of namespaces to skip for pagination (default: 0)
273
+ */
274
+ offset?: number;
275
+ }
276
+
277
+ /**
278
+ * Paginated response for vector namespace statistics
279
+ */
280
+ export interface VectorStatsPaginated {
281
+ /**
282
+ * Map of namespace names to their statistics
283
+ */
284
+ namespaces: Record<string, VectorNamespaceStats>;
285
+ /**
286
+ * Total number of namespaces across all pages
287
+ */
288
+ total: number;
289
+ /**
290
+ * Number of namespaces requested per page
291
+ */
292
+ limit: number;
293
+ /**
294
+ * Number of namespaces skipped
295
+ */
296
+ offset: number;
297
+ /**
298
+ * Whether there are more namespaces available
299
+ */
300
+ hasMore: boolean;
301
+ }
302
+
263
303
  /**
264
304
  * Vector storage service for managing vector embeddings and semantic search
265
305
  */
@@ -427,24 +467,27 @@ export interface VectorStorage {
427
467
  getStats(name: string): Promise<VectorNamespaceStatsWithSamples>;
428
468
 
429
469
  /**
430
- * Get statistics for all namespaces in the organization
470
+ * get statistics for all namespaces with optional pagination
431
471
  *
432
- * @returns map of namespace names to their statistics
472
+ * @param params - optional pagination parameters (limit, offset)
473
+ * @returns map of namespace names to statistics, or paginated response if params provided
433
474
  *
434
- * @example
435
- * ```typescript
436
- * const allStats = await vectorStore.getAllStats();
437
- * for (const [name, stats] of Object.entries(allStats)) {
438
- * console.log(`${name}: ${stats.count} vectors, ${stats.sum} bytes`);
439
- * }
440
- * ```
475
+ * @remarks
476
+ * - Without params: returns flat map of all namespaces (backward compatible)
477
+ * - With params: returns paginated response with total count and hasMore flag
478
+ * - Default limit is 100, maximum is 1000
441
479
  */
442
- getAllStats(): Promise<Record<string, VectorNamespaceStats>>;
480
+ getAllStats(params?: VectorGetAllStatsParams): Promise<Record<string, VectorNamespaceStats> | VectorStatsPaginated>;
443
481
 
444
482
  /**
445
483
  * Get all namespace names
446
484
  *
447
- * @returns array of namespace names
485
+ * @returns array of namespace names (up to 1000)
486
+ *
487
+ * @remarks
488
+ * This method returns a maximum of 1000 namespace names.
489
+ * If you have more than 1000 namespaces, only the first 1000
490
+ * (ordered by creation date, most recent first) will be returned.
448
491
  *
449
492
  * @example
450
493
  * ```typescript
@@ -518,8 +561,6 @@ type VectorDeleteResponse = VectorDeleteSuccessResponse | VectorDeleteErrorRespo
518
561
 
519
562
  type VectorStatsResponse = VectorNamespaceStatsWithSamples;
520
563
 
521
- type VectorAllStatsResponse = Record<string, VectorNamespaceStats>;
522
-
523
564
  interface VectorDeleteNamespaceSuccessResponse {
524
565
  success: true;
525
566
  data: number;
@@ -926,11 +967,19 @@ export class VectorStorageService implements VectorStorage {
926
967
  throw await toServiceException('GET', url, res.response);
927
968
  }
928
969
 
929
- async getAllStats(): Promise<Record<string, VectorNamespaceStats>> {
930
- const url = buildUrl(this.#baseUrl, '/vector/2025-03-17/stats');
970
+ async getAllStats(params?: VectorGetAllStatsParams): Promise<Record<string, VectorNamespaceStats> | VectorStatsPaginated> {
971
+ const queryParams = new URLSearchParams();
972
+ if (params?.limit !== undefined) {
973
+ queryParams.set('limit', String(params.limit));
974
+ }
975
+ if (params?.offset !== undefined) {
976
+ queryParams.set('offset', String(params.offset));
977
+ }
978
+ const queryString = queryParams.toString();
979
+ const url = buildUrl(this.#baseUrl, `/vector/2025-03-17/stats${queryString ? `?${queryString}` : ''}`);
931
980
  const signal = AbortSignal.timeout(10_000);
932
981
 
933
- const res = await this.#adapter.invoke<VectorAllStatsResponse>(url, {
982
+ const res = await this.#adapter.invoke<Record<string, VectorNamespaceStats> | VectorStatsPaginated>(url, {
934
983
  method: 'GET',
935
984
  signal,
936
985
  telemetry: {
@@ -947,8 +996,20 @@ export class VectorStorageService implements VectorStorage {
947
996
  }
948
997
 
949
998
  async getNamespaces(): Promise<string[]> {
950
- const stats = await this.getAllStats();
951
- return Object.keys(stats);
999
+ const url = buildUrl(this.#baseUrl, '/vector/2025-03-17/namespaces');
1000
+ const signal = AbortSignal.timeout(10_000);
1001
+ const res = await this.#adapter.invoke<string[]>(url, {
1002
+ method: 'GET',
1003
+ signal,
1004
+ telemetry: {
1005
+ name: 'agentuity.vector.getNamespaces',
1006
+ attributes: {},
1007
+ },
1008
+ });
1009
+ if (res.ok) {
1010
+ return res.data;
1011
+ }
1012
+ throw await toServiceException('GET', url, res.response);
952
1013
  }
953
1014
 
954
1015
  async deleteNamespace(name: string): Promise<void> {