@mastra/client-js 1.31.2-alpha.6 → 1.32.0-alpha.11
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 +75 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +57 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -36
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-controller.d.ts +48 -9
- package/dist/resources/agent-controller.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +210 -119
- package/dist/route-types.generated.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -6140,16 +6140,24 @@ var Channels = class extends BaseResource {
|
|
|
6140
6140
|
|
|
6141
6141
|
// src/resources/agent-controller.ts
|
|
6142
6142
|
var AgentControllerSession = class extends BaseResource {
|
|
6143
|
-
constructor(options, controllerId, resourceId) {
|
|
6143
|
+
constructor(options, controllerId, resourceId, scope) {
|
|
6144
6144
|
super(options);
|
|
6145
6145
|
this.controllerId = controllerId;
|
|
6146
6146
|
this.resourceId = resourceId;
|
|
6147
|
+
this.scope = scope;
|
|
6147
6148
|
}
|
|
6148
6149
|
controllerId;
|
|
6149
6150
|
resourceId;
|
|
6151
|
+
scope;
|
|
6150
6152
|
base() {
|
|
6151
6153
|
return `/agent-controller/${encodeURIComponent(this.controllerId)}/sessions/${encodeURIComponent(this.resourceId)}`;
|
|
6152
6154
|
}
|
|
6155
|
+
/** Append this session's scope (if any) as a `sessionScope` query param. */
|
|
6156
|
+
url(path) {
|
|
6157
|
+
if (this.scope === void 0) return path;
|
|
6158
|
+
const sep = path.includes("?") ? "&" : "?";
|
|
6159
|
+
return `${path}${sep}sessionScope=${encodeURIComponent(this.scope)}`;
|
|
6160
|
+
}
|
|
6153
6161
|
/**
|
|
6154
6162
|
* Create or resume this session. Pass `tags` to scope initial thread
|
|
6155
6163
|
* selection — a thread is a resume candidate only when its metadata matches
|
|
@@ -6160,7 +6168,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6160
6168
|
create(options) {
|
|
6161
6169
|
return this.request(`/agent-controller/${encodeURIComponent(this.controllerId)}/sessions`, {
|
|
6162
6170
|
method: "POST",
|
|
6163
|
-
body: { resourceId: this.resourceId, tags: options?.tags }
|
|
6171
|
+
body: { resourceId: this.resourceId, tags: options?.tags, sessionScope: this.scope }
|
|
6164
6172
|
});
|
|
6165
6173
|
}
|
|
6166
6174
|
/**
|
|
@@ -6168,7 +6176,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6168
6176
|
* message arrives here as `message_*` events, not on the sendMessage call.
|
|
6169
6177
|
*/
|
|
6170
6178
|
async subscribe(options) {
|
|
6171
|
-
const response = await this.request(`${this.base()}/stream
|
|
6179
|
+
const response = await this.request(this.url(`${this.base()}/stream`), { stream: true });
|
|
6172
6180
|
if (!response.body) {
|
|
6173
6181
|
throw new Error("No response body for agent controller session stream");
|
|
6174
6182
|
}
|
|
@@ -6210,17 +6218,25 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6210
6218
|
}
|
|
6211
6219
|
};
|
|
6212
6220
|
}
|
|
6213
|
-
/**
|
|
6221
|
+
/**
|
|
6222
|
+
* Send a user message. The reply streams over `subscribe()`.
|
|
6223
|
+
* Pass a structured message to attach files (e.g. pasted images) as base64-encoded data:
|
|
6224
|
+
* `sendMessage({ content: 'What is in this image?', files })`.
|
|
6225
|
+
*/
|
|
6214
6226
|
async sendMessage(message) {
|
|
6215
|
-
|
|
6227
|
+
const { content, files } = typeof message === "string" ? { content: message, files: void 0 } : message;
|
|
6228
|
+
await this.request(this.url(`${this.base()}/messages`), {
|
|
6229
|
+
method: "POST",
|
|
6230
|
+
body: { message: content, ...files?.length ? { files } : {} }
|
|
6231
|
+
});
|
|
6216
6232
|
}
|
|
6217
6233
|
/** Abort the in-flight run for this session. */
|
|
6218
6234
|
async abort() {
|
|
6219
|
-
await this.request(`${this.base()}/abort
|
|
6235
|
+
await this.request(this.url(`${this.base()}/abort`), { method: "POST" });
|
|
6220
6236
|
}
|
|
6221
6237
|
/** Approve or decline a pending tool call (`tool_approval_required`). */
|
|
6222
6238
|
async approveTool(toolCallId, approved) {
|
|
6223
|
-
await this.request(`${this.base()}/tool-approval
|
|
6239
|
+
await this.request(this.url(`${this.base()}/tool-approval`), {
|
|
6224
6240
|
method: "POST",
|
|
6225
6241
|
body: { toolCallId, approved }
|
|
6226
6242
|
});
|
|
@@ -6231,35 +6247,34 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6231
6247
|
* `request_access`, and a {@link PlanResume} for `submit_plan`.
|
|
6232
6248
|
*/
|
|
6233
6249
|
async respondToToolSuspension(toolCallId, resumeData) {
|
|
6234
|
-
await this.request(`${this.base()}/tool-suspension
|
|
6250
|
+
await this.request(this.url(`${this.base()}/tool-suspension`), {
|
|
6235
6251
|
method: "POST",
|
|
6236
6252
|
body: { toolCallId, resumeData }
|
|
6237
6253
|
});
|
|
6238
6254
|
}
|
|
6239
6255
|
/** Inject a message into the in-flight run without starting a new turn. */
|
|
6240
6256
|
async steer(message) {
|
|
6241
|
-
await this.request(`${this.base()}/steer
|
|
6257
|
+
await this.request(this.url(`${this.base()}/steer`), { method: "POST", body: { message } });
|
|
6242
6258
|
}
|
|
6243
6259
|
/** Get the current mode, model, and thread (for initial UI hydration). */
|
|
6244
6260
|
state() {
|
|
6245
|
-
return this.request(this.base());
|
|
6261
|
+
return this.request(this.url(this.base()));
|
|
6246
6262
|
}
|
|
6247
6263
|
/** Merge key-value pairs into the session state. Existing keys not in the payload are preserved. */
|
|
6248
6264
|
async setState(updates) {
|
|
6249
|
-
await this.request(`${this.base()}/state
|
|
6265
|
+
await this.request(this.url(`${this.base()}/state`), { method: "PUT", body: { state: updates } });
|
|
6250
6266
|
}
|
|
6251
6267
|
/** Switch the active mode (e.g. `build`, `plan`). */
|
|
6252
6268
|
async switchMode(modeId) {
|
|
6253
|
-
await this.request(`${this.base()}/mode
|
|
6269
|
+
await this.request(this.url(`${this.base()}/mode`), { method: "POST", body: { modeId } });
|
|
6254
6270
|
}
|
|
6255
6271
|
/** Switch the model. Defaults to thread scope. */
|
|
6256
6272
|
async switchModel(modelId, options) {
|
|
6257
|
-
await this.request(`${this.base()}/model
|
|
6273
|
+
await this.request(this.url(`${this.base()}/model`), {
|
|
6258
6274
|
method: "POST",
|
|
6259
6275
|
body: { modelId, scope: options?.scope, modeId: options?.modeId }
|
|
6260
6276
|
});
|
|
6261
6277
|
}
|
|
6262
|
-
/** List the threads for this session's resource, most-recently-updated first. Pass `limit` for just the newest N. */
|
|
6263
6278
|
/**
|
|
6264
6279
|
* List the session's threads, newest first. Pass `limit` to cap the count
|
|
6265
6280
|
* (e.g. for a sidebar) and `tags` to scope to threads matching every tag —
|
|
@@ -6273,36 +6288,38 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6273
6288
|
if (opts.limit != null) params.set("limit", String(opts.limit));
|
|
6274
6289
|
if (opts.tags && Object.keys(opts.tags).length > 0) params.set("tags", JSON.stringify(opts.tags));
|
|
6275
6290
|
const query = params.toString() ? `?${params.toString()}` : "";
|
|
6276
|
-
const body = await this.request(
|
|
6291
|
+
const body = await this.request(
|
|
6292
|
+
this.url(`${this.base()}/threads${query}`)
|
|
6293
|
+
);
|
|
6277
6294
|
return body.threads;
|
|
6278
6295
|
}
|
|
6279
6296
|
/** Switch the session to an existing thread (rebinds stream + state). */
|
|
6280
6297
|
async switchThread(threadId) {
|
|
6281
|
-
await this.request(`${this.base()}/thread
|
|
6298
|
+
await this.request(this.url(`${this.base()}/thread`), { method: "POST", body: { threadId } });
|
|
6282
6299
|
}
|
|
6283
6300
|
/** Create a new thread (unbinds previous, binds the new one). */
|
|
6284
6301
|
async createThread(title) {
|
|
6285
|
-
return this.request(`${this.base()}/threads
|
|
6302
|
+
return this.request(this.url(`${this.base()}/threads`), {
|
|
6286
6303
|
method: "POST",
|
|
6287
6304
|
body: { title }
|
|
6288
6305
|
});
|
|
6289
6306
|
}
|
|
6290
6307
|
/** Delete a thread. If it's the active thread the session unbinds. */
|
|
6291
6308
|
async deleteThread(threadId) {
|
|
6292
|
-
await this.request(`${this.base()}/threads/${encodeURIComponent(threadId)}
|
|
6309
|
+
await this.request(this.url(`${this.base()}/threads/${encodeURIComponent(threadId)}`), {
|
|
6293
6310
|
method: "DELETE"
|
|
6294
6311
|
});
|
|
6295
6312
|
}
|
|
6296
6313
|
/** Rename a thread. */
|
|
6297
6314
|
async renameThread(threadId, title) {
|
|
6298
|
-
await this.request(`${this.base()}/threads/${encodeURIComponent(threadId)}
|
|
6315
|
+
await this.request(this.url(`${this.base()}/threads/${encodeURIComponent(threadId)}`), {
|
|
6299
6316
|
method: "PUT",
|
|
6300
6317
|
body: { title }
|
|
6301
6318
|
});
|
|
6302
6319
|
}
|
|
6303
6320
|
/** Clone a thread (and its messages). The session binds to the clone. */
|
|
6304
6321
|
async cloneThread(options) {
|
|
6305
|
-
return this.request(`${this.base()}/threads/clone
|
|
6322
|
+
return this.request(this.url(`${this.base()}/threads/clone`), {
|
|
6306
6323
|
method: "POST",
|
|
6307
6324
|
body: options ?? {}
|
|
6308
6325
|
});
|
|
@@ -6311,7 +6328,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6311
6328
|
async listMessages(threadId, limit) {
|
|
6312
6329
|
const params = limit != null ? `?limit=${limit}` : "";
|
|
6313
6330
|
const body = await this.request(
|
|
6314
|
-
`${this.base()}/threads/${encodeURIComponent(threadId)}/messages${params}`
|
|
6331
|
+
this.url(`${this.base()}/threads/${encodeURIComponent(threadId)}/messages${params}`)
|
|
6315
6332
|
);
|
|
6316
6333
|
return body.messages;
|
|
6317
6334
|
}
|
|
@@ -6320,33 +6337,33 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6320
6337
|
* if a run is active it queues for after completion.
|
|
6321
6338
|
*/
|
|
6322
6339
|
async followUp(message) {
|
|
6323
|
-
await this.request(`${this.base()}/follow-up
|
|
6340
|
+
await this.request(this.url(`${this.base()}/follow-up`), { method: "POST", body: { message } });
|
|
6324
6341
|
}
|
|
6325
6342
|
/** Get the observational memory record for this session's thread. */
|
|
6326
6343
|
async getOMRecord() {
|
|
6327
|
-
const body = await this.request(`${this.base()}/om`);
|
|
6344
|
+
const body = await this.request(this.url(`${this.base()}/om`));
|
|
6328
6345
|
return body.record;
|
|
6329
6346
|
}
|
|
6330
6347
|
/** Change the session's resource identity. */
|
|
6331
6348
|
async setResourceId(newResourceId) {
|
|
6332
|
-
await this.request(`${this.base()}/resource
|
|
6349
|
+
await this.request(this.url(`${this.base()}/resource`), {
|
|
6333
6350
|
method: "POST",
|
|
6334
6351
|
body: { newResourceId }
|
|
6335
6352
|
});
|
|
6336
6353
|
}
|
|
6337
6354
|
/** Get known resource IDs for this session. */
|
|
6338
6355
|
async getResourceIds() {
|
|
6339
|
-
const body = await this.request(`${this.base()}/resources`);
|
|
6356
|
+
const body = await this.request(this.url(`${this.base()}/resources`));
|
|
6340
6357
|
return body.resourceIds;
|
|
6341
6358
|
}
|
|
6342
6359
|
/** Get the current goal for this session's thread. */
|
|
6343
6360
|
async getGoal() {
|
|
6344
|
-
const body = await this.request(`${this.base()}/goal`);
|
|
6361
|
+
const body = await this.request(this.url(`${this.base()}/goal`));
|
|
6345
6362
|
return body.goal;
|
|
6346
6363
|
}
|
|
6347
6364
|
/** Set a new goal objective. The agent's in-loop judge evaluates progress after each turn. */
|
|
6348
6365
|
async setGoal(objective, options) {
|
|
6349
|
-
const body = await this.request(`${this.base()}/goal
|
|
6366
|
+
const body = await this.request(this.url(`${this.base()}/goal`), {
|
|
6350
6367
|
method: "POST",
|
|
6351
6368
|
body: { objective, ...options }
|
|
6352
6369
|
});
|
|
@@ -6354,7 +6371,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6354
6371
|
}
|
|
6355
6372
|
/** Update goal options (judge model, max runs, status). */
|
|
6356
6373
|
async updateGoal(options) {
|
|
6357
|
-
const body = await this.request(`${this.base()}/goal
|
|
6374
|
+
const body = await this.request(this.url(`${this.base()}/goal`), {
|
|
6358
6375
|
method: "PUT",
|
|
6359
6376
|
body: options
|
|
6360
6377
|
});
|
|
@@ -6362,25 +6379,25 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6362
6379
|
}
|
|
6363
6380
|
/** Clear the current goal. */
|
|
6364
6381
|
async clearGoal() {
|
|
6365
|
-
await this.request(`${this.base()}/goal
|
|
6382
|
+
await this.request(this.url(`${this.base()}/goal`), { method: "DELETE" });
|
|
6366
6383
|
}
|
|
6367
6384
|
// ---------------------------------------------------------------------------
|
|
6368
6385
|
// Permissions
|
|
6369
6386
|
// ---------------------------------------------------------------------------
|
|
6370
6387
|
/** Get the current permission rules (per-category and per-tool policies). */
|
|
6371
6388
|
async getPermissions() {
|
|
6372
|
-
return this.request(`${this.base()}/permissions`);
|
|
6389
|
+
return this.request(this.url(`${this.base()}/permissions`));
|
|
6373
6390
|
}
|
|
6374
6391
|
/** Set the approval policy for a tool category. */
|
|
6375
6392
|
async setPermissionForCategory(category, policy) {
|
|
6376
|
-
await this.request(`${this.base()}/permissions/category
|
|
6393
|
+
await this.request(this.url(`${this.base()}/permissions/category`), {
|
|
6377
6394
|
method: "PUT",
|
|
6378
6395
|
body: { category, policy }
|
|
6379
6396
|
});
|
|
6380
6397
|
}
|
|
6381
6398
|
/** Set the approval policy for a specific tool. */
|
|
6382
6399
|
async setPermissionForTool(toolName, policy) {
|
|
6383
|
-
await this.request(`${this.base()}/permissions/tool
|
|
6400
|
+
await this.request(this.url(`${this.base()}/permissions/tool`), {
|
|
6384
6401
|
method: "PUT",
|
|
6385
6402
|
body: { toolName, policy }
|
|
6386
6403
|
});
|
|
@@ -6391,7 +6408,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6391
6408
|
* or is persisted for later.
|
|
6392
6409
|
*/
|
|
6393
6410
|
async sendNotification(input) {
|
|
6394
|
-
return this.request(`${this.base()}/notifications
|
|
6411
|
+
return this.request(this.url(`${this.base()}/notifications`), {
|
|
6395
6412
|
method: "POST",
|
|
6396
6413
|
body: input
|
|
6397
6414
|
});
|
|
@@ -6420,9 +6437,13 @@ var AgentController = class extends BaseResource {
|
|
|
6420
6437
|
async workspaceStatus() {
|
|
6421
6438
|
return this.request(`${this.basePath()}/workspace`);
|
|
6422
6439
|
}
|
|
6423
|
-
/**
|
|
6424
|
-
|
|
6425
|
-
|
|
6440
|
+
/**
|
|
6441
|
+
* Scope to a session bound to `resourceId` (e.g. a user or conversation id).
|
|
6442
|
+
* Pass `scope` to address an independent session over the same resourceId
|
|
6443
|
+
* (e.g. one session per git worktree, with the worktree path as the scope).
|
|
6444
|
+
*/
|
|
6445
|
+
session(resourceId, scope) {
|
|
6446
|
+
return new AgentControllerSession(this.options, this.controllerId, resourceId, scope);
|
|
6426
6447
|
}
|
|
6427
6448
|
};
|
|
6428
6449
|
function agentControllerMessageText(message) {
|