@mastra/client-js 0.0.0-mcp-server-update-20250421162713 → 0.0.0-mcp-schema-serializer-20250430202337

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/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { CoreMessage, AiMessageType, StorageThreadType, MessageType, StepAction, StepGraph, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
1
+ import { processDataStream } from '@ai-sdk/ui-utils';
2
+ import { CoreMessage, AiMessageType, StorageThreadType, MessageType, StepAction, StepGraph, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
2
3
  import { JSONSchema7 } from 'json-schema';
3
4
  import { ZodSchema } from 'zod';
4
- import { processDataStream } from '@ai-sdk/ui-utils';
5
5
  import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
6
+ import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
7
+ import { RuntimeContext } from '@mastra/core/runtime-context';
6
8
 
7
9
  interface ClientOptions {
8
10
  /** Base URL for API requests */
@@ -38,6 +40,9 @@ type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
38
40
  } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
39
41
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
40
42
  evals: any[];
43
+ instructions: string;
44
+ name: string;
45
+ id: string;
41
46
  }
42
47
  interface GetToolResponse {
43
48
  id: string;
@@ -53,6 +58,7 @@ interface GetWorkflowResponse {
53
58
  stepSubscriberGraph: Record<string, StepGraph>;
54
59
  workflowId?: string;
55
60
  }
61
+ type GetWorkflowRunsResponse = WorkflowRuns;
56
62
  type WorkflowRunResult = {
57
63
  activePaths: Record<string, {
58
64
  status: string;
@@ -63,6 +69,26 @@ type WorkflowRunResult = {
63
69
  timestamp: number;
64
70
  runId: string;
65
71
  };
72
+ interface GetVNextWorkflowResponse {
73
+ name: string;
74
+ steps: {
75
+ [key: string]: {
76
+ id: string;
77
+ description: string;
78
+ inputSchema: string;
79
+ outputSchema: string;
80
+ resumeSchema: string;
81
+ suspendSchema: string;
82
+ };
83
+ };
84
+ stepGraph: NewWorkflow['serializedStepGraph'];
85
+ inputSchema: string;
86
+ outputSchema: string;
87
+ }
88
+ type VNextWorkflowWatchResult = WatchEvent & {
89
+ runId: string;
90
+ };
91
+ type VNextWorkflowRunResult = WorkflowResult<any, any>;
66
92
  interface UpsertVectorParams {
67
93
  indexName: string;
68
94
  vectors: number[][];
@@ -97,7 +123,7 @@ type SaveMessageToMemoryResponse = MessageType[];
97
123
  interface CreateMemoryThreadParams {
98
124
  title: string;
99
125
  metadata: Record<string, any>;
100
- resourceid: string;
126
+ resourceId: string;
101
127
  threadId: string;
102
128
  agentId: string;
103
129
  }
@@ -110,7 +136,7 @@ type GetMemoryThreadResponse = StorageThreadType[];
110
136
  interface UpdateMemoryThreadParams {
111
137
  title: string;
112
138
  metadata: Record<string, any>;
113
- resourceid: string;
139
+ resourceId: string;
114
140
  }
115
141
  interface GetMemoryThreadMessagesResponse {
116
142
  messages: CoreMessage[];
@@ -376,6 +402,11 @@ declare class Workflow extends BaseResource {
376
402
  * @returns Promise containing workflow details including steps and graphs
377
403
  */
378
404
  details(): Promise<GetWorkflowResponse>;
405
+ /**
406
+ * Retrieves all runs for a workflow
407
+ * @returns Promise containing workflow runs array
408
+ */
409
+ runs(): Promise<GetWorkflowRunsResponse>;
379
410
  /**
380
411
  * @deprecated Use `startAsync` instead
381
412
  * Executes the workflow with the provided parameters
@@ -469,9 +500,97 @@ declare class Tool extends BaseResource {
469
500
  */
470
501
  execute(params: {
471
502
  data: any;
503
+ runId?: string;
472
504
  }): Promise<any>;
473
505
  }
474
506
 
507
+ declare class VNextWorkflow extends BaseResource {
508
+ private workflowId;
509
+ constructor(options: ClientOptions, workflowId: string);
510
+ /**
511
+ * Creates an async generator that processes a readable stream and yields vNext workflow records
512
+ * separated by the Record Separator character (\x1E)
513
+ *
514
+ * @param stream - The readable stream to process
515
+ * @returns An async generator that yields parsed records
516
+ */
517
+ private streamProcessor;
518
+ /**
519
+ * Retrieves details about the vNext workflow
520
+ * @returns Promise containing vNext workflow details including steps and graphs
521
+ */
522
+ details(): Promise<GetVNextWorkflowResponse>;
523
+ /**
524
+ * Retrieves all runs for a vNext workflow
525
+ * @returns Promise containing vNext workflow runs array
526
+ */
527
+ runs(): Promise<GetWorkflowRunsResponse>;
528
+ /**
529
+ * Creates a new vNext workflow run
530
+ * @param params - Optional object containing the optional runId
531
+ * @returns Promise containing the runId of the created run
532
+ */
533
+ createRun(params?: {
534
+ runId?: string;
535
+ }): Promise<{
536
+ runId: string;
537
+ }>;
538
+ /**
539
+ * Starts a vNext workflow run synchronously without waiting for the workflow to complete
540
+ * @param params - Object containing the runId, inputData and runtimeContext
541
+ * @returns Promise containing success message
542
+ */
543
+ start(params: {
544
+ runId: string;
545
+ inputData: Record<string, any>;
546
+ runtimeContext?: RuntimeContext;
547
+ }): Promise<{
548
+ message: string;
549
+ }>;
550
+ /**
551
+ * Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
552
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
553
+ * @returns Promise containing success message
554
+ */
555
+ resume({ step, runId, resumeData, runtimeContext, }: {
556
+ step: string | string[];
557
+ runId: string;
558
+ resumeData?: Record<string, any>;
559
+ runtimeContext?: RuntimeContext;
560
+ }): Promise<{
561
+ message: string;
562
+ }>;
563
+ /**
564
+ * Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
565
+ * @param params - Object containing the optional runId, inputData and runtimeContext
566
+ * @returns Promise containing the vNext workflow execution results
567
+ */
568
+ startAsync(params: {
569
+ runId?: string;
570
+ inputData: Record<string, any>;
571
+ runtimeContext?: RuntimeContext;
572
+ }): Promise<VNextWorkflowRunResult>;
573
+ /**
574
+ * Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
575
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
576
+ * @returns Promise containing the vNext workflow resume results
577
+ */
578
+ resumeAsync(params: {
579
+ runId: string;
580
+ step: string | string[];
581
+ resumeData?: Record<string, any>;
582
+ runtimeContext?: RuntimeContext;
583
+ }): Promise<VNextWorkflowRunResult>;
584
+ /**
585
+ * Watches vNext workflow transitions in real-time
586
+ * @param runId - Optional run ID to filter the watch stream
587
+ * @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
588
+ */
589
+ watch({ runId }: {
590
+ runId?: string;
591
+ }, onRecord: (record: VNextWorkflowWatchResult) => void): Promise<void>;
592
+ }
593
+
475
594
  declare class MastraClient extends BaseResource {
476
595
  constructor(options: ClientOptions);
477
596
  /**
@@ -538,6 +657,17 @@ declare class MastraClient extends BaseResource {
538
657
  * @returns Workflow instance
539
658
  */
540
659
  getWorkflow(workflowId: string): Workflow;
660
+ /**
661
+ * Retrieves all available vNext workflows
662
+ * @returns Promise containing map of vNext workflow IDs to vNext workflow details
663
+ */
664
+ getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
665
+ /**
666
+ * Gets a vNext workflow instance by ID
667
+ * @param workflowId - ID of the vNext workflow to retrieve
668
+ * @returns vNext Workflow instance
669
+ */
670
+ getVNextWorkflow(workflowId: string): VNextWorkflow;
541
671
  /**
542
672
  * Gets a vector instance by name
543
673
  * @param vectorName - Name of the vector to retrieve
@@ -582,4 +712,4 @@ declare class MastraClient extends BaseResource {
582
712
  getNetwork(networkId: string): Network;
583
713
  }
584
714
 
585
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
715
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { processDataStream } from '@ai-sdk/ui-utils';
1
2
  import { ZodSchema } from 'zod';
2
3
  import { zodToJsonSchema } from 'zod-to-json-schema';
3
- import { processDataStream } from '@ai-sdk/ui-utils';
4
4
 
5
5
  // src/resources/agent.ts
6
6
 
@@ -371,6 +371,13 @@ var Workflow = class extends BaseResource {
371
371
  details() {
372
372
  return this.request(`/api/workflows/${this.workflowId}`);
373
373
  }
374
+ /**
375
+ * Retrieves all runs for a workflow
376
+ * @returns Promise containing workflow runs array
377
+ */
378
+ runs() {
379
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
380
+ }
374
381
  /**
375
382
  * @deprecated Use `startAsync` instead
376
383
  * Executes the workflow with the provided parameters
@@ -487,7 +494,7 @@ var Workflow = class extends BaseResource {
487
494
  }
488
495
  }
489
496
  }
490
- } catch (error) {
497
+ } catch {
491
498
  }
492
499
  }
493
500
  if (buffer) {
@@ -541,13 +548,180 @@ var Tool = class extends BaseResource {
541
548
  * @returns Promise containing the tool execution results
542
549
  */
543
550
  execute(params) {
544
- return this.request(`/api/tools/${this.toolId}/execute`, {
551
+ const url = new URLSearchParams();
552
+ if (params.runId) {
553
+ url.set("runId", params.runId);
554
+ }
555
+ return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
545
556
  method: "POST",
546
- body: params
557
+ body: params.data
547
558
  });
548
559
  }
549
560
  };
550
561
 
562
+ // src/resources/vnext-workflow.ts
563
+ var RECORD_SEPARATOR2 = "";
564
+ var VNextWorkflow = class extends BaseResource {
565
+ constructor(options, workflowId) {
566
+ super(options);
567
+ this.workflowId = workflowId;
568
+ }
569
+ /**
570
+ * Creates an async generator that processes a readable stream and yields vNext workflow records
571
+ * separated by the Record Separator character (\x1E)
572
+ *
573
+ * @param stream - The readable stream to process
574
+ * @returns An async generator that yields parsed records
575
+ */
576
+ async *streamProcessor(stream) {
577
+ const reader = stream.getReader();
578
+ let doneReading = false;
579
+ let buffer = "";
580
+ try {
581
+ while (!doneReading) {
582
+ const { done, value } = await reader.read();
583
+ doneReading = done;
584
+ if (done && !value) continue;
585
+ try {
586
+ const decoded = value ? new TextDecoder().decode(value) : "";
587
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
588
+ buffer = chunks.pop() || "";
589
+ for (const chunk of chunks) {
590
+ if (chunk) {
591
+ if (typeof chunk === "string") {
592
+ try {
593
+ const parsedChunk = JSON.parse(chunk);
594
+ yield parsedChunk;
595
+ } catch {
596
+ }
597
+ }
598
+ }
599
+ }
600
+ } catch {
601
+ }
602
+ }
603
+ if (buffer) {
604
+ try {
605
+ yield JSON.parse(buffer);
606
+ } catch {
607
+ }
608
+ }
609
+ } finally {
610
+ reader.cancel().catch(() => {
611
+ });
612
+ }
613
+ }
614
+ /**
615
+ * Retrieves details about the vNext workflow
616
+ * @returns Promise containing vNext workflow details including steps and graphs
617
+ */
618
+ details() {
619
+ return this.request(`/api/workflows/v-next/${this.workflowId}`);
620
+ }
621
+ /**
622
+ * Retrieves all runs for a vNext workflow
623
+ * @returns Promise containing vNext workflow runs array
624
+ */
625
+ runs() {
626
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
627
+ }
628
+ /**
629
+ * Creates a new vNext workflow run
630
+ * @param params - Optional object containing the optional runId
631
+ * @returns Promise containing the runId of the created run
632
+ */
633
+ createRun(params) {
634
+ const searchParams = new URLSearchParams();
635
+ if (!!params?.runId) {
636
+ searchParams.set("runId", params.runId);
637
+ }
638
+ return this.request(`/api/workflows/v-next/${this.workflowId}/create-run?${searchParams.toString()}`, {
639
+ method: "POST"
640
+ });
641
+ }
642
+ /**
643
+ * Starts a vNext workflow run synchronously without waiting for the workflow to complete
644
+ * @param params - Object containing the runId, inputData and runtimeContext
645
+ * @returns Promise containing success message
646
+ */
647
+ start(params) {
648
+ return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
649
+ method: "POST",
650
+ body: { inputData: params?.inputData, runtimeContext: params.runtimeContext }
651
+ });
652
+ }
653
+ /**
654
+ * Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
655
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
656
+ * @returns Promise containing success message
657
+ */
658
+ resume({
659
+ step,
660
+ runId,
661
+ resumeData,
662
+ runtimeContext
663
+ }) {
664
+ return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
665
+ method: "POST",
666
+ stream: true,
667
+ body: {
668
+ step,
669
+ resumeData,
670
+ runtimeContext
671
+ }
672
+ });
673
+ }
674
+ /**
675
+ * Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
676
+ * @param params - Object containing the optional runId, inputData and runtimeContext
677
+ * @returns Promise containing the vNext workflow execution results
678
+ */
679
+ startAsync(params) {
680
+ const searchParams = new URLSearchParams();
681
+ if (!!params?.runId) {
682
+ searchParams.set("runId", params.runId);
683
+ }
684
+ return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
685
+ method: "POST",
686
+ body: { inputData: params.inputData, runtimeContext: params.runtimeContext }
687
+ });
688
+ }
689
+ /**
690
+ * Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
691
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
692
+ * @returns Promise containing the vNext workflow resume results
693
+ */
694
+ resumeAsync(params) {
695
+ return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
696
+ method: "POST",
697
+ body: {
698
+ step: params.step,
699
+ resumeData: params.resumeData,
700
+ runtimeContext: params.runtimeContext
701
+ }
702
+ });
703
+ }
704
+ /**
705
+ * Watches vNext workflow transitions in real-time
706
+ * @param runId - Optional run ID to filter the watch stream
707
+ * @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
708
+ */
709
+ async watch({ runId }, onRecord) {
710
+ const response = await this.request(`/api/workflows/v-next/${this.workflowId}/watch?runId=${runId}`, {
711
+ stream: true
712
+ });
713
+ if (!response.ok) {
714
+ throw new Error(`Failed to watch vNext workflow: ${response.statusText}`);
715
+ }
716
+ if (!response.body) {
717
+ throw new Error("Response body is null");
718
+ }
719
+ for await (const record of this.streamProcessor(response.body)) {
720
+ onRecord(record);
721
+ }
722
+ }
723
+ };
724
+
551
725
  // src/client.ts
