@mastra/memory 1.39.1 → 1.40.0-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 (68) hide show
  1. package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +51 -12
  2. package/dist/docs/SKILL.md +1 -6
  3. package/dist/docs/assets/SOURCE_MAP.json +56 -56
  4. package/dist/docs/references/docs-agents-human-in-the-loop.md +26 -1
  5. package/dist/docs/references/docs-guides-context-engineering.md +2 -2
  6. package/dist/docs/references/docs-harness-background-tasks.md +85 -1
  7. package/dist/docs/references/docs-memory-memory-processors.md +49 -3
  8. package/dist/docs/references/docs-memory-observational-memory.md +27 -1
  9. package/dist/docs/references/docs-memory-semantic-recall.md +20 -20
  10. package/dist/docs/references/integrations-databases-libsql.md +1 -1
  11. package/dist/docs/references/integrations-databases-mongodb.md +1 -1
  12. package/dist/docs/references/integrations-databases-oracledb.md +1 -1
  13. package/dist/docs/references/integrations-databases-postgresql.md +31 -0
  14. package/dist/docs/references/reference-memory-memory-class.md +77 -0
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/processors/index.cjs +1 -1
  20. package/dist/processors/index.js +1 -1
  21. package/dist/processors/observational-memory/buffering-coordinator.d.ts.map +1 -1
  22. package/dist/processors/observational-memory/constants.d.ts +3 -3
  23. package/dist/processors/observational-memory/constants.d.ts.map +1 -1
  24. package/dist/processors/observational-memory/error.d.ts +10 -2
  25. package/dist/processors/observational-memory/error.d.ts.map +1 -1
  26. package/dist/processors/observational-memory/extractor.d.ts.map +1 -1
  27. package/dist/processors/observational-memory/hooks.d.ts +1 -1
  28. package/dist/processors/observational-memory/hooks.d.ts.map +1 -1
  29. package/dist/processors/observational-memory/model-by-input-tokens.d.ts.map +1 -1
  30. package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts +2 -2
  31. package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
  32. package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +1 -1
  33. package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +1 -1
  34. package/dist/processors/observational-memory/observation-strategies/sync.d.ts +2 -2
  35. package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -1
  36. package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -1
  37. package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -1
  38. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  39. package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -1
  40. package/dist/processors/observational-memory/processor.d.ts +7 -7
  41. package/dist/processors/observational-memory/processor.d.ts.map +1 -1
  42. package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
  43. package/dist/processors/observational-memory/retry.d.ts.map +1 -1
  44. package/dist/processors/observational-memory/subconscious/curate.d.ts.map +1 -1
  45. package/dist/processors/observational-memory/subconscious/index.d.ts.map +1 -1
  46. package/dist/processors/observational-memory/subconscious/pinned-state-processor.d.ts.map +1 -1
  47. package/dist/processors/observational-memory/subconscious/remind-continuation.d.ts.map +1 -1
  48. package/dist/processors/observational-memory/subconscious/remind.d.ts.map +1 -1
  49. package/dist/processors/observational-memory/subconscious/semantic-index.d.ts.map +1 -1
  50. package/dist/processors/observational-memory/summarize.d.ts.map +1 -1
  51. package/dist/processors/observational-memory/token-counter.d.ts.map +1 -1
  52. package/dist/processors/observational-memory/working-memory-extractor.d.ts.map +1 -1
  53. package/dist/processors/working-memory-state/processor.d.ts.map +1 -1
  54. package/dist/{src-DnCjNqwE.cjs → src-DZnFu-zL.cjs} +671 -623
  55. package/dist/src-DZnFu-zL.cjs.map +1 -0
  56. package/dist/{src-CLQXrKvR.js → src-DhDMOGBn.js} +671 -623
  57. package/dist/src-DhDMOGBn.js.map +1 -0
  58. package/dist/tools/om-tools.d.ts +1 -1
  59. package/dist/tools/om-tools.d.ts.map +1 -1
  60. package/dist/tools/working-memory.d.ts.map +1 -1
  61. package/package.json +4 -4
  62. package/dist/docs/references/reference-vectors-libsql.md +0 -309
  63. package/dist/docs/references/reference-vectors-mongodb.md +0 -655
  64. package/dist/docs/references/reference-vectors-oracledb.md +0 -349
  65. package/dist/docs/references/reference-vectors-pg.md +0 -439
  66. package/dist/docs/references/reference-vectors-upstash.md +0 -308
  67. package/dist/src-CLQXrKvR.js.map +0 -1
  68. package/dist/src-DnCjNqwE.cjs.map +0 -1
@@ -35,6 +35,36 @@ export declare class AISDKError extends Error {
35
35
  protected static hasMarker(error: unknown, marker: string): boolean;
36
36
  }
