@smartmemory/sdk-js 1.4.57 → 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');
@@ -1,9 +1,9 @@
1
- var R = (a) => {
1
+ var S = (a) => {
2
2
  throw TypeError(a);
3
3
  };
4
- var k = (a, e, t) => e.has(a) || R("Cannot " + t);
5
- var g = (a, e, t) => (k(a, e, "read from private field"), t ? t.call(a) : e.get(a)), w = (a, e, t) => e.has(a) ? R("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, t), b = (a, e, t, s) => (k(a, e, "write to private field"), s ? s.call(a, t) : e.set(a, t), t), S = (a, e, t) => (k(a, e, "access private method"), t);
6
- const A = {
4
+ var w = (a, e, t) => e.has(a) || S("Cannot " + t);
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 A = {
16
16
  tenant: ["tenant_id", "workspace_id", "sm_workspace_id"],
17
17
  team: ["team_id", "sm_team_id"]
18
18
  };
19
- class C {
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 = { ...A, ...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 C {
148
148
  return s === "none" || s === "null" || s === "undefined" ? null : t;
149
149
  }
150
150
  }
151
- var l, f, v;
152
- class P {
151
+ var m, _, v;
152
+ class z {
153
153
  /**
154
154
  * @param {Object} options
155
155
  * @param {string} options.apiBaseUrl
@@ -160,22 +160,22 @@ class P {
160
160
  * @param {function(): void} options.onRefreshFailed
161
161
  */
162
162
  constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager: s, useCookieAuth: r = !1, onTokenRefreshed: n, onRefreshFailed: i }) {
163
- w(this, f);
164
- w(this, l, null);
163
+ b(this, _);
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 (g(this, l))
169
- return g(this, l);
170
- b(this, l, S(this, f, v).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 g(this, l);
172
+ return await g(this, m);
173
173
  } finally {
174
- b(this, l, null);
174
+ I(this, m, null);
175
175
  }
176
176
  }
177
177
  }
178
- l = new WeakMap(), f = new WeakSet(), v = 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");
@@ -190,8 +190,8 @@ l = new WeakMap(), f = new WeakSet(), v = async function() {
190
190
  const r = await s.json();
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
- const I = "smart_memory_sso_redirect";
194
- class L {
193
+ const R = "smart_memory_sso_redirect";
194
+ class E {
195
195
  /**
196
196
  * @param {Object} options
197
197
  * @param {string} options.webAppUrl - Web app URL for login redirect
@@ -216,26 +216,26 @@ class L {
216
216
  }
217
217
  storeRedirect(e) {
218
218
  try {
219
- sessionStorage.setItem(I, e);
219
+ sessionStorage.setItem(R, e);
220
220
  } catch (t) {
221
221
  console.warn("Failed to store redirect URL:", t);
222
222
  }
223
223
  }
224
224
  getAndClearRedirect() {
225
225
  try {
226
- const e = sessionStorage.getItem(I);
227
- return sessionStorage.removeItem(I), e;
226
+ const e = sessionStorage.getItem(R);
227
+ return sessionStorage.removeItem(R), e;
228
228
  } catch {
229
229
  return null;
230
230
  }
231
231
  }
232
232
  }
233
- class q {
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 C({
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 P({
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 q {
247
247
  onRefreshFailed: () => {
248
248
  this.clearLocalAuth();
249
249
  }
250
- }) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new L({
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
@@ -377,10 +377,10 @@ class h extends Error {
377
377
  super(e), this.name = "APIError", this.status = t, this.detail = s;
378
378
  }
379
379
  }
380
- function d(a) {
380
+ function f(a) {
381
381
  return typeof FormData < "u" && a instanceof FormData;
382
382
  }
383
- class M {
383
+ class O {
384
384
  /**
385
385
  * @param {import('../auth/AuthCore.js').AuthCore} authCore
386
386
  * @param {{ fetchFn?: typeof globalThis.fetch }} [options]
@@ -394,7 +394,7 @@ class M {
394
394
  async request(e, t = {}) {
395
395
  var i, o;
396
396
  const s = `${this.baseURL}${e}`, r = {
397
- ...d(t.body) ? {} : { "Content-Type": "application/json" },
397
+ ...f(t.body) ? {} : { "Content-Type": "application/json" },
398
398
  ...this.auth.getAuthHeaders(t.headers)
399
399
  }, n = this.auth.getRequestOptions({ ...t, headers: r });
400
400
  try {
@@ -402,13 +402,13 @@ class M {
402
402
  if (c.status === 401 && !t.__isRetry)
403
403
  try {
404
404
  await this.auth.refreshToken();
405
- const u = {
406
- ...d(t.body) ? {} : { "Content-Type": "application/json" },
405
+ const l = {
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: u, __isRetry: !0 })
411
+ this.auth.getRequestOptions({ ...n, headers: l, __isRetry: !0 })
412
412
  );
413
413
  } catch {
414
414
  }
@@ -436,7 +436,7 @@ class M {
436
436
  async requestBinary(e, t = {}) {
437
437
  var i, o;
438
438
  const s = `${this.baseURL}${e}`, r = {
439
- ...d(t.body) ? {} : { "Content-Type": "application/json" },
439
+ ...f(t.body) ? {} : { "Content-Type": "application/json" },
440
440
  ...this.auth.getAuthHeaders(t.headers)
441
441
  }, n = this.auth.getRequestOptions({ ...t, headers: r });
442
442
  try {
@@ -444,13 +444,13 @@ class M {
444
444
  if (c.status === 401 && !t.__isRetry)
445
445
  try {
446
446
  await this.auth.refreshToken();
447
- const u = {
448
- ...d(t.body) ? {} : { "Content-Type": "application/json" },
447
+ const l = {
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: u, __isRetry: !0 })
453
+ this.auth.getRequestOptions({ ...n, headers: l, __isRetry: !0 })
454
454
  );
455
455
  } catch {
456
456
  }
@@ -527,7 +527,7 @@ class M {
527
527
  return typeof (e == null ? void 0 : e.message) == "string" ? e.message : `HTTP ${t}`;
528
528
  }
529
529
  }
530
- class z {
530
+ class F {
531
531
  constructor(e) {
532
532
  this.api = e;
533
533
  }
@@ -545,6 +545,11 @@ class z {
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 z {
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 z {
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
  }
@@ -637,6 +665,21 @@ class z {
637
665
  * @param {boolean} [options.consolidationFirst=false] - When true (NEURO-1d), surface a
638
666
  * consolidated summary above the scattered source memories it consolidates — best for
639
667
  * synthesis queries. Opt-in; implies includeConsolidated.
668
+ * @param {string|Date|null} [options.asOfDate=null] - Transaction-time travel
669
+ * (PLAT-AUDITABLE-MEMORY-1): return what the system believed at this
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.
676
+ * @param {boolean} [options.includeSuperseded=false] - Keep superseded items
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.
640
683
  * @param {boolean} [options.cite=false] - When true (RECALL-CITATIONS-1), the
641
684
  * envelope gains a `citations` array of `{n, item_id, item_type, preview, score, footnote_marker}`.
642
685
  * Empty `citations: []` when no results — distinguishes "no results" from "no citations requested".
@@ -647,11 +690,31 @@ class z {
647
690
  * carries `GroupRootStub`s for any lineage root_id referenced by some
648
691
  * result's `lineage_roots` but not itself in `results`; `citations` is
649
692
  * present only under `cite: true`. Pre-LINEAGE-1 callers who indexed into a
650
- * 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.
651
698
  */
652
- 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: u = 3, budgetMs: p = 1500, semanticHops: _ = !1, includeReference: $ = !1, includeConsolidated: T = !1, consolidationFirst: U = !1 } = {}) {
653
- const m = { query: e, top_k: t, enable_hybrid: s };
654
- return r && (m.memory_type = r), n && (m.expertise = !0), i && (m.cite = !0), o && (m.decompose = !0), c && (m.multi_hop = !0), c && u !== 3 && (m.max_hops = u), c && p !== 1500 && (m.budget_ms = p), c && _ && (m.semantic_hops = !0), $ && (m.include_reference = !0), T && (m.include_consolidated = !0), U && (m.consolidation_first = !0), this.api.post("/memory/search", m);
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 } = {}) {
700
+ const u = { query: e, top_k: t, enable_hybrid: s };
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);
702
+ }
703
+ /**
704
+ * Get the complete audit answer for one memory (PLAT-AUDITABLE-MEMORY-1).
705
+ *
706
+ * Returns the explain-contract shape: identity + origin tier, every belief
707
+ * the system held over time (with chain hashes), supersession in both
708
+ * directions, lineage roots, decision provenance, and chain verification.
709
+ * A `chain_verified` of `null` means nothing to verify (legacy or
710
+ * unversioned) — it is NOT a tamper warning.
711
+ *
712
+ * @param {string} memoryId - Memory item ID.
713
+ * @returns {Promise<object>} Explain response
714
+ * (docs/features/PLAT-AUDITABLE-MEMORY-1/explain-contract.json).
715
+ */
716
+ async explain(e) {
717
+ return this.api.get(`/memory/${encodeURIComponent(e)}/explain`);
655
718
  }
656
719
  async getWorkingContext(e, t, { k: s = 20, maxTokens: r = null, strategy: n = null } = {}) {
657
720
  const i = {
@@ -827,7 +890,7 @@ class z {
827
890
  return this.api.get("/memory/clustering/stats");
828
891
  }
829
892
  }
830
- class E {
893
+ class j {
831
894
  constructor(e) {
832
895
  this.api = e;
833
896
  }
@@ -855,10 +918,10 @@ class E {
855
918
  evidenceIds: i = null,
856
919
  domain: o = null,
857
920
  tags: c = null,
858
- rejectedAlternatives: u = null,
921
+ rejectedAlternatives: l = null,
859
922
  rationale: p = null,
860
- constraints: _ = null,
861
- agentId: $ = null
923
+ constraints: $ = null,
924
+ agentId: k = null
862
925
  }) {
863
926
  return this.api.post("/memory/decisions/create", {
864
927
  content: e,
@@ -869,10 +932,10 @@ class E {
869
932
  evidence_ids: i,
870
933
  domain: o,
871
934
  tags: c,
872
- rejected_alternatives: u,
935
+ rejected_alternatives: l,
873
936
  rationale: p,
874
- constraints: _,
875
- agent_id: $
937
+ constraints: $,
938
+ agent_id: k
876
939
  });
877
940
  }
878
941
  /**
@@ -1045,7 +1108,7 @@ class E {
1045
1108
  });
1046
1109
  }
1047
1110
  }
1048
- class x {
1111
+ class H {
1049
1112
  constructor(e) {
1050
1113
  this.api = e;
1051
1114
  }
@@ -1067,7 +1130,7 @@ class x {
1067
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);
1068
1131
  }
1069
1132
  }
1070
- class O {
1133
+ class B {
1071
1134
  constructor(e) {
1072
1135
  this.api = e;
1073
1136
  }
@@ -1202,7 +1265,7 @@ class O {
1202
1265
  );
1203
1266
  }
1204
1267
  }
1205
- class F {
1268
+ class K {
1206
1269
  constructor(e) {
1207
1270
  this.api = e;
1208
1271
  }
@@ -1244,7 +1307,7 @@ class F {
1244
1307
  return this.api.delete(`/memory/teams/${e}/members/${t}`);
1245
1308
  }
1246
1309
  }
1247
- class j {
1310
+ class G {
1248
1311
  constructor(e) {
1249
1312
  this.api = e;
1250
1313
  }
@@ -1266,7 +1329,7 @@ class j {
1266
1329
  return this.api.patch("/auth/llm-keys", e);
1267
1330
  }
1268
1331
  }
1269
- class H {
1332
+ class N {
1270
1333
  constructor(e) {
1271
1334
  this.api = e;
1272
1335
  }
@@ -1292,7 +1355,7 @@ class H {
1292
1355
  });
1293
1356
  }
1294
1357
  }
1295
- class B {
1358
+ class D {
1296
1359
  constructor(e) {
1297
1360
  this.api = e;
1298
1361
  }
@@ -1313,7 +1376,7 @@ class B {
1313
1376
  return this.api.delete(`/memory/api-keys/${e}`);
1314
1377
  }
1315
1378
  }
1316
- class K {
1379
+ class J {
1317
1380
  constructor(e) {
1318
1381
  this.api = e;
1319
1382
  }
@@ -1372,7 +1435,7 @@ class K {
1372
1435
  return this.api.get(`/memory/agents/${e}/evaluation/history${n ? "?" + n : ""}`);
1373
1436
  }
1374
1437
  }
1375
- class G {
1438
+ class W {
1376
1439
  constructor(e) {
1377
1440
  this.api = e;
1378
1441
  }
@@ -1386,7 +1449,7 @@ class G {
1386
1449
  return this.api.get("/usage/tiers");
1387
1450
  }
1388
1451
  }
1389
- class D {
1452
+ class V {
1390
1453
  constructor(e) {
1391
1454
  this.api = e;
1392
1455
  }
@@ -1403,7 +1466,7 @@ class D {
1403
1466
  return this.api.get("/memory/plugins");
1404
1467
  }
1405
1468
  }
1406
- class N {
1469
+ class Y {
1407
1470
  constructor(e) {
1408
1471
  this.api = e;
1409
1472
  }
@@ -1426,7 +1489,7 @@ class N {
1426
1489
  return this.api.get("/memory/token-usage/current");
1427
1490
  }
1428
1491
  }
1429
- class J {
1492
+ class X {
1430
1493
  constructor(e) {
1431
1494
  this.api = e;
1432
1495
  }
@@ -1572,7 +1635,7 @@ class J {
1572
1635
  return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
1573
1636
  }
1574
1637
  }
1575
- class W {
1638
+ class Z {
1576
1639
  constructor(e) {
1577
1640
  this.api = e;
1578
1641
  }
@@ -1641,7 +1704,7 @@ class W {
1641
1704
  return this.api.get("/memory/governance/summary");
1642
1705
  }
1643
1706
  }
1644
- class V {
1707
+ class Q {
1645
1708
  constructor(e) {
1646
1709
  this.api = e;
1647
1710
  }
@@ -1682,7 +1745,7 @@ class V {
1682
1745
  return this.api.post("/memory/evolution/reinforce/opinions");
1683
1746
  }
1684
1747
  }
1685
- class Y {
1748
+ class ee {
1686
1749
  constructor(e) {
1687
1750
  this.api = e;
1688
1751
  }
@@ -1780,7 +1843,7 @@ class Y {
1780
1843
  });
1781
1844
  }
1782
1845
  }
1783
- class Z {
1846
+ class te {
1784
1847
  constructor(e) {
1785
1848
  this.api = e;
1786
1849
  }
@@ -1834,7 +1897,7 @@ class Z {
1834
1897
  return this.api.get(`/memory/reasoning/traces/${e}`);
1835
1898
  }
1836
1899
  }
1837
- class Q {
1900
+ class se {
1838
1901
  constructor(e) {
1839
1902
  this.api = e;
1840
1903
  }
@@ -2404,7 +2467,7 @@ class Q {
2404
2467
  return r !== void 0 && (n.expected_tier = r), this.api.post("/memory/ontology/queue/bulk", n);
2405
2468
  }
2406
2469
  }
2407
- class X {
2470
+ class re {
2408
2471
  constructor(e) {
2409
2472
  this.api = e;
2410
2473
  }
@@ -2433,7 +2496,7 @@ class X {
2433
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);
2434
2497
  }
2435
2498
  }
2436
- class ee {
2499
+ class ne {
2437
2500
  constructor(e) {
2438
2501
  this.api = e;
2439
2502
  }
@@ -2469,7 +2532,7 @@ class ee {
2469
2532
  return this.api.get("/memory/inference/rules");
2470
2533
  }
2471
2534
  }
2472
- class te {
2535
+ class ie {
2473
2536
  constructor(e) {
2474
2537
  this.api = e;
2475
2538
  }
@@ -2585,7 +2648,7 @@ class te {
2585
2648
  return this.api.delete(`/memory/pipeline/configs/${e}`);
2586
2649
  }
2587
2650
  }
2588
- class se {
2651
+ class ae {
2589
2652
  constructor(e) {
2590
2653
  this.api = e;
2591
2654
  }
@@ -2611,7 +2674,7 @@ class se {
2611
2674
  return this.api.get(`/memory/archive/${e}`);
2612
2675
  }
2613
2676
  }
2614
- class re {
2677
+ class oe {
2615
2678
  constructor(e) {
2616
2679
  this.api = e;
2617
2680
  }
@@ -2770,7 +2833,7 @@ class re {
2770
2833
  return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${s}`);
2771
2834
  }
2772
2835
  }
2773
- class ne {
2836
+ class ce {
2774
2837
  constructor(e) {
2775
2838
  this.api = e;
2776
2839
  }
@@ -2806,7 +2869,7 @@ class ne {
2806
2869
  return this.api.get("/memory/procedures/matches/stats");
2807
2870
  }
2808
2871
  }
2809
- class ie {
2872
+ class ue {
2810
2873
  constructor(e) {
2811
2874
  this.api = e;
2812
2875
  }
@@ -2855,7 +2918,7 @@ class ie {
2855
2918
  return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
2856
2919
  }
2857
2920
  }
2858
- class ae {
2921
+ class le {
2859
2922
  constructor(e) {
2860
2923
  this.api = e;
2861
2924
  }
@@ -2910,7 +2973,7 @@ class ae {
2910
2973
  return this.api.get(`/memory/procedures/schemas/${e}`);
2911
2974
  }
2912
2975
  }
2913
- class oe {
2976
+ class me {
2914
2977
  constructor(e) {
2915
2978
  this.api = e;
2916
2979
  }
@@ -2982,11 +3045,119 @@ class oe {
2982
3045
  return this.api.delete(`/memory/summary/${e}`);
2983
3046
  }
2984
3047
  }
2985
- class me {
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 {
2986
3157
  constructor(e) {
2987
- this.auth = new q(e);
2988
- const t = new M(this.auth, { fetchFn: e.fetchFn });
2989
- this._api = t, this.memories = new z(t), this.decisions = new E(t), this.opinions = new x(t), this.graph = new O(t), this.teams = new F(t), this.profiles = new j(t), this.subscriptions = new H(t), this.authAPI = new B(t), this.agents = new K(t), this.usage = new G(t), this.insights = new D(t), this.tokenUsage = new N(t), this.temporal = new J(t), this.governance = new W(t), this.evolution = new V(t), this.reasoning = new Y(t), this.reasoningTraces = new Z(t), this.ontology = new Q(t), this.analytics = new X(t), this.validation = new ee(t), this.pipeline = new te(t), this.archive = new se(t), this.zettelkasten = new re(t), this.procedureMatches = new ne(t), this.procedureCandidates = new ie(t), this.procedureDrift = new ae(t), this.summaries = new oe(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);
2990
3161
  }
2991
3162
  setTeamId(e) {
2992
3163
  this.auth.tokenManager.setTeamId(e), this.auth.notifyListeners();
@@ -3013,35 +3184,37 @@ class me {
3013
3184
  }
3014
3185
  export {
3015
3186
  h as A,
3016
- M as B,
3017
- E as D,
3018
- V as E,
3019
- W as G,
3020
- D as I,
3021
- z as M,
3022
- Q as O,
3023
- te as P,
3024
- Y as R,
3025
- me as S,
3026
- F as T,
3027
- G as U,
3028
- ee as V,
3029
- re as Z,
3030
- K as a,
3031
- X as b,
3032
- se as c,
3033
- B as d,
3034
- q as e,
3035
- O as f,
3036
- x as g,
3037
- ie as h,
3038
- ne as i,
3039
- j,
3040
- Z as k,
3041
- H as l,
3042
- J as m,
3043
- C as n,
3044
- N as o,
3045
- P as p,
3046
- L 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
3047
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-D1O9gOZK.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-D1O9gOZK.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-D1O9gOZK.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,7 +1,7 @@
1
1
  {
2
2
  "name": "@smartmemory/sdk-js",
3
- "version": "1.4.57",
4
- "description": "Unified JavaScript SDK for SmartMemory API \u2014 auth + API client for all frontends",
3
+ "version": "1.4.60",
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",