@smartmemory/sdk-js 0.5.1 → 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-Ds7Kn35C.js → core-BIdNSA4o.js} +240 -111
- 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,13 +94,21 @@ 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 {
|
|
@@ -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 v {
|
|
|
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 v {
|
|
|
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,7 +385,7 @@ class A {
|
|
|
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
391
|
var a, c;
|
|
@@ -390,25 +398,25 @@ class A {
|
|
|
390
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
411
|
if (o.status === 401)
|
|
404
|
-
throw (c = (a = this.auth).clearLocalAuth) == null || c.call(a), new
|
|
412
|
+
throw (c = (a = this.auth).clearLocalAuth) == null || c.call(a), new g("Authentication required", 401, "auth_expired");
|
|
405
413
|
if (o.status === 204)
|
|
406
414
|
return null;
|
|
407
415
|
if (!o.ok)
|
|
408
416
|
throw await this._handleError(o);
|
|
409
417
|
return await o.json();
|
|
410
418
|
} catch (o) {
|
|
411
|
-
throw o instanceof
|
|
419
|
+
throw o instanceof g ? o : new g(o.message, 0, "network_error");
|
|
412
420
|
}
|
|
413
421
|
}
|
|
414
422
|
async get(e, t = {}) {
|
|
@@ -448,25 +456,33 @@ class A {
|
|
|
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
|
}
|
|
462
|
-
async create({
|
|
463
|
-
|
|
470
|
+
async create({
|
|
471
|
+
content: e,
|
|
472
|
+
memoryType: t = "semantic",
|
|
473
|
+
metadata: r = null,
|
|
474
|
+
usePipeline: s = !0,
|
|
475
|
+
profileName: n = null,
|
|
476
|
+
conversationContext: a = null
|
|
477
|
+
}) {
|
|
478
|
+
const c = {
|
|
464
479
|
content: e,
|
|
465
480
|
memory_type: t,
|
|
466
481
|
metadata: r,
|
|
467
482
|
use_pipeline: s,
|
|
468
483
|
profile_name: n
|
|
469
|
-
}
|
|
484
|
+
};
|
|
485
|
+
return a != null && (c.conversation_context = a), this.api.post("/memory/add", c);
|
|
470
486
|
}
|
|
471
487
|
async get(e) {
|
|
472
488
|
const t = await this.api.get(`/memory/${e}`);
|
|
@@ -495,9 +511,33 @@ class R {
|
|
|
495
511
|
let s = `/memory/list?limit=${e}&offset=${t}`;
|
|
496
512
|
return r && (s += `&memory_type=${r}`), this.api.get(s);
|
|
497
513
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
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);
|
|
501
541
|
}
|
|
502
542
|
async getWorkingContext(e, t, { k: r = 20, maxTokens: s = null, strategy: n = null } = {}) {
|
|
503
543
|
const a = {
|
|
@@ -601,8 +641,21 @@ class R {
|
|
|
601
641
|
async personalize(e = {}, t = {}) {
|
|
602
642
|
return this.api.post("/memory/personalize", { traits: e, preferences: t });
|
|
603
643
|
}
|
|
604
|
-
|
|
605
|
-
|
|
644
|
+
/**
|
|
645
|
+
* Reinforce recalled memory items with explicit feedback.
|
|
646
|
+
*
|
|
647
|
+
* Bumps `retention_score` immediately and, for `helpful` outcomes with multiple
|
|
648
|
+
* items, strengthens the `CO_RETRIEVED` edges between every pair — feeding into
|
|
649
|
+
* the Hebbian co-retrieval evolver.
|
|
650
|
+
*
|
|
651
|
+
* @param {string[]} itemIds - Item IDs returned by a prior `search()` call (1-50).
|
|
652
|
+
* @param {'helpful'|'misleading'|'neutral'} outcome - Feedback signal.
|
|
653
|
+
* @param {string} [query] - Original query that produced these results.
|
|
654
|
+
* @returns {Promise<{updated: number, edges_strengthened: number, outcome: string}>}
|
|
655
|
+
*/
|
|
656
|
+
async feedback(e, t, r = null) {
|
|
657
|
+
const s = { item_ids: e, outcome: t };
|
|
658
|
+
return r != null && (s.query = r), this.api.post("/memory/feedback", s);
|
|
606
659
|
}
|
|
607
660
|
async ground(e, t, r = null) {
|
|
608
661
|
return this.api.post(`/memory/${e}/ground`, {
|
|
@@ -647,7 +700,7 @@ class R {
|
|
|
647
700
|
return this.api.get("/memory/clustering/stats");
|
|
648
701
|
}
|
|
649
702
|
}
|
|
650
|
-
class
|
|
703
|
+
class M {
|
|
651
704
|
constructor(e) {
|
|
652
705
|
this.api = e;
|
|
653
706
|
}
|
|
@@ -662,6 +715,9 @@ class U {
|
|
|
662
715
|
* @param {string[]} [params.evidenceIds]
|
|
663
716
|
* @param {string} [params.domain]
|
|
664
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'.
|
|
665
721
|
*/
|
|
666
722
|
async create({
|
|
667
723
|
content: e,
|
|
@@ -671,7 +727,11 @@ class U {
|
|
|
671
727
|
sourceSessionId: n = null,
|
|
672
728
|
evidenceIds: a = null,
|
|
673
729
|
domain: c = null,
|
|
674
|
-
tags: o = null
|
|
730
|
+
tags: o = null,
|
|
731
|
+
rejectedAlternatives: u = null,
|
|
732
|
+
rationale: y = null,
|
|
733
|
+
constraints: f = null,
|
|
734
|
+
agentId: _ = null
|
|
675
735
|
}) {
|
|
676
736
|
return this.api.post("/memory/decisions/create", {
|
|
677
737
|
content: e,
|
|
@@ -681,12 +741,27 @@ class U {
|
|
|
681
741
|
source_session_id: n,
|
|
682
742
|
evidence_ids: a,
|
|
683
743
|
domain: c,
|
|
684
|
-
tags: o
|
|
744
|
+
tags: o,
|
|
745
|
+
rejected_alternatives: u,
|
|
746
|
+
rationale: y,
|
|
747
|
+
constraints: f,
|
|
748
|
+
agent_id: _
|
|
685
749
|
});
|
|
686
750
|
}
|
|
687
751
|
/**
|
|
688
752
|
* List active decisions with optional filters.
|
|
689
|
-
* @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).
|
|
690
765
|
*/
|
|
691
766
|
async list(e = {}) {
|
|
692
767
|
const t = new URLSearchParams(e).toString();
|
|
@@ -802,7 +877,29 @@ class U {
|
|
|
802
877
|
});
|
|
803
878
|
}
|
|
804
879
|
}
|
|
805
|
-
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 {
|
|
806
903
|
constructor(e) {
|
|
807
904
|
this.api = e;
|
|
808
905
|
}
|
|
@@ -888,7 +985,7 @@ class C {
|
|
|
888
985
|
return this.api.get(`/memory/${encodeURIComponent(e)}/links`);
|
|
889
986
|
}
|
|
890
987
|
}
|
|
891
|
-
class
|
|
988
|
+
class O {
|
|
892
989
|
constructor(e) {
|
|
893
990
|
this.api = e;
|
|
894
991
|
}
|
|
@@ -928,7 +1025,7 @@ class P {
|
|
|
928
1025
|
return this.api.delete(`/memory/teams/${e}/members/${t}`);
|
|
929
1026
|
}
|
|
930
1027
|
}
|
|
931
|
-
class
|
|
1028
|
+
class x {
|
|
932
1029
|
constructor(e) {
|
|
933
1030
|
this.api = e;
|
|
934
1031
|
}
|
|
@@ -945,7 +1042,7 @@ class M {
|
|
|
945
1042
|
return this.api.patch("/auth/llm-keys", e);
|
|
946
1043
|
}
|
|
947
1044
|
}
|
|
948
|
-
class
|
|
1045
|
+
class q {
|
|
949
1046
|
constructor(e) {
|
|
950
1047
|
this.api = e;
|
|
951
1048
|
}
|
|
@@ -971,7 +1068,7 @@ class L {
|
|
|
971
1068
|
});
|
|
972
1069
|
}
|
|
973
1070
|
}
|
|
974
|
-
class
|
|
1071
|
+
class j {
|
|
975
1072
|
constructor(e) {
|
|
976
1073
|
this.api = e;
|
|
977
1074
|
}
|
|
@@ -992,7 +1089,7 @@ class z {
|
|
|
992
1089
|
return this.api.delete(`/memory/api-keys/${e}`);
|
|
993
1090
|
}
|
|
994
1091
|
}
|
|
995
|
-
class
|
|
1092
|
+
class F {
|
|
996
1093
|
constructor(e) {
|
|
997
1094
|
this.api = e;
|
|
998
1095
|
}
|
|
@@ -1019,8 +1116,39 @@ class E {
|
|
|
1019
1116
|
async setRecallProfile(e, t) {
|
|
1020
1117
|
return this.api.put(`/memory/agents/${e}/recall-profile`, { recall_profile: t });
|
|
1021
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
|
+
}
|
|
1022
1150
|
}
|
|
1023
|
-
class
|
|
1151
|
+
class K {
|
|
1024
1152
|
constructor(e) {
|
|
1025
1153
|
this.api = e;
|
|
1026
1154
|
}
|
|
@@ -1034,7 +1162,7 @@ class x {
|
|
|
1034
1162
|
return this.api.get("/usage/tiers");
|
|
1035
1163
|
}
|
|
1036
1164
|
}
|
|
1037
|
-
class
|
|
1165
|
+
class H {
|
|
1038
1166
|
constructor(e) {
|
|
1039
1167
|
this.api = e;
|
|
1040
1168
|
}
|
|
@@ -1051,7 +1179,7 @@ class O {
|
|
|
1051
1179
|
return this.api.get("/memory/plugins");
|
|
1052
1180
|
}
|
|
1053
1181
|
}
|
|
1054
|
-
class
|
|
1182
|
+
class B {
|
|
1055
1183
|
constructor(e) {
|
|
1056
1184
|
this.api = e;
|
|
1057
1185
|
}
|
|
@@ -1074,7 +1202,7 @@ class q {
|
|
|
1074
1202
|
return this.api.get("/memory/token-usage/current");
|
|
1075
1203
|
}
|
|
1076
1204
|
}
|
|
1077
|
-
class
|
|
1205
|
+
class D {
|
|
1078
1206
|
constructor(e) {
|
|
1079
1207
|
this.api = e;
|
|
1080
1208
|
}
|
|
@@ -1220,7 +1348,7 @@ class F {
|
|
|
1220
1348
|
return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
|
|
1221
1349
|
}
|
|
1222
1350
|
}
|
|
1223
|
-
class
|
|
1351
|
+
class G {
|
|
1224
1352
|
constructor(e) {
|
|
1225
1353
|
this.api = e;
|
|
1226
1354
|
}
|
|
@@ -1289,7 +1417,7 @@ class H {
|
|
|
1289
1417
|
return this.api.get("/memory/governance/summary");
|
|
1290
1418
|
}
|
|
1291
1419
|
}
|
|
1292
|
-
class
|
|
1420
|
+
class N {
|
|
1293
1421
|
constructor(e) {
|
|
1294
1422
|
this.api = e;
|
|
1295
1423
|
}
|
|
@@ -1330,7 +1458,7 @@ class j {
|
|
|
1330
1458
|
return this.api.post("/memory/evolution/reinforce/opinions");
|
|
1331
1459
|
}
|
|
1332
1460
|
}
|
|
1333
|
-
class
|
|
1461
|
+
class V {
|
|
1334
1462
|
constructor(e) {
|
|
1335
1463
|
this.api = e;
|
|
1336
1464
|
}
|
|
@@ -1428,7 +1556,7 @@ class K {
|
|
|
1428
1556
|
});
|
|
1429
1557
|
}
|
|
1430
1558
|
}
|
|
1431
|
-
class
|
|
1559
|
+
class J {
|
|
1432
1560
|
constructor(e) {
|
|
1433
1561
|
this.api = e;
|
|
1434
1562
|
}
|
|
@@ -1482,7 +1610,7 @@ class B {
|
|
|
1482
1610
|
return this.api.get(`/memory/reasoning/traces/${e}`);
|
|
1483
1611
|
}
|
|
1484
1612
|
}
|
|
1485
|
-
class
|
|
1613
|
+
class W {
|
|
1486
1614
|
constructor(e) {
|
|
1487
1615
|
this.api = e;
|
|
1488
1616
|
}
|
|
@@ -1850,7 +1978,7 @@ class D {
|
|
|
1850
1978
|
return this.api.get(`/memory/ontology/updates/stats?history=${e}`);
|
|
1851
1979
|
}
|
|
1852
1980
|
}
|
|
1853
|
-
class
|
|
1981
|
+
class Y {
|
|
1854
1982
|
constructor(e) {
|
|
1855
1983
|
this.api = e;
|
|
1856
1984
|
}
|
|
@@ -1879,7 +2007,7 @@ class G {
|
|
|
1879
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);
|
|
1880
2008
|
}
|
|
1881
2009
|
}
|
|
1882
|
-
class
|
|
2010
|
+
class Z {
|
|
1883
2011
|
constructor(e) {
|
|
1884
2012
|
this.api = e;
|
|
1885
2013
|
}
|
|
@@ -1915,7 +2043,7 @@ class N {
|
|
|
1915
2043
|
return this.api.get("/memory/validation/inference/rules");
|
|
1916
2044
|
}
|
|
1917
2045
|
}
|
|
1918
|
-
class
|
|
2046
|
+
class X {
|
|
1919
2047
|
constructor(e) {
|
|
1920
2048
|
this.api = e;
|
|
1921
2049
|
}
|
|
@@ -2031,7 +2159,7 @@ class V {
|
|
|
2031
2159
|
return this.api.delete(`/memory/pipeline/configs/${e}`);
|
|
2032
2160
|
}
|
|
2033
2161
|
}
|
|
2034
|
-
class
|
|
2162
|
+
class Q {
|
|
2035
2163
|
constructor(e) {
|
|
2036
2164
|
this.api = e;
|
|
2037
2165
|
}
|
|
@@ -2057,7 +2185,7 @@ class J {
|
|
|
2057
2185
|
return this.api.get(`/memory/archive/${e}`);
|
|
2058
2186
|
}
|
|
2059
2187
|
}
|
|
2060
|
-
class
|
|
2188
|
+
class ee {
|
|
2061
2189
|
constructor(e) {
|
|
2062
2190
|
this.api = e;
|
|
2063
2191
|
}
|
|
@@ -2216,7 +2344,7 @@ class W {
|
|
|
2216
2344
|
return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${r}`);
|
|
2217
2345
|
}
|
|
2218
2346
|
}
|
|
2219
|
-
class
|
|
2347
|
+
class te {
|
|
2220
2348
|
constructor(e) {
|
|
2221
2349
|
this.api = e;
|
|
2222
2350
|
}
|
|
@@ -2252,7 +2380,7 @@ class Y {
|
|
|
2252
2380
|
return this.api.get("/memory/procedures/matches/stats");
|
|
2253
2381
|
}
|
|
2254
2382
|
}
|
|
2255
|
-
class
|
|
2383
|
+
class re {
|
|
2256
2384
|
constructor(e) {
|
|
2257
2385
|
this.api = e;
|
|
2258
2386
|
}
|
|
@@ -2301,7 +2429,7 @@ class Z {
|
|
|
2301
2429
|
return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
|
|
2302
2430
|
}
|
|
2303
2431
|
}
|
|
2304
|
-
class
|
|
2432
|
+
class se {
|
|
2305
2433
|
constructor(e) {
|
|
2306
2434
|
this.api = e;
|
|
2307
2435
|
}
|
|
@@ -2356,7 +2484,7 @@ class X {
|
|
|
2356
2484
|
return this.api.get(`/memory/procedures/schemas/${e}`);
|
|
2357
2485
|
}
|
|
2358
2486
|
}
|
|
2359
|
-
class
|
|
2487
|
+
class ne {
|
|
2360
2488
|
constructor(e) {
|
|
2361
2489
|
this.api = e;
|
|
2362
2490
|
}
|
|
@@ -2428,11 +2556,11 @@ class Q {
|
|
|
2428
2556
|
return this.api.delete(`/memory/summary/${e}`);
|
|
2429
2557
|
}
|
|
2430
2558
|
}
|
|
2431
|
-
class
|
|
2559
|
+
class ae {
|
|
2432
2560
|
constructor(e) {
|
|
2433
|
-
this.auth = new
|
|
2434
|
-
const t = new
|
|
2435
|
-
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);
|
|
2436
2564
|
}
|
|
2437
2565
|
setTeamId(e) {
|
|
2438
2566
|
this.auth.tokenManager.setTeamId(e), this.auth.notifyListeners();
|
|
@@ -2442,35 +2570,36 @@ class te {
|
|
|
2442
2570
|
}
|
|
2443
2571
|
}
|
|
2444
2572
|
export {
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
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,
|
|
2473
2601
|
q as n,
|
|
2474
|
-
|
|
2475
|
-
|
|
2602
|
+
D as o,
|
|
2603
|
+
A as p,
|
|
2604
|
+
B as q
|
|
2476
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.
|
|
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"
|