@mastra/server 1.79.0 → 1.80.0-alpha.0

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 (136) hide show
  1. package/dist/_types/@internal_core/dist/storage/index.d.ts +243 -243
  2. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/request-context/index.d.ts +13 -13
  3. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/routes/index.d.ts +12 -12
  4. package/dist/_types/@internal_voice/dist/_types/@internal_core/dist/types/index.d.ts +1 -2
  5. package/dist/{agent-builder-CuBD1tpv.cjs → agent-builder-BkPIfCgW.cjs} +2 -2
  6. package/dist/{agent-builder-CuBD1tpv.cjs.map → agent-builder-BkPIfCgW.cjs.map} +1 -1
  7. package/dist/{agent-builder-VhM8ADW-.js → agent-builder-DvxYJR85.js} +2 -2
  8. package/dist/{agent-builder-VhM8ADW-.js.map → agent-builder-DvxYJR85.js.map} +1 -1
  9. package/dist/{api-schema-manifest-DIlNfbyw.cjs → api-schema-manifest-CQSdIekp.cjs} +2 -2
  10. package/dist/{api-schema-manifest-DIlNfbyw.cjs.map → api-schema-manifest-CQSdIekp.cjs.map} +1 -1
  11. package/dist/{api-schema-manifest-CI90M4sX.js → api-schema-manifest-Ce-tWsRS.js} +2 -2
  12. package/dist/{api-schema-manifest-CI90M4sX.js.map → api-schema-manifest-Ce-tWsRS.js.map} +1 -1
  13. package/dist/{dist-B-bEVWlJ.cjs → dist-B3KkuNCj.cjs} +41 -7
  14. package/dist/{dist-B-bEVWlJ.cjs.map → dist-B3KkuNCj.cjs.map} +1 -1
  15. package/dist/dist-CTklSbUE.js +1 -0
  16. package/dist/{dist-k77XQGUn.js → dist-DqKW0v-Y.js} +41 -7
  17. package/dist/{dist-k77XQGUn.js.map → dist-DqKW0v-Y.js.map} +1 -1
  18. package/dist/{dist-B3kC8Yd0.cjs → dist-rMs0TQWs.cjs} +1 -1
  19. package/dist/docs/SKILL.md +2 -2
  20. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  21. package/dist/docs/references/docs-connections-a2a.md +1 -1
  22. package/dist/docs/references/docs-guides-mcp-authentication-authorization.md +2 -2
  23. package/dist/docs/references/docs-server-middleware.md +1 -1
  24. package/dist/docs/references/reference-observability-tracing-advanced-queries.md +92 -11
  25. package/dist/{helpers-CAcEhq38.cjs → helpers-DvzrUzqY.cjs} +2 -2
  26. package/dist/{helpers-CAcEhq38.cjs.map → helpers-DvzrUzqY.cjs.map} +1 -1
  27. package/dist/{helpers-vrqddDd5.js → helpers-gCkmhB9x.js} +2 -2
  28. package/dist/{helpers-vrqddDd5.js.map → helpers-gCkmhB9x.js.map} +1 -1
  29. package/dist/{observability-BBMCMeT-.cjs → observability-C2BZQ2jU.cjs} +3 -2
  30. package/dist/{observability-BBMCMeT-.cjs.map → observability-C2BZQ2jU.cjs.map} +1 -1
  31. package/dist/{observability-ZRgRcvoX.js → observability-Dz9jvMJ3.js} +3 -2
  32. package/dist/{observability-ZRgRcvoX.js.map → observability-Dz9jvMJ3.js.map} +1 -1
  33. package/dist/{observability-new-endpoints-fjoZzEtk.js → observability-new-endpoints-3DlTYf34.js} +117 -4
  34. package/dist/observability-new-endpoints-3DlTYf34.js.map +1 -0
  35. package/dist/{observability-new-endpoints-tG3-odLa.cjs → observability-new-endpoints-Drr7q2Dj.cjs} +121 -2
  36. package/dist/observability-new-endpoints-Drr7q2Dj.cjs.map +1 -0
  37. package/dist/{probe-image-size-BdfbUHxx.js → probe-image-size-BRq0A2_y.js} +2 -2
  38. package/dist/{probe-image-size-BdfbUHxx.js.map → probe-image-size-BRq0A2_y.js.map} +1 -1
  39. package/dist/{probe-image-size-Alv3gwKl.cjs → probe-image-size-C8vYbACH.cjs} +2 -2
  40. package/dist/{probe-image-size-Alv3gwKl.cjs.map → probe-image-size-C8vYbACH.cjs.map} +1 -1
  41. package/dist/{routes-DGLJyqjD.cjs → routes-B4I5n3rK.cjs} +12 -11
  42. package/dist/routes-B4I5n3rK.cjs.map +1 -0
  43. package/dist/{routes-BC20mdNN.js → routes-nhnsGZVb.js} +12 -11
  44. package/dist/routes-nhnsGZVb.js.map +1 -0
  45. package/dist/server/auth/helpers.d.ts.map +1 -1
  46. package/dist/server/auth/index.cjs +1 -1
  47. package/dist/server/auth/index.js +1 -1
  48. package/dist/server/handlers/agent-builder.cjs +1 -1
  49. package/dist/server/handlers/agent-builder.js +1 -1
  50. package/dist/server/handlers/auth.cjs +15 -1
  51. package/dist/server/handlers/auth.cjs.map +1 -1
  52. package/dist/server/handlers/auth.d.ts.map +1 -1
  53. package/dist/server/handlers/auth.js +15 -1
  54. package/dist/server/handlers/auth.js.map +1 -1
  55. package/dist/server/handlers/mcp-client-versions.cjs +1 -1
  56. package/dist/server/handlers/mcp-client-versions.js +1 -1
  57. package/dist/server/handlers/observability-new-endpoints.cjs +2 -1
  58. package/dist/server/handlers/observability-new-endpoints.d.ts +132 -0
  59. package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
  60. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  61. package/dist/server/handlers/observability-shared.cjs +19 -0
  62. package/dist/server/handlers/observability-shared.cjs.map +1 -1
  63. package/dist/server/handlers/observability-shared.d.ts +10 -0
  64. package/dist/server/handlers/observability-shared.d.ts.map +1 -1
  65. package/dist/server/handlers/observability-shared.js +18 -1
  66. package/dist/server/handlers/observability-shared.js.map +1 -1
  67. package/dist/server/handlers/observability.cjs +3 -2
  68. package/dist/server/handlers/observability.js +3 -3
  69. package/dist/server/handlers/prompt-block-versions.cjs +1 -1
  70. package/dist/server/handlers/prompt-block-versions.js +1 -1
  71. package/dist/server/handlers/schedules-workflows-shim.cjs.map +1 -1
  72. package/dist/server/handlers/schedules-workflows-shim.js.map +1 -1
  73. package/dist/server/handlers/scorer-versions.cjs +1 -1
  74. package/dist/server/handlers/scorer-versions.js +1 -1
  75. package/dist/server/handlers/stored-agents.cjs +29 -11
  76. package/dist/server/handlers/stored-agents.cjs.map +1 -1
  77. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  78. package/dist/server/handlers/stored-agents.js +29 -11
  79. package/dist/server/handlers/stored-agents.js.map +1 -1
  80. package/dist/server/handlers/stored-mcp-clients.cjs +1 -1
  81. package/dist/server/handlers/stored-mcp-clients.js +1 -1
  82. package/dist/server/handlers/stored-prompt-blocks.cjs +1 -1
  83. package/dist/server/handlers/stored-prompt-blocks.js +1 -1
  84. package/dist/server/handlers/stored-scorers.cjs +1 -1
  85. package/dist/server/handlers/stored-scorers.js +1 -1
  86. package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
  87. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  88. package/dist/server/handlers/stored-skills.cjs +1 -1
  89. package/dist/server/handlers/stored-skills.js +1 -1
  90. package/dist/server/handlers/system.cjs +2 -2
  91. package/dist/server/handlers/system.d.ts +2 -0
  92. package/dist/server/handlers/system.d.ts.map +1 -1
  93. package/dist/server/handlers/system.js +2 -2
  94. package/dist/server/handlers/tools.d.ts.map +1 -1
  95. package/dist/server/handlers/workspace.cjs +1 -1
  96. package/dist/server/handlers/workspace.d.ts +23 -23
  97. package/dist/server/handlers/workspace.js +1 -1
  98. package/dist/server/handlers.cjs +3 -3
  99. package/dist/server/handlers.js +3 -3
  100. package/dist/server/schemas/index.cjs +2 -2
  101. package/dist/server/schemas/index.js +2 -2
  102. package/dist/server/schemas/system.d.ts +2 -0
  103. package/dist/server/schemas/system.d.ts.map +1 -1
  104. package/dist/server/server-adapter/index.cjs +95 -3
  105. package/dist/server/server-adapter/index.cjs.map +1 -1
  106. package/dist/server/server-adapter/index.d.ts +28 -1
  107. package/dist/server/server-adapter/index.d.ts.map +1 -1
  108. package/dist/server/server-adapter/index.js +93 -4
  109. package/dist/server/server-adapter/index.js.map +1 -1
  110. package/dist/server/server-adapter/mcp-disconnect.d.ts +16 -0
  111. package/dist/server/server-adapter/mcp-disconnect.d.ts.map +1 -0
  112. package/dist/server/server-adapter/routes/observability.d.ts +129 -0
  113. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
  114. package/dist/server/server-adapter/routes/system.d.ts +2 -0
  115. package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
  116. package/dist/server/server-adapter/routes/workspace.d.ts +23 -23
  117. package/dist/{system-BvpFMIJB.cjs → system-B_Sod-Le.cjs} +2 -1
  118. package/dist/system-B_Sod-Le.cjs.map +1 -0
  119. package/dist/{system-CpzPxRRq.js → system-sSSmmt7I.js} +2 -1
  120. package/dist/system-sSSmmt7I.js.map +1 -0
  121. package/dist/tools-CmFSfDMn.js.map +1 -1
  122. package/dist/tools-SPJtxG9N.cjs.map +1 -1
  123. package/dist/{workspace-B6kzp-bo.js → workspace-BVHXoKmP.js} +2 -2
  124. package/dist/workspace-BVHXoKmP.js.map +1 -0
  125. package/dist/{workspace-COKR1SxH.cjs → workspace-d25MZ9dj.cjs} +2 -2
  126. package/dist/workspace-d25MZ9dj.cjs.map +1 -0
  127. package/package.json +9 -9
  128. package/dist/dist-BM9J-PTK.js +0 -1
  129. package/dist/observability-new-endpoints-fjoZzEtk.js.map +0 -1
  130. package/dist/observability-new-endpoints-tG3-odLa.cjs.map +0 -1
  131. package/dist/routes-BC20mdNN.js.map +0 -1
  132. package/dist/routes-DGLJyqjD.cjs.map +0 -1
  133. package/dist/system-BvpFMIJB.cjs.map +0 -1
  134. package/dist/system-CpzPxRRq.js.map +0 -1
  135. package/dist/workspace-B6kzp-bo.js.map +0 -1
  136. package/dist/workspace-COKR1SxH.cjs.map +0 -1
