@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.mjs
CHANGED
|
@@ -96,6 +96,12 @@ function parseErrorCode(raw) {
|
|
|
96
96
|
}
|
|
97
97
|
return "UNKNOWN" /* UNKNOWN */;
|
|
98
98
|
}
|
|
99
|
+
function flattenRecalledMemory(item) {
|
|
100
|
+
if (item && typeof item === "object" && item.memory && typeof item.memory === "object") {
|
|
101
|
+
return { ...item.memory, score: item.score, depth: item.depth };
|
|
102
|
+
}
|
|
103
|
+
return item;
|
|
104
|
+
}
|
|
99
105
|
var DEFAULT_TIMEOUT = 3e4;
|
|
100
106
|
var DEFAULT_MAX_RETRIES = 3;
|
|
101
107
|
var DEFAULT_BASE_DELAY = 100;
|
|
@@ -353,7 +359,33 @@ var DakeraClient = class {
|
|
|
353
359
|
if (options.ids) body.ids = options.ids;
|
|
354
360
|
if (options.filter) body.filter = options.filter;
|
|
355
361
|
if (options.deleteAll) body.delete_all = true;
|
|
356
|
-
return this.request("POST", `/v1/namespaces/${namespace}/delete`, body);
|
|
362
|
+
return this.request("POST", `/v1/namespaces/${namespace}/vectors/delete`, body);
|
|
363
|
+
}
|
|
364
|
+
/** Bulk update vector metadata matching a filter. */
|
|
365
|
+
async bulkUpdateVectors(namespace, filter, update) {
|
|
366
|
+
return this.request(
|
|
367
|
+
"POST",
|
|
368
|
+
`/v1/namespaces/${encodeURIComponent(namespace)}/vectors/bulk-update`,
|
|
369
|
+
{ filter, update }
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
/** Bulk delete vectors matching a filter. */
|
|
373
|
+
async bulkDeleteVectors(namespace, filter) {
|
|
374
|
+
return this.request(
|
|
375
|
+
"POST",
|
|
376
|
+
`/v1/namespaces/${encodeURIComponent(namespace)}/vectors/bulk-delete`,
|
|
377
|
+
{ filter }
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
/** Count vectors in a namespace, optionally filtered. */
|
|
381
|
+
async countVectors(namespace, filter) {
|
|
382
|
+
const body = {};
|
|
383
|
+
if (filter) body.filter = filter;
|
|
384
|
+
return this.request(
|
|
385
|
+
"POST",
|
|
386
|
+
`/v1/namespaces/${encodeURIComponent(namespace)}/vectors/count`,
|
|
387
|
+
body
|
|
388
|
+
);
|
|
357
389
|
}
|
|
358
390
|
/**
|
|
359
391
|
* Fetch vectors by ID.
|
|
@@ -578,6 +610,14 @@ var DakeraClient = class {
|
|
|
578
610
|
async health() {
|
|
579
611
|
return this.request("GET", "/health");
|
|
580
612
|
}
|
|
613
|
+
/** K8s readiness probe — checks storage and dependencies. */
|
|
614
|
+
async healthReady() {
|
|
615
|
+
return this.request("GET", "/health/ready");
|
|
616
|
+
}
|
|
617
|
+
/** K8s liveness probe — checks process is alive. */
|
|
618
|
+
async healthLive() {
|
|
619
|
+
return this.request("GET", "/health/live");
|
|
620
|
+
}
|
|
581
621
|
/**
|
|
582
622
|
* Get index statistics for a namespace.
|
|
583
623
|
*
|
|
@@ -1062,7 +1102,11 @@ var DakeraClient = class {
|
|
|
1062
1102
|
if (options?.until !== void 0) body["until"] = options.until;
|
|
1063
1103
|
if (options?.routing !== void 0) body["routing"] = options.routing;
|
|
1064
1104
|
if (options?.rerank !== void 0) body["rerank"] = options.rerank;
|
|
1065
|
-
|
|
1105
|
+
const raw = await this.request("POST", "/v1/memory/recall", { ...body, agent_id: agentId2 });
|
|
1106
|
+
return {
|
|
1107
|
+
memories: (raw.memories ?? []).map(flattenRecalledMemory),
|
|
1108
|
+
...raw.associated_memories ? { associated_memories: raw.associated_memories.map(flattenRecalledMemory) } : {}
|
|
1109
|
+
};
|
|
1066
1110
|
}
|
|
1067
1111
|
/** Get a specific memory */
|
|
1068
1112
|
async getMemory(agentId2, memoryId2) {
|
|
@@ -1121,7 +1165,8 @@ var DakeraClient = class {
|
|
|
1121
1165
|
if (options?.routing !== void 0) body["routing"] = options.routing;
|
|
1122
1166
|
if (options?.rerank !== void 0) body["rerank"] = options.rerank;
|
|
1123
1167
|
const result = await this.request("POST", "/v1/memory/search", { ...body, agent_id: agentId2 });
|
|
1124
|
-
|
|
1168
|
+
const items = result.memories ?? result;
|
|
1169
|
+
return (Array.isArray(items) ? items : []).map(flattenRecalledMemory);
|
|
1125
1170
|
}
|
|
1126
1171
|
/** Update importance of memories */
|
|
1127
1172
|
async updateImportance(agentId2, request) {
|
|
@@ -1139,6 +1184,22 @@ var DakeraClient = class {
|
|
|
1139
1184
|
async consolidate(agentId2, request) {
|
|
1140
1185
|
return this.request("POST", "/v1/memory/consolidate", { ...request ?? {}, agent_id: agentId2 });
|
|
1141
1186
|
}
|
|
1187
|
+
/** Consolidate memories directly for an agent (DBSCAN clustering). */
|
|
1188
|
+
async consolidateAgent(agentId2) {
|
|
1189
|
+
return this.request("POST", `/v1/agents/${encodeURIComponent(agentId2)}/consolidate`);
|
|
1190
|
+
}
|
|
1191
|
+
/** Get the consolidation execution log for an agent. */
|
|
1192
|
+
async getConsolidationLog(agentId2) {
|
|
1193
|
+
return this.request("GET", `/v1/agents/${encodeURIComponent(agentId2)}/consolidation/log`);
|
|
1194
|
+
}
|
|
1195
|
+
/** Update the consolidation configuration for an agent. */
|
|
1196
|
+
async patchConsolidationConfig(agentId2, config) {
|
|
1197
|
+
return this.request(
|
|
1198
|
+
"PATCH",
|
|
1199
|
+
`/v1/agents/${encodeURIComponent(agentId2)}/consolidation/config`,
|
|
1200
|
+
config
|
|
1201
|
+
);
|
|
1202
|
+
}
|
|
1142
1203
|
/** Submit feedback on a memory recall */
|
|
1143
1204
|
async memoryFeedback(agentId2, request) {
|
|
1144
1205
|
return this.request("POST", "/v1/memory/feedback", { ...request, agent_id: agentId2 });
|
|
@@ -1261,6 +1322,14 @@ var DakeraClient = class {
|
|
|
1261
1322
|
// =========================================================================
|
|
1262
1323
|
// Entity Extraction Operations (CE-4)
|
|
1263
1324
|
// =========================================================================
|
|
1325
|
+
/** Get entity extraction configuration for a namespace. */
|
|
1326
|
+
async getNamespaceEntityConfig(namespace) {
|
|
1327
|
+
return this.request("GET", `/v1/namespaces/${encodeURIComponent(namespace)}/config`);
|
|
1328
|
+
}
|
|
1329
|
+
/** Get the extractor provider configuration for a namespace. */
|
|
1330
|
+
async getNamespaceExtractor(namespace) {
|
|
1331
|
+
return this.request("GET", `/v1/namespaces/${encodeURIComponent(namespace)}/extractor`);
|
|
1332
|
+
}
|
|
1264
1333
|
/**
|
|
1265
1334
|
* Configure entity extraction for a namespace.
|
|
1266
1335
|
*
|
|
@@ -1314,7 +1383,7 @@ var DakeraClient = class {
|
|
|
1314
1383
|
}
|
|
1315
1384
|
/** End a session. Returns the session state and total memory count at close. */
|
|
1316
1385
|
async endSession(sessionId2) {
|
|
1317
|
-
return this.request("POST", `/v1/sessions/${sessionId2}/end
|
|
1386
|
+
return this.request("POST", `/v1/sessions/${sessionId2}/end`, {});
|
|
1318
1387
|
}
|
|
1319
1388
|
/** Get session details */
|
|
1320
1389
|
async getSession(sessionId2) {
|
|
@@ -2216,6 +2285,226 @@ var DakeraClient = class {
|
|
|
2216
2285
|
const body = namespace ? { namespace } : {};
|
|
2217
2286
|
return this.request("POST", "/admin/fulltext/reindex", body);
|
|
2218
2287
|
}
|
|
2288
|
+
// ---------------------------------------------------------------------------
|
|
2289
|
+
// Admin — Cluster & Maintenance
|
|
2290
|
+
// ---------------------------------------------------------------------------
|
|
2291
|
+
/** GET /admin/cluster/replication — cluster replication status. */
|
|
2292
|
+
async adminClusterReplication() {
|
|
2293
|
+
return this.request("GET", "/admin/cluster/replication");
|
|
2294
|
+
}
|
|
2295
|
+
/** GET /admin/cluster/shards — list shards. */
|
|
2296
|
+
async adminListShards() {
|
|
2297
|
+
return this.request("GET", "/admin/cluster/shards");
|
|
2298
|
+
}
|
|
2299
|
+
/** POST /admin/cluster/shards/rebalance — rebalance shards. */
|
|
2300
|
+
async adminRebalanceShards(request) {
|
|
2301
|
+
return this.request("POST", "/admin/cluster/shards/rebalance", request ?? {});
|
|
2302
|
+
}
|
|
2303
|
+
/** GET /admin/cluster/maintenance — maintenance mode status. */
|
|
2304
|
+
async adminMaintenanceStatus() {
|
|
2305
|
+
return this.request("GET", "/admin/cluster/maintenance");
|
|
2306
|
+
}
|
|
2307
|
+
/** POST /admin/cluster/maintenance/enable — enable maintenance mode. */
|
|
2308
|
+
async adminEnableMaintenance(request) {
|
|
2309
|
+
return this.request("POST", "/admin/cluster/maintenance/enable", request);
|
|
2310
|
+
}
|
|
2311
|
+
/** POST /admin/cluster/maintenance/disable — disable maintenance mode. */
|
|
2312
|
+
async adminDisableMaintenance(request) {
|
|
2313
|
+
return this.request("POST", "/admin/cluster/maintenance/disable", request ?? {});
|
|
2314
|
+
}
|
|
2315
|
+
// ---------------------------------------------------------------------------
|
|
2316
|
+
// Admin — Quotas
|
|
2317
|
+
// ---------------------------------------------------------------------------
|
|
2318
|
+
/** GET /admin/quotas — list all namespace quotas. */
|
|
2319
|
+
async adminListQuotas() {
|
|
2320
|
+
return this.request("GET", "/admin/quotas");
|
|
2321
|
+
}
|
|
2322
|
+
/** GET /admin/quotas/default — get default quota configuration. */
|
|
2323
|
+
async adminGetDefaultQuota() {
|
|
2324
|
+
return this.request("GET", "/admin/quotas/default");
|
|
2325
|
+
}
|
|
2326
|
+
/** PUT /admin/quotas/default — set default quota configuration. */
|
|
2327
|
+
async adminSetDefaultQuota(request) {
|
|
2328
|
+
return this.request("PUT", "/admin/quotas/default", request);
|
|
2329
|
+
}
|
|
2330
|
+
/** GET /admin/quotas/{namespace} — get namespace quota. */
|
|
2331
|
+
async adminGetQuota(namespace) {
|
|
2332
|
+
return this.request("GET", `/admin/quotas/${namespace}`);
|
|
2333
|
+
}
|
|
2334
|
+
/** PUT /admin/quotas/{namespace} — set namespace quota. */
|
|
2335
|
+
async adminSetQuota(namespace, request) {
|
|
2336
|
+
return this.request("PUT", `/admin/quotas/${namespace}`, request);
|
|
2337
|
+
}
|
|
2338
|
+
/** DELETE /admin/quotas/{namespace} — remove namespace quota. */
|
|
2339
|
+
async adminDeleteQuota(namespace) {
|
|
2340
|
+
return this.request("DELETE", `/admin/quotas/${namespace}`);
|
|
2341
|
+
}
|
|
2342
|
+
/** POST /admin/quotas/{namespace}/check — check if operation would exceed quota. */
|
|
2343
|
+
async adminCheckQuota(namespace, request) {
|
|
2344
|
+
return this.request("POST", `/admin/quotas/${namespace}/check`, request);
|
|
2345
|
+
}
|
|
2346
|
+
// ---------------------------------------------------------------------------
|
|
2347
|
+
// Admin — Slow Queries
|
|
2348
|
+
// ---------------------------------------------------------------------------
|
|
2349
|
+
/** GET /admin/slow-queries — list recent slow queries. */
|
|
2350
|
+
async adminListSlowQueries(params) {
|
|
2351
|
+
const qs = params ? new URLSearchParams(Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)])).toString() : "";
|
|
2352
|
+
const path = qs ? `/admin/slow-queries?${qs}` : "/admin/slow-queries";
|
|
2353
|
+
return this.request("GET", path);
|
|
2354
|
+
}
|
|
2355
|
+
/** GET /admin/slow-queries/summary — slow query summary. */
|
|
2356
|
+
async adminSlowQuerySummary() {
|
|
2357
|
+
return this.request("GET", "/admin/slow-queries/summary");
|
|
2358
|
+
}
|
|
2359
|
+
/** DELETE /admin/slow-queries — clear slow query log. */
|
|
2360
|
+
async adminClearSlowQueries(namespace) {
|
|
2361
|
+
const path = namespace ? `/admin/slow-queries?namespace=${encodeURIComponent(namespace)}` : "/admin/slow-queries";
|
|
2362
|
+
return this.request("DELETE", path);
|
|
2363
|
+
}
|
|
2364
|
+
/** PATCH /admin/slow-queries/config — update slow query configuration. */
|
|
2365
|
+
async adminUpdateSlowQueryConfig(config) {
|
|
2366
|
+
return this.request("PATCH", "/admin/slow-queries/config", config);
|
|
2367
|
+
}
|
|
2368
|
+
// ---------------------------------------------------------------------------
|
|
2369
|
+
// Admin — Backups
|
|
2370
|
+
// ---------------------------------------------------------------------------
|
|
2371
|
+
/** GET /admin/backups — list all backups. */
|
|
2372
|
+
async adminListBackups() {
|
|
2373
|
+
return this.request("GET", "/admin/backups");
|
|
2374
|
+
}
|
|
2375
|
+
/** POST /admin/backups — create a new backup. */
|
|
2376
|
+
async adminCreateBackup(request) {
|
|
2377
|
+
return this.request("POST", "/admin/backups", request);
|
|
2378
|
+
}
|
|
2379
|
+
/** GET /admin/backups/{id} — get backup details. */
|
|
2380
|
+
async adminGetBackup(backupId) {
|
|
2381
|
+
return this.request("GET", `/admin/backups/${backupId}`);
|
|
2382
|
+
}
|
|
2383
|
+
/** DELETE /admin/backups/{id} — delete a backup. */
|
|
2384
|
+
async adminDeleteBackup(backupId) {
|
|
2385
|
+
return this.request("DELETE", `/admin/backups/${backupId}`);
|
|
2386
|
+
}
|
|
2387
|
+
/** GET /admin/backups/schedule — get backup schedule. */
|
|
2388
|
+
async adminGetBackupSchedule() {
|
|
2389
|
+
return this.request("GET", "/admin/backups/schedule");
|
|
2390
|
+
}
|
|
2391
|
+
/** POST /admin/backups/schedule — update backup schedule. */
|
|
2392
|
+
async adminUpdateBackupSchedule(request) {
|
|
2393
|
+
return this.request("POST", "/admin/backups/schedule", request);
|
|
2394
|
+
}
|
|
2395
|
+
/** POST /admin/backups/restore — restore from backup. */
|
|
2396
|
+
async adminRestoreBackup(request) {
|
|
2397
|
+
return this.request("POST", "/admin/backups/restore", request);
|
|
2398
|
+
}
|
|
2399
|
+
/** GET /admin/backups/restore/{id} — restore operation status. */
|
|
2400
|
+
async adminGetRestoreStatus(restoreId) {
|
|
2401
|
+
return this.request("GET", `/admin/backups/restore/${restoreId}`);
|
|
2402
|
+
}
|
|
2403
|
+
// ---------------------------------------------------------------------------
|
|
2404
|
+
// Ops — Diagnostics & Jobs
|
|
2405
|
+
// ---------------------------------------------------------------------------
|
|
2406
|
+
/** GET /ops/diagnostics — system diagnostics. */
|
|
2407
|
+
async opsDiagnostics() {
|
|
2408
|
+
return this.request("GET", "/ops/diagnostics");
|
|
2409
|
+
}
|
|
2410
|
+
/** GET /ops/jobs — list background jobs. */
|
|
2411
|
+
async opsListJobs() {
|
|
2412
|
+
return this.request("GET", "/ops/jobs");
|
|
2413
|
+
}
|
|
2414
|
+
/** GET /ops/jobs/{id} — get job status. */
|
|
2415
|
+
async opsGetJob(jobId) {
|
|
2416
|
+
return this.request("GET", `/ops/jobs/${jobId}`);
|
|
2417
|
+
}
|
|
2418
|
+
/** POST /ops/compact — trigger compaction. */
|
|
2419
|
+
async opsCompact(request) {
|
|
2420
|
+
return this.request("POST", "/ops/compact", request ?? {});
|
|
2421
|
+
}
|
|
2422
|
+
/** POST /ops/shutdown — request graceful shutdown. */
|
|
2423
|
+
async opsShutdown() {
|
|
2424
|
+
return this.request("POST", "/ops/shutdown");
|
|
2425
|
+
}
|
|
2426
|
+
// ────────────────────────────────────────────────────────────
|
|
2427
|
+
// Phase 3 — Engine Parity
|
|
2428
|
+
// ────────────────────────────────────────────────────────────
|
|
2429
|
+
/** GET /v1/namespaces/{namespace}/fulltext/stats — full-text index statistics. */
|
|
2430
|
+
async fulltextStats(namespace) {
|
|
2431
|
+
return this.request(
|
|
2432
|
+
"GET",
|
|
2433
|
+
`/v1/namespaces/${encodeURIComponent(namespace)}/fulltext/stats`
|
|
2434
|
+
);
|
|
2435
|
+
}
|
|
2436
|
+
/** POST /v1/namespaces/{namespace}/fulltext/delete — delete documents from full-text index. */
|
|
2437
|
+
async fulltextDelete(namespace, ids) {
|
|
2438
|
+
return this.request(
|
|
2439
|
+
"POST",
|
|
2440
|
+
`/v1/namespaces/${encodeURIComponent(namespace)}/fulltext/delete`,
|
|
2441
|
+
{ ids }
|
|
2442
|
+
);
|
|
2443
|
+
}
|
|
2444
|
+
/** GET /admin/ttl/stats — TTL statistics across all namespaces. */
|
|
2445
|
+
async adminTtlStats() {
|
|
2446
|
+
return this.request("GET", "/admin/ttl/stats");
|
|
2447
|
+
}
|
|
2448
|
+
/** POST /v1/route — route a query to the best-matching namespace(s). */
|
|
2449
|
+
async routeQuery(request) {
|
|
2450
|
+
return this.request("POST", "/v1/route", request);
|
|
2451
|
+
}
|
|
2452
|
+
/** GET /v1/import/{job_id}/status — check import job progress. */
|
|
2453
|
+
async importJobStatus(jobId) {
|
|
2454
|
+
return this.request(
|
|
2455
|
+
"GET",
|
|
2456
|
+
`/v1/import/${encodeURIComponent(jobId)}/status`
|
|
2457
|
+
);
|
|
2458
|
+
}
|
|
2459
|
+
/** GET /admin/backups/{id}/download — download a backup as binary data. */
|
|
2460
|
+
async adminDownloadBackup(backupId) {
|
|
2461
|
+
const url = `${this.baseUrl}/admin/backups/${encodeURIComponent(backupId)}/download`;
|
|
2462
|
+
const response = await fetch(url, {
|
|
2463
|
+
headers: { ...this.headers, Accept: "application/octet-stream" }
|
|
2464
|
+
});
|
|
2465
|
+
if (!response.ok) {
|
|
2466
|
+
throw new Error(`Download failed: ${response.status}`);
|
|
2467
|
+
}
|
|
2468
|
+
return response.arrayBuffer();
|
|
2469
|
+
}
|
|
2470
|
+
/** POST /admin/backups/upload — upload a backup archive. */
|
|
2471
|
+
async adminUploadBackup(data) {
|
|
2472
|
+
const url = `${this.baseUrl}/admin/backups/upload`;
|
|
2473
|
+
const headers = {};
|
|
2474
|
+
if (this.apiKey) {
|
|
2475
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
2476
|
+
}
|
|
2477
|
+
headers["Content-Type"] = "application/gzip";
|
|
2478
|
+
const response = await fetch(url, {
|
|
2479
|
+
method: "POST",
|
|
2480
|
+
headers,
|
|
2481
|
+
body: data instanceof ArrayBuffer ? data : data
|
|
2482
|
+
});
|
|
2483
|
+
if (!response.ok) {
|
|
2484
|
+
throw new Error(`Upload failed: ${response.status}`);
|
|
2485
|
+
}
|
|
2486
|
+
return response.json();
|
|
2487
|
+
}
|
|
2488
|
+
/** GET /admin/storage/tiers — storage tier overview. */
|
|
2489
|
+
async adminStorageTierOverview() {
|
|
2490
|
+
return this.request("GET", "/admin/storage/tiers");
|
|
2491
|
+
}
|
|
2492
|
+
/** GET /admin/background-activity — current background activity. */
|
|
2493
|
+
async adminBackgroundActivity() {
|
|
2494
|
+
return this.request("GET", "/admin/background-activity");
|
|
2495
|
+
}
|
|
2496
|
+
/** GET /admin/memory-type-stats — memory type distribution statistics. */
|
|
2497
|
+
async adminMemoryTypeStats() {
|
|
2498
|
+
return this.request("GET", "/admin/memory-type-stats");
|
|
2499
|
+
}
|
|
2500
|
+
/** POST /admin/namespaces/migrate-dimensions — migrate namespace embedding dimensions. */
|
|
2501
|
+
async adminMigrateNamespaceDimensions(request) {
|
|
2502
|
+
return this.request(
|
|
2503
|
+
"POST",
|
|
2504
|
+
"/admin/namespaces/migrate-dimensions",
|
|
2505
|
+
request ?? {}
|
|
2506
|
+
);
|
|
2507
|
+
}
|
|
2219
2508
|
};
|
|
2220
2509
|
|
|
2221
2510
|
// src/types.ts
|