feat: 编辑器实时探测并显示已关联虚拟环境

fix: 按系统 ANSI 代码页解码子进程输出,修复中文日志乱码
This commit is contained in:
2026-10-24 22:30:10 +08:00
parent 23565b40a4
commit dd7612bc74
20 changed files with 1508 additions and 48 deletions
+136
View File
@@ -89,6 +89,46 @@
}
}
},
"/api/v1/python/venv": {
"post": {
"tags": [
"system"
],
"operationId": "probe_python_venv",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/VenvProbeRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Detected Python virtual environment",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/VenvProbeResponse"
}
}
}
},
"400": {
"description": "Invalid venv probe request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/runs/{run_id}": {
"get": {
"tags": [
@@ -892,6 +932,14 @@
"POST"
]
},
"InterpreterKind": {
"type": "string",
"enum": [
"python",
"node",
"other"
]
},
"LogChunkResponse": {
"type": "object",
"required": [
@@ -1323,6 +1371,94 @@
}
},
"additionalProperties": false
},
"VenvProbeRequest": {
"type": "object",
"description": "编辑器在用户填写工作目录时发起的探测请求。",
"required": [
"working_dir",
"interpreter"
],
"properties": {
"interpreter": {
"type": "string",
"description": "解释器或可执行程序,对应 `action.interpreter`"
},
"venv": {
"type": [
"string",
"null"
],
"description": "手动填写的虚拟环境目录,对应 `action.venv`"
},
"working_dir": {
"type": "string",
"description": "任务工作目录,对应 `action.working_dir`"
}
},
"additionalProperties": false
},
"VenvProbeResponse": {
"type": "object",
"required": [
"status",
"interpreter_kind",
"message"
],
"properties": {
"display_path": {
"type": [
"string",
"null"
],
"description": "供界面展示的解释器路径;位于工作目录内时使用相对路径"
},
"interpreter_kind": {
"$ref": "#/components/schemas/InterpreterKind"
},
"message": {
"type": "string"
},
"source": {
"oneOf": [
{
"$ref": "#/components/schemas/VenvSource"
},
{
"type": "null"
}
]
},
"status": {
"$ref": "#/components/schemas/VenvProbeStatus"
},
"venv_path": {
"type": [
"string",
"null"
],
"description": "虚拟环境根目录的绝对路径"
}
}
},
"VenvProbeStatus": {
"type": "string",
"enum": [
"linked",
"invalid",
"missing",
"not_applicable",
"incomplete"
]
},
"VenvSource": {
"type": "string",
"description": "虚拟环境的来源,用于在界面上说明\"为什么\"关联到了这个环境。",
"enum": [
"configured",
"interpreter",
"working_directory"
]
}
}
}