@mastra/client-js 0.0.0-default-storage-virtual-file-20250410035748 → 0.0.0-experimental-agent-builder-20250815195917

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 (85) hide show
  1. package/.turbo/turbo-build.log +18 -0
  2. package/CHANGELOG.md +1598 -2
  3. package/LICENSE.md +15 -0
  4. package/README.md +2 -1
  5. package/dist/adapters/agui.d.ts +23 -0
  6. package/dist/adapters/agui.d.ts.map +1 -0
  7. package/dist/client.d.ts +270 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/example.d.ts +2 -0
  10. package/dist/example.d.ts.map +1 -0
  11. package/dist/index.cjs +1800 -78
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.ts +4 -587
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +1798 -80
  16. package/dist/index.js.map +1 -0
  17. package/dist/resources/a2a.d.ts +41 -0
  18. package/dist/resources/a2a.d.ts.map +1 -0
  19. package/dist/resources/agent.d.ts +123 -0
  20. package/dist/resources/agent.d.ts.map +1 -0
  21. package/dist/resources/base.d.ts +13 -0
  22. package/dist/resources/base.d.ts.map +1 -0
  23. package/dist/resources/index.d.ts +11 -0
  24. package/dist/resources/index.d.ts.map +1 -0
  25. package/dist/resources/legacy-workflow.d.ts +87 -0
  26. package/dist/resources/legacy-workflow.d.ts.map +1 -0
  27. package/dist/resources/mcp-tool.d.ts +27 -0
  28. package/dist/resources/mcp-tool.d.ts.map +1 -0
  29. package/dist/resources/memory-thread.d.ts +53 -0
  30. package/dist/resources/memory-thread.d.ts.map +1 -0
  31. package/dist/resources/network-memory-thread.d.ts +47 -0
  32. package/dist/resources/network-memory-thread.d.ts.map +1 -0
  33. package/dist/resources/network.d.ts +30 -0
  34. package/dist/resources/network.d.ts.map +1 -0
  35. package/dist/resources/tool.d.ts +23 -0
  36. package/dist/resources/tool.d.ts.map +1 -0
  37. package/dist/resources/vNextNetwork.d.ts +42 -0
  38. package/dist/resources/vNextNetwork.d.ts.map +1 -0
  39. package/dist/resources/vector.d.ts +48 -0
  40. package/dist/resources/vector.d.ts.map +1 -0
  41. package/dist/resources/workflow.d.ts +154 -0
  42. package/dist/resources/workflow.d.ts.map +1 -0
  43. package/dist/types.d.ts +422 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/utils/index.d.ts +3 -0
  46. package/dist/utils/index.d.ts.map +1 -0
  47. package/dist/utils/process-client-tools.d.ts +3 -0
  48. package/dist/utils/process-client-tools.d.ts.map +1 -0
  49. package/dist/utils/zod-to-json-schema.d.ts +105 -0
  50. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  51. package/integration-tests/agui-adapter.test.ts +122 -0
  52. package/integration-tests/package.json +18 -0
  53. package/integration-tests/src/mastra/index.ts +35 -0
  54. package/integration-tests/vitest.config.ts +9 -0
  55. package/package.json +34 -18
  56. package/src/adapters/agui.test.ts +322 -0
  57. package/src/adapters/agui.ts +257 -0
  58. package/src/client.ts +422 -14
  59. package/src/example.ts +59 -29
  60. package/src/index.test.ts +526 -10
  61. package/src/index.ts +1 -0
  62. package/src/resources/a2a.ts +98 -0
  63. package/src/resources/agent.ts +641 -49
  64. package/src/resources/base.ts +8 -2
  65. package/src/resources/index.ts +4 -1
  66. package/src/resources/legacy-workflow.ts +242 -0
  67. package/src/resources/mcp-tool.ts +48 -0
  68. package/src/resources/memory-thread.test.ts +285 -0
  69. package/src/resources/memory-thread.ts +44 -5
  70. package/src/resources/network-memory-thread.test.ts +269 -0
  71. package/src/resources/network-memory-thread.ts +81 -0
  72. package/src/resources/network.ts +11 -17
  73. package/src/resources/tool.ts +16 -3
  74. package/src/resources/vNextNetwork.ts +194 -0
  75. package/src/resources/workflow.ts +289 -94
  76. package/src/types.ts +301 -23
  77. package/src/utils/index.ts +11 -0
  78. package/src/utils/process-client-tools.ts +32 -0
  79. package/src/utils/zod-to-json-schema.ts +10 -0
  80. package/src/v2-messages.test.ts +180 -0
  81. package/tsconfig.build.json +9 -0
  82. package/tsconfig.json +1 -1
  83. package/tsup.config.ts +17 -0
  84. package/LICENSE +0 -44
  85. package/dist/index.d.cts +0 -587
