@mastra/server 1.58.0-alpha.7 → 1.58.0-alpha.8

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.
@@ -5962,7 +5962,7 @@ function splitLines(text) {
5962
5962
  return result;
5963
5963
  }
5964
5964
  //#endregion
5965
- //#region ../memory/dist/src-MScpLVRh.js
5965
+ //#region ../memory/dist/src-hv0DMVM-.js
5966
5966
  var __defProp$3 = Object.defineProperty;
5967
5967
  var __exportAll = (all, no_symbols) => {
5968
5968
  let target = {};
@@ -21488,6 +21488,16 @@ function sanitizeToolResultValue(value, seen = /* @__PURE__ */ new WeakMap()) {
21488
21488
  }
21489
21489
  return sanitizedObject;
21490
21490
  }
21491
+ /**
21492
+ * Serializes a tool result without truncating it.
21493
+ *
21494
+ * Token accounting must see the full result: the truncation applied by
21495
+ * {@link formatToolResultForObserver} exists to bound what the Observer LLM reads,
21496
+ * not to describe what the agent's provider context actually holds.
21497
+ */
21498
+ function serializeToolResultForTokenCounting(value) {
21499
+ return stringifyToolResult(value);
21500
+ }
21491
21501
  function stringifyToolResult(value) {
21492
21502
  if (typeof value === "string") return value;
21493
21503
  const sanitized = sanitizeToolResultValue(value);
@@ -24081,7 +24091,7 @@ var TokenCounter = class TokenCounter {
24081
24091
  let tokens = 0;
24082
24092
  const cacheParts = [];
24083
24093
  const countJsonContentPart = (contentPart) => {
24084
- const formatted = formatToolResultForObserver(contentPart);
24094
+ const formatted = serializeToolResultForTokenCounting(contentPart);
24085
24095
  tokens += this.countString(formatted);
24086
24096
  cacheParts.push({
24087
24097
  type: "json",
@@ -24444,7 +24454,7 @@ var TokenCounter = class TokenCounter {
24444
24454
  const contentTokens = this.countMultimodalToolResultContent(part, resultForCounting);
24445
24455
  if (contentTokens !== void 0) tokens += contentTokens;
24446
24456
  else {
24447
- const formattedResult = formatToolResultForObserver(resultForCounting);
24457
+ const formattedResult = serializeToolResultForTokenCounting(resultForCounting);
24448
24458
  tokens += this.readOrPersistPartEstimate(part, usingStoredModelOutput ? "tool-result-model-output-json" : "tool-result-json", formattedResult);
24449
24459
  }
24450
24460
  if (typeof resultForCounting !== "string") overheadDelta -= 12;
@@ -27201,7 +27211,7 @@ var SyncObservationStrategy = class extends ObservationStrategy {
27201
27211
  });
27202
27212
  await this.storage.updateThread({
27203
27213
  id: threadId,
27204
- title: shouldUpdateThreadTitle ? newTitle : thread.title ?? "",
27214
+ ...shouldUpdateThreadTitle ? { title: newTitle } : {},
27205
27215
  metadata: newMetadata
27206
27216
  });
27207
27217
  if (shouldUpdateThreadTitle) threadUpdateMarker = createThreadUpdateMarker({
@@ -27391,7 +27401,7 @@ var AsyncBufferObservationStrategy = class extends ObservationStrategy {
27391
27401
  });
27392
27402
  await this.storage.updateThread({
27393
27403
  id: threadId,
27394
- title: shouldUpdateThreadTitle ? newTitle : thread.title ?? "",
27404
+ ...shouldUpdateThreadTitle ? { title: newTitle } : {},
27395
27405
  metadata: newMetadata
27396
27406
  });
27397
27407
  if (shouldUpdateThreadTitle) {
@@ -27734,7 +27744,7 @@ var ResourceScopedObservationStrategy = class extends ObservationStrategy {
27734
27744
  });
27735
27745
  await this.storage.updateThread({
27736
27746
  id: update.threadId,
27737
- title: shouldUpdateThreadTitle ? newTitle : thread.title ?? "",
27747
+ ...shouldUpdateThreadTitle ? { title: newTitle } : {},
27738
27748
  metadata: newMetadata
27739
27749
  });
27740
27750
  if (shouldUpdateThreadTitle) threadUpdateMarkers.push(createThreadUpdateMarker({
@@ -28665,7 +28675,6 @@ async function persistThreadExtractedValues(storage, extractors, threadId, value
28665
28675
  });
28666
28676
  await storage.updateThread({
28667
28677
  id: threadId,
28668
- title: thread.title ?? "",
28669
28678
  metadata: newMetadata
28670
28679
  });
28671
28680
  }
@@ -31633,7 +31642,7 @@ ${formattedMessages}
31633
31642
  const shouldUpdateThreadTitle = !!newTitle && newTitle.length >= 3 && newTitle !== oldTitle;
31634
31643
  await this.storage.updateThread({
31635
31644
  id: threadId,
31636
- title: shouldUpdateThreadTitle ? newTitle : thread.title ?? "",
31645
+ ...shouldUpdateThreadTitle ? { title: newTitle } : {},
31637
31646
  metadata: newMetadata
31638
31647
  });
31639
31648
  }
@@ -31851,7 +31860,6 @@ ${formattedMessages}
31851
31860
  });
31852
31861
  await this.storage.updateThread({
31853
31862
  id: threadId,
31854
- title: thread.title ?? "",
31855
31863
  metadata: newMetadata
31856
31864
  });
31857
31865
  }
@@ -32970,7 +32978,6 @@ var Memory = class extends _mastra_core_memory.MastraMemory {
32970
32978
  if (!thread) throw new Error(`Thread ${threadId} not found`);
32971
32979
  await memoryStore.updateThread({
32972
32980
  id: threadId,
32973
- title: thread.title || "",
32974
32981
  metadata: {
32975
32982
  ...thread.metadata,
32976
32983
  workingMemory
@@ -33059,7 +33066,6 @@ ${workingMemory}`;
33059
33066
  if (!thread) throw new Error(`Thread ${threadId} not found`);
33060
33067
  await memoryStore.updateThread({
33061
33068
  id: threadId,
33062
- title: thread.title || "",
33063
33069
  metadata: {
33064
33070
  ...thread.metadata,
33065
33071
  workingMemory
@@ -44778,4 +44784,4 @@ const agentBuilderWorkflows = {
44778
44784
  //#endregion
44779
44785
  exports.agentBuilderWorkflows = agentBuilderWorkflows;
44780
44786
 
44781
- //# sourceMappingURL=dist-fvOsjRn_.cjs.map
44787
+ //# sourceMappingURL=dist-DhqgxyoU.cjs.map