@axiom-lattice/core 4.2.12 → 4.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1971,6 +1971,12 @@ var InMemoryMcpServerConfigStore = class {
1971
1971
 
1972
1972
  // src/store_lattice/InMemoryAgentWebAppStore.ts
1973
1973
  import { randomUUID } from "crypto";
1974
+ function cloneAppearance(appearance) {
1975
+ return {
1976
+ ...appearance,
1977
+ ...appearance.quickPrompts ? { quickPrompts: appearance.quickPrompts.map((prompt) => ({ ...prompt })) } : {}
1978
+ };
1979
+ }
1974
1980
  function cloneWebApp(webApp) {
1975
1981
  return {
1976
1982
  ...webApp,
@@ -1981,7 +1987,7 @@ function cloneWebApp(webApp) {
1981
1987
  allowedModelKeys: webApp.scope.allowedModelKeys ? [...webApp.scope.allowedModelKeys] : void 0
1982
1988
  },
1983
1989
  features: { ...webApp.features },
1984
- appearance: { ...webApp.appearance },
1990
+ appearance: cloneAppearance(webApp.appearance),
1985
1991
  identity: webApp.identity ? { policy: webApp.identity.policy, issuers: webApp.identity.issuers.map((issuer) => ({ ...issuer })) } : void 0,
1986
1992
  createdAt: new Date(webApp.createdAt),
1987
1993
  updatedAt: new Date(webApp.updatedAt)
@@ -2027,7 +2033,7 @@ var InMemoryAgentWebAppStore = class {
2027
2033
  allowedModelKeys: input.scope.allowedModelKeys ? [...input.scope.allowedModelKeys] : void 0
2028
2034
  },
2029
2035
  features: { ...input.features },
2030
- appearance: { ...input.appearance },
2036
+ appearance: cloneAppearance(input.appearance),
2031
2037
  identity: input.identity ? { policy: input.identity.policy, issuers: input.identity.issuers.map((issuer) => ({ ...issuer })) } : void 0,
2032
2038
  createdAt: now,
2033
2039
  updatedAt: now
@@ -2059,7 +2065,7 @@ var InMemoryAgentWebAppStore = class {
2059
2065
  }
2060
2066
  } : {},
2061
2067
  ...patch.features ? { features: { ...patch.features } } : {},
2062
- ...patch.appearance ? { appearance: { ...patch.appearance } } : {},
2068
+ ...patch.appearance ? { appearance: cloneAppearance(patch.appearance) } : {},
2063
2069
  ...patch.identity !== void 0 ? { identity: { policy: patch.identity.policy, issuers: patch.identity.issuers.map((issuer) => ({ ...issuer })) } } : {},
2064
2070
  ...patch.status !== void 0 ? { status: patch.status } : {},
2065
2071
  updatedAt: new Date(Math.max(Date.now(), existing.updatedAt.getTime() + 1))
@@ -2285,6 +2291,17 @@ var InMemoryProjectRoomCoordinator = class {
2285
2291
  }
2286
2292
  this.messages.set(JSON.stringify([message.tenantId, message.id]), storedMessage);
2287
2293
  },
2294
+ deleteMessage: (tenantId2, id) => {
2295
+ assertActive();
2296
+ const key5 = JSON.stringify([tenantId2, id]);
2297
+ const message = this.messages.get(key5);
2298
+ if (message === void 0) return false;
2299
+ this.messages.delete(key5);
2300
+ if (message.idempotencyKey !== void 0) {
2301
+ this.messageIdsByIdempotency.delete(JSON.stringify([tenantId2, message.roomId, message.idempotencyKey]));
2302
+ }
2303
+ return true;
2304
+ },
2288
2305
  nextTimestamp: (previousTimestamp) => {
2289
2306
  assertActive();
2290
2307
  const current = this.clock().getTime();
@@ -2690,6 +2707,25 @@ var InMemoryProjectRoomMessageStore = class {
2690
2707
  const horizon = Date.prototype.getTime.call(input.after);
2691
2708
  return this.coordinator.runExclusive((transaction) => transaction.getMessages().filter((message) => message.tenantId === input.tenantId && message.roomId === input.roomId && message.createdAt.getTime() > horizon).filter((message) => input.excludeAuthorUserId === void 0 || !(message.author.type === "human" && message.author.userId === input.excludeAuthorUserId)).length);
2692
2709
  }
2710
+ /**
2711
+ * Deletes one bounded batch of chat messages older than a horizon.
2712
+ *
2713
+ * @param input - Exclusive upper time bound and requested batch size (clamped to 1..1000).
2714
+ * @returns The number of deleted rows.
2715
+ * @remarks Only `source: "user" | "agent"` rows are eligible; task/system events are retained.
2716
+ */
2717
+ async deleteChatOlderThan(input) {
2718
+ if (!validDate(input.before)) {
2719
+ throw new RangeError("Project room message retention horizon date is invalid");
2720
+ }
2721
+ const horizon = Date.prototype.getTime.call(input.before);
2722
+ const limit = Math.min(1e3, Math.max(1, Math.trunc(Number.isFinite(input.limit) ? input.limit : 1)));
2723
+ return this.coordinator.runExclusive((transaction) => {
2724
+ const candidates = transaction.getMessages().filter((message) => (message.source === "user" || message.source === "agent") && message.createdAt.getTime() < horizon).sort((left, right) => left.createdAt.getTime() - right.createdAt.getTime() || left.id.localeCompare(right.id)).slice(0, limit);
2725
+ for (const message of candidates) transaction.deleteMessage(message.tenantId, message.id);
2726
+ return candidates.length;
2727
+ });
2728
+ }
2693
2729
  createInTransaction(transaction, input) {
2694
2730
  if (transaction.getMessage(input.tenantId, input.id) !== void 0) {
2695
2731
  throw new ProjectRoomMessageIdConflictError(input.tenantId, input.id);