Skip to content

Commit 51defb1

Browse files
committed
TEMP: UNDO ME: Debug
1 parent 19fc314 commit 51defb1

File tree

5 files changed

+146
-5204
lines changed

5 files changed

+146
-5204
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export const mastra = new Mastra({
1717
}),
1818
logger: new PinoLogger({
1919
name: "Mastra",
20-
level: "info",
20+
level: "debug",
2121
}),
2222
});

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Agent as LocalMastraAgent } from "@mastra/core/agent";
1818
import { RuntimeContext } from "@mastra/core/runtime-context";
1919
import { randomUUID } from "crypto";
2020
import { Observable } from "rxjs";
21+
import util from "util";
2122
import { MastraClient } from "@mastra/client-js";
2223
type RemoteMastraAgent = ReturnType<MastraClient["getAgent"]>;
2324
import {
@@ -70,6 +71,8 @@ export class MastraAgent extends AbstractAgent {
7071
runId: input.runId,
7172
};
7273

74+
console.log("runStartedEvent", runStartedEvent);
75+
7376
subscriber.next(runStartedEvent);
7477

7578
// Handle local agent memory management (from Mastra implementation)
@@ -118,6 +121,7 @@ export class MastraAgent extends AbstractAgent {
118121
messageId,
119122
delta: text,
120123
};
124+
console.log("textMessageChunkEvent", util.inspect(event, { depth: null }));
121125
subscriber.next(event);
122126
},
123127
onToolCallPart: (streamPart) => {
@@ -127,19 +131,22 @@ export class MastraAgent extends AbstractAgent {
127131
toolCallId: streamPart.toolCallId,
128132
toolCallName: streamPart.toolName,
129133
};
134+
console.log("toolCallStartEvent", util.inspect(startEvent, { depth: null }));
130135
subscriber.next(startEvent);
131136

132137
const argsEvent: ToolCallArgsEvent = {
133138
type: EventType.TOOL_CALL_ARGS,
134139
toolCallId: streamPart.toolCallId,
135140
delta: JSON.stringify(streamPart.args),
136141
};
142+
console.log("toolCallArgsEvent", util.inspect(argsEvent, { depth: null }));
137143
subscriber.next(argsEvent);
138144

139145
const endEvent: ToolCallEndEvent = {
140146
type: EventType.TOOL_CALL_END,
141147
toolCallId: streamPart.toolCallId,
142148
};
149+
console.log("toolCallEndEvent", util.inspect(endEvent, { depth: null }));
143150
subscriber.next(endEvent);
144151
},
145152
onToolResultPart(streamPart) {
@@ -151,6 +158,11 @@ export class MastraAgent extends AbstractAgent {
151158
role: "tool",
152159
};
153160

161+
console.log(
162+
"toolCallResultEvent",
163+
util.inspect(toolCallResultEvent, { depth: null }),
164+
);
165+
154166
subscriber.next(toolCallResultEvent);
155167
},
156168
onFinishMessagePart: async () => {
@@ -162,6 +174,7 @@ export class MastraAgent extends AbstractAgent {
162174
subscriber.error(error);
163175
},
164176
onRunFinished: async () => {
177+
console.log("onRunFinished");
165178
if (this.isLocalMastraAgent(this.agent)) {
166179
try {
167180
const memory = await this.agent.getMemory();
@@ -248,9 +261,11 @@ export class MastraAgent extends AbstractAgent {
248261
},
249262
{} as Record<string, any>,
250263
);
264+
console.log("clientTools", util.inspect(clientTools, { depth: null }));
251265
const resourceId = this.resourceId ?? threadId;
252266
const convertedMessages = convertAGUIMessagesToMastra(messages);
253267
const runtimeContext = this.runtimeContext;
268+
console.log("runtimeContext", runtimeContext);
254269

255270
if (this.isLocalMastraAgent(this.agent)) {
256271
// Local agent - use the agent's stream method directly
@@ -286,13 +301,15 @@ export class MastraAgent extends AbstractAgent {
286301
}
287302
} else {
288303
// If it's already a readable stream, process it directly
289-
await processDataStream({
304+
const postProcessedResponse = await processDataStream({
290305
stream: response as any,
291306
onTextPart,
292307
onToolCallPart,
293308
onToolResultPart,
294309
onFinishMessagePart,
295310
});
311+
console.log("data stream processed");
312+
console.log("postProcessedResponse", util.inspect(postProcessedResponse, { depth: null }));
296313
await onRunFinished?.();
297314
}
298315
} else {
@@ -312,14 +329,22 @@ export class MastraAgent extends AbstractAgent {
312329
clientTools,
313330
});
314331

332+
console.log("response", util.inspect(response, { depth: null }));
333+
315334
// Remote agents should have a processDataStream method
316335
if (response && typeof response.processDataStream === "function") {
317-
await response.processDataStream({
336+
console.log("processing data stream");
337+
const postProcessedResponse = await response.processDataStream({
318338
onTextPart,
319339
onToolCallPart,
320340
onToolResultPart,
321341
onFinishMessagePart,
322342
});
343+
344+
console.log("data stream processed");
345+
346+
console.log("postProcessedResponse", util.inspect(postProcessedResponse, { depth: null }));
347+
323348
await onRunFinished?.();
324349
} else {
325350
throw new Error("Invalid response from remote agent");

typescript-sdk/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,12 @@
2525
"engines": {
2626
"node": ">=18"
2727
},
28-
"version": "0.0.1"
28+
"version": "0.0.1",
29+
"dependencies": {
30+
"@copilotkit/react-core": "link:../../../../Library/pnpm/global/5/node_modules/@copilotkit/react-core",
31+
"@copilotkit/react-ui": "link:../../../../Library/pnpm/global/5/node_modules/@copilotkit/react-ui",
32+
"@copilotkit/runtime": "link:../../../../Library/pnpm/global/5/node_modules/@copilotkit/runtime",
33+
"@copilotkit/runtime-client-gql": "link:../../../../Library/pnpm/global/5/node_modules/@copilotkit/runtime-client-gql",
34+
"@copilotkit/shared": "link:../../../../Library/pnpm/global/5/node_modules/@copilotkit/shared"
35+
}
2936
}

0 commit comments

Comments
 (0)