@genfeedai/workflows 0.2.0 → 0.3.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/README.md CHANGED
@@ -94,3 +94,19 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on submitting new workfl
94
94
  ## License
95
95
 
96
96
  AGPL-3.0
97
+
98
+
99
+ ## Extension & Engine Contracts
100
+
101
+ Use shared contracts for workflow engines and cloud extension packs:
102
+
103
+ ```typescript
104
+ import type {
105
+ ExecutableWorkflow,
106
+ NodeDefinition,
107
+ ExtensionPack,
108
+ NodeRegistry,
109
+ } from '@genfeedai/workflows/contracts';
110
+ ```
111
+
112
+ These contracts are designed so private/cloud node packs can extend public core workflows without forking type definitions.
@@ -0,0 +1,39 @@
1
+ // src/contracts/execution.ts
2
+ var DEFAULT_RETRY_CONFIG = {
3
+ backoffMultiplier: 2,
4
+ baseDelayMs: 1e3,
5
+ maxDelayMs: 3e4,
6
+ maxRetries: 3
7
+ };
8
+
9
+ // src/extensions/registry.ts
10
+ var InMemoryNodeRegistry = class {
11
+ nodes = /* @__PURE__ */ new Map();
12
+ register(node) {
13
+ this.nodes.set(this.key(node.type, node.version), node);
14
+ }
15
+ registerMany(nodes) {
16
+ for (const node of nodes) this.register(node);
17
+ }
18
+ registerPack(pack) {
19
+ this.registerMany(pack.nodes);
20
+ }
21
+ get(type, version) {
22
+ if (version !== void 0) {
23
+ return this.nodes.get(this.key(type, version));
24
+ }
25
+ const candidates = [...this.nodes.values()].filter((node) => node.type === type).sort((a, b) => b.version - a.version);
26
+ return candidates[0];
27
+ }
28
+ list() {
29
+ return [...this.nodes.values()];
30
+ }
31
+ key(type, version) {
32
+ return `${type}@${version}`;
33
+ }
34
+ };
35
+
36
+ export {
37
+ DEFAULT_RETRY_CONFIG,
38
+ InMemoryNodeRegistry
39
+ };
@@ -0,0 +1,127 @@
1
+ type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
2
+ type NodeExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
3
+ type WorkflowLifecycle = 'draft' | 'published' | 'archived';
4
+ interface ExecutionProgressEvent {
5
+ runId: string;
6
+ workflowId: string;
7
+ progress: number;
8
+ currentNodeId?: string;
9
+ currentNodeLabel?: string;
10
+ completedNodes: string[];
11
+ failedNodes: string[];
12
+ timestamp: Date;
13
+ }
14
+ interface NodeStatusChangeEvent {
15
+ runId: string;
16
+ workflowId: string;
17
+ nodeId: string;
18
+ previousStatus: NodeExecutionStatus;
19
+ newStatus: NodeExecutionStatus;
20
+ error?: string;
21
+ output?: unknown;
22
+ timestamp: Date;
23
+ }
24
+ interface ExecutionOptions {
25
+ nodeIds?: string[];
26
+ resumeFromNodeId?: string;
27
+ respectLocks?: boolean;
28
+ maxRetries?: number;
29
+ onProgress?: (event: ExecutionProgressEvent) => void;
30
+ onNodeStatusChange?: (event: NodeStatusChangeEvent) => void;
31
+ availableCredits?: number;
32
+ dryRun?: boolean;
33
+ }
34
+ interface ExecutableNode {
35
+ id: string;
36
+ type: string;
37
+ label: string;
38
+ config: Record<string, unknown>;
39
+ inputs: string[];
40
+ isLocked?: boolean;
41
+ cachedOutput?: unknown;
42
+ }
43
+ interface ExecutableEdge {
44
+ id: string;
45
+ source: string;
46
+ target: string;
47
+ sourceHandle?: string;
48
+ targetHandle?: string;
49
+ }
50
+ interface ExecutableWorkflow {
51
+ id: string;
52
+ organizationId: string;
53
+ userId: string;
54
+ nodes: ExecutableNode[];
55
+ edges: ExecutableEdge[];
56
+ lockedNodeIds: string[];
57
+ }
58
+ interface ValidationResult {
59
+ isValid: boolean;
60
+ errors: ValidationError[];
61
+ warnings: ValidationWarning[];
62
+ }
63
+ interface ValidationError {
64
+ code: string;
65
+ message: string;
66
+ nodeId?: string;
67
+ field?: string;
68
+ }
69
+ interface ValidationWarning {
70
+ code: string;
71
+ message: string;
72
+ nodeId?: string;
73
+ }
74
+ interface RetryConfig {
75
+ maxRetries: number;
76
+ baseDelayMs: number;
77
+ maxDelayMs: number;
78
+ backoffMultiplier: number;
79
+ }
80
+ declare const DEFAULT_RETRY_CONFIG: RetryConfig;
81
+
82
+ /**
83
+ * Stable extension contracts for workflow engines.
84
+ * Cloud/private packages should implement these interfaces without forking them.
85
+ */
86
+ type NodeSchema = Record<string, unknown>;
87
+ interface NodeDefinition {
88
+ type: string;
89
+ version: number;
90
+ label: string;
91
+ description?: string;
92
+ inputs: NodeSchema;
93
+ outputs: NodeSchema;
94
+ configSchema?: NodeSchema;
95
+ }
96
+ interface NodeExecutionContext {
97
+ environment?: 'local' | 'cloud';
98
+ metadata?: Record<string, unknown>;
99
+ }
100
+ interface ExtensionPack {
101
+ id: string;
102
+ version: string;
103
+ nodes: NodeDefinition[];
104
+ capabilities?: string[];
105
+ }
106
+
107
+ /**
108
+ * Minimal registry interface for composing core and private workflow node packs.
109
+ */
110
+ interface NodeRegistry {
111
+ register(node: NodeDefinition): void;
112
+ registerMany(nodes: NodeDefinition[]): void;
113
+ registerPack(pack: ExtensionPack): void;
114
+ get(type: string, version?: number): NodeDefinition | undefined;
115
+ list(): NodeDefinition[];
116
+ }
117
+ declare class InMemoryNodeRegistry implements NodeRegistry {
118
+ private readonly nodes;
119
+ register(node: NodeDefinition): void;
120
+ registerMany(nodes: NodeDefinition[]): void;
121
+ registerPack(pack: ExtensionPack): void;
122
+ get(type: string, version?: number): NodeDefinition | undefined;
123
+ list(): NodeDefinition[];
124
+ private key;
125
+ }
126
+
127
+ export { DEFAULT_RETRY_CONFIG, type ExecutableEdge, type ExecutableNode, type ExecutableWorkflow, type ExecutionOptions, type ExecutionProgressEvent, type ExecutionStatus, type ExtensionPack, InMemoryNodeRegistry, type NodeDefinition, type NodeExecutionContext, type NodeExecutionStatus, type NodeRegistry, type NodeSchema, type NodeStatusChangeEvent, type RetryConfig, type ValidationError, type ValidationResult, type ValidationWarning, type WorkflowLifecycle };
@@ -0,0 +1,127 @@
1
+ type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
2
+ type NodeExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
3
+ type WorkflowLifecycle = 'draft' | 'published' | 'archived';
4
+ interface ExecutionProgressEvent {
5
+ runId: string;
6
+ workflowId: string;
7
+ progress: number;
8
+ currentNodeId?: string;
9
+ currentNodeLabel?: string;
10
+ completedNodes: string[];
11
+ failedNodes: string[];
12
+ timestamp: Date;
13
+ }
14
+ interface NodeStatusChangeEvent {
15
+ runId: string;
16
+ workflowId: string;
17
+ nodeId: string;
18
+ previousStatus: NodeExecutionStatus;
19
+ newStatus: NodeExecutionStatus;
20
+ error?: string;
21
+ output?: unknown;
22
+ timestamp: Date;
23
+ }
24
+ interface ExecutionOptions {
25
+ nodeIds?: string[];
26
+ resumeFromNodeId?: string;
27
+ respectLocks?: boolean;
28
+ maxRetries?: number;
29
+ onProgress?: (event: ExecutionProgressEvent) => void;
30
+ onNodeStatusChange?: (event: NodeStatusChangeEvent) => void;
31
+ availableCredits?: number;
32
+ dryRun?: boolean;
33
+ }
34
+ interface ExecutableNode {
35
+ id: string;
36
+ type: string;
37
+ label: string;
38
+ config: Record<string, unknown>;
39
+ inputs: string[];
40
+ isLocked?: boolean;
41
+ cachedOutput?: unknown;
42
+ }
43
+ interface ExecutableEdge {
44
+ id: string;
45
+ source: string;
46
+ target: string;
47
+ sourceHandle?: string;
48
+ targetHandle?: string;
49
+ }
50
+ interface ExecutableWorkflow {
51
+ id: string;
52
+ organizationId: string;
53
+ userId: string;
54
+ nodes: ExecutableNode[];
55
+ edges: ExecutableEdge[];
56
+ lockedNodeIds: string[];
57
+ }
58
+ interface ValidationResult {
59
+ isValid: boolean;
60
+ errors: ValidationError[];
61
+ warnings: ValidationWarning[];
62
+ }
63
+ interface ValidationError {
64
+ code: string;
65
+ message: string;
66
+ nodeId?: string;
67
+ field?: string;
68
+ }
69
+ interface ValidationWarning {
70
+ code: string;
71
+ message: string;
72
+ nodeId?: string;
73
+ }
74
+ interface RetryConfig {
75
+ maxRetries: number;
76
+ baseDelayMs: number;
77
+ maxDelayMs: number;
78
+ backoffMultiplier: number;
79
+ }
80
+ declare const DEFAULT_RETRY_CONFIG: RetryConfig;
81
+
82
+ /**
83
+ * Stable extension contracts for workflow engines.
84
+ * Cloud/private packages should implement these interfaces without forking them.
85
+ */
86
+ type NodeSchema = Record<string, unknown>;
87
+ interface NodeDefinition {
88
+ type: string;
89
+ version: number;
90
+ label: string;
91
+ description?: string;
92
+ inputs: NodeSchema;
93
+ outputs: NodeSchema;
94
+ configSchema?: NodeSchema;
95
+ }
96
+ interface NodeExecutionContext {
97
+ environment?: 'local' | 'cloud';
98
+ metadata?: Record<string, unknown>;
99
+ }
100
+ interface ExtensionPack {
101
+ id: string;
102
+ version: string;
103
+ nodes: NodeDefinition[];
104
+ capabilities?: string[];
105
+ }
106
+
107
+ /**
108
+ * Minimal registry interface for composing core and private workflow node packs.
109
+ */
110
+ interface NodeRegistry {
111
+ register(node: NodeDefinition): void;
112
+ registerMany(nodes: NodeDefinition[]): void;
113
+ registerPack(pack: ExtensionPack): void;
114
+ get(type: string, version?: number): NodeDefinition | undefined;
115
+ list(): NodeDefinition[];
116
+ }
117
+ declare class InMemoryNodeRegistry implements NodeRegistry {
118
+ private readonly nodes;
119
+ register(node: NodeDefinition): void;
120
+ registerMany(nodes: NodeDefinition[]): void;
121
+ registerPack(pack: ExtensionPack): void;
122
+ get(type: string, version?: number): NodeDefinition | undefined;
123
+ list(): NodeDefinition[];
124
+ private key;
125
+ }
126
+
127
+ export { DEFAULT_RETRY_CONFIG, type ExecutableEdge, type ExecutableNode, type ExecutableWorkflow, type ExecutionOptions, type ExecutionProgressEvent, type ExecutionStatus, type ExtensionPack, InMemoryNodeRegistry, type NodeDefinition, type NodeExecutionContext, type NodeExecutionStatus, type NodeRegistry, type NodeSchema, type NodeStatusChangeEvent, type RetryConfig, type ValidationError, type ValidationResult, type ValidationWarning, type WorkflowLifecycle };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/contracts/index.ts
21
+ var contracts_exports = {};
22
+ __export(contracts_exports, {
23
+ DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
24
+ InMemoryNodeRegistry: () => InMemoryNodeRegistry
25
+ });
26
+ module.exports = __toCommonJS(contracts_exports);
27
+
28
+ // src/contracts/execution.ts
29
+ var DEFAULT_RETRY_CONFIG = {
30
+ backoffMultiplier: 2,
31
+ baseDelayMs: 1e3,
32
+ maxDelayMs: 3e4,
33
+ maxRetries: 3
34
+ };
35
+
36
+ // src/extensions/registry.ts
37
+ var InMemoryNodeRegistry = class {
38
+ nodes = /* @__PURE__ */ new Map();
39
+ register(node) {
40
+ this.nodes.set(this.key(node.type, node.version), node);
41
+ }
42
+ registerMany(nodes) {
43
+ for (const node of nodes) this.register(node);
44
+ }
45
+ registerPack(pack) {
46
+ this.registerMany(pack.nodes);
47
+ }
48
+ get(type, version) {
49
+ if (version !== void 0) {
50
+ return this.nodes.get(this.key(type, version));
51
+ }
52
+ const candidates = [...this.nodes.values()].filter((node) => node.type === type).sort((a, b) => b.version - a.version);
53
+ return candidates[0];
54
+ }
55
+ list() {
56
+ return [...this.nodes.values()];
57
+ }
58
+ key(type, version) {
59
+ return `${type}@${version}`;
60
+ }
61
+ };
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ DEFAULT_RETRY_CONFIG,
65
+ InMemoryNodeRegistry
66
+ });
@@ -0,0 +1,8 @@
1
+ import {
2
+ DEFAULT_RETRY_CONFIG,
3
+ InMemoryNodeRegistry
4
+ } from "../chunk-CTZNKWZB.mjs";
5
+ export {
6
+ DEFAULT_RETRY_CONFIG,
7
+ InMemoryNodeRegistry
8
+ };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ export { DEFAULT_RETRY_CONFIG, ExecutableEdge, ExecutableNode, ExecutableWorkflow, ExecutionOptions, ExecutionProgressEvent, ExecutionStatus, ExtensionPack, InMemoryNodeRegistry, NodeDefinition, NodeExecutionContext, NodeExecutionStatus, NodeRegistry, NodeSchema, NodeStatusChangeEvent, RetryConfig, ValidationError, ValidationResult, ValidationWarning, WorkflowLifecycle } from './contracts/index.mjs';
1
2
  import { ComfyUIPrompt, ComfyUIQueuePromptResponse, ComfyUIHistoryEntry, ComfyUIWorkflowTemplate, WorkflowNode, WorkflowEdge } from '@genfeedai/types';
