secondbrainos-mcp-server 1.4.1 → 1.4.3
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/build/index.js +42 -33
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -476,7 +476,13 @@ class SecondBrainOSServer {
|
|
|
476
476
|
async interceptFilePathArgs(args) {
|
|
477
477
|
const result = { ...args };
|
|
478
478
|
for (const [key, value] of Object.entries(result)) {
|
|
479
|
-
if (
|
|
479
|
+
if (Array.isArray(value)) {
|
|
480
|
+
result[key] = await Promise.all(value.map(async (item) => typeof item === 'object' && item !== null
|
|
481
|
+
? this.interceptFilePathArgs(item)
|
|
482
|
+
: item));
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if (typeof value === 'object' && value !== null) {
|
|
480
486
|
result[key] = await this.interceptFilePathArgs(value);
|
|
481
487
|
continue;
|
|
482
488
|
}
|
|
@@ -610,43 +616,46 @@ class SecondBrainOSServer {
|
|
|
610
616
|
console.error('Failed to write agent skill files:', error);
|
|
611
617
|
}
|
|
612
618
|
}
|
|
613
|
-
// 3. workflows
|
|
619
|
+
// 3. workflows (parallelized — each workflow fetched concurrently)
|
|
614
620
|
if (this.runPromptChainPath) {
|
|
615
621
|
try {
|
|
616
622
|
const data = await this.callRunPromptChain('', '');
|
|
617
|
-
const workflows = data.workflows || [];
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
623
|
+
const workflows = (data.workflows || []).filter((wf) => wf.name && wf.workflow_id);
|
|
624
|
+
await Promise.all(workflows.map(async (wf) => {
|
|
625
|
+
try {
|
|
626
|
+
const folderName = toSnakeCase(wf.name);
|
|
627
|
+
const workflowDetail = await this.callRunPromptChain('workflow', wf.workflow_id);
|
|
628
|
+
const promptIds = workflowDetail.prompt_id || [];
|
|
629
|
+
const promptResults = await Promise.all(promptIds.map(async (promptId) => {
|
|
630
|
+
try {
|
|
631
|
+
const promptData = await this.callRunPromptChain('prompt', promptId);
|
|
632
|
+
return {
|
|
633
|
+
id: promptId,
|
|
634
|
+
name: promptData.name,
|
|
635
|
+
order: promptData.order,
|
|
636
|
+
description: promptData.description || ''
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
catch {
|
|
640
|
+
return { id: promptId, name: '', order: 0, description: '' };
|
|
641
|
+
}
|
|
642
|
+
}));
|
|
643
|
+
const sortedPrompts = promptResults.sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
644
|
+
const workflowDocument = {
|
|
645
|
+
skill_id: wf.workflow_id,
|
|
646
|
+
name: wf.name,
|
|
647
|
+
description: wf.description || '',
|
|
648
|
+
prompts: sortedPrompts
|
|
649
|
+
};
|
|
650
|
+
writeSkill(path.join(skillsBase, 'workflows', folderName), `---\nname: secondbrainos_skill_${folderName}\ndescription: "${wf.description || wf.name}"\nuser-invocable: false\n---\n\n${JSON.stringify(workflowDocument, null, 2)}\n`);
|
|
651
|
+
}
|
|
652
|
+
catch (error) {
|
|
653
|
+
console.error(`Failed to write skill file for workflow "${wf.name}":`, error);
|
|
654
|
+
}
|
|
655
|
+
}));
|
|
647
656
|
}
|
|
648
657
|
catch (error) {
|
|
649
|
-
console.error('Failed to
|
|
658
|
+
console.error('Failed to fetch workflows for skill files:', error);
|
|
650
659
|
}
|
|
651
660
|
}
|
|
652
661
|
// 4. knowledgebases
|