@mastra/server 1.56.0-alpha.5 → 1.56.0-alpha.7

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.
Files changed (179) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/_types/@internal_core/dist/storage/index.d.ts +8 -0
  3. package/dist/{a2a-Dmw3AD3r.cjs → a2a-CE7HKP5V.cjs} +3 -3
  4. package/dist/{a2a-Dmw3AD3r.cjs.map → a2a-CE7HKP5V.cjs.map} +1 -1
  5. package/dist/{a2a-BHqh8DdO.js → a2a-_3LYIc9y.js} +3 -3
  6. package/dist/{a2a-BHqh8DdO.js.map → a2a-_3LYIc9y.js.map} +1 -1
  7. package/dist/{api-schema-manifest-BD9sVZgj.cjs → api-schema-manifest-Ba-Ssw4H.cjs} +3 -3
  8. package/dist/{api-schema-manifest-BD9sVZgj.cjs.map → api-schema-manifest-Ba-Ssw4H.cjs.map} +1 -1
  9. package/dist/{api-schema-manifest-DOHg_30B.js → api-schema-manifest-DbTP-DpV.js} +3 -3
  10. package/dist/{api-schema-manifest-DOHg_30B.js.map → api-schema-manifest-DbTP-DpV.js.map} +1 -1
  11. package/dist/{background-tasks-BuRJRi1i.cjs → background-tasks-CYgzzUnb.cjs} +2 -2
  12. package/dist/{background-tasks-BuRJRi1i.cjs.map → background-tasks-CYgzzUnb.cjs.map} +1 -1
  13. package/dist/{background-tasks-BdcOtHq3.js → background-tasks-DnmhLalp.js} +2 -2
  14. package/dist/{background-tasks-BdcOtHq3.js.map → background-tasks-DnmhLalp.js.map} +1 -1
  15. package/dist/{builder-registry-NmiGAW1q.cjs → builder-registry-C_PysvMI.cjs} +3 -3
  16. package/dist/{builder-registry-NmiGAW1q.cjs.map → builder-registry-C_PysvMI.cjs.map} +1 -1
  17. package/dist/{builder-registry-dh22nXUR.js → builder-registry-DaPvPspl.js} +3 -3
  18. package/dist/{builder-registry-dh22nXUR.js.map → builder-registry-DaPvPspl.js.map} +1 -1
  19. package/dist/{channels-Cv5RlwiT.cjs → channels-BonQBJT0.cjs} +2 -2
  20. package/dist/{channels-Cv5RlwiT.cjs.map → channels-BonQBJT0.cjs.map} +1 -1
  21. package/dist/{channels-Do3L4evC.js → channels-BqkOxxEk.js} +2 -2
  22. package/dist/{channels-Do3L4evC.js.map → channels-BqkOxxEk.js.map} +1 -1
  23. package/dist/{datasets-7yYpHm7l.cjs → datasets-Cvix7Rms.cjs} +6 -1
  24. package/dist/datasets-Cvix7Rms.cjs.map +1 -0
  25. package/dist/{datasets-CopqHYDy.js → datasets-dhXnHLAL.js} +6 -1
  26. package/dist/datasets-dhXnHLAL.js.map +1 -0
  27. package/dist/{dist-D9hQEsv9.cjs → dist-CpDWlJbf.cjs} +69 -16
  28. package/dist/dist-CpDWlJbf.cjs.map +1 -0
  29. package/dist/{dist-BlHxui7N.js → dist-Epz-mpJn.js} +65 -12
  30. package/dist/dist-Epz-mpJn.js.map +1 -0
  31. package/dist/docs/SKILL.md +1 -1
  32. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  33. package/dist/{editor-builder-Dn6ru5DU.cjs → editor-builder-ByNr3nc9.cjs} +2 -2
  34. package/dist/{editor-builder-Dn6ru5DU.cjs.map → editor-builder-ByNr3nc9.cjs.map} +1 -1
  35. package/dist/{editor-builder-DkGLV2Gj.js → editor-builder-CW9Tcqg1.js} +2 -2
  36. package/dist/{editor-builder-DkGLV2Gj.js.map → editor-builder-CW9Tcqg1.js.map} +1 -1
  37. package/dist/{observability-new-endpoints-C1g-Gvjz.js → observability-new-endpoints-CCyqX1Ra.js} +3 -2
  38. package/dist/observability-new-endpoints-CCyqX1Ra.js.map +1 -0
  39. package/dist/{observability-new-endpoints-Dp2vQgwB.cjs → observability-new-endpoints-DFBDedGH.cjs} +3 -2
  40. package/dist/observability-new-endpoints-DFBDedGH.cjs.map +1 -0
  41. package/dist/{route-builder-CXe0EI1P.js → route-builder-CIk5k35M.js} +2 -2
  42. package/dist/{route-builder-CXe0EI1P.js.map → route-builder-CIk5k35M.js.map} +1 -1
  43. package/dist/{route-builder-BZaWjoDk.cjs → route-builder-CgLVYL1c.cjs} +4 -4
  44. package/dist/{route-builder-BZaWjoDk.cjs.map → route-builder-CgLVYL1c.cjs.map} +1 -1
  45. package/dist/{routes-Bmt4vUom.cjs → routes-2WgTU1wN.cjs} +10 -10
  46. package/dist/{routes-Bmt4vUom.cjs.map → routes-2WgTU1wN.cjs.map} +1 -1
  47. package/dist/{routes-YeBVxmmg.js → routes-CN8wYsyr.js} +10 -10
  48. package/dist/{routes-YeBVxmmg.js.map → routes-CN8wYsyr.js.map} +1 -1
  49. package/dist/{schedules-Dury8Ely.cjs → schedules-CK3-IE0h.cjs} +2 -2
  50. package/dist/{schedules-Dury8Ely.cjs.map → schedules-CK3-IE0h.cjs.map} +1 -1
  51. package/dist/{schedules-ziUJUmzR.js → schedules-qxFoU-Tb.js} +2 -2
  52. package/dist/{schedules-ziUJUmzR.js.map → schedules-qxFoU-Tb.js.map} +1 -1
  53. package/dist/schema-B8-5YCsA.js +2 -0
  54. package/dist/schema-BieM1qrc.cjs +1 -0
  55. package/dist/{schema-Ba6HLBWs-29iOFPqZ.cjs → schema-Bv9OdW1f-BY6u3u8K.cjs} +22 -4
  56. package/dist/schema-Bv9OdW1f-BY6u3u8K.cjs.map +1 -0
  57. package/dist/{schema-Ba6HLBWs-C2m5ORpo.js → schema-Bv9OdW1f-CIOfv-3w.js} +22 -4
  58. package/dist/schema-Bv9OdW1f-CIOfv-3w.js.map +1 -0
  59. package/dist/server/handlers/a2a.cjs +1 -1
  60. package/dist/server/handlers/a2a.js +1 -1
  61. package/dist/server/handlers/agent-builder.cjs +3 -3
  62. package/dist/server/handlers/agent-builder.js +3 -3
  63. package/dist/server/handlers/agent-controller.cjs +1 -1
  64. package/dist/server/handlers/agent-controller.js +1 -1
  65. package/dist/server/handlers/agent-versions.cjs +2 -2
  66. package/dist/server/handlers/agent-versions.js +2 -2
  67. package/dist/server/handlers/agents.cjs +5 -5
  68. package/dist/server/handlers/agents.js +4 -4
  69. package/dist/server/handlers/auth.cjs +1 -1
  70. package/dist/server/handlers/auth.js +1 -1
  71. package/dist/server/handlers/background-tasks.cjs +1 -1
  72. package/dist/server/handlers/background-tasks.js +1 -1
  73. package/dist/server/handlers/builder-registry.cjs +1 -1
  74. package/dist/server/handlers/builder-registry.js +1 -1
  75. package/dist/server/handlers/channels.cjs +1 -1
  76. package/dist/server/handlers/channels.js +1 -1
  77. package/dist/server/handlers/conversations.cjs +1 -1
  78. package/dist/server/handlers/conversations.js +1 -1
  79. package/dist/server/handlers/datasets.cjs +8 -6
  80. package/dist/server/handlers/datasets.cjs.map +1 -1
  81. package/dist/server/handlers/datasets.d.ts +20 -0
  82. package/dist/server/handlers/datasets.d.ts.map +1 -1
  83. package/dist/server/handlers/datasets.js +8 -6
  84. package/dist/server/handlers/datasets.js.map +1 -1
  85. package/dist/server/handlers/editor-builder.cjs +1 -1
  86. package/dist/server/handlers/editor-builder.js +1 -1
  87. package/dist/server/handlers/favorites-enrichment.cjs +1 -1
  88. package/dist/server/handlers/favorites-enrichment.js +1 -1
  89. package/dist/server/handlers/logs.cjs +1 -1
  90. package/dist/server/handlers/logs.js +1 -1
  91. package/dist/server/handlers/mcp-client-versions.cjs +2 -2
  92. package/dist/server/handlers/mcp-client-versions.js +2 -2
  93. package/dist/server/handlers/mcp.cjs +1 -1
  94. package/dist/server/handlers/mcp.js +1 -1
  95. package/dist/server/handlers/memory.cjs +1 -1
  96. package/dist/server/handlers/memory.js +1 -1
  97. package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
  98. package/dist/server/handlers/observability-new-endpoints.d.ts +16 -0
  99. package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
  100. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  101. package/dist/server/handlers/observability-shared.cjs +1 -1
  102. package/dist/server/handlers/observability-shared.js +1 -1
  103. package/dist/server/handlers/observability.cjs +2 -2
  104. package/dist/server/handlers/observability.js +2 -2
  105. package/dist/server/handlers/processor-providers.cjs +1 -1
  106. package/dist/server/handlers/processor-providers.js +1 -1
  107. package/dist/server/handlers/processors.cjs +1 -1
  108. package/dist/server/handlers/processors.js +1 -1
  109. package/dist/server/handlers/prompt-block-versions.cjs +2 -2
  110. package/dist/server/handlers/prompt-block-versions.js +2 -2
  111. package/dist/server/handlers/responses.cjs +1 -1
  112. package/dist/server/handlers/responses.js +1 -1
  113. package/dist/server/handlers/schedules.cjs +1 -1
  114. package/dist/server/handlers/schedules.js +1 -1
  115. package/dist/server/handlers/scorer-versions.cjs +2 -2
  116. package/dist/server/handlers/scorer-versions.js +2 -2
  117. package/dist/server/handlers/scores.cjs +1 -1
  118. package/dist/server/handlers/scores.js +1 -1
  119. package/dist/server/handlers/stored-agent-favorites.cjs +3 -3
  120. package/dist/server/handlers/stored-agent-favorites.js +3 -3
  121. package/dist/server/handlers/stored-agents.cjs +3 -3
  122. package/dist/server/handlers/stored-agents.js +3 -3
  123. package/dist/server/handlers/stored-mcp-clients.cjs +2 -2
  124. package/dist/server/handlers/stored-mcp-clients.js +2 -2
  125. package/dist/server/handlers/stored-prompt-blocks.cjs +2 -2
  126. package/dist/server/handlers/stored-prompt-blocks.js +2 -2
  127. package/dist/server/handlers/stored-scorers.cjs +2 -2
  128. package/dist/server/handlers/stored-scorers.js +2 -2
  129. package/dist/server/handlers/stored-skill-favorites.cjs +3 -3
  130. package/dist/server/handlers/stored-skill-favorites.js +3 -3
  131. package/dist/server/handlers/stored-skills.cjs +3 -3
  132. package/dist/server/handlers/stored-skills.js +3 -3
  133. package/dist/server/handlers/stored-workflows.cjs +1 -1
  134. package/dist/server/handlers/stored-workflows.js +1 -1
  135. package/dist/server/handlers/stored-workspaces.cjs +2 -2
  136. package/dist/server/handlers/stored-workspaces.js +2 -2
  137. package/dist/server/handlers/system.cjs +2 -2
  138. package/dist/server/handlers/system.js +2 -2
  139. package/dist/server/handlers/tool-providers.cjs +1 -1
  140. package/dist/server/handlers/tool-providers.js +1 -1
  141. package/dist/server/handlers/tools.cjs +5 -5
  142. package/dist/server/handlers/tools.js +4 -4
  143. package/dist/server/handlers/vector.cjs +1 -1
  144. package/dist/server/handlers/vector.js +1 -1
  145. package/dist/server/handlers/workflows.cjs +2 -2
  146. package/dist/server/handlers/workflows.js +2 -2
  147. package/dist/server/handlers/workspace.cjs +1 -1
  148. package/dist/server/handlers/workspace.js +1 -1
  149. package/dist/server/handlers.cjs +2 -2
  150. package/dist/server/handlers.js +2 -2
  151. package/dist/server/schemas/datasets.d.ts +8 -0
  152. package/dist/server/schemas/datasets.d.ts.map +1 -1
  153. package/dist/server/schemas/index.cjs +1 -1
  154. package/dist/server/schemas/index.js +1 -1
  155. package/dist/server/server-adapter/index.cjs +3 -3
  156. package/dist/server/server-adapter/index.js +3 -3
  157. package/dist/server/server-adapter/routes/datasets.d.ts +20 -0
  158. package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
  159. package/dist/server/server-adapter/routes/observability.d.ts +8 -0
  160. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
  161. package/dist/{stored-workflows-B3zZJg8e.js → stored-workflows-OanG0TmB.js} +2 -2
  162. package/dist/{stored-workflows-B3zZJg8e.js.map → stored-workflows-OanG0TmB.js.map} +1 -1
  163. package/dist/{stored-workflows-RgQKpn7N.cjs → stored-workflows-pCiWK305.cjs} +2 -2
  164. package/dist/{stored-workflows-RgQKpn7N.cjs.map → stored-workflows-pCiWK305.cjs.map} +1 -1
  165. package/dist/{utils-DVelcVp5.js → utils-qxLrCsRx.js} +3 -3
  166. package/dist/{utils-DVelcVp5.js.map → utils-qxLrCsRx.js.map} +1 -1
  167. package/dist/{utils-5wLvbOLW.cjs → utils-xsPNtHk8.cjs} +5 -5
  168. package/dist/{utils-5wLvbOLW.cjs.map → utils-xsPNtHk8.cjs.map} +1 -1
  169. package/package.json +5 -5
  170. package/dist/datasets-7yYpHm7l.cjs.map +0 -1
  171. package/dist/datasets-CopqHYDy.js.map +0 -1
  172. package/dist/dist-BlHxui7N.js.map +0 -1
  173. package/dist/dist-D9hQEsv9.cjs.map +0 -1
  174. package/dist/observability-new-endpoints-C1g-Gvjz.js.map +0 -1
  175. package/dist/observability-new-endpoints-Dp2vQgwB.cjs.map +0 -1
  176. package/dist/schema-BXx4ex7A.cjs +0 -1
  177. package/dist/schema-Ba6HLBWs-29iOFPqZ.cjs.map +0 -1
  178. package/dist/schema-Ba6HLBWs-C2m5ORpo.js.map +0 -1
  179. package/dist/schema-CcKMuta9.js +0 -2
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM$1, r as __require, t as __commonJSMin$1 } from "./rolldown-runtime-DuvcJU0W.js";
2
- import { n as standardSchemaToJSONSchema, r as toStandardSchema$1, t as isStandardSchemaWithJSON$1 } from "./schema-Ba6HLBWs-C2m5ORpo.js";
3
- import "./schema-CcKMuta9.js";
2
+ import { n as standardSchemaToJSONSchema, r as toStandardSchema$1, t as isStandardSchemaWithJSON$1 } from "./schema-Bv9OdW1f-CIOfv-3w.js";
3
+ import "./schema-B8-5YCsA.js";
4
4
  import { openai } from "./dist-DyBO3IVt.js";
