@mastra/inngest 1.10.4 → 1.10.5

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.
@@ -2431,7 +2431,7 @@ function createInngestDurableAgenticWorkflow(options) {
2431
2431
  stepIndex: input.stepIndex ?? 0
2432
2432
  };
2433
2433
  }, { id: "init-iteration-state" }).dowhile(singleIterationWorkflow, async (params) => {
2434
- const { inputData, engine } = params;
2434
+ const { inputData, engine, mastra } = params;
2435
2435
  const state = inputData;
2436
2436
  const pubsub = params[_mastra_core_workflows__constants.PUBSUB_SYMBOL];
2437
2437
  const { step } = engine;
@@ -2457,7 +2457,7 @@ function createInngestDurableAgenticWorkflow(options) {
2457
2457
  let stopped;
2458
2458
  try {
2459
2459
  stopped = await step.run(`stop-when-${state.runId}-${state.iterationCount}`, async () => {
2460
- const stopWhen = _mastra_core_agent_durable.globalRunRegistry.get(state.runId)?.stopWhen;
2460
+ const stopWhen = (0, _mastra_core_agent_durable.getRunRegistryEntry)(state.runId, mastra)?.stopWhen;
2461
2461
  if (!stopWhen || state.accumulatedSteps.length === 0) return false;
2462
2462
  const steps = state.accumulatedSteps;
2463
2463
  return (await Promise.all((Array.isArray(stopWhen) ? stopWhen : [stopWhen]).map((condition) => condition({ steps })))).some(Boolean);
@@ -2547,14 +2547,16 @@ function createInngestDurableAgenticWorkflow(options) {
2547
2547
  stepResult: finalOutput.stepResult
2548
2548
  });
2549
2549
  return finalOutput;
2550
- }, { id: "map-final-output" }).map(async ({ inputData, getInitData, mastra, requestContext, tracingContext }) => {
2550
+ }, { id: "map-final-output" }).map(async (params) => {
2551
+ const { inputData, getInitData, mastra, requestContext, tracingContext } = params;
2551
2552
  (0, _mastra_core_agent_durable.executeDurableAgentScorers)({
2552
2553
  initData: getInitData(),
2553
2554
  finalOutput: inputData,
2554
2555
  mastra,
2555
2556
  requestContext,
2556
- tracingContext
2557
- });
2557
+ tracingContext,
2558
+ loadStoredMessages: (0, _mastra_core_agent_durable.loadRunStoredMessages)(params)
2559
+ }).catch((error) => mastra?.getLogger?.()?.warn?.(`[DurableAgent] Skipped scorers: ${error}`));
2558
2560
  return inputData;
2559
2561
  }, { id: "execute-scorers" }).commit();
2560
2562
  }
