@dakera-ai/dakera 0.11.55 → 0.11.57

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.
@@ -618,6 +650,14 @@ var DakeraClient = class {
618
650
  async health() {
619
651
  return this.request("GET", "/health");
620
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
+ }
621
661
  /**
622
662
  * Get index statistics for a namespace.
623
663
  *
@@ -1102,7 +1142,11 @@ var DakeraClient = class {
1102
1142
  if (options?.until !== void 0) body["until"] = options.until;
1103
1143
  if (options?.routing !== void 0) body["routing"] = options.routing;
1104
1144
  if (options?.rerank !== void 0) body["rerank"] = options.rerank;
1105
- return this.request("POST", "/v1/memory/recall", { ...body, agent_id: agentId2 });
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
+ };
1106
1150
  }
1107
1151
  /** Get a specific memory */
1108
1152
  async getMemory(agentId2, memoryId2) {
@@ -1152,6 +1196,28 @@ var DakeraClient = class {
1152
1196
  async batchForget(request) {
1153
1197
  return this.request("DELETE", "/v1/memories/forget/batch", request);
1154
1198
  }
1199
+ /**
1200
+ * Store multiple memories in a single request (DAK-5508).
1201
+ *
1202
+ * Uses `POST /v1/memories/store/batch`. The server embeds all contents in a
1203
+ * single ONNX inference pass, yielding ≥100× throughput vs. N sequential
1204
+ * single-store calls. Accepts up to 1 000 memories per call.
1205
+ *
1206
+ * @example
1207
+ * ```ts
1208
+ * const resp = await client.storeMemoriesBatch({
1209
+ * agent_id: 'agent-1',
1210
+ * memories: [
1211
+ * { content: 'The user prefers dark mode', importance: 0.8 },
1212
+ * { content: 'The user is based in Berlin', importance: 0.7 },
1213
+ * ],
1214
+ * });
1215
+ * console.log(`Stored ${resp.stored_count} memories`);
1216
+ * ```
1217
+ */
1218
+ async storeMemoriesBatch(request) {
1219
+ return this.request("POST", "/v1/memories/store/batch", request);
1220
+ }
1155
1221
  /** Search memories for an agent */
1156
1222
  async searchMemories(agentId2, query, options) {
1157
1223
  const body = { query };
@@ -1161,7 +1227,8 @@ var DakeraClient = class {
1161
1227
  if (options?.routing !== void 0) body["routing"] = options.routing;
1162
1228
  if (options?.rerank !== void 0) body["rerank"] = options.rerank;
1163
1229
  const result = await this.request("POST", "/v1/memory/search", { ...body, agent_id: agentId2 });
1164
- return result.memories ?? result;
1230
+ const items = result.memories ?? result;
1231
+ return (Array.isArray(items) ? items : []).map(flattenRecalledMemory);
1165
1232
  }
1166
1233
  /** Update importance of memories */
1167
1234
  async updateImportance(agentId2, request) {
@@ -1179,6 +1246,22 @@ var DakeraClient = class {
1179
1246
  async consolidate(agentId2, request) {
1180
1247
  return this.request("POST", "/v1/memory/consolidate", { ...request ?? {}, agent_id: agentId2 });
1181
1248
  }
1249
+ /** Consolidate memories directly for an agent (DBSCAN clustering). */
1250
+ async consolidateAgent(agentId2) {
1251
+ return this.request("POST", `/v1/agents/${encodeURIComponent(agentId2)}/consolidate`);
1252
+ }
1253
+ /** Get the consolidation execution log for an agent. */
1254
+ async getConsolidationLog(agentId2) {
1255
+ return this.request("GET", `/v1/agents/${encodeURIComponent(agentId2)}/consolidation/log`);
1256
+ }
1257
+ /** Update the consolidation configuration for an agent. */
1258
+ async patchConsolidationConfig(agentId2, config) {
1259
+ return this.request(
1260
+ "PATCH",
1261
+ `/v1/agents/${encodeURIComponent(agentId2)}/consolidation/config`,
1262
+ config
1263
+ );
1264
+ }
1182
1265
  /** Submit feedback on a memory recall */
1183
1266
  async memoryFeedback(agentId2, request) {
1184
1267
  return this.request("POST", "/v1/memory/feedback", { ...request, agent_id: agentId2 });
@@ -1301,6 +1384,14 @@ var DakeraClient = class {
1301
1384
  // =========================================================================
1302
1385
  // Entity Extraction Operations (CE-4)
1303
1386
  // =========================================================================
1387
+ /** Get entity extraction configuration for a namespace. */
1388
+ async getNamespaceEntityConfig(namespace) {
1389
+ return this.request("GET", `/v1/namespaces/${encodeURIComponent(namespace)}/config`);
1390
+ }
1391
+ /** Get the extractor provider configuration for a namespace. */
1392
+ async getNamespaceExtractor(namespace) {
1393
+ return this.request("GET", `/v1/namespaces/${encodeURIComponent(namespace)}/extractor`);
1394
+ }
1304
1395
  /**
1305
1396
  * Configure entity extraction for a namespace.
1306
1397
  *
@@ -1354,7 +1445,7 @@ var DakeraClient = class {
1354
1445
  }
1355
1446
  /** End a session. Returns the session state and total memory count at close. */
1356
1447
  async endSession(sessionId2) {
1357
- return this.request("POST", `/v1/sessions/${sessionId2}/end`);
1448
+ return this.request("POST", `/v1/sessions/${sessionId2}/end`, {});
1358
1449
  }
1359
1450
  /** Get session details */
1360
1451
  async getSession(sessionId2) {
@@ -2256,6 +2347,226 @@ var DakeraClient = class {
2256
2347
  const body = namespace ? { namespace } : {};
2257
2348
  return this.request("POST", "/admin/fulltext/reindex", body);
2258
2349
  }
2350
+ // ---------------------------------------------------------------------------
2351
+ // Admin — Cluster & Maintenance
2352
+ // ---------------------------------------------------------------------------
2353
+ /** GET /admin/cluster/replication — cluster replication status. */
2354
+ async adminClusterReplication() {
2355
+ return this.request("GET", "/admin/cluster/replication");
2356
+ }
2357
+ /** GET /admin/cluster/shards — list shards. */
2358
+ async adminListShards() {
2359
+ return this.request("GET", "/admin/cluster/shards");
2360
+ }
2361
+ /** POST /admin/cluster/shards/rebalance — rebalance shards. */
2362
+ async adminRebalanceShards(request) {
2363
+ return this.request("POST", "/admin/cluster/shards/rebalance", request ?? {});
2364
+ }
2365
+ /** GET /admin/cluster/maintenance — maintenance mode status. */
2366
+ async adminMaintenanceStatus() {
2367
+ return this.request("GET", "/admin/cluster/maintenance");
2368
+ }
2369
+ /** POST /admin/cluster/maintenance/enable — enable maintenance mode. */
2370
+ async adminEnableMaintenance(request) {
2371
+ return this.request("POST", "/admin/cluster/maintenance/enable", request);
2372
+ }
2373
+ /** POST /admin/cluster/maintenance/disable — disable maintenance mode. */
2374
+ async adminDisableMaintenance(request) {
2375
+ return this.request("POST", "/admin/cluster/maintenance/disable", request ?? {});
2376
+ }
2377
+ // ---------------------------------------------------------------------------
2378
+ // Admin — Quotas
2379
+ // ---------------------------------------------------------------------------
2380
+ /** GET /admin/quotas — list all namespace quotas. */
2381
+ async adminListQuotas() {
2382
+ return this.request("GET", "/admin/quotas");
2383
+ }
2384
+ /** GET /admin/quotas/default — get default quota configuration. */
2385
+ async adminGetDefaultQuota() {
2386
+ return this.request("GET", "/admin/quotas/default");
2387
+ }
2388
+ /** PUT /admin/quotas/default — set default quota configuration. */
2389
+ async adminSetDefaultQuota(request) {
2390
+ return this.request("PUT", "/admin/quotas/default", request);
2391
+ }
2392
+ /** GET /admin/quotas/{namespace} — get namespace quota. */
2393
+ async adminGetQuota(namespace) {
2394
+ return this.request("GET", `/admin/quotas/${namespace}`);
2395
+ }
2396
+ /** PUT /admin/quotas/{namespace} — set namespace quota. */
2397
+ async adminSetQuota(namespace, request) {
2398
+ return this.request("PUT", `/admin/quotas/${namespace}`, request);
2399
+ }
2400
+ /** DELETE /admin/quotas/{namespace} — remove namespace quota. */
2401
+ async adminDeleteQuota(namespace) {
2402
+ return this.request("DELETE", `/admin/quotas/${namespace}`);
2403
+ }
2404
+ /** POST /admin/quotas/{namespace}/check — check if operation would exceed quota. */
2405
+ async adminCheckQuota(namespace, request) {
2406
+ return this.request("POST", `/admin/quotas/${namespace}/check`, request);
2407
+ }
2408
+ // ---------------------------------------------------------------------------
2409
+ // Admin — Slow Queries
2410
+ // ---------------------------------------------------------------------------
2411
+ /** GET /admin/slow-queries — list recent slow queries. */
2412
+ async adminListSlowQueries(params) {
2413
+ const qs = params ? new URLSearchParams(Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)])).toString() : "";
2414
+ const path = qs ? `/admin/slow-queries?${qs}` : "/admin/slow-queries";
2415
+ return this.request("GET", path);
2416
+ }
2417
+ /** GET /admin/slow-queries/summary — slow query summary. */
2418
+ async adminSlowQuerySummary() {
2419
+ return this.request("GET", "/admin/slow-queries/summary");
2420
+ }
2421
+ /** DELETE /admin/slow-queries — clear slow query log. */
2422
+ async adminClearSlowQueries(namespace) {
2423
+ const path = namespace ? `/admin/slow-queries?namespace=${encodeURIComponent(namespace)}` : "/admin/slow-queries";
2424
+ return this.request("DELETE", path);
2425
+ }
2426
+ /** PATCH /admin/slow-queries/config — update slow query configuration. */
2427
+ async adminUpdateSlowQueryConfig(config) {
2428
+ return this.request("PATCH", "/admin/slow-queries/config", config);
2429
+ }
2430
+ // ---------------------------------------------------------------------------
2431
+ // Admin — Backups
2432
+ // ---------------------------------------------------------------------------
2433
+ /** GET /admin/backups — list all backups. */
2434
+ async adminListBackups() {
2435
+ return this.request("GET", "/admin/backups");
2436
+ }
2437
+ /** POST /admin/backups — create a new backup. */
2438
+ async adminCreateBackup(request) {
2439
+ return this.request("POST", "/admin/backups", request);
2440
+ }
2441
+ /** GET /admin/backups/{id} — get backup details. */
2442
+ async adminGetBackup(backupId) {
2443
+ return this.request("GET", `/admin/backups/${backupId}`);
2444
+ }
2445
+ /** DELETE /admin/backups/{id} — delete a backup. */
2446
+ async adminDeleteBackup(backupId) {
2447
+ return this.request("DELETE", `/admin/backups/${backupId}`);
2448
+ }
2449
+ /** GET /admin/backups/schedule — get backup schedule. */
2450
+ async adminGetBackupSchedule() {
2451
+ return this.request("GET", "/admin/backups/schedule");
2452
+ }
2453
+ /** POST /admin/backups/schedule — update backup schedule. */
2454
+ async adminUpdateBackupSchedule(request) {
2455
+ return this.request("POST", "/admin/backups/schedule", request);
2456
+ }
2457
+ /** POST /admin/backups/restore — restore from backup. */
2458
+ async adminRestoreBackup(request) {
2459
+ return this.request("POST", "/admin/backups/restore", request);
2460
+ }
2461
+ /** GET /admin/backups/restore/{id} — restore operation status. */
2462
+ async adminGetRestoreStatus(restoreId) {
2463
+ return this.request("GET", `/admin/backups/restore/${restoreId}`);
2464
+ }
2465
+ // ---------------------------------------------------------------------------
2466
+ // Ops — Diagnostics & Jobs
2467
+ // ---------------------------------------------------------------------------
2468
+ /** GET /ops/diagnostics — system diagnostics. */
2469
+ async opsDiagnostics() {
2470
+ return this.request("GET", "/ops/diagnostics");
2471
+ }
2472
+ /** GET /ops/jobs — list background jobs. */
2473
+ async opsListJobs() {
2474
+ return this.request("GET", "/ops/jobs");
2475
+ }
2476
+ /** GET /ops/jobs/{id} — get job status. */
2477
+ async opsGetJob(jobId) {
2478
+ return this.request("GET", `/ops/jobs/${jobId}`);
2479
+ }
2480
+ /** POST /ops/compact — trigger compaction. */
2481
+ async opsCompact(request) {
2482
+ return this.request("POST", "/ops/compact", request ?? {});
2483
+ }
2484
+ /** POST /ops/shutdown — request graceful shutdown. */
2485
+ async opsShutdown() {
2486
+ return this.request("POST", "/ops/shutdown");
2487
+ }
2488
+ // ────────────────────────────────────────────────────────────
2489
+ // Phase 3 — Engine Parity
2490
+ // ────────────────────────────────────────────────────────────
2491
+ /** GET /v1/namespaces/{namespace}/fulltext/stats — full-text index statistics. */
2492
+ async fulltextStats(namespace) {
2493
+ return this.request(
2494
+ "GET",
2495
+ `/v1/namespaces/${encodeURIComponent(namespace)}/fulltext/stats`
2496
+ );
2497
+ }
2498
+ /** POST /v1/namespaces/{namespace}/fulltext/delete — delete documents from full-text index. */
2499
+ async fulltextDelete(namespace, ids) {
2500
+ return this.request(
2501
+ "POST",
2502
+ `/v1/namespaces/${encodeURIComponent(namespace)}/fulltext/delete`,
2503
+ { ids }
2504
+ );
2505
+ }
2506
+ /** GET /admin/ttl/stats — TTL statistics across all namespaces. */
2507
+ async adminTtlStats() {
2508
+ return this.request("GET", "/admin/ttl/stats");
2509
+ }
2510
+ /** POST /v1/route — route a query to the best-matching namespace(s). */
2511
+ async routeQuery(request) {
2512
+ return this.request("POST", "/v1/route", request);
2513
+ }
2514
+ /** GET /v1/import/{job_id}/status — check import job progress. */
2515
+ async importJobStatus(jobId) {
2516
+ return this.request(
2517
+ "GET",
2518
+ `/v1/import/${encodeURIComponent(jobId)}/status`
2519
+ );
2520
+ }
2521
+ /** GET /admin/backups/{id}/download — download a backup as binary data. */
2522
+ async adminDownloadBackup(backupId) {
2523
+ const url = `${this.baseUrl}/admin/backups/${encodeURIComponent(backupId)}/download`;
2524
+ const response = await fetch(url, {
2525
+ headers: { ...this.headers, Accept: "application/octet-stream" }
2526
+ });
2527
+ if (!response.ok) {
2528
+ throw new Error(`Download failed: ${response.status}`);
2529
+ }
2530
+ return response.arrayBuffer();
2531
+ }
2532
+ /** POST /admin/backups/upload — upload a backup archive. */
2533
+ async adminUploadBackup(data) {
2534
+ const url = `${this.baseUrl}/admin/backups/upload`;
2535
+ const headers = {};
2536
+ if (this.apiKey) {
2537
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
2538
+ }
2539
+ headers["Content-Type"] = "application/gzip";
2540
+ const response = await fetch(url, {
2541
+ method: "POST",
2542
+ headers,
2543
+ body: data instanceof ArrayBuffer ? data : data
2544
+ });
2545
+ if (!response.ok) {
2546
+ throw new Error(`Upload failed: ${response.status}`);
2547
+ }
2548
+ return response.json();
2549
+ }
2550
+ /** GET /admin/storage/tiers — storage tier overview. */
2551
+ async adminStorageTierOverview() {
2552
+ return this.request("GET", "/admin/storage/tiers");
2553
+ }
2554
+ /** GET /admin/background-activity — current background activity. */
2555
+ async adminBackgroundActivity() {
2556
+ return this.request("GET", "/admin/background-activity");
2557
+ }
2558
+ /** GET /admin/memory-type-stats — memory type distribution statistics. */
2559
+ async adminMemoryTypeStats() {
2560
+ return this.request("GET", "/admin/memory-type-stats");
2561
+ }
2562
+ /** POST /admin/namespaces/migrate-dimensions — migrate namespace embedding dimensions. */
2563
+ async adminMigrateNamespaceDimensions(request) {
2564
+ return this.request(
2565
+ "POST",
2566
+ "/admin/namespaces/migrate-dimensions",
2567
+ request ?? {}
2568
+ );
2569
+ }
2259
2570
  };
2260
2571
 
2261
2572
  // src/types.ts