@fractal-solutions/qflow 1.0.58 → 1.0.60

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.
@@ -1,6 +1,7 @@
1
1
  import { AsyncNode } from '../qflow.js';
2
2
  // You would need to install the 'ssh2' library: npm install ssh2
3
3
  import { Client } from 'ssh2';
4
+ import { log } from '../logger.js';
4
5
  export class RemoteExecutionNode extends AsyncNode {
5
6
  constructor(maxRetries = 1, wait = 0) {
6
7
  super(maxRetries, wait);
@@ -30,7 +31,7 @@ export class RemoteExecutionNode extends AsyncNode {
30
31
  try {
31
32
  await new Promise((resolve, reject) => {
32
33
  conn.on('ready', () => {
33
- console.log(`[RemoteExecutionNode] Connected to ${username}@${host}:${port}`);
34
+ log(`[RemoteExecutionNode] Connected to ${username}@${host}:${port}`, this.params.logging);
34
35
  resolve();
35
36
  }).on('error', (err) => {
36
37
  reject(new Error(`SSH connection error: ${err.message}`));
@@ -74,7 +75,7 @@ export class RemoteExecutionNode extends AsyncNode {
74
75
  finally {
75
76
  if (conn && conn.connected) {
76
77
  conn.end();
77
- console.log(`[RemoteExecutionNode] Disconnected from ${host}`);
78
+ log(`[RemoteExecutionNode] Disconnected from ${host}`, this.params.logging);
78
79
  }
79
80
  }
80
81
  return result;
@@ -1,6 +1,7 @@
1
1
  import { AsyncNode, AsyncFlow } from '../qflow.js';
2
2
  // You would need to install the 'node-cron' library: npm install node-cron
3
3
  import * as cron from 'node-cron';
4
+ import { log } from '../logger.js';
4
5
  export class SchedulerNode extends AsyncNode {
5
6
  // Static map to hold all active scheduled tasks
6
7
  static activeTasks = new Map();
@@ -26,12 +27,12 @@ export class SchedulerNode extends AsyncNode {
26
27
  const existingTask = SchedulerNode.activeTasks.get(id);
27
28
  existingTask.stop();
28
29
  SchedulerNode.activeTasks.delete(id);
29
- console.log(`[SchedulerNode] Stopped existing task with ID: ${id}`);
30
+ log(`[SchedulerNode] Stopped existing task with ID: ${id}`, this.params.logging);
30
31
  }
31
32
  let task;
32
33
  if (typeof schedule === 'string') { // Cron string
33
34
  task = cron.schedule(schedule, async () => {
34
- console.log(`[SchedulerNode] Scheduled cron task triggered for ID: ${id}`);
35
+ log(`[SchedulerNode] Scheduled cron task triggered for ID: ${id}`, this.params.logging);
35
36
  try {
36
37
  // If flow is a string, assume it's a flow name from a global registry
37
38
  // This would require the SchedulerNode to have access to the flowRegistry
@@ -39,37 +40,37 @@ export class SchedulerNode extends AsyncNode {
39
40
  const flowInstance = flow; // Assuming flow is an AsyncFlow instance
40
41
  const taskShared = { ...flowParams };
41
42
  const result = await flowInstance.runAsync(taskShared);
42
- console.log(`[SchedulerNode] Scheduled flow (ID: ${id}) completed successfully. Result:`, result);
43
+ log(`[SchedulerNode] Scheduled flow (ID: ${id}) completed successfully. Result: ${JSON.stringify(result)}`, this.params.logging);
43
44
  }
44
45
  catch (e) {
45
- console.error(`[SchedulerNode] Scheduled flow (ID: ${id}) failed:`, e);
46
+ log(`[SchedulerNode] Scheduled flow (ID: ${id}) failed: ${e.message}`, this.params.logging, { type: 'error' });
46
47
  }
47
48
  }, {
48
49
  scheduled: true,
49
50
  timezone: 'America/New_York' // Example timezone
50
51
  });
51
- console.log(`[SchedulerNode] Started cron job (ID: ${id}) with schedule: ${schedule}`);
52
+ log(`[SchedulerNode] Started cron job (ID: ${id}) with schedule: ${schedule}`, this.params.logging);
52
53
  SchedulerNode.activeTasks.set(id, task);
53
54
  return { status: 'scheduled', type: 'cron', schedule: schedule, id: id };
54
55
  }
55
56
  else if (typeof schedule === 'number') { // Milliseconds for setTimeout
56
57
  const timerId = setTimeout(async () => {
57
- console.log(`[SchedulerNode] Scheduled one-time task triggered for ID: ${id}`);
58
+ log(`[SchedulerNode] Scheduled one-time task triggered for ID: ${id}`, this.params.logging);
58
59
  try {
59
60
  const flowInstance = flow; // Assuming flow is an AsyncFlow instance
60
61
  const taskShared = { ...flowParams };
61
62
  const result = await flowInstance.runAsync(taskShared);
62
- console.log(`[SchedulerNode] Scheduled flow (ID: ${id}) completed successfully. Result:`, result);
63
+ log(`[SchedulerNode] Scheduled flow (ID: ${id}) completed successfully. Result: ${JSON.stringify(result)}`, this.params.logging);
63
64
  }
64
65
  catch (e) {
65
- console.error(`[SchedulerNode] Scheduled flow (ID: ${id}) failed:`, e);
66
+ log(`[SchedulerNode] Scheduled flow (ID: ${id}) failed: ${e.message}`, this.params.logging, { type: 'error' });
66
67
  }
67
68
  finally {
68
69
  SchedulerNode.activeTasks.delete(id); // Remove one-time task after execution
69
70
  }
70
71
  }, schedule);
71
72
  task = { id: id, stop: () => clearTimeout(timerId) }; // Simple wrapper for setTimeout
72
- console.log(`[SchedulerNode] Started one-time task (ID: ${id}) in ${schedule}ms`);
73
+ log(`[SchedulerNode] Started one-time task (ID: ${id}) in ${schedule}ms`, this.params.logging);
73
74
  SchedulerNode.activeTasks.set(id, task);
74
75
  return { status: 'scheduled', type: 'timeout', schedule: schedule, id: id };
75
76
  }
@@ -85,11 +86,11 @@ export class SchedulerNode extends AsyncNode {
85
86
  const taskToStop = SchedulerNode.activeTasks.get(id);
86
87
  taskToStop.stop();
87
88
  SchedulerNode.activeTasks.delete(id);
88
- console.log(`[SchedulerNode] Stopped task with ID: ${id}`);
89
+ log(`[SchedulerNode] Stopped task with ID: ${id}`, this.params.logging);
89
90
  return { status: 'stopped', id: id };
90
91
  }
91
92
  else {
92
- console.warn(`[SchedulerNode] No active task found with ID: ${id}`);
93
+ log(`[SchedulerNode] No active task found with ID: ${id}`, this.params.logging, { type: 'warn' });
93
94
  return { status: 'not_found', id: id };
94
95
  }
95
96
  }
@@ -1,5 +1,6 @@
1
1
  import { AsyncNode } from '../qflow.js';
2
2
  import * as cheerio from 'cheerio';
3
+ import { log } from '../logger.js';
3
4
  /**
4
5
  * Performs a web search using DuckDuckGo's HTML-only interface.
5
6
  * This node does not require an API key and is designed for reliability without heavy dependencies.
@@ -14,7 +15,7 @@ export class DuckDuckGoSearchNode extends AsyncNode {
14
15
  throw new Error('DuckDuckGoSearchNode requires a `query` parameter.');
15
16
  }
16
17
  const url = `https://html.duckduckgo.com/html/?q=${encodeURIComponent(query)}`;
17
- console.log(`[DuckDuckGo] Searching for: "${query}"`);
18
+ log(`[DuckDuckGo] Searching for: "${query}"`, this.params.logging);
18
19
  const response = await fetch(url);
19
20
  if (!response.ok) {
20
21
  throw new Error(`DuckDuckGo HTML search failed with status ${response.status}`);
@@ -57,7 +58,7 @@ export class GoogleSearchNode extends AsyncNode {
57
58
  throw new Error('GoogleSearchNode requires `query`, `apiKey`, and `cseId` parameters.');
58
59
  }
59
60
  const url = `https://www.googleapis.com/customsearch/v1?key=${apiKey}&cx=${cseId}&q=${encodeURIComponent(query)}`;
60
- console.log(`[Google Search] Searching for: "${query}"`);
61
+ log(`[Google Search] Searching for: "${query}"`, this.params.logging);
61
62
  const response = await fetch(url);
62
63
  if (!response.ok) {
63
64
  const errorData = await response.json();
@@ -2,6 +2,7 @@ import { AsyncNode, AsyncFlow } from '../qflow.js';
2
2
  import { promises as fs } from 'fs';
3
3
  import path from 'path';
4
4
  import { EmbeddingNode } from './embedding.js';
5
+ import { log } from '../logger.js';
5
6
  // Utility function for cosine similarity
6
7
  function cosineSimilarity(vecA, vecB) {
7
8
  let dotProduct = 0;
@@ -67,15 +68,15 @@ export class SemanticMemoryNode extends AsyncNode {
67
68
  };
68
69
  // Save updated index
69
70
  await fs.writeFile(this.indexFilePath, JSON.stringify(this.memoryIndex, null, 2), 'utf-8');
70
- console.log(`[SemanticMemory] Stored memory: ${memoryId}`);
71
+ log(`[SemanticMemory] Stored memory: ${memoryId}`, this.params.logging);
71
72
  return { status: 'stored', id: memoryId };
72
73
  case 'retrieve':
73
74
  if (!query) {
74
75
  throw new Error('Retrieve action requires a `query`.');
75
76
  }
76
- console.log(`[SemanticMemory] Retrieving memories for query: "${query}"...`);
77
+ log(`[SemanticMemory] Retrieving memories for query: "${query}"...`, this.params.logging);
77
78
  if (Object.keys(this.memoryIndex).length === 0) {
78
- console.log('[SemanticMemory] No memories stored. Returning empty.');
79
+ log('[SemanticMemory] No memories stored. Returning empty.', this.params.logging);
79
80
  return [];
80
81
  }
81
82
  // Generate embedding for the query
@@ -97,7 +98,7 @@ export class SemanticMemoryNode extends AsyncNode {
97
98
  // Sort by similarity (descending) and return top results
98
99
  similarities.sort((a, b) => b.similarity - a.similarity);
99
100
  const topResults = similarities.slice(0, this.params.topK || 5);
100
- console.log(`[SemanticMemory] Retrieved ${topResults.length} semantic memories.`);
101
+ log(`[SemanticMemory] Retrieved ${topResults.length} semantic memories.`, this.params.logging);
101
102
  return topResults;
102
103
  default:
103
104
  throw new Error(`Unsupported action: ${action}`);
@@ -1,4 +1,5 @@
1
1
  import { AsyncNode } from '../qflow.js';
2
+ import { log } from '../logger.js';
2
3
  const API_BASE = 'https://api.stripe.com/v1';
3
4
  /**
4
5
  * Creates a new charge in Stripe.
@@ -16,7 +17,7 @@ export class CreateChargeNode extends AsyncNode {
16
17
  if (!apiKey || !amount || !currency || !source) {
17
18
  throw new Error('Missing required parameters: apiKey, amount, currency, source');
18
19
  }
19
- console.log(`[Stripe] Creating charge for ${amount} ${currency}...`);
20
+ log(`[Stripe] Creating charge for ${amount} ${currency}...`, this.params.logging);
20
21
  const response = await fetch(`${API_BASE}/charges`, {
21
22
  method: 'POST',
22
23
  headers: {
@@ -35,7 +36,7 @@ export class CreateChargeNode extends AsyncNode {
35
36
  throw new Error(`Stripe API error: ${response.status} - ${errorData.error.message}`);
36
37
  }
37
38
  const charge = await response.json();
38
- console.log(`[Stripe] Successfully created charge ${charge.id}`);
39
+ log(`[Stripe] Successfully created charge ${charge.id}`, this.params.logging);
39
40
  return charge;
40
41
  }
41
42
  }
@@ -51,7 +52,7 @@ export class GetBalanceNode extends AsyncNode {
51
52
  if (!apiKey) {
52
53
  throw new Error('Missing required parameter: apiKey');
53
54
  }
54
- console.log('[Stripe] Getting account balance...');
55
+ log('[Stripe] Getting account balance...', this.params.logging);
55
56
  const response = await fetch(`${API_BASE}/balance`, {
56
57
  headers: {
57
58
  'Authorization': `Bearer ${apiKey}`
@@ -62,7 +63,7 @@ export class GetBalanceNode extends AsyncNode {
62
63
  throw new Error(`Stripe API error: ${response.status} - ${errorData.error.message}`);
63
64
  }
64
65
  const balance = await response.json();
65
- console.log('[Stripe] Successfully retrieved account balance.');
66
+ log('[Stripe] Successfully retrieved account balance.', this.params.logging);
66
67
  return balance;
67
68
  }
68
69
  }
@@ -1,5 +1,6 @@
1
1
  import { AsyncNode } from '../qflow.js';
2
2
  import { DeepSeekLLMNode } from './llm.js'; // Assuming DeepSeekLLMNode for summarization
3
+ import { log } from '../logger.js';
3
4
  /**
4
5
  * Summarizes a given text using an LLM.
5
6
  * @param {object} params - The parameters for the node.
@@ -16,11 +17,11 @@ export class SummarizeNode extends AsyncNode {
16
17
  if (!llmNode) {
17
18
  throw new Error('SummarizeNode requires an `llmNode` instance for summarization.');
18
19
  }
19
- console.log(`[Summarize] Summarizing text (length: ${text.length})...`);
20
+ log(`[Summarize] Summarizing text (length: ${text.length})...`, this.params.logging);
20
21
  const prompt = `Please summarize the following text concisely, focusing on key information relevant to an agent's task. Keep the summary under 500 words:\n\n${text}`;
21
22
  llmNode.setParams({ prompt: prompt, keyword: 'summarization' });
22
23
  const summary = await llmNode.runAsync({});
23
- console.log(`[Summarize] Summary generated (length: ${summary.length}).`);
24
+ log(`[Summarize] Summary generated (length: ${summary.length}).`, this.params.logging);
24
25
  return summary;
25
26
  }
26
27
  async postAsync(shared, prepRes, execRes) {
@@ -1,6 +1,7 @@
1
1
  import { AsyncNode } from '../qflow.js';
2
2
  import { exec } from 'child_process';
3
3
  import os from 'os';
4
+ import { log } from '../logger.js';
4
5
  export class SystemNotificationNode extends AsyncNode {
5
6
  constructor(maxRetries = 1, wait = 0) {
6
7
  super(maxRetries, wait);
@@ -31,17 +32,17 @@ export class SystemNotificationNode extends AsyncNode {
31
32
  default:
32
33
  throw new Error(`Unsupported platform for SystemNotificationNode: ${platform}`);
33
34
  }
34
- console.log(`[SystemNotificationNode] Executing: ${command}`);
35
+ log(`[SystemNotificationNode] Executing: ${command}`, this.params.logging);
35
36
  return new Promise((resolve, reject) => {
36
37
  exec(command, (error, stdout, stderr) => {
37
38
  if (error) {
38
- console.error(`SystemNotificationNode error: ${error.message}`);
39
+ log(`SystemNotificationNode error: ${error.message}`, this.params.logging, { type: 'error' });
39
40
  return reject(error);
40
41
  }
41
42
  if (stderr) {
42
- console.warn(`SystemNotificationNode stderr: ${stderr}`);
43
+ log(`SystemNotificationNode stderr: ${stderr}`, this.params.logging, { type: 'warn' });
43
44
  }
44
- console.log(`Notification displayed: "${message}"`);
45
+ log(`Notification displayed: "${message}"`, this.params.logging);
45
46
  resolve({ message, title, stdout, stderr });
46
47
  });
47
48
  });
@@ -1,4 +1,5 @@
1
1
  import { AsyncNode } from '../qflow.js';
2
+ import { log } from '../logger.js';
2
3
  export class TransformNode extends AsyncNode {
3
4
  async execAsync() {
4
5
  const { input, transformFunction } = this.params;
@@ -17,7 +18,7 @@ export class TransformNode extends AsyncNode {
17
18
  }
18
19
  try {
19
20
  const result = func(input);
20
- console.log(`[TransformNode] Transformation complete. Result: ${JSON.stringify(result).substring(0, 100)}...`);
21
+ log(`[TransformNode] Transformation complete. Result: ${JSON.stringify(result).substring(0, 100)}...`, this.params.logging);
21
22
  return result;
22
23
  }
23
24
  catch (e) {
@@ -2,6 +2,7 @@ import { AsyncNode, AsyncFlow } from '../qflow.js';
2
2
  import http from 'http';
3
3
  import { URL } from 'url'; // Node.js built-in
4
4
  import crypto from 'crypto'; // Node.js built-in
5
+ import { log } from '../logger.js';
5
6
  export class WebHookNode extends AsyncNode {
6
7
  constructor(maxRetries = 1, wait = 0) {
7
8
  super(maxRetries, wait);
@@ -27,7 +28,7 @@ export class WebHookNode extends AsyncNode {
27
28
  this.sharedSecret = sharedSecret;
28
29
  // Ensure server is not already running
29
30
  if (this.server && this.server.listening) {
30
- console.warn(`[WebHookNode] Server already listening on port ${port}. Reusing existing server.`);
31
+ log(`[WebHookNode] Server already listening on port ${port}. Reusing existing server.`, this.params.logging, { type: 'warn' });
31
32
  return { status: 'server_already_running', port, path };
32
33
  }
33
34
  this.server = http.createServer(async (req, res) => {
@@ -43,7 +44,7 @@ export class WebHookNode extends AsyncNode {
43
44
  payload = JSON.parse(body);
44
45
  }
45
46
  catch (e) {
46
- console.error('[WebHookNode] Failed to parse webhook body as JSON:', e);
47
+ log('[WebHookNode] Failed to parse webhook body as JSON:', this.params.logging, { type: 'error' });
47
48
  res.writeHead(400, { 'Content-Type': 'application/json' });
48
49
  res.end(JSON.stringify({ error: 'Invalid JSON payload' }));
49
50
  return;
@@ -52,7 +53,7 @@ export class WebHookNode extends AsyncNode {
52
53
  if (this.sharedSecret) {
53
54
  const signature = req.headers['x-hub-signature-256'] || req.headers['x-webhook-signature']; // Common headers
54
55
  if (!signature) {
55
- console.warn('[WebHookNode] Webhook received without signature, but sharedSecret is configured.');
56
+ log('[WebHookNode] Webhook received without signature, but sharedSecret is configured.', this.params.logging, { type: 'warn' });
56
57
  res.writeHead(401, { 'Content-Type': 'application/json' });
57
58
  res.end(JSON.stringify({ error: 'Missing signature' }));
58
59
  return;
@@ -61,24 +62,24 @@ export class WebHookNode extends AsyncNode {
61
62
  hmac.update(body);
62
63
  const digest = `sha256=${hmac.digest('hex')}`; // Format might vary (e.g., 'v1=...')
63
64
  if (digest !== signature) { // Simple comparison, real-world might need more robust parsing
64
- console.warn('[WebHookNode] Webhook signature mismatch. Request rejected.');
65
+ log('[WebHookNode] Webhook signature mismatch. Request rejected.', this.params.logging, { type: 'warn' });
65
66
  res.writeHead(403, { 'Content-Type': 'application/json' });
66
67
  res.end(JSON.stringify({ error: 'Invalid signature' }));
67
68
  return;
68
69
  }
69
- console.log('[WebHookNode] Webhook signature verified.');
70
+ log('[WebHookNode] Webhook signature verified.', this.params.logging);
70
71
  }
71
- console.log(`[WebHookNode] Webhook received on ${this.webhookPath}. Triggering flow...`);
72
+ log(`[WebHookNode] Webhook received on ${this.webhookPath}. Triggering flow...`, this.params.logging);
72
73
  const triggeredFlowShared = { webhook: { headers: req.headers, payload: payload, method: req.method, path: requestUrl.pathname } };
73
74
  if (this.params.waitForFlow) {
74
75
  try {
75
76
  const flowResult = await this.flowToTrigger.runAsync(triggeredFlowShared);
76
- console.log('[WebHookNode] Triggered flow completed successfully:', flowResult);
77
+ log('[WebHookNode] Triggered flow completed successfully:', this.params.logging);
77
78
  res.writeHead(this.params.responseStatus || 200, { 'Content-Type': 'application/json' });
78
79
  res.end(JSON.stringify(flowResult));
79
80
  }
80
81
  catch (flowError) {
81
- console.error('[WebHookNode] Triggered flow failed:', flowError);
82
+ log('[WebHookNode] Triggered flow failed:', this.params.logging, { type: 'error' });
82
83
  res.writeHead(500, { 'Content-Type': 'application/json' });
83
84
  res.end(JSON.stringify({ error: 'Flow execution failed' }));
84
85
  }
@@ -86,10 +87,10 @@ export class WebHookNode extends AsyncNode {
86
87
  else {
87
88
  this.flowToTrigger.runAsync(triggeredFlowShared)
88
89
  .then(flowResult => {
89
- console.log('[WebHookNode] Triggered flow completed successfully:', flowResult);
90
+ log('[WebHookNode] Triggered flow completed successfully:', this.params.logging);
90
91
  })
91
92
  .catch(flowError => {
92
- console.error('[WebHookNode] Triggered flow failed:', flowError);
93
+ log('[WebHookNode] Triggered flow failed:', this.params.logging, { type: 'error' });
93
94
  });
94
95
  // Send response back to webhook sender
95
96
  res.writeHead(this.params.responseStatus || 200, { 'Content-Type': 'application/json' });
@@ -104,7 +105,7 @@ export class WebHookNode extends AsyncNode {
104
105
  });
105
106
  await new Promise(resolve => {
106
107
  this.server.listen(port, () => {
107
- console.log(`[WebHookNode] Listening for webhooks on http://localhost:${port}${this.webhookPath}`);
108
+ log(`[WebHookNode] Listening for webhooks on http://localhost:${port}${this.webhookPath}`, this.params.logging);
108
109
  resolve();
109
110
  });
110
111
  });
@@ -1,4 +1,5 @@
1
1
  import { AsyncNode } from '../qflow.js';
2
+ import { log } from '../logger.js';
2
3
  /**
3
4
  * Fetches the HTML content of a given URL.
4
5
  * @param {object} params - The parameters for the node.
@@ -11,13 +12,13 @@ export class ScrapeURLNode extends AsyncNode {
11
12
  if (!url) {
12
13
  throw new Error('URL is required for ScrapeURLNode.');
13
14
  }
14
- console.log(`[WebScraper] Scraping URL: ${url}...`);
15
+ log(`[WebScraper] Scraping URL: ${url}...`, this.params.logging);
15
16
  const response = await fetch(url);
16
17
  if (!response.ok) {
17
18
  throw new Error(`Failed to fetch URL: ${response.status} - ${response.statusText}`);
18
19
  }
19
20
  const html = await response.text();
20
- console.log(`[WebScraper] Successfully scraped URL: ${url}`);
21
+ log(`[WebScraper] Successfully scraped URL: ${url}`, this.params.logging);
21
22
  return html;
22
23
  }
23
24
  async postAsync(shared, prepRes, execRes) {
@@ -25,7 +26,7 @@ export class ScrapeURLNode extends AsyncNode {
25
26
  const MAX_HTML_LENGTH = 4000;
26
27
  shared.webScrapedContent = execRes.substring(0, MAX_HTML_LENGTH);
27
28
  if (execRes.length > MAX_HTML_LENGTH) {
28
- console.warn(`[WebScraper] Truncated HTML content from ${execRes.length} to ${MAX_HTML_LENGTH} characters.`);
29
+ log(`[WebScraper] Truncated HTML content from ${execRes.length} to ${MAX_HTML_LENGTH} characters.`, this.params.logging, { type: 'warn' });
29
30
  }
30
31
  return shared.webScrapedContent;
31
32
  }
@@ -0,0 +1,12 @@
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';
@@ -0,0 +1,27 @@
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fractal-solutions/qflow",
3
- "version": "1.0.58",
3
+ "version": "1.0.60",
4
4
  "description": "A lightweight and flexible JavaScript library for creating and managing workflows and agents.",
5
5
  "main": "dist/qflow.js",
6
6
  "types": "dist/qflow.d.ts",