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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AA,CAAQ;KAexC,qBAAA,GAAwB,aAAa,OAAA,CAAQ;GACtD,cAAA,8BAA4C;GAC5C,WAAA,GAAc;;;;;;;;;;;;;cAuBJ,MAAM;;;;;;cAwFN,OAAO;KAqBf,uCAAuC;YAChC;;KAGP,iCAAiC,kCACpC,qBAAqB,aACnB,KAAK,yBAAyB;;;;;;;;SAQrB;;;;;;;;;;;;;;;;8BAoBH,OACA,eACA,cACA;;;;;KAML,cAAA;;;;;;;;;;;;;KAeA,iBAAA;;;;;;;;;;;;;;;;;6BAqBC,OACA,eACA,cACA;;;;;;;;;;;;;;;;;;;;;;KAwBD,4BAEH;SACS,sCAEL,qCAAqC;;QAI7B;QACA;;;;SAIC;WAGT;SACW;;QAGD;QAEA;;;;SAIC;WAGT;;UAEY,qCACc;;QAIhB;QACA;;;;SAIC;WAGT;;;QAEU;QAEA;;;;SAIC;WAET;;;;KAKP,2BAA2B;;;;;;;;;;;;;;;;;;;SAmBvB;;;;QAKD,SAAA,CAAU,MAAM"}
@@ -1,13 +1,14 @@
1
1
  import { InngestApi } from "../api/api.js";
2
2
  import { ExclusiveKeys, ParametersExceptFirst, SendEventPayload } from "../helpers/types.js";
3
- import { StepFetch } from "./Fetch.js";
4
3
  import { Jsonify } from "../helpers/jsonify.js";
4
+ import { StepFetch } from "./Fetch.js";
5
5
  import { DurationLike, InstantLike, ZonedDateTimeLike } from "../helpers/temporal.js";
6
6
  import { GroupTools } from "./InngestGroupTools.js";
7
- import { Middleware } from "./middleware/middleware.js";
7
+ import { MetadataStepTool, metadataSymbol } from "./InngestMetadata.js";
8
+ import { ScoreStepTool, scoreSymbol } from "./InngestScore.js";
8
9
  import { Realtime } from "./realtime/types.js";
9
10
  import { EventType } from "./triggers/triggers.js";
10
- import { MetadataStepTool, metadataSymbol } from "./InngestMetadata.js";
11
+ import { Middleware } from "./middleware/middleware.js";
11
12
  import { InngestExecution } from "./execution/InngestExecution.js";
12
13
  import { ApplyAllMiddlewareTransforms, Context, EventMeta, EventPayload, HashedOp, InvocationResult, InvokeTargetFunctionDefinition, OutgoingOp, ReceivedEventMeta, SendEventOutput, StepOptions, StepOptionsOrId, TriggerEventFromFunction } from "../types.js";
13
14
  import { ClientOptionsFromInngest, GetFunctionOutputRaw, GetStepTools, Inngest } from "./Inngest.js";
@@ -329,6 +330,7 @@ declare const createStepTools: <TClient extends Inngest.Any, TFnMiddleware exten
329
330
  type GenericStepTools = GetStepTools<Inngest.Any>;
330
331
  type ExperimentalStepTools = GetStepTools<Inngest.Any> & {
331
332
  [metadataSymbol]: (memoizationId: string) => MetadataStepTool;
333
+ [scoreSymbol]: ScoreStepTool;
332
334
  };
