@mastra/client-js 0.0.0-custom-instrumentation-20250626084921 → 0.0.0-custom-instrumentation-20250708222033

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.10.7-alpha.0 build /home/runner/work/mastra/mastra/client-sdks/client-js
2
+ > @mastra/client-js@0.10.10 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 67.49 KB
13
- CJS ⚡️ Build success in 1525ms
14
- ESM dist/index.js 67.20 KB
15
- ESM ⚡️ Build success in 1531ms
16
12
  DTS Build start
17
- DTS ⚡️ Build success in 15127ms
18
- DTS dist/index.d.ts 39.62 KB
19
- DTS dist/index.d.cts 39.62 KB
13
+ CJS dist/index.cjs 68.80 KB
14
+ CJS ⚡️ Build success in 1969ms
15
+ ESM dist/index.js 68.51 KB
16
+ ESM ⚡️ Build success in 1974ms
17
+ DTS ⚡️ Build success in 15601ms
18
+ DTS dist/index.d.ts 40.65 KB
19
+ DTS dist/index.d.cts 40.65 KB
package/CHANGELOG.md CHANGED
@@ -1,12 +1,172 @@
1
1
  # @mastra/client-js
2
2
 
3
- ## 0.0.0-custom-instrumentation-20250626084921
3
+ ## 0.0.0-custom-instrumentation-20250708222033
4
+
5
+ ### Patch Changes
6
+
7
+ - @mastra/core@0.0.0-custom-instrumentation-20250708222033
8
+
9
+ ## 0.10.10
10
+
11
+ ### Patch Changes
12
+
13
+ - 18da791: Add abortSignal to client SDK options
14
+ - Updated dependencies [2873c7f]
15
+ - Updated dependencies [1c1c6a1]
16
+ - Updated dependencies [f8ce2cc]
17
+ - Updated dependencies [8c846b6]
18
+ - Updated dependencies [c7bbf1e]
19
+ - Updated dependencies [8722d53]
20
+ - Updated dependencies [565cc0c]
21
+ - Updated dependencies [b790fd1]
22
+ - Updated dependencies [132027f]
23
+ - Updated dependencies [0c85311]
24
+ - Updated dependencies [d7ed04d]
25
+ - Updated dependencies [cb16baf]
26
+ - Updated dependencies [f36e4f1]
27
+ - Updated dependencies [7f6e403]
28
+ - @mastra/core@0.10.11
29
+
30
+ ## 0.10.10-alpha.4
31
+
32
+ ### Patch Changes
33
+
34
+ - @mastra/core@0.10.11-alpha.4
35
+
36
+ ## 0.10.10-alpha.3
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [c7bbf1e]
41
+ - Updated dependencies [8722d53]
42
+ - Updated dependencies [132027f]
43
+ - Updated dependencies [0c85311]
44
+ - Updated dependencies [cb16baf]
45
+ - @mastra/core@0.10.11-alpha.3
46
+
47
+ ## 0.10.10-alpha.2
48
+
49
+ ### Patch Changes
50
+
51
+ - 18da791: Add abortSignal to client SDK options
52
+ - Updated dependencies [2873c7f]
53
+ - Updated dependencies [1c1c6a1]
54
+ - Updated dependencies [565cc0c]
55
+ - @mastra/core@0.10.11-alpha.2
56
+
57
+ ## 0.10.10-alpha.1
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [7f6e403]
62
+ - @mastra/core@0.10.11-alpha.1
63
+
64
+ ## 0.10.10-alpha.0
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [f8ce2cc]
69
+ - Updated dependencies [8c846b6]
70
+ - Updated dependencies [b790fd1]
71
+ - Updated dependencies [d7ed04d]
72
+ - Updated dependencies [f36e4f1]
73
+ - @mastra/core@0.10.11-alpha.0
74
+
75
+ ## 0.10.9
76
+
77
+ ### Patch Changes
78
+
79
+ - b60f510: Fix getWorkflowRuns by limit and offset
80
+ - 6997af1: add send event to server, deployer, client-js and playground-ui
81
+ - Updated dependencies [4d3fbdf]
82
+ - @mastra/core@0.10.10
83
+
84
+ ## 0.10.9-alpha.1
85
+
86
+ ### Patch Changes
87
+
88
+ - b60f510: Fix getWorkflowRuns by limit and offset
89
+ - 6997af1: add send event to server, deployer, client-js and playground-ui
90
+ - @mastra/core@0.10.10-alpha.1
91
+
92
+ ## 0.10.9-alpha.0
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies [4d3fbdf]
97
+ - @mastra/core@0.10.10-alpha.0
98
+
99
+ ## 0.10.8
100
+
101
+ ### Patch Changes
102
+
103
+ - 9047bda: clientTools - stream tool-result part
104
+ - a606c75: show right suspend schema for nested workflow on playground
105
+ - 1760a1c: Use workflow stream in playground instead of watch
106
+ - 038e5ae: Add cancel workflow run
107
+ - 7e801dd: Add tools to network api response
108
+ - Updated dependencies [9dda1ac]
109
+ - Updated dependencies [c984582]
110
+ - Updated dependencies [7e801dd]
111
+ - Updated dependencies [a606c75]
112
+ - Updated dependencies [7aa70a4]
113
+ - Updated dependencies [764f86a]
114
+ - Updated dependencies [1760a1c]
115
+ - Updated dependencies [038e5ae]
116
+ - Updated dependencies [7dda16a]
117
+ - Updated dependencies [5ebfcdd]
118
+ - Updated dependencies [b2d0c91]
119
+ - Updated dependencies [4e809ad]
120
+ - Updated dependencies [57929df]
121
+ - Updated dependencies [b7852ed]
122
+ - Updated dependencies [6320a61]
123
+ - @mastra/core@0.10.9
124
+
125
+ ## 0.10.8-alpha.0
126
+
127
+ ### Patch Changes
128
+
129
+ - 9047bda: clientTools - stream tool-result part
130
+ - a606c75: show right suspend schema for nested workflow on playground
131
+ - 1760a1c: Use workflow stream in playground instead of watch
132
+ - 038e5ae: Add cancel workflow run
133
+ - 7e801dd: Add tools to network api response
134
+ - Updated dependencies [9dda1ac]
135
+ - Updated dependencies [c984582]
136
+ - Updated dependencies [7e801dd]
137
+ - Updated dependencies [a606c75]
138
+ - Updated dependencies [7aa70a4]
139
+ - Updated dependencies [764f86a]
140
+ - Updated dependencies [1760a1c]
141
+ - Updated dependencies [038e5ae]
142
+ - Updated dependencies [7dda16a]
143
+ - Updated dependencies [5ebfcdd]
144
+ - Updated dependencies [b2d0c91]
145
+ - Updated dependencies [4e809ad]
146
+ - Updated dependencies [57929df]
147
+ - Updated dependencies [b7852ed]
148
+ - Updated dependencies [6320a61]
149
+ - @mastra/core@0.10.9-alpha.0
150
+
151
+ ## 0.10.7
4
152
 
