inngest 4.24.0 → 4.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +176 -0
- package/components/InngestStepTools.cjs +22 -1
- package/components/InngestStepTools.cjs.map +1 -1
- package/components/InngestStepTools.d.cts.map +1 -1
- package/components/InngestStepTools.d.ts.map +1 -1
- package/components/InngestStepTools.js +22 -2
- package/components/InngestStepTools.js.map +1 -1
- package/components/execution/als.cjs.map +1 -1
- package/components/execution/als.d.cts +6 -0
- package/components/execution/als.d.cts.map +1 -1
- package/components/execution/als.d.ts +6 -0
- package/components/execution/als.d.ts.map +1 -1
- package/components/execution/als.js.map +1 -1
- package/components/execution/engine.cjs +36 -16
- package/components/execution/engine.cjs.map +1 -1
- package/components/execution/engine.d.cts.map +1 -1
- package/components/execution/engine.d.ts.map +1 -1
- package/components/execution/engine.js +36 -16
- package/components/execution/engine.js.map +1 -1
- package/components/execution/otel/middleware.d.cts +7 -7
- package/components/execution/otel/middleware.d.ts +7 -7
- package/components/realtime/types.d.cts +4 -4
- package/components/realtime/types.d.cts.map +1 -1
- package/components/realtime/types.d.ts +4 -4
- package/components/realtime/types.d.ts.map +1 -1
- package/components/sandbox/durable.cjs +111 -27
- package/components/sandbox/durable.cjs.map +1 -1
- package/components/sandbox/durable.js +109 -27
- package/components/sandbox/durable.js.map +1 -1
- package/components/sandbox/group.cjs +61 -27
- package/components/sandbox/group.cjs.map +1 -1
- package/components/sandbox/group.d.cts.map +1 -1
- package/components/sandbox/group.d.ts.map +1 -1
- package/components/sandbox/group.js +59 -28
- package/components/sandbox/group.js.map +1 -1
- package/components/sandbox/image.cjs +25 -0
- package/components/sandbox/image.cjs.map +1 -0
- package/components/sandbox/image.d.cts +32 -0
- package/components/sandbox/image.d.cts.map +1 -0
- package/components/sandbox/image.d.ts +32 -0
- package/components/sandbox/image.d.ts.map +1 -0
- package/components/sandbox/image.js +23 -0
- package/components/sandbox/image.js.map +1 -0
- package/components/sandbox/middleware.cjs +90 -38
- package/components/sandbox/middleware.cjs.map +1 -1
- package/components/sandbox/middleware.d.cts +5 -1
- package/components/sandbox/middleware.d.cts.map +1 -1
- package/components/sandbox/middleware.d.ts +5 -1
- package/components/sandbox/middleware.d.ts.map +1 -1
- package/components/sandbox/middleware.js +90 -38
- package/components/sandbox/middleware.js.map +1 -1
- package/components/sandbox/protocol.cjs +27 -0
- package/components/sandbox/protocol.cjs.map +1 -1
- package/components/sandbox/protocol.d.cts.map +1 -1
- package/components/sandbox/protocol.d.ts.map +1 -1
- package/components/sandbox/protocol.js +28 -1
- package/components/sandbox/protocol.js.map +1 -1
- package/components/sandbox/runnerScripts.cjs +214 -0
- package/components/sandbox/runnerScripts.cjs.map +1 -0
- package/components/sandbox/runnerScripts.js +213 -0
- package/components/sandbox/runnerScripts.js.map +1 -0
- package/components/sandbox/runners.cjs +113 -0
- package/components/sandbox/runners.cjs.map +1 -0
- package/components/sandbox/runners.d.cts +45 -0
- package/components/sandbox/runners.d.cts.map +1 -0
- package/components/sandbox/runners.d.ts +45 -0
- package/components/sandbox/runners.d.ts.map +1 -0
- package/components/sandbox/runners.js +113 -0
- package/components/sandbox/runners.js.map +1 -0
- package/components/sandbox/toolRunner.cjs +321 -0
- package/components/sandbox/toolRunner.cjs.map +1 -0
- package/components/sandbox/toolRunner.js +319 -0
- package/components/sandbox/toolRunner.js.map +1 -0
- package/components/sandbox/toolStubs.cjs +187 -0
- package/components/sandbox/toolStubs.cjs.map +1 -0
- package/components/sandbox/toolStubs.js +185 -0
- package/components/sandbox/toolStubs.js.map +1 -0
- package/components/sandbox/tools.cjs +173 -0
- package/components/sandbox/tools.cjs.map +1 -0
- package/components/sandbox/tools.d.cts +142 -0
- package/components/sandbox/tools.d.cts.map +1 -0
- package/components/sandbox/tools.d.ts +142 -0
- package/components/sandbox/tools.d.ts.map +1 -0
- package/components/sandbox/tools.js +166 -0
- package/components/sandbox/tools.js.map +1 -0
- package/components/sandbox/trace.cjs +7 -0
- package/components/sandbox/trace.cjs.map +1 -1
- package/components/sandbox/trace.js +7 -1
- package/components/sandbox/trace.js.map +1 -1
- package/components/sandbox/types.cjs.map +1 -1
- package/components/sandbox/types.d.cts +37 -2
- package/components/sandbox/types.d.cts.map +1 -1
- package/components/sandbox/types.d.ts +37 -2
- package/components/sandbox/types.d.ts.map +1 -1
- package/components/sandbox/types.js.map +1 -1
- package/components/sandbox/validation.cjs +21 -1
- package/components/sandbox/validation.cjs.map +1 -1
- package/components/sandbox/validation.js +19 -2
- package/components/sandbox/validation.js.map +1 -1
- package/experimental.cjs +5 -1
- package/experimental.d.cts +4 -1
- package/experimental.d.ts +4 -1
- package/experimental.js +3 -1
- package/package.json +2 -1
- package/version.cjs +1 -1
- package/version.cjs.map +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,181 @@
|
|
|
1
1
|
# inngest
|
|
2
2
|
|
|
3
|
+
## 4.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1802](https://github.com/inngest/inngest-js/pull/1802) [`40af8b5b`](https://github.com/inngest/inngest-js/commit/40af8b5b30293ab748eb51fcd600371ab89e1257) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Choose the image a sandbox starts from with `image.inngest()` or `image.custom()`, exported from `inngest/experimental`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { image } from "inngest/experimental";
|
|
11
|
+
|
|
12
|
+
await step.sandbox.create("build", {
|
|
13
|
+
name: "build",
|
|
14
|
+
vcpu: 2,
|
|
15
|
+
memoryMb: 2048,
|
|
16
|
+
from: image.inngest("base"),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
await step.sandbox.create("custom", {
|
|
20
|
+
name: "custom",
|
|
21
|
+
vcpu: 2,
|
|
22
|
+
memoryMb: 2048,
|
|
23
|
+
from: image.custom("my-image:v1"),
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- [#1756](https://github.com/inngest/inngest-js/pull/1756) [`5dc1279d`](https://github.com/inngest/inngest-js/commit/5dc1279d6b45dfe1e29c91f0e2283d8775d7a51c) Thanks [@jakobevangelista](https://github.com/jakobevangelista)! - Select an already-published image with `image` in `inngest.sandboxes.create()` or `step.sandbox.create()`. Names, tags, and artifact SHA-256 references are supported. Omission keeps the default base image; snapshot clones retain their source image and cannot select another. Sandbox resources expose an optional `imageDigest` containing the pinned artifact digest.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [#1801](https://github.com/inngest/inngest-js/pull/1801) [`023ebfa3`](https://github.com/inngest/inngest-js/commit/023ebfa3eb279e3b0364c354647d0dd6813998eb) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Functions using `optimizeParallelism: false` once again complete the run when the function returns, as they did in v3. In v4 this changed unintentionally: the run waited for steps you started but never awaited. If you don't use `optimizeParallelism: false`, nothing changes.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
inngest.createFunction(
|
|
35
|
+
{
|
|
36
|
+
id: "example",
|
|
37
|
+
optimizeParallelism: false,
|
|
38
|
+
triggers: [{ event: "app/example" }],
|
|
39
|
+
},
|
|
40
|
+
async ({ step }) => {
|
|
41
|
+
step.sleep("unused", "7d");
|
|
42
|
+
|
|
43
|
+
return "done";
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- [#1791](https://github.com/inngest/inngest-js/pull/1791) [`b112a09e`](https://github.com/inngest/inngest-js/commit/b112a09e8f1cff2a836bfc82626bf18a32c4c7a4) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Experimental: code running in a sandbox can now call functions in your app. Pass `tools` to `commands.run`, and each call the code makes runs your function as its own durable step, so it's retried and memoized like any other step.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
await sandbox.commands.run("agent", "node agent.js", {
|
|
52
|
+
tools: {
|
|
53
|
+
getCustomer: (id: string) => db.customers.find(id),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
// agent.js, inside the sandbox
|
|
60
|
+
const { tools } = require("inngest_tools");
|
|
61
|
+
const customer = await tools.getCustomer("cus_1");
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
In Python, use `from inngest_tools import tools` and `await tools.getCustomer("cus_1")`. A tool that fails raises a `ToolError` the code can catch.
|
|
65
|
+
|
|
66
|
+
- [#1783](https://github.com/inngest/inngest-js/pull/1783) [`167709c6`](https://github.com/inngest/inngest-js/commit/167709c6322b6a1104ce677b2529a4041546e481) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Experimental: you can now run Python in a sandbox with `step.sandbox.python`, available with `sandboxMiddleware()`. It creates a sandbox, runs your code, and destroys it, and a top-level `return` gives the result back. Pass data in with `input`: each key becomes a variable. A non-zero exit fails the step with the error output. Code and input of any size work, and results can be as large as a step can return.
|
|
67
|
+
|
|
68
|
+
Pass a schema as `schema.output` to validate the result: it's typed from the schema (as its JSON form, like `step.run`), and a result that doesn't match fails the step with the schema's issues.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const stats = await step.sandbox.python(
|
|
72
|
+
"stats",
|
|
73
|
+
`import statistics
|
|
74
|
+
return {"mean": statistics.mean(values)}`,
|
|
75
|
+
{
|
|
76
|
+
input: { values: [1, 2, 3, 4] },
|
|
77
|
+
schema: { output: z.object({ mean: z.number() }) },
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Like any other step, it takes a step ID or step options, such as `{ id: "stats", name: "Compute the mean" }`, as its first argument.
|
|
83
|
+
|
|
84
|
+
- [#1787](https://github.com/inngest/inngest-js/pull/1787) [`dc120418`](https://github.com/inngest/inngest-js/commit/dc1204183c601163b1c4cac3b4330f337d551637) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Experimental: inline sandbox runner code can be indented to match your source; it's dedented before it runs.
|
|
85
|
+
|
|
86
|
+
- [#1793](https://github.com/inngest/inngest-js/pull/1793) [`27b3631c`](https://github.com/inngest/inngest-js/commit/27b3631c0ad03c9fc9800393877592bca3d4b1d3) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Experimental: `step.sandbox.python` and `step.sandbox.typescript` now take `tools`. The code calls them as `tools.name(...)` with no import, and each call runs your function as a durable step.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
const total = await step.sandbox.python(
|
|
90
|
+
"total",
|
|
91
|
+
`customer = await tools.getCustomer("cus_1")
|
|
92
|
+
return customer["seats"] * 10`,
|
|
93
|
+
{
|
|
94
|
+
tools: { getCustomer: (id: string) => db.customers.find(id) },
|
|
95
|
+
schema: { output: z.number() },
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- [#1795](https://github.com/inngest/inngest-js/pull/1795) [`e308aaa3`](https://github.com/inngest/inngest-js/commit/e308aaa398a7d406875867fdf0c73b5e5e731d5d) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Experimental: sandbox code can now call `tool.group()` tools, whose body is a group of real steps. Run steps in parallel, invoke other functions and use their result, send events, or wait for one, all from a single tool call.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { step } from "inngest";
|
|
104
|
+
import { tool } from "inngest/experimental";
|
|
105
|
+
|
|
106
|
+
const refund = tool.group({
|
|
107
|
+
input: z.object({ orderId: z.string() }),
|
|
108
|
+
run: async ({ orderId }) => {
|
|
109
|
+
const result = await step.invoke("refund", {
|
|
110
|
+
function: refundFn,
|
|
111
|
+
data: { orderId },
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
await step.sendEvent("notify", { name: "order/refunded", data: result });
|
|
115
|
+
|
|
116
|
+
return result;
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- [#1796](https://github.com/inngest/inngest-js/pull/1796) [`0cc19e58`](https://github.com/inngest/inngest-js/commit/0cc19e585daaf263adfae5fc7321491f7e45f124) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Experimental: an Inngest function, or a `referenceFunction()` to one, can now be a sandbox tool. The code calls it with named arguments, which become the event data, and gets the function's result back. The invoke is a durable step.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { eventType } from "inngest";
|
|
125
|
+
|
|
126
|
+
const refund = inngest.createFunction(
|
|
127
|
+
{
|
|
128
|
+
id: "refund",
|
|
129
|
+
triggers: [
|
|
130
|
+
eventType("order/refund", {
|
|
131
|
+
schema: z.object({ orderId: z.string() }),
|
|
132
|
+
}),
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
async ({ event }) => issueRefund(event.data.orderId),
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
await sandbox.commands.run("agent", "node agent.js", {
|
|
139
|
+
tools: { refund },
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The arguments are checked against the function's trigger schema when it has one. Without a schema, any named arguments are sent; wrap the invoke in `tool.group()` to declare the input you want.
|
|
144
|
+
|
|
145
|
+
- [#1794](https://github.com/inngest/inngest-js/pull/1794) [`80016cf0`](https://github.com/inngest/inngest-js/commit/80016cf05b6181da08efeb474b63cf3de0755fef) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Experimental: declare a sandbox tool with `tool.step()` to give it typed, named arguments. The `input` schema is checked before anything runs, so a bad call gets a `ToolError` back in the sandbox, and `output` checks the result. A plain function in `tools` still works, and takes positional arguments.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import { tool } from "inngest/experimental";
|
|
149
|
+
|
|
150
|
+
const getCustomer = tool.step({
|
|
151
|
+
input: z.object({ id: z.string() }),
|
|
152
|
+
output: z.object({ name: z.string() }),
|
|
153
|
+
run: async ({ id }) => db.customers.find(id),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
await sandbox.commands.run("agent", "node agent.js", {
|
|
157
|
+
tools: { getCustomer },
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
// agent.js, inside the sandbox
|
|
163
|
+
const { tools } = require("inngest_tools");
|
|
164
|
+
const customer = await tools.getCustomer({ id: "cus_1" });
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
`tool.step()` works with `commands.run` and with the Python and TypeScript runners. Its body also receives an idempotency key that stays the same across retries, for APIs that deduplicate writes.
|
|
168
|
+
|
|
169
|
+
- [#1784](https://github.com/inngest/inngest-js/pull/1784) [`f5b71099`](https://github.com/inngest/inngest-js/commit/f5b71099489c6db3a806de55b7f3471eeed0dd3d) Thanks [@jpwilliams](https://github.com/jpwilliams)! - Experimental: you can now run TypeScript in a sandbox with `step.sandbox.typescript`, available with `sandboxMiddleware()`. `input` keys become variables, a top-level `return` gives the result back, and top-level `await` works. It takes the same `schema.output` as `step.sandbox.python` to validate and type the result. The sandbox image needs Node 22.13 or later.
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
const total = await step.sandbox.typescript(
|
|
173
|
+
"sum",
|
|
174
|
+
`return numbers.reduce((a: number, b: number) => a + b, 0)`,
|
|
175
|
+
{ input: { numbers: [1, 2, 3] } },
|
|
176
|
+
);
|
|
177
|
+
```
|
|
178
|
+
|
|
3
179
|
## 4.24.0
|
|
4
180
|
|
|
5
181
|
### Minor Changes
|
|
@@ -58,6 +58,21 @@ const withSpan = (span, callback) => {
|
|
|
58
58
|
}, callback);
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
|
+
* Run a callback whose steps get `prefix` before their IDs, so concurrent
|
|
62
|
+
* callers can use the same IDs.
|
|
63
|
+
*/
|
|
64
|
+
const withStepIdPrefix = (prefix, callback) => {
|
|
65
|
+
const currentCtx = require_als.getAsyncCtxSync();
|
|
66
|
+
if (!currentCtx?.execution) return callback();
|
|
67
|
+
return require_als.runWithAsyncCtx({
|
|
68
|
+
...currentCtx,
|
|
69
|
+
execution: {
|
|
70
|
+
...currentCtx.execution,
|
|
71
|
+
stepIdPrefix: `${currentCtx.execution.stepIdPrefix ?? ""}${prefix}`
|
|
72
|
+
}
|
|
73
|
+
}, callback);
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
61
76
|
* Suffix used to namespace steps that are automatically indexed.
|
|
62
77
|
*/
|
|
63
78
|
const STEP_INDEXING_SUFFIX = ":";
|
|
@@ -70,8 +85,13 @@ const createStepTools = (client, execution, stepHandler) => {
|
|
|
70
85
|
*/
|
|
71
86
|
const createTool = (matchOp, opts) => {
|
|
72
87
|
const wrappedMatchOp = (stepOptions, ...rest) => {
|
|
73
|
-
const op = matchOp(stepOptions, ...rest);
|
|
74
88
|
const alsCtx = require_als.getAsyncCtxSync()?.execution;
|
|
89
|
+
const prefix = alsCtx?.stepIdPrefix;
|
|
90
|
+
const op = matchOp(prefix ? {
|
|
91
|
+
...stepOptions,
|
|
92
|
+
id: `${prefix}${stepOptions.id}`,
|
|
93
|
+
name: stepOptions.name ?? stepOptions.id
|
|
94
|
+
} : stepOptions, ...rest);
|
|
75
95
|
if (alsCtx?.insideExperimentSelect) throw new require_NonRetriableError.NonRetriableError("Step tools (step.run, step.sleep, etc.) cannot be called inside an experiment select() callback. Move step calls into variant callbacks instead.");
|
|
76
96
|
const parallelMode = stepOptions.parallelMode ?? alsCtx?.parallelMode;
|
|
77
97
|
if (parallelMode) op.opts = {
|
|
@@ -478,4 +498,5 @@ exports.getStepOptions = getStepOptions;
|
|
|
478
498
|
exports.group = group;
|
|
479
499
|
exports.step = step;
|
|
480
500
|
exports.withSpan = withSpan;
|
|
501
|
+
exports.withStepIdPrefix = withStepIdPrefix;
|
|
481
502
|
//# sourceMappingURL=InngestStepTools.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestStepTools.cjs","names":["getAsyncCtxSync","runWithAsyncCtx","wrappedMatchOp: MatchOpFn<T>","NonRetriableError","opts: HashedOp[\"opts\"]","StepMode","StepOpCode","UnscopedMetadataBuilder","createStepScoreWrapper: ScoreStepTool","sendStepScore","sessionPropagationSymbol","stampPropagatedSessions","timeStr","internalLoggerSymbol","matchOpts: { timeout: string; if?: string }","models","msTimeStr: string","z","v","InngestFunction","InngestFunctionReference","opts: {\n payload: typeof payload;\n function_id: string;\n timeout?: string;\n }","normalizeEventMeta","stepFetch","metadataSymbol","scoreSymbol","headers: Record<string, string>","step: GenericStepTools","getAsyncCtx","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 { Jsonify } from \"../helpers/jsonify.ts\";\nimport {\n normalizeEventMeta,\n stampPropagatedSessions,\n} 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 type SendSignalResponse,\n StepMode,\n StepOpCode,\n type StepOptions,\n type StepOptionsOrId,\n type StepSpan,\n type TriggerEventFromFunction,\n} from \"../types.ts\";\nimport {\n getAsyncCtx,\n getAsyncCtxSync,\n runWithAsyncCtx,\n} 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 sessionPropagationSymbol,\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 * The origin a step or nested span in `path` inherits. Each span in a path\n * already carries its effective origin, so the innermost span's is the answer.\n * See `StepOptions[\"~origin\"]`.\n */\nconst spanOrigin = (path: StepSpan[] | undefined): string | undefined => {\n return path?.[path.length - 1]?.origin;\n};\n\n/**\n * Append a span to a span path, naming it by its ID if it has no name. `kind`\n * is only sent when given. A span without its own `origin` takes the origin of\n * its parent, so `origin` is only sent when one is in scope.\n */\nconst appendSpan = (\n path: (StepSpan & { name: string })[] | undefined,\n span: StepSpan,\n): (StepSpan & { name: string })[] => {\n const { id, name = id, kind } = span;\n const origin = span.origin ?? spanOrigin(path);\n\n return [\n ...(path ?? []),\n { id, name, ...(kind ? { kind } : {}), ...(origin ? { origin } : {}) },\n ];\n};\n\n/**\n * Run a callback with `span` appended to the current span path, so steps\n * created within it carry the path. See `GroupTools[\"~span\"]`.\n */\nexport const withSpan = <T>(span: StepSpan, callback: () => T): T => {\n const currentCtx = getAsyncCtxSync();\n\n if (!currentCtx?.execution) {\n return callback();\n }\n\n return runWithAsyncCtx(\n {\n ...currentCtx,\n execution: {\n ...currentCtx.execution,\n span: appendSpan(currentCtx.execution.span, span),\n },\n },\n callback,\n );\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 // The span option nests inside the `group[\"~span\"]()` scope, if any\n const span = stepOptions[\"~span\"]\n ? appendSpan(alsCtx?.span, stepOptions[\"~span\"])\n : alsCtx?.span;\n\n if (span) {\n op.opts = { ...op.opts, span };\n }\n\n // The step's own origin wins, then the innermost span's\n const origin = stepOptions[\"~origin\"] ?? spanOrigin(span);\n\n if (origin) {\n op.opts = { ...op.opts, origin };\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 set: async (\n values: Record<string, unknown>,\n kind = \"default\",\n ): Promise<void> => {\n await tools.run(memoizationId, async () => {\n await builder.set(values, kind);\n });\n },\n /**\n * @deprecated Use `set()` instead. See `MetadataBuilder.update()`.\n */\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 // Only stamp inherited sessions when the client-level toggle is on.\n //\n // `_send` also stamps from the ambient run context, so for a Node\n // runtime this is redundant — but deliberately so: it stamps\n // synchronously from the direct `ctx`, and so still works on runtimes\n // where `_send`'s AsyncLocalStorage read comes back empty. `_send`\n // leaves this stamp authoritative.\n const payloadToSend = client[sessionPropagationSymbol]\n ? stampPropagatedSessions(payload, ctx.sessions)\n : payload;\n return client[\"_send\"]({\n payload: payloadToSend,\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, client[internalLoggerSymbol]),\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<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 * Durations of less than 1 second round up to `1s`, the minimum\n * resolution of a durable wait.\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(\n typeof opts === \"string\" ? opts : opts.timeout,\n client[internalLoggerSymbol],\n ),\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 * Durations of less than 1 second round up to `1s`, the minimum\n * resolution of a durable wait.\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, client[internalLoggerSymbol]);\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:\n typeof timeout === \"undefined\"\n ? undefined\n : timeStr(timeout, client[internalLoggerSymbol]),\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 \"~span\": withSpan,\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 // Manual layer: RFC 7386 patch — a whole-field `null` clears all\n // inherited sessions, so it must parse. Values stay loose here because\n // `normalizeEventSessions` validates them right after the parse with\n // precise per-key errors; tightening them in zod would mask those behind\n // the generic invoke-options error.\n sessions: z.record(z.any()).nullable().optional(),\n // Machine-stamped layer: string/number ids only, never tombstones.\n propagated_sessions: z\n .record(z.union([z.string(), z.number()]))\n .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 * By default the invoked run inherits the calling run's sessions. The\n * `meta.propagated_sessions` layer is stamped automatically from\n * `ctx.sessions`.\n *\n * Pass `meta.sessions` to add or override sessions on the invocation.\n *\n * Inheritance can be disabled at the client level.\n *\n * Values are normalized to strings before sending, as with\n * `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 * Durations of less than 1 second round up to `1s`, the minimum\n * resolution of a durable wait.\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 * Durations of less than 1 second round up to `1s`, the minimum\n * resolution of a durable wait.\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":";;;;;;;;;;;;;;;;;AAgOA,MAAa,kBAAkB,YAA0C;AACvE,KAAI,OAAO,YAAY,SACrB,QAAO,EAAE,IAAI,SAAS;AAGxB,QAAO;;;;;;;AAQT,MAAM,cAAc,SAAqD;AACvE,QAAO,OAAO,KAAK,SAAS,IAAI;;;;;;;AAQlC,MAAM,cACJ,MACA,SACoC;CACpC,MAAM,EAAE,IAAI,OAAO,IAAI,SAAS;CAChC,MAAM,SAAS,KAAK,UAAU,WAAW,KAAK;AAE9C,QAAO,CACL,GAAI,QAAQ,EAAE,EACd;EAAE;EAAI;EAAM,GAAI,OAAO,EAAE,MAAM,GAAG,EAAE;EAAG,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;EAAG,CACvE;;;;;;AAOH,MAAa,YAAe,MAAgB,aAAyB;CACnE,MAAM,aAAaA,6BAAiB;AAEpC,KAAI,CAAC,YAAY,UACf,QAAO,UAAU;AAGnB,QAAOC,4BACL;EACE,GAAG;EACH,WAAW;GACT,GAAG,WAAW;GACd,MAAM,WAAW,WAAW,UAAU,MAAM,KAA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D;AAKH,QAAO,IAAI,UAAU,IAAI;;AAG3B,MAAM,0BAA0B,YAAiC;CAC/D,MAAM,MAAM,MAAMA,yBAAa;AAC/B,KAAI,CAAC,IACH,OAAM,IAAI,MACR,0FACD;AAGH,KAAI,CAAC,IAAI,UACP,OAAM,IAAI,MACR,oGACD;AAGH,QAAO,IAAI,UAAU,IAAI;;;;;;;AAQ3B,MAAaC,QAAoB;CAC/B,WAAW,GAAG,SACZ,yBAAyB,CAAC,MAAM,UAAU,MAAM,SAAS,GAAG,KAAK,CAAC;CACpE,aAAa,GAAG,SACd,yBAAyB,CAAC,MAAM,UAAU,MAAM,WAAW,GAAG,KAAK,CAAC;CACtE,SAAS;CACV;;;;;AAMD,MAAa,sBAAsBZ,SAAE,OAAO;CAC1C,MAAMA,SAAE,OAAOA,SAAE,KAAK,CAAC,CAAC,UAAU;CAClC,GAAGA,SAAE,QAAQ,CAAC,UAAU;CACxB,MAAMA,SACH,OAAO;EAMN,UAAUA,SAAE,OAAOA,SAAE,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU;EAEjD,qBAAqBA,SAClB,OAAOA,SAAE,MAAM,CAACA,SAAE,QAAQ,EAAEA,SAAE,QAAQ,CAAC,CAAC,CAAC,CACzC,UAAU;EACd,CAAC,CACD,UAAU;CACd,CAAC"}
|
|
1
|
+
{"version":3,"file":"InngestStepTools.cjs","names":["getAsyncCtxSync","runWithAsyncCtx","wrappedMatchOp: MatchOpFn<T>","NonRetriableError","opts: HashedOp[\"opts\"]","StepMode","StepOpCode","UnscopedMetadataBuilder","createStepScoreWrapper: ScoreStepTool","sendStepScore","sessionPropagationSymbol","stampPropagatedSessions","timeStr","internalLoggerSymbol","matchOpts: { timeout: string; if?: string }","models","msTimeStr: string","z","v","InngestFunction","InngestFunctionReference","opts: {\n payload: typeof payload;\n function_id: string;\n timeout?: string;\n }","normalizeEventMeta","stepFetch","metadataSymbol","scoreSymbol","headers: Record<string, string>","step: GenericStepTools","getAsyncCtx","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 { Jsonify } from \"../helpers/jsonify.ts\";\nimport {\n normalizeEventMeta,\n stampPropagatedSessions,\n} 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 type SendSignalResponse,\n StepMode,\n StepOpCode,\n type StepOptions,\n type StepOptionsOrId,\n type StepSpan,\n type TriggerEventFromFunction,\n} from \"../types.ts\";\nimport {\n getAsyncCtx,\n getAsyncCtxSync,\n runWithAsyncCtx,\n} 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 sessionPropagationSymbol,\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 * The origin a step or nested span in `path` inherits. Each span in a path\n * already carries its effective origin, so the innermost span's is the answer.\n * See `StepOptions[\"~origin\"]`.\n */\nconst spanOrigin = (path: StepSpan[] | undefined): string | undefined => {\n return path?.[path.length - 1]?.origin;\n};\n\n/**\n * Append a span to a span path, naming it by its ID if it has no name. `kind`\n * is only sent when given. A span without its own `origin` takes the origin of\n * its parent, so `origin` is only sent when one is in scope.\n */\nconst appendSpan = (\n path: (StepSpan & { name: string })[] | undefined,\n span: StepSpan,\n): (StepSpan & { name: string })[] => {\n const { id, name = id, kind } = span;\n const origin = span.origin ?? spanOrigin(path);\n\n return [\n ...(path ?? []),\n { id, name, ...(kind ? { kind } : {}), ...(origin ? { origin } : {}) },\n ];\n};\n\n/**\n * Run a callback with `span` appended to the current span path, so steps\n * created within it carry the path. See `GroupTools[\"~span\"]`.\n */\nexport const withSpan = <T>(span: StepSpan, callback: () => T): T => {\n const currentCtx = getAsyncCtxSync();\n\n if (!currentCtx?.execution) {\n return callback();\n }\n\n return runWithAsyncCtx(\n {\n ...currentCtx,\n execution: {\n ...currentCtx.execution,\n span: appendSpan(currentCtx.execution.span, span),\n },\n },\n callback,\n );\n};\n\n/**\n * Run a callback whose steps get `prefix` before their IDs, so concurrent\n * callers can use the same IDs.\n */\nexport const withStepIdPrefix = <T>(prefix: string, callback: () => T): T => {\n const currentCtx = getAsyncCtxSync();\n\n if (!currentCtx?.execution) {\n return callback();\n }\n\n return runWithAsyncCtx(\n {\n ...currentCtx,\n execution: {\n ...currentCtx.execution,\n stepIdPrefix: `${currentCtx.execution.stepIdPrefix ?? \"\"}${prefix}`,\n },\n },\n callback,\n );\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 alsCtx = getAsyncCtxSync()?.execution;\n const prefix = alsCtx?.stepIdPrefix;\n const op = matchOp(\n prefix\n ? {\n ...stepOptions,\n id: `${prefix}${stepOptions.id}`,\n name: stepOptions.name ?? stepOptions.id,\n }\n : stepOptions,\n ...rest,\n );\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 // The span option nests inside the `group[\"~span\"]()` scope, if any\n const span = stepOptions[\"~span\"]\n ? appendSpan(alsCtx?.span, stepOptions[\"~span\"])\n : alsCtx?.span;\n\n if (span) {\n op.opts = { ...op.opts, span };\n }\n\n // The step's own origin wins, then the innermost span's\n const origin = stepOptions[\"~origin\"] ?? spanOrigin(span);\n\n if (origin) {\n op.opts = { ...op.opts, origin };\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 set: async (\n values: Record<string, unknown>,\n kind = \"default\",\n ): Promise<void> => {\n await tools.run(memoizationId, async () => {\n await builder.set(values, kind);\n });\n },\n /**\n * @deprecated Use `set()` instead. See `MetadataBuilder.update()`.\n */\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 // Only stamp inherited sessions when the client-level toggle is on.\n //\n // `_send` also stamps from the ambient run context, so for a Node\n // runtime this is redundant — but deliberately so: it stamps\n // synchronously from the direct `ctx`, and so still works on runtimes\n // where `_send`'s AsyncLocalStorage read comes back empty. `_send`\n // leaves this stamp authoritative.\n const payloadToSend = client[sessionPropagationSymbol]\n ? stampPropagatedSessions(payload, ctx.sessions)\n : payload;\n return client[\"_send\"]({\n payload: payloadToSend,\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, client[internalLoggerSymbol]),\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<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 * Durations of less than 1 second round up to `1s`, the minimum\n * resolution of a durable wait.\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(\n typeof opts === \"string\" ? opts : opts.timeout,\n client[internalLoggerSymbol],\n ),\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 * Durations of less than 1 second round up to `1s`, the minimum\n * resolution of a durable wait.\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, client[internalLoggerSymbol]);\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:\n typeof timeout === \"undefined\"\n ? undefined\n : timeStr(timeout, client[internalLoggerSymbol]),\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 \"~span\": withSpan,\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 // Manual layer: RFC 7386 patch — a whole-field `null` clears all\n // inherited sessions, so it must parse. Values stay loose here because\n // `normalizeEventSessions` validates them right after the parse with\n // precise per-key errors; tightening them in zod would mask those behind\n // the generic invoke-options error.\n sessions: z.record(z.any()).nullable().optional(),\n // Machine-stamped layer: string/number ids only, never tombstones.\n propagated_sessions: z\n .record(z.union([z.string(), z.number()]))\n .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 * By default the invoked run inherits the calling run's sessions. The\n * `meta.propagated_sessions` layer is stamped automatically from\n * `ctx.sessions`.\n *\n * Pass `meta.sessions` to add or override sessions on the invocation.\n *\n * Inheritance can be disabled at the client level.\n *\n * Values are normalized to strings before sending, as with\n * `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 * Durations of less than 1 second round up to `1s`, the minimum\n * resolution of a durable wait.\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 * Durations of less than 1 second round up to `1s`, the minimum\n * resolution of a durable wait.\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":";;;;;;;;;;;;;;;;;AAgOA,MAAa,kBAAkB,YAA0C;AACvE,KAAI,OAAO,YAAY,SACrB,QAAO,EAAE,IAAI,SAAS;AAGxB,QAAO;;;;;;;AAQT,MAAM,cAAc,SAAqD;AACvE,QAAO,OAAO,KAAK,SAAS,IAAI;;;;;;;AAQlC,MAAM,cACJ,MACA,SACoC;CACpC,MAAM,EAAE,IAAI,OAAO,IAAI,SAAS;CAChC,MAAM,SAAS,KAAK,UAAU,WAAW,KAAK;AAE9C,QAAO,CACL,GAAI,QAAQ,EAAE,EACd;EAAE;EAAI;EAAM,GAAI,OAAO,EAAE,MAAM,GAAG,EAAE;EAAG,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;EAAG,CACvE;;;;;;AAOH,MAAa,YAAe,MAAgB,aAAyB;CACnE,MAAM,aAAaA,6BAAiB;AAEpC,KAAI,CAAC,YAAY,UACf,QAAO,UAAU;AAGnB,QAAOC,4BACL;EACE,GAAG;EACH,WAAW;GACT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1
|
-
{"version":3,"file":"InngestStepTools.d.cts","names":[],"sources":["../../src/components/InngestStepTools.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgFA;;;;;;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;
|
|
1
|
+
{"version":3,"file":"InngestStepTools.d.cts","names":[],"sources":["../../src/components/InngestStepTools.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgFA;;;;;;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;EAqGvC;;;;;;;;;cAOC,EAAA,OAAA;SAAsB,EAAA,OAAW;;;AAGvC;EAg1BC,OAAA,EAthCU,OAshCV,CAAA,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;;;;;8BAuBH,OACA,eACA,cACA;;;;;KAML,cAAA;;;;;;;;;;;;;KAeA,iBAAA;;;;;;;;;;;;;;;;;;;;6BAwBC,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InngestStepTools.d.ts","names":[],"sources":["../../src/components/InngestStepTools.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgFA;;;;;;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;
|
|
1
|
+
{"version":3,"file":"InngestStepTools.d.ts","names":[],"sources":["../../src/components/InngestStepTools.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgFA;;;;;;AAsBiB,UAtBA,qBAAA,CAsBU;EAAA;;;;;;EAAgB,gBAAA,EAAA,CAAA,OAAA,EAAA,GAAA,GAfP,OAeO,CAAA,OAAA,CAAA,EAAA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AKP,gBAAgB,cAAuB,sBAC1C;;;;;;6BAyCc,6CACJ,uBACP,eAAe,eAClB,iBACH,6BACE,iBAAiB,SAAS,gBAC1B,qBAAqB;;;;;;;;SAHJ;;;;;;KA2Jf,gBAAA,GAAmB,aAAa,OAAA,CAAQ;KAexC,qBAAA,GAAwB,aAAa,OAAA,CAAQ;GACtD,cAAA,8BAA4C;GAC5C,WAAA,GAAc;;;;;;;;;;;;;cAuBJ,MAAM;;;;;;cAwFN,OAAO;KA+Bf,uCAAuC;YAChC;;KAGP,iCAAiC,kCACpC,qBAAqB,aACnB,KAAK,yBAAyB;;;;;;;;;;;;;;;SAerB;;;;;;;;;;;;;;;;;;;8BAuBH,OACA,eACA,cACA;;;;;KAML,cAAA;;;;;;;;;;;;;KAeA,iBAAA;;;;;;;;;;;;;;;;;;;;6BAwBC,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"}
|
|
@@ -57,6 +57,21 @@ const withSpan = (span, callback) => {
|
|
|
57
57
|
}, callback);
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
|
+
* Run a callback whose steps get `prefix` before their IDs, so concurrent
|
|
61
|
+
* callers can use the same IDs.
|
|
62
|
+
*/
|
|
63
|
+
const withStepIdPrefix = (prefix, callback) => {
|
|
64
|
+
const currentCtx = getAsyncCtxSync();
|
|
65
|
+
if (!currentCtx?.execution) return callback();
|
|
66
|
+
return runWithAsyncCtx({
|
|
67
|
+
...currentCtx,
|
|
68
|
+
execution: {
|
|
69
|
+
...currentCtx.execution,
|
|
70
|
+
stepIdPrefix: `${currentCtx.execution.stepIdPrefix ?? ""}${prefix}`
|
|
71
|
+
}
|
|
72
|
+
}, callback);
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
60
75
|
* Suffix used to namespace steps that are automatically indexed.
|
|
61
76
|
*/
|
|
62
77
|
const STEP_INDEXING_SUFFIX = ":";
|
|
@@ -69,8 +84,13 @@ const createStepTools = (client, execution, stepHandler) => {
|
|
|
69
84
|
*/
|
|
70
85
|
const createTool = (matchOp, opts) => {
|
|
71
86
|
const wrappedMatchOp = (stepOptions, ...rest) => {
|
|
72
|
-
const op = matchOp(stepOptions, ...rest);
|
|
73
87
|
const alsCtx = getAsyncCtxSync()?.execution;
|
|
88
|
+
const prefix = alsCtx?.stepIdPrefix;
|
|
89
|
+
const op = matchOp(prefix ? {
|
|
90
|
+
...stepOptions,
|
|
91
|
+
id: `${prefix}${stepOptions.id}`,
|
|
92
|
+
name: stepOptions.name ?? stepOptions.id
|
|
93
|
+
} : stepOptions, ...rest);
|
|
74
94
|
if (alsCtx?.insideExperimentSelect) throw new NonRetriableError("Step tools (step.run, step.sleep, etc.) cannot be called inside an experiment select() callback. Move step calls into variant callbacks instead.");
|
|
75
95
|
const parallelMode = stepOptions.parallelMode ?? alsCtx?.parallelMode;
|
|
76
96
|
if (parallelMode) op.opts = {
|
|
@@ -469,5 +489,5 @@ const invokePayloadSchema = z.object({
|
|
|
469
489
|
});
|
|
470
490
|
|
|
471
491
|
//#endregion
|
|
472
|
-
export { STEP_INDEXING_SUFFIX, createStepTools, experimentStepRunSymbol, gatewaySymbol, getStepOptions, group, step, withSpan };
|
|
492
|
+
export { STEP_INDEXING_SUFFIX, createStepTools, experimentStepRunSymbol, gatewaySymbol, getStepOptions, group, step, withSpan, withStepIdPrefix };
|
|
473
493
|
//# sourceMappingURL=InngestStepTools.js.map
|