@mastra/client-js 0.10.5-alpha.0 → 0.10.5-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.10.5-alpha.0 build /home/runner/work/mastra/mastra/client-sdks/client-js
2
+ > @mastra/client-js@0.10.5-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
- ESM dist/index.js 46.36 KB
13
- ESM ⚡️ Build success in 1229ms
14
- CJS dist/index.cjs 46.65 KB
15
- CJS ⚡️ Build success in 1218ms
12
+ CJS dist/index.cjs 47.24 KB
13
+ CJS ⚡️ Build success in 1490ms
14
+ ESM dist/index.js 46.95 KB
15
+ ESM ⚡️ Build success in 2034ms
16
16
  DTS Build start
17
- DTS ⚡️ Build success in 14740ms
18
- DTS dist/index.d.ts 32.85 KB
19
- DTS dist/index.d.cts 32.85 KB
17
+ DTS ⚡️ Build success in 15050ms
18
+ DTS dist/index.d.ts 33.64 KB
19
+ DTS dist/index.d.cts 33.64 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 0.10.5-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ee9af57: Add api for polling run execution result and get run by id
8
+ - 3270d9d: Fix runtime context being undefined
9
+ - Updated dependencies [ee9af57]
10
+ - Updated dependencies [751c894]
11
+ - Updated dependencies [577ce3a]
12
+ - Updated dependencies [9260b3a]
13
+ - @mastra/core@0.10.6-alpha.1
14
+
3
15
  ## 0.10.5-alpha.0
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -922,6 +922,22 @@ var Workflow = class extends BaseResource {
922
922
  return this.request(`/api/workflows/${this.workflowId}/runs`);
923
923
  }
924
924
  }
925
+ /**
926
+ * Retrieves a specific workflow run by its ID
927
+ * @param runId - The ID of the workflow run to retrieve
928
+ * @returns Promise containing the workflow run details
929
+ */
930
+ runById(runId) {
931
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
932
+ }
933
+ /**
934
+ * Retrieves the execution result for a specific workflow run by its ID
935
+ * @param runId - The ID of the workflow run to retrieve the execution result for
936
+ * @returns Promise containing the workflow run execution result
937
+ */
938
+ runExecutionResult(runId) {
939
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
940
+ }
925
941
  /**
926
942
  * Creates a new workflow run
927
943
  * @param params - Optional object containing the optional runId
@@ -996,7 +1012,7 @@ var Workflow = class extends BaseResource {
996
1012
  if (!!params?.runId) {
997
1013
  searchParams.set("runId", params.runId);
998
1014
  }
999
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
1015
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1000
1016
  const response = await this.request(
1001
1017
  `/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
1002
1018
  {
package/dist/index.d.cts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
2
  import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
3
  import { processDataStream } from '@ai-sdk/ui-utils';
4
- import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
4
+ import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
5
5
  import { JSONSchema7 } from 'json-schema';
6
6
  import { ZodSchema } from 'zod';
7
7
  import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
8
8
  import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
9
9
  import { RuntimeContext } from '@mastra/core/runtime-context';
10
- import { Workflow as Workflow$1, WorkflowResult, WatchEvent } from '@mastra/core/workflows';
10
+ import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
11
11
  import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
12
12
  import * as stream_web from 'stream/web';
13
13
  import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
@@ -89,6 +89,8 @@ interface GetWorkflowRunsParams {
89
89
  }
90
90
  type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
91
91
  type GetWorkflowRunsResponse = WorkflowRuns;
92
+ type GetWorkflowRunByIdResponse = WorkflowRun;
93
+ type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
92
94
  type LegacyWorkflowRunResult = {
93
95
  activePaths: Record<string, {
94
96
  status: string;
@@ -624,6 +626,18 @@ declare class Workflow extends BaseResource {
624
626
  * @returns Promise containing workflow runs array
625
627
  */
626
628
  runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
629
+ /**
630
+ * Retrieves a specific workflow run by its ID
631
+ * @param runId - The ID of the workflow run to retrieve
632
+ * @returns Promise containing the workflow run details
633
+ */
634
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
635
+ /**
636
+ * Retrieves the execution result for a specific workflow run by its ID
637
+ * @param runId - The ID of the workflow run to retrieve the execution result for
638
+ * @returns Promise containing the workflow run execution result
639
+ */
640
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
627
641
  /**
628
642
  * Creates a new workflow run
629
643
  * @param params - Optional object containing the optional runId
@@ -935,4 +949,4 @@ declare class MastraClient extends BaseResource {
935
949
  getA2A(agentId: string): A2A;
936
950
  }
937
951
 
938
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
952
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
2
  import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
3
  import { processDataStream } from '@ai-sdk/ui-utils';
4
- import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
4
+ import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
5
5
  import { JSONSchema7 } from 'json-schema';
6
6
  import { ZodSchema } from 'zod';
7
7
  import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
8
8
  import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
9
9
  import { RuntimeContext } from '@mastra/core/runtime-context';
10
- import { Workflow as Workflow$1, WorkflowResult, WatchEvent } from '@mastra/core/workflows';
10
+ import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
11
11
  import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
12
12
  import * as stream_web from 'stream/web';
13
13
  import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
@@ -89,6 +89,8 @@ interface GetWorkflowRunsParams {
89
89
  }
90
90
  type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
91
91
  type GetWorkflowRunsResponse = WorkflowRuns;
92
+ type GetWorkflowRunByIdResponse = WorkflowRun;
93
+ type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
92
94
  type LegacyWorkflowRunResult = {
93
95
  activePaths: Record<string, {
94
96
  status: string;
@@ -624,6 +626,18 @@ declare class Workflow extends BaseResource {
624
626
  * @returns Promise containing workflow runs array
625
627
  */
