@mastra/client-js 0.1.20 → 0.1.21-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- > @mastra/client-js@0.1.20-alpha.6 build /home/runner/work/mastra/mastra/client-sdks/client-js
2
+ > @mastra/client-js@0.1.21-alpha.1 build /home/runner/work/mastra/mastra/client-sdks/client-js
3
3
  > tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -9,11 +9,11 @@
9
9
  CLI Cleaning output folder
10
10
  ESM Build start
11
11
  CJS Build start
12
- CJS dist/index.cjs 34.65 KB
13
- CJS ⚡️ Build success in 1542ms
14
- ESM dist/index.js 34.43 KB
15
- ESM ⚡️ Build success in 1566ms
12
+ CJS dist/index.cjs 35.18 KB
13
+ CJS ⚡️ Build success in 1141ms
14
+ ESM dist/index.js 34.95 KB
15
+ ESM ⚡️ Build success in 1145ms
16
16
  DTS Build start
17
- DTS ⚡️ Build success in 14884ms
17
+ DTS ⚡️ Build success in 14023ms
18
18
  DTS dist/index.d.ts 25.12 KB
19
19
  DTS dist/index.d.cts 25.12 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 0.1.21-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 36eb1aa: Fix AGUI text part
8
+ - 62c9e7d: Fix disappearing tool calls in streaming
9
+ - Updated dependencies [e450778]
10
+ - Updated dependencies [8902157]
11
+ - Updated dependencies [ca0dc88]
12
+ - Updated dependencies [9cd1a46]
13
+ - Updated dependencies [70dbf51]
14
+ - @mastra/core@0.9.3-alpha.1
15
+
16
+ ## 0.1.21-alpha.0
17
+
18
+ ### Patch Changes
19
+
20
+ - 526c570: expose agent runtimeContext from clientSDK
21
+ - Updated dependencies [526c570]
22
+ - Updated dependencies [b5d2de0]
23
+ - Updated dependencies [644f8ad]
24
+ - @mastra/core@0.9.3-alpha.0
25
+
3
26
  ## 0.1.20
4
27
 
5
28
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -44,6 +44,7 @@ var AGUIAdapter = class extends client.AbstractAgent {
44
44
  )
