@mastra/server 1.60.0-alpha.11 → 1.60.0-alpha.13

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 (131) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{a2a-C4JIRtLT.cjs → a2a-BtXFFv-0.cjs} +2 -2
  3. package/dist/{a2a-C4JIRtLT.cjs.map → a2a-BtXFFv-0.cjs.map} +1 -1
  4. package/dist/{a2a-B2yosTel.js → a2a-DZhtQeFL.js} +2 -2
  5. package/dist/{a2a-B2yosTel.js.map → a2a-DZhtQeFL.js.map} +1 -1
  6. package/dist/{api-schema-manifest-Cq7dyGz7.js → api-schema-manifest-BdBDDuGv.js} +2 -2
  7. package/dist/{api-schema-manifest-Cq7dyGz7.js.map → api-schema-manifest-BdBDDuGv.js.map} +1 -1
  8. package/dist/{api-schema-manifest-DBTuPeWn.cjs → api-schema-manifest-CLvx-Pd5.cjs} +2 -2
  9. package/dist/{api-schema-manifest-DBTuPeWn.cjs.map → api-schema-manifest-CLvx-Pd5.cjs.map} +1 -1
  10. package/dist/{builder-registry-C-NVj8w5.cjs → builder-registry-Dcd_ApmT.cjs} +2 -2
  11. package/dist/{builder-registry-C-NVj8w5.cjs.map → builder-registry-Dcd_ApmT.cjs.map} +1 -1
  12. package/dist/{builder-registry-CqLsr39q.js → builder-registry-DnEa4qnF.js} +2 -2
  13. package/dist/{builder-registry-CqLsr39q.js.map → builder-registry-DnEa4qnF.js.map} +1 -1
  14. package/dist/{channels-BnFQESMf.js → channels-BO3Zd38V.js} +2 -2
  15. package/dist/{channels-BnFQESMf.js.map → channels-BO3Zd38V.js.map} +1 -1
  16. package/dist/{channels-Bn2aN-6o.cjs → channels-D9WRnKzU.cjs} +2 -2
  17. package/dist/{channels-Bn2aN-6o.cjs.map → channels-D9WRnKzU.cjs.map} +1 -1
  18. package/dist/{constants-CutMu4A_.js → constants-0jFCWoex.js} +13 -2
  19. package/dist/constants-0jFCWoex.js.map +1 -0
  20. package/dist/{constants-CXPpy-Ef.cjs → constants-4IJp_uzj.cjs} +18 -1
  21. package/dist/constants-4IJp_uzj.cjs.map +1 -0
  22. package/dist/{dist-DR_dRdv7.js → dist-0PQDswJk.js} +2692 -288
  23. package/dist/dist-0PQDswJk.js.map +1 -0
  24. package/dist/{dist-BrbvwbbJ.cjs → dist-Jy_bgZ7X.cjs} +2691 -287
  25. package/dist/dist-Jy_bgZ7X.cjs.map +1 -0
  26. package/dist/docs/SKILL.md +1 -1
  27. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  28. package/dist/{helpers-C54OMiDG.cjs → helpers-BWxRRShz.cjs} +2 -2
  29. package/dist/{helpers-C54OMiDG.cjs.map → helpers-BWxRRShz.cjs.map} +1 -1
  30. package/dist/{helpers-Da9nPOFL.js → helpers-DBAYsA50.js} +2 -2
  31. package/dist/{helpers-Da9nPOFL.js.map → helpers-DBAYsA50.js.map} +1 -1
  32. package/dist/{routes-DHRnM_bB.cjs → routes-B0T6HEoP.cjs} +8 -8
  33. package/dist/{routes-DHRnM_bB.cjs.map → routes-B0T6HEoP.cjs.map} +1 -1
  34. package/dist/{routes-DMs0TJQw.js → routes-CT1kQN7A.js} +8 -8
  35. package/dist/{routes-DMs0TJQw.js.map → routes-CT1kQN7A.js.map} +1 -1
  36. package/dist/server/auth/index.cjs +2 -2
  37. package/dist/server/auth/index.js +2 -2
  38. package/dist/server/constants.d.ts +11 -0
  39. package/dist/server/constants.d.ts.map +1 -1
  40. package/dist/server/handlers/a2a.cjs +1 -1
  41. package/dist/server/handlers/a2a.js +1 -1
  42. package/dist/server/handlers/agent-builder.cjs +2 -2
  43. package/dist/server/handlers/agent-builder.js +2 -2
  44. package/dist/server/handlers/agent-versions.cjs +1 -1
  45. package/dist/server/handlers/agent-versions.js +1 -1
  46. package/dist/server/handlers/agents.cjs +3 -3
  47. package/dist/server/handlers/agents.js +3 -3
  48. package/dist/server/handlers/auth.cjs +14 -6
  49. package/dist/server/handlers/auth.cjs.map +1 -1
  50. package/dist/server/handlers/auth.d.ts +10 -4
  51. package/dist/server/handlers/auth.d.ts.map +1 -1
  52. package/dist/server/handlers/auth.js +14 -6
  53. package/dist/server/handlers/auth.js.map +1 -1
  54. package/dist/server/handlers/authorship.cjs +1 -1
  55. package/dist/server/handlers/authorship.js +1 -1
  56. package/dist/server/handlers/builder-registry.cjs +1 -1
  57. package/dist/server/handlers/builder-registry.js +1 -1
  58. package/dist/server/handlers/channels.cjs +1 -1
  59. package/dist/server/handlers/channels.js +1 -1
  60. package/dist/server/handlers/conversations.cjs +1 -1
  61. package/dist/server/handlers/conversations.js +1 -1
  62. package/dist/server/handlers/datasets.cjs +1 -1
  63. package/dist/server/handlers/datasets.js +1 -1
  64. package/dist/server/handlers/logs.cjs +1 -1
  65. package/dist/server/handlers/logs.js +1 -1
  66. package/dist/server/handlers/mcp-client-versions.cjs +1 -1
  67. package/dist/server/handlers/mcp-client-versions.js +1 -1
  68. package/dist/server/handlers/memory.cjs +1 -1
  69. package/dist/server/handlers/memory.js +1 -1
  70. package/dist/server/handlers/observability.cjs +5 -2
  71. package/dist/server/handlers/observability.cjs.map +1 -1
  72. package/dist/server/handlers/observability.d.ts.map +1 -1
  73. package/dist/server/handlers/observability.js +6 -3
  74. package/dist/server/handlers/observability.js.map +1 -1
  75. package/dist/server/handlers/plans.cjs +1 -1
  76. package/dist/server/handlers/plans.js +1 -1
  77. package/dist/server/handlers/prompt-block-versions.cjs +1 -1
  78. package/dist/server/handlers/prompt-block-versions.js +1 -1
  79. package/dist/server/handlers/responses.cjs +1 -1
  80. package/dist/server/handlers/responses.js +1 -1
  81. package/dist/server/handlers/responses.storage.cjs +1 -1
  82. package/dist/server/handlers/responses.storage.js +1 -1
  83. package/dist/server/handlers/scorer-versions.cjs +1 -1
  84. package/dist/server/handlers/scorer-versions.js +1 -1
  85. package/dist/server/handlers/stored-agent-favorites.cjs +1 -1
  86. package/dist/server/handlers/stored-agent-favorites.js +1 -1
  87. package/dist/server/handlers/stored-agents.cjs +3 -3
  88. package/dist/server/handlers/stored-agents.js +3 -3
  89. package/dist/server/handlers/stored-mcp-clients.cjs +1 -1
  90. package/dist/server/handlers/stored-mcp-clients.js +1 -1
  91. package/dist/server/handlers/stored-prompt-blocks.cjs +1 -1
  92. package/dist/server/handlers/stored-prompt-blocks.js +1 -1
  93. package/dist/server/handlers/stored-scorers.cjs +1 -1
  94. package/dist/server/handlers/stored-scorers.js +1 -1
  95. package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
  96. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  97. package/dist/server/handlers/stored-skills.cjs +1 -1
  98. package/dist/server/handlers/stored-skills.js +1 -1
  99. package/dist/server/handlers/stored-workspaces.cjs +1 -1
  100. package/dist/server/handlers/stored-workspaces.js +1 -1
  101. package/dist/server/handlers/system.cjs +1 -1
  102. package/dist/server/handlers/system.js +1 -1
  103. package/dist/server/handlers/tool-providers.cjs +1 -1
  104. package/dist/server/handlers/tool-providers.js +1 -1
  105. package/dist/server/handlers/tools.cjs +2 -2
  106. package/dist/server/handlers/tools.js +2 -2
  107. package/dist/server/handlers/utils.cjs +1 -1
  108. package/dist/server/handlers/utils.js +1 -1
  109. package/dist/server/handlers/validate-agent-instructions.cjs +1 -1
  110. package/dist/server/handlers/validate-agent-instructions.js +1 -1
  111. package/dist/server/handlers/workflows.cjs +2 -2
  112. package/dist/server/handlers/workflows.js +2 -2
  113. package/dist/server/handlers.cjs +1 -1
  114. package/dist/server/handlers.js +1 -1
  115. package/dist/server/schemas/index.cjs +5 -5
  116. package/dist/server/schemas/index.js +5 -5
  117. package/dist/server/server-adapter/index.cjs +5 -5
  118. package/dist/server/server-adapter/index.js +5 -5
  119. package/dist/{utils-CljhO7OY.js → utils-B2vd77Fi.js} +2 -2
  120. package/dist/{utils-CljhO7OY.js.map → utils-B2vd77Fi.js.map} +1 -1
  121. package/dist/{utils-zkjmP1OK.cjs → utils-CmYnjLcY.cjs} +2 -2
  122. package/dist/{utils-zkjmP1OK.cjs.map → utils-CmYnjLcY.cjs.map} +1 -1
  123. package/dist/{utils-Xnn91QBW.cjs → utils-DJMUhfvY.cjs} +2 -2
  124. package/dist/{utils-Xnn91QBW.cjs.map → utils-DJMUhfvY.cjs.map} +1 -1
  125. package/dist/{utils-qMLbyf2U.js → utils-Hz8Hc2cd.js} +2 -2
  126. package/dist/{utils-qMLbyf2U.js.map → utils-Hz8Hc2cd.js.map} +1 -1
  127. package/package.json +5 -5
  128. package/dist/constants-CXPpy-Ef.cjs.map +0 -1
  129. package/dist/constants-CutMu4A_.js.map +0 -1
  130. package/dist/dist-BrbvwbbJ.cjs.map +0 -1
  131. package/dist/dist-DR_dRdv7.js.map +0 -1
