* feat: 支持返回登录二维码与 Docker 部署 * feat: 完善扫码登录功能 * fix: 修复当存在已经登录的情况,上层还会启动 goroutine的问题,并把 mcp 的返回增加为图片格式
97 lines
2.4 KiB
Go
97 lines
2.4 KiB
Go
package main
|
|
|
|
// HTTP API 响应类型
|
|
|
|
// ErrorResponse 错误响应
|
|
type ErrorResponse struct {
|
|
Error string `json:"error"`
|
|
Code string `json:"code"`
|
|
Details any `json:"details,omitempty"`
|
|
}
|
|
|
|
// SuccessResponse 成功响应
|
|
type SuccessResponse struct {
|
|
Success bool `json:"success"`
|
|
Data any `json:"data"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
|
|
// JSON-RPC 相关类型
|
|
|
|
// JSONRPCRequest JSON-RPC 请求
|
|
type JSONRPCRequest struct {
|
|
JSONRPC string `json:"jsonrpc"`
|
|
Method string `json:"method"`
|
|
Params any `json:"params,omitempty"`
|
|
ID any `json:"id"`
|
|
}
|
|
|
|
// JSONRPCResponse JSON-RPC 响应
|
|
type JSONRPCResponse struct {
|
|
JSONRPC string `json:"jsonrpc"`
|
|
Result any `json:"result,omitempty"`
|
|
Error *JSONRPCError `json:"error,omitempty"`
|
|
ID any `json:"id"`
|
|
}
|
|
|
|
// JSONRPCError JSON-RPC 错误
|
|
type JSONRPCError struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data any `json:"data,omitempty"`
|
|
}
|
|
|
|
// MCP 相关类型
|
|
|
|
// MCPToolCall MCP 工具调用
|
|
type MCPToolCall struct {
|
|
Name string `json:"name"`
|
|
Arguments map[string]interface{} `json:"arguments"`
|
|
}
|
|
|
|
// MCPToolResult MCP 工具结果
|
|
type MCPToolResult struct {
|
|
Content []MCPContent `json:"content"`
|
|
IsError bool `json:"isError,omitempty"`
|
|
}
|
|
|
|
// MCPContent MCP 内容
|
|
type MCPContent struct {
|
|
Type string `json:"type"`
|
|
Text string `json:"text"`
|
|
MimeType string `json:"mimeType"`
|
|
Data string `json:"data"`
|
|
}
|
|
|
|
// FeedDetailRequest Feed详情请求
|
|
type FeedDetailRequest struct {
|
|
FeedID string `json:"feed_id" binding:"required"`
|
|
XsecToken string `json:"xsec_token" binding:"required"`
|
|
}
|
|
|
|
// FeedDetailResponse Feed详情响应
|
|
type FeedDetailResponse struct {
|
|
FeedID string `json:"feed_id"`
|
|
Data any `json:"data"`
|
|
}
|
|
|
|
// PostCommentRequest 发表评论请求
|
|
type PostCommentRequest struct {
|
|
FeedID string `json:"feed_id" binding:"required"`
|
|
XsecToken string `json:"xsec_token" binding:"required"`
|
|
Content string `json:"content" binding:"required"`
|
|
}
|
|
|
|
// PostCommentResponse 发表评论响应
|
|
type PostCommentResponse struct {
|
|
FeedID string `json:"feed_id"`
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// UserProfileRequest 用户主页请求
|
|
type UserProfileRequest struct {
|
|
UserID string `json:"user_id" binding:"required"`
|
|
XsecToken string `json:"xsec_token" binding:"required"`
|
|
}
|