@mastra/client-js 1.18.0-alpha.12 → 1.18.0-alpha.14

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,64 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.18.0-alpha.14
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`f984b4d`](https://github.com/mastra-ai/mastra/commit/f984b4d6c60bf2ae2a9b156f0e8c35a66fe96c91), [`ce01024`](https://github.com/mastra-ai/mastra/commit/ce010242eee9bdfc09e4c26725b9d37998679a8d), [`f984b4d`](https://github.com/mastra-ai/mastra/commit/f984b4d6c60bf2ae2a9b156f0e8c35a66fe96c91), [`8373ff4`](https://github.com/mastra-ai/mastra/commit/8373ff46745d77af79f183c4470f80fa2727a6b2), [`11c1528`](https://github.com/mastra-ai/mastra/commit/11c152848c5d0ef227184853b5040f5b41ee7b1e)]:
8
+ - @mastra/core@1.33.0-alpha.13
9
+
10
+ ## 1.18.0-alpha.13
11
+
12
+ ### Minor Changes
13
+
14
+ - Added Agent signals for sending contextual messages into agent thread loops and subscribing to thread activity. ([#16229](https://github.com/mastra-ai/mastra/pull/16229))
15
+
16
+ Call `agent.sendSignal()` to inject context into a running agent loop. When the thread is idle, that same signal becomes the prompt that starts the next loop by default. Use `ifActive.behavior` and `ifIdle.behavior` to deliver, persist, discard, or wake from a signal.
17
+
18
+ Use `agent.subscribeToThread()` to follow the raw stream chunks for a memory thread, observe signal echoes with stable IDs, and abort the active stream for that thread.
19
+
20
+ ```ts
21
+ const subscription = await agent.subscribeToThread({ resourceId, threadId });
22
+
23
+ void (async () => {
24
+ for await (const part of subscription.stream) {
25
+ if (part.type === 'finish') {
26
+ subscription.unsubscribe();
27
+ }
28
+ }
29
+ })();
30
+
31
+ agent.sendSignal({ type: 'user-message', contents: 'Use the latest answer' }, { resourceId, threadId });
32
+ ```
33
+
34
+ - Fix client-js bugs surfaced by the SDK ↔ server contract audit. ([#16439](https://github.com/mastra-ai/mastra/pull/16439))
35
+ - `MastraClient.getAgentBuilderActions()` previously requested `/agent-builder/` (trailing slash) and 404'd. Now hits `/agent-builder`.
36
+ - `AgentBuilder.stream(params, runId)` now requires `runId`. The server route requires it; calls without it failed with a server-side validation error. The SDK now both types `runId` as required and guards at runtime.
37
+ - `MastraClient.createStoredSkill(...)` now requires `description` in its parameter type. The server schema has always required it; the SDK type used to mark it optional, so omitting it produced a runtime 400 instead of a compile error.
38
+
39
+ Migration:
40
+
41
+ ```ts
42
+ // Before
43
+ await agentBuilder.stream({ inputData });
44
+
45
+ // After
46
+ await agentBuilder.stream({ inputData }, runId);
47
+ ```
48
+
49
+ ```ts
50
+ // Before
51
+ await client.createStoredSkill({ name, instructions });
52
+
53
+ // After
54
+ await client.createStoredSkill({ name, description, instructions });
55
+ ```
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [[`b59316f`](https://github.com/mastra-ai/mastra/commit/b59316ffa0f7688165b0f9c81ccdf85da461e5b2), [`55f1e2d`](https://github.com/mastra-ai/mastra/commit/55f1e2d65425b95a49ae788053b266f256e38c96), [`d48a705`](https://github.com/mastra-ai/mastra/commit/d48a705ff3dfbdc7a996e07ecd8293b5effd9a2a)]:
60
+ - @mastra/core@1.33.0-alpha.12
61
+
3
62
  ## 1.18.0-alpha.12
4
63
 
5
64
  ### Patch Changes
@@ -1547,16 +1547,16 @@ declare interface EventSourceMessage {
1547
1547
  * implementation in that browsers will default this to `message`, whereas this parser will
1548
1548
  * leave this as `undefined` if not explicitly declared.
1549
1549
  */
1550
- event?: string | undefined;
1550
+ event?: string | undefined
1551
1551
  /**
1552
1552
  * ID of the message, if any was provided by the server. Can be used by clients to keep the
1553
1553
  * last received message ID in sync when reconnecting.
1554
1554
  */
1555
- id?: string | undefined;
1555
+ id?: string | undefined
1556
1556
  /**
1557
1557
  * The data received for this message
1558
1558
  */
1559
- data: string;
1559
+ data: string
1560
1560
  }
1561
1561
 
1562
1562
  /**
@@ -1580,11 +1580,8 @@ declare interface EventSourceMessage {
1580
1580
  *
1581
1581
  * @public
1582
1582
  */
1583
- declare class EventSourceParserStream extends TransformStream<
1584
- string,
1585
- EventSourceMessage
1586
- > {
1587
- constructor({ onError, onRetry, onComment }?: StreamOptions);
1583
+ declare class EventSourceParserStream extends TransformStream<string, EventSourceMessage> {
1584
+ constructor({onError, onRetry, onComment}?: StreamOptions)
1588
1585
  }
1589
1586
 
1590
1587
  /**
@@ -6988,19 +6985,19 @@ declare interface StreamOptions {
6988
6985
  *
6989
6986
  * @defaultValue `undefined`
6990
6987
  */
6991
- onError?: ("terminate" | ((error: Error) => void)) | undefined;
6988
+ onError?: ('terminate' | ((error: Error) => void)) | undefined
6992
6989
  /**
6993
6990
  * Callback for when a reconnection interval is sent from the server.
6994
6991
  *
6995
6992
  * @param retry - The number of milliseconds to wait before reconnecting.
6996
6993
  */
6997
- onRetry?: ((retry: number) => void) | undefined;
6994
+ onRetry?: ((retry: number) => void) | undefined
6998
6995
  /**
6999
6996
  * Callback for when a comment is encountered in the stream.
7000
6997
  *
7001
6998
  * @param comment - The comment encountered in the stream.
7002
6999
  */
7003
- onComment?: ((comment: string) => void) | undefined;
7000
+ onComment?: ((comment: string) => void) | undefined
7004
7001
  }
7005
7002
 
7006
7003
  /**
@@ -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.18.0-alpha.12"
6
+ version: "1.18.0-alpha.14"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -16,6 +16,7 @@ Read the individual reference documents for detailed explanations and code examp
16
16
 
17
17
  ### Docs
18
18
 
19
+ - [Signals](references/docs-agents-signals.md) - Learn how to send real-time context into a Mastra agent thread.
19
20
  - [Editor overview](references/docs-editor-overview.md) - Let non-technical team members iterate on agents, version every change, and run experiments without redeploying.
20
21
  - [Auth0](references/docs-server-auth-auth0.md) - Documentation for the @mastra/auth-auth0 package, which authenticates Mastra applications using Auth0 authentication.
21
22
  - [Clerk](references/docs-server-auth-clerk.md) - Documentation for the `@mastra/auth-clerk` package, which authenticates Mastra applications using Clerk authentication.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.18.0-alpha.12",
2
+ "version": "1.18.0-alpha.14",
3
3
  "package": "@mastra/client-js",
4
4
  "exports": {
5
5
  "RequestContext": {
@@ -0,0 +1,151 @@
1
+ # Signals
2
+
3
+ > **Experimental:** Agent signals are experimental. The API may change in a future release.
4
+
5
+ Signals are a way to interact with an agent through a thread. Instead of starting every interaction with `agent.stream()`, subscribe to a thread and send signals. Mastra either wakes the agent when the thread is idle or drops the signal into the running agent loop.
6
+
7
+ Signals are a context engineering tool for guiding the agent in real time as the agent loop progresses. Use them to add system-generated content from external event sources, such as incoming email notifications, GitHub pull request comments, background task notifications, and similar events.
8
+
9
+ ## Quickstart
10
+
11
+ Subscribe to the thread before sending signals. The subscription receives the active stream when the signal wakes the agent or enters a running loop.
12
+
13
+ ```typescript
14
+ const subscription = await agent.subscribeToThread({
15
+ resourceId: 'user_123',
16
+ threadId: 'thread_456',
17
+ })
18
+
19
+ agent.sendSignal(
20
+ {
21
+ type: 'user-message',
22
+ contents: 'Compare that with the previous option.',
23
+ },
24
+ {
25
+ resourceId: 'user_123',
26
+ threadId: 'thread_456',
27
+ },
28
+ )
29
+
30
+ for await (const chunk of subscription.stream) {
31
+ console.log(chunk)
32
+ }
33
+ ```
34
+
35
+ When the thread has a running agent stream, the signal becomes new input inside that agent loop. When the thread is idle, Mastra starts a stream with the signal as the first input.
36
+
37
+ ## Control signal behavior
38
+
39
+ By default, Mastra delivers signals to active runs and wakes idle threads. Use `ifActive.behavior` and `ifIdle.behavior` to change that behavior.
40
+
41
+ ```typescript
42
+ const result = agent.sendSignal(
43
+ {
44
+ type: 'user-message',
45
+ contents: 'Store this for later, but do not wake the agent.',
46
+ },
47
+ {
48
+ resourceId: 'user_123',
49
+ threadId: 'thread_456',
50
+ ifIdle: {
51
+ behavior: 'persist',
52
+ },
53
+ },
54
+ )
55
+
56
+ await result.persisted
57
+ ```
58
+
59
+ The behavior options are:
60
+
61
+ - `ifActive.behavior: 'deliver'`: Add the signal to the running agent loop. This is the default.
62
+ - `ifActive.behavior: 'persist'`: Save the signal to memory without adding it to the running loop.
63
+ - `ifActive.behavior: 'discard'`: Ignore the signal while the thread is active.
64
+ - `ifIdle.behavior: 'wake'`: Start a stream with the signal as the first input. This is the default.
65
+ - `ifIdle.behavior: 'persist'`: Save the signal to memory without starting a stream.
66
+ - `ifIdle.behavior: 'discard'`: Ignore the signal while the thread is idle.
67
+
68
+ Pass `ifIdle.streamOptions` when the idle wake-up stream needs options such as model settings, tools, or runtime context. You do not need to repeat `memory.resource` or `memory.thread`; Mastra uses the top-level `resourceId` and `threadId` for the thread.
69
+
70
+ ```typescript
71
+ agent.sendSignal(
72
+ {
73
+ type: 'user-message',
74
+ contents: 'Continue with the next step.',
75
+ },
76
+ {
77
+ resourceId: 'user_123',
78
+ threadId: 'thread_456',
79
+ ifIdle: {
80
+ behavior: 'wake',
81
+ streamOptions: {
82
+ maxSteps: 3,
83
+ },
84
+ },
85
+ },
86
+ )
87
+ ```
88
+
89
+ ## Send external event context
90
+
91
+ Use custom signal types for system-generated context. Non-user signal types are rendered as XML-style user-role context so they can appear inside conversation history without looking like assistant output.
92
+
93
+ ```typescript
94
+ agent.sendSignal(
95
+ {
96
+ type: 'system-reminder',
97
+ contents: 'User X has left a new PR comment asking for a smaller API surface.',
98
+ attributes: {
99
+ type: 'github',
100
+ pr: '123',
101
+ },
102
+ },
103
+ {
104
+ resourceId: 'user_123',
105
+ threadId: 'thread_456',
106
+ },
107
+ )
108
+ ```
109
+
110
+ The model receives the custom signal as context like this:
111
+
112
+ ```xml
113
+ <system-reminder type="github" pr="123">User X has left a new PR comment asking for a smaller API surface.</system-reminder>
114
+ ```
115
+
116
+ Use XML-safe signal type names and attribute names. Signal type names and attribute names can contain letters, numbers, underscores, periods, and hyphens. They must start with a letter or underscore.
117
+
118
+ ## Use the client SDK
119
+
120
+ The JavaScript client exposes the same thread signal APIs. Use `subscribeToThread()` before `sendSignal()` so the client can render the stream that wakes from, or receives, the signal.
121
+
122
+ ```typescript
123
+ const agent = client.getAgent('supportAgent')
124
+
125
+ const subscription = await agent.subscribeToThread({
126
+ resourceId: 'user_123',
127
+ threadId: 'thread_456',
128
+ })
129
+
130
+ await agent.sendSignal({
131
+ signal: {
132
+ type: 'user-message',
133
+ contents: 'Show the shorter version.',
134
+ },
135
+ resourceId: 'user_123',
136
+ threadId: 'thread_456',
137
+ })
138
+
139
+ await subscription.processDataStream({
140
+ onChunk: chunk => {
141
+ console.log(chunk)
142
+ },
143
+ })
144
+ ```
145
+
146
+ ## Related
147
+
148
+ - [`Agent.sendSignal()`](https://mastra.ai/reference/agents/agent)
149
+ - [`Agent.subscribeToThread()`](https://mastra.ai/reference/agents/agent)
150
+ - [`client.getAgent().sendSignal()`](https://mastra.ai/reference/client-js/agents)
151
+ - [`client.getAgent().subscribeToThread()`](https://mastra.ai/reference/client-js/agents)
@@ -151,6 +151,95 @@ for await (const part of uiMessageStream) {
151
151
  }
152
152
  ```
153
153
 
154
+ ### `sendSignal()`
155
+
156
+ Send a signal to an active agent run or memory thread. Use this with `subscribeToThread()` so the client can render the stream that wakes from, or receives, the signal.
157
+
158
+ ```typescript
159
+ const agent = mastraClient.getAgent('support-agent')
160
+
161
+ const result = await agent.sendSignal({
162
+ signal: {
163
+ type: 'user-message',
164
+ contents: 'Also consider the customer note I just added.',
165
+ },
166
+ resourceId: 'user-123',
167
+ threadId: 'thread-abc',
168
+ })
169
+
170
+ console.log(result.runId)
171
+ ```
172
+
173
+ Use `ifActive.behavior` and `ifIdle.behavior` to control whether Mastra delivers, persists, discards, or wakes from a signal:
174
+
175
+ ```typescript
176
+ await agent.sendSignal({
177
+ signal: { type: 'user-message', contents: 'Store this for later.' },
178
+ resourceId: 'user-123',
179
+ threadId: 'thread-abc',
180
+ ifIdle: {
181
+ behavior: 'persist',
182
+ },
183
+ })
184
+ ```
185
+
186
+ Pass `ifIdle.streamOptions` when the idle wake-up stream needs options such as model settings, tools, or runtime context:
187
+
188
+ ```typescript
189
+ await agent.sendSignal({
190
+ signal: { type: 'user-message', contents: 'Start from this signal.' },
191
+ resourceId: 'user-123',
192
+ threadId: 'thread-abc',
193
+ ifIdle: {
194
+ behavior: 'wake',
195
+ streamOptions: {
196
+ maxSteps: 3,
197
+ },
198
+ },
199
+ })
200
+ ```
201
+
202
+ Returns `{ accepted: true, runId: string }`.
203
+
204
+ **signal** (`{ type: 'user-message'; contents: MessageListInput } | { type: string; contents: string }`): \`user-message\` signals are treated as user input. Other signal types are converted to contextual XML before the next model call.
205
+
206
+ **runId** (`string`): Run ID to target directly.
207
+
208
+ **resourceId** (`string`): Resource ID for the memory thread. Use with \`threadId\` for thread-targeted signals.
209
+
210
+ **threadId** (`string`): Thread ID to target. Use with \`resourceId\` for thread-targeted signals.
211
+
212
+ **ifActive.behavior** (`'deliver' | 'persist' | 'discard'`): Controls what happens when the target thread is active. Defaults to \`deliver\`.
213
+
214
+ **ifIdle.behavior** (`'wake' | 'persist' | 'discard'`): Controls what happens when the target thread is idle. Defaults to \`wake\`.
215
+
216
+ **ifIdle.streamOptions** (`Omit<AgentExecutionOptions, 'messages'>`): Options for the stream that starts when \`ifIdle.behavior\` is \`wake\`.
217
+
218
+ ### `subscribeToThread()`
219
+
220
+ Subscribe to raw stream chunks for a memory thread. Use this to render output from a thread that may be started or continued by `sendSignal()`.
221
+
222
+ ```typescript
223
+ const agent = mastraClient.getAgent('support-agent')
224
+
225
+ const subscription = await agent.subscribeToThread({
226
+ resourceId: 'user-123',
227
+ threadId: 'thread-abc',
228
+ })
229
+
230
+ await subscription.processDataStream({
231
+ onChunk: async chunk => {
232
+ console.log(chunk)
233
+ },
234
+ })
235
+ ```
236
+
237
+ `subscribeToThread()` returns the underlying `Response` plus a `processDataStream()` helper. The helper reads the subscription stream until the connection closes or the request is aborted.
238
+
239
+ **resourceId** (`string`): Resource ID for the memory thread.
240
+
241
+ **threadId** (`string`): Thread ID to subscribe to.
242
+
154
243
  ### `streamUntilIdle()`
155
244
 
156
245
  Stream a response and keep the stream open until every [background task](https://mastra.ai/docs/agents/background-tasks) dispatched during the run completes. The server re-enters the agentic loop on each task completion so the LLM can react to results in the same call. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call falls through to a plain `stream()`.
package/dist/index.cjs CHANGED
@@ -135,11 +135,15 @@ function processClientTools(clientTools) {
135
135
  // src/utils/process-mastra-stream.ts
136
136
  async function sharedProcessMastraStream({
137
137
  stream,
138
- onChunk
138
+ onChunk,
139
+ signal
139
140
  }) {
140
141
  const reader = stream.getReader();
141
142
  const decoder = new TextDecoder();
142
143
  let buffer = "";
144
+ const abort = () => void reader.cancel();
145
+ if (signal?.aborted) abort();
146
+ else signal?.addEventListener("abort", abort, { once: true });
143
147
  try {
144
148
  while (true) {
145
149
  const { done, value } = await reader.read();
@@ -167,25 +171,30 @@ async function sharedProcessMastraStream({
167
171
  }
168
172
  }
169
173
  } finally {
174
+ signal?.removeEventListener("abort", abort);
170
175
  reader.releaseLock();
171
176
  }
172
177
  }
173
178
  async function processMastraNetworkStream({
174
179
  stream,
175
- onChunk
180
+ onChunk,
181
+ signal
176
182
  }) {
177
183
  return sharedProcessMastraStream({
178
184
  stream,
179
- onChunk
185
+ onChunk,
186
+ signal
180
187
  });
181
188
  }
182
189
  async function processMastraStream({
183
190
  stream,
184
- onChunk
191
+ onChunk,
192
+ signal
185
193
  }) {
186
194
  return sharedProcessMastraStream({
187
195
  stream,
188
- onChunk
196
+ onChunk,
197
+ signal
189
198
  });
190
199
  }
191
200
 
@@ -348,8 +357,6 @@ var AgentVoice = class extends BaseResource {
348
357
  this.version = version;
349
358
  this.agentId = agentId;
350
359
  }
351
- agentId;
352
- version;
353
360
  getQueryString(requestContext, delimiter = "?") {
354
361
  const searchParams = new URLSearchParams(requestContextQueryString(requestContext).slice(1));
355
362
  if (this.version) {
@@ -419,8 +426,6 @@ var Agent = class extends BaseResource {
419
426
  this.version = version;
420
427
  this.voice = new AgentVoice(options, this.agentId, this.version);
421
428
  }
422
- agentId;
423
- version;
424
429
  voice;
425
430
  getQueryString(requestContext, delimiter = "?") {
426
431
  const searchParams = new URLSearchParams(requestContextQueryString(requestContext).slice(1));
@@ -446,6 +451,38 @@ var Agent = class extends BaseResource {
446
451
  body: { instructions, comment }
447
452
  });
448
453
  }
454
+ /**
455
+ * @experimental Agent signals are experimental and may change in a future release.
456
+ */
457
+ sendSignal(params) {
458
+ return this.request(`/agents/${this.agentId}/signals`, {
459
+ method: "POST",
460
+ body: params
461
+ });
462
+ }
463
+ /**
464
+ * @experimental Agent signals are experimental and may change in a future release.
465
+ */
466
+ async subscribeToThread(params) {
467
+ const streamResponse = await this.request(`/agents/${this.agentId}/threads/subscribe`, {
468
+ method: "POST",
469
+ body: params,
470
+ stream: true
471
+ });
472
+ if (!streamResponse.body) {
473
+ throw new Error("No response body");
474
+ }
475
+ streamResponse.processDataStream = async ({
476
+ onChunk
477
+ }) => {
478
+ await processMastraStream({
479
+ stream: streamResponse.body,
480
+ onChunk,
481
+ signal: this.options.abortSignal
482
+ });
483
+ };
484
+ return streamResponse;
485
+ }
449
486
  /**
450
487
  * Clones this agent to a new stored agent in the database
451
488
  * @param params - Clone parameters including optional newId, newName, metadata, authorId, and requestContext
@@ -1905,8 +1942,6 @@ var MemoryThread = class extends BaseResource {
1905
1942
  this.threadId = threadId;
1906
1943
  this.agentId = agentId;
1907
1944
  }
1908
- threadId;
1909
- agentId;
1910
1945
  /**
1911
1946
  * Builds the query string for agentId (if provided)
1912
1947
  */
@@ -2039,7 +2074,6 @@ var Vector = class extends BaseResource {
2039
2074
  super(options);
2040
2075
  this.vectorName = vectorName;
2041
2076
  }
2042
- vectorName;
2043
2077
  /**
2044
2078
  * Retrieves details about a specific vector index
2045
2079
  * @param indexName - Name of the index to get details for
@@ -2112,7 +2146,6 @@ var Tool = class extends BaseResource {
2112
2146
  super(options);
2113
2147
  this.toolId = toolId;
2114
2148
  }
2115
- toolId;
2116
2149
  /**
2117
2150
  * Retrieves details about the tool
2118
2151
  * @param requestContext - Optional request context to pass as query parameter
@@ -2148,7 +2181,6 @@ var Processor = class extends BaseResource {
2148
2181
  super(options);
2149
2182
  this.processorId = processorId;
2150
2183
  }
2151
- processorId;
2152
2184
  /**
2153
2185
  * Retrieves details about the processor
2154
2186
  * @param requestContext - Optional request context to pass as query parameter
@@ -2230,8 +2262,6 @@ var Run = class extends BaseResource {
2230
2262
  this.workflowId = workflowId;
2231
2263
  this.runId = runId;
2232
2264
  }
2233
- workflowId;
2234
- runId;
2235
2265
  /**
2236
2266
  * Creates a transform stream that parses RECORD_SEPARATOR-delimited JSON chunks
2237
2267
  */
@@ -2624,7 +2654,6 @@ var Workflow = class extends BaseResource {
2624
2654
  super(options);
2625
2655
  this.workflowId = workflowId;
2626
2656
  }
2627
- workflowId;
2628
2657
  /**
2629
2658
  * Retrieves details about the workflow
2630
2659
  * @param requestContext - Optional request context to pass as query parameter
@@ -2987,7 +3016,6 @@ var A2A = class extends BaseResource {
2987
3016
  super(options);
2988
3017
  this.agentId = agentId;
2989
3018
  }
2990
- agentId;
2991
3019
  /**
2992
3020
  * Get the agent card with metadata about the agent.
2993
3021
  * @param options - Optional Agent Card verification settings
@@ -3236,7 +3264,6 @@ var AgentBuilder = class extends BaseResource {
3236
3264
  super(options);
3237
3265
  this.actionId = actionId;
3238
3266
  }
3239
- actionId;
3240
3267
  // Helper function to transform workflow result to action result
3241
3268
  transformWorkflowResult(result) {
3242
3269
  if (result.status === "success") {
@@ -3423,13 +3450,14 @@ var AgentBuilder = class extends BaseResource {
3423
3450
  * This calls `/agent-builder/:actionId/stream`.
3424
3451
  */
3425
3452
  async stream(params, runId) {
3426
- const searchParams = new URLSearchParams();
3427
- if (runId) {
3428
- searchParams.set("runId", runId);
3453
+ if (!runId) {
3454
+ throw new Error("runId is required to stream an agent builder action");
3429
3455
  }
3456
+ const searchParams = new URLSearchParams();
3457
+ searchParams.set("runId", runId);
3430
3458
  const requestContext = parseClientRequestContext(params.requestContext);
3431
3459
  const { requestContext: _, ...actionParams } = params;
3432
- const url = `/agent-builder/${this.actionId}/stream${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
3460
+ const url = `/agent-builder/${this.actionId}/stream?${searchParams.toString()}`;
3433
3461
  const response = await this.request(url, {
3434
3462
  method: "POST",
3435
3463
  body: { ...actionParams, requestContext },
@@ -3963,7 +3991,6 @@ var StoredAgent = class extends BaseResource {
3963
3991
  super(options);
3964
3992
  this.storedAgentId = storedAgentId;
3965
3993
  }
3966
- storedAgentId;
3967
3994
  /**
3968
3995
  * Retrieves details about the stored agent
3969
3996
  * @param requestContext - Optional request context to pass as query parameter
@@ -4123,7 +4150,6 @@ var StoredPromptBlock = class extends BaseResource {
4123
4150
  super(options);
4124
4151
  this.storedPromptBlockId = storedPromptBlockId;
4125
4152
  }
4126
- storedPromptBlockId;
4127
4153
  /**
4128
4154
  * Retrieves details about the stored prompt block
4129
4155
  * @param requestContext - Optional request context to pass as query parameter
@@ -4283,7 +4309,6 @@ var StoredMCPClient = class extends BaseResource {
4283
4309
  super(options);
4284
4310
  this.storedMCPClientId = storedMCPClientId;
4285
4311
  }
4286
- storedMCPClientId;
4287
4312
  /**
4288
4313
  * Retrieves details about the stored MCP client
4289
4314
  * @param requestContext - Optional request context to pass as query parameter
@@ -4330,7 +4355,6 @@ var StoredScorer = class extends BaseResource {
4330
4355
  super(options);
4331
4356
  this.storedScorerId = storedScorerId;
4332
4357
  }
4333
- storedScorerId;
4334
4358
  /**
4335
4359
  * Retrieves details about the stored scorer definition
4336
4360
  * @param requestContext - Optional request context to pass as query parameter
@@ -4491,7 +4515,6 @@ var ToolProvider = class extends BaseResource {
4491
4515
  super(options);
4492
4516
  this.providerId = providerId;
4493
4517
  }
4494
- providerId;
4495
4518
  /**
4496
4519
  * Lists available toolkits from this provider
4497
4520
  * @returns Promise containing list of toolkits
@@ -4541,7 +4564,6 @@ var ProcessorProvider = class extends BaseResource {
4541
4564
  super(options);
4542
4565
  this.providerId = providerId;
4543
4566
  }
4544
- providerId;
4545
4567
  /**
4546
4568
  * Gets details about this processor provider and its available processors
4547
4569
  * @returns Promise containing provider info and processor list
@@ -4561,9 +4583,6 @@ var WorkspaceSkillResource = class extends BaseResource {
4561
4583
  this.basePath = `/workspaces/${encodeURIComponent(this.workspaceId)}/skills/${encodeURIComponent(this.skillName)}`;
4562
4584
  this.pathQuery = this.skillPath ? `?path=${encodeURIComponent(this.skillPath)}` : "";
4563
4585
  }
4564
- workspaceId;
4565
- skillName;
4566
- skillPath;
4567
4586
  basePath;
4568
4587
  pathQuery;
4569
4588
  /**
@@ -4783,7 +4802,6 @@ var StoredSkill = class extends BaseResource {
4783
4802
  super(options);
4784
4803
  this.storedSkillId = storedSkillId;
4785
4804
  }
4786
- storedSkillId;
4787
4805
  /**
4788
4806
  * Retrieves details about the stored skill
4789
4807
  * @param requestContext - Optional request context to pass as query parameter
@@ -4880,7 +4898,6 @@ var ResponsesStream = class {
4880
4898
  constructor(response) {
4881
4899
  this.response = response;
4882
4900
  }
4883
- response;
4884
4901
  asResponse() {
4885
4902
  return this.response;
4886
4903
  }
@@ -5290,7 +5307,7 @@ var MastraClient = class extends BaseResource {
5290
5307
  * @returns Promise containing map of action IDs to action details
5291
5308
  */
5292
5309
  getAgentBuilderActions() {
5293
- return this.request("/agent-builder/");
5310
+ return this.request("/agent-builder");
5294
5311
  }
5295
5312
  /**
5296
5313
  * Gets an agent builder instance for executing agent-builder workflows