5
153
  ### Patch Changes
6
154
 
7
155
  - a344ac7: Fix tool streaming in agent network
156
+ - Updated dependencies [b8f16b2]
157
+ - Updated dependencies [3e04487]
8
158
  - Updated dependencies [a344ac7]
9
- - @mastra/core@0.0.0-custom-instrumentation-20250626084921
159
+ - Updated dependencies [dc4ca0a]
160
+ - @mastra/core@0.10.8
161
+
162
+ ## 0.10.7-alpha.1
163
+
164
+ ### Patch Changes
165
+
166
+ - Updated dependencies [b8f16b2]
167
+ - Updated dependencies [3e04487]
168
+ - Updated dependencies [dc4ca0a]
169
+ - @mastra/core@0.10.8-alpha.1
10
170
 
11
171
  ## 0.10.7-alpha.0
12
172
 
package/LICENSE.md CHANGED
@@ -1,46 +1,15 @@
1
- # Elastic License 2.0 (ELv2)
1
+ # Apache License 2.0
2
2
 
3
- Copyright (c) 2025 Mastra AI, Inc.
3
+ Copyright (c) 2025 Kepler Software, Inc.
4
4
 
5
- **Acceptance**
6
- By using the software, you agree to all of the terms and conditions below.
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
7
8
 
8
- **Copyright License**
9
- The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
10
 