626
628
  runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
629
+ /**
630
+ * Retrieves a specific workflow run by its ID
631
+ * @param runId - The ID of the workflow run to retrieve
632
+ * @returns Promise containing the workflow run details
633
+ */
634
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
635
+ /**
636
+ * Retrieves the execution result for a specific workflow run by its ID
637
+ * @param runId - The ID of the workflow run to retrieve the execution result for
638
+ * @returns Promise containing the workflow run execution result
639
+ */
640
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
627
641
  /**
628
642
  * Creates a new workflow run
629
643
  * @param params - Optional object containing the optional runId
@@ -935,4 +949,4 @@ declare class MastraClient extends BaseResource {
935
949
  getA2A(agentId: string): A2A;
936
950
  }
937
951
 
938
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
952
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
package/dist/index.js CHANGED
@@ -916,6 +916,22 @@ var Workflow = class extends BaseResource {
916
916
  return this.request(`/api/workflows/${this.workflowId}/runs`);
917
917
  }
918
918
  }
919
+ /**
920
+ * Retrieves a specific workflow run by its ID
921
+ * @param runId - The ID of the workflow run to retrieve
922
+ * @returns Promise containing the workflow run details
923
+ */
924
+ runById(runId) {
925
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
926
+ }
927
+ /**
928
+ * Retrieves the execution result for a specific workflow run by its ID
929
+ * @param runId - The ID of the workflow run to retrieve the execution result for
930
+ * @returns Promise containing the workflow run execution result
931
+ */
932
+ runExecutionResult(runId) {
933
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
934
+ }
919
935
  /**
920
936
  * Creates a new workflow run
921
937
  * @param params - Optional object containing the optional runId
@@ -990,7 +1006,7 @@ var Workflow = class extends BaseResource {
990
1006
  if (!!params?.runId) {
991
1007
  searchParams.set("runId", params.runId);
992
1008
  }
993
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
1009
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
994
1010
  const response = await this.request(
995
1011
  `/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
996
1012
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.10.5-alpha.0",
3
+ "version": "0.10.5-alpha.1",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  "rxjs": "7.8.1",
34
34
  "zod": "^3.25.57",
35
35
  "zod-to-json-schema": "^3.24.5",
36
- "@mastra/core": "0.10.6-alpha.0"
36
+ "@mastra/core": "0.10.6-alpha.1"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "zod": "^3.0.0"
@@ -6,6 +6,8 @@ import type {
6
6
  GetWorkflowRunsParams,
7
7
  WorkflowRunResult,
8
8
  WorkflowWatchResult,
9
+ GetWorkflowRunByIdResponse,
10
+ GetWorkflowRunExecutionResultResponse,
9
11
  } from '../types';
10
12
 
11
13
  import { parseClientRuntimeContext } from '../utils';
@@ -130,6 +132,24 @@ export class Workflow extends BaseResource {
130
132
  }
131
133
  }
132
134
 
135
+ /**
136
+ * Retrieves a specific workflow run by its ID
137
+ * @param runId - The ID of the workflow run to retrieve
138
+ * @returns Promise containing the workflow run details
139
+ */
140
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse> {
141
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
142
+ }
143
+
144
+ /**
145
+ * Retrieves the execution result for a specific workflow run by its ID
146
+ * @param runId - The ID of the workflow run to retrieve the execution result for
147
+ * @returns Promise containing the workflow run execution result
148
+ */
149
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse> {
150
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
151
+ }
152
+
133
153
  /**
134
154
  * Creates a new workflow run
135
155
  * @param params - Optional object containing the optional runId
@@ -228,7 +248,7 @@ export class Workflow extends BaseResource {
228
248
  searchParams.set('runId', params.runId);
229
249
  }
230
250
 
231
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined;
251
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
232
252
  const response: Response = await this.request(
233
253
  `/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
234
254
  {
package/src/types.ts CHANGED
@@ -5,6 +5,7 @@ import type {
5
5
  QueryResult,
6
6
  StorageThreadType,
7
7
  WorkflowRuns,
8
+ WorkflowRun,
8
9
  LegacyWorkflowRuns,
9
10
  } from '@mastra/core';
10
11
  import type { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
@@ -115,6 +116,10 @@ export type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
115
116
 
116
117
  export type GetWorkflowRunsResponse = WorkflowRuns;
117
118
 
119
+ export type GetWorkflowRunByIdResponse = WorkflowRun;
120
+
121
+ export type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
122
+
118
123
  export type LegacyWorkflowRunResult = {
119
124
  activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
120
125
  results: CoreLegacyWorkflowRunResult<any, any, any>['results'];