@smartmemory/sdk-js 1.4.64 → 1.4.67
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/{core-GpqOJ8RQ.js → core-y-uPkyF8.js} +543 -422
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var P = (a) => {
|
|
2
2
|
throw TypeError(a);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var R = (a, e, t) => (
|
|
4
|
+
var v = (a, e, t) => e.has(a) || P("Cannot " + t);
|
|
5
|
+
var R = (a, e, t) => (v(a, e, "read from private field"), t ? t.call(a) : e.get(a)), A = (a, e, t) => e.has(a) ? P("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, t), T = (a, e, t, n) => (v(a, e, "write to private field"), n ? n.call(a, t) : e.set(a, t), t), q = (a, e, t) => (v(a, e, "access private method"), t);
|
|
6
6
|
const M = {
|
|
7
7
|
access: "smart_memory_auth_token",
|
|
8
8
|
refresh: "smart_memory_refresh_token",
|
|
@@ -16,7 +16,7 @@ const M = {
|
|
|
16
16
|
tenant: ["tenant_id", "workspace_id", "sm_workspace_id"],
|
|
17
17
|
team: ["team_id", "sm_team_id"]
|
|
18
18
|
};
|
|
19
|
-
class
|
|
19
|
+
class x {
|
|
20
20
|
/**
|
|
21
21
|
* @param {Object} options
|
|
22
22
|
* @param {'localStorage' | 'sessionStorage' | 'memory'} [options.storage='localStorage']
|
|
@@ -112,14 +112,14 @@ class z {
|
|
|
112
112
|
/** @private */
|
|
113
113
|
_getFromStorage(e, t = []) {
|
|
114
114
|
try {
|
|
115
|
-
const
|
|
115
|
+
const n = this.storageType === "localStorage" ? localStorage : sessionStorage, s = this.storageType === "localStorage" ? sessionStorage : localStorage, r = n.getItem(e) || s.getItem(e);
|
|
116
116
|
if (r != null) return r;
|
|
117
117
|
for (const i of t) {
|
|
118
|
-
const c =
|
|
118
|
+
const c = n.getItem(i) || s.getItem(i);
|
|
119
119
|
if (c != null) {
|
|
120
120
|
this._setInStorage(e, c);
|
|
121
121
|
try {
|
|
122
|
-
|
|
122
|
+
n.removeItem(i), s.removeItem(i);
|
|
123
123
|
} catch {
|
|
124
124
|
}
|
|
125
125
|
return c;
|
|
@@ -133,10 +133,10 @@ class z {
|
|
|
133
133
|
/** @private */
|
|
134
134
|
_setInStorage(e, t) {
|
|
135
135
|
try {
|
|
136
|
-
const
|
|
137
|
-
t != null ? (
|
|
138
|
-
} catch (
|
|
139
|
-
console.error("Failed to write to storage:",
|
|
136
|
+
const n = this.storageType === "localStorage" ? localStorage : sessionStorage, s = this.storageType === "localStorage" ? sessionStorage : localStorage;
|
|
137
|
+
t != null ? (n.setItem(e, t), s.removeItem(e)) : (n.removeItem(e), s.removeItem(e));
|
|
138
|
+
} catch (n) {
|
|
139
|
+
console.error("Failed to write to storage:", n);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
/** @private */
|
|
@@ -144,12 +144,12 @@ class z {
|
|
|
144
144
|
if (e == null) return null;
|
|
145
145
|
const t = String(e).trim();
|
|
146
146
|
if (!t) return null;
|
|
147
|
-
const
|
|
148
|
-
return
|
|
147
|
+
const n = t.toLowerCase();
|
|
148
|
+
return n === "none" || n === "null" || n === "undefined" ? null : t;
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
var f, U,
|
|
152
|
-
class
|
|
151
|
+
var f, U, E;
|
|
152
|
+
class z {
|
|
153
153
|
/**
|
|
154
154
|
* @param {Object} options
|
|
155
155
|
* @param {string} options.apiBaseUrl
|
|
@@ -159,47 +159,47 @@ class E {
|
|
|
159
159
|
* @param {function(string): void} options.onTokenRefreshed
|
|
160
160
|
* @param {function(): void} options.onRefreshFailed
|
|
161
161
|
*/
|
|
162
|
-
constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager =
|
|
162
|
+
constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager: n, useCookieAuth: s = !1, onTokenRefreshed: r, onRefreshFailed: i }) {
|
|
163
|
+
A(this, U);
|
|
164
|
+
A(this, f, null);
|
|
165
|
+
this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager = n, this.useCookieAuth = s, this.onTokenRefreshed = r, this.onRefreshFailed = i;
|
|
166
166
|
}
|
|
167
167
|
async refresh() {
|
|
168
168
|
if (R(this, f))
|
|
169
169
|
return R(this, f);
|
|
170
|
-
|
|
170
|
+
T(this, f, q(this, U, E).call(this));
|
|
171
171
|
try {
|
|
172
172
|
return await R(this, f);
|
|
173
173
|
} finally {
|
|
174
|
-
|
|
174
|
+
T(this, f, null);
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
f = new WeakMap(), U = new WeakSet(),
|
|
178
|
+
f = new WeakMap(), U = new WeakSet(), E = async function() {
|
|
179
179
|
const e = this.tokenManager.getRefreshToken();
|
|
180
180
|
if (!e && !this.useCookieAuth)
|
|
181
181
|
throw this.onRefreshFailed(), new Error("No refresh token");
|
|
182
|
-
const t = JSON.stringify(e ? { refresh_token: e } : {}),
|
|
182
|
+
const t = JSON.stringify(e ? { refresh_token: e } : {}), n = await fetch(`${this.apiBaseUrl}${this.refreshEndpoint}`, {
|
|
183
183
|
...this.useCookieAuth ? { credentials: "include" } : {},
|
|
184
184
|
method: "POST",
|
|
185
185
|
headers: { "Content-Type": "application/json" },
|
|
186
186
|
body: t
|
|
187
187
|
});
|
|
188
|
-
if (!
|
|
189
|
-
throw this.onRefreshFailed(), new Error(`Refresh failed: ${
|
|
190
|
-
const
|
|
191
|
-
return this.tokenManager.setAccessToken(
|
|
188
|
+
if (!n.ok)
|
|
189
|
+
throw this.onRefreshFailed(), new Error(`Refresh failed: ${n.status}`);
|
|
190
|
+
const s = await n.json();
|
|
191
|
+
return this.tokenManager.setAccessToken(s.access_token), s.refresh_token && this.tokenManager.setRefreshToken(s.refresh_token), this.onTokenRefreshed(s.access_token), s.access_token;
|
|
192
192
|
};
|
|
193
193
|
const C = "smart_memory_sso_redirect";
|
|
194
|
-
class
|
|
194
|
+
class F {
|
|
195
195
|
/**
|
|
196
196
|
* @param {Object} options
|
|
197
197
|
* @param {string} options.webAppUrl - Web app URL for login redirect
|
|
198
198
|
* @param {string[]} [options.allowedHosts=[]] - Allowed redirect hostnames
|
|
199
199
|
* @param {import('./TokenManager.js').TokenManager} options.tokenManager
|
|
200
200
|
*/
|
|
201
|
-
constructor({ webAppUrl: e, allowedHosts: t = [], tokenManager:
|
|
202
|
-
this.webAppUrl = e, this.allowedHosts = t, this.tokenManager =
|
|
201
|
+
constructor({ webAppUrl: e, allowedHosts: t = [], tokenManager: n }) {
|
|
202
|
+
this.webAppUrl = e, this.allowedHosts = t, this.tokenManager = n;
|
|
203
203
|
}
|
|
204
204
|
getLoginUrl(e) {
|
|
205
205
|
const t = e || `${window.location.origin}/auth/callback`;
|
|
@@ -230,24 +230,24 @@ class x {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
class
|
|
233
|
+
class O {
|
|
234
234
|
constructor(e) {
|
|
235
|
-
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
|
|
235
|
+
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({
|
|
236
236
|
storage: e.storage || "localStorage",
|
|
237
237
|
keys: e.tokenKeys
|
|
238
|
-
}), this.mode !== "apiKey" ? this.refreshManager = new
|
|
238
|
+
}), this.mode !== "apiKey" ? this.refreshManager = new z({
|
|
239
239
|
apiBaseUrl: this.apiBaseUrl,
|
|
240
240
|
refreshEndpoint: this.endpoints.refresh || "/auth/refresh",
|
|
241
241
|
tokenManager: this.tokenManager,
|
|
242
242
|
useCookieAuth: this.useCookieAuth,
|
|
243
243
|
onTokenRefreshed: (t) => {
|
|
244
|
-
var
|
|
245
|
-
this.currentToken = t, this.notifyListeners(), (
|
|
244
|
+
var n;
|
|
245
|
+
this.currentToken = t, this.notifyListeners(), (n = e.onTokenRefresh) == null || n.call(e, t);
|
|
246
246
|
},
|
|
247
247
|
onRefreshFailed: () => {
|
|
248
248
|
this.clearLocalAuth();
|
|
249
249
|
}
|
|
250
|
-
}) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new
|
|
250
|
+
}) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new F({
|
|
251
251
|
webAppUrl: e.webAppUrl,
|
|
252
252
|
allowedHosts: e.allowedRedirectHosts || [],
|
|
253
253
|
tokenManager: this.tokenManager
|
|
@@ -266,14 +266,14 @@ class F {
|
|
|
266
266
|
return this.tokenManager.getTenantId();
|
|
267
267
|
}
|
|
268
268
|
hasRole(e) {
|
|
269
|
-
var t,
|
|
270
|
-
return ((
|
|
269
|
+
var t, n;
|
|
270
|
+
return ((n = (t = this.currentUser) == null ? void 0 : t.roles) == null ? void 0 : n.includes(e)) || !1;
|
|
271
271
|
}
|
|
272
272
|
getAuthHeaders(e = {}) {
|
|
273
273
|
const t = { ...e };
|
|
274
274
|
this.currentToken && (t.Authorization = this.currentToken.startsWith("Bearer ") ? this.currentToken : `Bearer ${this.currentToken}`);
|
|
275
|
-
const
|
|
276
|
-
return
|
|
275
|
+
const n = this.tokenManager.getTeamId();
|
|
276
|
+
return n && (t["X-Workspace-Id"] = n), t;
|
|
277
277
|
}
|
|
278
278
|
getRequestOptions(e = {}) {
|
|
279
279
|
return this.useCookieAuth ? { credentials: "include", ...e } : { ...e };
|
|
@@ -292,8 +292,8 @@ class F {
|
|
|
292
292
|
this.listeners.forEach((t) => {
|
|
293
293
|
try {
|
|
294
294
|
t(e);
|
|
295
|
-
} catch (
|
|
296
|
-
console.error("Auth listener error:",
|
|
295
|
+
} catch (n) {
|
|
296
|
+
console.error("Auth listener error:", n);
|
|
297
297
|
}
|
|
298
298
|
});
|
|
299
299
|
}
|
|
@@ -342,11 +342,11 @@ class F {
|
|
|
342
342
|
let t = await fetch(
|
|
343
343
|
e,
|
|
344
344
|
this.getRequestOptions({ method: "GET", headers: this.getAuthHeaders() })
|
|
345
|
-
),
|
|
345
|
+
), n = !1;
|
|
346
346
|
if (!t.ok && (this.currentToken || this.tokenManager.getTeamId()) && (t = await fetch(
|
|
347
347
|
e,
|
|
348
348
|
this.getRequestOptions({ method: "GET", headers: {} })
|
|
349
|
-
),
|
|
349
|
+
), n = t.ok), !t.ok && t.status === 401 && this.refreshManager)
|
|
350
350
|
try {
|
|
351
351
|
await this.refreshManager.refresh(), t = await fetch(
|
|
352
352
|
e,
|
|
@@ -355,10 +355,10 @@ class F {
|
|
|
355
355
|
} catch {
|
|
356
356
|
}
|
|
357
357
|
if (!t.ok) return !1;
|
|
358
|
-
const
|
|
359
|
-
this.currentUser =
|
|
360
|
-
const r = (
|
|
361
|
-
return r && (this.tokenManager.setTeamId(r), this.tokenManager.setTenantId((
|
|
358
|
+
const s = await t.json();
|
|
359
|
+
this.currentUser = s, this.tokenManager.setUser(s);
|
|
360
|
+
const r = (s == null ? void 0 : s.default_team_id) || this.tokenManager.getTeamId() || null;
|
|
361
|
+
return r && (this.tokenManager.setTeamId(r), this.tokenManager.setTenantId((s == null ? void 0 : s.tenant_id) || r)), n && (this.tokenManager.setAccessToken(null), this.currentToken = null, s != null && s.default_team_id && this.tokenManager.setTeamId(s.default_team_id)), this.notifyListeners(), !0;
|
|
362
362
|
} catch {
|
|
363
363
|
return !1;
|
|
364
364
|
}
|
|
@@ -373,14 +373,17 @@ class k extends Error {
|
|
|
373
373
|
* @param {number} [status=0] - HTTP status code (0 for network errors)
|
|
374
374
|
* @param {Object|null} [detail=null] - Error detail from API response
|
|
375
375
|
*/
|
|
376
|
-
constructor(e, t = 0,
|
|
377
|
-
super(e), this.name = "APIError", this.status = t, this.detail =
|
|
376
|
+
constructor(e, t = 0, n = null) {
|
|
377
|
+
super(e), this.name = "APIError", this.status = t, this.detail = n;
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
function S(a) {
|
|
381
381
|
return typeof FormData < "u" && a instanceof FormData;
|
|
382
382
|
}
|
|
383
|
-
|
|
383
|
+
function L(a) {
|
|
384
|
+
return (a == null ? void 0 : a.name) === "AbortError";
|
|
385
|
+
}
|
|
386
|
+
class j {
|
|
384
387
|
/**
|
|
385
388
|
* @param {import('../auth/AuthCore.js').AuthCore} authCore
|
|
386
389
|
* @param {{ fetchFn?: typeof globalThis.fetch }} [options]
|
|
@@ -391,14 +394,24 @@ class O {
|
|
|
391
394
|
get fetchFn() {
|
|
392
395
|
return this._customFetchFn || globalThis.fetch.bind(globalThis);
|
|
393
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Issue an authenticated request.
|
|
399
|
+
*
|
|
400
|
+
* `options` is forwarded to `fetch` (via `AuthCore.getRequestOptions`), so any standard
|
|
401
|
+
* `RequestInit` key applies — notably `signal`, which cancels an in-flight request.
|
|
402
|
+
* An aborted request rejects with the original `AbortError`, not an `APIError`.
|
|
403
|
+
*
|
|
404
|
+
* @param {string} endpoint - Path appended to the client's base URL.
|
|
405
|
+
* @param {RequestInit & { signal?: AbortSignal }} [options]
|
|
406
|
+
*/
|
|
394
407
|
async request(e, t = {}) {
|
|
395
408
|
var i, c;
|
|
396
|
-
const
|
|
409
|
+
const n = `${this.baseURL}${e}`, s = {
|
|
397
410
|
...S(t.body) ? {} : { "Content-Type": "application/json" },
|
|
398
411
|
...this.auth.getAuthHeaders(t.headers)
|
|
399
|
-
}, r = this.auth.getRequestOptions({ ...t, headers:
|
|
412
|
+
}, r = this.auth.getRequestOptions({ ...t, headers: s });
|
|
400
413
|
try {
|
|
401
|
-
let o = await this.fetchFn(
|
|
414
|
+
let o = await this.fetchFn(n, r);
|
|
402
415
|
if (o.status === 401 && !t.__isRetry)
|
|
403
416
|
try {
|
|
404
417
|
await this.auth.refreshToken();
|
|
@@ -407,7 +420,7 @@ class O {
|
|
|
407
420
|
...this.auth.getAuthHeaders(t.headers)
|
|
408
421
|
};
|
|
409
422
|
o = await this.fetchFn(
|
|
410
|
-
|
|
423
|
+
n,
|
|
411
424
|
this.auth.getRequestOptions({ ...r, headers: h, __isRetry: !0 })
|
|
412
425
|
);
|
|
413
426
|
} catch {
|
|
@@ -420,27 +433,27 @@ class O {
|
|
|
420
433
|
throw await this._handleError(o);
|
|
421
434
|
return await o.json();
|
|
422
435
|
} catch (o) {
|
|
423
|
-
throw o instanceof k ? o : new k(o.message, 0, "network_error");
|
|
436
|
+
throw o instanceof k || L(o) ? o : new k(o.message, 0, "network_error");
|
|
424
437
|
}
|
|
425
438
|
}
|
|
426
439
|
async get(e, t = {}) {
|
|
427
440
|
return this.request(e, { ...t, method: "GET" });
|
|
428
441
|
}
|
|
429
|
-
async post(e, t,
|
|
442
|
+
async post(e, t, n = {}) {
|
|
430
443
|
return this.request(e, {
|
|
431
|
-
...
|
|
444
|
+
...n,
|
|
432
445
|
method: "POST",
|
|
433
446
|
body: JSON.stringify(t)
|
|
434
447
|
});
|
|
435
448
|
}
|
|
436
449
|
async requestBinary(e, t = {}) {
|
|
437
450
|
var i, c;
|
|
438
|
-
const
|
|
451
|
+
const n = `${this.baseURL}${e}`, s = {
|
|
439
452
|
...S(t.body) ? {} : { "Content-Type": "application/json" },
|
|
440
453
|
...this.auth.getAuthHeaders(t.headers)
|
|
441
|
-
}, r = this.auth.getRequestOptions({ ...t, headers:
|
|
454
|
+
}, r = this.auth.getRequestOptions({ ...t, headers: s });
|
|
442
455
|
try {
|
|
443
|
-
let o = await this.fetchFn(
|
|
456
|
+
let o = await this.fetchFn(n, r);
|
|
444
457
|
if (o.status === 401 && !t.__isRetry)
|
|
445
458
|
try {
|
|
446
459
|
await this.auth.refreshToken();
|
|
@@ -449,7 +462,7 @@ class O {
|
|
|
449
462
|
...this.auth.getAuthHeaders(t.headers)
|
|
450
463
|
};
|
|
451
464
|
o = await this.fetchFn(
|
|
452
|
-
|
|
465
|
+
n,
|
|
453
466
|
this.auth.getRequestOptions({ ...r, headers: h, __isRetry: !0 })
|
|
454
467
|
);
|
|
455
468
|
} catch {
|
|
@@ -460,26 +473,26 @@ class O {
|
|
|
460
473
|
throw await this._handleError(o);
|
|
461
474
|
return await o.arrayBuffer();
|
|
462
475
|
} catch (o) {
|
|
463
|
-
throw o instanceof k ? o : new k(o.message, 0, "network_error");
|
|
476
|
+
throw o instanceof k || L(o) ? o : new k(o.message, 0, "network_error");
|
|
464
477
|
}
|
|
465
478
|
}
|
|
466
|
-
async postForm(e, t,
|
|
479
|
+
async postForm(e, t, n = {}) {
|
|
467
480
|
return this.request(e, {
|
|
468
|
-
...
|
|
481
|
+
...n,
|
|
469
482
|
method: "POST",
|
|
470
483
|
body: t
|
|
471
484
|
});
|
|
472
485
|
}
|
|
473
|
-
async put(e, t,
|
|
486
|
+
async put(e, t, n = {}) {
|
|
474
487
|
return this.request(e, {
|
|
475
|
-
...
|
|
488
|
+
...n,
|
|
476
489
|
method: "PUT",
|
|
477
490
|
body: JSON.stringify(t)
|
|
478
491
|
});
|
|
479
492
|
}
|
|
480
|
-
async patch(e, t,
|
|
493
|
+
async patch(e, t, n = {}) {
|
|
481
494
|
return this.request(e, {
|
|
482
|
-
...
|
|
495
|
+
...n,
|
|
483
496
|
method: "PATCH",
|
|
484
497
|
body: JSON.stringify(t)
|
|
485
498
|
});
|
|
@@ -489,11 +502,11 @@ class O {
|
|
|
489
502
|
}
|
|
490
503
|
/** @private */
|
|
491
504
|
async _handleError(e) {
|
|
492
|
-
var
|
|
505
|
+
var s, r;
|
|
493
506
|
let t;
|
|
494
|
-
const
|
|
507
|
+
const n = (r = (s = e.headers) == null ? void 0 : s.get) == null ? void 0 : r.call(s, "content-type");
|
|
495
508
|
try {
|
|
496
|
-
|
|
509
|
+
n != null && n.includes("application/json") ? t = await e.json() : t = { message: await e.text() };
|
|
497
510
|
} catch {
|
|
498
511
|
t = { message: `HTTP ${e.status}` };
|
|
499
512
|
}
|
|
@@ -516,18 +529,18 @@ class O {
|
|
|
516
529
|
* @private
|
|
517
530
|
*/
|
|
518
531
|
_extractMessage(e, t) {
|
|
519
|
-
var
|
|
520
|
-
const
|
|
521
|
-
if (typeof
|
|
522
|
-
if (
|
|
523
|
-
if (typeof
|
|
524
|
-
if (typeof
|
|
525
|
-
if (Array.isArray(
|
|
532
|
+
var s;
|
|
533
|
+
const n = e == null ? void 0 : e.detail;
|
|
534
|
+
if (typeof n == "string") return n;
|
|
535
|
+
if (n && typeof n == "object") {
|
|
536
|
+
if (typeof n.message == "string") return n.message;
|
|
537
|
+
if (typeof n.code == "string") return n.code;
|
|
538
|
+
if (Array.isArray(n) && typeof ((s = n[0]) == null ? void 0 : s.msg) == "string") return n[0].msg;
|
|
526
539
|
}
|
|
527
540
|
return typeof (e == null ? void 0 : e.message) == "string" ? e.message : `HTTP ${t}`;
|
|
528
541
|
}
|
|
529
542
|
}
|
|
530
|
-
class
|
|
543
|
+
class B {
|
|
531
544
|
constructor(e) {
|
|
532
545
|
this.api = e;
|
|
533
546
|
}
|
|
@@ -554,8 +567,8 @@ class j {
|
|
|
554
567
|
async create({
|
|
555
568
|
content: e,
|
|
556
569
|
memoryType: t = "semantic",
|
|
557
|
-
metadata:
|
|
558
|
-
usePipeline:
|
|
570
|
+
metadata: n = null,
|
|
571
|
+
usePipeline: s = !0,
|
|
559
572
|
profileName: r = null,
|
|
560
573
|
conversationContext: i = null,
|
|
561
574
|
embed: c = null
|
|
@@ -563,8 +576,8 @@ class j {
|
|
|
563
576
|
const o = {
|
|
564
577
|
content: e,
|
|
565
578
|
memory_type: t,
|
|
566
|
-
metadata:
|
|
567
|
-
use_pipeline:
|
|
579
|
+
metadata: n,
|
|
580
|
+
use_pipeline: s,
|
|
568
581
|
profile_name: r
|
|
569
582
|
};
|
|
570
583
|
return i != null && (o.conversation_context = i), c != null && (o.embed = c), this.api.post("/memory/add", o);
|
|
@@ -589,11 +602,11 @@ class j {
|
|
|
589
602
|
async update(e, t) {
|
|
590
603
|
return this.api.patch(`/memory/${encodeURIComponent(e)}`, t);
|
|
591
604
|
}
|
|
592
|
-
async supersede(e, { content: t, memoryType:
|
|
605
|
+
async supersede(e, { content: t, memoryType: n, metadata: s = {}, reason: r }) {
|
|
593
606
|
return this.api.post(`/memory/${encodeURIComponent(e)}/supersede`, {
|
|
594
607
|
content: t,
|
|
595
|
-
memory_type:
|
|
596
|
-
metadata:
|
|
608
|
+
memory_type: n,
|
|
609
|
+
metadata: s,
|
|
597
610
|
reason: r
|
|
598
611
|
});
|
|
599
612
|
}
|
|
@@ -613,10 +626,10 @@ class j {
|
|
|
613
626
|
* @throws 400 if `newItemId` equals `id`; 404 if either item is missing *or*
|
|
614
627
|
* out of scope (deliberately indistinguishable); 409 if the store declined.
|
|
615
628
|
*/
|
|
616
|
-
async supersedeLink(e, t,
|
|
629
|
+
async supersedeLink(e, t, n = null) {
|
|
617
630
|
return this.api.post(`/memory/${encodeURIComponent(e)}/supersede-link`, {
|
|
618
631
|
new_item_id: t,
|
|
619
|
-
reason:
|
|
632
|
+
reason: n
|
|
620
633
|
});
|
|
621
634
|
}
|
|
622
635
|
async delete(e) {
|
|
@@ -641,12 +654,12 @@ class j {
|
|
|
641
654
|
async list({
|
|
642
655
|
limit: e = 50,
|
|
643
656
|
offset: t = 0,
|
|
644
|
-
type:
|
|
645
|
-
metadataKey:
|
|
657
|
+
type: n = null,
|
|
658
|
+
metadataKey: s = null,
|
|
646
659
|
metadataValue: r = null
|
|
647
660
|
} = {}) {
|
|
648
661
|
const i = new URLSearchParams({ limit: e, offset: t });
|
|
649
|
-
return
|
|
662
|
+
return n && i.append("memory_type", n), s != null && i.append("metadata_key", s), r != null && i.append("metadata_value", r), this.api.get(`/memory/list?${i}`);
|
|
650
663
|
}
|
|
651
664
|
/**
|
|
652
665
|
* Search for memory items.
|
|
@@ -696,9 +709,9 @@ class j {
|
|
|
696
709
|
* result marked `'unresolved'` is PRESENT-DAY content and must not be rendered
|
|
697
710
|
* as a historical belief.
|
|
698
711
|
*/
|
|
699
|
-
async search(e, { topK: t = 5, enableHybrid:
|
|
700
|
-
const l = { query: e, top_k: t, enable_hybrid:
|
|
701
|
-
return
|
|
712
|
+
async search(e, { topK: t = 5, enableHybrid: n = !0, memoryType: s = null, expertise: r = !1, cite: i = !1, decompose: c = !1, multiHop: o = !1, maxHops: h = 3, budgetMs: y = 1500, semanticHops: p = !1, includeReference: d = !1, includeConsolidated: _ = !1, consolidationFirst: $ = !1, asOfDate: g = null, asOfStrict: u = !1, includeSuperseded: b = !1, includeRetracted: I = !1 } = {}) {
|
|
713
|
+
const l = { query: e, top_k: t, enable_hybrid: n };
|
|
714
|
+
return s && (l.memory_type = s), r && (l.expertise = !0), i && (l.cite = !0), c && (l.decompose = !0), o && (l.multi_hop = !0), o && h !== 3 && (l.max_hops = h), o && y !== 1500 && (l.budget_ms = y), o && p && (l.semantic_hops = !0), d && (l.include_reference = !0), _ && (l.include_consolidated = !0), $ && (l.consolidation_first = !0), g && (l.as_of_date = g instanceof Date ? g.toISOString() : g), u && (l.as_of_strict = !0), b && (l.include_superseded = !0), I && (l.include_retracted = !0), this.api.post("/memory/search", l);
|
|
702
715
|
}
|
|
703
716
|
/**
|
|
704
717
|
* Get the complete audit answer for one memory (PLAT-AUDITABLE-MEMORY-1).
|
|
@@ -716,28 +729,28 @@ class j {
|
|
|
716
729
|
async explain(e) {
|
|
717
730
|
return this.api.get(`/memory/${encodeURIComponent(e)}/explain`);
|
|
718
731
|
}
|
|
719
|
-
async getWorkingContext(e, t, { k:
|
|
732
|
+
async getWorkingContext(e, t, { k: n = 20, maxTokens: s = null, strategy: r = null } = {}) {
|
|
720
733
|
const i = {
|
|
721
734
|
session_id: e,
|
|
722
735
|
query: t,
|
|
723
|
-
k:
|
|
736
|
+
k: n
|
|
724
737
|
};
|
|
725
|
-
return
|
|
738
|
+
return s != null && (i.max_tokens = s), r != null && (i.strategy = r), this.api.post("/memory/context", i);
|
|
726
739
|
}
|
|
727
|
-
async searchAdvanced(e, { algorithm: t = "query_traversal", maxResults:
|
|
740
|
+
async searchAdvanced(e, { algorithm: t = "query_traversal", maxResults: n = 15, useSSG: s = !0 } = {}) {
|
|
728
741
|
return this.api.post("/memory/search/advanced", {
|
|
729
742
|
query: e,
|
|
730
743
|
algorithm: t,
|
|
731
|
-
max_results:
|
|
732
|
-
use_ssg:
|
|
744
|
+
max_results: n,
|
|
745
|
+
use_ssg: s
|
|
733
746
|
});
|
|
734
747
|
}
|
|
735
|
-
async ingest(e, { profileName: t = null, extractorName:
|
|
748
|
+
async ingest(e, { profileName: t = null, extractorName: n = "llm", context: s = {} } = {}) {
|
|
736
749
|
return this.api.post("/memory/ingest", {
|
|
737
750
|
content: e,
|
|
738
751
|
profile_name: t,
|
|
739
|
-
extractor_name:
|
|
740
|
-
context:
|
|
752
|
+
extractor_name: n,
|
|
753
|
+
context: s
|
|
741
754
|
});
|
|
742
755
|
}
|
|
743
756
|
async getLineage(e) {
|
|
@@ -755,13 +768,13 @@ class j {
|
|
|
755
768
|
* endpoints return slightly different item shapes, so migrate deliberately rather
|
|
756
769
|
* than by find-and-replace.
|
|
757
770
|
*/
|
|
758
|
-
async searchByMetadata(e, t, { memoryType:
|
|
771
|
+
async searchByMetadata(e, t, { memoryType: n = null, limit: s = 25 } = {}) {
|
|
759
772
|
const r = new URLSearchParams({
|
|
760
773
|
metadata_key: e,
|
|
761
774
|
metadata_value: t,
|
|
762
|
-
limit:
|
|
775
|
+
limit: s
|
|
763
776
|
});
|
|
764
|
-
return
|
|
777
|
+
return n && r.append("memory_type", n), this.api.get(`/memory/by-metadata?${r}`);
|
|
765
778
|
}
|
|
766
779
|
async getNeighbors(e) {
|
|
767
780
|
return this.api.get(`/memory/${encodeURIComponent(e)}/neighbors`);
|
|
@@ -771,43 +784,71 @@ class j {
|
|
|
771
784
|
}
|
|
772
785
|
async ingestConversation(e, {
|
|
773
786
|
sessionBoundaries: t = null,
|
|
774
|
-
conversationId:
|
|
775
|
-
sessionDates:
|
|
787
|
+
conversationId: n = null,
|
|
788
|
+
sessionDates: s = null,
|
|
776
789
|
turnsPerChunk: r = 15,
|
|
777
790
|
maxChunkChars: i = 12e3,
|
|
778
791
|
maxConcurrent: c = 4
|
|
779
792
|
} = {}) {
|
|
780
793
|
const o = { turns: e, turns_per_chunk: r, max_chunk_chars: i, max_concurrent: c };
|
|
781
|
-
return t && (o.session_boundaries = t),
|
|
794
|
+
return t && (o.session_boundaries = t), n && (o.conversation_id = n), s && (o.session_dates = s), this.api.post("/memory/ingest/conversation", o);
|
|
782
795
|
}
|
|
783
|
-
async ingestDocument(e, { title: t = null, source:
|
|
796
|
+
async ingestDocument(e, { title: t = null, source: n = null, chunkStrategy: s = null } = {}) {
|
|
784
797
|
const r = { content: e };
|
|
785
|
-
return t && (r.title = t),
|
|
798
|
+
return t && (r.title = t), n && (r.source = n), s && (r.chunk_strategy = s), this.api.post("/memory/ingest/document", r);
|
|
786
799
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
800
|
+
/**
|
|
801
|
+
* Import a ChatGPT or Claude conversation export (DIST-CHAT-IMPORT-1).
|
|
802
|
+
*
|
|
803
|
+
* Conversations run through the normal conversation pipeline, so entities and
|
|
804
|
+
* relations are extracted exactly as for a live conversation. Items land with
|
|
805
|
+
* origin `import:chatgpt_export` / `import:claude_export` — tier 1, so they are
|
|
806
|
+
* recallable, and dedupe-eligible, so re-uploading a later export updates the
|
|
807
|
+
* overlap rather than duplicating it.
|
|
808
|
+
*
|
|
809
|
+
* @param {Blob|File} file - The vendor .zip as downloaded, or its conversations.json.
|
|
810
|
+
* @param {object} [options]
|
|
811
|
+
* @param {string} [options.sourceFormat='auto'] - 'auto' | 'chatgpt' | 'claude'.
|
|
812
|
+
* @param {number} [options.maxConversations=25] - Cap on conversations ingested (1-200).
|
|
813
|
+
* The import is synchronous and each conversation runs the full pipeline, so this
|
|
814
|
+
* bound is real. Longest conversations are kept first.
|
|
815
|
+
* @returns {Promise<object>} `{ source_format, conversations_imported,
|
|
816
|
+
* conversations_failed, turns_imported, items_created, warnings }`. Always check
|
|
817
|
+
* `warnings` — a non-empty list means something was capped, skipped, or degraded
|
|
818
|
+
* even though the call succeeded.
|
|
819
|
+
*/
|
|
820
|
+
async importChatExport(e, { sourceFormat: t = "auto", maxConversations: n = 25 } = {}) {
|
|
821
|
+
const s = new FormData();
|
|
822
|
+
return s.append("file", e, e.name || "conversations.json"), s.append("source_format", t), s.append("max_conversations", String(n)), this.api.post("/memory/import/chat-export", s);
|
|
823
|
+
}
|
|
824
|
+
/** List supported chat-export formats and how a user obtains each export. */
|
|
825
|
+
async chatExportFormats() {
|
|
826
|
+
return this.api.get("/memory/import/chat-export/formats");
|
|
827
|
+
}
|
|
828
|
+
async codeIndex(e, { repo: t = null, commit: n = null } = {}) {
|
|
829
|
+
const s = { path: e };
|
|
830
|
+
return t && (s.repo = t), n && (s.commit = n), this.api.post("/memory/code/index", s);
|
|
831
|
+
}
|
|
832
|
+
async codeSearch(e, { entityType: t = null, repo: n = null, limit: s = 20, semantic: r = !1 } = {}) {
|
|
833
|
+
const i = new URLSearchParams({ query: e, limit: s, semantic: r });
|
|
834
|
+
return t && i.append("entity_type", t), n && i.append("repo", n), this.api.get(`/memory/code/search?${i}`);
|
|
794
835
|
}
|
|
795
836
|
async codeContext(e, { repo: t = null } = {}) {
|
|
796
|
-
const
|
|
797
|
-
return t &&
|
|
837
|
+
const n = new URLSearchParams({ entity_name: e });
|
|
838
|
+
return t && n.append("repo", t), this.api.get(`/memory/code/context?${n}`);
|
|
798
839
|
}
|
|
799
840
|
async codeDeadCode(e) {
|
|
800
841
|
return this.api.get(`/memory/code/dead-code?repo=${encodeURIComponent(e)}`);
|
|
801
842
|
}
|
|
802
|
-
async codeDependencies(e, { direction: t = "both", repo:
|
|
803
|
-
const
|
|
804
|
-
return
|
|
843
|
+
async codeDependencies(e, { direction: t = "both", repo: n = null } = {}) {
|
|
844
|
+
const s = new URLSearchParams({ entity_name: e, direction: t });
|
|
845
|
+
return n && s.append("repo", n), this.api.get(`/memory/code/dependencies?${s}`);
|
|
805
846
|
}
|
|
806
847
|
async getPlan(e) {
|
|
807
848
|
return this.api.get(`/memory/plans/${e}`);
|
|
808
849
|
}
|
|
809
|
-
async updatePlanTask(e, { taskId: t, status:
|
|
810
|
-
return this.api.patch(`/memory/plans/${e}/task`, { task_id: t, status:
|
|
850
|
+
async updatePlanTask(e, { taskId: t, status: n }) {
|
|
851
|
+
return this.api.patch(`/memory/plans/${e}/task`, { task_id: t, status: n });
|
|
811
852
|
}
|
|
812
853
|
async completePlan(e, { graduate: t = !1 } = {}) {
|
|
813
854
|
return this.api.post(`/memory/plans/${e}/complete`, { graduate: t });
|
|
@@ -815,11 +856,11 @@ class j {
|
|
|
815
856
|
async failPlan(e, t) {
|
|
816
857
|
return this.api.post(`/memory/plans/${e}/fail`, { reason: t });
|
|
817
858
|
}
|
|
818
|
-
async link(e, t,
|
|
859
|
+
async link(e, t, n = "RELATED") {
|
|
819
860
|
return this.api.post("/memory/link", {
|
|
820
861
|
source_id: e,
|
|
821
862
|
target_id: t,
|
|
822
|
-
link_type:
|
|
863
|
+
link_type: n
|
|
823
864
|
});
|
|
824
865
|
}
|
|
825
866
|
async enrich(e, t = []) {
|
|
@@ -843,44 +884,44 @@ class j {
|
|
|
843
884
|
* @param {string} [query] - Original query that produced these results.
|
|
844
885
|
* @returns {Promise<{updated: number, edges_strengthened: number, outcome: string}>}
|
|
845
886
|
*/
|
|
846
|
-
async feedback(e, t,
|
|
847
|
-
const
|
|
848
|
-
return
|
|
887
|
+
async feedback(e, t, n = null) {
|
|
888
|
+
const s = { item_ids: e, outcome: t };
|
|
889
|
+
return n != null && (s.query = n), this.api.post("/memory/feedback", s);
|
|
849
890
|
}
|
|
850
|
-
async ground(e, t,
|
|
891
|
+
async ground(e, t, n = null) {
|
|
851
892
|
return this.api.post(`/memory/${encodeURIComponent(e)}/ground`, {
|
|
852
893
|
item_id: e,
|
|
853
894
|
source_url: t,
|
|
854
|
-
validation:
|
|
895
|
+
validation: n
|
|
855
896
|
});
|
|
856
897
|
}
|
|
857
898
|
async clearAll(e = !1) {
|
|
858
899
|
return this.api.delete(`/memory/clear-all?nuclear=${e}`);
|
|
859
900
|
}
|
|
860
901
|
// --- Temporal ---
|
|
861
|
-
async getHistory(e, { startTime: t = null, endTime:
|
|
862
|
-
let r = `/memory/temporal/${e}/history?limit=${
|
|
863
|
-
return t && (r += `&start_time=${t}`),
|
|
902
|
+
async getHistory(e, { startTime: t = null, endTime: n = null, limit: s = 100 } = {}) {
|
|
903
|
+
let r = `/memory/temporal/${e}/history?limit=${s}`;
|
|
904
|
+
return t && (r += `&start_time=${t}`), n && (r += `&end_time=${n}`), this.api.get(r);
|
|
864
905
|
}
|
|
865
|
-
async timeTravel(e, { query: t = null, limit:
|
|
866
|
-
let
|
|
867
|
-
return t && (
|
|
906
|
+
async timeTravel(e, { query: t = null, limit: n = 100 } = {}) {
|
|
907
|
+
let s = `/memory/temporal/at/${e}?limit=${n}`;
|
|
908
|
+
return t && (s += `&query=${encodeURIComponent(t)}`), this.api.get(s);
|
|
868
909
|
}
|
|
869
910
|
async getItemAtTime(e, t) {
|
|
870
911
|
return this.api.get(`/memory/temporal/${e}/at/${t}`);
|
|
871
912
|
}
|
|
872
|
-
async getChanges(e, { since: t = null, until:
|
|
913
|
+
async getChanges(e, { since: t = null, until: n = null, changeType: s = null } = {}) {
|
|
873
914
|
let r = `/memory/temporal/${e}/changes`;
|
|
874
915
|
const i = [];
|
|
875
|
-
return t && i.push(`since=${t}`),
|
|
916
|
+
return t && i.push(`since=${t}`), n && i.push(`until=${n}`), s && i.push(`change_type=${s}`), i.length && (r += `?${i.join("&")}`), this.api.get(r);
|
|
876
917
|
}
|
|
877
|
-
async compareVersions(e, t,
|
|
878
|
-
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${
|
|
918
|
+
async compareVersions(e, t, n) {
|
|
919
|
+
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${n}`);
|
|
879
920
|
}
|
|
880
|
-
async rollback(e, { toVersion: t = null, toTime:
|
|
881
|
-
let
|
|
921
|
+
async rollback(e, { toVersion: t = null, toTime: n = null } = {}) {
|
|
922
|
+
let s = `/memory/temporal/${e}/rollback`;
|
|
882
923
|
const r = [];
|
|
883
|
-
return t !== null && r.push(`to_version=${t}`),
|
|
924
|
+
return t !== null && r.push(`to_version=${t}`), n && r.push(`to_time=${n}`), r.length && (s += `?${r.join("&")}`), this.api.post(s);
|
|
884
925
|
}
|
|
885
926
|
// --- Clustering ---
|
|
886
927
|
async runClustering(e = 0.1, t = !1) {
|
|
@@ -912,8 +953,8 @@ class H {
|
|
|
912
953
|
async create({
|
|
913
954
|
content: e,
|
|
914
955
|
decisionType: t = "inference",
|
|
915
|
-
confidence:
|
|
916
|
-
sourceTraceId:
|
|
956
|
+
confidence: n = 0.8,
|
|
957
|
+
sourceTraceId: s = null,
|
|
917
958
|
sourceSessionId: r = null,
|
|
918
959
|
evidenceIds: i = null,
|
|
919
960
|
domain: c = null,
|
|
@@ -926,8 +967,8 @@ class H {
|
|
|
926
967
|
return this.api.post("/memory/decisions/create", {
|
|
927
968
|
content: e,
|
|
928
969
|
decision_type: t,
|
|
929
|
-
confidence:
|
|
930
|
-
source_trace_id:
|
|
970
|
+
confidence: n,
|
|
971
|
+
source_trace_id: s,
|
|
931
972
|
source_session_id: r,
|
|
932
973
|
evidence_ids: i,
|
|
933
974
|
domain: c,
|
|
@@ -981,12 +1022,12 @@ class H {
|
|
|
981
1022
|
* @param {string[]} [params.tags]
|
|
982
1023
|
* @param {string} [params.agentId]
|
|
983
1024
|
*/
|
|
984
|
-
async createPending({ content: e, requirements: t, domain:
|
|
1025
|
+
async createPending({ content: e, requirements: t, domain: n = null, tags: s = null, agentId: r = null }) {
|
|
985
1026
|
return this.api.post("/memory/decisions/pending/create", {
|
|
986
1027
|
content: e,
|
|
987
1028
|
requirements: t,
|
|
988
|
-
domain:
|
|
989
|
-
tags:
|
|
1029
|
+
domain: n,
|
|
1030
|
+
tags: s,
|
|
990
1031
|
agent_id: r
|
|
991
1032
|
});
|
|
992
1033
|
}
|
|
@@ -997,10 +1038,10 @@ class H {
|
|
|
997
1038
|
* @param {string} params.requirementId
|
|
998
1039
|
* @param {string} params.memoryId
|
|
999
1040
|
*/
|
|
1000
|
-
async resolveRequirement(e, { requirementId: t, memoryId:
|
|
1041
|
+
async resolveRequirement(e, { requirementId: t, memoryId: n }) {
|
|
1001
1042
|
return this.api.post(`/memory/decisions/pending/${e}/resolve`, {
|
|
1002
1043
|
requirement_id: t,
|
|
1003
|
-
memory_id:
|
|
1044
|
+
memory_id: n
|
|
1004
1045
|
});
|
|
1005
1046
|
}
|
|
1006
1047
|
/**
|
|
@@ -1073,8 +1114,8 @@ class H {
|
|
|
1073
1114
|
* @param {string} [options.direction='both'] - causes|effects|both
|
|
1074
1115
|
* @param {number} [options.maxDepth=3]
|
|
1075
1116
|
*/
|
|
1076
|
-
async getCausalChain(e, { direction: t = "both", maxDepth:
|
|
1077
|
-
return this.api.get(`/memory/decisions/${e}/causal-chain?direction=${t}&max_depth=${
|
|
1117
|
+
async getCausalChain(e, { direction: t = "both", maxDepth: n = 3 } = {}) {
|
|
1118
|
+
return this.api.get(`/memory/decisions/${e}/causal-chain?direction=${t}&max_depth=${n}`);
|
|
1078
1119
|
}
|
|
1079
1120
|
/**
|
|
1080
1121
|
* Find existing decisions that may conflict with this one.
|
|
@@ -1108,7 +1149,7 @@ class H {
|
|
|
1108
1149
|
});
|
|
1109
1150
|
}
|
|
1110
1151
|
}
|
|
1111
|
-
class
|
|
1152
|
+
class K {
|
|
1112
1153
|
constructor(e) {
|
|
1113
1154
|
this.api = e;
|
|
1114
1155
|
}
|
|
@@ -1126,30 +1167,37 @@ class B {
|
|
|
1126
1167
|
* server auto-populate from scope.resolve_agent_id().
|
|
1127
1168
|
*/
|
|
1128
1169
|
async createOpinion(e, t = {}) {
|
|
1129
|
-
const
|
|
1130
|
-
return t.confidence !== void 0 && (
|
|
1170
|
+
const n = { content: e };
|
|
1171
|
+
return t.confidence !== void 0 && (n.confidence = t.confidence), t.subject !== void 0 && (n.subject = t.subject), t.subjectType !== void 0 && (n.subject_type = t.subjectType), t.disposition !== void 0 && (n.disposition = t.disposition), t.formedFrom !== void 0 && (n.formed_from = t.formedFrom), t.domain !== void 0 && (n.domain = t.domain), t.agentId !== void 0 && (n.agent_id = t.agentId), this.api.post("/memory/opinions/create", n);
|
|
1131
1172
|
}
|
|
1132
1173
|
}
|
|
1133
|
-
class
|
|
1174
|
+
class G {
|
|
1134
1175
|
constructor(e) {
|
|
1135
1176
|
this.api = e;
|
|
1136
1177
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1178
|
+
/**
|
|
1179
|
+
* Fetch a memory item's graph neighbours.
|
|
1180
|
+
* @param {string} itemId
|
|
1181
|
+
* @param {{ signal?: AbortSignal }} [options]
|
|
1182
|
+
*/
|
|
1183
|
+
async getNeighbors(e, t = {}) {
|
|
1184
|
+
return this.api.get(`/memory/${encodeURIComponent(e)}/neighbors`, t);
|
|
1139
1185
|
}
|
|
1140
|
-
async addEdge(e, t,
|
|
1186
|
+
async addEdge(e, t, n, s = {}) {
|
|
1141
1187
|
return this.api.post("/memory/edge", {
|
|
1142
1188
|
source_id: e,
|
|
1143
1189
|
target_id: t,
|
|
1144
|
-
relation_type:
|
|
1145
|
-
properties:
|
|
1190
|
+
relation_type: n,
|
|
1191
|
+
properties: s
|
|
1146
1192
|
});
|
|
1147
1193
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1194
|
+
/** @param {{ signal?: AbortSignal }} [options] */
|
|
1195
|
+
async getHealth(e = {}) {
|
|
1196
|
+
return this.api.get("/memory/graph/health", e);
|
|
1150
1197
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1198
|
+
/** @param {{ signal?: AbortSignal }} [options] */
|
|
1199
|
+
async getInferenceRules(e = {}) {
|
|
1200
|
+
return this.api.get("/memory/inference/rules", e);
|
|
1153
1201
|
}
|
|
1154
1202
|
async runInference({ dryRun: e = !1 } = {}) {
|
|
1155
1203
|
return this.api.post("/memory/inference", {
|
|
@@ -1161,24 +1209,29 @@ class K {
|
|
|
1161
1209
|
* @param {string} startId
|
|
1162
1210
|
* @param {string} endId
|
|
1163
1211
|
* @param {number} [maxHops=5]
|
|
1212
|
+
* @param {{ signal?: AbortSignal }} [options]
|
|
1164
1213
|
*/
|
|
1165
|
-
async findShortestPath(e, t, s =
|
|
1166
|
-
return this.api.get(`/memory/graph/path?start_id=${encodeURIComponent(e)}&end_id=${encodeURIComponent(t)}&max_hops=${s
|
|
1214
|
+
async findShortestPath(e, t, n = 5, s = {}) {
|
|
1215
|
+
return this.api.get(`/memory/graph/path?start_id=${encodeURIComponent(e)}&end_id=${encodeURIComponent(t)}&max_hops=${n}`, s);
|
|
1167
1216
|
}
|
|
1168
1217
|
/**
|
|
1169
1218
|
* Fetch the full knowledge graph.
|
|
1170
1219
|
* @param {number} [limit] - Optional client hint; backend enforces hard cap.
|
|
1220
|
+
* @param {{ signal?: AbortSignal }} [options]
|
|
1171
1221
|
*/
|
|
1172
|
-
async getFullGraph(e) {
|
|
1173
|
-
return e == null ? this.api.get("/memory/graph/full") : this.api.get(`/memory/graph/full?limit=${encodeURIComponent(e)}
|
|
1222
|
+
async getFullGraph(e, t = {}) {
|
|
1223
|
+
return e == null ? this.api.get("/memory/graph/full", t) : this.api.get(`/memory/graph/full?limit=${encodeURIComponent(e)}`, t);
|
|
1174
1224
|
}
|
|
1175
1225
|
/**
|
|
1176
1226
|
* Fetch edges for multiple node IDs in bulk.
|
|
1227
|
+
*
|
|
1228
|
+
* A POST, but a read — it mutates nothing, so unlike the writes below it takes a signal.
|
|
1177
1229
|
* @param {string[]} nodeIds
|
|
1230
|
+
* @param {{ includeProperties?: boolean, signal?: AbortSignal }} [options]
|
|
1178
1231
|
*/
|
|
1179
|
-
async getEdgesBulk(e, { includeProperties: t = !1 } = {}) {
|
|
1232
|
+
async getEdgesBulk(e, { includeProperties: t = !1, signal: n } = {}) {
|
|
1180
1233
|
const s = t ? "?include_properties=true" : "";
|
|
1181
|
-
return this.api.post(`/memory/graph/edges${s}`, { node_ids: e });
|
|
1234
|
+
return this.api.post(`/memory/graph/edges${s}`, { node_ids: e }, n ? { signal: n } : {});
|
|
1182
1235
|
}
|
|
1183
1236
|
/**
|
|
1184
1237
|
* Bulk upsert graph nodes and edges, optionally replacing a node-ID prefix.
|
|
@@ -1187,16 +1240,17 @@ class K {
|
|
|
1187
1240
|
* @param {Array<Object>} [params.edges=[]] - Edges with source_id, target_id, edge_type, and properties.
|
|
1188
1241
|
* @param {string|null} [params.deletePrefix=null] - Scoped node-ID prefix to delete before writing.
|
|
1189
1242
|
*/
|
|
1190
|
-
async bulkUpsert({ nodes: e = [], edges: t = [], deletePrefix:
|
|
1191
|
-
const
|
|
1192
|
-
return
|
|
1243
|
+
async bulkUpsert({ nodes: e = [], edges: t = [], deletePrefix: n = null } = {}) {
|
|
1244
|
+
const s = { nodes: e, edges: t };
|
|
1245
|
+
return n !== null && (s.delete_prefix = n), this.api.post("/memory/graph/bulk", s);
|
|
1193
1246
|
}
|
|
1194
1247
|
/**
|
|
1195
1248
|
* Get Wikipedia grounding status for an entity node.
|
|
1196
1249
|
* @param {string} nodeId
|
|
1250
|
+
* @param {{ signal?: AbortSignal }} [options]
|
|
1197
1251
|
*/
|
|
1198
|
-
async getGroundingStatus(e) {
|
|
1199
|
-
return this.api.get(`/memory/graph/nodes/${encodeURIComponent(e)}/grounding
|
|
1252
|
+
async getGroundingStatus(e, t = {}) {
|
|
1253
|
+
return this.api.get(`/memory/graph/nodes/${encodeURIComponent(e)}/grounding`, t);
|
|
1200
1254
|
}
|
|
1201
1255
|
/**
|
|
1202
1256
|
* Update an entity node's label or type. Triggers ontology self-learning.
|
|
@@ -1223,9 +1277,10 @@ class K {
|
|
|
1223
1277
|
/**
|
|
1224
1278
|
* Get links for a memory item.
|
|
1225
1279
|
* @param {string} itemId
|
|
1280
|
+
* @param {{ signal?: AbortSignal }} [options]
|
|
1226
1281
|
*/
|
|
1227
|
-
async getLinks(e) {
|
|
1228
|
-
return this.api.get(`/memory/${encodeURIComponent(e)}/links
|
|
1282
|
+
async getLinks(e, t = {}) {
|
|
1283
|
+
return this.api.get(`/memory/${encodeURIComponent(e)}/links`, t);
|
|
1229
1284
|
}
|
|
1230
1285
|
/**
|
|
1231
1286
|
* Merge unambiguous single-token entity aliases ("Hudson") into their
|
|
@@ -1265,7 +1320,7 @@ class K {
|
|
|
1265
1320
|
);
|
|
1266
1321
|
}
|
|
1267
1322
|
}
|
|
1268
|
-
class
|
|
1323
|
+
class D {
|
|
1269
1324
|
constructor(e) {
|
|
1270
1325
|
this.api = e;
|
|
1271
1326
|
}
|
|
@@ -1273,12 +1328,12 @@ class G {
|
|
|
1273
1328
|
const t = e ? "?include_system=true" : "";
|
|
1274
1329
|
return this.api.get(`/memory/teams${t}`);
|
|
1275
1330
|
}
|
|
1276
|
-
async create({ name: e, description: t = null, dataClassification:
|
|
1331
|
+
async create({ name: e, description: t = null, dataClassification: n = "internal", costCenter: s = null, isSystem: r = !1 }) {
|
|
1277
1332
|
const i = {
|
|
1278
1333
|
name: e,
|
|
1279
1334
|
description: t,
|
|
1280
|
-
data_classification:
|
|
1281
|
-
cost_center:
|
|
1335
|
+
data_classification: n,
|
|
1336
|
+
cost_center: s
|
|
1282
1337
|
};
|
|
1283
1338
|
return r && (i.is_system = !0), this.api.post("/memory/teams", i);
|
|
1284
1339
|
}
|
|
@@ -1294,20 +1349,20 @@ class G {
|
|
|
1294
1349
|
async getMembers(e) {
|
|
1295
1350
|
return this.api.get(`/memory/teams/${e}/members`);
|
|
1296
1351
|
}
|
|
1297
|
-
async addMember(e, t,
|
|
1352
|
+
async addMember(e, t, n = "member") {
|
|
1298
1353
|
return this.api.post(`/memory/teams/${e}/members`, {
|
|
1299
1354
|
user_id: t,
|
|
1300
|
-
role:
|
|
1355
|
+
role: n
|
|
1301
1356
|
});
|
|
1302
1357
|
}
|
|
1303
|
-
async updateMember(e, t,
|
|
1304
|
-
return this.api.patch(`/memory/teams/${e}/members/${t}`, { role:
|
|
1358
|
+
async updateMember(e, t, n) {
|
|
1359
|
+
return this.api.patch(`/memory/teams/${e}/members/${t}`, { role: n });
|
|
1305
1360
|
}
|
|
1306
1361
|
async removeMember(e, t) {
|
|
1307
1362
|
return this.api.delete(`/memory/teams/${e}/members/${t}`);
|
|
1308
1363
|
}
|
|
1309
1364
|
}
|
|
1310
|
-
class
|
|
1365
|
+
class N {
|
|
1311
1366
|
constructor(e) {
|
|
1312
1367
|
this.api = e;
|
|
1313
1368
|
}
|
|
@@ -1329,7 +1384,7 @@ class D {
|
|
|
1329
1384
|
return this.api.patch("/auth/llm-keys", e);
|
|
1330
1385
|
}
|
|
1331
1386
|
}
|
|
1332
|
-
class
|
|
1387
|
+
class J {
|
|
1333
1388
|
constructor(e) {
|
|
1334
1389
|
this.api = e;
|
|
1335
1390
|
}
|
|
@@ -1355,18 +1410,18 @@ class N {
|
|
|
1355
1410
|
});
|
|
1356
1411
|
}
|
|
1357
1412
|
}
|
|
1358
|
-
class
|
|
1413
|
+
class W {
|
|
1359
1414
|
constructor(e) {
|
|
1360
1415
|
this.api = e;
|
|
1361
1416
|
}
|
|
1362
1417
|
async getCurrentUser() {
|
|
1363
1418
|
return this.api.get("/auth/me");
|
|
1364
1419
|
}
|
|
1365
|
-
async createAPIKey(e, t,
|
|
1420
|
+
async createAPIKey(e, t, n = null) {
|
|
1366
1421
|
return this.api.post("/memory/api-keys", {
|
|
1367
1422
|
name: e,
|
|
1368
1423
|
scopes: t,
|
|
1369
|
-
expires_in_days:
|
|
1424
|
+
expires_in_days: n
|
|
1370
1425
|
});
|
|
1371
1426
|
}
|
|
1372
1427
|
async listAPIKeys() {
|
|
@@ -1376,19 +1431,19 @@ class J {
|
|
|
1376
1431
|
return this.api.delete(`/memory/api-keys/${e}`);
|
|
1377
1432
|
}
|
|
1378
1433
|
}
|
|
1379
|
-
class
|
|
1434
|
+
class V {
|
|
1380
1435
|
constructor(e) {
|
|
1381
1436
|
this.api = e;
|
|
1382
1437
|
}
|
|
1383
1438
|
async list() {
|
|
1384
1439
|
return this.api.get("/memory/agents");
|
|
1385
1440
|
}
|
|
1386
|
-
async create({ name: e, description: t = null, agentConfig:
|
|
1441
|
+
async create({ name: e, description: t = null, agentConfig: n = {}, roles: s = ["user"] }) {
|
|
1387
1442
|
return this.api.post("/memory/agents", {
|
|
1388
1443
|
name: e,
|
|
1389
1444
|
description: t,
|
|
1390
|
-
agent_config:
|
|
1391
|
-
roles:
|
|
1445
|
+
agent_config: n,
|
|
1446
|
+
roles: s
|
|
1392
1447
|
});
|
|
1393
1448
|
}
|
|
1394
1449
|
async get(e) {
|
|
@@ -1414,9 +1469,9 @@ class W {
|
|
|
1414
1469
|
* @param {string} domain - Domain string (e.g. "python").
|
|
1415
1470
|
* @returns {Promise<{evaluation: object|null}>}
|
|
1416
1471
|
*/
|
|
1417
|
-
async getEvaluation(e, t,
|
|
1418
|
-
const
|
|
1419
|
-
return this.api.get(`/memory/agents/${e}/evaluation${
|
|
1472
|
+
async getEvaluation(e, t, n) {
|
|
1473
|
+
const s = new URLSearchParams({ dimension: t, domain: n }).toString();
|
|
1474
|
+
return this.api.get(`/memory/agents/${e}/evaluation${s ? "?" + s : ""}`);
|
|
1420
1475
|
}
|
|
1421
1476
|
/**
|
|
1422
1477
|
* Get evaluation history for an agent on a given (dimension, domain) slot.
|
|
@@ -1430,12 +1485,12 @@ class W {
|
|
|
1430
1485
|
* @param {number} [options.limit=20] - Maximum records to return.
|
|
1431
1486
|
* @returns {Promise<{history: object[]}>}
|
|
1432
1487
|
*/
|
|
1433
|
-
async listEvaluationHistory(e, t,
|
|
1434
|
-
const r = new URLSearchParams({ dimension: t, domain:
|
|
1488
|
+
async listEvaluationHistory(e, t, n, { limit: s = 20 } = {}) {
|
|
1489
|
+
const r = new URLSearchParams({ dimension: t, domain: n, limit: String(s) }).toString();
|
|
1435
1490
|
return this.api.get(`/memory/agents/${e}/evaluation/history${r ? "?" + r : ""}`);
|
|
1436
1491
|
}
|
|
1437
1492
|
}
|
|
1438
|
-
class
|
|
1493
|
+
class Y {
|
|
1439
1494
|
constructor(e) {
|
|
1440
1495
|
this.api = e;
|
|
1441
1496
|
}
|
|
@@ -1449,7 +1504,7 @@ class V {
|
|
|
1449
1504
|
return this.api.get("/usage/tiers");
|
|
1450
1505
|
}
|
|
1451
1506
|
}
|
|
1452
|
-
class
|
|
1507
|
+
class X {
|
|
1453
1508
|
constructor(e) {
|
|
1454
1509
|
this.api = e;
|
|
1455
1510
|
}
|
|
@@ -1466,7 +1521,7 @@ class Y {
|
|
|
1466
1521
|
return this.api.get("/memory/plugins");
|
|
1467
1522
|
}
|
|
1468
1523
|
}
|
|
1469
|
-
class
|
|
1524
|
+
class Z {
|
|
1470
1525
|
constructor(e) {
|
|
1471
1526
|
this.api = e;
|
|
1472
1527
|
}
|
|
@@ -1489,7 +1544,7 @@ class X {
|
|
|
1489
1544
|
return this.api.get("/memory/token-usage/current");
|
|
1490
1545
|
}
|
|
1491
1546
|
}
|
|
1492
|
-
class
|
|
1547
|
+
class Q {
|
|
1493
1548
|
constructor(e) {
|
|
1494
1549
|
this.api = e;
|
|
1495
1550
|
}
|
|
@@ -1502,9 +1557,9 @@ class Z {
|
|
|
1502
1557
|
* @param {string} [options.endTime] - ISO end time
|
|
1503
1558
|
* @param {number} [options.limit=100]
|
|
1504
1559
|
*/
|
|
1505
|
-
async getHistory(e, { startTime: t = null, endTime:
|
|
1506
|
-
let r = `/memory/temporal/${e}/history?limit=${
|
|
1507
|
-
return t && (r += `&start_time=${t}`),
|
|
1560
|
+
async getHistory(e, { startTime: t = null, endTime: n = null, limit: s = 100 } = {}) {
|
|
1561
|
+
let r = `/memory/temporal/${e}/history?limit=${s}`;
|
|
1562
|
+
return t && (r += `&start_time=${t}`), n && (r += `&end_time=${n}`), this.api.get(r);
|
|
1508
1563
|
}
|
|
1509
1564
|
// === TIME-TRAVEL QUERIES ===
|
|
1510
1565
|
/**
|
|
@@ -1514,9 +1569,9 @@ class Z {
|
|
|
1514
1569
|
* @param {string} [options.query]
|
|
1515
1570
|
* @param {number} [options.limit=100]
|
|
1516
1571
|
*/
|
|
1517
|
-
async timeTravel(e, { query: t = null, limit:
|
|
1518
|
-
let
|
|
1519
|
-
return t && (
|
|
1572
|
+
async timeTravel(e, { query: t = null, limit: n = 100 } = {}) {
|
|
1573
|
+
let s = `/memory/temporal/at/${e}?limit=${n}`;
|
|
1574
|
+
return t && (s += `&query=${encodeURIComponent(t)}`), this.api.get(s);
|
|
1520
1575
|
}
|
|
1521
1576
|
/**
|
|
1522
1577
|
* Get specific item as it existed at timestamp.
|
|
@@ -1535,10 +1590,10 @@ class Z {
|
|
|
1535
1590
|
* @param {string} [options.until]
|
|
1536
1591
|
* @param {string} [options.changeType]
|
|
1537
1592
|
*/
|
|
1538
|
-
async getChanges(e, { since: t = null, until:
|
|
1593
|
+
async getChanges(e, { since: t = null, until: n = null, changeType: s = null } = {}) {
|
|
1539
1594
|
let r = `/memory/temporal/${e}/changes`;
|
|
1540
1595
|
const i = [];
|
|
1541
|
-
return t && i.push(`since=${t}`),
|
|
1596
|
+
return t && i.push(`since=${t}`), n && i.push(`until=${n}`), s && i.push(`change_type=${s}`), i.length && (r += `?${i.join("&")}`), this.api.get(r);
|
|
1542
1597
|
}
|
|
1543
1598
|
// === VERSION COMPARISON ===
|
|
1544
1599
|
/**
|
|
@@ -1547,8 +1602,8 @@ class Z {
|
|
|
1547
1602
|
* @param {number} v1
|
|
1548
1603
|
* @param {number} v2
|
|
1549
1604
|
*/
|
|
1550
|
-
async compareVersions(e, t,
|
|
1551
|
-
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${
|
|
1605
|
+
async compareVersions(e, t, n) {
|
|
1606
|
+
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${n}`);
|
|
1552
1607
|
}
|
|
1553
1608
|
// === ROLLBACK ===
|
|
1554
1609
|
/**
|
|
@@ -1558,10 +1613,10 @@ class Z {
|
|
|
1558
1613
|
* @param {number} [options.toVersion]
|
|
1559
1614
|
* @param {string} [options.toTime]
|
|
1560
1615
|
*/
|
|
1561
|
-
async rollback(e, { toVersion: t = null, toTime:
|
|
1562
|
-
let
|
|
1616
|
+
async rollback(e, { toVersion: t = null, toTime: n = null } = {}) {
|
|
1617
|
+
let s = `/memory/temporal/${e}/rollback`;
|
|
1563
1618
|
const r = [];
|
|
1564
|
-
return t !== null && r.push(`to_version=${t}`),
|
|
1619
|
+
return t !== null && r.push(`to_version=${t}`), n && r.push(`to_time=${n}`), r.length && (s += `?${r.join("&")}`), this.api.post(s);
|
|
1565
1620
|
}
|
|
1566
1621
|
// === AUDIT TRAIL ===
|
|
1567
1622
|
/**
|
|
@@ -1573,10 +1628,10 @@ class Z {
|
|
|
1573
1628
|
* @param {string} [options.startTime]
|
|
1574
1629
|
* @param {string} [options.endTime]
|
|
1575
1630
|
*/
|
|
1576
|
-
async getAuditTrail(e, { changeType: t = null, userId:
|
|
1631
|
+
async getAuditTrail(e, { changeType: t = null, userId: n = null, startTime: s = null, endTime: r = null } = {}) {
|
|
1577
1632
|
let i = `/memory/temporal/${e}/audit`;
|
|
1578
1633
|
const c = [];
|
|
1579
|
-
return t && c.push(`change_type=${t}`),
|
|
1634
|
+
return t && c.push(`change_type=${t}`), n && c.push(`user_id=${n}`), s && c.push(`start_time=${s}`), r && c.push(`end_time=${r}`), c.length && (i += `?${c.join("&")}`), this.api.get(i);
|
|
1580
1635
|
}
|
|
1581
1636
|
// === TEMPORAL SEARCH ===
|
|
1582
1637
|
/**
|
|
@@ -1586,12 +1641,12 @@ class Z {
|
|
|
1586
1641
|
* @param {string} endTime
|
|
1587
1642
|
* @param {number} [limit=100]
|
|
1588
1643
|
*/
|
|
1589
|
-
async searchDuringRange(e, t,
|
|
1644
|
+
async searchDuringRange(e, t, n, s = 100) {
|
|
1590
1645
|
const r = new URLSearchParams({
|
|
1591
1646
|
query: e,
|
|
1592
1647
|
start_time: t,
|
|
1593
|
-
end_time:
|
|
1594
|
-
limit: String(
|
|
1648
|
+
end_time: n,
|
|
1649
|
+
limit: String(s)
|
|
1595
1650
|
}).toString();
|
|
1596
1651
|
return this.api.get(`/memory/temporal/search/during?${r}`);
|
|
1597
1652
|
}
|
|
@@ -1604,10 +1659,10 @@ class Z {
|
|
|
1604
1659
|
* @param {string} [options.reportType='HIPAA']
|
|
1605
1660
|
* @param {string[]} [options.itemIds]
|
|
1606
1661
|
*/
|
|
1607
|
-
async complianceReport(e, t, { reportType:
|
|
1608
|
-
let r = `/memory/temporal/compliance/report?start_date=${e}&end_date=${t}&report_type=${
|
|
1609
|
-
if (
|
|
1610
|
-
for (const i of
|
|
1662
|
+
async complianceReport(e, t, { reportType: n = "HIPAA", itemIds: s = null } = {}) {
|
|
1663
|
+
let r = `/memory/temporal/compliance/report?start_date=${e}&end_date=${t}&report_type=${n}`;
|
|
1664
|
+
if (s && s.length)
|
|
1665
|
+
for (const i of s)
|
|
1611
1666
|
r += `&item_ids=${encodeURIComponent(i)}`;
|
|
1612
1667
|
return this.api.get(r);
|
|
1613
1668
|
}
|
|
@@ -1635,7 +1690,7 @@ class Z {
|
|
|
1635
1690
|
return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
|
|
1636
1691
|
}
|
|
1637
1692
|
}
|
|
1638
|
-
class
|
|
1693
|
+
class ee {
|
|
1639
1694
|
constructor(e) {
|
|
1640
1695
|
this.api = e;
|
|
1641
1696
|
}
|
|
@@ -1646,11 +1701,11 @@ class Q {
|
|
|
1646
1701
|
* @param {number} [options.topK=100]
|
|
1647
1702
|
* @param {Object[]} [options.memoryItems] - Direct items to analyze
|
|
1648
1703
|
*/
|
|
1649
|
-
async runAnalysis({ query: e = "*", topK: t = 100, memoryItems:
|
|
1704
|
+
async runAnalysis({ query: e = "*", topK: t = 100, memoryItems: n = [] } = {}) {
|
|
1650
1705
|
return this.api.post("/memory/governance/run-analysis", {
|
|
1651
1706
|
query: e,
|
|
1652
1707
|
top_k: t,
|
|
1653
|
-
memory_items:
|
|
1708
|
+
memory_items: n
|
|
1654
1709
|
});
|
|
1655
1710
|
}
|
|
1656
1711
|
/**
|
|
@@ -1660,10 +1715,10 @@ class Q {
|
|
|
1660
1715
|
* @param {boolean} [options.autoFixableOnly=false]
|
|
1661
1716
|
*/
|
|
1662
1717
|
async listViolations({ severity: e = null, autoFixableOnly: t = !1 } = {}) {
|
|
1663
|
-
const
|
|
1664
|
-
e &&
|
|
1665
|
-
const
|
|
1666
|
-
return this.api.get(`/memory/governance/violations${
|
|
1718
|
+
const n = [];
|
|
1719
|
+
e && n.push(`severity=${e}`), t && n.push("auto_fixable_only=true");
|
|
1720
|
+
const s = n.length ? `?${n.join("&")}` : "";
|
|
1721
|
+
return this.api.get(`/memory/governance/violations${s}`);
|
|
1667
1722
|
}
|
|
1668
1723
|
/**
|
|
1669
1724
|
* Get a specific violation by ID.
|
|
@@ -1680,12 +1735,12 @@ class Q {
|
|
|
1680
1735
|
* @param {string} [params.rationale='']
|
|
1681
1736
|
* @param {string} [params.decidedBy='human']
|
|
1682
1737
|
*/
|
|
1683
|
-
async applyDecision({ violationId: e, action: t = "approve", rationale:
|
|
1738
|
+
async applyDecision({ violationId: e, action: t = "approve", rationale: n = "", decidedBy: s = "human" }) {
|
|
1684
1739
|
return this.api.post("/memory/governance/apply-decision", {
|
|
1685
1740
|
violation_id: e,
|
|
1686
1741
|
action: t,
|
|
1687
|
-
rationale:
|
|
1688
|
-
decided_by:
|
|
1742
|
+
rationale: n,
|
|
1743
|
+
decided_by: s
|
|
1689
1744
|
});
|
|
1690
1745
|
}
|
|
1691
1746
|
/**
|
|
@@ -1704,7 +1759,7 @@ class Q {
|
|
|
1704
1759
|
return this.api.get("/memory/governance/summary");
|
|
1705
1760
|
}
|
|
1706
1761
|
}
|
|
1707
|
-
class
|
|
1762
|
+
class te {
|
|
1708
1763
|
constructor(e) {
|
|
1709
1764
|
this.api = e;
|
|
1710
1765
|
}
|
|
@@ -1745,7 +1800,7 @@ class ee {
|
|
|
1745
1800
|
return this.api.post("/memory/evolution/reinforce/opinions");
|
|
1746
1801
|
}
|
|
1747
1802
|
}
|
|
1748
|
-
class
|
|
1803
|
+
class ne {
|
|
1749
1804
|
constructor(e) {
|
|
1750
1805
|
this.api = e;
|
|
1751
1806
|
}
|
|
@@ -1757,11 +1812,11 @@ class te {
|
|
|
1757
1812
|
* @param {string} [params.memoryType='semantic']
|
|
1758
1813
|
* @param {boolean} [params.useLlm=true]
|
|
1759
1814
|
*/
|
|
1760
|
-
async challenge({ assertion: e, memoryType: t = "semantic", useLlm:
|
|
1815
|
+
async challenge({ assertion: e, memoryType: t = "semantic", useLlm: n = !0 }) {
|
|
1761
1816
|
return this.api.post("/memory/reasoning/challenge", {
|
|
1762
1817
|
assertion: e,
|
|
1763
1818
|
memory_type: t,
|
|
1764
|
-
use_llm:
|
|
1819
|
+
use_llm: n
|
|
1765
1820
|
});
|
|
1766
1821
|
}
|
|
1767
1822
|
/**
|
|
@@ -1774,12 +1829,12 @@ class te {
|
|
|
1774
1829
|
* @param {boolean} [params.useWikipedia=true]
|
|
1775
1830
|
* @param {boolean} [params.useLlm=true]
|
|
1776
1831
|
*/
|
|
1777
|
-
async resolve({ existingItemId: e, newFact: t, autoResolve:
|
|
1832
|
+
async resolve({ existingItemId: e, newFact: t, autoResolve: n = !0, strategy: s = null, useWikipedia: r = !0, useLlm: i = !0 }) {
|
|
1778
1833
|
return this.api.post("/memory/reasoning/resolve", {
|
|
1779
1834
|
existing_item_id: e,
|
|
1780
1835
|
new_fact: t,
|
|
1781
|
-
auto_resolve:
|
|
1782
|
-
strategy:
|
|
1836
|
+
auto_resolve: n,
|
|
1837
|
+
strategy: s,
|
|
1783
1838
|
use_wikipedia: r,
|
|
1784
1839
|
use_llm: i
|
|
1785
1840
|
});
|
|
@@ -1855,12 +1910,12 @@ class se {
|
|
|
1855
1910
|
* @param {number} [params.minQualityScore=0.4]
|
|
1856
1911
|
* @param {boolean} [params.useLlmDetection=true]
|
|
1857
1912
|
*/
|
|
1858
|
-
async extract({ content: e, minSteps: t = 2, minQualityScore:
|
|
1913
|
+
async extract({ content: e, minSteps: t = 2, minQualityScore: n = 0.4, useLlmDetection: s = !0 }) {
|
|
1859
1914
|
return this.api.post("/memory/reasoning/traces/extract", {
|
|
1860
1915
|
content: e,
|
|
1861
1916
|
min_steps: t,
|
|
1862
|
-
min_quality_score:
|
|
1863
|
-
use_llm_detection:
|
|
1917
|
+
min_quality_score: n,
|
|
1918
|
+
use_llm_detection: s
|
|
1864
1919
|
});
|
|
1865
1920
|
}
|
|
1866
1921
|
/**
|
|
@@ -1882,11 +1937,11 @@ class se {
|
|
|
1882
1937
|
* @param {string} [params.artifactId]
|
|
1883
1938
|
* @param {number} [params.limit=10]
|
|
1884
1939
|
*/
|
|
1885
|
-
async query({ query: e, artifactId: t = null, limit:
|
|
1940
|
+
async query({ query: e, artifactId: t = null, limit: n = 10 }) {
|
|
1886
1941
|
return this.api.post("/memory/reasoning/traces/query", {
|
|
1887
1942
|
query: e,
|
|
1888
1943
|
artifact_id: t,
|
|
1889
|
-
limit:
|
|
1944
|
+
limit: n
|
|
1890
1945
|
});
|
|
1891
1946
|
}
|
|
1892
1947
|
/**
|
|
@@ -1897,7 +1952,7 @@ class se {
|
|
|
1897
1952
|
return this.api.get(`/memory/reasoning/traces/${e}`);
|
|
1898
1953
|
}
|
|
1899
1954
|
}
|
|
1900
|
-
class
|
|
1955
|
+
class re {
|
|
1901
1956
|
constructor(e) {
|
|
1902
1957
|
this.api = e;
|
|
1903
1958
|
}
|
|
@@ -1909,11 +1964,11 @@ class ne {
|
|
|
1909
1964
|
* @param {Array<{docId: string, text: string}>} params.rawChunks
|
|
1910
1965
|
* @param {Object} [params.params={}]
|
|
1911
1966
|
*/
|
|
1912
|
-
async runInference({ registryId: e = "default", rawChunks: t, params:
|
|
1967
|
+
async runInference({ registryId: e = "default", rawChunks: t, params: n = {} }) {
|
|
1913
1968
|
return this.api.post("/memory/ontology/inference/run", {
|
|
1914
1969
|
registry_id: e,
|
|
1915
|
-
raw_chunks: t.map((
|
|
1916
|
-
params:
|
|
1970
|
+
raw_chunks: t.map((s) => ({ doc_id: s.docId, text: s.text })),
|
|
1971
|
+
params: n
|
|
1917
1972
|
});
|
|
1918
1973
|
}
|
|
1919
1974
|
// === REGISTRY MANAGEMENT ===
|
|
@@ -1930,11 +1985,11 @@ class ne {
|
|
|
1930
1985
|
* @param {string} [params.description='']
|
|
1931
1986
|
* @param {string} [params.domain='general']
|
|
1932
1987
|
*/
|
|
1933
|
-
async createRegistry({ name: e, description: t = "", domain:
|
|
1988
|
+
async createRegistry({ name: e, description: t = "", domain: n = "general" }) {
|
|
1934
1989
|
return this.api.post("/memory/ontology/registries", {
|
|
1935
1990
|
name: e,
|
|
1936
1991
|
description: t,
|
|
1937
|
-
domain:
|
|
1992
|
+
domain: n
|
|
1938
1993
|
});
|
|
1939
1994
|
}
|
|
1940
1995
|
/**
|
|
@@ -1943,8 +1998,8 @@ class ne {
|
|
|
1943
1998
|
* @param {string} [version]
|
|
1944
1999
|
*/
|
|
1945
2000
|
async getSnapshot(e, t = null) {
|
|
1946
|
-
let
|
|
1947
|
-
return t && (
|
|
2001
|
+
let n = `/memory/ontology/registry/${e}/snapshot`;
|
|
2002
|
+
return t && (n += `?version=${encodeURIComponent(t)}`), this.api.get(n);
|
|
1948
2003
|
}
|
|
1949
2004
|
/**
|
|
1950
2005
|
* Apply a changeset to create a new version of the registry.
|
|
@@ -1954,11 +2009,11 @@ class ne {
|
|
|
1954
2009
|
* @param {Object} params.changeset - OntologyIR changeset
|
|
1955
2010
|
* @param {string} [params.message='']
|
|
1956
2011
|
*/
|
|
1957
|
-
async applyChangeset(e, { baseVersion: t = "", changeset:
|
|
2012
|
+
async applyChangeset(e, { baseVersion: t = "", changeset: n, message: s = "" }) {
|
|
1958
2013
|
return this.api.post(`/memory/ontology/registry/${e}/apply`, {
|
|
1959
2014
|
base_version: t,
|
|
1960
|
-
changeset:
|
|
1961
|
-
message:
|
|
2015
|
+
changeset: n,
|
|
2016
|
+
message: s
|
|
1962
2017
|
});
|
|
1963
2018
|
}
|
|
1964
2019
|
/**
|
|
@@ -1984,10 +2039,10 @@ class ne {
|
|
|
1984
2039
|
* @param {string} [params.targetVersion='']
|
|
1985
2040
|
* @param {string} [params.message='']
|
|
1986
2041
|
*/
|
|
1987
|
-
async rollbackRegistry(e, { targetVersion: t = "", message:
|
|
2042
|
+
async rollbackRegistry(e, { targetVersion: t = "", message: n = "" }) {
|
|
1988
2043
|
return this.api.post(`/memory/ontology/registry/${e}/rollback`, {
|
|
1989
2044
|
target_version: t,
|
|
1990
|
-
message:
|
|
2045
|
+
message: n
|
|
1991
2046
|
});
|
|
1992
2047
|
}
|
|
1993
2048
|
/**
|
|
@@ -1996,8 +2051,8 @@ class ne {
|
|
|
1996
2051
|
* @param {string} [version]
|
|
1997
2052
|
*/
|
|
1998
2053
|
async exportRegistry(e, t = null) {
|
|
1999
|
-
let
|
|
2000
|
-
return t && (
|
|
2054
|
+
let n = `/memory/ontology/registry/${e}/export`;
|
|
2055
|
+
return t && (n += `?version=${encodeURIComponent(t)}`), this.api.get(n);
|
|
2001
2056
|
}
|
|
2002
2057
|
/**
|
|
2003
2058
|
* Import data into a registry.
|
|
@@ -2006,10 +2061,10 @@ class ne {
|
|
|
2006
2061
|
* @param {Object} params.data - Complete ontology data to import
|
|
2007
2062
|
* @param {string} [params.message='']
|
|
2008
2063
|
*/
|
|
2009
|
-
async importRegistry(e, { data: t, message:
|
|
2064
|
+
async importRegistry(e, { data: t, message: n = "" }) {
|
|
2010
2065
|
return this.api.post(`/memory/ontology/registry/${e}/import`, {
|
|
2011
2066
|
data: t,
|
|
2012
|
-
message:
|
|
2067
|
+
message: n
|
|
2013
2068
|
});
|
|
2014
2069
|
}
|
|
2015
2070
|
// === ENRICHMENT & GROUNDING ===
|
|
@@ -2038,11 +2093,11 @@ class ne {
|
|
|
2038
2093
|
* @param {string} params.itemId
|
|
2039
2094
|
* @param {string[]} params.candidates
|
|
2040
2095
|
*/
|
|
2041
|
-
async runGrounding({ grounder: e = "wikipedia", itemId: t, candidates:
|
|
2096
|
+
async runGrounding({ grounder: e = "wikipedia", itemId: t, candidates: n }) {
|
|
2042
2097
|
return this.api.post("/memory/ontology/grounding/run", {
|
|
2043
2098
|
grounder: e,
|
|
2044
2099
|
item_id: t,
|
|
2045
|
-
candidates:
|
|
2100
|
+
candidates: n
|
|
2046
2101
|
});
|
|
2047
2102
|
}
|
|
2048
2103
|
// === TEMPLATES ===
|
|
@@ -2078,11 +2133,11 @@ class ne {
|
|
|
2078
2133
|
* @param {string} params.name
|
|
2079
2134
|
* @param {string} [params.description='']
|
|
2080
2135
|
*/
|
|
2081
|
-
async saveAsTemplate({ registryId: e, name: t, description:
|
|
2136
|
+
async saveAsTemplate({ registryId: e, name: t, description: n = "" }) {
|
|
2082
2137
|
return this.api.post("/memory/ontology/templates", {
|
|
2083
2138
|
registry_id: e,
|
|
2084
2139
|
name: t,
|
|
2085
|
-
description:
|
|
2140
|
+
description: n
|
|
2086
2141
|
});
|
|
2087
2142
|
}
|
|
2088
2143
|
/**
|
|
@@ -2107,12 +2162,12 @@ class ne {
|
|
|
2107
2162
|
* @param {number} [params.confidence=0.9]
|
|
2108
2163
|
* @param {boolean} [params.isGlobal=false]
|
|
2109
2164
|
*/
|
|
2110
|
-
async createPattern({ name: e, entityType: t, confidence:
|
|
2165
|
+
async createPattern({ name: e, entityType: t, confidence: n = 0.9, isGlobal: s = !1 }) {
|
|
2111
2166
|
return this.api.post("/memory/ontology/patterns", {
|
|
2112
2167
|
name: e,
|
|
2113
2168
|
entity_type: t,
|
|
2114
|
-
confidence:
|
|
2115
|
-
is_global:
|
|
2169
|
+
confidence: n,
|
|
2170
|
+
is_global: s
|
|
2116
2171
|
});
|
|
2117
2172
|
}
|
|
2118
2173
|
/**
|
|
@@ -2151,10 +2206,10 @@ class ne {
|
|
|
2151
2206
|
* @param {string} params.baseRegistryId
|
|
2152
2207
|
* @param {string} [params.pinnedVersion]
|
|
2153
2208
|
*/
|
|
2154
|
-
async subscribe(e, { baseRegistryId: t, pinnedVersion:
|
|
2209
|
+
async subscribe(e, { baseRegistryId: t, pinnedVersion: n = null }) {
|
|
2155
2210
|
return this.api.post(`/memory/ontology/registry/${e}/subscribe`, {
|
|
2156
2211
|
base_registry_id: t,
|
|
2157
|
-
pinned_version:
|
|
2212
|
+
pinned_version: n
|
|
2158
2213
|
});
|
|
2159
2214
|
}
|
|
2160
2215
|
/**
|
|
@@ -2272,9 +2327,9 @@ class ne {
|
|
|
2272
2327
|
* @param {string} [options.kind] missing_in_graph | missing_in_registry | name_conflict_unresolvable
|
|
2273
2328
|
* @param {number} [options.limit=50]
|
|
2274
2329
|
*/
|
|
2275
|
-
async listHitl({ status: e = "open", kind: t = null, limit:
|
|
2276
|
-
const
|
|
2277
|
-
return t &&
|
|
2330
|
+
async listHitl({ status: e = "open", kind: t = null, limit: n = 50 } = {}) {
|
|
2331
|
+
const s = new URLSearchParams({ status: e, limit: String(n) });
|
|
2332
|
+
return t && s.set("kind", t), this.api.get(`/memory/ontology/hitl?${s.toString()}`);
|
|
2278
2333
|
}
|
|
2279
2334
|
/**
|
|
2280
2335
|
* Resolve one ontology HITL queue item (open -> resolved).
|
|
@@ -2283,8 +2338,8 @@ class ne {
|
|
|
2283
2338
|
* @param {('accepted'|'dismissed'|'deferred')} body.action
|
|
2284
2339
|
* @param {string} [body.note]
|
|
2285
2340
|
*/
|
|
2286
|
-
async resolveHitl(e, { action: t, note:
|
|
2287
|
-
return this.api.post(`/memory/ontology/hitl/${e}/resolve`, { action: t, note:
|
|
2341
|
+
async resolveHitl(e, { action: t, note: n = null }) {
|
|
2342
|
+
return this.api.post(`/memory/ontology/hitl/${e}/resolve`, { action: t, note: n });
|
|
2288
2343
|
}
|
|
2289
2344
|
// --- ONTO-CRUD-1 read / audit / migration surface -------------------------
|
|
2290
2345
|
/**
|
|
@@ -2298,9 +2353,9 @@ class ne {
|
|
|
2298
2353
|
* @param {number} [options.limit=100]
|
|
2299
2354
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2300
2355
|
*/
|
|
2301
|
-
async listTypes({ tier: e, layer: t, packId:
|
|
2356
|
+
async listTypes({ tier: e, layer: t, packId: n, hasIri: s, kind: r, limit: i = 100, cursor: c } = {}) {
|
|
2302
2357
|
const o = { limit: String(i) };
|
|
2303
|
-
e !== void 0 && (o.tier = e), t !== void 0 && (o.layer = t),
|
|
2358
|
+
e !== void 0 && (o.tier = e), t !== void 0 && (o.layer = t), n !== void 0 && (o.pack_id = n), s !== void 0 && (o.has_iri = String(s)), r !== void 0 && (o.kind = r), c !== void 0 && (o.cursor = c);
|
|
2304
2359
|
const h = new URLSearchParams(o).toString();
|
|
2305
2360
|
return this.api.get(`/memory/ontology/types${h ? "?" + h : ""}`);
|
|
2306
2361
|
}
|
|
@@ -2335,8 +2390,8 @@ class ne {
|
|
|
2335
2390
|
*/
|
|
2336
2391
|
async declareType(e, {
|
|
2337
2392
|
kind: t = "entity",
|
|
2338
|
-
propertiesSchema:
|
|
2339
|
-
requiredProperties:
|
|
2393
|
+
propertiesSchema: n,
|
|
2394
|
+
requiredProperties: s,
|
|
2340
2395
|
storageStrategy: r,
|
|
2341
2396
|
storageSearchable: i,
|
|
2342
2397
|
iri: c,
|
|
@@ -2350,7 +2405,7 @@ class ne {
|
|
|
2350
2405
|
tier: g = "confirmed"
|
|
2351
2406
|
} = {}) {
|
|
2352
2407
|
const u = { name: e, kind: t, tier: g };
|
|
2353
|
-
return
|
|
2408
|
+
return n !== void 0 && (u.properties_schema = n), s !== void 0 && (u.required_properties = s), r !== void 0 && (u.storage_strategy = r), i !== void 0 && (u.storage_searchable = i), c !== void 0 && (u.iri = c), o !== void 0 && (u.wikidata_qid = o), h !== void 0 && (u.display_name = h), y !== void 0 && (u.definition = y), p !== void 0 && (u.description = p), d !== void 0 && (u.aliases = d), _ !== void 0 && (u.examples = _), $ !== void 0 && (u.parent_types = $), this.api.post("/memory/ontology/types", u);
|
|
2354
2409
|
}
|
|
2355
2410
|
/**
|
|
2356
2411
|
* Declare an ontology relation (CORE-MEMTYPE-DECLARE-1; declare-only in P1).
|
|
@@ -2381,8 +2436,8 @@ class ne {
|
|
|
2381
2436
|
*/
|
|
2382
2437
|
async declareRelation(e, {
|
|
2383
2438
|
domain: t,
|
|
2384
|
-
range:
|
|
2385
|
-
inverseOf:
|
|
2439
|
+
range: n,
|
|
2440
|
+
inverseOf: s,
|
|
2386
2441
|
cardinality: r,
|
|
2387
2442
|
temporal: i,
|
|
2388
2443
|
propertiesSchema: c,
|
|
@@ -2400,7 +2455,7 @@ class ne {
|
|
|
2400
2455
|
tier: l = "confirmed"
|
|
2401
2456
|
} = {}) {
|
|
2402
2457
|
const m = { name: e, tier: l };
|
|
2403
|
-
return t !== void 0 && (m.domain = t),
|
|
2458
|
+
return t !== void 0 && (m.domain = t), n !== void 0 && (m.range = n), s !== void 0 && (m.inverse_of = s), r !== void 0 && (m.cardinality = r), i !== void 0 && (m.temporal = i), c !== void 0 && (m.properties_schema = c), o !== void 0 && (m.transitive = o), h !== void 0 && (m.symmetric = h), y !== void 0 && (m.reflexive = y), p !== void 0 && (m.parent_relations = p), d !== void 0 && (m.iri = d), _ !== void 0 && (m.wikidata_pid = _), $ !== void 0 && (m.display_name = $), g !== void 0 && (m.definition = g), u !== void 0 && (m.description = u), b !== void 0 && (m.aliases = b), I !== void 0 && (m.examples = I), this.api.post("/memory/ontology/relations", m);
|
|
2404
2459
|
}
|
|
2405
2460
|
/**
|
|
2406
2461
|
* List ontology relation types, keyset-paginated. Mirror of `listTypes`.
|
|
@@ -2412,9 +2467,9 @@ class ne {
|
|
|
2412
2467
|
* @param {number} [options.limit=100]
|
|
2413
2468
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2414
2469
|
*/
|
|
2415
|
-
async listRelations({ tier: e, layer: t, packId:
|
|
2470
|
+
async listRelations({ tier: e, layer: t, packId: n, hasIri: s, limit: r = 100, cursor: i } = {}) {
|
|
2416
2471
|
const c = { limit: String(r) };
|
|
2417
|
-
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), n !== void 0 && (c.pack_id = n), s !== void 0 && (c.has_iri = String(s)), i !== void 0 && (c.cursor = i);
|
|
2418
2473
|
const o = new URLSearchParams(c).toString();
|
|
2419
2474
|
return this.api.get(`/memory/ontology/relations${o ? "?" + o : ""}`);
|
|
2420
2475
|
}
|
|
@@ -2441,9 +2496,9 @@ class ne {
|
|
|
2441
2496
|
* @param {string} [options.until] full ISO-8601 upper bound (inclusive)
|
|
2442
2497
|
* @param {number} [options.limit=200]
|
|
2443
2498
|
*/
|
|
2444
|
-
async listAudit({ actor: e, action: t, since:
|
|
2499
|
+
async listAudit({ actor: e, action: t, since: n, until: s, limit: r = 200 } = {}) {
|
|
2445
2500
|
const i = { limit: String(r) };
|
|
2446
|
-
e !== void 0 && (i.actor = e), t !== void 0 && (i.action = t),
|
|
2501
|
+
e !== void 0 && (i.actor = e), t !== void 0 && (i.action = t), n !== void 0 && (i.since = n), s !== void 0 && (i.until = s);
|
|
2447
2502
|
const c = new URLSearchParams(i).toString();
|
|
2448
2503
|
return this.api.get(`/memory/ontology/audit${c ? "?" + c : ""}`);
|
|
2449
2504
|
}
|
|
@@ -2468,10 +2523,10 @@ class ne {
|
|
|
2468
2523
|
* @param {string} [options.packVersion] scope to one installed version; omit for all
|
|
2469
2524
|
*/
|
|
2470
2525
|
async getPackAudit(e, { packVersion: t = null } = {}) {
|
|
2471
|
-
const
|
|
2472
|
-
t !== null && (
|
|
2473
|
-
const
|
|
2474
|
-
return this.api.get(`/memory/ontology/packs/${encodeURIComponent(e)}/audit${
|
|
2526
|
+
const n = {};
|
|
2527
|
+
t !== null && (n.pack_version = t);
|
|
2528
|
+
const s = new URLSearchParams(n).toString();
|
|
2529
|
+
return this.api.get(`/memory/ontology/packs/${encodeURIComponent(e)}/audit${s ? "?" + s : ""}`);
|
|
2475
2530
|
}
|
|
2476
2531
|
/**
|
|
2477
2532
|
* Reclassify every instance of `fromId` onto `toId`. Both types stay live.
|
|
@@ -2488,8 +2543,8 @@ class ne {
|
|
|
2488
2543
|
* defaults, so an entity migration returns them empty/zero rather than omitting
|
|
2489
2544
|
* them — callers never branch on kind to read a response.
|
|
2490
2545
|
*/
|
|
2491
|
-
async migrateTypeInstances(e, t, { reason:
|
|
2492
|
-
const i = { reason:
|
|
2546
|
+
async migrateTypeInstances(e, t, { reason: n, batchSize: s = 500, onViolation: r = "refuse" }) {
|
|
2547
|
+
const i = { reason: n, batch_size: s };
|
|
2493
2548
|
return r !== "refuse" && (i.on_violation = r), this.api.post(
|
|
2494
2549
|
`/memory/ontology/types/${encodeURIComponent(e)}/migrate-to/${encodeURIComponent(t)}`,
|
|
2495
2550
|
i
|
|
@@ -2518,9 +2573,9 @@ class ne {
|
|
|
2518
2573
|
* @param {number} [options.limit=100]
|
|
2519
2574
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2520
2575
|
*/
|
|
2521
|
-
async listReviewQueue({ tier: e, assignee: t, source:
|
|
2522
|
-
const i = { limit: String(
|
|
2523
|
-
e !== void 0 && (i.tier = e), t !== void 0 && (i.assignee = t),
|
|
2576
|
+
async listReviewQueue({ tier: e, assignee: t, source: n, limit: s = 100, cursor: r } = {}) {
|
|
2577
|
+
const i = { limit: String(s) };
|
|
2578
|
+
e !== void 0 && (i.tier = e), t !== void 0 && (i.assignee = t), n !== void 0 && (i.source = n), r !== void 0 && (i.cursor = r);
|
|
2524
2579
|
const c = new URLSearchParams(i).toString();
|
|
2525
2580
|
return this.api.get(`/memory/ontology/queue${c ? "?" + c : ""}`);
|
|
2526
2581
|
}
|
|
@@ -2531,8 +2586,8 @@ class ne {
|
|
|
2531
2586
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2532
2587
|
*/
|
|
2533
2588
|
async approveReviewType(e, { expectedTier: t } = {}) {
|
|
2534
|
-
const
|
|
2535
|
-
return t !== void 0 && (
|
|
2589
|
+
const n = {};
|
|
2590
|
+
return t !== void 0 && (n.expected_tier = t), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/approve`, n);
|
|
2536
2591
|
}
|
|
2537
2592
|
/**
|
|
2538
2593
|
* Reject one ontology review type.
|
|
@@ -2541,8 +2596,8 @@ class ne {
|
|
|
2541
2596
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2542
2597
|
*/
|
|
2543
2598
|
async rejectReviewType(e, { expectedTier: t } = {}) {
|
|
2544
|
-
const
|
|
2545
|
-
return t !== void 0 && (
|
|
2599
|
+
const n = {};
|
|
2600
|
+
return t !== void 0 && (n.expected_tier = t), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/reject`, n);
|
|
2546
2601
|
}
|
|
2547
2602
|
/**
|
|
2548
2603
|
* Merge one ontology review type into another type.
|
|
@@ -2551,9 +2606,9 @@ class ne {
|
|
|
2551
2606
|
* @param {Object} [options]
|
|
2552
2607
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2553
2608
|
*/
|
|
2554
|
-
async mergeReviewType(e, t, { expectedTier:
|
|
2555
|
-
const
|
|
2556
|
-
return
|
|
2609
|
+
async mergeReviewType(e, t, { expectedTier: n } = {}) {
|
|
2610
|
+
const s = { into_id: t };
|
|
2611
|
+
return n !== void 0 && (s.expected_tier = n), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/merge`, s);
|
|
2557
2612
|
}
|
|
2558
2613
|
/**
|
|
2559
2614
|
* Edit and promote one ontology review type.
|
|
@@ -2562,9 +2617,9 @@ class ne {
|
|
|
2562
2617
|
* @param {Object} [options]
|
|
2563
2618
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2564
2619
|
*/
|
|
2565
|
-
async editPromoteReviewType(e, t, { expectedTier:
|
|
2566
|
-
const
|
|
2567
|
-
return
|
|
2620
|
+
async editPromoteReviewType(e, t, { expectedTier: n } = {}) {
|
|
2621
|
+
const s = { edits: t };
|
|
2622
|
+
return n !== void 0 && (s.expected_tier = n), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/edit-promote`, s);
|
|
2568
2623
|
}
|
|
2569
2624
|
/**
|
|
2570
2625
|
* Assign or clear the reviewer for one ontology review type.
|
|
@@ -2582,12 +2637,12 @@ class ne {
|
|
|
2582
2637
|
* @param {Object} [options.params] action-specific params
|
|
2583
2638
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2584
2639
|
*/
|
|
2585
|
-
async bulkReviewAction(e, t, { params:
|
|
2586
|
-
const r = { action: e, ids: t, params:
|
|
2587
|
-
return
|
|
2640
|
+
async bulkReviewAction(e, t, { params: n, expectedTier: s } = {}) {
|
|
2641
|
+
const r = { action: e, ids: t, params: n === void 0 ? {} : n };
|
|
2642
|
+
return s !== void 0 && (r.expected_tier = s), this.api.post("/memory/ontology/queue/bulk", r);
|
|
2588
2643
|
}
|
|
2589
2644
|
}
|
|
2590
|
-
class
|
|
2645
|
+
class ie {
|
|
2591
2646
|
constructor(e) {
|
|
2592
2647
|
this.api = e;
|
|
2593
2648
|
}
|
|
@@ -2611,12 +2666,12 @@ class re {
|
|
|
2611
2666
|
* @param {boolean} [options.sentimentAnalysis]
|
|
2612
2667
|
* @param {boolean} [options.topicAnalysis]
|
|
2613
2668
|
*/
|
|
2614
|
-
async detectBias({ protectedAttributes: e = null, sentimentAnalysis: t = null, topicAnalysis:
|
|
2615
|
-
const
|
|
2616
|
-
return e !== null && (
|
|
2669
|
+
async detectBias({ protectedAttributes: e = null, sentimentAnalysis: t = null, topicAnalysis: n = null } = {}) {
|
|
2670
|
+
const s = {};
|
|
2671
|
+
return e !== null && (s.protected_attributes = e), t !== null && (s.sentiment_analysis = t), n !== null && (s.topic_analysis = n), this.api.post("/memory/analytics/bias", s);
|
|
2617
2672
|
}
|
|
2618
2673
|
}
|
|
2619
|
-
class
|
|
2674
|
+
class ae {
|
|
2620
2675
|
constructor(e) {
|
|
2621
2676
|
this.api = e;
|
|
2622
2677
|
}
|
|
@@ -2652,7 +2707,7 @@ class ie {
|
|
|
2652
2707
|
return this.api.get("/memory/inference/rules");
|
|
2653
2708
|
}
|
|
2654
2709
|
}
|
|
2655
|
-
class
|
|
2710
|
+
class oe {
|
|
2656
2711
|
constructor(e) {
|
|
2657
2712
|
this.api = e;
|
|
2658
2713
|
}
|
|
@@ -2699,8 +2754,8 @@ class ae {
|
|
|
2699
2754
|
* @param {string} [runId]
|
|
2700
2755
|
*/
|
|
2701
2756
|
async getState(e, t = null) {
|
|
2702
|
-
let
|
|
2703
|
-
return t && (
|
|
2757
|
+
let n = `/memory/pipeline/${e}/state`;
|
|
2758
|
+
return t && (n += `?run_id=${encodeURIComponent(t)}`), this.api.get(n);
|
|
2704
2759
|
}
|
|
2705
2760
|
/**
|
|
2706
2761
|
* Reset a pipeline, clearing its state.
|
|
@@ -2731,11 +2786,11 @@ class ae {
|
|
|
2731
2786
|
* @param {string} [params.description='']
|
|
2732
2787
|
* @param {Object} params.config
|
|
2733
2788
|
*/
|
|
2734
|
-
async createConfig({ name: e, description: t = "", config:
|
|
2789
|
+
async createConfig({ name: e, description: t = "", config: n }) {
|
|
2735
2790
|
return this.api.post("/memory/pipeline/configs", {
|
|
2736
2791
|
name: e,
|
|
2737
2792
|
description: t,
|
|
2738
|
-
config:
|
|
2793
|
+
config: n
|
|
2739
2794
|
});
|
|
2740
2795
|
}
|
|
2741
2796
|
/**
|
|
@@ -2753,11 +2808,11 @@ class ae {
|
|
|
2753
2808
|
* @param {string} [params.description='']
|
|
2754
2809
|
* @param {Object} [params.config={}]
|
|
2755
2810
|
*/
|
|
2756
|
-
async updateConfig(e, { name: t = "", description:
|
|
2811
|
+
async updateConfig(e, { name: t = "", description: n = "", config: s = {} }) {
|
|
2757
2812
|
return this.api.patch(`/memory/pipeline/configs/${e}`, {
|
|
2758
2813
|
name: t,
|
|
2759
|
-
description:
|
|
2760
|
-
config:
|
|
2814
|
+
description: n,
|
|
2815
|
+
config: s
|
|
2761
2816
|
});
|
|
2762
2817
|
}
|
|
2763
2818
|
/**
|
|
@@ -2768,7 +2823,7 @@ class ae {
|
|
|
2768
2823
|
return this.api.delete(`/memory/pipeline/configs/${e}`);
|
|
2769
2824
|
}
|
|
2770
2825
|
}
|
|
2771
|
-
class
|
|
2826
|
+
class ce {
|
|
2772
2827
|
constructor(e) {
|
|
2773
2828
|
this.api = e;
|
|
2774
2829
|
}
|
|
@@ -2779,11 +2834,11 @@ class oe {
|
|
|
2779
2834
|
* @param {Object} params.payload
|
|
2780
2835
|
* @param {Object} [params.metadata={}]
|
|
2781
2836
|
*/
|
|
2782
|
-
async store({ conversationId: e, payload: t, metadata:
|
|
2837
|
+
async store({ conversationId: e, payload: t, metadata: n = {} }) {
|
|
2783
2838
|
return this.api.post("/memory/archive/store", {
|
|
2784
2839
|
conversation_id: e,
|
|
2785
2840
|
payload: t,
|
|
2786
|
-
metadata:
|
|
2841
|
+
metadata: n
|
|
2787
2842
|
});
|
|
2788
2843
|
}
|
|
2789
2844
|
/**
|
|
@@ -2794,7 +2849,7 @@ class oe {
|
|
|
2794
2849
|
return this.api.get(`/memory/archive/${e}`);
|
|
2795
2850
|
}
|
|
2796
2851
|
}
|
|
2797
|
-
class
|
|
2852
|
+
class ue {
|
|
2798
2853
|
constructor(e) {
|
|
2799
2854
|
this.api = e;
|
|
2800
2855
|
}
|
|
@@ -2854,8 +2909,8 @@ class ce {
|
|
|
2854
2909
|
* @param {number} [options.maxDistance=3]
|
|
2855
2910
|
* @param {number} [options.minSurprise=0.5]
|
|
2856
2911
|
*/
|
|
2857
|
-
async getDiscoveries(e, { maxDistance: t = 3, minSurprise:
|
|
2858
|
-
return this.api.get(`/memory/zettel/${e}/discoveries?max_distance=${t}&min_surprise=${
|
|
2912
|
+
async getDiscoveries(e, { maxDistance: t = 3, minSurprise: n = 0.5 } = {}) {
|
|
2913
|
+
return this.api.get(`/memory/zettel/${e}/discoveries?max_distance=${t}&min_surprise=${n}`);
|
|
2859
2914
|
}
|
|
2860
2915
|
/**
|
|
2861
2916
|
* Find paths between two notes.
|
|
@@ -2863,8 +2918,8 @@ class ce {
|
|
|
2863
2918
|
* @param {string} targetId
|
|
2864
2919
|
* @param {number} [maxPaths=5]
|
|
2865
2920
|
*/
|
|
2866
|
-
async getPath(e, t,
|
|
2867
|
-
return this.api.get(`/memory/zettel/${e}/path/${t}?max_paths=${
|
|
2921
|
+
async getPath(e, t, n = 5) {
|
|
2922
|
+
return this.api.get(`/memory/zettel/${e}/path/${t}?max_paths=${n}`);
|
|
2868
2923
|
}
|
|
2869
2924
|
// === WIKILINK SUPPORT ===
|
|
2870
2925
|
/**
|
|
@@ -2890,8 +2945,8 @@ class ce {
|
|
|
2890
2945
|
* @param {number} [options.depth=2]
|
|
2891
2946
|
* @param {boolean} [options.includeMetadata=true]
|
|
2892
2947
|
*/
|
|
2893
|
-
async getSubgraph(e, { depth: t = 2, includeMetadata:
|
|
2894
|
-
return this.api.get(`/memory/zettel/${e}/graph?depth=${t}&include_metadata=${
|
|
2948
|
+
async getSubgraph(e, { depth: t = 2, includeMetadata: n = !0 } = {}) {
|
|
2949
|
+
return this.api.get(`/memory/zettel/${e}/graph?depth=${t}&include_metadata=${n}`);
|
|
2895
2950
|
}
|
|
2896
2951
|
// === ADDITIONAL DISCOVERY ===
|
|
2897
2952
|
/**
|
|
@@ -2932,8 +2987,8 @@ class ce {
|
|
|
2932
2987
|
* @param {string} value
|
|
2933
2988
|
* @param {number} [limit=100]
|
|
2934
2989
|
*/
|
|
2935
|
-
async findByProperty(e, t,
|
|
2936
|
-
return this.api.get(`/memory/zettel/by-property?key=${encodeURIComponent(e)}&value=${encodeURIComponent(t)}&limit=${
|
|
2990
|
+
async findByProperty(e, t, n = 100) {
|
|
2991
|
+
return this.api.get(`/memory/zettel/by-property?key=${encodeURIComponent(e)}&value=${encodeURIComponent(t)}&limit=${n}`);
|
|
2937
2992
|
}
|
|
2938
2993
|
/**
|
|
2939
2994
|
* Find notes mentioning an entity.
|
|
@@ -2949,11 +3004,11 @@ class ce {
|
|
|
2949
3004
|
* @param {string} relationType
|
|
2950
3005
|
* @param {number} [limit=100]
|
|
2951
3006
|
*/
|
|
2952
|
-
async queryByRelation(e, t,
|
|
2953
|
-
return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${
|
|
3007
|
+
async queryByRelation(e, t, n = 100) {
|
|
3008
|
+
return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${n}`);
|
|
2954
3009
|
}
|
|
2955
3010
|
}
|
|
2956
|
-
class
|
|
3011
|
+
class le {
|
|
2957
3012
|
constructor(e) {
|
|
2958
3013
|
this.api = e;
|
|
2959
3014
|
}
|
|
@@ -2968,9 +3023,9 @@ class ue {
|
|
|
2968
3023
|
*/
|
|
2969
3024
|
async list(e = {}) {
|
|
2970
3025
|
const t = Object.fromEntries(
|
|
2971
|
-
Object.entries(e).filter(([,
|
|
2972
|
-
),
|
|
2973
|
-
return this.api.get(`/memory/procedures/matches${
|
|
3026
|
+
Object.entries(e).filter(([, s]) => s != null)
|
|
3027
|
+
), n = new URLSearchParams(t).toString();
|
|
3028
|
+
return this.api.get(`/memory/procedures/matches${n ? "?" + n : ""}`);
|
|
2974
3029
|
}
|
|
2975
3030
|
/**
|
|
2976
3031
|
* Submit feedback for a procedure match.
|
|
@@ -2978,9 +3033,9 @@ class ue {
|
|
|
2978
3033
|
* @param {string} feedback - One of "success", "failure", "neutral"
|
|
2979
3034
|
* @param {string} [note] - Optional explanation
|
|
2980
3035
|
*/
|
|
2981
|
-
async submitFeedback(e, t,
|
|
2982
|
-
const
|
|
2983
|
-
return
|
|
3036
|
+
async submitFeedback(e, t, n = null) {
|
|
3037
|
+
const s = { feedback: t };
|
|
3038
|
+
return n && (s.note = n), this.api.post(`/memory/procedures/matches/${e}/feedback`, s);
|
|
2984
3039
|
}
|
|
2985
3040
|
/**
|
|
2986
3041
|
* Get aggregated procedure match statistics.
|
|
@@ -2989,7 +3044,7 @@ class ue {
|
|
|
2989
3044
|
return this.api.get("/memory/procedures/matches/stats");
|
|
2990
3045
|
}
|
|
2991
3046
|
}
|
|
2992
|
-
class
|
|
3047
|
+
class me {
|
|
2993
3048
|
constructor(e) {
|
|
2994
3049
|
this.api = e;
|
|
2995
3050
|
}
|
|
@@ -3004,9 +3059,9 @@ class le {
|
|
|
3004
3059
|
*/
|
|
3005
3060
|
async list(e = {}) {
|
|
3006
3061
|
const t = Object.fromEntries(
|
|
3007
|
-
Object.entries(e).filter(([,
|
|
3008
|
-
),
|
|
3009
|
-
return this.api.get(`/memory/procedures/candidates${
|
|
3062
|
+
Object.entries(e).filter(([, s]) => s != null)
|
|
3063
|
+
), n = new URLSearchParams(t).toString();
|
|
3064
|
+
return this.api.get(`/memory/procedures/candidates${n ? "?" + n : ""}`);
|
|
3010
3065
|
}
|
|
3011
3066
|
/**
|
|
3012
3067
|
* Promote a candidate cluster to a new procedure.
|
|
@@ -3020,14 +3075,14 @@ class le {
|
|
|
3020
3075
|
* @returns {Promise<Object>} Response with procedure_id and status
|
|
3021
3076
|
*/
|
|
3022
3077
|
async promote(e, t = {}) {
|
|
3023
|
-
const
|
|
3078
|
+
const n = {
|
|
3024
3079
|
name: t.name ?? null,
|
|
3025
3080
|
description: t.description ?? null,
|
|
3026
3081
|
procedure_type: t.procedure_type ?? "extraction",
|
|
3027
3082
|
preferred_profile: t.preferred_profile ?? "quick_extract",
|
|
3028
3083
|
remove_working_items: t.remove_working_items ?? !1
|
|
3029
3084
|
};
|
|
3030
|
-
return this.api.post(`/memory/procedures/candidates/${e}/promote`,
|
|
3085
|
+
return this.api.post(`/memory/procedures/candidates/${e}/promote`, n);
|
|
3031
3086
|
}
|
|
3032
3087
|
/**
|
|
3033
3088
|
* Dismiss a candidate cluster from future recommendations.
|
|
@@ -3038,7 +3093,7 @@ class le {
|
|
|
3038
3093
|
return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
|
|
3039
3094
|
}
|
|
3040
3095
|
}
|
|
3041
|
-
class
|
|
3096
|
+
class he {
|
|
3042
3097
|
constructor(e) {
|
|
3043
3098
|
this.api = e;
|
|
3044
3099
|
}
|
|
@@ -3055,9 +3110,9 @@ class me {
|
|
|
3055
3110
|
*/
|
|
3056
3111
|
async list(e = {}) {
|
|
3057
3112
|
const t = Object.fromEntries(
|
|
3058
|
-
Object.entries(e).filter(([,
|
|
3059
|
-
),
|
|
3060
|
-
return this.api.get(`/memory/procedures/drift${
|
|
3113
|
+
Object.entries(e).filter(([, s]) => s != null)
|
|
3114
|
+
), n = new URLSearchParams(t).toString();
|
|
3115
|
+
return this.api.get(`/memory/procedures/drift${n ? "?" + n : ""}`);
|
|
3061
3116
|
}
|
|
3062
3117
|
/**
|
|
3063
3118
|
* Get a single drift event with full change details.
|
|
@@ -3074,8 +3129,8 @@ class me {
|
|
|
3074
3129
|
* @returns {Promise<{status: string, event_id: string, resolved: boolean}>}
|
|
3075
3130
|
*/
|
|
3076
3131
|
async resolve(e, t = null) {
|
|
3077
|
-
const
|
|
3078
|
-
return t != null && (
|
|
3132
|
+
const n = {};
|
|
3133
|
+
return t != null && (n.note = t), this.api.post(`/memory/procedures/drift/${e}/resolve`, n);
|
|
3079
3134
|
}
|
|
3080
3135
|
/**
|
|
3081
3136
|
* Trigger a drift sweep across all procedures in the workspace.
|
|
@@ -3093,7 +3148,7 @@ class me {
|
|
|
3093
3148
|
return this.api.get(`/memory/procedures/schemas/${e}`);
|
|
3094
3149
|
}
|
|
3095
3150
|
}
|
|
3096
|
-
class
|
|
3151
|
+
class ye {
|
|
3097
3152
|
constructor(e) {
|
|
3098
3153
|
this.api = e;
|
|
3099
3154
|
}
|
|
@@ -3144,9 +3199,9 @@ class he {
|
|
|
3144
3199
|
* @param {number} [params.limit=20]
|
|
3145
3200
|
* @param {string} [params.before] ISO 8601 datetime
|
|
3146
3201
|
*/
|
|
3147
|
-
async list({ isHeartbeat: e = null, limit: t = 20, before:
|
|
3148
|
-
const
|
|
3149
|
-
return e !== null && (
|
|
3202
|
+
async list({ isHeartbeat: e = null, limit: t = 20, before: n = null } = {}) {
|
|
3203
|
+
const s = { limit: t };
|
|
3204
|
+
return e !== null && (s.is_heartbeat = e), n !== null && (s.before = n), this.api.get("/memory/summary/list", s);
|
|
3150
3205
|
}
|
|
3151
3206
|
/** SnapshotDelta between two snapshots. Returns null on 404. */
|
|
3152
3207
|
async delta({ from: e, to: t }) {
|
|
@@ -3155,9 +3210,9 @@ class he {
|
|
|
3155
3210
|
from: e,
|
|
3156
3211
|
to: t
|
|
3157
3212
|
});
|
|
3158
|
-
} catch (
|
|
3159
|
-
if ((
|
|
3160
|
-
throw
|
|
3213
|
+
} catch (n) {
|
|
3214
|
+
if ((n == null ? void 0 : n.status) === 404) return null;
|
|
3215
|
+
throw n;
|
|
3161
3216
|
}
|
|
3162
3217
|
}
|
|
3163
3218
|
/** Admin-only delete. Throws on 403/404/500. */
|
|
@@ -3165,7 +3220,7 @@ class he {
|
|
|
3165
3220
|
return this.api.delete(`/memory/summary/${e}`);
|
|
3166
3221
|
}
|
|
3167
3222
|
}
|
|
3168
|
-
class
|
|
3223
|
+
class pe {
|
|
3169
3224
|
constructor(e) {
|
|
3170
3225
|
this.api = e;
|
|
3171
3226
|
}
|
|
@@ -3177,13 +3232,13 @@ class ye {
|
|
|
3177
3232
|
* @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
|
|
3178
3233
|
*/
|
|
3179
3234
|
async acquire(e, { ttlSeconds: t } = {}) {
|
|
3180
|
-
var
|
|
3181
|
-
const
|
|
3182
|
-
t !== void 0 && (
|
|
3235
|
+
var s, r;
|
|
3236
|
+
const n = {};
|
|
3237
|
+
t !== void 0 && (n.ttl_seconds = t);
|
|
3183
3238
|
try {
|
|
3184
|
-
return await this.api.post(`/memory/locks/${e}`,
|
|
3239
|
+
return await this.api.post(`/memory/locks/${e}`, n);
|
|
3185
3240
|
} catch (i) {
|
|
3186
|
-
if ((i == null ? void 0 : i.status) === 409 && ((r = (
|
|
3241
|
+
if ((i == null ? void 0 : i.status) === 409 && ((r = (s = i.detail) == null ? void 0 : s.detail) == null ? void 0 : r.reason) === "lock_held")
|
|
3187
3242
|
return null;
|
|
3188
3243
|
throw i;
|
|
3189
3244
|
}
|
|
@@ -3196,12 +3251,12 @@ class ye {
|
|
|
3196
3251
|
* @param {number} [params.ttlSeconds]
|
|
3197
3252
|
* @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
|
|
3198
3253
|
*/
|
|
3199
|
-
async renew(e, t, { ttlSeconds:
|
|
3254
|
+
async renew(e, t, { ttlSeconds: n } = {}) {
|
|
3200
3255
|
var r, i;
|
|
3201
|
-
const
|
|
3202
|
-
|
|
3256
|
+
const s = {};
|
|
3257
|
+
n !== void 0 && (s.ttl_seconds = n);
|
|
3203
3258
|
try {
|
|
3204
|
-
return await this.api.post(`/memory/locks/${e}/renew`,
|
|
3259
|
+
return await this.api.post(`/memory/locks/${e}/renew`, s, {
|
|
3205
3260
|
headers: { "X-Lease-Token": t }
|
|
3206
3261
|
});
|
|
3207
3262
|
} catch (c) {
|
|
@@ -3217,19 +3272,19 @@ class ye {
|
|
|
3217
3272
|
* @returns {Promise<boolean>}
|
|
3218
3273
|
*/
|
|
3219
3274
|
async release(e, t) {
|
|
3220
|
-
var
|
|
3275
|
+
var n, s;
|
|
3221
3276
|
try {
|
|
3222
3277
|
return await this.api.delete(`/memory/locks/${e}`, {
|
|
3223
3278
|
headers: { "X-Lease-Token": t }
|
|
3224
3279
|
}), !0;
|
|
3225
3280
|
} catch (r) {
|
|
3226
|
-
if ((r == null ? void 0 : r.status) === 409 && ((
|
|
3281
|
+
if ((r == null ? void 0 : r.status) === 409 && ((s = (n = r.detail) == null ? void 0 : n.detail) == null ? void 0 : s.reason) === "not_owner")
|
|
3227
3282
|
return !1;
|
|
3228
3283
|
throw r;
|
|
3229
3284
|
}
|
|
3230
3285
|
}
|
|
3231
3286
|
}
|
|
3232
|
-
class
|
|
3287
|
+
class de {
|
|
3233
3288
|
constructor(e) {
|
|
3234
3289
|
this.api = e;
|
|
3235
3290
|
}
|
|
@@ -3250,9 +3305,9 @@ class pe {
|
|
|
3250
3305
|
* @param {number} [params.count] How many to allocate (1..100, default 1).
|
|
3251
3306
|
* @returns {Promise<{name: string, value: number, first: number, count: number}>}
|
|
3252
3307
|
*/
|
|
3253
|
-
async allocate(e, { floor: t, count:
|
|
3254
|
-
const
|
|
3255
|
-
return t !== void 0 && (
|
|
3308
|
+
async allocate(e, { floor: t, count: n } = {}) {
|
|
3309
|
+
const s = {};
|
|
3310
|
+
return t !== void 0 && (s.floor = t), n !== void 0 && (s.count = n), this.api.post(`/memory/sequences/${e}/next`, s);
|
|
3256
3311
|
}
|
|
3257
3312
|
/**
|
|
3258
3313
|
* Read the counter without consuming a number, or null if never allocated.
|
|
@@ -3275,9 +3330,75 @@ class pe {
|
|
|
3275
3330
|
}
|
|
3276
3331
|
class ge {
|
|
3277
3332
|
constructor(e) {
|
|
3278
|
-
this.
|
|
3279
|
-
|
|
3280
|
-
|
|
3333
|
+
this.api = e;
|
|
3334
|
+
}
|
|
3335
|
+
/**
|
|
3336
|
+
* Assemble one priority-ordered context block within a token budget.
|
|
3337
|
+
* @param {Object} params
|
|
3338
|
+
* @param {number} params.budgetTokens Token budget for the packed block.
|
|
3339
|
+
* @param {string} [params.query] Query to rank items by relevance; omit for
|
|
3340
|
+
* tier + recency ranking.
|
|
3341
|
+
* @param {Array<Object>} [params.sections] Overrides the default section
|
|
3342
|
+
* list/order/caps. Each entry is `{ name, cap_tokens }` on the wire;
|
|
3343
|
+
* callers may pass either `cap_tokens` or camelCase `capTokens` and it
|
|
3344
|
+
* will be normalized to `cap_tokens`.
|
|
3345
|
+
* @param {string} [params.preset] Named section set, used instead of
|
|
3346
|
+
* `sections`. `'wakeup'` is the session-start L1 card (active plan, anchors,
|
|
3347
|
+
* workspace topics, last-session headline) — pass it with a small budget
|
|
3348
|
+
* (~300 tokens); the default sections go degenerate at that size, and the card
|
|
3349
|
+
* is content-bounded so a typical workspace renders far under it. Passing
|
|
3350
|
+
* both `preset` and `sections` is rejected with a 400.
|
|
3351
|
+
*
|
|
3352
|
+
* `null` and `undefined` are treated identically for both optional params and
|
|
3353
|
+
* omitted from the wire body. `null` is what you get from `JSON.parse`, from a
|
|
3354
|
+
* default-valued config object, or from a caller spreading a partially-filled
|
|
3355
|
+
* options object — and `sections: null` previously reached `null.map(...)` and
|
|
3356
|
+
* threw. Omitting also matches the Python SDK and the MCP remote backend, so one
|
|
3357
|
+
* body shape reaches the route from every client.
|
|
3358
|
+
* @returns {Promise<Object>} RecallPack — `{ block, manifest }`.
|
|
3359
|
+
*/
|
|
3360
|
+
async pack({ budgetTokens: e, query: t, sections: n, preset: s } = {}) {
|
|
3361
|
+
const r = { budget_tokens: e };
|
|
3362
|
+
return t != null && (r.query = t), n != null && (r.sections = n.map(({ name: i, cap_tokens: c, capTokens: o }) => ({
|
|
3363
|
+
name: i,
|
|
3364
|
+
cap_tokens: c !== void 0 ? c : o
|
|
3365
|
+
}))), s != null && (r.preset = s), this.api.post("/memory/recall/pack", r);
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
class fe {
|
|
3369
|
+
constructor(e) {
|
|
3370
|
+
this.api = e;
|
|
3371
|
+
}
|
|
3372
|
+
/**
|
|
3373
|
+
* Compile active workspace decisions into a Stratum policy bundle.
|
|
3374
|
+
*
|
|
3375
|
+
* @param {Object} [params]
|
|
3376
|
+
* @param {string} [params.workflow] Workflow selector echoed by the bundle.
|
|
3377
|
+
* @param {string} [params.domain] Exact source-decision domain filter.
|
|
3378
|
+
* @param {string[]} [params.statuses=['active']] Repeatable lifecycle selector.
|
|
3379
|
+
* @returns {Promise<Object>} The policy-exchange contract bundle.
|
|
3380
|
+
*/
|
|
3381
|
+
async getBundle({ workflow: e, domain: t, statuses: n = ["active"] } = {}) {
|
|
3382
|
+
const s = new URLSearchParams();
|
|
3383
|
+
if (e != null && s.append("workflow", e), t != null && s.append("domain", t), Array.isArray(n))
|
|
3384
|
+
for (const i of n) s.append("status", i);
|
|
3385
|
+
const r = s.toString();
|
|
3386
|
+
return this.api.get(`/memory/policy/bundle${r ? "?" + r : ""}`);
|
|
3387
|
+
}
|
|
3388
|
+
/**
|
|
3389
|
+
* Record an idempotent Stratum enforcement event without reshaping contract fields.
|
|
3390
|
+
* @param {Object} event Enforcement event using the contract's snake_case keys.
|
|
3391
|
+
* @returns {Promise<Object>} `{ event_id, item_id, created, edges }`.
|
|
3392
|
+
*/
|
|
3393
|
+
async recordEnforcementEvent(e) {
|
|
3394
|
+
return this.api.post("/memory/policy/events", e);
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
class $e {
|
|
3398
|
+
constructor(e) {
|
|
3399
|
+
this.auth = new O(e);
|
|
3400
|
+
const t = new j(this.auth, { fetchFn: e.fetchFn });
|
|
3401
|
+
this._api = t, this.memories = new B(t), this.decisions = new H(t), this.opinions = new K(t), this.graph = new G(t), this.teams = new D(t), this.profiles = new N(t), this.subscriptions = new J(t), this.authAPI = new W(t), this.agents = new V(t), this.usage = new Y(t), this.insights = new X(t), this.tokenUsage = new Z(t), this.temporal = new Q(t), this.governance = new ee(t), this.evolution = new te(t), this.reasoning = new ne(t), this.reasoningTraces = new se(t), this.ontology = new re(t), this.analytics = new ie(t), this.validation = new ae(t), this.pipeline = new oe(t), this.archive = new ce(t), this.zettelkasten = new ue(t), this.procedureMatches = new le(t), this.procedureCandidates = new me(t), this.procedureDrift = new he(t), this.summaries = new ye(t), this.locks = new pe(t), this.sequences = new de(t), this.recall = new ge(t), this.policy = new fe(t);
|
|
3281
3402
|
}
|
|
3282
3403
|
setTeamId(e) {
|
|
3283
3404
|
this.auth.tokenManager.setTeamId(e), this.auth.notifyListeners();
|
|
@@ -3298,43 +3419,43 @@ class ge {
|
|
|
3298
3419
|
* @returns {Promise<{ imported: number, failed: number, workspace_id: string }>}
|
|
3299
3420
|
*/
|
|
3300
3421
|
async importOkf(e) {
|
|
3301
|
-
const t = e instanceof Blob ? e : new Blob([e], { type: "application/gzip" }),
|
|
3302
|
-
return
|
|
3422
|
+
const t = e instanceof Blob ? e : new Blob([e], { type: "application/gzip" }), n = new FormData();
|
|
3423
|
+
return n.append("file", t, "smartmemory-okf-import.tar.gz"), this._api.postForm("/memory/okf/import", n);
|
|
3303
3424
|
}
|
|
3304
3425
|
}
|
|
3305
3426
|
export {
|
|
3306
3427
|
k as A,
|
|
3307
|
-
|
|
3428
|
+
j as B,
|
|
3308
3429
|
H as D,
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3430
|
+
te as E,
|
|
3431
|
+
ee as G,
|
|
3432
|
+
X as I,
|
|
3433
|
+
pe as L,
|
|
3434
|
+
B as M,
|
|
3435
|
+
re as O,
|
|
3436
|
+
oe as P,
|
|
3437
|
+
ne as R,
|
|
3438
|
+
de as S,
|
|
3439
|
+
D as T,
|
|
3440
|
+
Y as U,
|
|
3441
|
+
ae as V,
|
|
3442
|
+
ue as Z,
|
|
3443
|
+
V as a,
|
|
3444
|
+
ie as b,
|
|
3445
|
+
ce as c,
|
|
3446
|
+
W as d,
|
|
3447
|
+
O as e,
|
|
3448
|
+
G as f,
|
|
3449
|
+
K as g,
|
|
3450
|
+
me as h,
|
|
3451
|
+
le as i,
|
|
3452
|
+
N as j,
|
|
3332
3453
|
se as k,
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3454
|
+
$e as l,
|
|
3455
|
+
J as m,
|
|
3456
|
+
Q as n,
|
|
3457
|
+
x as o,
|
|
3458
|
+
Z as p,
|
|
3459
|
+
z as q,
|
|
3460
|
+
F as r
|
|
3340
3461
|
};
|