Phase 3: Dynamic Workflow Engine - VM sandbox (node:vm) with agent/parallel/pipeline API, Claude Code compatible - Workflow file discovery (.boocode/workflows/*.js + ~/.boocode/workflows/*.js) - Workflow manager with session/chat creation and inference dispatch - Built-in catalog: deep-research, review-code, find-issues - Resumability cache: SHA-256 hash of agent spec, in-memory Map Phase 4: Background Subagents - background-task.ts service: spawn/poll/cancel lifecycle - spawn_subagent, subagent_status, subagent_result tools in ALL_TOOLS Phase 5: Multi-modal + Cache Shape - Multi-modal stub with type defs and hook point in payload.ts - CacheShapeBadge component in trace viewer (colored bar + %)
56 lines
1.7 KiB
Markdown
56 lines
1.7 KiB
Markdown
# Dynamic Workflow Engine — Design
|
|
|
|
## Architecture
|
|
|
|
```
|
|
User writes workflow JS file:
|
|
.boocode/workflows/my-flow.js
|
|
|
|
Workflow Runtime (apps/server)
|
|
├── isolated-vm sandbox (or node:vm)
|
|
├── API surface: agent(), parallel(), pipeline(), phase(), budget()
|
|
├── Tool bridge → BooCode's existing tool set
|
|
├── Workflow manager (concurrency, lifecycle)
|
|
├── Resumability cache (SHA-256 of agent spec)
|
|
└── Catalog (built-in workflows: deep-research, review-code)
|
|
|
|
Workflow execution:
|
|
1. User triggers workflow (slash command or Orchestrator panel)
|
|
2. File discovery finds .boocode/workflows/<name>.js
|
|
3. Sandbox compiles and executes the script
|
|
4. agent() calls go through tool bridge → existing inference pipeline
|
|
5. parallel() spawns concurrent agent calls (max 3 default)
|
|
6. Results stream via existing WS frames
|
|
7. Completed agents cached by hash for resume
|
|
|
|
API Surface (Claude Code compatible):
|
|
agent(prompt, { label?, schema?, model?, capabilities?, max_tool_calls? })
|
|
parallel([() => agent(...), () => agent(...)])
|
|
pipeline(items, ...stages)
|
|
phase(title)
|
|
log(message)
|
|
budget.total / budget.spent() / budget.remaining()
|
|
args
|
|
workflow(name, args?) — one level of nesting
|
|
```
|
|
|
|
## Implementation Plan
|
|
|
|
### Phase 1: Core Runtime (this session)
|
|
- Sandbox using Node's `vm` module (no extra deps)
|
|
- `agent()` function that creates a task and waits for completion
|
|
- Workflow file discovery
|
|
- Basic workflow manager
|
|
|
|
### Phase 2: Advanced Primitives
|
|
- `parallel()` with concurrency limits
|
|
- `pipeline()` streaming
|
|
- `budget()` token tracking
|
|
- Workflow resumability cache
|
|
|
|
### Phase 3: UI + Polish
|
|
- Integration with Orchestrator panel
|
|
- Built-in workflow catalog
|
|
- Workflow editor
|
|
- Error recovery
|