5
5
  import { createRequire } from "module";
6
6
  import * as z4 from "zod/v4";
@@ -5958,7 +5958,7 @@ function splitLines(text) {
5958
5958
  return result;
5959
5959
  }
5960
5960
  //#endregion
5961
- //#region ../memory/dist/src-DoNjfXNm.js
5961
+ //#region ../memory/dist/src-BgdYYHLc.js
5962
5962
  var __defProp$4 = Object.defineProperty;
5963
5963
  var __exportAll = (all, no_symbols) => {
5964
5964
  let target = {};
@@ -20498,7 +20498,7 @@ var constants_exports = /* @__PURE__ */ __exportAll({
20498
20498
  OBSERVATION_CONTEXT_INSTRUCTIONS: () => OBSERVATION_CONTEXT_INSTRUCTIONS,
20499
20499
  OBSERVATION_CONTEXT_PROMPT: () => OBSERVATION_CONTEXT_PROMPT,
20500
20500
  OBSERVATION_CONTINUATION_HINT: () => OBSERVATION_CONTINUATION_HINT,
20501
- OBSERVATION_RETRIEVAL_INSTRUCTIONS: () => OBSERVATION_RETRIEVAL_INSTRUCTIONS
20501
+ getRetrievalInstructions: () => getRetrievalInstructions
20502
20502
  });
20503
20503
  /**
20504
20504
  * Default configuration values matching the spec
@@ -20561,8 +20561,22 @@ SYSTEM REMINDERS: Messages wrapped in <system-reminder>...</system-reminder> con
20561
20561
  /**
20562
20562
  * Instructions for retrieval mode — explains observation-group ranges and the recall tool.
20563
20563
  * Appended to context when `retrieval` is enabled.
20564
+ *
20565
+ * The content adapts to the retrieval scope:
20566
+ * - `'resource'`: covers routing between `search`, `threads`, and `messages` across
20567
+ * all of the user's threads, including fallback when search results are unsuitable.
20568
+ * - `'thread'`: covers cursor-based browsing and search within the current thread.
20569
+ *
20570
+ * @param scope - The retrieval scope the recall tool was registered with.
20571
+ * @param customInstructions - Optional application-provided guidance appended after
20572
+ * the native instructions. Never replaces them.
20573
+ * @param searchEnabled - Whether semantic search (`retrieval: { vector: true }`) is
20574
+ * available. When false, the guidance only covers \`threads\`/\`messages\` browsing so
20575
+ * the agent is not steered toward a mode that cannot work.
20564
20576
  */
20565
- const OBSERVATION_RETRIEVAL_INSTRUCTIONS = `## Recall looking up source messages
20577
+ function getRetrievalInstructions(scope = "resource", customInstructions, searchEnabled = true) {
20578
+ const isResource = scope === "resource";
20579
+ const base = `## Recall — looking up source messages
20566
20580
 
20567
20581
  Your memory is comprised of observations which are sometimes wrapped in <observation-group> xml tags containing ranges like <observation-group range="startId:endId">. These ranges point back to the raw messages that each observation group was derived from. The original messages are still available — use the **recall** tool to retrieve them.
20568
20582
 
@@ -20570,11 +20584,32 @@ Your memory is comprised of observations which are sometimes wrapped in <observa
20570
20584
  - The user asks you to **repeat, show, or reproduce** something from a past conversation
20571
20585
  - The user asks for **exact content** — code, text, quotes, error messages, URLs, file paths, specific numbers
20572
20586
  - Your observations mention something but your memory lacks the detail needed to fully answer (e.g. you know a blog post was shared but only have a summary of it)
20573
- - You want to **verify or expand on** an observation before responding
20587
+ - You want to **verify or expand on** an observation before responding${isResource ? `
20588
+ - The user references another conversation that your observations don't cover — even if you have no observations yet, their other threads may contain it` : ""}
20574
20589
 
20575
20590
  **Default to using recall when the user references specific past content.** Your observations capture the gist, not the details. If there's any doubt whether your memory is complete enough, use recall.
20576
20591
 
20577
- ### How to use recall
20592
+ ${isResource ? searchEnabled ? `### Choosing a mode
20593
+ The recall tool works across ALL of this user's conversation threads, not just the current one.
20594
+
20595
+ - Use \`mode: "search"\` with a \`query\` when you don't know which thread contains the answer. Each result includes its thread ID and the raw message IDs it came from, which you can use as a \`cursor\`.
20596
+ - Use \`mode: "messages"\` when you already know the thread — pass \`threadId\` to read another thread, or a \`cursor\` from an observation-group range or a search result.
20597
+ - Use \`mode: "threads"\` to list the user's threads (IDs, titles, dates) when you need to discover where something was discussed. Use \`before\`/\`after\` to narrow by date.
20598
+
20599
+ **If search results look irrelevant, do not give up.** Search only covers content that has been indexed — a short or recent conversation may exist in raw message history before any observation of it was created. When search returns nothing suitable but the user is clearly referring to a past conversation, call \`mode: "threads"\` to find candidate threads (titles and dates are strong clues), then read them with \`mode: "messages"\`. If a search result already gives you a thread ID, go straight to \`mode: "messages"\`.` : `### Choosing a mode
20600
+ The recall tool works across ALL of this user's conversation threads, not just the current one.
20601
+
20602
+ - Use \`mode: "threads"\` to list the user's threads (IDs, titles, dates) when you need to discover where something was discussed. Use \`before\`/\`after\` to narrow by date.
20603
+ - Use \`mode: "messages"\` when you know the thread — pass \`threadId\` to read another thread, or a \`cursor\` from an observation-group range.
20604
+
20605
+ When the user refers to a past conversation you don't have a cursor for, call \`mode: "threads"\` to find candidate threads (titles and dates are strong clues), then read them with \`mode: "messages"\`. Raw history may exist for threads that have no observations yet.` : `### Choosing a mode
20606
+ The recall tool is limited to the current conversation thread.
20607
+
20608
+ - Use \`mode: "messages"\` (default) to page through this thread's message history near a cursor.${searchEnabled ? `
20609
+ - Use \`mode: "search"\` with a \`query\` to find messages by content within this thread.` : ""}
20610
+ - Use \`mode: "threads"\` to get the current thread's ID, title, and dates.`}
20611
+
20612
+ ### How to use recall with a cursor
20578
20613
  Each range has the format \`startId:endId\` where both are message IDs separated by a colon.
20579
20614
 
20580
20615
  1. Find the observation group relevant to the user's question and extract the start or end ID from its range.
@@ -20600,9 +20635,16 @@ Low-detail results may include truncation hints like:
20600
20635
  ### When recall is NOT needed
20601
20636
  - The user is asking for a high-level summary and your observations already cover it
20602
20637
  - The question is about general preferences or facts that don't require source text
20603
- - There is no relevant range in your observations for the topic
20638
+ ${isResource ? `- No relevant observation range exists AND ${searchEnabled ? "`search`/`threads`" : "`threads`"} turned up nothing — but remember that raw history may exist for threads that have no observations yet, so check before concluding the information is unavailable` : `- There is no relevant range in your observations for the topic`}
20604
20639
 
20605
20640
  Observation groups with range IDs and your recall tool allows you to think back and remember details you're fuzzy on.`;
