@mastra/deployer 0.23.3 → 0.24.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 (49) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/build/analyze/analyzeEntry.d.ts +2 -1
  3. package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
  4. package/dist/build/analyze/constants.d.ts.map +1 -1
  5. package/dist/build/analyze.cjs +2 -2
  6. package/dist/build/analyze.js +1 -1
  7. package/dist/build/bundler.cjs +3 -3
  8. package/dist/build/bundler.js +1 -1
  9. package/dist/build/index.cjs +12 -12
  10. package/dist/build/index.js +4 -4
  11. package/dist/bundler/index.cjs +2 -2
  12. package/dist/bundler/index.js +1 -1
  13. package/dist/{chunk-HPIEW72C.cjs → chunk-AJX72IGP.cjs} +5 -5
  14. package/dist/{chunk-HPIEW72C.cjs.map → chunk-AJX72IGP.cjs.map} +1 -1
  15. package/dist/{chunk-BS2NS3OF.js → chunk-B2Q76NIL.js} +3 -3
  16. package/dist/{chunk-BS2NS3OF.js.map → chunk-B2Q76NIL.js.map} +1 -1
  17. package/dist/{chunk-S5UMATJZ.js → chunk-CVRN2K4O.js} +21 -11
  18. package/dist/chunk-CVRN2K4O.js.map +1 -0
  19. package/dist/{chunk-X4PRG273.js → chunk-FD5X42ZU.js} +4 -4
  20. package/dist/{chunk-X4PRG273.js.map → chunk-FD5X42ZU.js.map} +1 -1
  21. package/dist/{chunk-WVZENB5V.cjs → chunk-IAEJ3C3J.cjs} +21 -11
  22. package/dist/chunk-IAEJ3C3J.cjs.map +1 -0
  23. package/dist/{chunk-NMOPG6KM.cjs → chunk-NSINCI76.cjs} +9 -9
  24. package/dist/{chunk-NMOPG6KM.cjs.map → chunk-NSINCI76.cjs.map} +1 -1
  25. package/dist/{chunk-7TQIPPJV.cjs → chunk-OART5HV7.cjs} +15 -15
  26. package/dist/{chunk-7TQIPPJV.cjs.map → chunk-OART5HV7.cjs.map} +1 -1
  27. package/dist/{chunk-BTSMIAV6.js → chunk-VDRZB7JQ.js} +5 -5
  28. package/dist/{chunk-BTSMIAV6.js.map → chunk-VDRZB7JQ.js.map} +1 -1
  29. package/dist/{chunk-F54BDKO2.js → chunk-XHLN6E4D.js} +3 -3
  30. package/dist/{chunk-F54BDKO2.js.map → chunk-XHLN6E4D.js.map} +1 -1
  31. package/dist/{chunk-OVVFXLQK.cjs → chunk-Z546LAA6.cjs} +14 -14
  32. package/dist/{chunk-OVVFXLQK.cjs.map → chunk-Z546LAA6.cjs.map} +1 -1
  33. package/dist/index.cjs +5 -5
  34. package/dist/index.js +2 -2
  35. package/dist/server/handlers/auth/defaults.d.ts.map +1 -1
  36. package/dist/server/handlers/routes/agents/handlers.d.ts +1 -10
  37. package/dist/server/handlers/routes/agents/handlers.d.ts.map +1 -1
  38. package/dist/server/handlers/routes/agents/router.d.ts.map +1 -1
  39. package/dist/server/handlers/routes/memory/handlers.d.ts.map +1 -1
  40. package/dist/server/handlers/utils.d.ts +0 -7
  41. package/dist/server/handlers/utils.d.ts.map +1 -1
  42. package/dist/server/index.cjs +267 -248
  43. package/dist/server/index.cjs.map +1 -1
  44. package/dist/server/index.d.ts.map +1 -1
  45. package/dist/server/index.js +268 -249
  46. package/dist/server/index.js.map +1 -1
  47. package/package.json +7 -7
  48. package/dist/chunk-S5UMATJZ.js.map +0 -1
  49. package/dist/chunk-WVZENB5V.cjs.map +0 -1
@@ -24,13 +24,13 @@ var a2a = require('@mastra/server/handlers/a2a');
24
24
  var streaming = require('hono/streaming');