333
335
  /**
334
336
  * A generic set of step tools that can be used without typing information about
@@ -1 +1 @@
1
- {"version":3,"file":"InngestStepTools.d.ts","names":[],"sources":["../../src/components/InngestStepTools.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiEA;;;;;;AAsBiB,UAtBA,qBAAA,CAsBU;EAAA;;;;;;EAAgB,gBAAA,EAAA,CAAA,OAAA,EAAA,GAAA,GAfP,OAeO,CAAA,OAAA,CAAA,EAAA,GAAA,IAAA;EA+E/B;;;;UAKG,EA7FH,UAAA,CAAW,QA6FR;;;;;EAKN,cAAA,EAAA,GAAA,GA5Fe,OA4Ff,CAAA,OAAA,CAAA;AAET;AAAuB,UA3FN,SAAA,SAAkB,QA2FZ,CAAA;UACZ,EAAA,MAAA;KACF,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,OAAA;SACA,EAAA,OAAA,EAAA;;;AAGT;;;;;;;EAsB4C,SAAA,EAAA,OAAA;EA4BvC;;;;;;;;;cAOC,EAAA,OAAA;SAAsB,EAAA,OAAW;;;AAGvC;EAkwBC,OAAA,EA/3BU,OA+3BV,CAAA,OAAA,CAAA;;;;;QA5vBc,EAAA,GAAA,GAAA,OAAA;OAiNM,CAAA,EAAA,OAAA;;;;;YAEV,EAtUG,qBAsUH;;;;;;;;;;;qB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A5nBG,wBACH,0BACJ,YAAY,cAClB,QAAQ,SAAA,CAAU,OAAO;;;;;;;;;iEAnajB,qBAUT,eAOM,WAAW,SAClB,QACH,6BACE,iBAAiB,SAAS,gBAC1B,uBAAsB,WAAW,SAAS,oBACtC,QAAQ,wBAAwB,KAChC,WAAW,2BAET,WAAW;;;;;;;;;;;;;;;;;;;;;;uBAscN,yCAKW,iBACrB;;;;;;;4BA0BU,uBAKP,gBAAgB,cAAuB,sBAC1C;;;;;;6BAyCc,6CACJ,uBACP,eAAe,eAClB,iBACH,6BACE,iBAAiB,SAAS,gBAC1B,qBAAqB;;;;;;;;SAHJ;;;;;;KAwJf,gBAAA,GAAmB,aAAa,OAAA,CAAQ;KAexC,qBAAA,GAAwB,aAAa,OAAA,CAAQ;GACtD,cAAA,8BAA4C;GAC5C,WAAA,GAAc;;;;;;;;;;;;;cAuBJ,MAAM;;;;;;cAwFN,OAAO;KAqBf,uCAAuC;YAChC;;KAGP,iCAAiC,kCACpC,qBAAqB,aACnB,KAAK,yBAAyB;;;;;;;;SAQrB;;;;;;;;;;;;;;;;8BAoBH,OACA,eACA,cACA;;;;;KAML,cAAA;;;;;;;;;;;;;KAeA,iBAAA;;;;;;;;;;;;;;;;;6BAqBC,OACA,eACA,cACA;;;;;;;;;;;;;;;;;;;;;;KAwBD,4BAEH;SACS,sCAEL,qCAAqC;;QAI7B;QACA;;;;SAIC;WAGT;SACW;;QAGD;QAEA;;;;SAIC;WAGT;;UAEY,qCACc;;QAIhB;QACA;;;;SAIC;WAGT;;;QAEU;QAEA;;;;SAIC;WAET;;;;KAKP,2BAA2B;;;;;;;;;;;;;;;;;;;SAmBvB;;;;QAKD,SAAA,CAAU,MAAM"}
@@ -6,6 +6,7 @@ import { getAsyncCtx, getAsyncCtxSync } from "./execution/als.js";
6
6
  import { normalizeEventMeta } from "../helpers/sessions.js";
7
7
  import { InngestFunction } from "./InngestFunction.js";
8
8
  import { UnscopedMetadataBuilder, metadataSymbol } from "./InngestMetadata.js";
9
+ import { scoreSymbol, sendStepScore, validateStepScoreOptions } from "./InngestScore.js";
9
10
  import { fetch } from "./Fetch.js";
10
11
  import { InngestFunctionReference } from "./InngestFunctionReference.js";
11
12
  import { internalLoggerSymbol } from "./Inngest.js";
@@ -101,6 +102,13 @@ const createStepTools = (client, execution, stepHandler) => {
101
102
  }
102
103
  };
103
104
  };
105
+ const createStepScoreWrapper = async (memoizationId, options) => {
106
+ if (!client["experimentalScoreEnabled"]) throw new NonRetriableError("step.score() is experimental. Enable it by adding scoreMiddleware() from \"inngest/experimental\" to your client middleware.");
107
+ validateStepScoreOptions(options);
108
+ await tools.run(memoizationId, async () => {
109
+ await sendStepScore(client, options);
110
+ });
111
+ };
104
112
  /**
105
113
  * Define the set of tools the user has access to for their step functions.
106
114
  *
@@ -306,6 +314,7 @@ const createStepTools = (client, execution, stepHandler) => {
306
314
  fetch
307
315
  };
308
316
  tools[metadataSymbol] = (memoizationId) => createStepMetadataWrapper(memoizationId);
317
+ tools[scoreSymbol] = createStepScoreWrapper;
309
318
  tools[experimentStepRunSymbol] = createStepRun("group.experiment");
310
319
  tools[gatewaySymbol] = createTool(({ id, name }, input, init) => {
311
320
  const url = input instanceof Request ? input.url : input.toString();
@@ -1 +1 @@
1
- {"version":3,"file":"InngestStepTools.js","names":["wrappedMatchOp: MatchOpFn<T>","opts: HashedOp[\"opts\"]","matchOpts: { timeout: string; if?: string }","msTimeStr: string","Temporal.getISOString","v","Temporal.isTemporalDuration","Temporal.isTemporalInstant","Temporal.isTemporalZonedDateTime","opts: {\n payload: typeof payload;\n function_id: string;\n timeout?: string;\n }","stepFetch","headers: Record<string, string>","step: GenericStepTools","group: GroupTools"],"sources":["../../src/components/InngestStepTools.ts"],"sourcesContent":["import { type AiAdapter, models } from \"@inngest/ai\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { z } from \"zod/v3\";\n\nimport type { InngestApi } from \"../api/api.ts\";\nimport type { Jsonify } from \"../helpers/jsonify.ts\";\nimport { normalizeEventMeta } from \"../helpers/sessions.ts\";\nimport { timeStr } from \"../helpers/strings.ts\";\nimport * as Temporal from \"../helpers/temporal.ts\";\nimport type {\n ExclusiveKeys,\n ParametersExceptFirst,\n SendEventPayload,\n} from \"../helpers/types.ts\";\nimport {\n type ApplyAllMiddlewareTransforms,\n type Context,\n type EventMeta,\n type EventPayload,\n type HashedOp,\n type InvocationResult,\n type InvokeTargetFunctionDefinition,\n type MinimalEventPayload,\n type OutgoingOp,\n type ReceivedEventMeta,\n type SendEventOutput,\n StepMode,\n StepOpCode,\n type StepOptions,\n type StepOptionsOrId,\n type TriggerEventFromFunction,\n} from \"../types.ts\";\nimport { getAsyncCtx, getAsyncCtxSync } from \"./execution/als.ts\";\nimport type { InngestExecution } from \"./execution/InngestExecution.ts\";\nimport { fetch as stepFetch } from \"./Fetch.ts\";\nimport {\n type ClientOptionsFromInngest,\n type GetFunctionOutputRaw,\n type GetStepTools,\n type Inngest,\n internalLoggerSymbol,\n} from \"./Inngest.ts\";\nimport { InngestFunction } from \"./InngestFunction.ts\";\nimport { InngestFunctionReference } from \"./InngestFunctionReference.ts\";\nimport type { GroupTools } from \"./InngestGroupTools.ts\";\nimport {\n type MetadataBuilder,\n type MetadataStepTool,\n metadataSymbol,\n UnscopedMetadataBuilder,\n} from \"./InngestMetadata.ts\";\nimport type { Middleware } from \"./middleware/index.ts\";\nimport { NonRetriableError } from \"./NonRetriableError.ts\";\nimport type { Realtime } from \"./realtime/types.ts\";\nimport type { EventType } from \"./triggers/triggers.ts\";\n\n/**\n * Middleware context for a step, created during step registration.\n *\n * Uses a \"deferred handler\" pattern: the `wrapStep` middleware chain starts\n * during discovery (so middleware can inject its own steps), but the real\n * handler isn't known until after the memoization lookup. `setActualHandler`\n * bridges the gap — the chain blocks on a deferred promise that is resolved\n * once `executeStep` determines the real result.\n */\nexport interface StepMiddlewareContext {\n /**\n * Sets the handler that the middleware pipeline will eventually call.\n * Called after memoization lookup to set either:\n * - A handler returning memoized data, OR\n * - A handler executing the step fresh\n */\n setActualHandler: (handler: () => Promise<unknown>) => void;\n\n /**\n * Step info after middleware transformations. The `options.id` may differ\n * from the original if middleware modified it via `transformStepInput`.\n */\n stepInfo: Middleware.StepInfo;\n\n /**\n * The middleware pipeline entry point. Call this to execute the step\n * through all middleware transformations.\n */\n wrappedHandler: () => Promise<unknown>;\n}\n\nexport interface FoundStep extends HashedOp {\n hashedId: string;\n fn?: (...args: unknown[]) => unknown;\n rawArgs: unknown[];\n\n /**\n * A boolean representing whether the step has been fulfilled, either\n * resolving or rejecting the `Promise` returned to userland code.\n *\n * Note that this is distinct from {@link hasStepState}, which instead tracks\n * whether the step has been given some state from the Executor. State from\n * the Executor could be data other than a resolution or rejection, such as\n * inputs.\n */\n fulfilled: boolean;\n\n /**\n * A boolean representing whether the step has been given some state from the\n * Executor. State from the Executor could be data other than a resolution or\n * rejection, such as inputs.\n *\n * This is distinct from {@link fulfilled}, which instead tracks whether the\n * step has been fulfilled, either resolving or rejecting the `Promise`\n * returned to userland code.\n */\n hasStepState: boolean;\n\n handled: boolean;\n\n /**\n * The promise that has been returned to userland code for this step.\n */\n promise: Promise<unknown>;\n\n /**\n * Returns a boolean representing whether or not the step was handled on this\n * invocation.\n */\n handle: () => boolean;\n\n // TODO This is used to track the input we want for this step. Might be\n // present in ctx from Executor.\n input?: unknown;\n\n /**\n * Middleware context for this step. Holds the `wrapStep` chain entry point\n * and the deferred handler setter used by `executeStep`.\n */\n middleware: StepMiddlewareContext;\n\n /**\n * For new steps where wrappedHandler is called during discovery,\n * this holds the resolve/reject to be called when the step's data is\n * memoized. Resolved with server-transformed data (post-wrapStepHandler),\n * which unblocks wrapStep's `next()`.\n *\n * Is undefined when any of the following is true:\n * - The step is fulfilled\n * - The step has no handler (`step.sleep`, `step.waitForSignal`, etc.)\n */\n memoizationDeferred?: {\n resolve: (value: unknown) => void;\n reject: (error: unknown) => void;\n };\n\n /**\n * For new steps where `wrappedHandler` is called during discovery, this holds\n * the promise for the wrapStep-transformed result. In checkpointing mode,\n * handle() reuses this promise to avoid a duplicate wrapStep call.\n */\n transformedResultPromise?: Promise<unknown>;\n\n /**\n * Optional metadata updates attached to this step, carried through from\n * the OutgoingOp so that checkpoint payloads include metadata.\n */\n metadata?: OutgoingOp[\"metadata\"];\n}\n\nexport type MatchOpFn<\n T extends (...args: unknown[]) => Promise<unknown> = (\n ...args: unknown[]\n ) => Promise<unknown>,\n> = (\n stepOptions: StepOptions,\n /**\n * Arguments passed by the user.\n */\n ...args: ParametersExceptFirst<T>\n) => Omit<HashedOp, \"data\" | \"error\">;\n\nexport type StepHandler = (info: {\n matchOp: MatchOpFn;\n opts?: StepToolOptions;\n args: [StepOptionsOrId, ...unknown[]];\n}) => Promise<unknown>;\n\nexport interface StepToolOptions<\n T extends (...args: unknown[]) => Promise<unknown> = (\n ...args: unknown[]\n ) => Promise<unknown>,\n> {\n /**\n * Optionally, we can also provide a function that will be called when\n * Inngest tells us to run this operation.\n *\n * If this function is defined, the first time the tool is used it will\n * report the desired operation (including options) to the Inngest. Inngest\n * will then call back to the function to tell it to run the step and then\n * retrieve data.\n *\n * We do this in order to allow functionality such as per-step retries; this\n * gives the SDK the opportunity to tell Inngest what it wants to do before\n * it does it.\n *\n * This function is passed the arguments passed by the user. It will be run\n * when we receive an operation matching this one that does not contain a\n * `data` property.\n */\n fn?: (...args: [Context.Any, ...Parameters<T>]) => unknown;\n}\n\nexport const getStepOptions = (options: StepOptionsOrId): StepOptions => {\n if (typeof options === \"string\") {\n return { id: options };\n }\n\n return options;\n};\n\n/**\n * Suffix used to namespace steps that are automatically indexed.\n */\nexport const STEP_INDEXING_SUFFIX = \":\";\n\n/**\n * Create a new set of step function tools ready to be used in a step function.\n * This function should be run and a fresh set of tools provided every time a\n * function is run.\n *\n * An op stack (function state) is passed in as well as some mutable properties\n * that the tools can use to submit a new op.\n */\n/**\n * Merge client-level and function-level middleware into a single array type\n * for use with ApplyAllMiddlewareTransforms etc.\n */\ntype MergedMiddleware<\n TClient extends Inngest.Any,\n TFnMiddleware extends Middleware.Class[] | undefined,\n> = [\n ...(ClientOptionsFromInngest<TClient>[\"middleware\"] extends Middleware.Class[]\n ? ClientOptionsFromInngest<TClient>[\"middleware\"]\n : []),\n ...(TFnMiddleware extends Middleware.Class[] ? TFnMiddleware : []),\n];\n\nexport const createStepTools = <\n TClient extends Inngest.Any,\n TFnMiddleware extends Middleware.Class[] | undefined = undefined,\n>(\n client: TClient,\n execution: InngestExecution,\n stepHandler: StepHandler,\n) => {\n /**\n * A local helper used to create tools that can be used to submit an op.\n *\n * When using this function, a generic type should be provided which is the\n * function signature exposed to the user.\n */\n // biome-ignore lint/suspicious/noExplicitAny: intentional\n const createTool = <T extends (...args: any[]) => Promise<unknown>>(\n /**\n * A function that returns an ID for this op. This is used to ensure that\n * the op stack is correctly filled, submitted, and retrieved with the same\n * ID.\n *\n * It is passed the arguments passed by the user.\n *\n * Most simple tools will likely only need to define this.\n */\n matchOp: MatchOpFn<T>,\n opts?: StepToolOptions<T>,\n ): T => {\n const wrappedMatchOp: MatchOpFn<T> = (stepOptions, ...rest) => {\n const op = matchOp(stepOptions, ...rest);\n\n const alsCtx = getAsyncCtxSync()?.execution;\n\n if (alsCtx?.insideExperimentSelect) {\n throw new NonRetriableError(\n \"Step tools (step.run, step.sleep, etc.) cannot be called inside \" +\n \"an experiment select() callback. Move step calls into variant \" +\n \"callbacks instead.\",\n );\n }\n\n // Explicit option takes precedence, then check ALS context\n const parallelMode = stepOptions.parallelMode ?? alsCtx?.parallelMode;\n\n if (parallelMode) {\n op.opts = { ...op.opts, parallelMode };\n }\n\n // Propagate experiment context to variant sub-steps\n const experimentContext = alsCtx?.experimentContext;\n if (experimentContext) {\n op.opts = { ...op.opts, ...experimentContext };\n }\n\n // Track that a step tool was invoked inside a variant callback\n const tracker = alsCtx?.experimentStepTracker;\n if (tracker) {\n tracker.found = true;\n }\n\n return op;\n };\n\n return (async (...args: Parameters<T>): Promise<unknown> => {\n const parsedArgs = args as unknown as [StepOptionsOrId, ...unknown[]];\n return stepHandler({ args: parsedArgs, matchOp: wrappedMatchOp, opts });\n }) as T;\n };\n\n /**\n * Create a new step run tool that can be used to run a step function using\n * `step.run()` as a shim.\n */\n const createStepRun = (\n /**\n * The sub-type of this step tool, exposed via `opts.type` when the op is\n * reported.\n */\n type?: string,\n ) => {\n return createTool<\n // biome-ignore lint/suspicious/noExplicitAny: intentional\n <TFn extends (...args: any[]) => unknown>(\n idOrOptions: StepOptionsOrId,\n\n /**\n * The function to run when this step is executed. Can be synchronous or\n * asynchronous.\n *\n * The return value of this function will be the return value of this\n * call to `run`, meaning you can return and reason about return data\n * for next steps.\n */\n fn: TFn,\n\n /**\n * Optional input to pass to the function. If this is specified, Inngest\n * will keep track of the input for this step and be able to display it\n * in the UI.\n */\n ...input: Parameters<TFn>\n ) => Promise<\n ApplyAllMiddlewareTransforms<\n MergedMiddleware<TClient, TFnMiddleware>,\n TFn extends (...args: Parameters<TFn>) => Promise<infer U>\n ? Awaited<U extends void ? null : U>\n : ReturnType<TFn> extends void\n ? null\n : ReturnType<TFn>\n >\n >\n >(\n ({ id, name }, _fn, ...input) => {\n const opts: HashedOp[\"opts\"] = {\n ...(input.length ? { input } : {}),\n ...(type ? { type } : {}),\n };\n\n return {\n id,\n mode: StepMode.Sync,\n op: StepOpCode.StepPlanned,\n name: id,\n displayName: name ?? id,\n ...(Object.keys(opts).length ? { opts } : {}),\n userland: { id },\n };\n },\n {\n fn: (_, __, fn, ...input) => fn(...input),\n },\n );\n };\n\n /**\n * Creates a metadata builder wrapper for step.metadata(\"id\").\n * Uses MetadataBuilder for config accumulation, but wraps .update() in tools.run() for memoization.\n */\n const createStepMetadataWrapper = (\n memoizationId: string,\n builder?: UnscopedMetadataBuilder,\n ) => {\n if (!client[\"experimentalMetadataEnabled\"]) {\n throw new Error(\n 'step.metadata() is experimental. Enable it by adding metadataMiddleware() from \"inngest/experimental\" to your client middleware.',\n );\n }\n const withBuilder = (next: UnscopedMetadataBuilder) =>\n createStepMetadataWrapper(memoizationId, next);\n\n if (!builder) {\n builder = new UnscopedMetadataBuilder(client).run();\n }\n\n return {\n run: (runId?: string) => withBuilder(builder.run(runId)),\n step: (stepId: string, index?: number) =>\n withBuilder(builder.step(stepId, index)),\n attempt: (attemptIndex: number) =>\n withBuilder(builder.attempt(attemptIndex)),\n span: (spanId: string) => withBuilder(builder.span(spanId)),\n update: async (\n values: Record<string, unknown>,\n kind = \"default\",\n ): Promise<void> => {\n await tools.run(memoizationId, async () => {\n await builder.update(values, kind);\n });\n },\n\n do: async (\n fn: (builder: MetadataBuilder) => Promise<void>,\n ): Promise<void> => {\n await tools.run(memoizationId, async () => {\n await fn(builder);\n });\n },\n };\n };\n\n /**\n * Define the set of tools the user has access to for their step functions.\n *\n * Each key is the function name and is expected to run `createTool` and pass\n * a generic type for that function as it will appear in the user's code.\n */\n const tools = {\n /**\n * Send one or many events to Inngest. Should always be used in place of\n * `inngest.send()` to ensure that the event send is successfully retried\n * and not sent multiple times due to memoisation.\n *\n * @example\n * ```ts\n * await step.sendEvent(\"emit-user-creation\", {\n * name: \"app/user.created\",\n * data: { id: 123 },\n * });\n *\n * await step.sendEvent(\"emit-user-updates\", [\n * {\n * name: \"app/user.created\",\n * data: { id: 123 },\n * },\n * {\n * name: \"app/user.feed.created\",\n * data: { id: 123 },\n * },\n * ]);\n * ```\n *\n * Returns a promise that will resolve once the event has been sent.\n */\n sendEvent: createTool<\n (\n idOrOptions: StepOptionsOrId,\n payload: SendEventPayload,\n ) => Promise<SendEventOutput<ClientOptionsFromInngest<TClient>>>\n >(\n ({ id, name }) => {\n return {\n id,\n mode: StepMode.Sync,\n op: StepOpCode.StepPlanned,\n name: \"sendEvent\",\n displayName: name ?? id,\n opts: {\n type: \"step.sendEvent\",\n },\n userland: { id },\n };\n },\n {\n fn: (_ctx, _idOrOptions, payload) => {\n const fn = execution[\"options\"][\"fn\"];\n return client[\"_send\"]({\n payload,\n headers: execution[\"options\"][\"headers\"],\n fnMiddleware: fn.opts.middleware ?? [],\n fn,\n });\n },\n },\n ),\n\n /**\n * EXPERIMENTAL: This API is not yet stable and may change in the future\n * without a major version bump.\n *\n * Wait for a particular signal to be received before continuing. When the\n * signal is received, its data will be returned.\n */\n waitForSignal: createTool<\n <TData>(\n idOrOptions: StepOptionsOrId,\n opts: WaitForSignalOpts,\n ) => Promise<{ signal: string; data: Jsonify<TData> } | null>\n >(({ id, name }, opts) => {\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.WaitForSignal,\n name: opts.signal,\n displayName: name ?? id,\n opts: {\n signal: opts.signal,\n timeout: timeStr(opts.timeout),\n conflict: opts.onConflict,\n },\n userland: { id },\n };\n }),\n\n /**\n * Step-level functionality related to realtime features.\n *\n * Unlike client-level realtime methods (`inngest.realtime.*`), these tools\n * will be their own durable steps when run. If you wish to use realtime\n * features outside of a step, make sure to use the client-level methods\n * instead.\n */\n realtime: {\n /**\n * Publish a realtime message as a durable step. Memoized and will not\n * re-fire on retry, unlike client-level `inngest.realtime.publish()`.\n *\n * Uses topic accessors: `step.realtime.publish(\"id\", chat.status, data)`\n */\n publish: createTool<\n <TData>(\n idOrOptions: StepOptionsOrId,\n topicRef: Realtime.TopicRef<TData>,\n data: TData,\n ) => Promise<TData>\n >(\n ({ id, name }) => {\n return {\n id,\n mode: StepMode.Sync,\n op: StepOpCode.StepPlanned,\n displayName: name ?? id,\n opts: {\n type: \"step.realtime.publish\",\n },\n userland: { id },\n };\n },\n {\n fn: async (ctx, _idOrOptions, topicRef, data) => {\n const topicConfig = topicRef.config;\n if (topicConfig && \"schema\" in topicConfig && topicConfig.schema) {\n const result =\n await topicConfig.schema[\"~standard\"].validate(data);\n if (result.issues) {\n throw new Error(\n `Schema validation failed for topic \"${topicRef.topic}\"`,\n );\n }\n }\n\n const res = await client[\"inngestApi\"].publish(\n {\n topics: [topicRef.topic],\n channel: topicRef.channel,\n runId: ctx.runId,\n },\n data,\n );\n\n if (!res.ok) {\n throw new Error(\n `Failed to publish to realtime: ${res.error?.error || \"Unknown error\"}`,\n );\n }\n\n return data;\n },\n },\n ),\n },\n\n /**\n * Send a Signal to Inngest.\n */\n sendSignal: createTool<\n (\n idOrOptions: StepOptionsOrId,\n opts: SendSignalOpts,\n ) => Promise<InngestApi.SendSignalResponse>\n >(\n ({ id, name }, opts) => {\n return {\n id,\n mode: StepMode.Sync,\n op: StepOpCode.StepPlanned,\n name: \"sendSignal\",\n displayName: name ?? id,\n opts: {\n type: \"step.sendSignal\",\n signal: opts.signal,\n },\n userland: { id },\n };\n },\n {\n fn: (_ctx, _idOrOptions, opts) => {\n return client[\"_sendSignal\"]({\n signal: opts.signal,\n data: opts.data,\n headers: execution[\"options\"][\"headers\"],\n });\n },\n },\n ),\n\n /**\n * Wait for a particular event to be received before continuing. When the\n * event is received, it will be returned.\n *\n * You can also provide options to control the particular event that is\n * received, for example to ensure that a user ID matches between two\n * events, or to only wait a maximum amount of time before giving up and\n * returning `null` instead of any event data.\n */\n waitForEvent: createTool<\n <\n TOpts extends {\n /**\n * The event to wait for.\n */\n event:\n | string\n // biome-ignore lint/suspicious/noExplicitAny: Allow any schema\n | EventType<string, any>;\n\n /**\n * The step function will wait for the event for a maximum of this\n * time, at which point the signal will be returned as `null` instead\n * of any signal data.\n *\n * The time to wait can be specified using a `number` of milliseconds,\n * an `ms`-compatible time string like `\"1 hour\"`, `\"30 mins\"`, or\n * `\"2.5d\"`, a `Date`, a `Temporal.Duration` (relative wait), or a\n * `Temporal.Instant` / `Temporal.ZonedDateTime` (absolute deadline).\n *\n * {@link https://npm.im/ms}\n */\n timeout:\n | number\n | string\n | Date\n | Temporal.DurationLike\n | Temporal.InstantLike\n | Temporal.ZonedDateTimeLike;\n } & ExclusiveKeys<{ match?: string; if?: string }, \"match\", \"if\">,\n >(\n idOrOptions: StepOptionsOrId,\n opts: TOpts,\n ) => Promise<WaitForEventResult<TOpts>>\n >(\n (\n { id, name },\n\n /**\n * Options to control the event we're waiting for.\n */\n opts,\n ) => {\n const matchOpts: { timeout: string; if?: string } = {\n timeout: timeStr(typeof opts === \"string\" ? opts : opts.timeout),\n };\n\n if (typeof opts !== \"string\") {\n if (opts?.match) {\n matchOpts.if = `event.${opts.match} == async.${opts.match}`;\n } else if (opts?.if) {\n matchOpts.if = opts.if;\n }\n }\n\n // Extract event name from string or EventType object\n const eventName =\n typeof opts.event === \"string\" ? opts.event : opts.event.name;\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.WaitForEvent,\n name: eventName,\n opts: matchOpts,\n displayName: name ?? id,\n userland: { id },\n };\n },\n ),\n\n /**\n * Use this tool to run business logic. Each call to `run` will be retried\n * individually, meaning you can compose complex workflows that safely\n * retry dependent asynchronous actions.\n *\n * The function you pass to `run` will be called only when this \"step\" is to\n * be executed and can be synchronous or asynchronous.\n *\n * In either case, the return value of the function will be the return value\n * of the `run` tool, meaning you can return and reason about return data\n * for next steps.\n */\n run: createStepRun(),\n\n /**\n * AI tooling for running AI models and other AI-related tasks.\n */\n ai: {\n /**\n * Use this tool to have Inngest make your AI calls. Useful for agentic workflows.\n *\n * Input is also tracked for this tool, meaning you can pass input to the\n * function and it will be displayed and editable in the UI.\n */\n infer: createTool<\n <TAdapter extends AiAdapter>(\n idOrOptions: StepOptionsOrId,\n options: AiInferOpts<TAdapter>,\n ) => Promise<AiAdapter.Output<TAdapter>>\n >(({ id, name }, options) => {\n // eslint-disable-next-line\n const { model, body, ...rest } = options;\n\n const modelCopy = { ...model };\n\n // Allow the model to mutate options and body for this call\n options.model.onCall?.(modelCopy, options.body);\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.AiGateway,\n displayName: name ?? id,\n opts: {\n type: \"step.ai.infer\",\n url: modelCopy.url,\n headers: modelCopy.headers,\n auth_key: modelCopy.authKey,\n format: modelCopy.format,\n // eslint-disable-next-line\n body,\n // eslint-disable-next-line\n ...rest,\n },\n userland: { id },\n };\n }),\n\n /**\n * Use this tool to wrap AI models and other AI-related tasks. Each call\n * to `wrap` will be retried individually, meaning you can compose complex\n * workflows that safely retry dependent asynchronous actions.\n *\n * Input is also tracked for this tool, meaning you can pass input to the\n * function and it will be displayed and editable in the UI.\n */\n wrap: createStepRun(\"step.ai.wrap\"),\n\n /**\n * Models for AI inference and other AI-related tasks.\n */\n models: {\n ...models,\n },\n },\n\n /**\n * Wait a specified amount of time before continuing.\n *\n * The time to wait can be specified using a `number` of milliseconds or an\n * `ms`-compatible time string like `\"1 hour\"`, `\"30 mins\"`, or `\"2.5d\"`.\n *\n * {@link https://npm.im/ms}\n *\n * To wait until a particular date, use `sleepUntil` instead.\n */\n sleep: createTool<\n (\n idOrOptions: StepOptionsOrId,\n\n /**\n * The amount of time to wait before continuing.\n */\n time: number | string | Temporal.DurationLike,\n ) => Promise<void>\n >(({ id, name }, time) => {\n /**\n * The presence of this operation in the returned stack indicates that the\n * sleep is over and we should continue execution.\n */\n const msTimeStr: string = timeStr(time);\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.Sleep,\n name: msTimeStr,\n displayName: name ?? id,\n userland: { id },\n };\n }),\n\n /**\n * Wait until a particular date before continuing by passing a `Date`.\n *\n * To wait for a particular amount of time from now, always use `sleep`\n * instead.\n */\n sleepUntil: createTool<\n (\n idOrOptions: StepOptionsOrId,\n\n /**\n * The date to wait until before continuing.\n */\n time: Date | string | Temporal.InstantLike | Temporal.ZonedDateTimeLike,\n ) => Promise<void>\n >(({ id, name }, time) => {\n try {\n const iso = Temporal.getISOString(time);\n\n /**\n * The presence of this operation in the returned stack indicates that the\n * sleep is over and we should continue execution.\n */\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.Sleep,\n name: iso,\n displayName: name ?? id,\n userland: { id },\n };\n } catch (err) {\n /**\n * If we're here, it's because the date is invalid. We'll throw a custom\n * error here to standardise this response.\n */\n client[internalLoggerSymbol].warn(\n { err },\n \"Invalid `Date`, date string, `Temporal.Instant`, or `Temporal.ZonedDateTime` passed to sleepUntil\",\n );\n\n throw new Error(\n `Invalid \\`Date\\`, date string, \\`Temporal.Instant\\`, or \\`Temporal.ZonedDateTime\\` passed to sleepUntil: ${\n time\n }`,\n );\n }\n }),\n\n /**\n * Invoke a passed Inngest `function` with the given `data`. Returns the\n * result of the returned value of the function or `null` if the function\n * does not return a value.\n */\n invoke: createTool<\n <TFunction extends InvokeTargetFunctionDefinition>(\n idOrOptions: StepOptionsOrId,\n opts: InvocationOpts<TFunction>,\n ) => InvocationResult<\n ApplyAllMiddlewareTransforms<\n MergedMiddleware<TClient, TFnMiddleware>,\n GetFunctionOutputRaw<TFunction>,\n \"functionOutputTransform\"\n >\n >\n >(({ id, name }, invokeOpts) => {\n // Create a discriminated union to operate on based on the input types\n // available for this tool.\n const optsSchema = invokePayloadSchema.extend({\n timeout: z\n .custom<\n | number\n | string\n | Date\n | Temporal.DurationLike\n | Temporal.InstantLike\n | Temporal.ZonedDateTimeLike\n >(\n (v) =>\n typeof v === \"number\" ||\n typeof v === \"string\" ||\n v instanceof Date ||\n Temporal.isTemporalDuration(v) ||\n Temporal.isTemporalInstant(v) ||\n Temporal.isTemporalZonedDateTime(v),\n { message: \"Invalid timeout\" },\n )\n .optional(),\n });\n\n const parsedFnOpts = optsSchema\n .extend({\n _type: z.literal(\"fnInstance\").optional().default(\"fnInstance\"),\n function: z.instanceof(InngestFunction),\n })\n .or(\n optsSchema.extend({\n _type: z.literal(\"refInstance\").optional().default(\"refInstance\"),\n function: z.instanceof(InngestFunctionReference),\n }),\n )\n .safeParse(invokeOpts);\n\n if (!parsedFnOpts.success) {\n throw new Error(\n `Invalid invocation options passed to invoke; must include a function instance or referenceFunction().`,\n );\n }\n\n const { _type, function: fn, data, v, meta, timeout } = parsedFnOpts.data;\n const payload = {\n data,\n v,\n meta: normalizeEventMeta(meta),\n } satisfies MinimalEventPayload;\n const opts: {\n payload: typeof payload;\n function_id: string;\n timeout?: string;\n } = {\n payload,\n function_id: \"\",\n timeout: typeof timeout === \"undefined\" ? undefined : timeStr(timeout),\n };\n\n switch (_type) {\n case \"fnInstance\":\n opts.function_id = fn.id(fn[\"client\"].id);\n break;\n\n case \"refInstance\":\n opts.function_id = [fn.opts.appId || client.id, fn.opts.functionId]\n .filter(Boolean)\n .join(\"-\");\n break;\n }\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.InvokeFunction,\n displayName: name ?? id,\n opts,\n userland: { id },\n };\n }),\n\n /**\n * `step.fetch` is a Fetch-API-compatible function that can be used to make\n * any HTTP code durable if it's called within an Inngest function.\n *\n * It will gracefully fall back to the global `fetch` if called outside of\n * this context, and a custom fallback can be set using the `config` method.\n */\n fetch: stepFetch,\n };\n\n // NOTE: This should be moved into the above object definition under the key\n // \"metadata\" when metadata is made non-experimental.\n (tools as unknown as ExperimentalStepTools)[metadataSymbol] = (\n memoizationId: string,\n ): MetadataStepTool => createStepMetadataWrapper(memoizationId);\n\n // Attach a step.run variant with opts.type = \"group.experiment\" for use by\n // group.experiment(). The symbol keeps it off the public `step` surface.\n (tools as unknown as ExperimentStepTools)[experimentStepRunSymbol] =\n createStepRun(\"group.experiment\");\n\n // Add an uptyped gateway\n (tools as unknown as InternalStepTools)[gatewaySymbol] = createTool(\n ({ id, name }, input, init) => {\n const url = input instanceof Request ? input.url : input.toString();\n\n const headers: Record<string, string> = {};\n if (input instanceof Request) {\n input.headers.forEach((value, key) => {\n headers[key] = value;\n });\n } else if (init?.headers) {\n const h = new Headers(init.headers);\n h.forEach((value, key) => {\n headers[key] = value;\n });\n }\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.Gateway,\n displayName: name ?? id,\n opts: {\n url,\n method: init?.method ?? \"GET\",\n headers,\n body: init?.body,\n },\n userland: { id },\n };\n },\n );\n\n return tools;\n};\n\n/**\n * A generic set of step tools, without typing information about the client used\n * to create them.\n */\nexport type GenericStepTools = GetStepTools<Inngest.Any>;\n\nexport const gatewaySymbol = Symbol.for(\"inngest.step.gateway\");\n\nexport type InternalStepTools = GetStepTools<Inngest.Any> & {\n [gatewaySymbol]: (\n idOrOptions: StepOptionsOrId,\n ...args: Parameters<typeof fetch>\n ) => Promise<{\n status_code: number;\n headers: Record<string, string>;\n body: string;\n }>;\n};\n\nexport type ExperimentalStepTools = GetStepTools<Inngest.Any> & {\n [metadataSymbol]: (memoizationId: string) => MetadataStepTool;\n};\n\nexport const experimentStepRunSymbol = Symbol.for(\"inngest.group.experiment\");\n\nexport type ExperimentStepTools = GetStepTools<Inngest.Any> & {\n [experimentStepRunSymbol]: (\n idOrOptions: StepOptionsOrId,\n fn: () => unknown,\n ) => Promise<unknown>;\n};\n\n/**\n * A generic set of step tools that can be used without typing information about\n * the client used to create them.\n *\n * These tools use AsyncLocalStorage to track the context in which they are\n * used, and will throw an error if used outside of an Inngest context.\n *\n * The intention of these high-level tools is to allow usage of Inngest step\n * tools within API endpoints, though they can still be used within regular\n * Inngest functions as well.\n */\nexport const step: GenericStepTools = {\n // TODO Support `step.fetch` (this is already kinda half way deferred)\n fetch: null as unknown as GenericStepTools[\"fetch\"],\n ai: {\n infer: (...args) =>\n getDeferredStepTooling().then((tools) => tools.ai.infer(...args)),\n wrap: (...args) =>\n getDeferredStepTooling().then((tools) => tools.ai.wrap(...args)),\n models: {\n ...models,\n },\n },\n invoke: (...args) =>\n getDeferredStepTooling().then((tools) => tools.invoke(...args)),\n run: (...args) =>\n getDeferredStepTooling().then((tools) => tools.run(...args)),\n sendEvent: (...args) =>\n getDeferredStepTooling().then((tools) => tools.sendEvent(...args)),\n sendSignal: (...args) =>\n getDeferredStepTooling().then((tools) => tools.sendSignal(...args)),\n sleep: (...args) =>\n getDeferredStepTooling().then((tools) => tools.sleep(...args)),\n sleepUntil: (...args) =>\n getDeferredStepTooling().then((tools) => tools.sleepUntil(...args)),\n waitForEvent: (...args) =>\n getDeferredStepTooling().then((tools) => tools.waitForEvent(...args)),\n waitForSignal: (...args) =>\n getDeferredStepTooling().then((tools) => tools.waitForSignal(...args)),\n realtime: {\n publish: (...args) =>\n getDeferredStepTooling().then((tools) => tools.realtime.publish(...args)),\n },\n};\n\n/**\n * An internal function used to retrieve or create step tooling for the current\n * execution context.\n *\n * Note that this requires an existing context to create the step tooling;\n * something must declare the Inngest execution context before this can be used.\n */\nconst getDeferredStepTooling = async (): Promise<GenericStepTools> => {\n const ctx = await getAsyncCtx();\n if (!ctx) {\n throw new Error(\n \"`step` tools can only be used within Inngest function executions; no context was found\",\n );\n }\n\n if (!ctx.app) {\n throw new Error(\n \"`step` tools can only be used within Inngest function executions; no Inngest client was found in the execution context\",\n );\n }\n\n if (!ctx.execution) {\n throw new Error(\n \"`step` tools can only be used within Inngest function executions; no execution context was found\",\n );\n }\n\n // If we're here, we're in the context of a function execution already and\n // we can return the existing step tooling.\n return ctx.execution.ctx.step;\n};\n\nconst getDeferredGroupTooling = async (): Promise<GroupTools> => {\n const ctx = await getAsyncCtx();\n if (!ctx) {\n throw new Error(\n \"`group` tools can only be used within Inngest function executions; no context was found\",\n );\n }\n\n if (!ctx.execution) {\n throw new Error(\n \"`group` tools can only be used within Inngest function executions; no execution context was found\",\n );\n }\n\n return ctx.execution.ctx.group;\n};\n\n/**\n * A deferred proxy for `group` tools that delegates through ALS context.\n *\n * @public\n */\nexport const group: GroupTools = {\n parallel: (...args) =>\n getDeferredGroupTooling().then((tools) => tools.parallel(...args)),\n experiment: (...args) =>\n getDeferredGroupTooling().then((tools) => tools.experiment(...args)),\n};\n\n/**\n * The event payload portion of the options for `step.invoke()`. This does not\n * include non-payload options like `timeout` or the function to invoke.\n */\nexport const invokePayloadSchema = z.object({\n data: z.record(z.any()).optional(),\n v: z.string().optional(),\n meta: z\n .object({\n sessions: z.record(z.any()).optional(),\n })\n .optional(),\n});\n\ntype InvocationTargetOpts<TFunction extends InvokeTargetFunctionDefinition> = {\n function: TFunction;\n};\n\ntype InvocationOpts<TFunction extends InvokeTargetFunctionDefinition> =\n InvocationTargetOpts<TFunction> &\n Omit<TriggerEventFromFunction<TFunction>, \"id\"> & {\n /**\n * Event meta shared with the invoked run.\n *\n * Meta is not inherited from the calling run; pass `meta.sessions`\n * explicitly to group the invoked run. Values are normalized to strings\n * before sending, as with `inngest.send()`.\n */\n meta?: EventMeta;\n\n /**\n * The step function will wait for the invocation to finish for a maximum\n * of this time, at which point the retured promise will be rejected\n * instead of resolved with the output of the invoked function.\n *\n * Note that the invoked function will continue to run even if this step\n * times out.\n *\n * The time to wait can be specified using a `number` of milliseconds, an\n * `ms`-compatible time string like `\"1 hour\"`, `\"30 mins\"`, or `\"2.5d\"`,\n * a `Date`, a `Temporal.Duration` (relative wait), or a `Temporal.Instant`\n * / `Temporal.ZonedDateTime` (absolute deadline).\n *\n * {@link https://npm.im/ms}\n */\n timeout?:\n | number\n | string\n | Date\n | Temporal.DurationLike\n | Temporal.InstantLike\n | Temporal.ZonedDateTimeLike;\n };\n\n/**\n * A set of parameters given to a `sendSignal` call.\n */\ntype SendSignalOpts = {\n /**\n * The signal to send.\n */\n signal: string;\n\n /**\n * The data to send with the signal.\n */\n data?: unknown;\n};\n\n/**\n * A set of parameters given to a `waitForSignal` call.\n */\ntype WaitForSignalOpts = {\n /**\n * The signal to wait for.\n */\n signal: string;\n\n /**\n * The step function will wait for the signal for a maximum of this time, at\n * which point the signal will be returned as `null` instead of any signal\n * data.\n *\n * The time to wait can be specified using a `number` of milliseconds, an\n * `ms`-compatible time string like `\"1 hour\"`, `\"30 mins\"`, or `\"2.5d\"`, a\n * `Date`, a `Temporal.Duration` (relative wait), or a `Temporal.Instant` /\n * `Temporal.ZonedDateTime` (absolute deadline).\n *\n * {@link https://npm.im/ms}\n */\n timeout:\n | number\n | string\n | Date\n | Temporal.DurationLike\n | Temporal.InstantLike\n | Temporal.ZonedDateTimeLike;\n\n /**\n * When this `step.waitForSignal()` call is made, choose whether an existing\n * wait for the same signal should be replaced, or whether this run should\n * fail.\n *\n * `\"replace\"` will replace any existing wait with this one, and the existing\n * wait will remain pending until it reaches its timeout.\n *\n * `\"fail\"` will cause this run to fail if there is already a wait for the\n * same signal.\n */\n onConflict: \"replace\" | \"fail\";\n};\n\n/**\n * Computes the return type for `waitForEvent` based on the options provided.\n *\n * Handles three cases:\n * 1. `event: EventType<TName, TSchema>` - extracts name and data from EventType\n * 2. `event: string` with `schema` - uses string as name and schema for data\n * 3. `event: string` without schema - uses string as name with untyped data\n */\ntype WaitForEventResult<TOpts> =\n // Case 1: event is an EventType with a schema\n TOpts extends {\n event: EventType<\n infer TName extends string,\n StandardSchemaV1<infer TData extends Record<string, unknown>>\n >;\n }\n ? {\n name: TName;\n data: TData;\n id: string;\n ts: number;\n v?: string;\n meta?: ReceivedEventMeta;\n } | null\n : // Case 2: event is an EventType without a schema\n TOpts extends {\n event: EventType<infer TName extends string, undefined>;\n }\n ? {\n name: TName;\n // biome-ignore lint/suspicious/noExplicitAny: fallback for untyped events\n data: Record<string, any>;\n id: string;\n ts: number;\n v?: string;\n meta?: ReceivedEventMeta;\n } | null\n : // Case 3: event is a string with schema (spread EventType)\n TOpts extends {\n event: infer TName extends string;\n schema: StandardSchemaV1<\n infer TData extends Record<string, unknown>\n >;\n }\n ? {\n name: TName;\n data: TData;\n id: string;\n ts: number;\n v?: string;\n meta?: ReceivedEventMeta;\n } | null\n : // Case 4: event is just a string\n TOpts extends { event: infer TName extends string }\n ? {\n name: TName;\n // biome-ignore lint/suspicious/noExplicitAny: fallback for untyped events\n data: Record<string, any>;\n id: string;\n ts: number;\n v?: string;\n meta?: ReceivedEventMeta;\n } | null\n : EventPayload | null;\n\n/**\n * Options for `step.ai.infer()`.\n */\ntype AiInferOpts<TModel extends AiAdapter> = {\n /**\n * The model to use for the inference. Create a model by importing from\n * `\"inngest\"` or by using `step.ai.models.*`.\n *\n * @example Import `openai()`\n * ```ts\n * import { openai } from \"inngest\";\n *\n * const model = openai({ model: \"gpt-4\" });\n * ```\n *\n * @example Use a model from `step.ai.models`\n * ```ts\n * async ({ step }) => {\n * const model = step.ai.models.openai({ model: \"gpt-4\" });\n * }\n * ```\n */\n model: TModel;\n\n /**\n * The input to pass to the model.\n */\n body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UAAU;CACd,CAAC"}
1
+ {"version":3,"file":"InngestStepTools.js","names":["wrappedMatchOp: MatchOpFn<T>","opts: HashedOp[\"opts\"]","createStepScoreWrapper: ScoreStepTool","matchOpts: { timeout: string; if?: string }","msTimeStr: string","Temporal.getISOString","v","Temporal.isTemporalDuration","Temporal.isTemporalInstant","Temporal.isTemporalZonedDateTime","opts: {\n payload: typeof payload;\n function_id: string;\n timeout?: string;\n }","stepFetch","headers: Record<string, string>","step: GenericStepTools","group: GroupTools"],"sources":["../../src/components/InngestStepTools.ts"],"sourcesContent":["import { type AiAdapter, models } from \"@inngest/ai\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { z } from \"zod/v3\";\n\nimport type { InngestApi } from \"../api/api.ts\";\nimport type { Jsonify } from \"../helpers/jsonify.ts\";\nimport { normalizeEventMeta } from \"../helpers/sessions.ts\";\nimport { timeStr } from \"../helpers/strings.ts\";\nimport * as Temporal from \"../helpers/temporal.ts\";\nimport type {\n ExclusiveKeys,\n ParametersExceptFirst,\n SendEventPayload,\n} from \"../helpers/types.ts\";\nimport {\n type ApplyAllMiddlewareTransforms,\n type Context,\n type EventMeta,\n type EventPayload,\n type HashedOp,\n type InvocationResult,\n type InvokeTargetFunctionDefinition,\n type MinimalEventPayload,\n type OutgoingOp,\n type ReceivedEventMeta,\n type SendEventOutput,\n StepMode,\n StepOpCode,\n type StepOptions,\n type StepOptionsOrId,\n type TriggerEventFromFunction,\n} from \"../types.ts\";\nimport { getAsyncCtx, getAsyncCtxSync } from \"./execution/als.ts\";\nimport type { InngestExecution } from \"./execution/InngestExecution.ts\";\nimport { fetch as stepFetch } from \"./Fetch.ts\";\nimport {\n type ClientOptionsFromInngest,\n type GetFunctionOutputRaw,\n type GetStepTools,\n type Inngest,\n internalLoggerSymbol,\n} from \"./Inngest.ts\";\nimport { InngestFunction } from \"./InngestFunction.ts\";\nimport { InngestFunctionReference } from \"./InngestFunctionReference.ts\";\nimport type { GroupTools } from \"./InngestGroupTools.ts\";\nimport {\n type MetadataBuilder,\n type MetadataStepTool,\n metadataSymbol,\n UnscopedMetadataBuilder,\n} from \"./InngestMetadata.ts\";\nimport {\n type ScoreStepTool,\n scoreSymbol,\n sendStepScore,\n validateStepScoreOptions,\n} from \"./InngestScore.ts\";\nimport type { Middleware } from \"./middleware/index.ts\";\nimport { NonRetriableError } from \"./NonRetriableError.ts\";\nimport type { Realtime } from \"./realtime/types.ts\";\nimport type { EventType } from \"./triggers/triggers.ts\";\n\n/**\n * Middleware context for a step, created during step registration.\n *\n * Uses a \"deferred handler\" pattern: the `wrapStep` middleware chain starts\n * during discovery (so middleware can inject its own steps), but the real\n * handler isn't known until after the memoization lookup. `setActualHandler`\n * bridges the gap — the chain blocks on a deferred promise that is resolved\n * once `executeStep` determines the real result.\n */\nexport interface StepMiddlewareContext {\n /**\n * Sets the handler that the middleware pipeline will eventually call.\n * Called after memoization lookup to set either:\n * - A handler returning memoized data, OR\n * - A handler executing the step fresh\n */\n setActualHandler: (handler: () => Promise<unknown>) => void;\n\n /**\n * Step info after middleware transformations. The `options.id` may differ\n * from the original if middleware modified it via `transformStepInput`.\n */\n stepInfo: Middleware.StepInfo;\n\n /**\n * The middleware pipeline entry point. Call this to execute the step\n * through all middleware transformations.\n */\n wrappedHandler: () => Promise<unknown>;\n}\n\nexport interface FoundStep extends HashedOp {\n hashedId: string;\n fn?: (...args: unknown[]) => unknown;\n rawArgs: unknown[];\n\n /**\n * A boolean representing whether the step has been fulfilled, either\n * resolving or rejecting the `Promise` returned to userland code.\n *\n * Note that this is distinct from {@link hasStepState}, which instead tracks\n * whether the step has been given some state from the Executor. State from\n * the Executor could be data other than a resolution or rejection, such as\n * inputs.\n */\n fulfilled: boolean;\n\n /**\n * A boolean representing whether the step has been given some state from the\n * Executor. State from the Executor could be data other than a resolution or\n * rejection, such as inputs.\n *\n * This is distinct from {@link fulfilled}, which instead tracks whether the\n * step has been fulfilled, either resolving or rejecting the `Promise`\n * returned to userland code.\n */\n hasStepState: boolean;\n\n handled: boolean;\n\n /**\n * The promise that has been returned to userland code for this step.\n */\n promise: Promise<unknown>;\n\n /**\n * Returns a boolean representing whether or not the step was handled on this\n * invocation.\n */\n handle: () => boolean;\n\n // TODO This is used to track the input we want for this step. Might be\n // present in ctx from Executor.\n input?: unknown;\n\n /**\n * Middleware context for this step. Holds the `wrapStep` chain entry point\n * and the deferred handler setter used by `executeStep`.\n */\n middleware: StepMiddlewareContext;\n\n /**\n * For new steps where wrappedHandler is called during discovery,\n * this holds the resolve/reject to be called when the step's data is\n * memoized. Resolved with server-transformed data (post-wrapStepHandler),\n * which unblocks wrapStep's `next()`.\n *\n * Is undefined when any of the following is true:\n * - The step is fulfilled\n * - The step has no handler (`step.sleep`, `step.waitForSignal`, etc.)\n */\n memoizationDeferred?: {\n resolve: (value: unknown) => void;\n reject: (error: unknown) => void;\n };\n\n /**\n * For new steps where `wrappedHandler` is called during discovery, this holds\n * the promise for the wrapStep-transformed result. In checkpointing mode,\n * handle() reuses this promise to avoid a duplicate wrapStep call.\n */\n transformedResultPromise?: Promise<unknown>;\n\n /**\n * Optional metadata updates attached to this step, carried through from\n * the OutgoingOp so that checkpoint payloads include metadata.\n */\n metadata?: OutgoingOp[\"metadata\"];\n}\n\nexport type MatchOpFn<\n T extends (...args: unknown[]) => Promise<unknown> = (\n ...args: unknown[]\n ) => Promise<unknown>,\n> = (\n stepOptions: StepOptions,\n /**\n * Arguments passed by the user.\n */\n ...args: ParametersExceptFirst<T>\n) => Omit<HashedOp, \"data\" | \"error\">;\n\nexport type StepHandler = (info: {\n matchOp: MatchOpFn;\n opts?: StepToolOptions;\n args: [StepOptionsOrId, ...unknown[]];\n}) => Promise<unknown>;\n\nexport interface StepToolOptions<\n T extends (...args: unknown[]) => Promise<unknown> = (\n ...args: unknown[]\n ) => Promise<unknown>,\n> {\n /**\n * Optionally, we can also provide a function that will be called when\n * Inngest tells us to run this operation.\n *\n * If this function is defined, the first time the tool is used it will\n * report the desired operation (including options) to the Inngest. Inngest\n * will then call back to the function to tell it to run the step and then\n * retrieve data.\n *\n * We do this in order to allow functionality such as per-step retries; this\n * gives the SDK the opportunity to tell Inngest what it wants to do before\n * it does it.\n *\n * This function is passed the arguments passed by the user. It will be run\n * when we receive an operation matching this one that does not contain a\n * `data` property.\n */\n fn?: (...args: [Context.Any, ...Parameters<T>]) => unknown;\n}\n\nexport const getStepOptions = (options: StepOptionsOrId): StepOptions => {\n if (typeof options === \"string\") {\n return { id: options };\n }\n\n return options;\n};\n\n/**\n * Suffix used to namespace steps that are automatically indexed.\n */\nexport const STEP_INDEXING_SUFFIX = \":\";\n\n/**\n * Create a new set of step function tools ready to be used in a step function.\n * This function should be run and a fresh set of tools provided every time a\n * function is run.\n *\n * An op stack (function state) is passed in as well as some mutable properties\n * that the tools can use to submit a new op.\n */\n/**\n * Merge client-level and function-level middleware into a single array type\n * for use with ApplyAllMiddlewareTransforms etc.\n */\ntype MergedMiddleware<\n TClient extends Inngest.Any,\n TFnMiddleware extends Middleware.Class[] | undefined,\n> = [\n ...(ClientOptionsFromInngest<TClient>[\"middleware\"] extends Middleware.Class[]\n ? ClientOptionsFromInngest<TClient>[\"middleware\"]\n : []),\n ...(TFnMiddleware extends Middleware.Class[] ? TFnMiddleware : []),\n];\n\nexport const createStepTools = <\n TClient extends Inngest.Any,\n TFnMiddleware extends Middleware.Class[] | undefined = undefined,\n>(\n client: TClient,\n execution: InngestExecution,\n stepHandler: StepHandler,\n) => {\n /**\n * A local helper used to create tools that can be used to submit an op.\n *\n * When using this function, a generic type should be provided which is the\n * function signature exposed to the user.\n */\n // biome-ignore lint/suspicious/noExplicitAny: intentional\n const createTool = <T extends (...args: any[]) => Promise<unknown>>(\n /**\n * A function that returns an ID for this op. This is used to ensure that\n * the op stack is correctly filled, submitted, and retrieved with the same\n * ID.\n *\n * It is passed the arguments passed by the user.\n *\n * Most simple tools will likely only need to define this.\n */\n matchOp: MatchOpFn<T>,\n opts?: StepToolOptions<T>,\n ): T => {\n const wrappedMatchOp: MatchOpFn<T> = (stepOptions, ...rest) => {\n const op = matchOp(stepOptions, ...rest);\n\n const alsCtx = getAsyncCtxSync()?.execution;\n\n if (alsCtx?.insideExperimentSelect) {\n throw new NonRetriableError(\n \"Step tools (step.run, step.sleep, etc.) cannot be called inside \" +\n \"an experiment select() callback. Move step calls into variant \" +\n \"callbacks instead.\",\n );\n }\n\n // Explicit option takes precedence, then check ALS context\n const parallelMode = stepOptions.parallelMode ?? alsCtx?.parallelMode;\n\n if (parallelMode) {\n op.opts = { ...op.opts, parallelMode };\n }\n\n // Propagate experiment context to variant sub-steps\n const experimentContext = alsCtx?.experimentContext;\n if (experimentContext) {\n op.opts = { ...op.opts, ...experimentContext };\n }\n\n // Track that a step tool was invoked inside a variant callback\n const tracker = alsCtx?.experimentStepTracker;\n if (tracker) {\n tracker.found = true;\n }\n\n return op;\n };\n\n return (async (...args: Parameters<T>): Promise<unknown> => {\n const parsedArgs = args as unknown as [StepOptionsOrId, ...unknown[]];\n return stepHandler({ args: parsedArgs, matchOp: wrappedMatchOp, opts });\n }) as T;\n };\n\n /**\n * Create a new step run tool that can be used to run a step function using\n * `step.run()` as a shim.\n */\n const createStepRun = (\n /**\n * The sub-type of this step tool, exposed via `opts.type` when the op is\n * reported.\n */\n type?: string,\n ) => {\n return createTool<\n // biome-ignore lint/suspicious/noExplicitAny: intentional\n <TFn extends (...args: any[]) => unknown>(\n idOrOptions: StepOptionsOrId,\n\n /**\n * The function to run when this step is executed. Can be synchronous or\n * asynchronous.\n *\n * The return value of this function will be the return value of this\n * call to `run`, meaning you can return and reason about return data\n * for next steps.\n */\n fn: TFn,\n\n /**\n * Optional input to pass to the function. If this is specified, Inngest\n * will keep track of the input for this step and be able to display it\n * in the UI.\n */\n ...input: Parameters<TFn>\n ) => Promise<\n ApplyAllMiddlewareTransforms<\n MergedMiddleware<TClient, TFnMiddleware>,\n TFn extends (...args: Parameters<TFn>) => Promise<infer U>\n ? Awaited<U extends void ? null : U>\n : ReturnType<TFn> extends void\n ? null\n : ReturnType<TFn>\n >\n >\n >(\n ({ id, name }, _fn, ...input) => {\n const opts: HashedOp[\"opts\"] = {\n ...(input.length ? { input } : {}),\n ...(type ? { type } : {}),\n };\n\n return {\n id,\n mode: StepMode.Sync,\n op: StepOpCode.StepPlanned,\n name: id,\n displayName: name ?? id,\n ...(Object.keys(opts).length ? { opts } : {}),\n userland: { id },\n };\n },\n {\n fn: (_, __, fn, ...input) => fn(...input),\n },\n );\n };\n\n /**\n * Creates a metadata builder wrapper for step.metadata(\"id\").\n * Uses MetadataBuilder for config accumulation, but wraps .update() in tools.run() for memoization.\n */\n const createStepMetadataWrapper = (\n memoizationId: string,\n builder?: UnscopedMetadataBuilder,\n ) => {\n if (!client[\"experimentalMetadataEnabled\"]) {\n throw new Error(\n 'step.metadata() is experimental. Enable it by adding metadataMiddleware() from \"inngest/experimental\" to your client middleware.',\n );\n }\n const withBuilder = (next: UnscopedMetadataBuilder) =>\n createStepMetadataWrapper(memoizationId, next);\n\n if (!builder) {\n builder = new UnscopedMetadataBuilder(client).run();\n }\n\n return {\n run: (runId?: string) => withBuilder(builder.run(runId)),\n step: (stepId: string, index?: number) =>\n withBuilder(builder.step(stepId, index)),\n attempt: (attemptIndex: number) =>\n withBuilder(builder.attempt(attemptIndex)),\n span: (spanId: string) => withBuilder(builder.span(spanId)),\n update: async (\n values: Record<string, unknown>,\n kind = \"default\",\n ): Promise<void> => {\n await tools.run(memoizationId, async () => {\n await builder.update(values, kind);\n });\n },\n\n do: async (\n fn: (builder: MetadataBuilder) => Promise<void>,\n ): Promise<void> => {\n await tools.run(memoizationId, async () => {\n await fn(builder);\n });\n },\n };\n };\n\n const createStepScoreWrapper: ScoreStepTool = async (\n memoizationId,\n options,\n ) => {\n if (!client[\"experimentalScoreEnabled\"]) {\n // This is a config error, so retrying the function cannot fix it\n throw new NonRetriableError(\n 'step.score() is experimental. Enable it by adding scoreMiddleware() from \"inngest/experimental\" to your client middleware.',\n );\n }\n\n validateStepScoreOptions(options);\n\n await tools.run(memoizationId, async () => {\n await sendStepScore(client, options);\n });\n };\n\n /**\n * Define the set of tools the user has access to for their step functions.\n *\n * Each key is the function name and is expected to run `createTool` and pass\n * a generic type for that function as it will appear in the user's code.\n */\n const tools = {\n /**\n * Send one or many events to Inngest. Should always be used in place of\n * `inngest.send()` to ensure that the event send is successfully retried\n * and not sent multiple times due to memoisation.\n *\n * @example\n * ```ts\n * await step.sendEvent(\"emit-user-creation\", {\n * name: \"app/user.created\",\n * data: { id: 123 },\n * });\n *\n * await step.sendEvent(\"emit-user-updates\", [\n * {\n * name: \"app/user.created\",\n * data: { id: 123 },\n * },\n * {\n * name: \"app/user.feed.created\",\n * data: { id: 123 },\n * },\n * ]);\n * ```\n *\n * Returns a promise that will resolve once the event has been sent.\n */\n sendEvent: createTool<\n (\n idOrOptions: StepOptionsOrId,\n payload: SendEventPayload,\n ) => Promise<SendEventOutput<ClientOptionsFromInngest<TClient>>>\n >(\n ({ id, name }) => {\n return {\n id,\n mode: StepMode.Sync,\n op: StepOpCode.StepPlanned,\n name: \"sendEvent\",\n displayName: name ?? id,\n opts: {\n type: \"step.sendEvent\",\n },\n userland: { id },\n };\n },\n {\n fn: (_ctx, _idOrOptions, payload) => {\n const fn = execution[\"options\"][\"fn\"];\n return client[\"_send\"]({\n payload,\n headers: execution[\"options\"][\"headers\"],\n fnMiddleware: fn.opts.middleware ?? [],\n fn,\n });\n },\n },\n ),\n\n /**\n * EXPERIMENTAL: This API is not yet stable and may change in the future\n * without a major version bump.\n *\n * Wait for a particular signal to be received before continuing. When the\n * signal is received, its data will be returned.\n */\n waitForSignal: createTool<\n <TData>(\n idOrOptions: StepOptionsOrId,\n opts: WaitForSignalOpts,\n ) => Promise<{ signal: string; data: Jsonify<TData> } | null>\n >(({ id, name }, opts) => {\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.WaitForSignal,\n name: opts.signal,\n displayName: name ?? id,\n opts: {\n signal: opts.signal,\n timeout: timeStr(opts.timeout),\n conflict: opts.onConflict,\n },\n userland: { id },\n };\n }),\n\n /**\n * Step-level functionality related to realtime features.\n *\n * Unlike client-level realtime methods (`inngest.realtime.*`), these tools\n * will be their own durable steps when run. If you wish to use realtime\n * features outside of a step, make sure to use the client-level methods\n * instead.\n */\n realtime: {\n /**\n * Publish a realtime message as a durable step. Memoized and will not\n * re-fire on retry, unlike client-level `inngest.realtime.publish()`.\n *\n * Uses topic accessors: `step.realtime.publish(\"id\", chat.status, data)`\n */\n publish: createTool<\n <TData>(\n idOrOptions: StepOptionsOrId,\n topicRef: Realtime.TopicRef<TData>,\n data: TData,\n ) => Promise<TData>\n >(\n ({ id, name }) => {\n return {\n id,\n mode: StepMode.Sync,\n op: StepOpCode.StepPlanned,\n displayName: name ?? id,\n opts: {\n type: \"step.realtime.publish\",\n },\n userland: { id },\n };\n },\n {\n fn: async (ctx, _idOrOptions, topicRef, data) => {\n const topicConfig = topicRef.config;\n if (topicConfig && \"schema\" in topicConfig && topicConfig.schema) {\n const result =\n await topicConfig.schema[\"~standard\"].validate(data);\n if (result.issues) {\n throw new Error(\n `Schema validation failed for topic \"${topicRef.topic}\"`,\n );\n }\n }\n\n const res = await client[\"inngestApi\"].publish(\n {\n topics: [topicRef.topic],\n channel: topicRef.channel,\n runId: ctx.runId,\n },\n data,\n );\n\n if (!res.ok) {\n throw new Error(\n `Failed to publish to realtime: ${res.error?.error || \"Unknown error\"}`,\n );\n }\n\n return data;\n },\n },\n ),\n },\n\n /**\n * Send a Signal to Inngest.\n */\n sendSignal: createTool<\n (\n idOrOptions: StepOptionsOrId,\n opts: SendSignalOpts,\n ) => Promise<InngestApi.SendSignalResponse>\n >(\n ({ id, name }, opts) => {\n return {\n id,\n mode: StepMode.Sync,\n op: StepOpCode.StepPlanned,\n name: \"sendSignal\",\n displayName: name ?? id,\n opts: {\n type: \"step.sendSignal\",\n signal: opts.signal,\n },\n userland: { id },\n };\n },\n {\n fn: (_ctx, _idOrOptions, opts) => {\n return client[\"_sendSignal\"]({\n signal: opts.signal,\n data: opts.data,\n headers: execution[\"options\"][\"headers\"],\n });\n },\n },\n ),\n\n /**\n * Wait for a particular event to be received before continuing. When the\n * event is received, it will be returned.\n *\n * You can also provide options to control the particular event that is\n * received, for example to ensure that a user ID matches between two\n * events, or to only wait a maximum amount of time before giving up and\n * returning `null` instead of any event data.\n */\n waitForEvent: createTool<\n <\n TOpts extends {\n /**\n * The event to wait for.\n */\n event:\n | string\n // biome-ignore lint/suspicious/noExplicitAny: Allow any schema\n | EventType<string, any>;\n\n /**\n * The step function will wait for the event for a maximum of this\n * time, at which point the signal will be returned as `null` instead\n * of any signal data.\n *\n * The time to wait can be specified using a `number` of milliseconds,\n * an `ms`-compatible time string like `\"1 hour\"`, `\"30 mins\"`, or\n * `\"2.5d\"`, a `Date`, a `Temporal.Duration` (relative wait), or a\n * `Temporal.Instant` / `Temporal.ZonedDateTime` (absolute deadline).\n *\n * {@link https://npm.im/ms}\n */\n timeout:\n | number\n | string\n | Date\n | Temporal.DurationLike\n | Temporal.InstantLike\n | Temporal.ZonedDateTimeLike;\n } & ExclusiveKeys<{ match?: string; if?: string }, \"match\", \"if\">,\n >(\n idOrOptions: StepOptionsOrId,\n opts: TOpts,\n ) => Promise<WaitForEventResult<TOpts>>\n >(\n (\n { id, name },\n\n /**\n * Options to control the event we're waiting for.\n */\n opts,\n ) => {\n const matchOpts: { timeout: string; if?: string } = {\n timeout: timeStr(typeof opts === \"string\" ? opts : opts.timeout),\n };\n\n if (typeof opts !== \"string\") {\n if (opts?.match) {\n matchOpts.if = `event.${opts.match} == async.${opts.match}`;\n } else if (opts?.if) {\n matchOpts.if = opts.if;\n }\n }\n\n // Extract event name from string or EventType object\n const eventName =\n typeof opts.event === \"string\" ? opts.event : opts.event.name;\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.WaitForEvent,\n name: eventName,\n opts: matchOpts,\n displayName: name ?? id,\n userland: { id },\n };\n },\n ),\n\n /**\n * Use this tool to run business logic. Each call to `run` will be retried\n * individually, meaning you can compose complex workflows that safely\n * retry dependent asynchronous actions.\n *\n * The function you pass to `run` will be called only when this \"step\" is to\n * be executed and can be synchronous or asynchronous.\n *\n * In either case, the return value of the function will be the return value\n * of the `run` tool, meaning you can return and reason about return data\n * for next steps.\n */\n run: createStepRun(),\n\n /**\n * AI tooling for running AI models and other AI-related tasks.\n */\n ai: {\n /**\n * Use this tool to have Inngest make your AI calls. Useful for agentic workflows.\n *\n * Input is also tracked for this tool, meaning you can pass input to the\n * function and it will be displayed and editable in the UI.\n */\n infer: createTool<\n <TAdapter extends AiAdapter>(\n idOrOptions: StepOptionsOrId,\n options: AiInferOpts<TAdapter>,\n ) => Promise<AiAdapter.Output<TAdapter>>\n >(({ id, name }, options) => {\n // eslint-disable-next-line\n const { model, body, ...rest } = options;\n\n const modelCopy = { ...model };\n\n // Allow the model to mutate options and body for this call\n options.model.onCall?.(modelCopy, options.body);\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.AiGateway,\n displayName: name ?? id,\n opts: {\n type: \"step.ai.infer\",\n url: modelCopy.url,\n headers: modelCopy.headers,\n auth_key: modelCopy.authKey,\n format: modelCopy.format,\n // eslint-disable-next-line\n body,\n // eslint-disable-next-line\n ...rest,\n },\n userland: { id },\n };\n }),\n\n /**\n * Use this tool to wrap AI models and other AI-related tasks. Each call\n * to `wrap` will be retried individually, meaning you can compose complex\n * workflows that safely retry dependent asynchronous actions.\n *\n * Input is also tracked for this tool, meaning you can pass input to the\n * function and it will be displayed and editable in the UI.\n */\n wrap: createStepRun(\"step.ai.wrap\"),\n\n /**\n * Models for AI inference and other AI-related tasks.\n */\n models: {\n ...models,\n },\n },\n\n /**\n * Wait a specified amount of time before continuing.\n *\n * The time to wait can be specified using a `number` of milliseconds or an\n * `ms`-compatible time string like `\"1 hour\"`, `\"30 mins\"`, or `\"2.5d\"`.\n *\n * {@link https://npm.im/ms}\n *\n * To wait until a particular date, use `sleepUntil` instead.\n */\n sleep: createTool<\n (\n idOrOptions: StepOptionsOrId,\n\n /**\n * The amount of time to wait before continuing.\n */\n time: number | string | Temporal.DurationLike,\n ) => Promise<void>\n >(({ id, name }, time) => {\n /**\n * The presence of this operation in the returned stack indicates that the\n * sleep is over and we should continue execution.\n */\n const msTimeStr: string = timeStr(time);\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.Sleep,\n name: msTimeStr,\n displayName: name ?? id,\n userland: { id },\n };\n }),\n\n /**\n * Wait until a particular date before continuing by passing a `Date`.\n *\n * To wait for a particular amount of time from now, always use `sleep`\n * instead.\n */\n sleepUntil: createTool<\n (\n idOrOptions: StepOptionsOrId,\n\n /**\n * The date to wait until before continuing.\n */\n time: Date | string | Temporal.InstantLike | Temporal.ZonedDateTimeLike,\n ) => Promise<void>\n >(({ id, name }, time) => {\n try {\n const iso = Temporal.getISOString(time);\n\n /**\n * The presence of this operation in the returned stack indicates that the\n * sleep is over and we should continue execution.\n */\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.Sleep,\n name: iso,\n displayName: name ?? id,\n userland: { id },\n };\n } catch (err) {\n /**\n * If we're here, it's because the date is invalid. We'll throw a custom\n * error here to standardise this response.\n */\n client[internalLoggerSymbol].warn(\n { err },\n \"Invalid `Date`, date string, `Temporal.Instant`, or `Temporal.ZonedDateTime` passed to sleepUntil\",\n );\n\n throw new Error(\n `Invalid \\`Date\\`, date string, \\`Temporal.Instant\\`, or \\`Temporal.ZonedDateTime\\` passed to sleepUntil: ${\n time\n }`,\n );\n }\n }),\n\n /**\n * Invoke a passed Inngest `function` with the given `data`. Returns the\n * result of the returned value of the function or `null` if the function\n * does not return a value.\n */\n invoke: createTool<\n <TFunction extends InvokeTargetFunctionDefinition>(\n idOrOptions: StepOptionsOrId,\n opts: InvocationOpts<TFunction>,\n ) => InvocationResult<\n ApplyAllMiddlewareTransforms<\n MergedMiddleware<TClient, TFnMiddleware>,\n GetFunctionOutputRaw<TFunction>,\n \"functionOutputTransform\"\n >\n >\n >(({ id, name }, invokeOpts) => {\n // Create a discriminated union to operate on based on the input types\n // available for this tool.\n const optsSchema = invokePayloadSchema.extend({\n timeout: z\n .custom<\n | number\n | string\n | Date\n | Temporal.DurationLike\n | Temporal.InstantLike\n | Temporal.ZonedDateTimeLike\n >(\n (v) =>\n typeof v === \"number\" ||\n typeof v === \"string\" ||\n v instanceof Date ||\n Temporal.isTemporalDuration(v) ||\n Temporal.isTemporalInstant(v) ||\n Temporal.isTemporalZonedDateTime(v),\n { message: \"Invalid timeout\" },\n )\n .optional(),\n });\n\n const parsedFnOpts = optsSchema\n .extend({\n _type: z.literal(\"fnInstance\").optional().default(\"fnInstance\"),\n function: z.instanceof(InngestFunction),\n })\n .or(\n optsSchema.extend({\n _type: z.literal(\"refInstance\").optional().default(\"refInstance\"),\n function: z.instanceof(InngestFunctionReference),\n }),\n )\n .safeParse(invokeOpts);\n\n if (!parsedFnOpts.success) {\n throw new Error(\n `Invalid invocation options passed to invoke; must include a function instance or referenceFunction().`,\n );\n }\n\n const { _type, function: fn, data, v, meta, timeout } = parsedFnOpts.data;\n const payload = {\n data,\n v,\n meta: normalizeEventMeta(meta),\n } satisfies MinimalEventPayload;\n const opts: {\n payload: typeof payload;\n function_id: string;\n timeout?: string;\n } = {\n payload,\n function_id: \"\",\n timeout: typeof timeout === \"undefined\" ? undefined : timeStr(timeout),\n };\n\n switch (_type) {\n case \"fnInstance\":\n opts.function_id = fn.id(fn[\"client\"].id);\n break;\n\n case \"refInstance\":\n opts.function_id = [fn.opts.appId || client.id, fn.opts.functionId]\n .filter(Boolean)\n .join(\"-\");\n break;\n }\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.InvokeFunction,\n displayName: name ?? id,\n opts,\n userland: { id },\n };\n }),\n\n /**\n * `step.fetch` is a Fetch-API-compatible function that can be used to make\n * any HTTP code durable if it's called within an Inngest function.\n *\n * It will gracefully fall back to the global `fetch` if called outside of\n * this context, and a custom fallback can be set using the `config` method.\n */\n fetch: stepFetch,\n };\n\n // NOTE: This should be moved into the above object definition under the key\n // \"metadata\" when metadata is made non-experimental.\n (tools as unknown as ExperimentalStepTools)[metadataSymbol] = (\n memoizationId: string,\n ): MetadataStepTool => createStepMetadataWrapper(memoizationId);\n (tools as unknown as ExperimentalStepTools)[scoreSymbol] =\n createStepScoreWrapper;\n\n // Attach a step.run variant with opts.type = \"group.experiment\" for use by\n // group.experiment(). The symbol keeps it off the public `step` surface.\n (tools as unknown as ExperimentStepTools)[experimentStepRunSymbol] =\n createStepRun(\"group.experiment\");\n\n // Add an uptyped gateway\n (tools as unknown as InternalStepTools)[gatewaySymbol] = createTool(\n ({ id, name }, input, init) => {\n const url = input instanceof Request ? input.url : input.toString();\n\n const headers: Record<string, string> = {};\n if (input instanceof Request) {\n input.headers.forEach((value, key) => {\n headers[key] = value;\n });\n } else if (init?.headers) {\n const h = new Headers(init.headers);\n h.forEach((value, key) => {\n headers[key] = value;\n });\n }\n\n return {\n id,\n mode: StepMode.Async,\n op: StepOpCode.Gateway,\n displayName: name ?? id,\n opts: {\n url,\n method: init?.method ?? \"GET\",\n headers,\n body: init?.body,\n },\n userland: { id },\n };\n },\n );\n\n return tools;\n};\n\n/**\n * A generic set of step tools, without typing information about the client used\n * to create them.\n */\nexport type GenericStepTools = GetStepTools<Inngest.Any>;\n\nexport const gatewaySymbol = Symbol.for(\"inngest.step.gateway\");\n\nexport type InternalStepTools = GetStepTools<Inngest.Any> & {\n [gatewaySymbol]: (\n idOrOptions: StepOptionsOrId,\n ...args: Parameters<typeof fetch>\n ) => Promise<{\n status_code: number;\n headers: Record<string, string>;\n body: string;\n }>;\n};\n\nexport type ExperimentalStepTools = GetStepTools<Inngest.Any> & {\n [metadataSymbol]: (memoizationId: string) => MetadataStepTool;\n [scoreSymbol]: ScoreStepTool;\n};\n\nexport const experimentStepRunSymbol = Symbol.for(\"inngest.group.experiment\");\n\nexport type ExperimentStepTools = GetStepTools<Inngest.Any> & {\n [experimentStepRunSymbol]: (\n idOrOptions: StepOptionsOrId,\n fn: () => unknown,\n ) => Promise<unknown>;\n};\n\n/**\n * A generic set of step tools that can be used without typing information about\n * the client used to create them.\n *\n * These tools use AsyncLocalStorage to track the context in which they are\n * used, and will throw an error if used outside of an Inngest context.\n *\n * The intention of these high-level tools is to allow usage of Inngest step\n * tools within API endpoints, though they can still be used within regular\n * Inngest functions as well.\n */\nexport const step: GenericStepTools = {\n // TODO Support `step.fetch` (this is already kinda half way deferred)\n fetch: null as unknown as GenericStepTools[\"fetch\"],\n ai: {\n infer: (...args) =>\n getDeferredStepTooling().then((tools) => tools.ai.infer(...args)),\n wrap: (...args) =>\n getDeferredStepTooling().then((tools) => tools.ai.wrap(...args)),\n models: {\n ...models,\n },\n },\n invoke: (...args) =>\n getDeferredStepTooling().then((tools) => tools.invoke(...args)),\n run: (...args) =>\n getDeferredStepTooling().then((tools) => tools.run(...args)),\n sendEvent: (...args) =>\n getDeferredStepTooling().then((tools) => tools.sendEvent(...args)),\n sendSignal: (...args) =>\n getDeferredStepTooling().then((tools) => tools.sendSignal(...args)),\n sleep: (...args) =>\n getDeferredStepTooling().then((tools) => tools.sleep(...args)),\n sleepUntil: (...args) =>\n getDeferredStepTooling().then((tools) => tools.sleepUntil(...args)),\n waitForEvent: (...args) =>\n getDeferredStepTooling().then((tools) => tools.waitForEvent(...args)),\n waitForSignal: (...args) =>\n getDeferredStepTooling().then((tools) => tools.waitForSignal(...args)),\n realtime: {\n publish: (...args) =>\n getDeferredStepTooling().then((tools) => tools.realtime.publish(...args)),\n },\n};\n\n/**\n * An internal function used to retrieve or create step tooling for the current\n * execution context.\n *\n * Note that this requires an existing context to create the step tooling;\n * something must declare the Inngest execution context before this can be used.\n */\nconst getDeferredStepTooling = async (): Promise<GenericStepTools> => {\n const ctx = await getAsyncCtx();\n if (!ctx) {\n throw new Error(\n \"`step` tools can only be used within Inngest function executions; no context was found\",\n );\n }\n\n if (!ctx.app) {\n throw new Error(\n \"`step` tools can only be used within Inngest function executions; no Inngest client was found in the execution context\",\n );\n }\n\n if (!ctx.execution) {\n throw new Error(\n \"`step` tools can only be used within Inngest function executions; no execution context was found\",\n );\n }\n\n // If we're here, we're in the context of a function execution already and\n // we can return the existing step tooling.\n return ctx.execution.ctx.step;\n};\n\nconst getDeferredGroupTooling = async (): Promise<GroupTools> => {\n const ctx = await getAsyncCtx();\n if (!ctx) {\n throw new Error(\n \"`group` tools can only be used within Inngest function executions; no context was found\",\n );\n }\n\n if (!ctx.execution) {\n throw new Error(\n \"`group` tools can only be used within Inngest function executions; no execution context was found\",\n );\n }\n\n return ctx.execution.ctx.group;\n};\n\n/**\n * A deferred proxy for `group` tools that delegates through ALS context.\n *\n * @public\n */\nexport const group: GroupTools = {\n parallel: (...args) =>\n getDeferredGroupTooling().then((tools) => tools.parallel(...args)),\n experiment: (...args) =>\n getDeferredGroupTooling().then((tools) => tools.experiment(...args)),\n};\n\n/**\n * The event payload portion of the options for `step.invoke()`. This does not\n * include non-payload options like `timeout` or the function to invoke.\n */\nexport const invokePayloadSchema = z.object({\n data: z.record(z.any()).optional(),\n v: z.string().optional(),\n meta: z\n .object({\n sessions: z.record(z.any()).optional(),\n })\n .optional(),\n});\n\ntype InvocationTargetOpts<TFunction extends InvokeTargetFunctionDefinition> = {\n function: TFunction;\n};\n\ntype InvocationOpts<TFunction extends InvokeTargetFunctionDefinition> =\n InvocationTargetOpts<TFunction> &\n Omit<TriggerEventFromFunction<TFunction>, \"id\"> & {\n /**\n * Event meta shared with the invoked run.\n *\n * Meta is not inherited from the calling run; pass `meta.sessions`\n * explicitly to group the invoked run. Values are normalized to strings\n * before sending, as with `inngest.send()`.\n */\n meta?: EventMeta;\n\n /**\n * The step function will wait for the invocation to finish for a maximum\n * of this time, at which point the retured promise will be rejected\n * instead of resolved with the output of the invoked function.\n *\n * Note that the invoked function will continue to run even if this step\n * times out.\n *\n * The time to wait can be specified using a `number` of milliseconds, an\n * `ms`-compatible time string like `\"1 hour\"`, `\"30 mins\"`, or `\"2.5d\"`,\n * a `Date`, a `Temporal.Duration` (relative wait), or a `Temporal.Instant`\n * / `Temporal.ZonedDateTime` (absolute deadline).\n *\n * {@link https://npm.im/ms}\n */\n timeout?:\n | number\n | string\n | Date\n | Temporal.DurationLike\n | Temporal.InstantLike\n | Temporal.ZonedDateTimeLike;\n };\n\n/**\n * A set of parameters given to a `sendSignal` call.\n */\ntype SendSignalOpts = {\n /**\n * The signal to send.\n */\n signal: string;\n\n /**\n * The data to send with the signal.\n */\n data?: unknown;\n};\n\n/**\n * A set of parameters given to a `waitForSignal` call.\n */\ntype WaitForSignalOpts = {\n /**\n * The signal to wait for.\n */\n signal: string;\n\n /**\n * The step function will wait for the signal for a maximum of this time, at\n * which point the signal will be returned as `null` instead of any signal\n * data.\n *\n * The time to wait can be specified using a `number` of milliseconds, an\n * `ms`-compatible time string like `\"1 hour\"`, `\"30 mins\"`, or `\"2.5d\"`, a\n * `Date`, a `Temporal.Duration` (relative wait), or a `Temporal.Instant` /\n * `Temporal.ZonedDateTime` (absolute deadline).\n *\n * {@link https://npm.im/ms}\n */\n timeout:\n | number\n | string\n | Date\n | Temporal.DurationLike\n | Temporal.InstantLike\n | Temporal.ZonedDateTimeLike;\n\n /**\n * When this `step.waitForSignal()` call is made, choose whether an existing\n * wait for the same signal should be replaced, or whether this run should\n * fail.\n *\n * `\"replace\"` will replace any existing wait with this one, and the existing\n * wait will remain pending until it reaches its timeout.\n *\n * `\"fail\"` will cause this run to fail if there is already a wait for the\n * same signal.\n */\n onConflict: \"replace\" | \"fail\";\n};\n\n/**\n * Computes the return type for `waitForEvent` based on the options provided.\n *\n * Handles three cases:\n * 1. `event: EventType<TName, TSchema>` - extracts name and data from EventType\n * 2. `event: string` with `schema` - uses string as name and schema for data\n * 3. `event: string` without schema - uses string as name with untyped data\n */\ntype WaitForEventResult<TOpts> =\n // Case 1: event is an EventType with a schema\n TOpts extends {\n event: EventType<\n infer TName extends string,\n StandardSchemaV1<infer TData extends Record<string, unknown>>\n >;\n }\n ? {\n name: TName;\n data: TData;\n id: string;\n ts: number;\n v?: string;\n meta?: ReceivedEventMeta;\n } | null\n : // Case 2: event is an EventType without a schema\n TOpts extends {\n event: EventType<infer TName extends string, undefined>;\n }\n ? {\n name: TName;\n // biome-ignore lint/suspicious/noExplicitAny: fallback for untyped events\n data: Record<string, any>;\n id: string;\n ts: number;\n v?: string;\n meta?: ReceivedEventMeta;\n } | null\n : // Case 3: event is a string with schema (spread EventType)\n TOpts extends {\n event: infer TName extends string;\n schema: StandardSchemaV1<\n infer TData extends Record<string, unknown>\n >;\n }\n ? {\n name: TName;\n data: TData;\n id: string;\n ts: number;\n v?: string;\n meta?: ReceivedEventMeta;\n } | null\n : // Case 4: event is just a string\n TOpts extends { event: infer TName extends string }\n ? {\n name: TName;\n // biome-ignore lint/suspicious/noExplicitAny: fallback for untyped events\n data: Record<string, any>;\n id: string;\n ts: number;\n v?: string;\n meta?: ReceivedEventMeta;\n } | null\n : EventPayload | null;\n\n/**\n * Options for `step.ai.infer()`.\n */\ntype AiInferOpts<TModel extends AiAdapter> = {\n /**\n * The model to use for the inference. Create a model by importing from\n * `\"inngest\"` or by using `step.ai.models.*`.\n *\n * @example Import `openai()`\n * ```ts\n * import { openai } from \"inngest\";\n *\n * const model = openai({ model: \"gpt-4\" });\n * ```\n *\n * @example Use a model from `step.ai.models`\n * ```ts\n * async ({ step }) => {\n * const model = step.ai.models.openai({ model: \"gpt-4\" });\n * }\n * ```\n */\n model: TModel;\n\n /**\n * The input to pass to the model.\n */\n body: AiAdapter.Input<TModel>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAuNA,MAAa,kBAAkB,YAA0C;AACvE,KAAI,OAAO,YAAY,SACrB,QAAO,EAAE,IAAI,SAAS;AAGxB,QAAO;;;;;AAMT,MAAa,uBAAuB;AAwBpC,MAAa,mBAIX,QACA,WACA,gBACG;;;;;;;CAQH,MAAM,cAUJ,SACA,SACM;EACN,MAAMA,kBAAgC,aAAa,GAAG,SAAS;GAC7D,MAAM,KAAK,QAAQ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components/ScoreFunction.ts
4
+ /**
5
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
6
+ * a major version bump.
7
+ *
8
+ * Create a typed scorer function. Wraps `createDefer`: the handler's
9
+ * return value is forwarded to `client.score(...)` inside a durable
10
+ * `step.run("score", ...)`. `runId` defaults to the parent run's id (from
11
+ * `event.data.parent.runId`) when the handler omits it. A nullish return
12
+ * is a no-op.
13
+ */
14
+ function createScorer(client, options, handler) {
15
+ return require_DeferredFunction.createDefer(client, options, async (ctx) => {
16
+ const result = await handler(ctx);
17
+ if (result) {
18
+ const parent = ctx.parents[0];
19
+ await ctx.step.run("score", async () => {
20
+ if (parent.experiment) await client.score.experiment({
21
+ experiment: parent.experiment,
22
+ runId: parent.runId,
23
+ ...result
24
+ });
25
+ else await client.score({
26
+ runId: parent.runId,
27
+ ...result
28
+ });
29
+ });
30
+ }
31
+ return result;
32
+ });
33
+ }
34
+
35
+ //#endregion
36
+ exports.createScorer = createScorer;
37
+ //# sourceMappingURL=ScoreFunction.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScoreFunction.cjs","names":["createDefer"],"sources":["../../src/components/ScoreFunction.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport {\n type CreateDeferInput,\n createDefer,\n type DeferContext,\n type DeferredFunction,\n} from \"./DeferredFunction.ts\";\nimport type { Inngest } from \"./Inngest.ts\";\nimport type { ScoreOptions } from \"./InngestScore.ts\";\nimport type { Middleware } from \"./middleware/index.ts\";\n\ntype ScorerResult =\n | (Omit<ScoreOptions, \"runId\"> & { runId?: string })\n | null\n | undefined;\n\n/**\n * EXPERIMENTAL: This API is not yet stable and may change in the future without\n * a major version bump.\n *\n * Create a typed scorer function. Wraps `createDefer`: the handler's\n * return value is forwarded to `client.score(...)` inside a durable\n * `step.run(\"score\", ...)`. `runId` defaults to the parent run's id (from\n * `event.data.parent.runId`) when the handler omits it. A nullish return\n * is a no-op.\n */\nexport function createScorer<\n TClient extends Inngest.Any,\n TSchema extends\n | StandardSchemaV1<Record<string, unknown>>\n | undefined = undefined,\n const TFnMiddleware extends Middleware.Class[] | undefined = undefined,\n>(\n client: TClient,\n options: CreateDeferInput<TFnMiddleware, TSchema>,\n handler: (\n ctx: DeferContext<TClient, TFnMiddleware, TSchema>,\n ) => ScorerResult | Promise<ScorerResult>,\n): DeferredFunction<TSchema> {\n return createDefer<TClient, TSchema, TFnMiddleware>(\n client,\n options,\n async (ctx) => {\n const result = await handler(ctx);\n if (result) {\n const parent = ctx.parents[0];\n await ctx.step.run(\"score\", async () => {\n if (parent.experiment) {\n await client.score.experiment({\n experiment: parent.experiment,\n runId: parent.runId,\n ...result,\n });\n } else {\n await client.score({ runId: parent.runId, ...result });\n }\n });\n }\n return result;\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,SAAgB,aAOd,QACA,SACA,SAG2B;AAC3B,QAAOA,qCACL,QACA,SACA,OAAO,QAAQ;EACb,MAAM,SAAS,MAAM,QAAQ,IAAI;AACjC,MAAI,QAAQ;GACV,MAAM,SAAS,IAAI,QAAQ;AAC3B,SAAM,IAAI,KAAK,IAAI,SAAS,YAAY;AACtC,QAAI,OAAO,WACT,OAAM,OAAO,MAAM,WAAW;KAC5B,YAAY,OAAO;KACnB,OAAO,OAAO;KACd,GAAG;KACJ,CAAC;QAEF,OAAM,OAAO,MAAM;KAAE,OAAO,OAAO;KAAO,GAAG;KAAQ,CAAC;KAExD;;AAEJ,SAAO;GAEV"}
@@ -0,0 +1,24 @@
1
+ import { ScoreOptions } from "./InngestScore.cjs";
2
+ import { Middleware } from "./middleware/middleware.cjs";
3
+ import { CreateDeferInput, DeferContext, DeferredFunction } from "./DeferredFunction.cjs";
4
+ import { Inngest } from "./Inngest.cjs";
5
+ import { StandardSchemaV1 } from "@standard-schema/spec";
6
+
7
+ //#region src/components/ScoreFunction.d.ts
8
+ type ScorerResult = (Omit<ScoreOptions, "runId"> & {
9
+ runId?: string;
10
+ }) | null | undefined;
11
+ /**
12
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
13
+ * a major version bump.
14
+ *
15
+ * Create a typed scorer function. Wraps `createDefer`: the handler's
16
+ * return value is forwarded to `client.score(...)` inside a durable
17
+ * `step.run("score", ...)`. `runId` defaults to the parent run's id (from
18
+ * `event.data.parent.runId`) when the handler omits it. A nullish return
19
+ * is a no-op.
20
+ */
21
+ declare function createScorer<TClient extends Inngest.Any, TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined = undefined, const TFnMiddleware extends Middleware.Class[] | undefined = undefined>(client: TClient, options: CreateDeferInput<TFnMiddleware, TSchema>, handler: (ctx: DeferContext<TClient, TFnMiddleware, TSchema>) => ScorerResult | Promise<ScorerResult>): DeferredFunction<TSchema>;
22
+ //#endregion
23
+ export { createScorer };
24
+ //# sourceMappingURL=ScoreFunction.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScoreFunction.d.cts","names":[],"sources":["../../src/components/ScoreFunction.ts"],"sourcesContent":[],"mappings":";;;;;;;KAWK,YAAA,IACA,KAAK;;AAH8C,CAAA,CAAA,GAEnD,IAAA,GAAA,SAAY;;;;;AAejB;;;;;;AAOU,iBAPM,YAON,CAAA,gBANQ,OAAA,CAAQ,GAMhB,EAAA,gBAJJ,gBAII,CAJa,MAIb,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,GAAA,SAAA,GAAA,SAAA,EAAA,4BAFoB,UAAA,CAAW,KAE/B,EAAA,GAAA,SAAA,GAAA,SAAA,CAAA,CAAA,MAAA,EAAA,OAAA,EAAA,OAAA,EACC,gBADD,CACkB,aADlB,EACiC,OADjC,CAAA,EAAA,OAAA,EAAA,CAAA,GAAA,EAGD,YAHC,CAGY,OAHZ,EAGqB,aAHrB,EAGoC,OAHpC,CAAA,EAAA,GAIH,YAJG,GAIY,OAJZ,CAIoB,YAJpB,CAAA,CAAA,EAKP,gBALO,CAKU,OALV,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { ScoreOptions } from "./InngestScore.js";
2
+ import { Middleware } from "./middleware/middleware.js";
3
+ import { CreateDeferInput, DeferContext, DeferredFunction } from "./DeferredFunction.js";
4
+ import { Inngest } from "./Inngest.js";
5
+ import { StandardSchemaV1 } from "@standard-schema/spec";
6
+
7
+ //#region src/components/ScoreFunction.d.ts
8
+ type ScorerResult = (Omit<ScoreOptions, "runId"> & {
9
+ runId?: string;
10
+ }) | null | undefined;
11
+ /**
12
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
13
+ * a major version bump.
14
+ *
15
+ * Create a typed scorer function. Wraps `createDefer`: the handler's
16
+ * return value is forwarded to `client.score(...)` inside a durable
17
+ * `step.run("score", ...)`. `runId` defaults to the parent run's id (from
18
+ * `event.data.parent.runId`) when the handler omits it. A nullish return
19
+ * is a no-op.
20
+ */
21
+ declare function createScorer<TClient extends Inngest.Any, TSchema extends StandardSchemaV1<Record<string, unknown>> | undefined = undefined, const TFnMiddleware extends Middleware.Class[] | undefined = undefined>(client: TClient, options: CreateDeferInput<TFnMiddleware, TSchema>, handler: (ctx: DeferContext<TClient, TFnMiddleware, TSchema>) => ScorerResult | Promise<ScorerResult>): DeferredFunction<TSchema>;
22
+ //#endregion
23
+ export { createScorer };
24
+ //# sourceMappingURL=ScoreFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScoreFunction.d.ts","names":[],"sources":["../../src/components/ScoreFunction.ts"],"sourcesContent":[],"mappings":";;;;;;;KAWK,YAAA,IACA,KAAK;;AAH8C,CAAA,CAAA,GAEnD,IAAA,GAAA,SAAY;;;;;AAejB;;;;;;AAOU,iBAPM,YAON,CAAA,gBANQ,OAAA,CAAQ,GAMhB,EAAA,gBAJJ,gBAII,CAJa,MAIb,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,GAAA,SAAA,GAAA,SAAA,EAAA,4BAFoB,UAAA,CAAW,KAE/B,EAAA,GAAA,SAAA,GAAA,SAAA,CAAA,CAAA,MAAA,EAAA,OAAA,EAAA,OAAA,EACC,gBADD,CACkB,aADlB,EACiC,OADjC,CAAA,EAAA,OAAA,EAAA,CAAA,GAAA,EAGD,YAHC,CAGY,OAHZ,EAGqB,aAHrB,EAGoC,OAHpC,CAAA,EAAA,GAIH,YAJG,GAIY,OAJZ,CAIoB,YAJpB,CAAA,CAAA,EAKP,gBALO,CAKU,OALV,CAAA"}
@@ -0,0 +1,37 @@
1
+ import { createDefer } from "./DeferredFunction.js";
2
+
3
+ //#region src/components/ScoreFunction.ts
4
+ /**
5
+ * EXPERIMENTAL: This API is not yet stable and may change in the future without
6
+ * a major version bump.
7
+ *
8
+ * Create a typed scorer function. Wraps `createDefer`: the handler's
9
+ * return value is forwarded to `client.score(...)` inside a durable
10
+ * `step.run("score", ...)`. `runId` defaults to the parent run's id (from
11
+ * `event.data.parent.runId`) when the handler omits it. A nullish return
12
+ * is a no-op.
13
+ */
14
+ function createScorer(client, options, handler) {
15
+ return createDefer(client, options, async (ctx) => {
16
+ const result = await handler(ctx);
17
+ if (result) {
18
+ const parent = ctx.parents[0];
19
+ await ctx.step.run("score", async () => {
20
+ if (parent.experiment) await client.score.experiment({
21
+ experiment: parent.experiment,
22
+ runId: parent.runId,
23
+ ...result
24
+ });
25
+ else await client.score({
26
+ runId: parent.runId,
27
+ ...result
28
+ });
29
+ });
30
+ }
31
+ return result;
32
+ });
33
+ }
34
+
35
+ //#endregion
36
+ export { createScorer };
37
+ //# sourceMappingURL=ScoreFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScoreFunction.js","names":[],"sources":["../../src/components/ScoreFunction.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport {\n type CreateDeferInput,\n createDefer,\n type DeferContext,\n type DeferredFunction,\n} from \"./DeferredFunction.ts\";\nimport type { Inngest } from \"./Inngest.ts\";\nimport type { ScoreOptions } from \"./InngestScore.ts\";\nimport type { Middleware } from \"./middleware/index.ts\";\n\ntype ScorerResult =\n | (Omit<ScoreOptions, \"runId\"> & { runId?: string })\n | null\n | undefined;\n\n/**\n * EXPERIMENTAL: This API is not yet stable and may change in the future without\n * a major version bump.\n *\n * Create a typed scorer function. Wraps `createDefer`: the handler's\n * return value is forwarded to `client.score(...)` inside a durable\n * `step.run(\"score\", ...)`. `runId` defaults to the parent run's id (from\n * `event.data.parent.runId`) when the handler omits it. A nullish return\n * is a no-op.\n */\nexport function createScorer<\n TClient extends Inngest.Any,\n TSchema extends\n | StandardSchemaV1<Record<string, unknown>>\n | undefined = undefined,\n const TFnMiddleware extends Middleware.Class[] | undefined = undefined,\n>(\n client: TClient,\n options: CreateDeferInput<TFnMiddleware, TSchema>,\n handler: (\n ctx: DeferContext<TClient, TFnMiddleware, TSchema>,\n ) => ScorerResult | Promise<ScorerResult>,\n): DeferredFunction<TSchema> {\n return createDefer<TClient, TSchema, TFnMiddleware>(\n client,\n options,\n async (ctx) => {\n const result = await handler(ctx);\n if (result) {\n const parent = ctx.parents[0];\n await ctx.step.run(\"score\", async () => {\n if (parent.experiment) {\n await client.score.experiment({\n experiment: parent.experiment,\n runId: parent.runId,\n ...result,\n });\n } else {\n await client.score({ runId: parent.runId, ...result });\n }\n });\n }\n return result;\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,SAAgB,aAOd,QACA,SACA,SAG2B;AAC3B,QAAO,YACL,QACA,SACA,OAAO,QAAQ;EACb,MAAM,SAAS,MAAM,QAAQ,IAAI;AACjC,MAAI,QAAQ;GACV,MAAM,SAAS,IAAI,QAAQ;AAC3B,SAAM,IAAI,KAAK,IAAI,SAAS,YAAY;AACtC,QAAI,OAAO,WACT,OAAM,OAAO,MAAM,WAAW;KAC5B,YAAY,OAAO;KACnB,OAAO,OAAO;KACd,GAAG;KACJ,CAAC;QAEF,OAAM,OAAO,MAAM;KAAE,OAAO,OAAO;KAAO,GAAG;KAAQ,CAAC;KAExD;;AAEJ,SAAO;GAEV"}
@@ -1,8 +1,8 @@
1
1
  import { ExecutionVersion } from "../../helpers/consts.cjs";
2
- import { MaybePromise, Simplify } from "../../helpers/types.cjs";
3
2
  import { ServerTiming } from "../../helpers/ServerTiming.cjs";
4
- import { Middleware } from "../middleware/middleware.cjs";
3
+ import { MaybePromise, Simplify } from "../../helpers/types.cjs";
5
4
  import { MetadataKind, MetadataOpcode, MetadataScope } from "../InngestMetadata.cjs";
5
+ import { Middleware } from "../middleware/middleware.cjs";
6
6
  import { InngestFunction } from "../InngestFunction.cjs";
7
7
  import { Context, IncomingOp, InternalCheckpointingOptions, OutgoingOp, StepMode } from "../../types.cjs";
8
8
  import { Inngest } from "../Inngest.cjs";
@@ -1,8 +1,8 @@
1
1
  import { ExecutionVersion } from "../../helpers/consts.js";
2
- import { MaybePromise, Simplify } from "../../helpers/types.js";
3
2
  import { ServerTiming } from "../../helpers/ServerTiming.js";
4
- import { Middleware } from "../middleware/middleware.js";
3
+ import { MaybePromise, Simplify } from "../../helpers/types.js";
5
4
  import { MetadataKind, MetadataOpcode, MetadataScope } from "../InngestMetadata.js";
5
+ import { Middleware } from "../middleware/middleware.js";
6
6
  import { InngestFunction } from "../InngestFunction.js";
7
7
  import { Context, IncomingOp, InternalCheckpointingOptions, OutgoingOp, StepMode } from "../../types.js";
8
8
  import { Inngest } from "../Inngest.js";
@@ -1 +1 @@
1
- {"version":3,"file":"als.cjs","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.cjs","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"}
@@ -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