inngest 4.7.0 → 4.8.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 (130) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/components/DeferredFunction.cjs +52 -0
  3. package/components/DeferredFunction.cjs.map +1 -1
  4. package/components/DeferredFunction.d.cts +35 -9
  5. package/components/DeferredFunction.d.cts.map +1 -1
  6. package/components/DeferredFunction.d.ts +35 -9
  7. package/components/DeferredFunction.d.ts.map +1 -1
  8. package/components/DeferredFunction.js +53 -1
  9. package/components/DeferredFunction.js.map +1 -1
  10. package/components/Inngest.cjs +24 -1
  11. package/components/Inngest.cjs.map +1 -1
  12. package/components/Inngest.d.cts +23 -3
  13. package/components/Inngest.d.cts.map +1 -1
  14. package/components/Inngest.d.ts +23 -3
  15. package/components/Inngest.d.ts.map +1 -1
  16. package/components/Inngest.js +24 -1
  17. package/components/Inngest.js.map +1 -1
  18. package/components/InngestCommHandler.d.cts +2 -2
  19. package/components/InngestCommHandler.d.ts +2 -2
  20. package/components/InngestFunction.d.cts +2 -2
  21. package/components/InngestFunction.d.ts +2 -2
  22. package/components/InngestGroupTools.cjs +7 -4
  23. package/components/InngestGroupTools.cjs.map +1 -1
  24. package/components/InngestGroupTools.d.cts +5 -24
  25. package/components/InngestGroupTools.d.cts.map +1 -1
  26. package/components/InngestGroupTools.d.ts +5 -24
  27. package/components/InngestGroupTools.d.ts.map +1 -1
  28. package/components/InngestGroupTools.js +7 -4
  29. package/components/InngestGroupTools.js.map +1 -1
  30. package/components/InngestMetadata.cjs +18 -4
  31. package/components/InngestMetadata.cjs.map +1 -1
  32. package/components/InngestMetadata.d.cts +2 -2
  33. package/components/InngestMetadata.d.cts.map +1 -1
  34. package/components/InngestMetadata.d.ts +2 -2
  35. package/components/InngestMetadata.d.ts.map +1 -1
  36. package/components/InngestMetadata.js +18 -5
  37. package/components/InngestMetadata.js.map +1 -1
  38. package/components/InngestScore.cjs +93 -0
  39. package/components/InngestScore.cjs.map +1 -0
  40. package/components/InngestScore.d.cts +89 -0
  41. package/components/InngestScore.d.cts.map +1 -0
  42. package/components/InngestScore.d.ts +89 -0
  43. package/components/InngestScore.d.ts.map +1 -0
  44. package/components/InngestScore.js +88 -0
  45. package/components/InngestScore.js.map +1 -0
  46. package/components/InngestStepTools.cjs +9 -0
  47. package/components/InngestStepTools.cjs.map +1 -1
  48. package/components/InngestStepTools.d.cts +5 -3
  49. package/components/InngestStepTools.d.cts.map +1 -1
  50. package/components/InngestStepTools.d.ts +5 -3
  51. package/components/InngestStepTools.d.ts.map +1 -1
  52. package/components/InngestStepTools.js +9 -0
  53. package/components/InngestStepTools.js.map +1 -1
  54. package/components/ScoreFunction.cjs +37 -0
  55. package/components/ScoreFunction.cjs.map +1 -0
  56. package/components/ScoreFunction.d.cts +24 -0
  57. package/components/ScoreFunction.d.cts.map +1 -0
  58. package/components/ScoreFunction.d.ts +24 -0
  59. package/components/ScoreFunction.d.ts.map +1 -0
  60. package/components/ScoreFunction.js +37 -0
  61. package/components/ScoreFunction.js.map +1 -0
  62. package/components/execution/InngestExecution.d.cts +2 -2
  63. package/components/execution/InngestExecution.d.ts +2 -2
  64. package/components/execution/als.cjs.map +1 -1
  65. package/components/execution/als.d.cts +1 -0
  66. package/components/execution/als.d.cts.map +1 -1
  67. package/components/execution/als.d.ts +1 -0
  68. package/components/execution/als.d.ts.map +1 -1
  69. package/components/execution/als.js.map +1 -1
  70. package/components/execution/engine.cjs +12 -10
  71. package/components/execution/engine.cjs.map +1 -1
  72. package/components/execution/engine.d.cts +1 -1
  73. package/components/execution/engine.d.cts.map +1 -1
  74. package/components/execution/engine.d.ts +1 -1
  75. package/components/execution/engine.d.ts.map +1 -1
  76. package/components/execution/engine.js +13 -11
  77. package/components/execution/engine.js.map +1 -1
  78. package/components/execution/otel/middleware.cjs +3 -1
  79. package/components/execution/otel/middleware.cjs.map +1 -1
  80. package/components/execution/otel/middleware.d.cts +14 -7
  81. package/components/execution/otel/middleware.d.cts.map +1 -1
  82. package/components/execution/otel/middleware.d.ts +14 -7
  83. package/components/execution/otel/middleware.d.ts.map +1 -1
  84. package/components/execution/otel/middleware.js +4 -2
  85. package/components/execution/otel/middleware.js.map +1 -1
  86. package/components/execution/otel/util.cjs +9 -1
  87. package/components/execution/otel/util.cjs.map +1 -1
  88. package/components/execution/otel/util.js +9 -2
  89. package/components/execution/otel/util.js.map +1 -1
  90. package/components/realtime/types.d.cts +4 -4
  91. package/components/realtime/types.d.cts.map +1 -1
  92. package/components/realtime/types.d.ts +4 -4
  93. package/components/realtime/types.d.ts.map +1 -1
  94. package/experimental.cjs +5 -1
  95. package/experimental.d.cts +4 -1
  96. package/experimental.d.ts +4 -1
  97. package/experimental.js +3 -1
  98. package/helpers/consts.cjs +7 -0
  99. package/helpers/consts.cjs.map +1 -1
  100. package/helpers/consts.d.cts.map +1 -1
  101. package/helpers/consts.d.ts.map +1 -1
  102. package/helpers/consts.js +7 -1
  103. package/helpers/consts.js.map +1 -1
  104. package/helpers/errors.cjs +16 -0
  105. package/helpers/errors.cjs.map +1 -1
  106. package/helpers/errors.d.cts +12 -1
  107. package/helpers/errors.d.cts.map +1 -1
  108. package/helpers/errors.d.ts +12 -1
  109. package/helpers/errors.d.ts.map +1 -1
  110. package/helpers/errors.js +16 -1
  111. package/helpers/errors.js.map +1 -1
  112. package/helpers/types.cjs +4 -0
  113. package/helpers/types.cjs.map +1 -1
  114. package/helpers/types.js +4 -1
  115. package/helpers/types.js.map +1 -1
  116. package/index.d.cts +2 -2
  117. package/index.d.ts +2 -2
  118. package/package.json +1 -1
  119. package/types.cjs.map +1 -1
  120. package/types.d.cts +26 -5
  121. package/types.d.cts.map +1 -1
  122. package/types.d.ts +26 -5
  123. package/types.d.ts.map +1 -1
  124. package/types.js.map +1 -1
  125. package/version.cjs +1 -1
  126. package/version.cjs.map +1 -1
  127. package/version.d.cts +1 -1
  128. package/version.d.ts +1 -1
  129. package/version.js +1 -1
  130. package/version.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"als.d.cts","names":[],"sources":["../../../src/components/execution/als.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAQA;AAA6B,UAAZ,YAAA,CAAY;;;;;;;EAmJhB,GAAA,EA5IN,OAAA,CAAQ,IA8Id;EAAA;;;;;;;;cApIa;;;;;SAML,OAAA,CAAQ;;;;;;oBAOG;;;;;;;;;;;;aAYP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyGA,mBAAwB,QAAQ"}