45
45
  }).then((response) => {
46
46
  let currentMessageId = void 0;
47
+ let isInTextMessage = false;
47
48
  return response.processDataStream({
48
49
  onTextPart: (text) => {
49
50
  if (currentMessageId === void 0) {
@@ -54,6 +55,7 @@ var AGUIAdapter = class extends client.AbstractAgent {
54
55
  role: "assistant"
55
56
  };
56
57
  subscriber.next(message2);
58
+ isInTextMessage = true;
57
59
  }
58
60
  const message = {
59
61
  type: client.EventType.TEXT_MESSAGE_CONTENT,
@@ -62,14 +64,14 @@ var AGUIAdapter = class extends client.AbstractAgent {
62
64
  };
63
65
  subscriber.next(message);
64
66
  },
65
- onFinishMessagePart: (message) => {
66
- console.log("onFinishMessagePart", message);
67
+ onFinishMessagePart: () => {
67
68
  if (currentMessageId !== void 0) {
68
- const message2 = {
69
+ const message = {
69
70
  type: client.EventType.TEXT_MESSAGE_END,
70
71
  messageId: currentMessageId
71
72
  };
72
- subscriber.next(message2);
73
+ subscriber.next(message);
74
+ isInTextMessage = false;
73
75
  }
74
76
  subscriber.next({
75
77
  type: client.EventType.RUN_FINISHED,
@@ -80,6 +82,14 @@ var AGUIAdapter = class extends client.AbstractAgent {
80
82
  },
81
83
  onToolCallPart(streamPart) {
82
84
  const parentMessageId = currentMessageId || generateUUID();
85
+ if (isInTextMessage) {
86
+ const message = {
87
+ type: client.EventType.TEXT_MESSAGE_END,
88
+ messageId: parentMessageId
89
+ };
90
+ subscriber.next(message);
91
+ isInTextMessage = false;
92
+ }
83
93
  subscriber.next({
84
94
  type: client.EventType.TOOL_CALL_START,
85
95
  toolCallId: streamPart.toolCallId,
@@ -100,7 +110,7 @@ var AGUIAdapter = class extends client.AbstractAgent {
100
110
  }
101
111
  });
102
112
  }).catch((error) => {
103
- console.log("error", error);
113
+ console.error("error", error);
104
114
  subscriber.error(error);
105
115
  });
106
116
  return () => {
@@ -301,7 +311,8 @@ var Agent = class extends BaseResource {
301
311
  const processedParams = {
302
312
  ...params,
303
313
  output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
304
- experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
314
+ experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output,
315
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
305
316
  };
306
317
  return this.request(`/api/agents/${this.agentId}/generate`, {
307
318
  method: "POST",
@@ -317,7 +328,8 @@ var Agent = class extends BaseResource {
317
328
  const processedParams = {
318
329
  ...params,
319
330
  output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
320
- experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
331
+ experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output,
332
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
321
333
  };
322
334
  const response = await this.request(`/api/agents/${this.agentId}/stream`, {
323
335
  method: "POST",
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ var AGUIAdapter = class extends AbstractAgent {
42
42
  )
43
43
  }).then((response) => {
44
44
  let currentMessageId = void 0;
45
+ let isInTextMessage = false;
45
46
  return response.processDataStream({
46
47
  onTextPart: (text) => {
47
48
  if (currentMessageId === void 0) {
@@ -52,6 +53,7 @@ var AGUIAdapter = class extends AbstractAgent {
52
53
  role: "assistant"
53
54
  };
54
55
  subscriber.next(message2);
56
+ isInTextMessage = true;
55
57
  }
56
58
  const message = {
57
59
  type: EventType.TEXT_MESSAGE_CONTENT,
@@ -60,14 +62,14 @@ var AGUIAdapter = class extends AbstractAgent {
60
62
  };
61
63
  subscriber.next(message);
62
64
  },
63
- onFinishMessagePart: (message) => {
64
- console.log("onFinishMessagePart", message);
65
+ onFinishMessagePart: () => {
65
66
  if (currentMessageId !== void 0) {
66
- const message2 = {
67
+ const message = {
67
68
  type: EventType.TEXT_MESSAGE_END,
68
69
  messageId: currentMessageId
69
70
  };
70
- subscriber.next(message2);
71
+ subscriber.next(message);
72
+ isInTextMessage = false;
71
73
  }
72
74
  subscriber.next({
73
75
  type: EventType.RUN_FINISHED,
@@ -78,6 +80,14 @@ var AGUIAdapter = class extends AbstractAgent {
78
80
  },
79
81
  onToolCallPart(streamPart) {
80
82
  const parentMessageId = currentMessageId || generateUUID();
83
+ if (isInTextMessage) {
84
+ const message = {
85
+ type: EventType.TEXT_MESSAGE_END,
86
+ messageId: parentMessageId
87
+ };
88
+ subscriber.next(message);
89
+ isInTextMessage = false;
90
+ }
81
91
  subscriber.next({
82
92
  type: EventType.TOOL_CALL_START,
83
93
  toolCallId: streamPart.toolCallId,
@@ -98,7 +108,7 @@ var AGUIAdapter = class extends AbstractAgent {
98
108
  }
99
109
  });
100
110
  }).catch((error) => {
101
- console.log("error", error);
111
+ console.error("error", error);
102
112
  subscriber.error(error);
103
113
  });
104
114
  return () => {
@@ -299,7 +309,8 @@ var Agent = class extends BaseResource {
299
309
  const processedParams = {
300
310
  ...params,
301
311
  output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
302
- experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output
312
+ experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output,
313
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
303
314
  };
304
315
  return this.request(`/api/agents/${this.agentId}/generate`, {
305
316
  method: "POST",
@@ -315,7 +326,8 @@ var Agent = class extends BaseResource {
315
326
  const processedParams = {
316
327
  ...params,
317
328
  output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
318
- experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output
329
+ experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output,
330
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
319
331
  };
320
332
  const response = await this.request(`/api/agents/${this.agentId}/stream`, {
321
333
  method: "POST",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.1.20",
3
+ "version": "0.1.21-alpha.1",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  "rxjs": "7.8.1",
29
29
  "zod": "^3.24.3",
30
30
  "zod-to-json-schema": "^3.24.5",
31
- "@mastra/core": "^0.9.2"
31
+ "@mastra/core": "^0.9.3-alpha.1"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "zod": "^3.24.2"
@@ -66,17 +66,18 @@ export class AGUIAdapter extends AbstractAgent {
66
66
  })
67
67
  .then(response => {
68
68
  let currentMessageId: string | undefined = undefined;
69
+ let isInTextMessage = false;
69
70
  return response.processDataStream({
70
71
  onTextPart: text => {
71
72
  if (currentMessageId === undefined) {
72
73
  currentMessageId = generateUUID();
73
-
74
74
  const message: TextMessageStartEvent = {
75
75
  type: EventType.TEXT_MESSAGE_START,
76
76
  messageId: currentMessageId,
77
77
  role: 'assistant',
78
78
  };
79
79
  subscriber.next(message);
80
+ isInTextMessage = true;
80
81
  }
81
82
 
82
83
  const message: TextMessageContentEvent = {
@@ -86,14 +87,14 @@ export class AGUIAdapter extends AbstractAgent {
86
87
  };
87
88
  subscriber.next(message);
88
89
  },
89
- onFinishMessagePart: message => {
90
- console.log('onFinishMessagePart', message);
90
+ onFinishMessagePart: () => {
91
91
  if (currentMessageId !== undefined) {
92
92
  const message: TextMessageEndEvent = {
93
93
  type: EventType.TEXT_MESSAGE_END,
94
94
  messageId: currentMessageId,
95
95
  };
96
96
  subscriber.next(message);
97
+ isInTextMessage = false;
97
98
  }
98
99
  // Emit run finished event
99
100
  subscriber.next({
@@ -107,6 +108,15 @@ export class AGUIAdapter extends AbstractAgent {
107
108
  },
108
109
  onToolCallPart(streamPart) {
109
110
  const parentMessageId = currentMessageId || generateUUID();
111
+ if (isInTextMessage) {
112
+ const message: TextMessageEndEvent = {
113
+ type: EventType.TEXT_MESSAGE_END,
114
+ messageId: parentMessageId,
115
+ };
116
+ subscriber.next(message);
117
+ isInTextMessage = false;
118
+ }
119
+
110
120
  subscriber.next({
111
121
  type: EventType.TOOL_CALL_START,
112
122
  toolCallId: streamPart.toolCallId,
@@ -130,7 +140,7 @@ export class AGUIAdapter extends AbstractAgent {
130
140
  });
131
141
  })
132
142
  .catch(error => {
133
- console.log('error', error);
143
+ console.error('error', error);
134
144
  // Handle error
135
145
  subscriber.error(error);
136
146
  });
@@ -126,6 +126,7 @@ export class Agent extends BaseResource {
126
126
  params.experimental_output instanceof ZodSchema
127
127
  ? zodToJsonSchema(params.experimental_output)
128
128
  : params.experimental_output,
129
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined,
129
130
  };
130
131
 
131
132
  return this.request(`/api/agents/${this.agentId}/generate`, {
@@ -153,6 +154,7 @@ export class Agent extends BaseResource {
153
154
  params.experimental_output instanceof ZodSchema
154
155
  ? zodToJsonSchema(params.experimental_output)
155
156
  : params.experimental_output,
157
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined,
156
158
  };
157
159
 
158
160
  const response: Response & {