@fractal-solutions/qflow 1.0.61 → 1.0.63

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.
Files changed (110) hide show
  1. package/README.md +75 -74
  2. package/package.json +1 -1
  3. package/dist/agent/agent.d.ts +0 -23
  4. package/dist/agent/agent.js +0 -365
  5. package/dist/agent/base_agent.d.ts +0 -21
  6. package/dist/agent/base_agent.js +0 -206
  7. package/dist/agent/logger.d.ts +0 -9
  8. package/dist/agent/logger.js +0 -45
  9. package/dist/agent/lpavrl_agent.d.ts +0 -5
  10. package/dist/agent/lpavrl_agent.js +0 -178
  11. package/dist/agent/ooda_agent.d.ts +0 -5
  12. package/dist/agent/ooda_agent.js +0 -167
  13. package/dist/agent/pema_agent.d.ts +0 -5
  14. package/dist/agent/pema_agent.js +0 -171
  15. package/dist/agent/raor_agent.d.ts +0 -5
  16. package/dist/agent/raor_agent.js +0 -164
  17. package/dist/agent/tools.d.ts +0 -5378
  18. package/dist/agent/tools.js +0 -1174
  19. package/dist/logger.d.ts +0 -9
  20. package/dist/logger.js +0 -107
  21. package/dist/nodes/agent_llm.d.ts +0 -31
  22. package/dist/nodes/agent_llm.js +0 -302
  23. package/dist/nodes/browser_control.d.ts +0 -4
  24. package/dist/nodes/browser_control.js +0 -73
  25. package/dist/nodes/code_interpreter.d.ts +0 -9
  26. package/dist/nodes/code_interpreter.js +0 -121
  27. package/dist/nodes/data_extractor.d.ts +0 -5
  28. package/dist/nodes/data_extractor.js +0 -81
  29. package/dist/nodes/data_validation.d.ts +0 -9
  30. package/dist/nodes/data_validation.js +0 -48
  31. package/dist/nodes/database.d.ts +0 -6
  32. package/dist/nodes/database.js +0 -89
  33. package/dist/nodes/display_image.d.ts +0 -4
  34. package/dist/nodes/display_image.js +0 -47
  35. package/dist/nodes/embedding.d.ts +0 -7
  36. package/dist/nodes/embedding.js +0 -45
  37. package/dist/nodes/filesystem.d.ts +0 -41
  38. package/dist/nodes/filesystem.js +0 -88
  39. package/dist/nodes/gis.d.ts +0 -37
  40. package/dist/nodes/gis.js +0 -106
  41. package/dist/nodes/git.d.ts +0 -4
  42. package/dist/nodes/git.js +0 -55
  43. package/dist/nodes/github.d.ts +0 -27
  44. package/dist/nodes/github.js +0 -75
  45. package/dist/nodes/hackernews.d.ts +0 -19
  46. package/dist/nodes/hackernews.js +0 -47
  47. package/dist/nodes/hardware_interaction.d.ts +0 -8
  48. package/dist/nodes/hardware_interaction.js +0 -98
  49. package/dist/nodes/http.d.ts +0 -26
  50. package/dist/nodes/http.js +0 -67
  51. package/dist/nodes/http_server.d.ts +0 -17
  52. package/dist/nodes/http_server.js +0 -190
  53. package/dist/nodes/image_gallery.d.ts +0 -8
  54. package/dist/nodes/image_gallery.js +0 -100
  55. package/dist/nodes/index.d.ts +0 -48
  56. package/dist/nodes/index.js +0 -48
  57. package/dist/nodes/interactive_input.d.ts +0 -4
  58. package/dist/nodes/interactive_input.js +0 -71
  59. package/dist/nodes/interactive_webview.d.ts +0 -19
  60. package/dist/nodes/interactive_webview.js +0 -310
  61. package/dist/nodes/iterator.d.ts +0 -5
  62. package/dist/nodes/iterator.js +0 -23
  63. package/dist/nodes/llm.d.ts +0 -18
  64. package/dist/nodes/llm.js +0 -215
  65. package/dist/nodes/memory.d.ts +0 -12
  66. package/dist/nodes/memory.js +0 -48
  67. package/dist/nodes/multimedia_processing.d.ts +0 -10
  68. package/dist/nodes/multimedia_processing.js +0 -80
  69. package/dist/nodes/openrouter_llm.d.ts +0 -8
  70. package/dist/nodes/openrouter_llm.js +0 -124
  71. package/dist/nodes/pdf_processor.d.ts +0 -4
  72. package/dist/nodes/pdf_processor.js +0 -75
  73. package/dist/nodes/remote_execution.d.ts +0 -4
  74. package/dist/nodes/remote_execution.js +0 -83
  75. package/dist/nodes/s3.d.ts +0 -6
  76. package/dist/nodes/s3.js +0 -38
  77. package/dist/nodes/scheduler.d.ts +0 -20
  78. package/dist/nodes/scheduler.js +0 -98
  79. package/dist/nodes/search.d.ts +0 -25
  80. package/dist/nodes/search.js +0 -78
  81. package/dist/nodes/semantic_memory.d.ts +0 -17
  82. package/dist/nodes/semantic_memory.js +0 -111
  83. package/dist/nodes/shell.d.ts +0 -11
  84. package/dist/nodes/shell.js +0 -29
  85. package/dist/nodes/speech_synthesis.d.ts +0 -45
  86. package/dist/nodes/speech_synthesis.js +0 -142
  87. package/dist/nodes/spreadsheet.d.ts +0 -10
  88. package/dist/nodes/spreadsheet.js +0 -241
  89. package/dist/nodes/stripe.d.ts +0 -23
  90. package/dist/nodes/stripe.js +0 -69
  91. package/dist/nodes/subflow.d.ts +0 -5
  92. package/dist/nodes/subflow.js +0 -16
  93. package/dist/nodes/summarize.d.ts +0 -12
  94. package/dist/nodes/summarize.js +0 -31
  95. package/dist/nodes/system_notification.d.ts +0 -4
  96. package/dist/nodes/system_notification.js +0 -50
  97. package/dist/nodes/transform.d.ts +0 -5
  98. package/dist/nodes/transform.js +0 -32
  99. package/dist/nodes/user.d.ts +0 -11
  100. package/dist/nodes/user.js +0 -32
  101. package/dist/nodes/webhook.d.ts +0 -15
  102. package/dist/nodes/webhook.js +0 -125
  103. package/dist/nodes/webscraper.d.ts +0 -11
  104. package/dist/nodes/webscraper.js +0 -33
  105. package/dist/nodes/websockets.d.ts +0 -4
  106. package/dist/nodes/websockets.js +0 -73
  107. package/dist/nodes/webview.d.ts +0 -12
  108. package/dist/nodes/webview.js +0 -27
  109. package/dist/qflow.d.ts +0 -69
  110. package/dist/qflow.js +0 -320
