zen-code 4.2.0 → 4.4.0
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/dist/app-BmOiGQbk.mjs +15899 -0
- package/dist/{checkpoint-1sAx_j1E-C7OZFRPe.mjs → checkpoint-1sAx_j1E-CmiXKr4s.mjs} +2 -2
- package/dist/{checkpoint-DxiUsHMy-LKqXeDEy.mjs → checkpoint-DxiUsHMy-DGyqjfqu.mjs} +2 -2
- package/dist/{graphBuilder-B3T9KyfH.mjs → graphBuilder-B0bC88R_.mjs} +2432 -2435
- package/dist/{id-DAEnqc1v.mjs → id-Cu7CRpDw.mjs} +1 -1
- package/dist/index-BHwkVemt.mjs +23 -0
- package/dist/{index-B9w1j1Jz.mjs → index-Bgm_TqjU.mjs} +13 -13
- package/dist/{index-D7W7mYQR.mjs → index-e2Fy3126.mjs} +3 -3
- package/dist/{memories-D7PFLLlR.mjs → memories-B8HqG014.mjs} +1 -1
- package/dist/nonInteractive.mjs +9 -11
- package/dist/queue-Bfg-8ehP-C5S3FsuT.mjs +106 -0
- package/dist/remote-threads-CrG03ZS7-C9duTCnB.mjs +157 -0
- package/dist/{shallow-ChkcFpXh.mjs → shallow-BKCaK1wH.mjs} +3 -3
- package/dist/{sqlite-adapter-5PeLHaxe-CUccULPN.mjs → sqlite-adapter-Bbonr5S5-DQLjfvyu.mjs} +10 -6
- package/dist/{subTasks-PsCKmIx0.mjs → subTasks-BTMXARkP.mjs} +1 -1
- package/dist/zen-code.mjs +1 -1
- package/package.json +7 -6
- package/dist/app-DWJrZDvr.mjs +0 -12316
- package/dist/queue-D6tEGCGs-C8z6cY9y.mjs +0 -87
- package/dist/tasks-Dmf3N6e4.mjs +0 -237
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { a as h, C as u } from "./app-DWJrZDvr.mjs";
|
|
2
|
-
import { createClient as c } from "redis";
|
|
3
|
-
class n extends h {
|
|
4
|
-
constructor(s, e = !0, i = 300) {
|
|
5
|
-
super(s, !0, i), this.id = s, this.compressMessages = e, this.ttl = i, this.queueKey = `queue:${this.id}`, this.channelKey = `channel:${this.id}`, this.redis = n.redis, this.subscriberRedis = n.subscriberRedis, this.cancelSignal = new AbortController(), this.redis.isOpen || this.redis.connect(), this.subscriberRedis.isOpen || this.subscriberRedis.connect(), this.isConnected = !0;
|
|
6
|
-
}
|
|
7
|
-
static redis = c({ url: process.env.REDIS_URL });
|
|
8
|
-
static subscriberRedis = c({ url: process.env.REDIS_URL });
|
|
9
|
-
static isQueueExist(s) {
|
|
10
|
-
return this.redis.exists(`queue:${s}`).then((e) => e > 0);
|
|
11
|
-
}
|
|
12
|
-
redis;
|
|
13
|
-
subscriberRedis;
|
|
14
|
-
queueKey;
|
|
15
|
-
channelKey;
|
|
16
|
-
isConnected = !1;
|
|
17
|
-
cancelSignal;
|
|
18
|
-
/**
|
|
19
|
-
* 推送消息到 Redis 队列
|
|
20
|
-
*/
|
|
21
|
-
async push(s) {
|
|
22
|
-
const e = await this.encodeData(s), i = Buffer.from(e);
|
|
23
|
-
await this.redis.rPush(this.queueKey, i), await this.redis.expire(this.queueKey, this.ttl), await this.redis.publish(this.channelKey, i), this.emit("dataChange", e);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 异步生成器:支持 for await...of 方式消费队列数据
|
|
27
|
-
*/
|
|
28
|
-
async *onDataReceive() {
|
|
29
|
-
let s = [], e = null, i = !1;
|
|
30
|
-
if (this.cancelSignal.signal.aborted)
|
|
31
|
-
return;
|
|
32
|
-
const l = async (t) => {
|
|
33
|
-
const a = await this.decodeData(t);
|
|
34
|
-
s.push(a), (a.event === "__stream_end__" || a.event === "__stream_error__" || a.event === "__stream_cancel__") && (setTimeout(() => {
|
|
35
|
-
i = !0, e && (e(), e = null);
|
|
36
|
-
}, 300), a.event === "__stream_cancel__" && await this.cancel()), e && (e(), e = null);
|
|
37
|
-
};
|
|
38
|
-
await this.subscriberRedis.subscribe(this.channelKey, (t) => {
|
|
39
|
-
l(t);
|
|
40
|
-
});
|
|
41
|
-
const r = () => {
|
|
42
|
-
i = !0, e && (e(), e = null);
|
|
43
|
-
};
|
|
44
|
-
this.cancelSignal.signal.addEventListener("abort", r);
|
|
45
|
-
try {
|
|
46
|
-
for (; !i && !this.cancelSignal.signal.aborted; )
|
|
47
|
-
if (s.length > 0) {
|
|
48
|
-
for (const t of s)
|
|
49
|
-
yield t;
|
|
50
|
-
s = [];
|
|
51
|
-
} else
|
|
52
|
-
await new Promise((t) => {
|
|
53
|
-
e = t;
|
|
54
|
-
});
|
|
55
|
-
} finally {
|
|
56
|
-
await this.subscriberRedis.unsubscribe(this.channelKey), this.cancelSignal.signal.removeEventListener("abort", r);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* 获取队列中的所有数据
|
|
61
|
-
*/
|
|
62
|
-
async getAll() {
|
|
63
|
-
const s = await this.redis.lRange(this.queueKey, 0, -1);
|
|
64
|
-
return !s || s.length === 0 ? [] : this.compressMessages ? await Promise.all(
|
|
65
|
-
s.map((e) => this.decodeData(e))
|
|
66
|
-
) : s.map((e) => JSON.parse(e));
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 清空队列
|
|
70
|
-
*/
|
|
71
|
-
clear() {
|
|
72
|
-
this.isConnected && this.redis.del(this.queueKey);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* 取消操作
|
|
76
|
-
*/
|
|
77
|
-
async cancel() {
|
|
78
|
-
this.cancelSignal.abort("user cancel this run"), await this.push(new u());
|
|
79
|
-
}
|
|
80
|
-
async copyToQueue(s, e) {
|
|
81
|
-
const i = new n(s, this.compressMessages, e ?? this.ttl);
|
|
82
|
-
return await this.redis.copy(this.queueKey, i.queueKey), await this.redis.expire(i.queueKey, e ?? this.ttl), i;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
export {
|
|
86
|
-
n as RedisStreamQueue
|
|
87
|
-
};
|
package/dist/tasks-Dmf3N6e4.mjs
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import "micromatch";
|
|
2
|
-
import "./graphBuilder-B3T9KyfH.mjs";
|
|
3
|
-
import { Low as n } from "lowdb";
|
|
4
|
-
import { JSONFile as d } from "lowdb/node";
|
|
5
|
-
import "yaml";
|
|
6
|
-
import r from "node:path";
|
|
7
|
-
class h {
|
|
8
|
-
db;
|
|
9
|
-
dbPath;
|
|
10
|
-
constructor(t) {
|
|
11
|
-
this.dbPath = r.join(t, ".claude", "task.json");
|
|
12
|
-
const a = new d(this.dbPath);
|
|
13
|
-
this.db = new n(a, this.getDefaultData());
|
|
14
|
-
}
|
|
15
|
-
getDefaultData() {
|
|
16
|
-
return {
|
|
17
|
-
version: "1.0",
|
|
18
|
-
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19
|
-
tasks: {},
|
|
20
|
-
history: [],
|
|
21
|
-
config: {
|
|
22
|
-
maxConcurrentAgents: 3,
|
|
23
|
-
retryLimit: 3,
|
|
24
|
-
autoResume: !1
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 初始化数据库
|
|
30
|
-
*/
|
|
31
|
-
async initialize() {
|
|
32
|
-
const t = await import("node:fs"), a = r.dirname(this.dbPath);
|
|
33
|
-
t.existsSync(a) || t.mkdirSync(a, { recursive: !0 }), await this.db.read(), this.db.data || (this.db.data = this.getDefaultData(), await this.db.write());
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 获取单个任务
|
|
37
|
-
*/
|
|
38
|
-
async getTask(t) {
|
|
39
|
-
return await this.db.read(), this.db.data.tasks[t];
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* 更新任务
|
|
43
|
-
*/
|
|
44
|
-
async updateTask(t, a) {
|
|
45
|
-
await this.db.read();
|
|
46
|
-
const i = this.db.data.tasks[t];
|
|
47
|
-
return i ? (this.db.data.tasks[t] = {
|
|
48
|
-
...i,
|
|
49
|
-
...a
|
|
50
|
-
}, a.status && (a.status === "running" && !i.startedAt ? this.db.data.tasks[t].startedAt = (/* @__PURE__ */ new Date()).toISOString() : ["complete", "error", "review"].includes(a.status) && !i.completedAt && (this.db.data.tasks[t].completedAt = (/* @__PURE__ */ new Date()).toISOString())), this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write(), !0) : !1;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* 批量添加任务(用于 Plan 初始化)
|
|
54
|
-
*/
|
|
55
|
-
async addTasks(t) {
|
|
56
|
-
await this.db.read();
|
|
57
|
-
for (const a of t)
|
|
58
|
-
this.db.data.tasks[a.id] = a;
|
|
59
|
-
this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write();
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 根据 status 获取任务列表
|
|
63
|
-
*/
|
|
64
|
-
async getTasksByStatus(t) {
|
|
65
|
-
return await this.db.read(), Object.values(this.db.data.tasks).filter((a) => a.status === t);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 获取所有任务
|
|
69
|
-
*/
|
|
70
|
-
async getAllTasks() {
|
|
71
|
-
return await this.db.read(), Object.values(this.db.data.tasks);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* 添加执行记录
|
|
75
|
-
*/
|
|
76
|
-
async addHistory(t) {
|
|
77
|
-
await this.db.read(), this.db.data.history.push(t), await this.db.write();
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 获取执行历史
|
|
81
|
-
*/
|
|
82
|
-
async getHistory(t) {
|
|
83
|
-
return await this.db.read(), t ? this.db.data.history.filter((a) => a.planId === t) : this.db.data.history;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* 设置活跃 Plan ID
|
|
87
|
-
*/
|
|
88
|
-
async setActivePlan(t) {
|
|
89
|
-
await this.db.read(), this.db.data.activePlanId = t, this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write();
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* 获取活跃 Plan ID
|
|
93
|
-
*/
|
|
94
|
-
async getActivePlan() {
|
|
95
|
-
return await this.db.read(), this.db.data.activePlanId;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* 更新配置
|
|
99
|
-
*/
|
|
100
|
-
async updateConfig(t) {
|
|
101
|
-
await this.db.read(), this.db.data.config = {
|
|
102
|
-
...this.db.data.config,
|
|
103
|
-
...t
|
|
104
|
-
}, this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* 获取配置
|
|
108
|
-
*/
|
|
109
|
-
async getConfig() {
|
|
110
|
-
return await this.db.read(), this.db.data.config;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* 清空所有任务(慎用)
|
|
114
|
-
*/
|
|
115
|
-
async clearAllTasks() {
|
|
116
|
-
await this.db.read(), this.db.data.tasks = {}, this.db.data.activePlanId = void 0, this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write();
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* 删除单个任务
|
|
120
|
-
*/
|
|
121
|
-
async deleteTask(t) {
|
|
122
|
-
return await this.db.read(), this.db.data.tasks[t] ? (delete this.db.data.tasks[t], this.db.data.lastUpdated = (/* @__PURE__ */ new Date()).toISOString(), await this.db.write(), !0) : !1;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* 获取数据库路径(用于测试)
|
|
126
|
-
*/
|
|
127
|
-
getDbPath() {
|
|
128
|
-
return this.dbPath;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
class o {
|
|
132
|
-
store = null;
|
|
133
|
-
projectRoot;
|
|
134
|
-
constructor(t) {
|
|
135
|
-
this.projectRoot = t;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* 初始化 Store
|
|
139
|
-
*/
|
|
140
|
-
async initialize() {
|
|
141
|
-
this.store || (this.store = new h(this.projectRoot), await this.store.initialize());
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* 确保 Store 已初始化
|
|
145
|
-
*/
|
|
146
|
-
ensureInitialized() {
|
|
147
|
-
if (!this.store)
|
|
148
|
-
throw new Error("TasksStore not initialized. Call initialize() first.");
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* 获取所有任务
|
|
152
|
-
*/
|
|
153
|
-
async getAllTasks() {
|
|
154
|
-
return this.ensureInitialized(), await this.store.getAllTasks();
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* 根据 status 获取任务
|
|
158
|
-
*/
|
|
159
|
-
async getTasksByStatus(t) {
|
|
160
|
-
return this.ensureInitialized(), await this.store.getTasksByStatus(t);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* 获取单个任务
|
|
164
|
-
*/
|
|
165
|
-
async getTask(t) {
|
|
166
|
-
return this.ensureInitialized(), await this.store.getTask(t);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* 更新任务状态
|
|
170
|
-
*/
|
|
171
|
-
async updateTaskStatus(t, a) {
|
|
172
|
-
return this.ensureInitialized(), await this.store.updateTask(t, { status: a });
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* 删除任务
|
|
176
|
-
*/
|
|
177
|
-
async deleteTask(t) {
|
|
178
|
-
return this.ensureInitialized(), await this.store.deleteTask(t);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* 批量添加任务
|
|
182
|
-
*/
|
|
183
|
-
async addTasks(t) {
|
|
184
|
-
this.ensureInitialized(), await this.store.addTasks(t);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* 获取活跃 Plan ID
|
|
188
|
-
*/
|
|
189
|
-
async getActivePlan() {
|
|
190
|
-
return this.ensureInitialized(), await this.store.getActivePlan();
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* 设置活跃 Plan ID
|
|
194
|
-
*/
|
|
195
|
-
async setActivePlan(t) {
|
|
196
|
-
this.ensureInitialized(), await this.store.setActivePlan(t);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* 获取任务统计
|
|
200
|
-
*/
|
|
201
|
-
async getTaskStats() {
|
|
202
|
-
const t = await this.getAllTasks();
|
|
203
|
-
return {
|
|
204
|
-
total: t.length,
|
|
205
|
-
pickup: t.filter((a) => a.status === "pickup").length,
|
|
206
|
-
running: t.filter((a) => a.status === "running").length,
|
|
207
|
-
complete: t.filter((a) => a.status === "complete").length,
|
|
208
|
-
error: t.filter((a) => a.status === "error").length,
|
|
209
|
-
review: t.filter((a) => a.status === "review").length,
|
|
210
|
-
feedback: t.filter((a) => a.status === "feedback").length
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* 获取执行历史
|
|
215
|
-
*/
|
|
216
|
-
async getHistory(t) {
|
|
217
|
-
return this.ensureInitialized(), await this.store.getHistory(t);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* 清空所有任务(慎用)
|
|
221
|
-
*/
|
|
222
|
-
async clearAllTasks() {
|
|
223
|
-
this.ensureInitialized(), await this.store.clearAllTasks();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
let e = null;
|
|
227
|
-
function k(s) {
|
|
228
|
-
if (!e) {
|
|
229
|
-
if (!s)
|
|
230
|
-
throw new Error("projectRoot is required for first initialization");
|
|
231
|
-
e = new o(s);
|
|
232
|
-
}
|
|
233
|
-
return e;
|
|
234
|
-
}
|
|
235
|
-
export {
|
|
236
|
-
k as getTasksStore
|
|
237
|
-
};
|