@mastra/core 1.5.0 → 1.6.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 +386 -0
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/adapters/AIV5Adapter.d.ts.map +1 -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 +7 -7
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +7 -7
- package/dist/agent/workflows/prepare-stream/schema.d.ts +11 -11
- package/dist/{chunk-CQ4Z6ZAV.cjs → chunk-3U3XFMGJ.cjs} +7 -7
- package/dist/{chunk-CQ4Z6ZAV.cjs.map → chunk-3U3XFMGJ.cjs.map} +1 -1
- package/dist/{chunk-D57U4II4.js → chunk-4WG5K4CK.js} +9 -8
- package/dist/chunk-4WG5K4CK.js.map +1 -0
- package/dist/{chunk-UZFGMMKU.js → chunk-5K45E5VE.js} +37 -3
- package/dist/chunk-5K45E5VE.js.map +1 -0
- package/dist/{chunk-OQ5LZ6OV.cjs → chunk-5VQPSWPG.cjs} +149 -61
- package/dist/chunk-5VQPSWPG.cjs.map +1 -0
- package/dist/{chunk-AIRMLZ43.js → chunk-7EXW4AAG.js} +4 -4
- package/dist/{chunk-AIRMLZ43.js.map → chunk-7EXW4AAG.js.map} +1 -1
- package/dist/{chunk-S4VVZI4E.cjs → chunk-AYHSPIT6.cjs} +326 -5
- package/dist/chunk-AYHSPIT6.cjs.map +1 -0
- package/dist/{chunk-YW54RH77.cjs → chunk-DB7U2C5B.cjs} +12 -5
- package/dist/chunk-DB7U2C5B.cjs.map +1 -0
- package/dist/{chunk-DST75PA4.js → chunk-DGS2KGDI.js} +4 -4
- package/dist/{chunk-DST75PA4.js.map → chunk-DGS2KGDI.js.map} +1 -1
- package/dist/{chunk-YIN5F7VO.js → chunk-EEU5NHHU.js} +4254 -3958
- package/dist/chunk-EEU5NHHU.js.map +1 -0
- package/dist/{chunk-A6EWCOGA.cjs → chunk-H5S4PS44.cjs} +197 -27
- package/dist/chunk-H5S4PS44.cjs.map +1 -0
- package/dist/{chunk-3YMDR4OL.cjs → chunk-HTAUP7ER.cjs} +4 -4
- package/dist/{chunk-3YMDR4OL.cjs.map → chunk-HTAUP7ER.cjs.map} +1 -1
- package/dist/{chunk-OHLVZVIK.js → chunk-IC5OUWKJ.js} +12 -5
- package/dist/chunk-IC5OUWKJ.js.map +1 -0
- package/dist/{chunk-MZIMV2BB.js → chunk-IHDE4CJV.js} +244 -213
- package/dist/chunk-IHDE4CJV.js.map +1 -0
- package/dist/{chunk-3KJW4EMO.js → chunk-IHEYJDJP.js} +3 -3
- package/dist/{chunk-3KJW4EMO.js.map → chunk-IHEYJDJP.js.map} +1 -1
- package/dist/{chunk-CXVMDV2B.js → chunk-IOY7Y5GV.js} +197 -27
- package/dist/chunk-IOY7Y5GV.js.map +1 -0
- package/dist/{chunk-MDC6VYA6.cjs → chunk-KAVAKMOQ.cjs} +4 -8
- package/dist/chunk-KAVAKMOQ.cjs.map +1 -0
- package/dist/{chunk-7WC7ALDW.cjs → chunk-LNKS4TJ6.cjs} +6 -6
- package/dist/{chunk-7WC7ALDW.cjs.map → chunk-LNKS4TJ6.cjs.map} +1 -1
- package/dist/{chunk-R3364RAL.js → chunk-MWGGSA5Q.js} +4 -4
- package/dist/{chunk-R3364RAL.js.map → chunk-MWGGSA5Q.js.map} +1 -1
- package/dist/{chunk-QSN5KQXZ.cjs → chunk-O7PZ4VOO.cjs} +11 -11
- package/dist/{chunk-QSN5KQXZ.cjs.map → chunk-O7PZ4VOO.cjs.map} +1 -1
- package/dist/chunk-OQDRPRKM.cjs +46 -0
- package/dist/chunk-OQDRPRKM.cjs.map +1 -0
- package/dist/{chunk-YV2YGQRY.js → chunk-RHKNKJNM.js} +101 -13
- package/dist/chunk-RHKNKJNM.js.map +1 -0
- package/dist/{chunk-TPDMP7OD.js → chunk-RHYZ6CQN.js} +4 -8
- package/dist/chunk-RHYZ6CQN.js.map +1 -0
- package/dist/{chunk-G5JVVFIG.cjs → chunk-RZNHRIM7.cjs} +9 -9
- package/dist/{chunk-G5JVVFIG.cjs.map → chunk-RZNHRIM7.cjs.map} +1 -1
- package/dist/{chunk-JZ6TH4HQ.cjs → chunk-TL2TTA4X.cjs} +4260 -3962
- package/dist/chunk-TL2TTA4X.cjs.map +1 -0
- package/dist/{chunk-KNXZ7KYL.cjs → chunk-TVPANHLE.cjs} +40 -2
- package/dist/chunk-TVPANHLE.cjs.map +1 -0
- package/dist/{chunk-7S6LA43E.cjs → chunk-VJWRJWSC.cjs} +278 -248
- package/dist/chunk-VJWRJWSC.cjs.map +1 -0
- package/dist/chunk-X2HAI3OX.js +39 -0
- package/dist/chunk-X2HAI3OX.js.map +1 -0
- package/dist/{chunk-FZ5DRHKE.js → chunk-XB3DA67Q.js} +325 -5
- package/dist/chunk-XB3DA67Q.js.map +1 -0
- package/dist/{chunk-NUV3BLRH.cjs → chunk-XWZAKKFT.cjs} +17 -16
- package/dist/chunk-XWZAKKFT.cjs.map +1 -0
- package/dist/{chunk-4GB2GS4S.js → chunk-YM6245EM.js} +5 -5
- package/dist/{chunk-4GB2GS4S.js.map → chunk-YM6245EM.js.map} +1 -1
- package/dist/datasets/index.cjs +17 -17
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +417 -391
- package/dist/docs/references/docs-memory-observational-memory.md +2 -0
- package/dist/docs/references/docs-streaming-tool-streaming.md +6 -0
- package/dist/docs/references/docs-workspace-filesystem.md +21 -1
- package/dist/docs/references/reference-harness-harness-class.md +645 -0
- package/dist/docs/references/reference-memory-memory-class.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +1 -0
- package/dist/docs/references/reference-workspace-local-filesystem.md +25 -0
- package/dist/docs/references/reference-workspace-workspace-class.md +1 -24
- package/dist/docs/references/reference.md +1 -0
- package/dist/editor/types.d.ts +20 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/evals/base.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/events/index.cjs +6 -2
- package/dist/events/index.d.ts +1 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +1 -1
- package/dist/harness/harness.d.ts +105 -35
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/index.cjs +472 -64
- package/dist/harness/index.cjs.map +1 -1
- package/dist/harness/index.d.ts +2 -1
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +468 -62
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/tools.d.ts +38 -0
- package/dist/harness/tools.d.ts.map +1 -1
- package/dist/harness/types.d.ts +64 -9
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +12 -12
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -1
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +6 -6
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +21 -21
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +14 -14
- 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 +7 -7
- 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 +21 -21
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +30 -30
- package/dist/loop/workflows/stream.d.ts +0 -13
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/models-dev-6P4CM74H.js +3 -0
- package/dist/{models-dev-MDI5E2YA.js.map → models-dev-6P4CM74H.js.map} +1 -1
- package/dist/models-dev-CLLSNT5L.cjs +12 -0
- package/dist/{models-dev-BW2GAM3K.cjs.map → models-dev-CLLSNT5L.cjs.map} +1 -1
- package/dist/processor-provider/index.cjs +256 -0
- package/dist/processor-provider/index.cjs.map +1 -0
- package/dist/processor-provider/index.d.ts +5 -0
- package/dist/processor-provider/index.d.ts.map +1 -0
- package/dist/processor-provider/index.js +243 -0
- package/dist/processor-provider/index.js.map +1 -0
- package/dist/processor-provider/phase-filtered-processor.d.ts +22 -0
- package/dist/processor-provider/phase-filtered-processor.d.ts.map +1 -0
- package/dist/processor-provider/providers/index.d.ts +12 -0
- package/dist/processor-provider/providers/index.d.ts.map +1 -0
- package/dist/processor-provider/types.d.ts +65 -0
- package/dist/processor-provider/types.d.ts.map +1 -0
- package/dist/processors/index.cjs +41 -41
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/message-history.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +14 -14
- package/dist/provider-registry-HMTFO5FV.cjs +40 -0
- package/dist/{provider-registry-4PH2JPIA.cjs.map → provider-registry-HMTFO5FV.cjs.map} +1 -1
- package/dist/provider-registry-TTZ2WN2P.js +3 -0
- package/dist/{provider-registry-VEJ3PN4S.js.map → provider-registry-TTZ2WN2P.js.map} +1 -1
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/base.d.ts +2 -1
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +68 -52
- package/dist/storage/constants.d.ts +6 -2
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/index.d.ts +1 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +4 -1
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -1
- package/dist/storage/domains/mcp-servers/base.d.ts +47 -0
- package/dist/storage/domains/mcp-servers/base.d.ts.map +1 -0
- package/dist/storage/domains/mcp-servers/index.d.ts +3 -0
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -0
- package/dist/storage/domains/mcp-servers/inmemory.d.ts +31 -0
- package/dist/storage/domains/mcp-servers/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/types.d.ts +44 -44
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +178 -154
- package/dist/storage/index.js +2 -2
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +220 -6
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/aisdk/v5/input.d.ts.map +1 -1
- package/dist/stream/base/input.d.ts +19 -0
- package/dist/stream/base/input.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/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/vector/index.cjs +9 -9
- package/dist/vector/index.js +2 -2
- package/dist/workflows/evented/execution-engine.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workspace/constants/index.d.ts +1 -0
- package/dist/workspace/constants/index.d.ts.map +1 -1
- package/dist/workspace/index.cjs +64 -64
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/tools/ast-edit.d.ts +97 -0
- package/dist/workspace/tools/ast-edit.d.ts.map +1 -0
- package/dist/workspace/tools/search.d.ts +1 -1
- package/dist/workspace/tools/tools.d.ts.map +1 -1
- package/package.json +12 -11
- package/processor-provider.d.ts +1 -0
- package/dist/chunk-4D4KB75Y.cjs +0 -9
- package/dist/chunk-4D4KB75Y.cjs.map +0 -1
- package/dist/chunk-7S6LA43E.cjs.map +0 -1
- package/dist/chunk-A6EWCOGA.cjs.map +0 -1
- package/dist/chunk-BVUMKER5.js +0 -7
- package/dist/chunk-BVUMKER5.js.map +0 -1
- package/dist/chunk-CXVMDV2B.js.map +0 -1
- package/dist/chunk-D57U4II4.js.map +0 -1
- package/dist/chunk-FZ5DRHKE.js.map +0 -1
- package/dist/chunk-JZ6TH4HQ.cjs.map +0 -1
- package/dist/chunk-KNXZ7KYL.cjs.map +0 -1
- package/dist/chunk-MDC6VYA6.cjs.map +0 -1
- package/dist/chunk-MZIMV2BB.js.map +0 -1
- package/dist/chunk-NUV3BLRH.cjs.map +0 -1
- package/dist/chunk-OHLVZVIK.js.map +0 -1
- package/dist/chunk-OQ5LZ6OV.cjs.map +0 -1
- package/dist/chunk-S4VVZI4E.cjs.map +0 -1
- package/dist/chunk-TPDMP7OD.js.map +0 -1
- package/dist/chunk-UZFGMMKU.js.map +0 -1
- package/dist/chunk-YIN5F7VO.js.map +0 -1
- package/dist/chunk-YV2YGQRY.js.map +0 -1
- package/dist/chunk-YW54RH77.cjs.map +0 -1
- package/dist/models-dev-BW2GAM3K.cjs +0 -12
- package/dist/models-dev-MDI5E2YA.js +0 -3
- package/dist/provider-registry-4PH2JPIA.cjs +0 -40
- package/dist/provider-registry-VEJ3PN4S.js +0 -3
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { DefaultVoice } from './chunk-LHRHOPUC.js';
|
|
2
|
-
import { extractLines, createWorkspaceTools, BM25Index } from './chunk-FZ5DRHKE.js';
|
|
3
2
|
import { PUBSUB_SYMBOL, STREAM_FORMAT_SYMBOL } from './chunk-2QXNHEDL.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { extractLines, createWorkspaceTools, BM25Index } from './chunk-XB3DA67Q.js';
|
|
4
|
+
import { InMemoryStore } from './chunk-EEU5NHHU.js';
|
|
5
|
+
import { MessageList, coreContentToString, DefaultGeneratedFile, DefaultGeneratedFileWithType } from './chunk-IC5OUWKJ.js';
|
|
6
6
|
import { parsePartialJson, isDeepEqualData, stepCountIs } from './chunk-UTLWS5LV.js';
|
|
7
7
|
import { generateId, asSchema, jsonSchema, APICallError, tool } from './chunk-CPLRD2VP.js';
|
|
8
8
|
import { executeHook } from './chunk-L54GIUCB.js';
|
|
9
|
-
import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-
|
|
9
|
+
import { resolveModelConfig, ModelRouterEmbeddingModel, ModelRouterLanguageModel } from './chunk-7EXW4AAG.js';
|
|
10
10
|
import { MastraLLMV1 } from './chunk-6DUTLERJ.js';
|
|
11
11
|
import { noopLogger } from './chunk-PSCMWPLC.js';
|
|
12
|
-
import {
|
|
12
|
+
import { EventEmitterPubSub } from './chunk-X2HAI3OX.js';
|
|
13
13
|
import { isZodType, removeUndefinedValues, ensureToolProperties, makeCoreTool, createMastraProxy, deepMerge, selectFields, delay } from './chunk-NN26FSKL.js';
|
|
14
14
|
import { getOrCreateSpan, wrapMastra, executeWithContextSync } from './chunk-33TGTTTS.js';
|
|
15
15
|
import { ToolStream } from './chunk-DD2VNRQM.js';
|
|
@@ -1954,6 +1954,58 @@ var ProcessorRunner = class _ProcessorRunner {
|
|
|
1954
1954
|
return {};
|
|
1955
1955
|
}
|
|
1956
1956
|
};
|
|
1957
|
+
|
|
1958
|
+
// src/stream/base/input.ts
|
|
1959
|
+
function safeEnqueue(controller, chunk) {
|
|
1960
|
+
try {
|
|
1961
|
+
controller.enqueue(chunk);
|
|
1962
|
+
return true;
|
|
1963
|
+
} catch {
|
|
1964
|
+
return false;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
function safeClose(controller) {
|
|
1968
|
+
try {
|
|
1969
|
+
controller.close();
|
|
1970
|
+
return true;
|
|
1971
|
+
} catch {
|
|
1972
|
+
return false;
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
function safeError(controller, error) {
|
|
1976
|
+
try {
|
|
1977
|
+
controller.error(error);
|
|
1978
|
+
return true;
|
|
1979
|
+
} catch {
|
|
1980
|
+
return false;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
var MastraModelInput = class extends MastraBase {
|
|
1984
|
+
initialize({ runId, createStream, onResult }) {
|
|
1985
|
+
const self = this;
|
|
1986
|
+
const stream = new ReadableStream({
|
|
1987
|
+
async start(controller) {
|
|
1988
|
+
try {
|
|
1989
|
+
const stream2 = await createStream();
|
|
1990
|
+
onResult({
|
|
1991
|
+
warnings: stream2.warnings,
|
|
1992
|
+
request: stream2.request,
|
|
1993
|
+
rawResponse: stream2.rawResponse || stream2.response || {}
|
|
1994
|
+
});
|
|
1995
|
+
await self.transform({
|
|
1996
|
+
runId,
|
|
1997
|
+
stream: stream2.stream,
|
|
1998
|
+
controller
|
|
1999
|
+
});
|
|
2000
|
+
safeClose(controller);
|
|
2001
|
+
} catch (error) {
|
|
2002
|
+
safeError(controller, error);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
});
|
|
2006
|
+
return stream;
|
|
2007
|
+
}
|
|
2008
|
+
};
|
|
1957
2009
|
function asJsonSchema(schema) {
|
|
1958
2010
|
if (!schema) {
|
|
1959
2011
|
return void 0;
|
|
@@ -3576,12 +3628,12 @@ var MastraModelOutput = class extends MastraBase {
|
|
|
3576
3628
|
return;
|
|
3577
3629
|
}
|
|
3578
3630
|
const chunkHandler = (chunk) => {
|
|
3579
|
-
controller
|
|
3631
|
+
safeEnqueue(controller, chunk);
|
|
3580
3632
|
};
|
|
3581
3633
|
const finishHandler = () => {
|
|
3582
3634
|
self.#emitter.off("chunk", chunkHandler);
|
|
3583
3635
|
self.#emitter.off("finish", finishHandler);
|
|
3584
|
-
controller
|
|
3636
|
+
safeClose(controller);
|
|
3585
3637
|
};
|
|
3586
3638
|
self.#emitter.on("chunk", chunkHandler);
|
|
3587
3639
|
self.#emitter.on("finish", finishHandler);
|
|
@@ -4606,36 +4658,6 @@ function runScorer({
|
|
|
4606
4658
|
};
|
|
4607
4659
|
executeHook("onScorerRun" /* ON_SCORER_RUN */, payload);
|
|
4608
4660
|
}
|
|
4609
|
-
var EventEmitterPubSub = class extends PubSub {
|
|
4610
|
-
emitter;
|
|
4611
|
-
constructor(existingEmitter) {
|
|
4612
|
-
super();
|
|
4613
|
-
this.emitter = existingEmitter ?? new EventEmitter2();
|
|
4614
|
-
}
|
|
4615
|
-
async publish(topic, event) {
|
|
4616
|
-
const id = crypto.randomUUID();
|
|
4617
|
-
const createdAt = /* @__PURE__ */ new Date();
|
|
4618
|
-
this.emitter.emit(topic, {
|
|
4619
|
-
...event,
|
|
4620
|
-
id,
|
|
4621
|
-
createdAt
|
|
4622
|
-
});
|
|
4623
|
-
}
|
|
4624
|
-
async subscribe(topic, cb) {
|
|
4625
|
-
this.emitter.on(topic, cb);
|
|
4626
|
-
}
|
|
4627
|
-
async unsubscribe(topic, cb) {
|
|
4628
|
-
this.emitter.off(topic, cb);
|
|
4629
|
-
}
|
|
4630
|
-
async flush() {
|
|
4631
|
-
}
|
|
4632
|
-
/**
|
|
4633
|
-
* Clean up all listeners during graceful shutdown.
|
|
4634
|
-
*/
|
|
4635
|
-
async close() {
|
|
4636
|
-
this.emitter.removeAllListeners();
|
|
4637
|
-
}
|
|
4638
|
-
};
|
|
4639
4661
|
var TextPartSchema = z.object({
|
|
4640
4662
|
type: z.literal("text"),
|
|
4641
4663
|
text: z.string()
|
|
@@ -10607,34 +10629,6 @@ var PrepareStepProcessor = class {
|
|
|
10607
10629
|
}
|
|
10608
10630
|
};
|
|
10609
10631
|
|
|
10610
|
-
// src/stream/base/input.ts
|
|
10611
|
-
var MastraModelInput = class extends MastraBase {
|
|
10612
|
-
initialize({ runId, createStream, onResult }) {
|
|
10613
|
-
const self = this;
|
|
10614
|
-
const stream = new ReadableStream({
|
|
10615
|
-
async start(controller) {
|
|
10616
|
-
try {
|
|
10617
|
-
const stream2 = await createStream();
|
|
10618
|
-
onResult({
|
|
10619
|
-
warnings: stream2.warnings,
|
|
10620
|
-
request: stream2.request,
|
|
10621
|
-
rawResponse: stream2.rawResponse || stream2.response || {}
|
|
10622
|
-
});
|
|
10623
|
-
await self.transform({
|
|
10624
|
-
runId,
|
|
10625
|
-
stream: stream2.stream,
|
|
10626
|
-
controller
|
|
10627
|
-
});
|
|
10628
|
-
controller.close();
|
|
10629
|
-
} catch (error) {
|
|
10630
|
-
controller.error(error);
|
|
10631
|
-
}
|
|
10632
|
-
}
|
|
10633
|
-
});
|
|
10634
|
-
return stream;
|
|
10635
|
-
}
|
|
10636
|
-
};
|
|
10637
|
-
|
|
10638
10632
|
// src/stream/aisdk/v5/input.ts
|
|
10639
10633
|
function isNumericId(id) {
|
|
10640
10634
|
return /^\d+$/.test(id);
|
|
@@ -10669,7 +10663,7 @@ var AISDKV5InputStream = class extends MastraModelInput {
|
|
|
10669
10663
|
}
|
|
10670
10664
|
transformedChunk.payload.id = idMap.get(originalId);
|
|
10671
10665
|
}
|
|
10672
|
-
controller
|
|
10666
|
+
safeEnqueue(controller, transformedChunk);
|
|
10673
10667
|
}
|
|
10674
10668
|
}
|
|
10675
10669
|
}
|
|
@@ -10983,9 +10977,7 @@ async function processOutputStream({
|
|
|
10983
10977
|
providerOptions: chunk.payload.providerMetadata
|
|
10984
10978
|
});
|
|
10985
10979
|
}
|
|
10986
|
-
|
|
10987
|
-
controller.enqueue(chunk);
|
|
10988
|
-
}
|
|
10980
|
+
safeEnqueue(controller, chunk);
|
|
10989
10981
|
break;
|
|
10990
10982
|
}
|
|
10991
10983
|
case "text-delta": {
|
|
@@ -10995,18 +10987,14 @@ async function processOutputStream({
|
|
|
10995
10987
|
textDeltas: textDeltasFromState,
|
|
10996
10988
|
isStreaming: true
|
|
10997
10989
|
});
|
|
10998
|
-
|
|
10999
|
-
controller.enqueue(chunk);
|
|
11000
|
-
}
|
|
10990
|
+
safeEnqueue(controller, chunk);
|
|
11001
10991
|
break;
|
|
11002
10992
|
}
|
|
11003
10993
|
case "text-end": {
|
|
11004
10994
|
runState.setState({
|
|
11005
10995
|
providerOptions: void 0
|
|
11006
10996
|
});
|
|
11007
|
-
|
|
11008
|
-
controller.enqueue(chunk);
|
|
11009
|
-
}
|
|
10997
|
+
safeEnqueue(controller, chunk);
|
|
11010
10998
|
break;
|
|
11011
10999
|
}
|
|
11012
11000
|
case "tool-call-input-streaming-start": {
|
|
@@ -11022,9 +11010,7 @@ async function processOutputStream({
|
|
|
11022
11010
|
logger?.error("Error calling onInputStart", error2);
|
|
11023
11011
|
}
|
|
11024
11012
|
}
|
|
11025
|
-
|
|
11026
|
-
controller.enqueue(chunk);
|
|
11027
|
-
}
|
|
11013
|
+
safeEnqueue(controller, chunk);
|
|
11028
11014
|
break;
|
|
11029
11015
|
}
|
|
11030
11016
|
case "tool-call-delta": {
|
|
@@ -11041,9 +11027,7 @@ async function processOutputStream({
|
|
|
11041
11027
|
logger?.error("Error calling onInputDelta", error2);
|
|
11042
11028
|
}
|
|
11043
11029
|
}
|
|
11044
|
-
|
|
11045
|
-
controller.enqueue(chunk);
|
|
11046
|
-
}
|
|
11030
|
+
safeEnqueue(controller, chunk);
|
|
11047
11031
|
break;
|
|
11048
11032
|
}
|
|
11049
11033
|
case "reasoning-start": {
|
|
@@ -11070,14 +11054,10 @@ async function processOutputStream({
|
|
|
11070
11054
|
createdAt: /* @__PURE__ */ new Date()
|
|
11071
11055
|
};
|
|
11072
11056
|
messageList.add(message, "response");
|
|
11073
|
-
|
|
11074
|
-
controller.enqueue(chunk);
|
|
11075
|
-
}
|
|
11057
|
+
safeEnqueue(controller, chunk);
|
|
11076
11058
|
break;
|
|
11077
11059
|
}
|
|
11078
|
-
|
|
11079
|
-
controller.enqueue(chunk);
|
|
11080
|
-
}
|
|
11060
|
+
safeEnqueue(controller, chunk);
|
|
11081
11061
|
break;
|
|
11082
11062
|
}
|
|
11083
11063
|
case "reasoning-delta": {
|
|
@@ -11088,9 +11068,7 @@ async function processOutputStream({
|
|
|
11088
11068
|
reasoningDeltas: reasoningDeltasFromState,
|
|
11089
11069
|
providerOptions: chunk.payload.providerMetadata ?? runState.state.providerOptions
|
|
11090
11070
|
});
|
|
11091
|
-
|
|
11092
|
-
controller.enqueue(chunk);
|
|
11093
|
-
}
|
|
11071
|
+
safeEnqueue(controller, chunk);
|
|
11094
11072
|
break;
|
|
11095
11073
|
}
|
|
11096
11074
|
case "reasoning-end": {
|
|
@@ -11116,9 +11094,7 @@ async function processOutputStream({
|
|
|
11116
11094
|
reasoningDeltas: [],
|
|
11117
11095
|
providerOptions: void 0
|
|
11118
11096
|
});
|
|
11119
|
-
|
|
11120
|
-
controller.enqueue(chunk);
|
|
11121
|
-
}
|
|
11097
|
+
safeEnqueue(controller, chunk);
|
|
11122
11098
|
break;
|
|
11123
11099
|
}
|
|
11124
11100
|
case "file":
|
|
@@ -11141,7 +11117,7 @@ async function processOutputStream({
|
|
|
11141
11117
|
createdAt: /* @__PURE__ */ new Date()
|
|
11142
11118
|
};
|
|
11143
11119
|
messageList.add(message, "response");
|
|
11144
|
-
controller
|
|
11120
|
+
safeEnqueue(controller, chunk);
|
|
11145
11121
|
}
|
|
11146
11122
|
break;
|
|
11147
11123
|
case "source":
|
|
@@ -11167,7 +11143,7 @@ async function processOutputStream({
|
|
|
11167
11143
|
createdAt: /* @__PURE__ */ new Date()
|
|
11168
11144
|
};
|
|
11169
11145
|
messageList.add(message, "response");
|
|
11170
|
-
controller
|
|
11146
|
+
safeEnqueue(controller, chunk);
|
|
11171
11147
|
}
|
|
11172
11148
|
break;
|
|
11173
11149
|
case "finish":
|
|
@@ -11201,13 +11177,11 @@ async function processOutputStream({
|
|
|
11201
11177
|
const error = getErrorFromUnknown(chunk.payload.error, {
|
|
11202
11178
|
fallbackMessage: "Unknown error in agent stream"
|
|
11203
11179
|
});
|
|
11204
|
-
controller
|
|
11180
|
+
safeEnqueue(controller, { ...chunk, payload: { ...chunk.payload, error } });
|
|
11205
11181
|
await options?.onError?.({ error });
|
|
11206
11182
|
break;
|
|
11207
11183
|
default:
|
|
11208
|
-
|
|
11209
|
-
controller.enqueue(chunk);
|
|
11210
|
-
}
|
|
11184
|
+
safeEnqueue(controller, chunk);
|
|
11211
11185
|
}
|
|
11212
11186
|
if ([
|
|
11213
11187
|
"text-delta",
|
|
@@ -11371,19 +11345,17 @@ function createLLMExecutionStep({
|
|
|
11371
11345
|
Object.assign(currentStep, processInputStepResult);
|
|
11372
11346
|
} catch (error) {
|
|
11373
11347
|
if (error instanceof TripWire) {
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
|
|
11381
|
-
|
|
11382
|
-
|
|
11383
|
-
|
|
11384
|
-
|
|
11385
|
-
});
|
|
11386
|
-
}
|
|
11348
|
+
safeEnqueue(controller, {
|
|
11349
|
+
type: "tripwire",
|
|
11350
|
+
runId,
|
|
11351
|
+
from: "AGENT" /* AGENT */,
|
|
11352
|
+
payload: {
|
|
11353
|
+
reason: error.message,
|
|
11354
|
+
retry: error.options?.retry,
|
|
11355
|
+
metadata: error.options?.metadata,
|
|
11356
|
+
processorId: error.processorId
|
|
11357
|
+
}
|
|
11358
|
+
});
|
|
11387
11359
|
const runState3 = new AgenticRunState({
|
|
11388
11360
|
_internal,
|
|
11389
11361
|
model
|
|
@@ -11510,10 +11482,7 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
11510
11482
|
warnings = warningsFromStream;
|
|
11511
11483
|
request = requestFromStream || {};
|
|
11512
11484
|
rawResponse = rawResponseFromStream;
|
|
11513
|
-
|
|
11514
|
-
return;
|
|
11515
|
-
}
|
|
11516
|
-
controller.enqueue({
|
|
11485
|
+
safeEnqueue(controller, {
|
|
11517
11486
|
runId,
|
|
11518
11487
|
from: "AGENT" /* AGENT */,
|
|
11519
11488
|
type: "step-start",
|
|
@@ -11595,20 +11564,16 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
11595
11564
|
await options?.onAbort?.({
|
|
11596
11565
|
steps: inputData?.output?.steps ?? []
|
|
11597
11566
|
});
|
|
11598
|
-
|
|
11599
|
-
controller.enqueue({ type: "abort", runId, from: "AGENT" /* AGENT */, payload: {} });
|
|
11600
|
-
}
|
|
11567
|
+
safeEnqueue(controller, { type: "abort", runId, from: "AGENT" /* AGENT */, payload: {} });
|
|
11601
11568
|
return { callBail: true, outputStream: outputStream2, runState: runState2, stepTools: currentStep.tools };
|
|
11602
11569
|
}
|
|
11603
11570
|
if (isLastModel) {
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
});
|
|
11611
|
-
}
|
|
11571
|
+
safeEnqueue(controller, {
|
|
11572
|
+
type: "error",
|
|
11573
|
+
runId,
|
|
11574
|
+
from: "AGENT" /* AGENT */,
|
|
11575
|
+
payload: { error }
|
|
11576
|
+
});
|
|
11612
11577
|
runState2.setState({
|
|
11613
11578
|
hasErrored: true,
|
|
11614
11579
|
stepResult: {
|
|
@@ -11689,7 +11654,8 @@ Analyse the suspended tools: ${JSON.stringify(suspendedTools)}, using the messag
|
|
|
11689
11654
|
toolName: toolCall.toolName,
|
|
11690
11655
|
args: toolCall.args
|
|
11691
11656
|
},
|
|
11692
|
-
|
|
11657
|
+
providerMetadata: toolCall.providerMetadata,
|
|
11658
|
+
providerExecuted: toolCall.providerExecuted
|
|
11693
11659
|
};
|
|
11694
11660
|
})
|
|
11695
11661
|
},
|
|
@@ -11944,7 +11910,7 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
|
|
|
11944
11910
|
};
|
|
11945
11911
|
rest.messageList.add(msg, "response");
|
|
11946
11912
|
}
|
|
11947
|
-
const hasPendingHITL = inputData.some((tc) => tc.result === void 0 && !tc.error);
|
|
11913
|
+
const hasPendingHITL = inputData.some((tc) => tc.result === void 0 && !tc.error && !tc.providerExecuted);
|
|
11948
11914
|
if (errorResults?.length > 0 && !hasPendingHITL) {
|
|
11949
11915
|
const successfulResults = inputData.filter((tc) => tc.result !== void 0);
|
|
11950
11916
|
if (successfulResults.length) {
|
|
@@ -11965,32 +11931,60 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
|
|
|
11965
11931
|
const processed = await processAndEnqueueChunk(chunk);
|
|
11966
11932
|
if (processed) await rest.options?.onChunk?.(processed);
|
|
11967
11933
|
}
|
|
11968
|
-
const
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
|
|
11972
|
-
|
|
11973
|
-
|
|
11974
|
-
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
|
|
11978
|
-
|
|
11979
|
-
|
|
11980
|
-
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
11985
|
-
|
|
11986
|
-
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11934
|
+
const clientResults = successfulResults.filter((tc) => !tc.providerExecuted);
|
|
11935
|
+
if (clientResults.length > 0) {
|
|
11936
|
+
const successMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
|
|
11937
|
+
const successMessage = {
|
|
11938
|
+
id: successMessageId || "",
|
|
11939
|
+
role: "assistant",
|
|
11940
|
+
content: {
|
|
11941
|
+
format: 2,
|
|
11942
|
+
parts: await Promise.all(
|
|
11943
|
+
clientResults.map(async (toolCall) => {
|
|
11944
|
+
const providerMetadata = await getProviderMetadataWithModelOutput(toolCall);
|
|
11945
|
+
return {
|
|
11946
|
+
type: "tool-invocation",
|
|
11947
|
+
toolInvocation: {
|
|
11948
|
+
state: "result",
|
|
11949
|
+
toolCallId: toolCall.toolCallId,
|
|
11950
|
+
toolName: toolCall.toolName,
|
|
11951
|
+
args: toolCall.args,
|
|
11952
|
+
result: toolCall.result
|
|
11953
|
+
},
|
|
11954
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
11955
|
+
};
|
|
11956
|
+
})
|
|
11957
|
+
)
|
|
11958
|
+
},
|
|
11959
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
11960
|
+
};
|
|
11961
|
+
rest.messageList.add(successMessage, "response");
|
|
11962
|
+
}
|
|
11963
|
+
if (successfulResults.some((tc) => tc.providerExecuted)) {
|
|
11964
|
+
const providerResults = successfulResults.filter((tc) => tc.providerExecuted);
|
|
11965
|
+
const providerMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
|
|
11966
|
+
const providerMessage = {
|
|
11967
|
+
id: providerMessageId || "",
|
|
11968
|
+
role: "assistant",
|
|
11969
|
+
content: {
|
|
11970
|
+
format: 2,
|
|
11971
|
+
parts: providerResults.map((toolCall) => ({
|
|
11972
|
+
type: "tool-invocation",
|
|
11973
|
+
toolInvocation: {
|
|
11974
|
+
state: "result",
|
|
11975
|
+
toolCallId: toolCall.toolCallId,
|
|
11976
|
+
toolName: toolCall.toolName,
|
|
11977
|
+
args: toolCall.args,
|
|
11978
|
+
result: toolCall.result
|
|
11979
|
+
},
|
|
11980
|
+
...toolCall.providerMetadata ? { providerMetadata: toolCall.providerMetadata } : {},
|
|
11981
|
+
providerExecuted: true
|
|
11982
|
+
}))
|
|
11983
|
+
},
|
|
11984
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
11985
|
+
};
|
|
11986
|
+
rest.messageList.add(providerMessage, "response");
|
|
11987
|
+
}
|
|
11994
11988
|
}
|
|
11995
11989
|
initialResult.stepResult.isContinued = true;
|
|
11996
11990
|
initialResult.stepResult.reason = "tool-calls";
|
|
@@ -12033,32 +12027,60 @@ function createLLMMappingStep({ models, _internal, ...rest }, llmExecutionStep)
|
|
|
12033
12027
|
const processed = await processAndEnqueueChunk(chunk);
|
|
12034
12028
|
if (processed) await rest.options?.onChunk?.(processed);
|
|
12035
12029
|
}
|
|
12036
|
-
const
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12030
|
+
const clientExecutedToolCalls = inputData.filter((toolCall) => !toolCall.providerExecuted);
|
|
12031
|
+
if (clientExecutedToolCalls.length > 0) {
|
|
12032
|
+
const toolResultMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
|
|
12033
|
+
const toolResultMessage = {
|
|
12034
|
+
id: toolResultMessageId || "",
|
|
12035
|
+
role: "assistant",
|
|
12036
|
+
content: {
|
|
12037
|
+
format: 2,
|
|
12038
|
+
parts: await Promise.all(
|
|
12039
|
+
clientExecutedToolCalls.map(async (toolCall) => {
|
|
12040
|
+
const providerMetadata = await getProviderMetadataWithModelOutput(toolCall);
|
|
12041
|
+
return {
|
|
12042
|
+
type: "tool-invocation",
|
|
12043
|
+
toolInvocation: {
|
|
12044
|
+
state: "result",
|
|
12045
|
+
toolCallId: toolCall.toolCallId,
|
|
12046
|
+
toolName: toolCall.toolName,
|
|
12047
|
+
args: toolCall.args,
|
|
12048
|
+
result: toolCall.result
|
|
12049
|
+
},
|
|
12050
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
12051
|
+
};
|
|
12052
|
+
})
|
|
12053
|
+
)
|
|
12054
|
+
},
|
|
12055
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
12056
|
+
};
|
|
12057
|
+
rest.messageList.add(toolResultMessage, "response");
|
|
12058
|
+
}
|
|
12059
|
+
const providerExecutedToolCalls = inputData.filter((toolCall) => toolCall.providerExecuted);
|
|
12060
|
+
if (providerExecutedToolCalls.length > 0) {
|
|
12061
|
+
const providerResultMessageId = rest.experimental_generateMessageId?.() || _internal?.generateId?.();
|
|
12062
|
+
const providerResultMessage = {
|
|
12063
|
+
id: providerResultMessageId || "",
|
|
12064
|
+
role: "assistant",
|
|
12065
|
+
content: {
|
|
12066
|
+
format: 2,
|
|
12067
|
+
parts: providerExecutedToolCalls.map((toolCall) => ({
|
|
12068
|
+
type: "tool-invocation",
|
|
12069
|
+
toolInvocation: {
|
|
12070
|
+
state: "result",
|
|
12071
|
+
toolCallId: toolCall.toolCallId,
|
|
12072
|
+
toolName: toolCall.toolName,
|
|
12073
|
+
args: toolCall.args,
|
|
12074
|
+
result: toolCall.result
|
|
12075
|
+
},
|
|
12076
|
+
...toolCall.providerMetadata ? { providerMetadata: toolCall.providerMetadata } : {},
|
|
12077
|
+
providerExecuted: true
|
|
12078
|
+
}))
|
|
12079
|
+
},
|
|
12080
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
12081
|
+
};
|
|
12082
|
+
rest.messageList.add(providerResultMessage, "response");
|
|
12083
|
+
}
|
|
12062
12084
|
return {
|
|
12063
12085
|
...initialResult,
|
|
12064
12086
|
messages: {
|
|
@@ -12231,7 +12253,7 @@ function createToolCallStep({
|
|
|
12231
12253
|
if (inputData.providerExecuted) {
|
|
12232
12254
|
return {
|
|
12233
12255
|
...inputData,
|
|
12234
|
-
result: inputData.output
|
|
12256
|
+
result: inputData.output ?? { providerExecuted: true, toolName: inputData.toolName }
|
|
12235
12257
|
};
|
|
12236
12258
|
}
|
|
12237
12259
|
if (!tool2) {
|
|
@@ -12469,6 +12491,14 @@ function createToolCallStep({
|
|
|
12469
12491
|
args.suspendedToolRunId = suspendedToolRunId;
|
|
12470
12492
|
}
|
|
12471
12493
|
}
|
|
12494
|
+
if (args === null || args === void 0) {
|
|
12495
|
+
return {
|
|
12496
|
+
error: new Error(
|
|
12497
|
+
`Tool "${inputData.toolName}" received invalid arguments \u2014 the provided JSON could not be parsed. Please provide valid JSON arguments.`
|
|
12498
|
+
),
|
|
12499
|
+
...inputData
|
|
12500
|
+
};
|
|
12501
|
+
}
|
|
12472
12502
|
const result = await tool2.execute(args, toolOptions);
|
|
12473
12503
|
if (tool2 && "onOutput" in tool2 && typeof tool2.onOutput === "function") {
|
|
12474
12504
|
try {
|
|
@@ -12660,15 +12690,13 @@ function createAgenticLoopWorkflow(params) {
|
|
|
12660
12690
|
const hasSteps = (typedInputData.output?.steps?.length ?? 0) > 0;
|
|
12661
12691
|
const shouldEmitStepFinish = typedInputData.stepResult?.reason !== "tripwire" || hasSteps;
|
|
12662
12692
|
if (shouldEmitStepFinish) {
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
});
|
|
12671
|
-
}
|
|
12693
|
+
safeEnqueue(controller, {
|
|
12694
|
+
type: "step-finish",
|
|
12695
|
+
runId,
|
|
12696
|
+
from: "AGENT" /* AGENT */,
|
|
12697
|
+
// @ts-expect-error TODO: Look into the proper types for this
|
|
12698
|
+
payload: typedInputData
|
|
12699
|
+
});
|
|
12672
12700
|
}
|
|
12673
12701
|
const reason = typedInputData.stepResult?.reason;
|
|
12674
12702
|
if (reason === void 0) {
|
|
@@ -12679,9 +12707,6 @@ function createAgenticLoopWorkflow(params) {
|
|
|
12679
12707
|
}
|
|
12680
12708
|
|
|
12681
12709
|
// src/loop/workflows/stream.ts
|
|
12682
|
-
function isControllerOpen(controller) {
|
|
12683
|
-
return controller.desiredSize !== 0 && controller.desiredSize !== null;
|
|
12684
|
-
}
|
|
12685
12710
|
function workflowLoopStream({
|
|
12686
12711
|
resumeContext,
|
|
12687
12712
|
requireToolApproval,
|
|
@@ -12720,7 +12745,7 @@ function workflowLoopStream({
|
|
|
12720
12745
|
};
|
|
12721
12746
|
messageList.add(message, "response");
|
|
12722
12747
|
}
|
|
12723
|
-
|
|
12748
|
+
safeEnqueue(controller, chunk);
|
|
12724
12749
|
};
|
|
12725
12750
|
const agenticLoopWorkflow = createAgenticLoopWorkflow({
|
|
12726
12751
|
resumeContext,
|
|
@@ -12763,7 +12788,7 @@ function workflowLoopStream({
|
|
|
12763
12788
|
}
|
|
12764
12789
|
};
|
|
12765
12790
|
if (!resumeContext) {
|
|
12766
|
-
controller
|
|
12791
|
+
safeEnqueue(controller, {
|
|
12767
12792
|
type: "start",
|
|
12768
12793
|
runId,
|
|
12769
12794
|
from: "AGENT" /* AGENT */,
|
|
@@ -12795,7 +12820,7 @@ function workflowLoopStream({
|
|
|
12795
12820
|
const error = getErrorFromUnknown(executionResult.error, {
|
|
12796
12821
|
fallbackMessage: "Unknown error in agent workflow stream"
|
|
12797
12822
|
});
|
|
12798
|
-
controller
|
|
12823
|
+
safeEnqueue(controller, {
|
|
12799
12824
|
type: "error",
|
|
12800
12825
|
runId,
|
|
12801
12826
|
from: "AGENT" /* AGENT */,
|
|
@@ -12808,11 +12833,11 @@ function workflowLoopStream({
|
|
|
12808
12833
|
if (executionResult.status !== "suspended") {
|
|
12809
12834
|
await agenticLoopWorkflow.deleteWorkflowRunById(runId);
|
|
12810
12835
|
}
|
|
12811
|
-
controller
|
|
12836
|
+
safeClose(controller);
|
|
12812
12837
|
return;
|
|
12813
12838
|
}
|
|
12814
12839
|
await agenticLoopWorkflow.deleteWorkflowRunById(runId);
|
|
12815
|
-
controller
|
|
12840
|
+
safeEnqueue(controller, {
|
|
12816
12841
|
type: "finish",
|
|
12817
12842
|
runId,
|
|
12818
12843
|
from: "AGENT" /* AGENT */,
|
|
@@ -12825,7 +12850,7 @@ function workflowLoopStream({
|
|
|
12825
12850
|
}
|
|
12826
12851
|
}
|
|
12827
12852
|
});
|
|
12828
|
-
controller
|
|
12853
|
+
safeClose(controller);
|
|
12829
12854
|
}
|
|
12830
12855
|
});
|
|
12831
12856
|
}
|
|
@@ -13126,16 +13151,19 @@ var MastraScorer = class _MastraScorer {
|
|
|
13126
13151
|
tracingContext
|
|
13127
13152
|
});
|
|
13128
13153
|
if (workflowResult.status === "failed") {
|
|
13129
|
-
throw new MastraError(
|
|
13130
|
-
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13154
|
+
throw new MastraError(
|
|
13155
|
+
{
|
|
13156
|
+
id: "MASTR_SCORER_FAILED_TO_RUN_WORKFLOW_FAILED",
|
|
13157
|
+
domain: "SCORER" /* SCORER */,
|
|
13158
|
+
category: "USER" /* USER */,
|
|
13159
|
+
text: `Scorer Run Failed: ${typeof workflowResult.error === "string" ? workflowResult.error : workflowResult.error.message}`,
|
|
13160
|
+
details: {
|
|
13161
|
+
scorerId: this.config.id ?? this.config.name,
|
|
13162
|
+
steps: this.steps.map((s) => s.name).join(", ")
|
|
13163
|
+
}
|
|
13164
|
+
},
|
|
13165
|
+
workflowResult.error instanceof Error ? workflowResult.error : void 0
|
|
13166
|
+
);
|
|
13139
13167
|
}
|
|
13140
13168
|
return this.transformToScorerResult({ workflowResult, originalInput: run });
|
|
13141
13169
|
}
|
|
@@ -13214,6 +13242,7 @@ var MastraScorer = class _MastraScorer {
|
|
|
13214
13242
|
validateInputs: false
|
|
13215
13243
|
}
|
|
13216
13244
|
});
|
|
13245
|
+
workflow.__setLogger(this.#mastra?.getLogger() ?? noopLogger);
|
|
13217
13246
|
let chainedWorkflow = workflow;
|
|
13218
13247
|
for (const step of workflowSteps) {
|
|
13219
13248
|
chainedWorkflow = chainedWorkflow.then(step);
|
|
@@ -15959,6 +15988,7 @@ async function networkLoop({
|
|
|
15959
15988
|
{ requestContext }
|
|
15960
15989
|
);
|
|
15961
15990
|
}
|
|
15991
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
15962
15992
|
if (isComplete) {
|
|
15963
15993
|
return {
|
|
15964
15994
|
...inputData,
|
|
@@ -23825,6 +23855,7 @@ var MessageHistory = class {
|
|
|
23825
23855
|
return messageList;
|
|
23826
23856
|
}
|
|
23827
23857
|
await this.persistMessages({ messages: messagesToSave, threadId, resourceId });
|
|
23858
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
23828
23859
|
return messageList;
|
|
23829
23860
|
}
|
|
23830
23861
|
/**
|
|
@@ -25284,6 +25315,6 @@ var MockMemory = class extends MastraMemory {
|
|
|
25284
25315
|
}
|
|
25285
25316
|
};
|
|
25286
25317
|
|
|
25287
|
-
export { Agent, BaseProcessor, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine,
|
|
25288
|
-
//# sourceMappingURL=chunk-
|
|
25289
|
-
//# sourceMappingURL=chunk-
|
|
25318
|
+
export { Agent, BaseProcessor, BatchPartsProcessor, ChunkFrom, DefaultExecutionEngine, 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 };
|
|
25319
|
+
//# sourceMappingURL=chunk-IHDE4CJV.js.map
|
|
25320
|
+
//# sourceMappingURL=chunk-IHDE4CJV.js.map
|