@leclabs/agent-flow-navigator-mcp 1.5.1 → 1.5.2
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/engine.js +12 -4
- package/package.json +1 -1
package/engine.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
17
|
-
import { join } from "path";
|
|
17
|
+
import { basename, join } from "path";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Read and parse a task file
|
|
@@ -672,11 +672,19 @@ export class WorkflowEngine {
|
|
|
672
672
|
if (taskFilePath) {
|
|
673
673
|
const task = readTaskFile(taskFilePath);
|
|
674
674
|
if (task) {
|
|
675
|
-
|
|
675
|
+
// Derive canonical ID from filename — this is the source of truth.
|
|
676
|
+
// Auto-corrects if task.id was corrupted by an external write.
|
|
677
|
+
const filenameId = basename(taskFilePath, ".json");
|
|
678
|
+
if (task.id !== filenameId) {
|
|
679
|
+
console.error(
|
|
680
|
+
`[Navigator] WARNING: task.id "${task.id}" does not match filename "${filenameId}.json" — auto-correcting`
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
const canonicalId = filenameId;
|
|
676
684
|
const userDesc = task.metadata?.userDescription || "";
|
|
677
685
|
task.metadata = { ...task.metadata, ...response.metadata };
|
|
678
686
|
task.subject = buildTaskSubject(
|
|
679
|
-
|
|
687
|
+
canonicalId,
|
|
680
688
|
userDesc,
|
|
681
689
|
response.metadata.workflowType,
|
|
682
690
|
response.currentStep,
|
|
@@ -693,7 +701,7 @@ export class WorkflowEngine {
|
|
|
693
701
|
if (response.orchestratorInstructions) {
|
|
694
702
|
task.description = response.orchestratorInstructions;
|
|
695
703
|
}
|
|
696
|
-
task.id =
|
|
704
|
+
task.id = canonicalId;
|
|
697
705
|
writeFileSync(taskFilePath, JSON.stringify(task, null, 2));
|
|
698
706
|
}
|
|
699
707
|
}
|