@@ -2771,7 +2773,7 @@ function createInngestAgent(options) {
2771
2773
  * worker. Mirrors the `abort()` handed out with a stream result.
2772
2774
  */
2773
2775
  function abortDurableRun(runId) {
2774
- const controller = _mastra_core_agent_durable.globalRunRegistry.get(runId)?.abortController;
2776
+ const controller = (0, _mastra_core_agent_durable.getRunRegistryEntry)(runId, mastra)?.abortController;
2775
2777
  if (controller && !controller.signal.aborted) controller.abort(/* @__PURE__ */ new Error("Aborted"));
2776
2778
  requestRemoteAbort(runId);
2777
2779
  }
@@ -2832,7 +2834,7 @@ function createInngestAgent(options) {
2832
2834
  const finalizeGlobalRegistry = () => {
2833
2835
  if (cleanedUp) return;
2834
2836
  cleanedUp = true;
2835
- _mastra_core_agent_durable.globalRunRegistry.delete(runId);
2837
+ (0, _mastra_core_agent_durable.deleteRunRegistryEntry)(runId, mastra);
2836
2838
  };
2837
2839
  const { output, cleanup: streamCleanup, ready } = (0, _mastra_core_agent_durable.createDurableAgentStream)({
2838
2840
  pubsub: getPubsub(),
@@ -2883,7 +2885,7 @@ function createInngestAgent(options) {
2883
2885
  const workflowExecution = ready.then(() => triggerWorkflow(runId, workflowInput, tracingOptions, streamOptions?.actor)).catch((error) => {
2884
2886
  emitError(runId, error);
2885
2887
  });
2886
- const trackedEntry = _mastra_core_agent_durable.globalRunRegistry.get(runId);
2888
+ const trackedEntry = (0, _mastra_core_agent_durable.getRunRegistryEntry)(runId, mastra);
2887
2889
  if (trackedEntry) trackedEntry.workflowExecution = workflowExecution;
2888
2890
  await _mastra_core_agent_durable.agentThreadStreamRuntime.registerRun(proxyRef, output, streamOptions ?? {}, agent.getPubSub(), streamOptions?.closeOnSuspend ? void 0 : { continuation: "across-suspension" });
2889
2891
  const cleanup = () => {
@@ -2919,7 +2921,7 @@ function createInngestAgent(options) {
2919
2921
  bgManager: mastra?.backgroundTaskManager
2920
2922
  });
2921
2923
  }
2922
- const existingRegistryEntry = _mastra_core_agent_durable.globalRunRegistry.get(runId);
2924
+ const existingRegistryEntry = (0, _mastra_core_agent_durable.getRunRegistryEntry)(runId, mastra);
2923
2925
  await (existingRegistryEntry?.workflowExecution)?.catch(() => {});
2924
2926
  const resumableSnapshot = (async () => {
2925
2927
  const workflowsStore = await mastra?.getStorage()?.getStore("workflows");
@@ -2953,6 +2955,7 @@ function createInngestAgent(options) {
2953
2955
  let existingEntry = existingRegistryEntry;
2954
2956
  if (!existingEntry) {
2955
2957
  existingEntry = {
2958
+ mastra,
2956
2959
  isPlaceholder: true,
2957
2960
  tools: {},
2958
2961
  model: void 0
@@ -2965,7 +2968,7 @@ function createInngestAgent(options) {
2965
2968
  const finalizeResumeRegistry = () => {
2966
2969
  if (resumeCleanedUp) return;
2967
2970
  resumeCleanedUp = true;
2968
- _mastra_core_agent_durable.globalRunRegistry.delete(runId);
2971
+ (0, _mastra_core_agent_durable.deleteRunRegistryEntry)(runId, mastra);
2969
2972
  };
2970
2973
  const { output, cleanup: streamCleanup, ready } = (0, _mastra_core_agent_durable.createDurableAgentStream)({
2971
2974
  pubsub: getPubsub(),
@@ -3147,7 +3150,7 @@ function createInngestAgent(options) {
3147
3150
  version: "v3"
3148
3151
  },
3149
3152
  offset: observeOptions?.offset,
3150
- structuredOutput: _mastra_core_agent_durable.globalRunRegistry.get(runId)?.structuredOutput,
3153
+ structuredOutput: (0, _mastra_core_agent_durable.getRunRegistryEntry)(runId, mastra)?.structuredOutput,
3151
3154
  onChunk: observeOptions?.onChunk,
3152
3155
  onStepFinish: observeOptions?.onStepFinish,
3153
3156
  onFinish: observeOptions?.onFinish,
@@ -3182,7 +3185,7 @@ function createInngestAgent(options) {
3182
3185
  const fullOutput = await result.output.getFullOutput();
3183
3186
  if (fullOutput.error) throw fullOutput.error;
3184
3187
  suspended = fullOutput.finishReason === "suspended";
3185
- if (suspended) await _mastra_core_agent_durable.globalRunRegistry.get(result.runId)?.workflowExecution;
3188
+ if (suspended) await (0, _mastra_core_agent_durable.getRunRegistryEntry)(result.runId, mastra)?.workflowExecution;
3186
3189
  if (!fullOutput.runId) fullOutput.runId = result.runId;
3187
3190
  return fullOutput;
3188
3191
  } finally {
@@ -3203,7 +3206,7 @@ function createInngestAgent(options) {
3203
3206
  const fullOutput = await result.output.getFullOutput();
3204
3207
  if (fullOutput.error) throw fullOutput.error;
3205
3208
  suspended = fullOutput.finishReason === "suspended";
3206
- if (suspended) await _mastra_core_agent_durable.globalRunRegistry.get(result.runId)?.workflowExecution;
3209
+ if (suspended) await (0, _mastra_core_agent_durable.getRunRegistryEntry)(result.runId, mastra)?.workflowExecution;
3207
3210
  if (!fullOutput.runId) fullOutput.runId = result.runId;
3208
3211
  return fullOutput;
3209
3212
  } finally {
@@ -3410,7 +3413,7 @@ function createInngestAgent(options) {
3410
3413
  abortRunStream(runId) {
3411
3414
  const aborted = agent.abortRunStream(runId);
3412
3415
  abortDurableRun(runId);
3413
- return aborted || _mastra_core_agent_durable.globalRunRegistry.get(runId) !== void 0;
3416
+ return aborted || (0, _mastra_core_agent_durable.getRunRegistryEntry)(runId, mastra) !== void 0;
3414
3417
  },
3415
3418
  __fork() {
3416
3419
  const { shouldPersistSnapshot: _ignored, ...forkOptions } = options;
@@ -4176,4 +4179,4 @@ Object.defineProperty(exports, "serve", {
4176
4179
  }
4177
4180
  });
4178
4181
 
4179
- //# sourceMappingURL=src-CQHBfx-I.cjs.map
4182
+ //# sourceMappingURL=src-DotczbYI.cjs.map