@mastra/client-js 1.47.0-alpha.1 → 1.47.0-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.
Files changed (50) hide show
  1. package/dist/_types/@ai-sdk_provider/package.json +1 -0
  2. package/dist/_types/@ai-sdk_provider-utils/dist/index.d.ts +1 -1
  3. package/dist/_types/@ai-sdk_provider-utils/package.json +1 -0
  4. package/dist/_types/@ai-sdk_ui-utils/dist/index.d.ts +3 -3
  5. package/dist/_types/@ai-sdk_ui-utils/package.json +1 -0
  6. package/dist/client.d.ts +45 -201
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/docs/SKILL.md +1 -1
  9. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  10. package/dist/docs/references/docs-connections-a2a.md +4 -3
  11. package/dist/docs/references/reference-client-js-mastra-client.md +1 -1
  12. package/dist/index.cjs +40 -28
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +40 -28
  17. package/dist/index.js.map +1 -1
  18. package/dist/resources/agent-builder.d.ts +25 -40
  19. package/dist/resources/agent-builder.d.ts.map +1 -1
  20. package/dist/resources/agent-controller.d.ts +5 -4
  21. package/dist/resources/agent-controller.d.ts.map +1 -1
  22. package/dist/resources/agent.d.ts +34 -72
  23. package/dist/resources/agent.d.ts.map +1 -1
  24. package/dist/resources/channels.d.ts +13 -31
  25. package/dist/resources/channels.d.ts.map +1 -1
  26. package/dist/resources/conversations.d.ts +6 -3
  27. package/dist/resources/conversations.d.ts.map +1 -1
  28. package/dist/resources/mcp-tool.d.ts +9 -6
  29. package/dist/resources/mcp-tool.d.ts.map +1 -1
  30. package/dist/resources/memory-thread.d.ts +6 -11
  31. package/dist/resources/memory-thread.d.ts.map +1 -1
  32. package/dist/resources/observability-route-types.d.ts +88 -0
  33. package/dist/resources/observability-route-types.d.ts.map +1 -0
  34. package/dist/resources/observability.d.ts +6 -9
  35. package/dist/resources/observability.d.ts.map +1 -1
  36. package/dist/resources/responses.d.ts +5 -2
  37. package/dist/resources/responses.d.ts.map +1 -1
  38. package/dist/resources/run.d.ts +21 -57
  39. package/dist/resources/run.d.ts.map +1 -1
  40. package/dist/resources/tool.d.ts +6 -4
  41. package/dist/resources/tool.d.ts.map +1 -1
  42. package/dist/resources/vector.d.ts +5 -10
  43. package/dist/resources/vector.d.ts.map +1 -1
  44. package/dist/resources/workflow.d.ts +8 -10
  45. package/dist/resources/workflow.d.ts.map +1 -1
  46. package/dist/route-types.generated.d.ts +3108 -2558
  47. package/dist/route-types.generated.d.ts.map +1 -1
  48. package/dist/types.d.ts +236 -1599
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +3 -3
@@ -67,7 +67,7 @@ Mastra supports A2A Protocol v0.3 and v1.0 on the same agent card and execution
67
67
  - `1.0`: Uses the v1.0 API.
68
68
  - Any other value: Returns a `VersionNotSupported` protocol error.
69
69
 
70
- Existing `A2AAgent` and `MastraClient.getA2A()` integrations continue to use v0.3. Use `MastraClient.getA2AV1()` for v1.0 requests. The v1 client sends `A2A-Version: 1.0` automatically and adds the `tasks/list` operation.
70
+ `A2AAgent` and `MastraClient.getA2A()` use v0.3 by default. Set `protocolVersion: '1.0'` on `A2AAgent` for v1.0 subagent delegation, or use `MastraClient.getA2AV1()` for direct v1.0 requests. Both v1.0 clients send `A2A-Version: 1.0` automatically. The direct v1.0 client also adds the `tasks/list` operation.
71
71
 
72
72
  Import v1.0 protocol types and codecs from `@mastra/core/a2a/v1`. The existing `@mastra/core/a2a/client` export remains on v0.3.
73
73
 
@@ -82,7 +82,7 @@ Use `A2AAgent` when another Mastra agent should delegate work to a remote agent.
82
82
 
83
83
  ## Consume A2A agents as subagents
84
84
 
