diff --git a/.gitignore b/.gitignore index dd630cfb..0477fed6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ backend/assets backend/docs/swagger.json -backend/assets-amd64 +backend/assets-amd64 \ No newline at end of file diff --git a/backend/build/Dockerfile b/backend/build/Dockerfile new file mode 100644 index 00000000..4a768c8b --- /dev/null +++ b/backend/build/Dockerfile @@ -0,0 +1,33 @@ +FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder + +WORKDIR /src +ENV CGO_ENABLED=0 + +COPY go.* . +ARG GOMODCACHE +RUN --mount=type=cache,target=${GOMODCACHE} \ + go mod download + +ARG TARGETOS TARGETARCH GOCACHE +ARG VERSION +ARG BUILD_TIME +ARG GIT_COMMIT +RUN --mount=type=bind,target=. \ +--mount=type=cache,target=${GOMODCACHE} \ +--mount=type=cache,target=${GOCACHE} \ +GOOS=$TARGETOS GOARCH=$TARGETARCH \ +go build \ +-ldflags "-w -s -X 'github.com/chaitin/MonkeyCode/backend/pkg/version.Version=${VERSION}' -X 'github.com/chaitin/MonkeyCode/backend/pkg/version.BuildTime=${BUILD_TIME}' -X 'github.com/chaitin/MonkeyCode/backend/pkg/version.GitCommit=${GIT_COMMIT}'" \ +-o /out/main \ +pro/cmd/server/main.go pro/cmd/server/wire_gen.go + +FROM alpine:3.22.1 as binary + +WORKDIR /app + +ADD migration ./migration +ADD assets/vsix ./assets/vsix + +COPY --from=builder /out/main /app/main + +CMD [ "./main" ] \ No newline at end of file diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json deleted file mode 100644 index 6300ba46..00000000 --- a/backend/docs/swagger.json +++ /dev/null @@ -1,7392 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "description": "MonkeyCode API", - "title": "MonkeyCode API", - "contact": {}, - "version": "1.0" - }, - "paths": { - "/api/v1/admin/create": { - "post": { - "description": "创建管理员", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "创建管理员", - "operationId": "create-admin", - "parameters": [ - { - "description": "创建管理员参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateAdminReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.AdminUser" - } - } - } - ] - } - } - } - } - }, - "/api/v1/admin/delete": { - "delete": { - "description": "删除管理员", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "删除管理员", - "operationId": "delete-admin", - "parameters": [ - { - "type": "string", - "description": "管理员ID", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "object" - } - } - } - ] - } - } - } - } - }, - "/api/v1/admin/export-completion-data": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "管理员导出所有补全相关数据", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "admin" - ], - "summary": "导出补全数据", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/domain.ExportCompletionDataResp" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/web.Resp" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/admin/list": { - "get": { - "description": "获取管理员用户列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "获取管理员用户列表", - "operationId": "list-admin-user", - "parameters": [ - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListAdminUserResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/admin/login": { - "post": { - "description": "管理员登录", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "管理员登录", - "operationId": "admin-login", - "parameters": [ - { - "description": "登录参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.LoginReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.AdminUser" - } - } - } - ] - } - } - } - } - }, - "/api/v1/admin/login-history": { - "get": { - "description": "获取管理员登录历史", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "获取管理员登录历史", - "operationId": "admin-login-history", - "parameters": [ - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListAdminLoginHistoryResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/admin/logout": { - "post": { - "description": "管理员登出", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "管理员登出", - "operationId": "admin-logout", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/admin/profile": { - "get": { - "description": "管理员信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "管理员信息", - "operationId": "admin-profile", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.AdminUser" - } - } - } - ] - } - } - } - } - }, - "/api/v1/admin/role": { - "get": { - "description": "获取角色列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "获取角色列表", - "operationId": "list-role", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.Role" - } - } - } - } - ] - } - } - } - }, - "post": { - "description": "授权角色", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "授权角色", - "operationId": "grant-role", - "parameters": [ - { - "description": "授权角色参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.GrantRoleReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/admin/setting": { - "get": { - "description": "获取系统设置", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "获取系统设置", - "operationId": "get-setting", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.Setting" - } - } - } - ] - } - } - } - }, - "put": { - "description": "更新为增量更新,只传需要更新的字段", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Admin" - ], - "summary": "更新系统设置", - "operationId": "update-setting", - "parameters": [ - { - "description": "更新系统设置参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateSettingReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.Setting" - } - } - } - ] - } - } - } - } - }, - "/api/v1/admin/user-group": { - "get": { - "description": "列出用户分组", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "UserGroup" - ], - "summary": "列出用户分组", - "operationId": "list-user-group", - "parameters": [ - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListUserGroupResp" - } - } - } - ] - } - } - } - }, - "put": { - "description": "更新用户分组", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "UserGroup" - ], - "summary": "更新用户分组", - "operationId": "update-user-group", - "parameters": [ - { - "description": "参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateUserGroupReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.UserGroup" - } - } - } - ] - } - } - } - }, - "post": { - "description": "创建用户分组", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "UserGroup" - ], - "summary": "创建用户分组", - "operationId": "create-group", - "parameters": [ - { - "description": "参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateUserGroupReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.UserGroup" - } - } - } - ] - } - } - } - }, - "delete": { - "description": "删除用户分组", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "UserGroup" - ], - "summary": "删除用户分组", - "operationId": "delete-group", - "parameters": [ - { - "type": "string", - "description": "分组id", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/admin/user-group/admin": { - "delete": { - "description": "从分组中移除管理员", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "UserGroup" - ], - "summary": "从分组中移除管理员", - "operationId": "remove-admin-from-group", - "parameters": [ - { - "description": "参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.GroupRemoveAdminReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/admin/user-group/grant": { - "post": { - "description": "授权分组给管理员", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "UserGroup" - ], - "summary": "授权分组给管理员", - "operationId": "grant-group", - "parameters": [ - { - "description": "参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.GrantGroupReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/admin/user-group/user": { - "post": { - "description": "添加用户到分组", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "UserGroup" - ], - "summary": "添加用户到分组", - "operationId": "add-user-to-group", - "parameters": [ - { - "description": "参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.GroupAddUserReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - }, - "delete": { - "description": "从分组中移除用户", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "UserGroup" - ], - "summary": "从分组中移除用户", - "operationId": "remove-user-from-group", - "parameters": [ - { - "description": "参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.GroupRemoveUserReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/billing/chat/info": { - "get": { - "description": "获取对话内容", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Billing" - ], - "summary": "获取对话内容", - "operationId": "chat-info", - "parameters": [ - { - "type": "string", - "description": "对话记录ID", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ChatInfo" - } - } - } - ] - } - } - } - } - }, - "/api/v1/billing/chat/record": { - "get": { - "description": "获取对话记录", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Billing" - ], - "summary": "获取对话记录", - "operationId": "list-chat-record", - "parameters": [ - { - "type": "string", - "description": "作者", - "name": "author", - "in": "query" - }, - { - "type": "boolean", - "description": "是否接受筛选", - "name": "is_accept", - "in": "query" - }, - { - "type": "string", - "description": "语言", - "name": "language", - "in": "query" - }, - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - }, - { - "type": "string", - "description": "工作模式", - "name": "work_mode", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListChatRecordResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/billing/completion/info": { - "get": { - "description": "获取补全内容", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Billing" - ], - "summary": "获取补全内容", - "operationId": "completion-info", - "parameters": [ - { - "type": "string", - "description": "补全记录ID", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.CompletionInfo" - } - } - } - ] - } - } - } - } - }, - "/api/v1/billing/completion/record": { - "get": { - "description": "获取补全记录", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Billing" - ], - "summary": "获取补全记录", - "operationId": "list-completion-record", - "parameters": [ - { - "type": "string", - "description": "作者", - "name": "author", - "in": "query" - }, - { - "type": "boolean", - "description": "是否接受筛选", - "name": "is_accept", - "in": "query" - }, - { - "type": "string", - "description": "语言", - "name": "language", - "in": "query" - }, - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - }, - { - "type": "string", - "description": "工作模式", - "name": "work_mode", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListCompletionRecordResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/cli/{command}": { - "post": { - "description": "运行monkeycode-cli命令", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "CLI" - ], - "summary": "运行monkeycode-cli命令", - "parameters": [ - { - "type": "string", - "description": "命令", - "name": "command", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "标志", - "name": "flag", - "in": "query" - }, - { - "description": "代码文件信息", - "name": "fileMetas", - "in": "body", - "required": true, - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.FileMeta" - } - } - } - ], - "responses": { - "200": { - "description": "输出结果", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.IndexResult" - } - } - }, - "500": { - "description": "内部错误", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/dashboard/category-stat": { - "get": { - "description": "获取分类统计信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Dashboard" - ], - "summary": "获取分类统计信息", - "operationId": "category-stat-dashboard", - "parameters": [ - { - "maximum": 90, - "minimum": 24, - "type": "integer", - "default": 90, - "description": "持续时间 (小时或天数)`", - "name": "duration", - "in": "query" - }, - { - "enum": [ - "hour", - "day" - ], - "type": "string", - "default": "day", - "description": "精度: \"hour\", \"day\"", - "name": "precision", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "用户ID,可选参数", - "name": "user_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.CategoryStat" - } - } - } - ] - } - } - } - } - }, - "/api/v1/dashboard/statistics": { - "get": { - "description": "获取统计信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Dashboard" - ], - "summary": "获取统计信息", - "operationId": "statistics-dashboard", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.Statistics" - } - } - } - ] - } - } - } - } - }, - "/api/v1/dashboard/time-stat": { - "get": { - "description": "获取时间统计信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Dashboard" - ], - "summary": "获取时间统计信息", - "operationId": "time-stat-dashboard", - "parameters": [ - { - "maximum": 90, - "minimum": 24, - "type": "integer", - "default": 90, - "description": "持续时间 (小时或天数)`", - "name": "duration", - "in": "query" - }, - { - "enum": [ - "hour", - "day" - ], - "type": "string", - "default": "day", - "description": "精度: \"hour\", \"day\"", - "name": "precision", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "用户ID,可选参数", - "name": "user_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.TimeStat" - } - } - } - ] - } - } - } - } - }, - "/api/v1/dashboard/user-code-rank": { - "get": { - "description": "用户贡献榜", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Dashboard" - ], - "summary": "用户贡献榜", - "operationId": "user-code-rank-dashboard", - "parameters": [ - { - "maximum": 90, - "minimum": 24, - "type": "integer", - "default": 90, - "description": "持续时间 (小时或天数)`", - "name": "duration", - "in": "query" - }, - { - "enum": [ - "hour", - "day" - ], - "type": "string", - "default": "day", - "description": "精度: \"hour\", \"day\"", - "name": "precision", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "用户ID,可选参数", - "name": "user_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.UserCodeRank" - } - } - } - } - ] - } - } - } - } - }, - "/api/v1/dashboard/user-events": { - "get": { - "description": "获取用户事件", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Dashboard" - ], - "summary": "获取用户事件", - "operationId": "user-events-dashboard", - "parameters": [ - { - "maximum": 90, - "minimum": 24, - "type": "integer", - "default": 90, - "description": "持续时间 (小时或天数)`", - "name": "duration", - "in": "query" - }, - { - "enum": [ - "hour", - "day" - ], - "type": "string", - "default": "day", - "description": "精度: \"hour\", \"day\"", - "name": "precision", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "用户ID,可选参数", - "name": "user_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.UserEvent" - } - } - } - } - ] - } - } - } - } - }, - "/api/v1/dashboard/user-heatmap": { - "get": { - "description": "用户热力图", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Dashboard" - ], - "summary": "用户热力图", - "operationId": "user-heatmap-dashboard", - "parameters": [ - { - "type": "string", - "description": "用户ID", - "name": "user_id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.UserHeatmapResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/dashboard/user-stat": { - "get": { - "description": "获取用户统计信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Dashboard" - ], - "summary": "获取用户统计信息", - "operationId": "user-stat-dashboard", - "parameters": [ - { - "maximum": 90, - "minimum": 24, - "type": "integer", - "default": 90, - "description": "持续时间 (小时或天数)`", - "name": "duration", - "in": "query" - }, - { - "enum": [ - "hour", - "day" - ], - "type": "string", - "default": "day", - "description": "精度: \"hour\", \"day\"", - "name": "precision", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "用户ID,可选参数", - "name": "user_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.UserStat" - } - } - } - ] - } - } - } - } - }, - "/api/v1/ide/codesnippet/context": { - "post": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "为IDE端提供代码片段上下文检索功能,使用API Key认证。支持单个查询和批量查询。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "CodeSnippet" - ], - "summary": "IDE端上下文检索", - "operationId": "get-context", - "parameters": [ - { - "description": "检索请求参数", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/v1.GetContextReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.CodeSnippet" - } - } - } - } - ] - } - } - } - } - }, - "/api/v1/ide/codesnippet/semantic": { - "post": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "为IDE端提供代码片段语义搜索功能,使用API Key认证。通过向量相似性搜索找到相关的代码片段。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "CodeSnippet" - ], - "summary": "IDE端语义搜索", - "operationId": "get-semantic-context", - "parameters": [ - { - "description": "语义搜索请求参数", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/v1.GetSemanticContextReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.CodeSnippet" - } - } - } - } - ] - } - } - } - } - }, - "/api/v1/license": { - "get": { - "description": "Get license", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "license" - ], - "summary": "Get license", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.LicenseResp" - } - } - } - ] - } - } - } - }, - "post": { - "description": "Upload license", - "consumes": [ - "multipart/form-data" - ], - "produces": [ - "application/json" - ], - "tags": [ - "license" - ], - "summary": "Upload license", - "parameters": [ - { - "enum": [ - "file", - "code" - ], - "type": "string", - "description": "license type", - "name": "license_type", - "in": "formData", - "required": true - }, - { - "type": "file", - "description": "license file", - "name": "license_file", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "license code", - "name": "license_code", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.LicenseResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/model": { - "get": { - "description": "获取模型列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Model" - ], - "summary": "获取模型列表", - "operationId": "list-model", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.AllModelResp" - } - } - } - ] - } - } - } - }, - "put": { - "description": "更新模型", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Model" - ], - "summary": "更新模型", - "operationId": "update-model", - "parameters": [ - { - "description": "模型", - "name": "model", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateModelReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.Model" - } - } - } - ] - } - } - } - }, - "post": { - "description": "创建模型", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Model" - ], - "summary": "创建模型", - "operationId": "create-model", - "parameters": [ - { - "description": "模型", - "name": "model", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateModelReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.Model" - } - } - } - ] - } - } - } - }, - "delete": { - "description": "删除模型", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Model" - ], - "summary": "删除模型", - "operationId": "delete-model", - "parameters": [ - { - "type": "string", - "description": "模型ID", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/model/check": { - "post": { - "description": "检查模型", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Model" - ], - "summary": "检查模型", - "operationId": "check-model", - "parameters": [ - { - "description": "模型", - "name": "model", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CheckModelReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.Model" - } - } - } - ] - } - } - } - } - }, - "/api/v1/model/my": { - "get": { - "description": "获取我的模型列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Model" - ], - "summary": "获取我的模型列表", - "operationId": "my-model-list", - "parameters": [ - { - "enum": [ - "llm", - "coder", - "embedding", - "audio", - "reranker" - ], - "type": "string", - "x-enum-varnames": [ - "ModelTypeLLM", - "ModelTypeCoder", - "ModelTypeEmbedding", - "ModelTypeAudio", - "ModelTypeReranker" - ], - "description": "模型类型 llm:对话模型 coder:代码模型", - "name": "model_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.Model" - } - } - } - } - ] - } - } - } - } - }, - "/api/v1/model/provider/supported": { - "get": { - "description": "获取供应商支持的模型列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Model" - ], - "summary": "获取供应商支持的模型列表", - "operationId": "get-provider-model-list", - "parameters": [ - { - "type": "string", - "name": "api_header", - "in": "query" - }, - { - "type": "string", - "name": "api_key", - "in": "query" - }, - { - "type": "string", - "name": "base_url", - "in": "query", - "required": true - }, - { - "enum": [ - "SiliconFlow", - "OpenAI", - "Ollama", - "DeepSeek", - "Moonshot", - "AzureOpenAI", - "BaiZhiCloud", - "Hunyuan", - "BaiLian", - "Volcengine" - ], - "type": "string", - "x-enum-varnames": [ - "ModelProviderSiliconFlow", - "ModelProviderOpenAI", - "ModelProviderOllama", - "ModelProviderDeepSeek", - "ModelProviderMoonshot", - "ModelProviderAzureOpenAI", - "ModelProviderBaiZhiCloud", - "ModelProviderHunyuan", - "ModelProviderBaiLian", - "ModelProviderVolcengine" - ], - "name": "provider", - "in": "query", - "required": true - }, - { - "enum": [ - "llm", - "coder", - "embedding", - "audio", - "reranker" - ], - "type": "string", - "x-enum-varnames": [ - "ModelTypeLLM", - "ModelTypeCoder", - "ModelTypeEmbedding", - "ModelTypeAudio", - "ModelTypeReranker" - ], - "name": "type", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.GetProviderModelListResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/model/token-usage": { - "get": { - "description": "获取模型token使用情况", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Model" - ], - "summary": "获取模型token使用情况", - "operationId": "get-token-usage", - "parameters": [ - { - "enum": [ - "llm", - "coder", - "embedding", - "audio", - "reranker" - ], - "type": "string", - "x-enum-varnames": [ - "ModelTypeLLM", - "ModelTypeCoder", - "ModelTypeEmbedding", - "ModelTypeAudio", - "ModelTypeReranker" - ], - "description": "模型类型 llm:对话模型 coder:代码模型", - "name": "model_type", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ModelTokenUsageResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/security/scanning": { - "get": { - "description": "获取扫描结果", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Security Scanning" - ], - "summary": "获取扫描结果", - "operationId": "security-scanning-list", - "parameters": [ - { - "type": "string", - "description": "作者", - "name": "author", - "in": "query" - }, - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "string", - "description": "项目名称", - "name": "project_name", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListSecurityScanningResp" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/security/scanning/detail": { - "get": { - "description": "获取扫描风险详情", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Security Scanning" - ], - "summary": "获取扫描风险详情", - "operationId": "security-scanning-detail", - "parameters": [ - { - "type": "string", - "description": "扫描任务id", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.SecurityScanningRiskDetail" - } - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/static/vsix": { - "get": { - "description": "下载VSCode插件", - "consumes": [ - "application/json" - ], - "produces": [ - "application/octet-stream" - ], - "tags": [ - "User" - ], - "summary": "下载VSCode插件", - "operationId": "vsix-download", - "responses": {} - } - }, - "/api/v1/user/chat/info": { - "get": { - "description": "获取对话内容", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Record" - ], - "summary": "获取对话内容", - "operationId": "user-chat-info", - "parameters": [ - { - "type": "string", - "description": "对话记录ID", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ChatInfo" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/user/chat/record": { - "get": { - "description": "获取用户对话记录", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Record" - ], - "summary": "获取用户对话记录", - "operationId": "user-list-chat-record", - "parameters": [ - { - "type": "string", - "description": "作者", - "name": "author", - "in": "query" - }, - { - "type": "boolean", - "description": "是否接受筛选", - "name": "is_accept", - "in": "query" - }, - { - "type": "string", - "description": "语言", - "name": "language", - "in": "query" - }, - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - }, - { - "type": "string", - "description": "工作模式", - "name": "work_mode", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListChatRecordResp" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/user/completion/info": { - "get": { - "description": "获取补全内容", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Record" - ], - "summary": "获取补全内容", - "operationId": "user-completion-info", - "parameters": [ - { - "type": "string", - "description": "补全记录ID", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.CompletionInfo" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/user/completion/record": { - "get": { - "description": "获取补全记录", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Record" - ], - "summary": "获取补全记录", - "operationId": "user-list-completion-record", - "parameters": [ - { - "type": "string", - "description": "作者", - "name": "author", - "in": "query" - }, - { - "type": "boolean", - "description": "是否接受筛选", - "name": "is_accept", - "in": "query" - }, - { - "type": "string", - "description": "语言", - "name": "language", - "in": "query" - }, - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - }, - { - "type": "string", - "description": "工作模式", - "name": "work_mode", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListCompletionRecordResp" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/user/dashboard/events": { - "get": { - "description": "获取用户事件", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Dashboard" - ], - "summary": "获取用户事件", - "operationId": "user-dashboard-events", - "parameters": [ - { - "maximum": 90, - "minimum": 24, - "type": "integer", - "default": 90, - "description": "持续时间 (小时或天数)`", - "name": "duration", - "in": "query" - }, - { - "enum": [ - "hour", - "day" - ], - "type": "string", - "default": "day", - "description": "精度: \"hour\", \"day\"", - "name": "precision", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "用户ID,可选参数", - "name": "user_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.UserEvent" - } - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/user/dashboard/heatmap": { - "get": { - "description": "用户热力图", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Dashboard" - ], - "summary": "用户热力图", - "operationId": "user-dashboard-heatmap", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.UserHeatmapResp" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/user/dashboard/stat": { - "get": { - "description": "获取用户统计信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Dashboard" - ], - "summary": "获取用户统计信息", - "operationId": "user-dashboard-stat", - "parameters": [ - { - "maximum": 90, - "minimum": 24, - "type": "integer", - "default": 90, - "description": "持续时间 (小时或天数)`", - "name": "duration", - "in": "query" - }, - { - "enum": [ - "hour", - "day" - ], - "type": "string", - "default": "day", - "description": "精度: \"hour\", \"day\"", - "name": "precision", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "用户ID,可选参数", - "name": "user_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.UserStat" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/user/delete": { - "delete": { - "description": "删除用户", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "删除用户", - "operationId": "delete-user", - "parameters": [ - { - "type": "string", - "description": "用户ID", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "object" - } - } - } - ] - } - } - } - } - }, - "/api/v1/user/invite": { - "get": { - "description": "获取用户邀请码", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "获取用户邀请码", - "operationId": "invite", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.InviteResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/user/list": { - "get": { - "description": "获取用户列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "获取用户列表", - "operationId": "list-user", - "parameters": [ - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListUserResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/user/login": { - "post": { - "description": "用户登录", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "用户登录", - "operationId": "login", - "parameters": [ - { - "description": "登录参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.LoginReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.LoginResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/user/login-history": { - "get": { - "description": "获取用户登录历史", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "获取用户登录历史", - "operationId": "login-history", - "parameters": [ - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListLoginHistoryResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/user/logout": { - "post": { - "description": "用户登出", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "用户登出", - "operationId": "logout", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/user/oauth/callback": { - "get": { - "description": "用户 OAuth 回调", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "用户 OAuth 回调", - "operationId": "user-oauth-callback", - "parameters": [ - { - "type": "string", - "name": "code", - "in": "query", - "required": true - }, - { - "type": "string", - "name": "state", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "string" - } - } - } - ] - } - } - } - } - }, - "/api/v1/user/oauth/signup-or-in": { - "get": { - "description": "用户 OAuth 登录或注册", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "用户 OAuth 登录或注册", - "operationId": "user-oauth-signup-or-in", - "parameters": [ - { - "type": "string", - "description": "邀请码", - "name": "inviate_code", - "in": "query" - }, - { - "enum": [ - "email", - "dingtalk", - "custom" - ], - "type": "string", - "x-enum-varnames": [ - "UserPlatformEmail", - "UserPlatformDingTalk", - "UserPlatformCustom" - ], - "description": "第三方平台 dingtalk", - "name": "platform", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "登录成功后跳转的 URL", - "name": "redirect_url", - "in": "query" - }, - { - "type": "string", - "description": "会话ID", - "name": "session_id", - "in": "query" - }, - { - "enum": [ - "plugin", - "browser" - ], - "type": "string", - "default": "plugin", - "x-enum-varnames": [ - "LoginSourcePlugin", - "LoginSourceBrowser" - ], - "description": "登录来源 plugin: 插件 browser: 浏览器; 默认为 plugin", - "name": "source", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.OAuthURLResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/user/profile": { - "get": { - "description": "获取用户信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Manage" - ], - "summary": "获取用户信息", - "operationId": "user-profile", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.User" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - }, - "put": { - "description": "更新用户信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Manage" - ], - "summary": "更新用户信息", - "operationId": "user-update-profile", - "parameters": [ - { - "description": "param", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ProfileUpdateReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.User" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/user/register": { - "post": { - "description": "注册用户", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "注册用户", - "operationId": "register", - "parameters": [ - { - "description": "注册参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.RegisterReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.User" - } - } - } - ] - } - } - } - } - }, - "/api/v1/user/security/scanning": { - "get": { - "description": "获取用户扫描结果", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Security Scanning" - ], - "summary": "获取用户扫描结果", - "operationId": "user-security-scanning-list", - "parameters": [ - { - "type": "string", - "description": "作者", - "name": "author", - "in": "query" - }, - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "string", - "description": "项目名称", - "name": "project_name", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListSecurityScanningResp" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/user/security/scanning/detail": { - "get": { - "description": "获取用户扫描风险详情", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User Security Scanning" - ], - "summary": "获取用户扫描风险详情", - "operationId": "user-security-scanning-detail", - "parameters": [ - { - "type": "string", - "description": "扫描任务id", - "name": "id", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.SecurityScanningRiskDetail" - } - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "type": "string" - } - } - } - } - }, - "/api/v1/user/update": { - "put": { - "description": "更新用户", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "更新用户", - "operationId": "update-user", - "parameters": [ - { - "description": "更新用户参数", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateUserReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.User" - } - } - } - ] - } - } - } - } - }, - "/api/v1/workspace/files": { - "get": { - "description": "分页获取工作区文件列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "获取工作区文件列表", - "operationId": "list-workspace-files", - "parameters": [ - { - "type": "string", - "description": "编程语言筛选", - "name": "language", - "in": "query" - }, - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "string", - "description": "搜索关键词(文件路径)", - "name": "search", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - }, - { - "type": "string", - "description": "用户ID", - "name": "user_id", - "in": "query" - }, - { - "type": "string", - "description": "工作区ID", - "name": "workspace_id", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListWorkspaceFileResp" - } - } - } - ] - } - } - } - }, - "post": { - "description": "创建一个新的工作区文件", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "创建工作区文件", - "operationId": "create-workspace-file", - "parameters": [ - { - "description": "文件信息", - "name": "file", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateWorkspaceFileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.WorkspaceFile" - } - } - } - ] - } - } - } - } - }, - "/api/v1/workspace/files/batch": { - "put": { - "description": "批量更新多个工作区文件", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "批量更新工作区文件", - "operationId": "batch-update-workspace-files", - "parameters": [ - { - "description": "文件列表", - "name": "files", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.BatchUpdateWorkspaceFileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.WorkspaceFile" - } - } - } - } - ] - } - } - } - }, - "post": { - "description": "批量创建多个工作区文件", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "批量创建工作区文件", - "operationId": "batch-create-workspace-files", - "parameters": [ - { - "description": "文件列表", - "name": "files", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.BatchCreateWorkspaceFileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.WorkspaceFile" - } - } - } - } - ] - } - } - } - } - }, - "/api/v1/workspace/files/by-path": { - "get": { - "description": "根据用户ID、项目ID和文件路径获取工作区文件", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "根据路径获取工作区文件", - "operationId": "get-workspace-file-by-path", - "parameters": [ - { - "type": "string", - "description": "用户ID", - "name": "user_id", - "in": "query" - }, - { - "type": "string", - "description": "项目ID", - "name": "project_id", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "文件路径", - "name": "path", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.WorkspaceFile" - } - } - } - ] - } - } - } - } - }, - "/api/v1/workspace/files/get-and-save": { - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "获取并保存工作区文件", - "parameters": [ - { - "description": "请求参数", - "name": "req", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.GetAndSaveReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/api/v1/workspace/files/sync": { - "post": { - "description": "同步本地文件到工作区,智能检测新增、修改和删除", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "同步工作区文件", - "operationId": "sync-workspace-files", - "parameters": [ - { - "description": "同步信息", - "name": "sync", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.SyncWorkspaceFileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.SyncWorkspaceFileResp" - } - } - } - ] - } - } - } - } - }, - "/api/v1/workspace/files/{id}": { - "get": { - "description": "根据文件ID获取工作区文件详情", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "根据ID获取工作区文件", - "operationId": "get-workspace-file-by-id", - "parameters": [ - { - "type": "string", - "description": "文件ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.WorkspaceFile" - } - } - } - ] - } - } - } - }, - "put": { - "description": "更新指定的工作区文件", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "更新工作区文件", - "operationId": "update-workspace-file", - "parameters": [ - { - "type": "string", - "description": "文件ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "更新信息", - "name": "file", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.UpdateWorkspaceFileReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.WorkspaceFile" - } - } - } - ] - } - } - } - }, - "delete": { - "description": "删除指定的工作区文件", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "WorkspaceFile" - ], - "summary": "删除工作区文件", - "operationId": "delete-workspace-file", - "parameters": [ - { - "type": "string", - "description": "文件ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/v1/chat/completions": { - "post": { - "description": "处理聊天补全请求", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "处理聊天补全请求", - "operationId": "chat-completion", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/v1/completion/accept": { - "post": { - "description": "接受补全请求", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "接受补全请求", - "operationId": "accept-completion", - "parameters": [ - { - "description": "补全请求", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.AcceptCompletionReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/v1/completions": { - "post": { - "description": "处理文本补全请求", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "处理文本补全请求", - "operationId": "completions", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/v1/embeddings": { - "post": { - "description": "处理嵌入请求", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "处理嵌入请求", - "operationId": "embeddings", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/v1/health": { - "get": { - "description": "固定回包 `{\"code\": 0, \"data\": \"MonkeyCode\"}`", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "健康检查", - "operationId": "health", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/v1/models": { - "get": { - "description": "模型列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "模型列表", - "operationId": "model-list", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ModelListResp" - } - } - } - ] - } - } - } - } - }, - "/v1/report": { - "post": { - "description": "报告,支持多种操作:accept(接受补全)、suggest(建议)、reject(拒绝补全并记录用户输入)、file_written(文件写入)", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "报告", - "operationId": "report", - "parameters": [ - { - "description": "报告请求", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ReportReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/v1/security/scanning": { - "get": { - "description": "扫描任务列表", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "扫描任务列表", - "operationId": "list-security-scanning", - "parameters": [ - { - "description": "扫描任务列表请求", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.ListSecurityScanningReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListSecurityScanningBriefResp" - } - } - } - ] - } - } - } - }, - "post": { - "description": "创建扫描任务", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "创建扫描任务", - "operationId": "create-security-scanning", - "parameters": [ - { - "description": "创建扫描任务请求", - "name": "param", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.CreateSecurityScanningReq" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/web.Resp" - } - } - } - } - }, - "/v1/security/scanning/detail": { - "get": { - "description": "分页只支持 next_token; 首页传空,后续判断has_next_page是否为true,传入回包给的next_token", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OpenAIV1" - ], - "summary": "获取扫描任务风险详情列表", - "operationId": "list-security-scanning-detail", - "parameters": [ - { - "type": "string", - "description": "扫描任务id", - "name": "id", - "in": "query" - }, - { - "type": "string", - "description": "下一页标识", - "name": "next_token", - "in": "query" - }, - { - "type": "integer", - "description": "分页", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "每页多少条记录", - "name": "size", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/web.Resp" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/domain.ListSecurityScanningDetailResp" - } - } - } - ] - } - } - } - } - } - }, - "definitions": { - "consts.AdminStatus": { - "type": "string", - "enum": [ - "active", - "inactive" - ], - "x-enum-varnames": [ - "AdminStatusActive", - "AdminStatusInactive" - ] - }, - "consts.ChatRole": { - "type": "string", - "enum": [ - "user", - "assistant", - "system" - ], - "x-enum-varnames": [ - "ChatRoleUser", - "ChatRoleAssistant", - "ChatRoleSystem" - ] - }, - "consts.LoginSource": { - "type": "string", - "enum": [ - "plugin", - "browser" - ], - "x-enum-varnames": [ - "LoginSourcePlugin", - "LoginSourceBrowser" - ] - }, - "consts.ModelProvider": { - "type": "string", - "enum": [ - "SiliconFlow", - "OpenAI", - "Ollama", - "DeepSeek", - "Moonshot", - "AzureOpenAI", - "BaiZhiCloud", - "Hunyuan", - "BaiLian", - "Volcengine" - ], - "x-enum-varnames": [ - "ModelProviderSiliconFlow", - "ModelProviderOpenAI", - "ModelProviderOllama", - "ModelProviderDeepSeek", - "ModelProviderMoonshot", - "ModelProviderAzureOpenAI", - "ModelProviderBaiZhiCloud", - "ModelProviderHunyuan", - "ModelProviderBaiLian", - "ModelProviderVolcengine" - ] - }, - "consts.ModelStatus": { - "type": "string", - "enum": [ - "active", - "inactive" - ], - "x-enum-varnames": [ - "ModelStatusActive", - "ModelStatusInactive" - ] - }, - "consts.ModelType": { - "type": "string", - "enum": [ - "llm", - "coder", - "embedding", - "audio", - "reranker" - ], - "x-enum-varnames": [ - "ModelTypeLLM", - "ModelTypeCoder", - "ModelTypeEmbedding", - "ModelTypeAudio", - "ModelTypeReranker" - ] - }, - "consts.ReportAction": { - "type": "string", - "enum": [ - "accept", - "suggest", - "file_written", - "reject", - "new_task", - "feedback_task", - "abort_task" - ], - "x-enum-varnames": [ - "ReportActionAccept", - "ReportActionSuggest", - "ReportActionFileWritten", - "ReportActionReject", - "ReportActionNewTask", - "ReportActionFeedbackTask", - "ReportActionAbortTask" - ] - }, - "consts.SecurityScanningLanguage": { - "type": "string", - "enum": [ - "C/C++", - "Java", - "Python", - "JavaScript", - "Go", - "PHP", - "C#", - "Swift", - "Ruby", - "Rust", - "HTML", - "Objective-C/C++", - "OCaml", - "Kotlin", - "Scala", - "Solidity", - "COBOL", - "Shell", - "SQL", - "Fortran", - "Dart", - "Groovy", - "Lua", - "Secrets", - "IaC" - ], - "x-enum-varnames": [ - "SecurityScanningLanguageCpp", - "SecurityScanningLanguageJava", - "SecurityScanningLanguagePython", - "SecurityScanningLanguageJavaScript", - "SecurityScanningLanguageGo", - "SecurityScanningLanguagePHP", - "SecurityScanningLanguageCS", - "SecurityScanningLanguageSwift", - "SecurityScanningLanguageRuby", - "SecurityScanningLanguageRust", - "SecurityScanningLanguageHTML", - "SecurityScanningLanguageObjectiveC", - "SecurityScanningLanguageOCaml", - "SecurityScanningLanguageKotlin", - "SecurityScanningLanguageScala", - "SecurityScanningLanguageSolidity", - "SecurityScanningLanguageCOBOL", - "SecurityScanningLanguageShell", - "SecurityScanningLanguageSQL", - "SecurityScanningLanguageFortran", - "SecurityScanningLanguageDart", - "SecurityScanningLanguageGroovy", - "SecurityScanningLanguageLua", - "SecurityScanningLanguageSecrets", - "SecurityScanningLanguageIaC" - ] - }, - "consts.SecurityScanningRiskLevel": { - "type": "string", - "enum": [ - "severe", - "critical", - "suggest" - ], - "x-enum-comments": { - "SecurityScanningRiskLevelCritical": "高危", - "SecurityScanningRiskLevelSevere": "严重", - "SecurityScanningRiskLevelSuggest": "建议" - }, - "x-enum-varnames": [ - "SecurityScanningRiskLevelSevere", - "SecurityScanningRiskLevelCritical", - "SecurityScanningRiskLevelSuggest" - ] - }, - "consts.SecurityScanningStatus": { - "type": "string", - "enum": [ - "pending", - "running", - "success", - "failed" - ], - "x-enum-varnames": [ - "SecurityScanningStatusPending", - "SecurityScanningStatusRunning", - "SecurityScanningStatusSuccess", - "SecurityScanningStatusFailed" - ] - }, - "consts.UserPlatform": { - "type": "string", - "enum": [ - "email", - "dingtalk", - "custom" - ], - "x-enum-varnames": [ - "UserPlatformEmail", - "UserPlatformDingTalk", - "UserPlatformCustom" - ] - }, - "consts.UserStatus": { - "type": "string", - "enum": [ - "active", - "inactive", - "locked" - ], - "x-enum-varnames": [ - "UserStatusActive", - "UserStatusInactive", - "UserStatusLocked" - ] - }, - "domain.AcceptCompletionReq": { - "type": "object", - "properties": { - "completion": { - "description": "补全内容", - "type": "string" - }, - "id": { - "description": "记录ID", - "type": "string" - } - } - }, - "domain.AdminLoginHistory": { - "type": "object", - "properties": { - "client_version": { - "description": "客户端版本", - "type": "string" - }, - "created_at": { - "description": "登录时间", - "type": "integer" - }, - "device": { - "description": "设备信息", - "type": "string" - }, - "ip_info": { - "description": "IP信息", - "allOf": [ - { - "$ref": "#/definitions/domain.IPInfo" - } - ] - }, - "user": { - "description": "用户信息", - "allOf": [ - { - "$ref": "#/definitions/domain.AdminUser" - } - ] - } - } - }, - "domain.AdminUser": { - "type": "object", - "properties": { - "created_at": { - "description": "创建时间", - "type": "integer" - }, - "id": { - "description": "用户ID", - "type": "string" - }, - "last_active_at": { - "description": "最后活跃时间", - "type": "integer" - }, - "role": { - "description": "角色", - "allOf": [ - { - "$ref": "#/definitions/domain.Role" - } - ] - }, - "status": { - "description": "用户状态 active: 正常 inactive: 禁用", - "allOf": [ - { - "$ref": "#/definitions/consts.AdminStatus" - } - ] - }, - "username": { - "description": "用户名", - "type": "string" - } - } - }, - "domain.AllModelResp": { - "type": "object", - "properties": { - "providers": { - "description": "提供商列表", - "type": "array", - "items": { - "$ref": "#/definitions/domain.ProviderModel" - } - } - } - }, - "domain.BatchCreateWorkspaceFileReq": { - "type": "object", - "required": [ - "files", - "user_id", - "workspace_id" - ], - "properties": { - "files": { - "description": "文件列表", - "type": "array", - "items": { - "$ref": "#/definitions/domain.CreateWorkspaceFileReq" - } - }, - "user_id": { - "description": "用户ID", - "type": "string" - }, - "workspace_id": { - "description": "工作区ID", - "type": "string" - } - } - }, - "domain.BatchUpdateWorkspaceFileReq": { - "type": "object", - "required": [ - "files" - ], - "properties": { - "files": { - "description": "文件列表", - "type": "array", - "items": { - "$ref": "#/definitions/domain.UpdateWorkspaceFileReq" - } - } - } - }, - "domain.CategoryPoint": { - "type": "object", - "properties": { - "category": { - "description": "分类", - "type": "string" - }, - "value": { - "description": "值", - "type": "integer" - } - } - }, - "domain.CategoryStat": { - "type": "object", - "properties": { - "program_language": { - "description": "编程语言占比", - "type": "array", - "items": { - "$ref": "#/definitions/domain.CategoryPoint" - } - }, - "work_mode": { - "description": "工作模式占比", - "type": "array", - "items": { - "$ref": "#/definitions/domain.CategoryPoint" - } - } - } - }, - "domain.ChatContent": { - "type": "object", - "properties": { - "content": { - "description": "内容", - "type": "string" - }, - "created_at": { - "type": "integer" - }, - "role": { - "description": "角色,如user: 用户的提问 assistant: 机器人回复 system: 系统消息", - "allOf": [ - { - "$ref": "#/definitions/consts.ChatRole" - } - ] - } - } - }, - "domain.ChatInfo": { - "type": "object", - "properties": { - "contents": { - "description": "消息内容", - "type": "array", - "items": { - "$ref": "#/definitions/domain.ChatContent" - } - }, - "id": { - "type": "string" - } - } - }, - "domain.ChatRecord": { - "type": "object", - "properties": { - "created_at": { - "description": "创建时间", - "type": "integer" - }, - "id": { - "description": "记录ID", - "type": "string" - }, - "input_tokens": { - "description": "输入token", - "type": "integer" - }, - "model": { - "description": "模型", - "allOf": [ - { - "$ref": "#/definitions/domain.Model" - } - ] - }, - "output_tokens": { - "description": "输出token", - "type": "integer" - }, - "question": { - "description": "问题", - "type": "string" - }, - "user": { - "description": "用户", - "allOf": [ - { - "$ref": "#/definitions/domain.User" - } - ] - }, - "work_mode": { - "description": "工作模式", - "type": "string" - } - } - }, - "domain.CheckModelReq": { - "type": "object", - "required": [ - "api_base", - "model_name", - "provider", - "type" - ], - "properties": { - "api_base": { - "description": "接口地址", - "type": "string" - }, - "api_header": { - "type": "string" - }, - "api_key": { - "description": "接口密钥", - "type": "string" - }, - "api_version": { - "type": "string" - }, - "model_name": { - "description": "模型名称", - "type": "string" - }, - "provider": { - "description": "提供商", - "allOf": [ - { - "$ref": "#/definitions/consts.ModelProvider" - } - ] - }, - "type": { - "enum": [ - "llm", - "coder", - "embedding", - "rerank" - ], - "allOf": [ - { - "$ref": "#/definitions/consts.ModelType" - } - ] - } - } - }, - "domain.CodeLanguageType": { - "type": "string", - "enum": [ - "go", - "python", - "java", - "javascript", - "typescript", - "jsx", - "tsx", - "html", - "css", - "php", - "rust", - "swift", - "kotlin", - "c", - "cpp" - ], - "x-enum-varnames": [ - "CodeLanguageTypeGo", - "CodeLanguageTypePython", - "CodeLanguageTypeJava", - "CodeLanguageTypeJavaScript", - "CodeLanguageTypeTypeScript", - "CodeLanguageTypeJSX", - "CodeLanguageTypeTSX", - "CodeLanguageTypeHTML", - "CodeLanguageTypeCSS", - "CodeLanguageTypePHP", - "CodeLanguageTypeRust", - "CodeLanguageTypeSwift", - "CodeLanguageTypeKotlin", - "CodeLanguageTypeC", - "CodeLanguageTypeCpp" - ] - }, - "domain.CodeSnippet": { - "type": "object", - "properties": { - "definition": { - "description": "结构化信息", - "type": "object", - "additionalProperties": {} - }, - "definitionText": { - "description": "定义文本", - "type": "string" - }, - "dependencies": { - "description": "依赖项", - "type": "array", - "items": { - "type": "string" - } - }, - "embedding": { - "description": "向量嵌入", - "type": "array", - "items": { - "type": "number" - } - }, - "endColumn": { - "description": "结束列号", - "type": "integer" - }, - "endLine": { - "description": "结束行号", - "type": "integer" - }, - "field": { - "description": "容器名称", - "type": "string" - }, - "fileHash": { - "description": "内容哈希", - "type": "string" - }, - "filePath": { - "description": "文件路径", - "type": "string" - }, - "id": { - "description": "代码片段ID", - "type": "string" - }, - "language": { - "description": "编程语言", - "type": "string" - }, - "name": { - "description": "代码片段名称", - "type": "string" - }, - "namespace": { - "description": "命名空间", - "type": "string" - }, - "parameters": { - "description": "参数列表", - "type": "array", - "items": { - "type": "object", - "additionalProperties": {} - } - }, - "rangeText": { - "description": "代码片段内容", - "type": "string" - }, - "scope": { - "description": "作用域信息", - "type": "array", - "items": { - "type": "string" - } - }, - "signature": { - "description": "函数签名", - "type": "string" - }, - "startColumn": { - "description": "起始列号", - "type": "integer" - }, - "startLine": { - "description": "起始行号", - "type": "integer" - }, - "type": { - "description": "代码片段类型", - "type": "string" - }, - "workspace_file_id": { - "description": "关联的workspace file ID", - "type": "string" - } - } - }, - "domain.CompletionData": { - "type": "object", - "properties": { - "code_lines": { - "description": "代码行数", - "type": "integer" - }, - "completion": { - "description": "LLM生成的补全代码", - "type": "string" - }, - "created_at": { - "description": "创建时间戳", - "type": "integer" - }, - "cursor_position": { - "description": "光标位置 {\"line\": 10, \"column\": 5}", - "type": "object", - "additionalProperties": {} - }, - "input_tokens": { - "description": "输入token数", - "type": "integer" - }, - "is_accept": { - "description": "用户是否接受补全", - "type": "boolean" - }, - "is_suggested": { - "description": "是否为建议模式", - "type": "boolean" - }, - "model_id": { - "description": "模型ID", - "type": "string" - }, - "model_name": { - "description": "模型名称", - "type": "string" - }, - "model_type": { - "description": "模型类型", - "type": "string" - }, - "output_tokens": { - "description": "输出token数", - "type": "integer" - }, - "program_language": { - "description": "编程语言", - "type": "string" - }, - "prompt": { - "description": "用户输入的提示", - "type": "string" - }, - "request_id": { - "description": "请求ID", - "type": "string" - }, - "source_code": { - "description": "当前文件原文", - "type": "string" - }, - "task_id": { - "description": "任务ID", - "type": "string" - }, - "updated_at": { - "description": "更新时间戳", - "type": "integer" - }, - "user_id": { - "description": "用户ID", - "type": "string" - }, - "user_input": { - "description": "用户最终输入的内容", - "type": "string" - }, - "work_mode": { - "description": "工作模式", - "type": "string" - } - } - }, - "domain.CompletionInfo": { - "type": "object", - "properties": { - "content": { - "type": "string" - }, - "created_at": { - "type": "integer" - }, - "id": { - "type": "string" - }, - "prompt": { - "type": "string" - } - } - }, - "domain.CompletionRecord": { - "type": "object", - "properties": { - "created_at": { - "description": "创建时间", - "type": "integer" - }, - "id": { - "description": "记录ID", - "type": "string" - }, - "input_tokens": { - "description": "输入token", - "type": "integer" - }, - "is_accept": { - "description": "是否采纳", - "type": "boolean" - }, - "output_tokens": { - "description": "输出token", - "type": "integer" - }, - "program_language": { - "description": "编程语言", - "type": "string" - }, - "user": { - "description": "用户", - "allOf": [ - { - "$ref": "#/definitions/domain.User" - } - ] - } - } - }, - "domain.CreateAdminReq": { - "type": "object", - "required": [ - "password", - "role_id", - "username" - ], - "properties": { - "password": { - "description": "密码", - "type": "string" - }, - "role_id": { - "description": "角色ID", - "type": "integer" - }, - "username": { - "description": "用户名", - "type": "string" - } - } - }, - "domain.CreateModelReq": { - "type": "object", - "required": [ - "api_base", - "model_name", - "provider" - ], - "properties": { - "api_base": { - "description": "接口地址 如:https://api.qwen.com", - "type": "string" - }, - "api_header": { - "type": "string" - }, - "api_key": { - "description": "接口密钥 如:sk-xxxx", - "type": "string" - }, - "api_version": { - "type": "string" - }, - "model_name": { - "description": "模型名称 如: deepseek-v3", - "type": "string" - }, - "model_type": { - "description": "模型类型 llm:对话模型 coder:代码模型", - "allOf": [ - { - "$ref": "#/definitions/consts.ModelType" - } - ] - }, - "param": { - "description": "高级参数", - "allOf": [ - { - "$ref": "#/definitions/domain.ModelParam" - } - ] - }, - "provider": { - "description": "提供商", - "enum": [ - "SiliconFlow", - "OpenAI", - "Ollama", - "DeepSeek", - "Moonshot", - "AzureOpenAI", - "BaiZhiCloud", - "Hunyuan", - "BaiLian", - "Volcengine", - "Other" - ], - "allOf": [ - { - "$ref": "#/definitions/consts.ModelProvider" - } - ] - }, - "show_name": { - "description": "模型显示名称", - "type": "string" - } - } - }, - "domain.CreateSecurityScanningReq": { - "type": "object", - "properties": { - "language": { - "description": "扫描语言", - "allOf": [ - { - "$ref": "#/definitions/consts.SecurityScanningLanguage" - } - ] - }, - "user_id": { - "type": "string" - }, - "workspace": { - "description": "项目目录", - "type": "string" - } - } - }, - "domain.CreateUserGroupReq": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "description": "组名称", - "type": "string" - } - } - }, - "domain.CreateWorkspaceFileReq": { - "type": "object", - "required": [ - "hash", - "path", - "user_id", - "workspace_id" - ], - "properties": { - "content": { - "description": "文件内容", - "type": "string" - }, - "hash": { - "description": "文件哈希", - "type": "string" - }, - "language": { - "description": "编程语言", - "type": "string" - }, - "path": { - "description": "文件路径", - "type": "string" - }, - "size": { - "description": "文件大小", - "type": "integer" - }, - "user_id": { - "description": "用户ID", - "type": "string" - }, - "workspace_id": { - "description": "工作区ID", - "type": "string" - } - } - }, - "domain.CustomOAuth": { - "type": "object", - "properties": { - "access_token_url": { - "description": "自定义OAuth访问令牌URL", - "type": "string" - }, - "authorize_url": { - "description": "自定义OAuth授权URL", - "type": "string" - }, - "avatar_field": { - "description": "用户信息回包中的头像URL字段名", - "type": "string" - }, - "client_id": { - "description": "自定义客户端ID", - "type": "string" - }, - "client_secret": { - "description": "自定义客户端密钥", - "type": "string" - }, - "email_field": { - "description": "用户信息回包中的邮箱字段名", - "type": "string" - }, - "enable": { - "description": "自定义OAuth开关", - "type": "boolean" - }, - "id_field": { - "description": "用户信息回包中的ID字段名", - "type": "string" - }, - "name_field": { - "description": "用户信息回包中的用户名字段名", - "type": "string" - }, - "scopes": { - "description": "自定义OAuth Scope列表", - "type": "array", - "items": { - "type": "string" - } - }, - "userinfo_url": { - "description": "自定义OAuth用户信息URL", - "type": "string" - } - } - }, - "domain.CustomOAuthReq": { - "type": "object", - "properties": { - "access_token_url": { - "description": "自定义OAuth访问令牌URL", - "type": "string" - }, - "authorize_url": { - "description": "自定义OAuth授权URL", - "type": "string" - }, - "avatar_field": { - "description": "用户信息回包中的头像URL字段名", - "type": "string" - }, - "client_id": { - "description": "自定义客户端ID", - "type": "string" - }, - "client_secret": { - "description": "自定义客户端密钥", - "type": "string" - }, - "email_field": { - "description": "用户信息回包中的邮箱字段名", - "type": "string" - }, - "enable": { - "description": "自定义OAuth开关", - "type": "boolean" - }, - "id_field": { - "description": "用户信息回包中的ID字段名", - "type": "string" - }, - "name_field": { - "description": "用户信息回包中的用户名字段名", - "type": "string" - }, - "scopes": { - "description": "自定义OAuth Scope列表", - "type": "array", - "items": { - "type": "string" - } - }, - "userinfo_url": { - "description": "自定义OAuth用户信息URL", - "type": "string" - } - } - }, - "domain.DingtalkOAuth": { - "type": "object", - "properties": { - "client_id": { - "description": "钉钉客户端ID", - "type": "string" - }, - "client_secret": { - "description": "钉钉客户端密钥", - "type": "string" - }, - "enable": { - "description": "钉钉OAuth开关", - "type": "boolean" - } - } - }, - "domain.DingtalkOAuthReq": { - "type": "object", - "properties": { - "client_id": { - "description": "钉钉客户端ID", - "type": "string" - }, - "client_secret": { - "description": "钉钉客户端密钥", - "type": "string" - }, - "enable": { - "description": "钉钉OAuth开关", - "type": "boolean" - } - } - }, - "domain.ExportCompletionDataResp": { - "type": "object", - "properties": { - "data": { - "description": "补全数据列表", - "type": "array", - "items": { - "$ref": "#/definitions/domain.CompletionData" - } - }, - "total_count": { - "description": "总记录数", - "type": "integer" - } - } - }, - "domain.FileMeta": { - "type": "object", - "properties": { - "content": { - "description": "文件内容(可选)", - "type": "string" - }, - "fileExtension": { - "type": "string" - }, - "fileHash": { - "description": "文件哈希(可选)", - "type": "string" - }, - "filePath": { - "type": "string" - }, - "language": { - "description": "语言类型(可选)", - "allOf": [ - { - "$ref": "#/definitions/domain.CodeLanguageType" - } - ] - } - } - }, - "domain.GetAndSaveReq": { - "type": "object", - "required": [ - "code_files", - "user_id", - "workspace_id" - ], - "properties": { - "code_files": { - "description": "代码文件信息", - "type": "array", - "items": { - "$ref": "#/definitions/domain.FileMeta" - } - }, - "user_id": { - "description": "用户ID", - "type": "string" - }, - "workspace_id": { - "description": "项目ID", - "type": "string" - } - } - }, - "domain.GetProviderModelListResp": { - "type": "object", - "properties": { - "models": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.ProviderModelListItem" - } - } - } - }, - "domain.GrantGroupReq": { - "type": "object", - "required": [ - "admin_ids", - "group_ids" - ], - "properties": { - "admin_ids": { - "description": "管理员ID列表", - "type": "array", - "items": { - "type": "string" - } - }, - "group_ids": { - "description": "分组ID列表", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "domain.GrantRoleReq": { - "type": "object", - "properties": { - "admin_id": { - "description": "管理员ID", - "type": "string" - }, - "role_ids": { - "description": "角色ID列表", - "type": "array", - "items": { - "type": "integer" - } - } - } - }, - "domain.GroupAddUserReq": { - "type": "object", - "required": [ - "group_ids", - "user_ids" - ], - "properties": { - "group_ids": { - "description": "分组ID列表", - "type": "array", - "items": { - "type": "string" - } - }, - "user_ids": { - "description": "用户ID列表", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "domain.GroupRemoveAdminReq": { - "type": "object", - "required": [ - "admin_ids", - "group_id" - ], - "properties": { - "admin_ids": { - "description": "管理员ID列表", - "type": "array", - "items": { - "type": "string" - } - }, - "group_id": { - "description": "分组ID", - "type": "string" - } - } - }, - "domain.GroupRemoveUserReq": { - "type": "object", - "required": [ - "group_id", - "user_ids" - ], - "properties": { - "group_id": { - "description": "分组ID", - "type": "string" - }, - "user_ids": { - "description": "用户ID列表", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "domain.IPInfo": { - "type": "object", - "properties": { - "asn": { - "description": "ASN", - "type": "string" - }, - "city": { - "description": "城市", - "type": "string" - }, - "country": { - "description": "国家", - "type": "string" - }, - "ip": { - "description": "IP地址", - "type": "string" - }, - "isp": { - "description": "运营商", - "type": "string" - }, - "province": { - "description": "省份", - "type": "string" - } - } - }, - "domain.IndexResult": { - "type": "object", - "properties": { - "definition": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "returnType": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, - "definitionText": { - "type": "string" - }, - "endLine": { - "type": "integer" - }, - "fileHash": { - "type": "string" - }, - "filePath": { - "type": "string" - }, - "implementText": { - "type": "string" - }, - "language": { - "type": "string" - }, - "name": { - "type": "string" - }, - "rangeText": { - "type": "string" - }, - "scope": {}, - "signature": { - "type": "string" - }, - "startLine": { - "type": "integer" - }, - "type": { - "type": "string" - } - } - }, - "domain.InviteResp": { - "type": "object", - "properties": { - "code": { - "description": "邀请码", - "type": "string" - } - } - }, - "domain.LicenseEdition": { - "type": "integer", - "enum": [ - 0, - 1, - 2 - ], - "x-enum-varnames": [ - "LicenseEditionFree", - "LicenseEditionContributor", - "LicenseEditionEnterprise" - ] - }, - "domain.LicenseResp": { - "type": "object", - "properties": { - "edition": { - "$ref": "#/definitions/domain.LicenseEdition" - }, - "expired_at": { - "type": "integer" - }, - "started_at": { - "type": "integer" - }, - "state": { - "type": "integer" - } - } - }, - "domain.ListAdminLoginHistoryResp": { - "type": "object", - "properties": { - "has_next_page": { - "type": "boolean" - }, - "login_histories": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminLoginHistory" - } - }, - "next_token": { - "type": "string" - }, - "total_count": { - "type": "integer" - } - } - }, - "domain.ListAdminUserResp": { - "type": "object", - "properties": { - "has_next_page": { - "type": "boolean" - }, - "next_token": { - "type": "string" - }, - "total_count": { - "type": "integer" - }, - "users": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminUser" - } - } - } - }, - "domain.ListChatRecordResp": { - "type": "object", - "properties": { - "has_next_page": { - "type": "boolean" - }, - "next_token": { - "type": "string" - }, - "records": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.ChatRecord" - } - }, - "total_count": { - "type": "integer" - } - } - }, - "domain.ListCompletionRecordResp": { - "type": "object", - "properties": { - "has_next_page": { - "type": "boolean" - }, - "next_token": { - "type": "string" - }, - "records": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.CompletionRecord" - } - }, - "total_count": { - "type": "integer" - } - } - }, - "domain.ListLoginHistoryResp": { - "type": "object", - "properties": { - "has_next_page": { - "type": "boolean" - }, - "login_histories": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.UserLoginHistory" - } - }, - "next_token": { - "type": "string" - }, - "total_count": { - "type": "integer" - } - } - }, - "domain.ListSecurityScanningBriefResp": { - "type": "object", - "properties": { - "has_next_page": { - "type": "boolean" - }, - "items": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.SecurityScanningBrief" - } - }, - "next_token": { - "type": "string" - }, - "total_count": { - "type": "integer" - } - } - }, - "domain.ListSecurityScanningDetailResp": { - "type": "object", - "properties": { - "has_next_page": { - "type": "boolean" - }, - "items": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.SecurityScanningRiskDetail" - } - }, - "next_token": { - "type": "string" - }, - "total_count": { - "type": "integer" - } - } - }, - "domain.ListSecurityScanningReq": { - "type": "object", - "properties": { - "author": { - "description": "作者", - "type": "string" - }, - "next_token": { - "description": "下一页标识", - "type": "string" - }, - "page": { - "description": "分页", - "type": "integer" - }, - "project_name": { - "description": "项目名称", - "type": "string" - }, - "size": { - "description": "每页多少条记录", - "type": "integer" - } - } - }, - "domain.ListSecurityScanningResp": { - "type": "object", - "properties": { - "has_next_page": { - "type": "boolean" - }, - "items": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.SecurityScanningResult" - } - }, - "next_token": { - "type": "string" - }, - "total_count": { - "type": "integer" - } - } - }, - "domain.ListUserGroupResp": { - "type": "object", - "properties": { - "groups": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.UserGroup" - } - }, - "has_next_page": { - "type": "boolean" - }, - "next_token": { - "type": "string" - }, - "total_count": { - "type": "integer" - } - } - }, - "domain.ListUserResp": { - "type": "object", - "properties": { - "has_next_page": { - "type": "boolean" - }, - "next_token": { - "type": "string" - }, - "total_count": { - "type": "integer" - }, - "users": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.User" - } - } - } - }, - "domain.ListWorkspaceFileResp": { - "type": "object", - "properties": { - "files": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.WorkspaceFile" - } - }, - "has_next_page": { - "type": "boolean" - }, - "next_token": { - "type": "string" - }, - "total_count": { - "type": "integer" - } - } - }, - "domain.LoginReq": { - "type": "object", - "required": [ - "source" - ], - "properties": { - "password": { - "description": "密码", - "type": "string" - }, - "session_id": { - "description": "会话Id插件登录时必填", - "type": "string" - }, - "source": { - "description": "登录来源 plugin: 插件 browser: 浏览器; 默认为 plugin", - "default": "plugin", - "allOf": [ - { - "$ref": "#/definitions/consts.LoginSource" - } - ] - }, - "username": { - "description": "用户名", - "type": "string" - } - } - }, - "domain.LoginResp": { - "type": "object", - "properties": { - "redirect_url": { - "description": "重定向URL", - "type": "string" - }, - "user": { - "description": "用户信息", - "allOf": [ - { - "$ref": "#/definitions/domain.User" - } - ] - } - } - }, - "domain.Model": { - "type": "object", - "properties": { - "api_base": { - "description": "接口地址 如:https://api.qwen.com", - "type": "string" - }, - "api_header": { - "description": "接口头 如:Authorization: Bearer sk-xxxx", - "type": "string" - }, - "api_key": { - "description": "接口密钥 如:sk-xxxx", - "type": "string" - }, - "api_version": { - "description": "接口版本 如:2023-05-15", - "type": "string" - }, - "created_at": { - "description": "创建时间", - "type": "integer" - }, - "id": { - "description": "模型ID", - "type": "string" - }, - "input": { - "description": "输入token数", - "type": "integer" - }, - "is_active": { - "description": "是否启用", - "type": "boolean" - }, - "is_internal": { - "description": "是否内部模型", - "type": "boolean" - }, - "model_name": { - "description": "模型名称 如: deepseek-v3", - "type": "string" - }, - "model_type": { - "description": "模型类型 llm:对话模型 coder:代码模型", - "allOf": [ - { - "$ref": "#/definitions/consts.ModelType" - } - ] - }, - "output": { - "description": "输出token数", - "type": "integer" - }, - "param": { - "description": "高级参数", - "allOf": [ - { - "$ref": "#/definitions/domain.ModelParam" - } - ] - }, - "provider": { - "description": "提供商", - "allOf": [ - { - "$ref": "#/definitions/consts.ModelProvider" - } - ] - }, - "show_name": { - "description": "模型显示名称", - "type": "string" - }, - "status": { - "description": "状态 active:启用 inactive:禁用", - "allOf": [ - { - "$ref": "#/definitions/consts.ModelStatus" - } - ] - }, - "updated_at": { - "description": "更新时间", - "type": "integer" - } - } - }, - "domain.ModelBasic": { - "type": "object", - "required": [ - "provider" - ], - "properties": { - "api_base": { - "description": "接口地址 如:https://api.qwen.com", - "type": "string" - }, - "name": { - "description": "模型名称", - "type": "string" - }, - "provider": { - "description": "提供商", - "enum": [ - "SiliconFlow", - "OpenAI", - "Ollama", - "DeepSeek", - "Moonshot", - "AzureOpenAI", - "BaiZhiCloud", - "Hunyuan", - "BaiLian", - "Volcengine", - "Other" - ], - "allOf": [ - { - "$ref": "#/definitions/consts.ModelProvider" - } - ] - } - } - }, - "domain.ModelData": { - "type": "object", - "properties": { - "api_base": { - "type": "string" - }, - "base_model": { - "type": "string" - }, - "created": { - "type": "integer" - }, - "id": { - "type": "string" - }, - "is_active": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "object": { - "type": "string" - }, - "owned_by": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, - "domain.ModelListResp": { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.ModelData" - } - }, - "object": { - "type": "string" - } - } - }, - "domain.ModelParam": { - "type": "object", - "properties": { - "context_window": { - "type": "integer" - }, - "max_tokens": { - "type": "integer" - }, - "r1_enabled": { - "type": "boolean" - }, - "support_computer_use": { - "type": "boolean" - }, - "support_images": { - "type": "boolean" - }, - "support_prompt_cache": { - "type": "boolean" - } - } - }, - "domain.ModelTokenUsage": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "tokens": { - "description": "使用token数", - "type": "integer" - } - } - }, - "domain.ModelTokenUsageResp": { - "type": "object", - "properties": { - "input_usage": { - "description": "输入token使用记录", - "type": "array", - "items": { - "$ref": "#/definitions/domain.ModelTokenUsage" - } - }, - "output_usage": { - "description": "输出token使用记录", - "type": "array", - "items": { - "$ref": "#/definitions/domain.ModelTokenUsage" - } - }, - "total_input": { - "description": "总输入token数", - "type": "integer" - }, - "total_output": { - "description": "总输出token数", - "type": "integer" - } - } - }, - "domain.OAuthURLResp": { - "type": "object", - "properties": { - "url": { - "type": "string" - } - } - }, - "domain.ProfileUpdateReq": { - "type": "object", - "properties": { - "avatar": { - "description": "头像", - "type": "string" - }, - "old_password": { - "description": "旧密码", - "type": "string" - }, - "password": { - "description": "密码", - "type": "string" - }, - "username": { - "description": "用户名", - "type": "string" - } - } - }, - "domain.ProviderModel": { - "type": "object", - "properties": { - "models": { - "description": "模型列表", - "type": "array", - "items": { - "$ref": "#/definitions/domain.ModelBasic" - } - }, - "provider": { - "description": "提供商", - "type": "string" - } - } - }, - "domain.ProviderModelListItem": { - "type": "object", - "properties": { - "model": { - "type": "string" - } - } - }, - "domain.RegisterReq": { - "type": "object", - "required": [ - "code", - "email", - "password", - "username" - ], - "properties": { - "code": { - "description": "邀请码", - "type": "string" - }, - "email": { - "description": "邮箱", - "type": "string" - }, - "password": { - "description": "密码", - "type": "string" - }, - "username": { - "description": "用户名", - "type": "string" - } - } - }, - "domain.ReportReq": { - "type": "object", - "properties": { - "action": { - "$ref": "#/definitions/consts.ReportAction" - }, - "content": { - "description": "内容", - "type": "string" - }, - "cursor_position": { - "description": "光标位置(用于reject action)", - "type": "object", - "additionalProperties": {} - }, - "id": { - "description": "task_id or resp_id", - "type": "string" - }, - "mode": { - "description": "模式", - "type": "string" - }, - "source_code": { - "description": "当前文件的原文(用于reject action)", - "type": "string" - }, - "tool": { - "description": "工具", - "type": "string" - }, - "user_input": { - "description": "用户输入的新文本(用于reject action)", - "type": "string" - } - } - }, - "domain.Role": { - "type": "object", - "properties": { - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - } - } - }, - "domain.SecurityScanningBrief": { - "type": "object", - "properties": { - "created_at": { - "description": "创建时间", - "type": "integer" - }, - "id": { - "description": "扫描任务id", - "type": "string" - }, - "report_url": { - "description": "报告url", - "type": "string" - }, - "status": { - "description": "扫描状态", - "allOf": [ - { - "$ref": "#/definitions/consts.SecurityScanningStatus" - } - ] - }, - "workspace": { - "description": "项目目录", - "type": "string" - } - } - }, - "domain.SecurityScanningResult": { - "type": "object", - "properties": { - "created_at": { - "description": "扫描开始时间", - "type": "integer" - }, - "error": { - "description": "错误信息", - "type": "string" - }, - "id": { - "description": "扫描任务id", - "type": "string" - }, - "name": { - "description": "扫描任务", - "type": "string" - }, - "path": { - "description": "项目路径", - "type": "string" - }, - "project_name": { - "description": "项目名称", - "type": "string" - }, - "risk": { - "description": "风险结果", - "allOf": [ - { - "$ref": "#/definitions/domain.SecurityScanningRiskResult" - } - ] - }, - "status": { - "description": "扫描状态", - "allOf": [ - { - "$ref": "#/definitions/consts.SecurityScanningStatus" - } - ] - }, - "user": { - "description": "用户", - "allOf": [ - { - "$ref": "#/definitions/domain.User" - } - ] - } - } - }, - "domain.SecurityScanningRiskDetail": { - "type": "object", - "properties": { - "content": { - "description": "代码内容", - "type": "string" - }, - "desc": { - "description": "风险描述", - "type": "string" - }, - "end": { - "description": "风险代码行结束位置", - "allOf": [ - { - "$ref": "#/definitions/types.Position" - } - ] - }, - "filename": { - "description": "风险文件名", - "type": "string" - }, - "fix": { - "description": "修复建议", - "type": "string" - }, - "id": { - "description": "风险id", - "type": "string" - }, - "level": { - "description": "风险等级", - "allOf": [ - { - "$ref": "#/definitions/consts.SecurityScanningRiskLevel" - } - ] - }, - "lines": { - "description": "风险代码行", - "type": "string" - }, - "start": { - "description": "风险代码行开始位置", - "allOf": [ - { - "$ref": "#/definitions/types.Position" - } - ] - } - } - }, - "domain.SecurityScanningRiskResult": { - "type": "object", - "properties": { - "critical_count": { - "description": "高危数", - "type": "integer" - }, - "id": { - "type": "string" - }, - "severe_count": { - "description": "严重数", - "type": "integer" - }, - "suggest_count": { - "description": "建议数", - "type": "integer" - } - } - }, - "domain.Setting": { - "type": "object", - "properties": { - "base_url": { - "description": "base url 配置,为了支持前置代理", - "type": "string" - }, - "created_at": { - "description": "创建时间", - "type": "integer" - }, - "custom_oauth": { - "description": "自定义OAuth接入", - "allOf": [ - { - "$ref": "#/definitions/domain.CustomOAuth" - } - ] - }, - "dingtalk_oauth": { - "description": "钉钉OAuth接入", - "allOf": [ - { - "$ref": "#/definitions/domain.DingtalkOAuth" - } - ] - }, - "disable_password_login": { - "description": "是否禁用密码登录", - "type": "boolean" - }, - "enable_auto_login": { - "description": "是否开启自动登录", - "type": "boolean" - }, - "enable_sso": { - "description": "是否开启SSO", - "type": "boolean" - }, - "force_two_factor_auth": { - "description": "是否强制两步验证", - "type": "boolean" - }, - "updated_at": { - "description": "更新时间", - "type": "integer" - } - } - }, - "domain.Statistics": { - "type": "object", - "properties": { - "disabled_users": { - "description": "禁用用户数", - "type": "integer" - }, - "total_users": { - "description": "总用户数", - "type": "integer" - } - } - }, - "domain.SyncWorkspaceFileReq": { - "type": "object", - "required": [ - "files", - "user_id", - "workspace_id" - ], - "properties": { - "files": { - "description": "要同步的文件列表", - "type": "array", - "items": { - "$ref": "#/definitions/domain.CreateWorkspaceFileReq" - } - }, - "user_id": { - "description": "用户ID", - "type": "string" - }, - "workspace_id": { - "description": "工作区ID", - "type": "string" - } - } - }, - "domain.SyncWorkspaceFileResp": { - "type": "object", - "properties": { - "created": { - "description": "新创建的文件", - "type": "array", - "items": { - "$ref": "#/definitions/domain.WorkspaceFile" - } - }, - "deleted": { - "description": "删除的文件ID", - "type": "array", - "items": { - "type": "string" - } - }, - "total": { - "description": "处理的文件总数", - "type": "integer" - }, - "updated": { - "description": "更新的文件", - "type": "array", - "items": { - "$ref": "#/definitions/domain.WorkspaceFile" - } - } - } - }, - "domain.TimeStat": { - "type": "object", - "properties": { - "accepted_per": { - "description": "接受率统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "number" - } - } - } - }, - "active_users": { - "description": "活跃用户数统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "integer" - } - } - } - }, - "chats": { - "description": "对话任务数统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "integer" - } - } - } - }, - "code_completions": { - "description": "补全任务数统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "integer" - } - } - } - }, - "lines_of_code": { - "description": "代码行数统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "integer" - } - } - } - }, - "real_time_tokens": { - "description": "实时token数统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "integer" - } - } - } - }, - "total_accepted_per": { - "description": "近90天平均接受率", - "type": "number" - }, - "total_chats": { - "description": "近90天对话任务数", - "type": "integer" - }, - "total_completions": { - "description": "近90天补全任务数", - "type": "integer" - }, - "total_lines_of_code": { - "description": "近90天代码行数", - "type": "integer" - }, - "total_users": { - "description": "近90天活跃用户数", - "type": "integer" - } - } - }, - "domain.UpdateModelReq": { - "type": "object", - "required": [ - "provider" - ], - "properties": { - "api_base": { - "description": "接口地址 如:https://api.qwen.com", - "type": "string" - }, - "api_header": { - "type": "string" - }, - "api_key": { - "description": "接口密钥 如:sk-xxxx", - "type": "string" - }, - "api_version": { - "type": "string" - }, - "id": { - "description": "模型ID", - "type": "string" - }, - "model_name": { - "description": "模型名称", - "type": "string" - }, - "param": { - "description": "高级参数", - "allOf": [ - { - "$ref": "#/definitions/domain.ModelParam" - } - ] - }, - "provider": { - "description": "提供商", - "enum": [ - "SiliconFlow", - "OpenAI", - "Ollama", - "DeepSeek", - "Moonshot", - "AzureOpenAI", - "BaiZhiCloud", - "Hunyuan", - "BaiLian", - "Volcengine", - "Other" - ], - "allOf": [ - { - "$ref": "#/definitions/consts.ModelProvider" - } - ] - }, - "show_name": { - "description": "模型显示名称", - "type": "string" - }, - "status": { - "description": "状态 active:启用 inactive:禁用", - "allOf": [ - { - "$ref": "#/definitions/consts.ModelStatus" - } - ] - } - } - }, - "domain.UpdateSettingReq": { - "type": "object", - "properties": { - "base_url": { - "description": "base url 配置,为了支持前置代理", - "type": "string" - }, - "custom_oauth": { - "description": "自定义OAuth配置", - "allOf": [ - { - "$ref": "#/definitions/domain.CustomOAuthReq" - } - ] - }, - "dingtalk_oauth": { - "description": "钉钉OAuth配置", - "allOf": [ - { - "$ref": "#/definitions/domain.DingtalkOAuthReq" - } - ] - }, - "disable_password_login": { - "description": "是否禁用密码登录", - "type": "boolean" - }, - "enable_auto_login": { - "description": "是否开启自动登录", - "type": "boolean" - }, - "enable_sso": { - "description": "是否开启SSO", - "type": "boolean" - }, - "force_two_factor_auth": { - "description": "是否强制两步验证", - "type": "boolean" - } - } - }, - "domain.UpdateUserGroupReq": { - "type": "object", - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "description": "分组id", - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "domain.UpdateUserReq": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "id": { - "description": "用户ID", - "type": "string" - }, - "password": { - "description": "重置密码", - "type": "string" - }, - "status": { - "description": "用户状态 active: 正常 locked: 锁定 inactive: 禁用", - "allOf": [ - { - "$ref": "#/definitions/consts.UserStatus" - } - ] - } - } - }, - "domain.UpdateWorkspaceFileReq": { - "type": "object", - "required": [ - "id" - ], - "properties": { - "content": { - "description": "文件内容", - "type": "string" - }, - "hash": { - "description": "文件哈希", - "type": "string" - }, - "id": { - "description": "文件ID", - "type": "string" - }, - "language": { - "description": "编程语言", - "type": "string" - }, - "size": { - "description": "文件大小", - "type": "integer" - } - } - }, - "domain.User": { - "type": "object", - "properties": { - "avatar_url": { - "description": "头像URL", - "type": "string" - }, - "created_at": { - "description": "创建时间", - "type": "integer" - }, - "email": { - "description": "邮箱", - "type": "string" - }, - "id": { - "description": "用户ID", - "type": "string" - }, - "is_deleted": { - "description": "是否删除", - "type": "boolean" - }, - "last_active_at": { - "description": "最后活跃时间", - "type": "integer" - }, - "status": { - "description": "用户状态 active: 正常 locked: 锁定 inactive: 禁用", - "allOf": [ - { - "$ref": "#/definitions/consts.UserStatus" - } - ] - }, - "two_step_auth": { - "description": "是否开启两步验证", - "type": "boolean" - }, - "username": { - "description": "用户名", - "type": "string" - } - } - }, - "domain.UserCodeRank": { - "type": "object", - "properties": { - "lines": { - "description": "代码行数", - "type": "integer" - }, - "user": { - "description": "用户信息", - "allOf": [ - { - "$ref": "#/definitions/domain.User" - } - ] - }, - "username": { - "description": "用户名", - "type": "string" - } - } - }, - "domain.UserEvent": { - "type": "object", - "properties": { - "created_at": { - "description": "事件时间", - "type": "integer" - }, - "name": { - "description": "事件名称", - "type": "string" - } - } - }, - "domain.UserGroup": { - "type": "object", - "properties": { - "admins": { - "description": "关联的管理员", - "type": "array", - "items": { - "$ref": "#/definitions/domain.AdminUser" - } - }, - "id": { - "type": "string" - }, - "name": { - "description": "组名", - "type": "string" - }, - "users": { - "description": "关联的用户", - "type": "array", - "items": { - "$ref": "#/definitions/domain.User" - } - } - } - }, - "domain.UserHeatmap": { - "type": "object", - "properties": { - "count": { - "type": "integer" - }, - "date": { - "type": "integer" - } - } - }, - "domain.UserHeatmapResp": { - "type": "object", - "properties": { - "max_count": { - "type": "integer" - }, - "points": { - "type": "array", - "items": { - "$ref": "#/definitions/domain.UserHeatmap" - } - } - } - }, - "domain.UserLoginHistory": { - "type": "object", - "properties": { - "client_id": { - "description": "插件ID vscode", - "type": "string" - }, - "client_version": { - "description": "客户端版本", - "type": "string" - }, - "created_at": { - "description": "登录时间", - "type": "integer" - }, - "device": { - "description": "设备信息", - "type": "string" - }, - "hostname": { - "description": "主机名", - "type": "string" - }, - "ip_info": { - "description": "IP信息", - "allOf": [ - { - "$ref": "#/definitions/domain.IPInfo" - } - ] - }, - "user": { - "description": "用户信息", - "allOf": [ - { - "$ref": "#/definitions/domain.User" - } - ] - } - } - }, - "domain.UserStat": { - "type": "object", - "properties": { - "accepted_per": { - "description": "接受率统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "number" - } - } - } - }, - "chats": { - "description": "对话任务数统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "integer" - } - } - } - }, - "code_completions": { - "description": "补全任务数统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "integer" - } - } - } - }, - "lines_of_code": { - "description": "代码行数统计", - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "description": "时间戳", - "type": "integer" - }, - "value": { - "description": "值", - "type": "integer" - } - } - } - }, - "program_language": { - "description": "编程语言占比", - "type": "array", - "items": { - "$ref": "#/definitions/domain.CategoryPoint" - } - }, - "total_accepted_per": { - "description": "总接受率", - "type": "number" - }, - "total_chats": { - "description": "总对话任务数", - "type": "integer" - }, - "total_completions": { - "description": "总补全任务数", - "type": "integer" - }, - "total_lines_of_code": { - "description": "总代码行数", - "type": "integer" - }, - "work_mode": { - "description": "工作模式占比", - "type": "array", - "items": { - "$ref": "#/definitions/domain.CategoryPoint" - } - } - } - }, - "domain.WorkspaceFile": { - "type": "object", - "properties": { - "content": { - "description": "文件内容", - "type": "string" - }, - "created_at": { - "description": "创建时间", - "type": "integer" - }, - "hash": { - "description": "文件哈希", - "type": "string" - }, - "id": { - "description": "文件ID", - "type": "string" - }, - "language": { - "description": "编程语言", - "type": "string" - }, - "path": { - "description": "文件路径", - "type": "string" - }, - "size": { - "description": "文件大小", - "type": "integer" - }, - "updated_at": { - "description": "更新时间", - "type": "integer" - }, - "user_id": { - "description": "用户ID", - "type": "string" - }, - "workspace_id": { - "description": "工作区ID", - "type": "string" - } - } - }, - "types.Position": { - "type": "object", - "properties": { - "col": { - "type": "integer" - }, - "line": { - "type": "integer" - }, - "offset": { - "type": "integer" - } - } - }, - "v1.GetContextReq": { - "type": "object", - "properties": { - "limit": { - "description": "返回结果数量限制,默认10", - "type": "integer" - }, - "queries": { - "description": "批量查询参数", - "type": "array", - "items": { - "$ref": "#/definitions/v1.Query" - } - }, - "query": { - "description": "单个查询参数", - "allOf": [ - { - "$ref": "#/definitions/v1.Query" - } - ] - }, - "workspacePath": { - "description": "工作区路径(必填)", - "type": "string" - } - } - }, - "v1.GetSemanticContextReq": { - "type": "object", - "properties": { - "limit": { - "description": "返回结果数量限制,默认10", - "type": "integer" - }, - "query": { - "description": "搜索查询文本(必填)", - "type": "string" - }, - "workspacePath": { - "description": "工作区路径(必填)", - "type": "string" - } - } - }, - "v1.Query": { - "type": "object", - "properties": { - "language": { - "description": "编程语言(可选)", - "type": "string" - }, - "name": { - "description": "代码片段名称(可选)", - "type": "string" - }, - "snippetType": { - "description": "代码片段类型(可选)", - "type": "string" - } - } - }, - "web.Resp": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "data": {}, - "message": { - "type": "string" - } - } - } - } -} \ No newline at end of file diff --git a/backend/domain/model.go b/backend/domain/model.go index d1e2f84a..bd79c86f 100644 --- a/backend/domain/model.go +++ b/backend/domain/model.go @@ -46,7 +46,7 @@ type CheckModelReq struct { } type GetProviderModelListReq struct { - Provider consts.ModelProvider `json:"provider" query:"provider" validate:"required,oneof=SiliconFlow OpenAI Ollama DeepSeek Moonshot AzureOpenAI BaiZhiCloud Hunyuan BaiLian Volcengine Other"` + Provider consts.ModelProvider `json:"provider" query:"provider" validate:"required,oneof=SiliconFlow OpenAI Ollama DeepSeek Moonshot AzureOpenAI BaiZhiCloud Hunyuan BaiLian Volcengine ZhiPu Gemini Other"` BaseURL string `json:"base_url" query:"base_url" validate:"required"` APIKey string `json:"api_key" query:"api_key"` APIHeader string `json:"api_header" query:"api_header"` @@ -76,11 +76,11 @@ type GetTokenUsageReq struct { type CreateModelReq struct { AdminID uuid.UUID `json:"-"` - ShowName string `json:"show_name"` // 模型显示名称 - ModelName string `json:"model_name" validate:"required"` // 模型名称 如: deepseek-v3 - Provider consts.ModelProvider `json:"provider" validate:"required,oneof=SiliconFlow OpenAI Ollama DeepSeek Moonshot AzureOpenAI BaiZhiCloud Hunyuan BaiLian Volcengine Other"` // 提供商 - APIBase string `json:"api_base" validate:"required"` // 接口地址 如:https://api.qwen.com - APIKey string `json:"api_key"` // 接口密钥 如:sk-xxxx + ShowName string `json:"show_name"` // 模型显示名称 + ModelName string `json:"model_name" validate:"required"` // 模型名称 如: deepseek-v3 + Provider consts.ModelProvider `json:"provider" validate:"required,oneof=SiliconFlow OpenAI Ollama DeepSeek Moonshot AzureOpenAI BaiZhiCloud Hunyuan BaiLian Volcengine ZhiPu Gemini Other"` // 提供商 + APIBase string `json:"api_base" validate:"required"` // 接口地址 如:https://api.qwen.com + APIKey string `json:"api_key"` // 接口密钥 如:sk-xxxx APIVersion string `json:"api_version"` APIHeader string `json:"api_header"` ModelType consts.ModelType `json:"model_type"` // 模型类型 llm:对话模型 coder:代码模型 @@ -108,12 +108,12 @@ func DefaultModelParam() *ModelParam { } type UpdateModelReq struct { - ID string `json:"id"` // 模型ID - ModelName *string `json:"model_name"` // 模型名称 - ShowName *string `json:"show_name"` // 模型显示名称 - Provider *consts.ModelProvider `json:"provider" validate:"required,oneof=SiliconFlow OpenAI Ollama DeepSeek Moonshot AzureOpenAI BaiZhiCloud Hunyuan BaiLian Volcengine Other"` // 提供商 - APIBase *string `json:"api_base"` // 接口地址 如:https://api.qwen.com - APIKey *string `json:"api_key"` // 接口密钥 如:sk-xxxx + ID string `json:"id"` // 模型ID + ModelName *string `json:"model_name"` // 模型名称 + ShowName *string `json:"show_name"` // 模型显示名称 + Provider *consts.ModelProvider `json:"provider" validate:"required,oneof=SiliconFlow OpenAI Ollama DeepSeek Moonshot AzureOpenAI BaiZhiCloud Hunyuan BaiLian Volcengine ZhiPu Gemini Other"` // 提供商 + APIBase *string `json:"api_base"` // 接口地址 如:https://api.qwen.com + APIKey *string `json:"api_key"` // 接口密钥 如:sk-xxxx APIVersion *string `json:"api_version"` APIHeader *string `json:"api_header"` Status *consts.ModelStatus `json:"status"` // 状态 active:启用 inactive:禁用 @@ -133,9 +133,9 @@ type ModelTokenUsage struct { } type ModelBasic struct { - Name string `json:"name"` // 模型名称 - Provider consts.ModelProvider `json:"provider" validate:"required,oneof=SiliconFlow OpenAI Ollama DeepSeek Moonshot AzureOpenAI BaiZhiCloud Hunyuan BaiLian Volcengine Other"` // 提供商 - APIBase string `json:"api_base"` // 接口地址 如:https://api.qwen.com + Name string `json:"name"` // 模型名称 + Provider consts.ModelProvider `json:"provider" validate:"required,oneof=SiliconFlow OpenAI Ollama DeepSeek Moonshot AzureOpenAI BaiZhiCloud Hunyuan BaiLian Volcengine ZhiPu Gemini Other"` // 提供商 + APIBase string `json:"api_base"` // 接口地址 如:https://api.qwen.com } type ModelUsage struct { @@ -200,4 +200,4 @@ func (m *Model) From(e *db.Model) *Model { type CheckModelResp struct { Error string `json:"error"` Content string `json:"content"` -} \ No newline at end of file +} diff --git a/backend/ent/rule/rule.go b/backend/ent/rule/rule.go index 80ef4bd8..d620c98a 100644 --- a/backend/ent/rule/rule.go +++ b/backend/ent/rule/rule.go @@ -113,9 +113,6 @@ func PermissionInterceptor(logger *slog.Logger) ent.Interceptor { return next.Query(ctx, q) } - logger = logger.With("type", fmt.Sprintf("%T", q)) - logger.DebugContext(ctx, "[PermissionInterceptor] query") - switch qq := q.(type) { case *db.UserGroupQuery: return WithPermission(ctx, next, q, func(ctx context.Context, p *domain.Permissions) error { diff --git a/backend/internal/model/usecase/model.go b/backend/internal/model/usecase/model.go index f46490a6..d6a852b4 100644 --- a/backend/internal/model/usecase/model.go +++ b/backend/internal/model/usecase/model.go @@ -15,7 +15,6 @@ import ( "github.com/chaitin/MonkeyCode/backend/domain" "github.com/chaitin/MonkeyCode/backend/ent/types" "github.com/chaitin/MonkeyCode/backend/pkg/cvt" - "github.com/chaitin/MonkeyCode/backend/pkg/request" ) type ModelUsecase struct { @@ -144,23 +143,6 @@ func (m *ModelUsecase) InitModel(ctx context.Context) error { return m.repo.InitModel(ctx, m.cfg.InitModel.Name, m.cfg.InitModel.Key, m.cfg.InitModel.URL) } -func (m *ModelUsecase) getQuery(req *domain.GetProviderModelListReq) request.Query { - q := make(request.Query, 0) - if req.Provider != consts.ModelProviderBaiZhiCloud && req.Provider != consts.ModelProviderSiliconFlow { - return q - } - q["type"] = "text" - q["sub_type"] = string(req.Type) - if req.Type == consts.ModelTypeLLM { - q["sub_type"] = "chat" - } - // 硅基流动不支持coder sub_type - if req.Provider == consts.ModelProviderSiliconFlow && req.Type == consts.ModelTypeCoder { - q["sub_type"] = "chat" - } - return q -} - func (m *ModelUsecase) Delete(ctx context.Context, id string) error { return m.repo.Delete(ctx, id) } diff --git a/backend/internal/proxy/proxy.go b/backend/internal/proxy/proxy.go index 2f895fe3..8b3d923c 100644 --- a/backend/internal/proxy/proxy.go +++ b/backend/internal/proxy/proxy.go @@ -1,7 +1,10 @@ package proxy import ( + "bytes" "context" + "encoding/json" + "io" "log/slog" "net" "net/http" @@ -28,6 +31,7 @@ type ProxyCtx struct { ReqTee *tee.ReqTee RequestID string UserID string + Metadata map[string]string } type LLMProxy struct { @@ -102,6 +106,36 @@ func (l *LLMProxy) rewrite(r *httputil.ProxyRequest) { return } + metadata := make(map[string]string) + if m.Provider == consts.ModelProviderZhiPu { + body, err := io.ReadAll(r.In.Body) + if err != nil { + l.logger.ErrorContext(r.In.Context(), "read request body failed", slog.String("path", r.In.URL.Path), slog.Any("err", err)) + return + } + req := make(map[string]any) + err = json.Unmarshal(body, &req) + if err != nil { + l.logger.ErrorContext(r.In.Context(), "unmarshal request body failed", slog.String("path", r.In.URL.Path), slog.Any("err", err)) + return + } + if md, ok := req["metadata"].(map[string]any); ok { + for k, v := range md { + metadata[k] = v.(string) + } + } + delete(req, "metadata") + body, err = json.Marshal(req) + if err != nil { + l.logger.ErrorContext(r.In.Context(), "marshal request body failed", slog.String("path", r.In.URL.Path), slog.Any("err", err)) + return + } + r.In.Body = io.NopCloser(bytes.NewBuffer(body)) + r.In.ContentLength = int64(len(body)) + r.Out.Body = io.NopCloser(bytes.NewBuffer(body)) + r.Out.ContentLength = int64(len(body)) + } + path := r.In.URL.Path path = strings.ReplaceAll(path, "/v1", "") path = ul.Path + path @@ -116,28 +150,29 @@ func (l *LLMProxy) rewrite(r *httputil.ProxyRequest) { RequestID: r.In.Context().Value(logger.RequestIDKey{}).(string), UserID: r.In.Context().Value(logger.UserIDKey{}).(string), Header: r.In.Header, + Metadata: metadata, }) r.Out = r.Out.WithContext(ctx) } - u, err := url.Parse(m.APIBase) - if err != nil { - l.logger.ErrorContext(r.In.Context(), "parse model api base failed", slog.String("path", r.In.URL.Path), slog.Any("err", err)) - return - } - - r.Out.URL.Scheme = u.Scheme - r.Out.URL.Host = u.Host + r.Out.URL.Scheme = ul.Scheme + r.Out.URL.Host = ul.Host r.Out.URL.Path = path r.Out.Header.Set("Authorization", "Bearer "+m.APIKey) r.SetXForwarded() - r.Out.Host = u.Host - l.logger.With("in", r.In.URL.Path, "out", r.Out.URL.Path).DebugContext(r.In.Context(), "rewrite request") + r.Out.Host = ul.Host + l.logger.With( + "in", r.In.URL.Path, + "out", r.Out.URL.Path, + "metadata", metadata, + ).DebugContext(r.In.Context(), "rewrite request") } func (l *LLMProxy) modifyResponse(resp *http.Response) error { if resp.StatusCode != http.StatusOK { - resp.Body = NewRespLog(resp.Request.Context(), l.logger, resp.Body) + body, _ := io.ReadAll(resp.Body) + l.logger.ErrorContext(resp.Request.Context(), "modify response failed", slog.String("body", string(body))) + resp.Body = io.NopCloser(bytes.NewBuffer(body)) return nil } diff --git a/backend/internal/proxy/recorder.go b/backend/internal/proxy/recorder.go index 0bc7ab34..8fe8cc3e 100644 --- a/backend/internal/proxy/recorder.go +++ b/backend/internal/proxy/recorder.go @@ -83,6 +83,13 @@ func (r *Recorder) handleShadow() { mode = req.Metadata["mode"] tool = req.Metadata["tool"] code = req.Metadata["code"] + if md := r.ctx.Metadata; len(md) > 0 { + prompt = md["prompt"] + taskID = md["task_id"] + mode = md["mode"] + tool = md["tool"] + code = md["code"] + } case consts.ModelTypeCoder: var req domain.CompletionRequest