zen-code 4.6.1 → 4.7.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/README.md +52 -27
- package/dist/FileSystemSkillStore-Dl5briBv.mjs +108 -0
- package/dist/MultiLineTextInput-e7hD79Wp.mjs +24631 -0
- package/dist/app-CcnStH9S.mjs +17015 -0
- package/dist/checkpoint-C5AFBYE--BbnaceZj.mjs +355 -0
- package/dist/checkpoint-DxiUsHMy-Cep4XMTK.mjs +394 -0
- package/dist/cli.mjs +17 -17
- package/dist/devtools-CzaVuYnh.mjs +2667 -0
- package/dist/graphBuilder-skVEY6RJ.mjs +34281 -0
- package/dist/index-BeLj9JYN.mjs +463 -0
- package/dist/{index-DEcMgCTj.mjs → index-D_dnZWV3.mjs} +2 -2
- package/dist/{load-Bh8eo6qE.mjs → load-iYJqYrjn.mjs} +1 -1
- package/dist/{memories-rSGKIPk5.mjs → memories-CSOPZKuJ.mjs} +2 -2
- package/dist/nonInteractive.mjs +28 -25
- package/dist/pg-adapter-BFtir1GE-BbUXBpaX.mjs +60 -0
- package/dist/queue-DySatFkr-DjaRbjhM.mjs +106 -0
- package/dist/remote-threads-CrG03ZS7-C9duTCnB.mjs +157 -0
- package/dist/shallow-CqCGqQDo.mjs +331 -0
- package/dist/shallow-checkpoint-BEhTdp7z-CquyGG0C.mjs +383 -0
- package/dist/sqlite-adapter-oBA95xba-BrBWorSV.mjs +82 -0
- package/dist/subTasks-DEZYN-F3.mjs +18 -0
- package/dist/zen-code.mjs +2 -8654
- package/dist/zen-keyboard.mjs +6 -7
- package/package.json +12 -9
- package/dist/FileSystemSkillStore-yvEvcRxB.mjs +0 -94
- package/dist/MultiLineTextInput-B4NEXnFm.mjs +0 -23343
- package/dist/devtools-BHqoL8a6.mjs +0 -11653
- package/dist/graphBuilder-B3IJ7dB2.mjs +0 -2641
- package/dist/subTasks-5KLIr9iy.mjs +0 -209
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { tool as g, HumanMessage as h, SystemMessage as p } from "langchain";
|
|
2
|
-
import { Command as m, Annotation as f } from "@langchain/langgraph";
|
|
3
|
-
import { z as n } from "zod";
|
|
4
|
-
import { createState as b } from "@langgraph-js/pro";
|
|
5
|
-
import { l as y, m as w } from "./graphBuilder-B3IJ7dB2.mjs";
|
|
6
|
-
n.object({
|
|
7
|
-
task_store: n.record(n.string(), n.any()).default({})
|
|
8
|
-
});
|
|
9
|
-
b().build({
|
|
10
|
-
task_store: f({
|
|
11
|
-
reducer: (r, t) => ({ ...r, ...t }),
|
|
12
|
-
default: () => ({})
|
|
13
|
-
})
|
|
14
|
-
});
|
|
15
|
-
const k = n.object({
|
|
16
|
-
task_id: n.string().optional().describe("The task id to ask the subagent, if not provided, will use the tool call id"),
|
|
17
|
-
subagent_id: n.string().describe(
|
|
18
|
-
'REQUIRED. The specific ID of the subagent to invoke (e.g., "agents/default", "agents/manager"). Must match exactly one of the available subagents listed in the system prompt.'
|
|
19
|
-
),
|
|
20
|
-
subagent_type: n.string().describe(
|
|
21
|
-
'REQUIRED. The type/category of subagent (e.g., "general-purpose", "statusline-setup"). Must be one of the available agent types listed in the tool description.'
|
|
22
|
-
),
|
|
23
|
-
task_description: n.string().describe("Describe the user state and what you want the subagent to do."),
|
|
24
|
-
data_transfer: n.any().optional().describe("Data to transfer to the subagent.")
|
|
25
|
-
}), _ = (r, t) => g(
|
|
26
|
-
async (e, s) => {
|
|
27
|
-
const a = s.state, o = e.task_id || s.toolCall.id;
|
|
28
|
-
let i = {
|
|
29
|
-
messages: []
|
|
30
|
-
};
|
|
31
|
-
o && a?.task_store?.[o] ? i = a?.task_store[o] : (i = JSON.parse(JSON.stringify(a)), i.messages = [], i.task_store = {});
|
|
32
|
-
const l = await r(o, e, a);
|
|
33
|
-
i.messages.push(new h({ content: e.task_description })), e.data_transfer && i.messages.push(
|
|
34
|
-
new h({
|
|
35
|
-
content: `Here is the data to help you complete the task: ${JSON.stringify(
|
|
36
|
-
e.data_transfer,
|
|
37
|
-
null,
|
|
38
|
-
2
|
|
39
|
-
)}`
|
|
40
|
-
})
|
|
41
|
-
);
|
|
42
|
-
const u = await l.invoke(i), c = u.messages.at(-1), d = {
|
|
43
|
-
task_store: {
|
|
44
|
-
...a?.task_store || {},
|
|
45
|
-
[o]: u
|
|
46
|
-
},
|
|
47
|
-
messages: [
|
|
48
|
-
{
|
|
49
|
-
role: "tool",
|
|
50
|
-
content: `task_id: ${o}
|
|
51
|
-
---
|
|
52
|
-
` + (c?.text || ""),
|
|
53
|
-
tool_call_id: s.toolCall.id
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
};
|
|
57
|
-
return new m({
|
|
58
|
-
update: d
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: "task",
|
|
63
|
-
description: `Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
64
|
-
|
|
65
|
-
Available agent types and the tools they have access to:
|
|
66
|
-
- general-purpose: General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you. (Tools: *)
|
|
67
|
-
- statusline-setup: Use this agent to configure the user's Claude Code status line setting. (Tools: Read, Edit)
|
|
68
|
-
- output-style-setup: Use this agent to create a Claude Code output style. (Tools: Read, Write, Edit, Glob, LS, Grep)
|
|
69
|
-
|
|
70
|
-
**IMPORTANT: Both subagent_id AND subagent_type are REQUIRED parameters. You must provide BOTH.**
|
|
71
|
-
|
|
72
|
-
- subagent_id: The specific ID of the subagent (e.g., "agents/default", "agents/manager")
|
|
73
|
-
- subagent_type: The type category of the subagent (e.g., "general-purpose", "statusline-setup")
|
|
74
|
-
|
|
75
|
-
When NOT to use the Agent tool:
|
|
76
|
-
- If you want to read a specific file path, use the Read or Glob tool instead of the Agent tool, to find the match more quickly
|
|
77
|
-
- If you are searching for a specific class definition like "class Foo", use the Glob tool instead, to find the match more quickly
|
|
78
|
-
- If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Agent tool, to find the match more quickly
|
|
79
|
-
- Other tasks that are not related to the agent descriptions above
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Usage notes:
|
|
83
|
-
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
84
|
-
2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
|
|
85
|
-
3. Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
|
|
86
|
-
4. The agent's outputs should generally be trusted
|
|
87
|
-
5. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent
|
|
88
|
-
6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
|
|
89
|
-
|
|
90
|
-
Example usage:
|
|
91
|
-
|
|
92
|
-
<example_agent_descriptions>
|
|
93
|
-
"code-reviewer": use this agent after you are done writing a significant piece of code
|
|
94
|
-
"greeting-responder": use this agent when to respond to user greetings with a friendly joke
|
|
95
|
-
</example_agent_description>
|
|
96
|
-
|
|
97
|
-
<example>
|
|
98
|
-
user: "Please write a function that checks if a number is prime"
|
|
99
|
-
assistant: Sure let me write a function that checks if a number is prime
|
|
100
|
-
assistant: First let me use the Write tool to write a function that checks if a number is prime
|
|
101
|
-
assistant: I'm going to use the Write tool to write the following code:
|
|
102
|
-
<code>
|
|
103
|
-
function isPrime(n) {
|
|
104
|
-
if (n <= 1) return false
|
|
105
|
-
for (let i = 2; i * i <= n; i++) {
|
|
106
|
-
if (n % i === 0) return false
|
|
107
|
-
}
|
|
108
|
-
return true
|
|
109
|
-
}
|
|
110
|
-
</code>
|
|
111
|
-
<commentary>
|
|
112
|
-
Since a signficant piece of code was written and the task was completed, now use the code-reviewer agent to review the code
|
|
113
|
-
</commentary>
|
|
114
|
-
assistant: Now let me use the code-reviewer agent to review the code
|
|
115
|
-
assistant: Uses the Task tool to launch the with the code-reviewer agent
|
|
116
|
-
</example>
|
|
117
|
-
|
|
118
|
-
<example>
|
|
119
|
-
user: "Hello"
|
|
120
|
-
<commentary>
|
|
121
|
-
Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
|
|
122
|
-
</commentary>
|
|
123
|
-
assistant: "I'm going to use the Task tool to launch the with the greeting-responder agent"
|
|
124
|
-
</example>
|
|
125
|
-
`,
|
|
126
|
-
schema: k
|
|
127
|
-
}
|
|
128
|
-
), v = `
|
|
129
|
-
|
|
130
|
-
## SubAgents System
|
|
131
|
-
|
|
132
|
-
You have access to a subagent system that can delegate specialized tasks to other agents.
|
|
133
|
-
|
|
134
|
-
**Available SubAgents:**
|
|
135
|
-
|
|
136
|
-
{subagents_list}
|
|
137
|
-
|
|
138
|
-
**How to Use SubAgents (Progressive Disclosure):**
|
|
139
|
-
|
|
140
|
-
SubAgents follow a **progressive disclosure** pattern - you know they exist (name + description above), but you only delegate tasks when needed:
|
|
141
|
-
|
|
142
|
-
1. **Recognize when to delegate**: Check if the user's task matches a subagent's specialization
|
|
143
|
-
2. **Use the task tool**: Call the tool with the subagent's ID and a clear task description
|
|
144
|
-
3. **Provide context**: Use the \`data_transfer\` parameter to pass relevant information
|
|
145
|
-
4. **Get results**: The subagent will process the task and return results
|
|
146
|
-
|
|
147
|
-
**When to Use SubAgents:**
|
|
148
|
-
- When the user's request requires specialized knowledge or workflows
|
|
149
|
-
- When a task is complex and can be broken down into subtasks
|
|
150
|
-
- When you need parallel processing or different expertise areas
|
|
151
|
-
- When a subagent provides proven patterns for specific domains
|
|
152
|
-
|
|
153
|
-
**SubAgent Tool Usage:**
|
|
154
|
-
|
|
155
|
-
The \`task\` tool is available for delegation:
|
|
156
|
-
|
|
157
|
-
- **subagent_id**: The ID of the subagent to delegate to
|
|
158
|
-
- **task_description**: Clear description of what needs to be done
|
|
159
|
-
- **task_id** (optional): Identifier for tracking, it will automatically be generated after you run a subagent.
|
|
160
|
-
- **data_transfer** (optional): Context/data to pass to the subagent
|
|
161
|
-
|
|
162
|
-
**Example Workflow:**
|
|
163
|
-
|
|
164
|
-
User: "Can you have the research agent look into quantum computing developments?"
|
|
165
|
-
|
|
166
|
-
1. Check available subagents above → See "research" subagent with ID
|
|
167
|
-
2. Use task tool with appropriate parameters
|
|
168
|
-
3. Provide clear task description and any necessary context
|
|
169
|
-
4. Process the results from the subagent
|
|
170
|
-
|
|
171
|
-
Remember: SubAgents are tools to distribute work and leverage specialized capabilities. When in doubt, check if a subagent exists for the task!
|
|
172
|
-
`;
|
|
173
|
-
class U {
|
|
174
|
-
name = "SubAgentsMiddleware";
|
|
175
|
-
stateSchema = y;
|
|
176
|
-
// contextSchema = undefined;
|
|
177
|
-
tools = [];
|
|
178
|
-
agentList = Promise.resolve("");
|
|
179
|
-
constructor(t) {
|
|
180
|
-
this.agentList = this.formatSubAgentsList(t), this.tools.push(
|
|
181
|
-
_(async (e, s, a) => await w(s.subagent_id, t, a, {}, { parent_id: e }))
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Format subagents metadata for display in system prompt.
|
|
186
|
-
*/
|
|
187
|
-
async formatSubAgentsList(t) {
|
|
188
|
-
const e = [];
|
|
189
|
-
for (const s of await t.listAgents())
|
|
190
|
-
e.push(`- **${s.id}**: ${s.description}`), e.push(` → Use task with subagent_id: "${s.id}"`);
|
|
191
|
-
return e.join(`
|
|
192
|
-
`);
|
|
193
|
-
}
|
|
194
|
-
async wrapModelCall(t, e) {
|
|
195
|
-
const s = await this.agentList, a = v.replace("{subagents_list}", s);
|
|
196
|
-
let o;
|
|
197
|
-
t.systemPrompt ? o = t.systemPrompt + `
|
|
198
|
-
|
|
199
|
-
` + a : o = a;
|
|
200
|
-
const i = new p(o), l = {
|
|
201
|
-
...t,
|
|
202
|
-
systemMessage: i
|
|
203
|
-
};
|
|
204
|
-
return await e(l);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
export {
|
|
208
|
-
U as SubAgentsMiddleware
|
|
209
|
-
};
|