@mastra/client-js 1.56.0-alpha.7 → 1.56.0-alpha.9
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/client.d.ts +1 -1
- 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 +11 -14
- package/dist/docs/references/docs-harness-schedules.md +8 -6
- package/dist/docs/references/reference-client-js-agent-controller.md +13 -3
- package/dist/docs/references/reference-client-js-mastra-client.md +1 -1
- package/dist/docs/references/reference-client-js-observability.md +3 -3
- package/dist/docs/references/reference-observability-tracing-advanced-queries.md +40 -31
- package/dist/index.cjs +53 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -62
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-controller.d.ts +21 -25
- package/dist/resources/agent-controller.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +604 -594
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +7 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -6800,48 +6800,40 @@ function hydrateEventTimestamps(event) {
|
|
|
6800
6800
|
return isKnownParsedEvent(event) ? hydrateKnownEvent(event) : event;
|
|
6801
6801
|
}
|
|
6802
6802
|
/**
|
|
6803
|
-
* A session
|
|
6804
|
-
* get-or-create on the server, so re-creating the same
|
|
6805
|
-
*
|
|
6806
|
-
*
|
|
6807
|
-
*
|
|
6808
|
-
* two sessions with the same resourceId but different scopes have their own
|
|
6809
|
-
* run loop, thread binding, and mode/model/state (e.g. one session per git
|
|
6810
|
-
* worktree, with the worktree path as the scope). The scope travels on every
|
|
6811
|
-
* request as a `sessionScope` query param.
|
|
6803
|
+
* A session addressed by its `sessionId` within one agent controller. Sessions
|
|
6804
|
+
* are get-or-create on the server, so re-creating the same sessionId resumes
|
|
6805
|
+
* the existing conversation rather than forking it. Many sessions can work on
|
|
6806
|
+
* one `resourceId` (whose threads and memory they use); each has its own run
|
|
6807
|
+
* loop, thread binding, and mode/model/state.
|
|
6812
6808
|
*/
|
|
6813
6809
|
var AgentControllerSession = class extends BaseResource {
|
|
6814
6810
|
controllerId;
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
constructor(options, controllerId, resourceId, scope) {
|
|
6811
|
+
sessionId;
|
|
6812
|
+
constructor(options, controllerId, sessionId) {
|
|
6818
6813
|
super(options);
|
|
6819
6814
|
this.controllerId = controllerId;
|
|
6820
|
-
this.
|
|
6821
|
-
this.scope = scope;
|
|
6815
|
+
this.sessionId = sessionId;
|
|
6822
6816
|
}
|
|
6823
6817
|
base() {
|
|
6824
|
-
return `/agent-controller/${encodeURIComponent(this.controllerId)}/sessions/${encodeURIComponent(this.
|
|
6825
|
-
}
|
|
6826
|
-
/** Append this session's scope (if any) as a `sessionScope` query param. */
|
|
6827
|
-
url(path) {
|
|
6828
|
-
if (this.scope === void 0) return path;
|
|
6829
|
-
return `${path}${path.includes("?") ? "&" : "?"}sessionScope=${encodeURIComponent(this.scope)}`;
|
|
6818
|
+
return `/agent-controller/${encodeURIComponent(this.controllerId)}/sessions/${encodeURIComponent(this.sessionId)}`;
|
|
6830
6819
|
}
|
|
6831
6820
|
/**
|
|
6832
|
-
* Create or resume this session.
|
|
6833
|
-
*
|
|
6834
|
-
*
|
|
6835
|
-
*
|
|
6821
|
+
* Create or resume this session. `resourceId` names whose threads and memory
|
|
6822
|
+
* the session works on. Without it the server resumes the session on the
|
|
6823
|
+
* resource it already has (the live session's, or the resource of the thread
|
|
6824
|
+
* with the session's id), falling back to the sessionId. Pass `tags` to scope
|
|
6825
|
+
* initial thread selection — a thread is a resume candidate only when its
|
|
6826
|
+
* metadata matches every tag. Pass `threadId` to bind the session to one
|
|
6827
|
+
* exact thread, creating it with that id when it does not exist.
|
|
6836
6828
|
*/
|
|
6837
6829
|
create(options) {
|
|
6838
6830
|
return this.request(`/agent-controller/${encodeURIComponent(this.controllerId)}/sessions`, {
|
|
6839
6831
|
method: "POST",
|
|
6840
6832
|
body: {
|
|
6841
|
-
resourceId:
|
|
6833
|
+
resourceId: options?.resourceId,
|
|
6834
|
+
sessionId: this.sessionId,
|
|
6842
6835
|
tags: options?.tags,
|
|
6843
|
-
threadId: options?.threadId
|
|
6844
|
-
sessionScope: this.scope
|
|
6836
|
+
threadId: options?.threadId
|
|
6845
6837
|
}
|
|
6846
6838
|
});
|
|
6847
6839
|
}
|
|
@@ -6897,7 +6889,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
6897
6889
|
const abort = new AbortController();
|
|
6898
6890
|
currentAbort = abort;
|
|
6899
6891
|
let openTimer;
|
|
6900
|
-
const request = this.request(
|
|
6892
|
+
const request = this.request(`${this.base()}/stream`, {
|
|
6901
6893
|
stream: true,
|
|
6902
6894
|
signal: abort.signal
|
|
6903
6895
|
});
|
|
@@ -7107,7 +7099,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7107
7099
|
files: void 0
|
|
7108
7100
|
} : message;
|
|
7109
7101
|
const requestContext = parseClientRequestContext(options?.requestContext);
|
|
7110
|
-
await this.request(
|
|
7102
|
+
await this.request(`${this.base()}/messages`, {
|
|
7111
7103
|
method: "POST",
|
|
7112
7104
|
body: {
|
|
7113
7105
|
message: content,
|
|
@@ -7118,7 +7110,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7118
7110
|
}
|
|
7119
7111
|
/** Abort the in-flight run for this session. */
|
|
7120
7112
|
async abort() {
|
|
7121
|
-
await this.request(
|
|
7113
|
+
await this.request(`${this.base()}/abort`, { method: "POST" });
|
|
7122
7114
|
}
|
|
7123
7115
|
/**
|
|
7124
7116
|
* Approve or decline a pending tool call (`tool_approval_required`). Resolves
|
|
@@ -7126,7 +7118,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7126
7118
|
*/
|
|
7127
7119
|
async approveTool(toolCallId, approved, options) {
|
|
7128
7120
|
const requestContext = parseClientRequestContext(options?.requestContext);
|
|
7129
|
-
return this.request(
|
|
7121
|
+
return this.request(`${this.base()}/tool-approval`, {
|
|
7130
7122
|
method: "POST",
|
|
7131
7123
|
retries: 0,
|
|
7132
7124
|
body: {
|
|
@@ -7144,7 +7136,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7144
7136
|
*/
|
|
7145
7137
|
async respondToToolSuspension(toolCallId, resumeData, options) {
|
|
7146
7138
|
const requestContext = parseClientRequestContext(options?.requestContext);
|
|
7147
|
-
return this.request(
|
|
7139
|
+
return this.request(`${this.base()}/tool-suspension`, {
|
|
7148
7140
|
method: "POST",
|
|
7149
7141
|
retries: 0,
|
|
7150
7142
|
body: {
|
|
@@ -7164,7 +7156,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7164
7156
|
files: void 0
|
|
7165
7157
|
} : message;
|
|
7166
7158
|
const requestContext = parseClientRequestContext(options?.requestContext);
|
|
7167
|
-
await this.request(
|
|
7159
|
+
await this.request(`${this.base()}/steer`, {
|
|
7168
7160
|
method: "POST",
|
|
7169
7161
|
body: {
|
|
7170
7162
|
message: content,
|
|
@@ -7176,18 +7168,18 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7176
7168
|
/** Get the current mode, model, and thread (for initial UI hydration). */
|
|
7177
7169
|
state(options) {
|
|
7178
7170
|
const path = options?.threadId ? `${this.base()}?threadId=${encodeURIComponent(options.threadId)}` : this.base();
|
|
7179
|
-
return this.request(
|
|
7171
|
+
return this.request(path);
|
|
7180
7172
|
}
|
|
7181
7173
|
/** Merge key-value pairs into the session state. Existing keys not in the payload are preserved. */
|
|
7182
7174
|
async setState(updates) {
|
|
7183
|
-
await this.request(
|
|
7175
|
+
await this.request(`${this.base()}/state`, {
|
|
7184
7176
|
method: "PUT",
|
|
7185
7177
|
body: { state: updates }
|
|
7186
7178
|
});
|
|
7187
7179
|
}
|
|
7188
7180
|
/** Switch the active mode (e.g. `build`, `plan`). */
|
|
7189
7181
|
async switchMode(modeId) {
|
|
7190
|
-
await this.request(
|
|
7182
|
+
await this.request(`${this.base()}/mode`, {
|
|
7191
7183
|
method: "POST",
|
|
7192
7184
|
body: { modeId }
|
|
7193
7185
|
});
|
|
@@ -7197,7 +7189,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7197
7189
|
* `thinkingLevel` is provided it is applied and persisted with the model.
|
|
7198
7190
|
*/
|
|
7199
7191
|
async switchModel(modelId, { thinkingLevel } = {}) {
|
|
7200
|
-
await this.request(
|
|
7192
|
+
await this.request(`${this.base()}/model`, {
|
|
7201
7193
|
method: "POST",
|
|
7202
7194
|
body: thinkingLevel !== void 0 ? {
|
|
7203
7195
|
modelId,
|
|
@@ -7218,36 +7210,36 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7218
7210
|
if (opts.limit != null) params.set("limit", String(opts.limit));
|
|
7219
7211
|
if (opts.tags && Object.keys(opts.tags).length > 0) params.set("tags", JSON.stringify(opts.tags));
|
|
7220
7212
|
const query = params.toString() ? `?${params.toString()}` : "";
|
|
7221
|
-
return (await this.request(
|
|
7213
|
+
return (await this.request(`${this.base()}/threads${query}`)).threads;
|
|
7222
7214
|
}
|
|
7223
7215
|
/** Switch the session to an existing thread (rebinds stream + state). */
|
|
7224
7216
|
async switchThread(threadId) {
|
|
7225
|
-
await this.request(
|
|
7217
|
+
await this.request(`${this.base()}/thread`, {
|
|
7226
7218
|
method: "POST",
|
|
7227
7219
|
body: { threadId }
|
|
7228
7220
|
});
|
|
7229
7221
|
}
|
|
7230
7222
|
/** Create a new thread (unbinds previous, binds the new one). */
|
|
7231
7223
|
async createThread(title) {
|
|
7232
|
-
return this.request(
|
|
7224
|
+
return this.request(`${this.base()}/threads`, {
|
|
7233
7225
|
method: "POST",
|
|
7234
7226
|
body: { title }
|
|
7235
7227
|
});
|
|
7236
7228
|
}
|
|
7237
7229
|
/** Delete a thread. If it's the active thread the session unbinds. */
|
|
7238
7230
|
async deleteThread(threadId) {
|
|
7239
|
-
await this.request(
|
|
7231
|
+
await this.request(`${this.base()}/threads/${encodeURIComponent(threadId)}`, { method: "DELETE" });
|
|
7240
7232
|
}
|
|
7241
7233
|
/** Rename a thread. */
|
|
7242
7234
|
async renameThread(threadId, title) {
|
|
7243
|
-
await this.request(
|
|
7235
|
+
await this.request(`${this.base()}/threads/${encodeURIComponent(threadId)}`, {
|
|
7244
7236
|
method: "PUT",
|
|
7245
7237
|
body: { title }
|
|
7246
7238
|
});
|
|
7247
7239
|
}
|
|
7248
7240
|
/** Clone a thread (and its messages). The session binds to the clone. */
|
|
7249
7241
|
async cloneThread(options) {
|
|
7250
|
-
return this.request(
|
|
7242
|
+
return this.request(`${this.base()}/threads/clone`, {
|
|
7251
7243
|
method: "POST",
|
|
7252
7244
|
body: options ?? {}
|
|
7253
7245
|
});
|
|
@@ -7268,7 +7260,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7268
7260
|
if (include) queryParams.set("include", JSON.stringify(include));
|
|
7269
7261
|
}
|
|
7270
7262
|
const query = queryParams.toString();
|
|
7271
|
-
const body = await this.request(
|
|
7263
|
+
const body = await this.request(`${this.base()}/threads/${encodeURIComponent(threadId)}/messages${query ? `?${query}` : ""}`);
|
|
7272
7264
|
const messages = body.messages.map(hydrateMessage);
|
|
7273
7265
|
if (legacy) return messages;
|
|
7274
7266
|
return {
|
|
@@ -7287,7 +7279,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7287
7279
|
files: void 0
|
|
7288
7280
|
} : message;
|
|
7289
7281
|
const requestContext = parseClientRequestContext(options?.requestContext);
|
|
7290
|
-
await this.request(
|
|
7282
|
+
await this.request(`${this.base()}/follow-up`, {
|
|
7291
7283
|
method: "POST",
|
|
7292
7284
|
body: {
|
|
7293
7285
|
message: content,
|
|
@@ -7298,26 +7290,26 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7298
7290
|
}
|
|
7299
7291
|
/** Get the observational memory record for this session's thread. */
|
|
7300
7292
|
async getOMRecord() {
|
|
7301
|
-
return (await this.request(
|
|
7293
|
+
return (await this.request(`${this.base()}/om`)).record;
|
|
7302
7294
|
}
|
|
7303
7295
|
/** Change the session's resource identity. */
|
|
7304
7296
|
async setResourceId(newResourceId) {
|
|
7305
|
-
await this.request(
|
|
7297
|
+
await this.request(`${this.base()}/resource`, {
|
|
7306
7298
|
method: "POST",
|
|
7307
7299
|
body: { newResourceId }
|
|
7308
7300
|
});
|
|
7309
7301
|
}
|
|
7310
7302
|
/** Get known resource IDs for this session. */
|
|
7311
7303
|
async getResourceIds() {
|
|
7312
|
-
return (await this.request(
|
|
7304
|
+
return (await this.request(`${this.base()}/resources`)).resourceIds;
|
|
7313
7305
|
}
|
|
7314
7306
|
/** Get the current goal for this session's thread. */
|
|
7315
7307
|
async getGoal() {
|
|
7316
|
-
return (await this.request(
|
|
7308
|
+
return (await this.request(`${this.base()}/goal`)).goal;
|
|
7317
7309
|
}
|
|
7318
7310
|
/** Set a new goal objective. The agent's in-loop judge evaluates progress after each turn. */
|
|
7319
7311
|
async setGoal(objective, options) {
|
|
7320
|
-
return (await this.request(
|
|
7312
|
+
return (await this.request(`${this.base()}/goal`, {
|
|
7321
7313
|
method: "POST",
|
|
7322
7314
|
body: {
|
|
7323
7315
|
objective,
|
|
@@ -7327,22 +7319,22 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7327
7319
|
}
|
|
7328
7320
|
/** Update goal options (judge model, max runs, status). */
|
|
7329
7321
|
async updateGoal(options) {
|
|
7330
|
-
return (await this.request(
|
|
7322
|
+
return (await this.request(`${this.base()}/goal`, {
|
|
7331
7323
|
method: "PUT",
|
|
7332
7324
|
body: options
|
|
7333
7325
|
})).goal;
|
|
7334
7326
|
}
|
|
7335
7327
|
/** Clear the current goal. */
|
|
7336
7328
|
async clearGoal() {
|
|
7337
|
-
await this.request(
|
|
7329
|
+
await this.request(`${this.base()}/goal`, { method: "DELETE" });
|
|
7338
7330
|
}
|
|
7339
7331
|
/** Get the current permission rules (per-category and per-tool policies). */
|
|
7340
7332
|
async getPermissions() {
|
|
7341
|
-
return this.request(
|
|
7333
|
+
return this.request(`${this.base()}/permissions`);
|
|
7342
7334
|
}
|
|
7343
7335
|
/** Set the approval policy for a tool category. */
|
|
7344
7336
|
async setPermissionForCategory(category, policy) {
|
|
7345
|
-
await this.request(
|
|
7337
|
+
await this.request(`${this.base()}/permissions/category`, {
|
|
7346
7338
|
method: "PUT",
|
|
7347
7339
|
body: {
|
|
7348
7340
|
category,
|
|
@@ -7352,7 +7344,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7352
7344
|
}
|
|
7353
7345
|
/** Set the approval policy for a specific tool. */
|
|
7354
7346
|
async setPermissionForTool(toolName, policy) {
|
|
7355
|
-
await this.request(
|
|
7347
|
+
await this.request(`${this.base()}/permissions/tool`, {
|
|
7356
7348
|
method: "PUT",
|
|
7357
7349
|
body: {
|
|
7358
7350
|
toolName,
|
|
@@ -7366,7 +7358,7 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
7366
7358
|
* or is persisted for later.
|
|
7367
7359
|
*/
|
|
7368
7360
|
async sendNotification(input) {
|
|
7369
|
-
return this.request(
|
|
7361
|
+
return this.request(`${this.base()}/notifications`, {
|
|
7370
7362
|
method: "POST",
|
|
7371
7363
|
body: input
|
|
7372
7364
|
});
|
|
@@ -7399,12 +7391,11 @@ var AgentController = class extends BaseResource {
|
|
|
7399
7391
|
return this.request(`${this.basePath()}/workspace`);
|
|
7400
7392
|
}
|
|
7401
7393
|
/**
|
|
7402
|
-
*
|
|
7403
|
-
*
|
|
7404
|
-
* (e.g. one session per git worktree, with the worktree path as the scope).
|
|
7394
|
+
* Address the session with this `sessionId`. Sessions created without an
|
|
7395
|
+
* explicit id are addressed by their `resourceId`.
|
|
7405
7396
|
*/
|
|
7406
|
-
session(
|
|
7407
|
-
return new AgentControllerSession(this.options, this.controllerId,
|
|
7397
|
+
session(sessionId) {
|
|
7398
|
+
return new AgentControllerSession(this.options, this.controllerId, sessionId);
|
|
7408
7399
|
}
|
|
7409
7400
|
};
|
|
7410
7401
|
/** Pull the plain text out of an assistant message's nested content parts. */
|
|
@@ -7478,7 +7469,7 @@ var MastraClient = class extends BaseResource {
|
|
|
7478
7469
|
}
|
|
7479
7470
|
/**
|
|
7480
7471
|
* Scopes to an agent controller hosted on the connected Mastra instance. Use
|
|
7481
|
-
* `getAgentController(id).session(
|
|
7472
|
+
* `getAgentController(id).session(sessionId)` to create/resume a session,
|
|
7482
7473
|
* stream its events, and send messages.
|
|
7483
7474
|
* @param controllerId - The id the agent controller is registered under on Mastra
|
|
7484
7475
|
*/
|