@mastra/client-js 0.1.20-alpha.0 → 0.1.20-alpha.3

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.0 build /home/runner/work/mastra/mastra/client-sdks/client-js
2
+ > @mastra/client-js@0.1.20-alpha.3 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 27.30 KB
13
- CJS ⚡️ Build success in 1193ms
14
- ESM dist/index.js 27.12 KB
15
- ESM ⚡️ Build success in 1199ms
12
+ ESM dist/index.js 29.18 KB
13
+ ESM ⚡️ Build success in 1092ms
14
+ CJS dist/index.cjs 29.36 KB
15
+ CJS ⚡️ Build success in 1093ms
16
16
  DTS Build start
17
- DTS ⚡️ Build success in 12145ms
18
- DTS dist/index.d.ts 24.11 KB
19
- DTS dist/index.d.cts 24.11 KB
17
+ DTS ⚡️ Build success in 12404ms
18
+ DTS dist/index.d.ts 24.97 KB
19
+ DTS dist/index.d.cts 24.97 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 0.1.20-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 4155f47: Add parameters to filter workflow runs
8
+ Add fromDate and toDate to telemetry parameters
9
+ - Updated dependencies [967b41c]
10
+ - Updated dependencies [4155f47]
11
+ - Updated dependencies [17826a9]
12
+ - @mastra/core@0.9.2-alpha.3
13
+
14
+ ## 0.1.20-alpha.2
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [26738f4]
19
+ - @mastra/core@0.9.2-alpha.2
20
+
21
+ ## 0.1.20-alpha.1
22
+
23
+ ### Patch Changes
24
+
25
+ - 254f5c3: Audit, cleanup MastraClient
26
+ - 2429c74: Add get workflow runs api to client-js
27
+ - Updated dependencies [b804723]
28
+ - @mastra/core@0.9.2-alpha.1
29
+
3
30
  ## 0.1.20-alpha.0
4
31
 
5
32
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var uiUtils = require('@ai-sdk/ui-utils');
3
4
  var zod = require('zod');
4
5
  var zodToJsonSchema = require('zod-to-json-schema');
5
- var uiUtils = require('@ai-sdk/ui-utils');
6
6
 
7
7
  // src/resources/agent.ts
8
8
 
@@ -373,6 +373,34 @@ var Workflow = class extends BaseResource {
373
373
  details() {
374
374
  return this.request(`/api/workflows/${this.workflowId}`);
375
375
  }
376
+ /**
377
+ * Retrieves all runs for a workflow
378
+ * @param params - Parameters for filtering runs
379
+ * @returns Promise containing workflow runs array
380
+ */
381
+ runs(params) {
382
+ const searchParams = new URLSearchParams();
383
+ if (params?.fromDate) {
384
+ searchParams.set("fromDate", params.fromDate.toISOString());
385
+ }
386
+ if (params?.toDate) {
387
+ searchParams.set("toDate", params.toDate.toISOString());
388
+ }
389
+ if (params?.limit) {
390
+ searchParams.set("limit", String(params.limit));
391
+ }
392
+ if (params?.offset) {
393
+ searchParams.set("offset", String(params.offset));
394
+ }
395
+ if (params?.resourceId) {
396
+ searchParams.set("resourceId", params.resourceId);
397
+ }
398
+ if (searchParams.size) {
399
+ return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
400
+ } else {
401
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
402
+ }
403
+ }
376
404
  /**
377
405
  * @deprecated Use `startAsync` instead
378
406
  * Executes the workflow with the provided parameters
@@ -489,7 +517,7 @@ var Workflow = class extends BaseResource {
489
517
  }
490
518
  }
491
519
  }
492
- } catch (error) {
520
+ } catch {
493
521
  }
494
522
  }
495
523
  if (buffer) {
@@ -543,9 +571,13 @@ var Tool = class extends BaseResource {
543
571
  * @returns Promise containing the tool execution results
544
572
  */
545
573
  execute(params) {
546
- return this.request(`/api/tools/${this.toolId}/execute`, {
574
+ const url = new URLSearchParams();
575
+ if (params.runId) {
576
+ url.set("runId", params.runId);
577
+ }
578
+ return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
547
579
  method: "POST",
548
- body: params
580
+ body: params.data
549
581
  });
550
582
  }
551
583
  };
@@ -588,7 +620,7 @@ var VNextWorkflow = class extends BaseResource {
588
620
  }
589
621
  }
590
622
  }
591
- } catch (error) {
623
+ } catch {
592
624
  }
593
625
  }
594
626
  if (buffer) {
@@ -609,6 +641,34 @@ var VNextWorkflow = class extends BaseResource {
609
641
  details() {
610
642
  return this.request(`/api/workflows/v-next/${this.workflowId}`);
611
643
  }
644
+ /**
645
+ * Retrieves all runs for a vNext workflow
646
+ * @param params - Parameters for filtering runs
647
+ * @returns Promise containing vNext workflow runs array
648
+ */
649
+ runs(params) {
650
+ const searchParams = new URLSearchParams();
651
+ if (params?.fromDate) {
652
+ searchParams.set("fromDate", params.fromDate.toISOString());
653
+ }
654
+ if (params?.toDate) {
655
+ searchParams.set("toDate", params.toDate.toISOString());
656
+ }
657
+ if (params?.limit) {
658
+ searchParams.set("limit", String(params.limit));
659
+ }
660
+ if (params?.offset) {
661
+ searchParams.set("offset", String(params.offset));
662
+ }
663
+ if (params?.resourceId) {
664
+ searchParams.set("resourceId", params.resourceId);
665
+ }
666
+ if (searchParams.size) {
667
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
668
+ } else {
669
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
670
+ }
671
+ }
612
672
  /**
613
673
  * Creates a new vNext workflow run
614
674
  * @param params - Optional object containing the optional runId
@@ -850,7 +910,7 @@ var MastraClient = class extends BaseResource {
850
910
  * @returns Promise containing telemetry data
851
911
  */
852
912
  getTelemetry(params) {
853
- const { name, scope, page, perPage, attribute } = params || {};
913
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
854
914
  const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
855
915
  const searchParams = new URLSearchParams();
856
916
  if (name) {
@@ -874,6 +934,12 @@ var MastraClient = class extends BaseResource {
874
934
  searchParams.set("attribute", _attribute);
875
935
  }
876
936
  }
937
+ if (fromDate) {
938
+ searchParams.set("fromDate", fromDate.toISOString());
939
+ }
940
+ if (toDate) {
941
+ searchParams.set("toDate", toDate.toISOString());
942
+ }
877
943
  if (searchParams.size) {
878
944
  return this.request(`/api/telemetry?${searchParams}`);
879
945
  } else {
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
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
6
  import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
7
7
  import { RuntimeContext } from '@mastra/core/runtime-context';
@@ -40,6 +40,9 @@ type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
40
40
  } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
41
41
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
42
42
  evals: any[];
43
+ instructions: string;
44
+ name: string;
45
+ id: string;
43
46
  }
44
47
  interface GetToolResponse {
45
48
  id: string;
@@ -55,6 +58,14 @@ interface GetWorkflowResponse {
55
58
  stepSubscriberGraph: Record<string, StepGraph>;
56
59
  workflowId?: string;
57
60
  }
61
+ interface GetWorkflowRunsParams {
62
+ fromDate?: Date;
63
+ toDate?: Date;
64
+ limit?: number;
65
+ offset?: number;
66
+ resourceId?: string;
67
+ }
68
+ type GetWorkflowRunsResponse = WorkflowRuns;
58
69
  type WorkflowRunResult = {
59
70
  activePaths: Record<string, {
60
71
  status: string;
@@ -193,6 +204,8 @@ interface GetTelemetryParams {
193
204
  page?: number;
194
205
  perPage?: number;
195
206
  attribute?: Record<string, string>;
207
+ fromDate?: Date;
208
+ toDate?: Date;
196
209
  }
197
210
  interface GetNetworkResponse {
198
211
  name: string;
@@ -398,6 +411,12 @@ declare class Workflow extends BaseResource {
398
411
  * @returns Promise containing workflow details including steps and graphs
399
412
  */
400
413
  details(): Promise<GetWorkflowResponse>;
414
+ /**
415
+ * Retrieves all runs for a workflow
416
+ * @param params - Parameters for filtering runs
417
+ * @returns Promise containing workflow runs array
418
+ */
419
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
401
420
  /**
402
421
  * @deprecated Use `startAsync` instead
403
422
  * Executes the workflow with the provided parameters
@@ -491,6 +510,7 @@ declare class Tool extends BaseResource {
491
510
  */
492
511
  execute(params: {
493
512
  data: any;
513
+ runId?: string;
494
514
  }): Promise<any>;
495
515
  }
496
516
 
@@ -510,6 +530,12 @@ declare class VNextWorkflow extends BaseResource {
510
530
  * @returns Promise containing vNext workflow details including steps and graphs
511
531
  */
512
532
  details(): Promise<GetVNextWorkflowResponse>;
533
+ /**
534
+ * Retrieves all runs for a vNext workflow
535
+ * @param params - Parameters for filtering runs
536
+ * @returns Promise containing vNext workflow runs array
537
+ */
538
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
513
539
  /**
514
540
  * Creates a new vNext workflow run
515
541
  * @param params - Optional object containing the optional runId
@@ -697,4 +723,4 @@ declare class MastraClient extends BaseResource {
697
723
  getNetwork(networkId: string): Network;
698
724
  }
699
725
 
700
- 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, 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 };
726
+ 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 GetWorkflowRunsParams, 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.d.ts CHANGED
@@ -1,7 +1,7 @@
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
6
  import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
7
7
  import { RuntimeContext } from '@mastra/core/runtime-context';
@@ -40,6 +40,9 @@ type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
40
40
  } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
41
41
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
42
42
  evals: any[];
43
+ instructions: string;
44
+ name: string;
45
+ id: string;
43
46
  }
44
47
  interface GetToolResponse {
45
48
  id: string;
@@ -55,6 +58,14 @@ interface GetWorkflowResponse {
55
58
  stepSubscriberGraph: Record<string, StepGraph>;
56
59
  workflowId?: string;
57
60
  }
61
+ interface GetWorkflowRunsParams {
62
+ fromDate?: Date;
63
+ toDate?: Date;
64
+ limit?: number;
65
+ offset?: number;
66
+ resourceId?: string;
67
+ }
68
+ type GetWorkflowRunsResponse = WorkflowRuns;
58
69
  type WorkflowRunResult = {
59
70
  activePaths: Record<string, {
60
71
  status: string;
@@ -193,6 +204,8 @@ interface GetTelemetryParams {
193
204
  page?: number;
194
205
  perPage?: number;
195
206
  attribute?: Record<string, string>;
207
+ fromDate?: Date;
208
+ toDate?: Date;
196
209
  }
197
210
  interface GetNetworkResponse {
198
211
  name: string;
@@ -398,6 +411,12 @@ declare class Workflow extends BaseResource {
398
411
  * @returns Promise containing workflow details including steps and graphs
399
412
  */
400
413
  details(): Promise<GetWorkflowResponse>;
414
+ /**
415
+ * Retrieves all runs for a workflow
416
+ * @param params - Parameters for filtering runs
417
+ * @returns Promise containing workflow runs array
418
+ */
419
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
401
420
  /**
402
421
  * @deprecated Use `startAsync` instead
403
422
  * Executes the workflow with the provided parameters
@@ -491,6 +510,7 @@ declare class Tool extends BaseResource {
491
510
  */
492
511
  execute(params: {
493
512
  data: any;
513
+ runId?: string;
494
514
  }): Promise<any>;
495
515
  }
496
516
 
@@ -510,6 +530,12 @@ declare class VNextWorkflow extends BaseResource {
510
530
  * @returns Promise containing vNext workflow details including steps and graphs
511
531
  */
512
532
  details(): Promise<GetVNextWorkflowResponse>;
533
+ /**
534
+ * Retrieves all runs for a vNext workflow
535
+ * @param params - Parameters for filtering runs
536
+ * @returns Promise containing vNext workflow runs array
537
+ */
538
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
513
539
  /**
514
540
  * Creates a new vNext workflow run
515
541
  * @param params - Optional object containing the optional runId
@@ -697,4 +723,4 @@ declare class MastraClient extends BaseResource {
697
723
  getNetwork(networkId: string): Network;
698
724
  }
699
725
 
700
- 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, 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 };
726
+ 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 GetWorkflowRunsParams, 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,34 @@ 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
+ * @param params - Parameters for filtering runs
377
+ * @returns Promise containing workflow runs array
378
+ */
379
+ runs(params) {
380
+ const searchParams = new URLSearchParams();
381
+ if (params?.fromDate) {
382
+ searchParams.set("fromDate", params.fromDate.toISOString());
383
+ }
384
+ if (params?.toDate) {
385
+ searchParams.set("toDate", params.toDate.toISOString());
386
+ }
387
+ if (params?.limit) {
388
+ searchParams.set("limit", String(params.limit));
389
+ }
390
+ if (params?.offset) {
391
+ searchParams.set("offset", String(params.offset));
392
+ }
393
+ if (params?.resourceId) {
394
+ searchParams.set("resourceId", params.resourceId);
395
+ }
396
+ if (searchParams.size) {
397
+ return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
398
+ } else {
399
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
400
+ }
401
+ }
374
402
  /**
375
403
  * @deprecated Use `startAsync` instead
376
404
  * Executes the workflow with the provided parameters
@@ -487,7 +515,7 @@ var Workflow = class extends BaseResource {
487
515
  }
488
516
  }
489
517
  }
490
- } catch (error) {
518
+ } catch {
491
519
  }
492
520
  }
493
521
  if (buffer) {
@@ -541,9 +569,13 @@ var Tool = class extends BaseResource {
541
569
  * @returns Promise containing the tool execution results
542
570
  */
543
571
  execute(params) {
544
- return this.request(`/api/tools/${this.toolId}/execute`, {
572
+ const url = new URLSearchParams();
573
+ if (params.runId) {
574
+ url.set("runId", params.runId);
575
+ }
576
+ return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
545
577
  method: "POST",
546
- body: params
578
+ body: params.data
547
579
  });
548
580
  }
549
581
  };
@@ -586,7 +618,7 @@ var VNextWorkflow = class extends BaseResource {
586
618
  }
587
619
  }
588
620
  }
589
- } catch (error) {
621
+ } catch {
590
622
  }
591
623
  }
592
624
  if (buffer) {
@@ -607,6 +639,34 @@ var VNextWorkflow = class extends BaseResource {
607
639
  details() {
608
640
  return this.request(`/api/workflows/v-next/${this.workflowId}`);
609
641
  }
642
+ /**
643
+ * Retrieves all runs for a vNext workflow
644
+ * @param params - Parameters for filtering runs
645
+ * @returns Promise containing vNext workflow runs array
646
+ */
647
+ runs(params) {
648
+ const searchParams = new URLSearchParams();
649
+ if (params?.fromDate) {
650
+ searchParams.set("fromDate", params.fromDate.toISOString());
651
+ }
652
+ if (params?.toDate) {
653
+ searchParams.set("toDate", params.toDate.toISOString());
654
+ }
655
+ if (params?.limit) {
656
+ searchParams.set("limit", String(params.limit));
657
+ }
658
+ if (params?.offset) {
659
+ searchParams.set("offset", String(params.offset));
660
+ }
661
+ if (params?.resourceId) {
662
+ searchParams.set("resourceId", params.resourceId);
663
+ }
664
+ if (searchParams.size) {
665
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
666
+ } else {
667
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
668
+ }
669
+ }
610
670
  /**
611
671
  * Creates a new vNext workflow run
612
672
  * @param params - Optional object containing the optional runId
@@ -848,7 +908,7 @@ var MastraClient = class extends BaseResource {
848
908
  * @returns Promise containing telemetry data
849
909
  */
850
910
  getTelemetry(params) {
851
- const { name, scope, page, perPage, attribute } = params || {};
911
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
852
912
  const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
853
913
  const searchParams = new URLSearchParams();
854
914
  if (name) {
@@ -872,6 +932,12 @@ var MastraClient = class extends BaseResource {
872
932
  searchParams.set("attribute", _attribute);
873
933
  }
874
934
  }
935
+ if (fromDate) {
936
+ searchParams.set("fromDate", fromDate.toISOString());
937
+ }
938
+ if (toDate) {
939
+ searchParams.set("toDate", toDate.toISOString());
940
+ }
875
941
  if (searchParams.size) {
876
942
  return this.request(`/api/telemetry?${searchParams}`);
877
943
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.1.20-alpha.0",
3
+ "version": "0.1.20-alpha.3",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
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.9.2-alpha.0"
29
+ "@mastra/core": "^0.9.2-alpha.3"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "zod": "^3.24.2"
package/src/client.ts CHANGED
@@ -180,7 +180,7 @@ export class MastraClient extends BaseResource {
180
180
  * @returns Promise containing telemetry data
181
181
  */
182
182
  public getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse> {
183
- const { name, scope, page, perPage, attribute } = params || {};
183
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
184
184
  const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
185
185
 
186
186
  const searchParams = new URLSearchParams();
@@ -205,6 +205,12 @@ export class MastraClient extends BaseResource {
205
205
  searchParams.set('attribute', _attribute);
206
206
  }
207
207
  }
208
+ if (fromDate) {
209
+ searchParams.set('fromDate', fromDate.toISOString());
210
+ }
211
+ if (toDate) {
212
+ searchParams.set('toDate', toDate.toISOString());
213
+ }
208
214
 
209
215
  if (searchParams.size) {
210
216
  return this.request(`/api/telemetry?${searchParams}`);
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;
@@ -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
  }
@@ -2,6 +2,8 @@ import type { RuntimeContext } from '@mastra/core/runtime-context';
2
2
  import type {
3
3
  ClientOptions,
4
4
  GetVNextWorkflowResponse,
5
+ GetWorkflowRunsParams,
6
+ GetWorkflowRunsResponse,
5
7
  VNextWorkflowRunResult,
6
8
  VNextWorkflowWatchResult,
7
9
  } from '../types';
@@ -67,7 +69,7 @@ export class VNextWorkflow extends BaseResource {
67
69
  }
68
70
  }
69
71
  }
70
- } catch (error) {
72
+ } catch {
71
73
  // Silently ignore parsing errors to maintain stream processing
72
74
  // This allows the stream to continue even if one record is malformed
73
75
  }
@@ -97,6 +99,36 @@ export class VNextWorkflow extends BaseResource {
97
99
  return this.request(`/api/workflows/v-next/${this.workflowId}`);
98
100
  }
99
101
 
102
+ /**
103
+ * Retrieves all runs for a vNext workflow
104
+ * @param params - Parameters for filtering runs
105
+ * @returns Promise containing vNext workflow runs array
106
+ */
107
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse> {
108
+ const searchParams = new URLSearchParams();
109
+ if (params?.fromDate) {
110
+ searchParams.set('fromDate', params.fromDate.toISOString());
111
+ }
112
+ if (params?.toDate) {
113
+ searchParams.set('toDate', params.toDate.toISOString());
114
+ }
115
+ if (params?.limit) {
116
+ searchParams.set('limit', String(params.limit));
117
+ }
118
+ if (params?.offset) {
119
+ searchParams.set('offset', String(params.offset));
120
+ }
121
+ if (params?.resourceId) {
122
+ searchParams.set('resourceId', params.resourceId);
123
+ }
124
+
125
+ if (searchParams.size) {
126
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
127
+ } else {
128
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
129
+ }
130
+ }
131
+
100
132
  /**
101
133
  * Creates a new vNext workflow run
102
134
  * @param params - Optional object containing the optional runId
@@ -1,4 +1,10 @@
1
- import type { GetWorkflowResponse, ClientOptions, WorkflowRunResult } from '../types';
1
+ import type {
2
+ GetWorkflowResponse,
3
+ ClientOptions,
4
+ WorkflowRunResult,
5
+ GetWorkflowRunsResponse,
6
+ GetWorkflowRunsParams,
7
+ } from '../types';
2
8
 
3
9
  import { BaseResource } from './base';
4
10
 
@@ -20,6 +26,36 @@ export class Workflow extends BaseResource {
20
26
  return this.request(`/api/workflows/${this.workflowId}`);
21
27
  }
22
28
 
29
+ /**
30
+ * Retrieves all runs for a workflow
31
+ * @param params - Parameters for filtering runs
32
+ * @returns Promise containing workflow runs array
33
+ */
34
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse> {
35
+ const searchParams = new URLSearchParams();
36
+ if (params?.fromDate) {
37
+ searchParams.set('fromDate', params.fromDate.toISOString());
38
+ }
39
+ if (params?.toDate) {
40
+ searchParams.set('toDate', params.toDate.toISOString());
41
+ }
42
+ if (params?.limit) {
43
+ searchParams.set('limit', String(params.limit));
44
+ }
45
+ if (params?.offset) {
46
+ searchParams.set('offset', String(params.offset));
47
+ }
48
+ if (params?.resourceId) {
49
+ searchParams.set('resourceId', params.resourceId);
50
+ }
51
+
52
+ if (searchParams.size) {
53
+ return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
54
+ } else {
55
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
56
+ }
57
+ }
58
+
23
59
  /**
24
60
  * @deprecated Use `startAsync` instead
25
61
  * Executes the workflow with the provided parameters
@@ -168,7 +204,7 @@ export class Workflow extends BaseResource {
168
204
  }
169
205
  }
170
206
  }
171
- } catch (error) {
207
+ } catch {
172
208
  // Silently ignore parsing errors to maintain stream processing
173
209
  // This allows the stream to continue even if one record is malformed
174
210
  }
package/src/types.ts CHANGED
@@ -8,6 +8,7 @@ import type {
8
8
  StorageThreadType,
9
9
  BaseLogMessage,
10
10
  WorkflowRunResult as CoreWorkflowRunResult,
11
+ WorkflowRuns,
11
12
  } from '@mastra/core';
12
13
 
13
14
  import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
@@ -55,6 +56,9 @@ export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefin
55
56
 
56
57
  export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
57
58
  evals: any[];
59
+ instructions: string;
60
+ name: string;
61
+ id: string;
58
62
  }
59
63
 
60
64
  export interface GetToolResponse {
@@ -73,6 +77,16 @@ export interface GetWorkflowResponse {
73
77
  workflowId?: string;
74
78
  }
75
79
 
80
+ export interface GetWorkflowRunsParams {
81
+ fromDate?: Date;
82
+ toDate?: Date;
83
+ limit?: number;
84
+ offset?: number;
85
+ resourceId?: string;
86
+ }
87
+
88
+ export type GetWorkflowRunsResponse = WorkflowRuns;
89
+
76
90
  export type WorkflowRunResult = {
77
91
  activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
78
92
  results: CoreWorkflowRunResult<any, any, any>['results'];
@@ -228,6 +242,8 @@ export interface GetTelemetryParams {
228
242
  page?: number;
229
243
  perPage?: number;
230
244
  attribute?: Record<string, string>;
245
+ fromDate?: Date;
246
+ toDate?: Date;
231
247
  }
232
248
 
233
249
  export interface GetNetworkResponse {