@smartmemory/sdk-js 1.4.67 → 1.4.85

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.
@@ -2,14 +2,14 @@ var P = (a) => {
2
2
  throw TypeError(a);
3
3
  };
4
4
  var v = (a, e, t) => e.has(a) || P("Cannot " + t);
5
- var R = (a, e, t) => (v(a, e, "read from private field"), t ? t.call(a) : e.get(a)), A = (a, e, t) => e.has(a) ? P("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, t), T = (a, e, t, n) => (v(a, e, "write to private field"), n ? n.call(a, t) : e.set(a, t), t), q = (a, e, t) => (v(a, e, "access private method"), t);
5
+ var I = (a, e, t) => (v(a, e, "read from private field"), t ? t.call(a) : e.get(a)), A = (a, e, t) => e.has(a) ? P("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, t), T = (a, e, t, n) => (v(a, e, "write to private field"), n ? n.call(a, t) : e.set(a, t), t), q = (a, e, t) => (v(a, e, "access private method"), t);
6
6
  const M = {
7
7
  access: "smart_memory_auth_token",
8
8
  refresh: "smart_memory_refresh_token",
9
9
  user: "smart_memory_user",
10
10
  tenant: "smart_memory_tenant_id",
11
11
  team: "smart_memory_team_id"
12
- }, w = {
12
+ }, k = {
13
13
  access: ["access_token", "sm_token"],
14
14
  refresh: ["refresh_token", "sm_refresh_token"],
15
15
  user: ["sm_user"],
@@ -26,7 +26,7 @@ class x {
26
26
  this.storageType = e, this.keys = { ...M, ...t }, this._memory = { access: null, refresh: null, user: null, tenant: null, team: null };
27
27
  }
28
28
  getAccessToken() {
29
- return this.storageType === "memory" ? this._memory.access : this._getFromStorage(this.keys.access, w.access);
29
+ return this.storageType === "memory" ? this._memory.access : this._getFromStorage(this.keys.access, k.access);
30
30
  }
31
31
  setAccessToken(e) {
32
32
  if (this.storageType === "memory") {
@@ -36,7 +36,7 @@ class x {
36
36
  this._setInStorage(this.keys.access, e);
37
37
  }
38
38
  getRefreshToken() {
39
- return this.storageType === "memory" ? this._memory.refresh : this._getFromStorage(this.keys.refresh, w.refresh);
39
+ return this.storageType === "memory" ? this._memory.refresh : this._getFromStorage(this.keys.refresh, k.refresh);
40
40
  }
41
41
  setRefreshToken(e) {
42
42
  if (this.storageType === "memory") {
@@ -47,7 +47,7 @@ class x {
47
47
  }
48
48
  getUser() {
49
49
  if (this.storageType === "memory") return this._memory.user;
50
- const e = this._getFromStorage(this.keys.user, w.user);
50
+ const e = this._getFromStorage(this.keys.user, k.user);
51
51
  if (!e) return null;
52
52
  try {
53
53
  return JSON.parse(e);
@@ -63,7 +63,7 @@ class x {
63
63
  this._setInStorage(this.keys.user, e ? JSON.stringify(e) : null);
64
64
  }
65
65
  getTenantId() {
66
- return this.storageType === "memory" ? this._memory.tenant : this._normalizeId(this._getFromStorage(this.keys.tenant, w.tenant));
66
+ return this.storageType === "memory" ? this._memory.tenant : this._normalizeId(this._getFromStorage(this.keys.tenant, k.tenant));
67
67
  }
68
68
  setTenantId(e) {
69
69
  const t = this._normalizeId(e);
@@ -74,7 +74,7 @@ class x {
74
74
  this._setInStorage(this.keys.tenant, t);
75
75
  }
76
76
  getTeamId() {
77
- return this.storageType === "memory" ? this._memory.team : this._normalizeId(this._getFromStorage(this.keys.team, w.team));
77
+ return this.storageType === "memory" ? this._memory.team : this._normalizeId(this._getFromStorage(this.keys.team, k.team));
78
78
  }
79
79
  setTeamId(e) {
80
80
  const t = this._normalizeId(e);
@@ -94,7 +94,7 @@ class x {
94
94
  localStorage.removeItem(e), sessionStorage.removeItem(e);
95
95
  } catch {
96
96
  }
97
- for (const e of Object.values(w))
97
+ for (const e of Object.values(k))
98
98
  for (const t of e)
99
99
  try {
100
100
  localStorage.removeItem(t), sessionStorage.removeItem(t);
@@ -148,7 +148,7 @@ class x {
148
148
  return n === "none" || n === "null" || n === "undefined" ? null : t;
149
149
  }
150
150
  }
151
- var f, U, E;
151
+ var g, S, E;
152
152
  class z {
153
153
  /**
154
154
  * @param {Object} options
@@ -160,22 +160,22 @@ class z {
160
160
  * @param {function(): void} options.onRefreshFailed
161
161
  */
162
162
  constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager: n, useCookieAuth: s = !1, onTokenRefreshed: r, onRefreshFailed: i }) {
163
- A(this, U);
164
- A(this, f, null);
163
+ A(this, S);
164
+ A(this, g, null);
165
165
  this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager = n, this.useCookieAuth = s, this.onTokenRefreshed = r, this.onRefreshFailed = i;
166
166
  }
167
167
  async refresh() {
168
- if (R(this, f))
169
- return R(this, f);
170
- T(this, f, q(this, U, E).call(this));
168
+ if (I(this, g))
169
+ return I(this, g);
170
+ T(this, g, q(this, S, E).call(this));
171
171
  try {
172
- return await R(this, f);
172
+ return await I(this, g);
173
173
  } finally {
174
- T(this, f, null);
174
+ T(this, g, null);
175
175
  }
176
176
  }
177
177
  }
178
- f = new WeakMap(), U = new WeakSet(), E = async function() {
178
+ g = new WeakMap(), S = new WeakSet(), E = 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");
@@ -367,7 +367,7 @@ class O {
367
367
  this.tokenManager.setTenantId(e), this.notifyListeners();
368
368
  }
369
369
  }
370
- class k extends Error {
370
+ class $ extends Error {
371
371
  /**
372
372
  * @param {string} message - Error message
373
373
  * @param {number} [status=0] - HTTP status code (0 for network errors)
@@ -377,7 +377,7 @@ class k extends Error {
377
377
  super(e), this.name = "APIError", this.status = t, this.detail = n;
378
378
  }
379
379
  }
380
- function S(a) {
380
+ function R(a) {
381
381
  return typeof FormData < "u" && a instanceof FormData;
382
382
  }
383
383
  function L(a) {
@@ -407,7 +407,7 @@ class j {
407
407
  async request(e, t = {}) {
408
408
  var i, c;
409
409
  const n = `${this.baseURL}${e}`, s = {
410
- ...S(t.body) ? {} : { "Content-Type": "application/json" },
410
+ ...R(t.body) ? {} : { "Content-Type": "application/json" },
411
411
  ...this.auth.getAuthHeaders(t.headers)
412
412
  }, r = this.auth.getRequestOptions({ ...t, headers: s });
413
413
  try {
@@ -415,25 +415,25 @@ class j {
415
415
  if (o.status === 401 && !t.__isRetry)
416
416
  try {
417
417
  await this.auth.refreshToken();
418
- const h = {
419
- ...S(t.body) ? {} : { "Content-Type": "application/json" },
418
+ const m = {
419
+ ...R(t.body) ? {} : { "Content-Type": "application/json" },
420
420
  ...this.auth.getAuthHeaders(t.headers)
421
421
  };
422
422
  o = await this.fetchFn(
423
423
  n,
424
- this.auth.getRequestOptions({ ...r, headers: h, __isRetry: !0 })
424
+ this.auth.getRequestOptions({ ...r, headers: m, __isRetry: !0 })
425
425
  );
426
426
  } catch {
427
427
  }
428
428
  if (o.status === 401)
429
- throw (c = (i = this.auth).clearLocalAuth) == null || c.call(i), new k("Authentication required", 401, "auth_expired");
429
+ throw (c = (i = this.auth).clearLocalAuth) == null || c.call(i), new $("Authentication required", 401, "auth_expired");
430
430
  if (o.status === 204)
431
431
  return null;
432
432
  if (!o.ok)
433
433
  throw await this._handleError(o);
434
434
  return await o.json();
435
435
  } catch (o) {
436
- throw o instanceof k || L(o) ? o : new k(o.message, 0, "network_error");
436
+ throw o instanceof $ || L(o) ? o : new $(o.message, 0, "network_error");
437
437
  }
438
438
  }
439
439
  async get(e, t = {}) {
@@ -449,7 +449,7 @@ class j {
449
449
  async requestBinary(e, t = {}) {
450
450
  var i, c;
451
451
  const n = `${this.baseURL}${e}`, s = {
452
- ...S(t.body) ? {} : { "Content-Type": "application/json" },
452
+ ...R(t.body) ? {} : { "Content-Type": "application/json" },
453
453
  ...this.auth.getAuthHeaders(t.headers)
454
454
  }, r = this.auth.getRequestOptions({ ...t, headers: s });
455
455
  try {
@@ -457,23 +457,23 @@ class j {
457
457
  if (o.status === 401 && !t.__isRetry)
458
458
  try {
459
459
  await this.auth.refreshToken();
460
- const h = {
461
- ...S(t.body) ? {} : { "Content-Type": "application/json" },
460
+ const m = {
461
+ ...R(t.body) ? {} : { "Content-Type": "application/json" },
462
462
  ...this.auth.getAuthHeaders(t.headers)
463
463
  };
464
464
  o = await this.fetchFn(
465
465
  n,
466
- this.auth.getRequestOptions({ ...r, headers: h, __isRetry: !0 })
466
+ this.auth.getRequestOptions({ ...r, headers: m, __isRetry: !0 })
467
467
  );
468
468
  } catch {
469
469
  }
470
470
  if (o.status === 401)
471
- throw (c = (i = this.auth).clearLocalAuth) == null || c.call(i), new k("Authentication required", 401, "auth_expired");
471
+ throw (c = (i = this.auth).clearLocalAuth) == null || c.call(i), new $("Authentication required", 401, "auth_expired");
472
472
  if (!o.ok)
473
473
  throw await this._handleError(o);
474
474
  return await o.arrayBuffer();
475
475
  } catch (o) {
476
- throw o instanceof k || L(o) ? o : new k(o.message, 0, "network_error");
476
+ throw o instanceof $ || L(o) ? o : new $(o.message, 0, "network_error");
477
477
  }
478
478
  }
479
479
  async postForm(e, t, n = {}) {
@@ -510,7 +510,7 @@ class j {
510
510
  } catch {
511
511
  t = { message: `HTTP ${e.status}` };
512
512
  }
513
- return new k(
513
+ return new $(
514
514
  this._extractMessage(t, e.status),
515
515
  e.status,
516
516
  t
@@ -693,6 +693,14 @@ class B {
693
693
  * with no replacement, so it is a separate lifecycle state from superseded and is
694
694
  * NOT covered by includeSuperseded. Both are inert when asOfDate is set, which
695
695
  * retains those rows regardless.
696
+ * @param {boolean} [options.includeArchived=false] - Keep archived items visible in
697
+ * results (CORE-ARCHIVED-RECALL-1). Archived items are memories the decay/prune
698
+ * evolvers retired, or the source an episodic-to-semantic promotion replaced.
699
+ * Third sibling of the two above and not covered by either: an archived item has
700
+ * no replacement and no version chain. Also inert when asOfDate is set. Note this
701
+ * default CHANGED behaviour rather than preserving it — before
702
+ * CORE-ARCHIVED-RECALL-1 the server read `archived` on no search path at all, so
703
+ * archived items were returned ranked exactly like live ones.
696
704
  * @param {boolean} [options.cite=false] - When true (RECALL-CITATIONS-1), the
697
705
  * envelope gains a `citations` array of `{n, item_id, item_type, preview, score, footnote_marker}`.
698
706
  * Empty `citations: []` when no results — distinguishes "no results" from "no citations requested".
@@ -709,9 +717,9 @@ class B {
709
717
  * result marked `'unresolved'` is PRESENT-DAY content and must not be rendered
710
718
  * as a historical belief.
711
719
  */
712
- async search(e, { topK: t = 5, enableHybrid: n = !0, memoryType: s = null, expertise: r = !1, cite: i = !1, decompose: c = !1, multiHop: o = !1, maxHops: h = 3, budgetMs: y = 1500, semanticHops: p = !1, includeReference: d = !1, includeConsolidated: _ = !1, consolidationFirst: $ = !1, asOfDate: g = null, asOfStrict: u = !1, includeSuperseded: b = !1, includeRetracted: I = !1 } = {}) {
713
- const l = { query: e, top_k: t, enable_hybrid: n };
714
- return s && (l.memory_type = s), r && (l.expertise = !0), i && (l.cite = !0), c && (l.decompose = !0), o && (l.multi_hop = !0), o && h !== 3 && (l.max_hops = h), o && y !== 1500 && (l.budget_ms = y), o && p && (l.semantic_hops = !0), d && (l.include_reference = !0), _ && (l.include_consolidated = !0), $ && (l.consolidation_first = !0), g && (l.as_of_date = g instanceof Date ? g.toISOString() : g), u && (l.as_of_strict = !0), b && (l.include_superseded = !0), I && (l.include_retracted = !0), this.api.post("/memory/search", l);
720
+ async search(e, { topK: t = 5, enableHybrid: n = !0, memoryType: s = null, expertise: r = !1, cite: i = !1, decompose: c = !1, multiHop: o = !1, maxHops: m = 3, budgetMs: h = 1500, semanticHops: y = !1, includeReference: p = !1, includeConsolidated: f = !1, consolidationFirst: _ = !1, asOfDate: d = null, asOfStrict: l = !1, includeSuperseded: w = !1, includeRetracted: b = !1, includeArchived: U = !1 } = {}) {
721
+ const u = { query: e, top_k: t, enable_hybrid: n };
722
+ return s && (u.memory_type = s), r && (u.expertise = !0), i && (u.cite = !0), c && (u.decompose = !0), o && (u.multi_hop = !0), o && m !== 3 && (u.max_hops = m), o && h !== 1500 && (u.budget_ms = h), o && y && (u.semantic_hops = !0), p && (u.include_reference = !0), f && (u.include_consolidated = !0), _ && (u.consolidation_first = !0), d && (u.as_of_date = d instanceof Date ? d.toISOString() : d), l && (u.as_of_strict = !0), w && (u.include_superseded = !0), b && (u.include_retracted = !0), U && (u.include_archived = !0), this.api.post("/memory/search", u);
715
723
  }
716
724
  /**
717
725
  * Get the complete audit answer for one memory (PLAT-AUDITABLE-MEMORY-1).
@@ -959,10 +967,10 @@ class H {
959
967
  evidenceIds: i = null,
960
968
  domain: c = null,
961
969
  tags: o = null,
962
- rejectedAlternatives: h = null,
963
- rationale: y = null,
964
- constraints: p = null,
965
- agentId: d = null
970
+ rejectedAlternatives: m = null,
971
+ rationale: h = null,
972
+ constraints: y = null,
973
+ agentId: p = null
966
974
  }) {
967
975
  return this.api.post("/memory/decisions/create", {
968
976
  content: e,
@@ -973,10 +981,10 @@ class H {
973
981
  evidence_ids: i,
974
982
  domain: c,
975
983
  tags: o,
976
- rejected_alternatives: h,
977
- rationale: y,
978
- constraints: p,
979
- agent_id: d
984
+ rejected_alternatives: m,
985
+ rationale: h,
986
+ constraints: y,
987
+ agent_id: p
980
988
  });
981
989
  }
982
990
  /**
@@ -2356,8 +2364,8 @@ class re {
2356
2364
  async listTypes({ tier: e, layer: t, packId: n, hasIri: s, kind: r, limit: i = 100, cursor: c } = {}) {
2357
2365
  const o = { limit: String(i) };
2358
2366
  e !== void 0 && (o.tier = e), t !== void 0 && (o.layer = t), n !== void 0 && (o.pack_id = n), s !== void 0 && (o.has_iri = String(s)), r !== void 0 && (o.kind = r), c !== void 0 && (o.cursor = c);
2359
- const h = new URLSearchParams(o).toString();
2360
- return this.api.get(`/memory/ontology/types${h ? "?" + h : ""}`);
2367
+ const m = new URLSearchParams(o).toString();
2368
+ return this.api.get(`/memory/ontology/types${m ? "?" + m : ""}`);
2361
2369
  }
2362
2370
  /**
2363
2371
  * Declare an ontology class (CORE-MEMTYPE-DECLARE-1).
@@ -2396,16 +2404,16 @@ class re {
2396
2404
  storageSearchable: i,
2397
2405
  iri: c,
2398
2406
  wikidataQid: o,
2399
- displayName: h,
2400
- definition: y,
2401
- description: p,
2402
- aliases: d,
2403
- examples: _,
2404
- parentTypes: $,
2405
- tier: g = "confirmed"
2407
+ displayName: m,
2408
+ definition: h,
2409
+ description: y,
2410
+ aliases: p,
2411
+ examples: f,
2412
+ parentTypes: _,
2413
+ tier: d = "confirmed"
2406
2414
  } = {}) {
2407
- const u = { name: e, kind: t, tier: g };
2408
- return n !== void 0 && (u.properties_schema = n), s !== void 0 && (u.required_properties = s), r !== void 0 && (u.storage_strategy = r), i !== void 0 && (u.storage_searchable = i), c !== void 0 && (u.iri = c), o !== void 0 && (u.wikidata_qid = o), h !== void 0 && (u.display_name = h), y !== void 0 && (u.definition = y), p !== void 0 && (u.description = p), d !== void 0 && (u.aliases = d), _ !== void 0 && (u.examples = _), $ !== void 0 && (u.parent_types = $), this.api.post("/memory/ontology/types", u);
2415
+ const l = { name: e, kind: t, tier: d };
2416
+ return n !== void 0 && (l.properties_schema = n), s !== void 0 && (l.required_properties = s), r !== void 0 && (l.storage_strategy = r), i !== void 0 && (l.storage_searchable = i), c !== void 0 && (l.iri = c), o !== void 0 && (l.wikidata_qid = o), m !== void 0 && (l.display_name = m), h !== void 0 && (l.definition = h), y !== void 0 && (l.description = y), p !== void 0 && (l.aliases = p), f !== void 0 && (l.examples = f), _ !== void 0 && (l.parent_types = _), this.api.post("/memory/ontology/types", l);
2409
2417
  }
2410
2418
  /**
2411
2419
  * Declare an ontology relation (CORE-MEMTYPE-DECLARE-1; declare-only in P1).
@@ -2442,20 +2450,20 @@ class re {
2442
2450
  temporal: i,
2443
2451
  propertiesSchema: c,
2444
2452
  transitive: o,
2445
- symmetric: h,
2446
- reflexive: y,
2447
- parentRelations: p,
2448
- iri: d,
2449
- wikidataPid: _,
2450
- displayName: $,
2451
- definition: g,
2452
- description: u,
2453
- aliases: b,
2454
- examples: I,
2455
- tier: l = "confirmed"
2453
+ symmetric: m,
2454
+ reflexive: h,
2455
+ parentRelations: y,
2456
+ iri: p,
2457
+ wikidataPid: f,
2458
+ displayName: _,
2459
+ definition: d,
2460
+ description: l,
2461
+ aliases: w,
2462
+ examples: b,
2463
+ tier: U = "confirmed"
2456
2464
  } = {}) {
2457
- const m = { name: e, tier: l };
2458
- return t !== void 0 && (m.domain = t), n !== void 0 && (m.range = n), s !== void 0 && (m.inverse_of = s), r !== void 0 && (m.cardinality = r), i !== void 0 && (m.temporal = i), c !== void 0 && (m.properties_schema = c), o !== void 0 && (m.transitive = o), h !== void 0 && (m.symmetric = h), y !== void 0 && (m.reflexive = y), p !== void 0 && (m.parent_relations = p), d !== void 0 && (m.iri = d), _ !== void 0 && (m.wikidata_pid = _), $ !== void 0 && (m.display_name = $), g !== void 0 && (m.definition = g), u !== void 0 && (m.description = u), b !== void 0 && (m.aliases = b), I !== void 0 && (m.examples = I), this.api.post("/memory/ontology/relations", m);
2465
+ const u = { name: e, tier: U };
2466
+ return t !== void 0 && (u.domain = t), n !== void 0 && (u.range = n), s !== void 0 && (u.inverse_of = s), r !== void 0 && (u.cardinality = r), i !== void 0 && (u.temporal = i), c !== void 0 && (u.properties_schema = c), o !== void 0 && (u.transitive = o), m !== void 0 && (u.symmetric = m), h !== void 0 && (u.reflexive = h), y !== void 0 && (u.parent_relations = y), p !== void 0 && (u.iri = p), f !== void 0 && (u.wikidata_pid = f), _ !== void 0 && (u.display_name = _), d !== void 0 && (u.definition = d), l !== void 0 && (u.description = l), w !== void 0 && (u.aliases = w), b !== void 0 && (u.examples = b), this.api.post("/memory/ontology/relations", u);
2459
2467
  }
2460
2468
  /**
2461
2469
  * List ontology relation types, keyset-paginated. Mirror of `listTypes`.
@@ -3424,7 +3432,7 @@ class $e {
3424
3432
  }
3425
3433
  }
3426
3434
  export {
3427
- k as A,
3435
+ $ as A,
3428
3436
  j as B,
3429
3437
  H as D,
3430
3438
  te as E,
package/dist/core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as e, a as r, d as A, e as I, B as P, D as o, f as n, I as t, M as g, O as i, j as m, q as M, r as h, l as f, m as l, T as S, o as p, U as u } from "./core-y-uPkyF8.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 g, O as i, j as m, q as M, r as h, l as f, m as l, T as S, o as p, U as u } from "./core-DM1Iz7Fc.js";
2
2
  export {
3
3
  e as APIError,
4
4
  r as AgentAPI,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as f, a as u, b 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-y-uPkyF8.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-DM1Iz7Fc.js";
2
2
  const i = {
3
3
  variables: {
4
4
  colorBackground: "transparent",
package/dist/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import h, { createContext as d, useRef as S, useState as p, useEffect as C, useCallback as c, useContext as g } from "react";
2
- import { l as y } from "./core-y-uPkyF8.js";
2
+ import { l as y } from "./core-DM1Iz7Fc.js";
3
3
  const m = d(null), f = d(null);
4
4
  function b({ children: e, ...r }) {
5
5
  const n = S(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartmemory/sdk-js",
3
- "version": "1.4.67",
3
+ "version": "1.4.85",
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",