Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

Merge branch 'pr-3505' into feat/release-3.56.0-batch

ra52b7877a189
diff --cc v3/@claude-flow/cli/src/mcp-tools/workflow-tools.ts
index 4046090183,39e757a531..94bfa29b92
--- a/v3/@claude-flow/cli/src/mcp-tools/workflow-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/workflow-tools.ts
@@@ -307,23 -289,25 +307,42 @@@ export const workflowTools: MCPTool[]
return { workflowId, error: 'Workflow already running' };
}
+ // Indices may name a step or the end boundary (used when resuming
+ // after the final step). Reject invalid control flow before any writes.
+ const validIndex = (value: unknown): value is number =>
+ typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 && value <= workflow.steps.length;
+ const startFromStep = input.startFromStep === undefined ? 0 : input.startFromStep;
+ if (!validIndex(startFromStep)) {
+ return { workflowId, error: `startFromStep must be an integer between 0 and ${workflow.steps.length}` };
+ }
+ for (const step of workflow.steps) {
+ if (step.type !== 'condition') continue;
+ for (const target of ['thenStep', 'elseStep']) {
+ if (step.config[target] !== undefined && !validIndex(step.config[target])) {
+ return { workflowId, error: `${step.stepId}.${target} must be an integer between 0 and ${workflow.steps.length}` };
+ }
+ }
+ }
+
+ const persistProgress = (): void => {
+ // An awaited step may overlap pause/stop/delete or a sibling workflow
+ // mutation. Merge only this workflow into the latest store snapshot.
+ const latest = loadWorkflowStore();
+ const current = latest.workflows[workflowId];
+ if (!current) {
+ workflow.status = 'failed';
+ workflow.error = 'Workflow was deleted during execution';
+ return;
+ }
+ if (current.status === 'failed') {
+ Object.assign(workflow, current);
+ return;
+ }
+ if (current.status === 'paused' && workflow.status !== 'failed') workflow.status = 'paused';
+ latest.workflows[workflowId] = workflow;
+ saveWorkflowStore(latest);
+ };
+
// Inject runtime variables
if (input.variables) {
workflow.variables = { ...workflow.variables, ...(input.variables as Record<string, unknown>) };
@@@ -331,7 -315,9 +350,9 @@@
workflow.status = 'running';
workflow.startedAt = new Date().toISOString();
+ delete workflow.error;
+ delete workflow.completedAt;
- workflow.currentStep = (input.startFromStep as number) || 0;
+ workflow.currentStep = startFromStep;
saveWorkflowStore(store);
// ADR-095 G3: real workflow runtime. Walk the steps in order;