11
- **Limitations**
12
- You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
13
-
14
- You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
15
-
16
- You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
17
-
18
- **Patents**
19
- The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
20
-
21
- **Notices**
22
- You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
23
-
24
- If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
25
-
26
- **No Other Rights**
27
- These terms do not imply any licenses other than those expressly granted in these terms.
28
-
29
- **Termination**
30
- If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
31
-
32
- **No Liability**
33
- As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
34
-
35
- **Definitions**
36
- The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
37
-
38
- _you_ refers to the individual or entity agreeing to these terms.
39
-
40
- _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
41
-
42
- _your licenses_ are all the licenses granted to you for the software under these terms.
43
-
44
- _use_ means anything you do with the software requiring one of your licenses.
45
-
46
- _trademark_ means trademarks, service marks, and similar rights.
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
package/dist/index.cjs CHANGED
@@ -258,6 +258,7 @@ var BaseResource = class {
258
258
  // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
259
259
  // 'x-mastra-client-type': 'js',
260
260
  },
261
+ signal: this.options.abortSignal,
261
262
  body: options.body instanceof FormData ? options.body : options.body ? JSON.stringify(options.body) : void 0
262
263
  });
263
264
  if (!response.ok) {
@@ -774,6 +775,19 @@ var Agent = class extends BaseResource {
774
775
  toolInvocation.state = "result";
775
776
  toolInvocation.result = result;
776
777
  }
778
+ const writer = writable.getWriter();
779
+ try {
780
+ await writer.write(
781
+ new TextEncoder().encode(
782
+ "a:" + JSON.stringify({
783
+ toolCallId: toolCall2.toolCallId,
784
+ result
785
+ }) + "\n"
786
+ )
787
+ );
788
+ } finally {
789
+ writer.releaseLock();
790
+ }
777
791
  const originalMessages = processedParams.messages;
778
792
  const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
779
793
  this.processStreamResponse(
@@ -1295,10 +1309,10 @@ var Workflow = class extends BaseResource {
1295
1309
  if (params?.toDate) {
1296
1310
  searchParams.set("toDate", params.toDate.toISOString());
1297
1311
  }
1298
- if (params?.limit) {
1312
+ if (params?.limit !== null && params?.limit !== void 0 && !isNaN(Number(params?.limit))) {
1299
1313
  searchParams.set("limit", String(params.limit));
1300
1314
  }
1301
- if (params?.offset) {
1315
+ if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
1302
1316
  searchParams.set("offset", String(params.offset));
1303
1317
  }
1304
1318
  if (params?.resourceId) {
@@ -1326,6 +1340,27 @@ var Workflow = class extends BaseResource {
1326
1340
  runExecutionResult(runId) {
1327
1341
  return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
1328
1342
  }
1343
+ /**
1344
+ * Cancels a specific workflow run by its ID
1345
+ * @param runId - The ID of the workflow run to cancel
1346
+ * @returns Promise containing a success message
1347
+ */
1348
+ cancelRun(runId) {
1349
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/cancel`, {
1350
+ method: "POST"
1351
+ });
1352
+ }
1353
+ /**
1354
+ * Sends an event to a specific workflow run by its ID
1355
+ * @param params - Object containing the runId, event and data
1356
+ * @returns Promise containing a success message
1357
+ */
1358
+ sendRunEvent(params) {
1359
+ return this.request(`/api/workflows/${this.workflowId}/runs/${params.runId}/send-event`, {
1360
+ method: "POST",
1361
+ body: { event: params.event, data: params.data }
1362
+ });
1363
+ }
1329
1364
  /**
1330
1365
  * Creates a new workflow run
1331
1366
  * @param params - Optional object containing the optional runId
package/dist/index.d.cts CHANGED
@@ -23,13 +23,14 @@ interface ClientOptions {
23
23
  maxBackoffMs?: number;
24
24
  /** Custom headers to include with requests */
25
25
  headers?: Record<string, string>;
26
+ /** Abort signal for request */
27
+ abortSignal?: AbortSignal;
26
28
  }
27
29
  interface RequestOptions {
28
30
  method?: string;
29
31
  headers?: Record<string, string>;
30
32
  body?: any;
31
33
  stream?: boolean;
32
- signal?: AbortSignal;
33
34
  }
34
35
  type WithoutMethods<T> = {
35
36
  [K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
@@ -52,14 +53,14 @@ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> =
52
53
  experimental_output?: T;
53
54
  runtimeContext?: RuntimeContext | Record<string, any>;
54
55
  clientTools?: ToolsInput;
55
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
56
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
56
57
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
57
58
  messages: string | string[] | CoreMessage[] | AiMessageType[];
58
59
  output?: T;
59
60
  experimental_output?: T;
60
61
  runtimeContext?: RuntimeContext | Record<string, any>;
61
62
  clientTools?: ToolsInput;
62
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
63
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
63
64
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
64
65
  evals: any[];
65
66
  instructions: string;
@@ -114,6 +115,17 @@ interface GetWorkflowResponse {
114
115
  suspendSchema: string;
115
116
  };
116
117
  };
118
+ allSteps: {
119
+ [key: string]: {
120
+ id: string;
121
+ description: string;
122
+ inputSchema: string;
123
+ outputSchema: string;
124
+ resumeSchema: string;
125
+ suspendSchema: string;
126
+ isWorkflow: boolean;
127
+ };
128
+ };
117
129
  stepGraph: Workflow$1['serializedStepGraph'];
118
130
  inputSchema: string;
119
131
  outputSchema: string;
@@ -306,6 +318,10 @@ interface GetVNextNetworkResponse {
306
318
  inputSchema: string | undefined;
307
319
  outputSchema: string | undefined;
308
320
  }>;
321
+ tools: Array<{
322
+ id: string;
323
+ description: string;
324
+ }>;
309
325
  }
310
326
  interface GenerateVNextNetworkResponse {
311
327
  task: string;
@@ -703,6 +719,26 @@ declare class Workflow extends BaseResource {
703
719
  * @returns Promise containing the workflow run execution result
704
720
  */
705
721
  runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
722
+ /**
723
+ * Cancels a specific workflow run by its ID
724
+ * @param runId - The ID of the workflow run to cancel
725
+ * @returns Promise containing a success message
726
+ */
727
+ cancelRun(runId: string): Promise<{
728
+ message: string;
729
+ }>;
730
+ /**
731
+ * Sends an event to a specific workflow run by its ID
732
+ * @param params - Object containing the runId, event and data
733
+ * @returns Promise containing a success message
734
+ */
735
+ sendRunEvent(params: {
736
+ runId: string;
737
+ event: string;
738
+ data: unknown;
739
+ }): Promise<{
740
+ message: string;
741
+ }>;
706
742
  /**
707
743
  * Creates a new workflow run
708
744
  * @param params - Optional object containing the optional runId
@@ -757,7 +793,10 @@ declare class Workflow extends BaseResource {
757
793
  runId?: string;
758
794
  inputData: Record<string, any>;
759
795
  runtimeContext?: RuntimeContext;
760
- }): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
796
+ }): Promise<stream_web.ReadableStream<{
797
+ type: string;
798
+ payload: any;
799
+ }>>;
761
800
  /**
762
801
  * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
763
802
  * @param params - Object containing the runId, step, resumeData and runtimeContext
package/dist/index.d.ts CHANGED
@@ -23,13 +23,14 @@ interface ClientOptions {
23
23
  maxBackoffMs?: number;
24
24
  /** Custom headers to include with requests */
25
25
  headers?: Record<string, string>;
26
+ /** Abort signal for request */
27
+ abortSignal?: AbortSignal;
26
28
  }
27
29
  interface RequestOptions {
28
30
  method?: string;
29
31
  headers?: Record<string, string>;
30
32
  body?: any;
31
33
  stream?: boolean;
32
- signal?: AbortSignal;
33
34
  }
34
35
  type WithoutMethods<T> = {
35
36
  [K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
@@ -52,14 +53,14 @@ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> =
52
53
  experimental_output?: T;
53
54
  runtimeContext?: RuntimeContext | Record<string, any>;
54
55
  clientTools?: ToolsInput;
55
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
56
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
56
57
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
57
58
  messages: string | string[] | CoreMessage[] | AiMessageType[];
58
59
  output?: T;
59
60
  experimental_output?: T;
60
61
  runtimeContext?: RuntimeContext | Record<string, any>;
61
62
  clientTools?: ToolsInput;
62
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
63
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
63
64
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
64
65
  evals: any[];
65
66
  instructions: string;
@@ -114,6 +115,17 @@ interface GetWorkflowResponse {
114
115
  suspendSchema: string;
115
116
  };
116
117
  };
118
+ allSteps: {
119
+ [key: string]: {
120
+ id: string;
121
+ description: string;
122
+ inputSchema: string;
123
+ outputSchema: string;
124
+ resumeSchema: string;
125
+ suspendSchema: string;
126
+ isWorkflow: boolean;
127
+ };
128
+ };
117
129
  stepGraph: Workflow$1['serializedStepGraph'];
118
130
  inputSchema: string;
119
131
  outputSchema: string;
@@ -306,6 +318,10 @@ interface GetVNextNetworkResponse {
306
318
  inputSchema: string | undefined;
307
319
  outputSchema: string | undefined;
308
320
  }>;
321
+ tools: Array<{
322
+ id: string;
323
+ description: string;
324
+ }>;
309
325
  }
310
326
  interface GenerateVNextNetworkResponse {
311
327
  task: string;
@@ -703,6 +719,26 @@ declare class Workflow extends BaseResource {
703
719
  * @returns Promise containing the workflow run execution result
704
720
  */
705
721
  runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
722
+ /**
723
+ * Cancels a specific workflow run by its ID
724
+ * @param runId - The ID of the workflow run to cancel
725
+ * @returns Promise containing a success message
726
+ */
727
+ cancelRun(runId: string): Promise<{
728
+ message: string;
729
+ }>;
730
+ /**
731
+ * Sends an event to a specific workflow run by its ID
732
+ * @param params - Object containing the runId, event and data
733
+ * @returns Promise containing a success message
734
+ */
735
+ sendRunEvent(params: {
736
+ runId: string;
737
+ event: string;
738
+ data: unknown;
739
+ }): Promise<{
740
+ message: string;
741
+ }>;
706
742
  /**
707
743
  * Creates a new workflow run
708
744
  * @param params - Optional object containing the optional runId
@@ -757,7 +793,10 @@ declare class Workflow extends BaseResource {
757
793
  runId?: string;
758
794
  inputData: Record<string, any>;
759
795
  runtimeContext?: RuntimeContext;
760
- }): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
796
+ }): Promise<stream_web.ReadableStream<{
797
+ type: string;
798
+ payload: any;
799
+ }>>;
761
800
  /**
762
801
  * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
763
802
  * @param params - Object containing the runId, step, resumeData and runtimeContext
package/dist/index.js CHANGED
@@ -252,6 +252,7 @@ var BaseResource = class {
252
252
  // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
253
253
  // 'x-mastra-client-type': 'js',
254
254
  },
255
+ signal: this.options.abortSignal,
255
256
  body: options.body instanceof FormData ? options.body : options.body ? JSON.stringify(options.body) : void 0
256
257
  });
257
258
  if (!response.ok) {
@@ -768,6 +769,19 @@ var Agent = class extends BaseResource {
768
769
  toolInvocation.state = "result";
769
770
  toolInvocation.result = result;
770
771
  }
772
+ const writer = writable.getWriter();
773
+ try {
774
+ await writer.write(
775
+ new TextEncoder().encode(
776
+ "a:" + JSON.stringify({
777
+ toolCallId: toolCall2.toolCallId,
778
+ result
779
+ }) + "\n"
780
+ )
781
+ );
782
+ } finally {
783
+ writer.releaseLock();
784
+ }
771
785
  const originalMessages = processedParams.messages;
772
786
  const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
773
787
  this.processStreamResponse(
@@ -1289,10 +1303,10 @@ var Workflow = class extends BaseResource {
1289
1303
  if (params?.toDate) {
1290
1304
  searchParams.set("toDate", params.toDate.toISOString());
1291
1305
  }
1292
- if (params?.limit) {
1306
+ if (params?.limit !== null && params?.limit !== void 0 && !isNaN(Number(params?.limit))) {
1293
1307
  searchParams.set("limit", String(params.limit));
1294
1308
  }
1295
- if (params?.offset) {
1309
+ if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
1296
1310
  searchParams.set("offset", String(params.offset));
1297
1311
  }
1298
1312
  if (params?.resourceId) {
@@ -1320,6 +1334,27 @@ var Workflow = class extends BaseResource {
1320
1334
  runExecutionResult(runId) {
1321
1335
  return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
1322
1336
  }
1337
+ /**
1338
+ * Cancels a specific workflow run by its ID
1339
+ * @param runId - The ID of the workflow run to cancel
1340
+ * @returns Promise containing a success message
1341
+ */
1342
+ cancelRun(runId) {
1343
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/cancel`, {
1344
+ method: "POST"
1345
+ });
1346
+ }
1347
+ /**
1348
+ * Sends an event to a specific workflow run by its ID
1349
+ * @param params - Object containing the runId, event and data
1350
+ * @returns Promise containing a success message
1351
+ */
1352
+ sendRunEvent(params) {
1353
+ return this.request(`/api/workflows/${this.workflowId}/runs/${params.runId}/send-event`, {
1354
+ method: "POST",
1355
+ body: { event: params.event, data: params.data }
1356
+ });
1357
+ }
1323
1358
  /**
1324
1359
  * Creates a new workflow run
1325
1360
  * @param params - Optional object containing the optional runId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.0.0-custom-instrumentation-20250626084921",
3
+ "version": "0.0.0-custom-instrumentation-20250708222033",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "directory": "client-sdks/client-js"
26
26
  },
27
27
  "homepage": "https://github.com/mastra-ai/mastra/tree/main/client-sdks/client-js#readme",
28
- "license": "Elastic-2.0",
28
+ "license": "Apache-2.0",
29
29
  "dependencies": {
30
30
  "@ag-ui/client": "^0.0.27",
31
31
  "@ai-sdk/ui-utils": "^1.2.11",
@@ -33,7 +33,7 @@
33
33
  "rxjs": "7.8.1",
34
34
  "zod": "^3.25.67",
35
35
  "zod-to-json-schema": "^3.24.5",
36
- "@mastra/core": "0.0.0-custom-instrumentation-20250626084921"
36
+ "@mastra/core": "0.0.0-custom-instrumentation-20250708222033"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "zod": "^3.0.0"
@@ -46,8 +46,8 @@
46
46
  "@types/node": "^20.19.0",
47
47
  "tsup": "^8.5.0",
48
48
  "typescript": "^5.8.3",
49
- "vitest": "^3.2.3",
50
- "@internal/lint": "0.0.0-custom-instrumentation-20250626084921"
49
+ "vitest": "^3.2.4",
50
+ "@internal/lint": "0.0.0-custom-instrumentation-20250708222033"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting",
@@ -673,6 +673,24 @@ export class Agent extends BaseResource {
673
673
  toolInvocation.result = result;
674
674
  }
675
675
 
676
+ // write the tool result part to the stream
677
+ const writer = writable.getWriter();
678
+
679
+ try {
680
+ await writer.write(
681
+ new TextEncoder().encode(
682
+ 'a:' +
683
+ JSON.stringify({
684
+ toolCallId: toolCall.toolCallId,
685
+ result,
686
+ }) +
687
+ '\n',
688
+ ),
689
+ );
690
+ } finally {
691
+ writer.releaseLock();
692
+ }
693
+
676
694
  // Convert messages to the correct format for the recursive call
677
695
  const originalMessages = processedParams.messages;
678
696
  const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
@@ -30,6 +30,7 @@ export class BaseResource {
30
30
  // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
31
31
  // 'x-mastra-client-type': 'js',
32
32
  },
33
+ signal: this.options.abortSignal,
33
34
  body:
34
35
  options.body instanceof FormData ? options.body : options.body ? JSON.stringify(options.body) : undefined,
35
36
  });
@@ -115,10 +115,10 @@ export class Workflow extends BaseResource {
115
115
  if (params?.toDate) {
116
116
  searchParams.set('toDate', params.toDate.toISOString());
117
117
  }
118
- if (params?.limit) {
118
+ if (params?.limit !== null && params?.limit !== undefined && !isNaN(Number(params?.limit))) {
119
119
  searchParams.set('limit', String(params.limit));
120
120
  }
121
- if (params?.offset) {
121
+ if (params?.offset !== null && params?.offset !== undefined && !isNaN(Number(params?.offset))) {
122
122
  searchParams.set('offset', String(params.offset));
123
123
  }
124
124
  if (params?.resourceId) {
@@ -150,6 +150,29 @@ export class Workflow extends BaseResource {
150
150
  return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
151
151
  }
152
152
 
153
+ /**
154
+ * Cancels a specific workflow run by its ID
155
+ * @param runId - The ID of the workflow run to cancel
156
+ * @returns Promise containing a success message
157
+ */
158
+ cancelRun(runId: string): Promise<{ message: string }> {
159
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/cancel`, {
160
+ method: 'POST',
161
+ });
162
+ }
163
+
164
+ /**
165
+ * Sends an event to a specific workflow run by its ID
166
+ * @param params - Object containing the runId, event and data
167
+ * @returns Promise containing a success message
168
+ */
169
+ sendRunEvent(params: { runId: string; event: string; data: unknown }): Promise<{ message: string }> {
170
+ return this.request(`/api/workflows/${this.workflowId}/runs/${params.runId}/send-event`, {
171
+ method: 'POST',
172
+ body: { event: params.event, data: params.data },
173
+ });
174
+ }
175
+
153
176
  /**
154
177
  * Creates a new workflow run
155
178
  * @param params - Optional object containing the optional runId
@@ -267,7 +290,7 @@ export class Workflow extends BaseResource {
267
290
  }
268
291
 
269
292
  // Create a transform stream that processes the response body
270
- const transformStream = new TransformStream<ArrayBuffer, WorkflowWatchResult>({
293
+ const transformStream = new TransformStream<ArrayBuffer, { type: string; payload: any }>({
271
294
  start() {},
272
295
  async transform(chunk, controller) {
273
296
  try {
package/src/types.ts CHANGED
@@ -34,6 +34,7 @@ export interface ClientOptions {
34
34
  /** Custom headers to include with requests */
35
35
  headers?: Record<string, string>;
36
36
  /** Abort signal for request */
37
+ abortSignal?: AbortSignal;
37
38
  }
38
39
 
39
40
  export interface RequestOptions {
@@ -41,7 +42,6 @@ export interface RequestOptions {
41
42
  headers?: Record<string, string>;
42
43
  body?: any;
43
44
  stream?: boolean;
44
- signal?: AbortSignal;
45
45
  }
46
46
 
47
47
  type WithoutMethods<T> = {
@@ -71,7 +71,9 @@ export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undef
71
71
  experimental_output?: T;
72
72
  runtimeContext?: RuntimeContext | Record<string, any>;
73
73
  clientTools?: ToolsInput;
74
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
74
+ } & WithoutMethods<
75
+ Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
76
+ >;
75
77
 
76
78
  export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
77
79
  messages: string | string[] | CoreMessage[] | AiMessageType[];
@@ -79,7 +81,9 @@ export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefin
79
81
  experimental_output?: T;
80
82
  runtimeContext?: RuntimeContext | Record<string, any>;
81
83
  clientTools?: ToolsInput;
82
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
84
+ } & WithoutMethods<
85
+ Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
86
+ >;
83
87
 
84
88
  export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
85
89
  evals: any[];
@@ -140,6 +144,17 @@ export interface GetWorkflowResponse {
140
144
  suspendSchema: string;
141
145
  };
142
146
  };
147
+ allSteps: {
148
+ [key: string]: {
149
+ id: string;
150
+ description: string;
151
+ inputSchema: string;
152
+ outputSchema: string;
153
+ resumeSchema: string;
154
+ suspendSchema: string;
155
+ isWorkflow: boolean;
156
+ };
157
+ };
143
158
  stepGraph: Workflow['serializedStepGraph'];
144
159
  inputSchema: string;
145
160
  outputSchema: string;
@@ -358,6 +373,10 @@ export interface GetVNextNetworkResponse {
358
373
  inputSchema: string | undefined;
359
374
  outputSchema: string | undefined;
360
375
  }>;
376
+ tools: Array<{
377
+ id: string;
378
+ description: string;
379
+ }>;
361
380
  }
362
381
 
363
382
  export interface GenerateVNextNetworkResponse {