@smartmemory/sdk-js 1.4.100 → 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-McKeQ81o.js → core-DUg_hHl8.js} +268 -263
- package/dist/core.js +12 -10
- package/dist/fetch.js +18 -37
- package/dist/index-BKI1h_Wn.js +107 -0
- package/dist/index.js +14 -11
- package/dist/progress.js +166 -142
- package/dist/react.js +20 -20
- 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,32 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var P = (o, e, t) => e.has(o) || M("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) ? M("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), L = (o, e, t, n) => (P(o, e, "write to private field"), n ? n.call(o, t) : e.set(o, t), t), z = (o, e, t) => (P(o, e, "access private method"), t);
|
|
6
|
-
const H = {
|
|
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
|
-
|
|
12
|
-
},
|
|
8
|
+
workspace: "smart_memory_workspace_id"
|
|
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
|
-
|
|
23
|
+
var s;
|
|
24
|
+
this.storageType = e;
|
|
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] : []
|
|
29
|
+
], this._memory = { access: null, refresh: null, user: null, tenant: null, workspace: null };
|
|
27
30
|
}
|
|
28
31
|
getAccessToken() {
|
|
29
|
-
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);
|
|
30
33
|
}
|
|
31
34
|
setAccessToken(e) {
|
|
32
35
|
if (this.storageType === "memory") {
|
|
@@ -36,7 +39,7 @@ class K {
|
|
|
36
39
|
this._setInStorage(this.keys.access, e);
|
|
37
40
|
}
|
|
38
41
|
getRefreshToken() {
|
|
39
|
-
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);
|
|
40
43
|
}
|
|
41
44
|
setRefreshToken(e) {
|
|
42
45
|
if (this.storageType === "memory") {
|
|
@@ -47,7 +50,7 @@ class K {
|
|
|
47
50
|
}
|
|
48
51
|
getUser() {
|
|
49
52
|
if (this.storageType === "memory") return this._memory.user;
|
|
50
|
-
const e = this._getFromStorage(this.keys.user,
|
|
53
|
+
const e = this._getFromStorage(this.keys.user, w.user);
|
|
51
54
|
if (!e) return null;
|
|
52
55
|
try {
|
|
53
56
|
return JSON.parse(e);
|
|
@@ -63,7 +66,7 @@ class K {
|
|
|
63
66
|
this._setInStorage(this.keys.user, e ? JSON.stringify(e) : null);
|
|
64
67
|
}
|
|
65
68
|
getTenantId() {
|
|
66
|
-
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));
|
|
67
70
|
}
|
|
68
71
|
setTenantId(e) {
|
|
69
72
|
const t = this._normalizeId(e);
|
|
@@ -73,20 +76,26 @@ class K {
|
|
|
73
76
|
}
|
|
74
77
|
this._setInStorage(this.keys.tenant, t);
|
|
75
78
|
}
|
|
76
|
-
|
|
77
|
-
return this.storageType === "memory" ? this._memory.
|
|
79
|
+
getWorkspaceId() {
|
|
80
|
+
return this.storageType === "memory" ? this._memory.workspace : this._normalizeId(this._getFromStorage(this.keys.workspace, this.workspaceAliases));
|
|
78
81
|
}
|
|
79
|
-
|
|
82
|
+
setWorkspaceId(e) {
|
|
80
83
|
const t = this._normalizeId(e);
|
|
81
84
|
if (this.storageType === "memory") {
|
|
82
|
-
this._memory.
|
|
85
|
+
this._memory.workspace = t;
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
|
-
this._setInStorage(this.keys.
|
|
88
|
+
this._setInStorage(this.keys.workspace, t);
|
|
89
|
+
}
|
|
90
|
+
getTeamId() {
|
|
91
|
+
return this.getWorkspaceId();
|
|
92
|
+
}
|
|
93
|
+
setTeamId(e) {
|
|
94
|
+
this.setWorkspaceId(e);
|
|
86
95
|
}
|
|
87
96
|
clearAll() {
|
|
88
97
|
if (this.storageType === "memory") {
|
|
89
|
-
this._memory = { access: null, refresh: null, user: null, tenant: null,
|
|
98
|
+
this._memory = { access: null, refresh: null, user: null, tenant: null, workspace: null };
|
|
90
99
|
return;
|
|
91
100
|
}
|
|
92
101
|
for (const e of Object.values(this.keys))
|
|
@@ -94,7 +103,7 @@ class K {
|
|
|
94
103
|
localStorage.removeItem(e), sessionStorage.removeItem(e);
|
|
95
104
|
} catch {
|
|
96
105
|
}
|
|
97
|
-
for (const e of Object.values(
|
|
106
|
+
for (const e of Object.values(w))
|
|
98
107
|
for (const t of e)
|
|
99
108
|
try {
|
|
100
109
|
localStorage.removeItem(t), sessionStorage.removeItem(t);
|
|
@@ -115,14 +124,14 @@ class K {
|
|
|
115
124
|
const n = this.storageType === "localStorage" ? localStorage : sessionStorage, s = this.storageType === "localStorage" ? sessionStorage : localStorage, r = n.getItem(e) || s.getItem(e);
|
|
116
125
|
if (r != null) return r;
|
|
117
126
|
for (const i of t) {
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
this._setInStorage(e,
|
|
127
|
+
const o = n.getItem(i) || s.getItem(i);
|
|
128
|
+
if (o != null) {
|
|
129
|
+
this._setInStorage(e, o);
|
|
121
130
|
try {
|
|
122
131
|
n.removeItem(i), s.removeItem(i);
|
|
123
132
|
} catch {
|
|
124
133
|
}
|
|
125
|
-
return
|
|
134
|
+
return o;
|
|
126
135
|
}
|
|
127
136
|
}
|
|
128
137
|
return null;
|
|
@@ -148,50 +157,8 @@ class K {
|
|
|
148
157
|
return n === "none" || n === "null" || n === "undefined" ? null : t;
|
|
149
158
|
}
|
|
150
159
|
}
|
|
151
|
-
|
|
152
|
-
class
|
|
153
|
-
/**
|
|
154
|
-
* @param {Object} options
|
|
155
|
-
* @param {string} options.apiBaseUrl
|
|
156
|
-
* @param {string} options.refreshEndpoint
|
|
157
|
-
* @param {import('./TokenManager.js').TokenManager} options.tokenManager
|
|
158
|
-
* @param {boolean} [options.useCookieAuth=false]
|
|
159
|
-
* @param {function(string): void} options.onTokenRefreshed
|
|
160
|
-
* @param {function(): void} options.onRefreshFailed
|
|
161
|
-
*/
|
|
162
|
-
constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager: n, useCookieAuth: s = !1, onTokenRefreshed: r, onRefreshFailed: i }) {
|
|
163
|
-
q(this, A);
|
|
164
|
-
q(this, _, null);
|
|
165
|
-
this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager = n, this.useCookieAuth = s, this.onTokenRefreshed = r, this.onRefreshFailed = i;
|
|
166
|
-
}
|
|
167
|
-
async refresh() {
|
|
168
|
-
if (v(this, _))
|
|
169
|
-
return v(this, _);
|
|
170
|
-
L(this, _, z(this, A, j).call(this));
|
|
171
|
-
try {
|
|
172
|
-
return await v(this, _);
|
|
173
|
-
} finally {
|
|
174
|
-
L(this, _, null);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
_ = new WeakMap(), A = new WeakSet(), j = async function() {
|
|
179
|
-
const e = this.tokenManager.getRefreshToken();
|
|
180
|
-
if (!e && !this.useCookieAuth)
|
|
181
|
-
throw this.onRefreshFailed(), new Error("No refresh token");
|
|
182
|
-
const t = JSON.stringify(e ? { refresh_token: e } : {}), n = await fetch(`${this.apiBaseUrl}${this.refreshEndpoint}`, {
|
|
183
|
-
...this.useCookieAuth ? { credentials: "include" } : {},
|
|
184
|
-
method: "POST",
|
|
185
|
-
headers: { "Content-Type": "application/json" },
|
|
186
|
-
body: t
|
|
187
|
-
});
|
|
188
|
-
if (!n.ok)
|
|
189
|
-
throw this.onRefreshFailed(), new Error(`Refresh failed: ${n.status}`);
|
|
190
|
-
const s = await n.json();
|
|
191
|
-
return this.tokenManager.setAccessToken(s.access_token), s.refresh_token && this.tokenManager.setRefreshToken(s.refresh_token), this.onTokenRefreshed(s.access_token), s.access_token;
|
|
192
|
-
};
|
|
193
|
-
const E = "smart_memory_sso_redirect";
|
|
194
|
-
class G {
|
|
160
|
+
const U = "smart_memory_sso_redirect";
|
|
161
|
+
class j {
|
|
195
162
|
/**
|
|
196
163
|
* @param {Object} options
|
|
197
164
|
* @param {string} options.webAppUrl - Web app URL for login redirect
|
|
@@ -216,30 +183,34 @@ class G {
|
|
|
216
183
|
}
|
|
217
184
|
storeRedirect(e) {
|
|
218
185
|
try {
|
|
219
|
-
sessionStorage.setItem(
|
|
186
|
+
sessionStorage.setItem(U, e);
|
|
220
187
|
} catch (t) {
|
|
221
188
|
console.warn("Failed to store redirect URL:", t);
|
|
222
189
|
}
|
|
223
190
|
}
|
|
224
191
|
getAndClearRedirect() {
|
|
225
192
|
try {
|
|
226
|
-
const e = sessionStorage.getItem(
|
|
227
|
-
return sessionStorage.removeItem(
|
|
193
|
+
const e = sessionStorage.getItem(U);
|
|
194
|
+
return sessionStorage.removeItem(U), e;
|
|
228
195
|
} catch {
|
|
229
196
|
return null;
|
|
230
197
|
}
|
|
231
198
|
}
|
|
232
199
|
}
|
|
233
|
-
class
|
|
200
|
+
class F {
|
|
234
201
|
constructor(e) {
|
|
235
|
-
this.mode = e.mode, this.apiBaseUrl = e.apiBaseUrl, this.endpoints = e.endpoints || {}, this.listeners = /* @__PURE__ */ new Set(), this.useCookieAuth = e.useCookieAuth ?? this.mode === "sso", this.apiKey = e.apiKey || null, this.apiKey && (this.mode = "apiKey"), this.tokenManager = new
|
|
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({
|
|
236
203
|
storage: e.storage || "localStorage",
|
|
237
204
|
keys: e.tokenKeys
|
|
238
|
-
}), this.mode !== "apiKey" ? this.refreshManager = new
|
|
205
|
+
}), this.mode !== "apiKey" ? this.refreshManager = new O({
|
|
239
206
|
apiBaseUrl: this.apiBaseUrl,
|
|
240
207
|
refreshEndpoint: this.endpoints.refresh || "/auth/refresh",
|
|
241
208
|
tokenManager: this.tokenManager,
|
|
242
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()]),
|
|
243
214
|
onTokenRefreshed: (t) => {
|
|
244
215
|
var n;
|
|
245
216
|
this.currentToken = t, this.notifyListeners(), (n = e.onTokenRefresh) == null || n.call(e, t);
|
|
@@ -247,7 +218,7 @@ class N {
|
|
|
247
218
|
onRefreshFailed: () => {
|
|
248
219
|
this.clearLocalAuth();
|
|
249
220
|
}
|
|
250
|
-
}) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new
|
|
221
|
+
}) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new j({
|
|
251
222
|
webAppUrl: e.webAppUrl,
|
|
252
223
|
allowedHosts: e.allowedRedirectHosts || [],
|
|
253
224
|
tokenManager: this.tokenManager
|
|
@@ -270,24 +241,36 @@ class N {
|
|
|
270
241
|
return ((n = (t = this.currentUser) == null ? void 0 : t.roles) == null ? void 0 : n.includes(e)) || !1;
|
|
271
242
|
}
|
|
272
243
|
getAuthHeaders(e = {}) {
|
|
273
|
-
const t = { ...e };
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
return n && (t["X-Workspace-Id"] = n), t;
|
|
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;
|
|
277
248
|
}
|
|
278
249
|
getRequestOptions(e = {}) {
|
|
279
|
-
|
|
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 };
|
|
280
262
|
}
|
|
281
263
|
addListener(e) {
|
|
282
264
|
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
283
265
|
}
|
|
284
266
|
notifyListeners() {
|
|
267
|
+
this.isAuthenticated() && this.connection.authenticated();
|
|
285
268
|
const e = {
|
|
286
269
|
isAuthenticated: this.isAuthenticated(),
|
|
287
270
|
user: this.currentUser,
|
|
288
271
|
token: this.currentToken,
|
|
289
272
|
tenantId: this.tokenManager.getTenantId(),
|
|
290
|
-
workspaceId: this.tokenManager.
|
|
273
|
+
workspaceId: this.tokenManager.getWorkspaceId()
|
|
291
274
|
};
|
|
292
275
|
this.listeners.forEach((t) => {
|
|
293
276
|
try {
|
|
@@ -303,7 +286,7 @@ class N {
|
|
|
303
286
|
return this.ssoManager.getLoginUrl(e);
|
|
304
287
|
}
|
|
305
288
|
clearLocalAuth() {
|
|
306
|
-
if (this.mode === "apiKey") {
|
|
289
|
+
if (this.sessionRevision++, this.connection.signedOut(), this.mode === "apiKey") {
|
|
307
290
|
this.apiKey = null, this.currentToken = null, this.notifyListeners();
|
|
308
291
|
return;
|
|
309
292
|
}
|
|
@@ -331,8 +314,7 @@ class N {
|
|
|
331
314
|
return this.apiKey;
|
|
332
315
|
if (!this.refreshManager)
|
|
333
316
|
throw new Error("Token refresh not available in this mode");
|
|
334
|
-
|
|
335
|
-
return this.currentToken = e, e;
|
|
317
|
+
return await this.refreshManager.refresh();
|
|
336
318
|
}
|
|
337
319
|
async bootstrapSession() {
|
|
338
320
|
if (this.mode === "apiKey" || !this.useCookieAuth)
|
|
@@ -343,7 +325,7 @@ class N {
|
|
|
343
325
|
e,
|
|
344
326
|
this.getRequestOptions({ method: "GET", headers: this.getAuthHeaders() })
|
|
345
327
|
), n = !1;
|
|
346
|
-
if (!t.ok && (this.currentToken || this.tokenManager.
|
|
328
|
+
if (!t.ok && (this.currentToken || this.tokenManager.getWorkspaceId()) && (t = await fetch(
|
|
347
329
|
e,
|
|
348
330
|
this.getRequestOptions({ method: "GET", headers: {} })
|
|
349
331
|
), n = t.ok), !t.ok && t.status === 401 && this.refreshManager)
|
|
@@ -357,8 +339,8 @@ class N {
|
|
|
357
339
|
if (!t.ok) return !1;
|
|
358
340
|
const s = await t.json();
|
|
359
341
|
this.currentUser = s, this.tokenManager.setUser(s);
|
|
360
|
-
const r = (s == null ? void 0 : s.default_team_id) || this.tokenManager.
|
|
361
|
-
return
|
|
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;
|
|
362
344
|
} catch {
|
|
363
345
|
return !1;
|
|
364
346
|
}
|
|
@@ -367,7 +349,7 @@ class N {
|
|
|
367
349
|
this.tokenManager.setTenantId(e), this.notifyListeners();
|
|
368
350
|
}
|
|
369
351
|
}
|
|
370
|
-
class
|
|
352
|
+
class _ extends Error {
|
|
371
353
|
/**
|
|
372
354
|
* @param {string} message - Error message
|
|
373
355
|
* @param {number} [status=0] - HTTP status code (0 for network errors)
|
|
@@ -377,13 +359,13 @@ class w extends Error {
|
|
|
377
359
|
super(e), this.name = "APIError", this.status = t, this.detail = n;
|
|
378
360
|
}
|
|
379
361
|
}
|
|
380
|
-
function
|
|
381
|
-
return typeof FormData < "u" &&
|
|
362
|
+
function q(a) {
|
|
363
|
+
return typeof FormData < "u" && a instanceof FormData;
|
|
382
364
|
}
|
|
383
|
-
function
|
|
384
|
-
return (
|
|
365
|
+
function L(a) {
|
|
366
|
+
return (a == null ? void 0 : a.name) === "AbortError";
|
|
385
367
|
}
|
|
386
|
-
class
|
|
368
|
+
class W {
|
|
387
369
|
/**
|
|
388
370
|
* @param {import('../auth/AuthCore.js').AuthCore} authCore
|
|
389
371
|
* @param {{ fetchFn?: typeof globalThis.fetch }} [options]
|
|
@@ -405,35 +387,28 @@ class J {
|
|
|
405
387
|
* @param {RequestInit & { signal?: AbortSignal }} [options]
|
|
406
388
|
*/
|
|
407
389
|
async request(e, t = {}) {
|
|
408
|
-
var i, a;
|
|
409
390
|
const n = `${this.baseURL}${e}`, s = {
|
|
410
|
-
...
|
|
391
|
+
...q(t.body) ? {} : { "Content-Type": "application/json" },
|
|
411
392
|
...this.auth.getAuthHeaders(t.headers)
|
|
412
393
|
}, r = this.auth.getRequestOptions({ ...t, headers: s });
|
|
413
394
|
try {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
);
|
|
426
|
-
} catch {
|
|
427
|
-
}
|
|
428
|
-
if (c.status === 401)
|
|
429
|
-
throw (a = (i = this.auth).clearLocalAuth) == null || a.call(i), new w("Authentication required", 401, "auth_expired");
|
|
430
|
-
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)
|
|
431
406
|
return null;
|
|
432
|
-
if (!
|
|
433
|
-
throw await this._handleError(
|
|
434
|
-
return await
|
|
435
|
-
} catch (
|
|
436
|
-
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");
|
|
437
412
|
}
|
|
438
413
|
}
|
|
439
414
|
async get(e, t = {}) {
|
|
@@ -447,33 +422,26 @@ class J {
|
|
|
447
422
|
});
|
|
448
423
|
}
|
|
449
424
|
async requestBinary(e, t = {}) {
|
|
450
|
-
var i, a;
|
|
451
425
|
const n = `${this.baseURL}${e}`, s = {
|
|
452
|
-
...
|
|
426
|
+
...q(t.body) ? {} : { "Content-Type": "application/json" },
|
|
453
427
|
...this.auth.getAuthHeaders(t.headers)
|
|
454
428
|
}, r = this.auth.getRequestOptions({ ...t, headers: s });
|
|
455
429
|
try {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
throw (a = (i = this.auth).clearLocalAuth) == null || a.call(i), new w("Authentication required", 401, "auth_expired");
|
|
472
|
-
if (!c.ok)
|
|
473
|
-
throw await this._handleError(c);
|
|
474
|
-
return await c.arrayBuffer();
|
|
475
|
-
} catch (c) {
|
|
476
|
-
throw c instanceof w || O(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");
|
|
477
445
|
}
|
|
478
446
|
}
|
|
479
447
|
async postForm(e, t, n = {}) {
|
|
@@ -510,7 +478,7 @@ class J {
|
|
|
510
478
|
} catch {
|
|
511
479
|
t = { message: `HTTP ${e.status}` };
|
|
512
480
|
}
|
|
513
|
-
return new
|
|
481
|
+
return new _(
|
|
514
482
|
this._extractMessage(t, e.status),
|
|
515
483
|
e.status,
|
|
516
484
|
t
|
|
@@ -540,7 +508,7 @@ class J {
|
|
|
540
508
|
return typeof (e == null ? void 0 : e.message) == "string" ? e.message : `HTTP ${t}`;
|
|
541
509
|
}
|
|
542
510
|
}
|
|
543
|
-
class
|
|
511
|
+
class B {
|
|
544
512
|
constructor(e) {
|
|
545
513
|
this.api = e;
|
|
546
514
|
}
|
|
@@ -571,7 +539,7 @@ class V {
|
|
|
571
539
|
usePipeline: s = !0,
|
|
572
540
|
profileName: r = null,
|
|
573
541
|
conversationContext: i = null,
|
|
574
|
-
embed:
|
|
542
|
+
embed: o = null
|
|
575
543
|
}) {
|
|
576
544
|
const c = {
|
|
577
545
|
content: e,
|
|
@@ -580,7 +548,7 @@ class V {
|
|
|
580
548
|
use_pipeline: s,
|
|
581
549
|
profile_name: r
|
|
582
550
|
};
|
|
583
|
-
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);
|
|
584
552
|
}
|
|
585
553
|
async get(e) {
|
|
586
554
|
const t = await this.api.get(`/memory/${encodeURIComponent(e)}`);
|
|
@@ -660,8 +628,8 @@ class V {
|
|
|
660
628
|
metadataValue: r = null,
|
|
661
629
|
includeGrounding: i = null
|
|
662
630
|
} = {}) {
|
|
663
|
-
const
|
|
664
|
-
return n != null &&
|
|
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}`);
|
|
665
633
|
}
|
|
666
634
|
/**
|
|
667
635
|
* Search for memory items.
|
|
@@ -671,6 +639,7 @@ class V {
|
|
|
671
639
|
* @param {number} [options.topK=5]
|
|
672
640
|
* @param {boolean} [options.enableHybrid=true]
|
|
673
641
|
* @param {string|null} [options.memoryType=null]
|
|
642
|
+
* @param {string|null} [options.reranker=null] - Optional reranker policy override.
|
|
674
643
|
* @param {boolean} [options.expertise=false] - When true (CORE-EXPERTISE-1 Phase 4a),
|
|
675
644
|
* the response shape changes from a flat list to `{results: {<expertise_type>: [items]}}`
|
|
676
645
|
* keyed by expertise type (decision, constraint, learned, opinion, reasoning, observation).
|
|
@@ -728,20 +697,21 @@ class V {
|
|
|
728
697
|
* hopStrategy: consensus follows entities several top results agree on; relevance follows
|
|
729
698
|
* best-result entities and one-off bridges; semantic asks an LLM. Omitted preserves core default.
|
|
730
699
|
* since/until: ISO strings or Dates bounding created_at in [since, until), independent of asOfDate. */
|
|
731
|
-
async search(e, { topK: t = 5, enableHybrid: n = !0, memoryType: s = null, expertise: r = !1, cite: i = !1, decompose:
|
|
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 } = {}) {
|
|
732
701
|
const l = { query: e, top_k: t, enable_hybrid: n };
|
|
733
|
-
if (
|
|
734
|
-
const
|
|
735
|
-
for (const f of Object.keys(
|
|
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)) {
|
|
736
705
|
if (["contains", "keyword-bm25"].includes(f))
|
|
737
706
|
throw new Error(`Channel ${f} was removed; use lexical.`);
|
|
738
|
-
if (!
|
|
707
|
+
if (!R.has(f)) throw new Error(`Unknown search channel ${f}. Accepted: ${[...R].join(", ")}`);
|
|
739
708
|
}
|
|
740
|
-
l.channel_weights =
|
|
709
|
+
l.channel_weights = S;
|
|
741
710
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
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);
|
|
745
715
|
}
|
|
746
716
|
/**
|
|
747
717
|
* Ask a question and get a written answer plus the evidence behind it (DIST-LITE-9).
|
|
@@ -826,14 +796,14 @@ class V {
|
|
|
826
796
|
* than by find-and-replace.
|
|
827
797
|
*/
|
|
828
798
|
async searchByMetadata(e, t, { memoryType: n = null, limit: s = 25, since: r = null, until: i = null } = {}) {
|
|
829
|
-
const
|
|
799
|
+
const o = new URLSearchParams({
|
|
830
800
|
metadata_key: e,
|
|
831
801
|
metadata_value: t,
|
|
832
802
|
limit: s
|
|
833
803
|
});
|
|
834
804
|
for (const [c, u] of Object.entries({ since: r, until: i }))
|
|
835
|
-
u != null &&
|
|
836
|
-
return n &&
|
|
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}`);
|
|
837
807
|
}
|
|
838
808
|
async getNeighbors(e) {
|
|
839
809
|
return this.api.get(`/memory/${encodeURIComponent(e)}/neighbors`);
|
|
@@ -847,10 +817,10 @@ class V {
|
|
|
847
817
|
sessionDates: s = null,
|
|
848
818
|
turnsPerChunk: r = 15,
|
|
849
819
|
maxChunkChars: i = 12e3,
|
|
850
|
-
maxConcurrent:
|
|
820
|
+
maxConcurrent: o = 4,
|
|
851
821
|
context: c = null
|
|
852
822
|
} = {}) {
|
|
853
|
-
const u = { turns: e, turns_per_chunk: r, max_chunk_chars: i, max_concurrent:
|
|
823
|
+
const u = { turns: e, turns_per_chunk: r, max_chunk_chars: i, max_concurrent: o };
|
|
854
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);
|
|
855
825
|
}
|
|
856
826
|
async ingestDocument(e, { title: t = null, source: n = null, chunkStrategy: s = null, context: r = null } = {}) {
|
|
@@ -1003,7 +973,7 @@ class V {
|
|
|
1003
973
|
return this.api.get("/memory/clustering/stats");
|
|
1004
974
|
}
|
|
1005
975
|
}
|
|
1006
|
-
class
|
|
976
|
+
class K {
|
|
1007
977
|
constructor(e) {
|
|
1008
978
|
this.api = e;
|
|
1009
979
|
}
|
|
@@ -1029,11 +999,11 @@ class W {
|
|
|
1029
999
|
sourceTraceId: s = null,
|
|
1030
1000
|
sourceSessionId: r = null,
|
|
1031
1001
|
evidenceIds: i = null,
|
|
1032
|
-
domain:
|
|
1002
|
+
domain: o = null,
|
|
1033
1003
|
tags: c = null,
|
|
1034
1004
|
rejectedAlternatives: u = null,
|
|
1035
1005
|
rationale: y = null,
|
|
1036
|
-
constraints:
|
|
1006
|
+
constraints: h = null,
|
|
1037
1007
|
agentId: d = null
|
|
1038
1008
|
}) {
|
|
1039
1009
|
return this.api.post("/memory/decisions/create", {
|
|
@@ -1043,11 +1013,11 @@ class W {
|
|
|
1043
1013
|
source_trace_id: s,
|
|
1044
1014
|
source_session_id: r,
|
|
1045
1015
|
evidence_ids: i,
|
|
1046
|
-
domain:
|
|
1016
|
+
domain: o,
|
|
1047
1017
|
tags: c,
|
|
1048
1018
|
rejected_alternatives: u,
|
|
1049
1019
|
rationale: y,
|
|
1050
|
-
constraints:
|
|
1020
|
+
constraints: h,
|
|
1051
1021
|
agent_id: d
|
|
1052
1022
|
});
|
|
1053
1023
|
}
|
|
@@ -1251,7 +1221,7 @@ class W {
|
|
|
1251
1221
|
});
|
|
1252
1222
|
}
|
|
1253
1223
|
}
|
|
1254
|
-
class
|
|
1224
|
+
class H {
|
|
1255
1225
|
constructor(e) {
|
|
1256
1226
|
this.api = e;
|
|
1257
1227
|
}
|
|
@@ -1273,7 +1243,7 @@ class Y {
|
|
|
1273
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);
|
|
1274
1244
|
}
|
|
1275
1245
|
}
|
|
1276
|
-
class
|
|
1246
|
+
class D {
|
|
1277
1247
|
constructor(e) {
|
|
1278
1248
|
this.api = e;
|
|
1279
1249
|
}
|
|
@@ -1422,7 +1392,7 @@ class X {
|
|
|
1422
1392
|
);
|
|
1423
1393
|
}
|
|
1424
1394
|
}
|
|
1425
|
-
class
|
|
1395
|
+
class G {
|
|
1426
1396
|
constructor(e) {
|
|
1427
1397
|
this.api = e;
|
|
1428
1398
|
}
|
|
@@ -1464,7 +1434,36 @@ class Z {
|
|
|
1464
1434
|
return this.api.delete(`/memory/teams/${e}/members/${t}`);
|
|
1465
1435
|
}
|
|
1466
1436
|
}
|
|
1467
|
-
class
|
|
1437
|
+
class N {
|
|
1438
|
+
constructor(e) {
|
|
1439
|
+
this.api = e;
|
|
1440
|
+
}
|
|
1441
|
+
async list() {
|
|
1442
|
+
return this.api.get("/memory/workspaces");
|
|
1443
|
+
}
|
|
1444
|
+
async create({ name: e, teamId: t, description: n = null }) {
|
|
1445
|
+
return this.api.post("/memory/workspaces", {
|
|
1446
|
+
name: e,
|
|
1447
|
+
description: n,
|
|
1448
|
+
team_id: t
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
async share(e, { teamId: t, permission: n }) {
|
|
1452
|
+
return this.api.post(`/memory/workspaces/${encodeURIComponent(e)}/share`, {
|
|
1453
|
+
team_id: t,
|
|
1454
|
+
permission: n
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
async revoke(e, t) {
|
|
1458
|
+
return this.api.delete(
|
|
1459
|
+
`/memory/workspaces/${encodeURIComponent(e)}/share/${encodeURIComponent(t)}`
|
|
1460
|
+
);
|
|
1461
|
+
}
|
|
1462
|
+
async listTeamWorkspaces(e) {
|
|
1463
|
+
return this.api.get(`/memory/teams/${encodeURIComponent(e)}/workspaces`);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
class J {
|
|
1468
1467
|
constructor(e) {
|
|
1469
1468
|
this.api = e;
|
|
1470
1469
|
}
|
|
@@ -1486,7 +1485,7 @@ class Q {
|
|
|
1486
1485
|
return this.api.patch("/auth/llm-keys", e);
|
|
1487
1486
|
}
|
|
1488
1487
|
}
|
|
1489
|
-
class
|
|
1488
|
+
class V {
|
|
1490
1489
|
constructor(e) {
|
|
1491
1490
|
this.api = e;
|
|
1492
1491
|
}
|
|
@@ -1512,7 +1511,7 @@ class ee {
|
|
|
1512
1511
|
});
|
|
1513
1512
|
}
|
|
1514
1513
|
}
|
|
1515
|
-
class
|
|
1514
|
+
class Y {
|
|
1516
1515
|
constructor(e) {
|
|
1517
1516
|
this.api = e;
|
|
1518
1517
|
}
|
|
@@ -1533,7 +1532,7 @@ class te {
|
|
|
1533
1532
|
return this.api.delete(`/memory/api-keys/${e}`);
|
|
1534
1533
|
}
|
|
1535
1534
|
}
|
|
1536
|
-
class
|
|
1535
|
+
class X {
|
|
1537
1536
|
constructor(e) {
|
|
1538
1537
|
this.api = e;
|
|
1539
1538
|
}
|
|
@@ -1592,7 +1591,7 @@ class ne {
|
|
|
1592
1591
|
return this.api.get(`/memory/agents/${e}/evaluation/history${r ? "?" + r : ""}`);
|
|
1593
1592
|
}
|
|
1594
1593
|
}
|
|
1595
|
-
class
|
|
1594
|
+
class Z {
|
|
1596
1595
|
constructor(e) {
|
|
1597
1596
|
this.api = e;
|
|
1598
1597
|
}
|
|
@@ -1606,7 +1605,7 @@ class se {
|
|
|
1606
1605
|
return this.api.get("/usage/tiers");
|
|
1607
1606
|
}
|
|
1608
1607
|
}
|
|
1609
|
-
class
|
|
1608
|
+
class Q {
|
|
1610
1609
|
constructor(e) {
|
|
1611
1610
|
this.api = e;
|
|
1612
1611
|
}
|
|
@@ -1623,7 +1622,7 @@ class re {
|
|
|
1623
1622
|
return this.api.get("/memory/plugins");
|
|
1624
1623
|
}
|
|
1625
1624
|
}
|
|
1626
|
-
class
|
|
1625
|
+
class ee {
|
|
1627
1626
|
constructor(e) {
|
|
1628
1627
|
this.api = e;
|
|
1629
1628
|
}
|
|
@@ -1646,7 +1645,7 @@ class ie {
|
|
|
1646
1645
|
return this.api.get("/memory/token-usage/current");
|
|
1647
1646
|
}
|
|
1648
1647
|
}
|
|
1649
|
-
class
|
|
1648
|
+
class te {
|
|
1650
1649
|
constructor(e) {
|
|
1651
1650
|
this.api = e;
|
|
1652
1651
|
}
|
|
@@ -1732,8 +1731,8 @@ class ae {
|
|
|
1732
1731
|
*/
|
|
1733
1732
|
async getAuditTrail(e, { changeType: t = null, userId: n = null, startTime: s = null, endTime: r = null } = {}) {
|
|
1734
1733
|
let i = `/memory/temporal/${e}/audit`;
|
|
1735
|
-
const
|
|
1736
|
-
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);
|
|
1737
1736
|
}
|
|
1738
1737
|
// === TEMPORAL SEARCH ===
|
|
1739
1738
|
/**
|
|
@@ -1792,7 +1791,7 @@ class ae {
|
|
|
1792
1791
|
return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
|
|
1793
1792
|
}
|
|
1794
1793
|
}
|
|
1795
|
-
class
|
|
1794
|
+
class ne {
|
|
1796
1795
|
constructor(e) {
|
|
1797
1796
|
this.api = e;
|
|
1798
1797
|
}
|
|
@@ -1861,7 +1860,7 @@ class oe {
|
|
|
1861
1860
|
return this.api.get("/memory/governance/summary");
|
|
1862
1861
|
}
|
|
1863
1862
|
}
|
|
1864
|
-
class
|
|
1863
|
+
class se {
|
|
1865
1864
|
constructor(e) {
|
|
1866
1865
|
this.api = e;
|
|
1867
1866
|
}
|
|
@@ -1902,7 +1901,7 @@ class ce {
|
|
|
1902
1901
|
return this.api.post("/memory/evolution/reinforce/opinions");
|
|
1903
1902
|
}
|
|
1904
1903
|
}
|
|
1905
|
-
class
|
|
1904
|
+
class re {
|
|
1906
1905
|
constructor(e) {
|
|
1907
1906
|
this.api = e;
|
|
1908
1907
|
}
|
|
@@ -2000,7 +1999,7 @@ class ue {
|
|
|
2000
1999
|
});
|
|
2001
2000
|
}
|
|
2002
2001
|
}
|
|
2003
|
-
class
|
|
2002
|
+
class ie {
|
|
2004
2003
|
constructor(e) {
|
|
2005
2004
|
this.api = e;
|
|
2006
2005
|
}
|
|
@@ -2054,7 +2053,7 @@ class le {
|
|
|
2054
2053
|
return this.api.get(`/memory/reasoning/traces/${e}`);
|
|
2055
2054
|
}
|
|
2056
2055
|
}
|
|
2057
|
-
class
|
|
2056
|
+
class oe {
|
|
2058
2057
|
constructor(e) {
|
|
2059
2058
|
this.api = e;
|
|
2060
2059
|
}
|
|
@@ -2455,9 +2454,9 @@ class me {
|
|
|
2455
2454
|
* @param {number} [options.limit=100]
|
|
2456
2455
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2457
2456
|
*/
|
|
2458
|
-
async listTypes({ tier: e, layer: t, packId: n, hasIri: s, kind: r, limit: i = 100, cursor:
|
|
2457
|
+
async listTypes({ tier: e, layer: t, packId: n, hasIri: s, kind: r, limit: i = 100, cursor: o } = {}) {
|
|
2459
2458
|
const c = { limit: String(i) };
|
|
2460
|
-
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),
|
|
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);
|
|
2461
2460
|
const u = new URLSearchParams(c).toString();
|
|
2462
2461
|
return this.api.get(`/memory/ontology/types${u ? "?" + u : ""}`);
|
|
2463
2462
|
}
|
|
@@ -2496,18 +2495,18 @@ class me {
|
|
|
2496
2495
|
requiredProperties: s,
|
|
2497
2496
|
storageStrategy: r,
|
|
2498
2497
|
storageSearchable: i,
|
|
2499
|
-
iri:
|
|
2498
|
+
iri: o,
|
|
2500
2499
|
wikidataQid: c,
|
|
2501
2500
|
displayName: u,
|
|
2502
2501
|
definition: y,
|
|
2503
|
-
description:
|
|
2502
|
+
description: h,
|
|
2504
2503
|
aliases: d,
|
|
2505
2504
|
examples: $,
|
|
2506
2505
|
parentTypes: k,
|
|
2507
2506
|
tier: g = "confirmed"
|
|
2508
2507
|
} = {}) {
|
|
2509
|
-
const
|
|
2510
|
-
return n !== void 0 && (
|
|
2508
|
+
const p = { name: e, kind: t, tier: g };
|
|
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);
|
|
2511
2510
|
}
|
|
2512
2511
|
/**
|
|
2513
2512
|
* Declare an ontology relation (CORE-MEMTYPE-DECLARE-1; declare-only in P1).
|
|
@@ -2542,22 +2541,22 @@ class me {
|
|
|
2542
2541
|
inverseOf: s,
|
|
2543
2542
|
cardinality: r,
|
|
2544
2543
|
temporal: i,
|
|
2545
|
-
propertiesSchema:
|
|
2544
|
+
propertiesSchema: o,
|
|
2546
2545
|
transitive: c,
|
|
2547
2546
|
symmetric: u,
|
|
2548
2547
|
reflexive: y,
|
|
2549
|
-
parentRelations:
|
|
2548
|
+
parentRelations: h,
|
|
2550
2549
|
iri: d,
|
|
2551
2550
|
wikidataPid: $,
|
|
2552
2551
|
displayName: k,
|
|
2553
2552
|
definition: g,
|
|
2554
|
-
description:
|
|
2553
|
+
description: p,
|
|
2555
2554
|
aliases: I,
|
|
2556
|
-
examples:
|
|
2557
|
-
tier:
|
|
2555
|
+
examples: b,
|
|
2556
|
+
tier: v = "confirmed"
|
|
2558
2557
|
} = {}) {
|
|
2559
|
-
const m = { name: e, tier:
|
|
2560
|
-
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),
|
|
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);
|
|
2561
2560
|
}
|
|
2562
2561
|
/**
|
|
2563
2562
|
* List ontology relation types, keyset-paginated. Mirror of `listTypes`.
|
|
@@ -2570,9 +2569,9 @@ class me {
|
|
|
2570
2569
|
* @param {string} [options.cursor] opaque keyset continuation token
|
|
2571
2570
|
*/
|
|
2572
2571
|
async listRelations({ tier: e, layer: t, packId: n, hasIri: s, limit: r = 100, cursor: i } = {}) {
|
|
2573
|
-
const
|
|
2574
|
-
e !== void 0 && (
|
|
2575
|
-
const c = new URLSearchParams(
|
|
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();
|
|
2576
2575
|
return this.api.get(`/memory/ontology/relations${c ? "?" + c : ""}`);
|
|
2577
2576
|
}
|
|
2578
2577
|
/**
|
|
@@ -2601,8 +2600,8 @@ class me {
|
|
|
2601
2600
|
async listAudit({ actor: e, action: t, since: n, until: s, limit: r = 200 } = {}) {
|
|
2602
2601
|
const i = { limit: String(r) };
|
|
2603
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);
|
|
2604
|
-
const
|
|
2605
|
-
return this.api.get(`/memory/ontology/audit${
|
|
2603
|
+
const o = new URLSearchParams(i).toString();
|
|
2604
|
+
return this.api.get(`/memory/ontology/audit${o ? "?" + o : ""}`);
|
|
2606
2605
|
}
|
|
2607
2606
|
/**
|
|
2608
2607
|
* Full append-only audit trail for one ontology type (oldest-first).
|
|
@@ -2678,8 +2677,8 @@ class me {
|
|
|
2678
2677
|
async listReviewQueue({ tier: e, assignee: t, source: n, limit: s = 100, cursor: r } = {}) {
|
|
2679
2678
|
const i = { limit: String(s) };
|
|
2680
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);
|
|
2681
|
-
const
|
|
2682
|
-
return this.api.get(`/memory/ontology/queue${
|
|
2680
|
+
const o = new URLSearchParams(i).toString();
|
|
2681
|
+
return this.api.get(`/memory/ontology/queue${o ? "?" + o : ""}`);
|
|
2683
2682
|
}
|
|
2684
2683
|
/**
|
|
2685
2684
|
* Approve one ontology review type.
|
|
@@ -2744,7 +2743,7 @@ class me {
|
|
|
2744
2743
|
return s !== void 0 && (r.expected_tier = s), this.api.post("/memory/ontology/queue/bulk", r);
|
|
2745
2744
|
}
|
|
2746
2745
|
}
|
|
2747
|
-
class
|
|
2746
|
+
class ae {
|
|
2748
2747
|
constructor(e) {
|
|
2749
2748
|
this.api = e;
|
|
2750
2749
|
}
|
|
@@ -2773,7 +2772,7 @@ class he {
|
|
|
2773
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);
|
|
2774
2773
|
}
|
|
2775
2774
|
}
|
|
2776
|
-
class
|
|
2775
|
+
class ce {
|
|
2777
2776
|
constructor(e) {
|
|
2778
2777
|
this.api = e;
|
|
2779
2778
|
}
|
|
@@ -2809,7 +2808,7 @@ class ye {
|
|
|
2809
2808
|
return this.api.get("/memory/inference/rules");
|
|
2810
2809
|
}
|
|
2811
2810
|
}
|
|
2812
|
-
class
|
|
2811
|
+
class ue {
|
|
2813
2812
|
constructor(e) {
|
|
2814
2813
|
this.api = e;
|
|
2815
2814
|
}
|
|
@@ -2925,7 +2924,7 @@ class pe {
|
|
|
2925
2924
|
return this.api.delete(`/memory/pipeline/configs/${e}`);
|
|
2926
2925
|
}
|
|
2927
2926
|
}
|
|
2928
|
-
class
|
|
2927
|
+
class le {
|
|
2929
2928
|
constructor(e) {
|
|
2930
2929
|
this.api = e;
|
|
2931
2930
|
}
|
|
@@ -2951,7 +2950,7 @@ class de {
|
|
|
2951
2950
|
return this.api.get(`/memory/archive/${e}`);
|
|
2952
2951
|
}
|
|
2953
2952
|
}
|
|
2954
|
-
class
|
|
2953
|
+
class me {
|
|
2955
2954
|
constructor(e) {
|
|
2956
2955
|
this.api = e;
|
|
2957
2956
|
}
|
|
@@ -3110,7 +3109,7 @@ class ge {
|
|
|
3110
3109
|
return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${n}`);
|
|
3111
3110
|
}
|
|
3112
3111
|
}
|
|
3113
|
-
class
|
|
3112
|
+
class pe {
|
|
3114
3113
|
constructor(e) {
|
|
3115
3114
|
this.api = e;
|
|
3116
3115
|
}
|
|
@@ -3146,7 +3145,7 @@ class fe {
|
|
|
3146
3145
|
return this.api.get("/memory/procedures/matches/stats");
|
|
3147
3146
|
}
|
|
3148
3147
|
}
|
|
3149
|
-
class
|
|
3148
|
+
class ye {
|
|
3150
3149
|
constructor(e) {
|
|
3151
3150
|
this.api = e;
|
|
3152
3151
|
}
|
|
@@ -3195,7 +3194,7 @@ class _e {
|
|
|
3195
3194
|
return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
|
|
3196
3195
|
}
|
|
3197
3196
|
}
|
|
3198
|
-
class
|
|
3197
|
+
class he {
|
|
3199
3198
|
constructor(e) {
|
|
3200
3199
|
this.api = e;
|
|
3201
3200
|
}
|
|
@@ -3250,7 +3249,7 @@ class $e {
|
|
|
3250
3249
|
return this.api.get(`/memory/procedures/schemas/${e}`);
|
|
3251
3250
|
}
|
|
3252
3251
|
}
|
|
3253
|
-
class
|
|
3252
|
+
class de {
|
|
3254
3253
|
constructor(e) {
|
|
3255
3254
|
this.api = e;
|
|
3256
3255
|
}
|
|
@@ -3322,7 +3321,7 @@ class ke {
|
|
|
3322
3321
|
return this.api.delete(`/memory/summary/${e}`);
|
|
3323
3322
|
}
|
|
3324
3323
|
}
|
|
3325
|
-
class
|
|
3324
|
+
class ge {
|
|
3326
3325
|
constructor(e) {
|
|
3327
3326
|
this.api = e;
|
|
3328
3327
|
}
|
|
@@ -3361,10 +3360,10 @@ class we {
|
|
|
3361
3360
|
return await this.api.post(`/memory/locks/${e}/renew`, s, {
|
|
3362
3361
|
headers: { "X-Lease-Token": t }
|
|
3363
3362
|
});
|
|
3364
|
-
} catch (
|
|
3365
|
-
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")
|
|
3366
3365
|
return null;
|
|
3367
|
-
throw
|
|
3366
|
+
throw o;
|
|
3368
3367
|
}
|
|
3369
3368
|
}
|
|
3370
3369
|
/**
|
|
@@ -3386,7 +3385,7 @@ class we {
|
|
|
3386
3385
|
}
|
|
3387
3386
|
}
|
|
3388
3387
|
}
|
|
3389
|
-
class
|
|
3388
|
+
class fe {
|
|
3390
3389
|
constructor(e) {
|
|
3391
3390
|
this.api = e;
|
|
3392
3391
|
}
|
|
@@ -3430,7 +3429,7 @@ class be {
|
|
|
3430
3429
|
}
|
|
3431
3430
|
}
|
|
3432
3431
|
}
|
|
3433
|
-
class
|
|
3432
|
+
class _e {
|
|
3434
3433
|
constructor(e) {
|
|
3435
3434
|
this.api = e;
|
|
3436
3435
|
}
|
|
@@ -3461,13 +3460,13 @@ class Ie {
|
|
|
3461
3460
|
*/
|
|
3462
3461
|
async pack({ budgetTokens: e, query: t, sections: n, preset: s } = {}) {
|
|
3463
3462
|
const r = { budget_tokens: e };
|
|
3464
|
-
return t != null && (r.query = t), n != null && (r.sections = n.map(({ name: i, cap_tokens:
|
|
3463
|
+
return t != null && (r.query = t), n != null && (r.sections = n.map(({ name: i, cap_tokens: o, capTokens: c }) => ({
|
|
3465
3464
|
name: i,
|
|
3466
|
-
cap_tokens:
|
|
3465
|
+
cap_tokens: o !== void 0 ? o : c
|
|
3467
3466
|
}))), s != null && (r.preset = s), this.api.post("/memory/recall/pack", r);
|
|
3468
3467
|
}
|
|
3469
3468
|
}
|
|
3470
|
-
class
|
|
3469
|
+
class $e {
|
|
3471
3470
|
constructor(e) {
|
|
3472
3471
|
this.api = e;
|
|
3473
3472
|
}
|
|
@@ -3496,17 +3495,23 @@ class Re {
|
|
|
3496
3495
|
return this.api.post("/memory/policy/events", e);
|
|
3497
3496
|
}
|
|
3498
3497
|
}
|
|
3499
|
-
class
|
|
3498
|
+
class Ie {
|
|
3500
3499
|
constructor(e) {
|
|
3501
|
-
this.auth = new
|
|
3502
|
-
const t = new
|
|
3503
|
-
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);
|
|
3503
|
+
}
|
|
3504
|
+
setWorkspaceId(e) {
|
|
3505
|
+
this.auth.tokenManager.setWorkspaceId(e), this.auth.notifyListeners();
|
|
3506
|
+
}
|
|
3507
|
+
getWorkspaceId() {
|
|
3508
|
+
return this.auth.tokenManager.getWorkspaceId();
|
|
3504
3509
|
}
|
|
3505
3510
|
setTeamId(e) {
|
|
3506
|
-
this.
|
|
3511
|
+
return this.setWorkspaceId(e);
|
|
3507
3512
|
}
|
|
3508
3513
|
getTeamId() {
|
|
3509
|
-
return this.
|
|
3514
|
+
return this.getWorkspaceId();
|
|
3510
3515
|
}
|
|
3511
3516
|
/**
|
|
3512
3517
|
* Export the current workspace as a gzipped OKF bundle.
|
|
@@ -3526,38 +3531,38 @@ class ve {
|
|
|
3526
3531
|
}
|
|
3527
3532
|
}
|
|
3528
3533
|
export {
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
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
|
|
3563
3568
|
};
|