@mastra/server 1.59.0-alpha.0 → 1.59.0-alpha.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.59.0-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`898bba4`](https://github.com/mastra-ai/mastra/commit/898bba46d4806dd255a44e5dc3a3d5827eaefdfe), [`f9aab1c`](https://github.com/mastra-ai/mastra/commit/f9aab1cfc3fda03238a7fd7bd8b794e07497878c), [`e31421b`](https://github.com/mastra-ai/mastra/commit/e31421bc9c11c03c6e74f447ecb5820000e2b9d7), [`aece0e7`](https://github.com/mastra-ai/mastra/commit/aece0e7cb124ae1eb1230689b887f5554b9a0bf0)]:
8
+ - @mastra/core@1.59.0-alpha.2
9
+
10
+ ## 1.59.0-alpha.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`aa3e7be`](https://github.com/mastra-ai/mastra/commit/aa3e7be30f8addb0278ea74429f4df054517a287), [`90822db`](https://github.com/mastra-ai/mastra/commit/90822dba08fb2169c518e4a6d7f127c098eb46b8), [`3700208`](https://github.com/mastra-ai/mastra/commit/37002080c7838267803a7e579a7d58b908d62f36), [`8b7131e`](https://github.com/mastra-ai/mastra/commit/8b7131eb0407f58f5205e68fb27b81f026488f28), [`79c4f82`](https://github.com/mastra-ai/mastra/commit/79c4f8295f568752eeadf8a9b50010a7d9ec06ae)]:
15
+ - @mastra/core@1.59.0-alpha.1
16
+
3
17
  ## 1.59.0-alpha.0
4
18
 
5
19
  ### Patch Changes
@@ -4693,7 +4693,7 @@ function splitLines(text) {
4693
4693
  return result;
4694
4694
  }
4695
4695
  //#endregion
4696
- //#region ../memory/dist/src-DGdlH4fo.js
4696
+ //#region ../memory/dist/src-BYD6Wp5m.js
4697
4697
  var __defProp$3 = Object.defineProperty;
4698
4698
  var __exportAll = (all, no_symbols) => {
4699
4699
  let target = {};
@@ -19371,7 +19371,7 @@ By default recall returns **low** detail: truncated text and tool names only. Ea
19371
19371
  - Use \`detail: "high"\` to get full message content including tool arguments and results. This will only return the high detail version of a single message part at a time.
19372
19372
  - Use \`partIndex\` with a cursor to fetch a single part at full detail — for example, to read one specific tool result or code block without loading every part.
19373
19373
 
19374
- If the result says \`truncated: true\`, the output was cut to fit the token budget. You can paginate or use \`partIndex\` to target specific content.
19374
+ If the result says \`truncated: true\`, the output was cut to fit the token budget. You can paginate or use \`partIndex\` to target specific content. If a single part is itself too large, follow the returned \`nextCharOffset\` as described below.
19375
19375
 
19376
19376
  ### Following up on truncated parts
19377
19377
  Low-detail results may include truncation hints like:
@@ -19379,6 +19379,8 @@ Low-detail results may include truncation hints like:
19379
19379
 
19380
19380
  **When you see these hints and need the full content, make the exact call described in the hint.** This is the normal workflow: first recall at low detail to scan, then drill into specific parts at high detail. Do not stop at the low-detail result if the user asked for exact content.
19381
19381
 
19382
+ If a single part is larger than the token budget, the \`partIndex\` result is \`truncated: true\` and includes \`nextCharOffset\`. Repeat the same call with \`charOffset\` set to that exact value to read the next chunk from where the previous one ended. Keep following \`nextCharOffset\` until the result no longer includes it — the chunks together contain the full part. Retrying without \`charOffset\` returns the same prefix again.
19383
+
19382
19384
  ### When recall is NOT needed
19383
19385
  - The user is asking for a high-level summary and your observations already cover it
19384
19386
  - The question is about general preferences or facts that don't require source text
@@ -23707,6 +23709,36 @@ function truncateByTokens(text, maxTokens, hint) {
23707
23709
  wasTruncated: true
23708
23710
  };
23709
23711
  }
23712
+ function chunkTextByTokens(text, maxTokens, charOffset = 0) {
23713
+ let startOffset = Math.max(0, Math.min(Math.floor(charOffset), text.length));
23714
+ const startCode = text.charCodeAt(startOffset);
23715
+ if (startCode >= 56320 && startCode <= 57343) startOffset += 1;
23716
+ const remaining = text.slice(startOffset);
23717
+ if (!remaining || estimateTokenCount(remaining) <= maxTokens) return {
23718
+ text: remaining,
23719
+ charOffset: startOffset,
23720
+ truncated: false
23721
+ };
23722
+ let low = 0;
23723
+ let high = remaining.length;
23724
+ let best = "";
23725
+ while (low <= high) {
23726
+ const mid = Math.floor((low + high) / 2);
23727
+ const candidate = safeSlice(remaining, mid);
23728
+ const candidateTokens = estimateTokenCount(candidate);
23729
+ if (candidate && candidateTokens <= maxTokens) {
23730
+ best = candidate;
23731
+ low = mid + 1;
23732
+ } else high = mid - 1;
23733
+ }
23734
+ const nextCharOffset = startOffset + best.length;
23735
+ return {
23736
+ text: best,
23737
+ charOffset: startOffset,
23738
+ nextCharOffset,
23739
+ truncated: nextCharOffset < text.length
23740
+ };
23741
+ }
23710
23742
  function lowDetailPartLimit(type) {
23711
23743
  if (type === "text") return AUTO_EXPAND_TEXT_TOKENS;
23712
23744
  if (type === "tool-result" || type === "tool-call") return AUTO_EXPAND_TOOL_TOKENS;
@@ -23924,7 +23956,7 @@ function renderFormattedParts(parts, timestamps, options) {
23924
23956
  tokenOffset: expandedTokens - options.maxTokens
23925
23957
  };
23926
23958
  }
23927
- async function recallPart({ memory, threadId, resourceId, cursor, partIndex, threadScope, maxTokens = DEFAULT_MAX_RESULT_TOKENS }) {
23959
+ async function recallPart({ memory, threadId, resourceId, cursor, partIndex, charOffset, threadScope, maxTokens = DEFAULT_MAX_RESULT_TOKENS }) {
23928
23960
  if (!memory || typeof memory.getMemoryStore !== "function") throw new Error("Memory instance is required for recall");
23929
23961
  if (!threadId) throw new Error("Thread ID is required for recall");
23930
23962
  const resolved = await resolveCursorMessage(memory, cursor, {
@@ -23948,31 +23980,36 @@ async function recallPart({ memory, threadId, resourceId, cursor, partIndex, thr
23948
23980
  if (nextMessage) {
23949
23981
  const firstNextPart = formatMessageParts(nextMessage, "high")[0];
23950
23982
  if (firstNextPart) {
23951
- const fallbackText = `${`Part index ${partIndex} not found in message ${cursor}; showing partIndex ${firstNextPart.partIndex} from next message ${firstNextPart.messageId}.\n\n`}${firstNextPart.text}`;
23952
- const truncatedText = truncateStringByTokens(fallbackText, maxTokens);
23953
- const wasTruncated = truncatedText !== fallbackText;
23983
+ const fallbackChunk = chunkTextByTokens(`${`Part index ${partIndex} not found in message ${cursor}; showing partIndex ${firstNextPart.partIndex} from next message ${firstNextPart.messageId}.\n\n`}${firstNextPart.text}`, maxTokens, charOffset);
23984
+ const fallbackContinuation = fallbackChunk.nextCharOffset ? `To continue this part, call recall cursor="${cursor}" partIndex=${partIndex} detail="high" charOffset=${fallbackChunk.nextCharOffset}.` : void 0;
23954
23985
  return {
23955
- text: truncatedText,
23986
+ text: fallbackChunk.text,
23956
23987
  messageId: firstNextPart.messageId,
23957
23988
  partIndex: firstNextPart.partIndex,
23958
23989
  role: firstNextPart.role,
23959
23990
  type: firstNextPart.type,
23960
- truncated: wasTruncated
23991
+ truncated: fallbackChunk.truncated,
23992
+ charOffset: fallbackChunk.charOffset,
23993
+ nextCharOffset: fallbackChunk.nextCharOffset,
23994
+ note: fallbackContinuation
23961
23995
  };
23962
23996
  }
23963
23997
  }
23964
23998
  }
23965
23999
  throw new Error(`Part index ${partIndex} not found in message ${cursor}. Available indices: ${availableIndices}`);
23966
24000
  }
23967
- const truncatedText = truncateStringByTokens(target.text, maxTokens);
23968
- const wasTruncated = truncatedText !== target.text;
24001
+ const chunk = chunkTextByTokens(target.text, maxTokens, charOffset);
24002
+ const note = chunk.nextCharOffset ? `To continue this part, call recall cursor="${target.messageId}" partIndex=${target.partIndex} detail="high" charOffset=${chunk.nextCharOffset}.` : void 0;
23969
24003
  return {
23970
- text: truncatedText,
24004
+ text: chunk.text,
23971
24005
  messageId: target.messageId,
23972
24006
  partIndex: target.partIndex,
23973
24007
  role: target.role,
23974
24008
  type: target.type,
23975
- truncated: wasTruncated
24009
+ truncated: chunk.truncated,
24010
+ charOffset: chunk.charOffset,
24011
+ nextCharOffset: chunk.nextCharOffset,
24012
+ note
23976
24013
  };
23977
24014
  }
23978
24015
  async function recallMessages({ memory, threadId, resourceId, cursor, page = 1, limit = 20, detail = "low", partType, toolName, threadScope, maxTokens = DEFAULT_MAX_RESULT_TOKENS }) {
@@ -24254,11 +24291,16 @@ const recallTool = (_memoryConfig, options) => {
24254
24291
  type: "integer",
24255
24292
  minimum: 0,
24256
24293
  description: "Fetch a single part from the cursor message by its positional index. When provided, returns only that part at high detail. Indices are shown as [p0], [p1], etc. in recall results."
24294
+ },
24295
+ charOffset: {
24296
+ type: "integer",
24297
+ minimum: 0,
24298
+ description: "Continue reading a truncated single part from this position. Pass the exact nextCharOffset value returned by a previous call; do not compute it yourself. Only applies with cursor and partIndex in mode=\"messages\"."
24257
24299
  }
24258
24300
  }
24259
24301
  },
24260
24302
  execute: async (inputData, context) => {
24261
- const { mode, query, cursor, threadId: explicitThreadId, anchor, page, limit, detail, partType, toolName, partIndex, before, after } = inputData;
24303
+ const { mode, query, cursor, threadId: explicitThreadId, anchor, page, limit, detail, partType, toolName, partIndex, charOffset, before, after } = inputData;
24262
24304
  const memory = context?.memory;
24263
24305
  const currentThreadId = context?.agent?.threadId;
24264
24306
  const resourceId = context?.agent?.resourceId;
@@ -24371,6 +24413,7 @@ const recallTool = (_memoryConfig, options) => {
24371
24413
  resourceId: isResourceScope ? resourceId : void 0,
24372
24414
  cursor,
24373
24415
  partIndex,
24416
+ charOffset,
24374
24417
  threadScope
24375
24418
  });
24376
24419
  return recallMessages({
@@ -26848,7 +26891,8 @@ var ObservationStep = class {
26848
26891
  }
26849
26892
  /**
26850
26893
  * Run the full threshold observation pipeline:
26851
- * waitForBuffering → re-check → activate → reflect → blockAfter gate observe
26894
+ * waitForBuffering → re-check → activate → reflect → observe (sync fallback when
26895
+ * buffered activation did not happen)
26852
26896
  */
26853
26897
  async runThresholdObservation() {
26854
26898
  const { threadId, resourceId, messageList } = this.turn;
@@ -43543,4 +43587,4 @@ const agentBuilderWorkflows = {
43543
43587
  //#endregion
43544
43588
  export { agentBuilderWorkflows };
43545
43589
 
43546
- //# sourceMappingURL=dist-7r8jzEWH.js.map
43590
+ //# sourceMappingURL=dist-ByXtFaHm.js.map