@@ -25,6 +25,17 @@ const MASTRA_INHERITED_MEMORY_KEY = "mastra__inheritedMemory";
25
25
  */
26
26
  const MASTRA_AUTH_MODE_KEY = "mastra__authMode";
27
27
  const MASTRA_CLIENT_TYPE_HEADER = "x-mastra-client-type";
28
+ /**
29
+ * Browser-facing host, set by a trusted proxy whose own `X-Forwarded-Host` does
30
+ * not survive the hop to the app. Railway's gateway, for example, overwrites
31
+ * `X-Forwarded-Host` with its internal domain, so an edge in front of it has no
32
+ * other way to tell the app which hostname the user actually typed.
33
+ *
34
+ * Read by `getPublicOrigin()` ahead of `X-Forwarded-Host`. Carries the same
35
+ * trust assumption as the other forwarded headers: meaningful only behind a
36
+ * proxy that sets it, and it must be stripped from untrusted client requests.
37
+ */
38
+ const MASTRA_PUBLIC_HOST_HEADER = "x-mastra-public-host";
28
39
  const MASTRA_STUDIO_CLIENT_TYPE = "studio";
29
40
  const RESERVED_CONTEXT_KEYS = /* @__PURE__ */ new Set([
30
41
  MASTRA_RESOURCE_ID_KEY,
@@ -106,6 +117,6 @@ async function resolveToolConfig(toolsConfig, toolName, context) {
106
117
  };
107
118
  }
108
119
  //#endregion
109
- export { MASTRA_RESOURCE_ID_KEY as a, MASTRA_USER_KEY as c, WORKSPACE_TOOLS as d, isReservedRequestContextKey as f, MASTRA_IS_STUDIO_KEY as i, MASTRA_USER_PERMISSIONS_KEY as l, resolveToolConfig as m, MASTRA_AUTH_TOKEN_KEY as n, MASTRA_STUDIO_CLIENT_TYPE as o, isStudioClientTypeHeader as p, MASTRA_CLIENT_TYPE_HEADER as r, MASTRA_THREAD_ID_KEY as s, MASTRA_AUTH_MODE_KEY as t, MASTRA_USER_ROLES_KEY as u };
120
+ export { MASTRA_PUBLIC_HOST_HEADER as a, MASTRA_THREAD_ID_KEY as c, MASTRA_USER_ROLES_KEY as d, WORKSPACE_TOOLS as f, resolveToolConfig as h, MASTRA_IS_STUDIO_KEY as i, MASTRA_USER_KEY as l, isStudioClientTypeHeader as m, MASTRA_AUTH_TOKEN_KEY as n, MASTRA_RESOURCE_ID_KEY as o, isReservedRequestContextKey as p, MASTRA_CLIENT_TYPE_HEADER as r, MASTRA_STUDIO_CLIENT_TYPE as s, MASTRA_AUTH_MODE_KEY as t, MASTRA_USER_PERMISSIONS_KEY as u };
110
121
 
111
- //# sourceMappingURL=constants-CutMu4A_.js.map
122
+ //# sourceMappingURL=constants-0jFCWoex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-0jFCWoex.js","names":[],"sources":["../src/server/constants.ts"],"sourcesContent":["/**\n * Constants inlined from @mastra/core to avoid import compatibility\n * issues with older core versions that don't export them yet.\n *\n * - Reserved RequestContext keys are inlined from @mastra/core/request-context.\n * - Workspace tool constants are inlined from @mastra/core/workspace.\n */\n\nexport const MASTRA_RESOURCE_ID_KEY = 'mastra__resourceId';\n\nexport const MASTRA_THREAD_ID_KEY = 'mastra__threadId';\n\nexport const MASTRA_USER_KEY = 'mastra__user';\n\nexport const MASTRA_USER_PERMISSIONS_KEY = 'mastra__userPermissions';\n\nexport const MASTRA_USER_ROLES_KEY = 'mastra__userRoles';\n\nexport const MASTRA_AUTH_TOKEN_KEY = 'mastra__authToken';\n\nexport const MASTRA_IS_STUDIO_KEY = 'mastra__isStudio';\n\n/**\n * Carries a delegating agent's memory into a delegated sub-agent run. Set only\n * by the delegation path inside a single process.\n */\nexport const MASTRA_INHERITED_MEMORY_KEY = 'mastra__inheritedMemory';\n\n/**\n * Tracks which auth mode was used for the current request.\n * Set to 'studio' when studio auth was used, 'server' when server auth was used.\n * Used to determine which RBAC/FGA provider to use for permission checks.\n */\nexport const MASTRA_AUTH_MODE_KEY = 'mastra__authMode';\n\nexport type MastraAuthMode = 'studio' | 'server';\n\nexport const MASTRA_CLIENT_TYPE_HEADER = 'x-mastra-client-type';\n\n/**\n * Browser-facing host, set by a trusted proxy whose own `X-Forwarded-Host` does\n * not survive the hop to the app. Railway's gateway, for example, overwrites\n * `X-Forwarded-Host` with its internal domain, so an edge in front of it has no\n * other way to tell the app which hostname the user actually typed.\n *\n * Read by `getPublicOrigin()` ahead of `X-Forwarded-Host`. Carries the same\n * trust assumption as the other forwarded headers: meaningful only behind a\n * proxy that sets it, and it must be stripped from untrusted client requests.\n */\nexport const MASTRA_PUBLIC_HOST_HEADER = 'x-mastra-public-host';\n\nexport const MASTRA_STUDIO_CLIENT_TYPE = 'studio';\n\nconst RESERVED_CONTEXT_KEYS = new Set([\n MASTRA_RESOURCE_ID_KEY,\n MASTRA_THREAD_ID_KEY,\n MASTRA_USER_KEY,\n MASTRA_USER_PERMISSIONS_KEY,\n MASTRA_USER_ROLES_KEY,\n MASTRA_AUTH_TOKEN_KEY,\n MASTRA_IS_STUDIO_KEY,\n MASTRA_AUTH_MODE_KEY,\n // Delegation stores a live memory instance here. A body-supplied value would\n // be handed to the agent as its memory and throw on the first memory call.\n MASTRA_INHERITED_MEMORY_KEY,\n // Tenant scope must be established server-side, never self-asserted by a\n // client. The trusted-actor FGA gate keys off `organizationId`, so a\n // body-supplied value must not be merged into the request context.\n 'organizationId',\n]);\n\nexport function isReservedRequestContextKey(key: string): boolean {\n return RESERVED_CONTEXT_KEYS.has(key);\n}\n\nexport function isStudioClientTypeHeader(value: string | undefined): boolean {\n return value?.toLowerCase() === MASTRA_STUDIO_CLIENT_TYPE;\n}\n\nexport const WORKSPACE_TOOLS_PREFIX = 'mastra_workspace' as const;\n\nexport const WORKSPACE_TOOLS = {\n FILESYSTEM: {\n READ_FILE: `${WORKSPACE_TOOLS_PREFIX}_read_file` as const,\n WRITE_FILE: `${WORKSPACE_TOOLS_PREFIX}_write_file` as const,\n EDIT_FILE: `${WORKSPACE_TOOLS_PREFIX}_edit_file` as const,\n LIST_FILES: `${WORKSPACE_TOOLS_PREFIX}_list_files` as const,\n DELETE: `${WORKSPACE_TOOLS_PREFIX}_delete` as const,\n FILE_STAT: `${WORKSPACE_TOOLS_PREFIX}_file_stat` as const,\n MKDIR: `${WORKSPACE_TOOLS_PREFIX}_mkdir` as const,\n GREP: `${WORKSPACE_TOOLS_PREFIX}_grep` as const,\n },\n SANDBOX: {\n EXECUTE_COMMAND: `${WORKSPACE_TOOLS_PREFIX}_execute_command` as const,\n },\n SEARCH: {\n SEARCH: `${WORKSPACE_TOOLS_PREFIX}_search` as const,\n INDEX: `${WORKSPACE_TOOLS_PREFIX}_index` as const,\n },\n} as const;\n\nexport type WorkspaceToolName =\n | (typeof WORKSPACE_TOOLS.FILESYSTEM)[keyof typeof WORKSPACE_TOOLS.FILESYSTEM]\n | (typeof WORKSPACE_TOOLS.SEARCH)[keyof typeof WORKSPACE_TOOLS.SEARCH]\n | (typeof WORKSPACE_TOOLS.SANDBOX)[keyof typeof WORKSPACE_TOOLS.SANDBOX];\n\n/**\n * A tool config value that may be a static boolean or a dynamic function.\n * Inlined from @mastra/core/workspace for compatibility.\n *\n * Uses `(...args: any[]) => any` for the function branch so it stays\n * assignable from all core context variants (ToolConfigContext,\n * ToolConfigWithArgsContext) without importing them.\n */\n\ntype DynamicToolConfigValue = boolean | ((...args: any[]) => any);\n\n/**\n * Configuration for a single workspace tool.\n */\nexport interface WorkspaceToolConfig {\n enabled?: DynamicToolConfigValue;\n requireApproval?: DynamicToolConfigValue;\n requireReadBeforeWrite?: DynamicToolConfigValue;\n}\n\n/**\n * Configuration for workspace tools.\n */\nexport type WorkspaceToolsConfig = {\n enabled?: DynamicToolConfigValue;\n requireApproval?: DynamicToolConfigValue;\n} & Partial<Record<WorkspaceToolName, WorkspaceToolConfig>>;\n\n/**\n * Safely resolve a dynamic config value (boolean or async function) to a boolean.\n * Falls back to `safeDefault` when no context is available or the function throws.\n */\nasync function resolveDynamicValue(\n value: DynamicToolConfigValue | undefined,\n context: { workspace: object; requestContext: Record<string, unknown> } | undefined,\n safeDefault: boolean,\n): Promise<boolean> {\n if (value === undefined) return safeDefault;\n if (typeof value === 'boolean') return value;\n if (!context) return safeDefault;\n try {\n return await value(context);\n } catch (error) {\n console.warn('[Workspace Tools] Dynamic config function threw, using safe default:', error);\n return safeDefault;\n }\n}\n\n/**\n * Resolve the effective configuration for a workspace tool.\n * Inlined from @mastra/core/workspace for compatibility.\n *\n * Dynamic function values are resolved by calling them with the provided\n * workspace and requestContext. If a function throws, safe defaults are used\n * (enabled → false, requireApproval → true, requireReadBeforeWrite → true).\n */\nexport async function resolveToolConfig(\n toolsConfig: WorkspaceToolsConfig | undefined,\n toolName: WorkspaceToolName,\n context?: { workspace: object; requestContext: Record<string, unknown> },\n): Promise<{ enabled: boolean; requireApproval: boolean; requireReadBeforeWrite?: boolean }> {\n let enabled: DynamicToolConfigValue = true;\n let requireApproval: DynamicToolConfigValue = false;\n let requireReadBeforeWrite: DynamicToolConfigValue | undefined;\n\n if (toolsConfig) {\n if (toolsConfig.enabled !== undefined) {\n enabled = toolsConfig.enabled;\n }\n if (toolsConfig.requireApproval !== undefined) {\n requireApproval = toolsConfig.requireApproval;\n }\n\n const perToolConfig = toolsConfig[toolName];\n if (perToolConfig) {\n if (perToolConfig.enabled !== undefined) {\n enabled = perToolConfig.enabled;\n }\n if (perToolConfig.requireApproval !== undefined) {\n requireApproval = perToolConfig.requireApproval;\n }\n if (perToolConfig.requireReadBeforeWrite !== undefined) {\n requireReadBeforeWrite = perToolConfig.requireReadBeforeWrite;\n }\n }\n }\n\n return {\n enabled: await resolveDynamicValue(enabled, context, false),\n requireApproval: await resolveDynamicValue(requireApproval, context, true),\n requireReadBeforeWrite:\n requireReadBeforeWrite !== undefined\n ? await resolveDynamicValue(requireReadBeforeWrite, context, true)\n : undefined,\n };\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,yBAAyB;AAEtC,MAAa,uBAAuB;AAEpC,MAAa,kBAAkB;AAE/B,MAAa,8BAA8B;AAE3C,MAAa,wBAAwB;AAErC,MAAa,wBAAwB;AAErC,MAAa,uBAAuB;;;;;AAMpC,MAAa,8BAA8B;;;;;;AAO3C,MAAa,uBAAuB;AAIpC,MAAa,4BAA4B;;;;;;;;;;;AAYzC,MAAa,4BAA4B;AAEzC,MAAa,4BAA4B;AAEzC,MAAM,wCAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CAIA;AACF,CAAC;AAED,SAAgB,4BAA4B,KAAsB;CAChE,OAAO,sBAAsB,IAAI,GAAG;AACtC;AAEA,SAAgB,yBAAyB,OAAoC;CAC3E,OAAO,OAAO,YAAY,MAAM;AAClC;AAEA,MAAa,yBAAyB;AAEtC,MAAa,kBAAkB;CAC7B,YAAY;EACV,WAAW,GAAG,uBAAuB;EACrC,YAAY,GAAG,uBAAuB;EACtC,WAAW,GAAG,uBAAuB;EACrC,YAAY,GAAG,uBAAuB;EACtC,QAAQ,GAAG,uBAAuB;EAClC,WAAW,GAAG,uBAAuB;EACrC,OAAO,GAAG,uBAAuB;EACjC,MAAM,GAAG,uBAAuB;CAClC;CACA,SAAS,EACP,iBAAiB,GAAG,uBAAuB,kBAC7C;CACA,QAAQ;EACN,QAAQ,GAAG,uBAAuB;EAClC,OAAO,GAAG,uBAAuB;CACnC;AACF;;;;;AAuCA,eAAe,oBACb,OACA,SACA,aACkB;CAClB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,OAAO,UAAU,WAAW,OAAO;CACvC,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI;EACF,OAAO,MAAM,MAAM,OAAO;CAC5B,SAAS,OAAO;EACd,QAAQ,KAAK,wEAAwE,KAAK;EAC1F,OAAO;CACT;AACF;;;;;;;;;AAUA,eAAsB,kBACpB,aACA,UACA,SAC2F;CAC3F,IAAI,UAAkC;CACtC,IAAI,kBAA0C;CAC9C,IAAI;CAEJ,IAAI,aAAa;EACf,IAAI,YAAY,YAAY,KAAA,GAC1B,UAAU,YAAY;EAExB,IAAI,YAAY,oBAAoB,KAAA,GAClC,kBAAkB,YAAY;EAGhC,MAAM,gBAAgB,YAAY;EAClC,IAAI,eAAe;GACjB,IAAI,cAAc,YAAY,KAAA,GAC5B,UAAU,cAAc;GAE1B,IAAI,cAAc,oBAAoB,KAAA,GACpC,kBAAkB,cAAc;GAElC,IAAI,cAAc,2BAA2B,KAAA,GAC3C,yBAAyB,cAAc;EAE3C;CACF;CAEA,OAAO;EACL,SAAS,MAAM,oBAAoB,SAAS,SAAS,KAAK;EAC1D,iBAAiB,MAAM,oBAAoB,iBAAiB,SAAS,IAAI;EACzE,wBACE,2BAA2B,KAAA,IACvB,MAAM,oBAAoB,wBAAwB,SAAS,IAAI,IAC/D,KAAA;CACR;AACF"}
@@ -25,6 +25,17 @@ const MASTRA_INHERITED_MEMORY_KEY = "mastra__inheritedMemory";
25
25
  */
26
26
  const MASTRA_AUTH_MODE_KEY = "mastra__authMode";
27
27
  const MASTRA_CLIENT_TYPE_HEADER = "x-mastra-client-type";
28
+ /**
29
+ * Browser-facing host, set by a trusted proxy whose own `X-Forwarded-Host` does
30
+ * not survive the hop to the app. Railway's gateway, for example, overwrites
31
+ * `X-Forwarded-Host` with its internal domain, so an edge in front of it has no
32
+ * other way to tell the app which hostname the user actually typed.
33
+ *
34
+ * Read by `getPublicOrigin()` ahead of `X-Forwarded-Host`. Carries the same
35
+ * trust assumption as the other forwarded headers: meaningful only behind a
36
+ * proxy that sets it, and it must be stripped from untrusted client requests.
37
+ */
38
+ const MASTRA_PUBLIC_HOST_HEADER = "x-mastra-public-host";
28
39
  const MASTRA_STUDIO_CLIENT_TYPE = "studio";
29
40
  const RESERVED_CONTEXT_KEYS = /* @__PURE__ */ new Set([
30
41
  MASTRA_RESOURCE_ID_KEY,
@@ -130,6 +141,12 @@ Object.defineProperty(exports, "MASTRA_IS_STUDIO_KEY", {
130
141
  return MASTRA_IS_STUDIO_KEY;
131
142
  }
132
143
  });
144
+ Object.defineProperty(exports, "MASTRA_PUBLIC_HOST_HEADER", {
145
+ enumerable: true,
146
+ get: function() {
147
+ return MASTRA_PUBLIC_HOST_HEADER;
148
+ }
149
+ });
133
150
  Object.defineProperty(exports, "MASTRA_RESOURCE_ID_KEY", {
134
151
  enumerable: true,
135
152
  get: function() {
@@ -191,4 +208,4 @@ Object.defineProperty(exports, "resolveToolConfig", {
191
208
  }
192
209
  });
193
210
 
194
- //# sourceMappingURL=constants-CXPpy-Ef.cjs.map
211
+ //# sourceMappingURL=constants-4IJp_uzj.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-4IJp_uzj.cjs","names":[],"sources":["../src/server/constants.ts"],"sourcesContent":["/**\n * Constants inlined from @mastra/core to avoid import compatibility\n * issues with older core versions that don't export them yet.\n *\n * - Reserved RequestContext keys are inlined from @mastra/core/request-context.\n * - Workspace tool constants are inlined from @mastra/core/workspace.\n */\n\nexport const MASTRA_RESOURCE_ID_KEY = 'mastra__resourceId';\n\nexport const MASTRA_THREAD_ID_KEY = 'mastra__threadId';\n\nexport const MASTRA_USER_KEY = 'mastra__user';\n\nexport const MASTRA_USER_PERMISSIONS_KEY = 'mastra__userPermissions';\n\nexport const MASTRA_USER_ROLES_KEY = 'mastra__userRoles';\n\nexport const MASTRA_AUTH_TOKEN_KEY = 'mastra__authToken';\n\nexport const MASTRA_IS_STUDIO_KEY = 'mastra__isStudio';\n\n/**\n * Carries a delegating agent's memory into a delegated sub-agent run. Set only\n * by the delegation path inside a single process.\n */\nexport const MASTRA_INHERITED_MEMORY_KEY = 'mastra__inheritedMemory';\n\n/**\n * Tracks which auth mode was used for the current request.\n * Set to 'studio' when studio auth was used, 'server' when server auth was used.\n * Used to determine which RBAC/FGA provider to use for permission checks.\n */\nexport const MASTRA_AUTH_MODE_KEY = 'mastra__authMode';\n\nexport type MastraAuthMode = 'studio' | 'server';\n\nexport const MASTRA_CLIENT_TYPE_HEADER = 'x-mastra-client-type';\n\n/**\n * Browser-facing host, set by a trusted proxy whose own `X-Forwarded-Host` does\n * not survive the hop to the app. Railway's gateway, for example, overwrites\n * `X-Forwarded-Host` with its internal domain, so an edge in front of it has no\n * other way to tell the app which hostname the user actually typed.\n *\n * Read by `getPublicOrigin()` ahead of `X-Forwarded-Host`. Carries the same\n * trust assumption as the other forwarded headers: meaningful only behind a\n * proxy that sets it, and it must be stripped from untrusted client requests.\n */\nexport const MASTRA_PUBLIC_HOST_HEADER = 'x-mastra-public-host';\n\nexport const MASTRA_STUDIO_CLIENT_TYPE = 'studio';\n\nconst RESERVED_CONTEXT_KEYS = new Set([\n MASTRA_RESOURCE_ID_KEY,\n MASTRA_THREAD_ID_KEY,\n MASTRA_USER_KEY,\n MASTRA_USER_PERMISSIONS_KEY,\n MASTRA_USER_ROLES_KEY,\n MASTRA_AUTH_TOKEN_KEY,\n MASTRA_IS_STUDIO_KEY,\n MASTRA_AUTH_MODE_KEY,\n // Delegation stores a live memory instance here. A body-supplied value would\n // be handed to the agent as its memory and throw on the first memory call.\n MASTRA_INHERITED_MEMORY_KEY,\n // Tenant scope must be established server-side, never self-asserted by a\n // client. The trusted-actor FGA gate keys off `organizationId`, so a\n // body-supplied value must not be merged into the request context.\n 'organizationId',\n]);\n\nexport function isReservedRequestContextKey(key: string): boolean {\n return RESERVED_CONTEXT_KEYS.has(key);\n}\n\nexport function isStudioClientTypeHeader(value: string | undefined): boolean {\n return value?.toLowerCase() === MASTRA_STUDIO_CLIENT_TYPE;\n}\n\nexport const WORKSPACE_TOOLS_PREFIX = 'mastra_workspace' as const;\n\nexport const WORKSPACE_TOOLS = {\n FILESYSTEM: {\n READ_FILE: `${WORKSPACE_TOOLS_PREFIX}_read_file` as const,\n WRITE_FILE: `${WORKSPACE_TOOLS_PREFIX}_write_file` as const,\n EDIT_FILE: `${WORKSPACE_TOOLS_PREFIX}_edit_file` as const,\n LIST_FILES: `${WORKSPACE_TOOLS_PREFIX}_list_files` as const,\n DELETE: `${WORKSPACE_TOOLS_PREFIX}_delete` as const,\n FILE_STAT: `${WORKSPACE_TOOLS_PREFIX}_file_stat` as const,\n MKDIR: `${WORKSPACE_TOOLS_PREFIX}_mkdir` as const,\n GREP: `${WORKSPACE_TOOLS_PREFIX}_grep` as const,\n },\n SANDBOX: {\n EXECUTE_COMMAND: `${WORKSPACE_TOOLS_PREFIX}_execute_command` as const,\n },\n SEARCH: {\n SEARCH: `${WORKSPACE_TOOLS_PREFIX}_search` as const,\n INDEX: `${WORKSPACE_TOOLS_PREFIX}_index` as const,\n },\n} as const;\n\nexport type WorkspaceToolName =\n | (typeof WORKSPACE_TOOLS.FILESYSTEM)[keyof typeof WORKSPACE_TOOLS.FILESYSTEM]\n | (typeof WORKSPACE_TOOLS.SEARCH)[keyof typeof WORKSPACE_TOOLS.SEARCH]\n | (typeof WORKSPACE_TOOLS.SANDBOX)[keyof typeof WORKSPACE_TOOLS.SANDBOX];\n\n/**\n * A tool config value that may be a static boolean or a dynamic function.\n * Inlined from @mastra/core/workspace for compatibility.\n *\n * Uses `(...args: any[]) => any` for the function branch so it stays\n * assignable from all core context variants (ToolConfigContext,\n * ToolConfigWithArgsContext) without importing them.\n */\n\ntype DynamicToolConfigValue = boolean | ((...args: any[]) => any);\n\n/**\n * Configuration for a single workspace tool.\n */\nexport interface WorkspaceToolConfig {\n enabled?: DynamicToolConfigValue;\n requireApproval?: DynamicToolConfigValue;\n requireReadBeforeWrite?: DynamicToolConfigValue;\n}\n\n/**\n * Configuration for workspace tools.\n */\nexport type WorkspaceToolsConfig = {\n enabled?: DynamicToolConfigValue;\n requireApproval?: DynamicToolConfigValue;\n} & Partial<Record<WorkspaceToolName, WorkspaceToolConfig>>;\n\n/**\n * Safely resolve a dynamic config value (boolean or async function) to a boolean.\n * Falls back to `safeDefault` when no context is available or the function throws.\n */\nasync function resolveDynamicValue(\n value: DynamicToolConfigValue | undefined,\n context: { workspace: object; requestContext: Record<string, unknown> } | undefined,\n safeDefault: boolean,\n): Promise<boolean> {\n if (value === undefined) return safeDefault;\n if (typeof value === 'boolean') return value;\n if (!context) return safeDefault;\n try {\n return await value(context);\n } catch (error) {\n console.warn('[Workspace Tools] Dynamic config function threw, using safe default:', error);\n return safeDefault;\n }\n}\n\n/**\n * Resolve the effective configuration for a workspace tool.\n * Inlined from @mastra/core/workspace for compatibility.\n *\n * Dynamic function values are resolved by calling them with the provided\n * workspace and requestContext. If a function throws, safe defaults are used\n * (enabled → false, requireApproval → true, requireReadBeforeWrite → true).\n */\nexport async function resolveToolConfig(\n toolsConfig: WorkspaceToolsConfig | undefined,\n toolName: WorkspaceToolName,\n context?: { workspace: object; requestContext: Record<string, unknown> },\n): Promise<{ enabled: boolean; requireApproval: boolean; requireReadBeforeWrite?: boolean }> {\n let enabled: DynamicToolConfigValue = true;\n let requireApproval: DynamicToolConfigValue = false;\n let requireReadBeforeWrite: DynamicToolConfigValue | undefined;\n\n if (toolsConfig) {\n if (toolsConfig.enabled !== undefined) {\n enabled = toolsConfig.enabled;\n }\n if (toolsConfig.requireApproval !== undefined) {\n requireApproval = toolsConfig.requireApproval;\n }\n\n const perToolConfig = toolsConfig[toolName];\n if (perToolConfig) {\n if (perToolConfig.enabled !== undefined) {\n enabled = perToolConfig.enabled;\n }\n if (perToolConfig.requireApproval !== undefined) {\n requireApproval = perToolConfig.requireApproval;\n }\n if (perToolConfig.requireReadBeforeWrite !== undefined) {\n requireReadBeforeWrite = perToolConfig.requireReadBeforeWrite;\n }\n }\n }\n\n return {\n enabled: await resolveDynamicValue(enabled, context, false),\n requireApproval: await resolveDynamicValue(requireApproval, context, true),\n requireReadBeforeWrite:\n requireReadBeforeWrite !== undefined\n ? await resolveDynamicValue(requireReadBeforeWrite, context, true)\n : undefined,\n };\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,yBAAyB;AAEtC,MAAa,uBAAuB;AAEpC,MAAa,kBAAkB;AAE/B,MAAa,8BAA8B;AAE3C,MAAa,wBAAwB;AAErC,MAAa,wBAAwB;AAErC,MAAa,uBAAuB;;;;;AAMpC,MAAa,8BAA8B;;;;;;AAO3C,MAAa,uBAAuB;AAIpC,MAAa,4BAA4B;;;;;;;;;;;AAYzC,MAAa,4BAA4B;AAEzC,MAAa,4BAA4B;AAEzC,MAAM,wCAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CAIA;AACF,CAAC;AAED,SAAgB,4BAA4B,KAAsB;CAChE,OAAO,sBAAsB,IAAI,GAAG;AACtC;AAEA,SAAgB,yBAAyB,OAAoC;CAC3E,OAAO,OAAO,YAAY,MAAM;AAClC;AAEA,MAAa,yBAAyB;AAEtC,MAAa,kBAAkB;CAC7B,YAAY;EACV,WAAW,GAAG,uBAAuB;EACrC,YAAY,GAAG,uBAAuB;EACtC,WAAW,GAAG,uBAAuB;EACrC,YAAY,GAAG,uBAAuB;EACtC,QAAQ,GAAG,uBAAuB;EAClC,WAAW,GAAG,uBAAuB;EACrC,OAAO,GAAG,uBAAuB;EACjC,MAAM,GAAG,uBAAuB;CAClC;CACA,SAAS,EACP,iBAAiB,GAAG,uBAAuB,kBAC7C;CACA,QAAQ;EACN,QAAQ,GAAG,uBAAuB;EAClC,OAAO,GAAG,uBAAuB;CACnC;AACF;;;;;AAuCA,eAAe,oBACb,OACA,SACA,aACkB;CAClB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,OAAO,UAAU,WAAW,OAAO;CACvC,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI;EACF,OAAO,MAAM,MAAM,OAAO;CAC5B,SAAS,OAAO;EACd,QAAQ,KAAK,wEAAwE,KAAK;EAC1F,OAAO;CACT;AACF;;;;;;;;;AAUA,eAAsB,kBACpB,aACA,UACA,SAC2F;CAC3F,IAAI,UAAkC;CACtC,IAAI,kBAA0C;CAC9C,IAAI;CAEJ,IAAI,aAAa;EACf,IAAI,YAAY,YAAY,KAAA,GAC1B,UAAU,YAAY;EAExB,IAAI,YAAY,oBAAoB,KAAA,GAClC,kBAAkB,YAAY;EAGhC,MAAM,gBAAgB,YAAY;EAClC,IAAI,eAAe;GACjB,IAAI,cAAc,YAAY,KAAA,GAC5B,UAAU,cAAc;GAE1B,IAAI,cAAc,oBAAoB,KAAA,GACpC,kBAAkB,cAAc;GAElC,IAAI,cAAc,2BAA2B,KAAA,GAC3C,yBAAyB,cAAc;EAE3C;CACF;CAEA,OAAO;EACL,SAAS,MAAM,oBAAoB,SAAS,SAAS,KAAK;EAC1D,iBAAiB,MAAM,oBAAoB,iBAAiB,SAAS,IAAI;EACzE,wBACE,2BAA2B,KAAA,IACvB,MAAM,oBAAoB,wBAAwB,SAAS,IAAI,IAC/D,KAAA;CACR;AACF"}