@smartmemory/sdk-js 1.4.60 → 1.4.64

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 g = (a, e, t) => (w(a, e, "read from private field"), t ? t.call(a) : e.get(a)), b = (a, e, t) => e.has(a) ? S("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, t), I = (a, e, t, s) => (w(a, e, "write to private field"), s ? s.call(a, t) : e.set(a, t), t), T = (a, e, t) => (w(a, e, "access private method"), t);
6
- const q = {
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 M {
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 = { ...q, ...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 M {
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 M {
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 M {
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 M {
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 M {
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 M {
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 M {
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 M {
148
148
  return s === "none" || s === "null" || s === "undefined" ? null : t;
149
149
  }
150
150
  }
151
- var m, _, v;
152
- class z {
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 z {
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, m, 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 (g(this, m))
169
- return g(this, m);
170
- I(this, m, T(this, _, v).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 g(this, m);
172
+ return await R(this, f);
173
173
  } finally {
174
- I(this, m, null);
174
+ A(this, f, null);
175
175
  }
176
176
  }
177
177
  }
178
- m = new WeakMap(), _ = new WeakSet(), v = 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 @@ m = new WeakMap(), _ = new WeakSet(), v = 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 E {
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 E {
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 x {
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 M({
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 z({
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 x {
247
247
  onRefreshFailed: () => {
248
248
  this.clearLocalAuth();
249
249
  }
250
- }) : this.refreshManager = null, this.mode === "sso" && (this.ssoManager = new E({
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 x {
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 x {
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,7 +377,7 @@ 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
383
  class O {
@@ -392,35 +392,35 @@ class O {
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 l = {
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: l, __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 O {
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 l = {
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: l, __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 O {
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 O {
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 F {
530
+ class j {
531
531
  constructor(e) {
532
532
  this.api = e;
533
533
  }
@@ -555,22 +555,22 @@ class F {
555
555
  content: e,
556
556
  memoryType: t = "semantic",
557
557
  metadata: s = null,
558
- usePipeline: r = !0,
559
- profileName: n = null,
558
+ usePipeline: n = !0,
559
+ profileName: r = null,
560
560
  conversationContext: i = null,
561
- embed: o = null
561
+ embed: c = null
562
562
  }) {
563
- const c = {
563
+ const o = {
564
564
  content: e,
565
565
  memory_type: t,
566
566
  metadata: s,
567
- use_pipeline: r,
568
- profile_name: n
567
+ use_pipeline: n,
568
+ profile_name: r
569
569
  };
570
- return i != null && (c.conversation_context = i), o != null && (c.embed = o), this.api.post("/memory/add", c);
570
+ return i != null && (o.conversation_context = i), c != null && (o.embed = c), this.api.post("/memory/add", o);
571
571
  }
572
572
  async get(e) {
573
- const t = await this.api.get(`/memory/${e}`);
573
+ const t = await this.api.get(`/memory/${encodeURIComponent(e)}`);
574
574
  return { ...t, id: t.item_id || t.id };
575
575
  }
576
576
  /**
@@ -587,14 +587,14 @@ class F {
587
587
  * (preserving memory_type and node_category).
588
588
  */
589
589
  async update(e, t) {
590
- return this.api.patch(`/memory/${e}`, t);
590
+ return this.api.patch(`/memory/${encodeURIComponent(e)}`, t);
591
591
  }
592
- async supersede(e, { content: t, memoryType: s, metadata: r = {}, reason: n }) {
593
- 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`, {
594
594
  content: t,
595
595
  memory_type: s,
596
- metadata: r,
597
- reason: n
596
+ metadata: n,
597
+ reason: r
598
598
  });
599
599
  }
600
600
  /**
@@ -614,13 +614,13 @@ class F {
614
614
  * out of scope (deliberately indistinguishable); 409 if the store declined.
615
615
  */
616
616
  async supersedeLink(e, t, s = null) {
617
- return this.api.post(`/memory/${e}/supersede-link`, {
617
+ return this.api.post(`/memory/${encodeURIComponent(e)}/supersede-link`, {
618
618
  new_item_id: t,
619
619
  reason: s
620
620
  });
621
621
  }
622
622
  async delete(e) {
623
- return this.api.delete(`/memory/${e}`);
623
+ return this.api.delete(`/memory/${encodeURIComponent(e)}`);
624
624
  }
625
625
  /**
626
626
  * List memory items, optionally filtered by an exact metadata match.
@@ -642,11 +642,11 @@ class F {
642
642
  limit: e = 50,
643
643
  offset: t = 0,
644
644
  type: s = null,
645
- metadataKey: r = null,
646
- metadataValue: n = null
645
+ metadataKey: n = null,
646
+ metadataValue: r = null
647
647
  } = {}) {
648
648
  const i = new URLSearchParams({ limit: e, offset: t });
649
- 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}`);
650
650
  }
651
651
  /**
652
652
  * Search for memory items.
@@ -696,9 +696,9 @@ class F {
696
696
  * result marked `'unresolved'` is PRESENT-DAY content and must not be rendered
697
697
  * as a historical belief.
698
698
  */
699
- async search(e, { topK: t = 5, enableHybrid: s = !0, memoryType: r = null, expertise: n = !1, cite: i = !1, decompose: o = !1, multiHop: c = !1, maxHops: l = 3, budgetMs: p = 1500, semanticHops: $ = !1, includeReference: k = !1, includeConsolidated: U = !1, consolidationFirst: A = !1, asOfDate: d = null, asOfStrict: C = !1, includeSuperseded: P = !1, includeRetracted: L = !1 } = {}) {
700
- const u = { query: e, top_k: t, enable_hybrid: s };
701
- return r && (u.memory_type = r), n && (u.expertise = !0), i && (u.cite = !0), o && (u.decompose = !0), c && (u.multi_hop = !0), c && l !== 3 && (u.max_hops = l), c && p !== 1500 && (u.budget_ms = p), c && $ && (u.semantic_hops = !0), k && (u.include_reference = !0), U && (u.include_consolidated = !0), A && (u.consolidation_first = !0), d && (u.as_of_date = d instanceof Date ? d.toISOString() : d), C && (u.as_of_strict = !0), P && (u.include_superseded = !0), L && (u.include_retracted = !0), this.api.post("/memory/search", u);
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);
702
702
  }
703
703
  /**
704
704
  * Get the complete audit answer for one memory (PLAT-AUDITABLE-MEMORY-1).
@@ -716,35 +716,35 @@ class F {
716
716
  async explain(e) {
717
717
  return this.api.get(`/memory/${encodeURIComponent(e)}/explain`);
718
718
  }
719
- 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 } = {}) {
720
720
  const i = {
721
721
  session_id: e,
722
722
  query: t,
723
723
  k: s
724
724
  };
725
- 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);
726
726
  }
727
- 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 } = {}) {
728
728
  return this.api.post("/memory/search/advanced", {
729
729
  query: e,
730
730
  algorithm: t,
731
731
  max_results: s,
732
- use_ssg: r
732
+ use_ssg: n
733
733
  });
734
734
  }
735
- async ingest(e, { profileName: t = null, extractorName: s = "llm", context: r = {} } = {}) {
735
+ async ingest(e, { profileName: t = null, extractorName: s = "llm", context: n = {} } = {}) {
736
736
  return this.api.post("/memory/ingest", {
737
737
  content: e,
738
738
  profile_name: t,
739
739
  extractor_name: s,
740
- context: r
740
+ context: n
741
741
  });
742
742
  }
743
743
  async getLineage(e) {
744
- return this.api.get(`/memory/${e}/lineage`);
744
+ return this.api.get(`/memory/${encodeURIComponent(e)}/lineage`);
745
745
  }
746
746
  async getLinks(e) {
747
- return this.api.get(`/memory/${e}/links`);
747
+ return this.api.get(`/memory/${encodeURIComponent(e)}/links`);
748
748
  }
749
749
  /**
750
750
  * Find memory items by exact metadata match.
@@ -755,16 +755,16 @@ class F {
755
755
  * endpoints return slightly different item shapes, so migrate deliberately rather
756
756
  * than by find-and-replace.
757
757
  */
758
- async searchByMetadata(e, t, { memoryType: s = null, limit: r = 25 } = {}) {
759
- const n = new URLSearchParams({
758
+ async searchByMetadata(e, t, { memoryType: s = null, limit: n = 25 } = {}) {
759
+ const r = new URLSearchParams({
760
760
  metadata_key: e,
761
761
  metadata_value: t,
762
- limit: r
762
+ limit: n
763
763
  });
764
- 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}`);
765
765
  }
766
766
  async getNeighbors(e) {
767
- return this.api.get(`/memory/${e}/neighbors`);
767
+ return this.api.get(`/memory/${encodeURIComponent(e)}/neighbors`);
768
768
  }
769
769
  async getSummary() {
770
770
  return this.api.get("/memory/summary");
@@ -772,24 +772,24 @@ class F {
772
772
  async ingestConversation(e, {
773
773
  sessionBoundaries: t = null,
774
774
  conversationId: s = null,
775
- sessionDates: r = null,
776
- turnsPerChunk: n = 15,
775
+ sessionDates: n = null,
776
+ turnsPerChunk: r = 15,
777
777
  maxChunkChars: i = 12e3,
778
- maxConcurrent: o = 4
778
+ maxConcurrent: c = 4
779
779
  } = {}) {
780
- const c = { turns: e, turns_per_chunk: n, max_chunk_chars: i, max_concurrent: o };
781
- 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);
782
782
  }
783
- async ingestDocument(e, { title: t = null, source: s = null, chunkStrategy: r = null } = {}) {
784
- const n = { content: e };
785
- 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);
786
786
  }
787
787
  async codeIndex(e, { repo: t = null, commit: s = null } = {}) {
788
- const r = { path: e };
789
- 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);
790
790
  }
791
- async codeSearch(e, { entityType: t = null, repo: s = null, limit: r = 20, semantic: n = !1 } = {}) {
792
- 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 });
793
793
  return t && i.append("entity_type", t), s && i.append("repo", s), this.api.get(`/memory/code/search?${i}`);
794
794
  }
795
795
  async codeContext(e, { repo: t = null } = {}) {
@@ -800,8 +800,8 @@ class F {
800
800
  return this.api.get(`/memory/code/dead-code?repo=${encodeURIComponent(e)}`);
801
801
  }
802
802
  async codeDependencies(e, { direction: t = "both", repo: s = null } = {}) {
803
- const r = new URLSearchParams({ entity_name: e, direction: t });
804
- 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}`);
805
805
  }
806
806
  async getPlan(e) {
807
807
  return this.api.get(`/memory/plans/${e}`);
@@ -823,7 +823,7 @@ class F {
823
823
  });
824
824
  }
825
825
  async enrich(e, t = []) {
826
- return this.api.post(`/memory/${e}/enrich`, {
826
+ return this.api.post(`/memory/${encodeURIComponent(e)}/enrich`, {
827
827
  item_id: e,
828
828
  routines: t
829
829
  });
@@ -844,11 +844,11 @@ class F {
844
844
  * @returns {Promise<{updated: number, edges_strengthened: number, outcome: string}>}
845
845
  */
846
846
  async feedback(e, t, s = null) {
847
- const r = { item_ids: e, outcome: t };
848
- 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);
849
849
  }
850
850
  async ground(e, t, s = null) {
851
- return this.api.post(`/memory/${e}/ground`, {
851
+ return this.api.post(`/memory/${encodeURIComponent(e)}/ground`, {
852
852
  item_id: e,
853
853
  source_url: t,
854
854
  validation: s
@@ -858,29 +858,29 @@ class F {
858
858
  return this.api.delete(`/memory/clear-all?nuclear=${e}`);
859
859
  }
860
860
  // --- Temporal ---
861
- async getHistory(e, { startTime: t = null, endTime: s = null, limit: r = 100 } = {}) {
862
- let n = `/memory/temporal/${e}/history?limit=${r}`;
863
- 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);
864
864
  }
865
865
  async timeTravel(e, { query: t = null, limit: s = 100 } = {}) {
866
- let r = `/memory/temporal/at/${e}?limit=${s}`;
867
- 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);
868
868
  }
869
869
  async getItemAtTime(e, t) {
870
870
  return this.api.get(`/memory/temporal/${e}/at/${t}`);
871
871
  }
872
- async getChanges(e, { since: t = null, until: s = null, changeType: r = null } = {}) {
873
- 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`;
874
874
  const i = [];
875
- 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);
876
876
  }
877
877
  async compareVersions(e, t, s) {
878
878
  return this.api.post(`/memory/temporal/${e}/compare?v1=${t}&v2=${s}`);
879
879
  }
880
880
  async rollback(e, { toVersion: t = null, toTime: s = null } = {}) {
881
- let r = `/memory/temporal/${e}/rollback`;
882
- const n = [];
883
- 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);
884
884
  }
885
885
  // --- Clustering ---
886
886
  async runClustering(e = 0.1, t = !1) {
@@ -890,7 +890,7 @@ class F {
890
890
  return this.api.get("/memory/clustering/stats");
891
891
  }
892
892
  }
893
- class j {
893
+ class H {
894
894
  constructor(e) {
895
895
  this.api = e;
896
896
  }
@@ -913,29 +913,29 @@ class j {
913
913
  content: e,
914
914
  decisionType: t = "inference",
915
915
  confidence: s = 0.8,
916
- sourceTraceId: r = null,
917
- sourceSessionId: n = null,
916
+ sourceTraceId: n = null,
917
+ sourceSessionId: r = null,
918
918
  evidenceIds: i = null,
919
- domain: o = null,
920
- tags: c = null,
921
- rejectedAlternatives: l = null,
922
- rationale: p = null,
923
- constraints: $ = null,
924
- 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
925
925
  }) {
926
926
  return this.api.post("/memory/decisions/create", {
927
927
  content: e,
928
928
  decision_type: t,
929
929
  confidence: s,
930
- source_trace_id: r,
931
- source_session_id: n,
930
+ source_trace_id: n,
931
+ source_session_id: r,
932
932
  evidence_ids: i,
933
- domain: o,
934
- tags: c,
935
- rejected_alternatives: l,
936
- rationale: p,
937
- constraints: $,
938
- agent_id: k
933
+ domain: c,
934
+ tags: o,
935
+ rejected_alternatives: h,
936
+ rationale: y,
937
+ constraints: p,
938
+ agent_id: d
939
939
  });
940
940
  }
941
941
  /**
@@ -981,13 +981,13 @@ class j {
981
981
  * @param {string[]} [params.tags]
982
982
  * @param {string} [params.agentId]
983
983
  */
984
- 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 }) {
985
985
  return this.api.post("/memory/decisions/pending/create", {
986
986
  content: e,
987
987
  requirements: t,
988
988
  domain: s,
989
- tags: r,
990
- agent_id: n
989
+ tags: n,
990
+ agent_id: r
991
991
  });
992
992
  }
993
993
  /**
@@ -1108,7 +1108,7 @@ class j {
1108
1108
  });
1109
1109
  }
1110
1110
  }
1111
- class H {
1111
+ class B {
1112
1112
  constructor(e) {
1113
1113
  this.api = e;
1114
1114
  }
@@ -1130,19 +1130,19 @@ class H {
1130
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);
1131
1131
  }
1132
1132
  }
1133
- class B {
1133
+ class K {
1134
1134
  constructor(e) {
1135
1135
  this.api = e;
1136
1136
  }
1137
1137
  async getNeighbors(e) {
1138
1138
  return this.api.get(`/memory/${e}/neighbors`);
1139
1139
  }
1140
- async addEdge(e, t, s, r = {}) {
1140
+ async addEdge(e, t, s, n = {}) {
1141
1141
  return this.api.post("/memory/edge", {
1142
1142
  source_id: e,
1143
1143
  target_id: t,
1144
1144
  relation_type: s,
1145
- properties: r
1145
+ properties: n
1146
1146
  });
1147
1147
  }
1148
1148
  async getHealth() {
@@ -1188,8 +1188,8 @@ class B {
1188
1188
  * @param {string|null} [params.deletePrefix=null] - Scoped node-ID prefix to delete before writing.
1189
1189
  */
1190
1190
  async bulkUpsert({ nodes: e = [], edges: t = [], deletePrefix: s = null } = {}) {
1191
- const r = { nodes: e, edges: t };
1192
- 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);
1193
1193
  }
1194
1194
  /**
1195
1195
  * Get Wikipedia grounding status for an entity node.
@@ -1265,7 +1265,7 @@ class B {
1265
1265
  );
1266
1266
  }
1267
1267
  }
1268
- class K {
1268
+ class G {
1269
1269
  constructor(e) {
1270
1270
  this.api = e;
1271
1271
  }
@@ -1273,14 +1273,14 @@ class K {
1273
1273
  const t = e ? "?include_system=true" : "";
1274
1274
  return this.api.get(`/memory/teams${t}`);
1275
1275
  }
1276
- 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 }) {
1277
1277
  const i = {
1278
1278
  name: e,
1279
1279
  description: t,
1280
1280
  data_classification: s,
1281
- cost_center: r
1281
+ cost_center: n
1282
1282
  };
1283
- 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);
1284
1284
  }
1285
1285
  async get(e) {
1286
1286
  return this.api.get(`/memory/teams/${e}`);
@@ -1307,7 +1307,7 @@ class K {
1307
1307
  return this.api.delete(`/memory/teams/${e}/members/${t}`);
1308
1308
  }
1309
1309
  }
1310
- class G {
1310
+ class D {
1311
1311
  constructor(e) {
1312
1312
  this.api = e;
1313
1313
  }
@@ -1355,7 +1355,7 @@ class N {
1355
1355
  });
1356
1356
  }
1357
1357
  }
1358
- class D {
1358
+ class J {
1359
1359
  constructor(e) {
1360
1360
  this.api = e;
1361
1361
  }
@@ -1376,19 +1376,19 @@ class D {
1376
1376
  return this.api.delete(`/memory/api-keys/${e}`);
1377
1377
  }
1378
1378
  }
1379
- class J {
1379
+ class W {
1380
1380
  constructor(e) {
1381
1381
  this.api = e;
1382
1382
  }
1383
1383
  async list() {
1384
1384
  return this.api.get("/memory/agents");
1385
1385
  }
1386
- 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"] }) {
1387
1387
  return this.api.post("/memory/agents", {
1388
1388
  name: e,
1389
1389
  description: t,
1390
1390
  agent_config: s,
1391
- roles: r
1391
+ roles: n
1392
1392
  });
1393
1393
  }
1394
1394
  async get(e) {
@@ -1415,8 +1415,8 @@ class J {
1415
1415
  * @returns {Promise<{evaluation: object|null}>}
1416
1416
  */
1417
1417
  async getEvaluation(e, t, s) {
1418
- const r = new URLSearchParams({ dimension: t, domain: s }).toString();
1419
- 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 : ""}`);
1420
1420
  }
1421
1421
  /**
1422
1422
  * Get evaluation history for an agent on a given (dimension, domain) slot.
@@ -1430,12 +1430,12 @@ class J {
1430
1430
  * @param {number} [options.limit=20] - Maximum records to return.
1431
1431
  * @returns {Promise<{history: object[]}>}
1432
1432
  */
1433
- async listEvaluationHistory(e, t, s, { limit: r = 20 } = {}) {
1434
- const n = new URLSearchParams({ dimension: t, domain: s, limit: String(r) }).toString();
1435
- 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 : ""}`);
1436
1436
  }
1437
1437
  }
1438
- class W {
1438
+ class V {
1439
1439
  constructor(e) {
1440
1440
  this.api = e;
1441
1441
  }
@@ -1449,7 +1449,7 @@ class W {
1449
1449
  return this.api.get("/usage/tiers");
1450
1450
  }
1451
1451
  }
1452
- class V {
1452
+ class Y {
1453
1453
  constructor(e) {
1454
1454
  this.api = e;
1455
1455
  }
@@ -1466,7 +1466,7 @@ class V {
1466
1466
  return this.api.get("/memory/plugins");
1467
1467
  }
1468
1468
  }
1469
- class Y {
1469
+ class X {
1470
1470
  constructor(e) {
1471
1471
  this.api = e;
1472
1472
  }
@@ -1489,7 +1489,7 @@ class Y {
1489
1489
  return this.api.get("/memory/token-usage/current");
1490
1490
  }
1491
1491
  }
1492
- class X {
1492
+ class Z {
1493
1493
  constructor(e) {
1494
1494
  this.api = e;
1495
1495
  }
@@ -1502,9 +1502,9 @@ class X {
1502
1502
  * @param {string} [options.endTime] - ISO end time
1503
1503
  * @param {number} [options.limit=100]
1504
1504
  */
1505
- async getHistory(e, { startTime: t = null, endTime: s = null, limit: r = 100 } = {}) {
1506
- let n = `/memory/temporal/${e}/history?limit=${r}`;
1507
- 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);
1508
1508
  }
1509
1509
  // === TIME-TRAVEL QUERIES ===
1510
1510
  /**
@@ -1515,8 +1515,8 @@ class X {
1515
1515
  * @param {number} [options.limit=100]
1516
1516
  */
1517
1517
  async timeTravel(e, { query: t = null, limit: s = 100 } = {}) {
1518
- let r = `/memory/temporal/at/${e}?limit=${s}`;
1519
- 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);
1520
1520
  }
1521
1521
  /**
1522
1522
  * Get specific item as it existed at timestamp.
@@ -1535,10 +1535,10 @@ class X {
1535
1535
  * @param {string} [options.until]
1536
1536
  * @param {string} [options.changeType]
1537
1537
  */
1538
- async getChanges(e, { since: t = null, until: s = null, changeType: r = null } = {}) {
1539
- 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`;
1540
1540
  const i = [];
1541
- 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);
1542
1542
  }
1543
1543
  // === VERSION COMPARISON ===
1544
1544
  /**
@@ -1559,9 +1559,9 @@ class X {
1559
1559
  * @param {string} [options.toTime]
1560
1560
  */
1561
1561
  async rollback(e, { toVersion: t = null, toTime: s = null } = {}) {
1562
- let r = `/memory/temporal/${e}/rollback`;
1563
- const n = [];
1564
- 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);
1565
1565
  }
1566
1566
  // === AUDIT TRAIL ===
1567
1567
  /**
@@ -1573,10 +1573,10 @@ class X {
1573
1573
  * @param {string} [options.startTime]
1574
1574
  * @param {string} [options.endTime]
1575
1575
  */
1576
- 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 } = {}) {
1577
1577
  let i = `/memory/temporal/${e}/audit`;
1578
- const o = [];
1579
- 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);
1580
1580
  }
1581
1581
  // === TEMPORAL SEARCH ===
1582
1582
  /**
@@ -1586,14 +1586,14 @@ class X {
1586
1586
  * @param {string} endTime
1587
1587
  * @param {number} [limit=100]
1588
1588
  */
1589
- async searchDuringRange(e, t, s, r = 100) {
1590
- const n = new URLSearchParams({
1589
+ async searchDuringRange(e, t, s, n = 100) {
1590
+ const r = new URLSearchParams({
1591
1591
  query: e,
1592
1592
  start_time: t,
1593
1593
  end_time: s,
1594
- limit: String(r)
1594
+ limit: String(n)
1595
1595
  }).toString();
1596
- return this.api.get(`/memory/temporal/search/during?${n}`);
1596
+ return this.api.get(`/memory/temporal/search/during?${r}`);
1597
1597
  }
1598
1598
  // === COMPLIANCE REPORTING ===
1599
1599
  /**
@@ -1604,12 +1604,12 @@ class X {
1604
1604
  * @param {string} [options.reportType='HIPAA']
1605
1605
  * @param {string[]} [options.itemIds]
1606
1606
  */
1607
- async complianceReport(e, t, { reportType: s = "HIPAA", itemIds: r = null } = {}) {
1608
- let n = `/memory/temporal/compliance/report?start_date=${e}&end_date=${t}&report_type=${s}`;
1609
- if (r && r.length)
1610
- for (const i of r)
1611
- n += `&item_ids=${encodeURIComponent(i)}`;
1612
- 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);
1613
1613
  }
1614
1614
  // === TEMPORAL RELATIONSHIPS ===
1615
1615
  /**
@@ -1635,7 +1635,7 @@ class X {
1635
1635
  return this.api.get(`/memory/temporal/relationships/${e}/valid-periods`);
1636
1636
  }
1637
1637
  }
1638
- class Z {
1638
+ class Q {
1639
1639
  constructor(e) {
1640
1640
  this.api = e;
1641
1641
  }
@@ -1662,8 +1662,8 @@ class Z {
1662
1662
  async listViolations({ severity: e = null, autoFixableOnly: t = !1 } = {}) {
1663
1663
  const s = [];
1664
1664
  e && s.push(`severity=${e}`), t && s.push("auto_fixable_only=true");
1665
- const r = s.length ? `?${s.join("&")}` : "";
1666
- return this.api.get(`/memory/governance/violations${r}`);
1665
+ const n = s.length ? `?${s.join("&")}` : "";
1666
+ return this.api.get(`/memory/governance/violations${n}`);
1667
1667
  }
1668
1668
  /**
1669
1669
  * Get a specific violation by ID.
@@ -1680,12 +1680,12 @@ class Z {
1680
1680
  * @param {string} [params.rationale='']
1681
1681
  * @param {string} [params.decidedBy='human']
1682
1682
  */
1683
- 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" }) {
1684
1684
  return this.api.post("/memory/governance/apply-decision", {
1685
1685
  violation_id: e,
1686
1686
  action: t,
1687
1687
  rationale: s,
1688
- decided_by: r
1688
+ decided_by: n
1689
1689
  });
1690
1690
  }
1691
1691
  /**
@@ -1704,7 +1704,7 @@ class Z {
1704
1704
  return this.api.get("/memory/governance/summary");
1705
1705
  }
1706
1706
  }
1707
- class Q {
1707
+ class ee {
1708
1708
  constructor(e) {
1709
1709
  this.api = e;
1710
1710
  }
@@ -1745,7 +1745,7 @@ class Q {
1745
1745
  return this.api.post("/memory/evolution/reinforce/opinions");
1746
1746
  }
1747
1747
  }
1748
- class ee {
1748
+ class te {
1749
1749
  constructor(e) {
1750
1750
  this.api = e;
1751
1751
  }
@@ -1774,13 +1774,13 @@ class ee {
1774
1774
  * @param {boolean} [params.useWikipedia=true]
1775
1775
  * @param {boolean} [params.useLlm=true]
1776
1776
  */
1777
- 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 }) {
1778
1778
  return this.api.post("/memory/reasoning/resolve", {
1779
1779
  existing_item_id: e,
1780
1780
  new_fact: t,
1781
1781
  auto_resolve: s,
1782
- strategy: r,
1783
- use_wikipedia: n,
1782
+ strategy: n,
1783
+ use_wikipedia: r,
1784
1784
  use_llm: i
1785
1785
  });
1786
1786
  }
@@ -1843,7 +1843,7 @@ class ee {
1843
1843
  });
1844
1844
  }
1845
1845
  }
1846
- class te {
1846
+ class se {
1847
1847
  constructor(e) {
1848
1848
  this.api = e;
1849
1849
  }
@@ -1855,12 +1855,12 @@ class te {
1855
1855
  * @param {number} [params.minQualityScore=0.4]
1856
1856
  * @param {boolean} [params.useLlmDetection=true]
1857
1857
  */
1858
- 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 }) {
1859
1859
  return this.api.post("/memory/reasoning/traces/extract", {
1860
1860
  content: e,
1861
1861
  min_steps: t,
1862
1862
  min_quality_score: s,
1863
- use_llm_detection: r
1863
+ use_llm_detection: n
1864
1864
  });
1865
1865
  }
1866
1866
  /**
@@ -1897,7 +1897,7 @@ class te {
1897
1897
  return this.api.get(`/memory/reasoning/traces/${e}`);
1898
1898
  }
1899
1899
  }
1900
- class se {
1900
+ class ne {
1901
1901
  constructor(e) {
1902
1902
  this.api = e;
1903
1903
  }
@@ -1912,7 +1912,7 @@ class se {
1912
1912
  async runInference({ registryId: e = "default", rawChunks: t, params: s = {} }) {
1913
1913
  return this.api.post("/memory/ontology/inference/run", {
1914
1914
  registry_id: e,
1915
- 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 })),
1916
1916
  params: s
1917
1917
  });
1918
1918
  }
@@ -1954,11 +1954,11 @@ class se {
1954
1954
  * @param {Object} params.changeset - OntologyIR changeset
1955
1955
  * @param {string} [params.message='']
1956
1956
  */
1957
- async applyChangeset(e, { baseVersion: t = "", changeset: s, message: r = "" }) {
1957
+ async applyChangeset(e, { baseVersion: t = "", changeset: s, message: n = "" }) {
1958
1958
  return this.api.post(`/memory/ontology/registry/${e}/apply`, {
1959
1959
  base_version: t,
1960
1960
  changeset: s,
1961
- message: r
1961
+ message: n
1962
1962
  });
1963
1963
  }
1964
1964
  /**
@@ -2107,12 +2107,12 @@ class se {
2107
2107
  * @param {number} [params.confidence=0.9]
2108
2108
  * @param {boolean} [params.isGlobal=false]
2109
2109
  */
2110
- 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 }) {
2111
2111
  return this.api.post("/memory/ontology/patterns", {
2112
2112
  name: e,
2113
2113
  entity_type: t,
2114
2114
  confidence: s,
2115
- is_global: r
2115
+ is_global: n
2116
2116
  });
2117
2117
  }
2118
2118
  /**
@@ -2273,8 +2273,8 @@ class se {
2273
2273
  * @param {number} [options.limit=50]
2274
2274
  */
2275
2275
  async listHitl({ status: e = "open", kind: t = null, limit: s = 50 } = {}) {
2276
- const r = new URLSearchParams({ status: e, limit: String(s) });
2277
- 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()}`);
2278
2278
  }
2279
2279
  /**
2280
2280
  * Resolve one ontology HITL queue item (open -> resolved).
@@ -2294,14 +2294,113 @@ class se {
2294
2294
  * @param {string} [options.layer] public|domain|private
2295
2295
  * @param {string} [options.packId] filter by originating pack id
2296
2296
  * @param {boolean} [options.hasIri] only types with (or without) an IRI
2297
+ * @param {string} [options.kind] entity | record (CORE-MEMTYPE-DECLARE-1)
2297
2298
  * @param {number} [options.limit=100]
2298
2299
  * @param {string} [options.cursor] opaque keyset continuation token
2299
2300
  */
2300
- async listTypes({ tier: e, layer: t, packId: s, hasIri: r, limit: n = 100, cursor: i } = {}) {
2301
- const o = { limit: String(n) };
2302
- 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);
2303
- const c = new URLSearchParams(o).toString();
2304
- 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);
2305
2404
  }
2306
2405
  /**
2307
2406
  * List ontology relation types, keyset-paginated. Mirror of `listTypes`.
@@ -2313,11 +2412,11 @@ class se {
2313
2412
  * @param {number} [options.limit=100]
2314
2413
  * @param {string} [options.cursor] opaque keyset continuation token
2315
2414
  */
2316
- async listRelations({ tier: e, layer: t, packId: s, hasIri: r, limit: n = 100, cursor: i } = {}) {
2317
- const o = { limit: String(n) };
2318
- 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);
2319
- const c = new URLSearchParams(o).toString();
2320
- 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 : ""}`);
2321
2420
  }
2322
2421
  /**
2323
2422
  * Resolve a single ontology type by iri/qid/name.
@@ -2342,11 +2441,11 @@ class se {
2342
2441
  * @param {string} [options.until] full ISO-8601 upper bound (inclusive)
2343
2442
  * @param {number} [options.limit=200]
2344
2443
  */
2345
- async listAudit({ actor: e, action: t, since: s, until: r, limit: n = 200 } = {}) {
2346
- const i = { limit: String(n) };
2347
- e !== void 0 && (i.actor = e), t !== void 0 && (i.action = t), s !== void 0 && (i.since = s), r !== void 0 && (i.until = r);
2348
- const o = new URLSearchParams(i).toString();
2349
- 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 : ""}`);
2350
2449
  }
2351
2450
  /**
2352
2451
  * Full append-only audit trail for one ontology type (oldest-first).
@@ -2371,8 +2470,8 @@ class se {
2371
2470
  async getPackAudit(e, { packVersion: t = null } = {}) {
2372
2471
  const s = {};
2373
2472
  t !== null && (s.pack_version = t);
2374
- const r = new URLSearchParams(s).toString();
2375
- 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 : ""}`);
2376
2475
  }
2377
2476
  /**
2378
2477
  * Reclassify every instance of `fromId` onto `toId`. Both types stay live.
@@ -2381,13 +2480,34 @@ class se {
2381
2480
  * @param {Object} params
2382
2481
  * @param {string} params.reason why the migration is being performed (audit evidence)
2383
2482
  * @param {number} [params.batchSize=500] instance edges rewritten per chunk
2384
- */
2385
- async migrateTypeInstances(e, t, { reason: s, batchSize: r = 500 }) {
2386
- 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(
2387
2494
  `/memory/ontology/types/${encodeURIComponent(e)}/migrate-to/${encodeURIComponent(t)}`,
2388
- { reason: s, batch_size: r }
2495
+ i
2389
2496
  );
2390
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
+ }
2391
2511
  // --- ONTO-HITL-CURATE-1 curation queue surface ---------------------------
2392
2512
  /**
2393
2513
  * List ontology review queue items, keyset-paginated.
@@ -2398,11 +2518,11 @@ class se {
2398
2518
  * @param {number} [options.limit=100]
2399
2519
  * @param {string} [options.cursor] opaque keyset continuation token
2400
2520
  */
2401
- async listReviewQueue({ tier: e, assignee: t, source: s, limit: r = 100, cursor: n } = {}) {
2402
- const i = { limit: String(r) };
2403
- e !== void 0 && (i.tier = e), t !== void 0 && (i.assignee = t), s !== void 0 && (i.source = s), n !== void 0 && (i.cursor = n);
2404
- const o = new URLSearchParams(i).toString();
2405
- 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 : ""}`);
2406
2526
  }
2407
2527
  /**
2408
2528
  * Approve one ontology review type.
@@ -2432,8 +2552,8 @@ class se {
2432
2552
  * @param {string} [options.expectedTier] optional optimistic tier precondition
2433
2553
  */
2434
2554
  async mergeReviewType(e, t, { expectedTier: s } = {}) {
2435
- const r = { into_id: t };
2436
- 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);
2437
2557
  }
2438
2558
  /**
2439
2559
  * Edit and promote one ontology review type.
@@ -2443,8 +2563,8 @@ class se {
2443
2563
  * @param {string} [options.expectedTier] optional optimistic tier precondition
2444
2564
  */
2445
2565
  async editPromoteReviewType(e, t, { expectedTier: s } = {}) {
2446
- const r = { edits: t };
2447
- 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);
2448
2568
  }
2449
2569
  /**
2450
2570
  * Assign or clear the reviewer for one ontology review type.
@@ -2462,9 +2582,9 @@ class se {
2462
2582
  * @param {Object} [options.params] action-specific params
2463
2583
  * @param {string} [options.expectedTier] optional optimistic tier precondition
2464
2584
  */
2465
- async bulkReviewAction(e, t, { params: s, expectedTier: r } = {}) {
2466
- const n = { action: e, ids: t, params: s === void 0 ? {} : s };
2467
- 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);
2468
2588
  }
2469
2589
  }
2470
2590
  class re {
@@ -2492,11 +2612,11 @@ class re {
2492
2612
  * @param {boolean} [options.topicAnalysis]
2493
2613
  */
2494
2614
  async detectBias({ protectedAttributes: e = null, sentimentAnalysis: t = null, topicAnalysis: s = null } = {}) {
2495
- const r = {};
2496
- return e !== null && (r.protected_attributes = e), t !== null && (r.sentiment_analysis = t), s !== null && (r.topic_analysis = s), this.api.post("/memory/analytics/bias", r);
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);
2497
2617
  }
2498
2618
  }
2499
- class ne {
2619
+ class ie {
2500
2620
  constructor(e) {
2501
2621
  this.api = e;
2502
2622
  }
@@ -2532,7 +2652,7 @@ class ne {
2532
2652
  return this.api.get("/memory/inference/rules");
2533
2653
  }
2534
2654
  }
2535
- class ie {
2655
+ class ae {
2536
2656
  constructor(e) {
2537
2657
  this.api = e;
2538
2658
  }
@@ -2633,11 +2753,11 @@ class ie {
2633
2753
  * @param {string} [params.description='']
2634
2754
  * @param {Object} [params.config={}]
2635
2755
  */
2636
- async updateConfig(e, { name: t = "", description: s = "", config: r = {} }) {
2756
+ async updateConfig(e, { name: t = "", description: s = "", config: n = {} }) {
2637
2757
  return this.api.patch(`/memory/pipeline/configs/${e}`, {
2638
2758
  name: t,
2639
2759
  description: s,
2640
- config: r
2760
+ config: n
2641
2761
  });
2642
2762
  }
2643
2763
  /**
@@ -2648,7 +2768,7 @@ class ie {
2648
2768
  return this.api.delete(`/memory/pipeline/configs/${e}`);
2649
2769
  }
2650
2770
  }
2651
- class ae {
2771
+ class oe {
2652
2772
  constructor(e) {
2653
2773
  this.api = e;
2654
2774
  }
@@ -2674,7 +2794,7 @@ class ae {
2674
2794
  return this.api.get(`/memory/archive/${e}`);
2675
2795
  }
2676
2796
  }
2677
- class oe {
2797
+ class ce {
2678
2798
  constructor(e) {
2679
2799
  this.api = e;
2680
2800
  }
@@ -2833,7 +2953,7 @@ class oe {
2833
2953
  return this.api.get(`/memory/zettel/by-relation/${e}/${t}?limit=${s}`);
2834
2954
  }
2835
2955
  }
2836
- class ce {
2956
+ class ue {
2837
2957
  constructor(e) {
2838
2958
  this.api = e;
2839
2959
  }
@@ -2848,7 +2968,7 @@ class ce {
2848
2968
  */
2849
2969
  async list(e = {}) {
2850
2970
  const t = Object.fromEntries(
2851
- Object.entries(e).filter(([, r]) => r != null)
2971
+ Object.entries(e).filter(([, n]) => n != null)
2852
2972
  ), s = new URLSearchParams(t).toString();
2853
2973
  return this.api.get(`/memory/procedures/matches${s ? "?" + s : ""}`);
2854
2974
  }
@@ -2859,8 +2979,8 @@ class ce {
2859
2979
  * @param {string} [note] - Optional explanation
2860
2980
  */
2861
2981
  async submitFeedback(e, t, s = null) {
2862
- const r = { feedback: t };
2863
- 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);
2864
2984
  }
2865
2985
  /**
2866
2986
  * Get aggregated procedure match statistics.
@@ -2869,7 +2989,7 @@ class ce {
2869
2989
  return this.api.get("/memory/procedures/matches/stats");
2870
2990
  }
2871
2991
  }
2872
- class ue {
2992
+ class le {
2873
2993
  constructor(e) {
2874
2994
  this.api = e;
2875
2995
  }
@@ -2884,7 +3004,7 @@ class ue {
2884
3004
  */
2885
3005
  async list(e = {}) {
2886
3006
  const t = Object.fromEntries(
2887
- Object.entries(e).filter(([, r]) => r != null)
3007
+ Object.entries(e).filter(([, n]) => n != null)
2888
3008
  ), s = new URLSearchParams(t).toString();
2889
3009
  return this.api.get(`/memory/procedures/candidates${s ? "?" + s : ""}`);
2890
3010
  }
@@ -2918,7 +3038,7 @@ class ue {
2918
3038
  return this.api.delete(`/memory/procedures/candidates/${e}/dismiss`);
2919
3039
  }
2920
3040
  }
2921
- class le {
3041
+ class me {
2922
3042
  constructor(e) {
2923
3043
  this.api = e;
2924
3044
  }
@@ -2935,7 +3055,7 @@ class le {
2935
3055
  */
2936
3056
  async list(e = {}) {
2937
3057
  const t = Object.fromEntries(
2938
- Object.entries(e).filter(([, r]) => r != null)
3058
+ Object.entries(e).filter(([, n]) => n != null)
2939
3059
  ), s = new URLSearchParams(t).toString();
2940
3060
  return this.api.get(`/memory/procedures/drift${s ? "?" + s : ""}`);
2941
3061
  }
@@ -2973,7 +3093,7 @@ class le {
2973
3093
  return this.api.get(`/memory/procedures/schemas/${e}`);
2974
3094
  }
2975
3095
  }
2976
- class me {
3096
+ class he {
2977
3097
  constructor(e) {
2978
3098
  this.api = e;
2979
3099
  }
@@ -3025,8 +3145,8 @@ class me {
3025
3145
  * @param {string} [params.before] ISO 8601 datetime
3026
3146
  */
3027
3147
  async list({ isHeartbeat: e = null, limit: t = 20, before: s = null } = {}) {
3028
- const r = { limit: t };
3029
- 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);
3030
3150
  }
3031
3151
  /** SnapshotDelta between two snapshots. Returns null on 404. */
3032
3152
  async delta({ from: e, to: t }) {
@@ -3045,7 +3165,7 @@ class me {
3045
3165
  return this.api.delete(`/memory/summary/${e}`);
3046
3166
  }
3047
3167
  }
3048
- class he {
3168
+ class ye {
3049
3169
  constructor(e) {
3050
3170
  this.api = e;
3051
3171
  }
@@ -3057,13 +3177,13 @@ class he {
3057
3177
  * @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
3058
3178
  */
3059
3179
  async acquire(e, { ttlSeconds: t } = {}) {
3060
- var r, n;
3180
+ var n, r;
3061
3181
  const s = {};
3062
3182
  t !== void 0 && (s.ttl_seconds = t);
3063
3183
  try {
3064
3184
  return await this.api.post(`/memory/locks/${e}`, s);
3065
3185
  } catch (i) {
3066
- if ((i == null ? void 0 : i.status) === 409 && ((n = (r = i.detail) == null ? void 0 : r.detail) == null ? void 0 : n.reason) === "lock_held")
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")
3067
3187
  return null;
3068
3188
  throw i;
3069
3189
  }
@@ -3077,17 +3197,17 @@ class he {
3077
3197
  * @returns {Promise<{key: string, token: string, expires_at: string, ttl_remaining_ms: number}|null>}
3078
3198
  */
3079
3199
  async renew(e, t, { ttlSeconds: s } = {}) {
3080
- var n, i;
3081
- const r = {};
3082
- s !== void 0 && (r.ttl_seconds = s);
3200
+ var r, i;
3201
+ const n = {};
3202
+ s !== void 0 && (n.ttl_seconds = s);
3083
3203
  try {
3084
- return await this.api.post(`/memory/locks/${e}/renew`, r, {
3204
+ return await this.api.post(`/memory/locks/${e}/renew`, n, {
3085
3205
  headers: { "X-Lease-Token": t }
3086
3206
  });
3087
- } catch (o) {
3088
- if ((o == null ? void 0 : o.status) === 409 && ((i = (n = o.detail) == null ? void 0 : n.detail) == null ? void 0 : i.reason) === "not_owner")
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")
3089
3209
  return null;
3090
- throw o;
3210
+ throw c;
3091
3211
  }
3092
3212
  }
3093
3213
  /**
@@ -3097,19 +3217,19 @@ class he {
3097
3217
  * @returns {Promise<boolean>}
3098
3218
  */
3099
3219
  async release(e, t) {
3100
- var s, r;
3220
+ var s, n;
3101
3221
  try {
3102
3222
  return await this.api.delete(`/memory/locks/${e}`, {
3103
3223
  headers: { "X-Lease-Token": t }
3104
3224
  }), !0;
3105
- } catch (n) {
3106
- if ((n == null ? void 0 : n.status) === 409 && ((r = (s = n.detail) == null ? void 0 : s.detail) == null ? void 0 : r.reason) === "not_owner")
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")
3107
3227
  return !1;
3108
- throw n;
3228
+ throw r;
3109
3229
  }
3110
3230
  }
3111
3231
  }
3112
- class ye {
3232
+ class pe {
3113
3233
  constructor(e) {
3114
3234
  this.api = e;
3115
3235
  }
@@ -3131,8 +3251,8 @@ class ye {
3131
3251
  * @returns {Promise<{name: string, value: number, first: number, count: number}>}
3132
3252
  */
3133
3253
  async allocate(e, { floor: t, count: s } = {}) {
3134
- const r = {};
3135
- return t !== void 0 && (r.floor = t), s !== void 0 && (r.count = s), this.api.post(`/memory/sequences/${e}/next`, r);
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);
3136
3256
  }
3137
3257
  /**
3138
3258
  * Read the counter without consuming a number, or null if never allocated.
@@ -3153,11 +3273,11 @@ class ye {
3153
3273
  }
3154
3274
  }
3155
3275
  }
3156
- class de {
3276
+ class ge {
3157
3277
  constructor(e) {
3158
- this.auth = new x(e);
3278
+ this.auth = new F(e);
3159
3279
  const t = new O(this.auth, { fetchFn: e.fetchFn });
3160
- this._api = t, this.memories = new F(t), this.decisions = new j(t), this.opinions = new H(t), this.graph = new B(t), this.teams = new K(t), this.profiles = new G(t), this.subscriptions = new N(t), this.authAPI = new D(t), this.agents = new J(t), this.usage = new W(t), this.insights = new V(t), this.tokenUsage = new Y(t), this.temporal = new X(t), this.governance = new Z(t), this.evolution = new Q(t), this.reasoning = new ee(t), this.reasoningTraces = new te(t), this.ontology = new se(t), this.analytics = new re(t), this.validation = new ne(t), this.pipeline = new ie(t), this.archive = new ae(t), this.zettelkasten = new oe(t), this.procedureMatches = new ce(t), this.procedureCandidates = new ue(t), this.procedureDrift = new le(t), this.summaries = new me(t), this.locks = new he(t), this.sequences = new ye(t);
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);
3161
3281
  }
3162
3282
  setTeamId(e) {
3163
3283
  this.auth.tokenManager.setTeamId(e), this.auth.notifyListeners();
@@ -3183,38 +3303,38 @@ class de {
3183
3303
  }
3184
3304
  }
3185
3305
  export {
3186
- h as A,
3306
+ k as A,
3187
3307
  O as B,
3188
- j as D,
3189
- Q as E,
3190
- Z as G,
3191
- V as I,
3192
- he as L,
3193
- F as M,
3194
- se as O,
3195
- ie as P,
3196
- ee as R,
3197
- ye as S,
3198
- K as T,
3199
- W as U,
3200
- ne as V,
3201
- oe as Z,
3202
- J as a,
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,
3203
3323
  re as b,
3204
- ae as c,
3205
- D as d,
3206
- x as e,
3207
- B as f,
3208
- H as g,
3209
- ue as h,
3210
- ce as i,
3211
- G as j,
3212
- te as k,
3213
- de as l,
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,
3214
3334
  N as m,
3215
- X as n,
3216
- M as o,
3217
- Y as p,
3218
- z as q,
3219
- E as r
3335
+ Z as n,
3336
+ z as o,
3337
+ X as p,
3338
+ E as q,
3339
+ x as r
3220
3340
  };