@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.
- package/README.md +75 -74
- 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,142 +0,0 @@
|
|
|
1
|
-
import { AsyncNode, AsyncFlow } from '../qflow.js';
|
|
2
|
-
import { ShellCommandNode, HttpRequestNode } from './index.js'; // Assuming these are available
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import os from 'os';
|
|
5
|
-
import { promises as fs } from 'fs';
|
|
6
|
-
// --- Provider Implementations ---
|
|
7
|
-
// macOS 'say' command provider
|
|
8
|
-
class MacOSSayProvider {
|
|
9
|
-
async synthesize(text, voice) {
|
|
10
|
-
let command = `say "${text}"`;
|
|
11
|
-
if (voice)
|
|
12
|
-
command += ` -v "${voice}"`;
|
|
13
|
-
return { command: command, type: 'shell' };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Linux 'espeak' command provider
|
|
17
|
-
class LinuxEspeakProvider {
|
|
18
|
-
async synthesize(text, voice) {
|
|
19
|
-
let command = `espeak "${text}"`;
|
|
20
|
-
if (voice)
|
|
21
|
-
command += ` -v "${voice}"`; // espeak voices are different (e.g., 'en-us', 'en-gb')
|
|
22
|
-
return { command: command, type: 'shell' };
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
// Windows PowerShell/SAPI provider (conceptual)
|
|
26
|
-
class WindowsSAPIProvider {
|
|
27
|
-
async synthesize(text, voice) {
|
|
28
|
-
// This is more complex. Requires PowerShell script to use System.Speech.Synthesis.SpeechSynthesizer
|
|
29
|
-
// and save to file, then play. Or directly play.
|
|
30
|
-
// For simplicity, we'll just throw an error for now.
|
|
31
|
-
throw new Error("Windows SAPI synthesis not implemented directly via shell command for this node.");
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// Google Cloud Text-to-Speech Provider (conceptual - requires API key)
|
|
35
|
-
class GoogleCloudTTSProvider {
|
|
36
|
-
constructor(apiKey) {
|
|
37
|
-
this.apiKey = apiKey;
|
|
38
|
-
this.baseUrl = "https://texttospeech.googleapis.com/v1/text:synthesize";
|
|
39
|
-
}
|
|
40
|
-
async synthesize(text, voiceConfig = { languageCode: 'en-US', name: 'en-US-Wavenet-D', ssmlGender: 'NEUTRAL' }) {
|
|
41
|
-
if (!this.apiKey) {
|
|
42
|
-
throw new Error("Google Cloud TTS API Key is not configured.");
|
|
43
|
-
}
|
|
44
|
-
const payload = {
|
|
45
|
-
input: { text: text },
|
|
46
|
-
voice: voiceConfig,
|
|
47
|
-
audioConfig: { audioEncoding: 'MP3' } // Or LINEAR16 for WAV
|
|
48
|
-
};
|
|
49
|
-
const url = `${this.baseUrl}?key=${this.apiKey}`;
|
|
50
|
-
const httpRequest = new HttpRequestNode();
|
|
51
|
-
httpRequest.setParams({
|
|
52
|
-
url: url,
|
|
53
|
-
method: 'POST',
|
|
54
|
-
headers: { 'Content-Type': 'application/json' },
|
|
55
|
-
body: payload
|
|
56
|
-
});
|
|
57
|
-
const response = await new AsyncFlow(httpRequest).runAsync({});
|
|
58
|
-
if (response.status === 200 && response.body && response.body.audioContent) {
|
|
59
|
-
// Google returns base64 encoded audio
|
|
60
|
-
const audioBuffer = Buffer.from(response.body.audioContent, 'base64');
|
|
61
|
-
const tempAudioPath = path.join(os.tmpdir(), `qflow_tts_${Date.now()}.mp3`);
|
|
62
|
-
await fs.writeFile(tempAudioPath, audioBuffer);
|
|
63
|
-
return { filePath: tempAudioPath, type: 'file' };
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
throw new Error(`Google Cloud TTS failed: ${response.status} - ${JSON.stringify(response.body)}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export class SpeechSynthesisNode extends AsyncNode {
|
|
71
|
-
constructor(maxRetries = 1, wait = 0) {
|
|
72
|
-
super(maxRetries, wait);
|
|
73
|
-
this.providers = {
|
|
74
|
-
macos: new MacOSSayProvider(),
|
|
75
|
-
linux: new LinuxEspeakProvider(),
|
|
76
|
-
windows: new WindowsSAPIProvider(), // Placeholder for Windows
|
|
77
|
-
google: new GoogleCloudTTSProvider(process.env.GOOGLE_TTS_API_KEY), // Requires API key
|
|
78
|
-
// Add other providers here
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
async execAsync() {
|
|
82
|
-
const { text, provider, voice, outputFilePath } = this.params;
|
|
83
|
-
if (!text) {
|
|
84
|
-
throw new Error('SpeechSynthesisNode requires `text` to synthesize.');
|
|
85
|
-
}
|
|
86
|
-
let selectedProvider;
|
|
87
|
-
let audioOutput;
|
|
88
|
-
// Determine provider based on OS or explicit parameter
|
|
89
|
-
if (provider) {
|
|
90
|
-
selectedProvider = this.providers[provider];
|
|
91
|
-
if (!selectedProvider) {
|
|
92
|
-
throw new Error(`Specified provider '${provider}' not supported or configured.`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// Default to OS-specific provider
|
|
97
|
-
const platform = os.platform();
|
|
98
|
-
if (platform === 'darwin')
|
|
99
|
-
selectedProvider = this.providers.macos;
|
|
100
|
-
else if (platform === 'linux')
|
|
101
|
-
selectedProvider = this.providers.linux;
|
|
102
|
-
else if (platform === 'win32')
|
|
103
|
-
selectedProvider = this.providers.windows;
|
|
104
|
-
else
|
|
105
|
-
throw new Error(`Speech synthesis not supported on platform: ${platform}`);
|
|
106
|
-
}
|
|
107
|
-
// Synthesize speech
|
|
108
|
-
const synthesisResult = await selectedProvider.synthesize(text, voice);
|
|
109
|
-
// Handle audio output (play or save to file)
|
|
110
|
-
if (synthesisResult.type === 'shell') {
|
|
111
|
-
// Directly execute the shell command to play audio
|
|
112
|
-
const shellNode = new ShellCommandNode();
|
|
113
|
-
shellNode.setParams({ command: synthesisResult.command });
|
|
114
|
-
await new AsyncFlow(shellNode).runAsync({});
|
|
115
|
-
audioOutput = { status: 'played_via_shell' };
|
|
116
|
-
}
|
|
117
|
-
else if (synthesisResult.type === 'file') {
|
|
118
|
-
// Audio is saved to a file, now play it
|
|
119
|
-
const audioFilePath = outputFilePath || synthesisResult.filePath;
|
|
120
|
-
if (!outputFilePath) { // If not saving to a specific path, play it
|
|
121
|
-
const playCommand = os.platform() === 'darwin' ? `afplay "${audioFilePath}"` :
|
|
122
|
-
os.platform() === 'linux' ? `aplay "${audioFilePath}"` : // Requires aplay (alsa-utils)
|
|
123
|
-
os.platform() === 'win32' ? `start "" "${audioFilePath}"` : // Plays with default player
|
|
124
|
-
null;
|
|
125
|
-
if (!playCommand)
|
|
126
|
-
throw new Error(`Audio playback not supported on platform: ${os.platform()}`);
|
|
127
|
-
const shellNode = new ShellCommandNode();
|
|
128
|
-
shellNode.setParams({ command: playCommand });
|
|
129
|
-
await new AsyncFlow(shellNode).runAsync({});
|
|
130
|
-
audioOutput = { status: 'played_from_file', filePath: audioFilePath };
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
// If outputFilePath was provided, just return the path
|
|
134
|
-
audioOutput = { status: 'saved_to_file', filePath: audioFilePath };
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
throw new Error('Unsupported synthesis result type.');
|
|
139
|
-
}
|
|
140
|
-
return audioOutput;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { AsyncNode } from '../qflow.js';
|
|
2
|
-
import { promises as fs } from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import * as XLSX from 'xlsx'; // npm install xlsx
|
|
5
|
-
export class SpreadsheetNode extends AsyncNode {
|
|
6
|
-
constructor(maxRetries = 1, wait = 0) {
|
|
7
|
-
super(maxRetries, wait);
|
|
8
|
-
}
|
|
9
|
-
async execAsync() {
|
|
10
|
-
const { filePath, action, // 'read', 'write', 'list_sheets', 'read_range', 'write_range', 'append_rows', 'delete_rows', 'insert_rows', 'add_sheet', 'delete_sheet', 'rename_sheet', 'format_cells'
|
|
11
|
-
sheetName, // Required for .xlsx/.xls read/write/management
|
|
12
|
-
data, // Required for 'write', 'write_range', 'append_rows'
|
|
13
|
-
headerRow = true, // For read/write
|
|
14
|
-
range, // A1 notation for 'read_range', 'write_range', 'format_cells'
|
|
15
|
-
startRow, // For 'delete_rows', 'insert_rows'
|
|
16
|
-
numRows, // For 'delete_rows', 'insert_rows'
|
|
17
|
-
startCol, // For 'delete_cols', 'insert_cols' (conceptual, not implementing now)
|
|
18
|
-
numCols, // For 'delete_cols', 'insert_cols' (conceptual, not implementing now)
|
|
19
|
-
newSheetName, // For 'rename_sheet'
|
|
20
|
-
formats // For 'format_cells'
|
|
21
|
-
} = this.params;
|
|
22
|
-
if (!filePath) {
|
|
23
|
-
throw new Error('SpreadsheetNode requires a `filePath` parameter.');
|
|
24
|
-
}
|
|
25
|
-
if (!action || !['read', 'write', 'list_sheets', 'read_range', 'write_range', 'append_rows', 'delete_rows', 'insert_rows', 'add_sheet', 'delete_sheet', 'rename_sheet', 'format_cells'].includes(action)) {
|
|
26
|
-
throw new Error('SpreadsheetNode requires a valid `action`.');
|
|
27
|
-
}
|
|
28
|
-
const fileExtension = path.extname(filePath).toLowerCase();
|
|
29
|
-
let workbook;
|
|
30
|
-
let result;
|
|
31
|
-
// Helper to read workbook (for read/list_sheets/modify)
|
|
32
|
-
const readWorkbook = async () => {
|
|
33
|
-
try {
|
|
34
|
-
const fileBuffer = await fs.readFile(filePath);
|
|
35
|
-
return XLSX.read(fileBuffer, { type: 'buffer' });
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
throw new Error(`Failed to read spreadsheet file: ${e.message}. Ensure file exists and is accessible.`);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
// Helper to write workbook (for modify actions)
|
|
42
|
-
const writeWorkbook = async (wb) => {
|
|
43
|
-
try {
|
|
44
|
-
XLSX.writeFile(wb, filePath);
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
throw new Error(`Failed to write spreadsheet file: ${e.message}.`);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
// Helper to get worksheet
|
|
51
|
-
const getWorksheet = (wb, sName) => {
|
|
52
|
-
if (!sName)
|
|
53
|
-
throw new Error('`sheetName` is required for this action.');
|
|
54
|
-
const ws = wb.Sheets[sName];
|
|
55
|
-
if (!ws)
|
|
56
|
-
throw new Error(`Sheet '${sName}' not found in workbook.`);
|
|
57
|
-
return ws;
|
|
58
|
-
};
|
|
59
|
-
switch (action) {
|
|
60
|
-
case 'list_sheets':
|
|
61
|
-
if (!['.xlsx', '.xls'].includes(fileExtension)) {
|
|
62
|
-
throw new Error(`List sheets action only supported for .xlsx or .xls files. Got: ${fileExtension}`);
|
|
63
|
-
}
|
|
64
|
-
workbook = await readWorkbook();
|
|
65
|
-
result = { sheets: workbook.SheetNames };
|
|
66
|
-
break;
|
|
67
|
-
case 'read':
|
|
68
|
-
if (!['.xlsx', '.xls', '.csv'].includes(fileExtension)) {
|
|
69
|
-
throw new Error(`Unsupported file format for reading: ${fileExtension}. Supported: .xlsx, .xls, .csv`);
|
|
70
|
-
}
|
|
71
|
-
workbook = await readWorkbook();
|
|
72
|
-
let worksheetRead;
|
|
73
|
-
if (fileExtension === '.csv') {
|
|
74
|
-
worksheetRead = workbook.Sheets[workbook.SheetNames[0]];
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
worksheetRead = getWorksheet(workbook, sheetName);
|
|
78
|
-
}
|
|
79
|
-
result = XLSX.utils.sheet_to_json(worksheetRead, { header: headerRow ? 1 : 'A' });
|
|
80
|
-
break;
|
|
81
|
-
case 'read_range':
|
|
82
|
-
if (!range)
|
|
83
|
-
throw new Error('`range` is required for read_range.');
|
|
84
|
-
if (!['.xlsx', '.xls', '.csv'].includes(fileExtension)) {
|
|
85
|
-
throw new Error(`Unsupported file format for reading range: ${fileExtension}. Supported: .xlsx, .xls, .csv`);
|
|
86
|
-
}
|
|
87
|
-
workbook = await readWorkbook();
|
|
88
|
-
let worksheetReadRange;
|
|
89
|
-
if (fileExtension === '.csv') {
|
|
90
|
-
worksheetReadRange = workbook.Sheets[workbook.SheetNames[0]];
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
worksheetReadRange = getWorksheet(workbook, sheetName);
|
|
94
|
-
}
|
|
95
|
-
result = XLSX.utils.sheet_to_json(worksheetReadRange, { header: headerRow ? 1 : 'A', range: range });
|
|
96
|
-
break;
|
|
97
|
-
case 'write':
|
|
98
|
-
if (!data || !Array.isArray(data) || data.length === 0)
|
|
99
|
-
throw new Error('`data` is required for write.');
|
|
100
|
-
if (!['.xlsx', '.csv'].includes(fileExtension)) {
|
|
101
|
-
throw new Error(`Unsupported file format for writing: ${fileExtension}. Supported: .xlsx, .csv`);
|
|
102
|
-
}
|
|
103
|
-
workbook = XLSX.utils.book_new();
|
|
104
|
-
const worksheetToWrite = XLSX.utils.json_to_sheet(data, { skipHeader: !headerRow });
|
|
105
|
-
if (fileExtension === '.csv') {
|
|
106
|
-
const csvContent = XLSX.utils.sheet_to_csv(worksheetToWrite);
|
|
107
|
-
await fs.writeFile(filePath, csvContent);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
if (!sheetName)
|
|
111
|
-
throw new Error('`sheetName` is required for .xlsx write.');
|
|
112
|
-
XLSX.utils.book_append_sheet(workbook, worksheetToWrite, sheetName);
|
|
113
|
-
await writeWorkbook(workbook);
|
|
114
|
-
}
|
|
115
|
-
result = { message: `Successfully wrote data to ${filePath}` };
|
|
116
|
-
break;
|
|
117
|
-
case 'write_range':
|
|
118
|
-
if (!range || !data || !Array.isArray(data))
|
|
119
|
-
throw new Error('`range` and `data` are required for write_range.');
|
|
120
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
121
|
-
throw new Error(`Unsupported file format for writing range: ${fileExtension}. Supported: .xlsx`);
|
|
122
|
-
workbook = await readWorkbook();
|
|
123
|
-
let worksheetWriteRange = getWorksheet(workbook, sheetName);
|
|
124
|
-
XLSX.utils.sheet_add_json(worksheetWriteRange, data, { origin: range, skipHeader: !headerRow });
|
|
125
|
-
await writeWorkbook(workbook);
|
|
126
|
-
result = { message: `Successfully wrote data to range ${range} in ${filePath}` };
|
|
127
|
-
break;
|
|
128
|
-
case 'append_rows':
|
|
129
|
-
if (!data || !Array.isArray(data))
|
|
130
|
-
throw new Error('`data` is required for append_rows.');
|
|
131
|
-
if (!['.xlsx', '.csv'].includes(fileExtension))
|
|
132
|
-
throw new Error(`Unsupported file format for appending: ${fileExtension}. Supported: .xlsx, .csv`);
|
|
133
|
-
workbook = await readWorkbook();
|
|
134
|
-
let worksheetAppend;
|
|
135
|
-
if (fileExtension === '.csv') {
|
|
136
|
-
worksheetAppend = workbook.Sheets[workbook.SheetNames[0]];
|
|
137
|
-
const csvContent = XLSX.utils.sheet_to_csv(worksheetAppend) + '\n' + XLSX.utils.sheet_to_csv(XLSX.utils.json_to_sheet(data, { skipHeader: true }));
|
|
138
|
-
await fs.writeFile(filePath, csvContent);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
worksheetAppend = getWorksheet(workbook, sheetName);
|
|
142
|
-
XLSX.utils.sheet_add_json(worksheetAppend, data, { skipHeader: true, origin: -1 }); // -1 appends to end
|
|
143
|
-
await writeWorkbook(workbook);
|
|
144
|
-
}
|
|
145
|
-
result = { message: `Successfully appended rows to ${filePath}` };
|
|
146
|
-
break;
|
|
147
|
-
case 'delete_rows':
|
|
148
|
-
if (startRow === undefined || numRows === undefined)
|
|
149
|
-
throw new Error('`startRow` and `numRows` are required for delete_rows.');
|
|
150
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
151
|
-
throw new Error(`Unsupported file format for deleting rows: ${fileExtension}. Supported: .xlsx`);
|
|
152
|
-
const deleteRowsHelper = (ws, start, num) => {
|
|
153
|
-
const range = XLSX.utils.decode_range(ws['!ref']);
|
|
154
|
-
for (let R = start; R < range.e.r; ++R) {
|
|
155
|
-
for (let C = range.s.c; C <= range.e.c; ++C) {
|
|
156
|
-
ws[XLSX.utils.encode_cell({ r: R, c: C })] = ws[XLSX.utils.encode_cell({ r: R + num, c: C })];
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
range.e.r -= num;
|
|
160
|
-
ws['!ref'] = XLSX.utils.encode_range(range.s, range.e);
|
|
161
|
-
};
|
|
162
|
-
workbook = await readWorkbook();
|
|
163
|
-
let worksheetDeleteRows = getWorksheet(workbook, sheetName);
|
|
164
|
-
deleteRowsHelper(worksheetDeleteRows, startRow - 1, numRows);
|
|
165
|
-
await writeWorkbook(workbook);
|
|
166
|
-
result = { message: `Successfully deleted ${numRows} rows starting from ${startRow} in ${filePath}` };
|
|
167
|
-
break;
|
|
168
|
-
case 'insert_rows':
|
|
169
|
-
if (startRow === undefined || numRows === undefined)
|
|
170
|
-
throw new Error('`startRow` and `numRows` are required for insert_rows.');
|
|
171
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
172
|
-
throw new Error(`Unsupported file format for inserting rows: ${fileExtension}. Supported: .xlsx`);
|
|
173
|
-
workbook = await readWorkbook();
|
|
174
|
-
let worksheetInsertRows = getWorksheet(workbook, sheetName);
|
|
175
|
-
XLSX.utils.sheet_add_aoa(worksheetInsertRows, Array(numRows).fill([]), { origin: startRow - 1 }); // Insert empty rows
|
|
176
|
-
await writeWorkbook(workbook);
|
|
177
|
-
result = { message: `Successfully inserted ${numRows} rows starting from ${startRow} in ${filePath}` };
|
|
178
|
-
break;
|
|
179
|
-
case 'add_sheet':
|
|
180
|
-
if (!newSheetName)
|
|
181
|
-
throw new Error('`newSheetName` is required for add_sheet.');
|
|
182
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
183
|
-
throw new Error(`Unsupported file format for adding sheet: ${fileExtension}. Supported: .xlsx`);
|
|
184
|
-
workbook = await readWorkbook();
|
|
185
|
-
if (workbook.SheetNames.includes(newSheetName))
|
|
186
|
-
throw new Error(`Sheet '${newSheetName}' already exists.`);
|
|
187
|
-
XLSX.utils.book_append_sheet(workbook, XLSX.utils.aoa_to_sheet([[]]), newSheetName); // Add empty sheet
|
|
188
|
-
await writeWorkbook(workbook);
|
|
189
|
-
result = { message: `Successfully added sheet '${newSheetName}' to ${filePath}` };
|
|
190
|
-
break;
|
|
191
|
-
case 'delete_sheet':
|
|
192
|
-
if (!sheetName)
|
|
193
|
-
throw new Error('`sheetName` is required for delete_sheet.');
|
|
194
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
195
|
-
throw new Error(`Unsupported file format for deleting sheet: ${fileExtension}. Supported: .xlsx`);
|
|
196
|
-
workbook = await readWorkbook();
|
|
197
|
-
if (!workbook.SheetNames.includes(sheetName))
|
|
198
|
-
throw new Error(`Sheet '${sheetName}' not found.`);
|
|
199
|
-
delete workbook.Sheets[sheetName];
|
|
200
|
-
workbook.SheetNames = workbook.SheetNames.filter(s => s !== sheetName);
|
|
201
|
-
await writeWorkbook(workbook);
|
|
202
|
-
result = { message: `Successfully deleted sheet '${sheetName}' from ${filePath}` };
|
|
203
|
-
break;
|
|
204
|
-
case 'rename_sheet':
|
|
205
|
-
if (!sheetName || !newSheetName)
|
|
206
|
-
throw new Error('`sheetName` and `newSheetName` are required for rename_sheet.');
|
|
207
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
208
|
-
throw new Error(`Unsupported file format for renaming sheet: ${fileExtension}. Supported: .xlsx`);
|
|
209
|
-
workbook = await readWorkbook();
|
|
210
|
-
if (!workbook.SheetNames.includes(sheetName))
|
|
211
|
-
throw new Error(`Sheet '${sheetName}' not found.`);
|
|
212
|
-
if (workbook.SheetNames.includes(newSheetName))
|
|
213
|
-
throw new Error(`Sheet '${newSheetName}' already exists.`);
|
|
214
|
-
workbook.SheetNames[workbook.SheetNames.indexOf(sheetName)] = newSheetName;
|
|
215
|
-
workbook.Sheets[newSheetName] = workbook.Sheets[sheetName];
|
|
216
|
-
delete workbook.Sheets[sheetName];
|
|
217
|
-
await writeWorkbook(workbook);
|
|
218
|
-
result = { message: `Successfully renamed sheet '${sheetName}' to '${newSheetName}' in ${filePath}` };
|
|
219
|
-
break;
|
|
220
|
-
case 'format_cells':
|
|
221
|
-
if (!range || !formats)
|
|
222
|
-
throw new Error('`range` and `formats` are required for format_cells.');
|
|
223
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
224
|
-
throw new Error(`Unsupported file format for formatting cells: ${fileExtension}. Supported: .xlsx`);
|
|
225
|
-
workbook = await readWorkbook();
|
|
226
|
-
let worksheetFormat = getWorksheet(workbook, sheetName);
|
|
227
|
-
// This is a simplified example. Real formatting is complex with XLSX.
|
|
228
|
-
// XLSX.utils.format_cell is not for writing styles, but for formatting values.
|
|
229
|
-
// To apply styles, you typically need to manipulate the cell object directly
|
|
230
|
-
// or use a library that builds on top of XLSX for styling (e.g., exceljs, but that's another dependency).
|
|
231
|
-
// For now, we'll just acknowledge the request and return a message.
|
|
232
|
-
// A real implementation would involve iterating cells in the range and applying styles.
|
|
233
|
-
result = { message: `Formatting cells in range ${range} with provided formats (conceptual). Actual styling not fully implemented with basic XLSX.js.` };
|
|
234
|
-
await writeWorkbook(workbook); // Still write to save any other changes
|
|
235
|
-
break;
|
|
236
|
-
default:
|
|
237
|
-
throw new Error(`Unsupported action: ${action}`);
|
|
238
|
-
}
|
|
239
|
-
return result;
|
|
240
|
-
}
|
|
241
|
-
}
|
package/dist/nodes/stripe.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new charge in Stripe.
|
|
3
|
-
* @param {object} params - The parameters for the node.
|
|
4
|
-
* @param {string} params.apiKey - The Stripe secret key.
|
|
5
|
-
* @param {number} params.amount - The amount to charge, in cents.
|
|
6
|
-
* @param {string} params.currency - The currency of the charge.
|
|
7
|
-
* @param {string} params.source - The source of the charge (e.g., a token).
|
|
8
|
-
* @param {string} [params.description] - The description of the charge.
|
|
9
|
-
* @returns {Promise<object>} A promise that resolves to the created charge object.
|
|
10
|
-
*/
|
|
11
|
-
export class CreateChargeNode extends AsyncNode {
|
|
12
|
-
execAsync(): Promise<unknown>;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Retrieves the current account balance from Stripe.
|
|
16
|
-
* @param {object} params - The parameters for the node.
|
|
17
|
-
* @param {string} params.apiKey - The Stripe secret key.
|
|
18
|
-
* @returns {Promise<object>} A promise that resolves to the balance object.
|
|
19
|
-
*/
|
|
20
|
-
export class GetBalanceNode extends AsyncNode {
|
|
21
|
-
execAsync(): Promise<unknown>;
|
|
22
|
-
}
|
|
23
|
-
import { AsyncNode } from '../qflow.js';
|
package/dist/nodes/stripe.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { AsyncNode } from '../qflow.js';
|
|
2
|
-
import { log } from '../logger.js';
|
|
3
|
-
const API_BASE = 'https://api.stripe.com/v1';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a new charge in Stripe.
|
|
6
|
-
* @param {object} params - The parameters for the node.
|
|
7
|
-
* @param {string} params.apiKey - The Stripe secret key.
|
|
8
|
-
* @param {number} params.amount - The amount to charge, in cents.
|
|
9
|
-
* @param {string} params.currency - The currency of the charge.
|
|
10
|
-
* @param {string} params.source - The source of the charge (e.g., a token).
|
|
11
|
-
* @param {string} [params.description] - The description of the charge.
|
|
12
|
-
* @returns {Promise<object>} A promise that resolves to the created charge object.
|
|
13
|
-
*/
|
|
14
|
-
export class CreateChargeNode extends AsyncNode {
|
|
15
|
-
async execAsync() {
|
|
16
|
-
const { apiKey, amount, currency, source, description } = this.params;
|
|
17
|
-
if (!apiKey || !amount || !currency || !source) {
|
|
18
|
-
throw new Error('Missing required parameters: apiKey, amount, currency, source');
|
|
19
|
-
}
|
|
20
|
-
log(`[Stripe] Creating charge for ${amount} ${currency}...`, this.params.logging);
|
|
21
|
-
const response = await fetch(`${API_BASE}/charges`, {
|
|
22
|
-
method: 'POST',
|
|
23
|
-
headers: {
|
|
24
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
25
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
26
|
-
},
|
|
27
|
-
body: new URLSearchParams({
|
|
28
|
-
amount,
|
|
29
|
-
currency,
|
|
30
|
-
source,
|
|
31
|
-
description
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
if (!response.ok) {
|
|
35
|
-
const errorData = await response.json();
|
|
36
|
-
throw new Error(`Stripe API error: ${response.status} - ${errorData.error.message}`);
|
|
37
|
-
}
|
|
38
|
-
const charge = await response.json();
|
|
39
|
-
log(`[Stripe] Successfully created charge ${charge.id}`, this.params.logging);
|
|
40
|
-
return charge;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Retrieves the current account balance from Stripe.
|
|
45
|
-
* @param {object} params - The parameters for the node.
|
|
46
|
-
* @param {string} params.apiKey - The Stripe secret key.
|
|
47
|
-
* @returns {Promise<object>} A promise that resolves to the balance object.
|
|
48
|
-
*/
|
|
49
|
-
export class GetBalanceNode extends AsyncNode {
|
|
50
|
-
async execAsync() {
|
|
51
|
-
const { apiKey } = this.params;
|
|
52
|
-
if (!apiKey) {
|
|
53
|
-
throw new Error('Missing required parameter: apiKey');
|
|
54
|
-
}
|
|
55
|
-
log('[Stripe] Getting account balance...', this.params.logging);
|
|
56
|
-
const response = await fetch(`${API_BASE}/balance`, {
|
|
57
|
-
headers: {
|
|
58
|
-
'Authorization': `Bearer ${apiKey}`
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
const errorData = await response.json();
|
|
63
|
-
throw new Error(`Stripe API error: ${response.status} - ${errorData.error.message}`);
|
|
64
|
-
}
|
|
65
|
-
const balance = await response.json();
|
|
66
|
-
log('[Stripe] Successfully retrieved account balance.', this.params.logging);
|
|
67
|
-
return balance;
|
|
68
|
-
}
|
|
69
|
-
}
|
package/dist/nodes/subflow.d.ts
DELETED
package/dist/nodes/subflow.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AsyncNode, AsyncFlow } from '../qflow.js';
|
|
2
|
-
export class SubFlowNode extends AsyncNode {
|
|
3
|
-
async execAsync() {
|
|
4
|
-
const { flow, shared } = this.params;
|
|
5
|
-
if (!flow || !(flow instanceof AsyncFlow)) {
|
|
6
|
-
throw new Error('SubFlowNode requires an `flow` parameter of type AsyncFlow.');
|
|
7
|
-
}
|
|
8
|
-
const subFlowShared = shared || {};
|
|
9
|
-
const result = await flow.runAsync(subFlowShared);
|
|
10
|
-
return result;
|
|
11
|
-
}
|
|
12
|
-
async postAsync(shared, prepRes, execRes) {
|
|
13
|
-
shared.subFlowResult = execRes;
|
|
14
|
-
return 'default';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Summarizes a given text using an LLM.
|
|
3
|
-
* @param {object} params - The parameters for the node.
|
|
4
|
-
* @param {string} params.text - The text content to summarize.
|
|
5
|
-
* @param {DeepSeekLLMNode} params.llmNode - An instance of an LLM node to perform the summarization.
|
|
6
|
-
* @returns {Promise<string>} A promise that resolves to the summarized text.
|
|
7
|
-
*/
|
|
8
|
-
export class SummarizeNode extends AsyncNode {
|
|
9
|
-
execAsync(): Promise<any>;
|
|
10
|
-
postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
|
|
11
|
-
}
|
|
12
|
-
import { AsyncNode } from '../qflow.js';
|
package/dist/nodes/summarize.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AsyncNode } from '../qflow.js';
|
|
2
|
-
import { DeepSeekLLMNode } from './llm.js'; // Assuming DeepSeekLLMNode for summarization
|
|
3
|
-
import { log } from '../logger.js';
|
|
4
|
-
/**
|
|
5
|
-
* Summarizes a given text using an LLM.
|
|
6
|
-
* @param {object} params - The parameters for the node.
|
|
7
|
-
* @param {string} params.text - The text content to summarize.
|
|
8
|
-
* @param {DeepSeekLLMNode} params.llmNode - An instance of an LLM node to perform the summarization.
|
|
9
|
-
* @returns {Promise<string>} A promise that resolves to the summarized text.
|
|
10
|
-
*/
|
|
11
|
-
export class SummarizeNode extends AsyncNode {
|
|
12
|
-
async execAsync() {
|
|
13
|
-
const { text, llmNode } = this.params;
|
|
14
|
-
if (!text) {
|
|
15
|
-
throw new Error('SummarizeNode requires a `text` parameter.');
|
|
16
|
-
}
|
|
17
|
-
if (!llmNode) {
|
|
18
|
-
throw new Error('SummarizeNode requires an `llmNode` instance for summarization.');
|
|
19
|
-
}
|
|
20
|
-
log(`[Summarize] Summarizing text (length: ${text.length})...`, this.params.logging);
|
|
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}`;
|
|
22
|
-
llmNode.setParams({ prompt: prompt, keyword: 'summarization' });
|
|
23
|
-
const summary = await llmNode.runAsync({});
|
|
24
|
-
log(`[Summarize] Summary generated (length: ${summary.length}).`, this.params.logging);
|
|
25
|
-
return summary;
|
|
26
|
-
}
|
|
27
|
-
async postAsync(shared, prepRes, execRes) {
|
|
28
|
-
shared.summary = execRes;
|
|
29
|
-
return 'default';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,50 +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 SystemNotificationNode extends AsyncNode {
|
|
6
|
-
constructor(maxRetries = 1, wait = 0) {
|
|
7
|
-
super(maxRetries, wait);
|
|
8
|
-
}
|
|
9
|
-
async execAsync() {
|
|
10
|
-
const { message, title = 'QFlow', icon = '' } = this.params;
|
|
11
|
-
if (!message) {
|
|
12
|
-
throw new Error('SystemNotificationNode requires a `message` parameter.');
|
|
13
|
-
}
|
|
14
|
-
let command = '';
|
|
15
|
-
const platform = os.platform();
|
|
16
|
-
switch (platform) {
|
|
17
|
-
case 'linux':
|
|
18
|
-
// Requires 'notify-send' (libnotify-bin package)
|
|
19
|
-
command = `notify-send "${title}" "${message}"`;
|
|
20
|
-
if (icon)
|
|
21
|
-
command += ` -i "${icon}"`;
|
|
22
|
-
break;
|
|
23
|
-
case 'darwin': // macOS
|
|
24
|
-
command = `osascript -e 'display notification "${message}" with title "${title}"'`;
|
|
25
|
-
// osascript doesn't directly support icons in this simple form
|
|
26
|
-
break;
|
|
27
|
-
case 'win32': // Windows
|
|
28
|
-
// Using PowerShell for a simple message box.
|
|
29
|
-
// For more advanced toast notifications, a dedicated module or more complex script would be needed.
|
|
30
|
-
command = `powershell -Command "[System.Windows.Forms.MessageBox]::Show(\"${message}\", \"${title}\")"`;
|
|
31
|
-
break;
|
|
32
|
-
default:
|
|
33
|
-
throw new Error(`Unsupported platform for SystemNotificationNode: ${platform}`);
|
|
34
|
-
}
|
|
35
|
-
log(`[SystemNotificationNode] Executing: ${command}`, this.params.logging);
|
|
36
|
-
return new Promise((resolve, reject) => {
|
|
37
|
-
exec(command, (error, stdout, stderr) => {
|
|
38
|
-
if (error) {
|
|
39
|
-
log(`SystemNotificationNode error: ${error.message}`, this.params.logging, { type: 'error' });
|
|
40
|
-
return reject(error);
|
|
41
|
-
}
|
|
42
|
-
if (stderr) {
|
|
43
|
-
log(`SystemNotificationNode stderr: ${stderr}`, this.params.logging, { type: 'warn' });
|
|
44
|
-
}
|
|
45
|
-
log(`Notification displayed: "${message}"`, this.params.logging);
|
|
46
|
-
resolve({ message, title, stdout, stderr });
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
package/dist/nodes/transform.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AsyncNode } from '../qflow.js';
|
|
2
|
-
import { log } from '../logger.js';
|
|
3
|
-
export class TransformNode extends AsyncNode {
|
|
4
|
-
async execAsync() {
|
|
5
|
-
const { input, transformFunction } = this.params;
|
|
6
|
-
if (transformFunction === undefined) {
|
|
7
|
-
throw new Error('TransformNode requires a `transformFunction`.');
|
|
8
|
-
}
|
|
9
|
-
let func;
|
|
10
|
-
try {
|
|
11
|
-
// Create a function from the string. This allows dynamic transformations.
|
|
12
|
-
// Using new Function() is powerful but requires careful handling of scope and security.
|
|
13
|
-
// For this context, we assume the user provides safe functions.
|
|
14
|
-
func = new Function('data', `return (${transformFunction})(data);`);
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
throw new Error(`Invalid transformFunction provided: ${e.message}`);
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const result = func(input);
|
|
21
|
-
log(`[TransformNode] Transformation complete. Result: ${JSON.stringify(result).substring(0, 100)}...`, this.params.logging);
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
throw new Error(`Error during transformation execution: ${e.message}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async postAsync(shared, prepRes, execRes) {
|
|
29
|
-
shared.transformedData = execRes;
|
|
30
|
-
return 'default';
|
|
31
|
-
}
|
|
32
|
-
}
|