@mastra/memory 1.41.0-alpha.0 → 1.41.0-alpha.1

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.
@@ -26449,6 +26449,24 @@ function formatObserverToolArguments(args, maxCharacters) {
26449
26449
  if (args === void 0) return maybeTruncate("[arguments unavailable]", maxCharacters);
26450
26450
  return formatToolArgumentsForObserver(args, { maxCharacters: maxCharacters || void 0 });
26451
26451
  }
26452
+ const OBSERVER_SIGNAL_ATTRIBUTE_NAME = /^[A-Za-z_][A-Za-z0-9_.-]*$/;
26453
+ const OBSERVER_SIGNAL_ATTRIBUTE_MAX_COUNT = 8;
26454
+ const OBSERVER_SIGNAL_ATTRIBUTE_MAX_VALUE_LENGTH = 80;
26455
+ /**
26456
+ * Renders a user signal's attributes (e.g. `name`, `role`) as ` (name="Jim" role="editor")` so
26457
+ * the Observer can tell speakers apart in a shared thread. Attribute data is caller-supplied,
26458
+ * so names must be plain identifiers, values are length-capped and JSON-quoted (no raw quotes
26459
+ * or line breaks), and only the first few attributes are kept to bound the label.
26460
+ */
26461
+ function formatObserverSignalAttributes(attributes) {
26462
+ if (!isRecord$1(attributes)) return "";
26463
+ const rendered = Object.entries(attributes).filter((entry) => OBSERVER_SIGNAL_ATTRIBUTE_NAME.test(entry[0]) && (typeof entry[1] === "string" || typeof entry[1] === "number" || typeof entry[1] === "boolean")).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).slice(0, OBSERVER_SIGNAL_ATTRIBUTE_MAX_COUNT).map(([key, value]) => {
26464
+ const text = String(value);
26465
+ const clipped = text.length > OBSERVER_SIGNAL_ATTRIBUTE_MAX_VALUE_LENGTH ? `${text.slice(0, OBSERVER_SIGNAL_ATTRIBUTE_MAX_VALUE_LENGTH)}...` : text;
26466
+ return `${key}=${JSON.stringify(clipped)}`;
26467
+ });
26468
+ return rendered.length > 0 ? ` (${rendered.join(" ")})` : "";
26469
+ }
26452
26470
  /**
26453
26471
  * Labels signals and system reminders by their tag instead of as "User", so the Observer
26454
26472
  * does not record runtime instructions as things the user said (#22195).
@@ -26456,7 +26474,7 @@ function formatObserverToolArguments(args, maxCharacters) {
26456
26474
  function getObserverMessageLabel(msg) {
26457
26475
  if (msg.role === "signal") {
26458
26476
  const signal = msg.content?.metadata?.signal;
26459
- return signal?.type === "user" ? "User" : signal?.tagName ?? signal?.type ?? "Signal";
26477
+ return signal?.type === "user" ? `User${formatObserverSignalAttributes(signal.attributes)}` : signal?.tagName ?? signal?.type ?? "Signal";
26460
26478
  }
26461
26479
  if (isSystemReminderMessage(msg)) return "system-reminder";
26462
26480
  return msg.role.charAt(0).toUpperCase() + msg.role.slice(1);
@@ -42707,4 +42725,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
42707
42725
  }
42708
42726
  });
42709
42727
 
42710
- //# sourceMappingURL=src-C83MwpMb.cjs.map
42728
+ //# sourceMappingURL=src-GDwZ0vzw.cjs.map