@smartmemory/sdk-js 0.6.4 → 1.4.25

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.
@@ -3,7 +3,7 @@ var I = (i) => {
3
3
  };
4
4
  var $ = (i, e, t) => e.has(i) || I("Cannot " + t);
5
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 = {
6
+ const R = {
7
7
  access: "smart_memory_auth_token",
8
8
  refresh: "smart_memory_refresh_token",
9
9
  user: "smart_memory_user",
@@ -16,14 +16,14 @@ const v = {
16
16
  tenant: ["tenant_id", "workspace_id", "sm_workspace_id"],
17
17
  team: ["team_id", "sm_team_id"]
18
18
  };
19
- class A {
19
+ class U {
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 = { ...v, ...t }, this._memory = { access: null, refresh: null, user: null, tenant: null, team: null };
26
+ this.storageType = e, this.keys = { ...R, ...t }, this._memory = { access: null, refresh: null, user: null, tenant: null, team: null };
27
27
  }
28
28
  getAccessToken() {
29
29
  return this.storageType === "memory" ? this._memory.access : this._getFromStorage(this.keys.access, h.access);
@@ -149,7 +149,7 @@ class A {
149
149
  }
150
150
  }
151
151
  var m, d, T;
152
- class R {
152
+ class P {
153
153
  /**
154
154
  * @param {Object} options
155
155
  * @param {string} options.apiBaseUrl
@@ -191,7 +191,7 @@ m = new WeakMap(), d = new WeakSet(), T = async function() {
191
191
  return this.tokenManager.setAccessToken(s.access_token), s.refresh_token && this.tokenManager.setRefreshToken(s.refresh_token), this.onTokenRefreshed(s.access_token), s.access_token;
192
192
  };
193
193
  const b = "smart_memory_sso_redirect";
194
- class U {
194
+ class C {
195
195
  /**
196
196
  * @param {Object} options
197
197
  * @param {string} options.webAppUrl - Web app URL for login redirect
@@ -230,12 +230,12 @@ class U {
230
230
  }
231
231
  }
232
232
  }
233
- class P {
233
+ class L {
234
234
  constructor(e) {
235
- this.mode = e.mode, this.apiBaseUrl = e.apiBaseUrl, this.endpoints = e.endpoints || {}, this.listeners = /* @__PURE__ */ new Set(), this.useCookieAuth = e.useCookieAuth ?? this.mode === "sso", this.apiKey = e.apiKey || null, this.apiKey && (this.mode = "apiKey"), this.tokenManager = new A({
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 U({
236
236
  storage: e.storage || "localStorage",
237
237
  keys: e.tokenKeys
238
- }), this.mode !== "apiKey" ? this.refreshManager = new R({
238
+ }), this.mode !== "apiKey" ? this.refreshManager = new P({
239
239
  apiBaseUrl: this.apiBaseUrl,
240
240
  refreshEndpoint: this.endpoints.refresh || "/auth/refresh",
241
241
  tokenManager: this.tokenManager,
@@ -247,7 +247,7 @@ class P {
247
247
  onRefreshFailed: () => {
248
248
  this.clearLocalAuth();
249
249
  }
250
- }) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new U({
250
+ }) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new C({
251
251
  webAppUrl: e.webAppUrl,
252
252
  allowedHosts: e.allowedRedirectHosts || [],
253
253
  tokenManager: this.tokenManager
@@ -376,7 +376,7 @@ class g extends Error {
376
376
  super(e), this.name = "APIError", this.status = t, this.detail = r;
377
377
  }
378
378
  }
379
- class C {
379
+ class M {
380
380
  /**
381
381
  * @param {import('../auth/AuthCore.js').AuthCore} authCore
382
382
  * @param {{ fetchFn?: typeof globalThis.fetch }} [options]
@@ -463,7 +463,7 @@ class C {
463
463
  );
464
464
  }
465
465
  }
466
- class L {
466
+ class z {
467
467
  constructor(e) {
468
468
  this.api = e;
469
469
  }
@@ -523,6 +523,11 @@ class L {
523
523
  * the response shape changes from a flat list to `{results: {<expertise_type>: [items]}}`
524
524
  * keyed by expertise type (decision, constraint, learned, opinion, reasoning, observation).
525
525
  * Each bucket holds up to topK items.
526
+ * @param {boolean} [options.includeConsolidated=false] - When true (CORE-CONSOLIDATE-1),
527
+ * include consolidated source memories (normally hidden) in results.
528
+ * @param {boolean} [options.consolidationFirst=false] - When true (NEURO-1d), surface a
529
+ * consolidated summary above the scattered source memories it consolidates — best for
530
+ * synthesis queries. Opt-in; implies includeConsolidated.
526
531
  * @param {boolean} [options.cite=false] - When true (RECALL-CITATIONS-1), the
527
532
  * envelope gains a `citations` array of `{n, item_id, item_type, preview, score, footnote_marker}`.
528
533
  * Empty `citations: []` when no results — distinguishes "no results" from "no citations requested".
@@ -535,9 +540,9 @@ class L {
535
540
  * present only under `cite: true`. Pre-LINEAGE-1 callers who indexed into a
536
541
  * bare array must read `response.results` instead.
537
542
  */
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 } = {}) {
543
+ 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, includeConsolidated: v = !1, consolidationFirst: A = !1 } = {}) {
539
544
  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);
545
+ 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), v && (l.include_consolidated = !0), A && (l.consolidation_first = !0), this.api.post("/memory/search", l);
541
546
  }
542
547
  async getWorkingContext(e, t, { k: r = 20, maxTokens: s = null, strategy: n = null } = {}) {
543
548
  const a = {
@@ -700,7 +705,7 @@ class L {
700
705
  return this.api.get("/memory/clustering/stats");
701
706
  }
702
707
  }
703
- class M {
708
+ class E {
704
709
  constructor(e) {
705
710
  this.api = e;
706
711
  }
@@ -877,7 +882,7 @@ class M {
877
882
  });
878
883
  }
879
884
  }
880
- class z {
885
+ class O {
881
886
  constructor(e) {
882
887
  this.api = e;
883
888
  }
@@ -899,7 +904,7 @@ class z {
899
904
  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
905
  }
901
906
  }
902
- class E {
907
+ class x {
903
908
  constructor(e) {
904
909
  this.api = e;
905
910
  }
@@ -984,8 +989,45 @@ class E {
984
989
  async getLinks(e) {
985
990
  return this.api.get(`/memory/${encodeURIComponent(e)}/links`);
986
991
  }
992
+ /**
993
+ * Merge unambiguous single-token entity aliases ("Hudson") into their
994
+ * multi-token canonical ("Rock Hudson") over the caller's workspace graph,
995
+ * abstaining on collisions (>=2 canonical candidates).
996
+ *
997
+ * `dry_run` is a query parameter (matching the /clustering/run precedent),
998
+ * not a JSON body — POST .../resolve-aliases?dry_run=true.
999
+ *
1000
+ * @param {Object} [options]
1001
+ * @param {boolean} [options.dryRun=false] - Compute the resolve/abstain plan and report counts without mutating the graph.
1002
+ * @param {boolean} [options.disambiguate=false] - Opt-in (CORE-GRAPH-ALIAS-DISAMBIG-1): additionally recover colliding surfaces by structural typed-neighbor overlap, merging only on a confident, clear winner (never mis-merge). Extractor-dependent; helps LLM-extracted graphs.
1003
+ * @returns {Promise<AliasResolveReport>}
1004
+ */
1005
+ async resolveAliases({ dryRun: e = !1, disambiguate: t = !1 } = {}) {
1006
+ return this.api.post(`/memory/graph/resolve-aliases?dry_run=${e}&disambiguate=${t}`);
1007
+ }
1008
+ /**
1009
+ * Dedup cross-extractor fragmented entity nodes (CORE-GRAPH-CANONICAL-DEDUP-1).
1010
+ *
1011
+ * Collapses same-name entity-node fragments (the same entity split across >1 node because two
1012
+ * extractors disagreed on its type -> divergent canonical_key -> the write-time dedup missed them)
1013
+ * into one node, precision-first, over the caller's workspace graph. Unblocks ensemble alias
1014
+ * disambiguation. Opt-in, default-off. Recommended ensemble sequence: dedupEntities() then
1015
+ * resolveAliases({ disambiguate: true }).
1016
+ *
1017
+ * Both flags are query parameters, not a JSON body — POST .../dedup-entities?dry_run=true.
1018
+ *
1019
+ * @param {Object} [options]
1020
+ * @param {boolean} [options.dryRun=false] - Compute the dedup plan and report counts without mutating the graph.
1021
+ * @param {boolean} [options.requireStructuralConfirmation=true] - When true, a same-name pair merges only on T0 (same QID), T1 (same canonical_key), or T2 (>= tau_min shared typed entity-neighbors). When false, exact same-name clusters merge on name alone once T0/T1 fail (riskier disjoint-edge-tail recovery).
1022
+ * @returns {Promise<EntityDedupReport>}
1023
+ */
1024
+ async dedupEntities({ dryRun: e = !1, requireStructuralConfirmation: t = !0 } = {}) {
1025
+ return this.api.post(
1026
+ `/memory/graph/dedup-entities?dry_run=${e}&require_structural_confirmation=${t}`
1027
+ );
1028
+ }
987
1029
  }
988
- class O {
1030
+ class q {
989
1031
  constructor(e) {
990
1032
  this.api = e;
991
1033
  }
@@ -1025,7 +1067,7 @@ class O {
1025
1067
  return this.api.delete(`/memory/teams/${e}/members/${t}`);
1026
1068
  }
1027
1069
  }
1028
- class x {
1070
+ class j {
1029
1071
  constructor(e) {
1030
1072
  this.api = e;
1031
1073
  }
@@ -1042,7 +1084,7 @@ class x {
1042
1084
  return this.api.patch("/auth/llm-keys", e);
1043
1085
  }
1044
1086
  }
1045
- class q {
1087
+ class F {
1046
1088
  constructor(e) {
1047
1089
  this.api = e;
1048
1090
  }
@@ -1068,7 +1110,7 @@ class q {
1068
1110
  });
1069
1111
  }
1070
1112
  }
1071
- class j {
1113
+ class K {
1072
1114
  constructor(e) {
1073
1115
  this.api = e;
1074
1116
  }
@@ -1089,7 +1131,7 @@ class j {
1089
1131
  return this.api.delete(`/memory/api-keys/${e}`);
1090
1132
  }
1091
1133
  }
1092
- class F {
1134
+ class H {
1093
1135
  constructor(e) {
1094
1136
  this.api = e;
1095
1137
  }
@@ -1148,7 +1190,7 @@ class F {
1148
1190
  return this.api.get(`/memory/agents/${e}/evaluation/history${n ? "?" + n : ""}`);
1149
1191
  }
1150
1192
  }
1151
- class K {
1193
+ class B {
1152
1194
  constructor(e) {
1153
1195
  this.api = e;
1154
1196
  }
@@ -1162,7 +1204,7 @@ class K {
1162
1204
  return this.api.get("/usage/tiers");
1163
1205
  }
1164
1206
  }
1165
- class H {
1207
+ class D {
1166
1208
  constructor(e) {
1167
1209
  this.api = e;
1168
1210
  }
@@ -1179,7 +1221,7 @@ class H {
1179
1221
  return this.api.get("/memory/plugins");
1180
1222
  }
1181
1223
  }
1182
- class B {
1224
+ class G {
1183
1225
  constructor(e) {
1184
1226
  this.api = e;
1185
1227
  }
@@ -1202,7 +1244,7 @@ class B {
1202
1244
  return this.api.get("/memory/token-usage/current");
1203
1245
  }
1204
1246
  }
1205
- class D {
1247
+ class N {
1206
1248
  constructor(e) {
1207
1249
  this.api = e;
1208
1250
  }
@@ -1348,7 +1390,7 @@ class D {
1348
1390
  return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
1349
1391
  }
1350
1392
  }
1351
- class G {
1393
+ class V {
1352
1394
  constructor(e) {
1353
1395
  this.api = e;
1354
1396
  }
@@ -1417,7 +1459,7 @@ class G {
1417
1459
  return this.api.get("/memory/governance/summary");
1418
1460
  }
1419
1461
  }
1420
- class N {
1462
+ class J {
1421
1463
  constructor(e) {
1422
1464
  this.api = e;
1423
1465
  }
@@ -1458,7 +1500,7 @@ class N {
1458
1500
  return this.api.post("/memory/evolution/reinforce/opinions");
1459
1501
  }
1460
1502
  }
1461
- class V {
1503
+ class W {
1462
1504
  constructor(e) {
1463
1505
  this.api = e;
1464
1506
  }
@@ -1556,7 +1598,7 @@ class V {
1556
1598
  });
1557
1599
  }
1558
1600
  }
1559
- class J {
1601
+ class Y {
1560
1602
  constructor(e) {
1561
1603
  this.api = e;
1562
1604
  }
@@ -1610,7 +1652,7 @@ class J {
1610
1652
  return this.api.get(`/memory/reasoning/traces/${e}`);
1611
1653
  }
1612
1654
  }
1613
- class W {
1655
+ class Z {
1614
1656
  constructor(e) {
1615
1657
  this.api = e;
1616
1658
  }
@@ -1978,7 +2020,7 @@ class W {
1978
2020
  return this.api.get(`/memory/ontology/updates/stats?history=${e}`);
1979
2021
  }
1980
2022
  }
1981
- class Y {
2023
+ class X {
1982
2024
  constructor(e) {
1983
2025
  this.api = e;
1984
2026
  }
@@ -2007,7 +2049,7 @@ class Y {
2007
2049
  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);
2008
2050
  }
2009
2051
  }
2010
- class Z {
2052
+ class Q {
2011
2053
  constructor(e) {
2012
2054
  this.api = e;
2013
2055
  }
@@ -2043,7 +2085,7 @@ class Z {
2043
2085
  return this.api.get("/memory/validation/inference/rules");
2044
2086
  }
2045
2087
  }
2046
- class X {
2088
+ class ee {
2047
2089
  constructor(e) {
2048
2090
  this.api = e;
2049
2091
  }
@@ -2159,7 +2201,7 @@ class X {
2159
2201
  return this.api.delete(`/memory/pipeline/configs/${e}`);
2160
2202
  }
2161
2203
  }
2162
- class Q {
2204
+ class te {
2163
2205
  constructor(e) {
2164
2206
  this.api = e;
2165
2207
  }
@@ -2185,7 +2227,7 @@ class Q {
2185
2227
  return this.api.get(`/memory/archive/${e}`);
2186
2228
  }
2187
2229
  }
2188
- class ee {
2230
+ class re {
2189
2231
  constructor(e) {
2190
2232
  this.api = e;
2191
2233
  }
@@ -2344,7 +2386,7 @@ class ee {
2344
2386
  return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${r}`);
2345
2387
  }
2346
2388
  }
2347
- class te {
2389
+ class se {
2348
2390
  constructor(e) {
2349
2391
  this.api = e;
2350
2392
  }
@@ -2380,7 +2422,7 @@ class te {
2380
2422
  return this.api.get("/memory/procedures/matches/stats");
2381
2423
  }
2382
2424
  }
2383
- class re {
2425
+ class ne {
2384
2426
  constructor(e) {
2385
2427
  this.api = e;
2386
2428
  }
@@ -2429,7 +2471,7 @@ class re {
2429
2471
  return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
2430
2472
  }
2431
2473
  }
2432
- class se {
2474
+ class ie {
2433
2475
  constructor(e) {
2434
2476
  this.api = e;
2435
2477
  }
@@ -2484,7 +2526,7 @@ class se {
2484
2526
  return this.api.get(`/memory/procedures/schemas/${e}`);
2485
2527
  }
2486
2528
  }
2487
- class ne {
2529
+ class ae {
2488
2530
  constructor(e) {
2489
2531
  this.api = e;
2490
2532
  }
@@ -2556,11 +2598,11 @@ class ne {
2556
2598
  return this.api.delete(`/memory/summary/${e}`);
2557
2599
  }
2558
2600
  }
2559
- class ae {
2601
+ class ce {
2560
2602
  constructor(e) {
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);
2603
+ this.auth = new L(e);
2604
+ const t = new M(this.auth, { fetchFn: e.fetchFn });
2605
+ this.memories = new z(t), this.decisions = new E(t), this.opinions = new O(t), this.graph = new x(t), this.teams = new q(t), this.profiles = new j(t), this.subscriptions = new F(t), this.authAPI = new K(t), this.agents = new H(t), this.usage = new B(t), this.insights = new D(t), this.tokenUsage = new G(t), this.temporal = new N(t), this.governance = new V(t), this.evolution = new J(t), this.reasoning = new W(t), this.reasoningTraces = new Y(t), this.ontology = new Z(t), this.analytics = new X(t), this.validation = new Q(t), this.pipeline = new ee(t), this.archive = new te(t), this.zettelkasten = new re(t), this.procedureMatches = new se(t), this.procedureCandidates = new ne(t), this.procedureDrift = new ie(t), this.summaries = new ae(t);
2564
2606
  }
2565
2607
  setTeamId(e) {
2566
2608
  this.auth.tokenManager.setTeamId(e), this.auth.notifyListeners();
@@ -2571,35 +2613,35 @@ class ae {
2571
2613
  }
2572
2614
  export {
2573
2615
  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,
2601
- q as n,
2602
- D as o,
2603
- A as p,
2604
- B as q
2616
+ M as B,
2617
+ E as D,
2618
+ J as E,
2619
+ V as G,
2620
+ D as I,
2621
+ z as M,
2622
+ Z as O,
2623
+ ee as P,
2624
+ W as R,
2625
+ ce as S,
2626
+ q as T,
2627
+ B as U,
2628
+ Q as V,
2629
+ re as Z,
2630
+ H as a,
2631
+ X as b,
2632
+ te as c,
2633
+ K as d,
2634
+ L as e,
2635
+ x as f,
2636
+ O as g,
2637
+ ne as h,
2638
+ se as i,
2639
+ j,
2640
+ Y as k,
2641
+ F as l,
2642
+ N as m,
2643
+ U as n,
2644
+ G as o,
2645
+ P as p,
2646
+ C as q
2605
2647
  };
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 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";
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, p as M, q as h, S as m, l as S, T as f, n as p, U as l } from "./core-CLtPrdbi.js";
2
2
  export {
3
3
  e as APIError,
4
4
  r as AgentAPI,
@@ -10,9 +10,9 @@ export {
10
10
  t as InsightsAPI,
11
11
  i as MemoryAPI,
12
12
  g as ProfileAPI,
13
- m as RefreshManager,
14
- M as SSOManager,
15
- h as SmartMemoryClient,
13
+ M as RefreshManager,
14
+ h as SSOManager,
15
+ m as SmartMemoryClient,
16
16
  S as SubscriptionAPI,
17
17
  f as TeamAPI,
18
18
  p as TokenManager,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
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";
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 S, S as R, l as F, T as M, m as L, n as O, o as G, U, V as $, Z as D } from "./core-CLtPrdbi.js";
2
2
  const i = {
3
3
  variables: {
4
4
  colorBackground: "transparent",
@@ -95,8 +95,8 @@ export {
95
95
  y as ProcedureMatchAPI,
96
96
  C as ProfileAPI,
97
97
  E as ReasoningAPI,
98
- R as ReasoningTracesAPI,
99
- S as SmartMemoryClient,
98
+ S as ReasoningTracesAPI,
99
+ R as SmartMemoryClient,
100
100
  F as SubscriptionAPI,
101
101
  M as TeamAPI,
102
102
  L as TemporalAPI,
package/dist/progress.js CHANGED
@@ -1,57 +1,57 @@
1
- async function P(r, n) {
1
+ async function _(r, n) {
2
2
  const t = r.getReader();
3
3
  let e;
4
4
  for (; !(e = await t.read()).done; )
5
5
  n(e.value);
6
6
  }
7
- function j(r) {
7
+ function R(r) {
8
8
  let n, t, e, o = !1;
9
- return function(a) {
10
- n === void 0 ? (n = a, t = 0, e = -1) : n = L(n, a);
9
+ return function(s) {
10
+ n === void 0 ? (n = s, t = 0, e = -1) : n = L(n, s);
11
11
  const i = n.length;
12
- let s = 0;
12
+ let a = 0;
13
13
  for (; t < i; ) {
14
- o && (n[t] === 10 && (s = ++t), o = !1);
15
- let l = -1;
16
- for (; t < i && l === -1; ++t)
14
+ o && (n[t] === 10 && (a = ++t), o = !1);
15
+ let c = -1;
16
+ for (; t < i && c === -1; ++t)
17
17
  switch (n[t]) {
18
18
  case 58:
19
- e === -1 && (e = t - s);
19
+ e === -1 && (e = t - a);
20
20
  break;
21
21
  case 13:
22
22
  o = !0;
23
23
  case 10:
24
- l = t;
24
+ c = t;
25
25
  break;
26
26
  }
27
- if (l === -1)
27
+ if (c === -1)
28
28
  break;
29
- r(n.subarray(s, l), e), s = t, e = -1;
29
+ r(n.subarray(a, c), e), a = t, e = -1;
30
30
  }
31
- s === i ? n = void 0 : s !== 0 && (n = n.subarray(s), t -= s);
31
+ a === i ? n = void 0 : a !== 0 && (n = n.subarray(a), t -= a);
32
32
  };
33
33
  }
34
- function x(r, n, t) {
35
- let e = k();
34
+ function P(r, n, t) {
35
+ let e = A();
36
36
  const o = new TextDecoder();
37
- return function(a, i) {
38
- if (a.length === 0)
39
- t == null || t(e), e = k();
37
+ return function(s, i) {
38
+ if (s.length === 0)
39
+ t == null || t(e), e = A();
40
40
  else if (i > 0) {
41
- const s = o.decode(a.subarray(0, i)), l = i + (a[i + 1] === 32 ? 2 : 1), c = o.decode(a.subarray(l));
42
- switch (s) {
41
+ const a = o.decode(s.subarray(0, i)), c = i + (s[i + 1] === 32 ? 2 : 1), l = o.decode(s.subarray(c));
42
+ switch (a) {
43
43
  case "data":
44
44
  e.data = e.data ? e.data + `
45
- ` + c : c;
45
+ ` + l : l;
46
46
  break;
47
47
  case "event":
48
- e.event = c;
48
+ e.event = l;
49
49
  break;
50
50
  case "id":
51
- r(e.id = c);
51
+ r(e.id = l);
52
52
  break;
53
53
  case "retry":
54
- const f = parseInt(c, 10);
54
+ const f = parseInt(l, 10);
55
55
  isNaN(f) || n(e.retry = f);
56
56
  break;
57
57
  }
@@ -62,7 +62,7 @@ function L(r, n) {
62
62
  const t = new Uint8Array(r.length + n.length);
63
63
  return t.set(r), t.set(n, r.length), t;
64
64
  }
65
- function k() {
65
+ function A() {
66
66
  return {
67
67
  data: "",
68
68
  event: "",
@@ -70,7 +70,7 @@ function k() {
70
70
  retry: void 0
71
71
  };
72
72
  }
73
- var $ = function(r, n) {
73
+ var j = function(r, n) {
74
74
  var t = {};
75
75
  for (var e in r) Object.prototype.hasOwnProperty.call(r, e) && n.indexOf(e) < 0 && (t[e] = r[e]);
76
76
  if (r != null && typeof Object.getOwnPropertySymbols == "function")
@@ -78,114 +78,115 @@ var $ = function(r, n) {
78
78
  n.indexOf(e[o]) < 0 && Object.prototype.propertyIsEnumerable.call(r, e[o]) && (t[e[o]] = r[e[o]]);
79
79
  return t;
80
80
  };
81
- const T = "text/event-stream", C = 1e3, I = "last-event-id";
82
- function H(r, n) {
83
- var { signal: t, headers: e, onopen: o, onmessage: h, onclose: a, onerror: i, openWhenHidden: s, fetch: l } = n, c = $(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
84
- return new Promise((f, w) => {
85
- const b = Object.assign({}, e);
86
- b.accept || (b.accept = T);
81
+ const k = "text/event-stream", x = 1e3, I = "last-event-id";
82
+ function N(r, n) {
83
+ var { signal: t, headers: e, onopen: o, onmessage: g, onclose: s, onerror: i, openWhenHidden: a, fetch: c } = n, l = j(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
84
+ return new Promise((f, E) => {
85
+ const y = Object.assign({}, e);
86
+ y.accept || (y.accept = k);
87
87
  let v;
88
- function g() {
89
- v.abort(), document.hidden || S();
88
+ function h() {
89
+ v.abort(), document.hidden || O();
90
90
  }
91
- s || document.addEventListener("visibilitychange", g);
92
- let p = C, d = 0;
91
+ a || document.addEventListener("visibilitychange", h);
92
+ let d = x, b = 0;
93
93
  function u() {
94
- document.removeEventListener("visibilitychange", g), window.clearTimeout(d), v.abort();
94
+ document.removeEventListener("visibilitychange", h), window.clearTimeout(b), v.abort();
95
95
  }
96
96
  t == null || t.addEventListener("abort", () => {
97
97
  u(), f();
98
98
  });
99
- const m = l ?? window.fetch, _ = o ?? R;
100
- async function S() {
101
- var O;
99
+ const w = c ?? window.fetch, m = o ?? $;
100
+ async function O() {
101
+ var T;
102
102
  v = new AbortController();
103
103
  try {
104
- const E = await m(r, Object.assign(Object.assign({}, c), { headers: b, signal: v.signal }));
105
- await _(E), await P(E.body, j(x((y) => {
106
- y ? b[I] = y : delete b[I];
107
- }, (y) => {
108
- p = y;
109
- }, h))), a == null || a(), u(), f();
110
- } catch (E) {
104
+ const S = await w(r, Object.assign(Object.assign({}, l), { headers: y, signal: v.signal }));
105
+ await m(S), await _(S.body, R(P((p) => {
106
+ p ? y[I] = p : delete y[I];
107
+ }, (p) => {
108
+ d = p;
109
+ }, g))), s == null || s(), u(), f();
110
+ } catch (S) {
111
111
  if (!v.signal.aborted)
112
112
  try {
113
- const y = (O = i == null ? void 0 : i(E)) !== null && O !== void 0 ? O : p;
114
- window.clearTimeout(d), d = window.setTimeout(S, y);
115
- } catch (y) {
116
- u(), w(y);
113
+ const p = (T = i == null ? void 0 : i(S)) !== null && T !== void 0 ? T : d;
114
+ window.clearTimeout(b), b = window.setTimeout(O, p);
115
+ } catch (p) {
116
+ u(), E(p);
117
117
  }
118
118
  }
119
119
  }
120
- S();
120
+ O();
121
121
  });
122
122
  }
123
- function R(r) {
123
+ function $(r) {
124
124
  const n = r.headers.get("content-type");
125
- if (!(n != null && n.startsWith(T)))
126
- throw new Error(`Expected content-type to be ${T}, Actual: ${n}`);
125
+ if (!(n != null && n.startsWith(k)))
126
+ throw new Error(`Expected content-type to be ${k}, Actual: ${n}`);
127
127
  }
128
- const N = "/memory/progress/stream", A = 3, W = 1e3;
129
- function q(r) {
128
+ const C = "/memory/progress/stream", H = 3, W = 1e3, q = /* @__PURE__ */ new Set([401, 403, 404]);
129
+ function U(r) {
130
130
  const {
131
131
  baseUrl: n = "",
132
132
  token: t,
133
133
  apiKey: e,
134
134
  workspaceId: o,
135
- runId: h,
136
- fromSeq: a,
135
+ runId: g,
136
+ fromSeq: s,
137
137
  since: i,
138
- onEvent: s,
139
- onError: l,
140
- onReconnect: c
138
+ onEvent: a,
139
+ onError: c,
140
+ onReconnect: l
141
141
  } = r, f = new URLSearchParams();
142
- h !== void 0 && f.set("run_id", h), a !== void 0 && f.set("from_seq", String(a)), i !== void 0 && f.set("since", i);
143
- const w = f.toString(), b = `${n}${N}${w ? "?" + w : ""}`, v = {
142
+ g !== void 0 && f.set("run_id", g), s !== void 0 && f.set("from_seq", String(s)), i !== void 0 && f.set("since", i);
143
+ const E = f.toString(), y = `${n}${C}${E ? "?" + E : ""}`, v = {
144
144
  Accept: "text/event-stream"
145
145
  };
146
146
  t ? v.Authorization = `Bearer ${t}` : e && (v["X-API-Key"] = e), o && (v["X-Workspace-Id"] = o);
147
- const g = new AbortController();
148
- let p = !1, d = 0;
149
- return H(b, {
147
+ const h = new AbortController();
148
+ let d = !1, b = 0;
149
+ return N(y, {
150
150
  headers: v,
151
- signal: g.signal,
151
+ signal: h.signal,
152
152
  openWhenHidden: !0,
153
153
  async onopen(u) {
154
154
  if (u.ok) {
155
- d = 0;
155
+ b = 0;
156
156
  return;
157
157
  }
158
- throw new Error(`SSE connection failed: HTTP ${u.status}`);
158
+ const w = u.status, m = new Error(`SSE connection failed: HTTP ${w}`);
159
+ throw q.has(w) && (d = !0, c(m), h.abort()), m;
159
160
  },
160
161
  onmessage(u) {
161
- if (p || !u.data) return;
162
- d = 0;
163
- let m;
162
+ if (d || !u.data) return;
163
+ b = 0;
164
+ let w;
164
165
  try {
165
- m = JSON.parse(u.data);
166
+ w = JSON.parse(u.data);
166
167
  } catch {
167
168
  return;
168
169
  }
169
- s(m);
170
+ a(w);
170
171
  },
171
172
  onerror(u) {
172
- if (!p) {
173
- if (d += 1, d >= A) {
174
- l(u), g.abort(), p = !0;
173
+ if (!d) {
174
+ if (b += 1, b >= H) {
175
+ c(u), d = !0, h.abort();
175
176
  return;
176
177
  }
177
- return c == null || c(), W * d;
178
+ return l == null || l(), W * b;
178
179
  }
179
180
  },
180
181
  onclose() {
181
- p || (d += 1, d >= A ? (l(new Error("SSE connection closed by server")), p = !0) : c == null || c());
182
+ d || (d = !0, c(new Error("SSE connection closed by server")));
182
183
  }
183
184
  }), {
184
185
  close() {
185
- p || (p = !0, g.abort());
186
+ d || (d = !0, h.abort());
186
187
  }
187
188
  };
188
189
  }
189
190
  export {
190
- q as subscribeProgress
191
+ U as subscribeProgress
191
192
  };
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 m } from "react";
2
- import { m as x } from "./core-BIdNSA4o.js";
3
- const f = d(null), g = d(null);
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-CLtPrdbi.js";
3
+ const m = 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]), w = c((i) => t.auth.getLoginUrl(i), [t]), S = {
26
+ }, [t]), A = c((i) => t.auth.hasRole(i), [t]), S = c((i) => t.auth.getLoginUrl(i), [t]), w = {
27
27
  ...u,
28
28
  logout: s,
29
29
  hasRole: A,
30
- getLoginUrl: w
30
+ getLoginUrl: S
31
31
  };
32
- return /* @__PURE__ */ h.createElement(f.Provider, { value: S }, /* @__PURE__ */ h.createElement(g.Provider, { value: t }, e));
32
+ return /* @__PURE__ */ h.createElement(m.Provider, { value: w }, /* @__PURE__ */ h.createElement(g.Provider, { value: t }, e));
33
33
  }
34
34
  function l() {
35
- const e = m(f);
35
+ const e = f(m);
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 = m(g);
49
+ const e = f(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
- f as AuthContext,
69
+ m as AuthContext,
70
70
  I as AuthWrapper,
71
71
  g as ClientContext,
72
72
  U as SmartMemoryProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartmemory/sdk-js",
3
- "version": "0.6.4",
3
+ "version": "1.4.25",
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",