@@ -1,11 +0,0 @@
1
- /**
2
- * Prompts the user for input and waits for their response.
3
- * @param {object} params - The parameters for the node.
4
- * @param {string} params.prompt - The message to display to the user.
5
- * @returns {Promise<string>} A promise that resolves to the user's input.
6
- */
7
- export class UserInputNode extends AsyncNode {
8
- execAsync(): Promise<any>;
9
- postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
10
- }
11
- import { AsyncNode } from '../qflow.js';
@@ -1,32 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import readline from 'readline';
3
- /**
4
- * Prompts the user for input and waits for their response.
5
- * @param {object} params - The parameters for the node.
6
- * @param {string} params.prompt - The message to display to the user.
7
- * @returns {Promise<string>} A promise that resolves to the user's input.
8
- */
9
- export class UserInputNode extends AsyncNode {
10
- async execAsync() {
11
- const { prompt } = this.params;
12
- if (!prompt) {
13
- throw new Error('Missing required parameter: prompt');
14
- }
15
- const rl = readline.createInterface({
16
- input: process.stdin,
17
- output: process.stdout
18
- });
19
- return new Promise((resolve) => {
20
- // ANSI escape codes for yellow text
21
- const yellowPrompt = `\x1b[33m${prompt}\x1b[0m`;
22
- rl.question(yellowPrompt, (answer) => {
23
- rl.close();
24
- resolve(answer);
25
- });
26
- });
27
- }
28
- async postAsync(shared, prepRes, execRes) {
29
- shared.userInput = execRes;
30
- return 'default';
31
- }
32
- }
@@ -1,15 +0,0 @@
1
- export class WebHookNode extends AsyncNode {
2
- server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | null;
3
- flowToTrigger: AsyncFlow | null;
4
- webhookPath: any;
5
- sharedSecret: any;
6
- execAsync(): Promise<{
7
- status: string;
8
- port: any;
9
- path: any;
10
- }>;
11
- postAsync(shared: any, prepRes: any, execRes: any): Promise<any>;
12
- }
13
- import { AsyncNode } from '../qflow.js';
14
- import http from 'http';
15
- import { AsyncFlow } from '../qflow.js';
@@ -1,125 +0,0 @@
1
- import { AsyncNode, AsyncFlow } from '../qflow.js';
2
- import http from 'http';
3
- import { URL } from 'url'; // Node.js built-in
4
- import crypto from 'crypto'; // Node.js built-in
5
- import { log } from '../logger.js';
6
- export class WebHookNode extends AsyncNode {
7
- constructor(maxRetries = 1, wait = 0) {
8
- super(maxRetries, wait);
9
- this.server = null;
10
- this.flowToTrigger = null;
11
- this.webhookPath = null;
12
- this.sharedSecret = null;
13
- }
14
- async execAsync() {
15
- const { port = 3000, // Port to listen on
16
- path = '/webhook', // URL path for the webhook
17
- flow, // The qflow AsyncFlow instance to trigger
18
- sharedSecret, // Optional: for HMAC verification
19
- responseStatus = 200, // HTTP status to send back
20
- responseBody = { status: 'received' }, // HTTP body to send back
21
- waitForFlow = false // Whether to wait for the flow to complete
22
- } = this.params;
23
- if (!flow || !(flow instanceof AsyncFlow)) {
24
- throw new Error('WebHookNode requires a `flow` parameter of type AsyncFlow to trigger.');
25
- }
26
- this.flowToTrigger = flow;
27
- this.webhookPath = path;
28
- this.sharedSecret = sharedSecret;
29
- // Ensure server is not already running
30
- if (this.server && this.server.listening) {
31
- log(`[WebHookNode] Server already listening on port ${port}. Reusing existing server.`, this.params.logging, { type: 'warn' });
32
- return { status: 'server_already_running', port, path };
33
- }
34
- this.server = http.createServer(async (req, res) => {
35
- const requestUrl = new URL(req.url, `http://${req.headers.host}`);
36
- if (req.method === 'POST' && requestUrl.pathname === this.webhookPath) {
37
- let body = '';
38
- req.on('data', chunk => {
39
- body += chunk.toString();
40
- });
41
- req.on('end', async () => {
42
- let payload;
43
- try {
44
- payload = JSON.parse(body);
45
- }
46
- catch (e) {
47
- log('[WebHookNode] Failed to parse webhook body as JSON:', this.params.logging, { type: 'error' });
48
- res.writeHead(400, { 'Content-Type': 'application/json' });
49
- res.end(JSON.stringify({ error: 'Invalid JSON payload' }));
50
- return;
51
- }
52
- // --- Security: HMAC Verification (if sharedSecret is provided) ---
53
- if (this.sharedSecret) {
54
- const signature = req.headers['x-hub-signature-256'] || req.headers['x-webhook-signature']; // Common headers
55
- if (!signature) {
56
- log('[WebHookNode] Webhook received without signature, but sharedSecret is configured.', this.params.logging, { type: 'warn' });
57
- res.writeHead(401, { 'Content-Type': 'application/json' });
58
- res.end(JSON.stringify({ error: 'Missing signature' }));
59
- return;
60
- }
61
- const hmac = crypto.createHmac('sha256', this.sharedSecret);
62
- hmac.update(body);
63
- const digest = `sha256=${hmac.digest('hex')}`; // Format might vary (e.g., 'v1=...')
64
- if (digest !== signature) { // Simple comparison, real-world might need more robust parsing
65
- log('[WebHookNode] Webhook signature mismatch. Request rejected.', this.params.logging, { type: 'warn' });
66
- res.writeHead(403, { 'Content-Type': 'application/json' });
67
- res.end(JSON.stringify({ error: 'Invalid signature' }));
68
- return;
69
- }
70
- log('[WebHookNode] Webhook signature verified.', this.params.logging);
71
- }
72
- log(`[WebHookNode] Webhook received on ${this.webhookPath}. Triggering flow...`, this.params.logging);
73
- const triggeredFlowShared = { webhook: { headers: req.headers, payload: payload, method: req.method, path: requestUrl.pathname } };
74
- if (this.params.waitForFlow) {
75
- try {
76
- const flowResult = await this.flowToTrigger.runAsync(triggeredFlowShared);
77
- log('[WebHookNode] Triggered flow completed successfully:', this.params.logging);
78
- res.writeHead(this.params.responseStatus || 200, { 'Content-Type': 'application/json' });
79
- res.end(JSON.stringify(flowResult));
80
- }
81
- catch (flowError) {
82
- log('[WebHookNode] Triggered flow failed:', this.params.logging, { type: 'error' });
83
- res.writeHead(500, { 'Content-Type': 'application/json' });
84
- res.end(JSON.stringify({ error: 'Flow execution failed' }));
85
- }
86
- }
87
- else {
88
- this.flowToTrigger.runAsync(triggeredFlowShared)
89
- .then(flowResult => {
90
- log('[WebHookNode] Triggered flow completed successfully:', this.params.logging);
91
- })
92
- .catch(flowError => {
93
- log('[WebHookNode] Triggered flow failed:', this.params.logging, { type: 'error' });
94
- });
95
- // Send response back to webhook sender
96
- res.writeHead(this.params.responseStatus || 200, { 'Content-Type': 'application/json' });
97
- res.end(JSON.stringify(this.params.responseBody || { status: 'received' }));
98
- }
99
- });
100
- }
101
- else {
102
- res.writeHead(404, { 'Content-Type': 'text/plain' });
103
- res.end('Not Found');
104
- }
105
- });
106
- await new Promise(resolve => {
107
- this.server.listen(port, () => {
108
- log(`[WebHookNode] Listening for webhooks on http://localhost:${port}${this.webhookPath}`, this.params.logging);
109
- resolve();
110
- });
111
- });
112
- // This node returns immediately after starting the server.
113
- // The flow continues, and the server runs in the background.
114
- return { status: 'listening', port, path: this.webhookPath };
115
- }
116
- // Cleanup: Ensure the server is closed when the node's flow completes or is cancelled
117
- async postAsync(shared, prepRes, execRes) {
118
- // For a long-running webhook listener, the server should NOT be closed here.
119
- // The server is intended to run in the background.
120
- // Cleanup (server.close()) should be handled by the application's shutdown logic
121
- // or if the WebHookNode is explicitly stopped by another part of the flow.
122
- // We will remove the automatic server closing here.
123
- return execRes;
124
- }
125
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Fetches the HTML content of a given URL.
3
- * @param {object} params - The parameters for the node.
4
- * @param {string} params.url - The URL to scrape.
5
- * @returns {Promise<string>} A promise that resolves to the HTML content of the page.
6
- */
7
- export class ScrapeURLNode extends AsyncNode {
8
- execAsync(): Promise<string>;
9
- postAsync(shared: any, prepRes: any, execRes: any): Promise<any>;
10
- }
11
- import { AsyncNode } from '../qflow.js';
@@ -1,33 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import { log } from '../logger.js';
3
- /**
4
- * Fetches the HTML content of a given URL.
5
- * @param {object} params - The parameters for the node.
6
- * @param {string} params.url - The URL to scrape.
7
- * @returns {Promise<string>} A promise that resolves to the HTML content of the page.
8
- */
9
- export class ScrapeURLNode extends AsyncNode {
10
- async execAsync() {
11
- const { url } = this.params;
12
- if (!url) {
13
- throw new Error('URL is required for ScrapeURLNode.');
14
- }
15
- log(`[WebScraper] Scraping URL: ${url}...`, this.params.logging);
16
- const response = await fetch(url);
17
- if (!response.ok) {
18
- throw new Error(`Failed to fetch URL: ${response.status} - ${response.statusText}`);
19
- }
20
- const html = await response.text();
21
- log(`[WebScraper] Successfully scraped URL: ${url}`, this.params.logging);
22
- return html;
23
- }
24
- async postAsync(shared, prepRes, execRes) {
25
- // Truncate the scraped HTML to avoid exceeding LLM context windows
26
- const MAX_HTML_LENGTH = 4000;
27
- shared.webScrapedContent = execRes.substring(0, MAX_HTML_LENGTH);
28
- if (execRes.length > MAX_HTML_LENGTH) {
29
- log(`[WebScraper] Truncated HTML content from ${execRes.length} to ${MAX_HTML_LENGTH} characters.`, this.params.logging, { type: 'warn' });
30
- }
31
- return shared.webScrapedContent;
32
- }
33
- }
@@ -1,4 +0,0 @@
1
- export class WebSocketsNode extends AsyncNode {
2
- execAsync(prepRes: any, shared: any): Promise<any>;
3
- }
4
- import { AsyncNode } from '../qflow.js';
@@ -1,73 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import WebSocket from 'ws';
3
- export class WebSocketsNode extends AsyncNode {
4
- async execAsync(prepRes, shared) {
5
- const { action, url, message, timeout = 5000, // 5-second timeout
6
- } = this.params;
7
- const connection = shared.webSocketConnection;
8
- return new Promise(async (resolve, reject) => {
9
- const timer = setTimeout(() => reject(new Error(`WebSocket action '${action}' timed out after ${timeout}ms`)), timeout);
10
- try {
11
- switch (action) {
12
- case 'connect':
13
- if (!url)
14
- throw new Error('`url` parameter is required for `connect` action.');
15
- const ws = new WebSocket(url);
16
- ws.on('open', () => {
17
- clearTimeout(timer);
18
- shared.webSocketConnection = ws;
19
- resolve({ message: `WebSocket connected to ${url}` });
20
- });
21
- ws.on('error', (err) => {
22
- clearTimeout(timer);
23
- reject(err);
24
- });
25
- break;
26
- case 'send':
27
- if (!connection)
28
- throw new Error('No active WebSocket connection found.');
29
- if (message === undefined)
30
- throw new Error('`message` parameter is required for `send` action.');
31
- const dataToSend = typeof message === 'object' ? JSON.stringify(message) : message;
32
- connection.send(dataToSend);
33
- clearTimeout(timer);
34
- resolve({ message: 'Message sent' });
35
- break;
36
- case 'receive':
37
- if (!connection)
38
- throw new Error('No active WebSocket connection found.');
39
- connection.once('message', (data) => {
40
- clearTimeout(timer);
41
- try {
42
- // Try to parse as JSON, otherwise return as string
43
- resolve(JSON.parse(data.toString()));
44
- }
45
- catch (e) {
46
- resolve(data.toString());
47
- }
48
- });
49
- connection.once('error', (err) => {
50
- clearTimeout(timer);
51
- reject(err);
52
- });
53
- break;
54
- case 'close':
55
- if (connection) {
56
- connection.close();
57
- delete shared.webSocketConnection;
58
- }
59
- clearTimeout(timer);
60
- resolve({ message: 'WebSocket connection closed' });
61
- break;
62
- default:
63
- clearTimeout(timer);
64
- throw new Error(`Unsupported WebSocket action: ${action}`);
65
- }
66
- }
67
- catch (error) {
68
- clearTimeout(timer);
69
- reject(error);
70
- }
71
- });
72
- }
73
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * A node that displays a webview window with the given HTML content.
3
- * @param {object} params - The parameters for the node.
4
- * @param {string} params.html - The HTML content to display in the webview.
5
- * @param {string} [params.title='Qflow Webview'] - The title of the webview window.
6
- * @param {number} [params.width=800] - The width of the webview window.
7
- * @param {number} [params.height=600] - The height of the webview window.
8
- */
9
- export class WebviewNode extends AsyncNode {
10
- execAsync(): Promise<string>;
11
- }
12
- import { AsyncNode } from '../qflow.js';
@@ -1,27 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import { Webview, SizeHint } from 'webview-bun';
3
- import { log } from '../logger.js';
4
- /**
5
- * A node that displays a webview window with the given HTML content.
6
- * @param {object} params - The parameters for the node.
7
- * @param {string} params.html - The HTML content to display in the webview.
8
- * @param {string} [params.title='Qflow Webview'] - The title of the webview window.
9
- * @param {number} [params.width=800] - The width of the webview window.
10
- * @param {number} [params.height=600] - The height of the webview window.
11
- */
12
- export class WebviewNode extends AsyncNode {
13
- async execAsync() {
14
- const { html, title = 'Qflow Webview', width = 800, height = 600 } = this.params;
15
- if (!html) {
16
- throw new Error('WebviewNode requires an `html` parameter.');
17
- }
18
- log(`[WebviewNode] Creating webview window with title: "${title}"`, this.params.logging);
19
- const webview = new Webview();
20
- webview.title = title;
21
- webview.size = { width, height, hint: SizeHint.NONE };
22
- webview.setHTML(html);
23
- webview.run();
24
- log(`[WebviewNode] Webview window closed.`, this.params.logging);
25
- return 'default';
26
- }
27
- }
package/dist/qflow.d.ts DELETED
@@ -1,69 +0,0 @@
1
- export class BaseNode {
2
- params: {};
3
- successors: {};
4
- setParams(params: any): void;
5
- next(node: any, action?: string): any;
6
- prep(shared: any): void;
7
- exec(prepRes: any): void;
8
- post(shared: any, prepRes: any, execRes: any): any;
9
- _exec(prepRes: any): void;
10
- _run(shared: any): any;
11
- run(shared: any): any;
12
- transition(action: any): ConditionalTransition;
13
- }
14
- export class Node extends BaseNode {
15
- constructor(maxRetries?: number, wait?: number);
16
- maxRetries: number;
17
- wait: number;
18
- execFallback(prepRes: any, error: any): void;
19
- _exec(prepRes: any, shared: any): void;
20
- }
21
- export class BatchNode extends Node {
22
- _exec(items: any): any;
23
- }
24
- export class Flow extends BaseNode {
25
- constructor(start?: null);
26
- startNode: any;
27
- start(startNode: any): any;
28
- getNextNode(curr: any, action: any): any;
29
- _orch(shared: any, params?: {}): any;
30
- }
31
- export class BatchFlow extends Flow {
32
- }
33
- export class AsyncNode extends Node {
34
- prepAsync(shared: any): Promise<void>;
35
- execAsync(prepRes: any): Promise<void>;
36
- execFallbackAsync(prepRes: any, error: any): Promise<void>;
37
- postAsync(shared: any, prepRes: any, execRes: any): Promise<void>;
38
- _exec(prepRes: any, shared: any, observer?: {}): Promise<void>;
39
- runAsync(shared: any): Promise<void>;
40
- _runAsync(shared: any): Promise<void>;
41
- _run(): void;
42
- }
43
- export class AsyncBatchNode extends AsyncNode {
44
- _exec(items: any, shared: any, observer: any): Promise<void[]>;
45
- }
46
- export class AsyncParallelBatchNode extends AsyncNode {
47
- _exec(items: any, shared: any, observer: any): Promise<any[]>;
48
- }
49
- export class AsyncFlow extends Flow {
50
- listeners: {};
51
- on(eventName: any, callback: any): void;
52
- emit(eventName: any, payload: any): void;
53
- prepAsync(shared: any): Promise<void>;
54
- postAsync(shared: any, prepRes: any, execRes: any): Promise<any>;
55
- _orchAsync(flowId: any, shared: any, params?: {}, initialNode?: any): Promise<any>;
56
- _runAsync(shared: any): Promise<any>;
57
- run(): void;
58
- runAsync(shared?: {}): Promise<any>;
59
- }
60
- export class AsyncBatchFlow extends AsyncFlow {
61
- }
62
- export class AsyncParallelBatchFlow extends AsyncFlow {
63
- }
64
- export class ConditionalTransition {
65
- constructor(src: any, action: any);
66
- src: any;
67
- action: any;
68
- to(tgt: any): any;
69
- }