@mastra/core 0.18.0 → 0.19.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/dist/action/index.d.ts +5 -5
- package/dist/action/index.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +20 -10
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +11 -11
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/input-processor/index.cjs +6 -6
- package/dist/agent/input-processor/index.js +1 -1
- package/dist/agent/message-list/index.d.ts +1 -1
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/trip-wire.d.ts +14 -0
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/types.d.ts +19 -11
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +4 -33
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/schema.d.ts +3 -1
- package/dist/agent/workflows/prepare-stream/schema.d.ts.map +1 -1
- package/dist/ai-tracing/exporters/default.d.ts +2 -2
- package/dist/ai-tracing/exporters/default.d.ts.map +1 -1
- package/dist/ai-tracing/index.cjs +32 -32
- package/dist/ai-tracing/index.js +1 -1
- package/dist/ai-tracing/types.d.ts +2 -2
- package/dist/ai-tracing/types.d.ts.map +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/{chunk-ITD7IHN5.js → chunk-2DGWSOVQ.js} +23 -5
- package/dist/chunk-2DGWSOVQ.js.map +1 -0
- package/dist/{chunk-WAGAASWE.cjs → chunk-2GHLV754.cjs} +5 -4
- package/dist/chunk-2GHLV754.cjs.map +1 -0
- package/dist/{chunk-JRTFV63C.cjs → chunk-3CCJVNYI.cjs} +48 -30
- package/dist/chunk-3CCJVNYI.cjs.map +1 -0
- package/dist/{chunk-TZZFP4EW.js → chunk-3WFH6YRI.js} +4 -4
- package/dist/{chunk-TZZFP4EW.js.map → chunk-3WFH6YRI.js.map} +1 -1
- package/dist/chunk-45CV4JYJ.cjs +4 -0
- package/dist/{chunk-VBPPPQO3.cjs.map → chunk-45CV4JYJ.cjs.map} +1 -1
- package/dist/{chunk-TJZ4ERV4.cjs → chunk-47WWN5FW.cjs} +19 -19
- package/dist/{chunk-TJZ4ERV4.cjs.map → chunk-47WWN5FW.cjs.map} +1 -1
- package/dist/{chunk-SEZBEL3U.js → chunk-4BEHJSL6.js} +4 -4
- package/dist/{chunk-SEZBEL3U.js.map → chunk-4BEHJSL6.js.map} +1 -1
- package/dist/{chunk-QIXLPKMN.cjs → chunk-4LGYM3WV.cjs} +4 -4
- package/dist/{chunk-QIXLPKMN.cjs.map → chunk-4LGYM3WV.cjs.map} +1 -1
- package/dist/chunk-4LSFAAZW.js +3 -0
- package/dist/{chunk-CE73R5W7.js.map → chunk-4LSFAAZW.js.map} +1 -1
- package/dist/{chunk-XUAWHRUO.cjs → chunk-4R2TBRS7.cjs} +37 -112
- package/dist/chunk-4R2TBRS7.cjs.map +1 -0
- package/dist/{chunk-AEYCHF2U.cjs → chunk-4VNAMG7K.cjs} +6 -6
- package/dist/{chunk-AEYCHF2U.cjs.map → chunk-4VNAMG7K.cjs.map} +1 -1
- package/dist/{chunk-FXLZYRV7.js → chunk-5HCVPQTD.js} +3 -3
- package/dist/{chunk-FXLZYRV7.js.map → chunk-5HCVPQTD.js.map} +1 -1
- package/dist/chunk-5M6ZTQJN.js +1374 -0
- package/dist/chunk-5M6ZTQJN.js.map +1 -0
- package/dist/{chunk-SW7WPHZ2.cjs → chunk-7E4ESNZS.cjs} +5 -5
- package/dist/{chunk-SW7WPHZ2.cjs.map → chunk-7E4ESNZS.cjs.map} +1 -1
- package/dist/{chunk-OVVKYARB.cjs → chunk-A4RAEU6X.cjs} +2 -2
- package/dist/chunk-A4RAEU6X.cjs.map +1 -0
- package/dist/{chunk-SHFLPFKN.js → chunk-BUY5X7DT.js} +4 -4
- package/dist/{chunk-SHFLPFKN.js.map → chunk-BUY5X7DT.js.map} +1 -1
- package/dist/{chunk-L7Z3C5XG.cjs → chunk-CQ73JM2N.cjs} +10 -10
- package/dist/{chunk-L7Z3C5XG.cjs.map → chunk-CQ73JM2N.cjs.map} +1 -1
- package/dist/{chunk-GGN63GU5.cjs → chunk-DRVSEV5Y.cjs} +25 -65
- package/dist/chunk-DRVSEV5Y.cjs.map +1 -0
- package/dist/{chunk-2TQHRYRK.cjs → chunk-EPMJYNEK.cjs} +4 -4
- package/dist/{chunk-2TQHRYRK.cjs.map → chunk-EPMJYNEK.cjs.map} +1 -1
- package/dist/{chunk-TKFLL33F.cjs → chunk-F6EJEELE.cjs} +9 -9
- package/dist/{chunk-TKFLL33F.cjs.map → chunk-F6EJEELE.cjs.map} +1 -1
- package/dist/{chunk-AR76DMZQ.js → chunk-FV4QVXO4.js} +2 -2
- package/dist/chunk-FV4QVXO4.js.map +1 -0
- package/dist/{chunk-O6PQYYT6.cjs → chunk-HQPFM22N.cjs} +63 -45
- package/dist/chunk-HQPFM22N.cjs.map +1 -0
- package/dist/{chunk-GMQUHK3L.js → chunk-IAXAPVOP.js} +4 -4
- package/dist/{chunk-GMQUHK3L.js.map → chunk-IAXAPVOP.js.map} +1 -1
- package/dist/{chunk-2ZSMA4EM.js → chunk-JJW5JU2G.js} +391 -367
- package/dist/chunk-JJW5JU2G.js.map +1 -0
- package/dist/{chunk-USHKSVKL.js → chunk-JWSZSM7U.js} +11 -9
- package/dist/{chunk-USHKSVKL.js.map → chunk-JWSZSM7U.js.map} +1 -1
- package/dist/{chunk-Y5XECV4O.cjs → chunk-K4AYIXVH.cjs} +4 -4
- package/dist/{chunk-Y5XECV4O.cjs.map → chunk-K4AYIXVH.cjs.map} +1 -1
- package/dist/{chunk-6NZTZOEI.js → chunk-LT6NPN3E.js} +33 -15
- package/dist/chunk-LT6NPN3E.js.map +1 -0
- package/dist/{chunk-7CF3FKP3.js → chunk-MAGA2UEJ.js} +4 -4
- package/dist/{chunk-7CF3FKP3.js.map → chunk-MAGA2UEJ.js.map} +1 -1
- package/dist/{chunk-RPFJBB5X.js → chunk-N4PK4MOG.js} +4 -4
- package/dist/{chunk-RPFJBB5X.js.map → chunk-N4PK4MOG.js.map} +1 -1
- package/dist/{chunk-TRZT7QPJ.cjs → chunk-NHJVMZIL.cjs} +19 -19
- package/dist/{chunk-TRZT7QPJ.cjs.map → chunk-NHJVMZIL.cjs.map} +1 -1
- package/dist/{chunk-BJZWMVNW.js → chunk-OBIF7QD5.js} +3 -3
- package/dist/{chunk-BJZWMVNW.js.map → chunk-OBIF7QD5.js.map} +1 -1
- package/dist/{chunk-JXRAFE3E.js → chunk-OSZMRVWP.js} +3 -3
- package/dist/{chunk-JXRAFE3E.js.map → chunk-OSZMRVWP.js.map} +1 -1
- package/dist/{chunk-SQFVIROI.js → chunk-PJ6HF3KW.js} +16 -56
- package/dist/chunk-PJ6HF3KW.js.map +1 -0
- package/dist/{chunk-CBV6EVJK.cjs → chunk-PLATPKJA.cjs} +433 -408
- package/dist/chunk-PLATPKJA.cjs.map +1 -0
- package/dist/{chunk-X2TVBX7O.js → chunk-RAXBZZKS.js} +4 -3
- package/dist/chunk-RAXBZZKS.js.map +1 -0
- package/dist/chunk-RFGQ3EQV.js +3 -0
- package/dist/chunk-RFGQ3EQV.js.map +1 -0
- package/dist/{chunk-YDLEEOJ6.js → chunk-RYFQKXXS.js} +3 -3
- package/dist/{chunk-YDLEEOJ6.js.map → chunk-RYFQKXXS.js.map} +1 -1
- package/dist/{chunk-C73WLCY3.cjs → chunk-S7UXT3V4.cjs} +21 -3
- package/dist/chunk-S7UXT3V4.cjs.map +1 -0
- package/dist/{chunk-R5GESRGB.js → chunk-SJMKDSRF.js} +37 -112
- package/dist/chunk-SJMKDSRF.js.map +1 -0
- package/dist/{chunk-YWXSGDDO.cjs → chunk-SQQMX4VC.cjs} +6 -6
- package/dist/{chunk-YWXSGDDO.cjs.map → chunk-SQQMX4VC.cjs.map} +1 -1
- package/dist/chunk-TCHOIK53.cjs +4 -0
- package/dist/chunk-TCHOIK53.cjs.map +1 -0
- package/dist/chunk-TIBULEK6.cjs +1379 -0
- package/dist/chunk-TIBULEK6.cjs.map +1 -0
- package/dist/{chunk-WECJNCGT.cjs → chunk-UTEH2LCJ.cjs} +19 -19
- package/dist/{chunk-WECJNCGT.cjs.map → chunk-UTEH2LCJ.cjs.map} +1 -1
- package/dist/{chunk-MCOVMKIS.js → chunk-WHFNGECY.js} +21 -4
- package/dist/chunk-WHFNGECY.js.map +1 -0
- package/dist/{chunk-NTXNE4YR.js → chunk-XG3SFWOH.js} +3 -3
- package/dist/{chunk-NTXNE4YR.js.map → chunk-XG3SFWOH.js.map} +1 -1
- package/dist/{chunk-UMATHB4Q.cjs → chunk-YJQDN37F.cjs} +40 -38
- package/dist/chunk-YJQDN37F.cjs.map +1 -0
- package/dist/error/index.cjs +5 -5
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +1 -1
- package/dist/error/utils.d.ts +8 -0
- package/dist/error/utils.d.ts.map +1 -0
- package/dist/eval/index.cjs +3 -3
- package/dist/eval/index.js +1 -1
- package/dist/index.cjs +87 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -17
- package/dist/index.js.map +1 -1
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +20 -0
- package/dist/llm/index.d.ts +3 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -1
- package/dist/llm/model/gateways/base.d.ts +42 -0
- package/dist/llm/model/gateways/base.d.ts.map +1 -0
- package/dist/llm/model/gateways/index.d.ts +3 -0
- package/dist/llm/model/gateways/index.d.ts.map +1 -0
- package/dist/llm/model/gateways/models-dev.d.ts +11 -0
- package/dist/llm/model/gateways/models-dev.d.ts.map +1 -0
- package/dist/llm/model/index.d.ts +2 -0
- package/dist/llm/model/index.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/openai-compatible.d.ts +32 -0
- package/dist/llm/model/openai-compatible.d.ts.map +1 -0
- package/dist/llm/model/provider-registry.generated.d.ts +462 -0
- package/dist/llm/model/provider-registry.generated.d.ts.map +1 -0
- package/dist/llm/model/shared.types.d.ts +8 -0
- package/dist/llm/model/shared.types.d.ts.map +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +18 -18
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/test-utils/fullStream.d.ts.map +1 -1
- package/dist/loop/test-utils/generateText.d.ts.map +1 -1
- package/dist/loop/test-utils/options.d.ts.map +1 -1
- package/dist/loop/test-utils/resultObject.d.ts.map +1 -1
- package/dist/loop/test-utils/streamObject.d.ts.map +1 -1
- package/dist/loop/test-utils/toUIMessageStream.d.ts.map +1 -1
- package/dist/loop/test-utils/tools.d.ts.map +1 -1
- package/dist/loop/types.d.ts +5 -5
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +147 -48
- package/dist/loop/workflows/agentic-execution/index.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +98 -32
- 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 +49 -16
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +147 -48
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/run-state.d.ts +5 -0
- package/dist/loop/workflows/run-state.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +57 -19
- package/dist/loop/workflows/schema.d.ts.map +1 -1
- package/dist/loop/workflows/stream.d.ts +13 -0
- package/dist/loop/workflows/stream.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +1 -1
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.js +1 -1
- package/dist/memory/types.d.ts +1 -1
- package/dist/network/vNext/index.cjs +29 -29
- package/dist/network/vNext/index.cjs.map +1 -1
- package/dist/network/vNext/index.d.ts +14 -14
- package/dist/network/vNext/index.js +17 -17
- package/dist/network/vNext/index.js.map +1 -1
- package/dist/processors/index.cjs +10 -10
- package/dist/processors/index.js +1 -1
- package/dist/processors/processors/language-detector.d.ts.map +1 -1
- package/dist/processors/processors/moderation.d.ts.map +1 -1
- package/dist/processors/processors/pii-detector.d.ts.map +1 -1
- package/dist/processors/processors/prompt-injection-detector.d.ts.map +1 -1
- package/dist/processors/processors/structured-output.d.ts.map +1 -1
- package/dist/processors/processors/system-prompt-scrubber.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +7 -7
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.js +1 -1
- package/dist/scores/index.cjs +9 -9
- package/dist/scores/index.js +2 -2
- package/dist/scores/scoreTraces/index.cjs +57 -68
- package/dist/scores/scoreTraces/index.cjs.map +1 -1
- package/dist/scores/scoreTraces/index.js +48 -59
- package/dist/scores/scoreTraces/index.js.map +1 -1
- package/dist/scores/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/scores/scoreTraces/utils.d.ts +4 -8
- package/dist/scores/scoreTraces/utils.d.ts.map +1 -1
- package/dist/scores/types.d.ts +8 -4
- package/dist/scores/types.d.ts.map +1 -1
- package/dist/server/index.cjs +7 -7
- package/dist/server/index.js +2 -2
- package/dist/storage/base.d.ts +14 -5
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/domains/observability/base.d.ts +5 -5
- package/dist/storage/domains/observability/base.d.ts.map +1 -1
- package/dist/storage/domains/observability/inmemory.d.ts +7 -7
- package/dist/storage/domains/observability/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/scores/base.d.ts +8 -0
- package/dist/storage/domains/scores/base.d.ts.map +1 -1
- package/dist/storage/domains/scores/inmemory.d.ts +8 -0
- package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +94 -64
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.js +59 -29
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/mock.d.ts +9 -0
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +2 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/compat/ui-message.d.ts +5 -5
- package/dist/stream/aisdk/v5/compat/ui-message.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +2 -5
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/input.d.ts +2 -1
- package/dist/stream/aisdk/v5/input.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output-helpers.d.ts +5 -11
- package/dist/stream/aisdk/v5/output-helpers.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +43 -16
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts +6 -6
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/input.d.ts +2 -1
- package/dist/stream/base/input.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +69 -82
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +4 -4
- package/dist/stream/index.d.ts +1 -1
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +1 -1
- package/dist/stream/types.d.ts +217 -96
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/telemetry/index.cjs +7 -7
- package/dist/telemetry/index.js +1 -1
- package/dist/test-utils/llm-mock.cjs +2 -2
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/tools/tool.d.ts +6 -8
- package/dist/tools/tool.d.ts.map +1 -1
- package/dist/tools/types.d.ts +8 -7
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +2 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.js +1 -1
- package/dist/{types.d.ts → types/dynamic-argument.d.ts} +3 -3
- package/dist/types/dynamic-argument.d.ts.map +1 -0
- package/dist/types/index.cjs +4 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/zod-compat.d.ts +23 -0
- package/dist/types/zod-compat.d.ts.map +1 -0
- package/dist/utils.cjs +17 -17
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +4 -4
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.js +1 -1
- package/dist/workflows/default.d.ts +1 -1
- package/dist/workflows/default.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 +1 -0
- 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/evented/workflow.d.ts +3 -1
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +2 -1
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/index.cjs +15 -11
- package/dist/workflows/index.d.ts +1 -0
- package/dist/workflows/index.d.ts.map +1 -1
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +22 -22
- package/dist/workflows/legacy/index.js +1 -1
- package/dist/workflows/legacy/step.d.ts +4 -4
- package/dist/workflows/legacy/step.d.ts.map +1 -1
- package/dist/workflows/legacy/types.d.ts +12 -7
- package/dist/workflows/legacy/types.d.ts.map +1 -1
- package/dist/workflows/legacy/workflow-instance.d.ts +2 -2
- package/dist/workflows/step.d.ts +3 -1
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +12 -1
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +10 -0
- package/dist/workflows/utils.d.ts.map +1 -0
- package/dist/workflows/workflow.d.ts +30 -14
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +6 -3
- package/types.d.ts +1 -0
- package/dist/chunk-2ZSMA4EM.js.map +0 -1
- package/dist/chunk-6NZTZOEI.js.map +0 -1
- package/dist/chunk-AR76DMZQ.js.map +0 -1
- package/dist/chunk-C73WLCY3.cjs.map +0 -1
- package/dist/chunk-CBV6EVJK.cjs.map +0 -1
- package/dist/chunk-CE73R5W7.js +0 -3
- package/dist/chunk-GGN63GU5.cjs.map +0 -1
- package/dist/chunk-ITD7IHN5.js.map +0 -1
- package/dist/chunk-JRTFV63C.cjs.map +0 -1
- package/dist/chunk-MCOVMKIS.js.map +0 -1
- package/dist/chunk-O6PQYYT6.cjs.map +0 -1
- package/dist/chunk-OVVKYARB.cjs.map +0 -1
- package/dist/chunk-R5GESRGB.js.map +0 -1
- package/dist/chunk-SQFVIROI.js.map +0 -1
- package/dist/chunk-UMATHB4Q.cjs.map +0 -1
- package/dist/chunk-VBPPPQO3.cjs +0 -4
- package/dist/chunk-WAGAASWE.cjs.map +0 -1
- package/dist/chunk-X2TVBX7O.js.map +0 -1
- package/dist/chunk-XUAWHRUO.cjs.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -11,119 +11,44 @@ var TABLE_SCORERS = "mastra_scorers";
|
|
|
11
11
|
var TABLE_AI_SPANS = "mastra_ai_spans";
|
|
12
12
|
var SCORERS_SCHEMA = {
|
|
13
13
|
id: { type: "text", nullable: false, primaryKey: true },
|
|
14
|
-
scorerId: {
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
extractStepResult: {
|
|
32
|
-
type: "jsonb",
|
|
33
|
-
nullable: true
|
|
34
|
-
},
|
|
35
|
-
analyzeStepResult: {
|
|
36
|
-
type: "jsonb",
|
|
37
|
-
nullable: true
|
|
38
|
-
},
|
|
39
|
-
score: {
|
|
40
|
-
type: "float"
|
|
41
|
-
},
|
|
42
|
-
reason: {
|
|
43
|
-
type: "text",
|
|
44
|
-
nullable: true
|
|
45
|
-
},
|
|
46
|
-
metadata: {
|
|
47
|
-
type: "jsonb",
|
|
48
|
-
nullable: true
|
|
49
|
-
},
|
|
50
|
-
preprocessPrompt: {
|
|
51
|
-
type: "text",
|
|
52
|
-
nullable: true
|
|
53
|
-
},
|
|
54
|
-
extractPrompt: {
|
|
55
|
-
type: "text",
|
|
56
|
-
nullable: true
|
|
57
|
-
},
|
|
58
|
-
generateScorePrompt: {
|
|
59
|
-
type: "text",
|
|
60
|
-
nullable: true
|
|
61
|
-
},
|
|
62
|
-
generateReasonPrompt: {
|
|
63
|
-
type: "text",
|
|
64
|
-
nullable: true
|
|
65
|
-
},
|
|
66
|
-
analyzePrompt: {
|
|
67
|
-
type: "text",
|
|
68
|
-
nullable: true
|
|
69
|
-
},
|
|
14
|
+
scorerId: { type: "text" },
|
|
15
|
+
traceId: { type: "text", nullable: true },
|
|
16
|
+
spanId: { type: "text", nullable: true },
|
|
17
|
+
runId: { type: "text" },
|
|
18
|
+
scorer: { type: "jsonb" },
|
|
19
|
+
preprocessStepResult: { type: "jsonb", nullable: true },
|
|
20
|
+
extractStepResult: { type: "jsonb", nullable: true },
|
|
21
|
+
analyzeStepResult: { type: "jsonb", nullable: true },
|
|
22
|
+
score: { type: "float" },
|
|
23
|
+
reason: { type: "text", nullable: true },
|
|
24
|
+
metadata: { type: "jsonb", nullable: true },
|
|
25
|
+
preprocessPrompt: { type: "text", nullable: true },
|
|
26
|
+
extractPrompt: { type: "text", nullable: true },
|
|
27
|
+
generateScorePrompt: { type: "text", nullable: true },
|
|
28
|
+
generateReasonPrompt: { type: "text", nullable: true },
|
|
29
|
+
analyzePrompt: { type: "text", nullable: true },
|
|
70
30
|
// Deprecated
|
|
71
|
-
reasonPrompt: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
output: {
|
|
80
|
-
type: "jsonb"
|
|
81
|
-
// MESSAGE OUTPUT
|
|
82
|
-
},
|
|
83
|
-
additionalContext: {
|
|
84
|
-
type: "jsonb",
|
|
85
|
-
// DATA FROM THE CONTEXT PARAM ON AN AGENT
|
|
86
|
-
nullable: true
|
|
87
|
-
},
|
|
88
|
-
runtimeContext: {
|
|
89
|
-
type: "jsonb",
|
|
90
|
-
// THE EVALUATE RUNTIME CONTEXT FOR THE RUN
|
|
91
|
-
nullable: true
|
|
92
|
-
},
|
|
31
|
+
reasonPrompt: { type: "text", nullable: true },
|
|
32
|
+
input: { type: "jsonb" },
|
|
33
|
+
output: { type: "jsonb" },
|
|
34
|
+
// MESSAGE OUTPUT
|
|
35
|
+
additionalContext: { type: "jsonb", nullable: true },
|
|
36
|
+
// DATA FROM THE CONTEXT PARAM ON AN AGENT
|
|
37
|
+
runtimeContext: { type: "jsonb", nullable: true },
|
|
38
|
+
// THE EVALUATE RUNTIME CONTEXT FOR THE RUN
|
|
93
39
|
/**
|
|
94
40
|
* Things you can evaluate
|
|
95
41
|
*/
|
|
96
|
-
entityType: {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
entityId: {
|
|
107
|
-
type: "text",
|
|
108
|
-
nullable: true
|
|
109
|
-
},
|
|
110
|
-
source: {
|
|
111
|
-
type: "text"
|
|
112
|
-
},
|
|
113
|
-
resourceId: {
|
|
114
|
-
type: "text",
|
|
115
|
-
nullable: true
|
|
116
|
-
},
|
|
117
|
-
threadId: {
|
|
118
|
-
type: "text",
|
|
119
|
-
nullable: true
|
|
120
|
-
},
|
|
121
|
-
createdAt: {
|
|
122
|
-
type: "timestamp"
|
|
123
|
-
},
|
|
124
|
-
updatedAt: {
|
|
125
|
-
type: "timestamp"
|
|
126
|
-
}
|
|
42
|
+
entityType: { type: "text", nullable: true },
|
|
43
|
+
// WORKFLOW, AGENT, TOOL, STEP, NETWORK
|
|
44
|
+
entity: { type: "jsonb", nullable: true },
|
|
45
|
+
// MINIMAL JSON DATA ABOUT WORKFLOW, AGENT, TOOL, STEP, NETWORK
|
|
46
|
+
entityId: { type: "text", nullable: true },
|
|
47
|
+
source: { type: "text" },
|
|
48
|
+
resourceId: { type: "text", nullable: true },
|
|
49
|
+
threadId: { type: "text", nullable: true },
|
|
50
|
+
createdAt: { type: "timestamp" },
|
|
51
|
+
updatedAt: { type: "timestamp" }
|
|
127
52
|
};
|
|
128
53
|
var AI_SPAN_SCHEMA = {
|
|
129
54
|
// Composite primary key of traceId and spanId
|
|
@@ -133,7 +58,7 @@ var AI_SPAN_SCHEMA = {
|
|
|
133
58
|
name: { type: "text", nullable: false },
|
|
134
59
|
scope: { type: "jsonb", nullable: true },
|
|
135
60
|
// Mastra package info {"core-version": "0.1.0"}
|
|
136
|
-
spanType: { type: "
|
|
61
|
+
spanType: { type: "text", nullable: false },
|
|
137
62
|
// WORKFLOW_RUN, WORKFLOW_STEP, AGENT_RUN, AGENT_STEP, TOOL_RUN, TOOL_STEP, etc.
|
|
138
63
|
attributes: { type: "jsonb", nullable: true },
|
|
139
64
|
metadata: { type: "jsonb", nullable: true },
|
|
@@ -262,5 +187,5 @@ exports.TABLE_SCORERS = TABLE_SCORERS;
|
|
|
262
187
|
exports.TABLE_THREADS = TABLE_THREADS;
|
|
263
188
|
exports.TABLE_TRACES = TABLE_TRACES;
|
|
264
189
|
exports.TABLE_WORKFLOW_SNAPSHOT = TABLE_WORKFLOW_SNAPSHOT;
|
|
265
|
-
//# sourceMappingURL=chunk-
|
|
266
|
-
//# sourceMappingURL=chunk-
|
|
190
|
+
//# sourceMappingURL=chunk-4R2TBRS7.cjs.map
|
|
191
|
+
//# sourceMappingURL=chunk-4R2TBRS7.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/storage/constants.ts"],"names":[],"mappings":";;;AAEO,IAAM,uBAAA,GAA0B;AAChC,IAAM,WAAA,GAAc;AACpB,IAAM,cAAA,GAAiB;AACvB,IAAM,aAAA,GAAgB;AACtB,IAAM,YAAA,GAAe;AACrB,IAAM,eAAA,GAAkB;AACxB,IAAM,aAAA,GAAgB;AACtB,IAAM,cAAA,GAAiB;AAYvB,IAAM,cAAA,GAAgD;AAAA,EAC3D,IAAI,EAAE,IAAA,EAAM,QAAQ,QAAA,EAAU,KAAA,EAAO,YAAY,IAAA,EAAK;AAAA,EACtD,QAAA,EAAU,EAAE,IAAA,EAAM,MAAA,EAAO;AAAA,EACzB,OAAA,EAAS,EAAE,IAAA,EAAM,MAAA,EAAQ,UAAU,IAAA,EAAK;AAAA,EACxC,MAAA,EAAQ,EAAE,IAAA,EAAM,MAAA,EAAQ,UAAU,IAAA,EAAK;AAAA,EACvC,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAO;AAAA,EACtB,MAAA,EAAQ,EAAE,IAAA,EAAM,OAAA,EAAQ;AAAA,EACxB,oBAAA,EAAsB,EAAE,IAA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EAAU,UAAU,KAAA,EAAM;AAAA,IAC7C,OAAA,EAAS,EAAE,IAAA,EAAM,QAAA,EAAU,UAAU,KAAA,EAAM;AAAA,IAC3C,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,UAAU,KAAA;AAAM,GAClD;AAAA,EACA,CAAC,eAAe,GAAG;AAAA,IACjB,IAAI,EAAE,IAAA,EAAM,QAAQ,QAAA,EAAU,KAAA,EAAO,YAAY,IAAA,EAAK;AAAA,IACtD,aAAA,EAAe,EAAE,IAAA,EAAM,MAAA,EAAQ,UAAU,IAAA,EAAK;AAAA,IAC9C,QAAA,EAAU,EAAE,IAAA,EAAM,OAAA,EAAS,UAAU,IAAA,EAAK;AAAA,IAC1C,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,UAAU,KAAA,EAAM;AAAA,IAChD,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,UAAU,KAAA;AAAM;AAEpD","file":"chunk-4R2TBRS7.cjs","sourcesContent":["import type { StorageColumn } from './types';\n\nexport const TABLE_WORKFLOW_SNAPSHOT = 'mastra_workflow_snapshot';\nexport const TABLE_EVALS = 'mastra_evals';\nexport const TABLE_MESSAGES = 'mastra_messages';\nexport const TABLE_THREADS = 'mastra_threads';\nexport const TABLE_TRACES = 'mastra_traces';\nexport const TABLE_RESOURCES = 'mastra_resources';\nexport const TABLE_SCORERS = 'mastra_scorers';\nexport const TABLE_AI_SPANS = 'mastra_ai_spans';\n\nexport type TABLE_NAMES =\n | typeof TABLE_WORKFLOW_SNAPSHOT\n | typeof TABLE_EVALS\n | typeof TABLE_MESSAGES\n | typeof TABLE_THREADS\n | typeof TABLE_TRACES\n | typeof TABLE_RESOURCES\n | typeof TABLE_SCORERS\n | typeof TABLE_AI_SPANS;\n\nexport const SCORERS_SCHEMA: Record<string, StorageColumn> = {\n id: { type: 'text', nullable: false, primaryKey: true },\n scorerId: { type: 'text' },\n traceId: { type: 'text', nullable: true },\n spanId: { type: 'text', nullable: true },\n runId: { type: 'text' },\n scorer: { type: 'jsonb' },\n preprocessStepResult: { type: 'jsonb', nullable: true },\n extractStepResult: { type: 'jsonb', nullable: true },\n analyzeStepResult: { type: 'jsonb', nullable: true },\n score: { type: 'float' },\n reason: { type: 'text', nullable: true },\n metadata: { type: 'jsonb', nullable: true },\n preprocessPrompt: { type: 'text', nullable: true },\n extractPrompt: { type: 'text', nullable: true },\n generateScorePrompt: { type: 'text', nullable: true },\n generateReasonPrompt: { type: 'text', nullable: true },\n analyzePrompt: { type: 'text', nullable: true },\n\n // Deprecated\n reasonPrompt: { type: 'text', nullable: true },\n input: { type: 'jsonb' },\n output: { type: 'jsonb' }, // MESSAGE OUTPUT\n additionalContext: { type: 'jsonb', nullable: true }, // DATA FROM THE CONTEXT PARAM ON AN AGENT\n runtimeContext: { type: 'jsonb', nullable: true }, // THE EVALUATE RUNTIME CONTEXT FOR THE RUN\n /**\n * Things you can evaluate\n */\n entityType: { type: 'text', nullable: true }, // WORKFLOW, AGENT, TOOL, STEP, NETWORK\n entity: { type: 'jsonb', nullable: true }, // MINIMAL JSON DATA ABOUT WORKFLOW, AGENT, TOOL, STEP, NETWORK\n entityId: { type: 'text', nullable: true },\n source: { type: 'text' },\n resourceId: { type: 'text', nullable: true },\n threadId: { type: 'text', nullable: true },\n createdAt: { type: 'timestamp' },\n updatedAt: { type: 'timestamp' },\n};\n\nexport const AI_SPAN_SCHEMA: Record<string, StorageColumn> = {\n // Composite primary key of traceId and spanId\n traceId: { type: 'text', nullable: false },\n spanId: { type: 'text', nullable: false },\n parentSpanId: { type: 'text', nullable: true },\n name: { type: 'text', nullable: false },\n scope: { type: 'jsonb', nullable: true }, // Mastra package info {\"core-version\": \"0.1.0\"}\n spanType: { type: 'text', nullable: false }, // WORKFLOW_RUN, WORKFLOW_STEP, AGENT_RUN, AGENT_STEP, TOOL_RUN, TOOL_STEP, etc.\n attributes: { type: 'jsonb', nullable: true },\n metadata: { type: 'jsonb', nullable: true },\n links: { type: 'jsonb', nullable: true },\n input: { type: 'jsonb', nullable: true },\n output: { type: 'jsonb', nullable: true },\n error: { type: 'jsonb', nullable: true },\n startedAt: { type: 'timestamp', nullable: false }, // When the span started\n endedAt: { type: 'timestamp', nullable: true }, // When the span ended\n createdAt: { type: 'timestamp', nullable: false }, // The time the database record was created\n updatedAt: { type: 'timestamp', nullable: true }, // The time the database record was last updated\n isEvent: { type: 'boolean', nullable: false },\n};\n\nexport const TABLE_SCHEMAS: Record<TABLE_NAMES, Record<string, StorageColumn>> = {\n [TABLE_WORKFLOW_SNAPSHOT]: {\n workflow_name: {\n type: 'text',\n },\n run_id: {\n type: 'text',\n },\n resourceId: { type: 'text', nullable: true },\n snapshot: {\n type: 'text',\n },\n createdAt: {\n type: 'timestamp',\n },\n updatedAt: {\n type: 'timestamp',\n },\n },\n [TABLE_SCORERS]: SCORERS_SCHEMA,\n [TABLE_EVALS]: {\n input: {\n type: 'text',\n },\n output: {\n type: 'text',\n },\n result: {\n type: 'jsonb',\n },\n agent_name: {\n type: 'text',\n },\n metric_name: {\n type: 'text',\n },\n instructions: {\n type: 'text',\n },\n test_info: {\n type: 'jsonb',\n nullable: true,\n },\n global_run_id: {\n type: 'text',\n },\n run_id: {\n type: 'text',\n },\n created_at: {\n type: 'timestamp',\n },\n createdAt: {\n type: 'timestamp',\n nullable: true,\n },\n },\n [TABLE_THREADS]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n resourceId: { type: 'text', nullable: false },\n title: { type: 'text', nullable: false },\n metadata: { type: 'text', nullable: true },\n createdAt: { type: 'timestamp', nullable: false },\n updatedAt: { type: 'timestamp', nullable: false },\n },\n [TABLE_MESSAGES]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n thread_id: { type: 'text', nullable: false },\n content: { type: 'text', nullable: false },\n role: { type: 'text', nullable: false },\n type: { type: 'text', nullable: false },\n createdAt: { type: 'timestamp', nullable: false },\n resourceId: { type: 'text', nullable: true },\n },\n [TABLE_AI_SPANS]: AI_SPAN_SCHEMA,\n [TABLE_TRACES]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n parentSpanId: { type: 'text', nullable: true },\n name: { type: 'text', nullable: false },\n traceId: { type: 'text', nullable: false },\n scope: { type: 'text', nullable: false },\n kind: { type: 'integer', nullable: false },\n attributes: { type: 'jsonb', nullable: true },\n status: { type: 'jsonb', nullable: true },\n events: { type: 'jsonb', nullable: true },\n links: { type: 'jsonb', nullable: true },\n other: { type: 'text', nullable: true },\n startTime: { type: 'bigint', nullable: false },\n endTime: { type: 'bigint', nullable: false },\n createdAt: { type: 'timestamp', nullable: false },\n },\n [TABLE_RESOURCES]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n workingMemory: { type: 'text', nullable: true },\n metadata: { type: 'jsonb', nullable: true },\n createdAt: { type: 'timestamp', nullable: false },\n updatedAt: { type: 'timestamp', nullable: false },\n },\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkV3VLOOSW_cjs = require('./chunk-V3VLOOSW.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkCQ73JM2N_cjs = require('./chunk-CQ73JM2N.cjs');
|
|
5
|
+
var chunkDRVSEV5Y_cjs = require('./chunk-DRVSEV5Y.cjs');
|
|
6
6
|
var chunk4L3P3PCP_cjs = require('./chunk-4L3P3PCP.cjs');
|
|
7
7
|
|
|
8
8
|
// src/memory/memory.ts
|
|
@@ -149,7 +149,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
149
149
|
if (config?.workingMemory && "use" in config.workingMemory) {
|
|
150
150
|
throw new Error("The workingMemory.use option has been removed. Working memory always uses tool-call mode.");
|
|
151
151
|
}
|
|
152
|
-
const mergedConfig =
|
|
152
|
+
const mergedConfig = chunkDRVSEV5Y_cjs.deepMerge(this.threadConfig, config || {});
|
|
153
153
|
if (config?.workingMemory?.schema) {
|
|
154
154
|
if (mergedConfig.workingMemory) {
|
|
155
155
|
mergedConfig.workingMemory.schema = config.workingMemory.schema;
|
|
@@ -247,7 +247,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
247
247
|
toolCallIds
|
|
248
248
|
};
|
|
249
249
|
const savedMessages = await this.saveMessages({ messages: [message], memoryConfig: config });
|
|
250
|
-
const list = new
|
|
250
|
+
const list = new chunkCQ73JM2N_cjs.MessageList({ threadId, resourceId }).add(savedMessages[0], "memory");
|
|
251
251
|
return list.get.all.v1()[0];
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
@@ -262,5 +262,5 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
262
262
|
exports.MastraMemory = MastraMemory;
|
|
263
263
|
exports.MemoryProcessor = MemoryProcessor;
|
|
264
264
|
exports.memoryDefaultOptions = memoryDefaultOptions;
|
|
265
|
-
//# sourceMappingURL=chunk-
|
|
266
|
-
//# sourceMappingURL=chunk-
|
|
265
|
+
//# sourceMappingURL=chunk-4VNAMG7K.cjs.map
|
|
266
|
+
//# sourceMappingURL=chunk-4VNAMG7K.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/memory/memory.ts"],"names":["MastraBase","augmentWithInit","deepMerge","MessageList"],"mappings":";;;;;;;;AA6BO,IAAe,eAAA,GAAf,cAAuCA,4BAAA,CAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvD,OAAA,CAAQ,UAAyB,KAAA,EAAoE;AACnG,IAAA,OAAO,QAAA;AAAA,EACT;AACF;AAEO,IAAM,oBAAA,GAAuB;AAAA,EAClC,YAAA,EAAc,EAAA;AAAA,EACd,cAAA,EAAgB,KAAA;AAAA,EAChB,OAAA,EAAS;AAAA,IACP,aAAA,EAAe;AAAA,GACjB;AAAA,EACA,aAAA,EAAe;AAAA,IACb,OAAA,EAAS,KAAA;AAAA,IACT,QAAA,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAad;AAMO,IAAe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,6BAAA,CAAY,EAAE,QAAA,EAAU,UAAA,EAAY,CAAA,CAAE,GAAA,CAAI,aAAA,CAAc,CAAC,CAAA,EAAI,QAAQ,CAAA;AACtF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,GAAA,CAAI,EAAA,GAAK,CAAC,CAAA;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,UAAA,GAAqB;AAC1B,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,UAAA,EAAW,IAAK,OAAO,UAAA,EAAW;AAAA,EACzD;AAiEF","file":"chunk-AEYCHF2U.cjs","sourcesContent":["import type { EmbeddingModelV2 } from '@ai-sdk/provider-v5';\nimport type { AssistantContent, UserContent, CoreMessage, EmbeddingModel } from 'ai';\nimport { MessageList } from '../agent/message-list';\nimport type { MastraMessageV2, UIMessageWithMetadata } from '../agent/message-list';\nimport { MastraBase } from '../base';\nimport type { Mastra } from '../mastra';\nimport type { MastraStorage, PaginationInfo, StorageGetMessagesArg, ThreadSortOptions } from '../storage';\nimport { augmentWithInit } from '../storage/storageWithInit';\nimport type { ToolAction } from '../tools';\nimport { deepMerge } from '../utils';\nimport type { MastraVector } from '../vector';\n\nimport type {\n SharedMemoryConfig,\n StorageThreadType,\n MemoryConfig,\n MastraMessageV1,\n WorkingMemoryTemplate,\n} from './types';\n\nexport type MemoryProcessorOpts = {\n systemMessage?: string;\n memorySystemMessage?: string;\n newMessages?: CoreMessage[];\n};\n/**\n * Interface for message processors that can filter or transform messages\n * before they're sent to the LLM.\n */\nexport abstract class MemoryProcessor extends MastraBase {\n /**\n * Process a list of messages and return a filtered or transformed list.\n * @param messages The messages to process\n * @returns The processed messages\n */\n process(messages: CoreMessage[], _opts: MemoryProcessorOpts): CoreMessage[] | Promise<CoreMessage[]> {\n return messages;\n }\n}\n\nexport const memoryDefaultOptions = {\n lastMessages: 10,\n semanticRecall: false,\n threads: {\n generateTitle: false,\n },\n workingMemory: {\n enabled: false,\n template: `\n# User Information\n- **First Name**: \n- **Last Name**: \n- **Location**: \n- **Occupation**: \n- **Interests**: \n- **Goals**: \n- **Events**: \n- **Facts**: \n- **Projects**: \n`,\n },\n} satisfies MemoryConfig;\n\n/**\n * Abstract Memory class that defines the interface for storing and retrieving\n * conversation threads and messages.\n */\nexport abstract class MastraMemory extends MastraBase {\n MAX_CONTEXT_TOKENS?: number;\n\n protected _storage?: MastraStorage;\n vector?: MastraVector;\n embedder?: EmbeddingModel<string> | EmbeddingModelV2<string>;\n private processors: MemoryProcessor[] = [];\n protected threadConfig: MemoryConfig = { ...memoryDefaultOptions };\n #mastra?: Mastra;\n\n constructor(config: { name: string } & SharedMemoryConfig) {\n super({ component: 'MEMORY', name: config.name });\n\n if (config.options) this.threadConfig = this.getMergedThreadConfig(config.options);\n if (config.processors) this.processors = config.processors;\n if (config.storage) {\n this._storage = augmentWithInit(config.storage);\n this._hasOwnStorage = true;\n }\n\n if (this.threadConfig.semanticRecall) {\n if (!config.vector) {\n throw new Error(\n `Semantic recall requires a vector store to be configured.\\n\\nhttps://mastra.ai/en/docs/memory/semantic-recall`,\n );\n }\n this.vector = config.vector;\n\n if (!config.embedder) {\n throw new Error(\n `Semantic recall requires an embedder to be configured.\\n\\nhttps://mastra.ai/en/docs/memory/semantic-recall`,\n );\n }\n this.embedder = config.embedder;\n }\n }\n\n /**\n * Internal method used by Mastra to register itself with the memory.\n * @param mastra The Mastra instance.\n * @internal\n */\n __registerMastra(mastra: Mastra): void {\n this.#mastra = mastra;\n }\n\n protected _hasOwnStorage = false;\n get hasOwnStorage() {\n return this._hasOwnStorage;\n }\n\n get storage() {\n if (!this._storage) {\n throw new Error(\n `Memory requires a storage provider to function. Add a storage configuration to Memory or to your Mastra instance.\\n\\nhttps://mastra.ai/en/docs/memory/overview`,\n );\n }\n return this._storage;\n }\n\n public setStorage(storage: MastraStorage) {\n this._storage = augmentWithInit(storage);\n }\n\n public setVector(vector: MastraVector) {\n this.vector = vector;\n }\n\n public setEmbedder(embedder: EmbeddingModel<string>) {\n this.embedder = embedder;\n }\n\n /**\n * Get a system message to inject into the conversation.\n * This will be called before each conversation turn.\n * Implementations can override this to inject custom system messages.\n */\n public async getSystemMessage(_input: {\n threadId: string;\n resourceId?: string;\n memoryConfig?: MemoryConfig;\n }): Promise<string | null> {\n return null;\n }\n\n /**\n * Get tools that should be available to the agent.\n * This will be called when converting tools for the agent.\n * Implementations can override this to provide additional tools.\n */\n public getTools(_config?: MemoryConfig): Record<string, ToolAction<any, any, any>> {\n return {};\n }\n\n protected async createEmbeddingIndex(dimensions?: number, config?: MemoryConfig): Promise<{ indexName: string }> {\n const defaultDimensions = 1536;\n const isDefault = dimensions === defaultDimensions;\n const usedDimensions = dimensions ?? defaultDimensions;\n const separator = this.vector?.indexSeparator ?? '_';\n const indexName = isDefault\n ? `memory${separator}messages`\n : `memory${separator}messages${separator}${usedDimensions}`;\n\n if (typeof this.vector === `undefined`) {\n throw new Error(`Tried to create embedding index but no vector db is attached to this Memory instance.`);\n }\n\n // Get index configuration from memory config\n const semanticConfig = typeof config?.semanticRecall === 'object' ? config.semanticRecall : undefined;\n const indexConfig = semanticConfig?.indexConfig;\n\n // Base parameters that all vector stores support\n const createParams: any = {\n indexName,\n dimension: usedDimensions,\n ...(indexConfig?.metric && { metric: indexConfig.metric }),\n };\n\n // Add PG-specific configuration if provided\n // Only PG vector store will use these parameters\n if (indexConfig && (indexConfig.type || indexConfig.ivf || indexConfig.hnsw)) {\n createParams.indexConfig = {};\n if (indexConfig.type) createParams.indexConfig.type = indexConfig.type;\n if (indexConfig.ivf) createParams.indexConfig.ivf = indexConfig.ivf;\n if (indexConfig.hnsw) createParams.indexConfig.hnsw = indexConfig.hnsw;\n }\n\n await this.vector.createIndex(createParams);\n return { indexName };\n }\n\n public getMergedThreadConfig(config?: MemoryConfig): MemoryConfig {\n if (config?.workingMemory && 'use' in config.workingMemory) {\n throw new Error('The workingMemory.use option has been removed. Working memory always uses tool-call mode.');\n }\n const mergedConfig = deepMerge(this.threadConfig, config || {});\n\n if (config?.workingMemory?.schema) {\n if (mergedConfig.workingMemory) {\n mergedConfig.workingMemory.schema = config.workingMemory.schema;\n }\n }\n\n return mergedConfig;\n }\n\n /**\n * Apply all configured message processors to a list of messages.\n * @param messages The messages to process\n * @returns The processed messages\n */\n protected async applyProcessors(\n messages: CoreMessage[],\n opts: {\n processors?: MemoryProcessor[];\n } & MemoryProcessorOpts,\n ): Promise<CoreMessage[]> {\n const processors = opts.processors || this.processors;\n if (!processors || processors.length === 0) {\n return messages;\n }\n\n let processedMessages = [...messages];\n\n for (const processor of processors) {\n processedMessages = await processor.process(processedMessages, {\n systemMessage: opts.systemMessage,\n newMessages: opts.newMessages,\n memorySystemMessage: opts.memorySystemMessage,\n });\n }\n\n return processedMessages;\n }\n\n processMessages({\n messages,\n processors,\n ...opts\n }: {\n messages: CoreMessage[];\n processors?: MemoryProcessor[];\n } & MemoryProcessorOpts) {\n return this.applyProcessors(messages, { processors: processors || this.processors, ...opts });\n }\n\n abstract rememberMessages({\n threadId,\n resourceId,\n vectorMessageSearch,\n config,\n }: {\n threadId: string;\n resourceId?: string;\n vectorMessageSearch?: string;\n config?: MemoryConfig;\n }): Promise<{ messages: MastraMessageV1[]; messagesV2: MastraMessageV2[] }>;\n\n estimateTokens(text: string): number {\n return Math.ceil(text.split(' ').length * 1.3);\n }\n\n /**\n * Retrieves a specific thread by its ID\n * @param threadId - The unique identifier of the thread\n * @returns Promise resolving to the thread or null if not found\n */\n abstract getThreadById({ threadId }: { threadId: string }): Promise<StorageThreadType | null>;\n\n /**\n * Retrieves all threads that belong to the specified resource.\n * @param resourceId - The unique identifier of the resource\n * @param orderBy - Which timestamp field to sort by (`'createdAt'` or `'updatedAt'`);\n * defaults to `'createdAt'`\n * @param sortDirection - Sort order for the results (`'ASC'` or `'DESC'`);\n * defaults to `'DESC'`\n * @returns Promise resolving to an array of matching threads; resolves to an empty array\n * if the resource has no threads\n */\n abstract getThreadsByResourceId({\n resourceId,\n orderBy,\n sortDirection,\n }: { resourceId: string } & ThreadSortOptions): Promise<StorageThreadType[]>;\n\n abstract getThreadsByResourceIdPaginated(\n args: {\n resourceId: string;\n page: number;\n perPage: number;\n } & ThreadSortOptions,\n ): Promise<PaginationInfo & { threads: StorageThreadType[] }>;\n\n /**\n * Saves or updates a thread\n * @param thread - The thread data to save\n * @returns Promise resolving to the saved thread\n */\n abstract saveThread({\n thread,\n memoryConfig,\n }: {\n thread: StorageThreadType;\n memoryConfig?: MemoryConfig;\n }): Promise<StorageThreadType>;\n\n /**\n * Saves messages to a thread\n * @param messages - Array of messages to save\n * @returns Promise resolving to the saved messages\n */\n abstract saveMessages(args: {\n messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];\n memoryConfig?: MemoryConfig | undefined;\n format?: 'v1';\n }): Promise<MastraMessageV1[]>;\n abstract saveMessages(args: {\n messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];\n memoryConfig?: MemoryConfig | undefined;\n format: 'v2';\n }): Promise<MastraMessageV2[]>;\n abstract saveMessages(args: {\n messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];\n memoryConfig?: MemoryConfig | undefined;\n format?: 'v1' | 'v2';\n }): Promise<MastraMessageV2[] | MastraMessageV1[]>;\n\n /**\n * Retrieves all messages for a specific thread\n * @param threadId - The unique identifier of the thread\n * @returns Promise resolving to array of messages and uiMessages\n */\n abstract query({\n threadId,\n resourceId,\n selectBy,\n }: StorageGetMessagesArg): Promise<{ messages: CoreMessage[]; uiMessages: UIMessageWithMetadata[] }>;\n\n /**\n * Helper method to create a new thread\n * @param title - Optional title for the thread\n * @param metadata - Optional metadata for the thread\n * @returns Promise resolving to the created thread\n */\n async createThread({\n threadId,\n resourceId,\n title,\n metadata,\n memoryConfig,\n saveThread = true,\n }: {\n resourceId: string;\n threadId?: string;\n title?: string;\n metadata?: Record<string, unknown>;\n memoryConfig?: MemoryConfig;\n saveThread?: boolean;\n }): Promise<StorageThreadType> {\n const thread: StorageThreadType = {\n id: threadId || this.generateId(),\n title: title || `New Thread ${new Date().toISOString()}`,\n resourceId,\n createdAt: new Date(),\n updatedAt: new Date(),\n metadata,\n };\n\n return saveThread ? this.saveThread({ thread, memoryConfig }) : thread;\n }\n\n /**\n * Helper method to delete a thread\n * @param threadId - the id of the thread to delete\n */\n abstract deleteThread(threadId: string): Promise<void>;\n\n /**\n * Helper method to add a single message to a thread\n * @param threadId - The thread to add the message to\n * @param content - The message content\n * @param role - The role of the message sender\n * @param type - The type of the message\n * @param toolNames - Optional array of tool names that were called\n * @param toolCallArgs - Optional array of tool call arguments\n * @param toolCallIds - Optional array of tool call ids\n * @returns Promise resolving to the saved message\n * @deprecated use saveMessages instead\n */\n async addMessage({\n threadId,\n resourceId,\n config,\n content,\n role,\n type,\n toolNames,\n toolCallArgs,\n toolCallIds,\n }: {\n threadId: string;\n resourceId: string;\n config?: MemoryConfig;\n content: UserContent | AssistantContent;\n role: 'user' | 'assistant';\n type: 'text' | 'tool-call' | 'tool-result';\n toolNames?: string[];\n toolCallArgs?: Record<string, unknown>[];\n toolCallIds?: string[];\n }): Promise<MastraMessageV1> {\n const message: MastraMessageV1 = {\n id: this.generateId(),\n content,\n role,\n createdAt: new Date(),\n threadId,\n resourceId,\n type,\n toolNames,\n toolCallArgs,\n toolCallIds,\n };\n\n const savedMessages = await this.saveMessages({ messages: [message], memoryConfig: config });\n const list = new MessageList({ threadId, resourceId }).add(savedMessages[0]!, 'memory');\n return list.get.all.v1()[0]!;\n }\n\n /**\n * Generates a unique identifier\n * @returns A unique string ID\n */\n public generateId(): string {\n return this.#mastra?.generateId() || crypto.randomUUID();\n }\n\n /**\n * Retrieves working memory for a specific thread\n * @param threadId - The unique identifier of the thread\n * @param resourceId - The unique identifier of the resource\n * @param memoryConfig - Optional memory configuration\n * @returns Promise resolving to working memory data or null if not found\n */\n abstract getWorkingMemory({\n threadId,\n resourceId,\n memoryConfig,\n }: {\n threadId: string;\n resourceId?: string;\n memoryConfig?: MemoryConfig;\n }): Promise<string | null>;\n\n /**\n * Retrieves working memory template for a specific thread\n * @param memoryConfig - Optional memory configuration\n * @returns Promise resolving to working memory template or null if not found\n */\n abstract getWorkingMemoryTemplate({\n memoryConfig,\n }?: {\n memoryConfig?: MemoryConfig;\n }): Promise<WorkingMemoryTemplate | null>;\n\n abstract updateWorkingMemory({\n threadId,\n resourceId,\n workingMemory,\n memoryConfig,\n }: {\n threadId: string;\n resourceId?: string;\n workingMemory: string;\n memoryConfig?: MemoryConfig;\n }): Promise<void>;\n\n /**\n * @warning experimental! can be removed or changed at any time\n */\n abstract __experimental_updateWorkingMemoryVNext({\n threadId,\n resourceId,\n workingMemory,\n searchString,\n memoryConfig,\n }: {\n threadId: string;\n resourceId?: string;\n workingMemory: string;\n searchString?: string;\n memoryConfig?: MemoryConfig;\n }): Promise<{ success: boolean; reason: string }>;\n\n /**\n * Deletes multiple messages by their IDs\n * @param messageIds - Array of message IDs to delete\n * @returns Promise that resolves when all messages are deleted\n */\n abstract deleteMessages(messageIds: string[]): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/memory/memory.ts"],"names":["MastraBase","augmentWithInit","deepMerge","MessageList"],"mappings":";;;;;;;;AA6BO,IAAe,eAAA,GAAf,cAAuCA,4BAAA,CAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvD,OAAA,CAAQ,UAAyB,KAAA,EAAoE;AACnG,IAAA,OAAO,QAAA;AAAA,EACT;AACF;AAEO,IAAM,oBAAA,GAAuB;AAAA,EAClC,YAAA,EAAc,EAAA;AAAA,EACd,cAAA,EAAgB,KAAA;AAAA,EAChB,OAAA,EAAS;AAAA,IACP,aAAA,EAAe;AAAA,GACjB;AAAA,EACA,aAAA,EAAe;AAAA,IACb,OAAA,EAAS,KAAA;AAAA,IACT,QAAA,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AA,MAAM,IAAA,GAAO,IAAIC,6BAAA,CAAY,EAAE,QAAA,EAAU,UAAA,EAAY,CAAA,CAAE,GAAA,CAAI,aAAA,CAAc,CAAC,CAAA,EAAI,QAAQ,CAAA;AACtF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,GAAA,CAAI,EAAA,GAAK,CAAC,CAAA;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,UAAA,GAAqB;AAC1B,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,UAAA,EAAW,IAAK,OAAO,UAAA,EAAW;AAAA,EACzD;AAiEF","file":"chunk-4VNAMG7K.cjs","sourcesContent":["import type { EmbeddingModelV2 } from '@ai-sdk/provider-v5';\nimport type { AssistantContent, UserContent, CoreMessage, EmbeddingModel } from 'ai';\nimport { MessageList } from '../agent/message-list';\nimport type { MastraMessageV2, UIMessageWithMetadata } from '../agent/message-list';\nimport { MastraBase } from '../base';\nimport type { Mastra } from '../mastra';\nimport type { MastraStorage, PaginationInfo, StorageGetMessagesArg, ThreadSortOptions } from '../storage';\nimport { augmentWithInit } from '../storage/storageWithInit';\nimport type { ToolAction } from '../tools';\nimport { deepMerge } from '../utils';\nimport type { MastraVector } from '../vector';\n\nimport type {\n SharedMemoryConfig,\n StorageThreadType,\n MemoryConfig,\n MastraMessageV1,\n WorkingMemoryTemplate,\n} from './types';\n\nexport type MemoryProcessorOpts = {\n systemMessage?: string;\n memorySystemMessage?: string;\n newMessages?: CoreMessage[];\n};\n/**\n * Interface for message processors that can filter or transform messages\n * before they're sent to the LLM.\n */\nexport abstract class MemoryProcessor extends MastraBase {\n /**\n * Process a list of messages and return a filtered or transformed list.\n * @param messages The messages to process\n * @returns The processed messages\n */\n process(messages: CoreMessage[], _opts: MemoryProcessorOpts): CoreMessage[] | Promise<CoreMessage[]> {\n return messages;\n }\n}\n\nexport const memoryDefaultOptions = {\n lastMessages: 10,\n semanticRecall: false,\n threads: {\n generateTitle: false,\n },\n workingMemory: {\n enabled: false,\n template: `\n# User Information\n- **First Name**: \n- **Last Name**: \n- **Location**: \n- **Occupation**: \n- **Interests**: \n- **Goals**: \n- **Events**: \n- **Facts**: \n- **Projects**: \n`,\n },\n} satisfies MemoryConfig;\n\n/**\n * Abstract Memory class that defines the interface for storing and retrieving\n * conversation threads and messages.\n */\nexport abstract class MastraMemory extends MastraBase {\n MAX_CONTEXT_TOKENS?: number;\n\n protected _storage?: MastraStorage;\n vector?: MastraVector;\n embedder?: EmbeddingModel<string> | EmbeddingModelV2<string>;\n private processors: MemoryProcessor[] = [];\n protected threadConfig: MemoryConfig = { ...memoryDefaultOptions };\n #mastra?: Mastra;\n\n constructor(config: { name: string } & SharedMemoryConfig) {\n super({ component: 'MEMORY', name: config.name });\n\n if (config.options) this.threadConfig = this.getMergedThreadConfig(config.options);\n if (config.processors) this.processors = config.processors;\n if (config.storage) {\n this._storage = augmentWithInit(config.storage);\n this._hasOwnStorage = true;\n }\n\n if (this.threadConfig.semanticRecall) {\n if (!config.vector) {\n throw new Error(\n `Semantic recall requires a vector store to be configured.\\n\\nhttps://mastra.ai/en/docs/memory/semantic-recall`,\n );\n }\n this.vector = config.vector;\n\n if (!config.embedder) {\n throw new Error(\n `Semantic recall requires an embedder to be configured.\\n\\nhttps://mastra.ai/en/docs/memory/semantic-recall`,\n );\n }\n this.embedder = config.embedder;\n }\n }\n\n /**\n * Internal method used by Mastra to register itself with the memory.\n * @param mastra The Mastra instance.\n * @internal\n */\n __registerMastra(mastra: Mastra): void {\n this.#mastra = mastra;\n }\n\n protected _hasOwnStorage = false;\n get hasOwnStorage() {\n return this._hasOwnStorage;\n }\n\n get storage() {\n if (!this._storage) {\n throw new Error(\n `Memory requires a storage provider to function. Add a storage configuration to Memory or to your Mastra instance.\\n\\nhttps://mastra.ai/en/docs/memory/overview`,\n );\n }\n return this._storage;\n }\n\n public setStorage(storage: MastraStorage) {\n this._storage = augmentWithInit(storage);\n }\n\n public setVector(vector: MastraVector) {\n this.vector = vector;\n }\n\n public setEmbedder(embedder: EmbeddingModel<string>) {\n this.embedder = embedder;\n }\n\n /**\n * Get a system message to inject into the conversation.\n * This will be called before each conversation turn.\n * Implementations can override this to inject custom system messages.\n */\n public async getSystemMessage(_input: {\n threadId: string;\n resourceId?: string;\n memoryConfig?: MemoryConfig;\n }): Promise<string | null> {\n return null;\n }\n\n /**\n * Get tools that should be available to the agent.\n * This will be called when converting tools for the agent.\n * Implementations can override this to provide additional tools.\n */\n public getTools(_config?: MemoryConfig): Record<string, ToolAction<any, any, any>> {\n return {};\n }\n\n protected async createEmbeddingIndex(dimensions?: number, config?: MemoryConfig): Promise<{ indexName: string }> {\n const defaultDimensions = 1536;\n const isDefault = dimensions === defaultDimensions;\n const usedDimensions = dimensions ?? defaultDimensions;\n const separator = this.vector?.indexSeparator ?? '_';\n const indexName = isDefault\n ? `memory${separator}messages`\n : `memory${separator}messages${separator}${usedDimensions}`;\n\n if (typeof this.vector === `undefined`) {\n throw new Error(`Tried to create embedding index but no vector db is attached to this Memory instance.`);\n }\n\n // Get index configuration from memory config\n const semanticConfig = typeof config?.semanticRecall === 'object' ? config.semanticRecall : undefined;\n const indexConfig = semanticConfig?.indexConfig;\n\n // Base parameters that all vector stores support\n const createParams: any = {\n indexName,\n dimension: usedDimensions,\n ...(indexConfig?.metric && { metric: indexConfig.metric }),\n };\n\n // Add PG-specific configuration if provided\n // Only PG vector store will use these parameters\n if (indexConfig && (indexConfig.type || indexConfig.ivf || indexConfig.hnsw)) {\n createParams.indexConfig = {};\n if (indexConfig.type) createParams.indexConfig.type = indexConfig.type;\n if (indexConfig.ivf) createParams.indexConfig.ivf = indexConfig.ivf;\n if (indexConfig.hnsw) createParams.indexConfig.hnsw = indexConfig.hnsw;\n }\n\n await this.vector.createIndex(createParams);\n return { indexName };\n }\n\n public getMergedThreadConfig(config?: MemoryConfig): MemoryConfig {\n if (config?.workingMemory && 'use' in config.workingMemory) {\n throw new Error('The workingMemory.use option has been removed. Working memory always uses tool-call mode.');\n }\n const mergedConfig = deepMerge(this.threadConfig, config || {});\n\n if (config?.workingMemory?.schema) {\n if (mergedConfig.workingMemory) {\n mergedConfig.workingMemory.schema = config.workingMemory.schema;\n }\n }\n\n return mergedConfig;\n }\n\n /**\n * Apply all configured message processors to a list of messages.\n * @param messages The messages to process\n * @returns The processed messages\n */\n protected async applyProcessors(\n messages: CoreMessage[],\n opts: {\n processors?: MemoryProcessor[];\n } & MemoryProcessorOpts,\n ): Promise<CoreMessage[]> {\n const processors = opts.processors || this.processors;\n if (!processors || processors.length === 0) {\n return messages;\n }\n\n let processedMessages = [...messages];\n\n for (const processor of processors) {\n processedMessages = await processor.process(processedMessages, {\n systemMessage: opts.systemMessage,\n newMessages: opts.newMessages,\n memorySystemMessage: opts.memorySystemMessage,\n });\n }\n\n return processedMessages;\n }\n\n processMessages({\n messages,\n processors,\n ...opts\n }: {\n messages: CoreMessage[];\n processors?: MemoryProcessor[];\n } & MemoryProcessorOpts) {\n return this.applyProcessors(messages, { processors: processors || this.processors, ...opts });\n }\n\n abstract rememberMessages({\n threadId,\n resourceId,\n vectorMessageSearch,\n config,\n }: {\n threadId: string;\n resourceId?: string;\n vectorMessageSearch?: string;\n config?: MemoryConfig;\n }): Promise<{ messages: MastraMessageV1[]; messagesV2: MastraMessageV2[] }>;\n\n estimateTokens(text: string): number {\n return Math.ceil(text.split(' ').length * 1.3);\n }\n\n /**\n * Retrieves a specific thread by its ID\n * @param threadId - The unique identifier of the thread\n * @returns Promise resolving to the thread or null if not found\n */\n abstract getThreadById({ threadId }: { threadId: string }): Promise<StorageThreadType | null>;\n\n /**\n * Retrieves all threads that belong to the specified resource.\n * @param resourceId - The unique identifier of the resource\n * @param orderBy - Which timestamp field to sort by (`'createdAt'` or `'updatedAt'`);\n * defaults to `'createdAt'`\n * @param sortDirection - Sort order for the results (`'ASC'` or `'DESC'`);\n * defaults to `'DESC'`\n * @returns Promise resolving to an array of matching threads; resolves to an empty array\n * if the resource has no threads\n */\n abstract getThreadsByResourceId({\n resourceId,\n orderBy,\n sortDirection,\n }: { resourceId: string } & ThreadSortOptions): Promise<StorageThreadType[]>;\n\n abstract getThreadsByResourceIdPaginated(\n args: {\n resourceId: string;\n page: number;\n perPage: number;\n } & ThreadSortOptions,\n ): Promise<PaginationInfo & { threads: StorageThreadType[] }>;\n\n /**\n * Saves or updates a thread\n * @param thread - The thread data to save\n * @returns Promise resolving to the saved thread\n */\n abstract saveThread({\n thread,\n memoryConfig,\n }: {\n thread: StorageThreadType;\n memoryConfig?: MemoryConfig;\n }): Promise<StorageThreadType>;\n\n /**\n * Saves messages to a thread\n * @param messages - Array of messages to save\n * @returns Promise resolving to the saved messages\n */\n abstract saveMessages(args: {\n messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];\n memoryConfig?: MemoryConfig | undefined;\n format?: 'v1';\n }): Promise<MastraMessageV1[]>;\n abstract saveMessages(args: {\n messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];\n memoryConfig?: MemoryConfig | undefined;\n format: 'v2';\n }): Promise<MastraMessageV2[]>;\n abstract saveMessages(args: {\n messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];\n memoryConfig?: MemoryConfig | undefined;\n format?: 'v1' | 'v2';\n }): Promise<MastraMessageV2[] | MastraMessageV1[]>;\n\n /**\n * Retrieves all messages for a specific thread\n * @param threadId - The unique identifier of the thread\n * @returns Promise resolving to array of messages and uiMessages\n */\n abstract query({\n threadId,\n resourceId,\n selectBy,\n }: StorageGetMessagesArg): Promise<{ messages: CoreMessage[]; uiMessages: UIMessageWithMetadata[] }>;\n\n /**\n * Helper method to create a new thread\n * @param title - Optional title for the thread\n * @param metadata - Optional metadata for the thread\n * @returns Promise resolving to the created thread\n */\n async createThread({\n threadId,\n resourceId,\n title,\n metadata,\n memoryConfig,\n saveThread = true,\n }: {\n resourceId: string;\n threadId?: string;\n title?: string;\n metadata?: Record<string, unknown>;\n memoryConfig?: MemoryConfig;\n saveThread?: boolean;\n }): Promise<StorageThreadType> {\n const thread: StorageThreadType = {\n id: threadId || this.generateId(),\n title: title || `New Thread ${new Date().toISOString()}`,\n resourceId,\n createdAt: new Date(),\n updatedAt: new Date(),\n metadata,\n };\n\n return saveThread ? this.saveThread({ thread, memoryConfig }) : thread;\n }\n\n /**\n * Helper method to delete a thread\n * @param threadId - the id of the thread to delete\n */\n abstract deleteThread(threadId: string): Promise<void>;\n\n /**\n * Helper method to add a single message to a thread\n * @param threadId - The thread to add the message to\n * @param content - The message content\n * @param role - The role of the message sender\n * @param type - The type of the message\n * @param toolNames - Optional array of tool names that were called\n * @param toolCallArgs - Optional array of tool call arguments\n * @param toolCallIds - Optional array of tool call ids\n * @returns Promise resolving to the saved message\n * @deprecated use saveMessages instead\n */\n async addMessage({\n threadId,\n resourceId,\n config,\n content,\n role,\n type,\n toolNames,\n toolCallArgs,\n toolCallIds,\n }: {\n threadId: string;\n resourceId: string;\n config?: MemoryConfig;\n content: UserContent | AssistantContent;\n role: 'user' | 'assistant';\n type: 'text' | 'tool-call' | 'tool-result';\n toolNames?: string[];\n toolCallArgs?: Record<string, unknown>[];\n toolCallIds?: string[];\n }): Promise<MastraMessageV1> {\n const message: MastraMessageV1 = {\n id: this.generateId(),\n content,\n role,\n createdAt: new Date(),\n threadId,\n resourceId,\n type,\n toolNames,\n toolCallArgs,\n toolCallIds,\n };\n\n const savedMessages = await this.saveMessages({ messages: [message], memoryConfig: config });\n const list = new MessageList({ threadId, resourceId }).add(savedMessages[0]!, 'memory');\n return list.get.all.v1()[0]!;\n }\n\n /**\n * Generates a unique identifier\n * @returns A unique string ID\n */\n public generateId(): string {\n return this.#mastra?.generateId() || crypto.randomUUID();\n }\n\n /**\n * Retrieves working memory for a specific thread\n * @param threadId - The unique identifier of the thread\n * @param resourceId - The unique identifier of the resource\n * @param memoryConfig - Optional memory configuration\n * @returns Promise resolving to working memory data or null if not found\n */\n abstract getWorkingMemory({\n threadId,\n resourceId,\n memoryConfig,\n }: {\n threadId: string;\n resourceId?: string;\n memoryConfig?: MemoryConfig;\n }): Promise<string | null>;\n\n /**\n * Retrieves working memory template for a specific thread\n * @param memoryConfig - Optional memory configuration\n * @returns Promise resolving to working memory template or null if not found\n */\n abstract getWorkingMemoryTemplate({\n memoryConfig,\n }?: {\n memoryConfig?: MemoryConfig;\n }): Promise<WorkingMemoryTemplate | null>;\n\n abstract updateWorkingMemory({\n threadId,\n resourceId,\n workingMemory,\n memoryConfig,\n }: {\n threadId: string;\n resourceId?: string;\n workingMemory: string;\n memoryConfig?: MemoryConfig;\n }): Promise<void>;\n\n /**\n * @warning experimental! can be removed or changed at any time\n */\n abstract __experimental_updateWorkingMemoryVNext({\n threadId,\n resourceId,\n workingMemory,\n searchString,\n memoryConfig,\n }: {\n threadId: string;\n resourceId?: string;\n workingMemory: string;\n searchString?: string;\n memoryConfig?: MemoryConfig;\n }): Promise<{ success: boolean; reason: string }>;\n\n /**\n * Deletes multiple messages by their IDs\n * @param messageIds - Array of message IDs to delete\n * @returns Promise that resolves when all messages are deleted\n */\n abstract deleteMessages(messageIds: string[]): Promise<void>;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { executeHook } from './chunk-TTELJD4F.js';
|
|
2
|
-
import { MastraError } from './chunk-
|
|
2
|
+
import { MastraError } from './chunk-WHFNGECY.js';
|
|
3
3
|
|
|
4
4
|
// src/eval/metric.ts
|
|
5
5
|
var Metric = class {
|
|
@@ -68,5 +68,5 @@ async function evaluate({
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export { Metric, evaluate };
|
|
71
|
-
//# sourceMappingURL=chunk-
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
71
|
+
//# sourceMappingURL=chunk-5HCVPQTD.js.map
|
|
72
|
+
//# sourceMappingURL=chunk-5HCVPQTD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/eval/metric.ts","../src/eval/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AAA,GACF;AAEA,EAAA,IAAI;AACF,IAAA,WAAA,CAAA,cAAA,sBAA0C,WAAW,CAAA;AAAA,EACvD,SAAS,CAAA,EAAY;AACnB,IAAA,MAAM,IAAI,WAAA;AAAA,MACR;AAAA,QACE,EAAA,EAAI,4BAAA;AAAA,QACJ,MAAA,EAAA,MAAA;AAAA,QACA,QAAA,EAAA,MAAA;AAAA,QACA,OAAA,EAAS;AAAA,UACP,SAAA;AAAA,UACA,UAAA;AAAA,UACA;AAAA;AACF,OACF;AAAA,MACA;AAAA,KACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,GAAG,YAAA,EAAc,MAAA,EAAO;AACnC","file":"chunk-5HCVPQTD.js","sourcesContent":["export interface MetricResult {\n score: number;\n info?: Record<string, any>;\n}\n\nexport abstract class Metric {\n abstract measure(input: string, output: string): Promise<MetricResult>;\n}\n","import type { Agent } from '../agent';\nimport { MastraError, ErrorCategory, ErrorDomain } from '../error';\nimport { AvailableHooks, executeHook } from '../hooks';\nimport type { Metric } from './metric';\nimport type { TestInfo, EvaluationResult } from './types';\n\nexport async function evaluate<T extends Agent>({\n agentName,\n input,\n metric,\n output,\n runId,\n globalRunId,\n testInfo,\n instructions,\n}: {\n agentName: string;\n input: Parameters<T['generate']>[0];\n metric: Metric;\n output: string;\n globalRunId: string;\n runId?: string;\n testInfo?: TestInfo;\n instructions: string;\n}): Promise<EvaluationResult> {\n const runIdToUse = runId || crypto.randomUUID();\n\n let metricResult;\n let metricName = metric.constructor.name;\n try {\n metricResult = await metric.measure(input.toString(), output);\n } catch (e: unknown) {\n throw new MastraError(\n {\n id: 'EVAL_METRIC_MEASURE_EXECUTION_FAILED',\n domain: ErrorDomain.EVAL,\n category: ErrorCategory.USER,\n details: {\n agentName,\n metricName,\n globalRunId,\n },\n },\n e,\n );\n }\n const traceObject = {\n input: input.toString(),\n output: output,\n result: metricResult,\n agentName,\n metricName,\n instructions,\n globalRunId,\n runId: runIdToUse,\n testInfo,\n };\n\n try {\n executeHook(AvailableHooks.ON_EVALUATION, traceObject);\n } catch (e: unknown) {\n throw new MastraError(\n {\n id: 'EVAL_HOOK_EXECUTION_FAILED',\n domain: ErrorDomain.EVAL,\n category: ErrorCategory.USER,\n details: {\n agentName,\n metricName,\n globalRunId,\n },\n },\n e,\n );\n }\n\n return { ...metricResult, output };\n}\n"]}
|