@mastra/server 1.77.0-alpha.1 → 1.77.0-alpha.3

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.
Files changed (30) hide show
  1. package/dist/{dist-B6B4Cxda.js → dist-C6Y74AMV.js} +8 -8
  2. package/dist/dist-C6Y74AMV.js.map +1 -0
  3. package/dist/{dist-BGfXR4Xj.cjs → dist-D0yst49-.cjs} +8 -8
  4. package/dist/dist-D0yst49-.cjs.map +1 -0
  5. package/dist/docs/SKILL.md +1 -1
  6. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  7. package/dist/server/handlers/agent-builder.cjs +1 -1
  8. package/dist/server/handlers/agent-builder.js +1 -1
  9. package/dist/server/handlers/agent-controller.cjs +20 -7
  10. package/dist/server/handlers/agent-controller.cjs.map +1 -1
  11. package/dist/server/handlers/agent-controller.d.ts +2 -0
  12. package/dist/server/handlers/agent-controller.d.ts.map +1 -1
  13. package/dist/server/handlers/agent-controller.js +20 -7
  14. package/dist/server/handlers/agent-controller.js.map +1 -1
  15. package/dist/server/handlers/error.cjs +9 -4
  16. package/dist/server/handlers/error.cjs.map +1 -1
  17. package/dist/server/handlers/error.d.ts.map +1 -1
  18. package/dist/server/handlers/error.js +9 -4
  19. package/dist/server/handlers/error.js.map +1 -1
  20. package/dist/server/handlers/workflows.cjs +8 -0
  21. package/dist/server/handlers/workflows.cjs.map +1 -1
  22. package/dist/server/handlers/workflows.d.ts +8 -0
  23. package/dist/server/handlers/workflows.d.ts.map +1 -1
  24. package/dist/server/handlers/workflows.js +8 -0
  25. package/dist/server/handlers/workflows.js.map +1 -1
  26. package/dist/server/server-adapter/routes/workflows.d.ts +2 -0
  27. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
  28. package/package.json +7 -7
  29. package/dist/dist-B6B4Cxda.js.map +0 -1
  30. package/dist/dist-BGfXR4Xj.cjs.map +0 -1
@@ -1,5 +1,6 @@
1
1
  import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
2
2
  import { n as createRoute } from "../../route-builder-lBil8Cvo.js";
3
+ import { l as MASTRA_USER_KEY } from "../../constants-1TDVXCCT.js";
3
4
  import { handleError } from "./error.js";
4
5
  import { t as enforceThreadAccess } from "../../utils-kaP2cyIO.js";
5
6
  import { E as includeSchema, F as messageOrderBySchema, h as filterSchema } from "../../memory-B58Q2LgU.js";
@@ -37,12 +38,20 @@ const RESERVED_THREAD_METADATA_KEYS = {
37
38
  observationThreshold: true,
38
39
  reflectionThreshold: true,
39
40
  tokenUsage: true,
41
+ ownerId: true,
42
+ createdBy: true,
40
43
  thinkingLevel: true,
41
44
  notifications: true
42
45
  };
43
46
  function isReservedThreadMetadataKey(key) {
44
47
  return Object.hasOwn(RESERVED_THREAD_METADATA_KEYS, key) || key.startsWith("modeModelId_");
45
48
  }
49
+ function getRequestMessageAuthor(requestContext) {
50
+ const user = requestContext?.get(MASTRA_USER_KEY);
51
+ if (!user || typeof user !== "object" || Array.isArray(user)) return void 0;
52
+ const id = user.id;
53
+ return typeof id === "string" && id ? { id } : void 0;
54
+ }
46
55
  /**
47
56
  * Resolves a controller by id via the canonical `mastra.getAgentController`
48
57
  * accessor, throwing a 404 if no controller is registered under that id.
@@ -152,6 +161,7 @@ const toolApprovalBodySchema = z.object({
152
161
  });
153
162
  const toolSuspensionBodySchema = z.object({
154
163
  toolCallId: z.string().min(1),
164
+ runId: z.string().min(1).optional(),
155
165
  resumeData: z.unknown(),
156
166
  requestContext: bodyRequestContextSchema
157
167
  });
@@ -595,11 +605,13 @@ const SEND_AGENT_CONTROLLER_MESSAGE_ROUTE = createRoute({
595
605
  handler: async ({ mastra, controllerId, resourceId, sessionScope, message, files, requestContext }) => {
596
606
  try {
597
607
  const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), resourceId, { scope: sessionScope }, requestContext);
608
+ const author = getRequestMessageAuthor(requestContext);
598
609
  ackBackgroundSessionWork({
599
610
  work: session.sendMessage({
600
611
  content: message,
601
612
  files,
602
- requestContext
613
+ requestContext,
614
+ ...author ? { author } : {}
603
615
  }),
604
616
  session,
605
617
  mastra,
@@ -697,21 +709,20 @@ const AGENT_CONTROLLER_TOOL_SUSPENSION_ROUTE = createRoute({
697
709
  tags: ["AgentController"],
698
710
  requiresAuth: true,
699
711
  requiresPermission: "agent-controller:execute",
700
- handler: async ({ mastra, controllerId, resourceId, sessionScope, toolCallId, resumeData, requestContext }) => {
712
+ handler: async ({ mastra, controllerId, resourceId, sessionScope, toolCallId, runId, resumeData, requestContext }) => {
701
713
  try {
702
714
  const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), resourceId, { scope: sessionScope }, requestContext);
703
- const claim = session.claimToolSuspension(toolCallId);
715
+ const claim = session.claimToolSuspension(toolCallId, runId);
704
716
  if (!claim.accepted) return {
705
717
  ok: false,
706
718
  reason: claim.reason
707
719
  };
708
- const claimedToolCallId = claim.toolCallId;
709
720
  ackBackgroundSessionWork({
710
721
  work: session.respondToToolSuspension({
711
- toolCallId,
722
+ address: claim.address,
712
723
  resumeData,
713
724
  requestContext
714
- }).finally(() => session.releaseToolResponse(claimedToolCallId)),
725
+ }).finally(() => session.releaseToolResponse(claim.claimKey)),
715
726
  session,
716
727
  mastra,
717
728
  operation: "respondToToolSuspension"
@@ -738,10 +749,12 @@ const STEER_AGENT_CONTROLLER_SESSION_ROUTE = createRoute({
738
749
  handler: async ({ mastra, controllerId, resourceId, sessionScope, message, requestContext }) => {
739
750
  try {
740
751
  const session = await getSession(getAgentControllerOrThrow(mastra, controllerId), resourceId, { scope: sessionScope }, requestContext);
752
+ const author = getRequestMessageAuthor(requestContext);
741
753
  ackBackgroundSessionWork({
742
754
  work: session.steer({
743
755
  content: message,
744
- requestContext
756
+ requestContext,
757
+ ...author ? { author } : {}
745
758
  }),
746
759
  session,
747
760
  mastra,