@dakera-ai/dakera 0.11.54 → 0.11.56

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.js CHANGED
@@ -136,6 +136,12 @@ function parseErrorCode(raw) {
136
136
  }
137
137
  return "UNKNOWN" /* UNKNOWN */;
138
138
  }
139
+ function flattenRecalledMemory(item) {
140
+ if (item && typeof item === "object" && item.memory && typeof item.memory === "object") {
141
+ return { ...item.memory, score: item.score, depth: item.depth };
142
+ }
143
+ return item;
144
+ }
139
145
  var DEFAULT_TIMEOUT = 3e4;
140
146
  var DEFAULT_MAX_RETRIES = 3;
141
147
  var DEFAULT_BASE_DELAY = 100;
@@ -393,7 +399,33 @@ var DakeraClient = class {
393
399
  if (options.ids) body.ids = options.ids;
394
400
  if (options.filter) body.filter = options.filter;
395
401
  if (options.deleteAll) body.delete_all = true;
396
- return this.request("POST", `/v1/namespaces/${namespace}/delete`, body);
402
+ return this.request("POST", `/v1/namespaces/${namespace}/vectors/delete`, body);
403
+ }
404
+ /** Bulk update vector metadata matching a filter. */
405
+ async bulkUpdateVectors(namespace, filter, update) {
406
+ return this.request(
407
+ "POST",
408
+ `/v1/namespaces/${encodeURIComponent(namespace)}/vectors/bulk-update`,
409
+ { filter, update }
410
+ );
411
+ }
412
+ /** Bulk delete vectors matching a filter. */
413
+ async bulkDeleteVectors(namespace, filter) {
414
+ return this.request(
415
+ "POST",
416
+ `/v1/namespaces/${encodeURIComponent(namespace)}/vectors/bulk-delete`,
417
+ { filter }
418
+ );
419
+ }
420
+ /** Count vectors in a namespace, optionally filtered. */
421
+ async countVectors(namespace, filter) {
422
+ const body = {};
423
+ if (filter) body.filter = filter;
424
+ return this.request(
425
+ "POST",
426
+ `/v1/namespaces/${encodeURIComponent(namespace)}/vectors/count`,
427
+ body
428
+ );
397
429
  }
398
430
  /**
399
431
  * Fetch vectors by ID.
@@ -505,11 +537,11 @@ var DakeraClient = class {
505
537
  *
506
538
  * When `vector` is omitted the server falls back to BM25-only full-text
507
539
  * search. When provided, results are blended with vector similarity
508
- * according to `alpha`.
540
+ * according to `vectorWeight`.
509
541
  *
510
542
  * @param namespace - Target namespace
511
543
  * @param query - Text query
512
- * @param options - Search options: vector (optional), topK, alpha, filter
544
+ * @param options - Search options: vector (optional), topK, vectorWeight, filter
513
545
  * @returns Hybrid search results
514
546
  *
515
547
  * @example
@@ -518,7 +550,7 @@ var DakeraClient = class {
518
550
  * const results = await client.hybridSearch('my-namespace', 'machine learning', {
519
551
  * vector: [0.1, 0.2, 0.3],
520
552
  * topK: 10,
521
- * alpha: 0.7, // 70% text, 30% vector
553
+ * vectorWeight: 0.7, // 70% vector, 30% text
522
554
  * });
523
555
  * // BM25-only (no vector)
524
556
  * const results = await client.hybridSearch('my-namespace', 'machine learning');
@@ -526,9 +558,9 @@ var DakeraClient = class {
526
558
  */
