Skip to content

API 路由对照表 ​

全量路由 ​

MethodPathHandlerAuth额度状态
POST/api/v1/auth/registerAuthHandler.Register--✅
POST/api/v1/auth/loginAuthHandler.Login--✅
POST/api/v1/auth/refreshAuthHandler.RefreshToken--✅
GET/api/v1/auth/oauth/googleOAuthHandler.GoogleLogin--✅
GET/api/v1/auth/oauth/google/callbackOAuthHandler.GoogleCallback--✅
GET/api/v1/auth/oauth/wechatOAuthHandler.WechatLogin--✅
GET/api/v1/auth/oauth/wechat/callbackOAuthHandler.WechatCallback--✅
GET/api/v1/auth/profileAuthHandler.GetProfile✅-✅
PUT/api/v1/auth/profileAuthHandler.UpdateProfile✅-✅
GET/api/v1/auth/self-profileAuthHandler.GetSelfProfile✅-✅
PUT/api/v1/auth/self-profileAuthHandler.UpdateSelfProfile✅-✅
GET/api/v1/subscription/usageSubscriptionHandler.Usage✅-✅
POST/api/v1/subscription/mock-activateSubscriptionHandler.MockActivate✅-✅ 演示
GET/api/v1/personsPersonHandler.List✅-✅
POST/api/v1/personsPersonHandler.Create✅-✅
POST/api/v1/persons/import-urlImportHandler.ImportFromURL✅-✅ LLM 抽取草稿
POST/api/v1/persons/import-textImportHandler.ImportFromText✅-✅
POST/api/v1/persons/import-imageImportHandler.ImportFromImage✅-✅ multipart
GET/api/v1/persons/:idPersonHandler.Get✅-✅
PUT/api/v1/persons/:idPersonHandler.Update✅-✅
DELETE/api/v1/persons/:idPersonHandler.Delete✅-✅
POST/api/v1/chatChatHandler.SendMessage✅Handler 内✅
POST/api/v1/chat/streamChatHandler.StreamMessage✅Handler 内✅ SSE
GET/api/v1/chat/sessionsChatHandler.ListSessions✅-✅
GET/api/v1/chat/sessions/:idChatHandler.GetSession✅-✅
DELETE/api/v1/chat/sessions/:idChatHandler.DeleteSession✅-✅
GET/api/v1/chat/statsChatHandler.Stats✅-✅
POST/api/v1/strategy/analyzeStrategyHandler.Analyze✅Handler 内✅
POST/api/v1/strategy/adviseStrategyHandler.Advise✅Handler 内✅
POST/api/v1/strategy/scriptStrategyHandler.Script✅Handler 内✅
GET/health----✅

响应格式 ​

json
{
  "code": 0,
  "message": "success",
  "data": { ... }
}

列表接口:{ items, total, page, pageSize, totalPages }


前后端字段映射 ​

所有字段已在 Phase 1 末期 / Phase 2 初期对齐:

  • Auth 响应:{ accessToken, refreshToken, user } — camelCase
  • Person / Chat 列表:{ items, total, page, pageSize, totalPages }
  • Chat 请求体(流式与非流式):{ sessionId?, message, personIds?, scenarioType?, model?, locale?, regenerate? }(regenerate: 用上一轮用户话重新生成)
  • Strategy 请求体:{ personId/personIds, scenarioType, content/description/goal, strategyThreadId, locale }
  • GORM JSON tag 全部 camelCase

HTTP 层与 Agent 层如何对接(面向「契约 / 接口」) ​

组合根:internal/handler/router.go 在进程内构造一个 *agent.System(agent.NewSystem(cfg.AI, recorder, logger, db)),注入到:

Handler是否调用 Agent说明
ChatHandler是agents.Chat / 非流式收集;组 *agent.AgentContext
StrategyHandler是agents.Analyze / Advise / Script
ImportHandler间接ImportService 使用 agentSystem.DefaultModel() 做 LLM 抽取,不走 Chat/Runner
AuthHandler / PersonHandler / SubscriptionHandler否仅 Service → Repository → DB

与 Agent 的「对外契约」(概念上的接口,便于你对照实现或日后抽象):

  1. 输入:*agent.AgentContext(userID、sessionID、历史消息、关联人物、自我画像、locale、Model、MaxOutputTokens、Redis 线程上下文等,由 Handler 从 DB/Redis 拼装)。
  2. 输出(流式):<-chan agent.StreamChunk(content / agent 名 / error;结束帧可带业务扩展字段如 profileProposal,见 sse.md)。
  3. 输出(策略直调):同上 channel,由 Handler 聚合或边写 SSE。

当前代码里 Handler 依赖的是具体类型 *agent.System,没有单独的 Go interface 包;若要做依赖注入单测或可替换实现,可自行引入例如 type AgentRuntime interface { Chat(...) <-chan agent.StreamChunk; Analyze(...); ... },由 *agent.System 实现。

前端侧:@shice/api 的 REST 路径与上表一致;流式对话见 streamChat 与 sse.md。权威路径列表以 router.go 为准,本文表应与其同步更新。