@mastra/inngest 1.11.3 → 1.11.4

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.
@@ -1,7 +1,7 @@
1
1
  import { Agent, MessageList, TripWire } from "@mastra/core/agent";
2
2
  import { ErrorCategory, ErrorDomain, MastraError, MastraNonRetryableError, getErrorFromUnknown } from "@mastra/core/error";
3
3
  import * as coreObservability from "@mastra/core/observability";
4
- import { EntityType, InternalSpans, SpanType } from "@mastra/core/observability";
4
+ import { EntityType, InternalSpans, SpanType, getOrCreateSpan } from "@mastra/core/observability";
5
5
  import { ProcessorRunner, ProcessorState, ProcessorStepOutputSchema, ProcessorStepSchema } from "@mastra/core/processors";
6
6
  import { toStandardSchema } from "@mastra/core/schema";
7
7
  import { Tool, createTool } from "@mastra/core/tools";
@@ -153,6 +153,14 @@ function generationUsage(usage, steps) {
153
153
  usage: usageIncomplete ? coreObservability.calculateObservedUsage?.(steps) ?? usage : usage
154
154
  };
155
155
  }
156
+ /**
157
+ * The context a suspending workflow run saves for its resume. A core without the helper saves the
158
+ * lineage alone, and its resume samples again.
159
+ */
160
+ function workflowResumeTracingContext(span) {
161
+ if (coreFeatures.has("workflow-resume-sampling")) return coreObservability.getWorkflowResumeTracingContext?.(span);
162
+ return coreObservability.getResumeTracingContext(span);
163
+ }
156
164
  // src/execution-engine.ts
157
165
  function isNonRetryableStepFailure(error) {
158
166
  if (error instanceof MastraNonRetryableError || error instanceof NonRetriableError) return true;
@@ -2163,23 +2171,32 @@ var InngestWorkflow = class extends Workflow {
2163
2171
  const mastra = this.#mastra;
2164
2172
  const tracingPolicy = this.options.tracingPolicy;
2165
2173
  const workflowSpanData = await step.run(`workflow.${this.id}.span.start`, async () => {
2166
- const observability = mastra?.observability?.getSelectedInstance({ requestContext });
2167
- if (!observability) return void 0;
2168
- const span = observability.startSpan({
2174
+ if (!mastra?.observability?.getSelectedInstance({ requestContext })) return void 0;
2175
+ const suspendedTracingContext = resume ? (await (await mastra.getStorage()?.getStore("workflows"))?.loadWorkflowSnapshot({
2176
+ workflowName: this.id,
2177
+ runId
2178
+ }))?.tracingContext : void 0;
2179
+ const span = getOrCreateSpan({
2169
2180
  type: SpanType.WORKFLOW_RUN,
2170
2181
  outcome: null,
2171
- name: `workflow run: '${this.id}'`,
2182
+ name: resume ? `workflow run: '${this.id}' (resumed)` : `workflow run: '${this.id}'`,
2172
2183
  entityType: EntityType.WORKFLOW_RUN,
2173
2184
  entityId: this.id,
2174
2185
  entityName: this.id,
2175
2186
  input: inputData,
2176
2187
  metadata: {
2177
2188
  resourceId,
2178
- runId
2189
+ runId,
2190
+ ...resume ? {
2191
+ resumed: true,
2192
+ resumedFromSpanId: suspendedTracingContext?.spanId
2193
+ } : {}
2179
2194
  },
2180
2195
  tracingPolicy,
2181
2196
  tracingOptions,
2182
- requestContext
2197
+ requestContext,
2198
+ resumeFrom: suspendedTracingContext,
2199
+ mastra
2183
2200
  });
2184
2201
  return span?.snapshot?.() ?? span?.exportSpan();
2185
2202
  });
@@ -2313,10 +2330,7 @@ var InngestWorkflow = class extends Workflow {
2313
2330
  result: result.status === "success" ? toSnapshotResult(result.result) : void 0,
2314
2331
  error: result.status === "failed" ? result.error : void 0,
2315
2332
  requestContext: requestContext.toJSON(),
2316
- tracingContext: workflowSpanData ? {
2317
- traceId: workflowSpanData.traceId,
2318
- spanId: workflowSpanData.id
2319
- } : void 0,
2333
+ tracingContext: workflowResumeTracingContext(workflowSpanData),
2320
2334
  timestamp: Date.now()
2321
2335
  };
2322
2336
  await workflowsStore.persistWorkflowSnapshot({
@@ -5185,4 +5199,4 @@ function init(inngest) {
5185
5199
  }
5186
5200
  export { createServe as a, isInngestAgent as c, InngestRun as d, InngestPubSub as f, connect as i, createInngestDurableAgenticWorkflow as l, InngestExecutionEngine as m, init as n, serve$1 as o, OVERSIZED_EVENT_CHUNK_TYPE as p, _compatibilityCheck as r, createInngestAgent as s, createStep as t, InngestWorkflow as u };
5187
5201
 
5188
- //# sourceMappingURL=src-CFtk0_CD.js.map
5202
+ //# sourceMappingURL=src-hK_U-MJ5.js.map