zen-code 2.1.0 → 2.3.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/MultiSelect-DZAUJ6V8.mjs +651 -0
- package/dist/app-C0lXPfzi.mjs +10027 -0
- package/dist/{checkpoint-1sAx_j1E-DbNzRw_n.mjs → checkpoint-1sAx_j1E-CeuO6wLL.mjs} +2 -1
- package/dist/{checkpoint-DxiUsHMy-BVWm3y9_.mjs → checkpoint-DxiUsHMy-D5StF4Dg.mjs} +4 -3
- package/dist/cli.mjs +33 -0
- package/dist/{devtools-BxIzBVXg.mjs → devtools-DpL9Fl6d.mjs} +658 -649
- package/dist/{app-CdJSgzzZ.mjs → graph-aTwGGPhX.mjs} +26957 -35867
- package/dist/{id-Bh5iJfyi.mjs → id-D-r9rdKn.mjs} +1 -1
- package/dist/{index-tkCYsAxh.mjs → index-DgogF6Ub.mjs} +5 -4
- package/dist/index-DpsJ-2by.mjs +23 -0
- package/dist/nonInteractive.mjs +45 -0
- package/dist/{queue-BSCnCent-DK-siJDC.mjs → queue-D6tEGCGs-CEAj3iiS.mjs} +21 -15
- package/dist/{shallow-Buk4Nzc4.mjs → shallow-Cg7nKycD.mjs} +5 -4
- package/dist/{use-input-CQELhJxU.mjs → use-input-1eSjZocJ.mjs} +751 -748
- package/dist/zen-code.mjs +2 -2
- package/dist/zen-init.mjs +5 -4
- package/dist/zen-keyboard.mjs +1 -1
- package/package.json +15 -17
- package/cli.js +0 -10
- package/dist/MultiSelect-C_hSPGpl.mjs +0 -655
- package/dist/index-DXn61qXM.mjs +0 -767
- package/dist/memory-BmHqUV4v.mjs +0 -93
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { u as C } from "./id-
|
|
2
|
-
import { B as v, c as x, T as $, m as I } from "./app-
|
|
1
|
+
import { u as C } from "./id-D-r9rdKn.mjs";
|
|
2
|
+
import { B as v, c as x, T as $, m as I } from "./app-C0lXPfzi.mjs";
|
|
3
|
+
import "./graph-aTwGGPhX.mjs";
|
|
3
4
|
import { createClient as O, createCluster as N } from "redis";
|
|
4
5
|
const W = [
|
|
5
6
|
{
|
|
@@ -105,7 +106,7 @@ const W = [
|
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
];
|
|
108
|
-
var
|
|
109
|
+
var L = class m extends v {
|
|
109
110
|
client;
|
|
110
111
|
ttlConfig;
|
|
111
112
|
constructor(e, t) {
|
|
@@ -459,5 +460,5 @@ function g(w) {
|
|
|
459
460
|
});
|
|
460
461
|
}
|
|
461
462
|
export {
|
|
462
|
-
|
|
463
|
+
L as RedisSaver
|
|
463
464
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Low as s } from "lowdb";
|
|
2
|
+
import { JSONFile as c } from "lowdb/node";
|
|
3
|
+
import d from "node:os";
|
|
4
|
+
import i from "node:path";
|
|
5
|
+
import e from "node:fs";
|
|
6
|
+
const n = {
|
|
7
|
+
config: {
|
|
8
|
+
main_model: "claude-sonnet-4-5",
|
|
9
|
+
model_provider: "openai"
|
|
10
|
+
}
|
|
11
|
+
}, f = d.homedir(), o = i.join(f, ".zen-code"), _ = i.join(o, "settings.json"), p = new c(_), a = new s(p, n), w = async () => {
|
|
12
|
+
await e.promises.mkdir(o, { recursive: !0 }), await a.read(), (!a.data || !a.data.config) && (a.data = n, await a.write()), t();
|
|
13
|
+
}, E = () => a.data.config, t = () => {
|
|
14
|
+
a.data.config.model_provider && (process.env.MODEL_PROVIDER = a.data.config.model_provider), a.data.config.openai_api_key && (process.env.OPENAI_API_KEY = a.data.config.openai_api_key), a.data.config.openai_base_url && (process.env.OPENAI_BASE_URL = a.data.config.openai_base_url), a.data.config.anthropic_api_key && (process.env.ANTHROPIC_API_KEY = a.data.config.anthropic_api_key), a.data.config.anthropic_base_url && (process.env.ANTHROPIC_BASE_URL = a.data.config.anthropic_base_url);
|
|
15
|
+
}, b = async (r) => {
|
|
16
|
+
await e.promises.mkdir(o, { recursive: !0 }), Object.assign(a.data.config, r), await a.write(), t();
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
_ as d,
|
|
20
|
+
E as g,
|
|
21
|
+
w as i,
|
|
22
|
+
b as u
|
|
23
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { HumanMessage as c } from "langchain";
|
|
2
|
+
import { g as l } from "./graph-aTwGGPhX.mjs";
|
|
3
|
+
import { i as m, g } from "./index-DpsJ-2by.mjs";
|
|
4
|
+
async function d() {
|
|
5
|
+
return new Promise((r, t) => {
|
|
6
|
+
let o = "";
|
|
7
|
+
process.stdin.setEncoding("utf8"), process.stdin.on("data", (n) => {
|
|
8
|
+
o += n;
|
|
9
|
+
}), process.stdin.on("end", () => {
|
|
10
|
+
r(o);
|
|
11
|
+
}), process.stdin.on("error", (n) => {
|
|
12
|
+
t(n);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async function u(r, t = !1) {
|
|
17
|
+
await m();
|
|
18
|
+
const o = g();
|
|
19
|
+
let n = r || "";
|
|
20
|
+
if (t)
|
|
21
|
+
try {
|
|
22
|
+
n = (await d()).trim();
|
|
23
|
+
} catch (e) {
|
|
24
|
+
throw console.error("❌ 读取 stdin 失败:", e), e;
|
|
25
|
+
}
|
|
26
|
+
n || (console.error("❌ 错误: 未提供输入内容"), console.error(`
|
|
27
|
+
用法:`), console.error(' zen-code -p "你的任务描述"'), console.error(' echo "内容" | zen-code'), process.exit(1));
|
|
28
|
+
try {
|
|
29
|
+
const e = {
|
|
30
|
+
messages: [new c(n)],
|
|
31
|
+
main_model: o.main_model,
|
|
32
|
+
enable_thinking: o.enable_thinking
|
|
33
|
+
}, s = await l.invoke(e, {
|
|
34
|
+
recursionLimit: 200
|
|
35
|
+
}), i = s.messages || [], a = i[i.length - 1];
|
|
36
|
+
return a && console.log(a.text), s;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw console.error(`
|
|
39
|
+
❌ 执行失败: ${e instanceof Error ? e.message : String(e)}
|
|
40
|
+
`), e;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
u as runNonInteractive
|
|
45
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { createClient as
|
|
3
|
-
class
|
|
1
|
+
import { a as h, C as u } from "./app-C0lXPfzi.mjs";
|
|
2
|
+
import { createClient as c } from "redis";
|
|
3
|
+
class n extends h {
|
|
4
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 =
|
|
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
6
|
}
|
|
7
|
-
static redis =
|
|
8
|
-
static subscriberRedis =
|
|
7
|
+
static redis = c({ url: process.env.REDIS_URL });
|
|
8
|
+
static subscriberRedis = c({ url: process.env.REDIS_URL });
|
|
9
9
|
static isQueueExist(s) {
|
|
10
10
|
return this.redis.exists(`queue:${s}`).then((e) => e > 0);
|
|
11
11
|
}
|
|
@@ -27,17 +27,23 @@ class r extends u {
|
|
|
27
27
|
*/
|
|
28
28
|
async *onDataReceive() {
|
|
29
29
|
let s = [], e = null, i = !1;
|
|
30
|
-
|
|
30
|
+
if (this.cancelSignal.signal.aborted)
|
|
31
|
+
return;
|
|
32
|
+
const l = async (t) => {
|
|
31
33
|
const a = await this.decodeData(t);
|
|
32
34
|
s.push(a), (a.event === "__stream_end__" || a.event === "__stream_error__" || a.event === "__stream_cancel__") && (setTimeout(() => {
|
|
33
35
|
i = !0, e && (e(), e = null);
|
|
34
|
-
}, 300), a.event === "__stream_cancel__" && this.cancel()), e && (e(), e = null);
|
|
36
|
+
}, 300), a.event === "__stream_cancel__" && await this.cancel()), e && (e(), e = null);
|
|
35
37
|
};
|
|
36
38
|
await this.subscriberRedis.subscribe(this.channelKey, (t) => {
|
|
37
|
-
|
|
39
|
+
l(t);
|
|
38
40
|
});
|
|
41
|
+
const r = () => {
|
|
42
|
+
i = !0, e && (e(), e = null);
|
|
43
|
+
};
|
|
44
|
+
this.cancelSignal.signal.addEventListener("abort", r);
|
|
39
45
|
try {
|
|
40
|
-
for (; !i; )
|
|
46
|
+
for (; !i && !this.cancelSignal.signal.aborted; )
|
|
41
47
|
if (s.length > 0) {
|
|
42
48
|
for (const t of s)
|
|
43
49
|
yield t;
|
|
@@ -47,7 +53,7 @@ class r extends u {
|
|
|
47
53
|
e = t;
|
|
48
54
|
});
|
|
49
55
|
} finally {
|
|
50
|
-
await this.subscriberRedis.unsubscribe(this.channelKey);
|
|
56
|
+
await this.subscriberRedis.unsubscribe(this.channelKey), this.cancelSignal.signal.removeEventListener("abort", r);
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
/**
|
|
@@ -68,14 +74,14 @@ class r extends u {
|
|
|
68
74
|
/**
|
|
69
75
|
* 取消操作
|
|
70
76
|
*/
|
|
71
|
-
cancel() {
|
|
72
|
-
this.
|
|
77
|
+
async cancel() {
|
|
78
|
+
this.cancelSignal.abort("user cancel this run"), await this.push(new u());
|
|
73
79
|
}
|
|
74
80
|
async copyToQueue(s, e) {
|
|
75
|
-
const i = new
|
|
81
|
+
const i = new n(s, this.compressMessages, e ?? this.ttl);
|
|
76
82
|
return await this.redis.copy(this.queueKey, i.queueKey), await this.redis.expire(i.queueKey, e ?? this.ttl), i;
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
export {
|
|
80
|
-
|
|
86
|
+
n as RedisStreamQueue
|
|
81
87
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { u as $ } from "./id-
|
|
2
|
-
import { B as g } from "./app-
|
|
1
|
+
import { u as $ } from "./id-D-r9rdKn.mjs";
|
|
2
|
+
import { B as g } from "./app-C0lXPfzi.mjs";
|
|
3
|
+
import "./graph-aTwGGPhX.mjs";
|
|
3
4
|
import { createClient as T } from "redis";
|
|
4
5
|
function k(u) {
|
|
5
6
|
if (u === null || typeof u != "object") return JSON.stringify(u);
|
|
@@ -86,7 +87,7 @@ const S = [{
|
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
}];
|
|
89
|
-
var
|
|
90
|
+
var O = class w extends g {
|
|
90
91
|
client;
|
|
91
92
|
ttlConfig;
|
|
92
93
|
constructor(t, e) {
|
|
@@ -327,5 +328,5 @@ var C = class w extends g {
|
|
|
327
328
|
}
|
|
328
329
|
};
|
|
329
330
|
export {
|
|
330
|
-
|
|
331
|
+
O as ShallowRedisSaver
|
|
331
332
|
};
|