Package Module Breakdown
Explains the current main, agent, sessions, services, plugins, types, and utils structure inside packages/downcity
Package Module Breakdown
packages/downcity/ is the runtime core. The fastest way to understand it is to follow the real runtime objects, not the old directory names.
Core Mental Model
main/owns entry assemblyagent/owns the single-project runtime centersession/owns the execution axisservices/own workflowsplugins/own extensions
Current Directory Map
1. main/
This is the current entry and assembly layer.
It owns:
- HTTP server startup and route mounting
- service and plugin integration entrypoints
- daemon and runtime process management
- env, config, model, and project setup
- dashboard and gateway APIs
Important subareas
main/index.ts
The current agent HTTP server entrypoint.
It:
- creates the Hono app
- mounts
static / health / services / plugins / execute / dashboard - starts and stops the Node HTTP server
main/service/
Owns:
- service lifecycle control
- service action execution
- service API registration
Key modules here are:
ServiceStateControllerServiceActionRunnerServiceActionApi
main/plugin/
Owns:
- plugin registration
- hook execution
- availability checks
- built-in plugin registration
Key objects here are:
HookRegistryPluginRegistry
main/runtime/ and main/daemon/
Own:
- console and agent process state
- pid, registry, path, and daemon metadata
- agent process discovery and lifecycle
main/ui/
Owns:
- dashboard and web UI APIs
- gateway behavior
- model, env, and channel-account control APIs
2. agent/
This is the single-project runtime center.
The most important object here is:
AgentRuntime
AgentRuntime holds:
cwdrootPathconfigenvsystemsmodelsessionFacadeservicespluginRegistry
AgentRuntime.ts
Owns:
- project runtime initialization
- config, env, and static system loading
- model creation
SessionExecutorRegistryandSessionFacadecreation- plugin registry creation
- per-agent service creation
- prompt hot reload
AgentContext.ts
Owns:
- the unified execution surface derived from
AgentRuntime
It exposes:
configenvloggersessioninvokeplugins
3. session/
This is the execution axis.
SessionFacade
The agent-owned session facade.
It exposes:
getExecutorgetHistoryStorerunappendUserMessageappendAssistantMessage
SessionExecutorRegistry
Owns:
- runtime caching by
sessionId - runtime to history store creation linkage
LocalSessionExecutor
Owns:
- runtime assembly for a single runnable session
SessionEngine
This is the execution kernel.
It owns:
- input assembly
- compaction retries
- tool loop execution
- final assistant message collection
4. services/
This is the workflow layer. The current core services are:
chattaskmemoryshell
Each service extends BaseService and is created per agent.
chat
Owns:
- channel ingress
- chat queue
- session bridge
- reply dispatch
- chat plugin points
task
Owns:
- task definitions
- cron scheduling
- script and agent task execution
- run artifacts
memory
Owns:
- memory writes
- indexing
- search
- flush and status
shell
Owns:
- one-shot shell execution
- long-lived shell sessions
- read / write / wait / close
5. plugins/
This is the extension layer.
The current built-in plugins are:
authskillvoice
Plugins provide:
- explicit actions
- system injection
- hook implementations
The runtime semantics are:
pipelineguardeffectresolve
6. types/
This is the cross-layer contract center.
It matters because:
- dashboard and APIs depend on it
AgentRuntime,AgentContext,Service, andPlugindepend on it- session and runtime result types depend on it
7. utils/
This is where shared infrastructure lives:
- logger
- sqlite store
- template
- storage
- id
- time
Suggested Reading Order
src/main/index.tssrc/agent/AgentRuntime.tssrc/agent/AgentContext.tssrc/session/SessionFacade.tssrc/session/execution/SessionExecutorRegistry.tssrc/session/execution/local/SessionEngine.tssrc/main/service/Services.tssrc/main/registries/ServiceClassRegistry.tssrc/services/chat/ChatService.tssrc/services/task/TaskService.tssrc/services/memory/MemoryService.tssrc/services/shell/ShellService.tssrc/main/plugin/Plugins.tssrc/main/plugin/PluginRegistry.tssrc/types/*