@fractal-solutions/qflow 1.0.59 → 1.0.61
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 +77 -1
- package/dist/qflow.config.d.ts +5 -0
- package/dist/qflow.config.js +16 -0
- package/dist/src/agent/agent.d.ts +23 -0
- package/dist/src/agent/agent.js +365 -0
- package/dist/src/agent/base_agent.d.ts +21 -0
- package/dist/src/agent/base_agent.js +206 -0
- package/dist/src/agent/logger.d.ts +9 -0
- package/dist/src/agent/logger.js +45 -0
- package/dist/src/agent/lpavrl_agent.d.ts +5 -0
- package/dist/src/agent/lpavrl_agent.js +178 -0
- package/dist/src/agent/ooda_agent.d.ts +5 -0
- package/dist/src/agent/ooda_agent.js +167 -0
- package/dist/src/agent/pema_agent.d.ts +5 -0
- package/dist/src/agent/pema_agent.js +171 -0
- package/dist/src/agent/raor_agent.d.ts +5 -0
- package/dist/src/agent/raor_agent.js +164 -0
- package/dist/src/agent/tools.d.ts +1 -0
- package/dist/src/agent/tools.js +148 -0
- package/dist/src/logger.d.ts +9 -0
- package/dist/src/logger.js +107 -0
- package/dist/src/nodes/agent_llm.d.ts +31 -0
- package/dist/src/nodes/agent_llm.js +302 -0
- package/dist/src/nodes/browser_control.d.ts +35 -0
- package/dist/src/nodes/browser_control.js +106 -0
- package/dist/src/nodes/code_interpreter.d.ts +38 -0
- package/dist/src/nodes/code_interpreter.js +150 -0
- package/dist/src/nodes/data_extractor.d.ts +40 -0
- package/dist/src/nodes/data_extractor.js +118 -0
- package/dist/src/nodes/data_validation.d.ts +36 -0
- package/dist/src/nodes/data_validation.js +77 -0
- package/dist/src/nodes/database.d.ts +50 -0
- package/dist/src/nodes/database.js +135 -0
- package/dist/src/nodes/display_image.d.ts +18 -0
- package/dist/src/nodes/display_image.js +63 -0
- package/dist/src/nodes/embedding.d.ts +29 -0
- package/dist/src/nodes/embedding.js +69 -0
- package/dist/src/nodes/filesystem.d.ts +105 -0
- package/dist/src/nodes/filesystem.js +160 -0
- package/dist/src/nodes/gis.d.ts +62 -0
- package/dist/src/nodes/gis.js +133 -0
- package/dist/src/nodes/git.d.ts +46 -0
- package/dist/src/nodes/git.js +99 -0
- package/dist/src/nodes/github.d.ts +83 -0
- package/dist/src/nodes/github.js +135 -0
- package/dist/src/nodes/hackernews.d.ts +47 -0
- package/dist/src/nodes/hackernews.js +79 -0
- package/dist/src/nodes/hardware_interaction.d.ts +39 -0
- package/dist/src/nodes/hardware_interaction.js +131 -0
- package/dist/src/nodes/http.d.ts +77 -0
- package/dist/src/nodes/http.js +120 -0
- package/dist/src/nodes/http_server.d.ts +54 -0
- package/dist/src/nodes/http_server.js +223 -0
- package/dist/src/nodes/image_gallery.d.ts +37 -0
- package/dist/src/nodes/image_gallery.js +129 -0
- package/dist/src/nodes/index.d.ts +48 -0
- package/dist/src/nodes/index.js +48 -0
- package/dist/src/nodes/interactive_input.d.ts +26 -0
- package/dist/src/nodes/interactive_input.js +95 -0
- package/dist/src/nodes/interactive_webview.d.ts +78 -0
- package/dist/src/nodes/interactive_webview.js +369 -0
- package/dist/src/nodes/iterator.d.ts +23 -0
- package/dist/src/nodes/iterator.js +43 -0
- package/dist/src/nodes/llm.d.ts +160 -0
- package/dist/src/nodes/llm.js +367 -0
- package/dist/src/nodes/memory.d.ts +43 -0
- package/dist/src/nodes/memory.js +90 -0
- package/dist/src/nodes/multimedia_processing.d.ts +57 -0
- package/dist/src/nodes/multimedia_processing.js +129 -0
- package/dist/src/nodes/openrouter_llm.d.ts +38 -0
- package/dist/src/nodes/openrouter_llm.js +156 -0
- package/dist/src/nodes/pdf_processor.d.ts +43 -0
- package/dist/src/nodes/pdf_processor.js +112 -0
- package/dist/src/nodes/remote_execution.d.ts +51 -0
- package/dist/src/nodes/remote_execution.js +132 -0
- package/dist/src/nodes/s3.d.ts +73 -0
- package/dist/src/nodes/s3.js +107 -0
- package/dist/src/nodes/scheduler.d.ts +51 -0
- package/dist/src/nodes/scheduler.js +131 -0
- package/dist/src/nodes/search.d.ts +61 -0
- package/dist/src/nodes/search.js +118 -0
- package/dist/src/nodes/semantic_memory.d.ts +64 -0
- package/dist/src/nodes/semantic_memory.js +160 -0
- package/dist/src/nodes/shell.d.ts +25 -0
- package/dist/src/nodes/shell.js +45 -0
- package/dist/src/nodes/speech_synthesis.d.ts +72 -0
- package/dist/src/nodes/speech_synthesis.js +171 -0
- package/dist/src/nodes/spreadsheet.d.ts +61 -0
- package/dist/src/nodes/spreadsheet.js +294 -0
- package/dist/src/nodes/stripe.d.ts +67 -0
- package/dist/src/nodes/stripe.js +117 -0
- package/dist/src/nodes/subflow.d.ts +23 -0
- package/dist/src/nodes/subflow.js +36 -0
- package/dist/src/nodes/summarize.d.ts +26 -0
- package/dist/src/nodes/summarize.js +51 -0
- package/dist/src/nodes/system_notification.d.ts +26 -0
- package/dist/src/nodes/system_notification.js +74 -0
- package/dist/src/nodes/transform.d.ts +23 -0
- package/dist/src/nodes/transform.js +52 -0
- package/dist/src/nodes/user.d.ts +25 -0
- package/dist/src/nodes/user.js +48 -0
- package/dist/src/nodes/webhook.d.ts +49 -0
- package/dist/src/nodes/webhook.js +161 -0
- package/dist/src/nodes/webscraper.d.ts +25 -0
- package/dist/src/nodes/webscraper.js +49 -0
- package/dist/src/nodes/websockets.d.ts +27 -0
- package/dist/src/nodes/websockets.js +98 -0
- package/dist/src/nodes/webview.d.ts +38 -0
- package/dist/src/nodes/webview.js +55 -0
- package/dist/src/qflow.d.ts +69 -0
- package/dist/src/qflow.js +320 -0
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
static getToolDefinition(): {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
parameters: {
|
|
11
|
+
type: string;
|
|
12
|
+
properties: {
|
|
13
|
+
mode: {
|
|
14
|
+
type: string;
|
|
15
|
+
enum: string[];
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
message: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
options: {
|
|
23
|
+
type: string;
|
|
24
|
+
items: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
prompt: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
title: {
|
|
34
|
+
type: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
width: {
|
|
38
|
+
type: string;
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
height: {
|
|
42
|
+
type: string;
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
theme: {
|
|
46
|
+
type: string;
|
|
47
|
+
enum: string[];
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
persistent: {
|
|
51
|
+
type: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
html: {
|
|
55
|
+
type: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
multilineInput: {
|
|
59
|
+
type: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
required: string[];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
constructor();
|
|
67
|
+
_webviewInstance: Webview | null;
|
|
68
|
+
execAsync(): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Sends data or executes JavaScript within an open persistent webview.
|
|
71
|
+
* @param {string} script - The JavaScript code to execute in the webview.
|
|
72
|
+
*/
|
|
73
|
+
sendToWebview(script: string): void;
|
|
74
|
+
postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
|
|
75
|
+
generateHTML(mode: any, params: any): string;
|
|
76
|
+
}
|
|
77
|
+
import { AsyncNode } from '../qflow.js';
|
|
78
|
+
import { Webview } from 'webview-bun';
|
|
@@ -0,0 +1,369 @@
|
|
|
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
|
+
static getToolDefinition() {
|
|
11
|
+
return {
|
|
12
|
+
name: "interactive_webview",
|
|
13
|
+
description: "Displays an interactive webview window for notifications, dialogs, or user input.",
|
|
14
|
+
parameters: {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
mode: {
|
|
18
|
+
type: "string",
|
|
19
|
+
enum: ["notification", "dialog", "input", "custom"],
|
|
20
|
+
description: "The mode of the webview: 'notification' (message with close button), 'dialog' (message with options), 'input' (message with text input), or 'custom' (full HTML control)."
|
|
21
|
+
},
|
|
22
|
+
message: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Required for 'notification' and 'dialog' modes. The message to display."
|
|
25
|
+
},
|
|
26
|
+
options: {
|
|
27
|
+
type: "array",
|
|
28
|
+
items: { type: "string" },
|
|
29
|
+
description: "Required for 'dialog' mode. An array of strings for the buttons."
|
|
30
|
+
},
|
|
31
|
+
prompt: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "Required for 'input' mode. The prompt message for the user."
|
|
34
|
+
},
|
|
35
|
+
title: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "Optional. The title of the webview window. Defaults to 'Qflow'."
|
|
38
|
+
},
|
|
39
|
+
width: {
|
|
40
|
+
type: "number",
|
|
41
|
+
description: "Optional. The width of the webview window. Defaults to 400."
|
|
42
|
+
},
|
|
43
|
+
height: {
|
|
44
|
+
type: "number",
|
|
45
|
+
description: "Optional. The height of the webview window. Defaults to 220."
|
|
46
|
+
},
|
|
47
|
+
theme: {
|
|
48
|
+
type: "string",
|
|
49
|
+
enum: ["light", "dark"],
|
|
50
|
+
description: "Optional. The theme for the webview. Defaults to 'light'."
|
|
51
|
+
},
|
|
52
|
+
persistent: {
|
|
53
|
+
type: "boolean",
|
|
54
|
+
description: "Optional. If true, the webview remains open after interaction. Defaults to false."
|
|
55
|
+
},
|
|
56
|
+
html: {
|
|
57
|
+
type: "string",
|
|
58
|
+
description: "Required for 'custom' mode. The full HTML content to display in the webview."
|
|
59
|
+
},
|
|
60
|
+
multilineInput: {
|
|
61
|
+
type: "boolean",
|
|
62
|
+
description: "Optional. If true, the input field in 'input' mode will be a multiline textarea. Defaults to false."
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
required: ["mode"]
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
constructor() {
|
|
70
|
+
super();
|
|
71
|
+
this._webviewInstance = null; // Store webview instance for sendToWebview
|
|
72
|
+
}
|
|
73
|
+
async execAsync() {
|
|
74
|
+
const { mode = 'notification', // 'notification', 'dialog', 'input'
|
|
75
|
+
message = '', options = [], // for dialog mode
|
|
76
|
+
prompt = '', // for input mode
|
|
77
|
+
title = 'Qflow', width = 400, height = 220, theme = 'light', // 'light', 'dark'
|
|
78
|
+
persistent = false, // New parameter for persistent webview
|
|
79
|
+
html = '', // New parameter for custom HTML content
|
|
80
|
+
multilineInput = false, // New parameter for multi-line input
|
|
81
|
+
} = this.params;
|
|
82
|
+
log(`[InteractiveWebviewNode] Creating '${mode}' webview with title: "${title}"`, this.params.logging);
|
|
83
|
+
return new Promise((resolve) => {
|
|
84
|
+
const webview = new Webview(false, {
|
|
85
|
+
width,
|
|
86
|
+
height,
|
|
87
|
+
hint: SizeHint.FIXED,
|
|
88
|
+
});
|
|
89
|
+
webview.title = title;
|
|
90
|
+
this._webviewInstance = webview; // Always store the instance
|
|
91
|
+
webview.bind('qflow', (result) => {
|
|
92
|
+
// This is the crucial part: qflow() from webview resolves execAsync
|
|
93
|
+
// If persistent, we still resolve, but the webview stays open.
|
|
94
|
+
// The flow will then continue.
|
|
95
|
+
resolve(result);
|
|
96
|
+
if (!persistent) {
|
|
97
|
+
webview.destroy();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
let contentHtml;
|
|
101
|
+
if (mode === 'custom') {
|
|
102
|
+
if (!html) {
|
|
103
|
+
throw new Error('InteractiveWebviewNode in custom mode requires an `html` parameter.');
|
|
104
|
+
}
|
|
105
|
+
contentHtml = html;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
contentHtml = this.generateHTML(mode, { message, options, prompt, title, theme, multilineInput });
|
|
109
|
+
}
|
|
110
|
+
webview.setHTML(contentHtml);
|
|
111
|
+
webview.run(); // This is a blocking call
|
|
112
|
+
// This log will only be reached after webview.run() exits (i.e., webview is closed)
|
|
113
|
+
log(`[InteractiveWebviewNode] Webview window closed.`, this.params.logging);
|
|
114
|
+
// If persistent, and webview.run() exits, it means the user closed it manually.
|
|
115
|
+
// In this case, we should resolve with a 'closed' status if not already resolved.
|
|
116
|
+
// However, the resolve(result) in webview.bind handles the primary interaction.
|
|
117
|
+
// If the webview is closed without qflow() being called, the promise might hang.
|
|
118
|
+
// Let's add a fallback resolve if webview.run() exits without qflow() being called.
|
|
119
|
+
// This is complex with blocking run().
|
|
120
|
+
// For now, assume qflow() is always called before manual close for persistent.
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Sends data or executes JavaScript within an open persistent webview.
|
|
125
|
+
* @param {string} script - The JavaScript code to execute in the webview.
|
|
126
|
+
*/
|
|
127
|
+
sendToWebview(script) {
|
|
128
|
+
if (this._webviewInstance && this._webviewInstance.unsafeHandle) {
|
|
129
|
+
this._webviewInstance.eval(script);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
log(`[InteractiveWebviewNode] Cannot send to webview: no persistent webview instance found.`, this.params.logging, { type: 'warn' });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async postAsync(shared, prepRes, execRes) {
|
|
136
|
+
shared.webviewResult = execRes;
|
|
137
|
+
return 'default';
|
|
138
|
+
}
|
|
139
|
+
generateHTML(mode, params) {
|
|
140
|
+
const { message, options, prompt, title, theme, multilineInput } = params;
|
|
141
|
+
const lightTheme = `
|
|
142
|
+
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
|
|
143
|
+
:root {
|
|
144
|
+
--primary-color: #007bff;
|
|
145
|
+
--bg-color: #f4f6f8;
|
|
146
|
+
--border-color: #d1d9e0;
|
|
147
|
+
--text-color: #212529;
|
|
148
|
+
--title-color: #212529;
|
|
149
|
+
--shadow-color: #007bff40;
|
|
150
|
+
}
|
|
151
|
+
body {
|
|
152
|
+
font-family: 'Orbitron', sans-serif;
|
|
153
|
+
background-color: var(--bg-color);
|
|
154
|
+
color: var(--text-color);
|
|
155
|
+
margin: 0;
|
|
156
|
+
padding: 1px;
|
|
157
|
+
overflow: auto;
|
|
158
|
+
user-select: none;
|
|
159
|
+
}
|
|
160
|
+
.container {
|
|
161
|
+
border: 1px solid var(--border-color);
|
|
162
|
+
height: calc(100vh - 2px);
|
|
163
|
+
width: calc(100vw - 2px);
|
|
164
|
+
display: flex;
|
|
165
|
+
flex-direction: column;
|
|
166
|
+
background-color: #ffffff;
|
|
167
|
+
box-shadow: 0 0 20px #0000001a;
|
|
168
|
+
}
|
|
169
|
+
.title-bar {
|
|
170
|
+
background-color: #e9ecef;
|
|
171
|
+
color: var(--title-color);
|
|
172
|
+
padding: 0.5rem;
|
|
173
|
+
text-align: center;
|
|
174
|
+
font-weight: bold;
|
|
175
|
+
border-bottom: 1px solid var(--border-color);
|
|
176
|
+
text-transform: uppercase;
|
|
177
|
+
letter-spacing: 2px;
|
|
178
|
+
}
|
|
179
|
+
.content {
|
|
180
|
+
flex-grow: 1;
|
|
181
|
+
padding: 1.5rem;
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
justify-content: center;
|
|
185
|
+
align-items: center;
|
|
186
|
+
text-align: center;
|
|
187
|
+
}
|
|
188
|
+
h1 {
|
|
189
|
+
font-size: 1.2rem;
|
|
190
|
+
margin-bottom: 1rem;
|
|
191
|
+
color: var(--title-color);
|
|
192
|
+
}
|
|
193
|
+
.button-group {
|
|
194
|
+
display: flex;
|
|
195
|
+
flex-wrap: wrap; /* Allow buttons to wrap */
|
|
196
|
+
justify-content: center; /* Center buttons */
|
|
197
|
+
gap: 1rem;
|
|
198
|
+
margin-top: 1rem;
|
|
199
|
+
}
|
|
200
|
+
button {
|
|
201
|
+
background-color: var(--primary-color);
|
|
202
|
+
color: white;
|
|
203
|
+
border: 1px solid var(--primary-color);
|
|
204
|
+
padding: 0.6rem 1.2rem;
|
|
205
|
+
font-family: 'Orbitron', sans-serif;
|
|
206
|
+
font-size: 0.9rem;
|
|
207
|
+
font-weight: bold;
|
|
208
|
+
cursor: pointer;
|
|
209
|
+
transition: all 0.3s ease;
|
|
210
|
+
text-transform: uppercase;
|
|
211
|
+
}
|
|
212
|
+
button:hover {
|
|
213
|
+
background-color: #0056b3;
|
|
214
|
+
border-color: #0056b3;
|
|
215
|
+
}
|
|
216
|
+
input, textarea { /* Apply styles to textarea as well */
|
|
217
|
+
background-color: #ffffff;
|
|
218
|
+
border: 1px solid var(--border-color);
|
|
219
|
+
color: var(--text-color);
|
|
220
|
+
padding: 0.6rem;
|
|
221
|
+
width: 80%;
|
|
222
|
+
font-family: 'Orbitron', sans-serif;
|
|
223
|
+
font-size: 1rem;
|
|
224
|
+
margin-bottom: 1rem;
|
|
225
|
+
}
|
|
226
|
+
input:focus, textarea:focus {
|
|
227
|
+
outline: none;
|
|
228
|
+
border-color: var(--primary-color);
|
|
229
|
+
box-shadow: 0 0 8px var(--shadow-color);
|
|
230
|
+
}
|
|
231
|
+
`;
|
|
232
|
+
const darkTheme = `
|
|
233
|
+
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
|
|
234
|
+
:root {
|
|
235
|
+
--primary-color: #00ffff;
|
|
236
|
+
--bg-color: #0a0a1a;
|
|
237
|
+
--border-color: #00ffff80;
|
|
238
|
+
--text-color: #e0e0e0;
|
|
239
|
+
--title-color: #ffffff;
|
|
240
|
+
--shadow-color: #00ffff40;
|
|
241
|
+
}
|
|
242
|
+
body {
|
|
243
|
+
font-family: 'Orbitron', sans-serif;
|
|
244
|
+
background-color: var(--bg-color);
|
|
245
|
+
color: var(--text-color);
|
|
246
|
+
margin: 0;
|
|
247
|
+
padding: 1px;
|
|
248
|
+
overflow: auto; /* Allow scrolling */
|
|
249
|
+
user-select: none;
|
|
250
|
+
}
|
|
251
|
+
.container {
|
|
252
|
+
border: 1px solid var(--border-color);
|
|
253
|
+
height: calc(100vh - 2px);
|
|
254
|
+
width: calc(100vw - 2px);
|
|
255
|
+
display: flex;
|
|
256
|
+
flex-direction: column;
|
|
257
|
+
background: radial-gradient(circle, rgba(10, 10, 26, 0.95) 0%, rgba(10, 10, 26, 0.85) 100%);
|
|
258
|
+
box-shadow: 0 0 20px var(--shadow-color);
|
|
259
|
+
}
|
|
260
|
+
.title-bar {
|
|
261
|
+
background-color: #00000030;
|
|
262
|
+
color: var(--title-color);
|
|
263
|
+
padding: 0.5rem;
|
|
264
|
+
text-align: center;
|
|
265
|
+
font-weight: bold;
|
|
266
|
+
border-bottom: 1px solid var(--border-color);
|
|
267
|
+
text-transform: uppercase;
|
|
268
|
+
letter-spacing: 2px;
|
|
269
|
+
text-shadow: 0 0 5px var(--primary-color);
|
|
270
|
+
}
|
|
271
|
+
.content {
|
|
272
|
+
flex-grow: 1;
|
|
273
|
+
padding: 1.5rem;
|
|
274
|
+
display: flex;
|
|
275
|
+
flex-direction: column;
|
|
276
|
+
justify-content: center;
|
|
277
|
+
align-items: center;
|
|
278
|
+
text-align: center;
|
|
279
|
+
}
|
|
280
|
+
h1 {
|
|
281
|
+
font-size: 1.2rem;
|
|
282
|
+
margin-bottom: 1rem;
|
|
283
|
+
color: var(--title-color);
|
|
284
|
+
text-shadow: 0 0 8px var(--shadow-color);
|
|
285
|
+
}
|
|
286
|
+
.button-group {
|
|
287
|
+
display: flex;
|
|
288
|
+
flex-wrap: wrap; /* Allow buttons to wrap */
|
|
289
|
+
justify-content: center; /* Center buttons */
|
|
290
|
+
gap: 1rem;
|
|
291
|
+
margin-top: 1rem;
|
|
292
|
+
}
|
|
293
|
+
button {
|
|
294
|
+
background-color: transparent;
|
|
295
|
+
color: var(--primary-color);
|
|
296
|
+
border: 1px solid var(--primary-color);
|
|
297
|
+
padding: 0.6rem 1.2rem;
|
|
298
|
+
font-family: 'Orbitron', sans-serif;
|
|
299
|
+
font-size: 0.9rem;
|
|
300
|
+
font-weight: bold;
|
|
301
|
+
cursor: pointer;
|
|
302
|
+
transition: all 0.3s ease;
|
|
303
|
+
text-transform: uppercase;
|
|
304
|
+
box-shadow: 0 0 10px var(--shadow-color) inset;
|
|
305
|
+
}
|
|
306
|
+
button:hover {
|
|
307
|
+
background-color: var(--primary-color);
|
|
308
|
+
color: var(--bg-color);
|
|
309
|
+
box-shadow: 0 0 20px var(--shadow-color);
|
|
310
|
+
}
|
|
311
|
+
input, textarea { /* Apply styles to textarea as well */
|
|
312
|
+
background-color: #00000030;
|
|
313
|
+
border: 1px solid var(--border-color);
|
|
314
|
+
color: var(--text-color);
|
|
315
|
+
padding: 0.6rem;
|
|
316
|
+
width: 80%;
|
|
317
|
+
font-family: 'Orbitron', sans-serif;
|
|
318
|
+
font-size: 1rem;
|
|
319
|
+
margin-bottom: 1rem;
|
|
320
|
+
}
|
|
321
|
+
input:focus, textarea:focus {
|
|
322
|
+
outline: none;
|
|
323
|
+
border-color: var(--primary-color);
|
|
324
|
+
box-shadow: 0 0 10px var(--shadow-color);
|
|
325
|
+
}
|
|
326
|
+
`;
|
|
327
|
+
let contentHtml = '';
|
|
328
|
+
switch (mode) {
|
|
329
|
+
case 'dialog':
|
|
330
|
+
contentHtml = `
|
|
331
|
+
<h1>${message}</h1>
|
|
332
|
+
<div class="button-group">
|
|
333
|
+
${options.map(option => `<button onclick="qflow('${option}')">${option}</button>`).join('')}
|
|
334
|
+
</div>
|
|
335
|
+
`;
|
|
336
|
+
break;
|
|
337
|
+
case 'input':
|
|
338
|
+
const inputElement = multilineInput ?
|
|
339
|
+
`<textarea id="userInput" rows="10" style="width: 80%;"></textarea>` :
|
|
340
|
+
`<input type="text" id="userInput" onkeydown="if(event.key==='Enter') document.getElementById('submitBtn').click()"/>`;
|
|
341
|
+
contentHtml = `
|
|
342
|
+
<h1>${prompt}</h1>
|
|
343
|
+
${inputElement}
|
|
344
|
+
<button id="submitBtn" onclick="qflow(document.getElementById('userInput').value)">Submit</button>
|
|
345
|
+
`;
|
|
346
|
+
break;
|
|
347
|
+
case 'notification':
|
|
348
|
+
default:
|
|
349
|
+
contentHtml = `
|
|
350
|
+
<h1>${message}</h1>
|
|
351
|
+
<div class="button-group">
|
|
352
|
+
<button onclick="qflow('closed')">${theme === 'dark' ? 'Acknowledge' : 'Close'}</button>
|
|
353
|
+
</div>
|
|
354
|
+
`;
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
const container = `<div class="container"><div class="title-bar">${title}</div><div class="content">${contentHtml}</div></div>`;
|
|
358
|
+
return `
|
|
359
|
+
<html>
|
|
360
|
+
<head>
|
|
361
|
+
<style>${theme === 'dark' ? darkTheme : lightTheme}</style>
|
|
362
|
+
</head>
|
|
363
|
+
<body>
|
|
364
|
+
${container}
|
|
365
|
+
</body>
|
|
366
|
+
</html>
|
|
367
|
+
`;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class IteratorNode extends AsyncNode {
|
|
2
|
+
static getToolDefinition(): {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
items: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
flow: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
execAsync(): Promise<any[]>;
|
|
21
|
+
postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
|
|
22
|
+
}
|
|
23
|
+
import { AsyncNode } from '../qflow.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AsyncNode, AsyncFlow } from '../qflow.js';
|
|
2
|
+
export class IteratorNode extends AsyncNode {
|
|
3
|
+
static getToolDefinition() {
|
|
4
|
+
return {
|
|
5
|
+
name: "iterator",
|
|
6
|
+
description: "Iterates items, executes sub-flow for each.",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
items: {
|
|
11
|
+
type: "array",
|
|
12
|
+
description: "The list of items to iterate over."
|
|
13
|
+
},
|
|
14
|
+
flow: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "The name of the flow to execute for each item, as registered in the flow registry."
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
required: ["items", "flow"]
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async execAsync() {
|
|
24
|
+
const { items, flow } = this.params;
|
|
25
|
+
if (!items || !Array.isArray(items)) {
|
|
26
|
+
throw new Error('IteratorNode requires an `items` parameter of type Array.');
|
|
27
|
+
}
|
|
28
|
+
if (!flow || !(flow instanceof AsyncFlow)) {
|
|
29
|
+
throw new Error('IteratorNode requires a `flow` parameter of type AsyncFlow.');
|
|
30
|
+
}
|
|
31
|
+
const results = [];
|
|
32
|
+
for (const item of items) {
|
|
33
|
+
const subFlowShared = { item, params: this.params };
|
|
34
|
+
const result = await flow.runAsync(subFlowShared);
|
|
35
|
+
results.push(result);
|
|
36
|
+
}
|
|
37
|
+
return results;
|
|
38
|
+
}
|
|
39
|
+
async postAsync(shared, prepRes, execRes) {
|
|
40
|
+
shared.iteratorResult = execRes;
|
|
41
|
+
return 'default';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export class DeepSeekLLMNode extends AsyncNode {
|
|
2
|
+
static getToolDefinition(): {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
prompt: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
apiKey: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
model: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
max_tokens: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
temperature: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
required: string[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
preparePrompt(shared: any): void;
|
|
33
|
+
execAsync(prepRes: any, shared: any): Promise<any>;
|
|
34
|
+
}
|
|
35
|
+
export class OpenAILLMNode extends AsyncNode {
|
|
36
|
+
static getToolDefinition(): {
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
parameters: {
|
|
40
|
+
type: string;
|
|
41
|
+
properties: {
|
|
42
|
+
prompt: {
|
|
43
|
+
type: string;
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
apiKey: {
|
|
47
|
+
type: string;
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
model: {
|
|
51
|
+
type: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
max_tokens: {
|
|
55
|
+
type: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
temperature: {
|
|
59
|
+
type: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
required: string[];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
execAsync(): Promise<any>;
|
|
67
|
+
}
|
|
68
|
+
export class GeminiLLMNode extends AsyncNode {
|
|
69
|
+
static getToolDefinition(): {
|
|
70
|
+
name: string;
|
|
71
|
+
description: string;
|
|
72
|
+
parameters: {
|
|
73
|
+
type: string;
|
|
74
|
+
properties: {
|
|
75
|
+
prompt: {
|
|
76
|
+
type: string;
|
|
77
|
+
description: string;
|
|
78
|
+
};
|
|
79
|
+
apiKey: {
|
|
80
|
+
type: string;
|
|
81
|
+
description: string;
|
|
82
|
+
};
|
|
83
|
+
model: {
|
|
84
|
+
type: string;
|
|
85
|
+
description: string;
|
|
86
|
+
};
|
|
87
|
+
temperature: {
|
|
88
|
+
type: string;
|
|
89
|
+
description: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
required: string[];
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
execAsync(): Promise<any>;
|
|
96
|
+
}
|
|
97
|
+
export class OllamaLLMNode extends AsyncNode {
|
|
98
|
+
static getToolDefinition(): {
|
|
99
|
+
name: string;
|
|
100
|
+
description: string;
|
|
101
|
+
parameters: {
|
|
102
|
+
type: string;
|
|
103
|
+
properties: {
|
|
104
|
+
prompt: {
|
|
105
|
+
type: string;
|
|
106
|
+
description: string;
|
|
107
|
+
};
|
|
108
|
+
model: {
|
|
109
|
+
type: string;
|
|
110
|
+
description: string;
|
|
111
|
+
};
|
|
112
|
+
baseUrl: {
|
|
113
|
+
type: string;
|
|
114
|
+
description: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
required: string[];
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
preparePrompt(shared: any): void;
|
|
121
|
+
execAsync(prepRes: any, shared: any): Promise<any>;
|
|
122
|
+
}
|
|
123
|
+
export class HuggingFaceLLMNode extends AsyncNode {
|
|
124
|
+
static getToolDefinition(): {
|
|
125
|
+
name: string;
|
|
126
|
+
description: string;
|
|
127
|
+
parameters: {
|
|
128
|
+
type: string;
|
|
129
|
+
properties: {
|
|
130
|
+
prompt: {
|
|
131
|
+
type: string;
|
|
132
|
+
description: string;
|
|
133
|
+
};
|
|
134
|
+
model: {
|
|
135
|
+
type: string;
|
|
136
|
+
description: string;
|
|
137
|
+
};
|
|
138
|
+
hfToken: {
|
|
139
|
+
type: string;
|
|
140
|
+
description: string;
|
|
141
|
+
};
|
|
142
|
+
temperature: {
|
|
143
|
+
type: string;
|
|
144
|
+
description: string;
|
|
145
|
+
};
|
|
146
|
+
max_new_tokens: {
|
|
147
|
+
type: string;
|
|
148
|
+
description: string;
|
|
149
|
+
};
|
|
150
|
+
baseUrl: {
|
|
151
|
+
type: string;
|
|
152
|
+
description: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
required: string[];
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
execAsync(): Promise<any>;
|
|
159
|
+
}
|
|
160
|
+
import { AsyncNode } from '../qflow.js';
|