20641
+ const custom = customInstructions?.trim();
20642
+ if (!custom) return base;
20643
+ return `${base}
20644
+
20645
+ ### Additional recall guidance
20646
+ ${custom}`;
20647
+ }
20606
20648
  const BUILT_IN_SLUGS = /* @__PURE__ */ new Set([
20607
20649
  "current-task",
20608
20650
  "suggested-response",
@@ -29544,6 +29586,11 @@ var ObservationalMemory = class ObservationalMemory {
29544
29586
  scope;
29545
29587
  /** Whether retrieval-mode observation groups are enabled. */
29546
29588
  retrieval;
29589
+ /** Scope the recall tool was registered with — controls which retrieval instructions are injected. */
29590
+ retrievalScope;
29591
+ /** Application-provided guidance appended after the native retrieval instructions. */
29592
+ retrievalInstructions;
29593
+ retrievalSearch;
29547
29594
  observationConfig;
29548
29595
  reflectionConfig;
29549
29596
  onDebugEvent;
@@ -29609,6 +29656,9 @@ var ObservationalMemory = class ObservationalMemory {
29609
29656
  this.storage = config.storage;
29610
29657
  this.scope = config.scope ?? "thread";
29611
29658
  this.retrieval = Boolean(config.retrieval);
29659
+ this.retrievalScope = typeof config.retrieval === "object" ? config.retrieval.scope ?? "resource" : "resource";
29660
+ this.retrievalInstructions = typeof config.retrieval === "object" ? config.retrieval.instructions : void 0;
29661
+ this.retrievalSearch = typeof config.retrieval === "object" && Boolean(config.retrieval.vector);
29612
29662
  this.onIndexObservations = config.onIndexObservations;
29613
29663
  this.hooks = config.hooks;
29614
29664
  this.mastra = config.mastra;
@@ -30257,7 +30307,7 @@ var ObservationalMemory = class ObservationalMemory {
30257
30307
  formatObservationsForContext(observations, currentTask, suggestedResponse, extractedValues, unobservedContextBlocks, currentDate, retrieval = false) {
30258
30308
  let optimized = retrieval ? renderObservationGroupsForReflection(observations) ?? optimizeObservationsForContext(observations) : optimizeObservationsForContext(observations);
30259
30309
  if (currentDate) optimized = addRelativeTimeToObservations(optimized, currentDate);
30260
- const messages = [`${OBSERVATION_CONTEXT_PROMPT}\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}${retrieval ? `\n\n${OBSERVATION_RETRIEVAL_INSTRUCTIONS}` : ""}`];
30310
+ const messages = [`${OBSERVATION_CONTEXT_PROMPT}\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}${retrieval ? `\n\n${getRetrievalInstructions(this.retrievalScope, this.retrievalInstructions, this.retrievalSearch)}` : ""}`];
30261
30311
  if (unobservedContextBlocks) messages.push(`The following content is from OTHER conversations different from the current conversation, they're here for reference, but they're not necessarily your focus:\nSTART_OTHER_CONVERSATIONS_BLOCK\n${unobservedContextBlocks}\nEND_OTHER_CONVERSATIONS_BLOCK`);
30262
30312
  const observationChunks = this.splitObservationContextChunks(optimized);
30263
30313
  if (observationChunks.length > 0) messages.push("<observations>", ...observationChunks);
@@ -30759,7 +30809,10 @@ ${formattedMessages}
30759
30809
  async buildContextSystemMessages(opts) {
30760
30810
  const { threadId, resourceId, unobservedContextBlocks } = opts;
30761
30811
  const record = opts.record ?? await this.getOrCreateRecord(threadId, resourceId);
30762
- if (!record.activeObservations) return void 0;
30812
+ if (!record.activeObservations) {
30813
+ if (this.retrieval && this.retrievalScope === "resource") return [getRetrievalInstructions(this.retrievalScope, this.retrievalInstructions, this.retrievalSearch)];
30814
+ return;
30815
+ }
30763
30816
  const omMetadata = getThreadOMMetadata((await this.storage.getThreadById({ threadId }))?.metadata);
30764
30817
  const currentTask = omMetadata?.currentTask;
30765
30818
  const suggestedResponse = omMetadata?.suggestedResponse;
@@ -31887,7 +31940,7 @@ var ObservationalMemoryProcessor = class {
31887
31940
  threadId,
31888
31941
  resourceId
31889
31942
  });
31890
- const systemMessages = ctx.hasObservations && ctx.omRecord ? await this.engine.buildContextSystemMessages({
31943
+ const systemMessages = ctx.omRecord ? await this.engine.buildContextSystemMessages({
31891
31944
  threadId,
31892
31945
  resourceId,
31893
31946
  record: ctx.omRecord,
@@ -44432,4 +44485,4 @@ const agentBuilderWorkflows = {
44432
44485
  //#endregion
44433
44486
  export { agentBuilderWorkflows };
44434
44487
 
44435
- //# sourceMappingURL=dist-BlHxui7N.js.map
44488
+ //# sourceMappingURL=dist-Epz-mpJn.js.map