1
+ {"version":3,"file":"als.d.cts","names":[],"sources":["../../../src/components/execution/als.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAQA;AAA6B,UAAZ,YAAA,CAAY;;;;;;;EAsJhB,GAAA,EA/IN,OAAA,CAAQ,IAiJd;EAAA;;;;;;;;cAvIa;;;;;SAML,OAAA,CAAQ;;;;;;oBAOG;;;;;;;;;;;;;aAeP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyGA,mBAAwB,QAAQ"}
@@ -37,6 +37,7 @@ interface AsyncContext {
37
37
  */
38
38
  executingStep?: StepOptions & {
39
39
  hashedId?: string;
40
+ userlandId?: string;
40
41
  };
41
42
  /**
42
43
  * If present, indicates the parallel mode that should be applied to steps
@@ -1 +1 @@
1
- {"version":3,"file":"als.d.ts","names":[],"sources":["../../../src/components/execution/als.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAQA;AAA6B,UAAZ,YAAA,CAAY;;;;;;;EAmJhB,GAAA,EA5IN,OAAA,CAAQ,IA8Id;EAAA;;;;;;;;cApIa;;;;;SAML,OAAA,CAAQ;;;;;;oBAOG;;;;;;;;;;;;aAYP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyGA,mBAAwB,QAAQ"}
1
+ {"version":3,"file":"als.d.ts","names":[],"sources":["../../../src/components/execution/als.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAQA;AAA6B,UAAZ,YAAA,CAAY;;;;;;;EAsJhB,GAAA,EA/IN,OAAA,CAAQ,IAiJd;EAAA;;;;;;;;cAvIa;;;;;SAML,OAAA,CAAQ;;;;;;oBAOG;;;;;;;;;;;;;aAeP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyGA,mBAAwB,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"als.js","names":["fallback: AsyncLocalStorageIsh"],"sources":["../../../src/components/execution/als.ts"],"sourcesContent":["import type { Context, StepOptions } from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { Stream } from \"../StreamTools.ts\";\nimport type { IInngestExecution } from \"./InngestExecution.ts\";\n\n/**\n * Note - this structure can be used by other libraries, so cannot have breaking changes.\n */\nexport interface AsyncContext {\n /**\n * The Inngest App that is currently being used to execute the function.\n *\n * If this is defined, we are in the context of an Inngest function execution,\n * or a possible one.\n */\n app: Inngest.Like;\n\n /**\n * Details of the current function execution context. If this doesn't exist,\n * then we're not currently in a function execution context.\n */\n execution?: {\n /**\n * The execution instance that is currently running the function.\n */\n instance: IInngestExecution;\n\n /**\n * The `ctx` object that has been passed in to this function execution,\n * including values such as `step` and `event`.\n */\n ctx: Context.Any;\n\n /**\n * If present, this indicates we are currently executing a `step.run()` step's\n * callback. Useful to understand whether we are in the context of a step\n * execution or within the main function body.\n */\n executingStep?: StepOptions & { hashedId?: string };\n\n /**\n * If present, indicates the parallel mode that should be applied to steps\n * created within this context. Set by `group.parallel()`.\n */\n parallelMode?: \"race\";\n\n /**\n * The stream tools instance for this execution context. Used by the\n * `stream` singleton to push/pipe SSE data to the client.\n */\n stream?: Stream;\n\n /**\n * If present, indicates the variant callback is executing within an\n * experiment. Set by `group.experiment()`. Any `step.*()` call within\n * this context will include these fields in `OutgoingOp.opts`.\n */\n experimentContext?: {\n experimentStepID: string;\n experimentName: string;\n variant: string;\n selectionStrategy: string;\n };\n\n /**\n * A mutable tracker used to detect whether any step tool was invoked\n * during a variant callback. Set by `group.experiment()`, flipped by\n * `createTool` in `InngestStepTools.ts`.\n */\n experimentStepTracker?: { found: boolean };\n\n /**\n * If true, we are inside the `select()` callback of\n * `group.experiment()`. Any `step.*()` call here would create a\n * nested step, which is not allowed.\n */\n insideExperimentSelect?: boolean;\n };\n}\n\n/**\n * A local-only symbol used as a key in global state to store the async local\n * storage instance.\n */\nconst alsSymbol = Symbol.for(\"inngest:als\");\n\n/**\n * Cache structure that stores both the promise and resolved ALS instance.\n * This allows synchronous access after initialization.\n */\ntype ALSCache = {\n promise: Promise<AsyncLocalStorageIsh>;\n resolved?: AsyncLocalStorageIsh;\n isFallback?: boolean;\n};\n\n/**\n * A type that represents a partial, runtime-agnostic interface of\n * `AsyncLocalStorage`.\n */\ntype AsyncLocalStorageIsh = {\n getStore: () => AsyncContext | undefined;\n run: <R>(store: AsyncContext, fn: () => R) => R;\n};\n\nconst getCache = (): ALSCache => {\n const g = globalThis as Record<symbol, ALSCache | undefined>;\n\n if (!g[alsSymbol]) {\n g[alsSymbol] = createCache();\n }\n\n return g[alsSymbol];\n};\n\nconst createCache = (): ALSCache => {\n const cache = {} as ALSCache;\n cache.promise = initializeALS(cache);\n return cache;\n};\n\nconst initializeALS = async (\n cache: ALSCache,\n): Promise<AsyncLocalStorageIsh> => {\n try {\n const { AsyncLocalStorage } = await import(\"node:async_hooks\");\n const als = new AsyncLocalStorage<AsyncContext>();\n cache.resolved = als;\n cache.isFallback = false;\n return als;\n } catch {\n const fallback: AsyncLocalStorageIsh = {\n getStore: () => undefined,\n run: (_, fn) => fn(),\n };\n cache.resolved = fallback;\n cache.isFallback = true;\n console.warn(\n \"node:async_hooks is not supported in this runtime. Async context is disabled.\",\n );\n return fallback;\n }\n};\n\n/**\n * Check if AsyncLocalStorage is unavailable and we're using the fallback.\n * Returns `undefined` if ALS hasn't been initialized yet.\n */\nexport const isALSFallback = (): boolean | undefined => {\n return getCache().isFallback;\n};\n\n/**\n * Retrieve the async context for the current execution.\n */\nexport const getAsyncCtx = async (): Promise<AsyncContext | undefined> => {\n return getAsyncLocalStorage().then((als) => als.getStore());\n};\n\n/**\n * Retrieve the async context for the current execution synchronously.\n * Returns undefined if ALS hasn't been initialized yet.\n */\nexport const getAsyncCtxSync = (): AsyncContext | undefined => {\n return getCache().resolved?.getStore();\n};\n\n/**\n * Get a singleton instance of `AsyncLocalStorage` used to store and retrieve\n * async context for the current execution.\n */\nexport const getAsyncLocalStorage = async (): Promise<AsyncLocalStorageIsh> => {\n return getCache().promise;\n};\n"],"mappings":";;;;;AAoFA,MAAM,YAAY,OAAO,IAAI,cAAc;AAqB3C,MAAM,iBAA2B;CAC/B,MAAM,IAAI;AAEV,KAAI,CAAC,EAAE,WACL,GAAE,aAAa,aAAa;AAG9B,QAAO,EAAE;;AAGX,MAAM,oBAA8B;CAClC,MAAM,QAAQ,EAAE;AAChB,OAAM,UAAU,cAAc,MAAM;AACpC,QAAO;;AAGT,MAAM,gBAAgB,OACpB,UACkC;AAClC,KAAI;EACF,MAAM,EAAE,sBAAsB,MAAM,OAAO;EAC3C,MAAM,MAAM,IAAI,mBAAiC;AACjD,QAAM,WAAW;AACjB,QAAM,aAAa;AACnB,SAAO;SACD;EACN,MAAMA,WAAiC;GACrC,gBAAgB;GAChB,MAAM,GAAG,OAAO,IAAI;GACrB;AACD,QAAM,WAAW;AACjB,QAAM,aAAa;AACnB,UAAQ,KACN,gFACD;AACD,SAAO;;;;;;;AAQX,MAAa,sBAA2C;AACtD,QAAO,UAAU,CAAC;;;;;AAMpB,MAAa,cAAc,YAA+C;AACxE,QAAO,sBAAsB,CAAC,MAAM,QAAQ,IAAI,UAAU,CAAC;;;;;;AAO7D,MAAa,wBAAkD;AAC7D,QAAO,UAAU,CAAC,UAAU,UAAU;;;;;;AAOxC,MAAa,uBAAuB,YAA2C;AAC7E,QAAO,UAAU,CAAC"}
1
+ {"version":3,"file":"als.js","names":["fallback: AsyncLocalStorageIsh"],"sources":["../../../src/components/execution/als.ts"],"sourcesContent":["import type { Context, StepOptions } from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { Stream } from \"../StreamTools.ts\";\nimport type { IInngestExecution } from \"./InngestExecution.ts\";\n\n/**\n * Note - this structure can be used by other libraries, so cannot have breaking changes.\n */\nexport interface AsyncContext {\n /**\n * The Inngest App that is currently being used to execute the function.\n *\n * If this is defined, we are in the context of an Inngest function execution,\n * or a possible one.\n */\n app: Inngest.Like;\n\n /**\n * Details of the current function execution context. If this doesn't exist,\n * then we're not currently in a function execution context.\n */\n execution?: {\n /**\n * The execution instance that is currently running the function.\n */\n instance: IInngestExecution;\n\n /**\n * The `ctx` object that has been passed in to this function execution,\n * including values such as `step` and `event`.\n */\n ctx: Context.Any;\n\n /**\n * If present, this indicates we are currently executing a `step.run()` step's\n * callback. Useful to understand whether we are in the context of a step\n * execution or within the main function body.\n */\n executingStep?: StepOptions & {\n hashedId?: string;\n userlandId?: string;\n };\n\n /**\n * If present, indicates the parallel mode that should be applied to steps\n * created within this context. Set by `group.parallel()`.\n */\n parallelMode?: \"race\";\n\n /**\n * The stream tools instance for this execution context. Used by the\n * `stream` singleton to push/pipe SSE data to the client.\n */\n stream?: Stream;\n\n /**\n * If present, indicates the variant callback is executing within an\n * experiment. Set by `group.experiment()`. Any `step.*()` call within\n * this context will include these fields in `OutgoingOp.opts`.\n */\n experimentContext?: {\n experimentStepID: string;\n experimentName: string;\n variant: string;\n selectionStrategy: string;\n };\n\n /**\n * A mutable tracker used to detect whether any step tool was invoked\n * during a variant callback. Set by `group.experiment()`, flipped by\n * `createTool` in `InngestStepTools.ts`.\n */\n experimentStepTracker?: { found: boolean };\n\n /**\n * If true, we are inside the `select()` callback of\n * `group.experiment()`. Any `step.*()` call here would create a\n * nested step, which is not allowed.\n */\n insideExperimentSelect?: boolean;\n };\n}\n\n/**\n * A local-only symbol used as a key in global state to store the async local\n * storage instance.\n */\nconst alsSymbol = Symbol.for(\"inngest:als\");\n\n/**\n * Cache structure that stores both the promise and resolved ALS instance.\n * This allows synchronous access after initialization.\n */\ntype ALSCache = {\n promise: Promise<AsyncLocalStorageIsh>;\n resolved?: AsyncLocalStorageIsh;\n isFallback?: boolean;\n};\n\n/**\n * A type that represents a partial, runtime-agnostic interface of\n * `AsyncLocalStorage`.\n */\ntype AsyncLocalStorageIsh = {\n getStore: () => AsyncContext | undefined;\n run: <R>(store: AsyncContext, fn: () => R) => R;\n};\n\nconst getCache = (): ALSCache => {\n const g = globalThis as Record<symbol, ALSCache | undefined>;\n\n if (!g[alsSymbol]) {\n g[alsSymbol] = createCache();\n }\n\n return g[alsSymbol];\n};\n\nconst createCache = (): ALSCache => {\n const cache = {} as ALSCache;\n cache.promise = initializeALS(cache);\n return cache;\n};\n\nconst initializeALS = async (\n cache: ALSCache,\n): Promise<AsyncLocalStorageIsh> => {\n try {\n const { AsyncLocalStorage } = await import(\"node:async_hooks\");\n const als = new AsyncLocalStorage<AsyncContext>();\n cache.resolved = als;\n cache.isFallback = false;\n return als;\n } catch {\n const fallback: AsyncLocalStorageIsh = {\n getStore: () => undefined,\n run: (_, fn) => fn(),\n };\n cache.resolved = fallback;\n cache.isFallback = true;\n console.warn(\n \"node:async_hooks is not supported in this runtime. Async context is disabled.\",\n );\n return fallback;\n }\n};\n\n/**\n * Check if AsyncLocalStorage is unavailable and we're using the fallback.\n * Returns `undefined` if ALS hasn't been initialized yet.\n */\nexport const isALSFallback = (): boolean | undefined => {\n return getCache().isFallback;\n};\n\n/**\n * Retrieve the async context for the current execution.\n */\nexport const getAsyncCtx = async (): Promise<AsyncContext | undefined> => {\n return getAsyncLocalStorage().then((als) => als.getStore());\n};\n\n/**\n * Retrieve the async context for the current execution synchronously.\n * Returns undefined if ALS hasn't been initialized yet.\n */\nexport const getAsyncCtxSync = (): AsyncContext | undefined => {\n return getCache().resolved?.getStore();\n};\n\n/**\n * Get a singleton instance of `AsyncLocalStorage` used to store and retrieve\n * async context for the current execution.\n */\nexport const getAsyncLocalStorage = async (): Promise<AsyncLocalStorageIsh> => {\n return getCache().promise;\n};\n"],"mappings":";;;;;AAuFA,MAAM,YAAY,OAAO,IAAI,cAAc;AAqB3C,MAAM,iBAA2B;CAC/B,MAAM,IAAI;AAEV,KAAI,CAAC,EAAE,WACL,GAAE,aAAa,aAAa;AAG9B,QAAO,EAAE;;AAGX,MAAM,oBAA8B;CAClC,MAAM,QAAQ,EAAE;AAChB,OAAM,UAAU,cAAc,MAAM;AACpC,QAAO;;AAGT,MAAM,gBAAgB,OACpB,UACkC;AAClC,KAAI;EACF,MAAM,EAAE,sBAAsB,MAAM,OAAO;EAC3C,MAAM,MAAM,IAAI,mBAAiC;AACjD,QAAM,WAAW;AACjB,QAAM,aAAa;AACnB,SAAO;SACD;EACN,MAAMA,WAAiC;GACrC,gBAAgB;GAChB,MAAM,GAAG,OAAO,IAAI;GACrB;AACD,QAAM,WAAW;AACjB,QAAM,aAAa;AACnB,UAAQ,KACN,gFACD;AACD,SAAO;;;;;;;AAQX,MAAa,sBAA2C;AACtD,QAAO,UAAU,CAAC;;;;;AAMpB,MAAa,cAAc,YAA+C;AACxE,QAAO,sBAAsB,CAAC,MAAM,QAAQ,IAAI,UAAU,CAAC;;;;;;AAO7D,MAAa,wBAAkD;AAC7D,QAAO,UAAU,CAAC,UAAU,UAAU;;;;;;AAOxC,MAAa,uBAAuB,YAA2C;AAC7E,QAAO,UAAU,CAAC"}
@@ -194,7 +194,7 @@ var InngestExecutionEngine = class extends require_InngestExecution.InngestExecu
194
194
  traceparent: this.options.headers[require_consts.headerKeys.TraceParent],
195
195
  tracestate: this.options.headers[require_consts.headerKeys.TraceState]
196
196
  });
