Skip to main content

Architecture

Anyy is a resident, local-first personal assistant. The product runtime owns sessions, memory, tools, skills, providers, channels, cron, background jobs, approvals, audit, and delivery surfaces.

The inner agent loop is intentionally small. Most product behavior lives around it, not inside it.

Product Runtime

The resident runtime is assembled from packages such as internal/gateway, internal/runtime, internal/state, internal/llm, internal/tools, internal/channels, internal/mcp, and internal/skills.

It resolves the active profile, config, role, provider/model, toolsets, skills, context, approvals, audit sinks, and repositories before calling the loop.

Agent Loop Kernel

internal/agent owns Run, Continue, provider streaming, tool-call iteration, tool-result messages, budget warnings, cancellation, and event emission.

It consumes interfaces: LLMProvider and AgentTool. It must not import gateway, RPC, state, config, channels, skills, approvals, audit, cron, TUI, or provider implementations.

Gateway Boundary

internal/gateway.Service is the resident session owner. It creates sessions, queues turns, builds prompt context, selects tools, runs the agent loop, persists records, publishes events, and handles subagents/background jobs.

Gateway code owns orchestration. Channel adapters, dashboard pages, TUI clients, and one-shot CLI commands should call gateway/RPC contracts rather than own agent-loop behavior.

RPC Boundary

internal/rpc provides JSON request/response dispatch and event subscription. Shared method names and payload shapes live in internal/protocol.

Adding a public method means updating protocol constants, registering a gateway or runtime handler, adding tests, and documenting the method in the reference.

State Boundary

internal/state is the SQLite repository layer. It stores sessions, turns, messages, tool calls/results, roles, memory metadata, cron, channels, approvals, ChangePlans, audit, artifacts, and background jobs.

Raw session detail may also be mirrored under raw/YYYY/MM/DD/. Blob bytes live outside SQLite when the payload is too large for inline storage.

Channel Boundary

Channels are adapters under internal/channels. They translate platform events into protocol.ChannelInbound and translate gateway output into platform messages.

Adapters do not own model selection, prompt assembly, memory, tool policy, or session persistence. They submit inbound work to the gateway and receive outbound delivery from it.