Skip to content

Proposal: Reduce deployment cost — make AgentFlow a zero-config OpenClaw native plugin #20

@Tweakzx

Description

@Tweakzx

Problem

Current AgentFlow deployment requires:

  1. pip install -e . — Python environment setup
  2. agentflow init --db ./data/agentflow.db — Manual DB initialization
  3. agentflow serve --db ./data/agentflow.db --port 8787 — A persistent Python process
  4. The OpenClaw plugin shells out to CLI (execFile("python3", ["-m", "agentflow.cli", ...])) for every operation

This is heavy for users who just want "agent task tracking + visualization". The Python service is a separate lifecycle to manage (start/stop/crash/restart), and the CLI bridge adds latency and fragility.

Proposal: Pure TypeScript OpenClaw Plugin

Rewrite the core as a pure TypeScript OpenClaw plugin that embeds better-sqlite3 (or better-sqlite3 bundled) instead of shelling out to Python.

Architecture

plugins/agentflow/
├── openclaw.plugin.json     # Plugin manifest
├── package.json             # Dependencies: better-sqlite3
├── index.ts                 # Plugin entry (register tools/commands/routes)
├── store.ts                 # SQLite wrapper (same schema, pure TS)
├── broker.ts                # In-process event broker + SSE
├── api.ts                   # REST API handlers (embedded in gateway)
└── console/
    └── index.html           # Static dashboard (served from plugin)

What Changes

Current Proposed
Python service (separate process) Embedded in OpenClaw gateway (same process)
pip install -e . npm install (or bundled with plugin)
agentflow init Auto-init on first use
agentflow serve --port 8787 Served on gateway port (e.g., /agentflow/)
CLI bridge (execFile python3) Direct function calls (zero IPC)
Separate port 8787 Gateway port (already running)
Python tests TypeScript tests

What Stays

  • Same SQLite schema — projects, tasks, runs, triggers, gate_profiles, etc.
  • Same REST API/api/tasks, /api/task/<id>/move, /api/flow, etc.
  • Same Web Console — Same HTML/CSS/JS, served as static file
  • Same OpenClaw plugin surface — tools, commands, HTTP routes

Concrete Benefits

  1. Zero-config install: openclaw plugin install agentflow → done
  2. No separate process: DB operations happen in-process, no IPC overhead
  3. Auto-init: First tool call creates the DB automatically
  4. Gateway-embedded UI: Dashboard at http://gateway:3000/agentflow/ — same auth, same port
  5. Better reliability: No process management, no Python path issues, no PYTHONPATH hacks
  6. Type safety: Plugin, store, and API all in TypeScript

Migration Path

  • Phase 1: Reimplement store.ts with better-sqlite3 (same schema)
  • Phase 2: Reimplement API handlers as OpenClaw HTTP routes
  • Phase 3: Bundle the HTML console as a static asset
  • Phase 4: Deprecate the Python CLI (keep for standalone use)

Why Not Fork

The Python CLI is still useful for:

  • Standalone use without OpenClaw
  • Scripting and automation
  • Non-OpenClaw environments

But the OpenClaw plugin path should not depend on it.

Open Questions

  1. Should the Python CLI remain as a separate package, or live alongside the TS plugin?
  2. Should the DB path be configurable via plugin config, or default to ~/.openclaw/agentflow.db?
  3. Should we use better-sqlite3 (native, fast) or sql.js (WASM, no native deps)?

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions