@mastra/memory 1.42.0-alpha.5 → 1.42.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/dist/_types/{@internal_ai-sdk-v4@0.0.99 → @internal_ai-sdk-v4@0.0.100}/dist/index.d.ts +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-harness-background-tasks.md +8 -5
- package/dist/docs/references/docs-memory-message-history.md +2 -0
- package/dist/index.d.ts +1 -1
- package/package.json +9 -9
- /package/dist/_types/{@internal_ai-sdk-v4@0.0.99 → @internal_ai-sdk-v4@0.0.100}/package.json +0 -0
package/dist/_types/{@internal_ai-sdk-v4@0.0.99 → @internal_ai-sdk-v4@0.0.100}/dist/index.d.ts
RENAMED
|
@@ -7486,4 +7486,4 @@ export declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeD
|
|
|
7486
7486
|
}): Schema<OBJECT>;
|
|
7487
7487
|
|
|
7488
7488
|
export { }
|
|
7489
|
-
export {
|
|
7489
|
+
export { LanguageModelV1FinishReason as LanguageModelV1FinishReason, LanguageModelV1CallWarning as LanguageModelV1CallWarning, JSONValue_2 as JSONValue_2, Source as Source, DataStreamString as DataStreamString, AttributeValue as AttributeValue, Tracer as Tracer, EmbeddingModelV1 as EmbeddingModelV1, EmbeddingModelV1Embedding as EmbeddingModelV1Embedding, ImageModelV1CallWarning as ImageModelV1CallWarning, TranscriptionModelV1CallWarning as TranscriptionModelV1CallWarning, SpeechModelV1CallWarning as SpeechModelV1CallWarning, ProviderOptions as ProviderOptions, ReasoningPart as ReasoningPart, RedactedReasoningPart as RedactedReasoningPart, ToolResultContent as ToolResultContent, inferParameters as inferParameters, ToolParameters as ToolParameters, JSONRPCRequestSchema as JSONRPCRequestSchema, JSONRPCResponseSchema as JSONRPCResponseSchema, JSONRPCErrorSchema as JSONRPCErrorSchema, JSONRPCNotificationSchema as JSONRPCNotificationSchema, JSONRPCMessageSchema as JSONRPCMessageSchema, MCPClientConfig as MCPClientConfig, MCPClient as MCPClient, ValueOf as ValueOf, ToToolResultObject as ToToolResultObject, ToToolsWithDefinedExecute as ToToolsWithDefinedExecute, ToToolsWithExecute as ToToolsWithExecute, ReasoningDetail as ReasoningDetail, ToolCallArray as ToolCallArray, ToolResultArray as ToolResultArray, ResponseMessage as ResponseMessage, Output_2 as Output_2, ConsumeStreamOptions as ConsumeStreamOptions, ImageModelV1 as ImageModelV1, CallSettings as CallSettings, Prompt as Prompt, StreamObjectOnErrorCallback as StreamObjectOnErrorCallback, AsyncIterableStream as AsyncIterableStream, SpeechModelV1 as SpeechModelV1, TranscriptionModelV1 as TranscriptionModelV1, LanguageModelV1ProviderMetadata as LanguageModelV1ProviderMetadata, ExtractModelId as ExtractModelId, ExtractLiteralUnion as ExtractLiteralUnion, ProviderV1 as ProviderV1, SingleRequestTextStreamPart as SingleRequestTextStreamPart, RetryErrorReason as RetryErrorReason, AssistantResponseSettings as AssistantResponseSettings, AssistantResponseCallback as AssistantResponseCallback, LanguageModelV1Message as LanguageModelV1Message, LanguageModelV1CallSettings as LanguageModelV1CallSettings, LanguageModelV1FunctionTool as LanguageModelV1FunctionTool, LanguageModelV1ProviderDefinedTool as LanguageModelV1ProviderDefinedTool, LanguageModelV1ToolChoice as LanguageModelV1ToolChoice, LanguageModelV1ObjectGenerationMode as LanguageModelV1ObjectGenerationMode, LanguageModelV1FunctionToolCall as LanguageModelV1FunctionToolCall, LanguageModelV1Source as LanguageModelV1Source, LanguageModelV1LogProbs as LanguageModelV1LogProbs, FetchFunction as FetchFunction, TextUIPart as TextUIPart, ReasoningUIPart as ReasoningUIPart, ToolInvocationUIPart as ToolInvocationUIPart, SourceUIPart as SourceUIPart, FileUIPart as FileUIPart, StepStartUIPart as StepStartUIPart, AssistantStreamPartType as AssistantStreamPartType, AssistantStreamPartValueType as AssistantStreamPartValueType, AssistantStreamString as AssistantStreamString, DataStreamPartType as DataStreamPartType, DataStreamPartValueType as DataStreamPartValueType, DeepPartialInternal as DeepPartialInternal, Validator as Validator };
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -335,12 +335,14 @@ Which layer to use depends on where consistency matters: subagent-level configur
|
|
|
335
335
|
|
|
336
336
|
A background task can pause itself mid-execution and wait for an external signal before continuing. This is useful for human approvals, webhooks, or any flow where the next step depends on data that arrives later.
|
|
337
337
|
|
|
338
|
-
A tool calls `suspend(data)` from inside its `execute
|
|
338
|
+
A tool calls `suspend(data)` from inside its `execute`. Once `execute` returns, Mastra:
|
|
339
339
|
|
|
340
|
-
- Persists `status: 'suspended'` and the `data` payload on the task record.
|
|
341
340
|
- Saves the workflow snapshot so the run survives process restarts.
|
|
342
|
-
-
|
|
341
|
+
- Persists `status: 'suspended'` and the `data` payload on the task record.
|
|
343
342
|
- Releases the concurrency slot so other tasks can run.
|
|
343
|
+
- Emits a `background-task-suspended` chunk on the manager stream.
|
|
344
|
+
|
|
345
|
+
The task is stored as `suspended` only after its snapshot is saved, so a task stored as `suspended` can always be resumed, even after a crash. Until then the task reads as `running`.
|
|
344
346
|
|
|
345
347
|
Resume the task with `mastra.backgroundTaskManager.resume(taskId, resumeData)`. The `resumeData` arrives in the tool's `execute` options on the resumed run, and the task transitions back to `running`.
|
|
346
348
|
|
|
@@ -557,7 +559,7 @@ Before a manager runs a task, it claims the task with a conditional write. The w
|
|
|
557
559
|
|
|
558
560
|
While the task runs, the owner renews the lease every `leaseDurationMs / 3`, with a minimum of one second. Each renewal is conditional on the task still being `running` under the same owner. The task's final writes, such as `completed`, `failed`, `timed_out`, or `suspended`, carry the same condition, so a manager that lost the task can't overwrite the result of the manager that replaced it.
|
|
559
561
|
|
|
560
|
-
The owner stops renewing when the task completes, fails, or suspends. On shutdown, the manager releases the leases it still holds, so other managers can recover those tasks without waiting for the lease to expire. A running task with `maxRetries: 0` can't run again, so shutdown fails it with `Worker process terminated before task completed`, the same ending as a crash, rather than cancelling it. A lease that isn't released, for example because the process crashed, expires on its own.
|
|
562
|
+
The owner stops renewing when the task completes, fails, or suspends. On shutdown, the manager releases the leases it still holds, so other managers can recover those tasks without waiting for the lease to expire. A running task with `maxRetries: 0` can't run again, so shutdown fails it with `Worker process terminated before task completed`, the same ending as a crash, rather than cancelling it. A task whose tool already called `suspend()` is kept instead, so its snapshot can still be saved. Once the tool returns or stops on the abort signal, Mastra saves the snapshot and stores the task as `suspended`, so it can be answered after the restart. If the tool is still running when shutdown ends, nothing is saved and the task is recovered as if its worker crashed. Stale-task recovery uses a retry if one is left and fails the task otherwise, while a redelivered dispatch can run it again even with `maxRetries: 0`. See [Recover a task from a dead owner](#recover-a-task-from-a-dead-owner). A lease that isn't released, for example because the process crashed, expires on its own.
|
|
561
563
|
|
|
562
564
|
### Recover a task from a dead owner
|
|
563
565
|
|
|
@@ -565,6 +567,7 @@ A manager treats a `running` task as abandoned only after its lease expires.
|
|
|
565
567
|
|
|
566
568
|
When `recoverStaleTasksOnStart` is `true`, the default, each manager that runs tasks scans for abandoned tasks on startup. If the scan finds a lease that hasn't expired yet, the manager scans again shortly after that lease expires, and repeats until no live lease is left. After startup, the manager also checks for running tasks with an expired lease every `leaseDurationMs`, so a task whose worker dies later is recovered without a restart. Each check reads up to `globalConcurrency` running tasks (at least 100, at most 1,000), which normally covers all of them, so the task is recovered within about one `leaseDurationMs` after its lease expires. When more tasks are running than that, for example because other servers use a higher `globalConcurrency`, each further page of running tasks adds one `leaseDurationMs`. For each task the scan recovers:
|
|
567
569
|
|
|
570
|
+
- If the task's snapshot already holds a suspension from its current attempt, the task is stored as `suspended` without using a retry, and you can answer it with `resume()`.
|
|
568
571
|
- If the task's worker shut down gracefully, it returns to `pending` and is dispatched again without using a retry.
|
|
569
572
|
- If the worker died and the task's `retryCount` is below `maxRetries`, it uses a retry, returns to `pending`, and is dispatched again.
|
|
570
573
|
- Otherwise, it fails with `Worker process terminated before task completed`. The failure fires `task.failed` and `onTaskFailed` like any other failure.
|
|
@@ -573,7 +576,7 @@ Only a crash counts against `maxRetries`, so a task that keeps taking its worker
|
|
|
573
576
|
|
|
574
577
|
The recovery write is conditional on the owner and lease that the scan read, so only one manager recovers each task.
|
|
575
578
|
|
|
576
|
-
If the pubsub redelivers the unacknowledged dispatch of an abandoned task, the redelivery claims the task once its lease expires and runs it again, even when `maxRetries` is `0`.
|
|
579
|
+
If the pubsub redelivers the unacknowledged dispatch of an abandoned task, the redelivery claims the task once its lease expires and runs it again, even when `maxRetries` is `0`. If the task's snapshot already holds a suspension from its current attempt, the redelivery stores the task as `suspended` instead of running it again.
|
|
577
580
|
|
|
578
581
|
The manager that runs the recovered task needs an executor for it. See the known limitations under [non-agent owners](#non-agent-owners).
|
|
579
582
|
|
|
@@ -207,6 +207,8 @@ export const supportAgent = new Agent({
|
|
|
207
207
|
|
|
208
208
|
Title generation runs asynchronously after the agent responds and doesn't affect response time.
|
|
209
209
|
|
|
210
|
+
On serverless runtimes, the platform can stop a request as soon as the response is sent, which cancels background work. Mastra's server passes the platform's `waitUntil` to agent runs so title generation finishes: Cloudflare Workers, Netlify, and Vercel deployments handle this automatically. When you call an agent directly inside your own serverless handler, pass `serverless: { waitUntil }` in the execution options.
|
|
211
|
+
|
|
210
212
|
### Streaming the generated title
|
|
211
213
|
|
|
212
214
|
By default title generation runs in the background and the run's stream doesn't wait for it, so HTTP clients only see the title on their next thread fetch. Set `emitEvent: true` to deliver the title on the run's stream instead: the stream waits for the title and emits a transient `data-thread-title` chunk before `finish`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { embedMany } from './_types/@internal_ai-sdk-v4@0.0.
|
|
1
|
+
import { embedMany } from './_types/@internal_ai-sdk-v4@0.0.100/dist/index.js';
|
|
2
2
|
import type { MastraDBMessage } from '@mastra/core/agent';
|
|
3
3
|
import type { Mastra } from '@mastra/core/mastra';
|
|
4
4
|
import { MastraMemory } from '@mastra/core/memory';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/memory",
|
|
3
|
-
"version": "1.42.0
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"probe-image-size": "^7.4.0",
|
|
54
54
|
"xxhash-wasm": "^1.1.0",
|
|
55
55
|
"zod": "^4.6.7",
|
|
56
|
-
"@mastra/schema-compat": "1.4.
|
|
56
|
+
"@mastra/schema-compat": "1.4.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@ai-sdk/openai-v5": "npm:@ai-sdk/openai@2.0.139",
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
"tsx": "^4.23.15",
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
69
|
"vitest": "5.1.0",
|
|
70
|
-
"@internal/ai-sdk-
|
|
71
|
-
"@internal/
|
|
72
|
-
"@internal/
|
|
73
|
-
"@
|
|
74
|
-
"@internal/
|
|
75
|
-
"@
|
|
76
|
-
"@internal/
|
|
70
|
+
"@internal/ai-sdk-v4": "0.0.100",
|
|
71
|
+
"@internal/ai-sdk-v5": "0.0.100",
|
|
72
|
+
"@internal/ai-v6": "0.0.100",
|
|
73
|
+
"@internal/ai-v7": "0.0.100",
|
|
74
|
+
"@internal/types-builder": "0.0.128",
|
|
75
|
+
"@mastra/core": "1.87.0",
|
|
76
|
+
"@internal/lint": "0.0.153"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@mastra/core": ">=1.85.1-0 <2.0.0-0"
|
/package/dist/_types/{@internal_ai-sdk-v4@0.0.99 → @internal_ai-sdk-v4@0.0.100}/package.json
RENAMED
|
File without changes
|