📡 Kịch bản · status · dừng
Base: http://127.0.0.1:8765/api/v1. {name} = tên file không đuôi .apc (Windows không phân biệt hoa thường). Không dùng .., /, \ trong tên.
Health
GET /api/v1/healthMọi request → 200 đầy đủ (không còn bản “probe không token”). Dùng để kiểm tra app đang mở và API còn lắng nghe.
{
"ok": true,
"service": "automate-pc-local-api",
"ts": 1757280000,
"slots_used": 2,
"slots_max": 16,
"threads_max": 8,
"auth_required": false
}Danh sách kịch bản
GET /api/v1/scriptsLiệt kê mọi file data/scripts/*.apc, kèm job đang chạy.
{
"ok": true,
"scripts": [
{
"name": "DemoFlow",
"path": "D:\\...\\data\\scripts\\DemoFlow.apc",
"modified_at": 1757280000
}
],
"slots_used": 1,
"slots_max": 16,
"threads_max": 8,
"running_scripts": ["D:\\...\\DemoFlow.apc"],
"jobs": [
{
"id": "a1b2c3d4e5f6",
"path": "D:\\...\\DemoFlow.apc",
"error": "",
"started_at": 1757280010.5,
"waiting_input": false,
"kind": "flow",
"label": "DemoFlow/LDPlayer",
"instance_key": "hwnd:198764",
"hwnd": 198764
}
]
}| Field | Ý nghĩa |
|---|---|
name | Dùng trong URL {name} |
path | Đường dẫn tuyệt đối |
modified_at | Unix giây (mtime file) |
jobs[].id | job_id — dùng để stop từng luồng |
jobs[].hwnd / instance_key | Cửa sổ đang bind (đa luồng) |
jobs[].waiting_input | Đang chờ lượt chuột |
Trạng thái một kịch bản
GET /api/v1/scripts/{name}/status{
"ok": true,
"name": "DemoFlow",
"path": "D:\\...\\DemoFlow.apc",
"running": true,
"running_count": 2,
"error": "",
"started_at": 1757280010.5,
"waiting_input": false,
"jobs": [
{
"id": "...",
"hwnd": 198764,
"instance_key": "hwnd:198764",
"label": "DemoFlow/LD-1"
}
],
"engine": {
"running": true,
"running_script": "D:\\...\\DemoFlow.apc",
"running_scripts": ["D:\\...\\DemoFlow.apc"],
"jobs": [],
"slots_used": 2,
"slots_max": 16,
"threads_max": 8,
"error": "",
"started_at": 1757280010.5
}
}| Field | Ý nghĩa |
|---|---|
running | Kịch bản này còn ít nhất 1 job |
running_count | Số luồng của đúng file này |
jobs | Chỉ job của file này (kèm hwnd, instance_key) |
engine.* | Toàn bộ engine (mọi script) |
Danh sách job
GET /api/v1/jobsMọi job engine (mọi kịch bản). Field giống mảng jobs trong /scripts.
Dừng
Dừng cả file (mọi luồng của kịch bản)
POST /api/v1/scripts/{name}/stopXóa hàng đợi đa luồng của file đó, gửi tín hiệu stop mọi job cùng path.
200 stop_requested hoặc not_running.
Dừng một HWND / instance / job
Cùng URL, thêm JSON body:
{ "hwnd": 198764 }
{ "instance_key": "hwnd:198764" }
{ "job_id": "a1b2c3d4e5f6" }Ưu tiên: job_id → instance_key / hwnd → cả file.
Dừng theo job_id (mọi kịch bản)
POST /api/v1/jobs/{job_id}/stop200 stop_requested · 404 not_found.
Dừng tất cả
POST /api/v1/run/stopMọi job + xóa hàng đợi API.
{ "ok": true, "message": "stop_requested" }
{ "ok": true, "message": "not_running", "name": "DemoFlow", "engine_running": false }