@fractal-solutions/qflow 1.0.59 → 1.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -1
- package/dist/qflow.config.d.ts +5 -0
- package/dist/qflow.config.js +16 -0
- package/dist/src/agent/agent.d.ts +23 -0
- package/dist/src/agent/agent.js +365 -0
- package/dist/src/agent/base_agent.d.ts +21 -0
- package/dist/src/agent/base_agent.js +206 -0
- package/dist/src/agent/logger.d.ts +9 -0
- package/dist/src/agent/logger.js +45 -0
- package/dist/src/agent/lpavrl_agent.d.ts +5 -0
- package/dist/src/agent/lpavrl_agent.js +178 -0
- package/dist/src/agent/ooda_agent.d.ts +5 -0
- package/dist/src/agent/ooda_agent.js +167 -0
- package/dist/src/agent/pema_agent.d.ts +5 -0
- package/dist/src/agent/pema_agent.js +171 -0
- package/dist/src/agent/raor_agent.d.ts +5 -0
- package/dist/src/agent/raor_agent.js +164 -0
- package/dist/src/agent/tools.d.ts +1 -0
- package/dist/src/agent/tools.js +148 -0
- package/dist/src/logger.d.ts +9 -0
- package/dist/src/logger.js +107 -0
- package/dist/src/nodes/agent_llm.d.ts +31 -0
- package/dist/src/nodes/agent_llm.js +302 -0
- package/dist/src/nodes/browser_control.d.ts +35 -0
- package/dist/src/nodes/browser_control.js +106 -0
- package/dist/src/nodes/code_interpreter.d.ts +38 -0
- package/dist/src/nodes/code_interpreter.js +150 -0
- package/dist/src/nodes/data_extractor.d.ts +40 -0
- package/dist/src/nodes/data_extractor.js +118 -0
- package/dist/src/nodes/data_validation.d.ts +36 -0
- package/dist/src/nodes/data_validation.js +77 -0
- package/dist/src/nodes/database.d.ts +50 -0
- package/dist/src/nodes/database.js +135 -0
- package/dist/src/nodes/display_image.d.ts +18 -0
- package/dist/src/nodes/display_image.js +63 -0
- package/dist/src/nodes/embedding.d.ts +29 -0
- package/dist/src/nodes/embedding.js +69 -0
- package/dist/src/nodes/filesystem.d.ts +105 -0
- package/dist/src/nodes/filesystem.js +160 -0
- package/dist/src/nodes/gis.d.ts +62 -0
- package/dist/src/nodes/gis.js +133 -0
- package/dist/src/nodes/git.d.ts +46 -0
- package/dist/src/nodes/git.js +99 -0
- package/dist/src/nodes/github.d.ts +83 -0
- package/dist/src/nodes/github.js +135 -0
- package/dist/src/nodes/hackernews.d.ts +47 -0
- package/dist/src/nodes/hackernews.js +79 -0
- package/dist/src/nodes/hardware_interaction.d.ts +39 -0
- package/dist/src/nodes/hardware_interaction.js +131 -0
- package/dist/src/nodes/http.d.ts +77 -0
- package/dist/src/nodes/http.js +120 -0
- package/dist/src/nodes/http_server.d.ts +54 -0
- package/dist/src/nodes/http_server.js +223 -0
- package/dist/src/nodes/image_gallery.d.ts +37 -0
- package/dist/src/nodes/image_gallery.js +129 -0
- package/dist/src/nodes/index.d.ts +48 -0
- package/dist/src/nodes/index.js +48 -0
- package/dist/src/nodes/interactive_input.d.ts +26 -0
- package/dist/src/nodes/interactive_input.js +95 -0
- package/dist/src/nodes/interactive_webview.d.ts +78 -0
- package/dist/src/nodes/interactive_webview.js +369 -0
- package/dist/src/nodes/iterator.d.ts +23 -0
- package/dist/src/nodes/iterator.js +43 -0
- package/dist/src/nodes/llm.d.ts +160 -0
- package/dist/src/nodes/llm.js +367 -0
- package/dist/src/nodes/memory.d.ts +43 -0
- package/dist/src/nodes/memory.js +90 -0
- package/dist/src/nodes/multimedia_processing.d.ts +57 -0
- package/dist/src/nodes/multimedia_processing.js +129 -0
- package/dist/src/nodes/openrouter_llm.d.ts +38 -0
- package/dist/src/nodes/openrouter_llm.js +156 -0
- package/dist/src/nodes/pdf_processor.d.ts +43 -0
- package/dist/src/nodes/pdf_processor.js +112 -0
- package/dist/src/nodes/remote_execution.d.ts +51 -0
- package/dist/src/nodes/remote_execution.js +132 -0
- package/dist/src/nodes/s3.d.ts +73 -0
- package/dist/src/nodes/s3.js +107 -0
- package/dist/src/nodes/scheduler.d.ts +51 -0
- package/dist/src/nodes/scheduler.js +131 -0
- package/dist/src/nodes/search.d.ts +61 -0
- package/dist/src/nodes/search.js +118 -0
- package/dist/src/nodes/semantic_memory.d.ts +64 -0
- package/dist/src/nodes/semantic_memory.js +160 -0
- package/dist/src/nodes/shell.d.ts +25 -0
- package/dist/src/nodes/shell.js +45 -0
- package/dist/src/nodes/speech_synthesis.d.ts +72 -0
- package/dist/src/nodes/speech_synthesis.js +171 -0
- package/dist/src/nodes/spreadsheet.d.ts +61 -0
- package/dist/src/nodes/spreadsheet.js +294 -0
- package/dist/src/nodes/stripe.d.ts +67 -0
- package/dist/src/nodes/stripe.js +117 -0
- package/dist/src/nodes/subflow.d.ts +23 -0
- package/dist/src/nodes/subflow.js +36 -0
- package/dist/src/nodes/summarize.d.ts +26 -0
- package/dist/src/nodes/summarize.js +51 -0
- package/dist/src/nodes/system_notification.d.ts +26 -0
- package/dist/src/nodes/system_notification.js +74 -0
- package/dist/src/nodes/transform.d.ts +23 -0
- package/dist/src/nodes/transform.js +52 -0
- package/dist/src/nodes/user.d.ts +25 -0
- package/dist/src/nodes/user.js +48 -0
- package/dist/src/nodes/webhook.d.ts +49 -0
- package/dist/src/nodes/webhook.js +161 -0
- package/dist/src/nodes/webscraper.d.ts +25 -0
- package/dist/src/nodes/webscraper.js +49 -0
- package/dist/src/nodes/websockets.d.ts +27 -0
- package/dist/src/nodes/websockets.js +98 -0
- package/dist/src/nodes/webview.d.ts +38 -0
- package/dist/src/nodes/webview.js +55 -0
- package/dist/src/qflow.d.ts +69 -0
- package/dist/src/qflow.js +320 -0
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a file from the file system.
|
|
3
|
+
* @param {object} params - The parameters for the node.
|
|
4
|
+
* @param {string} params.filePath - The path to the file to read.
|
|
5
|
+
* @returns {Promise<string>} A promise that resolves to the content of the file.
|
|
6
|
+
*/
|
|
7
|
+
export class ReadFileNode extends AsyncNode {
|
|
8
|
+
static getToolDefinition(): {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
parameters: {
|
|
12
|
+
type: string;
|
|
13
|
+
properties: {
|
|
14
|
+
filePath: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
required: string[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
execAsync(): Promise<string>;
|
|
23
|
+
postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Writes a file to the file system.
|
|
27
|
+
* @param {object} params - The parameters for the node.
|
|
28
|
+
* @param {string} params.filePath - The path to the file to write.
|
|
29
|
+
* @param {string} params.content - The content to write to the file.
|
|
30
|
+
* @returns {Promise<void>} A promise that resolves when the file has been written.
|
|
31
|
+
*/
|
|
32
|
+
export class WriteFileNode extends AsyncNode {
|
|
33
|
+
static getToolDefinition(): {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
parameters: {
|
|
37
|
+
type: string;
|
|
38
|
+
properties: {
|
|
39
|
+
filePath: {
|
|
40
|
+
type: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
content: {
|
|
44
|
+
type: string;
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
required: string[];
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
execAsync(): Promise<string>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Appends content to a file.
|
|
55
|
+
* @param {object} params - The parameters for the node.
|
|
56
|
+
* @param {string} params.filePath - The path to the file to append to.
|
|
57
|
+
* @param {string} params.content - The content to append to the file.
|
|
58
|
+
* @returns {Promise<void>} A promise that resolves when the content has been appended.
|
|
59
|
+
*/
|
|
60
|
+
export class AppendFileNode extends AsyncNode {
|
|
61
|
+
static getToolDefinition(): {
|
|
62
|
+
name: string;
|
|
63
|
+
description: string;
|
|
64
|
+
parameters: {
|
|
65
|
+
type: string;
|
|
66
|
+
properties: {
|
|
67
|
+
filePath: {
|
|
68
|
+
type: string;
|
|
69
|
+
description: string;
|
|
70
|
+
};
|
|
71
|
+
content: {
|
|
72
|
+
type: string;
|
|
73
|
+
description: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
required: string[];
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
execAsync(): Promise<string>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Lists the files in a directory.
|
|
83
|
+
* @param {object} params - The parameters for the node.
|
|
84
|
+
* @param {string} params.directoryPath - The path to the directory to list.
|
|
85
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of file names.
|
|
86
|
+
*/
|
|
87
|
+
export class ListDirectoryNode extends AsyncNode {
|
|
88
|
+
static getToolDefinition(): {
|
|
89
|
+
name: string;
|
|
90
|
+
description: string;
|
|
91
|
+
parameters: {
|
|
92
|
+
type: string;
|
|
93
|
+
properties: {
|
|
94
|
+
directoryPath: {
|
|
95
|
+
type: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
required: string[];
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
execAsync(): Promise<string[]>;
|
|
103
|
+
postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
|
|
104
|
+
}
|
|
105
|
+
import { AsyncNode } from '../qflow.js';
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { AsyncNode } from '../qflow.js';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { log } from '../logger.js';
|
|
5
|
+
/**
|
|
6
|
+
* Reads a file from the file system.
|
|
7
|
+
* @param {object} params - The parameters for the node.
|
|
8
|
+
* @param {string} params.filePath - The path to the file to read.
|
|
9
|
+
* @returns {Promise<string>} A promise that resolves to the content of the file.
|
|
10
|
+
*/
|
|
11
|
+
export class ReadFileNode extends AsyncNode {
|
|
12
|
+
static getToolDefinition() {
|
|
13
|
+
return {
|
|
14
|
+
name: "read_file",
|
|
15
|
+
description: "Reads file content.",
|
|
16
|
+
parameters: {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: {
|
|
19
|
+
filePath: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "The absolute path to the file to read."
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
required: ["filePath"]
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async execAsync() {
|
|
29
|
+
const { filePath } = this.params;
|
|
30
|
+
if (!filePath) {
|
|
31
|
+
throw new Error('Missing required parameter: filePath');
|
|
32
|
+
}
|
|
33
|
+
log(`[FileSystem] Reading file: ${filePath}`, this.params.logging);
|
|
34
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
35
|
+
log(`[FileSystem] Successfully read file: ${filePath}`, this.params.logging);
|
|
36
|
+
return content;
|
|
37
|
+
}
|
|
38
|
+
async postAsync(shared, prepRes, execRes) {
|
|
39
|
+
shared.fileContent = execRes;
|
|
40
|
+
return 'default';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Writes a file to the file system.
|
|
45
|
+
* @param {object} params - The parameters for the node.
|
|
46
|
+
* @param {string} params.filePath - The path to the file to write.
|
|
47
|
+
* @param {string} params.content - The content to write to the file.
|
|
48
|
+
* @returns {Promise<void>} A promise that resolves when the file has been written.
|
|
49
|
+
*/
|
|
50
|
+
export class WriteFileNode extends AsyncNode {
|
|
51
|
+
static getToolDefinition() {
|
|
52
|
+
return {
|
|
53
|
+
name: "write_file",
|
|
54
|
+
description: "Writes content to a file.",
|
|
55
|
+
parameters: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {
|
|
58
|
+
filePath: {
|
|
59
|
+
type: "string",
|
|
60
|
+
description: "The absolute path to the file to write to."
|
|
61
|
+
},
|
|
62
|
+
content: {
|
|
63
|
+
type: "string",
|
|
64
|
+
description: "The content to write to the file."
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
required: ["filePath", "content"]
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async execAsync() {
|
|
72
|
+
const { filePath, content } = this.params;
|
|
73
|
+
if (!filePath || content === undefined) {
|
|
74
|
+
throw new Error('Missing required parameters: filePath, content');
|
|
75
|
+
}
|
|
76
|
+
log(`[FileSystem] Writing to file: ${filePath}`, this.params.logging);
|
|
77
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
78
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
79
|
+
log(`[FileSystem] Successfully wrote to file: ${filePath}`, this.params.logging);
|
|
80
|
+
return 'default';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Appends content to a file.
|
|
85
|
+
* @param {object} params - The parameters for the node.
|
|
86
|
+
* @param {string} params.filePath - The path to the file to append to.
|
|
87
|
+
* @param {string} params.content - The content to append to the file.
|
|
88
|
+
* @returns {Promise<void>} A promise that resolves when the content has been appended.
|
|
89
|
+
*/
|
|
90
|
+
export class AppendFileNode extends AsyncNode {
|
|
91
|
+
static getToolDefinition() {
|
|
92
|
+
return {
|
|
93
|
+
name: "append_file",
|
|
94
|
+
description: "Appends content to a file.",
|
|
95
|
+
parameters: {
|
|
96
|
+
type: "object",
|
|
97
|
+
properties: {
|
|
98
|
+
filePath: {
|
|
99
|
+
type: "string",
|
|
100
|
+
description: "The absolute path to the file to append to."
|
|
101
|
+
},
|
|
102
|
+
content: {
|
|
103
|
+
type: "string",
|
|
104
|
+
description: "The content to append to the file."
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
required: ["filePath", "content"]
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async execAsync() {
|
|
112
|
+
const { filePath, content } = this.params;
|
|
113
|
+
if (!filePath || content === undefined) {
|
|
114
|
+
throw new Error('Missing required parameters: filePath, content');
|
|
115
|
+
}
|
|
116
|
+
log(`[FileSystem] Appending to file: ${filePath}`, this.params.logging);
|
|
117
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
118
|
+
await fs.appendFile(filePath, content, 'utf-8');
|
|
119
|
+
log(`[FileSystem] Successfully appended to file: ${filePath}`, this.params.logging);
|
|
120
|
+
return 'default';
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Lists the files in a directory.
|
|
125
|
+
* @param {object} params - The parameters for the node.
|
|
126
|
+
* @param {string} params.directoryPath - The path to the directory to list.
|
|
127
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of file names.
|
|
128
|
+
*/
|
|
129
|
+
export class ListDirectoryNode extends AsyncNode {
|
|
130
|
+
static getToolDefinition() {
|
|
131
|
+
return {
|
|
132
|
+
name: "list_directory",
|
|
133
|
+
description: "Lists directory contents.",
|
|
134
|
+
parameters: {
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
directoryPath: {
|
|
138
|
+
type: "string",
|
|
139
|
+
description: "The absolute path to the directory to list."
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
required: ["directoryPath"]
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async execAsync() {
|
|
147
|
+
const { directoryPath } = this.params;
|
|
148
|
+
if (!directoryPath) {
|
|
149
|
+
throw new Error('Missing required parameter: directoryPath');
|
|
150
|
+
}
|
|
151
|
+
log(`[FileSystem] Listing directory: ${directoryPath}`, this.params.logging);
|
|
152
|
+
const files = await fs.readdir(directoryPath);
|
|
153
|
+
log(`[FileSystem] Successfully listed directory: ${directoryPath}`, this.params.logging);
|
|
154
|
+
return files;
|
|
155
|
+
}
|
|
156
|
+
async postAsync(shared, prepRes, execRes) {
|
|
157
|
+
shared.directoryFiles = execRes;
|
|
158
|
+
return 'default';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export class GISNode extends AsyncNode {
|
|
2
|
+
static getToolDefinition(): {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
operation: {
|
|
9
|
+
type: string;
|
|
10
|
+
enum: string[];
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
provider: {
|
|
14
|
+
type: string;
|
|
15
|
+
enum: string[];
|
|
16
|
+
default: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
params: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
required: string[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
providers: {
|
|
28
|
+
google: GoogleMapsProvider;
|
|
29
|
+
openstreetmap: OpenStreetMapProvider;
|
|
30
|
+
};
|
|
31
|
+
execAsync(): Promise<any>;
|
|
32
|
+
}
|
|
33
|
+
import { AsyncNode } from '../qflow.js';
|
|
34
|
+
declare class GoogleMapsProvider {
|
|
35
|
+
constructor(apiKey: any);
|
|
36
|
+
apiKey: any;
|
|
37
|
+
baseUrl: string;
|
|
38
|
+
geocode(address: any): Promise<{
|
|
39
|
+
lat: any;
|
|
40
|
+
lng: any;
|
|
41
|
+
formattedAddress: any;
|
|
42
|
+
}>;
|
|
43
|
+
reverseGeocode(lat: any, lng: any): Promise<{
|
|
44
|
+
lat: number;
|
|
45
|
+
lng: number;
|
|
46
|
+
formattedAddress: any;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
declare class OpenStreetMapProvider {
|
|
50
|
+
baseUrl: string;
|
|
51
|
+
geocode(address: any): Promise<{
|
|
52
|
+
lat: number;
|
|
53
|
+
lng: number;
|
|
54
|
+
formattedAddress: any;
|
|
55
|
+
}>;
|
|
56
|
+
reverseGeocode(lat: any, lng: any): Promise<{
|
|
57
|
+
lat: number;
|
|
58
|
+
lng: number;
|
|
59
|
+
formattedAddress: any;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { AsyncNode, AsyncFlow } from '../qflow.js';
|
|
2
|
+
import { HttpRequestNode } from './index.js'; // For making HTTP requests to APIs
|
|
3
|
+
// Internal helper for Google Maps API calls
|
|
4
|
+
class GoogleMapsProvider {
|
|
5
|
+
constructor(apiKey) {
|
|
6
|
+
this.apiKey = apiKey;
|
|
7
|
+
this.baseUrl = "https://maps.googleapis.com/maps/api";
|
|
8
|
+
}
|
|
9
|
+
async geocode(address) {
|
|
10
|
+
if (!this.apiKey) {
|
|
11
|
+
throw new Error("Google Maps API Key is not configured for GoogleMapsProvider.");
|
|
12
|
+
}
|
|
13
|
+
const url = `${this.baseUrl}/geocode/json?address=${encodeURIComponent(address)}&key=${this.apiKey}`;
|
|
14
|
+
const httpRequest = new HttpRequestNode();
|
|
15
|
+
httpRequest.setParams({ url, method: 'GET' });
|
|
16
|
+
const response = await new AsyncFlow(httpRequest).runAsync({});
|
|
17
|
+
const data = response.body;
|
|
18
|
+
if (data.status === 'OK' && data.results.length > 0) {
|
|
19
|
+
const location = data.results[0].geometry.location;
|
|
20
|
+
return { lat: location.lat, lng: location.lng, formattedAddress: data.results[0].formatted_address };
|
|
21
|
+
}
|
|
22
|
+
throw new Error(`Google Geocoding failed: ${data.status || JSON.stringify(data)}`);
|
|
23
|
+
}
|
|
24
|
+
async reverseGeocode(lat, lng) {
|
|
25
|
+
if (!this.apiKey) {
|
|
26
|
+
throw new Error("Google Maps API Key is not configured for GoogleMapsProvider.");
|
|
27
|
+
}
|
|
28
|
+
const url = `${this.baseUrl}/geocode/json?latlng=${lat},${lng}&key=${this.apiKey}`;
|
|
29
|
+
const httpRequest = new HttpRequestNode();
|
|
30
|
+
httpRequest.setParams({ url, method: 'GET' });
|
|
31
|
+
const response = await new AsyncFlow(httpRequest).runAsync({});
|
|
32
|
+
const data = response.body;
|
|
33
|
+
if (data.status === 'OK' && data.results.length > 0) {
|
|
34
|
+
const result = data.results[0];
|
|
35
|
+
return { lat: parseFloat(result.geometry.location.lat), lng: parseFloat(result.geometry.location.lng), formattedAddress: result.formatted_address };
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`Google Reverse Geocoding failed: ${data.status || JSON.stringify(data)}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Internal helper for OpenStreetMap (Nominatim for geocoding)
|
|
41
|
+
class OpenStreetMapProvider {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.baseUrl = "https://nominatim.openstreetmap.org";
|
|
44
|
+
}
|
|
45
|
+
async geocode(address) {
|
|
46
|
+
const url = `${this.baseUrl}/search?q=${encodeURIComponent(address)}&format=json&limit=1`;
|
|
47
|
+
const httpRequest = new HttpRequestNode();
|
|
48
|
+
httpRequest.setParams({ url, method: 'GET', headers: { 'User-Agent': 'QFlowGISNode/1.0 (https://github.com/fractal-solutions/qflow)' } }); // Nominatim requires User-Agent
|
|
49
|
+
const response = await new AsyncFlow(httpRequest).runAsync({});
|
|
50
|
+
const data = response.body;
|
|
51
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
52
|
+
const result = data[0];
|
|
53
|
+
return { lat: parseFloat(result.lat), lng: parseFloat(result.lon), formattedAddress: result.display_name };
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`OpenStreetMap Geocoding failed: No results for ${address}`);
|
|
56
|
+
}
|
|
57
|
+
async reverseGeocode(lat, lng) {
|
|
58
|
+
const url = `${this.baseUrl}/reverse?lat=${lat}&lon=${lng}&format=json`;
|
|
59
|
+
const httpRequest = new HttpRequestNode();
|
|
60
|
+
httpRequest.setParams({ url, method: 'GET', headers: { 'User-Agent': 'QFlowGISNode/1.0 (https://github.com/fractal-solutions/qflow)' } }); // Nominatim requires User-Agent
|
|
61
|
+
const response = await new AsyncFlow(httpRequest).runAsync({});
|
|
62
|
+
const data = response.body;
|
|
63
|
+
if (data && data.display_name) {
|
|
64
|
+
return { lat: parseFloat(data.lat), lng: parseFloat(data.lon), formattedAddress: data.display_name };
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`OpenStreetMap Reverse Geocoding failed: No results for ${lat},${lng}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export class GISNode extends AsyncNode {
|
|
70
|
+
static getToolDefinition() {
|
|
71
|
+
return {
|
|
72
|
+
name: "gis",
|
|
73
|
+
description: "Performs Geographic Information System (GIS) operations like geocoding and reverse geocoding.",
|
|
74
|
+
parameters: {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: {
|
|
77
|
+
operation: {
|
|
78
|
+
type: "string",
|
|
79
|
+
enum: ["geocode", "reverseGeocode"],
|
|
80
|
+
description: "The GIS operation to perform: 'geocode' (address to coordinates) or 'reverseGeocode' (coordinates to address)."
|
|
81
|
+
},
|
|
82
|
+
provider: {
|
|
83
|
+
type: "string",
|
|
84
|
+
enum: ["google", "openstreetmap"],
|
|
85
|
+
default: "openstreetmap",
|
|
86
|
+
description: "The GIS service provider to use. Defaults to 'openstreetmap' (free, open-source)."
|
|
87
|
+
},
|
|
88
|
+
params: {
|
|
89
|
+
type: "object",
|
|
90
|
+
description: "Parameters specific to the operation. For 'geocode', requires { address: string }. For 'reverseGeocode', requires { lat: number, lng: number }."
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
required: ["operation", "params"]
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
constructor(maxRetries = 3, wait = 1) {
|
|
98
|
+
super(maxRetries, wait);
|
|
99
|
+
this.providers = {
|
|
100
|
+
google: new GoogleMapsProvider(process.env.GOOGLE_MAPS_API_KEY), // API key from env var
|
|
101
|
+
openstreetmap: new OpenStreetMapProvider(),
|
|
102
|
+
// Add other providers here (e.g., mapbox: new MapboxProvider(process.env.MAPBOX_API_KEY))
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async execAsync() {
|
|
106
|
+
const { operation, provider = 'openstreetmap', params } = this.params; // Default to openstreetmap
|
|
107
|
+
if (!operation) {
|
|
108
|
+
throw new Error('GISNode requires an `operation` parameter (e.g., "geocode", "reverseGeocode", "route").');
|
|
109
|
+
}
|
|
110
|
+
if (!this.providers[provider]) {
|
|
111
|
+
throw new Error(`GIS provider '${provider}' not supported or configured.`);
|
|
112
|
+
}
|
|
113
|
+
const currentProvider = this.providers[provider];
|
|
114
|
+
// Dispatch to the appropriate provider method based on operation
|
|
115
|
+
switch (operation) {
|
|
116
|
+
case 'geocode':
|
|
117
|
+
if (!params || !params.address) {
|
|
118
|
+
throw new Error('Geocode operation requires `params.address`.');
|
|
119
|
+
}
|
|
120
|
+
return await currentProvider.geocode(params.address);
|
|
121
|
+
case 'reverseGeocode':
|
|
122
|
+
if (!params || typeof params.lat !== 'number' || typeof params.lng !== 'number') {
|
|
123
|
+
throw new Error('Reverse Geocode operation requires `params.lat` and `params.lng` as numbers.');
|
|
124
|
+
}
|
|
125
|
+
return await currentProvider.reverseGeocode(params.lat, params.lng);
|
|
126
|
+
// Add other operations here
|
|
127
|
+
// case 'route':
|
|
128
|
+
// return await currentProvider.route(params.origin, params.destination);
|
|
129
|
+
default:
|
|
130
|
+
throw new Error(`Unsupported GIS operation: ${operation}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class GitNode extends AsyncNode {
|
|
2
|
+
static getToolDefinition(): {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
action: {
|
|
9
|
+
type: string;
|
|
10
|
+
enum: string[];
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
repoPath: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
remoteUrl: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
files: {
|
|
22
|
+
type: string;
|
|
23
|
+
items: {
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
message: {
|
|
29
|
+
type: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
branch: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
remote: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
required: string[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
execAsync(): Promise<{}>;
|
|
45
|
+
}
|
|
46
|
+
import { AsyncNode } from '../qflow.js';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AsyncNode } from '../qflow.js';
|
|
2
|
+
import simpleGit from 'simple-git';
|
|
3
|
+
export class GitNode extends AsyncNode {
|
|
4
|
+
static getToolDefinition() {
|
|
5
|
+
return {
|
|
6
|
+
name: "git",
|
|
7
|
+
description: "Performs Git operations like clone, add, commit, and push.",
|
|
8
|
+
parameters: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
action: {
|
|
12
|
+
type: "string",
|
|
13
|
+
enum: ["clone", "init", "add", "commit", "push", "pull", "status"],
|
|
14
|
+
description: "The Git action to perform."
|
|
15
|
+
},
|
|
16
|
+
repoPath: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "The local path to the repository."
|
|
19
|
+
},
|
|
20
|
+
remoteUrl: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "The URL of the remote repository (for 'clone' action)."
|
|
23
|
+
},
|
|
24
|
+
files: {
|
|
25
|
+
type: "array",
|
|
26
|
+
items: {
|
|
27
|
+
type: "string"
|
|
28
|
+
},
|
|
29
|
+
description: "An array of file paths to add to the staging area (for 'add' action)."
|
|
30
|
+
},
|
|
31
|
+
message: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "The commit message (for 'commit' action)."
|
|
34
|
+
},
|
|
35
|
+
branch: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "The branch to push to or pull from."
|
|
38
|
+
},
|
|
39
|
+
remote: {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "The name of the remote (e.g., 'origin')."
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
required: ["action"]
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async execAsync() {
|
|
49
|
+
const { action, repoPath, remoteUrl, files, message, branch, remote = 'origin', } = this.params;
|
|
50
|
+
if (!repoPath && action !== 'clone') {
|
|
51
|
+
throw new Error('GitNode requires a `repoPath` for all actions except `clone`.');
|
|
52
|
+
}
|
|
53
|
+
const git = simpleGit(repoPath);
|
|
54
|
+
let result = {};
|
|
55
|
+
switch (action) {
|
|
56
|
+
case 'clone':
|
|
57
|
+
if (!remoteUrl || !repoPath)
|
|
58
|
+
throw new Error('`remoteUrl` and `repoPath` are required for `clone`.');
|
|
59
|
+
await git.clone(remoteUrl, repoPath);
|
|
60
|
+
result = { message: `Repository cloned from ${remoteUrl} to ${repoPath}` };
|
|
61
|
+
break;
|
|
62
|
+
case 'init':
|
|
63
|
+
await git.init();
|
|
64
|
+
result = { message: `Initialized empty Git repository in ${repoPath}` };
|
|
65
|
+
break;
|
|
66
|
+
case 'add':
|
|
67
|
+
if (!files)
|
|
68
|
+
throw new Error('`files` parameter is required for `add` action.');
|
|
69
|
+
await git.add(files);
|
|
70
|
+
result = { message: `Files added: ${files.join(', ')}` };
|
|
71
|
+
break;
|
|
72
|
+
case 'commit':
|
|
73
|
+
if (!message)
|
|
74
|
+
throw new Error('`message` parameter is required for `commit` action.');
|
|
75
|
+
const commitResult = await git.commit(message);
|
|
76
|
+
result = { message: 'Commit successful', ...commitResult };
|
|
77
|
+
break;
|
|
78
|
+
case 'push':
|
|
79
|
+
if (!branch)
|
|
80
|
+
throw new Error('`branch` parameter is required for `push` action.');
|
|
81
|
+
await git.push(remote, branch);
|
|
82
|
+
result = { message: `Pushed to ${remote}/${branch}` };
|
|
83
|
+
break;
|
|
84
|
+
case 'pull':
|
|
85
|
+
if (!branch)
|
|
86
|
+
throw new Error('`branch` parameter is required for `pull` action.');
|
|
87
|
+
await git.pull(remote, branch);
|
|
88
|
+
result = { message: `Pulled from ${remote}/${branch}` };
|
|
89
|
+
break;
|
|
90
|
+
case 'status':
|
|
91
|
+
const statusResult = await git.status();
|
|
92
|
+
result = statusResult;
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
throw new Error(`Unsupported Git action: ${action}`);
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new issue in a GitHub repository.
|
|
3
|
+
* @param {object} params - The parameters for the node.
|
|
4
|
+
* @param {string} params.token - The GitHub personal access token.
|
|
5
|
+
* @param {string} params.owner - The owner of the repository.
|
|
6
|
+
* @param {string} params.repo - The name of the repository.
|
|
7
|
+
* @param {string} params.title - The title of the issue.
|
|
8
|
+
* @param {string} [params.body] - The body of the issue.
|
|
9
|
+
* @returns {Promise<object>} A promise that resolves to the created issue object.
|
|
10
|
+
*/
|
|
11
|
+
export class CreateIssueNode extends AsyncNode {
|
|
12
|
+
static getToolDefinition(): {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
parameters: {
|
|
16
|
+
type: string;
|
|
17
|
+
properties: {
|
|
18
|
+
token: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
owner: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
repo: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
title: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
body: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
required: string[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
execAsync(): Promise<unknown>;
|
|
43
|
+
postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves an issue from a GitHub repository.
|
|
47
|
+
* @param {object} params - The parameters for the node.
|
|
48
|
+
* @param {string} params.token - The GitHub personal access token.
|
|
49
|
+
* @param {string} params.owner - The owner of the repository.
|
|
50
|
+
* @param {string} params.repo - The name of the repository.
|
|
51
|
+
* @param {number} params.issue_number - The number of the issue to retrieve.
|
|
52
|
+
* @returns {Promise<object>} A promise that resolves to the issue object.
|
|
53
|
+
*/
|
|
54
|
+
export class GetIssueNode extends AsyncNode {
|
|
55
|
+
static getToolDefinition(): {
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
parameters: {
|
|
59
|
+
type: string;
|
|
60
|
+
properties: {
|
|
61
|
+
token: {
|
|
62
|
+
type: string;
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
owner: {
|
|
66
|
+
type: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
repo: {
|
|
70
|
+
type: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
issue_number: {
|
|
74
|
+
type: string;
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
required: string[];
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
execAsync(): Promise<unknown>;
|
|
82
|
+
}
|
|
83
|
+
import { AsyncNode } from '../qflow.js';
|