@hanhnd/agent-kit 1.0.22 → 1.0.23
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/kit-server.js +15 -24
- package/dist/tools/agent.js +16 -27
- package/package.json +1 -1
package/dist/kit-server.js
CHANGED
|
@@ -21176,7 +21176,7 @@ ${"\u2500".repeat(60)}
|
|
|
21176
21176
|
function registerAgentTools(server2) {
|
|
21177
21177
|
server2.tool(
|
|
21178
21178
|
"kit_trigger_agent",
|
|
21179
|
-
"!Important: Trigger only when user explicitly asks to delegate a task to an external agent CLI (gemini or claude). The task can be a direct message or a path to a handoff file (.agent-kit/handoffs/plans/plan-xyz.md).
|
|
21179
|
+
"!Important: Trigger only when user explicitly asks to delegate a task to an external agent CLI (gemini or claude). The task can be a direct message or a path to a handoff file (.agent-kit/handoffs/plans/plan-xyz.md).",
|
|
21180
21180
|
{
|
|
21181
21181
|
agent: external_exports.enum(["gemini", "claude"]).describe('The agent CLI to invoke: "gemini" or "claude"'),
|
|
21182
21182
|
task: external_exports.string().describe(
|
|
@@ -21199,28 +21199,20 @@ function registerAgentTools(server2) {
|
|
|
21199
21199
|
return mcpText(`Error reading task file: ${err}`);
|
|
21200
21200
|
}
|
|
21201
21201
|
}
|
|
21202
|
-
let usedAgent = agent;
|
|
21203
|
-
let fallbackReason;
|
|
21204
21202
|
if (!commandExists(agent)) {
|
|
21205
|
-
const
|
|
21206
|
-
|
|
21207
|
-
|
|
21208
|
-
|
|
21209
|
-
|
|
21210
|
-
|
|
21211
|
-
|
|
21212
|
-
agent,
|
|
21213
|
-
status: "error",
|
|
21214
|
-
output: "",
|
|
21215
|
-
error: `Neither ${agent} nor the fallback agent CLI is installed. ${installHint}`
|
|
21216
|
-
});
|
|
21217
|
-
}
|
|
21203
|
+
const installHint = agent === "gemini" ? "Install Gemini CLI: https://github.com/google-gemini/gemini-cli" : "Install Claude CLI: npm install -g @anthropic-ai/claude-code";
|
|
21204
|
+
return mcpJson({
|
|
21205
|
+
agent,
|
|
21206
|
+
status: "error",
|
|
21207
|
+
output: "",
|
|
21208
|
+
error: `${agent} CLI is not installed. ${installHint}`
|
|
21209
|
+
});
|
|
21218
21210
|
}
|
|
21219
|
-
const agentArgs =
|
|
21220
|
-
const { logPath: lp, logStream } = initAgentLog(workspaceRoot, taskSlug(task),
|
|
21211
|
+
const agentArgs = agent === "gemini" ? ["-y", "-p", prompt] : ["--dangerously-skip-permissions", "-p", prompt];
|
|
21212
|
+
const { logPath: lp, logStream } = initAgentLog(workspaceRoot, taskSlug(task), agent);
|
|
21221
21213
|
logPath = lp;
|
|
21222
21214
|
const jobId = randomUUID();
|
|
21223
|
-
const child = spawn(
|
|
21215
|
+
const child = spawn(agent, agentArgs, {
|
|
21224
21216
|
cwd: workspaceRoot,
|
|
21225
21217
|
env: { ...process.env, GEMINI_WORKSPACE: workspaceRoot },
|
|
21226
21218
|
detached: process.platform !== "win32"
|
|
@@ -21237,7 +21229,7 @@ function registerAgentTools(server2) {
|
|
|
21237
21229
|
}
|
|
21238
21230
|
};
|
|
21239
21231
|
job = {
|
|
21240
|
-
agent
|
|
21232
|
+
agent,
|
|
21241
21233
|
process: child,
|
|
21242
21234
|
startedAt: /* @__PURE__ */ new Date(),
|
|
21243
21235
|
chunks: [],
|
|
@@ -21270,11 +21262,10 @@ function registerAgentTools(server2) {
|
|
|
21270
21262
|
child.on("error", reject);
|
|
21271
21263
|
});
|
|
21272
21264
|
return mcpJson({
|
|
21273
|
-
agent
|
|
21274
|
-
status:
|
|
21265
|
+
agent,
|
|
21266
|
+
status: "success",
|
|
21275
21267
|
log: logPath,
|
|
21276
|
-
output: sanitizeOutput(job.chunks.join(""))
|
|
21277
|
-
...fallbackReason && { fallback_reason: fallbackReason }
|
|
21268
|
+
output: sanitizeOutput(job.chunks.join(""))
|
|
21278
21269
|
});
|
|
21279
21270
|
} catch (error2) {
|
|
21280
21271
|
if (extra.signal.aborted) {
|
package/dist/tools/agent.js
CHANGED
|
@@ -34,7 +34,7 @@ function initAgentLog(workspaceRoot, slug, agent) {
|
|
|
34
34
|
return { logPath: path.relative(workspaceRoot, logFile), logStream };
|
|
35
35
|
}
|
|
36
36
|
export function registerAgentTools(server) {
|
|
37
|
-
server.tool('kit_trigger_agent', '!Important: Trigger only when user explicitly asks to delegate a task to an external agent CLI (gemini or claude). The task can be a direct message or a path to a handoff file (.agent-kit/handoffs/plans/plan-xyz.md).
|
|
37
|
+
server.tool('kit_trigger_agent', '!Important: Trigger only when user explicitly asks to delegate a task to an external agent CLI (gemini or claude). The task can be a direct message or a path to a handoff file (.agent-kit/handoffs/plans/plan-xyz.md).', {
|
|
38
38
|
agent: z.enum(['gemini', 'claude']).describe('The agent CLI to invoke: "gemini" or "claude"'),
|
|
39
39
|
task: z
|
|
40
40
|
.string()
|
|
@@ -57,38 +57,28 @@ export function registerAgentTools(server) {
|
|
|
57
57
|
return mcpText(`Error reading task file: ${err}`);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
// Resolve agent with fallback
|
|
61
|
-
let usedAgent = agent;
|
|
62
|
-
let fallbackReason;
|
|
63
60
|
if (!commandExists(agent)) {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return mcpJson({
|
|
74
|
-
agent,
|
|
75
|
-
status: 'error',
|
|
76
|
-
output: '',
|
|
77
|
-
error: `Neither ${agent} nor the fallback agent CLI is installed. ${installHint}`,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
61
|
+
const installHint = agent === 'gemini'
|
|
62
|
+
? 'Install Gemini CLI: https://github.com/google-gemini/gemini-cli'
|
|
63
|
+
: 'Install Claude CLI: npm install -g @anthropic-ai/claude-code';
|
|
64
|
+
return mcpJson({
|
|
65
|
+
agent,
|
|
66
|
+
status: 'error',
|
|
67
|
+
output: '',
|
|
68
|
+
error: `${agent} CLI is not installed. ${installHint}`,
|
|
69
|
+
});
|
|
80
70
|
}
|
|
81
71
|
// Gemini: -y (--yolo) for auto-accept, -p for headless prompt
|
|
82
72
|
// Claude: --dangerously-skip-permissions for auto-accept, -p/--print for headless
|
|
83
|
-
const agentArgs =
|
|
73
|
+
const agentArgs = agent === 'gemini'
|
|
84
74
|
? ['-y', '-p', prompt]
|
|
85
75
|
: ['--dangerously-skip-permissions', '-p', prompt];
|
|
86
|
-
const { logPath: lp, logStream } = initAgentLog(workspaceRoot, taskSlug(task),
|
|
76
|
+
const { logPath: lp, logStream } = initAgentLog(workspaceRoot, taskSlug(task), agent);
|
|
87
77
|
logPath = lp;
|
|
88
78
|
const jobId = randomUUID();
|
|
89
79
|
// detached=true on Unix creates a new process group so we can kill the
|
|
90
80
|
// entire tree (CLI + its sub-agents) with process.kill(-pid, signal).
|
|
91
|
-
const child = spawn(
|
|
81
|
+
const child = spawn(agent, agentArgs, {
|
|
92
82
|
cwd: workspaceRoot,
|
|
93
83
|
env: { ...process.env, GEMINI_WORKSPACE: workspaceRoot },
|
|
94
84
|
detached: process.platform !== 'win32',
|
|
@@ -107,7 +97,7 @@ export function registerAgentTools(server) {
|
|
|
107
97
|
}
|
|
108
98
|
};
|
|
109
99
|
job = {
|
|
110
|
-
agent:
|
|
100
|
+
agent: agent,
|
|
111
101
|
process: child,
|
|
112
102
|
startedAt: new Date(),
|
|
113
103
|
chunks: [],
|
|
@@ -142,11 +132,10 @@ export function registerAgentTools(server) {
|
|
|
142
132
|
child.on('error', reject);
|
|
143
133
|
});
|
|
144
134
|
return mcpJson({
|
|
145
|
-
agent
|
|
146
|
-
status:
|
|
135
|
+
agent,
|
|
136
|
+
status: 'success',
|
|
147
137
|
log: logPath,
|
|
148
138
|
output: sanitizeOutput(job.chunks.join('')),
|
|
149
|
-
...(fallbackReason && { fallback_reason: fallbackReason }),
|
|
150
139
|
});
|
|
151
140
|
}
|
|
152
141
|
catch (error) {
|