Skip to content

Commit e8efab7

Browse files
roaminrotylerslaton
authored andcommitted
fix(mastra): update dependencies and fix integration
1 parent 19334f3 commit e8efab7

File tree

3 files changed

+1388
-228
lines changed

3 files changed

+1388
-228
lines changed

typescript-sdk/integrations/mastra/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@
2626
"dependencies": {
2727
"@ag-ui/client": "workspace:*",
2828
"@ai-sdk/ui-utils": "^1.1.19",
29-
"@mastra/client-js": "^0.10.9",
29+
"@mastra/client-js": "^0.10.18",
3030
"rxjs": "7.8.1"
3131
},
3232
"peerDependencies": {
33-
"@copilotkit/runtime": "^1.8.13",
34-
"@mastra/core": "^0.10.10 || ^0.11.1",
33+
"@copilotkit/runtime": "^1.9.3",
34+
"@mastra/core": "^0.11.1 || ^0.12.1",
3535
"zod": "^3.25.67"
3636
},
3737
"devDependencies": {
38-
"@mastra/core": "^0.11.1",
38+
"@mastra/core": "^0.12.1",
3939
"@types/jest": "^29.5.14",
4040
"@types/node": "^20.11.19",
4141
"jest": "^29.7.0",

typescript-sdk/integrations/mastra/src/mastra.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ export class MastraAgent extends AbstractAgent {
7373
subscriber.next(runStartedEvent);
7474

7575
// Handle local agent memory management (from Mastra implementation)
76-
if ("metrics" in this.agent) {
77-
// @ts-ignore
78-
const memory = this.agent.getMemory();
76+
if (this.isLocalMastraAgent(this.agent)) {
77+
const memory = await this.agent.getMemory();
7978

8079
if (memory && input.state && Object.keys(input.state || {}).length > 0) {
8180
let thread: StorageThreadType | null = await memory.getThreadById({
@@ -163,14 +162,12 @@ export class MastraAgent extends AbstractAgent {
163162
subscriber.error(error);
164163
},
165164
onRunFinished: async () => {
166-
if ("metrics" in this.agent) {
165+
if (this.isLocalMastraAgent(this.agent)) {
167166
try {
168-
// @ts-ignore
169-
const memory = this.agent.getMemory();
167+
const memory = await this.agent.getMemory();
170168
if (memory) {
171169
const workingMemory = await memory.getWorkingMemory({
172170
threadId: input.threadId,
173-
// @ts-ignore
174171
memoryConfig: {
175172
workingMemory: {
176173
enabled: true,
@@ -219,6 +216,10 @@ export class MastraAgent extends AbstractAgent {
219216
});
220217
}
221218

219+
isLocalMastraAgent(agent: LocalMastraAgent | RemoteMastraAgent): agent is LocalMastraAgent {
220+
return "getMemory" in agent;
221+
}
222+
222223
/**
223224
* Streams in process or remote mastra agent.
224225
* @param input - The input for the mastra agent.
@@ -251,13 +252,7 @@ export class MastraAgent extends AbstractAgent {
251252
const convertedMessages = convertAGUIMessagesToMastra(messages);
252253
const runtimeContext = this.runtimeContext;
253254

254-
function isLocalMastraAgent(
255-
agent: LocalMastraAgent | RemoteMastraAgent,
256-
): agent is LocalMastraAgent {
257-
return "metrics" in agent;
258-
}
259-
260-
if (isLocalMastraAgent(this.agent)) {
255+
if (this.isLocalMastraAgent(this.agent)) {
261256
// Local agent - use the agent's stream method directly
262257
try {
263258
const response = await this.agent.stream(convertedMessages, {

0 commit comments

Comments
 (0)