@smartmemory/sdk-js 0.6.0 → 0.6.4
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 +27 -0
- package/dist/{core-CC81ya-7.js → core-BIdNSA4o.js} +237 -129
- package/dist/core.js +6 -6
- package/dist/fetch.js +19 -19
- package/dist/index.js +43 -35
- package/dist/react.js +9 -9
- package/package.json +21 -6
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @smartmemory/sdk-js
|
|
2
2
|
|
|
3
|
+
**Version:** 0.6.0
|
|
4
|
+
|
|
3
5
|
Unified JavaScript SDK for [SmartMemory](https://smartmemory.ai) — consolidates authentication and API client logic across all SmartMemory frontend applications.
|
|
4
6
|
|
|
5
7
|
## Features
|
|
@@ -117,6 +119,27 @@ const client = new SmartMemoryClient({
|
|
|
117
119
|
|
|
118
120
|
## Domain APIs
|
|
119
121
|
|
|
122
|
+
### Expertise Layer
|
|
123
|
+
|
|
124
|
+
SmartMemory's [expertise layer](https://docs.smartmemory.ai/smartmemory/concepts/expertise-vs-knowledge) — `decision`, `constraint`, `learned`, `opinion`, `reasoning`, `observation` — surfaces in this SDK via `client.decisions.create()` (with structured `rejectedAlternatives` / `rationale` / `constraints`) for capture and via `client.memories.search(query, { expertise: true })` for partitioned recall.
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
// Capture
|
|
128
|
+
await client.decisions.create({
|
|
129
|
+
title: 'Adopt FalkorDB',
|
|
130
|
+
rejectedAlternatives: ['Neo4j', 'Memgraph'],
|
|
131
|
+
rationale: 'Smallest ops surface; vector-native; permissive license.',
|
|
132
|
+
constraints: ['Must support Cypher subset'],
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Recall — typed-dict, partitioned by expertise type
|
|
136
|
+
const results = await client.memories.search('graph db choice', { expertise: true });
|
|
137
|
+
// { decision: [...], constraint: [...], learned: [...],
|
|
138
|
+
// opinion: [...], reasoning: [...], observation: [...] }
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Default `client.memories.search(query)` returns the flat list — no breaking change. The `{ expertise: true }` option switches the response shape; the SDK passes it through verbatim.
|
|
142
|
+
|
|
120
143
|
### Memories
|
|
121
144
|
|
|
122
145
|
```javascript
|
|
@@ -264,3 +287,7 @@ npm run build # production build
|
|
|
264
287
|
## License
|
|
265
288
|
|
|
266
289
|
MIT
|
|
290
|
+
|
|
291
|
+
## Documentation
|
|
292
|
+
|
|
293
|
+
Full SmartMemory documentation: https://docs.smartmemory.ai
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var
|
|
1
|
+
var I = (i) => {
|
|
2
2
|
throw TypeError(i);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
const
|
|
4
|
+
var $ = (i, e, t) => e.has(i) || I("Cannot " + t);
|
|
5
|
+
var p = (i, e, t) => ($(i, e, "read from private field"), t ? t.call(i) : e.get(i)), k = (i, e, t) => e.has(i) ? I("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), w = (i, e, t, r) => ($(i, e, "write to private field"), r ? r.call(i, t) : e.set(i, t), t), S = (i, e, t) => ($(i, e, "access private method"), t);
|
|
6
|
+
const v = {
|
|
7
7
|
access: "smart_memory_auth_token",
|
|
8
8
|
refresh: "smart_memory_refresh_token",
|
|
9
9
|
user: "smart_memory_user",
|
|
10
10
|
tenant: "smart_memory_tenant_id",
|
|
11
11
|
team: "smart_memory_team_id"
|
|
12
|
-
},
|
|
12
|
+
}, h = {
|
|
13
13
|
access: ["access_token", "sm_token"],
|
|
14
14
|
refresh: ["refresh_token", "sm_refresh_token"],
|
|
15
15
|
user: ["sm_user"],
|
|
16
16
|
tenant: ["tenant_id", "workspace_id", "sm_workspace_id"],
|
|
17
17
|
team: ["team_id", "sm_team_id"]
|
|
18
18
|
};
|
|
19
|
-
class
|
|
19
|
+
class A {
|
|
20
20
|
/**
|
|
21
21
|
* @param {Object} options
|
|
22
22
|
* @param {'localStorage' | 'sessionStorage' | 'memory'} [options.storage='localStorage']
|
|
23
23
|
* @param {Object} [options.keys] - Custom storage key names
|
|
24
24
|
*/
|
|
25
25
|
constructor({ storage: e = "localStorage", keys: t = {} } = {}) {
|
|
26
|
-
this.storageType = e, this.keys = { ...
|
|
26
|
+
this.storageType = e, this.keys = { ...v, ...t }, this._memory = { access: null, refresh: null, user: null, tenant: null, team: null };
|
|
27
27
|
}
|
|
28
28
|
getAccessToken() {
|
|
29
|
-
return this.storageType === "memory" ? this._memory.access : this._getFromStorage(this.keys.access,
|
|
29
|
+
return this.storageType === "memory" ? this._memory.access : this._getFromStorage(this.keys.access, h.access);
|
|
30
30
|
}
|
|
31
31
|
setAccessToken(e) {
|
|
32
32
|
if (this.storageType === "memory") {
|
|
@@ -36,7 +36,7 @@ class I {
|
|
|
36
36
|
this._setInStorage(this.keys.access, e);
|
|
37
37
|
}
|
|
38
38
|
getRefreshToken() {
|
|
39
|
-
return this.storageType === "memory" ? this._memory.refresh : this._getFromStorage(this.keys.refresh,
|
|
39
|
+
return this.storageType === "memory" ? this._memory.refresh : this._getFromStorage(this.keys.refresh, h.refresh);
|
|
40
40
|
}
|
|
41
41
|
setRefreshToken(e) {
|
|
42
42
|
if (this.storageType === "memory") {
|
|
@@ -47,7 +47,7 @@ class I {
|
|
|
47
47
|
}
|
|
48
48
|
getUser() {
|
|
49
49
|
if (this.storageType === "memory") return this._memory.user;
|
|
50
|
-
const e = this._getFromStorage(this.keys.user,
|
|
50
|
+
const e = this._getFromStorage(this.keys.user, h.user);
|
|
51
51
|
if (!e) return null;
|
|
52
52
|
try {
|
|
53
53
|
return JSON.parse(e);
|
|
@@ -63,7 +63,7 @@ class I {
|
|
|
63
63
|
this._setInStorage(this.keys.user, e ? JSON.stringify(e) : null);
|
|
64
64
|
}
|
|
65
65
|
getTenantId() {
|
|
66
|
-
return this.storageType === "memory" ? this._memory.tenant : this._normalizeId(this._getFromStorage(this.keys.tenant,
|
|
66
|
+
return this.storageType === "memory" ? this._memory.tenant : this._normalizeId(this._getFromStorage(this.keys.tenant, h.tenant));
|
|
67
67
|
}
|
|
68
68
|
setTenantId(e) {
|
|
69
69
|
const t = this._normalizeId(e);
|
|
@@ -74,7 +74,7 @@ class I {
|
|
|
74
74
|
this._setInStorage(this.keys.tenant, t);
|
|
75
75
|
}
|
|
76
76
|
getTeamId() {
|
|
77
|
-
return this.storageType === "memory" ? this._memory.team : this._normalizeId(this._getFromStorage(this.keys.team,
|
|
77
|
+
return this.storageType === "memory" ? this._memory.team : this._normalizeId(this._getFromStorage(this.keys.team, h.team));
|
|
78
78
|
}
|
|
79
79
|
setTeamId(e) {
|
|
80
80
|
const t = this._normalizeId(e);
|
|
@@ -94,27 +94,35 @@ class I {
|
|
|
94
94
|
localStorage.removeItem(e), sessionStorage.removeItem(e);
|
|
95
95
|
} catch {
|
|
96
96
|
}
|
|
97
|
-
for (const e of Object.values(
|
|
97
|
+
for (const e of Object.values(h))
|
|
98
98
|
for (const t of e)
|
|
99
99
|
try {
|
|
100
100
|
localStorage.removeItem(t), sessionStorage.removeItem(t);
|
|
101
101
|
} catch {
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
+
getImpersonationState() {
|
|
105
|
+
if (this.storageType === "memory") return null;
|
|
106
|
+
const e = sessionStorage.getItem("sm_impersonate_email");
|
|
107
|
+
return e ? { email: e } : null;
|
|
108
|
+
}
|
|
109
|
+
clearImpersonation() {
|
|
110
|
+
this.storageType !== "memory" && (sessionStorage.removeItem("sm_impersonate_token"), sessionStorage.removeItem("sm_impersonate_team"), sessionStorage.removeItem("sm_impersonate_tenant"), sessionStorage.removeItem("sm_impersonate_email"));
|
|
111
|
+
}
|
|
104
112
|
/** @private */
|
|
105
113
|
_getFromStorage(e, t = []) {
|
|
106
114
|
try {
|
|
107
115
|
const r = this.storageType === "localStorage" ? localStorage : sessionStorage, s = this.storageType === "localStorage" ? sessionStorage : localStorage, n = r.getItem(e) || s.getItem(e);
|
|
108
116
|
if (n != null) return n;
|
|
109
117
|
for (const a of t) {
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
this._setInStorage(e,
|
|
118
|
+
const c = r.getItem(a) || s.getItem(a);
|
|
119
|
+
if (c != null) {
|
|
120
|
+
this._setInStorage(e, c);
|
|
113
121
|
try {
|
|
114
122
|
r.removeItem(a), s.removeItem(a);
|
|
115
123
|
} catch {
|
|
116
124
|
}
|
|
117
|
-
return
|
|
125
|
+
return c;
|
|
118
126
|
}
|
|
119
127
|
}
|
|
120
128
|
return null;
|
|
@@ -140,8 +148,8 @@ class I {
|
|
|
140
148
|
return r === "none" || r === "null" || r === "undefined" ? null : t;
|
|
141
149
|
}
|
|
142
150
|
}
|
|
143
|
-
var
|
|
144
|
-
class
|
|
151
|
+
var m, d, T;
|
|
152
|
+
class R {
|
|
145
153
|
/**
|
|
146
154
|
* @param {Object} options
|
|
147
155
|
* @param {string} options.apiBaseUrl
|
|
@@ -152,22 +160,22 @@ class T {
|
|
|
152
160
|
* @param {function(): void} options.onRefreshFailed
|
|
153
161
|
*/
|
|
154
162
|
constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager: r, useCookieAuth: s = !1, onTokenRefreshed: n, onRefreshFailed: a }) {
|
|
155
|
-
|
|
156
|
-
|
|
163
|
+
k(this, d);
|
|
164
|
+
k(this, m, null);
|
|
157
165
|
this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager = r, this.useCookieAuth = s, this.onTokenRefreshed = n, this.onRefreshFailed = a;
|
|
158
166
|
}
|
|
159
167
|
async refresh() {
|
|
160
|
-
if (
|
|
161
|
-
return
|
|
162
|
-
|
|
168
|
+
if (p(this, m))
|
|
169
|
+
return p(this, m);
|
|
170
|
+
w(this, m, S(this, d, T).call(this));
|
|
163
171
|
try {
|
|
164
|
-
return await
|
|
172
|
+
return await p(this, m);
|
|
165
173
|
} finally {
|
|
166
|
-
|
|
174
|
+
w(this, m, null);
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
177
|
}
|
|
170
|
-
|
|
178
|
+
m = new WeakMap(), d = new WeakSet(), T = async function() {
|
|
171
179
|
const e = this.tokenManager.getRefreshToken();
|
|
172
180
|
if (!e && !this.useCookieAuth)
|
|
173
181
|
throw this.onRefreshFailed(), new Error("No refresh token");
|
|
@@ -182,8 +190,8 @@ l = new WeakMap(), y = new WeakSet(), k = async function() {
|
|
|
182
190
|
const s = await r.json();
|
|
183
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;
|
|
184
192
|
};
|
|
185
|
-
const
|
|
186
|
-
class
|
|
193
|
+
const b = "smart_memory_sso_redirect";
|
|
194
|
+
class U {
|
|
187
195
|
/**
|
|
188
196
|
* @param {Object} options
|
|
189
197
|
* @param {string} options.webAppUrl - Web app URL for login redirect
|
|
@@ -208,26 +216,26 @@ class S {
|
|
|
208
216
|
}
|
|
209
217
|
storeRedirect(e) {
|
|
210
218
|
try {
|
|
211
|
-
sessionStorage.setItem(
|
|
219
|
+
sessionStorage.setItem(b, e);
|
|
212
220
|
} catch (t) {
|
|
213
221
|
console.warn("Failed to store redirect URL:", t);
|
|
214
222
|
}
|
|
215
223
|
}
|
|
216
224
|
getAndClearRedirect() {
|
|
217
225
|
try {
|
|
218
|
-
const e = sessionStorage.getItem(
|
|
219
|
-
return sessionStorage.removeItem(
|
|
226
|
+
const e = sessionStorage.getItem(b);
|
|
227
|
+
return sessionStorage.removeItem(b), e;
|
|
220
228
|
} catch {
|
|
221
229
|
return null;
|
|
222
230
|
}
|
|
223
231
|
}
|
|
224
232
|
}
|
|
225
|
-
class
|
|
233
|
+
class P {
|
|
226
234
|
constructor(e) {
|
|
227
|
-
this.mode = e.mode, this.apiBaseUrl = e.apiBaseUrl, this.endpoints = e.endpoints || {}, this.listeners = /* @__PURE__ */ new Set(), this.useCookieAuth = e.useCookieAuth ?? this.mode === "sso", this.apiKey = e.apiKey || null, this.apiKey && (this.mode = "apiKey"), this.tokenManager = new
|
|
235
|
+
this.mode = e.mode, this.apiBaseUrl = e.apiBaseUrl, this.endpoints = e.endpoints || {}, this.listeners = /* @__PURE__ */ new Set(), this.useCookieAuth = e.useCookieAuth ?? this.mode === "sso", this.apiKey = e.apiKey || null, this.apiKey && (this.mode = "apiKey"), this.tokenManager = new A({
|
|
228
236
|
storage: e.storage || "localStorage",
|
|
229
237
|
keys: e.tokenKeys
|
|
230
|
-
}), this.mode !== "apiKey" ? this.refreshManager = new
|
|
238
|
+
}), this.mode !== "apiKey" ? this.refreshManager = new R({
|
|
231
239
|
apiBaseUrl: this.apiBaseUrl,
|
|
232
240
|
refreshEndpoint: this.endpoints.refresh || "/auth/refresh",
|
|
233
241
|
tokenManager: this.tokenManager,
|
|
@@ -239,7 +247,7 @@ class A {
|
|
|
239
247
|
onRefreshFailed: () => {
|
|
240
248
|
this.clearLocalAuth();
|
|
241
249
|
}
|
|
242
|
-
}) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new
|
|
250
|
+
}) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new U({
|
|
243
251
|
webAppUrl: e.webAppUrl,
|
|
244
252
|
allowedHosts: e.allowedRedirectHosts || [],
|
|
245
253
|
tokenManager: this.tokenManager
|
|
@@ -358,7 +366,7 @@ class A {
|
|
|
358
366
|
this.tokenManager.setTenantId(e), this.notifyListeners();
|
|
359
367
|
}
|
|
360
368
|
}
|
|
361
|
-
class
|
|
369
|
+
class g extends Error {
|
|
362
370
|
/**
|
|
363
371
|
* @param {string} message - Error message
|
|
364
372
|
* @param {number} [status=0] - HTTP status code (0 for network errors)
|
|
@@ -368,7 +376,7 @@ class h extends Error {
|
|
|
368
376
|
super(e), this.name = "APIError", this.status = t, this.detail = r;
|
|
369
377
|
}
|
|
370
378
|
}
|
|
371
|
-
class
|
|
379
|
+
class C {
|
|
372
380
|
/**
|
|
373
381
|
* @param {import('../auth/AuthCore.js').AuthCore} authCore
|
|
374
382
|
* @param {{ fetchFn?: typeof globalThis.fetch }} [options]
|
|
@@ -377,38 +385,38 @@ class v {
|
|
|
377
385
|
this.auth = e, this.baseURL = e.apiBaseUrl, this._customFetchFn = t || null;
|
|
378
386
|
}
|
|
379
387
|
get fetchFn() {
|
|
380
|
-
return this._customFetchFn || globalThis.fetch;
|
|
388
|
+
return this._customFetchFn || globalThis.fetch.bind(globalThis);
|
|
381
389
|
}
|
|
382
390
|
async request(e, t = {}) {
|
|
383
|
-
var a,
|
|
391
|
+
var a, c;
|
|
384
392
|
const r = `${this.baseURL}${e}`, s = {
|
|
385
393
|
"Content-Type": "application/json",
|
|
386
394
|
...this.auth.getAuthHeaders(t.headers)
|
|
387
395
|
}, n = this.auth.getRequestOptions({ ...t, headers: s });
|
|
388
396
|
try {
|
|
389
|
-
let
|
|
390
|
-
if (
|
|
397
|
+
let o = await this.fetchFn(r, n);
|
|
398
|
+
if (o.status === 401 && !t.__isRetry)
|
|
391
399
|
try {
|
|
392
400
|
await this.auth.refreshToken();
|
|
393
|
-
const
|
|
401
|
+
const u = {
|
|
394
402
|
"Content-Type": "application/json",
|
|
395
403
|
...this.auth.getAuthHeaders(t.headers)
|
|
396
404
|
};
|
|
397
|
-
|
|
405
|
+
o = await this.fetchFn(
|
|
398
406
|
r,
|
|
399
|
-
this.auth.getRequestOptions({ ...n, headers:
|
|
407
|
+
this.auth.getRequestOptions({ ...n, headers: u, __isRetry: !0 })
|
|
400
408
|
);
|
|
401
409
|
} catch {
|
|
402
410
|
}
|
|
403
|
-
if (
|
|
404
|
-
throw (
|
|
405
|
-
if (
|
|
411
|
+
if (o.status === 401)
|
|
412
|
+
throw (c = (a = this.auth).clearLocalAuth) == null || c.call(a), new g("Authentication required", 401, "auth_expired");
|
|
413
|
+
if (o.status === 204)
|
|
406
414
|
return null;
|
|
407
|
-
if (!
|
|
408
|
-
throw await this._handleError(
|
|
409
|
-
return await
|
|
410
|
-
} catch (
|
|
411
|
-
throw
|
|
415
|
+
if (!o.ok)
|
|
416
|
+
throw await this._handleError(o);
|
|
417
|
+
return await o.json();
|
|
418
|
+
} catch (o) {
|
|
419
|
+
throw o instanceof g ? o : new g(o.message, 0, "network_error");
|
|
412
420
|
}
|
|
413
421
|
}
|
|
414
422
|
async get(e, t = {}) {
|
|
@@ -448,14 +456,14 @@ class v {
|
|
|
448
456
|
} catch {
|
|
449
457
|
t = { message: `HTTP ${e.status}` };
|
|
450
458
|
}
|
|
451
|
-
return new
|
|
459
|
+
return new g(
|
|
452
460
|
t.detail || t.message || `HTTP ${e.status}`,
|
|
453
461
|
e.status,
|
|
454
462
|
t
|
|
455
463
|
);
|
|
456
464
|
}
|
|
457
465
|
}
|
|
458
|
-
class
|
|
466
|
+
class L {
|
|
459
467
|
constructor(e) {
|
|
460
468
|
this.api = e;
|
|
461
469
|
}
|
|
@@ -467,14 +475,14 @@ class R {
|
|
|
467
475
|
profileName: n = null,
|
|
468
476
|
conversationContext: a = null
|
|
469
477
|
}) {
|
|
470
|
-
const
|
|
478
|
+
const c = {
|
|
471
479
|
content: e,
|
|
472
480
|
memory_type: t,
|
|
473
481
|
metadata: r,
|
|
474
482
|
use_pipeline: s,
|
|
475
483
|
profile_name: n
|
|
476
484
|
};
|
|
477
|
-
return a != null && (
|
|
485
|
+
return a != null && (c.conversation_context = a), this.api.post("/memory/add", c);
|
|
478
486
|
}
|
|
479
487
|
async get(e) {
|
|
480
488
|
const t = await this.api.get(`/memory/${e}`);
|
|
@@ -503,9 +511,33 @@ class R {
|
|
|
503
511
|
let s = `/memory/list?limit=${e}&offset=${t}`;
|
|
504
512
|
return r && (s += `&memory_type=${r}`), this.api.get(s);
|
|
505
513
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
514
|
+
/**
|
|
515
|
+
* Search for memory items.
|
|
516
|
+
*
|
|
517
|
+
* @param {string} query - Search query string.
|
|
518
|
+
* @param {object} [options]
|
|
519
|
+
* @param {number} [options.topK=5]
|
|
520
|
+
* @param {boolean} [options.enableHybrid=true]
|
|
521
|
+
* @param {string|null} [options.memoryType=null]
|
|
522
|
+
* @param {boolean} [options.expertise=false] - When true (CORE-EXPERTISE-1 Phase 4a),
|
|
523
|
+
* the response shape changes from a flat list to `{results: {<expertise_type>: [items]}}`
|
|
524
|
+
* keyed by expertise type (decision, constraint, learned, opinion, reasoning, observation).
|
|
525
|
+
* Each bucket holds up to topK items.
|
|
526
|
+
* @param {boolean} [options.cite=false] - When true (RECALL-CITATIONS-1), the
|
|
527
|
+
* envelope gains a `citations` array of `{n, item_id, item_type, preview, score, footnote_marker}`.
|
|
528
|
+
* Empty `citations: []` when no results — distinguishes "no results" from "no citations requested".
|
|
529
|
+
* @returns {Promise<{results: Array|Object, group_roots: Object, citations?: Array}>}
|
|
530
|
+
* CORE-RECALL-LINEAGE-1: the response is ALWAYS a `SearchResponse` envelope —
|
|
531
|
+
* `results` is a flat array by default and a `{bucket: [...]}` map under
|
|
532
|
+
* `expertise: true`; `group_roots` is always present (possibly `{}`) and
|
|
533
|
+
* carries `GroupRootStub`s for any lineage root_id referenced by some
|
|
534
|
+
* result's `lineage_roots` but not itself in `results`; `citations` is
|
|
535
|
+
* present only under `cite: true`. Pre-LINEAGE-1 callers who indexed into a
|
|
536
|
+
* bare array must read `response.results` instead.
|
|
537
|
+
*/
|
|
538
|
+
async search(e, { topK: t = 5, enableHybrid: r = !0, memoryType: s = null, expertise: n = !1, cite: a = !1, decompose: c = !1, multiHop: o = !1, maxHops: u = 3, budgetMs: y = 1500, semanticHops: f = !1, includeReference: _ = !1 } = {}) {
|
|
539
|
+
const l = { query: e, top_k: t, enable_hybrid: r };
|
|
540
|
+
return s && (l.memory_type = s), n && (l.expertise = !0), a && (l.cite = !0), c && (l.decompose = !0), o && (l.multi_hop = !0), o && u !== 3 && (l.max_hops = u), o && y !== 1500 && (l.budget_ms = y), o && f && (l.semantic_hops = !0), _ && (l.include_reference = !0), this.api.post("/memory/search", l);
|
|
509
541
|
}
|
|
510
542
|
async getWorkingContext(e, t, { k: r = 20, maxTokens: s = null, strategy: n = null } = {}) {
|
|
511
543
|
const a = {
|
|
@@ -553,10 +585,10 @@ class R {
|
|
|
553
585
|
sessionDates: s = null,
|
|
554
586
|
turnsPerChunk: n = 15,
|
|
555
587
|
maxChunkChars: a = 12e3,
|
|
556
|
-
maxConcurrent:
|
|
588
|
+
maxConcurrent: c = 4
|
|
557
589
|
} = {}) {
|
|
558
|
-
const
|
|
559
|
-
return t && (
|
|
590
|
+
const o = { turns: e, turns_per_chunk: n, max_chunk_chars: a, max_concurrent: c };
|
|
591
|
+
return t && (o.session_boundaries = t), r && (o.conversation_id = r), s && (o.session_dates = s), this.api.post("/memory/ingest/conversation", o);
|
|
560
592
|
}
|
|
561
593
|
async ingestDocument(e, { title: t = null, source: r = null, chunkStrategy: s = null } = {}) {
|
|
562
594
|
const n = { content: e };
|
|
@@ -668,7 +700,7 @@ class R {
|
|
|
668
700
|
return this.api.get("/memory/clustering/stats");
|
|
669
701
|
}
|
|
670
702
|
}
|
|
671
|
-
class
|
|
703
|
+
class M {
|
|
672
704
|
constructor(e) {
|
|
673
705
|
this.api = e;
|
|
674
706
|
}
|
|
@@ -683,6 +715,9 @@ class U {
|
|
|
683
715
|
* @param {string[]} [params.evidenceIds]
|
|
684
716
|
* @param {string} [params.domain]
|
|
685
717
|
* @param {string[]} [params.tags]
|
|
718
|
+
* @param {string} [params.agentId] - Producing agent id (CORE-AGENT-ATTRIBUTION-1).
|
|
719
|
+
* When omitted, the backend auto-populates from scope.resolve_agent_id() —
|
|
720
|
+
* non-null only when the caller's user_type=='agent'.
|
|
686
721
|
*/
|
|
687
722
|
async create({
|
|
688
723
|
content: e,
|
|
@@ -691,8 +726,12 @@ class U {
|
|
|
691
726
|
sourceTraceId: s = null,
|
|
692
727
|
sourceSessionId: n = null,
|
|
693
728
|
evidenceIds: a = null,
|
|
694
|
-
domain:
|
|
695
|
-
tags:
|
|
729
|
+
domain: c = null,
|
|
730
|
+
tags: o = null,
|
|
731
|
+
rejectedAlternatives: u = null,
|
|
732
|
+
rationale: y = null,
|
|
733
|
+
constraints: f = null,
|
|
734
|
+
agentId: _ = null
|
|
696
735
|
}) {
|
|
697
736
|
return this.api.post("/memory/decisions/create", {
|
|
698
737
|
content: e,
|
|
@@ -701,13 +740,28 @@ class U {
|
|
|
701
740
|
source_trace_id: s,
|
|
702
741
|
source_session_id: n,
|
|
703
742
|
evidence_ids: a,
|
|
704
|
-
domain:
|
|
705
|
-
tags:
|
|
743
|
+
domain: c,
|
|
744
|
+
tags: o,
|
|
745
|
+
rejected_alternatives: u,
|
|
746
|
+
rationale: y,
|
|
747
|
+
constraints: f,
|
|
748
|
+
agent_id: _
|
|
706
749
|
});
|
|
707
750
|
}
|
|
708
751
|
/**
|
|
709
752
|
* List active decisions with optional filters.
|
|
710
|
-
* @param {Object} [params] - Query parameters
|
|
753
|
+
* @param {Object} [params] - Query parameters
|
|
754
|
+
* @param {string} [params.domain] - Filter by domain
|
|
755
|
+
* @param {string} [params.decision_type] - Filter by decision type
|
|
756
|
+
* @param {number} [params.min_confidence=0.0] - Minimum confidence (0..1)
|
|
757
|
+
* @param {number} [params.limit=50] - Maximum results
|
|
758
|
+
* @param {string} [params.agent_id] - Filter by producing agent id
|
|
759
|
+
* (CORE-AGENT-ATTRIBUTION-1). NULL-valued rows are excluded when set.
|
|
760
|
+
* @param {string} [params.provenance_memory_id] - Inverse-provenance filter
|
|
761
|
+
* (CORE-DECISION-PROVENANCE-LOOKUP-1). When set, returns only decisions whose
|
|
762
|
+
* provenance subgraph contains this memory id. Filters compose in-query so
|
|
763
|
+
* the response never silently truncates below `limit` when more matches exist.
|
|
764
|
+
* Unknown or out-of-scope memory ids return an empty list (never 404).
|
|
711
765
|
*/
|
|
712
766
|
async list(e = {}) {
|
|
713
767
|
const t = new URLSearchParams(e).toString();
|
|
@@ -823,7 +877,29 @@ class U {
|
|
|
823
877
|
});
|
|
824
878
|
}
|
|
825
879
|
}
|
|
826
|
-
class
|
|
880
|
+
class z {
|
|
881
|
+
constructor(e) {
|
|
882
|
+
this.api = e;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Create a new opinion with optional agent attribution.
|
|
886
|
+
* @param {string} content - Opinion content (required).
|
|
887
|
+
* @param {Object} [opts]
|
|
888
|
+
* @param {number} [opts.confidence] - Initial confidence (0..1).
|
|
889
|
+
* @param {string} [opts.subject] - What the opinion is about.
|
|
890
|
+
* @param {string} [opts.subjectType] - Type tag for the subject.
|
|
891
|
+
* @param {Object} [opts.disposition] - Disposition payload.
|
|
892
|
+
* @param {string[]} [opts.formedFrom] - Source memory ids that formed it.
|
|
893
|
+
* @param {string} [opts.domain] - Domain tag for filtered retrieval.
|
|
894
|
+
* @param {string} [opts.agentId] - Producing agent id; omit to let the
|
|
895
|
+
* server auto-populate from scope.resolve_agent_id().
|
|
896
|
+
*/
|
|
897
|
+
async createOpinion(e, t = {}) {
|
|
898
|
+
const r = { content: e };
|
|
899
|
+
return t.confidence !== void 0 && (r.confidence = t.confidence), t.subject !== void 0 && (r.subject = t.subject), t.subjectType !== void 0 && (r.subject_type = t.subjectType), t.disposition !== void 0 && (r.disposition = t.disposition), t.formedFrom !== void 0 && (r.formed_from = t.formedFrom), t.domain !== void 0 && (r.domain = t.domain), t.agentId !== void 0 && (r.agent_id = t.agentId), this.api.post("/memory/opinions/create", r);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
class E {
|
|
827
903
|
constructor(e) {
|
|
828
904
|
this.api = e;
|
|
829
905
|
}
|
|
@@ -909,7 +985,7 @@ class P {
|
|
|
909
985
|
return this.api.get(`/memory/${encodeURIComponent(e)}/links`);
|
|
910
986
|
}
|
|
911
987
|
}
|
|
912
|
-
class
|
|
988
|
+
class O {
|
|
913
989
|
constructor(e) {
|
|
914
990
|
this.api = e;
|
|
915
991
|
}
|
|
@@ -949,7 +1025,7 @@ class C {
|
|
|
949
1025
|
return this.api.delete(`/memory/teams/${e}/members/${t}`);
|
|
950
1026
|
}
|
|
951
1027
|
}
|
|
952
|
-
class
|
|
1028
|
+
class x {
|
|
953
1029
|
constructor(e) {
|
|
954
1030
|
this.api = e;
|
|
955
1031
|
}
|
|
@@ -966,7 +1042,7 @@ class M {
|
|
|
966
1042
|
return this.api.patch("/auth/llm-keys", e);
|
|
967
1043
|
}
|
|
968
1044
|
}
|
|
969
|
-
class
|
|
1045
|
+
class q {
|
|
970
1046
|
constructor(e) {
|
|
971
1047
|
this.api = e;
|
|
972
1048
|
}
|
|
@@ -992,7 +1068,7 @@ class L {
|
|
|
992
1068
|
});
|
|
993
1069
|
}
|
|
994
1070
|
}
|
|
995
|
-
class
|
|
1071
|
+
class j {
|
|
996
1072
|
constructor(e) {
|
|
997
1073
|
this.api = e;
|
|
998
1074
|
}
|
|
@@ -1013,7 +1089,7 @@ class z {
|
|
|
1013
1089
|
return this.api.delete(`/memory/api-keys/${e}`);
|
|
1014
1090
|
}
|
|
1015
1091
|
}
|
|
1016
|
-
class
|
|
1092
|
+
class F {
|
|
1017
1093
|
constructor(e) {
|
|
1018
1094
|
this.api = e;
|
|
1019
1095
|
}
|
|
@@ -1040,8 +1116,39 @@ class E {
|
|
|
1040
1116
|
async setRecallProfile(e, t) {
|
|
1041
1117
|
return this.api.put(`/memory/agents/${e}/recall-profile`, { recall_profile: t });
|
|
1042
1118
|
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Get the current evaluation for an agent on a given (dimension, domain) slot.
|
|
1121
|
+
*
|
|
1122
|
+
* CORE-AGENT-2 S03-T11. Returns { evaluation: object | null }.
|
|
1123
|
+
* null means no evaluation has been written yet (cold-start) — not an error.
|
|
1124
|
+
*
|
|
1125
|
+
* @param {string} agentId - Agent identifier.
|
|
1126
|
+
* @param {string} dimension - Performance dimension (e.g. "decision_volume").
|
|
1127
|
+
* @param {string} domain - Domain string (e.g. "python").
|
|
1128
|
+
* @returns {Promise<{evaluation: object|null}>}
|
|
1129
|
+
*/
|
|
1130
|
+
async getEvaluation(e, t, r) {
|
|
1131
|
+
const s = new URLSearchParams({ dimension: t, domain: r }).toString();
|
|
1132
|
+
return this.api.get(`/memory/agents/${e}/evaluation${s ? "?" + s : ""}`);
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Get evaluation history for an agent on a given (dimension, domain) slot.
|
|
1136
|
+
*
|
|
1137
|
+
* CORE-AGENT-2 S03-T11. Returns { history: object[] } sorted most-recent-first.
|
|
1138
|
+
*
|
|
1139
|
+
* @param {string} agentId - Agent identifier.
|
|
1140
|
+
* @param {string} dimension - Performance dimension.
|
|
1141
|
+
* @param {string} domain - Domain string.
|
|
1142
|
+
* @param {object} [options]
|
|
1143
|
+
* @param {number} [options.limit=20] - Maximum records to return.
|
|
1144
|
+
* @returns {Promise<{history: object[]}>}
|
|
1145
|
+
*/
|
|
1146
|
+
async listEvaluationHistory(e, t, r, { limit: s = 20 } = {}) {
|
|
1147
|
+
const n = new URLSearchParams({ dimension: t, domain: r, limit: String(s) }).toString();
|
|
1148
|
+
return this.api.get(`/memory/agents/${e}/evaluation/history${n ? "?" + n : ""}`);
|
|
1149
|
+
}
|
|
1043
1150
|
}
|
|
1044
|
-
class
|
|
1151
|
+
class K {
|
|
1045
1152
|
constructor(e) {
|
|
1046
1153
|
this.api = e;
|
|
1047
1154
|
}
|
|
@@ -1055,7 +1162,7 @@ class x {
|
|
|
1055
1162
|
return this.api.get("/usage/tiers");
|
|
1056
1163
|
}
|
|
1057
1164
|
}
|
|
1058
|
-
class
|
|
1165
|
+
class H {
|
|
1059
1166
|
constructor(e) {
|
|
1060
1167
|
this.api = e;
|
|
1061
1168
|
}
|
|
@@ -1072,7 +1179,7 @@ class O {
|
|
|
1072
1179
|
return this.api.get("/memory/plugins");
|
|
1073
1180
|
}
|
|
1074
1181
|
}
|
|
1075
|
-
class
|
|
1182
|
+
class B {
|
|
1076
1183
|
constructor(e) {
|
|
1077
1184
|
this.api = e;
|
|
1078
1185
|
}
|
|
@@ -1095,7 +1202,7 @@ class q {
|
|
|
1095
1202
|
return this.api.get("/memory/token-usage/current");
|
|
1096
1203
|
}
|
|
1097
1204
|
}
|
|
1098
|
-
class
|
|
1205
|
+
class D {
|
|
1099
1206
|
constructor(e) {
|
|
1100
1207
|
this.api = e;
|
|
1101
1208
|
}
|
|
@@ -1181,8 +1288,8 @@ class F {
|
|
|
1181
1288
|
*/
|
|
1182
1289
|
async getAuditTrail(e, { changeType: t = null, userId: r = null, startTime: s = null, endTime: n = null } = {}) {
|
|
1183
1290
|
let a = `/memory/temporal/${e}/audit`;
|
|
1184
|
-
const
|
|
1185
|
-
return t &&
|
|
1291
|
+
const c = [];
|
|
1292
|
+
return t && c.push(`change_type=${t}`), r && c.push(`user_id=${r}`), s && c.push(`start_time=${s}`), n && c.push(`end_time=${n}`), c.length && (a += `?${c.join("&")}`), this.api.get(a);
|
|
1186
1293
|
}
|
|
1187
1294
|
// === TEMPORAL SEARCH ===
|
|
1188
1295
|
/**
|
|
@@ -1241,7 +1348,7 @@ class F {
|
|
|
1241
1348
|
return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
|
|
1242
1349
|
}
|
|
1243
1350
|
}
|
|
1244
|
-
class
|
|
1351
|
+
class G {
|
|
1245
1352
|
constructor(e) {
|
|
1246
1353
|
this.api = e;
|
|
1247
1354
|
}
|
|
@@ -1310,7 +1417,7 @@ class H {
|
|
|
1310
1417
|
return this.api.get("/memory/governance/summary");
|
|
1311
1418
|
}
|
|
1312
1419
|
}
|
|
1313
|
-
class
|
|
1420
|
+
class N {
|
|
1314
1421
|
constructor(e) {
|
|
1315
1422
|
this.api = e;
|
|
1316
1423
|
}
|
|
@@ -1351,7 +1458,7 @@ class j {
|
|
|
1351
1458
|
return this.api.post("/memory/evolution/reinforce/opinions");
|
|
1352
1459
|
}
|
|
1353
1460
|
}
|
|
1354
|
-
class
|
|
1461
|
+
class V {
|
|
1355
1462
|
constructor(e) {
|
|
1356
1463
|
this.api = e;
|
|
1357
1464
|
}
|
|
@@ -1449,7 +1556,7 @@ class K {
|
|
|
1449
1556
|
});
|
|
1450
1557
|
}
|
|
1451
1558
|
}
|
|
1452
|
-
class
|
|
1559
|
+
class J {
|
|
1453
1560
|
constructor(e) {
|
|
1454
1561
|
this.api = e;
|
|
1455
1562
|
}
|
|
@@ -1503,7 +1610,7 @@ class B {
|
|
|
1503
1610
|
return this.api.get(`/memory/reasoning/traces/${e}`);
|
|
1504
1611
|
}
|
|
1505
1612
|
}
|
|
1506
|
-
class
|
|
1613
|
+
class W {
|
|
1507
1614
|
constructor(e) {
|
|
1508
1615
|
this.api = e;
|
|
1509
1616
|
}
|
|
@@ -1871,7 +1978,7 @@ class D {
|
|
|
1871
1978
|
return this.api.get(`/memory/ontology/updates/stats?history=${e}`);
|
|
1872
1979
|
}
|
|
1873
1980
|
}
|
|
1874
|
-
class
|
|
1981
|
+
class Y {
|
|
1875
1982
|
constructor(e) {
|
|
1876
1983
|
this.api = e;
|
|
1877
1984
|
}
|
|
@@ -1900,7 +2007,7 @@ class G {
|
|
|
1900
2007
|
return e !== null && (s.protected_attributes = e), t !== null && (s.sentiment_analysis = t), r !== null && (s.topic_analysis = r), this.api.post("/memory/analytics/bias", s);
|
|
1901
2008
|
}
|
|
1902
2009
|
}
|
|
1903
|
-
class
|
|
2010
|
+
class Z {
|
|
1904
2011
|
constructor(e) {
|
|
1905
2012
|
this.api = e;
|
|
1906
2013
|
}
|
|
@@ -1936,7 +2043,7 @@ class N {
|
|
|
1936
2043
|
return this.api.get("/memory/validation/inference/rules");
|
|
1937
2044
|
}
|
|
1938
2045
|
}
|
|
1939
|
-
class
|
|
2046
|
+
class X {
|
|
1940
2047
|
constructor(e) {
|
|
1941
2048
|
this.api = e;
|
|
1942
2049
|
}
|
|
@@ -2052,7 +2159,7 @@ class V {
|
|
|
2052
2159
|
return this.api.delete(`/memory/pipeline/configs/${e}`);
|
|
2053
2160
|
}
|
|
2054
2161
|
}
|
|
2055
|
-
class
|
|
2162
|
+
class Q {
|
|
2056
2163
|
constructor(e) {
|
|
2057
2164
|
this.api = e;
|
|
2058
2165
|
}
|
|
@@ -2078,7 +2185,7 @@ class J {
|
|
|
2078
2185
|
return this.api.get(`/memory/archive/${e}`);
|
|
2079
2186
|
}
|
|
2080
2187
|
}
|
|
2081
|
-
class
|
|
2188
|
+
class ee {
|
|
2082
2189
|
constructor(e) {
|
|
2083
2190
|
this.api = e;
|
|
2084
2191
|
}
|
|
@@ -2237,7 +2344,7 @@ class W {
|
|
|
2237
2344
|
return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${r}`);
|
|
2238
2345
|
}
|
|
2239
2346
|
}
|
|
2240
|
-
class
|
|
2347
|
+
class te {
|
|
2241
2348
|
constructor(e) {
|
|
2242
2349
|
this.api = e;
|
|
2243
2350
|
}
|
|
@@ -2273,7 +2380,7 @@ class Y {
|
|
|
2273
2380
|
return this.api.get("/memory/procedures/matches/stats");
|
|
2274
2381
|
}
|
|
2275
2382
|
}
|
|
2276
|
-
class
|
|
2383
|
+
class re {
|
|
2277
2384
|
constructor(e) {
|
|
2278
2385
|
this.api = e;
|
|
2279
2386
|
}
|
|
@@ -2322,7 +2429,7 @@ class Z {
|
|
|
2322
2429
|
return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
|
|
2323
2430
|
}
|
|
2324
2431
|
}
|
|
2325
|
-
class
|
|
2432
|
+
class se {
|
|
2326
2433
|
constructor(e) {
|
|
2327
2434
|
this.api = e;
|
|
2328
2435
|
}
|
|
@@ -2377,7 +2484,7 @@ class X {
|
|
|
2377
2484
|
return this.api.get(`/memory/procedures/schemas/${e}`);
|
|
2378
2485
|
}
|
|
2379
2486
|
}
|
|
2380
|
-
class
|
|
2487
|
+
class ne {
|
|
2381
2488
|
constructor(e) {
|
|
2382
2489
|
this.api = e;
|
|
2383
2490
|
}
|
|
@@ -2449,11 +2556,11 @@ class Q {
|
|
|
2449
2556
|
return this.api.delete(`/memory/summary/${e}`);
|
|
2450
2557
|
}
|
|
2451
2558
|
}
|
|
2452
|
-
class
|
|
2559
|
+
class ae {
|
|
2453
2560
|
constructor(e) {
|
|
2454
|
-
this.auth = new
|
|
2455
|
-
const t = new
|
|
2456
|
-
this.memories = new
|
|
2561
|
+
this.auth = new P(e);
|
|
2562
|
+
const t = new C(this.auth, { fetchFn: e.fetchFn });
|
|
2563
|
+
this.memories = new L(t), this.decisions = new M(t), this.opinions = new z(t), this.graph = new E(t), this.teams = new O(t), this.profiles = new x(t), this.subscriptions = new q(t), this.authAPI = new j(t), this.agents = new F(t), this.usage = new K(t), this.insights = new H(t), this.tokenUsage = new B(t), this.temporal = new D(t), this.governance = new G(t), this.evolution = new N(t), this.reasoning = new V(t), this.reasoningTraces = new J(t), this.ontology = new W(t), this.analytics = new Y(t), this.validation = new Z(t), this.pipeline = new X(t), this.archive = new Q(t), this.zettelkasten = new ee(t), this.procedureMatches = new te(t), this.procedureCandidates = new re(t), this.procedureDrift = new se(t), this.summaries = new ne(t);
|
|
2457
2564
|
}
|
|
2458
2565
|
setTeamId(e) {
|
|
2459
2566
|
this.auth.tokenManager.setTeamId(e), this.auth.notifyListeners();
|
|
@@ -2463,35 +2570,36 @@ class te {
|
|
|
2463
2570
|
}
|
|
2464
2571
|
}
|
|
2465
2572
|
export {
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2573
|
+
g as A,
|
|
2574
|
+
C as B,
|
|
2575
|
+
M as D,
|
|
2576
|
+
N as E,
|
|
2577
|
+
G,
|
|
2578
|
+
H as I,
|
|
2579
|
+
L as M,
|
|
2580
|
+
W as O,
|
|
2581
|
+
X as P,
|
|
2582
|
+
V as R,
|
|
2583
|
+
U as S,
|
|
2584
|
+
O as T,
|
|
2585
|
+
K as U,
|
|
2586
|
+
Z as V,
|
|
2587
|
+
ee as Z,
|
|
2588
|
+
F as a,
|
|
2589
|
+
Y as b,
|
|
2590
|
+
Q as c,
|
|
2591
|
+
j as d,
|
|
2592
|
+
P as e,
|
|
2593
|
+
E as f,
|
|
2594
|
+
z as g,
|
|
2595
|
+
re as h,
|
|
2596
|
+
te as i,
|
|
2597
|
+
x as j,
|
|
2598
|
+
J as k,
|
|
2599
|
+
R as l,
|
|
2600
|
+
ae as m,
|
|
2494
2601
|
q as n,
|
|
2495
|
-
|
|
2496
|
-
|
|
2602
|
+
D as o,
|
|
2603
|
+
A as p,
|
|
2604
|
+
B as q
|
|
2497
2605
|
};
|
package/dist/core.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { A as e, a as r, d as A, e as I, B as P, D as
|
|
1
|
+
import { A as e, a as r, d as A, e as I, B as P, D as n, f as o, I as t, M as i, j as g, l as m, S as M, m as h, n as S, T as f, p, U as l } from "./core-BIdNSA4o.js";
|
|
2
2
|
export {
|
|
3
3
|
e as APIError,
|
|
4
4
|
r as AgentAPI,
|
|
5
5
|
A as AuthAPI,
|
|
6
6
|
I as AuthCore,
|
|
7
7
|
P as BaseAPI,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
n as DecisionAPI,
|
|
9
|
+
o as GraphAPI,
|
|
10
|
+
t as InsightsAPI,
|
|
11
|
+
i as MemoryAPI,
|
|
12
12
|
g as ProfileAPI,
|
|
13
13
|
m as RefreshManager,
|
|
14
14
|
M as SSOManager,
|
|
@@ -16,5 +16,5 @@ export {
|
|
|
16
16
|
S as SubscriptionAPI,
|
|
17
17
|
f as TeamAPI,
|
|
18
18
|
p as TokenManager,
|
|
19
|
-
|
|
19
|
+
l as UsageAPI
|
|
20
20
|
};
|
package/dist/fetch.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
function
|
|
2
|
-
return async function(
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
function l(e) {
|
|
2
|
+
return async function(s, t = {}) {
|
|
3
|
+
var c;
|
|
4
|
+
const i = {
|
|
5
5
|
"Content-Type": "application/json",
|
|
6
6
|
...e.getAuthHeaders(t.headers)
|
|
7
|
-
},
|
|
8
|
-
if (
|
|
7
|
+
}, n = await fetch(s, e.getRequestOptions({ ...t, headers: i }));
|
|
8
|
+
if (n.status === 401 && !t.__isRetry)
|
|
9
9
|
try {
|
|
10
10
|
await e.refreshToken();
|
|
11
11
|
const a = {
|
|
@@ -13,31 +13,31 @@ function d(e) {
|
|
|
13
13
|
...e.getAuthHeaders(t.headers)
|
|
14
14
|
};
|
|
15
15
|
return fetch(
|
|
16
|
-
|
|
16
|
+
s,
|
|
17
17
|
e.getRequestOptions({ ...t, headers: a, __isRetry: !0 })
|
|
18
18
|
);
|
|
19
19
|
} catch {
|
|
20
|
-
throw (
|
|
20
|
+
throw (c = e.clearLocalAuth) == null || c.call(e), new Error("Authentication required");
|
|
21
21
|
}
|
|
22
|
-
return
|
|
22
|
+
return n;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function f(e, { urlPatterns:
|
|
26
|
-
const
|
|
27
|
-
return globalThis.fetch = async function(n,
|
|
28
|
-
const
|
|
29
|
-
if (!(
|
|
30
|
-
return
|
|
25
|
+
function f(e, { urlPatterns: r = [] } = {}) {
|
|
26
|
+
const s = globalThis.fetch, t = s.bind(globalThis);
|
|
27
|
+
return globalThis.fetch = async function(n, c = {}) {
|
|
28
|
+
const a = typeof n == "string" ? n : n.toString();
|
|
29
|
+
if (!(r.length === 0 || r.some((o) => a.includes(o))))
|
|
30
|
+
return t(n, c);
|
|
31
31
|
const h = {
|
|
32
|
-
...
|
|
32
|
+
...c.headers,
|
|
33
33
|
...e.getAuthHeaders()
|
|
34
34
|
};
|
|
35
|
-
return
|
|
35
|
+
return t(n, { ...c, headers: h });
|
|
36
36
|
}, function() {
|
|
37
|
-
globalThis.fetch =
|
|
37
|
+
globalThis.fetch = s;
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
export {
|
|
41
|
-
|
|
41
|
+
l as createAuthFetch,
|
|
42
42
|
f as installInterceptor
|
|
43
43
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as f, a as u, b, c as
|
|
1
|
+
import { A as f, a as u, b as A, c as b, d as P, e as h, D as I, E as g, G as x, f as p, I as w, M as m, O as k, g as v, P as T, h as B, i as y, j as C, R as E, k as R, m as S, n as F, T as M, o as L, p as O, q as G, U, V as $, Z as D } from "./core-BIdNSA4o.js";
|
|
2
2
|
const i = {
|
|
3
3
|
variables: {
|
|
4
4
|
colorBackground: "transparent",
|
|
@@ -27,34 +27,41 @@ const i = {
|
|
|
27
27
|
formFieldErrorText: "text-red-300",
|
|
28
28
|
formButtonPrimary: "bg-blue-600 hover:bg-blue-500 text-white",
|
|
29
29
|
footerActionLink: "text-blue-400 hover:text-blue-300",
|
|
30
|
-
footer
|
|
30
|
+
// Clerk paints the footer with TWO stacked background-image layers, the
|
|
31
|
+
// second an opaque black linear-gradient — !bg-transparent only overrides
|
|
32
|
+
// background-COLOR, so !bg-none is required to kill the background-IMAGE
|
|
33
|
+
// and let the card show through. Verified against live DOM 2026-05-28.
|
|
34
|
+
footer: "!bg-transparent !bg-none",
|
|
31
35
|
footerAction: "!bg-transparent",
|
|
32
|
-
badge: "hidden"
|
|
36
|
+
badge: "hidden",
|
|
37
|
+
// The "Last used" pill is cl-lastAuthenticationStrategyBadge, NOT cl-badge —
|
|
38
|
+
// the badge:'hidden' above never caught it. It also clips past the card edge.
|
|
39
|
+
lastAuthenticationStrategyBadge: "hidden"
|
|
33
40
|
}
|
|
34
41
|
};
|
|
35
|
-
async function n(
|
|
36
|
-
for (let e = 0; e <
|
|
42
|
+
async function n(o, a = 8, r = 300) {
|
|
43
|
+
for (let e = 0; e < a; e += 1) {
|
|
37
44
|
let t = null;
|
|
38
45
|
try {
|
|
39
|
-
t = await
|
|
46
|
+
t = await o({ skipCache: !0 });
|
|
40
47
|
} catch {
|
|
41
|
-
t = await
|
|
48
|
+
t = await o();
|
|
42
49
|
}
|
|
43
50
|
if (t) return t;
|
|
44
|
-
e <
|
|
51
|
+
e < a - 1 && await new Promise((s) => setTimeout(s, r));
|
|
45
52
|
}
|
|
46
53
|
return null;
|
|
47
54
|
}
|
|
48
55
|
async function l({
|
|
49
|
-
apiBaseUrl:
|
|
50
|
-
getToken:
|
|
56
|
+
apiBaseUrl: o,
|
|
57
|
+
getToken: a
|
|
51
58
|
}) {
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
59
|
+
const r = await n(a);
|
|
60
|
+
if (!r)
|
|
54
61
|
throw new Error("Missing Clerk token after retries");
|
|
55
|
-
const e = await fetch(`${
|
|
62
|
+
const e = await fetch(`${o}/auth/clerk/session`, {
|
|
56
63
|
method: "POST",
|
|
57
|
-
headers: { Authorization: `Bearer ${
|
|
64
|
+
headers: { Authorization: `Bearer ${r}` },
|
|
58
65
|
credentials: "include"
|
|
59
66
|
});
|
|
60
67
|
if (!e.ok) {
|
|
@@ -70,33 +77,34 @@ async function l({
|
|
|
70
77
|
export {
|
|
71
78
|
f as APIError,
|
|
72
79
|
u as AgentAPI,
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
A as AnalyticsAPI,
|
|
81
|
+
b as ArchiveAPI,
|
|
75
82
|
P as AuthAPI,
|
|
76
83
|
h as AuthCore,
|
|
77
84
|
i as CLERK_APPEARANCE,
|
|
78
85
|
I as DecisionAPI,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
g as EvolutionAPI,
|
|
87
|
+
x as GovernanceAPI,
|
|
88
|
+
p as GraphAPI,
|
|
89
|
+
w as InsightsAPI,
|
|
90
|
+
m as MemoryAPI,
|
|
84
91
|
k as OntologyAPI,
|
|
85
|
-
v as
|
|
86
|
-
T as
|
|
87
|
-
B as
|
|
88
|
-
y as
|
|
89
|
-
C as
|
|
90
|
-
E as
|
|
91
|
-
R as
|
|
92
|
-
S as
|
|
93
|
-
F as
|
|
94
|
-
M as
|
|
95
|
-
L as
|
|
92
|
+
v as OpinionAPI,
|
|
93
|
+
T as PipelineAPI,
|
|
94
|
+
B as ProcedureCandidateAPI,
|
|
95
|
+
y as ProcedureMatchAPI,
|
|
96
|
+
C as ProfileAPI,
|
|
97
|
+
E as ReasoningAPI,
|
|
98
|
+
R as ReasoningTracesAPI,
|
|
99
|
+
S as SmartMemoryClient,
|
|
100
|
+
F as SubscriptionAPI,
|
|
101
|
+
M as TeamAPI,
|
|
102
|
+
L as TemporalAPI,
|
|
103
|
+
O as TokenManager,
|
|
96
104
|
G as TokenUsageAPI,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
105
|
+
U as UsageAPI,
|
|
106
|
+
$ as ValidationAPI,
|
|
107
|
+
D as ZettelkastenAPI,
|
|
100
108
|
l as exchangeClerkSession,
|
|
101
109
|
n as getClerkTokenWithRetry
|
|
102
110
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import h, { createContext as d, useRef as y, useState as v, useEffect as b, useCallback as c, useContext as
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
1
|
+
import h, { createContext as d, useRef as y, useState as v, useEffect as b, useCallback as c, useContext as m } from "react";
|
|
2
|
+
import { m as x } from "./core-BIdNSA4o.js";
|
|
3
|
+
const f = d(null), g = d(null);
|
|
4
4
|
function U({ children: e, ...r }) {
|
|
5
5
|
const n = y(null);
|
|
6
6
|
n.current || (n.current = new x(r));
|
|
@@ -23,16 +23,16 @@ function U({ children: e, ...r }) {
|
|
|
23
23
|
}), [t]);
|
|
24
24
|
const s = c(async () => {
|
|
25
25
|
await t.auth.logout();
|
|
26
|
-
}, [t]), A = c((i) => t.auth.hasRole(i), [t]),
|
|
26
|
+
}, [t]), A = c((i) => t.auth.hasRole(i), [t]), w = c((i) => t.auth.getLoginUrl(i), [t]), S = {
|
|
27
27
|
...u,
|
|
28
28
|
logout: s,
|
|
29
29
|
hasRole: A,
|
|
30
|
-
getLoginUrl:
|
|
30
|
+
getLoginUrl: w
|
|
31
31
|
};
|
|
32
|
-
return /* @__PURE__ */ h.createElement(
|
|
32
|
+
return /* @__PURE__ */ h.createElement(f.Provider, { value: S }, /* @__PURE__ */ h.createElement(g.Provider, { value: t }, e));
|
|
33
33
|
}
|
|
34
34
|
function l() {
|
|
35
|
-
const e = f
|
|
35
|
+
const e = m(f);
|
|
36
36
|
if (!e)
|
|
37
37
|
throw new Error("useAuth must be used within a SmartMemoryProvider");
|
|
38
38
|
return e;
|
|
@@ -46,7 +46,7 @@ function p() {
|
|
|
46
46
|
return { login: e, logout: r, hasRole: n, getLoginUrl: t };
|
|
47
47
|
}
|
|
48
48
|
function E() {
|
|
49
|
-
const e =
|
|
49
|
+
const e = m(g);
|
|
50
50
|
if (!e)
|
|
51
51
|
throw new Error("useSmartMemory must be used within a SmartMemoryProvider");
|
|
52
52
|
return e;
|
|
@@ -66,7 +66,7 @@ function I({ children: e, fallback: r = null, redirectToLogin: n = !1 }) {
|
|
|
66
66
|
return e;
|
|
67
67
|
}
|
|
68
68
|
export {
|
|
69
|
-
|
|
69
|
+
f as AuthContext,
|
|
70
70
|
I as AuthWrapper,
|
|
71
71
|
g as ClientContext,
|
|
72
72
|
U as SmartMemoryProvider,
|
package/package.json
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartmemory/sdk-js",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Unified JavaScript SDK for SmartMemory API — auth + API client for all frontends",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"./
|
|
9
|
+
".": {
|
|
10
|
+
"development": "./src/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./core": {
|
|
14
|
+
"development": "./src/core.js",
|
|
15
|
+
"default": "./dist/core.js"
|
|
16
|
+
},
|
|
17
|
+
"./react": {
|
|
18
|
+
"development": "./src/react/index.js",
|
|
19
|
+
"default": "./dist/react.js"
|
|
20
|
+
},
|
|
21
|
+
"./fetch": {
|
|
22
|
+
"development": "./src/fetch/index.js",
|
|
23
|
+
"default": "./dist/fetch.js"
|
|
24
|
+
},
|
|
25
|
+
"./progress": {
|
|
26
|
+
"development": "./src/progress.ts",
|
|
27
|
+
"default": "./dist/progress.js"
|
|
28
|
+
}
|
|
14
29
|
},
|
|
15
30
|
"files": [
|
|
16
31
|
"dist"
|