@mastra/client-js 1.54.0-alpha.2 → 1.54.0-alpha.4
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 +18 -0
- package/dist/docs/references/reference-client-js-agent-controller.md +2 -2
- package/dist/index.cjs +18 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-controller.d.ts +21 -3
- package/dist/resources/agent-controller.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +2 -7
- package/dist/route-types.generated.d.ts.map +1 -1
- package/package.json +6 -6
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.54.0-alpha.
|
|
6
|
+
version: "1.54.0-alpha.4"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -133,6 +133,24 @@ const session = await controller.createSession({
|
|
|
133
133
|
|
|
134
134
|
Use [`session.thread.create()`](https://mastra.ai/reference/agent-controller/session) and [`session.thread.switch()`](https://mastra.ai/reference/agent-controller/session) to move one live Session between conversations.
|
|
135
135
|
|
|
136
|
+
### Transfer thread ownership
|
|
137
|
+
|
|
138
|
+
Each new thread stores its durable owner in `metadata.ownerId` and its original creator in `metadata.createdBy`. Both default to the Session host's `ownerId`. `createdBy` doesn't change when ownership transfers.
|
|
139
|
+
|
|
140
|
+
Read the active thread's owner and transfer it through `session.thread`:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
const currentOwnerId = await session.thread.getOwner()
|
|
144
|
+
|
|
145
|
+
await session.thread.transferOwnership({
|
|
146
|
+
toOwnerId: 'user-456',
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Transfers are serialized within one process. Hosts that require a durable cross-process compare-and-set should commit it in their own storage first, then call `transferOwnership()` to mirror the owner onto the active thread.
|
|
151
|
+
|
|
152
|
+
Every run snapshots the thread owner when it starts. Tools and other dynamic runtime code can read that value from `AgentControllerRequestContext.threadOwnerId`. If ownership changes during a run, the active run keeps the old snapshot and the next run receives the new owner. `context.session.ownerId` remains the identity of the process-local Session host.
|
|
153
|
+
|
|
136
154
|
### List stored messages from the client
|
|
137
155
|
|
|
138
156
|
Use the Agent Controller client to page through a thread's stored messages. Passing an options object returns the messages with pagination metadata:
|
|
@@ -121,11 +121,11 @@ Pass `options.requestContext` to merge custom context into the run's request con
|
|
|
121
121
|
|
|
122
122
|
### `steer(message, options?)`
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
Aborts the in-flight run, then sends the message as a new turn. Pass a string, or `{ content, files }` to attach files in the same shape as `sendMessage()`.
|
|
125
125
|
|
|
126
126
|
### `followUp(message, options?)`
|
|
127
127
|
|
|
128
|
-
Queues a follow-up message. If the session is idle it sends immediately. If a run is active it queues for after the run completes.
|
|
128
|
+
Queues a follow-up message. If the session is idle it sends immediately. If a run is active it queues for after the run completes. Pass a string, or `{ content, files }` to attach files in the same shape as `sendMessage()`.
|
|
129
129
|
|
|
130
130
|
### `abort()`
|
|
131
131
|
|
package/dist/index.cjs
CHANGED
|
@@ -6075,6 +6075,7 @@ const KNOWN_AGENT_CONTROLLER_EVENT_TYPES = new Set(Object.keys({
|
|
|
6075
6075
|
thread_changed: true,
|
|
6076
6076
|
thread_created: true,
|
|
6077
6077
|
thread_deleted: true,
|
|
6078
|
+
thread_owner_changed: true,
|
|
6078
6079
|
thread_title_updated: true,
|
|
6079
6080
|
subagent_start: true,
|
|
6080
6081
|
subagent_text_delta: true,
|
|
@@ -6437,13 +6438,21 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6437
6438
|
}
|
|
6438
6439
|
});
|
|
6439
6440
|
}
|
|
6440
|
-
/**
|
|
6441
|
+
/**
|
|
6442
|
+
* Aborts the in-flight run, then sends the message as a new turn.
|
|
6443
|
+
* Pass a structured message to attach files, as with `sendMessage`.
|
|
6444
|
+
*/
|
|
6441
6445
|
async steer(message, options) {
|
|
6446
|
+
const { content, files } = typeof message === "string" ? {
|
|
6447
|
+
content: message,
|
|
6448
|
+
files: void 0
|
|
6449
|
+
} : message;
|
|
6442
6450
|
const requestContext = parseClientRequestContext(options?.requestContext);
|
|
6443
6451
|
await this.request(this.url(`${this.base()}/steer`), {
|
|
6444
6452
|
method: "POST",
|
|
6445
6453
|
body: {
|
|
6446
|
-
message,
|
|
6454
|
+
message: content,
|
|
6455
|
+
...files?.length ? { files } : {},
|
|
6447
6456
|
...requestContext ? { requestContext } : {}
|
|
6448
6457
|
}
|
|
6449
6458
|
});
|
|
@@ -6554,13 +6563,19 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6554
6563
|
/**
|
|
6555
6564
|
* Queue a follow-up message. If the session is idle it sends immediately;
|
|
6556
6565
|
* if a run is active it queues for after completion.
|
|
6566
|
+
* Pass a structured message to attach files, as with `sendMessage`.
|
|
6557
6567
|
*/
|
|
6558
6568
|
async followUp(message, options) {
|
|
6569
|
+
const { content, files } = typeof message === "string" ? {
|
|
6570
|
+
content: message,
|
|
6571
|
+
files: void 0
|
|
6572
|
+
} : message;
|
|
6559
6573
|
const requestContext = parseClientRequestContext(options?.requestContext);
|
|
6560
6574
|
await this.request(this.url(`${this.base()}/follow-up`), {
|
|
6561
6575
|
method: "POST",
|
|
6562
6576
|
body: {
|
|
6563
|
-
message,
|
|
6577
|
+
message: content,
|
|
6578
|
+
...files?.length ? { files } : {},
|
|
6564
6579
|
...requestContext ? { requestContext } : {}
|
|
6565
6580
|
}
|
|
6566
6581
|
});
|