@dakera-ai/dakera 0.11.55 → 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/README.md +2 -2
- package/dist/index.d.mts +611 -7
- package/dist/index.d.ts +611 -7
- package/dist/index.js +293 -4
- package/dist/index.mjs +293 -4
- package/package.json +1 -1
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
|
-
|
|
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) {
|
|
@@ -1161,7 +1205,8 @@ var DakeraClient = class {
|
|
|
1161
1205
|
if (options?.routing !== void 0) body["routing"] = options.routing;
|
|
1162
1206
|
if (options?.rerank !== void 0) body["rerank"] = options.rerank;
|
|
1163
1207
|
const result = await this.request("POST", "/v1/memory/search", { ...body, agent_id: agentId2 });
|
|
1164
|
-
|
|
1208
|
+
const items = result.memories ?? result;
|
|
1209
|
+
return (Array.isArray(items) ? items : []).map(flattenRecalledMemory);
|
|
1165
1210
|
}
|
|
1166
1211
|
/** Update importance of memories */
|
|
1167
1212
|
async updateImportance(agentId2, request) {
|
|
@@ -1179,6 +1224,22 @@ var DakeraClient = class {
|
|
|
1179
1224
|
async consolidate(agentId2, request) {
|
|
1180
1225
|
return this.request("POST", "/v1/memory/consolidate", { ...request ?? {}, agent_id: agentId2 });
|
|
1181
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
|
+
);
|
|
1242
|
+
}
|
|
1182
1243
|
/** Submit feedback on a memory recall */
|
|
1183
1244
|
async memoryFeedback(agentId2, request) {
|
|
1184
1245
|
return this.request("POST", "/v1/memory/feedback", { ...request, agent_id: agentId2 });
|
|
@@ -1301,6 +1362,14 @@ var DakeraClient = class {
|
|
|
1301
1362
|
// =========================================================================
|
|
1302
1363
|
// Entity Extraction Operations (CE-4)
|
|
1303
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
|
+
}
|
|
1304
1373
|
/**
|
|
1305
1374
|
* Configure entity extraction for a namespace.
|
|
1306
1375
|
*
|
|
@@ -1354,7 +1423,7 @@ var DakeraClient = class {
|
|
|
1354
1423
|
}
|
|
1355
1424
|
/** End a session. Returns the session state and total memory count at close. */
|
|
1356
1425
|
async endSession(sessionId2) {
|
|
1357
|
-
return this.request("POST", `/v1/sessions/${sessionId2}/end
|
|
1426
|
+
return this.request("POST", `/v1/sessions/${sessionId2}/end`, {});
|
|
1358
1427
|
}
|
|
1359
1428
|
/** Get session details */
|
|
1360
1429
|
async getSession(sessionId2) {
|
|
@@ -2256,6 +2325,226 @@ var DakeraClient = class {
|
|
|
2256
2325
|
const body = namespace ? { namespace } : {};
|
|
2257
2326
|
return this.request("POST", "/admin/fulltext/reindex", body);
|
|
2258
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
|
+
}
|
|
2259
2548
|
};
|
|
2260
2549
|
|
|
2261
2550
|
// src/types.ts
|