powr-sdk-api 4.0.0 → 4.1.0
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/routes/index.js +1 -1
- package/dist/services/tools.js +76 -9
- package/package.json +1 -1
package/dist/routes/index.js
CHANGED
|
@@ -51,7 +51,7 @@ const createPowrRoutes = (options = {}) => {
|
|
|
51
51
|
router.use('/profiles', verifyToken, profilesRoutes);
|
|
52
52
|
router.use('/chat', verifyToken, chatRoutes);
|
|
53
53
|
router.use('/feeds', verifyToken, feedsRoutes);
|
|
54
|
-
router.use('/tools', toolsRoutes);
|
|
54
|
+
router.use('/tools', verifyToken, toolsRoutes);
|
|
55
55
|
return router;
|
|
56
56
|
};
|
|
57
57
|
|
package/dist/services/tools.js
CHANGED
|
@@ -297,16 +297,83 @@ class ToolsManager {
|
|
|
297
297
|
return JSON.parse(Buffer.from(encryptedConfig, 'base64').toString());
|
|
298
298
|
}
|
|
299
299
|
async executeAction(tool, actionId, params, config) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
300
|
+
try {
|
|
301
|
+
switch (tool.name.toLowerCase()) {
|
|
302
|
+
case 'gmail':
|
|
303
|
+
return await this.executeGmailAction(actionId, params, config);
|
|
304
|
+
case 'slack':
|
|
305
|
+
return await this.executeSlackAction(actionId, params, config);
|
|
306
|
+
case 'github':
|
|
307
|
+
return await this.executeGitHubAction(actionId, params, config);
|
|
308
|
+
default:
|
|
309
|
+
return {
|
|
310
|
+
success: false,
|
|
311
|
+
message: `Tool ${tool.name} not implemented yet`
|
|
312
|
+
};
|
|
309
313
|
}
|
|
314
|
+
} catch (error) {
|
|
315
|
+
console.error(`❌ Error executing ${tool.name} action:`, error);
|
|
316
|
+
return {
|
|
317
|
+
success: false,
|
|
318
|
+
message: `Failed to execute ${actionId} on ${tool.name}: ${error.message}`
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async executeGmailAction(actionId, params, config) {
|
|
323
|
+
const nodemailer = require('nodemailer');
|
|
324
|
+
try {
|
|
325
|
+
// Create transporter
|
|
326
|
+
const transporter = nodemailer.createTransporter({
|
|
327
|
+
service: 'gmail',
|
|
328
|
+
auth: {
|
|
329
|
+
user: config.email,
|
|
330
|
+
pass: config.appPassword // Use app password for Gmail
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
switch (actionId) {
|
|
334
|
+
case 'send-email':
|
|
335
|
+
const mailOptions = {
|
|
336
|
+
from: config.email,
|
|
337
|
+
to: params.to,
|
|
338
|
+
subject: params.subject,
|
|
339
|
+
text: params.body
|
|
340
|
+
};
|
|
341
|
+
const result = await transporter.sendMail(mailOptions);
|
|
342
|
+
return {
|
|
343
|
+
success: true,
|
|
344
|
+
message: `Email sent successfully to ${params.to}`,
|
|
345
|
+
data: {
|
|
346
|
+
messageId: result.messageId,
|
|
347
|
+
to: params.to,
|
|
348
|
+
subject: params.subject
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
default:
|
|
352
|
+
return {
|
|
353
|
+
success: false,
|
|
354
|
+
message: `Unknown Gmail action: ${actionId}`
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
} catch (error) {
|
|
358
|
+
console.error('❌ Gmail execution error:', error);
|
|
359
|
+
return {
|
|
360
|
+
success: false,
|
|
361
|
+
message: `Failed to send email: ${error.message}`
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
async executeSlackAction(actionId, params, config) {
|
|
366
|
+
// TODO: Implement Slack actions
|
|
367
|
+
return {
|
|
368
|
+
success: false,
|
|
369
|
+
message: "Slack integration not implemented yet"
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
async executeGitHubAction(actionId, params, config) {
|
|
373
|
+
// TODO: Implement GitHub actions
|
|
374
|
+
return {
|
|
375
|
+
success: false,
|
|
376
|
+
message: "GitHub integration not implemented yet"
|
|
310
377
|
};
|
|
311
378
|
}
|
|
312
379
|
async testConnection(tool, config) {
|