Architecture
Felix is one pnpm workspace: sixteen packages under packages/ and five apps under apps/. The
packages hold the runtime and the shared presentation code; the apps choose providers, tools,
storage and the screen, and compose the packages into something you run. The tables below cover the
core ones. The others are @felix/lookups (tools over public services), @felix/mcp (MCP tools), @felix/quickjs (the script engine),
@felix/skills (the Agent Skills format), @felix/storage (the hosted stores, their clients and
the partition host, over a portable key-value contract), @felix/telemetry, @felix/workflows (the workflow
interpreter) and @felix/workspace (the browser workspace), and apps/evals runs live scenarios
through the terminal client, and checks harness prompts it does not run against the same model.
The runtime packages
Section titled “The runtime packages”These three make a run happen. None of them imports a Node or Cloudflare API, so the same code runs in the Worker, in Node and in tests.
| Package | Owns | Does not own |
|---|---|---|
@felix/ai |
Messages, the Model interface, completeModel for one inference, message and conversation validation, provider error types, the provider adapters (Workers AI, Anthropic, OpenAI, OpenAI-compatible, Google Gemini and Vertex AI, Mistral, Amazon Bedrock), image and classifier models, SSE decoding. |
Tools, the loop, sessions, configuration, storage. |
@felix/agent |
runAgent: the tool loop, tool parsing, the beforeTool gate and afterTool hook, parallel batches, budgets, retries, steering and context hooks, and the order of checkpoints and events. |
Persistence, which tools exist, approval records, HTTP. |
@felix/harness |
The Session interface, prompt (history checks, then the user checkpoint, then the run), the prompt queue, compaction, closing interrupted calls, and the child-agent supervisor. |
Storage adapters, locks and leases, instruction files, credentials. |
@felix/ai exports its providers and fixtures on separate paths, so importing the core does not pull
them in:
| Export | Contents |
|---|---|
@felix/ai |
The provider-neutral contract. |
@felix/ai/workers-ai |
workersAiModel (over an injected run function, such as the Worker’s AI binding) and workersAiRestModel. |
@felix/ai/anthropic |
anthropicModel. |
@felix/ai/openai-responses, /openai-compatible, /google, /mistral, /bedrock, /aws |
The other model providers, and the AWS request signing Bedrock uses. |
@felix/ai/workers-ai-images, /openai-images, /google-images, /openrouter-images, /workers-ai-classifier, /system-one |
Image generation and classifier models. |
@felix/ai/workers-ai-transcription |
Workers AI speech-to-text. |
@felix/ai/sse |
The SSE decoder, shared with the HTTP client. |
@felix/ai/testing, @felix/ai/testing/anthropic, @felix/ai/testing/bedrock |
Scripted models and provider wire fixtures for tests and the demo. |
@felix/harness/demo is the credential-free scripted run behind pnpm demo, the terminal client’s
--demo and the API’s /demo route. Outside tests, it is the only code that imports the testing
fixtures.
The wire and presentation packages
Section titled “The wire and presentation packages”| Package | Owns | Does not own |
|---|---|---|
@felix/protocol |
The versioned run request and event frames, thread and health shapes, their paths, and the validators both ends use. | Any HTTP client or server. |
@felix/client |
A fetch client for run streams, threads and health, built on the protocol. Credentials are passed in by the caller. | Server code, React, caching. |
@felix/transcript |
The view-agnostic transcript model the web and terminal transcripts both read: turns, tool cards, plans, and parsing of tool-result shapes. | Rendering, conversation state. |
@felix/ui |
React controls, the shared mark, and styles. | App state, networking. |
@felix/design |
Design tokens and the mark’s geometry, used by the web app, the terminal client and this site. | Components. |
The apps
Section titled “The apps”| App | Owns |
|---|---|
apps/api |
The Cloudflare Worker: HTTP routing and authentication, provider selection from its bindings, the backpressured SSE stream, and hosted thread storage (revisions, leases, limits) on SQLite-backed Durable Objects. |
apps/web |
The React app: conversation and thread state, browser storage, server reads through TanStack Query, and the screens. |
apps/cli |
The felix terminal client: configuration, the workspace file tools, the write prompt, instruction files, locked session files, and the full-screen renderer. |
apps/docs |
This site. |
An app is never a dependency of another workspace. Platform code stays in the app that runs on the
platform: the stores are portable (@felix/storage), and the Durable Object adapter that hosts
them is in apps/api; the filesystem tools and session files are in
apps/cli.
docs/diagrams/deploy-topology.mmd, which follows apps/api/wrangler.jsonc (env.workers-ai, env.workers-ai-sandbox), apps/api/src/config.ts:Env and apiConfig, apps/api/src/main.ts, apps/api/src/storage/stores.ts, apps/docs/wrangler.jsonc..POST /v1/runs/stream reach the model and the thread?Wider than the column here; it scrolls sideways.Drawn from docs/diagrams/request-path.mmd, which follows apps/api/src/index.ts:fetch, apps/api/src/app.ts:createApp (fetch, routeChat), apps/api/src/runs/run-host.ts:createRunHost (start), apps/api/src/routes/chat.ts:chatResponse..Dependency direction
Section titled “Dependency direction”ai ◄── agent ◄── harness ▲ └── protocol ◄── client
api ─► ai, agent, harness, protocol, client, lookups, mcp, skills, storage, telemetry, workflowscli ─► ai, agent, harness, protocol, client, lookups, mcp, quickjs, skills, telemetry, transcript, designweb ─► ai, client, protocol, skills, transcript, workspace, ui, designdocs ─► protocol, designevals ─► ai, agent, harness, protocolai depends on no other Felix package. agent depends on ai, and harness on both. protocol
uses the message types from ai; client depends on protocol and the SSE decoder from ai. transcript, ui and design depend on no other Felix package.
The web app reaches the runtime only over HTTP: it imports neither agent nor harness.
Checked boundaries
Section titled “Checked boundaries”pnpm check runs the structural checks in .agents/skills/felix-architecture/scripts/check.ts before the type checks. Its boundary check reads every source file in
every workspace and fails on:
| Rule | Example it rejects |
|---|---|
| Undeclared dependency | Importing a package the workspace’s package.json does not list. |
| Non-public import | Importing a path another package does not list in its exports. |
| Relative import across workspaces | ../../packages/ai/src/types.ts from an app. |
| App as a dependency | Any import of an app from another workspace. |
| Platform API in a package | node:fs or cloudflare:workers in non-test code under packages/. |
| Uncheckable loading | A dynamic import() or require() with a computed path. |
| Runtime dependency cycle | Two workspaces that depend on each other. |
Tests may import Node APIs and declared dev dependencies. Production package type checks run without Node’s ambient types, and tests are type-checked separately. See Testing for the full verification command.
Checked conventions
Section titled “Checked conventions”.agents/skills/felix-architecture/scripts/conventions.ts declares the repository’s structure as data: each workspace, what it owns, the
Felix workspaces it uses, and the purpose of each top-level src/ folder. The same pnpm check
step, also available as pnpm structure, fails on:
| Rule | Example it rejects |
|---|---|
| Unregistered workspace | A new packages/* folder with no entry. |
| Workspace shape | A package without private, "type": "module", a check script, or a tsconfig.json that excludes src/test/**. |
| Undeclared internal dependency | A @felix/* dependency the entry’s uses does not list. |
| Undeclared folder | A new top-level src/ folder with no purpose. |
| Misplaced test | A name.test.ts or name.browser.ts outside src/test/, or a src/test/ folder with no src/ counterpart. |
| Name | A file or folder that is not kebab-case (Astro components are PascalCase), or a generic name such as utils or helpers. |
The checks run against conventions.ts itself too: a declared folder, dependency, or exception
that no longer exists fails, so the file stays accurate.
© Felix. All rights reserved.