@mastra/memory 1.28.1 → 1.28.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.28.2-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Improve tool schema compatibility with providers that validate tool definitions server-side. ([#22487](https://github.com/mastra-ai/mastra/pull/22487))
8
+
9
+ - Fixed observational memory prompts appearing in stored conversation history. ([#22324](https://github.com/mastra-ai/mastra/pull/22324))
10
+
3
11
  ## 1.28.1
4
12
 
5
13
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-memory
3
3
  description: Documentation for @mastra/memory. Use when working with @mastra/memory APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/memory"
6
- version: "1.28.1"
6
+ version: "1.28.2-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -16,59 +16,59 @@ Read the individual reference documents for detailed explanations and code examp
16
16
 
17
17
  ### Docs
18
18
 
19
- - [Human-in-the-loop](references/docs-agents-human-in-the-loop.md) - Learn how to require approvals and suspend tool execution, plus automatically resume suspended tools while keeping humans in control of agent workflows.
20
- - [Agent networks](references/docs-agents-networks.md) - Coordinate multiple agents, workflows, and tools using agent networks for complex, non-deterministic task execution.
21
- - [Evals with memory](references/docs-evals-evals-with-memory.md) - Run scorers against memory-enabled agents, including observational memory in thread scope, using runEvals and dataset experiments.
22
- - [Context engineering](references/docs-guides-context-engineering.md) - Learn how to choose, retrieve, persist, and control the context a Mastra agent receives.
23
- - [Background tasks](references/docs-harness-background-tasks.md) - Learn how to dispatch long-running tool calls in the background and keep the stream open until they complete, plus orchestrate subagents asynchronously.
24
- - [Goals](references/docs-harness-goals.md) - Learn how to set a durable objective on an agent that's judged in the execution loop, so the agent keeps working until the goal is complete or the run budget is exhausted.
25
- - [Memory processors](references/docs-memory-memory-processors.md) - Learn how to use memory processors in Mastra to filter, trim, and transform messages before they're sent to the language model to manage context window limits.
26
- - [Message history](references/docs-memory-message-history.md) - Learn how to configure message history in Mastra to store recent messages from the current conversation.
27
- - [Multi-user threads](references/docs-memory-multi-user-threads.md) - Share one Mastra thread between multiple users by carrying speaker identity in the message body.
28
- - [Observational Memory](references/docs-memory-observational-memory.md) - Learn how Observational Memory keeps your agent's context window small while preserving long-term memory across conversations.
29
- - [Memory](references/docs-memory-overview.md) - Learn how Mastra's memory system works with working memory, message history, semantic recall, and observational memory.
30
- - [Semantic recall](references/docs-memory-semantic-recall.md) - Learn how to use semantic recall in Mastra to retrieve relevant messages from past conversations using vector search and embeddings.
31
- - [Working memory](references/docs-memory-working-memory.md) - Learn how to configure working memory in Mastra to store persistent user data, preferences.
32
- - [Storage](references/docs-storage.md) - Configure storage for Mastra to persist runtime state across agents, workflows, observability, evals, schedules, and memory.
33
- - [Subagents](references/docs-subagents.md) - Learn how to coordinate multiple agents with delegation hooks, iteration monitoring, message filtering, and task completion scoring.
19
+ - [Human-in-the-loop](references/docs-agents-human-in-the-loop.md) - Add human-in-the-loop controls to Mastra agents with tool approval and suspended execution, so people can provide input before a run resumes or stops.
20
+ - [Agent networks](references/docs-agents-networks.md) - Understand deprecated Mastra agent networks, including multi-agent routing, structured output, tool approvals, and migration to supervisor agents.
21
+ - [Evals with memory](references/docs-evals-evals-with-memory.md) - Run Mastra evals against memory-enabled agents using shared or per-item threads, observational memory, runEvals, and dataset experiments.
22
+ - [Context engineering](references/docs-guides-context-engineering.md) - Engineer the context Mastra agents receive by combining instructions, inline data, tools, RAG, filesystems, memory, and observational memory.
23
+ - [Background tasks](references/docs-harness-background-tasks.md) - Run long-lived Mastra tool calls and subagents as background tasks while streams remain open, with configurable LLM behavior and completion events.
24
+ - [Goals](references/docs-harness-goals.md) - Set a durable goal for a Mastra agent so an execution loop evaluates progress and continues working until the objective completes or its run budget ends.
25
+ - [Memory processors](references/docs-memory-memory-processors.md) - Configure Mastra memory processors to filter, trim, transform, and deduplicate messages before they reach the model while managing context limits.
26
+ - [Message history](references/docs-memory-message-history.md) - Store and retrieve recent Mastra conversation messages, configure history limits and thread titles, and query threads for chat interfaces.
27
+ - [Multi-user threads](references/docs-memory-multi-user-threads.md) - Share one Mastra memory thread across multiple users by preserving speaker identity in messages and combining history with observational or working memory.
28
+ - [Observational Memory](references/docs-memory-observational-memory.md) - Configure Mastra Observational Memory to compress long conversations into durable observations while preserving context across threads and sessions.
29
+ - [Memory](references/docs-memory-overview.md) - Add memory to Mastra agents with message history, semantic recall, working memory, and observational memory across threads and multi-agent delegation.
30
+ - [Semantic recall](references/docs-memory-semantic-recall.md) - Retrieve relevant messages from past Mastra conversations with semantic recall, vector search, embeddings, metadata filters, and configurable storage.
31
+ - [Working memory](references/docs-memory-working-memory.md) - Persist user profiles, preferences, and application data with Mastra working memory using resource- or thread-scoped templates and storage adapters.
32
+ - [Storage](references/docs-storage.md) - Configure Mastra storage to persist memory, workflow state, observability data, evals, schedules, and long-running agent state across restarts.
33
+ - [Subagents](references/docs-subagents.md) - Build Mastra supervisor agents that delegate work to specialized subagents with hooks, request context, message filtering, and completion scoring.
34
34
 
35
35
  ### Integrations
36
36
 
37
- - [GitHub](references/integrations-channels-github.md) - Notify a Mastra agent when subscribed GitHub pull requests change.
38
- - [Aurora DSQL](references/integrations-databases-aurora-dsql.md) - Documentation for the Amazon Aurora DSQL storage implementation in Mastra.
39
- - [DynamoDB](references/integrations-databases-dynamodb.md) - Documentation for the DynamoDB storage implementation in Mastra, using a single-table design with ElectroDB.
40
- - [Elasticsearch](references/integrations-databases-elasticsearch.md) - Documentation for the Elasticsearch storage implementation in Mastra.
41
- - [libSQL](references/integrations-databases-libsql.md) - Documentation for the libSQL storage implementation in Mastra.
42
- - [MongoDB](references/integrations-databases-mongodb.md) - Documentation for the MongoDB storage implementation in Mastra.
43
- - [OracleDB](references/integrations-databases-oracledb.md) - Documentation for the Oracle Database storage provider in Mastra.
44
- - [PostgreSQL](references/integrations-databases-postgresql.md) - Documentation for the PostgreSQL storage implementation in Mastra.
45
- - [Redis](references/integrations-databases-redis.md) - Documentation for the Redis storage implementation in Mastra.
46
- - [Upstash](references/integrations-databases-upstash.md) - Documentation for the Upstash storage implementation in Mastra.
47
- - [Valkey](references/integrations-databases-valkey.md) - Documentation for the GLIDE-backed Valkey storage implementation in Mastra.
37
+ - [GitHub](references/integrations-channels-github.md) - Subscribe Mastra agents to GitHub pull requests with @mastra/github-signals, polling modes, notification signals, and subscription management tools.
38
+ - [Aurora DSQL](references/integrations-databases-aurora-dsql.md) - Store Mastra application data in Amazon Aurora DSQL with IAM authentication, configurable credentials, schema initialization, and connection options.
39
+ - [DynamoDB](references/integrations-databases-dynamodb.md) - Persist Mastra data in Amazon DynamoDB with a single-table ElectroDB design, configurable indexes, TTL support, credentials, and table initialization.
40
+ - [Elasticsearch](references/integrations-databases-elasticsearch.md) - Store Mastra agent memory, workflow snapshots, and scores in Elasticsearch with URL, authentication, or shared client connection configuration.
41
+ - [libSQL](references/integrations-databases-libsql.md) - Persist Mastra messages, workflow snapshots, traces, and eval scores in local or remote libSQL with managed tables and initialization options.
42
+ - [MongoDB](references/integrations-databases-mongodb.md) - Store Mastra application data and vectors in MongoDB, configure connections and collections, initialize schemas, and add persistent agent memory.
43
+ - [OracleDB](references/integrations-databases-oracledb.md) - Persist Mastra memory, workflows, observability, scores, MCP metadata, and agent registry data in Oracle Database with OracleStore.
44
+ - [PostgreSQL](references/integrations-databases-postgresql.md) - Persist Mastra application data in PostgreSQL with PostgresStore, configure connections and pools, initialize schemas, and enable observability.
45
+ - [Redis](references/integrations-databases-redis.md) - Store Mastra application data in Redis using connection strings, host settings, or custom clients, including Sentinel and Cluster deployments.
46
+ - [Upstash](references/integrations-databases-upstash.md) - Use Upstash Redis as serverless Mastra storage with REST credentials, namespaced keys, durable persistence, and deployment-friendly connections.
47
+ - [Valkey](references/integrations-databases-valkey.md) - Configure Valkey storage and caching for Mastra through the GLIDE client, including authentication, connection options, persistence, and cleanup.
48
48
 
49
49
  ### Reference
50
50
 
51
- - [Reference: Mastra.getMemory()](references/reference-core-getMemory.md) - Documentation for the `Mastra.getMemory()` method in Mastra, which retrieves a registered memory instance by its registry key.
52
- - [Reference: Mastra.listMemory()](references/reference-core-listMemory.md) - Documentation for the `Mastra.listMemory()` method in Mastra, which returns all registered memory instances.
53
- - [Memory](references/reference-file-based-agents-memory.md) - Give a file-based agent persistent memory with a memory.ts module.
54
- - [Reference: Cloned thread utilities](references/reference-memory-clone-utilities.md) - Documentation for utility methods to work with cloned threads in Mastra Memory.
55
- - [Reference: Memory.cloneThread()](references/reference-memory-cloneThread.md) - Documentation for the `Memory.cloneThread()` method in Mastra, which creates a copy of a conversation thread with all its messages.
56
- - [Reference: Memory.createThread()](references/reference-memory-createThread.md) - Documentation for the `Memory.createThread()` method in Mastra, which creates a new conversation thread in the memory system.
57
- - [Reference: Memory.getThreadById()](references/reference-memory-getThreadById.md) - Documentation for the `Memory.getThreadById()` method in Mastra, which retrieves a specific thread by its ID.
58
- - [Reference: Memory.listThreads()](references/reference-memory-listThreads.md) - Documentation for the `Memory.listThreads()` method in Mastra, which retrieves threads with optional filtering by resourceId and/or metadata.
59
- - [Reference: Memory class](references/reference-memory-memory-class.md) - Documentation for the `Memory` class in Mastra, which provides a reliable system for managing conversation history and thread-based message storage.
60
- - [Reference: Observational Memory](references/reference-memory-observational-memory.md) - API reference for Observational Memory in Mastra: a three-tier memory system that uses Observer and Reflector agents to maintain long-term memory across conversations.
61
- - [Reference: Memory.settled()](references/reference-memory-settled.md) - Documentation for the `Memory.settled()` method in Mastra, which waits for background memory work to finish before you close the storage connection.
62
- - [Reference: summarizeConversation()](references/reference-memory-summarizeConversation.md) - Documentation for the standalone `summarizeConversation()` function in Mastra, which summarizes messages you pass in and extracts structured values from them.
63
- - [Reference: Memory.summarizeThread()](references/reference-memory-summarizeThread.md) - Documentation for the `Memory.summarizeThread()` method in Mastra, which summarizes a thread's conversation in one shot and extracts structured values from it.
64
- - [Migration: AgentNetwork to .network()](references/reference-migrations-agentnetwork.md) - Learn how to migrate from AgentNetwork primitives to .network() in Mastra.
65
- - [Memory](references/reference-migrations-upgrade-to-v1-memory.md) - Learn how to migrate memory-related changes when upgrading to v1.
66
- - [Reference: TokenLimiterProcessor](references/reference-processors-token-limiter-processor.md) - Documentation for the TokenLimiterProcessor in Mastra, which limits the number of tokens in messages.
67
- - [Reference: libSQL vector store](references/reference-vectors-libsql.md) - Documentation for the LibSQLVector class in Mastra, which provides vector search using libSQL with vector extensions.
68
- - [Reference: MongoDB vector store](references/reference-vectors-mongodb.md) - Documentation for the MongoDBVector class in Mastra, which provides vector search using MongoDB Atlas and Vector Search.
69
- - [Reference: OracleDB vector store](references/reference-vectors-oracledb.md) - Documentation for the Oracle Database vector provider in Mastra.
70
- - [Reference: PG vector store](references/reference-vectors-pg.md) - Documentation for the PgVector class in Mastra, which provides vector search using PostgreSQL with pgvector extension.
71
- - [Reference: Upstash vector store](references/reference-vectors-upstash.md) - Documentation for the UpstashVector class in Mastra, which provides vector search using Upstash Vector.
51
+ - [Reference: Mastra.getMemory()](references/reference-core-getMemory.md) - The .getMemory() method retrieves a memory instance from the Mastra registry by its key.
52
+ - [Reference: Mastra.listMemory()](references/reference-core-listMemory.md) - The .listMemory() method returns all memory instances registered with the Mastra instance.
53
+ - [Memory](references/reference-file-based-agents-memory.md) - A file-based agent gets memory from a memory.ts file that default-exports a Memory instance.
54
+ - [Reference: Cloned thread utilities](references/reference-memory-clone-utilities.md) - Use Mastra Memory clone utilities to create threads derived from an existing conversation, then inspect clone relationships and manage their messages.
55
+ - [Reference: Memory.cloneThread()](references/reference-memory-cloneThread.md) - The .cloneThread() method creates a copy of an existing conversation thread, including all its messages.
56
+ - [Reference: Memory.createThread()](references/reference-memory-createThread.md) - The .createThread() method creates a new conversation thread in the memory system. Each thread represents a distinct conversation or context and can contain multiple messages.
57
+ - [Reference: Memory.getThreadById()](references/reference-memory-getThreadById.md) - Use Memory.getThreadById() to retrieve a conversation thread by ID, including its resource association, metadata, and stored properties.
58
+ - [Reference: Memory.listThreads()](references/reference-memory-listThreads.md) - The listThreads() method retrieves threads with pagination support and optional filtering by resourceId, metadata, or both.
59
+ - [Reference: Memory class](references/reference-memory-memory-class.md) - The Memory class provides a reliable system for managing conversation history and thread-based message storage in Mastra.
60
+ - [Reference: Observational Memory](references/reference-memory-observational-memory.md) - Observational Memory (OM) is Mastra's memory system for long-context agentic memory. An Observer watches conversations and creates observations.
61
+ - [Reference: Memory.settled()](references/reference-memory-settled.md) - Use Memory.settled() to wait for asynchronous memory work, including working-memory updates and observational memory, before closing storage.
62
+ - [Reference: summarizeConversation()](references/reference-memory-summarizeConversation.md) - The standalone summarizeConversation() function summarizes a conversation in one shot.
63
+ - [Reference: Memory.summarizeThread()](references/reference-memory-summarizeThread.md) - Call Memory.summarizeThread() to produce a thread summary in one operation and extract configured structured values from its messages.
64
+ - [Migration: AgentNetwork to .network()](references/reference-migrations-agentnetwork.md) - Migrate deprecated AgentNetwork usage to supervisor agents and the standard Agent.generate() or Agent.stream() APIs in current Mastra releases.
65
+ - [Memory](references/reference-migrations-upgrade-to-v1-memory.md) - Memory configuration now requires explicit parameters, and default settings have been updated for better performance and predictability.
66
+ - [Reference: TokenLimiterProcessor](references/reference-processors-token-limiter-processor.md) - Use TokenLimiterProcessor to constrain message tokens during input, per-step input, or output processing with configurable limits and strategies.
67
+ - [Reference: libSQL vector store](references/reference-vectors-libsql.md) - Configure LibSQLVector for similarity search and metadata filtering with local libSQL, SQLite-compatible vector extensions, or Turso databases.
68
+ - [Reference: MongoDB vector store](references/reference-vectors-mongodb.md) - The MongoDBVector class provides vector search using MongoDB Vector Search. It enables efficient similarity search and metadata filtering within your MongoDB collections.
69
+ - [Reference: OracleDB vector store](references/reference-vectors-oracledb.md) - OracleVector stores embeddings in Oracle Database VECTOR columns and exposes them through Mastra's vector interface.
70
+ - [Reference: PG vector store](references/reference-vectors-pg.md) - The PgVector class provides vector search using PostgreSQL with pgvector extension. It provides reliable vector similarity search capabilities within your existing PostgreSQL database.
71
+ - [Reference: Upstash vector store](references/reference-vectors-upstash.md) - Configure UpstashVector for serverless similarity and hybrid search, metadata filtering, index management, and vector operations with Upstash Vector.
72
72
 
73
73
 
74
74
  Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.28.1",
2
+ "version": "1.28.2-alpha.0",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {},
5
5
  "modules": {
@@ -14,8 +14,6 @@ Semantic recall is RAG-based search that helps agents maintain context across lo
14
14
 
15
15
  It uses vector embeddings of messages for similarity search and integrates with vector stores, plus has configurable context windows around retrieved messages.
16
16
 
17
- ![Diagram showing Mastra Memory semantic recall](/assets/images/semantic-recall-fd7b9336a6d0d18019216cb6d3dbe710.png)
18
-
19
17
  When it's enabled, new messages are used to query a vector DB for semantically similar messages.
20
18
 
21
19
  After getting a response from the LLM, all new messages (user, assistant, and tool calls/results) are inserted into the vector DB to be recalled in later interactions.
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-Br56ncef.cjs");
2
+ const require_src = require("./src-Bq1Ng-3M.cjs");
3
3
  let _mastra_core_processors = require("@mastra/core/processors");
4
4
  exports.Extractor = require_src.Extractor;
5
5
  exports.KnowledgeSemanticIndexCoordinator = require_src.KnowledgeSemanticIndexCoordinator;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { C as SUMMARIZE_THREAD_DEFAULTS, G as ModelByInputTokens, H as KnowledgeSemanticIndexCoordinator, Q as Extractor, S as WorkingMemoryExtractor, U as StaleKnowledgeSemanticIndexError, V as Subconscious, a as extractWorkingMemoryContent, b as WorkingMemoryStateProcessor, c as getObservationsAsOf, i as WorkingMemory, n as MessageHistory, o as extractWorkingMemoryTags, r as SemanticRecall, s as removeWorkingMemoryTags, t as Memory, v as WORKING_MEMORY_STATE_ID, w as summarizeConversation, x as deepMergeWorkingMemory, y as WORKING_MEMORY_STATE_PROCESSOR_ID } from "./src-BNtoxIHL.js";
1
+ import { C as SUMMARIZE_THREAD_DEFAULTS, G as ModelByInputTokens, H as KnowledgeSemanticIndexCoordinator, Q as Extractor, S as WorkingMemoryExtractor, U as StaleKnowledgeSemanticIndexError, V as Subconscious, a as extractWorkingMemoryContent, b as WorkingMemoryStateProcessor, c as getObservationsAsOf, i as WorkingMemory, n as MessageHistory, o as extractWorkingMemoryTags, r as SemanticRecall, s as removeWorkingMemoryTags, t as Memory, v as WORKING_MEMORY_STATE_ID, w as summarizeConversation, x as deepMergeWorkingMemory, y as WORKING_MEMORY_STATE_PROCESSOR_ID } from "./src-Br1yJXN1.js";
2
2
  export { Extractor, KnowledgeSemanticIndexCoordinator, Memory, MessageHistory, ModelByInputTokens, SUMMARIZE_THREAD_DEFAULTS, SemanticRecall, StaleKnowledgeSemanticIndexError, Subconscious, WORKING_MEMORY_STATE_ID, WORKING_MEMORY_STATE_PROCESSOR_ID, WorkingMemory, WorkingMemoryExtractor, WorkingMemoryStateProcessor, deepMergeWorkingMemory, extractWorkingMemoryContent, extractWorkingMemoryTags, getObservationsAsOf, removeWorkingMemoryTags, summarizeConversation };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("../src-Br56ncef.cjs");
2
+ const require_src = require("../src-Bq1Ng-3M.cjs");
3
3
  exports.Extractor = require_src.Extractor;
4
4
  exports.KnowledgeSemanticIndexCoordinator = require_src.KnowledgeSemanticIndexCoordinator;
5
5
  exports.ModelByInputTokens = require_src.ModelByInputTokens;
@@ -1,2 +1,2 @@
1
- import { A as formatMessagesForObserver, B as OBSERVATION_CONTINUATION_HINT, D as buildObserverPrompt, E as OBSERVER_SYSTEM_PROMPT, F as parseAnchorId, G as ModelByInputTokens, H as KnowledgeSemanticIndexCoordinator, I as stripEphemeralAnchorIds, J as SUBCONSCIOUS_ACTIVITY_STATE_ID, K as SubconsciousCaptureExtractor, L as OBSERVATIONAL_MEMORY_DEFAULTS, M as optimizeObservationsForContext, N as parseObserverOutput, O as buildObserverSystemPrompt, P as injectAnchorIds, Q as Extractor, R as OBSERVATION_CONTEXT_INSTRUCTIONS, S as WorkingMemoryExtractor, T as TokenCounter, U as StaleKnowledgeSemanticIndexError, V as Subconscious, W as SubconsciousRemindExtractor, X as publishSubconsciousActivity, Y as buildSubconsciousActivitySnapshot, Z as renderSubconsciousActivity, _ as wrapInObservationGroup, c as getObservationsAsOf, d as combineObservationGroupRanges, f as deriveObservationGroupProvenance, g as stripObservationGroups, h as renderObservationGroupsForReflection, j as hasCurrentTaskSection, k as extractCurrentTask, l as ObservationalMemoryProcessor, m as reconcileObservationGroupsFromReflection, p as parseObservationGroups, q as subconsciousCaptureSchema, u as ObservationalMemory, w as summarizeConversation, z as OBSERVATION_CONTEXT_PROMPT } from "../src-BNtoxIHL.js";
1
+ import { A as formatMessagesForObserver, B as OBSERVATION_CONTINUATION_HINT, D as buildObserverPrompt, E as OBSERVER_SYSTEM_PROMPT, F as parseAnchorId, G as ModelByInputTokens, H as KnowledgeSemanticIndexCoordinator, I as stripEphemeralAnchorIds, J as SUBCONSCIOUS_ACTIVITY_STATE_ID, K as SubconsciousCaptureExtractor, L as OBSERVATIONAL_MEMORY_DEFAULTS, M as optimizeObservationsForContext, N as parseObserverOutput, O as buildObserverSystemPrompt, P as injectAnchorIds, Q as Extractor, R as OBSERVATION_CONTEXT_INSTRUCTIONS, S as WorkingMemoryExtractor, T as TokenCounter, U as StaleKnowledgeSemanticIndexError, V as Subconscious, W as SubconsciousRemindExtractor, X as publishSubconsciousActivity, Y as buildSubconsciousActivitySnapshot, Z as renderSubconsciousActivity, _ as wrapInObservationGroup, c as getObservationsAsOf, d as combineObservationGroupRanges, f as deriveObservationGroupProvenance, g as stripObservationGroups, h as renderObservationGroupsForReflection, j as hasCurrentTaskSection, k as extractCurrentTask, l as ObservationalMemoryProcessor, m as reconcileObservationGroupsFromReflection, p as parseObservationGroups, q as subconsciousCaptureSchema, u as ObservationalMemory, w as summarizeConversation, z as OBSERVATION_CONTEXT_PROMPT } from "../src-Br1yJXN1.js";
2
2
  export { Extractor, KnowledgeSemanticIndexCoordinator, ModelByInputTokens, OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTEXT_INSTRUCTIONS, OBSERVATION_CONTEXT_PROMPT, OBSERVATION_CONTINUATION_HINT, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, SUBCONSCIOUS_ACTIVITY_STATE_ID, StaleKnowledgeSemanticIndexError, Subconscious, SubconsciousCaptureExtractor, SubconsciousRemindExtractor, TokenCounter, WorkingMemoryExtractor, buildObserverPrompt, buildObserverSystemPrompt, buildSubconsciousActivitySnapshot, combineObservationGroupRanges, deriveObservationGroupProvenance, extractCurrentTask, formatMessagesForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, publishSubconsciousActivity, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, renderSubconsciousActivity, stripEphemeralAnchorIds, stripObservationGroups, subconsciousCaptureSchema, summarizeConversation, wrapInObservationGroup };
@@ -34,14 +34,14 @@ export declare function isMessageAtOrBeforeCursor(msg: MastraDBMessage, cursor:
34
34
  /**
35
35
  * Get the messages Observational Memory is allowed to work with.
36
36
  *
37
- * Messages supplied through the `context` option are per-run ephemeral input. Core's
38
- * persistence contract already treats them as never-persist: `MessageStateManager` routes
39
- * them into `userContextMessages`, and `drainUnsavedMessages` only drains input/response.
37
+ * Messages supplied through the `context` option and the synthetic `om-continuation`
38
+ * message are prompt-only input. Core's persistence contract already treats context as
39
+ * never-persist, while the continuation remains memory-sourced so it can stay in the live
40
+ * actor prompt.
40
41
  *
41
- * OM builds its windows from `get.all.db()`, which includes context messages, and then
42
- * seals and persists candidates directly turning ephemeral context into durable user
43
- * messages. Excluding them here keeps OM's window, sealing, persistence and token
44
- * accounting consistent with that contract.
42
+ * OM builds its windows from `get.all.db()`, which includes both categories, and then seals
43
+ * and persists candidates directly. Excluding them here keeps OM's observation, buffering,
44
+ * persistence, and token accounting consistent with their ephemeral contract.
45
45
  */
46
46
  export declare function getObservableMessages(messageList: MessageList): MastraDBMessage[];
47
47
  /**
@@ -1,3 +1,4 @@
1
+ export declare const BOUNDARY_WITH_DATE_RE: RegExp;
1
2
  /**
2
3
  * Given a raw `activeObservations` string (from an `ObservationalMemoryRecord`),
3
4
  * return only the observation text that would have been visible at `asOf`.
@@ -1 +1 @@
1
- {"version":3,"file":"observation-utils.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/observation-utils.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,kBAAkB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CA6BlF"}
1
+ {"version":3,"file":"observation-utils.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/observation-utils.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,QAC2D,CAAC;AAE9F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,kBAAkB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CA6BlF"}
@@ -1 +1 @@
1
- {"version":3,"file":"knowledge-write-tools.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/subconscious/knowledge-write-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAQlG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAQrD,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE;QACP,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;KACpE,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,cAAc,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC;AAoBD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,yBAAyB,EACjC,OAAO,EAAE,0BAA0B,GAClC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CA+N3C"}
1
+ {"version":3,"file":"knowledge-write-tools.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/subconscious/knowledge-write-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAQlG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAQrD,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE;QACP,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;KACpE,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,cAAc,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC;AAoBD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,yBAAyB,EACjC,OAAO,EAAE,0BAA0B,GAClC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAoR3C"}
@@ -16096,6 +16096,12 @@ function requireVisible(scope, options, label) {
16096
16096
  if (!(0, _mastra_core_storage.isKnowledgeScopeVisible)(scope, options.scope)) throw new Error(`${label} is outside the curator's visible scope.`);
16097
16097
  }
16098
16098
  function createKnowledgeWriteTools(memory, options) {
16099
+ async function resolveWritableNode(id) {
16100
+ const node = await (await getStore(memory)).getNode(id);
16101
+ if (!node || node.mergedInto) throw new Error(`Knowledge node not found: ${id}`);
16102
+ requireVisible(node.scope, options, "Knowledge node");
16103
+ return node;
16104
+ }
16099
16105
  return {
16100
16106
  knowledge_append: (0, _mastra_core_tools.createTool)({
16101
16107
  id: "knowledge_append",
@@ -16166,7 +16172,7 @@ function createKnowledgeWriteTools(memory, options) {
16166
16172
  }),
16167
16173
  knowledge_update_node: (0, _mastra_core_tools.createTool)({
16168
16174
  id: "knowledge_update_node",
16169
- description: "Update a visible node name or kind using optimistic concurrency. Provide at least one of name or kind.",
16175
+ description: "Atomically rename and re-kind a visible node using optimistic concurrency.",
16170
16176
  inputSchema: {
16171
16177
  type: "object",
16172
16178
  properties: {
@@ -16187,17 +16193,18 @@ function createKnowledgeWriteTools(memory, options) {
16187
16193
  minLength: 1
16188
16194
  }
16189
16195
  },
16190
- required: ["node", "expectedVersion"],
16196
+ required: [
16197
+ "node",
16198
+ "expectedVersion",
16199
+ "name",
16200
+ "kind"
16201
+ ],
16191
16202
  additionalProperties: false
16192
16203
  },
16193
16204
  execute: async (input) => {
16194
16205
  const value = input;
16195
- if (value.name === void 0 && value.kind === void 0) throw new Error("knowledge_update_node requires at least one of: name, kind.");
16196
- const store = await getStore(memory);
16197
- const node = await store.getNode(value.node);
16198
- if (!node || node.mergedInto) throw new Error(`Knowledge node not found: ${value.node}`);
16199
- requireVisible(node.scope, options, "Knowledge node");
16200
- return store.updateNode({
16206
+ const node = await resolveWritableNode(value.node);
16207
+ return (await getStore(memory)).updateNode({
16201
16208
  id: node.id,
16202
16209
  version: value.expectedVersion,
16203
16210
  name: value.name,
@@ -16205,6 +16212,78 @@ function createKnowledgeWriteTools(memory, options) {
16205
16212
  });
16206
16213
  }
16207
16214
  }),
16215
+ knowledge_rename_node: (0, _mastra_core_tools.createTool)({
16216
+ id: "knowledge_rename_node",
16217
+ description: "Rename a visible node using optimistic concurrency.",
16218
+ inputSchema: {
16219
+ type: "object",
16220
+ properties: {
16221
+ node: {
16222
+ type: "string",
16223
+ minLength: 1
16224
+ },
16225
+ expectedVersion: {
16226
+ type: "integer",
16227
+ minimum: 1
16228
+ },
16229
+ name: {
16230
+ type: "string",
16231
+ minLength: 1
16232
+ }
16233
+ },
16234
+ required: [
16235
+ "node",
16236
+ "expectedVersion",
16237
+ "name"
16238
+ ],
16239
+ additionalProperties: false
16240
+ },
16241
+ execute: async (input) => {
16242
+ const value = input;
16243
+ const node = await resolveWritableNode(value.node);
16244
+ return (await getStore(memory)).updateNode({
16245
+ id: node.id,
16246
+ version: value.expectedVersion,
16247
+ name: value.name
16248
+ });
16249
+ }
16250
+ }),
16251
+ knowledge_set_node_kind: (0, _mastra_core_tools.createTool)({
16252
+ id: "knowledge_set_node_kind",
16253
+ description: "Change a visible node kind using optimistic concurrency.",
16254
+ inputSchema: {
16255
+ type: "object",
16256
+ properties: {
16257
+ node: {
16258
+ type: "string",
16259
+ minLength: 1
16260
+ },
16261
+ expectedVersion: {
16262
+ type: "integer",
16263
+ minimum: 1
16264
+ },
16265
+ kind: {
16266
+ type: "string",
16267
+ minLength: 1
16268
+ }
16269
+ },
16270
+ required: [
16271
+ "node",
16272
+ "expectedVersion",
16273
+ "kind"
16274
+ ],
16275
+ additionalProperties: false
16276
+ },
16277
+ execute: async (input) => {
16278
+ const value = input;
16279
+ const node = await resolveWritableNode(value.node);
16280
+ return (await getStore(memory)).updateNode({
16281
+ id: node.id,
16282
+ version: value.expectedVersion,
16283
+ kind: value.kind
16284
+ });
16285
+ }
16286
+ }),
16208
16287
  knowledge_merge_nodes: (0, _mastra_core_tools.createTool)({
16209
16288
  id: "knowledge_merge_nodes",
16210
16289
  description: "Merge a visible duplicate node into another visible node using source-version CAS.",
@@ -16744,7 +16823,7 @@ var Subconscious = class {
16744
16823
  const CURATION_AGENT = "curate";
16745
16824
  const DEFAULT_INSTRUCTIONS$1 = `Maintain durable scoped knowledge from the committed observation worklist.
16746
16825
 
16747
- Use the read tools to inspect existing nodes, knowledge records, mentions, backlinks, and long-form node content. Use the write tools to merge true duplicates, repair names and links, soft-delete superseded knowledge records, rescope knowledge records only when justified and permitted by their ceilings, and synthesize useful node content. Never restore deleted knowledge records. Never invent provenance, capture timestamps, scopes, ceilings, IDs, or versions; those are enforced by code. Resolve optimistic-concurrency conflicts by reading the latest record and retrying the intended mutation. Keep the reserved capture-guidance node concise and update it only with durable guidance that will improve future capture.
16826
+ Use the read tools to inspect existing nodes, knowledge records, mentions, backlinks, and long-form node content. Use the write tools to merge true duplicates, repair names and links, soft-delete superseded knowledge records, rescope knowledge records only when justified and permitted by their ceilings, and synthesize useful node content. When both a node name and kind must change, use knowledge_update_node so they commit atomically under one expectedVersion; use the single-field tools only when changing one field. Never restore deleted knowledge records. Never invent provenance, capture timestamps, scopes, ceilings, IDs, or versions; those are enforced by code. Resolve optimistic-concurrency conflicts by reading the latest record and retrying the intended mutation. Keep the reserved capture-guidance node concise and update it only with durable guidance that will improve future capture.
16748
16827
 
16749
16828
  For each significant entity node touched by a KnowledgeRecord in the current worklist, including people, projects, pull requests, issues, repositories, documents, and organizations, maintain a short entity description; do not walk nodes outside the worklist for this. Use the supplied record and read the named node once; do not search or browse unless its identity is ambiguous. Describe what the entity is, its current state, and links to its real-world object, then write it with knowledge_write_node_description, which always requires expectedVersion from the node you just read; after a version conflict, re-read the node and regenerate the description from its current state before retrying. If the node does not exist yet, create it first with knowledge_write_node_content, then re-read it for its fresh version before writing the description. Write one or two plain-text sentences, roughly 40 to 75 tokens; storage rejects any description over its hard length cap, so keep them tight and put long-form detail in node content instead. Include links only from the entity's own records or observations that explicitly associate the link with that entity; never invent a URL, identifier, file path, or provenance. Leave long-form node content alone unless you are synthesizing it deliberately; never shrink content into a synopsis. For entity-description maintenance only, skip low-signal nodes with only a trivial record, any system-kind node, and the reserved capture-guidance node.
16750
16829
 
@@ -23219,20 +23298,20 @@ function getUnobservedPartsPreservingToolCallPairs(message) {
23219
23298
  /**
23220
23299
  * Get the messages Observational Memory is allowed to work with.
23221
23300
  *
23222
- * Messages supplied through the `context` option are per-run ephemeral input. Core's
23223
- * persistence contract already treats them as never-persist: `MessageStateManager` routes
23224
- * them into `userContextMessages`, and `drainUnsavedMessages` only drains input/response.
23301
+ * Messages supplied through the `context` option and the synthetic `om-continuation`
23302
+ * message are prompt-only input. Core's persistence contract already treats context as
23303
+ * never-persist, while the continuation remains memory-sourced so it can stay in the live
23304
+ * actor prompt.
23225
23305
  *
23226
- * OM builds its windows from `get.all.db()`, which includes context messages, and then
23227
- * seals and persists candidates directly turning ephemeral context into durable user
23228
- * messages. Excluding them here keeps OM's window, sealing, persistence and token
23229
- * accounting consistent with that contract.
23306
+ * OM builds its windows from `get.all.db()`, which includes both categories, and then seals
23307
+ * and persists candidates directly. Excluding them here keeps OM's observation, buffering,
23308
+ * persistence, and token accounting consistent with their ephemeral contract.
23230
23309
  */
23231
23310
  function getObservableMessages(messageList) {
23232
- const allMessages = messageList.get.all.db();
23233
23311
  const contextMessageIds = messageList.makeMessageSourceChecker().context;
23234
- if (contextMessageIds.size === 0) return allMessages;
23235
- return allMessages.filter((message) => !contextMessageIds.has(message.id));
23312
+ return messageList.get.all.db().filter((message) => {
23313
+ return message.id !== "om-continuation" && !contextMessageIds.has(message.id);
23314
+ });
23236
23315
  }
23237
23316
  /**
23238
23317
  * Safely extract buffered observation chunks from a record.
@@ -31869,4 +31948,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
31869
31948
  }
31870
31949
  });
31871
31950
 
31872
- //# sourceMappingURL=src-Br56ncef.cjs.map
31951
+ //# sourceMappingURL=src-Bq1Ng-3M.cjs.map