emdash icon indicating copy to clipboard operation
emdash copied to clipboard

[feat]: Local HTTP API for Programmatic Task Creation

Open yarisoy opened this issue 6 months ago • 0 comments

Feature Summary

Expose emdash's task creation, project listing, and task listing through a localhost HTTP server so external agents and scripts can create fully provisioned tasks without direct database manipulation or UI automation.

Problem or Use Case

Emdash's parallel agent execution is only as fast as task intake. Currently, task creation is GUI-only, which bottlenecks at human speed. Users who want to integrate emdash into larger workflows have no supported path:

  1. The GUI (manual, not scriptable)
  2. Direct SQLite insertion (bypasses branch creation, worktree provisioning, event emission, and UI reactivity)
  3. Automating the Electron renderer via DevTools protocol (fragile, undocumented, security risk)

This blocks several high-value use cases:

  • Multi-agent orchestration: A meta-agent decomposes a large problem and spawns parallel emdash tasks programmatically, leveraging emdash's core differentiator (parallel agent execution) at machine speed.
  • Issue tracker integration: Scripts that pull from GitHub Issues, Linear, Jira, or any tracker can pipe work directly into emdash without manual copy-pasting.
  • CI/CD pipelines: Pipeline failure triggers a webhook that creates an emdash task with full context attached, no human in the loop for triage.
  • CLI-native workflows: Power users who live in the terminal can create tasks via curl or a thin CLI wrapper instead of context-switching to the GUI.

Without an official API, users will build direct-to-DB hacks that break invariants and corrupt state. Or they leave for tools that are scriptable. An API turns emdash from "tool you use" into "platform you build on."

Proposed Solution

A minimal HTTP server running inside the Electron main process, bound to 127.0.0.1 only (no remote exposure). It delegates to existing internal functions, ensuring all side effects (worktree provisioning, git branch creation, event emission, telemetry) happen correctly.

Endpoints:

  • GET /api/projects - returns all configured projects
  • GET /api/tasks?projectId=X - returns tasks, optionally filtered by project
  • POST /api/tasks - creates a fully provisioned task using the same code path as the GUI

Configuration:

  • Port defaults to 19234, configurable via EMDASH_API_PORT environment variable
  • Server starts automatically with the app and stops on quit
  • If port is in use, logs an error and the app continues normally without the API

UX:

  • Zero configuration required for default usage
  • External tools interact via standard HTTP (curl, Python requests, any language)
  • Structured JSON error responses matching existing CreateTaskError types
  • Project must be opened in emdash UI before tasks can be created against it via API

Integration:

  • Uses Node.js built-in http module (no new dependencies)
  • Calls existing createTask(), getProjects(), getTasks() functions directly
  • Two-line integration into app lifecycle (start after DB init, stop on quit)

Alternatives Considered

  • Unix domain socket: Slightly more secure (filesystem permissions), but less portable (Windows inconsistent, some HTTP clients need extra config for UDS).
  • Custom URL scheme (emdash://create-task?...): Fire-and-forget only, no response body, serializing complex params in a URL is painful.
  • File drop inbox (watch ~/.emdash/inbox/ for JSON files): No synchronous response channel, fs.watch is flaky across platforms.
  • Electron IPC via --remote-debugging-port: Exposes entire renderer, security risk, requires Chrome DevTools Protocol client.

Additional Context

I may be able to help develop this if approved.

yarisoy avatar May 12 '26 18:05 yarisoy