@@ -12,7 +12,7 @@ type RecordToTuple<T> = { [K in keyof T]: [K, T[K]]; }[keyof T][];
12
12
  * requestContext.set(MASTRA_RESOURCE_ID_KEY, authenticatedUser.id);
13
13
  * ```
14
14
  */
15
- declare const MASTRA_RESOURCE_ID_KEY = "mastra__resourceId";
15
+ export declare const MASTRA_RESOURCE_ID_KEY = "mastra__resourceId";
16
16
  /**
17
17
  * Reserved key for setting threadId from middleware.
18
18
  * When set in RequestContext, this takes precedence over client-provided values
@@ -25,7 +25,7 @@ declare const MASTRA_RESOURCE_ID_KEY = "mastra__resourceId";
25
25
  * requestContext.set(MASTRA_THREAD_ID_KEY, threadId);
26
26
  * ```
27
27
  */
28
- declare const MASTRA_THREAD_ID_KEY = "mastra__threadId";
28
+ export declare const MASTRA_THREAD_ID_KEY = "mastra__threadId";
29
29
  /**
30
30
  * Reserved key for setting agent scopes from middleware.
31
31
  *
@@ -46,7 +46,7 @@ declare const MASTRA_THREAD_ID_KEY = "mastra__threadId";
46
46
  * requestContext.set(MASTRA_SCOPES_KEY, [`org:${user.orgId}`, `resource:${user.id}`]);
47
47
  * ```
48
48
  */
49
- declare const MASTRA_SCOPES_KEY = "mastra__scopes";
49
+ export declare const MASTRA_SCOPES_KEY = "mastra__scopes";
50
50
  /**
51
51
  * Reserved key for storing version overrides on RequestContext.
52
52
  * When set, sub-agent delegation resolves versioned agents from these overrides.
@@ -58,13 +58,13 @@ declare const MASTRA_SCOPES_KEY = "mastra__scopes";
58
58
  * });
59
59
  * ```
60
60
  */
61
- declare const MASTRA_VERSIONS_KEY = "mastra__versions";
61
+ export declare const MASTRA_VERSIONS_KEY = "mastra__versions";
62
62
  /**
63
63
  * Reserved key for storing the raw auth token from the incoming request.
64
64
  * Used by the editor to forward authentication when connecting to MCP servers
65
65
  * that require the same auth as the Mastra server itself.
66
66
  */
67
- declare const MASTRA_AUTH_TOKEN_KEY = "mastra__authToken";
67
+ export declare const MASTRA_AUTH_TOKEN_KEY = "mastra__authToken";
68
68
  /**
69
69
  * Reserved key carrying a delegating agent's `MastraMemory` into a delegated
70
70
  * run, so a sub-agent without its own memory can persist that run's transcript
@@ -75,7 +75,7 @@ declare const MASTRA_AUTH_TOKEN_KEY = "mastra__authToken";
75
75
  * from the durable request-context snapshot and is not copied into further
76
76
  * nested delegated runs. Internal to delegation — do not set it yourself.
77
77
  */
78
- declare const MASTRA_INHERITED_MEMORY_KEY = "mastra__inheritedMemory";
78
+ export declare const MASTRA_INHERITED_MEMORY_KEY = "mastra__inheritedMemory";
79
79
  /**
80
80
  * Reserved key naming who sent a user message: `{ id, name?, avatarUrl? }`.
81
81
  * Set by the host that authenticated the request; the agent-controller copies
@@ -88,7 +88,7 @@ declare const MASTRA_INHERITED_MEMORY_KEY = "mastra__inheritedMemory";
88
88
  * requestContext.setRaw(MASTRA_MESSAGE_AUTHOR_KEY, { id: user.id, name: user.name, avatarUrl: user.avatarUrl });
89
89
  * ```
90
90
  */
91
- declare const MASTRA_MESSAGE_AUTHOR_KEY = "mastra__messageAuthor";
91
+ export declare const MASTRA_MESSAGE_AUTHOR_KEY = "mastra__messageAuthor";
92
92
  /**
93
93
  * Whether a request-context key is reserved for Mastra itself.
94
94
  *
@@ -98,18 +98,18 @@ declare const MASTRA_MESSAGE_AUTHOR_KEY = "mastra__messageAuthor";
98
98
  * Reserved keys are framework state rather than caller-provided data, so they
99
99
  * are left out of span serialization.
100
100
  */
101
- declare function isReservedRequestContextKey(key: string): boolean;
102
- type VersionSelector = {
101
+ export declare function isReservedRequestContextKey(key: string): boolean;
102
+ export type VersionSelector = {
103
103
  versionId: string;
104
104
  } | {
105
105
  status: 'draft' | 'published';
106
106
  };
107
- type VersionOverrides = {
107
+ export type VersionOverrides = {
108
108
  agents?: Record<string, VersionSelector>;
109
109
  /** Fallback status for sub-agents (and future primitives) without an explicit entry. */
110
110
  defaultStatus?: 'draft' | 'published';
111
111
  };
112
- declare function mergeVersionOverrides(base?: VersionOverrides, overrides?: VersionOverrides): VersionOverrides | undefined;
112
+ export declare function mergeVersionOverrides(base?: VersionOverrides, overrides?: VersionOverrides): VersionOverrides | undefined;
113
113
  /**
114
114
  * Carries typed, request-specific values through agents, tools, and workflows.
115
115
  * Pass the instance as `requestContext` when starting an operation.
@@ -131,7 +131,7 @@ declare function mergeVersionOverrides(base?: VersionOverrides, overrides?: Vers
131
131
  * @see [Request context documentation](https://mastra.ai/docs/server/request-context)
132
132
  * if packaged docs are unavailable.
133
133
  */
134
- declare class RequestContext<Values extends Record<string, any> | unknown = unknown> {
134
+ export declare class RequestContext<Values extends Record<string, any> | unknown = unknown> {
135
135
  private registry;
136
136
  constructor(iterable?: Values extends Record<string, any> ? RecordToTuple<Partial<Values>> : Iterable<readonly [string, unknown]>);
137
137
  /**
@@ -282,5 +282,5 @@ declare class RequestContext<Values extends Record<string, any> | unknown = unkn
282
282
  get all(): Values extends Record<string, any> ? Values : Record<string, any>;
283
283
  }
284
284
  //#endregion
285
- export { MASTRA_AUTH_TOKEN_KEY, MASTRA_INHERITED_MEMORY_KEY, MASTRA_MESSAGE_AUTHOR_KEY, MASTRA_RESOURCE_ID_KEY, MASTRA_SCOPES_KEY, MASTRA_THREAD_ID_KEY, MASTRA_VERSIONS_KEY, RequestContext, VersionOverrides, VersionSelector, isReservedRequestContextKey, mergeVersionOverrides };
285
+ export {};
286
286
  //# sourceMappingURL=index.d.ts.map
@@ -2,7 +2,7 @@ import { RequestContext } from "../request-context/index.js";
2
2
  import { ToolsInput } from "../types/index.js";
3
3
  import * as z$1 from "../../../zod/v4/index.cjs";
4
4
  //#region src/routes/index.d.ts
5
- interface OpenAPIRoute {
5
+ export interface OpenAPIRoute {
6
6
  summary?: string;
7
7
  description?: string;
8
8
  tags?: string[];
@@ -41,16 +41,16 @@ interface RouteOpenAPIConfig {
41
41
  responseSchema?: z$1.ZodSchema;
42
42
  deprecated?: boolean;
43
43
  }
44
- declare function generateRouteOpenAPI({ method, path, summary, description, tags, pathParamSchema, queryParamSchema, bodySchema, responseSchema, deprecated }: RouteOpenAPIConfig): OpenAPIRoute;
45
- type ResponseType = 'stream' | 'json' | 'datastream-response' | 'mcp-http' | 'mcp-sse';
46
- type InferParams<TPathSchema extends z$1.ZodTypeAny | undefined, TQuerySchema extends z$1.ZodTypeAny | undefined, TBodySchema extends z$1.ZodTypeAny | undefined> = (TPathSchema extends z$1.ZodTypeAny ? z$1.infer<TPathSchema> : {}) & (TQuerySchema extends z$1.ZodTypeAny ? z$1.infer<TQuerySchema> : {}) & (TBodySchema extends z$1.ZodTypeAny ? z$1.infer<TBodySchema> : {});
47
- interface RouteSchemas<TPathSchema = unknown, TQuerySchema = unknown, TBodySchema = unknown, TResponseSchema = unknown> {
44
+ export declare function generateRouteOpenAPI({ method, path, summary, description, tags, pathParamSchema, queryParamSchema, bodySchema, responseSchema, deprecated }: RouteOpenAPIConfig): OpenAPIRoute;
45
+ export type ResponseType = 'stream' | 'json' | 'datastream-response' | 'mcp-http' | 'mcp-sse';
46
+ export type InferParams<TPathSchema extends z$1.ZodTypeAny | undefined, TQuerySchema extends z$1.ZodTypeAny | undefined, TBodySchema extends z$1.ZodTypeAny | undefined> = (TPathSchema extends z$1.ZodTypeAny ? z$1.infer<TPathSchema> : {}) & (TQuerySchema extends z$1.ZodTypeAny ? z$1.infer<TQuerySchema> : {}) & (TBodySchema extends z$1.ZodTypeAny ? z$1.infer<TBodySchema> : {});
47
+ export interface RouteSchemas<TPathSchema = unknown, TQuerySchema = unknown, TBodySchema = unknown, TResponseSchema = unknown> {
48
48
  readonly pathParams: TPathSchema;
49
49
  readonly queryParams: TQuerySchema;
50
50
  readonly body: TBodySchema;
51
51
  readonly response: TResponseSchema;
52
52
  }
53
- type ServerContext = {
53
+ export type ServerContext = {
54
54
  mastra: any;
55
55
  requestContext: RequestContext;
56
56
  registeredTools?: ToolsInput;
@@ -58,12 +58,12 @@ type ServerContext = {
58
58
  abortSignal: AbortSignal;
59
59
  routePrefix?: string;
60
60
  };
61
- type ServerRouteHandler<TParams = Record<string, unknown>, TResponse = unknown, TResponseType extends ResponseType = 'json'> = (params: TParams & ServerContext) => Promise<TResponseType extends 'stream' ? ReadableStream : TResponseType extends 'datastream-response' ? Response : TResponse>;
62
- type ValidationErrorHook = (error: z$1.ZodError) => {
61
+ export type ServerRouteHandler<TParams = Record<string, unknown>, TResponse = unknown, TResponseType extends ResponseType = 'json'> = (params: TParams & ServerContext) => Promise<TResponseType extends 'stream' ? ReadableStream : TResponseType extends 'datastream-response' ? Response : TResponse>;
62
+ export type ValidationErrorHook = (error: z$1.ZodError) => {
63
63
  status?: number;
64
64
  body?: unknown;
65
65
  } | void;
66
- type ServerRoute<TParams = Record<string, unknown>, TResponse = unknown, TResponseType extends ResponseType = ResponseType, TSchemas extends RouteSchemas = RouteSchemas, TMethod extends string = string, TPath extends string = string> = {
66
+ export type ServerRoute<TParams = Record<string, unknown>, TResponse = unknown, TResponseType extends ResponseType = ResponseType, TSchemas extends RouteSchemas = RouteSchemas, TMethod extends string = string, TPath extends string = string> = {
67
67
  method: TMethod;
68
68
  path: TPath;
69
69
  responseType: TResponseType;
@@ -104,8 +104,8 @@ interface RouteConfig<TPathSchema extends z$1.ZodTypeAny | undefined = undefined
104
104
  fga?: any;
105
105
  onValidationError?: ValidationErrorHook;
106
106
  }
107
- declare function createRoute<TPathSchema extends z$1.ZodTypeAny | undefined = undefined, TQuerySchema extends z$1.ZodTypeAny | undefined = undefined, TBodySchema extends z$1.ZodTypeAny | undefined = undefined, TResponseSchema extends z$1.ZodTypeAny | undefined = undefined, TResponseType extends ResponseType = 'json', TMethod extends string = string, TPath extends string = string>(config: RouteConfig<TPathSchema, TQuerySchema, TBodySchema, TResponseSchema, TResponseType, TMethod, TPath>): ServerRoute<InferParams<TPathSchema, TQuerySchema, TBodySchema>, TResponseSchema extends z$1.ZodTypeAny ? z$1.infer<TResponseSchema> : unknown, TResponseType, RouteSchemas<TPathSchema, TQuerySchema, TBodySchema, TResponseSchema>, TMethod, TPath>;
108
- declare function createPublicRoute<TPathSchema extends z$1.ZodTypeAny | undefined = undefined, TQuerySchema extends z$1.ZodTypeAny | undefined = undefined, TBodySchema extends z$1.ZodTypeAny | undefined = undefined, TResponseSchema extends z$1.ZodTypeAny | undefined = undefined, TResponseType extends ResponseType = 'json', TMethod extends string = string, TPath extends string = string>(config: Omit<RouteConfig<TPathSchema, TQuerySchema, TBodySchema, TResponseSchema, TResponseType, TMethod, TPath>, 'requiresAuth'>): ServerRoute<InferParams<TPathSchema, TQuerySchema, TBodySchema>, TResponseSchema extends z$1.ZodTypeAny ? z$1.infer<TResponseSchema> : unknown, TResponseType, RouteSchemas<TPathSchema, TQuerySchema, TBodySchema, TResponseSchema>, TMethod, TPath>;
107
+ export declare function createRoute<TPathSchema extends z$1.ZodTypeAny | undefined = undefined, TQuerySchema extends z$1.ZodTypeAny | undefined = undefined, TBodySchema extends z$1.ZodTypeAny | undefined = undefined, TResponseSchema extends z$1.ZodTypeAny | undefined = undefined, TResponseType extends ResponseType = 'json', TMethod extends string = string, TPath extends string = string>(config: RouteConfig<TPathSchema, TQuerySchema, TBodySchema, TResponseSchema, TResponseType, TMethod, TPath>): ServerRoute<InferParams<TPathSchema, TQuerySchema, TBodySchema>, TResponseSchema extends z$1.ZodTypeAny ? z$1.infer<TResponseSchema> : unknown, TResponseType, RouteSchemas<TPathSchema, TQuerySchema, TBodySchema, TResponseSchema>, TMethod, TPath>;
108
+ export declare function createPublicRoute<TPathSchema extends z$1.ZodTypeAny | undefined = undefined, TQuerySchema extends z$1.ZodTypeAny | undefined = undefined, TBodySchema extends z$1.ZodTypeAny | undefined = undefined, TResponseSchema extends z$1.ZodTypeAny | undefined = undefined, TResponseType extends ResponseType = 'json', TMethod extends string = string, TPath extends string = string>(config: Omit<RouteConfig<TPathSchema, TQuerySchema, TBodySchema, TResponseSchema, TResponseType, TMethod, TPath>, 'requiresAuth'>): ServerRoute<InferParams<TPathSchema, TQuerySchema, TBodySchema>, TResponseSchema extends z$1.ZodTypeAny ? z$1.infer<TResponseSchema> : unknown, TResponseType, RouteSchemas<TPathSchema, TQuerySchema, TBodySchema, TResponseSchema>, TMethod, TPath>;
109
109
  //#endregion
110
- export { InferParams, OpenAPIRoute, ResponseType, RouteSchemas, ServerContext, ServerRoute, ServerRouteHandler, ValidationErrorHook, createPublicRoute, createRoute, generateRouteOpenAPI };
110
+ export {};
111
111
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,4 @@
1
1
  //#region src/types/index.d.ts
2
- type ToolsInput = Record<string, any>;
2
+ export type ToolsInput = Record<string, any>;
3
3
  //#endregion
4
- export { ToolsInput };
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -29,7 +29,7 @@ var agent_builder_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll
29
29
  });
30
30
  let agentBuilderWorkflowsPromise;
31
31
  async function loadAgentBuilderWorkflows() {
32
- agentBuilderWorkflowsPromise ??= Promise.resolve().then(() => require("./dist-B-bEVWlJ.cjs")).then((mod) => mod.agentBuilderWorkflows);
32
+ agentBuilderWorkflowsPromise ??= Promise.resolve().then(() => require("./dist-B3KkuNCj.cjs")).then((mod) => mod.agentBuilderWorkflows);
33
33
  return agentBuilderWorkflowsPromise;
34
34
  }
35
35
  async function registerAgentBuilderWorkflows(mastra) {
@@ -725,4 +725,4 @@ Object.defineProperty(exports, "agent_builder_exports", {
725
725
  }
726
726
  });
727
727
 
728
- //# sourceMappingURL=agent-builder-CuBD1tpv.cjs.map
728
+ //# sourceMappingURL=agent-builder-BkPIfCgW.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-builder-CuBD1tpv.cjs","names":["createRoute","listWorkflowsResponseSchema","handleError","actionIdPathParams","workflowInfoSchema","WorkflowRegistry","HTTPException","listWorkflowRunsQuerySchema","workflowRunsResponseSchema","actionRunPathParams","workflowRunResultQuerySchema","workflowRunResultSchema","optionalRunIdSchema","createWorkflowRunResponseSchema","runIdSchema","streamAgentBuilderBodySchema","streamResponseSchema","startAsyncAgentBuilderBodySchema","workflowExecutionResultSchema","workflowControlResponseSchema","resumeAgentBuilderBodySchema","streamLegacyAgentBuilderBodySchema"],"sources":["../src/server/handlers/agent-builder.ts"],"sourcesContent":["import type { agentBuilderWorkflows as agentBuilderWorkflowsType } from '@mastra/agent-builder';\nimport { HTTPException } from '../http-exception';\nimport {\n actionIdPathParams,\n actionRunPathParams,\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n resumeAgentBuilderBodySchema,\n streamAgentBuilderBodySchema,\n startAsyncAgentBuilderBodySchema,\n workflowExecutionResultSchema,\n workflowControlResponseSchema,\n workflowRunsResponseSchema,\n workflowInfoSchema,\n listWorkflowsResponseSchema,\n streamLegacyAgentBuilderBodySchema,\n workflowRunResultSchema,\n workflowRunResultQuerySchema,\n} from '../schemas/agent-builder';\nimport { streamResponseSchema } from '../schemas/agents';\nimport { optionalRunIdSchema, runIdSchema } from '../schemas/common';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\nimport * as workflows from './workflows';\n\ntype AgentBuilderWorkflows = typeof agentBuilderWorkflowsType;\n\nlet agentBuilderWorkflowsPromise: Promise<AgentBuilderWorkflows> | undefined;\n\nasync function loadAgentBuilderWorkflows(): Promise<AgentBuilderWorkflows> {\n agentBuilderWorkflowsPromise ??= import('@mastra/agent-builder').then(mod => mod.agentBuilderWorkflows);\n return agentBuilderWorkflowsPromise;\n}\n\nasync function registerAgentBuilderWorkflows(\n mastra: Parameters<typeof WorkflowRegistry.registerTemporaryWorkflows>[1],\n) {\n const agentBuilderWorkflows = await loadAgentBuilderWorkflows();\n WorkflowRegistry.registerTemporaryWorkflows(agentBuilderWorkflows, mastra);\n return agentBuilderWorkflows;\n}\n\n// ============================================================================\n// Route Definitions (handlers call workflow route handlers with transformed parameters)\n// ============================================================================\n\nexport const LIST_AGENT_BUILDER_ACTIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder',\n responseType: 'json',\n responseSchema: listWorkflowsResponseSchema,\n summary: 'List agent-builder actions',\n description: 'Returns a list of all available agent-builder actions',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n logger.info('Listing agent builder actions');\n\n // Call workflow list handler\n return await workflows.LIST_WORKFLOWS_ROUTE.handler(ctx);\n } catch (error) {\n logger.error('Error listing agent builder actions', { error });\n return handleError(error, 'Error getting agent builder workflows');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n responseSchema: workflowInfoSchema,\n summary: 'Get action by ID',\n description: 'Returns details for a specific agent-builder action',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId } = ctx;\n const logger = mastra.getLogger();\n try {\n const agentBuilderWorkflows = await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, {\n message: `Invalid agent-builder action: ${actionId}. Valid actions are: ${Object.keys(agentBuilderWorkflows).join(', ')}`,\n });\n }\n\n logger.info('Getting agent builder action by ID', { actionId });\n\n return await workflows.GET_WORKFLOW_BY_ID_ROUTE.handler({ ...ctx, workflowId: actionId });\n } catch (error) {\n logger.error('Error getting agent builder action by ID', { error, actionId });\n return handleError(error, 'Error getting agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId/runs',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: listWorkflowRunsQuerySchema,\n responseSchema: workflowRunsResponseSchema,\n summary: 'List action runs',\n description: 'Returns a paginated list of execution runs for the specified action',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Listing agent builder action runs', { actionId });\n\n return await workflows.LIST_WORKFLOW_RUNS_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error listing agent builder action runs', { error, actionId });\n return handleError(error, 'Error getting agent builder action runs');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId/runs/:runId',\n responseType: 'json',\n pathParamSchema: actionRunPathParams,\n queryParamSchema: workflowRunResultQuerySchema,\n responseSchema: workflowRunResultSchema,\n summary: 'Get action run by ID',\n description:\n 'Returns details for a specific action run with metadata and processed execution state. Use the fields query parameter to reduce payload size.',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Getting agent builder action run by ID', { actionId, runId });\n\n return await workflows.GET_WORKFLOW_RUN_BY_ID_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error getting agent builder action run', { error, actionId, runId });\n return handleError(error, 'Error getting agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/create-run',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Create action run',\n description: 'Creates a new action execution instance with an optional custom run ID',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Creating agent builder action run', { actionId, runId });\n\n return await workflows.CREATE_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error creating agent builder action run', { error, actionId });\n return handleError(error, 'Error creating agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/stream',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Stream action execution',\n description: 'Executes an action and streams the results in real-time',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Streaming agent builder action', { actionId, runId });\n\n return await workflows.STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error streaming agent builder action', { error, actionId });\n return handleError(error, 'Error streaming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/start-async',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: startAsyncAgentBuilderBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Start action asynchronously',\n description: 'Starts an action execution asynchronously without streaming results',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Starting agent builder action asynchronously', { actionId, runId });\n\n return await workflows.START_ASYNC_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error starting agent builder action asynchronously', { error, actionId });\n return handleError(error, 'Error starting agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const START_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/start',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: startAsyncAgentBuilderBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Start specific action run',\n description: 'Starts execution of a specific action run by ID',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Starting specific agent builder action run', { actionId, runId });\n\n return await workflows.START_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error starting agent builder action run', { error, actionId });\n return handleError(error, 'Error starting agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/observe',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe action stream',\n description: 'Observes and streams updates from an already running action execution',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Observing agent builder action stream', { actionId, runId });\n\n return await workflows.OBSERVE_STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error observing agent builder action stream', { error, actionId });\n return handleError(error, 'Error observing agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-async',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Resume action asynchronously',\n description: 'Resumes a suspended action execution asynchronously without streaming',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action asynchronously', { actionId, runId, step });\n\n return await workflows.RESUME_ASYNC_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action asynchronously', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\n/**\n * Fire-and-forget resume for agent-builder actions: returns immediately with the runId without\n * waiting for completion. Delegates to the workflows `resume-no-wait` route.\n *\n * TODO(v2): fold this behavior into the `resume-async` route in Mastra v2 and remove this route.\n * Kept separate in v1 to avoid breaking the existing `resume-async` response contract.\n */\nexport const RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-no-wait',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Resume action without waiting',\n description:\n 'Resumes a suspended action execution without waiting (fire-and-forget) and returns immediately with the runId. The action continues executing in the background.',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action without waiting', { actionId, runId, step });\n\n return await workflows.RESUME_NO_WAIT_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action without waiting', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Resume action',\n description: 'Resumes a suspended action execution from a specific step',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action', { actionId, runId, step });\n\n return await workflows.RESUME_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-stream',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Resume action stream',\n description: 'Resumes a suspended action execution and continues streaming results',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action stream', { actionId, runId, step });\n\n return await workflows.RESUME_STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action stream', { error, actionId });\n return handleError(error, 'Error resuming agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/runs/:runId/cancel',\n responseType: 'json',\n pathParamSchema: actionRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Cancel action run',\n description: 'Cancels an in-progress action execution',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Cancelling agent builder action run', { actionId, runId });\n\n return await workflows.CANCEL_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error cancelling agent builder action run', { error, actionId });\n return handleError(error, 'Error cancelling agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\n// Legacy routes (deprecated)\nexport const STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/stream-legacy',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamLegacyAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Stream agent-builder action with legacy format',\n description:\n 'Legacy endpoint for streaming agent-builder action execution. Use /agent-builder/:actionId/stream instead.',\n tags: ['Agent Builder', 'Legacy'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Streaming agent builder action (legacy)', { actionId, runId });\n\n return await workflows.STREAM_LEGACY_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error streaming agent builder action (legacy)', { error, actionId });\n return handleError(error, 'Error streaming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/observe-stream-legacy',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Observe agent-builder action stream with legacy format',\n description:\n 'Legacy endpoint for observing agent-builder action stream. Use /agent-builder/:actionId/observe instead.',\n tags: ['Agent Builder', 'Legacy'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Observing agent builder action stream (legacy)', { actionId, runId });\n\n return await workflows.OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error observing agent builder action stream (legacy)', { error, actionId });\n return handleError(error, 'Error observing agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAI;AAEJ,eAAe,4BAA4D;CACzE,iCAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAiC,qBAAA,CAAA,CAAA,CAAgC,MAAK,QAAO,IAAI,qBAAqB;CACtG,OAAO;AACT;AAEA,eAAe,8BACb,QACA;CACA,MAAM,wBAAwB,MAAM,0BAA0B;CAC9D,cAAA,iBAAiB,2BAA2B,uBAAuB,MAAM;CACzE,OAAO;AACT;AAMA,MAAa,mCAAmCA,sBAAAA,YAAY;CAC1D,QAAQ;CACR,MAAM;CACN,cAAc;CACd,gBAAgBC,kBAAAA;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,eAAe;CACtB,cAAc;CACd,SAAS,OAAM,QAAO;EACpB,MAAM,EAAE,WAAW;EACnB,MAAM,SAAS,OAAO,UAAU;EAChC,IAAI;GACF,MAAM,8BAA8B,MAAM;GAC1C,OAAO,KAAK,+BAA+B;GAG3C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,UAAU;GACR,cAAA,iBAAiB,QAAQ;EAC3B;CACF;AACF,CAAC;AAED,MAAa,mDAAmDF,sBAAAA,YAAY;CAC1E,QAAQ;CACR,MAAM;CACN,cAAc;CACd,iBAAiBG,sBAAAA;CACjB,kBAAkBW,eAAAA;CAClB,gBAAgBE,eAAAA;CAChB,SAAS;CACT,aACE;CACF,MAAM,CAAC,iBAAiB,QAAQ;CAChC,cAAc;CACd,SAAS,OAAM,QAAO;EACpB,MAAM,EAAE,QAAQ,UAAU,UAAU;EACpC,MAAM,SAAS,OAAO,UAAU;EAChC,IAAI;GACF,MAAM,8BAA8B,MAAM;GAE1C,IAAI,YAAY,CAACX,cAAAA,iBAAiB,uBAAuB,QAAQ,GAC/D,MAAM,IAAIC,uBAAAA,cAAc,KAAK,EAAE,SAAS,iCAAiC,WAAW,CAAC;GAGvF,OAAO,KAAK,kDAAkD;IAAE;IAAU;GAAM,CAAC;GAEjF,OAAO,MAAA,oBAAA,qCAAqD,QAAQ;IAClE,GAAG;IACH,YAAY;GACd,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,wDAAwD;IAAE;IAAO;GAAS,CAAC;GACxF,OAAOJ,8BAAAA,YAAY,OAAO,6CAA6C;EACzE,UAAU;GACR,cAAA,iBAAiB,QAAQ;EAC3B;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"agent-builder-BkPIfCgW.cjs","names":["createRoute","listWorkflowsResponseSchema","handleError","actionIdPathParams","workflowInfoSchema","WorkflowRegistry","HTTPException","listWorkflowRunsQuerySchema","workflowRunsResponseSchema","actionRunPathParams","workflowRunResultQuerySchema","workflowRunResultSchema","optionalRunIdSchema","createWorkflowRunResponseSchema","runIdSchema","streamAgentBuilderBodySchema","streamResponseSchema","startAsyncAgentBuilderBodySchema","workflowExecutionResultSchema","workflowControlResponseSchema","resumeAgentBuilderBodySchema","streamLegacyAgentBuilderBodySchema"],"sources":["../src/server/handlers/agent-builder.ts"],"sourcesContent":["import type { agentBuilderWorkflows as agentBuilderWorkflowsType } from '@mastra/agent-builder';\nimport { HTTPException } from '../http-exception';\nimport {\n actionIdPathParams,\n actionRunPathParams,\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n resumeAgentBuilderBodySchema,\n streamAgentBuilderBodySchema,\n startAsyncAgentBuilderBodySchema,\n workflowExecutionResultSchema,\n workflowControlResponseSchema,\n workflowRunsResponseSchema,\n workflowInfoSchema,\n listWorkflowsResponseSchema,\n streamLegacyAgentBuilderBodySchema,\n workflowRunResultSchema,\n workflowRunResultQuerySchema,\n} from '../schemas/agent-builder';\nimport { streamResponseSchema } from '../schemas/agents';\nimport { optionalRunIdSchema, runIdSchema } from '../schemas/common';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\nimport * as workflows from './workflows';\n\ntype AgentBuilderWorkflows = typeof agentBuilderWorkflowsType;\n\nlet agentBuilderWorkflowsPromise: Promise<AgentBuilderWorkflows> | undefined;\n\nasync function loadAgentBuilderWorkflows(): Promise<AgentBuilderWorkflows> {\n agentBuilderWorkflowsPromise ??= import('@mastra/agent-builder').then(mod => mod.agentBuilderWorkflows);\n return agentBuilderWorkflowsPromise;\n}\n\nasync function registerAgentBuilderWorkflows(\n mastra: Parameters<typeof WorkflowRegistry.registerTemporaryWorkflows>[1],\n) {\n const agentBuilderWorkflows = await loadAgentBuilderWorkflows();\n WorkflowRegistry.registerTemporaryWorkflows(agentBuilderWorkflows, mastra);\n return agentBuilderWorkflows;\n}\n\n// ============================================================================\n// Route Definitions (handlers call workflow route handlers with transformed parameters)\n// ============================================================================\n\nexport const LIST_AGENT_BUILDER_ACTIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder',\n responseType: 'json',\n responseSchema: listWorkflowsResponseSchema,\n summary: 'List agent-builder actions',\n description: 'Returns a list of all available agent-builder actions',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n logger.info('Listing agent builder actions');\n\n // Call workflow list handler\n return await workflows.LIST_WORKFLOWS_ROUTE.handler(ctx);\n } catch (error) {\n logger.error('Error listing agent builder actions', { error });\n return handleError(error, 'Error getting agent builder workflows');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n responseSchema: workflowInfoSchema,\n summary: 'Get action by ID',\n description: 'Returns details for a specific agent-builder action',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId } = ctx;\n const logger = mastra.getLogger();\n try {\n const agentBuilderWorkflows = await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, {\n message: `Invalid agent-builder action: ${actionId}. Valid actions are: ${Object.keys(agentBuilderWorkflows).join(', ')}`,\n });\n }\n\n logger.info('Getting agent builder action by ID', { actionId });\n\n return await workflows.GET_WORKFLOW_BY_ID_ROUTE.handler({ ...ctx, workflowId: actionId });\n } catch (error) {\n logger.error('Error getting agent builder action by ID', { error, actionId });\n return handleError(error, 'Error getting agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId/runs',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: listWorkflowRunsQuerySchema,\n responseSchema: workflowRunsResponseSchema,\n summary: 'List action runs',\n description: 'Returns a paginated list of execution runs for the specified action',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Listing agent builder action runs', { actionId });\n\n return await workflows.LIST_WORKFLOW_RUNS_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error listing agent builder action runs', { error, actionId });\n return handleError(error, 'Error getting agent builder action runs');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId/runs/:runId',\n responseType: 'json',\n pathParamSchema: actionRunPathParams,\n queryParamSchema: workflowRunResultQuerySchema,\n responseSchema: workflowRunResultSchema,\n summary: 'Get action run by ID',\n description:\n 'Returns details for a specific action run with metadata and processed execution state. Use the fields query parameter to reduce payload size.',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Getting agent builder action run by ID', { actionId, runId });\n\n return await workflows.GET_WORKFLOW_RUN_BY_ID_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error getting agent builder action run', { error, actionId, runId });\n return handleError(error, 'Error getting agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/create-run',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Create action run',\n description: 'Creates a new action execution instance with an optional custom run ID',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Creating agent builder action run', { actionId, runId });\n\n return await workflows.CREATE_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error creating agent builder action run', { error, actionId });\n return handleError(error, 'Error creating agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/stream',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Stream action execution',\n description: 'Executes an action and streams the results in real-time',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Streaming agent builder action', { actionId, runId });\n\n return await workflows.STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error streaming agent builder action', { error, actionId });\n return handleError(error, 'Error streaming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/start-async',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: startAsyncAgentBuilderBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Start action asynchronously',\n description: 'Starts an action execution asynchronously without streaming results',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Starting agent builder action asynchronously', { actionId, runId });\n\n return await workflows.START_ASYNC_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error starting agent builder action asynchronously', { error, actionId });\n return handleError(error, 'Error starting agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const START_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/start',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: startAsyncAgentBuilderBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Start specific action run',\n description: 'Starts execution of a specific action run by ID',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Starting specific agent builder action run', { actionId, runId });\n\n return await workflows.START_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error starting agent builder action run', { error, actionId });\n return handleError(error, 'Error starting agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/observe',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe action stream',\n description: 'Observes and streams updates from an already running action execution',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Observing agent builder action stream', { actionId, runId });\n\n return await workflows.OBSERVE_STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error observing agent builder action stream', { error, actionId });\n return handleError(error, 'Error observing agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-async',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Resume action asynchronously',\n description: 'Resumes a suspended action execution asynchronously without streaming',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action asynchronously', { actionId, runId, step });\n\n return await workflows.RESUME_ASYNC_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action asynchronously', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\n/**\n * Fire-and-forget resume for agent-builder actions: returns immediately with the runId without\n * waiting for completion. Delegates to the workflows `resume-no-wait` route.\n *\n * TODO(v2): fold this behavior into the `resume-async` route in Mastra v2 and remove this route.\n * Kept separate in v1 to avoid breaking the existing `resume-async` response contract.\n */\nexport const RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-no-wait',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Resume action without waiting',\n description:\n 'Resumes a suspended action execution without waiting (fire-and-forget) and returns immediately with the runId. The action continues executing in the background.',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action without waiting', { actionId, runId, step });\n\n return await workflows.RESUME_NO_WAIT_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action without waiting', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Resume action',\n description: 'Resumes a suspended action execution from a specific step',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action', { actionId, runId, step });\n\n return await workflows.RESUME_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-stream',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Resume action stream',\n description: 'Resumes a suspended action execution and continues streaming results',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action stream', { actionId, runId, step });\n\n return await workflows.RESUME_STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action stream', { error, actionId });\n return handleError(error, 'Error resuming agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/runs/:runId/cancel',\n responseType: 'json',\n pathParamSchema: actionRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Cancel action run',\n description: 'Cancels an in-progress action execution',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Cancelling agent builder action run', { actionId, runId });\n\n return await workflows.CANCEL_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error cancelling agent builder action run', { error, actionId });\n return handleError(error, 'Error cancelling agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\n// Legacy routes (deprecated)\nexport const STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/stream-legacy',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamLegacyAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Stream agent-builder action with legacy format',\n description:\n 'Legacy endpoint for streaming agent-builder action execution. Use /agent-builder/:actionId/stream instead.',\n tags: ['Agent Builder', 'Legacy'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Streaming agent builder action (legacy)', { actionId, runId });\n\n return await workflows.STREAM_LEGACY_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error streaming agent builder action (legacy)', { error, actionId });\n return handleError(error, 'Error streaming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/observe-stream-legacy',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Observe agent-builder action stream with legacy format',\n description:\n 'Legacy endpoint for observing agent-builder action stream. Use /agent-builder/:actionId/observe instead.',\n tags: ['Agent Builder', 'Legacy'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Observing agent builder action stream (legacy)', { actionId, runId });\n\n return await workflows.OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error observing agent builder action stream (legacy)', { error, actionId });\n return handleError(error, 'Error observing agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAI;AAEJ,eAAe,4BAA4D;CACzE,iCAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAiC,qBAAA,CAAA,CAAA,CAAgC,MAAK,QAAO,IAAI,qBAAqB;CACtG,OAAO;AACT;AAEA,eAAe,8BACb,QACA;CACA,MAAM,wBAAwB,MAAM,0BAA0B;CAC9D,cAAA,iBAAiB,2BAA2B,uBAAuB,MAAM;CACzE,OAAO;AACT;AAMA,MAAa,mCAAmCA,sBAAAA,YAAY;CAC1D,QAAQ;CACR,MAAM;CACN,cAAc;CACd,gBAAgBC,kBAAAA;CAChB,SAAS;CACT,aAAa;CAC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A,oBAAA,6BAA6C,QAAQ;IAC1D,GAAG;IACH,YAAY;IACZ;GACF,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,iDAAiD;IAAE;IAAO;GAAS,CAAC;GACjF,OAAOJ,8BAAAA,YAAY,OAAO,sCAAsC;EAClE,UAAU;GACR,cAAA,iBAAiB,QAAQ;EAC3B;CACF;AACF,CAAC;AAED,MAAa,mDAAmDF,sBAAAA,YAAY;CAC1E,QAAQ;CACR,MAAM;CACN,cAAc;CACd,iBAAiBG,sBAAAA;CACjB,kBAAkBW,eAAAA;CAClB,gBAAgBE,eAAAA;CAChB,SAAS;CACT,aACE;CACF,MAAM,CAAC,iBAAiB,QAAQ;CAChC,cAAc;CACd,SAAS,OAAM,QAAO;EACpB,MAAM,EAAE,QAAQ,UAAU,UAAU;EACpC,MAAM,SAAS,OAAO,UAAU;EAChC,IAAI;GACF,MAAM,8BAA8B,MAAM;GAE1C,IAAI,YAAY,CAACX,cAAAA,iBAAiB,uBAAuB,QAAQ,GAC/D,MAAM,IAAIC,uBAAAA,cAAc,KAAK,EAAE,SAAS,iCAAiC,WAAW,CAAC;GAGvF,OAAO,KAAK,kDAAkD;IAAE;IAAU;GAAM,CAAC;GAEjF,OAAO,MAAA,oBAAA,qCAAqD,QAAQ;IAClE,GAAG;IACH,YAAY;GACd,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,wDAAwD;IAAE;IAAO;GAAS,CAAC;GACxF,OAAOJ,8BAAAA,YAAY,OAAO,6CAA6C;EACzE,UAAU;GACR,cAAA,iBAAiB,QAAQ;EAC3B;CACF;AACF,CAAC"}
@@ -29,7 +29,7 @@ var agent_builder_exports = /* @__PURE__ */ __exportAll({
29
29
  });
30
30
  let agentBuilderWorkflowsPromise;
31
31
  async function loadAgentBuilderWorkflows() {
32
- agentBuilderWorkflowsPromise ??= import("./dist-k77XQGUn.js").then((mod) => mod.agentBuilderWorkflows);
32
+ agentBuilderWorkflowsPromise ??= import("./dist-DqKW0v-Y.js").then((mod) => mod.agentBuilderWorkflows);
33
33
  return agentBuilderWorkflowsPromise;
34
34
  }
35
35
  async function registerAgentBuilderWorkflows(mastra) {
@@ -624,4 +624,4 @@ const OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({
624
624
  //#endregion
625
625
  export { agent_builder_exports as _, LIST_AGENT_BUILDER_ACTIONS_ROUTE as a, OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE as c, RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE as d, RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE as f, STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE as g, STREAM_AGENT_BUILDER_ACTION_ROUTE as h, GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE as i, RESUME_AGENT_BUILDER_ACTION_ROUTE as l, START_ASYNC_AGENT_BUILDER_ACTION_ROUTE as m, CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE as n, LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE as o, START_AGENT_BUILDER_ACTION_RUN_ROUTE as p, GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE as r, OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE as s, CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE as t, RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE as u };
626
626
 
627
- //# sourceMappingURL=agent-builder-VhM8ADW-.js.map
627
+ //# sourceMappingURL=agent-builder-DvxYJR85.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-builder-VhM8ADW-.js","names":[],"sources":["../src/server/handlers/agent-builder.ts"],"sourcesContent":["import type { agentBuilderWorkflows as agentBuilderWorkflowsType } from '@mastra/agent-builder';\nimport { HTTPException } from '../http-exception';\nimport {\n actionIdPathParams,\n actionRunPathParams,\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n resumeAgentBuilderBodySchema,\n streamAgentBuilderBodySchema,\n startAsyncAgentBuilderBodySchema,\n workflowExecutionResultSchema,\n workflowControlResponseSchema,\n workflowRunsResponseSchema,\n workflowInfoSchema,\n listWorkflowsResponseSchema,\n streamLegacyAgentBuilderBodySchema,\n workflowRunResultSchema,\n workflowRunResultQuerySchema,\n} from '../schemas/agent-builder';\nimport { streamResponseSchema } from '../schemas/agents';\nimport { optionalRunIdSchema, runIdSchema } from '../schemas/common';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\nimport * as workflows from './workflows';\n\ntype AgentBuilderWorkflows = typeof agentBuilderWorkflowsType;\n\nlet agentBuilderWorkflowsPromise: Promise<AgentBuilderWorkflows> | undefined;\n\nasync function loadAgentBuilderWorkflows(): Promise<AgentBuilderWorkflows> {\n agentBuilderWorkflowsPromise ??= import('@mastra/agent-builder').then(mod => mod.agentBuilderWorkflows);\n return agentBuilderWorkflowsPromise;\n}\n\nasync function registerAgentBuilderWorkflows(\n mastra: Parameters<typeof WorkflowRegistry.registerTemporaryWorkflows>[1],\n) {\n const agentBuilderWorkflows = await loadAgentBuilderWorkflows();\n WorkflowRegistry.registerTemporaryWorkflows(agentBuilderWorkflows, mastra);\n return agentBuilderWorkflows;\n}\n\n// ============================================================================\n// Route Definitions (handlers call workflow route handlers with transformed parameters)\n// ============================================================================\n\nexport const LIST_AGENT_BUILDER_ACTIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder',\n responseType: 'json',\n responseSchema: listWorkflowsResponseSchema,\n summary: 'List agent-builder actions',\n description: 'Returns a list of all available agent-builder actions',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n logger.info('Listing agent builder actions');\n\n // Call workflow list handler\n return await workflows.LIST_WORKFLOWS_ROUTE.handler(ctx);\n } catch (error) {\n logger.error('Error listing agent builder actions', { error });\n return handleError(error, 'Error getting agent builder workflows');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n responseSchema: workflowInfoSchema,\n summary: 'Get action by ID',\n description: 'Returns details for a specific agent-builder action',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId } = ctx;\n const logger = mastra.getLogger();\n try {\n const agentBuilderWorkflows = await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, {\n message: `Invalid agent-builder action: ${actionId}. Valid actions are: ${Object.keys(agentBuilderWorkflows).join(', ')}`,\n });\n }\n\n logger.info('Getting agent builder action by ID', { actionId });\n\n return await workflows.GET_WORKFLOW_BY_ID_ROUTE.handler({ ...ctx, workflowId: actionId });\n } catch (error) {\n logger.error('Error getting agent builder action by ID', { error, actionId });\n return handleError(error, 'Error getting agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId/runs',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: listWorkflowRunsQuerySchema,\n responseSchema: workflowRunsResponseSchema,\n summary: 'List action runs',\n description: 'Returns a paginated list of execution runs for the specified action',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Listing agent builder action runs', { actionId });\n\n return await workflows.LIST_WORKFLOW_RUNS_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error listing agent builder action runs', { error, actionId });\n return handleError(error, 'Error getting agent builder action runs');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId/runs/:runId',\n responseType: 'json',\n pathParamSchema: actionRunPathParams,\n queryParamSchema: workflowRunResultQuerySchema,\n responseSchema: workflowRunResultSchema,\n summary: 'Get action run by ID',\n description:\n 'Returns details for a specific action run with metadata and processed execution state. Use the fields query parameter to reduce payload size.',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Getting agent builder action run by ID', { actionId, runId });\n\n return await workflows.GET_WORKFLOW_RUN_BY_ID_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error getting agent builder action run', { error, actionId, runId });\n return handleError(error, 'Error getting agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/create-run',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Create action run',\n description: 'Creates a new action execution instance with an optional custom run ID',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Creating agent builder action run', { actionId, runId });\n\n return await workflows.CREATE_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error creating agent builder action run', { error, actionId });\n return handleError(error, 'Error creating agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/stream',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Stream action execution',\n description: 'Executes an action and streams the results in real-time',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Streaming agent builder action', { actionId, runId });\n\n return await workflows.STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error streaming agent builder action', { error, actionId });\n return handleError(error, 'Error streaming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/start-async',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: startAsyncAgentBuilderBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Start action asynchronously',\n description: 'Starts an action execution asynchronously without streaming results',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Starting agent builder action asynchronously', { actionId, runId });\n\n return await workflows.START_ASYNC_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error starting agent builder action asynchronously', { error, actionId });\n return handleError(error, 'Error starting agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const START_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/start',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: startAsyncAgentBuilderBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Start specific action run',\n description: 'Starts execution of a specific action run by ID',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Starting specific agent builder action run', { actionId, runId });\n\n return await workflows.START_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error starting agent builder action run', { error, actionId });\n return handleError(error, 'Error starting agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/observe',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe action stream',\n description: 'Observes and streams updates from an already running action execution',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Observing agent builder action stream', { actionId, runId });\n\n return await workflows.OBSERVE_STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error observing agent builder action stream', { error, actionId });\n return handleError(error, 'Error observing agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-async',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Resume action asynchronously',\n description: 'Resumes a suspended action execution asynchronously without streaming',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action asynchronously', { actionId, runId, step });\n\n return await workflows.RESUME_ASYNC_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action asynchronously', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\n/**\n * Fire-and-forget resume for agent-builder actions: returns immediately with the runId without\n * waiting for completion. Delegates to the workflows `resume-no-wait` route.\n *\n * TODO(v2): fold this behavior into the `resume-async` route in Mastra v2 and remove this route.\n * Kept separate in v1 to avoid breaking the existing `resume-async` response contract.\n */\nexport const RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-no-wait',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Resume action without waiting',\n description:\n 'Resumes a suspended action execution without waiting (fire-and-forget) and returns immediately with the runId. The action continues executing in the background.',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action without waiting', { actionId, runId, step });\n\n return await workflows.RESUME_NO_WAIT_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action without waiting', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Resume action',\n description: 'Resumes a suspended action execution from a specific step',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action', { actionId, runId, step });\n\n return await workflows.RESUME_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-stream',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Resume action stream',\n description: 'Resumes a suspended action execution and continues streaming results',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action stream', { actionId, runId, step });\n\n return await workflows.RESUME_STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action stream', { error, actionId });\n return handleError(error, 'Error resuming agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/runs/:runId/cancel',\n responseType: 'json',\n pathParamSchema: actionRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Cancel action run',\n description: 'Cancels an in-progress action execution',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Cancelling agent builder action run', { actionId, runId });\n\n return await workflows.CANCEL_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error cancelling agent builder action run', { error, actionId });\n return handleError(error, 'Error cancelling agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\n// Legacy routes (deprecated)\nexport const STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/stream-legacy',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamLegacyAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Stream agent-builder action with legacy format',\n description:\n 'Legacy endpoint for streaming agent-builder action execution. Use /agent-builder/:actionId/stream instead.',\n tags: ['Agent Builder', 'Legacy'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Streaming agent builder action (legacy)', { actionId, runId });\n\n return await workflows.STREAM_LEGACY_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error streaming agent builder action (legacy)', { error, actionId });\n return handleError(error, 'Error streaming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/observe-stream-legacy',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Observe agent-builder action stream with legacy format',\n description:\n 'Legacy endpoint for observing agent-builder action stream. Use /agent-builder/:actionId/observe instead.',\n tags: ['Agent Builder', 'Legacy'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Observing agent builder action stream (legacy)', { actionId, runId });\n\n return await workflows.OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error observing agent builder action stream (legacy)', { error, actionId });\n return handleError(error, 'Error observing agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAI;AAEJ,eAAe,4BAA4D;CACzE,iCAAiC,OAAO,qBAAwB,CAAC,MAAK,QAAO,IAAI,qBAAqB;CACtG,OAAO;AACT;AAEA,eAAe,8BACb,QACA;CACA,MAAM,wBAAwB,MAAM,0BAA0B;CAC9D,iBAAiB,2BAA2B,uBAAuB,MAAM;CACzE,OAAO;AACT;AAMA,MAAa,mCAAmC,YAAY;CAC1D,QAAQ;CACR,MAAM;CACN,cAAc;CACd,gBAAgB;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,eAAe;CACtB,cAAc;CACd,SAAS,OAAM,QAAO;EACpB,MAAM,EAAE,WAAW;EACnB,MAAM,SAAS,OAAO,UAAU;EAChC,IAAI;GACF,MAAM,8BAA8B,MAAM;GAC1C,OAAO,KAAK,+BAA+B;GAG3C,OAAO,MAAA,qBAAqC,QAAQ,GAAG;EACzD,SAAS,OAAO;GAC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;EAClE,UAAU;GACR,iBAAiB,QAAQ;EAC3B;CACF;AACF,CAAC;AAED,MAAa,mDAAmD,YAAY;CAC1E,QAAQ;CACR,MAAM;CACN,cAAc;CACd,iBAAiB;CACjB,kBAAkB;CAClB,gBAAgB;CAChB,SAAS;CACT,aACE;CACF,MAAM,CAAC,iBAAiB,QAAQ;CAChC,cAAc;CACd,SAAS,OAAM,QAAO;EACpB,MAAM,EAAE,QAAQ,UAAU,UAAU;EACpC,MAAM,SAAS,OAAO,UAAU;EAChC,IAAI;GACF,MAAM,8BAA8B,MAAM;GAE1C,IAAI,YAAY,CAAC,iBAAiB,uBAAuB,QAAQ,GAC/D,MAAM,IAAI,cAAc,KAAK,EAAE,SAAS,iCAAiC,WAAW,CAAC;GAGvF,OAAO,KAAK,kDAAkD;IAAE;IAAU;GAAM,CAAC;GAEjF,OAAO,MAAA,qCAAqD,QAAQ;IAClE,GAAG;IACH,YAAY;GACd,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,wDAAwD;IAAE;IAAO;GAAS,CAAC;GACxF,OAAO,YAAY,OAAO,6CAA6C;EACzE,UAAU;GACR,iBAAiB,QAAQ;EAC3B;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"agent-builder-DvxYJR85.js","names":[],"sources":["../src/server/handlers/agent-builder.ts"],"sourcesContent":["import type { agentBuilderWorkflows as agentBuilderWorkflowsType } from '@mastra/agent-builder';\nimport { HTTPException } from '../http-exception';\nimport {\n actionIdPathParams,\n actionRunPathParams,\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n resumeAgentBuilderBodySchema,\n streamAgentBuilderBodySchema,\n startAsyncAgentBuilderBodySchema,\n workflowExecutionResultSchema,\n workflowControlResponseSchema,\n workflowRunsResponseSchema,\n workflowInfoSchema,\n listWorkflowsResponseSchema,\n streamLegacyAgentBuilderBodySchema,\n workflowRunResultSchema,\n workflowRunResultQuerySchema,\n} from '../schemas/agent-builder';\nimport { streamResponseSchema } from '../schemas/agents';\nimport { optionalRunIdSchema, runIdSchema } from '../schemas/common';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\nimport * as workflows from './workflows';\n\ntype AgentBuilderWorkflows = typeof agentBuilderWorkflowsType;\n\nlet agentBuilderWorkflowsPromise: Promise<AgentBuilderWorkflows> | undefined;\n\nasync function loadAgentBuilderWorkflows(): Promise<AgentBuilderWorkflows> {\n agentBuilderWorkflowsPromise ??= import('@mastra/agent-builder').then(mod => mod.agentBuilderWorkflows);\n return agentBuilderWorkflowsPromise;\n}\n\nasync function registerAgentBuilderWorkflows(\n mastra: Parameters<typeof WorkflowRegistry.registerTemporaryWorkflows>[1],\n) {\n const agentBuilderWorkflows = await loadAgentBuilderWorkflows();\n WorkflowRegistry.registerTemporaryWorkflows(agentBuilderWorkflows, mastra);\n return agentBuilderWorkflows;\n}\n\n// ============================================================================\n// Route Definitions (handlers call workflow route handlers with transformed parameters)\n// ============================================================================\n\nexport const LIST_AGENT_BUILDER_ACTIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder',\n responseType: 'json',\n responseSchema: listWorkflowsResponseSchema,\n summary: 'List agent-builder actions',\n description: 'Returns a list of all available agent-builder actions',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n logger.info('Listing agent builder actions');\n\n // Call workflow list handler\n return await workflows.LIST_WORKFLOWS_ROUTE.handler(ctx);\n } catch (error) {\n logger.error('Error listing agent builder actions', { error });\n return handleError(error, 'Error getting agent builder workflows');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n responseSchema: workflowInfoSchema,\n summary: 'Get action by ID',\n description: 'Returns details for a specific agent-builder action',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId } = ctx;\n const logger = mastra.getLogger();\n try {\n const agentBuilderWorkflows = await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, {\n message: `Invalid agent-builder action: ${actionId}. Valid actions are: ${Object.keys(agentBuilderWorkflows).join(', ')}`,\n });\n }\n\n logger.info('Getting agent builder action by ID', { actionId });\n\n return await workflows.GET_WORKFLOW_BY_ID_ROUTE.handler({ ...ctx, workflowId: actionId });\n } catch (error) {\n logger.error('Error getting agent builder action by ID', { error, actionId });\n return handleError(error, 'Error getting agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId/runs',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: listWorkflowRunsQuerySchema,\n responseSchema: workflowRunsResponseSchema,\n summary: 'List action runs',\n description: 'Returns a paginated list of execution runs for the specified action',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Listing agent builder action runs', { actionId });\n\n return await workflows.LIST_WORKFLOW_RUNS_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error listing agent builder action runs', { error, actionId });\n return handleError(error, 'Error getting agent builder action runs');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/agent-builder/:actionId/runs/:runId',\n responseType: 'json',\n pathParamSchema: actionRunPathParams,\n queryParamSchema: workflowRunResultQuerySchema,\n responseSchema: workflowRunResultSchema,\n summary: 'Get action run by ID',\n description:\n 'Returns details for a specific action run with metadata and processed execution state. Use the fields query parameter to reduce payload size.',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Getting agent builder action run by ID', { actionId, runId });\n\n return await workflows.GET_WORKFLOW_RUN_BY_ID_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error getting agent builder action run', { error, actionId, runId });\n return handleError(error, 'Error getting agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/create-run',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Create action run',\n description: 'Creates a new action execution instance with an optional custom run ID',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Creating agent builder action run', { actionId, runId });\n\n return await workflows.CREATE_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error creating agent builder action run', { error, actionId });\n return handleError(error, 'Error creating agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/stream',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Stream action execution',\n description: 'Executes an action and streams the results in real-time',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Streaming agent builder action', { actionId, runId });\n\n return await workflows.STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error streaming agent builder action', { error, actionId });\n return handleError(error, 'Error streaming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/start-async',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: startAsyncAgentBuilderBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Start action asynchronously',\n description: 'Starts an action execution asynchronously without streaming results',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Starting agent builder action asynchronously', { actionId, runId });\n\n return await workflows.START_ASYNC_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error starting agent builder action asynchronously', { error, actionId });\n return handleError(error, 'Error starting agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const START_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/start',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: startAsyncAgentBuilderBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Start specific action run',\n description: 'Starts execution of a specific action run by ID',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Starting specific agent builder action run', { actionId, runId });\n\n return await workflows.START_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error starting agent builder action run', { error, actionId });\n return handleError(error, 'Error starting agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/observe',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe action stream',\n description: 'Observes and streams updates from an already running action execution',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Observing agent builder action stream', { actionId, runId });\n\n return await workflows.OBSERVE_STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error observing agent builder action stream', { error, actionId });\n return handleError(error, 'Error observing agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-async',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Resume action asynchronously',\n description: 'Resumes a suspended action execution asynchronously without streaming',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action asynchronously', { actionId, runId, step });\n\n return await workflows.RESUME_ASYNC_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action asynchronously', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\n/**\n * Fire-and-forget resume for agent-builder actions: returns immediately with the runId without\n * waiting for completion. Delegates to the workflows `resume-no-wait` route.\n *\n * TODO(v2): fold this behavior into the `resume-async` route in Mastra v2 and remove this route.\n * Kept separate in v1 to avoid breaking the existing `resume-async` response contract.\n */\nexport const RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-no-wait',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Resume action without waiting',\n description:\n 'Resumes a suspended action execution without waiting (fire-and-forget) and returns immediately with the runId. The action continues executing in the background.',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action without waiting', { actionId, runId, step });\n\n return await workflows.RESUME_NO_WAIT_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action without waiting', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume',\n responseType: 'json',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Resume action',\n description: 'Resumes a suspended action execution from a specific step',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action', { actionId, runId, step });\n\n return await workflows.RESUME_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action', { error, actionId });\n return handleError(error, 'Error resuming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/resume-stream',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Resume action stream',\n description: 'Resumes a suspended action execution and continues streaming results',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, step, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Resuming agent builder action stream', { actionId, runId, step });\n\n return await workflows.RESUME_STREAM_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error resuming agent builder action stream', { error, actionId });\n return handleError(error, 'Error resuming agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/runs/:runId/cancel',\n responseType: 'json',\n pathParamSchema: actionRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Cancel action run',\n description: 'Cancels an in-progress action execution',\n tags: ['Agent Builder'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Cancelling agent builder action run', { actionId, runId });\n\n return await workflows.CANCEL_WORKFLOW_RUN_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error cancelling agent builder action run', { error, actionId });\n return handleError(error, 'Error cancelling agent builder action run');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\n// Legacy routes (deprecated)\nexport const STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/stream-legacy',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamLegacyAgentBuilderBodySchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Stream agent-builder action with legacy format',\n description:\n 'Legacy endpoint for streaming agent-builder action execution. Use /agent-builder/:actionId/stream instead.',\n tags: ['Agent Builder', 'Legacy'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId, requestContext } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Streaming agent builder action (legacy)', { actionId, runId });\n\n return await workflows.STREAM_LEGACY_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n requestContext,\n });\n } catch (error) {\n logger.error('Error streaming agent builder action (legacy)', { error, actionId });\n return handleError(error, 'Error streaming agent builder action');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n\nexport const OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({\n method: 'POST',\n path: '/agent-builder/:actionId/observe-stream-legacy',\n responseType: 'stream',\n pathParamSchema: actionIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Observe agent-builder action stream with legacy format',\n description:\n 'Legacy endpoint for observing agent-builder action stream. Use /agent-builder/:actionId/observe instead.',\n tags: ['Agent Builder', 'Legacy'],\n requiresAuth: true,\n handler: async ctx => {\n const { mastra, actionId, runId } = ctx;\n const logger = mastra.getLogger();\n try {\n await registerAgentBuilderWorkflows(mastra);\n\n if (actionId && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {\n throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });\n }\n\n logger.info('Observing agent builder action stream (legacy)', { actionId, runId });\n\n return await workflows.OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE.handler({\n ...ctx,\n workflowId: actionId,\n });\n } catch (error) {\n logger.error('Error observing agent builder action stream (legacy)', { error, actionId });\n return handleError(error, 'Error observing agent builder action stream');\n } finally {\n WorkflowRegistry.cleanup();\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAI;AAEJ,eAAe,4BAA4D;CACzE,iCAAiC,OAAO,qBAAwB,CAAC,MAAK,QAAO,IAAI,qBAAqB;CACtG,OAAO;AACT;AAEA,eAAe,8BACb,QACA;CACA,MAAM,wBAAwB,MAAM,0BAA0B;CAC9D,iBAAiB,2BAA2B,uBAAuB,MAAM;CACzE,OAAO;AACT;AAMA,MAAa,mCAAmC,YAAY;CAC1D,QAAQ;CACR,MAAM;CACN,cAAc;CACd,gBAAgB;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,eAAe;CACtB,cAAc;CACd,SAAS,OAAM,QAAO;EACpB,MAAM,EAAE,WAAW;EACnB,MAAM,SAAS,OAAO,UAAU;EAChC,IAAI;GACF,MAAM,8BAA8B,MAAM;GAC1C,OAAO,KAAK,+BAA+B;GAG3C,OAAO,MAAA,qBAAqC,QAAQ,GAAG;EACzD,SAAS,OAAO;GACd,OAAO,MAAM,uCAAuC,EAAE,MAAM,CAAC;GAC7D,OAAO,YAAY,OAAO,uCAAuC;EACnE,UAAU;GACR,iBAAiB,QAAQ;EAC3B;CACF;AACF,CAAC;AAED,MAAa,uCAAuC,YAAY;CAC9D,QAAQ;CACR,MAAM;CACN,cAAc;CACd,iBAAiB;CACjB,gBAAgB;C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cAAc;CACd,SAAS,OAAM,QAAO;EACpB,MAAM,EAAE,QAAQ,UAAU,UAAU;EACpC,MAAM,SAAS,OAAO,UAAU;EAChC,IAAI;GACF,MAAM,8BAA8B,MAAM;GAE1C,IAAI,YAAY,CAAC,iBAAiB,uBAAuB,QAAQ,GAC/D,MAAM,IAAI,cAAc,KAAK,EAAE,SAAS,iCAAiC,WAAW,CAAC;GAGvF,OAAO,KAAK,kDAAkD;IAAE;IAAU;GAAM,CAAC;GAEjF,OAAO,MAAA,qCAAqD,QAAQ;IAClE,GAAG;IACH,YAAY;GACd,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,wDAAwD;IAAE;IAAO;GAAS,CAAC;GACxF,OAAO,YAAY,OAAO,6CAA6C;EACzE,UAAU;GACR,iBAAiB,QAAQ;EAC3B;CACF;AACF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  require("./rolldown-runtime-BwC_XMyb.cjs");
2
2
  const require_route_builder = require("./route-builder-B2Qhhd7C.cjs");
3
- const require_routes = require("./routes-DGLJyqjD.cjs");
3
+ const require_routes = require("./routes-B4I5n3rK.cjs");
4
4
  //#region src/server/server-adapter/api-schema-manifest.ts
5
5
  function convertSchema(schema) {
6
6
  return schema ? require_route_builder.schemaToJsonSchema(schema) : void 0;
@@ -59,4 +59,4 @@ function buildApiSchemaManifest(routes = require_routes.SERVER_ROUTES) {
59
59
  //#endregion
60
60
  exports.buildApiSchemaManifest = buildApiSchemaManifest;
61
61
 
62
- //# sourceMappingURL=api-schema-manifest-DIlNfbyw.cjs.map
62
+ //# sourceMappingURL=api-schema-manifest-CQSdIekp.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-schema-manifest-DIlNfbyw.cjs","names":["schemaToJsonSchema","SERVER_ROUTES"],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const alternatives: unknown[] | undefined = responseSchema.anyOf ?? responseSchema.oneOf;\n if (alternatives?.length) {\n const shapes = alternatives.map(schema => inferResponseShape(asJsonSchema(schema)));\n const first = shapes[0]!;\n return shapes.every(\n shape =>\n shape.kind === first.kind &&\n shape.listProperty === first.listProperty &&\n shape.paginationProperty === first.paginationProperty,\n )\n ? first\n : { kind: 'single' };\n }\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\n/** CLI flags cover all request variants; the endpoint still validates the selected variant. */\nexport function getApiSchemaPropertyNames(schema: JSONSchema7 | undefined): string[] {\n if (!schema) return [];\n const names = Object.keys(schema.properties ?? {});\n for (const branch of schema.anyOf ?? schema.oneOf ?? [])\n names.push(...getApiSchemaPropertyNames(asJsonSchema(branch)));\n return [...new Set(names)].sort();\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;;AA2BA,SAAS,cAAc,QAA4D;CACjF,OAAO,SAASA,sBAAAA,mBAAmB,MAAM,IAAI,KAAA;AAC/C;AAEA,SAAS,aAAa,OAAyC;CAC7D,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAwB,KAAA;AAChG;AAEA,SAAS,WAAW,QAAkE;CACpF,MAAM,OAAO,QAAQ;CACrB,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,OAAO,IAAI;AACpD;AAEA,SAAS,mBAAmB,gBAAiE;CAC3F,IAAI,CAAC,gBAAgB,OAAO,EAAE,MAAM,UAAU;CAE9C,MAAM,eAAsC,eAAe,SAAS,eAAe;CACnF,IAAI,cAAc,QAAQ;EACxB,MAAM,SAAS,aAAa,KA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MAAM,UAAU;IAC1C;IACA,eAAe,mBAAmB,cAAc;GAClD;EACF,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"api-schema-manifest-CQSdIekp.cjs","names":["schemaToJsonSchema","SERVER_ROUTES"],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const alternatives: unknown[] | undefined = responseSchema.anyOf ?? responseSchema.oneOf;\n if (alternatives?.length) {\n const shapes = alternatives.map(schema => inferResponseShape(asJsonSchema(schema)));\n const first = shapes[0]!;\n return shapes.every(\n shape =>\n shape.kind === first.kind &&\n shape.listProperty === first.listProperty &&\n shape.paginationProperty === first.paginationProperty,\n )\n ? first\n : { kind: 'single' };\n }\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\n/** CLI flags cover all request variants; the endpoint still validates the selected variant. */\nexport function getApiSchemaPropertyNames(schema: JSONSchema7 | undefined): string[] {\n if (!schema) return [];\n const names = Object.keys(schema.properties ?? {});\n for (const branch of schema.anyOf ?? schema.oneOf ?? [])\n names.push(...getApiSchemaPropertyNames(asJsonSchema(branch)));\n return [...new Set(names)].sort();\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;;AA2BA,SAAS,cAAc,QAA4D;CACjF,OAAO,SAASA,sBAAAA,mBAAmB,MAAM,IAAI,KAAA;AAC/C;AAEA,SAAS,aAAa,OAAyC;CAC7D,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAwB,KAAA;AAChG;AAEA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CC,eAAAA,eAAkC;CACxG,OAAO;EACL,SAAS;EACT,QAAQ,OAAO,OAAO,eAAe,CAAC,CAAC,KAAI,UAAS;GAClD,MAAM,iBAAiB,cAAc,MAAM,cAAc;GACzD,OAAO;IACL,QAAQ,MAAM;IACd,MAAM,MAAM;IACZ,cAAc,MAAM;IACpB,iBAAiB,cAAc,MAAM,eAAe;IACpD,kBAAkB,cAAc,MAAM,gBAAgB;IACtD,YAAY,cAAc,MAAM,UAAU;IAC1C;IACA,eAAe,mBAAmB,cAAc;GAClD;EACF,CAAC;CACH;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { c as schemaToJsonSchema } from "./route-builder-CjkWxv4E.js";
2
- import { t as SERVER_ROUTES } from "./routes-BC20mdNN.js";
2
+ import { t as SERVER_ROUTES } from "./routes-nhnsGZVb.js";
3
3
  //#region src/server/server-adapter/api-schema-manifest.ts
4
4
  function convertSchema(schema) {
5
5
  return schema ? schemaToJsonSchema(schema) : void 0;
@@ -58,4 +58,4 @@ function buildApiSchemaManifest(routes = SERVER_ROUTES) {
58
58
  //#endregion
59
59
  export { buildApiSchemaManifest };
60
60
 
61
- //# sourceMappingURL=api-schema-manifest-CI90M4sX.js.map
61
+ //# sourceMappingURL=api-schema-manifest-Ce-tWsRS.js.map