Skip to content

Port OpenCode orchestrator to Dart/Flutter for native mobile support #4

@EightRice

Description

@EightRice

Summary

Port the OpenCode orchestrator mode from Python to Dart, enabling the Flutter app (sidekick-web) to run agent orchestration natively without requiring a separate daemon. This would enable true mobile-first agents.

Motivation

Currently Chevin runs as a Python daemon that the Flutter app connects to. For mobile use cases, this requires either:

  • Remote connection to a desktop/server daemon
  • Running Python via Termux (hacky)

With a native Dart orchestrator, the Flutter app becomes self-contained and can run on any platform Flutter supports (iOS, Android, macOS, Windows, Linux, Web).

The OpenCode mode is ideal for porting because it uses pure HTTP API calls to LLM providers - no native binaries or CLI dependencies.

Components to Port

Component Python File Complexity Notes
OpenCode Adapter opencode_adapter.py Low ~400 lines. HTTP calls via httpx → Dart http package
OpenCode Orchestrator opencode_orchestrator.py Medium ~500 lines. Main orchestration logic, event streaming
Engine Events engine.py (partial) Low Event types enum + simple data classes
Agent Registry agent_registry.py Low Track agent hierarchy - simple dict/tree
Task Store task_store.py Low JSON persistence - easy in Dart
User Profile user_profile.py Low Simple data model + JSON persistence
System Prompt Builder system_prompt.py Low String templating
Config config.py Low Data classes

What Does NOT Need Porting

  • sdk_wrapper.py - Claude SDK specific (not used in OpenCode mode)
  • orchestrator.py - Claude SDK orchestrator (not OpenCode)
  • delegate_tool.py - Claude SDK delegation (OpenCode has its own)
  • http.py - Server transport (Flutter IS the UI)
  • cli.py, cli_client.py - CLI interfaces
  • voice/ - Could port later if needed

Proposed Dart Structure

lib/chevin/
├── adapters/
│   └── opencode_adapter.dart   (~300 LOC)
├── core/
│   ├── engine_event.dart       (~100 LOC)
│   ├── agent_registry.dart     (~200 LOC)
│   ├── task_store.dart         (~200 LOC)
│   ├── user_profile.dart       (~150 LOC)
│   └── config.dart             (~100 LOC)
├── orchestrator.dart           (~500 LOC)
└── system_prompt.dart          (~200 LOC)

Estimated total: ~1,500-2,000 lines of Dart

Dart Package Equivalents

Python Dart
httpx.AsyncClient http or dio package
asyncio / async for Stream<T> / await for
dataclass Dart classes with json_serializable
Path / file I/O path_provider + dart:io
logging logger package

Effort Estimate

1-2 weeks for a working MVP with focused effort.

Benefits

  • True offline-capable mobile agents (with local models)
  • No daemon dependency for basic use cases
  • Same architecture/protocol as Python version
  • Cross-platform from single codebase

Labels

enhancement, sidekick-web, mobile

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions