Files
task_pilot/contracts/openapi.json
T
CNWei 1914d38451 feat: 本地 uv 与托管 Python 环境管理
- 新增 uv 管理:只认程序目录副本或指定路径,支持从科大镜像下载并按 sha256 校验

- uv 环境变量(UV_*)可配置,默认相对程序目录(python / uv-cache),同时注入 uv 调用与任务进程

- 新增托管虚拟环境与 Python 版本管理:用 uv 下载解释器、预创建环境、查看已装包

- 新建任务保存时自动创建 .venv,运行期只校验、不再自动装依赖;镜像只在装包时使用

- 前端改为顶部品牌栏 + 三栏工作台,uv / 镜像源 / 虚拟环境各自独立弹窗

- 发布包构建后去掉工作区继承的低完整性标签

- 修复调度集成测试并发时误取 skipped 运行的问题
2026-11-07 16:57:27 +08:00

2653 lines
64 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"openapi": "3.1.0",
"info": {
"title": "TaskPilot API",
"description": "Local task scheduling and process management API.",
"license": {
"name": ""
},
"version": "0.1.0"
},
"paths": {
"/api/v1/cron/preview": {
"post": {
"tags": [
"system"
],
"operationId": "preview_cron",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CronPreviewRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Upcoming cron occurrences",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CronPreviewResponse"
}
}
}
},
"400": {
"description": "Invalid cron preview request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/events": {
"get": {
"tags": [
"runs"
],
"operationId": "execution_events",
"responses": {
"200": {
"description": "Run status and log events",
"content": {
"text/event-stream": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/api/v1/health": {
"get": {
"tags": [
"system"
],
"operationId": "health",
"responses": {
"200": {
"description": "TaskPilot API is healthy",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HealthResponse"
}
}
}
}
}
}
},
"/api/v1/python/envs": {
"get": {
"tags": [
"python-envs"
],
"operationId": "list_envs",
"responses": {
"200": {
"description": "Managed virtual environments",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ManagedEnvSummary"
}
}
}
}
}
}
},
"post": {
"tags": [
"python-envs"
],
"operationId": "create_env",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateManagedEnvRequest"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "Virtual environment created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ManagedEnvSummary"
}
}
}
},
"400": {
"description": "Validation or uv failure",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/python/envs/{name}": {
"delete": {
"tags": [
"python-envs"
],
"operationId": "delete_env",
"parameters": [
{
"name": "name",
"in": "path",
"description": "Environment name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "Environment deleted"
},
"404": {
"description": "Environment not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/python/envs/{name}/packages": {
"get": {
"tags": [
"python-envs"
],
"operationId": "list_env_packages",
"parameters": [
{
"name": "name",
"in": "path",
"description": "Environment name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Installed packages",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ManagedEnvPackage"
}
}
}
}
},
"404": {
"description": "Environment not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/python/mirrors": {
"get": {
"tags": [
"python-mirrors"
],
"operationId": "list_python_mirrors",
"responses": {
"200": {
"description": "Python package mirrors",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PythonMirrorResponse"
}
}
}
}
}
}
},
"post": {
"tags": [
"python-mirrors"
],
"operationId": "create_python_mirror",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreatePythonMirrorRequest"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "Mirror created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PythonMirrorResponse"
}
}
}
},
"400": {
"description": "Validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"409": {
"description": "Mirror URL already exists",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/python/mirrors/{id}": {
"get": {
"tags": [
"python-mirrors"
],
"operationId": "get_python_mirror",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Mirror identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Mirror detail",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PythonMirrorResponse"
}
}
}
},
"404": {
"description": "Mirror not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
},
"put": {
"tags": [
"python-mirrors"
],
"operationId": "update_python_mirror",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Mirror identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdatePythonMirrorRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Mirror updated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PythonMirrorResponse"
}
}
}
},
"400": {
"description": "Validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"404": {
"description": "Mirror not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"409": {
"description": "Mirror URL already exists",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
},
"delete": {
"tags": [
"python-mirrors"
],
"operationId": "delete_python_mirror",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Mirror identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "Mirror deleted"
},
"404": {
"description": "Mirror not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/python/mirrors/{id}/default": {
"post": {
"tags": [
"python-mirrors"
],
"operationId": "set_default_python_mirror",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Mirror identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Default mirror updated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PythonMirrorResponse"
}
}
}
},
"404": {
"description": "Mirror not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/python/pythons": {
"get": {
"tags": [
"python-envs"
],
"operationId": "list_pythons",
"responses": {
"200": {
"description": "Pythons downloaded by uv into the platform directory",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ManagedPython"
}
}
}
}
},
"400": {
"description": "uv unavailable",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
},
"post": {
"tags": [
"python-envs"
],
"operationId": "install_python",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InstallPythonRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Python downloaded; returns the installed list",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ManagedPython"
}
}
}
}
},
"400": {
"description": "Validation or uv failure",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/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/python/venv/create": {
"post": {
"tags": [
"system"
],
"operationId": "create_python_venv",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreatePythonVenvRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Created or reused project virtual environment",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/VenvProbeResponse"
}
}
}
},
"400": {
"description": "Project cannot create a virtual environment",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/runs/{run_id}": {
"get": {
"tags": [
"runs"
],
"operationId": "get_run",
"parameters": [
{
"name": "run_id",
"in": "path",
"description": "Run identifier",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"200": {
"description": "Task run detail",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskRunResponse"
}
}
}
},
"404": {
"description": "Run not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/runs/{run_id}/cancel": {
"post": {
"tags": [
"runs"
],
"operationId": "cancel_run",
"parameters": [
{
"name": "run_id",
"in": "path",
"description": "Run identifier",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"202": {
"description": "Cancellation requested",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskRunResponse"
}
}
}
},
"404": {
"description": "Run not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"409": {
"description": "Run is not cancellable",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/runs/{run_id}/logs": {
"get": {
"tags": [
"runs"
],
"operationId": "get_run_logs",
"parameters": [
{
"name": "run_id",
"in": "path",
"description": "Run identifier",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "offset",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"format": "int64",
"minimum": 0
}
}
],
"responses": {
"200": {
"description": "Incremental task run log",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LogChunkResponse"
}
}
}
},
"404": {
"description": "Run not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/runs/{run_id}/logs/download": {
"get": {
"tags": [
"runs"
],
"operationId": "download_run_logs",
"parameters": [
{
"name": "run_id",
"in": "path",
"description": "Run identifier",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"responses": {
"200": {
"description": "Plain text task log",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
},
"404": {
"description": "Run or log not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/schedule": {
"get": {
"tags": [
"tasks"
],
"operationId": "list_schedule",
"responses": {
"200": {
"description": "Next trigger time per enabled task",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ScheduledTaskResponse"
}
}
}
}
}
}
}
},
"/api/v1/session": {
"get": {
"tags": [
"system"
],
"operationId": "session",
"responses": {
"200": {
"description": "Local API session token",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SessionResponse"
}
}
}
}
}
}
},
"/api/v1/stats": {
"get": {
"tags": [
"tasks"
],
"operationId": "task_stats",
"responses": {
"200": {
"description": "Dashboard counters",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskStatsResponse"
}
}
}
}
}
}
},
"/api/v1/system/directories": {
"get": {
"tags": [
"system"
],
"operationId": "list_directories",
"parameters": [
{
"name": "path",
"in": "query",
"description": "绝对目录路径;留空表示列出盘符",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Subdirectories of the requested path, or the drive list",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DirectoryListingResponse"
}
}
}
},
"400": {
"description": "The path is not an existing absolute directory",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/tasks": {
"get": {
"tags": [
"tasks"
],
"operationId": "list_tasks",
"parameters": [
{
"name": "q",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "enabled",
"in": "query",
"required": false,
"schema": {
"type": "boolean"
}
},
{
"name": "action_type",
"in": "query",
"required": false,
"schema": {
"$ref": "#/components/schemas/TaskActionType"
}
},
{
"name": "page",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"format": "int32",
"minimum": 0
}
},
{
"name": "page_size",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"format": "int32",
"minimum": 0
}
}
],
"responses": {
"200": {
"description": "Paginated task list",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskListResponse"
}
}
}
}
}
},
"post": {
"tags": [
"tasks"
],
"operationId": "create_task",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateTaskRequest"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "Task created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskResponse"
}
}
}
},
"400": {
"description": "Validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"409": {
"description": "Task ID already exists",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/tasks/{id}": {
"get": {
"tags": [
"tasks"
],
"operationId": "get_task",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Stable task identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Task detail",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskResponse"
}
}
}
},
"404": {
"description": "Task not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
},
"put": {
"tags": [
"tasks"
],
"operationId": "update_task",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Stable task identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateTaskRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Task updated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskResponse"
}
}
}
},
"400": {
"description": "Validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"404": {
"description": "Task not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
},
"delete": {
"tags": [
"tasks"
],
"operationId": "delete_task",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Stable task identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "Task deleted"
},
"404": {
"description": "Task not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/tasks/{id}/disable": {
"post": {
"tags": [
"tasks"
],
"operationId": "disable_task",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Stable task identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Task disabled",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskResponse"
}
}
}
},
"404": {
"description": "Task not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/tasks/{id}/enable": {
"post": {
"tags": [
"tasks"
],
"operationId": "enable_task",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Stable task identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Task enabled",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskResponse"
}
}
}
},
"404": {
"description": "Task not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/tasks/{id}/run": {
"post": {
"tags": [
"runs"
],
"operationId": "run_task",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Stable task identifier",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"202": {
"description": "Manual run accepted",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskRunResponse"
}
}
}
},
"404": {
"description": "Task not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"422": {
"description": "Action executor not implemented",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/tasks/{id}/runs": {
"get": {
"tags": [
"runs"
],
"operationId": "list_task_runs",
"parameters": [
{
"name": "id",
"in": "path",
"description": "Stable task identifier",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "page",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"format": "int32",
"minimum": 0
}
},
{
"name": "page_size",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"format": "int32",
"minimum": 0
}
},
{
"name": "status",
"in": "query",
"required": false,
"schema": {
"$ref": "#/components/schemas/RunStatus"
}
},
{
"name": "trigger",
"in": "query",
"required": false,
"schema": {
"$ref": "#/components/schemas/RunTrigger"
}
}
],
"responses": {
"200": {
"description": "Task run history",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TaskRunListResponse"
}
}
}
}
}
}
},
"/api/v1/uv": {
"get": {
"tags": [
"uv"
],
"operationId": "get_uv_settings",
"responses": {
"200": {
"description": "uv settings and detected executables",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UvSettingsResponse"
}
}
}
}
}
},
"put": {
"tags": [
"uv"
],
"operationId": "update_uv_settings",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateUvSettingsRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "uv settings saved",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UvSettingsResponse"
}
}
}
},
"400": {
"description": "Validation failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/v1/uv/download": {
"post": {
"tags": [
"uv"
],
"operationId": "download_uv",
"responses": {
"200": {
"description": "uv downloaded from the mirror and switched to it",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UvSettingsResponse"
}
}
}
},
"400": {
"description": "Download, verification or install failed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"ConcurrencyPolicy": {
"type": "string",
"enum": [
"skip"
]
},
"CreateManagedEnvRequest": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"description": "目录名,`[A-Za-z0-9._-]`,也是任务里引用它的标识"
},
"packages": {
"type": "array",
"items": {
"type": "string"
},
"description": "预装包,每行一个,例如 `numpy==2.1.0`"
},
"python_version": {
"type": [
"string",
"null"
],
"description": "创建时使用的 Python 版本,例如 `3.11`;留空由 uv 决定"
}
},
"additionalProperties": false
},
"CreatePythonMirrorRequest": {
"type": "object",
"required": [
"name",
"index_url"
],
"properties": {
"enabled": {
"type": "boolean"
},
"index_url": {
"type": "string"
},
"name": {
"type": "string"
},
"trusted_host": {
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
},
"CreatePythonVenvRequest": {
"type": "object",
"description": "用 uv 为项目创建 `.venv`(pyproject 用 uv sync,requirements 用 uv venv + uv pip install)。",
"required": [
"working_dir"
],
"properties": {
"working_dir": {
"type": "string"
}
},
"additionalProperties": false
},
"CreateTaskRequest": {
"type": "object",
"required": [
"id",
"name",
"cron",
"action"
],
"properties": {
"action": {
"$ref": "#/components/schemas/TaskAction"
},
"concurrency_policy": {
"$ref": "#/components/schemas/ConcurrencyPolicy"
},
"cron": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"retry_policy": {
"$ref": "#/components/schemas/RetryPolicy"
},
"timeout_secs": {
"type": "integer",
"format": "int64",
"minimum": 0
},
"timezone": {
"type": "string"
}
},
"additionalProperties": false
},
"CronPreviewRequest": {
"type": "object",
"required": [
"expression",
"timezone",
"count"
],
"properties": {
"count": {
"type": "integer",
"minimum": 0
},
"expression": {
"type": "string"
},
"timezone": {
"type": "string"
}
},
"additionalProperties": false
},
"CronPreviewResponse": {
"type": "object",
"required": [
"timezone",
"runs"
],
"properties": {
"runs": {
"type": "array",
"items": {
"type": "string"
}
},
"timezone": {
"type": "string"
}
}
},
"DirectoryEntry": {
"type": "object",
"required": [
"name",
"path"
],
"properties": {
"name": {
"type": "string",
"description": "用于展示的名称"
},
"path": {
"type": "string",
"description": "绝对路径,选中后回填到表单"
}
}
},
"DirectoryListingResponse": {
"type": "object",
"required": [
"entries",
"truncated"
],
"properties": {
"entries": {
"type": "array",
"items": {
"$ref": "#/components/schemas/DirectoryEntry"
}
},
"parent": {
"type": [
"string",
"null"
],
"description": "上一级目录;盘符根目录和盘符列表为 null"
},
"path": {
"type": [
"string",
"null"
],
"description": "当前目录;为 null 表示正在列出盘符"
},
"truncated": {
"type": "boolean",
"description": "条目超过上限被截断时为 true"
}
}
},
"ErrorResponse": {
"type": "object",
"required": [
"code",
"message",
"details"
],
"properties": {
"code": {
"type": "string"
},
"details": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"type": "string"
}
},
"field": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
}
}
},
"HealthResponse": {
"type": "object",
"required": [
"status",
"service",
"version"
],
"properties": {
"service": {
"type": "string",
"description": "Stable service identifier."
},
"status": {
"type": "string",
"description": "Current service status."
},
"version": {
"type": "string",
"description": "Backend package version."
}
}
},
"HttpMethod": {
"type": "string",
"enum": [
"GET",
"POST"
]
},
"InstallPythonRequest": {
"type": "object",
"required": [
"version"
],
"properties": {
"version": {
"type": "string",
"description": "要下载的版本,例如 `3.12` 或 `3.12.4`"
}
},
"additionalProperties": false
},
"InterpreterKind": {
"type": "string",
"enum": [
"python",
"node",
"other"
]
},
"LogChunkResponse": {
"type": "object",
"required": [
"content",
"next_offset",
"complete"
],
"properties": {
"complete": {
"type": "boolean"
},
"content": {
"type": "string"
},
"next_offset": {
"type": "integer",
"format": "int64",
"minimum": 0
}
}
},
"ManagedEnvPackage": {
"type": "object",
"required": [
"name",
"version"
],
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
}
}
},
"ManagedEnvSummary": {
"type": "object",
"required": [
"name",
"path"
],
"properties": {
"name": {
"type": "string"
},
"path": {
"type": "string",
"description": "虚拟环境根目录的绝对路径"
},
"python_version": {
"type": [
"string",
"null"
],
"description": "取自 `pyvenv.cfg` 的 `version_info`"
}
}
},
"ManagedPython": {
"type": "object",
"required": [
"version",
"path"
],
"properties": {
"path": {
"type": "string",
"description": "uv 下载到平台目录下的解释器路径"
},
"version": {
"type": "string"
}
}
},
"PythonMirrorResponse": {
"type": "object",
"description": "一个 Python 包索引镜像(pip / uv)。",
"required": [
"id",
"name",
"index_url",
"enabled",
"is_default",
"created_at",
"updated_at"
],
"properties": {
"created_at": {
"type": "string",
"format": "date-time"
},
"enabled": {
"type": "boolean"
},
"id": {
"type": "string"
},
"index_url": {
"type": "string",
"description": "pip 的 `--index-url`,运行时注入 `PIP_INDEX_URL`"
},
"is_default": {
"type": "boolean",
"description": "当前默认镜像;同一时间最多一个"
},
"name": {
"type": "string"
},
"trusted_host": {
"type": [
"string",
"null"
],
"description": "pip 的 `--trusted-host`;https 源通常为空"
},
"updated_at": {
"type": "string",
"format": "date-time"
}
}
},
"RetryPolicy": {
"type": "object",
"properties": {
"delay_secs": {
"type": "integer",
"format": "int64",
"minimum": 0
},
"max_attempts": {
"type": "integer",
"format": "int32",
"minimum": 0
}
},
"additionalProperties": false
},
"RunStatus": {
"type": "string",
"enum": [
"queued",
"running",
"succeeded",
"failed",
"timed_out",
"cancelled",
"skipped"
]
},
"RunTrigger": {
"type": "string",
"enum": [
"schedule",
"manual",
"retry"
]
},
"ScheduledTaskResponse": {
"type": "object",
"description": "已注册调度的任务及其下次触发时间。",
"required": [
"task_id"
],
"properties": {
"next_run_at": {
"type": [
"string",
"null"
],
"format": "date-time",
"description": "下次触发时间;调度正在重建时可能为空"
},
"task_id": {
"type": "string"
}
}
},
"ScriptLanguage": {
"type": "string",
"enum": [
"python",
"shell",
"node",
"lua"
]
},
"SessionResponse": {
"type": "object",
"required": [
"token"
],
"properties": {
"token": {
"type": "string",
"description": "Random per-process token required for mutating browser requests."
}
}
},
"TaskAction": {
"oneOf": [
{
"type": "object",
"required": [
"working_dir",
"interpreter",
"script",
"type"
],
"properties": {
"args": {
"type": "array",
"items": {
"type": "string"
}
},
"env": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"type": "string"
}
},
"interpreter": {
"type": "string"
},
"language": {
"oneOf": [
{
"$ref": "#/components/schemas/ScriptLanguage"
},
{
"type": "null"
}
]
},
"script": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"script"
]
},
"venv": {
"type": [
"string",
"null"
]
},
"working_dir": {
"type": "string"
}
}
},
{
"type": "object",
"required": [
"url",
"method",
"type"
],
"properties": {
"body": {
"type": [
"string",
"null"
]
},
"expected_status": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"minimum": 0
}
},
"headers": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"type": "string"
}
},
"method": {
"$ref": "#/components/schemas/HttpMethod"
},
"type": {
"type": "string",
"enum": [
"http"
]
},
"url": {
"type": "string"
}
}
},
{
"type": "object",
"required": [
"executable",
"type"
],
"properties": {
"args": {
"type": "array",
"items": {
"type": "string"
}
},
"env": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"type": "string"
}
},
"executable": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"process"
]
},
"working_dir": {
"type": [
"string",
"null"
]
}
}
}
]
},
"TaskActionType": {
"type": "string",
"enum": [
"script",
"http",
"process"
]
},
"TaskListResponse": {
"type": "object",
"required": [
"items",
"page",
"page_size",
"total"
],
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TaskResponse"
}
},
"page": {
"type": "integer",
"format": "int32",
"minimum": 0
},
"page_size": {
"type": "integer",
"format": "int32",
"minimum": 0
},
"total": {
"type": "integer",
"format": "int64",
"minimum": 0
}
}
},
"TaskResponse": {
"type": "object",
"required": [
"id",
"name",
"cron",
"timezone",
"enabled",
"timeout_secs",
"concurrency_policy",
"retry_policy",
"action",
"created_at",
"updated_at"
],
"properties": {
"action": {
"$ref": "#/components/schemas/TaskAction"
},
"concurrency_policy": {
"$ref": "#/components/schemas/ConcurrencyPolicy"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"cron": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"retry_policy": {
"$ref": "#/components/schemas/RetryPolicy"
},
"timeout_secs": {
"type": "integer",
"format": "int64",
"minimum": 0
},
"timezone": {
"type": "string"
},
"updated_at": {
"type": "string",
"format": "date-time"
}
}
},
"TaskRunListResponse": {
"type": "object",
"required": [
"items",
"page",
"page_size",
"total"
],
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TaskRunResponse"
}
},
"page": {
"type": "integer",
"format": "int32",
"minimum": 0
},
"page_size": {
"type": "integer",
"format": "int32",
"minimum": 0
},
"total": {
"type": "integer",
"format": "int64",
"minimum": 0
}
}
},
"TaskRunResponse": {
"type": "object",
"required": [
"id",
"task_id",
"trigger",
"status",
"created_at"
],
"properties": {
"created_at": {
"type": "string",
"format": "date-time"
},
"duration_ms": {
"type": [
"integer",
"null"
],
"format": "int64",
"minimum": 0
},
"error_message": {
"type": [
"string",
"null"
]
},
"exit_code": {
"type": [
"integer",
"null"
],
"format": "int32"
},
"finished_at": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"id": {
"type": "integer",
"format": "int64"
},
"started_at": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"status": {
"$ref": "#/components/schemas/RunStatus"
},
"task_id": {
"type": "string"
},
"trigger": {
"$ref": "#/components/schemas/RunTrigger"
}
}
},
"TaskStatsResponse": {
"type": "object",
"description": "仪表盘指标:一次请求拿到全部计数,避免为每个指标各发一次列表查询。",
"required": [
"total",
"enabled",
"running",
"script",
"http",
"process"
],
"properties": {
"enabled": {
"type": "integer",
"format": "int64",
"description": "已启用任务数",
"minimum": 0
},
"http": {
"type": "integer",
"format": "int64",
"description": "HTTP 类任务数",
"minimum": 0
},
"process": {
"type": "integer",
"format": "int64",
"description": "进程类任务数",
"minimum": 0
},
"running": {
"type": "integer",
"format": "int64",
"description": "当前正在执行的任务数",
"minimum": 0
},
"script": {
"type": "integer",
"format": "int64",
"description": "脚本类任务数",
"minimum": 0
},
"total": {
"type": "integer",
"format": "int64",
"description": "任务总数",
"minimum": 0
}
}
},
"UpdatePythonMirrorRequest": {
"type": "object",
"required": [
"name",
"index_url",
"enabled"
],
"properties": {
"enabled": {
"type": "boolean"
},
"index_url": {
"type": "string"
},
"name": {
"type": "string"
},
"trusted_host": {
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
},
"UpdateTaskRequest": {
"type": "object",
"required": [
"name",
"cron",
"action"
],
"properties": {
"action": {
"$ref": "#/components/schemas/TaskAction"
},
"concurrency_policy": {
"$ref": "#/components/schemas/ConcurrencyPolicy"
},
"cron": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"name": {
"type": "string"
},
"retry_policy": {
"$ref": "#/components/schemas/RetryPolicy"
},
"timeout_secs": {
"type": "integer",
"format": "int64",
"minimum": 0
},
"timezone": {
"type": "string"
}
},
"additionalProperties": false
},
"UpdateUvSettingsRequest": {
"type": "object",
"required": [
"source"
],
"properties": {
"custom_path": {
"type": [
"string",
"null"
]
},
"extra_env": {
"type": "object",
"description": "额外注入给 uv 的环境变量;只允许 `UV_` 前缀",
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"type": "string"
}
},
"source": {
"$ref": "#/components/schemas/UvSource"
}
},
"additionalProperties": false
},
"UvCandidate": {
"type": "object",
"required": [
"source",
"path",
"available"
],
"properties": {
"available": {
"type": "boolean"
},
"path": {
"type": "string"
},
"source": {
"$ref": "#/components/schemas/UvSource"
},
"version": {
"type": [
"string",
"null"
]
}
}
},
"UvSettingsResponse": {
"type": "object",
"required": [
"source",
"extra_env",
"managed_dir",
"python_dir",
"cache_dir",
"env_defaults",
"candidates"
],
"properties": {
"cache_dir": {
"type": "string",
"description": "实际生效的 uv 缓存目录(绝对路径)"
},
"candidates": {
"type": "array",
"items": {
"$ref": "#/components/schemas/UvCandidate"
},
"description": "各来源的探测结果"
},
"custom_path": {
"type": [
"string",
"null"
]
},
"env_defaults": {
"type": "object",
"description": "两个路径变量的默认值(相对程序目录),页面用来显示「默认」那一行",
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"type": "string"
}
},
"executable": {
"type": [
"string",
"null"
],
"description": "当前设置指向的 uv;不可用时 `version` 为空"
},
"extra_env": {
"type": "object",
"description": "额外注入给 uv 的环境变量;只允许 `UV_` 前缀",
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"type": "string"
}
},
"managed_dir": {
"type": "string",
"description": "程序目录下的 uv 目录"
},
"python_dir": {
"type": "string",
"description": "实际生效的 Python 存放目录(绝对路径,相对值按程序目录解析)"
},
"source": {
"$ref": "#/components/schemas/UvSource"
},
"version": {
"type": [
"string",
"null"
]
}
}
},
"UvSource": {
"type": "string",
"description": "uv 从哪里来。只用平台自己认的副本,不读系统 PATH:PATH 上的版本和可用性\n会随启动方式变化,不适合当调度器的隐式依赖。",
"enum": [
"managed",
"custom"
]
},
"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",
"uv_available",
"has_pyproject",
"has_requirements",
"requirements_files",
"can_create"
],
"properties": {
"can_create": {
"type": "boolean",
"description": "没有虚拟环境时,是否可以用 uv 创建(有 uv 即可,纯标准库脚本会得到一个空环境)"
},
"display_path": {
"type": [
"string",
"null"
],
"description": "供界面展示的解释器路径;位于工作目录内时使用相对路径"
},
"has_pyproject": {
"type": "boolean",
"description": "工作目录根部是否存在 pyproject.toml"
},
"has_requirements": {
"type": "boolean",
"description": "工作目录根部是否存在 requirements*.txt"
},
"interpreter_kind": {
"$ref": "#/components/schemas/InterpreterKind"
},
"message": {
"type": "string"
},
"requirements_files": {
"type": "array",
"items": {
"type": "string"
},
"description": "探测到的 requirements 文件名(仅根目录)"
},
"source": {
"oneOf": [
{
"$ref": "#/components/schemas/VenvSource"
},
{
"type": "null"
}
]
},
"status": {
"$ref": "#/components/schemas/VenvProbeStatus"
},
"uv_available": {
"type": "boolean",
"description": "本机 PATH 中是否能找到 uv"
},
"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"
]
}
}
}
}