HTTP/SSE 服务器实现层。src/api.ts:5-8 用 @opencode-ai/protocol/api 的 makeDefaultApi 装配 HttpApi,并注入 LocationMiddleware/SessionLocationMiddleware 具体中间件;src/routes.ts:1-13 把 core 的各类服务(SessionV2/SessionExecution/LocationServiceMap/Database/ToolOutputStore 等)装配为 Effect Layer;src/handlers.ts:1-40 合并 19 个 handler(session/message/agent/model/provider/fs/event/pty 等),每个 handler 将 HTTP 请求桥接到 core 领域服务。
· HttpApi 装配与中间件注入(packages/server/src/api.ts:5-8)
· 19 个资源 handler(packages/server/src/handlers.ts:21-40)
· core 服务到 HTTP 层的 Effect Layer 桥接(packages/server/src/routes.ts:1-13)
· 授权/会话定位中间件(packages/server/src/middleware/authorization.ts、session-location.ts)
· CORS 与 auth 基础(packages/server/src/cors.ts、auth.ts)
| 节点 | 机制 | 证据 |
|---|---|---|
| core | workspace-dep | @opencode-ai/server/package.json dependencies.@opencode-ai/core |
| protocol | workspace-dep | @opencode-ai/server/package.json dependencies.@opencode-ai/protocol |
| plan | agent-core | 装配层→官方包 |
| build | agent-core | 装配层→官方包 |
| 节点 | 机制 | 证据 |
|---|---|---|
| cli | workspace-dep | @opencode-ai/cli/package.json dependencies.@opencode-ai/server |
| sdk-next | workspace-dep | @opencode-ai/sdk-next/package.json dependencies.@opencode-ai/server |
| opencode | semantic-dep | stage-01 opencode |
把 Effect HttpApi 与 core 领域服务粘合为可运行的 HTTP 服务(不依赖 CLI),使 opencode 主程序、sdk createOpencodeServer 与其他宿主都能复用同一套服务端装配。
官方底座,未被本机装配层直接引用