@lucid-softworks/workflow-core 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lucid Softworks
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # `@lucid-softworks/workflow-core`
2
+
3
+ Shared workflow states, execution context, cancellation errors, and injectable
4
+ clock contracts. The system clock supports abortable sleeps.
@@ -0,0 +1,34 @@
1
+ export type WorkflowTaskState = "pending" | "running" | "succeeded" | "failed" | "skipped" | "cancelled" | "compensated";
2
+ export interface WorkflowAbortSignal {
3
+ readonly aborted: boolean;
4
+ readonly reason: unknown;
5
+ addEventListener(type: "abort", listener: () => void, options?: Readonly<{
6
+ once?: boolean;
7
+ }>): void;
8
+ removeEventListener(type: "abort", listener: () => void): void;
9
+ }
10
+ export type WorkflowExecutionContext = Readonly<{
11
+ executionId: string;
12
+ taskId: string;
13
+ attempt: number;
14
+ signal: WorkflowAbortSignal;
15
+ results: ReadonlyMap<string, unknown>;
16
+ }>;
17
+ export type WorkflowTaskRecord = Readonly<{
18
+ id: string;
19
+ state: WorkflowTaskState;
20
+ output?: unknown;
21
+ error?: unknown;
22
+ }>;
23
+ export type WorkflowClock = Readonly<{
24
+ now: () => number;
25
+ sleep: (milliseconds: number, signal?: WorkflowAbortSignal) => Promise<void>;
26
+ }>;
27
+ export declare class WorkflowCancelledError extends Error {
28
+ readonly reason?: unknown;
29
+ readonly name = "WorkflowCancelledError";
30
+ constructor(reason?: unknown);
31
+ }
32
+ export declare function throwIfWorkflowCancelled(signal: WorkflowAbortSignal): void;
33
+ export declare const systemWorkflowClock: WorkflowClock;
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,SAAS,GACT,WAAW,GACX,QAAQ,GACR,SAAS,GACT,WAAW,GACX,aAAa,CAAC;AAElB,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,gBAAgB,CACd,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,IAAI,EACpB,OAAO,CAAC,EAAE,QAAQ,CAAC;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,GACrC,IAAI,CAAC;IACR,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAChE;AAED,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC,CAAC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9E,CAAC,CAAC;AAEH,qBAAa,sBAAuB,SAAQ,KAAK;IAEnC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO;IADrC,SAAkB,IAAI,4BAA4B;IAClD,YAAqB,MAAM,CAAC,EAAE,OAAO,EAEpC;CACF;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAE1E;AAED,eAAO,MAAM,mBAAmB,EAAE,aAmBjC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ export class WorkflowCancelledError extends Error {
2
+ reason;
3
+ name = "WorkflowCancelledError";
4
+ constructor(reason) {
5
+ super("Workflow execution was cancelled");
6
+ this.reason = reason;
7
+ }
8
+ }
9
+ export function throwIfWorkflowCancelled(signal) {
10
+ if (signal.aborted)
11
+ throw new WorkflowCancelledError(signal.reason);
12
+ }
13
+ export const systemWorkflowClock = {
14
+ now: Date.now,
15
+ sleep(milliseconds, signal) {
16
+ return new Promise((resolve, reject) => {
17
+ if (signal?.aborted) {
18
+ reject(new WorkflowCancelledError(signal.reason));
19
+ return;
20
+ }
21
+ const timeout = setTimeout(resolve, milliseconds);
22
+ signal?.addEventListener("abort", () => {
23
+ clearTimeout(timeout);
24
+ reject(new WorkflowCancelledError(signal.reason));
25
+ }, { once: true });
26
+ });
27
+ },
28
+ };
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAwCA,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAE1B,MAAM;IADT,IAAI,GAAG,wBAAwB,CAAC;IAClD,YAAqB,MAAgB;QACnC,KAAK,CAAC,kCAAkC,CAAC,CAAC;sBADvB,MAAM;IAE3B,CAAC;CACF;AAED,MAAM,UAAU,wBAAwB,CAAC,MAA2B;IAClE,IAAI,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAkB;IAChD,GAAG,EAAE,IAAI,CAAC,GAAG;IACb,KAAK,CAAC,YAAY,EAAE,MAAM;QACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;gBACpB,MAAM,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;gBAClD,OAAO;YACT,CAAC;YACD,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAClD,MAAM,EAAE,gBAAgB,CACtB,OAAO,EACP,GAAG,EAAE;gBACH,YAAY,CAAC,OAAO,CAAC,CAAC;gBACtB,MAAM,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YACpD,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@lucid-softworks/workflow-core",
3
+ "version": "0.0.0",
4
+ "description": "Shared workflow execution context, state, clock, and cancellation contracts.",
5
+ "keywords": [
6
+ "core",
7
+ "javascript",
8
+ "typescript",
9
+ "utility",
10
+ "workflow"
11
+ ],
12
+ "homepage": "https://github.com/lucid-softworks/workflow-core#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/lucid-softworks/workflow-core/issues"
15
+ },
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/lucid-softworks/workflow-core.git"
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "type": "module",
25
+ "sideEffects": false,
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ }
31
+ },
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "provenance": true
35
+ },
36
+ "scripts": {
37
+ "bench": "vitest bench --run",
38
+ "bench:smoke": "VITEST_BENCHMARK_SMOKE=1 vitest bench --run",
39
+ "build": "tsc -p tsconfig.build.json",
40
+ "check": "oxfmt --check . && oxlint . && tsc -p tsconfig.json && tsc -p tsconfig.build.json && vitest run --coverage && publint && VITEST_BENCHMARK_SMOKE=1 vitest bench --run",
41
+ "format": "oxfmt --write .",
42
+ "format:check": "oxfmt --check .",
43
+ "lint": "oxlint .",
44
+ "pack:check": "publint",
45
+ "test": "vitest run --coverage",
46
+ "typecheck": "tsc -p tsconfig.json"
47
+ },
48
+ "devDependencies": {
49
+ "@lucid-softworks/oxfmt-config": "^0.1.1",
50
+ "@lucid-softworks/oxlint-config": "^0.1.0",
51
+ "@lucid-softworks/tsconfig": "^0.1.0",
52
+ "@lucid-softworks/vitest-config": "^0.1.1",
53
+ "@types/node": "26.1.1",
54
+ "@vitest/coverage-v8": "4.1.10",
55
+ "oxfmt": "0.60.0",
56
+ "oxlint": "1.75.0",
57
+ "publint": "0.3.22",
58
+ "typescript": "7.0.2",
59
+ "vitest": "4.1.10"
60
+ },
61
+ "engines": {
62
+ "node": ">=22"
63
+ },
64
+ "packageManager": "pnpm@11.16.0"
65
+ }