85
- Use `A2AAgent` to wrap a remote A2A agent, then add it to a parent agent with the [supervisor agents](https://mastra.ai/docs/subagents) pattern. Pass an explicit agent card URL when the remote server hosts multiple agents or uses a custom well-known path.
85
+ Use `A2AAgent` to wrap a remote A2A agent, then add it to a parent agent with the [supervisor agents](https://mastra.ai/docs/subagents) pattern. Pass an explicit agent card URL when the remote server hosts multiple agents or uses a custom well-known path. Set `protocolVersion: '1.0'` when the remote agent requires A2A v1.0. Omit it to use v0.3.
86
86
 
87
87
  ```typescript
88
88
  import { Agent } from '@mastra/core/agent'
@@ -90,6 +90,7 @@ import { A2AAgent } from '@mastra/core/a2a'
90
90
 
91
91
  const remoteWeatherAgent = new A2AAgent({
92
92
  url: 'https://weather.example.com/api/.well-known/weather-agent/agent-card.json',
93
+ protocolVersion: '1.0',
93
94
  headers: {
94
95
  Authorization: `Bearer ${process.env.WEATHER_AGENT_TOKEN}`,
95
96
  },
@@ -112,7 +113,7 @@ During execution, `A2AAgent`:
112
113
 
113
114
  - Fetches and caches the remote agent card.
114
115
  - Reads the execution URL and capabilities from the card.
115
- - Calls `message/send` for non-streaming runs or `message/stream` when streaming is supported.
116
+ - Calls `message/send` or `message/stream` with v0.3, and `SendMessage` or `SendStreamingMessage` with v1.0.
116
117
  - Converts remote messages, tasks, artifacts, and status updates into Mastra subagent results.
117
118
  - Supports `resumeGenerate()` and `resumeStream()` when the remote task requires follow-up input or resubscription.
118
119
 
@@ -81,7 +81,7 @@ You can also pass `requestContext` as a `Record<string, any>`.
81
81
 
82
82
  **getWorkflow(workflowId)** (`Workflow`): Retrieves a specific workflow instance by ID.
83
83
 
84
- **getAgentBuilderActions()** (`Promise<Record<string, WorkflowInfo>>`): Returns all available Agent Builder actions. See Agent Builder API.
84
+ **getAgentBuilderActions()** (`Promise<GetAgentBuilderActionsResponse>`): Returns all available Agent Builder actions. See Agent Builder API.
85
85
 
86
86
  **getAgentBuilderAction(actionId)** (`AgentBuilder`): Retrieves an Agent Builder action by ID. See Agent Builder API.
87
87
 
package/dist/index.cjs CHANGED
@@ -919,6 +919,11 @@ var Agent = class extends BaseResource {
919
919
  * depending on the toolset's scope).
920
920
  *
921
921
  * @param threadId - Optional thread ID for thread-scoped browser sessions
922
+ *
923
+ * @remarks This is a browser-stream adapter compatibility endpoint, not a
924
+ * `SERVER_ROUTES` route. Its historical deployer implementation returns
925
+ * `{ success: true }`; no generated contract exists while the adapter owns it.
926
+ * The public `boolean` result remains broad for backwards compatibility.
922
927
  */
923
928
  closeBrowser(threadId) {
924
929
  return this.request(`/agents/${this.agentId}/browser/close`, {
@@ -3235,7 +3240,7 @@ var Run = class extends BaseResource {
3235
3240
  resourceId: params.resourceId,
3236
3241
  perStep: params.perStep
3237
3242
  }
3238
- }).then(deserializeWorkflowError);
3243
+ }).then((result) => deserializeWorkflowError(result));
3239
3244
  }
3240
3245
  /**
3241
3246
  * Starts a workflow run and returns a stream
@@ -3317,7 +3322,7 @@ var Run = class extends BaseResource {
3317
3322
  perStep: params.perStep,
3318
3323
  forEachIndex: params.forEachIndex
3319
3324
  }
3320
- }).then(deserializeWorkflowError);
3325
+ }).then((result) => deserializeWorkflowError(result));
3321
3326
  }
3322
3327
  /**
3323
3328
  * Resumes a suspended workflow step without waiting for the workflow to complete (fire-and-forget)
@@ -3401,7 +3406,7 @@ var Run = class extends BaseResource {
3401
3406
  requestContext,
3402
3407
  tracingOptions: params?.tracingOptions
3403
3408
  }
3404
- }).then(deserializeWorkflowError);
3409
+ }).then((result) => deserializeWorkflowError(result));
3405
3410
  }
3406
3411
  /**
3407
3412
  * Time travels a workflow run synchronously without waiting for the workflow to complete
@@ -3431,7 +3436,7 @@ var Run = class extends BaseResource {
3431
3436
  ...params,
3432
3437
  requestContext
3433
3438
  }
3434
- }).then(deserializeWorkflowError);
3439
+ }).then((result) => deserializeWorkflowError(result));
3435
3440
  }
3436
3441
  /**
3437
3442
  * Time travels a workflow run and returns a stream
@@ -4017,13 +4022,14 @@ var MCPTool = class extends BaseResource {
4017
4022
  /**
4018
4023
  * Executes this specific tool on the MCP server.
4019
4024
  * @param params - Parameters for tool execution, including data/args and optional requestContext.
4020
- * @returns Promise containing the result of the tool execution.
4025
+ * On a 2026-07-28 server a tool can answer `{ status: 'suspended', suspendPayload, resumeSchema }`;
4026
+ * call again with the same `data` plus `resumeData` (matching `resumeSchema`) and the echoed
4027
+ * `suspendPayload` to continue it.
4028
+ * @returns Promise containing `{ result }`, or the suspended shape described above.
4021
4029
  */
4022
4030
  execute(params) {
4023
- const body = {};
4024
- if (params.data !== void 0) body.data = params.data;
4025
- if (params.requestContext !== void 0) body.requestContext = params.requestContext;
4026
- return this.request(`/mcp/${encodeURIComponent(this.serverId)}/tools/${encodeURIComponent(this.toolId)}/execute`, {
4031
+ const { requestContext, ...body } = params;
4032
+ return this.request(`/mcp/${encodeURIComponent(this.serverId)}/tools/${encodeURIComponent(this.toolId)}/execute${requestContextQueryString(requestContext)}`, {
4027
4033
  method: "POST",
4028
4034
  body
4029
4035
  });
@@ -4041,23 +4047,29 @@ var AgentBuilder = class extends BaseResource {
4041
4047
  this.actionId = actionId;
4042
4048
  }
4043
4049
  transformWorkflowResult(result) {
4044
- if (result.status === "success") return {
4045
- success: result.result.success || false,
4046
- applied: result.result.applied || false,
4047
- branchName: result.result.branchName,
4048
- message: result.result.message || "Agent builder action completed",
4049
- validationResults: result.result.validationResults,
4050
- error: result.result.error,
4051
- errors: result.result.errors,
4052
- stepResults: result.result.stepResults
4053
- };
4054
- else if (result.status === "failed") return {
4055
- success: false,
4056
- applied: false,
4057
- message: `Agent builder action failed: ${result.error.message}`,
4058
- error: result.error.message
4059
- };
4060
- else return {
4050
+ if (result.status === "success") {
4051
+ const actionResult = result.result;
4052
+ return {
4053
+ success: actionResult?.success ?? false,
4054
+ applied: actionResult?.applied ?? false,
4055
+ branchName: actionResult?.branchName,
4056
+ message: actionResult?.message ?? "Agent builder action completed",
4057
+ validationResults: actionResult?.validationResults,
4058
+ error: actionResult?.error,
4059
+ errors: actionResult?.errors,
4060
+ stepResults: actionResult?.stepResults
4061
+ };
4062
+ }
4063
+ if (result.status === "failed") {
4064
+ const message = result.error?.message ?? "Agent builder action failed";
4065
+ return {
4066
+ success: false,
4067
+ applied: false,
4068
+ message: `Agent builder action failed: ${message}`,
4069
+ error: message
4070
+ };
4071
+ }
4072
+ return {
4061
4073
  success: false,
4062
4074
  applied: false,
4063
4075
  message: "Agent builder action was suspended",
@@ -4253,7 +4265,7 @@ var AgentBuilder = class extends BaseResource {
4253
4265
  * This calls `/agent-builder/:actionId`.
4254
4266
  */
4255
4267
  async details() {
4256
- return await this.request(`/agent-builder/${this.actionId}`);
4268
+ return this.request(`/agent-builder/${this.actionId}`);
4257
4269
  }
4258
4270
  /**
4259
4271
  * Gets all runs for this agent builder action.
@@ -4482,7 +4494,7 @@ var Observability = class extends BaseResource {
4482
4494
  deleteTraces(params) {
4483
4495
  return this.request(`/observability/traces/delete`, {
4484
4496
  method: "POST",
4485
- body: { traceIds: params.traceIds }
4497
+ body: params
4486
4498
  });
4487
4499
  }
4488
4500
  /**