527
559
  async hybridSearch(namespace, query, options = {}) {
528
560
  const body = {
529
- query,
561
+ text: query,
530
562
  top_k: options.topK ?? 10,
531
- alpha: options.alpha ?? 0.5
563
+ vector_weight: options.vectorWeight ?? 0.5
532
564
  };
533
565
  if (options.vector != null) {
534
566
  body["vector"] = options.vector;
@@ -556,7 +588,7 @@ var DakeraClient = class {
556
588
  "GET",
557
589
  "/v1/namespaces"
558
590
  );
559
- return response.namespaces;
591
+ return response.namespaces.map((ns) => ({ namespace: ns, vector_count: 0 }));
560
592
  }
561
593
  /**
562
594
  * Get namespace information.
@@ -575,11 +607,16 @@ var DakeraClient = class {
575
607
  * @returns Created namespace info
576
608
  */
577
609
  async createNamespace(namespace, options = {}) {
578
- const body = { name: namespace };
579
- if (options.dimensions) body.dimensions = options.dimensions;
610
+ const body = {};
611
+ if (options.dimensions) body.dimension = options.dimensions;
580
612
  if (options.indexType) body.index_type = options.indexType;
581
613
  if (options.metadata) body.metadata = options.metadata;
582
- return this.request("POST", "/v1/namespaces", body);
614
+ const response = await this.request(
615
+ "PUT",
616
+ `/v1/namespaces/${namespace}`,
617
+ body
618
+ );
619
+ return { namespace: response.namespace, vector_count: 0, dimension: response.dimension };
583
620
  }
584
621
  /**
585
622
  * Create or update a namespace configuration (upsert semantics).
@@ -613,6 +650,14 @@ var DakeraClient = class {
613
650
  async health() {
614
651
  return this.request("GET", "/health");
615
652
  }
653
+ /** K8s readiness probe — checks storage and dependencies. */
654
+ async healthReady() {
655
+ return this.request("GET", "/health/ready");
656
+ }
657
+ /** K8s liveness probe — checks process is alive. */
658
+ async healthLive() {
659
+ return this.request("GET", "/health/live");
660
+ }
616
661
  /**
617
662
  * Get index statistics for a namespace.
618
663
  *
@@ -1064,7 +1109,7 @@ var DakeraClient = class {
1064
1109
  // ===========================================================================
1065
1110
  /** Store a memory for an agent */
1066
1111
  async storeMemory(agentId2, request) {
1067
- return this.request("POST", `/v1/agents/${agentId2}/memories`, request);
1112
+ return this.request("POST", "/v1/memory/store", { ...request, agent_id: agentId2 });
1068
1113
  }
1069
1114
  /**
1070
1115
  * Recall memories for an agent.
@@ -1097,19 +1142,23 @@ var DakeraClient = class {
1097
1142
  if (options?.until !== void 0) body["until"] = options.until;
1098
1143
  if (options?.routing !== void 0) body["routing"] = options.routing;
1099
1144
  if (options?.rerank !== void 0) body["rerank"] = options.rerank;
1100
- return this.request("POST", `/v1/agents/${agentId2}/memories/recall`, body);
1145
+ const raw = await this.request("POST", "/v1/memory/recall", { ...body, agent_id: agentId2 });
1146
+ return {
1147
+ memories: (raw.memories ?? []).map(flattenRecalledMemory),
1148
+ ...raw.associated_memories ? { associated_memories: raw.associated_memories.map(flattenRecalledMemory) } : {}
1149
+ };
1101
1150
  }
1102
1151
  /** Get a specific memory */
1103
1152
  async getMemory(agentId2, memoryId2) {
1104
- return this.request("GET", `/v1/agents/${agentId2}/memories/${memoryId2}`);
1153
+ return this.request("GET", `/v1/memory/get/${memoryId2}?agent_id=${encodeURIComponent(agentId2)}`);
1105
1154
  }
1106
1155
  /** Update an existing memory */
1107
- async updateMemory(agentId2, memoryId2, request) {
1108
- return this.request("PUT", `/v1/agents/${agentId2}/memories/${memoryId2}`, request);
1156
+ async updateMemory(_agentId, memoryId2, request) {
1157
+ return this.request("PUT", `/v1/memory/update/${memoryId2}`, request);
1109
1158
  }
1110
1159
  /** Delete a memory */
1111
1160
  async forget(agentId2, memoryId2) {
1112
- return this.request("DELETE", `/v1/agents/${agentId2}/memories/${memoryId2}`);
1161
+ return this.request("POST", "/v1/memory/forget", { agent_id: agentId2, memory_ids: [memoryId2] });
1113
1162
  }
1114
1163
  /**
1115
1164
  * Bulk-recall memories using filter predicates (CE-2).
@@ -1155,20 +1204,45 @@ var DakeraClient = class {
1155
1204
  if (options?.min_importance !== void 0) body["min_importance"] = options.min_importance;
1156
1205
  if (options?.routing !== void 0) body["routing"] = options.routing;
1157
1206
  if (options?.rerank !== void 0) body["rerank"] = options.rerank;
1158
- const result = await this.request("POST", `/v1/agents/${agentId2}/memories/search`, body);
1159
- return result.memories ?? result;
1207
+ const result = await this.request("POST", "/v1/memory/search", { ...body, agent_id: agentId2 });
1208
+ const items = result.memories ?? result;
1209
+ return (Array.isArray(items) ? items : []).map(flattenRecalledMemory);
1160
1210
  }
1161
1211
  /** Update importance of memories */
1162
1212
  async updateImportance(agentId2, request) {
1163
- return this.request("PUT", `/v1/agents/${agentId2}/memories/importance`, request);
1213
+ let result = { status: "ok" };
1214
+ for (const memoryId2 of request.memory_ids) {
1215
+ result = await this.request("POST", "/v1/memory/importance", {
1216
+ agent_id: agentId2,
1217
+ memory_id: memoryId2,
1218
+ importance: request.importance
1219
+ });
1220
+ }
1221
+ return result;
1164
1222
  }
1165
1223
  /** Consolidate memories for an agent */
1166
1224
  async consolidate(agentId2, request) {
1167
- return this.request("POST", `/v1/agents/${agentId2}/memories/consolidate`, request ?? {});
1225
+ return this.request("POST", "/v1/memory/consolidate", { ...request ?? {}, agent_id: agentId2 });
1226
+ }
1227
+ /** Consolidate memories directly for an agent (DBSCAN clustering). */
1228
+ async consolidateAgent(agentId2) {
1229
+ return this.request("POST", `/v1/agents/${encodeURIComponent(agentId2)}/consolidate`);
1230
+ }
1231
+ /** Get the consolidation execution log for an agent. */
1232
+ async getConsolidationLog(agentId2) {
1233
+ return this.request("GET", `/v1/agents/${encodeURIComponent(agentId2)}/consolidation/log`);
1234
+ }
1235
+ /** Update the consolidation configuration for an agent. */
1236
+ async patchConsolidationConfig(agentId2, config) {
1237
+ return this.request(
1238
+ "PATCH",
1239
+ `/v1/agents/${encodeURIComponent(agentId2)}/consolidation/config`,
1240
+ config
1241
+ );
1168
1242
  }
1169
1243
  /** Submit feedback on a memory recall */
1170
1244
  async memoryFeedback(agentId2, request) {
1171
- return this.request("POST", `/v1/agents/${agentId2}/memories/feedback`, request);
1245
+ return this.request("POST", "/v1/memory/feedback", { ...request, agent_id: agentId2 });
1172
1246
  }
1173
1247
  // ===========================================================================
1174
1248
  // Memory Feedback Loop — INT-1
@@ -1288,6 +1362,14 @@ var DakeraClient = class {
1288
1362
  // =========================================================================
1289
1363
  // Entity Extraction Operations (CE-4)
1290
1364
  // =========================================================================
1365
+ /** Get entity extraction configuration for a namespace. */
1366
+ async getNamespaceEntityConfig(namespace) {
1367
+ return this.request("GET", `/v1/namespaces/${encodeURIComponent(namespace)}/config`);
1368
+ }
1369
+ /** Get the extractor provider configuration for a namespace. */
1370
+ async getNamespaceExtractor(namespace) {
1371
+ return this.request("GET", `/v1/namespaces/${encodeURIComponent(namespace)}/extractor`);
1372
+ }
1291
1373
  /**
1292
1374
  * Configure entity extraction for a namespace.
1293
1375
  *
@@ -1314,7 +1396,7 @@ var DakeraClient = class {
1314
1396
  * @note Requires CE-4 (GLiNER) on the server.
1315
1397
  */
1316
1398
  async extractEntities(text, entityTypes) {
1317
- const body = { text };
1399
+ const body = { content: text };
1318
1400
  if (entityTypes !== void 0) {
1319
1401
  body["entity_types"] = entityTypes;
1320
1402
  }
@@ -1341,7 +1423,7 @@ var DakeraClient = class {
1341
1423
  }
1342
1424
  /** End a session. Returns the session state and total memory count at close. */
1343
1425
  async endSession(sessionId2) {
1344
- return this.request("POST", `/v1/sessions/${sessionId2}/end`);
1426
+ return this.request("POST", `/v1/sessions/${sessionId2}/end`, {});
1345
1427
  }
1346
1428
  /** Get session details */
1347
1429
  async getSession(sessionId2) {
@@ -2243,6 +2325,226 @@ var DakeraClient = class {
2243
2325
  const body = namespace ? { namespace } : {};
2244
2326
  return this.request("POST", "/admin/fulltext/reindex", body);
2245
2327
  }
2328
+ // ---------------------------------------------------------------------------
2329
+ // Admin — Cluster & Maintenance
2330
+ // ---------------------------------------------------------------------------
2331
+ /** GET /admin/cluster/replication — cluster replication status. */
2332
+ async adminClusterReplication() {
2333
+ return this.request("GET", "/admin/cluster/replication");
2334
+ }
2335
+ /** GET /admin/cluster/shards — list shards. */
2336
+ async adminListShards() {
2337
+ return this.request("GET", "/admin/cluster/shards");
2338
+ }
2339
+ /** POST /admin/cluster/shards/rebalance — rebalance shards. */
2340
+ async adminRebalanceShards(request) {
2341
+ return this.request("POST", "/admin/cluster/shards/rebalance", request ?? {});
2342
+ }
2343
+ /** GET /admin/cluster/maintenance — maintenance mode status. */
2344
+ async adminMaintenanceStatus() {
2345
+ return this.request("GET", "/admin/cluster/maintenance");
2346
+ }
2347
+ /** POST /admin/cluster/maintenance/enable — enable maintenance mode. */
2348
+ async adminEnableMaintenance(request) {
2349
+ return this.request("POST", "/admin/cluster/maintenance/enable", request);
2350
+ }
2351
+ /** POST /admin/cluster/maintenance/disable — disable maintenance mode. */
2352
+ async adminDisableMaintenance(request) {
2353
+ return this.request("POST", "/admin/cluster/maintenance/disable", request ?? {});
2354
+ }
2355
+ // ---------------------------------------------------------------------------
2356
+ // Admin — Quotas
2357
+ // ---------------------------------------------------------------------------
2358
+ /** GET /admin/quotas — list all namespace quotas. */
2359
+ async adminListQuotas() {
2360
+ return this.request("GET", "/admin/quotas");
2361
+ }
2362
+ /** GET /admin/quotas/default — get default quota configuration. */
2363
+ async adminGetDefaultQuota() {
2364
+ return this.request("GET", "/admin/quotas/default");
2365
+ }
2366
+ /** PUT /admin/quotas/default — set default quota configuration. */
2367
+ async adminSetDefaultQuota(request) {
2368
+ return this.request("PUT", "/admin/quotas/default", request);
2369
+ }
2370
+ /** GET /admin/quotas/{namespace} — get namespace quota. */
2371
+ async adminGetQuota(namespace) {
2372
+ return this.request("GET", `/admin/quotas/${namespace}`);
2373
+ }
2374
+ /** PUT /admin/quotas/{namespace} — set namespace quota. */
2375
+ async adminSetQuota(namespace, request) {
2376
+ return this.request("PUT", `/admin/quotas/${namespace}`, request);
2377
+ }
2378
+ /** DELETE /admin/quotas/{namespace} — remove namespace quota. */
2379
+ async adminDeleteQuota(namespace) {
2380
+ return this.request("DELETE", `/admin/quotas/${namespace}`);
2381
+ }
2382
+ /** POST /admin/quotas/{namespace}/check — check if operation would exceed quota. */
2383
+ async adminCheckQuota(namespace, request) {
2384
+ return this.request("POST", `/admin/quotas/${namespace}/check`, request);
2385
+ }
2386
+ // ---------------------------------------------------------------------------
2387
+ // Admin — Slow Queries
2388
+ // ---------------------------------------------------------------------------
2389
+ /** GET /admin/slow-queries — list recent slow queries. */
2390
+ async adminListSlowQueries(params) {
2391
+ const qs = params ? new URLSearchParams(Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)])).toString() : "";
2392
+ const path = qs ? `/admin/slow-queries?${qs}` : "/admin/slow-queries";
2393
+ return this.request("GET", path);
2394
+ }
2395
+ /** GET /admin/slow-queries/summary — slow query summary. */
2396
+ async adminSlowQuerySummary() {
2397
+ return this.request("GET", "/admin/slow-queries/summary");
2398
+ }
2399
+ /** DELETE /admin/slow-queries — clear slow query log. */
2400
+ async adminClearSlowQueries(namespace) {
2401
+ const path = namespace ? `/admin/slow-queries?namespace=${encodeURIComponent(namespace)}` : "/admin/slow-queries";
2402
+ return this.request("DELETE", path);
2403
+ }
2404
+ /** PATCH /admin/slow-queries/config — update slow query configuration. */
2405
+ async adminUpdateSlowQueryConfig(config) {
2406
+ return this.request("PATCH", "/admin/slow-queries/config", config);
2407
+ }
2408
+ // ---------------------------------------------------------------------------
2409
+ // Admin — Backups
2410
+ // ---------------------------------------------------------------------------
2411
+ /** GET /admin/backups — list all backups. */
2412
+ async adminListBackups() {
2413
+ return this.request("GET", "/admin/backups");
2414
+ }
2415
+ /** POST /admin/backups — create a new backup. */
2416
+ async adminCreateBackup(request) {
2417
+ return this.request("POST", "/admin/backups", request);
2418
+ }
2419
+ /** GET /admin/backups/{id} — get backup details. */
2420
+ async adminGetBackup(backupId) {
2421
+ return this.request("GET", `/admin/backups/${backupId}`);
2422
+ }
2423
+ /** DELETE /admin/backups/{id} — delete a backup. */
2424
+ async adminDeleteBackup(backupId) {
2425
+ return this.request("DELETE", `/admin/backups/${backupId}`);
2426
+ }
2427
+ /** GET /admin/backups/schedule — get backup schedule. */
2428
+ async adminGetBackupSchedule() {
2429
+ return this.request("GET", "/admin/backups/schedule");
2430
+ }
2431
+ /** POST /admin/backups/schedule — update backup schedule. */
2432
+ async adminUpdateBackupSchedule(request) {
2433
+ return this.request("POST", "/admin/backups/schedule", request);
2434
+ }
2435
+ /** POST /admin/backups/restore — restore from backup. */
2436
+ async adminRestoreBackup(request) {
2437
+ return this.request("POST", "/admin/backups/restore", request);
2438
+ }
2439
+ /** GET /admin/backups/restore/{id} — restore operation status. */
2440
+ async adminGetRestoreStatus(restoreId) {
2441
+ return this.request("GET", `/admin/backups/restore/${restoreId}`);
2442
+ }
2443
+ // ---------------------------------------------------------------------------
2444
+ // Ops — Diagnostics & Jobs
2445
+ // ---------------------------------------------------------------------------
2446
+ /** GET /ops/diagnostics — system diagnostics. */
2447
+ async opsDiagnostics() {
2448
+ return this.request("GET", "/ops/diagnostics");
2449
+ }
2450
+ /** GET /ops/jobs — list background jobs. */
2451
+ async opsListJobs() {
2452
+ return this.request("GET", "/ops/jobs");
2453
+ }
2454
+ /** GET /ops/jobs/{id} — get job status. */
2455
+ async opsGetJob(jobId) {
2456
+ return this.request("GET", `/ops/jobs/${jobId}`);
2457
+ }
2458
+ /** POST /ops/compact — trigger compaction. */
2459
+ async opsCompact(request) {
2460
+ return this.request("POST", "/ops/compact", request ?? {});
2461
+ }
2462
+ /** POST /ops/shutdown — request graceful shutdown. */
2463
+ async opsShutdown() {
2464
+ return this.request("POST", "/ops/shutdown");
2465
+ }
2466
+ // ────────────────────────────────────────────────────────────
2467
+ // Phase 3 — Engine Parity
2468
+ // ────────────────────────────────────────────────────────────
2469
+ /** GET /v1/namespaces/{namespace}/fulltext/stats — full-text index statistics. */
2470
+ async fulltextStats(namespace) {
2471
+ return this.request(
2472
+ "GET",
2473
+ `/v1/namespaces/${encodeURIComponent(namespace)}/fulltext/stats`
2474
+ );
2475
+ }
2476
+ /** POST /v1/namespaces/{namespace}/fulltext/delete — delete documents from full-text index. */
2477
+ async fulltextDelete(namespace, ids) {
2478
+ return this.request(
2479
+ "POST",
2480
+ `/v1/namespaces/${encodeURIComponent(namespace)}/fulltext/delete`,
2481
+ { ids }
2482
+ );
2483
+ }
2484
+ /** GET /admin/ttl/stats — TTL statistics across all namespaces. */
2485
+ async adminTtlStats() {
2486
+ return this.request("GET", "/admin/ttl/stats");
2487
+ }
2488
+ /** POST /v1/route — route a query to the best-matching namespace(s). */
2489
+ async routeQuery(request) {
2490
+ return this.request("POST", "/v1/route", request);
2491
+ }
2492
+ /** GET /v1/import/{job_id}/status — check import job progress. */
2493
+ async importJobStatus(jobId) {
2494
+ return this.request(
2495
+ "GET",
2496
+ `/v1/import/${encodeURIComponent(jobId)}/status`
2497
+ );
2498
+ }
2499
+ /** GET /admin/backups/{id}/download — download a backup as binary data. */
2500
+ async adminDownloadBackup(backupId) {
2501
+ const url = `${this.baseUrl}/admin/backups/${encodeURIComponent(backupId)}/download`;
2502
+ const response = await fetch(url, {
2503
+ headers: { ...this.headers, Accept: "application/octet-stream" }
2504
+ });
2505
+ if (!response.ok) {
2506
+ throw new Error(`Download failed: ${response.status}`);
2507
+ }
2508
+ return response.arrayBuffer();
2509
+ }
2510
+ /** POST /admin/backups/upload — upload a backup archive. */
2511
+ async adminUploadBackup(data) {
2512
+ const url = `${this.baseUrl}/admin/backups/upload`;
2513
+ const headers = {};
2514
+ if (this.apiKey) {
2515
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
2516
+ }
2517
+ headers["Content-Type"] = "application/gzip";
2518
+ const response = await fetch(url, {
2519
+ method: "POST",
2520
+ headers,
2521
+ body: data instanceof ArrayBuffer ? data : data
2522
+ });
2523
+ if (!response.ok) {
2524
+ throw new Error(`Upload failed: ${response.status}`);
2525
+ }
2526
+ return response.json();
2527
+ }
2528
+ /** GET /admin/storage/tiers — storage tier overview. */
2529
+ async adminStorageTierOverview() {
2530
+ return this.request("GET", "/admin/storage/tiers");
2531
+ }
2532
+ /** GET /admin/background-activity — current background activity. */
2533
+ async adminBackgroundActivity() {
2534
+ return this.request("GET", "/admin/background-activity");
2535
+ }
2536
+ /** GET /admin/memory-type-stats — memory type distribution statistics. */
2537
+ async adminMemoryTypeStats() {
2538
+ return this.request("GET", "/admin/memory-type-stats");
2539
+ }
2540
+ /** POST /admin/namespaces/migrate-dimensions — migrate namespace embedding dimensions. */
2541
+ async adminMigrateNamespaceDimensions(request) {
2542
+ return this.request(
2543
+ "POST",
2544
+ "/admin/namespaces/migrate-dimensions",
2545
+ request ?? {}
2546
+ );
2547
+ }
2246
2548
  };
2247
2549
 
2248
2550
  // src/types.ts