How withastro/flue works
1. This is a TypeScript monorepo for an agent-harness framework, not a single app. The center of gravity is packages/runtime, with surrounding packages for deployment targets, integrations, persistence, UI helpers, and examples. apps/docs and apps/www are the public documentation/marketing surfaces.
2. The main product layer is @flue/runtime. It defines agents, sessions, workflows, tools, skills, sandboxes, routing, durable execution, event streaming, and persistence contracts. Architecturally, this is the engine that turns an incoming request or event into a long-lived agent run, records progress, and rehydrates state after restarts.
3. Runtime execution is split by environment. packages/runtime/src/node provides local Node.js execution, while packages/runtime/src/cloudflare adds Cloudflare Workers-specific coordination, registry, gateway, sandbox, and model/provider plumbing. The repo is built to support both local development and hosted execution with the same conceptual API.
4. Agent flow is: external input enters through an HTTP route or channel webhook, runtime resolves the agent definition, then the agent executes with instructions, tools, skills, and a sandbox. During the run, the runtime emits events, stores run/session state, and can stream chunks/results back to callers. Durable execution is a first-class boundary, so accepted work survives process interruption.
5. packages/sdk is the consumer-facing client layer for invoking deployed agents and workflows over HTTP/streaming. It is separate from the runtime so external applications can call Flue deployments without embedding the harness itself.
6. packages/cli is the local orchestration and build boundary. It provides the flue binary, config loading, build/dev commands, blueprint generation, and Cloudflare/Node-specific build plugins. In practice, the CLI is how projects are initialized, run locally, and packaged for deployment.
7. Integrations are organized as small, focused packages under packages/* for channels and external services. Channel packages such as Slack, Discord, GitHub, Teams, Telegram, WhatsApp, Twilio, Zendesk, Intercom, Linear, Notion, Stripe, Shopify, Resend, Google Chat, and Salesforce Marketing Cloud expose verified webhook/event entry points and service-specific route helpers.
8. Persistence is abstracted behind adapter packages. There are dedicated packages for Postgres, MongoDB, MySQL, Redis, LibSQL, and SQLite-compatible backends, each mapping runtime concepts like runs, sessions, event streams, submissions, and chunks onto the underlying store. This lets the same agent model run with different durability and deployment constraints.
9. packages/react is a separate UI-state integration layer for React applications. It provides hooks, reducers, session/workflow state, and a provider so a frontend can observe and control agent or workflow runs without owning the runtime itself.
10. The apps/docs site is the canonical architecture and reference surface. It mirrors the product structure: guides, CLI docs, SDK docs, API references, ecosystem pages, and per-channel/per-database/per-deploy documentation. apps/www is the marketing and landing site, with blog and example pages.
11. The examples/ directory is effectively an architecture catalog. Each example demonstrates one integration pattern or deployment topology: agent-only, chat SDK, channel webhooks, sandbox usage, workflow composition, observability, React UI, and external service connectors. These are the best place to see end-to-end data flow through the framework.
12. Repository automation exists alongside the product code. .github contains contributor approval and PR redirect workflows, while .flue, .agents, and .opencode hold repo-specific automation and documentation-agent assets. These do not shape runtime behavior, but they support maintenance and content generation across the monorepo.
13. Build and verification are monorepo-wide and strongly package-scoped. Most packages have their own tsdown config and Vitest suites, with workerd-specific test variants where Cloudflare behavior matters. That split reflects the repo’s main boundary: shared abstractions in TypeScript, with environment-specific behavior isolated per target.
Main entry points: run-store.ts Run state · index.ts Runtime · routing.ts Routing · client.ts SDK client
Components 21
Runtime engine
Shared agent harness, execution flow, routing, and durable state management.
- Runtime · Main runtime surface that ties together agents, tools, routing, streaming, and persistence contracts.
packages/runtime/src/index.ts - Dispatch · Core request-to-run orchestration and event dispatch pipeline.
packages/runtime/src/runtime/dispatch.ts - Agent run · Resolves and executes agent definitions, instructions, tools, skills, and sandboxed work.
packages/runtime/src/runtime/handle-agent.ts - Streaming · Streaming routes and chunk/result emission back to callers.
packages/runtime/src/runtime/handle-stream-routes.ts - Run state · Run/session persistence and rehydration primitives used for durable execution.
packages/runtime/src/runtime/run-store.ts - Routing · Maps incoming inputs and channels onto the right agent or workflow entrypoint.
packages/runtime/src/routing.ts
Execution targets
Environment-specific runtime implementations for Node.js and Cloudflare.
- Node runtime · Local Node.js execution and coordination layer.
packages/runtime/src/node/index.ts - Cloudflare runtime · Cloudflare Workers coordination, registry, gateway, sandbox, and model/provider plumbing.
packages/runtime/src/cloudflare/index.ts
Integrations
Channel and service packages that expose webhook or route entry points.
- Slack · Webhook and route helpers for Slack event entry points.
packages/slack/src/routes.ts - GitHub · Webhook entry points for GitHub events.
packages/github/src/webhook.ts - Google Chat · Route and auth helpers for Google Chat integrations.
packages/google-chat/src/routes.ts
Persistence
Adapter packages that map runtime state onto different backing stores.
- Postgres · Persistence adapter for relational durable storage.
packages/postgres/src/postgres-adapter.ts - Redis · Persistence adapter for fast state and event-related storage.
packages/redis/src/redis-adapter.ts - MongoDB · Persistence adapter for document-oriented durable storage.
packages/mongodb/src/mongodb-adapter.ts
Surfaces and examples
Consumer SDK, React bindings, docs, marketing site, and example topologies.
- SDK client · Consumer-facing client for invoking deployed agents and workflows over HTTP and streaming.
packages/sdk/src/client.ts - Flue CLI · Binary entrypoint for local orchestration, dev, build, and deployment packaging.
packages/cli/bin/flue.ts - Build flow · Build/dev orchestration, config loading, and target-specific build plugins.
packages/cli/src/lib/build.ts - React provider · Provider and hooks for observing and controlling runs from React apps.
packages/react/src/provider.ts - Docs site · Canonical reference surface for guides, API docs, ecosystem pages, and concepts.
apps/docs/src/pages/index.astro - Marketing site · Public landing, blog, and product marketing surface.
apps/www/src/pages/index.astro - Examples · Representative end-to-end examples covering agents, channels, workflows, sandboxes, and UI integration.
examples/hello-world/src/app.ts
Connections 24
- Runtime → Dispatch: orchestrates · The entry surface composes the dispatch pipeline.
- Dispatch → Agent run: starts runs · Dispatch resolves an agent and begins execution.
- Dispatch → Routing: routes input · Incoming requests and channel events are routed to the proper handler.
- Agent run → Streaming: emits · Agent execution publishes streaming chunks and results.
- Agent run → Run state: persists · Runs and session progress are durably recorded for later rehydration.
- Routing → Slack: webhooks · Channel packages provide verified entry points into the runtime.
- Routing → GitHub: webhooks · Channel packages provide verified entry points into the runtime.
- Routing → Google Chat: webhooks · Channel packages provide verified entry points into the runtime.
- Node runtime → Runtime: uses · Node target reuses the shared runtime concepts and APIs.
- Cloudflare runtime → Runtime: uses · Cloudflare target reuses the shared runtime concepts and APIs.
- Cloudflare runtime → Run state: hosts · Cloudflare-specific coordination includes durable execution pieces.
- SDK client → Streaming: consumes · The SDK invokes and streams results from deployed runtime instances.
- Flue CLI → Build flow: delegates · The binary entrypoint drives local orchestration and packaging commands.
- Build flow → Node runtime: builds for · CLI produces Node-oriented dev/build flows and plugins.
- Build flow → Cloudflare runtime: builds for · CLI produces Cloudflare-oriented dev/build flows and plugins.
- React provider → SDK client: wraps · React bindings sit on top of the client-facing invocation model.
- Docs site → Runtime: documents · Docs mirror the product architecture and runtime concepts.
- Docs site → SDK client: documents · Docs cover the public SDK and streaming APIs.
- Marketing site → Docs site: points to · Marketing surface leads into the canonical documentation.
- Examples → Runtime: demonstrates · Examples show the runtime in real agent and workflow setups.
- Examples → SDK client: demonstrates · Some examples exercise the external client path.
- Run state → Postgres: adapts to · Runtime persistence can be backed by Postgres.
- Run state → Redis: adapts to · Runtime persistence can be backed by Redis.
- Run state → MongoDB: adapts to · Runtime persistence can be backed by MongoDB.