Core Concepts
Port and Instance Lifecycle
How console, agent, service, and plugin coordinate on port allocation, routing, and runtime lifecycle
Port and Instance Lifecycle
Unified Rule
- Agent ports are allocated by
console. city agent start/restartdoes not require users to manage ports manually.serviceandplugincommands resolve target agent first, then endpoint.
Runtime Roles
console
- Maintains
~/.downcity/console/agents.json - Starts/stops/restarts agent daemons
- Allocates agent ports
agent
- One project maps to one daemon
- Runtime HTTP APIs include
/api/services/*and/api/plugins/* - Debug metadata is persisted to
.downcity/.debug
service / plugin
city service ...calls service routescity plugin ...calls plugin routes- both are dispatched in the target runtime
Agent Port Allocation
- Validate console is running
- Validate project files
- Allocate an available port
- Start daemon
- Persist debug metadata
- Upsert console registry
Endpoint Resolution
For runtime API calls:
- explicit CLI
--host/--port DC_SERVER_HOST/PORTDC_CTX_SERVER_HOST/PORT- daemon metadata
- default
127.0.0.1:5314
Recommendations
- In multi-agent scenarios, prefer
city service ... --agent <name>. Plugin actions run locally against the selected project path. - Do not keep stale
DC_SERVER_PORTin your shell profile. - If runtime status is abnormal, run
city agent doctor --fixand inspect daemon logs.