## 1. Discovery and Dependencies - [x] 1.1 Confirm React Flow package choice (`@xyflow/react`) and add it to the workspace dependencies. - [x] 1.2 Confirm XState, p-queue, Croner, and SQLite package choices with runtime compatibility. - [x] 1.3 Define shared orchestration TypeScript contracts for workflows, nodes, edges, schedules, runs, events, and artifacts. - [x] 1.4 Decide whether initial persistence uses the current local runtime JSON store or SQLite immediately behind the repository interface. (Business orchestration now uses SQLite as primary storage when the local `sqlite3` CLI is available, with JSON shadow fallback.) ## 2. Workbench Entry - [x] 2.1 Reuse the existing `/workflow` route, sidebar item, and App Center card instead of adding a second workflow entry. - [x] 2.2 Audit the current `WorkflowPage`, `WORKFLOW_PRESETS`, and `/local-api/workflows/run` behavior. - [x] 2.3 Convert useful old presets into graph templates. - [x] 2.4 Ensure search and navigation route users into the rebuilt module. ## 3. Visual Editor - [x] 3.1 Create the main `BusinessOrchestrationPage` component. - [x] 3.2 Add the React Flow canvas with custom TrueGrowth node styling. - [x] 3.3 Add the node palette with supported node groups. - [x] 3.4 Support drag-to-create nodes, edge creation, node movement, delete, duplicate, zoom, minimap, and fit view. - [x] 3.5 Add the right inspector for detailed node configuration. - [x] 3.6 Add workflow-level settings for name, description, variables, concurrency, retry defaults, and failure behavior. - [x] 3.7 Add validation UI for cycles, missing required config, incompatible input/output contracts, and unsupported target capabilities. ## 4. Runtime DAG Engine - [x] 4.1 Implement graph validation and topological dependency planning. - [x] 4.2 Implement workflow and node lifecycle state transitions. - [x] 4.3 Add p-queue based global, provider, and platform concurrency limits. - [x] 4.4 Add cancellation, retry, timeout, skip, and partial-failure behavior. - [x] 4.5 Persist workflow run state and node events before and after transitions. - [x] 4.6 Expose local runtime endpoints for create/update workflow, validate, run, cancel, retry node, list runs, and stream events. ## 5. Real Node Adapters - [x] 5.1 Add an intelligence/news node adapter that outputs structured summaries and scripts. - [x] 5.2 Add an AI image node adapter using existing image/provider routes. - [x] 5.3 Add an AI video node adapter using existing video/provider routes. - [x] 5.4 Add a digital-human node adapter that outputs publishable video assets. - [x] 5.5 Add an intelligent editing node adapter using FunClip, FFmpeg, ASR, and subtitle bridge capabilities. - [x] 5.6 Add a publish-center node adapter that creates and tracks social publishing campaigns. - [x] 5.7 Normalize adapter progress, logs, output artifacts, and errors into orchestration events. ## 6. Scheduled Task Center - [x] 6.1 Add a scheduler tab/page inside the orchestration module. - [x] 6.2 Add cron expression, preset, timezone, start/end, overlap, and misfire controls. - [x] 6.3 Show next-run previews and validation messages. - [x] 6.4 Implement Croner-backed local scheduler registration and restore on runtime start. - [x] 6.5 Create immutable workflow runs for scheduled fires. - [x] 6.6 Add execution history, logs, artifacts, retry, cancel, enable/disable, and run-now actions. ## 7. Desktop Runtime Isolation - [x] 7.1 Keep orchestration APIs stable between browser dev and Electron packaged mode. - [x] 7.2 Move heavy FunClip/FFmpeg/ASR/browser publishing execution into Electron UtilityProcess where packaging requires it. - [x] 7.3 Add crash detection and recovery events for isolated sidecars. ## 8. Verification - [ ] 8.1 Validate the OpenSpec change with `openspec validate add-visual-business-orchestration --strict` when the CLI is available. (`pnpm exec openspec validate add-visual-business-orchestration --strict` is currently blocked because the `openspec` command is not installed in this workspace.) - [x] 8.2 Add unit tests for graph validation, topological ordering, cycle rejection, config validation, and scheduler next-run calculation. - [x] 8.3 Add runtime integration tests for a deterministic DAG with parallel branches, retries, cancellation, and recovery. - [x] 8.4 Add workbench tests for drag/drop creation, inspector editing, validation messages, save/load, run progress, and schedule creation. (Initial render, node add, schedule controls, schedule visibility, schedule request persistence, and run progress tests are in place.) - [x] 8.5 Add an end-to-end smoke test for a sample flow: news summary -> digital-human video -> intelligent edit -> publish draft. (Automated local API verifier covers validation, dependency order, execution, utility isolation, and social publishing draft/campaign artifact output.)