The NOT NULL constraint forced heartbeat runs to synthesize a fake task row (`[Heartbeat] X — Check for work`) so the FK could resolve. Three layers of code — acquireHeartbeatTask, findReusableHeartbeatTask, cleanupDuplicateHeartbeatTasks, plus the is_heartbeat flag column + UI filter — existed to paper over one bad constraint. Remove the constraint and the whole workaround vanishes. SQLite table rebuild with data preservation. Live production DB, no backup — migration is atomic, idempotent, and verified before DROP. ## Migration v35 (rebuild runs with nullable task_id) Uses `fn:` form so it can: - Snapshot `COUNT(*) FROM runs` before copy - Walk `PRAGMA table_info(runs)` to detect drift columns (v34 declared a column set; any additive ALTER since v14 shows up here) - Assert `COUNT(*) FROM runs_new == beforeCount` before `DROP TABLE runs` - `PRAGMA defer_foreign_keys = ON` so run_events(run_id) FK defers to commit time, by which runs has the same id set under the new name - Recreate all 6 indexes on the new table If the assertion fails, the migration throws inside the existing `transaction()` wrapper. SQLite rolls back the whole migration, old `runs` table is untouched, `schema_migrations` never records v35. Next app start retries cleanly. ## Migration v36 (drop tasks.is_heartbeat + synthetic rows) Runs now carry `task_id = NULL` for heartbeat dispatches. The `is_heartbeat` flag is dead data going forward. 1. `UPDATE runs SET task_id = NULL WHERE task_id IN (SELECT id FROM tasks WHERE is_heartbeat = 1)` 2. `DELETE FROM tasks WHERE is_heartbeat = 1` (synthetic rows, not real work) 3. Rebuild `tasks` without the `is_heartbeat` column (same defer-FK + row-count-assert pattern as v35) ## Code cleanup - `RunRecord.taskId: string | null`; `createRun` / `cancelRunForDeletion` / `finishRun` guard every `UPDATE tasks` path with a null-check. - `TaskRecord.isHeartbeat` removed; every SELECT / filter / UI reference dropped. - Delete `acquireHeartbeatTask` / `findReusableHeartbeatTask` / `cleanupDuplicateHeartbeatTasks` — dead after the constraint lifts. - Delete `src/main/orchestration/heartbeat-task.ts` (pure workaround constant file). - `heartbeat.ts` creates runs with `taskId: null` when the agent has no assigned work. Turn context already supports nullable task (heartbeatFallbackSection); prompt surface unchanged. - `validateTaskCreation` drops the `isHeartbeat` parameter — user- authored + automation-authored tasks are never heartbeat. - Renderer: `run.taskId ? taskMap.get(...) : undefined` in Dashboard / RunCenter / RunDetail / RunQueue. - Delete `tests/unit/heartbeat-coalescing.test.ts` (12 tests that exercised the deleted DB methods). - Drop 1 isHeartbeat-bypass test from `task-quality-gates.test.ts`. ## Grep verification - `isHeartbeatTaskTitle src/` → 0 - `acquireHeartbeatTask src/` → migration comment only - `is_heartbeat src/` → schema.ts migration history only - `isHeartbeat src/` → 0 Tests: 578/578 (was 591 — delta is 13 tests that tested deleted code).
AgentCompany
Launch autonomous AI companies from your desktop.
Set a goal. Watch AI agents self-organize, delegate, and deliver.
PLEASE USE A CODING PLAN, IT COMSUMES A LOT OF TOKENS
I will add support for Ollama and Github Copilot in the near future.
Download | Website | Features | Quick Start
What is AgentCompany?
AgentCompany is a cross-platform desktop app that turns a single goal into a coordinated AI team. You provide a company name, description, and mission. A CEO agent self-organizes departments, delegates tasks, and produces deliverables — code, content, research, business plans, and more — while you observe and approve through a chat-based command hub. Inspired by Paperclip
Supported AI Runtimes
| Runtime | Status |
|---|---|
| Claude Code | Ready |
| Codex CLI | Ready |
| Gemini CLI | Ready |
Features
Self-Organizing Teams
Your AI CEO builds the org chart — recruiting specialists, creating departments, and establishing reporting lines from a single goal.
Real-Time Agent Communication
Agents coordinate through channel and direct-message threads. Watch decisions unfold in real time.
Autonomous Task Management
Goals break down into tasks automatically. Agents pick up work, report progress, and escalate blockers without intervention.
Human-in-the-Loop Approvals
Critical decisions surface for your review. Approve, reject, or redirect — your company respects the chain of command.
AI Document Generation
Agents draft business plans, marketing strategies, and technical specs — stored in a shared document center.
One-Click Company Creation
Name it, describe the mission, connect a runtime, and launch. Agents start working in under a minute.
Quick Start
Download
Grab the latest release for your platform:
Available for macOS (Apple Silicon & Intel), Windows, and Linux.
Build from Source
# Prerequisites: Node.js 22+, pnpm 10+
pnpm install
pnpm dev
Verification
pnpm typecheck
pnpm lint
pnpm test:unit
pnpm test:integration
pnpm test:e2e
pnpm build:verify
Packaging
pnpm build # Compile + package for current platform → /build/release
pnpm build:dir # Compile + unpackaged directory
pnpm build:current # Build for current host platform (see note below for other OS)
pnpm release:local # Signed/uploading release pipeline (see docs/release/local-r2.md)
- Targets: macOS (
.dmg), Windows (.exe/ NSIS), Linux (.AppImage) - Packaging uses
electron-builder - Local builds use ad-hoc signing (
CSC_IDENTITY_AUTO_DISCOVERY=false) - Defaults to
--publish never; override withAGENTCOMPANY_ELECTRON_PUBLISH - Cloudflare R2 release hosting + auto-update pipeline:
docs/release/local-r2.md
Architecture
src/
main/ # Electron main process — database, services, IPC, orchestration
preload/ # Context-isolated bridge — DesktopApi via contextBridge
renderer/ # React 19 UI — components, hooks, i18n
shared/ # Contracts, types, Zod schemas shared across processes
packages/
adapter-utils/ # Shared adapter utilities
adapter-claude-local/
adapter-codex-local/
adapter-gemini-local/
Key Design Decisions
- Local-first: SQLite database, secrets in OS keychain, no external services required
- Security:
contextIsolation: true,nodeIntegration: false, Zod-validated IPC, JWT agent tokens - Agent coordination: Agents delegate tasks, escalate blockers, and produce deliverables through the orchestration runtime
Tech Stack
| Layer | Technology |
|---|---|
| Framework | Electron 39.8.0 |
| Runtime | Node.js 22+ |
| Language | TypeScript 5.9 (strict) |
| UI | React 19, Tailwind CSS 4, Framer Motion |
| Build | electron-vite, Vite 7, electron-builder |
| Database | SQLite (WAL mode, schema in src/main/database/) |
| Validation | Zod 4 |
| Testing | Vitest, Playwright |
License
Built with quiet authority. Ship your AI company.






