@mastra/client-js 0.0.0-a2a-20250421213654

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/LICENSE.md ADDED
@@ -0,0 +1,46 @@
1
+ # Elastic License 2.0 (ELv2)
2
+
3
+ Copyright (c) 2025 Mastra AI, Inc.
4
+
5
+ **Acceptance**
6
+ By using the software, you agree to all of the terms and conditions below.
7
+
8
+ **Copyright License**
9
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
10
+
11
+ **Limitations**
12
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
13
+
14
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
15
+
16
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
17
+
18
+ **Patents**
19
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
20
+
21
+ **Notices**
22
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
23
+
24
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
25
+
26
+ **No Other Rights**
27
+ These terms do not imply any licenses other than those expressly granted in these terms.
28
+
29
+ **Termination**
30
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
31
+
32
+ **No Liability**
33
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
34
+
35
+ **Definitions**
36
+ The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
37
+
38
+ _you_ refers to the individual or entity agreeing to these terms.
39
+
40
+ _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
41
+
42
+ _your licenses_ are all the licenses granted to you for the software under these terms.
43
+
44
+ _use_ means anything you do with the software requiring one of your licenses.
45
+
46
+ _trademark_ means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # Mastra Client
2
+
3
+ JavaScript/TypeScript client library for the [Mastra AI](https://mastra.ai) framework. This client provides a simple interface to interact with Mastra AI's APIs for agents, vectors, memory, tools, and workflows.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/client-js
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { MastraClient } from '@mastra/client';
15
+
16
+ // Initialize the client
17
+ const client = new MastraClient({
18
+ baseUrl: 'http://localhost:4111', // Your Mastra API endpoint
19
+ });
20
+
21
+ // Example: Working with an Agent
22
+ async function main() {
23
+ // Get an agent instance
24
+ const agent = client.getAgent('your-agent-id');
25
+
26
+ // Generate a response
27
+ const response = await agent.generate({
28
+ messages: [{ role: 'user', content: "What's the weather like today?" }],
29
+ });
30
+
31
+ console.log(response);
32
+ }
33
+ ```
34
+
35
+ ## Client Configuration
36
+
37
+ The client can be configured with several options:
38
+
39
+ ```typescript
40
+ const client = new MastraClient({
41
+ baseUrl: string; // Base URL for the Mastra API
42
+ retries?: number; // Number of retry attempts (default: 3)
43
+ backoffMs?: number; // Initial backoff time in ms (default: 300)
44
+ maxBackoffMs?: number; // Maximum backoff time in ms (default: 5000)
45
+ headers?: Record<string, string>; // Custom headers
46
+ });
47
+ ```
48
+
49
+ ## Available Methods
50
+
51
+ ### Agents
52
+
53
+ - `getAgents()`: Get all available agents
54
+ - `getAgent(agentId)`: Get a specific agent instance
55
+ - `agent.details()`: Get agent details
56
+ - `agent.generate(params)`: Generate a response
57
+ - `agent.stream(params)`: Stream a response
58
+ - `agent.getTool(toolId)`: Get agent tool details
59
+ - `agent.evals()`: Get agent evaluations
60
+ - `agent.liveEvals()`: Get live evaluations
61
+
62
+ ### Memory
63
+
64
+ - `getMemoryThreads(params)`: Get memory threads
65
+ - `createMemoryThread(params)`: Create a new memory thread
66
+ - `getMemoryThread(threadId)`: Get a memory thread instance
67
+ - `saveMessageToMemory(params)`: Save messages to memory
68
+ - `getMemoryStatus()`: Get memory system status
69
+
70
+ ### Tools
71
+
72
+ - `getTools()`: Get all available tools
73
+ - `getTool(toolId)`: Get a tool instance
74
+ - `tool.details()`: Get tool details
75
+ - `tool.execute(params)`: Execute the tool
76
+
77
+ ### Workflows
78
+
79
+ - `getWorkflows()`: Get all workflows
80
+ - `getWorkflow(workflowId)`: Get a workflow instance
81
+ - `workflow.details()`: Get workflow details
82
+ - `workflow.createRun()`: Create workflow run
83
+ - `workflow.startAsync(params)`: Execute the workflow and wait for execution results
84
+ - `workflow.resumeAsync(parmas)`: Resume suspended workflow step async
85
+ - `workflow.watch({runId},(record)=>{})`: Watch the step transitions of the workflow run
86
+ - `workflow.start({runId, triggerData})`: Start a workflow run sync
87
+ - `workflow.resume(params)`: Resume the workflow run sync
88
+
89
+ ### Vectors
90
+
91
+ - `getVector(vectorName)`: Get a vector instance
92
+ - `vector.details(indexName)`: Get vector index details
93
+ - `vector.delete(indexName)`: Delete a vector index
94
+ - `vector.getIndexes()`: Get all indexes
95
+ - `vector.createIndex(params)`: Create a new index
96
+ - `vector.upsert(params)`: Upsert vectors
97
+ - `vector.query(params)`: Query vectors
98
+
99
+ ### Logs
100
+
101
+ - `getLogs(params)`: Get system logs
102
+ - `getLog(params)`: Get specific log entry
103
+ - `getLogTransports()`: Get configured Log transports
104
+
105
+ ### Telemetry
106
+
107
+ - `getTelemetry(params)`: Get telemetry data
108
+
109
+ ## Error Handling
110
+
111
+ The client includes built-in retry logic for failed requests:
112
+
113
+ - Automatically retries failed requests with exponential backoff
114
+ - Configurable retry count and backoff timing
115
+ - Throws error after max retries reached
116
+
117
+ ## Internal Implementation
118
+
119
+ The client uses the native `fetch` API internally for making HTTP requests. All requests are automatically handled with:
120
+
121
+ - JSON serialization/deserialization
122
+ - Retry logic with exponential backoff
123
+ - Custom header management
124
+ - Error handling
125
+
126
+ ## License
127
+
128
+ MIT