2
3
 
3
4
  interface ComfyUIClientOptions {
@@ -132,13 +133,6 @@ interface ZImageTurboLoraParams extends ZImageTurboParams {
132
133
  }
133
134
  declare function buildZImageTurboLoraPrompt(params: ZImageTurboLoraParams): ComfyUIPrompt;
134
135
 
135
- /**
136
- * Workflow Registry for @genfeedai/workflows
137
- *
138
- * This registry contains metadata for all official workflow templates.
139
- * The actual workflow JSON files are stored in the `workflows/` directory.
140
- */
141
-
142
136
  interface WorkflowJson {
143
137
  version: number;
144
138
  name: string;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { DEFAULT_RETRY_CONFIG, ExecutableEdge, ExecutableNode, ExecutableWorkflow, ExecutionOptions, ExecutionProgressEvent, ExecutionStatus, ExtensionPack, InMemoryNodeRegistry, NodeDefinition, NodeExecutionContext, NodeExecutionStatus, NodeRegistry, NodeSchema, NodeStatusChangeEvent, RetryConfig, ValidationError, ValidationResult, ValidationWarning, WorkflowLifecycle } from './contracts/index.js';
1
2
  import { ComfyUIPrompt, ComfyUIQueuePromptResponse, ComfyUIHistoryEntry, ComfyUIWorkflowTemplate, WorkflowNode, WorkflowEdge } from '@genfeedai/types';
2
3
 
3
4
  interface ComfyUIClientOptions {
@@ -132,13 +133,6 @@ interface ZImageTurboLoraParams extends ZImageTurboParams {
132
133
  }
133
134
  declare function buildZImageTurboLoraPrompt(params: ZImageTurboLoraParams): ComfyUIPrompt;
134
135
 
135
- /**
136
- * Workflow Registry for @genfeedai/workflows
137
- *
138
- * This registry contains metadata for all official workflow templates.
139
- * The actual workflow JSON files are stored in the `workflows/` directory.
140
- */
141
-
142
136
  interface WorkflowJson {
143
137
  version: number;
144
138
  name: string;
package/dist/index.js CHANGED
@@ -32,6 +32,8 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  ComfyUIClient: () => ComfyUIClient,
34
34
  ComfyUITemplateRunner: () => ComfyUITemplateRunner,
35
+ DEFAULT_RETRY_CONFIG: () => DEFAULT_RETRY_CONFIG,
36
+ InMemoryNodeRegistry: () => InMemoryNodeRegistry,
35
37
  WORKFLOW_REGISTRY: () => WORKFLOW_REGISTRY,
36
38
  buildFlux2DevPrompt: () => buildFlux2DevPrompt,
37
39
  buildFlux2DevPulidLoraPrompt: () => buildFlux2DevPulidLoraPrompt,
@@ -52,6 +54,41 @@ __export(index_exports, {
52
54
  });
53
55
  module.exports = __toCommonJS(index_exports);
54
56
 
57
+ // src/contracts/execution.ts
58
+ var DEFAULT_RETRY_CONFIG = {
59
+ backoffMultiplier: 2,
60
+ baseDelayMs: 1e3,
61
+ maxDelayMs: 3e4,
62
+ maxRetries: 3
63
+ };
64
+
65
+ // src/extensions/registry.ts
66
+ var InMemoryNodeRegistry = class {
67
+ nodes = /* @__PURE__ */ new Map();
68
+ register(node) {
69
+ this.nodes.set(this.key(node.type, node.version), node);
70
+ }
71
+ registerMany(nodes) {
72
+ for (const node of nodes) this.register(node);
73
+ }
74
+ registerPack(pack) {
75
+ this.registerMany(pack.nodes);
76
+ }
77
+ get(type, version) {
78
+ if (version !== void 0) {
79
+ return this.nodes.get(this.key(type, version));
80
+ }
81
+ const candidates = [...this.nodes.values()].filter((node) => node.type === type).sort((a, b) => b.version - a.version);
82
+ return candidates[0];
83
+ }
84
+ list() {
85
+ return [...this.nodes.values()];
86
+ }
87
+ key(type, version) {
88
+ return `${type}@${version}`;
89
+ }
90
+ };
91
+
55
92
  // src/comfyui/client.ts
56
93
  var DEFAULT_POLL_MS = 2e3;
57
94
  var DEFAULT_TIMEOUT_MS = 3e5;
@@ -1241,6 +1278,8 @@ function searchWorkflowsByTag(tag) {
1241
1278
  0 && (module.exports = {
1242
1279
  ComfyUIClient,
1243
1280
  ComfyUITemplateRunner,
1281
+ DEFAULT_RETRY_CONFIG,
1282
+ InMemoryNodeRegistry,
1244
1283
  WORKFLOW_REGISTRY,
1245
1284
  buildFlux2DevPrompt,
1246
1285
  buildFlux2DevPulidLoraPrompt,
package/dist/index.mjs CHANGED
@@ -1,3 +1,8 @@
1
+ import {
2
+ DEFAULT_RETRY_CONFIG,
3
+ InMemoryNodeRegistry
4
+ } from "./chunk-CTZNKWZB.mjs";
5
+
1
6
  // src/comfyui/client.ts
2
7
  var DEFAULT_POLL_MS = 2e3;
3
8
  var DEFAULT_TIMEOUT_MS = 3e5;
@@ -1186,6 +1191,8 @@ function searchWorkflowsByTag(tag) {
1186
1191
  export {
1187
1192
  ComfyUIClient,
1188
1193
  ComfyUITemplateRunner,
1194
+ DEFAULT_RETRY_CONFIG,
1195
+ InMemoryNodeRegistry,
1189
1196
  WORKFLOW_REGISTRY,
1190
1197
  buildFlux2DevPrompt,
1191
1198
  buildFlux2DevPulidLoraPrompt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genfeedai/workflows",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "sideEffects": false,
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
@@ -25,7 +25,12 @@
25
25
  "import": "./dist/comfyui/index.mjs",
26
26
  "require": "./dist/comfyui/index.js"
27
27
  },
28
- "./workflows/*": "./workflows/*"
28
+ "./workflows/*": "./workflows/*",
29
+ "./contracts": {
30
+ "types": "./dist/contracts/index.d.ts",
31
+ "import": "./dist/contracts/index.mjs",
32
+ "require": "./dist/contracts/index.js"
33
+ }
29
34
  },
30
35
  "files": [
31
36
  "dist",
@@ -33,8 +38,8 @@
33
38
  "metadata"
34
39
  ],
35
40
  "scripts": {
36
- "build": "tsup src/index.ts --format esm,cjs --dts --clean",
37
- "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
41
+ "build": "tsup src/index.ts src/contracts/index.ts --format esm,cjs --dts --clean",
42
+ "dev": "tsup src/index.ts src/contracts/index.ts --format esm,cjs --dts --watch",
38
43
  "prepublishOnly": "bun run build"
39
44
  },
40
45
  "devDependencies": {