552
726
  var MastraClient = class extends BaseResource {
553
727
  constructor(options) {
@@ -640,6 +814,21 @@ var MastraClient = class extends BaseResource {
640
814
  getWorkflow(workflowId) {
641
815
  return new Workflow(this.options, workflowId);
642
816
  }
817
+ /**
818
+ * Retrieves all available vNext workflows
819
+ * @returns Promise containing map of vNext workflow IDs to vNext workflow details
820
+ */
821
+ getVNextWorkflows() {
822
+ return this.request("/api/workflows/v-next");
823
+ }
824
+ /**
825
+ * Gets a vNext workflow instance by ID
826
+ * @param workflowId - ID of the vNext workflow to retrieve
827
+ * @returns vNext Workflow instance
828
+ */
829
+ getVNextWorkflow(workflowId) {
830
+ return new VNextWorkflow(this.options, workflowId);
831
+ }
643
832
  /**
644
833
  * Gets a vector instance by name
645
834
  * @param vectorName - Name of the vector to retrieve
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.0.0-mcp-server-update-20250421162713",
3
+ "version": "0.0.0-mcp-schema-serializer-20250430202337",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -26,7 +26,10 @@
26
26
  "json-schema": "^0.4.0",
27
27
  "zod": "^3.24.2",
28
28
  "zod-to-json-schema": "^3.24.3",
29
- "@mastra/core": "0.0.0-mcp-server-update-20250421162713"
29
+ "@mastra/core": "0.0.0-mcp-schema-serializer-20250430202337"
30
+ },
31
+ "peerDependencies": {
32
+ "zod": "^3.24.2"
30
33
  },
31
34
  "devDependencies": {
32
35
  "@babel/preset-env": "^7.26.9",
@@ -36,7 +39,7 @@
36
39
  "@types/node": "^20.17.27",
37
40
  "tsup": "^8.4.0",
38
41
  "typescript": "^5.8.2",
39
- "vitest": "^3.0.9",
42
+ "vitest": "^3.1.2",
40
43
  "@internal/lint": "0.0.2"
41
44
  },
42
45
  "scripts": {
package/src/client.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, Network } from './resources';
1
+ import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, Network, VNextWorkflow } from './resources';
2
2
  import type {
3
3
  ClientOptions,
4
4
  CreateMemoryThreadParams,
@@ -13,8 +13,8 @@ import type {
13
13
  GetTelemetryParams,
14
14
  GetTelemetryResponse,
15
15
  GetToolResponse,
16
+ GetVNextWorkflowResponse,
16
17
  GetWorkflowResponse,
17
- RequestOptions,
18
18
  SaveMessageToMemoryParams,
19
19
  SaveMessageToMemoryResponse,
20
20
  } from './types';
@@ -122,6 +122,23 @@ export class MastraClient extends BaseResource {
122
122
  return new Workflow(this.options, workflowId);
123
123
  }
124
124
 
125
+ /**
126
+ * Retrieves all available vNext workflows
127
+ * @returns Promise containing map of vNext workflow IDs to vNext workflow details
128
+ */
129
+ public getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>> {
130
+ return this.request('/api/workflows/v-next');
131
+ }
132
+
133
+ /**
134
+ * Gets a vNext workflow instance by ID
135
+ * @param workflowId - ID of the vNext workflow to retrieve
136
+ * @returns vNext Workflow instance
137
+ */
138
+ public getVNextWorkflow(workflowId: string) {
139
+ return new VNextWorkflow(this.options, workflowId);
140
+ }
141
+
125
142
  /**
126
143
  * Gets a vector instance by name
127
144
  * @param vectorName - Name of the vector to retrieve
@@ -166,14 +183,6 @@ export class MastraClient extends BaseResource {
166
183
  const { name, scope, page, perPage, attribute } = params || {};
167
184
  const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
168
185
 
169
- const queryObj = {
170
- ...(name ? { name } : {}),
171
- ...(scope ? { scope } : {}),
172
- ...(page ? { page: String(page) } : {}),
173
- ...(perPage ? { perPage: String(perPage) } : {}),
174
- ...(_attribute?.length ? { attribute: _attribute } : {}),
175
- } as const;
176
-
177
186
  const searchParams = new URLSearchParams();
178
187
  if (name) {
179
188
  searchParams.set('name', name);
package/src/index.test.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { MessageType } from '@mastra/core';
2
1
  import { describe, expect, beforeEach, it, vi } from 'vitest';
3
2
 
4
3
  import { MastraClient } from './client';
@@ -489,7 +488,7 @@ describe('MastraClient Resources', () => {
489
488
  const result = await memoryThread.update({
490
489
  title: 'Updated Thread',
491
490
  metadata: { updated: true },
492
- resourceid: 'test-resource',
491
+ resourceId: 'test-resource',
493
492
  });
494
493
  expect(result).toEqual(mockResponse);
495
494
  expect(global.fetch).toHaveBeenCalledWith(
@@ -536,6 +535,7 @@ describe('MastraClient Resources', () => {
536
535
  content: 'test',
537
536
  role: 'user' as const,
538
537
  threadId: 'test-thread',
538
+ resourceId: 'test-resource',
539
539
  createdAt: new Date('2025-03-26T10:40:55.116Z'),
540
540
  },
541
541
  ];
@@ -584,10 +584,10 @@ describe('MastraClient Resources', () => {
584
584
  it('should execute tool', async () => {
585
585
  const mockResponse = { data: 'test' };
586
586
  mockFetchResponse(mockResponse);
587
- const result = await tool.execute({ data: '' });
587
+ const result = await tool.execute({ data: '', runId: 'test-run-id' });
588
588
  expect(result).toEqual(mockResponse);
589
589
  expect(global.fetch).toHaveBeenCalledWith(
590
- `${clientOptions.baseUrl}/api/tools/test-tool/execute`,
590
+ `${clientOptions.baseUrl}/api/tools/test-tool/execute?runId=test-run-id`,
591
591
  expect.objectContaining({
592
592
  method: 'POST',
593
593
  headers: expect.objectContaining({
@@ -1,8 +1,8 @@
1
+ import { processDataStream } from '@ai-sdk/ui-utils';
1
2
  import type { GenerateReturn } from '@mastra/core';
2
3
  import type { JSONSchema7 } from 'json-schema';
3
4
  import { ZodSchema } from 'zod';
4
5
  import { zodToJsonSchema } from 'zod-to-json-schema';
5
- import { processDataStream } from '@ai-sdk/ui-utils';
6
6
 
7
7
  import type {
8
8
  GenerateParams,
@@ -29,7 +29,6 @@ export class AgentTool extends BaseResource {
29
29
  * @param params - Parameters required for tool execution
30
30
  * @returns Promise containing tool execution results
31
31
  */
32
- /** @deprecated use CreateRun/startRun */
33
32
  execute(params: { data: any }): Promise<any> {
34
33
  return this.request(`/api/agents/${this.agentId}/tools/${this.toolId}/execute`, {
35
34
  method: 'POST',
@@ -1,4 +1,4 @@
1
- import type { RequestFunction, RequestOptions, ClientOptions } from '../types';
1
+ import type { RequestOptions, ClientOptions } from '../types';
2
2
 
3
3
  export class BaseResource {
4
4
  readonly options: ClientOptions;
@@ -5,3 +5,4 @@ export * from './vector';
5
5
  export * from './workflow';
6
6
  export * from './tool';
7
7
  export * from './base';
8
+ export * from './vnext-workflow';
@@ -1,13 +1,6 @@
1
1
  import type { StorageThreadType } from '@mastra/core';
2
2
 
3
- import type {
4
- CreateMemoryThreadParams,
5
- GetMemoryThreadMessagesResponse,
6
- GetMemoryThreadResponse,
7
- ClientOptions,
8
- SaveMessageToMemoryParams,
9
- UpdateMemoryThreadParams,
10
- } from '../types';
3
+ import type { GetMemoryThreadMessagesResponse, ClientOptions, UpdateMemoryThreadParams } from '../types';
11
4
 
12
5
  import { BaseResource } from './base';
13
6
 
@@ -1,3 +1,4 @@
1
+ import { processDataStream } from '@ai-sdk/ui-utils';
1
2
  import type { GenerateReturn } from '@mastra/core';
2
3
  import type { JSONSchema7 } from 'json-schema';
3
4
  import { ZodSchema } from 'zod';
@@ -6,7 +7,6 @@ import { zodToJsonSchema } from 'zod-to-json-schema';
6
7
  import type { GenerateParams, ClientOptions, StreamParams, GetNetworkResponse } from '../types';
7
8
 
8
9
  import { BaseResource } from './base';
9
- import { processDataStream } from '@ai-sdk/ui-utils';
10
10
 
11
11
  export class Network extends BaseResource {
12
12
  constructor(
@@ -23,10 +23,16 @@ export class Tool extends BaseResource {
23
23
  * @param params - Parameters required for tool execution
24
24
  * @returns Promise containing the tool execution results
25
25
  */
26
- execute(params: { data: any }): Promise<any> {
27
- return this.request(`/api/tools/${this.toolId}/execute`, {
26
+ execute(params: { data: any; runId?: string }): Promise<any> {
27
+ const url = new URLSearchParams();
28
+
29
+ if (params.runId) {
30
+ url.set('runId', params.runId);
31
+ }
32
+
33
+ return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
28
34
  method: 'POST',
29
- body: params,
35
+ body: params.data,
30
36
  });
31
37
  }
32
38
  }