25
25
  var bodyLimit = require('hono/body-limit');
26
26
  var agentBuilder = require('@mastra/server/handlers/agent-builder');
27
+ var agent = require('@mastra/core/agent');
28
+ var zod = require('zod');
29
+ var tools$1 = require('@mastra/server/handlers/tools');
27
30
  var error = require('@mastra/core/error');
28
31
  var llm = require('@mastra/core/llm');
29
32
  var stream$1 = require('@mastra/core/stream');
30
33
  var agents = require('@mastra/server/handlers/agents');
31
- var agent = require('@mastra/core/agent');
32
- var zod = require('zod');
33
- var tools$1 = require('@mastra/server/handlers/tools');
34
34
  var voice = require('@mastra/server/handlers/voice');
35
35
  var logs = require('@mastra/server/handlers/logs');
36
36
  var util = require('util');
@@ -1056,6 +1056,7 @@ async function getAgentExecutionHandler(c2) {
1056
1056
  // src/server/handlers/auth/defaults.ts
1057
1057
  var defaultAuthConfig = {
1058
1058
  protected: ["/api/*"],
1059
+ public: ["/api"],
1059
1060
  // Simple rule system
1060
1061
  rules: [
1061
1062
  // Admin users can do anything
@@ -2320,15 +2321,196 @@ function agentBuilderRouter(bodyLimitOptions) {
2320
2321
  );
2321
2322
  return router;
2322
2323
  }
2323
- var AllowedProviderKeys = {
2324
- openai: "OPENAI_API_KEY",
2325
- xai: "XAI_API_KEY",
2326
- anthropic: "ANTHROPIC_API_KEY",
2327
- google: "GOOGLE_GENERATIVE_AI_API_KEY",
2328
- groq: "GROQ_API_KEY"
2329
- };
2324
+ async function generateSystemPromptHandler(c2) {
2325
+ try {
2326
+ const agentId = c2.req.param("agentId");
2327
+ const isPlayground = c2.get("playground") === true;
2328
+ if (!isPlayground) {
2329
+ return c2.json({ error: "This API is only available in the playground environment" }, 403);
2330
+ }
2331
+ const { instructions, comment } = await c2.req.json();
2332
+ if (!instructions) {
2333
+ return c2.json({ error: "Missing instructions in request body" }, 400);
2334
+ }
2335
+ const mastra = c2.get("mastra");
2336
+ const agent$1 = mastra.getAgent(agentId);
2337
+ if (!agent$1) {
2338
+ return c2.json({ error: "Agent not found" }, 404);
2339
+ }
2340
+ let evalSummary = "";
2341
+ try {
2342
+ const testEvals = await mastra.getStorage()?.getEvalsByAgentName?.(agent$1.name, "test") || [];
2343
+ const liveEvals = await mastra.getStorage()?.getEvalsByAgentName?.(agent$1.name, "live") || [];
2344
+ const evalsMapped = [...testEvals, ...liveEvals].filter(
2345
+ ({ instructions: evalInstructions }) => evalInstructions === instructions
2346
+ );
2347
+ evalSummary = evalsMapped.map(
2348
+ ({ input, output, result: result2 }) => `
2349
+ Input: ${input}
2350
+
2351
+ Output: ${output}
2352
+
2353
+ Result: ${JSON.stringify(result2)}
2330
2354
 
2331
- // src/server/handlers/routes/agents/handlers.ts
2355
+ `
2356
+ ).join("");
2357
+ } catch (error) {
2358
+ mastra.getLogger().error(`Error fetching evals`, { error });
2359
+ }
2360
+ const ENHANCE_SYSTEM_PROMPT_INSTRUCTIONS = `
2361
+ You are an expert system prompt engineer, specialized in analyzing and enhancing instructions to create clear, effective, and comprehensive system prompts. Your goal is to help users transform their basic instructions into well-structured system prompts that will guide AI behavior effectively.
2362
+ Follow these steps to analyze and enhance the instructions:
2363
+ 1. ANALYSIS PHASE
2364
+ - Identify the core purpose and goals
2365
+ - Extract key constraints and requirements
2366
+ - Recognize domain-specific terminology and concepts
2367
+ - Note any implicit assumptions that should be made explicit
2368
+ 2. PROMPT STRUCTURE
2369
+ Create a system prompt with these components:
2370
+ a) ROLE DEFINITION
2371
+ - Clear statement of the AI's role and purpose
2372
+ - Key responsibilities and scope
2373
+ - Primary stakeholders and users
2374
+ b) CORE CAPABILITIES
2375
+ - Main functions and abilities
2376
+ - Specific domain knowledge required
2377
+ - Tools and resources available
2378
+ c) BEHAVIORAL GUIDELINES
2379
+ - Communication style and tone
2380
+ - Decision-making framework
2381
+ - Error handling approach
2382
+ - Ethical considerations
2383
+ d) CONSTRAINTS & BOUNDARIES
2384
+ - Explicit limitations
2385
+ - Out-of-scope activities
2386
+ - Security and privacy considerations
2387
+ e) SUCCESS CRITERIA
2388
+ - Quality standards
2389
+ - Expected outcomes
2390
+ - Performance metrics
2391
+ 3. QUALITY CHECKS
2392
+ Ensure the prompt is:
2393
+ - Clear and unambiguous
2394
+ - Comprehensive yet concise
2395
+ - Properly scoped
2396
+ - Technically accurate
2397
+ - Ethically sound
2398
+ 4. OUTPUT FORMAT
2399
+ Return a structured response with:
2400
+ - Enhanced system prompt
2401
+ - Analysis of key components
2402
+ - Identified goals and constraints
2403
+ - Core domain concepts
2404
+ Remember: A good system prompt should be specific enough to guide behavior but flexible enough to handle edge cases.
2405
+ Focus on creating prompts that are clear, actionable, and aligned with the intended use case.
2406
+ `;
2407
+ const systemPromptAgent = new agent.Agent({
2408
+ name: "system-prompt-enhancer",
2409
+ instructions: ENHANCE_SYSTEM_PROMPT_INSTRUCTIONS,
2410
+ model: agent$1.llm?.getModel()
2411
+ });
2412
+ const result = await systemPromptAgent.generate(
2413
+ `
2414
+ We need to improve the system prompt.
2415
+ Current: ${instructions}
2416
+ ${comment ? `User feedback: ${comment}` : ""}
2417
+ ${evalSummary ? `
2418
+ Evaluation Results:
2419
+ ${evalSummary}` : ""}
2420
+ `,
2421
+ {
2422
+ output: zod.z.object({
2423
+ new_prompt: zod.z.string(),
2424
+ explanation: zod.z.string()
2425
+ })
2426
+ }
2427
+ );
2428
+ return c2.json(result?.object || {});
2429
+ } catch (error) {
2430
+ return handleError(error, "Error generating system prompt");
2431
+ }
2432
+ }
2433
+ async function getToolsHandler(c2) {
2434
+ try {
2435
+ const tools = c2.get("tools");
2436
+ const result = await tools$1.getToolsHandler({
2437
+ tools
2438
+ });
2439
+ return c2.json(result || {});
2440
+ } catch (error) {
2441
+ return handleError(error, "Error getting tools");
2442
+ }
2443
+ }
2444
+ async function getToolByIdHandler(c2) {
2445
+ try {
2446
+ const tools = c2.get("tools");
2447
+ const toolId = c2.req.param("toolId");
2448
+ const result = await tools$1.getToolByIdHandler({
2449
+ tools,
2450
+ toolId
2451
+ });
2452
+ return c2.json(result);
2453
+ } catch (error) {
2454
+ return handleError(error, "Error getting tool");
2455
+ }
2456
+ }
2457
+ function executeToolHandler(tools) {
2458
+ return async (c2) => {
2459
+ try {
2460
+ const mastra = c2.get("mastra");
2461
+ const runtimeContext = c2.get("runtimeContext");
2462
+ const toolId = decodeURIComponent(c2.req.param("toolId"));
2463
+ const runId = c2.req.query("runId");
2464
+ const { data } = await c2.req.json();
2465
+ const result = await tools$1.executeToolHandler(tools)({
2466
+ mastra,
2467
+ toolId,
2468
+ data,
2469
+ runtimeContext,
2470
+ runId
2471
+ });
2472
+ return c2.json(result);
2473
+ } catch (error) {
2474
+ return handleError(error, "Error executing tool");
2475
+ }
2476
+ };
2477
+ }
2478
+ async function getAgentToolHandler(c2) {
2479
+ try {
2480
+ const mastra = c2.get("mastra");
2481
+ const runtimeContext = c2.get("runtimeContext");
2482
+ const agentId = c2.req.param("agentId");
2483
+ const toolId = c2.req.param("toolId");
2484
+ const result = await tools$1.getAgentToolHandler({
2485
+ mastra,
2486
+ agentId,
2487
+ toolId,
2488
+ runtimeContext
2489
+ });
2490
+ return c2.json(result);
2491
+ } catch (error) {
2492
+ return handleError(error, "Error getting agent tool");
2493
+ }
2494
+ }
2495
+ async function executeAgentToolHandler(c2) {
2496
+ try {
2497
+ const mastra = c2.get("mastra");
2498
+ const runtimeContext = c2.get("runtimeContext");
2499
+ const agentId = c2.req.param("agentId");
2500
+ const toolId = c2.req.param("toolId");
2501
+ const { data } = await c2.req.json();
2502
+ const result = await tools$1.executeAgentToolHandler({
2503
+ mastra,
2504
+ agentId,
2505
+ toolId,
2506
+ data,
2507
+ runtimeContext
2508
+ });
2509
+ return c2.json(result);
2510
+ } catch (error) {
2511
+ return handleError(error, "Error executing tool");
2512
+ }
2513
+ }
2332
2514
  var sharedBodyOptions = {
2333
2515
  messages: {
2334
2516
  type: "array",
@@ -2815,6 +2997,19 @@ async function updateAgentModelHandler(c2) {
2815
2997
  return handleError(error, "Error updating agent model");
2816
2998
  }
2817
2999
  }
3000
+ async function resetAgentModelHandler(c2) {
3001
+ try {
3002
+ const mastra = c2.get("mastra");
3003
+ const agentId = c2.req.param("agentId");
3004
+ const result = await agents.resetAgentModelHandler({
3005
+ mastra,
3006
+ agentId
3007
+ });
3008
+ return c2.json(result);
3009
+ } catch (error) {
3010
+ return handleError(error, "Error resetting agent model");
3011
+ }
3012
+ }
2818
3013
  async function deprecatedStreamVNextHandler(c2) {
2819
3014
  return c2.json(
2820
3015
  {
@@ -2827,28 +3022,6 @@ async function deprecatedStreamVNextHandler(c2) {
2827
3022
  // 410 Gone status code for deprecated endpoints
2828
3023
  );
2829
3024
  }
2830
- async function getModelProvidersHandler(c2) {
2831
- const isPlayground = c2.get("playground") === true;
2832
- if (!isPlayground) {
2833
- return c2.json({ error: "This API is only available in the playground environment" }, 403);
2834
- }
2835
- const envVars = process.env;
2836
- const providers = Object.entries(AllowedProviderKeys);
2837
- const envKeys = Object.keys(envVars);
2838
- const availableProviders = providers.filter(([_, value]) => envKeys.includes(value) && !!envVars[value]);
2839
- const providerInfo = availableProviders.map(([key, envVar]) => {
2840
- const providerConfig = llm.getProviderConfig(key);
2841
- return {
2842
- id: key,
2843
- name: key.charAt(0).toUpperCase() + key.slice(1).replace(/-/g, " "),
2844
- envVar,
2845
- hasApiKey: !!envVars[envVar],
2846
- docUrl: providerConfig?.docUrl || null,
2847
- models: providerConfig?.models || []
2848
- };
2849
- });
2850
- return c2.json(providerInfo);
2851
- }
2852
3025
  async function updateAgentModelInModelListHandler(c2) {
2853
3026
  try {
2854
3027
  const mastra = c2.get("mastra");
@@ -2881,196 +3054,6 @@ async function reorderAgentModelListHandler(c2) {
2881
3054
  return handleError(error, "Error reordering agent model list");
2882
3055
  }
2883
3056
  }
2884
- async function generateSystemPromptHandler(c2) {
2885
- try {
2886
- const agentId = c2.req.param("agentId");
2887
- const isPlayground = c2.get("playground") === true;
2888
- if (!isPlayground) {
2889
- return c2.json({ error: "This API is only available in the playground environment" }, 403);
2890
- }
2891
- const { instructions, comment } = await c2.req.json();
2892
- if (!instructions) {
2893
- return c2.json({ error: "Missing instructions in request body" }, 400);
2894
- }
2895
- const mastra = c2.get("mastra");
2896
- const agent$1 = mastra.getAgent(agentId);
2897
- if (!agent$1) {
2898
- return c2.json({ error: "Agent not found" }, 404);
2899
- }
2900
- let evalSummary = "";
2901
- try {
2902
- const testEvals = await mastra.getStorage()?.getEvalsByAgentName?.(agent$1.name, "test") || [];
2903
- const liveEvals = await mastra.getStorage()?.getEvalsByAgentName?.(agent$1.name, "live") || [];
2904
- const evalsMapped = [...testEvals, ...liveEvals].filter(
2905
- ({ instructions: evalInstructions }) => evalInstructions === instructions
2906
- );
2907
- evalSummary = evalsMapped.map(
2908
- ({ input, output, result: result2 }) => `
2909
- Input: ${input}
2910
-
2911
- Output: ${output}
2912
-
2913
- Result: ${JSON.stringify(result2)}
2914
-
2915
- `
2916
- ).join("");
2917
- } catch (error) {
2918
- mastra.getLogger().error(`Error fetching evals`, { error });
2919
- }
2920
- const ENHANCE_SYSTEM_PROMPT_INSTRUCTIONS = `
2921
- You are an expert system prompt engineer, specialized in analyzing and enhancing instructions to create clear, effective, and comprehensive system prompts. Your goal is to help users transform their basic instructions into well-structured system prompts that will guide AI behavior effectively.
2922
- Follow these steps to analyze and enhance the instructions:
2923
- 1. ANALYSIS PHASE
2924
- - Identify the core purpose and goals
2925
- - Extract key constraints and requirements
2926
- - Recognize domain-specific terminology and concepts
2927
- - Note any implicit assumptions that should be made explicit
2928
- 2. PROMPT STRUCTURE
2929
- Create a system prompt with these components:
2930
- a) ROLE DEFINITION
2931
- - Clear statement of the AI's role and purpose
2932
- - Key responsibilities and scope
2933
- - Primary stakeholders and users
2934
- b) CORE CAPABILITIES
2935
- - Main functions and abilities
2936
- - Specific domain knowledge required
2937
- - Tools and resources available
2938
- c) BEHAVIORAL GUIDELINES
2939
- - Communication style and tone
2940
- - Decision-making framework
2941
- - Error handling approach
2942
- - Ethical considerations
2943
- d) CONSTRAINTS & BOUNDARIES
2944
- - Explicit limitations
2945
- - Out-of-scope activities
2946
- - Security and privacy considerations
2947
- e) SUCCESS CRITERIA
2948
- - Quality standards
2949
- - Expected outcomes
2950
- - Performance metrics
2951
- 3. QUALITY CHECKS
2952
- Ensure the prompt is:
2953
- - Clear and unambiguous
2954
- - Comprehensive yet concise
2955
- - Properly scoped
2956
- - Technically accurate
2957
- - Ethically sound
2958
- 4. OUTPUT FORMAT
2959
- Return a structured response with:
2960
- - Enhanced system prompt
2961
- - Analysis of key components
2962
- - Identified goals and constraints
2963
- - Core domain concepts
2964
- Remember: A good system prompt should be specific enough to guide behavior but flexible enough to handle edge cases.
2965
- Focus on creating prompts that are clear, actionable, and aligned with the intended use case.
2966
- `;
2967
- const systemPromptAgent = new agent.Agent({
2968
- name: "system-prompt-enhancer",
2969
- instructions: ENHANCE_SYSTEM_PROMPT_INSTRUCTIONS,
2970
- model: agent$1.llm?.getModel()
2971
- });
2972
- const result = await systemPromptAgent.generate(
2973
- `
2974
- We need to improve the system prompt.
2975
- Current: ${instructions}
2976
- ${comment ? `User feedback: ${comment}` : ""}
2977
- ${evalSummary ? `
2978
- Evaluation Results:
2979
- ${evalSummary}` : ""}
2980
- `,
2981
- {
2982
- output: zod.z.object({
2983
- new_prompt: zod.z.string(),
2984
- explanation: zod.z.string()
2985
- })
2986
- }
2987
- );
2988
- return c2.json(result?.object || {});
2989
- } catch (error) {
2990
- return handleError(error, "Error generating system prompt");
2991
- }
2992
- }
2993
- async function getToolsHandler(c2) {
2994
- try {
2995
- const tools = c2.get("tools");
2996
- const result = await tools$1.getToolsHandler({
2997
- tools
2998
- });
2999
- return c2.json(result || {});
3000
- } catch (error) {
3001
- return handleError(error, "Error getting tools");
3002
- }
3003
- }
3004
- async function getToolByIdHandler(c2) {
3005
- try {
3006
- const tools = c2.get("tools");
3007
- const toolId = c2.req.param("toolId");
3008
- const result = await tools$1.getToolByIdHandler({
3009
- tools,
3010
- toolId
3011
- });
3012
- return c2.json(result);
3013
- } catch (error) {
3014
- return handleError(error, "Error getting tool");
3015
- }
3016
- }
3017
- function executeToolHandler(tools) {
3018
- return async (c2) => {
3019
- try {
3020
- const mastra = c2.get("mastra");
3021
- const runtimeContext = c2.get("runtimeContext");
3022
- const toolId = decodeURIComponent(c2.req.param("toolId"));
3023
- const runId = c2.req.query("runId");
3024
- const { data } = await c2.req.json();
3025
- const result = await tools$1.executeToolHandler(tools)({
3026
- mastra,
3027
- toolId,
3028
- data,
3029
- runtimeContext,
3030
- runId
3031
- });
3032
- return c2.json(result);
3033
- } catch (error) {
3034
- return handleError(error, "Error executing tool");
3035
- }
3036
- };
3037
- }
3038
- async function getAgentToolHandler(c2) {
3039
- try {
3040
- const mastra = c2.get("mastra");
3041
- const runtimeContext = c2.get("runtimeContext");
3042
- const agentId = c2.req.param("agentId");
3043
- const toolId = c2.req.param("toolId");
3044
- const result = await tools$1.getAgentToolHandler({
3045
- mastra,
3046
- agentId,
3047
- toolId,
3048
- runtimeContext
3049
- });
3050
- return c2.json(result);
3051
- } catch (error) {
3052
- return handleError(error, "Error getting agent tool");
3053
- }
3054
- }
3055
- async function executeAgentToolHandler(c2) {
3056
- try {
3057
- const mastra = c2.get("mastra");
3058
- const runtimeContext = c2.get("runtimeContext");
3059
- const agentId = c2.req.param("agentId");
3060
- const toolId = c2.req.param("toolId");
3061
- const { data } = await c2.req.json();
3062
- const result = await tools$1.executeAgentToolHandler({
3063
- mastra,
3064
- agentId,
3065
- toolId,
3066
- data,
3067
- runtimeContext
3068
- });
3069
- return c2.json(result);
3070
- } catch (error) {
3071
- return handleError(error, "Error executing tool");
3072
- }
3073
- }
3074
3057
  async function getSpeakersHandler(c2) {
3075
3058
  try {
3076
3059
  const mastra = c2.get("mastra");
@@ -3854,6 +3837,31 @@ function agentsRouter(bodyLimitOptions) {
3854
3837
  }),
3855
3838
  updateAgentModelHandler
3856
3839
  );
3840
+ router.post(
3841
+ "/:agentId/model/reset",
3842
+ bodyLimit.bodyLimit(bodyLimitOptions),
3843
+ w({
3844
+ description: "Reset the agent model to the original model set during construction",
3845
+ tags: ["agents"],
3846
+ parameters: [
3847
+ {
3848
+ name: "agentId",
3849
+ in: "path",
3850
+ required: true,
3851
+ schema: { type: "string" }
3852
+ }
3853
+ ],
3854
+ responses: {
3855
+ 200: {
3856
+ description: "Model reset to original successfully"
3857
+ },
3858
+ 404: {
3859
+ description: "Agent not found"
3860
+ }
3861
+ }
3862
+ }),
3863
+ resetAgentModelHandler
3864
+ );
3857
3865
  router.post(
3858
3866
  "/:agentId/models/reorder",
3859
3867
  bodyLimit.bodyLimit(bodyLimitOptions),
@@ -7339,9 +7347,11 @@ async function getMemoryStatusHandler(c2) {
7339
7347
  try {
7340
7348
  const mastra = c2.get("mastra");
7341
7349
  const agentId = c2.req.query("agentId");
7350
+ const runtimeContext = c2.get("runtimeContext");
7342
7351
  const result = await memory.getMemoryStatusHandler({
7343
7352
  mastra,
7344
- agentId
7353
+ agentId,
7354
+ runtimeContext
7345
7355
  });
7346
7356
  return c2.json(result);
7347
7357
  } catch (error) {
@@ -7352,9 +7362,11 @@ async function getMemoryConfigHandler(c2) {
7352
7362
  try {
7353
7363
  const mastra = c2.get("mastra");
7354
7364
  const agentId = c2.req.query("agentId");
7365
+ const runtimeContext = c2.get("runtimeContext");
7355
7366
  const result = await memory.getMemoryConfigHandler({
7356
7367
  mastra,
7357
- agentId
7368
+ agentId,
7369
+ runtimeContext
7358
7370
  });
7359
7371
  return c2.json(result);
7360
7372
  } catch (error) {
@@ -7368,12 +7380,14 @@ async function getThreadsHandler(c2) {
7368
7380
  const resourceId = c2.req.query("resourceid");
7369
7381
  const orderBy = c2.req.query("orderBy");
7370
7382
  const sortDirection = c2.req.query("sortDirection");
7383
+ const runtimeContext = c2.get("runtimeContext");
7371
7384
  const result = await memory.getThreadsHandler({
7372
7385
  mastra,
7373
7386
  agentId,
7374
7387
  resourceId,
7375
7388
  orderBy,
7376
- sortDirection
7389
+ sortDirection,
7390
+ runtimeContext
7377
7391
  });
7378
7392
  return c2.json(result);
7379
7393
  } catch (error) {
@@ -7389,6 +7403,7 @@ async function getThreadsPaginatedHandler(c2) {
7389
7403
  const perPage = parseInt(c2.req.query("perPage") || "100", 10);
7390
7404
  const orderBy = c2.req.query("orderBy");
7391
7405
  const sortDirection = c2.req.query("sortDirection");
7406
+ const runtimeContext = c2.get("runtimeContext");
7392
7407
  const result = await memory.getThreadsPaginatedHandler({
7393
7408
  mastra,
7394
7409
  agentId,
@@ -7396,7 +7411,8 @@ async function getThreadsPaginatedHandler(c2) {
7396
7411
  page,
7397
7412
  perPage,
7398
7413
  orderBy,
7399
- sortDirection
7414
+ sortDirection,
7415
+ runtimeContext
7400
7416
  });
7401
7417
  return c2.json(result);
7402
7418
  } catch (error) {
@@ -7408,10 +7424,12 @@ async function getThreadByIdHandler(c2) {
7408
7424
  const mastra = c2.get("mastra");
7409
7425
  const agentId = c2.req.query("agentId");
7410
7426
  const threadId = c2.req.param("threadId");
7427
+ const runtimeContext = c2.get("runtimeContext");
7411
7428
  const result = await memory.getThreadByIdHandler({
7412
7429
  mastra,
7413
7430
  agentId,
7414
- threadId
7431
+ threadId,
7432
+ runtimeContext
7415
7433
  });
7416
7434
  return c2.json(result);
7417
7435
  } catch (error) {
@@ -7423,10 +7441,12 @@ async function saveMessagesHandler(c2) {
7423
7441
  const mastra = c2.get("mastra");
7424
7442
  const agentId = c2.req.query("agentId");
7425
7443
  const body = await c2.req.json();
7444
+ const runtimeContext = c2.get("runtimeContext");
7426
7445
  const result = await memory.saveMessagesHandler({
7427
7446
  mastra,
7428
7447
  agentId,
7429
- body
7448
+ body,
7449
+ runtimeContext
7430
7450
  });
7431
7451
  return c2.json(result);
7432
7452
  } catch (error) {
@@ -7438,10 +7458,12 @@ async function createThreadHandler(c2) {
7438
7458
  const mastra = c2.get("mastra");
7439
7459
  const agentId = c2.req.query("agentId");
7440
7460
  const body = await c2.req.json();
7461
+ const runtimeContext = c2.get("runtimeContext");
7441
7462
  const result = await memory.createThreadHandler({
7442
7463
  mastra,
7443
7464
  agentId,
7444
- body
7465
+ body,
7466
+ runtimeContext
7445
7467
  });
7446
7468
  return c2.json(result);
7447
7469
  } catch (error) {
@@ -7454,11 +7476,13 @@ async function updateThreadHandler(c2) {
7454
7476
  const agentId = c2.req.query("agentId");
7455
7477
  const threadId = c2.req.param("threadId");
7456
7478
  const body = await c2.req.json();
7479
+ const runtimeContext = c2.get("runtimeContext");
7457
7480
  const result = await memory.updateThreadHandler({
7458
7481
  mastra,
7459
7482
  agentId,
7460
7483
  threadId,
7461
- body
7484
+ body,
7485
+ runtimeContext
7462
7486
  });
7463
7487
  return c2.json(result);
7464
7488
  } catch (error) {
@@ -7470,10 +7494,12 @@ async function deleteThreadHandler(c2) {
7470
7494
  const mastra = c2.get("mastra");
7471
7495
  const agentId = c2.req.query("agentId");
7472
7496
  const threadId = c2.req.param("threadId");
7497
+ const runtimeContext = c2.get("runtimeContext");
7473
7498
  const result = await memory.deleteThreadHandler({
7474
7499
  mastra,
7475
7500
  agentId,
7476
- threadId
7501
+ threadId,
7502
+ runtimeContext
7477
7503
  });
7478
7504
  return c2.json(result);
7479
7505
  } catch (error) {
@@ -7486,11 +7512,13 @@ async function getMessagesHandler(c2) {
7486
7512
  const agentId = c2.req.query("agentId");
7487
7513
  const threadId = c2.req.param("threadId");
7488
7514
  const limit = parseLimit(c2.req.query("limit"));
7515
+ const runtimeContext = c2.get("runtimeContext");
7489
7516
  const result = await memory.getMessagesHandler({
7490
7517
  mastra,
7491
7518
  agentId,
7492
7519
  threadId,
7493
- limit
7520
+ limit,
7521
+ runtimeContext
7494
7522
  });
7495
7523
  return c2.json(result);
7496
7524
  } catch (error) {
@@ -7529,11 +7557,13 @@ async function updateWorkingMemoryHandler(c2) {
7529
7557
  const agentId = c2.req.query("agentId");
7530
7558
  const threadId = c2.req.param("threadId");
7531
7559
  const body = await c2.req.json();
7560
+ const runtimeContext = c2.get("runtimeContext");
7532
7561
  const result = await memory.updateWorkingMemoryHandler({
7533
7562
  mastra,
7534
7563
  agentId,
7535
7564
  threadId,
7536
- body
7565
+ body,
7566
+ runtimeContext
7537
7567
  });
7538
7568
  return c2.json(result);
7539
7569
  } catch (error) {
@@ -7546,11 +7576,13 @@ async function getWorkingMemoryHandler(c2) {
7546
7576
  const agentId = c2.req.query("agentId");
7547
7577
  const threadId = c2.req.param("threadId");
7548
7578
  const resourceId = c2.req.query("resourceId");
7579
+ const runtimeContext = c2.get("runtimeContext");
7549
7580
  const result = await memory.getWorkingMemoryHandler({
7550
7581
  mastra,
7551
7582
  agentId,
7552
7583
  threadId,
7553
- resourceId
7584
+ resourceId,
7585
+ runtimeContext
7554
7586
  });
7555
7587
  return c2.json(result);
7556
7588
  } catch (error) {
@@ -11999,19 +12031,6 @@ async function createHonoServer(mastra, options = {
11999
12031
  }),
12000
12032
  rootHandler
12001
12033
  );
12002
- app.get(
12003
- "/api/model-providers",
12004
- w({
12005
- description: "Get all model providers with available keys",
12006
- tags: ["agents"],
12007
- responses: {
12008
- 200: {
12009
- description: "All model providers with available keys"
12010
- }
12011
- }
12012
- }),
12013
- getModelProvidersHandler
12014
- );
12015
12034
  app.route("/api/agents", agentsRouter(bodyLimitOptions));
12016
12035
  if (options.isDev) {
12017
12036
  app.route("/api/agents", agentsRouterDev(bodyLimitOptions));