@mastra/client-js 1.29.0-alpha.8 → 1.29.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
CHANGED
|
@@ -1,5 +1,136 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.29.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **Added** heartbeats: schedule an agent to run on a recurring cron, either inside an existing conversation thread or on its own. ([#18184](https://github.com/mastra-ai/mastra/pull/18184))
|
|
8
|
+
|
|
9
|
+
A heartbeat fires a prompt to an agent on a schedule. When it has a thread, the run is delivered into that thread as a normal agent signal, so anything watching the thread sees it like any other message; without a thread, the agent just runs in isolation. Each heartbeat has its own id and an optional `name`, so one agent or thread can have several heartbeats with different schedules and prompts. The id is generated for you, or you can pass your own `id` to `create` for a stable handle (it's normalized to `hb_<slug>`). Heartbeats are persisted, so they keep firing across process restarts with no extra setup.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const hb = await mastra.heartbeats.create({
|
|
13
|
+
agentId: 'chef',
|
|
14
|
+
name: 'morning-checkin',
|
|
15
|
+
threadId,
|
|
16
|
+
resourceId,
|
|
17
|
+
cron: '*/5 * * * *',
|
|
18
|
+
prompt: 'Check in on the user',
|
|
19
|
+
ifActive: { behavior: 'discard' }, // skip if the user is mid-conversation
|
|
20
|
+
ifIdle: { behavior: 'wake' }, // wake the agent if the thread is idle
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Threadless: run the agent on a cron with no conversation.
|
|
24
|
+
await mastra.heartbeats.create({
|
|
25
|
+
agentId: 'chef',
|
|
26
|
+
cron: '0 * * * *',
|
|
27
|
+
prompt: 'Run the hourly summary',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await mastra.heartbeats.list({ agentId: 'chef' });
|
|
31
|
+
await mastra.heartbeats.get(hb.id);
|
|
32
|
+
await mastra.heartbeats.update(hb.id, { prompt: 'check in gently' });
|
|
33
|
+
await mastra.heartbeats.pause(hb.id);
|
|
34
|
+
await mastra.heartbeats.resume(hb.id);
|
|
35
|
+
await mastra.heartbeats.run(hb.id); // fire once now
|
|
36
|
+
await mastra.heartbeats.delete(hb.id);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The same CRUD is available over HTTP through `@mastra/server` (under `/api/heartbeats`) and as top-level methods on the `@mastra/client-js` client (`client.createHeartbeat`, `client.getHeartbeat`, `client.listHeartbeats`, etc.).
|
|
40
|
+
|
|
41
|
+
**Lifecycle hooks**
|
|
42
|
+
|
|
43
|
+
React to heartbeat runs via `heartbeat` on the `Mastra` constructor. It's a single hook bundle that runs for every agent's heartbeats; each hook receives the firing `agentId` so you can branch on it. `prepare` resolves fire-time parameters (for example, creating a fresh thread per fire), and `onFinish` / `onError` / `onAbort` mirror `agent.stream`.
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
new Mastra({
|
|
47
|
+
// ...
|
|
48
|
+
heartbeat: {
|
|
49
|
+
// Return overrides, `null` to skip this fire, or `undefined` to use defaults.
|
|
50
|
+
prepare: async ({ agentId, heartbeat }) => {
|
|
51
|
+
if (agentId === 'chef' && heartbeat.name === 'daily-digest') {
|
|
52
|
+
return { threadId: await createDailyThread(), resourceId: 'slack:U095PUH0FKL' };
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
onFinish: ({ agentId, outcome, result, heartbeat }) => {
|
|
56
|
+
metrics.record({ agentId, heartbeat: heartbeat.name, outcome });
|
|
57
|
+
},
|
|
58
|
+
onError: ({ agentId, error, phase, heartbeat }) => {
|
|
59
|
+
alerts.send(`heartbeat ${agentId}/${heartbeat.name} failed in ${phase}: ${error.message}`);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Signal shaping**
|
|
66
|
+
|
|
67
|
+
A heartbeat fire surfaces to the agent as a signal. By default it uses the `notification` type and renders as `<heartbeat>…</heartbeat>`; override `signalType` and `tagName` to change either. `ifActive` and `ifIdle` mirror the `agent.sendSignal` options shape (`{ behavior, attributes }`, plus `streamOptions` on `ifIdle`) and stay JSON-serializable so they persist with the schedule. `ifIdle.streamOptions` currently accepts `requestContext`, which is rehydrated onto the woken run. Top-level `attributes` are rendered on the signal tag, and top-level `providerOptions` are merged into the signal payload on every fire.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
await mastra.heartbeats.create({
|
|
71
|
+
agentId: 'chef',
|
|
72
|
+
threadId,
|
|
73
|
+
resourceId,
|
|
74
|
+
cron: '*/5 * * * *',
|
|
75
|
+
prompt: 'Check in on the user',
|
|
76
|
+
tagName: 'check-in', // renders as <check-in>…</check-in>
|
|
77
|
+
attributes: { source: 'cron' },
|
|
78
|
+
providerOptions: { openai: { store: false } },
|
|
79
|
+
ifIdle: {
|
|
80
|
+
behavior: 'wake',
|
|
81
|
+
streamOptions: { requestContext: { locale: 'en-US' } },
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- Added storage-backed discovery of suspended agent runs, so human-in-the-loop approval UIs can recover a pending run after a page refresh or server restart. ([#17898](https://github.com/mastra-ai/mastra/pull/17898))
|
|
87
|
+
|
|
88
|
+
`agent.listSuspendedRuns()` lists runs waiting on a tool-call approval or on a tool that called `suspend()`. Unlike the in-memory `getActiveThreadRunId()`, it reads from storage, so it works after a restart and across multiple server instances:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
const { runs, total } = await agent.listSuspendedRuns({ threadId, resourceId });
|
|
92
|
+
if (runs[0]) {
|
|
93
|
+
// runs[0].toolCalls -> [{ toolCallId, toolName, args, requiresApproval }]
|
|
94
|
+
await agent.approveToolCall({ runId: runs[0].runId, toolCallId: runs[0].toolCalls[0].toolCallId });
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Supports `threadId`/`resourceId`/date filters and pagination, mirroring `listWorkflowRuns()`. The same surface is exposed over HTTP as `GET /agents/:agentId/suspended-runs` and on the client SDK as `agent.listSuspendedRuns()`; server-enforced request-context values take precedence over client query parameters, so clients cannot list runs outside their scope.
|
|
99
|
+
|
|
100
|
+
`sendToolApproval()` now falls back to this storage-backed discovery when no active run is found in memory for the thread, so approvals keep working after a restart. If several suspended runs match, it throws an error asking for a `toolCallId` to disambiguate.
|
|
101
|
+
|
|
102
|
+
**Why:** approval UIs previously had no public way to recover a suspended run after a refresh or restart, forcing apps to parse internal workflow snapshots.
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- Fix `listLogs` and `getLogForRun` dropping the `page` and `perPage` query parameters when they are `0`. Requesting the first page with `page: 0` (or `perPage: 0`) now sends those values instead of falling back to the server defaults. Closes #18631. ([#18632](https://github.com/mastra-ai/mastra/pull/18632))
|
|
107
|
+
|
|
108
|
+
- add Studio support for observational memory extractors ([#18655](https://github.com/mastra-ai/mastra/pull/18655))
|
|
109
|
+
|
|
110
|
+
Adds `bufferedObservationChunks` and extraction metadata to the buffer-status API and client types so extracted values flow through during live streaming. Renders observational memory indicators from a normalized cycle model that preserves extraction data across streaming, refetch, reload, activation, and failure transitions.
|
|
111
|
+
|
|
112
|
+
- Updated dependencies [[`b9a2961`](https://github.com/mastra-ai/mastra/commit/b9a2961c1be81e3639c0879e58588c26dd0ae866), [`b33c77d`](https://github.com/mastra-ai/mastra/commit/b33c77d5293f14a794f3ec38dc947a6676de2764), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`cdd5f93`](https://github.com/mastra-ai/mastra/commit/cdd5f939cefa67390629704dce92563ccbf492b2), [`1274eb3`](https://github.com/mastra-ai/mastra/commit/1274eb3a9508f579ceb3187fbce34408222d4b71), [`0ac14ce`](https://github.com/mastra-ai/mastra/commit/0ac14cea48e1b0a7857782153c78f7242fdf7e1a), [`9566d27`](https://github.com/mastra-ai/mastra/commit/9566d27ead3d95bdbe5a69e5a082a68222829cf2), [`8be63b0`](https://github.com/mastra-ai/mastra/commit/8be63b015fb8d72cea1220f05e7dc3bb997cc249), [`1009f77`](https://github.com/mastra-ai/mastra/commit/1009f772aa40016b49267c8566d0c29f6a16aa3c), [`1b8728a`](https://github.com/mastra-ai/mastra/commit/1b8728a57fd844205a452b0b4216d20ff60c784a), [`23c31de`](https://github.com/mastra-ai/mastra/commit/23c31de96ed8153402dcf092ac84b27a0c3638c1), [`0368766`](https://github.com/mastra-ai/mastra/commit/0368766744c7ea3df4d6059e2cc15f7bdf55f5a6), [`d0702ee`](https://github.com/mastra-ai/mastra/commit/d0702eedc1594cb2d0d83476440cfc2ec8820adb), [`9feeaa0`](https://github.com/mastra-ai/mastra/commit/9feeaa0f9a1af07039e5b4f22b932b0cb18617e8), [`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`345eecc`](https://github.com/mastra-ai/mastra/commit/345eecce6ba519b5d987f0e10b5de4c8e5734580), [`1917c53`](https://github.com/mastra-ai/mastra/commit/1917c53b19dac43926f29c496893b0686462dca4), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`705ba98`](https://github.com/mastra-ai/mastra/commit/705ba98726d388a596e896225f237907ca6807a9), [`95857bc`](https://github.com/mastra-ai/mastra/commit/95857bcd6669da7193f503e803f0d72a2bd66be6), [`e62c108`](https://github.com/mastra-ai/mastra/commit/e62c108409dfd6a6cac0a48ec39c5cc81d24fd52), [`2866f04`](https://github.com/mastra-ai/mastra/commit/2866f04953edb78c1637fa45cc53abe24122edcb), [`ee14cae`](https://github.com/mastra-ai/mastra/commit/ee14cae244805783bde518a6142de28b744b169c), [`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1), [`c2f0b7f`](https://github.com/mastra-ai/mastra/commit/c2f0b7f1370f4428d165f51f0d1d9a48331cc257), [`213feb8`](https://github.com/mastra-ai/mastra/commit/213feb87bfdd1d8ec00ea660e218f9bcfcb34e7b), [`58e287b`](https://github.com/mastra-ai/mastra/commit/58e287b1edaf978b13745a1795989cad3826e82b), [`e420b3c`](https://github.com/mastra-ai/mastra/commit/e420b3c3ffc98bbc5b791897ea390bb47af99696), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`bfbbb01`](https://github.com/mastra-ai/mastra/commit/bfbbb01bd845ba54cdc0c678c277d08a7cb847e4), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
|
|
113
|
+
- @mastra/core@1.48.0
|
|
114
|
+
- @mastra/schema-compat@1.3.2
|
|
115
|
+
|
|
116
|
+
## 1.29.0-alpha.10
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- add Studio support for observational memory extractors ([#18655](https://github.com/mastra-ai/mastra/pull/18655))
|
|
121
|
+
|
|
122
|
+
Adds `bufferedObservationChunks` and extraction metadata to the buffer-status API and client types so extracted values flow through during live streaming. Renders observational memory indicators from a normalized cycle model that preserves extraction data across streaming, refetch, reload, activation, and failure transitions.
|
|
123
|
+
|
|
124
|
+
- Updated dependencies [[`6f578ac`](https://github.com/mastra-ai/mastra/commit/6f578acba84930b406b2a0700b17cfdfaf5aae56), [`c01012f`](https://github.com/mastra-ai/mastra/commit/c01012f50368d29eb3fc3764df42d48291973d23), [`be875ed`](https://github.com/mastra-ai/mastra/commit/be875ed43f856742ce58529f531b5ea0ae6911f3), [`9eefdc0`](https://github.com/mastra-ai/mastra/commit/9eefdc0ac03f989718c6d835334940a977938895), [`7d112ca`](https://github.com/mastra-ai/mastra/commit/7d112ca17078479b2659b88ba1c85b936cfc111c)]:
|
|
125
|
+
- @mastra/core@1.48.0-alpha.10
|
|
126
|
+
|
|
127
|
+
## 1.29.0-alpha.9
|
|
128
|
+
|
|
129
|
+
### Patch Changes
|
|
130
|
+
|
|
131
|
+
- Updated dependencies [[`e84e791`](https://github.com/mastra-ai/mastra/commit/e84e79174031d7bc8793ca6c805eb38b06e7cfb1)]:
|
|
132
|
+
- @mastra/core@1.48.0-alpha.9
|
|
133
|
+
|
|
3
134
|
## 1.29.0-alpha.8
|
|
4
135
|
|
|
5
136
|
### 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.29.0
|
|
6
|
+
version: "1.29.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -7599,6 +7599,26 @@ export type GetMemoryObservationalMemory_Response = {
|
|
|
7599
7599
|
threadId: string | null;
|
|
7600
7600
|
activeObservations: string;
|
|
7601
7601
|
bufferedObservations?: string | undefined;
|
|
7602
|
+
bufferedObservationChunks?: {
|
|
7603
|
+
id?: string | undefined;
|
|
7604
|
+
cycleId: string;
|
|
7605
|
+
observations: string;
|
|
7606
|
+
tokenCount: number;
|
|
7607
|
+
messageIds?: string[] | undefined;
|
|
7608
|
+
messageTokens: number;
|
|
7609
|
+
lastObservedAt?: Date | undefined;
|
|
7610
|
+
createdAt?: Date | undefined;
|
|
7611
|
+
suggestedContinuation?: string | undefined;
|
|
7612
|
+
currentTask?: string | undefined;
|
|
7613
|
+
threadTitle?: string | undefined;
|
|
7614
|
+
extractedValues?: {
|
|
7615
|
+
[key: string]: unknown;
|
|
7616
|
+
} | undefined;
|
|
7617
|
+
extractionFailures?: {
|
|
7618
|
+
slug: string;
|
|
7619
|
+
error: string;
|
|
7620
|
+
}[] | undefined;
|
|
7621
|
+
}[] | undefined;
|
|
7602
7622
|
bufferedReflection?: string | undefined;
|
|
7603
7623
|
originType: 'initial' | 'observation' | 'reflection';
|
|
7604
7624
|
generationCount: number;
|
|
@@ -7624,6 +7644,26 @@ export type GetMemoryObservationalMemory_Response = {
|
|
|
7624
7644
|
threadId: string | null;
|
|
7625
7645
|
activeObservations: string;
|
|
7626
7646
|
bufferedObservations?: string | undefined;
|
|
7647
|
+
bufferedObservationChunks?: {
|
|
7648
|
+
id?: string | undefined;
|
|
7649
|
+
cycleId: string;
|
|
7650
|
+
observations: string;
|
|
7651
|
+
tokenCount: number;
|
|
7652
|
+
messageIds?: string[] | undefined;
|
|
7653
|
+
messageTokens: number;
|
|
7654
|
+
lastObservedAt?: Date | undefined;
|
|
7655
|
+
createdAt?: Date | undefined;
|
|
7656
|
+
suggestedContinuation?: string | undefined;
|
|
7657
|
+
currentTask?: string | undefined;
|
|
7658
|
+
threadTitle?: string | undefined;
|
|
7659
|
+
extractedValues?: {
|
|
7660
|
+
[key: string]: unknown;
|
|
7661
|
+
} | undefined;
|
|
7662
|
+
extractionFailures?: {
|
|
7663
|
+
slug: string;
|
|
7664
|
+
error: string;
|
|
7665
|
+
}[] | undefined;
|
|
7666
|
+
}[] | undefined;
|
|
7627
7667
|
bufferedReflection?: string | undefined;
|
|
7628
7668
|
originType: 'initial' | 'observation' | 'reflection';
|
|
7629
7669
|
generationCount: number;
|
|
@@ -7675,6 +7715,26 @@ export type PostMemoryObservationalMemoryBufferStatus_Response = {
|
|
|
7675
7715
|
threadId: string | null;
|
|
7676
7716
|
activeObservations: string;
|
|
7677
7717
|
bufferedObservations?: string | undefined;
|
|
7718
|
+
bufferedObservationChunks?: {
|
|
7719
|
+
id?: string | undefined;
|
|
7720
|
+
cycleId: string;
|
|
7721
|
+
observations: string;
|
|
7722
|
+
tokenCount: number;
|
|
7723
|
+
messageIds?: string[] | undefined;
|
|
7724
|
+
messageTokens: number;
|
|
7725
|
+
lastObservedAt?: Date | undefined;
|
|
7726
|
+
createdAt?: Date | undefined;
|
|
7727
|
+
suggestedContinuation?: string | undefined;
|
|
7728
|
+
currentTask?: string | undefined;
|
|
7729
|
+
threadTitle?: string | undefined;
|
|
7730
|
+
extractedValues?: {
|
|
7731
|
+
[key: string]: unknown;
|
|
7732
|
+
} | undefined;
|
|
7733
|
+
extractionFailures?: {
|
|
7734
|
+
slug: string;
|
|
7735
|
+
error: string;
|
|
7736
|
+
}[] | undefined;
|
|
7737
|
+
}[] | undefined;
|
|
7678
7738
|
bufferedReflection?: string | undefined;
|
|
7679
7739
|
originType: 'initial' | 'observation' | 'reflection';
|
|
7680
7740
|
generationCount: number;
|