@fractal-solutions/qflow 1.0.62 → 1.0.64
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/dist/agent/tools.d.ts +1 -5378
- package/dist/agent/tools.js +145 -1171
- package/dist/nodes/browser_control.d.ts +31 -0
- package/dist/nodes/browser_control.js +33 -0
- package/dist/nodes/code_interpreter.d.ts +29 -0
- package/dist/nodes/code_interpreter.js +29 -0
- package/dist/nodes/data_extractor.d.ts +35 -0
- package/dist/nodes/data_extractor.js +37 -0
- package/dist/nodes/data_validation.d.ts +27 -0
- package/dist/nodes/data_validation.js +29 -0
- package/dist/nodes/database.d.ts +44 -0
- package/dist/nodes/database.js +46 -0
- package/dist/nodes/display_image.d.ts +14 -0
- package/dist/nodes/display_image.js +16 -0
- package/dist/nodes/embedding.d.ts +22 -0
- package/dist/nodes/embedding.js +24 -0
- package/dist/nodes/filesystem.d.ts +64 -0
- package/dist/nodes/filesystem.js +72 -0
- package/dist/nodes/gis.d.ts +25 -0
- package/dist/nodes/gis.js +27 -0
- package/dist/nodes/git.d.ts +42 -0
- package/dist/nodes/git.js +44 -0
- package/dist/nodes/github.d.ts +56 -0
- package/dist/nodes/github.js +60 -0
- package/dist/nodes/hackernews.d.ts +28 -0
- package/dist/nodes/hackernews.js +32 -0
- package/dist/nodes/hardware_interaction.d.ts +31 -0
- package/dist/nodes/hardware_interaction.js +33 -0
- package/dist/nodes/http.d.ts +51 -0
- package/dist/nodes/http.js +53 -0
- package/dist/nodes/http_server.d.ts +37 -0
- package/dist/nodes/http_server.js +33 -0
- package/dist/nodes/image_gallery.d.ts +29 -0
- package/dist/nodes/image_gallery.js +29 -0
- package/dist/nodes/interactive_input.d.ts +22 -0
- package/dist/nodes/interactive_input.js +24 -0
- package/dist/nodes/interactive_webview.d.ts +59 -0
- package/dist/nodes/interactive_webview.js +59 -0
- package/dist/nodes/iterator.d.ts +18 -0
- package/dist/nodes/iterator.js +20 -0
- package/dist/nodes/llm.d.ts +142 -0
- package/dist/nodes/llm.js +152 -0
- package/dist/nodes/memory.d.ts +31 -0
- package/dist/nodes/memory.js +80 -38
- package/dist/nodes/multimedia_processing.d.ts +47 -0
- package/dist/nodes/multimedia_processing.js +49 -0
- package/dist/nodes/openrouter_llm.d.ts +30 -0
- package/dist/nodes/openrouter_llm.js +32 -0
- package/dist/nodes/pdf_processor.d.ts +39 -0
- package/dist/nodes/pdf_processor.js +37 -0
- package/dist/nodes/remote_execution.d.ts +47 -0
- package/dist/nodes/remote_execution.js +49 -0
- package/dist/nodes/s3.d.ts +67 -0
- package/dist/nodes/s3.js +69 -0
- package/dist/nodes/scheduler.d.ts +31 -0
- package/dist/nodes/scheduler.js +33 -0
- package/dist/nodes/search.d.ts +36 -0
- package/dist/nodes/search.js +40 -0
- package/dist/nodes/semantic_memory.d.ts +47 -0
- package/dist/nodes/semantic_memory.js +49 -0
- package/dist/nodes/shell.d.ts +14 -0
- package/dist/nodes/shell.js +16 -0
- package/dist/nodes/speech_synthesis.d.ts +27 -0
- package/dist/nodes/speech_synthesis.js +29 -0
- package/dist/nodes/spreadsheet.d.ts +51 -0
- package/dist/nodes/spreadsheet.js +53 -0
- package/dist/nodes/stripe.d.ts +44 -0
- package/dist/nodes/stripe.js +48 -0
- package/dist/nodes/subflow.d.ts +18 -0
- package/dist/nodes/subflow.js +20 -0
- package/dist/nodes/summarize.d.ts +14 -0
- package/dist/nodes/summarize.js +20 -0
- package/dist/nodes/system_notification.d.ts +22 -0
- package/dist/nodes/system_notification.js +24 -0
- package/dist/nodes/transform.d.ts +18 -0
- package/dist/nodes/transform.js +20 -0
- package/dist/nodes/user.d.ts +14 -0
- package/dist/nodes/user.js +16 -0
- package/dist/nodes/webhook.d.ts +34 -0
- package/dist/nodes/webhook.js +36 -0
- package/dist/nodes/webscraper.d.ts +14 -0
- package/dist/nodes/webscraper.js +16 -0
- package/dist/nodes/websockets.d.ts +23 -0
- package/dist/nodes/websockets.js +25 -0
- package/dist/nodes/webview.d.ts +26 -0
- package/dist/nodes/webview.js +28 -0
- package/package.json +3 -2
- package/dist/qflow.config.d.ts +0 -5
- package/dist/qflow.config.js +0 -16
- package/dist/src/agent/agent.d.ts +0 -23
- package/dist/src/agent/agent.js +0 -365
- package/dist/src/agent/base_agent.d.ts +0 -21
- package/dist/src/agent/base_agent.js +0 -206
- package/dist/src/agent/logger.d.ts +0 -9
- package/dist/src/agent/logger.js +0 -45
- package/dist/src/agent/lpavrl_agent.d.ts +0 -5
- package/dist/src/agent/lpavrl_agent.js +0 -178
- package/dist/src/agent/ooda_agent.d.ts +0 -5
- package/dist/src/agent/ooda_agent.js +0 -167
- package/dist/src/agent/pema_agent.d.ts +0 -5
- package/dist/src/agent/pema_agent.js +0 -171
- package/dist/src/agent/raor_agent.d.ts +0 -5
- package/dist/src/agent/raor_agent.js +0 -164
- package/dist/src/agent/tools.d.ts +0 -1
- package/dist/src/agent/tools.js +0 -148
- package/dist/src/logger.d.ts +0 -9
- package/dist/src/logger.js +0 -107
- package/dist/src/nodes/agent_llm.d.ts +0 -31
- package/dist/src/nodes/agent_llm.js +0 -302
- package/dist/src/nodes/browser_control.d.ts +0 -35
- package/dist/src/nodes/browser_control.js +0 -106
- package/dist/src/nodes/code_interpreter.d.ts +0 -38
- package/dist/src/nodes/code_interpreter.js +0 -150
- package/dist/src/nodes/data_extractor.d.ts +0 -40
- package/dist/src/nodes/data_extractor.js +0 -118
- package/dist/src/nodes/data_validation.d.ts +0 -36
- package/dist/src/nodes/data_validation.js +0 -77
- package/dist/src/nodes/database.d.ts +0 -50
- package/dist/src/nodes/database.js +0 -135
- package/dist/src/nodes/display_image.d.ts +0 -18
- package/dist/src/nodes/display_image.js +0 -63
- package/dist/src/nodes/embedding.d.ts +0 -29
- package/dist/src/nodes/embedding.js +0 -69
- package/dist/src/nodes/filesystem.d.ts +0 -105
- package/dist/src/nodes/filesystem.js +0 -160
- package/dist/src/nodes/gis.d.ts +0 -62
- package/dist/src/nodes/gis.js +0 -133
- package/dist/src/nodes/git.d.ts +0 -46
- package/dist/src/nodes/git.js +0 -99
- package/dist/src/nodes/github.d.ts +0 -83
- package/dist/src/nodes/github.js +0 -135
- package/dist/src/nodes/hackernews.d.ts +0 -47
- package/dist/src/nodes/hackernews.js +0 -79
- package/dist/src/nodes/hardware_interaction.d.ts +0 -39
- package/dist/src/nodes/hardware_interaction.js +0 -131
- package/dist/src/nodes/http.d.ts +0 -77
- package/dist/src/nodes/http.js +0 -120
- package/dist/src/nodes/http_server.d.ts +0 -54
- package/dist/src/nodes/http_server.js +0 -223
- package/dist/src/nodes/image_gallery.d.ts +0 -37
- package/dist/src/nodes/image_gallery.js +0 -129
- package/dist/src/nodes/index.d.ts +0 -48
- package/dist/src/nodes/index.js +0 -48
- package/dist/src/nodes/interactive_input.d.ts +0 -26
- package/dist/src/nodes/interactive_input.js +0 -95
- package/dist/src/nodes/interactive_webview.d.ts +0 -78
- package/dist/src/nodes/interactive_webview.js +0 -369
- package/dist/src/nodes/iterator.d.ts +0 -23
- package/dist/src/nodes/iterator.js +0 -43
- package/dist/src/nodes/llm.d.ts +0 -160
- package/dist/src/nodes/llm.js +0 -367
- package/dist/src/nodes/memory.d.ts +0 -43
- package/dist/src/nodes/memory.js +0 -90
- package/dist/src/nodes/multimedia_processing.d.ts +0 -57
- package/dist/src/nodes/multimedia_processing.js +0 -129
- package/dist/src/nodes/openrouter_llm.d.ts +0 -38
- package/dist/src/nodes/openrouter_llm.js +0 -156
- package/dist/src/nodes/pdf_processor.d.ts +0 -43
- package/dist/src/nodes/pdf_processor.js +0 -112
- package/dist/src/nodes/remote_execution.d.ts +0 -51
- package/dist/src/nodes/remote_execution.js +0 -132
- package/dist/src/nodes/s3.d.ts +0 -73
- package/dist/src/nodes/s3.js +0 -107
- package/dist/src/nodes/scheduler.d.ts +0 -51
- package/dist/src/nodes/scheduler.js +0 -131
- package/dist/src/nodes/search.d.ts +0 -61
- package/dist/src/nodes/search.js +0 -118
- package/dist/src/nodes/semantic_memory.d.ts +0 -64
- package/dist/src/nodes/semantic_memory.js +0 -160
- package/dist/src/nodes/shell.d.ts +0 -25
- package/dist/src/nodes/shell.js +0 -45
- package/dist/src/nodes/speech_synthesis.d.ts +0 -72
- package/dist/src/nodes/speech_synthesis.js +0 -171
- package/dist/src/nodes/spreadsheet.d.ts +0 -61
- package/dist/src/nodes/spreadsheet.js +0 -294
- package/dist/src/nodes/stripe.d.ts +0 -67
- package/dist/src/nodes/stripe.js +0 -117
- package/dist/src/nodes/subflow.d.ts +0 -23
- package/dist/src/nodes/subflow.js +0 -36
- package/dist/src/nodes/summarize.d.ts +0 -26
- package/dist/src/nodes/summarize.js +0 -51
- package/dist/src/nodes/system_notification.d.ts +0 -26
- package/dist/src/nodes/system_notification.js +0 -74
- package/dist/src/nodes/transform.d.ts +0 -23
- package/dist/src/nodes/transform.js +0 -52
- package/dist/src/nodes/user.d.ts +0 -25
- package/dist/src/nodes/user.js +0 -48
- package/dist/src/nodes/webhook.d.ts +0 -49
- package/dist/src/nodes/webhook.js +0 -161
- package/dist/src/nodes/webscraper.d.ts +0 -25
- package/dist/src/nodes/webscraper.js +0 -49
- package/dist/src/nodes/websockets.d.ts +0 -27
- package/dist/src/nodes/websockets.js +0 -98
- package/dist/src/nodes/webview.d.ts +0 -38
- package/dist/src/nodes/webview.js +0 -55
- package/dist/src/qflow.d.ts +0 -69
- package/dist/src/qflow.js +0 -320
- /package/dist/{src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{src/types.js → types.js} +0 -0
|
@@ -1,294 +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
|
-
static getToolDefinition() {
|
|
7
|
-
return {
|
|
8
|
-
name: "spreadsheet",
|
|
9
|
-
description: "Reads from and writes to spreadsheet files (.xlsx, .xls, .csv) with advanced manipulation.",
|
|
10
|
-
parameters: {
|
|
11
|
-
type: "object",
|
|
12
|
-
properties: {
|
|
13
|
-
action: {
|
|
14
|
-
type: "string",
|
|
15
|
-
enum: ["read", "write", "list_sheets", "read_range", "write_range", "append_rows", "delete_rows", "insert_rows", "add_sheet", "delete_sheet", "rename_sheet", "format_cells"],
|
|
16
|
-
description: "The action to perform."
|
|
17
|
-
},
|
|
18
|
-
filePath: {
|
|
19
|
-
type: "string",
|
|
20
|
-
description: "The absolute path to the spreadsheet file."
|
|
21
|
-
},
|
|
22
|
-
sheetName: {
|
|
23
|
-
type: "string",
|
|
24
|
-
description: "Required for .xlsx/.xls files and sheet-specific actions. The name of the sheet."
|
|
25
|
-
},
|
|
26
|
-
data: {
|
|
27
|
-
type: "array",
|
|
28
|
-
description: "Required for 'write', 'write_range', 'append_rows'. The data to write (array of arrays or array of objects)."
|
|
29
|
-
},
|
|
30
|
-
headerRow: {
|
|
31
|
-
type: "boolean",
|
|
32
|
-
description: "Optional. True if the first row is a header. Defaults to true."
|
|
33
|
-
},
|
|
34
|
-
range: {
|
|
35
|
-
type: "string",
|
|
36
|
-
description: "Required for 'read_range', 'write_range', 'format_cells'. A1 notation (e.g., 'Sheet1!A1:C10')."
|
|
37
|
-
},
|
|
38
|
-
startRow: {
|
|
39
|
-
type: "number",
|
|
40
|
-
description: "Required for 'delete_rows', 'insert_rows'. The 1-indexed starting row."
|
|
41
|
-
},
|
|
42
|
-
numRows: {
|
|
43
|
-
type: "number",
|
|
44
|
-
description: "Required for 'delete_rows', 'insert_rows'. The number of rows to delete/insert."
|
|
45
|
-
},
|
|
46
|
-
newSheetName: {
|
|
47
|
-
type: "string",
|
|
48
|
-
description: "Required for 'add_sheet', 'rename_sheet'. The name of the new sheet."
|
|
49
|
-
},
|
|
50
|
-
formats: {
|
|
51
|
-
type: "object",
|
|
52
|
-
description: "Required for 'format_cells'. Formatting options (conceptual, basic XLSX.js has limited styling)."
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
required: ["action", "filePath"]
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
constructor(maxRetries = 1, wait = 0) {
|
|
60
|
-
super(maxRetries, wait);
|
|
61
|
-
}
|
|
62
|
-
async execAsync() {
|
|
63
|
-
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'
|
|
64
|
-
sheetName, // Required for .xlsx/.xls read/write/management
|
|
65
|
-
data, // Required for 'write', 'write_range', 'append_rows'
|
|
66
|
-
headerRow = true, // For read/write
|
|
67
|
-
range, // A1 notation for 'read_range', 'write_range', 'format_cells'
|
|
68
|
-
startRow, // For 'delete_rows', 'insert_rows'
|
|
69
|
-
numRows, // For 'delete_rows', 'insert_rows'
|
|
70
|
-
startCol, // For 'delete_cols', 'insert_cols' (conceptual, not implementing now)
|
|
71
|
-
numCols, // For 'delete_cols', 'insert_cols' (conceptual, not implementing now)
|
|
72
|
-
newSheetName, // For 'rename_sheet'
|
|
73
|
-
formats // For 'format_cells'
|
|
74
|
-
} = this.params;
|
|
75
|
-
if (!filePath) {
|
|
76
|
-
throw new Error('SpreadsheetNode requires a `filePath` parameter.');
|
|
77
|
-
}
|
|
78
|
-
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)) {
|
|
79
|
-
throw new Error('SpreadsheetNode requires a valid `action`.');
|
|
80
|
-
}
|
|
81
|
-
const fileExtension = path.extname(filePath).toLowerCase();
|
|
82
|
-
let workbook;
|
|
83
|
-
let result;
|
|
84
|
-
// Helper to read workbook (for read/list_sheets/modify)
|
|
85
|
-
const readWorkbook = async () => {
|
|
86
|
-
try {
|
|
87
|
-
const fileBuffer = await fs.readFile(filePath);
|
|
88
|
-
return XLSX.read(fileBuffer, { type: 'buffer' });
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
throw new Error(`Failed to read spreadsheet file: ${e.message}. Ensure file exists and is accessible.`);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
// Helper to write workbook (for modify actions)
|
|
95
|
-
const writeWorkbook = async (wb) => {
|
|
96
|
-
try {
|
|
97
|
-
XLSX.writeFile(wb, filePath);
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
100
|
-
throw new Error(`Failed to write spreadsheet file: ${e.message}.`);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
// Helper to get worksheet
|
|
104
|
-
const getWorksheet = (wb, sName) => {
|
|
105
|
-
if (!sName)
|
|
106
|
-
throw new Error('`sheetName` is required for this action.');
|
|
107
|
-
const ws = wb.Sheets[sName];
|
|
108
|
-
if (!ws)
|
|
109
|
-
throw new Error(`Sheet '${sName}' not found in workbook.`);
|
|
110
|
-
return ws;
|
|
111
|
-
};
|
|
112
|
-
switch (action) {
|
|
113
|
-
case 'list_sheets':
|
|
114
|
-
if (!['.xlsx', '.xls'].includes(fileExtension)) {
|
|
115
|
-
throw new Error(`List sheets action only supported for .xlsx or .xls files. Got: ${fileExtension}`);
|
|
116
|
-
}
|
|
117
|
-
workbook = await readWorkbook();
|
|
118
|
-
result = { sheets: workbook.SheetNames };
|
|
119
|
-
break;
|
|
120
|
-
case 'read':
|
|
121
|
-
if (!['.xlsx', '.xls', '.csv'].includes(fileExtension)) {
|
|
122
|
-
throw new Error(`Unsupported file format for reading: ${fileExtension}. Supported: .xlsx, .xls, .csv`);
|
|
123
|
-
}
|
|
124
|
-
workbook = await readWorkbook();
|
|
125
|
-
let worksheetRead;
|
|
126
|
-
if (fileExtension === '.csv') {
|
|
127
|
-
worksheetRead = workbook.Sheets[workbook.SheetNames[0]];
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
worksheetRead = getWorksheet(workbook, sheetName);
|
|
131
|
-
}
|
|
132
|
-
result = XLSX.utils.sheet_to_json(worksheetRead, { header: headerRow ? 1 : 'A' });
|
|
133
|
-
break;
|
|
134
|
-
case 'read_range':
|
|
135
|
-
if (!range)
|
|
136
|
-
throw new Error('`range` is required for read_range.');
|
|
137
|
-
if (!['.xlsx', '.xls', '.csv'].includes(fileExtension)) {
|
|
138
|
-
throw new Error(`Unsupported file format for reading range: ${fileExtension}. Supported: .xlsx, .xls, .csv`);
|
|
139
|
-
}
|
|
140
|
-
workbook = await readWorkbook();
|
|
141
|
-
let worksheetReadRange;
|
|
142
|
-
if (fileExtension === '.csv') {
|
|
143
|
-
worksheetReadRange = workbook.Sheets[workbook.SheetNames[0]];
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
worksheetReadRange = getWorksheet(workbook, sheetName);
|
|
147
|
-
}
|
|
148
|
-
result = XLSX.utils.sheet_to_json(worksheetReadRange, { header: headerRow ? 1 : 'A', range: range });
|
|
149
|
-
break;
|
|
150
|
-
case 'write':
|
|
151
|
-
if (!data || !Array.isArray(data) || data.length === 0)
|
|
152
|
-
throw new Error('`data` is required for write.');
|
|
153
|
-
if (!['.xlsx', '.csv'].includes(fileExtension)) {
|
|
154
|
-
throw new Error(`Unsupported file format for writing: ${fileExtension}. Supported: .xlsx, .csv`);
|
|
155
|
-
}
|
|
156
|
-
workbook = XLSX.utils.book_new();
|
|
157
|
-
const worksheetToWrite = XLSX.utils.json_to_sheet(data, { skipHeader: !headerRow });
|
|
158
|
-
if (fileExtension === '.csv') {
|
|
159
|
-
const csvContent = XLSX.utils.sheet_to_csv(worksheetToWrite);
|
|
160
|
-
await fs.writeFile(filePath, csvContent);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
if (!sheetName)
|
|
164
|
-
throw new Error('`sheetName` is required for .xlsx write.');
|
|
165
|
-
XLSX.utils.book_append_sheet(workbook, worksheetToWrite, sheetName);
|
|
166
|
-
await writeWorkbook(workbook);
|
|
167
|
-
}
|
|
168
|
-
result = { message: `Successfully wrote data to ${filePath}` };
|
|
169
|
-
break;
|
|
170
|
-
case 'write_range':
|
|
171
|
-
if (!range || !data || !Array.isArray(data))
|
|
172
|
-
throw new Error('`range` and `data` are required for write_range.');
|
|
173
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
174
|
-
throw new Error(`Unsupported file format for writing range: ${fileExtension}. Supported: .xlsx`);
|
|
175
|
-
workbook = await readWorkbook();
|
|
176
|
-
let worksheetWriteRange = getWorksheet(workbook, sheetName);
|
|
177
|
-
XLSX.utils.sheet_add_json(worksheetWriteRange, data, { origin: range, skipHeader: !headerRow });
|
|
178
|
-
await writeWorkbook(workbook);
|
|
179
|
-
result = { message: `Successfully wrote data to range ${range} in ${filePath}` };
|
|
180
|
-
break;
|
|
181
|
-
case 'append_rows':
|
|
182
|
-
if (!data || !Array.isArray(data))
|
|
183
|
-
throw new Error('`data` is required for append_rows.');
|
|
184
|
-
if (!['.xlsx', '.csv'].includes(fileExtension))
|
|
185
|
-
throw new Error(`Unsupported file format for appending: ${fileExtension}. Supported: .xlsx, .csv`);
|
|
186
|
-
workbook = await readWorkbook();
|
|
187
|
-
let worksheetAppend;
|
|
188
|
-
if (fileExtension === '.csv') {
|
|
189
|
-
worksheetAppend = workbook.Sheets[workbook.SheetNames[0]];
|
|
190
|
-
const csvContent = XLSX.utils.sheet_to_csv(worksheetAppend) + '\n' + XLSX.utils.sheet_to_csv(XLSX.utils.json_to_sheet(data, { skipHeader: true }));
|
|
191
|
-
await fs.writeFile(filePath, csvContent);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
worksheetAppend = getWorksheet(workbook, sheetName);
|
|
195
|
-
XLSX.utils.sheet_add_json(worksheetAppend, data, { skipHeader: true, origin: -1 }); // -1 appends to end
|
|
196
|
-
await writeWorkbook(workbook);
|
|
197
|
-
}
|
|
198
|
-
result = { message: `Successfully appended rows to ${filePath}` };
|
|
199
|
-
break;
|
|
200
|
-
case 'delete_rows':
|
|
201
|
-
if (startRow === undefined || numRows === undefined)
|
|
202
|
-
throw new Error('`startRow` and `numRows` are required for delete_rows.');
|
|
203
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
204
|
-
throw new Error(`Unsupported file format for deleting rows: ${fileExtension}. Supported: .xlsx`);
|
|
205
|
-
const deleteRowsHelper = (ws, start, num) => {
|
|
206
|
-
const range = XLSX.utils.decode_range(ws['!ref']);
|
|
207
|
-
for (let R = start; R < range.e.r; ++R) {
|
|
208
|
-
for (let C = range.s.c; C <= range.e.c; ++C) {
|
|
209
|
-
ws[XLSX.utils.encode_cell({ r: R, c: C })] = ws[XLSX.utils.encode_cell({ r: R + num, c: C })];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
range.e.r -= num;
|
|
213
|
-
ws['!ref'] = XLSX.utils.encode_range(range.s, range.e);
|
|
214
|
-
};
|
|
215
|
-
workbook = await readWorkbook();
|
|
216
|
-
let worksheetDeleteRows = getWorksheet(workbook, sheetName);
|
|
217
|
-
deleteRowsHelper(worksheetDeleteRows, startRow - 1, numRows);
|
|
218
|
-
await writeWorkbook(workbook);
|
|
219
|
-
result = { message: `Successfully deleted ${numRows} rows starting from ${startRow} in ${filePath}` };
|
|
220
|
-
break;
|
|
221
|
-
case 'insert_rows':
|
|
222
|
-
if (startRow === undefined || numRows === undefined)
|
|
223
|
-
throw new Error('`startRow` and `numRows` are required for insert_rows.');
|
|
224
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
225
|
-
throw new Error(`Unsupported file format for inserting rows: ${fileExtension}. Supported: .xlsx`);
|
|
226
|
-
workbook = await readWorkbook();
|
|
227
|
-
let worksheetInsertRows = getWorksheet(workbook, sheetName);
|
|
228
|
-
XLSX.utils.sheet_add_aoa(worksheetInsertRows, Array(numRows).fill([]), { origin: startRow - 1 }); // Insert empty rows
|
|
229
|
-
await writeWorkbook(workbook);
|
|
230
|
-
result = { message: `Successfully inserted ${numRows} rows starting from ${startRow} in ${filePath}` };
|
|
231
|
-
break;
|
|
232
|
-
case 'add_sheet':
|
|
233
|
-
if (!newSheetName)
|
|
234
|
-
throw new Error('`newSheetName` is required for add_sheet.');
|
|
235
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
236
|
-
throw new Error(`Unsupported file format for adding sheet: ${fileExtension}. Supported: .xlsx`);
|
|
237
|
-
workbook = await readWorkbook();
|
|
238
|
-
if (workbook.SheetNames.includes(newSheetName))
|
|
239
|
-
throw new Error(`Sheet '${newSheetName}' already exists.`);
|
|
240
|
-
XLSX.utils.book_append_sheet(workbook, XLSX.utils.aoa_to_sheet([[]]), newSheetName); // Add empty sheet
|
|
241
|
-
await writeWorkbook(workbook);
|
|
242
|
-
result = { message: `Successfully added sheet '${newSheetName}' to ${filePath}` };
|
|
243
|
-
break;
|
|
244
|
-
case 'delete_sheet':
|
|
245
|
-
if (!sheetName)
|
|
246
|
-
throw new Error('`sheetName` is required for delete_sheet.');
|
|
247
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
248
|
-
throw new Error(`Unsupported file format for deleting sheet: ${fileExtension}. Supported: .xlsx`);
|
|
249
|
-
workbook = await readWorkbook();
|
|
250
|
-
if (!workbook.SheetNames.includes(sheetName))
|
|
251
|
-
throw new Error(`Sheet '${sheetName}' not found.`);
|
|
252
|
-
delete workbook.Sheets[sheetName];
|
|
253
|
-
workbook.SheetNames = workbook.SheetNames.filter(s => s !== sheetName);
|
|
254
|
-
await writeWorkbook(workbook);
|
|
255
|
-
result = { message: `Successfully deleted sheet '${sheetName}' from ${filePath}` };
|
|
256
|
-
break;
|
|
257
|
-
case 'rename_sheet':
|
|
258
|
-
if (!sheetName || !newSheetName)
|
|
259
|
-
throw new Error('`sheetName` and `newSheetName` are required for rename_sheet.');
|
|
260
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
261
|
-
throw new Error(`Unsupported file format for renaming sheet: ${fileExtension}. Supported: .xlsx`);
|
|
262
|
-
workbook = await readWorkbook();
|
|
263
|
-
if (!workbook.SheetNames.includes(sheetName))
|
|
264
|
-
throw new Error(`Sheet '${sheetName}' not found.`);
|
|
265
|
-
if (workbook.SheetNames.includes(newSheetName))
|
|
266
|
-
throw new Error(`Sheet '${newSheetName}' already exists.`);
|
|
267
|
-
workbook.SheetNames[workbook.SheetNames.indexOf(sheetName)] = newSheetName;
|
|
268
|
-
workbook.Sheets[newSheetName] = workbook.Sheets[sheetName];
|
|
269
|
-
delete workbook.Sheets[sheetName];
|
|
270
|
-
await writeWorkbook(workbook);
|
|
271
|
-
result = { message: `Successfully renamed sheet '${sheetName}' to '${newSheetName}' in ${filePath}` };
|
|
272
|
-
break;
|
|
273
|
-
case 'format_cells':
|
|
274
|
-
if (!range || !formats)
|
|
275
|
-
throw new Error('`range` and `formats` are required for format_cells.');
|
|
276
|
-
if (!['.xlsx'].includes(fileExtension))
|
|
277
|
-
throw new Error(`Unsupported file format for formatting cells: ${fileExtension}. Supported: .xlsx`);
|
|
278
|
-
workbook = await readWorkbook();
|
|
279
|
-
let worksheetFormat = getWorksheet(workbook, sheetName);
|
|
280
|
-
// This is a simplified example. Real formatting is complex with XLSX.
|
|
281
|
-
// XLSX.utils.format_cell is not for writing styles, but for formatting values.
|
|
282
|
-
// To apply styles, you typically need to manipulate the cell object directly
|
|
283
|
-
// or use a library that builds on top of XLSX for styling (e.g., exceljs, but that's another dependency).
|
|
284
|
-
// For now, we'll just acknowledge the request and return a message.
|
|
285
|
-
// A real implementation would involve iterating cells in the range and applying styles.
|
|
286
|
-
result = { message: `Formatting cells in range ${range} with provided formats (conceptual). Actual styling not fully implemented with basic XLSX.js.` };
|
|
287
|
-
await writeWorkbook(workbook); // Still write to save any other changes
|
|
288
|
-
break;
|
|
289
|
-
default:
|
|
290
|
-
throw new Error(`Unsupported action: ${action}`);
|
|
291
|
-
}
|
|
292
|
-
return result;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
@@ -1,67 +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
|
-
static getToolDefinition(): {
|
|
13
|
-
name: string;
|
|
14
|
-
description: string;
|
|
15
|
-
parameters: {
|
|
16
|
-
type: string;
|
|
17
|
-
properties: {
|
|
18
|
-
apiKey: {
|
|
19
|
-
type: string;
|
|
20
|
-
description: string;
|
|
21
|
-
};
|
|
22
|
-
amount: {
|
|
23
|
-
type: string;
|
|
24
|
-
description: string;
|
|
25
|
-
};
|
|
26
|
-
currency: {
|
|
27
|
-
type: string;
|
|
28
|
-
description: string;
|
|
29
|
-
};
|
|
30
|
-
source: {
|
|
31
|
-
type: string;
|
|
32
|
-
description: string;
|
|
33
|
-
};
|
|
34
|
-
description: {
|
|
35
|
-
type: string;
|
|
36
|
-
description: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
required: string[];
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
execAsync(): Promise<unknown>;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Retrieves the current account balance from Stripe.
|
|
46
|
-
* @param {object} params - The parameters for the node.
|
|
47
|
-
* @param {string} params.apiKey - The Stripe secret key.
|
|
48
|
-
* @returns {Promise<object>} A promise that resolves to the balance object.
|
|
49
|
-
*/
|
|
50
|
-
export class GetBalanceNode extends AsyncNode {
|
|
51
|
-
static getToolDefinition(): {
|
|
52
|
-
name: string;
|
|
53
|
-
description: string;
|
|
54
|
-
parameters: {
|
|
55
|
-
type: string;
|
|
56
|
-
properties: {
|
|
57
|
-
apiKey: {
|
|
58
|
-
type: string;
|
|
59
|
-
description: string;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
required: string[];
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
execAsync(): Promise<unknown>;
|
|
66
|
-
}
|
|
67
|
-
import { AsyncNode } from '../qflow.js';
|
package/dist/src/nodes/stripe.js
DELETED
|
@@ -1,117 +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
|
-
static getToolDefinition() {
|
|
16
|
-
return {
|
|
17
|
-
name: "stripe_create_charge",
|
|
18
|
-
description: "Creates a new charge in Stripe.",
|
|
19
|
-
parameters: {
|
|
20
|
-
type: "object",
|
|
21
|
-
properties: {
|
|
22
|
-
apiKey: {
|
|
23
|
-
type: "string",
|
|
24
|
-
description: "The Stripe secret key."
|
|
25
|
-
},
|
|
26
|
-
amount: {
|
|
27
|
-
type: "number",
|
|
28
|
-
description: "The amount to charge, in cents."
|
|
29
|
-
},
|
|
30
|
-
currency: {
|
|
31
|
-
type: "string",
|
|
32
|
-
description: "The currency of the charge (e.g., 'usd')."
|
|
33
|
-
},
|
|
34
|
-
source: {
|
|
35
|
-
type: "string",
|
|
36
|
-
description: "The source of the charge (e.g., a token or card ID)."
|
|
37
|
-
},
|
|
38
|
-
description: {
|
|
39
|
-
type: "string",
|
|
40
|
-
description: "Optional. The description of the charge."
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
required: ["apiKey", "amount", "currency", "source"]
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
async execAsync() {
|
|
48
|
-
const { apiKey, amount, currency, source, description } = this.params;
|
|
49
|
-
if (!apiKey || !amount || !currency || !source) {
|
|
50
|
-
throw new Error('Missing required parameters: apiKey, amount, currency, source');
|
|
51
|
-
}
|
|
52
|
-
log(`[Stripe] Creating charge for ${amount} ${currency}...`, this.params.logging);
|
|
53
|
-
const response = await fetch(`${API_BASE}/charges`, {
|
|
54
|
-
method: 'POST',
|
|
55
|
-
headers: {
|
|
56
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
57
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
58
|
-
},
|
|
59
|
-
body: new URLSearchParams({
|
|
60
|
-
amount,
|
|
61
|
-
currency,
|
|
62
|
-
source,
|
|
63
|
-
description
|
|
64
|
-
})
|
|
65
|
-
});
|
|
66
|
-
if (!response.ok) {
|
|
67
|
-
const errorData = await response.json();
|
|
68
|
-
throw new Error(`Stripe API error: ${response.status} - ${errorData.error.message}`);
|
|
69
|
-
}
|
|
70
|
-
const charge = await response.json();
|
|
71
|
-
log(`[Stripe] Successfully created charge ${charge.id}`, this.params.logging);
|
|
72
|
-
return charge;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Retrieves the current account balance from Stripe.
|
|
77
|
-
* @param {object} params - The parameters for the node.
|
|
78
|
-
* @param {string} params.apiKey - The Stripe secret key.
|
|
79
|
-
* @returns {Promise<object>} A promise that resolves to the balance object.
|
|
80
|
-
*/
|
|
81
|
-
export class GetBalanceNode extends AsyncNode {
|
|
82
|
-
static getToolDefinition() {
|
|
83
|
-
return {
|
|
84
|
-
name: "stripe_get_balance",
|
|
85
|
-
description: "Retrieves the current account balance from Stripe.",
|
|
86
|
-
parameters: {
|
|
87
|
-
type: "object",
|
|
88
|
-
properties: {
|
|
89
|
-
apiKey: {
|
|
90
|
-
type: "string",
|
|
91
|
-
description: "The Stripe secret key."
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
required: ["apiKey"]
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
async execAsync() {
|
|
99
|
-
const { apiKey } = this.params;
|
|
100
|
-
if (!apiKey) {
|
|
101
|
-
throw new Error('Missing required parameter: apiKey');
|
|
102
|
-
}
|
|
103
|
-
log('[Stripe] Getting account balance...', this.params.logging);
|
|
104
|
-
const response = await fetch(`${API_BASE}/balance`, {
|
|
105
|
-
headers: {
|
|
106
|
-
'Authorization': `Bearer ${apiKey}`
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
if (!response.ok) {
|
|
110
|
-
const errorData = await response.json();
|
|
111
|
-
throw new Error(`Stripe API error: ${response.status} - ${errorData.error.message}`);
|
|
112
|
-
}
|
|
113
|
-
const balance = await response.json();
|
|
114
|
-
log('[Stripe] Successfully retrieved account balance.', this.params.logging);
|
|
115
|
-
return balance;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export class SubFlowNode extends AsyncNode {
|
|
2
|
-
static getToolDefinition(): {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
parameters: {
|
|
6
|
-
type: string;
|
|
7
|
-
properties: {
|
|
8
|
-
flow: {
|
|
9
|
-
type: string;
|
|
10
|
-
description: string;
|
|
11
|
-
};
|
|
12
|
-
shared: {
|
|
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';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { AsyncNode, AsyncFlow } from '../qflow.js';
|
|
2
|
-
export class SubFlowNode extends AsyncNode {
|
|
3
|
-
static getToolDefinition() {
|
|
4
|
-
return {
|
|
5
|
-
name: "sub_flow",
|
|
6
|
-
description: "Executes a sub-flow.",
|
|
7
|
-
parameters: {
|
|
8
|
-
type: "object",
|
|
9
|
-
properties: {
|
|
10
|
-
flow: {
|
|
11
|
-
type: "string",
|
|
12
|
-
description: "The name of the flow to execute, as registered in the flow registry."
|
|
13
|
-
},
|
|
14
|
-
shared: {
|
|
15
|
-
type: "object",
|
|
16
|
-
description: "The shared object to pass to the sub-flow."
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
required: ["flow"]
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
async execAsync() {
|
|
24
|
-
const { flow, shared } = this.params;
|
|
25
|
-
if (!flow || !(flow instanceof AsyncFlow)) {
|
|
26
|
-
throw new Error('SubFlowNode requires an `flow` parameter of type AsyncFlow.');
|
|
27
|
-
}
|
|
28
|
-
const subFlowShared = shared || {};
|
|
29
|
-
const result = await flow.runAsync(subFlowShared);
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
async postAsync(shared, prepRes, execRes) {
|
|
33
|
-
shared.subFlowResult = execRes;
|
|
34
|
-
return 'default';
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,26 +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
|
-
static getToolDefinition(): {
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
parameters: {
|
|
13
|
-
type: string;
|
|
14
|
-
properties: {
|
|
15
|
-
text: {
|
|
16
|
-
type: string;
|
|
17
|
-
description: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
required: string[];
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
execAsync(): Promise<any>;
|
|
24
|
-
postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
|
|
25
|
-
}
|
|
26
|
-
import { AsyncNode } from '../qflow.js';
|
|
@@ -1,51 +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
|
-
static getToolDefinition() {
|
|
13
|
-
return {
|
|
14
|
-
name: "summarize_text",
|
|
15
|
-
description: "Summarizes a given text using an LLM.",
|
|
16
|
-
parameters: {
|
|
17
|
-
type: "object",
|
|
18
|
-
properties: {
|
|
19
|
-
text: {
|
|
20
|
-
type: "string",
|
|
21
|
-
description: "The text content to summarize."
|
|
22
|
-
},
|
|
23
|
-
// Note: llmNode itself cannot be directly passed as a tool parameter in JSON schema.
|
|
24
|
-
// The agent would need to be configured with a default summarization LLM,
|
|
25
|
-
// or the tool definition would need to specify parameters for an LLM to be instantiated.
|
|
26
|
-
// For now, we'll omit llmNode from the tool definition, assuming it's handled internally by the agent.
|
|
27
|
-
},
|
|
28
|
-
required: ["text"]
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
async execAsync() {
|
|
33
|
-
const { text, llmNode } = this.params;
|
|
34
|
-
if (!text) {
|
|
35
|
-
throw new Error('SummarizeNode requires a `text` parameter.');
|
|
36
|
-
}
|
|
37
|
-
if (!llmNode) {
|
|
38
|
-
throw new Error('SummarizeNode requires an `llmNode` instance for summarization.');
|
|
39
|
-
}
|
|
40
|
-
log(`[Summarize] Summarizing text (length: ${text.length})...`, this.params.logging);
|
|
41
|
-
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}`;
|
|
42
|
-
llmNode.setParams({ prompt: prompt, keyword: 'summarization' });
|
|
43
|
-
const summary = await llmNode.runAsync({});
|
|
44
|
-
log(`[Summarize] Summary generated (length: ${summary.length}).`, this.params.logging);
|
|
45
|
-
return summary;
|
|
46
|
-
}
|
|
47
|
-
async postAsync(shared, prepRes, execRes) {
|
|
48
|
-
shared.summary = execRes;
|
|
49
|
-
return 'default';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export class SystemNotificationNode extends AsyncNode {
|
|
2
|
-
static getToolDefinition(): {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
parameters: {
|
|
6
|
-
type: string;
|
|
7
|
-
properties: {
|
|
8
|
-
message: {
|
|
9
|
-
type: string;
|
|
10
|
-
description: string;
|
|
11
|
-
};
|
|
12
|
-
title: {
|
|
13
|
-
type: string;
|
|
14
|
-
description: string;
|
|
15
|
-
};
|
|
16
|
-
icon: {
|
|
17
|
-
type: string;
|
|
18
|
-
description: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
required: string[];
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
execAsync(): Promise<any>;
|
|
25
|
-
}
|
|
26
|
-
import { AsyncNode } from '../qflow.js';
|