@mastra/memory 1.10.0 → 1.10.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/dist/{chunk-7A3UGAXY.js → chunk-2QSOQQPM.js} +6817 -6611
  3. package/dist/chunk-2QSOQQPM.js.map +1 -0
  4. package/dist/chunk-D4J4XPGM.cjs +111 -0
  5. package/dist/chunk-D4J4XPGM.cjs.map +1 -0
  6. package/dist/chunk-LSJJAJAF.js +105 -0
  7. package/dist/chunk-LSJJAJAF.js.map +1 -0
  8. package/dist/{chunk-EVBFYGDL.cjs → chunk-NS47X3OB.cjs} +6808 -6605
  9. package/dist/chunk-NS47X3OB.cjs.map +1 -0
  10. package/dist/constants-BDOITAO3.js +3 -0
  11. package/dist/constants-BDOITAO3.js.map +1 -0
  12. package/dist/constants-HXOCZPB7.cjs +28 -0
  13. package/dist/constants-HXOCZPB7.cjs.map +1 -0
  14. package/dist/docs/SKILL.md +1 -1
  15. package/dist/docs/assets/SOURCE_MAP.json +67 -61
  16. package/dist/docs/references/docs-memory-observational-memory.md +7 -5
  17. package/dist/docs/references/reference-memory-observational-memory.md +2 -2
  18. package/dist/index.cjs +207 -78
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +52 -5
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +200 -71
  23. package/dist/index.js.map +1 -1
  24. package/dist/{observational-memory-COYJCVX3.cjs → observational-memory-I5UTOG63.cjs} +46 -41
  25. package/dist/{observational-memory-COYJCVX3.cjs.map → observational-memory-I5UTOG63.cjs.map} +1 -1
  26. package/dist/observational-memory-WMCWT577.js +4 -0
  27. package/dist/{observational-memory-K2U3QQIO.js.map → observational-memory-WMCWT577.js.map} +1 -1
  28. package/dist/processors/index.cjs +44 -39
  29. package/dist/processors/index.js +2 -1
  30. package/dist/processors/observational-memory/buffering-coordinator.d.ts +61 -0
  31. package/dist/processors/observational-memory/buffering-coordinator.d.ts.map +1 -0
  32. package/dist/processors/observational-memory/constants.d.ts +62 -0
  33. package/dist/processors/observational-memory/constants.d.ts.map +1 -0
  34. package/dist/processors/observational-memory/debug.d.ts +3 -0
  35. package/dist/processors/observational-memory/debug.d.ts.map +1 -0
  36. package/dist/processors/observational-memory/index.d.ts +5 -2
  37. package/dist/processors/observational-memory/index.d.ts.map +1 -1
  38. package/dist/processors/observational-memory/message-utils.d.ts +69 -0
  39. package/dist/processors/observational-memory/message-utils.d.ts.map +1 -0
  40. package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts +33 -0
  41. package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -0
  42. package/dist/processors/observational-memory/observation-strategies/base.d.ts +102 -0
  43. package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +1 -0
  44. package/dist/processors/observational-memory/observation-strategies/index.d.ts +7 -0
  45. package/dist/processors/observational-memory/observation-strategies/index.d.ts.map +1 -0
  46. package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts +39 -0
  47. package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +1 -0
  48. package/dist/processors/observational-memory/observation-strategies/sync.d.ts +35 -0
  49. package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -0
  50. package/dist/processors/observational-memory/observation-strategies/types.d.ts +55 -0
  51. package/dist/processors/observational-memory/observation-strategies/types.d.ts.map +1 -0
  52. package/dist/processors/observational-memory/observation-turn/index.d.ts +4 -0
  53. package/dist/processors/observational-memory/observation-turn/index.d.ts.map +1 -0
  54. package/dist/processors/observational-memory/observation-turn/step.d.ts +34 -0
  55. package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -0
  56. package/dist/processors/observational-memory/observation-turn/turn.d.ts +84 -0
  57. package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -0
  58. package/dist/processors/observational-memory/observation-turn/types.d.ts +38 -0
  59. package/dist/processors/observational-memory/observation-turn/types.d.ts.map +1 -0
  60. package/dist/processors/observational-memory/observational-memory.d.ts +388 -553
  61. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  62. package/dist/processors/observational-memory/observer-runner.d.ts +65 -0
  63. package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -0
  64. package/dist/processors/observational-memory/processor.d.ts +70 -0
  65. package/dist/processors/observational-memory/processor.d.ts.map +1 -0
  66. package/dist/processors/observational-memory/reflector-runner.d.ts +95 -0
  67. package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -0
  68. package/dist/processors/observational-memory/types.d.ts +157 -0
  69. package/dist/processors/observational-memory/types.d.ts.map +1 -1
  70. package/package.json +2 -2
  71. package/dist/chunk-7A3UGAXY.js.map +0 -1
  72. package/dist/chunk-EVBFYGDL.cjs.map +0 -1
  73. package/dist/observational-memory-K2U3QQIO.js +0 -3
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ // src/processors/observational-memory/constants.ts
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-D4J4XPGM.cjs.map
111
+ //# sourceMappingURL=chunk-D4J4XPGM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/processors/observational-memory/constants.ts"],"names":[],"mappings":";;;AAGO,IAAM,6BAAA,GAAgC;AAAA,EAC3C,WAAA,EAAa;AAAA,IACX,KAAA,EAAO,yBAAA;AAAA,IACP,aAAA,EAAe,GAAA;AAAA,IACf,aAAA,EAAe;AAAA,MACb,WAAA,EAAa,GAAA;AAAA,MACb,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,MAAA,EAAQ;AAAA,QACN,cAAA,EAAgB;AAAA,UACd,cAAA,EAAgB;AAAA;AAClB;AACF,KACF;AAAA,IACA,iBAAA,EAAmB,GAAA;AAAA;AAAA,IAEnB,YAAA,EAAc,GAAA;AAAA;AAAA,IACd,gBAAA,EAAkB;AAAA;AAAA,GACpB;AAAA,EACA,UAAA,EAAY;AAAA,IACV,KAAA,EAAO,yBAAA;AAAA,IACP,iBAAA,EAAmB,GAAA;AAAA,IACnB,aAAA,EAAe;AAAA,MACb,WAAA,EAAa,CAAA;AAAA;AAAA,MACb,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,MAAA,EAAQ;AAAA,QACN,cAAA,EAAgB;AAAA,UACd,cAAA,EAAgB;AAAA;AAClB;AACF,KACF;AAAA;AAAA,IAEA,gBAAA,EAAkB;AAAA;AAAA;AAEtB;AAOO,IAAM,6BAAA,GAAgC,CAAA;;AAAA;;AAAA;;AAAA,wEAAA;AAatC,IAAM,0BAAA,GAA6B,CAAA,2FAAA;AAMnC,IAAM,gCAAA,GAAmC,CAAA;;AAAA;;AAAA;;AAAA;;AAAA,qPAAA;AAczC,IAAM,kCAAA,GAAqC,CAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA,qHAAA","file":"chunk-D4J4XPGM.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
+ // src/processors/observational-memory/constants.ts
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-LSJJAJAF.js.map
105
+ //# sourceMappingURL=chunk-LSJJAJAF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/processors/observational-memory/constants.ts"],"names":[],"mappings":";AAGO,IAAM,6BAAA,GAAgC;AAAA,EAC3C,WAAA,EAAa;AAAA,IACX,KAAA,EAAO,yBAAA;AAAA,IACP,aAAA,EAAe,GAAA;AAAA,IACf,aAAA,EAAe;AAAA,MACb,WAAA,EAAa,GAAA;AAAA,MACb,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,MAAA,EAAQ;AAAA,QACN,cAAA,EAAgB;AAAA,UACd,cAAA,EAAgB;AAAA;AAClB;AACF,KACF;AAAA,IACA,iBAAA,EAAmB,GAAA;AAAA;AAAA,IAEnB,YAAA,EAAc,GAAA;AAAA;AAAA,IACd,gBAAA,EAAkB;AAAA;AAAA,GACpB;AAAA,EACA,UAAA,EAAY;AAAA,IACV,KAAA,EAAO,yBAAA;AAAA,IACP,iBAAA,EAAmB,GAAA;AAAA,IACnB,aAAA,EAAe;AAAA,MACb,WAAA,EAAa,CAAA;AAAA;AAAA,MACb,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,MAAA,EAAQ;AAAA,QACN,cAAA,EAAgB;AAAA,UACd,cAAA,EAAgB;AAAA;AAClB;AACF,KACF;AAAA;AAAA,IAEA,gBAAA,EAAkB;AAAA;AAAA;AAEtB;AAOO,IAAM,6BAAA,GAAgC,CAAA;;AAAA;;AAAA;;AAAA,wEAAA;AAatC,IAAM,0BAAA,GAA6B,CAAA,2FAAA;AAMnC,IAAM,gCAAA,GAAmC,CAAA;;AAAA;;AAAA;;AAAA;;AAAA,qPAAA;AAczC,IAAM,kCAAA,GAAqC,CAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA,qHAAA","file":"chunk-LSJJAJAF.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"]}