@smartmemory/sdk-js 1.4.59 → 1.4.60

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 CHANGED
@@ -185,6 +185,9 @@ client.memories.delete(id);
185
185
  client.memories.list({ limit: 50, offset: 0, type: 'semantic' });
186
186
  client.memories.search('query', { topK: 5, enableHybrid: true });
187
187
  client.memories.searchAdvanced('query', { algorithm: 'query_traversal' });
188
+ // Time travel and provenance (auditable memory)
189
+ client.memories.search('query', { asOfDate: '2026-06-01T00:00:00Z', includeSuperseded: true });
190
+ client.memories.explain(memoryId); // origin, version audit, supersession lineage, chain verification
188
191
  client.memories.ingest('content', { extractorName: 'llm' });
189
192
  client.memories.getSummary();
190
193
  client.memories.link(sourceId, targetId, 'RELATED');
@@ -2,8 +2,8 @@ var S = (a) => {
2
2
  throw TypeError(a);
3
3
  };
4
4
  var w = (a, e, t) => e.has(a) || S("Cannot " + t);
5
- var d = (a, e, t) => (w(a, e, "read from private field"), t ? t.call(a) : e.get(a)), b = (a, e, t) => e.has(a) ? S("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, t), I = (a, e, t, s) => (w(a, e, "write to private field"), s ? s.call(a, t) : e.set(a, t), t), v = (a, e, t) => (w(a, e, "access private method"), t);
6
- const P = {
5
+ var g = (a, e, t) => (w(a, e, "read from private field"), t ? t.call(a) : e.get(a)), b = (a, e, t) => e.has(a) ? S("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, t), I = (a, e, t, s) => (w(a, e, "write to private field"), s ? s.call(a, t) : e.set(a, t), t), T = (a, e, t) => (w(a, e, "access private method"), t);
6
+ const q = {
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 P = {
16
16
  tenant: ["tenant_id", "workspace_id", "sm_workspace_id"],
17
17
  team: ["team_id", "sm_team_id"]
18
18
  };
19
- class L {
19
+ class M {
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 = { ...P, ...t }, this._memory = { access: null, refresh: null, user: null, tenant: null, team: null };
26
+ this.storageType = e, this.keys = { ...q, ...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, y.access);
@@ -148,8 +148,8 @@ class L {
148
148
  return s === "none" || s === "null" || s === "undefined" ? null : t;
149
149
  }
150
150
  }
151
- var l, _, T;
152
- class q {
151
+ var m, _, v;
152
+ class z {
153
153
  /**
154
154
  * @param {Object} options
155
155
  * @param {string} options.apiBaseUrl
@@ -161,21 +161,21 @@ class q {
161
161
  */
162
162
  constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager: s, useCookieAuth: r = !1, onTokenRefreshed: n, onRefreshFailed: i }) {
163
163
  b(this, _);
164
- b(this, l, null);
164
+ b(this, m, null);
165
165
  this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager = s, this.useCookieAuth = r, this.onTokenRefreshed = n, this.onRefreshFailed = i;
166
166
  }
167
167
  async refresh() {
168
- if (d(this, l))
169
- return d(this, l);
170
- I(this, l, v(this, _, T).call(this));
168
+ if (g(this, m))
169
+ return g(this, m);
170
+ I(this, m, T(this, _, v).call(this));
171
171
  try {
172
- return await d(this, l);
172
+ return await g(this, m);
173
173
  } finally {
174
- I(this, l, null);
174
+ I(this, m, null);
175
175
  }
176
176
  }
177
177
  }
178
- l = new WeakMap(), _ = new WeakSet(), T = async function() {
178
+ m = new WeakMap(), _ = new WeakSet(), v = async function() {
179
179
  const e = this.tokenManager.getRefreshToken();
180
180
  if (!e && !this.useCookieAuth)
181
181
  throw this.onRefreshFailed(), new Error("No refresh token");
@@ -191,7 +191,7 @@ l = new WeakMap(), _ = new WeakSet(), T = async function() {
191
191
  return this.tokenManager.setAccessToken(r.access_token), r.refresh_token && this.tokenManager.setRefreshToken(r.refresh_token), this.onTokenRefreshed(r.access_token), r.access_token;
192
192
  };
193
193
  const R = "smart_memory_sso_redirect";
194
- class M {
194
+ class E {
195
195
  /**
196
196
  * @param {Object} options
197
197
  * @param {string} options.webAppUrl - Web app URL for login redirect
@@ -230,12 +230,12 @@ class M {
230
230
  }
231
231
  }
232
232
  }
233
- class z {
233
+ class x {
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 L({
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 M({
236
236
  storage: e.storage || "localStorage",
237
237
  keys: e.tokenKeys
238
- }), this.mode !== "apiKey" ? this.refreshManager = new q({
238
+ }), this.mode !== "apiKey" ? this.refreshManager = new z({
239
239
  apiBaseUrl: this.apiBaseUrl,
240
240
  refreshEndpoint: this.endpoints.refresh || "/auth/refresh",
241
241
  tokenManager: this.tokenManager,
@@ -247,7 +247,7 @@ class z {
247
247
  onRefreshFailed: () => {
248
248
  this.clearLocalAuth();
249
249
  }
250
- }) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new M({
250
+ }) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new E({
251
251
  webAppUrl: e.webAppUrl,
252
252
  allowedHosts: e.allowedRedirectHosts || [],
253
253
  tokenManager: this.tokenManager
@@ -380,7 +380,7 @@ class h extends Error {
380
380
  function f(a) {
381
381
  return typeof FormData < "u" && a instanceof FormData;
382
382
  }
383
- class E {
383
+ class O {
384
384
  /**
385
385
  * @param {import('../auth/AuthCore.js').AuthCore} authCore
386
386
  * @param {{ fetchFn?: typeof globalThis.fetch }} [options]
@@ -402,13 +402,13 @@ class E {
402
402
  if (c.status === 401 && !t.__isRetry)
403
403
  try {
404
404
  await this.auth.refreshToken();
405
- const m = {
405
+ const l = {
406
406
  ...f(t.body) ? {} : { "Content-Type": "application/json" },
407
407
  ...this.auth.getAuthHeaders(t.headers)
408
408
  };
409
409
  c = await this.fetchFn(
410
410
  s,
411
- this.auth.getRequestOptions({ ...n, headers: m, __isRetry: !0 })
411
+ this.auth.getRequestOptions({ ...n, headers: l, __isRetry: !0 })
412
412
  );
413
413
  } catch {
414
414
  }
@@ -444,13 +444,13 @@ class E {
444
444
  if (c.status === 401 && !t.__isRetry)
445
445
  try {
446
446
  await this.auth.refreshToken();
447
- const m = {
447
+ const l = {
448
448
  ...f(t.body) ? {} : { "Content-Type": "application/json" },
449
449
  ...this.auth.getAuthHeaders(t.headers)
450
450
  };
451
451
  c = await this.fetchFn(
452
452
  s,
453
- this.auth.getRequestOptions({ ...n, headers: m, __isRetry: !0 })
453
+ this.auth.getRequestOptions({ ...n, headers: l, __isRetry: !0 })
454
454
  );
455
455
  } catch {
456
456
  }
@@ -527,7 +527,7 @@ class E {
527
527
  return typeof (e == null ? void 0 : e.message) == "string" ? e.message : `HTTP ${t}`;
528
528
  }
529
529
  }
530
- class x {
530
+ class F {
531
531
  constructor(e) {
532
532
  this.api = e;
533
533
  }
@@ -545,6 +545,11 @@ class x {
545
545
  * @param {boolean} [options.usePipeline=true] - Run the full extraction pipeline
546
546
  * @param {string} [options.profileName] - Pipeline profile, routed server-side
547
547
  * @param {Object} [options.conversationContext] - Conversation-aware extraction context
548
+ * @param {boolean} [options.embed] - SVC-EMBED-CONTROL-1 embedding override.
549
+ * `true` forces an embedding, `false` suppresses one, omitted leaves existing
550
+ * behaviour untouched. **Only valid with `usePipeline: false`** — the server
551
+ * answers 400 for the combination rather than silently ignoring it, because
552
+ * the ingestion pipeline has no per-item override.
548
553
  */
549
554
  async create({
550
555
  content: e,
@@ -552,16 +557,17 @@ class x {
552
557
  metadata: s = null,
553
558
  usePipeline: r = !0,
554
559
  profileName: n = null,
555
- conversationContext: i = null
560
+ conversationContext: i = null,
561
+ embed: o = null
556
562
  }) {
557
- const o = {
563
+ const c = {
558
564
  content: e,
559
565
  memory_type: t,
560
566
  metadata: s,
561
567
  use_pipeline: r,
562
568
  profile_name: n
563
569
  };
564
- return i != null && (o.conversation_context = i), this.api.post("/memory/add", o);
570
+ return i != null && (c.conversation_context = i), o != null && (c.embed = o), this.api.post("/memory/add", c);
565
571
  }
566
572
  async get(e) {
567
573
  const t = await this.api.get(`/memory/${e}`);
@@ -591,6 +597,28 @@ class x {
591
597
  reason: n
592
598
  });
593
599
  }
600
+ /**
601
+ * Link two ALREADY-STORED items as a supersession (SVC-SUPERSEDE-LINK-1).
602
+ *
603
+ * Use this when both records exist. Use {@link supersede} instead when the
604
+ * replacement still has to be created from content.
605
+ *
606
+ * The write stamps the OLD record with `superseded`, `superseded_by` and
607
+ * `superseded_at`. Detect supersession by reading those off a recalled record —
608
+ * the newer record carries no marker, so never scan for inbound links.
609
+ *
610
+ * @param {string} id - The OLD item (the one being superseded)
611
+ * @param {string} newItemId - The NEW item; must already exist and be in scope
612
+ * @param {string} [reason] - Optional human-readable reason
613
+ * @throws 400 if `newItemId` equals `id`; 404 if either item is missing *or*
614
+ * out of scope (deliberately indistinguishable); 409 if the store declined.
615
+ */
616
+ async supersedeLink(e, t, s = null) {
617
+ return this.api.post(`/memory/${e}/supersede-link`, {
618
+ new_item_id: t,
619
+ reason: s
620
+ });
621
+ }
594
622
  async delete(e) {
595
623
  return this.api.delete(`/memory/${e}`);
596
624
  }
@@ -640,8 +668,18 @@ class x {
640
668
  * @param {string|Date|null} [options.asOfDate=null] - Transaction-time travel
641
669
  * (PLAT-AUDITABLE-MEMORY-1): return what the system believed at this
642
670
  * ISO-8601 instant. Date objects serialize to ISO automatically.
671
+ * @param {boolean} [options.asOfStrict=false] - Only meaningful with asOfDate
672
+ * (PLAT-AUDITABLE-MEMORY-1 gap #2). Default returns results that could not be
673
+ * resolved, each carrying `as_of_resolution: 'unresolved'`, and summarises them
674
+ * in the envelope's `as_of_diagnostics`. When true the request fails with 422
675
+ * instead, for callers who would rather have no answer than a partial history.
643
676
  * @param {boolean} [options.includeSuperseded=false] - Keep superseded items
644
677
  * visible in results (PLAT-AUDITABLE-MEMORY-1).
678
+ * @param {boolean} [options.includeRetracted=false] - Keep retracted items visible
679
+ * in results (CORE-RETRACTED-RECALL-1). A retracted belief was withdrawn outright
680
+ * with no replacement, so it is a separate lifecycle state from superseded and is
681
+ * NOT covered by includeSuperseded. Both are inert when asOfDate is set, which
682
+ * retains those rows regardless.
645
683
  * @param {boolean} [options.cite=false] - When true (RECALL-CITATIONS-1), the
646
684
  * envelope gains a `citations` array of `{n, item_id, item_type, preview, score, footnote_marker}`.
647
685
  * Empty `citations: []` when no results — distinguishes "no results" from "no citations requested".
@@ -652,11 +690,15 @@ class x {
652
690
  * carries `GroupRootStub`s for any lineage root_id referenced by some
653
691
  * result's `lineage_roots` but not itself in `results`; `citations` is
654
692
  * present only under `cite: true`. Pre-LINEAGE-1 callers who indexed into a
655
- * bare array must read `response.results` instead.
693
+ * bare array must read `response.results` instead. When `asOfDate` is set the
694
+ * envelope also carries `as_of_diagnostics` ({as_of, policy, unresolved_count,
695
+ * unresolved_item_ids, note}) and every result carries `as_of_resolution`. A
696
+ * result marked `'unresolved'` is PRESENT-DAY content and must not be rendered
697
+ * as a historical belief.
656
698
  */
657
- async search(e, { topK: t = 5, enableHybrid: s = !0, memoryType: r = null, expertise: n = !1, cite: i = !1, decompose: o = !1, multiHop: c = !1, maxHops: m = 3, budgetMs: p = 1500, semanticHops: $ = !1, includeReference: k = !1, includeConsolidated: U = !1, consolidationFirst: A = !1, asOfDate: g = null, includeSuperseded: C = !1 } = {}) {
699
+ async search(e, { topK: t = 5, enableHybrid: s = !0, memoryType: r = null, expertise: n = !1, cite: i = !1, decompose: o = !1, multiHop: c = !1, maxHops: l = 3, budgetMs: p = 1500, semanticHops: $ = !1, includeReference: k = !1, includeConsolidated: U = !1, consolidationFirst: A = !1, asOfDate: d = null, asOfStrict: C = !1, includeSuperseded: P = !1, includeRetracted: L = !1 } = {}) {
658
700
  const u = { query: e, top_k: t, enable_hybrid: s };
659
- return r && (u.memory_type = r), n && (u.expertise = !0), i && (u.cite = !0), o && (u.decompose = !0), c && (u.multi_hop = !0), c && m !== 3 && (u.max_hops = m), c && p !== 1500 && (u.budget_ms = p), c && $ && (u.semantic_hops = !0), k && (u.include_reference = !0), U && (u.include_consolidated = !0), A && (u.consolidation_first = !0), g && (u.as_of_date = g instanceof Date ? g.toISOString() : g), C && (u.include_superseded = !0), this.api.post("/memory/search", u);
701
+ return r && (u.memory_type = r), n && (u.expertise = !0), i && (u.cite = !0), o && (u.decompose = !0), c && (u.multi_hop = !0), c && l !== 3 && (u.max_hops = l), c && p !== 1500 && (u.budget_ms = p), c && $ && (u.semantic_hops = !0), k && (u.include_reference = !0), U && (u.include_consolidated = !0), A && (u.consolidation_first = !0), d && (u.as_of_date = d instanceof Date ? d.toISOString() : d), C && (u.as_of_strict = !0), P && (u.include_superseded = !0), L && (u.include_retracted = !0), this.api.post("/memory/search", u);
660
702
  }
661
703
  /**
662
704
  * Get the complete audit answer for one memory (PLAT-AUDITABLE-MEMORY-1).
@@ -848,7 +890,7 @@ class x {
848
890
  return this.api.get("/memory/clustering/stats");
849
891
  }
850
892
  }
851
- class O {
893
+ class j {
852
894
  constructor(e) {
853
895
  this.api = e;
854
896
  }
@@ -876,7 +918,7 @@ class O {
876
918
  evidenceIds: i = null,
877
919
  domain: o = null,
878
920
  tags: c = null,
879
- rejectedAlternatives: m = null,
921
+ rejectedAlternatives: l = null,
880
922
  rationale: p = null,
881
923
  constraints: $ = null,
882
924
  agentId: k = null
@@ -890,7 +932,7 @@ class O {
890
932
  evidence_ids: i,
891
933
  domain: o,
892
934
  tags: c,
893
- rejected_alternatives: m,
935
+ rejected_alternatives: l,
894
936
  rationale: p,
895
937
  constraints: $,
896
938
  agent_id: k
@@ -1066,7 +1108,7 @@ class O {
1066
1108
  });
1067
1109
  }
1068
1110
  }
1069
- class F {
1111
+ class H {
1070
1112
  constructor(e) {
1071
1113
  this.api = e;
1072
1114
  }
@@ -1088,7 +1130,7 @@ class F {
1088
1130
  return t.confidence !== void 0 && (s.confidence = t.confidence), t.subject !== void 0 && (s.subject = t.subject), t.subjectType !== void 0 && (s.subject_type = t.subjectType), t.disposition !== void 0 && (s.disposition = t.disposition), t.formedFrom !== void 0 && (s.formed_from = t.formedFrom), t.domain !== void 0 && (s.domain = t.domain), t.agentId !== void 0 && (s.agent_id = t.agentId), this.api.post("/memory/opinions/create", s);
1089
1131
  }
1090
1132
  }
1091
- class j {
1133
+ class B {
1092
1134
  constructor(e) {
1093
1135
  this.api = e;
1094
1136
  }
@@ -1223,7 +1265,7 @@ class j {
1223
1265
  );
1224
1266
  }
1225
1267
  }
1226
- class H {
1268
+ class K {
1227
1269
  constructor(e) {
1228
1270
  this.api = e;
1229
1271
  }
@@ -1265,7 +1307,7 @@ class H {
1265
1307
  return this.api.delete(`/memory/teams/${e}/members/${t}`);
1266
1308
  }
1267
1309
  }
1268
- class B {
1310
+ class G {
1269
1311
  constructor(e) {
1270
1312
  this.api = e;
1271
1313
  }
@@ -1287,7 +1329,7 @@ class B {
1287
1329
  return this.api.patch("/auth/llm-keys", e);
1288
1330
  }
1289
1331
  }
1290
- class K {
1332
+ class N {
1291
1333
  constructor(e) {
1292
1334
  this.api = e;
1293
1335
  }
@@ -1313,7 +1355,7 @@ class K {
1313
1355
  });
1314
1356
  }
1315
1357
  }
1316
- class G {
1358
+ class D {
1317
1359
  constructor(e) {
1318
1360
  this.api = e;
1319
1361
  }
@@ -1334,7 +1376,7 @@ class G {
1334
1376
  return this.api.delete(`/memory/api-keys/${e}`);
1335
1377
  }
1336
1378
  }
1337
- class N {
1379
+ class J {
1338
1380
  constructor(e) {
1339
1381
  this.api = e;
1340
1382
  }
@@ -1393,7 +1435,7 @@ class N {
1393
1435
  return this.api.get(`/memory/agents/${e}/evaluation/history${n ? "?" + n : ""}`);
1394
1436
  }
1395
1437
  }
1396
- class D {
1438
+ class W {
1397
1439
  constructor(e) {
1398
1440
  this.api = e;
1399
1441
  }
@@ -1407,7 +1449,7 @@ class D {
1407
1449
  return this.api.get("/usage/tiers");
1408
1450
  }
1409
1451
  }
1410
- class J {
1452
+ class V {
1411
1453
  constructor(e) {
1412
1454
  this.api = e;
1413
1455
  }
@@ -1424,7 +1466,7 @@ class J {
1424
1466
  return this.api.get("/memory/plugins");
1425
1467
  }
1426
1468
  }
1427
- class W {
1469
+ class Y {
1428
1470
  constructor(e) {
1429
1471
  this.api = e;
1430
1472
  }
@@ -1447,7 +1489,7 @@ class W {
1447
1489
  return this.api.get("/memory/token-usage/current");
1448
1490
  }
1449
1491
  }
1450
- class V {
1492
+ class X {
1451
1493
  constructor(e) {
1452
1494
  this.api = e;
1453
1495
  }
@@ -1593,7 +1635,7 @@ class V {
1593
1635
  return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
1594
1636
  }
1595
1637
  }
1596
- class Y {
1638
+ class Z {
1597
1639
  constructor(e) {
1598
1640
  this.api = e;
1599
1641
  }
@@ -1662,7 +1704,7 @@ class Y {
1662
1704
  return this.api.get("/memory/governance/summary");
1663
1705
  }
1664
1706
  }
1665
- class Z {
1707
+ class Q {
1666
1708
  constructor(e) {
1667
1709
  this.api = e;
1668
1710
  }
@@ -1703,7 +1745,7 @@ class Z {
1703
1745
  return this.api.post("/memory/evolution/reinforce/opinions");
1704
1746
  }
1705
1747
  }
1706
- class Q {
1748
+ class ee {
1707
1749
  constructor(e) {
1708
1750
  this.api = e;
1709
1751
  }
@@ -1801,7 +1843,7 @@ class Q {
1801
1843
  });
1802
1844
  }
1803
1845
  }
1804
- class X {
1846
+ class te {
1805
1847
  constructor(e) {
1806
1848
  this.api = e;
1807
1849
  }
@@ -1855,7 +1897,7 @@ class X {
1855
1897
  return this.api.get(`/memory/reasoning/traces/${e}`);
1856
1898
  }
1857
1899
  }
1858
- class ee {
1900
+ class se {
1859
1901
  constructor(e) {
1860
1902
  this.api = e;
1861
1903
  }
@@ -2425,7 +2467,7 @@ class ee {
2425
2467
  return r !== void 0 && (n.expected_tier = r), this.api.post("/memory/ontology/queue/bulk", n);
2426
2468
  }
2427
2469
  }
2428
- class te {
2470
+ class re {
2429
2471
  constructor(e) {
2430
2472
  this.api = e;
2431
2473
  }
@@ -2454,7 +2496,7 @@ class te {
2454
2496
  return e !== null && (r.protected_attributes = e), t !== null && (r.sentiment_analysis = t), s !== null && (r.topic_analysis = s), this.api.post("/memory/analytics/bias", r);
2455
2497
  }
2456
2498
  }
2457
- class se {
2499
+ class ne {
2458
2500
  constructor(e) {
2459
2501
  this.api = e;
2460
2502
  }
@@ -2490,7 +2532,7 @@ class se {
2490
2532
  return this.api.get("/memory/inference/rules");
2491
2533
  }
2492
2534
  }
2493
- class re {
2535
+ class ie {
2494
2536
  constructor(e) {
2495
2537
  this.api = e;
2496
2538
  }
@@ -2606,7 +2648,7 @@ class re {
2606
2648
  return this.api.delete(`/memory/pipeline/configs/${e}`);
2607
2649
  }
2608
2650
  }
2609
- class ne {
2651
+ class ae {
2610
2652
  constructor(e) {
2611
2653
  this.api = e;
2612
2654
  }
@@ -2632,7 +2674,7 @@ class ne {
2632
2674
  return this.api.get(`/memory/archive/${e}`);
2633
2675
  }
2634
2676
  }
2635
- class ie {
2677
+ class oe {
2636
2678
  constructor(e) {
2637
2679
  this.api = e;
2638
2680
  }
@@ -2791,7 +2833,7 @@ class ie {
2791
2833
  return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${s}`);
2792
2834
  }
2793
2835
  }
2794
- class ae {
2836
+ class ce {
2795
2837
  constructor(e) {
2796
2838
  this.api = e;
2797
2839
  }
@@ -2827,7 +2869,7 @@ class ae {
2827
2869
  return this.api.get("/memory/procedures/matches/stats");
2828
2870
  }
2829
2871
  }
2830
- class oe {
2872
+ class ue {
2831
2873
  constructor(e) {
2832
2874
  this.api = e;
2833
2875
  }
@@ -2876,7 +2918,7 @@ class oe {
2876
2918
  return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
2877
2919
  }
2878
2920
  }
2879
- class ce {
2921
+ class le {
2880
2922
  constructor(e) {
2881
2923
  this.api = e;
2882
2924
  }
@@ -2931,7 +2973,7 @@ class ce {
2931
2973
  return this.api.get(`/memory/procedures/schemas/${e}`);
2932
2974
  }
2933
2975
  }
2934
- class ue {
2976
+ class me {
2935
2977
  constructor(e) {
2936
2978
  this.api = e;
2937
2979
  }
@@ -3003,11 +3045,119 @@ class ue {
3003
3045
  return this.api.delete(`/memory/summary/${e}`);
3004
3046
  }
3005
3047
  }
3006
- class le {
3048
+ class he {
3049
+ constructor(e) {
3050
+ this.api = e;
3051
+ }
3052
+ /**
3053
+ * Acquire a lease, or return null when a live holder definitively owns it.
3054
+ * @param {string} key
3055
+ * @param {Object} [params]
3056
+ * @param {number} [params.ttlSeconds]
3057
+ * @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
3058
+ */
3059
+ async acquire(e, { ttlSeconds: t } = {}) {
3060
+ var r, n;
3061
+ const s = {};
3062
+ t !== void 0 && (s.ttl_seconds = t);
3063
+ try {
3064
+ return await this.api.post(`/memory/locks/${e}`, s);
3065
+ } catch (i) {
3066
+ if ((i == null ? void 0 : i.status) === 409 && ((n = (r = i.detail) == null ? void 0 : r.detail) == null ? void 0 : n.reason) === "lock_held")
3067
+ return null;
3068
+ throw i;
3069
+ }
3070
+ }
3071
+ /**
3072
+ * Renew a lease, or return null when this token definitively no longer owns it.
3073
+ * @param {string} key
3074
+ * @param {string} token
3075
+ * @param {Object} [params]
3076
+ * @param {number} [params.ttlSeconds]
3077
+ * @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
3078
+ */
3079
+ async renew(e, t, { ttlSeconds: s } = {}) {
3080
+ var n, i;
3081
+ const r = {};
3082
+ s !== void 0 && (r.ttl_seconds = s);
3083
+ try {
3084
+ return await this.api.post(`/memory/locks/${e}/renew`, r, {
3085
+ headers: { "X-Lease-Token": t }
3086
+ });
3087
+ } catch (o) {
3088
+ if ((o == null ? void 0 : o.status) === 409 && ((i = (n = o.detail) == null ? void 0 : n.detail) == null ? void 0 : i.reason) === "not_owner")
3089
+ return null;
3090
+ throw o;
3091
+ }
3092
+ }
3093
+ /**
3094
+ * Release a lease. Returns false when this token definitively no longer owns it.
3095
+ * @param {string} key
3096
+ * @param {string} token
3097
+ * @returns {Promise<boolean>}
3098
+ */
3099
+ async release(e, t) {
3100
+ var s, r;
3101
+ try {
3102
+ return await this.api.delete(`/memory/locks/${e}`, {
3103
+ headers: { "X-Lease-Token": t }
3104
+ }), !0;
3105
+ } catch (n) {
3106
+ if ((n == null ? void 0 : n.status) === 409 && ((r = (s = n.detail) == null ? void 0 : s.detail) == null ? void 0 : r.reason) === "not_owner")
3107
+ return !1;
3108
+ throw n;
3109
+ }
3110
+ }
3111
+ }
3112
+ class ye {
3113
+ constructor(e) {
3114
+ this.api = e;
3115
+ }
3116
+ /**
3117
+ * Consume the next numbers. The caller owns the inclusive range [first, value].
3118
+ *
3119
+ * Every non-2xx throws. Unlike the lease there is no benign failure to
3120
+ * swallow — returning null on a 503 would let a caller mistake coordinator
3121
+ * failure for an allocation, which is the one thing this primitive prevents.
3122
+ *
3123
+ * Numbers you do not use are LOST. There is no release and no reclaim; gaps
3124
+ * are guaranteed, so never treat `value` as a record count.
3125
+ *
3126
+ * @param {string} name
3127
+ * @param {Object} [params]
3128
+ * @param {number} [params.floor] High-water mark. Applied with `$max`, so it
3129
+ * can only ever raise the counter — safe and idempotent to send every call.
3130
+ * @param {number} [params.count] How many to allocate (1..100, default 1).
3131
+ * @returns {Promise<{name: string, value: number, first: number, count: number}>}
3132
+ */
3133
+ async allocate(e, { floor: t, count: s } = {}) {
3134
+ const r = {};
3135
+ return t !== void 0 && (r.floor = t), s !== void 0 && (r.count = s), this.api.post(`/memory/sequences/${e}/next`, r);
3136
+ }
3137
+ /**
3138
+ * Read the counter without consuming a number, or null if never allocated.
3139
+ *
3140
+ * Only a 404 becomes null. A 503 throws — a down coordinator is not the same
3141
+ * answer as "this sequence does not exist".
3142
+ *
3143
+ * @param {string} name
3144
+ * @returns {Promise<number|null>}
3145
+ */
3146
+ async peek(e) {
3147
+ try {
3148
+ const t = await this.api.get(`/memory/sequences/${e}`);
3149
+ return (t == null ? void 0 : t.value) ?? null;
3150
+ } catch (t) {
3151
+ if ((t == null ? void 0 : t.status) === 404) return null;
3152
+ throw t;
3153
+ }
3154
+ }
3155
+ }
3156
+ class de {
3007
3157
  constructor(e) {
3008
- this.auth = new z(e);
3009
- const t = new E(this.auth, { fetchFn: e.fetchFn });
3010
- this._api = t, this.memories = new x(t), this.decisions = new O(t), this.opinions = new F(t), this.graph = new j(t), this.teams = new H(t), this.profiles = new B(t), this.subscriptions = new K(t), this.authAPI = new G(t), this.agents = new N(t), this.usage = new D(t), this.insights = new J(t), this.tokenUsage = new W(t), this.temporal = new V(t), this.governance = new Y(t), this.evolution = new Z(t), this.reasoning = new Q(t), this.reasoningTraces = new X(t), this.ontology = new ee(t), this.analytics = new te(t), this.validation = new se(t), this.pipeline = new re(t), this.archive = new ne(t), this.zettelkasten = new ie(t), this.procedureMatches = new ae(t), this.procedureCandidates = new oe(t), this.procedureDrift = new ce(t), this.summaries = new ue(t);
3158
+ this.auth = new x(e);
3159
+ const t = new O(this.auth, { fetchFn: e.fetchFn });
3160
+ this._api = t, this.memories = new F(t), this.decisions = new j(t), this.opinions = new H(t), this.graph = new B(t), this.teams = new K(t), this.profiles = new G(t), this.subscriptions = new N(t), this.authAPI = new D(t), this.agents = new J(t), this.usage = new W(t), this.insights = new V(t), this.tokenUsage = new Y(t), this.temporal = new X(t), this.governance = new Z(t), this.evolution = new Q(t), this.reasoning = new ee(t), this.reasoningTraces = new te(t), this.ontology = new se(t), this.analytics = new re(t), this.validation = new ne(t), this.pipeline = new ie(t), this.archive = new ae(t), this.zettelkasten = new oe(t), this.procedureMatches = new ce(t), this.procedureCandidates = new ue(t), this.procedureDrift = new le(t), this.summaries = new me(t), this.locks = new he(t), this.sequences = new ye(t);
3011
3161
  }
3012
3162
  setTeamId(e) {
3013
3163
  this.auth.tokenManager.setTeamId(e), this.auth.notifyListeners();
@@ -3034,35 +3184,37 @@ class le {
3034
3184
  }
3035
3185
  export {
3036
3186
  h as A,
3037
- E as B,
3038
- O as D,
3039
- Z as E,
3040
- Y as G,
3041
- J as I,
3042
- x as M,
3043
- ee as O,
3044
- re as P,
3045
- Q as R,
3046
- le as S,
3047
- H as T,
3048
- D as U,
3049
- se as V,
3050
- ie as Z,
3051
- N as a,
3052
- te as b,
3053
- ne as c,
3054
- G as d,
3055
- z as e,
3056
- j as f,
3057
- F as g,
3058
- oe as h,
3059
- ae as i,
3060
- B as j,
3061
- X as k,
3062
- K as l,
3063
- V as m,
3064
- L as n,
3065
- W as o,
3066
- q as p,
3067
- M as q
3187
+ O as B,
3188
+ j as D,
3189
+ Q as E,
3190
+ Z as G,
3191
+ V as I,
3192
+ he as L,
3193
+ F as M,
3194
+ se as O,
3195
+ ie as P,
3196
+ ee as R,
3197
+ ye as S,
3198
+ K as T,
3199
+ W as U,
3200
+ ne as V,
3201
+ oe as Z,
3202
+ J as a,
3203
+ re as b,
3204
+ ae as c,
3205
+ D as d,
3206
+ x as e,
3207
+ B as f,
3208
+ H as g,
3209
+ ue as h,
3210
+ ce as i,
3211
+ G as j,
3212
+ te as k,
3213
+ de as l,
3214
+ N as m,
3215
+ X as n,
3216
+ M as o,
3217
+ Y as p,
3218
+ z as q,
3219
+ E as r
3068
3220
  };
package/dist/core.js CHANGED
@@ -1,20 +1,20 @@
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-BEScfRuq.js";
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 t, M as i, j as g, q as m, r as M, l as h, m as f, T as S, o as l, U as p } from "./core-Casbg124.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
- n as DecisionAPI,
9
- o as GraphAPI,
8
+ o as DecisionAPI,
9
+ n as GraphAPI,
10
10
  t as InsightsAPI,
11
11
  i as MemoryAPI,
12
12
  g as ProfileAPI,
13
- M as RefreshManager,
14
- h as SSOManager,
15
- m as SmartMemoryClient,
16
- S as SubscriptionAPI,
17
- f as TeamAPI,
18
- p as TokenManager,
19
- l as UsageAPI
13
+ m as RefreshManager,
14
+ M as SSOManager,
15
+ h as SmartMemoryClient,
16
+ f as SubscriptionAPI,
17
+ S as TeamAPI,
18
+ l as TokenManager,
19
+ p as UsageAPI
20
20
  };
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 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-BEScfRuq.js";
1
+ import { A as f, a as u, b as A, c as P, d as b, e as h, D as I, E as g, G as x, f as p, I as w, L as m, M as k, O as v, g as T, P as B, h as y, i as C, j as S, R as E, k as R, S as F, l as L, m as M, T as O, n as G, o as U, p as $, U as D, V, Z } from "./core-Casbg124.js";
2
2
  const i = {
3
3
  variables: {
4
4
  colorBackground: "transparent",
@@ -39,27 +39,27 @@ const i = {
39
39
  lastAuthenticationStrategyBadge: "hidden"
40
40
  }
41
41
  };
42
- async function n(o, a = 8, r = 300) {
43
- for (let e = 0; e < a; e += 1) {
42
+ async function n(a, o = 8, r = 300) {
43
+ for (let e = 0; e < o; e += 1) {
44
44
  let t = null;
45
45
  try {
46
- t = await o({ skipCache: !0 });
46
+ t = await a({ skipCache: !0 });
47
47
  } catch {
48
- t = await o();
48
+ t = await a();
49
49
  }
50
50
  if (t) return t;
51
- e < a - 1 && await new Promise((s) => setTimeout(s, r));
51
+ e < o - 1 && await new Promise((s) => setTimeout(s, r));
52
52
  }
53
53
  return null;
54
54
  }
55
55
  async function l({
56
- apiBaseUrl: o,
57
- getToken: a
56
+ apiBaseUrl: a,
57
+ getToken: o
58
58
  }) {
59
- const r = await n(a);
59
+ const r = await n(o);
60
60
  if (!r)
61
61
  throw new Error("Missing Clerk token after retries");
62
- const e = await fetch(`${o}/auth/clerk/session`, {
62
+ const e = await fetch(`${a}/auth/clerk/session`, {
63
63
  method: "POST",
64
64
  headers: { Authorization: `Bearer ${r}` },
65
65
  credentials: "include"
@@ -78,8 +78,8 @@ export {
78
78
  f as APIError,
79
79
  u as AgentAPI,
80
80
  A as AnalyticsAPI,
81
- b as ArchiveAPI,
82
- P as AuthAPI,
81
+ P as ArchiveAPI,
82
+ b as AuthAPI,
83
83
  h as AuthCore,
84
84
  i as CLERK_APPEARANCE,
85
85
  I as DecisionAPI,
@@ -87,24 +87,26 @@ export {
87
87
  x as GovernanceAPI,
88
88
  p as GraphAPI,
89
89
  w as InsightsAPI,
90
- m as MemoryAPI,
91
- k as OntologyAPI,
92
- v as OpinionAPI,
93
- T as PipelineAPI,
94
- B as ProcedureCandidateAPI,
95
- y as ProcedureMatchAPI,
96
- C as ProfileAPI,
90
+ m as LockAPI,
91
+ k as MemoryAPI,
92
+ v as OntologyAPI,
93
+ T as OpinionAPI,
94
+ B as PipelineAPI,
95
+ y as ProcedureCandidateAPI,
96
+ C as ProcedureMatchAPI,
97
+ S as ProfileAPI,
97
98
  E as ReasoningAPI,
98
- S as ReasoningTracesAPI,
99
- R as SmartMemoryClient,
100
- F as SubscriptionAPI,
101
- M as TeamAPI,
102
- L as TemporalAPI,
103
- O as TokenManager,
104
- G as TokenUsageAPI,
105
- U as UsageAPI,
106
- $ as ValidationAPI,
107
- D as ZettelkastenAPI,
99
+ R as ReasoningTracesAPI,
100
+ F as SequenceAPI,
101
+ L as SmartMemoryClient,
102
+ M as SubscriptionAPI,
103
+ O as TeamAPI,
104
+ G as TemporalAPI,
105
+ U as TokenManager,
106
+ $ as TokenUsageAPI,
107
+ D as UsageAPI,
108
+ V as ValidationAPI,
109
+ Z as ZettelkastenAPI,
108
110
  l as exchangeClerkSession,
109
111
  n as getClerkTokenWithRetry
110
112
  };
package/dist/react.js CHANGED
@@ -1,8 +1,8 @@
1
- import h, { createContext as d, useRef as I, useState as p, useEffect as C, useCallback as c, useContext as g } from "react";
2
- import { S as y } from "./core-BEScfRuq.js";
1
+ import h, { createContext as d, useRef as S, useState as p, useEffect as C, useCallback as c, useContext as g } from "react";
2
+ import { l as y } from "./core-Casbg124.js";
3
3
  const m = d(null), f = d(null);
4
4
  function b({ children: e, ...r }) {
5
- const n = I(null);
5
+ const n = S(null);
6
6
  n.current || (n.current = new y(r));
7
7
  const t = n.current, [o, u] = p({
8
8
  isAuthenticated: t.auth.isAuthenticated(),
@@ -14,8 +14,8 @@ function b({ children: e, ...r }) {
14
14
  error: null
15
15
  });
16
16
  C(() => t.auth.addListener((i) => {
17
- u((k) => ({
18
- ...k,
17
+ u((I) => ({
18
+ ...I,
19
19
  isAuthenticated: i.isAuthenticated,
20
20
  user: i.user,
21
21
  token: i.token,
@@ -25,13 +25,13 @@ function b({ children: e, ...r }) {
25
25
  }), [t]);
26
26
  const a = c(async () => {
27
27
  await t.auth.logout();
28
- }, [t]), w = c((s) => t.auth.hasRole(s), [t]), A = c((s) => t.auth.getLoginUrl(s), [t]), S = {
28
+ }, [t]), w = c((s) => t.auth.hasRole(s), [t]), A = c((s) => t.auth.getLoginUrl(s), [t]), k = {
29
29
  ...o,
30
30
  logout: a,
31
31
  hasRole: w,
32
32
  getLoginUrl: A
33
33
  };
34
- return /* @__PURE__ */ h.createElement(m.Provider, { value: S }, /* @__PURE__ */ h.createElement(f.Provider, { value: t }, e));
34
+ return /* @__PURE__ */ h.createElement(m.Provider, { value: k }, /* @__PURE__ */ h.createElement(f.Provider, { value: t }, e));
35
35
  }
36
36
  function l() {
37
37
  const e = g(m);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartmemory/sdk-js",
3
- "version": "1.4.59",
3
+ "version": "1.4.60",
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",