@fractal-solutions/qflow 1.0.62 → 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.
- package/package.json +1 -1
- package/dist/agent/agent.d.ts +0 -23
- package/dist/agent/agent.js +0 -365
- package/dist/agent/base_agent.d.ts +0 -21
- package/dist/agent/base_agent.js +0 -206
- package/dist/agent/logger.d.ts +0 -9
- package/dist/agent/logger.js +0 -45
- package/dist/agent/lpavrl_agent.d.ts +0 -5
- package/dist/agent/lpavrl_agent.js +0 -178
- package/dist/agent/ooda_agent.d.ts +0 -5
- package/dist/agent/ooda_agent.js +0 -167
- package/dist/agent/pema_agent.d.ts +0 -5
- package/dist/agent/pema_agent.js +0 -171
- package/dist/agent/raor_agent.d.ts +0 -5
- package/dist/agent/raor_agent.js +0 -164
- package/dist/agent/tools.d.ts +0 -5378
- package/dist/agent/tools.js +0 -1174
- package/dist/logger.d.ts +0 -9
- package/dist/logger.js +0 -107
- package/dist/nodes/agent_llm.d.ts +0 -31
- package/dist/nodes/agent_llm.js +0 -302
- package/dist/nodes/browser_control.d.ts +0 -4
- package/dist/nodes/browser_control.js +0 -73
- package/dist/nodes/code_interpreter.d.ts +0 -9
- package/dist/nodes/code_interpreter.js +0 -121
- package/dist/nodes/data_extractor.d.ts +0 -5
- package/dist/nodes/data_extractor.js +0 -81
- package/dist/nodes/data_validation.d.ts +0 -9
- package/dist/nodes/data_validation.js +0 -48
- package/dist/nodes/database.d.ts +0 -6
- package/dist/nodes/database.js +0 -89
- package/dist/nodes/display_image.d.ts +0 -4
- package/dist/nodes/display_image.js +0 -47
- package/dist/nodes/embedding.d.ts +0 -7
- package/dist/nodes/embedding.js +0 -45
- package/dist/nodes/filesystem.d.ts +0 -41
- package/dist/nodes/filesystem.js +0 -88
- package/dist/nodes/gis.d.ts +0 -37
- package/dist/nodes/gis.js +0 -106
- package/dist/nodes/git.d.ts +0 -4
- package/dist/nodes/git.js +0 -55
- package/dist/nodes/github.d.ts +0 -27
- package/dist/nodes/github.js +0 -75
- package/dist/nodes/hackernews.d.ts +0 -19
- package/dist/nodes/hackernews.js +0 -47
- package/dist/nodes/hardware_interaction.d.ts +0 -8
- package/dist/nodes/hardware_interaction.js +0 -98
- package/dist/nodes/http.d.ts +0 -26
- package/dist/nodes/http.js +0 -67
- package/dist/nodes/http_server.d.ts +0 -17
- package/dist/nodes/http_server.js +0 -190
- package/dist/nodes/image_gallery.d.ts +0 -8
- package/dist/nodes/image_gallery.js +0 -100
- package/dist/nodes/index.d.ts +0 -48
- package/dist/nodes/index.js +0 -48
- package/dist/nodes/interactive_input.d.ts +0 -4
- package/dist/nodes/interactive_input.js +0 -71
- package/dist/nodes/interactive_webview.d.ts +0 -19
- package/dist/nodes/interactive_webview.js +0 -310
- package/dist/nodes/iterator.d.ts +0 -5
- package/dist/nodes/iterator.js +0 -23
- package/dist/nodes/llm.d.ts +0 -18
- package/dist/nodes/llm.js +0 -215
- package/dist/nodes/memory.d.ts +0 -12
- package/dist/nodes/memory.js +0 -48
- package/dist/nodes/multimedia_processing.d.ts +0 -10
- package/dist/nodes/multimedia_processing.js +0 -80
- package/dist/nodes/openrouter_llm.d.ts +0 -8
- package/dist/nodes/openrouter_llm.js +0 -124
- package/dist/nodes/pdf_processor.d.ts +0 -4
- package/dist/nodes/pdf_processor.js +0 -75
- package/dist/nodes/remote_execution.d.ts +0 -4
- package/dist/nodes/remote_execution.js +0 -83
- package/dist/nodes/s3.d.ts +0 -6
- package/dist/nodes/s3.js +0 -38
- package/dist/nodes/scheduler.d.ts +0 -20
- package/dist/nodes/scheduler.js +0 -98
- package/dist/nodes/search.d.ts +0 -25
- package/dist/nodes/search.js +0 -78
- package/dist/nodes/semantic_memory.d.ts +0 -17
- package/dist/nodes/semantic_memory.js +0 -111
- package/dist/nodes/shell.d.ts +0 -11
- package/dist/nodes/shell.js +0 -29
- package/dist/nodes/speech_synthesis.d.ts +0 -45
- package/dist/nodes/speech_synthesis.js +0 -142
- package/dist/nodes/spreadsheet.d.ts +0 -10
- package/dist/nodes/spreadsheet.js +0 -241
- package/dist/nodes/stripe.d.ts +0 -23
- package/dist/nodes/stripe.js +0 -69
- package/dist/nodes/subflow.d.ts +0 -5
- package/dist/nodes/subflow.js +0 -16
- package/dist/nodes/summarize.d.ts +0 -12
- package/dist/nodes/summarize.js +0 -31
- package/dist/nodes/system_notification.d.ts +0 -4
- package/dist/nodes/system_notification.js +0 -50
- package/dist/nodes/transform.d.ts +0 -5
- package/dist/nodes/transform.js +0 -32
- package/dist/nodes/user.d.ts +0 -11
- package/dist/nodes/user.js +0 -32
- package/dist/nodes/webhook.d.ts +0 -15
- package/dist/nodes/webhook.js +0 -125
- package/dist/nodes/webscraper.d.ts +0 -11
- package/dist/nodes/webscraper.js +0 -33
- package/dist/nodes/websockets.d.ts +0 -4
- package/dist/nodes/websockets.js +0 -73
- package/dist/nodes/webview.d.ts +0 -12
- package/dist/nodes/webview.js +0 -27
- package/dist/qflow.d.ts +0 -69
- package/dist/qflow.js +0 -320
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { AsyncNode, AsyncFlow } from '../qflow.js';
|
|
2
|
-
import { ShellCommandNode } from './index.js'; // Assuming ShellCommandNode is available
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import os from 'os';
|
|
5
|
-
import { promises as fs } from 'fs';
|
|
6
|
-
import { log } from '../logger.js';
|
|
7
|
-
export class ImageGalleryNode extends AsyncNode {
|
|
8
|
-
constructor(maxRetries = 1, wait = 0) {
|
|
9
|
-
super(maxRetries, wait);
|
|
10
|
-
}
|
|
11
|
-
async execAsync() {
|
|
12
|
-
const { imagePaths, // Array of absolute paths to image files
|
|
13
|
-
title = 'Image Gallery', description = 'Generated by QFlow Agent', outputDir // Optional: directory to save the HTML file
|
|
14
|
-
} = this.params;
|
|
15
|
-
if (!imagePaths || !Array.isArray(imagePaths) || imagePaths.length === 0) {
|
|
16
|
-
throw new Error('ImageGalleryNode requires an `imagePaths` array.');
|
|
17
|
-
}
|
|
18
|
-
const tempDir = outputDir || path.join(os.tmpdir(), `qflow_image_gallery_${Date.now()}`);
|
|
19
|
-
await fs.mkdir(tempDir, { recursive: true });
|
|
20
|
-
const htmlFilePath = path.join(tempDir, 'index.html');
|
|
21
|
-
// Generate HTML content
|
|
22
|
-
let imageHtml = '';
|
|
23
|
-
for (const imagePath of imagePaths) {
|
|
24
|
-
// For security and portability, it's best to embed images as base64 data URIs
|
|
25
|
-
// or ensure they are served from a web-accessible location.
|
|
26
|
-
// For simplicity in this node, we'll use file:// URLs, but this might have browser security warnings.
|
|
27
|
-
// A more robust solution would involve a local web server (like BrowserGUINode).
|
|
28
|
-
// For simplicity in this node, we'll assume direct file access for now.
|
|
29
|
-
// Or, even better, copy images to the tempDir and reference them relatively.
|
|
30
|
-
const imageName = path.basename(imagePath);
|
|
31
|
-
const destImagePath = path.join(tempDir, imageName);
|
|
32
|
-
try {
|
|
33
|
-
await fs.copyFile(imagePath, destImagePath); // Copy image to temp dir
|
|
34
|
-
imageHtml += `<div class="gallery-item">\n`;
|
|
35
|
-
imageHtml += ` <img src="${imageName}" alt="${imageName}">\n`;
|
|
36
|
-
imageHtml += ` <p>${imageName}</p>\n`;
|
|
37
|
-
imageHtml += `</div>\n`;
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
log(`[ImageGalleryNode] Could not copy image ${imagePath}: ${e.message}. Skipping.`, this.params.logging, { type: 'warn' });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const htmlContent = `
|
|
44
|
-
<!DOCTYPE html>
|
|
45
|
-
<html lang="en">
|
|
46
|
-
<head>
|
|
47
|
-
<meta charset="UTF-8">
|
|
48
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
49
|
-
<title>${title}</title>
|
|
50
|
-
<style>
|
|
51
|
-
body { font-family: sans-serif; margin: 20px; background-color: #f0f0f0; }
|
|
52
|
-
h1 { color: #333; }
|
|
53
|
-
p { color: #666; }
|
|
54
|
-
.gallery-container {
|
|
55
|
-
display: grid;
|
|
56
|
-
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
|
57
|
-
gap: 20px;
|
|
58
|
-
padding: 20px;
|
|
59
|
-
background-color: #fff;
|
|
60
|
-
border-radius: 8px;
|
|
61
|
-
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
62
|
-
}
|
|
63
|
-
.gallery-item {
|
|
64
|
-
border: 1px solid #ddd;
|
|
65
|
-
border-radius: 4px;
|
|
66
|
-
padding: 10px;
|
|
67
|
-
text-align: center;
|
|
68
|
-
background-color: #f9f9f9;
|
|
69
|
-
}
|
|
70
|
-
.gallery-item img {
|
|
71
|
-
max-width: 100%;
|
|
72
|
-
height: auto;
|
|
73
|
-
display: block;
|
|
74
|
-
margin: 0 auto 10px auto;
|
|
75
|
-
border-radius: 4px;
|
|
76
|
-
}
|
|
77
|
-
</style>
|
|
78
|
-
</head>
|
|
79
|
-
<body>
|
|
80
|
-
<h1>${title}</h1>
|
|
81
|
-
<p>${description}</p>
|
|
82
|
-
<div class="gallery-container">
|
|
83
|
-
${imageHtml}
|
|
84
|
-
</div>
|
|
85
|
-
</body>
|
|
86
|
-
</html>
|
|
87
|
-
`;
|
|
88
|
-
await fs.writeFile(htmlFilePath, htmlContent);
|
|
89
|
-
log(`[ImageGalleryNode] Generated HTML gallery at: ${htmlFilePath}`, this.params.logging);
|
|
90
|
-
// Open the HTML file in the default web browser
|
|
91
|
-
const openBrowserCommand = os.platform() === 'darwin' ? `open "${htmlFilePath}"` :
|
|
92
|
-
os.platform() === 'win32' ? `start "" "${htmlFilePath}"` :
|
|
93
|
-
`xdg-open "${htmlFilePath}"`;
|
|
94
|
-
const shellNode = new ShellCommandNode();
|
|
95
|
-
shellNode.setParams({ command: openBrowserCommand });
|
|
96
|
-
await new AsyncFlow(shellNode).runAsync({});
|
|
97
|
-
log(`[ImageGalleryNode] Opened gallery in browser.`, this.params.logging);
|
|
98
|
-
return { status: 'gallery_displayed', htmlFilePath: htmlFilePath, imageCount: imagePaths.length };
|
|
99
|
-
}
|
|
100
|
-
}
|
package/dist/nodes/index.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export * from "./llm.js";
|
|
2
|
-
export * from "./agent_llm.js";
|
|
3
|
-
export * from "./data_extractor.js";
|
|
4
|
-
export * from "./code_interpreter.js";
|
|
5
|
-
export * from "./hackernews.js";
|
|
6
|
-
export * from "./github.js";
|
|
7
|
-
export * from "./stripe.js";
|
|
8
|
-
export * from "./webscraper.js";
|
|
9
|
-
export * from "./browser_control.js";
|
|
10
|
-
export * from "./system_notification.js";
|
|
11
|
-
export * from "./interactive_input.js";
|
|
12
|
-
export * from "./pdf_processor.js";
|
|
13
|
-
export * from "./gis.js";
|
|
14
|
-
export * from "./display_image.js";
|
|
15
|
-
export * from "./hardware_interaction.js";
|
|
16
|
-
export * from "./webhook.js";
|
|
17
|
-
export * from "./scheduler.js";
|
|
18
|
-
export * from "./image_gallery.js";
|
|
19
|
-
export * from "./speech_synthesis.js";
|
|
20
|
-
export * from "./multimedia_processing.js";
|
|
21
|
-
export * from "./remote_execution.js";
|
|
22
|
-
export * from "./data_validation.js";
|
|
23
|
-
export * from "./spreadsheet.js";
|
|
24
|
-
export * from "./shell.js";
|
|
25
|
-
export * from "./filesystem.js";
|
|
26
|
-
export * from "./user.js";
|
|
27
|
-
export * from "./http.js";
|
|
28
|
-
export * from "./http_server.js";
|
|
29
|
-
export * from "./search.js";
|
|
30
|
-
export * from "./summarize.js";
|
|
31
|
-
export * from "./memory.js";
|
|
32
|
-
export * from "./transform.js";
|
|
33
|
-
export * from "./embedding.js";
|
|
34
|
-
export * from "./semantic_memory.js";
|
|
35
|
-
export * from "./semantic_memory.js";
|
|
36
|
-
export * from "../agent/agent.js";
|
|
37
|
-
export * from "./subflow.js";
|
|
38
|
-
export * from "./iterator.js";
|
|
39
|
-
export * from "./openrouter_llm.js";
|
|
40
|
-
export * from "./database.js";
|
|
41
|
-
export * from "./s3.js";
|
|
42
|
-
export * from "../agent/base_agent.js";
|
|
43
|
-
export * from "../agent/raor_agent.js";
|
|
44
|
-
export * from "../agent/ooda_agent.js";
|
|
45
|
-
export * from "../agent/lpavrl_agent.js";
|
|
46
|
-
export * from "../agent/pema_agent.js";
|
|
47
|
-
export * from "./webview.js";
|
|
48
|
-
export * from "./interactive_webview.js";
|
package/dist/nodes/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export * from './llm.js';
|
|
2
|
-
export * from './agent_llm.js';
|
|
3
|
-
export * from './data_extractor.js';
|
|
4
|
-
export * from './code_interpreter.js';
|
|
5
|
-
export * from './hackernews.js';
|
|
6
|
-
export * from './github.js';
|
|
7
|
-
export * from './stripe.js';
|
|
8
|
-
export * from './webscraper.js';
|
|
9
|
-
export * from './browser_control.js';
|
|
10
|
-
export * from './system_notification.js';
|
|
11
|
-
export * from './interactive_input.js';
|
|
12
|
-
export * from './pdf_processor.js';
|
|
13
|
-
export * from './gis.js';
|
|
14
|
-
export * from './display_image.js';
|
|
15
|
-
export * from './hardware_interaction.js';
|
|
16
|
-
export * from './webhook.js';
|
|
17
|
-
export * from './scheduler.js';
|
|
18
|
-
export * from './image_gallery.js';
|
|
19
|
-
export * from './speech_synthesis.js';
|
|
20
|
-
export * from './multimedia_processing.js';
|
|
21
|
-
export * from './remote_execution.js';
|
|
22
|
-
export * from './data_validation.js';
|
|
23
|
-
export * from './spreadsheet.js';
|
|
24
|
-
export * from './shell.js';
|
|
25
|
-
export * from './filesystem.js';
|
|
26
|
-
export * from './user.js';
|
|
27
|
-
export * from './http.js';
|
|
28
|
-
export * from './http_server.js';
|
|
29
|
-
export * from './search.js';
|
|
30
|
-
export * from './summarize.js';
|
|
31
|
-
export * from './memory.js';
|
|
32
|
-
export * from './transform.js';
|
|
33
|
-
export * from './embedding.js';
|
|
34
|
-
export * from './semantic_memory.js';
|
|
35
|
-
export * from './semantic_memory.js';
|
|
36
|
-
export * from '../agent/agent.js';
|
|
37
|
-
export * from './subflow.js';
|
|
38
|
-
export * from './iterator.js';
|
|
39
|
-
export * from './openrouter_llm.js';
|
|
40
|
-
export * from './database.js';
|
|
41
|
-
export * from './s3.js';
|
|
42
|
-
export * from '../agent/base_agent.js';
|
|
43
|
-
export * from '../agent/raor_agent.js';
|
|
44
|
-
export * from '../agent/ooda_agent.js';
|
|
45
|
-
export * from '../agent/lpavrl_agent.js';
|
|
46
|
-
export * from '../agent/pema_agent.js';
|
|
47
|
-
export * from './webview.js';
|
|
48
|
-
export * from './interactive_webview.js';
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { AsyncNode } from '../qflow.js';
|
|
2
|
-
import { exec } from 'child_process';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import { log } from '../logger.js';
|
|
5
|
-
export class InteractiveInputNode extends AsyncNode {
|
|
6
|
-
constructor(maxRetries = 1, wait = 0) {
|
|
7
|
-
super(maxRetries, wait);
|
|
8
|
-
}
|
|
9
|
-
async execAsync() {
|
|
10
|
-
const { prompt, title = 'QFlow Input', defaultValue = '' } = this.params;
|
|
11
|
-
if (!prompt) {
|
|
12
|
-
throw new Error('InteractiveInputNode requires a `prompt` parameter.');
|
|
13
|
-
}
|
|
14
|
-
let command = '';
|
|
15
|
-
const platform = os.platform();
|
|
16
|
-
switch (platform) {
|
|
17
|
-
case 'linux':
|
|
18
|
-
let linuxCommand = '';
|
|
19
|
-
try {
|
|
20
|
-
await new Promise((res, rej) => exec('which zenity', (e) => e ? rej(e) : res()));
|
|
21
|
-
linuxCommand = `zenity --entry --title="${title}" --text="${prompt}" --entry-text="${defaultValue}"`;
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
try {
|
|
25
|
-
await new Promise((res, rej) => exec('which kdialog', (e) => e ? rej(e) : res()));
|
|
26
|
-
linuxCommand = `kdialog --inputbox "${prompt}" "${defaultValue}" --title "${title}"`;
|
|
27
|
-
}
|
|
28
|
-
catch (e2) {
|
|
29
|
-
throw new Error('No GUI input tool (zenity or kdialog) found on Linux. Please install one or use UserInputNode.');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
command = linuxCommand;
|
|
33
|
-
break;
|
|
34
|
-
case 'darwin': // macOS
|
|
35
|
-
// osascript -e 'set T to text returned of (display dialog "PROMPT" default answer "DEFAULT" with title "TITLE")'
|
|
36
|
-
command = `osascript -e 'set T to text returned of (display dialog "${prompt}" default answer "${defaultValue}" with title "${title}")'`;
|
|
37
|
-
break;
|
|
38
|
-
case 'win32': // Windows
|
|
39
|
-
// PowerShell for input box
|
|
40
|
-
// (New-Object -TypeName Microsoft.VisualBasic.Interaction).InputBox("PROMPT", "TITLE", "DEFAULT")
|
|
41
|
-
command = `powershell -Command "(New-Object -TypeName Microsoft.VisualBasic.Interaction).InputBox('${prompt}', '${title}', '${defaultValue}')"`;
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
throw new Error(`Unsupported platform for InteractiveInputNode: ${platform}`);
|
|
45
|
-
}
|
|
46
|
-
log(`[InteractiveInputNode] Executing: ${command}`, this.params.logging);
|
|
47
|
-
return new Promise((resolve, reject) => {
|
|
48
|
-
exec(command, (error, stdout, stderr) => {
|
|
49
|
-
if (error) {
|
|
50
|
-
// User cancelled the dialog or tool not found
|
|
51
|
-
log(`InteractiveInputNode error: ${error.message}`, this.params.logging, { type: 'error' });
|
|
52
|
-
// Differentiate between user cancellation and actual error
|
|
53
|
-
if (error.code === 1 && platform === 'linux' && error.message.includes('zenity')) {
|
|
54
|
-
// Zenity returns 1 on cancel
|
|
55
|
-
return resolve(null); // Or reject with a specific message
|
|
56
|
-
}
|
|
57
|
-
if (error.message.includes('User canceled')) { // osascript cancel
|
|
58
|
-
return resolve(null);
|
|
59
|
-
}
|
|
60
|
-
return reject(error);
|
|
61
|
-
}
|
|
62
|
-
if (stderr) {
|
|
63
|
-
log(`InteractiveInputNode stderr: ${stderr}`, this.params.logging, { type: 'warn' });
|
|
64
|
-
}
|
|
65
|
-
const userInput = stdout.trim();
|
|
66
|
-
log(`User input received: "${userInput}"`, this.params.logging);
|
|
67
|
-
resolve(userInput);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A node that displays an interactive webview window.
|
|
3
|
-
* It can be used for dialogs, user input, and notifications.
|
|
4
|
-
* The result from the user interaction is passed to the next node.
|
|
5
|
-
*/
|
|
6
|
-
export class InteractiveWebviewNode extends AsyncNode {
|
|
7
|
-
constructor();
|
|
8
|
-
_webviewInstance: Webview | null;
|
|
9
|
-
execAsync(): Promise<any>;
|
|
10
|
-
/**
|
|
11
|
-
* Sends data or executes JavaScript within an open persistent webview.
|
|
12
|
-
* @param {string} script - The JavaScript code to execute in the webview.
|
|
13
|
-
*/
|
|
14
|
-
sendToWebview(script: string): void;
|
|
15
|
-
postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
|
|
16
|
-
generateHTML(mode: any, params: any): string;
|
|
17
|
-
}
|
|
18
|
-
import { AsyncNode } from '../qflow.js';
|
|
19
|
-
import { Webview } from 'webview-bun';
|
|
@@ -1,310 +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 an interactive webview window.
|
|
6
|
-
* It can be used for dialogs, user input, and notifications.
|
|
7
|
-
* The result from the user interaction is passed to the next node.
|
|
8
|
-
*/
|
|
9
|
-
export class InteractiveWebviewNode extends AsyncNode {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
this._webviewInstance = null; // Store webview instance for sendToWebview
|
|
13
|
-
}
|
|
14
|
-
async execAsync() {
|
|
15
|
-
const { mode = 'notification', // 'notification', 'dialog', 'input'
|
|
16
|
-
message = '', options = [], // for dialog mode
|
|
17
|
-
prompt = '', // for input mode
|
|
18
|
-
title = 'Qflow', width = 400, height = 220, theme = 'light', // 'light', 'dark'
|
|
19
|
-
persistent = false, // New parameter for persistent webview
|
|
20
|
-
html = '', // New parameter for custom HTML content
|
|
21
|
-
multilineInput = false, // New parameter for multi-line input
|
|
22
|
-
} = this.params;
|
|
23
|
-
log(`[InteractiveWebviewNode] Creating '${mode}' webview with title: "${title}"`, this.params.logging);
|
|
24
|
-
return new Promise((resolve) => {
|
|
25
|
-
const webview = new Webview(false, {
|
|
26
|
-
width,
|
|
27
|
-
height,
|
|
28
|
-
hint: SizeHint.FIXED,
|
|
29
|
-
});
|
|
30
|
-
webview.title = title;
|
|
31
|
-
this._webviewInstance = webview; // Always store the instance
|
|
32
|
-
webview.bind('qflow', (result) => {
|
|
33
|
-
// This is the crucial part: qflow() from webview resolves execAsync
|
|
34
|
-
// If persistent, we still resolve, but the webview stays open.
|
|
35
|
-
// The flow will then continue.
|
|
36
|
-
resolve(result);
|
|
37
|
-
if (!persistent) {
|
|
38
|
-
webview.destroy();
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
let contentHtml;
|
|
42
|
-
if (mode === 'custom') {
|
|
43
|
-
if (!html) {
|
|
44
|
-
throw new Error('InteractiveWebviewNode in custom mode requires an `html` parameter.');
|
|
45
|
-
}
|
|
46
|
-
contentHtml = html;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
contentHtml = this.generateHTML(mode, { message, options, prompt, title, theme, multilineInput });
|
|
50
|
-
}
|
|
51
|
-
webview.setHTML(contentHtml);
|
|
52
|
-
webview.run(); // This is a blocking call
|
|
53
|
-
// This log will only be reached after webview.run() exits (i.e., webview is closed)
|
|
54
|
-
log(`[InteractiveWebviewNode] Webview window closed.`, this.params.logging);
|
|
55
|
-
// If persistent, and webview.run() exits, it means the user closed it manually.
|
|
56
|
-
// In this case, we should resolve with a 'closed' status if not already resolved.
|
|
57
|
-
// However, the resolve(result) in webview.bind handles the primary interaction.
|
|
58
|
-
// If the webview is closed without qflow() being called, the promise might hang.
|
|
59
|
-
// Let's add a fallback resolve if webview.run() exits without qflow() being called.
|
|
60
|
-
// This is complex with blocking run().
|
|
61
|
-
// For now, assume qflow() is always called before manual close for persistent.
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Sends data or executes JavaScript within an open persistent webview.
|
|
66
|
-
* @param {string} script - The JavaScript code to execute in the webview.
|
|
67
|
-
*/
|
|
68
|
-
sendToWebview(script) {
|
|
69
|
-
if (this._webviewInstance && this._webviewInstance.unsafeHandle) {
|
|
70
|
-
this._webviewInstance.eval(script);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
log(`[InteractiveWebviewNode] Cannot send to webview: no persistent webview instance found.`, this.params.logging, { type: 'warn' });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async postAsync(shared, prepRes, execRes) {
|
|
77
|
-
shared.webviewResult = execRes;
|
|
78
|
-
return 'default';
|
|
79
|
-
}
|
|
80
|
-
generateHTML(mode, params) {
|
|
81
|
-
const { message, options, prompt, title, theme, multilineInput } = params;
|
|
82
|
-
const lightTheme = `
|
|
83
|
-
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
|
|
84
|
-
:root {
|
|
85
|
-
--primary-color: #007bff;
|
|
86
|
-
--bg-color: #f4f6f8;
|
|
87
|
-
--border-color: #d1d9e0;
|
|
88
|
-
--text-color: #212529;
|
|
89
|
-
--title-color: #212529;
|
|
90
|
-
--shadow-color: #007bff40;
|
|
91
|
-
}
|
|
92
|
-
body {
|
|
93
|
-
font-family: 'Orbitron', sans-serif;
|
|
94
|
-
background-color: var(--bg-color);
|
|
95
|
-
color: var(--text-color);
|
|
96
|
-
margin: 0;
|
|
97
|
-
padding: 1px;
|
|
98
|
-
overflow: auto;
|
|
99
|
-
user-select: none;
|
|
100
|
-
}
|
|
101
|
-
.container {
|
|
102
|
-
border: 1px solid var(--border-color);
|
|
103
|
-
height: calc(100vh - 2px);
|
|
104
|
-
width: calc(100vw - 2px);
|
|
105
|
-
display: flex;
|
|
106
|
-
flex-direction: column;
|
|
107
|
-
background-color: #ffffff;
|
|
108
|
-
box-shadow: 0 0 20px #0000001a;
|
|
109
|
-
}
|
|
110
|
-
.title-bar {
|
|
111
|
-
background-color: #e9ecef;
|
|
112
|
-
color: var(--title-color);
|
|
113
|
-
padding: 0.5rem;
|
|
114
|
-
text-align: center;
|
|
115
|
-
font-weight: bold;
|
|
116
|
-
border-bottom: 1px solid var(--border-color);
|
|
117
|
-
text-transform: uppercase;
|
|
118
|
-
letter-spacing: 2px;
|
|
119
|
-
}
|
|
120
|
-
.content {
|
|
121
|
-
flex-grow: 1;
|
|
122
|
-
padding: 1.5rem;
|
|
123
|
-
display: flex;
|
|
124
|
-
flex-direction: column;
|
|
125
|
-
justify-content: center;
|
|
126
|
-
align-items: center;
|
|
127
|
-
text-align: center;
|
|
128
|
-
}
|
|
129
|
-
h1 {
|
|
130
|
-
font-size: 1.2rem;
|
|
131
|
-
margin-bottom: 1rem;
|
|
132
|
-
color: var(--title-color);
|
|
133
|
-
}
|
|
134
|
-
.button-group {
|
|
135
|
-
display: flex;
|
|
136
|
-
flex-wrap: wrap; /* Allow buttons to wrap */
|
|
137
|
-
justify-content: center; /* Center buttons */
|
|
138
|
-
gap: 1rem;
|
|
139
|
-
margin-top: 1rem;
|
|
140
|
-
}
|
|
141
|
-
button {
|
|
142
|
-
background-color: var(--primary-color);
|
|
143
|
-
color: white;
|
|
144
|
-
border: 1px solid var(--primary-color);
|
|
145
|
-
padding: 0.6rem 1.2rem;
|
|
146
|
-
font-family: 'Orbitron', sans-serif;
|
|
147
|
-
font-size: 0.9rem;
|
|
148
|
-
font-weight: bold;
|
|
149
|
-
cursor: pointer;
|
|
150
|
-
transition: all 0.3s ease;
|
|
151
|
-
text-transform: uppercase;
|
|
152
|
-
}
|
|
153
|
-
button:hover {
|
|
154
|
-
background-color: #0056b3;
|
|
155
|
-
border-color: #0056b3;
|
|
156
|
-
}
|
|
157
|
-
input, textarea { /* Apply styles to textarea as well */
|
|
158
|
-
background-color: #ffffff;
|
|
159
|
-
border: 1px solid var(--border-color);
|
|
160
|
-
color: var(--text-color);
|
|
161
|
-
padding: 0.6rem;
|
|
162
|
-
width: 80%;
|
|
163
|
-
font-family: 'Orbitron', sans-serif;
|
|
164
|
-
font-size: 1rem;
|
|
165
|
-
margin-bottom: 1rem;
|
|
166
|
-
}
|
|
167
|
-
input:focus, textarea:focus {
|
|
168
|
-
outline: none;
|
|
169
|
-
border-color: var(--primary-color);
|
|
170
|
-
box-shadow: 0 0 8px var(--shadow-color);
|
|
171
|
-
}
|
|
172
|
-
`;
|
|
173
|
-
const darkTheme = `
|
|
174
|
-
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
|
|
175
|
-
:root {
|
|
176
|
-
--primary-color: #00ffff;
|
|
177
|
-
--bg-color: #0a0a1a;
|
|
178
|
-
--border-color: #00ffff80;
|
|
179
|
-
--text-color: #e0e0e0;
|
|
180
|
-
--title-color: #ffffff;
|
|
181
|
-
--shadow-color: #00ffff40;
|
|
182
|
-
}
|
|
183
|
-
body {
|
|
184
|
-
font-family: 'Orbitron', sans-serif;
|
|
185
|
-
background-color: var(--bg-color);
|
|
186
|
-
color: var(--text-color);
|
|
187
|
-
margin: 0;
|
|
188
|
-
padding: 1px;
|
|
189
|
-
overflow: auto; /* Allow scrolling */
|
|
190
|
-
user-select: none;
|
|
191
|
-
}
|
|
192
|
-
.container {
|
|
193
|
-
border: 1px solid var(--border-color);
|
|
194
|
-
height: calc(100vh - 2px);
|
|
195
|
-
width: calc(100vw - 2px);
|
|
196
|
-
display: flex;
|
|
197
|
-
flex-direction: column;
|
|
198
|
-
background: radial-gradient(circle, rgba(10, 10, 26, 0.95) 0%, rgba(10, 10, 26, 0.85) 100%);
|
|
199
|
-
box-shadow: 0 0 20px var(--shadow-color);
|
|
200
|
-
}
|
|
201
|
-
.title-bar {
|
|
202
|
-
background-color: #00000030;
|
|
203
|
-
color: var(--title-color);
|
|
204
|
-
padding: 0.5rem;
|
|
205
|
-
text-align: center;
|
|
206
|
-
font-weight: bold;
|
|
207
|
-
border-bottom: 1px solid var(--border-color);
|
|
208
|
-
text-transform: uppercase;
|
|
209
|
-
letter-spacing: 2px;
|
|
210
|
-
text-shadow: 0 0 5px var(--primary-color);
|
|
211
|
-
}
|
|
212
|
-
.content {
|
|
213
|
-
flex-grow: 1;
|
|
214
|
-
padding: 1.5rem;
|
|
215
|
-
display: flex;
|
|
216
|
-
flex-direction: column;
|
|
217
|
-
justify-content: center;
|
|
218
|
-
align-items: center;
|
|
219
|
-
text-align: center;
|
|
220
|
-
}
|
|
221
|
-
h1 {
|
|
222
|
-
font-size: 1.2rem;
|
|
223
|
-
margin-bottom: 1rem;
|
|
224
|
-
color: var(--title-color);
|
|
225
|
-
text-shadow: 0 0 8px var(--shadow-color);
|
|
226
|
-
}
|
|
227
|
-
.button-group {
|
|
228
|
-
display: flex;
|
|
229
|
-
flex-wrap: wrap; /* Allow buttons to wrap */
|
|
230
|
-
justify-content: center; /* Center buttons */
|
|
231
|
-
gap: 1rem;
|
|
232
|
-
margin-top: 1rem;
|
|
233
|
-
}
|
|
234
|
-
button {
|
|
235
|
-
background-color: transparent;
|
|
236
|
-
color: var(--primary-color);
|
|
237
|
-
border: 1px solid var(--primary-color);
|
|
238
|
-
padding: 0.6rem 1.2rem;
|
|
239
|
-
font-family: 'Orbitron', sans-serif;
|
|
240
|
-
font-size: 0.9rem;
|
|
241
|
-
font-weight: bold;
|
|
242
|
-
cursor: pointer;
|
|
243
|
-
transition: all 0.3s ease;
|
|
244
|
-
text-transform: uppercase;
|
|
245
|
-
box-shadow: 0 0 10px var(--shadow-color) inset;
|
|
246
|
-
}
|
|
247
|
-
button:hover {
|
|
248
|
-
background-color: var(--primary-color);
|
|
249
|
-
color: var(--bg-color);
|
|
250
|
-
box-shadow: 0 0 20px var(--shadow-color);
|
|
251
|
-
}
|
|
252
|
-
input, textarea { /* Apply styles to textarea as well */
|
|
253
|
-
background-color: #00000030;
|
|
254
|
-
border: 1px solid var(--border-color);
|
|
255
|
-
color: var(--text-color);
|
|
256
|
-
padding: 0.6rem;
|
|
257
|
-
width: 80%;
|
|
258
|
-
font-family: 'Orbitron', sans-serif;
|
|
259
|
-
font-size: 1rem;
|
|
260
|
-
margin-bottom: 1rem;
|
|
261
|
-
}
|
|
262
|
-
input:focus, textarea:focus {
|
|
263
|
-
outline: none;
|
|
264
|
-
border-color: var(--primary-color);
|
|
265
|
-
box-shadow: 0 0 10px var(--shadow-color);
|
|
266
|
-
}
|
|
267
|
-
`;
|
|
268
|
-
let contentHtml = '';
|
|
269
|
-
switch (mode) {
|
|
270
|
-
case 'dialog':
|
|
271
|
-
contentHtml = `
|
|
272
|
-
<h1>${message}</h1>
|
|
273
|
-
<div class="button-group">
|
|
274
|
-
${options.map(option => `<button onclick="qflow('${option}')">${option}</button>`).join('')}
|
|
275
|
-
</div>
|
|
276
|
-
`;
|
|
277
|
-
break;
|
|
278
|
-
case 'input':
|
|
279
|
-
const inputElement = multilineInput ?
|
|
280
|
-
`<textarea id="userInput" rows="10" style="width: 80%;"></textarea>` :
|
|
281
|
-
`<input type="text" id="userInput" onkeydown="if(event.key==='Enter') document.getElementById('submitBtn').click()"/>`;
|
|
282
|
-
contentHtml = `
|
|
283
|
-
<h1>${prompt}</h1>
|
|
284
|
-
${inputElement}
|
|
285
|
-
<button id="submitBtn" onclick="qflow(document.getElementById('userInput').value)">Submit</button>
|
|
286
|
-
`;
|
|
287
|
-
break;
|
|
288
|
-
case 'notification':
|
|
289
|
-
default:
|
|
290
|
-
contentHtml = `
|
|
291
|
-
<h1>${message}</h1>
|
|
292
|
-
<div class="button-group">
|
|
293
|
-
<button onclick="qflow('closed')">${theme === 'dark' ? 'Acknowledge' : 'Close'}</button>
|
|
294
|
-
</div>
|
|
295
|
-
`;
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
const container = `<div class="container"><div class="title-bar">${title}</div><div class="content">${contentHtml}</div></div>`;
|
|
299
|
-
return `
|
|
300
|
-
<html>
|
|
301
|
-
<head>
|
|
302
|
-
<style>${theme === 'dark' ? darkTheme : lightTheme}</style>
|
|
303
|
-
</head>
|
|
304
|
-
<body>
|
|
305
|
-
${container}
|
|
306
|
-
</body>
|
|
307
|
-
</html>
|
|
308
|
-
`;
|
|
309
|
-
}
|
|
310
|
-
}
|
package/dist/nodes/iterator.d.ts
DELETED
package/dist/nodes/iterator.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AsyncNode, AsyncFlow } from '../qflow.js';
|
|
2
|
-
export class IteratorNode extends AsyncNode {
|
|
3
|
-
async execAsync() {
|
|
4
|
-
const { items, flow } = this.params;
|
|
5
|
-
if (!items || !Array.isArray(items)) {
|
|
6
|
-
throw new Error('IteratorNode requires an `items` parameter of type Array.');
|
|
7
|
-
}
|
|
8
|
-
if (!flow || !(flow instanceof AsyncFlow)) {
|
|
9
|
-
throw new Error('IteratorNode requires a `flow` parameter of type AsyncFlow.');
|
|
10
|
-
}
|
|
11
|
-
const results = [];
|
|
12
|
-
for (const item of items) {
|
|
13
|
-
const subFlowShared = { item, params: this.params };
|
|
14
|
-
const result = await flow.runAsync(subFlowShared);
|
|
15
|
-
results.push(result);
|
|
16
|
-
}
|
|
17
|
-
return results;
|
|
18
|
-
}
|
|
19
|
-
async postAsync(shared, prepRes, execRes) {
|
|
20
|
-
shared.iteratorResult = execRes;
|
|
21
|
-
return 'default';
|
|
22
|
-
}
|
|
23
|
-
}
|
package/dist/nodes/llm.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export class DeepSeekLLMNode extends AsyncNode {
|
|
2
|
-
preparePrompt(shared: any): void;
|
|
3
|
-
execAsync(prepRes: any, shared: any): Promise<any>;
|
|
4
|
-
}
|
|
5
|
-
export class OpenAILLMNode extends AsyncNode {
|
|
6
|
-
execAsync(): Promise<any>;
|
|
7
|
-
}
|
|
8
|
-
export class GeminiLLMNode extends AsyncNode {
|
|
9
|
-
execAsync(): Promise<any>;
|
|
10
|
-
}
|
|
11
|
-
export class OllamaLLMNode extends AsyncNode {
|
|
12
|
-
preparePrompt(shared: any): void;
|
|
13
|
-
execAsync(prepRes: any, shared: any): Promise<any>;
|
|
14
|
-
}
|
|
15
|
-
export class HuggingFaceLLMNode extends AsyncNode {
|
|
16
|
-
execAsync(): Promise<any>;
|
|
17
|
-
}
|
|
18
|
-
import { AsyncNode } from '../qflow.js';
|