@mastra/server 1.79.0-alpha.8 → 1.79.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/{api-schema-manifest-CXiWNHBm.js → api-schema-manifest-CWRIJP-B.js} +2 -2
- package/dist/{api-schema-manifest-CXiWNHBm.js.map → api-schema-manifest-CWRIJP-B.js.map} +1 -1
- package/dist/{api-schema-manifest-Cs2cYG-m.cjs → api-schema-manifest-DUseI2VG.cjs} +2 -2
- package/dist/{api-schema-manifest-Cs2cYG-m.cjs.map → api-schema-manifest-DUseI2VG.cjs.map} +1 -1
- package/dist/{dist-BGzSzjTX.cjs → dist-9c3PXXpk.cjs} +100 -7
- package/dist/{dist-BGzSzjTX.cjs.map → dist-9c3PXXpk.cjs.map} +1 -1
- package/dist/{dist-BeXd4jq2.js → dist-DGCnbhNe.js} +100 -7
- package/dist/{dist-BeXd4jq2.js.map → dist-DGCnbhNe.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-guides-mcp-authentication-authorization.md +2 -2
- package/dist/docs/references/reference-observability-tracing-advanced-queries.md +11 -9
- package/dist/{observability-new-endpoints-outfOdc8.cjs → observability-new-endpoints-AMp9bnMV.cjs} +4 -4
- package/dist/observability-new-endpoints-AMp9bnMV.cjs.map +1 -0
- package/dist/{observability-new-endpoints-7wGwP3se.js → observability-new-endpoints-BU8JYPfh.js} +5 -5
- package/dist/{observability-new-endpoints-7wGwP3se.js.map → observability-new-endpoints-BU8JYPfh.js.map} +1 -1
- package/dist/{routes-gZRBp2vK.cjs → routes-DPojsNf1.cjs} +2 -2
- package/dist/{routes-gZRBp2vK.cjs.map → routes-DPojsNf1.cjs.map} +1 -1
- package/dist/{routes-BYcXmjX3.js → routes-rwufkyUe.js} +2 -2
- package/dist/{routes-BYcXmjX3.js.map → routes-rwufkyUe.js.map} +1 -1
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-controller.cjs +190 -170
- package/dist/server/handlers/agent-controller.cjs.map +1 -1
- package/dist/server/handlers/agent-controller.d.ts +165 -155
- package/dist/server/handlers/agent-controller.d.ts.map +1 -1
- package/dist/server/handlers/agent-controller.js +190 -170
- package/dist/server/handlers/agent-controller.js.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +8 -0
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +1 -1
- package/dist/server/handlers/observability-shared.cjs +31 -21
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +9 -4
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +31 -20
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability.cjs +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/system.cjs +2 -2
- package/dist/server/handlers/system.d.ts +4 -0
- package/dist/server/handlers/system.d.ts.map +1 -1
- package/dist/server/handlers/system.js +2 -2
- package/dist/server/schemas/index.cjs +1 -1
- package/dist/server/schemas/index.js +1 -1
- package/dist/server/schemas/system.d.ts +4 -0
- package/dist/server/schemas/system.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +4 -0
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/system.d.ts +4 -0
- package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
- package/dist/{system-DvpPWdIa.cjs → system-BvpFMIJB.cjs} +3 -1
- package/dist/system-BvpFMIJB.cjs.map +1 -0
- package/dist/{system-BLcPGYXT.js → system-CpzPxRRq.js} +3 -1
- package/dist/system-CpzPxRRq.js.map +1 -0
- package/package.json +6 -6
- package/dist/observability-new-endpoints-outfOdc8.cjs.map +0 -1
- package/dist/system-BLcPGYXT.js.map +0 -1
- package/dist/system-DvpPWdIa.cjs.map +0 -1
|
@@ -15,8 +15,9 @@ let zod_v4 = require("zod/v4");
|
|
|
15
15
|
* `new Mastra({ agentControllers })`) exposes its sessions over HTTP so
|
|
16
16
|
* non-terminal clients — e.g. a browser-based MastraCode — can create sessions,
|
|
17
17
|
* send messages, stream events, and drive run-control. Each route resolves its
|
|
18
|
-
* target AgentController by id, then operates on
|
|
19
|
-
* `
|
|
18
|
+
* target AgentController by id, then operates on the session addressed by
|
|
19
|
+
* `sessionId` (which works on the threads and memory of its `resourceId`).
|
|
20
|
+
* Mutating routes use get-or-create resolution so reconnects
|
|
20
21
|
* resume rather than fork the conversation; read routes only inspect existing
|
|
21
22
|
* live sessions.
|
|
22
23
|
*/
|
|
@@ -64,54 +65,50 @@ function getAgentControllerOrThrow(mastra, controllerId) {
|
|
|
64
65
|
return controller;
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
68
|
+
* The resource of the session addressed by `sessionId`, without materializing
|
|
69
|
+
* it: the live session's resource, else the resource of the thread sharing the
|
|
70
|
+
* session's id, else `sessionId` itself (the default when a session is created
|
|
71
|
+
* without a `sessionId`).
|
|
69
72
|
*/
|
|
70
|
-
async function
|
|
71
|
-
await controller.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return controller.createSession({
|
|
75
|
-
resourceId,
|
|
76
|
-
id,
|
|
77
|
-
ownerId: controller.id,
|
|
78
|
-
tags,
|
|
79
|
-
scope,
|
|
80
|
-
threadId,
|
|
81
|
-
requestContext
|
|
82
|
-
});
|
|
73
|
+
async function resolveSessionResourceId(controller, sessionId) {
|
|
74
|
+
const live = await controller.getSession(sessionId);
|
|
75
|
+
if (live) return live.identity.getResourceId();
|
|
76
|
+
return (await controller.queryThreadById({ threadId: sessionId }))?.resourceId ?? sessionId;
|
|
83
77
|
}
|
|
84
78
|
/**
|
|
85
|
-
* Resolve the session every other
|
|
86
|
-
*
|
|
87
|
-
*
|
|
79
|
+
* Resolve the session addressed by `sessionId` that every route other than create acts on: the live one, or a
|
|
80
|
+
* lost one (e.g. after a restart) rebuilt from storage. When a thread with the session's id exists, the session
|
|
81
|
+
* resumes on that thread under the thread's resource (hosts that use `sessionId === threadId` recover their own
|
|
82
|
+
* thread even when many sessions share one resource); otherwise it resumes on `resourceId = sessionId`, the
|
|
83
|
+
* default `POST /sessions` applies when no `sessionId` is sent. Never starts a conversation, so a write that
|
|
84
|
+
* arrives before the session was started fails instead of landing on a thread nobody reads.
|
|
88
85
|
*/
|
|
89
|
-
async function getSession(controller,
|
|
86
|
+
async function getSession(controller, sessionId, requestContext) {
|
|
90
87
|
await controller.init();
|
|
91
|
-
const
|
|
92
|
-
const
|
|
88
|
+
const live = await controller.getSession(sessionId);
|
|
89
|
+
const thread = live ? null : await controller.queryThreadById({ threadId: sessionId });
|
|
93
90
|
try {
|
|
94
91
|
return await controller.createSession({
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
id: sessionId,
|
|
93
|
+
resourceId: live?.identity.getResourceId() ?? thread?.resourceId ?? sessionId,
|
|
97
94
|
ownerId: controller.id,
|
|
98
|
-
|
|
95
|
+
threadId: thread ? sessionId : void 0,
|
|
99
96
|
resumeOnly: true,
|
|
100
97
|
requestContext
|
|
101
98
|
});
|
|
102
99
|
} catch (error) {
|
|
103
100
|
if (error instanceof Error && error.code === "SESSION_NOT_STARTED") throw new require_http_exception.HTTPException(404, {
|
|
104
|
-
message: `No session has been started
|
|
101
|
+
message: `No session "${sessionId}" has been started. Create it with POST /agent-controller/:controllerId/sessions first.`,
|
|
105
102
|
cause: error
|
|
106
103
|
});
|
|
107
104
|
throw error;
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
|
-
async function getExistingSession(controller,
|
|
107
|
+
async function getExistingSession(controller, sessionId, requestContext) {
|
|
111
108
|
await controller.init();
|
|
112
|
-
const session = await controller.
|
|
109
|
+
const session = await controller.getSession(sessionId, requestContext);
|
|
113
110
|
if (session) return session;
|
|
114
|
-
return getSession(controller,
|
|
111
|
+
return getSession(controller, sessionId, requestContext);
|
|
115
112
|
}
|
|
116
113
|
/**
|
|
117
114
|
* Acknowledges a session operation that keeps running after the response is
|
|
@@ -148,22 +145,29 @@ function ackBackgroundSessionWork({ work, session, mastra, operation }) {
|
|
|
148
145
|
const controllerIdPathParams = zod_v4.z.object({ controllerId: zod_v4.z.string() });
|
|
149
146
|
const sessionPathParams = zod_v4.z.object({
|
|
150
147
|
controllerId: zod_v4.z.string(),
|
|
151
|
-
|
|
148
|
+
sessionId: zod_v4.z.string()
|
|
152
149
|
});
|
|
153
150
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* sessions (e.g. one per git worktree). Sent as a `sessionScope` query param
|
|
157
|
-
* on session routes; named to avoid colliding with the model-switch `scope`.
|
|
151
|
+
* Sessions used to be addressed by `resourceId` plus `sessionScope`. The param is gone: reject it
|
|
152
|
+
* rather than drop it, so an older client's scoped session can't quietly merge into another one.
|
|
158
153
|
*/
|
|
159
|
-
const
|
|
160
|
-
const
|
|
154
|
+
const removedSessionScope = zod_v4.z.never({ error: "sessionScope was removed; address the session by sessionId" }).optional();
|
|
155
|
+
const sessionQuerySchema = zod_v4.z.object({ sessionScope: removedSessionScope });
|
|
156
|
+
const sessionStateQuerySchema = sessionQuerySchema.extend({ threadId: zod_v4.z.string().optional() });
|
|
161
157
|
const createSessionBodySchema = zod_v4.z.object({
|
|
162
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Whose threads and memory the session works on. Optional when `sessionId` is
|
|
160
|
+
* sent: the session then resumes on the resource it already has (the live
|
|
161
|
+
* session's, or the resource of the thread with the session's id), falling
|
|
162
|
+
* back to the session id.
|
|
163
|
+
*/
|
|
164
|
+
resourceId: zod_v4.z.string().optional(),
|
|
165
|
+
/** Address of the session. Defaults to `resourceId`. */
|
|
166
|
+
sessionId: zod_v4.z.string().optional(),
|
|
167
|
+
sessionScope: removedSessionScope,
|
|
163
168
|
tags: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.string()).optional(),
|
|
164
|
-
threadId: zod_v4.z.string().optional()
|
|
165
|
-
|
|
166
|
-
});
|
|
169
|
+
threadId: zod_v4.z.string().optional()
|
|
170
|
+
}).refine((body) => body.resourceId !== void 0 || body.sessionId !== void 0, { message: "resourceId or sessionId is required" });
|
|
167
171
|
const MAX_FILE_DATA_LENGTH = 14 * 1024 * 1024;
|
|
168
172
|
const MAX_TOTAL_FILE_DATA_LENGTH = 28 * 1024 * 1024;
|
|
169
173
|
/**
|
|
@@ -225,7 +229,7 @@ const createThreadBodySchema = zod_v4.z.object({ title: zod_v4.z.string().option
|
|
|
225
229
|
const renameThreadBodySchema = zod_v4.z.object({ title: zod_v4.z.string() });
|
|
226
230
|
const threadPathParams = zod_v4.z.object({
|
|
227
231
|
controllerId: zod_v4.z.string(),
|
|
228
|
-
|
|
232
|
+
sessionId: zod_v4.z.string(),
|
|
229
233
|
threadId: zod_v4.z.string()
|
|
230
234
|
});
|
|
231
235
|
const cloneThreadBodySchema = zod_v4.z.object({
|
|
@@ -234,14 +238,14 @@ const cloneThreadBodySchema = zod_v4.z.object({
|
|
|
234
238
|
});
|
|
235
239
|
const controllerPaginationNumber = zod_v4.z.coerce.number().int().min(0);
|
|
236
240
|
const listMessagesQuerySchema = zod_v4.z.object({
|
|
241
|
+
sessionScope: removedSessionScope,
|
|
237
242
|
/** @deprecated Use page and perPage instead. */
|
|
238
243
|
limit: controllerPaginationNumber.optional(),
|
|
239
244
|
page: controllerPaginationNumber.optional(),
|
|
240
245
|
perPage: zod_v4.z.preprocess((value) => value === "false" ? false : value, zod_v4.z.union([zod_v4.z.literal(false), controllerPaginationNumber])).optional(),
|
|
241
246
|
orderBy: require_memory.messageOrderBySchema,
|
|
242
247
|
include: require_memory.includeSchema,
|
|
243
|
-
filter: require_memory.filterSchema
|
|
244
|
-
sessionScope: zod_v4.z.string().optional()
|
|
248
|
+
filter: require_memory.filterSchema
|
|
245
249
|
}).superRefine((value, ctx) => {
|
|
246
250
|
if (value.limit === void 0) return;
|
|
247
251
|
for (const field of [
|
|
@@ -262,8 +266,8 @@ const listMessagesQuerySchema = zod_v4.z.object({
|
|
|
262
266
|
* only their own threads. Malformed JSON is treated as "no filter".
|
|
263
267
|
*/
|
|
264
268
|
const listThreadsQuerySchema = zod_v4.z.object({
|
|
269
|
+
sessionScope: removedSessionScope,
|
|
265
270
|
limit: zod_v4.z.coerce.number().optional(),
|
|
266
|
-
sessionScope: zod_v4.z.string().optional(),
|
|
267
271
|
tags: zod_v4.z.preprocess((value) => {
|
|
268
272
|
if (typeof value !== "string" || value.length === 0) return void 0;
|
|
269
273
|
try {
|
|
@@ -298,6 +302,7 @@ const sendNotificationBodySchema = zod_v4.z.object({
|
|
|
298
302
|
const listAgentControllersResponseSchema = zod_v4.z.object({ agentControllers: zod_v4.z.array(zod_v4.z.object({ id: zod_v4.z.string() })) });
|
|
299
303
|
const createSessionResponseSchema = zod_v4.z.object({
|
|
300
304
|
controllerId: zod_v4.z.string(),
|
|
305
|
+
sessionId: zod_v4.z.string(),
|
|
301
306
|
resourceId: zod_v4.z.string(),
|
|
302
307
|
threadId: zod_v4.z.string().optional()
|
|
303
308
|
});
|
|
@@ -373,6 +378,7 @@ const taskSnapshotSchema = zod_v4.z.object({
|
|
|
373
378
|
});
|
|
374
379
|
const sessionStateResponseSchema = zod_v4.z.object({
|
|
375
380
|
controllerId: zod_v4.z.string(),
|
|
381
|
+
sessionId: zod_v4.z.string(),
|
|
376
382
|
resourceId: zod_v4.z.string(),
|
|
377
383
|
threadId: zod_v4.z.string().optional(),
|
|
378
384
|
modeId: zod_v4.z.string(),
|
|
@@ -489,25 +495,34 @@ const LIST_AGENT_CONTROLLERS_ROUTE = require_route_builder.createRoute({
|
|
|
489
495
|
const CREATE_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRoute({
|
|
490
496
|
method: "POST",
|
|
491
497
|
path: "/agent-controller/:controllerId/sessions",
|
|
498
|
+
queryParamSchema: sessionQuerySchema,
|
|
492
499
|
responseType: "json",
|
|
493
500
|
pathParamSchema: controllerIdPathParams,
|
|
494
501
|
bodySchema: createSessionBodySchema,
|
|
495
502
|
responseSchema: createSessionResponseSchema,
|
|
496
503
|
summary: "Create or resume a controller session",
|
|
497
|
-
description: "Creates
|
|
504
|
+
description: "Creates the session addressed by `sessionId` on the given resourceId, or returns the existing one (get-or-create), so reconnects resume the conversation. Without a `sessionId` the session is addressed by `resourceId`; without a `resourceId` it resumes on the resource it already has. Every other session route requires a started session and returns 404 until one exists or can be recovered from a stored thread.",
|
|
498
505
|
tags: ["AgentController"],
|
|
499
506
|
requiresAuth: true,
|
|
500
507
|
requiresPermission: "agent-controller:execute",
|
|
501
|
-
handler: async ({ mastra, controllerId, resourceId,
|
|
508
|
+
handler: async ({ mastra, controllerId, resourceId, sessionId, tags, threadId, requestContext }) => {
|
|
502
509
|
try {
|
|
510
|
+
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
511
|
+
await controller.init();
|
|
512
|
+
const id = sessionId ?? resourceId;
|
|
513
|
+
const session = await controller.createSession({
|
|
514
|
+
id,
|
|
515
|
+
resourceId: resourceId ?? await resolveSessionResourceId(controller, id),
|
|
516
|
+
ownerId: controller.id,
|
|
517
|
+
tags,
|
|
518
|
+
threadId,
|
|
519
|
+
requestContext
|
|
520
|
+
});
|
|
503
521
|
return {
|
|
504
522
|
controllerId,
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
scope: sessionScope,
|
|
509
|
-
threadId
|
|
510
|
-
}, requestContext)).thread.getId() ?? void 0
|
|
523
|
+
sessionId: session.identity.getId(),
|
|
524
|
+
resourceId: session.identity.getResourceId(),
|
|
525
|
+
threadId: session.thread.getId() ?? void 0
|
|
511
526
|
};
|
|
512
527
|
} catch (error) {
|
|
513
528
|
return require_server_handlers_error.handleError(error, "error creating controller session");
|
|
@@ -554,20 +569,20 @@ function toWireEvent(event) {
|
|
|
554
569
|
}
|
|
555
570
|
const STREAM_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRoute({
|
|
556
571
|
method: "GET",
|
|
557
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
572
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/stream",
|
|
573
|
+
queryParamSchema: sessionQuerySchema,
|
|
558
574
|
responseType: "stream",
|
|
559
575
|
streamFormat: "sse",
|
|
560
576
|
sseFlushOnConnect: true,
|
|
561
577
|
pathParamSchema: sessionPathParams,
|
|
562
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
563
578
|
summary: "Stream controller session events",
|
|
564
579
|
description: "Subscribes to a session’s event bus and streams events to the client over SSE.",
|
|
565
580
|
tags: ["AgentController", "Streaming"],
|
|
566
581
|
requiresAuth: true,
|
|
567
582
|
requiresPermission: "agent-controller:read",
|
|
568
|
-
handler: async ({ mastra, controllerId,
|
|
583
|
+
handler: async ({ mastra, controllerId, sessionId, abortSignal, requestContext }) => {
|
|
569
584
|
try {
|
|
570
|
-
const session = await getExistingSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
585
|
+
const session = await getExistingSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext);
|
|
571
586
|
let cleanedUp = false;
|
|
572
587
|
let heartbeat;
|
|
573
588
|
let unsubscribe;
|
|
@@ -636,10 +651,10 @@ const STREAM_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRoute(
|
|
|
636
651
|
});
|
|
637
652
|
const SEND_AGENT_CONTROLLER_MESSAGE_ROUTE = require_route_builder.createRoute({
|
|
638
653
|
method: "POST",
|
|
639
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
654
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/messages",
|
|
655
|
+
queryParamSchema: sessionQuerySchema,
|
|
640
656
|
responseType: "json",
|
|
641
657
|
pathParamSchema: sessionPathParams,
|
|
642
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
643
658
|
bodySchema: sendMessageBodySchema,
|
|
644
659
|
responseSchema: ackResponseSchema,
|
|
645
660
|
summary: "Send a message to a controller session",
|
|
@@ -647,9 +662,9 @@ const SEND_AGENT_CONTROLLER_MESSAGE_ROUTE = require_route_builder.createRoute({
|
|
|
647
662
|
tags: ["AgentController", "Streaming"],
|
|
648
663
|
requiresAuth: true,
|
|
649
664
|
requiresPermission: "agent-controller:execute",
|
|
650
|
-
handler: async ({ mastra, controllerId,
|
|
665
|
+
handler: async ({ mastra, controllerId, sessionId, message, files, requestContext }) => {
|
|
651
666
|
try {
|
|
652
|
-
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
667
|
+
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext);
|
|
653
668
|
const author = getRequestMessageAuthor(requestContext);
|
|
654
669
|
ackBackgroundSessionWork({
|
|
655
670
|
work: session.sendMessage({
|
|
@@ -670,19 +685,19 @@ const SEND_AGENT_CONTROLLER_MESSAGE_ROUTE = require_route_builder.createRoute({
|
|
|
670
685
|
});
|
|
671
686
|
const ABORT_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRoute({
|
|
672
687
|
method: "POST",
|
|
673
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
688
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/abort",
|
|
689
|
+
queryParamSchema: sessionQuerySchema,
|
|
674
690
|
responseType: "json",
|
|
675
691
|
pathParamSchema: sessionPathParams,
|
|
676
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
677
692
|
responseSchema: ackResponseSchema,
|
|
678
693
|
summary: "Abort a controller session run",
|
|
679
694
|
description: "Aborts the in-flight run for the session, if any.",
|
|
680
695
|
tags: ["AgentController"],
|
|
681
696
|
requiresAuth: true,
|
|
682
697
|
requiresPermission: "agent-controller:execute",
|
|
683
|
-
handler: async ({ mastra, controllerId,
|
|
698
|
+
handler: async ({ mastra, controllerId, sessionId, requestContext }) => {
|
|
684
699
|
try {
|
|
685
|
-
(await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
700
|
+
(await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).abort();
|
|
686
701
|
return { ok: true };
|
|
687
702
|
} catch (error) {
|
|
688
703
|
return require_server_handlers_error.handleError(error, "error aborting controller session");
|
|
@@ -691,10 +706,10 @@ const ABORT_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRoute({
|
|
|
691
706
|
});
|
|
692
707
|
const AGENT_CONTROLLER_TOOL_APPROVAL_ROUTE = require_route_builder.createRoute({
|
|
693
708
|
method: "POST",
|
|
694
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
709
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/tool-approval",
|
|
710
|
+
queryParamSchema: sessionQuerySchema,
|
|
695
711
|
responseType: "json",
|
|
696
712
|
pathParamSchema: sessionPathParams,
|
|
697
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
698
713
|
bodySchema: toolApprovalBodySchema,
|
|
699
714
|
responseSchema: toolCommandAckResponseSchema,
|
|
700
715
|
summary: "Respond to a controller tool approval",
|
|
@@ -702,9 +717,9 @@ const AGENT_CONTROLLER_TOOL_APPROVAL_ROUTE = require_route_builder.createRoute({
|
|
|
702
717
|
tags: ["AgentController"],
|
|
703
718
|
requiresAuth: true,
|
|
704
719
|
requiresPermission: "agent-controller:execute",
|
|
705
|
-
handler: async ({ mastra, controllerId,
|
|
720
|
+
handler: async ({ mastra, controllerId, sessionId, toolCallId, approved, alwaysAllowCategory, requestContext }) => {
|
|
706
721
|
try {
|
|
707
|
-
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
722
|
+
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext);
|
|
708
723
|
if ((toolCallId ? session.approval.isArmed({ toolCallId }) : session.approval.isArmed()) || !toolCallId) {
|
|
709
724
|
const result = session.respondToToolApproval({
|
|
710
725
|
toolCallId,
|
|
@@ -744,10 +759,10 @@ const AGENT_CONTROLLER_TOOL_APPROVAL_ROUTE = require_route_builder.createRoute({
|
|
|
744
759
|
});
|
|
745
760
|
const AGENT_CONTROLLER_TOOL_SUSPENSION_ROUTE = require_route_builder.createRoute({
|
|
746
761
|
method: "POST",
|
|
747
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
762
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/tool-suspension",
|
|
763
|
+
queryParamSchema: sessionQuerySchema,
|
|
748
764
|
responseType: "json",
|
|
749
765
|
pathParamSchema: sessionPathParams,
|
|
750
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
751
766
|
bodySchema: toolSuspensionBodySchema,
|
|
752
767
|
responseSchema: toolCommandAckResponseSchema,
|
|
753
768
|
summary: "Respond to a suspended controller tool",
|
|
@@ -755,9 +770,9 @@ const AGENT_CONTROLLER_TOOL_SUSPENSION_ROUTE = require_route_builder.createRoute
|
|
|
755
770
|
tags: ["AgentController"],
|
|
756
771
|
requiresAuth: true,
|
|
757
772
|
requiresPermission: "agent-controller:execute",
|
|
758
|
-
handler: async ({ mastra, controllerId,
|
|
773
|
+
handler: async ({ mastra, controllerId, sessionId, toolCallId, runId, resumeData, requestContext }) => {
|
|
759
774
|
try {
|
|
760
|
-
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
775
|
+
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext);
|
|
761
776
|
const claim = session.claimToolSuspension(toolCallId, runId);
|
|
762
777
|
if (!claim.accepted) return {
|
|
763
778
|
ok: false,
|
|
@@ -781,10 +796,10 @@ const AGENT_CONTROLLER_TOOL_SUSPENSION_ROUTE = require_route_builder.createRoute
|
|
|
781
796
|
});
|
|
782
797
|
const STEER_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRoute({
|
|
783
798
|
method: "POST",
|
|
784
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
799
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/steer",
|
|
800
|
+
queryParamSchema: sessionQuerySchema,
|
|
785
801
|
responseType: "json",
|
|
786
802
|
pathParamSchema: sessionPathParams,
|
|
787
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
788
803
|
bodySchema: steerBodySchema,
|
|
789
804
|
responseSchema: ackResponseSchema,
|
|
790
805
|
summary: "Steer the in-flight run",
|
|
@@ -792,9 +807,9 @@ const STEER_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRoute({
|
|
|
792
807
|
tags: ["AgentController"],
|
|
793
808
|
requiresAuth: true,
|
|
794
809
|
requiresPermission: "agent-controller:execute",
|
|
795
|
-
handler: async ({ mastra, controllerId,
|
|
810
|
+
handler: async ({ mastra, controllerId, sessionId, message, files, requestContext }) => {
|
|
796
811
|
try {
|
|
797
|
-
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
812
|
+
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext);
|
|
798
813
|
const author = getRequestMessageAuthor(requestContext);
|
|
799
814
|
ackBackgroundSessionWork({
|
|
800
815
|
work: session.steer({
|
|
@@ -815,10 +830,10 @@ const STEER_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRoute({
|
|
|
815
830
|
});
|
|
816
831
|
const SWITCH_AGENT_CONTROLLER_MODE_ROUTE = require_route_builder.createRoute({
|
|
817
832
|
method: "POST",
|
|
818
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
833
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/mode",
|
|
834
|
+
queryParamSchema: sessionQuerySchema,
|
|
819
835
|
responseType: "json",
|
|
820
836
|
pathParamSchema: sessionPathParams,
|
|
821
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
822
837
|
bodySchema: switchModeBodySchema,
|
|
823
838
|
responseSchema: ackResponseSchema,
|
|
824
839
|
summary: "Switch the session mode",
|
|
@@ -826,9 +841,9 @@ const SWITCH_AGENT_CONTROLLER_MODE_ROUTE = require_route_builder.createRoute({
|
|
|
826
841
|
tags: ["AgentController"],
|
|
827
842
|
requiresAuth: true,
|
|
828
843
|
requiresPermission: "agent-controller:execute",
|
|
829
|
-
handler: async ({ mastra, controllerId,
|
|
844
|
+
handler: async ({ mastra, controllerId, sessionId, modeId, requestContext }) => {
|
|
830
845
|
try {
|
|
831
|
-
await (await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
846
|
+
await (await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).mode.switch({ modeId });
|
|
832
847
|
return { ok: true };
|
|
833
848
|
} catch (error) {
|
|
834
849
|
return require_server_handlers_error.handleError(error, "error switching controller mode");
|
|
@@ -837,10 +852,10 @@ const SWITCH_AGENT_CONTROLLER_MODE_ROUTE = require_route_builder.createRoute({
|
|
|
837
852
|
});
|
|
838
853
|
const SWITCH_AGENT_CONTROLLER_MODEL_ROUTE = require_route_builder.createRoute({
|
|
839
854
|
method: "POST",
|
|
840
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
855
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/model",
|
|
856
|
+
queryParamSchema: sessionQuerySchema,
|
|
841
857
|
responseType: "json",
|
|
842
858
|
pathParamSchema: sessionPathParams,
|
|
843
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
844
859
|
bodySchema: switchModelBodySchema,
|
|
845
860
|
responseSchema: ackResponseSchema,
|
|
846
861
|
summary: "Switch the session model",
|
|
@@ -848,9 +863,9 @@ const SWITCH_AGENT_CONTROLLER_MODEL_ROUTE = require_route_builder.createRoute({
|
|
|
848
863
|
tags: ["AgentController"],
|
|
849
864
|
requiresAuth: true,
|
|
850
865
|
requiresPermission: "agent-controller:execute",
|
|
851
|
-
handler: async ({ mastra, controllerId,
|
|
866
|
+
handler: async ({ mastra, controllerId, sessionId, modelId, thinkingLevel, requestContext }) => {
|
|
852
867
|
try {
|
|
853
|
-
await (await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
868
|
+
await (await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).model.switch(modelId, { thinkingLevel });
|
|
854
869
|
return { ok: true };
|
|
855
870
|
} catch (error) {
|
|
856
871
|
return require_server_handlers_error.handleError(error, "error switching controller model");
|
|
@@ -859,10 +874,10 @@ const SWITCH_AGENT_CONTROLLER_MODEL_ROUTE = require_route_builder.createRoute({
|
|
|
859
874
|
});
|
|
860
875
|
const SWITCH_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
861
876
|
method: "POST",
|
|
862
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
877
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/thread",
|
|
878
|
+
queryParamSchema: sessionQuerySchema,
|
|
863
879
|
responseType: "json",
|
|
864
880
|
pathParamSchema: sessionPathParams,
|
|
865
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
866
881
|
bodySchema: switchThreadBodySchema,
|
|
867
882
|
responseSchema: ackResponseSchema,
|
|
868
883
|
summary: "Switch the session thread",
|
|
@@ -870,9 +885,9 @@ const SWITCH_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
|
870
885
|
tags: ["AgentController"],
|
|
871
886
|
requiresAuth: true,
|
|
872
887
|
requiresPermission: "agent-controller:execute",
|
|
873
|
-
handler: async ({ mastra, controllerId,
|
|
888
|
+
handler: async ({ mastra, controllerId, sessionId, threadId, requestContext }) => {
|
|
874
889
|
try {
|
|
875
|
-
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
890
|
+
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext);
|
|
876
891
|
if (session.thread.getId() !== threadId) await session.thread.switch({
|
|
877
892
|
threadId,
|
|
878
893
|
requestContext
|
|
@@ -885,22 +900,23 @@ const SWITCH_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
|
885
900
|
});
|
|
886
901
|
const TRANSFER_AGENT_CONTROLLER_THREAD_OWNERSHIP_ROUTE = require_route_builder.createRoute({
|
|
887
902
|
method: "POST",
|
|
888
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
903
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/threads/:threadId/owner",
|
|
904
|
+
queryParamSchema: sessionQuerySchema,
|
|
889
905
|
responseType: "json",
|
|
890
906
|
pathParamSchema: threadPathParams,
|
|
891
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
892
907
|
responseSchema: transferOwnershipResponseSchema,
|
|
893
908
|
summary: "Take ownership of a thread",
|
|
894
909
|
description: "Transfers ownership of the specified thread to the authenticated user from the request context. The thread must belong to the session's resource, and the caller needs memory write access to it. The session's active thread does not change.",
|
|
895
910
|
tags: ["AgentController", "Threads"],
|
|
896
911
|
requiresAuth: true,
|
|
897
912
|
requiresPermission: "agent-controller:execute",
|
|
898
|
-
handler: async ({ mastra, controllerId,
|
|
913
|
+
handler: async ({ mastra, controllerId, sessionId, threadId, requestContext }) => {
|
|
899
914
|
try {
|
|
900
915
|
const ownerId = getRequestMessageAuthor(requestContext)?.id;
|
|
901
916
|
if (!ownerId) throw new require_http_exception.HTTPException(401, { message: "An authenticated user is required to transfer thread ownership" });
|
|
902
917
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
903
918
|
await controller.init();
|
|
919
|
+
const resourceId = await resolveSessionResourceId(controller, sessionId);
|
|
904
920
|
const thread = await controller.queryThreadById({ threadId });
|
|
905
921
|
if (!thread || thread.resourceId !== resourceId) throw new require_http_exception.HTTPException(404, { message: "Thread not found" });
|
|
906
922
|
await require_utils.enforceThreadAccess({
|
|
@@ -911,7 +927,7 @@ const TRANSFER_AGENT_CONTROLLER_THREAD_OWNERSHIP_ROUTE = require_route_builder.c
|
|
|
911
927
|
effectiveResourceId: resourceId,
|
|
912
928
|
permission: require_utils.MastraFGAPermissions.MEMORY_WRITE
|
|
913
929
|
});
|
|
914
|
-
await (await getSession(controller,
|
|
930
|
+
await (await getSession(controller, sessionId, requestContext)).thread.transferOwnership({
|
|
915
931
|
toOwnerId: ownerId,
|
|
916
932
|
threadId
|
|
917
933
|
});
|
|
@@ -926,7 +942,7 @@ const TRANSFER_AGENT_CONTROLLER_THREAD_OWNERSHIP_ROUTE = require_route_builder.c
|
|
|
926
942
|
});
|
|
927
943
|
const GET_AGENT_CONTROLLER_SESSION_STATE_ROUTE = require_route_builder.createRoute({
|
|
928
944
|
method: "GET",
|
|
929
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
945
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId",
|
|
930
946
|
responseType: "json",
|
|
931
947
|
pathParamSchema: sessionPathParams,
|
|
932
948
|
queryParamSchema: sessionStateQuerySchema,
|
|
@@ -936,9 +952,10 @@ const GET_AGENT_CONTROLLER_SESSION_STATE_ROUTE = require_route_builder.createRou
|
|
|
936
952
|
tags: ["AgentController"],
|
|
937
953
|
requiresAuth: true,
|
|
938
954
|
requiresPermission: "agent-controller:read",
|
|
939
|
-
handler: async ({ mastra, controllerId,
|
|
955
|
+
handler: async ({ mastra, controllerId, sessionId, threadId: requestedThreadId, requestContext }) => {
|
|
940
956
|
try {
|
|
941
|
-
const session = await getExistingSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
957
|
+
const session = await getExistingSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext);
|
|
958
|
+
const resourceId = session.identity.getResourceId();
|
|
942
959
|
const ds = session.displayState.get();
|
|
943
960
|
const threadId = requestedThreadId ?? session.thread.getId() ?? void 0;
|
|
944
961
|
const storage = mastra.getStorage();
|
|
@@ -962,6 +979,7 @@ const GET_AGENT_CONTROLLER_SESSION_STATE_ROUTE = require_route_builder.createRou
|
|
|
962
979
|
const oneOfOptional = (value, allowed) => allowed.includes(value) ? value : void 0;
|
|
963
980
|
return {
|
|
964
981
|
controllerId,
|
|
982
|
+
sessionId: session.identity.getId(),
|
|
965
983
|
resourceId,
|
|
966
984
|
threadId,
|
|
967
985
|
modeId: session.mode.get(),
|
|
@@ -1052,19 +1070,20 @@ const LIST_AGENT_CONTROLLER_ACTIVE_RUNS_ROUTE = require_route_builder.createRout
|
|
|
1052
1070
|
});
|
|
1053
1071
|
const LIST_AGENT_CONTROLLER_THREADS_ROUTE = require_route_builder.createRoute({
|
|
1054
1072
|
method: "GET",
|
|
1055
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1073
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/threads",
|
|
1056
1074
|
responseType: "json",
|
|
1057
1075
|
pathParamSchema: sessionPathParams,
|
|
1058
1076
|
queryParamSchema: listThreadsQuerySchema,
|
|
1059
1077
|
responseSchema: listThreadsResponseSchema,
|
|
1060
1078
|
summary: "List session threads",
|
|
1061
|
-
description: "Lists the
|
|
1079
|
+
description: "Lists every thread of the session’s resource (not only the session’s own threads), most-recently-updated first. Pass `limit` to return only the newest N (e.g. for a sidebar). Pass `tags` (a JSON-encoded object) to scope the list to threads matching every tag — e.g. `{ projectPath }` so git worktrees sharing a resourceId each see only their own threads.",
|
|
1062
1080
|
tags: ["AgentController"],
|
|
1063
1081
|
requiresAuth: true,
|
|
1064
1082
|
requiresPermission: "agent-controller:read",
|
|
1065
|
-
handler: async ({ mastra, controllerId,
|
|
1083
|
+
handler: async ({ mastra, controllerId, sessionId, limit, tags }) => {
|
|
1066
1084
|
try {
|
|
1067
1085
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
1086
|
+
const resourceId = await resolveSessionResourceId(controller, sessionId);
|
|
1068
1087
|
const threads = await controller.queryThreads({ resourceId });
|
|
1069
1088
|
const getTags = (t) => {
|
|
1070
1089
|
const metadata = t.metadata ?? {};
|
|
@@ -1099,10 +1118,10 @@ const LIST_AGENT_CONTROLLER_THREADS_ROUTE = require_route_builder.createRoute({
|
|
|
1099
1118
|
});
|
|
1100
1119
|
const SEND_AGENT_CONTROLLER_NOTIFICATION_ROUTE = require_route_builder.createRoute({
|
|
1101
1120
|
method: "POST",
|
|
1102
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1121
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/notifications",
|
|
1122
|
+
queryParamSchema: sessionQuerySchema,
|
|
1103
1123
|
responseType: "json",
|
|
1104
1124
|
pathParamSchema: sessionPathParams,
|
|
1105
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1106
1125
|
bodySchema: sendNotificationBodySchema,
|
|
1107
1126
|
responseSchema: zod_v4.z.object({
|
|
1108
1127
|
accepted: zod_v4.z.boolean(),
|
|
@@ -1115,9 +1134,9 @@ const SEND_AGENT_CONTROLLER_NOTIFICATION_ROUTE = require_route_builder.createRou
|
|
|
1115
1134
|
tags: ["AgentController"],
|
|
1116
1135
|
requiresAuth: true,
|
|
1117
1136
|
requiresPermission: "agent-controller:execute",
|
|
1118
|
-
handler: async ({ mastra, controllerId,
|
|
1137
|
+
handler: async ({ mastra, controllerId, sessionId, source, kind, summary, priority, payload, sourceId, dedupeKey, coalesceKey, attributes, metadata, requestContext }) => {
|
|
1119
1138
|
try {
|
|
1120
|
-
const result = await (await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1139
|
+
const result = await (await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).sendNotificationSignal({
|
|
1121
1140
|
source,
|
|
1122
1141
|
kind,
|
|
1123
1142
|
summary,
|
|
@@ -1142,10 +1161,10 @@ const SEND_AGENT_CONTROLLER_NOTIFICATION_ROUTE = require_route_builder.createRou
|
|
|
1142
1161
|
});
|
|
1143
1162
|
const CREATE_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
1144
1163
|
method: "POST",
|
|
1145
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1164
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/threads",
|
|
1165
|
+
queryParamSchema: sessionQuerySchema,
|
|
1146
1166
|
responseType: "json",
|
|
1147
1167
|
pathParamSchema: sessionPathParams,
|
|
1148
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1149
1168
|
bodySchema: createThreadBodySchema,
|
|
1150
1169
|
responseSchema: threadResponseSchema,
|
|
1151
1170
|
summary: "Create a new thread",
|
|
@@ -1153,9 +1172,9 @@ const CREATE_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
|
1153
1172
|
tags: ["AgentController", "Threads"],
|
|
1154
1173
|
requiresAuth: true,
|
|
1155
1174
|
requiresPermission: "agent-controller:execute",
|
|
1156
|
-
handler: async ({ mastra, controllerId,
|
|
1175
|
+
handler: async ({ mastra, controllerId, sessionId, title, requestContext }) => {
|
|
1157
1176
|
try {
|
|
1158
|
-
const thread = await (await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1177
|
+
const thread = await (await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).thread.create({
|
|
1159
1178
|
title,
|
|
1160
1179
|
requestContext
|
|
1161
1180
|
});
|
|
@@ -1173,19 +1192,19 @@ const CREATE_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
|
1173
1192
|
});
|
|
1174
1193
|
const DELETE_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
1175
1194
|
method: "DELETE",
|
|
1176
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1195
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/threads/:threadId",
|
|
1196
|
+
queryParamSchema: sessionQuerySchema,
|
|
1177
1197
|
responseType: "json",
|
|
1178
1198
|
pathParamSchema: threadPathParams,
|
|
1179
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1180
1199
|
responseSchema: ackResponseSchema,
|
|
1181
1200
|
summary: "Delete a thread",
|
|
1182
1201
|
description: "Deletes a thread. If the deleted thread is the active one, the session is unbound.",
|
|
1183
1202
|
tags: ["AgentController", "Threads"],
|
|
1184
1203
|
requiresAuth: true,
|
|
1185
1204
|
requiresPermission: "agent-controller:execute",
|
|
1186
|
-
handler: async ({ mastra, controllerId,
|
|
1205
|
+
handler: async ({ mastra, controllerId, sessionId, threadId, requestContext }) => {
|
|
1187
1206
|
try {
|
|
1188
|
-
await (await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1207
|
+
await (await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).thread.delete({
|
|
1189
1208
|
threadId,
|
|
1190
1209
|
requestContext
|
|
1191
1210
|
});
|
|
@@ -1197,10 +1216,10 @@ const DELETE_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
|
1197
1216
|
});
|
|
1198
1217
|
const RENAME_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
1199
1218
|
method: "PUT",
|
|
1200
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1219
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/threads/:threadId",
|
|
1220
|
+
queryParamSchema: sessionQuerySchema,
|
|
1201
1221
|
responseType: "json",
|
|
1202
1222
|
pathParamSchema: threadPathParams,
|
|
1203
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1204
1223
|
bodySchema: renameThreadBodySchema,
|
|
1205
1224
|
responseSchema: ackResponseSchema,
|
|
1206
1225
|
summary: "Rename a thread",
|
|
@@ -1208,9 +1227,9 @@ const RENAME_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
|
1208
1227
|
tags: ["AgentController", "Threads"],
|
|
1209
1228
|
requiresAuth: true,
|
|
1210
1229
|
requiresPermission: "agent-controller:execute",
|
|
1211
|
-
handler: async ({ mastra, controllerId,
|
|
1230
|
+
handler: async ({ mastra, controllerId, sessionId, threadId, title, requestContext }) => {
|
|
1212
1231
|
try {
|
|
1213
|
-
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1232
|
+
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext);
|
|
1214
1233
|
if (session.thread.getId() !== threadId) await session.thread.switch({
|
|
1215
1234
|
threadId,
|
|
1216
1235
|
requestContext
|
|
@@ -1224,10 +1243,10 @@ const RENAME_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
|
1224
1243
|
});
|
|
1225
1244
|
const CLONE_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
1226
1245
|
method: "POST",
|
|
1227
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1246
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/threads/clone",
|
|
1247
|
+
queryParamSchema: sessionQuerySchema,
|
|
1228
1248
|
responseType: "json",
|
|
1229
1249
|
pathParamSchema: sessionPathParams,
|
|
1230
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1231
1250
|
bodySchema: cloneThreadBodySchema,
|
|
1232
1251
|
responseSchema: threadResponseSchema,
|
|
1233
1252
|
summary: "Clone a thread",
|
|
@@ -1235,9 +1254,9 @@ const CLONE_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
|
1235
1254
|
tags: ["AgentController", "Threads"],
|
|
1236
1255
|
requiresAuth: true,
|
|
1237
1256
|
requiresPermission: "agent-controller:execute",
|
|
1238
|
-
handler: async ({ mastra, controllerId,
|
|
1257
|
+
handler: async ({ mastra, controllerId, sessionId, sourceThreadId, title, requestContext }) => {
|
|
1239
1258
|
try {
|
|
1240
|
-
const thread = await (await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1259
|
+
const thread = await (await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).thread.clone({
|
|
1241
1260
|
sourceThreadId,
|
|
1242
1261
|
title,
|
|
1243
1262
|
requestContext
|
|
@@ -1256,7 +1275,7 @@ const CLONE_AGENT_CONTROLLER_THREAD_ROUTE = require_route_builder.createRoute({
|
|
|
1256
1275
|
});
|
|
1257
1276
|
const LIST_AGENT_CONTROLLER_THREAD_MESSAGES_ROUTE = require_route_builder.createRoute({
|
|
1258
1277
|
method: "GET",
|
|
1259
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1278
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/threads/:threadId/messages",
|
|
1260
1279
|
responseType: "json",
|
|
1261
1280
|
pathParamSchema: threadPathParams,
|
|
1262
1281
|
queryParamSchema: listMessagesQuerySchema,
|
|
@@ -1266,12 +1285,13 @@ const LIST_AGENT_CONTROLLER_THREAD_MESSAGES_ROUTE = require_route_builder.create
|
|
|
1266
1285
|
tags: ["AgentController", "Threads"],
|
|
1267
1286
|
requiresAuth: true,
|
|
1268
1287
|
requiresPermission: "agent-controller:read",
|
|
1269
|
-
handler: async ({ mastra, controllerId,
|
|
1288
|
+
handler: async ({ mastra, controllerId, sessionId, threadId, limit, page, perPage, orderBy, include, filter, requestContext }) => {
|
|
1270
1289
|
try {
|
|
1271
1290
|
if (limit !== void 0 && (perPage !== void 0 || orderBy !== void 0 || include !== void 0 || filter !== void 0)) throw new require_http_exception.HTTPException(400, { message: "limit can only be combined with page; use perPage instead" });
|
|
1272
1291
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
1292
|
+
const resourceId = await resolveSessionResourceId(controller, sessionId);
|
|
1273
1293
|
const thread = await controller.queryThreadById({ threadId });
|
|
1274
|
-
if (!thread ||
|
|
1294
|
+
if (!thread || thread.resourceId && thread.resourceId !== resourceId) throw new require_http_exception.HTTPException(404, { message: "Thread not found" });
|
|
1275
1295
|
await require_utils.enforceThreadAccess({
|
|
1276
1296
|
mastra,
|
|
1277
1297
|
requestContext,
|
|
@@ -1318,10 +1338,10 @@ const LIST_AGENT_CONTROLLER_THREAD_MESSAGES_ROUTE = require_route_builder.create
|
|
|
1318
1338
|
});
|
|
1319
1339
|
const FOLLOW_UP_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRoute({
|
|
1320
1340
|
method: "POST",
|
|
1321
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1341
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/follow-up",
|
|
1342
|
+
queryParamSchema: sessionQuerySchema,
|
|
1322
1343
|
responseType: "json",
|
|
1323
1344
|
pathParamSchema: sessionPathParams,
|
|
1324
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1325
1345
|
bodySchema: followUpBodySchema,
|
|
1326
1346
|
responseSchema: ackResponseSchema,
|
|
1327
1347
|
summary: "Queue a follow-up message",
|
|
@@ -1329,9 +1349,9 @@ const FOLLOW_UP_AGENT_CONTROLLER_SESSION_ROUTE = require_route_builder.createRou
|
|
|
1329
1349
|
tags: ["AgentController"],
|
|
1330
1350
|
requiresAuth: true,
|
|
1331
1351
|
requiresPermission: "agent-controller:execute",
|
|
1332
|
-
handler: async ({ mastra, controllerId,
|
|
1352
|
+
handler: async ({ mastra, controllerId, sessionId, message, files, requestContext }) => {
|
|
1333
1353
|
try {
|
|
1334
|
-
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1354
|
+
const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext);
|
|
1335
1355
|
ackBackgroundSessionWork({
|
|
1336
1356
|
work: session.followUp({
|
|
1337
1357
|
content: message,
|
|
@@ -1401,20 +1421,20 @@ const GET_AGENT_CONTROLLER_WORKSPACE_STATUS_ROUTE = require_route_builder.create
|
|
|
1401
1421
|
});
|
|
1402
1422
|
const GET_AGENT_CONTROLLER_OM_RECORD_ROUTE = require_route_builder.createRoute({
|
|
1403
1423
|
method: "GET",
|
|
1404
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1424
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/om",
|
|
1425
|
+
queryParamSchema: sessionQuerySchema,
|
|
1405
1426
|
responseType: "json",
|
|
1406
1427
|
pathParamSchema: sessionPathParams,
|
|
1407
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1408
1428
|
responseSchema: omRecordResponseSchema,
|
|
1409
1429
|
summary: "Get observational memory record",
|
|
1410
1430
|
description: "Returns the current observational memory record for the session’s thread/resource.",
|
|
1411
1431
|
tags: ["AgentController"],
|
|
1412
1432
|
requiresAuth: true,
|
|
1413
1433
|
requiresPermission: "agent-controller:read",
|
|
1414
|
-
handler: async ({ mastra, controllerId,
|
|
1434
|
+
handler: async ({ mastra, controllerId, sessionId, requestContext }) => {
|
|
1415
1435
|
try {
|
|
1416
1436
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
1417
|
-
const session = await getExistingSession(controller,
|
|
1437
|
+
const session = await getExistingSession(controller, sessionId, requestContext);
|
|
1418
1438
|
return { record: await controller.getObservationalMemoryRecord(session) ?? void 0 };
|
|
1419
1439
|
} catch (error) {
|
|
1420
1440
|
return require_server_handlers_error.handleError(error, "error reading controller OM record");
|
|
@@ -1423,10 +1443,10 @@ const GET_AGENT_CONTROLLER_OM_RECORD_ROUTE = require_route_builder.createRoute({
|
|
|
1423
1443
|
});
|
|
1424
1444
|
const SET_AGENT_CONTROLLER_RESOURCE_ID_ROUTE = require_route_builder.createRoute({
|
|
1425
1445
|
method: "POST",
|
|
1426
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1446
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/resource",
|
|
1447
|
+
queryParamSchema: sessionQuerySchema,
|
|
1427
1448
|
responseType: "json",
|
|
1428
1449
|
pathParamSchema: sessionPathParams,
|
|
1429
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1430
1450
|
bodySchema: zod_v4.z.object({ newResourceId: zod_v4.z.string() }),
|
|
1431
1451
|
responseSchema: ackResponseSchema,
|
|
1432
1452
|
summary: "Change the session resource ID",
|
|
@@ -1434,10 +1454,10 @@ const SET_AGENT_CONTROLLER_RESOURCE_ID_ROUTE = require_route_builder.createRoute
|
|
|
1434
1454
|
tags: ["AgentController"],
|
|
1435
1455
|
requiresAuth: true,
|
|
1436
1456
|
requiresPermission: "agent-controller:execute",
|
|
1437
|
-
handler: async ({ mastra, controllerId,
|
|
1457
|
+
handler: async ({ mastra, controllerId, sessionId, newResourceId, requestContext }) => {
|
|
1438
1458
|
try {
|
|
1439
1459
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
1440
|
-
const session = await getSession(controller,
|
|
1460
|
+
const session = await getSession(controller, sessionId, requestContext);
|
|
1441
1461
|
await controller.setResourceId(session, { resourceId: newResourceId });
|
|
1442
1462
|
return { ok: true };
|
|
1443
1463
|
} catch (error) {
|
|
@@ -1447,20 +1467,20 @@ const SET_AGENT_CONTROLLER_RESOURCE_ID_ROUTE = require_route_builder.createRoute
|
|
|
1447
1467
|
});
|
|
1448
1468
|
const GET_AGENT_CONTROLLER_RESOURCE_IDS_ROUTE = require_route_builder.createRoute({
|
|
1449
1469
|
method: "GET",
|
|
1450
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1470
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/resources",
|
|
1471
|
+
queryParamSchema: sessionQuerySchema,
|
|
1451
1472
|
responseType: "json",
|
|
1452
1473
|
pathParamSchema: sessionPathParams,
|
|
1453
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1454
1474
|
responseSchema: zod_v4.z.object({ resourceIds: zod_v4.z.array(zod_v4.z.string()) }),
|
|
1455
1475
|
summary: "Get known resource IDs",
|
|
1456
1476
|
description: "Lists the resource IDs known to this session (from threads).",
|
|
1457
1477
|
tags: ["AgentController"],
|
|
1458
1478
|
requiresAuth: true,
|
|
1459
1479
|
requiresPermission: "agent-controller:read",
|
|
1460
|
-
handler: async ({ mastra, controllerId,
|
|
1480
|
+
handler: async ({ mastra, controllerId, sessionId, requestContext }) => {
|
|
1461
1481
|
try {
|
|
1462
1482
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
1463
|
-
const session = await getExistingSession(controller,
|
|
1483
|
+
const session = await getExistingSession(controller, sessionId, requestContext);
|
|
1464
1484
|
return { resourceIds: await controller.getKnownResourceIds(session) };
|
|
1465
1485
|
} catch (error) {
|
|
1466
1486
|
return require_server_handlers_error.handleError(error, "error listing controller resource IDs");
|
|
@@ -1502,20 +1522,20 @@ function getAgentForSession(controller, session) {
|
|
|
1502
1522
|
}
|
|
1503
1523
|
const GET_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
1504
1524
|
method: "GET",
|
|
1505
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1525
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/goal",
|
|
1526
|
+
queryParamSchema: sessionQuerySchema,
|
|
1506
1527
|
responseType: "json",
|
|
1507
1528
|
pathParamSchema: sessionPathParams,
|
|
1508
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1509
1529
|
responseSchema: goalResponseSchema,
|
|
1510
1530
|
summary: "Get the current goal",
|
|
1511
1531
|
description: "Returns the active/paused/done goal objective for the session’s thread, if any.",
|
|
1512
1532
|
tags: ["AgentController", "Goals"],
|
|
1513
1533
|
requiresAuth: true,
|
|
1514
1534
|
requiresPermission: "agent-controller:read",
|
|
1515
|
-
handler: async ({ mastra, controllerId,
|
|
1535
|
+
handler: async ({ mastra, controllerId, sessionId, requestContext }) => {
|
|
1516
1536
|
try {
|
|
1517
1537
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
1518
|
-
const session = await getExistingSession(controller,
|
|
1538
|
+
const session = await getExistingSession(controller, sessionId, requestContext);
|
|
1519
1539
|
const threadId = session.thread.getId();
|
|
1520
1540
|
if (!threadId) return { goal: void 0 };
|
|
1521
1541
|
return { goal: await getAgentForSession(controller, session).getObjective({ threadId }) ?? void 0 };
|
|
@@ -1526,10 +1546,10 @@ const GET_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
|
1526
1546
|
});
|
|
1527
1547
|
const SET_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
1528
1548
|
method: "POST",
|
|
1529
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1549
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/goal",
|
|
1550
|
+
queryParamSchema: sessionQuerySchema,
|
|
1530
1551
|
responseType: "json",
|
|
1531
1552
|
pathParamSchema: sessionPathParams,
|
|
1532
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1533
1553
|
bodySchema: setGoalBodySchema,
|
|
1534
1554
|
responseSchema: goalResponseSchema,
|
|
1535
1555
|
summary: "Set a goal",
|
|
@@ -1537,10 +1557,10 @@ const SET_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
|
1537
1557
|
tags: ["AgentController", "Goals"],
|
|
1538
1558
|
requiresAuth: true,
|
|
1539
1559
|
requiresPermission: "agent-controller:execute",
|
|
1540
|
-
handler: async ({ mastra, controllerId,
|
|
1560
|
+
handler: async ({ mastra, controllerId, sessionId, objective, judgeModelId, maxRuns, requestContext }) => {
|
|
1541
1561
|
try {
|
|
1542
1562
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
1543
|
-
const session = await getSession(controller,
|
|
1563
|
+
const session = await getSession(controller, sessionId, requestContext);
|
|
1544
1564
|
const threadId = session.thread.getId();
|
|
1545
1565
|
if (!threadId) throw new require_http_exception.HTTPException(400, { message: "session has no active thread" });
|
|
1546
1566
|
return { goal: await getAgentForSession(controller, session).setObjective(objective, {
|
|
@@ -1556,10 +1576,10 @@ const SET_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
|
1556
1576
|
});
|
|
1557
1577
|
const UPDATE_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
1558
1578
|
method: "PUT",
|
|
1559
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1579
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/goal",
|
|
1580
|
+
queryParamSchema: sessionQuerySchema,
|
|
1560
1581
|
responseType: "json",
|
|
1561
1582
|
pathParamSchema: sessionPathParams,
|
|
1562
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1563
1583
|
bodySchema: updateGoalBodySchema,
|
|
1564
1584
|
responseSchema: goalResponseSchema,
|
|
1565
1585
|
summary: "Update goal options",
|
|
@@ -1567,10 +1587,10 @@ const UPDATE_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
|
1567
1587
|
tags: ["AgentController", "Goals"],
|
|
1568
1588
|
requiresAuth: true,
|
|
1569
1589
|
requiresPermission: "agent-controller:execute",
|
|
1570
|
-
handler: async ({ mastra, controllerId,
|
|
1590
|
+
handler: async ({ mastra, controllerId, sessionId, judgeModelId, maxRuns, status, requestContext }) => {
|
|
1571
1591
|
try {
|
|
1572
1592
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
1573
|
-
const session = await getSession(controller,
|
|
1593
|
+
const session = await getSession(controller, sessionId, requestContext);
|
|
1574
1594
|
const threadId = session.thread.getId();
|
|
1575
1595
|
if (!threadId) throw new require_http_exception.HTTPException(400, { message: "session has no active thread" });
|
|
1576
1596
|
return { goal: await getAgentForSession(controller, session).updateObjectiveOptions({
|
|
@@ -1586,20 +1606,20 @@ const UPDATE_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
|
1586
1606
|
});
|
|
1587
1607
|
const CLEAR_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
1588
1608
|
method: "DELETE",
|
|
1589
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1609
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/goal",
|
|
1610
|
+
queryParamSchema: sessionQuerySchema,
|
|
1590
1611
|
responseType: "json",
|
|
1591
1612
|
pathParamSchema: sessionPathParams,
|
|
1592
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1593
1613
|
responseSchema: ackResponseSchema,
|
|
1594
1614
|
summary: "Clear the goal",
|
|
1595
1615
|
description: "Removes the active goal from the session’s thread.",
|
|
1596
1616
|
tags: ["AgentController", "Goals"],
|
|
1597
1617
|
requiresAuth: true,
|
|
1598
1618
|
requiresPermission: "agent-controller:execute",
|
|
1599
|
-
handler: async ({ mastra, controllerId,
|
|
1619
|
+
handler: async ({ mastra, controllerId, sessionId, requestContext }) => {
|
|
1600
1620
|
try {
|
|
1601
1621
|
const controller = getAgentControllerOrThrow(mastra, controllerId);
|
|
1602
|
-
const session = await getSession(controller,
|
|
1622
|
+
const session = await getSession(controller, sessionId, requestContext);
|
|
1603
1623
|
const threadId = session.thread.getId();
|
|
1604
1624
|
if (!threadId) throw new require_http_exception.HTTPException(400, { message: "session has no active thread" });
|
|
1605
1625
|
await getAgentForSession(controller, session).clearObjective({ threadId });
|
|
@@ -1611,19 +1631,19 @@ const CLEAR_AGENT_CONTROLLER_GOAL_ROUTE = require_route_builder.createRoute({
|
|
|
1611
1631
|
});
|
|
1612
1632
|
const GET_AGENT_CONTROLLER_PERMISSIONS_ROUTE = require_route_builder.createRoute({
|
|
1613
1633
|
method: "GET",
|
|
1614
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1634
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/permissions",
|
|
1635
|
+
queryParamSchema: sessionQuerySchema,
|
|
1615
1636
|
responseType: "json",
|
|
1616
1637
|
pathParamSchema: sessionPathParams,
|
|
1617
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1618
1638
|
responseSchema: permissionRulesResponseSchema,
|
|
1619
1639
|
summary: "Get permission rules",
|
|
1620
1640
|
description: "Returns the current permission rules (per-category and per-tool policies) for the session.",
|
|
1621
1641
|
tags: ["AgentController", "Permissions"],
|
|
1622
1642
|
requiresAuth: true,
|
|
1623
1643
|
requiresPermission: "agent-controller:read",
|
|
1624
|
-
handler: async ({ mastra, controllerId,
|
|
1644
|
+
handler: async ({ mastra, controllerId, sessionId, requestContext }) => {
|
|
1625
1645
|
try {
|
|
1626
|
-
const rules = (await getExistingSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1646
|
+
const rules = (await getExistingSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).permissions.getRules();
|
|
1627
1647
|
return {
|
|
1628
1648
|
categories: rules.categories,
|
|
1629
1649
|
tools: rules.tools
|
|
@@ -1635,10 +1655,10 @@ const GET_AGENT_CONTROLLER_PERMISSIONS_ROUTE = require_route_builder.createRoute
|
|
|
1635
1655
|
});
|
|
1636
1656
|
const SET_AGENT_CONTROLLER_CATEGORY_PERMISSION_ROUTE = require_route_builder.createRoute({
|
|
1637
1657
|
method: "PUT",
|
|
1638
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1658
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/permissions/category",
|
|
1659
|
+
queryParamSchema: sessionQuerySchema,
|
|
1639
1660
|
responseType: "json",
|
|
1640
1661
|
pathParamSchema: sessionPathParams,
|
|
1641
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1642
1662
|
bodySchema: setCategoryPermissionBodySchema,
|
|
1643
1663
|
responseSchema: ackResponseSchema,
|
|
1644
1664
|
summary: "Set permission for a tool category",
|
|
@@ -1646,9 +1666,9 @@ const SET_AGENT_CONTROLLER_CATEGORY_PERMISSION_ROUTE = require_route_builder.cre
|
|
|
1646
1666
|
tags: ["AgentController", "Permissions"],
|
|
1647
1667
|
requiresAuth: true,
|
|
1648
1668
|
requiresPermission: "agent-controller:execute",
|
|
1649
|
-
handler: async ({ mastra, controllerId,
|
|
1669
|
+
handler: async ({ mastra, controllerId, sessionId, category, policy, requestContext }) => {
|
|
1650
1670
|
try {
|
|
1651
|
-
await (await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1671
|
+
await (await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).permissions.setForCategory({
|
|
1652
1672
|
category,
|
|
1653
1673
|
policy
|
|
1654
1674
|
});
|
|
@@ -1660,10 +1680,10 @@ const SET_AGENT_CONTROLLER_CATEGORY_PERMISSION_ROUTE = require_route_builder.cre
|
|
|
1660
1680
|
});
|
|
1661
1681
|
const SET_AGENT_CONTROLLER_TOOL_PERMISSION_ROUTE = require_route_builder.createRoute({
|
|
1662
1682
|
method: "PUT",
|
|
1663
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1683
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/permissions/tool",
|
|
1684
|
+
queryParamSchema: sessionQuerySchema,
|
|
1664
1685
|
responseType: "json",
|
|
1665
1686
|
pathParamSchema: sessionPathParams,
|
|
1666
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1667
1687
|
bodySchema: setToolPermissionBodySchema,
|
|
1668
1688
|
responseSchema: ackResponseSchema,
|
|
1669
1689
|
summary: "Set permission for a specific tool",
|
|
@@ -1671,9 +1691,9 @@ const SET_AGENT_CONTROLLER_TOOL_PERMISSION_ROUTE = require_route_builder.createR
|
|
|
1671
1691
|
tags: ["AgentController", "Permissions"],
|
|
1672
1692
|
requiresAuth: true,
|
|
1673
1693
|
requiresPermission: "agent-controller:execute",
|
|
1674
|
-
handler: async ({ mastra, controllerId,
|
|
1694
|
+
handler: async ({ mastra, controllerId, sessionId, toolName, policy, requestContext }) => {
|
|
1675
1695
|
try {
|
|
1676
|
-
await (await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1696
|
+
await (await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).permissions.setForTool({
|
|
1677
1697
|
toolName,
|
|
1678
1698
|
policy
|
|
1679
1699
|
});
|
|
@@ -1686,10 +1706,10 @@ const SET_AGENT_CONTROLLER_TOOL_PERMISSION_ROUTE = require_route_builder.createR
|
|
|
1686
1706
|
const setSessionStateBodySchema = zod_v4.z.object({ state: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.unknown()) });
|
|
1687
1707
|
const SET_AGENT_CONTROLLER_SESSION_STATE_ROUTE = require_route_builder.createRoute({
|
|
1688
1708
|
method: "PUT",
|
|
1689
|
-
path: "/agent-controller/:controllerId/sessions/:
|
|
1709
|
+
path: "/agent-controller/:controllerId/sessions/:sessionId/state",
|
|
1710
|
+
queryParamSchema: sessionQuerySchema,
|
|
1690
1711
|
responseType: "json",
|
|
1691
1712
|
pathParamSchema: sessionPathParams,
|
|
1692
|
-
queryParamSchema: sessionScopeQuerySchema,
|
|
1693
1713
|
bodySchema: setSessionStateBodySchema,
|
|
1694
1714
|
responseSchema: ackResponseSchema,
|
|
1695
1715
|
summary: "Set session state",
|
|
@@ -1697,9 +1717,9 @@ const SET_AGENT_CONTROLLER_SESSION_STATE_ROUTE = require_route_builder.createRou
|
|
|
1697
1717
|
tags: ["AgentController"],
|
|
1698
1718
|
requiresAuth: true,
|
|
1699
1719
|
requiresPermission: "agent-controller:execute",
|
|
1700
|
-
handler: async ({ mastra, controllerId,
|
|
1720
|
+
handler: async ({ mastra, controllerId, sessionId, state, requestContext }) => {
|
|
1701
1721
|
try {
|
|
1702
|
-
await (await getSession(getAgentControllerOrThrow(mastra, controllerId),
|
|
1722
|
+
await (await getSession(getAgentControllerOrThrow(mastra, controllerId), sessionId, requestContext)).state.set(state);
|
|
1703
1723
|
return { ok: true };
|
|
1704
1724
|
} catch (error) {
|
|
1705
1725
|
return require_server_handlers_error.handleError(error, "error setting controller session state");
|