@mastra/server 1.86.0 → 1.87.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 (29) hide show
  1. package/dist/{agent-builder-DHnNRROR.js → agent-builder-B3vJTDHo.js} +1 -1
  2. package/dist/{agent-builder-anRH1X35.cjs → agent-builder-QnIH-0LI.cjs} +1 -1
  3. package/dist/{api-schema-manifest-4PK1dBWt.js → api-schema-manifest-BS3Xfypt.js} +1 -1
  4. package/dist/{api-schema-manifest-CX16hC7V.cjs → api-schema-manifest-DohjGeTI.cjs} +1 -1
  5. package/dist/{catalogue-DNy7Fog6.cjs → catalogue-BTdmOZq6.cjs} +3 -3
  6. package/dist/{catalogue-BOzHZ1xt.js → catalogue-CS1s8mfe.js} +3 -3
  7. package/dist/docs/SKILL.md +1 -1
  8. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  9. package/dist/docs/references/docs-agents-resumable-streams.md +15 -6
  10. package/dist/{routes-BZVlqLly.js → routes-ClPVLnwR.js} +3 -3
  11. package/dist/{routes-vuZLexcc.cjs → routes-K6oFQRlg.cjs} +3 -3
  12. package/dist/server/handlers/agent-builder.cjs +1 -1
  13. package/dist/server/handlers/agent-builder.js +1 -1
  14. package/dist/server/handlers/error.cjs +26 -0
  15. package/dist/server/handlers/error.d.ts +2 -0
  16. package/dist/server/handlers/error.js +26 -1
  17. package/dist/server/handlers/system.cjs +1 -1
  18. package/dist/server/handlers/system.js +1 -1
  19. package/dist/server/handlers/workflows.cjs +1 -1
  20. package/dist/server/handlers/workflows.js +1 -1
  21. package/dist/server/handlers.cjs +2 -2
  22. package/dist/server/handlers.js +2 -2
  23. package/dist/server/server-adapter/index.cjs +2 -2
  24. package/dist/server/server-adapter/index.js +2 -2
  25. package/dist/{server-adapter-h8YRQXAC.js → server-adapter-CqgdBTrQ.js} +1 -1
  26. package/dist/{server-adapter-CurME3ch.cjs → server-adapter-CuGKb03z.cjs} +1 -1
  27. package/dist/{workflows-D5bfbang.js → workflows-OjUXkjWw.js} +19 -9
  28. package/dist/{workflows-CHKSHV4f.cjs → workflows-PVrj85xM.cjs} +18 -8
  29. package/package.json +2 -2
@@ -7,7 +7,7 @@ import { o as optionalRunIdSchema, u as runIdSchema } from "./common-J-yUnHk9.js
7
7
  import { n as createRoute } from "./route-builder-Dz18c3qm.js";
8
8
  import { t as WorkflowRegistry } from "./utils-C2VRtQjI.js";
9
9
  import { handleError } from "./server/handlers/error.js";
10
- import { C as STREAM_LEGACY_WORKFLOW_ROUTE, S as START_WORKFLOW_RUN_ROUTE, _ as RESUME_ASYNC_WORKFLOW_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, b as RESUME_WORKFLOW_ROUTE, c as LIST_WORKFLOW_RUNS_ROUTE, d as OBSERVE_STREAM_WORKFLOW_ROUTE, n as CREATE_WORKFLOW_RUN_ROUTE, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, t as CANCEL_WORKFLOW_RUN_ROUTE, u as OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE, v as RESUME_NO_WAIT_WORKFLOW_ROUTE, w as STREAM_WORKFLOW_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE, y as RESUME_STREAM_WORKFLOW_ROUTE } from "./workflows-D5bfbang.js";
10
+ import { C as STREAM_LEGACY_WORKFLOW_ROUTE, S as START_WORKFLOW_RUN_ROUTE, _ as RESUME_ASYNC_WORKFLOW_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, b as RESUME_WORKFLOW_ROUTE, c as LIST_WORKFLOW_RUNS_ROUTE, d as OBSERVE_STREAM_WORKFLOW_ROUTE, n as CREATE_WORKFLOW_RUN_ROUTE, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, t as CANCEL_WORKFLOW_RUN_ROUTE, u as OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE, v as RESUME_NO_WAIT_WORKFLOW_ROUTE, w as STREAM_WORKFLOW_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE, y as RESUME_STREAM_WORKFLOW_ROUTE } from "./workflows-OjUXkjWw.js";
11
11
  // src/server/handlers/agent-builder.ts
