Cloud Platform Architecture

Kilo Cloud is hosted platform layer for authentication, model routing, billing, product configuration, automation, and scoped execution services. Cloud implementation lives in open-source Kilo-Org/cloud repository.

ℹ️Static source scope

This page describes Worker surfaces, bindings, routes, and code paths present in Kilo-Org/cloud. Static source shows deployable architecture, not live production enablement, rollout percentages, retention configuration, or vendor settings. Validate live environment before making production or compliance claims. Use Kilo Cloud Security Architecture for trust boundaries and data flows.

How to use this page

Use this page to understand hosted service topology: which product boundaries exist, where long-running work executes, and how hosted runtimes relate. For trigger-to-execution workflows, continue to Automation Services. For trust boundaries and controls, continue to Cloud Security.

Hosted layers

LayerResponsibilityExamples
Web control planeIdentity, organization authorization, billing, product configuration, and API orchestrationNext.js application in apps/web/
Shared cloud servicesModel routing, asynchronous orchestration, real-time delivery, persistence adapters, and operational servicesKilo Gateway, Workers, queues, Durable Objects, R2, KV, Hyperdrive
Scoped executionRuns code or scoped runtime workloadsCloud Agent, Gas Town container
External providersServices outside Kilo Cloud trust boundaryModel providers, source-control providers, messaging providers, telemetry providers

Where these pages say owner, they mean personal user or organization that authorizes scoped product state and credentials.

Cloudflare terms

TermMeaning in these docs
WorkerDeployed service boundary that handles HTTP requests, queue messages, schedules, or service-binding calls
Durable ObjectStateful Cloudflare actor with stable identity, storage, and alarm support
QueueAsynchronous delivery boundary used to separate ingress from long-running work
Dead-letter queueQueue for messages that exhausted normal delivery attempts
Service bindingDirect Worker-to-Worker call boundary configured in Wrangler
R2Object storage for scoped blobs, assets, attachments, or export data
KVDistributed key-value storage for cache, mapping, rollout, and dedup state; not strongly consistent authority
HyperdriveCloudflare binding used to connect Workers to PostgreSQL
SandboxIsolated container execution binding used by selected hosted workloads

Product topology

flowchart LR
  clients["Browser, editor, and mobile clients"]
  web["Web control plane"]
  gateway["Kilo Gateway"]
  automation["Automation Workers"]
  agent["Cloud Agent"]
  chat["Kilo Chat / Event Service / Notifications"]
  town["Gas Town"]
  wasteland["Wasteland"]
  repos["GitHub and GitLab repositories"]
  providers["Model providers and gateways"]
  stores["PostgreSQL, Durable Objects, queues, R2, KV, and analytics stores"]

  clients --> web
  clients --> gateway
  web -. "short-lived connection ticket" .-> clients
  clients -->|"ticketed WebSocket"| chat
  web --> automation --> agent
  web --> agent
  agent --> repos
  agent --> providers
  town --> repos
  town --> providers
  town --> wasteland
  gateway --> stores
  agent --> stores
  chat --> stores
  wasteland --> stores

Not every hosted flow launches Cloud Agent. Shared services also route model requests, deliver chat events, and dispatch notifications.

Service families

FamilyPrimary servicesRole
Session executioncloud-agent-next
session-ingest
git-token-service
notifications
Hosted coding sessions, session ingestion, repository credentials, and completion push
Automationcode-review-infra
auto-triage-infra
auto-fix-infra
security-auto-analysis
security-sync
webhook-agent-ingest
Queue-backed review, triage, fix, security, and configured trigger flows
Real-time chatkilo-chat
event-service
notifications
Conversation state, WebSocket delivery, and mobile push
Multi-agent orchestrationgastown
wasteland
Town execution and collaborative commons
Evaluation and operationso11y
kilo-ops
model-eval-ingest
Metrics, alerts, operations, and model-evaluation ingestion
Attributionai-attributionAI-edit attribution events

Kilo Gateway

Gateway consists of cloud API routes plus packages/kilo-gateway/ client integration in Kilo-Org/kilocode. It handles account-aware and anonymous-free model access. See Cloud Security for request branches and endpoint families.

