|
1 | | -# Project context — loaded into every agent session via `instructions` in kilo.jsonc. |
| 1 | +# Project context |
2 | 2 |
|
3 | | -# Keep this short and factual. It orients agents to THIS project specifically |
| 3 | +CorpOS is the open reference implementation of an autonomous company: |
| 4 | +firm model + work contracts + control plane. Simulation-first. |
4 | 5 |
|
5 | | -# (unlike AGENTS.md, which states universal rules). |
| 6 | +Workspaces: `packages/core`, `packages/mcp-knowledge`, `apps/api`, `apps/console`. |
6 | 7 |
|
7 | | -## What this project is |
| 8 | +Commands: `npm run dev`, `npm test`, `npm run scenario`, `npm run audit:verify`, |
| 9 | +`./scripts/harness/verify.sh`, `./scripts/harness/adversarial.sh`. |
8 | 10 |
|
9 | | -`CorpOS` — an autonomous company operating system: a TypeScript multi-agent |
10 | | -runtime plus a control plane (policy engine, approval gates, spend caps, audit, |
11 | | -REST/WebSocket API, dashboard). Department "agents" (support, sales, ops, |
12 | | -finance, engineering) reason via an LLM, call permissioned tools, and coordinate |
13 | | -through a shared orchestrator. Every consequential action is policy-gated. |
14 | | - |
15 | | -## Architecture (in brief) |
16 | | - |
17 | | -- **Runtime layer** (`src/core/`): `types`, `llm`, `logger`, `event-bus`, `store` |
18 | | - (SQLite via better-sqlite3), `tool` (typed registry + permissions), `policy` |
19 | | - (allow/deny/approve decisions + spend tracking), `memory`, `agent` (reasoning |
20 | | - loop), `orchestrator` (lifecycle, dispatch, concurrency, retries), `app` |
21 | | - (composition root). |
22 | | -- **Agents** (`src/agents/`): one file per department; each declares a system |
23 | | - prompt, a tool subset, and owns its domain tools. |
24 | | -- **Tools** (`src/tools/`): CRM, comms, billing, knowledge, system packs. |
25 | | - Every tool declares a `ToolPermission` (category + optional cost cap + |
26 | | - `requiresApproval`). |
27 | | -- **Control plane** (`src/api/`): Express REST + WebSocket; serves the dashboard. |
28 | | - |
29 | | -## Key conventions |
30 | | - |
31 | | -- TypeScript, ESM (`"type": "module"`), strict. Node >= 20. |
32 | | -- 2-space indent, LF, no trailing whitespace (see `.editorconfig`). |
33 | | -- IDs via `nanoid`. JSON-schema for tool parameter validation; `zod` only where |
34 | | - ergonomic. |
35 | | -- No comments unless genuinely necessary. |
36 | | -- Consequential tools (spend, external comms, mutating) MUST route through the |
37 | | - policy engine and produce audit events. Nothing destructive runs autonomously. |
38 | | -- Agent reasoning loop is LLM-driven but fully reproducible under the |
39 | | - `SimulationProvider` (scripted responses) — all tests run without network. |
40 | | - |
41 | | -## Commands |
42 | | - |
43 | | -- Install: `npm install` |
44 | | -- Typecheck: `npm run typecheck` |
45 | | -- Build: `npm run build` |
46 | | -- Run server (API + dashboard): `npm run dev` (boots on `$PORT` or 3000) |
47 | | -- Run a recorded multi-agent scenario: `npm run scenario` |
48 | | -- Tests: `npm test` (vitest) |
49 | | - |
50 | | -## LLM provider |
51 | | - |
52 | | -Agents call **OpenRouter** via its OpenAI-compatible endpoint |
53 | | -(`https://openrouter.ai/api/v1`), model **Owl Alpha**, key from |
54 | | -`OPENROUTER_API_KEY` and slug from `OPENROUTER_MODEL` (default |
55 | | -`openrouter/owl-alpha` — set the real OpenRouter slug for Owl Alpha there). |
56 | | -Optional `OPENROUTER_REFERER` / `OPENROUTER_TITLE` set the OpenRouter |
57 | | -`HTTP-Referer` / `X-Title` headers. Z.AI and OpenAI remain supported as |
58 | | -alternatives (`provider: "zai"|"openai"`); the factory auto-detects by key. |
59 | | - |
60 | | -**Gotcha: no key is set in this environment.** The system runs |
61 | | -**simulation-first** — the `SimulationProvider` returns scripted/tool-driven |
62 | | -responses so the full system is demonstrable and tested without network. Provide |
63 | | -`OPENROUTER_API_KEY` to switch the default agent provider to live OpenRouter. |
64 | | -Never log keys. |
65 | | - |
66 | | -## Gotchas |
67 | | - |
68 | | -- Do NOT edit `package-lock.json` directly (permission-denied by design); run |
69 | | - `npm install` to change the lockfile. |
70 | | -- Agent Manager run-script derives a per-worktree `$PORT` from the worktree path; |
71 | | - parallel worktrees bind different ports — read `$PORT`, don't hardcode 3000. |
72 | | -- SQLite file (`data/company.db`) is created at runtime; do not commit it. |
73 | | -- The reasoning loop is non-deterministic under a live LLM; deterministic tests |
74 | | - rely on `SimulationProvider` scripts. |
| 11 | +Site id: `corpos`. Program: `corpos-autonomous-company`. |
0 commit comments