@smartmemory/sdk-js 1.4.59 → 1.4.61

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.
@@ -1,32 +1,32 @@
1
- var S = (a) => {
1
+ var P = (a) => {
2
2
  throw TypeError(a);
3
3
  };
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 = {
4
+ var T = (a, e, t) => e.has(a) || P("Cannot " + t);
5
+ var R = (a, e, t) => (T(a, e, "read from private field"), t ? t.call(a) : e.get(a)), v = (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), A = (a, e, t, s) => (T(a, e, "write to private field"), s ? s.call(a, t) : e.set(a, t), t), q = (a, e, t) => (T(a, e, "access private method"), t);
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
- }, y = {
12
+ }, w = {
13
13
  access: ["access_token", "sm_token"],
14
14
  refresh: ["refresh_token", "sm_refresh_token"],
15
15
  user: ["sm_user"],
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 z {
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 = { ...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, y.access);
29
+ return this.storageType === "memory" ? this._memory.access : this._getFromStorage(this.keys.access, w.access);
30
30
  }
31
31
  setAccessToken(e) {
32
32
  if (this.storageType === "memory") {
@@ -36,7 +36,7 @@ class L {
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, y.refresh);
39
+ return this.storageType === "memory" ? this._memory.refresh : this._getFromStorage(this.keys.refresh, w.refresh);
40
40
  }
41
41
  setRefreshToken(e) {
42
42
  if (this.storageType === "memory") {
@@ -47,7 +47,7 @@ class L {
47
47
  }
48
48
  getUser() {
49
49
  if (this.storageType === "memory") return this._memory.user;
50
- const e = this._getFromStorage(this.keys.user, y.user);
50
+ const e = this._getFromStorage(this.keys.user, w.user);
51
51
  if (!e) return null;
52
52
  try {
53
53
  return JSON.parse(e);
@@ -63,7 +63,7 @@ class L {
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, y.tenant));
66
+ return this.storageType === "memory" ? this._memory.tenant : this._normalizeId(this._getFromStorage(this.keys.tenant, w.tenant));
67
67
  }
68
68
  setTenantId(e) {
69
69
  const t = this._normalizeId(e);
@@ -74,7 +74,7 @@ class L {
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, y.team));
77
+ return this.storageType === "memory" ? this._memory.team : this._normalizeId(this._getFromStorage(this.keys.team, w.team));
78
78
  }
79
79
  setTeamId(e) {
80
80
  const t = this._normalizeId(e);
@@ -94,7 +94,7 @@ class L {
94
94
  localStorage.removeItem(e), sessionStorage.removeItem(e);
95
95
  } catch {
96
96
  }
97
- for (const e of Object.values(y))
97
+ for (const e of Object.values(w))
98
98
  for (const t of e)
99
99
  try {
100
100
  localStorage.removeItem(t), sessionStorage.removeItem(t);
@@ -112,17 +112,17 @@ class L {
112
112
  /** @private */
113
113
  _getFromStorage(e, t = []) {
114
114
  try {
115
- const s = this.storageType === "localStorage" ? localStorage : sessionStorage, r = this.storageType === "localStorage" ? sessionStorage : localStorage, n = s.getItem(e) || r.getItem(e);
116
- if (n != null) return n;
115
+ const s = this.storageType === "localStorage" ? localStorage : sessionStorage, n = this.storageType === "localStorage" ? sessionStorage : localStorage, r = s.getItem(e) || n.getItem(e);
116
+ if (r != null) return r;
117
117
  for (const i of t) {
118
- const o = s.getItem(i) || r.getItem(i);
119
- if (o != null) {
120
- this._setInStorage(e, o);
118
+ const c = s.getItem(i) || n.getItem(i);
119
+ if (c != null) {
120
+ this._setInStorage(e, c);
121
121
  try {
122
- s.removeItem(i), r.removeItem(i);
122
+ s.removeItem(i), n.removeItem(i);
123
123
  } catch {
124
124
  }
125
- return o;
125
+ return c;
126
126
  }
127
127
  }
128
128
  return null;
@@ -133,8 +133,8 @@ class L {
133
133
  /** @private */
134
134
  _setInStorage(e, t) {
135
135
  try {
136
- const s = this.storageType === "localStorage" ? localStorage : sessionStorage, r = this.storageType === "localStorage" ? sessionStorage : localStorage;
137
- t != null ? (s.setItem(e, t), r.removeItem(e)) : (s.removeItem(e), r.removeItem(e));
136
+ const s = this.storageType === "localStorage" ? localStorage : sessionStorage, n = this.storageType === "localStorage" ? sessionStorage : localStorage;
137
+ t != null ? (s.setItem(e, t), n.removeItem(e)) : (s.removeItem(e), n.removeItem(e));
138
138
  } catch (s) {
139
139
  console.error("Failed to write to storage:", s);
140
140
  }
@@ -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 f, U, L;
152
+ class E {
153
153
  /**
154
154
  * @param {Object} options
155
155
  * @param {string} options.apiBaseUrl
@@ -159,23 +159,23 @@ class q {
159
159
  * @param {function(string): void} options.onTokenRefreshed
160
160
  * @param {function(): void} options.onRefreshFailed
161
161
  */
162
- constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager: s, useCookieAuth: r = !1, onTokenRefreshed: n, onRefreshFailed: i }) {
163
- b(this, _);
164
- b(this, l, null);
165
- this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager = s, this.useCookieAuth = r, this.onTokenRefreshed = n, this.onRefreshFailed = i;
162
+ constructor({ apiBaseUrl: e, refreshEndpoint: t, tokenManager: s, useCookieAuth: n = !1, onTokenRefreshed: r, onRefreshFailed: i }) {
163
+ v(this, U);
164
+ v(this, f, null);
165
+ this.apiBaseUrl = e, this.refreshEndpoint = t, this.tokenManager = s, this.useCookieAuth = n, this.onTokenRefreshed = r, 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 (R(this, f))
169
+ return R(this, f);
170
+ A(this, f, q(this, U, L).call(this));
171
171
  try {
172
- return await d(this, l);
172
+ return await R(this, f);
173
173
  } finally {
174
- I(this, l, null);
174
+ A(this, f, null);
175
175
  }
176
176
  }
177
177
  }
178
- l = new WeakMap(), _ = new WeakSet(), T = async function() {
178
+ f = new WeakMap(), U = new WeakSet(), L = 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");
@@ -187,11 +187,11 @@ l = new WeakMap(), _ = new WeakSet(), T = async function() {
187
187
  });
188
188
  if (!s.ok)
189
189
  throw this.onRefreshFailed(), new Error(`Refresh failed: ${s.status}`);
190
- const r = await s.json();
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;
190
+ const n = await s.json();
191
+ return this.tokenManager.setAccessToken(n.access_token), n.refresh_token && this.tokenManager.setRefreshToken(n.refresh_token), this.onTokenRefreshed(n.access_token), n.access_token;
192
192
  };
193
- const R = "smart_memory_sso_redirect";
194
- class M {
193
+ const C = "smart_memory_sso_redirect";
194
+ class x {
195
195
  /**
196
196
  * @param {Object} options
197
197
  * @param {string} options.webAppUrl - Web app URL for login redirect
@@ -216,26 +216,26 @@ class M {
216
216
  }
217
217
  storeRedirect(e) {
218
218
  try {
219
- sessionStorage.setItem(R, e);
219
+ sessionStorage.setItem(C, 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(R);
227
- return sessionStorage.removeItem(R), e;
226
+ const e = sessionStorage.getItem(C);
227
+ return sessionStorage.removeItem(C), e;
228
228
  } catch {
229
229
  return null;
230
230
  }
231
231
  }
232
232
  }
233
- class z {
233
+ class F {
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 z({
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 E({
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 x({
251
251
  webAppUrl: e.webAppUrl,
252
252
  allowedHosts: e.allowedRedirectHosts || [],
253
253
  tokenManager: this.tokenManager
@@ -355,10 +355,10 @@ class z {
355
355
  } catch {
356
356
  }
357
357
  if (!t.ok) return !1;
358
- const r = await t.json();
359
- this.currentUser = r, this.tokenManager.setUser(r);
360
- const n = (r == null ? void 0 : r.default_team_id) || this.tokenManager.getTeamId() || null;
361
- return n && (this.tokenManager.setTeamId(n), this.tokenManager.setTenantId((r == null ? void 0 : r.tenant_id) || n)), s && (this.tokenManager.setAccessToken(null), this.currentToken = null, r != null && r.default_team_id && this.tokenManager.setTeamId(r.default_team_id)), this.notifyListeners(), !0;
358
+ const n = await t.json();
359
+ this.currentUser = n, this.tokenManager.setUser(n);
360
+ const r = (n == null ? void 0 : n.default_team_id) || this.tokenManager.getTeamId() || null;
361
+ return r && (this.tokenManager.setTeamId(r), this.tokenManager.setTenantId((n == null ? void 0 : n.tenant_id) || r)), s && (this.tokenManager.setAccessToken(null), this.currentToken = null, n != null && n.default_team_id && this.tokenManager.setTeamId(n.default_team_id)), this.notifyListeners(), !0;
362
362
  } catch {
363
363
  return !1;
364
364
  }
@@ -367,7 +367,7 @@ class z {
367
367
  this.tokenManager.setTenantId(e), this.notifyListeners();
368
368
  }
369
369
  }
370
- class h extends Error {
370
+ class k 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,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 f(a) {
380
+ function S(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]
@@ -392,35 +392,35 @@ class E {
392
392
  return this._customFetchFn || globalThis.fetch.bind(globalThis);
393
393
  }
394
394
  async request(e, t = {}) {
395
- var i, o;
396
- const s = `${this.baseURL}${e}`, r = {
397
- ...f(t.body) ? {} : { "Content-Type": "application/json" },
395
+ var i, c;
396
+ const s = `${this.baseURL}${e}`, n = {
397
+ ...S(t.body) ? {} : { "Content-Type": "application/json" },
398
398
  ...this.auth.getAuthHeaders(t.headers)
399
- }, n = this.auth.getRequestOptions({ ...t, headers: r });
399
+ }, r = this.auth.getRequestOptions({ ...t, headers: n });
400
400
  try {
401
- let c = await this.fetchFn(s, n);
402
- if (c.status === 401 && !t.__isRetry)
401
+ let o = await this.fetchFn(s, r);
402
+ if (o.status === 401 && !t.__isRetry)
403
403
  try {
404
404
  await this.auth.refreshToken();
405
- const m = {
406
- ...f(t.body) ? {} : { "Content-Type": "application/json" },
405
+ const h = {
406
+ ...S(t.body) ? {} : { "Content-Type": "application/json" },
407
407
  ...this.auth.getAuthHeaders(t.headers)
408
408
  };
409
- c = await this.fetchFn(
409
+ o = await this.fetchFn(
410
410
  s,
411
- this.auth.getRequestOptions({ ...n, headers: m, __isRetry: !0 })
411
+ this.auth.getRequestOptions({ ...r, headers: h, __isRetry: !0 })
412
412
  );
413
413
  } catch {
414
414
  }
415
- if (c.status === 401)
416
- throw (o = (i = this.auth).clearLocalAuth) == null || o.call(i), new h("Authentication required", 401, "auth_expired");
417
- if (c.status === 204)
415
+ if (o.status === 401)
416
+ throw (c = (i = this.auth).clearLocalAuth) == null || c.call(i), new k("Authentication required", 401, "auth_expired");
417
+ if (o.status === 204)
418
418
  return null;
419
- if (!c.ok)
420
- throw await this._handleError(c);
421
- return await c.json();
422
- } catch (c) {
423
- throw c instanceof h ? c : new h(c.message, 0, "network_error");
419
+ if (!o.ok)
420
+ throw await this._handleError(o);
421
+ return await o.json();
422
+ } catch (o) {
423
+ throw o instanceof k ? o : new k(o.message, 0, "network_error");
424
424
  }
425
425
  }
426
426
  async get(e, t = {}) {
@@ -434,33 +434,33 @@ class E {
434
434
  });
435
435
  }
436
436
  async requestBinary(e, t = {}) {
437
- var i, o;
438
- const s = `${this.baseURL}${e}`, r = {
439
- ...f(t.body) ? {} : { "Content-Type": "application/json" },
437
+ var i, c;
438
+ const s = `${this.baseURL}${e}`, n = {
439
+ ...S(t.body) ? {} : { "Content-Type": "application/json" },
440
440
  ...this.auth.getAuthHeaders(t.headers)
441
- }, n = this.auth.getRequestOptions({ ...t, headers: r });
441
+ }, r = this.auth.getRequestOptions({ ...t, headers: n });
442
442
  try {
443
- let c = await this.fetchFn(s, n);
444
- if (c.status === 401 && !t.__isRetry)
443
+ let o = await this.fetchFn(s, r);
444
+ if (o.status === 401 && !t.__isRetry)
445
445
  try {
446
446
  await this.auth.refreshToken();
447
- const m = {
448
- ...f(t.body) ? {} : { "Content-Type": "application/json" },
447
+ const h = {
448
+ ...S(t.body) ? {} : { "Content-Type": "application/json" },
449
449
  ...this.auth.getAuthHeaders(t.headers)
450
450
  };
451
- c = await this.fetchFn(
451
+ o = await this.fetchFn(
452
452
  s,
453
- this.auth.getRequestOptions({ ...n, headers: m, __isRetry: !0 })
453
+ this.auth.getRequestOptions({ ...r, headers: h, __isRetry: !0 })
454
454
  );
455
455
  } catch {
456
456
  }
457
- if (c.status === 401)
458
- throw (o = (i = this.auth).clearLocalAuth) == null || o.call(i), new h("Authentication required", 401, "auth_expired");
459
- if (!c.ok)
460
- throw await this._handleError(c);
461
- return await c.arrayBuffer();
462
- } catch (c) {
463
- throw c instanceof h ? c : new h(c.message, 0, "network_error");
457
+ if (o.status === 401)
458
+ throw (c = (i = this.auth).clearLocalAuth) == null || c.call(i), new k("Authentication required", 401, "auth_expired");
459
+ if (!o.ok)
460
+ throw await this._handleError(o);
461
+ return await o.arrayBuffer();
462
+ } catch (o) {
463
+ throw o instanceof k ? o : new k(o.message, 0, "network_error");
464
464
  }
465
465
  }
466
466
  async postForm(e, t, s = {}) {
@@ -489,15 +489,15 @@ class E {
489
489
  }
490
490
  /** @private */
491
491
  async _handleError(e) {
492
- var r, n;
492
+ var n, r;
493
493
  let t;
494
- const s = (n = (r = e.headers) == null ? void 0 : r.get) == null ? void 0 : n.call(r, "content-type");
494
+ const s = (r = (n = e.headers) == null ? void 0 : n.get) == null ? void 0 : r.call(n, "content-type");
495
495
  try {
496
496
  s != null && s.includes("application/json") ? t = await e.json() : t = { message: await e.text() };
497
497
  } catch {
498
498
  t = { message: `HTTP ${e.status}` };
499
499
  }
500
- return new h(
500
+ return new k(
501
501
  this._extractMessage(t, e.status),
502
502
  e.status,
503
503
  t
@@ -516,18 +516,18 @@ class E {
516
516
  * @private
517
517
  */
518
518
  _extractMessage(e, t) {
519
- var r;
519
+ var n;
520
520
  const s = e == null ? void 0 : e.detail;
521
521
  if (typeof s == "string") return s;
522
522
  if (s && typeof s == "object") {
523
523
  if (typeof s.message == "string") return s.message;
524
524
  if (typeof s.code == "string") return s.code;
525
- if (Array.isArray(s) && typeof ((r = s[0]) == null ? void 0 : r.msg) == "string") return s[0].msg;
525
+ if (Array.isArray(s) && typeof ((n = s[0]) == null ? void 0 : n.msg) == "string") return s[0].msg;
526
526
  }
527
527
  return typeof (e == null ? void 0 : e.message) == "string" ? e.message : `HTTP ${t}`;
528
528
  }
529
529
  }
530
- class x {
530
+ class j {
531
531
  constructor(e) {
532
532
  this.api = e;
533
533
  }
@@ -545,26 +545,32 @@ 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,
551
556
  memoryType: t = "semantic",
552
557
  metadata: s = null,
553
- usePipeline: r = !0,
554
- profileName: n = null,
555
- conversationContext: i = null
558
+ usePipeline: n = !0,
559
+ profileName: r = null,
560
+ conversationContext: i = null,
561
+ embed: c = null
556
562
  }) {
557
563
  const o = {
558
564
  content: e,
559
565
  memory_type: t,
560
566
  metadata: s,
561
- use_pipeline: r,
562
- profile_name: n
567
+ use_pipeline: n,
568
+ profile_name: r
563
569
  };
564
- return i != null && (o.conversation_context = i), this.api.post("/memory/add", o);
570
+ return i != null && (o.conversation_context = i), c != null && (o.embed = c), this.api.post("/memory/add", o);
565
571
  }
566
572
  async get(e) {
567
- const t = await this.api.get(`/memory/${e}`);
573
+ const t = await this.api.get(`/memory/${encodeURIComponent(e)}`);
568
574
  return { ...t, id: t.item_id || t.id };
569
575
  }
570
576
  /**
@@ -581,18 +587,40 @@ class x {
581
587
  * (preserving memory_type and node_category).
582
588
  */
583
589
  async update(e, t) {
584
- return this.api.patch(`/memory/${e}`, t);
590
+ return this.api.patch(`/memory/${encodeURIComponent(e)}`, t);
585
591
  }
586
- async supersede(e, { content: t, memoryType: s, metadata: r = {}, reason: n }) {
587
- return this.api.post(`/memory/${e}/supersede`, {
592
+ async supersede(e, { content: t, memoryType: s, metadata: n = {}, reason: r }) {
593
+ return this.api.post(`/memory/${encodeURIComponent(e)}/supersede`, {
588
594
  content: t,
589
595
  memory_type: s,
590
- metadata: r,
591
- reason: n
596
+ metadata: n,
597
+ reason: r
598
+ });
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/${encodeURIComponent(e)}/supersede-link`, {
618
+ new_item_id: t,
619
+ reason: s
592
620
  });
593
621
  }
594
622
  async delete(e) {
595
- return this.api.delete(`/memory/${e}`);
623
+ return this.api.delete(`/memory/${encodeURIComponent(e)}`);
596
624
  }
597
625
  /**
598
626
  * List memory items, optionally filtered by an exact metadata match.
@@ -614,11 +642,11 @@ class x {
614
642
  limit: e = 50,
615
643
  offset: t = 0,
616
644
  type: s = null,
617
- metadataKey: r = null,
618
- metadataValue: n = null
645
+ metadataKey: n = null,
646
+ metadataValue: r = null
619
647
  } = {}) {
620
648
  const i = new URLSearchParams({ limit: e, offset: t });
621
- return s && i.append("memory_type", s), r != null && i.append("metadata_key", r), n != null && i.append("metadata_value", n), this.api.get(`/memory/list?${i}`);
649
+ return s && i.append("memory_type", s), n != null && i.append("metadata_key", n), r != null && i.append("metadata_value", r), this.api.get(`/memory/list?${i}`);
622
650
  }
623
651
  /**
624
652
  * Search for memory items.
@@ -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 } = {}) {
658
- 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);
699
+ async search(e, { topK: t = 5, enableHybrid: s = !0, memoryType: n = 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 } = {}) {
700
+ const l = { query: e, top_k: t, enable_hybrid: s };
701
+ return n && (l.memory_type = n), 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);
660
702
  }
661
703
  /**
662
704
  * Get the complete audit answer for one memory (PLAT-AUDITABLE-MEMORY-1).
@@ -674,35 +716,35 @@ class x {
674
716
  async explain(e) {
675
717
  return this.api.get(`/memory/${encodeURIComponent(e)}/explain`);
676
718
  }
677
- async getWorkingContext(e, t, { k: s = 20, maxTokens: r = null, strategy: n = null } = {}) {
719
+ async getWorkingContext(e, t, { k: s = 20, maxTokens: n = null, strategy: r = null } = {}) {
678
720
  const i = {
679
721
  session_id: e,
680
722
  query: t,
681
723
  k: s
682
724
  };
683
- return r != null && (i.max_tokens = r), n != null && (i.strategy = n), this.api.post("/memory/context", i);
725
+ return n != null && (i.max_tokens = n), r != null && (i.strategy = r), this.api.post("/memory/context", i);
684
726
  }
685
- async searchAdvanced(e, { algorithm: t = "query_traversal", maxResults: s = 15, useSSG: r = !0 } = {}) {
727
+ async searchAdvanced(e, { algorithm: t = "query_traversal", maxResults: s = 15, useSSG: n = !0 } = {}) {
686
728
  return this.api.post("/memory/search/advanced", {
687
729
  query: e,
688
730
  algorithm: t,
689
731
  max_results: s,
690
- use_ssg: r
732
+ use_ssg: n
691
733
  });
692
734
  }
693
- async ingest(e, { profileName: t = null, extractorName: s = "llm", context: r = {} } = {}) {
735
+ async ingest(e, { profileName: t = null, extractorName: s = "llm", context: n = {} } = {}) {
694
736
  return this.api.post("/memory/ingest", {
695
737
  content: e,
696
738
  profile_name: t,
697
739
  extractor_name: s,
698
- context: r
740
+ context: n
699
741
  });
700
742
  }
701
743
  async getLineage(e) {
702
- return this.api.get(`/memory/${e}/lineage`);
744
+ return this.api.get(`/memory/${encodeURIComponent(e)}/lineage`);
703
745
  }
704
746
  async getLinks(e) {
705
- return this.api.get(`/memory/${e}/links`);
747
+ return this.api.get(`/memory/${encodeURIComponent(e)}/links`);
706
748
  }
707
749
  /**
708
750
  * Find memory items by exact metadata match.
@@ -713,16 +755,16 @@ class x {
713
755
  * endpoints return slightly different item shapes, so migrate deliberately rather
714
756
  * than by find-and-replace.
715
757
  */
716
- async searchByMetadata(e, t, { memoryType: s = null, limit: r = 25 } = {}) {
717
- const n = new URLSearchParams({
758
+ async searchByMetadata(e, t, { memoryType: s = null, limit: n = 25 } = {}) {
759
+ const r = new URLSearchParams({
718
760
  metadata_key: e,
719
761
  metadata_value: t,
720
- limit: r
762
+ limit: n
721
763
  });
722
- return s && n.append("memory_type", s), this.api.get(`/memory/by-metadata?${n}`);
764
+ return s && r.append("memory_type", s), this.api.get(`/memory/by-metadata?${r}`);
723
765
  }
724
766
  async getNeighbors(e) {
725
- return this.api.get(`/memory/${e}/neighbors`);
767
+ return this.api.get(`/memory/${encodeURIComponent(e)}/neighbors`);
726
768
  }
727
769
  async getSummary() {
728
770
  return this.api.get("/memory/summary");
@@ -730,24 +772,24 @@ class x {
730
772
  async ingestConversation(e, {
731
773
  sessionBoundaries: t = null,
732
774
  conversationId: s = null,
733
- sessionDates: r = null,
734
- turnsPerChunk: n = 15,
775
+ sessionDates: n = null,
776
+ turnsPerChunk: r = 15,
735
777
  maxChunkChars: i = 12e3,
736
- maxConcurrent: o = 4
778
+ maxConcurrent: c = 4
737
779
  } = {}) {
738
- const c = { turns: e, turns_per_chunk: n, max_chunk_chars: i, max_concurrent: o };
739
- return t && (c.session_boundaries = t), s && (c.conversation_id = s), r && (c.session_dates = r), this.api.post("/memory/ingest/conversation", c);
780
+ const o = { turns: e, turns_per_chunk: r, max_chunk_chars: i, max_concurrent: c };
781
+ return t && (o.session_boundaries = t), s && (o.conversation_id = s), n && (o.session_dates = n), this.api.post("/memory/ingest/conversation", o);
740
782
  }
741
- async ingestDocument(e, { title: t = null, source: s = null, chunkStrategy: r = null } = {}) {
742
- const n = { content: e };
743
- return t && (n.title = t), s && (n.source = s), r && (n.chunk_strategy = r), this.api.post("/memory/ingest/document", n);
783
+ async ingestDocument(e, { title: t = null, source: s = null, chunkStrategy: n = null } = {}) {
784
+ const r = { content: e };
785
+ return t && (r.title = t), s && (r.source = s), n && (r.chunk_strategy = n), this.api.post("/memory/ingest/document", r);
744
786
  }
745
787
  async codeIndex(e, { repo: t = null, commit: s = null } = {}) {
746
- const r = { path: e };
747
- return t && (r.repo = t), s && (r.commit = s), this.api.post("/memory/code/index", r);
788
+ const n = { path: e };
789
+ return t && (n.repo = t), s && (n.commit = s), this.api.post("/memory/code/index", n);
748
790
  }
749
- async codeSearch(e, { entityType: t = null, repo: s = null, limit: r = 20, semantic: n = !1 } = {}) {
750
- const i = new URLSearchParams({ query: e, limit: r, semantic: n });
791
+ async codeSearch(e, { entityType: t = null, repo: s = null, limit: n = 20, semantic: r = !1 } = {}) {
792
+ const i = new URLSearchParams({ query: e, limit: n, semantic: r });
751
793
  return t && i.append("entity_type", t), s && i.append("repo", s), this.api.get(`/memory/code/search?${i}`);
752
794
  }
753
795
  async codeContext(e, { repo: t = null } = {}) {
@@ -758,8 +800,8 @@ class x {
758
800
  return this.api.get(`/memory/code/dead-code?repo=${encodeURIComponent(e)}`);
759
801
  }
760
802
  async codeDependencies(e, { direction: t = "both", repo: s = null } = {}) {
761
- const r = new URLSearchParams({ entity_name: e, direction: t });
762
- return s && r.append("repo", s), this.api.get(`/memory/code/dependencies?${r}`);
803
+ const n = new URLSearchParams({ entity_name: e, direction: t });
804
+ return s && n.append("repo", s), this.api.get(`/memory/code/dependencies?${n}`);
763
805
  }
764
806
  async getPlan(e) {
765
807
  return this.api.get(`/memory/plans/${e}`);
@@ -781,7 +823,7 @@ class x {
781
823
  });
782
824
  }
783
825
  async enrich(e, t = []) {
784
- return this.api.post(`/memory/${e}/enrich`, {
826
+ return this.api.post(`/memory/${encodeURIComponent(e)}/enrich`, {
785
827
  item_id: e,
786
828
  routines: t
787
829
  });
@@ -802,11 +844,11 @@ class x {
802
844
  * @returns {Promise<{updated: number, edges_strengthened: number, outcome: string}>}
803
845
  */
804
846
  async feedback(e, t, s = null) {
805
- const r = { item_ids: e, outcome: t };
806
- return s != null && (r.query = s), this.api.post("/memory/feedback", r);
847
+ const n = { item_ids: e, outcome: t };
848
+ return s != null && (n.query = s), this.api.post("/memory/feedback", n);
807
849
  }
808
850
  async ground(e, t, s = null) {
809
- return this.api.post(`/memory/${e}/ground`, {
851
+ return this.api.post(`/memory/${encodeURIComponent(e)}/ground`, {
810
852
  item_id: e,
811
853
  source_url: t,
812
854
  validation: s
@@ -816,29 +858,29 @@ class x {
816
858
  return this.api.delete(`/memory/clear-all?nuclear=${e}`);
817
859
  }
818
860
  // --- Temporal ---
819
- async getHistory(e, { startTime: t = null, endTime: s = null, limit: r = 100 } = {}) {
820
- let n = `/memory/temporal/${e}/history?limit=${r}`;
821
- return t && (n += `&start_time=${t}`), s && (n += `&end_time=${s}`), this.api.get(n);
861
+ async getHistory(e, { startTime: t = null, endTime: s = null, limit: n = 100 } = {}) {
862
+ let r = `/memory/temporal/${e}/history?limit=${n}`;
863
+ return t && (r += `&start_time=${t}`), s && (r += `&end_time=${s}`), this.api.get(r);
822
864
  }
823
865
  async timeTravel(e, { query: t = null, limit: s = 100 } = {}) {
824
- let r = `/memory/temporal/at/${e}?limit=${s}`;
825
- return t && (r += `&query=${encodeURIComponent(t)}`), this.api.get(r);
866
+ let n = `/memory/temporal/at/${e}?limit=${s}`;
867
+ return t && (n += `&query=${encodeURIComponent(t)}`), this.api.get(n);
826
868
  }
827
869
  async getItemAtTime(e, t) {
828
870
  return this.api.get(`/memory/temporal/${e}/at/${t}`);
829
871
  }
830
- async getChanges(e, { since: t = null, until: s = null, changeType: r = null } = {}) {
831
- let n = `/memory/temporal/${e}/changes`;
872
+ async getChanges(e, { since: t = null, until: s = null, changeType: n = null } = {}) {
873
+ let r = `/memory/temporal/${e}/changes`;
832
874
  const i = [];
833
- return t && i.push(`since=${t}`), s && i.push(`until=${s}`), r && i.push(`change_type=${r}`), i.length && (n += `?${i.join("&")}`), this.api.get(n);
875
+ return t && i.push(`since=${t}`), s && i.push(`until=${s}`), n && i.push(`change_type=${n}`), i.length && (r += `?${i.join("&")}`), this.api.get(r);
834
876
  }
835
877
  async compareVersions(e, t, s) {
836
878
  return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${s}`);
837
879
  }
838
880
  async rollback(e, { toVersion: t = null, toTime: s = null } = {}) {
839
- let r = `/memory/temporal/${e}/rollback`;
840
- const n = [];
841
- return t !== null && n.push(`to_version=${t}`), s && n.push(`to_time=${s}`), n.length && (r += `?${n.join("&")}`), this.api.post(r);
881
+ let n = `/memory/temporal/${e}/rollback`;
882
+ const r = [];
883
+ return t !== null && r.push(`to_version=${t}`), s && r.push(`to_time=${s}`), r.length && (n += `?${r.join("&")}`), this.api.post(n);
842
884
  }
843
885
  // --- Clustering ---
844
886
  async runClustering(e = 0.1, t = !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 H {
852
894
  constructor(e) {
853
895
  this.api = e;
854
896
  }
@@ -871,29 +913,29 @@ class O {
871
913
  content: e,
872
914
  decisionType: t = "inference",
873
915
  confidence: s = 0.8,
874
- sourceTraceId: r = null,
875
- sourceSessionId: n = null,
916
+ sourceTraceId: n = null,
917
+ sourceSessionId: r = null,
876
918
  evidenceIds: i = null,
877
- domain: o = null,
878
- tags: c = null,
879
- rejectedAlternatives: m = null,
880
- rationale: p = null,
881
- constraints: $ = null,
882
- agentId: k = null
919
+ domain: c = null,
920
+ tags: o = null,
921
+ rejectedAlternatives: h = null,
922
+ rationale: y = null,
923
+ constraints: p = null,
924
+ agentId: d = null
883
925
  }) {
884
926
  return this.api.post("/memory/decisions/create", {
885
927
  content: e,
886
928
  decision_type: t,
887
929
  confidence: s,
888
- source_trace_id: r,
889
- source_session_id: n,
930
+ source_trace_id: n,
931
+ source_session_id: r,
890
932
  evidence_ids: i,
891
- domain: o,
892
- tags: c,
893
- rejected_alternatives: m,
894
- rationale: p,
895
- constraints: $,
896
- agent_id: k
933
+ domain: c,
934
+ tags: o,
935
+ rejected_alternatives: h,
936
+ rationale: y,
937
+ constraints: p,
938
+ agent_id: d
897
939
  });
898
940
  }
899
941
  /**
@@ -939,13 +981,13 @@ class O {
939
981
  * @param {string[]} [params.tags]
940
982
  * @param {string} [params.agentId]
941
983
  */
942
- async createPending({ content: e, requirements: t, domain: s = null, tags: r = null, agentId: n = null }) {
984
+ async createPending({ content: e, requirements: t, domain: s = null, tags: n = null, agentId: r = null }) {
943
985
  return this.api.post("/memory/decisions/pending/create", {
944
986
  content: e,
945
987
  requirements: t,
946
988
  domain: s,
947
- tags: r,
948
- agent_id: n
989
+ tags: n,
990
+ agent_id: r
949
991
  });
950
992
  }
951
993
  /**
@@ -1066,7 +1108,7 @@ class O {
1066
1108
  });
1067
1109
  }
1068
1110
  }
1069
- class F {
1111
+ class B {
1070
1112
  constructor(e) {
1071
1113
  this.api = e;
1072
1114
  }
@@ -1088,19 +1130,19 @@ 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 K {
1092
1134
  constructor(e) {
1093
1135
  this.api = e;
1094
1136
  }
1095
1137
  async getNeighbors(e) {
1096
1138
  return this.api.get(`/memory/${e}/neighbors`);
1097
1139
  }
1098
- async addEdge(e, t, s, r = {}) {
1140
+ async addEdge(e, t, s, n = {}) {
1099
1141
  return this.api.post("/memory/edge", {
1100
1142
  source_id: e,
1101
1143
  target_id: t,
1102
1144
  relation_type: s,
1103
- properties: r
1145
+ properties: n
1104
1146
  });
1105
1147
  }
1106
1148
  async getHealth() {
@@ -1146,8 +1188,8 @@ class j {
1146
1188
  * @param {string|null} [params.deletePrefix=null] - Scoped node-ID prefix to delete before writing.
1147
1189
  */
1148
1190
  async bulkUpsert({ nodes: e = [], edges: t = [], deletePrefix: s = null } = {}) {
1149
- const r = { nodes: e, edges: t };
1150
- return s !== null && (r.delete_prefix = s), this.api.post("/memory/graph/bulk", r);
1191
+ const n = { nodes: e, edges: t };
1192
+ return s !== null && (n.delete_prefix = s), this.api.post("/memory/graph/bulk", n);
1151
1193
  }
1152
1194
  /**
1153
1195
  * Get Wikipedia grounding status for an entity node.
@@ -1223,7 +1265,7 @@ class j {
1223
1265
  );
1224
1266
  }
1225
1267
  }
1226
- class H {
1268
+ class G {
1227
1269
  constructor(e) {
1228
1270
  this.api = e;
1229
1271
  }
@@ -1231,14 +1273,14 @@ class H {
1231
1273
  const t = e ? "?include_system=true" : "";
1232
1274
  return this.api.get(`/memory/teams${t}`);
1233
1275
  }
1234
- async create({ name: e, description: t = null, dataClassification: s = "internal", costCenter: r = null, isSystem: n = !1 }) {
1276
+ async create({ name: e, description: t = null, dataClassification: s = "internal", costCenter: n = null, isSystem: r = !1 }) {
1235
1277
  const i = {
1236
1278
  name: e,
1237
1279
  description: t,
1238
1280
  data_classification: s,
1239
- cost_center: r
1281
+ cost_center: n
1240
1282
  };
1241
- return n && (i.is_system = !0), this.api.post("/memory/teams", i);
1283
+ return r && (i.is_system = !0), this.api.post("/memory/teams", i);
1242
1284
  }
1243
1285
  async get(e) {
1244
1286
  return this.api.get(`/memory/teams/${e}`);
@@ -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 D {
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 J {
1317
1359
  constructor(e) {
1318
1360
  this.api = e;
1319
1361
  }
@@ -1334,19 +1376,19 @@ class G {
1334
1376
  return this.api.delete(`/memory/api-keys/${e}`);
1335
1377
  }
1336
1378
  }
1337
- class N {
1379
+ class W {
1338
1380
  constructor(e) {
1339
1381
  this.api = e;
1340
1382
  }
1341
1383
  async list() {
1342
1384
  return this.api.get("/memory/agents");
1343
1385
  }
1344
- async create({ name: e, description: t = null, agentConfig: s = {}, roles: r = ["user"] }) {
1386
+ async create({ name: e, description: t = null, agentConfig: s = {}, roles: n = ["user"] }) {
1345
1387
  return this.api.post("/memory/agents", {
1346
1388
  name: e,
1347
1389
  description: t,
1348
1390
  agent_config: s,
1349
- roles: r
1391
+ roles: n
1350
1392
  });
1351
1393
  }
1352
1394
  async get(e) {
@@ -1373,8 +1415,8 @@ class N {
1373
1415
  * @returns {Promise<{evaluation: object|null}>}
1374
1416
  */
1375
1417
  async getEvaluation(e, t, s) {
1376
- const r = new URLSearchParams({ dimension: t, domain: s }).toString();
1377
- return this.api.get(`/memory/agents/${e}/evaluation${r ? "?" + r : ""}`);
1418
+ const n = new URLSearchParams({ dimension: t, domain: s }).toString();
1419
+ return this.api.get(`/memory/agents/${e}/evaluation${n ? "?" + n : ""}`);
1378
1420
  }
1379
1421
  /**
1380
1422
  * Get evaluation history for an agent on a given (dimension, domain) slot.
@@ -1388,12 +1430,12 @@ class N {
1388
1430
  * @param {number} [options.limit=20] - Maximum records to return.
1389
1431
  * @returns {Promise<{history: object[]}>}
1390
1432
  */
1391
- async listEvaluationHistory(e, t, s, { limit: r = 20 } = {}) {
1392
- const n = new URLSearchParams({ dimension: t, domain: s, limit: String(r) }).toString();
1393
- return this.api.get(`/memory/agents/${e}/evaluation/history${n ? "?" + n : ""}`);
1433
+ async listEvaluationHistory(e, t, s, { limit: n = 20 } = {}) {
1434
+ const r = new URLSearchParams({ dimension: t, domain: s, limit: String(n) }).toString();
1435
+ return this.api.get(`/memory/agents/${e}/evaluation/history${r ? "?" + r : ""}`);
1394
1436
  }
1395
1437
  }
1396
- class D {
1438
+ class V {
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 Y {
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 X {
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 Z {
1451
1493
  constructor(e) {
1452
1494
  this.api = e;
1453
1495
  }
@@ -1460,9 +1502,9 @@ class V {
1460
1502
  * @param {string} [options.endTime] - ISO end time
1461
1503
  * @param {number} [options.limit=100]
1462
1504
  */
1463
- async getHistory(e, { startTime: t = null, endTime: s = null, limit: r = 100 } = {}) {
1464
- let n = `/memory/temporal/${e}/history?limit=${r}`;
1465
- return t && (n += `&start_time=${t}`), s && (n += `&end_time=${s}`), this.api.get(n);
1505
+ async getHistory(e, { startTime: t = null, endTime: s = null, limit: n = 100 } = {}) {
1506
+ let r = `/memory/temporal/${e}/history?limit=${n}`;
1507
+ return t && (r += `&start_time=${t}`), s && (r += `&end_time=${s}`), this.api.get(r);
1466
1508
  }
1467
1509
  // === TIME-TRAVEL QUERIES ===
1468
1510
  /**
@@ -1473,8 +1515,8 @@ class V {
1473
1515
  * @param {number} [options.limit=100]
1474
1516
  */
1475
1517
  async timeTravel(e, { query: t = null, limit: s = 100 } = {}) {
1476
- let r = `/memory/temporal/at/${e}?limit=${s}`;
1477
- return t && (r += `&query=${encodeURIComponent(t)}`), this.api.get(r);
1518
+ let n = `/memory/temporal/at/${e}?limit=${s}`;
1519
+ return t && (n += `&query=${encodeURIComponent(t)}`), this.api.get(n);
1478
1520
  }
1479
1521
  /**
1480
1522
  * Get specific item as it existed at timestamp.
@@ -1493,10 +1535,10 @@ class V {
1493
1535
  * @param {string} [options.until]
1494
1536
  * @param {string} [options.changeType]
1495
1537
  */
1496
- async getChanges(e, { since: t = null, until: s = null, changeType: r = null } = {}) {
1497
- let n = `/memory/temporal/${e}/changes`;
1538
+ async getChanges(e, { since: t = null, until: s = null, changeType: n = null } = {}) {
1539
+ let r = `/memory/temporal/${e}/changes`;
1498
1540
  const i = [];
1499
- return t && i.push(`since=${t}`), s && i.push(`until=${s}`), r && i.push(`change_type=${r}`), i.length && (n += `?${i.join("&")}`), this.api.get(n);
1541
+ return t && i.push(`since=${t}`), s && i.push(`until=${s}`), n && i.push(`change_type=${n}`), i.length && (r += `?${i.join("&")}`), this.api.get(r);
1500
1542
  }
1501
1543
  // === VERSION COMPARISON ===
1502
1544
  /**
@@ -1517,9 +1559,9 @@ class V {
1517
1559
  * @param {string} [options.toTime]
1518
1560
  */
1519
1561
  async rollback(e, { toVersion: t = null, toTime: s = null } = {}) {
1520
- let r = `/memory/temporal/${e}/rollback`;
1521
- const n = [];
1522
- return t !== null && n.push(`to_version=${t}`), s && n.push(`to_time=${s}`), n.length && (r += `?${n.join("&")}`), this.api.post(r);
1562
+ let n = `/memory/temporal/${e}/rollback`;
1563
+ const r = [];
1564
+ return t !== null && r.push(`to_version=${t}`), s && r.push(`to_time=${s}`), r.length && (n += `?${r.join("&")}`), this.api.post(n);
1523
1565
  }
1524
1566
  // === AUDIT TRAIL ===
1525
1567
  /**
@@ -1531,10 +1573,10 @@ class V {
1531
1573
  * @param {string} [options.startTime]
1532
1574
  * @param {string} [options.endTime]
1533
1575
  */
1534
- async getAuditTrail(e, { changeType: t = null, userId: s = null, startTime: r = null, endTime: n = null } = {}) {
1576
+ async getAuditTrail(e, { changeType: t = null, userId: s = null, startTime: n = null, endTime: r = null } = {}) {
1535
1577
  let i = `/memory/temporal/${e}/audit`;
1536
- const o = [];
1537
- return t && o.push(`change_type=${t}`), s && o.push(`user_id=${s}`), r && o.push(`start_time=${r}`), n && o.push(`end_time=${n}`), o.length && (i += `?${o.join("&")}`), this.api.get(i);
1578
+ const c = [];
1579
+ return t && c.push(`change_type=${t}`), s && c.push(`user_id=${s}`), n && c.push(`start_time=${n}`), r && c.push(`end_time=${r}`), c.length && (i += `?${c.join("&")}`), this.api.get(i);
1538
1580
  }
1539
1581
  // === TEMPORAL SEARCH ===
1540
1582
  /**
@@ -1544,14 +1586,14 @@ class V {
1544
1586
  * @param {string} endTime
1545
1587
  * @param {number} [limit=100]
1546
1588
  */
1547
- async searchDuringRange(e, t, s, r = 100) {
1548
- const n = new URLSearchParams({
1589
+ async searchDuringRange(e, t, s, n = 100) {
1590
+ const r = new URLSearchParams({
1549
1591
  query: e,
1550
1592
  start_time: t,
1551
1593
  end_time: s,
1552
- limit: String(r)
1594
+ limit: String(n)
1553
1595
  }).toString();
1554
- return this.api.get(`/memory/temporal/search/during?${n}`);
1596
+ return this.api.get(`/memory/temporal/search/during?${r}`);
1555
1597
  }
1556
1598
  // === COMPLIANCE REPORTING ===
1557
1599
  /**
@@ -1562,12 +1604,12 @@ class V {
1562
1604
  * @param {string} [options.reportType='HIPAA']
1563
1605
  * @param {string[]} [options.itemIds]
1564
1606
  */
1565
- async complianceReport(e, t, { reportType: s = "HIPAA", itemIds: r = null } = {}) {
1566
- let n = `/memory/temporal/compliance/report?start_date=${e}&end_date=${t}&report_type=${s}`;
1567
- if (r && r.length)
1568
- for (const i of r)
1569
- n += `&item_ids=${encodeURIComponent(i)}`;
1570
- return this.api.get(n);
1607
+ async complianceReport(e, t, { reportType: s = "HIPAA", itemIds: n = null } = {}) {
1608
+ let r = `/memory/temporal/compliance/report?start_date=${e}&end_date=${t}&report_type=${s}`;
1609
+ if (n && n.length)
1610
+ for (const i of n)
1611
+ r += `&item_ids=${encodeURIComponent(i)}`;
1612
+ return this.api.get(r);
1571
1613
  }
1572
1614
  // === TEMPORAL RELATIONSHIPS ===
1573
1615
  /**
@@ -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 Q {
1597
1639
  constructor(e) {
1598
1640
  this.api = e;
1599
1641
  }
@@ -1620,8 +1662,8 @@ class Y {
1620
1662
  async listViolations({ severity: e = null, autoFixableOnly: t = !1 } = {}) {
1621
1663
  const s = [];
1622
1664
  e && s.push(`severity=${e}`), t && s.push("auto_fixable_only=true");
1623
- const r = s.length ? `?${s.join("&")}` : "";
1624
- return this.api.get(`/memory/governance/violations${r}`);
1665
+ const n = s.length ? `?${s.join("&")}` : "";
1666
+ return this.api.get(`/memory/governance/violations${n}`);
1625
1667
  }
1626
1668
  /**
1627
1669
  * Get a specific violation by ID.
@@ -1638,12 +1680,12 @@ class Y {
1638
1680
  * @param {string} [params.rationale='']
1639
1681
  * @param {string} [params.decidedBy='human']
1640
1682
  */
1641
- async applyDecision({ violationId: e, action: t = "approve", rationale: s = "", decidedBy: r = "human" }) {
1683
+ async applyDecision({ violationId: e, action: t = "approve", rationale: s = "", decidedBy: n = "human" }) {
1642
1684
  return this.api.post("/memory/governance/apply-decision", {
1643
1685
  violation_id: e,
1644
1686
  action: t,
1645
1687
  rationale: s,
1646
- decided_by: r
1688
+ decided_by: n
1647
1689
  });
1648
1690
  }
1649
1691
  /**
@@ -1662,7 +1704,7 @@ class Y {
1662
1704
  return this.api.get("/memory/governance/summary");
1663
1705
  }
1664
1706
  }
1665
- class Z {
1707
+ class ee {
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 te {
1707
1749
  constructor(e) {
1708
1750
  this.api = e;
1709
1751
  }
@@ -1732,13 +1774,13 @@ class Q {
1732
1774
  * @param {boolean} [params.useWikipedia=true]
1733
1775
  * @param {boolean} [params.useLlm=true]
1734
1776
  */
1735
- async resolve({ existingItemId: e, newFact: t, autoResolve: s = !0, strategy: r = null, useWikipedia: n = !0, useLlm: i = !0 }) {
1777
+ async resolve({ existingItemId: e, newFact: t, autoResolve: s = !0, strategy: n = null, useWikipedia: r = !0, useLlm: i = !0 }) {
1736
1778
  return this.api.post("/memory/reasoning/resolve", {
1737
1779
  existing_item_id: e,
1738
1780
  new_fact: t,
1739
1781
  auto_resolve: s,
1740
- strategy: r,
1741
- use_wikipedia: n,
1782
+ strategy: n,
1783
+ use_wikipedia: r,
1742
1784
  use_llm: i
1743
1785
  });
1744
1786
  }
@@ -1801,7 +1843,7 @@ class Q {
1801
1843
  });
1802
1844
  }
1803
1845
  }
1804
- class X {
1846
+ class se {
1805
1847
  constructor(e) {
1806
1848
  this.api = e;
1807
1849
  }
@@ -1813,12 +1855,12 @@ class X {
1813
1855
  * @param {number} [params.minQualityScore=0.4]
1814
1856
  * @param {boolean} [params.useLlmDetection=true]
1815
1857
  */
1816
- async extract({ content: e, minSteps: t = 2, minQualityScore: s = 0.4, useLlmDetection: r = !0 }) {
1858
+ async extract({ content: e, minSteps: t = 2, minQualityScore: s = 0.4, useLlmDetection: n = !0 }) {
1817
1859
  return this.api.post("/memory/reasoning/traces/extract", {
1818
1860
  content: e,
1819
1861
  min_steps: t,
1820
1862
  min_quality_score: s,
1821
- use_llm_detection: r
1863
+ use_llm_detection: n
1822
1864
  });
1823
1865
  }
1824
1866
  /**
@@ -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 ne {
1859
1901
  constructor(e) {
1860
1902
  this.api = e;
1861
1903
  }
@@ -1870,7 +1912,7 @@ class ee {
1870
1912
  async runInference({ registryId: e = "default", rawChunks: t, params: s = {} }) {
1871
1913
  return this.api.post("/memory/ontology/inference/run", {
1872
1914
  registry_id: e,
1873
- raw_chunks: t.map((r) => ({ doc_id: r.docId, text: r.text })),
1915
+ raw_chunks: t.map((n) => ({ doc_id: n.docId, text: n.text })),
1874
1916
  params: s
1875
1917
  });
1876
1918
  }
@@ -1912,11 +1954,11 @@ class ee {
1912
1954
  * @param {Object} params.changeset - OntologyIR changeset
1913
1955
  * @param {string} [params.message='']
1914
1956
  */
1915
- async applyChangeset(e, { baseVersion: t = "", changeset: s, message: r = "" }) {
1957
+ async applyChangeset(e, { baseVersion: t = "", changeset: s, message: n = "" }) {
1916
1958
  return this.api.post(`/memory/ontology/registry/${e}/apply`, {
1917
1959
  base_version: t,
1918
1960
  changeset: s,
1919
- message: r
1961
+ message: n
1920
1962
  });
1921
1963
  }
1922
1964
  /**
@@ -2065,12 +2107,12 @@ class ee {
2065
2107
  * @param {number} [params.confidence=0.9]
2066
2108
  * @param {boolean} [params.isGlobal=false]
2067
2109
  */
2068
- async createPattern({ name: e, entityType: t, confidence: s = 0.9, isGlobal: r = !1 }) {
2110
+ async createPattern({ name: e, entityType: t, confidence: s = 0.9, isGlobal: n = !1 }) {
2069
2111
  return this.api.post("/memory/ontology/patterns", {
2070
2112
  name: e,
2071
2113
  entity_type: t,
2072
2114
  confidence: s,
2073
- is_global: r
2115
+ is_global: n
2074
2116
  });
2075
2117
  }
2076
2118
  /**
@@ -2231,8 +2273,8 @@ class ee {
2231
2273
  * @param {number} [options.limit=50]
2232
2274
  */
2233
2275
  async listHitl({ status: e = "open", kind: t = null, limit: s = 50 } = {}) {
2234
- const r = new URLSearchParams({ status: e, limit: String(s) });
2235
- return t && r.set("kind", t), this.api.get(`/memory/ontology/hitl?${r.toString()}`);
2276
+ const n = new URLSearchParams({ status: e, limit: String(s) });
2277
+ return t && n.set("kind", t), this.api.get(`/memory/ontology/hitl?${n.toString()}`);
2236
2278
  }
2237
2279
  /**
2238
2280
  * Resolve one ontology HITL queue item (open -> resolved).
@@ -2252,14 +2294,113 @@ class ee {
2252
2294
  * @param {string} [options.layer] public|domain|private
2253
2295
  * @param {string} [options.packId] filter by originating pack id
2254
2296
  * @param {boolean} [options.hasIri] only types with (or without) an IRI
2297
+ * @param {string} [options.kind] entity | record (CORE-MEMTYPE-DECLARE-1)
2255
2298
  * @param {number} [options.limit=100]
2256
2299
  * @param {string} [options.cursor] opaque keyset continuation token
2257
2300
  */
2258
- async listTypes({ tier: e, layer: t, packId: s, hasIri: r, limit: n = 100, cursor: i } = {}) {
2259
- const o = { limit: String(n) };
2260
- e !== void 0 && (o.tier = e), t !== void 0 && (o.layer = t), s !== void 0 && (o.pack_id = s), r !== void 0 && (o.has_iri = String(r)), i !== void 0 && (o.cursor = i);
2261
- const c = new URLSearchParams(o).toString();
2262
- return this.api.get(`/memory/ontology/types${c ? "?" + c : ""}`);
2301
+ async listTypes({ tier: e, layer: t, packId: s, hasIri: n, kind: r, limit: i = 100, cursor: c } = {}) {
2302
+ const o = { limit: String(i) };
2303
+ e !== void 0 && (o.tier = e), t !== void 0 && (o.layer = t), s !== void 0 && (o.pack_id = s), n !== void 0 && (o.has_iri = String(n)), r !== void 0 && (o.kind = r), c !== void 0 && (o.cursor = c);
2304
+ const h = new URLSearchParams(o).toString();
2305
+ return this.api.get(`/memory/ontology/types${h ? "?" + h : ""}`);
2306
+ }
2307
+ /**
2308
+ * Declare an ontology class (CORE-MEMTYPE-DECLARE-1).
2309
+ *
2310
+ * `kind: 'record'` declares a concrete record type: items may then be
2311
+ * written with `memory_type=name` through the add and structured-ingest
2312
+ * surfaces, schema-checked against `propertiesSchema` (STRICT by default —
2313
+ * violations refuse with a structured 400; the server-side literal-"false"
2314
+ * env kill-switch downgrades to WARNING).
2315
+ * Field names/enums are pinned by `memory-type-contract.json`.
2316
+ *
2317
+ * @param {string} name class name — for kind='record' this IS the memory_type
2318
+ * @param {Object} [options]
2319
+ * @param {('entity'|'record')} [options.kind='entity']
2320
+ * @param {Object} [options.propertiesSchema] field name -> {type, of?, default?, indexed?, append_only?}
2321
+ * @param {string[]} [options.requiredProperties]
2322
+ * @param {('full'|'indexed'|'append')} [options.storageStrategy] record classes only
2323
+ * @param {boolean} [options.storageSearchable] record classes only
2324
+ * @param {string} [options.iri]
2325
+ * @param {string} [options.wikidataQid]
2326
+ * @param {string} [options.displayName]
2327
+ * @param {string} [options.definition]
2328
+ * @param {string} [options.description]
2329
+ * @param {string[]} [options.aliases]
2330
+ * @param {string[]} [options.examples]
2331
+ * @param {string[]} [options.parentTypes]
2332
+ * @param {string} [options.tier='confirmed'] 'working' routes through review
2333
+ * @returns {Promise<Object>} the created type projection (incl. kind + storage facet)
2334
+ * @throws 400 invalid schema/tier/kind/strategy; 409 built-in shadowing or identity conflict
2335
+ */
2336
+ async declareType(e, {
2337
+ kind: t = "entity",
2338
+ propertiesSchema: s,
2339
+ requiredProperties: n,
2340
+ storageStrategy: r,
2341
+ storageSearchable: i,
2342
+ iri: c,
2343
+ wikidataQid: o,
2344
+ displayName: h,
2345
+ definition: y,
2346
+ description: p,
2347
+ aliases: d,
2348
+ examples: _,
2349
+ parentTypes: $,
2350
+ tier: g = "confirmed"
2351
+ } = {}) {
2352
+ const u = { name: e, kind: t, tier: g };
2353
+ return s !== void 0 && (u.properties_schema = s), n !== void 0 && (u.required_properties = n), 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);
2354
+ }
2355
+ /**
2356
+ * Declare an ontology relation (CORE-MEMTYPE-DECLARE-1; declare-only in P1).
2357
+ * Record links use record-class domain/range; edge validation is P3.
2358
+ *
2359
+ * @param {string} name
2360
+ * @param {Object} [options]
2361
+ * @param {string[]} [options.domain]
2362
+ * @param {string[]} [options.range]
2363
+ * @param {string} [options.inverseOf]
2364
+ * @param {('1:1'|'1:N'|'N:N')} [options.cardinality]
2365
+ * @param {boolean} [options.temporal]
2366
+ * @param {Object} [options.propertiesSchema]
2367
+ * @param {boolean} [options.transitive]
2368
+ * @param {boolean} [options.symmetric]
2369
+ * @param {boolean} [options.reflexive]
2370
+ * @param {string[]} [options.parentRelations]
2371
+ * @param {string} [options.iri]
2372
+ * @param {string} [options.wikidataPid]
2373
+ * @param {string} [options.displayName]
2374
+ * @param {string} [options.definition]
2375
+ * @param {string} [options.description]
2376
+ * @param {string[]} [options.aliases]
2377
+ * @param {string[]} [options.examples]
2378
+ * @param {string} [options.tier='confirmed']
2379
+ * @returns {Promise<Object>} the created relation projection
2380
+ * @throws 400 invalid tier; 409 identity-slot conflict
2381
+ */
2382
+ async declareRelation(e, {
2383
+ domain: t,
2384
+ range: s,
2385
+ inverseOf: n,
2386
+ cardinality: r,
2387
+ temporal: i,
2388
+ propertiesSchema: c,
2389
+ transitive: o,
2390
+ symmetric: h,
2391
+ reflexive: y,
2392
+ parentRelations: p,
2393
+ iri: d,
2394
+ wikidataPid: _,
2395
+ displayName: $,
2396
+ definition: g,
2397
+ description: u,
2398
+ aliases: b,
2399
+ examples: I,
2400
+ tier: l = "confirmed"
2401
+ } = {}) {
2402
+ const m = { name: e, tier: l };
2403
+ return t !== void 0 && (m.domain = t), s !== void 0 && (m.range = s), n !== void 0 && (m.inverse_of = n), 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);
2263
2404
  }
2264
2405
  /**
2265
2406
  * List ontology relation types, keyset-paginated. Mirror of `listTypes`.
@@ -2271,11 +2412,11 @@ class ee {
2271
2412
  * @param {number} [options.limit=100]
2272
2413
  * @param {string} [options.cursor] opaque keyset continuation token
2273
2414
  */
2274
- async listRelations({ tier: e, layer: t, packId: s, hasIri: r, limit: n = 100, cursor: i } = {}) {
2275
- const o = { limit: String(n) };
2276
- e !== void 0 && (o.tier = e), t !== void 0 && (o.layer = t), s !== void 0 && (o.pack_id = s), r !== void 0 && (o.has_iri = String(r)), i !== void 0 && (o.cursor = i);
2277
- const c = new URLSearchParams(o).toString();
2278
- return this.api.get(`/memory/ontology/relations${c ? "?" + c : ""}`);
2415
+ async listRelations({ tier: e, layer: t, packId: s, hasIri: n, limit: r = 100, cursor: i } = {}) {
2416
+ const c = { limit: String(r) };
2417
+ e !== void 0 && (c.tier = e), t !== void 0 && (c.layer = t), s !== void 0 && (c.pack_id = s), n !== void 0 && (c.has_iri = String(n)), i !== void 0 && (c.cursor = i);
2418
+ const o = new URLSearchParams(c).toString();
2419
+ return this.api.get(`/memory/ontology/relations${o ? "?" + o : ""}`);
2279
2420
  }
2280
2421
  /**
2281
2422
  * Resolve a single ontology type by iri/qid/name.
@@ -2300,11 +2441,11 @@ class ee {
2300
2441
  * @param {string} [options.until] full ISO-8601 upper bound (inclusive)
2301
2442
  * @param {number} [options.limit=200]
2302
2443
  */
2303
- async listAudit({ actor: e, action: t, since: s, until: r, limit: n = 200 } = {}) {
2304
- const i = { limit: String(n) };
2305
- e !== void 0 && (i.actor = e), t !== void 0 && (i.action = t), s !== void 0 && (i.since = s), r !== void 0 && (i.until = r);
2306
- const o = new URLSearchParams(i).toString();
2307
- return this.api.get(`/memory/ontology/audit${o ? "?" + o : ""}`);
2444
+ async listAudit({ actor: e, action: t, since: s, until: n, limit: r = 200 } = {}) {
2445
+ const i = { limit: String(r) };
2446
+ e !== void 0 && (i.actor = e), t !== void 0 && (i.action = t), s !== void 0 && (i.since = s), n !== void 0 && (i.until = n);
2447
+ const c = new URLSearchParams(i).toString();
2448
+ return this.api.get(`/memory/ontology/audit${c ? "?" + c : ""}`);
2308
2449
  }
2309
2450
  /**
2310
2451
  * Full append-only audit trail for one ontology type (oldest-first).
@@ -2329,8 +2470,8 @@ class ee {
2329
2470
  async getPackAudit(e, { packVersion: t = null } = {}) {
2330
2471
  const s = {};
2331
2472
  t !== null && (s.pack_version = t);
2332
- const r = new URLSearchParams(s).toString();
2333
- return this.api.get(`/memory/ontology/packs/${encodeURIComponent(e)}/audit${r ? "?" + r : ""}`);
2473
+ const n = new URLSearchParams(s).toString();
2474
+ return this.api.get(`/memory/ontology/packs/${encodeURIComponent(e)}/audit${n ? "?" + n : ""}`);
2334
2475
  }
2335
2476
  /**
2336
2477
  * Reclassify every instance of `fromId` onto `toId`. Both types stay live.
@@ -2339,13 +2480,34 @@ class ee {
2339
2480
  * @param {Object} params
2340
2481
  * @param {string} params.reason why the migration is being performed (audit evidence)
2341
2482
  * @param {number} [params.batchSize=500] instance edges rewritten per chunk
2342
- */
2343
- async migrateTypeInstances(e, t, { reason: s, batchSize: r = 500 }) {
2344
- return this.api.post(
2483
+ * @param {('refuse'|'skip')} [params.onViolation='refuse'] record migrations:
2484
+ * strict preflight or migrate valid items and report skipped ids. Ignored for entities.
2485
+ * @returns {Promise<Object>} Always includes moved_item_ids, skipped_items,
2486
+ * vector_metadata_updated, vector_metadata_missing, vector_metadata_failed and
2487
+ * searchable_mismatch_count alongside the original fields. They are additive with
2488
+ * defaults, so an entity migration returns them empty/zero rather than omitting
2489
+ * them — callers never branch on kind to read a response.
2490
+ */
2491
+ async migrateTypeInstances(e, t, { reason: s, batchSize: n = 500, onViolation: r = "refuse" }) {
2492
+ const i = { reason: s, batch_size: n };
2493
+ return r !== "refuse" && (i.on_violation = r), this.api.post(
2345
2494
  `/memory/ontology/types/${encodeURIComponent(e)}/migrate-to/${encodeURIComponent(t)}`,
2346
- { reason: s, batch_size: r }
2495
+ i
2347
2496
  );
2348
2497
  }
2498
+ /**
2499
+ * Retire this workspace's own confirmed record class.
2500
+ * Deliberately narrow: the server refuses (400) unless the type resolves to the
2501
+ * workspace's PRIVATE layer AND is kind 'record'. Public and pack classes are
2502
+ * shared vocabulary — retiring `decision` would disable a built-in memory type
2503
+ * for the whole workspace. Entity classes use the curation queue instead.
2504
+ * @param {string} typeId ontology type identifier
2505
+ * @param {string} reason audit evidence for the retirement
2506
+ * @returns {Promise<{ok: boolean}>}
2507
+ */
2508
+ async retireType(e, t) {
2509
+ return this.api.post(`/memory/ontology/types/${encodeURIComponent(e)}/retire`, { reason: t });
2510
+ }
2349
2511
  // --- ONTO-HITL-CURATE-1 curation queue surface ---------------------------
2350
2512
  /**
2351
2513
  * List ontology review queue items, keyset-paginated.
@@ -2356,11 +2518,11 @@ class ee {
2356
2518
  * @param {number} [options.limit=100]
2357
2519
  * @param {string} [options.cursor] opaque keyset continuation token
2358
2520
  */
2359
- async listReviewQueue({ tier: e, assignee: t, source: s, limit: r = 100, cursor: n } = {}) {
2360
- const i = { limit: String(r) };
2361
- e !== void 0 && (i.tier = e), t !== void 0 && (i.assignee = t), s !== void 0 && (i.source = s), n !== void 0 && (i.cursor = n);
2362
- const o = new URLSearchParams(i).toString();
2363
- return this.api.get(`/memory/ontology/queue${o ? "?" + o : ""}`);
2521
+ async listReviewQueue({ tier: e, assignee: t, source: s, limit: n = 100, cursor: r } = {}) {
2522
+ const i = { limit: String(n) };
2523
+ e !== void 0 && (i.tier = e), t !== void 0 && (i.assignee = t), s !== void 0 && (i.source = s), r !== void 0 && (i.cursor = r);
2524
+ const c = new URLSearchParams(i).toString();
2525
+ return this.api.get(`/memory/ontology/queue${c ? "?" + c : ""}`);
2364
2526
  }
2365
2527
  /**
2366
2528
  * Approve one ontology review type.
@@ -2390,8 +2552,8 @@ class ee {
2390
2552
  * @param {string} [options.expectedTier] optional optimistic tier precondition
2391
2553
  */
2392
2554
  async mergeReviewType(e, t, { expectedTier: s } = {}) {
2393
- const r = { into_id: t };
2394
- return s !== void 0 && (r.expected_tier = s), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/merge`, r);
2555
+ const n = { into_id: t };
2556
+ return s !== void 0 && (n.expected_tier = s), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/merge`, n);
2395
2557
  }
2396
2558
  /**
2397
2559
  * Edit and promote one ontology review type.
@@ -2401,8 +2563,8 @@ class ee {
2401
2563
  * @param {string} [options.expectedTier] optional optimistic tier precondition
2402
2564
  */
2403
2565
  async editPromoteReviewType(e, t, { expectedTier: s } = {}) {
2404
- const r = { edits: t };
2405
- return s !== void 0 && (r.expected_tier = s), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/edit-promote`, r);
2566
+ const n = { edits: t };
2567
+ return s !== void 0 && (n.expected_tier = s), this.api.post(`/memory/ontology/queue/${encodeURIComponent(e)}/edit-promote`, n);
2406
2568
  }
2407
2569
  /**
2408
2570
  * Assign or clear the reviewer for one ontology review type.
@@ -2420,12 +2582,12 @@ class ee {
2420
2582
  * @param {Object} [options.params] action-specific params
2421
2583
  * @param {string} [options.expectedTier] optional optimistic tier precondition
2422
2584
  */
2423
- async bulkReviewAction(e, t, { params: s, expectedTier: r } = {}) {
2424
- const n = { action: e, ids: t, params: s === void 0 ? {} : s };
2425
- return r !== void 0 && (n.expected_tier = r), this.api.post("/memory/ontology/queue/bulk", n);
2585
+ async bulkReviewAction(e, t, { params: s, expectedTier: n } = {}) {
2586
+ const r = { action: e, ids: t, params: s === void 0 ? {} : s };
2587
+ return n !== void 0 && (r.expected_tier = n), this.api.post("/memory/ontology/queue/bulk", r);
2426
2588
  }
2427
2589
  }
2428
- class te {
2590
+ class re {
2429
2591
  constructor(e) {
2430
2592
  this.api = e;
2431
2593
  }
@@ -2450,11 +2612,11 @@ class te {
2450
2612
  * @param {boolean} [options.topicAnalysis]
2451
2613
  */
2452
2614
  async detectBias({ protectedAttributes: e = null, sentimentAnalysis: t = null, topicAnalysis: s = null } = {}) {
2453
- const r = {};
2454
- 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);
2615
+ const n = {};
2616
+ return e !== null && (n.protected_attributes = e), t !== null && (n.sentiment_analysis = t), s !== null && (n.topic_analysis = s), this.api.post("/memory/analytics/bias", n);
2455
2617
  }
2456
2618
  }
2457
- class se {
2619
+ class ie {
2458
2620
  constructor(e) {
2459
2621
  this.api = e;
2460
2622
  }
@@ -2490,7 +2652,7 @@ class se {
2490
2652
  return this.api.get("/memory/inference/rules");
2491
2653
  }
2492
2654
  }
2493
- class re {
2655
+ class ae {
2494
2656
  constructor(e) {
2495
2657
  this.api = e;
2496
2658
  }
@@ -2591,11 +2753,11 @@ class re {
2591
2753
  * @param {string} [params.description='']
2592
2754
  * @param {Object} [params.config={}]
2593
2755
  */
2594
- async updateConfig(e, { name: t = "", description: s = "", config: r = {} }) {
2756
+ async updateConfig(e, { name: t = "", description: s = "", config: n = {} }) {
2595
2757
  return this.api.patch(`/memory/pipeline/configs/${e}`, {
2596
2758
  name: t,
2597
2759
  description: s,
2598
- config: r
2760
+ config: n
2599
2761
  });
2600
2762
  }
2601
2763
  /**
@@ -2606,7 +2768,7 @@ class re {
2606
2768
  return this.api.delete(`/memory/pipeline/configs/${e}`);
2607
2769
  }
2608
2770
  }
2609
- class ne {
2771
+ class oe {
2610
2772
  constructor(e) {
2611
2773
  this.api = e;
2612
2774
  }
@@ -2632,7 +2794,7 @@ class ne {
2632
2794
  return this.api.get(`/memory/archive/${e}`);
2633
2795
  }
2634
2796
  }
2635
- class ie {
2797
+ class ce {
2636
2798
  constructor(e) {
2637
2799
  this.api = e;
2638
2800
  }
@@ -2791,7 +2953,7 @@ class ie {
2791
2953
  return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${s}`);
2792
2954
  }
2793
2955
  }
2794
- class ae {
2956
+ class ue {
2795
2957
  constructor(e) {
2796
2958
  this.api = e;
2797
2959
  }
@@ -2806,7 +2968,7 @@ class ae {
2806
2968
  */
2807
2969
  async list(e = {}) {
2808
2970
  const t = Object.fromEntries(
2809
- Object.entries(e).filter(([, r]) => r != null)
2971
+ Object.entries(e).filter(([, n]) => n != null)
2810
2972
  ), s = new URLSearchParams(t).toString();
2811
2973
  return this.api.get(`/memory/procedures/matches${s ? "?" + s : ""}`);
2812
2974
  }
@@ -2817,8 +2979,8 @@ class ae {
2817
2979
  * @param {string} [note] - Optional explanation
2818
2980
  */
2819
2981
  async submitFeedback(e, t, s = null) {
2820
- const r = { feedback: t };
2821
- return s && (r.note = s), this.api.post(`/memory/procedures/matches/${e}/feedback`, r);
2982
+ const n = { feedback: t };
2983
+ return s && (n.note = s), this.api.post(`/memory/procedures/matches/${e}/feedback`, n);
2822
2984
  }
2823
2985
  /**
2824
2986
  * Get aggregated procedure match statistics.
@@ -2827,7 +2989,7 @@ class ae {
2827
2989
  return this.api.get("/memory/procedures/matches/stats");
2828
2990
  }
2829
2991
  }
2830
- class oe {
2992
+ class le {
2831
2993
  constructor(e) {
2832
2994
  this.api = e;
2833
2995
  }
@@ -2842,7 +3004,7 @@ class oe {
2842
3004
  */
2843
3005
  async list(e = {}) {
2844
3006
  const t = Object.fromEntries(
2845
- Object.entries(e).filter(([, r]) => r != null)
3007
+ Object.entries(e).filter(([, n]) => n != null)
2846
3008
  ), s = new URLSearchParams(t).toString();
2847
3009
  return this.api.get(`/memory/procedures/candidates${s ? "?" + s : ""}`);
2848
3010
  }
@@ -2876,7 +3038,7 @@ class oe {
2876
3038
  return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
2877
3039
  }
2878
3040
  }
2879
- class ce {
3041
+ class me {
2880
3042
  constructor(e) {
2881
3043
  this.api = e;
2882
3044
  }
@@ -2893,7 +3055,7 @@ class ce {
2893
3055
  */
2894
3056
  async list(e = {}) {
2895
3057
  const t = Object.fromEntries(
2896
- Object.entries(e).filter(([, r]) => r != null)
3058
+ Object.entries(e).filter(([, n]) => n != null)
2897
3059
  ), s = new URLSearchParams(t).toString();
2898
3060
  return this.api.get(`/memory/procedures/drift${s ? "?" + s : ""}`);
2899
3061
  }
@@ -2931,7 +3093,7 @@ class ce {
2931
3093
  return this.api.get(`/memory/procedures/schemas/${e}`);
2932
3094
  }
2933
3095
  }
2934
- class ue {
3096
+ class he {
2935
3097
  constructor(e) {
2936
3098
  this.api = e;
2937
3099
  }
@@ -2983,8 +3145,8 @@ class ue {
2983
3145
  * @param {string} [params.before] ISO 8601 datetime
2984
3146
  */
2985
3147
  async list({ isHeartbeat: e = null, limit: t = 20, before: s = null } = {}) {
2986
- const r = { limit: t };
2987
- return e !== null && (r.is_heartbeat = e), s !== null && (r.before = s), this.api.get("/memory/summary/list", r);
3148
+ const n = { limit: t };
3149
+ return e !== null && (n.is_heartbeat = e), s !== null && (n.before = s), this.api.get("/memory/summary/list", n);
2988
3150
  }
2989
3151
  /** SnapshotDelta between two snapshots. Returns null on 404. */
2990
3152
  async delta({ from: e, to: t }) {
@@ -3003,11 +3165,119 @@ class ue {
3003
3165
  return this.api.delete(`/memory/summary/${e}`);
3004
3166
  }
3005
3167
  }
3006
- class le {
3168
+ class ye {
3169
+ constructor(e) {
3170
+ this.api = e;
3171
+ }
3172
+ /**
3173
+ * Acquire a lease, or return null when a live holder definitively owns it.
3174
+ * @param {string} key
3175
+ * @param {Object} [params]
3176
+ * @param {number} [params.ttlSeconds]
3177
+ * @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
3178
+ */
3179
+ async acquire(e, { ttlSeconds: t } = {}) {
3180
+ var n, r;
3181
+ const s = {};
3182
+ t !== void 0 && (s.ttl_seconds = t);
3183
+ try {
3184
+ return await this.api.post(`/memory/locks/${e}`, s);
3185
+ } catch (i) {
3186
+ if ((i == null ? void 0 : i.status) === 409 && ((r = (n = i.detail) == null ? void 0 : n.detail) == null ? void 0 : r.reason) === "lock_held")
3187
+ return null;
3188
+ throw i;
3189
+ }
3190
+ }
3191
+ /**
3192
+ * Renew a lease, or return null when this token definitively no longer owns it.
3193
+ * @param {string} key
3194
+ * @param {string} token
3195
+ * @param {Object} [params]
3196
+ * @param {number} [params.ttlSeconds]
3197
+ * @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
3198
+ */
3199
+ async renew(e, t, { ttlSeconds: s } = {}) {
3200
+ var r, i;
3201
+ const n = {};
3202
+ s !== void 0 && (n.ttl_seconds = s);
3203
+ try {
3204
+ return await this.api.post(`/memory/locks/${e}/renew`, n, {
3205
+ headers: { "X-Lease-Token": t }
3206
+ });
3207
+ } catch (c) {
3208
+ if ((c == null ? void 0 : c.status) === 409 && ((i = (r = c.detail) == null ? void 0 : r.detail) == null ? void 0 : i.reason) === "not_owner")
3209
+ return null;
3210
+ throw c;
3211
+ }
3212
+ }
3213
+ /**
3214
+ * Release a lease. Returns false when this token definitively no longer owns it.
3215
+ * @param {string} key
3216
+ * @param {string} token
3217
+ * @returns {Promise<boolean>}
3218
+ */
3219
+ async release(e, t) {
3220
+ var s, n;
3221
+ try {
3222
+ return await this.api.delete(`/memory/locks/${e}`, {
3223
+ headers: { "X-Lease-Token": t }
3224
+ }), !0;
3225
+ } catch (r) {
3226
+ if ((r == null ? void 0 : r.status) === 409 && ((n = (s = r.detail) == null ? void 0 : s.detail) == null ? void 0 : n.reason) === "not_owner")
3227
+ return !1;
3228
+ throw r;
3229
+ }
3230
+ }
3231
+ }
3232
+ class pe {
3233
+ constructor(e) {
3234
+ this.api = e;
3235
+ }
3236
+ /**
3237
+ * Consume the next numbers. The caller owns the inclusive range [first, value].
3238
+ *
3239
+ * Every non-2xx throws. Unlike the lease there is no benign failure to
3240
+ * swallow — returning null on a 503 would let a caller mistake coordinator
3241
+ * failure for an allocation, which is the one thing this primitive prevents.
3242
+ *
3243
+ * Numbers you do not use are LOST. There is no release and no reclaim; gaps
3244
+ * are guaranteed, so never treat `value` as a record count.
3245
+ *
3246
+ * @param {string} name
3247
+ * @param {Object} [params]
3248
+ * @param {number} [params.floor] High-water mark. Applied with `$max`, so it
3249
+ * can only ever raise the counter — safe and idempotent to send every call.
3250
+ * @param {number} [params.count] How many to allocate (1..100, default 1).
3251
+ * @returns {Promise<{name: string, value: number, first: number, count: number}>}
3252
+ */
3253
+ async allocate(e, { floor: t, count: s } = {}) {
3254
+ const n = {};
3255
+ return t !== void 0 && (n.floor = t), s !== void 0 && (n.count = s), this.api.post(`/memory/sequences/${e}/next`, n);
3256
+ }
3257
+ /**
3258
+ * Read the counter without consuming a number, or null if never allocated.
3259
+ *
3260
+ * Only a 404 becomes null. A 503 throws — a down coordinator is not the same
3261
+ * answer as "this sequence does not exist".
3262
+ *
3263
+ * @param {string} name
3264
+ * @returns {Promise<number|null>}
3265
+ */
3266
+ async peek(e) {
3267
+ try {
3268
+ const t = await this.api.get(`/memory/sequences/${e}`);
3269
+ return (t == null ? void 0 : t.value) ?? null;
3270
+ } catch (t) {
3271
+ if ((t == null ? void 0 : t.status) === 404) return null;
3272
+ throw t;
3273
+ }
3274
+ }
3275
+ }
3276
+ class ge {
3007
3277
  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);
3278
+ this.auth = new F(e);
3279
+ const t = new O(this.auth, { fetchFn: e.fetchFn });
3280
+ this._api = t, this.memories = new j(t), this.decisions = new H(t), this.opinions = new B(t), this.graph = new K(t), this.teams = new G(t), this.profiles = new D(t), this.subscriptions = new N(t), this.authAPI = new J(t), this.agents = new W(t), this.usage = new V(t), this.insights = new Y(t), this.tokenUsage = new X(t), this.temporal = new Z(t), this.governance = new Q(t), this.evolution = new ee(t), this.reasoning = new te(t), this.reasoningTraces = new se(t), this.ontology = new ne(t), this.analytics = new re(t), this.validation = new ie(t), this.pipeline = new ae(t), this.archive = new oe(t), this.zettelkasten = new ce(t), this.procedureMatches = new ue(t), this.procedureCandidates = new le(t), this.procedureDrift = new me(t), this.summaries = new he(t), this.locks = new ye(t), this.sequences = new pe(t);
3011
3281
  }
3012
3282
  setTeamId(e) {
3013
3283
  this.auth.tokenManager.setTeamId(e), this.auth.notifyListeners();
@@ -3033,36 +3303,38 @@ class le {
3033
3303
  }
3034
3304
  }
3035
3305
  export {
3036
- 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
3306
+ k as A,
3307
+ O as B,
3308
+ H as D,
3309
+ ee as E,
3310
+ Q as G,
3311
+ Y as I,
3312
+ ye as L,
3313
+ j as M,
3314
+ ne as O,
3315
+ ae as P,
3316
+ te as R,
3317
+ pe as S,
3318
+ G as T,
3319
+ V as U,
3320
+ ie as V,
3321
+ ce as Z,
3322
+ W as a,
3323
+ re as b,
3324
+ oe as c,
3325
+ J as d,
3326
+ F as e,
3327
+ K as f,
3328
+ B as g,
3329
+ le as h,
3330
+ ue as i,
3331
+ D as j,
3332
+ se as k,
3333
+ ge as l,
3334
+ N as m,
3335
+ Z as n,
3336
+ z as o,
3337
+ X as p,
3338
+ E as q,
3339
+ x as r
3068
3340
  };