@synergenius/flow-weaver 0.10.12 → 0.12.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.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: Flow Weaver Debugging
3
3
  description: Debugging workflows, validation, diagnostics, and error resolution
4
- keywords: [debug, troubleshooting, errors, WebSocket, diagnostics, runtime, validation, trace]
4
+ keywords: [debug, troubleshooting, errors, WebSocket, diagnostics, runtime, validation, trace, step-through, checkpoint, resume, breakpoint, crash-recovery, REPL]
5
5
  ---
6
6
 
7
7
  # Flow Weaver Debugging Guide
@@ -267,6 +267,153 @@ Use `--timeout <ms>` as a safeguard when running workflows that may block on unr
267
267
 
268
268
  See `built-in-nodes` for full documentation on mock configuration and testing patterns.
269
269
 
270
+ ## Step-Through Debugging
271
+
272
+ Flow Weaver supports pausing execution at node boundaries, inspecting all variable values, modifying them, and stepping through the workflow one node at a time. This works from both the CLI (interactive REPL) and MCP tools (for LLM-driven debugging).
273
+
274
+ The debug system intercepts execution at two points per node: before it runs (where you can inspect inputs and decide whether to proceed) and after it completes (where you can see its outputs before continuing to the next node).
275
+
276
+ ### CLI Debug Mode
277
+
278
+ ```bash
279
+ flow-weaver run workflow.ts --debug --params '{"x": 5}'
280
+ ```
281
+
282
+ This starts an interactive debug REPL. The workflow pauses before the first node and waits for your command:
283
+
284
+ ```
285
+ Flow Weaver Debug
286
+ Type "h" for help.
287
+
288
+ [paused] before: validate (1/5)
289
+ > s
290
+
291
+ validate.isValid = true
292
+
293
+ [paused] before: compute (2/5)
294
+ > i validate
295
+ validate:
296
+ isValid:0 = true
297
+
298
+ > set validate.isValid false
299
+ Set validate.isValid = false
300
+
301
+ > s
302
+ ```
303
+
304
+ Debug REPL commands:
305
+
306
+ | Command | Description |
307
+ |---------|-------------|
308
+ | `s`, `step` | Execute the next node, then pause |
309
+ | `c`, `continue` | Run to completion |
310
+ | `cb` | Run until the next breakpoint |
311
+ | `i`, `inspect` | Show all variables grouped by node |
312
+ | `i <node>` | Show variables for a specific node |
313
+ | `b <node>` | Add a breakpoint |
314
+ | `rb <node>` | Remove a breakpoint |
315
+ | `bl` | List all breakpoints |
316
+ | `set <node>.<port> <json>` | Modify a variable value |
317
+ | `q`, `quit` | Abort the debug session |
318
+ | `h`, `help` | Show command help |
319
+
320
+ You can set breakpoints at startup with `--breakpoint`:
321
+
322
+ ```bash
323
+ flow-weaver run workflow.ts --debug --breakpoint processData --breakpoint formatOutput
324
+ ```
325
+
326
+ ### MCP Debug Tools
327
+
328
+ For LLM-driven debugging via MCP, use these tools:
329
+
330
+ **`fw_debug_workflow`** starts a debug session. Pass the file path and optional parameters, breakpoints, and checkpoint flag. Returns a `debugId` and the initial pause state with all variable values, execution order, and current position.
331
+
332
+ **`fw_debug_step`** advances one node. Returns the updated state after the node completes.
333
+
334
+ **`fw_debug_continue`** runs to completion or to the next breakpoint (with `toBreakpoint: true`).
335
+
336
+ **`fw_debug_inspect`** reads the current state without advancing execution. Optionally filter to a specific node's variables.
337
+
338
+ **`fw_debug_set_variable`** modifies a variable value. Takes `nodeId`, `portName`, and the new `value`. The change takes effect when the next node executes.
339
+
340
+ **`fw_debug_breakpoint`** adds, removes, or lists breakpoints.
341
+
342
+ **`fw_list_debug_sessions`** shows all active debug sessions.
343
+
344
+ Example MCP sequence:
345
+
346
+ ```
347
+ 1. fw_debug_workflow(filePath: "workflow.ts", params: { x: 5 })
348
+ → { debugId: "debug-...", status: "paused", state: { currentNodeId: "validate", ... } }
349
+
350
+ 2. fw_debug_step(debugId: "debug-...")
351
+ → { status: "paused", state: { currentNodeId: "compute", variables: { "validate:isValid:0": true } } }
352
+
353
+ 3. fw_debug_set_variable(debugId: "debug-...", nodeId: "validate", portName: "isValid", value: false)
354
+ → { modified: "validate:isValid:0" }
355
+
356
+ 4. fw_debug_continue(debugId: "debug-...")
357
+ → { status: "completed", result: { ... } }
358
+ ```
359
+
360
+ ---
361
+
362
+ ## Checkpoint/Resume (Crash Recovery)
363
+
364
+ Checkpointing writes workflow state to disk after each node completes. If the process crashes mid-execution, the checkpoint file persists and can resume the workflow from the last completed node, skipping work that was already done.
365
+
366
+ ### Enabling Checkpoints
367
+
368
+ ```bash
369
+ flow-weaver run workflow.ts --checkpoint --params '{"data": "large-dataset"}'
370
+ ```
371
+
372
+ This creates a `.fw-checkpoints/` directory next to the workflow file containing one JSON file per run. The file is automatically deleted after successful completion, so you'll only see them after a crash.
373
+
374
+ ### Resuming from a Checkpoint
375
+
376
+ ```bash
377
+ # Auto-detect the most recent checkpoint
378
+ flow-weaver run workflow.ts --resume
379
+
380
+ # Specify a checkpoint file
381
+ flow-weaver run workflow.ts --resume .fw-checkpoints/myWorkflow-run-123.json
382
+
383
+ # Resume in debug mode (step through from the resume point)
384
+ flow-weaver run workflow.ts --resume --debug
385
+ ```
386
+
387
+ Via MCP: `fw_resume_from_checkpoint(filePath: "workflow.ts")`.
388
+
389
+ ### How It Works
390
+
391
+ After each node completes, the checkpoint writer serializes the execution context (all variable values, execution indices, and completion state) to a JSON file. On resume, the controller walks the topological execution order and skips nodes that have serialized outputs, restoring their values directly into the context.
392
+
393
+ If the workflow file has changed since the checkpoint was written (detected via SHA-256 hash), a warning is shown but execution proceeds.
394
+
395
+ ### Handling Non-Serializable Values
396
+
397
+ Not all values can survive serialization. Function values are invoked to get their concrete results. Promises and objects with circular references get marked as unserializable. When a checkpoint has unserializable outputs for a node, that node and all its downstream dependents are re-executed instead of being skipped.
398
+
399
+ On resume, the tool reports what happened:
400
+
401
+ ```
402
+ Resuming from checkpoint: .fw-checkpoints/pipeline-run-abc.json
403
+ Skipping 5 completed nodes
404
+ Re-running 2 nodes: processImage, formatOutput
405
+ ```
406
+
407
+ ### Checkpoint File Location
408
+
409
+ Checkpoints live in `.fw-checkpoints/` next to the workflow file. Add this to `.gitignore`:
410
+
411
+ ```
412
+ .fw-checkpoints/
413
+ ```
414
+
415
+ ---
416
+
270
417
  ## Dev Mode
271
418
 
272
419
  Use `flow-weaver dev` to watch, compile, and run in a single command:
@@ -281,10 +428,10 @@ This recompiles and re-runs automatically on every file save.
281
428
 
282
429
  ## Related Topics
283
430
 
284
- - `error-codes` Error code reference with fixes
285
- - `built-in-nodes` Mock system for delay, waitForEvent, invokeWorkflow
286
- - `cli-reference` All CLI commands and flags
287
- - `advanced-annotations` Pull execution, merge strategies, and other advanced features
431
+ - `error-codes` -- Error code reference with fixes
432
+ - `built-in-nodes` -- Mock system for delay, waitForEvent, invokeWorkflow
433
+ - `cli-reference` -- All CLI commands and flags
434
+ - `advanced-annotations` -- Pull execution, merge strategies, and other advanced features
288
435
 
289
436
  ## Still Stuck?
290
437
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synergenius/flow-weaver",
3
- "version": "0.10.12",
3
+ "version": "0.12.0",
4
4
  "description": "Deterministic workflow compiler for AI agents. Compiles to standalone TypeScript, no runtime dependencies.",
5
5
  "private": false,
6
6
  "type": "module",