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.
@@ -1,42 +1,46 @@
1
1
  import { HumanMessage as c } from "langchain";
2
- import { g as m } from "./graphBuilder-B6OHvcgJ.mjs";
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 { i as l, g } from "./index-BG-c4_r3.mjs";
9
- async function d() {
10
- return new Promise((t, r) => {
11
- let n = "";
12
- process.stdin.setEncoding("utf8"), process.stdin.on("data", (e) => {
13
- n += e;
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
- t(n);
16
- }), process.stdin.on("error", (e) => {
17
- r(e);
19
+ e(r);
20
+ }), process.stdin.on("error", (t) => {
21
+ n(t);
18
22
  });
19
23
  });
20
24
  }
21
- async function k(t, r = !1) {
22
- await l();
23
- const n = await g();
24
- let e = t || "";
25
- if (r)
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
- e = (await d()).trim();
31
+ t = (await g()).trim();
28
32
  } catch (o) {
29
33
  throw console.error("❌ 读取 stdin 失败:", o), o;
30
34
  }
31
- e || (console.error("❌ 错误: 未提供输入内容"), console.error(`
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(e)],
36
- main_model: n.main_model,
37
- enable_thinking: n.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: 200
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
- k as runNonInteractive
53
+ v as runNonInteractive
50
54
  };
@@ -1,4 +1,4 @@
1
- import { a as h, C as u } from "./app-D748EsP_.mjs";
1
+ import { a as h, C as u } from "./app-QzdcE86p.mjs";
2
2
  import { createClient as c } from "redis";
3
3
  class n extends h {
4
4
  constructor(s, e = !0, i = 300) {
@@ -1,6 +1,6 @@
1
- import { u as $ } from "./id-BclYO3iE.mjs";
2
- import { B as g } from "./app-D748EsP_.mjs";
3
- import "./graphBuilder-B6OHvcgJ.mjs";
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
+ };
@@ -3,7 +3,7 @@ import "./index-BG-c4_r3.mjs";
3
3
  import "lowdb";
4
4
  import "lowdb/node";
5
5
  import "yaml";
6
- import { T as a } from "./graphBuilder-B6OHvcgJ.mjs";
6
+ import { T as a } from "./graphBuilder-ulTm2bmI.mjs";
7
7
  class r {
8
8
  store = null;
9
9
  projectRoot;
package/dist/zen-code.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import "./use-input-1eSjZocJ.mjs";
1
+ import "./MultiLineTextInput-DjNvaZzA.mjs";
2
2
  import "chalk";
3
- import "./app-D748EsP_.mjs";
3
+ import "./app-QzdcE86p.mjs";