@yolk-sdk/vercel-workflows 0.1.0-canary.100
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/LICENSE +21 -0
- package/README.md +340 -0
- package/dist/effect.d.mts +56 -0
- package/dist/effect.d.mts.map +1 -0
- package/dist/effect.mjs +58 -0
- package/dist/effect.mjs.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +4 -0
- package/dist/testing/index.d.mts +97 -0
- package/dist/testing/index.d.mts.map +1 -0
- package/dist/testing/index.mjs +285 -0
- package/dist/testing/index.mjs.map +1 -0
- package/dist/workflow-children.d.mts +42 -0
- package/dist/workflow-children.d.mts.map +1 -0
- package/dist/workflow-children.mjs +54 -0
- package/dist/workflow-children.mjs.map +1 -0
- package/dist/workflow-events.d.mts +210 -0
- package/dist/workflow-events.d.mts.map +1 -0
- package/dist/workflow-events.mjs +54 -0
- package/dist/workflow-events.mjs.map +1 -0
- package/dist/workflow-loop.d.mts +416 -0
- package/dist/workflow-loop.d.mts.map +1 -0
- package/dist/workflow-loop.mjs +177 -0
- package/dist/workflow-loop.mjs.map +1 -0
- package/dist/workflow.d.mts +4 -0
- package/dist/workflow.mjs +4 -0
- package/package.json +77 -0
- package/src/effect.ts +232 -0
- package/src/index.ts +36 -0
- package/src/testing/index.ts +503 -0
- package/src/workflow-children.ts +81 -0
- package/src/workflow-events.ts +202 -0
- package/src/workflow-loop.ts +404 -0
- package/src/workflow.ts +42 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
//#region src/testing/index.ts
|
|
3
|
+
var TestWorkflowStreamConflictError = class extends Error {
|
|
4
|
+
name = "EntityConflictError";
|
|
5
|
+
status = 409;
|
|
6
|
+
constructor(runId) {
|
|
7
|
+
super(`Workflow run "${runId}" stream already completed`);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var TestWorkflowRunConflictError = class extends Error {
|
|
11
|
+
name = "EntityConflictError";
|
|
12
|
+
status = 409;
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var TestWorkflowHookNotFoundError = class extends Error {
|
|
18
|
+
name = "HookNotFoundError";
|
|
19
|
+
constructor(token) {
|
|
20
|
+
super(`Workflow hook "${token}" was not found`);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var TestWorkflowHookConflictError = class extends Error {
|
|
24
|
+
name = "HookConflictError";
|
|
25
|
+
constructor(token) {
|
|
26
|
+
super(`Workflow hook "${token}" was already resumed`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var TestWorkflowRunNotFoundError = class extends Error {
|
|
30
|
+
name = "WorkflowRunNotFoundError";
|
|
31
|
+
constructor(runId) {
|
|
32
|
+
super(`Workflow run "${runId}" was not found`);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var TestWorkflowRunCancelledError = class extends Error {
|
|
36
|
+
name = "WorkflowRunCancelledError";
|
|
37
|
+
constructor(runId) {
|
|
38
|
+
super(`Workflow run "${runId}" was cancelled`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const defaultTestWorkflowStepMaxRetries = 3;
|
|
42
|
+
const ambientStorage = new AsyncLocalStorage();
|
|
43
|
+
const requireAmbient = () => {
|
|
44
|
+
const ambient = ambientStorage.getStore();
|
|
45
|
+
if (ambient === void 0) throw new Error("Workflow ambient API called outside a TestWorkflowWorld run context");
|
|
46
|
+
return ambient;
|
|
47
|
+
};
|
|
48
|
+
var TestWorkflowWorld = class {
|
|
49
|
+
runs = /* @__PURE__ */ new Map();
|
|
50
|
+
runSequence = 0;
|
|
51
|
+
start(workflowFn, args) {
|
|
52
|
+
this.runSequence += 1;
|
|
53
|
+
const runId = `twr_${this.runSequence}`;
|
|
54
|
+
const run = {
|
|
55
|
+
runId,
|
|
56
|
+
status: "pending",
|
|
57
|
+
returnValue: void 0,
|
|
58
|
+
runError: void 0,
|
|
59
|
+
settled: Promise.resolve(),
|
|
60
|
+
chunks: [],
|
|
61
|
+
streamClosed: false,
|
|
62
|
+
streamCloseCount: 0,
|
|
63
|
+
writeAfterCloseAttempts: 0,
|
|
64
|
+
changeListeners: /* @__PURE__ */ new Set(),
|
|
65
|
+
hooks: /* @__PURE__ */ new Map(),
|
|
66
|
+
resumedHookTokens: /* @__PURE__ */ new Set(),
|
|
67
|
+
stepSequence: 0,
|
|
68
|
+
stepAttempts: /* @__PURE__ */ new Map()
|
|
69
|
+
};
|
|
70
|
+
this.runs.set(runId, run);
|
|
71
|
+
run.settled = ambientStorage.run({
|
|
72
|
+
world: this,
|
|
73
|
+
run,
|
|
74
|
+
stepMetadata: void 0
|
|
75
|
+
}, async () => {
|
|
76
|
+
await Promise.resolve();
|
|
77
|
+
if (run.status === "cancelled") return;
|
|
78
|
+
run.status = "running";
|
|
79
|
+
try {
|
|
80
|
+
run.returnValue = await workflowFn(...args);
|
|
81
|
+
if (run.status === "running") run.status = "completed";
|
|
82
|
+
} catch (error) {
|
|
83
|
+
run.runError = error;
|
|
84
|
+
if (run.status === "running") run.status = "failed";
|
|
85
|
+
} finally {
|
|
86
|
+
this.notifyChange(run);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return { runId };
|
|
90
|
+
}
|
|
91
|
+
async settled(runId) {
|
|
92
|
+
await this.requireRun(runId).settled;
|
|
93
|
+
}
|
|
94
|
+
inspect(runId) {
|
|
95
|
+
const run = this.requireRun(runId);
|
|
96
|
+
return {
|
|
97
|
+
runId: run.runId,
|
|
98
|
+
status: run.status,
|
|
99
|
+
chunks: [...run.chunks],
|
|
100
|
+
streamClosed: run.streamClosed,
|
|
101
|
+
streamCloseCount: run.streamCloseCount,
|
|
102
|
+
writeAfterCloseAttempts: run.writeAfterCloseAttempts,
|
|
103
|
+
stepAttempts: new Map(run.stepAttempts),
|
|
104
|
+
runError: run.runError
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
status(runId) {
|
|
108
|
+
return this.requireRun(runId).status;
|
|
109
|
+
}
|
|
110
|
+
async cancel(runId) {
|
|
111
|
+
const run = this.requireRun(runId);
|
|
112
|
+
if (run.status === "completed" || run.status === "failed" || run.status === "cancelled") throw new TestWorkflowRunConflictError(`Workflow run "${runId}" is already ${run.status} and cannot be cancelled`);
|
|
113
|
+
run.status = "cancelled";
|
|
114
|
+
for (const [token, hook] of run.hooks) {
|
|
115
|
+
run.hooks.delete(token);
|
|
116
|
+
hook.reject(new TestWorkflowRunCancelledError(runId));
|
|
117
|
+
}
|
|
118
|
+
this.notifyChange(run);
|
|
119
|
+
}
|
|
120
|
+
async resumeHook(token, payload) {
|
|
121
|
+
for (const run of this.runs.values()) {
|
|
122
|
+
const hook = run.hooks.get(token);
|
|
123
|
+
if (hook !== void 0) {
|
|
124
|
+
run.hooks.delete(token);
|
|
125
|
+
run.resumedHookTokens.add(token);
|
|
126
|
+
hook.resolve(payload);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (run.resumedHookTokens.has(token)) throw new TestWorkflowHookConflictError(token);
|
|
130
|
+
}
|
|
131
|
+
throw new TestWorkflowHookNotFoundError(token);
|
|
132
|
+
}
|
|
133
|
+
hasResumedHook(token) {
|
|
134
|
+
for (const run of this.runs.values()) if (run.resumedHookTokens.has(token)) return true;
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
async runStep(stepFn, args, stepName = stepFn.name === "" ? "step" : stepFn.name) {
|
|
138
|
+
const run = requireAmbient().run;
|
|
139
|
+
run.stepSequence += 1;
|
|
140
|
+
const stepId = `${run.runId}:step:${run.stepSequence}:${stepName}`;
|
|
141
|
+
const maxAttempts = (stepFn.maxRetries ?? 3) + 1;
|
|
142
|
+
let attempt = 1;
|
|
143
|
+
for (;;) {
|
|
144
|
+
run.stepAttempts.set(stepName, (run.stepAttempts.get(stepName) ?? 0) + 1);
|
|
145
|
+
try {
|
|
146
|
+
return await ambientStorage.run({
|
|
147
|
+
world: this,
|
|
148
|
+
run,
|
|
149
|
+
stepMetadata: {
|
|
150
|
+
attempt,
|
|
151
|
+
stepId,
|
|
152
|
+
stepName
|
|
153
|
+
}
|
|
154
|
+
}, () => stepFn(...args));
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (attempt >= maxAttempts) throw error;
|
|
157
|
+
attempt += 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
step(stepFn, stepName) {
|
|
162
|
+
return (...args) => this.runStep(stepFn, args, stepName);
|
|
163
|
+
}
|
|
164
|
+
static getWorkflowMetadata() {
|
|
165
|
+
return { workflowRunId: requireAmbient().run.runId };
|
|
166
|
+
}
|
|
167
|
+
static getStepMetadata() {
|
|
168
|
+
const ambient = requireAmbient();
|
|
169
|
+
if (ambient.stepMetadata === void 0) throw new Error("getStepMetadata called outside a step context");
|
|
170
|
+
return ambient.stepMetadata;
|
|
171
|
+
}
|
|
172
|
+
static getWritable() {
|
|
173
|
+
const ambient = requireAmbient();
|
|
174
|
+
return ambient.world.makeWritable(ambient.run);
|
|
175
|
+
}
|
|
176
|
+
static createHook(input) {
|
|
177
|
+
const ambient = requireAmbient();
|
|
178
|
+
return ambient.world.makeHook(ambient.run, input.token);
|
|
179
|
+
}
|
|
180
|
+
makeWritable(run) {
|
|
181
|
+
return new WritableStream({
|
|
182
|
+
write: (chunk) => {
|
|
183
|
+
if (run.streamClosed || run.status === "cancelled") {
|
|
184
|
+
run.writeAfterCloseAttempts += 1;
|
|
185
|
+
throw new TestWorkflowStreamConflictError(run.runId);
|
|
186
|
+
}
|
|
187
|
+
run.chunks.push(chunk);
|
|
188
|
+
this.notifyChange(run);
|
|
189
|
+
},
|
|
190
|
+
close: () => {
|
|
191
|
+
if (run.streamClosed) {
|
|
192
|
+
run.streamCloseCount += 1;
|
|
193
|
+
throw new TestWorkflowStreamConflictError(run.runId);
|
|
194
|
+
}
|
|
195
|
+
run.streamClosed = true;
|
|
196
|
+
run.streamCloseCount += 1;
|
|
197
|
+
this.notifyChange(run);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
makeHook(run, token) {
|
|
202
|
+
let resolveHook = () => {};
|
|
203
|
+
let rejectHook = () => {};
|
|
204
|
+
const promise = new Promise((resolve, reject) => {
|
|
205
|
+
resolveHook = (payload) => resolve(payload);
|
|
206
|
+
rejectHook = reject;
|
|
207
|
+
});
|
|
208
|
+
run.hooks.set(token, {
|
|
209
|
+
resolve: resolveHook,
|
|
210
|
+
reject: rejectHook
|
|
211
|
+
});
|
|
212
|
+
return Object.assign(promise, { [Symbol.dispose]: () => {
|
|
213
|
+
run.hooks.delete(token);
|
|
214
|
+
} });
|
|
215
|
+
}
|
|
216
|
+
getReadable(runId, options) {
|
|
217
|
+
const run = this.requireRun(runId);
|
|
218
|
+
const requestedStart = options?.startIndex ?? 0;
|
|
219
|
+
let index = requestedStart < 0 ? Math.max(0, run.chunks.length + requestedStart) : requestedStart;
|
|
220
|
+
const stream = new ReadableStream({ pull: async (controller) => {
|
|
221
|
+
while (index >= run.chunks.length && !this.streamEnded(run)) await this.nextChange(run);
|
|
222
|
+
if (index < run.chunks.length) {
|
|
223
|
+
controller.enqueue(run.chunks[index]);
|
|
224
|
+
index += 1;
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
controller.close();
|
|
228
|
+
} });
|
|
229
|
+
return Object.assign(stream, { getTailIndex: () => Promise.resolve(run.chunks.length - 1) });
|
|
230
|
+
}
|
|
231
|
+
streamEnded(run) {
|
|
232
|
+
return run.streamClosed || run.status === "cancelled";
|
|
233
|
+
}
|
|
234
|
+
notifyChange(run) {
|
|
235
|
+
const listeners = [...run.changeListeners];
|
|
236
|
+
run.changeListeners.clear();
|
|
237
|
+
for (const listener of listeners) listener();
|
|
238
|
+
}
|
|
239
|
+
nextChange(run) {
|
|
240
|
+
return new Promise((resolve) => {
|
|
241
|
+
run.changeListeners.add(resolve);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
requireRun(runId) {
|
|
245
|
+
const run = this.runs.get(runId);
|
|
246
|
+
if (run === void 0) throw new TestWorkflowRunNotFoundError(runId);
|
|
247
|
+
return run;
|
|
248
|
+
}
|
|
249
|
+
sdkRun(run) {
|
|
250
|
+
const getReadable = (options) => this.getReadable(run.runId, options);
|
|
251
|
+
const cancel = () => this.cancel(run.runId);
|
|
252
|
+
return {
|
|
253
|
+
runId: run.runId,
|
|
254
|
+
getReadable,
|
|
255
|
+
cancel,
|
|
256
|
+
get status() {
|
|
257
|
+
return Promise.resolve(run.status);
|
|
258
|
+
},
|
|
259
|
+
get returnValue() {
|
|
260
|
+
return run.settled.then(() => {
|
|
261
|
+
if (run.status === "completed") return run.returnValue;
|
|
262
|
+
throw run.runError ?? new TestWorkflowRunCancelledError(run.runId);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
sdk = {
|
|
268
|
+
start: async (workflowFn, args) => {
|
|
269
|
+
const { runId } = this.start(workflowFn, args);
|
|
270
|
+
return this.sdkRun(this.requireRun(runId));
|
|
271
|
+
},
|
|
272
|
+
getRun: (runId) => this.sdkRun(this.requireRun(runId)),
|
|
273
|
+
resumeHook: (token, payload) => this.resumeHook(token, payload)
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
const testWorkflowModule = {
|
|
277
|
+
getWorkflowMetadata: () => TestWorkflowWorld.getWorkflowMetadata(),
|
|
278
|
+
getStepMetadata: () => TestWorkflowWorld.getStepMetadata(),
|
|
279
|
+
getWritable: () => TestWorkflowWorld.getWritable(),
|
|
280
|
+
createHook: (input) => TestWorkflowWorld.createHook(input)
|
|
281
|
+
};
|
|
282
|
+
//#endregion
|
|
283
|
+
export { TestWorkflowHookConflictError, TestWorkflowHookNotFoundError, TestWorkflowRunCancelledError, TestWorkflowRunConflictError, TestWorkflowRunNotFoundError, TestWorkflowStreamConflictError, TestWorkflowWorld, defaultTestWorkflowStepMaxRetries, testWorkflowModule };
|
|
284
|
+
|
|
285
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/testing/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport type {\n VercelWorkflowsSdkClient,\n VercelWorkflowsSdkRun,\n VercelWorkflowReadableOptions,\n VercelWorkflowReadableStream,\n VercelWorkflowRunStatus\n} from '../effect.ts'\n\n// Behavioral emulator of the Vercel Workflow platform for tests: run lifecycle,\n// append-only durable streams with close-once -> 409 write conflicts, a step\n// executor honoring `fn.maxRetries` + `getStepMetadata().attempt`, hooks/resume,\n// and cancellation. Host code under test runs unmodified against it; tests mock\n// only the `workflow` module's ambient APIs, delegating to the active world\n// (see `testWorkflowModule`).\n//\n// The single most important semantic: writing to (or re-closing) a closed\n// durable stream fails with the platform's HTTP 409 \"already completed\"\n// conflict shape. Any code path that performs a terminal stream effect from a\n// retryable step attempt poisons every subsequent platform retry — exactly the\n// #252 production bug. The emulator enforces that invariant permanently.\n\nexport type TestWorkflowRunStatus = VercelWorkflowRunStatus\n\n// Matches the platform's conflict contract: `EntityConflictError.is(value)`\n// checks `value.name === 'EntityConflictError'`, and the Vercel world maps\n// HTTP 409 responses to that class.\nexport class TestWorkflowStreamConflictError extends Error {\n override readonly name = 'EntityConflictError'\n readonly status = 409\n\n constructor(runId: string) {\n super(`Workflow run \"${runId}\" stream already completed`)\n }\n}\n\nexport class TestWorkflowRunConflictError extends Error {\n override readonly name = 'EntityConflictError'\n readonly status = 409\n\n constructor(message: string) {\n super(message)\n }\n}\n\nexport class TestWorkflowHookNotFoundError extends Error {\n override readonly name = 'HookNotFoundError'\n\n constructor(token: string) {\n super(`Workflow hook \"${token}\" was not found`)\n }\n}\n\nexport class TestWorkflowHookConflictError extends Error {\n override readonly name = 'HookConflictError'\n\n constructor(token: string) {\n super(`Workflow hook \"${token}\" was already resumed`)\n }\n}\n\nexport class TestWorkflowRunNotFoundError extends Error {\n override readonly name = 'WorkflowRunNotFoundError'\n\n constructor(runId: string) {\n super(`Workflow run \"${runId}\" was not found`)\n }\n}\n\nexport class TestWorkflowRunCancelledError extends Error {\n override readonly name = 'WorkflowRunCancelledError'\n\n constructor(runId: string) {\n super(`Workflow run \"${runId}\" was cancelled`)\n }\n}\n\nexport type TestWorkflowMetadata = { readonly workflowRunId: string }\n\nexport type TestWorkflowStepMetadata = {\n readonly attempt: number\n readonly stepId: string\n readonly stepName: string\n}\n\nexport type TestWorkflowStepFunction<TArgs extends ReadonlyArray<unknown>, TResult> = ((\n ...args: TArgs\n) => Promise<TResult>) & { readonly maxRetries?: number }\n\n// The platform default: retries after the first attempt; total attempts = maxRetries + 1.\nexport const defaultTestWorkflowStepMaxRetries = 3\n\ntype HookRecord = {\n readonly resolve: (payload: unknown) => void\n readonly reject: (error: TestWorkflowRunCancelledError) => void\n}\n\ntype TestWorkflowRunRecord = {\n readonly runId: string\n status: TestWorkflowRunStatus\n returnValue: unknown\n runError: unknown\n settled: Promise<void>\n readonly chunks: Array<unknown>\n streamClosed: boolean\n streamCloseCount: number\n writeAfterCloseAttempts: number\n readonly changeListeners: Set<() => void>\n readonly hooks: Map<string, HookRecord>\n readonly resumedHookTokens: Set<string>\n stepSequence: number\n readonly stepAttempts: Map<string, number>\n}\n\ntype AmbientContext = {\n readonly world: TestWorkflowWorld\n readonly run: TestWorkflowRunRecord\n readonly stepMetadata: TestWorkflowStepMetadata | undefined\n}\n\nconst ambientStorage = new AsyncLocalStorage<AmbientContext>()\n\nconst requireAmbient = (): AmbientContext => {\n const ambient = ambientStorage.getStore()\n\n if (ambient === undefined) {\n throw new Error('Workflow ambient API called outside a TestWorkflowWorld run context')\n }\n\n return ambient\n}\n\nexport type TestWorkflowRunInspection = {\n readonly runId: string\n readonly status: TestWorkflowRunStatus\n readonly chunks: ReadonlyArray<unknown>\n readonly streamClosed: boolean\n readonly streamCloseCount: number\n readonly writeAfterCloseAttempts: number\n readonly stepAttempts: ReadonlyMap<string, number>\n readonly runError: unknown\n}\n\nexport type TestWorkflowHook<T> = Promise<T> & { readonly [Symbol.dispose]: () => void }\n\ntype TestWorkflowWorldStartResult = { readonly runId: string }\n\nexport class TestWorkflowWorld {\n private readonly runs = new Map<string, TestWorkflowRunRecord>()\n private runSequence = 0\n\n start<TArgs extends ReadonlyArray<unknown>, TResult>(\n workflowFn: (...args: TArgs) => Promise<TResult>,\n args: TArgs\n ): TestWorkflowWorldStartResult {\n this.runSequence += 1\n const runId = `twr_${this.runSequence}`\n\n const run: TestWorkflowRunRecord = {\n runId,\n status: 'pending',\n returnValue: undefined,\n runError: undefined,\n settled: Promise.resolve(),\n chunks: [],\n streamClosed: false,\n streamCloseCount: 0,\n writeAfterCloseAttempts: 0,\n changeListeners: new Set(),\n hooks: new Map(),\n resumedHookTokens: new Set(),\n stepSequence: 0,\n stepAttempts: new Map()\n }\n\n this.runs.set(runId, run)\n\n run.settled = ambientStorage.run(\n { world: this, run, stepMetadata: undefined },\n async (): Promise<void> => {\n // Yield once so callers observe `pending` before execution begins,\n // mirroring the platform's enqueue-then-run lifecycle.\n await Promise.resolve()\n\n if (run.status === 'cancelled') return\n\n run.status = 'running'\n\n try {\n run.returnValue = await workflowFn(...args)\n\n if (run.status === 'running') run.status = 'completed'\n } catch (error) {\n run.runError = error\n\n if (run.status === 'running') run.status = 'failed'\n } finally {\n this.notifyChange(run)\n }\n }\n )\n\n return { runId }\n }\n\n async settled(runId: string): Promise<void> {\n await this.requireRun(runId).settled\n }\n\n inspect(runId: string): TestWorkflowRunInspection {\n const run = this.requireRun(runId)\n\n return {\n runId: run.runId,\n status: run.status,\n chunks: [...run.chunks],\n streamClosed: run.streamClosed,\n streamCloseCount: run.streamCloseCount,\n writeAfterCloseAttempts: run.writeAfterCloseAttempts,\n stepAttempts: new Map(run.stepAttempts),\n runError: run.runError\n }\n }\n\n status(runId: string): TestWorkflowRunStatus {\n return this.requireRun(runId).status\n }\n\n async cancel(runId: string): Promise<void> {\n const run = this.requireRun(runId)\n\n if (run.status === 'completed' || run.status === 'failed' || run.status === 'cancelled') {\n throw new TestWorkflowRunConflictError(\n `Workflow run \"${runId}\" is already ${run.status} and cannot be cancelled`\n )\n }\n\n run.status = 'cancelled'\n\n for (const [token, hook] of run.hooks) {\n run.hooks.delete(token)\n hook.reject(new TestWorkflowRunCancelledError(runId))\n }\n\n this.notifyChange(run)\n }\n\n async resumeHook(token: string, payload: unknown): Promise<void> {\n for (const run of this.runs.values()) {\n const hook = run.hooks.get(token)\n\n if (hook !== undefined) {\n run.hooks.delete(token)\n run.resumedHookTokens.add(token)\n hook.resolve(payload)\n\n return\n }\n\n if (run.resumedHookTokens.has(token)) {\n throw new TestWorkflowHookConflictError(token)\n }\n }\n\n throw new TestWorkflowHookNotFoundError(token)\n }\n\n hasResumedHook(token: string): boolean {\n for (const run of this.runs.values()) {\n if (run.resumedHookTokens.has(token)) return true\n }\n\n return false\n }\n\n // --- Step executor (platform retry semantics) ---\n\n // Runs a step body with the platform's retry contract: `fn.maxRetries`\n // retries after the first attempt (total attempts = maxRetries + 1) and\n // 1-based `getStepMetadata().attempt` visible to the body.\n async runStep<TArgs extends ReadonlyArray<unknown>, TResult>(\n stepFn: TestWorkflowStepFunction<TArgs, TResult>,\n args: TArgs,\n stepName = stepFn.name === '' ? 'step' : stepFn.name\n ): Promise<TResult> {\n const ambient = requireAmbient()\n const run = ambient.run\n run.stepSequence += 1\n const stepId = `${run.runId}:step:${run.stepSequence}:${stepName}`\n const maxRetries = stepFn.maxRetries ?? defaultTestWorkflowStepMaxRetries\n const maxAttempts = maxRetries + 1\n\n let attempt = 1\n\n for (;;) {\n run.stepAttempts.set(stepName, (run.stepAttempts.get(stepName) ?? 0) + 1)\n\n try {\n return await ambientStorage.run(\n { world: this, run, stepMetadata: { attempt, stepId, stepName } },\n () => stepFn(...args)\n )\n } catch (error) {\n if (attempt >= maxAttempts) throw error\n attempt += 1\n }\n }\n }\n\n // Wraps a step function so orchestration code can invoke it exactly the way\n // the platform invokes `use step` functions: through the retry executor.\n step<TArgs extends ReadonlyArray<unknown>, TResult>(\n stepFn: TestWorkflowStepFunction<TArgs, TResult>,\n stepName?: string\n ): (...args: TArgs) => Promise<TResult> {\n return (...args: TArgs) => this.runStep(stepFn, args, stepName)\n }\n\n // --- Ambient platform APIs (exposed through `testWorkflowModule`) ---\n\n static getWorkflowMetadata(): TestWorkflowMetadata {\n return { workflowRunId: requireAmbient().run.runId }\n }\n\n static getStepMetadata(): TestWorkflowStepMetadata {\n const ambient = requireAmbient()\n\n if (ambient.stepMetadata === undefined) {\n throw new Error('getStepMetadata called outside a step context')\n }\n\n return ambient.stepMetadata\n }\n\n static getWritable<T>(): WritableStream<T> {\n const ambient = requireAmbient()\n\n return ambient.world.makeWritable(ambient.run)\n }\n\n static createHook<T>(input: { readonly token: string }): TestWorkflowHook<T> {\n const ambient = requireAmbient()\n\n return ambient.world.makeHook<T>(ambient.run, input.token)\n }\n\n // --- Durable streams ---\n\n private makeWritable<T>(run: TestWorkflowRunRecord): WritableStream<T> {\n return new WritableStream<T>({\n write: chunk => {\n if (run.streamClosed || run.status === 'cancelled') {\n run.writeAfterCloseAttempts += 1\n throw new TestWorkflowStreamConflictError(run.runId)\n }\n\n run.chunks.push(chunk)\n this.notifyChange(run)\n },\n close: () => {\n if (run.streamClosed) {\n run.streamCloseCount += 1\n throw new TestWorkflowStreamConflictError(run.runId)\n }\n\n run.streamClosed = true\n run.streamCloseCount += 1\n this.notifyChange(run)\n }\n })\n }\n\n private makeHook<T>(run: TestWorkflowRunRecord, token: string): TestWorkflowHook<T> {\n let resolveHook: (payload: unknown) => void = () => {}\n\n let rejectHook: (error: TestWorkflowRunCancelledError) => void = () => {}\n\n const promise = new Promise<T>((resolve, reject) => {\n // SAFETY: Hook payloads are caller-typed on the platform (`createHook<T>`).\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n resolveHook = payload => resolve(payload as T)\n rejectHook = reject\n })\n\n run.hooks.set(token, { resolve: resolveHook, reject: rejectHook })\n\n return Object.assign(promise, {\n [Symbol.dispose]: () => {\n run.hooks.delete(token)\n }\n })\n }\n\n getReadable<T>(\n runId: string,\n options?: VercelWorkflowReadableOptions\n ): VercelWorkflowReadableStream<T> {\n const run = this.requireRun(runId)\n const requestedStart = options?.startIndex ?? 0\n\n let index =\n requestedStart < 0 ? Math.max(0, run.chunks.length + requestedStart) : requestedStart\n\n const stream = new ReadableStream<T>({\n pull: async controller => {\n while (index >= run.chunks.length && !this.streamEnded(run)) {\n await this.nextChange(run)\n }\n\n if (index < run.chunks.length) {\n // SAFETY: The platform readable is caller-typed (`WorkflowReadableStream<R = any>`);\n // the durable log stores opaque chunks, so this coercion mirrors the\n // platform contract exactly.\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n controller.enqueue(run.chunks[index] as T)\n index += 1\n\n return\n }\n\n controller.close()\n }\n })\n\n return Object.assign(stream, {\n getTailIndex: () => Promise.resolve(run.chunks.length - 1)\n })\n }\n\n private streamEnded(run: TestWorkflowRunRecord): boolean {\n return run.streamClosed || run.status === 'cancelled'\n }\n\n private notifyChange(run: TestWorkflowRunRecord): void {\n const listeners = [...run.changeListeners]\n run.changeListeners.clear()\n\n for (const listener of listeners) listener()\n }\n\n private nextChange(run: TestWorkflowRunRecord): Promise<void> {\n return new Promise(resolve => {\n run.changeListeners.add(resolve)\n })\n }\n\n private requireRun(runId: string): TestWorkflowRunRecord {\n const run = this.runs.get(runId)\n\n if (run === undefined) throw new TestWorkflowRunNotFoundError(runId)\n\n return run\n }\n\n // --- SDK adapter for `VercelWorkflows.layerFromSdk` ---\n\n private sdkRun<TResult>(run: TestWorkflowRunRecord): VercelWorkflowsSdkRun<TResult> {\n const getReadable = <Chunk>(options?: VercelWorkflowReadableOptions) =>\n this.getReadable<Chunk>(run.runId, options)\n\n const cancel = () => this.cancel(run.runId)\n\n return {\n runId: run.runId,\n getReadable,\n cancel,\n get status() {\n return Promise.resolve(run.status)\n },\n get returnValue() {\n return run.settled.then(() => {\n if (run.status === 'completed') {\n // SAFETY: Return values are caller-typed on the platform SDK as well.\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return run.returnValue as TResult\n }\n\n throw run.runError ?? new TestWorkflowRunCancelledError(run.runId)\n })\n }\n }\n }\n\n readonly sdk: VercelWorkflowsSdkClient = {\n start: async (workflowFn, args) => {\n const { runId } = this.start(workflowFn, args)\n\n return this.sdkRun(this.requireRun(runId))\n },\n getRun: <TResult>(runId: string) => this.sdkRun<TResult>(this.requireRun(runId)),\n resumeHook: (token, payload) => this.resumeHook(token, payload)\n }\n}\n\n// Factory for `vi.mock('workflow', () => testWorkflowModule)`: the mocked\n// module surface delegates every ambient platform API to the active world's\n// AsyncLocalStorage context, so production code under test runs unmodified.\nexport const testWorkflowModule = {\n getWorkflowMetadata: () => TestWorkflowWorld.getWorkflowMetadata(),\n getStepMetadata: () => TestWorkflowWorld.getStepMetadata(),\n getWritable: <T>() => TestWorkflowWorld.getWritable<T>(),\n createHook: <T>(input: { readonly token: string }) => TestWorkflowWorld.createHook<T>(input)\n}\n"],"mappings":";;AA2BA,IAAa,kCAAb,cAAqD,MAAM;CACzD,OAAyB;CACzB,SAAkB;CAElB,YAAY,OAAe;EACzB,MAAM,iBAAiB,MAAM,2BAA2B;CAC1D;AACF;AAEA,IAAa,+BAAb,cAAkD,MAAM;CACtD,OAAyB;CACzB,SAAkB;CAElB,YAAY,SAAiB;EAC3B,MAAM,OAAO;CACf;AACF;AAEA,IAAa,gCAAb,cAAmD,MAAM;CACvD,OAAyB;CAEzB,YAAY,OAAe;EACzB,MAAM,kBAAkB,MAAM,gBAAgB;CAChD;AACF;AAEA,IAAa,gCAAb,cAAmD,MAAM;CACvD,OAAyB;CAEzB,YAAY,OAAe;EACzB,MAAM,kBAAkB,MAAM,sBAAsB;CACtD;AACF;AAEA,IAAa,+BAAb,cAAkD,MAAM;CACtD,OAAyB;CAEzB,YAAY,OAAe;EAC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.d.ts
|
|
2
|
+
/** Workflow orchestration only. Callbacks must be durable steps (sleep must be Workflow sleep).
|
|
3
|
+
* A read is short-lived; never put a long returnValue poll inside a step.
|
|
4
|
+
* Both callbacks receive a deterministic zero-based attempt for host budgets/backoff.
|
|
5
|
+
* Defaults remain unbounded: hosts end observation at their ceiling by returning done + value.
|
|
6
|
+
*/
|
|
7
|
+
declare function awaitWorkflowChild<A>(input: {
|
|
8
|
+
readonly read: (attempt: number) => Promise<{
|
|
9
|
+
readonly done: false;
|
|
10
|
+
} | {
|
|
11
|
+
readonly done: true;
|
|
12
|
+
readonly value: A;
|
|
13
|
+
}>;
|
|
14
|
+
readonly sleep: (attempt: number) => Promise<void>;
|
|
15
|
+
}): Promise<A>;
|
|
16
|
+
/** Preflight fences the entire batch. On rejection, stop dispatching new work, settle already
|
|
17
|
+
* active siblings, and return their ordered progress alongside failures. Hosts must handle failures.
|
|
18
|
+
*/
|
|
19
|
+
declare function orchestrateWorkflowToolBatch<Call, Result, Pause>(input: {
|
|
20
|
+
readonly calls: ReadonlyArray<Call>;
|
|
21
|
+
readonly concurrency: number;
|
|
22
|
+
readonly preflight: () => Promise<{
|
|
23
|
+
readonly ready: true;
|
|
24
|
+
} | {
|
|
25
|
+
readonly ready: false;
|
|
26
|
+
readonly value: Pause;
|
|
27
|
+
}>;
|
|
28
|
+
readonly execute: (call: Call, index: number) => Promise<Result>;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
readonly ready: true;
|
|
31
|
+
readonly results: ReadonlyArray<Result>;
|
|
32
|
+
readonly failures?: ReadonlyArray<{
|
|
33
|
+
readonly index: number;
|
|
34
|
+
readonly error: unknown;
|
|
35
|
+
}>;
|
|
36
|
+
} | {
|
|
37
|
+
readonly ready: false;
|
|
38
|
+
readonly value: Pause;
|
|
39
|
+
}>;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { awaitWorkflowChild, orchestrateWorkflowToolBatch };
|
|
42
|
+
//# sourceMappingURL=workflow-children.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-children.d.mts","names":[],"sources":["../src/workflow-children.ts"],"mappings":";;AAKA;;;;iBAAsB,kBAAA,GAAA,CAAsB,KAAA;EAAA,SACjC,IAAA,GACP,OAAA,aACG,OAAA;IAAA,SAAmB,IAAA;EAAA;IAAA,SAA2B,IAAA;IAAA,SAAqB,KAAA,EAAO,CAAA;EAAA;EAAA,SACtE,KAAA,GAAQ,OAAA,aAAoB,OAAA;AAAA,IACnC,OAAA,CAAQ,CAAA;;;;iBAcU,4BAAA,qBAAA,CAAkD,KAAA;EAAA,SAC7D,KAAA,EAAO,aAAA,CAAc,IAAA;EAAA,SACrB,WAAA;EAAA,SACA,SAAA,QAAiB,OAAA;IAAA,SACb,KAAA;EAAA;IAAA,SAA2B,KAAA;IAAA,SAAuB,KAAA,EAAO,KAAA;EAAA;EAAA,SAE7D,OAAA,GAAU,IAAA,EAAM,IAAA,EAAM,KAAA,aAAkB,OAAA,CAAQ,MAAA;AAAA,IACvD,OAAA;EAAA,SAEW,KAAA;EAAA,SACA,OAAA,EAAS,aAAA,CAAc,MAAA;EAAA,SACvB,QAAA,GAAW,aAAA;IAAA,SAAyB,KAAA;IAAA,SAAwB,KAAA;EAAA;AAAA;EAAA,SAE5D,KAAA;EAAA,SAAuB,KAAA,EAAO,KAAA;AAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//#region src/workflow-children.ts
|
|
2
|
+
/** Workflow orchestration only. Callbacks must be durable steps (sleep must be Workflow sleep).
|
|
3
|
+
* A read is short-lived; never put a long returnValue poll inside a step.
|
|
4
|
+
* Both callbacks receive a deterministic zero-based attempt for host budgets/backoff.
|
|
5
|
+
* Defaults remain unbounded: hosts end observation at their ceiling by returning done + value.
|
|
6
|
+
*/
|
|
7
|
+
async function awaitWorkflowChild(input) {
|
|
8
|
+
const { read, sleep } = input;
|
|
9
|
+
for (let attempt = 0;; attempt++) {
|
|
10
|
+
const state = await read(attempt);
|
|
11
|
+
if (state.done) return state.value;
|
|
12
|
+
await sleep(attempt);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Preflight fences the entire batch. On rejection, stop dispatching new work, settle already
|
|
16
|
+
* active siblings, and return their ordered progress alongside failures. Hosts must handle failures.
|
|
17
|
+
*/
|
|
18
|
+
async function orchestrateWorkflowToolBatch(input) {
|
|
19
|
+
const { calls, concurrency, preflight, execute } = input;
|
|
20
|
+
const prepared = await preflight();
|
|
21
|
+
if (!prepared.ready) return prepared;
|
|
22
|
+
const width = Number.isFinite(concurrency) ? Math.max(1, Math.floor(concurrency)) : 1;
|
|
23
|
+
const entries = calls.map((call, index) => ({
|
|
24
|
+
call,
|
|
25
|
+
index
|
|
26
|
+
}));
|
|
27
|
+
let next = 0;
|
|
28
|
+
const results = /* @__PURE__ */ new Map();
|
|
29
|
+
const failures = [];
|
|
30
|
+
await Promise.all(Array.from({ length: Math.min(width, calls.length) }, async () => {
|
|
31
|
+
while (failures.length === 0) {
|
|
32
|
+
const entry = entries[next++];
|
|
33
|
+
if (entry === void 0) return;
|
|
34
|
+
try {
|
|
35
|
+
results.set(entry.index, await execute(entry.call, entry.index));
|
|
36
|
+
} catch (error) {
|
|
37
|
+
failures.push({
|
|
38
|
+
index: entry.index,
|
|
39
|
+
error
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}));
|
|
44
|
+
const ready = {
|
|
45
|
+
ready: true,
|
|
46
|
+
results: [...results.entries()].sort(([a], [b]) => a - b).map(([, result]) => result)
|
|
47
|
+
};
|
|
48
|
+
if (failures.length !== 0) ready.failures = failures.sort((a, b) => a.index - b.index);
|
|
49
|
+
return ready;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { awaitWorkflowChild, orchestrateWorkflowToolBatch };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=workflow-children.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-children.mjs","names":[],"sources":["../src/workflow-children.ts"],"sourcesContent":["/** Workflow orchestration only. Callbacks must be durable steps (sleep must be Workflow sleep).\n * A read is short-lived; never put a long returnValue poll inside a step.\n * Both callbacks receive a deterministic zero-based attempt for host budgets/backoff.\n * Defaults remain unbounded: hosts end observation at their ceiling by returning done + value.\n */\nexport async function awaitWorkflowChild<A>(input: {\n readonly read: (\n attempt: number\n ) => Promise<{ readonly done: false } | { readonly done: true; readonly value: A }>\n readonly sleep: (attempt: number) => Promise<void>\n}): Promise<A> {\n const { read, sleep } = input\n\n for (let attempt = 0; ; attempt++) {\n const state = await read(attempt)\n\n if (state.done) return state.value\n await sleep(attempt)\n }\n}\n\n/** Preflight fences the entire batch. On rejection, stop dispatching new work, settle already\n * active siblings, and return their ordered progress alongside failures. Hosts must handle failures.\n */\nexport async function orchestrateWorkflowToolBatch<Call, Result, Pause>(input: {\n readonly calls: ReadonlyArray<Call>\n readonly concurrency: number\n readonly preflight: () => Promise<\n { readonly ready: true } | { readonly ready: false; readonly value: Pause }\n >\n readonly execute: (call: Call, index: number) => Promise<Result>\n}): Promise<\n | {\n readonly ready: true\n readonly results: ReadonlyArray<Result>\n readonly failures?: ReadonlyArray<{ readonly index: number; readonly error: unknown }>\n }\n | { readonly ready: false; readonly value: Pause }\n> {\n const { calls, concurrency, preflight, execute } = input\n const prepared = await preflight()\n\n if (!prepared.ready) return prepared\n const width = Number.isFinite(concurrency) ? Math.max(1, Math.floor(concurrency)) : 1\n const entries = calls.map((call, index) => ({ call, index }))\n let next = 0\n const results = new Map<number, Result>()\n const failures: Array<{ readonly index: number; readonly error: unknown }> = []\n await Promise.all(\n Array.from({ length: Math.min(width, calls.length) }, async () => {\n while (failures.length === 0) {\n const entry = entries[next++]\n\n if (entry === undefined) return\n\n try {\n results.set(entry.index, await execute(entry.call, entry.index))\n } catch (error) {\n failures.push({ index: entry.index, error })\n }\n }\n })\n )\n\n type ReadyWorkflowToolBatch = {\n ready: true\n results: Array<Result>\n failures?: Array<{ readonly index: number; readonly error: unknown }>\n }\n\n const ready: ReadyWorkflowToolBatch = {\n ready: true,\n results: [...results.entries()].sort(([a], [b]) => a - b).map(([, result]) => result)\n }\n\n if (failures.length !== 0) {\n ready.failures = failures.sort((a, b) => a.index - b.index)\n }\n\n return ready\n}\n"],"mappings":";;;;;;AAKA,eAAsB,mBAAsB,OAK7B;CACb,MAAM,EAAE,MAAM,UAAU;CAExB,KAAK,IAAI,UAAU,IAAK,WAAW;EACjC,MAAM,QAAQ,MAAM,KAAK,OAAO;EAEhC,IAAI,MAAM,MAAM,OAAO,MAAM;EAC7B,MAAM,MAAM,OAAO;CACrB;AACF;;;;AAKA,eAAsB,6BAAkD,OActE;CACA,MAAM,EAAE,OAAO,aAAa,WAAW,YAAY;CACnD,MAAM,WAAW,MAAM,UAAU;CAEjC,IAAI,CAAC,SAAS,OAAO,OAAO;CAC5B,MAAM,QAAQ,OAAO,SAAS,WAAW,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,WAAW,CAAC,IAAI;CACpF,MAAM,UAAU,MAAM,KAAK,MAAM,WAAW;EAAE;EAAM;CAAM,EAAE;CAC5D,IAAI,OAAO;CACX,MAAM,0BAAU,IAAI,IAAoB;CACxC,MAAM,WAAuE,CAAC;CAC9E,MAAM,QAAQ,IACZ,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,OAAO,MAAM,MAAM,EAAE,GAAG,YAAY;EAChE,OAAO,SAAS,WAAW,GAAG;GAC5B,MAAM,QAAQ,QAAQ;GAEtB,IAAI,UAAU,KAAA,GAAW;GAEzB,IAAI;IACF,QAAQ,IAAI,MAAM,OAAO,MAAM,QAAQ,MAAM,MAAM,MAAM,KAAK,CAAC;GACjE,SAAS,OAAO;IACd,SAAS,KAAK;KAAE,OAAO,MAAM;KAAO;IAAM,CAAC;GAC7C;EACF;CACF,CAAC,CACH;CAQA,MAAM,QAAgC;EACpC,OAAO;EACP,SAAS,CAAC,GAAG,QAAQ,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,EAAE,KAAK,GAAG,YAAY,MAAM;CACtF;CAEA,IAAI,SAAS,WAAW,GACtB,MAAM,WAAW,SAAS,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;CAG5D,OAAO;AACT"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { Data, Effect } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/workflow-events.d.ts
|
|
4
|
+
type DurableAgentEventSequencerState = {
|
|
5
|
+
readonly eventSequence: number;
|
|
6
|
+
};
|
|
7
|
+
type DurableAgentEvent<Event extends object = object> = Event & {
|
|
8
|
+
readonly eventId: string;
|
|
9
|
+
readonly createdAtMs?: number;
|
|
10
|
+
};
|
|
11
|
+
type DurableAgentEventIdInput = {
|
|
12
|
+
readonly streamId: string;
|
|
13
|
+
readonly turn: number;
|
|
14
|
+
readonly eventSequence: number;
|
|
15
|
+
};
|
|
16
|
+
type SequenceDurableAgentEventInput<Event extends object = object> = {
|
|
17
|
+
readonly state: DurableAgentEventSequencerState;
|
|
18
|
+
/**
|
|
19
|
+
* Stable id namespace for one independent durable stream.
|
|
20
|
+
*
|
|
21
|
+
* Include the workflow/session/run id when multiple logical runs can be
|
|
22
|
+
* projected in the same client. Replay-safe clients de-dupe by `eventId`, so
|
|
23
|
+
* reusing a stream id across runs can drop legitimate follow-up events.
|
|
24
|
+
*/
|
|
25
|
+
readonly streamId: string;
|
|
26
|
+
readonly turn: number;
|
|
27
|
+
readonly event: Event;
|
|
28
|
+
readonly createdAtMs?: number;
|
|
29
|
+
};
|
|
30
|
+
type SequencedDurableAgentEvent<Event extends object = object> = {
|
|
31
|
+
readonly event: DurableAgentEvent<Event>;
|
|
32
|
+
readonly eventSequence: number;
|
|
33
|
+
readonly nextEventSequence: number;
|
|
34
|
+
readonly nextState: DurableAgentEventSequencerState;
|
|
35
|
+
};
|
|
36
|
+
type WriteDurableAgentEventInput<Event extends object = object> = SequenceDurableAgentEventInput<Event> & {
|
|
37
|
+
readonly writer: WritableStreamDefaultWriter<Uint8Array>;
|
|
38
|
+
};
|
|
39
|
+
type CommitThenWriteTerminalEventInput<TerminalEvent extends object, TerminalWriteResult, CommitErrorWriteResult, CommitError, TerminalWriteError, CommitErrorWriteError> = {
|
|
40
|
+
readonly commit: Effect.Effect<void, CommitError>;
|
|
41
|
+
readonly terminal: TerminalEvent;
|
|
42
|
+
readonly write: (event: TerminalEvent) => Effect.Effect<TerminalWriteResult, TerminalWriteError>;
|
|
43
|
+
readonly writeCommitError: (error: CommitError) => Effect.Effect<CommitErrorWriteResult, CommitErrorWriteError>;
|
|
44
|
+
};
|
|
45
|
+
type CommitThenWriteTerminalEventResult<TerminalWriteResult, CommitErrorWriteResult> = Data.TaggedEnum<{
|
|
46
|
+
Committed: {
|
|
47
|
+
readonly writeResult: TerminalWriteResult;
|
|
48
|
+
};
|
|
49
|
+
CommitFailed: {
|
|
50
|
+
readonly commitError: unknown;
|
|
51
|
+
readonly writeResult: CommitErrorWriteResult;
|
|
52
|
+
};
|
|
53
|
+
TerminalWriteFailed: {
|
|
54
|
+
readonly error: unknown;
|
|
55
|
+
};
|
|
56
|
+
CommitErrorWriteFailed: {
|
|
57
|
+
readonly commitError: unknown;
|
|
58
|
+
readonly error: unknown;
|
|
59
|
+
};
|
|
60
|
+
}>;
|
|
61
|
+
declare const CommitThenWriteTerminalEventResult: {
|
|
62
|
+
readonly Committed: <A, B>(args: {
|
|
63
|
+
readonly writeResult: A;
|
|
64
|
+
}) => {
|
|
65
|
+
readonly _tag: "Committed";
|
|
66
|
+
readonly writeResult: A;
|
|
67
|
+
};
|
|
68
|
+
readonly CommitFailed: <A, B>(args: {
|
|
69
|
+
readonly commitError: unknown;
|
|
70
|
+
readonly writeResult: B;
|
|
71
|
+
}) => {
|
|
72
|
+
readonly _tag: "CommitFailed";
|
|
73
|
+
readonly commitError: unknown;
|
|
74
|
+
readonly writeResult: B;
|
|
75
|
+
};
|
|
76
|
+
readonly TerminalWriteFailed: <A, B>(args: {
|
|
77
|
+
readonly error: unknown;
|
|
78
|
+
}) => {
|
|
79
|
+
readonly _tag: "TerminalWriteFailed";
|
|
80
|
+
readonly error: unknown;
|
|
81
|
+
};
|
|
82
|
+
readonly CommitErrorWriteFailed: <A, B>(args: {
|
|
83
|
+
readonly commitError: unknown;
|
|
84
|
+
readonly error: unknown;
|
|
85
|
+
}) => {
|
|
86
|
+
readonly _tag: "CommitErrorWriteFailed";
|
|
87
|
+
readonly commitError: unknown;
|
|
88
|
+
readonly error: unknown;
|
|
89
|
+
};
|
|
90
|
+
readonly $is: <Tag extends "Committed" | "CommitFailed" | "TerminalWriteFailed" | "CommitErrorWriteFailed">(tag: Tag) => {
|
|
91
|
+
<T extends {
|
|
92
|
+
readonly _tag: "Committed";
|
|
93
|
+
readonly writeResult: any;
|
|
94
|
+
} | {
|
|
95
|
+
readonly _tag: "CommitFailed";
|
|
96
|
+
readonly commitError: unknown;
|
|
97
|
+
readonly writeResult: any;
|
|
98
|
+
} | {
|
|
99
|
+
readonly _tag: "TerminalWriteFailed";
|
|
100
|
+
readonly error: unknown;
|
|
101
|
+
} | {
|
|
102
|
+
readonly _tag: "CommitErrorWriteFailed";
|
|
103
|
+
readonly commitError: unknown;
|
|
104
|
+
readonly error: unknown;
|
|
105
|
+
}>(u: T): u is T & {
|
|
106
|
+
readonly _tag: Tag;
|
|
107
|
+
};
|
|
108
|
+
(u: unknown): u is Extract<{
|
|
109
|
+
readonly _tag: "Committed";
|
|
110
|
+
readonly writeResult: unknown;
|
|
111
|
+
}, {
|
|
112
|
+
readonly _tag: Tag;
|
|
113
|
+
}> | Extract<{
|
|
114
|
+
readonly _tag: "CommitFailed";
|
|
115
|
+
readonly commitError: unknown;
|
|
116
|
+
readonly writeResult: unknown;
|
|
117
|
+
}, {
|
|
118
|
+
readonly _tag: Tag;
|
|
119
|
+
}> | Extract<{
|
|
120
|
+
readonly _tag: "TerminalWriteFailed";
|
|
121
|
+
readonly error: unknown;
|
|
122
|
+
}, {
|
|
123
|
+
readonly _tag: Tag;
|
|
124
|
+
}> | Extract<{
|
|
125
|
+
readonly _tag: "CommitErrorWriteFailed";
|
|
126
|
+
readonly commitError: unknown;
|
|
127
|
+
readonly error: unknown;
|
|
128
|
+
}, {
|
|
129
|
+
readonly _tag: Tag;
|
|
130
|
+
}>;
|
|
131
|
+
};
|
|
132
|
+
readonly $match: {
|
|
133
|
+
<A, B, C, D, Cases extends {
|
|
134
|
+
readonly Committed: (args: {
|
|
135
|
+
readonly _tag: "Committed";
|
|
136
|
+
readonly writeResult: A;
|
|
137
|
+
}) => any;
|
|
138
|
+
readonly CommitFailed: (args: {
|
|
139
|
+
readonly _tag: "CommitFailed";
|
|
140
|
+
readonly commitError: unknown;
|
|
141
|
+
readonly writeResult: B;
|
|
142
|
+
}) => any;
|
|
143
|
+
readonly TerminalWriteFailed: (args: {
|
|
144
|
+
readonly _tag: "TerminalWriteFailed";
|
|
145
|
+
readonly error: unknown;
|
|
146
|
+
}) => any;
|
|
147
|
+
readonly CommitErrorWriteFailed: (args: {
|
|
148
|
+
readonly _tag: "CommitErrorWriteFailed";
|
|
149
|
+
readonly commitError: unknown;
|
|
150
|
+
readonly error: unknown;
|
|
151
|
+
}) => any;
|
|
152
|
+
}>(cases: Cases): (self: {
|
|
153
|
+
readonly _tag: "Committed";
|
|
154
|
+
readonly writeResult: A;
|
|
155
|
+
} | {
|
|
156
|
+
readonly _tag: "CommitFailed";
|
|
157
|
+
readonly commitError: unknown;
|
|
158
|
+
readonly writeResult: B;
|
|
159
|
+
} | {
|
|
160
|
+
readonly _tag: "TerminalWriteFailed";
|
|
161
|
+
readonly error: unknown;
|
|
162
|
+
} | {
|
|
163
|
+
readonly _tag: "CommitErrorWriteFailed";
|
|
164
|
+
readonly commitError: unknown;
|
|
165
|
+
readonly error: unknown;
|
|
166
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Committed" | "CommitFailed" | "TerminalWriteFailed" | "CommitErrorWriteFailed"]>>;
|
|
167
|
+
<A, B, C, D, Cases extends {
|
|
168
|
+
readonly Committed: (args: {
|
|
169
|
+
readonly _tag: "Committed";
|
|
170
|
+
readonly writeResult: A;
|
|
171
|
+
}) => any;
|
|
172
|
+
readonly CommitFailed: (args: {
|
|
173
|
+
readonly _tag: "CommitFailed";
|
|
174
|
+
readonly commitError: unknown;
|
|
175
|
+
readonly writeResult: B;
|
|
176
|
+
}) => any;
|
|
177
|
+
readonly TerminalWriteFailed: (args: {
|
|
178
|
+
readonly _tag: "TerminalWriteFailed";
|
|
179
|
+
readonly error: unknown;
|
|
180
|
+
}) => any;
|
|
181
|
+
readonly CommitErrorWriteFailed: (args: {
|
|
182
|
+
readonly _tag: "CommitErrorWriteFailed";
|
|
183
|
+
readonly commitError: unknown;
|
|
184
|
+
readonly error: unknown;
|
|
185
|
+
}) => any;
|
|
186
|
+
}>(self: {
|
|
187
|
+
readonly _tag: "Committed";
|
|
188
|
+
readonly writeResult: A;
|
|
189
|
+
} | {
|
|
190
|
+
readonly _tag: "CommitFailed";
|
|
191
|
+
readonly commitError: unknown;
|
|
192
|
+
readonly writeResult: B;
|
|
193
|
+
} | {
|
|
194
|
+
readonly _tag: "TerminalWriteFailed";
|
|
195
|
+
readonly error: unknown;
|
|
196
|
+
} | {
|
|
197
|
+
readonly _tag: "CommitErrorWriteFailed";
|
|
198
|
+
readonly commitError: unknown;
|
|
199
|
+
readonly error: unknown;
|
|
200
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Committed" | "CommitFailed" | "TerminalWriteFailed" | "CommitErrorWriteFailed"]>>;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
declare const makeDurableAgentEventSequencerState: (eventSequence?: number) => DurableAgentEventSequencerState;
|
|
204
|
+
declare const durableAgentEventId: (input: DurableAgentEventIdInput) => string;
|
|
205
|
+
declare const sequenceDurableAgentEvent: <Event extends object>(input: SequenceDurableAgentEventInput<Event>) => SequencedDurableAgentEvent<Event>;
|
|
206
|
+
declare const writeDurableAgentEvent: <Event extends object>(input: WriteDurableAgentEventInput<Event>) => Effect.Effect<SequencedDurableAgentEvent<Event>, unknown>;
|
|
207
|
+
declare const commitThenWriteTerminalEvent: <TerminalEvent extends object, TerminalWriteResult, CommitErrorWriteResult, CommitError, TerminalWriteError, CommitErrorWriteError>(input: CommitThenWriteTerminalEventInput<TerminalEvent, TerminalWriteResult, CommitErrorWriteResult, CommitError, TerminalWriteError, CommitErrorWriteError>) => Effect.Effect<CommitThenWriteTerminalEventResult<TerminalWriteResult, CommitErrorWriteResult>, never>;
|
|
208
|
+
//#endregion
|
|
209
|
+
export { CommitThenWriteTerminalEventInput, CommitThenWriteTerminalEventResult, DurableAgentEvent, DurableAgentEventIdInput, DurableAgentEventSequencerState, SequenceDurableAgentEventInput, SequencedDurableAgentEvent, WriteDurableAgentEventInput, commitThenWriteTerminalEvent, durableAgentEventId, makeDurableAgentEventSequencerState, sequenceDurableAgentEvent, writeDurableAgentEvent };
|
|
210
|
+
//# sourceMappingURL=workflow-events.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-events.d.mts","names":[],"sources":["../src/workflow-events.ts"],"mappings":";;;KAEY,+BAAA;EAAA,SACD,aAAa;AAAA;AAAA,KAGZ,iBAAA,kCAAmD,KAAK;EAAA,SACzD,OAAA;EAAA,SACA,WAAA;AAAA;AAAA,KAGC,wBAAA;EAAA,SACD,QAAA;EAAA,SACA,IAAA;EAAA,SACA,aAAA;AAAA;AAAA,KAGC,8BAAA;EAAA,SACD,KAAA,EAAO,+BAAA;EAVP;;AAAW;AAGtB;;;;EAHW,SAkBA,QAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA,EAAO,KAAK;EAAA,SACZ,WAAA;AAAA;AAAA,KAGC,0BAAA;EAAA,SACD,KAAA,EAAO,iBAAA,CAAkB,KAAA;EAAA,SACzB,aAAA;EAAA,SACA,iBAAA;EAAA,SACA,SAAA,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