@fractal-solutions/qflow 1.0.50 → 1.0.51
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 +76 -7
- package/dist/nodes/http_server.d.ts +12 -0
- package/dist/nodes/http_server.js +85 -0
- package/dist/nodes/webhook.js +27 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,18 +14,20 @@
|
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
To get started quickly with a new project, you can use the `create-qflow` tool (Recommended):
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
|
|
21
|
-
# or
|
|
22
|
-
bun add @fractal-solutions/qflow
|
|
20
|
+
bunx create-qflow@latest <project-name>
|
|
23
21
|
```
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
or
|
|
24
|
+
|
|
25
|
+
You can install `qflow` via npm or Bun:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
|
|
28
|
+
npm install @fractal-solutions/qflow
|
|
29
|
+
# or
|
|
30
|
+
bun add @fractal-solutions/qflow
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
## Module Imports
|
|
@@ -251,7 +253,74 @@ For a detailed explanation of the agents, see the [Agents documentation](documen
|
|
|
251
253
|
|
|
252
254
|
## Integrated Nodes and their Examples
|
|
253
255
|
|
|
254
|
-
|
|
256
|
+
Here's a comprehensive list of integrated nodes available in qflow, along with a brief description and a link to their detailed documentation.
|
|
257
|
+
|
|
258
|
+
### Data
|
|
259
|
+
|
|
260
|
+
* **[CodeInterpreterNode](documentation/nodes/code_interpreter.md)**: Executes Python code snippets.
|
|
261
|
+
* **[DataExtractorNode](documentation/nodes/data_extractor.md)**: Extracts structured data from HTML, JSON, or plain text.
|
|
262
|
+
* **[DatabaseNode](documentation/nodes/database.md)**: Provides a powerful and flexible way to interact with SQL databases.
|
|
263
|
+
* **[EmbeddingNode](documentation/nodes/embedding.md)**: Generates vector embeddings for text (requires Ollama).
|
|
264
|
+
* **[MemoryNode](documentation/nodes/memory.md)**: Stores and retrieves text memories (keyword-based).
|
|
265
|
+
* **[SemanticMemoryNode](documentation/nodes/semantic_memory.md)**: Stores and retrieves text memories via semantic search (requires Ollama).
|
|
266
|
+
* **[TransformNode](documentation/nodes/transform.md)**: Transforms input data using a provided JavaScript function.
|
|
267
|
+
* **[PDFProcessorNode](documentation/nodes/pdf_processor.md)**: Extracts text or images from PDF documents.
|
|
268
|
+
* **[SpreadsheetNode](documentation/nodes/spreadsheet.md)**: Reads from and writes to spreadsheet files (.xlsx, .xls, .csv) with advanced manipulation.
|
|
269
|
+
* **[DataValidationNode](documentation/nodes/data_validation.md)**: Validates structured data against a JSON Schema.
|
|
270
|
+
|
|
271
|
+
### System
|
|
272
|
+
|
|
273
|
+
* **[ShellCommandNode](documentation/nodes/shell_command.md)**: Executes shell commands.
|
|
274
|
+
* **[ReadFileNode](documentation/nodes/read_file.md)**: Reads the content of a specified file.
|
|
275
|
+
* **[WriteFileNode](documentation/nodes/write_file.md)**: Writes content to a specified file.
|
|
276
|
+
* **[AppendFileNode](documentation/nodes/append_file.md)**: Appends content to an existing file.
|
|
277
|
+
* **[ListDirectoryNode](documentation/nodes/list_directory.md)**: Lists the files and subdirectories within a specified directory.
|
|
278
|
+
* **[SystemNotificationNode](documentation/nodes/system_notification.md)**: Displays a system-level notification across OSs.
|
|
279
|
+
* **[DisplayImageNode](documentation/nodes/display_image.md)**: Displays an image file using the system's default image viewer.
|
|
280
|
+
* **[HardwareInteractionNode](documentation/nodes/hardware_interaction.md)**: Communicates with local hardware via serial port (UART).
|
|
281
|
+
* **[ImageGalleryNode](documentation/nodes/image_gallery.md)**: Generates an HTML gallery from multiple image files and opens it in a web browser.
|
|
282
|
+
* **[SpeechSynthesisNode](documentation/nodes/speech_synthesis.md)**: Converts text to spoken audio using OS capabilities or cloud APIs.
|
|
283
|
+
* **[MultimediaProcessingNode](documentation/nodes/multimedia_processing.md)**: Performs various multimedia operations on audio and video files using ffmpeg.
|
|
284
|
+
* **[RemoteExecutionNode](documentation/nodes/remote_execution.md)**: Executes commands on remote machines via SSH.
|
|
285
|
+
|
|
286
|
+
### Web
|
|
287
|
+
|
|
288
|
+
* **[HttpRequestNode](documentation/nodes/http_request.md)**: Makes a generic HTTP request to any URL.
|
|
289
|
+
* **[WebScraperNode](documentation/nodes/web_scraper.md)**: Fetches the HTML content of a given URL.
|
|
290
|
+
* **[DuckDuckGoSearchNode](documentation/nodes/duckduckgo_search.md)**: Performs a web search using DuckDuckGo.
|
|
291
|
+
* **[GoogleSearchNode](documentation/nodes/google_search.md)**: Performs a web search using the Google Custom Search API.
|
|
292
|
+
* **[BrowserControlNode](documentation/nodes/browser_control.md)**: Controls a web browser to navigate pages, interact with elements, and take screenshots.
|
|
293
|
+
* **[WebSocketsNode](documentation/nodes/websockets.md)**: Provides real-time, two-way communication with web services.
|
|
294
|
+
* **[WebhookNode](documentation/nodes/webhook.md)**: Exposes an HTTP endpoint to receive webhooks, triggering a specified qflow flow.
|
|
295
|
+
* **[HttpServerNode](documentation/nodes/http_server.md)**: Creates a web server and handles HTTP requests by triggering a qflow flow.
|
|
296
|
+
|
|
297
|
+
### Flow Control
|
|
298
|
+
|
|
299
|
+
* **[SubFlowNode](documentation/nodes/sub_flow.md)**: Executes a sub-flow.
|
|
300
|
+
* **[IteratorNode](documentation/nodes/iterator.md)**: Iterates items, executes sub-flow for each.
|
|
301
|
+
* **[SchedulerNode](documentation/nodes/scheduler.md)**: Schedules qflow flows for future or recurring execution using cron syntax or a delay.
|
|
302
|
+
|
|
303
|
+
### Other
|
|
304
|
+
|
|
305
|
+
* **[GitNode](documentation/nodes/git.md)**: Performs Git operations like clone, add, commit, and push.
|
|
306
|
+
* **[GISNode](documentation/nodes/gis.md)**: Performs Geographic Information System operations like geocoding and reverse geocoding.
|
|
307
|
+
* **[GitHubNode](documentation/nodes/github.md)**: Performs GitHub operations like creating and managing issues.
|
|
308
|
+
* **[HackerNewsNode](documentation/nodes/hackernews.md)**: Fetches top stories and item details from Hacker News.
|
|
309
|
+
* **[StripeNode](documentation/nodes/stripe.md)**: Performs Stripe operations like creating charges and retrieving account balances.
|
|
310
|
+
|
|
311
|
+
### LLMs
|
|
312
|
+
|
|
313
|
+
* **[DeepSeekLLMNode](documentation/nodes/deepseek_llm.md)**: Interacts with the DeepSeek API.
|
|
314
|
+
* **[OpenAILLMNode](documentation/nodes/openai_llm.md)**: Interacts with the OpenAI API.
|
|
315
|
+
* **[GeminiLLMNode](documentation/nodes/gemini_llm.md)**: Interacts with the Google Gemini API.
|
|
316
|
+
* **[OllamaLLMNode](documentation/nodes/ollama_llm.md)**: Interacts with a local Ollama instance.
|
|
317
|
+
* **[HuggingFaceLLMNode](documentation/nodes/huggingface_llm.md)**: Interacts with the Hugging Face API.
|
|
318
|
+
* **[OpenRouterLLMNode](documentation/nodes/openrouter_llm.md)**: Interacts with the OpenRouter API.
|
|
319
|
+
|
|
320
|
+
### Agent
|
|
321
|
+
|
|
322
|
+
* **[AgentNode](documentation/nodes/agent.md)**: The core of agentic behavior in qflow. It orchestrates tools and LLM reasoning to achieve complex goals.
|
|
323
|
+
|
|
255
324
|
|
|
256
325
|
|
|
257
326
|
## Error Handling
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class HttpServerNode extends AsyncNode {
|
|
2
|
+
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | null;
|
|
3
|
+
flowToTrigger: AsyncFlow | null;
|
|
4
|
+
execAsync(): Promise<{
|
|
5
|
+
status: string;
|
|
6
|
+
port: any;
|
|
7
|
+
}>;
|
|
8
|
+
postAsync(shared: any, prepRes: any, execRes: any): Promise<any>;
|
|
9
|
+
}
|
|
10
|
+
import { AsyncNode } from '../qflow.js';
|
|
11
|
+
import http from 'http';
|
|
12
|
+
import { AsyncFlow } from '../qflow.js';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { AsyncNode, AsyncFlow } from '../qflow.js';
|
|
2
|
+
import http from 'http';
|
|
3
|
+
import { URL } from 'url';
|
|
4
|
+
export class HttpServerNode extends AsyncNode {
|
|
5
|
+
constructor(maxRetries = 1, wait = 0) {
|
|
6
|
+
super(maxRetries, wait);
|
|
7
|
+
this.server = null;
|
|
8
|
+
this.flowToTrigger = null;
|
|
9
|
+
}
|
|
10
|
+
async execAsync() {
|
|
11
|
+
const { port = 3000, flow, waitForFlow = false } = this.params;
|
|
12
|
+
if (!flow || !(flow instanceof AsyncFlow)) {
|
|
13
|
+
throw new Error('HttpServerNode requires a `flow` parameter of type AsyncFlow to trigger.');
|
|
14
|
+
}
|
|
15
|
+
this.flowToTrigger = flow;
|
|
16
|
+
if (this.server && this.server.listening) {
|
|
17
|
+
console.warn(`[HttpServerNode] Server already listening on port ${port}. Reusing existing server.`);
|
|
18
|
+
return { status: 'server_already_running', port };
|
|
19
|
+
}
|
|
20
|
+
this.server = http.createServer(async (req, res) => {
|
|
21
|
+
const requestUrl = new URL(req.url, `http://${req.headers.host}`);
|
|
22
|
+
let body = '';
|
|
23
|
+
req.on('data', chunk => {
|
|
24
|
+
body += chunk.toString();
|
|
25
|
+
});
|
|
26
|
+
req.on('end', async () => {
|
|
27
|
+
let payload;
|
|
28
|
+
if (body) {
|
|
29
|
+
try {
|
|
30
|
+
payload = JSON.parse(body);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
console.error('[HttpServerNode] Failed to parse request body as JSON:', e);
|
|
34
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
35
|
+
res.end(JSON.stringify({ error: 'Invalid JSON payload' }));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const triggeredFlowShared = {
|
|
40
|
+
webhook: {
|
|
41
|
+
req,
|
|
42
|
+
res,
|
|
43
|
+
headers: req.headers,
|
|
44
|
+
payload,
|
|
45
|
+
method: req.method,
|
|
46
|
+
path: requestUrl.pathname,
|
|
47
|
+
query: Object.fromEntries(requestUrl.searchParams)
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
if (waitForFlow) {
|
|
51
|
+
try {
|
|
52
|
+
const flowResult = await this.flowToTrigger.runAsync(triggeredFlowShared);
|
|
53
|
+
if (!res.writableEnded) {
|
|
54
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
55
|
+
res.end(JSON.stringify(flowResult));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (flowError) {
|
|
59
|
+
console.error('[HttpServerNode] Triggered flow failed:', flowError);
|
|
60
|
+
if (!res.writableEnded) {
|
|
61
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
62
|
+
res.end(JSON.stringify({ error: 'Flow execution failed' }));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.flowToTrigger.runAsync(triggeredFlowShared).catch(flowError => {
|
|
68
|
+
console.error('[HttpServerNode] Triggered flow failed:', flowError);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
await new Promise(resolve => {
|
|
74
|
+
this.server.listen(port, () => {
|
|
75
|
+
console.log(`[HttpServerNode] Listening for requests on http://localhost:${port}`);
|
|
76
|
+
resolve();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return { status: 'listening', port };
|
|
80
|
+
}
|
|
81
|
+
async postAsync(shared, prepRes, execRes) {
|
|
82
|
+
// The server should not be closed here.
|
|
83
|
+
return execRes;
|
|
84
|
+
}
|
|
85
|
+
}
|
package/dist/nodes/webhook.js
CHANGED
|
@@ -16,7 +16,8 @@ export class WebHookNode extends AsyncNode {
|
|
|
16
16
|
flow, // The qflow AsyncFlow instance to trigger
|
|
17
17
|
sharedSecret, // Optional: for HMAC verification
|
|
18
18
|
responseStatus = 200, // HTTP status to send back
|
|
19
|
-
responseBody = { status: 'received' } // HTTP body to send back
|
|
19
|
+
responseBody = { status: 'received' }, // HTTP body to send back
|
|
20
|
+
waitForFlow = false // Whether to wait for the flow to complete
|
|
20
21
|
} = this.params;
|
|
21
22
|
if (!flow || !(flow instanceof AsyncFlow)) {
|
|
22
23
|
throw new Error('WebHookNode requires a `flow` parameter of type AsyncFlow to trigger.');
|
|
@@ -68,19 +69,32 @@ export class WebHookNode extends AsyncNode {
|
|
|
68
69
|
console.log('[WebHookNode] Webhook signature verified.');
|
|
69
70
|
}
|
|
70
71
|
console.log(`[WebHookNode] Webhook received on ${this.webhookPath}. Triggering flow...`);
|
|
71
|
-
// Trigger the flow in the background
|
|
72
|
-
// Create a new shared object for the triggered flow, including the webhook payload
|
|
73
72
|
const triggeredFlowShared = { webhook: { headers: req.headers, payload: payload, method: req.method, path: requestUrl.pathname } };
|
|
74
|
-
this.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
if (this.params.waitForFlow) {
|
|
74
|
+
try {
|
|
75
|
+
const flowResult = await this.flowToTrigger.runAsync(triggeredFlowShared);
|
|
76
|
+
console.log('[WebHookNode] Triggered flow completed successfully:', flowResult);
|
|
77
|
+
res.writeHead(this.params.responseStatus || 200, { 'Content-Type': 'application/json' });
|
|
78
|
+
res.end(JSON.stringify(flowResult));
|
|
79
|
+
}
|
|
80
|
+
catch (flowError) {
|
|
81
|
+
console.error('[WebHookNode] Triggered flow failed:', flowError);
|
|
82
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
83
|
+
res.end(JSON.stringify({ error: 'Flow execution failed' }));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.flowToTrigger.runAsync(triggeredFlowShared)
|
|
88
|
+
.then(flowResult => {
|
|
89
|
+
console.log('[WebHookNode] Triggered flow completed successfully:', flowResult);
|
|
90
|
+
})
|
|
91
|
+
.catch(flowError => {
|
|
92
|
+
console.error('[WebHookNode] Triggered flow failed:', flowError);
|
|
93
|
+
});
|
|
94
|
+
// Send response back to webhook sender
|
|
95
|
+
res.writeHead(this.params.responseStatus || 200, { 'Content-Type': 'application/json' });
|
|
96
|
+
res.end(JSON.stringify(this.params.responseBody || { status: 'received' }));
|
|
97
|
+
}
|
|
84
98
|
});
|
|
85
99
|
}
|
|
86
100
|
else {
|
package/package.json
CHANGED