@smartmemory/sdk-js 1.4.96 → 1.4.119
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-McKeQ81o.js → core-BLQpDtod.js} +500 -450
- package/dist/core.js +5 -4
- package/dist/index.js +14 -11
- package/dist/react.js +20 -20
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var
|
|
1
|
+
var z = (o) => {
|
|
2
2
|
throw TypeError(o);
|
|
3
3
|
};
|
|
4
|
-
var P = (o, e, t) => e.has(o) ||
|
|
5
|
-
var v = (o, e, t) => (P(o, e, "read from private field"), t ? t.call(o) : e.get(o)), q = (o, e, t) => e.has(o) ?
|
|
6
|
-
const
|
|
4
|
+
var P = (o, e, t) => e.has(o) || z("Cannot " + t);
|
|
5
|
+
var v = (o, e, t) => (P(o, e, "read from private field"), t ? t.call(o) : e.get(o)), q = (o, e, t) => e.has(o) ? z("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), L = (o, e, t, s) => (P(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t), O = (o, e, t) => (P(o, e, "access private method"), t);
|
|
6
|
+
const j = {
|
|
7
7
|
access: "smart_memory_auth_token",
|
|
8
8
|
refresh: "smart_memory_refresh_token",
|
|
9
9
|
user: "smart_memory_user",
|
|
10
10
|
tenant: "smart_memory_tenant_id",
|
|
11
|
-
|
|
12
|
-
},
|
|
11
|
+
workspace: "smart_memory_workspace_id"
|
|
12
|
+
}, I = {
|
|
13
13
|
access: ["access_token", "sm_token"],
|
|
14
14
|
refresh: ["refresh_token", "sm_refresh_token"],
|
|
15
15
|
user: ["sm_user"],
|
|
16
16
|
tenant: ["tenant_id", "workspace_id", "sm_workspace_id"],
|
|
17
|
-
|
|
17
|
+
workspace: ["smart_memory_team_id", "team_id", "sm_team_id"]
|
|
18
18
|
};
|
|
19
19
|
class K {
|
|
20
20
|
/**
|
|
@@ -23,10 +23,16 @@ class K {
|
|
|
23
23
|
* @param {Object} [options.keys] - Custom storage key names
|
|
24
24
|
*/
|
|
25
25
|
constructor({ storage: e = "localStorage", keys: t = {} } = {}) {
|
|
26
|
-
|
|
26
|
+
var n;
|
|
27
|
+
this.storageType = e;
|
|
28
|
+
const s = t.workspace || t.team || j.workspace;
|
|
29
|
+
this.keys = { ...j, ...t, workspace: s }, (n = this.keys).team ?? (n.team = s), this.workspaceAliases = [
|
|
30
|
+
...I.workspace,
|
|
31
|
+
...t.team && t.team !== s ? [t.team] : []
|
|
32
|
+
], this._memory = { access: null, refresh: null, user: null, tenant: null, workspace: null };
|
|
27
33
|
}
|
|
28
34
|
getAccessToken() {
|
|
29
|
-
return this.storageType === "memory" ? this._memory.access : this._getFromStorage(this.keys.access,
|
|
35
|
+
return this.storageType === "memory" ? this._memory.access : this._getFromStorage(this.keys.access, I.access);
|
|
30
36
|
}
|
|
31
37
|
setAccessToken(e) {
|
|
32
38
|
if (this.storageType === "memory") {
|
|
@@ -36,7 +42,7 @@ class K {
|
|
|
36
42
|
this._setInStorage(this.keys.access, e);
|
|
37
43
|
}
|
|
38
44
|
getRefreshToken() {
|
|
39
|
-
return this.storageType === "memory" ? this._memory.refresh : this._getFromStorage(this.keys.refresh,
|
|
45
|
+
return this.storageType === "memory" ? this._memory.refresh : this._getFromStorage(this.keys.refresh, I.refresh);
|
|
40
46
|
}
|
|
41
47
|
setRefreshToken(e) {
|
|
42
48
|
if (this.storageType === "memory") {
|
|
@@ -47,7 +53,7 @@ class K {
|
|
|
47
53
|
}
|
|
48
54
|
getUser() {
|
|
49
55
|
if (this.storageType === "memory") return this._memory.user;
|
|
50
|
-
const e = this._getFromStorage(this.keys.user,
|
|
56
|
+
const e = this._getFromStorage(this.keys.user, I.user);
|
|
51
57
|
if (!e) return null;
|
|
52
58
|
try {
|
|
53
59
|
return JSON.parse(e);
|
|
@@ -63,7 +69,7 @@ class K {
|
|
|
63
69
|
this._setInStorage(this.keys.user, e ? JSON.stringify(e) : null);
|
|
64
70
|
}
|
|
65
71
|
getTenantId() {
|
|
66
|
-
return this.storageType === "memory" ? this._memory.tenant : this._normalizeId(this._getFromStorage(this.keys.tenant,
|
|
72
|
+
return this.storageType === "memory" ? this._memory.tenant : this._normalizeId(this._getFromStorage(this.keys.tenant, I.tenant));
|
|
67
73
|
}
|
|
68
74
|
setTenantId(e) {
|
|
69
75
|
const t = this._normalizeId(e);
|
|
@@ -73,20 +79,26 @@ class K {
|
|
|
73
79
|
}
|
|
74
80
|
this._setInStorage(this.keys.tenant, t);
|
|
75
81
|
}
|
|
76
|
-
|
|
77
|
-
return this.storageType === "memory" ? this._memory.
|
|
82
|
+
getWorkspaceId() {
|
|
83
|
+
return this.storageType === "memory" ? this._memory.workspace : this._normalizeId(this._getFromStorage(this.keys.workspace, this.workspaceAliases));
|
|
78
84
|
}
|
|
79
|
-
|
|
85
|
+
setWorkspaceId(e) {
|
|
80
86
|
const t = this._normalizeId(e);
|
|
81
87
|
if (this.storageType === "memory") {
|
|
82
|
-
this._memory.
|
|
88
|
+
this._memory.workspace = t;
|
|
83
89
|
return;
|
|
84
90
|
}
|
|
85
|
-
this._setInStorage(this.keys.
|
|
91
|
+
this._setInStorage(this.keys.workspace, t);
|
|
92
|
+
}
|
|
93
|
+
getTeamId() {
|
|
94
|
+
return this.getWorkspaceId();
|
|
95
|
+
}
|
|
96
|
+
setTeamId(e) {
|
|
97
|
+
this.setWorkspaceId(e);
|
|
86
98
|
}
|
|
87
99
|
clearAll() {
|
|
88
100
|
if (this.storageType === "memory") {
|
|
89
|
-
this._memory = { access: null, refresh: null, user: null, tenant: null,
|
|
101
|
+
this._memory = { access: null, refresh: null, user: null, tenant: null, workspace: null };
|
|
90
102
|
return;
|
|
91
103
|
}
|
|
92
104
|
for (const e of Object.values(this.keys))
|
|
@@ -94,7 +106,7 @@ class K {
|
|
|
94
106
|
localStorage.removeItem(e), sessionStorage.removeItem(e);
|
|
95
107
|
} catch {
|
|
96
108
|
}
|
|
97
|
-
for (const e of Object.values(
|
|
109
|
+
for (const e of Object.values(I))
|
|
98
110
|
for (const t of e)
|
|
99
111
|
try {
|
|
100
112
|
localStorage.removeItem(t), sessionStorage.removeItem(t);
|
|
@@ -112,14 +124,14 @@ class K {
|
|
|
112
124
|
/** @private */
|
|
113
125
|
_getFromStorage(e, t = []) {
|
|
114
126
|
try {
|
|
115
|
-
const
|
|
127
|
+
const s = this.storageType === "localStorage" ? localStorage : sessionStorage, n = this.storageType === "localStorage" ? sessionStorage : localStorage, r = s.getItem(e) || n.getItem(e);
|
|
116
128
|
if (r != null) return r;
|
|
117
129
|
for (const i of t) {
|
|
118
|
-
const a =
|
|
130
|
+
const a = s.getItem(i) || n.getItem(i);
|
|
119
131
|
if (a != null) {
|
|
120
132
|
this._setInStorage(e, a);
|
|
121
133
|
try {
|
|
122
|
-
|
|
134
|
+
s.removeItem(i), n.removeItem(i);
|
|
123
135
|
} catch {
|
|
124
136
|
}
|
|
125
137
|
return a;
|
|
@@ -133,10 +145,10 @@ class K {
|
|
|
133
145
|
/** @private */
|
|
134
146
|
_setInStorage(e, t) {
|
|
135
147
|
try {
|
|
136
|
-
const
|
|
137
|
-
t != null ? (
|
|
138
|
-
} catch (
|
|
139
|
-
console.error("Failed to write to storage:",
|
|
148
|
+
const s = this.storageType === "localStorage" ? localStorage : sessionStorage, n = this.storageType === "localStorage" ? sessionStorage : localStorage;
|
|
149
|
+
t != null ? (s.setItem(e, t), n.removeItem(e)) : (s.removeItem(e), n.removeItem(e));
|
|
150
|
+
} catch (s) {
|
|
151
|
+
console.error("Failed to write to storage:", s);
|
|
140
152
|
}
|
|
141
153
|
}
|
|
142
154
|
/** @private */
|
|
@@ -144,11 +156,11 @@ class K {
|
|
|
144
156
|
if (e == null) return null;
|
|
145
157
|
const t = String(e).trim();
|
|
146
158
|
if (!t) return null;
|
|
147
|
-
const
|
|
148
|
-
return
|
|
159
|
+
const s = t.toLowerCase();
|
|
160
|
+
return s === "none" || s === "null" || s === "undefined" ? null : t;
|
|
149
161
|
}
|
|
150
162
|
}
|
|
151
|
-
var _, A,
|
|
163
|
+
var _, A, B;
|
|
152
164
|
class D {
|
|
153
165
|
/**
|
|
154
166
|
* @param {Object} options
|
|
@@ -159,15 +171,15 @@ class D {
|
|
|
159
171
|
* @param {function(string): void} options.onTokenRefreshed
|
|
160
172
|
* @param {function(): void} options.onRefreshFailed
|
|
161
173
|
*/
|
|
162
|
-
constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager:
|
|
174
|
+
constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager: s, useCookieAuth: n = !1, onTokenRefreshed: r, onRefreshFailed: i }) {
|
|
163
175
|
q(this, A);
|
|
164
176
|
q(this, _, null);
|
|
165
|
-
this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager =
|
|
177
|
+
this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager = s, this.useCookieAuth = n, this.onTokenRefreshed = r, this.onRefreshFailed = i;
|
|
166
178
|
}
|
|
167
179
|
async refresh() {
|
|
168
180
|
if (v(this, _))
|
|
169
181
|
return v(this, _);
|
|
170
|
-
L(this, _,
|
|
182
|
+
L(this, _, O(this, A, B).call(this));
|
|
171
183
|
try {
|
|
172
184
|
return await v(this, _);
|
|
173
185
|
} finally {
|
|
@@ -175,20 +187,20 @@ class D {
|
|
|
175
187
|
}
|
|
176
188
|
}
|
|
177
189
|
}
|
|
178
|
-
_ = new WeakMap(), A = new WeakSet(),
|
|
190
|
+
_ = new WeakMap(), A = new WeakSet(), B = async function() {
|
|
179
191
|
const e = this.tokenManager.getRefreshToken();
|
|
180
192
|
if (!e && !this.useCookieAuth)
|
|
181
193
|
throw this.onRefreshFailed(), new Error("No refresh token");
|
|
182
|
-
const t = JSON.stringify(e ? { refresh_token: e } : {}),
|
|
194
|
+
const t = JSON.stringify(e ? { refresh_token: e } : {}), s = await fetch(`${this.apiBaseUrl}${this.refreshEndpoint}`, {
|
|
183
195
|
...this.useCookieAuth ? { credentials: "include" } : {},
|
|
184
196
|
method: "POST",
|
|
185
197
|
headers: { "Content-Type": "application/json" },
|
|
186
198
|
body: t
|
|
187
199
|
});
|
|
188
|
-
if (!
|
|
189
|
-
throw this.onRefreshFailed(), new Error(`Refresh failed: ${
|
|
190
|
-
const
|
|
191
|
-
return this.tokenManager.setAccessToken(
|
|
200
|
+
if (!s.ok)
|
|
201
|
+
throw this.onRefreshFailed(), new Error(`Refresh failed: ${s.status}`);
|
|
202
|
+
const n = await s.json();
|
|
203
|
+
return this.tokenManager.setAccessToken(n.access_token), n.refresh_token && this.tokenManager.setRefreshToken(n.refresh_token), this.onTokenRefreshed(n.access_token), n.access_token;
|
|
192
204
|
};
|
|
193
205
|
const E = "smart_memory_sso_redirect";
|
|
194
206
|
class G {
|
|
@@ -198,8 +210,8 @@ class G {
|
|
|
198
210
|
* @param {string[]} [options.allowedHosts=[]] - Allowed redirect hostnames
|
|
199
211
|
* @param {import('./TokenManager.js').TokenManager} options.tokenManager
|
|
200
212
|
*/
|
|
201
|
-
constructor({ webAppUrl: e, allowedHosts: t = [], tokenManager:
|
|
202
|
-
this.webAppUrl = e, this.allowedHosts = t, this.tokenManager =
|
|
213
|
+
constructor({ webAppUrl: e, allowedHosts: t = [], tokenManager: s }) {
|
|
214
|
+
this.webAppUrl = e, this.allowedHosts = t, this.tokenManager = s;
|
|
203
215
|
}
|
|
204
216
|
getLoginUrl(e) {
|
|
205
217
|
const t = e || `${window.location.origin}/auth/callback`;
|
|
@@ -241,8 +253,8 @@ class N {
|
|
|
241
253
|
tokenManager: this.tokenManager,
|
|
242
254
|
useCookieAuth: this.useCookieAuth,
|
|
243
255
|
onTokenRefreshed: (t) => {
|
|
244
|
-
var
|
|
245
|
-
this.currentToken = t, this.notifyListeners(), (
|
|
256
|
+
var s;
|
|
257
|
+
this.currentToken = t, this.notifyListeners(), (s = e.onTokenRefresh) == null || s.call(e, t);
|
|
246
258
|
},
|
|
247
259
|
onRefreshFailed: () => {
|
|
248
260
|
this.clearLocalAuth();
|
|
@@ -266,14 +278,14 @@ class N {
|
|
|
266
278
|
return this.tokenManager.getTenantId();
|
|
267
279
|
}
|
|
268
280
|
hasRole(e) {
|
|
269
|
-
var t,
|
|
270
|
-
return ((
|
|
281
|
+
var t, s;
|
|
282
|
+
return ((s = (t = this.currentUser) == null ? void 0 : t.roles) == null ? void 0 : s.includes(e)) || !1;
|
|
271
283
|
}
|
|
272
284
|
getAuthHeaders(e = {}) {
|
|
273
285
|
const t = { ...e };
|
|
274
286
|
this.currentToken && (t.Authorization = this.currentToken.startsWith("Bearer ") ? this.currentToken : `Bearer ${this.currentToken}`);
|
|
275
|
-
const
|
|
276
|
-
return
|
|
287
|
+
const s = this.tokenManager.getWorkspaceId();
|
|
288
|
+
return s && (t["X-Workspace-Id"] = s), t;
|
|
277
289
|
}
|
|
278
290
|
getRequestOptions(e = {}) {
|
|
279
291
|
return this.useCookieAuth ? { credentials: "include", ...e } : { ...e };
|
|
@@ -287,13 +299,13 @@ class N {
|
|
|
287
299
|
user: this.currentUser,
|
|
288
300
|
token: this.currentToken,
|
|
289
301
|
tenantId: this.tokenManager.getTenantId(),
|
|
290
|
-
workspaceId: this.tokenManager.
|
|
302
|
+
workspaceId: this.tokenManager.getWorkspaceId()
|
|
291
303
|
};
|
|
292
304
|
this.listeners.forEach((t) => {
|
|
293
305
|
try {
|
|
294
306
|
t(e);
|
|
295
|
-
} catch (
|
|
296
|
-
console.error("Auth listener error:",
|
|
307
|
+
} catch (s) {
|
|
308
|
+
console.error("Auth listener error:", s);
|
|
297
309
|
}
|
|
298
310
|
});
|
|
299
311
|
}
|
|
@@ -342,11 +354,11 @@ class N {
|
|
|
342
354
|
let t = await fetch(
|
|
343
355
|
e,
|
|
344
356
|
this.getRequestOptions({ method: "GET", headers: this.getAuthHeaders() })
|
|
345
|
-
),
|
|
346
|
-
if (!t.ok && (this.currentToken || this.tokenManager.
|
|
357
|
+
), s = !1;
|
|
358
|
+
if (!t.ok && (this.currentToken || this.tokenManager.getWorkspaceId()) && (t = await fetch(
|
|
347
359
|
e,
|
|
348
360
|
this.getRequestOptions({ method: "GET", headers: {} })
|
|
349
|
-
),
|
|
361
|
+
), s = t.ok), !t.ok && t.status === 401 && this.refreshManager)
|
|
350
362
|
try {
|
|
351
363
|
await this.refreshManager.refresh(), t = await fetch(
|
|
352
364
|
e,
|
|
@@ -355,10 +367,10 @@ class N {
|
|
|
355
367
|
} catch {
|
|
356
368
|
}
|
|
357
369
|
if (!t.ok) return !1;
|
|
358
|
-
const
|
|
359
|
-
this.currentUser =
|
|
360
|
-
const r = (
|
|
361
|
-
return
|
|
370
|
+
const n = await t.json();
|
|
371
|
+
this.currentUser = n, this.tokenManager.setUser(n);
|
|
372
|
+
const r = (n == null ? void 0 : n.default_workspace_id) || (n == null ? void 0 : n.default_team_id) || null, i = r || this.tokenManager.getWorkspaceId() || null;
|
|
373
|
+
return i && (this.tokenManager.setWorkspaceId(i), this.tokenManager.setTenantId((n == null ? void 0 : n.tenant_id) || i)), s && (this.tokenManager.setAccessToken(null), this.currentToken = null, r && this.tokenManager.setWorkspaceId(r)), this.notifyListeners(), !0;
|
|
362
374
|
} catch {
|
|
363
375
|
return !1;
|
|
364
376
|
}
|
|
@@ -373,14 +385,14 @@ class w extends Error {
|
|
|
373
385
|
* @param {number} [status=0] - HTTP status code (0 for network errors)
|
|
374
386
|
* @param {Object|null} [detail=null] - Error detail from API response
|
|
375
387
|
*/
|
|
376
|
-
constructor(e, t = 0,
|
|
377
|
-
super(e), this.name = "APIError", this.status = t, this.detail =
|
|
388
|
+
constructor(e, t = 0, s = null) {
|
|
389
|
+
super(e), this.name = "APIError", this.status = t, this.detail = s;
|
|
378
390
|
}
|
|
379
391
|
}
|
|
380
392
|
function U(o) {
|
|
381
393
|
return typeof FormData < "u" && o instanceof FormData;
|
|
382
394
|
}
|
|
383
|
-
function
|
|
395
|
+
function F(o) {
|
|
384
396
|
return (o == null ? void 0 : o.name) === "AbortError";
|
|
385
397
|
}
|
|
386
398
|
class J {
|
|
@@ -406,12 +418,12 @@ class J {
|
|
|
406
418
|
*/
|
|
407
419
|
async request(e, t = {}) {
|
|
408
420
|
var i, a;
|
|
409
|
-
const
|
|
421
|
+
const s = `${this.baseURL}${e}`, n = {
|
|
410
422
|
...U(t.body) ? {} : { "Content-Type": "application/json" },
|
|
411
423
|
...this.auth.getAuthHeaders(t.headers)
|
|
412
|
-
}, r = this.auth.getRequestOptions({ ...t, headers:
|
|
424
|
+
}, r = this.auth.getRequestOptions({ ...t, headers: n });
|
|
413
425
|
try {
|
|
414
|
-
let c = await this.fetchFn(
|
|
426
|
+
let c = await this.fetchFn(s, r);
|
|
415
427
|
if (c.status === 401 && !t.__isRetry)
|
|
416
428
|
try {
|
|
417
429
|
await this.auth.refreshToken();
|
|
@@ -420,7 +432,7 @@ class J {
|
|
|
420
432
|
...this.auth.getAuthHeaders(t.headers)
|
|
421
433
|
};
|
|
422
434
|
c = await this.fetchFn(
|
|
423
|
-
|
|
435
|
+
s,
|
|
424
436
|
this.auth.getRequestOptions({ ...r, headers: u, __isRetry: !0 })
|
|
425
437
|
);
|
|
426
438
|
} catch {
|
|
@@ -433,27 +445,27 @@ class J {
|
|
|
433
445
|
throw await this._handleError(c);
|
|
434
446
|
return await c.json();
|
|
435
447
|
} catch (c) {
|
|
436
|
-
throw c instanceof w ||
|
|
448
|
+
throw c instanceof w || F(c) ? c : new w(c.message, 0, "network_error");
|
|
437
449
|
}
|
|
438
450
|
}
|
|
439
451
|
async get(e, t = {}) {
|
|
440
452
|
return this.request(e, { ...t, method: "GET" });
|
|
441
453
|
}
|
|
442
|
-
async post(e, t,
|
|
454
|
+
async post(e, t, s = {}) {
|
|
443
455
|
return this.request(e, {
|
|
444
|
-
...
|
|
456
|
+
...s,
|
|
445
457
|
method: "POST",
|
|
446
458
|
body: JSON.stringify(t)
|
|
447
459
|
});
|
|
448
460
|
}
|
|
449
461
|
async requestBinary(e, t = {}) {
|
|
450
462
|
var i, a;
|
|
451
|
-
const
|
|
463
|
+
const s = `${this.baseURL}${e}`, n = {
|
|
452
464
|
...U(t.body) ? {} : { "Content-Type": "application/json" },
|
|
453
465
|
...this.auth.getAuthHeaders(t.headers)
|
|
454
|
-
}, r = this.auth.getRequestOptions({ ...t, headers:
|
|
466
|
+
}, r = this.auth.getRequestOptions({ ...t, headers: n });
|
|
455
467
|
try {
|
|
456
|
-
let c = await this.fetchFn(
|
|
468
|
+
let c = await this.fetchFn(s, r);
|
|
457
469
|
if (c.status === 401 && !t.__isRetry)
|
|
458
470
|
try {
|
|
459
471
|
await this.auth.refreshToken();
|
|
@@ -462,7 +474,7 @@ class J {
|
|
|
462
474
|
...this.auth.getAuthHeaders(t.headers)
|
|
463
475
|
};
|
|
464
476
|
c = await this.fetchFn(
|
|
465
|
-
|
|
477
|
+
s,
|
|
466
478
|
this.auth.getRequestOptions({ ...r, headers: u, __isRetry: !0 })
|
|
467
479
|
);
|
|
468
480
|
} catch {
|
|
@@ -473,26 +485,26 @@ class J {
|
|
|
473
485
|
throw await this._handleError(c);
|
|
474
486
|
return await c.arrayBuffer();
|
|
475
487
|
} catch (c) {
|
|
476
|
-
throw c instanceof w ||
|
|
488
|
+
throw c instanceof w || F(c) ? c : new w(c.message, 0, "network_error");
|
|
477
489
|
}
|
|
478
490
|
}
|
|
479
|
-
async postForm(e, t,
|
|
491
|
+
async postForm(e, t, s = {}) {
|
|
480
492
|
return this.request(e, {
|
|
481
|
-
...
|
|
493
|
+
...s,
|
|
482
494
|
method: "POST",
|
|
483
495
|
body: t
|
|
484
496
|
});
|
|
485
497
|
}
|
|
486
|
-
async put(e, t,
|
|
498
|
+
async put(e, t, s = {}) {
|
|
487
499
|
return this.request(e, {
|
|
488
|
-
...
|
|
500
|
+
...s,
|
|
489
501
|
method: "PUT",
|
|
490
502
|
body: JSON.stringify(t)
|
|
491
503
|
});
|
|
492
504
|
}
|
|
493
|
-
async patch(e, t,
|
|
505
|
+
async patch(e, t, s = {}) {
|
|
494
506
|
return this.request(e, {
|
|
495
|
-
...
|
|
507
|
+
...s,
|
|
496
508
|
method: "PATCH",
|
|
497
509
|
body: JSON.stringify(t)
|
|
498
510
|
});
|
|
@@ -502,11 +514,11 @@ class J {
|
|
|
502
514
|
}
|
|
503
515
|
/** @private */
|
|
504
516
|
async _handleError(e) {
|
|
505
|
-
var
|
|
517
|
+
var n, r;
|
|
506
518
|
let t;
|
|
507
|
-
const
|
|
519
|
+
const s = (r = (n = e.headers) == null ? void 0 : n.get) == null ? void 0 : r.call(n, "content-type");
|
|
508
520
|
try {
|
|
509
|
-
|
|
521
|
+
s != null && s.includes("application/json") ? t = await e.json() : t = { message: await e.text() };
|
|
510
522
|
} catch {
|
|
511
523
|
t = { message: `HTTP ${e.status}` };
|
|
512
524
|
}
|
|
@@ -529,13 +541,13 @@ class J {
|
|
|
529
541
|
* @private
|
|
530
542
|
*/
|
|
531
543
|
_extractMessage(e, t) {
|
|
532
|
-
var
|
|
533
|
-
const
|
|
534
|
-
if (typeof
|
|
535
|
-
if (
|
|
536
|
-
if (typeof
|
|
537
|
-
if (typeof
|
|
538
|
-
if (Array.isArray(
|
|
544
|
+
var n;
|
|
545
|
+
const s = e == null ? void 0 : e.detail;
|
|
546
|
+
if (typeof s == "string") return s;
|
|
547
|
+
if (s && typeof s == "object") {
|
|
548
|
+
if (typeof s.message == "string") return s.message;
|
|
549
|
+
if (typeof s.code == "string") return s.code;
|
|
550
|
+
if (Array.isArray(s) && typeof ((n = s[0]) == null ? void 0 : n.msg) == "string") return s[0].msg;
|
|
539
551
|
}
|
|
540
552
|
return typeof (e == null ? void 0 : e.message) == "string" ? e.message : `HTTP ${t}`;
|
|
541
553
|
}
|
|
@@ -567,8 +579,8 @@ class V {
|
|
|
567
579
|
async create({
|
|
568
580
|
content: e,
|
|
569
581
|
memoryType: t = "semantic",
|
|
570
|
-
metadata:
|
|
571
|
-
usePipeline:
|
|
582
|
+
metadata: s = null,
|
|
583
|
+
usePipeline: n = !0,
|
|
572
584
|
profileName: r = null,
|
|
573
585
|
conversationContext: i = null,
|
|
574
586
|
embed: a = null
|
|
@@ -576,8 +588,8 @@ class V {
|
|
|
576
588
|
const c = {
|
|
577
589
|
content: e,
|
|
578
590
|
memory_type: t,
|
|
579
|
-
metadata:
|
|
580
|
-
use_pipeline:
|
|
591
|
+
metadata: s,
|
|
592
|
+
use_pipeline: n,
|
|
581
593
|
profile_name: r
|
|
582
594
|
};
|
|
583
595
|
return i != null && (c.conversation_context = i), a != null && (c.embed = a), this.api.post("/memory/add", c);
|
|
@@ -602,11 +614,11 @@ class V {
|
|
|
602
614
|
async update(e, t) {
|
|
603
615
|
return this.api.patch(`/memory/${encodeURIComponent(e)}`, t);
|
|
604
616
|
}
|
|
605
|
-
async supersede(e, { content: t, memoryType:
|
|
617
|
+
async supersede(e, { content: t, memoryType: s, metadata: n = {}, reason: r }) {
|
|
606
618
|
return this.api.post(`/memory/${encodeURIComponent(e)}/supersede`, {
|
|
607
619
|
content: t,
|
|
608
|
-
memory_type:
|
|
609
|
-
metadata:
|
|
620
|
+
memory_type: s,
|
|
621
|
+
metadata: n,
|
|
610
622
|
reason: r
|
|
611
623
|
});
|
|
612
624
|
}
|
|
@@ -626,10 +638,10 @@ class V {
|
|
|
626
638
|
* @throws 400 if `newItemId` equals `id`; 404 if either item is missing *or*
|
|
627
639
|
* out of scope (deliberately indistinguishable); 409 if the store declined.
|
|
628
640
|
*/
|
|
629
|
-
async supersedeLink(e, t,
|
|
641
|
+
async supersedeLink(e, t, s = null) {
|
|
630
642
|
return this.api.post(`/memory/${encodeURIComponent(e)}/supersede-link`, {
|
|
631
643
|
new_item_id: t,
|
|
632
|
-
reason:
|
|
644
|
+
reason: s
|
|
633
645
|
});
|
|
634
646
|
}
|
|
635
647
|
async delete(e) {
|
|
@@ -655,13 +667,13 @@ class V {
|
|
|
655
667
|
async list({
|
|
656
668
|
limit: e = 50,
|
|
657
669
|
offset: t = 0,
|
|
658
|
-
type:
|
|
659
|
-
metadataKey:
|
|
670
|
+
type: s = null,
|
|
671
|
+
metadataKey: n = null,
|
|
660
672
|
metadataValue: r = null,
|
|
661
673
|
includeGrounding: i = null
|
|
662
674
|
} = {}) {
|
|
663
675
|
const a = new URLSearchParams({ limit: e, offset: t });
|
|
664
|
-
return
|
|
676
|
+
return s != null && a.append("memory_type", s), n != null && a.append("metadata_key", n), r != null && a.append("metadata_value", r), i != null && a.append("include_grounding", i), this.api.get(`/memory/list?${a}`);
|
|
665
677
|
}
|
|
666
678
|
/**
|
|
667
679
|
* Search for memory items.
|
|
@@ -671,6 +683,7 @@ class V {
|
|
|
671
683
|
* @param {number} [options.topK=5]
|
|
672
684
|
* @param {boolean} [options.enableHybrid=true]
|
|
673
685
|
* @param {string|null} [options.memoryType=null]
|
|
686
|
+
* @param {string|null} [options.reranker=null] - Optional reranker policy override.
|
|
674
687
|
* @param {boolean} [options.expertise=false] - When true (CORE-EXPERTISE-1 Phase 4a),
|
|
675
688
|
* the response shape changes from a flat list to `{results: {<expertise_type>: [items]}}`
|
|
676
689
|
* keyed by expertise type (decision, constraint, learned, opinion, reasoning, observation).
|
|
@@ -728,20 +741,21 @@ class V {
|
|
|
728
741
|
* hopStrategy: consensus follows entities several top results agree on; relevance follows
|
|
729
742
|
* best-result entities and one-off bridges; semantic asks an LLM. Omitted preserves core default.
|
|
730
743
|
* since/until: ISO strings or Dates bounding created_at in [since, until), independent of asOfDate. */
|
|
731
|
-
async search(e, { topK: t = 5, enableHybrid:
|
|
732
|
-
const l = { query: e, top_k: t, enable_hybrid:
|
|
733
|
-
if (
|
|
744
|
+
async search(e, { topK: t = 5, enableHybrid: s = !0, memoryType: n = null, expertise: r = !1, cite: i = !1, decompose: a = !1, multiHop: c = !1, maxHops: u = 3, budgetMs: h = 1500, semanticHops: y = !1, includeReference: d = !1, includeConsolidated: $ = !1, consolidationFirst: k = !1, asOfDate: g = null, asOfStrict: p = !1, includeSuperseded: b = !1, includeRetracted: R = !1, includeArchived: C = !1, excludeSpeculative: m = !1, since: H = null, until: W = null, hopStrategy: x = null, channelWeights: T = null, reranker: M = null } = {}) {
|
|
745
|
+
const l = { query: e, top_k: t, enable_hybrid: s };
|
|
746
|
+
if (T != null) {
|
|
734
747
|
const S = /* @__PURE__ */ new Set(["entity-graph", "ssg-traversal", "semantic", "regex-text", "lexical", "spreading-activation", "facts", "structural-semantic"]);
|
|
735
|
-
for (const f of Object.keys(
|
|
748
|
+
for (const f of Object.keys(T)) {
|
|
736
749
|
if (["contains", "keyword-bm25"].includes(f))
|
|
737
750
|
throw new Error(`Channel ${f} was removed; use lexical.`);
|
|
738
751
|
if (!S.has(f)) throw new Error(`Unknown search channel ${f}. Accepted: ${[...S].join(", ")}`);
|
|
739
752
|
}
|
|
740
|
-
l.channel_weights =
|
|
753
|
+
l.channel_weights = T;
|
|
741
754
|
}
|
|
742
|
-
|
|
755
|
+
M != null && (l.reranker = M);
|
|
756
|
+
for (const [S, f] of Object.entries({ since: H, until: W }))
|
|
743
757
|
f != null && (l[S] = f instanceof Date ? f.toISOString() : f);
|
|
744
|
-
return
|
|
758
|
+
return n && (l.memory_type = n), r && (l.expertise = !0), i && (l.cite = !0), a && (l.decompose = !0), x != null && (l.hop_strategy = x), c && (l.multi_hop = !0), c && u !== 3 && (l.max_hops = u), c && h !== 1500 && (l.budget_ms = h), c && y && (l.semantic_hops = !0), d && (l.include_reference = !0), $ && (l.include_consolidated = !0), k && (l.consolidation_first = !0), g && (l.as_of_date = g instanceof Date ? g.toISOString() : g), p && (l.as_of_strict = !0), b && (l.include_superseded = !0), R && (l.include_retracted = !0), C && (l.include_archived = !0), m && (l.exclude_speculative = !0), this.api.post("/memory/search", l);
|
|
745
759
|
}
|
|
746
760
|
/**
|
|
747
761
|
* Ask a question and get a written answer plus the evidence behind it (DIST-LITE-9).
|
|
@@ -766,9 +780,9 @@ class V {
|
|
|
766
780
|
* Relation rows carry both display labels and graph node ids; combine them as
|
|
767
781
|
* `${source_id}->${target_id}:${type}` to address the edge in a graph view.
|
|
768
782
|
*/
|
|
769
|
-
async ask(e, { limit: t = 5, reasoning:
|
|
770
|
-
const
|
|
771
|
-
return
|
|
783
|
+
async ask(e, { limit: t = 5, reasoning: s = !0 } = {}) {
|
|
784
|
+
const n = { question: e, limit: t };
|
|
785
|
+
return s !== !0 && (n.reasoning = s), this.api.post("/memory/ask", n);
|
|
772
786
|
}
|
|
773
787
|
/**
|
|
774
788
|
* Get the complete audit answer for one memory (PLAT-AUDITABLE-MEMORY-1).
|
|
@@ -786,28 +800,28 @@ class V {
|
|
|
786
800
|
async explain(e) {
|
|
787
801
|
return this.api.get(`/memory/${encodeURIComponent(e)}/explain`);
|
|
788
802
|
}
|
|
789
|
-
async getWorkingContext(e, t, { k:
|
|
803
|
+
async getWorkingContext(e, t, { k: s = 20, maxTokens: n = null, strategy: r = null } = {}) {
|
|
790
804
|
const i = {
|
|
791
805
|
session_id: e,
|
|
792
806
|
query: t,
|
|
793
|
-
k:
|
|
807
|
+
k: s
|
|
794
808
|
};
|
|
795
|
-
return
|
|
809
|
+
return n != null && (i.max_tokens = n), r != null && (i.strategy = r), this.api.post("/memory/context", i);
|
|
796
810
|
}
|
|
797
|
-
async searchAdvanced(e, { algorithm: t = "query_traversal", maxResults:
|
|
811
|
+
async searchAdvanced(e, { algorithm: t = "query_traversal", maxResults: s = 15, useSSG: n = !0 } = {}) {
|
|
798
812
|
return this.api.post("/memory/search/advanced", {
|
|
799
813
|
query: e,
|
|
800
814
|
algorithm: t,
|
|
801
|
-
max_results:
|
|
802
|
-
use_ssg:
|
|
815
|
+
max_results: s,
|
|
816
|
+
use_ssg: n
|
|
803
817
|
});
|
|
804
818
|
}
|
|
805
|
-
async ingest(e, { profileName: t = null, extractorName:
|
|
819
|
+
async ingest(e, { profileName: t = null, extractorName: s = "llm", context: n = {} } = {}) {
|
|
806
820
|
return this.api.post("/memory/ingest", {
|
|
807
821
|
content: e,
|
|
808
822
|
profile_name: t,
|
|
809
|
-
extractor_name:
|
|
810
|
-
context:
|
|
823
|
+
extractor_name: s,
|
|
824
|
+
context: n
|
|
811
825
|
});
|
|
812
826
|
}
|
|
813
827
|
async getLineage(e) {
|
|
@@ -825,15 +839,15 @@ class V {
|
|
|
825
839
|
* endpoints return slightly different item shapes, so migrate deliberately rather
|
|
826
840
|
* than by find-and-replace.
|
|
827
841
|
*/
|
|
828
|
-
async searchByMetadata(e, t, { memoryType:
|
|
842
|
+
async searchByMetadata(e, t, { memoryType: s = null, limit: n = 25, since: r = null, until: i = null } = {}) {
|
|
829
843
|
const a = new URLSearchParams({
|
|
830
844
|
metadata_key: e,
|
|
831
845
|
metadata_value: t,
|
|
832
|
-
limit:
|
|
846
|
+
limit: n
|
|
833
847
|
});
|
|
834
848
|
for (const [c, u] of Object.entries({ since: r, until: i }))
|
|
835
849
|
u != null && a.append(c, u instanceof Date ? u.toISOString() : u);
|
|
836
|
-
return
|
|
850
|
+
return s && a.append("memory_type", s), this.api.get(`/memory/by-metadata?${a}`);
|
|
837
851
|
}
|
|
838
852
|
async getNeighbors(e) {
|
|
839
853
|
return this.api.get(`/memory/${encodeURIComponent(e)}/neighbors`);
|
|
@@ -843,19 +857,19 @@ class V {
|
|
|
843
857
|
}
|
|
844
858
|
async ingestConversation(e, {
|
|
845
859
|
sessionBoundaries: t = null,
|
|
846
|
-
conversationId:
|
|
847
|
-
sessionDates:
|
|
860
|
+
conversationId: s = null,
|
|
861
|
+
sessionDates: n = null,
|
|
848
862
|
turnsPerChunk: r = 15,
|
|
849
863
|
maxChunkChars: i = 12e3,
|
|
850
864
|
maxConcurrent: a = 4,
|
|
851
865
|
context: c = null
|
|
852
866
|
} = {}) {
|
|
853
867
|
const u = { turns: e, turns_per_chunk: r, max_chunk_chars: i, max_concurrent: a };
|
|
854
|
-
return t && (u.session_boundaries = t),
|
|
868
|
+
return t && (u.session_boundaries = t), s && (u.conversation_id = s), n && (u.session_dates = n), c !== null && (u.context = c), this.api.post("/memory/ingest/conversation", u);
|
|
855
869
|
}
|
|
856
|
-
async ingestDocument(e, { title: t = null, source:
|
|
870
|
+
async ingestDocument(e, { title: t = null, source: s = null, chunkStrategy: n = null, context: r = null } = {}) {
|
|
857
871
|
const i = { content: e };
|
|
858
|
-
return t && (i.title = t),
|
|
872
|
+
return t && (i.title = t), s && (i.source = s), n && (i.chunk_strategy = n), r !== null && (i.context = r), this.api.post("/memory/ingest/document", i);
|
|
859
873
|
}
|
|
860
874
|
/**
|
|
861
875
|
* Import a ChatGPT or Claude conversation export (DIST-CHAT-IMPORT-1).
|
|
@@ -877,38 +891,38 @@ class V {
|
|
|
877
891
|
* `warnings` — a non-empty list means something was capped, skipped, or degraded
|
|
878
892
|
* even though the call succeeded.
|
|
879
893
|
*/
|
|
880
|
-
async importChatExport(e, { sourceFormat: t = "auto", maxConversations:
|
|
881
|
-
const
|
|
882
|
-
return
|
|
894
|
+
async importChatExport(e, { sourceFormat: t = "auto", maxConversations: s = 25 } = {}) {
|
|
895
|
+
const n = new FormData();
|
|
896
|
+
return n.append("file", e, e.name || "conversations.json"), n.append("source_format", t), n.append("max_conversations", String(s)), this.api.post("/memory/import/chat-export", n);
|
|
883
897
|
}
|
|
884
898
|
/** List supported chat-export formats and how a user obtains each export. */
|
|
885
899
|
async chatExportFormats() {
|
|
886
900
|
return this.api.get("/memory/import/chat-export/formats");
|
|
887
901
|
}
|
|
888
|
-
async codeIndex(e, { repo: t = null, commit:
|
|
889
|
-
const
|
|
890
|
-
return t && (
|
|
902
|
+
async codeIndex(e, { repo: t = null, commit: s = null } = {}) {
|
|
903
|
+
const n = { path: e };
|
|
904
|
+
return t && (n.repo = t), s && (n.commit = s), this.api.post("/memory/code/index", n);
|
|
891
905
|
}
|
|
892
|
-
async codeSearch(e, { entityType: t = null, repo:
|
|
893
|
-
const i = new URLSearchParams({ query: e, limit:
|
|
894
|
-
return t && i.append("entity_type", t),
|
|
906
|
+
async codeSearch(e, { entityType: t = null, repo: s = null, limit: n = 20, semantic: r = !1 } = {}) {
|
|
907
|
+
const i = new URLSearchParams({ query: e, limit: n, semantic: r });
|
|
908
|
+
return t && i.append("entity_type", t), s && i.append("repo", s), this.api.get(`/memory/code/search?${i}`);
|
|
895
909
|
}
|
|
896
910
|
async codeContext(e, { repo: t = null } = {}) {
|
|
897
|
-
const
|
|
898
|
-
return t &&
|
|
911
|
+
const s = new URLSearchParams({ entity_name: e });
|
|
912
|
+
return t && s.append("repo", t), this.api.get(`/memory/code/context?${s}`);
|
|
899
913
|
}
|
|
900
914
|
async codeDeadCode(e) {
|
|
901
915
|
return this.api.get(`/memory/code/dead-code?repo=${encodeURIComponent(e)}`);
|
|
902
916
|
}
|
|
903
|
-
async codeDependencies(e, { direction: t = "both", repo:
|
|
904
|
-
const
|
|
905
|
-
return
|
|
917
|
+
async codeDependencies(e, { direction: t = "both", repo: s = null } = {}) {
|
|
918
|
+
const n = new URLSearchParams({ entity_name: e, direction: t });
|
|
919
|
+
return s && n.append("repo", s), this.api.get(`/memory/code/dependencies?${n}`);
|
|
906
920
|
}
|
|
907
921
|
async getPlan(e) {
|
|
908
922
|
return this.api.get(`/memory/plans/${e}`);
|
|
909
923
|
}
|
|
910
|
-
async updatePlanTask(e, { taskId: t, status:
|
|
911
|
-
return this.api.patch(`/memory/plans/${e}/task`, { task_id: t, status:
|
|
924
|
+
async updatePlanTask(e, { taskId: t, status: s }) {
|
|
925
|
+
return this.api.patch(`/memory/plans/${e}/task`, { task_id: t, status: s });
|
|
912
926
|
}
|
|
913
927
|
async completePlan(e, { graduate: t = !1 } = {}) {
|
|
914
928
|
return this.api.post(`/memory/plans/${e}/complete`, { graduate: t });
|
|
@@ -916,11 +930,11 @@ class V {
|
|
|
916
930
|
async failPlan(e, t) {
|
|
917
931
|
return this.api.post(`/memory/plans/${e}/fail`, { reason: t });
|
|
918
932
|
}
|
|
919
|
-
async link(e, t,
|
|
933
|
+
async link(e, t, s = "RELATED") {
|
|
920
934
|
return this.api.post("/memory/link", {
|
|
921
935
|
source_id: e,
|
|
922
936
|
target_id: t,
|
|
923
|
-
link_type:
|
|
937
|
+
link_type: s
|
|
924
938
|
});
|
|
925
939
|
}
|
|
926
940
|
async enrich(e, t = []) {
|
|
@@ -950,9 +964,9 @@ class V {
|
|
|
950
964
|
* @param {string} [query] - Original query that produced these results.
|
|
951
965
|
* @returns {Promise<{updated: number, edges_strengthened: number, outcome: string}>}
|
|
952
966
|
*/
|
|
953
|
-
async feedback(e, t,
|
|
954
|
-
const
|
|
955
|
-
return
|
|
967
|
+
async feedback(e, t, s = null) {
|
|
968
|
+
const n = { item_ids: e, outcome: t };
|
|
969
|
+
return s != null && (n.query = s), this.api.post("/memory/feedback", n);
|
|
956
970
|
}
|
|
957
971
|
/**
|
|
958
972
|
* Request grounding for a memory item.
|
|
@@ -960,40 +974,40 @@ class V {
|
|
|
960
974
|
* The endpoint currently returns HTTP 501 because
|
|
961
975
|
* CORE-GROUND-ROUTE-CONTRACT-1 is not implemented.
|
|
962
976
|
*/
|
|
963
|
-
async ground(e, t,
|
|
977
|
+
async ground(e, t, s = null) {
|
|
964
978
|
return this.api.post(`/memory/${encodeURIComponent(e)}/ground`, {
|
|
965
979
|
item_id: e,
|
|
966
980
|
source_url: t,
|
|
967
|
-
validation:
|
|
981
|
+
validation: s
|
|
968
982
|
});
|
|
969
983
|
}
|
|
970
984
|
async clearAll(e = !1) {
|
|
971
985
|
return this.api.delete(`/memory/clear-all?nuclear=${e}`);
|
|
972
986
|
}
|
|
973
987
|
// --- Temporal ---
|
|
974
|
-
async getHistory(e, { startTime: t = null, endTime:
|
|
975
|
-
let r = `/memory/temporal/${e}/history?limit=${
|
|
976
|
-
return t && (r += `&start_time=${t}`),
|
|
988
|
+
async getHistory(e, { startTime: t = null, endTime: s = null, limit: n = 100 } = {}) {
|
|
989
|
+
let r = `/memory/temporal/${e}/history?limit=${n}`;
|
|
990
|
+
return t && (r += `&start_time=${t}`), s && (r += `&end_time=${s}`), this.api.get(r);
|
|
977
991
|
}
|
|
978
|
-
async timeTravel(e, { query: t = null, limit:
|
|
979
|
-
let
|
|
980
|
-
return t && (
|
|
992
|
+
async timeTravel(e, { query: t = null, limit: s = 100 } = {}) {
|
|
993
|
+
let n = `/memory/temporal/at/${e}?limit=${s}`;
|
|
994
|
+
return t && (n += `&query=${encodeURIComponent(t)}`), this.api.get(n);
|
|
981
995
|
}
|
|
982
996
|
async getItemAtTime(e, t) {
|
|
983
997
|
return this.api.get(`/memory/temporal/${e}/at/${t}`);
|
|
984
998
|
}
|
|
985
|
-
async getChanges(e, { since: t = null, until:
|
|
999
|
+
async getChanges(e, { since: t = null, until: s = null, changeType: n = null } = {}) {
|
|
986
1000
|
let r = `/memory/temporal/${e}/changes`;
|
|
987
1001
|
const i = [];
|
|
988
|
-
return t && i.push(`since=${t}`),
|
|
1002
|
+
return t && i.push(`since=${t}`), s && i.push(`until=${s}`), n && i.push(`change_type=${n}`), i.length && (r += `?${i.join("&")}`), this.api.get(r);
|
|
989
1003
|
}
|
|
990
|
-
async compareVersions(e, t,
|
|
991
|
-
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${
|
|
1004
|
+
async compareVersions(e, t, s) {
|
|
1005
|
+
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${s}`);
|
|
992
1006
|
}
|
|
993
|
-
async rollback(e, { toVersion: t = null, toTime:
|
|
994
|
-
let
|
|
1007
|
+
async rollback(e, { toVersion: t = null, toTime: s = null } = {}) {
|
|
1008
|
+
let n = `/memory/temporal/${e}/rollback`;
|
|
995
1009
|
const r = [];
|
|
996
|
-
return t !== null && r.push(`to_version=${t}`),
|
|
1010
|
+
return t !== null && r.push(`to_version=${t}`), s && r.push(`to_time=${s}`), r.length && (n += `?${r.join("&")}`), this.api.post(n);
|
|
997
1011
|
}
|
|
998
1012
|
// --- Clustering ---
|
|
999
1013
|
async runClustering(e = 0.1, t = !1) {
|
|
@@ -1003,7 +1017,7 @@ class V {
|
|
|
1003
1017
|
return this.api.get("/memory/clustering/stats");
|
|
1004
1018
|
}
|
|
1005
1019
|
}
|
|
1006
|
-
class
|
|
1020
|
+
class Y {
|
|
1007
1021
|
constructor(e) {
|
|
1008
1022
|
this.api = e;
|
|
1009
1023
|
}
|
|
@@ -1025,29 +1039,29 @@ class W {
|
|
|
1025
1039
|
async create({
|
|
1026
1040
|
content: e,
|
|
1027
1041
|
decisionType: t = "inference",
|
|
1028
|
-
confidence:
|
|
1029
|
-
sourceTraceId:
|
|
1042
|
+
confidence: s = 0.8,
|
|
1043
|
+
sourceTraceId: n = null,
|
|
1030
1044
|
sourceSessionId: r = null,
|
|
1031
1045
|
evidenceIds: i = null,
|
|
1032
1046
|
domain: a = null,
|
|
1033
1047
|
tags: c = null,
|
|
1034
1048
|
rejectedAlternatives: u = null,
|
|
1035
|
-
rationale:
|
|
1036
|
-
constraints:
|
|
1049
|
+
rationale: h = null,
|
|
1050
|
+
constraints: y = null,
|
|
1037
1051
|
agentId: d = null
|
|
1038
1052
|
}) {
|
|
1039
1053
|
return this.api.post("/memory/decisions/create", {
|
|
1040
1054
|
content: e,
|
|
1041
1055
|
decision_type: t,
|
|
1042
|
-
confidence:
|
|
1043
|
-
source_trace_id:
|
|
1056
|
+
confidence: s,
|
|
1057
|
+
source_trace_id: n,
|
|
1044
1058
|
source_session_id: r,
|
|
1045
1059
|
evidence_ids: i,
|
|
1046
1060
|
domain: a,
|
|
1047
1061
|
tags: c,
|
|
1048
1062
|
rejected_alternatives: u,
|
|
1049
|
-
rationale:
|
|
1050
|
-
constraints:
|
|
1063
|
+
rationale: h,
|
|
1064
|
+
constraints: y,
|
|
1051
1065
|
agent_id: d
|
|
1052
1066
|
});
|
|
1053
1067
|
}
|
|
@@ -1112,12 +1126,12 @@ class W {
|
|
|
1112
1126
|
* @param {string[]} [params.tags]
|
|
1113
1127
|
* @param {string} [params.agentId]
|
|
1114
1128
|
*/
|
|
1115
|
-
async createPending({ content: e, requirements: t, domain:
|
|
1129
|
+
async createPending({ content: e, requirements: t, domain: s = null, tags: n = null, agentId: r = null }) {
|
|
1116
1130
|
return this.api.post("/memory/decisions/pending/create", {
|
|
1117
1131
|
content: e,
|
|
1118
1132
|
requirements: t,
|
|
1119
|
-
domain:
|
|
1120
|
-
tags:
|
|
1133
|
+
domain: s,
|
|
1134
|
+
tags: n,
|
|
1121
1135
|
agent_id: r
|
|
1122
1136
|
});
|
|
1123
1137
|
}
|
|
@@ -1128,10 +1142,10 @@ class W {
|
|
|
1128
1142
|
* @param {string} params.requirementId
|
|
1129
1143
|
* @param {string} params.memoryId
|
|
1130
1144
|
*/
|
|
1131
|
-
async resolveRequirement(e, { requirementId: t, memoryId:
|
|
1145
|
+
async resolveRequirement(e, { requirementId: t, memoryId: s }) {
|
|
1132
1146
|
return this.api.post(`/memory/decisions/pending/${e}/resolve`, {
|
|
1133
1147
|
requirement_id: t,
|
|
1134
|
-
memory_id:
|
|
1148
|
+
memory_id: s
|
|
1135
1149
|
});
|
|
1136
1150
|
}
|
|
1137
1151
|
/**
|
|
@@ -1216,8 +1230,8 @@ class W {
|
|
|
1216
1230
|
* @param {string} [options.direction='both'] - causes|effects|both
|
|
1217
1231
|
* @param {number} [options.maxDepth=3]
|
|
1218
1232
|
*/
|
|
1219
|
-
async getCausalChain(e, { direction: t = "both", maxDepth:
|
|
1220
|
-
return this.api.get(`/memory/decisions/${e}/causal-chain?direction=${t}&max_depth=${
|
|
1233
|
+
async getCausalChain(e, { direction: t = "both", maxDepth: s = 3 } = {}) {
|
|
1234
|
+
return this.api.get(`/memory/decisions/${e}/causal-chain?direction=${t}&max_depth=${s}`);
|
|
1221
1235
|
}
|
|
1222
1236
|
/**
|
|
1223
1237
|
* Find existing decisions that may conflict with this one.
|
|
@@ -1251,7 +1265,7 @@ class W {
|
|
|
1251
1265
|
});
|
|
1252
1266
|
}
|
|
1253
1267
|
}
|
|
1254
|
-
class
|
|
1268
|
+
class X {
|
|
1255
1269
|
constructor(e) {
|
|
1256
1270
|
this.api = e;
|
|
1257
1271
|
}
|
|
@@ -1269,11 +1283,11 @@ class Y {
|
|
|
1269
1283
|
* server auto-populate from scope.resolve_agent_id().
|
|
1270
1284
|
*/
|
|
1271
1285
|
async createOpinion(e, t = {}) {
|
|
1272
|
-
const
|
|
1273
|
-
return t.confidence !== void 0 && (
|
|
1286
|
+
const s = { content: e };
|
|
1287
|
+
return t.confidence !== void 0 && (s.confidence = t.confidence), t.subject !== void 0 && (s.subject = t.subject), t.subjectType !== void 0 && (s.subject_type = t.subjectType), t.disposition !== void 0 && (s.disposition = t.disposition), t.formedFrom !== void 0 && (s.formed_from = t.formedFrom), t.domain !== void 0 && (s.domain = t.domain), t.agentId !== void 0 && (s.agent_id = t.agentId), this.api.post("/memory/opinions/create", s);
|
|
1274
1288
|
}
|
|
1275
1289
|
}
|
|
1276
|
-
class
|
|
1290
|
+
class Z {
|
|
1277
1291
|
constructor(e) {
|
|
1278
1292
|
this.api = e;
|
|
1279
1293
|
}
|
|
@@ -1285,12 +1299,12 @@ class X {
|
|
|
1285
1299
|
async getNeighbors(e, t = {}) {
|
|
1286
1300
|
return this.api.get(`/memory/${encodeURIComponent(e)}/neighbors`, t);
|
|
1287
1301
|
}
|
|
1288
|
-
async addEdge(e, t,
|
|
1302
|
+
async addEdge(e, t, s, n = {}) {
|
|
1289
1303
|
return this.api.post("/memory/edge", {
|
|
1290
1304
|
source_id: e,
|
|
1291
1305
|
target_id: t,
|
|
1292
|
-
relation_type:
|
|
1293
|
-
properties:
|
|
1306
|
+
relation_type: s,
|
|
1307
|
+
properties: n
|
|
1294
1308
|
});
|
|
1295
1309
|
}
|
|
1296
1310
|
/** @param {{ signal?: AbortSignal }} [options] */
|
|
@@ -1313,8 +1327,8 @@ class X {
|
|
|
1313
1327
|
* @param {number} [maxHops=5]
|
|
1314
1328
|
* @param {{ signal?: AbortSignal }} [options]
|
|
1315
1329
|
*/
|
|
1316
|
-
async findShortestPath(e, t,
|
|
1317
|
-
return this.api.get(`/memory/graph/path?start_id=${encodeURIComponent(e)}&end_id=${encodeURIComponent(t)}&max_hops=${
|
|
1330
|
+
async findShortestPath(e, t, s = 5, n = {}) {
|
|
1331
|
+
return this.api.get(`/memory/graph/path?start_id=${encodeURIComponent(e)}&end_id=${encodeURIComponent(t)}&max_hops=${s}`, n);
|
|
1318
1332
|
}
|
|
1319
1333
|
/**
|
|
1320
1334
|
* Fetch the full knowledge graph.
|
|
@@ -1331,9 +1345,9 @@ class X {
|
|
|
1331
1345
|
* @param {string[]} nodeIds
|
|
1332
1346
|
* @param {{ includeProperties?: boolean, signal?: AbortSignal }} [options]
|
|
1333
1347
|
*/
|
|
1334
|
-
async getEdgesBulk(e, { includeProperties: t = !1, signal:
|
|
1335
|
-
const
|
|
1336
|
-
return this.api.post(`/memory/graph/edges${
|
|
1348
|
+
async getEdgesBulk(e, { includeProperties: t = !1, signal: s } = {}) {
|
|
1349
|
+
const n = t ? "?include_properties=true" : "";
|
|
1350
|
+
return this.api.post(`/memory/graph/edges${n}`, { node_ids: e }, s ? { signal: s } : {});
|
|
1337
1351
|
}
|
|
1338
1352
|
/**
|
|
1339
1353
|
* Bulk upsert graph nodes and edges, optionally replacing a node-ID prefix.
|
|
@@ -1342,9 +1356,9 @@ class X {
|
|
|
1342
1356
|
* @param {Array<Object>} [params.edges=[]] - Edges with source_id, target_id, edge_type, and properties.
|
|
1343
1357
|
* @param {string|null} [params.deletePrefix=null] - Scoped node-ID prefix to delete before writing.
|
|
1344
1358
|
*/
|
|
1345
|
-
async bulkUpsert({ nodes: e = [], edges: t = [], deletePrefix:
|
|
1346
|
-
const
|
|
1347
|
-
return
|
|
1359
|
+
async bulkUpsert({ nodes: e = [], edges: t = [], deletePrefix: s = null } = {}) {
|
|
1360
|
+
const n = { nodes: e, edges: t };
|
|
1361
|
+
return s !== null && (n.delete_prefix = s), this.api.post("/memory/graph/bulk", n);
|
|
1348
1362
|
}
|
|
1349
1363
|
/**
|
|
1350
1364
|
* Get Wikipedia grounding status for an entity node.
|
|
@@ -1422,7 +1436,7 @@ class X {
|
|
|
1422
1436
|
);
|
|
1423
1437
|
}
|
|
1424
1438
|
}
|
|
1425
|
-
class
|
|
1439
|
+
class Q {
|
|
1426
1440
|
constructor(e) {
|
|
1427
1441
|
this.api = e;
|
|
1428
1442
|
}
|
|
@@ -1430,12 +1444,12 @@ class Z {
|
|
|
1430
1444
|
const t = e ? "?include_system=true" : "";
|
|
1431
1445
|
return this.api.get(`/memory/teams${t}`);
|
|
1432
1446
|
}
|
|
1433
|
-
async create({ name: e, description: t = null, dataClassification:
|
|
1447
|
+
async create({ name: e, description: t = null, dataClassification: s = "internal", costCenter: n = null, isSystem: r = !1 }) {
|
|
1434
1448
|
const i = {
|
|
1435
1449
|
name: e,
|
|
1436
1450
|
description: t,
|
|
1437
|
-
data_classification:
|
|
1438
|
-
cost_center:
|
|
1451
|
+
data_classification: s,
|
|
1452
|
+
cost_center: n
|
|
1439
1453
|
};
|
|
1440
1454
|
return r && (i.is_system = !0), this.api.post("/memory/teams", i);
|
|
1441
1455
|
}
|
|
@@ -1451,20 +1465,49 @@ class Z {
|
|
|
1451
1465
|
async getMembers(e) {
|
|
1452
1466
|
return this.api.get(`/memory/teams/${e}/members`);
|
|
1453
1467
|
}
|
|
1454
|
-
async addMember(e, t,
|
|
1468
|
+
async addMember(e, t, s = "member") {
|
|
1455
1469
|
return this.api.post(`/memory/teams/${e}/members`, {
|
|
1456
1470
|
user_id: t,
|
|
1457
|
-
role:
|
|
1471
|
+
role: s
|
|
1458
1472
|
});
|
|
1459
1473
|
}
|
|
1460
|
-
async updateMember(e, t,
|
|
1461
|
-
return this.api.patch(`/memory/teams/${e}/members/${t}`, { role:
|
|
1474
|
+
async updateMember(e, t, s) {
|
|
1475
|
+
return this.api.patch(`/memory/teams/${e}/members/${t}`, { role: s });
|
|
1462
1476
|
}
|
|
1463
1477
|
async removeMember(e, t) {
|
|
1464
1478
|
return this.api.delete(`/memory/teams/${e}/members/${t}`);
|
|
1465
1479
|
}
|
|
1466
1480
|
}
|
|
1467
|
-
class
|
|
1481
|
+
class ee {
|
|
1482
|
+
constructor(e) {
|
|
1483
|
+
this.api = e;
|
|
1484
|
+
}
|
|
1485
|
+
async list() {
|
|
1486
|
+
return this.api.get("/memory/workspaces");
|
|
1487
|
+
}
|
|
1488
|
+
async create({ name: e, teamId: t, description: s = null }) {
|
|
1489
|
+
return this.api.post("/memory/workspaces", {
|
|
1490
|
+
name: e,
|
|
1491
|
+
description: s,
|
|
1492
|
+
team_id: t
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
async share(e, { teamId: t, permission: s }) {
|
|
1496
|
+
return this.api.post(`/memory/workspaces/${encodeURIComponent(e)}/share`, {
|
|
1497
|
+
team_id: t,
|
|
1498
|
+
permission: s
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
async revoke(e, t) {
|
|
1502
|
+
return this.api.delete(
|
|
1503
|
+
`/memory/workspaces/${encodeURIComponent(e)}/share/${encodeURIComponent(t)}`
|
|
1504
|
+
);
|
|
1505
|
+
}
|
|
1506
|
+
async listTeamWorkspaces(e) {
|
|
1507
|
+
return this.api.get(`/memory/teams/${encodeURIComponent(e)}/workspaces`);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
class te {
|
|
1468
1511
|
constructor(e) {
|
|
1469
1512
|
this.api = e;
|
|
1470
1513
|
}
|
|
@@ -1486,7 +1529,7 @@ class Q {
|
|
|
1486
1529
|
return this.api.patch("/auth/llm-keys", e);
|
|
1487
1530
|
}
|
|
1488
1531
|
}
|
|
1489
|
-
class
|
|
1532
|
+
class se {
|
|
1490
1533
|
constructor(e) {
|
|
1491
1534
|
this.api = e;
|
|
1492
1535
|
}
|
|
@@ -1512,18 +1555,18 @@ class ee {
|
|
|
1512
1555
|
});
|
|
1513
1556
|
}
|
|
1514
1557
|
}
|
|
1515
|
-
class
|
|
1558
|
+
class ne {
|
|
1516
1559
|
constructor(e) {
|
|
1517
1560
|
this.api = e;
|
|
1518
1561
|
}
|
|
1519
1562
|
async getCurrentUser() {
|
|
1520
1563
|
return this.api.get("/auth/me");
|
|
1521
1564
|
}
|
|
1522
|
-
async createAPIKey(e, t,
|
|
1565
|
+
async createAPIKey(e, t, s = null) {
|
|
1523
1566
|
return this.api.post("/memory/api-keys", {
|
|
1524
1567
|
name: e,
|
|
1525
1568
|
scopes: t,
|
|
1526
|
-
expires_in_days:
|
|
1569
|
+
expires_in_days: s
|
|
1527
1570
|
});
|
|
1528
1571
|
}
|
|
1529
1572
|
async listAPIKeys() {
|
|
@@ -1533,19 +1576,19 @@ class te {
|
|
|
1533
1576
|
return this.api.delete(`/memory/api-keys/${e}`);
|
|
1534
1577
|
}
|
|
1535
1578
|
}
|
|
1536
|
-
class
|
|
1579
|
+
class re {
|
|
1537
1580
|
constructor(e) {
|
|
1538
1581
|
this.api = e;
|
|
1539
1582
|
}
|
|
1540
1583
|
async list() {
|
|
1541
1584
|
return this.api.get("/memory/agents");
|
|
1542
1585
|
}
|
|
1543
|
-
async create({ name: e, description: t = null, agentConfig:
|
|
1586
|
+
async create({ name: e, description: t = null, agentConfig: s = {}, roles: n = ["user"] }) {
|
|
1544
1587
|
return this.api.post("/memory/agents", {
|
|
1545
1588
|
name: e,
|
|
1546
1589
|
description: t,
|
|
1547
|
-
agent_config:
|
|
1548
|
-
roles:
|
|
1590
|
+
agent_config: s,
|
|
1591
|
+
roles: n
|
|
1549
1592
|
});
|
|
1550
1593
|
}
|
|
1551
1594
|
async get(e) {
|
|
@@ -1571,9 +1614,9 @@ class ne {
|
|
|
1571
1614
|
* @param {string} domain - Domain string (e.g. "python").
|
|
1572
1615
|
* @returns {Promise<{evaluation: object|null}>}
|
|
1573
1616
|
*/
|
|
1574
|
-
async getEvaluation(e, t,
|
|
1575
|
-
const
|
|
1576
|
-
return this.api.get(`/memory/agents/${e}/evaluation${
|
|
1617
|
+
async getEvaluation(e, t, s) {
|
|
1618
|
+
const n = new URLSearchParams({ dimension: t, domain: s }).toString();
|
|
1619
|
+
return this.api.get(`/memory/agents/${e}/evaluation${n ? "?" + n : ""}`);
|
|
1577
1620
|
}
|
|
1578
1621
|
/**
|
|
1579
1622
|
* Get evaluation history for an agent on a given (dimension, domain) slot.
|
|
@@ -1587,12 +1630,12 @@ class ne {
|
|
|
1587
1630
|
* @param {number} [options.limit=20] - Maximum records to return.
|
|
1588
1631
|
* @returns {Promise<{history: object[]}>}
|
|
1589
1632
|
*/
|
|
1590
|
-
async listEvaluationHistory(e, t,
|
|
1591
|
-
const r = new URLSearchParams({ dimension: t, domain:
|
|
1633
|
+
async listEvaluationHistory(e, t, s, { limit: n = 20 } = {}) {
|
|
1634
|
+
const r = new URLSearchParams({ dimension: t, domain: s, limit: String(n) }).toString();
|
|
1592
1635
|
return this.api.get(`/memory/agents/${e}/evaluation/history${r ? "?" + r : ""}`);
|
|
1593
1636
|
}
|
|
1594
1637
|
}
|
|
1595
|
-
class
|
|
1638
|
+
class ie {
|
|
1596
1639
|
constructor(e) {
|
|
1597
1640
|
this.api = e;
|
|
1598
1641
|
}
|
|
@@ -1606,7 +1649,7 @@ class se {
|
|
|
1606
1649
|
return this.api.get("/usage/tiers");
|
|
1607
1650
|
}
|
|
1608
1651
|
}
|
|
1609
|
-
class
|
|
1652
|
+
class ae {
|
|
1610
1653
|
constructor(e) {
|
|
1611
1654
|
this.api = e;
|
|
1612
1655
|
}
|
|
@@ -1623,7 +1666,7 @@ class re {
|
|
|
1623
1666
|
return this.api.get("/memory/plugins");
|
|
1624
1667
|
}
|
|
1625
1668
|
}
|
|
1626
|
-
class
|
|
1669
|
+
class oe {
|
|
1627
1670
|
constructor(e) {
|
|
1628
1671
|
this.api = e;
|
|
1629
1672
|
}
|
|
@@ -1646,7 +1689,7 @@ class ie {
|
|
|
1646
1689
|
return this.api.get("/memory/token-usage/current");
|
|
1647
1690
|
}
|
|
1648
1691
|
}
|
|
1649
|
-
class
|
|
1692
|
+
class ce {
|
|
1650
1693
|
constructor(e) {
|
|
1651
1694
|
this.api = e;
|
|
1652
1695
|
}
|
|
@@ -1659,9 +1702,9 @@ class ae {
|
|
|
1659
1702
|
* @param {string} [options.endTime] - ISO end time
|
|
1660
1703
|
* @param {number} [options.limit=100]
|
|
1661
1704
|
*/
|
|
1662
|
-
async getHistory(e, { startTime: t = null, endTime:
|
|
1663
|
-
let r = `/memory/temporal/${e}/history?limit=${
|
|
1664
|
-
return t && (r += `&start_time=${t}`),
|
|
1705
|
+
async getHistory(e, { startTime: t = null, endTime: s = null, limit: n = 100 } = {}) {
|
|
1706
|
+
let r = `/memory/temporal/${e}/history?limit=${n}`;
|
|
1707
|
+
return t && (r += `&start_time=${t}`), s && (r += `&end_time=${s}`), this.api.get(r);
|
|
1665
1708
|
}
|
|
1666
1709
|
// === TIME-TRAVEL QUERIES ===
|
|
1667
1710
|
/**
|
|
@@ -1671,9 +1714,9 @@ class ae {
|
|
|
1671
1714
|
* @param {string} [options.query]
|
|
1672
1715
|
* @param {number} [options.limit=100]
|
|
1673
1716
|
*/
|
|
1674
|
-
async timeTravel(e, { query: t = null, limit:
|
|
1675
|
-
let
|
|
1676
|
-
return t && (
|
|
1717
|
+
async timeTravel(e, { query: t = null, limit: s = 100 } = {}) {
|
|
1718
|
+
let n = `/memory/temporal/at/${e}?limit=${s}`;
|
|
1719
|
+
return t && (n += `&query=${encodeURIComponent(t)}`), this.api.get(n);
|
|
1677
1720
|
}
|
|
1678
1721
|
/**
|
|
1679
1722
|
* Get specific item as it existed at timestamp.
|
|
@@ -1692,10 +1735,10 @@ class ae {
|
|
|
1692
1735
|
* @param {string} [options.until]
|
|
1693
1736
|
* @param {string} [options.changeType]
|
|
1694
1737
|
*/
|
|
1695
|
-
async getChanges(e, { since: t = null, until:
|
|
1738
|
+
async getChanges(e, { since: t = null, until: s = null, changeType: n = null } = {}) {
|
|
1696
1739
|
let r = `/memory/temporal/${e}/changes`;
|
|
1697
1740
|
const i = [];
|
|
1698
|
-
return t && i.push(`since=${t}`),
|
|
1741
|
+
return t && i.push(`since=${t}`), s && i.push(`until=${s}`), n && i.push(`change_type=${n}`), i.length && (r += `?${i.join("&")}`), this.api.get(r);
|
|
1699
1742
|
}
|
|
1700
1743
|
// === VERSION COMPARISON ===
|
|
1701
1744
|
/**
|
|
@@ -1704,8 +1747,8 @@ class ae {
|
|
|
1704
1747
|
* @param {number} v1
|
|
1705
1748
|
* @param {number} v2
|
|
1706
1749
|
*/
|
|
1707
|
-
async compareVersions(e, t,
|
|
1708
|
-
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${
|
|
1750
|
+
async compareVersions(e, t, s) {
|
|
1751
|
+
return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${s}`);
|
|
1709
1752
|
}
|
|
1710
1753
|
// === ROLLBACK ===
|
|
1711
1754
|
/**
|
|
@@ -1715,10 +1758,10 @@ class ae {
|
|
|
1715
1758
|
* @param {number} [options.toVersion]
|
|
1716
1759
|
* @param {string} [options.toTime]
|
|
1717
1760
|
*/
|
|
1718
|
-
async rollback(e, { toVersion: t = null, toTime:
|
|
1719
|
-
let
|
|
1761
|
+
async rollback(e, { toVersion: t = null, toTime: s = null } = {}) {
|
|
1762
|
+
let n = `/memory/temporal/${e}/rollback`;
|
|
1720
1763
|
const r = [];
|
|
1721
|
-
return t !== null && r.push(`to_version=${t}`),
|
|
1764
|
+
return t !== null && r.push(`to_version=${t}`), s && r.push(`to_time=${s}`), r.length && (n += `?${r.join("&")}`), this.api.post(n);
|
|
1722
1765
|
}
|
|
1723
1766
|
// === AUDIT TRAIL ===
|
|
1724
1767
|
/**
|
|
@@ -1730,10 +1773,10 @@ class ae {
|
|
|
1730
1773
|
* @param {string} [options.startTime]
|
|
1731
1774
|
* @param {string} [options.endTime]
|
|
1732
1775
|
*/
|
|
1733
|
-
async getAuditTrail(e, { changeType: t = null, userId:
|
|
1776
|
+
async getAuditTrail(e, { changeType: t = null, userId: s = null, startTime: n = null, endTime: r = null } = {}) {
|
|
1734
1777
|
let i = `/memory/temporal/${e}/audit`;
|
|
1735
1778
|
const a = [];
|
|
1736
|
-
return t && a.push(`change_type=${t}`),
|
|
1779
|
+
return t && a.push(`change_type=${t}`), s && a.push(`user_id=${s}`), n && a.push(`start_time=${n}`), r && a.push(`end_time=${r}`), a.length && (i += `?${a.join("&")}`), this.api.get(i);
|
|
1737
1780
|
}
|
|
1738
1781
|
// === TEMPORAL SEARCH ===
|
|
1739
1782
|
/**
|
|
@@ -1743,12 +1786,12 @@ class ae {
|
|
|
1743
1786
|
* @param {string} endTime
|
|
1744
1787
|
* @param {number} [limit=100]
|
|
1745
1788
|
*/
|
|
1746
|
-
async searchDuringRange(e, t,
|
|
1789
|
+
async searchDuringRange(e, t, s, n = 100) {
|
|
1747
1790
|
const r = new URLSearchParams({
|
|
1748
1791
|
query: e,
|
|
1749
1792
|
start_time: t,
|
|
1750
|
-
end_time:
|
|
1751
|
-
limit: String(
|
|
1793
|
+
end_time: s,
|
|
1794
|
+
limit: String(n)
|
|
1752
1795
|
}).toString();
|
|
1753
1796
|
return this.api.get(`/memory/temporal/search/during?${r}`);
|
|
1754
1797
|
}
|
|
@@ -1761,10 +1804,10 @@ class ae {
|
|
|
1761
1804
|
* @param {string} [options.reportType='HIPAA']
|
|
1762
1805
|
* @param {string[]} [options.itemIds]
|
|
1763
1806
|
*/
|
|
1764
|
-
async complianceReport(e, t, { reportType:
|
|
1765
|
-
let r = `/memory/temporal/compliance/report?start_date=${e}&end_date=${t}&report_type=${
|
|
1766
|
-
if (
|
|
1767
|
-
for (const i of
|
|
1807
|
+
async complianceReport(e, t, { reportType: s = "HIPAA", itemIds: n = null } = {}) {
|
|
1808
|
+
let r = `/memory/temporal/compliance/report?start_date=${e}&end_date=${t}&report_type=${s}`;
|
|
1809
|
+
if (n && n.length)
|
|
1810
|
+
for (const i of n)
|
|
1768
1811
|
r += `&item_ids=${encodeURIComponent(i)}`;
|
|
1769
1812
|
return this.api.get(r);
|
|
1770
1813
|
}
|
|
@@ -1792,7 +1835,7 @@ class ae {
|
|
|
1792
1835
|
return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
|
|
1793
1836
|
}
|
|
1794
1837
|
}
|
|
1795
|
-
class
|
|
1838
|
+
class ue {
|
|
1796
1839
|
constructor(e) {
|
|
1797
1840
|
this.api = e;
|
|
1798
1841
|
}
|
|
@@ -1803,11 +1846,11 @@ class oe {
|
|
|
1803
1846
|
* @param {number} [options.topK=100]
|
|
1804
1847
|
* @param {Object[]} [options.memoryItems] - Direct items to analyze
|
|
1805
1848
|
*/
|
|
1806
|
-
async runAnalysis({ query: e = "*", topK: t = 100, memoryItems:
|
|
1849
|
+
async runAnalysis({ query: e = "*", topK: t = 100, memoryItems: s = [] } = {}) {
|
|
1807
1850
|
return this.api.post("/memory/governance/run-analysis", {
|
|
1808
1851
|
query: e,
|
|
1809
1852
|
top_k: t,
|
|
1810
|
-
memory_items:
|
|
1853
|
+
memory_items: s
|
|
1811
1854
|
});
|
|
1812
1855
|
}
|
|
1813
1856
|
/**
|
|
@@ -1817,10 +1860,10 @@ class oe {
|
|
|
1817
1860
|
* @param {boolean} [options.autoFixableOnly=false]
|
|
1818
1861
|
*/
|
|
1819
1862
|
async listViolations({ severity: e = null, autoFixableOnly: t = !1 } = {}) {
|
|
1820
|
-
const
|
|
1821
|
-
e &&
|
|
1822
|
-
const
|
|
1823
|
-
return this.api.get(`/memory/governance/violations${
|
|
1863
|
+
const s = [];
|
|
1864
|
+
e && s.push(`severity=${e}`), t && s.push("auto_fixable_only=true");
|
|
1865
|
+
const n = s.length ? `?${s.join("&")}` : "";
|
|
1866
|
+
return this.api.get(`/memory/governance/violations${n}`);
|
|
1824
1867
|
}
|
|
1825
1868
|
/**
|
|
1826
1869
|
* Get a specific violation by ID.
|
|
@@ -1837,12 +1880,12 @@ class oe {
|
|
|
1837
1880
|
* @param {string} [params.rationale='']
|
|
1838
1881
|
* @param {string} [params.decidedBy='human']
|
|
1839
1882
|
*/
|
|
1840
|
-
async applyDecision({ violationId: e, action: t = "approve", rationale:
|
|
1883
|
+
async applyDecision({ violationId: e, action: t = "approve", rationale: s = "", decidedBy: n = "human" }) {
|
|
1841
1884
|
return this.api.post("/memory/governance/apply-decision", {
|
|
1842
1885
|
violation_id: e,
|
|
1843
1886
|
action: t,
|
|
1844
|
-
rationale:
|
|
1845
|
-
decided_by:
|
|
1887
|
+
rationale: s,
|
|
1888
|
+
decided_by: n
|
|
1846
1889
|
});
|
|
1847
1890
|
}
|
|
1848
1891
|
/**
|
|
@@ -1861,7 +1904,7 @@ class oe {
|
|
|
1861
1904
|
return this.api.get("/memory/governance/summary");
|
|
1862
1905
|
}
|
|
1863
1906
|
}
|
|
1864
|
-
class
|
|
1907
|
+
class le {
|
|
1865
1908
|
constructor(e) {
|
|
1866
1909
|
this.api = e;
|
|
1867
1910
|
}
|
|
@@ -1902,7 +1945,7 @@ class ce {
|
|
|
1902
1945
|
return this.api.post("/memory/evolution/reinforce/opinions");
|
|
1903
1946
|
}
|
|
1904
1947
|
}
|
|
1905
|
-
class
|
|
1948
|
+
class me {
|
|
1906
1949
|
constructor(e) {
|
|
1907
1950
|
this.api = e;
|
|
1908
1951
|
}
|
|
@@ -1914,11 +1957,11 @@ class ue {
|
|
|
1914
1957
|
* @param {string} [params.memoryType='semantic']
|
|
1915
1958
|
* @param {boolean} [params.useLlm=true]
|
|
1916
1959
|
*/
|
|
1917
|
-
async challenge({ assertion: e, memoryType: t = "semantic", useLlm:
|
|
1960
|
+
async challenge({ assertion: e, memoryType: t = "semantic", useLlm: s = !0 }) {
|
|
1918
1961
|
return this.api.post("/memory/reasoning/challenge", {
|
|
1919
1962
|
assertion: e,
|
|
1920
1963
|
memory_type: t,
|
|
1921
|
-
use_llm:
|
|
1964
|
+
use_llm: s
|
|
1922
1965
|
});
|
|
1923
1966
|
}
|
|
1924
1967
|
/**
|
|
@@ -1931,12 +1974,12 @@ class ue {
|
|
|
1931
1974
|
* @param {boolean} [params.useWikipedia=true]
|
|
1932
1975
|
* @param {boolean} [params.useLlm=true]
|
|
1933
1976
|
*/
|
|
1934
|
-
async resolve({ existingItemId: e, newFact: t, autoResolve:
|
|
1977
|
+
async resolve({ existingItemId: e, newFact: t, autoResolve: s = !0, strategy: n = null, useWikipedia: r = !0, useLlm: i = !0 }) {
|
|
1935
1978
|
return this.api.post("/memory/reasoning/resolve", {
|
|
1936
1979
|
existing_item_id: e,
|
|
1937
1980
|
new_fact: t,
|
|
1938
|
-
auto_resolve:
|
|
1939
|
-
strategy:
|
|
1981
|
+
auto_resolve: s,
|
|
1982
|
+
strategy: n,
|
|
1940
1983
|
use_wikipedia: r,
|
|
1941
1984
|
use_llm: i
|
|
1942
1985
|
});
|
|
@@ -2000,7 +2043,7 @@ class ue {
|
|
|
2000
2043
|
});
|
|
2001
2044
|
}
|
|
2002
2045
|
}
|
|
2003
|
-
class
|
|
2046
|
+
class pe {
|
|
2004
2047
|
constructor(e) {
|
|
2005
2048
|
this.api = e;
|
|
2006
2049
|
}
|
|
@@ -2012,12 +2055,12 @@ class le {
|
|
|
2012
2055
|
* @param {number} [params.minQualityScore=0.4]
|
|
2013
2056
|
* @param {boolean} [params.useLlmDetection=true]
|
|
2014
2057
|
*/
|
|
2015
|
-
async extract({ content: e, minSteps: t = 2, minQualityScore:
|
|
2058
|
+
async extract({ content: e, minSteps: t = 2, minQualityScore: s = 0.4, useLlmDetection: n = !0 }) {
|
|
2016
2059
|
return this.api.post("/memory/reasoning/traces/extract", {
|
|
2017
2060
|
content: e,
|
|
2018
2061
|
min_steps: t,
|
|
2019
|
-
min_quality_score:
|
|
2020
|
-
use_llm_detection:
|
|
2062
|
+
min_quality_score: s,
|
|
2063
|
+
use_llm_detection: n
|
|
2021
2064
|
});
|
|
2022
2065
|
}
|
|
2023
2066
|
/**
|
|
@@ -2039,11 +2082,11 @@ class le {
|
|
|
2039
2082
|
* @param {string} [params.artifactId]
|
|
2040
2083
|
* @param {number} [params.limit=10]
|
|
2041
2084
|
*/
|
|
2042
|
-
async query({ query: e, artifactId: t = null, limit:
|
|
2085
|
+
async query({ query: e, artifactId: t = null, limit: s = 10 }) {
|
|
2043
2086
|
return this.api.post("/memory/reasoning/traces/query", {
|
|
2044
2087
|
query: e,
|
|
2045
2088
|
artifact_id: t,
|
|
2046
|
-
limit:
|
|
2089
|
+
limit: s
|
|
2047
2090
|
});
|
|
2048
2091
|
}
|
|
2049
2092
|
/**
|
|
@@ -2054,7 +2097,7 @@ class le {
|
|
|
2054
2097
|
return this.api.get(`/memory/reasoning/traces/${e}`);
|
|
2055
2098
|
}
|
|
2056
2099
|
}
|
|
2057
|
-
class
|
|
2100
|
+
class he {
|
|
2058
2101
|
constructor(e) {
|
|
2059
2102
|
this.api = e;
|
|
2060
2103
|
}
|
|
@@ -2066,11 +2109,11 @@ class me {
|
|
|
2066
2109
|
* @param {Array<{docId: string, text: string}>} params.rawChunks
|
|
2067
2110
|
* @param {Object} [params.params={}]
|
|
2068
2111
|
*/
|
|
2069
|
-
async runInference({ registryId: e = "default", rawChunks: t, params:
|
|
2112
|
+
async runInference({ registryId: e = "default", rawChunks: t, params: s = {} }) {
|
|
2070
2113
|
return this.api.post("/memory/ontology/inference/run", {
|
|
2071
2114
|
registry_id: e,
|
|
2072
|
-
raw_chunks: t.map((
|
|
2073
|
-
params:
|
|
2115
|
+
raw_chunks: t.map((n) => ({ doc_id: n.docId, text: n.text })),
|
|
2116
|
+
params: s
|
|
2074
2117
|
});
|
|
2075
2118
|
}
|
|
2076
2119
|
// === REGISTRY MANAGEMENT ===
|
|
@@ -2087,11 +2130,11 @@ class me {
|
|
|
2087
2130
|
* @param {string} [params.description='']
|
|
2088
2131
|
* @param {string} [params.domain='general']
|
|
2089
2132
|
*/
|
|
2090
|
-
async createRegistry({ name: e, description: t = "", domain:
|
|
2133
|
+
async createRegistry({ name: e, description: t = "", domain: s = "general" }) {
|
|
2091
2134
|
return this.api.post("/memory/ontology/registries", {
|
|
2092
2135
|
name: e,
|
|
2093
2136
|
description: t,
|
|
2094
|
-
domain:
|
|
2137
|
+
domain: s
|
|
2095
2138
|
});
|
|
2096
2139
|
}
|
|
2097
2140
|
/**
|
|
@@ -2100,8 +2143,8 @@ class me {
|
|
|
2100
2143
|
* @param {string} [version]
|
|
2101
2144
|
*/
|
|
2102
2145
|
async getSnapshot(e, t = null) {
|
|
2103
|
-
let
|
|
2104
|
-
return t && (
|
|
2146
|
+
let s = `/memory/ontology/registry/${e}/snapshot`;
|
|
2147
|
+
return t && (s += `?version=${encodeURIComponent(t)}`), this.api.get(s);
|
|
2105
2148
|
}
|
|
2106
2149
|
/**
|
|
2107
2150
|
* Apply a changeset to create a new version of the registry.
|
|
@@ -2111,11 +2154,11 @@ class me {
|
|
|
2111
2154
|
* @param {Object} params.changeset - OntologyIR changeset
|
|
2112
2155
|
* @param {string} [params.message='']
|
|
2113
2156
|
*/
|
|
2114
|
-
async applyChangeset(e, { baseVersion: t = "", changeset:
|
|
2157
|
+
async applyChangeset(e, { baseVersion: t = "", changeset: s, message: n = "" }) {
|
|
2115
2158
|
return this.api.post(`/memory/ontology/registry/${e}/apply`, {
|
|
2116
2159
|
base_version: t,
|
|
2117
|
-
changeset:
|
|
2118
|
-
message:
|
|
2160
|
+
changeset: s,
|
|
2161
|
+
message: n
|
|
2119
2162
|
});
|
|
2120
2163
|
}
|
|
2121
2164
|
/**
|
|
@@ -2141,10 +2184,10 @@ class me {
|
|
|
2141
2184
|
* @param {string} [params.targetVersion='']
|
|
2142
2185
|
* @param {string} [params.message='']
|
|
2143
2186
|
*/
|
|
2144
|
-
async rollbackRegistry(e, { targetVersion: t = "", message:
|
|
2187
|
+
async rollbackRegistry(e, { targetVersion: t = "", message: s = "" }) {
|
|
2145
2188
|
return this.api.post(`/memory/ontology/registry/${e}/rollback`, {
|
|
2146
2189
|
target_version: t,
|
|
2147
|
-
message:
|
|
2190
|
+
message: s
|
|
2148
2191
|
});
|
|
2149
2192
|
}
|
|
2150
2193
|
/**
|
|
@@ -2153,8 +2196,8 @@ class me {
|
|
|
2153
2196
|
* @param {string} [version]
|
|
2154
2197
|
*/
|
|
2155
2198
|
async exportRegistry(e, t = null) {
|
|
2156
|
-
let
|
|
2157
|
-
return t && (
|
|
2199
|
+
let s = `/memory/ontology/registry/${e}/export`;
|
|
2200
|
+
return t && (s += `?version=${encodeURIComponent(t)}`), this.api.get(s);
|
|
2158
2201
|
}
|
|
2159
2202
|
/**
|
|
2160
2203
|
* Import data into a registry.
|
|
@@ -2163,10 +2206,10 @@ class me {
|
|
|
2163
2206
|
* @param {Object} params.data - Complete ontology data to import
|
|
2164
2207
|
* @param {string} [params.message='']
|
|
2165
2208
|
*/
|
|
2166
|
-
async importRegistry(e, { data: t, message:
|
|
2209
|
+
async importRegistry(e, { data: t, message: s = "" }) {
|
|
2167
2210
|
return this.api.post(`/memory/ontology/registry/${e}/import`, {
|
|
2168
2211
|
data: t,
|
|
2169
|
-
message:
|
|
2212
|
+
message: s
|
|
2170
2213
|
});
|
|
2171
2214
|
}
|
|
2172
2215
|
// === ENRICHMENT & GROUNDING ===
|
|
@@ -2195,11 +2238,11 @@ class me {
|
|
|
2195
2238
|
* @param {string} params.itemId
|
|
2196
2239
|
* @param {string[]} params.candidates
|
|
2197
2240
|
*/
|
|
2198
|
-
async runGrounding({ grounder: e = "wikipedia", itemId: t, candidates:
|
|
2241
|
+
async runGrounding({ grounder: e = "wikipedia", itemId: t, candidates: s }) {
|
|
2199
2242
|
return this.api.post("/memory/ontology/grounding/run", {
|
|
2200
2243
|
grounder: e,
|
|
2201
2244
|
item_id: t,
|
|
2202
|
-
candidates:
|
|
2245
|
+
candidates: s
|
|
2203
2246
|
});
|
|
2204
2247
|
}
|
|
2205
2248
|
// === TEMPLATES ===
|
|
@@ -2235,11 +2278,11 @@ class me {
|
|
|
2235
2278
|
* @param {string} params.name
|
|
2236
2279
|
* @param {string} [params.description='']
|
|
2237
2280
|
*/
|
|
2238
|
-
async saveAsTemplate({ registryId: e, name: t, description:
|
|
2281
|
+
async saveAsTemplate({ registryId: e, name: t, description: s = "" }) {
|
|
2239
2282
|
return this.api.post("/memory/ontology/templates", {
|
|
2240
2283
|
registry_id: e,
|
|
2241
2284
|
name: t,
|
|
2242
|
-
description:
|
|
2285
|
+
description: s
|
|
2243
2286
|
});
|
|
2244
2287
|
}
|
|
2245
2288
|
/**
|
|
@@ -2264,12 +2307,12 @@ class me {
|
|
|
2264
2307
|
* @param {number} [params.confidence=0.9]
|
|
2265
2308
|
* @param {boolean} [params.isGlobal=false]
|
|
2266
2309
|
*/
|
|
2267
|
-
async createPattern({ name: e, entityType: t, confidence:
|
|
2310
|
+
async createPattern({ name: e, entityType: t, confidence: s = 0.9, isGlobal: n = !1 }) {
|
|
2268
2311
|
return this.api.post("/memory/ontology/patterns", {
|
|
2269
2312
|
name: e,
|
|
2270
2313
|
entity_type: t,
|
|
2271
|
-
confidence:
|
|
2272
|
-
is_global:
|
|
2314
|
+
confidence: s,
|
|
2315
|
+
is_global: n
|
|
2273
2316
|
});
|
|
2274
2317
|
}
|
|
2275
2318
|
/**
|
|
@@ -2308,10 +2351,10 @@ class me {
|
|
|
2308
2351
|
* @param {string} params.baseRegistryId
|
|
2309
2352
|
* @param {string} [params.pinnedVersion]
|
|
2310
2353
|
*/
|
|
2311
|
-
async subscribe(e, { baseRegistryId: t, pinnedVersion:
|
|
2354
|
+
async subscribe(e, { baseRegistryId: t, pinnedVersion: s = null }) {
|
|
2312
2355
|
return this.api.post(`/memory/ontology/registry/${e}/subscribe`, {
|
|
2313
2356
|
base_registry_id: t,
|
|
2314
|
-
pinned_version:
|
|
2357
|
+
pinned_version: s
|
|
2315
2358
|
});
|
|
2316
2359
|
}
|
|
2317
2360
|
/**
|
|
@@ -2429,9 +2472,9 @@ class me {
|
|
|
2429
2472
|
* @param {string} [options.kind] missing_in_graph | missing_in_registry | name_conflict_unresolvable
|
|
2430
2473
|
* @param {number} [options.limit=50]
|
|
2431
2474
|
*/
|
|
2432
|
-
async listHitl({ status: e = "open", kind: t = null, limit:
|
|
2433
|
-
const
|
|
2434
|
-
return t &&
|
|
2475
|
+
async listHitl({ status: e = "open", kind: t = null, limit: s = 50 } = {}) {
|
|
2476
|
+
const n = new URLSearchParams({ status: e, limit: String(s) });
|
|
2477
|
+
return t && n.set("kind", t), this.api.get(`/memory/ontology/hitl?${n.toString()}`);
|
|
2435
2478
|
}
|
|
2436
2479
|
/**
|
|
2437
2480
|
* Resolve one ontology HITL queue item (open -> resolved).
|
|
@@ -2440,8 +2483,8 @@ class me {
|
|
|
2440
2483
|
* @param {('accepted'|'dismissed'|'deferred')} body.action
|
|
2441
2484
|
* @param {string} [body.note]
|
|
2442
2485
|
*/
|
|
2443
|
-
async resolveHitl(e, { action: t, note:
|
|
2444
|
-
return this.api.post(`/memory/ontology/hitl/${e}/resolve`, { action: t, note:
|
|
2486
|
+
async resolveHitl(e, { action: t, note: s = null }) {
|
|
2487
|
+
return this.api.post(`/memory/ontology/hitl/${e}/resolve`, { action: t, note: s });
|
|
2445
2488
|
}
|
|
2446
2489
|
// --- ONTO-CRUD-1 read / audit / migration surface -------------------------
|
|
2447
2490
|
/**
|
|
@@ -2455,9 +2498,9 @@ class me {
|
|
|
2455
2498
|
* @param {number} [options.limit=100]
|
|
2456
2499
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2457
2500
|
*/
|
|
2458
|
-
async listTypes({ tier: e, layer: t, packId:
|
|
2501
|
+
async listTypes({ tier: e, layer: t, packId: s, hasIri: n, kind: r, limit: i = 100, cursor: a } = {}) {
|
|
2459
2502
|
const c = { limit: String(i) };
|
|
2460
|
-
e !== void 0 && (c.tier = e), t !== void 0 && (c.layer = t),
|
|
2503
|
+
e !== void 0 && (c.tier = e), t !== void 0 && (c.layer = t), s !== void 0 && (c.pack_id = s), n !== void 0 && (c.has_iri = String(n)), r !== void 0 && (c.kind = r), a !== void 0 && (c.cursor = a);
|
|
2461
2504
|
const u = new URLSearchParams(c).toString();
|
|
2462
2505
|
return this.api.get(`/memory/ontology/types${u ? "?" + u : ""}`);
|
|
2463
2506
|
}
|
|
@@ -2492,22 +2535,22 @@ class me {
|
|
|
2492
2535
|
*/
|
|
2493
2536
|
async declareType(e, {
|
|
2494
2537
|
kind: t = "entity",
|
|
2495
|
-
propertiesSchema:
|
|
2496
|
-
requiredProperties:
|
|
2538
|
+
propertiesSchema: s,
|
|
2539
|
+
requiredProperties: n,
|
|
2497
2540
|
storageStrategy: r,
|
|
2498
2541
|
storageSearchable: i,
|
|
2499
2542
|
iri: a,
|
|
2500
2543
|
wikidataQid: c,
|
|
2501
2544
|
displayName: u,
|
|
2502
|
-
definition:
|
|
2503
|
-
description:
|
|
2545
|
+
definition: h,
|
|
2546
|
+
description: y,
|
|
2504
2547
|
aliases: d,
|
|
2505
2548
|
examples: $,
|
|
2506
2549
|
parentTypes: k,
|
|
2507
2550
|
tier: g = "confirmed"
|
|
2508
2551
|
} = {}) {
|
|
2509
|
-
const
|
|
2510
|
-
return
|
|
2552
|
+
const p = { name: e, kind: t, tier: g };
|
|
2553
|
+
return s !== void 0 && (p.properties_schema = s), n !== void 0 && (p.required_properties = n), r !== void 0 && (p.storage_strategy = r), i !== void 0 && (p.storage_searchable = i), a !== void 0 && (p.iri = a), c !== void 0 && (p.wikidata_qid = c), u !== void 0 && (p.display_name = u), h !== void 0 && (p.definition = h), y !== void 0 && (p.description = y), d !== void 0 && (p.aliases = d), $ !== void 0 && (p.examples = $), k !== void 0 && (p.parent_types = k), this.api.post("/memory/ontology/types", p);
|
|
2511
2554
|
}
|
|
2512
2555
|
/**
|
|
2513
2556
|
* Declare an ontology relation (CORE-MEMTYPE-DECLARE-1; declare-only in P1).
|
|
@@ -2538,26 +2581,26 @@ class me {
|
|
|
2538
2581
|
*/
|
|
2539
2582
|
async declareRelation(e, {
|
|
2540
2583
|
domain: t,
|
|
2541
|
-
range:
|
|
2542
|
-
inverseOf:
|
|
2584
|
+
range: s,
|
|
2585
|
+
inverseOf: n,
|
|
2543
2586
|
cardinality: r,
|
|
2544
2587
|
temporal: i,
|
|
2545
2588
|
propertiesSchema: a,
|
|
2546
2589
|
transitive: c,
|
|
2547
2590
|
symmetric: u,
|
|
2548
|
-
reflexive:
|
|
2549
|
-
parentRelations:
|
|
2591
|
+
reflexive: h,
|
|
2592
|
+
parentRelations: y,
|
|
2550
2593
|
iri: d,
|
|
2551
2594
|
wikidataPid: $,
|
|
2552
2595
|
displayName: k,
|
|
2553
2596
|
definition: g,
|
|
2554
|
-
description:
|
|
2555
|
-
aliases:
|
|
2597
|
+
description: p,
|
|
2598
|
+
aliases: b,
|
|
2556
2599
|
examples: R,
|
|
2557
|
-
tier:
|
|
2600
|
+
tier: C = "confirmed"
|
|
2558
2601
|
} = {}) {
|
|
2559
|
-
const m = { name: e, tier:
|
|
2560
|
-
return t !== void 0 && (m.domain = t),
|
|
2602
|
+
const m = { name: e, tier: C };
|
|
2603
|
+
return t !== void 0 && (m.domain = t), s !== void 0 && (m.range = s), n !== void 0 && (m.inverse_of = n), r !== void 0 && (m.cardinality = r), i !== void 0 && (m.temporal = i), a !== void 0 && (m.properties_schema = a), c !== void 0 && (m.transitive = c), u !== void 0 && (m.symmetric = u), h !== void 0 && (m.reflexive = h), y !== void 0 && (m.parent_relations = y), d !== void 0 && (m.iri = d), $ !== void 0 && (m.wikidata_pid = $), k !== void 0 && (m.display_name = k), g !== void 0 && (m.definition = g), p !== void 0 && (m.description = p), b !== void 0 && (m.aliases = b), R !== void 0 && (m.examples = R), this.api.post("/memory/ontology/relations", m);
|
|
2561
2604
|
}
|
|
2562
2605
|
/**
|
|
2563
2606
|
* List ontology relation types, keyset-paginated. Mirror of `listTypes`.
|
|
@@ -2569,9 +2612,9 @@ class me {
|
|
|
2569
2612
|
* @param {number} [options.limit=100]
|
|
2570
2613
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2571
2614
|
*/
|
|
2572
|
-
async listRelations({ tier: e, layer: t, packId:
|
|
2615
|
+
async listRelations({ tier: e, layer: t, packId: s, hasIri: n, limit: r = 100, cursor: i } = {}) {
|
|
2573
2616
|
const a = { limit: String(r) };
|
|
2574
|
-
e !== void 0 && (a.tier = e), t !== void 0 && (a.layer = t),
|
|
2617
|
+
e !== void 0 && (a.tier = e), t !== void 0 && (a.layer = t), s !== void 0 && (a.pack_id = s), n !== void 0 && (a.has_iri = String(n)), i !== void 0 && (a.cursor = i);
|
|
2575
2618
|
const c = new URLSearchParams(a).toString();
|
|
2576
2619
|
return this.api.get(`/memory/ontology/relations${c ? "?" + c : ""}`);
|
|
2577
2620
|
}
|
|
@@ -2598,9 +2641,9 @@ class me {
|
|
|
2598
2641
|
* @param {string} [options.until] full ISO-8601 upper bound (inclusive)
|
|
2599
2642
|
* @param {number} [options.limit=200]
|
|
2600
2643
|
*/
|
|
2601
|
-
async listAudit({ actor: e, action: t, since:
|
|
2644
|
+
async listAudit({ actor: e, action: t, since: s, until: n, limit: r = 200 } = {}) {
|
|
2602
2645
|
const i = { limit: String(r) };
|
|
2603
|
-
e !== void 0 && (i.actor = e), t !== void 0 && (i.action = t),
|
|
2646
|
+
e !== void 0 && (i.actor = e), t !== void 0 && (i.action = t), s !== void 0 && (i.since = s), n !== void 0 && (i.until = n);
|
|
2604
2647
|
const a = new URLSearchParams(i).toString();
|
|
2605
2648
|
return this.api.get(`/memory/ontology/audit${a ? "?" + a : ""}`);
|
|
2606
2649
|
}
|
|
@@ -2625,10 +2668,10 @@ class me {
|
|
|
2625
2668
|
* @param {string} [options.packVersion] scope to one installed version; omit for all
|
|
2626
2669
|
*/
|
|
2627
2670
|
async getPackAudit(e, { packVersion: t = null } = {}) {
|
|
2628
|
-
const
|
|
2629
|
-
t !== null && (
|
|
2630
|
-
const
|
|
2631
|
-
return this.api.get(`/memory/ontology/packs/${encodeURIComponent(e)}/audit${
|
|
2671
|
+
const s = {};
|
|
2672
|
+
t !== null && (s.pack_version = t);
|
|
2673
|
+
const n = new URLSearchParams(s).toString();
|
|
2674
|
+
return this.api.get(`/memory/ontology/packs/${encodeURIComponent(e)}/audit${n ? "?" + n : ""}`);
|
|
2632
2675
|
}
|
|
2633
2676
|
/**
|
|
2634
2677
|
* Reclassify every instance of `fromId` onto `toId`. Both types stay live.
|
|
@@ -2645,8 +2688,8 @@ class me {
|
|
|
2645
2688
|
* defaults, so an entity migration returns them empty/zero rather than omitting
|
|
2646
2689
|
* them — callers never branch on kind to read a response.
|
|
2647
2690
|
*/
|
|
2648
|
-
async migrateTypeInstances(e, t, { reason:
|
|
2649
|
-
const i = { reason:
|
|
2691
|
+
async migrateTypeInstances(e, t, { reason: s, batchSize: n = 500, onViolation: r = "refuse" }) {
|
|
2692
|
+
const i = { reason: s, batch_size: n };
|
|
2650
2693
|
return r !== "refuse" && (i.on_violation = r), this.api.post(
|
|
2651
2694
|
`/memory/ontology/types/${encodeURIComponent(e)}/migrate-to/${encodeURIComponent(t)}`,
|
|
2652
2695
|
i
|
|
@@ -2675,9 +2718,9 @@ class me {
|
|
|
2675
2718
|
* @param {number} [options.limit=100]
|
|
2676
2719
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2677
2720
|
*/
|
|
2678
|
-
async listReviewQueue({ tier: e, assignee: t, source:
|
|
2679
|
-
const i = { limit: String(
|
|
2680
|
-
e !== void 0 && (i.tier = e), t !== void 0 && (i.assignee = t),
|
|
2721
|
+
async listReviewQueue({ tier: e, assignee: t, source: s, limit: n = 100, cursor: r } = {}) {
|
|
2722
|
+
const i = { limit: String(n) };
|
|
2723
|
+
e !== void 0 && (i.tier = e), t !== void 0 && (i.assignee = t), s !== void 0 && (i.source = s), r !== void 0 && (i.cursor = r);
|
|
2681
2724
|
const a = new URLSearchParams(i).toString();
|
|
2682
2725
|
return this.api.get(`/memory/ontology/queue${a ? "?" + a : ""}`);
|
|
2683
2726
|
}
|
|
@@ -2688,8 +2731,8 @@ class me {
|
|
|
2688
2731
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2689
2732
|
*/
|
|
2690
2733
|
async approveReviewType(e, { expectedTier: t } = {}) {
|
|
2691
|
-
const
|
|
2692
|
-
return t !== void 0 && (
|
|
2734
|
+
const s = {};
|
|
2735
|
+
return t !== void 0 && (s.expected_tier = t), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/approve`, s);
|
|
2693
2736
|
}
|
|
2694
2737
|
/**
|
|
2695
2738
|
* Reject one ontology review type.
|
|
@@ -2698,8 +2741,8 @@ class me {
|
|
|
2698
2741
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2699
2742
|
*/
|
|
2700
2743
|
async rejectReviewType(e, { expectedTier: t } = {}) {
|
|
2701
|
-
const
|
|
2702
|
-
return t !== void 0 && (
|
|
2744
|
+
const s = {};
|
|
2745
|
+
return t !== void 0 && (s.expected_tier = t), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/reject`, s);
|
|
2703
2746
|
}
|
|
2704
2747
|
/**
|
|
2705
2748
|
* Merge one ontology review type into another type.
|
|
@@ -2708,9 +2751,9 @@ class me {
|
|
|
2708
2751
|
* @param {Object} [options]
|
|
2709
2752
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2710
2753
|
*/
|
|
2711
|
-
async mergeReviewType(e, t, { expectedTier:
|
|
2712
|
-
const
|
|
2713
|
-
return
|
|
2754
|
+
async mergeReviewType(e, t, { expectedTier: s } = {}) {
|
|
2755
|
+
const n = { into_id: t };
|
|
2756
|
+
return s !== void 0 && (n.expected_tier = s), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/merge`, n);
|
|
2714
2757
|
}
|
|
2715
2758
|
/**
|
|
2716
2759
|
* Edit and promote one ontology review type.
|
|
@@ -2719,9 +2762,9 @@ class me {
|
|
|
2719
2762
|
* @param {Object} [options]
|
|
2720
2763
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2721
2764
|
*/
|
|
2722
|
-
async editPromoteReviewType(e, t, { expectedTier:
|
|
2723
|
-
const
|
|
2724
|
-
return
|
|
2765
|
+
async editPromoteReviewType(e, t, { expectedTier: s } = {}) {
|
|
2766
|
+
const n = { edits: t };
|
|
2767
|
+
return s !== void 0 && (n.expected_tier = s), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/edit-promote`, n);
|
|
2725
2768
|
}
|
|
2726
2769
|
/**
|
|
2727
2770
|
* Assign or clear the reviewer for one ontology review type.
|
|
@@ -2739,12 +2782,12 @@ class me {
|
|
|
2739
2782
|
* @param {Object} [options.params] action-specific params
|
|
2740
2783
|
* @param {string} [options.expectedTier] optional optimistic tier precondition
|
|
2741
2784
|
*/
|
|
2742
|
-
async bulkReviewAction(e, t, { params:
|
|
2743
|
-
const r = { action: e, ids: t, params:
|
|
2744
|
-
return
|
|
2785
|
+
async bulkReviewAction(e, t, { params: s, expectedTier: n } = {}) {
|
|
2786
|
+
const r = { action: e, ids: t, params: s === void 0 ? {} : s };
|
|
2787
|
+
return n !== void 0 && (r.expected_tier = n), this.api.post("/memory/ontology/queue/bulk", r);
|
|
2745
2788
|
}
|
|
2746
2789
|
}
|
|
2747
|
-
class
|
|
2790
|
+
class ye {
|
|
2748
2791
|
constructor(e) {
|
|
2749
2792
|
this.api = e;
|
|
2750
2793
|
}
|
|
@@ -2768,12 +2811,12 @@ class he {
|
|
|
2768
2811
|
* @param {boolean} [options.sentimentAnalysis]
|
|
2769
2812
|
* @param {boolean} [options.topicAnalysis]
|
|
2770
2813
|
*/
|
|
2771
|
-
async detectBias({ protectedAttributes: e = null, sentimentAnalysis: t = null, topicAnalysis:
|
|
2772
|
-
const
|
|
2773
|
-
return e !== null && (
|
|
2814
|
+
async detectBias({ protectedAttributes: e = null, sentimentAnalysis: t = null, topicAnalysis: s = null } = {}) {
|
|
2815
|
+
const n = {};
|
|
2816
|
+
return e !== null && (n.protected_attributes = e), t !== null && (n.sentiment_analysis = t), s !== null && (n.topic_analysis = s), this.api.post("/memory/analytics/bias", n);
|
|
2774
2817
|
}
|
|
2775
2818
|
}
|
|
2776
|
-
class
|
|
2819
|
+
class de {
|
|
2777
2820
|
constructor(e) {
|
|
2778
2821
|
this.api = e;
|
|
2779
2822
|
}
|
|
@@ -2809,7 +2852,7 @@ class ye {
|
|
|
2809
2852
|
return this.api.get("/memory/inference/rules");
|
|
2810
2853
|
}
|
|
2811
2854
|
}
|
|
2812
|
-
class
|
|
2855
|
+
class ge {
|
|
2813
2856
|
constructor(e) {
|
|
2814
2857
|
this.api = e;
|
|
2815
2858
|
}
|
|
@@ -2856,8 +2899,8 @@ class pe {
|
|
|
2856
2899
|
* @param {string} [runId]
|
|
2857
2900
|
*/
|
|
2858
2901
|
async getState(e, t = null) {
|
|
2859
|
-
let
|
|
2860
|
-
return t && (
|
|
2902
|
+
let s = `/memory/pipeline/${e}/state`;
|
|
2903
|
+
return t && (s += `?run_id=${encodeURIComponent(t)}`), this.api.get(s);
|
|
2861
2904
|
}
|
|
2862
2905
|
/**
|
|
2863
2906
|
* Reset a pipeline, clearing its state.
|
|
@@ -2888,11 +2931,11 @@ class pe {
|
|
|
2888
2931
|
* @param {string} [params.description='']
|
|
2889
2932
|
* @param {Object} params.config
|
|
2890
2933
|
*/
|
|
2891
|
-
async createConfig({ name: e, description: t = "", config:
|
|
2934
|
+
async createConfig({ name: e, description: t = "", config: s }) {
|
|
2892
2935
|
return this.api.post("/memory/pipeline/configs", {
|
|
2893
2936
|
name: e,
|
|
2894
2937
|
description: t,
|
|
2895
|
-
config:
|
|
2938
|
+
config: s
|
|
2896
2939
|
});
|
|
2897
2940
|
}
|
|
2898
2941
|
/**
|
|
@@ -2910,11 +2953,11 @@ class pe {
|
|
|
2910
2953
|
* @param {string} [params.description='']
|
|
2911
2954
|
* @param {Object} [params.config={}]
|
|
2912
2955
|
*/
|
|
2913
|
-
async updateConfig(e, { name: t = "", description:
|
|
2956
|
+
async updateConfig(e, { name: t = "", description: s = "", config: n = {} }) {
|
|
2914
2957
|
return this.api.patch(`/memory/pipeline/configs/${e}`, {
|
|
2915
2958
|
name: t,
|
|
2916
|
-
description:
|
|
2917
|
-
config:
|
|
2959
|
+
description: s,
|
|
2960
|
+
config: n
|
|
2918
2961
|
});
|
|
2919
2962
|
}
|
|
2920
2963
|
/**
|
|
@@ -2925,7 +2968,7 @@ class pe {
|
|
|
2925
2968
|
return this.api.delete(`/memory/pipeline/configs/${e}`);
|
|
2926
2969
|
}
|
|
2927
2970
|
}
|
|
2928
|
-
class
|
|
2971
|
+
class fe {
|
|
2929
2972
|
constructor(e) {
|
|
2930
2973
|
this.api = e;
|
|
2931
2974
|
}
|
|
@@ -2936,11 +2979,11 @@ class de {
|
|
|
2936
2979
|
* @param {Object} params.payload
|
|
2937
2980
|
* @param {Object} [params.metadata={}]
|
|
2938
2981
|
*/
|
|
2939
|
-
async store({ conversationId: e, payload: t, metadata:
|
|
2982
|
+
async store({ conversationId: e, payload: t, metadata: s = {} }) {
|
|
2940
2983
|
return this.api.post("/memory/archive/store", {
|
|
2941
2984
|
conversation_id: e,
|
|
2942
2985
|
payload: t,
|
|
2943
|
-
metadata:
|
|
2986
|
+
metadata: s
|
|
2944
2987
|
});
|
|
2945
2988
|
}
|
|
2946
2989
|
/**
|
|
@@ -2951,7 +2994,7 @@ class de {
|
|
|
2951
2994
|
return this.api.get(`/memory/archive/${e}`);
|
|
2952
2995
|
}
|
|
2953
2996
|
}
|
|
2954
|
-
class
|
|
2997
|
+
class _e {
|
|
2955
2998
|
constructor(e) {
|
|
2956
2999
|
this.api = e;
|
|
2957
3000
|
}
|
|
@@ -3011,8 +3054,8 @@ class ge {
|
|
|
3011
3054
|
* @param {number} [options.maxDistance=3]
|
|
3012
3055
|
* @param {number} [options.minSurprise=0.5]
|
|
3013
3056
|
*/
|
|
3014
|
-
async getDiscoveries(e, { maxDistance: t = 3, minSurprise:
|
|
3015
|
-
return this.api.get(`/memory/zettel/${e}/discoveries?max_distance=${t}&min_surprise=${
|
|
3057
|
+
async getDiscoveries(e, { maxDistance: t = 3, minSurprise: s = 0.5 } = {}) {
|
|
3058
|
+
return this.api.get(`/memory/zettel/${e}/discoveries?max_distance=${t}&min_surprise=${s}`);
|
|
3016
3059
|
}
|
|
3017
3060
|
/**
|
|
3018
3061
|
* Find paths between two notes.
|
|
@@ -3020,8 +3063,8 @@ class ge {
|
|
|
3020
3063
|
* @param {string} targetId
|
|
3021
3064
|
* @param {number} [maxPaths=5]
|
|
3022
3065
|
*/
|
|
3023
|
-
async getPath(e, t,
|
|
3024
|
-
return this.api.get(`/memory/zettel/${e}/path/${t}?max_paths=${
|
|
3066
|
+
async getPath(e, t, s = 5) {
|
|
3067
|
+
return this.api.get(`/memory/zettel/${e}/path/${t}?max_paths=${s}`);
|
|
3025
3068
|
}
|
|
3026
3069
|
// === WIKILINK SUPPORT ===
|
|
3027
3070
|
/**
|
|
@@ -3047,8 +3090,8 @@ class ge {
|
|
|
3047
3090
|
* @param {number} [options.depth=2]
|
|
3048
3091
|
* @param {boolean} [options.includeMetadata=true]
|
|
3049
3092
|
*/
|
|
3050
|
-
async getSubgraph(e, { depth: t = 2, includeMetadata:
|
|
3051
|
-
return this.api.get(`/memory/zettel/${e}/graph?depth=${t}&include_metadata=${
|
|
3093
|
+
async getSubgraph(e, { depth: t = 2, includeMetadata: s = !0 } = {}) {
|
|
3094
|
+
return this.api.get(`/memory/zettel/${e}/graph?depth=${t}&include_metadata=${s}`);
|
|
3052
3095
|
}
|
|
3053
3096
|
// === ADDITIONAL DISCOVERY ===
|
|
3054
3097
|
/**
|
|
@@ -3089,8 +3132,8 @@ class ge {
|
|
|
3089
3132
|
* @param {string} value
|
|
3090
3133
|
* @param {number} [limit=100]
|
|
3091
3134
|
*/
|
|
3092
|
-
async findByProperty(e, t,
|
|
3093
|
-
return this.api.get(`/memory/zettel/by-property?key=${encodeURIComponent(e)}&value=${encodeURIComponent(t)}&limit=${
|
|
3135
|
+
async findByProperty(e, t, s = 100) {
|
|
3136
|
+
return this.api.get(`/memory/zettel/by-property?key=${encodeURIComponent(e)}&value=${encodeURIComponent(t)}&limit=${s}`);
|
|
3094
3137
|
}
|
|
3095
3138
|
/**
|
|
3096
3139
|
* Find notes mentioning an entity.
|
|
@@ -3106,11 +3149,11 @@ class ge {
|
|
|
3106
3149
|
* @param {string} relationType
|
|
3107
3150
|
* @param {number} [limit=100]
|
|
3108
3151
|
*/
|
|
3109
|
-
async queryByRelation(e, t,
|
|
3110
|
-
return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${
|
|
3152
|
+
async queryByRelation(e, t, s = 100) {
|
|
3153
|
+
return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${s}`);
|
|
3111
3154
|
}
|
|
3112
3155
|
}
|
|
3113
|
-
class
|
|
3156
|
+
class $e {
|
|
3114
3157
|
constructor(e) {
|
|
3115
3158
|
this.api = e;
|
|
3116
3159
|
}
|
|
@@ -3125,9 +3168,9 @@ class fe {
|
|
|
3125
3168
|
*/
|
|
3126
3169
|
async list(e = {}) {
|
|
3127
3170
|
const t = Object.fromEntries(
|
|
3128
|
-
Object.entries(e).filter(([,
|
|
3129
|
-
),
|
|
3130
|
-
return this.api.get(`/memory/procedures/matches${
|
|
3171
|
+
Object.entries(e).filter(([, n]) => n != null)
|
|
3172
|
+
), s = new URLSearchParams(t).toString();
|
|
3173
|
+
return this.api.get(`/memory/procedures/matches${s ? "?" + s : ""}`);
|
|
3131
3174
|
}
|
|
3132
3175
|
/**
|
|
3133
3176
|
* Submit feedback for a procedure match.
|
|
@@ -3135,9 +3178,9 @@ class fe {
|
|
|
3135
3178
|
* @param {string} feedback - One of "success", "failure", "neutral"
|
|
3136
3179
|
* @param {string} [note] - Optional explanation
|
|
3137
3180
|
*/
|
|
3138
|
-
async submitFeedback(e, t,
|
|
3139
|
-
const
|
|
3140
|
-
return
|
|
3181
|
+
async submitFeedback(e, t, s = null) {
|
|
3182
|
+
const n = { feedback: t };
|
|
3183
|
+
return s && (n.note = s), this.api.post(`/memory/procedures/matches/${e}/feedback`, n);
|
|
3141
3184
|
}
|
|
3142
3185
|
/**
|
|
3143
3186
|
* Get aggregated procedure match statistics.
|
|
@@ -3146,7 +3189,7 @@ class fe {
|
|
|
3146
3189
|
return this.api.get("/memory/procedures/matches/stats");
|
|
3147
3190
|
}
|
|
3148
3191
|
}
|
|
3149
|
-
class
|
|
3192
|
+
class ke {
|
|
3150
3193
|
constructor(e) {
|
|
3151
3194
|
this.api = e;
|
|
3152
3195
|
}
|
|
@@ -3161,9 +3204,9 @@ class _e {
|
|
|
3161
3204
|
*/
|
|
3162
3205
|
async list(e = {}) {
|
|
3163
3206
|
const t = Object.fromEntries(
|
|
3164
|
-
Object.entries(e).filter(([,
|
|
3165
|
-
),
|
|
3166
|
-
return this.api.get(`/memory/procedures/candidates${
|
|
3207
|
+
Object.entries(e).filter(([, n]) => n != null)
|
|
3208
|
+
), s = new URLSearchParams(t).toString();
|
|
3209
|
+
return this.api.get(`/memory/procedures/candidates${s ? "?" + s : ""}`);
|
|
3167
3210
|
}
|
|
3168
3211
|
/**
|
|
3169
3212
|
* Promote a candidate cluster to a new procedure.
|
|
@@ -3177,14 +3220,14 @@ class _e {
|
|
|
3177
3220
|
* @returns {Promise<Object>} Response with procedure_id and status
|
|
3178
3221
|
*/
|
|
3179
3222
|
async promote(e, t = {}) {
|
|
3180
|
-
const
|
|
3223
|
+
const s = {
|
|
3181
3224
|
name: t.name ?? null,
|
|
3182
3225
|
description: t.description ?? null,
|
|
3183
3226
|
procedure_type: t.procedure_type ?? "extraction",
|
|
3184
3227
|
preferred_profile: t.preferred_profile ?? "quick_extract",
|
|
3185
3228
|
remove_working_items: t.remove_working_items ?? !1
|
|
3186
3229
|
};
|
|
3187
|
-
return this.api.post(`/memory/procedures/candidates/${e}/promote`,
|
|
3230
|
+
return this.api.post(`/memory/procedures/candidates/${e}/promote`, s);
|
|
3188
3231
|
}
|
|
3189
3232
|
/**
|
|
3190
3233
|
* Dismiss a candidate cluster from future recommendations.
|
|
@@ -3195,7 +3238,7 @@ class _e {
|
|
|
3195
3238
|
return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
|
|
3196
3239
|
}
|
|
3197
3240
|
}
|
|
3198
|
-
class
|
|
3241
|
+
class we {
|
|
3199
3242
|
constructor(e) {
|
|
3200
3243
|
this.api = e;
|
|
3201
3244
|
}
|
|
@@ -3212,9 +3255,9 @@ class $e {
|
|
|
3212
3255
|
*/
|
|
3213
3256
|
async list(e = {}) {
|
|
3214
3257
|
const t = Object.fromEntries(
|
|
3215
|
-
Object.entries(e).filter(([,
|
|
3216
|
-
),
|
|
3217
|
-
return this.api.get(`/memory/procedures/drift${
|
|
3258
|
+
Object.entries(e).filter(([, n]) => n != null)
|
|
3259
|
+
), s = new URLSearchParams(t).toString();
|
|
3260
|
+
return this.api.get(`/memory/procedures/drift${s ? "?" + s : ""}`);
|
|
3218
3261
|
}
|
|
3219
3262
|
/**
|
|
3220
3263
|
* Get a single drift event with full change details.
|
|
@@ -3231,8 +3274,8 @@ class $e {
|
|
|
3231
3274
|
* @returns {Promise<{status: string, event_id: string, resolved: boolean}>}
|
|
3232
3275
|
*/
|
|
3233
3276
|
async resolve(e, t = null) {
|
|
3234
|
-
const
|
|
3235
|
-
return t != null && (
|
|
3277
|
+
const s = {};
|
|
3278
|
+
return t != null && (s.note = t), this.api.post(`/memory/procedures/drift/${e}/resolve`, s);
|
|
3236
3279
|
}
|
|
3237
3280
|
/**
|
|
3238
3281
|
* Trigger a drift sweep across all procedures in the workspace.
|
|
@@ -3250,7 +3293,7 @@ class $e {
|
|
|
3250
3293
|
return this.api.get(`/memory/procedures/schemas/${e}`);
|
|
3251
3294
|
}
|
|
3252
3295
|
}
|
|
3253
|
-
class
|
|
3296
|
+
class Ie {
|
|
3254
3297
|
constructor(e) {
|
|
3255
3298
|
this.api = e;
|
|
3256
3299
|
}
|
|
@@ -3301,9 +3344,9 @@ class ke {
|
|
|
3301
3344
|
* @param {number} [params.limit=20]
|
|
3302
3345
|
* @param {string} [params.before] ISO 8601 datetime
|
|
3303
3346
|
*/
|
|
3304
|
-
async list({ isHeartbeat: e = null, limit: t = 20, before:
|
|
3305
|
-
const
|
|
3306
|
-
return e !== null && (
|
|
3347
|
+
async list({ isHeartbeat: e = null, limit: t = 20, before: s = null } = {}) {
|
|
3348
|
+
const n = { limit: t };
|
|
3349
|
+
return e !== null && (n.is_heartbeat = e), s !== null && (n.before = s), this.api.get("/memory/summary/list", n);
|
|
3307
3350
|
}
|
|
3308
3351
|
/** SnapshotDelta between two snapshots. Returns null on 404. */
|
|
3309
3352
|
async delta({ from: e, to: t }) {
|
|
@@ -3312,9 +3355,9 @@ class ke {
|
|
|
3312
3355
|
from: e,
|
|
3313
3356
|
to: t
|
|
3314
3357
|
});
|
|
3315
|
-
} catch (
|
|
3316
|
-
if ((
|
|
3317
|
-
throw
|
|
3358
|
+
} catch (s) {
|
|
3359
|
+
if ((s == null ? void 0 : s.status) === 404) return null;
|
|
3360
|
+
throw s;
|
|
3318
3361
|
}
|
|
3319
3362
|
}
|
|
3320
3363
|
/** Admin-only delete. Throws on 403/404/500. */
|
|
@@ -3322,7 +3365,7 @@ class ke {
|
|
|
3322
3365
|
return this.api.delete(`/memory/summary/${e}`);
|
|
3323
3366
|
}
|
|
3324
3367
|
}
|
|
3325
|
-
class
|
|
3368
|
+
class be {
|
|
3326
3369
|
constructor(e) {
|
|
3327
3370
|
this.api = e;
|
|
3328
3371
|
}
|
|
@@ -3334,13 +3377,13 @@ class we {
|
|
|
3334
3377
|
* @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
|
|
3335
3378
|
*/
|
|
3336
3379
|
async acquire(e, { ttlSeconds: t } = {}) {
|
|
3337
|
-
var
|
|
3338
|
-
const
|
|
3339
|
-
t !== void 0 && (
|
|
3380
|
+
var n, r;
|
|
3381
|
+
const s = {};
|
|
3382
|
+
t !== void 0 && (s.ttl_seconds = t);
|
|
3340
3383
|
try {
|
|
3341
|
-
return await this.api.post(`/memory/locks/${e}`,
|
|
3384
|
+
return await this.api.post(`/memory/locks/${e}`, s);
|
|
3342
3385
|
} catch (i) {
|
|
3343
|
-
if ((i == null ? void 0 : i.status) === 409 && ((r = (
|
|
3386
|
+
if ((i == null ? void 0 : i.status) === 409 && ((r = (n = i.detail) == null ? void 0 : n.detail) == null ? void 0 : r.reason) === "lock_held")
|
|
3344
3387
|
return null;
|
|
3345
3388
|
throw i;
|
|
3346
3389
|
}
|
|
@@ -3353,12 +3396,12 @@ class we {
|
|
|
3353
3396
|
* @param {number} [params.ttlSeconds]
|
|
3354
3397
|
* @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
|
|
3355
3398
|
*/
|
|
3356
|
-
async renew(e, t, { ttlSeconds:
|
|
3399
|
+
async renew(e, t, { ttlSeconds: s } = {}) {
|
|
3357
3400
|
var r, i;
|
|
3358
|
-
const
|
|
3359
|
-
|
|
3401
|
+
const n = {};
|
|
3402
|
+
s !== void 0 && (n.ttl_seconds = s);
|
|
3360
3403
|
try {
|
|
3361
|
-
return await this.api.post(`/memory/locks/${e}/renew`,
|
|
3404
|
+
return await this.api.post(`/memory/locks/${e}/renew`, n, {
|
|
3362
3405
|
headers: { "X-Lease-Token": t }
|
|
3363
3406
|
});
|
|
3364
3407
|
} catch (a) {
|
|
@@ -3374,19 +3417,19 @@ class we {
|
|
|
3374
3417
|
* @returns {Promise<boolean>}
|
|
3375
3418
|
*/
|
|
3376
3419
|
async release(e, t) {
|
|
3377
|
-
var
|
|
3420
|
+
var s, n;
|
|
3378
3421
|
try {
|
|
3379
3422
|
return await this.api.delete(`/memory/locks/${e}`, {
|
|
3380
3423
|
headers: { "X-Lease-Token": t }
|
|
3381
3424
|
}), !0;
|
|
3382
3425
|
} catch (r) {
|
|
3383
|
-
if ((r == null ? void 0 : r.status) === 409 && ((
|
|
3426
|
+
if ((r == null ? void 0 : r.status) === 409 && ((n = (s = r.detail) == null ? void 0 : s.detail) == null ? void 0 : n.reason) === "not_owner")
|
|
3384
3427
|
return !1;
|
|
3385
3428
|
throw r;
|
|
3386
3429
|
}
|
|
3387
3430
|
}
|
|
3388
3431
|
}
|
|
3389
|
-
class
|
|
3432
|
+
class Re {
|
|
3390
3433
|
constructor(e) {
|
|
3391
3434
|
this.api = e;
|
|
3392
3435
|
}
|
|
@@ -3407,9 +3450,9 @@ class be {
|
|
|
3407
3450
|
* @param {number} [params.count] How many to allocate (1..100, default 1).
|
|
3408
3451
|
* @returns {Promise<{name: string, value: number, first: number, count: number}>}
|
|
3409
3452
|
*/
|
|
3410
|
-
async allocate(e, { floor: t, count:
|
|
3411
|
-
const
|
|
3412
|
-
return t !== void 0 && (
|
|
3453
|
+
async allocate(e, { floor: t, count: s } = {}) {
|
|
3454
|
+
const n = {};
|
|
3455
|
+
return t !== void 0 && (n.floor = t), s !== void 0 && (n.count = s), this.api.post(`/memory/sequences/${e}/next`, n);
|
|
3413
3456
|
}
|
|
3414
3457
|
/**
|
|
3415
3458
|
* Read the counter without consuming a number, or null if never allocated.
|
|
@@ -3430,7 +3473,7 @@ class be {
|
|
|
3430
3473
|
}
|
|
3431
3474
|
}
|
|
3432
3475
|
}
|
|
3433
|
-
class
|
|
3476
|
+
class Se {
|
|
3434
3477
|
constructor(e) {
|
|
3435
3478
|
this.api = e;
|
|
3436
3479
|
}
|
|
@@ -3459,15 +3502,15 @@ class Ie {
|
|
|
3459
3502
|
* body shape reaches the route from every client.
|
|
3460
3503
|
* @returns {Promise<Object>} RecallPack — `{ block, manifest }`.
|
|
3461
3504
|
*/
|
|
3462
|
-
async pack({ budgetTokens: e, query: t, sections:
|
|
3505
|
+
async pack({ budgetTokens: e, query: t, sections: s, preset: n } = {}) {
|
|
3463
3506
|
const r = { budget_tokens: e };
|
|
3464
|
-
return t != null && (r.query = t),
|
|
3507
|
+
return t != null && (r.query = t), s != null && (r.sections = s.map(({ name: i, cap_tokens: a, capTokens: c }) => ({
|
|
3465
3508
|
name: i,
|
|
3466
3509
|
cap_tokens: a !== void 0 ? a : c
|
|
3467
|
-
}))),
|
|
3510
|
+
}))), n != null && (r.preset = n), this.api.post("/memory/recall/pack", r);
|
|
3468
3511
|
}
|
|
3469
3512
|
}
|
|
3470
|
-
class
|
|
3513
|
+
class ve {
|
|
3471
3514
|
constructor(e) {
|
|
3472
3515
|
this.api = e;
|
|
3473
3516
|
}
|
|
@@ -3480,11 +3523,11 @@ class Re {
|
|
|
3480
3523
|
* @param {string[]} [params.statuses=['active']] Repeatable lifecycle selector.
|
|
3481
3524
|
* @returns {Promise<Object>} The policy-exchange contract bundle.
|
|
3482
3525
|
*/
|
|
3483
|
-
async getBundle({ workflow: e, domain: t, statuses:
|
|
3484
|
-
const
|
|
3485
|
-
if (e != null &&
|
|
3486
|
-
for (const i of
|
|
3487
|
-
const r =
|
|
3526
|
+
async getBundle({ workflow: e, domain: t, statuses: s = ["active"] } = {}) {
|
|
3527
|
+
const n = new URLSearchParams();
|
|
3528
|
+
if (e != null && n.append("workflow", e), t != null && n.append("domain", t), Array.isArray(s))
|
|
3529
|
+
for (const i of s) n.append("status", i);
|
|
3530
|
+
const r = n.toString();
|
|
3488
3531
|
return this.api.get(`/memory/policy/bundle${r ? "?" + r : ""}`);
|
|
3489
3532
|
}
|
|
3490
3533
|
/**
|
|
@@ -3496,17 +3539,23 @@ class Re {
|
|
|
3496
3539
|
return this.api.post("/memory/policy/events", e);
|
|
3497
3540
|
}
|
|
3498
3541
|
}
|
|
3499
|
-
class
|
|
3542
|
+
class Ae {
|
|
3500
3543
|
constructor(e) {
|
|
3501
3544
|
this.auth = new N(e);
|
|
3502
3545
|
const t = new J(this.auth, { fetchFn: e.fetchFn });
|
|
3503
|
-
this._api = t, this.memories = new V(t), this.decisions = new
|
|
3546
|
+
this._api = t, this.memories = new V(t), this.decisions = new Y(t), this.opinions = new X(t), this.graph = new Z(t), this.teams = new Q(t), this.workspaces = new ee(t), this.profiles = new te(t), this.subscriptions = new se(t), this.authAPI = new ne(t), this.agents = new re(t), this.usage = new ie(t), this.insights = new ae(t), this.tokenUsage = new oe(t), this.temporal = new ce(t), this.governance = new ue(t), this.evolution = new le(t), this.reasoning = new me(t), this.reasoningTraces = new pe(t), this.ontology = new he(t), this.analytics = new ye(t), this.validation = new de(t), this.pipeline = new ge(t), this.archive = new fe(t), this.zettelkasten = new _e(t), this.procedureMatches = new $e(t), this.procedureCandidates = new ke(t), this.procedureDrift = new we(t), this.summaries = new Ie(t), this.locks = new be(t), this.sequences = new Re(t), this.recall = new Se(t), this.policy = new ve(t);
|
|
3547
|
+
}
|
|
3548
|
+
setWorkspaceId(e) {
|
|
3549
|
+
this.auth.tokenManager.setWorkspaceId(e), this.auth.notifyListeners();
|
|
3550
|
+
}
|
|
3551
|
+
getWorkspaceId() {
|
|
3552
|
+
return this.auth.tokenManager.getWorkspaceId();
|
|
3504
3553
|
}
|
|
3505
3554
|
setTeamId(e) {
|
|
3506
|
-
this.
|
|
3555
|
+
return this.setWorkspaceId(e);
|
|
3507
3556
|
}
|
|
3508
3557
|
getTeamId() {
|
|
3509
|
-
return this.
|
|
3558
|
+
return this.getWorkspaceId();
|
|
3510
3559
|
}
|
|
3511
3560
|
/**
|
|
3512
3561
|
* Export the current workspace as a gzipped OKF bundle.
|
|
@@ -3521,43 +3570,44 @@ class ve {
|
|
|
3521
3570
|
* @returns {Promise<{ imported: number, failed: number, workspace_id: string }>}
|
|
3522
3571
|
*/
|
|
3523
3572
|
async importOkf(e) {
|
|
3524
|
-
const t = e instanceof Blob ? e : new Blob([e], { type: "application/gzip" }),
|
|
3525
|
-
return
|
|
3573
|
+
const t = e instanceof Blob ? e : new Blob([e], { type: "application/gzip" }), s = new FormData();
|
|
3574
|
+
return s.append("file", t, "smartmemory-okf-import.tar.gz"), this._api.postForm("/memory/okf/import", s);
|
|
3526
3575
|
}
|
|
3527
3576
|
}
|
|
3528
3577
|
export {
|
|
3529
3578
|
w as A,
|
|
3530
3579
|
J as B,
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3580
|
+
Y as D,
|
|
3581
|
+
le as E,
|
|
3582
|
+
ue as G,
|
|
3583
|
+
ae as I,
|
|
3584
|
+
be as L,
|
|
3536
3585
|
V as M,
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3586
|
+
he as O,
|
|
3587
|
+
ge as P,
|
|
3588
|
+
me as R,
|
|
3589
|
+
Re as S,
|
|
3590
|
+
Q as T,
|
|
3591
|
+
ie as U,
|
|
3592
|
+
de as V,
|
|
3593
|
+
ee as W,
|
|
3594
|
+
_e as Z,
|
|
3595
|
+
re as a,
|
|
3596
|
+
ye as b,
|
|
3597
|
+
fe as c,
|
|
3598
|
+
ne as d,
|
|
3549
3599
|
N as e,
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3600
|
+
Z as f,
|
|
3601
|
+
X as g,
|
|
3602
|
+
ke as h,
|
|
3603
|
+
$e as i,
|
|
3604
|
+
te as j,
|
|
3605
|
+
pe as k,
|
|
3606
|
+
Ae as l,
|
|
3607
|
+
se as m,
|
|
3608
|
+
ce as n,
|
|
3559
3609
|
K as o,
|
|
3560
|
-
|
|
3610
|
+
oe as p,
|
|
3561
3611
|
D as q,
|
|
3562
3612
|
G as r
|
|
3563
3613
|
};
|