@mastra/client-js 1.22.0-alpha.9 → 1.23.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 +202 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agents-signals.md +229 -9
- package/dist/docs/references/docs-editor-overview.md +11 -10
- package/dist/docs/references/reference-client-js-agents.md +41 -7
- package/dist/index.cjs +81 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +81 -50
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +21 -1
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/stored-agent.d.ts +8 -1
- package/dist/resources/stored-agent.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +36 -0
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,207 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.23.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added `GET /stored/agents/:storedAgentId/dependents` endpoint that lists agents ([#17183](https://github.com/mastra-ai/mastra/pull/17183))
|
|
8
|
+
referencing a stored agent as a sub-agent.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
const { dependents, hiddenCount } = await client.getStoredAgent(id).dependents();
|
|
12
|
+
// { dependents: [{ id: 'parent-1', name: 'Triager' }], hiddenCount: 2 }
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- `dependents` — caller-readable agents (public agents and the caller's own private
|
|
16
|
+
agents) with `id` + `name`.
|
|
17
|
+
- `hiddenCount` — cross-workspace dependents the caller cannot read, only surfaced
|
|
18
|
+
when the target agent is public.
|
|
19
|
+
|
|
20
|
+
Access mirrors `GET /stored/agents/:storedAgentId` — 404 when the caller cannot
|
|
21
|
+
read the target.
|
|
22
|
+
|
|
23
|
+
- Add experimental `agent.sendMessage()` and `agent.queueMessage()` helpers for the new message-first server routes. ([#17238](https://github.com/mastra-ai/mastra/pull/17238))
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Improved agent message, stream, and observational-memory type handling across the client SDKs and playground UI. ([#17208](https://github.com/mastra-ai/mastra/pull/17208))
|
|
28
|
+
|
|
29
|
+
- Fixed subscribed client tools so browser-executed tool results continue through the existing thread subscription instead of opening and canceling a second stream. This prevents closed-stream errors in apps like Agent Builder when multiple client tools run during one response. ([#17532](https://github.com/mastra-ai/mastra/pull/17532))
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [[`c973db4`](https://github.com/mastra-ai/mastra/commit/c973db428df1b564ff0c35d4b2a90e8f4f1e13fd), [`552285e`](https://github.com/mastra-ai/mastra/commit/552285e5af43cfc680a0972032cab8de8776c6a0), [`77e686c`](https://github.com/mastra-ai/mastra/commit/77e686c264e493e99ae5024e4dfe3ea5d5a09718), [`ece8dba`](https://github.com/mastra-ai/mastra/commit/ece8dba7ec1a5089eee8c33167cd762bfa91e509), [`e751af2`](https://github.com/mastra-ai/mastra/commit/e751af219433fbf4c7035b2d771b4c9ec8813b05), [`e2a8380`](https://github.com/mastra-ai/mastra/commit/e2a838017a7657850404c1e94c70d79ffdc6f14a), [`be3f1cd`](https://github.com/mastra-ai/mastra/commit/be3f1cd81f0e2a649e8eac15a024d542d814aef8), [`a34d9db`](https://github.com/mastra-ai/mastra/commit/a34d9dbc39fedb722f271318e9355ecee70489ab)]:
|
|
32
|
+
- @mastra/core@1.39.0-alpha.0
|
|
33
|
+
|
|
34
|
+
## 1.22.0
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- Added an agent override export API and server-side ownership enforcement. ([#17228](https://github.com/mastra-ai/mastra/pull/17228))
|
|
39
|
+
|
|
40
|
+
The server and client now expose an agent override export endpoint so Studio can download an agent's overrides as JSON for review or commit workflows. Saves are enforced server-side against each agent's `editor` config, so only owned fields (instructions, tools, or tool descriptions) are persisted and fields locked by the `editor` config are stripped.
|
|
41
|
+
|
|
42
|
+
The system packages response also reports the active editor `source` so clients can render the correct editing experience.
|
|
43
|
+
|
|
44
|
+
- Add fire-and-forget workflow resume that returns immediately with `{ runId }` without awaiting the run output. ([#17230](https://github.com/mastra-ai/mastra/pull/17230))
|
|
45
|
+
|
|
46
|
+
For `@mastra/inngest`, this skips the `getRunOutput()` polling that previously raced a realtime subscription against the Inngest runs API and could surface spurious 404s even though the durable workflow was running fine.
|
|
47
|
+
- `Run.resumeAsync()` added to core: dispatches the resume in the background and returns `{ runId }` immediately. Engines that poll for results (Inngest) override it to skip polling entirely.
|
|
48
|
+
- `InngestRun.resumeAsync()` sends the resume event and returns `{ runId }`, skipping polling. Send-time failures (bad payload, event send failure) still reject synchronously and roll back the snapshot.
|
|
49
|
+
- New `POST /workflows/:workflowId/resume-no-wait` and `POST /agent-builder/:actionId/resume-no-wait` routes return `{ runId }` immediately.
|
|
50
|
+
- New client SDK `run.resumeNoWait()` resolves with `{ runId }`.
|
|
51
|
+
|
|
52
|
+
The existing `resumeAsync()` client/server surface is unchanged and still resolves with the full workflow result, so there is no breaking change.
|
|
53
|
+
|
|
54
|
+
`resumeNoWait` is intentionally additive in v1. In Mastra v2 the fire-and-forget behavior is planned to become the default behavior of `resumeAsync()` (mirroring `start`/`resume` semantics), at which point `resumeNoWait` and the `resume-no-wait` routes will be removed. The code paths carry `TODO(v2)` comments documenting this consolidation.
|
|
55
|
+
|
|
56
|
+
- Added a `PATCH /tool-providers/:providerId/connections/:connectionId` endpoint and matching client SDK method so authors can rename a connection's display label after creation. ([#17249](https://github.com/mastra-ai/mastra/pull/17249))
|
|
57
|
+
|
|
58
|
+
**Rename a connection from the client SDK**
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { MastraClient } from '@mastra/client-js';
|
|
62
|
+
|
|
63
|
+
const client = new MastraClient({ baseUrl: '…' });
|
|
64
|
+
|
|
65
|
+
await client.getToolProvider('composio').updateConnection('auth_abc', {
|
|
66
|
+
label: 'Work inbox',
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Pass `label: null` (or an empty string) to clear the existing label. Labels are 1–32 characters and accept letters, digits, spaces, underscores, and hyphens (`[A-Za-z0-9 _-]+`).
|
|
71
|
+
|
|
72
|
+
**Ownership enforced server-side**
|
|
73
|
+
|
|
74
|
+
Non-owners get a 403 unless they hold `tool-providers:admin`. Shared connections are reachable by every author. The label is stored on the connection row itself, so the rename flows to every agent that pins the connection — no per-agent edit needed.
|
|
75
|
+
|
|
76
|
+
- Added the v1 ToolProvider runtime, server routes, client SDK methods, and editor wiring that power OAuth-backed integrations on stored agents. ([#17248](https://github.com/mastra-ai/mastra/pull/17248))
|
|
77
|
+
|
|
78
|
+
**Stored agents can now pin OAuth connections per toolkit**
|
|
79
|
+
|
|
80
|
+
A stored agent's config accepts a new `toolProviders` shape that tells the runtime which connection to bind for each toolkit at execution time. Connections can be scoped per-author, shared across an org, or supplied by the caller.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
{
|
|
84
|
+
toolProviders: {
|
|
85
|
+
composio: {
|
|
86
|
+
connections: {
|
|
87
|
+
gmail: [{ kind: 'author', toolkit: 'gmail', connectionId: 'auth_abc', scope: 'per-author' }],
|
|
88
|
+
},
|
|
89
|
+
tools: {
|
|
90
|
+
GMAIL_FETCH_EMAILS: { toolkit: 'gmail' },
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**New client SDK surface for managing connections**
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import { MastraClient } from '@mastra/client-js';
|
|
101
|
+
|
|
102
|
+
const client = new MastraClient({ baseUrl: '…' });
|
|
103
|
+
const composio = client.toolProvider('composio');
|
|
104
|
+
|
|
105
|
+
const { items } = await composio.listConnections({ toolkit: 'gmail' });
|
|
106
|
+
await composio.disconnectConnection('auth_abc');
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**New `ToolProvider` interface for custom providers**
|
|
110
|
+
|
|
111
|
+
Providers implement a VNext surface (`listToolkitsVNext`, `listToolsVNext`, `resolveToolsVNext`) plus the auth round-trip (`authorize`, `getAuthStatus`, `listConnections`, `disconnectConnection`, `listConnectionFields`, `health`). The Composio provider has been rewritten on this surface; the older catalog methods remain as `@deprecated` shims for back-compat.
|
|
112
|
+
|
|
113
|
+
Connections list responses use `page`/`perPage` pagination, matching the rest of the server surface.
|
|
114
|
+
|
|
115
|
+
Both stored agents (`editor.agent.getById(...)`) and code-defined agents with stored overrides (`editor.agent.applyStoredOverrides(...)`) resolve `toolProviders` at request time, merging provider-resolved tools alongside code/registry/MCP/integration tools.
|
|
116
|
+
|
|
117
|
+
Stored agents that don't set `toolProviders` continue to work unchanged. The Studio/Builder UI ships separately.
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- Separated thread subscription cleanup from active-run aborts so closing or switching a listener only unsubscribes that listener, while explicit cancel still aborts the active run. ([#17310](https://github.com/mastra-ai/mastra/pull/17310))
|
|
122
|
+
|
|
123
|
+
- Added subscription-native tool approval APIs so approving or declining a tool call resumes through the active thread subscription instead of requiring a separate continuation stream. New messages are queued while a tool approval is waiting, preventing overlapping runs from duplicating approval requests. ([#17311](https://github.com/mastra-ai/mastra/pull/17311))
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
await agent.sendToolApproval({
|
|
127
|
+
resourceId: 'user-123',
|
|
128
|
+
threadId: 'thread-123',
|
|
129
|
+
toolCallId: 'tool-call-123',
|
|
130
|
+
approved: true,
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- Fixed sub-agent version resolution in supervisor mode. Sub-agents now inherit the parent's draft/published version semantics — when chatting in the editor (draft mode), sub-agents resolve to their latest draft version; in the main agent chat (published mode), sub-agents resolve to their published version. Previously, sub-agents without explicit per-agent version overrides always fell back to the code-defined default, ignoring the parent's version context. ([#17165](https://github.com/mastra-ai/mastra/pull/17165))
|
|
135
|
+
|
|
136
|
+
- Hardened v1 ToolProvider connection routes and SDK forwarding. ([#17248](https://github.com/mastra-ai/mastra/pull/17248))
|
|
137
|
+
|
|
138
|
+
**Fail closed on unknown `connectionId`**
|
|
139
|
+
|
|
140
|
+
`DELETE /tool-providers/:providerId/connections/:connectionId` and
|
|
141
|
+
`GET …/usage` now return `403` when storage is configured but no persisted
|
|
142
|
+
row matches the supplied `connectionId` and the caller isn't an admin.
|
|
143
|
+
Previously these routes fell through to the caller's own `authorId`, which
|
|
144
|
+
let non-admin callers probe (and trigger provider-side `revokeConnection`
|
|
145
|
+
for) IDs that didn't belong to them.
|
|
146
|
+
|
|
147
|
+
**Aligned authorize label validation with stored label rules**
|
|
148
|
+
|
|
149
|
+
`POST /tool-providers/:providerId/authorize` now enforces the same label
|
|
150
|
+
rules the stored `toolProviders` config uses (`min(1)`, `max(32)`,
|
|
151
|
+
`/^[A-Za-z0-9 _-]+$/`). Labels that pass `authorize` are now guaranteed to
|
|
152
|
+
pass downstream stored-agent validation.
|
|
153
|
+
|
|
154
|
+
**SDK forwards `toolkit` on connection-scoped operations**
|
|
155
|
+
|
|
156
|
+
`@mastra/client-js`:
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
await client.toolProviders.get('composio').disconnectConnection('ca_xxx', {
|
|
160
|
+
toolkit: 'gmail',
|
|
161
|
+
force: true,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const usage = await client.toolProviders.get('composio').getConnectionUsage('ca_xxx', { toolkit: 'gmail' });
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
`disconnectConnection` now forwards `params.toolkit` (previously dropped)
|
|
168
|
+
and `getConnectionUsage` accepts an optional `{ toolkit }` parameter so
|
|
169
|
+
toolkit-scoped connection lookups disambiguate correctly server-side.
|
|
170
|
+
|
|
171
|
+
- Improved observability and error isolation in the v1 ToolProvider runtime. ([#17248](https://github.com/mastra-ai/mastra/pull/17248))
|
|
172
|
+
|
|
173
|
+
**Better visibility into connection-scope misconfiguration**
|
|
174
|
+
|
|
175
|
+
When an agent runs with a stored ToolProvider connection whose scope cannot be resolved from the request context, the runtime now logs a one-shot warning and falls back to a shared bucket instead of silently routing every caller to the same OAuth account. Multi-tenant deployments get a clear signal when their identity wiring isn't reaching the runtime.
|
|
176
|
+
|
|
177
|
+
**One bad toolkit no longer disables sibling providers**
|
|
178
|
+
|
|
179
|
+
If a provider returns more connections for a toolkit than its declared capabilities allow, the runtime now logs and skips that toolkit instead of throwing. Other providers and other toolkits on the same agent continue to resolve normally.
|
|
180
|
+
|
|
181
|
+
- Workflows now support an optional `metadata` field for attaching custom key-value data such as `displayName`, `author`, or `category`. Metadata is preserved through serialization and returned in workflow info API responses. ([#17355](https://github.com/mastra-ai/mastra/pull/17355))
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// Define a workflow with metadata
|
|
185
|
+
const myWorkflow = createWorkflow({
|
|
186
|
+
id: 'data-processing',
|
|
187
|
+
metadata: {
|
|
188
|
+
displayName: 'Data Processing Pipeline',
|
|
189
|
+
|
|
190
|
+
category: 'ETL',
|
|
191
|
+
},
|
|
192
|
+
inputSchema: z.object({ ... }),
|
|
193
|
+
outputSchema: z.object({ ... }),
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Retrieve workflow info with metadata via the Mastra Server API
|
|
197
|
+
const workflowInfo = await mastraClient.getWorkflow('data-processing');
|
|
198
|
+
console.log(workflowInfo.metadata?.displayName); // "Data Processing Pipeline"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- Updated dependencies [[`00eca42`](https://github.com/mastra-ai/mastra/commit/00eca4252393aa114dc8c9a5e1da68df91fa06cf), [`fa63872`](https://github.com/mastra-ai/mastra/commit/fa6387280954e6b667bec5714b55ba082bc627ff), [`d779de3`](https://github.com/mastra-ai/mastra/commit/d779de3cd9d2e7ed8110547190e2f15e786a0e41), [`1750c97`](https://github.com/mastra-ai/mastra/commit/1750c975d6179fbf6db2813b15229d4f8f23fc55), [`9283971`](https://github.com/mastra-ai/mastra/commit/928397157009b4aef4d5fdf3a0a273cb371beb55), [`f07b646`](https://github.com/mastra-ai/mastra/commit/f07b64604ab7d25391179790b7fd4823df9e2dff), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`40f9297`](https://github.com/mastra-ai/mastra/commit/40f9297003b921c62373d3e8d3a4bda76c9f6de3), [`19a8658`](https://github.com/mastra-ai/mastra/commit/19a86589c788ef48bb6c1b0612cc82a201857379), [`850af77`](https://github.com/mastra-ai/mastra/commit/850af7779cb87c350804488734544a5b1843de25), [`0f0d1ba`](https://github.com/mastra-ai/mastra/commit/0f0d1ba67bfcb2204e571401662f1eceefc03357), [`a18775a`](https://github.com/mastra-ai/mastra/commit/a18775a693172546ee2378d39b67d4e32895b251), [`1baf2d1`](https://github.com/mastra-ai/mastra/commit/1baf2d152c6881338ff8f114633d5316fe13dd15), [`8c31bcd`](https://github.com/mastra-ai/mastra/commit/8c31bcdb00e597880d5939b1b7d7566fbe5dacae), [`0e32507`](https://github.com/mastra-ai/mastra/commit/0e32507962cdfa5569b7bda5bc6fb3dd34e40b03), [`95b14cd`](https://github.com/mastra-ai/mastra/commit/95b14cdd820e86d97ac05fe568424c513a252e31), [`07c3de7`](https://github.com/mastra-ai/mastra/commit/07c3de7f7bc418beccaea3b5e6b7f7cdda79d492), [`0bf2d93`](https://github.com/mastra-ai/mastra/commit/0bf2d932d20e2936f2d9abb8c0a86e24fbc97ec6), [`7b0d34c`](https://github.com/mastra-ai/mastra/commit/7b0d34cfe4a2fce22ac86ae17404685ff67a2ddb), [`a659a77`](https://github.com/mastra-ai/mastra/commit/a659a779bdebe3a52a518c56d2260592d0240fe0), [`aa36be2`](https://github.com/mastra-ai/mastra/commit/aa36be23aa513b7dc53cb8ca16b7fab8f20e43ad), [`3332be9`](https://github.com/mastra-ai/mastra/commit/3332be9701ecd77aba840959d9a1d1ce7aef02d3), [`212c635`](https://github.com/mastra-ai/mastra/commit/212c635203e61d036ab41db8ff86c3893dc795b3), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`9aa5a73`](https://github.com/mastra-ai/mastra/commit/9aa5a73e7e110f6e9365eec69364a33d5f03bb56), [`f73c789`](https://github.com/mastra-ai/mastra/commit/f73c789e8ef21561580395d2c410119cab5848c8), [`8bd16da`](https://github.com/mastra-ai/mastra/commit/8bd16da73a4cb874d739373643dbd6a6e7f88684), [`c8630f8`](https://github.com/mastra-ai/mastra/commit/c8630f80d4f40cb5d22e60ab162b618b1907167a), [`94dfef6`](https://github.com/mastra-ai/mastra/commit/94dfef6e2bf19a88467ea3940afcbce88a433f0f), [`47f71dc`](https://github.com/mastra-ai/mastra/commit/47f71dc6fbcbd12d71e21a979e676e20a02bd77d), [`50ceae2`](https://github.com/mastra-ai/mastra/commit/50ceae270878e2f8fb2b2c6c2faab09df0007c8a), [`a122f79`](https://github.com/mastra-ai/mastra/commit/a122f79427ae225ec79c7b2ed46278da48d04b17), [`8cdde58`](https://github.com/mastra-ai/mastra/commit/8cdde5875bbba6702d9df226f2b20232b8d75d6c), [`3a081c1`](https://github.com/mastra-ai/mastra/commit/3a081c1255c5ae8c99f6dad91cc612934ef6f2bd), [`49f8abc`](https://github.com/mastra-ai/mastra/commit/49f8abce8258e4f2f87bd326acfbdb641264a47c), [`847ff1e`](https://github.com/mastra-ai/mastra/commit/847ff1e0d94368d94b2e173e4e0908e115568ef3), [`0c1ed1d`](https://github.com/mastra-ai/mastra/commit/0c1ed1d00c7d87b5ac99ca95896211a2fa9189fa), [`259d409`](https://github.com/mastra-ai/mastra/commit/259d409a514174299dbde1ff5e1121209b3ba850), [`9e16c68`](https://github.com/mastra-ai/mastra/commit/9e16c6818b6485ccb43df28aba6f3a2219d28662), [`cefca33`](https://github.com/mastra-ai/mastra/commit/cefca33ae666e69810c935fedf95a929c173d1d7), [`d00e8c5`](https://github.com/mastra-ai/mastra/commit/d00e8c50daebe5bce5bf2f48bde39c86fc3d2fe4), [`36fa7e2`](https://github.com/mastra-ai/mastra/commit/36fa7e24d14e58a1eb46147097b32f583e5b8775), [`87e9774`](https://github.com/mastra-ai/mastra/commit/87e97741c1e493cd6d62f478eb810b49bda4d57c), [`65a72e7`](https://github.com/mastra-ai/mastra/commit/65a72e70c25eedea8ff985a6624b96be2850236b), [`fe9eacd`](https://github.com/mastra-ai/mastra/commit/fe9eacd9545a0a9d64aad31c9fa90294a425289e), [`4c02027`](https://github.com/mastra-ai/mastra/commit/4c020277235eaa6b1dc957c90ad0639eef213992), [`0f77241`](https://github.com/mastra-ai/mastra/commit/0f7724108806703799a8ba80ad0f09414afd5066), [`849efb9`](https://github.com/mastra-ai/mastra/commit/849efb9fca6dc976589c1f90a303fea618769109), [`92ff509`](https://github.com/mastra-ai/mastra/commit/92ff5098ef8a990438ca038077021a5f7541ec1d), [`3fce5e7`](https://github.com/mastra-ai/mastra/commit/3fce5e70d011d289043e75003ef3336ed4aa43c3), [`a763592`](https://github.com/mastra-ai/mastra/commit/a763592c3db46963ef1011cfe16fe372816e775e), [`db79c86`](https://github.com/mastra-ai/mastra/commit/db79c86c60723d57e02f9636ca2611bd4515f194), [`6855012`](https://github.com/mastra-ai/mastra/commit/685501247cc4717506f3e89beed03509d63a5370), [`80c7737`](https://github.com/mastra-ai/mastra/commit/80c7737e32d7917b5f356957d67c169d01744fd3), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`3f1cf47`](https://github.com/mastra-ai/mastra/commit/3f1cf476f74c1e4cc2df908837e05853a5347e31), [`ff9d743`](https://github.com/mastra-ai/mastra/commit/ff9d743f71d7e072927725c0d700632aca0c1fee)]:
|
|
202
|
+
- @mastra/schema-compat@1.2.11
|
|
203
|
+
- @mastra/core@1.38.0
|
|
204
|
+
|
|
3
205
|
## 1.22.0-alpha.9
|
|
4
206
|
|
|
5
207
|
### 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.23.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -97,7 +97,7 @@ The behavior options are:
|
|
|
97
97
|
- `ifIdle.behavior: 'persist'`: Save the signal or message to memory without starting a stream.
|
|
98
98
|
- `ifIdle.behavior: 'discard'`: Ignore the signal or message while the thread is idle.
|
|
99
99
|
|
|
100
|
-
Pass `ifIdle.streamOptions` when the idle wake-up stream needs options such as model settings, tools, or runtime context. You
|
|
100
|
+
Pass `ifIdle.streamOptions` when the idle wake-up stream needs options such as model settings, tools, or runtime context. You don't need to repeat `memory.resource` or `memory.thread`; Mastra uses the top-level `resourceId` and `threadId` for the thread.
|
|
101
101
|
|
|
102
102
|
```typescript
|
|
103
103
|
agent.sendMessage('Continue with the next step.', {
|
|
@@ -143,6 +143,10 @@ The model receives the signal as context like this:
|
|
|
143
143
|
|
|
144
144
|
Use XML-safe `tagName` and attribute names. They can contain letters, numbers, underscores, periods, and hyphens. They must start with a letter or underscore.
|
|
145
145
|
|
|
146
|
+
### Storage support
|
|
147
|
+
|
|
148
|
+
Notification inbox storage is available in the storage adapters that support richer memory and signal workflows: [libSQL](https://mastra.ai/reference/storage/libsql), [PostgreSQL](https://mastra.ai/reference/storage/postgresql), and [MongoDB](https://mastra.ai/reference/storage/mongodb). These adapters expose notification records through `getStore('notifications')`.
|
|
149
|
+
|
|
146
150
|
## Send processor context
|
|
147
151
|
|
|
148
152
|
Processors can send reactive signals during a run. A processor should inspect the chat history, react to a specific trigger, and avoid sending the same context more than once.
|
|
@@ -220,7 +224,224 @@ When the agent is idle:
|
|
|
220
224
|
<user source="chat" delivery="new-message">Also cover the edge cases.</user>
|
|
221
225
|
```
|
|
222
226
|
|
|
223
|
-
Top-level `attributes` always apply. The selected branch's `attributes` are merged into them at delivery time. The `delivery` name shown above
|
|
227
|
+
Top-level `attributes` always apply. The selected branch's `attributes` are merged into them at delivery time. The `delivery` name shown above isn't a special Mastra API field. It's a custom attribute name used for this example. Add any attribute names that suit your use case.
|
|
228
|
+
|
|
229
|
+
## State signals
|
|
230
|
+
|
|
231
|
+
State signals expose named, thread-scoped context lanes. Use them for durable context that changes over time, such as browser state, editor state, or a background watcher result.
|
|
232
|
+
|
|
233
|
+
Each state signal needs:
|
|
234
|
+
|
|
235
|
+
- `id`: The state lane name, such as `browser`.
|
|
236
|
+
- `cacheKey`: A producer-owned key for deduping the current state.
|
|
237
|
+
- `mode`: `snapshot` for an authoritative state copy, or `delta` for a change event.
|
|
238
|
+
|
|
239
|
+
Use `sendStateSignal()` when an external producer detects a state change.
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
await agent.sendStateSignal(
|
|
243
|
+
{
|
|
244
|
+
id: 'browser',
|
|
245
|
+
mode: 'snapshot',
|
|
246
|
+
cacheKey: 'browser:https://example.com:3-tabs',
|
|
247
|
+
contents: 'Browser is open on https://example.com with 3 tabs.',
|
|
248
|
+
value: {
|
|
249
|
+
activeUrl: 'https://example.com',
|
|
250
|
+
tabCount: 3,
|
|
251
|
+
open: true,
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
resourceId: 'user_123',
|
|
256
|
+
threadId: 'thread_456',
|
|
257
|
+
},
|
|
258
|
+
)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
When Mastra accepts a state signal, it stores compact tracking metadata on the thread. The metadata records the lane's current `cacheKey`, current mode, version, last signal id, and last snapshot signal id. If a producer sends the same `cacheKey` and mode again while that state is still current, Mastra skips the duplicate.
|
|
262
|
+
|
|
263
|
+
State signal fields have separate roles:
|
|
264
|
+
|
|
265
|
+
- `contents`: The representation the model reads.
|
|
266
|
+
- `value`: The structured snapshot for `mode: 'snapshot'`.
|
|
267
|
+
- `delta`: The structured change for `mode: 'delta'`.
|
|
268
|
+
- `metadata.state`: The runtime tracking envelope with `id`, `mode`, `cacheKey`, `version`, and `threadId`.
|
|
269
|
+
|
|
270
|
+
Use `computeStateSignal()` when a processor owns a state lane. Mastra calls it once per model input step after `processInputStep()`. If the processor omits `id`, Mastra uses the processor id as the state lane id. Set `stateId` when the public state lane should differ from the processor id.
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
import type { ComputeStateSignalArgs, Processor } from '@mastra/core/processors'
|
|
274
|
+
|
|
275
|
+
export const browserStateProcessor: Processor = {
|
|
276
|
+
id: 'browser-state',
|
|
277
|
+
stateId: 'browser',
|
|
278
|
+
computeStateSignal(args: ComputeStateSignalArgs) {
|
|
279
|
+
const browser = readCurrentBrowserState()
|
|
280
|
+
const previous = readMostRecentBrowserState(args.activeStateSignals)
|
|
281
|
+
const changed = previous ? diffBrowserState(previous, browser) : browser
|
|
282
|
+
const shouldRefreshSnapshot = Boolean(args.lastSnapshot && !args.contextWindow.hasSnapshot)
|
|
283
|
+
|
|
284
|
+
if (previous && Object.keys(changed).length === 0 && !shouldRefreshSnapshot) {
|
|
285
|
+
return
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const isDelta = Boolean(previous && !shouldRefreshSnapshot)
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
mode: isDelta ? 'delta' : 'snapshot',
|
|
292
|
+
cacheKey: stableBrowserStateCacheKey(browser),
|
|
293
|
+
contents: isDelta ? describeBrowserDelta(changed) : describeBrowserSnapshot(browser),
|
|
294
|
+
value: browser,
|
|
295
|
+
...(isDelta ? { delta: changed } : {}),
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Mastra passes `lastSnapshot` and `deltasSinceSnapshot` into `computeStateSignal()`. It resolves them from message history when the current message list doesn't contain the latest snapshot. The processor still owns merge and diff logic.
|
|
302
|
+
|
|
303
|
+
`contextWindow.hasSnapshot` tells the processor whether the active message window already contains a snapshot for this state lane. If it's `false`, return a fresh `snapshot` so the model sees the current state even after older state messages are trimmed from the context window.
|
|
304
|
+
|
|
305
|
+
The built-in browser context processor emits state under the `browser` id with snapshot and delta modes.
|
|
306
|
+
|
|
307
|
+
## Notification signals
|
|
308
|
+
|
|
309
|
+
Notification signals represent external events such as GitHub activity, email, Slack mentions, CI status, incidents, recordings, or direct messages. Use `agent.sendNotificationSignal()` when the event should create a durable inbox record.
|
|
310
|
+
|
|
311
|
+
Notification delivery has two phases:
|
|
312
|
+
|
|
313
|
+
- **Ingress**: `agent.sendNotificationSignal()` stores a notification record, then resolves the agent's delivery policy.
|
|
314
|
+
- **Dispatch**: Mastra consumes due records stamped with `deliverAt` or `summaryAt` and emits full notification or summary signals.
|
|
315
|
+
|
|
316
|
+
A notification record stores the source, kind, priority, summary, payload, resource id, thread id, agent id, coalescing keys, and delivery metadata. The delivery decision controls what happens after ingress:
|
|
317
|
+
|
|
318
|
+
- `deliver` or `queue`: Emit a full `<notification>` signal and mark the record `delivered`.
|
|
319
|
+
- `defer`: Keep the record `pending` with `deliverAt`.
|
|
320
|
+
- `summarize`: Keep the record `pending` with `summaryAt`, or emit an immediate summary when the policy requests it.
|
|
321
|
+
- `persist`: Keep the record `pending` in the inbox without scheduled delivery.
|
|
322
|
+
- `discard`: Mark the record `discarded` and emit no signal.
|
|
323
|
+
|
|
324
|
+
The default delivery policy is priority-aware:
|
|
325
|
+
|
|
326
|
+
| Priority | Active thread | Idle thread |
|
|
327
|
+
| -------- | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
328
|
+
| `urgent` | Deliver a full notification immediately | Deliver a full notification immediately |
|
|
329
|
+
| `high` | Emit a summary immediately, keep `deliverAt`, then deliver the full notification when the thread is idle | Deliver a full notification immediately |
|
|
330
|
+
| `medium` | Batch with `summaryAt` and later deliver one notification summary | Deliver a full notification immediately |
|
|
331
|
+
| `low` | Batch with `summaryAt` and later deliver one notification summary | Batch with `summaryAt` and later deliver one notification summary without waking the model loop |
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
await agent.sendNotificationSignal(
|
|
335
|
+
{
|
|
336
|
+
source: 'github',
|
|
337
|
+
kind: 'ci-status',
|
|
338
|
+
priority: 'high',
|
|
339
|
+
summary: 'CI failed on main: 3 tests failed.',
|
|
340
|
+
payload: {
|
|
341
|
+
repository: 'acme/app',
|
|
342
|
+
branch: 'main',
|
|
343
|
+
},
|
|
344
|
+
dedupeKey: 'github:acme/app:main:ci',
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
resourceId: 'user_123',
|
|
348
|
+
threadId: 'thread_456',
|
|
349
|
+
},
|
|
350
|
+
)
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
The model receives full notifications as context:
|
|
354
|
+
|
|
355
|
+
```xml
|
|
356
|
+
<notification source="github" type="ci-status" priority="high" status="delivered">CI failed on main: 3 tests failed.</notification>
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
Notification summaries tell the model that inbox records are waiting:
|
|
360
|
+
|
|
361
|
+
```xml
|
|
362
|
+
<notification-summary pending="10">github: 3, email: 5, slack: 2</notification-summary>
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
When Mastra emits a summary, it clears `summaryAt` and sets `summarySignalId` on each summarized record. The records stay pending and readable. When Mastra emits a full notification, it sets `deliveredSignalId` and marks the record `delivered`. If the inbox tool reads a notification first, it can inject the full notification signal and mark the record `seen`, which prevents duplicate full delivery.
|
|
366
|
+
|
|
367
|
+
Configure a delivery policy on the agent when some notifications should wait for a different dispatch window or summary rollup.
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
export const supportAgent = new Agent({
|
|
371
|
+
id: 'support-agent',
|
|
372
|
+
name: 'Support Agent',
|
|
373
|
+
instructions: 'Help the user triage updates.',
|
|
374
|
+
model: 'openai/gpt-5.5',
|
|
375
|
+
notifications: {
|
|
376
|
+
deliveryPolicy: {
|
|
377
|
+
priorities: {
|
|
378
|
+
urgent: 'deliver',
|
|
379
|
+
},
|
|
380
|
+
decide: ({ record }) => {
|
|
381
|
+
if (record.priority === 'low') {
|
|
382
|
+
return {
|
|
383
|
+
action: 'summarize',
|
|
384
|
+
summaryAt: new Date(Date.now() + 30 * 60 * 1000),
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
})
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Enable scheduled dispatch at the Mastra level so deferred notifications and summary rollups are delivered through the existing workflow scheduler.
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
export const mastra = new Mastra({
|
|
397
|
+
agents: { supportAgent },
|
|
398
|
+
storage,
|
|
399
|
+
notifications: {
|
|
400
|
+
dispatch: {
|
|
401
|
+
enabled: true,
|
|
402
|
+
cron: '*/1 * * * *',
|
|
403
|
+
batchSize: 100,
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
})
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
`notifications.dispatch.enabled` registers an internal workflow with the default cron `*/1 * * * *`. The dispatcher reads due notification records from storage, groups summaries by `agentId`, `resourceId`, and `threadId`, and emits signals through the Agent thread runtime. It isn't a user-facing entrypoint.
|
|
410
|
+
|
|
411
|
+
### Notification inbox tool
|
|
412
|
+
|
|
413
|
+
Use `createNotificationInboxTool()` to give agents one tool for inbox actions instead of many CRUD tools.
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
import { createNotificationInboxTool } from '@mastra/core/notifications'
|
|
417
|
+
|
|
418
|
+
const notificationsStorage = await storage.getStore('notifications')
|
|
419
|
+
|
|
420
|
+
export const supportAgent = new Agent({
|
|
421
|
+
id: 'support-agent',
|
|
422
|
+
name: 'Support Agent',
|
|
423
|
+
instructions: 'Help the user triage updates.',
|
|
424
|
+
model: 'openai/gpt-5.5',
|
|
425
|
+
tools: {
|
|
426
|
+
notificationInbox: createNotificationInboxTool({ storage: notificationsStorage }),
|
|
427
|
+
},
|
|
428
|
+
})
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
The tool id is `notification-inbox`. It supports these actions:
|
|
432
|
+
|
|
433
|
+
- `list`: List notifications for the current thread.
|
|
434
|
+
- `read`: Deliver readable full notification signals into the chat when possible, then mark records `seen`.
|
|
435
|
+
- `markSeen`: Mark one record `seen`.
|
|
436
|
+
- `dismiss`: Mark one record `dismissed`.
|
|
437
|
+
- `archive`: Mark one record `archived`.
|
|
438
|
+
- `search`: Search notification summaries in the current thread.
|
|
439
|
+
|
|
440
|
+
The tool uses the current `threadId` from the tool execution context unless one is provided. Use `read` after a `<notification-summary>` signal when the agent needs the full records behind the summary. The `read` result reports how many notifications will be delivered; it doesn't use normal tool output as the main context channel for the notification contents.
|
|
441
|
+
|
|
442
|
+
`sendNotificationSignal()` requires a storage domain with `notifications` support. LibSQL supports notifications. Other storage adapters need matching notification domain support before they can store notification records.
|
|
443
|
+
|
|
444
|
+
Use `sendSignal({ type: 'notification' })` only for lower-level notification-shaped context that should bypass inbox storage.
|
|
224
445
|
|
|
225
446
|
## Compatibility
|
|
226
447
|
|
|
@@ -229,7 +450,7 @@ Mastra still accepts legacy signal payloads such as `type: 'user-message'` and `
|
|
|
229
450
|
- `type: 'user-message'`: Normalizes to `type: 'user'` and `tagName: 'user'`
|
|
230
451
|
- `type: 'system-reminder'`: Normalizes to `type: 'reactive'` and `tagName: 'system-reminder'`
|
|
231
452
|
|
|
232
|
-
Existing stored signal rows and older clients continue to load through the compatibility layer.
|
|
453
|
+
Existing stored signal rows and older clients continue to load through the compatibility layer. New clients call the message routes when the server supports them; React's thread signal path falls back to the legacy `/signals` route when it detects an older server.
|
|
233
454
|
|
|
234
455
|
> **Note:** Visit [Agent signals reference](https://mastra.ai/reference/agents/agent) for the full message, signal, and subscription types.
|
|
235
456
|
|
|
@@ -264,11 +485,8 @@ const subscription = await agent.subscribeToThread({
|
|
|
264
485
|
threadId: 'thread_456',
|
|
265
486
|
})
|
|
266
487
|
|
|
267
|
-
await agent.
|
|
268
|
-
|
|
269
|
-
type: 'user-message',
|
|
270
|
-
contents: 'Show the shorter version.',
|
|
271
|
-
},
|
|
488
|
+
await agent.sendMessage({
|
|
489
|
+
message: 'Show the shorter version.',
|
|
272
490
|
resourceId: 'user_123',
|
|
273
491
|
threadId: 'thread_456',
|
|
274
492
|
})
|
|
@@ -307,7 +525,9 @@ Use heartbeats together with client-side reconnect logic. Heartbeats reduce idle
|
|
|
307
525
|
- [`Agent.queueMessage()`](https://mastra.ai/reference/agents/agent)
|
|
308
526
|
- [`Agent.sendSignal()`](https://mastra.ai/reference/agents/agent)
|
|
309
527
|
- [`Agent.subscribeToThread()`](https://mastra.ai/reference/agents/agent)
|
|
310
|
-
- [
|
|
528
|
+
- [`client.getAgent().sendMessage()`](https://mastra.ai/reference/client-js/agents)
|
|
529
|
+
- [`client.getAgent().queueMessage()`](https://mastra.ai/reference/client-js/agents)
|
|
311
530
|
- [`client.getAgent().sendSignal()`](https://mastra.ai/reference/client-js/agents)
|
|
531
|
+
- [Server agent routes](https://mastra.ai/reference/server/routes)
|
|
312
532
|
- [`client.getAgent().subscribeToThread()`](https://mastra.ai/reference/client-js/agents)
|
|
313
533
|
- [`client.getAgent().sendToolApproval()`](https://mastra.ai/reference/client-js/agents)
|
|
@@ -149,16 +149,17 @@ The `editor.agent` namespace also exposes `getById`, `list`, `listResolved`, and
|
|
|
149
149
|
|
|
150
150
|
The same operations are available over HTTP through the Mastra server. Use these when you want to manage stored agents from a separate service or from a non-TypeScript client:
|
|
151
151
|
|
|
152
|
-
| Method | Path
|
|
153
|
-
| -------- |
|
|
154
|
-
| `GET` | `/stored/agents`
|
|
155
|
-
| `POST` | `/stored/agents`
|
|
156
|
-
| `GET` | `/stored/agents/:storedAgentId`
|
|
157
|
-
| `PATCH` | `/stored/agents/:storedAgentId`
|
|
158
|
-
| `DELETE` | `/stored/agents/:storedAgentId`
|
|
159
|
-
| `
|
|
160
|
-
|
|
161
|
-
|
|
152
|
+
| Method | Path | Description |
|
|
153
|
+
| -------- | ------------------------------------------ | ---------------------------------------------------------------- |
|
|
154
|
+
| `GET` | `/stored/agents` | List all stored agents. |
|
|
155
|
+
| `POST` | `/stored/agents` | Create a stored agent. |
|
|
156
|
+
| `GET` | `/stored/agents/:storedAgentId` | Get a stored agent by ID. |
|
|
157
|
+
| `PATCH` | `/stored/agents/:storedAgentId` | Update a stored agent. |
|
|
158
|
+
| `DELETE` | `/stored/agents/:storedAgentId` | Delete a stored agent. |
|
|
159
|
+
| `GET` | `/stored/agents/:storedAgentId/dependents` | List agents that reference this agent as a sub-agent. |
|
|
160
|
+
| `POST` | `/stored/agents/:storedAgentId/export` | Export a stored agent's override as a deterministic JSON config. |
|
|
161
|
+
|
|
162
|
+
The dependents endpoint helps warn before deleting or unsharing an agent that other agents depend on: `dependents` lists caller-readable agents by `id` and `name`, while `hiddenCount` aggregates cross-workspace references the caller cannot read (surfaced only when the target is public). The export endpoint returns only the fields the agent's [`editor` config](https://mastra.ai/reference/agents/agent) allows, so the output matches the per-agent file the code source writes to disk. The Client SDK wraps these endpoints with `client.listStoredAgents()`, `client.createStoredAgent()`, `client.getStoredAgent()`, `client.getStoredAgent(id).dependents()`, and `client.getStoredAgent(id).export()`. Version management endpoints live under `/stored/agents/:storedAgentId/versions`, see [version management](https://mastra.ai/reference/client-js/agents) for the full list.
|
|
162
163
|
|
|
163
164
|
### Automated experimentation
|
|
164
165
|
|
|
@@ -151,17 +151,51 @@ for await (const part of uiMessageStream) {
|
|
|
151
151
|
}
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
### `sendMessage()`
|
|
155
|
+
|
|
156
|
+
Send user-authored input to an active agent run or idle memory thread. Use this with `subscribeToThread()` so the client can render the stream that wakes from, or receives, the message.
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
const agent = mastraClient.getAgent('support-agent')
|
|
160
|
+
|
|
161
|
+
const result = await agent.sendMessage({
|
|
162
|
+
message: {
|
|
163
|
+
contents: 'Also consider the customer note I just added.',
|
|
164
|
+
attributes: { sentFrom: 'web' },
|
|
165
|
+
},
|
|
166
|
+
resourceId: 'user-123',
|
|
167
|
+
threadId: 'thread-abc',
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
console.log(result.runId)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`message` accepts a string, an array of text/file parts, or an object with `contents`, `attributes`, `metadata`, and `providerOptions`.
|
|
174
|
+
|
|
175
|
+
### `queueMessage()`
|
|
176
|
+
|
|
177
|
+
Queue user-authored input for the next thread turn. If the thread is active, Mastra starts a new run after the current run completes. If the thread is idle, Mastra starts a run immediately.
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
await agent.queueMessage({
|
|
181
|
+
message: 'Also check whether the tests need updates.',
|
|
182
|
+
resourceId: 'user-123',
|
|
183
|
+
threadId: 'thread-abc',
|
|
184
|
+
})
|
|
185
|
+
```
|
|
186
|
+
|
|
154
187
|
### `sendSignal()`
|
|
155
188
|
|
|
156
|
-
Send a signal to an active agent run or memory thread. Use this
|
|
189
|
+
Send a lower-level signal to an active agent run or memory thread. Use this for system-generated context such as reactive reminders or notification-shaped context that doesn't need inbox storage. For durable notification records, use the server-side [`Agent.sendNotificationSignal()`](https://mastra.ai/reference/agents/agent) API. For user-authored input, prefer `sendMessage()` or `queueMessage()`.
|
|
157
190
|
|
|
158
191
|
```typescript
|
|
159
192
|
const agent = mastraClient.getAgent('support-agent')
|
|
160
193
|
|
|
161
194
|
const result = await agent.sendSignal({
|
|
162
195
|
signal: {
|
|
163
|
-
type: '
|
|
164
|
-
|
|
196
|
+
type: 'reactive',
|
|
197
|
+
tagName: 'system-reminder',
|
|
198
|
+
contents: 'Also consider the latest customer note.',
|
|
165
199
|
},
|
|
166
200
|
resourceId: 'user-123',
|
|
167
201
|
threadId: 'thread-abc',
|
|
@@ -174,7 +208,7 @@ Use `ifActive.behavior` and `ifIdle.behavior` to control whether Mastra delivers
|
|
|
174
208
|
|
|
175
209
|
```typescript
|
|
176
210
|
await agent.sendSignal({
|
|
177
|
-
signal: { type: '
|
|
211
|
+
signal: { type: 'reactive', tagName: 'system-reminder', contents: 'Store this for later.' },
|
|
178
212
|
resourceId: 'user-123',
|
|
179
213
|
threadId: 'thread-abc',
|
|
180
214
|
ifIdle: {
|
|
@@ -187,7 +221,7 @@ Pass `ifIdle.streamOptions` when the idle wake-up stream needs options such as m
|
|
|
187
221
|
|
|
188
222
|
```typescript
|
|
189
223
|
await agent.sendSignal({
|
|
190
|
-
signal: { type: '
|
|
224
|
+
signal: { type: 'reactive', tagName: 'system-reminder', contents: 'Start from this signal.' },
|
|
191
225
|
resourceId: 'user-123',
|
|
192
226
|
threadId: 'thread-abc',
|
|
193
227
|
ifIdle: {
|
|
@@ -201,7 +235,7 @@ await agent.sendSignal({
|
|
|
201
235
|
|
|
202
236
|
Returns `{ accepted: true, runId: string }`.
|
|
203
237
|
|
|
204
|
-
**signal** (`{ type: 'user
|
|
238
|
+
**signal** (`{ type: 'user' | 'reactive' | 'notification' | string; tagName?: string; contents: string | Array<TextPart | FilePart>; attributes?: Record<string, JSONValue>; metadata?: Record<string, unknown>; providerOptions?: ProviderMetadata }`): Lower-level signal payload. Use \`type\` for the semantic signal category and \`tagName\` for the XML tag shown to the model. \`providerOptions\` is attached to the resulting prompt turn and persisted on the stored signal message.
|
|
205
239
|
|
|
206
240
|
**runId** (`string`): Run ID to target directly.
|
|
207
241
|
|
|
@@ -217,7 +251,7 @@ Returns `{ accepted: true, runId: string }`.
|
|
|
217
251
|
|
|
218
252
|
### `subscribeToThread()`
|
|
219
253
|
|
|
220
|
-
Subscribe to raw stream chunks for a memory thread. Use this to render output from a thread that may be started or continued by `sendSignal()
|
|
254
|
+
Subscribe to raw stream chunks for a memory thread. Use this to render output from a thread that may be started or continued by `sendMessage()`, `queueMessage()`, `sendSignal()`, or server-side notification dispatch.
|
|
221
255
|
|
|
222
256
|
```typescript
|
|
223
257
|
const agent = mastraClient.getAgent('support-agent')
|