@mastra/core 1.0.0-beta.13 → 1.0.0-beta.15
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 +477 -0
- package/dist/agent/agent-legacy.d.ts.map +1 -1
- package/dist/agent/agent.d.ts +2 -2
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +6 -7
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +17 -9
- 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/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.d.ts +1 -1
- package/dist/agent/message-list/index.d.ts.map +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/prompt/attachments-to-parts.d.ts.map +1 -1
- package/dist/agent/trip-wire.d.ts +2 -2
- package/dist/agent/trip-wire.d.ts.map +1 -1
- package/dist/agent/utils.d.ts +4 -1
- package/dist/agent/utils.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/prepare-memory-step.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts +3 -3
- package/dist/agent/workflows/prepare-stream/prepare-tools-step.d.ts.map +1 -1
- package/dist/bundler/types.d.ts +1 -0
- package/dist/bundler/types.d.ts.map +1 -1
- package/dist/chunk-2AU5ZHBL.js +79 -0
- package/dist/chunk-2AU5ZHBL.js.map +1 -0
- package/dist/{chunk-7HEAVZRS.cjs → chunk-2OOMJRXZ.cjs} +15 -15
- package/dist/{chunk-7HEAVZRS.cjs.map → chunk-2OOMJRXZ.cjs.map} +1 -1
- package/dist/chunk-37YWZMBX.js +27 -0
- package/dist/chunk-37YWZMBX.js.map +1 -0
- package/dist/{chunk-VETAQUW3.js → chunk-3HDRO3GG.js} +790 -1206
- package/dist/chunk-3HDRO3GG.js.map +1 -0
- package/dist/{chunk-MRRFTNF4.js → chunk-4DFWV4IR.js} +3 -4
- package/dist/chunk-4DFWV4IR.js.map +1 -0
- package/dist/{chunk-373OC54J.js → chunk-4HP7CS6L.js} +7 -6
- package/dist/chunk-4HP7CS6L.js.map +1 -0
- package/dist/{chunk-62Q7K656.js → chunk-4J4M2Q5R.js} +125 -121
- package/dist/chunk-4J4M2Q5R.js.map +1 -0
- package/dist/{chunk-HWMMIRIF.cjs → chunk-4U7ZLI36.cjs} +3 -2
- package/dist/chunk-4U7ZLI36.cjs.map +1 -0
- package/dist/{chunk-Z55SJVEC.cjs → chunk-6HJFCSJ4.cjs} +7 -6
- package/dist/chunk-6HJFCSJ4.cjs.map +1 -0
- package/dist/{chunk-Y7MZ5LJT.cjs → chunk-AAX7ZOM7.cjs} +101 -102
- package/dist/chunk-AAX7ZOM7.cjs.map +1 -0
- package/dist/{chunk-WPTTKULS.js → chunk-AR5CF3IN.js} +4 -4
- package/dist/{chunk-WPTTKULS.js.map → chunk-AR5CF3IN.js.map} +1 -1
- package/dist/{chunk-5VZGJTPR.js → chunk-BAZHNX5P.js} +57 -11
- package/dist/chunk-BAZHNX5P.js.map +1 -0
- package/dist/{chunk-MLKE7HRS.cjs → chunk-BC2VKOH4.cjs} +43 -21
- package/dist/chunk-BC2VKOH4.cjs.map +1 -0
- package/dist/{chunk-2IU4RGU5.js → chunk-BCUKD2XG.js} +59 -19
- package/dist/chunk-BCUKD2XG.js.map +1 -0
- package/dist/{chunk-WYGUWVTF.js → chunk-CBQ6WDUJ.js} +9 -9
- package/dist/chunk-CBQ6WDUJ.js.map +1 -0
- package/dist/chunk-CBVHOGXX.cjs +674 -0
- package/dist/chunk-CBVHOGXX.cjs.map +1 -0
- package/dist/{chunk-PJAK4U6R.cjs → chunk-CBY37FTP.cjs} +28 -28
- package/dist/chunk-CBY37FTP.cjs.map +1 -0
- package/dist/{chunk-BQDZIQ3G.js → chunk-D2IFWD7A.js} +365 -137
- package/dist/chunk-D2IFWD7A.js.map +1 -0
- package/dist/{chunk-R5AJGM55.cjs → chunk-DDK3URK2.cjs} +987 -519
- package/dist/chunk-DDK3URK2.cjs.map +1 -0
- package/dist/chunk-DRJTNGI4.cjs +263 -0
- package/dist/chunk-DRJTNGI4.cjs.map +1 -0
- package/dist/{chunk-X6IBA7FP.cjs → chunk-EMLEZXTQ.cjs} +22 -120
- package/dist/chunk-EMLEZXTQ.cjs.map +1 -0
- package/dist/{chunk-OWIEOL55.cjs → chunk-F75EQ574.cjs} +695 -254
- package/dist/chunk-F75EQ574.cjs.map +1 -0
- package/dist/{chunk-YPLZDWG7.js → chunk-FJEVLHJT.js} +3 -2
- package/dist/chunk-FJEVLHJT.js.map +1 -0
- package/dist/chunk-GVAPYQRO.cjs +252 -0
- package/dist/chunk-GVAPYQRO.cjs.map +1 -0
- package/dist/{chunk-MXBVP7HX.cjs → chunk-GXMJ5URG.cjs} +227 -181
- package/dist/chunk-GXMJ5URG.cjs.map +1 -0
- package/dist/chunk-H2NHG7QL.cjs +32 -0
- package/dist/chunk-H2NHG7QL.cjs.map +1 -0
- package/dist/chunk-HAYBGFPA.js +259 -0
- package/dist/chunk-HAYBGFPA.js.map +1 -0
- package/dist/{chunk-GIWC35YQ.js → chunk-IHISDRFV.js} +299 -49
- package/dist/chunk-IHISDRFV.js.map +1 -0
- package/dist/{chunk-VEPP75C4.cjs → chunk-IRTICXRZ.cjs} +101 -61
- package/dist/chunk-IRTICXRZ.cjs.map +1 -0
- package/dist/{chunk-ARAQIW6E.js → chunk-K66U47VL.js} +617 -188
- package/dist/chunk-K66U47VL.js.map +1 -0
- package/dist/{chunk-LGB4VNZI.cjs → chunk-LOV5NNGK.cjs} +811 -1235
- package/dist/chunk-LOV5NNGK.cjs.map +1 -0
- package/dist/{chunk-E5BQRAJK.js → chunk-NGWTSHNA.js} +823 -362
- package/dist/chunk-NGWTSHNA.js.map +1 -0
- package/dist/{chunk-72YCRTEX.cjs → chunk-O2CAMK4A.cjs} +13 -2
- package/dist/chunk-O2CAMK4A.cjs.map +1 -0
- package/dist/{chunk-4BC5FUAO.js → chunk-O7M7DR4E.js} +6 -5
- package/dist/chunk-O7M7DR4E.js.map +1 -0
- package/dist/chunk-OTIGV7CL.js +10215 -0
- package/dist/chunk-OTIGV7CL.js.map +1 -0
- package/dist/{chunk-WYWRMIQC.js → chunk-QXL3F3T2.js} +9 -105
- package/dist/chunk-QXL3F3T2.js.map +1 -0
- package/dist/{chunk-U4CSOY6T.cjs → chunk-RA2CHJCY.cjs} +399 -171
- package/dist/chunk-RA2CHJCY.cjs.map +1 -0
- package/dist/chunk-RMV5HJM7.cjs +10237 -0
- package/dist/chunk-RMV5HJM7.cjs.map +1 -0
- package/dist/{chunk-AGHLXC4I.cjs → chunk-S23TNDXG.cjs} +300 -50
- package/dist/chunk-S23TNDXG.cjs.map +1 -0
- package/dist/{chunk-H4VUIOWU.cjs → chunk-SSB4AVHU.cjs} +20 -19
- package/dist/chunk-SSB4AVHU.cjs.map +1 -0
- package/dist/chunk-ST7NBF4H.cjs +84 -0
- package/dist/chunk-ST7NBF4H.cjs.map +1 -0
- package/dist/{chunk-SZYSDJTN.cjs → chunk-T2LVULCK.cjs} +142 -137
- package/dist/chunk-T2LVULCK.cjs.map +1 -0
- package/dist/chunk-VE6HQ7H6.js +250 -0
- package/dist/chunk-VE6HQ7H6.js.map +1 -0
- package/dist/{chunk-RCJLMMTO.js → chunk-XJB7J4UT.js} +30 -8
- package/dist/chunk-XJB7J4UT.js.map +1 -0
- package/dist/chunk-YV43YEZ6.js +598 -0
- package/dist/chunk-YV43YEZ6.js.map +1 -0
- package/dist/{chunk-Y36Y5MTD.js → chunk-ZGIVAQRI.js} +13 -3
- package/dist/chunk-ZGIVAQRI.js.map +1 -0
- package/dist/error/index.cjs +6 -6
- package/dist/error/index.d.ts +1 -0
- package/dist/error/index.d.ts.map +1 -1
- package/dist/error/index.js +1 -1
- package/dist/evals/index.cjs +49 -9
- package/dist/evals/index.js +2 -2
- package/dist/evals/run/index.d.ts.map +1 -1
- package/dist/evals/scoreTraces/index.cjs +70 -22
- package/dist/evals/scoreTraces/index.cjs.map +1 -1
- package/dist/evals/scoreTraces/index.js +63 -15
- package/dist/evals/scoreTraces/index.js.map +1 -1
- package/dist/evals/scoreTraces/scoreTracesWorkflow.d.ts.map +1 -1
- package/dist/evals/scoreTraces/utils.d.ts.map +1 -1
- package/dist/evals/types.d.ts +568 -116
- package/dist/evals/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +21 -21
- package/dist/llm/index.js +5 -5
- package/dist/llm/model/aisdk/generate-to-stream.d.ts +20 -0
- package/dist/llm/model/aisdk/generate-to-stream.d.ts.map +1 -0
- package/dist/llm/model/aisdk/v5/model.d.ts +4 -0
- package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
- package/dist/llm/model/aisdk/v6/model.d.ts +43 -0
- package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -0
- package/dist/llm/model/embedding-router.d.ts +1 -1
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/llm/model/provider-options.d.ts +2 -1
- package/dist/llm/model/provider-options.d.ts.map +1 -1
- package/dist/llm/model/provider-types.generated.d.ts +126 -17
- package/dist/llm/model/resolve-model.d.ts +2 -2
- package/dist/llm/model/resolve-model.d.ts.map +1 -1
- package/dist/llm/model/shared.types.d.ts +18 -7
- 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 +8 -8
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV2Mock.d.ts.map +1 -1
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts +29 -0
- package/dist/loop/test-utils/MastraLanguageModelV3Mock.d.ts.map +1 -0
- package/dist/loop/test-utils/fullStream.d.ts +2 -1
- package/dist/loop/test-utils/fullStream.d.ts.map +1 -1
- package/dist/loop/test-utils/resultObject.d.ts +2 -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/utils-v3.d.ts +55 -0
- package/dist/loop/test-utils/utils-v3.d.ts.map +1 -0
- package/dist/loop/types.d.ts +10 -8
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +36 -36
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +25 -25
- 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 +12 -12
- package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
- package/dist/loop/workflows/agentic-loop/index.d.ts +36 -36
- package/dist/loop/workflows/agentic-loop/index.d.ts.map +1 -1
- package/dist/loop/workflows/run-state.d.ts +2 -2
- package/dist/loop/workflows/run-state.d.ts.map +1 -1
- package/dist/loop/workflows/schema.d.ts +12 -12
- package/dist/mastra/hooks.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +7 -2
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +4 -4
- package/dist/mcp/index.js +1 -1
- package/dist/memory/index.cjs +26 -6
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +9 -8
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/memory/mock.d.ts +2 -1
- package/dist/memory/mock.d.ts.map +1 -1
- package/dist/memory/types.d.ts +3 -4
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/memory/working-memory-utils.d.ts +20 -0
- package/dist/memory/working-memory-utils.d.ts.map +1 -0
- package/dist/models-dev-26XLUKVK.cjs +12 -0
- package/dist/{models-dev-D3EKFGAO.cjs.map → models-dev-26XLUKVK.cjs.map} +1 -1
- package/dist/models-dev-HUFLQFPB.js +3 -0
- package/dist/{models-dev-EO22XOXQ.js.map → models-dev-HUFLQFPB.js.map} +1 -1
- package/dist/netlify-CUYK2MZ2.cjs +12 -0
- package/dist/{netlify-WE42TZIT.cjs.map → netlify-CUYK2MZ2.cjs.map} +1 -1
- package/dist/netlify-J4QPOROO.js +3 -0
- package/dist/{netlify-AE4LNCAI.js.map → netlify-J4QPOROO.js.map} +1 -1
- package/dist/observability/index.cjs +14 -10
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +32 -19
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.d.ts +9 -7
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/memory/message-history.d.ts +7 -1
- package/dist/processors/memory/message-history.d.ts.map +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/token-limiter.d.ts +5 -2
- package/dist/processors/processors/token-limiter.d.ts.map +1 -1
- package/dist/processors/runner.d.ts +2 -0
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/processors/step-schema.d.ts +26 -26
- package/dist/processors/step-schema.d.ts.map +1 -1
- package/dist/provider-registry-6CIGRQVZ.js +3 -0
- package/dist/{provider-registry-6LF3NGC5.js.map → provider-registry-6CIGRQVZ.js.map} +1 -1
- package/dist/provider-registry-7O7FJ4BS.cjs +40 -0
- package/dist/{provider-registry-73FKMXJV.cjs.map → provider-registry-7O7FJ4BS.cjs.map} +1 -1
- package/dist/provider-registry.json +295 -45
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.cjs.map +1 -1
- package/dist/relevance/index.js +2 -2
- package/dist/relevance/index.js.map +1 -1
- package/dist/server/index.cjs +5 -5
- package/dist/server/index.js +1 -1
- package/dist/storage/base.d.ts +40 -292
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.cjs +60 -0
- package/dist/storage/constants.cjs.map +1 -0
- package/dist/storage/constants.d.ts +6 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/constants.js +3 -0
- package/dist/storage/constants.js.map +1 -0
- package/dist/storage/domains/agents/base.d.ts +2 -2
- package/dist/storage/domains/agents/base.d.ts.map +1 -1
- package/dist/storage/domains/agents/inmemory.d.ts +5 -4
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/base.d.ts +20 -0
- package/dist/storage/domains/base.d.ts.map +1 -0
- package/dist/storage/domains/index.d.ts +3 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/inmemory-db.d.ts +57 -0
- package/dist/storage/domains/inmemory-db.d.ts.map +1 -0
- package/dist/storage/domains/memory/base.d.ts +2 -2
- package/dist/storage/domains/memory/base.d.ts.map +1 -1
- package/dist/storage/domains/memory/inmemory.d.ts +5 -13
- package/dist/storage/domains/memory/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/base.d.ts +24 -29
- package/dist/storage/domains/observability/base.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +1 -0
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/inmemory.d.ts +46 -35
- package/dist/storage/domains/observability/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/observability/types.d.ts +2365 -0
- package/dist/storage/domains/observability/types.d.ts.map +1 -0
- package/dist/storage/domains/scores/base.d.ts +9 -20
- package/dist/storage/domains/scores/base.d.ts.map +1 -1
- package/dist/storage/domains/scores/inmemory.d.ts +11 -22
- package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/shared.d.ts +76 -0
- package/dist/storage/domains/shared.d.ts.map +1 -0
- package/dist/storage/domains/workflows/base.d.ts +4 -2
- package/dist/storage/domains/workflows/base.d.ts.map +1 -1
- package/dist/storage/domains/workflows/inmemory.d.ts +10 -9
- package/dist/storage/domains/workflows/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +272 -59
- package/dist/storage/index.js +2 -1
- package/dist/storage/mock.d.ts +28 -174
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +39 -44
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/utils.d.ts +5 -0
- package/dist/storage/utils.d.ts.map +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
- package/dist/stream/RunOutput.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/execute.d.ts +4 -4
- package/dist/stream/aisdk/v5/execute.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/output.d.ts +2 -2
- package/dist/stream/aisdk/v5/output.d.ts.map +1 -1
- package/dist/stream/aisdk/v5/transform.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +7 -5
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +12 -12
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +32 -21
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.cjs.map +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/test-utils/llm-mock.js.map +1 -1
- package/dist/token-6GSAFR2W-LTZ7QQUP.js +61 -0
- package/dist/token-6GSAFR2W-LTZ7QQUP.js.map +1 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs +63 -0
- package/dist/token-6GSAFR2W-UEEINYAN.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-QTFZ26EN.js +8 -0
- package/dist/token-util-NEHG7TUY-QTFZ26EN.js.map +1 -0
- package/dist/token-util-NEHG7TUY-WZL2DNCG.cjs +10 -0
- package/dist/token-util-NEHG7TUY-WZL2DNCG.cjs.map +1 -0
- package/dist/tool-loop-agent/index.cjs +20 -0
- package/dist/tool-loop-agent/index.cjs.map +1 -0
- package/dist/tool-loop-agent/index.d.ts +36 -0
- package/dist/tool-loop-agent/index.d.ts.map +1 -0
- package/dist/tool-loop-agent/index.js +3 -0
- package/dist/tool-loop-agent/index.js.map +1 -0
- package/dist/tool-loop-agent/tool-loop-processor.d.ts +30 -0
- package/dist/tool-loop-agent/tool-loop-processor.d.ts.map +1 -0
- package/dist/tool-loop-agent/utils.d.ts +17 -0
- package/dist/tool-loop-agent/utils.d.ts.map +1 -0
- 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-builder/builder.d.ts.map +1 -1
- package/dist/tools/toolchecks.d.ts +1 -1
- package/dist/tools/toolchecks.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +1 -1
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/utils/zod-utils.d.ts +34 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/dist/utils.cjs +39 -22
- package/dist/utils.d.ts +3 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -1
- package/dist/vector/embed.d.ts +1 -0
- package/dist/vector/embed.d.ts.map +1 -1
- package/dist/vector/index.cjs +18 -5
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.js +9 -2
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/vector.d.ts +26 -3
- package/dist/vector/vector.d.ts.map +1 -1
- package/dist/voice/composite-voice.d.ts.map +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/default.d.ts +2 -0
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/execution-engine.d.ts +1 -0
- 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 +5 -0
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/index.d.ts +20 -4
- package/dist/workflows/evented/workflow-event-processor/index.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/loop.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/parallel.d.ts.map +1 -1
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts +2 -2
- package/dist/workflows/evented/workflow-event-processor/sleep.d.ts.map +1 -1
- package/dist/workflows/evented/workflow.d.ts +10 -2
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/execution-engine.d.ts +1 -0
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts +4 -0
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/entry.d.ts +3 -2
- package/dist/workflows/handlers/entry.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts +1 -0
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/types.d.ts +23 -3
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +1 -0
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +26 -9
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +20 -12
- package/src/llm/model/provider-types.generated.d.ts +126 -17
- package/storage/constants.d.ts +1 -0
- package/tool-loop-agent.d.ts +1 -0
- package/dist/chunk-2IU4RGU5.js.map +0 -1
- package/dist/chunk-373OC54J.js.map +0 -1
- package/dist/chunk-4BC5FUAO.js.map +0 -1
- package/dist/chunk-5VZGJTPR.js.map +0 -1
- package/dist/chunk-62Q7K656.js.map +0 -1
- package/dist/chunk-72YCRTEX.cjs.map +0 -1
- package/dist/chunk-ADADLFDR.js +0 -42
- package/dist/chunk-ADADLFDR.js.map +0 -1
- package/dist/chunk-AGHLXC4I.cjs.map +0 -1
- package/dist/chunk-ARAQIW6E.js.map +0 -1
- package/dist/chunk-BQDZIQ3G.js.map +0 -1
- package/dist/chunk-E5BQRAJK.js.map +0 -1
- package/dist/chunk-GIWC35YQ.js.map +0 -1
- package/dist/chunk-H4VUIOWU.cjs.map +0 -1
- package/dist/chunk-HWMMIRIF.cjs.map +0 -1
- package/dist/chunk-IXZ2T2QX.cjs +0 -448
- package/dist/chunk-IXZ2T2QX.cjs.map +0 -1
- package/dist/chunk-LGB4VNZI.cjs.map +0 -1
- package/dist/chunk-MLKE7HRS.cjs.map +0 -1
- package/dist/chunk-MRRFTNF4.js.map +0 -1
- package/dist/chunk-MXBVP7HX.cjs.map +0 -1
- package/dist/chunk-OWIEOL55.cjs.map +0 -1
- package/dist/chunk-PJAK4U6R.cjs.map +0 -1
- package/dist/chunk-R5AJGM55.cjs.map +0 -1
- package/dist/chunk-RCJLMMTO.js.map +0 -1
- package/dist/chunk-SZYSDJTN.cjs.map +0 -1
- package/dist/chunk-T2VLUFGG.cjs +0 -47
- package/dist/chunk-T2VLUFGG.cjs.map +0 -1
- package/dist/chunk-U4CSOY6T.cjs.map +0 -1
- package/dist/chunk-UBSPZTQX.js +0 -434
- package/dist/chunk-UBSPZTQX.js.map +0 -1
- package/dist/chunk-VEPP75C4.cjs.map +0 -1
- package/dist/chunk-VETAQUW3.js.map +0 -1
- package/dist/chunk-WYGUWVTF.js.map +0 -1
- package/dist/chunk-WYWRMIQC.js.map +0 -1
- package/dist/chunk-X6IBA7FP.cjs.map +0 -1
- package/dist/chunk-Y36Y5MTD.js.map +0 -1
- package/dist/chunk-Y7MZ5LJT.cjs.map +0 -1
- package/dist/chunk-YPLZDWG7.js.map +0 -1
- package/dist/chunk-Z55SJVEC.cjs.map +0 -1
- package/dist/llm/model/is-v2-model.d.ts +0 -3
- package/dist/llm/model/is-v2-model.d.ts.map +0 -1
- package/dist/models-dev-D3EKFGAO.cjs +0 -12
- package/dist/models-dev-EO22XOXQ.js +0 -3
- package/dist/netlify-AE4LNCAI.js +0 -3
- package/dist/netlify-WE42TZIT.cjs +0 -12
- package/dist/provider-registry-6LF3NGC5.js +0 -3
- package/dist/provider-registry-73FKMXJV.cjs +0 -40
|
@@ -1,188 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkEMLEZXTQ_cjs = require('./chunk-EMLEZXTQ.cjs');
|
|
4
|
+
var chunkCBVHOGXX_cjs = require('./chunk-CBVHOGXX.cjs');
|
|
5
|
+
var chunk4U7ZLI36_cjs = require('./chunk-4U7ZLI36.cjs');
|
|
5
6
|
var chunkDGV2FWB4_cjs = require('./chunk-DGV2FWB4.cjs');
|
|
6
7
|
|
|
7
|
-
// src/storage/constants.ts
|
|
8
|
-
var TABLE_WORKFLOW_SNAPSHOT = "mastra_workflow_snapshot";
|
|
9
|
-
var TABLE_MESSAGES = "mastra_messages";
|
|
10
|
-
var TABLE_THREADS = "mastra_threads";
|
|
11
|
-
var TABLE_TRACES = "mastra_traces";
|
|
12
|
-
var TABLE_RESOURCES = "mastra_resources";
|
|
13
|
-
var TABLE_SCORERS = "mastra_scorers";
|
|
14
|
-
var TABLE_SPANS = "mastra_ai_spans";
|
|
15
|
-
var TABLE_AGENTS = "mastra_agents";
|
|
16
|
-
var SCORERS_SCHEMA = {
|
|
17
|
-
id: { type: "text", nullable: false, primaryKey: true },
|
|
18
|
-
scorerId: { type: "text" },
|
|
19
|
-
traceId: { type: "text", nullable: true },
|
|
20
|
-
spanId: { type: "text", nullable: true },
|
|
21
|
-
runId: { type: "text" },
|
|
22
|
-
scorer: { type: "jsonb" },
|
|
23
|
-
preprocessStepResult: { type: "jsonb", nullable: true },
|
|
24
|
-
extractStepResult: { type: "jsonb", nullable: true },
|
|
25
|
-
analyzeStepResult: { type: "jsonb", nullable: true },
|
|
26
|
-
score: { type: "float" },
|
|
27
|
-
reason: { type: "text", nullable: true },
|
|
28
|
-
metadata: { type: "jsonb", nullable: true },
|
|
29
|
-
preprocessPrompt: { type: "text", nullable: true },
|
|
30
|
-
extractPrompt: { type: "text", nullable: true },
|
|
31
|
-
generateScorePrompt: { type: "text", nullable: true },
|
|
32
|
-
generateReasonPrompt: { type: "text", nullable: true },
|
|
33
|
-
analyzePrompt: { type: "text", nullable: true },
|
|
34
|
-
// Deprecated
|
|
35
|
-
reasonPrompt: { type: "text", nullable: true },
|
|
36
|
-
input: { type: "jsonb" },
|
|
37
|
-
output: { type: "jsonb" },
|
|
38
|
-
// MESSAGE OUTPUT
|
|
39
|
-
additionalContext: { type: "jsonb", nullable: true },
|
|
40
|
-
// DATA FROM THE CONTEXT PARAM ON AN AGENT
|
|
41
|
-
requestContext: { type: "jsonb", nullable: true },
|
|
42
|
-
// THE EVALUATE Request Context FOR THE RUN
|
|
43
|
-
/**
|
|
44
|
-
* Things you can evaluate
|
|
45
|
-
*/
|
|
46
|
-
entityType: { type: "text", nullable: true },
|
|
47
|
-
// WORKFLOW, AGENT, TOOL, STEP, NETWORK
|
|
48
|
-
entity: { type: "jsonb", nullable: true },
|
|
49
|
-
// MINIMAL JSON DATA ABOUT WORKFLOW, AGENT, TOOL, STEP, NETWORK
|
|
50
|
-
entityId: { type: "text", nullable: true },
|
|
51
|
-
source: { type: "text" },
|
|
52
|
-
resourceId: { type: "text", nullable: true },
|
|
53
|
-
threadId: { type: "text", nullable: true },
|
|
54
|
-
createdAt: { type: "timestamp" },
|
|
55
|
-
updatedAt: { type: "timestamp" }
|
|
56
|
-
};
|
|
57
|
-
var SPAN_SCHEMA = {
|
|
58
|
-
// Composite primary key of traceId and spanId
|
|
59
|
-
traceId: { type: "text", nullable: false },
|
|
60
|
-
spanId: { type: "text", nullable: false },
|
|
61
|
-
parentSpanId: { type: "text", nullable: true },
|
|
62
|
-
name: { type: "text", nullable: false },
|
|
63
|
-
scope: { type: "jsonb", nullable: true },
|
|
64
|
-
// Mastra package info {"core-version": "0.1.0"}
|
|
65
|
-
spanType: { type: "text", nullable: false },
|
|
66
|
-
// WORKFLOW_RUN, WORKFLOW_STEP, AGENT_RUN, AGENT_STEP, TOOL_RUN, TOOL_STEP, etc.
|
|
67
|
-
attributes: { type: "jsonb", nullable: true },
|
|
68
|
-
metadata: { type: "jsonb", nullable: true },
|
|
69
|
-
links: { type: "jsonb", nullable: true },
|
|
70
|
-
input: { type: "jsonb", nullable: true },
|
|
71
|
-
output: { type: "jsonb", nullable: true },
|
|
72
|
-
error: { type: "jsonb", nullable: true },
|
|
73
|
-
startedAt: { type: "timestamp", nullable: false },
|
|
74
|
-
// When the span started
|
|
75
|
-
endedAt: { type: "timestamp", nullable: true },
|
|
76
|
-
// When the span ended
|
|
77
|
-
createdAt: { type: "timestamp", nullable: false },
|
|
78
|
-
// The time the database record was created
|
|
79
|
-
updatedAt: { type: "timestamp", nullable: true },
|
|
80
|
-
// The time the database record was last updated
|
|
81
|
-
isEvent: { type: "boolean", nullable: false }
|
|
82
|
-
};
|
|
83
|
-
var AGENTS_SCHEMA = {
|
|
84
|
-
id: { type: "text", nullable: false, primaryKey: true },
|
|
85
|
-
name: { type: "text", nullable: false },
|
|
86
|
-
description: { type: "text", nullable: true },
|
|
87
|
-
instructions: { type: "text", nullable: false },
|
|
88
|
-
// System instructions for the agent
|
|
89
|
-
model: { type: "jsonb", nullable: false },
|
|
90
|
-
// Model configuration (provider, name, etc.)
|
|
91
|
-
tools: { type: "jsonb", nullable: true },
|
|
92
|
-
// Serialized tool references/configurations
|
|
93
|
-
defaultOptions: { type: "jsonb", nullable: true },
|
|
94
|
-
// Default options for generate/stream calls
|
|
95
|
-
workflows: { type: "jsonb", nullable: true },
|
|
96
|
-
// Workflow references (IDs or configurations)
|
|
97
|
-
agents: { type: "jsonb", nullable: true },
|
|
98
|
-
// Sub-agent references (IDs or configurations)
|
|
99
|
-
inputProcessors: { type: "jsonb", nullable: true },
|
|
100
|
-
// Input processor configurations
|
|
101
|
-
outputProcessors: { type: "jsonb", nullable: true },
|
|
102
|
-
// Output processor configurations
|
|
103
|
-
memory: { type: "jsonb", nullable: true },
|
|
104
|
-
// Memory configuration
|
|
105
|
-
scorers: { type: "jsonb", nullable: true },
|
|
106
|
-
// Scorer configurations
|
|
107
|
-
metadata: { type: "jsonb", nullable: true },
|
|
108
|
-
// Additional metadata for the agent
|
|
109
|
-
createdAt: { type: "timestamp", nullable: false },
|
|
110
|
-
updatedAt: { type: "timestamp", nullable: false }
|
|
111
|
-
};
|
|
112
|
-
var TABLE_SCHEMAS = {
|
|
113
|
-
[TABLE_WORKFLOW_SNAPSHOT]: {
|
|
114
|
-
workflow_name: {
|
|
115
|
-
type: "text"
|
|
116
|
-
},
|
|
117
|
-
run_id: {
|
|
118
|
-
type: "text"
|
|
119
|
-
},
|
|
120
|
-
resourceId: { type: "text", nullable: true },
|
|
121
|
-
snapshot: {
|
|
122
|
-
type: "text"
|
|
123
|
-
},
|
|
124
|
-
createdAt: {
|
|
125
|
-
type: "timestamp"
|
|
126
|
-
},
|
|
127
|
-
updatedAt: {
|
|
128
|
-
type: "timestamp"
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
[TABLE_SCORERS]: SCORERS_SCHEMA,
|
|
132
|
-
[TABLE_THREADS]: {
|
|
133
|
-
id: { type: "text", nullable: false, primaryKey: true },
|
|
134
|
-
resourceId: { type: "text", nullable: false },
|
|
135
|
-
title: { type: "text", nullable: false },
|
|
136
|
-
metadata: { type: "text", nullable: true },
|
|
137
|
-
createdAt: { type: "timestamp", nullable: false },
|
|
138
|
-
updatedAt: { type: "timestamp", nullable: false }
|
|
139
|
-
},
|
|
140
|
-
[TABLE_MESSAGES]: {
|
|
141
|
-
id: { type: "text", nullable: false, primaryKey: true },
|
|
142
|
-
thread_id: { type: "text", nullable: false },
|
|
143
|
-
content: { type: "text", nullable: false },
|
|
144
|
-
role: { type: "text", nullable: false },
|
|
145
|
-
type: { type: "text", nullable: false },
|
|
146
|
-
createdAt: { type: "timestamp", nullable: false },
|
|
147
|
-
resourceId: { type: "text", nullable: true }
|
|
148
|
-
},
|
|
149
|
-
[TABLE_SPANS]: SPAN_SCHEMA,
|
|
150
|
-
[TABLE_TRACES]: {
|
|
151
|
-
id: { type: "text", nullable: false, primaryKey: true },
|
|
152
|
-
parentSpanId: { type: "text", nullable: true },
|
|
153
|
-
name: { type: "text", nullable: false },
|
|
154
|
-
traceId: { type: "text", nullable: false },
|
|
155
|
-
scope: { type: "text", nullable: false },
|
|
156
|
-
kind: { type: "integer", nullable: false },
|
|
157
|
-
attributes: { type: "jsonb", nullable: true },
|
|
158
|
-
status: { type: "jsonb", nullable: true },
|
|
159
|
-
events: { type: "jsonb", nullable: true },
|
|
160
|
-
links: { type: "jsonb", nullable: true },
|
|
161
|
-
other: { type: "text", nullable: true },
|
|
162
|
-
startTime: { type: "bigint", nullable: false },
|
|
163
|
-
endTime: { type: "bigint", nullable: false },
|
|
164
|
-
createdAt: { type: "timestamp", nullable: false }
|
|
165
|
-
},
|
|
166
|
-
[TABLE_RESOURCES]: {
|
|
167
|
-
id: { type: "text", nullable: false, primaryKey: true },
|
|
168
|
-
workingMemory: { type: "text", nullable: true },
|
|
169
|
-
metadata: { type: "jsonb", nullable: true },
|
|
170
|
-
createdAt: { type: "timestamp", nullable: false },
|
|
171
|
-
updatedAt: { type: "timestamp", nullable: false }
|
|
172
|
-
},
|
|
173
|
-
[TABLE_AGENTS]: AGENTS_SCHEMA
|
|
174
|
-
};
|
|
175
|
-
|
|
176
8
|
// src/storage/base.ts
|
|
177
|
-
function ensureDate(date) {
|
|
178
|
-
if (!date) return void 0;
|
|
179
|
-
return date instanceof Date ? date : new Date(date);
|
|
180
|
-
}
|
|
181
|
-
function serializeDate(date) {
|
|
182
|
-
if (!date) return void 0;
|
|
183
|
-
const dateObj = ensureDate(date);
|
|
184
|
-
return dateObj?.toISOString();
|
|
185
|
-
}
|
|
186
9
|
function normalizePerPage(perPageInput, defaultValue) {
|
|
187
10
|
if (perPageInput === false) {
|
|
188
11
|
return Number.MAX_SAFE_INTEGER;
|
|
@@ -242,537 +65,138 @@ var MastraStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
242
65
|
hasColumn: false,
|
|
243
66
|
createTable: false,
|
|
244
67
|
deleteMessages: false,
|
|
245
|
-
|
|
68
|
+
observability: false,
|
|
246
69
|
indexManagement: false,
|
|
247
70
|
listScoresBySpan: false,
|
|
248
71
|
agents: false
|
|
249
72
|
};
|
|
250
73
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
async updateResource(_) {
|
|
268
|
-
throw new Error(
|
|
269
|
-
`Resource working memory is not supported by this storage adapter (${this.constructor.name}). Supported storage adapters: LibSQL (@mastra/libsql), PostgreSQL (@mastra/pg), Upstash (@mastra/upstash). To use per-resource working memory, switch to one of these supported storage adapters.`
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
async listMessages(args) {
|
|
273
|
-
if (this.stores?.memory) {
|
|
274
|
-
return this.stores.memory.listMessages(args);
|
|
275
|
-
}
|
|
276
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
277
|
-
id: "MASTRA_STORAGE_LIST_MESSAGES_NOT_SUPPORTED",
|
|
278
|
-
domain: "STORAGE" /* STORAGE */,
|
|
279
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
280
|
-
text: `Listing messages is not implemented by this storage adapter (${this.constructor.name})`
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
async listWorkflowRuns(args) {
|
|
284
|
-
if (this.stores?.workflows) {
|
|
285
|
-
return this.stores.workflows.listWorkflowRuns(args);
|
|
286
|
-
}
|
|
287
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
288
|
-
id: "MASTRA_STORAGE_LIST_WORKFLOW_RUNS_NOT_SUPPORTED",
|
|
289
|
-
domain: "STORAGE" /* STORAGE */,
|
|
290
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
291
|
-
text: `Listing workflow runs is not implemented by this storage adapter (${this.constructor.name})`
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
async listThreadsByResourceId(args) {
|
|
295
|
-
if (this.stores?.memory) {
|
|
296
|
-
return this.stores.memory.listThreadsByResourceId(args);
|
|
297
|
-
}
|
|
298
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
299
|
-
id: "MASTRA_STORAGE_LIST_THREADS_BY_RESOURCE_ID_PAGINATED_NOT_SUPPORTED",
|
|
300
|
-
domain: "STORAGE" /* STORAGE */,
|
|
301
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
302
|
-
text: `Listing threads by resource ID paginated is not implemented by this storage adapter (${this.constructor.name})`
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
async listMessagesById({ messageIds }) {
|
|
306
|
-
if (this.stores?.memory) {
|
|
307
|
-
const result = await this.stores.memory.listMessagesById({ messageIds });
|
|
308
|
-
return result;
|
|
309
|
-
}
|
|
310
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
311
|
-
id: "MASTRA_STORAGE_LIST_MESSAGES_BY_ID_NOT_SUPPORTED",
|
|
312
|
-
domain: "STORAGE" /* STORAGE */,
|
|
313
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
314
|
-
text: `Listing messages by ID is not implemented by this storage adapter (${this.constructor.name})`
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
async deleteMessages(_messageIds) {
|
|
318
|
-
throw new Error(
|
|
319
|
-
`Message deletion is not supported by this storage adapter (${this.constructor.name}). The deleteMessages method needs to be implemented in the storage adapter.`
|
|
320
|
-
);
|
|
74
|
+
/**
|
|
75
|
+
* Get a domain-specific storage interface.
|
|
76
|
+
*
|
|
77
|
+
* @param storeName - The name of the domain to access ('memory', 'workflows', 'scores', 'observability', 'agents')
|
|
78
|
+
* @returns The domain storage interface, or undefined if not available
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const memory = await storage.getStore('memory');
|
|
83
|
+
* if (memory) {
|
|
84
|
+
* await memory.saveThread({ thread });
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
async getStore(storeName) {
|
|
89
|
+
return this.stores?.[storeName];
|
|
321
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Initialize all domain stores.
|
|
93
|
+
* This creates necessary tables, indexes, and performs any required migrations.
|
|
94
|
+
*/
|
|
322
95
|
async init() {
|
|
323
96
|
if (this.shouldCacheInit && await this.hasInitialized) {
|
|
324
97
|
return;
|
|
325
98
|
}
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]
|
|
330
|
-
}),
|
|
331
|
-
this.createTable({
|
|
332
|
-
tableName: TABLE_THREADS,
|
|
333
|
-
schema: TABLE_SCHEMAS[TABLE_THREADS]
|
|
334
|
-
}),
|
|
335
|
-
this.createTable({
|
|
336
|
-
tableName: TABLE_MESSAGES,
|
|
337
|
-
schema: TABLE_SCHEMAS[TABLE_MESSAGES]
|
|
338
|
-
}),
|
|
339
|
-
this.createTable({
|
|
340
|
-
tableName: TABLE_TRACES,
|
|
341
|
-
schema: TABLE_SCHEMAS[TABLE_TRACES]
|
|
342
|
-
}),
|
|
343
|
-
this.createTable({
|
|
344
|
-
tableName: TABLE_SCORERS,
|
|
345
|
-
schema: TABLE_SCHEMAS[TABLE_SCORERS]
|
|
346
|
-
})
|
|
347
|
-
];
|
|
348
|
-
if (this.supports.resourceWorkingMemory) {
|
|
349
|
-
tableCreationTasks.push(
|
|
350
|
-
this.createTable({
|
|
351
|
-
tableName: TABLE_RESOURCES,
|
|
352
|
-
schema: TABLE_SCHEMAS[TABLE_RESOURCES]
|
|
353
|
-
})
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
if (this.supports.observabilityInstance) {
|
|
357
|
-
tableCreationTasks.push(
|
|
358
|
-
this.createTable({
|
|
359
|
-
tableName: TABLE_SPANS,
|
|
360
|
-
schema: TABLE_SCHEMAS[TABLE_SPANS]
|
|
361
|
-
})
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
if (this.supports.agents) {
|
|
365
|
-
tableCreationTasks.push(
|
|
366
|
-
this.createTable({
|
|
367
|
-
tableName: TABLE_AGENTS,
|
|
368
|
-
schema: TABLE_SCHEMAS[TABLE_AGENTS]
|
|
369
|
-
})
|
|
370
|
-
);
|
|
99
|
+
const initTasks = [];
|
|
100
|
+
if (this.stores?.memory) {
|
|
101
|
+
initTasks.push(this.stores.memory.init());
|
|
371
102
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
await this?.alterTable?.({
|
|
375
|
-
tableName: TABLE_MESSAGES,
|
|
376
|
-
schema: TABLE_SCHEMAS[TABLE_MESSAGES],
|
|
377
|
-
ifNotExists: ["resourceId"]
|
|
378
|
-
});
|
|
379
|
-
await this?.alterTable?.({
|
|
380
|
-
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
381
|
-
schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT],
|
|
382
|
-
ifNotExists: ["resourceId"]
|
|
383
|
-
});
|
|
384
|
-
await this?.alterTable?.({
|
|
385
|
-
tableName: TABLE_SCORERS,
|
|
386
|
-
schema: TABLE_SCHEMAS[TABLE_SCORERS],
|
|
387
|
-
ifNotExists: ["spanId", "requestContext"]
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
async persistWorkflowSnapshot({
|
|
391
|
-
workflowName,
|
|
392
|
-
runId,
|
|
393
|
-
resourceId,
|
|
394
|
-
snapshot
|
|
395
|
-
}) {
|
|
396
|
-
await this.init();
|
|
397
|
-
const data = {
|
|
398
|
-
workflow_name: workflowName,
|
|
399
|
-
run_id: runId,
|
|
400
|
-
resourceId,
|
|
401
|
-
snapshot,
|
|
402
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
403
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
404
|
-
};
|
|
405
|
-
this.logger.debug("Persisting workflow snapshot", { workflowName, runId, data });
|
|
406
|
-
await this.insert({
|
|
407
|
-
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
408
|
-
record: data
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
async loadWorkflowSnapshot({
|
|
412
|
-
workflowName,
|
|
413
|
-
runId
|
|
414
|
-
}) {
|
|
415
|
-
if (!this.hasInitialized) {
|
|
416
|
-
await this.init();
|
|
103
|
+
if (this.stores?.workflows) {
|
|
104
|
+
initTasks.push(this.stores.workflows.init());
|
|
417
105
|
}
|
|
418
|
-
this.
|
|
419
|
-
|
|
420
|
-
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
421
|
-
keys: { workflow_name: workflowName, run_id: runId }
|
|
422
|
-
});
|
|
423
|
-
return d ? d.snapshot : null;
|
|
424
|
-
}
|
|
425
|
-
async listScoresBySpan({
|
|
426
|
-
traceId,
|
|
427
|
-
spanId,
|
|
428
|
-
pagination: _pagination
|
|
429
|
-
}) {
|
|
430
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
431
|
-
id: "SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED",
|
|
432
|
-
domain: "STORAGE" /* STORAGE */,
|
|
433
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
434
|
-
details: { traceId, spanId }
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* OBSERVABILITY
|
|
439
|
-
*/
|
|
440
|
-
/**
|
|
441
|
-
* Provides hints for tracing strategy selection by the DefaultExporter.
|
|
442
|
-
* Storage adapters can override this to specify their preferred and supported strategies.
|
|
443
|
-
*/
|
|
444
|
-
get tracingStrategy() {
|
|
445
|
-
if (this.stores?.observability) {
|
|
446
|
-
return this.stores.observability.tracingStrategy;
|
|
106
|
+
if (this.stores?.scores) {
|
|
107
|
+
initTasks.push(this.stores.scores.init());
|
|
447
108
|
}
|
|
448
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
449
|
-
id: "MASTRA_STORAGE_TRACING_STRATEGY_NOT_SUPPORTED",
|
|
450
|
-
domain: "STORAGE" /* STORAGE */,
|
|
451
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
452
|
-
text: `tracing is not supported by this storage adapter (${this.constructor.name})`
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Creates a single Span record in the storage provider.
|
|
457
|
-
*/
|
|
458
|
-
async createSpan(span) {
|
|
459
109
|
if (this.stores?.observability) {
|
|
460
|
-
|
|
110
|
+
initTasks.push(this.stores.observability.init());
|
|
461
111
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
domain: "STORAGE" /* STORAGE */,
|
|
465
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
466
|
-
text: `tracing is not supported by this storage adapter (${this.constructor.name})`
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
/**
|
|
470
|
-
* Updates a single Span with partial data. Primarily used for realtime trace creation.
|
|
471
|
-
*/
|
|
472
|
-
async updateSpan(params) {
|
|
473
|
-
if (this.stores?.observability) {
|
|
474
|
-
return this.stores.observability.updateSpan(params);
|
|
112
|
+
if (this.stores?.agents) {
|
|
113
|
+
initTasks.push(this.stores.agents.init());
|
|
475
114
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
domain: "STORAGE" /* STORAGE */,
|
|
479
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
480
|
-
text: `tracing is not supported by this storage adapter (${this.constructor.name})`
|
|
481
|
-
});
|
|
115
|
+
this.hasInitialized = Promise.all(initTasks).then(() => true);
|
|
116
|
+
await this.hasInitialized;
|
|
482
117
|
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/storage/domains/base.ts
|
|
121
|
+
var StorageDomain = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
483
122
|
/**
|
|
484
|
-
*
|
|
123
|
+
* Initialize the storage domain.
|
|
124
|
+
* This should create any necessary tables/collections.
|
|
125
|
+
* Default implementation is a no-op - override in adapters that need initialization.
|
|
485
126
|
*/
|
|
486
|
-
async
|
|
487
|
-
if (this.stores?.observability) {
|
|
488
|
-
return this.stores.observability.getTrace(traceId);
|
|
489
|
-
}
|
|
490
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
491
|
-
id: "MASTRA_STORAGE_GET_TRACE_NOT_SUPPORTED",
|
|
492
|
-
domain: "STORAGE" /* STORAGE */,
|
|
493
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
494
|
-
text: `tracing is not supported by this storage adapter (${this.constructor.name})`
|
|
495
|
-
});
|
|
127
|
+
async init() {
|
|
496
128
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
id: "MASTRA_STORAGE_GET_TRACES_PAGINATED_NOT_SUPPORTED",
|
|
506
|
-
domain: "STORAGE" /* STORAGE */,
|
|
507
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
508
|
-
text: `tracing is not supported by this storage adapter (${this.constructor.name})`
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// src/storage/domains/agents/base.ts
|
|
132
|
+
var AgentsStorage = class extends StorageDomain {
|
|
133
|
+
constructor() {
|
|
134
|
+
super({
|
|
135
|
+
component: "STORAGE",
|
|
136
|
+
name: "AGENTS"
|
|
509
137
|
});
|
|
510
138
|
}
|
|
511
139
|
/**
|
|
512
|
-
*
|
|
140
|
+
* Parses orderBy input for consistent sorting behavior.
|
|
513
141
|
*/
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
id: "MASTRA_STORAGE_BATCH_CREATE_AI_SPANS_NOT_SUPPORTED",
|
|
520
|
-
domain: "STORAGE" /* STORAGE */,
|
|
521
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
522
|
-
text: `tracing is not supported by this storage adapter (${this.constructor.name})`
|
|
523
|
-
});
|
|
142
|
+
parseOrderBy(orderBy, defaultDirection = "DESC") {
|
|
143
|
+
return {
|
|
144
|
+
field: orderBy?.field && orderBy.field in AGENT_ORDER_BY_SET ? orderBy.field : "createdAt",
|
|
145
|
+
direction: orderBy?.direction && orderBy.direction in AGENT_SORT_DIRECTION_SET ? orderBy.direction : defaultDirection
|
|
146
|
+
};
|
|
524
147
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
148
|
+
};
|
|
149
|
+
var AGENT_ORDER_BY_SET = {
|
|
150
|
+
createdAt: true,
|
|
151
|
+
updatedAt: true
|
|
152
|
+
};
|
|
153
|
+
var AGENT_SORT_DIRECTION_SET = {
|
|
154
|
+
ASC: true,
|
|
155
|
+
DESC: true
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// src/storage/domains/agents/inmemory.ts
|
|
159
|
+
var InMemoryAgentsStorage = class extends AgentsStorage {
|
|
160
|
+
db;
|
|
161
|
+
constructor({ db }) {
|
|
162
|
+
super();
|
|
163
|
+
this.db = db;
|
|
538
164
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
*/
|
|
542
|
-
async batchDeleteTraces(args) {
|
|
543
|
-
if (this.stores?.observability) {
|
|
544
|
-
return this.stores.observability.batchDeleteTraces(args);
|
|
545
|
-
}
|
|
546
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
547
|
-
id: "MASTRA_STORAGE_BATCH_DELETE_TRACES_NOT_SUPPORTED",
|
|
548
|
-
domain: "STORAGE" /* STORAGE */,
|
|
549
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
550
|
-
text: `tracing is not supported by this storage adapter (${this.constructor.name})`
|
|
551
|
-
});
|
|
165
|
+
async dangerouslyClearAll() {
|
|
166
|
+
this.db.agents.clear();
|
|
552
167
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
}
|
|
566
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
567
|
-
id: "MASTRA_STORAGE_CREATE_INDEX_NOT_SUPPORTED",
|
|
568
|
-
domain: "STORAGE" /* STORAGE */,
|
|
569
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
570
|
-
text: `Index management is not supported by this storage adapter (${this.constructor.name})`
|
|
571
|
-
});
|
|
168
|
+
async getAgentById({ id }) {
|
|
169
|
+
this.logger.debug(`InMemoryAgentsStorage: getAgentById called for ${id}`);
|
|
170
|
+
const agent = this.db.agents.get(id);
|
|
171
|
+
return agent ? {
|
|
172
|
+
...agent,
|
|
173
|
+
metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
|
|
174
|
+
model: { ...agent.model },
|
|
175
|
+
tools: agent.tools ? [...agent.tools] : agent.tools,
|
|
176
|
+
workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
|
|
177
|
+
agents: agent.agents ? [...agent.agents] : agent.agents,
|
|
178
|
+
scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
|
|
179
|
+
} : null;
|
|
572
180
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
async dropIndex(indexName) {
|
|
578
|
-
if (this.stores?.operations) {
|
|
579
|
-
return this.stores.operations.dropIndex(indexName);
|
|
181
|
+
async createAgent({ agent }) {
|
|
182
|
+
this.logger.debug(`InMemoryAgentsStorage: createAgent called for ${agent.id}`);
|
|
183
|
+
if (this.db.agents.has(agent.id)) {
|
|
184
|
+
throw new Error(`Agent with id ${agent.id} already exists`);
|
|
580
185
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
}
|
|
186
|
+
const now = /* @__PURE__ */ new Date();
|
|
187
|
+
const newAgent = {
|
|
188
|
+
...agent,
|
|
189
|
+
createdAt: now,
|
|
190
|
+
updatedAt: now
|
|
191
|
+
};
|
|
192
|
+
this.db.agents.set(agent.id, newAgent);
|
|
193
|
+
return { ...newAgent };
|
|
587
194
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
if (this.stores?.operations) {
|
|
594
|
-
return this.stores.operations.listIndexes(tableName);
|
|
595
|
-
}
|
|
596
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
597
|
-
id: "MASTRA_STORAGE_LIST_INDEXES_NOT_SUPPORTED",
|
|
598
|
-
domain: "STORAGE" /* STORAGE */,
|
|
599
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
600
|
-
text: `Index management is not supported by this storage adapter (${this.constructor.name})`
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
/**
|
|
604
|
-
* Gets detailed statistics for a specific index
|
|
605
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
606
|
-
*/
|
|
607
|
-
async describeIndex(indexName) {
|
|
608
|
-
if (this.stores?.operations) {
|
|
609
|
-
return this.stores.operations.describeIndex(indexName);
|
|
610
|
-
}
|
|
611
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
612
|
-
id: "MASTRA_STORAGE_DESCRIBE_INDEX_NOT_SUPPORTED",
|
|
613
|
-
domain: "STORAGE" /* STORAGE */,
|
|
614
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
615
|
-
text: `Index management is not supported by this storage adapter (${this.constructor.name})`
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* AGENTS STORAGE
|
|
620
|
-
* These methods delegate to the agents store for agent CRUD operations.
|
|
621
|
-
* This enables dynamic creation of agents via Mastra Studio.
|
|
622
|
-
*/
|
|
623
|
-
/**
|
|
624
|
-
* Retrieves an agent by its unique identifier.
|
|
625
|
-
* @param id - The unique identifier of the agent
|
|
626
|
-
* @returns The agent if found, null otherwise
|
|
627
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
628
|
-
*/
|
|
629
|
-
async getAgentById({ id }) {
|
|
630
|
-
if (this.stores?.agents) {
|
|
631
|
-
return this.stores.agents.getAgentById({ id });
|
|
632
|
-
}
|
|
633
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
634
|
-
id: "MASTRA_STORAGE_GET_AGENT_BY_ID_NOT_SUPPORTED",
|
|
635
|
-
domain: "STORAGE" /* STORAGE */,
|
|
636
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
637
|
-
text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Creates a new agent in storage.
|
|
642
|
-
* @param agent - The agent data to create
|
|
643
|
-
* @returns The created agent with timestamps
|
|
644
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
645
|
-
*/
|
|
646
|
-
async createAgent({ agent }) {
|
|
647
|
-
if (this.stores?.agents) {
|
|
648
|
-
return this.stores.agents.createAgent({ agent });
|
|
649
|
-
}
|
|
650
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
651
|
-
id: "MASTRA_STORAGE_CREATE_AGENT_NOT_SUPPORTED",
|
|
652
|
-
domain: "STORAGE" /* STORAGE */,
|
|
653
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
654
|
-
text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Updates an existing agent in storage.
|
|
659
|
-
* @param id - The unique identifier of the agent to update
|
|
660
|
-
* @param updates - The fields to update
|
|
661
|
-
* @returns The updated agent
|
|
662
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
663
|
-
*/
|
|
664
|
-
async updateAgent(args) {
|
|
665
|
-
if (this.stores?.agents) {
|
|
666
|
-
return this.stores.agents.updateAgent(args);
|
|
667
|
-
}
|
|
668
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
669
|
-
id: "MASTRA_STORAGE_UPDATE_AGENT_NOT_SUPPORTED",
|
|
670
|
-
domain: "STORAGE" /* STORAGE */,
|
|
671
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
672
|
-
text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Deletes an agent from storage.
|
|
677
|
-
* @param id - The unique identifier of the agent to delete
|
|
678
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
679
|
-
*/
|
|
680
|
-
async deleteAgent({ id }) {
|
|
681
|
-
if (this.stores?.agents) {
|
|
682
|
-
return this.stores.agents.deleteAgent({ id });
|
|
683
|
-
}
|
|
684
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
685
|
-
id: "MASTRA_STORAGE_DELETE_AGENT_NOT_SUPPORTED",
|
|
686
|
-
domain: "STORAGE" /* STORAGE */,
|
|
687
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
688
|
-
text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
/**
|
|
692
|
-
* Lists all agents with optional pagination.
|
|
693
|
-
* @param args - Pagination and ordering options
|
|
694
|
-
* @returns Paginated list of agents
|
|
695
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
696
|
-
*/
|
|
697
|
-
async listAgents(args) {
|
|
698
|
-
if (this.stores?.agents) {
|
|
699
|
-
return this.stores.agents.listAgents(args);
|
|
700
|
-
}
|
|
701
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
702
|
-
id: "MASTRA_STORAGE_LIST_AGENTS_NOT_SUPPORTED",
|
|
703
|
-
domain: "STORAGE" /* STORAGE */,
|
|
704
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
705
|
-
text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
|
|
706
|
-
});
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
// src/storage/domains/agents/base.ts
|
|
711
|
-
var AgentsStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
712
|
-
constructor() {
|
|
713
|
-
super({
|
|
714
|
-
component: "STORAGE",
|
|
715
|
-
name: "AGENTS"
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Parses orderBy input for consistent sorting behavior.
|
|
720
|
-
*/
|
|
721
|
-
parseOrderBy(orderBy, defaultDirection = "DESC") {
|
|
722
|
-
return {
|
|
723
|
-
field: orderBy?.field && orderBy.field in AGENT_ORDER_BY_SET ? orderBy.field : "createdAt",
|
|
724
|
-
direction: orderBy?.direction && orderBy.direction in AGENT_SORT_DIRECTION_SET ? orderBy.direction : defaultDirection
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
var AGENT_ORDER_BY_SET = {
|
|
729
|
-
createdAt: true,
|
|
730
|
-
updatedAt: true
|
|
731
|
-
};
|
|
732
|
-
var AGENT_SORT_DIRECTION_SET = {
|
|
733
|
-
ASC: true,
|
|
734
|
-
DESC: true
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
// src/storage/domains/agents/inmemory.ts
|
|
738
|
-
var InMemoryAgentsStorage = class extends AgentsStorage {
|
|
739
|
-
collection;
|
|
740
|
-
constructor({ collection }) {
|
|
741
|
-
super();
|
|
742
|
-
this.collection = collection;
|
|
743
|
-
}
|
|
744
|
-
async getAgentById({ id }) {
|
|
745
|
-
this.logger.debug(`InMemoryAgentsStorage: getAgentById called for ${id}`);
|
|
746
|
-
const agent = this.collection.get(id);
|
|
747
|
-
return agent ? {
|
|
748
|
-
...agent,
|
|
749
|
-
metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
|
|
750
|
-
model: { ...agent.model },
|
|
751
|
-
tools: agent.tools ? [...agent.tools] : agent.tools,
|
|
752
|
-
workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
|
|
753
|
-
agents: agent.agents ? [...agent.agents] : agent.agents,
|
|
754
|
-
scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
|
|
755
|
-
} : null;
|
|
756
|
-
}
|
|
757
|
-
async createAgent({ agent }) {
|
|
758
|
-
this.logger.debug(`InMemoryAgentsStorage: createAgent called for ${agent.id}`);
|
|
759
|
-
if (this.collection.has(agent.id)) {
|
|
760
|
-
throw new Error(`Agent with id ${agent.id} already exists`);
|
|
761
|
-
}
|
|
762
|
-
const now = /* @__PURE__ */ new Date();
|
|
763
|
-
const newAgent = {
|
|
764
|
-
...agent,
|
|
765
|
-
createdAt: now,
|
|
766
|
-
updatedAt: now
|
|
767
|
-
};
|
|
768
|
-
this.collection.set(agent.id, newAgent);
|
|
769
|
-
return { ...newAgent };
|
|
770
|
-
}
|
|
771
|
-
async updateAgent({ id, ...updates }) {
|
|
772
|
-
this.logger.debug(`InMemoryAgentsStorage: updateAgent called for ${id}`);
|
|
773
|
-
const existingAgent = this.collection.get(id);
|
|
774
|
-
if (!existingAgent) {
|
|
775
|
-
throw new Error(`Agent with id ${id} not found`);
|
|
195
|
+
async updateAgent({ id, ...updates }) {
|
|
196
|
+
this.logger.debug(`InMemoryAgentsStorage: updateAgent called for ${id}`);
|
|
197
|
+
const existingAgent = this.db.agents.get(id);
|
|
198
|
+
if (!existingAgent) {
|
|
199
|
+
throw new Error(`Agent with id ${id} not found`);
|
|
776
200
|
}
|
|
777
201
|
const updatedAgent = {
|
|
778
202
|
...existingAgent,
|
|
@@ -795,12 +219,12 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
|
|
|
795
219
|
},
|
|
796
220
|
updatedAt: /* @__PURE__ */ new Date()
|
|
797
221
|
};
|
|
798
|
-
this.
|
|
222
|
+
this.db.agents.set(id, updatedAgent);
|
|
799
223
|
return { ...updatedAgent };
|
|
800
224
|
}
|
|
801
225
|
async deleteAgent({ id }) {
|
|
802
226
|
this.logger.debug(`InMemoryAgentsStorage: deleteAgent called for ${id}`);
|
|
803
|
-
this.
|
|
227
|
+
this.db.agents.delete(id);
|
|
804
228
|
}
|
|
805
229
|
async listAgents(args) {
|
|
806
230
|
const { page = 0, perPage: perPageInput, orderBy } = args || {};
|
|
@@ -814,7 +238,7 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
|
|
|
814
238
|
if (page * perPage > maxOffset) {
|
|
815
239
|
throw new Error("page value too large");
|
|
816
240
|
}
|
|
817
|
-
const agents = Array.from(this.
|
|
241
|
+
const agents = Array.from(this.db.agents.values());
|
|
818
242
|
const sortedAgents = this.sortAgents(agents, field, direction);
|
|
819
243
|
const clonedAgents = sortedAgents.map((agent) => ({
|
|
820
244
|
...agent,
|
|
@@ -843,6 +267,30 @@ var InMemoryAgentsStorage = class extends AgentsStorage {
|
|
|
843
267
|
}
|
|
844
268
|
};
|
|
845
269
|
|
|
270
|
+
// src/storage/domains/inmemory-db.ts
|
|
271
|
+
var InMemoryDB = class {
|
|
272
|
+
threads = /* @__PURE__ */ new Map();
|
|
273
|
+
messages = /* @__PURE__ */ new Map();
|
|
274
|
+
resources = /* @__PURE__ */ new Map();
|
|
275
|
+
workflows = /* @__PURE__ */ new Map();
|
|
276
|
+
scores = /* @__PURE__ */ new Map();
|
|
277
|
+
traces = /* @__PURE__ */ new Map();
|
|
278
|
+
agents = /* @__PURE__ */ new Map();
|
|
279
|
+
/**
|
|
280
|
+
* Clears all data from all collections.
|
|
281
|
+
* Useful for testing.
|
|
282
|
+
*/
|
|
283
|
+
clear() {
|
|
284
|
+
this.threads.clear();
|
|
285
|
+
this.messages.clear();
|
|
286
|
+
this.resources.clear();
|
|
287
|
+
this.workflows.clear();
|
|
288
|
+
this.scores.clear();
|
|
289
|
+
this.traces.clear();
|
|
290
|
+
this.agents.clear();
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
846
294
|
// src/storage/utils.ts
|
|
847
295
|
function safelyParseJSON(input) {
|
|
848
296
|
if (input && typeof input === "object") return input;
|
|
@@ -858,7 +306,7 @@ function safelyParseJSON(input) {
|
|
|
858
306
|
}
|
|
859
307
|
function transformRow(row, tableName, options = {}) {
|
|
860
308
|
const { preferredTimestampFields = {}, convertTimestamps = false, nullValuePattern, fieldMappings = {} } = options;
|
|
861
|
-
const tableSchema = TABLE_SCHEMAS[tableName];
|
|
309
|
+
const tableSchema = chunkCBVHOGXX_cjs.TABLE_SCHEMAS[tableName];
|
|
862
310
|
const result = {};
|
|
863
311
|
for (const [key, columnSchema] of Object.entries(tableSchema)) {
|
|
864
312
|
const sourceKey = fieldMappings[key] ?? key;
|
|
@@ -889,7 +337,7 @@ function transformRow(row, tableName, options = {}) {
|
|
|
889
337
|
return result;
|
|
890
338
|
}
|
|
891
339
|
function transformScoreRow(row, options = {}) {
|
|
892
|
-
return transformRow(row, TABLE_SCORERS, options);
|
|
340
|
+
return transformRow(row, chunkCBVHOGXX_cjs.TABLE_SCORERS, options);
|
|
893
341
|
}
|
|
894
342
|
function toUpperSnakeCase(str) {
|
|
895
343
|
return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -907,9 +355,57 @@ function createStorageErrorId(store, operation, status) {
|
|
|
907
355
|
function createVectorErrorId(store, operation, status) {
|
|
908
356
|
return createStoreErrorId("vector", store, operation, status);
|
|
909
357
|
}
|
|
358
|
+
function getSqlType(type) {
|
|
359
|
+
switch (type) {
|
|
360
|
+
case "text":
|
|
361
|
+
return "TEXT";
|
|
362
|
+
case "timestamp":
|
|
363
|
+
return "TIMESTAMP";
|
|
364
|
+
case "float":
|
|
365
|
+
return "FLOAT";
|
|
366
|
+
case "integer":
|
|
367
|
+
return "INTEGER";
|
|
368
|
+
case "bigint":
|
|
369
|
+
return "BIGINT";
|
|
370
|
+
case "jsonb":
|
|
371
|
+
return "JSONB";
|
|
372
|
+
case "boolean":
|
|
373
|
+
return "BOOLEAN";
|
|
374
|
+
default:
|
|
375
|
+
return "TEXT";
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
function getDefaultValue(type) {
|
|
379
|
+
switch (type) {
|
|
380
|
+
case "text":
|
|
381
|
+
case "uuid":
|
|
382
|
+
return "DEFAULT ''";
|
|
383
|
+
case "timestamp":
|
|
384
|
+
return "DEFAULT '1970-01-01 00:00:00'";
|
|
385
|
+
case "integer":
|
|
386
|
+
case "bigint":
|
|
387
|
+
case "float":
|
|
388
|
+
return "DEFAULT 0";
|
|
389
|
+
case "jsonb":
|
|
390
|
+
return "DEFAULT '{}'";
|
|
391
|
+
case "boolean":
|
|
392
|
+
return "DEFAULT FALSE";
|
|
393
|
+
default:
|
|
394
|
+
return "DEFAULT ''";
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function ensureDate(date) {
|
|
398
|
+
if (!date) return void 0;
|
|
399
|
+
return date instanceof Date ? date : new Date(date);
|
|
400
|
+
}
|
|
401
|
+
function serializeDate(date) {
|
|
402
|
+
if (!date) return void 0;
|
|
403
|
+
const dateObj = ensureDate(date);
|
|
404
|
+
return dateObj?.toISOString();
|
|
405
|
+
}
|
|
910
406
|
|
|
911
407
|
// src/storage/domains/memory/base.ts
|
|
912
|
-
var MemoryStorage = class extends
|
|
408
|
+
var MemoryStorage = class extends StorageDomain {
|
|
913
409
|
constructor() {
|
|
914
410
|
super({
|
|
915
411
|
component: "STORAGE",
|
|
@@ -954,25 +450,25 @@ var THREAD_THREAD_SORT_DIRECTION_SET = {
|
|
|
954
450
|
|
|
955
451
|
// src/storage/domains/memory/inmemory.ts
|
|
956
452
|
var InMemoryMemory = class extends MemoryStorage {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
constructor({
|
|
960
|
-
collection,
|
|
961
|
-
operations
|
|
962
|
-
}) {
|
|
453
|
+
db;
|
|
454
|
+
constructor({ db }) {
|
|
963
455
|
super();
|
|
964
|
-
this.
|
|
965
|
-
|
|
456
|
+
this.db = db;
|
|
457
|
+
}
|
|
458
|
+
async dangerouslyClearAll() {
|
|
459
|
+
this.db.threads.clear();
|
|
460
|
+
this.db.messages.clear();
|
|
461
|
+
this.db.resources.clear();
|
|
966
462
|
}
|
|
967
463
|
async getThreadById({ threadId }) {
|
|
968
|
-
this.logger.debug(`
|
|
969
|
-
const thread = this.
|
|
464
|
+
this.logger.debug(`InMemoryMemory: getThreadById called for ${threadId}`);
|
|
465
|
+
const thread = this.db.threads.get(threadId);
|
|
970
466
|
return thread ? { ...thread, metadata: thread.metadata ? { ...thread.metadata } : thread.metadata } : null;
|
|
971
467
|
}
|
|
972
468
|
async saveThread({ thread }) {
|
|
973
|
-
this.logger.debug(`
|
|
469
|
+
this.logger.debug(`InMemoryMemory: saveThread called for ${thread.id}`);
|
|
974
470
|
const key = thread.id;
|
|
975
|
-
this.
|
|
471
|
+
this.db.threads.set(key, thread);
|
|
976
472
|
return thread;
|
|
977
473
|
}
|
|
978
474
|
async updateThread({
|
|
@@ -980,8 +476,8 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
980
476
|
title,
|
|
981
477
|
metadata
|
|
982
478
|
}) {
|
|
983
|
-
this.logger.debug(`
|
|
984
|
-
const thread = this.
|
|
479
|
+
this.logger.debug(`InMemoryMemory: updateThread called for ${id}`);
|
|
480
|
+
const thread = this.db.threads.get(id);
|
|
985
481
|
if (!thread) {
|
|
986
482
|
throw new Error(`Thread with id ${id} not found`);
|
|
987
483
|
}
|
|
@@ -993,11 +489,11 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
993
489
|
return thread;
|
|
994
490
|
}
|
|
995
491
|
async deleteThread({ threadId }) {
|
|
996
|
-
this.logger.debug(`
|
|
997
|
-
this.
|
|
998
|
-
this.
|
|
492
|
+
this.logger.debug(`InMemoryMemory: deleteThread called for ${threadId}`);
|
|
493
|
+
this.db.threads.delete(threadId);
|
|
494
|
+
this.db.messages.forEach((msg, key) => {
|
|
999
495
|
if (msg.thread_id === threadId) {
|
|
1000
|
-
this.
|
|
496
|
+
this.db.messages.delete(key);
|
|
1001
497
|
}
|
|
1002
498
|
});
|
|
1003
499
|
}
|
|
@@ -1011,7 +507,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1011
507
|
orderBy
|
|
1012
508
|
}) {
|
|
1013
509
|
const threadIds = Array.isArray(threadId) ? threadId : [threadId];
|
|
1014
|
-
this.logger.debug(`
|
|
510
|
+
this.logger.debug(`InMemoryMemory: listMessages called for threads ${threadIds.join(", ")}`);
|
|
1015
511
|
if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
|
|
1016
512
|
throw new Error("threadId must be a non-empty string or array of non-empty strings");
|
|
1017
513
|
}
|
|
@@ -1026,7 +522,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1026
522
|
throw new Error("page value too large");
|
|
1027
523
|
}
|
|
1028
524
|
const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
1029
|
-
let threadMessages = Array.from(this.
|
|
525
|
+
let threadMessages = Array.from(this.db.messages.values()).filter((msg) => {
|
|
1030
526
|
if (!threadIdSet.has(msg.thread_id)) return false;
|
|
1031
527
|
if (resourceId && msg.resourceId !== resourceId) return false;
|
|
1032
528
|
return true;
|
|
@@ -1064,7 +560,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1064
560
|
}
|
|
1065
561
|
if (include && include.length > 0) {
|
|
1066
562
|
for (const includeItem of include) {
|
|
1067
|
-
const targetMessage = this.
|
|
563
|
+
const targetMessage = this.db.messages.get(includeItem.id);
|
|
1068
564
|
if (targetMessage) {
|
|
1069
565
|
const convertedMessage = {
|
|
1070
566
|
id: targetMessage.id,
|
|
@@ -1080,7 +576,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1080
576
|
messageIds.add(convertedMessage.id);
|
|
1081
577
|
}
|
|
1082
578
|
if (includeItem.withPreviousMessages) {
|
|
1083
|
-
const allThreadMessages = Array.from(this.
|
|
579
|
+
const allThreadMessages = Array.from(this.db.messages.values()).filter((msg) => msg.thread_id === (includeItem.threadId || threadId)).sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
1084
580
|
const targetIndex = allThreadMessages.findIndex((msg) => msg.id === includeItem.id);
|
|
1085
581
|
if (targetIndex !== -1) {
|
|
1086
582
|
const startIndex = Math.max(0, targetIndex - (includeItem.withPreviousMessages || 0));
|
|
@@ -1103,7 +599,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1103
599
|
}
|
|
1104
600
|
}
|
|
1105
601
|
if (includeItem.withNextMessages) {
|
|
1106
|
-
const allThreadMessages = Array.from(this.
|
|
602
|
+
const allThreadMessages = Array.from(this.db.messages.values()).filter((msg) => msg.thread_id === (includeItem.threadId || threadId)).sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
1107
603
|
const targetIndex = allThreadMessages.findIndex((msg) => msg.id === includeItem.id);
|
|
1108
604
|
if (targetIndex !== -1) {
|
|
1109
605
|
const endIndex = Math.min(
|
|
@@ -1174,20 +670,23 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1174
670
|
};
|
|
1175
671
|
}
|
|
1176
672
|
async listMessagesById({ messageIds }) {
|
|
1177
|
-
this.logger.debug(`
|
|
1178
|
-
const rawMessages = messageIds.map((id) => this.
|
|
1179
|
-
const list = new
|
|
673
|
+
this.logger.debug(`InMemoryMemory: listMessagesById called`);
|
|
674
|
+
const rawMessages = messageIds.map((id) => this.db.messages.get(id)).filter((message) => !!message);
|
|
675
|
+
const list = new chunkEMLEZXTQ_cjs.MessageList().add(
|
|
676
|
+
rawMessages.map((m) => this.parseStoredMessage(m)),
|
|
677
|
+
"memory"
|
|
678
|
+
);
|
|
1180
679
|
return { messages: list.get.all.db() };
|
|
1181
680
|
}
|
|
1182
681
|
async saveMessages(args) {
|
|
1183
682
|
const { messages } = args;
|
|
1184
|
-
this.logger.debug(`
|
|
683
|
+
this.logger.debug(`InMemoryMemory: saveMessages called with ${messages.length} messages`);
|
|
1185
684
|
if (messages.some((msg) => msg.id === "error-message" || msg.resourceId === null)) {
|
|
1186
685
|
throw new Error("Simulated error for testing");
|
|
1187
686
|
}
|
|
1188
687
|
const threadIds = new Set(messages.map((msg) => msg.threadId).filter((id) => Boolean(id)));
|
|
1189
688
|
for (const threadId of threadIds) {
|
|
1190
|
-
const thread = this.
|
|
689
|
+
const thread = this.db.threads.get(threadId);
|
|
1191
690
|
if (thread) {
|
|
1192
691
|
thread.updatedAt = /* @__PURE__ */ new Date();
|
|
1193
692
|
}
|
|
@@ -1203,15 +702,15 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1203
702
|
createdAt: message.createdAt,
|
|
1204
703
|
resourceId: message.resourceId || null
|
|
1205
704
|
};
|
|
1206
|
-
this.
|
|
705
|
+
this.db.messages.set(key, storageMessage);
|
|
1207
706
|
}
|
|
1208
|
-
const list = new
|
|
707
|
+
const list = new chunkEMLEZXTQ_cjs.MessageList().add(messages, "memory");
|
|
1209
708
|
return { messages: list.get.all.db() };
|
|
1210
709
|
}
|
|
1211
710
|
async updateMessages(args) {
|
|
1212
711
|
const updatedMessages = [];
|
|
1213
712
|
for (const update of args.messages) {
|
|
1214
|
-
const storageMsg = this.
|
|
713
|
+
const storageMsg = this.db.messages.get(update.id);
|
|
1215
714
|
if (!storageMsg) continue;
|
|
1216
715
|
const oldThreadId = storageMsg.thread_id;
|
|
1217
716
|
const newThreadId = update.threadId || oldThreadId;
|
|
@@ -1238,13 +737,13 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1238
737
|
storageMsg.thread_id = newThreadId;
|
|
1239
738
|
const base = Date.now();
|
|
1240
739
|
let oldThreadNewTime;
|
|
1241
|
-
const oldThread = this.
|
|
740
|
+
const oldThread = this.db.threads.get(oldThreadId);
|
|
1242
741
|
if (oldThread) {
|
|
1243
742
|
const prev = new Date(oldThread.updatedAt).getTime();
|
|
1244
743
|
oldThreadNewTime = Math.max(base, prev + 1);
|
|
1245
744
|
oldThread.updatedAt = new Date(oldThreadNewTime);
|
|
1246
745
|
}
|
|
1247
|
-
const newThread = this.
|
|
746
|
+
const newThread = this.db.threads.get(newThreadId);
|
|
1248
747
|
if (newThread) {
|
|
1249
748
|
const prev = new Date(newThread.updatedAt).getTime();
|
|
1250
749
|
let newThreadNewTime = Math.max(base + 1, prev + 1);
|
|
@@ -1254,7 +753,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1254
753
|
newThread.updatedAt = new Date(newThreadNewTime);
|
|
1255
754
|
}
|
|
1256
755
|
} else {
|
|
1257
|
-
const thread = this.
|
|
756
|
+
const thread = this.db.threads.get(oldThreadId);
|
|
1258
757
|
if (thread) {
|
|
1259
758
|
const prev = new Date(thread.updatedAt).getTime();
|
|
1260
759
|
let newTime = Date.now();
|
|
@@ -1262,7 +761,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1262
761
|
thread.updatedAt = new Date(newTime);
|
|
1263
762
|
}
|
|
1264
763
|
}
|
|
1265
|
-
this.
|
|
764
|
+
this.db.messages.set(update.id, storageMsg);
|
|
1266
765
|
updatedMessages.push({
|
|
1267
766
|
id: storageMsg.id,
|
|
1268
767
|
threadId: storageMsg.thread_id,
|
|
@@ -1279,18 +778,18 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1279
778
|
if (!messageIds || messageIds.length === 0) {
|
|
1280
779
|
return;
|
|
1281
780
|
}
|
|
1282
|
-
this.logger.debug(`
|
|
781
|
+
this.logger.debug(`InMemoryMemory: deleteMessages called for ${messageIds.length} messages`);
|
|
1283
782
|
const threadIds = /* @__PURE__ */ new Set();
|
|
1284
783
|
for (const messageId of messageIds) {
|
|
1285
|
-
const message = this.
|
|
784
|
+
const message = this.db.messages.get(messageId);
|
|
1286
785
|
if (message && message.thread_id) {
|
|
1287
786
|
threadIds.add(message.thread_id);
|
|
1288
787
|
}
|
|
1289
|
-
this.
|
|
788
|
+
this.db.messages.delete(messageId);
|
|
1290
789
|
}
|
|
1291
790
|
const now = /* @__PURE__ */ new Date();
|
|
1292
791
|
for (const threadId of threadIds) {
|
|
1293
|
-
const thread = this.
|
|
792
|
+
const thread = this.db.threads.get(threadId);
|
|
1294
793
|
if (thread) {
|
|
1295
794
|
thread.updatedAt = now;
|
|
1296
795
|
}
|
|
@@ -1307,8 +806,8 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1307
806
|
if (page * perPage > maxOffset) {
|
|
1308
807
|
throw new Error("page value too large");
|
|
1309
808
|
}
|
|
1310
|
-
this.logger.debug(`
|
|
1311
|
-
const threads = Array.from(this.
|
|
809
|
+
this.logger.debug(`InMemoryMemory: listThreadsByResourceId called for ${resourceId}`);
|
|
810
|
+
const threads = Array.from(this.db.threads.values()).filter((t) => t.resourceId === resourceId);
|
|
1312
811
|
const sortedThreads = this.sortThreads(threads, field, direction);
|
|
1313
812
|
const clonedThreads = sortedThreads.map((thread) => ({
|
|
1314
813
|
...thread,
|
|
@@ -1324,13 +823,13 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1324
823
|
};
|
|
1325
824
|
}
|
|
1326
825
|
async getResourceById({ resourceId }) {
|
|
1327
|
-
this.logger.debug(`
|
|
1328
|
-
const resource = this.
|
|
826
|
+
this.logger.debug(`InMemoryMemory: getResourceById called for ${resourceId}`);
|
|
827
|
+
const resource = this.db.resources.get(resourceId);
|
|
1329
828
|
return resource ? { ...resource, metadata: resource.metadata ? { ...resource.metadata } : resource.metadata } : null;
|
|
1330
829
|
}
|
|
1331
830
|
async saveResource({ resource }) {
|
|
1332
|
-
this.logger.debug(`
|
|
1333
|
-
this.
|
|
831
|
+
this.logger.debug(`InMemoryMemory: saveResource called for ${resource.id}`);
|
|
832
|
+
this.db.resources.set(resource.id, resource);
|
|
1334
833
|
return resource;
|
|
1335
834
|
}
|
|
1336
835
|
async updateResource({
|
|
@@ -1338,8 +837,8 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1338
837
|
workingMemory,
|
|
1339
838
|
metadata
|
|
1340
839
|
}) {
|
|
1341
|
-
this.logger.debug(`
|
|
1342
|
-
let resource = this.
|
|
840
|
+
this.logger.debug(`InMemoryMemory: updateResource called for ${resourceId}`);
|
|
841
|
+
let resource = this.db.resources.get(resourceId);
|
|
1343
842
|
if (!resource) {
|
|
1344
843
|
resource = {
|
|
1345
844
|
id: resourceId,
|
|
@@ -1359,7 +858,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1359
858
|
updatedAt: /* @__PURE__ */ new Date()
|
|
1360
859
|
};
|
|
1361
860
|
}
|
|
1362
|
-
this.
|
|
861
|
+
this.db.resources.set(resourceId, resource);
|
|
1363
862
|
return resource;
|
|
1364
863
|
}
|
|
1365
864
|
sortThreads(threads, field, direction) {
|
|
@@ -1380,13 +879,15 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
1380
879
|
};
|
|
1381
880
|
|
|
1382
881
|
// src/storage/domains/observability/base.ts
|
|
1383
|
-
var ObservabilityStorage = class extends
|
|
882
|
+
var ObservabilityStorage = class extends StorageDomain {
|
|
1384
883
|
constructor() {
|
|
1385
884
|
super({
|
|
1386
885
|
component: "STORAGE",
|
|
1387
886
|
name: "OBSERVABILITY"
|
|
1388
887
|
});
|
|
1389
888
|
}
|
|
889
|
+
async dangerouslyClearAll() {
|
|
890
|
+
}
|
|
1390
891
|
/**
|
|
1391
892
|
* Provides hints for tracing strategy selection by the DefaultExporter.
|
|
1392
893
|
* Storage adapters can override this to specify their preferred and supported strategies.
|
|
@@ -1401,8 +902,8 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
1401
902
|
/**
|
|
1402
903
|
* Creates a single Span record in the storage provider.
|
|
1403
904
|
*/
|
|
1404
|
-
createSpan(
|
|
1405
|
-
throw new
|
|
905
|
+
async createSpan(_args) {
|
|
906
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1406
907
|
id: "OBSERVABILITY_CREATE_SPAN_NOT_IMPLEMENTED",
|
|
1407
908
|
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1408
909
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -1412,19 +913,41 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
1412
913
|
/**
|
|
1413
914
|
* Updates a single Span with partial data. Primarily used for realtime trace creation.
|
|
1414
915
|
*/
|
|
1415
|
-
updateSpan(
|
|
1416
|
-
throw new
|
|
916
|
+
async updateSpan(_args) {
|
|
917
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1417
918
|
id: "OBSERVABILITY_STORAGE_UPDATE_SPAN_NOT_IMPLEMENTED",
|
|
1418
919
|
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1419
920
|
category: "SYSTEM" /* SYSTEM */,
|
|
1420
921
|
text: "This storage provider does not support updating spans"
|
|
1421
922
|
});
|
|
1422
923
|
}
|
|
924
|
+
/**
|
|
925
|
+
* Retrieves a single span.
|
|
926
|
+
*/
|
|
927
|
+
async getSpan(_args) {
|
|
928
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
929
|
+
id: "OBSERVABILITY_STORAGE_GET_SPAN_NOT_IMPLEMENTED",
|
|
930
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
931
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
932
|
+
text: "This storage provider does not support getting spans"
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Retrieves a single root span.
|
|
937
|
+
*/
|
|
938
|
+
async getRootSpan(_args) {
|
|
939
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
940
|
+
id: "OBSERVABILITY_STORAGE_GET_ROOT_SPAN_NOT_IMPLEMENTED",
|
|
941
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
942
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
943
|
+
text: "This storage provider does not support getting root spans"
|
|
944
|
+
});
|
|
945
|
+
}
|
|
1423
946
|
/**
|
|
1424
947
|
* Retrieves a single trace with all its associated spans.
|
|
1425
948
|
*/
|
|
1426
|
-
getTrace(
|
|
1427
|
-
throw new
|
|
949
|
+
async getTrace(_args) {
|
|
950
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1428
951
|
id: "OBSERVABILITY_STORAGE_GET_TRACE_NOT_IMPLEMENTED",
|
|
1429
952
|
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1430
953
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -1432,21 +955,21 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
1432
955
|
});
|
|
1433
956
|
}
|
|
1434
957
|
/**
|
|
1435
|
-
* Retrieves a
|
|
958
|
+
* Retrieves a list of traces with optional filtering.
|
|
1436
959
|
*/
|
|
1437
|
-
|
|
1438
|
-
throw new
|
|
1439
|
-
id: "
|
|
960
|
+
async listTraces(_args) {
|
|
961
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
962
|
+
id: "OBSERVABILITY_STORAGE_LIST_TRACES_NOT_IMPLEMENTED",
|
|
1440
963
|
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1441
964
|
category: "SYSTEM" /* SYSTEM */,
|
|
1442
|
-
text: "This storage provider does not support
|
|
965
|
+
text: "This storage provider does not support listing traces"
|
|
1443
966
|
});
|
|
1444
967
|
}
|
|
1445
968
|
/**
|
|
1446
969
|
* Creates multiple Spans in a single batch.
|
|
1447
970
|
*/
|
|
1448
|
-
batchCreateSpans(_args) {
|
|
1449
|
-
throw new
|
|
971
|
+
async batchCreateSpans(_args) {
|
|
972
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1450
973
|
id: "OBSERVABILITY_STORAGE_BATCH_CREATE_SPAN_NOT_IMPLEMENTED",
|
|
1451
974
|
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1452
975
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -1456,8 +979,8 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
1456
979
|
/**
|
|
1457
980
|
* Updates multiple Spans in a single batch.
|
|
1458
981
|
*/
|
|
1459
|
-
batchUpdateSpans(_args) {
|
|
1460
|
-
throw new
|
|
982
|
+
async batchUpdateSpans(_args) {
|
|
983
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1461
984
|
id: "OBSERVABILITY_STORAGE_BATCH_UPDATE_SPANS_NOT_IMPLEMENTED",
|
|
1462
985
|
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1463
986
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -1467,8 +990,8 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
1467
990
|
/**
|
|
1468
991
|
* Deletes multiple traces and all their associated spans in a single batch operation.
|
|
1469
992
|
*/
|
|
1470
|
-
batchDeleteTraces(_args) {
|
|
1471
|
-
throw new
|
|
993
|
+
async batchDeleteTraces(_args) {
|
|
994
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1472
995
|
id: "OBSERVABILITY_STORAGE_BATCH_DELETE_TRACES_NOT_IMPLEMENTED",
|
|
1473
996
|
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1474
997
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -1479,12 +1002,13 @@ var ObservabilityStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
1479
1002
|
|
|
1480
1003
|
// src/storage/domains/observability/inmemory.ts
|
|
1481
1004
|
var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
constructor({ collection, operations }) {
|
|
1005
|
+
db;
|
|
1006
|
+
constructor({ db }) {
|
|
1485
1007
|
super();
|
|
1486
|
-
this.
|
|
1487
|
-
|
|
1008
|
+
this.db = db;
|
|
1009
|
+
}
|
|
1010
|
+
async dangerouslyClearAll() {
|
|
1011
|
+
this.db.traces.clear();
|
|
1488
1012
|
}
|
|
1489
1013
|
get tracingStrategy() {
|
|
1490
1014
|
return {
|
|
@@ -1492,22 +1016,32 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1492
1016
|
supported: ["realtime", "batch-with-updates", "insert-only"]
|
|
1493
1017
|
};
|
|
1494
1018
|
}
|
|
1495
|
-
async createSpan(
|
|
1019
|
+
async createSpan(args) {
|
|
1020
|
+
const { span } = args;
|
|
1496
1021
|
this.validateCreateSpan(span);
|
|
1497
|
-
const
|
|
1498
|
-
const record =
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1022
|
+
const now = /* @__PURE__ */ new Date();
|
|
1023
|
+
const record = {
|
|
1024
|
+
...span,
|
|
1025
|
+
createdAt: now,
|
|
1026
|
+
updatedAt: now
|
|
1027
|
+
};
|
|
1028
|
+
this.upsertSpanToTrace(record);
|
|
1502
1029
|
}
|
|
1503
1030
|
async batchCreateSpans(args) {
|
|
1504
|
-
|
|
1505
|
-
|
|
1031
|
+
const now = /* @__PURE__ */ new Date();
|
|
1032
|
+
for (const span of args.records) {
|
|
1033
|
+
this.validateCreateSpan(span);
|
|
1034
|
+
const record = {
|
|
1035
|
+
...span,
|
|
1036
|
+
createdAt: now,
|
|
1037
|
+
updatedAt: now
|
|
1038
|
+
};
|
|
1039
|
+
this.upsertSpanToTrace(record);
|
|
1506
1040
|
}
|
|
1507
1041
|
}
|
|
1508
1042
|
validateCreateSpan(record) {
|
|
1509
1043
|
if (!record.spanId) {
|
|
1510
|
-
throw new
|
|
1044
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1511
1045
|
id: "OBSERVABILITY_SPAN_ID_REQUIRED",
|
|
1512
1046
|
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1513
1047
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -1515,7 +1049,7 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1515
1049
|
});
|
|
1516
1050
|
}
|
|
1517
1051
|
if (!record.traceId) {
|
|
1518
|
-
throw new
|
|
1052
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1519
1053
|
id: "OBSERVABILITY_TRACE_ID_REQUIRED",
|
|
1520
1054
|
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1521
1055
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -1523,11 +1057,74 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1523
1057
|
});
|
|
1524
1058
|
}
|
|
1525
1059
|
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1060
|
+
/**
|
|
1061
|
+
* Inserts or updates a span in the trace and recomputes trace-level properties
|
|
1062
|
+
*/
|
|
1063
|
+
upsertSpanToTrace(span) {
|
|
1064
|
+
const { traceId, spanId } = span;
|
|
1065
|
+
let traceEntry = this.db.traces.get(traceId);
|
|
1066
|
+
if (!traceEntry) {
|
|
1067
|
+
traceEntry = {
|
|
1068
|
+
spans: {},
|
|
1069
|
+
rootSpan: null,
|
|
1070
|
+
status: "running" /* RUNNING */,
|
|
1071
|
+
hasChildError: false
|
|
1072
|
+
};
|
|
1073
|
+
this.db.traces.set(traceId, traceEntry);
|
|
1074
|
+
}
|
|
1075
|
+
traceEntry.spans[spanId] = span;
|
|
1076
|
+
if (span.parentSpanId === null) {
|
|
1077
|
+
traceEntry.rootSpan = span;
|
|
1078
|
+
}
|
|
1079
|
+
this.recomputeTraceProperties(traceEntry);
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Recomputes derived trace properties from all spans
|
|
1083
|
+
*/
|
|
1084
|
+
recomputeTraceProperties(traceEntry) {
|
|
1085
|
+
const spans = Object.values(traceEntry.spans);
|
|
1086
|
+
if (spans.length === 0) return;
|
|
1087
|
+
traceEntry.hasChildError = spans.some((s) => s.error != null);
|
|
1088
|
+
const rootSpan = traceEntry.rootSpan;
|
|
1089
|
+
if (rootSpan) {
|
|
1090
|
+
if (rootSpan.error != null) {
|
|
1091
|
+
traceEntry.status = "error" /* ERROR */;
|
|
1092
|
+
} else if (rootSpan.endedAt === null) {
|
|
1093
|
+
traceEntry.status = "running" /* RUNNING */;
|
|
1094
|
+
} else {
|
|
1095
|
+
traceEntry.status = "success" /* SUCCESS */;
|
|
1096
|
+
}
|
|
1097
|
+
} else {
|
|
1098
|
+
traceEntry.status = "running" /* RUNNING */;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
async getSpan(args) {
|
|
1102
|
+
const { traceId, spanId } = args;
|
|
1103
|
+
const traceEntry = this.db.traces.get(traceId);
|
|
1104
|
+
if (!traceEntry) {
|
|
1105
|
+
return null;
|
|
1106
|
+
}
|
|
1107
|
+
const span = traceEntry.spans[spanId];
|
|
1108
|
+
if (!span) {
|
|
1109
|
+
return null;
|
|
1110
|
+
}
|
|
1111
|
+
return { span };
|
|
1112
|
+
}
|
|
1113
|
+
async getRootSpan(args) {
|
|
1114
|
+
const { traceId } = args;
|
|
1115
|
+
const traceEntry = this.db.traces.get(traceId);
|
|
1116
|
+
if (!traceEntry || !traceEntry.rootSpan) {
|
|
1117
|
+
return null;
|
|
1118
|
+
}
|
|
1119
|
+
return { span: traceEntry.rootSpan };
|
|
1528
1120
|
}
|
|
1529
|
-
async getTrace(
|
|
1530
|
-
const
|
|
1121
|
+
async getTrace(args) {
|
|
1122
|
+
const { traceId } = args;
|
|
1123
|
+
const traceEntry = this.db.traces.get(traceId);
|
|
1124
|
+
if (!traceEntry) {
|
|
1125
|
+
return null;
|
|
1126
|
+
}
|
|
1127
|
+
const spans = Object.values(traceEntry.spans);
|
|
1531
1128
|
if (spans.length === 0) {
|
|
1532
1129
|
return null;
|
|
1533
1130
|
}
|
|
@@ -1537,278 +1134,239 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
|
|
|
1537
1134
|
spans
|
|
1538
1135
|
};
|
|
1539
1136
|
}
|
|
1540
|
-
async
|
|
1541
|
-
filters,
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
const
|
|
1550
|
-
|
|
1551
|
-
|
|
1137
|
+
async listTraces(args) {
|
|
1138
|
+
const { filters, pagination, orderBy } = chunkCBVHOGXX_cjs.listTracesArgsSchema.parse(args);
|
|
1139
|
+
const matchingRootSpans = [];
|
|
1140
|
+
for (const [, traceEntry] of this.db.traces) {
|
|
1141
|
+
if (!traceEntry.rootSpan) continue;
|
|
1142
|
+
if (this.traceMatchesFilters(traceEntry, filters)) {
|
|
1143
|
+
matchingRootSpans.push(traceEntry.rootSpan);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
const { field: sortField, direction: sortDirection } = orderBy;
|
|
1147
|
+
matchingRootSpans.sort((a, b) => {
|
|
1148
|
+
if (sortField === "endedAt") {
|
|
1149
|
+
const aVal = a.endedAt;
|
|
1150
|
+
const bVal = b.endedAt;
|
|
1151
|
+
if (aVal == null && bVal == null) return 0;
|
|
1152
|
+
if (aVal == null) return sortDirection === "DESC" ? -1 : 1;
|
|
1153
|
+
if (bVal == null) return sortDirection === "DESC" ? 1 : -1;
|
|
1154
|
+
const diff = aVal.getTime() - bVal.getTime();
|
|
1155
|
+
return sortDirection === "DESC" ? -diff : diff;
|
|
1156
|
+
} else {
|
|
1157
|
+
const diff = a.startedAt.getTime() - b.startedAt.getTime();
|
|
1158
|
+
return sortDirection === "DESC" ? -diff : diff;
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
1161
|
+
const total = matchingRootSpans.length;
|
|
1162
|
+
const { page, perPage } = pagination;
|
|
1552
1163
|
const start = page * perPage;
|
|
1553
1164
|
const end = start + perPage;
|
|
1554
|
-
const paged =
|
|
1165
|
+
const paged = matchingRootSpans.slice(start, end);
|
|
1555
1166
|
return {
|
|
1556
1167
|
spans: paged,
|
|
1557
1168
|
pagination: { total, page, perPage, hasMore: end < total }
|
|
1558
1169
|
};
|
|
1559
1170
|
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
if (filter?.entityType === "agent" && filter.entityId !== span.attributes?.agentId) return false;
|
|
1575
|
-
if (filter?.entityType === "workflow" && filter.entityId !== span.attributes?.workflowId) return false;
|
|
1576
|
-
return true;
|
|
1577
|
-
});
|
|
1578
|
-
}
|
|
1579
|
-
filterSpansByPagination(spans, pagination) {
|
|
1580
|
-
const page = pagination?.page ?? 0;
|
|
1581
|
-
const perPage = pagination?.perPage ?? 10;
|
|
1582
|
-
const start = page * perPage;
|
|
1583
|
-
const end = start + perPage;
|
|
1584
|
-
return spans.slice(start, end);
|
|
1585
|
-
}
|
|
1586
|
-
async updateSpan(params) {
|
|
1587
|
-
const id = this.generateId(params);
|
|
1588
|
-
const span = this.collection.get(id);
|
|
1589
|
-
if (!span) {
|
|
1590
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
1591
|
-
id: "OBSERVABILITY_UPDATE_SPAN_NOT_FOUND",
|
|
1592
|
-
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1593
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
1594
|
-
text: "Span not found for update"
|
|
1595
|
-
});
|
|
1171
|
+
/**
|
|
1172
|
+
* Check if a trace matches all provided filters
|
|
1173
|
+
*/
|
|
1174
|
+
traceMatchesFilters(traceEntry, filters) {
|
|
1175
|
+
if (!filters) return true;
|
|
1176
|
+
const rootSpan = traceEntry.rootSpan;
|
|
1177
|
+
if (!rootSpan) return false;
|
|
1178
|
+
if (filters.startedAt) {
|
|
1179
|
+
if (filters.startedAt.start && rootSpan.startedAt < filters.startedAt.start) {
|
|
1180
|
+
return false;
|
|
1181
|
+
}
|
|
1182
|
+
if (filters.startedAt.end && rootSpan.startedAt > filters.startedAt.end) {
|
|
1183
|
+
return false;
|
|
1184
|
+
}
|
|
1596
1185
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1186
|
+
if (filters.endedAt) {
|
|
1187
|
+
if (rootSpan.endedAt == null) {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
if (filters.endedAt.start && rootSpan.endedAt < filters.endedAt.start) {
|
|
1191
|
+
return false;
|
|
1192
|
+
}
|
|
1193
|
+
if (filters.endedAt.end && rootSpan.endedAt > filters.endedAt.end) {
|
|
1194
|
+
return false;
|
|
1195
|
+
}
|
|
1602
1196
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1197
|
+
if (filters.spanType !== void 0 && rootSpan.spanType !== filters.spanType) {
|
|
1198
|
+
return false;
|
|
1199
|
+
}
|
|
1200
|
+
if (filters.entityType !== void 0 && rootSpan.entityType !== filters.entityType) {
|
|
1201
|
+
return false;
|
|
1202
|
+
}
|
|
1203
|
+
if (filters.entityId !== void 0 && rootSpan.entityId !== filters.entityId) {
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
if (filters.entityName !== void 0 && rootSpan.entityName !== filters.entityName) {
|
|
1207
|
+
return false;
|
|
1208
|
+
}
|
|
1209
|
+
if (filters.userId !== void 0 && rootSpan.userId !== filters.userId) {
|
|
1210
|
+
return false;
|
|
1211
|
+
}
|
|
1212
|
+
if (filters.organizationId !== void 0 && rootSpan.organizationId !== filters.organizationId) {
|
|
1213
|
+
return false;
|
|
1214
|
+
}
|
|
1215
|
+
if (filters.resourceId !== void 0 && rootSpan.resourceId !== filters.resourceId) {
|
|
1216
|
+
return false;
|
|
1217
|
+
}
|
|
1218
|
+
if (filters.runId !== void 0 && rootSpan.runId !== filters.runId) {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
if (filters.sessionId !== void 0 && rootSpan.sessionId !== filters.sessionId) {
|
|
1222
|
+
return false;
|
|
1223
|
+
}
|
|
1224
|
+
if (filters.threadId !== void 0 && rootSpan.threadId !== filters.threadId) {
|
|
1225
|
+
return false;
|
|
1226
|
+
}
|
|
1227
|
+
if (filters.requestId !== void 0 && rootSpan.requestId !== filters.requestId) {
|
|
1228
|
+
return false;
|
|
1229
|
+
}
|
|
1230
|
+
if (filters.environment !== void 0 && rootSpan.environment !== filters.environment) {
|
|
1231
|
+
return false;
|
|
1232
|
+
}
|
|
1233
|
+
if (filters.source !== void 0 && rootSpan.source !== filters.source) {
|
|
1234
|
+
return false;
|
|
1235
|
+
}
|
|
1236
|
+
if (filters.serviceName !== void 0 && rootSpan.serviceName !== filters.serviceName) {
|
|
1237
|
+
return false;
|
|
1238
|
+
}
|
|
1239
|
+
if (filters.scope != null && rootSpan.scope != null) {
|
|
1240
|
+
for (const [key, value] of Object.entries(filters.scope)) {
|
|
1241
|
+
if (!this.jsonValueEquals(rootSpan.scope[key], value)) {
|
|
1242
|
+
return false;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
} else if (filters.scope != null && rootSpan.scope == null) {
|
|
1246
|
+
return false;
|
|
1247
|
+
}
|
|
1248
|
+
if (filters.metadata != null && rootSpan.metadata != null) {
|
|
1249
|
+
for (const [key, value] of Object.entries(filters.metadata)) {
|
|
1250
|
+
if (!this.jsonValueEquals(rootSpan.metadata[key], value)) {
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
} else if (filters.metadata != null && rootSpan.metadata == null) {
|
|
1255
|
+
return false;
|
|
1256
|
+
}
|
|
1257
|
+
if (filters.tags != null && filters.tags.length > 0) {
|
|
1258
|
+
if (rootSpan.tags == null) {
|
|
1259
|
+
return false;
|
|
1260
|
+
}
|
|
1261
|
+
for (const tag of filters.tags) {
|
|
1262
|
+
if (!rootSpan.tags.includes(tag)) {
|
|
1263
|
+
return false;
|
|
1264
|
+
}
|
|
1609
1265
|
}
|
|
1610
1266
|
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
component: "STORAGE",
|
|
1619
|
-
name: "OPERATIONS"
|
|
1620
|
-
});
|
|
1621
|
-
}
|
|
1622
|
-
getSqlType(type) {
|
|
1623
|
-
switch (type) {
|
|
1624
|
-
case "text":
|
|
1625
|
-
return "TEXT";
|
|
1626
|
-
case "timestamp":
|
|
1627
|
-
return "TIMESTAMP";
|
|
1628
|
-
case "float":
|
|
1629
|
-
return "FLOAT";
|
|
1630
|
-
case "integer":
|
|
1631
|
-
return "INTEGER";
|
|
1632
|
-
case "bigint":
|
|
1633
|
-
return "BIGINT";
|
|
1634
|
-
case "jsonb":
|
|
1635
|
-
return "JSONB";
|
|
1636
|
-
default:
|
|
1637
|
-
return "TEXT";
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
getDefaultValue(type) {
|
|
1641
|
-
switch (type) {
|
|
1642
|
-
case "text":
|
|
1643
|
-
case "uuid":
|
|
1644
|
-
return "DEFAULT ''";
|
|
1645
|
-
case "timestamp":
|
|
1646
|
-
return "DEFAULT '1970-01-01 00:00:00'";
|
|
1647
|
-
case "integer":
|
|
1648
|
-
case "bigint":
|
|
1649
|
-
case "float":
|
|
1650
|
-
return "DEFAULT 0";
|
|
1651
|
-
case "jsonb":
|
|
1652
|
-
return "DEFAULT '{}'";
|
|
1653
|
-
default:
|
|
1654
|
-
return "DEFAULT ''";
|
|
1655
|
-
}
|
|
1656
|
-
}
|
|
1657
|
-
/**
|
|
1658
|
-
* DATABASE INDEX MANAGEMENT
|
|
1659
|
-
* Optional methods for database index management.
|
|
1660
|
-
* Storage adapters can override these to provide index management capabilities.
|
|
1661
|
-
*/
|
|
1662
|
-
/**
|
|
1663
|
-
* Creates a database index on specified columns
|
|
1664
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
1665
|
-
*/
|
|
1666
|
-
async createIndex(_options) {
|
|
1667
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
1668
|
-
id: "MASTRA_STORAGE_CREATE_INDEX_NOT_SUPPORTED",
|
|
1669
|
-
domain: "STORAGE" /* STORAGE */,
|
|
1670
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
1671
|
-
text: `Index management is not supported by this storage adapter`
|
|
1672
|
-
});
|
|
1267
|
+
if (filters.status !== void 0 && traceEntry.status !== filters.status) {
|
|
1268
|
+
return false;
|
|
1269
|
+
}
|
|
1270
|
+
if (filters.hasChildError !== void 0 && traceEntry.hasChildError !== filters.hasChildError) {
|
|
1271
|
+
return false;
|
|
1272
|
+
}
|
|
1273
|
+
return true;
|
|
1673
1274
|
}
|
|
1674
1275
|
/**
|
|
1675
|
-
*
|
|
1676
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
1677
|
-
*/
|
|
1678
|
-
async dropIndex(_indexName) {
|
|
1679
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
1680
|
-
id: "MASTRA_STORAGE_DROP_INDEX_NOT_SUPPORTED",
|
|
1681
|
-
domain: "STORAGE" /* STORAGE */,
|
|
1682
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
1683
|
-
text: `Index management is not supported by this storage adapter`
|
|
1684
|
-
});
|
|
1685
|
-
}
|
|
1686
|
-
/**
|
|
1687
|
-
* Lists database indexes for a table or all tables
|
|
1688
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
1689
|
-
*/
|
|
1690
|
-
async listIndexes(_tableName) {
|
|
1691
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
1692
|
-
id: "MASTRA_STORAGE_LIST_INDEXES_NOT_SUPPORTED",
|
|
1693
|
-
domain: "STORAGE" /* STORAGE */,
|
|
1694
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
1695
|
-
text: `Index management is not supported by this storage adapter`
|
|
1696
|
-
});
|
|
1697
|
-
}
|
|
1698
|
-
/**
|
|
1699
|
-
* Gets detailed statistics for a specific index
|
|
1700
|
-
* @throws {MastraError} if not supported by the storage adapter
|
|
1701
|
-
*/
|
|
1702
|
-
async describeIndex(_indexName) {
|
|
1703
|
-
throw new chunkHWMMIRIF_cjs.MastraError({
|
|
1704
|
-
id: "MASTRA_STORAGE_DESCRIBE_INDEX_NOT_SUPPORTED",
|
|
1705
|
-
domain: "STORAGE" /* STORAGE */,
|
|
1706
|
-
category: "SYSTEM" /* SYSTEM */,
|
|
1707
|
-
text: `Index management is not supported by this storage adapter`
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
/**
|
|
1711
|
-
* Returns definitions for automatic performance indexes
|
|
1712
|
-
* Storage adapters can override this to define indexes that should be created during initialization
|
|
1713
|
-
* @returns Array of index definitions to create automatically
|
|
1276
|
+
* Deep equality check for JSON values
|
|
1714
1277
|
*/
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
};
|
|
1719
|
-
|
|
1720
|
-
// src/storage/domains/operations/inmemory.ts
|
|
1721
|
-
var StoreOperationsInMemory = class extends StoreOperations {
|
|
1722
|
-
data;
|
|
1723
|
-
constructor() {
|
|
1724
|
-
super();
|
|
1725
|
-
this.data = {
|
|
1726
|
-
mastra_workflow_snapshot: /* @__PURE__ */ new Map(),
|
|
1727
|
-
mastra_messages: /* @__PURE__ */ new Map(),
|
|
1728
|
-
mastra_threads: /* @__PURE__ */ new Map(),
|
|
1729
|
-
mastra_traces: /* @__PURE__ */ new Map(),
|
|
1730
|
-
mastra_resources: /* @__PURE__ */ new Map(),
|
|
1731
|
-
mastra_scorers: /* @__PURE__ */ new Map(),
|
|
1732
|
-
mastra_ai_spans: /* @__PURE__ */ new Map(),
|
|
1733
|
-
mastra_agents: /* @__PURE__ */ new Map()
|
|
1734
|
-
};
|
|
1735
|
-
}
|
|
1736
|
-
getDatabase() {
|
|
1737
|
-
return this.data;
|
|
1738
|
-
}
|
|
1739
|
-
async insert({ tableName, record }) {
|
|
1740
|
-
const table = this.data[tableName];
|
|
1741
|
-
let key = record.id;
|
|
1742
|
-
if ([TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
|
|
1743
|
-
key = record.workflow_name ? `${record.workflow_name}-${record.run_id}` : record.run_id;
|
|
1744
|
-
record.id = key;
|
|
1745
|
-
} else if (!record.id) {
|
|
1746
|
-
key = `auto-${Date.now()}-${Math.random()}`;
|
|
1747
|
-
record.id = key;
|
|
1278
|
+
jsonValueEquals(a, b) {
|
|
1279
|
+
if (a === void 0 || b === void 0) {
|
|
1280
|
+
return a === b;
|
|
1748
1281
|
}
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1282
|
+
if (a === null || b === null) {
|
|
1283
|
+
return a === b;
|
|
1284
|
+
}
|
|
1285
|
+
if (typeof a !== typeof b) {
|
|
1286
|
+
return false;
|
|
1287
|
+
}
|
|
1288
|
+
if (a instanceof Date && b instanceof Date) {
|
|
1289
|
+
return a.getTime() === b.getTime();
|
|
1290
|
+
}
|
|
1291
|
+
if (a instanceof Date || b instanceof Date) {
|
|
1292
|
+
return false;
|
|
1293
|
+
}
|
|
1294
|
+
if (typeof a === "object") {
|
|
1295
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1296
|
+
if (a.length !== b.length) return false;
|
|
1297
|
+
return a.every((val, i) => this.jsonValueEquals(val, b[i]));
|
|
1761
1298
|
}
|
|
1762
|
-
|
|
1299
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
1300
|
+
return false;
|
|
1301
|
+
}
|
|
1302
|
+
const aKeys = Object.keys(a);
|
|
1303
|
+
const bKeys = Object.keys(b);
|
|
1304
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
1305
|
+
return aKeys.every(
|
|
1306
|
+
(key) => this.jsonValueEquals(a[key], b[key])
|
|
1307
|
+
);
|
|
1763
1308
|
}
|
|
1309
|
+
return a === b;
|
|
1764
1310
|
}
|
|
1765
|
-
async
|
|
1766
|
-
|
|
1767
|
-
const
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1311
|
+
async updateSpan(args) {
|
|
1312
|
+
const { traceId, spanId, updates } = args;
|
|
1313
|
+
const traceEntry = this.db.traces.get(traceId);
|
|
1314
|
+
if (!traceEntry) {
|
|
1315
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1316
|
+
id: "OBSERVABILITY_UPDATE_SPAN_NOT_FOUND",
|
|
1317
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1318
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
1319
|
+
text: "Trace not found for span update"
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
const span = traceEntry.spans[spanId];
|
|
1323
|
+
if (!span) {
|
|
1324
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1325
|
+
id: "OBSERVABILITY_UPDATE_SPAN_NOT_FOUND",
|
|
1326
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1327
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
1328
|
+
text: "Span not found for update"
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
const updatedSpan = {
|
|
1332
|
+
...span,
|
|
1333
|
+
...updates,
|
|
1334
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
1335
|
+
};
|
|
1336
|
+
traceEntry.spans[spanId] = updatedSpan;
|
|
1337
|
+
if (updatedSpan.parentSpanId === null) {
|
|
1338
|
+
traceEntry.rootSpan = updatedSpan;
|
|
1339
|
+
}
|
|
1340
|
+
this.recomputeTraceProperties(traceEntry);
|
|
1785
1341
|
}
|
|
1786
|
-
async
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
this.logger.debug(`MockStore: alterTable called for ${tableName} with schema`, schema);
|
|
1342
|
+
async batchUpdateSpans(args) {
|
|
1343
|
+
for (const record of args.records) {
|
|
1344
|
+
await this.updateSpan(record);
|
|
1345
|
+
}
|
|
1791
1346
|
}
|
|
1792
|
-
async
|
|
1793
|
-
|
|
1794
|
-
|
|
1347
|
+
async batchDeleteTraces(args) {
|
|
1348
|
+
for (const traceId of args.traceIds) {
|
|
1349
|
+
this.db.traces.delete(traceId);
|
|
1350
|
+
}
|
|
1795
1351
|
}
|
|
1796
1352
|
};
|
|
1797
1353
|
|
|
1798
1354
|
// src/storage/domains/scores/base.ts
|
|
1799
|
-
var ScoresStorage = class extends
|
|
1355
|
+
var ScoresStorage = class extends StorageDomain {
|
|
1800
1356
|
constructor() {
|
|
1801
1357
|
super({
|
|
1802
1358
|
component: "STORAGE",
|
|
1803
1359
|
name: "SCORES"
|
|
1804
1360
|
});
|
|
1805
1361
|
}
|
|
1362
|
+
async dangerouslyClearAll() {
|
|
1363
|
+
}
|
|
1806
1364
|
async listScoresBySpan({
|
|
1807
1365
|
traceId,
|
|
1808
1366
|
spanId,
|
|
1809
1367
|
pagination: _pagination
|
|
1810
1368
|
}) {
|
|
1811
|
-
throw new
|
|
1369
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1812
1370
|
id: "SCORES_STORAGE_GET_SCORES_BY_SPAN_NOT_IMPLEMENTED",
|
|
1813
1371
|
domain: "STORAGE" /* STORAGE */,
|
|
1814
1372
|
category: "SYSTEM" /* SYSTEM */,
|
|
@@ -1819,17 +1377,20 @@ var ScoresStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
1819
1377
|
|
|
1820
1378
|
// src/storage/domains/scores/inmemory.ts
|
|
1821
1379
|
var ScoresInMemory = class extends ScoresStorage {
|
|
1822
|
-
|
|
1823
|
-
constructor({
|
|
1380
|
+
db;
|
|
1381
|
+
constructor({ db }) {
|
|
1824
1382
|
super();
|
|
1825
|
-
this.
|
|
1383
|
+
this.db = db;
|
|
1384
|
+
}
|
|
1385
|
+
async dangerouslyClearAll() {
|
|
1386
|
+
this.db.scores.clear();
|
|
1826
1387
|
}
|
|
1827
1388
|
async getScoreById({ id }) {
|
|
1828
|
-
return this.scores.get(id) ?? null;
|
|
1389
|
+
return this.db.scores.get(id) ?? null;
|
|
1829
1390
|
}
|
|
1830
1391
|
async saveScore(score) {
|
|
1831
1392
|
const newScore = { id: crypto.randomUUID(), createdAt: /* @__PURE__ */ new Date(), updatedAt: /* @__PURE__ */ new Date(), ...score };
|
|
1832
|
-
this.scores.set(newScore.id, newScore);
|
|
1393
|
+
this.db.scores.set(newScore.id, newScore);
|
|
1833
1394
|
return { score: newScore };
|
|
1834
1395
|
}
|
|
1835
1396
|
async listScoresByScorerId({
|
|
@@ -1839,7 +1400,7 @@ var ScoresInMemory = class extends ScoresStorage {
|
|
|
1839
1400
|
entityType,
|
|
1840
1401
|
source
|
|
1841
1402
|
}) {
|
|
1842
|
-
const scores = Array.from(this.scores.values()).filter((score) => {
|
|
1403
|
+
const scores = Array.from(this.db.scores.values()).filter((score) => {
|
|
1843
1404
|
let baseFilter = score.scorerId === scorerId;
|
|
1844
1405
|
if (entityId) {
|
|
1845
1406
|
baseFilter = baseFilter && score.entityId === entityId;
|
|
@@ -1870,7 +1431,7 @@ var ScoresInMemory = class extends ScoresStorage {
|
|
|
1870
1431
|
runId,
|
|
1871
1432
|
pagination
|
|
1872
1433
|
}) {
|
|
1873
|
-
const scores = Array.from(this.scores.values()).filter((score) => score.runId === runId);
|
|
1434
|
+
const scores = Array.from(this.db.scores.values()).filter((score) => score.runId === runId);
|
|
1874
1435
|
const { page, perPage: perPageInput } = pagination;
|
|
1875
1436
|
const perPage = normalizePerPage(perPageInput, Number.MAX_SAFE_INTEGER);
|
|
1876
1437
|
const { offset: start, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
@@ -1890,7 +1451,7 @@ var ScoresInMemory = class extends ScoresStorage {
|
|
|
1890
1451
|
entityType,
|
|
1891
1452
|
pagination
|
|
1892
1453
|
}) {
|
|
1893
|
-
const scores = Array.from(this.scores.values()).filter((score) => {
|
|
1454
|
+
const scores = Array.from(this.db.scores.values()).filter((score) => {
|
|
1894
1455
|
const baseFilter = score.entityId === entityId && score.entityType === entityType;
|
|
1895
1456
|
return baseFilter;
|
|
1896
1457
|
});
|
|
@@ -1913,7 +1474,7 @@ var ScoresInMemory = class extends ScoresStorage {
|
|
|
1913
1474
|
spanId,
|
|
1914
1475
|
pagination
|
|
1915
1476
|
}) {
|
|
1916
|
-
const scores = Array.from(this.scores.values()).filter(
|
|
1477
|
+
const scores = Array.from(this.db.scores.values()).filter(
|
|
1917
1478
|
(score) => score.traceId === traceId && score.spanId === spanId
|
|
1918
1479
|
);
|
|
1919
1480
|
scores.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
@@ -1934,7 +1495,7 @@ var ScoresInMemory = class extends ScoresStorage {
|
|
|
1934
1495
|
};
|
|
1935
1496
|
|
|
1936
1497
|
// src/storage/domains/workflows/base.ts
|
|
1937
|
-
var WorkflowsStorage = class extends
|
|
1498
|
+
var WorkflowsStorage = class extends StorageDomain {
|
|
1938
1499
|
constructor() {
|
|
1939
1500
|
super({
|
|
1940
1501
|
component: "STORAGE",
|
|
@@ -1945,12 +1506,16 @@ var WorkflowsStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
1945
1506
|
|
|
1946
1507
|
// src/storage/domains/workflows/inmemory.ts
|
|
1947
1508
|
var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
constructor({ collection, operations }) {
|
|
1509
|
+
db;
|
|
1510
|
+
constructor({ db }) {
|
|
1951
1511
|
super();
|
|
1952
|
-
this.
|
|
1953
|
-
|
|
1512
|
+
this.db = db;
|
|
1513
|
+
}
|
|
1514
|
+
async dangerouslyClearAll() {
|
|
1515
|
+
this.db.workflows.clear();
|
|
1516
|
+
}
|
|
1517
|
+
getWorkflowKey(workflowName, runId) {
|
|
1518
|
+
return `${workflowName}-${runId}`;
|
|
1954
1519
|
}
|
|
1955
1520
|
async updateWorkflowResults({
|
|
1956
1521
|
workflowName,
|
|
@@ -1959,8 +1524,9 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
|
1959
1524
|
result,
|
|
1960
1525
|
requestContext
|
|
1961
1526
|
}) {
|
|
1962
|
-
this.logger.debug(`
|
|
1963
|
-
const
|
|
1527
|
+
this.logger.debug(`WorkflowsInMemory: updateWorkflowResults called for ${workflowName} ${runId} ${stepId}`, result);
|
|
1528
|
+
const key = this.getWorkflowKey(workflowName, runId);
|
|
1529
|
+
const run = this.db.workflows.get(key);
|
|
1964
1530
|
if (!run) {
|
|
1965
1531
|
return {};
|
|
1966
1532
|
}
|
|
@@ -1979,18 +1545,19 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
|
1979
1545
|
status: "pending",
|
|
1980
1546
|
runId: run.run_id
|
|
1981
1547
|
};
|
|
1982
|
-
this.
|
|
1548
|
+
this.db.workflows.set(key, {
|
|
1983
1549
|
...run,
|
|
1984
1550
|
snapshot
|
|
1985
1551
|
});
|
|
1552
|
+
} else {
|
|
1553
|
+
snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
|
|
1986
1554
|
}
|
|
1987
|
-
snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
|
|
1988
1555
|
if (!snapshot || !snapshot?.context) {
|
|
1989
1556
|
throw new Error(`Snapshot not found for runId ${runId}`);
|
|
1990
1557
|
}
|
|
1991
1558
|
snapshot.context[stepId] = result;
|
|
1992
1559
|
snapshot.requestContext = { ...snapshot.requestContext, ...requestContext };
|
|
1993
|
-
this.
|
|
1560
|
+
this.db.workflows.set(key, {
|
|
1994
1561
|
...run,
|
|
1995
1562
|
snapshot
|
|
1996
1563
|
});
|
|
@@ -2001,7 +1568,8 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
|
2001
1568
|
runId,
|
|
2002
1569
|
opts
|
|
2003
1570
|
}) {
|
|
2004
|
-
const
|
|
1571
|
+
const key = this.getWorkflowKey(workflowName, runId);
|
|
1572
|
+
const run = this.db.workflows.get(key);
|
|
2005
1573
|
if (!run) {
|
|
2006
1574
|
return;
|
|
2007
1575
|
}
|
|
@@ -2020,7 +1588,7 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
|
2020
1588
|
status: "pending",
|
|
2021
1589
|
runId: run.run_id
|
|
2022
1590
|
};
|
|
2023
|
-
this.
|
|
1591
|
+
this.db.workflows.set(key, {
|
|
2024
1592
|
...run,
|
|
2025
1593
|
snapshot
|
|
2026
1594
|
});
|
|
@@ -2031,7 +1599,7 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
|
2031
1599
|
throw new Error(`Snapshot not found for runId ${runId}`);
|
|
2032
1600
|
}
|
|
2033
1601
|
snapshot = { ...snapshot, ...opts };
|
|
2034
|
-
this.
|
|
1602
|
+
this.db.workflows.set(key, {
|
|
2035
1603
|
...run,
|
|
2036
1604
|
snapshot
|
|
2037
1605
|
});
|
|
@@ -2041,31 +1609,34 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
|
2041
1609
|
workflowName,
|
|
2042
1610
|
runId,
|
|
2043
1611
|
resourceId,
|
|
2044
|
-
snapshot
|
|
1612
|
+
snapshot,
|
|
1613
|
+
createdAt,
|
|
1614
|
+
updatedAt
|
|
2045
1615
|
}) {
|
|
1616
|
+
const key = this.getWorkflowKey(workflowName, runId);
|
|
1617
|
+
const now = /* @__PURE__ */ new Date();
|
|
2046
1618
|
const data = {
|
|
2047
1619
|
workflow_name: workflowName,
|
|
2048
1620
|
run_id: runId,
|
|
2049
1621
|
resourceId,
|
|
2050
1622
|
snapshot,
|
|
2051
|
-
createdAt:
|
|
2052
|
-
updatedAt:
|
|
1623
|
+
createdAt: createdAt ?? now,
|
|
1624
|
+
updatedAt: updatedAt ?? now
|
|
2053
1625
|
};
|
|
2054
|
-
|
|
2055
|
-
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
2056
|
-
record: data
|
|
2057
|
-
});
|
|
1626
|
+
this.db.workflows.set(key, data);
|
|
2058
1627
|
}
|
|
2059
1628
|
async loadWorkflowSnapshot({
|
|
2060
1629
|
workflowName,
|
|
2061
1630
|
runId
|
|
2062
1631
|
}) {
|
|
2063
1632
|
this.logger.debug("Loading workflow snapshot", { workflowName, runId });
|
|
2064
|
-
const
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
1633
|
+
const key = this.getWorkflowKey(workflowName, runId);
|
|
1634
|
+
const run = this.db.workflows.get(key);
|
|
1635
|
+
if (!run) {
|
|
1636
|
+
return null;
|
|
1637
|
+
}
|
|
1638
|
+
const snapshot = typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot;
|
|
1639
|
+
return snapshot ? JSON.parse(JSON.stringify(snapshot)) : null;
|
|
2069
1640
|
}
|
|
2070
1641
|
async listWorkflowRuns({
|
|
2071
1642
|
workflowName,
|
|
@@ -2079,7 +1650,7 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
|
2079
1650
|
if (page !== void 0 && page < 0) {
|
|
2080
1651
|
throw new Error("page must be >= 0");
|
|
2081
1652
|
}
|
|
2082
|
-
let runs = Array.from(this.
|
|
1653
|
+
let runs = Array.from(this.db.workflows.values());
|
|
2083
1654
|
if (workflowName) runs = runs.filter((run) => run.workflow_name === workflowName);
|
|
2084
1655
|
if (status) {
|
|
2085
1656
|
runs = runs.filter((run) => {
|
|
@@ -2133,7 +1704,7 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
|
2133
1704
|
runId,
|
|
2134
1705
|
workflowName
|
|
2135
1706
|
}) {
|
|
2136
|
-
const runs = Array.from(this.
|
|
1707
|
+
const runs = Array.from(this.db.workflows.values()).filter((r) => r.run_id === runId);
|
|
2137
1708
|
let run = runs.find((r) => r.workflow_name === workflowName);
|
|
2138
1709
|
if (!run) return null;
|
|
2139
1710
|
const parsedRun = {
|
|
@@ -2148,230 +1719,243 @@ var WorkflowsInMemory = class extends WorkflowsStorage {
|
|
|
2148
1719
|
return parsedRun;
|
|
2149
1720
|
}
|
|
2150
1721
|
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
2151
|
-
this.
|
|
1722
|
+
const key = this.getWorkflowKey(workflowName, runId);
|
|
1723
|
+
this.db.workflows.delete(key);
|
|
2152
1724
|
}
|
|
2153
1725
|
};
|
|
2154
1726
|
|
|
2155
1727
|
// src/storage/mock.ts
|
|
2156
1728
|
var InMemoryStore = class extends MastraStorage {
|
|
2157
1729
|
stores;
|
|
1730
|
+
/**
|
|
1731
|
+
* Internal database layer shared across all domains.
|
|
1732
|
+
* This is an implementation detail - domains interact with this
|
|
1733
|
+
* rather than managing their own data structures.
|
|
1734
|
+
*/
|
|
1735
|
+
#db;
|
|
2158
1736
|
constructor({ id = "in-memory" } = {}) {
|
|
2159
1737
|
super({ id, name: "InMemoryStorage" });
|
|
2160
1738
|
this.hasInitialized = Promise.resolve(true);
|
|
2161
|
-
|
|
2162
|
-
const database = operationsStorage.getDatabase();
|
|
2163
|
-
const scoresStorage = new ScoresInMemory({
|
|
2164
|
-
collection: database.mastra_scorers
|
|
2165
|
-
});
|
|
2166
|
-
const workflowsStorage = new WorkflowsInMemory({
|
|
2167
|
-
collection: database.mastra_workflow_snapshot,
|
|
2168
|
-
operations: operationsStorage
|
|
2169
|
-
});
|
|
2170
|
-
const memoryStorage = new InMemoryMemory({
|
|
2171
|
-
collection: {
|
|
2172
|
-
threads: database.mastra_threads,
|
|
2173
|
-
resources: database.mastra_resources,
|
|
2174
|
-
messages: database.mastra_messages
|
|
2175
|
-
},
|
|
2176
|
-
operations: operationsStorage
|
|
2177
|
-
});
|
|
2178
|
-
const observabilityStorage = new ObservabilityInMemory({
|
|
2179
|
-
collection: database.mastra_ai_spans,
|
|
2180
|
-
operations: operationsStorage
|
|
2181
|
-
});
|
|
2182
|
-
const agentsCollection = /* @__PURE__ */ new Map();
|
|
2183
|
-
const agentsStorage = new InMemoryAgentsStorage({
|
|
2184
|
-
collection: agentsCollection
|
|
2185
|
-
});
|
|
1739
|
+
this.#db = new InMemoryDB();
|
|
2186
1740
|
this.stores = {
|
|
2187
|
-
|
|
2188
|
-
workflows:
|
|
2189
|
-
scores:
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
agents: agentsStorage
|
|
1741
|
+
memory: new InMemoryMemory({ db: this.#db }),
|
|
1742
|
+
workflows: new WorkflowsInMemory({ db: this.#db }),
|
|
1743
|
+
scores: new ScoresInMemory({ db: this.#db }),
|
|
1744
|
+
observability: new ObservabilityInMemory({ db: this.#db }),
|
|
1745
|
+
agents: new InMemoryAgentsStorage({ db: this.#db })
|
|
2193
1746
|
};
|
|
2194
1747
|
}
|
|
2195
1748
|
get supports() {
|
|
2196
1749
|
return {
|
|
2197
1750
|
selectByIncludeResourceScope: false,
|
|
2198
|
-
resourceWorkingMemory:
|
|
1751
|
+
resourceWorkingMemory: true,
|
|
2199
1752
|
hasColumn: false,
|
|
2200
1753
|
createTable: false,
|
|
2201
1754
|
deleteMessages: true,
|
|
2202
|
-
|
|
1755
|
+
observability: true,
|
|
2203
1756
|
indexManagement: false,
|
|
2204
1757
|
listScoresBySpan: true,
|
|
2205
1758
|
agents: true
|
|
2206
1759
|
};
|
|
2207
1760
|
}
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
}
|
|
2216
|
-
async loadWorkflowSnapshot({
|
|
2217
|
-
workflowName,
|
|
2218
|
-
runId
|
|
2219
|
-
}) {
|
|
2220
|
-
return this.stores.workflows.loadWorkflowSnapshot({ workflowName, runId });
|
|
2221
|
-
}
|
|
2222
|
-
async createTable({
|
|
2223
|
-
tableName,
|
|
2224
|
-
schema
|
|
2225
|
-
}) {
|
|
2226
|
-
await this.stores.operations.createTable({ tableName, schema });
|
|
2227
|
-
}
|
|
2228
|
-
async alterTable({
|
|
2229
|
-
tableName,
|
|
2230
|
-
schema,
|
|
2231
|
-
ifNotExists
|
|
2232
|
-
}) {
|
|
2233
|
-
await this.stores.operations.alterTable({ tableName, schema, ifNotExists });
|
|
2234
|
-
}
|
|
2235
|
-
async clearTable({ tableName }) {
|
|
2236
|
-
await this.stores.operations.clearTable({ tableName });
|
|
2237
|
-
}
|
|
2238
|
-
async dropTable({ tableName }) {
|
|
2239
|
-
await this.stores.operations.dropTable({ tableName });
|
|
2240
|
-
}
|
|
2241
|
-
async insert({ tableName, record }) {
|
|
2242
|
-
await this.stores.operations.insert({ tableName, record });
|
|
2243
|
-
}
|
|
2244
|
-
async updateWorkflowResults({
|
|
2245
|
-
workflowName,
|
|
2246
|
-
runId,
|
|
2247
|
-
stepId,
|
|
2248
|
-
result,
|
|
2249
|
-
requestContext
|
|
2250
|
-
}) {
|
|
2251
|
-
return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, requestContext });
|
|
2252
|
-
}
|
|
2253
|
-
async updateWorkflowState({
|
|
2254
|
-
workflowName,
|
|
2255
|
-
runId,
|
|
2256
|
-
opts
|
|
2257
|
-
}) {
|
|
2258
|
-
return this.stores.workflows.updateWorkflowState({ workflowName, runId, opts });
|
|
2259
|
-
}
|
|
2260
|
-
async batchInsert({ tableName, records }) {
|
|
2261
|
-
await this.stores.operations.batchInsert({ tableName, records });
|
|
2262
|
-
}
|
|
2263
|
-
async load({ tableName, keys }) {
|
|
2264
|
-
return this.stores.operations.load({ tableName, keys });
|
|
2265
|
-
}
|
|
2266
|
-
async getThreadById({ threadId }) {
|
|
2267
|
-
return this.stores.memory.getThreadById({ threadId });
|
|
1761
|
+
/**
|
|
1762
|
+
* Clears all data from the in-memory database.
|
|
1763
|
+
* Useful for testing.
|
|
1764
|
+
* @deprecated Use dangerouslyClearAll() on individual domains instead.
|
|
1765
|
+
*/
|
|
1766
|
+
clear() {
|
|
1767
|
+
this.#db.clear();
|
|
2268
1768
|
}
|
|
2269
|
-
|
|
2270
|
-
|
|
1769
|
+
};
|
|
1770
|
+
var MockStore = InMemoryStore;
|
|
1771
|
+
|
|
1772
|
+
// src/storage/domains/operations/base.ts
|
|
1773
|
+
var StoreOperations = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
1774
|
+
constructor() {
|
|
1775
|
+
super({
|
|
1776
|
+
component: "STORAGE",
|
|
1777
|
+
name: "OPERATIONS"
|
|
1778
|
+
});
|
|
2271
1779
|
}
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
1780
|
+
getSqlType(type) {
|
|
1781
|
+
switch (type) {
|
|
1782
|
+
case "text":
|
|
1783
|
+
return "TEXT";
|
|
1784
|
+
case "timestamp":
|
|
1785
|
+
return "TIMESTAMP";
|
|
1786
|
+
case "float":
|
|
1787
|
+
return "FLOAT";
|
|
1788
|
+
case "integer":
|
|
1789
|
+
return "INTEGER";
|
|
1790
|
+
case "bigint":
|
|
1791
|
+
return "BIGINT";
|
|
1792
|
+
case "jsonb":
|
|
1793
|
+
return "JSONB";
|
|
1794
|
+
default:
|
|
1795
|
+
return "TEXT";
|
|
1796
|
+
}
|
|
2278
1797
|
}
|
|
2279
|
-
|
|
2280
|
-
|
|
1798
|
+
getDefaultValue(type) {
|
|
1799
|
+
switch (type) {
|
|
1800
|
+
case "text":
|
|
1801
|
+
case "uuid":
|
|
1802
|
+
return "DEFAULT ''";
|
|
1803
|
+
case "timestamp":
|
|
1804
|
+
return "DEFAULT '1970-01-01 00:00:00'";
|
|
1805
|
+
case "integer":
|
|
1806
|
+
case "bigint":
|
|
1807
|
+
case "float":
|
|
1808
|
+
return "DEFAULT 0";
|
|
1809
|
+
case "jsonb":
|
|
1810
|
+
return "DEFAULT '{}'";
|
|
1811
|
+
default:
|
|
1812
|
+
return "DEFAULT ''";
|
|
1813
|
+
}
|
|
2281
1814
|
}
|
|
2282
|
-
|
|
2283
|
-
|
|
1815
|
+
/**
|
|
1816
|
+
* DATABASE INDEX MANAGEMENT
|
|
1817
|
+
* Optional methods for database index management.
|
|
1818
|
+
* Storage adapters can override these to provide index management capabilities.
|
|
1819
|
+
*/
|
|
1820
|
+
/**
|
|
1821
|
+
* Creates a database index on specified columns
|
|
1822
|
+
* @throws {MastraError} if not supported by the storage adapter
|
|
1823
|
+
*/
|
|
1824
|
+
async createIndex(_options) {
|
|
1825
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1826
|
+
id: "MASTRA_STORAGE_CREATE_INDEX_NOT_SUPPORTED",
|
|
1827
|
+
domain: "STORAGE" /* STORAGE */,
|
|
1828
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
1829
|
+
text: `Index management is not supported by this storage adapter`
|
|
1830
|
+
});
|
|
2284
1831
|
}
|
|
2285
|
-
|
|
2286
|
-
|
|
1832
|
+
/**
|
|
1833
|
+
* Drops a database index by name
|
|
1834
|
+
* @throws {MastraError} if not supported by the storage adapter
|
|
1835
|
+
*/
|
|
1836
|
+
async dropIndex(_indexName) {
|
|
1837
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1838
|
+
id: "MASTRA_STORAGE_DROP_INDEX_NOT_SUPPORTED",
|
|
1839
|
+
domain: "STORAGE" /* STORAGE */,
|
|
1840
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
1841
|
+
text: `Index management is not supported by this storage adapter`
|
|
1842
|
+
});
|
|
2287
1843
|
}
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
1844
|
+
/**
|
|
1845
|
+
* Lists database indexes for a table or all tables
|
|
1846
|
+
* @throws {MastraError} if not supported by the storage adapter
|
|
1847
|
+
*/
|
|
1848
|
+
async listIndexes(_tableName) {
|
|
1849
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1850
|
+
id: "MASTRA_STORAGE_LIST_INDEXES_NOT_SUPPORTED",
|
|
1851
|
+
domain: "STORAGE" /* STORAGE */,
|
|
1852
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
1853
|
+
text: `Index management is not supported by this storage adapter`
|
|
1854
|
+
});
|
|
2294
1855
|
}
|
|
2295
|
-
|
|
2296
|
-
|
|
1856
|
+
/**
|
|
1857
|
+
* Gets detailed statistics for a specific index
|
|
1858
|
+
* @throws {MastraError} if not supported by the storage adapter
|
|
1859
|
+
*/
|
|
1860
|
+
async describeIndex(_indexName) {
|
|
1861
|
+
throw new chunk4U7ZLI36_cjs.MastraError({
|
|
1862
|
+
id: "MASTRA_STORAGE_DESCRIBE_INDEX_NOT_SUPPORTED",
|
|
1863
|
+
domain: "STORAGE" /* STORAGE */,
|
|
1864
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
1865
|
+
text: `Index management is not supported by this storage adapter`
|
|
1866
|
+
});
|
|
2297
1867
|
}
|
|
2298
|
-
|
|
2299
|
-
|
|
1868
|
+
/**
|
|
1869
|
+
* Returns definitions for automatic performance indexes
|
|
1870
|
+
* Storage adapters can override this to define indexes that should be created during initialization
|
|
1871
|
+
* @returns Array of index definitions to create automatically
|
|
1872
|
+
*/
|
|
1873
|
+
getAutomaticIndexDefinitions() {
|
|
1874
|
+
return [];
|
|
2300
1875
|
}
|
|
2301
|
-
|
|
2302
|
-
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
// src/storage/domains/operations/inmemory.ts
|
|
1879
|
+
var StoreOperationsInMemory = class extends StoreOperations {
|
|
1880
|
+
data;
|
|
1881
|
+
constructor() {
|
|
1882
|
+
super();
|
|
1883
|
+
this.data = {
|
|
1884
|
+
mastra_workflow_snapshot: /* @__PURE__ */ new Map(),
|
|
1885
|
+
mastra_messages: /* @__PURE__ */ new Map(),
|
|
1886
|
+
mastra_threads: /* @__PURE__ */ new Map(),
|
|
1887
|
+
mastra_traces: /* @__PURE__ */ new Map(),
|
|
1888
|
+
mastra_resources: /* @__PURE__ */ new Map(),
|
|
1889
|
+
mastra_scorers: /* @__PURE__ */ new Map(),
|
|
1890
|
+
mastra_ai_spans: /* @__PURE__ */ new Map(),
|
|
1891
|
+
mastra_agents: /* @__PURE__ */ new Map()
|
|
1892
|
+
};
|
|
2303
1893
|
}
|
|
2304
|
-
|
|
2305
|
-
return this.
|
|
1894
|
+
getDatabase() {
|
|
1895
|
+
return this.data;
|
|
2306
1896
|
}
|
|
2307
|
-
async
|
|
2308
|
-
|
|
1897
|
+
async insert({ tableName, record }) {
|
|
1898
|
+
const table = this.data[tableName];
|
|
1899
|
+
let key = record.id;
|
|
1900
|
+
if ([chunkCBVHOGXX_cjs.TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
|
|
1901
|
+
key = record.workflow_name ? `${record.workflow_name}-${record.run_id}` : record.run_id;
|
|
1902
|
+
record.id = key;
|
|
1903
|
+
} else if (!record.id) {
|
|
1904
|
+
key = `auto-${Date.now()}-${Math.random()}`;
|
|
1905
|
+
record.id = key;
|
|
1906
|
+
}
|
|
1907
|
+
table.set(key, record);
|
|
2309
1908
|
}
|
|
2310
|
-
async
|
|
2311
|
-
|
|
1909
|
+
async batchInsert({ tableName, records }) {
|
|
1910
|
+
const table = this.data[tableName];
|
|
1911
|
+
for (const record of records) {
|
|
1912
|
+
let key = record.id;
|
|
1913
|
+
if ([chunkCBVHOGXX_cjs.TABLE_WORKFLOW_SNAPSHOT].includes(tableName) && !record.id && record.run_id) {
|
|
1914
|
+
key = record.run_id;
|
|
1915
|
+
record.id = key;
|
|
1916
|
+
} else if (!record.id) {
|
|
1917
|
+
key = `auto-${Date.now()}-${Math.random()}`;
|
|
1918
|
+
record.id = key;
|
|
1919
|
+
}
|
|
1920
|
+
table.set(key, record);
|
|
1921
|
+
}
|
|
2312
1922
|
}
|
|
2313
|
-
async
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
pagination
|
|
2319
|
-
}) {
|
|
2320
|
-
return this.stores.scores.listScoresByScorerId({ scorerId, entityId, entityType, source, pagination });
|
|
1923
|
+
async load({ tableName, keys }) {
|
|
1924
|
+
this.logger.debug(`MockStore: load called for ${tableName} with keys`, keys);
|
|
1925
|
+
const table = this.data[tableName];
|
|
1926
|
+
const records = Array.from(table.values());
|
|
1927
|
+
return records.filter((record) => Object.keys(keys).every((key) => record[key] === keys[key]))?.[0];
|
|
2321
1928
|
}
|
|
2322
|
-
async
|
|
2323
|
-
|
|
2324
|
-
|
|
1929
|
+
async createTable({
|
|
1930
|
+
tableName,
|
|
1931
|
+
schema
|
|
2325
1932
|
}) {
|
|
2326
|
-
|
|
1933
|
+
this.logger.debug(`MockStore: createTable called for ${tableName} with schema`, schema);
|
|
1934
|
+
this.data[tableName] = /* @__PURE__ */ new Map();
|
|
2327
1935
|
}
|
|
2328
|
-
async
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
pagination
|
|
2332
|
-
}) {
|
|
2333
|
-
return this.stores.scores.listScoresByEntityId({ entityId, entityType, pagination });
|
|
1936
|
+
async clearTable({ tableName }) {
|
|
1937
|
+
this.logger.debug(`MockStore: clearTable called for ${tableName}`);
|
|
1938
|
+
this.data[tableName].clear();
|
|
2334
1939
|
}
|
|
2335
|
-
async
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
pagination
|
|
2339
|
-
}) {
|
|
2340
|
-
return this.stores.scores.listScoresBySpan({ traceId, spanId, pagination });
|
|
1940
|
+
async dropTable({ tableName }) {
|
|
1941
|
+
this.logger.debug(`MockStore: dropTable called for ${tableName}`);
|
|
1942
|
+
this.data[tableName].clear();
|
|
2341
1943
|
}
|
|
2342
|
-
async
|
|
2343
|
-
|
|
2344
|
-
|
|
1944
|
+
async alterTable({
|
|
1945
|
+
tableName,
|
|
1946
|
+
schema
|
|
2345
1947
|
}) {
|
|
2346
|
-
|
|
2347
|
-
}
|
|
2348
|
-
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
2349
|
-
return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
|
|
2350
|
-
}
|
|
2351
|
-
async createSpan(span) {
|
|
2352
|
-
return this.stores.observability.createSpan(span);
|
|
2353
|
-
}
|
|
2354
|
-
async updateSpan(params) {
|
|
2355
|
-
return this.stores.observability.updateSpan(params);
|
|
2356
|
-
}
|
|
2357
|
-
async getTrace(traceId) {
|
|
2358
|
-
return this.stores.observability.getTrace(traceId);
|
|
2359
|
-
}
|
|
2360
|
-
async batchCreateSpans(args) {
|
|
2361
|
-
return this.stores.observability.batchCreateSpans(args);
|
|
2362
|
-
}
|
|
2363
|
-
async batchUpdateSpans(args) {
|
|
2364
|
-
return this.stores.observability.batchUpdateSpans(args);
|
|
1948
|
+
this.logger.debug(`MockStore: alterTable called for ${tableName} with schema`, schema);
|
|
2365
1949
|
}
|
|
2366
|
-
async
|
|
2367
|
-
|
|
1950
|
+
async hasColumn(table, column) {
|
|
1951
|
+
this.logger.debug(`MockStore: hasColumn called for ${table} with column ${column}`);
|
|
1952
|
+
return true;
|
|
2368
1953
|
}
|
|
2369
1954
|
};
|
|
2370
|
-
var MockStore = InMemoryStore;
|
|
2371
1955
|
|
|
2372
|
-
exports.AGENTS_SCHEMA = AGENTS_SCHEMA;
|
|
2373
1956
|
exports.AgentsStorage = AgentsStorage;
|
|
2374
1957
|
exports.InMemoryAgentsStorage = InMemoryAgentsStorage;
|
|
1958
|
+
exports.InMemoryDB = InMemoryDB;
|
|
2375
1959
|
exports.InMemoryMemory = InMemoryMemory;
|
|
2376
1960
|
exports.InMemoryStore = InMemoryStore;
|
|
2377
1961
|
exports.MastraStorage = MastraStorage;
|
|
@@ -2379,21 +1963,11 @@ exports.MemoryStorage = MemoryStorage;
|
|
|
2379
1963
|
exports.MockStore = MockStore;
|
|
2380
1964
|
exports.ObservabilityInMemory = ObservabilityInMemory;
|
|
2381
1965
|
exports.ObservabilityStorage = ObservabilityStorage;
|
|
2382
|
-
exports.SCORERS_SCHEMA = SCORERS_SCHEMA;
|
|
2383
|
-
exports.SPAN_SCHEMA = SPAN_SCHEMA;
|
|
2384
1966
|
exports.ScoresInMemory = ScoresInMemory;
|
|
2385
1967
|
exports.ScoresStorage = ScoresStorage;
|
|
1968
|
+
exports.StorageDomain = StorageDomain;
|
|
2386
1969
|
exports.StoreOperations = StoreOperations;
|
|
2387
1970
|
exports.StoreOperationsInMemory = StoreOperationsInMemory;
|
|
2388
|
-
exports.TABLE_AGENTS = TABLE_AGENTS;
|
|
2389
|
-
exports.TABLE_MESSAGES = TABLE_MESSAGES;
|
|
2390
|
-
exports.TABLE_RESOURCES = TABLE_RESOURCES;
|
|
2391
|
-
exports.TABLE_SCHEMAS = TABLE_SCHEMAS;
|
|
2392
|
-
exports.TABLE_SCORERS = TABLE_SCORERS;
|
|
2393
|
-
exports.TABLE_SPANS = TABLE_SPANS;
|
|
2394
|
-
exports.TABLE_THREADS = TABLE_THREADS;
|
|
2395
|
-
exports.TABLE_TRACES = TABLE_TRACES;
|
|
2396
|
-
exports.TABLE_WORKFLOW_SNAPSHOT = TABLE_WORKFLOW_SNAPSHOT;
|
|
2397
1971
|
exports.WorkflowsInMemory = WorkflowsInMemory;
|
|
2398
1972
|
exports.WorkflowsStorage = WorkflowsStorage;
|
|
2399
1973
|
exports.calculatePagination = calculatePagination;
|
|
@@ -2401,10 +1975,12 @@ exports.createStorageErrorId = createStorageErrorId;
|
|
|
2401
1975
|
exports.createStoreErrorId = createStoreErrorId;
|
|
2402
1976
|
exports.createVectorErrorId = createVectorErrorId;
|
|
2403
1977
|
exports.ensureDate = ensureDate;
|
|
1978
|
+
exports.getDefaultValue = getDefaultValue;
|
|
1979
|
+
exports.getSqlType = getSqlType;
|
|
2404
1980
|
exports.normalizePerPage = normalizePerPage;
|
|
2405
1981
|
exports.safelyParseJSON = safelyParseJSON;
|
|
2406
1982
|
exports.serializeDate = serializeDate;
|
|
2407
1983
|
exports.transformRow = transformRow;
|
|
2408
1984
|
exports.transformScoreRow = transformScoreRow;
|
|
2409
|
-
//# sourceMappingURL=chunk-
|
|
2410
|
-
//# sourceMappingURL=chunk-
|
|
1985
|
+
//# sourceMappingURL=chunk-LOV5NNGK.cjs.map
|
|
1986
|
+
//# sourceMappingURL=chunk-LOV5NNGK.cjs.map
|