@brickkit/cli 0.11.0 → 0.13.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/dashboard-dist/CollapsiblePanel-CbUysOp5.js +2 -0
- package/dashboard-dist/CompositeRoot-D4sRkYq3.js +1 -0
- package/dashboard-dist/Geist-Variable.woff2 +0 -0
- package/dashboard-dist/GeistMono-Variable.woff2 +0 -0
- package/dashboard-dist/PopoverPopup-CiI2avT_.js +1 -0
- package/dashboard-dist/api-reference-mT9VNcPb.js +265 -0
- package/dashboard-dist/app.css +2 -2
- package/dashboard-dist/app.js +12 -13
- package/dashboard-dist/ccount-CcG1m-Yh.js +1 -0
- package/dashboard-dist/client-CwATkLJa.js +1 -0
- package/dashboard-dist/core-BEUWp6B5.js +1 -0
- package/dashboard-dist/docs-BRrtyxDB.js +4 -0
- package/dashboard-dist/docs.css +1 -1
- package/dashboard-dist/kit.js +1 -1
- package/dashboard-dist/popover-Bj9x-88h.js +1 -0
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +309 -211
- package/dist/bin.js.map +1 -1
- package/dist/build.js +463 -0
- package/dist/build.js.map +1 -0
- package/dist/client-contract-file.js +356 -1
- package/dist/client-contract-file.js.map +1 -0
- package/dist/compiler.d.ts +12 -3
- package/dist/compiler.js +1 -1
- package/dist/compiler2.js +13 -7
- package/dist/compiler2.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.js +1 -252
- package/dist/config2.d.ts +122 -0
- package/dist/config2.js +207 -0
- package/dist/config2.js.map +1 -0
- package/dist/dashboard-extension.d.ts +3 -2
- package/dist/{dev-telemetry-store.js → dashboard-host.js} +1381 -1432
- package/dist/dashboard-host.js.map +1 -0
- package/dist/dashboard-protocol.js +189 -0
- package/dist/dashboard-protocol.js.map +1 -0
- package/dist/dashboard.d.ts +8 -135
- package/dist/definitions.js +33 -0
- package/dist/definitions.js.map +1 -0
- package/dist/dev-application.js +34 -0
- package/dist/dev-application.js.map +1 -0
- package/dist/dev-protocol.js +21 -0
- package/dist/dev-protocol.js.map +1 -0
- package/dist/dev-reporter.d.ts +0 -2
- package/dist/dev-reporter.js +3 -3
- package/dist/dev-reporter.js.map +1 -1
- package/dist/dev-telemetry.js +8 -24
- package/dist/dev-telemetry.js.map +1 -1
- package/dist/dev-worker.js +80 -21
- package/dist/dev-worker.js.map +1 -1
- package/dist/index.d.ts +18 -87
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -0
- package/dist/lint/oxlint.d.ts +0 -2
- package/dist/lint/oxlint.js +6 -5
- package/dist/lint/oxlint.js.map +1 -1
- package/dist/own-module.js +7 -0
- package/dist/own-module.js.map +1 -0
- package/dist/plugin.d.ts +6 -11
- package/dist/plugin.js +6 -42
- package/dist/plugin.js.map +1 -1
- package/dist/production-dashboard.d.ts +2 -0
- package/dist/production-dashboard.js +51 -0
- package/dist/production-dashboard.js.map +1 -0
- package/dist/production-dashboard2.d.ts +34 -0
- package/dist/{presets.js → project.js} +107 -113
- package/dist/project.js.map +1 -0
- package/dist/serve.d.ts +24 -0
- package/dist/serve.js +1 -0
- package/dist/serve2.js +49 -0
- package/dist/serve2.js.map +1 -0
- package/dist/vite.d.ts +0 -2
- package/dist/vite.js +28 -51
- package/dist/vite.js.map +1 -1
- package/dist/workflows.d.ts +2 -4
- package/dist/workflows2.js +60 -39
- package/dist/workflows2.js.map +1 -1
- package/inspector-dist/client/assets/api.rpc-BvRk9kiK.js +0 -0
- package/inspector-dist/client/assets/api.stream._streamId-BvRk9kiK.js +0 -0
- package/inspector-dist/client/assets/app-CeSwVsRm.css +2 -0
- package/inspector-dist/client/assets/dist-BK8w6xOr.js +3930 -0
- package/inspector-dist/client/assets/dist-CG2aVufI.js +197 -0
- package/inspector-dist/client/assets/entry.client-D9jbgmTR.js +9391 -0
- package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-CfRnuITN.js +34 -0
- package/inspector-dist/client/assets/home-hwPlkNhv.js +4034 -0
- package/inspector-dist/client/assets/jsx-runtime-CPEah4WQ.js +7084 -0
- package/inspector-dist/client/assets/manifest-0e76e9ac.js +1 -0
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-ZDR2PNY_.js +1 -0
- package/inspector-dist/client/assets/root-ChBNTZd2.css +2 -0
- package/inspector-dist/client/assets/root-SLeEf-sT.js +320 -0
- package/inspector-dist/client/assets/run-detail-DYbVkIFH.js +1871 -0
- package/inspector-dist/client/assets/tabs-CaJisoyb.js +73751 -0
- package/inspector-dist/client/assets/tabs-L5XKzOpP.css +1 -0
- package/inspector-dist/client/assets/zstd-browser-decoder-D94wmfAU.js +41 -0
- package/inspector-dist/server/assets/app-DGlfWVUI.js +99330 -0
- package/inspector-dist/server/assets/chunk-RLXIAIE6-F0SJZlei.js +42975 -0
- package/inspector-dist/server/assets/dist-BCbwm6jl.js +10325 -0
- package/inspector-dist/server/assets/dist-CG2aVufI.js +197 -0
- package/inspector-dist/server/assets/dist-Ce0I2PUv.js +1137 -0
- package/inspector-dist/server/assets/dist-DY0UlahA.js +1642 -0
- package/inspector-dist/server/assets/encryption-DdQgC8Rk.js +886 -0
- package/inspector-dist/server/assets/event-metadata-n7E4zEmT.js +145 -0
- package/inspector-dist/server/assets/functions-CNVQtbgg.js +1170 -0
- package/inspector-dist/server/assets/global-singleton-D8sIN5du.js +80 -0
- package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-CWRzMxYD.js +34 -0
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-D0v0ngVr.js +1 -0
- package/inspector-dist/server/assets/parse-Begau9cA.js +469 -0
- package/inspector-dist/server/assets/rolldown-runtime-C1I3wEg2.js +43 -0
- package/inspector-dist/server/assets/serialization-format-BbuGfHog.js +476 -0
- package/inspector-dist/server/assets/token-BgMmJNP5.js +60 -0
- package/inspector-dist/server/assets/token-BrUX0bxz.js +55 -0
- package/inspector-dist/server/assets/token-util-DZN32qmT.js +455 -0
- package/inspector-dist/server/assets/wrapper-CIC3w0oC.js +3624 -0
- package/inspector-dist/server/assets/ws-transport-CxTYB11n.js +29476 -0
- package/inspector-dist/server/assets/zstd-browser-decoder-D7bCXbGg.js +38 -0
- package/inspector-dist/server/index.js +1 -58
- package/package.json +39 -28
- package/vite-client.d.ts +1 -1
- package/dashboard-dist/CollapsiblePanel-BX79_W-b.js +0 -2
- package/dashboard-dist/CompositeRoot-xzybXjnx.js +0 -1
- package/dashboard-dist/PopoverPopup-CvlmC7EL.js +0 -1
- package/dashboard-dist/api-reference-BcAYVYwJ.js +0 -260
- package/dashboard-dist/core-BGO9JZ1r.js +0 -1
- package/dashboard-dist/docs-DHikPD2v.js +0 -4
- package/dashboard-dist/popover-DG498XHH.js +0 -1
- package/dist/app-entry.js +0 -1
- package/dist/app-entry2.js +0 -19
- package/dist/app-entry2.js.map +0 -1
- package/dist/bin.d.ts.map +0 -1
- package/dist/client-contract-file2.js +0 -34
- package/dist/client-contract-file2.js.map +0 -1
- package/dist/client-contract.js +0 -1
- package/dist/client-contract2.js +0 -294
- package/dist/client-contract2.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/dashboard-extension.d.ts.map +0 -1
- package/dist/dev-reporter.d.ts.map +0 -1
- package/dist/dev-telemetry-store.js.map +0 -1
- package/dist/emit.d.ts +0 -7
- package/dist/emit.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lint/oxlint.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/presets.js.map +0 -1
- package/dist/runner.js +0 -523
- package/dist/runner.js.map +0 -1
- package/dist/vite.d.ts.map +0 -1
- package/dist/workflows.d.ts.map +0 -1
- package/inspector-dist/client/assets/api.rpc-l0sNRNKZ.js +0 -1
- package/inspector-dist/client/assets/api.stream._streamId-l0sNRNKZ.js +0 -1
- package/inspector-dist/client/assets/app-CvoGgWcV.css +0 -1
- package/inspector-dist/client/assets/entry.client-BJ6G3n5t.js +0 -11697
- package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-C-3wZnxf.js +0 -19
- package/inspector-dist/client/assets/home-CSKAS4P2.js +0 -4979
- package/inspector-dist/client/assets/index-DECCyMR0.js +0 -4482
- package/inspector-dist/client/assets/index-Dot7CgrA.js +0 -9837
- package/inspector-dist/client/assets/index-HqNj_XIX.js +0 -200
- package/inspector-dist/client/assets/manifest-139c9319.js +0 -1
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-DC0K8uTy.js +0 -58626
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-F88p7PFX.css +0 -1
- package/inspector-dist/client/assets/root-BMHd_XHz.css +0 -1
- package/inspector-dist/client/assets/root-cbi6iYwg.js +0 -305
- package/inspector-dist/client/assets/run-detail-CWoGxu_0.css +0 -1
- package/inspector-dist/client/assets/run-detail-Cc7tSGNq.js +0 -6237
- package/inspector-dist/client/assets/world-config-context-BAD1QCrR.js +0 -26
- package/inspector-dist/client/assets/zstd-browser-decoder-BQoRpP7L.js +0 -28
- package/inspector-dist/server/assets/app-DUP5RybL.js +0 -174880
- package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-D2g4hL2-.js +0 -71
- package/inspector-dist/server/assets/index-BfLBLRRi.js +0 -204
- package/inspector-dist/server/assets/index-BzrGWk7J.js +0 -1164
- package/inspector-dist/server/assets/index-D71yP6AL.js +0 -191
- package/inspector-dist/server/assets/index-wGSWRns3.js +0 -1296
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-DsvuKoEV.js +0 -58
- package/inspector-dist/server/assets/token-ClUZZwXl.js +0 -95
- package/inspector-dist/server/assets/token-util-DSxMZ6nI.js +0 -33
- package/inspector-dist/server/assets/wrapper-B3vstpCO.js +0 -67
- package/inspector-dist/server/assets/zstd-browser-decoder-Dn82m2BU.js +0 -77
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
import { o as __toESM, t as __commonJSMin } from "./rolldown-runtime-C1I3wEg2.js";
|
|
2
|
+
// ../../node_modules/.bun/ms@2.1.3/node_modules/ms/index.js
|
|
3
|
+
var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
/**
|
|
5
|
+
* Helpers.
|
|
6
|
+
*/
|
|
7
|
+
var s = 1e3;
|
|
8
|
+
var m = s * 60;
|
|
9
|
+
var h = m * 60;
|
|
10
|
+
var d = h * 24;
|
|
11
|
+
var w = d * 7;
|
|
12
|
+
var y = d * 365.25;
|
|
13
|
+
/**
|
|
14
|
+
* Parse or format the given `val`.
|
|
15
|
+
*
|
|
16
|
+
* Options:
|
|
17
|
+
*
|
|
18
|
+
* - `long` verbose formatting [false]
|
|
19
|
+
*
|
|
20
|
+
* @param {String|Number} val
|
|
21
|
+
* @param {Object} [options]
|
|
22
|
+
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
23
|
+
* @return {String|Number}
|
|
24
|
+
* @api public
|
|
25
|
+
*/
|
|
26
|
+
module.exports = function(val, options) {
|
|
27
|
+
options = options || {};
|
|
28
|
+
var type = typeof val;
|
|
29
|
+
if (type === "string" && val.length > 0) return parse(val);
|
|
30
|
+
else if (type === "number" && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
|
|
31
|
+
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Parse the given `str` and return milliseconds.
|
|
35
|
+
*
|
|
36
|
+
* @param {String} str
|
|
37
|
+
* @return {Number}
|
|
38
|
+
* @api private
|
|
39
|
+
*/
|
|
40
|
+
function parse(str) {
|
|
41
|
+
str = String(str);
|
|
42
|
+
if (str.length > 100) return;
|
|
43
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
44
|
+
if (!match) return;
|
|
45
|
+
var n = parseFloat(match[1]);
|
|
46
|
+
switch ((match[2] || "ms").toLowerCase()) {
|
|
47
|
+
case "years":
|
|
48
|
+
case "year":
|
|
49
|
+
case "yrs":
|
|
50
|
+
case "yr":
|
|
51
|
+
case "y": return n * y;
|
|
52
|
+
case "weeks":
|
|
53
|
+
case "week":
|
|
54
|
+
case "w": return n * w;
|
|
55
|
+
case "days":
|
|
56
|
+
case "day":
|
|
57
|
+
case "d": return n * d;
|
|
58
|
+
case "hours":
|
|
59
|
+
case "hour":
|
|
60
|
+
case "hrs":
|
|
61
|
+
case "hr":
|
|
62
|
+
case "h": return n * h;
|
|
63
|
+
case "minutes":
|
|
64
|
+
case "minute":
|
|
65
|
+
case "mins":
|
|
66
|
+
case "min":
|
|
67
|
+
case "m": return n * m;
|
|
68
|
+
case "seconds":
|
|
69
|
+
case "second":
|
|
70
|
+
case "secs":
|
|
71
|
+
case "sec":
|
|
72
|
+
case "s": return n * s;
|
|
73
|
+
case "milliseconds":
|
|
74
|
+
case "millisecond":
|
|
75
|
+
case "msecs":
|
|
76
|
+
case "msec":
|
|
77
|
+
case "ms": return n;
|
|
78
|
+
default: return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Short format for `ms`.
|
|
83
|
+
*
|
|
84
|
+
* @param {Number} ms
|
|
85
|
+
* @return {String}
|
|
86
|
+
* @api private
|
|
87
|
+
*/
|
|
88
|
+
function fmtShort(ms) {
|
|
89
|
+
var msAbs = Math.abs(ms);
|
|
90
|
+
if (msAbs >= d) return Math.round(ms / d) + "d";
|
|
91
|
+
if (msAbs >= h) return Math.round(ms / h) + "h";
|
|
92
|
+
if (msAbs >= m) return Math.round(ms / m) + "m";
|
|
93
|
+
if (msAbs >= s) return Math.round(ms / s) + "s";
|
|
94
|
+
return ms + "ms";
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Long format for `ms`.
|
|
98
|
+
*
|
|
99
|
+
* @param {Number} ms
|
|
100
|
+
* @return {String}
|
|
101
|
+
* @api private
|
|
102
|
+
*/
|
|
103
|
+
function fmtLong(ms) {
|
|
104
|
+
var msAbs = Math.abs(ms);
|
|
105
|
+
if (msAbs >= d) return plural(ms, msAbs, d, "day");
|
|
106
|
+
if (msAbs >= h) return plural(ms, msAbs, h, "hour");
|
|
107
|
+
if (msAbs >= m) return plural(ms, msAbs, m, "minute");
|
|
108
|
+
if (msAbs >= s) return plural(ms, msAbs, s, "second");
|
|
109
|
+
return ms + " ms";
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Pluralization helper.
|
|
113
|
+
*/
|
|
114
|
+
function plural(ms, msAbs, n, name) {
|
|
115
|
+
var isPlural = msAbs >= n * 1.5;
|
|
116
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
117
|
+
}
|
|
118
|
+
}));
|
|
119
|
+
// ../../node_modules/.bun/@workflow+utils@5.0.2/node_modules/@workflow/utils/dist/time.js
|
|
120
|
+
var import_ms = /* @__PURE__ */ __toESM(require_ms(), 1);
|
|
121
|
+
/**
|
|
122
|
+
* Parses a duration parameter (string, number, or Date) and returns a Date object
|
|
123
|
+
* representing when the duration should elapse.
|
|
124
|
+
*
|
|
125
|
+
* - For strings: Parses duration strings like "1s", "5m", "1h", etc. using the `ms` library
|
|
126
|
+
* - For numbers: Treats as milliseconds from now
|
|
127
|
+
* - For Date objects: Returns the date directly (handles both Date instances and date-like objects from deserialization)
|
|
128
|
+
*
|
|
129
|
+
* @param param - The duration parameter (StringValue, Date, or number of milliseconds)
|
|
130
|
+
* @returns A Date object representing when the duration should elapse
|
|
131
|
+
* @throws {Error} If the parameter is invalid or cannot be parsed, or the
|
|
132
|
+
* resulting time is not a valid date (an Invalid Date, or a duration that
|
|
133
|
+
* lands past the largest time a Date can hold)
|
|
134
|
+
*/
|
|
135
|
+
function parseDurationToDate(param) {
|
|
136
|
+
const date = durationToDate(param);
|
|
137
|
+
if (Number.isNaN(date.getTime())) throw new Error(typeof param === "object" ? "Invalid date: the Date object does not hold a valid time." : `Invalid duration: ${JSON.stringify(param)} ends past the latest time a Date can represent.`);
|
|
138
|
+
return date;
|
|
139
|
+
}
|
|
140
|
+
function durationToDate(param) {
|
|
141
|
+
if (typeof param === "string") {
|
|
142
|
+
const durationMs = (0, import_ms.default)(param);
|
|
143
|
+
if (typeof durationMs !== "number" || durationMs < 0) throw new Error(`Invalid duration: "${param}". Expected a valid duration string like "1s", "1m", "1h", etc.`);
|
|
144
|
+
return new Date(Date.now() + durationMs);
|
|
145
|
+
} else if (typeof param === "number") {
|
|
146
|
+
if (param < 0 || !Number.isFinite(param)) throw new Error(`Invalid duration: ${param}. Expected a non-negative finite number of milliseconds.`);
|
|
147
|
+
return new Date(Date.now() + param);
|
|
148
|
+
} else if (param instanceof Date || param && typeof param === "object" && typeof param.getTime === "function") return param instanceof Date ? param : new Date(param.getTime());
|
|
149
|
+
else throw new Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`);
|
|
150
|
+
}
|
|
151
|
+
// ../../node_modules/.bun/@workflow+errors@5.1.0/node_modules/@workflow/errors/dist/error-codes.js
|
|
152
|
+
/**
|
|
153
|
+
* Error codes for classifying run failures.
|
|
154
|
+
* These are populated in the `errorCode` field of `run_failed` events
|
|
155
|
+
* and flow through to `StructuredError.code` on the run entity.
|
|
156
|
+
*/
|
|
157
|
+
var RUN_ERROR_CODES = {
|
|
158
|
+
/** Error thrown in user workflow or step code */
|
|
159
|
+
USER_ERROR: "USER_ERROR",
|
|
160
|
+
/** Internal runtime error (missing timestamps, runtime invariant failures) */
|
|
161
|
+
RUNTIME_ERROR: "RUNTIME_ERROR",
|
|
162
|
+
/** Event log contains orphaned or mismatched events and cannot be replayed */
|
|
163
|
+
CORRUPTED_EVENT_LOG: "CORRUPTED_EVENT_LOG",
|
|
164
|
+
/** One replay could not consume the event log deterministically; retryable */
|
|
165
|
+
REPLAY_DIVERGENCE: "REPLAY_DIVERGENCE",
|
|
166
|
+
/** Run exceeded the maximum number of queue deliveries */
|
|
167
|
+
MAX_DELIVERIES_EXCEEDED: "MAX_DELIVERIES_EXCEEDED",
|
|
168
|
+
/** Run exceeded the maximum number of events per run */
|
|
169
|
+
MAX_EVENTS_EXCEEDED: "MAX_EVENTS_EXCEEDED",
|
|
170
|
+
/** Workflow replay exceeded the maximum allowed duration */
|
|
171
|
+
REPLAY_TIMEOUT: "REPLAY_TIMEOUT",
|
|
172
|
+
/** Workflow stream infrastructure failed while reading or writing data */
|
|
173
|
+
STREAM_ERROR: "STREAM_ERROR",
|
|
174
|
+
/** World response violated the SDK contract and cannot be retried safely */
|
|
175
|
+
WORLD_CONTRACT_ERROR: "WORLD_CONTRACT_ERROR",
|
|
176
|
+
/** Run was delivered to a deployment other than the one it is pinned to */
|
|
177
|
+
DEPLOYMENT_MISMATCH: "DEPLOYMENT_MISMATCH"
|
|
178
|
+
};
|
|
179
|
+
// ../../node_modules/.bun/@workflow+errors@5.1.0/node_modules/@workflow/errors/dist/index.js
|
|
180
|
+
var BASE_URL = "https://workflow-sdk.dev/err";
|
|
181
|
+
/**
|
|
182
|
+
* @internal
|
|
183
|
+
* Check if a value is an Error without relying on Node.js utilities.
|
|
184
|
+
* This is needed for error classes that can be used in VM contexts where
|
|
185
|
+
* Node.js imports are not available.
|
|
186
|
+
*/
|
|
187
|
+
function isError(value) {
|
|
188
|
+
return typeof value === "object" && value !== null && "name" in value && "message" in value;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* @internal
|
|
192
|
+
* Compose a framed-detail body for an error message, using the same `╰▶` /
|
|
193
|
+
* `├▶` box-drawing structure used by `ContextViolationError` (in
|
|
194
|
+
* `@workflow/core`), so every error class with a hint or docs slug
|
|
195
|
+
* renders consistently:
|
|
196
|
+
*
|
|
197
|
+
* <title>
|
|
198
|
+
* ├▶ hint: <hint>
|
|
199
|
+
* ╰▶ docs: https://workflow-sdk.dev/err/<slug>
|
|
200
|
+
*
|
|
201
|
+
* Plain text only, no ANSI here, since `@workflow/errors`'s main entry
|
|
202
|
+
* stays chalk-free. The runtime logger renders the same chars with
|
|
203
|
+
* dim styling at log time.
|
|
204
|
+
*
|
|
205
|
+
* Returns only `title` when there are no details to frame. Multi-line
|
|
206
|
+
* detail values are indented under their branch so the tree stays
|
|
207
|
+
* readable.
|
|
208
|
+
*/
|
|
209
|
+
function appendFramedDetails(title, details) {
|
|
210
|
+
if (details.length === 0) return title;
|
|
211
|
+
const lines = [title];
|
|
212
|
+
details.forEach((detail, index) => {
|
|
213
|
+
const isLast = index === details.length - 1;
|
|
214
|
+
const head = isLast ? "╰▶ " : "├▶ ";
|
|
215
|
+
const cont = isLast ? " " : "│ ";
|
|
216
|
+
`${detail.label}: ${detail.value}`.split("\n").forEach((line, i) => {
|
|
217
|
+
lines.push(`${i === 0 ? head : cont}${line}`);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
return lines.join("\n");
|
|
221
|
+
}
|
|
222
|
+
function buildFramedDetails(hint, slug) {
|
|
223
|
+
const out = [];
|
|
224
|
+
if (hint) out.push({
|
|
225
|
+
label: "hint",
|
|
226
|
+
value: hint
|
|
227
|
+
});
|
|
228
|
+
if (slug) out.push({
|
|
229
|
+
label: "docs",
|
|
230
|
+
value: `${BASE_URL}/${slug}`
|
|
231
|
+
});
|
|
232
|
+
return out;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* @internal
|
|
236
|
+
* All the slugs of the errors used for documentation links.
|
|
237
|
+
*/
|
|
238
|
+
var ERROR_SLUGS = {
|
|
239
|
+
NODE_JS_MODULE_IN_WORKFLOW: "node-js-module-in-workflow",
|
|
240
|
+
START_INVALID_WORKFLOW_FUNCTION: "start-invalid-workflow-function",
|
|
241
|
+
SERIALIZATION_FAILED: "serialization-failed",
|
|
242
|
+
WEBHOOK_INVALID_RESPOND_WITH_VALUE: "webhook-invalid-respond-with-value",
|
|
243
|
+
WEBHOOK_RESPONSE_NOT_SENT: "webhook-response-not-sent",
|
|
244
|
+
FETCH_IN_WORKFLOW_FUNCTION: "fetch-in-workflow",
|
|
245
|
+
TIMEOUT_FUNCTIONS_IN_WORKFLOW: "timeout-in-workflow",
|
|
246
|
+
HOOK_CONFLICT: "hook-conflict",
|
|
247
|
+
HOOK_FORCE_CLAIMED: "hook-force-claimed",
|
|
248
|
+
CORRUPTED_EVENT_LOG: "corrupted-event-log",
|
|
249
|
+
REPLAY_DIVERGENCE: "replay-divergence",
|
|
250
|
+
STEP_NOT_REGISTERED: "step-not-registered",
|
|
251
|
+
WORKFLOW_NOT_REGISTERED: "workflow-not-registered",
|
|
252
|
+
RUNTIME_DECRYPTION_FAILED: "runtime-decryption-failed",
|
|
253
|
+
DEPLOYMENT_MISMATCH: "deployment-mismatch",
|
|
254
|
+
MAX_EVENTS_EXCEEDED: "max-events-exceeded",
|
|
255
|
+
REPLAY_TIMEOUT: "replay-timeout"
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* The base class for all Workflow-related errors.
|
|
259
|
+
*
|
|
260
|
+
* This error is thrown by the Workflow SDK when internal operations fail.
|
|
261
|
+
* You can use this class with `instanceof` to catch any Workflow SDK error.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```ts
|
|
265
|
+
* try {
|
|
266
|
+
* await getRun(runId);
|
|
267
|
+
* } catch (error) {
|
|
268
|
+
* if (error instanceof WorkflowError) {
|
|
269
|
+
* console.error('Workflow SDK error:', error.message);
|
|
270
|
+
* }
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
var WorkflowError = class extends Error {
|
|
275
|
+
cause;
|
|
276
|
+
constructor(message, options) {
|
|
277
|
+
const msgDocs = appendFramedDetails(message, buildFramedDetails(void 0, options?.slug));
|
|
278
|
+
super(msgDocs, { cause: options?.cause });
|
|
279
|
+
if (options?.cause !== void 0) this.cause = options.cause;
|
|
280
|
+
if (options?.cause instanceof Error) this.stack = `${this.stack}\nCaused by: ${options.cause.stack}`;
|
|
281
|
+
}
|
|
282
|
+
static is(value) {
|
|
283
|
+
return isError(value) && value.name === "WorkflowError";
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Thrown when a world (storage backend) operation fails unexpectedly.
|
|
288
|
+
*
|
|
289
|
+
* This is the catch-all error for world implementations. Specific,
|
|
290
|
+
* well-known failure modes have dedicated error types (e.g.
|
|
291
|
+
* EntityConflictError, RunExpiredError, ThrottleError). This error
|
|
292
|
+
* covers everything else: validation failures, missing entities
|
|
293
|
+
* without a dedicated type, or unexpected HTTP errors from world-vercel.
|
|
294
|
+
*/
|
|
295
|
+
var WorkflowWorldError = class extends WorkflowError {
|
|
296
|
+
status;
|
|
297
|
+
code;
|
|
298
|
+
url;
|
|
299
|
+
/** Retry-After value in seconds, present on 429 and 425 responses */
|
|
300
|
+
retryAfter;
|
|
301
|
+
/**
|
|
302
|
+
* The offending argument, present on client-side validation failures
|
|
303
|
+
* (`code: 'INVALID_ARGUMENT'`). Lets a caller correct the specific
|
|
304
|
+
* parameter without parsing the message.
|
|
305
|
+
*/
|
|
306
|
+
field;
|
|
307
|
+
/**
|
|
308
|
+
* Why the World gave `code`, when it says. For
|
|
309
|
+
* `START_HOOK_ADMISSION_REJECTED`: `invalid`, `expired`, `token_mismatch`,
|
|
310
|
+
* `ordinary_run` or `disabled`; for `START_HOOK_ADMISSION_DISABLED`:
|
|
311
|
+
* `disabled`.
|
|
312
|
+
*/
|
|
313
|
+
reason;
|
|
314
|
+
constructor(message, options) {
|
|
315
|
+
super(message, { cause: options?.cause });
|
|
316
|
+
this.name = "WorkflowWorldError";
|
|
317
|
+
this.status = options?.status;
|
|
318
|
+
this.code = options?.code;
|
|
319
|
+
this.url = options?.url;
|
|
320
|
+
this.retryAfter = options?.retryAfter;
|
|
321
|
+
this.field = options?.field;
|
|
322
|
+
this.reason = options?.reason;
|
|
323
|
+
}
|
|
324
|
+
static is(value) {
|
|
325
|
+
return isError(value) && value.name === "WorkflowWorldError";
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* `WorkflowWorldError.code` for a `start({ hook })` request the World will
|
|
330
|
+
* never admit: an invalid start Hook, a retention beyond the World's limit, a
|
|
331
|
+
* candidate too old to be created, or a candidate refused while admission was
|
|
332
|
+
* switched off and recorded as refused. Permanent, so the queued copy of the
|
|
333
|
+
* candidate stops retrying on it.
|
|
334
|
+
*/
|
|
335
|
+
var START_HOOK_ADMISSION_REJECTED = "START_HOOK_ADMISSION_REJECTED";
|
|
336
|
+
/**
|
|
337
|
+
* `WorkflowWorldError.code` for a `start({ hook })` request answered while
|
|
338
|
+
* admission is switched off on the backend, with no decision recorded for the
|
|
339
|
+
* candidate. Not final: once admission is back on, another copy of the same
|
|
340
|
+
* candidate can still be admitted. `start()` reports it as
|
|
341
|
+
* `WorkflowStartError`, and the candidate's queued copy is redelivered rather
|
|
342
|
+
* than acknowledged.
|
|
343
|
+
*/
|
|
344
|
+
var START_HOOK_ADMISSION_DISABLED = "START_HOOK_ADMISSION_DISABLED";
|
|
345
|
+
/**
|
|
346
|
+
* `WorkflowWorldError.code` for a `run_cancelled` that reached a
|
|
347
|
+
* `start({ hook })` candidate the World admitted but never created a run for.
|
|
348
|
+
* The World fenced it, so no copy can create it any more, and released its
|
|
349
|
+
* token as for an ended run. `cancel()` treats it as cancelled.
|
|
350
|
+
*/
|
|
351
|
+
var START_HOOK_CANDIDATE_CANCELLED = "START_HOOK_CANDIDATE_CANCELLED";
|
|
352
|
+
/**
|
|
353
|
+
* Thrown when `start()` with a `hook` cannot confirm whether its candidate run
|
|
354
|
+
* was queued (`stage: 'queue'`) or admitted (`stage: 'admission'`). The outcome
|
|
355
|
+
* is unknown, not failed: the candidate may still become the run that owns the
|
|
356
|
+
* token. `runId` identifies the candidate for inspection.
|
|
357
|
+
*
|
|
358
|
+
* Safe to retry while the token is held: if the first candidate was admitted
|
|
359
|
+
* and still holds the token, the retry throws `HookConflictError` naming it;
|
|
360
|
+
* if it was not admitted, the retry's candidate becomes the owner. The token
|
|
361
|
+
* is held until the owner ends, then for any `experimental_minRetention`,
|
|
362
|
+
* unless the owner disposes its start Hook first, which releases it at once
|
|
363
|
+
* (see "Take care with the start Hook's lifecycle" in the `start()` docs). A
|
|
364
|
+
* retry after the token is released is admitted as a new run, so set a
|
|
365
|
+
* retention that covers the retry window, and keep the start Hook open, when
|
|
366
|
+
* a repeat must never run. Inside a workflow, the
|
|
367
|
+
* `start()` step retries it like any other transient failure.
|
|
368
|
+
*
|
|
369
|
+
* Use the static `WorkflowStartError.is()` method for type-safe checking in
|
|
370
|
+
* catch blocks.
|
|
371
|
+
*/
|
|
372
|
+
var WorkflowStartError = class extends WorkflowError {
|
|
373
|
+
/** The candidate run's ID. */
|
|
374
|
+
runId;
|
|
375
|
+
/** The step whose outcome could not be confirmed. */
|
|
376
|
+
stage;
|
|
377
|
+
constructor(runId, stage, cause) {
|
|
378
|
+
const causeMessage = isError(cause) ? cause.message : cause === void 0 ? "unknown error" : String(cause);
|
|
379
|
+
super(`Could not confirm whether workflow run "${runId}" was ${stage === "queue" ? "queued" : "admitted"}: ${causeMessage}. Retrying with the same hook token is safe while the token is held: it never admits a second run while the first one holds it.`, { cause });
|
|
380
|
+
this.name = "WorkflowStartError";
|
|
381
|
+
this.runId = runId;
|
|
382
|
+
this.stage = stage;
|
|
383
|
+
}
|
|
384
|
+
static is(value) {
|
|
385
|
+
return isError(value) && value.name === "WorkflowStartError";
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Thrown when a workflow run fails during execution.
|
|
390
|
+
*
|
|
391
|
+
* This error indicates that the workflow encountered a fatal error and cannot
|
|
392
|
+
* continue. It is thrown when awaiting `run.returnValue` on a run whose status
|
|
393
|
+
* is `'failed'`. The `cause` property contains the underlying error with its
|
|
394
|
+
* message, stack trace, and optional error code.
|
|
395
|
+
*
|
|
396
|
+
* Use the static `WorkflowRunFailedError.is()` method for type-safe checking
|
|
397
|
+
* in catch blocks.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* import { WorkflowRunFailedError } from "workflow/internal/errors";
|
|
402
|
+
*
|
|
403
|
+
* try {
|
|
404
|
+
* const result = await run.returnValue;
|
|
405
|
+
* } catch (error) {
|
|
406
|
+
* if (WorkflowRunFailedError.is(error)) {
|
|
407
|
+
* console.error(`Run ${error.runId} failed:`, error.cause.message);
|
|
408
|
+
* }
|
|
409
|
+
* }
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
var WorkflowRunFailedError = class extends WorkflowError {
|
|
413
|
+
/**
|
|
414
|
+
* `failed` is terminal, and a run's terminal state is immutable. This error
|
|
415
|
+
* is only ever thrown after a *successful* read of such a run, so re-running
|
|
416
|
+
* the read returns the same record and throws the same error. Marking it
|
|
417
|
+
* non-retryable is what stops the step executor from spending a retry budget
|
|
418
|
+
* on that when the read happens inside a step — a parent awaiting a child's
|
|
419
|
+
* `returnValue` — and then replacing this error with its retry-exhaustion
|
|
420
|
+
* wrapper. A read that *fails* throws something else and stays retryable.
|
|
421
|
+
* See `FatalError.is()`.
|
|
422
|
+
*/
|
|
423
|
+
fatal = true;
|
|
424
|
+
runId;
|
|
425
|
+
/**
|
|
426
|
+
* The high-level error category (e.g. USER_ERROR, RUNTIME_ERROR) for the
|
|
427
|
+
* failed run, from the run_failed event's `errorCode` field.
|
|
428
|
+
*/
|
|
429
|
+
errorCode;
|
|
430
|
+
constructor(runId, error, options = {}) {
|
|
431
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : error && typeof error === "object" && "message" in error ? String(error.message) : "Unknown error";
|
|
432
|
+
super(`Workflow run "${runId}" failed: ${message}`, { cause: error });
|
|
433
|
+
this.name = "WorkflowRunFailedError";
|
|
434
|
+
this.runId = runId;
|
|
435
|
+
if (options.errorCode !== void 0) this.errorCode = options.errorCode;
|
|
436
|
+
}
|
|
437
|
+
static is(value) {
|
|
438
|
+
return isError(value) && value.name === "WorkflowRunFailedError";
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Thrown when attempting to get results from an incomplete workflow run.
|
|
443
|
+
*
|
|
444
|
+
* This error occurs when you try to access the result of a workflow
|
|
445
|
+
* that is still running or hasn't completed yet.
|
|
446
|
+
*/
|
|
447
|
+
var WorkflowRunNotCompletedError = class extends WorkflowError {
|
|
448
|
+
runId;
|
|
449
|
+
status;
|
|
450
|
+
constructor(runId, status) {
|
|
451
|
+
super(`Workflow run "${runId}" has not completed`, {});
|
|
452
|
+
this.name = "WorkflowRunNotCompletedError";
|
|
453
|
+
this.runId = runId;
|
|
454
|
+
this.status = status;
|
|
455
|
+
}
|
|
456
|
+
static is(value) {
|
|
457
|
+
return isError(value) && value.name === "WorkflowRunNotCompletedError";
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
/**
|
|
461
|
+
* Thrown when the Workflow runtime encounters an internal error.
|
|
462
|
+
*
|
|
463
|
+
* This error indicates an issue with workflow execution, such as
|
|
464
|
+
* serialization failures, starting an invalid workflow function, or
|
|
465
|
+
* other runtime problems.
|
|
466
|
+
*/
|
|
467
|
+
var WorkflowRuntimeError = class extends WorkflowError {
|
|
468
|
+
constructor(message, options) {
|
|
469
|
+
super(message, { ...options });
|
|
470
|
+
this.name = "WorkflowRuntimeError";
|
|
471
|
+
}
|
|
472
|
+
static is(value) {
|
|
473
|
+
return isError(value) && value.name === "WorkflowRuntimeError";
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* Thrown when the persisted workflow event log cannot be replayed because it
|
|
478
|
+
* contains orphaned, duplicate, or mismatched events.
|
|
479
|
+
*
|
|
480
|
+
* This is a runtime/infrastructure failure rather than user code throwing.
|
|
481
|
+
* When this reaches run failure handling, it is recorded with the distinct
|
|
482
|
+
* `CORRUPTED_EVENT_LOG` code so worlds and backends can track it separately
|
|
483
|
+
* from generic runtime failures.
|
|
484
|
+
*/
|
|
485
|
+
var CorruptedEventLogError = class extends WorkflowRuntimeError {
|
|
486
|
+
constructor(message, options) {
|
|
487
|
+
super(message, {
|
|
488
|
+
...options,
|
|
489
|
+
slug: ERROR_SLUGS.CORRUPTED_EVENT_LOG
|
|
490
|
+
});
|
|
491
|
+
this.name = "CorruptedEventLogError";
|
|
492
|
+
}
|
|
493
|
+
static is(value) {
|
|
494
|
+
return isError(value) && value.name === "CorruptedEventLogError";
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* Thrown when the SDK's built-in AES-GCM encryption layer fails to encrypt
|
|
499
|
+
* or decrypt a workflow payload.
|
|
500
|
+
*
|
|
501
|
+
* This is an internal SDK failure: user code never invokes the SDK's
|
|
502
|
+
* encryption primitives directly. Common causes:
|
|
503
|
+
*
|
|
504
|
+
* - A ciphertext / auth tag mismatch, typically surfaced as the native Web
|
|
505
|
+
* Crypto `OperationError: The operation failed for an operation-specific
|
|
506
|
+
* reason`. Usually caused by ciphertext mutation or truncation in transit
|
|
507
|
+
* between storage and read (truncated HTTP response, edge-cache miss
|
|
508
|
+
* returning a partial 200, proxy drop during streaming, etc.).
|
|
509
|
+
* - A key resolution mismatch (wrong deployment, missing key material).
|
|
510
|
+
* - A malformed encrypted envelope (too short to contain the GCM nonce
|
|
511
|
+
* and tag).
|
|
512
|
+
*
|
|
513
|
+
* Extends {@link WorkflowRuntimeError} so the run-failure classifier
|
|
514
|
+
* routes it to `RUNTIME_ERROR`.
|
|
515
|
+
*/
|
|
516
|
+
var RuntimeDecryptionError = class extends WorkflowRuntimeError {
|
|
517
|
+
constructor(message, options) {
|
|
518
|
+
super(message, {
|
|
519
|
+
cause: options?.cause,
|
|
520
|
+
slug: ERROR_SLUGS.RUNTIME_DECRYPTION_FAILED
|
|
521
|
+
});
|
|
522
|
+
this.name = "RuntimeDecryptionError";
|
|
523
|
+
if (options?.context !== void 0) this.context = options.context;
|
|
524
|
+
}
|
|
525
|
+
static is(value) {
|
|
526
|
+
return isError(value) && value.name === "RuntimeDecryptionError";
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* Thrown when a stream's encryption key cannot be resolved and retrying will
|
|
531
|
+
* not help: the key lookup failed with something other than a transient world
|
|
532
|
+
* error (e.g. a `404`, or the run that owns the stream does not exist). The
|
|
533
|
+
* original failure is the `cause`.
|
|
534
|
+
*
|
|
535
|
+
* Transient lookup failures (transport, timeout, or an HTTP `429` / `5xx`
|
|
536
|
+
* status, whether or not the world threw a `WorkflowWorldError`) are not
|
|
537
|
+
* wrapped in this error; they surface as themselves so the step retries.
|
|
538
|
+
*
|
|
539
|
+
* Fatal, so the step skips the retry loop.
|
|
540
|
+
*/
|
|
541
|
+
var EncryptionKeyLookupError = class extends WorkflowRuntimeError {
|
|
542
|
+
fatal = true;
|
|
543
|
+
constructor(message, options) {
|
|
544
|
+
super(message, { cause: options?.cause });
|
|
545
|
+
this.name = "EncryptionKeyLookupError";
|
|
546
|
+
}
|
|
547
|
+
static is(value) {
|
|
548
|
+
return isError(value) && value.name === "EncryptionKeyLookupError";
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
552
|
+
* Thrown when a value cannot be serialized into or deserialized out of the
|
|
553
|
+
* workflow event log.
|
|
554
|
+
*
|
|
555
|
+
* This usually indicates a user-facing mistake: passing a non-serializable
|
|
556
|
+
* value (class without `WORKFLOW_SERIALIZE`, locked stream, direct workflow
|
|
557
|
+
* function reference) into a step boundary, or an unregistered class
|
|
558
|
+
* returning from a step.
|
|
559
|
+
*
|
|
560
|
+
* Internal invariants (corrupted buffers, unknown format bytes) should use
|
|
561
|
+
* `WorkflowRuntimeError` instead; this class is scoped to things the user
|
|
562
|
+
* can fix in their own code.
|
|
563
|
+
*/
|
|
564
|
+
var SerializationError = class extends WorkflowError {
|
|
565
|
+
hint;
|
|
566
|
+
/**
|
|
567
|
+
* Serialization errors are deterministic: if a step returns a non-POJO,
|
|
568
|
+
* replaying the step will always produce the same non-serializable value.
|
|
569
|
+
* Retrying is guaranteed to fail, so these errors are surfaced as fatal
|
|
570
|
+
* and skip the step-retry loop. `FatalError.is()` recognizes any error
|
|
571
|
+
* with `fatal: true` (see `packages/errors/src/index.ts`), so no other
|
|
572
|
+
* wiring is required for user-thrown SerializationErrors.
|
|
573
|
+
*/
|
|
574
|
+
fatal = true;
|
|
575
|
+
constructor(message, options) {
|
|
576
|
+
const body = appendFramedDetails(message, buildFramedDetails(options?.hint, void 0));
|
|
577
|
+
super(body, { cause: options?.cause });
|
|
578
|
+
this.name = "SerializationError";
|
|
579
|
+
this.hint = options?.hint;
|
|
580
|
+
}
|
|
581
|
+
static is(value) {
|
|
582
|
+
return isError(value) && value.name === "SerializationError";
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
/**
|
|
586
|
+
* Thrown when a step function is not registered in the current deployment.
|
|
587
|
+
*
|
|
588
|
+
* This is an infrastructure error, not a user code error. It typically means
|
|
589
|
+
* something went wrong with the bundling/build tooling that caused the step
|
|
590
|
+
* to not get built correctly.
|
|
591
|
+
*
|
|
592
|
+
* When this happens, the step fails (like a FatalError) and control is passed back
|
|
593
|
+
* to the workflow function, which can optionally handle the failure gracefully.
|
|
594
|
+
*/
|
|
595
|
+
var StepNotRegisteredError = class extends WorkflowRuntimeError {
|
|
596
|
+
stepName;
|
|
597
|
+
constructor(stepName) {
|
|
598
|
+
super(`Step "${stepName}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`, { slug: ERROR_SLUGS.STEP_NOT_REGISTERED });
|
|
599
|
+
this.name = "StepNotRegisteredError";
|
|
600
|
+
this.stepName = stepName;
|
|
601
|
+
}
|
|
602
|
+
static is(value) {
|
|
603
|
+
return isError(value) && value.name === "StepNotRegisteredError";
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
607
|
+
* Thrown when a workflow function is not registered in the current deployment.
|
|
608
|
+
*
|
|
609
|
+
* This is an infrastructure error, not a user code error. It typically means:
|
|
610
|
+
* - A run was started against a deployment that does not have the workflow
|
|
611
|
+
* (e.g., the workflow was renamed or moved and a new run targeted the latest deployment)
|
|
612
|
+
* - Something went wrong with the bundling/build tooling that caused the workflow
|
|
613
|
+
* to not get built correctly
|
|
614
|
+
*
|
|
615
|
+
* When this happens, the run fails with a `RUNTIME_ERROR` error code.
|
|
616
|
+
*/
|
|
617
|
+
var WorkflowNotRegisteredError = class extends WorkflowRuntimeError {
|
|
618
|
+
workflowName;
|
|
619
|
+
constructor(workflowName) {
|
|
620
|
+
super(`Workflow "${workflowName}" is not registered in the current deployment. This usually means a run was started against a deployment that does not have this workflow, or there was a build/bundling issue.`, { slug: ERROR_SLUGS.WORKFLOW_NOT_REGISTERED });
|
|
621
|
+
this.name = "WorkflowNotRegisteredError";
|
|
622
|
+
this.workflowName = workflowName;
|
|
623
|
+
}
|
|
624
|
+
static is(value) {
|
|
625
|
+
return isError(value) && value.name === "WorkflowNotRegisteredError";
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
* Thrown when performing operations on a workflow run that does not exist.
|
|
630
|
+
*
|
|
631
|
+
* This error occurs when you call methods on a run object (e.g. `run.status`,
|
|
632
|
+
* `run.cancel()`, `run.returnValue`) but the underlying run ID does not match
|
|
633
|
+
* any known workflow run. Note that `getRun(id)` itself is synchronous and will
|
|
634
|
+
* not throw; this error is raised when subsequent operations discover the run
|
|
635
|
+
* is missing.
|
|
636
|
+
*
|
|
637
|
+
* Use the static `WorkflowRunNotFoundError.is()` method for type-safe checking
|
|
638
|
+
* in catch blocks.
|
|
639
|
+
*
|
|
640
|
+
* @example
|
|
641
|
+
* ```ts
|
|
642
|
+
* import { WorkflowRunNotFoundError } from "workflow/internal/errors";
|
|
643
|
+
*
|
|
644
|
+
* try {
|
|
645
|
+
* const status = await run.status;
|
|
646
|
+
* } catch (error) {
|
|
647
|
+
* if (WorkflowRunNotFoundError.is(error)) {
|
|
648
|
+
* console.error(`Run ${error.runId} does not exist`);
|
|
649
|
+
* }
|
|
650
|
+
* }
|
|
651
|
+
* ```
|
|
652
|
+
*/
|
|
653
|
+
var WorkflowRunNotFoundError = class extends WorkflowError {
|
|
654
|
+
runId;
|
|
655
|
+
constructor(runId) {
|
|
656
|
+
super(`Workflow run "${runId}" not found`, {});
|
|
657
|
+
this.name = "WorkflowRunNotFoundError";
|
|
658
|
+
this.runId = runId;
|
|
659
|
+
}
|
|
660
|
+
static is(value) {
|
|
661
|
+
return isError(value) && value.name === "WorkflowRunNotFoundError";
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
/**
|
|
665
|
+
* Thrown when a hook token is already in use by another active workflow run.
|
|
666
|
+
*
|
|
667
|
+
* This is a user error: it means the same custom token was passed to
|
|
668
|
+
* `createHook` in two or more concurrent runs. Use a unique token per run
|
|
669
|
+
* (or omit the token to let the runtime generate one automatically).
|
|
670
|
+
*
|
|
671
|
+
* `start(workflow, args, { hook })` throws it with `kind: 'start'` for a
|
|
672
|
+
* duplicate start: no run was created, and `conflictingRunId` owns the token.
|
|
673
|
+
*/
|
|
674
|
+
var HookConflictError = class extends WorkflowError {
|
|
675
|
+
token;
|
|
676
|
+
conflictingRunId;
|
|
677
|
+
/** `'start'` when a `start({ hook })` was refused; no run was created. */
|
|
678
|
+
kind;
|
|
679
|
+
constructor(token, conflictingRunId, options) {
|
|
680
|
+
super(options?.kind === "start" ? `No run was created: workflow run "${conflictingRunId}" already owns this hook token` : `Hook token "${token}" is already in use by another workflow${conflictingRunId ? ` (run "${conflictingRunId}")` : ""}`, { slug: ERROR_SLUGS.HOOK_CONFLICT });
|
|
681
|
+
this.name = "HookConflictError";
|
|
682
|
+
this.token = token;
|
|
683
|
+
if (conflictingRunId !== void 0) this.conflictingRunId = conflictingRunId;
|
|
684
|
+
if (options?.kind !== void 0) this.kind = options.kind;
|
|
685
|
+
}
|
|
686
|
+
static is(value) {
|
|
687
|
+
return isError(value) && value.name === "HookConflictError";
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
/**
|
|
691
|
+
* Thrown from `await hook` (or the hook's async iterator) when another run
|
|
692
|
+
* took this hook's token with `createHook({ token, experimental_force: true })`.
|
|
693
|
+
*
|
|
694
|
+
* The hook is disposed: payloads it received before the takeover were still
|
|
695
|
+
* delivered, everything after goes to the new owner, and this run's log holds
|
|
696
|
+
* a `hook_disposed` naming the run that took it. Whether that ends the run is
|
|
697
|
+
* the workflow's call — catch it to hand over gracefully, or let it fail.
|
|
698
|
+
*
|
|
699
|
+
* Use the static `HookForceClaimedError.is()` method for type-safe checking
|
|
700
|
+
* in catch blocks; the class identity differs between the workflow VM and the
|
|
701
|
+
* host, so `instanceof` is not reliable across that boundary.
|
|
702
|
+
*/
|
|
703
|
+
var HookForceClaimedError = class extends WorkflowError {
|
|
704
|
+
token;
|
|
705
|
+
/** The run that took the token. */
|
|
706
|
+
claimedByRunId;
|
|
707
|
+
/** The hook (in `claimedByRunId`) the token now belongs to. */
|
|
708
|
+
claimedByHookId;
|
|
709
|
+
constructor(token, claimedByRunId, claimedByHookId) {
|
|
710
|
+
super(`Hook token "${token}" was force-claimed by another workflow (run "${claimedByRunId}")`, { slug: ERROR_SLUGS.HOOK_FORCE_CLAIMED });
|
|
711
|
+
this.name = "HookForceClaimedError";
|
|
712
|
+
this.token = token;
|
|
713
|
+
this.claimedByRunId = claimedByRunId;
|
|
714
|
+
if (claimedByHookId !== void 0) this.claimedByHookId = claimedByHookId;
|
|
715
|
+
}
|
|
716
|
+
static is(value) {
|
|
717
|
+
return isError(value) && value.name === "HookForceClaimedError";
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* Thrown when calling `resumeHook()` or `resumeWebhook()` with a token that
|
|
722
|
+
* does not match any active hook.
|
|
723
|
+
*
|
|
724
|
+
* Common causes:
|
|
725
|
+
* - The hook has expired (past its TTL)
|
|
726
|
+
* - The hook was already disposed after being consumed
|
|
727
|
+
* - The workflow has not started yet, so the hook does not exist
|
|
728
|
+
*
|
|
729
|
+
* A common pattern is to catch this error and start a new workflow run when
|
|
730
|
+
* the hook does not exist yet (the "resume or start" pattern).
|
|
731
|
+
*
|
|
732
|
+
* Use the static `HookNotFoundError.is()` method for type-safe checking in
|
|
733
|
+
* catch blocks.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* ```ts
|
|
737
|
+
* import { HookNotFoundError } from "workflow/internal/errors";
|
|
738
|
+
*
|
|
739
|
+
* try {
|
|
740
|
+
* await resumeHook(token, payload);
|
|
741
|
+
* } catch (error) {
|
|
742
|
+
* if (HookNotFoundError.is(error)) {
|
|
743
|
+
* // Hook doesn't exist, so start a new workflow run instead
|
|
744
|
+
* await startWorkflow("myWorkflow", payload);
|
|
745
|
+
* }
|
|
746
|
+
* }
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
var HookNotFoundError = class extends WorkflowError {
|
|
750
|
+
token;
|
|
751
|
+
constructor(token) {
|
|
752
|
+
super("Hook not found", {});
|
|
753
|
+
this.name = "HookNotFoundError";
|
|
754
|
+
this.token = token;
|
|
755
|
+
}
|
|
756
|
+
static is(value) {
|
|
757
|
+
return isError(value) && value.name === "HookNotFoundError";
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
/**
|
|
761
|
+
* Thrown when an operation conflicts with the current state of an entity.
|
|
762
|
+
* This includes attempts to modify an entity already in a terminal state,
|
|
763
|
+
* create an entity that already exists, or any other 409-style conflict.
|
|
764
|
+
*
|
|
765
|
+
* The workflow runtime handles this error automatically. Users interacting
|
|
766
|
+
* with world storage backends directly may encounter it.
|
|
767
|
+
*/
|
|
768
|
+
var EntityConflictError = class extends WorkflowWorldError {
|
|
769
|
+
constructor(message) {
|
|
770
|
+
super(message);
|
|
771
|
+
this.name = "EntityConflictError";
|
|
772
|
+
}
|
|
773
|
+
static is(value) {
|
|
774
|
+
return isError(value) && value.name === "EntityConflictError";
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
/**
|
|
778
|
+
* Thrown when a run is no longer available, either because it has been
|
|
779
|
+
* cleaned up, expired, or already reached a terminal state (completed/failed).
|
|
780
|
+
*
|
|
781
|
+
* Also thrown by `await run.returnValue` when the run's data passed its
|
|
782
|
+
* retention boundary — because it was started with
|
|
783
|
+
* `experimental_retention: 0`, or simply because it aged out of the World's
|
|
784
|
+
* default window. The run's metadata usually outlives its payloads, so
|
|
785
|
+
* `runStatus` and `expiredAt` are populated when the World still has them: the
|
|
786
|
+
* caller can tell "it succeeded, but the result is gone" from "it failed".
|
|
787
|
+
* When even the metadata is gone the World reports the run as missing and you
|
|
788
|
+
* get {@link WorkflowRunNotFoundError} instead.
|
|
789
|
+
*
|
|
790
|
+
* This is terminal. Retrying cannot bring the data back.
|
|
791
|
+
*/
|
|
792
|
+
var RunExpiredError = class extends WorkflowWorldError {
|
|
793
|
+
runId;
|
|
794
|
+
runStatus;
|
|
795
|
+
expiredAt;
|
|
796
|
+
constructor(message, runId, runStatus, expiredAt) {
|
|
797
|
+
super(message, {
|
|
798
|
+
status: 410,
|
|
799
|
+
code: "run-expired"
|
|
800
|
+
});
|
|
801
|
+
this.runId = runId;
|
|
802
|
+
this.runStatus = runStatus;
|
|
803
|
+
this.expiredAt = expiredAt;
|
|
804
|
+
this.name = "RunExpiredError";
|
|
805
|
+
}
|
|
806
|
+
static is(value) {
|
|
807
|
+
return isError(value) && value.name === "RunExpiredError";
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
/**
|
|
811
|
+
* Thrown when Workflow's stream infrastructure fails to read or write data.
|
|
812
|
+
* The failure is attributable to the Workflow service rather than user code.
|
|
813
|
+
*/
|
|
814
|
+
var StreamError = class extends WorkflowWorldError {
|
|
815
|
+
constructor(message, options) {
|
|
816
|
+
super(message, {
|
|
817
|
+
code: RUN_ERROR_CODES.STREAM_ERROR,
|
|
818
|
+
cause: options?.cause,
|
|
819
|
+
url: options?.url,
|
|
820
|
+
status: options?.status
|
|
821
|
+
});
|
|
822
|
+
this.name = "StreamError";
|
|
823
|
+
}
|
|
824
|
+
static is(value) {
|
|
825
|
+
return isError(value) && value.name === "StreamError";
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
/**
|
|
829
|
+
* Thrown when a stream is no longer readable because its owning run passed its
|
|
830
|
+
* storage-retention boundary. This is terminal: retrying cannot restore data.
|
|
831
|
+
*
|
|
832
|
+
* Unlike {@link RunExpiredError}, this identifies the failed stream read and
|
|
833
|
+
* exposes the server's authoritative expiry timestamp for user-facing errors.
|
|
834
|
+
*/
|
|
835
|
+
var StreamExpiredError = class extends WorkflowWorldError {
|
|
836
|
+
runId;
|
|
837
|
+
streamId;
|
|
838
|
+
expiredAt;
|
|
839
|
+
constructor(message, runId, streamId, expiredAt) {
|
|
840
|
+
super(message, {
|
|
841
|
+
status: 410,
|
|
842
|
+
code: "stream-expired"
|
|
843
|
+
});
|
|
844
|
+
this.runId = runId;
|
|
845
|
+
this.streamId = streamId;
|
|
846
|
+
this.expiredAt = expiredAt;
|
|
847
|
+
this.name = "StreamExpiredError";
|
|
848
|
+
}
|
|
849
|
+
static is(value) {
|
|
850
|
+
return isError(value) && value.name === "StreamExpiredError";
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
/**
|
|
854
|
+
* Thrown when an operation cannot proceed because a required timestamp
|
|
855
|
+
* (e.g. retryAfter) has not been reached yet.
|
|
856
|
+
*
|
|
857
|
+
* The workflow runtime handles this error automatically. Users interacting
|
|
858
|
+
* with world storage backends directly may encounter it.
|
|
859
|
+
*
|
|
860
|
+
* @property retryAfter - Delay in seconds before the operation can be retried.
|
|
861
|
+
*/
|
|
862
|
+
var TooEarlyError = class extends WorkflowWorldError {
|
|
863
|
+
constructor(message, options) {
|
|
864
|
+
super(message, { retryAfter: options?.retryAfter });
|
|
865
|
+
this.name = "TooEarlyError";
|
|
866
|
+
}
|
|
867
|
+
static is(value) {
|
|
868
|
+
return isError(value) && value.name === "TooEarlyError";
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
/**
|
|
872
|
+
* Thrown when a request is rate limited by the workflow backend.
|
|
873
|
+
*
|
|
874
|
+
* The workflow runtime handles this error automatically with retry logic.
|
|
875
|
+
* Users interacting with world storage backends directly may encounter it
|
|
876
|
+
* if retries are exhausted.
|
|
877
|
+
*
|
|
878
|
+
* @property retryAfter - Delay in seconds before the request can be retried.
|
|
879
|
+
*/
|
|
880
|
+
var ThrottleError = class extends WorkflowWorldError {
|
|
881
|
+
retryAfter;
|
|
882
|
+
constructor(message, options) {
|
|
883
|
+
super(message);
|
|
884
|
+
this.name = "ThrottleError";
|
|
885
|
+
this.retryAfter = options?.retryAfter;
|
|
886
|
+
}
|
|
887
|
+
static is(value) {
|
|
888
|
+
return isError(value) && value.name === "ThrottleError";
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
/**
|
|
892
|
+
* Thrown when the backend rejects an event creation because the client's
|
|
893
|
+
* event-log snapshot is stale: the log the client replayed from is missing
|
|
894
|
+
* an event the backend has already recorded (HTTP 412).
|
|
895
|
+
*
|
|
896
|
+
* The workflow runtime handles this automatically: it restarts the replay from
|
|
897
|
+
* a corrected event log, ultimately re-enqueueing the run if it cannot catch
|
|
898
|
+
* up. Users interacting with world storage backends directly may encounter it.
|
|
899
|
+
*
|
|
900
|
+
* @property retryAfter - Delay in seconds before retrying. Accepted for
|
|
901
|
+
* forward-compatibility; the runtime restarts its replay immediately and
|
|
902
|
+
* does not read this field.
|
|
903
|
+
* @property details - Optional rejection detail supplied by the World. A World
|
|
904
|
+
* MAY attach the events the client's snapshot was missing so the client can
|
|
905
|
+
* correct its log without a follow-up fetch. The attached set must account
|
|
906
|
+
* for the whole discrepancy the rejection reported or be omitted entirely; a
|
|
907
|
+
* client that receives nothing does the authoritative full reload, which is
|
|
908
|
+
* always correct. Typed `unknown` because this package cannot depend
|
|
909
|
+
* on the event type; consumers narrow it themselves and must treat a
|
|
910
|
+
* missing or malformed value as "no detail" (a full reload is always
|
|
911
|
+
* correct).
|
|
912
|
+
*/
|
|
913
|
+
var PreconditionFailedError = class extends WorkflowWorldError {
|
|
914
|
+
details;
|
|
915
|
+
constructor(message, options) {
|
|
916
|
+
super(message, {
|
|
917
|
+
status: 412,
|
|
918
|
+
retryAfter: options?.retryAfter
|
|
919
|
+
});
|
|
920
|
+
this.name = "PreconditionFailedError";
|
|
921
|
+
this.details = options?.details;
|
|
922
|
+
}
|
|
923
|
+
static is(value) {
|
|
924
|
+
return isError(value) && value.name === "PreconditionFailedError";
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
/** Error code a World uses for an {@link InBandSupersededError} refusal. */
|
|
928
|
+
var IN_BAND_SUPERSEDED_CODE = "in-band-superseded";
|
|
929
|
+
/**
|
|
930
|
+
* Thrown when a World refuses an in-band write (a write made by the run's
|
|
931
|
+
* orchestrator) because another orchestrator invocation of the same run has
|
|
932
|
+
* written in-band since this one loaded the log (HTTP 412,
|
|
933
|
+
* `in-band-superseded`).
|
|
934
|
+
*
|
|
935
|
+
* The in-band fence is what keeps a run to one orchestrator writer. An
|
|
936
|
+
* invocation that receives this error has been superseded: it stops writing
|
|
937
|
+
* and stops running step bodies, sends the queue messages its own committed
|
|
938
|
+
* writes still owe (background step messages, wait timers), and asks for a
|
|
939
|
+
* redelivery of its queue message instead of acknowledging it: the
|
|
940
|
+
* redelivery re-sends what a second delivery of the same message may have
|
|
941
|
+
* committed and never sent, and continues the run if no other invocation
|
|
942
|
+
* does. The runtime handles all of this;
|
|
943
|
+
* users calling a World's storage API directly may encounter it.
|
|
944
|
+
*
|
|
945
|
+
* @property seq - The run's allocated position count at the time of the
|
|
946
|
+
* refusal, when the World reports it. Diagnostic only.
|
|
947
|
+
* @property seqInBand - The run's in-band position count at the time of the
|
|
948
|
+
* refusal, when the World reports it. Diagnostic only: a client must never
|
|
949
|
+
* adopt it as its own count, since that would make it a writer without
|
|
950
|
+
* having seen the events the count stands for.
|
|
951
|
+
*/
|
|
952
|
+
var InBandSupersededError = class extends WorkflowWorldError {
|
|
953
|
+
seq;
|
|
954
|
+
seqInBand;
|
|
955
|
+
constructor(message, options) {
|
|
956
|
+
super(message, {
|
|
957
|
+
status: 412,
|
|
958
|
+
code: IN_BAND_SUPERSEDED_CODE
|
|
959
|
+
});
|
|
960
|
+
this.name = "InBandSupersededError";
|
|
961
|
+
this.seq = options?.seq;
|
|
962
|
+
this.seqInBand = options?.seqInBand;
|
|
963
|
+
}
|
|
964
|
+
static is(value) {
|
|
965
|
+
return isError(value) && value.name === "InBandSupersededError";
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
/**
|
|
969
|
+
* Thrown when awaiting `run.returnValue` on a workflow run that was cancelled.
|
|
970
|
+
*
|
|
971
|
+
* This error indicates that the workflow was explicitly cancelled (via
|
|
972
|
+
* `run.cancel()`) and will not produce a return value. You can check for
|
|
973
|
+
* cancellation before awaiting the return value by inspecting `run.status`.
|
|
974
|
+
*
|
|
975
|
+
* Use the static `WorkflowRunCancelledError.is()` method for type-safe
|
|
976
|
+
* checking in catch blocks.
|
|
977
|
+
*
|
|
978
|
+
* @example
|
|
979
|
+
* ```ts
|
|
980
|
+
* import { WorkflowRunCancelledError } from "workflow/internal/errors";
|
|
981
|
+
*
|
|
982
|
+
* try {
|
|
983
|
+
* const result = await run.returnValue;
|
|
984
|
+
* } catch (error) {
|
|
985
|
+
* if (WorkflowRunCancelledError.is(error)) {
|
|
986
|
+
* console.log(`Run ${error.runId} was cancelled`);
|
|
987
|
+
* }
|
|
988
|
+
* }
|
|
989
|
+
* ```
|
|
990
|
+
*/
|
|
991
|
+
var WorkflowRunCancelledError = class extends WorkflowError {
|
|
992
|
+
/** Terminal and immutable, for the same reason as {@link WorkflowRunFailedError.fatal}. */
|
|
993
|
+
fatal = true;
|
|
994
|
+
runId;
|
|
995
|
+
constructor(runId) {
|
|
996
|
+
super(`Workflow run "${runId}" cancelled`, {});
|
|
997
|
+
this.name = "WorkflowRunCancelledError";
|
|
998
|
+
this.runId = runId;
|
|
999
|
+
}
|
|
1000
|
+
static is(value) {
|
|
1001
|
+
return isError(value) && value.name === "WorkflowRunCancelledError";
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
/**
|
|
1005
|
+
* Thrown when attempting to operate on a workflow run that requires a newer World version.
|
|
1006
|
+
*
|
|
1007
|
+
* This error occurs when a run was created with a newer spec version than the
|
|
1008
|
+
* current World implementation supports. To resolve this, upgrade your
|
|
1009
|
+
* `workflow` packages to a version that supports the required spec version.
|
|
1010
|
+
*
|
|
1011
|
+
* Use the static `RunNotSupportedError.is()` method for type-safe checking in
|
|
1012
|
+
* catch blocks.
|
|
1013
|
+
*
|
|
1014
|
+
* @example
|
|
1015
|
+
* ```ts
|
|
1016
|
+
* import { RunNotSupportedError } from "workflow/internal/errors";
|
|
1017
|
+
*
|
|
1018
|
+
* try {
|
|
1019
|
+
* const status = await run.status;
|
|
1020
|
+
* } catch (error) {
|
|
1021
|
+
* if (RunNotSupportedError.is(error)) {
|
|
1022
|
+
* console.error(
|
|
1023
|
+
* `Run requires spec v${error.runSpecVersion}, ` +
|
|
1024
|
+
* `but world supports v${error.worldSpecVersion}`
|
|
1025
|
+
* );
|
|
1026
|
+
* }
|
|
1027
|
+
* }
|
|
1028
|
+
* ```
|
|
1029
|
+
*/
|
|
1030
|
+
var RunNotSupportedError = class extends WorkflowError {
|
|
1031
|
+
runSpecVersion;
|
|
1032
|
+
worldSpecVersion;
|
|
1033
|
+
constructor(runSpecVersion, worldSpecVersion) {
|
|
1034
|
+
super(`Run requires spec version ${runSpecVersion}, but world supports version ${worldSpecVersion}. Please upgrade 'workflow' package.`);
|
|
1035
|
+
this.name = "RunNotSupportedError";
|
|
1036
|
+
this.runSpecVersion = runSpecVersion;
|
|
1037
|
+
this.worldSpecVersion = worldSpecVersion;
|
|
1038
|
+
}
|
|
1039
|
+
static is(value) {
|
|
1040
|
+
return isError(value) && value.name === "RunNotSupportedError";
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
/**
|
|
1044
|
+
* A fatal error is an error that cannot be retried.
|
|
1045
|
+
* It will cause the step to fail and the error will
|
|
1046
|
+
* be bubbled up to the workflow logic.
|
|
1047
|
+
*
|
|
1048
|
+
* Any error can opt into the non-retry behavior by setting a `fatal: true`
|
|
1049
|
+
* own property. This is how structured error classes that aren't direct
|
|
1050
|
+
* `FatalError` subclasses (e.g. context-violation errors) signal to the
|
|
1051
|
+
* step executor that retrying will never help (the user's code is calling
|
|
1052
|
+
* a workflow-only API from the wrong context, or similar) and burning
|
|
1053
|
+
* retry attempts produces a wall of duplicated log output.
|
|
1054
|
+
*/
|
|
1055
|
+
var FatalError = class extends Error {
|
|
1056
|
+
fatal = true;
|
|
1057
|
+
constructor(message) {
|
|
1058
|
+
super(message);
|
|
1059
|
+
this.name = "FatalError";
|
|
1060
|
+
}
|
|
1061
|
+
static is(value) {
|
|
1062
|
+
if (!isError(value)) return false;
|
|
1063
|
+
if (value.name === "FatalError") return true;
|
|
1064
|
+
return value.fatal === true;
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
/**
|
|
1068
|
+
* An error that can happen during a step execution, allowing
|
|
1069
|
+
* for configuration of the retry behavior.
|
|
1070
|
+
*/
|
|
1071
|
+
var RetryableError = class extends Error {
|
|
1072
|
+
/**
|
|
1073
|
+
* The Date when the step should be retried.
|
|
1074
|
+
*/
|
|
1075
|
+
retryAfter;
|
|
1076
|
+
constructor(message, options = {}) {
|
|
1077
|
+
super(message);
|
|
1078
|
+
this.name = "RetryableError";
|
|
1079
|
+
if (options.retryAfter !== void 0) this.retryAfter = parseDurationToDate(options.retryAfter);
|
|
1080
|
+
else this.retryAfter = new Date(Date.now() + 1e3);
|
|
1081
|
+
}
|
|
1082
|
+
static is(value) {
|
|
1083
|
+
return isError(value) && value.name === "RetryableError";
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
var FATAL_ERROR_KEY = Symbol.for("@workflow/errors//FatalError");
|
|
1087
|
+
var RETRYABLE_ERROR_KEY = Symbol.for("@workflow/errors//RetryableError");
|
|
1088
|
+
var HOOK_CONFLICT_ERROR_KEY = Symbol.for("@workflow/errors//HookConflictError");
|
|
1089
|
+
var HOOK_FORCE_CLAIMED_ERROR_KEY = Symbol.for("@workflow/errors//HookForceClaimedError");
|
|
1090
|
+
var RUNTIME_DECRYPTION_ERROR_KEY = Symbol.for("@workflow/errors//RuntimeDecryptionError");
|
|
1091
|
+
var STREAM_ERROR_KEY = Symbol.for("@workflow/errors//StreamError");
|
|
1092
|
+
var WORKFLOW_START_ERROR_KEY = Symbol.for("@workflow/errors//WorkflowStartError");
|
|
1093
|
+
if (typeof globalThis !== "undefined") {
|
|
1094
|
+
if (!Object.hasOwn(globalThis, FATAL_ERROR_KEY)) Object.defineProperty(globalThis, FATAL_ERROR_KEY, {
|
|
1095
|
+
value: FatalError,
|
|
1096
|
+
writable: false,
|
|
1097
|
+
enumerable: false,
|
|
1098
|
+
configurable: false
|
|
1099
|
+
});
|
|
1100
|
+
if (!Object.hasOwn(globalThis, RETRYABLE_ERROR_KEY)) Object.defineProperty(globalThis, RETRYABLE_ERROR_KEY, {
|
|
1101
|
+
value: RetryableError,
|
|
1102
|
+
writable: false,
|
|
1103
|
+
enumerable: false,
|
|
1104
|
+
configurable: false
|
|
1105
|
+
});
|
|
1106
|
+
if (!Object.hasOwn(globalThis, HOOK_CONFLICT_ERROR_KEY)) Object.defineProperty(globalThis, HOOK_CONFLICT_ERROR_KEY, {
|
|
1107
|
+
value: HookConflictError,
|
|
1108
|
+
writable: false,
|
|
1109
|
+
enumerable: false,
|
|
1110
|
+
configurable: false
|
|
1111
|
+
});
|
|
1112
|
+
if (!Object.hasOwn(globalThis, HOOK_FORCE_CLAIMED_ERROR_KEY)) Object.defineProperty(globalThis, HOOK_FORCE_CLAIMED_ERROR_KEY, {
|
|
1113
|
+
value: HookForceClaimedError,
|
|
1114
|
+
writable: false,
|
|
1115
|
+
enumerable: false,
|
|
1116
|
+
configurable: false
|
|
1117
|
+
});
|
|
1118
|
+
if (!Object.hasOwn(globalThis, RUNTIME_DECRYPTION_ERROR_KEY)) Object.defineProperty(globalThis, RUNTIME_DECRYPTION_ERROR_KEY, {
|
|
1119
|
+
value: RuntimeDecryptionError,
|
|
1120
|
+
writable: false,
|
|
1121
|
+
enumerable: false,
|
|
1122
|
+
configurable: false
|
|
1123
|
+
});
|
|
1124
|
+
if (!Object.hasOwn(globalThis, STREAM_ERROR_KEY)) Object.defineProperty(globalThis, STREAM_ERROR_KEY, {
|
|
1125
|
+
value: StreamError,
|
|
1126
|
+
writable: false,
|
|
1127
|
+
enumerable: false,
|
|
1128
|
+
configurable: false
|
|
1129
|
+
});
|
|
1130
|
+
if (!Object.hasOwn(globalThis, WORKFLOW_START_ERROR_KEY)) Object.defineProperty(globalThis, WORKFLOW_START_ERROR_KEY, {
|
|
1131
|
+
value: WorkflowStartError,
|
|
1132
|
+
writable: false,
|
|
1133
|
+
enumerable: false,
|
|
1134
|
+
configurable: false
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
export { WorkflowStartError as A, TooEarlyError as C, WorkflowRunNotCompletedError as D, WorkflowRunFailedError as E, RUN_ERROR_CODES as M, parseDurationToDate as N, WorkflowRunNotFoundError as O, require_ms as P, ThrottleError as S, WorkflowRunCancelledError as T, START_HOOK_CANDIDATE_CANCELLED as _, HookConflictError as a, StreamError as b, IN_BAND_SUPERSEDED_CODE as c, RetryableError as d, RunExpiredError as f, START_HOOK_ADMISSION_REJECTED as g, START_HOOK_ADMISSION_DISABLED as h, FatalError as i, WorkflowWorldError as j, WorkflowRuntimeError as k, InBandSupersededError as l, RuntimeDecryptionError as m, EncryptionKeyLookupError as n, HookForceClaimedError as o, RunNotSupportedError as p, EntityConflictError as r, HookNotFoundError as s, CorruptedEventLogError as t, PreconditionFailedError as u, SerializationError as v, WorkflowNotRegisteredError as w, StreamExpiredError as x, StepNotRegisteredError as y };
|