@mastra/client-js 1.21.1 → 1.21.2-alpha.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.21.2-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`d779de3`](https://github.com/mastra-ai/mastra/commit/d779de3cd9d2e7ed8110547190e2f15e786a0e41), [`1750c97`](https://github.com/mastra-ai/mastra/commit/1750c975d6179fbf6db2813b15229d4f8f23fc55), [`0e32507`](https://github.com/mastra-ai/mastra/commit/0e32507962cdfa5569b7bda5bc6fb3dd34e40b03), [`3a081c1`](https://github.com/mastra-ai/mastra/commit/3a081c1255c5ae8c99f6dad91cc612934ef6f2bd), [`fe9eacd`](https://github.com/mastra-ai/mastra/commit/fe9eacd9545a0a9d64aad31c9fa90294a425289e), [`db79c86`](https://github.com/mastra-ai/mastra/commit/db79c86c60723d57e02f9636ca2611bd4515f194)]:
8
+ - @mastra/core@1.38.0-alpha.2
9
+
10
+ ## 1.21.2-alpha.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Fixed sub-agent version resolution in supervisor mode. Sub-agents now inherit the parent's draft/published version semantics — when chatting in the editor (draft mode), sub-agents resolve to their latest draft version; in the main agent chat (published mode), sub-agents resolve to their published version. Previously, sub-agents without explicit per-agent version overrides always fell back to the code-defined default, ignoring the parent's version context. ([#17165](https://github.com/mastra-ai/mastra/pull/17165))
15
+
16
+ - Updated dependencies [[`49f8abc`](https://github.com/mastra-ai/mastra/commit/49f8abce8258e4f2f87bd326acfbdb641264a47c)]:
17
+ - @mastra/core@1.37.2-alpha.1
18
+
19
+ ## 1.21.2-alpha.0
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [[`07c3de7`](https://github.com/mastra-ai/mastra/commit/07c3de7f7bc418beccaea3b5e6b7f7cdda79d492)]:
24
+ - @mastra/core@1.37.2-alpha.0
25
+
3
26
  ## 1.21.1
4
27
 
5
28
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-client-js
3
3
  description: Documentation for @mastra/client-js. Use when working with @mastra/client-js APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/client-js"
6
- version: "1.21.1"
6
+ version: "1.21.2-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -33,6 +33,7 @@ Read the individual reference documents for detailed explanations and code examp
33
33
  - [Reference: toAISdkStream()](references/reference-ai-sdk-to-ai-sdk-stream.md) - API reference for toAISdkStream(), a function to convert Mastra streams to AI SDK-compatible streams.
34
34
  - [Reference: toAISdkV4Messages()](references/reference-ai-sdk-to-ai-sdk-v4-messages.md) - API reference for toAISdkV4Messages(), a function to convert Mastra messages to AI SDK v4 UI messages.
35
35
  - [Reference: toAISdkV5Messages()](references/reference-ai-sdk-to-ai-sdk-v5-messages.md) - API reference for toAISdkV5Messages(), a function to convert Mastra messages to AI SDK v5 UI messages.
36
+ - [Reference: Agent Builder API](references/reference-client-js-agent-builder.md) - Learn how to interact with Agent Builder actions, including starting runs, streaming progress, resuming suspended steps, and observing runs using the client-js SDK.
36
37
  - [Reference: Agents API](references/reference-client-js-agents.md) - Learn how to interact with Mastra AI agents, including generating responses, streaming interactions, and managing agent tools using the client-js SDK.
37
38
  - [Reference: OpenAI Responses API Conversations](references/reference-client-js-conversations.md) - API reference for the client-js helpers that call Mastra's OpenAI-compatible `/v1/conversations` routes.
38
39
  - [Reference: Error handling](references/reference-client-js-error-handling.md) - Learn about the built-in retry mechanism and error handling capabilities in the Mastra client-js SDK.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.21.1",
2
+ "version": "1.21.2-alpha.2",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {
5
5
  "RequestContext": {
@@ -0,0 +1,161 @@
1
+ # Agent Builder API
2
+
3
+ The Agent Builder API provides methods to interact with [Agent Builder](https://mastra.ai/docs/agent-builder/overview) actions on the server. Each action is a workflow exposed under `/agent-builder/:actionId/*`. The Builder must be enabled on the server via `MastraEditor.builder.enabled`, with a valid `MASTRA_EE_LICENSE` in production.
4
+
5
+ ## Getting all actions
6
+
7
+ Retrieve a record of available Agent Builder actions:
8
+
9
+ ```typescript
10
+ const actions = await mastraClient.getAgentBuilderActions()
11
+ ```
12
+
13
+ Returns a `Record<string, WorkflowInfo>` keyed by action ID.
14
+
15
+ ## Working with a specific action
16
+
17
+ Get an instance of a specific action by its ID:
18
+
19
+ ```typescript
20
+ const action = mastraClient.getAgentBuilderAction('create-agent')
21
+ ```
22
+
23
+ ## Action methods
24
+
25
+ ### `details()`
26
+
27
+ Retrieve metadata about an Agent Builder action:
28
+
29
+ ```typescript
30
+ const info = await action.details()
31
+ ```
32
+
33
+ ### `createRun()`
34
+
35
+ Create a new run for this action and receive a `runId`. Use the returned id with `startActionRun()`, `stream()`, `resume()`, or `observeStream()`.
36
+
37
+ ```typescript
38
+ const { runId } = await action.createRun()
39
+ ```
40
+
41
+ You can also pass an explicit `runId`:
42
+
43
+ ```typescript
44
+ const { runId } = await action.createRun({ runId: 'my-run-id' })
45
+ ```
46
+
47
+ ### `startAsync()`
48
+
49
+ Start the action and wait for completion. Returns the final `AgentBuilderActionResult` with `success`, `applied`, `branchName`, `message`, `validationResults`, `error`, `errors`, and `stepResults`.
50
+
51
+ ```typescript
52
+ const result = await action.startAsync({
53
+ inputData: { agentName: 'support-bot' },
54
+ })
55
+ ```
56
+
57
+ Pass an existing `runId` as the second argument to start a previously created run:
58
+
59
+ ```typescript
60
+ const { runId } = await action.createRun()
61
+ const result = await action.startAsync({ inputData }, runId)
62
+ ```
63
+
64
+ ### `startActionRun()`
65
+
66
+ Start an existing run without waiting for completion. Returns `{ message }`.
67
+
68
+ ```typescript
69
+ const { runId } = await action.createRun()
70
+ await action.startActionRun({ inputData }, runId)
71
+ ```
72
+
73
+ ### `stream()`
74
+
75
+ Start an existing run and stream progress events as a `ReadableStream<{ type, payload }>`.
76
+
77
+ ```typescript
78
+ const { runId } = await action.createRun()
79
+ const stream = await action.stream({ inputData }, runId)
80
+
81
+ for await (const event of stream) {
82
+ console.log(event.type, event.payload)
83
+ }
84
+ ```
85
+
86
+ ### `resume()`
87
+
88
+ Resume a suspended step on a run. Returns `{ message }`.
89
+
90
+ ```typescript
91
+ await action.resume({ step: 'review', resumeData: { approved: true } }, runId)
92
+ ```
93
+
94
+ ### `resumeAsync()`
95
+
96
+ Resume a suspended step and wait for completion. Returns an `AgentBuilderActionResult`.
97
+
98
+ ```typescript
99
+ const result = await action.resumeAsync({ step: 'review', resumeData: { approved: true } }, runId)
100
+ ```
101
+
102
+ ### `resumeStream()`
103
+
104
+ Resume a suspended step and stream subsequent events.
105
+
106
+ ```typescript
107
+ const stream = await action.resumeStream({
108
+ runId,
109
+ step: 'review',
110
+ resumeData: { approved: true },
111
+ })
112
+ ```
113
+
114
+ ### `observeStream()`
115
+
116
+ Attach to an existing run, replaying cached events from the beginning, then continuing with live events. Use this to recover after a page refresh or hot reload.
117
+
118
+ ```typescript
119
+ const stream = await action.observeStream({ runId })
120
+ ```
121
+
122
+ ### `observeStreamLegacy()`
123
+
124
+ Same as `observeStream()` but uses the legacy streaming endpoint. Prefer `observeStream()` for new code.
125
+
126
+ ```typescript
127
+ const stream = await action.observeStreamLegacy({ runId })
128
+ ```
129
+
130
+ ### `runs()`
131
+
132
+ List runs for this action with optional filters.
133
+
134
+ ```typescript
135
+ const runs = await action.runs({ page: 0, perPage: 20 })
136
+ ```
137
+
138
+ Accepts `fromDate`, `toDate`, `page`, `perPage`, `resourceId`, and legacy `limit`/`offset`.
139
+
140
+ ### `runById()`
141
+
142
+ Fetch a specific run by ID. Use `fields` to limit the returned payload and `withNestedWorkflows` to skip nested workflow data.
143
+
144
+ ```typescript
145
+ const run = await action.runById(runId, {
146
+ fields: ['result', 'steps'],
147
+ withNestedWorkflows: false,
148
+ })
149
+ ```
150
+
151
+ ### `cancelRun()`
152
+
153
+ Cancel an in-flight run.
154
+
155
+ ```typescript
156
+ await action.cancelRun(runId)
157
+ ```
158
+
159
+ ## Access control
160
+
161
+ The `/agent-builder/*` routes are gated by the `agent-builder` permission resource. Calling clients need at minimum `agent-builder:read` and `agent-builder:execute`, plus any picker resources the action touches (`stored-agents`, `stored-skills`, `tools`, `workflows`, `memory`). See [Access control](https://mastra.ai/docs/agent-builder/access-control) for the full grant list.
@@ -73,6 +73,10 @@ You can also pass `requestContext` as a `Record<string, any>`.
73
73
 
74
74
  **getWorkflow(workflowId)** (`Workflow`): Retrieves a specific workflow instance by ID.
75
75
 
76
+ **getAgentBuilderActions()** (`Promise<Record<string, WorkflowInfo>>`): Returns all available Agent Builder actions. See \[Agent Builder API]\(/reference/client-js/agent-builder).
77
+
78
+ **getAgentBuilderAction(actionId)** (`AgentBuilder`): Retrieves an Agent Builder action by ID. See \[Agent Builder API]\(/reference/client-js/agent-builder).
79
+
76
80
  **responses** (`Responses`): Provides OpenAI-style Responses API helpers with \`create()\`, \`retrieve()\`, \`stream()\`, and \`delete()\`.
77
81
 
78
82
  **conversations** (`Conversations`): Provides conversation helpers with \`create()\`, \`retrieve()\`, \`delete()\`, and \`items.list()\`.
@@ -2362,7 +2362,7 @@ export interface PostAgentsAgentIdClone_RouteContract {
2362
2362
  responseType: 'json';
2363
2363
  }
2364
2364
  export type GetAgentsAgentIdVoiceSpeakers_PathParams = {
2365
- /** Unique identifier for the agent */
2365
+ /** Agent ID */
2366
2366
  agentId: string;
2367
2367
  };
2368
2368
  export type GetAgentsAgentIdVoiceSpeakers_Response = {
@@ -2388,14 +2388,17 @@ export interface GetAgentsAgentIdVoiceSpeakers_RouteContract {
2388
2388
  response: GetAgentsAgentIdVoiceSpeakers_Response;
2389
2389
  responseType: 'json';
2390
2390
  }
2391
+ /** @deprecated */
2391
2392
  export type GetAgentsAgentIdSpeakers_PathParams = {
2392
- /** Unique identifier for the agent */
2393
+ /** Agent ID */
2393
2394
  agentId: string;
2394
2395
  };
2396
+ /** @deprecated */
2395
2397
  export type GetAgentsAgentIdSpeakers_Response = {
2396
2398
  voiceId: string;
2397
2399
  [x: string]: unknown;
2398
2400
  }[];
2401
+ /** @deprecated */
2399
2402
  export type GetAgentsAgentIdSpeakers_Request = Simplify<(GetAgentsAgentIdSpeakers_PathParams extends never ? {} : {
2400
2403
  params: GetAgentsAgentIdSpeakers_PathParams;
2401
2404
  }) & (never extends never ? {} : {} extends never ? {
@@ -2407,6 +2410,7 @@ export type GetAgentsAgentIdSpeakers_Request = Simplify<(GetAgentsAgentIdSpeaker
2407
2410
  } : {
2408
2411
  body: never;
2409
2412
  })>;
2413
+ /** @deprecated */
2410
2414
  export interface GetAgentsAgentIdSpeakers_RouteContract {
2411
2415
  pathParams: GetAgentsAgentIdSpeakers_PathParams;
2412
2416
  queryParams: never;
@@ -2448,6 +2452,7 @@ export type PostAgentsAgentIdGenerate_Body = {
2448
2452
  status: 'draft' | 'published';
2449
2453
  };
2450
2454
  } | undefined;
2455
+ defaultStatus?: ('draft' | 'published') | undefined;
2451
2456
  } | undefined;
2452
2457
  maxSteps?: number | undefined;
2453
2458
  stopWhen?: any | undefined;
@@ -2564,6 +2569,7 @@ export type PostAgentsAgentIdGenerateVnext_Body = {
2564
2569
  status: 'draft' | 'published';
2565
2570
  };
2566
2571
  } | undefined;
2572
+ defaultStatus?: ('draft' | 'published') | undefined;
2567
2573
  } | undefined;
2568
2574
  maxSteps?: number | undefined;
2569
2575
  stopWhen?: any | undefined;
@@ -2680,6 +2686,7 @@ export type PostAgentsAgentIdStream_Body = {
2680
2686
  status: 'draft' | 'published';
2681
2687
  };
2682
2688
  } | undefined;
2689
+ defaultStatus?: ('draft' | 'published') | undefined;
2683
2690
  } | undefined;
2684
2691
  maxSteps?: number | undefined;
2685
2692
  stopWhen?: any | undefined;
@@ -2796,6 +2803,7 @@ export type PostAgentsAgentIdStreamUntilIdle_Body = {
2796
2803
  status: 'draft' | 'published';
2797
2804
  };
2798
2805
  } | undefined;
2806
+ defaultStatus?: ('draft' | 'published') | undefined;
2799
2807
  } | undefined;
2800
2808
  maxSteps?: number | undefined;
2801
2809
  stopWhen?: any | undefined;
@@ -2915,6 +2923,7 @@ export type PostAgentsAgentIdStreamVnext_Body = {
2915
2923
  status: 'draft' | 'published';
2916
2924
  };
2917
2925
  } | undefined;
2926
+ defaultStatus?: ('draft' | 'published') | undefined;
2918
2927
  } | undefined;
2919
2928
  maxSteps?: number | undefined;
2920
2929
  stopWhen?: any | undefined;
@@ -3153,6 +3162,7 @@ export type PostAgentsAgentIdSignals_Body = {
3153
3162
  status: 'draft' | 'published';
3154
3163
  };
3155
3164
  } | undefined;
3165
+ defaultStatus?: ('draft' | 'published') | undefined;
3156
3166
  } | undefined;
3157
3167
  maxSteps?: number | undefined;
3158
3168
  stopWhen?: any | undefined;
@@ -3401,6 +3411,7 @@ export type PostAgentsAgentIdResumeStream_Body = {
3401
3411
  status: 'draft' | 'published';
3402
3412
  };
3403
3413
  } | undefined;
3414
+ defaultStatus?: ('draft' | 'published') | undefined;
3404
3415
  } | undefined;
3405
3416
  maxSteps?: number | undefined;
3406
3417
  stopWhen?: any | undefined;
@@ -3644,6 +3655,7 @@ export type PostAgentsAgentIdResumeStreamUntilIdle_Body = {
3644
3655
  status: 'draft' | 'published';
3645
3656
  };
3646
3657
  } | undefined;
3658
+ defaultStatus?: ('draft' | 'published') | undefined;
3647
3659
  } | undefined;
3648
3660
  maxSteps?: number | undefined;
3649
3661
  stopWhen?: any | undefined;
@@ -3763,6 +3775,7 @@ export type PostAgentsAgentIdNetwork_Body = {
3763
3775
  status: 'draft' | 'published';
3764
3776
  };
3765
3777
  } | undefined;
3778
+ defaultStatus?: ('draft' | 'published') | undefined;
3766
3779
  } | undefined;
3767
3780
  maxSteps?: number | undefined;
3768
3781
  stopWhen?: any | undefined;
@@ -4088,7 +4101,7 @@ export interface GetAgentsAgentIdSkillsSkillName_RouteContract {
4088
4101
  responseType: 'json';
4089
4102
  }
4090
4103
  export type PostAgentsAgentIdVoiceSpeak_PathParams = {
4091
- /** Unique identifier for the agent */
4104
+ /** Agent ID */
4092
4105
  agentId: string;
4093
4106
  };
4094
4107
  export type PostAgentsAgentIdVoiceSpeak_Body = {
@@ -4115,15 +4128,19 @@ export interface PostAgentsAgentIdVoiceSpeak_RouteContract {
4115
4128
  response: PostAgentsAgentIdVoiceSpeak_Response;
4116
4129
  responseType: 'stream';
4117
4130
  }
4131
+ /** @deprecated */
4118
4132
  export type PostAgentsAgentIdSpeak_PathParams = {
4119
- /** Unique identifier for the agent */
4133
+ /** Agent ID */
4120
4134
  agentId: string;
4121
4135
  };
4136
+ /** @deprecated */
4122
4137
  export type PostAgentsAgentIdSpeak_Body = {
4123
4138
  text: string;
4124
4139
  speakerId?: string | undefined;
4125
4140
  };
4141
+ /** @deprecated */
4126
4142
  export type PostAgentsAgentIdSpeak_Response = any;
4143
+ /** @deprecated */
4127
4144
  export type PostAgentsAgentIdSpeak_Request = Simplify<(PostAgentsAgentIdSpeak_PathParams extends never ? {} : {
4128
4145
  params: PostAgentsAgentIdSpeak_PathParams;
4129
4146
  }) & (never extends never ? {} : {} extends never ? {
@@ -4135,6 +4152,7 @@ export type PostAgentsAgentIdSpeak_Request = Simplify<(PostAgentsAgentIdSpeak_Pa
4135
4152
  } : {
4136
4153
  body: PostAgentsAgentIdSpeak_Body;
4137
4154
  })>;
4155
+ /** @deprecated */
4138
4156
  export interface PostAgentsAgentIdSpeak_RouteContract {
4139
4157
  pathParams: PostAgentsAgentIdSpeak_PathParams;
4140
4158
  queryParams: never;
@@ -4144,7 +4162,7 @@ export interface PostAgentsAgentIdSpeak_RouteContract {
4144
4162
  responseType: 'stream';
4145
4163
  }
4146
4164
  export type PostAgentsAgentIdVoiceListen_PathParams = {
4147
- /** Unique identifier for the agent */
4165
+ /** Agent ID */
4148
4166
  agentId: string;
4149
4167
  };
4150
4168
  export type PostAgentsAgentIdVoiceListen_Body = {
@@ -4175,19 +4193,23 @@ export interface PostAgentsAgentIdVoiceListen_RouteContract {
4175
4193
  response: PostAgentsAgentIdVoiceListen_Response;
4176
4194
  responseType: 'json';
4177
4195
  }
4196
+ /** @deprecated */
4178
4197
  export type PostAgentsAgentIdListen_PathParams = {
4179
- /** Unique identifier for the agent */
4198
+ /** Agent ID */
4180
4199
  agentId: string;
4181
4200
  };
4201
+ /** @deprecated */
4182
4202
  export type PostAgentsAgentIdListen_Body = {
4183
4203
  audio: any;
4184
4204
  options?: {
4185
4205
  [key: string]: any;
4186
4206
  } | undefined;
4187
4207
  };
4208
+ /** @deprecated */
4188
4209
  export type PostAgentsAgentIdListen_Response = {
4189
4210
  text: string;
4190
4211
  };
4212
+ /** @deprecated */
4191
4213
  export type PostAgentsAgentIdListen_Request = Simplify<(PostAgentsAgentIdListen_PathParams extends never ? {} : {
4192
4214
  params: PostAgentsAgentIdListen_PathParams;
4193
4215
  }) & (never extends never ? {} : {} extends never ? {
@@ -4199,6 +4221,7 @@ export type PostAgentsAgentIdListen_Request = Simplify<(PostAgentsAgentIdListen_
4199
4221
  } : {
4200
4222
  body: PostAgentsAgentIdListen_Body;
4201
4223
  })>;
4224
+ /** @deprecated */
4202
4225
  export interface PostAgentsAgentIdListen_RouteContract {
4203
4226
  pathParams: PostAgentsAgentIdListen_PathParams;
4204
4227
  queryParams: never;
@@ -4208,7 +4231,7 @@ export interface PostAgentsAgentIdListen_RouteContract {
4208
4231
  responseType: 'json';
4209
4232
  }
4210
4233
  export type GetAgentsAgentIdVoiceListener_PathParams = {
4211
- /** Unique identifier for the agent */
4234
+ /** Agent ID */
4212
4235
  agentId: string;
4213
4236
  };
4214
4237
  export type GetAgentsAgentIdVoiceListener_Response = any;
@@ -4266,6 +4289,7 @@ export type PostAgentsAgentIdStreamVNext_Body = {
4266
4289
  status: 'draft' | 'published';
4267
4290
  };
4268
4291
  } | undefined;
4292
+ defaultStatus?: ('draft' | 'published') | undefined;
4269
4293
  } | undefined;
4270
4294
  maxSteps?: number | undefined;
4271
4295
  stopWhen?: any | undefined;
@@ -4387,6 +4411,7 @@ export type PostAgentsAgentIdStreamVnextUi_Body = {
4387
4411
  status: 'draft' | 'published';
4388
4412
  };
4389
4413
  } | undefined;
4414
+ defaultStatus?: ('draft' | 'published') | undefined;
4390
4415
  } | undefined;
4391
4416
  maxSteps?: number | undefined;
4392
4417
  stopWhen?: any | undefined;
@@ -4508,6 +4533,7 @@ export type PostAgentsAgentIdStreamUi_Body = {
4508
4533
  status: 'draft' | 'published';
4509
4534
  };
4510
4535
  } | undefined;
4536
+ defaultStatus?: ('draft' | 'published') | undefined;
4511
4537
  } | undefined;
4512
4538
  maxSteps?: number | undefined;
4513
4539
  stopWhen?: any | undefined;
@@ -12455,6 +12481,7 @@ export type PostAgentsAgentIdGenerateLegacy_Body = {
12455
12481
  status: 'draft' | 'published';
12456
12482
  };
12457
12483
  } | undefined;
12484
+ defaultStatus?: ('draft' | 'published') | undefined;
12458
12485
  } | undefined;
12459
12486
  maxSteps?: number | undefined;
12460
12487
  stopWhen?: any | undefined;
@@ -12574,6 +12601,7 @@ export type PostAgentsAgentIdStreamLegacy_Body = {
12574
12601
  status: 'draft' | 'published';
12575
12602
  };
12576
12603
  } | undefined;
12604
+ defaultStatus?: ('draft' | 'published') | undefined;
12577
12605
  } | undefined;
12578
12606
  maxSteps?: number | undefined;
12579
12607
  stopWhen?: any | undefined;
@@ -41550,6 +41578,7 @@ export type PostDatasetsDatasetIdExperiments_Body = {
41550
41578
  status: 'draft' | 'published';
41551
41579
  };
41552
41580
  } | undefined;
41581
+ defaultStatus?: ('draft' | 'published') | undefined;
41553
41582
  } | undefined;
41554
41583
  };
41555
41584
  export type PostDatasetsDatasetIdExperiments_Response = {