@mastra/inngest 1.1.2 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @mastra/inngest
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Fixed excessive OTel trace pollution from internal polling fetch calls. When using APM tools like Sentry or Datadog, the polling loop in `getRunOutput()` would generate hundreds of identical GET spans per workflow run, inflating observability costs and making traces harder to read. Polling fetch calls are now wrapped with `suppressTracing()` to eliminate this noise while preserving all user-facing spans. ([#14088](https://github.com/mastra-ai/mastra/pull/14088))
8
+
9
+ Closes #13892
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [[`cb611a1`](https://github.com/mastra-ai/mastra/commit/cb611a1e89a4f4cf74c97b57e0c27bb56f2eceb5), [`da93115`](https://github.com/mastra-ai/mastra/commit/da931155c1a9bc63d455d3d86b4ec984db5991fe), [`62d1d3c`](https://github.com/mastra-ai/mastra/commit/62d1d3cc08fe8182e7080237fd975de862ec8c91), [`9e1a3ed`](https://github.com/mastra-ai/mastra/commit/9e1a3ed07cfafb5e8e19a796ce0bee817002d7c0), [`8681ecb`](https://github.com/mastra-ai/mastra/commit/8681ecb86184d5907267000e4576cc442a9a83fc), [`28d0249`](https://github.com/mastra-ai/mastra/commit/28d0249295782277040ad1e0d243e695b7ab1ce4), [`681ee1c`](https://github.com/mastra-ai/mastra/commit/681ee1c811359efd1b8bebc4bce35b9bb7b14bec), [`bb0f09d`](https://github.com/mastra-ai/mastra/commit/bb0f09dbac58401b36069f483acf5673202db5b5), [`a579f7a`](https://github.com/mastra-ai/mastra/commit/a579f7a31e582674862b5679bc79af7ccf7429b8), [`5f7e9d0`](https://github.com/mastra-ai/mastra/commit/5f7e9d0db664020e1f3d97d7d18c6b0b9d4843d0), [`d7f14c3`](https://github.com/mastra-ai/mastra/commit/d7f14c3285cd253ecdd5f58139b7b6cbdf3678b5), [`0efe12a`](https://github.com/mastra-ai/mastra/commit/0efe12a5f008a939a1aac71699486ba40138054e)]:
14
+ - @mastra/core@1.15.0
15
+
16
+ ## 1.2.0-alpha.0
17
+
18
+ ### Minor Changes
19
+
20
+ - Fixed excessive OTel trace pollution from internal polling fetch calls. When using APM tools like Sentry or Datadog, the polling loop in `getRunOutput()` would generate hundreds of identical GET spans per workflow run, inflating observability costs and making traces harder to read. Polling fetch calls are now wrapped with `suppressTracing()` to eliminate this noise while preserving all user-facing spans. ([#14088](https://github.com/mastra-ai/mastra/pull/14088))
21
+
22
+ Closes #13892
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [[`cb611a1`](https://github.com/mastra-ai/mastra/commit/cb611a1e89a4f4cf74c97b57e0c27bb56f2eceb5), [`62d1d3c`](https://github.com/mastra-ai/mastra/commit/62d1d3cc08fe8182e7080237fd975de862ec8c91), [`8681ecb`](https://github.com/mastra-ai/mastra/commit/8681ecb86184d5907267000e4576cc442a9a83fc), [`28d0249`](https://github.com/mastra-ai/mastra/commit/28d0249295782277040ad1e0d243e695b7ab1ce4), [`bb0f09d`](https://github.com/mastra-ai/mastra/commit/bb0f09dbac58401b36069f483acf5673202db5b5), [`5f7e9d0`](https://github.com/mastra-ai/mastra/commit/5f7e9d0db664020e1f3d97d7d18c6b0b9d4843d0)]:
27
+ - @mastra/core@1.15.0-alpha.0
28
+
3
29
  ## 1.1.2
4
30
 
5
31
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -4,6 +4,7 @@ var agent = require('@mastra/core/agent');
4
4
  var error = require('@mastra/core/error');
5
5
  var observability = require('@mastra/core/observability');
6
6
  var processors = require('@mastra/core/processors');
7
+ var schema = require('@mastra/core/schema');
7
8
  var tools = require('@mastra/core/tools');
8
9
  var workflows = require('@mastra/core/workflows');
9
10
  var _constants = require('@mastra/core/workflows/_constants');
@@ -15,6 +16,8 @@ var realtime = require('@inngest/realtime');
15
16
  var events = require('@mastra/core/events');
16
17
  var web = require('stream/web');
17
18
  var stream = require('@mastra/core/stream');
19
+ var api = require('@opentelemetry/api');
20
+ var core = require('@opentelemetry/core');
18
21
  var hono = require('inngest/hono');
19
22
 
20
23
  // src/index.ts
@@ -642,13 +645,13 @@ var InngestRun = class extends workflows.Run {
642
645
  let lastError = null;
643
646
  for (let attempt = 0; attempt < maxRetries; attempt++) {
644
647
  try {
645
- const response = await fetch(
646
- `${this.inngest.apiBaseUrl ?? "https://api.inngest.com"}/v1/events/${eventId}/runs`,
647
- {
648
+ const response = await api.context.with(
649
+ core.suppressTracing(api.context.active()),
650
+ () => fetch(`${this.inngest.apiBaseUrl ?? "https://api.inngest.com"}/v1/events/${eventId}/runs`, {
648
651
  headers: {
649
652
  Authorization: `Bearer ${process.env.INNGEST_SIGNING_KEY}`
650
653
  }
651
- }
654
+ })
652
655
  );
653
656
  if (response.status === 429) {
654
657
  const retryAfter = parseInt(response.headers.get("retry-after") || "2", 10);
@@ -1787,11 +1790,11 @@ function createStepFromParams(params) {
1787
1790
  return {
1788
1791
  id: params.id,
1789
1792
  description: params.description,
1790
- inputSchema: params.inputSchema,
1791
- stateSchema: params.stateSchema,
1792
- outputSchema: params.outputSchema,
1793
- resumeSchema: params.resumeSchema,
1794
- suspendSchema: params.suspendSchema,
1793
+ inputSchema: schema.toStandardSchema(params.inputSchema),
1794
+ stateSchema: params.stateSchema ? schema.toStandardSchema(params.stateSchema) : void 0,
1795
+ outputSchema: schema.toStandardSchema(params.outputSchema),
1796
+ resumeSchema: params.resumeSchema ? schema.toStandardSchema(params.resumeSchema) : void 0,
1797
+ suspendSchema: params.suspendSchema ? schema.toStandardSchema(params.suspendSchema) : void 0,
1795
1798
  scorers: params.scorers,
1796
1799
  retries: params.retries,
1797
1800
  metadata: params.metadata,
@@ -1805,10 +1808,12 @@ function createStepFromAgent(params, agentOrToolOptions) {
1805
1808
  return {
1806
1809
  id: params.name,
1807
1810
  description: params.getDescription(),
1808
- inputSchema: zod.z.object({
1809
- prompt: zod.z.string()
1810
- }),
1811
- outputSchema,
1811
+ inputSchema: schema.toStandardSchema(
1812
+ zod.z.object({
1813
+ prompt: zod.z.string()
1814
+ })
1815
+ ),
1816
+ outputSchema: schema.toStandardSchema(outputSchema),
1812
1817
  retries,
1813
1818
  scorers,
1814
1819
  metadata,
@@ -1851,20 +1856,25 @@ function createStepFromAgent(params, agentOrToolOptions) {
1851
1856
  });
1852
1857
  stream = fullStream;
1853
1858
  } else {
1854
- const modelOutput = await params.stream(inputData.prompt, {
1855
- ...agentOptions ?? {},
1859
+ const { structuredOutput, ...restAgentOptions } = agentOptions ?? {};
1860
+ const baseOptions = {
1861
+ ...restAgentOptions,
1856
1862
  requestContext,
1857
1863
  tracingContext,
1858
1864
  onFinish: (result) => {
1859
1865
  const resultWithObject = result;
1860
- if (agentOptions?.structuredOutput?.schema && resultWithObject.object) {
1866
+ if (structuredOutput?.schema && resultWithObject.object) {
1861
1867
  structuredResult = resultWithObject.object;
1862
1868
  }
1863
1869
  streamPromise.resolve(result.text);
1864
1870
  void agentOptions?.onFinish?.(result);
1865
1871
  },
1866
1872
  abortSignal
1867
- });
1873
+ };
1874
+ const modelOutput = structuredOutput ? await params.stream(inputData.prompt, {
1875
+ ...baseOptions,
1876
+ structuredOutput
1877
+ }) : await params.stream(inputData.prompt, baseOptions);
1868
1878
  stream = modelOutput.fullStream;
1869
1879
  }
1870
1880
  if (streamFormat === "legacy") {
@@ -2014,6 +2024,7 @@ function createStepFromProcessor(processor) {
2014
2024
  part,
2015
2025
  streamParts,
2016
2026
  state,
2027
+ result,
2017
2028
  finishReason,
2018
2029
  toolCalls,
2019
2030
  text,
@@ -2065,6 +2076,7 @@ function createStepFromProcessor(processor) {
2065
2076
  systemMessages,
2066
2077
  streamParts,
2067
2078
  state,
2079
+ result,
2068
2080
  finishReason,
2069
2081
  toolCalls,
2070
2082
  text,
@@ -2081,9 +2093,9 @@ function createStepFromProcessor(processor) {
2081
2093
  };
2082
2094
  const executePhaseWithSpan = async (fn) => {
2083
2095
  try {
2084
- const result = await fn();
2085
- processorSpan?.end({ output: result });
2086
- return result;
2096
+ const result2 = await fn();
2097
+ processorSpan?.end({ output: result2 });
2098
+ return result2;
2087
2099
  } catch (error) {
2088
2100
  if (error instanceof agent.TripWire) {
2089
2101
  processorSpan?.end({ output: { tripwire: error.message } });
@@ -2107,15 +2119,15 @@ function createStepFromProcessor(processor) {
2107
2119
  }
2108
2120
  const idsBeforeProcessing = messages.map((m) => m.id);
2109
2121
  const check = passThrough.messageList.makeMessageSourceChecker();
2110
- const result = await processor.processInput({
2122
+ const result2 = await processor.processInput({
2111
2123
  ...baseContext,
2112
2124
  messages,
2113
2125
  messageList: passThrough.messageList,
2114
2126
  systemMessages: systemMessages ?? [],
2115
2127
  state: {}
2116
2128
  });
2117
- if (result instanceof agent.MessageList) {
2118
- if (result !== passThrough.messageList) {
2129
+ if (result2 instanceof agent.MessageList) {
2130
+ if (result2 !== passThrough.messageList) {
2119
2131
  throw new error.MastraError({
2120
2132
  category: error.ErrorCategory.USER,
2121
2133
  domain: error.ErrorDomain.MASTRA_WORKFLOW,
@@ -2125,20 +2137,20 @@ function createStepFromProcessor(processor) {
2125
2137
  }
2126
2138
  return {
2127
2139
  ...passThrough,
2128
- messages: result.get.all.db(),
2129
- systemMessages: result.getAllSystemMessages()
2140
+ messages: result2.get.all.db(),
2141
+ systemMessages: result2.getAllSystemMessages()
2130
2142
  };
2131
- } else if (Array.isArray(result)) {
2143
+ } else if (Array.isArray(result2)) {
2132
2144
  processors.ProcessorRunner.applyMessagesToMessageList(
2133
- result,
2145
+ result2,
2134
2146
  passThrough.messageList,
2135
2147
  idsBeforeProcessing,
2136
2148
  check,
2137
2149
  "input"
2138
2150
  );
2139
- return { ...passThrough, messages: result };
2140
- } else if (result && "messages" in result && "systemMessages" in result) {
2141
- const typedResult = result;
2151
+ return { ...passThrough, messages: result2 };
2152
+ } else if (result2 && "messages" in result2 && "systemMessages" in result2) {
2153
+ const typedResult = result2;
2142
2154
  processors.ProcessorRunner.applyMessagesToMessageList(
2143
2155
  typedResult.messages,
2144
2156
  passThrough.messageList,
@@ -2169,7 +2181,7 @@ function createStepFromProcessor(processor) {
2169
2181
  }
2170
2182
  const idsBeforeProcessing = messages.map((m) => m.id);
2171
2183
  const check = passThrough.messageList.makeMessageSourceChecker();
2172
- const result = await processor.processInputStep({
2184
+ const result2 = await processor.processInputStep({
2173
2185
  ...baseContext,
2174
2186
  messages,
2175
2187
  messageList: passThrough.messageList,
@@ -2186,7 +2198,7 @@ function createStepFromProcessor(processor) {
2186
2198
  steps: steps ?? [],
2187
2199
  state: {}
2188
2200
  });
2189
- const validatedResult = await processors.ProcessorRunner.validateAndFormatProcessInputStepResult(result, {
2201
+ const validatedResult = await processors.ProcessorRunner.validateAndFormatProcessInputStepResult(result2, {
2190
2202
  messageList: passThrough.messageList,
2191
2203
  processor,
2192
2204
  stepNumber: stepNumber ?? 0
@@ -2234,9 +2246,9 @@ function createStepFromProcessor(processor) {
2234
2246
  };
2235
2247
  }
2236
2248
  const processorTracingContext2 = processorSpan2 ? { currentSpan: processorSpan2 } : baseContext.tracingContext;
2237
- let result;
2249
+ let result2;
2238
2250
  try {
2239
- result = await processor.processOutputStream({
2251
+ result2 = await processor.processOutputStream({
2240
2252
  ...baseContext,
2241
2253
  tracingContext: processorTracingContext2,
2242
2254
  part,
@@ -2246,7 +2258,7 @@ function createStepFromProcessor(processor) {
2246
2258
  // Optional for stream processing
2247
2259
  });
2248
2260
  if (part && part.type === "finish") {
2249
- processorSpan2?.end({ output: result });
2261
+ processorSpan2?.end({ output: result2 });
2250
2262
  delete mutableState[spanKey];
2251
2263
  }
2252
2264
  } catch (error) {
@@ -2258,7 +2270,7 @@ function createStepFromProcessor(processor) {
2258
2270
  delete mutableState[spanKey];
2259
2271
  throw error;
2260
2272
  }
2261
- return { ...passThrough, state: mutableState, part: result };
2273
+ return { ...passThrough, state: mutableState, part: result2 };
2262
2274
  }
2263
2275
  return { ...passThrough, part };
2264
2276
  }
@@ -2274,14 +2286,21 @@ function createStepFromProcessor(processor) {
2274
2286
  }
2275
2287
  const idsBeforeProcessing = messages.map((m) => m.id);
2276
2288
  const check = passThrough.messageList.makeMessageSourceChecker();
2277
- const result = await processor.processOutputResult({
2289
+ const outputResult = passThrough.result ?? {
2290
+ text: "",
2291
+ usage: { inputTokens: 0, outputTokens: 0, totalTokens: 0 },
2292
+ finishReason: "unknown",
2293
+ steps: []
2294
+ };
2295
+ const processResult = await processor.processOutputResult({
2278
2296
  ...baseContext,
2279
2297
  messages,
2280
2298
  messageList: passThrough.messageList,
2281
- state: {}
2299
+ state: passThrough.state ?? {},
2300
+ result: outputResult
2282
2301
  });
2283
- if (result instanceof agent.MessageList) {
2284
- if (result !== passThrough.messageList) {
2302
+ if (processResult instanceof agent.MessageList) {
2303
+ if (processResult !== passThrough.messageList) {
2285
2304
  throw new error.MastraError({
2286
2305
  category: error.ErrorCategory.USER,
2287
2306
  domain: error.ErrorDomain.MASTRA_WORKFLOW,
@@ -2291,20 +2310,20 @@ function createStepFromProcessor(processor) {
2291
2310
  }
2292
2311
  return {
2293
2312
  ...passThrough,
2294
- messages: result.get.all.db(),
2295
- systemMessages: result.getAllSystemMessages()
2313
+ messages: processResult.get.all.db(),
2314
+ systemMessages: processResult.getAllSystemMessages()
2296
2315
  };
2297
- } else if (Array.isArray(result)) {
2316
+ } else if (Array.isArray(processResult)) {
2298
2317
  processors.ProcessorRunner.applyMessagesToMessageList(
2299
- result,
2318
+ processResult,
2300
2319
  passThrough.messageList,
2301
2320
  idsBeforeProcessing,
2302
2321
  check,
2303
2322
  "response"
2304
2323
  );
2305
- return { ...passThrough, messages: result };
2306
- } else if (result && "messages" in result && "systemMessages" in result) {
2307
- const typedResult = result;
2324
+ return { ...passThrough, messages: processResult };
2325
+ } else if (processResult && "messages" in processResult && "systemMessages" in processResult) {
2326
+ const typedResult = processResult;
2308
2327
  processors.ProcessorRunner.applyMessagesToMessageList(
2309
2328
  typedResult.messages,
2310
2329
  passThrough.messageList,
@@ -2335,7 +2354,7 @@ function createStepFromProcessor(processor) {
2335
2354
  }
2336
2355
  const idsBeforeProcessing = messages.map((m) => m.id);
2337
2356
  const check = passThrough.messageList.makeMessageSourceChecker();
2338
- const result = await processor.processOutputStep({
2357
+ const result2 = await processor.processOutputStep({
2339
2358
  ...baseContext,
2340
2359
  messages,
2341
2360
  messageList: passThrough.messageList,
@@ -2347,8 +2366,8 @@ function createStepFromProcessor(processor) {
2347
2366
  steps: steps ?? [],
2348
2367
  state: {}
2349
2368
  });
2350
- if (result instanceof agent.MessageList) {
2351
- if (result !== passThrough.messageList) {
2369
+ if (result2 instanceof agent.MessageList) {
2370
+ if (result2 !== passThrough.messageList) {
2352
2371
  throw new error.MastraError({
2353
2372
  category: error.ErrorCategory.USER,
2354
2373
  domain: error.ErrorDomain.MASTRA_WORKFLOW,
@@ -2358,20 +2377,20 @@ function createStepFromProcessor(processor) {
2358
2377
  }
2359
2378
  return {
2360
2379
  ...passThrough,
2361
- messages: result.get.all.db(),
2362
- systemMessages: result.getAllSystemMessages()
2380
+ messages: result2.get.all.db(),
2381
+ systemMessages: result2.getAllSystemMessages()
2363
2382
  };
2364
- } else if (Array.isArray(result)) {
2383
+ } else if (Array.isArray(result2)) {
2365
2384
  processors.ProcessorRunner.applyMessagesToMessageList(
2366
- result,
2385
+ result2,
2367
2386
  passThrough.messageList,
2368
2387
  idsBeforeProcessing,
2369
2388
  check,
2370
2389
  "response"
2371
2390
  );
2372
- return { ...passThrough, messages: result };
2373
- } else if (result && "messages" in result && "systemMessages" in result) {
2374
- const typedResult = result;
2391
+ return { ...passThrough, messages: result2 };
2392
+ } else if (result2 && "messages" in result2 && "systemMessages" in result2) {
2393
+ const typedResult = result2;
2375
2394
  processors.ProcessorRunner.applyMessagesToMessageList(
2376
2395
  typedResult.messages,
2377
2396
  passThrough.messageList,