12
12
  var agent_builder_exports = /* @__PURE__ */ __exportAll({
13
13
  CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE: () => CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE,
@@ -7,7 +7,7 @@ const require_common = require("./common-D5XxSuvu.cjs");
7
7
  const require_route_builder = require("./route-builder-DjTBxSZN.cjs");
8
8
  const require_utils = require("./utils-DQJOBnMo.cjs");
9
9
  const require_server_handlers_error = require("./server/handlers/error.cjs");
10
- const require_workflows$1 = require("./workflows-CHKSHV4f.cjs");
10
+ const require_workflows$1 = require("./workflows-PVrj85xM.cjs");
11
11
  // src/server/handlers/agent-builder.ts
12
12
  var agent_builder_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
13
13
  CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE: () => CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE,
@@ -1,5 +1,5 @@
1
1
  import { c as schemaToJsonSchema } from "./route-builder-Dz18c3qm.js";
2
- import { r as SERVER_ROUTES } from "./routes-BZVlqLly.js";
2
+ import { r as SERVER_ROUTES } from "./routes-ClPVLnwR.js";
3
3
  // src/server/server-adapter/api-schema-manifest.ts
4
4
  function convertSchema(schema, io) {
5
5
  return schema ? schemaToJsonSchema(schema, io) : void 0;
@@ -1,6 +1,6 @@
1
1
  require("./rolldown-runtime-10nMEhjP.cjs");
2
2
  const require_route_builder = require("./route-builder-DjTBxSZN.cjs");
3
- const require_routes = require("./routes-vuZLexcc.cjs");
3
+ const require_routes = require("./routes-K6oFQRlg.cjs");
4
4
  // src/server/server-adapter/api-schema-manifest.ts
5
5
  function convertSchema(schema, io) {
6
6
  return schema ? require_route_builder.schemaToJsonSchema(schema, io) : void 0;
@@ -3,9 +3,9 @@ const require_schema_TQPB_dl2 = require("./schema-TQPB_dl2-CJX1q58F.cjs");
3
3
  require("./constants-CyNbINin.cjs");
4
4
  const require_agents = require("./agents-GHhuyz5x.cjs");
5
5
  const require_tools = require("./tools-By0RVh_O.cjs");
6
- const require_workflows = require("./workflows-CHKSHV4f.cjs");
7
- const require_server_adapter = require("./server-adapter-CurME3ch.cjs");
8
- const require_routes = require("./routes-vuZLexcc.cjs");
6
+ const require_workflows = require("./workflows-PVrj85xM.cjs");
7
+ const require_server_adapter = require("./server-adapter-CuGKb03z.cjs");
8
+ const require_routes = require("./routes-K6oFQRlg.cjs");
9
9
  require("./utils-DQJOBnMo.cjs");
10
10
  const require_memory = require("./memory-4Izw-l6v.cjs");
11
11
  const require_observability = require("./observability-zNA_CVaz.cjs");
@@ -2,9 +2,9 @@ import { n as standardSchemaToJSONSchema, r as toStandardSchema } from "./schema
2
2
  import "./constants-C1ASuP4t.js";
3
3
  import { G as getAgentFromSystem, f as GENERATE_AGENT_ROUTE, h as GET_AGENT_BY_ID_ROUTE, v as LIST_AGENTS_ROUTE } from "./agents-CAXsXenf.js";
4
4
  import { a as LIST_TOOLS_ROUTE, i as GET_TOOL_BY_ID_ROUTE, n as EXECUTE_TOOL_ROUTE, o as findTool } from "./tools-C3KBdlil.js";
5
- import { _ as RESUME_ASYNC_WORKFLOW_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, k as listWorkflowsFromSystem, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, t as CANCEL_WORKFLOW_RUN_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE } from "./workflows-D5bfbang.js";
6
- import { o as checkRouteRBAC, r as authorizeRoute, s as dispatchRoute } from "./server-adapter-h8YRQXAC.js";
7
- import { c as getBuiltinMCPCapabilities, s as getEffectivePermission } from "./routes-BZVlqLly.js";
5
+ import { _ as RESUME_ASYNC_WORKFLOW_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, k as listWorkflowsFromSystem, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, t as CANCEL_WORKFLOW_RUN_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE } from "./workflows-OjUXkjWw.js";
6
+ import { o as checkRouteRBAC, r as authorizeRoute, s as dispatchRoute } from "./server-adapter-CqgdBTrQ.js";
7
+ import { c as getBuiltinMCPCapabilities, s as getEffectivePermission } from "./routes-ClPVLnwR.js";
8
8
  import "./utils-C2VRtQjI.js";
9
9
  import { E as UPDATE_THREAD_ROUTE, b as LIST_THREADS_ROUTE, d as GET_MEMORY_STATUS_ROUTE, f as GET_OBSERVATIONAL_MEMORY_ROUTE, g as GET_WORKING_MEMORY_ROUTE, h as GET_THREAD_BY_ID_ROUTE, i as CREATE_THREAD_ROUTE, l as GET_MEMORY_CONFIG_ROUTE, n as CLONE_THREAD_ROUTE, p as GET_RESOURCE_WORKING_MEMORY_ROUTE, t as AWAIT_BUFFER_STATUS_ROUTE, v as LIST_MESSAGES_ROUTE } from "./memory-03B4pe3w.js";
10
10
  import { a as GET_TRACE_ROUTE, i as GET_TRACE_LIGHT_ROUTE, o as GET_TRACE_TRAJECTORY_ROUTE, r as GET_SPAN_ROUTE, u as LIST_TRACES_ROUTE } from "./observability-URaJnI_U.js";
@@ -3,7 +3,7 @@ name: mastra-server
3
3
  description: Documentation for @mastra/server. Use when working with @mastra/server APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/server"
6
- version: "1.86.0"
6
+ version: "1.87.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.86.0",
2
+ "version": "1.87.0-alpha.0",
3
3
  "package": "@mastra/server",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -18,7 +18,12 @@ Resumable streams don't make the run itself durable. Reconnecting isn't crash re
18
18
  | Plain agent with `durable: false` | Off, including registered agents |
19
19
  | Explicit `createDurableAgent()` wrapper | Always published; pass `cache: false` to the factory to disable the replay cache, not transport history |
20
20
 
21
- A registered agent, durable or not, publishes on `mastra.pubsub` and caches events in `mastra.serverCache`, or an in-memory cache when the server has none. Every `Mastra` instance that shares that PubSub and cache can observe the run. An agent-level `pubsub` takes precedence, except on the evented engine, whose steps always publish on `mastra.pubsub`.
21
+ Mastra resolves the stream transport and replay cache separately:
22
+
23
+ - **Transport:** For the plain loop and the default durable engine, Mastra uses the first configured option: the agent's `durable.pubsub`, the agent's top-level `pubsub`, or `mastra.pubsub`. Evented steps publish on `mastra.pubsub` so workers can publish to the same stream.
24
+ - **Replay cache:** Mastra uses the agent's `durable.cache`, then `mastra.serverCache`, then an in-memory cache. Evented runs use the shared Mastra cache when replay caching is enabled. If the transport is already a `CachingPubSub`, Mastra reuses its cache. Set `durable.cache: false` to skip adding a replay cache without changing the transport or its retained history.
25
+
26
+ For deployments with more than one process, see [PubSub setup for resumable streams](https://mastra.ai/docs/server/pubsub).
22
27
 
23
28
  ## Configure streams
24
29
 
@@ -48,7 +53,9 @@ export const supportAgent = new Agent({
48
53
 
49
54
  `durable: true` turns streams on with these defaults, including for standalone agents.
50
55
 
51
- On a plain `Agent`, `durable` configures resumable streams only. For checkpoint-backed execution, wrap the agent explicitly with `createDurableAgent({ agent })`. To recover in-flight runs after a crash, also configure persistent workflow storage and `recovery: { durableAgents: 'auto' }`. For manual recovery instead, pass a `shouldPersistSnapshot` policy that includes `running` snapshots and call `recoverActiveRuns()` yourself. See [crash recovery](https://mastra.ai/docs/harness/durable-agents) for setup and persistence policies.
56
+ To checkpoint execution as well as publish run frames, set `durable.executionEngine` to `'default'` or `'evented'` on the agent, or inherit the setting from `Mastra`. Without an engine setting, `durable: true` only enables stream publication.
57
+
58
+ To continue an in-flight run after a crash, configure [crash recovery](https://mastra.ai/docs/harness/durable-agents) separately.
52
59
 
53
60
  Configure the wrapper's stream cache and transport through the factory's `cache`, `pubsub`, `shouldCache`, and `cleanupTimeoutMs` options.
54
61
 
@@ -72,15 +79,17 @@ To keep live observation but skip the replay cache, pass `durable: { cache: fals
72
79
 
73
80
  ### How long runs stay available
74
81
 
75
- After a run finishes, the executing process schedules cleanup of its events and ownership record after `cleanupTimeoutMs`. The timer allows the process to exit before cleanup. Shared cache data then remains until expiry or eviction. Redis Streams retains its native topic data until `clearTopic()` succeeds or its idle TTL expires. The transport's default idle TTL is seven days. Configure `streamIdleTtlMs` to change it, or set it to `0` to disable transport expiry. A run parked on a tool approval or suspension isn't cleared by that timer, because resuming it continues on the same topic.
82
+ When a run finishes, the executing process schedules deletion of its events and ownership record after `cleanupTimeoutMs` (30 seconds by default). That's the fast path. Everything is also bounded by idle retention, refreshed on every append, so a process that restarts before the deletion timer fires can't leave a run's state behind indefinitely. A run parked on a tool approval or suspension isn't deleted, because resuming it continues on the same topic.
76
83
 
77
- The cache bounds everything else:
84
+ The retentions that apply:
78
85
 
79
- - Run logs and ownership records ask the cache for a 24-hour TTL. The in-memory cache uses at least this TTL for indexed run logs, unless cache expiry is disabled. Cache entry limits can evict data sooner.
86
+ - A run's replay cache requests a minimum 24-hour lifetime after the last append (`runLogTtlMs` on [`CachingPubSub`](https://mastra.ai/reference/pubsub/caching-pubsub)). Redis and Valkey Streams use a separate 24-hour transport default for run topics. These defaults match the run record's own 24-hour lifetime, deliberately: a run parked on a tool approval appends nothing while it waits, so its retention is never refreshed, and the events must outlive every moment the record still authorizes an `observe()` or resume. For thread streams, `threadStreamLogTtlMs` requests one hour in the cache while the transport independently defaults to one hour, enough for an idle thread's tail to survive a reconnect. Cache TTL overrides leave the transport defaults unchanged, though `streamIdleTtlMs` can shorten them. The replay cache's retention is stamped only when an event is appended. The transport's is also refreshed when a reader subscribes.
87
+ - A run's ownership record keeps a 24-hour lifetime, so a run parked overnight on an approval stays authorizable for observe and resume, and because its events share that lifetime, the approval request is still there to replay. The run log is a delivery buffer and messages live in storage: once both expire, `observe()` returns 404 rather than replaying, and a client fetches the conversation from storage.
88
+ - Topics that don't belong to a single run or thread, such as work queues and application feeds, keep the transport's own idle TTL, seven days by default for [Redis Streams](https://mastra.ai/reference/pubsub/redis-streams) and [Valkey Streams](https://mastra.ai/reference/pubsub/valkey-streams). They need it: a grouped consumer that was offline must still find its backlog. Configure `streamIdleTtlMs` to change it, or set it to `0` to disable transport expiry. Lowering it also lowers the retention on run topics.
80
89
  - The in-memory cache holds 1,000 entries by default. Each run uses several entries (its event log, a counter and its ownership record), so heavy traffic evicts older runs sooner.
81
90
  - The server's observe and abort routes return 404 when a run's ownership record is evicted or expires. Evicted run events can't be replayed.
82
91
 
83
- Use a shared cache such as Redis, sized for your traffic, when runs must stay observable across servers or for long approval waits.
92
+ A run log recreated after its retention lapsed normally numbers above the indices it issued before. An attached observer then keeps receiving the new frames. Treat that as the common case rather than a guarantee: the built-in Redis, Valkey and in-memory caches derive the numbering from a clock, Convex numbers densely instead, and the fallback that detects a restarted log only recognizes one that restarts at zero. An observer attached across a log recreated below its cursor can miss new frames. Reattaching without the old offset can replay the entries still retained in the new log, while reusing that offset can skip them. Storage remains the source of truth for a run's messages. Use a shared cache such as Redis, sized for your traffic, when runs must stay observable across servers or for long approval waits.
84
93
 
85
94
  ## Follow a run
86
95
 
@@ -1,6 +1,6 @@
1
1
  import { r as __exportAll } from "./rolldown-runtime-CQI-hT2b.js";
2
2
  import { n as GET_AGENT_CARD_ROUTE, t as AGENT_EXECUTION_ROUTE } from "./a2a-CY7rgzPe.js";
3
- import { a as LIST_AGENT_BUILDER_ACTIONS_ROUTE, c as OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, d as RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE, f as RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE, g as STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, h as STREAM_AGENT_BUILDER_ACTION_ROUTE, i as GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE, l as RESUME_AGENT_BUILDER_ACTION_ROUTE, m as START_ASYNC_AGENT_BUILDER_ACTION_ROUTE, n as CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE, o as LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE, p as START_AGENT_BUILDER_ACTION_RUN_ROUTE, r as GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE, s as OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE, t as CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE, u as RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE } from "./agent-builder-DHnNRROR.js";
3
+ import { a as LIST_AGENT_BUILDER_ACTIONS_ROUTE, c as OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, d as RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE, f as RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE, g as STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, h as STREAM_AGENT_BUILDER_ACTION_ROUTE, i as GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE, l as RESUME_AGENT_BUILDER_ACTION_ROUTE, m as START_ASYNC_AGENT_BUILDER_ACTION_ROUTE, n as CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE, o as LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE, p as START_AGENT_BUILDER_ACTION_RUN_ROUTE, r as GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE, s as OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE, t as CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE, u as RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE } from "./agent-builder-B3vJTDHo.js";
4
4
  import { A as STEER_AGENT_CONTROLLER_SESSION_ROUTE, C as SEND_AGENT_CONTROLLER_MESSAGE_ROUTE, D as SET_AGENT_CONTROLLER_RESOURCE_ID_ROUTE, E as SET_AGENT_CONTROLLER_GOAL_ROUTE, F as TRANSFER_AGENT_CONTROLLER_THREAD_OWNERSHIP_ROUTE, I as UPDATE_AGENT_CONTROLLER_GOAL_ROUTE, M as SWITCH_AGENT_CONTROLLER_MODEL_ROUTE, N as SWITCH_AGENT_CONTROLLER_MODE_ROUTE, O as SET_AGENT_CONTROLLER_SESSION_STATE_ROUTE, P as SWITCH_AGENT_CONTROLLER_THREAD_ROUTE, S as RENAME_AGENT_CONTROLLER_THREAD_ROUTE, T as SET_AGENT_CONTROLLER_CATEGORY_PERMISSION_ROUTE, _ as LIST_AGENT_CONTROLLER_ACTIVE_RUNS_ROUTE, a as CLONE_AGENT_CONTROLLER_THREAD_ROUTE, b as LIST_AGENT_CONTROLLER_THREADS_ROUTE, c as DELETE_AGENT_CONTROLLER_THREAD_ROUTE, d as GET_AGENT_CONTROLLER_OM_RECORD_ROUTE, f as GET_AGENT_CONTROLLER_PERMISSIONS_ROUTE, g as LIST_AGENT_CONTROLLERS_ROUTE, h as GET_AGENT_CONTROLLER_WORKSPACE_STATUS_ROUTE, i as CLEAR_AGENT_CONTROLLER_GOAL_ROUTE, j as STREAM_AGENT_CONTROLLER_SESSION_ROUTE, k as SET_AGENT_CONTROLLER_TOOL_PERMISSION_ROUTE, l as FOLLOW_UP_AGENT_CONTROLLER_SESSION_ROUTE, m as GET_AGENT_CONTROLLER_SESSION_STATE_ROUTE, n as AGENT_CONTROLLER_TOOL_APPROVAL_ROUTE, o as CREATE_AGENT_CONTROLLER_SESSION_ROUTE, p as GET_AGENT_CONTROLLER_RESOURCE_IDS_ROUTE, r as AGENT_CONTROLLER_TOOL_SUSPENSION_ROUTE, s as CREATE_AGENT_CONTROLLER_THREAD_ROUTE, t as ABORT_AGENT_CONTROLLER_SESSION_ROUTE, u as GET_AGENT_CONTROLLER_GOAL_ROUTE, v as LIST_AGENT_CONTROLLER_MODELS_ROUTE, w as SEND_AGENT_CONTROLLER_NOTIFICATION_ROUTE, x as LIST_AGENT_CONTROLLER_THREAD_MESSAGES_ROUTE, y as LIST_AGENT_CONTROLLER_MODES_ROUTE } from "./agent-controller-CzKnfKkw.js";
5
5
  import { A as SEND_TOOL_APPROVAL_ROUTE, B as UPDATE_AGENT_MODEL_IN_MODEL_LIST_ROUTE, C as RECOVER_ROUTE, D as RESUME_STREAM_UNTIL_IDLE_ROUTE, E as RESUME_STREAM_ROUTE, F as STREAM_UI_MESSAGE_DEPRECATED_ROUTE, I as STREAM_UI_MESSAGE_VNEXT_DEPRECATED_ROUTE, L as STREAM_UNTIL_IDLE_GENERATE_ROUTE, M as STREAM_GENERATE_ROUTE, N as STREAM_GENERATE_VNEXT_DEPRECATED_ROUTE, O as SEND_AGENT_MESSAGE_ROUTE, P as STREAM_NETWORK_ROUTE, R as STREAM_VNEXT_DEPRECATED_ROUTE, S as QUEUE_AGENT_SIGNAL_ROUTE, T as RESET_AGENT_MODEL_ROUTE, V as UPDATE_AGENT_MODEL_ROUTE, _ as GET_PROVIDERS_ROUTE, a as APPROVE_TOOL_CALL_ROUTE, b as OBSERVE_AGENT_STREAM_ROUTE, c as DECLINE_NETWORK_TOOL_CALL_ROUTE, d as ENHANCE_INSTRUCTIONS_ROUTE, f as GENERATE_AGENT_ROUTE, g as GET_AGENT_SKILL_ROUTE, h as GET_AGENT_BY_ID_ROUTE, i as APPROVE_TOOL_CALL_GENERATE_ROUTE, j as STREAM_GENERATE_LEGACY_ROUTE, k as SEND_AGENT_SIGNAL_ROUTE, l as DECLINE_TOOL_CALL_GENERATE_ROUTE, m as GENERATE_LEGACY_ROUTE, n as ABORT_AGENT_THREAD_ROUTE, o as CANCEL_AGENT_PENDING_SIGNALS_ROUTE, p as GENERATE_AGENT_VNEXT_ROUTE, r as APPROVE_NETWORK_TOOL_CALL_ROUTE, s as CLONE_AGENT_ROUTE, t as ABORT_AGENT_RUN_ROUTE, u as DECLINE_TOOL_CALL_ROUTE, v as LIST_AGENTS_ROUTE, w as REORDER_AGENT_MODEL_LIST_ROUTE, x as QUEUE_AGENT_MESSAGE_ROUTE, y as LIST_SUSPENDED_RUNS_ROUTE, z as SUBSCRIBE_AGENT_THREAD_ROUTE } from "./agents-CAXsXenf.js";
6
6
  import { t as READ_AGENT_PLAN_ROUTE } from "./plans-DGC1grMp.js";
@@ -16,7 +16,7 @@ import { a as LIST_BUILDER_REGISTRIES_ROUTE, i as BUILDER_REGISTRY_SEARCH_ROUTE,
16
16
  import { n as GET_EDITOR_BUILDER_SETTINGS_ROUTE, r as GET_INFRASTRUCTURE_STATUS_ROUTE, t as GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE } from "./editor-builder-BRzXnsRW.js";
17
17
  import { n as STREAM_WORKFLOW_BUILDER_ROUTE, t as GET_WORKFLOW_BUILDER_SETTINGS_ROUTE } from "./workflow-builder-BET96Cr_.js";
18
18
  import { a as GET_KNOWLEDGE_PAGE_ROUTE, c as SEARCH_KNOWLEDGE_ROUTE, i as GET_KNOWLEDGE_PAGE_LINKS_ROUTE, l as STREAM_KNOWLEDGE_EVENTS_ROUTE, n as GET_KNOWLEDGE_GRAPH_ROUTE, o as GET_KNOWLEDGE_TREE_ROUTE, r as GET_KNOWLEDGE_LINK_COUNTS_ROUTE, s as LIST_KNOWLEDGE_ROUTE, t as GET_KNOWLEDGE_ACTIVITY_ROUTE } from "./knowledge-wqC0nrmu.js";
19
- import { C as STREAM_LEGACY_WORKFLOW_ROUTE, D as TIME_TRAVEL_WORKFLOW_ROUTE, E as TIME_TRAVEL_STREAM_WORKFLOW_ROUTE, S as START_WORKFLOW_RUN_ROUTE, T as TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE, _ as RESUME_ASYNC_WORKFLOW_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, b as RESUME_WORKFLOW_ROUTE, c as LIST_WORKFLOW_RUNS_ROUTE, d as OBSERVE_STREAM_WORKFLOW_ROUTE, f as RECEIVE_WORKFLOW_EVENT_ROUTE, g as RESTART_WORKFLOW_ROUTE, h as RESTART_ASYNC_WORKFLOW_ROUTE, i as EXECUTE_WORKFLOW_STEP_ROUTE, l as LIST_WORKFLOW_RUN_COUNTS_ROUTE, m as RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE, n as CREATE_WORKFLOW_RUN_ROUTE, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, p as RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE, r as DELETE_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, t as CANCEL_WORKFLOW_RUN_ROUTE, u as OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE, v as RESUME_NO_WAIT_WORKFLOW_ROUTE, w as STREAM_WORKFLOW_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE, y as RESUME_STREAM_WORKFLOW_ROUTE } from "./workflows-D5bfbang.js";
19
+ import { C as STREAM_LEGACY_WORKFLOW_ROUTE, D as TIME_TRAVEL_WORKFLOW_ROUTE, E as TIME_TRAVEL_STREAM_WORKFLOW_ROUTE, S as START_WORKFLOW_RUN_ROUTE, T as TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE, _ as RESUME_ASYNC_WORKFLOW_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, b as RESUME_WORKFLOW_ROUTE, c as LIST_WORKFLOW_RUNS_ROUTE, d as OBSERVE_STREAM_WORKFLOW_ROUTE, f as RECEIVE_WORKFLOW_EVENT_ROUTE, g as RESTART_WORKFLOW_ROUTE, h as RESTART_ASYNC_WORKFLOW_ROUTE, i as EXECUTE_WORKFLOW_STEP_ROUTE, l as LIST_WORKFLOW_RUN_COUNTS_ROUTE, m as RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE, n as CREATE_WORKFLOW_RUN_ROUTE, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, p as RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE, r as DELETE_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, t as CANCEL_WORKFLOW_RUN_ROUTE, u as OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE, v as RESUME_NO_WAIT_WORKFLOW_ROUTE, w as STREAM_WORKFLOW_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE, y as RESUME_STREAM_WORKFLOW_ROUTE } from "./workflows-OjUXkjWw.js";
20
20
  import { n as LIST_LOGS_ROUTE, r as LIST_LOG_TRANSPORTS_ROUTE, t as LIST_LOGS_BY_RUN_ID_ROUTE } from "./logs-CqgT7AOV.js";
21
21
  import { _ as READ_MCP_SERVER_RESOURCE_ROUTE, a as FIND_MCP_SERVER_TASK_ROUTE, c as LIST_MCP_SERVERS_ROUTE, d as LIST_MCP_SERVER_TASKS_ROUTE, f as LIST_MCP_SERVER_TOOLS_ROUTE, g as POLL_MCP_SERVER_EVENT_ROUTE, h as MCP_SSE_TRANSPORT_ROUTE, i as EXECUTE_MCP_SERVER_TOOL_ROUTE, l as LIST_MCP_SERVER_EVENTS_ROUTE, m as MCP_SSE_MESSAGES_ROUTE, n as CANCEL_MCP_SERVER_TASK_ROUTE, o as GET_MCP_SERVER_DETAIL_ROUTE, p as MCP_HTTP_TRANSPORT_ROUTE, r as EMIT_MCP_SERVER_EVENT_ROUTE, s as GET_MCP_SERVER_TOOL_DETAIL_ROUTE, t as ANSWER_MCP_SERVER_TASK_ROUTE, u as LIST_MCP_SERVER_RESOURCES_ROUTE, v as STREAM_MCP_SERVER_EVENT_ROUTE } from "./mcp-DXvFogeV.js";
22
22
  import { a as wrapSchemaForQueryParams, i as pickParams, n as createRoute, r as jsonQueryParam, s as generateOpenAPIDocument, t as createPublicRoute } from "./route-builder-Dz18c3qm.js";
@@ -235,7 +235,7 @@ async function loadBuiltinMCP(mastra) {
235
235
  })
236
236
  });
237
237
  }
238
- const { buildBuiltinMCPTools, modelSummaryOf } = await import("./catalogue-BOzHZ1xt.js");
238
+ const { buildBuiltinMCPTools, modelSummaryOf } = await import("./catalogue-CS1s8mfe.js");
239
239
  return {
240
240
  MCPServer: mcp.MCPServer,
241
241
  buildBuiltinMCPTools,
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-10nMEhjP.cjs");
2
2
  const require_a2a = require("./a2a-DwjvHqcb.cjs");
3
- const require_agent_builder = require("./agent-builder-anRH1X35.cjs");
3
+ const require_agent_builder = require("./agent-builder-QnIH-0LI.cjs");
4
4
  const require_agent_controller = require("./agent-controller-BP-CFfsg.cjs");
5
5
  const require_agents = require("./agents-GHhuyz5x.cjs");
6
6
  const require_plans = require("./plans-kA8E3Auv.cjs");
@@ -16,7 +16,7 @@ const require_builder_registry = require("./builder-registry-BBI_5CBL.cjs");
16
16
  const require_editor_builder = require("./editor-builder-G1ub9j0s.cjs");
17
17
  const require_workflow_builder = require("./workflow-builder-DpL3Nq6T.cjs");
18
18
  const require_knowledge = require("./knowledge-B3768ERP.cjs");
19
- const require_workflows = require("./workflows-CHKSHV4f.cjs");
19
+ const require_workflows = require("./workflows-PVrj85xM.cjs");
20
20
  const require_logs = require("./logs-B0dcn5iB.cjs");
21
21
  const require_mcp = require("./mcp-C060MyHc.cjs");
22
22
  const require_route_builder = require("./route-builder-DjTBxSZN.cjs");
@@ -235,7 +235,7 @@ async function loadBuiltinMCP(mastra) {
235
235
  })
236
236
  });
237
237
  }
238
- const { buildBuiltinMCPTools, modelSummaryOf } = await Promise.resolve().then(() => require("./catalogue-DNy7Fog6.cjs"));
238
+ const { buildBuiltinMCPTools, modelSummaryOf } = await Promise.resolve().then(() => require("./catalogue-BTdmOZq6.cjs"));
239
239
  return {
240
240
  MCPServer: mcp.MCPServer,
241
241
  buildBuiltinMCPTools,
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../rolldown-runtime-10nMEhjP.cjs");
3
- const require_agent_builder = require("../../agent-builder-anRH1X35.cjs");
3
+ const require_agent_builder = require("../../agent-builder-QnIH-0LI.cjs");
4
4
  exports.CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE = require_agent_builder.CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE;
5
5
  exports.CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE = require_agent_builder.CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE;
6
6
  exports.GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE = require_agent_builder.GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE;
@@ -1 +1 @@
1
- export { t as CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE, n as CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE, r as GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE, i as GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE, a as LIST_AGENT_BUILDER_ACTIONS_ROUTE, o as LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE, s as OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE, c as OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, l as RESUME_AGENT_BUILDER_ACTION_ROUTE, u as RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE, d as RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE, f as RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE, p as START_AGENT_BUILDER_ACTION_RUN_ROUTE, m as START_ASYNC_AGENT_BUILDER_ACTION_ROUTE, h as STREAM_AGENT_BUILDER_ACTION_ROUTE, g as STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE } from "../../agent-builder-DHnNRROR.js";
1
+ export { t as CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE, n as CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE, r as GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE, i as GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE, a as LIST_AGENT_BUILDER_ACTIONS_ROUTE, o as LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE, s as OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE, c as OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, l as RESUME_AGENT_BUILDER_ACTION_ROUTE, u as RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE, d as RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE, f as RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE, p as START_AGENT_BUILDER_ACTION_RUN_ROUTE, m as START_ASYNC_AGENT_BUILDER_ACTION_ROUTE, h as STREAM_AGENT_BUILDER_ACTION_ROUTE, g as STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE } from "../../agent-builder-B3vJTDHo.js";
@@ -52,6 +52,16 @@ function isDurableRunConflictError(error) {
52
52
  const id = error?.id;
53
53
  return error instanceof Error && typeof id === "string" && DURABLE_RUN_CONFLICT_CODES.has(id);
54
54
  }
55
+ const RUN_FENCE_CONFLICT_CODE = "STORAGE_RUN_FENCE_CONFLICT";
56
+ /** The run named by the run fence conflict in `error` or its cause chain, if there is one. */
57
+ function runFenceConflictRunId(error) {
58
+ let current = error;
59
+ for (let depth = 0; depth < 8 && current && typeof current === "object"; depth++) {
60
+ const { id, code, details, cause } = current;
61
+ if ((id === RUN_FENCE_CONFLICT_CODE || code === RUN_FENCE_CONFLICT_CODE) && typeof details?.runId === "string") return details.runId;
62
+ current = cause;
63
+ }
64
+ }
55
65
  const FEEDBACK_REVIEW_STATUS_CONFLICT_CODE = "OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_CONFLICT";
56
66
  function isFeedbackReviewStatusConflictError(error) {
57
67
  return error instanceof Error && error.id === FEEDBACK_REVIEW_STATUS_CONFLICT_CODE;
@@ -127,6 +137,21 @@ function handleError(error, defaultMessage) {
127
137
  cause: error
128
138
  });
129
139
  }
140
+ const fencedRunId = runFenceConflictRunId(error);
141
+ if (fencedRunId !== void 0) {
142
+ const message = `Workflow run "${fencedRunId}" is now driven by another instance. Read the run for its current state.`;
143
+ throw new require_http_exception.HTTPException(409, {
144
+ res: new Response(JSON.stringify({
145
+ error: message,
146
+ code: RUN_FENCE_CONFLICT_CODE
147
+ }), {
148
+ status: 409,
149
+ headers: { "content-type": "application/json" }
150
+ }),
151
+ message,
152
+ cause: error
153
+ });
154
+ }
130
155
  if (isFeedbackReviewStatusConflictError(error)) throw new require_http_exception.HTTPException(409, {
131
156
  message: error.message,
132
157
  stack: error.stack,
@@ -153,3 +178,4 @@ function handleError(error, defaultMessage) {
153
178
  exports.formatZodError = formatZodError;
154
179
  exports.handleError = handleError;
155
180
  exports.isZodError = isZodError;
181
+ exports.runFenceConflictRunId = runFenceConflictRunId;
@@ -9,6 +9,8 @@ export interface ZodErrorLike {
9
9
  message: string;
10
10
  }>;
11
11
  }
12
+ /** The run named by the run fence conflict in `error` or its cause chain, if there is one. */
13
+ export declare function runFenceConflictRunId(error: unknown): string | undefined;
12
14
  /**
13
15
  * Structural check for ZodError instances.
14
16
  *
@@ -50,6 +50,16 @@ function isDurableRunConflictError(error) {
50
50
  const id = error?.id;
51
51
  return error instanceof Error && typeof id === "string" && DURABLE_RUN_CONFLICT_CODES.has(id);
52
52
  }
53
+ const RUN_FENCE_CONFLICT_CODE = "STORAGE_RUN_FENCE_CONFLICT";
54
+ /** The run named by the run fence conflict in `error` or its cause chain, if there is one. */
55
+ function runFenceConflictRunId(error) {
56
+ let current = error;
57
+ for (let depth = 0; depth < 8 && current && typeof current === "object"; depth++) {
58
+ const { id, code, details, cause } = current;
59
+ if ((id === RUN_FENCE_CONFLICT_CODE || code === RUN_FENCE_CONFLICT_CODE) && typeof details?.runId === "string") return details.runId;
60
+ current = cause;
61
+ }
62
+ }
53
63
  const FEEDBACK_REVIEW_STATUS_CONFLICT_CODE = "OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_CONFLICT";
54
64
  function isFeedbackReviewStatusConflictError(error) {
55
65
  return error instanceof Error && error.id === FEEDBACK_REVIEW_STATUS_CONFLICT_CODE;
@@ -125,6 +135,21 @@ function handleError(error, defaultMessage) {
125
135
  cause: error
126
136
  });
127
137
  }
138
+ const fencedRunId = runFenceConflictRunId(error);
139
+ if (fencedRunId !== void 0) {
140
+ const message = `Workflow run "${fencedRunId}" is now driven by another instance. Read the run for its current state.`;
141
+ throw new HTTPException(409, {
142
+ res: new Response(JSON.stringify({
143
+ error: message,
144
+ code: RUN_FENCE_CONFLICT_CODE
145
+ }), {
146
+ status: 409,
147
+ headers: { "content-type": "application/json" }
148
+ }),
149
+ message,
150
+ cause: error
151
+ });
152
+ }
128
153
  if (isFeedbackReviewStatusConflictError(error)) throw new HTTPException(409, {
129
154
  message: error.message,
130
155
  stack: error.stack,
@@ -148,4 +173,4 @@ function handleError(error, defaultMessage) {
148
173
  cause: apiError.cause
149
174
  });
150
175
  }
151
- export { formatZodError, handleError, isZodError };
176
+ export { formatZodError, handleError, isZodError, runFenceConflictRunId };
@@ -90,7 +90,7 @@ const GET_API_SCHEMA_ROUTE = require_route_builder.createRoute({
90
90
  tags: ["System"],
91
91
  requiresAuth: true,
92
92
  handler: async () => {
93
- const { buildApiSchemaManifest } = await Promise.resolve().then(() => require("../../api-schema-manifest-CX16hC7V.cjs"));
93
+ const { buildApiSchemaManifest } = await Promise.resolve().then(() => require("../../api-schema-manifest-DohjGeTI.cjs"));
94
94
  return buildApiSchemaManifest();
95
95
  }
96
96
  });
@@ -88,7 +88,7 @@ const GET_API_SCHEMA_ROUTE = createRoute({
88
88
  tags: ["System"],
89
89
  requiresAuth: true,
90
90
  handler: async () => {
91
- const { buildApiSchemaManifest } = await import("../../api-schema-manifest-4PK1dBWt.js");
91
+ const { buildApiSchemaManifest } = await import("../../api-schema-manifest-BS3Xfypt.js");
92
92
  return buildApiSchemaManifest();
93
93
  }
94
94
  });
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../rolldown-runtime-10nMEhjP.cjs");
3
- const require_workflows = require("../../workflows-CHKSHV4f.cjs");
3
+ const require_workflows = require("../../workflows-PVrj85xM.cjs");
4
4
  exports.CANCEL_WORKFLOW_RUN_ROUTE = require_workflows.CANCEL_WORKFLOW_RUN_ROUTE;
5
5
  exports.CREATE_WORKFLOW_RUN_ROUTE = require_workflows.CREATE_WORKFLOW_RUN_ROUTE;
6
6
  exports.DELETE_WORKFLOW_RUN_BY_ID_ROUTE = require_workflows.DELETE_WORKFLOW_RUN_BY_ID_ROUTE;
@@ -1 +1 @@
1
- export { t as CANCEL_WORKFLOW_RUN_ROUTE, n as CREATE_WORKFLOW_RUN_ROUTE, r as DELETE_WORKFLOW_RUN_BY_ID_ROUTE, i as EXECUTE_WORKFLOW_STEP_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, c as LIST_WORKFLOW_RUNS_ROUTE, l as LIST_WORKFLOW_RUN_COUNTS_ROUTE, u as OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE, d as OBSERVE_STREAM_WORKFLOW_ROUTE, f as RECEIVE_WORKFLOW_EVENT_ROUTE, p as RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE, m as RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE, h as RESTART_ASYNC_WORKFLOW_ROUTE, g as RESTART_WORKFLOW_ROUTE, _ as RESUME_ASYNC_WORKFLOW_ROUTE, v as RESUME_NO_WAIT_WORKFLOW_ROUTE, y as RESUME_STREAM_WORKFLOW_ROUTE, b as RESUME_WORKFLOW_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE, S as START_WORKFLOW_RUN_ROUTE, C as STREAM_LEGACY_WORKFLOW_ROUTE, w as STREAM_WORKFLOW_ROUTE, T as TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE, E as TIME_TRAVEL_STREAM_WORKFLOW_ROUTE, D as TIME_TRAVEL_WORKFLOW_ROUTE, O as __setWorkflowRunCountsNow, k as listWorkflowsFromSystem } from "../../workflows-D5bfbang.js";
1
+ export { t as CANCEL_WORKFLOW_RUN_ROUTE, n as CREATE_WORKFLOW_RUN_ROUTE, r as DELETE_WORKFLOW_RUN_BY_ID_ROUTE, i as EXECUTE_WORKFLOW_STEP_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, c as LIST_WORKFLOW_RUNS_ROUTE, l as LIST_WORKFLOW_RUN_COUNTS_ROUTE, u as OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE, d as OBSERVE_STREAM_WORKFLOW_ROUTE, f as RECEIVE_WORKFLOW_EVENT_ROUTE, p as RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE, m as RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE, h as RESTART_ASYNC_WORKFLOW_ROUTE, g as RESTART_WORKFLOW_ROUTE, _ as RESUME_ASYNC_WORKFLOW_ROUTE, v as RESUME_NO_WAIT_WORKFLOW_ROUTE, y as RESUME_STREAM_WORKFLOW_ROUTE, b as RESUME_WORKFLOW_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE, S as START_WORKFLOW_RUN_ROUTE, C as STREAM_LEGACY_WORKFLOW_ROUTE, w as STREAM_WORKFLOW_ROUTE, T as TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE, E as TIME_TRAVEL_STREAM_WORKFLOW_ROUTE, D as TIME_TRAVEL_WORKFLOW_ROUTE, O as __setWorkflowRunCountsNow, k as listWorkflowsFromSystem } from "../../workflows-OjUXkjWw.js";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../rolldown-runtime-10nMEhjP.cjs");
3
- const require_agent_builder = require("../agent-builder-anRH1X35.cjs");
3
+ const require_agent_builder = require("../agent-builder-QnIH-0LI.cjs");
4
4
  const require_server_handlers_error = require("./handlers/error.cjs");
5
5
  const require_agents = require("../agents-GHhuyz5x.cjs");
6
6
  const require_plans = require("../plans-kA8E3Auv.cjs");
@@ -16,7 +16,7 @@ const require_tools = require("../tools-By0RVh_O.cjs");
16
16
  const require_workspace = require("../workspace-D-Exdj2l.cjs");
17
17
  const require_vector = require("../vector-DIFU_fwU.cjs");
18
18
  const require_voice = require("../voice-CESew8Fc.cjs");
19
- const require_workflows = require("../workflows-CHKSHV4f.cjs");
19
+ const require_workflows = require("../workflows-PVrj85xM.cjs");
20
20
  const require_dynamic_workflows = require("../dynamic-workflows-CEKdGcSr.cjs");
21
21
  Object.defineProperty(exports, "a2a", {
22
22
  enumerable: true,
@@ -1,4 +1,4 @@
1
- import { _ as agent_builder_exports } from "../agent-builder-DHnNRROR.js";
1
+ import { _ as agent_builder_exports } from "../agent-builder-B3vJTDHo.js";
2
2
  import { formatZodError, isZodError } from "./handlers/error.js";
3
3
  import { H as agents_exports } from "../agents-CAXsXenf.js";
4
4
  import { n as plans_exports } from "../plans-DGC1grMp.js";
@@ -14,6 +14,6 @@ import { s as tools_exports } from "../tools-C3KBdlil.js";
14
14
  import { E as workspace_exports } from "../workspace-CgIZRc2P.js";
15
15
  import { g as vector_exports } from "../vector-Bz-glead.js";
16
16
  import { c as voice_exports } from "../voice-PfxY_vQg.js";
17
- import { A as workflows_exports } from "../workflows-D5bfbang.js";
17
+ import { A as workflows_exports } from "../workflows-OjUXkjWw.js";
18
18
  import { a as dynamic_workflows_exports } from "../dynamic-workflows-DF9X_oDG.js";
19
19
  export { a2a_exports as a2a, agent_builder_exports as agentBuilder, agents_exports as agents, conversations_exports as conversations, dynamic_workflows_exports as dynamicWorkflows, formatZodError, isZodError, logs_exports as logs, mcp_exports as mcp, memory_exports as memory, observability_exports as observability, plans_exports as plans, responses_exports as responses, scores_exports as scores, tools_exports as tools, vector_exports as vector, voice_exports as voice, workflows_exports as workflows, workspace_exports as workspace };
@@ -6,8 +6,8 @@ const require_utils = require("../../utils-DQJOBnMo.cjs");
6
6
  const require_constants = require("../../constants-CyNbINin.cjs");
7
7
  const require_server_handlers_error = require("../handlers/error.cjs");
8
8
  const require_agent_controller = require("../../agent-controller-BP-CFfsg.cjs");
9
- const require_routes = require("../../routes-vuZLexcc.cjs");
10
- const require_server_adapter = require("../../server-adapter-CurME3ch.cjs");
9
+ const require_routes = require("../../routes-K6oFQRlg.cjs");
10
+ const require_server_adapter = require("../../server-adapter-CuGKb03z.cjs");
11
11
  exports.ALL_SERVER_ROUTES = require_routes.ALL_SERVER_ROUTES;
12
12
  exports.BUILTIN_MCP_HTTP_ROUTE = require_routes.BUILTIN_MCP_HTTP_ROUTE;
13
13
  exports.HTTPException = require_http_exception.HTTPException;
@@ -4,6 +4,6 @@ import { o as normalizeRoutePath, t as WorkflowRegistry } from "../../utils-C2VR
4
4
  import { _ as isStudioClientTypeHeader, a as MASTRA_KNOWLEDGE_PRINCIPALS_KEY, g as isReservedRequestContextKey, i as MASTRA_IS_STUDIO_KEY, l as MASTRA_STUDIO_CLIENT_TYPE, m as RESERVED_REQUEST_CONTEXT_KEYS, r as MASTRA_CLIENT_TYPE_HEADER, t as MASTRA_AUTH_MODE_KEY } from "../../constants-C1ASuP4t.js";
5
5
  import { isZodError } from "../handlers/error.js";
6
6
  import { L as serializeStreamChunk } from "../../agent-controller-CzKnfKkw.js";
7
- import { a as derivePermission, d as resolveServerRoute, i as deriveAction, l as KNOWLEDGE_ROUTES, n as OPT_IN_ROUTES, o as extractResource, r as SERVER_ROUTES, s as getEffectivePermission, t as ALL_SERVER_ROUTES, u as BUILTIN_MCP_HTTP_ROUTE } from "../../routes-BZVlqLly.js";
8
- import { A as isMCPAudienceEnforced, C as writeWithBackpressure, D as buildMcpAuthInfoFromRequestContext, E as applyMcpRequestAuth, M as mcpWWWAuthenticate, O as checkMCPAudience, S as cancelReaderOnResponseClose, T as propagateRequestAbort, _ as parseRouteBody, a as checkRouteFGA, b as registerDispatchAdapter, c as getCustomHTTPExceptionResponse, d as getFGAProvider, f as getHTTPErrorResponse, g as normalizeQueryParams, h as isSafeObjectKey, i as bindDispatchAdapter, j as isMCPOAuthDiscoveryEnabled, k as createMCPOAuthMetadataRoutes, l as getCustomRouteHTTPExceptionResponse, m as invokeRoute, n as MastraServer, o as checkRouteRBAC, p as getRoutePermissionError, r as authorizeRoute, s as dispatchRoute, t as MASTRA_FRAMEWORK_PUBLIC_KEY, u as getEffectiveRBACProvider, v as parseRoutePathParams, w as redactStreamChunk, x as resolveRouteValidationError, y as parseRouteQueryParams } from "../../server-adapter-h8YRQXAC.js";
7
+ import { a as derivePermission, d as resolveServerRoute, i as deriveAction, l as KNOWLEDGE_ROUTES, n as OPT_IN_ROUTES, o as extractResource, r as SERVER_ROUTES, s as getEffectivePermission, t as ALL_SERVER_ROUTES, u as BUILTIN_MCP_HTTP_ROUTE } from "../../routes-ClPVLnwR.js";
8
+ import { A as isMCPAudienceEnforced, C as writeWithBackpressure, D as buildMcpAuthInfoFromRequestContext, E as applyMcpRequestAuth, M as mcpWWWAuthenticate, O as checkMCPAudience, S as cancelReaderOnResponseClose, T as propagateRequestAbort, _ as parseRouteBody, a as checkRouteFGA, b as registerDispatchAdapter, c as getCustomHTTPExceptionResponse, d as getFGAProvider, f as getHTTPErrorResponse, g as normalizeQueryParams, h as isSafeObjectKey, i as bindDispatchAdapter, j as isMCPOAuthDiscoveryEnabled, k as createMCPOAuthMetadataRoutes, l as getCustomRouteHTTPExceptionResponse, m as invokeRoute, n as MastraServer, o as checkRouteRBAC, p as getRoutePermissionError, r as authorizeRoute, s as dispatchRoute, t as MASTRA_FRAMEWORK_PUBLIC_KEY, u as getEffectiveRBACProvider, v as parseRoutePathParams, w as redactStreamChunk, x as resolveRouteValidationError, y as parseRouteQueryParams } from "../../server-adapter-CqgdBTrQ.js";
9
9
  export { ALL_SERVER_ROUTES, BUILTIN_MCP_HTTP_ROUTE, HTTPException, KNOWLEDGE_ROUTES, MASTRA_AUTH_MODE_KEY, MASTRA_CLIENT_TYPE_HEADER, MASTRA_FRAMEWORK_PUBLIC_KEY, MASTRA_IS_STUDIO_KEY, MASTRA_KNOWLEDGE_PRINCIPALS_KEY, MASTRA_STUDIO_CLIENT_TYPE, MastraServer, OPT_IN_ROUTES, RESERVED_REQUEST_CONTEXT_KEYS, SERVER_ROUTES, WorkflowRegistry, applyMcpRequestAuth, authorizeRoute, bindDispatchAdapter, buildMcpAuthInfoFromRequestContext, cancelReaderOnResponseClose, checkMCPAudience, checkRouteFGA, checkRouteRBAC, convertCustomRoutesToOpenAPIPaths, createMCPOAuthMetadataRoutes, createPublicRoute, createRoute, deriveAction, derivePermission, dispatchRoute, extractResource, generateOpenAPIDocument, getCustomHTTPExceptionResponse, getCustomRouteHTTPExceptionResponse, getEffectivePermission, getEffectiveRBACProvider, getFGAProvider, getHTTPErrorResponse, getRoutePermissionError, invokeRoute, isMCPAudienceEnforced, isMCPOAuthDiscoveryEnabled, isReservedRequestContextKey, isSafeObjectKey, isStudioClientTypeHeader, isZodError, jsonQueryParam, mcpWWWAuthenticate, normalizeQueryParams, normalizeRoutePath, parseRouteBody, parseRoutePathParams, parseRouteQueryParams, pickParams, propagateRequestAbort, redactStreamChunk, registerDispatchAdapter, resolveRouteValidationError, resolveServerRoute, serializeStreamChunk, wrapSchemaForQueryParams, writeWithBackpressure };
@@ -3,7 +3,7 @@ import { _ as isStudioClientTypeHeader, c as MASTRA_RESOURCE_ID_KEY$1, d as MAST
3
3
  import { formatZodError, isZodError } from "./server/handlers/error.js";
4
4
  import { t as HTTPException } from "./http-exception-CzaWkxMl.js";
5
5
  import { n as createRoute, o as convertCustomRoutesToOpenAPIPaths, s as generateOpenAPIDocument } from "./route-builder-Dz18c3qm.js";
6
- import { d as resolveServerRoute, f as isBuiltinMCPEnabled, n as OPT_IN_ROUTES, p as resolveBuiltinMCPPath, r as SERVER_ROUTES, s as getEffectivePermission } from "./routes-BZVlqLly.js";
6
+ import { d as resolveServerRoute, f as isBuiltinMCPEnabled, n as OPT_IN_ROUTES, p as resolveBuiltinMCPPath, r as SERVER_ROUTES, s as getEffectivePermission } from "./routes-ClPVLnwR.js";
7
7
  import { o as normalizeRoutePath } from "./utils-C2VRtQjI.js";
8
8
  import "./agent-controller-CzKnfKkw.js";
9
9
  import { z } from "zod/v4";
@@ -3,7 +3,7 @@ const require_constants = require("./constants-CyNbINin.cjs");
3
3
  const require_server_handlers_error = require("./server/handlers/error.cjs");
4
4
  const require_http_exception = require("./http-exception-Co3MbFUf.cjs");
5
5
  const require_route_builder = require("./route-builder-DjTBxSZN.cjs");
6
- const require_routes = require("./routes-vuZLexcc.cjs");
6
+ const require_routes = require("./routes-K6oFQRlg.cjs");
7
7
  const require_utils = require("./utils-DQJOBnMo.cjs");
8
8
  require("./agent-controller-BP-CFfsg.cjs");
9
9
  let zod_v4 = require("zod/v4");
@@ -6,7 +6,7 @@ import { o as optionalRunIdSchema, u as runIdSchema } from "./common-J-yUnHk9.js
6
6
  import { _ as workflowRunCountsResponseSchema, a as observeWorkflowQuerySchema, b as workflowRunResultSchema, d as streamWorkflowBodySchema, f as timeTravelBodySchema, g as workflowInfoSchema, h as workflowIdPathParams, i as listWorkflowsResponseSchema, l as startAsyncWorkflowBodySchema, m as workflowExecutionResultSchema, n as createWorkflowRunResponseSchema, o as restartBodySchema, p as workflowControlResponseSchema, r as listWorkflowRunsQuerySchema, s as resumeBodySchema, t as createWorkflowRunBodySchema, v as workflowRunPathParams, x as workflowRunsResponseSchema, y as workflowRunResultQuerySchema } from "./workflows-DTxiWG6x.js";
7
7
  import { n as createRoute } from "./route-builder-Dz18c3qm.js";
8
8
  import { a as getWorkflowInfo, t as WorkflowRegistry } from "./utils-C2VRtQjI.js";
9
- import { handleError } from "./server/handlers/error.js";
9
+ import { handleError, runFenceConflictRunId } from "./server/handlers/error.js";
10
10
  import { z } from "zod/v4";
11
11
  import { isDeepStrictEqual } from "util";
12
12
  import { createReplayStream } from "@mastra/core/stream";
@@ -66,6 +66,20 @@ async function withLoadedSteps(result) {
66
66
  } : result;
67
67
  }
68
68
  /**
69
+ * Logs a run a route started in the background that rejected. A takeover of that run by another
70
+ * instance is not a failure here: the run's claim already logged a warning.
71
+ */
72
+ function logBackgroundRunFailure(mastra, message, error, context) {
73
+ if (runFenceConflictRunId(error) === context.runId) {
74
+ mastra.getLogger().debug(`${message}: another instance took the run over`, context);
75
+ return;
76
+ }
77
+ mastra.getLogger().error(message, {
78
+ error,
79
+ ...context
80
+ });
81
+ }
82
+ /**
69
83
  * Runs whose chunks are already being written to the cache in this process,
70
84
  * keyed by runId. A run has exactly one writer: without this, two concurrent
71
85
  * requests for the same runId each cache every chunk and the replayed history
@@ -601,8 +615,7 @@ const START_WORKFLOW_RUN_ROUTE = createRoute({
601
615
  ...params,
602
616
  requestContext
603
617
  }).catch((error) => {
604
- mastra.getLogger().error("Failed to start workflow run", {
605
- error,
618
+ logBackgroundRunFailure(mastra, "Failed to start workflow run", error, {
606
619
  workflowId,
607
620
  runId
608
621
  });
@@ -776,8 +789,7 @@ const RESUME_WORKFLOW_ROUTE = createRoute({
776
789
  ...params,
777
790
  requestContext
778
791
  }).catch((error) => {
779
- mastra.getLogger().error("Failed to resume workflow run", {
780
- error,
792
+ logBackgroundRunFailure(mastra, "Failed to resume workflow run", error, {
781
793
  workflowId,
782
794
  runId
783
795
  });
@@ -857,8 +869,7 @@ const RESTART_WORKFLOW_ROUTE = createRoute({
857
869
  ...params,
858
870
  requestContext
859
871
  }).catch((error) => {
860
- mastra.getLogger().error("Failed to restart workflow run in background", {
861
- error,
872
+ logBackgroundRunFailure(mastra, "Failed to restart workflow run in background", error, {
862
873
  workflowId,
863
874
  runId
864
875
  });
@@ -995,8 +1006,7 @@ const TIME_TRAVEL_WORKFLOW_ROUTE = createRoute({
995
1006
  ...params,
996
1007
  requestContext
997
1008
  }).catch((error) => {
998
- mastra.getLogger().error("Failed to time travel workflow run", {
999
- error,
1009
+ logBackgroundRunFailure(mastra, "Failed to time travel workflow run", error, {
1000
1010
  workflowId,
1001
1011
  runId
1002
1012
  });
@@ -66,6 +66,20 @@ async function withLoadedSteps(result) {
66
66
  } : result;
67
67
  }
68
68
  /**
69
+ * Logs a run a route started in the background that rejected. A takeover of that run by another
70
+ * instance is not a failure here: the run's claim already logged a warning.
71
+ */
72
+ function logBackgroundRunFailure(mastra, message, error, context) {
73
+ if (require_server_handlers_error.runFenceConflictRunId(error) === context.runId) {
74
+ mastra.getLogger().debug(`${message}: another instance took the run over`, context);
75
+ return;
76
+ }
77
+ mastra.getLogger().error(message, {
78
+ error,
79
+ ...context
80
+ });
81
+ }
82
+ /**
69
83
  * Runs whose chunks are already being written to the cache in this process,
70
84
  * keyed by runId. A run has exactly one writer: without this, two concurrent
71
85
  * requests for the same runId each cache every chunk and the replayed history
@@ -601,8 +615,7 @@ const START_WORKFLOW_RUN_ROUTE = require_route_builder.createRoute({
601
615
  ...params,
602
616
  requestContext
603
617
  }).catch((error) => {
604
- mastra.getLogger().error("Failed to start workflow run", {
605
- error,
618
+ logBackgroundRunFailure(mastra, "Failed to start workflow run", error, {
606
619
  workflowId,
607
620
  runId
608
621
  });
@@ -776,8 +789,7 @@ const RESUME_WORKFLOW_ROUTE = require_route_builder.createRoute({
776
789
  ...params,
777
790
  requestContext
778
791
  }).catch((error) => {
779
- mastra.getLogger().error("Failed to resume workflow run", {
780
- error,
792
+ logBackgroundRunFailure(mastra, "Failed to resume workflow run", error, {
781
793
  workflowId,
782
794
  runId
783
795
  });
@@ -857,8 +869,7 @@ const RESTART_WORKFLOW_ROUTE = require_route_builder.createRoute({
857
869
  ...params,
858
870
  requestContext
859
871
  }).catch((error) => {
860
- mastra.getLogger().error("Failed to restart workflow run in background", {
861
- error,
872
+ logBackgroundRunFailure(mastra, "Failed to restart workflow run in background", error, {
862
873
  workflowId,
863
874
  runId
864
875
  });
@@ -995,8 +1006,7 @@ const TIME_TRAVEL_WORKFLOW_ROUTE = require_route_builder.createRoute({
995
1006
  ...params,
996
1007
  requestContext
997
1008
  }).catch((error) => {
998
- mastra.getLogger().error("Failed to time travel workflow run", {
999
- error,
1009
+ logBackgroundRunFailure(mastra, "Failed to time travel workflow run", error, {
1000
1010
  workflowId,
1001
1011
  runId
1002
1012
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/server",
3
- "version": "1.86.0",
3
+ "version": "1.87.0-alpha.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -133,7 +133,7 @@
133
133
  "@internal/types-builder": "0.0.127",
134
134
  "@internal/voice": "0.0.48",
135
135
  "@mastra/agent-builder": "1.2.3",
136
- "@mastra/core": "1.86.0",
136
+ "@mastra/core": "1.87.0-alpha.0",
137
137
  "@mastra/mcp": "^2.11.0",
138
138
  "@mastra/schema-compat": "1.4.1"
139
139
  },