核心原理

端口与实例生命周期

说明 console、agent 与 plugin 端点的端口分配、路由与生命周期

端口与实例生命周期

统一规则

  • agent 端口由 console 分配。
  • town agent start/restart 不要求用户手工管端口。
  • plugin 命令先找目标 agent,再找 endpoint。

运行时角色

console

  • 维护 ~/.downcity/console/agents.json
  • 启停 agent daemon
  • 分配端口

agent

  • 一个项目对应一个 daemon
  • runtime API 包括 /api/plugins/list/api/plugins/catalog/api/plugins/*
  • debug 信息写入 .downcity/.debug

plugin 端点

  • town plugin ... 走 plugin 路由
  • 都在目标 runtime 内部分发

endpoint 解析

对 plugin API 调用来说:

  1. CLI 显式 --host/--port
  2. DC_CITY_HOST/DC_CITY_PORT
  3. daemon metadata
  4. 默认 127.0.0.1:5314

建议

  • 多 agent 场景优先使用 town plugin ... --agent <id>
  • 不要在 shell profile 里残留错误的 DC_CITY_PORT
  • runtime 状态异常时先执行 town agent doctor --fix 并检查 daemon 日志。