@smartmemory/sdk-js 1.4.124 → 1.4.126
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/apiBaseUrl.js +37 -0
- package/dist/connection.js +1 -1
- package/dist/{core-DUg_hHl8.js → core-CmAr3Blx.js} +382 -369
- package/dist/core.js +2 -2
- package/dist/index-BKn-OWw0.js +108 -0
- package/dist/index.js +5 -3
- package/dist/react.js +1 -1
- package/package.json +5 -1
- package/dist/index-BKI1h_Wn.js +0 -107
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as z, R as O } from "./index-
|
|
1
|
+
import { C as z, R as O } from "./index-BKn-OWw0.js";
|
|
2
2
|
import { f as T } from "./recovery-JyUr2KHh.js";
|
|
3
3
|
const P = {
|
|
4
4
|
access: "smart_memory_auth_token",
|
|
@@ -20,12 +20,12 @@ class x {
|
|
|
20
20
|
* @param {Object} [options.keys] - Custom storage key names
|
|
21
21
|
*/
|
|
22
22
|
constructor({ storage: e = "localStorage", keys: t = {} } = {}) {
|
|
23
|
-
var
|
|
23
|
+
var n;
|
|
24
24
|
this.storageType = e;
|
|
25
|
-
const
|
|
26
|
-
this.keys = { ...P, ...t, workspace:
|
|
25
|
+
const s = t.workspace || t.team || P.workspace;
|
|
26
|
+
this.keys = { ...P, ...t, workspace: s }, (n = this.keys).team ?? (n.team = s), this.workspaceAliases = [
|
|
27
27
|
...w.workspace,
|
|
28
|
-
...t.team && t.team !==
|
|
28
|
+
...t.team && t.team !== s ? [t.team] : []
|
|
29
29
|
], this._memory = { access: null, refresh: null, user: null, tenant: null, workspace: null };
|
|
30
30
|
}
|
|
31
31
|
getAccessToken() {
|
|
@@ -121,14 +121,14 @@ class x {
|
|
|
121
121
|
/** @private */
|
|
122
122
|
_getFromStorage(e, t = []) {
|
|
123
123
|
try {
|
|
124
|
-
const
|
|
124
|
+
const s = this.storageType === "localStorage" ? localStorage : sessionStorage, n = this.storageType === "localStorage" ? sessionStorage : localStorage, r = s.getItem(e) || n.getItem(e);
|
|
125
125
|
if (r != null) return r;
|
|
126
126
|
for (const i of t) {
|
|
127
|
-
const o =
|
|
127
|
+
const o = s.getItem(i) || n.getItem(i);
|
|
128
128
|
if (o != null) {
|
|
129
129
|
this._setInStorage(e, o);
|
|
130
130
|
try {
|
|
131
|
-
|
|
131
|
+
s.removeItem(i), n.removeItem(i);
|
|
132
132
|
} catch {
|
|
133
133
|
}
|
|
134
134
|
return o;
|
|
@@ -142,10 +142,10 @@ class x {
|
|
|
142
142
|
/** @private */
|
|
143
143
|
_setInStorage(e, t) {
|
|
144
144
|
try {
|
|
145
|
-
const
|
|
146
|
-
t != null ? (
|
|
147
|
-
} catch (
|
|
148
|
-
console.error("Failed to write to storage:",
|
|
145
|
+
const s = this.storageType === "localStorage" ? localStorage : sessionStorage, n = this.storageType === "localStorage" ? sessionStorage : localStorage;
|
|
146
|
+
t != null ? (s.setItem(e, t), n.removeItem(e)) : (s.removeItem(e), n.removeItem(e));
|
|
147
|
+
} catch (s) {
|
|
148
|
+
console.error("Failed to write to storage:", s);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
/** @private */
|
|
@@ -153,8 +153,8 @@ class x {
|
|
|
153
153
|
if (e == null) return null;
|
|
154
154
|
const t = String(e).trim();
|
|
155
155
|
if (!t) return null;
|
|
156
|
-
const
|
|
157
|
-
return
|
|
156
|
+
const s = t.toLowerCase();
|
|
157
|
+
return s === "none" || s === "null" || s === "undefined" ? null : t;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
const U = "smart_memory_sso_redirect";
|
|
@@ -165,8 +165,8 @@ class j {
|
|
|
165
165
|
* @param {string[]} [options.allowedHosts=[]] - Allowed redirect hostnames
|
|
166
166
|
* @param {import('./TokenManager.js').TokenManager} options.tokenManager
|
|
167
167
|
*/
|
|
168
|
-
constructor({ webAppUrl: e, allowedHosts: t = [], tokenManager:
|
|
169
|
-
this.webAppUrl = e, this.allowedHosts = t, this.tokenManager =
|
|
168
|
+
constructor({ webAppUrl: e, allowedHosts: t = [], tokenManager: s }) {
|
|
169
|
+
this.webAppUrl = e, this.allowedHosts = t, this.tokenManager = s;
|
|
170
170
|
}
|
|
171
171
|
getLoginUrl(e) {
|
|
172
172
|
const t = e || `${window.location.origin}/auth/callback`;
|
|
@@ -199,11 +199,12 @@ class j {
|
|
|
199
199
|
}
|
|
200
200
|
class F {
|
|
201
201
|
constructor(e) {
|
|
202
|
-
this.sessionRevision = 0, this.connection = new z(), this.mode = e.mode, this.
|
|
202
|
+
this.sessionRevision = 0, this.connection = new z(), this.mode = e.mode, this._apiBaseUrl = e.apiBaseUrl, this.endpoints = e.endpoints || {}, this.listeners = /* @__PURE__ */ new Set(), this.useCookieAuth = e.useCookieAuth ?? this.mode === "sso", this.apiKey = e.apiKey || null, this.apiKey && (this.mode = "apiKey"), this.tokenManager = new x({
|
|
203
203
|
storage: e.storage || "localStorage",
|
|
204
204
|
keys: e.tokenKeys
|
|
205
205
|
}), this.mode !== "apiKey" ? this.refreshManager = new O({
|
|
206
|
-
|
|
206
|
+
// Forward the raw config so a function form keeps resolving per refresh.
|
|
207
|
+
apiBaseUrl: e.apiBaseUrl,
|
|
207
208
|
refreshEndpoint: this.endpoints.refresh || "/auth/refresh",
|
|
208
209
|
tokenManager: this.tokenManager,
|
|
209
210
|
useCookieAuth: this.useCookieAuth,
|
|
@@ -212,8 +213,8 @@ class F {
|
|
|
212
213
|
connection: this.connection,
|
|
213
214
|
getSessionKey: () => JSON.stringify([this.sessionRevision, this.currentToken, this.tokenManager.getWorkspaceId()]),
|
|
214
215
|
onTokenRefreshed: (t) => {
|
|
215
|
-
var
|
|
216
|
-
this.currentToken = t, this.notifyListeners(), (
|
|
216
|
+
var s;
|
|
217
|
+
this.currentToken = t, this.notifyListeners(), (s = e.onTokenRefresh) == null || s.call(e, t);
|
|
217
218
|
},
|
|
218
219
|
onRefreshFailed: () => {
|
|
219
220
|
this.clearLocalAuth();
|
|
@@ -224,6 +225,14 @@ class F {
|
|
|
224
225
|
tokenManager: this.tokenManager
|
|
225
226
|
})), this.mode === "apiKey" ? (this.currentUser = null, this.currentToken = this.apiKey) : (this.currentUser = this.tokenManager.getUser(), this.currentToken = this.tokenManager.getAccessToken());
|
|
226
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Current API base URL. When constructed with a function it is invoked on
|
|
230
|
+
* every access so runtime-resolved bases stay live for the session.
|
|
231
|
+
* @returns {string}
|
|
232
|
+
*/
|
|
233
|
+
get apiBaseUrl() {
|
|
234
|
+
return typeof this._apiBaseUrl == "function" ? this._apiBaseUrl() : this._apiBaseUrl;
|
|
235
|
+
}
|
|
227
236
|
isAuthenticated() {
|
|
228
237
|
return !!this.currentToken || this.useCookieAuth && !!this.currentUser;
|
|
229
238
|
}
|
|
@@ -237,25 +246,25 @@ class F {
|
|
|
237
246
|
return this.tokenManager.getTenantId();
|
|
238
247
|
}
|
|
239
248
|
hasRole(e) {
|
|
240
|
-
var t,
|
|
241
|
-
return ((
|
|
249
|
+
var t, s;
|
|
250
|
+
return ((s = (t = this.currentUser) == null ? void 0 : t.roles) == null ? void 0 : s.includes(e)) || !1;
|
|
242
251
|
}
|
|
243
252
|
getAuthHeaders(e = {}) {
|
|
244
|
-
const t = typeof (e == null ? void 0 : e.entries) == "function" || Array.isArray(e) ? Object.fromEntries(new Headers(e)) : { ...e },
|
|
245
|
-
for (const
|
|
246
|
-
(
|
|
247
|
-
return this.currentToken && (t.Authorization = this.currentToken.startsWith("Bearer ") ? this.currentToken : `Bearer ${this.currentToken}`),
|
|
253
|
+
const t = typeof (e == null ? void 0 : e.entries) == "function" || Array.isArray(e) ? Object.fromEntries(new Headers(e)) : { ...e }, s = this.tokenManager.getWorkspaceId();
|
|
254
|
+
for (const n of Object.keys(t))
|
|
255
|
+
(n.toLowerCase() === "authorization" || s && n.toLowerCase() === "x-workspace-id") && delete t[n];
|
|
256
|
+
return this.currentToken && (t.Authorization = this.currentToken.startsWith("Bearer ") ? this.currentToken : `Bearer ${this.currentToken}`), s && (t["X-Workspace-Id"] = s), t;
|
|
248
257
|
}
|
|
249
258
|
getRequestOptions(e = {}) {
|
|
250
|
-
var
|
|
259
|
+
var s;
|
|
251
260
|
if (!this.useCookieAuth) return { ...e };
|
|
252
|
-
const t = typeof ((
|
|
261
|
+
const t = typeof ((s = e.headers) == null ? void 0 : s.entries) == "function" || Array.isArray(e.headers) ? Object.fromEntries(new Headers(e.headers)) : { ...e.headers };
|
|
253
262
|
if (["POST", "PUT", "PATCH", "DELETE"].includes((e.method || "GET").toUpperCase()) && typeof document < "u") {
|
|
254
|
-
const
|
|
255
|
-
if (
|
|
263
|
+
const n = document.cookie.split(/;\s*/).find((r) => r.startsWith("sm_csrf="));
|
|
264
|
+
if (n) {
|
|
256
265
|
for (const r of Object.keys(t))
|
|
257
266
|
r.toLowerCase() === "x-csrf-token" && delete t[r];
|
|
258
|
-
t["x-csrf-token"] = decodeURIComponent(
|
|
267
|
+
t["x-csrf-token"] = decodeURIComponent(n.slice(8));
|
|
259
268
|
}
|
|
260
269
|
}
|
|
261
270
|
return { credentials: "include", ...e, headers: t };
|
|
@@ -275,8 +284,8 @@ class F {
|
|
|
275
284
|
this.listeners.forEach((t) => {
|
|
276
285
|
try {
|
|
277
286
|
t(e);
|
|
278
|
-
} catch (
|
|
279
|
-
console.error("Auth listener error:",
|
|
287
|
+
} catch (s) {
|
|
288
|
+
console.error("Auth listener error:", s);
|
|
280
289
|
}
|
|
281
290
|
});
|
|
282
291
|
}
|
|
@@ -324,11 +333,11 @@ class F {
|
|
|
324
333
|
let t = await fetch(
|
|
325
334
|
e,
|
|
326
335
|
this.getRequestOptions({ method: "GET", headers: this.getAuthHeaders() })
|
|
327
|
-
),
|
|
336
|
+
), s = !1;
|
|
328
337
|
if (!t.ok && (this.currentToken || this.tokenManager.getWorkspaceId()) && (t = await fetch(
|
|
329
338
|
e,
|
|
330
339
|
this.getRequestOptions({ method: "GET", headers: {} })
|
|
331
|
-
),
|
|
340
|
+
), s = t.ok), !t.ok && t.status === 401 && this.refreshManager)
|
|
332
341
|
try {
|
|
333
342
|
await this.refreshManager.refresh(), t = await fetch(
|
|
334
343
|
e,
|
|
@@ -337,10 +346,10 @@ class F {
|
|
|
337
346
|
} catch {
|
|
338
347
|
}
|
|
339
348
|
if (!t.ok) return !1;
|
|
340
|
-
const
|
|
341
|
-
this.currentUser =
|
|
342
|
-
const r = (
|
|
343
|
-
return i && (this.tokenManager.setWorkspaceId(i), this.tokenManager.setTenantId((
|
|
349
|
+
const n = await t.json();
|
|
350
|
+
this.currentUser = n, this.tokenManager.setUser(n);
|
|
351
|
+
const r = (n == null ? void 0 : n.default_workspace_id) || (n == null ? void 0 : n.default_team_id) || null, i = r || this.tokenManager.getWorkspaceId() || null;
|
|
352
|
+
return i && (this.tokenManager.setWorkspaceId(i), this.tokenManager.setTenantId((n == null ? void 0 : n.tenant_id) || i)), s && (this.tokenManager.setAccessToken(null), this.currentToken = null, r && this.tokenManager.setWorkspaceId(r)), this.notifyListeners(), !0;
|
|
344
353
|
} catch {
|
|
345
354
|
return !1;
|
|
346
355
|
}
|
|
@@ -355,8 +364,8 @@ class _ extends Error {
|
|
|
355
364
|
* @param {number} [status=0] - HTTP status code (0 for network errors)
|
|
356
365
|
* @param {Object|null} [detail=null] - Error detail from API response
|
|
357
366
|
*/
|
|
358
|
-
constructor(e, t = 0,
|
|
359
|
-
super(e), this.name = "APIError", this.status = t, this.detail =
|
|
367
|
+
constructor(e, t = 0, s = null) {
|
|
368
|
+
super(e), this.name = "APIError", this.status = t, this.detail = s;
|
|
360
369
|
}
|
|
361
370
|
}
|
|
362
371
|
function q(a) {
|
|
@@ -365,13 +374,17 @@ function q(a) {
|
|
|
365
374
|
function L(a) {
|
|
366
375
|
return (a == null ? void 0 : a.name) === "AbortError";
|
|
367
376
|
}
|
|
368
|
-
class
|
|
377
|
+
class B {
|
|
369
378
|
/**
|
|
370
379
|
* @param {import('../auth/AuthCore.js').AuthCore} authCore
|
|
371
380
|
* @param {{ fetchFn?: typeof globalThis.fetch }} [options]
|
|
372
381
|
*/
|
|
373
382
|
constructor(e, { fetchFn: t } = {}) {
|
|
374
|
-
this.auth = e, this.
|
|
383
|
+
this.auth = e, this._customFetchFn = t || null;
|
|
384
|
+
}
|
|
385
|
+
/** Resolved per request so function-form auth base URLs stay live. */
|
|
386
|
+
get baseURL() {
|
|
387
|
+
return this.auth.apiBaseUrl;
|
|
375
388
|
}
|
|
376
389
|
get fetchFn() {
|
|
377
390
|
return this._customFetchFn || globalThis.fetch.bind(globalThis);
|
|
@@ -387,19 +400,19 @@ class W {
|
|
|
387
400
|
* @param {RequestInit & { signal?: AbortSignal }} [options]
|
|
388
401
|
*/
|
|
389
402
|
async request(e, t = {}) {
|
|
390
|
-
const
|
|
403
|
+
const s = `${this.baseURL}${e}`, n = {
|
|
391
404
|
...q(t.body) ? {} : { "Content-Type": "application/json" },
|
|
392
405
|
...this.auth.getAuthHeaders(t.headers)
|
|
393
|
-
}, r = this.auth.getRequestOptions({ ...t, headers:
|
|
406
|
+
}, r = this.auth.getRequestOptions({ ...t, headers: n });
|
|
394
407
|
try {
|
|
395
408
|
const i = await T(this.auth, (o) => this.fetchFn(
|
|
396
|
-
|
|
409
|
+
s,
|
|
397
410
|
this.auth.getRequestOptions({
|
|
398
411
|
...r,
|
|
399
|
-
headers: this.auth.getAuthHeaders(
|
|
412
|
+
headers: this.auth.getAuthHeaders(n),
|
|
400
413
|
...o ? { __isRetry: !0 } : {}
|
|
401
414
|
})
|
|
402
|
-
), { source:
|
|
415
|
+
), { source: s, signal: t.signal, retry: !t.__isRetry });
|
|
403
416
|
if (i.status === 401)
|
|
404
417
|
throw new _("Authentication required", 401, "auth_expired");
|
|
405
418
|
if (i.status === 204)
|
|
@@ -414,27 +427,27 @@ class W {
|
|
|
414
427
|
async get(e, t = {}) {
|
|
415
428
|
return this.request(e, { ...t, method: "GET" });
|
|
416
429
|
}
|
|
417
|
-
async post(e, t,
|
|
430
|
+
async post(e, t, s = {}) {
|
|
418
431
|
return this.request(e, {
|
|
419
|
-
...
|
|
432
|
+
...s,
|
|
420
433
|
method: "POST",
|
|
421
434
|
body: JSON.stringify(t)
|
|
422
435
|
});
|
|
423
436
|
}
|
|
424
437
|
async requestBinary(e, t = {}) {
|
|
425
|
-
const
|
|
438
|
+
const s = `${this.baseURL}${e}`, n = {
|
|
426
439
|
...q(t.body) ? {} : { "Content-Type": "application/json" },
|
|
427
440
|
...this.auth.getAuthHeaders(t.headers)
|
|
428
|
-
}, r = this.auth.getRequestOptions({ ...t, headers:
|
|
441
|
+
}, r = this.auth.getRequestOptions({ ...t, headers: n });
|
|
429
442
|
try {
|
|
430
443
|
const i = await T(this.auth, (o) => this.fetchFn(
|
|
431
|
-
|
|
444
|
+
s,
|
|
432
445
|
this.auth.getRequestOptions({
|
|
433
446
|
...r,
|
|
434
|
-
headers: this.auth.getAuthHeaders(
|
|
447
|
+
headers: this.auth.getAuthHeaders(n),
|
|
435
448
|
...o ? { __isRetry: !0 } : {}
|
|
436
449
|
})
|
|
437
|
-
), { source:
|
|
450
|
+
), { source: s, signal: t.signal, retry: !t.__isRetry });
|
|
438
451
|
if (i.status === 401)
|
|
439
452
|
throw new _("Authentication required", 401, "auth_expired");
|
|
440
453
|
if (!i.ok)
|
|
@@ -444,23 +457,23 @@ class W {
|
|
|
444
457
|
throw i.recoverable === !1 ? new _("Authentication required", 401, "auth_expired") : i instanceof _ || i.name === "SessionRefreshError" || L(i) ? i : new _(i.message, 0, "network_error");
|
|
445
458
|
}
|
|
446
459
|
}
|
|
447
|
-
async postForm(e, t,
|
|
460
|
+
async postForm(e, t, s = {}) {
|
|
448
461
|
return this.request(e, {
|
|
449
|
-
...
|
|
462
|
+
...s,
|
|
450
463
|
method: "POST",
|
|
451
464
|
body: t
|
|
452
465
|
});
|
|
453
466
|
}
|
|
454
|
-
async put(e, t,
|
|
467
|
+
async put(e, t, s = {}) {
|
|
455
468
|
return this.request(e, {
|
|
456
|
-
...
|
|
469
|
+
...s,
|
|
457
470
|
method: "PUT",
|
|
458
471
|
body: JSON.stringify(t)
|
|
459
472
|
});
|
|
460
473
|
}
|
|
461
|
-
async patch(e, t,
|
|
474
|
+
async patch(e, t, s = {}) {
|
|
462
475
|
return this.request(e, {
|
|
463
|
-
...
|
|
476
|
+
...s,
|
|
464
477
|
method: "PATCH",
|
|
465
478
|
body: JSON.stringify(t)
|
|
466
479
|
});
|
|
@@ -470,11 +483,11 @@ class W {
|
|
|
470
483
|
}
|
|
471
484
|
/** @private */
|
|
472
485
|
async _handleError(e) {
|
|
473
|
-
var
|
|
486
|
+
var n, r;
|
|
474
487
|
let t;
|
|
475
|
-
const
|
|
488
|
+
const s = (r = (n = e.headers) == null ? void 0 : n.get) == null ? void 0 : r.call(n, "content-type");
|
|
476
489
|
try {
|
|
477
|
-
|
|
490
|
+
s != null && s.includes("application/json") ? t = await e.json() : t = { message: await e.text() };
|
|
478
491
|
} catch {
|
|
479
492
|
t = { message: `HTTP ${e.status}` };
|
|
480
493
|
}
|
|
@@ -497,18 +510,18 @@ class W {
|
|
|
497
510
|
* @private
|
|
498
511
|
*/
|
|
499
512
|
_extractMessage(e, t) {
|
|
500
|
-
var
|
|
501
|
-
const
|
|
502
|
-
if (typeof
|
|
503
|
-
if (
|
|
504
|
-
if (typeof
|
|
505
|
-
if (typeof
|
|
506
|
-
if (Array.isArray(
|
|
513
|
+
var n;
|
|
514
|
+
const s = e == null ? void 0 : e.detail;
|
|
515
|
+
if (typeof s == "string") return s;
|
|
516
|
+
if (s && typeof s == "object") {
|
|
517
|
+
if (typeof s.message == "string") return s.message;
|
|
518
|
+
if (typeof s.code == "string") return s.code;
|
|
519
|
+
if (Array.isArray(s) && typeof ((n = s[0]) == null ? void 0 : n.msg) == "string") return s[0].msg;
|
|
507
520
|
}
|
|
508
521
|
return typeof (e == null ? void 0 : e.message) == "string" ? e.message : `HTTP ${t}`;
|
|
509
522
|
}
|
|
510
523
|
}
|
|
511
|
-
class
|
|
524
|
+
class W {
|
|
512
525
|
constructor(e) {
|
|
513
526
|
this.api = e;
|
|
514
527
|
}
|
|
@@ -535,8 +548,8 @@ class B {
|
|
|
535
548
|
async create({
|
|
536
549
|
content: e,
|
|
537
550
|
memoryType: t = "semantic",
|
|
538
|
-
metadata:
|
|
539
|
-
usePipeline:
|
|
551
|
+
metadata: s = null,
|
|
552
|
+
usePipeline: n = !0,
|
|
540
553
|
profileName: r = null,
|
|
541
554
|
conversationContext: i = null,
|
|
542
555
|
embed: o = null
|
|
@@ -544,8 +557,8 @@ class B {
|
|
|
544
557
|
const c = {
|
|
545
558
|
content: e,
|
|
546
559
|
memory_type: t,
|
|
547
|
-
metadata:
|
|
548
|
-
use_pipeline:
|
|
560
|
+
metadata: s,
|
|
561
|
+
use_pipeline: n,
|
|
549
562
|
profile_name: r
|
|
550
563
|
};
|
|
551
564
|
return i != null && (c.conversation_context = i), o != null && (c.embed = o), this.api.post("/memory/add", c);
|
|
@@ -570,11 +583,11 @@ class B {
|
|
|
570
583
|
async update(e, t) {
|
|
571
584
|
return this.api.patch(`/memory/${encodeURIComponent(e)}`, t);
|
|
572
585
|
}
|
|
573
|
-
async supersede(e, { content: t, memoryType:
|
|
586
|
+
async supersede(e, { content: t, memoryType: s, metadata: n = {}, reason: r }) {
|
|
574
587
|
return this.api.post(`/memory/${encodeURIComponent(e)}/supersede`, {
|
|
575
588
|
content: t,
|
|
576
|
-
memory_type:
|
|
577
|
-
metadata:
|
|
589
|
+
memory_type: s,
|
|
590
|
+
metadata: n,
|
|
578
591
|
reason: r
|
|
579
592
|
});
|
|
580
593
|
}
|
|
@@ -594,10 +607,10 @@ class B {
|
|
|
594
607
|
* @throws 400 if `newItemId` equals `id`; 404 if either item is missing *or*
|
|
595
608
|
* out of scope (deliberately indistinguishable); 409 if the store declined.
|
|
596
609
|
*/
|
|
597
|
-
async supersedeLink(e, t,
|
|
610
|
+
async supersedeLink(e, t, s = null) {
|
|
598
611
|
return this.api.post(`/memory/${encodeURIComponent(e)}/supersede-link`, {
|
|
599
612
|
new_item_id: t,
|
|
600
|
-
reason:
|
|
613
|
+
reason: s
|
|
601
614
|
});
|
|
602
615
|
}
|
|
603
616
|
async delete(e) {
|
|
@@ -623,13 +636,13 @@ class B {
|
|
|
623
636
|
async list({
|
|
624
637
|
limit: e = 50,
|
|
625
638
|
offset: t = 0,
|
|
626
|
-
type:
|
|
627
|
-
metadataKey:
|
|
639
|
+
type: s = null,
|
|
640
|
+
metadataKey: n = null,
|
|
628
641
|
metadataValue: r = null,
|
|
629
642
|
includeGrounding: i = null
|
|
630
643
|
} = {}) {
|
|
631
644
|
const o = new URLSearchParams({ limit: e, offset: t });
|
|
632
|
-
return
|
|
645
|
+
return s != null && o.append("memory_type", s), n != null && o.append("metadata_key", n), r != null && o.append("metadata_value", r), i != null && o.append("include_grounding", i), this.api.get(`/memory/list?${o}`);
|
|
633
646
|
}
|
|
634
647
|
/**
|
|
635
648
|
* Search for memory items.
|
|
@@ -697,8 +710,8 @@ class B {
|
|
|
697
710
|
* hopStrategy: consensus follows entities several top results agree on; relevance follows
|
|
698
711
|
* best-result entities and one-off bridges; semantic asks an LLM. Omitted preserves core default.
|
|
699
712
|
* since/until: ISO strings or Dates bounding created_at in [since, until), independent of asOfDate. */
|
|
700
|
-
async search(e, { topK: t = 5, enableHybrid:
|
|
701
|
-
const l = { query: e, top_k: t, enable_hybrid:
|
|
713
|
+
async search(e, { topK: t = 5, enableHybrid: s = !0, memoryType: n = null, expertise: r = !1, cite: i = !1, decompose: o = !1, multiHop: c = !1, maxHops: u = 3, budgetMs: y = 1500, semanticHops: h = !1, includeReference: d = !1, includeConsolidated: $ = !1, consolidationFirst: k = !1, asOfDate: g = null, asOfStrict: p = !1, includeSuperseded: I = !1, includeRetracted: b = !1, includeArchived: v = !1, excludeSpeculative: m = !1, since: E = null, until: M = null, hopStrategy: A = null, channelWeights: S = null, reranker: C = null } = {}) {
|
|
714
|
+
const l = { query: e, top_k: t, enable_hybrid: s };
|
|
702
715
|
if (S != null) {
|
|
703
716
|
const R = /* @__PURE__ */ new Set(["entity-graph", "ssg-traversal", "semantic", "regex-text", "lexical", "spreading-activation", "facts", "structural-semantic"]);
|
|
704
717
|
for (const f of Object.keys(S)) {
|
|
@@ -711,7 +724,7 @@ class B {
|
|
|
711
724
|
C != null && (l.reranker = C);
|
|
712
725
|
for (const [R, f] of Object.entries({ since: E, until: M }))
|
|
713
726
|
f != null && (l[R] = f instanceof Date ? f.toISOString() : f);
|
|
714
|
-
return
|
|
727
|
+
return n && (l.memory_type = n), r && (l.expertise = !0), i && (l.cite = !0), o && (l.decompose = !0), A != null && (l.hop_strategy = A), c && (l.multi_hop = !0), c && u !== 3 && (l.max_hops = u), c && y !== 1500 && (l.budget_ms = y), c && h && (l.semantic_hops = !0), d && (l.include_reference = !0), $ && (l.include_consolidated = !0), k && (l.consolidation_first = !0), g && (l.as_of_date = g instanceof Date ? g.toISOString() : g), p && (l.as_of_strict = !0), I && (l.include_superseded = !0), b && (l.include_retracted = !0), v && (l.include_archived = !0), m && (l.exclude_speculative = !0), this.api.post("/memory/search", l);
|
|
715
728
|
}
|
|
716
729
|
/**
|
|
717
730
|
* Ask a question and get a written answer plus the evidence behind it (DIST-LITE-9).
|
|
@@ -736,9 +749,9 @@ class B {
|
|
|
736
749
|
* Relation rows carry both display labels and graph node ids; combine them as
|
|
737
750
|
* `${source_id}->${target_id}:${type}` to address the edge in a graph view.
|
|
738
751
|
*/
|
|
739
|
-
async ask(e, { limit: t = 5, reasoning:
|
|
740
|
-
const
|
|
741
|
-
return
|
|
752
|
+
async ask(e, { limit: t = 5, reasoning: s = !0 } = {}) {
|
|
753
|
+
const n = { question: e, limit: t };
|
|
754
|
+
return s !== !0 && (n.reasoning = s), this.api.post("/memory/ask", n);
|
|
742
755
|
}
|
|
743
756
|
/**
|
|
744
757
|
* Get the complete audit answer for one memory (PLAT-AUDITABLE-MEMORY-1).
|
|
@@ -756,28 +769,28 @@ class B {
|
|
|
756
769
|
async explain(e) {
|
|
757
770
|
return this.api.get(`/memory/${encodeURIComponent(e)}/explain`);
|
|
758
771
|
}
|
|
759
|
-
async getWorkingContext(e, t, { k:
|
|
772
|
+
async getWorkingContext(e, t, { k: s = 20, maxTokens: n = null, strategy: r = null } = {}) {
|
|
760
773
|
const i = {
|
|
761
774
|
session_id: e,
|
|
762
775
|
query: t,
|
|
763
|
-
k:
|
|
776
|
+
k: s
|
|
764
777
|
};
|
|
765
|
-
return
|
|
778
|
+
return n != null && (i.max_tokens = n), r != null && (i.strategy = r), this.api.post("/memory/context", i);
|
|
766
779
|
}
|
|
767
|
-
async searchAdvanced(e, { algorithm: t = "query_traversal", maxResults:
|
|
780
|
+
async searchAdvanced(e, { algorithm: t = "query_traversal", maxResults: s = 15, useSSG: n = !0 } = {}) {
|
|
768
781
|
return this.api.post("/memory/search/advanced", {
|
|
769
782
|
query: e,
|
|
770
783
|
algorithm: t,
|
|
771
|
-
max_results:
|
|
772
|
-
use_ssg:
|
|
784
|
+
max_results: s,
|
|
785
|
+
use_ssg: n
|
|
773
786
|
});
|
|
774
787
|
}
|
|
775
|
-
async ingest(e, { profileName: t = null, extractorName:
|
|
788
|
+
async ingest(e, { profileName: t = null, extractorName: s = "llm", context: n = {} } = {}) {
|
|
776
789
|
return this.api.post("/memory/ingest", {
|
|
777
790
|
content: e,
|
|
778
791
|
profile_name: t,
|
|
779
|
-
extractor_name:
|
|
780
|
-
context:
|
|
792
|
+
extractor_name: s,
|
|
793
|
+
context: n
|
|
781
794
|
});
|
|
782
795
|
}
|
|
783
796
|
async getLineage(e) {
|
|
@@ -795,15 +808,15 @@ class B {
|
|
|
795
808
|
* endpoints return slightly different item shapes, so migrate deliberately rather
|
|
796
809
|
* than by find-and-replace.
|
|
797
810
|
*/
|
|
798
|
-
async searchByMetadata(e, t, { memoryType:
|
|
811
|
+
async searchByMetadata(e, t, { memoryType: s = null, limit: n = 25, since: r = null, until: i = null } = {}) {
|
|
799
812
|
const o = new URLSearchParams({
|
|
800
813
|
metadata_key: e,
|
|
801
814
|
metadata_value: t,
|
|
802
|
-
limit:
|
|
815
|
+
limit: n
|
|
803
816
|
});
|
|
804
817
|
for (const [c, u] of Object.entries({ since: r, until: i }))
|
|
805
818
|
u != null && o.append(c, u instanceof Date ? u.toISOString() : u);
|
|
806
|
-
return
|
|
819
|
+
return s && o.append("memory_type", s), this.api.get(`/memory/by-metadata?${o}`);
|
|
807
820
|
}
|
|
808
821
|
async getNeighbors(e) {
|
|
809
822
|
return this.api.get(`/memory/${encodeURIComponent(e)}/neighbors`);
|
|
@@ -813,19 +826,19 @@ class B {
|
|
|
813
826
|
}
|
|
814
827
|
async ingestConversation(e, {
|
|
815
828
|
sessionBoundaries: t = null,
|
|
816
|
-
conversationId:
|
|
817
|
-
sessionDates:
|
|
829
|
+
conversationId: s = null,
|
|
830
|
+
sessionDates: n = null,
|
|
818
831
|
turnsPerChunk: r = 15,
|
|
819
832
|
maxChunkChars: i = 12e3,
|
|
820
833
|
maxConcurrent: o = 4,
|
|
821
834
|
context: c = null
|
|
822
835
|
} = {}) {
|
|
823
836
|
const u = { turns: e, turns_per_chunk: r, max_chunk_chars: i, max_concurrent: o };
|
|
824
|
-
return t && (u.session_boundaries = t),
|
|
837
|
+
return t && (u.session_boundaries = t), s && (u.conversation_id = s), n && (u.session_dates = n), c !== null && (u.context = c), this.api.post("/memory/ingest/conversation", u);
|
|
825
838
|
}
|
|
826
|
-
async ingestDocument(e, { title: t = null, source:
|
|
839
|
+
async ingestDocument(e, { title: t = null, source: s = null, chunkStrategy: n = null, context: r = null } = {}) {
|
|
827
840
|
const i = { content: e };
|
|
828
|
-
return t && (i.title = t),
|
|
841
|
+
return t && (i.title = t), s && (i.source = s), n && (i.chunk_strategy = n), r !== null && (i.context = r), this.api.post("/memory/ingest/document", i);
|
|
829
842
|
}
|
|
830
843
|
/**
|
|
831
844
|
* Import a ChatGPT or Claude conversation export (DIST-CHAT-IMPORT-1).
|
|
@@ -847,38 +860,38 @@ class B {
|
|
|
847
860
|
* `warnings` — a non-empty list means something was capped, skipped, or degraded
|
|
848
861
|
* even though the call succeeded.
|
|
849
862
|
*/
|
|
850
|
-
async importChatExport(e, { sourceFormat: t = "auto", maxConversations:
|
|
851
|
-
const
|
|
852
|
-
return
|
|
863
|
+
async importChatExport(e, { sourceFormat: t = "auto", maxConversations: s = 25 } = {}) {
|
|
864
|
+
const n = new FormData();
|
|
865
|
+
return n.append("file", e, e.name || "conversations.json"), n.append("source_format", t), n.append("max_conversations", String(s)), this.api.post("/memory/import/chat-export", n);
|
|
853
866
|
}
|
|
854
867
|
/** List supported chat-export formats and how a user obtains each export. */
|
|
855
868
|
async chatExportFormats() {
|
|
856
869
|
return this.api.get("/memory/import/chat-export/formats");
|
|
857
870
|
}
|
|
858
|
-
async codeIndex(e, { repo: t = null, commit:
|
|
859
|
-
const
|
|
860
|
-
return t && (
|
|
871
|
+
async codeIndex(e, { repo: t = null, commit: s = null } = {}) {
|
|
872
|
+
const n = { path: e };
|
|
873
|
+
return t && (n.repo = t), s && (n.commit = s), this.api.post("/memory/code/index", n);
|
|
861
874
|
}
|
|
862
|
-
async codeSearch(e, { entityType: t = null, repo:
|
|
863
|
-
const i = new URLSearchParams({ query: e, limit:
|
|
864
|
-
return t && i.append("entity_type", t),
|
|
875
|
+
async codeSearch(e, { entityType: t = null, repo: s = null, limit: n = 20, semantic: r = !1 } = {}) {
|
|
876
|
+
const i = new URLSearchParams({ query: e, limit: n, semantic: r });
|
|
877
|
+
return t && i.append("entity_type", t), s && i.append("repo", s), this.api.get(`/memory/code/search?${i}`);
|
|
865
878
|
}
|
|
866
879
|
async codeContext(e, { repo: t = null } = {}) {
|
|
867
|
-
const
|
|
868
|
-
return t &&
|
|
880
|
+
const s = new URLSearchParams({ entity_name: e });
|
|
881
|
+
return t && s.append("repo", t), this.api.get(`/memory/code/context?${s}`);
|
|
869
882
|
}
|
|
870
883
|
async codeDeadCode(e) {
|
|
871
884
|
return this.api.get(`/memory/code/dead-code?repo=${encodeURIComponent(e)}`);
|
|
872
885
|
}
|
|
873
|
-
async codeDependencies(e, { direction: t = "both", repo:
|
|
874
|
-
const
|
|
875
|
-
return
|
|
886
|
+
async codeDependencies(e, { direction: t = "both", repo: s = null } = {}) {
|
|
887
|
+
const n = new URLSearchParams({ entity_name: e, direction: t });
|
|
888
|
+
return s && n.append("repo", s), this.api.get(`/memory/code/dependencies?${n}`);
|
|
876
889
|
}
|
|
877
890
|
async getPlan(e) {
|
|
878
891
|
return this.api.get(`/memory/plans/${e}`);
|
|
879
892
|
}
|
|
880
|
-
async updatePlanTask(e, { taskId: t, status:
|
|
881
|
-
return this.api.patch(`/memory/plans/${e}/task`, { task_id: t, status:
|
|
893
|
+
async updatePlanTask(e, { taskId: t, status: s }) {
|
|
894
|
+
return this.api.patch(`/memory/plans/${e}/task`, { task_id: t, status: s });
|
|
882
895
|
}
|
|
883
896
|
async completePlan(e, { graduate: t = !1 } = {}) {
|
|
884
897
|
return this.api.post(`/memory/plans/${e}/complete`, { graduate: t });
|
|
@@ -886,11 +899,11 @@ class B {
|
|
|
886
899
|
async failPlan(e, t) {
|
|
887
900
|
return this.api.post(`/memory/plans/${e}/fail`, { reason: t });
|
|
888
901
|
}
|
|
889
|
-
async link(e, t,
|
|
902
|
+
async link(e, t, s = "RELATED") {
|
|
890
903
|
return this.api.post("/memory/link", {
|
|
891
904
|
source_id: e,
|
|
892
905
|
target_id: t,
|
|
893
|
-
link_type:
|
|
906
|
+
link_type: s
|
|
894
907
|
});
|
|
895
908
|
}
|
|
896
909
|
async enrich(e, t = []) {
|
|
@@ -920,9 +933,9 @@ class B {
|
|
|
920
933
|
* @param {string} [query] - Original query that produced these results.
|
|
921
934
|
* @returns {Promise<{updated: number, edges_strengthened: number, outcome: string}>}
|
|
922
935
|
*/
|
|
923
|
-
async feedback(e, t,
|
|
924
|
-
const
|
|
925
|
-
return
|
|
936
|
+
async feedback(e, t, s = null) {
|
|
937
|
+
const n = { item_ids: e, outcome: t };
|
|
938
|
+
return s != null && (n.query = s), this.api.post("/memory/feedback", n);
|
|
926
939
|
}
|
|
927
940
|
/**
|
|
928
941
|
* Request grounding for a memory item.
|
|
@@ -930,40 +943,40 @@ class B {
|
|
|
930
943
|
* The endpoint currently returns HTTP 501 because
|
|
931
944
|
* CORE-GROUND-ROUTE-CONTRACT-1 is not implemented.
|
|
932
945
|
*/
|
|
933
|
-
async ground(e, t,
|
|
946
|
+
async ground(e, t, s = null) {
|
|
934
947
|
return this.api.post(`/memory/${encodeURIComponent(e)}/ground`, {
|
|
935
948
|
item_id: e,
|
|
936
949
|
source_url: t,
|
|
937
|
-
validation:
|
|
950
|
+
validation: s
|
|
938
951
|
});
|
|
939
952
|
}
|
|
940
953
|
async clearAll(e = !1) {
|
|
941
954
|
return this.api.delete(`/memory/clear-all?nuclear=${e}`);
|
|
942
955
|
}
|
|
943
956
|
// --- Temporal ---
|
|
944
|
-
async getHistory(e, { startTime: t = null, endTime:
|
|
945
|
-
let r = `/memory/temporal/${e}/history?limit=${
|
|
946
|
-
return t && (r += `&start_time=${t}`),
|
|
957
|
+
async getHistory(e, { startTime: t = null, endTime: s = null, limit: n = 100 } = {}) {
|
|
958
|
+
let r = `/memory/temporal/${e}/history?limit=${n}`;
|
|
959
|
+
return t && (r += `&start_time=${t}`), s && (r += `&end_time=${s}`), this.api.get(r);
|
|
947
960
|
}
|
|
948
|
-
async timeTravel(e, { query: t = null, limit:
|
|
949
|
-
let
|
|
950
|
-
return t && (
|
|
961
|
+
async timeTravel(e, { query: t = null, limit: s = 100 } = {}) {
|
|
962
|
+
let n = `/memory/temporal/at/${e}?limit=${s}`;
|
|
963
|
+
return t && (n += `&query=${encodeURIComponent(t)}`), this.api.get(n);
|
|
951
964
|
}
|
|
952
965
|
async getItemAtTime(e, t) {
|
|
953
966
|
return this.api.get(`/memory/temporal/${e}/at/${t}`);
|
|
954
967
|
}
|
|
955
|
-
async getChanges(e, { since: t = null, until:
|
|
968
|
+
async getChanges(e, { since: t = null, until: s = null, changeType: n = null } = {}) {
|
|
956
969
|
let r = `/memory/temporal/${e}/changes`;
|
|
957
970
|
const i = [];
|
|
958
|
-
return t && i.push(`since=${t}`),
|
|
971
|
+
return t && i.push(`since=${t}`), s && i.push(`until=${s}`), n && i.push(`change_type=${n}`), i.length && (r += `?${i.join("&")}`), this.api.get(r);
|
|
959
972
|
}
|
|
960
|
-
async compareVersions(e, t,
|
|
961
|
-
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${
|
|
973
|
+
async compareVersions(e, t, s) {
|
|
974
|
+
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${s}`);
|
|
962
975
|
}
|
|
963
|
-
async rollback(e, { toVersion: t = null, toTime:
|
|
964
|
-
let
|
|
976
|
+
async rollback(e, { toVersion: t = null, toTime: s = null } = {}) {
|
|
977
|
+
let n = `/memory/temporal/${e}/rollback`;
|
|
965
978
|
const r = [];
|
|
966
|
-
return t !== null && r.push(`to_version=${t}`),
|
|
979
|
+
return t !== null && r.push(`to_version=${t}`), s && r.push(`to_time=${s}`), r.length && (n += `?${r.join("&")}`), this.api.post(n);
|
|
967
980
|
}
|
|
968
981
|
// --- Clustering ---
|
|
969
982
|
async runClustering(e = 0.1, t = !1) {
|
|
@@ -995,8 +1008,8 @@ class K {
|
|
|
995
1008
|
async create({
|
|
996
1009
|
content: e,
|
|
997
1010
|
decisionType: t = "inference",
|
|
998
|
-
confidence:
|
|
999
|
-
sourceTraceId:
|
|
1011
|
+
confidence: s = 0.8,
|
|
1012
|
+
sourceTraceId: n = null,
|
|
1000
1013
|
sourceSessionId: r = null,
|
|
1001
1014
|
evidenceIds: i = null,
|
|
1002
1015
|
domain: o = null,
|
|
@@ -1009,8 +1022,8 @@ class K {
|
|
|
1009
1022
|
return this.api.post("/memory/decisions/create", {
|
|
1010
1023
|
content: e,
|
|
1011
1024
|
decision_type: t,
|
|
1012
|
-
confidence:
|
|
1013
|
-
source_trace_id:
|
|
1025
|
+
confidence: s,
|
|
1026
|
+
source_trace_id: n,
|
|
1014
1027
|
source_session_id: r,
|
|
1015
1028
|
evidence_ids: i,
|
|
1016
1029
|
domain: o,
|
|
@@ -1082,12 +1095,12 @@ class K {
|
|
|
1082
1095
|
* @param {string[]} [params.tags]
|
|
1083
1096
|
* @param {string} [params.agentId]
|
|
1084
1097
|
*/
|
|
1085
|
-
async createPending({ content: e, requirements: t, domain:
|
|
1098
|
+
async createPending({ content: e, requirements: t, domain: s = null, tags: n = null, agentId: r = null }) {
|
|
1086
1099
|
return this.api.post("/memory/decisions/pending/create", {
|
|
1087
1100
|
content: e,
|
|
1088
1101
|
requirements: t,
|
|
1089
|
-
domain:
|
|
1090
|
-
tags:
|
|
1102
|
+
domain: s,
|
|
1103
|
+
tags: n,
|
|
1091
1104
|
agent_id: r
|
|
1092
1105
|
});
|
|
1093
1106
|
}
|
|
@@ -1098,10 +1111,10 @@ class K {
|
|
|
1098
1111
|
* @param {string} params.requirementId
|
|
1099
1112
|
* @param {string} params.memoryId
|
|
1100
1113
|
*/
|
|
1101
|
-
async resolveRequirement(e, { requirementId: t, memoryId:
|
|
1114
|
+
async resolveRequirement(e, { requirementId: t, memoryId: s }) {
|
|
1102
1115
|
return this.api.post(`/memory/decisions/pending/${e}/resolve`, {
|
|
1103
1116
|
requirement_id: t,
|
|
1104
|
-
memory_id:
|
|
1117
|
+
memory_id: s
|
|
1105
1118
|
});
|
|
1106
1119
|
}
|
|
1107
1120
|
/**
|
|
@@ -1186,8 +1199,8 @@ class K {
|
|
|
1186
1199
|
* @param {string} [options.direction='both'] - causes|effects|both
|
|
1187
1200
|
* @param {number} [options.maxDepth=3]
|
|
1188
1201
|
*/
|
|
1189
|
-
async getCausalChain(e, { direction: t = "both", maxDepth:
|
|
1190
|
-
return this.api.get(`/memory/decisions/${e}/causal-chain?direction=${t}&max_depth=${
|
|
1202
|
+
async getCausalChain(e, { direction: t = "both", maxDepth: s = 3 } = {}) {
|
|
1203
|
+
return this.api.get(`/memory/decisions/${e}/causal-chain?direction=${t}&max_depth=${s}`);
|
|
1191
1204
|
}
|
|
1192
1205
|
/**
|
|
1193
1206
|
* Find existing decisions that may conflict with this one.
|
|
@@ -1239,8 +1252,8 @@ class H {
|
|
|
1239
1252
|
* server auto-populate from scope.resolve_agent_id().
|
|
1240
1253
|
*/
|
|
1241
1254
|
async createOpinion(e, t = {}) {
|
|
1242
|
-
const
|
|
1243
|
-
return t.confidence !== void 0 && (
|
|
1255
|
+
const s = { content: e };
|
|
1256
|
+
return t.confidence !== void 0 && (s.confidence = t.confidence), t.subject !== void 0 && (s.subject = t.subject), t.subjectType !== void 0 && (s.subject_type = t.subjectType), t.disposition !== void 0 && (s.disposition = t.disposition), t.formedFrom !== void 0 && (s.formed_from = t.formedFrom), t.domain !== void 0 && (s.domain = t.domain), t.agentId !== void 0 && (s.agent_id = t.agentId), this.api.post("/memory/opinions/create", s);
|
|
1244
1257
|
}
|
|
1245
1258
|
}
|
|
1246
1259
|
class D {
|
|
@@ -1255,12 +1268,12 @@ class D {
|
|
|
1255
1268
|
async getNeighbors(e, t = {}) {
|
|
1256
1269
|
return this.api.get(`/memory/${encodeURIComponent(e)}/neighbors`, t);
|
|
1257
1270
|
}
|
|
1258
|
-
async addEdge(e, t,
|
|
1271
|
+
async addEdge(e, t, s, n = {}) {
|
|
1259
1272
|
return this.api.post("/memory/edge", {
|
|
1260
1273
|
source_id: e,
|
|
1261
1274
|
target_id: t,
|
|
1262
|
-
relation_type:
|
|
1263
|
-
properties:
|
|
1275
|
+
relation_type: s,
|
|
1276
|
+
properties: n
|
|
1264
1277
|
});
|
|
1265
1278
|
}
|
|
1266
1279
|
/** @param {{ signal?: AbortSignal }} [options] */
|
|
@@ -1283,8 +1296,8 @@ class D {
|
|
|
1283
1296
|
* @param {number} [maxHops=5]
|
|
1284
1297
|
* @param {{ signal?: AbortSignal }} [options]
|
|
1285
1298
|
*/
|
|
1286
|
-
async findShortestPath(e, t,
|
|
1287
|
-
return this.api.get(`/memory/graph/path?start_id=${encodeURIComponent(e)}&end_id=${encodeURIComponent(t)}&max_hops=${
|
|
1299
|
+
async findShortestPath(e, t, s = 5, n = {}) {
|
|
1300
|
+
return this.api.get(`/memory/graph/path?start_id=${encodeURIComponent(e)}&end_id=${encodeURIComponent(t)}&max_hops=${s}`, n);
|
|
1288
1301
|
}
|
|
1289
1302
|
/**
|
|
1290
1303
|
* Fetch the full knowledge graph.
|
|
@@ -1301,9 +1314,9 @@ class D {
|
|
|
1301
1314
|
* @param {string[]} nodeIds
|
|
1302
1315
|
* @param {{ includeProperties?: boolean, signal?: AbortSignal }} [options]
|
|
1303
1316
|
*/
|
|
1304
|
-
async getEdgesBulk(e, { includeProperties: t = !1, signal:
|
|
1305
|
-
const
|
|
1306
|
-
return this.api.post(`/memory/graph/edges${
|
|
1317
|
+
async getEdgesBulk(e, { includeProperties: t = !1, signal: s } = {}) {
|
|
1318
|
+
const n = t ? "?include_properties=true" : "";
|
|
1319
|
+
return this.api.post(`/memory/graph/edges${n}`, { node_ids: e }, s ? { signal: s } : {});
|
|
1307
1320
|
}
|
|
1308
1321
|
/**
|
|
1309
1322
|
* Bulk upsert graph nodes and edges, optionally replacing a node-ID prefix.
|
|
@@ -1312,9 +1325,9 @@ class D {
|
|
|
1312
1325
|
* @param {Array<Object>} [params.edges=[]] - Edges with source_id, target_id, edge_type, and properties.
|
|
1313
1326
|
* @param {string|null} [params.deletePrefix=null] - Scoped node-ID prefix to delete before writing.
|
|
1314
1327
|
*/
|
|
1315
|
-
async bulkUpsert({ nodes: e = [], edges: t = [], deletePrefix:
|
|
1316
|
-
const
|
|
1317
|
-
return
|
|
1328
|
+
async bulkUpsert({ nodes: e = [], edges: t = [], deletePrefix: s = null } = {}) {
|
|
1329
|
+
const n = { nodes: e, edges: t };
|
|
1330
|
+
return s !== null && (n.delete_prefix = s), this.api.post("/memory/graph/bulk", n);
|
|
1318
1331
|
}
|
|
1319
1332
|
/**
|
|
1320
1333
|
* Get Wikipedia grounding status for an entity node.
|
|
@@ -1400,12 +1413,12 @@ class G {
|
|
|
1400
1413
|
const t = e ? "?include_system=true" : "";
|
|
1401
1414
|
return this.api.get(`/memory/teams${t}`);
|
|
1402
1415
|
}
|
|
1403
|
-
async create({ name: e, description: t = null, dataClassification:
|
|
1416
|
+
async create({ name: e, description: t = null, dataClassification: s = "internal", costCenter: n = null, isSystem: r = !1 }) {
|
|
1404
1417
|
const i = {
|
|
1405
1418
|
name: e,
|
|
1406
1419
|
description: t,
|
|
1407
|
-
data_classification:
|
|
1408
|
-
cost_center:
|
|
1420
|
+
data_classification: s,
|
|
1421
|
+
cost_center: n
|
|
1409
1422
|
};
|
|
1410
1423
|
return r && (i.is_system = !0), this.api.post("/memory/teams", i);
|
|
1411
1424
|
}
|
|
@@ -1421,14 +1434,14 @@ class G {
|
|
|
1421
1434
|
async getMembers(e) {
|
|
1422
1435
|
return this.api.get(`/memory/teams/${e}/members`);
|
|
1423
1436
|
}
|
|
1424
|
-
async addMember(e, t,
|
|
1437
|
+
async addMember(e, t, s = "member") {
|
|
1425
1438
|
return this.api.post(`/memory/teams/${e}/members`, {
|
|
1426
1439
|
user_id: t,
|
|
1427
|
-
role:
|
|
1440
|
+
role: s
|
|
1428
1441
|
});
|
|
1429
1442
|
}
|
|
1430
|
-
async updateMember(e, t,
|
|
1431
|
-
return this.api.patch(`/memory/teams/${e}/members/${t}`, { role:
|
|
1443
|
+
async updateMember(e, t, s) {
|
|
1444
|
+
return this.api.patch(`/memory/teams/${e}/members/${t}`, { role: s });
|
|
1432
1445
|
}
|
|
1433
1446
|
async removeMember(e, t) {
|
|
1434
1447
|
return this.api.delete(`/memory/teams/${e}/members/${t}`);
|
|
@@ -1441,17 +1454,17 @@ class N {
|
|
|
1441
1454
|
async list() {
|
|
1442
1455
|
return this.api.get("/memory/workspaces");
|
|
1443
1456
|
}
|
|
1444
|
-
async create({ name: e, teamId: t, description:
|
|
1457
|
+
async create({ name: e, teamId: t, description: s = null }) {
|
|
1445
1458
|
return this.api.post("/memory/workspaces", {
|
|
1446
1459
|
name: e,
|
|
1447
|
-
description:
|
|
1460
|
+
description: s,
|
|
1448
1461
|
team_id: t
|
|
1449
1462
|
});
|
|
1450
1463
|
}
|
|
1451
|
-
async share(e, { teamId: t, permission:
|
|
1464
|
+
async share(e, { teamId: t, permission: s }) {
|
|
1452
1465
|
return this.api.post(`/memory/workspaces/${encodeURIComponent(e)}/share`, {
|
|
1453
1466
|
team_id: t,
|
|
1454
|
-
permission:
|
|
1467
|
+
permission: s
|
|
1455
1468
|
});
|
|
1456
1469
|
}
|
|
1457
1470
|
async revoke(e, t) {
|
|
@@ -1518,11 +1531,11 @@ class Y {
|
|
|
1518
1531
|
async getCurrentUser() {
|
|
1519
1532
|
return this.api.get("/auth/me");
|
|
1520
1533
|
}
|
|
1521
|
-
async createAPIKey(e, t,
|
|
1534
|
+
async createAPIKey(e, t, s = null) {
|
|
1522
1535
|
return this.api.post("/memory/api-keys", {
|
|
1523
1536
|
name: e,
|
|
1524
1537
|
scopes: t,
|
|
1525
|
-
expires_in_days:
|
|
1538
|
+
expires_in_days: s
|
|
1526
1539
|
});
|
|
1527
1540
|
}
|
|
1528
1541
|
async listAPIKeys() {
|
|
@@ -1539,12 +1552,12 @@ class X {
|
|
|
1539
1552
|
async list() {
|
|
1540
1553
|
return this.api.get("/memory/agents");
|
|
1541
1554
|
}
|
|
1542
|
-
async create({ name: e, description: t = null, agentConfig:
|
|
1555
|
+
async create({ name: e, description: t = null, agentConfig: s = {}, roles: n = ["user"] }) {
|
|
1543
1556
|
return this.api.post("/memory/agents", {
|
|
1544
1557
|
name: e,
|
|
1545
1558
|
description: t,
|
|
1546
|
-
agent_config:
|
|
1547
|
-
roles:
|
|
1559
|
+
agent_config: s,
|
|
1560
|
+
roles: n
|
|
1548
1561
|
});
|
|
1549
1562
|
}
|
|
1550
1563
|
async get(e) {
|
|
@@ -1570,9 +1583,9 @@ class X {
|
|
|
1570
1583
|
* @param {string} domain - Domain string (e.g. "python").
|
|
1571
1584
|
* @returns {Promise<{evaluation: object|null}>}
|
|
1572
1585
|
*/
|
|
1573
|
-
async getEvaluation(e, t,
|
|
1574
|
-
const
|
|
1575
|
-
return this.api.get(`/memory/agents/${e}/evaluation${
|
|
1586
|
+
async getEvaluation(e, t, s) {
|
|
1587
|
+
const n = new URLSearchParams({ dimension: t, domain: s }).toString();
|
|
1588
|
+
return this.api.get(`/memory/agents/${e}/evaluation${n ? "?" + n : ""}`);
|
|
1576
1589
|
}
|
|
1577
1590
|
/**
|
|
1578
1591
|
* Get evaluation history for an agent on a given (dimension, domain) slot.
|
|
@@ -1586,8 +1599,8 @@ class X {
|
|
|
1586
1599
|
* @param {number} [options.limit=20] - Maximum records to return.
|
|
1587
1600
|
* @returns {Promise<{history: object[]}>}
|
|
1588
1601
|
*/
|
|
1589
|
-
async listEvaluationHistory(e, t,
|
|
1590
|
-
const r = new URLSearchParams({ dimension: t, domain:
|
|
1602
|
+
async listEvaluationHistory(e, t, s, { limit: n = 20 } = {}) {
|
|
1603
|
+
const r = new URLSearchParams({ dimension: t, domain: s, limit: String(n) }).toString();
|
|
1591
1604
|
return this.api.get(`/memory/agents/${e}/evaluation/history${r ? "?" + r : ""}`);
|
|
1592
1605
|
}
|
|
1593
1606
|
}
|
|
@@ -1658,9 +1671,9 @@ class te {
|
|
|
1658
1671
|
* @param {string} [options.endTime] - ISO end time
|
|
1659
1672
|
* @param {number} [options.limit=100]
|
|
1660
1673
|
*/
|
|
1661
|
-
async getHistory(e, { startTime: t = null, endTime:
|
|
1662
|
-
let r = `/memory/temporal/${e}/history?limit=${
|
|
1663
|
-
return t && (r += `&start_time=${t}`),
|
|
1674
|
+
async getHistory(e, { startTime: t = null, endTime: s = null, limit: n = 100 } = {}) {
|
|
1675
|
+
let r = `/memory/temporal/${e}/history?limit=${n}`;
|
|
1676
|
+
return t && (r += `&start_time=${t}`), s && (r += `&end_time=${s}`), this.api.get(r);
|
|
1664
1677
|
}
|
|
1665
1678
|
// === TIME-TRAVEL QUERIES ===
|
|
1666
1679
|
/**
|
|
@@ -1670,9 +1683,9 @@ class te {
|
|
|
1670
1683
|
* @param {string} [options.query]
|
|
1671
1684
|
* @param {number} [options.limit=100]
|
|
1672
1685
|
*/
|
|
1673
|
-
async timeTravel(e, { query: t = null, limit:
|
|
1674
|
-
let
|
|
1675
|
-
return t && (
|
|
1686
|
+
async timeTravel(e, { query: t = null, limit: s = 100 } = {}) {
|
|
1687
|
+
let n = `/memory/temporal/at/${e}?limit=${s}`;
|
|
1688
|
+
return t && (n += `&query=${encodeURIComponent(t)}`), this.api.get(n);
|
|
1676
1689
|
}
|
|
1677
1690
|
/**
|
|
1678
1691
|
* Get specific item as it existed at timestamp.
|
|
@@ -1691,10 +1704,10 @@ class te {
|
|
|
1691
1704
|
* @param {string} [options.until]
|
|
1692
1705
|
* @param {string} [options.changeType]
|
|
1693
1706
|
*/
|
|
1694
|
-
async getChanges(e, { since: t = null, until:
|
|
1707
|
+
async getChanges(e, { since: t = null, until: s = null, changeType: n = null } = {}) {
|
|
1695
1708
|
let r = `/memory/temporal/${e}/changes`;
|
|
1696
1709
|
const i = [];
|
|
1697
|
-
return t && i.push(`since=${t}`),
|
|
1710
|
+
return t && i.push(`since=${t}`), s && i.push(`until=${s}`), n && i.push(`change_type=${n}`), i.length && (r += `?${i.join("&")}`), this.api.get(r);
|
|
1698
1711
|
}
|
|
1699
1712
|
// === VERSION COMPARISON ===
|
|
1700
1713
|
/**
|
|
@@ -1703,8 +1716,8 @@ class te {
|
|
|
1703
1716
|
* @param {number} v1
|
|
1704
1717
|
* @param {number} v2
|
|
1705
1718
|
*/
|
|
1706
|
-
async compareVersions(e, t,
|
|
1707
|
-
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${
|
|
1719
|
+
async compareVersions(e, t, s) {
|
|
1720
|
+
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${s}`);
|
|
1708
1721
|
}
|
|
1709
1722
|
// === ROLLBACK ===
|
|
1710
1723
|
/**
|
|
@@ -1714,10 +1727,10 @@ class te {
|
|
|
1714
1727
|
* @param {number} [options.toVersion]
|
|
1715
1728
|
* @param {string} [options.toTime]
|
|
1716
1729
|
*/
|
|
1717
|
-
async rollback(e, { toVersion: t = null, toTime:
|
|
1718
|
-
let
|
|
1730
|
+
async rollback(e, { toVersion: t = null, toTime: s = null } = {}) {
|
|
1731
|
+
let n = `/memory/temporal/${e}/rollback`;
|
|
1719
1732
|
const r = [];
|
|
1720
|
-
return t !== null && r.push(`to_version=${t}`),
|
|
1733
|
+
return t !== null && r.push(`to_version=${t}`), s && r.push(`to_time=${s}`), r.length && (n += `?${r.join("&")}`), this.api.post(n);
|
|
1721
1734
|
}
|
|
1722
1735
|
// === AUDIT TRAIL ===
|
|
1723
1736
|
/**
|
|
@@ -1729,10 +1742,10 @@ class te {
|
|
|
1729
1742
|
* @param {string} [options.startTime]
|
|
1730
1743
|
* @param {string} [options.endTime]
|
|
1731
1744
|
*/
|
|
1732
|
-
async getAuditTrail(e, { changeType: t = null, userId:
|
|
1745
|
+
async getAuditTrail(e, { changeType: t = null, userId: s = null, startTime: n = null, endTime: r = null } = {}) {
|
|
1733
1746
|
let i = `/memory/temporal/${e}/audit`;
|
|
1734
1747
|
const o = [];
|
|
1735
|
-
return t && o.push(`change_type=${t}`),
|
|
1748
|
+
return t && o.push(`change_type=${t}`), s && o.push(`user_id=${s}`), n && o.push(`start_time=${n}`), r && o.push(`end_time=${r}`), o.length && (i += `?${o.join("&")}`), this.api.get(i);
|
|
1736
1749
|
}
|
|
1737
1750
|
// === TEMPORAL SEARCH ===
|
|
1738
1751
|
/**
|
|
@@ -1742,12 +1755,12 @@ class te {
|
|
|
1742
1755
|
* @param {string} endTime
|
|
1743
1756
|
* @param {number} [limit=100]
|
|
1744
1757
|
*/
|
|
1745
|
-
async searchDuringRange(e, t,
|
|
1758
|
+
async searchDuringRange(e, t, s, n = 100) {
|
|
1746
1759
|
const r = new URLSearchParams({
|
|
1747
1760
|
query: e,
|
|
1748
1761
|
start_time: t,
|
|
1749
|
-
end_time:
|
|
1750
|
-
limit: String(
|
|
1762
|
+
end_time: s,
|
|
1763
|
+
limit: String(n)
|
|
1751
1764
|
}).toString();
|
|
1752
1765
|
return this.api.get(`/memory/temporal/search/during?${r}`);
|
|
1753
1766
|
}
|
|
@@ -1760,10 +1773,10 @@ class te {
|
|
|
1760
1773
|
* @param {string} [options.reportType='HIPAA']
|
|
1761
1774
|
* @param {string[]} [options.itemIds]
|
|
1762
1775
|
*/
|
|
1763
|
-
async complianceReport(e, t, { reportType:
|
|
1764
|
-
let r = `/memory/temporal/compliance/report?start_date=${e}&end_date=${t}&report_type=${
|
|
1765
|
-
if (
|
|
1766
|
-
for (const i of
|
|
1776
|
+
async complianceReport(e, t, { reportType: s = "HIPAA", itemIds: n = null } = {}) {
|
|
1777
|
+
let r = `/memory/temporal/compliance/report?start_date=${e}&end_date=${t}&report_type=${s}`;
|
|
1778
|
+
if (n && n.length)
|
|
1779
|
+
for (const i of n)
|
|
1767
1780
|
r += `&item_ids=${encodeURIComponent(i)}`;
|
|
1768
1781
|
return this.api.get(r);
|
|
1769
1782
|
}
|
|
@@ -1791,7 +1804,7 @@ class te {
|
|
|
1791
1804
|
return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
|
|
1792
1805
|
}
|
|
1793
1806
|
}
|
|
1794
|
-
class
|
|
1807
|
+
class se {
|
|
1795
1808
|
constructor(e) {
|
|
1796
1809
|
this.api = e;
|
|
1797
1810
|
}
|
|
@@ -1802,11 +1815,11 @@ class ne {
|
|
|
1802
1815
|
* @param {number} [options.topK=100]
|
|
1803
1816
|
* @param {Object[]} [options.memoryItems] - Direct items to analyze
|
|
1804
1817
|
*/
|
|
1805
|
-
async runAnalysis({ query: e = "*", topK: t = 100, memoryItems:
|
|
1818
|
+
async runAnalysis({ query: e = "*", topK: t = 100, memoryItems: s = [] } = {}) {
|
|
1806
1819
|
return this.api.post("/memory/governance/run-analysis", {
|
|
1807
1820
|
query: e,
|
|
1808
1821
|
top_k: t,
|
|
1809
|
-
memory_items:
|
|
1822
|
+
memory_items: s
|
|
1810
1823
|
});
|
|
1811
1824
|
}
|
|
1812
1825
|
/**
|
|
@@ -1816,10 +1829,10 @@ class ne {
|
|
|
1816
1829
|
* @param {boolean} [options.autoFixableOnly=false]
|
|
1817
1830
|
*/
|
|
1818
1831
|
async listViolations({ severity: e = null, autoFixableOnly: t = !1 } = {}) {
|
|
1819
|
-
const
|
|
1820
|
-
e &&
|
|
1821
|
-
const
|
|
1822
|
-
return this.api.get(`/memory/governance/violations${
|
|
1832
|
+
const s = [];
|
|
1833
|
+
e && s.push(`severity=${e}`), t && s.push("auto_fixable_only=true");
|
|
1834
|
+
const n = s.length ? `?${s.join("&")}` : "";
|
|
1835
|
+
return this.api.get(`/memory/governance/violations${n}`);
|
|
1823
1836
|
}
|
|
1824
1837
|
/**
|
|
1825
1838
|
* Get a specific violation by ID.
|
|
@@ -1836,12 +1849,12 @@ class ne {
|
|
|
1836
1849
|
* @param {string} [params.rationale='']
|
|
1837
1850
|
* @param {string} [params.decidedBy='human']
|
|
1838
1851
|
*/
|
|
1839
|
-
async applyDecision({ violationId: e, action: t = "approve", rationale:
|
|
1852
|
+
async applyDecision({ violationId: e, action: t = "approve", rationale: s = "", decidedBy: n = "human" }) {
|
|
1840
1853
|
return this.api.post("/memory/governance/apply-decision", {
|
|
1841
1854
|
violation_id: e,
|
|
1842
1855
|
action: t,
|
|
1843
|
-
rationale:
|
|
1844
|
-
decided_by:
|
|
1856
|
+
rationale: s,
|
|
1857
|
+
decided_by: n
|
|
1845
1858
|
});
|
|
1846
1859
|
}
|
|
1847
1860
|
/**
|
|
@@ -1860,7 +1873,7 @@ class ne {
|
|
|
1860
1873
|
return this.api.get("/memory/governance/summary");
|
|
1861
1874
|
}
|
|
1862
1875
|
}
|
|
1863
|
-
class
|
|
1876
|
+
class ne {
|
|
1864
1877
|
constructor(e) {
|
|
1865
1878
|
this.api = e;
|
|
1866
1879
|
}
|
|
@@ -1913,11 +1926,11 @@ class re {
|
|
|
1913
1926
|
* @param {string} [params.memoryType='semantic']
|
|
1914
1927
|
* @param {boolean} [params.useLlm=true]
|
|
1915
1928
|
*/
|
|
1916
|
-
async challenge({ assertion: e, memoryType: t = "semantic", useLlm:
|
|
1929
|
+
async challenge({ assertion: e, memoryType: t = "semantic", useLlm: s = !0 }) {
|
|
1917
1930
|
return this.api.post("/memory/reasoning/challenge", {
|
|
1918
1931
|
assertion: e,
|
|
1919
1932
|
memory_type: t,
|
|
1920
|
-
use_llm:
|
|
1933
|
+
use_llm: s
|
|
1921
1934
|
});
|
|
1922
1935
|
}
|
|
1923
1936
|
/**
|
|
@@ -1930,12 +1943,12 @@ class re {
|
|
|
1930
1943
|
* @param {boolean} [params.useWikipedia=true]
|
|
1931
1944
|
* @param {boolean} [params.useLlm=true]
|
|
1932
1945
|
*/
|
|
1933
|
-
async resolve({ existingItemId: e, newFact: t, autoResolve:
|
|
1946
|
+
async resolve({ existingItemId: e, newFact: t, autoResolve: s = !0, strategy: n = null, useWikipedia: r = !0, useLlm: i = !0 }) {
|
|
1934
1947
|
return this.api.post("/memory/reasoning/resolve", {
|
|
1935
1948
|
existing_item_id: e,
|
|
1936
1949
|
new_fact: t,
|
|
1937
|
-
auto_resolve:
|
|
1938
|
-
strategy:
|
|
1950
|
+
auto_resolve: s,
|
|
1951
|
+
strategy: n,
|
|
1939
1952
|
use_wikipedia: r,
|
|
1940
1953
|
use_llm: i
|
|
1941
1954
|
});
|
|
@@ -2011,12 +2024,12 @@ class ie {
|
|
|
2011
2024
|
* @param {number} [params.minQualityScore=0.4]
|
|
2012
2025
|
* @param {boolean} [params.useLlmDetection=true]
|
|
2013
2026
|
*/
|
|
2014
|
-
async extract({ content: e, minSteps: t = 2, minQualityScore:
|
|
2027
|
+
async extract({ content: e, minSteps: t = 2, minQualityScore: s = 0.4, useLlmDetection: n = !0 }) {
|
|
2015
2028
|
return this.api.post("/memory/reasoning/traces/extract", {
|
|
2016
2029
|
content: e,
|
|
2017
2030
|
min_steps: t,
|
|
2018
|
-
min_quality_score:
|
|
2019
|
-
use_llm_detection:
|
|
2031
|
+
min_quality_score: s,
|
|
2032
|
+
use_llm_detection: n
|
|
2020
2033
|
});
|
|
2021
2034
|
}
|
|
2022
2035
|
/**
|
|
@@ -2038,11 +2051,11 @@ class ie {
|
|
|
2038
2051
|
* @param {string} [params.artifactId]
|
|
2039
2052
|
* @param {number} [params.limit=10]
|
|
2040
2053
|
*/
|
|
2041
|
-
async query({ query: e, artifactId: t = null, limit:
|
|
2054
|
+
async query({ query: e, artifactId: t = null, limit: s = 10 }) {
|
|
2042
2055
|
return this.api.post("/memory/reasoning/traces/query", {
|
|
2043
2056
|
query: e,
|
|
2044
2057
|
artifact_id: t,
|
|
2045
|
-
limit:
|
|
2058
|
+
limit: s
|
|
2046
2059
|
});
|
|
2047
2060
|
}
|
|
2048
2061
|
/**
|
|
@@ -2065,11 +2078,11 @@ class oe {
|
|
|
2065
2078
|
* @param {Array<{docId: string, text: string}>} params.rawChunks
|
|
2066
2079
|
* @param {Object} [params.params={}]
|
|
2067
2080
|
*/
|
|
2068
|
-
async runInference({ registryId: e = "default", rawChunks: t, params:
|
|
2081
|
+
async runInference({ registryId: e = "default", rawChunks: t, params: s = {} }) {
|
|
2069
2082
|
return this.api.post("/memory/ontology/inference/run", {
|
|
2070
2083
|
registry_id: e,
|
|
2071
|
-
raw_chunks: t.map((
|
|
2072
|
-
params:
|
|
2084
|
+
raw_chunks: t.map((n) => ({ doc_id: n.docId, text: n.text })),
|
|
2085
|
+
params: s
|
|
2073
2086
|
});
|
|
2074
2087
|
}
|
|
2075
2088
|
// === REGISTRY MANAGEMENT ===
|
|
@@ -2086,11 +2099,11 @@ class oe {
|
|
|
2086
2099
|
* @param {string} [params.description='']
|
|
2087
2100
|
* @param {string} [params.domain='general']
|
|
2088
2101
|
*/
|
|
2089
|
-
async createRegistry({ name: e, description: t = "", domain:
|
|
2102
|
+
async createRegistry({ name: e, description: t = "", domain: s = "general" }) {
|
|
2090
2103
|
return this.api.post("/memory/ontology/registries", {
|
|
2091
2104
|
name: e,
|
|
2092
2105
|
description: t,
|
|
2093
|
-
domain:
|
|
2106
|
+
domain: s
|
|
2094
2107
|
});
|
|
2095
2108
|
}
|
|
2096
2109
|
/**
|
|
@@ -2099,8 +2112,8 @@ class oe {
|
|
|
2099
2112
|
* @param {string} [version]
|
|
2100
2113
|
*/
|
|
2101
2114
|
async getSnapshot(e, t = null) {
|
|
2102
|
-
let
|
|
2103
|
-
return t && (
|
|
2115
|
+
let s = `/memory/ontology/registry/${e}/snapshot`;
|
|
2116
|
+
return t && (s += `?version=${encodeURIComponent(t)}`), this.api.get(s);
|
|
2104
2117
|
}
|
|
2105
2118
|
/**
|
|
2106
2119
|
* Apply a changeset to create a new version of the registry.
|
|
@@ -2110,11 +2123,11 @@ class oe {
|
|
|
2110
2123
|
* @param {Object} params.changeset - OntologyIR changeset
|
|
2111
2124
|
* @param {string} [params.message='']
|
|
2112
2125
|
*/
|
|
2113
|
-
async applyChangeset(e, { baseVersion: t = "", changeset:
|
|
2126
|
+
async applyChangeset(e, { baseVersion: t = "", changeset: s, message: n = "" }) {
|
|
2114
2127
|
return this.api.post(`/memory/ontology/registry/${e}/apply`, {
|
|
2115
2128
|
base_version: t,
|
|
2116
|
-
changeset:
|
|
2117
|
-
message:
|
|
2129
|
+
changeset: s,
|
|
2130
|
+
message: n
|
|
2118
2131
|
});
|
|
2119
2132
|
}
|
|
2120
2133
|
/**
|
|
@@ -2140,10 +2153,10 @@ class oe {
|
|
|
2140
2153
|
* @param {string} [params.targetVersion='']
|
|
2141
2154
|
* @param {string} [params.message='']
|
|
2142
2155
|
*/
|
|
2143
|
-
async rollbackRegistry(e, { targetVersion: t = "", message:
|
|
2156
|
+
async rollbackRegistry(e, { targetVersion: t = "", message: s = "" }) {
|
|
2144
2157
|
return this.api.post(`/memory/ontology/registry/${e}/rollback`, {
|
|
2145
2158
|
target_version: t,
|
|
2146
|
-
message:
|
|
2159
|
+
message: s
|
|
2147
2160
|
});
|
|
2148
2161
|
}
|
|
2149
2162
|
/**
|
|
@@ -2152,8 +2165,8 @@ class oe {
|
|
|
2152
2165
|
* @param {string} [version]
|
|
2153
2166
|
*/
|
|
2154
2167
|
async exportRegistry(e, t = null) {
|
|
2155
|
-
let
|
|
2156
|
-
return t && (
|
|
2168
|
+
let s = `/memory/ontology/registry/${e}/export`;
|
|
2169
|
+
return t && (s += `?version=${encodeURIComponent(t)}`), this.api.get(s);
|
|
2157
2170
|
}
|
|
2158
2171
|
/**
|
|
2159
2172
|
* Import data into a registry.
|
|
@@ -2162,10 +2175,10 @@ class oe {
|
|
|
2162
2175
|
* @param {Object} params.data - Complete ontology data to import
|
|
2163
2176
|
* @param {string} [params.message='']
|
|
2164
2177
|
*/
|
|
2165
|
-
async importRegistry(e, { data: t, message:
|
|
2178
|
+
async importRegistry(e, { data: t, message: s = "" }) {
|
|
2166
2179
|
return this.api.post(`/memory/ontology/registry/${e}/import`, {
|
|
2167
2180
|
data: t,
|
|
2168
|
-
message:
|
|
2181
|
+
message: s
|
|
2169
2182
|
});
|
|
2170
2183
|
}
|
|
2171
2184
|
// === ENRICHMENT & GROUNDING ===
|
|
@@ -2194,11 +2207,11 @@ class oe {
|
|
|
2194
2207
|
* @param {string} params.itemId
|
|
2195
2208
|
* @param {string[]} params.candidates
|
|
2196
2209
|
*/
|
|
2197
|
-
async runGrounding({ grounder: e = "wikipedia", itemId: t, candidates:
|
|
2210
|
+
async runGrounding({ grounder: e = "wikipedia", itemId: t, candidates: s }) {
|
|
2198
2211
|
return this.api.post("/memory/ontology/grounding/run", {
|
|
2199
2212
|
grounder: e,
|
|
2200
2213
|
item_id: t,
|
|
2201
|
-
candidates:
|
|
2214
|
+
candidates: s
|
|
2202
2215
|
});
|
|
2203
2216
|
}
|
|
2204
2217
|
// === TEMPLATES ===
|
|
@@ -2234,11 +2247,11 @@ class oe {
|
|
|
2234
2247
|
* @param {string} params.name
|
|
2235
2248
|
* @param {string} [params.description='']
|
|
2236
2249
|
*/
|
|
2237
|
-
async saveAsTemplate({ registryId: e, name: t, description:
|
|
2250
|
+
async saveAsTemplate({ registryId: e, name: t, description: s = "" }) {
|
|
2238
2251
|
return this.api.post("/memory/ontology/templates", {
|
|
2239
2252
|
registry_id: e,
|
|
2240
2253
|
name: t,
|
|
2241
|
-
description:
|
|
2254
|
+
description: s
|
|
2242
2255
|
});
|
|
2243
2256
|
}
|
|
2244
2257
|
/**
|
|
@@ -2263,12 +2276,12 @@ class oe {
|
|
|
2263
2276
|
* @param {number} [params.confidence=0.9]
|
|
2264
2277
|
* @param {boolean} [params.isGlobal=false]
|
|
2265
2278
|
*/
|
|
2266
|
-
async createPattern({ name: e, entityType: t, confidence:
|
|
2279
|
+
async createPattern({ name: e, entityType: t, confidence: s = 0.9, isGlobal: n = !1 }) {
|
|
2267
2280
|
return this.api.post("/memory/ontology/patterns", {
|
|
2268
2281
|
name: e,
|
|
2269
2282
|
entity_type: t,
|
|
2270
|
-
confidence:
|
|
2271
|
-
is_global:
|
|
2283
|
+
confidence: s,
|
|
2284
|
+
is_global: n
|
|
2272
2285
|
});
|
|
2273
2286
|
}
|
|
2274
2287
|
/**
|
|
@@ -2307,10 +2320,10 @@ class oe {
|
|
|
2307
2320
|
* @param {string} params.baseRegistryId
|
|
2308
2321
|
* @param {string} [params.pinnedVersion]
|
|
2309
2322
|
*/
|
|
2310
|
-
async subscribe(e, { baseRegistryId: t, pinnedVersion:
|
|
2323
|
+
async subscribe(e, { baseRegistryId: t, pinnedVersion: s = null }) {
|
|
2311
2324
|
return this.api.post(`/memory/ontology/registry/${e}/subscribe`, {
|
|
2312
2325
|
base_registry_id: t,
|
|
2313
|
-
pinned_version:
|
|
2326
|
+
pinned_version: s
|
|
2314
2327
|
});
|
|
2315
2328
|
}
|
|
2316
2329
|
/**
|
|
@@ -2428,9 +2441,9 @@ class oe {
|
|
|
2428
2441
|
* @param {string} [options.kind] missing_in_graph | missing_in_registry | name_conflict_unresolvable
|
|
2429
2442
|
* @param {number} [options.limit=50]
|
|
2430
2443
|
*/
|
|
2431
|
-
async listHitl({ status: e = "open", kind: t = null, limit:
|
|
2432
|
-
const
|
|
2433
|
-
return t &&
|
|
2444
|
+
async listHitl({ status: e = "open", kind: t = null, limit: s = 50 } = {}) {
|
|
2445
|
+
const n = new URLSearchParams({ status: e, limit: String(s) });
|
|
2446
|
+
return t && n.set("kind", t), this.api.get(`/memory/ontology/hitl?${n.toString()}`);
|
|
2434
2447
|
}
|
|
2435
2448
|
/**
|
|
2436
2449
|
* Resolve one ontology HITL queue item (open -> resolved).
|
|
@@ -2439,8 +2452,8 @@ class oe {
|
|
|
2439
2452
|
* @param {('accepted'|'dismissed'|'deferred')} body.action
|
|
2440
2453
|
* @param {string} [body.note]
|
|
2441
2454
|
*/
|
|
2442
|
-
async resolveHitl(e, { action: t, note:
|
|
2443
|
-
return this.api.post(`/memory/ontology/hitl/${e}/resolve`, { action: t, note:
|
|
2455
|
+
async resolveHitl(e, { action: t, note: s = null }) {
|
|
2456
|
+
return this.api.post(`/memory/ontology/hitl/${e}/resolve`, { action: t, note: s });
|
|
2444
2457
|
}
|
|
2445
2458
|
// --- ONTO-CRUD-1 read / audit / migration surface -------------------------
|
|
2446
2459
|
/**
|
|
@@ -2454,9 +2467,9 @@ class oe {
|
|
|
2454
2467
|
* @param {number} [options.limit=100]
|
|
2455
2468
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2456
2469
|
*/
|
|
2457
|
-
async listTypes({ tier: e, layer: t, packId:
|
|
2470
|
+
async listTypes({ tier: e, layer: t, packId: s, hasIri: n, kind: r, limit: i = 100, cursor: o } = {}) {
|
|
2458
2471
|
const c = { limit: String(i) };
|
|
2459
|
-
e !== void 0 && (c.tier = e), t !== void 0 && (c.layer = t),
|
|
2472
|
+
e !== void 0 && (c.tier = e), t !== void 0 && (c.layer = t), s !== void 0 && (c.pack_id = s), n !== void 0 && (c.has_iri = String(n)), r !== void 0 && (c.kind = r), o !== void 0 && (c.cursor = o);
|
|
2460
2473
|
const u = new URLSearchParams(c).toString();
|
|
2461
2474
|
return this.api.get(`/memory/ontology/types${u ? "?" + u : ""}`);
|
|
2462
2475
|
}
|
|
@@ -2491,8 +2504,8 @@ class oe {
|
|
|
2491
2504
|
*/
|
|
2492
2505
|
async declareType(e, {
|
|
2493
2506
|
kind: t = "entity",
|
|
2494
|
-
propertiesSchema:
|
|
2495
|
-
requiredProperties:
|
|
2507
|
+
propertiesSchema: s,
|
|
2508
|
+
requiredProperties: n,
|
|
2496
2509
|
storageStrategy: r,
|
|
2497
2510
|
storageSearchable: i,
|
|
2498
2511
|
iri: o,
|
|
@@ -2506,7 +2519,7 @@ class oe {
|
|
|
2506
2519
|
tier: g = "confirmed"
|
|
2507
2520
|
} = {}) {
|
|
2508
2521
|
const p = { name: e, kind: t, tier: g };
|
|
2509
|
-
return
|
|
2522
|
+
return s !== void 0 && (p.properties_schema = s), n !== void 0 && (p.required_properties = n), r !== void 0 && (p.storage_strategy = r), i !== void 0 && (p.storage_searchable = i), o !== void 0 && (p.iri = o), c !== void 0 && (p.wikidata_qid = c), u !== void 0 && (p.display_name = u), y !== void 0 && (p.definition = y), h !== void 0 && (p.description = h), d !== void 0 && (p.aliases = d), $ !== void 0 && (p.examples = $), k !== void 0 && (p.parent_types = k), this.api.post("/memory/ontology/types", p);
|
|
2510
2523
|
}
|
|
2511
2524
|
/**
|
|
2512
2525
|
* Declare an ontology relation (CORE-MEMTYPE-DECLARE-1; declare-only in P1).
|
|
@@ -2537,8 +2550,8 @@ class oe {
|
|
|
2537
2550
|
*/
|
|
2538
2551
|
async declareRelation(e, {
|
|
2539
2552
|
domain: t,
|
|
2540
|
-
range:
|
|
2541
|
-
inverseOf:
|
|
2553
|
+
range: s,
|
|
2554
|
+
inverseOf: n,
|
|
2542
2555
|
cardinality: r,
|
|
2543
2556
|
temporal: i,
|
|
2544
2557
|
propertiesSchema: o,
|
|
@@ -2556,7 +2569,7 @@ class oe {
|
|
|
2556
2569
|
tier: v = "confirmed"
|
|
2557
2570
|
} = {}) {
|
|
2558
2571
|
const m = { name: e, tier: v };
|
|
2559
|
-
return t !== void 0 && (m.domain = t),
|
|
2572
|
+
return t !== void 0 && (m.domain = t), s !== void 0 && (m.range = s), n !== void 0 && (m.inverse_of = n), r !== void 0 && (m.cardinality = r), i !== void 0 && (m.temporal = i), o !== void 0 && (m.properties_schema = o), c !== void 0 && (m.transitive = c), u !== void 0 && (m.symmetric = u), y !== void 0 && (m.reflexive = y), h !== void 0 && (m.parent_relations = h), d !== void 0 && (m.iri = d), $ !== void 0 && (m.wikidata_pid = $), k !== void 0 && (m.display_name = k), g !== void 0 && (m.definition = g), p !== void 0 && (m.description = p), I !== void 0 && (m.aliases = I), b !== void 0 && (m.examples = b), this.api.post("/memory/ontology/relations", m);
|
|
2560
2573
|
}
|
|
2561
2574
|
/**
|
|
2562
2575
|
* List ontology relation types, keyset-paginated. Mirror of `listTypes`.
|
|
@@ -2568,9 +2581,9 @@ class oe {
|
|
|
2568
2581
|
* @param {number} [options.limit=100]
|
|
2569
2582
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2570
2583
|
*/
|
|
2571
|
-
async listRelations({ tier: e, layer: t, packId:
|
|
2584
|
+
async listRelations({ tier: e, layer: t, packId: s, hasIri: n, limit: r = 100, cursor: i } = {}) {
|
|
2572
2585
|
const o = { limit: String(r) };
|
|
2573
|
-
e !== void 0 && (o.tier = e), t !== void 0 && (o.layer = t),
|
|
2586
|
+
e !== void 0 && (o.tier = e), t !== void 0 && (o.layer = t), s !== void 0 && (o.pack_id = s), n !== void 0 && (o.has_iri = String(n)), i !== void 0 && (o.cursor = i);
|
|
2574
2587
|
const c = new URLSearchParams(o).toString();
|
|
2575
2588
|
return this.api.get(`/memory/ontology/relations${c ? "?" + c : ""}`);
|
|
2576
2589
|
}
|
|
@@ -2597,9 +2610,9 @@ class oe {
|
|
|
2597
2610
|
* @param {string} [options.until] full ISO-8601 upper bound (inclusive)
|
|
2598
2611
|
* @param {number} [options.limit=200]
|
|
2599
2612
|
*/
|
|
2600
|
-
async listAudit({ actor: e, action: t, since:
|
|
2613
|
+
async listAudit({ actor: e, action: t, since: s, until: n, limit: r = 200 } = {}) {
|
|
2601
2614
|
const i = { limit: String(r) };
|
|
2602
|
-
e !== void 0 && (i.actor = e), t !== void 0 && (i.action = t),
|
|
2615
|
+
e !== void 0 && (i.actor = e), t !== void 0 && (i.action = t), s !== void 0 && (i.since = s), n !== void 0 && (i.until = n);
|
|
2603
2616
|
const o = new URLSearchParams(i).toString();
|
|
2604
2617
|
return this.api.get(`/memory/ontology/audit${o ? "?" + o : ""}`);
|
|
2605
2618
|
}
|
|
@@ -2624,10 +2637,10 @@ class oe {
|
|
|
2624
2637
|
* @param {string} [options.packVersion] scope to one installed version; omit for all
|
|
2625
2638
|
*/
|
|
2626
2639
|
async getPackAudit(e, { packVersion: t = null } = {}) {
|
|
2627
|
-
const
|
|
2628
|
-
t !== null && (
|
|
2629
|
-
const
|
|
2630
|
-
return this.api.get(`/memory/ontology/packs/${encodeURIComponent(e)}/audit${
|
|
2640
|
+
const s = {};
|
|
2641
|
+
t !== null && (s.pack_version = t);
|
|
2642
|
+
const n = new URLSearchParams(s).toString();
|
|
2643
|
+
return this.api.get(`/memory/ontology/packs/${encodeURIComponent(e)}/audit${n ? "?" + n : ""}`);
|
|
2631
2644
|
}
|
|
2632
2645
|
/**
|
|
2633
2646
|
* Reclassify every instance of `fromId` onto `toId`. Both types stay live.
|
|
@@ -2644,8 +2657,8 @@ class oe {
|
|
|
2644
2657
|
* defaults, so an entity migration returns them empty/zero rather than omitting
|
|
2645
2658
|
* them — callers never branch on kind to read a response.
|
|
2646
2659
|
*/
|
|
2647
|
-
async migrateTypeInstances(e, t, { reason:
|
|
2648
|
-
const i = { reason:
|
|
2660
|
+
async migrateTypeInstances(e, t, { reason: s, batchSize: n = 500, onViolation: r = "refuse" }) {
|
|
2661
|
+
const i = { reason: s, batch_size: n };
|
|
2649
2662
|
return r !== "refuse" && (i.on_violation = r), this.api.post(
|
|
2650
2663
|
`/memory/ontology/types/${encodeURIComponent(e)}/migrate-to/${encodeURIComponent(t)}`,
|
|
2651
2664
|
i
|
|
@@ -2674,9 +2687,9 @@ class oe {
|
|
|
2674
2687
|
* @param {number} [options.limit=100]
|
|
2675
2688
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2676
2689
|
*/
|
|
2677
|
-
async listReviewQueue({ tier: e, assignee: t, source:
|
|
2678
|
-
const i = { limit: String(
|
|
2679
|
-
e !== void 0 && (i.tier = e), t !== void 0 && (i.assignee = t),
|
|
2690
|
+
async listReviewQueue({ tier: e, assignee: t, source: s, limit: n = 100, cursor: r } = {}) {
|
|
2691
|
+
const i = { limit: String(n) };
|
|
2692
|
+
e !== void 0 && (i.tier = e), t !== void 0 && (i.assignee = t), s !== void 0 && (i.source = s), r !== void 0 && (i.cursor = r);
|
|
2680
2693
|
const o = new URLSearchParams(i).toString();
|
|
2681
2694
|
return this.api.get(`/memory/ontology/queue${o ? "?" + o : ""}`);
|
|
2682
2695
|
}
|
|
@@ -2687,8 +2700,8 @@ class oe {
|
|
|
2687
2700
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2688
2701
|
*/
|
|
2689
2702
|
async approveReviewType(e, { expectedTier: t } = {}) {
|
|
2690
|
-
const
|
|
2691
|
-
return t !== void 0 && (
|
|
2703
|
+
const s = {};
|
|
2704
|
+
return t !== void 0 && (s.expected_tier = t), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/approve`, s);
|
|
2692
2705
|
}
|
|
2693
2706
|
/**
|
|
2694
2707
|
* Reject one ontology review type.
|
|
@@ -2697,8 +2710,8 @@ class oe {
|
|
|
2697
2710
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2698
2711
|
*/
|
|
2699
2712
|
async rejectReviewType(e, { expectedTier: t } = {}) {
|
|
2700
|
-
const
|
|
2701
|
-
return t !== void 0 && (
|
|
2713
|
+
const s = {};
|
|
2714
|
+
return t !== void 0 && (s.expected_tier = t), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/reject`, s);
|
|
2702
2715
|
}
|
|
2703
2716
|
/**
|
|
2704
2717
|
* Merge one ontology review type into another type.
|
|
@@ -2707,9 +2720,9 @@ class oe {
|
|
|
2707
2720
|
* @param {Object} [options]
|
|
2708
2721
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2709
2722
|
*/
|
|
2710
|
-
async mergeReviewType(e, t, { expectedTier:
|
|
2711
|
-
const
|
|
2712
|
-
return
|
|
2723
|
+
async mergeReviewType(e, t, { expectedTier: s } = {}) {
|
|
2724
|
+
const n = { into_id: t };
|
|
2725
|
+
return s !== void 0 && (n.expected_tier = s), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/merge`, n);
|
|
2713
2726
|
}
|
|
2714
2727
|
/**
|
|
2715
2728
|
* Edit and promote one ontology review type.
|
|
@@ -2718,9 +2731,9 @@ class oe {
|
|
|
2718
2731
|
* @param {Object} [options]
|
|
2719
2732
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2720
2733
|
*/
|
|
2721
|
-
async editPromoteReviewType(e, t, { expectedTier:
|
|
2722
|
-
const
|
|
2723
|
-
return
|
|
2734
|
+
async editPromoteReviewType(e, t, { expectedTier: s } = {}) {
|
|
2735
|
+
const n = { edits: t };
|
|
2736
|
+
return s !== void 0 && (n.expected_tier = s), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/edit-promote`, n);
|
|
2724
2737
|
}
|
|
2725
2738
|
/**
|
|
2726
2739
|
* Assign or clear the reviewer for one ontology review type.
|
|
@@ -2738,9 +2751,9 @@ class oe {
|
|
|
2738
2751
|
* @param {Object} [options.params] action-specific params
|
|
2739
2752
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2740
2753
|
*/
|
|
2741
|
-
async bulkReviewAction(e, t, { params:
|
|
2742
|
-
const r = { action: e, ids: t, params:
|
|
2743
|
-
return
|
|
2754
|
+
async bulkReviewAction(e, t, { params: s, expectedTier: n } = {}) {
|
|
2755
|
+
const r = { action: e, ids: t, params: s === void 0 ? {} : s };
|
|
2756
|
+
return n !== void 0 && (r.expected_tier = n), this.api.post("/memory/ontology/queue/bulk", r);
|
|
2744
2757
|
}
|
|
2745
2758
|
}
|
|
2746
2759
|
class ae {
|
|
@@ -2767,9 +2780,9 @@ class ae {
|
|
|
2767
2780
|
* @param {boolean} [options.sentimentAnalysis]
|
|
2768
2781
|
* @param {boolean} [options.topicAnalysis]
|
|
2769
2782
|
*/
|
|
2770
|
-
async detectBias({ protectedAttributes: e = null, sentimentAnalysis: t = null, topicAnalysis:
|
|
2771
|
-
const
|
|
2772
|
-
return e !== null && (
|
|
2783
|
+
async detectBias({ protectedAttributes: e = null, sentimentAnalysis: t = null, topicAnalysis: s = null } = {}) {
|
|
2784
|
+
const n = {};
|
|
2785
|
+
return e !== null && (n.protected_attributes = e), t !== null && (n.sentiment_analysis = t), s !== null && (n.topic_analysis = s), this.api.post("/memory/analytics/bias", n);
|
|
2773
2786
|
}
|
|
2774
2787
|
}
|
|
2775
2788
|
class ce {
|
|
@@ -2855,8 +2868,8 @@ class ue {
|
|
|
2855
2868
|
* @param {string} [runId]
|
|
2856
2869
|
*/
|
|
2857
2870
|
async getState(e, t = null) {
|
|
2858
|
-
let
|
|
2859
|
-
return t && (
|
|
2871
|
+
let s = `/memory/pipeline/${e}/state`;
|
|
2872
|
+
return t && (s += `?run_id=${encodeURIComponent(t)}`), this.api.get(s);
|
|
2860
2873
|
}
|
|
2861
2874
|
/**
|
|
2862
2875
|
* Reset a pipeline, clearing its state.
|
|
@@ -2887,11 +2900,11 @@ class ue {
|
|
|
2887
2900
|
* @param {string} [params.description='']
|
|
2888
2901
|
* @param {Object} params.config
|
|
2889
2902
|
*/
|
|
2890
|
-
async createConfig({ name: e, description: t = "", config:
|
|
2903
|
+
async createConfig({ name: e, description: t = "", config: s }) {
|
|
2891
2904
|
return this.api.post("/memory/pipeline/configs", {
|
|
2892
2905
|
name: e,
|
|
2893
2906
|
description: t,
|
|
2894
|
-
config:
|
|
2907
|
+
config: s
|
|
2895
2908
|
});
|
|
2896
2909
|
}
|
|
2897
2910
|
/**
|
|
@@ -2909,11 +2922,11 @@ class ue {
|
|
|
2909
2922
|
* @param {string} [params.description='']
|
|
2910
2923
|
* @param {Object} [params.config={}]
|
|
2911
2924
|
*/
|
|
2912
|
-
async updateConfig(e, { name: t = "", description:
|
|
2925
|
+
async updateConfig(e, { name: t = "", description: s = "", config: n = {} }) {
|
|
2913
2926
|
return this.api.patch(`/memory/pipeline/configs/${e}`, {
|
|
2914
2927
|
name: t,
|
|
2915
|
-
description:
|
|
2916
|
-
config:
|
|
2928
|
+
description: s,
|
|
2929
|
+
config: n
|
|
2917
2930
|
});
|
|
2918
2931
|
}
|
|
2919
2932
|
/**
|
|
@@ -2935,11 +2948,11 @@ class le {
|
|
|
2935
2948
|
* @param {Object} params.payload
|
|
2936
2949
|
* @param {Object} [params.metadata={}]
|
|
2937
2950
|
*/
|
|
2938
|
-
async store({ conversationId: e, payload: t, metadata:
|
|
2951
|
+
async store({ conversationId: e, payload: t, metadata: s = {} }) {
|
|
2939
2952
|
return this.api.post("/memory/archive/store", {
|
|
2940
2953
|
conversation_id: e,
|
|
2941
2954
|
payload: t,
|
|
2942
|
-
metadata:
|
|
2955
|
+
metadata: s
|
|
2943
2956
|
});
|
|
2944
2957
|
}
|
|
2945
2958
|
/**
|
|
@@ -3010,8 +3023,8 @@ class me {
|
|
|
3010
3023
|
* @param {number} [options.maxDistance=3]
|
|
3011
3024
|
* @param {number} [options.minSurprise=0.5]
|
|
3012
3025
|
*/
|
|
3013
|
-
async getDiscoveries(e, { maxDistance: t = 3, minSurprise:
|
|
3014
|
-
return this.api.get(`/memory/zettel/${e}/discoveries?max_distance=${t}&min_surprise=${
|
|
3026
|
+
async getDiscoveries(e, { maxDistance: t = 3, minSurprise: s = 0.5 } = {}) {
|
|
3027
|
+
return this.api.get(`/memory/zettel/${e}/discoveries?max_distance=${t}&min_surprise=${s}`);
|
|
3015
3028
|
}
|
|
3016
3029
|
/**
|
|
3017
3030
|
* Find paths between two notes.
|
|
@@ -3019,8 +3032,8 @@ class me {
|
|
|
3019
3032
|
* @param {string} targetId
|
|
3020
3033
|
* @param {number} [maxPaths=5]
|
|
3021
3034
|
*/
|
|
3022
|
-
async getPath(e, t,
|
|
3023
|
-
return this.api.get(`/memory/zettel/${e}/path/${t}?max_paths=${
|
|
3035
|
+
async getPath(e, t, s = 5) {
|
|
3036
|
+
return this.api.get(`/memory/zettel/${e}/path/${t}?max_paths=${s}`);
|
|
3024
3037
|
}
|
|
3025
3038
|
// === WIKILINK SUPPORT ===
|
|
3026
3039
|
/**
|
|
@@ -3046,8 +3059,8 @@ class me {
|
|
|
3046
3059
|
* @param {number} [options.depth=2]
|
|
3047
3060
|
* @param {boolean} [options.includeMetadata=true]
|
|
3048
3061
|
*/
|
|
3049
|
-
async getSubgraph(e, { depth: t = 2, includeMetadata:
|
|
3050
|
-
return this.api.get(`/memory/zettel/${e}/graph?depth=${t}&include_metadata=${
|
|
3062
|
+
async getSubgraph(e, { depth: t = 2, includeMetadata: s = !0 } = {}) {
|
|
3063
|
+
return this.api.get(`/memory/zettel/${e}/graph?depth=${t}&include_metadata=${s}`);
|
|
3051
3064
|
}
|
|
3052
3065
|
// === ADDITIONAL DISCOVERY ===
|
|
3053
3066
|
/**
|
|
@@ -3088,8 +3101,8 @@ class me {
|
|
|
3088
3101
|
* @param {string} value
|
|
3089
3102
|
* @param {number} [limit=100]
|
|
3090
3103
|
*/
|
|
3091
|
-
async findByProperty(e, t,
|
|
3092
|
-
return this.api.get(`/memory/zettel/by-property?key=${encodeURIComponent(e)}&value=${encodeURIComponent(t)}&limit=${
|
|
3104
|
+
async findByProperty(e, t, s = 100) {
|
|
3105
|
+
return this.api.get(`/memory/zettel/by-property?key=${encodeURIComponent(e)}&value=${encodeURIComponent(t)}&limit=${s}`);
|
|
3093
3106
|
}
|
|
3094
3107
|
/**
|
|
3095
3108
|
* Find notes mentioning an entity.
|
|
@@ -3105,8 +3118,8 @@ class me {
|
|
|
3105
3118
|
* @param {string} relationType
|
|
3106
3119
|
* @param {number} [limit=100]
|
|
3107
3120
|
*/
|
|
3108
|
-
async queryByRelation(e, t,
|
|
3109
|
-
return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${
|
|
3121
|
+
async queryByRelation(e, t, s = 100) {
|
|
3122
|
+
return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${s}`);
|
|
3110
3123
|
}
|
|
3111
3124
|
}
|
|
3112
3125
|
class pe {
|
|
@@ -3124,9 +3137,9 @@ class pe {
|
|
|
3124
3137
|
*/
|
|
3125
3138
|
async list(e = {}) {
|
|
3126
3139
|
const t = Object.fromEntries(
|
|
3127
|
-
Object.entries(e).filter(([,
|
|
3128
|
-
),
|
|
3129
|
-
return this.api.get(`/memory/procedures/matches${
|
|
3140
|
+
Object.entries(e).filter(([, n]) => n != null)
|
|
3141
|
+
), s = new URLSearchParams(t).toString();
|
|
3142
|
+
return this.api.get(`/memory/procedures/matches${s ? "?" + s : ""}`);
|
|
3130
3143
|
}
|
|
3131
3144
|
/**
|
|
3132
3145
|
* Submit feedback for a procedure match.
|
|
@@ -3134,9 +3147,9 @@ class pe {
|
|
|
3134
3147
|
* @param {string} feedback - One of "success", "failure", "neutral"
|
|
3135
3148
|
* @param {string} [note] - Optional explanation
|
|
3136
3149
|
*/
|
|
3137
|
-
async submitFeedback(e, t,
|
|
3138
|
-
const
|
|
3139
|
-
return
|
|
3150
|
+
async submitFeedback(e, t, s = null) {
|
|
3151
|
+
const n = { feedback: t };
|
|
3152
|
+
return s && (n.note = s), this.api.post(`/memory/procedures/matches/${e}/feedback`, n);
|
|
3140
3153
|
}
|
|
3141
3154
|
/**
|
|
3142
3155
|
* Get aggregated procedure match statistics.
|
|
@@ -3160,9 +3173,9 @@ class ye {
|
|
|
3160
3173
|
*/
|
|
3161
3174
|
async list(e = {}) {
|
|
3162
3175
|
const t = Object.fromEntries(
|
|
3163
|
-
Object.entries(e).filter(([,
|
|
3164
|
-
),
|
|
3165
|
-
return this.api.get(`/memory/procedures/candidates${
|
|
3176
|
+
Object.entries(e).filter(([, n]) => n != null)
|
|
3177
|
+
), s = new URLSearchParams(t).toString();
|
|
3178
|
+
return this.api.get(`/memory/procedures/candidates${s ? "?" + s : ""}`);
|
|
3166
3179
|
}
|
|
3167
3180
|
/**
|
|
3168
3181
|
* Promote a candidate cluster to a new procedure.
|
|
@@ -3176,14 +3189,14 @@ class ye {
|
|
|
3176
3189
|
* @returns {Promise<Object>} Response with procedure_id and status
|
|
3177
3190
|
*/
|
|
3178
3191
|
async promote(e, t = {}) {
|
|
3179
|
-
const
|
|
3192
|
+
const s = {
|
|
3180
3193
|
name: t.name ?? null,
|
|
3181
3194
|
description: t.description ?? null,
|
|
3182
3195
|
procedure_type: t.procedure_type ?? "extraction",
|
|
3183
3196
|
preferred_profile: t.preferred_profile ?? "quick_extract",
|
|
3184
3197
|
remove_working_items: t.remove_working_items ?? !1
|
|
3185
3198
|
};
|
|
3186
|
-
return this.api.post(`/memory/procedures/candidates/${e}/promote`,
|
|
3199
|
+
return this.api.post(`/memory/procedures/candidates/${e}/promote`, s);
|
|
3187
3200
|
}
|
|
3188
3201
|
/**
|
|
3189
3202
|
* Dismiss a candidate cluster from future recommendations.
|
|
@@ -3211,9 +3224,9 @@ class he {
|
|
|
3211
3224
|
*/
|
|
3212
3225
|
async list(e = {}) {
|
|
3213
3226
|
const t = Object.fromEntries(
|
|
3214
|
-
Object.entries(e).filter(([,
|
|
3215
|
-
),
|
|
3216
|
-
return this.api.get(`/memory/procedures/drift${
|
|
3227
|
+
Object.entries(e).filter(([, n]) => n != null)
|
|
3228
|
+
), s = new URLSearchParams(t).toString();
|
|
3229
|
+
return this.api.get(`/memory/procedures/drift${s ? "?" + s : ""}`);
|
|
3217
3230
|
}
|
|
3218
3231
|
/**
|
|
3219
3232
|
* Get a single drift event with full change details.
|
|
@@ -3230,8 +3243,8 @@ class he {
|
|
|
3230
3243
|
* @returns {Promise<{status: string, event_id: string, resolved: boolean}>}
|
|
3231
3244
|
*/
|
|
3232
3245
|
async resolve(e, t = null) {
|
|
3233
|
-
const
|
|
3234
|
-
return t != null && (
|
|
3246
|
+
const s = {};
|
|
3247
|
+
return t != null && (s.note = t), this.api.post(`/memory/procedures/drift/${e}/resolve`, s);
|
|
3235
3248
|
}
|
|
3236
3249
|
/**
|
|
3237
3250
|
* Trigger a drift sweep across all procedures in the workspace.
|
|
@@ -3300,9 +3313,9 @@ class de {
|
|
|
3300
3313
|
* @param {number} [params.limit=20]
|
|
3301
3314
|
* @param {string} [params.before] ISO 8601 datetime
|
|
3302
3315
|
*/
|
|
3303
|
-
async list({ isHeartbeat: e = null, limit: t = 20, before:
|
|
3304
|
-
const
|
|
3305
|
-
return e !== null && (
|
|
3316
|
+
async list({ isHeartbeat: e = null, limit: t = 20, before: s = null } = {}) {
|
|
3317
|
+
const n = { limit: t };
|
|
3318
|
+
return e !== null && (n.is_heartbeat = e), s !== null && (n.before = s), this.api.get("/memory/summary/list", n);
|
|
3306
3319
|
}
|
|
3307
3320
|
/** SnapshotDelta between two snapshots. Returns null on 404. */
|
|
3308
3321
|
async delta({ from: e, to: t }) {
|
|
@@ -3311,9 +3324,9 @@ class de {
|
|
|
3311
3324
|
from: e,
|
|
3312
3325
|
to: t
|
|
3313
3326
|
});
|
|
3314
|
-
} catch (
|
|
3315
|
-
if ((
|
|
3316
|
-
throw
|
|
3327
|
+
} catch (s) {
|
|
3328
|
+
if ((s == null ? void 0 : s.status) === 404) return null;
|
|
3329
|
+
throw s;
|
|
3317
3330
|
}
|
|
3318
3331
|
}
|
|
3319
3332
|
/** Admin-only delete. Throws on 403/404/500. */
|
|
@@ -3333,13 +3346,13 @@ class ge {
|
|
|
3333
3346
|
* @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
|
|
3334
3347
|
*/
|
|
3335
3348
|
async acquire(e, { ttlSeconds: t } = {}) {
|
|
3336
|
-
var
|
|
3337
|
-
const
|
|
3338
|
-
t !== void 0 && (
|
|
3349
|
+
var n, r;
|
|
3350
|
+
const s = {};
|
|
3351
|
+
t !== void 0 && (s.ttl_seconds = t);
|
|
3339
3352
|
try {
|
|
3340
|
-
return await this.api.post(`/memory/locks/${e}`,
|
|
3353
|
+
return await this.api.post(`/memory/locks/${e}`, s);
|
|
3341
3354
|
} catch (i) {
|
|
3342
|
-
if ((i == null ? void 0 : i.status) === 409 && ((r = (
|
|
3355
|
+
if ((i == null ? void 0 : i.status) === 409 && ((r = (n = i.detail) == null ? void 0 : n.detail) == null ? void 0 : r.reason) === "lock_held")
|
|
3343
3356
|
return null;
|
|
3344
3357
|
throw i;
|
|
3345
3358
|
}
|
|
@@ -3352,12 +3365,12 @@ class ge {
|
|
|
3352
3365
|
* @param {number} [params.ttlSeconds]
|
|
3353
3366
|
* @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
|
|
3354
3367
|
*/
|
|
3355
|
-
async renew(e, t, { ttlSeconds:
|
|
3368
|
+
async renew(e, t, { ttlSeconds: s } = {}) {
|
|
3356
3369
|
var r, i;
|
|
3357
|
-
const
|
|
3358
|
-
|
|
3370
|
+
const n = {};
|
|
3371
|
+
s !== void 0 && (n.ttl_seconds = s);
|
|
3359
3372
|
try {
|
|
3360
|
-
return await this.api.post(`/memory/locks/${e}/renew`,
|
|
3373
|
+
return await this.api.post(`/memory/locks/${e}/renew`, n, {
|
|
3361
3374
|
headers: { "X-Lease-Token": t }
|
|
3362
3375
|
});
|
|
3363
3376
|
} catch (o) {
|
|
@@ -3373,13 +3386,13 @@ class ge {
|
|
|
3373
3386
|
* @returns {Promise<boolean>}
|
|
3374
3387
|
*/
|
|
3375
3388
|
async release(e, t) {
|
|
3376
|
-
var
|
|
3389
|
+
var s, n;
|
|
3377
3390
|
try {
|
|
3378
3391
|
return await this.api.delete(`/memory/locks/${e}`, {
|
|
3379
3392
|
headers: { "X-Lease-Token": t }
|
|
3380
3393
|
}), !0;
|
|
3381
3394
|
} catch (r) {
|
|
3382
|
-
if ((r == null ? void 0 : r.status) === 409 && ((
|
|
3395
|
+
if ((r == null ? void 0 : r.status) === 409 && ((n = (s = r.detail) == null ? void 0 : s.detail) == null ? void 0 : n.reason) === "not_owner")
|
|
3383
3396
|
return !1;
|
|
3384
3397
|
throw r;
|
|
3385
3398
|
}
|
|
@@ -3406,9 +3419,9 @@ class fe {
|
|
|
3406
3419
|
* @param {number} [params.count] How many to allocate (1..100, default 1).
|
|
3407
3420
|
* @returns {Promise<{name: string, value: number, first: number, count: number}>}
|
|
3408
3421
|
*/
|
|
3409
|
-
async allocate(e, { floor: t, count:
|
|
3410
|
-
const
|
|
3411
|
-
return t !== void 0 && (
|
|
3422
|
+
async allocate(e, { floor: t, count: s } = {}) {
|
|
3423
|
+
const n = {};
|
|
3424
|
+
return t !== void 0 && (n.floor = t), s !== void 0 && (n.count = s), this.api.post(`/memory/sequences/${e}/next`, n);
|
|
3412
3425
|
}
|
|
3413
3426
|
/**
|
|
3414
3427
|
* Read the counter without consuming a number, or null if never allocated.
|
|
@@ -3458,12 +3471,12 @@ class _e {
|
|
|
3458
3471
|
* body shape reaches the route from every client.
|
|
3459
3472
|
* @returns {Promise<Object>} RecallPack — `{ block, manifest }`.
|
|
3460
3473
|
*/
|
|
3461
|
-
async pack({ budgetTokens: e, query: t, sections:
|
|
3474
|
+
async pack({ budgetTokens: e, query: t, sections: s, preset: n } = {}) {
|
|
3462
3475
|
const r = { budget_tokens: e };
|
|
3463
|
-
return t != null && (r.query = t),
|
|
3476
|
+
return t != null && (r.query = t), s != null && (r.sections = s.map(({ name: i, cap_tokens: o, capTokens: c }) => ({
|
|
3464
3477
|
name: i,
|
|
3465
3478
|
cap_tokens: o !== void 0 ? o : c
|
|
3466
|
-
}))),
|
|
3479
|
+
}))), n != null && (r.preset = n), this.api.post("/memory/recall/pack", r);
|
|
3467
3480
|
}
|
|
3468
3481
|
}
|
|
3469
3482
|
class $e {
|
|
@@ -3479,11 +3492,11 @@ class $e {
|
|
|
3479
3492
|
* @param {string[]} [params.statuses=['active']] Repeatable lifecycle selector.
|
|
3480
3493
|
* @returns {Promise<Object>} The policy-exchange contract bundle.
|
|
3481
3494
|
*/
|
|
3482
|
-
async getBundle({ workflow: e, domain: t, statuses:
|
|
3483
|
-
const
|
|
3484
|
-
if (e != null &&
|
|
3485
|
-
for (const i of
|
|
3486
|
-
const r =
|
|
3495
|
+
async getBundle({ workflow: e, domain: t, statuses: s = ["active"] } = {}) {
|
|
3496
|
+
const n = new URLSearchParams();
|
|
3497
|
+
if (e != null && n.append("workflow", e), t != null && n.append("domain", t), Array.isArray(s))
|
|
3498
|
+
for (const i of s) n.append("status", i);
|
|
3499
|
+
const r = n.toString();
|
|
3487
3500
|
return this.api.get(`/memory/policy/bundle${r ? "?" + r : ""}`);
|
|
3488
3501
|
}
|
|
3489
3502
|
/**
|
|
@@ -3498,8 +3511,8 @@ class $e {
|
|
|
3498
3511
|
class Ie {
|
|
3499
3512
|
constructor(e) {
|
|
3500
3513
|
this.auth = new F(e), this.connection = this.auth.connection;
|
|
3501
|
-
const t = new
|
|
3502
|
-
this._api = t, this.memories = new
|
|
3514
|
+
const t = new B(this.auth, { fetchFn: e.fetchFn });
|
|
3515
|
+
this._api = t, this.memories = new W(t), this.decisions = new K(t), this.opinions = new H(t), this.graph = new D(t), this.teams = new G(t), this.workspaces = new N(t), this.profiles = new J(t), this.subscriptions = new V(t), this.authAPI = new Y(t), this.agents = new X(t), this.usage = new Z(t), this.insights = new Q(t), this.tokenUsage = new ee(t), this.temporal = new te(t), this.governance = new se(t), this.evolution = new ne(t), this.reasoning = new re(t), this.reasoningTraces = new ie(t), this.ontology = new oe(t), this.analytics = new ae(t), this.validation = new ce(t), this.pipeline = new ue(t), this.archive = new le(t), this.zettelkasten = new me(t), this.procedureMatches = new pe(t), this.procedureCandidates = new ye(t), this.procedureDrift = new he(t), this.summaries = new de(t), this.locks = new ge(t), this.sequences = new fe(t), this.recall = new _e(t), this.policy = new $e(t);
|
|
3503
3516
|
}
|
|
3504
3517
|
setWorkspaceId(e) {
|
|
3505
3518
|
this.auth.tokenManager.setWorkspaceId(e), this.auth.notifyListeners();
|
|
@@ -3526,19 +3539,19 @@ class Ie {
|
|
|
3526
3539
|
* @returns {Promise<{ imported: number, failed: number, workspace_id: string }>}
|
|
3527
3540
|
*/
|
|
3528
3541
|
async importOkf(e) {
|
|
3529
|
-
const t = e instanceof Blob ? e : new Blob([e], { type: "application/gzip" }),
|
|
3530
|
-
return
|
|
3542
|
+
const t = e instanceof Blob ? e : new Blob([e], { type: "application/gzip" }), s = new FormData();
|
|
3543
|
+
return s.append("file", t, "smartmemory-okf-import.tar.gz"), this._api.postForm("/memory/okf/import", s);
|
|
3531
3544
|
}
|
|
3532
3545
|
}
|
|
3533
3546
|
export {
|
|
3534
3547
|
_ as A,
|
|
3535
|
-
|
|
3548
|
+
B,
|
|
3536
3549
|
K as D,
|
|
3537
|
-
|
|
3538
|
-
|
|
3550
|
+
ne as E,
|
|
3551
|
+
se as G,
|
|
3539
3552
|
Q as I,
|
|
3540
3553
|
ge as L,
|
|
3541
|
-
|
|
3554
|
+
W as M,
|
|
3542
3555
|
oe as O,
|
|
3543
3556
|
ue as P,
|
|
3544
3557
|
re as R,
|