37
37
 
38
+ /**
39
+ * AnyValue can be:
40
+ * - a string, number, boolean value
41
+ * - a byte array (Uint8Array)
42
+ * - array of any value
43
+ * - map from string to any value (a plain Object)
44
+ * - null (an empty value)
45
+ *
46
+ * https://opentelemetry.io/docs/specs/otel/common/#anyvalue
47
+ *
48
+ * Notable JavaScript types that are excluded:
49
+ * - `undefined` - Excluding this means the common practice in instrumentations,
50
+ * using `undefined` to mean "no value for this optional attribute", can
51
+ * remain supported.
52
+ * - `BigInt`
53
+ * - TypedArrays other than `Uint8Array`
54
+ * - subclasses of Object, e.g. Date, Error
55
+ *
56
+ * The TypeScript type `unknown` is used for `AnyValue`. This has some
57
+ * implications:
58
+ * - Callers of `@opentelemetry/api` APIs using `AnyValue` can pass in
59
+ * whatever type. This was always the case for (untyped) JavaScript usage.
60
+ * - SDK implementations of `@opentelemetry/api` need to document if/when they
61
+ * support a subset of AnyValue types.
62
+ * - Using `unknown` allows future changes to support more types (e.g. BigInt).
63
+ *
64
+ * @since 1.10.0
65
+ */
66
+ declare type AnyValue = unknown;
67
+
38
68
  export declare class APICallError extends AISDKError {
39
69
  private readonly [symbol$c_2];
40
70
  readonly url: string;
@@ -193,24 +223,20 @@ export declare interface Attachment {
193
223
  }
194
224
 
195
225
  /**
196
- * Attributes is a map from string to attribute values.
197
- *
198
- * Note: only the own enumerable keys are counted as valid attribute keys.
226
+ * Attributes is a mapping from string to attribute values.
227
+ * https://opentelemetry.io/docs/specs/otel/common/#attribute-collections
199
228
  *
200
- * @since 1.3.0
229
+ * @since 1.1.0
201
230
  */
202
231
  declare interface Attributes {
203
- [attributeKey: string]: AttributeValue | undefined;
232
+ [attributeKey: string]: AnyValue;
204
233
  }
205
234
 
206
235
  /**
207
- * Attribute values may be any non-nullish primitive value except an object.
208
- *
209
- * null or undefined attribute values are invalid and will result in undefined behavior.
210
- *
211
- * @since 1.3.0
236
+ * @since 1.1.0
237
+ * @deprecated use AnyValue
212
238
  */
213
- declare type AttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
239
+ declare type AttributeValue = AnyValue;
214
240
 
215
241
  declare type CallSettings = {
216
242
  /**
@@ -4281,7 +4307,11 @@ declare interface Link {
4281
4307
  context: SpanContext;
4282
4308
  /** A set of {@link SpanAttributes} on the link. */
4283
4309
  attributes?: SpanAttributes;
4284
- /** Count of attributes of the link that were dropped due to collection limits */
4310
+ /**
4311
+ * Count of attributes of the link that were dropped due to collection limits
4312
+ *
4313
+ * @since 1.4.1
4314
+ */
4285
4315
  droppedAttributesCount?: number;
4286
4316
  }
4287
4317
 
@@ -5193,6 +5223,8 @@ declare interface Span {
5193
5223
  * It is preferred span links be added at span creation.
5194
5224
  *
5195
5225
  * @param link the link to add.
5226
+ *
5227
+ * @since 1.9.0
5196
5228
  */
5197
5229
  addLink(link: Link): this;
5198
5230
  /**
@@ -5202,6 +5234,8 @@ declare interface Span {
5202
5234
  * It is preferred span links be added at span creation.
5203
5235
  *
5204
5236
  * @param links the links to add.
5237
+ *
5238
+ * @since 1.9.0
5205
5239
  */
5206
5240
  addLinks(links: Link[]): this;
5207
5241
  /**
@@ -6995,6 +7029,11 @@ declare interface Tracer {
6995
7029
  * Additionally the new span gets set in context and this context is activated
6996
7030
  * for the duration of the function call.
6997
7031
  *
7032
+ * **Important**: The callback function is responsible for calling `span.end()`
7033
+ * to finish the span. Unlike some other OpenTelemetry implementations, the span
7034
+ * is NOT automatically ended when the callback returns. If `span.end()` is not
7035
+ * called, the span will never be exported and will be silently lost.
7036
+ *
6998
7037
  * @param name The name of the span
6999
7038
  * @param [options] SpanOptions used for span creation
7000
7039
  * @param [context] Context to use to extract parent
@@ -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.39.1"
6
+ version: "1.40.0-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -67,11 +67,6 @@ Read the individual reference documents for detailed explanations and code examp
67
67
  - [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.
68
68
  - [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.
69
69
  - [Reference: TokenLimiterProcessor](references/reference-processors-token-limiter-processor.md) - Use TokenLimiterProcessor to constrain message tokens during prompt, input, or output processing with configurable limits and strategies.
70
- - [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.
71
- - [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.
72
- - [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.
73
- - [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.
74
- - [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.
75
70
 
76
71
 
77
72
  Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
@@ -1,229 +1,229 @@
1
1
  {
2
- "version": "1.39.1",
2
+ "version": "1.40.0-alpha.1",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {
5
5
  "d": {
6
6
  "types": "dist/processors/index.d.ts",
7
- "implementation": "dist/src-CLQXrKvR.js"
7
+ "implementation": "dist/src-DhDMOGBn.js"
8
8
  },
9
9
  "et": {
10
10
  "types": "dist/processors/index.d.ts",
11
- "implementation": "dist/src-CLQXrKvR.js"
11
+ "implementation": "dist/src-DhDMOGBn.js"
12
12
  },
13
13
  "K": {
14
14
  "types": "dist/processors/index.d.ts",
15
- "implementation": "dist/src-CLQXrKvR.js"
15
+ "implementation": "dist/src-DhDMOGBn.js"
16
16
  },
17
17
  "Y": {
18
18
  "types": "dist/processors/index.d.ts",
19
- "implementation": "dist/src-CLQXrKvR.js"
19
+ "implementation": "dist/src-DhDMOGBn.js"
20
20
  },
21
21
  "z": {
22
22
  "types": "dist/processors/index.d.ts",
23
- "implementation": "dist/src-CLQXrKvR.js"
23
+ "implementation": "dist/src-DhDMOGBn.js"
24
24
  },
25
25
  "B": {
26
26
  "types": "dist/processors/index.d.ts",
27
- "implementation": "dist/src-CLQXrKvR.js"
27
+ "implementation": "dist/src-DhDMOGBn.js"
28
28
  },
29
29
  "V": {
30
30
  "types": "dist/processors/index.d.ts",
31
- "implementation": "dist/src-CLQXrKvR.js"
31
+ "implementation": "dist/src-DhDMOGBn.js"
32
32
  },
33
33
  "H": {
34
34
  "types": "dist/processors/index.d.ts",
35
- "implementation": "dist/src-CLQXrKvR.js"
35
+ "implementation": "dist/src-DhDMOGBn.js"
36
36
  },
37
37
  "U": {
38
38
  "types": "dist/processors/index.d.ts",
39
- "implementation": "dist/src-CLQXrKvR.js"
39
+ "implementation": "dist/src-DhDMOGBn.js"
40
40
  },
41
41
  "O": {
42
42
  "types": "dist/processors/index.d.ts",
43
- "implementation": "dist/src-CLQXrKvR.js"
43
+ "implementation": "dist/src-DhDMOGBn.js"
44
44
  },
45
45
  "u": {
46
46
  "types": "dist/processors/index.d.ts",
47
- "implementation": "dist/src-CLQXrKvR.js"
47
+ "implementation": "dist/src-DhDMOGBn.js"
48
48
  },
49
49
  "l": {
50
50
  "types": "dist/processors/index.d.ts",
51
- "implementation": "dist/src-CLQXrKvR.js"
51
+ "implementation": "dist/src-DhDMOGBn.js"
52
52
  },
53
53
  "X": {
54
54
  "types": "dist/processors/index.d.ts",
55
- "implementation": "dist/src-CLQXrKvR.js"
55
+ "implementation": "dist/src-DhDMOGBn.js"
56
56
  },
57
57
  "q": {
58
58
  "types": "dist/processors/index.d.ts",
59
- "implementation": "dist/src-CLQXrKvR.js"
59
+ "implementation": "dist/src-DhDMOGBn.js"
60
60
  },
61
61
  "G": {
62
62
  "types": "dist/processors/index.d.ts",
63
- "implementation": "dist/src-CLQXrKvR.js"
63
+ "implementation": "dist/src-DhDMOGBn.js"
64
64
  },
65
65
  "J": {
66
66
  "types": "dist/processors/index.d.ts",
67
- "implementation": "dist/src-CLQXrKvR.js"
67
+ "implementation": "dist/src-DhDMOGBn.js"
68
68
  },
69
69
  "D": {
70
70
  "types": "dist/processors/index.d.ts",
71
- "implementation": "dist/src-CLQXrKvR.js"
71
+ "implementation": "dist/src-DhDMOGBn.js"
72
72
  },
73
73
  "C": {
74
74
  "types": "dist/processors/index.d.ts",
75
- "implementation": "dist/src-CLQXrKvR.js"
75
+ "implementation": "dist/src-DhDMOGBn.js"
76
76
  },
77
77
  "k": {
78
78
  "types": "dist/processors/index.d.ts",
79
- "implementation": "dist/src-CLQXrKvR.js"
79
+ "implementation": "dist/src-DhDMOGBn.js"
80
80
  },
81
81
  "A": {
82
82
  "types": "dist/processors/index.d.ts",
83
- "implementation": "dist/src-CLQXrKvR.js"
83
+ "implementation": "dist/src-DhDMOGBn.js"
84
84
  },
85
85
  "Z": {
86
86
  "types": "dist/processors/index.d.ts",
87
- "implementation": "dist/src-CLQXrKvR.js"
87
+ "implementation": "dist/src-DhDMOGBn.js"
88
88
  },
89
89
  "g": {
90
90
  "types": "dist/processors/index.d.ts",
91
- "implementation": "dist/src-CLQXrKvR.js"
91
+ "implementation": "dist/src-DhDMOGBn.js"
92
92
  },
93
93
  "_": {
94
94
  "types": "dist/processors/index.d.ts",
95
- "implementation": "dist/src-CLQXrKvR.js"
95
+ "implementation": "dist/src-DhDMOGBn.js"
96
96
  },
97
97
  "j": {
98
98
  "types": "dist/processors/index.d.ts",
99
- "implementation": "dist/src-CLQXrKvR.js"
99
+ "implementation": "dist/src-DhDMOGBn.js"
100
100
  },
101
101
  "M": {
102
102
  "types": "dist/processors/index.d.ts",
103
- "implementation": "dist/src-CLQXrKvR.js"
103
+ "implementation": "dist/src-DhDMOGBn.js"
104
104
  },
105
105
  "W": {
106
106
  "types": "dist/processors/index.d.ts",
107
- "implementation": "dist/src-CLQXrKvR.js"
107
+ "implementation": "dist/src-DhDMOGBn.js"
108
108
  },
109
109
  "c": {
110
110
  "types": "dist/processors/index.d.ts",
111
- "implementation": "dist/src-CLQXrKvR.js"
111
+ "implementation": "dist/src-DhDMOGBn.js"
112
112
  },
113
113
  "N": {
114
114
  "types": "dist/processors/index.d.ts",
115
- "implementation": "dist/src-CLQXrKvR.js"
115
+ "implementation": "dist/src-DhDMOGBn.js"
116
116
  },
117
117
  "I": {
118
118
  "types": "dist/processors/index.d.ts",
119
- "implementation": "dist/src-CLQXrKvR.js"
119
+ "implementation": "dist/src-DhDMOGBn.js"
120
120
  },
121
121
  "P": {
122
122
  "types": "dist/processors/index.d.ts",
123
- "implementation": "dist/src-CLQXrKvR.js"
123
+ "implementation": "dist/src-DhDMOGBn.js"
124
124
  },
125
125
  "L": {
126
126
  "types": "dist/processors/index.d.ts",
127
- "implementation": "dist/src-CLQXrKvR.js"
127
+ "implementation": "dist/src-DhDMOGBn.js"
128
128
  },
129
129
  "v": {
130
130
  "types": "dist/processors/index.d.ts",
131
- "implementation": "dist/src-CLQXrKvR.js"
131
+ "implementation": "dist/src-DhDMOGBn.js"
132
132
  },
133
133
  "F": {
134
134
  "types": "dist/processors/index.d.ts",
135
- "implementation": "dist/src-CLQXrKvR.js"
135
+ "implementation": "dist/src-DhDMOGBn.js"
136
136
  },
137
137
  "Q": {
138
138
  "types": "dist/processors/index.d.ts",
139
- "implementation": "dist/src-CLQXrKvR.js"
139
+ "implementation": "dist/src-DhDMOGBn.js"
140
140
  },
141
141
  "y": {
142
142
  "types": "dist/processors/index.d.ts",
143
- "implementation": "dist/src-CLQXrKvR.js"
143
+ "implementation": "dist/src-DhDMOGBn.js"
144
144
  },
145
145
  "b": {
146
146
  "types": "dist/processors/index.d.ts",
147
- "implementation": "dist/src-CLQXrKvR.js"
147
+ "implementation": "dist/src-DhDMOGBn.js"
148
148
  },
149
149
  "$": {
150
150
  "types": "dist/processors/index.d.ts",
151
- "implementation": "dist/src-CLQXrKvR.js"
151
+ "implementation": "dist/src-DhDMOGBn.js"
152
152
  },
153
153
  "f": {
154
154
  "types": "dist/processors/index.d.ts",
155
- "implementation": "dist/src-CLQXrKvR.js"
155
+ "implementation": "dist/src-DhDMOGBn.js"
156
156
  },
157
157
  "R": {
158
158
  "types": "dist/processors/index.d.ts",
159
- "implementation": "dist/src-CLQXrKvR.js"
159
+ "implementation": "dist/src-DhDMOGBn.js"
160
160
  },
161
161
  "x": {
162
162
  "types": "dist/processors/index.d.ts",
163
- "implementation": "dist/src-CLQXrKvR.js"
163
+ "implementation": "dist/src-DhDMOGBn.js"
164
164
  },
165
165
  "E": {
166
166
  "types": "dist/processors/index.d.ts",
167
- "implementation": "dist/src-CLQXrKvR.js"
167
+ "implementation": "dist/src-DhDMOGBn.js"
168
168
  },
169
169
  "S": {
170
170
  "types": "dist/processors/index.d.ts",
171
- "implementation": "dist/src-CLQXrKvR.js"
171
+ "implementation": "dist/src-DhDMOGBn.js"
172
172
  },
173
173
  "t": {
174
174
  "types": "dist/index.d.ts",
175
- "implementation": "dist/src-CLQXrKvR.js"
175
+ "implementation": "dist/src-DhDMOGBn.js"
176
176
  },
177
177
  "n": {
178
178
  "types": "dist/index.d.ts",
179
- "implementation": "dist/src-CLQXrKvR.js"
179
+ "implementation": "dist/src-DhDMOGBn.js"
180
180
  },
181
181
  "T": {
182
182
  "types": "dist/index.d.ts",
183
- "implementation": "dist/src-CLQXrKvR.js"
183
+ "implementation": "dist/src-DhDMOGBn.js"
184
184
  },
185
185
  "r": {
186
186
  "types": "dist/index.d.ts",
187
- "implementation": "dist/src-CLQXrKvR.js"
187
+ "implementation": "dist/src-DhDMOGBn.js"
188
188
  },
189
189
  "p": {
190
190
  "types": "dist/index.d.ts",
191
- "implementation": "dist/src-CLQXrKvR.js"
191
+ "implementation": "dist/src-DhDMOGBn.js"
192
192
  },
193
193
  "m": {
194
194
  "types": "dist/index.d.ts",
195
- "implementation": "dist/src-CLQXrKvR.js"
195
+ "implementation": "dist/src-DhDMOGBn.js"
196
196
  },
197
197
  "i": {
198
198
  "types": "dist/index.d.ts",
199
- "implementation": "dist/src-CLQXrKvR.js"
199
+ "implementation": "dist/src-DhDMOGBn.js"
200
200
  },
201
201
  "h": {
202
202
  "types": "dist/index.d.ts",
203
- "implementation": "dist/src-CLQXrKvR.js"
203
+ "implementation": "dist/src-DhDMOGBn.js"
204
204
  },
205
205
  "w": {
206
206
  "types": "dist/index.d.ts",
207
- "implementation": "dist/src-CLQXrKvR.js"
207
+ "implementation": "dist/src-DhDMOGBn.js"
208
208
  },
209
209
  "a": {
210
210
  "types": "dist/index.d.ts",
211
- "implementation": "dist/src-CLQXrKvR.js"
211
+ "implementation": "dist/src-DhDMOGBn.js"
212
212
  },
213
213
  "o": {
214
214
  "types": "dist/index.d.ts",
215
- "implementation": "dist/src-CLQXrKvR.js"
215
+ "implementation": "dist/src-DhDMOGBn.js"
216
216
  },
217
217
  "s": {
218
218
  "types": "dist/index.d.ts",
219
- "implementation": "dist/src-CLQXrKvR.js"
219
+ "implementation": "dist/src-DhDMOGBn.js"
220
220
  }
221
221
  },
222
222
  "modules": {
223
223
  "processors": {
224
224
  "index": "dist/processors/index.js",
225
225
  "chunks": [
226
- "src-CLQXrKvR.js"
226
+ "src-DhDMOGBn.js"
227
227
  ]
228
228
  }
229
229
  }
@@ -116,7 +116,7 @@ const stream = await agent.stream('Clean up old records', {
116
116
  })
117
117
  ```
118
118
 
119
- The function can be asynchronous. For decisions that depend on the tool name and arguments, use a [classifier](https://mastra.ai/reference/classifier/classifier) to estimate whether the call needs human review:
119
+ The function can be asynchronous. For decisions that depend on the tool name and arguments, use a [classifier](https://mastra.ai/docs/classifier) to estimate whether the call needs human review:
120
120
 
121
121
  ```typescript
122
122
  import { Classifier } from '@mastra/core/classifier'
@@ -589,6 +589,31 @@ A [supervisor agent](https://mastra.ai/docs/subagents) coordinates multiple suba
589
589
 
590
590
  Tool approvals also propagate through multiple levels of delegation. If a supervisor delegates to subagent A, which delegates to subagent B that has a tool with `requireApproval: true`, the approval request still surfaces at the top-level supervisor.
591
591
 
592
+ ### Identify which subagent tool paused
593
+
594
+ The supervisor raises a subagent's pause on its own delegation call, so `toolCallId` on the `tool-call-approval` or `tool-call-suspended` chunk is the supervisor's call to the subagent. Always pass that `toolCallId` when you approve, decline, or resume.
595
+
596
+ To show which of the subagent's tool calls paused, read these fields from the same payload:
597
+
598
+ - `delegatedToolCallId`: The ID of the subagent's tool call that paused. Use it to tell apart two pauses from the same delegation, such as a question followed by an approval.
599
+ - `delegatedToolName`: The name of the subagent's tool that paused.
600
+
601
+ With several levels of delegation, both fields name the deepest tool call, the one that actually paused. Memory saves them with the pause, so they're still there when you reload the conversation, and `generate()` returns them on `suspendPayload`.
602
+
603
+ ```typescript
604
+ const stream = await supervisorAgent.stream('Draft and publish the report')
605
+
606
+ for await (const chunk of stream.fullStream) {
607
+ if (chunk.type === 'tool-call-approval' || chunk.type === 'tool-call-suspended') {
608
+ // Label the pause with the subagent tool call that caused it
609
+ console.log('Paused:', chunk.payload.delegatedToolName, chunk.payload.delegatedToolCallId)
610
+
611
+ // Pass the supervisor's delegation call when you approve, decline, or resume
612
+ console.log('Resume with:', chunk.payload.toolCallId)
613
+ }
614
+ }
615
+ ```
616
+
592
617
  ### Approve and decline in supervisor agents
593
618
 
594
619
  The example below creates a subagent with a tool requiring approval. When the tool triggers an approval request, it surfaces in the supervisor's stream as a `tool-call-approval` chunk:
@@ -145,8 +145,8 @@ export const workspace = new Workspace({
145
145
  autoIndexPaths: ['**/*.md'],
146
146
  })
