@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,160 +0,0 @@
|
|
|
1
|
-
import { AsyncNode, AsyncFlow } from '../qflow.js';
|
|
2
|
-
import { promises as fs } from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { EmbeddingNode } from './embedding.js';
|
|
5
|
-
import { log } from '../logger.js';
|
|
6
|
-
// Utility function for cosine similarity
|
|
7
|
-
function cosineSimilarity(vecA, vecB) {
|
|
8
|
-
let dotProduct = 0;
|
|
9
|
-
let magnitudeA = 0;
|
|
10
|
-
let magnitudeB = 0;
|
|
11
|
-
for (let i = 0; i < vecA.length; i++) {
|
|
12
|
-
dotProduct += vecA[i] * vecB[i];
|
|
13
|
-
magnitudeA += vecA[i] * vecA[i];
|
|
14
|
-
magnitudeB += vecB[i] * vecB[i];
|
|
15
|
-
}
|
|
16
|
-
magnitudeA = Math.sqrt(magnitudeA);
|
|
17
|
-
magnitudeB = Math.sqrt(magnitudeB);
|
|
18
|
-
if (magnitudeA === 0 || magnitudeB === 0)
|
|
19
|
-
return 0; // Avoid division by zero
|
|
20
|
-
return dotProduct / (magnitudeA * magnitudeB);
|
|
21
|
-
}
|
|
22
|
-
export class SemanticMemoryNode extends AsyncNode {
|
|
23
|
-
static getToolDefinition() {
|
|
24
|
-
return {
|
|
25
|
-
name: "semantic_memory_node",
|
|
26
|
-
description: "Stores and retrieves text memories via semantic search (requires Ollama).",
|
|
27
|
-
parameters: {
|
|
28
|
-
type: "object",
|
|
29
|
-
properties: {
|
|
30
|
-
action: {
|
|
31
|
-
type: "string",
|
|
32
|
-
enum: ["store", "retrieve"],
|
|
33
|
-
description: "The action to perform: 'store' a new memory or 'retrieve' existing ones."
|
|
34
|
-
},
|
|
35
|
-
content: {
|
|
36
|
-
type: "string",
|
|
37
|
-
description: "Required for 'store' action. The text content of the memory to store."
|
|
38
|
-
},
|
|
39
|
-
query: {
|
|
40
|
-
type: "string",
|
|
41
|
-
description: "Required for 'retrieve' action. The text query for semantic search."
|
|
42
|
-
},
|
|
43
|
-
id: {
|
|
44
|
-
type: "string",
|
|
45
|
-
description: "Optional for 'store' action. A unique identifier for the memory. If not provided, one will be generated."
|
|
46
|
-
},
|
|
47
|
-
metadata: {
|
|
48
|
-
type: "object",
|
|
49
|
-
description: "Optional for 'store' action. Key-value pairs to store alongside the memory."
|
|
50
|
-
},
|
|
51
|
-
memoryPath: {
|
|
52
|
-
type: "string",
|
|
53
|
-
description: "Optional. The directory path where memories and the index are stored. Defaults to './semantic_memories'."
|
|
54
|
-
},
|
|
55
|
-
embeddingModel: {
|
|
56
|
-
type: "string",
|
|
57
|
-
description: "Optional. The Ollama embedding model name to use (e.g., 'nomic-embed-text'). Defaults to 'nomic-embed-text'."
|
|
58
|
-
},
|
|
59
|
-
embeddingBaseUrl: {
|
|
60
|
-
type: "string",
|
|
61
|
-
description: "Optional. The base URL of the Ollama API for embeddings. Defaults to 'http://localhost:11434'."
|
|
62
|
-
},
|
|
63
|
-
topK: {
|
|
64
|
-
type: "number",
|
|
65
|
-
description: "Optional for 'retrieve' action. The number of top similar results to retrieve. Defaults to 5."
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
required: ["action"]
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
constructor() {
|
|
73
|
-
super();
|
|
74
|
-
this.memoryIndex = {}; // In-memory index: { id: { content: string, embedding: number[], metadata: object } }
|
|
75
|
-
this.indexFilePath = '';
|
|
76
|
-
this.memoriesDir = '';
|
|
77
|
-
}
|
|
78
|
-
async execAsync() {
|
|
79
|
-
const { action, content, query, id, metadata, memoryPath = './semantic_memories', embeddingModel, embeddingBaseUrl } = this.params;
|
|
80
|
-
this.memoriesDir = path.resolve(memoryPath);
|
|
81
|
-
this.indexFilePath = path.join(this.memoriesDir, 'index.json');
|
|
82
|
-
// Ensure memories directory exists
|
|
83
|
-
await fs.mkdir(this.memoriesDir, { recursive: true }).catch(() => { });
|
|
84
|
-
// Load existing index
|
|
85
|
-
try {
|
|
86
|
-
const indexContent = await fs.readFile(this.indexFilePath, 'utf-8');
|
|
87
|
-
this.memoryIndex = JSON.parse(indexContent);
|
|
88
|
-
}
|
|
89
|
-
catch (e) {
|
|
90
|
-
if (e.code === 'ENOENT') {
|
|
91
|
-
this.memoryIndex = {}; // File doesn't exist, start with empty index
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
throw new Error(`Failed to load memory index: ${e.message}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
switch (action) {
|
|
98
|
-
case 'store':
|
|
99
|
-
if (!content) {
|
|
100
|
-
throw new Error('Store action requires `content`.');
|
|
101
|
-
}
|
|
102
|
-
const memoryId = id || `sem_mem_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
|
|
103
|
-
// Generate embedding for the content
|
|
104
|
-
const embedNodeStore = new EmbeddingNode();
|
|
105
|
-
embedNodeStore.setParams({
|
|
106
|
-
text: content,
|
|
107
|
-
model: embeddingModel,
|
|
108
|
-
baseUrl: embeddingBaseUrl
|
|
109
|
-
});
|
|
110
|
-
const embedFlowStore = new AsyncFlow(embedNodeStore);
|
|
111
|
-
const embedResultStore = await embedFlowStore.runAsync({});
|
|
112
|
-
const embedding = embedResultStore.embedding;
|
|
113
|
-
this.memoryIndex[memoryId] = {
|
|
114
|
-
content: content,
|
|
115
|
-
embedding: embedding,
|
|
116
|
-
metadata: metadata || {},
|
|
117
|
-
};
|
|
118
|
-
// Save updated index
|
|
119
|
-
await fs.writeFile(this.indexFilePath, JSON.stringify(this.memoryIndex, null, 2), 'utf-8');
|
|
120
|
-
log(`[SemanticMemory] Stored memory: ${memoryId}`, this.params.logging);
|
|
121
|
-
return { status: 'stored', id: memoryId };
|
|
122
|
-
case 'retrieve':
|
|
123
|
-
if (!query) {
|
|
124
|
-
throw new Error('Retrieve action requires a `query`.');
|
|
125
|
-
}
|
|
126
|
-
log(`[SemanticMemory] Retrieving memories for query: "${query}"...`, this.params.logging);
|
|
127
|
-
if (Object.keys(this.memoryIndex).length === 0) {
|
|
128
|
-
log('[SemanticMemory] No memories stored. Returning empty.', this.params.logging);
|
|
129
|
-
return [];
|
|
130
|
-
}
|
|
131
|
-
// Generate embedding for the query
|
|
132
|
-
const embedNodeRetrieve = new EmbeddingNode();
|
|
133
|
-
embedNodeRetrieve.setParams({
|
|
134
|
-
text: query,
|
|
135
|
-
model: embeddingModel,
|
|
136
|
-
baseUrl: embeddingBaseUrl
|
|
137
|
-
});
|
|
138
|
-
const embedFlowRetrieve = new AsyncFlow(embedNodeRetrieve);
|
|
139
|
-
const embedResultRetrieve = await embedFlowRetrieve.runAsync({});
|
|
140
|
-
const queryEmbedding = embedResultRetrieve.embedding;
|
|
141
|
-
const similarities = [];
|
|
142
|
-
for (const memId in this.memoryIndex) {
|
|
143
|
-
const memory = this.memoryIndex[memId];
|
|
144
|
-
const similarity = cosineSimilarity(queryEmbedding, memory.embedding);
|
|
145
|
-
similarities.push({ id: memId, content: memory.content, metadata: memory.metadata, similarity: similarity });
|
|
146
|
-
}
|
|
147
|
-
// Sort by similarity (descending) and return top results
|
|
148
|
-
similarities.sort((a, b) => b.similarity - a.similarity);
|
|
149
|
-
const topResults = similarities.slice(0, this.params.topK || 5);
|
|
150
|
-
log(`[SemanticMemory] Retrieved ${topResults.length} semantic memories.`, this.params.logging);
|
|
151
|
-
return topResults;
|
|
152
|
-
default:
|
|
153
|
-
throw new Error(`Unsupported action: ${action}`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
async postAsync(shared, prepRes, execRes) {
|
|
157
|
-
shared.semanticMemoryResult = execRes;
|
|
158
|
-
return 'default';
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Executes a shell command as if in a terminal.
|
|
3
|
-
* @param {object} params - The parameters for the node.
|
|
4
|
-
* @param {string} params.command - The command string to execute (e.g., "ls -l" or "echo 'hello' > file.txt").
|
|
5
|
-
* @returns {Promise<object>} A promise that resolves to an object containing the stdout and stderr of the command.
|
|
6
|
-
*/
|
|
7
|
-
export class ShellCommandNode extends AsyncNode {
|
|
8
|
-
static getToolDefinition(): {
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
parameters: {
|
|
12
|
-
type: string;
|
|
13
|
-
properties: {
|
|
14
|
-
command: {
|
|
15
|
-
type: string;
|
|
16
|
-
description: string;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
required: string[];
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
execAsync(): Promise<any>;
|
|
23
|
-
postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
|
|
24
|
-
}
|
|
25
|
-
import { AsyncNode } from '../qflow.js';
|
package/dist/src/nodes/shell.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { AsyncNode } from '../qflow.js';
|
|
2
|
-
import { exec } from 'child_process';
|
|
3
|
-
/**
|
|
4
|
-
* Executes a shell command as if in a terminal.
|
|
5
|
-
* @param {object} params - The parameters for the node.
|
|
6
|
-
* @param {string} params.command - The command string to execute (e.g., "ls -l" or "echo 'hello' > file.txt").
|
|
7
|
-
* @returns {Promise<object>} A promise that resolves to an object containing the stdout and stderr of the command.
|
|
8
|
-
*/
|
|
9
|
-
export class ShellCommandNode extends AsyncNode {
|
|
10
|
-
static getToolDefinition() {
|
|
11
|
-
return {
|
|
12
|
-
name: "shell_command",
|
|
13
|
-
description: "Executes shell commands. When running long running processes like npm run dev or bun run dev, add an ampersand (&) to the end to run in the background eg. 'npm run dev &'",
|
|
14
|
-
parameters: {
|
|
15
|
-
type: "object",
|
|
16
|
-
properties: {
|
|
17
|
-
command: {
|
|
18
|
-
type: "string",
|
|
19
|
-
description: "The full shell command to execute (e.g., 'ls -l', 'npm install cheerio')."
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
required: ["command"]
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
async execAsync() {
|
|
27
|
-
const { command } = this.params;
|
|
28
|
-
if (!command) {
|
|
29
|
-
throw new Error('Missing required parameter: command');
|
|
30
|
-
}
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
exec(command, (error, stdout, stderr) => {
|
|
33
|
-
if (error) {
|
|
34
|
-
reject(error);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
resolve({ stdout, stderr });
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async postAsync(shared, prepRes, execRes) {
|
|
42
|
-
shared.shellResult = execRes;
|
|
43
|
-
return 'default';
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export class SpeechSynthesisNode extends AsyncNode {
|
|
2
|
-
static getToolDefinition(): {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
parameters: {
|
|
6
|
-
type: string;
|
|
7
|
-
properties: {
|
|
8
|
-
text: {
|
|
9
|
-
type: string;
|
|
10
|
-
description: string;
|
|
11
|
-
};
|
|
12
|
-
provider: {
|
|
13
|
-
type: string;
|
|
14
|
-
enum: string[];
|
|
15
|
-
description: string;
|
|
16
|
-
};
|
|
17
|
-
voice: {
|
|
18
|
-
type: string;
|
|
19
|
-
description: string;
|
|
20
|
-
};
|
|
21
|
-
outputFilePath: {
|
|
22
|
-
type: string;
|
|
23
|
-
description: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
required: string[];
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
providers: {
|
|
30
|
-
macos: MacOSSayProvider;
|
|
31
|
-
linux: LinuxEspeakProvider;
|
|
32
|
-
windows: WindowsSAPIProvider;
|
|
33
|
-
google: GoogleCloudTTSProvider;
|
|
34
|
-
};
|
|
35
|
-
execAsync(): Promise<{
|
|
36
|
-
status: string;
|
|
37
|
-
filePath?: undefined;
|
|
38
|
-
} | {
|
|
39
|
-
status: string;
|
|
40
|
-
filePath: any;
|
|
41
|
-
}>;
|
|
42
|
-
}
|
|
43
|
-
import { AsyncNode } from '../qflow.js';
|
|
44
|
-
declare class MacOSSayProvider {
|
|
45
|
-
synthesize(text: any, voice: any): Promise<{
|
|
46
|
-
command: string;
|
|
47
|
-
type: string;
|
|
48
|
-
}>;
|
|
49
|
-
}
|
|
50
|
-
declare class LinuxEspeakProvider {
|
|
51
|
-
synthesize(text: any, voice: any): Promise<{
|
|
52
|
-
command: string;
|
|
53
|
-
type: string;
|
|
54
|
-
}>;
|
|
55
|
-
}
|
|
56
|
-
declare class WindowsSAPIProvider {
|
|
57
|
-
synthesize(text: any, voice: any): Promise<void>;
|
|
58
|
-
}
|
|
59
|
-
declare class GoogleCloudTTSProvider {
|
|
60
|
-
constructor(apiKey: any);
|
|
61
|
-
apiKey: any;
|
|
62
|
-
baseUrl: string;
|
|
63
|
-
synthesize(text: any, voiceConfig?: {
|
|
64
|
-
languageCode: string;
|
|
65
|
-
name: string;
|
|
66
|
-
ssmlGender: string;
|
|
67
|
-
}): Promise<{
|
|
68
|
-
filePath: string;
|
|
69
|
-
type: string;
|
|
70
|
-
}>;
|
|
71
|
-
}
|
|
72
|
-
export {};
|
|
@@ -1,171 +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
|
-
static getToolDefinition() {
|
|
72
|
-
return {
|
|
73
|
-
name: "speech_synthesis",
|
|
74
|
-
description: "Converts text to spoken audio using OS capabilities or cloud APIs.",
|
|
75
|
-
parameters: {
|
|
76
|
-
type: "object",
|
|
77
|
-
properties: {
|
|
78
|
-
text: {
|
|
79
|
-
type: "string",
|
|
80
|
-
description: "The text to convert to speech."
|
|
81
|
-
},
|
|
82
|
-
provider: {
|
|
83
|
-
type: "string",
|
|
84
|
-
enum: ["macos", "linux", "windows", "google"],
|
|
85
|
-
description: "Optional. The speech synthesis provider to use. Defaults to OS-specific. 'google' requires GOOGLE_TTS_API_KEY."
|
|
86
|
-
},
|
|
87
|
-
voice: {
|
|
88
|
-
type: "string",
|
|
89
|
-
description: "Optional. The specific voice to use (e.g., 'Alex' for macOS, 'en-us' for espeak, 'en-US-Wavenet-D' for Google)."
|
|
90
|
-
},
|
|
91
|
-
outputFilePath: {
|
|
92
|
-
type: "string",
|
|
93
|
-
description: "Optional. If provided, saves the audio to this file path instead of playing it directly."
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
required: ["text"]
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
constructor(maxRetries = 1, wait = 0) {
|
|
101
|
-
super(maxRetries, wait);
|
|
102
|
-
this.providers = {
|
|
103
|
-
macos: new MacOSSayProvider(),
|
|
104
|
-
linux: new LinuxEspeakProvider(),
|
|
105
|
-
windows: new WindowsSAPIProvider(), // Placeholder for Windows
|
|
106
|
-
google: new GoogleCloudTTSProvider(process.env.GOOGLE_TTS_API_KEY), // Requires API key
|
|
107
|
-
// Add other providers here
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
async execAsync() {
|
|
111
|
-
const { text, provider, voice, outputFilePath } = this.params;
|
|
112
|
-
if (!text) {
|
|
113
|
-
throw new Error('SpeechSynthesisNode requires `text` to synthesize.');
|
|
114
|
-
}
|
|
115
|
-
let selectedProvider;
|
|
116
|
-
let audioOutput;
|
|
117
|
-
// Determine provider based on OS or explicit parameter
|
|
118
|
-
if (provider) {
|
|
119
|
-
selectedProvider = this.providers[provider];
|
|
120
|
-
if (!selectedProvider) {
|
|
121
|
-
throw new Error(`Specified provider '${provider}' not supported or configured.`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
// Default to OS-specific provider
|
|
126
|
-
const platform = os.platform();
|
|
127
|
-
if (platform === 'darwin')
|
|
128
|
-
selectedProvider = this.providers.macos;
|
|
129
|
-
else if (platform === 'linux')
|
|
130
|
-
selectedProvider = this.providers.linux;
|
|
131
|
-
else if (platform === 'win32')
|
|
132
|
-
selectedProvider = this.providers.windows;
|
|
133
|
-
else
|
|
134
|
-
throw new Error(`Speech synthesis not supported on platform: ${platform}`);
|
|
135
|
-
}
|
|
136
|
-
// Synthesize speech
|
|
137
|
-
const synthesisResult = await selectedProvider.synthesize(text, voice);
|
|
138
|
-
// Handle audio output (play or save to file)
|
|
139
|
-
if (synthesisResult.type === 'shell') {
|
|
140
|
-
// Directly execute the shell command to play audio
|
|
141
|
-
const shellNode = new ShellCommandNode();
|
|
142
|
-
shellNode.setParams({ command: synthesisResult.command });
|
|
143
|
-
await new AsyncFlow(shellNode).runAsync({});
|
|
144
|
-
audioOutput = { status: 'played_via_shell' };
|
|
145
|
-
}
|
|
146
|
-
else if (synthesisResult.type === 'file') {
|
|
147
|
-
// Audio is saved to a file, now play it
|
|
148
|
-
const audioFilePath = outputFilePath || synthesisResult.filePath;
|
|
149
|
-
if (!outputFilePath) { // If not saving to a specific path, play it
|
|
150
|
-
const playCommand = os.platform() === 'darwin' ? `afplay "${audioFilePath}"` :
|
|
151
|
-
os.platform() === 'linux' ? `aplay "${audioFilePath}"` : // Requires aplay (alsa-utils)
|
|
152
|
-
os.platform() === 'win32' ? `start "" "${audioFilePath}"` : // Plays with default player
|
|
153
|
-
null;
|
|
154
|
-
if (!playCommand)
|
|
155
|
-
throw new Error(`Audio playback not supported on platform: ${os.platform()}`);
|
|
156
|
-
const shellNode = new ShellCommandNode();
|
|
157
|
-
shellNode.setParams({ command: playCommand });
|
|
158
|
-
await new AsyncFlow(shellNode).runAsync({});
|
|
159
|
-
audioOutput = { status: 'played_from_file', filePath: audioFilePath };
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
// If outputFilePath was provided, just return the path
|
|
163
|
-
audioOutput = { status: 'saved_to_file', filePath: audioFilePath };
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
throw new Error('Unsupported synthesis result type.');
|
|
168
|
-
}
|
|
169
|
-
return audioOutput;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export class SpreadsheetNode 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
|
-
filePath: {
|
|
14
|
-
type: string;
|
|
15
|
-
description: string;
|
|
16
|
-
};
|
|
17
|
-
sheetName: {
|
|
18
|
-
type: string;
|
|
19
|
-
description: string;
|
|
20
|
-
};
|
|
21
|
-
data: {
|
|
22
|
-
type: string;
|
|
23
|
-
description: string;
|
|
24
|
-
};
|
|
25
|
-
headerRow: {
|
|
26
|
-
type: string;
|
|
27
|
-
description: string;
|
|
28
|
-
};
|
|
29
|
-
range: {
|
|
30
|
-
type: string;
|
|
31
|
-
description: string;
|
|
32
|
-
};
|
|
33
|
-
startRow: {
|
|
34
|
-
type: string;
|
|
35
|
-
description: string;
|
|
36
|
-
};
|
|
37
|
-
numRows: {
|
|
38
|
-
type: string;
|
|
39
|
-
description: string;
|
|
40
|
-
};
|
|
41
|
-
newSheetName: {
|
|
42
|
-
type: string;
|
|
43
|
-
description: string;
|
|
44
|
-
};
|
|
45
|
-
formats: {
|
|
46
|
-
type: string;
|
|
47
|
-
description: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
required: string[];
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
execAsync(): Promise<any[] | {
|
|
54
|
-
sheets: string[];
|
|
55
|
-
message?: undefined;
|
|
56
|
-
} | {
|
|
57
|
-
message: string;
|
|
58
|
-
sheets?: undefined;
|
|
59
|
-
}>;
|
|
60
|
-
}
|
|
61
|
-
import { AsyncNode } from '../qflow.js';
|