zen-code 3.0.4 → 4.0.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/{use-input-1eSjZocJ.mjs → MultiLineTextInput-DjNvaZzA.mjs} +11966 -11473
- package/dist/app-QzdcE86p.mjs +11834 -0
- package/dist/ask_agents-bHg8fyUp.mjs +67 -0
- package/dist/{checkpoint-1sAx_j1E-DddugKQb.mjs → checkpoint-1sAx_j1E-vdL63_qZ.mjs} +2 -2
- package/dist/{checkpoint-DxiUsHMy-B5V5-cLZ.mjs → checkpoint-DxiUsHMy-DSc-mf5U.mjs} +2 -2
- package/dist/get_allowed_models-DWso18Ri.mjs +253 -0
- package/dist/{graphBuilder-B6OHvcgJ.mjs → graphBuilder-ulTm2bmI.mjs} +17628 -34829
- package/dist/{id-BclYO3iE.mjs → id-BHzJB_zk.mjs} +10 -10
- package/dist/index-BrsJ_rEy.mjs +212 -0
- package/dist/{index-CnZgr5T4.mjs → index-hjtoWC6i.mjs} +3 -3
- package/dist/load-Bh8eo6qE.mjs +119 -0
- package/dist/load-Cjl9cJ0o.mjs +105 -0
- package/dist/memories-C_p4qG-9.mjs +115 -0
- package/dist/nonInteractive.mjs +26 -22
- package/dist/{queue-D6tEGCGs-dM7Qa7Il.mjs → queue-D6tEGCGs-dshzv8m6.mjs} +1 -1
- package/dist/{shallow-VHsFXFdT.mjs → shallow-BJVbNSyQ.mjs} +3 -3
- package/dist/subagents-DnvCjtPv.mjs +95 -0
- package/dist/{tasks-Clf8LhHz.mjs → tasks-DhCRIevp.mjs} +1 -1
- package/dist/zen-code.mjs +2 -2
- package/dist/zen-init.mjs +189 -160
- package/dist/zen-keyboard.mjs +1 -1
- package/package.json +7 -5
- package/dist/app-D748EsP_.mjs +0 -18686
- package/dist/get_allowed_models-tD7oPVgc.mjs +0 -774
package/dist/nonInteractive.mjs
CHANGED
|
@@ -1,42 +1,46 @@
|
|
|
1
1
|
import { HumanMessage as c } from "langchain";
|
|
2
|
-
import { g as m } from "./graphBuilder-
|
|
2
|
+
import { g as m } from "./graphBuilder-ulTm2bmI.mjs";
|
|
3
3
|
import "@langchain/langgraph";
|
|
4
4
|
import "zod";
|
|
5
5
|
import "@langchain/openai";
|
|
6
6
|
import "@langchain/anthropic";
|
|
7
7
|
import "yaml";
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import "./ask_agents-bHg8fyUp.mjs";
|
|
9
|
+
import "micromatch";
|
|
10
|
+
import { i as p, g as l } from "./index-BG-c4_r3.mjs";
|
|
11
|
+
import "lowdb";
|
|
12
|
+
import "lowdb/node";
|
|
13
|
+
async function g() {
|
|
14
|
+
return new Promise((e, n) => {
|
|
15
|
+
let r = "";
|
|
16
|
+
process.stdin.setEncoding("utf8"), process.stdin.on("data", (t) => {
|
|
17
|
+
r += t;
|
|
14
18
|
}), process.stdin.on("end", () => {
|
|
15
|
-
|
|
16
|
-
}), process.stdin.on("error", (
|
|
17
|
-
|
|
19
|
+
e(r);
|
|
20
|
+
}), process.stdin.on("error", (t) => {
|
|
21
|
+
n(t);
|
|
18
22
|
});
|
|
19
23
|
});
|
|
20
24
|
}
|
|
21
|
-
async function
|
|
22
|
-
await
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
if (
|
|
25
|
+
async function v(e, n = !1) {
|
|
26
|
+
await p();
|
|
27
|
+
const r = await l();
|
|
28
|
+
let t = e || "";
|
|
29
|
+
if (n)
|
|
26
30
|
try {
|
|
27
|
-
|
|
31
|
+
t = (await g()).trim();
|
|
28
32
|
} catch (o) {
|
|
29
33
|
throw console.error("❌ 读取 stdin 失败:", o), o;
|
|
30
34
|
}
|
|
31
|
-
|
|
35
|
+
t || (console.error("❌ 错误: 未提供输入内容"), console.error(`
|
|
32
36
|
用法:`), console.error(' zen-code -p "你的任务描述"'), console.error(' echo "内容" | zen-code'), process.exit(1));
|
|
33
37
|
try {
|
|
34
38
|
const o = {
|
|
35
|
-
messages: [new c(
|
|
36
|
-
main_model:
|
|
37
|
-
enable_thinking:
|
|
39
|
+
messages: [new c(t)],
|
|
40
|
+
main_model: r.main_model,
|
|
41
|
+
enable_thinking: r.enable_thinking
|
|
38
42
|
}, s = await m.invoke(o, {
|
|
39
|
-
recursionLimit:
|
|
43
|
+
recursionLimit: 500
|
|
40
44
|
}), i = s.messages || [], a = i[i.length - 1];
|
|
41
45
|
return a && console.log(a.text), s;
|
|
42
46
|
} catch (o) {
|
|
@@ -46,5 +50,5 @@ async function k(t, r = !1) {
|
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
export {
|
|
49
|
-
|
|
53
|
+
v as runNonInteractive
|
|
50
54
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as $ } from "./id-
|
|
2
|
-
import { B as g } from "./app-
|
|
3
|
-
import "./graphBuilder-
|
|
1
|
+
import { u as $ } from "./id-BHzJB_zk.mjs";
|
|
2
|
+
import { B as g } from "./app-QzdcE86p.mjs";
|
|
3
|
+
import "./graphBuilder-ulTm2bmI.mjs";
|
|
4
4
|
import { createClient as T } from "redis";
|
|
5
5
|
function k(u) {
|
|
6
6
|
if (u === null || typeof u != "object") return JSON.stringify(u);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { HumanMessage as r, SystemMessage as u } from "langchain";
|
|
2
|
+
import { S as l, a as g } from "./ask_agents-bHg8fyUp.mjs";
|
|
3
|
+
const b = `
|
|
4
|
+
|
|
5
|
+
## SubAgents System
|
|
6
|
+
|
|
7
|
+
You have access to a subagent system that can delegate specialized tasks to other agents.
|
|
8
|
+
|
|
9
|
+
**Available SubAgents:**
|
|
10
|
+
|
|
11
|
+
{subagents_list}
|
|
12
|
+
|
|
13
|
+
**How to Use SubAgents (Progressive Disclosure):**
|
|
14
|
+
|
|
15
|
+
SubAgents follow a **progressive disclosure** pattern - you know they exist (name + description above), but you only delegate tasks when needed:
|
|
16
|
+
|
|
17
|
+
1. **Recognize when to delegate**: Check if the user's task matches a subagent's specialization
|
|
18
|
+
2. **Use the ask_subagents tool**: Call the tool with the subagent's ID and a clear task description
|
|
19
|
+
3. **Provide context**: Use the \`data_transfer\` parameter to pass relevant information
|
|
20
|
+
4. **Get results**: The subagent will process the task and return results
|
|
21
|
+
|
|
22
|
+
**When to Use SubAgents:**
|
|
23
|
+
- When the user's request requires specialized knowledge or workflows
|
|
24
|
+
- When a task is complex and can be broken down into subtasks
|
|
25
|
+
- When you need parallel processing or different expertise areas
|
|
26
|
+
- When a subagent provides proven patterns for specific domains
|
|
27
|
+
|
|
28
|
+
**SubAgent Tool Usage:**
|
|
29
|
+
|
|
30
|
+
The \`ask_subagents\` tool is available for delegation:
|
|
31
|
+
|
|
32
|
+
- **subagent_id**: The ID of the subagent to delegate to
|
|
33
|
+
- **task_description**: Clear description of what needs to be done
|
|
34
|
+
- **task_id** (optional): Identifier for tracking, it will automatically be generated after you run a subagent.
|
|
35
|
+
- **data_transfer** (optional): Context/data to pass to the subagent
|
|
36
|
+
|
|
37
|
+
**Example Workflow:**
|
|
38
|
+
|
|
39
|
+
User: "Can you have the research agent look into quantum computing developments?"
|
|
40
|
+
|
|
41
|
+
1. Check available subagents above → See "research" subagent with ID
|
|
42
|
+
2. Use ask_subagents tool with appropriate parameters
|
|
43
|
+
3. Provide clear task description and any necessary context
|
|
44
|
+
4. Process the results from the subagent
|
|
45
|
+
|
|
46
|
+
Remember: SubAgents are tools to distribute work and leverage specialized capabilities. When in doubt, check if a subagent exists for the task!
|
|
47
|
+
`;
|
|
48
|
+
class p {
|
|
49
|
+
name = "SubAgentsMiddleware";
|
|
50
|
+
stateSchema = l;
|
|
51
|
+
contextSchema = void 0;
|
|
52
|
+
tools = [];
|
|
53
|
+
constructor() {
|
|
54
|
+
this.tools.push(
|
|
55
|
+
g(
|
|
56
|
+
async (e, s, t) => await this.selectSubAgent(e, s, t),
|
|
57
|
+
{ name: "ask_subagents", description: "ask subagents to help you" }
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
subAgents = /* @__PURE__ */ new Map();
|
|
62
|
+
addSubAgents(e, s) {
|
|
63
|
+
this.subAgents.set(e, s);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Format subagents metadata for display in system prompt.
|
|
67
|
+
*/
|
|
68
|
+
formatSubAgentsList() {
|
|
69
|
+
if (this.subAgents.size === 0)
|
|
70
|
+
return "(No subagents available yet. You can add subagents using the addSubAgents method)";
|
|
71
|
+
const e = [];
|
|
72
|
+
for (const [s, t] of this.subAgents)
|
|
73
|
+
e.push(`- **${s}**: Subagent for specialized tasks`), e.push(` → Use ask_subagents with subagent_id: "${s}"`);
|
|
74
|
+
return e.join(`
|
|
75
|
+
`);
|
|
76
|
+
}
|
|
77
|
+
async selectSubAgent(e, s, t) {
|
|
78
|
+
return t.messages.push(new r(s.task_description)), this.subAgents.get(s.subagent_id)(e, s, t);
|
|
79
|
+
}
|
|
80
|
+
async wrapModelCall(e, s) {
|
|
81
|
+
const t = this.formatSubAgentsList(), n = b.replace("{subagents_list}", t);
|
|
82
|
+
let a;
|
|
83
|
+
e.systemPrompt ? a = e.systemPrompt + `
|
|
84
|
+
|
|
85
|
+
` + n : a = n;
|
|
86
|
+
const o = new u(a), i = {
|
|
87
|
+
...e,
|
|
88
|
+
systemMessage: o
|
|
89
|
+
};
|
|
90
|
+
return await s(i);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
p as SubAgentsMiddleware
|
|
95
|
+
};
|
package/dist/zen-code.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./MultiLineTextInput-DjNvaZzA.mjs";
|
|
2
2
|
import "chalk";
|
|
3
|
-
import "./app-
|
|
3
|
+
import "./app-QzdcE86p.mjs";
|