@mastra/core 1.0.0-beta.7 → 1.0.0-beta.9
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 +77 -0
- package/dist/agent/agent.d.ts +1 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/index.cjs +9 -9
- package/dist/agent/index.js +2 -2
- package/dist/agent/message-list/index.cjs +3 -3
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts +2 -1
- package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts +2 -1
- package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
- package/dist/{chunk-PJ7AYWAX.cjs → chunk-3DRGAKUH.cjs} +382 -13
- package/dist/chunk-3DRGAKUH.cjs.map +1 -0
- package/dist/{chunk-EE5NIGJ4.js → chunk-4GLDYGNN.js} +3 -3
- package/dist/{chunk-EE5NIGJ4.js.map → chunk-4GLDYGNN.js.map} +1 -1
- package/dist/{chunk-4GTU7MB2.js → chunk-7IMDJAYQ.js} +5 -5
- package/dist/{chunk-4GTU7MB2.js.map → chunk-7IMDJAYQ.js.map} +1 -1
- package/dist/{chunk-M7CQULF7.cjs → chunk-7S7TLMTS.cjs} +287 -10
- package/dist/chunk-7S7TLMTS.cjs.map +1 -0
- package/dist/{chunk-NAKPEQEQ.js → chunk-A4C3AGVS.js} +5 -5
- package/dist/{chunk-NAKPEQEQ.js.map → chunk-A4C3AGVS.js.map} +1 -1
- package/dist/{chunk-DMPHPHMU.js → chunk-APMPOYPI.js} +3 -3
- package/dist/{chunk-DMPHPHMU.js.map → chunk-APMPOYPI.js.map} +1 -1
- package/dist/{chunk-POM7FCH5.js → chunk-ARSSSQQP.js} +141 -48
- package/dist/chunk-ARSSSQQP.js.map +1 -0
- package/dist/{chunk-HJNEZRI4.cjs → chunk-CKRWR5DS.cjs} +15 -15
- package/dist/{chunk-HJNEZRI4.cjs.map → chunk-CKRWR5DS.cjs.map} +1 -1
- package/dist/{chunk-26YAGTXK.cjs → chunk-DWB7SBVC.cjs} +28 -32
- package/dist/chunk-DWB7SBVC.cjs.map +1 -0
- package/dist/{chunk-URMN7TTH.cjs → chunk-EGXQVF75.cjs} +380 -6
- package/dist/chunk-EGXQVF75.cjs.map +1 -0
- package/dist/{chunk-4AP234N6.cjs → chunk-F77YTHXI.cjs} +4 -4
- package/dist/{chunk-4AP234N6.cjs.map → chunk-F77YTHXI.cjs.map} +1 -1
- package/dist/{chunk-6C2PU6J4.cjs → chunk-HSRQXO6F.cjs} +6 -6
- package/dist/{chunk-6C2PU6J4.cjs.map → chunk-HSRQXO6F.cjs.map} +1 -1
- package/dist/{chunk-YUXTDKYN.cjs → chunk-IISGCZJ4.cjs} +15 -15
- package/dist/{chunk-YUXTDKYN.cjs.map → chunk-IISGCZJ4.cjs.map} +1 -1
- package/dist/{chunk-EPMSC67U.js → chunk-LB7UOP2X.js} +376 -7
- package/dist/chunk-LB7UOP2X.js.map +1 -0
- package/dist/{chunk-URBPEE67.js → chunk-MCRIVYUB.js} +3 -3
- package/dist/{chunk-URBPEE67.js.map → chunk-MCRIVYUB.js.map} +1 -1
- package/dist/{chunk-AZQMPE7G.cjs → chunk-MRFUISXC.cjs} +3 -3
- package/dist/{chunk-AZQMPE7G.cjs.map → chunk-MRFUISXC.cjs.map} +1 -1
- package/dist/{chunk-TLLXRG2Z.js → chunk-OEIVMCWX.js} +3 -3
- package/dist/{chunk-TLLXRG2Z.js.map → chunk-OEIVMCWX.js.map} +1 -1
- package/dist/{chunk-FNSFXWDN.js → chunk-PIHOAJTA.js} +2 -2
- package/dist/chunk-PIHOAJTA.js.map +1 -0
- package/dist/{chunk-ZUWJCGLM.js → chunk-QM5SRDJX.js} +4 -5
- package/dist/chunk-QM5SRDJX.js.map +1 -0
- package/dist/{chunk-Z4Y554NX.js → chunk-QTEIZ2XG.js} +8 -12
- package/dist/chunk-QTEIZ2XG.js.map +1 -0
- package/dist/{chunk-VBKMNIWK.cjs → chunk-RIG4JP3V.cjs} +11 -11
- package/dist/{chunk-VBKMNIWK.cjs.map → chunk-RIG4JP3V.cjs.map} +1 -1
- package/dist/{chunk-5T53HHNP.js → chunk-SLX3NVAC.js} +4 -4
- package/dist/{chunk-5T53HHNP.js.map → chunk-SLX3NVAC.js.map} +1 -1
- package/dist/{chunk-TQB2HMEC.cjs → chunk-SVLMF4UZ.cjs} +44 -45
- package/dist/chunk-SVLMF4UZ.cjs.map +1 -0
- package/dist/{chunk-3EYBRHB2.cjs → chunk-UVM27J4A.cjs} +2 -2
- package/dist/chunk-UVM27J4A.cjs.map +1 -0
- package/dist/{chunk-GZ6MCDK2.js → chunk-VQ3FTSRC.js} +379 -5
- package/dist/chunk-VQ3FTSRC.js.map +1 -0
- package/dist/{chunk-YBEW5YWC.cjs → chunk-VRFSEZBA.cjs} +6 -6
- package/dist/{chunk-YBEW5YWC.cjs.map → chunk-VRFSEZBA.cjs.map} +1 -1
- package/dist/{chunk-RBBEMTMA.cjs → chunk-XMT5T4F2.cjs} +184 -89
- package/dist/chunk-XMT5T4F2.cjs.map +1 -0
- package/dist/{chunk-G32WDDGV.js → chunk-ZINZHEXZ.js} +282 -9
- package/dist/chunk-ZINZHEXZ.js.map +1 -0
- package/dist/evals/index.cjs +9 -9
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/evals/types.d.ts +21 -20
- package/dist/evals/types.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/llm/index.cjs +11 -11
- package/dist/llm/index.js +3 -3
- 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-types.generated.d.ts +180 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +2 -2
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/types.d.ts +1 -0
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +191 -5
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +6 -6
- package/dist/memory/index.js +1 -1
- package/dist/memory/memory.d.ts +6 -0
- package/dist/memory/memory.d.ts.map +1 -1
- package/dist/models-dev-23RN2WHG.js +3 -0
- package/dist/{models-dev-6GD3644V.js.map → models-dev-23RN2WHG.js.map} +1 -1
- package/dist/models-dev-EO3SUIY2.cjs +12 -0
- package/dist/{models-dev-IUQBXJSS.cjs.map → models-dev-EO3SUIY2.cjs.map} +1 -1
- package/dist/observability/index.cjs +10 -10
- package/dist/observability/index.js +1 -1
- package/dist/observability/types/tracing.d.ts +4 -0
- package/dist/observability/types/tracing.d.ts.map +1 -1
- package/dist/processors/index.cjs +17 -17
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-FM3IVY6C.js +3 -0
- package/dist/{provider-registry-ZTMZMTVV.js.map → provider-registry-FM3IVY6C.js.map} +1 -1
- package/dist/provider-registry-Q6T32VC5.cjs +40 -0
- package/dist/{provider-registry-7IFOXWPR.cjs.map → provider-registry-Q6T32VC5.cjs.map} +1 -1
- package/dist/provider-registry.json +376 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +1 -1
- package/dist/storage/base.d.ts +50 -2
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/constants.d.ts +3 -1
- package/dist/storage/constants.d.ts.map +1 -1
- package/dist/storage/domains/agents/base.d.ts +49 -0
- package/dist/storage/domains/agents/base.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts +3 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -0
- package/dist/storage/domains/agents/inmemory.d.ts +22 -0
- package/dist/storage/domains/agents/inmemory.d.ts.map +1 -0
- package/dist/storage/domains/index.d.ts +1 -0
- package/dist/storage/domains/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/scores/base.d.ts +2 -2
- package/dist/storage/domains/scores/base.d.ts.map +1 -1
- package/dist/storage/domains/scores/inmemory.d.ts +2 -2
- package/dist/storage/domains/scores/inmemory.d.ts.map +1 -1
- package/dist/storage/index.cjs +50 -34
- package/dist/storage/index.js +1 -1
- package/dist/storage/mock.d.ts +3 -2
- package/dist/storage/mock.d.ts.map +1 -1
- package/dist/storage/types.d.ts +82 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/base/output-format-handlers.d.ts +13 -0
- package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
- package/dist/stream/index.cjs +15 -11
- package/dist/stream/index.d.ts +1 -1
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +2 -2
- package/dist/test-utils/llm-mock.cjs +10 -10
- package/dist/test-utils/llm-mock.js +3 -3
- package/dist/utils.cjs +22 -22
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +1 -1
- package/dist/workflows/default.d.ts +2 -2
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/step-executor.d.ts.map +1 -1
- package/dist/workflows/handlers/control-flow.d.ts.map +1 -1
- package/dist/workflows/handlers/step.d.ts.map +1 -1
- package/dist/workflows/index.cjs +24 -20
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/step.d.ts +4 -3
- package/dist/workflows/step.d.ts.map +1 -1
- package/dist/workflows/utils.d.ts +10 -1
- package/dist/workflows/utils.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +3 -3
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/llm/model/provider-types.generated.d.ts +180 -1
- package/dist/chunk-26YAGTXK.cjs.map +0 -1
- package/dist/chunk-3EYBRHB2.cjs.map +0 -1
- package/dist/chunk-EPMSC67U.js.map +0 -1
- package/dist/chunk-FNSFXWDN.js.map +0 -1
- package/dist/chunk-G32WDDGV.js.map +0 -1
- package/dist/chunk-GZ6MCDK2.js.map +0 -1
- package/dist/chunk-M7CQULF7.cjs.map +0 -1
- package/dist/chunk-PJ7AYWAX.cjs.map +0 -1
- package/dist/chunk-POM7FCH5.js.map +0 -1
- package/dist/chunk-RBBEMTMA.cjs.map +0 -1
- package/dist/chunk-TQB2HMEC.cjs.map +0 -1
- package/dist/chunk-URMN7TTH.cjs.map +0 -1
- package/dist/chunk-Z4Y554NX.js.map +0 -1
- package/dist/chunk-ZUWJCGLM.js.map +0 -1
- package/dist/models-dev-6GD3644V.js +0 -3
- package/dist/models-dev-IUQBXJSS.cjs +0 -12
- package/dist/provider-registry-7IFOXWPR.cjs +0 -40
- package/dist/provider-registry-ZTMZMTVV.js +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVRFSEZBA_cjs = require('./chunk-VRFSEZBA.cjs');
|
|
4
4
|
var chunkTWH4PTDG_cjs = require('./chunk-TWH4PTDG.cjs');
|
|
5
5
|
var chunkDGV2FWB4_cjs = require('./chunk-DGV2FWB4.cjs');
|
|
6
6
|
|
|
@@ -12,6 +12,7 @@ var TABLE_TRACES = "mastra_traces";
|
|
|
12
12
|
var TABLE_RESOURCES = "mastra_resources";
|
|
13
13
|
var TABLE_SCORERS = "mastra_scorers";
|
|
14
14
|
var TABLE_SPANS = "mastra_ai_spans";
|
|
15
|
+
var TABLE_AGENTS = "mastra_agents";
|
|
15
16
|
var SCORERS_SCHEMA = {
|
|
16
17
|
id: { type: "text", nullable: false, primaryKey: true },
|
|
17
18
|
scorerId: { type: "text" },
|
|
@@ -79,6 +80,35 @@ var SPAN_SCHEMA = {
|
|
|
79
80
|
// The time the database record was last updated
|
|
80
81
|
isEvent: { type: "boolean", nullable: false }
|
|
81
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
|
+
};
|
|
82
112
|
var TABLE_SCHEMAS = {
|
|
83
113
|
[TABLE_WORKFLOW_SNAPSHOT]: {
|
|
84
114
|
workflow_name: {
|
|
@@ -139,7 +169,8 @@ var TABLE_SCHEMAS = {
|
|
|
139
169
|
metadata: { type: "jsonb", nullable: true },
|
|
140
170
|
createdAt: { type: "timestamp", nullable: false },
|
|
141
171
|
updatedAt: { type: "timestamp", nullable: false }
|
|
142
|
-
}
|
|
172
|
+
},
|
|
173
|
+
[TABLE_AGENTS]: AGENTS_SCHEMA
|
|
143
174
|
};
|
|
144
175
|
|
|
145
176
|
// src/storage/base.ts
|
|
@@ -213,7 +244,8 @@ var MastraStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
213
244
|
deleteMessages: false,
|
|
214
245
|
observabilityInstance: false,
|
|
215
246
|
indexManagement: false,
|
|
216
|
-
listScoresBySpan: false
|
|
247
|
+
listScoresBySpan: false,
|
|
248
|
+
agents: false
|
|
217
249
|
};
|
|
218
250
|
}
|
|
219
251
|
ensureDate(date) {
|
|
@@ -364,6 +396,14 @@ var MastraStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
364
396
|
})
|
|
365
397
|
);
|
|
366
398
|
}
|
|
399
|
+
if (this.supports.agents) {
|
|
400
|
+
tableCreationTasks.push(
|
|
401
|
+
this.createTable({
|
|
402
|
+
tableName: TABLE_AGENTS,
|
|
403
|
+
schema: TABLE_SCHEMAS[TABLE_AGENTS]
|
|
404
|
+
})
|
|
405
|
+
);
|
|
406
|
+
}
|
|
367
407
|
this.hasInitialized = Promise.all(tableCreationTasks).then(() => true);
|
|
368
408
|
await this.hasInitialized;
|
|
369
409
|
await this?.alterTable?.({
|
|
@@ -610,6 +650,232 @@ var MastraStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
|
610
650
|
text: `Index management is not supported by this storage adapter (${this.constructor.name})`
|
|
611
651
|
});
|
|
612
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* AGENTS STORAGE
|
|
655
|
+
* These methods delegate to the agents store for agent CRUD operations.
|
|
656
|
+
* This enables dynamic creation of agents via Mastra Studio.
|
|
657
|
+
*/
|
|
658
|
+
/**
|
|
659
|
+
* Retrieves an agent by its unique identifier.
|
|
660
|
+
* @param id - The unique identifier of the agent
|
|
661
|
+
* @returns The agent if found, null otherwise
|
|
662
|
+
* @throws {MastraError} if not supported by the storage adapter
|
|
663
|
+
*/
|
|
664
|
+
async getAgentById({ id }) {
|
|
665
|
+
if (this.stores?.agents) {
|
|
666
|
+
return this.stores.agents.getAgentById({ id });
|
|
667
|
+
}
|
|
668
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
669
|
+
id: "MASTRA_STORAGE_GET_AGENT_BY_ID_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
|
+
* Creates a new agent in storage.
|
|
677
|
+
* @param agent - The agent data to create
|
|
678
|
+
* @returns The created agent with timestamps
|
|
679
|
+
* @throws {MastraError} if not supported by the storage adapter
|
|
680
|
+
*/
|
|
681
|
+
async createAgent({ agent }) {
|
|
682
|
+
if (this.stores?.agents) {
|
|
683
|
+
return this.stores.agents.createAgent({ agent });
|
|
684
|
+
}
|
|
685
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
686
|
+
id: "MASTRA_STORAGE_CREATE_AGENT_NOT_SUPPORTED",
|
|
687
|
+
domain: "STORAGE" /* STORAGE */,
|
|
688
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
689
|
+
text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Updates an existing agent in storage.
|
|
694
|
+
* @param id - The unique identifier of the agent to update
|
|
695
|
+
* @param updates - The fields to update
|
|
696
|
+
* @returns The updated agent
|
|
697
|
+
* @throws {MastraError} if not supported by the storage adapter
|
|
698
|
+
*/
|
|
699
|
+
async updateAgent(args) {
|
|
700
|
+
if (this.stores?.agents) {
|
|
701
|
+
return this.stores.agents.updateAgent(args);
|
|
702
|
+
}
|
|
703
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
704
|
+
id: "MASTRA_STORAGE_UPDATE_AGENT_NOT_SUPPORTED",
|
|
705
|
+
domain: "STORAGE" /* STORAGE */,
|
|
706
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
707
|
+
text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Deletes an agent from storage.
|
|
712
|
+
* @param id - The unique identifier of the agent to delete
|
|
713
|
+
* @throws {MastraError} if not supported by the storage adapter
|
|
714
|
+
*/
|
|
715
|
+
async deleteAgent({ id }) {
|
|
716
|
+
if (this.stores?.agents) {
|
|
717
|
+
return this.stores.agents.deleteAgent({ id });
|
|
718
|
+
}
|
|
719
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
720
|
+
id: "MASTRA_STORAGE_DELETE_AGENT_NOT_SUPPORTED",
|
|
721
|
+
domain: "STORAGE" /* STORAGE */,
|
|
722
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
723
|
+
text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Lists all agents with optional pagination.
|
|
728
|
+
* @param args - Pagination and ordering options
|
|
729
|
+
* @returns Paginated list of agents
|
|
730
|
+
* @throws {MastraError} if not supported by the storage adapter
|
|
731
|
+
*/
|
|
732
|
+
async listAgents(args) {
|
|
733
|
+
if (this.stores?.agents) {
|
|
734
|
+
return this.stores.agents.listAgents(args);
|
|
735
|
+
}
|
|
736
|
+
throw new chunkTWH4PTDG_cjs.MastraError({
|
|
737
|
+
id: "MASTRA_STORAGE_LIST_AGENTS_NOT_SUPPORTED",
|
|
738
|
+
domain: "STORAGE" /* STORAGE */,
|
|
739
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
740
|
+
text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
// src/storage/domains/agents/base.ts
|
|
746
|
+
var AgentsStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
|
|
747
|
+
constructor() {
|
|
748
|
+
super({
|
|
749
|
+
component: "STORAGE",
|
|
750
|
+
name: "AGENTS"
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Parses orderBy input for consistent sorting behavior.
|
|
755
|
+
*/
|
|
756
|
+
parseOrderBy(orderBy, defaultDirection = "DESC") {
|
|
757
|
+
return {
|
|
758
|
+
field: orderBy?.field && orderBy.field in AGENT_ORDER_BY_SET ? orderBy.field : "createdAt",
|
|
759
|
+
direction: orderBy?.direction && orderBy.direction in AGENT_SORT_DIRECTION_SET ? orderBy.direction : defaultDirection
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
var AGENT_ORDER_BY_SET = {
|
|
764
|
+
createdAt: true,
|
|
765
|
+
updatedAt: true
|
|
766
|
+
};
|
|
767
|
+
var AGENT_SORT_DIRECTION_SET = {
|
|
768
|
+
ASC: true,
|
|
769
|
+
DESC: true
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
// src/storage/domains/agents/inmemory.ts
|
|
773
|
+
var InMemoryAgentsStorage = class extends AgentsStorage {
|
|
774
|
+
collection;
|
|
775
|
+
constructor({ collection }) {
|
|
776
|
+
super();
|
|
777
|
+
this.collection = collection;
|
|
778
|
+
}
|
|
779
|
+
async getAgentById({ id }) {
|
|
780
|
+
this.logger.debug(`InMemoryAgentsStorage: getAgentById called for ${id}`);
|
|
781
|
+
const agent = this.collection.get(id);
|
|
782
|
+
return agent ? {
|
|
783
|
+
...agent,
|
|
784
|
+
metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
|
|
785
|
+
model: { ...agent.model },
|
|
786
|
+
tools: agent.tools ? [...agent.tools] : agent.tools,
|
|
787
|
+
workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
|
|
788
|
+
agents: agent.agents ? [...agent.agents] : agent.agents,
|
|
789
|
+
scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
|
|
790
|
+
} : null;
|
|
791
|
+
}
|
|
792
|
+
async createAgent({ agent }) {
|
|
793
|
+
this.logger.debug(`InMemoryAgentsStorage: createAgent called for ${agent.id}`);
|
|
794
|
+
if (this.collection.has(agent.id)) {
|
|
795
|
+
throw new Error(`Agent with id ${agent.id} already exists`);
|
|
796
|
+
}
|
|
797
|
+
const now = /* @__PURE__ */ new Date();
|
|
798
|
+
const newAgent = {
|
|
799
|
+
...agent,
|
|
800
|
+
createdAt: now,
|
|
801
|
+
updatedAt: now
|
|
802
|
+
};
|
|
803
|
+
this.collection.set(agent.id, newAgent);
|
|
804
|
+
return { ...newAgent };
|
|
805
|
+
}
|
|
806
|
+
async updateAgent({ id, ...updates }) {
|
|
807
|
+
this.logger.debug(`InMemoryAgentsStorage: updateAgent called for ${id}`);
|
|
808
|
+
const existingAgent = this.collection.get(id);
|
|
809
|
+
if (!existingAgent) {
|
|
810
|
+
throw new Error(`Agent with id ${id} not found`);
|
|
811
|
+
}
|
|
812
|
+
const updatedAgent = {
|
|
813
|
+
...existingAgent,
|
|
814
|
+
...updates.name !== void 0 && { name: updates.name },
|
|
815
|
+
...updates.description !== void 0 && { description: updates.description },
|
|
816
|
+
...updates.instructions !== void 0 && { instructions: updates.instructions },
|
|
817
|
+
...updates.model !== void 0 && { model: updates.model },
|
|
818
|
+
...updates.tools !== void 0 && { tools: updates.tools },
|
|
819
|
+
...updates.defaultOptions !== void 0 && {
|
|
820
|
+
defaultOptions: updates.defaultOptions
|
|
821
|
+
},
|
|
822
|
+
...updates.workflows !== void 0 && { workflows: updates.workflows },
|
|
823
|
+
...updates.agents !== void 0 && { agents: updates.agents },
|
|
824
|
+
...updates.inputProcessors !== void 0 && { inputProcessors: updates.inputProcessors },
|
|
825
|
+
...updates.outputProcessors !== void 0 && { outputProcessors: updates.outputProcessors },
|
|
826
|
+
...updates.memory !== void 0 && { memory: updates.memory },
|
|
827
|
+
...updates.scorers !== void 0 && { scorers: updates.scorers },
|
|
828
|
+
...updates.metadata !== void 0 && {
|
|
829
|
+
metadata: { ...existingAgent.metadata, ...updates.metadata }
|
|
830
|
+
},
|
|
831
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
832
|
+
};
|
|
833
|
+
this.collection.set(id, updatedAgent);
|
|
834
|
+
return { ...updatedAgent };
|
|
835
|
+
}
|
|
836
|
+
async deleteAgent({ id }) {
|
|
837
|
+
this.logger.debug(`InMemoryAgentsStorage: deleteAgent called for ${id}`);
|
|
838
|
+
this.collection.delete(id);
|
|
839
|
+
}
|
|
840
|
+
async listAgents(args) {
|
|
841
|
+
const { page = 0, perPage: perPageInput, orderBy } = args || {};
|
|
842
|
+
const { field, direction } = this.parseOrderBy(orderBy);
|
|
843
|
+
this.logger.debug(`InMemoryAgentsStorage: listAgents called`);
|
|
844
|
+
const perPage = normalizePerPage(perPageInput, 100);
|
|
845
|
+
if (page < 0) {
|
|
846
|
+
throw new Error("page must be >= 0");
|
|
847
|
+
}
|
|
848
|
+
const maxOffset = Number.MAX_SAFE_INTEGER / 2;
|
|
849
|
+
if (page * perPage > maxOffset) {
|
|
850
|
+
throw new Error("page value too large");
|
|
851
|
+
}
|
|
852
|
+
const agents = Array.from(this.collection.values());
|
|
853
|
+
const sortedAgents = this.sortAgents(agents, field, direction);
|
|
854
|
+
const clonedAgents = sortedAgents.map((agent) => ({
|
|
855
|
+
...agent,
|
|
856
|
+
metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
|
|
857
|
+
model: { ...agent.model },
|
|
858
|
+
tools: agent.tools ? [...agent.tools] : agent.tools,
|
|
859
|
+
workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
|
|
860
|
+
agents: agent.agents ? [...agent.agents] : agent.agents,
|
|
861
|
+
scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
|
|
862
|
+
}));
|
|
863
|
+
const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
864
|
+
return {
|
|
865
|
+
agents: clonedAgents.slice(offset, offset + perPage),
|
|
866
|
+
total: clonedAgents.length,
|
|
867
|
+
page,
|
|
868
|
+
perPage: perPageForResponse,
|
|
869
|
+
hasMore: offset + perPage < clonedAgents.length
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
sortAgents(agents, field, direction) {
|
|
873
|
+
return agents.sort((a, b) => {
|
|
874
|
+
const aValue = new Date(a[field]).getTime();
|
|
875
|
+
const bValue = new Date(b[field]).getTime();
|
|
876
|
+
return direction === "ASC" ? aValue - bValue : bValue - aValue;
|
|
877
|
+
});
|
|
878
|
+
}
|
|
613
879
|
};
|
|
614
880
|
|
|
615
881
|
// src/storage/utils.ts
|
|
@@ -945,7 +1211,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
945
1211
|
async listMessagesById({ messageIds }) {
|
|
946
1212
|
this.logger.debug(`MockStore: listMessagesById called`);
|
|
947
1213
|
const rawMessages = messageIds.map((id) => this.collection.messages.get(id)).filter((message) => !!message);
|
|
948
|
-
const list = new
|
|
1214
|
+
const list = new chunkVRFSEZBA_cjs.MessageList().add(rawMessages.map(this.parseStoredMessage), "memory");
|
|
949
1215
|
return { messages: list.get.all.db() };
|
|
950
1216
|
}
|
|
951
1217
|
async saveMessages(args) {
|
|
@@ -974,7 +1240,7 @@ var InMemoryMemory = class extends MemoryStorage {
|
|
|
974
1240
|
};
|
|
975
1241
|
this.collection.messages.set(key, storageMessage);
|
|
976
1242
|
}
|
|
977
|
-
const list = new
|
|
1243
|
+
const list = new chunkVRFSEZBA_cjs.MessageList().add(messages, "memory");
|
|
978
1244
|
return { messages: list.get.all.db() };
|
|
979
1245
|
}
|
|
980
1246
|
async updateMessages(args) {
|
|
@@ -1498,7 +1764,8 @@ var StoreOperationsInMemory = class extends StoreOperations {
|
|
|
1498
1764
|
mastra_traces: /* @__PURE__ */ new Map(),
|
|
1499
1765
|
mastra_resources: /* @__PURE__ */ new Map(),
|
|
1500
1766
|
mastra_scorers: /* @__PURE__ */ new Map(),
|
|
1501
|
-
mastra_ai_spans: /* @__PURE__ */ new Map()
|
|
1767
|
+
mastra_ai_spans: /* @__PURE__ */ new Map(),
|
|
1768
|
+
mastra_agents: /* @__PURE__ */ new Map()
|
|
1502
1769
|
};
|
|
1503
1770
|
}
|
|
1504
1771
|
getDatabase() {
|
|
@@ -1944,12 +2211,17 @@ var InMemoryStore = class extends MastraStorage {
|
|
|
1944
2211
|
collection: database.mastra_ai_spans,
|
|
1945
2212
|
operations: operationsStorage
|
|
1946
2213
|
});
|
|
2214
|
+
const agentsCollection = /* @__PURE__ */ new Map();
|
|
2215
|
+
const agentsStorage = new InMemoryAgentsStorage({
|
|
2216
|
+
collection: agentsCollection
|
|
2217
|
+
});
|
|
1947
2218
|
this.stores = {
|
|
1948
2219
|
operations: operationsStorage,
|
|
1949
2220
|
workflows: workflowsStorage,
|
|
1950
2221
|
scores: scoresStorage,
|
|
1951
2222
|
memory: memoryStorage,
|
|
1952
|
-
observability: observabilityStorage
|
|
2223
|
+
observability: observabilityStorage,
|
|
2224
|
+
agents: agentsStorage
|
|
1953
2225
|
};
|
|
1954
2226
|
}
|
|
1955
2227
|
get supports() {
|
|
@@ -1961,7 +2233,8 @@ var InMemoryStore = class extends MastraStorage {
|
|
|
1961
2233
|
deleteMessages: true,
|
|
1962
2234
|
observabilityInstance: true,
|
|
1963
2235
|
indexManagement: false,
|
|
1964
|
-
listScoresBySpan: true
|
|
2236
|
+
listScoresBySpan: true,
|
|
2237
|
+
agents: true
|
|
1965
2238
|
};
|
|
1966
2239
|
}
|
|
1967
2240
|
async persistWorkflowSnapshot({
|
|
@@ -2125,6 +2398,9 @@ var InMemoryStore = class extends MastraStorage {
|
|
|
2125
2398
|
};
|
|
2126
2399
|
var MockStore = InMemoryStore;
|
|
2127
2400
|
|
|
2401
|
+
exports.AGENTS_SCHEMA = AGENTS_SCHEMA;
|
|
2402
|
+
exports.AgentsStorage = AgentsStorage;
|
|
2403
|
+
exports.InMemoryAgentsStorage = InMemoryAgentsStorage;
|
|
2128
2404
|
exports.InMemoryMemory = InMemoryMemory;
|
|
2129
2405
|
exports.InMemoryStore = InMemoryStore;
|
|
2130
2406
|
exports.MastraStorage = MastraStorage;
|
|
@@ -2138,6 +2414,7 @@ exports.ScoresInMemory = ScoresInMemory;
|
|
|
2138
2414
|
exports.ScoresStorage = ScoresStorage;
|
|
2139
2415
|
exports.StoreOperations = StoreOperations;
|
|
2140
2416
|
exports.StoreOperationsInMemory = StoreOperationsInMemory;
|
|
2417
|
+
exports.TABLE_AGENTS = TABLE_AGENTS;
|
|
2141
2418
|
exports.TABLE_MESSAGES = TABLE_MESSAGES;
|
|
2142
2419
|
exports.TABLE_RESOURCES = TABLE_RESOURCES;
|
|
2143
2420
|
exports.TABLE_SCHEMAS = TABLE_SCHEMAS;
|
|
@@ -2158,5 +2435,5 @@ exports.safelyParseJSON = safelyParseJSON;
|
|
|
2158
2435
|
exports.serializeDate = serializeDate;
|
|
2159
2436
|
exports.transformRow = transformRow;
|
|
2160
2437
|
exports.transformScoreRow = transformScoreRow;
|
|
2161
|
-
//# sourceMappingURL=chunk-
|
|
2162
|
-
//# sourceMappingURL=chunk-
|
|
2438
|
+
//# sourceMappingURL=chunk-7S7TLMTS.cjs.map
|
|
2439
|
+
//# sourceMappingURL=chunk-7S7TLMTS.cjs.map
|