kovence-cli 1.2.0 → 1.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/CHANGELOG.md +38 -0
- package/README.md +66 -6
- package/nd.js +22 -1
- package/package.json +1 -1
- package/providers.js +524 -113
- package/src/agent/history.js +502 -9
- package/src/agent/project_context.js +219 -24
- package/src/agent/request_logger.js +148 -0
- package/src/agent/resilience.js +296 -46
- package/src/agent/streaming_write.js +23 -15
- package/src/agent/subagent.js +655 -0
- package/src/agent/turn.js +1210 -269
- package/src/cli/args.js +9 -1
- package/src/cli/sinks.js +188 -106
- package/src/commands/handlers.js +245 -7
- package/src/config/model_registry.js +39 -2
- package/src/config/sessions.js +19 -2
- package/src/config/skills.js +425 -0
- package/src/permissions/engine.js +22 -6
- package/src/permissions/store.js +4 -1
- package/src/settings/schema.js +298 -9
- package/src/settings/store.js +75 -6
- package/src/tools/browser.js +722 -0
- package/src/tools/edit.js +471 -0
- package/src/tools/exec.js +349 -34
- package/src/tools/patch_git.js +12 -1
- package/src/tools/read_tracker.js +87 -0
- package/src/tools/tasks.js +68 -28
- package/tools.js +778 -171
- package/tui.js +142 -30
- package/ui.js +22 -1
package/src/tools/tasks.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const { spawn } = require("node:child_process");
|
|
4
|
-
const { scrubChildEnv, killProcessGroup } = require("./exec");
|
|
4
|
+
const { scrubChildEnv, killProcessGroup, stripAnsiEscapes } = require("./exec");
|
|
5
5
|
|
|
6
6
|
const MAX_LOG_CHARS = 64000;
|
|
7
7
|
|
|
@@ -12,31 +12,9 @@ class BackgroundTaskManager {
|
|
|
12
12
|
this.onChange = onChange;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
this.seq += 1;
|
|
17
|
-
const id = String(this.seq);
|
|
18
|
-
const child = spawn("sh", ["-c", command], {
|
|
19
|
-
cwd,
|
|
20
|
-
env: env || scrubChildEnv(process.env),
|
|
21
|
-
detached: process.platform !== "win32",
|
|
22
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const task = {
|
|
26
|
-
id,
|
|
27
|
-
pid: child.pid,
|
|
28
|
-
command: String(command),
|
|
29
|
-
cwd,
|
|
30
|
-
startedAt: new Date().toISOString(),
|
|
31
|
-
endedAt: null,
|
|
32
|
-
status: "running",
|
|
33
|
-
exitCode: null,
|
|
34
|
-
output: "",
|
|
35
|
-
_child: child,
|
|
36
|
-
};
|
|
37
|
-
|
|
15
|
+
_attachChild(task, child) {
|
|
38
16
|
const appendOut = (chunk) => {
|
|
39
|
-
task.output += chunk.toString("utf8");
|
|
17
|
+
task.output += stripAnsiEscapes(chunk.toString("utf8"));
|
|
40
18
|
if (task.output.length > MAX_LOG_CHARS) {
|
|
41
19
|
task.output = task.output.slice(-MAX_LOG_CHARS);
|
|
42
20
|
}
|
|
@@ -61,7 +39,64 @@ class BackgroundTaskManager {
|
|
|
61
39
|
task._child = null;
|
|
62
40
|
this.onChange?.();
|
|
63
41
|
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
startTask(command, { cwd = process.cwd(), env = null } = {}) {
|
|
45
|
+
this.seq += 1;
|
|
46
|
+
const id = String(this.seq);
|
|
47
|
+
const isWin = process.platform === "win32";
|
|
48
|
+
const shellBin = isWin ? process.env.COMSPEC || "cmd.exe" : "sh";
|
|
49
|
+
const shellArgs = isWin ? ["/d", "/s", "/c", command] : ["-c", command];
|
|
50
|
+
const child = spawn(shellBin, shellArgs, {
|
|
51
|
+
cwd,
|
|
52
|
+
env: env || scrubChildEnv(process.env),
|
|
53
|
+
detached: !isWin,
|
|
54
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
55
|
+
});
|
|
64
56
|
|
|
57
|
+
const task = {
|
|
58
|
+
id,
|
|
59
|
+
pid: child.pid,
|
|
60
|
+
command: String(command),
|
|
61
|
+
cwd,
|
|
62
|
+
startedAt: new Date().toISOString(),
|
|
63
|
+
endedAt: null,
|
|
64
|
+
status: "running",
|
|
65
|
+
exitCode: null,
|
|
66
|
+
output: "",
|
|
67
|
+
_child: child,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
this._attachChild(task, child);
|
|
71
|
+
this.tasks.set(id, task);
|
|
72
|
+
this.onChange?.();
|
|
73
|
+
return this.serializeTask(task);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Adopt an already-running child process (e.g. promoted on command timeout).
|
|
78
|
+
*/
|
|
79
|
+
adoptProcess(child, { command, cwd = process.cwd(), initialOutput = "" } = {}) {
|
|
80
|
+
this.seq += 1;
|
|
81
|
+
const id = String(this.seq);
|
|
82
|
+
const cleanInitial = stripAnsiEscapes(initialOutput);
|
|
83
|
+
const task = {
|
|
84
|
+
id,
|
|
85
|
+
pid: child.pid,
|
|
86
|
+
command: String(command),
|
|
87
|
+
cwd,
|
|
88
|
+
startedAt: new Date().toISOString(),
|
|
89
|
+
endedAt: null,
|
|
90
|
+
status: child.exitCode !== null ? "exited" : "running",
|
|
91
|
+
exitCode: child.exitCode,
|
|
92
|
+
output: cleanInitial.length > MAX_LOG_CHARS ? cleanInitial.slice(-MAX_LOG_CHARS) : cleanInitial,
|
|
93
|
+
_child: child.exitCode !== null ? null : child,
|
|
94
|
+
};
|
|
95
|
+
if (task._child) {
|
|
96
|
+
this._attachChild(task, child);
|
|
97
|
+
} else {
|
|
98
|
+
task.endedAt = new Date().toISOString();
|
|
99
|
+
}
|
|
65
100
|
this.tasks.set(id, task);
|
|
66
101
|
this.onChange?.();
|
|
67
102
|
return this.serializeTask(task);
|
|
@@ -102,9 +137,10 @@ class BackgroundTaskManager {
|
|
|
102
137
|
if (!t) return false;
|
|
103
138
|
if (t.status === "running" && t._child) {
|
|
104
139
|
t.status = "killed";
|
|
105
|
-
|
|
140
|
+
const child = t._child;
|
|
141
|
+
killProcessGroup(child, "SIGTERM");
|
|
106
142
|
setTimeout(() => {
|
|
107
|
-
if (t._child) killProcessGroup(
|
|
143
|
+
if (t._child) killProcessGroup(child, "SIGKILL");
|
|
108
144
|
}, 300).unref?.();
|
|
109
145
|
this.onChange?.();
|
|
110
146
|
return true;
|
|
@@ -116,7 +152,11 @@ class BackgroundTaskManager {
|
|
|
116
152
|
for (const t of this.tasks.values()) {
|
|
117
153
|
if (t.status === "running" && t._child) {
|
|
118
154
|
t.status = "killed";
|
|
119
|
-
|
|
155
|
+
const child = t._child;
|
|
156
|
+
killProcessGroup(child, "SIGTERM");
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
killProcessGroup(child, "SIGKILL");
|
|
159
|
+
}, 200).unref?.();
|
|
120
160
|
}
|
|
121
161
|
}
|
|
122
162
|
}
|