@mastra/core 1.3.0 → 1.4.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 +462 -0
- package/datasets.d.ts +1 -0
- package/dist/agent/agent.d.ts +1 -1
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/adapters/AIV4Adapter.d.ts.map +1 -1
- package/dist/agent/message-list/adapters/AIV5Adapter.d.ts.map +1 -1
- package/dist/agent/message-list/conversion/output-converter.d.ts +2 -1
- package/dist/agent/message-list/conversion/output-converter.d.ts.map +1 -1
- package/dist/agent/message-list/index.cjs +18 -18
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +1 -1
- package/dist/chunk-3JVFFAJX.cjs +1207 -0
- package/dist/chunk-3JVFFAJX.cjs.map +1 -0
- package/dist/{chunk-WL3AW3YA.js → chunk-3X3CZUXI.js} +4070 -3983
- package/dist/chunk-3X3CZUXI.js.map +1 -0
- package/dist/{chunk-2GWTJFVM.js → chunk-4EHGOATH.js} +46 -14
- package/dist/chunk-4EHGOATH.js.map +1 -0
- package/dist/{chunk-YNXIGRQE.cjs → chunk-4IJ4UDZX.cjs} +319 -83
- package/dist/chunk-4IJ4UDZX.cjs.map +1 -0
- package/dist/{chunk-CGPH7CMG.cjs → chunk-4KFEMXTV.cjs} +46 -14
- package/dist/chunk-4KFEMXTV.cjs.map +1 -0
- package/dist/{chunk-PHYJYZ32.js → chunk-4TQ4EBYX.js} +16 -8
- package/dist/chunk-4TQ4EBYX.js.map +1 -0
- package/dist/{chunk-SIZEIYNH.js → chunk-4XSAZPPS.js} +254 -18
- package/dist/chunk-4XSAZPPS.js.map +1 -0
- package/dist/{chunk-KUTU2YZF.js → chunk-5Q5Y34SS.js} +5 -5
- package/dist/{chunk-KUTU2YZF.js.map → chunk-5Q5Y34SS.js.map} +1 -1
- package/dist/{chunk-EH6SAGEO.cjs → chunk-64WGYTQK.cjs} +72 -53
- package/dist/{chunk-EH6SAGEO.cjs.map → chunk-64WGYTQK.cjs.map} +1 -1
- package/dist/{chunk-OOCEAC6U.cjs → chunk-65PHUUMF.cjs} +3 -3
- package/dist/{chunk-OOCEAC6U.cjs.map → chunk-65PHUUMF.cjs.map} +1 -1
- package/dist/{chunk-JNE2ABVB.js → chunk-7NKUSQEV.js} +1094 -10
- package/dist/chunk-7NKUSQEV.js.map +1 -0
- package/dist/{chunk-ZHFM7HCQ.js → chunk-AXHBJ4GX.js} +3 -3
- package/dist/{chunk-ZHFM7HCQ.js.map → chunk-AXHBJ4GX.js.map} +1 -1
- package/dist/{chunk-ILQXPZCD.js → chunk-AY6DBRS3.js} +37 -21
- package/dist/chunk-AY6DBRS3.js.map +1 -0
- package/dist/{chunk-TERSHTY5.cjs → chunk-BP7VYTOP.cjs} +1116 -21
- package/dist/chunk-BP7VYTOP.cjs.map +1 -0
- package/dist/{chunk-UE2G2LRP.cjs → chunk-CZ4NQANZ.cjs} +37 -21
- package/dist/chunk-CZ4NQANZ.cjs.map +1 -0
- package/dist/{chunk-NCC45KOB.cjs → chunk-DBSVT6AR.cjs} +7 -7
- package/dist/{chunk-NCC45KOB.cjs.map → chunk-DBSVT6AR.cjs.map} +1 -1
- package/dist/{chunk-BXLLXTT4.js → chunk-FLPEGTEK.js} +4 -4
- package/dist/{chunk-BXLLXTT4.js.map → chunk-FLPEGTEK.js.map} +1 -1
- package/dist/{chunk-ON2KVIUJ.cjs → chunk-HYRYTTMT.cjs} +7 -7
- package/dist/{chunk-ON2KVIUJ.cjs.map → chunk-HYRYTTMT.cjs.map} +1 -1
- package/dist/chunk-NJ7TL3LQ.js +1196 -0
- package/dist/chunk-NJ7TL3LQ.js.map +1 -0
- package/dist/{chunk-EUG4AON3.cjs → chunk-NKYWDNCI.cjs} +8 -7
- package/dist/{chunk-EUG4AON3.cjs.map → chunk-NKYWDNCI.cjs.map} +1 -1
- package/dist/{chunk-UHVG25VW.cjs → chunk-NZG2JAKS.cjs} +23 -15
- package/dist/chunk-NZG2JAKS.cjs.map +1 -0
- package/dist/{chunk-44SUGDBR.js → chunk-PS5ONCXY.js} +109 -5
- package/dist/chunk-PS5ONCXY.js.map +1 -0
- package/dist/{chunk-57QAF2ZQ.js → chunk-QTTWRCB5.js} +4 -4
- package/dist/{chunk-57QAF2ZQ.js.map → chunk-QTTWRCB5.js.map} +1 -1
- package/dist/{chunk-VM25PDSW.js → chunk-RZ4CIIZR.js} +4 -4
- package/dist/{chunk-VM25PDSW.js.map → chunk-RZ4CIIZR.js.map} +1 -1
- package/dist/{chunk-C3XU7ZDC.cjs → chunk-SU5APAM6.cjs} +123 -4
- package/dist/chunk-SU5APAM6.cjs.map +1 -0
- package/dist/{chunk-3MJCJLZS.js → chunk-U2HKJZCI.js} +24 -5
- package/dist/{chunk-3MJCJLZS.js.map → chunk-U2HKJZCI.js.map} +1 -1
- package/dist/{chunk-GCTAD6B7.cjs → chunk-VD5YA6RH.cjs} +12 -12
- package/dist/{chunk-GCTAD6B7.cjs.map → chunk-VD5YA6RH.cjs.map} +1 -1
- package/dist/{chunk-KAJNBNWP.cjs → chunk-YNNJLLFN.cjs} +4071 -3984
- package/dist/chunk-YNNJLLFN.cjs.map +1 -0
- package/dist/datasets/dataset.d.ts +153 -0
- package/dist/datasets/dataset.d.ts.map +1 -0
- package/dist/datasets/experiment/analytics/aggregate.d.ts +46 -0
- package/dist/datasets/experiment/analytics/aggregate.d.ts.map +1 -0
- package/dist/datasets/experiment/analytics/compare.d.ts +33 -0
- package/dist/datasets/experiment/analytics/compare.d.ts.map +1 -0
- package/dist/datasets/experiment/analytics/index.d.ts +9 -0
- package/dist/datasets/experiment/analytics/index.d.ts.map +1 -0
- package/dist/datasets/experiment/analytics/types.d.ts +103 -0
- package/dist/datasets/experiment/analytics/types.d.ts.map +1 -0
- package/dist/datasets/experiment/executor.d.ts +40 -0
- package/dist/datasets/experiment/executor.d.ts.map +1 -0
- package/dist/datasets/experiment/index.d.ts +31 -0
- package/dist/datasets/experiment/index.d.ts.map +1 -0
- package/dist/datasets/experiment/scorer.d.ts +21 -0
- package/dist/datasets/experiment/scorer.d.ts.map +1 -0
- package/dist/datasets/experiment/types.d.ts +140 -0
- package/dist/datasets/experiment/types.d.ts.map +1 -0
- package/dist/datasets/index.cjs +69 -0
- package/dist/datasets/index.cjs.map +1 -0
- package/dist/datasets/index.d.ts +6 -0
- package/dist/datasets/index.d.ts.map +1 -0
- package/dist/datasets/index.js +4 -0
- package/dist/datasets/index.js.map +1 -0
- package/dist/datasets/manager.d.ts +73 -0
- package/dist/datasets/manager.d.ts.map +1 -0
- package/dist/datasets/validation/errors.d.ts +44 -0
- package/dist/datasets/validation/errors.d.ts.map +1 -0
- package/dist/datasets/validation/index.d.ts +3 -0
- package/dist/datasets/validation/index.d.ts.map +1 -0
- package/dist/datasets/validation/validator.d.ts +24 -0
- package/dist/datasets/validation/validator.d.ts.map +1 -0
- package/dist/docs/SKILL.md +1 -3
- package/dist/docs/assets/SOURCE_MAP.json +436 -346
- package/dist/docs/references/docs-memory-observational-memory.md +86 -11
- package/dist/docs/references/docs-streaming-events.md +23 -0
- package/dist/docs/references/docs-workspace-filesystem.md +72 -1
- package/dist/docs/references/docs-workspace-overview.md +95 -12
- package/dist/docs/references/docs-workspace-sandbox.md +2 -0
- package/dist/docs/references/guides-agent-frameworks-ai-sdk.md +6 -2
- package/dist/docs/references/reference-ai-sdk-with-mastra.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +318 -9
- package/dist/docs/references/reference-streaming-workflows-stream.md +1 -0
- package/dist/docs/references/reference-workflows-workflow-methods-foreach.md +30 -0
- package/dist/docs/references/reference.md +3 -0
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.d.ts.map +1 -1
- package/dist/editor/types.d.ts +21 -3
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/features/index.cjs +1 -1
- package/dist/features/index.cjs.map +1 -1
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/index.js +1 -1
- package/dist/features/index.js.map +1 -1
- package/dist/index.cjs +2 -7
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/llm/index.cjs +10 -10
- package/dist/llm/index.js +2 -2
- package/dist/llm/model/provider-types.generated.d.ts +1694 -1659
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +1 -1
- package/dist/loop/workflows/errors.d.ts +4 -0
- package/dist/loop/workflows/errors.d.ts.map +1 -0
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +2 -0
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +5 -0
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/types.d.ts +56 -0
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/processors/index.cjs +41 -41
- package/dist/processors/index.js +1 -1
- package/dist/processors/processors/skills.d.ts +1 -1
- package/dist/processors/processors/skills.d.ts.map +1 -1
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/trailing-assistant-guard.d.ts +34 -0
- package/dist/processors/trailing-assistant-guard.d.ts.map +1 -0
- package/dist/provider-registry-6LZAGQET.cjs +40 -0
- package/dist/{provider-registry-C6XCYX44.cjs.map → provider-registry-6LZAGQET.cjs.map} +1 -1
- package/dist/provider-registry-QUNT7S55.js +3 -0
- package/dist/{provider-registry-NWU4YFQW.js.map → provider-registry-QUNT7S55.js.map} +1 -1
- package/dist/provider-registry.json +4068 -3981
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/base.d.ts +4 -1
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +87 -27
- package/dist/storage/constants.d.ts +21 -2
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/datasets/base.d.ts +83 -0
- package/dist/storage/domains/datasets/base.d.ts.map +1 -0
- package/dist/storage/domains/datasets/index.d.ts +3 -0
- package/dist/storage/domains/datasets/index.d.ts.map +1 -0
- package/dist/storage/domains/datasets/inmemory.d.ts +40 -0
- package/dist/storage/domains/datasets/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/experiments/base.d.ts +28 -0
- package/dist/storage/domains/experiments/base.d.ts.map +1 -0
- package/dist/storage/domains/experiments/index.d.ts +3 -0
- package/dist/storage/domains/experiments/index.d.ts.map +1 -0
- package/dist/storage/domains/experiments/inmemory.d.ts +28 -0
- package/dist/storage/domains/experiments/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/index.d.ts +3 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +9 -1
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
- package/dist/storage/domains/mcp-clients/base.d.ts +47 -0
- package/dist/storage/domains/mcp-clients/base.d.ts.map +1 -0
- package/dist/storage/domains/mcp-clients/index.d.ts +3 -0
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -0
- package/dist/storage/domains/mcp-clients/inmemory.d.ts +31 -0
- package/dist/storage/domains/mcp-clients/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +201 -117
- package/dist/storage/index.js +2 -2
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +338 -3
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +15 -0
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tool-provider/index.cjs +4 -0
- package/dist/tool-provider/index.cjs.map +1 -0
- package/dist/tool-provider/index.d.ts +2 -0
- package/dist/tool-provider/index.d.ts.map +1 -0
- package/dist/tool-provider/index.js +3 -0
- package/dist/tool-provider/index.js.map +1 -0
- package/dist/tool-provider/types.d.ts +113 -0
- package/dist/tool-provider/types.d.ts.map +1 -0
- package/dist/utils.cjs +23 -23
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/workflow.d.ts +2 -2
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/dist/workspace/filesystem/filesystem.d.ts +5 -15
- package/dist/workspace/filesystem/filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/local-filesystem.d.ts +18 -2
- package/dist/workspace/filesystem/local-filesystem.d.ts.map +1 -1
- package/dist/workspace/filesystem/mastra-filesystem.d.ts +21 -1
- package/dist/workspace/filesystem/mastra-filesystem.d.ts.map +1 -1
- package/dist/workspace/index.cjs +41 -41
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/lifecycle.d.ts +49 -53
- package/dist/workspace/lifecycle.d.ts.map +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/mastra-sandbox.d.ts +3 -2
- package/dist/workspace/sandbox/mastra-sandbox.d.ts.map +1 -1
- package/dist/workspace/sandbox/sandbox.d.ts +3 -4
- package/dist/workspace/sandbox/sandbox.d.ts.map +1 -1
- package/dist/workspace/workspace.d.ts +2 -15
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/llm/model/provider-types.generated.d.ts +1694 -1659
- package/tool-provider.d.ts +1 -0
- package/dist/chunk-2GWTJFVM.js.map +0 -1
- package/dist/chunk-44SUGDBR.js.map +0 -1
- package/dist/chunk-C3XU7ZDC.cjs.map +0 -1
- package/dist/chunk-CGPH7CMG.cjs.map +0 -1
- package/dist/chunk-ILQXPZCD.js.map +0 -1
- package/dist/chunk-JNE2ABVB.js.map +0 -1
- package/dist/chunk-KAJNBNWP.cjs.map +0 -1
- package/dist/chunk-PHYJYZ32.js.map +0 -1
- package/dist/chunk-SIZEIYNH.js.map +0 -1
- package/dist/chunk-TERSHTY5.cjs.map +0 -1
- package/dist/chunk-UE2G2LRP.cjs.map +0 -1
- package/dist/chunk-UHVG25VW.cjs.map +0 -1
- package/dist/chunk-WL3AW3YA.js.map +0 -1
- package/dist/chunk-YNXIGRQE.cjs.map +0 -1
- package/dist/docs/references/reference-cli-mastra.md +0 -336
- package/dist/docs/references/reference-deployer-cloudflare.md +0 -56
- package/dist/provider-registry-C6XCYX44.cjs +0 -40
- package/dist/provider-registry-NWU4YFQW.js +0 -3
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { extractLines, createWorkspaceTools, BM25Index } from './chunk-
|
|
1
|
+
import { extractLines, createWorkspaceTools, BM25Index } from './chunk-4EHGOATH.js';
|
|
2
2
|
import { DefaultVoice } from './chunk-LHRHOPUC.js';
|
|
3
3
|
import { PUBSUB_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-2QXNHEDL.js';
|
|
4
|
-
import { InMemoryStore } from './chunk-
|
|
5
|
-
import { MessageList, coreContentToString, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-
|
|
4
|
+
import { InMemoryStore } from './chunk-7NKUSQEV.js';
|
|
5
|
+
import { MessageList, coreContentToString, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-AY6DBRS3.js';
|
|
6
6
|
import { parsePartialJson, isDeepEqualData, stepCountIs } from './chunk-UTLWS5LV.js';
|
|
7
7
|
import { generateId, asSchema, jsonSchema, APICallError, tool } from './chunk-CPLRD2VP.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { executeHook } from './chunk-L54GIUCB.js';
|
|
9
|
+
import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-FLPEGTEK.js';
|
|
10
|
+
import { MastraLLMV1 } from './chunk-RZ4CIIZR.js';
|
|
10
11
|
import { noopLogger } from './chunk-PSCMWPLC.js';
|
|
11
12
|
import { PubSub } from './chunk-BVUMKER5.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
13
|
+
import { isZodType, removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, deepMerge, selectFields, delay } from './chunk-AXHBJ4GX.js';
|
|
14
|
+
import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-Y3TQ52UE.js';
|
|
14
15
|
import { ToolStream } from './chunk-DD2VNRQM.js';
|
|
15
16
|
import { Tool, createTool } from './chunk-RS6CZXGA.js';
|
|
16
|
-
import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-Y3TQ52UE.js';
|
|
17
17
|
import { RequestContext, MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY } from './chunk-CCLV5CAA.js';
|
|
18
18
|
import { MastraError, getErrorFromUnknown } from './chunk-FJEVLHJT.js';
|
|
19
19
|
import { zodToJsonSchema } from './chunk-PJKCPRYF.js';
|
|
@@ -990,6 +990,45 @@ function resolveThreadIdFromArgs(args) {
|
|
|
990
990
|
if (args?.threadId) return { id: args.threadId };
|
|
991
991
|
return void 0;
|
|
992
992
|
}
|
|
993
|
+
var CLAUDE_46_PATTERN = /[^0-9]4[.-]6/;
|
|
994
|
+
function isMaybeClaude46(model) {
|
|
995
|
+
if (typeof model === "function") return true;
|
|
996
|
+
if (Array.isArray(model)) {
|
|
997
|
+
return model.some((m) => isMaybeClaude46(m.model ?? m));
|
|
998
|
+
}
|
|
999
|
+
if (typeof model === "string") {
|
|
1000
|
+
return model.startsWith("anthropic") && CLAUDE_46_PATTERN.test(model);
|
|
1001
|
+
}
|
|
1002
|
+
if (model && typeof model === "object" && "provider" in model && "modelId" in model) {
|
|
1003
|
+
const { provider, modelId } = model;
|
|
1004
|
+
return provider.startsWith("anthropic") && CLAUDE_46_PATTERN.test(modelId);
|
|
1005
|
+
}
|
|
1006
|
+
return true;
|
|
1007
|
+
}
|
|
1008
|
+
var TrailingAssistantGuard = class {
|
|
1009
|
+
id = "trailing-assistant-guard";
|
|
1010
|
+
name = "Trailing Assistant Guard";
|
|
1011
|
+
processInputStep({ messages, structuredOutput }) {
|
|
1012
|
+
const willUseResponseFormat = structuredOutput?.schema && !structuredOutput?.model && !structuredOutput?.jsonPromptInjection;
|
|
1013
|
+
if (!willUseResponseFormat) return;
|
|
1014
|
+
const lastMessage = messages[messages.length - 1];
|
|
1015
|
+
if (!lastMessage || lastMessage.role !== "assistant") return;
|
|
1016
|
+
return {
|
|
1017
|
+
messages: [
|
|
1018
|
+
...messages,
|
|
1019
|
+
{
|
|
1020
|
+
id: randomUUID(),
|
|
1021
|
+
role: "user",
|
|
1022
|
+
content: {
|
|
1023
|
+
format: 2,
|
|
1024
|
+
parts: [{ type: "text", text: "Generate the structured response." }]
|
|
1025
|
+
},
|
|
1026
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1027
|
+
}
|
|
1028
|
+
]
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
993
1032
|
|
|
994
1033
|
// src/processors/runner.ts
|
|
995
1034
|
var ProcessorState = class {
|
|
@@ -1117,11 +1156,23 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1117
1156
|
);
|
|
1118
1157
|
}
|
|
1119
1158
|
if (result.status !== "success") {
|
|
1159
|
+
const details = [];
|
|
1160
|
+
if (result.status === "failed") {
|
|
1161
|
+
if (result.error) {
|
|
1162
|
+
details.push(result.error.message || JSON.stringify(result.error));
|
|
1163
|
+
}
|
|
1164
|
+
for (const [stepId, step] of Object.entries(result.steps)) {
|
|
1165
|
+
if (step.status === "failed" && step.error?.message) {
|
|
1166
|
+
details.push(`step ${stepId}: ${step.error.message}`);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
const detailStr = details.length > 0 ? ` \u2014 ${details.join("; ")}` : "";
|
|
1120
1171
|
throw new MastraError({
|
|
1121
1172
|
category: "USER",
|
|
1122
1173
|
domain: "AGENT",
|
|
1123
1174
|
id: "PROCESSOR_WORKFLOW_FAILED",
|
|
1124
|
-
text: `Processor workflow ${workflow.id} failed with status: ${result.status}`
|
|
1175
|
+
text: `Processor workflow ${workflow.id} failed with status: ${result.status}${detailStr}`
|
|
1125
1176
|
});
|
|
1126
1177
|
}
|
|
1127
1178
|
const output = result.result;
|
|
@@ -1541,7 +1592,8 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1541
1592
|
structuredOutput: args.structuredOutput,
|
|
1542
1593
|
retryCount: args.retryCount ?? 0
|
|
1543
1594
|
};
|
|
1544
|
-
|
|
1595
|
+
const processors = stepInput.model && isMaybeClaude46(stepInput.model) ? [...this.inputProcessors, new TrailingAssistantGuard()] : this.inputProcessors;
|
|
1596
|
+
for (const [index, processorOrWorkflow] of processors.entries()) {
|
|
1545
1597
|
const processableMessages = messageList.get.all.db();
|
|
1546
1598
|
const idsBeforeProcessing = processableMessages.map((m) => m.id);
|
|
1547
1599
|
const check = messageList.makeMessageSourceChecker();
|
|
@@ -5823,6 +5875,8 @@ async function executeForeach(engine, params) {
|
|
|
5823
5875
|
const prevForeachOutput = prevPayload?.suspendPayload?.__workflow_meta?.foreachOutput || [];
|
|
5824
5876
|
const prevResumeLabels = prevPayload?.suspendPayload?.__workflow_meta?.resumeLabels || {};
|
|
5825
5877
|
const resumeLabels = getResumeLabelsByStepId(prevResumeLabels, step.id);
|
|
5878
|
+
const totalCount = prevOutput.length;
|
|
5879
|
+
let completedCount = 0;
|
|
5826
5880
|
for (let i = 0; i < prevOutput.length; i += concurrency) {
|
|
5827
5881
|
const items = prevOutput.slice(i, i + concurrency);
|
|
5828
5882
|
const itemsResults = await Promise.all(
|
|
@@ -5873,7 +5927,36 @@ async function executeForeach(engine, params) {
|
|
|
5873
5927
|
const execResults = { status, error, suspendPayload, suspendedAt, endedAt, output };
|
|
5874
5928
|
if (execResults.status === "suspended") {
|
|
5875
5929
|
foreachIndexObj[i + resultIndex] = execResults;
|
|
5930
|
+
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
5931
|
+
type: "watch",
|
|
5932
|
+
runId,
|
|
5933
|
+
data: {
|
|
5934
|
+
type: "workflow-step-progress",
|
|
5935
|
+
payload: {
|
|
5936
|
+
id: step.id,
|
|
5937
|
+
completedCount,
|
|
5938
|
+
totalCount,
|
|
5939
|
+
currentIndex: i + resultIndex,
|
|
5940
|
+
iterationStatus: "suspended"
|
|
5941
|
+
}
|
|
5942
|
+
}
|
|
5943
|
+
});
|
|
5876
5944
|
} else {
|
|
5945
|
+
completedCount++;
|
|
5946
|
+
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
5947
|
+
type: "watch",
|
|
5948
|
+
runId,
|
|
5949
|
+
data: {
|
|
5950
|
+
type: "workflow-step-progress",
|
|
5951
|
+
payload: {
|
|
5952
|
+
id: step.id,
|
|
5953
|
+
completedCount,
|
|
5954
|
+
totalCount,
|
|
5955
|
+
currentIndex: i + resultIndex,
|
|
5956
|
+
iterationStatus: "failed"
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
});
|
|
5877
5960
|
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
5878
5961
|
type: "watch",
|
|
5879
5962
|
runId,
|
|
@@ -5899,6 +5982,22 @@ async function executeForeach(engine, params) {
|
|
|
5899
5982
|
return result;
|
|
5900
5983
|
}
|
|
5901
5984
|
} else {
|
|
5985
|
+
completedCount++;
|
|
5986
|
+
await pubsub.publish(`workflow.events.v2.${runId}`, {
|
|
5987
|
+
type: "watch",
|
|
5988
|
+
runId,
|
|
5989
|
+
data: {
|
|
5990
|
+
type: "workflow-step-progress",
|
|
5991
|
+
payload: {
|
|
5992
|
+
id: step.id,
|
|
5993
|
+
completedCount,
|
|
5994
|
+
totalCount,
|
|
5995
|
+
currentIndex: i + resultIndex,
|
|
5996
|
+
iterationStatus: "success",
|
|
5997
|
+
iterationOutput: result?.output
|
|
5998
|
+
}
|
|
5999
|
+
}
|
|
6000
|
+
});
|
|
5902
6001
|
const indexResumeLabel = Object.keys(resumeLabels).find(
|
|
5903
6002
|
(key) => resumeLabels[key]?.foreachIndex === i + resultIndex
|
|
5904
6003
|
);
|
|
@@ -11052,6 +11151,7 @@ function executeStreamWithFallbackModels(models, logger) {
|
|
|
11052
11151
|
let index = 0;
|
|
11053
11152
|
let finalResult;
|
|
11054
11153
|
let done = false;
|
|
11154
|
+
let lastError;
|
|
11055
11155
|
for (const modelConfig of models) {
|
|
11056
11156
|
index++;
|
|
11057
11157
|
const maxRetries = modelConfig.maxRetries || 0;
|
|
@@ -11070,6 +11170,7 @@ function executeStreamWithFallbackModels(models, logger) {
|
|
|
11070
11170
|
if (err instanceof TripWire) {
|
|
11071
11171
|
throw err;
|
|
11072
11172
|
}
|
|
11173
|
+
lastError = err;
|
|
11073
11174
|
attempt++;
|
|
11074
11175
|
logger?.error(`Error executing model ${modelConfig.model.modelId}, attempt ${attempt}====`, err);
|
|
11075
11176
|
if (attempt > maxRetries) {
|
|
@@ -11081,8 +11182,10 @@ function executeStreamWithFallbackModels(models, logger) {
|
|
|
11081
11182
|
}
|
|
11082
11183
|
}
|
|
11083
11184
|
if (typeof finalResult === "undefined") {
|
|
11084
|
-
|
|
11085
|
-
|
|
11185
|
+
const lastErrMsg = lastError instanceof Error ? lastError.message : String(lastError);
|
|
11186
|
+
const errorMessage = `Exhausted all fallback models and reached the maximum number of retries. Last error: ${lastErrMsg}`;
|
|
11187
|
+
logger?.error(errorMessage);
|
|
11188
|
+
throw new Error(errorMessage, { cause: lastError });
|
|
11086
11189
|
}
|
|
11087
11190
|
return finalResult;
|
|
11088
11191
|
};
|
|
@@ -11647,6 +11750,16 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
11647
11750
|
}
|
|
11648
11751
|
});
|
|
11649
11752
|
}
|
|
11753
|
+
|
|
11754
|
+
// src/loop/workflows/errors.ts
|
|
11755
|
+
var ToolNotFoundError = class extends Error {
|
|
11756
|
+
constructor(message) {
|
|
11757
|
+
super(message);
|
|
11758
|
+
this.name = "ToolNotFoundError";
|
|
11759
|
+
}
|
|
11760
|
+
};
|
|
11761
|
+
|
|
11762
|
+
// src/loop/workflows/agentic-execution/llm-mapping-step.ts
|
|
11650
11763
|
function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep) {
|
|
11651
11764
|
const processorRunner = rest.outputProcessors?.length && rest.logger ? new ProcessorRunner({
|
|
11652
11765
|
inputProcessors: [],
|
|
@@ -11738,6 +11851,60 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
|
|
|
11738
11851
|
};
|
|
11739
11852
|
rest.messageList.add(msg, "response");
|
|
11740
11853
|
}
|
|
11854
|
+
const allErrorsAreToolNotFound = errorResults?.length > 0 && errorResults.every((tc) => tc.error instanceof ToolNotFoundError);
|
|
11855
|
+
const hasPendingHITL = inputData.some((tc) => tc.result === void 0 && !tc.error);
|
|
11856
|
+
if (allErrorsAreToolNotFound && !hasPendingHITL) {
|
|
11857
|
+
const successfulResults = inputData.filter((tc) => tc.result !== void 0);
|
|
11858
|
+
if (successfulResults.length) {
|
|
11859
|
+
for (const toolCall of successfulResults) {
|
|
11860
|
+
const chunk = {
|
|
11861
|
+
type: "tool-result",
|
|
11862
|
+
runId: rest.runId,
|
|
11863
|
+
from: "AGENT" /* AGENT */,
|
|
11864
|
+
payload: {
|
|
11865
|
+
args: toolCall.args,
|
|
11866
|
+
toolCallId: toolCall.toolCallId,
|
|
11867
|
+
toolName: toolCall.toolName,
|
|
11868
|
+
result: toolCall.result,
|
|
11869
|
+
providerMetadata: toolCall.providerMetadata,
|
|
11870
|
+
providerExecuted: toolCall.providerExecuted
|
|
11871
|
+
}
|
|
11872
|
+
};
|
|
11873
|
+
await processAndEnqueueChunk(chunk);
|
|
11874
|
+
}
|
|
11875
|
+
const successMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
|
|
11876
|
+
const successMessage = {
|
|
11877
|
+
id: successMessageId || "",
|
|
11878
|
+
role: "assistant",
|
|
11879
|
+
content: {
|
|
11880
|
+
format: 2,
|
|
11881
|
+
parts: successfulResults.map((toolCall) => ({
|
|
11882
|
+
type: "tool-invocation",
|
|
11883
|
+
toolInvocation: {
|
|
11884
|
+
state: "result",
|
|
11885
|
+
toolCallId: toolCall.toolCallId,
|
|
11886
|
+
toolName: toolCall.toolName,
|
|
11887
|
+
args: toolCall.args,
|
|
11888
|
+
result: toolCall.result
|
|
11889
|
+
},
|
|
11890
|
+
...toolCall.providerMetadata ? { providerMetadata: toolCall.providerMetadata } : {}
|
|
11891
|
+
}))
|
|
11892
|
+
},
|
|
11893
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
11894
|
+
};
|
|
11895
|
+
rest.messageList.add(successMessage, "response");
|
|
11896
|
+
}
|
|
11897
|
+
initialResult.stepResult.isContinued = true;
|
|
11898
|
+
initialResult.stepResult.reason = "tool-calls";
|
|
11899
|
+
return {
|
|
11900
|
+
...initialResult,
|
|
11901
|
+
messages: {
|
|
11902
|
+
all: rest.messageList.get.all.aiV5.model(),
|
|
11903
|
+
user: rest.messageList.get.input.aiV5.model(),
|
|
11904
|
+
nonUser: rest.messageList.get.response.aiV5.model()
|
|
11905
|
+
}
|
|
11906
|
+
};
|
|
11907
|
+
}
|
|
11741
11908
|
if (initialResult.stepResult.reason !== "retry") {
|
|
11742
11909
|
initialResult.stepResult.isContinued = false;
|
|
11743
11910
|
}
|
|
@@ -11963,7 +12130,14 @@ function createToolCallStep({
|
|
|
11963
12130
|
};
|
|
11964
12131
|
}
|
|
11965
12132
|
if (!tool2) {
|
|
11966
|
-
|
|
12133
|
+
const availableToolNames = Object.keys(stepTools || {});
|
|
12134
|
+
const availableToolsStr = availableToolNames.length > 0 ? ` Available tools: ${availableToolNames.join(", ")}` : "";
|
|
12135
|
+
return {
|
|
12136
|
+
error: new ToolNotFoundError(
|
|
12137
|
+
`Tool "${inputData.toolName}" not found.${availableToolsStr}. Call tools by their exact name only \u2014 never add prefixes, namespaces, or colons.`
|
|
12138
|
+
),
|
|
12139
|
+
...inputData
|
|
12140
|
+
};
|
|
11967
12141
|
}
|
|
11968
12142
|
if (tool2 && "onInputAvailable" in tool2) {
|
|
11969
12143
|
try {
|
|
@@ -16197,9 +16371,9 @@ ${skillInstructions}`;
|
|
|
16197
16371
|
/**
|
|
16198
16372
|
* Process input step - inject available skills and provide skill tools
|
|
16199
16373
|
*/
|
|
16200
|
-
async processInputStep({ messageList, tools, stepNumber }) {
|
|
16374
|
+
async processInputStep({ messageList, tools, stepNumber, requestContext }) {
|
|
16201
16375
|
if (stepNumber === 0) {
|
|
16202
|
-
await this.skills?.maybeRefresh();
|
|
16376
|
+
await this.skills?.maybeRefresh({ requestContext });
|
|
16203
16377
|
}
|
|
16204
16378
|
const skillsList = await this.skills?.list();
|
|
16205
16379
|
const hasSkills = skillsList && skillsList.length > 0;
|
|
@@ -24172,6 +24346,14 @@ function augmentWithInit(storage) {
|
|
|
24172
24346
|
}
|
|
24173
24347
|
|
|
24174
24348
|
// src/memory/memory.ts
|
|
24349
|
+
function extractModelIdString(model) {
|
|
24350
|
+
if (typeof model === "string") return model;
|
|
24351
|
+
if (typeof model === "function") return void 0;
|
|
24352
|
+
if (model && typeof model === "object" && "id" in model && typeof model.id === "string") {
|
|
24353
|
+
return model.id;
|
|
24354
|
+
}
|
|
24355
|
+
return void 0;
|
|
24356
|
+
}
|
|
24175
24357
|
var MemoryProcessor = class extends MastraBase {
|
|
24176
24358
|
/**
|
|
24177
24359
|
* Process a list of messages and return a filtered or transformed list.
|
|
@@ -24618,7 +24800,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
24618
24800
|
* @returns Serializable memory configuration
|
|
24619
24801
|
*/
|
|
24620
24802
|
getConfig() {
|
|
24621
|
-
const { generateTitle, workingMemory, threads, ...restConfig } = this.threadConfig;
|
|
24803
|
+
const { generateTitle, workingMemory, threads, observationalMemory, ...restConfig } = this.threadConfig;
|
|
24622
24804
|
const config = {
|
|
24623
24805
|
vector: this.vector?.id,
|
|
24624
24806
|
options: {
|
|
@@ -24655,8 +24837,62 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
24655
24837
|
const { telemetry, ...rest } = this.embedderOptions;
|
|
24656
24838
|
config.embedderOptions = rest;
|
|
24657
24839
|
}
|
|
24840
|
+
if (observationalMemory !== void 0) {
|
|
24841
|
+
config.observationalMemory = this.serializeObservationalMemory(observationalMemory);
|
|
24842
|
+
}
|
|
24658
24843
|
return config;
|
|
24659
24844
|
}
|
|
24845
|
+
/**
|
|
24846
|
+
* Serialize observational memory config to a JSON-safe representation.
|
|
24847
|
+
* Model references that aren't string IDs are dropped (non-serializable).
|
|
24848
|
+
*/
|
|
24849
|
+
serializeObservationalMemory(om) {
|
|
24850
|
+
if (typeof om === "boolean") {
|
|
24851
|
+
return om;
|
|
24852
|
+
}
|
|
24853
|
+
if (om.enabled === false) {
|
|
24854
|
+
return false;
|
|
24855
|
+
}
|
|
24856
|
+
const result = {
|
|
24857
|
+
scope: om.scope,
|
|
24858
|
+
shareTokenBudget: om.shareTokenBudget
|
|
24859
|
+
};
|
|
24860
|
+
const topModelId = extractModelIdString(om.model);
|
|
24861
|
+
if (topModelId) {
|
|
24862
|
+
result.model = topModelId;
|
|
24863
|
+
}
|
|
24864
|
+
if (om.observation) {
|
|
24865
|
+
const obs = om.observation;
|
|
24866
|
+
result.observation = {
|
|
24867
|
+
messageTokens: obs.messageTokens,
|
|
24868
|
+
modelSettings: obs.modelSettings,
|
|
24869
|
+
providerOptions: obs.providerOptions,
|
|
24870
|
+
maxTokensPerBatch: obs.maxTokensPerBatch,
|
|
24871
|
+
bufferTokens: obs.bufferTokens,
|
|
24872
|
+
bufferActivation: obs.bufferActivation,
|
|
24873
|
+
blockAfter: obs.blockAfter
|
|
24874
|
+
};
|
|
24875
|
+
const obsModelId = extractModelIdString(obs.model);
|
|
24876
|
+
if (obsModelId) {
|
|
24877
|
+
result.observation.model = obsModelId;
|
|
24878
|
+
}
|
|
24879
|
+
}
|
|
24880
|
+
if (om.reflection) {
|
|
24881
|
+
const ref = om.reflection;
|
|
24882
|
+
result.reflection = {
|
|
24883
|
+
observationTokens: ref.observationTokens,
|
|
24884
|
+
modelSettings: ref.modelSettings,
|
|
24885
|
+
providerOptions: ref.providerOptions,
|
|
24886
|
+
blockAfter: ref.blockAfter,
|
|
24887
|
+
bufferActivation: ref.bufferActivation
|
|
24888
|
+
};
|
|
24889
|
+
const refModelId = extractModelIdString(ref.model);
|
|
24890
|
+
if (refModelId) {
|
|
24891
|
+
result.reflection.model = refModelId;
|
|
24892
|
+
}
|
|
24893
|
+
}
|
|
24894
|
+
return result;
|
|
24895
|
+
}
|
|
24660
24896
|
};
|
|
24661
24897
|
var isZodObject = (v) => v instanceof ZodObject;
|
|
24662
24898
|
var MockMemory = class extends MastraMemory {
|
|
@@ -24873,5 +25109,5 @@ var MockMemory = class extends MastraMemory {
|
|
|
24873
25109
|
};
|
|
24874
25110
|
|
|
24875
25111
|
export { Agent, BaseProcessor, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, EventEmitterPubSub, ExecutionEngine, FilePartSchema, ImagePartSchema, LanguageDetector, MastraAgentNetworkStream, MastraMemory, MastraModelOutput, MastraScorer, MemoryProcessor, MessageContentSchema, MessageHistory, MessagePartSchema, MockMemory, ModerationProcessor, PIIDetector, ProcessorInputPhaseSchema, ProcessorInputStepPhaseSchema, ProcessorMessageContentSchema, ProcessorMessageSchema, ProcessorOutputResultPhaseSchema, ProcessorOutputStepPhaseSchema, ProcessorOutputStreamPhaseSchema, ProcessorRunner, ProcessorState, ProcessorStepInputSchema, ProcessorStepOutputSchema, ProcessorStepSchema, PromptInjectionDetector, ReasoningPartSchema, Run, SemanticRecall, SkillsProcessor, SourcePartSchema, StepStartPartSchema, StructuredOutputProcessor, SystemPromptScrubber, TextPartSchema, TokenLimiterProcessor, ToolCallFilter, ToolInvocationPartSchema, ToolSearchProcessor, TripWire, UnicodeNormalizer, WORKING_MEMORY_END_TAG, WORKING_MEMORY_START_TAG, Workflow, WorkflowRunOutput, WorkingMemory, augmentWithInit, cleanStepResult, cloneStep, cloneWorkflow, convertFullStreamChunkToMastra, convertFullStreamChunkToUIMessageStream, convertMastraChunkToAISDKv5, createDeprecationProxy, createScorer, createStep, createTimeTravelExecutionParams, createWorkflow, extractWorkingMemoryContent, extractWorkingMemoryTags, formatCheckFeedback, formatCompletionFeedback, formatValidationFeedback, generateFinalResult, generateStructuredFinalResult, getResumeLabelsByStepId, getStepIds, getStepResult, getThreadOMMetadata, getZodErrors, globalEmbeddingCache, hydrateSerializedStepErrors, isObservationalMemoryEnabled, isProcessor, isProcessorWorkflow, isSupportedLanguageModel, loop, mapVariable, memoryDefaultOptions, parseMemoryRequestContext, removeWorkingMemoryTags, resolveThreadIdFromArgs, runChecks, runCompletionScorers, runCountDeprecationMessage, runDefaultCompletionCheck, runValidation, setThreadOMMetadata, supportedLanguageModelSpecifications, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, validateStepInput, validateStepRequestContext, validateStepResumeData, validateStepStateData, validateStepSuspendData };
|
|
24876
|
-
//# sourceMappingURL=chunk-
|
|
24877
|
-
//# sourceMappingURL=chunk-
|
|
25112
|
+
//# sourceMappingURL=chunk-4XSAZPPS.js.map
|
|
25113
|
+
//# sourceMappingURL=chunk-4XSAZPPS.js.map
|