@smartmemory/sdk-js 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{core-Ds7Kn35C.js → core-CC81ya-7.js} +62 -41
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
|
@@ -107,14 +107,14 @@ class I {
|
|
|
107
107
|
const r = this.storageType === "localStorage" ? localStorage : sessionStorage, s = this.storageType === "localStorage" ? sessionStorage : localStorage, n = r.getItem(e) || s.getItem(e);
|
|
108
108
|
if (n != null) return n;
|
|
109
109
|
for (const a of t) {
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
this._setInStorage(e,
|
|
110
|
+
const o = r.getItem(a) || s.getItem(a);
|
|
111
|
+
if (o != null) {
|
|
112
|
+
this._setInStorage(e, o);
|
|
113
113
|
try {
|
|
114
114
|
r.removeItem(a), s.removeItem(a);
|
|
115
115
|
} catch {
|
|
116
116
|
}
|
|
117
|
-
return
|
|
117
|
+
return o;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
return null;
|
|
@@ -222,7 +222,7 @@ class S {
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
class
|
|
225
|
+
class A {
|
|
226
226
|
constructor(e) {
|
|
227
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 I({
|
|
228
228
|
storage: e.storage || "localStorage",
|
|
@@ -368,7 +368,7 @@ class h extends Error {
|
|
|
368
368
|
super(e), this.name = "APIError", this.status = t, this.detail = r;
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
class
|
|
371
|
+
class v {
|
|
372
372
|
/**
|
|
373
373
|
* @param {import('../auth/AuthCore.js').AuthCore} authCore
|
|
374
374
|
* @param {{ fetchFn?: typeof globalThis.fetch }} [options]
|
|
@@ -380,35 +380,35 @@ class A {
|
|
|
380
380
|
return this._customFetchFn || globalThis.fetch;
|
|
381
381
|
}
|
|
382
382
|
async request(e, t = {}) {
|
|
383
|
-
var a,
|
|
383
|
+
var a, o;
|
|
384
384
|
const r = `${this.baseURL}${e}`, s = {
|
|
385
385
|
"Content-Type": "application/json",
|
|
386
386
|
...this.auth.getAuthHeaders(t.headers)
|
|
387
387
|
}, n = this.auth.getRequestOptions({ ...t, headers: s });
|
|
388
388
|
try {
|
|
389
|
-
let
|
|
390
|
-
if (
|
|
389
|
+
let c = await this.fetchFn(r, n);
|
|
390
|
+
if (c.status === 401 && !t.__isRetry)
|
|
391
391
|
try {
|
|
392
392
|
await this.auth.refreshToken();
|
|
393
393
|
const w = {
|
|
394
394
|
"Content-Type": "application/json",
|
|
395
395
|
...this.auth.getAuthHeaders(t.headers)
|
|
396
396
|
};
|
|
397
|
-
|
|
397
|
+
c = await this.fetchFn(
|
|
398
398
|
r,
|
|
399
399
|
this.auth.getRequestOptions({ ...n, headers: w, __isRetry: !0 })
|
|
400
400
|
);
|
|
401
401
|
} catch {
|
|
402
402
|
}
|
|
403
|
-
if (
|
|
404
|
-
throw (
|
|
405
|
-
if (
|
|
403
|
+
if (c.status === 401)
|
|
404
|
+
throw (o = (a = this.auth).clearLocalAuth) == null || o.call(a), new h("Authentication required", 401, "auth_expired");
|
|
405
|
+
if (c.status === 204)
|
|
406
406
|
return null;
|
|
407
|
-
if (!
|
|
408
|
-
throw await this._handleError(
|
|
409
|
-
return await
|
|
410
|
-
} catch (
|
|
411
|
-
throw
|
|
407
|
+
if (!c.ok)
|
|
408
|
+
throw await this._handleError(c);
|
|
409
|
+
return await c.json();
|
|
410
|
+
} catch (c) {
|
|
411
|
+
throw c instanceof h ? c : new h(c.message, 0, "network_error");
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
async get(e, t = {}) {
|
|
@@ -459,14 +459,22 @@ class R {
|
|
|
459
459
|
constructor(e) {
|
|
460
460
|
this.api = e;
|
|
461
461
|
}
|
|
462
|
-
async create({
|
|
463
|
-
|
|
462
|
+
async create({
|
|
463
|
+
content: e,
|
|
464
|
+
memoryType: t = "semantic",
|
|
465
|
+
metadata: r = null,
|
|
466
|
+
usePipeline: s = !0,
|
|
467
|
+
profileName: n = null,
|
|
468
|
+
conversationContext: a = null
|
|
469
|
+
}) {
|
|
470
|
+
const o = {
|
|
464
471
|
content: e,
|
|
465
472
|
memory_type: t,
|
|
466
473
|
metadata: r,
|
|
467
474
|
use_pipeline: s,
|
|
468
475
|
profile_name: n
|
|
469
|
-
}
|
|
476
|
+
};
|
|
477
|
+
return a != null && (o.conversation_context = a), this.api.post("/memory/add", o);
|
|
470
478
|
}
|
|
471
479
|
async get(e) {
|
|
472
480
|
const t = await this.api.get(`/memory/${e}`);
|
|
@@ -545,10 +553,10 @@ class R {
|
|
|
545
553
|
sessionDates: s = null,
|
|
546
554
|
turnsPerChunk: n = 15,
|
|
547
555
|
maxChunkChars: a = 12e3,
|
|
548
|
-
maxConcurrent:
|
|
556
|
+
maxConcurrent: o = 4
|
|
549
557
|
} = {}) {
|
|
550
|
-
const
|
|
551
|
-
return t && (
|
|
558
|
+
const c = { turns: e, turns_per_chunk: n, max_chunk_chars: a, max_concurrent: o };
|
|
559
|
+
return t && (c.session_boundaries = t), r && (c.conversation_id = r), s && (c.session_dates = s), this.api.post("/memory/ingest/conversation", c);
|
|
552
560
|
}
|
|
553
561
|
async ingestDocument(e, { title: t = null, source: r = null, chunkStrategy: s = null } = {}) {
|
|
554
562
|
const n = { content: e };
|
|
@@ -601,8 +609,21 @@ class R {
|
|
|
601
609
|
async personalize(e = {}, t = {}) {
|
|
602
610
|
return this.api.post("/memory/personalize", { traits: e, preferences: t });
|
|
603
611
|
}
|
|
604
|
-
|
|
605
|
-
|
|
612
|
+
/**
|
|
613
|
+
* Reinforce recalled memory items with explicit feedback.
|
|
614
|
+
*
|
|
615
|
+
* Bumps `retention_score` immediately and, for `helpful` outcomes with multiple
|
|
616
|
+
* items, strengthens the `CO_RETRIEVED` edges between every pair — feeding into
|
|
617
|
+
* the Hebbian co-retrieval evolver.
|
|
618
|
+
*
|
|
619
|
+
* @param {string[]} itemIds - Item IDs returned by a prior `search()` call (1-50).
|
|
620
|
+
* @param {'helpful'|'misleading'|'neutral'} outcome - Feedback signal.
|
|
621
|
+
* @param {string} [query] - Original query that produced these results.
|
|
622
|
+
* @returns {Promise<{updated: number, edges_strengthened: number, outcome: string}>}
|
|
623
|
+
*/
|
|
624
|
+
async feedback(e, t, r = null) {
|
|
625
|
+
const s = { item_ids: e, outcome: t };
|
|
626
|
+
return r != null && (s.query = r), this.api.post("/memory/feedback", s);
|
|
606
627
|
}
|
|
607
628
|
async ground(e, t, r = null) {
|
|
608
629
|
return this.api.post(`/memory/${e}/ground`, {
|
|
@@ -670,8 +691,8 @@ class U {
|
|
|
670
691
|
sourceTraceId: s = null,
|
|
671
692
|
sourceSessionId: n = null,
|
|
672
693
|
evidenceIds: a = null,
|
|
673
|
-
domain:
|
|
674
|
-
tags:
|
|
694
|
+
domain: o = null,
|
|
695
|
+
tags: c = null
|
|
675
696
|
}) {
|
|
676
697
|
return this.api.post("/memory/decisions/create", {
|
|
677
698
|
content: e,
|
|
@@ -680,8 +701,8 @@ class U {
|
|
|
680
701
|
source_trace_id: s,
|
|
681
702
|
source_session_id: n,
|
|
682
703
|
evidence_ids: a,
|
|
683
|
-
domain:
|
|
684
|
-
tags:
|
|
704
|
+
domain: o,
|
|
705
|
+
tags: c
|
|
685
706
|
});
|
|
686
707
|
}
|
|
687
708
|
/**
|
|
@@ -802,7 +823,7 @@ class U {
|
|
|
802
823
|
});
|
|
803
824
|
}
|
|
804
825
|
}
|
|
805
|
-
class
|
|
826
|
+
class P {
|
|
806
827
|
constructor(e) {
|
|
807
828
|
this.api = e;
|
|
808
829
|
}
|
|
@@ -888,7 +909,7 @@ class C {
|
|
|
888
909
|
return this.api.get(`/memory/${encodeURIComponent(e)}/links`);
|
|
889
910
|
}
|
|
890
911
|
}
|
|
891
|
-
class
|
|
912
|
+
class C {
|
|
892
913
|
constructor(e) {
|
|
893
914
|
this.api = e;
|
|
894
915
|
}
|
|
@@ -1160,8 +1181,8 @@ class F {
|
|
|
1160
1181
|
*/
|
|
1161
1182
|
async getAuditTrail(e, { changeType: t = null, userId: r = null, startTime: s = null, endTime: n = null } = {}) {
|
|
1162
1183
|
let a = `/memory/temporal/${e}/audit`;
|
|
1163
|
-
const
|
|
1164
|
-
return t &&
|
|
1184
|
+
const o = [];
|
|
1185
|
+
return t && o.push(`change_type=${t}`), r && o.push(`user_id=${r}`), s && o.push(`start_time=${s}`), n && o.push(`end_time=${n}`), o.length && (a += `?${o.join("&")}`), this.api.get(a);
|
|
1165
1186
|
}
|
|
1166
1187
|
// === TEMPORAL SEARCH ===
|
|
1167
1188
|
/**
|
|
@@ -2430,9 +2451,9 @@ class Q {
|
|
|
2430
2451
|
}
|
|
2431
2452
|
class te {
|
|
2432
2453
|
constructor(e) {
|
|
2433
|
-
this.auth = new
|
|
2434
|
-
const t = new
|
|
2435
|
-
this.memories = new R(t), this.decisions = new U(t), this.graph = new
|
|
2454
|
+
this.auth = new A(e);
|
|
2455
|
+
const t = new v(this.auth, { fetchFn: e.fetchFn });
|
|
2456
|
+
this.memories = new R(t), this.decisions = new U(t), this.graph = new P(t), this.teams = new C(t), this.profiles = new M(t), this.subscriptions = new L(t), this.authAPI = new z(t), this.agents = new E(t), this.usage = new x(t), this.insights = new O(t), this.tokenUsage = new q(t), this.temporal = new F(t), this.governance = new H(t), this.evolution = new j(t), this.reasoning = new K(t), this.reasoningTraces = new B(t), this.ontology = new D(t), this.analytics = new G(t), this.validation = new N(t), this.pipeline = new V(t), this.archive = new J(t), this.zettelkasten = new W(t), this.procedureMatches = new Y(t), this.procedureCandidates = new Z(t), this.procedureDrift = new X(t), this.summaries = new Q(t);
|
|
2436
2457
|
}
|
|
2437
2458
|
setTeamId(e) {
|
|
2438
2459
|
this.auth.tokenManager.setTeamId(e), this.auth.notifyListeners();
|
|
@@ -2443,7 +2464,7 @@ class te {
|
|
|
2443
2464
|
}
|
|
2444
2465
|
export {
|
|
2445
2466
|
h as A,
|
|
2446
|
-
|
|
2467
|
+
v as B,
|
|
2447
2468
|
U as D,
|
|
2448
2469
|
j as E,
|
|
2449
2470
|
H as G,
|
|
@@ -2453,7 +2474,7 @@ export {
|
|
|
2453
2474
|
V as P,
|
|
2454
2475
|
K as R,
|
|
2455
2476
|
te as S,
|
|
2456
|
-
|
|
2477
|
+
C as T,
|
|
2457
2478
|
x as U,
|
|
2458
2479
|
N as V,
|
|
2459
2480
|
W as Z,
|
|
@@ -2461,8 +2482,8 @@ export {
|
|
|
2461
2482
|
G as b,
|
|
2462
2483
|
J as c,
|
|
2463
2484
|
z as d,
|
|
2464
|
-
|
|
2465
|
-
|
|
2485
|
+
A as e,
|
|
2486
|
+
P as f,
|
|
2466
2487
|
Z as g,
|
|
2467
2488
|
Y as h,
|
|
2468
2489
|
M as i,
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as e, a as r, d as A, e as I, B as P, D as o, f as n, I as i, M as t, i as g, o as m, p as M, S as h, k as S, T as f, m as p, U as u } from "./core-
|
|
1
|
+
import { A as e, a as r, d as A, e as I, B as P, D as o, f as n, I as i, M as t, i as g, o as m, p as M, S as h, k as S, T as f, m as p, U as u } from "./core-CC81ya-7.js";
|
|
2
2
|
export {
|
|
3
3
|
e as APIError,
|
|
4
4
|
r as AgentAPI,
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as f, a as u, b, c as A, d as P, e as h, D as I, E as x, G as g, f as w, I as m, M as p, O as k, P as v, g as T, h as B, i as y, R as C, j as E, S as R, k as S, T as F, l as M, m as L, n as G, U as O, V as U, Z as $ } from "./core-
|
|
1
|
+
import { A as f, a as u, b, c as A, d as P, e as h, D as I, E as x, G as g, f as w, I as m, M as p, O as k, P as v, g as T, h as B, i as y, R as C, j as E, S as R, k as S, T as F, l as M, m as L, n as G, U as O, V as U, Z as $ } from "./core-CC81ya-7.js";
|
|
2
2
|
const i = {
|
|
3
3
|
variables: {
|
|
4
4
|
colorBackground: "transparent",
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import h, { createContext as d, useRef as y, useState as v, useEffect as b, useCallback as c, useContext as f } from "react";
|
|
2
|
-
import { S as x } from "./core-
|
|
2
|
+
import { S as x } from "./core-CC81ya-7.js";
|
|
3
3
|
const m = d(null), g = d(null);
|
|
4
4
|
function U({ children: e, ...r }) {
|
|
5
5
|
const n = y(null);
|