197
- require_metadataProcessor.metadataSpanProcessor.declareStartingSpan({
197
+ if (this.options.client.aiMetadataEnabled) require_metadataProcessor.metadataSpanProcessor.declareStartingSpan({
198
198
  span,
199
199
  traceparent: this.options.headers[require_consts.headerKeys.TraceParent],
200
200
  onAIMetadata: (aiMetadata) => {
@@ -912,7 +912,8 @@ var InngestExecutionEngine = class extends require_InngestExecution.InngestExecu
912
912
  if (store?.execution) store.execution.executingStep = {
913
913
  id,
914
914
  name: displayName,
915
- hashedId
915
+ hashedId,
916
+ userlandId: userland.id
916
917
  };
917
918
  this.devDebug(`executing step "${id}"`);
918
919
  if (this.rootSpanId && this.options.checkpointingConfig) require_access.clientProcessorMap.get(this.options.client)?.declareStepExecution(this.rootSpanId, userland.id ?? "", userland.index ?? 0, hashedId, this.options.data?.attempt ?? 0);
@@ -1045,8 +1046,10 @@ var InngestExecutionEngine = class extends require_InngestExecution.InngestExecu
1045
1046
  })), triggers);
1046
1047
  }
1047
1048
  /**
1048
- * Validate the deferred event's data against the defer function's own
1049
- * schema (set via `createDefer`'s `opts.schema`).
1049
+ * Validate the deferred event's data against the defer function's own schema
1050
+ * (set via `createDefer`'s `opts.schema`). Our internal metadata
1051
+ * (`event.data._inngest`) was already stripped, so that won't affect
1052
+ * validation.
1050
1053
  */
