Add scheduled task automation skill with worker execution pipeline.
Memind CI / Test, build, and release guards (push) Failing after 18s

Introduce scheduled-task-automation for H5 and WeChat, persist tasks in h5_scheduled_tasks, and run due jobs via a dedicated worker that executes agent tasks and delivers results.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-31 08:02:49 +08:00
parent 4186522c72
commit 81e63c16d3
27 changed files with 1736 additions and 2 deletions
+31
View File
@@ -772,6 +772,37 @@ export async function migrateSchema(pool) {
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
`);
await pool.query(`
CREATE TABLE IF NOT EXISTS h5_scheduled_tasks (
id CHAR(36) PRIMARY KEY,
user_id CHAR(36) NOT NULL,
title VARCHAR(200) NOT NULL,
task_spec TEXT NOT NULL,
recurrence ENUM('once', 'daily', 'weekly') NOT NULL DEFAULT 'daily',
hour TINYINT UNSIGNED NULL,
minute TINYINT UNSIGNED NOT NULL DEFAULT 0,
weekday TINYINT UNSIGNED NULL,
timezone VARCHAR(64) NOT NULL DEFAULT 'Asia/Shanghai',
next_run_at BIGINT NOT NULL,
last_run_at BIGINT NULL,
notify_channel ENUM('wechat', 'web', 'both') NOT NULL DEFAULT 'both',
status ENUM('active', 'locked', 'running', 'completed', 'failed', 'cancelled') NOT NULL DEFAULT 'active',
attempts INT NOT NULL DEFAULT 0,
locked_until BIGINT NULL,
last_error VARCHAR(500) NULL,
last_result_json JSON NULL,
source_channel ENUM('h5', 'wechat', 'agent', 'api') NOT NULL DEFAULT 'agent',
source_session_id VARCHAR(128) NULL,
source_message_id VARCHAR(128) NULL,
source_text TEXT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
KEY idx_scheduled_task_due (status, next_run_at),
KEY idx_scheduled_task_user (user_id, status, next_run_at),
CONSTRAINT fk_scheduled_task_user FOREIGN KEY (user_id) REFERENCES h5_users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
`);
await pool.query(`
CREATE TABLE IF NOT EXISTS h5_schedule_delivery_logs (
id CHAR(36) PRIMARY KEY,