147
147
 
148
- // Agents receive tools including read_file, list_files, grep,
149
- // mastra_workspace_search, and mastra_workspace_index.
148
+ // Agents receive tools including mastra_workspace_read_file, mastra_workspace_list_files,
149
+ // mastra_workspace_grep, mastra_workspace_search, and mastra_workspace_index.
150
150
  await workspace.init()
151
151
  ```
152
152
 
@@ -292,6 +292,19 @@ await mastra.backgroundTaskManager?.resume(taskId, {
292
292
  })
293
293
  ```
294
294
 
295
+ ### Resume when no slot is free
296
+
297
+ By default, `resume()` throws `Concurrency limit reached` when every concurrency slot is in use. Pass `{ onNoSlot: 'queue' }` to queue the resume instead:
298
+
299
+ ```typescript
300
+ const task = await mastra.backgroundTaskManager?.resume(taskId, resumeData, { onNoSlot: 'queue' })
301
+ // task.status is still 'suspended' until a slot frees up
302
+ ```
303
+
304
+ The task stays `suspended` until a slot frees up, then resumes with the queued `resumeData`. Cancelling the task drops the queued resume.
305
+
306
+ The queue lives in the memory of the process that called `resume()`. If that process exits before the resume runs, the task stays `suspended` and the `resumeData` is lost. To survive restarts, persist the resume data yourself and call `resume()` again.
307
+
295
308
  ### What happens to the agent loop