1051
1054
  async validateDeferEventSchema() {
1052
1055
  const fn = this.options.fn;
@@ -1189,10 +1192,6 @@ var InngestExecutionEngine = class extends require_InngestExecution.InngestExecu
1189
1192
  group: require_InngestGroupTools.createGroupTools({ experimentStepRun }),
1190
1193
  defer
1191
1194
  };
1192
- if (this.options.handlerKind === "defer") {
1193
- delete fnArg.event.data._inngest;
1194
- for (const event of fnArg.events) delete event.data._inngest;
1195
- }
1196
1195
  /**
1197
1196
  * Handle use of the `onFailure` option by deserializing the error.
1198
1197
  */
@@ -1486,7 +1485,7 @@ var InngestExecutionEngine = class extends require_InngestExecution.InngestExecu
1486
1485
  * schema mismatch) are logged and the call is silently skipped.
1487
1486
  */
1488
1487
  buildDefer(stepHandler) {
1489
- return (idOrOptions, { function: deferFn, data }) => {
1488
+ return (idOrOptions, { function: deferFn, data, experiment }) => {
1490
1489
  const log = this.options.client[require_Inngest.internalLoggerSymbol];
1491
1490
  const runId = this.fnArg.runId;
1492
1491
  try {
@@ -1513,7 +1512,10 @@ var InngestExecutionEngine = class extends require_InngestExecution.InngestExecu
1513
1512
  input = result.value ?? data;
1514
1513
  }
1515
1514
  stepHandler({
1516
- args: [idOrOptions, input],
1515
+ args: [idOrOptions, experiment && require_types$1.isRecord(input) ? {
1516
+ ...input,
1517
+ [require_consts.deferExperimentKey]: experiment
1518
+ } : input],
1517
1519
  matchOp: (stepOptions, inputArg) => ({
1518
1520
  id: stepOptions.id,
1519
1521
  mode: require_types.StepMode.Sync,