opencode-supertask 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,6 +7,8 @@ AI-powered task queue for [OpenCode](https://opencode.ai) agents — schedule, r
7
7
 
8
8
  [简体中文](#简体中文)
9
9
 
10
+ Documentation: [current architecture](docs/architecture.md) · [operations and troubleshooting](docs/operations.md) · [document index](docs/README.md)
11
+
10
12
  ## Installation
11
13
 
12
14
  ### Quick Install
@@ -19,12 +21,14 @@ Add the plugin to `~/.config/opencode/opencode.json`:
19
21
  }
20
22
  ```
21
23
 
22
- Restart OpenCode. That's it.
24
+ Restart OpenCode to load 11 `supertask_*` tools. Then choose how to run the Gateway:
25
+
26
+ ```bash
27
+ supertask install # recommended for long-running use: explicit pm2 setup
28
+ supertask gateway # foreground mode: no pm2 required
29
+ ```
23
30
 
24
- The plugin auto-starts a Gateway process (via pm2) and injects:
25
- - 10 MCP tools (`supertask_add`, `supertask_next`, `supertask_start`, `supertask_done`, `supertask_fail`, `supertask_get`, `supertask_list`, `supertask_status`, `supertask_retry`, `supertask_schedule`)
26
- - A `supertask-runner` agent (used internally by the Gateway)
27
- - A Web Dashboard at http://localhost:4680
31
+ The plugin never installs global dependencies by itself. Without a running Gateway, queue-management tools still work, but scheduled and queued tasks are not executed and the Dashboard is unavailable.
28
32
 
29
33
  ### Uninstall
30
34
 
@@ -41,7 +45,7 @@ rm ~/.local/share/opencode/tasks.db
41
45
  ### CLI Install / Uninstall
42
46
 
43
47
  ```bash
44
- supertask install # Install Gateway as pm2 service (auto-start, crash recovery)
48
+ supertask install # Explicitly install/configure pm2 and start Gateway
45
49
  supertask uninstall # Stop and remove Gateway from pm2
46
50
  ```
47
51
 
@@ -64,7 +68,7 @@ Then add the local path to your config:
64
68
 
65
69
  ## Quick Start
66
70
 
67
- After installation, the Gateway starts automatically. Use the MCP tools in OpenCode:
71
+ After starting the Gateway with `supertask install` or `supertask gateway`, use the MCP tools in OpenCode:
68
72
 
69
73
  ```
70
74
  Create a task: "帮我生成项目的 README" with agent "explore"
@@ -87,7 +91,8 @@ supertask ui # open Web Dashboard in browser
87
91
  supertask config # show current config
88
92
 
89
93
  # Task management
90
- supertask add -n "Task" -a "agent" -p "prompt" --importance 5
94
+ supertask add -n "Task" -a "agent" -p "prompt" --importance 5 \
95
+ --max-retries 3 --retry-backoff "30s" --timeout "30min"
91
96
  supertask list [--status pending] [--limit 20]
92
97
  supertask get --id 1
93
98
  supertask status
@@ -100,7 +105,8 @@ supertask template add --name "Daily" --agent "gen" \
100
105
  supertask template add --name "Delayed" --agent "gen" \
101
106
  --prompt "..." --type delayed --delay "30min"
102
107
  supertask template add --name "Hourly" --agent "gen" \
103
- --prompt "..." --type recurring --interval "1h"
108
+ --prompt "..." --type recurring --interval "1h" \
109
+ --batch "reports" --retry-backoff "30s" --timeout "30min"
104
110
  supertask template list
105
111
  supertask template enable --id 1
106
112
  ```
@@ -121,8 +127,8 @@ Schedule supports friendly duration strings:
121
127
  ## Architecture
122
128
 
123
129
  ```
124
- Gateway (auto-started by pm2)
125
- ├── Worker → claim tasks, spawn supertask-runner via opencode run
130
+ Gateway (foreground or optionally managed by pm2)
131
+ ├── Worker → claim tasks, execute the target agent via opencode run
126
132
  ├── Scheduler → clone tasks from templates (cron / delayed / recurring)
127
133
  ├── Watchdog → heartbeat timeout, auto-retry, data cleanup
128
134
  └── Dashboard → Web UI on port 4680 (Hono SSR)
@@ -130,29 +136,42 @@ Gateway (auto-started by pm2)
130
136
 
131
137
  Config file: `~/.config/opencode/supertask.json`
132
138
 
139
+ The complete configuration reference and restart semantics are documented in [Operations and Troubleshooting](docs/operations.md).
140
+
133
141
  ```json
134
142
  {
135
- "worker": { "maxConcurrency": 2 },
136
- "scheduler": { "enabled": true, "catchUp": "next" },
137
- "watchdog": { "heartbeatTimeoutMs": 600000, "retentionDays": 30 },
143
+ "configVersion": 2,
144
+ "worker": { "maxConcurrency": 2, "taskTimeoutMs": 1800000, "shutdownGracePeriodMs": 30000 },
145
+ "scheduler": { "enabled": true, "checkIntervalMs": 1000 },
146
+ "watchdog": {
147
+ "heartbeatTimeoutMs": 600000,
148
+ "checkIntervalMs": 60000,
149
+ "cleanupIntervalMs": 86400000,
150
+ "retentionDays": 30
151
+ },
138
152
  "dashboard": { "enabled": true, "port": 4680 }
139
153
  }
140
154
  ```
141
155
 
142
156
  Key mechanisms:
143
- - **Auto-start** — Plugin auto-installs pm2 and starts Gateway on first use
144
- - **Auto-upgrade** — Plugin detects version changes and auto-reloads Gateway
157
+ - **Process supervision** — optional pm2 crash recovery; plugin load never installs pm2, but can reuse an existing installation
158
+ - **Version-aware restart** — if pm2 is already installed, plugin load starts or restarts the Gateway when the package version changes
145
159
  - **Process lock** — SQLite `BEGIN IMMEDIATE` ensures single instance
160
+ - **Readiness check** — PM2 PID must match a fresh, ready Gateway lock; `/health` also checks component activity
146
161
  - **Heartbeat** — Worker updates every 30s; Watchdog kills stale processes
147
- - **Exponential backoff** — 30s × 2^n, capped at 30min
148
- - **Dead letter queue** — Exhausted retries `dead_letter`, manually recoverable
162
+ - **Graceful shutdown** — stop claiming work, drain active tasks for 30s, then interrupt and requeue only unfinished tasks
163
+ - **Exponential backoff** — configurable base × 2^n, capped at 30min
164
+ - **Dead letter queue** — `maxRetries` additional retries exhausted → `dead_letter`, manually recoverable
149
165
  - **Batch isolation** — Same `batchId` serial; different `batchId` parallel
150
- - **Priority** — `urgency DESC → importance DESC → createdAt ASC`
166
+ - **Priority** — `urgency DESC → importance DESC → createdAt ASC → id ASC`
167
+ - **Local Dashboard boundary** — loopback-only listener, same-origin write checks, escaped database output
151
168
 
152
169
  ## Web Dashboard
153
170
 
154
171
  http://localhost:4680 — 4 pages:
155
172
 
173
+ Health endpoint: `GET http://localhost:4680/health` returns 200 only after Gateway startup completes and its internal loops remain active.
174
+
156
175
  | Page | Features |
157
176
  |------|----------|
158
177
  | Task Queue | Filter by status, retry, delete |
@@ -182,6 +201,8 @@ MIT
182
201
 
183
202
  SuperTask 是一个基于 SQLite 的 AI Agent 任务调度系统,专为 [OpenCode](https://opencode.ai) 设计。
184
203
 
204
+ 详细文档:[当前架构与决策](docs/architecture.md) · [运行与排障手册](docs/operations.md) · [文档索引](docs/README.md)
205
+
185
206
  ### 安装
186
207
 
187
208
  在 `~/.config/opencode/opencode.json` 中添加:
@@ -192,10 +213,14 @@ SuperTask 是一个基于 SQLite 的 AI Agent 任务调度系统,专为 [OpenC
192
213
  }
193
214
  ```
194
215
 
195
- 重启 OpenCode 即可。插件会自动:
196
- - 安装 pm2 并启动 Gateway 常驻进程
197
- - 注入 10 个 MCP 工具和 supertask-runner Agent
198
- - 启动 Web 控制台(http://localhost:4680)
216
+ 重启 OpenCode 后会注入 11 个 `supertask_*` 工具。随后选择一种 Gateway 运行方式:
217
+
218
+ ```bash
219
+ supertask install # 长期运行推荐:显式安装/配置 pm2 并启动 Gateway
220
+ supertask gateway # 前台运行:不需要 pm2
221
+ ```
222
+
223
+ 插件不会自行安装全局依赖。Gateway 未运行时仍可管理队列,但不会执行排队/定时任务,也不会启动 Web 控制台。
199
224
 
200
225
  ### 卸载
201
226
 
@@ -223,8 +248,9 @@ supertask template add --type cron --cron "0 9 * * *" ...
223
248
  ### 核心功能
224
249
 
225
250
  - **任务队列** — 优先级调度、批次隔离、依赖管理
226
- - **自动启动**插件首次加载时自动安装 pm2 并启动 Gateway
227
- - **自动升级**插件更新后自动检测版本变化并 reload Gateway
251
+ - **安全停止**默认等待在途任务 30 秒;超时任务才会被中断并重新排队
252
+ - **进程守护**可选 pm2 崩溃恢复;插件加载不会安装 pm2,但可复用机器上已有的 PM2
253
+ - **版本感知重启** — 已安装 pm2 时,插件加载会在包版本变化后启动或重启 Gateway
228
254
  - **定时任务** — cron / delayed / recurring,支持友好时间格式
229
255
  - **Web 控制台** — 任务监控、执行日志、在线配置、清空数据库
230
256
  - **Session 追踪** — 自动从 opencode run 输出中捕获 session ID