@@ -0,0 +1,98 @@
1
+ import type {
2
+ AgentCard,
3
+ GetTaskResponse,
4
+ MessageSendParams,
5
+ SendMessageResponse,
6
+ SendStreamingMessageResponse,
7
+ Task,
8
+ TaskQueryParams,
9
+ } from '@mastra/core/a2a';
10
+ import type { ClientOptions } from '../types';
11
+ import { BaseResource } from './base';
12
+
13
+ /**
14
+ * Class for interacting with an agent via the A2A protocol
15
+ */
16
+ export class A2A extends BaseResource {
17
+ constructor(
18
+ options: ClientOptions,
19
+ private agentId: string,
20
+ ) {
21
+ super(options);
22
+ }
23
+
24
+ /**
25
+ * Get the agent card with metadata about the agent
26
+ * @returns Promise containing the agent card information
27
+ */
28
+ async getCard(): Promise<AgentCard> {
29
+ return this.request(`/.well-known/${this.agentId}/agent-card.json`);
30
+ }
31
+
32
+ /**
33
+ * Send a message to the agent and gets a message or task response
34
+ * @param params - Parameters for the task
35
+ * @returns Promise containing the response
36
+ */
37
+ async sendMessage(params: MessageSendParams): Promise<SendMessageResponse> {
38
+ const response = await this.request<SendMessageResponse>(`/a2a/${this.agentId}`, {
39
+ method: 'POST',
40
+ body: {
41
+ method: 'message/send',
42
+ params,
43
+ },
44
+ });
45
+
46
+ return response;
47
+ }
48
+
49
+ /**
50
+ * Sends a message to an agent to initiate/continue a task and subscribes
51
+ * the client to real-time updates for that task via Server-Sent Events (SSE).
52
+ * @param params - Parameters for the task
53
+ * @returns A stream of Server-Sent Events. Each SSE `data` field contains a `SendStreamingMessageResponse`
54
+ */
55
+ async sendStreamingMessage(params: MessageSendParams): Promise<AsyncIterable<SendStreamingMessageResponse>> {
56
+ const response = await this.request<AsyncIterable<SendStreamingMessageResponse>>(`/a2a/${this.agentId}`, {
57
+ method: 'POST',
58
+ body: {
59
+ method: 'message/stream',
60
+ params,
61
+ },
62
+ });
63
+
64
+ return response;
65
+ }
66
+
67
+ /**
68
+ * Get the status and result of a task
69
+ * @param params - Parameters for querying the task
70
+ * @returns Promise containing the task response
71
+ */
72
+ async getTask(params: TaskQueryParams): Promise<GetTaskResponse> {
73
+ const response = await this.request<GetTaskResponse>(`/a2a/${this.agentId}`, {
74
+ method: 'POST',
75
+ body: {
76
+ method: 'tasks/get',
77
+ params,
78
+ },
79
+ });
80
+
81
+ return response;
82
+ }
83
+
84
+ /**
85
+ * Cancel a running task
86
+ * @param params - Parameters identifying the task to cancel
87
+ * @returns Promise containing the task response
88
+ */
89
+ async cancelTask(params: TaskQueryParams): Promise<Task> {
90
+ return this.request(`/a2a/${this.agentId}`, {
91
+ method: 'POST',
92
+ body: {
93
+ method: 'tasks/cancel',
94
+ params,
95
+ },
96
+ });
97
+ }
98
+ }