@fractal-solutions/qflow 1.0.84 → 2.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/CHANGELOG.md +119 -0
- package/LICENSE +21 -504
- package/MIGRATION.md +1130 -0
- package/README.md +1432 -823
- package/dist/agent/agent.d.ts +4 -22
- package/dist/agent/agent.js +4 -364
- package/dist/agent/base_agent.d.ts +8 -20
- package/dist/agent/base_agent.js +8 -205
- package/dist/agent/control_nodes.d.ts +61 -0
- package/dist/agent/control_nodes.js +164 -0
- package/dist/agent/engine.d.ts +45 -0
- package/dist/agent/engine.js +415 -0
- package/dist/agent/flow.d.ts +77 -0
- package/dist/agent/flow.js +148 -0
- package/dist/agent/index.d.ts +12 -0
- package/dist/agent/index.js +12 -0
- package/dist/agent/lpavrl_agent.d.ts +1 -2
- package/dist/agent/lpavrl_agent.js +2 -175
- package/dist/agent/ooda_agent.d.ts +1 -2
- package/dist/agent/ooda_agent.js +2 -164
- package/dist/agent/pema_agent.d.ts +1 -2
- package/dist/agent/pema_agent.js +2 -168
- package/dist/agent/raor_agent.d.ts +1 -2
- package/dist/agent/raor_agent.js +2 -161
- package/dist/agent/strategies.d.ts +126 -0
- package/dist/agent/strategies.js +159 -0
- package/dist/agent/tools.d.ts +1 -0
- package/dist/agent/tools.js +42 -24
- package/dist/approval.d.ts +42 -0
- package/dist/approval.js +86 -0
- package/dist/budget.d.ts +103 -0
- package/dist/budget.js +133 -0
- package/dist/bun_nodes.d.ts +119 -0
- package/dist/bun_nodes.js +331 -0
- package/dist/contracts.d.ts +30 -0
- package/dist/contracts.js +103 -0
- package/dist/durable.d.ts +278 -0
- package/dist/durable.js +730 -0
- package/dist/eval.d.ts +165 -0
- package/dist/eval.js +263 -0
- package/dist/graph.d.ts +157 -0
- package/dist/graph.js +330 -0
- package/dist/llm/index.d.ts +359 -0
- package/dist/llm/index.js +924 -0
- package/dist/logger.js +7 -3
- package/dist/mcp/client.d.ts +55 -0
- package/dist/mcp/client.js +145 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/server.d.ts +106 -0
- package/dist/mcp/server.js +154 -0
- package/dist/mcp/stdio.d.ts +2 -0
- package/dist/mcp/stdio.js +3 -0
- package/dist/memory.d.ts +101 -0
- package/dist/memory.js +217 -0
- package/dist/nodes/browser_control.js +5 -4
- package/dist/nodes/data_extractor.js +2 -1
- package/dist/nodes/data_validation.d.ts +3 -3
- package/dist/nodes/data_validation.js +19 -5
- package/dist/nodes/database.d.ts +2 -1
- package/dist/nodes/database.js +71 -58
- package/dist/nodes/gis.js +1 -1
- package/dist/nodes/git.d.ts +1 -1
- package/dist/nodes/git.js +65 -51
- package/dist/nodes/github.d.ts +1 -0
- package/dist/nodes/hardware_interaction.d.ts +2 -4
- package/dist/nodes/hardware_interaction.js +4 -3
- package/dist/nodes/http.d.ts +1 -7
- package/dist/nodes/http.js +46 -33
- package/dist/nodes/image_gallery.js +45 -45
- package/dist/nodes/index.d.ts +8 -0
- package/dist/nodes/index.js +8 -0
- package/dist/nodes/interactive_webview.d.ts +1 -2
- package/dist/nodes/interactive_webview.js +217 -216
- package/dist/nodes/multimedia_processing.js +1 -1
- package/dist/nodes/navigator.d.ts +7 -0
- package/dist/nodes/navigator.js +48 -8
- package/dist/nodes/pdf_processor.js +2 -1
- package/dist/nodes/remote_execution.js +2 -2
- package/dist/nodes/s3.d.ts +1 -0
- package/dist/nodes/scheduler.js +2 -2
- package/dist/nodes/search.d.ts +1 -1
- package/dist/nodes/search.js +3 -2
- package/dist/nodes/speech_synthesis.js +2 -1
- package/dist/nodes/spreadsheet.d.ts +1 -7
- package/dist/nodes/spreadsheet.js +2 -1
- package/dist/nodes/streaming_llm.d.ts +51 -0
- package/dist/nodes/streaming_llm.js +120 -0
- package/dist/nodes/webhook.d.ts +1 -5
- package/dist/nodes/webhook.js +106 -93
- package/dist/nodes/websockets.js +5 -3
- package/dist/nodes/webview.js +3 -2
- package/dist/optional.d.ts +32 -0
- package/dist/optional.js +61 -0
- package/dist/qflow.d.ts +25 -14
- package/dist/qflow.js +140 -49
- package/dist/schedule.d.ts +41 -0
- package/dist/schedule.js +149 -0
- package/dist/side_effects.d.ts +50 -0
- package/dist/side_effects.js +94 -0
- package/dist/streaming.d.ts +35 -0
- package/dist/streaming.js +199 -0
- package/dist/testing.d.ts +47 -0
- package/dist/testing.js +130 -0
- package/dist/tool_spec.d.ts +76 -0
- package/dist/tool_spec.js +321 -0
- package/dist/trace.d.ts +28 -0
- package/dist/trace.js +190 -0
- package/dist/util.d.ts +57 -0
- package/dist/util.js +122 -0
- package/package.json +153 -67
- package/qflow.config.js +18 -18
- package/scripts/postinstall.js +50 -0
- package/scripts/verify-package.js +114 -0
package/dist/util.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/** Small, dependency-free helpers shared by the 2.0 node families. */
|
|
2
|
+
export function stableStringify(value, seen = new WeakSet()) {
|
|
3
|
+
if (value == null || typeof value !== 'object')
|
|
4
|
+
return JSON.stringify(value ?? null);
|
|
5
|
+
if (seen.has(value))
|
|
6
|
+
return '"[Circular]"';
|
|
7
|
+
seen.add(value);
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
return `[${value.map(item => stableStringify(item, seen)).join(',')}]`;
|
|
10
|
+
}
|
|
11
|
+
if (value instanceof Date)
|
|
12
|
+
return JSON.stringify(value.toISOString());
|
|
13
|
+
if (value instanceof Error)
|
|
14
|
+
return JSON.stringify({ name: value.name, message: value.message });
|
|
15
|
+
const keys = Object.keys(value).sort();
|
|
16
|
+
return `{${keys.map(key => `${JSON.stringify(key)}:${stableStringify(value[key], seen)}`).join(',')}}`;
|
|
17
|
+
}
|
|
18
|
+
/** Deterministic 32-bit hash, useful for operation and idempotency keys. */
|
|
19
|
+
export function stableHash(value) {
|
|
20
|
+
const input = typeof value === 'string' ? value : stableStringify(value);
|
|
21
|
+
let hash = 0x811c9dc5;
|
|
22
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
23
|
+
hash ^= input.charCodeAt(i);
|
|
24
|
+
hash = Math.imul(hash, 0x01000193);
|
|
25
|
+
}
|
|
26
|
+
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
27
|
+
}
|
|
28
|
+
export function cloneValue(value, seen = new WeakSet()) {
|
|
29
|
+
if (value == null || typeof value !== 'object')
|
|
30
|
+
return value;
|
|
31
|
+
if (seen.has(value))
|
|
32
|
+
return '[Circular]';
|
|
33
|
+
seen.add(value);
|
|
34
|
+
if (Array.isArray(value))
|
|
35
|
+
return value.map(item => cloneValue(item, seen));
|
|
36
|
+
if (value instanceof Date)
|
|
37
|
+
return value.toISOString();
|
|
38
|
+
if (value instanceof Error)
|
|
39
|
+
return { name: value.name, message: value.message };
|
|
40
|
+
const result = {};
|
|
41
|
+
for (const [key, child] of Object.entries(value)) {
|
|
42
|
+
result[key] = cloneValue(child, seen);
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
export class SideEffectUncertainError extends Error {
|
|
47
|
+
constructor(operationId, message) {
|
|
48
|
+
super(message ?? `Side effect '${operationId}' was reserved but never recorded as completed. It must not be retried automatically.`);
|
|
49
|
+
this.name = 'SideEffectUncertainError';
|
|
50
|
+
this.code = 'QFLOW_SIDE_EFFECT_UNCERTAIN';
|
|
51
|
+
this.operationId = operationId;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Another worker holds an active lease on an operation; do not execute it. */
|
|
55
|
+
export class SideEffectClaimedError extends SideEffectUncertainError {
|
|
56
|
+
constructor(operationId, claimedBy, message) {
|
|
57
|
+
super(operationId, message ?? `Side effect '${operationId}' is currently claimed by worker '${claimedBy}'. Wait for its lease to expire or for the owner to finish.`);
|
|
58
|
+
this.name = 'SideEffectClaimedError';
|
|
59
|
+
this.code = 'QFLOW_SIDE_EFFECT_CLAIMED';
|
|
60
|
+
this.claimedBy = claimedBy;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** A durable run is waiting for a human/webhook decision. */
|
|
64
|
+
export class ApprovalPendingError extends Error {
|
|
65
|
+
constructor(approvalId, { runId = null, prompt = null, step = 0 } = {}) {
|
|
66
|
+
super(`Approval '${approvalId}' is pending for run '${runId ?? 'unknown'}'.`);
|
|
67
|
+
this.name = 'ApprovalPendingError';
|
|
68
|
+
this.code = 'QFLOW_APPROVAL_PENDING';
|
|
69
|
+
this.approvalId = approvalId;
|
|
70
|
+
this.runId = runId;
|
|
71
|
+
this.prompt = prompt;
|
|
72
|
+
this.step = step;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** A durable run is waiting until a future time. */
|
|
76
|
+
export class SchedulePendingError extends Error {
|
|
77
|
+
constructor(scheduleId, { runId = null, dueAt = 0, step = 0 } = {}) {
|
|
78
|
+
super(`Schedule '${scheduleId}' is not due until ${new Date(dueAt).toISOString()}.`);
|
|
79
|
+
this.name = 'SchedulePendingError';
|
|
80
|
+
this.code = 'QFLOW_SCHEDULE_PENDING';
|
|
81
|
+
this.scheduleId = scheduleId;
|
|
82
|
+
this.runId = runId;
|
|
83
|
+
this.dueAt = dueAt;
|
|
84
|
+
this.step = step;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** A resumed run targets a different flow version than the one it started with. */
|
|
88
|
+
export class FlowVersionMismatchError extends Error {
|
|
89
|
+
constructor(runId, expected, actual, message) {
|
|
90
|
+
super(message ?? `Run '${runId}' was started with flow version '${expected}' but the current flow is '${actual}'.`);
|
|
91
|
+
this.name = 'FlowVersionMismatchError';
|
|
92
|
+
this.code = 'QFLOW_FLOW_VERSION_MISMATCH';
|
|
93
|
+
this.runId = runId;
|
|
94
|
+
this.expected = expected;
|
|
95
|
+
this.actual = actual;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** A run exceeded a configured cost/token/latency/step budget. */
|
|
99
|
+
export class BudgetExceededError extends Error {
|
|
100
|
+
constructor(reasons = [], snapshot = {}, message) {
|
|
101
|
+
super(message ?? `Budget exceeded: ${reasons.join(', ') || 'limit reached'}.`);
|
|
102
|
+
this.name = 'BudgetExceededError';
|
|
103
|
+
this.code = 'QFLOW_BUDGET_EXCEEDED';
|
|
104
|
+
this.reasons = reasons;
|
|
105
|
+
this.snapshot = snapshot;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export function resolveTemplate(template, context) {
|
|
109
|
+
if (typeof template !== 'string')
|
|
110
|
+
return template;
|
|
111
|
+
return template.replace(/\{\{([^}]+)\}\}/g, (_match, rawPath) => {
|
|
112
|
+
const path = rawPath.trim();
|
|
113
|
+
const parts = path.split('.');
|
|
114
|
+
let value = context;
|
|
115
|
+
for (const part of parts) {
|
|
116
|
+
if (value == null)
|
|
117
|
+
return '';
|
|
118
|
+
value = value[part];
|
|
119
|
+
}
|
|
120
|
+
return value == null ? '' : String(value);
|
|
121
|
+
});
|
|
122
|
+
}
|
package/package.json
CHANGED
|
@@ -1,67 +1,153 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@fractal-solutions/qflow",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A lightweight and flexible JavaScript library for creating and managing workflows and agents.",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"types": "./dist/
|
|
14
|
-
"default": "./dist/
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@fractal-solutions/qflow",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "A lightweight and flexible JavaScript library for creating and managing workflows and agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/qflow.js",
|
|
7
|
+
"types": "dist/qflow.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"qflow-mcp": "dist/mcp/stdio.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/qflow.d.ts",
|
|
14
|
+
"default": "./dist/qflow.js"
|
|
15
|
+
},
|
|
16
|
+
"./nodes": {
|
|
17
|
+
"types": "./dist/nodes/index.d.ts",
|
|
18
|
+
"default": "./dist/nodes/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./mcp": {
|
|
21
|
+
"types": "./dist/mcp/index.d.ts",
|
|
22
|
+
"default": "./dist/mcp/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./agent": {
|
|
25
|
+
"types": "./dist/agent/index.d.ts",
|
|
26
|
+
"default": "./dist/agent/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./streaming": {
|
|
29
|
+
"types": "./dist/streaming.d.ts",
|
|
30
|
+
"default": "./dist/streaming.js"
|
|
31
|
+
},
|
|
32
|
+
"./durable": {
|
|
33
|
+
"types": "./dist/durable.d.ts",
|
|
34
|
+
"default": "./dist/durable.js"
|
|
35
|
+
},
|
|
36
|
+
"./testing": {
|
|
37
|
+
"types": "./dist/testing.d.ts",
|
|
38
|
+
"default": "./dist/testing.js"
|
|
39
|
+
},
|
|
40
|
+
"./graph": {
|
|
41
|
+
"types": "./dist/graph.d.ts",
|
|
42
|
+
"default": "./dist/graph.js"
|
|
43
|
+
},
|
|
44
|
+
"./trace": {
|
|
45
|
+
"types": "./dist/trace.d.ts",
|
|
46
|
+
"default": "./dist/trace.js"
|
|
47
|
+
},
|
|
48
|
+
"./optional": {
|
|
49
|
+
"types": "./dist/optional.d.ts",
|
|
50
|
+
"default": "./dist/optional.js"
|
|
51
|
+
},
|
|
52
|
+
"./logger": {
|
|
53
|
+
"types": "./dist/logger.d.ts",
|
|
54
|
+
"default": "./dist/logger.js"
|
|
55
|
+
},
|
|
56
|
+
"./llm": {
|
|
57
|
+
"types": "./dist/llm/index.d.ts",
|
|
58
|
+
"default": "./dist/llm/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./tool-spec": {
|
|
61
|
+
"types": "./dist/tool_spec.d.ts",
|
|
62
|
+
"default": "./dist/tool_spec.js"
|
|
63
|
+
},
|
|
64
|
+
"./contracts": {
|
|
65
|
+
"types": "./dist/contracts.d.ts",
|
|
66
|
+
"default": "./dist/contracts.js"
|
|
67
|
+
},
|
|
68
|
+
"./side-effects": {
|
|
69
|
+
"types": "./dist/side_effects.d.ts",
|
|
70
|
+
"default": "./dist/side_effects.js"
|
|
71
|
+
},
|
|
72
|
+
"./eval": {
|
|
73
|
+
"types": "./dist/eval.d.ts",
|
|
74
|
+
"default": "./dist/eval.js"
|
|
75
|
+
},
|
|
76
|
+
"./bun": {
|
|
77
|
+
"types": "./dist/bun_nodes.d.ts",
|
|
78
|
+
"default": "./dist/bun_nodes.js"
|
|
79
|
+
},
|
|
80
|
+
"./approval": {
|
|
81
|
+
"types": "./dist/approval.d.ts",
|
|
82
|
+
"default": "./dist/approval.js"
|
|
83
|
+
},
|
|
84
|
+
"./schedule": {
|
|
85
|
+
"types": "./dist/schedule.d.ts",
|
|
86
|
+
"default": "./dist/schedule.js"
|
|
87
|
+
},
|
|
88
|
+
"./budget": {
|
|
89
|
+
"types": "./dist/budget.d.ts",
|
|
90
|
+
"default": "./dist/budget.js"
|
|
91
|
+
},
|
|
92
|
+
"./memory": {
|
|
93
|
+
"types": "./dist/memory.d.ts",
|
|
94
|
+
"default": "./dist/memory.js"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"files": [
|
|
98
|
+
"dist/",
|
|
99
|
+
"README.md",
|
|
100
|
+
"MIGRATION.md",
|
|
101
|
+
"CHANGELOG.md",
|
|
102
|
+
"qflow.config.js",
|
|
103
|
+
"scripts/"
|
|
104
|
+
],
|
|
105
|
+
"scripts": {
|
|
106
|
+
"test": "bun test tests",
|
|
107
|
+
"clean": "rm -rf dist",
|
|
108
|
+
"build": "bun run clean && tsc --project tsconfig.build.json",
|
|
109
|
+
"examples:v2": "bun examples/v2/run-all.js",
|
|
110
|
+
"postinstall": "bun scripts/postinstall.js",
|
|
111
|
+
"prepublishOnly": "bun scripts/verify-package.js"
|
|
112
|
+
},
|
|
113
|
+
"keywords": [
|
|
114
|
+
"workflow",
|
|
115
|
+
"agents",
|
|
116
|
+
"pipeline",
|
|
117
|
+
"automation",
|
|
118
|
+
"flow",
|
|
119
|
+
"async",
|
|
120
|
+
"batch"
|
|
121
|
+
],
|
|
122
|
+
"author": "Fractal Solutions",
|
|
123
|
+
"license": "MIT",
|
|
124
|
+
"repository": {
|
|
125
|
+
"type": "git",
|
|
126
|
+
"url": "git+https://github.com/fractal-solutions/qflow.git"
|
|
127
|
+
},
|
|
128
|
+
"bugs": {
|
|
129
|
+
"url": "https://github.com/fractal-solutions/qflow/issues"
|
|
130
|
+
},
|
|
131
|
+
"homepage": "https://github.com/fractal-solutions/qflow#readme",
|
|
132
|
+
"dependencies": {
|
|
133
|
+
"chalk": "^5.6.2"
|
|
134
|
+
},
|
|
135
|
+
"optionalDependencies": {
|
|
136
|
+
"@serialport/parser-readline": "^13.0.0",
|
|
137
|
+
"ajv": "^8.17.1",
|
|
138
|
+
"ajv-formats": "^3.0.1",
|
|
139
|
+
"cheerio": "^1.1.2",
|
|
140
|
+
"node-cron": "^4.2.1",
|
|
141
|
+
"playwright": "^1.55.0",
|
|
142
|
+
"serialport": "^13.0.0",
|
|
143
|
+
"simple-git": "^3.28.0",
|
|
144
|
+
"ssh2": "^1.17.0",
|
|
145
|
+
"webview-bun": "^2.4.0",
|
|
146
|
+
"ws": "^8.18.3",
|
|
147
|
+
"xlsx": "^0.18.5"
|
|
148
|
+
},
|
|
149
|
+
"devDependencies": {
|
|
150
|
+
"@types/bun": "latest",
|
|
151
|
+
"typescript": "^5.9.2"
|
|
152
|
+
}
|
|
153
|
+
}
|
package/qflow.config.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
// qflow.config.js
|
|
2
|
-
/**
|
|
3
|
-
* @type {import('./src/types').QFlowConfig}
|
|
4
|
-
*/
|
|
5
|
-
const qflowConfig = {
|
|
6
|
-
/**
|
|
7
|
-
* An array of paths to custom node files.
|
|
8
|
-
* These nodes will be dynamically loaded and their static getToolDefinition() methods
|
|
9
|
-
* will be used to make them available as tools for agents.
|
|
10
|
-
* Paths should be relative to the project root.
|
|
11
|
-
* Example: ['./my_nodes/my_custom_node.js', './another_module/special_node.js']
|
|
12
|
-
*/
|
|
13
|
-
customNodePaths: [],
|
|
14
|
-
|
|
15
|
-
// Add other qflow configurations here in the future
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default qflowConfig;
|
|
1
|
+
// qflow.config.js
|
|
2
|
+
/**
|
|
3
|
+
* @type {import('./src/types').QFlowConfig}
|
|
4
|
+
*/
|
|
5
|
+
const qflowConfig = {
|
|
6
|
+
/**
|
|
7
|
+
* An array of paths to custom node files.
|
|
8
|
+
* These nodes will be dynamically loaded and their static getToolDefinition() methods
|
|
9
|
+
* will be used to make them available as tools for agents.
|
|
10
|
+
* Paths should be relative to the project root.
|
|
11
|
+
* Example: ['./my_nodes/my_custom_node.js', './another_module/special_node.js']
|
|
12
|
+
*/
|
|
13
|
+
customNodePaths: [],
|
|
14
|
+
|
|
15
|
+
// Add other qflow configurations here in the future
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default qflowConfig;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
|
|
3
|
+
const platform = os.platform();
|
|
4
|
+
|
|
5
|
+
const messages = {
|
|
6
|
+
linux: `
|
|
7
|
+
---------------------------------------------------------------------
|
|
8
|
+
[Qflow] Optional dependency for WebviewNode:
|
|
9
|
+
To use the WebviewNode, you need to install system dependencies.
|
|
10
|
+
The compiled linux library in this package requires GTK 4 and WebkitGTK 6.0.
|
|
11
|
+
|
|
12
|
+
Please install the required packages for your distribution:
|
|
13
|
+
|
|
14
|
+
Debian-based: sudo apt install libgtk-4-1 libwebkitgtk-6.0-4
|
|
15
|
+
Arch-based: sudo pacman -S gtk4 webkitgtk-6.0
|
|
16
|
+
Fedora-based: sudo dnf install gtk4 webkitgtk6.0
|
|
17
|
+
|
|
18
|
+
For development and building from source, you may also need:
|
|
19
|
+
Debian-based: sudo apt install libgtk-4-dev libwebkitgtk-6.0-dev cmake ninja-build clang
|
|
20
|
+
Fedora-based: sudo dnf install gtk4-devel webkitgtk6.0-devel cmake ninja-build clang
|
|
21
|
+
Arch-based: sudo pacman -S cmake ninja clang
|
|
22
|
+
---------------------------------------------------------------------
|
|
23
|
+
`,
|
|
24
|
+
win32: `
|
|
25
|
+
---------------------------------------------------------------------
|
|
26
|
+
[Qflow] Optional dependency for WebviewNode:
|
|
27
|
+
To use the WebviewNode, the Microsoft Edge WebView2 runtime is required.
|
|
28
|
+
It is usually pre-installed on Windows 11. For other versions, you can
|
|
29
|
+
download it from: https://developer.microsoft.com/en-us/microsoft-edge/webview2/
|
|
30
|
+
|
|
31
|
+
For development and building from source, you will need the C++ Build Tools:
|
|
32
|
+
1. Go to https://visualstudio.microsoft.com/downloads
|
|
33
|
+
2. Scroll to "Tools for Visual Studio" and download "Build Tools for Visual Studio".
|
|
34
|
+
3. Select "Desktop development with C++" and install.
|
|
35
|
+
---------------------------------------------------------------------
|
|
36
|
+
`,
|
|
37
|
+
darwin: `
|
|
38
|
+
---------------------------------------------------------------------
|
|
39
|
+
[Qflow] Optional dependency for WebviewNode:
|
|
40
|
+
No special installation is required for running on macOS.
|
|
41
|
+
|
|
42
|
+
For development and building from source, you will need:
|
|
43
|
+
brew install cmake ninja clang
|
|
44
|
+
---------------------------------------------------------------------
|
|
45
|
+
`
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (messages[platform]) {
|
|
49
|
+
console.log(messages[platform]);
|
|
50
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
const root = path.resolve(import.meta.dir, '..');
|
|
6
|
+
const npmCommand = ['npm'];
|
|
7
|
+
const tmp = path.join(os.tmpdir(), `qflow-prepublish-${crypto.randomUUID()}`);
|
|
8
|
+
const consumer = path.join(tmp, 'consumer');
|
|
9
|
+
|
|
10
|
+
// `npm publish` leaks config such as npm_config_dry_run into lifecycle
|
|
11
|
+
// scripts. The verifier must run its own pack/install for real.
|
|
12
|
+
function npmEnv() {
|
|
13
|
+
const env = { ...process.env };
|
|
14
|
+
delete env.npm_config_dry_run;
|
|
15
|
+
delete env.npm_config_pack_destination;
|
|
16
|
+
return env;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function run(command, args, cwd, { capture = false, env = process.env } = {}) {
|
|
20
|
+
const cmd = Array.isArray(command) ? command : [command];
|
|
21
|
+
const result = Bun.spawnSync({
|
|
22
|
+
cmd: [...cmd, ...args],
|
|
23
|
+
cwd,
|
|
24
|
+
env,
|
|
25
|
+
stdout: capture ? 'pipe' : 'inherit',
|
|
26
|
+
stderr: capture ? 'pipe' : 'inherit',
|
|
27
|
+
});
|
|
28
|
+
const output = {
|
|
29
|
+
stdout: result.stdout?.toString() ?? '',
|
|
30
|
+
stderr: result.stderr?.toString() ?? '',
|
|
31
|
+
};
|
|
32
|
+
if (result.exitCode !== 0) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`${[...cmd, ...args].join(' ')} failed (exit ${result.exitCode})\n${output.stdout}${output.stderr}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return output;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const smokeSource = `
|
|
41
|
+
const subpaths = [
|
|
42
|
+
['@fractal-solutions/qflow', ['Node', 'Flow', 'AsyncNode', 'AsyncFlow']],
|
|
43
|
+
['@fractal-solutions/qflow/nodes', ['ReplaySafeNode', 'WaitForApprovalNode', 'ScheduleNode', 'BudgetNode', 'MemoryStoreNode']],
|
|
44
|
+
['@fractal-solutions/qflow/agent', ['AgentNode', 'AgentEngine']],
|
|
45
|
+
['@fractal-solutions/qflow/mcp', ['QFlowMCPServer']],
|
|
46
|
+
['@fractal-solutions/qflow/streaming', ['streamChatCompletions']],
|
|
47
|
+
['@fractal-solutions/qflow/durable', ['DurableFlow', 'SQLiteCheckpointer', 'WaitForApprovalNode', 'BudgetTracker']],
|
|
48
|
+
['@fractal-solutions/qflow/testing', ['recordFlow', 'MockNode']],
|
|
49
|
+
['@fractal-solutions/qflow/graph', ['MapNode', 'BranchNode']],
|
|
50
|
+
['@fractal-solutions/qflow/trace', ['normalizeTrace', 'writeTraceFile']],
|
|
51
|
+
['@fractal-solutions/qflow/optional', ['loadOptional']],
|
|
52
|
+
['@fractal-solutions/qflow/logger', ['log', 'LogLevel']],
|
|
53
|
+
['@fractal-solutions/qflow/llm', ['LLMNode', 'LLMAdapter']],
|
|
54
|
+
['@fractal-solutions/qflow/tool-spec', ['ToolSpec', 'ToolRegistry']],
|
|
55
|
+
['@fractal-solutions/qflow/contracts', ['StateContract', 'defineState']],
|
|
56
|
+
['@fractal-solutions/qflow/side-effects', ['ReplaySafeNode', 'SideEffectClaimedError']],
|
|
57
|
+
['@fractal-solutions/qflow/eval', ['AssertNode', 'ReplayNode']],
|
|
58
|
+
['@fractal-solutions/qflow/bun', ['BunSpawnNode', 'SQLiteQueryNode']],
|
|
59
|
+
['@fractal-solutions/qflow/approval', ['WaitForApprovalNode']],
|
|
60
|
+
['@fractal-solutions/qflow/schedule', ['ScheduleNode', 'nextCronTime']],
|
|
61
|
+
['@fractal-solutions/qflow/budget', ['BudgetTracker', 'BudgetNode', 'BudgetExceededError']],
|
|
62
|
+
['@fractal-solutions/qflow/memory', ['MemoryStoreNode', 'SQLiteMemoryStore']],
|
|
63
|
+
];
|
|
64
|
+
for (const [specifier, names] of subpaths) {
|
|
65
|
+
const mod = await import(specifier);
|
|
66
|
+
const missing = names.filter(name => !(name in mod));
|
|
67
|
+
if (missing.length) throw new Error(specifier + ': missing ' + missing.join(', '));
|
|
68
|
+
}
|
|
69
|
+
console.log('All ' + subpaths.length + ' published subpaths import correctly.');
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
console.log('[verify-package] 1/5 tests');
|
|
74
|
+
run(process.execPath, ['test', 'tests'], root);
|
|
75
|
+
|
|
76
|
+
console.log('[verify-package] 2/5 build');
|
|
77
|
+
run(process.execPath, ['run', 'build'], root);
|
|
78
|
+
|
|
79
|
+
console.log('[verify-package] 3/5 pack');
|
|
80
|
+
mkdirSync(tmp, { recursive: true });
|
|
81
|
+
const packed = run(npmCommand, ['pack', '--pack-destination', tmp, '--silent'], root, {
|
|
82
|
+
capture: true,
|
|
83
|
+
env: npmEnv(),
|
|
84
|
+
});
|
|
85
|
+
const tarball = packed.stdout.trim().split(/\r?\n/).filter(Boolean).pop();
|
|
86
|
+
if (!tarball?.endsWith('.tgz')) throw new Error(`Could not read tarball name from npm pack: ${packed.stdout}`);
|
|
87
|
+
console.log(`[verify-package] ${tarball}`);
|
|
88
|
+
|
|
89
|
+
console.log('[verify-package] 4/5 install tarball in a clean consumer project (runs postinstall)');
|
|
90
|
+
mkdirSync(consumer, { recursive: true });
|
|
91
|
+
writeFileSync(
|
|
92
|
+
path.join(consumer, 'package.json'),
|
|
93
|
+
JSON.stringify({ name: 'qflow-package-smoke', version: '1.0.0', private: true, type: 'module' }, null, 2)
|
|
94
|
+
);
|
|
95
|
+
run(npmCommand, [
|
|
96
|
+
'install', path.join(tmp, tarball),
|
|
97
|
+
'--omit=optional', '--no-audit', '--no-fund',
|
|
98
|
+
], consumer, { env: npmEnv() });
|
|
99
|
+
if (existsSync(path.join(consumer, 'node_modules', 'typescript'))) {
|
|
100
|
+
throw new Error('typescript was installed for the consumer; it must stay a devDependency.');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log('[verify-package] 5/5 import every published subpath');
|
|
104
|
+
writeFileSync(path.join(consumer, 'smoke.js'), smokeSource);
|
|
105
|
+
run(process.execPath, ['smoke.js'], consumer);
|
|
106
|
+
|
|
107
|
+
console.log('[verify-package] Package is ready to publish.');
|
|
108
|
+
} finally {
|
|
109
|
+
try {
|
|
110
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.warn(`[verify-package] Could not remove ${tmp}: ${error.message}`);
|
|
113
|
+
}
|
|
114
|
+
}
|