@mastra/deployer 0.24.9-alpha.0 → 0.24.9

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @mastra/deployer
2
2
 
3
+ ## 0.24.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Update prompt handler to use new scoring system instead of deprecated evals. ([#11274](https://github.com/mastra-ai/mastra/pull/11274))
8
+
9
+ - Updated dependencies [[`c56f64b`](https://github.com/mastra-ai/mastra/commit/c56f64b0d7365d744cfe99f54369795917c057b7), [`60d99c0`](https://github.com/mastra-ai/mastra/commit/60d99c0addeed9d759c1b9fe4924d830ec93ac84)]:
10
+ - @mastra/core@0.24.9
11
+ - @mastra/server@0.24.9
12
+
13
+ ## 0.24.9-alpha.1
14
+
15
+ ### Patch Changes
16
+
17
+ - Update prompt handler to use new scoring system instead of deprecated evals. ([#11274](https://github.com/mastra-ai/mastra/pull/11274))
18
+
19
+ - Updated dependencies [[`60d99c0`](https://github.com/mastra-ai/mastra/commit/60d99c0addeed9d759c1b9fe4924d830ec93ac84)]:
20
+ - @mastra/server@0.24.9-alpha.1
21
+ - @mastra/core@0.24.9-alpha.1
22
+
3
23
  ## 0.24.9-alpha.0
4
24
 
5
25
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/prompt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAKpC,wBAAsB,2BAA2B,CAAC,CAAC,EAAE,OAAO,qBAwH3D"}
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/prompt.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAapC,wBAAsB,2BAA2B,CAAC,CAAC,EAAE,OAAO,qBAuH3D"}
@@ -2338,6 +2338,12 @@ function agentBuilderRouter(bodyLimitOptions) {
2338
2338
  );
2339
2339
  return router;
2340
2340
  }
2341
+ var getUserMessageFromRunInput = (input) => {
2342
+ return input?.inputMessages.find(({ role }) => role === "user")?.content;
2343
+ };
2344
+ var extractAgentResponseMessages = (runOutput) => {
2345
+ return runOutput.filter((msg) => msg.role === "assistant").map((msg) => msg.content);
2346
+ };
2341
2347
  async function generateSystemPromptHandler(c2) {
2342
2348
  try {
2343
2349
  const agentId = c2.req.param("agentId");
@@ -2354,25 +2360,29 @@ async function generateSystemPromptHandler(c2) {
2354
2360
  if (!agent$1) {
2355
2361
  return c2.json({ error: "Agent not found" }, 404);
2356
2362
  }
2357
- let evalSummary = "";
2363
+ let scoreSummary = "";
2358
2364
  try {
2359
- const testEvals = await mastra.getStorage()?.getEvalsByAgentName?.(agent$1.name, "test") || [];
2360
- const liveEvals = await mastra.getStorage()?.getEvalsByAgentName?.(agent$1.name, "live") || [];
2361
- const evalsMapped = [...testEvals, ...liveEvals].filter(
2362
- ({ instructions: evalInstructions }) => evalInstructions === instructions
2363
- );
2364
- evalSummary = evalsMapped.map(
2365
- ({ input, output, result: result2 }) => `
2366
- Input: ${input}
2367
-
2368
- Output: ${output}
2365
+ const scoresResult = await mastra.getStorage()?.getScoresByEntityId?.({
2366
+ entityId: agent$1.name,
2367
+ entityType: "AGENT",
2368
+ pagination: { page: 0, perPage: 100 }
2369
+ });
2370
+ const scores = scoresResult?.scores || [];
2371
+ scoreSummary = scores.map(({ input, output, score, reason, scorer }) => {
2372
+ const userMessage = getUserMessageFromRunInput(input);
2373
+ const agentResponses = extractAgentResponseMessages(output);
2374
+ return `
2375
+ User: ${userMessage}
2369
2376
 
2370
- Result: ${JSON.stringify(result2)}
2377
+ Agent: ${agentResponses.join("\n")}
2371
2378
 
2372
- `
2373
- ).join("");
2379
+ Score: ${score}${reason ? `
2380
+ Reason: ${reason}` : ""}${scorer?.name ? `
2381
+ Scorer: ${scorer.name}` : ""}
2382
+ `;
2383
+ }).join("");
2374
2384
  } catch (error) {
2375
- mastra.getLogger().error(`Error fetching evals`, { error });
2385
+ mastra.getLogger().error(`Error fetching scores`, { error });
2376
2386
  }
2377
2387
  const ENHANCE_SYSTEM_PROMPT_INSTRUCTIONS = `
2378
2388
  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.
@@ -2431,9 +2441,9 @@ async function generateSystemPromptHandler(c2) {
2431
2441
  We need to improve the system prompt.
2432
2442
  Current: ${instructions}
2433
2443
  ${comment ? `User feedback: ${comment}` : ""}
2434
- ${evalSummary ? `
2435
- Evaluation Results:
2436
- ${evalSummary}` : ""}
2444
+ ${scoreSummary ? `
2445
+ Scoring Results:
2446
+ ${scoreSummary}` : ""}
2437
2447
  `,
2438
2448
  {
2439
2449
  output: zod.z.object({