ResponsibilityDescription
AuthenticationResolves signed-in account and organization context when required
Anonymous free accessAllows eligible free-model requests without account auth under IP-derived context and limits
Provider routingRoutes managed-key, BYOK, custom-endpoint, and configured-gateway requests
CatalogsServes model, provider, embedding-model, and transcription-model surfaces
Usage and billingRecords applicable token usage, credits, entitlements, and billing metadata

Auto Model clients send stable kilo-auto/* tier IDs. Gateway resolves tiers server-side before provider routing so mappings can change without client releases. See Models and Providers for current tier behavior.

Eligible gateway requests can include normalized project label for usage attribution and grouping. Label identifies project without sending full repository URL.

Cloud Agent

services/cloud-agent-next/ is current Cloud Agent session runtime. Each launched unit is a Cloud Agent execution session. Runtime uses queue-first orchestration and session messages.

Every Cloud Agent execution session receives separate workspace and home paths. Policy-selected sandbox allocation is not universally one container per session.

LayerIsolation rule
Working directorySeparate per execution session
Home directorySeparate per execution session
Git workspaceSeparate per execution session
Sandbox identityPolicy-selected
Default allocationMay share owner-scoped sandbox across sessions
Selected organization flowsMay use per-session sandbox
Devcontainer flowsUse per-session DIND sandbox
flowchart TB
  callers["Web control plane and automation Workers"]
  session["CloudAgentSession Durable Object"]
  sandbox["Sandbox"]
  small["SandboxSmall"]
  dind["SandboxDIND"]
  ingest["Session Ingest binding"]
  tokens["Git Token Service binding"]
  notify["Notifications binding"]
  r2["R2 session bucket"]
  db["Hyperdrive -> PostgreSQL"]
  callback["Callback queue"]
  report["Report queue"]
  dlq["Report dead-letter queue"]

  callers --> session
  session --> sandbox
  session --> small
  session --> dind
  session --> ingest
  session --> tokens
  session --> notify
  session --> r2
  session --> db
  session --> callback
  session --> report --> dlq

services/cloud-agent-next/wrangler.jsonc defines these bindings. Presence in Wrangler config proves deployable topology, not active production allocation counts or rollout policy.

Automation boundaries

Automation Services owns trigger, owner-scope, queue, callback, output, and recovery details. This table only shows how automation relates to hosted platform.

ServiceHosted execution relationship
Kilo BotLaunches Cloud Agent for requested repository work
Code ReviewRuns queued review sessions through Cloud Agent
Auto TriageCan classify issue without Cloud Agent during duplicate check; launches Cloud Agent when classification session is needed
Auto FixLaunches Cloud Agent to create issue-fix pull request
Security AgentRuns model triage in security-auto-analysis; launches Cloud Agent only for selected deep analysis
Webhook Agent IngestDelivers configured prompt to Cloud Agent

Webhook Agent Ingest

services/webhook-agent-ingest/ is configured-trigger boundary. It accepts HTTP webhooks and scheduled alarms, then dispatches a Cloud Agent session. Automation Services owns activation, authentication, queue, and alarm details.

Security Agent

Security Agent keeps finding sync, analysis dispatch, and sandbox execution separate.

flowchart TB
  github["GitHub Dependabot API"]
  postgres["PostgreSQL<br/>Security Agent state"]

  subgraph sync ["Finding sync"]
    direction LR
    interactive["Interactive web sync"] --> web["Web Security Agent handler"] --> github
    cron["security-sync<br/>six-hour cron"] --> queue["Owner-level sync queue"] --> tokens["Git Token Service binding"] --> github
    github --> postgres
  end

  subgraph analysis ["Analysis"]
    direction LR
    postgres -->|"Queued analysis row"| worker["security-auto-analysis"] --> triage["Model gateway triage"] --> deep{"Deep analysis needed?"}
    deep -->|"Yes"| agent["Cloud Agent<br/>deep analysis"] --> callback["Finding-scoped callback"] --> postgres
    deep -->|"No"| postgres
  end

  subgraph cleanup ["Stale-analysis cleanup"]
    direction LR
    cleanupCron["Web cleanup cron"] --> reconcile["Reconcile stale running findings<br/>without active queue work"] --> postgres
  end

PostgreSQL holds owner-scoped findings, analysis queue rows, owner pause or block state, Security Agent configuration, and audit records. See Automation Services for queue lifecycle and its static-source limitation, and Cloud Security for trust boundaries.

Chat events and notifications

sequenceDiagram
  participant Client as Browser or mobile client
  participant Ticket as Event Service ticket API
  participant Events as Event Service
  participant Session as UserSessionDO
  participant Chat as Kilo Chat conversation-state DOs
  participant Notify as NotificationChannelDO
  participant Expo
  participant Queue as Receipt queue

  Client->>Ticket: Request short-lived connection ticket
  Ticket-->>Client: Return short-lived ticket
  Client->>Events: Open WebSocket with ticket
  Events->>Session: Register presence
  Chat->>Events: Fan out conversation event
  Events-->>Client: Deliver WebSocket event
  Chat->>Notify: Request selected conversation push
  Notify->>Events: Check presence context
  Events-->>Notify: Return presence context
  alt User already present
    Notify-->>Chat: Suppress push
  else Push needed
    Notify->>Expo: Send push
    Expo-->>Notify: Return receipt
    Notify->>Queue: Enqueue receipt
    Queue->>Notify: Process receipt and stale-token cleanup
  end

Kilo Chat stores conversation state in Durable Objects and fans events out through Event Service. Notifications checks Event Service presence context before selected pushes and processes Expo receipts asynchronously. See Cloud Security for ticket and push-delivery trust boundaries.

Gas Town and Wasteland

Gas Town is multi-agent orchestration for coding work on repositories. TownDO owns town state and TownContainerDO owns town container execution. Active town work uses 5-second alarm cadence. Idle towns use 5-minute cadence.

Gas Town conceptRole
TownWorkspace or project with one or more rigs
RigRepository attached to town
BeadUnit of work such as issue, task, merge request, or message
ConvoyRelated beads with dependency tracking
MayorPersistent coordinator that decomposes and delegates work
PolecatWorker agent that edits code and creates pull requests
RefineryReview agent that runs quality gates and handles merge flow
TriageEphemeral agent for ambiguous automated-check outcomes

Gas Town binds separate wasteland Worker through WASTELAND_SERVICE. Wasteland uses WastelandDO and WastelandRegistryDO Durable Objects and DoltHub-backed collaborative commons paths.

flowchart LR
  town["Gas Town TownDO"]
  container["TownContainerDO"]
  binding["WASTELAND_SERVICE binding"]
  wasteland["Wasteland Worker"]
  dos["WastelandDO and WastelandRegistryDO"]
  dolt["DoltHub-backed collaborative commons"]

  town --> container
  town --> binding --> wasteland --> dos --> dolt

Observability

services/o11y/ is current metrics and alert infrastructure. Higher-order agent outcome analysis remains roadmap work unless backed by separate implementation.

SurfaceStatic-source behavior
Alert evaluationWorker cron runs every minute
API metricsAnalytics Engine dataset plus Pipeline stream
Session metricsAnalytics Engine dataset plus Pipeline stream
ExportPipelines dual-write R2 Parquet data for Snowflake export infrastructure
Alert deduplicationKV namespace stores TTL-based cooldown state
Alert configurationAlertConfigDO stores strongly consistent config
Session connectionsession-ingest binds to o11y and emits session metrics

Source map

Paths below are relative to Kilo-Org/cloud.

ConcernSource paths
Cloud Agent session service and bindingsservices/cloud-agent-next/
services/cloud-agent-next/wrangler.jsonc
Session ingestion and Git tokensservices/session-ingest/
services/git-token-service/
Automation Workersservices/code-review-infra/
services/auto-triage-infra/
services/auto-fix-infra/
services/webhook-agent-ingest/
Security Agentapps/web/src/lib/security-agent/
services/security-auto-analysis/
services/security-sync/
Chat, events, and notificationsservices/kilo-chat/
services/event-service/
services/notifications/
Multi-agent orchestrationservices/gastown/
services/wasteland/
Observability and operationsservices/o11y/
services/kilo-ops/
services/model-eval-ingest/
Attributionservices/ai-attribution/