296
309
 
297
310
  When a task suspends mid-`stream()` with `untilIdle`, the wrapper treats it as terminal for the current iteration and closes. Once the resume payload is available, call `agent.resumeStream(resumeData, { runId, toolCallId, memory, untilIdle: true })` to continue immediately. The resumed background task completes and adds its result to the message list before the agent runs a follow-up turn on the same SSE connection. To drive the resume out of band, call `mastra.backgroundTaskManager.resume(taskId, resumeData)` directly. Its result is still written into the thread for the next user turn.
@@ -310,7 +323,7 @@ Each layer can register terminal-state callbacks. They don't replace one another
310
323
 
311
324
  - Tool-level `background.onComplete` / `onFailed`: scoped to one tool.
312
325
  - Agent-level `backgroundTasks.onTaskComplete` / `onTaskFailed`: scoped to all tasks dispatched by this agent.
313
- - Manager-level `onTaskComplete` / `onTaskFailed`: scoped globally.
326
+ - Manager-level `onTaskComplete` / `onTaskFailed`: scoped globally. These fire for every task, including tasks from [non-agent owners](#non-agent-owners).
314
327
 
315
328
  ```typescript
316
329
  import { Mastra } from '@mastra/core'
@@ -398,6 +411,77 @@ const { tasks, total } = await mastra.backgroundTaskManager?.listTasks({
398
411
 
399
412
  These read from storage rather than the pubsub stream, so they're suitable for paginated lists and detail views.
400
413
 
414
+ ## Non-agent owners
415
+
416
+ Code other than agents can run tasks through the manager. For example, an MCP server can run long tool calls as background tasks. The task's `agentId` is its owner key, and agent streams, `untilIdle`, and the end-of-step wait only see tasks whose `agentId` matches the agent. Use a namespaced owner key such as `mcp-server:<serverId>` so it can't collide with a real agent ID. Mastra doesn't enforce this.
417
+
418
+ Non-agent owners usually register a static executor with `registerStaticExecutor()` so any process can run or recover their tasks. They can also set these optional task fields:
419
+
420
+ - `expiresAt`: When cleanup deletes the task. Once a task completes, fails, is cancelled, or times out, cleanup deletes it after `expiresAt` passes instead of using `completedTtlMs` or `failedTtlMs`. Cleanup only runs when you set the `cleanup` option, and it never deletes a pending, running, or suspended task, so cancel expired work first. It also needs a storage adapter version that supports `expiresAt`. Older adapters keep using the global retention settings.
421
+ - `metadata`: JSON stored with the task. The manager doesn't read it.
422
+
423
+ ```typescript
424
+ mastra.backgroundTaskManager?.registerStaticExecutor('mcp-server:ops:deploy', {
425
+ execute: runDeploy,
426
+ })
427
+
428
+ await mastra.backgroundTaskManager?.enqueue({
429
+ agentId: 'mcp-server:ops',
430
+ toolName: 'mcp-server:ops:deploy',
431
+ toolCallId: taskId,
432
+ runId: taskId,
433
+ args,
434
+ resourceId: principalId,
435
+ expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),
436
+ metadata: { ttlMs: 86_400_000 },
437
+ })
438
+ ```
439
+
440
+ Use `perOwnerConcurrency` to give an owner its own concurrency limit instead of `perAgentConcurrency`. Its tasks still count toward `globalConcurrency`:
441
+
442
+ ```typescript
443
+ export const mastra = new Mastra({
444
+ storage,
445
+ backgroundTasks: {
446
+ enabled: true,
447
+ globalConcurrency: 60,
448
+ perOwnerConcurrency: { 'mcp-server:ops': 50 },
449
+ },
450
+ })
451
+ ```
452
+
453
+ Known limitations:
454
+
455
+ - A recovered task runs without the original request. Store anything the executor needs, such as the principal in `resourceId` or other JSON in `metadata`, on the task itself.
456
+ - A `pending` task that isn't pinned holds no lease. On startup, another process can pick it up and dispatch it. If its executor only existed in the original process, the task fails with `No executor registered`. Static executors registered in every process avoid this. Use `pinToWorker` when the original process already started the work.
457
+ - The end-of-step wait in the agent loop only waits for `running` tasks, not `pending` ones. [#28228](https://github.com/mastra-ai/mastra/pull/28228) tracks the fix.
458
+
459
+ ### Pin a task to the current worker
460
+
461
+ Sometimes work for a task is already running in this process before you enqueue it. For example, an MCP server may start a tool call inside the request and hand it to a background task only if it runs long. Pass `pinToWorker: true` with a task context so no other process starts the same work:
462
+
463
+ ```typescript
464
+ await mastra.backgroundTaskManager?.enqueue(
465
+ {
466
+ agentId: 'mcp-server:ops',
467
+ toolName: 'mcp-server:ops:deploy',
468
+ toolCallId: taskId,
469
+ runId: taskId,
470
+ args,
471
+ },
472
+ { executor: { execute: adoptRunningDeploy } },
473
+ { pinToWorker: true },
474
+ )
475
+ ```
476
+
477
+ `pinToWorker` means work for this task is already in flight on this worker. The `pending` task records this worker as its owner and holds an execution lease, which the worker renews while the task waits for a free slot. Other processes don't recover or dispatch the task while the lease is live.
478
+
479
+ If the worker dies or shuts down first, that work is lost. Recovery treats the task as a lost attempt, like a running task whose worker died. If `retryCount` is below `maxRetries`, the task uses a retry and runs on another worker, which needs a static executor for it. Otherwise the task fails with `Worker process terminated before task completed`. A task with `maxRetries: 0` never runs on another worker. Other processes check for lapsed pins at startup and then every `leaseDurationMs`, unless `recoverStaleTasksOnStart` is `false`.
480
+
481
+ A lapsed lease only shows that the worker stopped renewing it, not that the work stopped. A worker whose event loop stalls past the lease can still be running the task when another worker retries it. Make pinned work idempotent, or guard its side effects, if it can be retried.
482
+
483
+ `pinToWorker` throws without a task context. Tasks that aren't pinned, including all agent tasks, hold no lease while `pending`.
484
+
401
485
  ## Related
402
486
 
403
487
  - [`Agent.stream()` reference](https://mastra.ai/reference/streaming/agents/stream)
@@ -12,13 +12,13 @@ Memory processors are [processors](https://mastra.ai/docs/agents/processors) tha
12
12
 
13
13
  ## Built-in memory processors
14
14
 
15
- Mastra automatically adds these processors when memory is enabled:
15
+ Mastra automatically adds these processors when memory is enabled. `MemoryInputFilter` is added only when a memory store is available and stored history will be loaded:
16
16
 
17
17
  ### `MemoryInputFilter`
18
18
 
19
- Trims client-echoed history before memory loaders run. For an existing thread, it keeps only the current user turn or new tool results. For an empty thread, it keeps the full initial input and removes provider item metadata from assistant parts that could refer to items that don't exist in storage.
19
+ Trims client-echoed history before memory loaders run. For an existing thread, it keeps only the current user turn or new tool results. For an empty thread, it keeps the full initial input and removes provider item metadata from assistant parts that could refer to items that don't exist in storage. When `retainFullInput: true` is set, it skips both the trim and the metadata strip and processes the input exactly as supplied, while stored history still loads.
20
20
 
21
- This processor runs first so `MessageHistory`, `SemanticRecall`, and Observational Memory receive only the new input they need.
21
+ By default, this processor runs first so `MessageHistory`, `SemanticRecall`, and Observational Memory receive only the new input they need.
22
22
 
23
23
  ### `MessageHistory`
24
24
 
@@ -320,6 +320,52 @@ const agent = new Agent({
320
320
 
321
321
  Both scenarios are safe - guardrails prevent inappropriate content from being persisted to memory
322
322
 
323
+ ## Aborted runs and saved messages
324
+
325
+ Cancelling a run and blocking it with a processor `abort()` both stop generation, but they save different things:
326
+
327
+ | What stops the run | Memory processors | What's persisted |
328
+ | ----------------------------- | ----------------- | ------------------------------------------------------------ |
329
+ | `abortSignal` from the caller | Still run | The user message and the assistant text the user already saw |
330
+ | `abort()` inside a processor | Skipped | Nothing; the tripwire blocks the save |
331
+
332
+ A caller cancellation goes through output processors like any other run, so the built-in `MessageHistory` processor saves the thread. The partial answer is stored as an ordinary assistant message with no error part, which means the next turn starts from what the user actually read.
333
+
334
+ ```typescript
335
+ import { Agent } from '@mastra/core/agent'
336
+ import { Memory } from '@mastra/memory'
337
+
338
+ const memory = new Memory({ options: { lastMessages: 20 } })
339
+ const agent = new Agent({
340
+ id: 'writer',
341
+ name: 'writer',
342
+ instructions: 'You write step-by-step migration guides.',
343
+ model: 'openai/gpt-6.1-sol',
344
+ memory,
345
+ })
346
+
347
+ const controller = new AbortController()
348
+ const stream = await agent.stream('Write the migration guide.', {
349
+ memory: { thread: 'thread-1', resource: 'user-1' },
350
+ abortSignal: controller.signal,
351
+ onAbort: ({ steps, text }) => {
352
+ console.log(`Aborted after ${steps.length} steps with ${text?.length ?? 0} characters streamed`)
353
+ },
354
+ })
355
+
356
+ let streamed = ''
357
+ for await (const chunk of stream.fullStream) {
358
+ if (chunk.type !== 'text-delta') continue
359
+ streamed += chunk.payload.text
360
+ if (streamed.length > 200) controller.abort()
361
+ }
362
+
363
+ // The partial answer is already in the thread
364
+ const { messages } = await memory.recall({ threadId: 'thread-1', resourceId: 'user-1' })
365
+ ```
366
+
367
+ `onAbort` receives the steps that completed before the cancellation and the assistant text streamed for the in-flight step. For the abort lifecycle itself, including durable runs aborted by `runId`, see the [`stream()` reference](https://mastra.ai/reference/streaming/agents/stream).
368
+
323
369
  ## Handling large attachments
324
370
 
325
371
  Some storage providers enforce record size limits that base64-encoded file attachments can exceed: