@mastra/server 1.58.0-alpha.4 → 1.58.0-alpha.5

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 (70) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/{agent-builder-DAiJH1u2.cjs → agent-builder-Bq8VQxPt.cjs} +2 -2
  3. package/dist/{agent-builder-DAiJH1u2.cjs.map → agent-builder-Bq8VQxPt.cjs.map} +1 -1
  4. package/dist/{agent-builder-gGFywDVq.js → agent-builder-DVv4fSab.js} +2 -2
  5. package/dist/{agent-builder-gGFywDVq.js.map → agent-builder-DVv4fSab.js.map} +1 -1
  6. package/dist/{api-schema-manifest-B4J_QYOr.js → api-schema-manifest-CtRYAXKX.js} +2 -2
  7. package/dist/{api-schema-manifest-B4J_QYOr.js.map → api-schema-manifest-CtRYAXKX.js.map} +1 -1
  8. package/dist/{api-schema-manifest-B3bC-D98.cjs → api-schema-manifest-tsMOBlmY.cjs} +2 -2
  9. package/dist/{api-schema-manifest-B3bC-D98.cjs.map → api-schema-manifest-tsMOBlmY.cjs.map} +1 -1
  10. package/dist/{dist-BKRMiJcn.js → dist-DkY6iCA4.js} +64 -35
  11. package/dist/dist-DkY6iCA4.js.map +1 -0
  12. package/dist/{dist-C2-SedDQ.cjs → dist-fvOsjRn_.cjs} +64 -35
  13. package/dist/dist-fvOsjRn_.cjs.map +1 -0
  14. package/dist/docs/SKILL.md +1 -1
  15. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  16. package/dist/docs/references/reference-server-routes.md +9 -9
  17. package/dist/{stored-workflows-OanG0TmB.js → dynamic-workflows-B4LI2B52.js} +61 -61
  18. package/dist/dynamic-workflows-B4LI2B52.js.map +1 -0
  19. package/dist/{stored-workflows-pCiWK305.cjs → dynamic-workflows-BXeywVEf.cjs} +70 -70
  20. package/dist/dynamic-workflows-BXeywVEf.cjs.map +1 -0
  21. package/dist/{routes-CZwPlO3-.cjs → routes-BRGPk2DE.cjs} +17 -17
  22. package/dist/routes-BRGPk2DE.cjs.map +1 -0
  23. package/dist/{routes-HUaCyUb7.js → routes-cMGFe7yS.js} +17 -17
  24. package/dist/routes-cMGFe7yS.js.map +1 -0
  25. package/dist/server/handlers/agent-builder.cjs +3 -3
  26. package/dist/server/handlers/agent-builder.d.ts +4 -4
  27. package/dist/server/handlers/agent-builder.js +3 -3
  28. package/dist/server/handlers/dynamic-workflows.cjs +6 -0
  29. package/dist/server/handlers/{stored-workflows.d.ts → dynamic-workflows.d.ts} +14 -14
  30. package/dist/server/handlers/{stored-workflows.d.ts.map → dynamic-workflows.d.ts.map} +1 -1
  31. package/dist/server/handlers/dynamic-workflows.js +2 -0
  32. package/dist/server/handlers/system.cjs +1 -1
  33. package/dist/server/handlers/system.js +1 -1
  34. package/dist/server/handlers/workflows.cjs +1 -1
  35. package/dist/server/handlers/workflows.d.ts +4 -4
  36. package/dist/server/handlers/workflows.js +1 -1
  37. package/dist/server/handlers.cjs +7 -7
  38. package/dist/server/handlers.d.ts +1 -1
  39. package/dist/server/handlers.d.ts.map +1 -1
  40. package/dist/server/handlers.js +2 -2
  41. package/dist/server/schemas/{stored-workflows.d.ts → dynamic-workflows.d.ts} +13 -13
  42. package/dist/server/schemas/dynamic-workflows.d.ts.map +1 -0
  43. package/dist/server/schemas/index.cjs +2 -2
  44. package/dist/server/schemas/index.js +2 -2
  45. package/dist/server/schemas/workflows.d.ts +2 -2
  46. package/dist/server/server-adapter/index.cjs +1 -1
  47. package/dist/server/server-adapter/index.js +1 -1
  48. package/dist/server/server-adapter/routes/agent-builder.d.ts +4 -4
  49. package/dist/server/server-adapter/routes/dynamic-workflows.d.ts +16 -0
  50. package/dist/server/server-adapter/routes/dynamic-workflows.d.ts.map +1 -0
  51. package/dist/server/server-adapter/routes/index.d.ts.map +1 -1
  52. package/dist/server/server-adapter/routes/workflows.d.ts +4 -4
  53. package/dist/{workflows-Dzxr6cmf.cjs → workflows-BPDvo87u.cjs} +2 -2
  54. package/dist/workflows-BPDvo87u.cjs.map +1 -0
  55. package/dist/{workflows-CMU5dz_4.js → workflows-Dzl1i83M.js} +2 -2
  56. package/dist/workflows-Dzl1i83M.js.map +1 -0
  57. package/package.json +8 -8
  58. package/dist/dist-BKRMiJcn.js.map +0 -1
  59. package/dist/dist-C2-SedDQ.cjs.map +0 -1
  60. package/dist/routes-CZwPlO3-.cjs.map +0 -1
  61. package/dist/routes-HUaCyUb7.js.map +0 -1
  62. package/dist/server/handlers/stored-workflows.cjs +0 -6
  63. package/dist/server/handlers/stored-workflows.js +0 -2
  64. package/dist/server/schemas/stored-workflows.d.ts.map +0 -1
  65. package/dist/server/server-adapter/routes/stored-workflows.d.ts +0 -16
  66. package/dist/server/server-adapter/routes/stored-workflows.d.ts.map +0 -1
  67. package/dist/stored-workflows-OanG0TmB.js.map +0 -1
  68. package/dist/stored-workflows-pCiWK305.cjs.map +0 -1
  69. package/dist/workflows-CMU5dz_4.js.map +0 -1
  70. package/dist/workflows-Dzxr6cmf.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.58.0-alpha.5
4
+
5
+ ### Minor Changes
6
+
7
+ - Renamed the stored workflows handlers and schemas to dynamic workflows. HTTP route paths and permissions are unchanged. ([#20938](https://github.com/mastra-ai/mastra/pull/20938))
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`6445eba`](https://github.com/mastra-ai/mastra/commit/6445eba6020abac681aba1cc9289f446cb400cbe), [`df31eb0`](https://github.com/mastra-ai/mastra/commit/df31eb0c7087d782a0d9346e467f9a4af4b0eef6), [`fcd0667`](https://github.com/mastra-ai/mastra/commit/fcd0667a4e378be35c9a1b1eb19cce78fbfd7282), [`bab06b1`](https://github.com/mastra-ai/mastra/commit/bab06b18923873a584bdfc71a6b4ec7fb4727fb7)]:
12
+ - @mastra/core@1.58.0-alpha.5
13
+
3
14
  ## 1.58.0-alpha.4
4
15
 
5
16
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- const require_workflows = require("./workflows-Dzxr6cmf.cjs");
1
+ const require_workflows = require("./workflows-BPDvo87u.cjs");
2
2
  let zod_v4 = require("zod/v4");
3
3
  //#region src/server/schemas/agent-builder.ts
4
4
  const actionIdPathParams = zod_v4.z.object({ actionId: zod_v4.z.string().describe("Unique identifier for the agent-builder action") });
@@ -64,4 +64,4 @@ Object.defineProperty(exports, "streamLegacyAgentBuilderBodySchema", {
64
64
  }
65
65
  });
66
66
 
67
- //# sourceMappingURL=agent-builder-DAiJH1u2.cjs.map
67
+ //# sourceMappingURL=agent-builder-Bq8VQxPt.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-builder-DAiJH1u2.cjs","names":["z","streamWorkflowBodySchema","streamLegacyWorkflowBodySchema","resumeBodySchema","startAsyncWorkflowBodySchema"],"sources":["../src/server/schemas/agent-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport {\n streamWorkflowBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamLegacyWorkflowBodySchema,\n} from './workflows';\n\n// Path parameter schemas\n\nexport const actionIdPathParams = z.object({\n actionId: z.string().describe('Unique identifier for the agent-builder action'),\n});\n\nexport const actionRunPathParams = z.object({\n actionId: z.string().describe('Unique identifier for the agent-builder action'),\n runId: z.string().describe('Unique identifier for the action run'),\n});\n\n/**\n * Agent-builder schemas use the same body schemas as workflows\n * Both use requestContext field\n */\n\n/**\n * Schema for stream agent-builder action body\n */\nexport const streamAgentBuilderBodySchema = streamWorkflowBodySchema;\n\n/**\n * Schema for legacy stream agent-builder action body\n */\nexport const streamLegacyAgentBuilderBodySchema = streamLegacyWorkflowBodySchema;\n\n/**\n * Schema for resume agent-builder action body\n */\nexport const resumeAgentBuilderBodySchema = resumeBodySchema;\n\n/**\n * Schema for start async agent-builder action body\n */\nexport const startAsyncAgentBuilderBodySchema = startAsyncWorkflowBodySchema;\n\n// Agent-builder actions use the same response schemas as workflows since they're wrapped workflow handlers\nexport {\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n sendWorkflowRunEventBodySchema,\n workflowExecutionResultSchema,\n workflowControlResponseSchema,\n workflowRunsResponseSchema,\n workflowInfoSchema,\n listWorkflowsResponseSchema,\n workflowRunResultSchema,\n workflowRunResultQuerySchema,\n} from './workflows';\n"],"mappings":";;;AAUA,MAAa,qBAAqBA,OAAAA,EAAE,OAAO,EACzC,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,gDAAgD,EAChF,CAAC;AAED,MAAa,sBAAsBA,OAAAA,EAAE,OAAO;CAC1C,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,gDAAgD;CAC9E,OAAOA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,sCAAsC;AACnE,CAAC;;;;;;;;AAUD,MAAa,+BAA+BC,kBAAAA;;;;AAK5C,MAAa,qCAAqCC,kBAAAA;;;;AAKlD,MAAa,+BAA+BC,kBAAAA;;;;AAK5C,MAAa,mCAAmCC,kBAAAA"}
1
+ {"version":3,"file":"agent-builder-Bq8VQxPt.cjs","names":["z","streamWorkflowBodySchema","streamLegacyWorkflowBodySchema","resumeBodySchema","startAsyncWorkflowBodySchema"],"sources":["../src/server/schemas/agent-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport {\n streamWorkflowBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamLegacyWorkflowBodySchema,\n} from './workflows';\n\n// Path parameter schemas\n\nexport const actionIdPathParams = z.object({\n actionId: z.string().describe('Unique identifier for the agent-builder action'),\n});\n\nexport const actionRunPathParams = z.object({\n actionId: z.string().describe('Unique identifier for the agent-builder action'),\n runId: z.string().describe('Unique identifier for the action run'),\n});\n\n/**\n * Agent-builder schemas use the same body schemas as workflows\n * Both use requestContext field\n */\n\n/**\n * Schema for stream agent-builder action body\n */\nexport const streamAgentBuilderBodySchema = streamWorkflowBodySchema;\n\n/**\n * Schema for legacy stream agent-builder action body\n */\nexport const streamLegacyAgentBuilderBodySchema = streamLegacyWorkflowBodySchema;\n\n/**\n * Schema for resume agent-builder action body\n */\nexport const resumeAgentBuilderBodySchema = resumeBodySchema;\n\n/**\n * Schema for start async agent-builder action body\n */\nexport const startAsyncAgentBuilderBodySchema = startAsyncWorkflowBodySchema;\n\n// Agent-builder actions use the same response schemas as workflows since they're wrapped workflow handlers\nexport {\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n sendWorkflowRunEventBodySchema,\n workflowExecutionResultSchema,\n workflowControlResponseSchema,\n workflowRunsResponseSchema,\n workflowInfoSchema,\n listWorkflowsResponseSchema,\n workflowRunResultSchema,\n workflowRunResultQuerySchema,\n} from './workflows';\n"],"mappings":";;;AAUA,MAAa,qBAAqBA,OAAAA,EAAE,OAAO,EACzC,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,gDAAgD,EAChF,CAAC;AAED,MAAa,sBAAsBA,OAAAA,EAAE,OAAO;CAC1C,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,gDAAgD;CAC9E,OAAOA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,sCAAsC;AACnE,CAAC;;;;;;;;AAUD,MAAa,+BAA+BC,kBAAAA;;;;AAK5C,MAAa,qCAAqCC,kBAAAA;;;;AAKlD,MAAa,+BAA+BC,kBAAAA;;;;AAK5C,MAAa,mCAAmCC,kBAAAA"}
@@ -1,4 +1,4 @@
1
- import { d as streamWorkflowBodySchema, l as startAsyncWorkflowBodySchema, s as resumeBodySchema, u as streamLegacyWorkflowBodySchema } from "./workflows-CMU5dz_4.js";
1
+ import { d as streamWorkflowBodySchema, l as startAsyncWorkflowBodySchema, s as resumeBodySchema, u as streamLegacyWorkflowBodySchema } from "./workflows-Dzl1i83M.js";
2
2
  import { z } from "zod/v4";
3
3
  //#region src/server/schemas/agent-builder.ts
4
4
  const actionIdPathParams = z.object({ actionId: z.string().describe("Unique identifier for the agent-builder action") });
@@ -29,4 +29,4 @@ const startAsyncAgentBuilderBodySchema = startAsyncWorkflowBodySchema;
29
29
  //#endregion
30
30
  export { streamAgentBuilderBodySchema as a, startAsyncAgentBuilderBodySchema as i, actionRunPathParams as n, streamLegacyAgentBuilderBodySchema as o, resumeAgentBuilderBodySchema as r, actionIdPathParams as t };
31
31
 
32
- //# sourceMappingURL=agent-builder-gGFywDVq.js.map
32
+ //# sourceMappingURL=agent-builder-DVv4fSab.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-builder-gGFywDVq.js","names":[],"sources":["../src/server/schemas/agent-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport {\n streamWorkflowBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamLegacyWorkflowBodySchema,\n} from './workflows';\n\n// Path parameter schemas\n\nexport const actionIdPathParams = z.object({\n actionId: z.string().describe('Unique identifier for the agent-builder action'),\n});\n\nexport const actionRunPathParams = z.object({\n actionId: z.string().describe('Unique identifier for the agent-builder action'),\n runId: z.string().describe('Unique identifier for the action run'),\n});\n\n/**\n * Agent-builder schemas use the same body schemas as workflows\n * Both use requestContext field\n */\n\n/**\n * Schema for stream agent-builder action body\n */\nexport const streamAgentBuilderBodySchema = streamWorkflowBodySchema;\n\n/**\n * Schema for legacy stream agent-builder action body\n */\nexport const streamLegacyAgentBuilderBodySchema = streamLegacyWorkflowBodySchema;\n\n/**\n * Schema for resume agent-builder action body\n */\nexport const resumeAgentBuilderBodySchema = resumeBodySchema;\n\n/**\n * Schema for start async agent-builder action body\n */\nexport const startAsyncAgentBuilderBodySchema = startAsyncWorkflowBodySchema;\n\n// Agent-builder actions use the same response schemas as workflows since they're wrapped workflow handlers\nexport {\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n sendWorkflowRunEventBodySchema,\n workflowExecutionResultSchema,\n workflowControlResponseSchema,\n workflowRunsResponseSchema,\n workflowInfoSchema,\n listWorkflowsResponseSchema,\n workflowRunResultSchema,\n workflowRunResultQuerySchema,\n} from './workflows';\n"],"mappings":";;;AAUA,MAAa,qBAAqB,EAAE,OAAO,EACzC,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,gDAAgD,EAChF,CAAC;AAED,MAAa,sBAAsB,EAAE,OAAO;CAC1C,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,gDAAgD;CAC9E,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,sCAAsC;AACnE,CAAC;;;;;;;;AAUD,MAAa,+BAA+B;;;;AAK5C,MAAa,qCAAqC;;;;AAKlD,MAAa,+BAA+B;;;;AAK5C,MAAa,mCAAmC"}
1
+ {"version":3,"file":"agent-builder-DVv4fSab.js","names":[],"sources":["../src/server/schemas/agent-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport {\n streamWorkflowBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamLegacyWorkflowBodySchema,\n} from './workflows';\n\n// Path parameter schemas\n\nexport const actionIdPathParams = z.object({\n actionId: z.string().describe('Unique identifier for the agent-builder action'),\n});\n\nexport const actionRunPathParams = z.object({\n actionId: z.string().describe('Unique identifier for the agent-builder action'),\n runId: z.string().describe('Unique identifier for the action run'),\n});\n\n/**\n * Agent-builder schemas use the same body schemas as workflows\n * Both use requestContext field\n */\n\n/**\n * Schema for stream agent-builder action body\n */\nexport const streamAgentBuilderBodySchema = streamWorkflowBodySchema;\n\n/**\n * Schema for legacy stream agent-builder action body\n */\nexport const streamLegacyAgentBuilderBodySchema = streamLegacyWorkflowBodySchema;\n\n/**\n * Schema for resume agent-builder action body\n */\nexport const resumeAgentBuilderBodySchema = resumeBodySchema;\n\n/**\n * Schema for start async agent-builder action body\n */\nexport const startAsyncAgentBuilderBodySchema = startAsyncWorkflowBodySchema;\n\n// Agent-builder actions use the same response schemas as workflows since they're wrapped workflow handlers\nexport {\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n sendWorkflowRunEventBodySchema,\n workflowExecutionResultSchema,\n workflowControlResponseSchema,\n workflowRunsResponseSchema,\n workflowInfoSchema,\n listWorkflowsResponseSchema,\n workflowRunResultSchema,\n workflowRunResultQuerySchema,\n} from './workflows';\n"],"mappings":";;;AAUA,MAAa,qBAAqB,EAAE,OAAO,EACzC,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,gDAAgD,EAChF,CAAC;AAED,MAAa,sBAAsB,EAAE,OAAO;CAC1C,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,gDAAgD;CAC9E,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,sCAAsC;AACnE,CAAC;;;;;;;;AAUD,MAAa,+BAA+B;;;;AAK5C,MAAa,qCAAqC;;;;AAKlD,MAAa,+BAA+B;;;;AAK5C,MAAa,mCAAmC"}
@@ -1,5 +1,5 @@
1
1
  import { c as schemaToJsonSchema } from "./route-builder-CIk5k35M.js";
2
- import { t as SERVER_ROUTES } from "./routes-HUaCyUb7.js";
2
+ import { t as SERVER_ROUTES } from "./routes-cMGFe7yS.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;
@@ -52,4 +52,4 @@ function buildApiSchemaManifest(routes = SERVER_ROUTES) {
52
52
  //#endregion
53
53
  export { buildApiSchemaManifest };
54
54
 
55
- //# sourceMappingURL=api-schema-manifest-B4J_QYOr.js.map
55
+ //# sourceMappingURL=api-schema-manifest-CtRYAXKX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-schema-manifest-B4J_QYOr.js","names":[],"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 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\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,SAAS,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,OAAO,WAAW,cAAc;CACtC,IAAI,SAAS,SAAS,OAAO,EAAE,MAAM,QAAQ;CAC7C,IAAI,SAAS,UAAU,OAAO,EAAE,MAAM,SAAS;CAE/C,MAAM,aACJ,eAAe,cAAc,CAAC,MAAM,QAAQ,eAAe,UAAU,IAAI,eAAe,aAAa,CAAC;CACxG,MAAM,gBAAgB,OAAO,KAAK,UAAU;CAC5C,MAAM,qBAAqB,UAAU,aAAa,SAAS,gBAAgB,aAAa,eAAe,KAAA;CACvG,MAAM,eAAe,OAAO,QAAQ,UAAU,CAAC,CAAC,MAC7C,GAAG,cAAc,WAAW,aAAa,QAAQ,CAAC,MAAM,OAC3D,CAAC,GAAG;CAEJ,IAAI,iBAAiB,sBAAsB,cAAc,UAAU,IACjE,OAAO;EAAE,MAAM;EAAmB;EAAc;CAAmB;CAErE,IAAI,eAAe,wBAAwB,cAAc,WAAW,GAAG,OAAO,EAAE,MAAM,SAAS;CAC/F,OAAO,EAAE,MAAM,SAAS;AAC1B;AAEA,SAAS,gBAAgB,OAA6B;CACpD,OAAO,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACjD;AAEA,SAAgB,uBAAuB,SAAiC,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
+ {"version":3,"file":"api-schema-manifest-CtRYAXKX.js","names":[],"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 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\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,SAAS,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,OAAO,WAAW,cAAc;CACtC,IAAI,SAAS,SAAS,OAAO,EAAE,MAAM,QAAQ;CAC7C,IAAI,SAAS,UAAU,OAAO,EAAE,MAAM,SAAS;CAE/C,MAAM,aACJ,eAAe,cAAc,CAAC,MAAM,QAAQ,eAAe,UAAU,IAAI,eAAe,aAAa,CAAC;CACxG,MAAM,gBAAgB,OAAO,KAAK,UAAU;CAC5C,MAAM,qBAAqB,UAAU,aAAa,SAAS,gBAAgB,aAAa,eAAe,KAAA;CACvG,MAAM,eAAe,OAAO,QAAQ,UAAU,CAAC,CAAC,MAC7C,GAAG,cAAc,WAAW,aAAa,QAAQ,CAAC,MAAM,OAC3D,CAAC,GAAG;CAEJ,IAAI,iBAAiB,sBAAsB,cAAc,UAAU,IACjE,OAAO;EAAE,MAAM;EAAmB;EAAc;CAAmB;CAErE,IAAI,eAAe,wBAAwB,cAAc,WAAW,GAAG,OAAO,EAAE,MAAM,SAAS;CAC/F,OAAO,EAAE,MAAM,SAAS;AAC1B;AAEA,SAAS,gBAAgB,OAA6B;CACpD,OAAO,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACjD;AAEA,SAAgB,uBAAuB,SAAiC,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
  const require_route_builder = require("./route-builder-CgLVYL1c.cjs");
2
- const require_routes = require("./routes-CZwPlO3-.cjs");
2
+ const require_routes = require("./routes-BRGPk2DE.cjs");
3
3
  //#region src/server/server-adapter/api-schema-manifest.ts
4
4
  function convertSchema(schema) {
5
5
  return schema ? require_route_builder.schemaToJsonSchema(schema) : void 0;
@@ -52,4 +52,4 @@ function buildApiSchemaManifest(routes = require_routes.SERVER_ROUTES) {
52
52
  //#endregion
53
53
  exports.buildApiSchemaManifest = buildApiSchemaManifest;
54
54
 
55
- //# sourceMappingURL=api-schema-manifest-B3bC-D98.cjs.map
55
+ //# sourceMappingURL=api-schema-manifest-tsMOBlmY.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-schema-manifest-B3bC-D98.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 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\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,OAAO,WAAW,cAAc;CACtC,IAAI,SAAS,SAAS,OAAO,EAAE,MAAM,QAAQ;CAC7C,IAAI,SAAS,UAAU,OAAO,EAAE,MAAM,SAAS;CAE/C,MAAM,aACJ,eAAe,cAAc,CAAC,MAAM,QAAQ,eAAe,UAAU,IAAI,eAAe,aAAa,CAAC;CACxG,MAAM,gBAAgB,OAAO,KAAK,UAAU;CAC5C,MAAM,qBAAqB,UAAU,aAAa,SAAS,gBAAgB,aAAa,eAAe,KAAA;CACvG,MAAM,eAAe,OAAO,QAAQ,UAAU,CAAC,CAAC,MAC7C,GAAG,cAAc,WAAW,aAAa,QAAQ,CAAC,MAAM,OAC3D,CAAC,GAAG;CAEJ,IAAI,iBAAiB,sBAAsB,cAAc,UAAU,IACjE,OAAO;EAAE,MAAM;EAAmB;EAAc;CAAmB;CAErE,IAAI,eAAe,wBAAwB,cAAc,WAAW,GAAG,OAAO,EAAE,MAAM,SAAS;CAC/F,OAAO,EAAE,MAAM,SAAS;AAC1B;AAEA,SAAS,gBAAgB,OAA6B;CACpD,OAAO,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACjD;AAEA,SAAgB,uBAAuB,SAAiCC,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
+ {"version":3,"file":"api-schema-manifest-tsMOBlmY.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 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\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,OAAO,WAAW,cAAc;CACtC,IAAI,SAAS,SAAS,OAAO,EAAE,MAAM,QAAQ;CAC7C,IAAI,SAAS,UAAU,OAAO,EAAE,MAAM,SAAS;CAE/C,MAAM,aACJ,eAAe,cAAc,CAAC,MAAM,QAAQ,eAAe,UAAU,IAAI,eAAe,aAAa,CAAC;CACxG,MAAM,gBAAgB,OAAO,KAAK,UAAU;CAC5C,MAAM,qBAAqB,UAAU,aAAa,SAAS,gBAAgB,aAAa,eAAe,KAAA;CACvG,MAAM,eAAe,OAAO,QAAQ,UAAU,CAAC,CAAC,MAC7C,GAAG,cAAc,WAAW,aAAa,QAAQ,CAAC,MAAM,OAC3D,CAAC,GAAG;CAEJ,IAAI,iBAAiB,sBAAsB,cAAc,UAAU,IACjE,OAAO;EAAE,MAAM;EAAmB;EAAc;CAAmB;CAErE,IAAI,eAAe,wBAAwB,cAAc,WAAW,GAAG,OAAO,EAAE,MAAM,SAAS;CAC/F,OAAO,EAAE,MAAM,SAAS;AAC1B;AAEA,SAAS,gBAAgB,OAA6B;CACpD,OAAO,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACjD;AAEA,SAAgB,uBAAuB,SAAiCC,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"}
@@ -5959,7 +5959,7 @@ function splitLines(text) {
5959
5959
  return result;
5960
5960
  }
5961
5961
  //#endregion
5962
- //#region ../memory/dist/src-CdqJP57F.js
5962
+ //#region ../memory/dist/src-MScpLVRh.js
5963
5963
  var __defProp$3 = Object.defineProperty;
5964
5964
  var __exportAll = (all, no_symbols) => {
5965
5965
  let target = {};
@@ -24380,33 +24380,62 @@ var TokenCounter = class TokenCounter {
24380
24380
  if (isImageAttachment) await resolveImageDimensionsAsync(part);
24381
24381
  return this.countAttachmentPartSync(part);
24382
24382
  }
24383
+ /**
24384
+ * Count the name and the arguments of a tool call. Every state before the tool produces an
24385
+ * output holds the same call signature in the context window, so all of those states share
24386
+ * these cache kinds. `buildEstimateKey` hashes the text, so a shared kind stays correct and
24387
+ * keeps the estimate warm while the invocation moves from one state to the next.
24388
+ */
24389
+ countToolCallSignature(part, invocation) {
24390
+ let tokens = 0;
24391
+ let overheadDelta = 0;
24392
+ if (invocation.toolName) tokens += this.readOrPersistPartEstimate(part, "tool-call-name", invocation.toolName);
24393
+ if (invocation.args) if (typeof invocation.args === "string") tokens += this.readOrPersistPartEstimate(part, "tool-call-args", invocation.args);
24394
+ else {
24395
+ const argsJson = JSON.stringify(invocation.args);
24396
+ tokens += this.readOrPersistPartEstimate(part, "tool-call-args-json", argsJson);
24397
+ overheadDelta -= 12;
24398
+ }
24399
+ return {
24400
+ tokens,
24401
+ overheadDelta
24402
+ };
24403
+ }
24383
24404
  countNonAttachmentPart(part) {
24384
24405
  let overheadDelta = 0;
24385
- let toolResultDelta = 0;
24406
+ let extraMessageDelta = 0;
24386
24407
  if (part.type === "text") return {
24387
24408
  tokens: this.readOrPersistPartEstimate(part, "text", part.text),
24388
24409
  overheadDelta,
24389
- toolResultDelta
24410
+ extraMessageDelta
24390
24411
  };
24391
24412
  if (part.type === "tool-invocation") {
24392
24413
  const invocation = part.toolInvocation;
24414
+ const state = invocation.state;
24393
24415
  let tokens = 0;
24394
- if (invocation.state === "call" || invocation.state === "partial-call") {
24395
- if (invocation.toolName) tokens += this.readOrPersistPartEstimate(part, `tool-${invocation.state}-name`, invocation.toolName);
24396
- if (invocation.args) if (typeof invocation.args === "string") tokens += this.readOrPersistPartEstimate(part, `tool-${invocation.state}-args`, invocation.args);
24397
- else {
24398
- const argsJson = JSON.stringify(invocation.args);
24399
- tokens += this.readOrPersistPartEstimate(part, `tool-${invocation.state}-args-json`, argsJson);
24400
- overheadDelta -= 12;
24401
- }
24416
+ if (state === "call" || state === "partial-call" || state === "approval-requested") {
24417
+ const signature = this.countToolCallSignature(part, invocation);
24418
+ return {
24419
+ tokens: signature.tokens,
24420
+ overheadDelta: overheadDelta + signature.overheadDelta,
24421
+ extraMessageDelta
24422
+ };
24423
+ }
24424
+ if (state === "approval-responded") {
24425
+ extraMessageDelta++;
24426
+ const signature = this.countToolCallSignature(part, invocation);
24427
+ tokens += signature.tokens;
24428
+ overheadDelta += signature.overheadDelta;
24429
+ const reason = invocation.approval?.reason;
24430
+ if (reason) tokens += this.readOrPersistPartEstimate(part, "tool-approval-reason", reason);
24402
24431
  return {
24403
24432
  tokens,
24404
24433
  overheadDelta,
24405
- toolResultDelta
24434
+ extraMessageDelta
24406
24435
  };
24407
24436
  }
24408
- if (invocation.state === "result") {
24409
- toolResultDelta++;
24437
+ if (state === "result") {
24438
+ extraMessageDelta++;
24410
24439
  const { value: resultForCounting, usingStoredModelOutput } = this.resolveToolResultForTokenCounting(part, invocation.result);
24411
24440
  if (resultForCounting !== void 0) {
24412
24441
  const contentTokens = this.countMultimodalToolResultContent(part, resultForCounting);
@@ -24420,47 +24449,45 @@ var TokenCounter = class TokenCounter {
24420
24449
  return {
24421
24450
  tokens,
24422
24451
  overheadDelta,
24423
- toolResultDelta
24452
+ extraMessageDelta
24424
24453
  };
24425
24454
  }
24426
- if (invocation.state === "output-denied") {
24427
- toolResultDelta++;
24455
+ if (state === "output-denied") {
24456
+ extraMessageDelta++;
24428
24457
  const reason = invocation.approval?.reason ?? "Tool call was not approved by the user";
24429
24458
  tokens += this.readOrPersistPartEstimate(part, "tool-result-denied", reason);
24430
24459
  return {
24431
24460
  tokens,
24432
24461
  overheadDelta,
24433
- toolResultDelta
24462
+ extraMessageDelta
24434
24463
  };
24435
24464
  }
24436
- if (invocation.state === "output-error") {
24437
- toolResultDelta++;
24438
- const errorText = invocation.errorText;
24439
- const errorMessage = typeof errorText === "string" ? errorText : "Tool execution failed";
24465
+ if (state === "output-error") {
24466
+ extraMessageDelta++;
24467
+ const errorMessage = typeof invocation.errorText === "string" ? invocation.errorText : "Tool execution failed";
24440
24468
  tokens += this.readOrPersistPartEstimate(part, "tool-result-error", errorMessage);
24441
24469
  return {
24442
24470
  tokens,
24443
24471
  overheadDelta,
24444
- toolResultDelta
24472
+ extraMessageDelta
24445
24473
  };
24446
24474
  }
24447
- throw new Error(`Unhandled tool-invocation state '${part.toolInvocation?.state}' in token counting for part type '${part.type}'`);
24448
24475
  }
24449
24476
  if (typeof part.type === "string" && part.type.startsWith("data-")) return {
24450
24477
  tokens: 0,
24451
24478
  overheadDelta,
24452
- toolResultDelta
24479
+ extraMessageDelta
24453
24480
  };
24454
24481
  if (part.type === "reasoning") return {
24455
24482
  tokens: 0,
24456
24483
  overheadDelta,
24457
- toolResultDelta
24484
+ extraMessageDelta
24458
24485
  };
24459
24486
  const serialized = serializePartForTokenCounting(part);
24460
24487
  return {
24461
24488
  tokens: this.readOrPersistPartEstimate(part, `part-${part.type}`, serialized),
24462
24489
  overheadDelta,
24463
- toolResultDelta
24490
+ extraMessageDelta
24464
24491
  };
24465
24492
  }
24466
24493
  /**
@@ -24469,7 +24496,7 @@ var TokenCounter = class TokenCounter {
24469
24496
  countMessage(message) {
24470
24497
  let payloadTokens = this.countString(message.role);
24471
24498
  let overhead = TokenCounter.TOKENS_PER_MESSAGE;
24472
- let toolResultCount = 0;
24499
+ let extraMessageCount = 0;
24473
24500
  if (typeof message.content === "string") payloadTokens += this.readOrPersistMessageEstimate(message, "message-content", message.content);
24474
24501
  else if (message.content && typeof message.content === "object") {
24475
24502
  if (message.content.content && !Array.isArray(message.content.parts)) payloadTokens += this.readOrPersistMessageEstimate(message, "content-content", message.content.content);
@@ -24482,16 +24509,16 @@ var TokenCounter = class TokenCounter {
24482
24509
  const result = this.countNonAttachmentPart(part);
24483
24510
  payloadTokens += result.tokens;
24484
24511
  overhead += result.overheadDelta;
24485
- toolResultCount += result.toolResultDelta;
24512
+ extraMessageCount += result.extraMessageDelta;
24486
24513
  }
24487
24514
  }
24488
- if (toolResultCount > 0) overhead += toolResultCount * TokenCounter.TOKENS_PER_MESSAGE;
24515
+ if (extraMessageCount > 0) overhead += extraMessageCount * TokenCounter.TOKENS_PER_MESSAGE;
24489
24516
  return Math.round(payloadTokens + overhead);
24490
24517
  }
24491
24518
  async countMessageAsync(message) {
24492
24519
  let payloadTokens = this.countString(message.role);
24493
24520
  let overhead = TokenCounter.TOKENS_PER_MESSAGE;
24494
- let toolResultCount = 0;
24521
+ let extraMessageCount = 0;
24495
24522
  if (typeof message.content === "string") payloadTokens += this.readOrPersistMessageEstimate(message, "message-content", message.content);
24496
24523
  else if (message.content && typeof message.content === "object") {
24497
24524
  if (message.content.content && !Array.isArray(message.content.parts)) payloadTokens += this.readOrPersistMessageEstimate(message, "content-content", message.content.content);
@@ -24504,10 +24531,10 @@ var TokenCounter = class TokenCounter {
24504
24531
  const result = this.countNonAttachmentPart(part);
24505
24532
  payloadTokens += result.tokens;
24506
24533
  overhead += result.overheadDelta;
24507
- toolResultCount += result.toolResultDelta;
24534
+ extraMessageCount += result.extraMessageDelta;
24508
24535
  }
24509
24536
  }
24510
- if (toolResultCount > 0) overhead += toolResultCount * TokenCounter.TOKENS_PER_MESSAGE;
24537
+ if (extraMessageCount > 0) overhead += extraMessageCount * TokenCounter.TOKENS_PER_MESSAGE;
24511
24538
  return Math.round(payloadTokens + overhead);
24512
24539
  }
24513
24540
  /**
@@ -25602,6 +25629,7 @@ function deepMergeWorkingMemory(existing, update) {
25602
25629
  for (const key of Object.keys(update)) {
25603
25630
  const updateValue = update[key];
25604
25631
  const existingValue = result[key];
25632
+ if (updateValue === void 0) continue;
25605
25633
  if (updateValue === null) delete result[key];
25606
25634
  else if (Array.isArray(updateValue)) result[key] = updateValue;
25607
25635
  else if (typeof updateValue === "object" && updateValue !== null && typeof existingValue === "object" && existingValue !== null && !Array.isArray(existingValue)) result[key] = deepMergeWorkingMemory(existingValue, updateValue);
@@ -25654,7 +25682,7 @@ const updateWorkingMemoryTool = (memoryConfig) => {
25654
25682
  version: 1,
25655
25683
  vendor: "mastra",
25656
25684
  validate: (value) => {
25657
- const memoryValue = !!value && typeof value === "object" && !Array.isArray(value) && "memory" in value ? value.memory : stripNullsFromOptional(value, jsonSchema);
25685
+ const memoryValue = stripNullsFromOptional(!!value && typeof value === "object" && !Array.isArray(value) && "memory" in value ? value.memory : value, jsonSchema);
25658
25686
  const result = validateMemory(memoryValue);
25659
25687
  return result instanceof Promise ? result.then(toWrappedResult) : toWrappedResult(result);
25660
25688
  },
@@ -25671,6 +25699,7 @@ const updateWorkingMemoryTool = (memoryConfig) => {
25671
25699
  id: "update-working-memory",
25672
25700
  description: schema ? useStateSignals ? `${stateSignalsPreamble} Data is merged with existing memory — only include fields you want to add or update.` : `Update the working memory with new information. Data is merged with existing memory - only include fields you want to add or update. To preserve existing data, omit the field entirely. Arrays are replaced entirely when provided, so pass the complete array or omit it to keep the existing values.` : useStateSignals ? `${stateSignalsPreamble} Pass the full updated Markdown blob as a string in the memory field.` : `Update the working memory with new information. Any data not included will be overwritten. Always pass data as string to the memory field. Never pass an object.`,
25673
25701
  inputSchema,
25702
+ ...usesMergeSemantics ? { strict: false } : {},
25674
25703
  execute: async (inputData, context) => {
25675
25704
  const workingMemoryInput = inputData;
25676
25705
  const threadId = context?.agent?.threadId;
@@ -44743,4 +44772,4 @@ const agentBuilderWorkflows = {
44743
44772
  //#endregion
44744
44773
  export { agentBuilderWorkflows };
44745
44774
 
44746
- //# sourceMappingURL=dist-BKRMiJcn.js.map
44775
+ //# sourceMappingURL=dist-DkY6iCA4.js.map