@mastra/client-js 1.54.1-alpha.4 → 1.55.0-alpha.6
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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-harness-agent-controller.md +2 -1
- package/dist/docs/references/docs-harness-signals.md +22 -0
- package/dist/docs/references/reference-client-js-agents.md +17 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +2 -1
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +28 -2
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
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.55.0-alpha.6"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -431,6 +431,7 @@ channels: {
|
|
|
431
431
|
|
|
432
432
|
return controller.createSession({
|
|
433
433
|
resourceId: thread.resourceId,
|
|
434
|
+
threadId: thread.id,
|
|
434
435
|
scope: install.id,
|
|
435
436
|
ownerId: controller.id,
|
|
436
437
|
requestContext,
|
|
@@ -439,7 +440,7 @@ channels: {
|
|
|
439
440
|
}
|
|
440
441
|
```
|
|
441
442
|
|
|
442
|
-
Create the session under `thread.resourceId`. Because a session can bind only threads it owns, use `resolveResourceId` to assign a different owner to the mapped thread. Sessions are get-or-create for each `resourceId` and `scope` combination. Pass `scope` when one thread needs separate sessions for each installation or principal.
|
|
443
|
+
Create the session under `thread.resourceId`. Because a session can bind only threads it owns, use `resolveResourceId` to assign a different owner to the mapped thread. Pass `threadId: thread.id` so the session opens on the mapped thread. Without it, a session that has tags or a `projectPath` doesn't treat the mapped thread as its own, so it creates an extra empty thread before switching to the mapped one. Sessions are get-or-create for each `resourceId` and `scope` combination. Pass `scope` when one thread needs separate sessions for each installation or principal.
|
|
443
444
|
|
|
444
445
|
Failures that aren't refusals (a storage outage, a bug in your resolver's dependencies) still post an error to the thread, so a broken bot doesn't look like a silent one. If you need to tell them apart in your own code, a refusal is a `ChannelSessionRejectedError` with the original error as its `cause`.
|
|
445
446
|
|
|
@@ -100,6 +100,26 @@ agent.queueMessage('Also check whether the tests need updates.', {
|
|
|
100
100
|
|
|
101
101
|
When the thread is idle, `queueMessage()` starts a run immediately. When the thread is active, it preserves turn order by starting a new run after the active run completes.
|
|
102
102
|
|
|
103
|
+
### Queue a typed signal for the next turn
|
|
104
|
+
|
|
105
|
+
Use `queueSignal()` when system-generated input needs the same turn ordering as `queueMessage()` but should keep its own signal type, tag, and attributes. For example, a skill invocation can render as a `<skill>` element instead of a plain user message:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
agent.queueSignal(
|
|
109
|
+
{
|
|
110
|
+
type: 'reactive',
|
|
111
|
+
tagName: 'skill',
|
|
112
|
+
attributes: { name: 'triage' },
|
|
113
|
+
contents: 'Triage the new issue.',
|
|
114
|
+
},
|
|
115
|
+
{ resourceId: 'user_123', threadId: 'thread_456' },
|
|
116
|
+
)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The model receives `<skill name="triage">Triage the new issue.</skill>`. Queued signals share the `queueMessage()` queue, so they count toward queue-count events and you can cancel them with `cancelQueuedMessages()`.
|
|
120
|
+
|
|
121
|
+
When a signal starts a run, the run's `AGENT_RUN` span records the signal's `id`, `type`, `tagName`, and `attributes` under `attributes.signal`.
|
|
122
|
+
|
|
103
123
|
### Cancel pending input
|
|
104
124
|
|
|
105
125
|
Use [`cancelQueuedMessages()`](https://mastra.ai/reference/agents/agent) to remove selected pending input without stopping the active run. Cancellation is scoped to the memory thread, including input submitted by other Agents sharing the same runtime and PubSub instance.
|
|
@@ -508,12 +528,14 @@ Use heartbeats together with client-side reconnect logic. Heartbeats reduce idle
|
|
|
508
528
|
|
|
509
529
|
- [`Agent.sendMessage()`](https://mastra.ai/reference/agents/agent)
|
|
510
530
|
- [`Agent.queueMessage()`](https://mastra.ai/reference/agents/agent)
|
|
531
|
+
- [`Agent.queueSignal()`](https://mastra.ai/reference/agents/agent)
|
|
511
532
|
- [`Agent.sendSignal()`](https://mastra.ai/reference/agents/agent)
|
|
512
533
|
- [`Agent.sendStateSignal()`](https://mastra.ai/reference/agents/agent)
|
|
513
534
|
- [`Agent.subscribeToThread()`](https://mastra.ai/reference/agents/agent)
|
|
514
535
|
- [`createNotificationInboxTool()`](https://mastra.ai/reference/signals/create-notification-inbox-tool)
|
|
515
536
|
- [`client.getAgent().sendMessage()`](https://mastra.ai/reference/client-js/agents)
|
|
516
537
|
- [`client.getAgent().queueMessage()`](https://mastra.ai/reference/client-js/agents)
|
|
538
|
+
- [`client.getAgent().queueSignal()`](https://mastra.ai/reference/client-js/agents)
|
|
517
539
|
- [`client.getAgent().sendSignal()`](https://mastra.ai/reference/client-js/agents)
|
|
518
540
|
- [Server agent routes](https://mastra.ai/reference/server/routes)
|
|
519
541
|
- [`client.getAgent().subscribeToThread()`](https://mastra.ai/reference/client-js/agents)
|
|
@@ -213,6 +213,23 @@ await agent.queueMessage({
|
|
|
213
213
|
})
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
+
### `queueSignal()`
|
|
217
|
+
|
|
218
|
+
Queue a typed signal for the next thread turn. It follows the same ordering as `queueMessage()`, but keeps the signal's `type`, `tagName`, and `attributes`.
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
await agent.queueSignal({
|
|
222
|
+
signal: {
|
|
223
|
+
type: 'reactive',
|
|
224
|
+
tagName: 'skill',
|
|
225
|
+
attributes: { name: 'triage' },
|
|
226
|
+
contents: 'Triage the new issue.',
|
|
227
|
+
},
|
|
228
|
+
resourceId: 'user-123',
|
|
229
|
+
threadId: 'thread-abc',
|
|
230
|
+
})
|
|
231
|
+
```
|
|
232
|
+
|
|
216
233
|
### `sendSignal()`
|
|
217
234
|
|
|
218
235
|
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()`.
|
package/dist/index.cjs
CHANGED
|
@@ -1010,6 +1010,9 @@ var Agent = class extends BaseResource {
|
|
|
1010
1010
|
sendSignal(params) {
|
|
1011
1011
|
return this.requestSignalRoute(`/agents/${this.agentId}/signals`, params);
|
|
1012
1012
|
}
|
|
1013
|
+
queueSignal(params) {
|
|
1014
|
+
return this.requestSignalRoute(`/agents/${this.agentId}/queue-signal`, params);
|
|
1015
|
+
}
|
|
1013
1016
|
async subscribeToThread(params) {
|
|
1014
1017
|
const { resourceId, threadId, withInitialHistory } = params;
|
|
1015
1018
|
const requestSubscription = () => this.request(`/agents/${this.agentId}/threads/subscribe`, {
|