@mastra/server 1.16.1-alpha.0 → 1.17.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 +14 -0
- package/dist/chunk-3D55EABW.cjs +111 -0
- package/dist/chunk-3D55EABW.cjs.map +1 -0
- package/dist/chunk-JMEMSVJ5.js +105 -0
- package/dist/chunk-JMEMSVJ5.js.map +1 -0
- package/dist/{chunk-7CABBOGK.js → chunk-PZE5ZBAX.js} +202 -73
- package/dist/chunk-PZE5ZBAX.js.map +1 -0
- package/dist/{chunk-ZQAASZVD.cjs → chunk-R5EM57UR.cjs} +6800 -6618
- package/dist/chunk-R5EM57UR.cjs.map +1 -0
- package/dist/{chunk-GFTW6WEN.cjs → chunk-SZBVW2WD.cjs} +215 -86
- package/dist/chunk-SZBVW2WD.cjs.map +1 -0
- package/dist/{chunk-VUR5VN5R.js → chunk-WICIG6YL.js} +6792 -6607
- package/dist/chunk-WICIG6YL.js.map +1 -0
- package/dist/constants-BDOITAO3-PCCYSQXK.js +3 -0
- package/dist/constants-BDOITAO3-PCCYSQXK.js.map +1 -0
- package/dist/constants-BDOITAO3-YWTMWUNT.cjs +28 -0
- package/dist/constants-BDOITAO3-YWTMWUNT.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/observational-memory-WMCWT577-EDKAVK3W.js +4 -0
- package/dist/{observational-memory-NMQ7URIP-FOPRYAC2.js.map → observational-memory-WMCWT577-EDKAVK3W.js.map} +1 -1
- package/dist/{observational-memory-NMQ7URIP-2GEIXUBD.cjs → observational-memory-WMCWT577-MXWR6ZYS.cjs} +46 -41
- package/dist/{observational-memory-NMQ7URIP-2GEIXUBD.cjs.map → observational-memory-WMCWT577-MXWR6ZYS.cjs.map} +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers.cjs +2 -2
- package/dist/server/handlers.js +1 -1
- package/dist/server/server-adapter/index.cjs +16 -16
- package/dist/server/server-adapter/index.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-7CABBOGK.js.map +0 -1
- package/dist/chunk-GFTW6WEN.cjs.map +0 -1
- package/dist/chunk-VUR5VN5R.js.map +0 -1
- package/dist/chunk-ZQAASZVD.cjs.map +0 -1
- package/dist/observational-memory-NMQ7URIP-FOPRYAC2.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
+
## 1.17.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`404fea1`](https://github.com/mastra-ai/mastra/commit/404fea13042181f0b0c73a101392ac87c79ceae2), [`ebf5047`](https://github.com/mastra-ai/mastra/commit/ebf5047e825c38a1a356f10b214c1d4260dfcd8d), [`675f15b`](https://github.com/mastra-ai/mastra/commit/675f15b7eaeea649158d228ea635be40480c584d), [`b174c63`](https://github.com/mastra-ai/mastra/commit/b174c63a093108d4e53b9bc89a078d9f66202b3f), [`eef7cb2`](https://github.com/mastra-ai/mastra/commit/eef7cb2abe7ef15951e2fdf792a5095c6c643333), [`86e3263`](https://github.com/mastra-ai/mastra/commit/86e326363edd12be5a5b25ccce4a39f66f7c9f50), [`e8a5b0b`](https://github.com/mastra-ai/mastra/commit/e8a5b0b9bc94d12dee4150095512ca27a288d778)]:
|
|
8
|
+
- @mastra/core@1.17.0-alpha.2
|
|
9
|
+
|
|
10
|
+
## 1.16.1-alpha.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`7302e5c`](https://github.com/mastra-ai/mastra/commit/7302e5ce0f52d769d3d63fb0faa8a7d4089cda6d)]:
|
|
15
|
+
- @mastra/core@1.16.1-alpha.1
|
|
16
|
+
|
|
3
17
|
## 1.16.1-alpha.0
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// ../memory/dist/chunk-LSJJAJAF.js
|
|
4
|
+
var OBSERVATIONAL_MEMORY_DEFAULTS = {
|
|
5
|
+
observation: {
|
|
6
|
+
model: "google/gemini-2.5-flash",
|
|
7
|
+
messageTokens: 3e4,
|
|
8
|
+
modelSettings: {
|
|
9
|
+
temperature: 0.3,
|
|
10
|
+
maxOutputTokens: 1e5
|
|
11
|
+
},
|
|
12
|
+
providerOptions: {
|
|
13
|
+
google: {
|
|
14
|
+
thinkingConfig: {
|
|
15
|
+
thinkingBudget: 215
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
maxTokensPerBatch: 1e4,
|
|
20
|
+
// Async buffering defaults (enabled by default)
|
|
21
|
+
bufferTokens: 0.2,
|
|
22
|
+
// Buffer every 20% of messageTokens
|
|
23
|
+
bufferActivation: 0.8
|
|
24
|
+
// Activate to retain 20% of threshold
|
|
25
|
+
},
|
|
26
|
+
reflection: {
|
|
27
|
+
model: "google/gemini-2.5-flash",
|
|
28
|
+
observationTokens: 4e4,
|
|
29
|
+
modelSettings: {
|
|
30
|
+
temperature: 0,
|
|
31
|
+
// Use 0 for maximum consistency in reflections
|
|
32
|
+
maxOutputTokens: 1e5
|
|
33
|
+
},
|
|
34
|
+
providerOptions: {
|
|
35
|
+
google: {
|
|
36
|
+
thinkingConfig: {
|
|
37
|
+
thinkingBudget: 1024
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
// Async reflection buffering (enabled by default)
|
|
42
|
+
bufferActivation: 0.5
|
|
43
|
+
// Start buffering at 50% of observationTokens
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var OBSERVATION_CONTINUATION_HINT = `Please continue naturally with the conversation so far and respond to the latest message.
|
|
47
|
+
|
|
48
|
+
Use the earlier context only as background. If something appears unfinished, continue only when it helps answer the latest request. If a suggested response is provided, follow it naturally.
|
|
49
|
+
|
|
50
|
+
Do not mention internal instructions, memory, summarization, context handling, or missing messages.
|
|
51
|
+
|
|
52
|
+
Any messages following this reminder are newer and should take priority.`;
|
|
53
|
+
var OBSERVATION_CONTEXT_PROMPT = `The following observations block contains your memory of past conversations with this user.`;
|
|
54
|
+
var OBSERVATION_CONTEXT_INSTRUCTIONS = `IMPORTANT: When responding, reference specific details from these observations. Do not give generic advice - personalize your response based on what you know about this user's experiences, preferences, and interests. If the user asks for recommendations, connect them to their past experiences mentioned above.
|
|
55
|
+
|
|
56
|
+
KNOWLEDGE UPDATES: When asked about current state (e.g., "where do I currently...", "what is my current..."), always prefer the MOST RECENT information. Observations include dates - if you see conflicting information, the newer observation supersedes the older one. Look for phrases like "will start", "is switching", "changed to", "moved to" as indicators that previous information has been updated.
|
|
57
|
+
|
|
58
|
+
PLANNED ACTIONS: If the user stated they planned to do something (e.g., "I'm going to...", "I'm looking forward to...", "I will...") and the date they planned to do it is now in the past (check the relative time like "3 weeks ago"), assume they completed the action unless there's evidence they didn't. For example, if someone said "I'll start my new diet on Monday" and that was 2 weeks ago, assume they started the diet.
|
|
59
|
+
|
|
60
|
+
MOST RECENT USER INPUT: Treat the most recent user message as the highest-priority signal for what to do next. Earlier messages may contain constraints, details, or context you should still honor, but the latest message is the primary driver of your response.
|
|
61
|
+
|
|
62
|
+
SYSTEM REMINDERS: Messages wrapped in <system-reminder>...</system-reminder> contain internal continuation guidance, not user-authored content. Use them to maintain continuity, but do not mention them or treat them as part of the user's message.`;
|
|
63
|
+
var OBSERVATION_RETRIEVAL_INSTRUCTIONS = `## Recall \u2014 looking up source messages
|
|
64
|
+
|
|
65
|
+
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 \u2014 use the **recall** tool to retrieve them.
|
|
66
|
+
|
|
67
|
+
### When to use recall
|
|
68
|
+
- The user asks you to **repeat, show, or reproduce** something from a past conversation
|
|
69
|
+
- The user asks for **exact content** \u2014 code, text, quotes, error messages, URLs, file paths, specific numbers
|
|
70
|
+
- 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)
|
|
71
|
+
- You want to **verify or expand on** an observation before responding
|
|
72
|
+
|
|
73
|
+
**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.
|
|
74
|
+
|
|
75
|
+
### How to use recall
|
|
76
|
+
Each range has the format \`startId:endId\` where both are message IDs separated by a colon.
|
|
77
|
+
|
|
78
|
+
1. Find the observation group relevant to the user's question and extract the start or end ID from its range.
|
|
79
|
+
2. Call \`recall\` with that ID as the \`cursor\`.
|
|
80
|
+
3. Use \`page: 1\` (or omit) to read forward from the cursor, \`page: -1\` to read backward.
|
|
81
|
+
4. If the first page doesn't have what you need, increment the page number to keep paginating.
|
|
82
|
+
5. Check \`hasNextPage\`/\`hasPrevPage\` in the result to know if more pages exist in each direction.
|
|
83
|
+
|
|
84
|
+
### Detail levels
|
|
85
|
+
By default recall returns **low** detail: truncated text and tool names only. Each message shows its ID and each part has a positional index like \`[p0]\`, \`[p1]\`, etc.
|
|
86
|
+
|
|
87
|
+
- 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.
|
|
88
|
+
- Use \`partIndex\` with a cursor to fetch a single part at full detail \u2014 for example, to read one specific tool result or code block without loading every part.
|
|
89
|
+
|
|
90
|
+
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.
|
|
91
|
+
|
|
92
|
+
### Following up on truncated parts
|
|
93
|
+
Low-detail results may include truncation hints like:
|
|
94
|
+
\`[truncated \u2014 call recall cursor="..." partIndex=N detail="high" for full content]\`
|
|
95
|
+
|
|
96
|
+
**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.
|
|
97
|
+
|
|
98
|
+
### When recall is NOT needed
|
|
99
|
+
- The user is asking for a high-level summary and your observations already cover it
|
|
100
|
+
- The question is about general preferences or facts that don't require source text
|
|
101
|
+
- There is no relevant range in your observations for the topic
|
|
102
|
+
|
|
103
|
+
Observation groups with range IDs and your recall tool allows you to think back and remember details you're fuzzy on.`;
|
|
104
|
+
|
|
105
|
+
exports.OBSERVATIONAL_MEMORY_DEFAULTS = OBSERVATIONAL_MEMORY_DEFAULTS;
|
|
106
|
+
exports.OBSERVATION_CONTEXT_INSTRUCTIONS = OBSERVATION_CONTEXT_INSTRUCTIONS;
|
|
107
|
+
exports.OBSERVATION_CONTEXT_PROMPT = OBSERVATION_CONTEXT_PROMPT;
|
|
108
|
+
exports.OBSERVATION_CONTINUATION_HINT = OBSERVATION_CONTINUATION_HINT;
|
|
109
|
+
exports.OBSERVATION_RETRIEVAL_INSTRUCTIONS = OBSERVATION_RETRIEVAL_INSTRUCTIONS;
|
|
110
|
+
//# sourceMappingURL=chunk-3D55EABW.cjs.map
|
|
111
|
+
//# sourceMappingURL=chunk-3D55EABW.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../memory/src/processors/observational-memory/constants.ts"],"names":[],"mappings":";;;AAGO,IAAM,6BAAA,GAAgC;EAC3C,WAAA,EAAa;IACX,KAAA,EAAO,yBAAA;IACP,aAAA,EAAe,GAAA;IACf,aAAA,EAAe;MACb,WAAA,EAAa,GAAA;MACb,eAAA,EAAiB;AAAA,KAAA;IAEnB,eAAA,EAAiB;MACf,MAAA,EAAQ;QACN,cAAA,EAAgB;UACd,cAAA,EAAgB;AAAA;AAClB;AACF,KAAA;IAEF,iBAAA,EAAmB,GAAA;;IAEnB,YAAA,EAAc,GAAA;;IACd,gBAAA,EAAkB;;AAAA,GAAA;EAEpB,UAAA,EAAY;IACV,KAAA,EAAO,yBAAA;IACP,iBAAA,EAAmB,GAAA;IACnB,aAAA,EAAe;MACb,WAAA,EAAa,CAAA;;MACb,eAAA,EAAiB;AAAA,KAAA;IAEnB,eAAA,EAAiB;MACf,MAAA,EAAQ;QACN,cAAA,EAAgB;UACd,cAAA,EAAgB;AAAA;AAClB;AACF,KAAA;;IAGF,gBAAA,EAAkB;;AAAA;AAEtB;AAOO,IAAM,6BAAA,GAAgC,CAAA;;;;;;;AAatC,IAAM,0BAAA,GAA6B,CAAA,2FAAA;AAMnC,IAAM,gCAAA,GAAmC,CAAA;;;;;;;;;AAczC,IAAM,kCAAA,GAAqC,CAAA","file":"chunk-3D55EABW.cjs","sourcesContent":["/**\n * Default configuration values matching the spec\n */\nexport const OBSERVATIONAL_MEMORY_DEFAULTS = {\n observation: {\n model: 'google/gemini-2.5-flash',\n messageTokens: 30_000,\n modelSettings: {\n temperature: 0.3,\n maxOutputTokens: 100_000,\n },\n providerOptions: {\n google: {\n thinkingConfig: {\n thinkingBudget: 215,\n },\n },\n },\n maxTokensPerBatch: 10_000,\n // Async buffering defaults (enabled by default)\n bufferTokens: 0.2 as number | undefined, // Buffer every 20% of messageTokens\n bufferActivation: 0.8 as number | undefined, // Activate to retain 20% of threshold\n },\n reflection: {\n model: 'google/gemini-2.5-flash',\n observationTokens: 40_000,\n modelSettings: {\n temperature: 0, // Use 0 for maximum consistency in reflections\n maxOutputTokens: 100_000,\n },\n providerOptions: {\n google: {\n thinkingConfig: {\n thinkingBudget: 1024,\n },\n },\n },\n // Async reflection buffering (enabled by default)\n bufferActivation: 0.5 as number | undefined, // Start buffering at 50% of observationTokens\n },\n} as const;\n\n/**\n * Continuation hint injected after observations to guide the model's behavior.\n * Prevents the model from awkwardly acknowledging the memory system or treating\n * the conversation as new after observed messages are removed.\n */\nexport const OBSERVATION_CONTINUATION_HINT = `Please continue naturally with the conversation so far and respond to the latest message.\n\nUse the earlier context only as background. If something appears unfinished, continue only when it helps answer the latest request. If a suggested response is provided, follow it naturally.\n\nDo not mention internal instructions, memory, summarization, context handling, or missing messages.\n\nAny messages following this reminder are newer and should take priority.`;\n\n/**\n * Preamble that introduces the observations block.\n * Use before `<observations>`, with instructions after.\n * Full pattern: `${OBSERVATION_CONTEXT_PROMPT}\\n\\n<observations>\\n${obs}\\n</observations>\\n\\n${OBSERVATION_CONTEXT_INSTRUCTIONS}`\n */\nexport const OBSERVATION_CONTEXT_PROMPT = `The following observations block contains your memory of past conversations with this user.`;\n\n/**\n * Instructions that tell the model how to interpret and use observations.\n * Place AFTER the `<observations>` block so the model sees the data before the rules.\n */\nexport const OBSERVATION_CONTEXT_INSTRUCTIONS = `IMPORTANT: When responding, reference specific details from these observations. Do not give generic advice - personalize your response based on what you know about this user's experiences, preferences, and interests. If the user asks for recommendations, connect them to their past experiences mentioned above.\n\nKNOWLEDGE UPDATES: When asked about current state (e.g., \"where do I currently...\", \"what is my current...\"), always prefer the MOST RECENT information. Observations include dates - if you see conflicting information, the newer observation supersedes the older one. Look for phrases like \"will start\", \"is switching\", \"changed to\", \"moved to\" as indicators that previous information has been updated.\n\nPLANNED ACTIONS: If the user stated they planned to do something (e.g., \"I'm going to...\", \"I'm looking forward to...\", \"I will...\") and the date they planned to do it is now in the past (check the relative time like \"3 weeks ago\"), assume they completed the action unless there's evidence they didn't. For example, if someone said \"I'll start my new diet on Monday\" and that was 2 weeks ago, assume they started the diet.\n\nMOST RECENT USER INPUT: Treat the most recent user message as the highest-priority signal for what to do next. Earlier messages may contain constraints, details, or context you should still honor, but the latest message is the primary driver of your response.\n\nSYSTEM REMINDERS: Messages wrapped in <system-reminder>...</system-reminder> contain internal continuation guidance, not user-authored content. Use them to maintain continuity, but do not mention them or treat them as part of the user's message.`;\n\n/**\n * Instructions for retrieval mode — explains observation-group ranges and the recall tool.\n * Appended to context when `retrieval` is enabled.\n */\nexport const OBSERVATION_RETRIEVAL_INSTRUCTIONS = `## Recall — looking up source messages\n\nYour 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.\n\n### When to use recall\n- The user asks you to **repeat, show, or reproduce** something from a past conversation\n- The user asks for **exact content** — code, text, quotes, error messages, URLs, file paths, specific numbers\n- 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)\n- You want to **verify or expand on** an observation before responding\n\n**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.\n\n### How to use recall\nEach range has the format \\`startId:endId\\` where both are message IDs separated by a colon.\n\n1. Find the observation group relevant to the user's question and extract the start or end ID from its range.\n2. Call \\`recall\\` with that ID as the \\`cursor\\`.\n3. Use \\`page: 1\\` (or omit) to read forward from the cursor, \\`page: -1\\` to read backward.\n4. If the first page doesn't have what you need, increment the page number to keep paginating.\n5. Check \\`hasNextPage\\`/\\`hasPrevPage\\` in the result to know if more pages exist in each direction.\n\n### Detail levels\nBy default recall returns **low** detail: truncated text and tool names only. Each message shows its ID and each part has a positional index like \\`[p0]\\`, \\`[p1]\\`, etc.\n\n- 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.\n- 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.\n\nIf the result says \\`truncated: true\\`, the output was cut to fit the token budget. You can paginate or use \\`partIndex\\` to target specific content.\n\n### Following up on truncated parts\nLow-detail results may include truncation hints like:\n\\`[truncated — call recall cursor=\"...\" partIndex=N detail=\"high\" for full content]\\`\n\n**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.\n\n### When recall is NOT needed\n- The user is asking for a high-level summary and your observations already cover it\n- The question is about general preferences or facts that don't require source text\n- There is no relevant range in your observations for the topic\n\nObservation groups with range IDs and your recall tool allows you to think back and remember details you're fuzzy on.`;\n"]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// ../memory/dist/chunk-LSJJAJAF.js
|
|
2
|
+
var OBSERVATIONAL_MEMORY_DEFAULTS = {
|
|
3
|
+
observation: {
|
|
4
|
+
model: "google/gemini-2.5-flash",
|
|
5
|
+
messageTokens: 3e4,
|
|
6
|
+
modelSettings: {
|
|
7
|
+
temperature: 0.3,
|
|
8
|
+
maxOutputTokens: 1e5
|
|
9
|
+
},
|
|
10
|
+
providerOptions: {
|
|
11
|
+
google: {
|
|
12
|
+
thinkingConfig: {
|
|
13
|
+
thinkingBudget: 215
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
maxTokensPerBatch: 1e4,
|
|
18
|
+
// Async buffering defaults (enabled by default)
|
|
19
|
+
bufferTokens: 0.2,
|
|
20
|
+
// Buffer every 20% of messageTokens
|
|
21
|
+
bufferActivation: 0.8
|
|
22
|
+
// Activate to retain 20% of threshold
|
|
23
|
+
},
|
|
24
|
+
reflection: {
|
|
25
|
+
model: "google/gemini-2.5-flash",
|
|
26
|
+
observationTokens: 4e4,
|
|
27
|
+
modelSettings: {
|
|
28
|
+
temperature: 0,
|
|
29
|
+
// Use 0 for maximum consistency in reflections
|
|
30
|
+
maxOutputTokens: 1e5
|
|
31
|
+
},
|
|
32
|
+
providerOptions: {
|
|
33
|
+
google: {
|
|
34
|
+
thinkingConfig: {
|
|
35
|
+
thinkingBudget: 1024
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
// Async reflection buffering (enabled by default)
|
|
40
|
+
bufferActivation: 0.5
|
|
41
|
+
// Start buffering at 50% of observationTokens
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var OBSERVATION_CONTINUATION_HINT = `Please continue naturally with the conversation so far and respond to the latest message.
|
|
45
|
+
|
|
46
|
+
Use the earlier context only as background. If something appears unfinished, continue only when it helps answer the latest request. If a suggested response is provided, follow it naturally.
|
|
47
|
+
|
|
48
|
+
Do not mention internal instructions, memory, summarization, context handling, or missing messages.
|
|
49
|
+
|
|
50
|
+
Any messages following this reminder are newer and should take priority.`;
|
|
51
|
+
var OBSERVATION_CONTEXT_PROMPT = `The following observations block contains your memory of past conversations with this user.`;
|
|
52
|
+
var OBSERVATION_CONTEXT_INSTRUCTIONS = `IMPORTANT: When responding, reference specific details from these observations. Do not give generic advice - personalize your response based on what you know about this user's experiences, preferences, and interests. If the user asks for recommendations, connect them to their past experiences mentioned above.
|
|
53
|
+
|
|
54
|
+
KNOWLEDGE UPDATES: When asked about current state (e.g., "where do I currently...", "what is my current..."), always prefer the MOST RECENT information. Observations include dates - if you see conflicting information, the newer observation supersedes the older one. Look for phrases like "will start", "is switching", "changed to", "moved to" as indicators that previous information has been updated.
|
|
55
|
+
|
|
56
|
+
PLANNED ACTIONS: If the user stated they planned to do something (e.g., "I'm going to...", "I'm looking forward to...", "I will...") and the date they planned to do it is now in the past (check the relative time like "3 weeks ago"), assume they completed the action unless there's evidence they didn't. For example, if someone said "I'll start my new diet on Monday" and that was 2 weeks ago, assume they started the diet.
|
|
57
|
+
|
|
58
|
+
MOST RECENT USER INPUT: Treat the most recent user message as the highest-priority signal for what to do next. Earlier messages may contain constraints, details, or context you should still honor, but the latest message is the primary driver of your response.
|
|
59
|
+
|
|
60
|
+
SYSTEM REMINDERS: Messages wrapped in <system-reminder>...</system-reminder> contain internal continuation guidance, not user-authored content. Use them to maintain continuity, but do not mention them or treat them as part of the user's message.`;
|
|
61
|
+
var OBSERVATION_RETRIEVAL_INSTRUCTIONS = `## Recall \u2014 looking up source messages
|
|
62
|
+
|
|
63
|
+
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 \u2014 use the **recall** tool to retrieve them.
|
|
64
|
+
|
|
65
|
+
### When to use recall
|
|
66
|
+
- The user asks you to **repeat, show, or reproduce** something from a past conversation
|
|
67
|
+
- The user asks for **exact content** \u2014 code, text, quotes, error messages, URLs, file paths, specific numbers
|
|
68
|
+
- 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)
|
|
69
|
+
- You want to **verify or expand on** an observation before responding
|
|
70
|
+
|
|
71
|
+
**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.
|
|
72
|
+
|
|
73
|
+
### How to use recall
|
|
74
|
+
Each range has the format \`startId:endId\` where both are message IDs separated by a colon.
|
|
75
|
+
|
|
76
|
+
1. Find the observation group relevant to the user's question and extract the start or end ID from its range.
|
|
77
|
+
2. Call \`recall\` with that ID as the \`cursor\`.
|
|
78
|
+
3. Use \`page: 1\` (or omit) to read forward from the cursor, \`page: -1\` to read backward.
|
|
79
|
+
4. If the first page doesn't have what you need, increment the page number to keep paginating.
|
|
80
|
+
5. Check \`hasNextPage\`/\`hasPrevPage\` in the result to know if more pages exist in each direction.
|
|
81
|
+
|
|
82
|
+
### Detail levels
|
|
83
|
+
By default recall returns **low** detail: truncated text and tool names only. Each message shows its ID and each part has a positional index like \`[p0]\`, \`[p1]\`, etc.
|
|
84
|
+
|
|
85
|
+
- 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.
|
|
86
|
+
- Use \`partIndex\` with a cursor to fetch a single part at full detail \u2014 for example, to read one specific tool result or code block without loading every part.
|
|
87
|
+
|
|
88
|
+
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.
|
|
89
|
+
|
|
90
|
+
### Following up on truncated parts
|
|
91
|
+
Low-detail results may include truncation hints like:
|
|
92
|
+
\`[truncated \u2014 call recall cursor="..." partIndex=N detail="high" for full content]\`
|
|
93
|
+
|
|
94
|
+
**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.
|
|
95
|
+
|
|
96
|
+
### When recall is NOT needed
|
|
97
|
+
- The user is asking for a high-level summary and your observations already cover it
|
|
98
|
+
- The question is about general preferences or facts that don't require source text
|
|
99
|
+
- There is no relevant range in your observations for the topic
|
|
100
|
+
|
|
101
|
+
Observation groups with range IDs and your recall tool allows you to think back and remember details you're fuzzy on.`;
|
|
102
|
+
|
|
103
|
+
export { OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTEXT_INSTRUCTIONS, OBSERVATION_CONTEXT_PROMPT, OBSERVATION_CONTINUATION_HINT, OBSERVATION_RETRIEVAL_INSTRUCTIONS };
|
|
104
|
+
//# sourceMappingURL=chunk-JMEMSVJ5.js.map
|
|
105
|
+
//# sourceMappingURL=chunk-JMEMSVJ5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../memory/src/processors/observational-memory/constants.ts"],"names":[],"mappings":";AAGO,IAAM,6BAAA,GAAgC;EAC3C,WAAA,EAAa;IACX,KAAA,EAAO,yBAAA;IACP,aAAA,EAAe,GAAA;IACf,aAAA,EAAe;MACb,WAAA,EAAa,GAAA;MACb,eAAA,EAAiB;AAAA,KAAA;IAEnB,eAAA,EAAiB;MACf,MAAA,EAAQ;QACN,cAAA,EAAgB;UACd,cAAA,EAAgB;AAAA;AAClB;AACF,KAAA;IAEF,iBAAA,EAAmB,GAAA;;IAEnB,YAAA,EAAc,GAAA;;IACd,gBAAA,EAAkB;;AAAA,GAAA;EAEpB,UAAA,EAAY;IACV,KAAA,EAAO,yBAAA;IACP,iBAAA,EAAmB,GAAA;IACnB,aAAA,EAAe;MACb,WAAA,EAAa,CAAA;;MACb,eAAA,EAAiB;AAAA,KAAA;IAEnB,eAAA,EAAiB;MACf,MAAA,EAAQ;QACN,cAAA,EAAgB;UACd,cAAA,EAAgB;AAAA;AAClB;AACF,KAAA;;IAGF,gBAAA,EAAkB;;AAAA;AAEtB;AAOO,IAAM,6BAAA,GAAgC,CAAA;;;;;;;AAatC,IAAM,0BAAA,GAA6B,CAAA,2FAAA;AAMnC,IAAM,gCAAA,GAAmC,CAAA;;;;;;;;;AAczC,IAAM,kCAAA,GAAqC,CAAA","file":"chunk-JMEMSVJ5.js","sourcesContent":["/**\n * Default configuration values matching the spec\n */\nexport const OBSERVATIONAL_MEMORY_DEFAULTS = {\n observation: {\n model: 'google/gemini-2.5-flash',\n messageTokens: 30_000,\n modelSettings: {\n temperature: 0.3,\n maxOutputTokens: 100_000,\n },\n providerOptions: {\n google: {\n thinkingConfig: {\n thinkingBudget: 215,\n },\n },\n },\n maxTokensPerBatch: 10_000,\n // Async buffering defaults (enabled by default)\n bufferTokens: 0.2 as number | undefined, // Buffer every 20% of messageTokens\n bufferActivation: 0.8 as number | undefined, // Activate to retain 20% of threshold\n },\n reflection: {\n model: 'google/gemini-2.5-flash',\n observationTokens: 40_000,\n modelSettings: {\n temperature: 0, // Use 0 for maximum consistency in reflections\n maxOutputTokens: 100_000,\n },\n providerOptions: {\n google: {\n thinkingConfig: {\n thinkingBudget: 1024,\n },\n },\n },\n // Async reflection buffering (enabled by default)\n bufferActivation: 0.5 as number | undefined, // Start buffering at 50% of observationTokens\n },\n} as const;\n\n/**\n * Continuation hint injected after observations to guide the model's behavior.\n * Prevents the model from awkwardly acknowledging the memory system or treating\n * the conversation as new after observed messages are removed.\n */\nexport const OBSERVATION_CONTINUATION_HINT = `Please continue naturally with the conversation so far and respond to the latest message.\n\nUse the earlier context only as background. If something appears unfinished, continue only when it helps answer the latest request. If a suggested response is provided, follow it naturally.\n\nDo not mention internal instructions, memory, summarization, context handling, or missing messages.\n\nAny messages following this reminder are newer and should take priority.`;\n\n/**\n * Preamble that introduces the observations block.\n * Use before `<observations>`, with instructions after.\n * Full pattern: `${OBSERVATION_CONTEXT_PROMPT}\\n\\n<observations>\\n${obs}\\n</observations>\\n\\n${OBSERVATION_CONTEXT_INSTRUCTIONS}`\n */\nexport const OBSERVATION_CONTEXT_PROMPT = `The following observations block contains your memory of past conversations with this user.`;\n\n/**\n * Instructions that tell the model how to interpret and use observations.\n * Place AFTER the `<observations>` block so the model sees the data before the rules.\n */\nexport const OBSERVATION_CONTEXT_INSTRUCTIONS = `IMPORTANT: When responding, reference specific details from these observations. Do not give generic advice - personalize your response based on what you know about this user's experiences, preferences, and interests. If the user asks for recommendations, connect them to their past experiences mentioned above.\n\nKNOWLEDGE UPDATES: When asked about current state (e.g., \"where do I currently...\", \"what is my current...\"), always prefer the MOST RECENT information. Observations include dates - if you see conflicting information, the newer observation supersedes the older one. Look for phrases like \"will start\", \"is switching\", \"changed to\", \"moved to\" as indicators that previous information has been updated.\n\nPLANNED ACTIONS: If the user stated they planned to do something (e.g., \"I'm going to...\", \"I'm looking forward to...\", \"I will...\") and the date they planned to do it is now in the past (check the relative time like \"3 weeks ago\"), assume they completed the action unless there's evidence they didn't. For example, if someone said \"I'll start my new diet on Monday\" and that was 2 weeks ago, assume they started the diet.\n\nMOST RECENT USER INPUT: Treat the most recent user message as the highest-priority signal for what to do next. Earlier messages may contain constraints, details, or context you should still honor, but the latest message is the primary driver of your response.\n\nSYSTEM REMINDERS: Messages wrapped in <system-reminder>...</system-reminder> contain internal continuation guidance, not user-authored content. Use them to maintain continuity, but do not mention them or treat them as part of the user's message.`;\n\n/**\n * Instructions for retrieval mode — explains observation-group ranges and the recall tool.\n * Appended to context when `retrieval` is enabled.\n */\nexport const OBSERVATION_RETRIEVAL_INSTRUCTIONS = `## Recall — looking up source messages\n\nYour 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.\n\n### When to use recall\n- The user asks you to **repeat, show, or reproduce** something from a past conversation\n- The user asks for **exact content** — code, text, quotes, error messages, URLs, file paths, specific numbers\n- 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)\n- You want to **verify or expand on** an observation before responding\n\n**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.\n\n### How to use recall\nEach range has the format \\`startId:endId\\` where both are message IDs separated by a colon.\n\n1. Find the observation group relevant to the user's question and extract the start or end ID from its range.\n2. Call \\`recall\\` with that ID as the \\`cursor\\`.\n3. Use \\`page: 1\\` (or omit) to read forward from the cursor, \\`page: -1\\` to read backward.\n4. If the first page doesn't have what you need, increment the page number to keep paginating.\n5. Check \\`hasNextPage\\`/\\`hasPrevPage\\` in the result to know if more pages exist in each direction.\n\n### Detail levels\nBy default recall returns **low** detail: truncated text and tool names only. Each message shows its ID and each part has a positional index like \\`[p0]\\`, \\`[p1]\\`, etc.\n\n- 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.\n- 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.\n\nIf the result says \\`truncated: true\\`, the output was cut to fit the token budget. You can paginate or use \\`partIndex\\` to target specific content.\n\n### Following up on truncated parts\nLow-detail results may include truncation hints like:\n\\`[truncated — call recall cursor=\"...\" partIndex=N detail=\"high\" for full content]\\`\n\n**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.\n\n### When recall is NOT needed\n- The user is asking for a high-level summary and your observations already cover it\n- The question is about general preferences or facts that don't require source text\n- There is no relevant range in your observations for the topic\n\nObservation groups with range IDs and your recall tool allows you to think back and remember details you're fuzzy on.`;\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { openai } from './chunk-PALNMAC6.js';
|
|
1
2
|
import { __commonJS as __commonJS$3, require_token_error as require_token_error$2, __toESM as __toESM$3 } from './chunk-JWVHBH4H.js';
|
|
2
3
|
import { __commonJS as __commonJS$1, require_token_error, __toESM } from './chunk-BZZVTO7B.js';
|
|
3
4
|
import { __commonJS as __commonJS$2, require_token_error as require_token_error$1, __toESM as __toESM$1 } from './chunk-PWAXLHKP.js';
|
|
4
|
-
import { e, truncateStringByTokens, resolveToolResultValue, formatToolResultForObserver, estimateTokenCount } from './chunk-
|
|
5
|
-
import { openai } from './chunk-PALNMAC6.js';
|
|
5
|
+
import { e, truncateStringByTokens, resolveToolResultValue, formatToolResultForObserver, estimateTokenCount } from './chunk-WICIG6YL.js';
|
|
6
6
|
import { LIST_WORKFLOWS_ROUTE, GET_WORKFLOW_BY_ID_ROUTE, LIST_WORKFLOW_RUNS_ROUTE, GET_WORKFLOW_RUN_BY_ID_ROUTE, CREATE_WORKFLOW_RUN_ROUTE, STREAM_WORKFLOW_ROUTE, START_ASYNC_WORKFLOW_ROUTE, START_WORKFLOW_RUN_ROUTE, OBSERVE_STREAM_WORKFLOW_ROUTE, RESUME_ASYNC_WORKFLOW_ROUTE, RESUME_WORKFLOW_ROUTE, RESUME_STREAM_WORKFLOW_ROUTE, CANCEL_WORKFLOW_RUN_ROUTE, STREAM_LEGACY_WORKFLOW_ROUTE, OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE } from './chunk-G2ZZKKQI.js';
|
|
7
7
|
import { actionIdPathParams, actionRunPathParams, streamAgentBuilderBodySchema, startAsyncAgentBuilderBodySchema, resumeAgentBuilderBodySchema, streamLegacyAgentBuilderBodySchema } from './chunk-S7PYDU5I.js';
|
|
8
8
|
import { listWorkflowsResponseSchema, workflowInfoSchema, workflowRunsResponseSchema, listWorkflowRunsQuerySchema, workflowRunResultSchema, workflowRunResultQuerySchema, createWorkflowRunResponseSchema, workflowExecutionResultSchema, workflowControlResponseSchema } from './chunk-7X4P2I6L.js';
|
|
@@ -16763,6 +16763,14 @@ var DEFAULT_MESSAGE_RANGE = { before: 1, after: 1 };
|
|
|
16763
16763
|
var DEFAULT_TOP_K = 4;
|
|
16764
16764
|
var VECTOR_DELETE_BATCH_SIZE = 100;
|
|
16765
16765
|
var Memory = class extends MastraMemory {
|
|
16766
|
+
_omEngine;
|
|
16767
|
+
/** The shared ObservationalMemory engine. Lazily created on first access. */
|
|
16768
|
+
get omEngine() {
|
|
16769
|
+
if (!this._omEngine) {
|
|
16770
|
+
this._omEngine = this._initOMEngine();
|
|
16771
|
+
}
|
|
16772
|
+
return this._omEngine;
|
|
16773
|
+
}
|
|
16766
16774
|
constructor(config = {}) {
|
|
16767
16775
|
super({ name: "Memory", ...config });
|
|
16768
16776
|
const mergedConfig = this.getMergedThreadConfig({
|
|
@@ -17403,6 +17411,179 @@ ${workingMemory}`;
|
|
|
17403
17411
|
data: workingMemoryData
|
|
17404
17412
|
});
|
|
17405
17413
|
}
|
|
17414
|
+
/**
|
|
17415
|
+
* Get everything needed for an LLM call in one shot.
|
|
17416
|
+
*
|
|
17417
|
+
* Assembles the system message (observations + working memory), loads
|
|
17418
|
+
* unobserved messages from storage, and returns them ready to use.
|
|
17419
|
+
*
|
|
17420
|
+
* @example
|
|
17421
|
+
* ```ts
|
|
17422
|
+
* const ctx = await memory.getContext({ threadId });
|
|
17423
|
+
* const result = await generateText({
|
|
17424
|
+
* model: openai('gpt-4o'),
|
|
17425
|
+
* system: ctx.systemMessage,
|
|
17426
|
+
* messages: ctx.messages.map(toAiSdkMessage),
|
|
17427
|
+
* });
|
|
17428
|
+
* ```
|
|
17429
|
+
*/
|
|
17430
|
+
async getContext(opts) {
|
|
17431
|
+
const { threadId, resourceId, memoryConfig } = opts;
|
|
17432
|
+
const config = this.getMergedThreadConfig(memoryConfig);
|
|
17433
|
+
const memoryStore = await this.getMemoryStore();
|
|
17434
|
+
const systemParts = [];
|
|
17435
|
+
let hasObservations = false;
|
|
17436
|
+
let omRecord = null;
|
|
17437
|
+
let continuationMessage;
|
|
17438
|
+
let otherThreadsContext;
|
|
17439
|
+
const omEngine = await this.omEngine;
|
|
17440
|
+
if (omEngine) {
|
|
17441
|
+
omRecord = await omEngine.getRecord(threadId, resourceId);
|
|
17442
|
+
if (omRecord?.activeObservations) {
|
|
17443
|
+
hasObservations = true;
|
|
17444
|
+
if (omEngine.scope === "resource" && resourceId) {
|
|
17445
|
+
otherThreadsContext = await omEngine.getOtherThreadsContext(resourceId, threadId);
|
|
17446
|
+
}
|
|
17447
|
+
const obsSystemMessage = await omEngine.buildContextSystemMessage({
|
|
17448
|
+
threadId,
|
|
17449
|
+
resourceId,
|
|
17450
|
+
record: omRecord,
|
|
17451
|
+
unobservedContextBlocks: otherThreadsContext
|
|
17452
|
+
});
|
|
17453
|
+
if (obsSystemMessage) {
|
|
17454
|
+
systemParts.push(obsSystemMessage);
|
|
17455
|
+
}
|
|
17456
|
+
const { OBSERVATION_CONTINUATION_HINT } = await import('./constants-BDOITAO3-PCCYSQXK.js');
|
|
17457
|
+
continuationMessage = {
|
|
17458
|
+
id: "om-continuation",
|
|
17459
|
+
role: "user",
|
|
17460
|
+
createdAt: /* @__PURE__ */ new Date(0),
|
|
17461
|
+
content: {
|
|
17462
|
+
format: 2,
|
|
17463
|
+
parts: [
|
|
17464
|
+
{
|
|
17465
|
+
type: "text",
|
|
17466
|
+
text: `<system-reminder>${OBSERVATION_CONTINUATION_HINT}</system-reminder>`
|
|
17467
|
+
}
|
|
17468
|
+
]
|
|
17469
|
+
},
|
|
17470
|
+
threadId,
|
|
17471
|
+
resourceId
|
|
17472
|
+
};
|
|
17473
|
+
}
|
|
17474
|
+
}
|
|
17475
|
+
const workingMemoryMessage = await this.getSystemMessage({ threadId, resourceId, memoryConfig: config });
|
|
17476
|
+
if (workingMemoryMessage) {
|
|
17477
|
+
systemParts.push(workingMemoryMessage);
|
|
17478
|
+
}
|
|
17479
|
+
let messages;
|
|
17480
|
+
if (omEngine && omRecord) {
|
|
17481
|
+
const dateFilter = omRecord.lastObservedAt ? { dateRange: { start: new Date(new Date(omRecord.lastObservedAt).getTime() + 1) } } : void 0;
|
|
17482
|
+
if (omEngine.scope === "resource" && resourceId) {
|
|
17483
|
+
const result = await memoryStore.listMessagesByResourceId({
|
|
17484
|
+
resourceId,
|
|
17485
|
+
orderBy: { field: "createdAt", direction: "ASC" },
|
|
17486
|
+
perPage: false,
|
|
17487
|
+
filter: dateFilter
|
|
17488
|
+
});
|
|
17489
|
+
messages = result.messages;
|
|
17490
|
+
} else {
|
|
17491
|
+
const result = await memoryStore.listMessages({
|
|
17492
|
+
threadId,
|
|
17493
|
+
orderBy: { field: "createdAt", direction: "ASC" },
|
|
17494
|
+
perPage: false,
|
|
17495
|
+
filter: dateFilter
|
|
17496
|
+
});
|
|
17497
|
+
messages = result.messages;
|
|
17498
|
+
}
|
|
17499
|
+
} else {
|
|
17500
|
+
const lastMessages = config.lastMessages;
|
|
17501
|
+
if (lastMessages === false) {
|
|
17502
|
+
messages = [];
|
|
17503
|
+
} else {
|
|
17504
|
+
const result = await memoryStore.listMessages({
|
|
17505
|
+
threadId,
|
|
17506
|
+
resourceId,
|
|
17507
|
+
orderBy: { field: "createdAt", direction: "DESC" },
|
|
17508
|
+
perPage: typeof lastMessages === "number" ? lastMessages : void 0
|
|
17509
|
+
});
|
|
17510
|
+
messages = result.messages.reverse();
|
|
17511
|
+
}
|
|
17512
|
+
}
|
|
17513
|
+
return {
|
|
17514
|
+
systemMessage: systemParts.length > 0 ? systemParts.join("\n\n") : void 0,
|
|
17515
|
+
messages,
|
|
17516
|
+
hasObservations,
|
|
17517
|
+
omRecord,
|
|
17518
|
+
continuationMessage,
|
|
17519
|
+
otherThreadsContext
|
|
17520
|
+
};
|
|
17521
|
+
}
|
|
17522
|
+
/**
|
|
17523
|
+
* Raw message upsert — persist messages to storage without embedding or working memory processing.
|
|
17524
|
+
* Used by the processor to save sealed messages before firing a background buffer operation.
|
|
17525
|
+
*/
|
|
17526
|
+
async persistMessages(messages) {
|
|
17527
|
+
if (messages.length === 0) return;
|
|
17528
|
+
const memoryStore = await this.getMemoryStore();
|
|
17529
|
+
await memoryStore.saveMessages({ messages });
|
|
17530
|
+
}
|
|
17531
|
+
/**
|
|
17532
|
+
* One-time initialization of the shared ObservationalMemory engine.
|
|
17533
|
+
* Called lazily by the `omEngine` getter on first access.
|
|
17534
|
+
*/
|
|
17535
|
+
async _initOMEngine() {
|
|
17536
|
+
const omConfig = normalizeObservationalMemoryConfig(this.threadConfig.observationalMemory);
|
|
17537
|
+
if (!omConfig) return null;
|
|
17538
|
+
const memoryStore = await this.storage.getStore("memory");
|
|
17539
|
+
if (!memoryStore || !memoryStore.supportsObservationalMemory) return null;
|
|
17540
|
+
const coreSupportsOM = coreFeatures.has("observationalMemory");
|
|
17541
|
+
if (!coreSupportsOM) {
|
|
17542
|
+
throw new Error(
|
|
17543
|
+
"Observational memory is enabled but the installed version of @mastra/core does not support it. Please upgrade @mastra/core to a version that includes observational memory support."
|
|
17544
|
+
);
|
|
17545
|
+
}
|
|
17546
|
+
if (omConfig.observation?.bufferTokens !== false && !coreFeatures.has("asyncBuffering")) {
|
|
17547
|
+
throw new Error(
|
|
17548
|
+
"Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, or @mastra/mongodb) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
|
|
17549
|
+
);
|
|
17550
|
+
}
|
|
17551
|
+
if (!coreFeatures.has("request-response-id-rotation")) {
|
|
17552
|
+
throw new Error(
|
|
17553
|
+
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
17554
|
+
);
|
|
17555
|
+
}
|
|
17556
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-WMCWT577-EDKAVK3W.js');
|
|
17557
|
+
return new OMClass({
|
|
17558
|
+
storage: memoryStore,
|
|
17559
|
+
scope: omConfig.scope,
|
|
17560
|
+
retrieval: omConfig.retrieval,
|
|
17561
|
+
shareTokenBudget: omConfig.shareTokenBudget,
|
|
17562
|
+
model: omConfig.model,
|
|
17563
|
+
observation: omConfig.observation ? {
|
|
17564
|
+
model: omConfig.observation.model,
|
|
17565
|
+
messageTokens: omConfig.observation.messageTokens,
|
|
17566
|
+
modelSettings: omConfig.observation.modelSettings,
|
|
17567
|
+
maxTokensPerBatch: omConfig.observation.maxTokensPerBatch,
|
|
17568
|
+
providerOptions: omConfig.observation.providerOptions,
|
|
17569
|
+
bufferTokens: omConfig.observation.bufferTokens,
|
|
17570
|
+
bufferActivation: omConfig.observation.bufferActivation,
|
|
17571
|
+
blockAfter: omConfig.observation.blockAfter,
|
|
17572
|
+
previousObserverTokens: omConfig.observation.previousObserverTokens,
|
|
17573
|
+
instruction: omConfig.observation.instruction,
|
|
17574
|
+
threadTitle: omConfig.observation.threadTitle
|
|
17575
|
+
} : void 0,
|
|
17576
|
+
reflection: omConfig.reflection ? {
|
|
17577
|
+
model: omConfig.reflection.model,
|
|
17578
|
+
observationTokens: omConfig.reflection.observationTokens,
|
|
17579
|
+
modelSettings: omConfig.reflection.modelSettings,
|
|
17580
|
+
providerOptions: omConfig.reflection.providerOptions,
|
|
17581
|
+
bufferActivation: omConfig.reflection.bufferActivation,
|
|
17582
|
+
blockAfter: omConfig.reflection.blockAfter,
|
|
17583
|
+
instruction: omConfig.reflection.instruction
|
|
17584
|
+
} : void 0
|
|
17585
|
+
});
|
|
17586
|
+
}
|
|
17406
17587
|
defaultWorkingMemoryTemplate = `
|
|
17407
17588
|
# User Information
|
|
17408
17589
|
- **First Name**:
|
|
@@ -18064,81 +18245,29 @@ Notes:
|
|
|
18064
18245
|
return processors;
|
|
18065
18246
|
}
|
|
18066
18247
|
/**
|
|
18067
|
-
* Creates an ObservationalMemory processor
|
|
18068
|
-
*
|
|
18069
|
-
*
|
|
18248
|
+
* Creates an ObservationalMemory processor wrapping the shared engine.
|
|
18249
|
+
* Returns null if OM is not configured, not supported, or already present
|
|
18250
|
+
* in the user's configured processors.
|
|
18070
18251
|
*/
|
|
18071
18252
|
async createOMProcessor(configuredProcessors = [], context2) {
|
|
18072
18253
|
const hasObservationalMemory = configuredProcessors.some(
|
|
18073
18254
|
(p) => !("workflow" in p) && p.id === "observational-memory"
|
|
18074
18255
|
);
|
|
18075
|
-
|
|
18076
|
-
const
|
|
18077
|
-
const
|
|
18078
|
-
|
|
18079
|
-
|
|
18256
|
+
if (hasObservationalMemory) return null;
|
|
18257
|
+
const runtimeMemory = context2?.get("MastraMemory");
|
|
18258
|
+
const runtimeObservationalMemory = normalizeObservationalMemoryConfig(
|
|
18259
|
+
runtimeMemory?.memoryConfig?.observationalMemory
|
|
18260
|
+
);
|
|
18261
|
+
const threadConfig = runtimeObservationalMemory ? this.getMergedThreadConfig({
|
|
18262
|
+
...runtimeMemory?.memoryConfig,
|
|
18263
|
+
observationalMemory: runtimeObservationalMemory
|
|
18080
18264
|
}) : this.threadConfig;
|
|
18081
|
-
const
|
|
18082
|
-
if (!
|
|
18083
|
-
|
|
18084
|
-
|
|
18085
|
-
const
|
|
18086
|
-
|
|
18087
|
-
throw new Error(
|
|
18088
|
-
"Observational memory is enabled but the installed version of @mastra/core does not support it. Please upgrade @mastra/core to a version that includes observational memory support."
|
|
18089
|
-
);
|
|
18090
|
-
}
|
|
18091
|
-
const memoryStore = await this.storage.getStore("memory");
|
|
18092
|
-
if (!memoryStore) {
|
|
18093
|
-
throw new Error(
|
|
18094
|
-
"Using Mastra Memory observational memory requires a storage adapter but no attached adapter was detected."
|
|
18095
|
-
);
|
|
18096
|
-
}
|
|
18097
|
-
if (!memoryStore.supportsObservationalMemory) {
|
|
18098
|
-
throw new Error(
|
|
18099
|
-
`Observational memory is enabled but the storage adapter (${memoryStore.constructor.name}) does not support it. If you're using @mastra/libsql, @mastra/pg, or @mastra/mongodb, upgrade to the latest version. Otherwise, use one of those adapters or disable observational memory.`
|
|
18100
|
-
);
|
|
18101
|
-
}
|
|
18102
|
-
if (omConfig.observation?.bufferTokens !== false && !coreFeatures.has("asyncBuffering")) {
|
|
18103
|
-
throw new Error(
|
|
18104
|
-
"Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, or @mastra/mongodb) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
|
|
18105
|
-
);
|
|
18106
|
-
}
|
|
18107
|
-
if (!coreFeatures.has("request-response-id-rotation")) {
|
|
18108
|
-
throw new Error(
|
|
18109
|
-
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
18110
|
-
);
|
|
18111
|
-
}
|
|
18112
|
-
const { ObservationalMemory } = await import('./observational-memory-NMQ7URIP-FOPRYAC2.js');
|
|
18113
|
-
return new ObservationalMemory({
|
|
18114
|
-
storage: memoryStore,
|
|
18115
|
-
scope: omConfig.scope,
|
|
18116
|
-
retrieval: omConfig.retrieval,
|
|
18117
|
-
shareTokenBudget: omConfig.shareTokenBudget,
|
|
18118
|
-
model: omConfig.model,
|
|
18119
|
-
observation: omConfig.observation ? {
|
|
18120
|
-
model: omConfig.observation.model,
|
|
18121
|
-
messageTokens: omConfig.observation.messageTokens,
|
|
18122
|
-
modelSettings: omConfig.observation.modelSettings,
|
|
18123
|
-
maxTokensPerBatch: omConfig.observation.maxTokensPerBatch,
|
|
18124
|
-
providerOptions: omConfig.observation.providerOptions,
|
|
18125
|
-
bufferTokens: omConfig.observation.bufferTokens,
|
|
18126
|
-
bufferActivation: omConfig.observation.bufferActivation,
|
|
18127
|
-
blockAfter: omConfig.observation.blockAfter,
|
|
18128
|
-
previousObserverTokens: omConfig.observation.previousObserverTokens,
|
|
18129
|
-
instruction: omConfig.observation.instruction,
|
|
18130
|
-
threadTitle: omConfig.observation.threadTitle
|
|
18131
|
-
} : void 0,
|
|
18132
|
-
reflection: omConfig.reflection ? {
|
|
18133
|
-
model: omConfig.reflection.model,
|
|
18134
|
-
observationTokens: omConfig.reflection.observationTokens,
|
|
18135
|
-
modelSettings: omConfig.reflection.modelSettings,
|
|
18136
|
-
providerOptions: omConfig.reflection.providerOptions,
|
|
18137
|
-
bufferActivation: omConfig.reflection.bufferActivation,
|
|
18138
|
-
blockAfter: omConfig.reflection.blockAfter,
|
|
18139
|
-
instruction: omConfig.reflection.instruction
|
|
18140
|
-
} : void 0
|
|
18141
|
-
});
|
|
18265
|
+
const effectiveConfig = normalizeObservationalMemoryConfig(threadConfig.observationalMemory);
|
|
18266
|
+
if (!effectiveConfig) return null;
|
|
18267
|
+
const engine = await this.omEngine;
|
|
18268
|
+
if (!engine) return null;
|
|
18269
|
+
const { ObservationalMemoryProcessor } = await import('./observational-memory-WMCWT577-EDKAVK3W.js');
|
|
18270
|
+
return new ObservationalMemoryProcessor(engine, this);
|
|
18142
18271
|
}
|
|
18143
18272
|
};
|
|
18144
18273
|
|
|
@@ -29338,5 +29467,5 @@ var OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({
|
|
|
29338
29467
|
});
|
|
29339
29468
|
|
|
29340
29469
|
export { CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE, CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE, GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE, GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE, LIST_AGENT_BUILDER_ACTIONS_ROUTE, LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE, OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE, OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, RESUME_AGENT_BUILDER_ACTION_ROUTE, RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE, RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE, START_AGENT_BUILDER_ACTION_RUN_ROUTE, START_ASYNC_AGENT_BUILDER_ACTION_ROUTE, STREAM_AGENT_BUILDER_ACTION_ROUTE, STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, agent_builder_exports };
|
|
29341
|
-
//# sourceMappingURL=chunk-
|
|
29342
|
-
//# sourceMappingURL=chunk-
|
|
29470
|
+
//# sourceMappingURL=chunk-PZE5ZBAX.js.map
|
|
29471
|
+
//# sourceMappingURL=chunk-PZE5ZBAX.js.map
|