@mastra/client-js 1.7.3 → 1.8.0-alpha.0
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 +41 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-server-auth-auth0.md +1 -1
- package/dist/docs/references/docs-server-auth-firebase.md +1 -1
- package/dist/docs/references/docs-server-mastra-client.md +1 -1
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-v4-messages.md +1 -1
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-v5-messages.md +1 -1
- package/dist/docs/references/reference-client-js-mastra-client.md +1 -1
- package/dist/index.cjs +21 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -16
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-builder.d.ts +7 -4
- package/dist/resources/agent-builder.d.ts.map +1 -1
- package/dist/resources/agent.d.ts +14 -8
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/run.d.ts +4 -4
- package/dist/resources/run.d.ts.map +1 -1
- package/dist/types.d.ts +19 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/process-mastra-stream.d.ts +2 -3
- package/dist/utils/process-mastra-stream.d.ts.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.8.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added `requestContext` field to dataset item API endpoints and `requestContextSchema` to dataset CRUD endpoints. Added `requestContext` option to the experiment trigger endpoint, which gets forwarded to agent execution during experiments. ([#13938](https://github.com/mastra-ai/mastra/pull/13938))
|
|
8
|
+
|
|
9
|
+
**Usage with `@mastra/client-js`:**
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// Create a dataset with a request context schema
|
|
13
|
+
await client.createDataset({
|
|
14
|
+
name: 'my-dataset',
|
|
15
|
+
requestContextSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: { region: { type: 'string' } },
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Add an item with request context
|
|
22
|
+
await client.addDatasetItem({
|
|
23
|
+
datasetId: 'my-dataset',
|
|
24
|
+
input: { prompt: 'Hello' },
|
|
25
|
+
requestContext: { region: 'us-east-1' },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Trigger an experiment with request context forwarded to agent
|
|
29
|
+
await client.triggerDatasetExperiment({
|
|
30
|
+
datasetId: 'my-dataset',
|
|
31
|
+
agentId: 'my-agent',
|
|
32
|
+
requestContext: { region: 'eu-west-1' },
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Fixed @mastra/client-js streaming APIs to expose standard Web Streams types in public declarations for browser consumers. ([#14079](https://github.com/mastra-ai/mastra/pull/14079))
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`4f71b43`](https://github.com/mastra-ai/mastra/commit/4f71b436a4a6b8839842d8da47b57b84509af56c), [`a070277`](https://github.com/mastra-ai/mastra/commit/a07027766ce195ba74d0783116d894cbab25d44c), [`b628b91`](https://github.com/mastra-ai/mastra/commit/b628b9128b372c0f54214d902b07279f03443900), [`332c014`](https://github.com/mastra-ai/mastra/commit/332c014e076b81edf7fe45b58205882726415e90), [`6b63153`](https://github.com/mastra-ai/mastra/commit/6b63153878ea841c0f4ce632ba66bb33e57e9c1b), [`4246e34`](https://github.com/mastra-ai/mastra/commit/4246e34cec9c26636d0965942268e6d07c346671), [`b8837ee`](https://github.com/mastra-ai/mastra/commit/b8837ee77e2e84197609762bfabd8b3da326d30c), [`fb58ce1`](https://github.com/mastra-ai/mastra/commit/fb58ce1de85d57f142005c4b3b7559f909167a3f), [`5d950f7`](https://github.com/mastra-ai/mastra/commit/5d950f7bf426a215a1808f0abef7de5c8336ba1c), [`28c85b1`](https://github.com/mastra-ai/mastra/commit/28c85b184fc32b40f7f160483c982da6d388ecbd), [`e9a08fb`](https://github.com/mastra-ai/mastra/commit/e9a08fbef1ada7e50e961e2f54f55e8c10b4a45c), [`631ffd8`](https://github.com/mastra-ai/mastra/commit/631ffd82fed108648b448b28e6a90e38c5f53bf5), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`aa61f29`](https://github.com/mastra-ai/mastra/commit/aa61f29ff8095ce46a4ae16e46c4d8c79b2b685b), [`7ff3714`](https://github.com/mastra-ai/mastra/commit/7ff37148515439bb3be009a60e02c3e363299760), [`41d79a1`](https://github.com/mastra-ai/mastra/commit/41d79a14bd8cb6de1e2565fd0a04786bae2f211b), [`e673376`](https://github.com/mastra-ai/mastra/commit/e6733763ad1321aa7e5ae15096b9c2104f93b1f3), [`b2204c9`](https://github.com/mastra-ai/mastra/commit/b2204c98a42848bbfb6f0440f005dc2b6354f1cd), [`a1bf1e3`](https://github.com/mastra-ai/mastra/commit/a1bf1e385ed4c0ef6f11b56c5887442970d127f2), [`b6f647a`](https://github.com/mastra-ai/mastra/commit/b6f647ae2388e091f366581595feb957e37d5b40), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`b081f27`](https://github.com/mastra-ai/mastra/commit/b081f272cf411716e1d6bd72ceac4bcee2657b19), [`0c09eac`](https://github.com/mastra-ai/mastra/commit/0c09eacb1926f64cfdc9ae5c6d63385cf8c9f72c), [`6b9b93d`](https://github.com/mastra-ai/mastra/commit/6b9b93d6f459d1ba6e36f163abf62a085ddb3d64), [`31b6067`](https://github.com/mastra-ai/mastra/commit/31b6067d0cc3ab10e1b29c36147f3b5266bc714a), [`797ac42`](https://github.com/mastra-ai/mastra/commit/797ac4276de231ad2d694d9aeca75980f6cd0419), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`0bc289e`](https://github.com/mastra-ai/mastra/commit/0bc289e2d476bf46c5b91c21969e8d0c6864691c), [`9b75a06`](https://github.com/mastra-ai/mastra/commit/9b75a06e53ebb0b950ba7c1e83a0142047185f46), [`4c3a1b1`](https://github.com/mastra-ai/mastra/commit/4c3a1b122ea083e003d71092f30f3b31680b01c0), [`85cc3b3`](https://github.com/mastra-ai/mastra/commit/85cc3b3b6f32ae4b083c26498f50d5b250ba944b), [`97ea28c`](https://github.com/mastra-ai/mastra/commit/97ea28c746e9e4147d56047bbb1c4a92417a3fec), [`d567299`](https://github.com/mastra-ai/mastra/commit/d567299cf81e02bd9d5221d4bc05967d6c224161), [`716ffe6`](https://github.com/mastra-ai/mastra/commit/716ffe68bed81f7c2690bc8581b9e140f7bf1c3d), [`8296332`](https://github.com/mastra-ai/mastra/commit/8296332de21c16e3dfc3d0b2d615720a6dc88f2f), [`4df2116`](https://github.com/mastra-ai/mastra/commit/4df211619dd922c047d396ca41cd7027c8c4c8e7), [`2219c1a`](https://github.com/mastra-ai/mastra/commit/2219c1acbd21da116da877f0036ffb985a9dd5a3), [`17c4145`](https://github.com/mastra-ai/mastra/commit/17c4145166099354545582335b5252bdfdfd908b)]:
|
|
41
|
+
- @mastra/core@1.11.0-alpha.0
|
|
42
|
+
- @mastra/schema-compat@1.2.0-alpha.0
|
|
43
|
+
|
|
3
44
|
## 1.7.3
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -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.
|
|
6
|
+
version: "1.8.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -66,7 +66,7 @@ export const mastra = new Mastra({
|
|
|
66
66
|
By default, `MastraAuthAuth0` allows all authenticated users who have valid Auth0 tokens for the specified audience. The token verification ensures that:
|
|
67
67
|
|
|
68
68
|
1. The token is properly signed by Auth0
|
|
69
|
-
2. The token
|
|
69
|
+
2. The token isn't expired
|
|
70
70
|
3. The token audience matches your configured audience
|
|
71
71
|
4. The token issuer matches your Auth0 domain
|
|
72
72
|
|
|
@@ -71,7 +71,7 @@ The `MastraAuthFirebase` class can be configured through constructor options or
|
|
|
71
71
|
- `FIREBASE_SERVICE_ACCOUNT`: Path to Firebase service account JSON file
|
|
72
72
|
- `FIRESTORE_DATABASE_ID` or `FIREBASE_DATABASE_ID`: Firestore database ID
|
|
73
73
|
|
|
74
|
-
> **Note:** When constructor options
|
|
74
|
+
> **Note:** When constructor options aren't provided, the class automatically reads these environment variables. This means you can call `new MastraAuthFirebase()` without any arguments if your environment variables are properly configured.
|
|
75
75
|
|
|
76
76
|
### User Authorization
|
|
77
77
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Mastra Client SDK
|
|
2
2
|
|
|
3
|
-
The Mastra Client SDK provides a
|
|
3
|
+
The Mastra Client SDK provides a concise and type-safe interface for interacting with your [Mastra Server](https://mastra.ai/docs/server/mastra-server) from your client environment.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Mastra Client SDK
|
|
2
2
|
|
|
3
|
-
The Mastra Client SDK provides a
|
|
3
|
+
The Mastra Client SDK provides a type-safe interface for interacting with your [Mastra Server](https://mastra.ai/docs/deployment/mastra-server) from your client environment.
|
|
4
4
|
|
|
5
5
|
## Usage example
|
|
6
6
|
|
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var uuid = require('@lukeed/uuid');
|
|
4
4
|
var error = require('@mastra/core/error');
|
|
5
|
+
var schema = require('@mastra/schema-compat/schema');
|
|
5
6
|
var requestContext = require('@mastra/core/request-context');
|
|
6
7
|
var isVercelTool = require('@mastra/core/tools/is-vercel-tool');
|
|
7
8
|
var zodToJson = require('@mastra/schema-compat/zod-to-json');
|
|
@@ -274,7 +275,7 @@ var customAlphabet = (alphabet, defaultSize = 21) => {
|
|
|
274
275
|
};
|
|
275
276
|
};
|
|
276
277
|
|
|
277
|
-
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@2.2.8_zod@3.
|
|
278
|
+
// ../../node_modules/.pnpm/@ai-sdk+provider-utils@2.2.8_zod@4.3.6/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
278
279
|
var import_secure_json_parse = __toESM(require_secure_json_parse());
|
|
279
280
|
var createIdGenerator = ({
|
|
280
281
|
prefix,
|
|
@@ -354,7 +355,7 @@ function safeParseJSON({
|
|
|
354
355
|
}
|
|
355
356
|
}
|
|
356
357
|
|
|
357
|
-
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@3.
|
|
358
|
+
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.3.6/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
358
359
|
new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
359
360
|
function fixJson(input) {
|
|
360
361
|
const stack = ["ROOT"];
|
|
@@ -1491,13 +1492,10 @@ var Agent = class extends BaseResource {
|
|
|
1491
1492
|
clientTools: processClientTools(params.clientTools)
|
|
1492
1493
|
};
|
|
1493
1494
|
const { resourceId, threadId, requestContext } = processedParams;
|
|
1494
|
-
const response = await this.request(
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
body: processedParams
|
|
1499
|
-
}
|
|
1500
|
-
);
|
|
1495
|
+
const response = await this.request(`/agents/${this.agentId}/generate-legacy`, {
|
|
1496
|
+
method: "POST",
|
|
1497
|
+
body: processedParams
|
|
1498
|
+
});
|
|
1501
1499
|
if (response.finishReason === "tool-calls") {
|
|
1502
1500
|
const toolCalls = response.toolCalls;
|
|
1503
1501
|
if (!toolCalls || !Array.isArray(toolCalls)) {
|
|
@@ -1532,7 +1530,7 @@ var Agent = class extends BaseResource {
|
|
|
1532
1530
|
]
|
|
1533
1531
|
}
|
|
1534
1532
|
];
|
|
1535
|
-
return this.
|
|
1533
|
+
return this.generateLegacy({
|
|
1536
1534
|
...params,
|
|
1537
1535
|
messages: updatedMessages
|
|
1538
1536
|
});
|
|
@@ -1552,7 +1550,7 @@ var Agent = class extends BaseResource {
|
|
|
1552
1550
|
clientTools: processClientTools(params.clientTools),
|
|
1553
1551
|
structuredOutput: params.structuredOutput ? {
|
|
1554
1552
|
...params.structuredOutput,
|
|
1555
|
-
schema:
|
|
1553
|
+
schema: schema.standardSchemaToJSONSchema(schema.toStandardSchema(params.structuredOutput.schema))
|
|
1556
1554
|
} : void 0
|
|
1557
1555
|
};
|
|
1558
1556
|
const { memory, requestContext } = processedParams;
|
|
@@ -2350,14 +2348,18 @@ var Agent = class extends BaseResource {
|
|
|
2350
2348
|
messages: messagesOrParams,
|
|
2351
2349
|
...options
|
|
2352
2350
|
};
|
|
2351
|
+
let structuredOutput = void 0;
|
|
2352
|
+
if (params.structuredOutput?.schema) {
|
|
2353
|
+
structuredOutput = {
|
|
2354
|
+
...params.structuredOutput,
|
|
2355
|
+
schema: schema.standardSchemaToJSONSchema(schema.toStandardSchema(params.structuredOutput.schema))
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2353
2358
|
const processedParams = {
|
|
2354
2359
|
...params,
|
|
2355
2360
|
requestContext: parseClientRequestContext(params.requestContext),
|
|
2356
2361
|
clientTools: processClientTools(params.clientTools),
|
|
2357
|
-
structuredOutput
|
|
2358
|
-
...params.structuredOutput,
|
|
2359
|
-
schema: zodToJsonSchema2(params.structuredOutput.schema)
|
|
2360
|
-
} : void 0
|
|
2362
|
+
structuredOutput
|
|
2361
2363
|
};
|
|
2362
2364
|
let readableController;
|
|
2363
2365
|
const readable = new ReadableStream({
|
|
@@ -3226,7 +3228,10 @@ var Run = class extends BaseResource {
|
|
|
3226
3228
|
* @param params - Object containing the step, inputData, resumeData, initialState, context, nestedStepsContext, requestContext and tracingOptions
|
|
3227
3229
|
* @returns Promise containing the workflow execution results
|
|
3228
3230
|
*/
|
|
3229
|
-
async timeTravelStream({
|
|
3231
|
+
async timeTravelStream({
|
|
3232
|
+
requestContext: paramsRequestContext,
|
|
3233
|
+
...params
|
|
3234
|
+
}) {
|
|
3230
3235
|
const requestContext = parseClientRequestContext(paramsRequestContext);
|
|
3231
3236
|
const response = await this.request(
|
|
3232
3237
|
`/workflows/${this.workflowId}/time-travel-stream?runId=${this.runId}`,
|