@mastra/deployer 0.18.0-alpha.2 → 0.18.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.
@@ -22,7 +22,7 @@ import { getAgentCardByIdHandler as getAgentCardByIdHandler$1, getAgentExecution
22
22
  import { stream } from 'hono/streaming';
23
23
  import { bodyLimit } from 'hono/body-limit';
24
24
  import { getAgentBuilderActionsHandler as getAgentBuilderActionsHandler$1, getAgentBuilderActionByIdHandler as getAgentBuilderActionByIdHandler$1, getAgentBuilderActionRunsHandler as getAgentBuilderActionRunsHandler$1, getAgentBuilderActionRunExecutionResultHandler as getAgentBuilderActionRunExecutionResultHandler$1, getAgentBuilderActionRunByIdHandler as getAgentBuilderActionRunByIdHandler$1, resumeAgentBuilderActionHandler as resumeAgentBuilderActionHandler$1, resumeAsyncAgentBuilderActionHandler as resumeAsyncAgentBuilderActionHandler$1, streamAgentBuilderActionHandler as streamAgentBuilderActionHandler$1, streamVNextAgentBuilderActionHandler as streamVNextAgentBuilderActionHandler$1, createAgentBuilderActionRunHandler as createAgentBuilderActionRunHandler$1, startAsyncAgentBuilderActionHandler as startAsyncAgentBuilderActionHandler$1, startAgentBuilderActionRunHandler as startAgentBuilderActionRunHandler$1, watchAgentBuilderActionHandler as watchAgentBuilderActionHandler$1, cancelAgentBuilderActionRunHandler as cancelAgentBuilderActionRunHandler$1, sendAgentBuilderActionRunEventHandler as sendAgentBuilderActionRunEventHandler$1 } from '@mastra/server/handlers/agent-builder';
25
- import { getAgentsHandler as getAgentsHandler$1, getAgentByIdHandler as getAgentByIdHandler$1, getEvalsByAgentIdHandler as getEvalsByAgentIdHandler$1, getLiveEvalsByAgentIdHandler as getLiveEvalsByAgentIdHandler$1, generateLegacyHandler as generateLegacyHandler$1, generateHandler as generateHandler$1, streamNetworkHandler as streamNetworkHandler$1, generateVNextHandler as generateVNextHandler$1, streamVNextGenerateHandler as streamVNextGenerateHandler$1, streamGenerateLegacyHandler as streamGenerateLegacyHandler$1, streamGenerateHandler as streamGenerateHandler$1, streamVNextUIMessageHandler as streamVNextUIMessageHandler$1, updateAgentModelHandler as updateAgentModelHandler$1 } from '@mastra/server/handlers/agents';
25
+ import { getAgentsHandler as getAgentsHandler$1, getAgentByIdHandler as getAgentByIdHandler$1, getEvalsByAgentIdHandler as getEvalsByAgentIdHandler$1, getLiveEvalsByAgentIdHandler as getLiveEvalsByAgentIdHandler$1, generateLegacyHandler as generateLegacyHandler$1, generateHandler as generateHandler$1, streamNetworkHandler as streamNetworkHandler$1, generateVNextHandler as generateVNextHandler$1, streamVNextGenerateHandler as streamVNextGenerateHandler$1, streamGenerateLegacyHandler as streamGenerateLegacyHandler$1, streamGenerateHandler as streamGenerateHandler$1, streamVNextUIMessageHandler as streamVNextUIMessageHandler$1, updateAgentModelHandler as updateAgentModelHandler$1, reorderAgentModelListHandler as reorderAgentModelListHandler$1, updateAgentModelInModelListHandler as updateAgentModelInModelListHandler$1 } from '@mastra/server/handlers/agents';
26
26
  import { Agent } from '@mastra/core/agent';
27
27
  import { z } from 'zod';
28
28
  import { getAgentToolHandler as getAgentToolHandler$1, executeAgentToolHandler as executeAgentToolHandler$1, getToolsHandler as getToolsHandler$1, getToolByIdHandler as getToolByIdHandler$1, executeToolHandler as executeToolHandler$1 } from '@mastra/server/handlers/tools';
@@ -33,7 +33,7 @@ import { Buffer as Buffer$1 } from 'buffer';
33
33
  import { getMemoryStatusHandler as getMemoryStatusHandler$1, getThreadsHandler as getThreadsHandler$1, getThreadByIdHandler as getThreadByIdHandler$1, getMessagesHandler as getMessagesHandler$1, createThreadHandler as createThreadHandler$1, updateThreadHandler as updateThreadHandler$1, deleteThreadHandler as deleteThreadHandler$1, saveMessagesHandler as saveMessagesHandler$1, deleteMessagesHandler as deleteMessagesHandler$1, getMemoryConfigHandler as getMemoryConfigHandler$1, getThreadsPaginatedHandler as getThreadsPaginatedHandler$1, getMessagesPaginatedHandler as getMessagesPaginatedHandler$1, searchMemoryHandler as searchMemoryHandler$1, getWorkingMemoryHandler as getWorkingMemoryHandler$1, updateWorkingMemoryHandler as updateWorkingMemoryHandler$1 } from '@mastra/server/handlers/memory';
34
34
  import { getVNextNetworksHandler as getVNextNetworksHandler$1, getVNextNetworkByIdHandler as getVNextNetworkByIdHandler$1, generateVNextNetworkHandler as generateVNextNetworkHandler$1, loopVNextNetworkHandler as loopVNextNetworkHandler$1, loopStreamVNextNetworkHandler as loopStreamVNextNetworkHandler$1, streamGenerateVNextNetworkHandler as streamGenerateVNextNetworkHandler$1 } from '@mastra/server/handlers/vNextNetwork';
35
35
  import { AISpanType } from '@mastra/core/ai-tracing';
36
- import { getAITracesPaginatedHandler as getAITracesPaginatedHandler$1, getAITraceHandler as getAITraceHandler$1 } from '@mastra/server/handlers/observability';
36
+ import { getAITracesPaginatedHandler as getAITracesPaginatedHandler$1, getAITraceHandler as getAITraceHandler$1, scoreTracesHandler } from '@mastra/server/handlers/observability';
37
37
  import { getScorersHandler as getScorersHandler$1, getScorerHandler as getScorerHandler$1, getScoresByRunIdHandler as getScoresByRunIdHandler$1, getScoresByScorerIdHandler as getScoresByScorerIdHandler$1, getScoresByEntityIdHandler as getScoresByEntityIdHandler$1, saveScoreHandler as saveScoreHandler$1 } from '@mastra/server/handlers/scores';
38
38
  import { getTelemetryHandler as getTelemetryHandler$1, storeTelemetryHandler as storeTelemetryHandler$1 } from '@mastra/server/handlers/telemetry';
39
39
  import { upsertVectors as upsertVectors$1, createIndex as createIndex$1, queryVectors as queryVectors$1, listIndexes as listIndexes$1, describeIndex as describeIndex$1, deleteIndex as deleteIndex$1 } from '@mastra/server/handlers/vector';
@@ -598,6 +598,9 @@ var createStreamBody = (stream7) => {
598
598
  stream7.on("data", (chunk) => {
599
599
  controller.enqueue(chunk);
600
600
  });
601
+ stream7.on("error", (err) => {
602
+ controller.error(err);
603
+ });
601
604
  stream7.on("end", () => {
602
605
  controller.close();
603
606
  });
@@ -2657,6 +2660,38 @@ async function getModelProvidersHandler(c2) {
2657
2660
  const availableProvidersNames = availableProviders.map(([key]) => key);
2658
2661
  return c2.json(availableProvidersNames);
2659
2662
  }
2663
+ async function updateAgentModelInModelListHandler(c2) {
2664
+ try {
2665
+ const mastra = c2.get("mastra");
2666
+ const agentId = c2.req.param("agentId");
2667
+ const modelConfigId = c2.req.param("modelConfigId");
2668
+ const body = await c2.req.json();
2669
+ const result = await updateAgentModelInModelListHandler$1({
2670
+ mastra,
2671
+ agentId,
2672
+ body,
2673
+ modelConfigId
2674
+ });
2675
+ return c2.json(result);
2676
+ } catch (error) {
2677
+ return handleError(error, "Error updating agent model in model list");
2678
+ }
2679
+ }
2680
+ async function reorderAgentModelListHandler(c2) {
2681
+ try {
2682
+ const mastra = c2.get("mastra");
2683
+ const agentId = c2.req.param("agentId");
2684
+ const body = await c2.req.json();
2685
+ const result = await reorderAgentModelListHandler$1({
2686
+ mastra,
2687
+ agentId,
2688
+ body
2689
+ });
2690
+ return c2.json(result);
2691
+ } catch (error) {
2692
+ return handleError(error, "Error reordering agent model list");
2693
+ }
2694
+ }
2660
2695
  async function generateSystemPromptHandler(c2) {
2661
2696
  try {
2662
2697
  const agentId = c2.req.param("agentId");
@@ -3477,6 +3512,116 @@ function agentsRouter(bodyLimitOptions) {
3477
3512
  }),
3478
3513
  updateAgentModelHandler
3479
3514
  );
3515
+ router.post(
3516
+ "/:agentId/models/reorder",
3517
+ bodyLimit(bodyLimitOptions),
3518
+ w({
3519
+ description: "Reorder the models for an agent",
3520
+ tags: ["agents"],
3521
+ parameters: [
3522
+ {
3523
+ name: "agentId",
3524
+ in: "path",
3525
+ required: true,
3526
+ schema: { type: "string" }
3527
+ }
3528
+ ],
3529
+ requestBody: {
3530
+ required: true,
3531
+ content: {
3532
+ "application/json": {
3533
+ schema: {
3534
+ type: "object",
3535
+ properties: {
3536
+ reorderedModelIds: {
3537
+ type: "array",
3538
+ items: {
3539
+ type: "string"
3540
+ }
3541
+ }
3542
+ },
3543
+ required: ["reorderedModelIds"]
3544
+ }
3545
+ }
3546
+ }
3547
+ },
3548
+ responses: {
3549
+ 200: {
3550
+ description: "Model list reordered successfully"
3551
+ },
3552
+ 404: {
3553
+ description: "Agent not found"
3554
+ }
3555
+ }
3556
+ }),
3557
+ reorderAgentModelListHandler
3558
+ );
3559
+ router.post(
3560
+ "/:agentId/models/:modelConfigId",
3561
+ bodyLimit(bodyLimitOptions),
3562
+ w({
3563
+ description: "Update the model for an agent in the model list",
3564
+ tags: ["agents"],
3565
+ parameters: [
3566
+ {
3567
+ name: "agentId",
3568
+ in: "path",
3569
+ required: true,
3570
+ schema: { type: "string" }
3571
+ },
3572
+ {
3573
+ name: "modelConfigId",
3574
+ in: "path",
3575
+ required: true,
3576
+ schema: { type: "string" }
3577
+ }
3578
+ ],
3579
+ requestBody: {
3580
+ required: true,
3581
+ content: {
3582
+ "application/json": {
3583
+ schema: {
3584
+ type: "object",
3585
+ properties: {
3586
+ model: {
3587
+ type: "object",
3588
+ properties: {
3589
+ modelId: {
3590
+ type: "string",
3591
+ description: "The modelId to update the agent to"
3592
+ },
3593
+ provider: {
3594
+ type: "string",
3595
+ enum: ["openai", "anthropic", "groq", "xai", "google"],
3596
+ description: "The provider of the model to update the agent to"
3597
+ }
3598
+ },
3599
+ required: ["modelId", "provider"]
3600
+ },
3601
+ maxRetries: {
3602
+ type: "number",
3603
+ description: "The maximum number of retries for the model"
3604
+ },
3605
+ enabled: {
3606
+ type: "boolean",
3607
+ description: "Whether the model is enabled"
3608
+ }
3609
+ }
3610
+ }
3611
+ }
3612
+ }
3613
+ },
3614
+ responses: {
3615
+ 200: {
3616
+ description: "Model updated successfully"
3617
+ },
3618
+ 404: {
3619
+ description: "Agent not found"
3620
+ }
3621
+ }
3622
+ }),
3623
+ updateAgentModelInModelListHandler
3624
+ );
3480
3625
  router.get(
3481
3626
  "/:agentId/speakers",
3482
3627
  async (c2, next) => {
@@ -8670,6 +8815,19 @@ async function getAITracesPaginatedHandler(c2) {
8670
8815
  return handleError(error, "Error getting AI traces paginated");
8671
8816
  }
8672
8817
  }
8818
+ async function processTraceScoringHandler(c2) {
8819
+ try {
8820
+ const mastra = c2.get("mastra");
8821
+ const { scorerName, targets } = await c2.req.json();
8822
+ const result = await scoreTracesHandler({
8823
+ mastra,
8824
+ body: { scorerName, targets }
8825
+ });
8826
+ return c2.json(result);
8827
+ } catch (error) {
8828
+ return handleError(error, "Error processing trace scoring");
8829
+ }
8830
+ }
8673
8831
 
8674
8832
  // src/server/handlers/routes/observability/router.ts
8675
8833
  function observabilityRouter() {
@@ -8762,6 +8920,125 @@ function observabilityRouter() {
8762
8920
  }),
8763
8921
  getAITraceHandler
8764
8922
  );
8923
+ router.post(
8924
+ "/traces/score",
8925
+ w({
8926
+ description: "Score traces using a specified scorer",
8927
+ tags: ["observability"],
8928
+ requestBody: {
8929
+ content: {
8930
+ "application/json": {
8931
+ schema: {
8932
+ type: "object",
8933
+ required: ["scorerName", "targets"],
8934
+ properties: {
8935
+ scorerName: {
8936
+ type: "string",
8937
+ description: "Name of the scorer to use for evaluation",
8938
+ example: "relevance-scorer"
8939
+ },
8940
+ targets: {
8941
+ type: "array",
8942
+ description: "Array of trace targets to score",
8943
+ minItems: 1,
8944
+ items: {
8945
+ type: "object",
8946
+ required: ["traceId"],
8947
+ properties: {
8948
+ traceId: {
8949
+ type: "string",
8950
+ description: "ID of the trace to score",
8951
+ example: "trace-123"
8952
+ },
8953
+ spanId: {
8954
+ type: "string",
8955
+ description: "Optional specific span ID within the trace to score",
8956
+ example: "span-456"
8957
+ }
8958
+ }
8959
+ }
8960
+ }
8961
+ }
8962
+ }
8963
+ }
8964
+ }
8965
+ },
8966
+ responses: {
8967
+ 200: {
8968
+ description: "Scoring initiated successfully",
8969
+ content: {
8970
+ "application/json": {
8971
+ schema: {
8972
+ type: "object",
8973
+ properties: {
8974
+ status: {
8975
+ type: "string",
8976
+ enum: ["success"],
8977
+ example: "success"
8978
+ },
8979
+ message: {
8980
+ type: "string",
8981
+ example: "Scoring started for 3 traces"
8982
+ },
8983
+ traceCount: {
8984
+ type: "number",
8985
+ example: 3
8986
+ }
8987
+ },
8988
+ required: ["status", "message", "traceCount"]
8989
+ }
8990
+ }
8991
+ }
8992
+ },
8993
+ 400: {
8994
+ description: "Bad request - invalid parameters",
8995
+ content: {
8996
+ "application/json": {
8997
+ schema: {
8998
+ type: "object",
8999
+ properties: {
9000
+ error: {
9001
+ type: "string"
9002
+ }
9003
+ }
9004
+ }
9005
+ }
9006
+ }
9007
+ },
9008
+ 404: {
9009
+ description: "Scorer not found",
9010
+ content: {
9011
+ "application/json": {
9012
+ schema: {
9013
+ type: "object",
9014
+ properties: {
9015
+ error: {
9016
+ type: "string"
9017
+ }
9018
+ }
9019
+ }
9020
+ }
9021
+ }
9022
+ },
9023
+ 500: {
9024
+ description: "Internal server error",
9025
+ content: {
9026
+ "application/json": {
9027
+ schema: {
9028
+ type: "object",
9029
+ properties: {
9030
+ error: {
9031
+ type: "string"
9032
+ }
9033
+ }
9034
+ }
9035
+ }
9036
+ }
9037
+ }
9038
+ }
9039
+ }),
9040
+ processTraceScoringHandler
9041
+ );
8765
9042
  return router;
8766
9043
  }
8767
9044
  async function getScorersHandler(c2) {