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