u-foo 3.0.29 → 3.0.31
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 +13 -8
- package/bin/ufoo.js +7 -2
- package/bin/ugrok.js +68 -0
- package/dist/tui/darwin-arm64/ufoo-tui +0 -0
- package/dist/tui/darwin-x64/ufoo-tui +0 -0
- package/dist/tui/linux-arm64/ufoo-tui +0 -0
- package/dist/tui/linux-x64/ufoo-tui +0 -0
- package/package.json +2 -1
- package/src/agents/activity/activityDetector.js +95 -0
- package/src/agents/controller/ufooAgent.js +3 -3
- package/src/agents/launch/launcher.js +17 -11
- package/src/agents/launch/ptyRunner.js +34 -12
- package/src/agents/launch/readyDetector.js +27 -0
- package/src/agents/prompts/defaultBootstrap.js +126 -1
- package/src/agents/providers/directAuthStatus.js +79 -0
- package/src/agents/providers/upstreamTransport.js +234 -85
- package/src/app/chat/commandExecutor.js +18 -10
- package/src/app/chat/commands.js +4 -2
- package/src/app/cli/run.js +7 -5
- package/src/code/UcodeController.js +201 -40
- package/src/code/agent.js +9 -2
- package/src/code/commands.js +13 -0
- package/src/code/dispatch.js +9 -1
- package/src/code/index.js +9 -2
- package/src/code/nativeRunner.js +398 -16
- package/src/code/providers/index.js +1 -0
- package/src/code/providers/modelsCatalog.js +21 -6
- package/src/code/providers/openaiResponsesTransport.js +119 -0
- package/src/code/providers/responsesProtocol.js +499 -0
- package/src/code/providers/transportContract.js +5 -1
- package/src/code/repl.js +95 -2
- package/src/code/tools/bash.js +159 -6
- package/src/code/ucodeSlashDispatch.js +13 -0
- package/src/config.js +6 -0
- package/src/coordination/bus/inject.js +2 -2
- package/src/coordination/bus/utils.js +4 -1
- package/src/orchestration/controller/gateRouter.js +2 -2
- package/src/orchestration/controller/launchRouting.js +2 -1
- package/src/orchestration/groups/validateTemplate.js +1 -1
- package/src/orchestration/solo/commands.js +1 -0
- package/src/runtime/daemon/index.js +12 -4
- package/src/runtime/daemon/nicknameScope.js +4 -1
- package/src/runtime/daemon/ops.js +8 -2
- package/src/ui/rustUcodeHost.js +86 -10
package/src/code/repl.js
CHANGED
|
@@ -111,6 +111,24 @@ function runSingleCommand(line = "", workspaceRoot = process.cwd()) {
|
|
|
111
111
|
kind: "status",
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
+
const queueMatch = text.match(/^(?:\/queue|queue)(?:\s+(.*))?$/i);
|
|
115
|
+
if (queueMatch) {
|
|
116
|
+
const action = String(queueMatch[1] || "status").trim().toLowerCase();
|
|
117
|
+
if (action === "status" || action === "show" || action === "") {
|
|
118
|
+
return { kind: "queue", action: "status" };
|
|
119
|
+
}
|
|
120
|
+
if (action === "clear") return { kind: "queue", action: "clear" };
|
|
121
|
+
if (action === "cancel" || action === "current") {
|
|
122
|
+
return { kind: "queue", action: "cancel" };
|
|
123
|
+
}
|
|
124
|
+
if (action === "stop" || action === "all") {
|
|
125
|
+
return { kind: "queue", action: "stop" };
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
kind: "error",
|
|
129
|
+
output: "usage: /queue [status|clear|cancel|stop]",
|
|
130
|
+
};
|
|
131
|
+
}
|
|
114
132
|
const modelMatch = text.match(/^(?:\/model|model)(?:\s+(.*))?$/i);
|
|
115
133
|
if (modelMatch) {
|
|
116
134
|
const rest = String(modelMatch[1] || "").trim();
|
|
@@ -387,6 +405,54 @@ async function runUcodeCoreAgent({
|
|
|
387
405
|
let autoBusError = "";
|
|
388
406
|
let closing = false;
|
|
389
407
|
let taskInFlight = false;
|
|
408
|
+
let queuedWork = 0;
|
|
409
|
+
let queueGeneration = 0;
|
|
410
|
+
let activeAbortController = null;
|
|
411
|
+
|
|
412
|
+
function formatCoreQueueStatus() {
|
|
413
|
+
return `Queue: ${taskInFlight ? "active" : "idle"} · pending ${queuedWork}`;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function handleCoreQueueCommand(action = "status") {
|
|
417
|
+
const normalized = String(action || "status").trim().toLowerCase();
|
|
418
|
+
if (normalized === "status") {
|
|
419
|
+
stdout.write(`${formatCoreQueueStatus()}\n`);
|
|
420
|
+
printPrompt(stdout);
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
if (normalized === "cancel") {
|
|
424
|
+
if (!activeAbortController) {
|
|
425
|
+
stdout.write("Queue: no active task.\n");
|
|
426
|
+
} else {
|
|
427
|
+
activeAbortController.abort();
|
|
428
|
+
stdout.write("Cancellation requested for the active task.\n");
|
|
429
|
+
}
|
|
430
|
+
printPrompt(stdout);
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
if (normalized === "clear") {
|
|
434
|
+
const count = queuedWork;
|
|
435
|
+
queueGeneration += 1;
|
|
436
|
+
queuedWork = 0;
|
|
437
|
+
stdout.write(count
|
|
438
|
+
? `Cleared ${count} pending task${count === 1 ? "" : "s"}.\n`
|
|
439
|
+
: "Queue: no pending tasks.\n");
|
|
440
|
+
printPrompt(stdout);
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
if (normalized === "stop") {
|
|
444
|
+
const count = queuedWork;
|
|
445
|
+
queueGeneration += 1;
|
|
446
|
+
queuedWork = 0;
|
|
447
|
+
if (activeAbortController) activeAbortController.abort();
|
|
448
|
+
stdout.write(`Queue stopped: ${activeAbortController ? "active cancellation requested" : "no active task"}; cleared ${count} pending.\n`);
|
|
449
|
+
printPrompt(stdout);
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
stdout.write("usage: /queue [status|clear|cancel|stop]\n");
|
|
453
|
+
printPrompt(stdout);
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
390
456
|
|
|
391
457
|
const runAutoBusOnce = async () => {
|
|
392
458
|
if (!autoBusEnabled || closing) return;
|
|
@@ -554,9 +620,12 @@ async function runUcodeCoreAgent({
|
|
|
554
620
|
}
|
|
555
621
|
|
|
556
622
|
taskInFlight = true;
|
|
623
|
+
const taskAbortController = new AbortController();
|
|
624
|
+
activeAbortController = taskAbortController;
|
|
557
625
|
let nlResult;
|
|
558
626
|
try {
|
|
559
627
|
nlResult = await runNaturalLanguageTask(result.task, state, {
|
|
628
|
+
signal: taskAbortController.signal,
|
|
560
629
|
onDelta: state.jsonOutput
|
|
561
630
|
? null
|
|
562
631
|
: async (delta) => {
|
|
@@ -575,6 +644,7 @@ async function runUcodeCoreAgent({
|
|
|
575
644
|
});
|
|
576
645
|
} finally {
|
|
577
646
|
taskInFlight = false;
|
|
647
|
+
if (activeAbortController === taskAbortController) activeAbortController = null;
|
|
578
648
|
}
|
|
579
649
|
|
|
580
650
|
if (!state.jsonOutput) {
|
|
@@ -620,6 +690,14 @@ async function runUcodeCoreAgent({
|
|
|
620
690
|
rl.on("line", (line) => {
|
|
621
691
|
const trimmed = normalizeLine(line);
|
|
622
692
|
|
|
693
|
+
if (/^(?:\/queue|queue)(?:\s|$)/i.test(trimmed)) {
|
|
694
|
+
const queueResult = runSingleCommand(trimmed, state.workspaceRoot || workspaceRoot);
|
|
695
|
+
if (queueResult.kind === "queue") {
|
|
696
|
+
handleCoreQueueCommand(queueResult.action);
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
623
701
|
// Pending approval/choice/chat takes priority over nudge / new NL.
|
|
624
702
|
try {
|
|
625
703
|
const { hasPendingUserInteraction } = require("./context/userInteraction");
|
|
@@ -628,7 +706,11 @@ async function runUcodeCoreAgent({
|
|
|
628
706
|
&& state.executionState
|
|
629
707
|
&& hasPendingUserInteraction(state.executionState)
|
|
630
708
|
) {
|
|
709
|
+
const generation = queueGeneration;
|
|
710
|
+
queuedWork += 1;
|
|
631
711
|
chain = chain.then(async () => {
|
|
712
|
+
queuedWork = Math.max(0, queuedWork - 1);
|
|
713
|
+
if (generation !== queueGeneration) return;
|
|
632
714
|
let streamBuffer = null;
|
|
633
715
|
let streamedVisible = false;
|
|
634
716
|
const escapeStripper = createEscapeTagStripper();
|
|
@@ -639,9 +721,12 @@ async function runUcodeCoreAgent({
|
|
|
639
721
|
});
|
|
640
722
|
}
|
|
641
723
|
taskInFlight = true;
|
|
724
|
+
const taskAbortController = new AbortController();
|
|
725
|
+
activeAbortController = taskAbortController;
|
|
642
726
|
let resumeResult;
|
|
643
727
|
try {
|
|
644
728
|
resumeResult = await submitUserInteractionAnswer(trimmed, state, {
|
|
729
|
+
signal: taskAbortController.signal,
|
|
645
730
|
onDelta: state.jsonOutput
|
|
646
731
|
? null
|
|
647
732
|
: async (delta) => {
|
|
@@ -660,6 +745,7 @@ async function runUcodeCoreAgent({
|
|
|
660
745
|
});
|
|
661
746
|
} finally {
|
|
662
747
|
taskInFlight = false;
|
|
748
|
+
if (activeAbortController === taskAbortController) activeAbortController = null;
|
|
663
749
|
}
|
|
664
750
|
if (streamBuffer) {
|
|
665
751
|
await streamBuffer.finish();
|
|
@@ -704,7 +790,13 @@ async function runUcodeCoreAgent({
|
|
|
704
790
|
printPrompt(stdout);
|
|
705
791
|
return;
|
|
706
792
|
}
|
|
707
|
-
|
|
793
|
+
const generation = queueGeneration;
|
|
794
|
+
queuedWork += 1;
|
|
795
|
+
chain = chain.then(() => {
|
|
796
|
+
queuedWork = Math.max(0, queuedWork - 1);
|
|
797
|
+
if (generation !== queueGeneration) return;
|
|
798
|
+
return handleLine(line);
|
|
799
|
+
}).catch((err) => {
|
|
708
800
|
stdout.write(`${JSON.stringify({ ok: false, error: err && err.message ? err.message : "agent loop failed" })}\n`);
|
|
709
801
|
printPrompt(stdout);
|
|
710
802
|
});
|
|
@@ -712,6 +804,7 @@ async function runUcodeCoreAgent({
|
|
|
712
804
|
|
|
713
805
|
rl.on("close", () => {
|
|
714
806
|
closing = true;
|
|
807
|
+
if (activeAbortController) activeAbortController.abort();
|
|
715
808
|
if (autoBusTimer) {
|
|
716
809
|
clearInterval(autoBusTimer);
|
|
717
810
|
autoBusTimer = null;
|
|
@@ -800,4 +893,4 @@ module.exports = {
|
|
|
800
893
|
applyUcodePlanCommand,
|
|
801
894
|
suggestUcodeModels,
|
|
802
895
|
suggestUcodeThinkingLevels: require("./modelCommand").suggestUcodeThinkingLevels,
|
|
803
|
-
};
|
|
896
|
+
};
|
package/src/code/tools/bash.js
CHANGED
|
@@ -1,21 +1,44 @@
|
|
|
1
|
-
const { spawnSync } = require("child_process");
|
|
1
|
+
const { spawn, spawnSync } = require("child_process");
|
|
2
2
|
const { normalizeWorkspaceRoot } = require("./common");
|
|
3
3
|
|
|
4
4
|
const MAX_TIMEOUT_MS = 600000;
|
|
5
|
+
const MAX_BUFFER_BYTES = 2 * 1024 * 1024;
|
|
6
|
+
|
|
7
|
+
function normalizeBashInput(input = {}, options = {}) {
|
|
8
|
+
const command = String(input.command || "").trim();
|
|
9
|
+
const workspaceRoot = normalizeWorkspaceRoot(options.workspaceRoot, options.cwd);
|
|
10
|
+
const timeoutMs = Number.isFinite(input.timeoutMs)
|
|
11
|
+
? Math.min(MAX_TIMEOUT_MS, Math.max(100, Math.floor(input.timeoutMs)))
|
|
12
|
+
: 60000;
|
|
13
|
+
return { command, workspaceRoot, timeoutMs };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function terminateChild(child, signal = "SIGTERM") {
|
|
17
|
+
if (!child) return;
|
|
18
|
+
if (process.platform !== "win32" && child.pid) {
|
|
19
|
+
try {
|
|
20
|
+
process.kill(-child.pid, signal);
|
|
21
|
+
return;
|
|
22
|
+
} catch {
|
|
23
|
+
// The process group may already have exited; fall back to the child.
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
child.kill(signal);
|
|
28
|
+
} catch {
|
|
29
|
+
// ignore a child that already exited
|
|
30
|
+
}
|
|
31
|
+
}
|
|
5
32
|
|
|
6
33
|
function runBashTool(input = {}, options = {}) {
|
|
7
34
|
try {
|
|
8
|
-
const command =
|
|
35
|
+
const { command, workspaceRoot, timeoutMs } = normalizeBashInput(input, options);
|
|
9
36
|
if (!command) {
|
|
10
37
|
return {
|
|
11
38
|
ok: false,
|
|
12
39
|
error: "command is required",
|
|
13
40
|
};
|
|
14
41
|
}
|
|
15
|
-
const workspaceRoot = normalizeWorkspaceRoot(options.workspaceRoot, options.cwd);
|
|
16
|
-
const timeoutMs = Number.isFinite(input.timeoutMs)
|
|
17
|
-
? Math.min(MAX_TIMEOUT_MS, Math.max(100, Math.floor(input.timeoutMs)))
|
|
18
|
-
: 60000;
|
|
19
42
|
const result = spawnSync(command, {
|
|
20
43
|
cwd: workspaceRoot,
|
|
21
44
|
shell: true,
|
|
@@ -65,6 +88,136 @@ function runBashTool(input = {}, options = {}) {
|
|
|
65
88
|
}
|
|
66
89
|
}
|
|
67
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Async bash execution for the native agent loop. Unlike spawnSync this path
|
|
93
|
+
* can observe an AbortSignal while a command is running and terminate the
|
|
94
|
+
* whole shell process group instead of waiting for the command's timeout.
|
|
95
|
+
*/
|
|
96
|
+
function runBashToolAsync(input = {}, options = {}) {
|
|
97
|
+
let command;
|
|
98
|
+
let workspaceRoot;
|
|
99
|
+
let timeoutMs;
|
|
100
|
+
try {
|
|
101
|
+
({ command, workspaceRoot, timeoutMs } = normalizeBashInput(input, options));
|
|
102
|
+
} catch (err) {
|
|
103
|
+
return Promise.resolve({
|
|
104
|
+
ok: false,
|
|
105
|
+
error: err && err.message ? err.message : "bash failed",
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const signal = options && options.signal;
|
|
109
|
+
if (!command) {
|
|
110
|
+
return Promise.resolve({ ok: false, error: "command is required" });
|
|
111
|
+
}
|
|
112
|
+
if (signal && signal.aborted) {
|
|
113
|
+
return Promise.resolve({
|
|
114
|
+
ok: false,
|
|
115
|
+
cancelled: true,
|
|
116
|
+
code: "cancelled",
|
|
117
|
+
error: "CLI cancelled",
|
|
118
|
+
workspaceRoot,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return new Promise((resolve) => {
|
|
123
|
+
let settled = false;
|
|
124
|
+
let timedOut = false;
|
|
125
|
+
let cancelled = false;
|
|
126
|
+
let overflow = false;
|
|
127
|
+
let timer = null;
|
|
128
|
+
let killTimer = null;
|
|
129
|
+
let stdout = "";
|
|
130
|
+
let stderr = "";
|
|
131
|
+
const finish = (result) => {
|
|
132
|
+
if (settled) return;
|
|
133
|
+
settled = true;
|
|
134
|
+
if (timer) clearTimeout(timer);
|
|
135
|
+
if (killTimer) clearTimeout(killTimer);
|
|
136
|
+
if (signal && typeof signal.removeEventListener === "function") {
|
|
137
|
+
signal.removeEventListener("abort", onAbort);
|
|
138
|
+
}
|
|
139
|
+
resolve({
|
|
140
|
+
workspaceRoot,
|
|
141
|
+
stdout,
|
|
142
|
+
stderr,
|
|
143
|
+
...result,
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const kill = (reason) => {
|
|
147
|
+
if (settled) return;
|
|
148
|
+
if (reason === "timeout") timedOut = true;
|
|
149
|
+
if (reason === "cancelled") cancelled = true;
|
|
150
|
+
terminateChild(child, "SIGTERM");
|
|
151
|
+
killTimer = setTimeout(() => terminateChild(child, "SIGKILL"), 250);
|
|
152
|
+
if (typeof killTimer.unref === "function") killTimer.unref();
|
|
153
|
+
};
|
|
154
|
+
const onAbort = () => kill("cancelled");
|
|
155
|
+
let child;
|
|
156
|
+
try {
|
|
157
|
+
child = spawn(command, {
|
|
158
|
+
cwd: workspaceRoot,
|
|
159
|
+
shell: true,
|
|
160
|
+
detached: process.platform !== "win32",
|
|
161
|
+
windowsHide: true,
|
|
162
|
+
});
|
|
163
|
+
} catch (err) {
|
|
164
|
+
finish({
|
|
165
|
+
ok: false,
|
|
166
|
+
code: -1,
|
|
167
|
+
signal: "",
|
|
168
|
+
error: err && err.message ? err.message : "bash failed",
|
|
169
|
+
});
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const collect = (target, chunk) => {
|
|
174
|
+
const text = Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk || "");
|
|
175
|
+
if (target === "stdout") stdout += text;
|
|
176
|
+
else stderr += text;
|
|
177
|
+
if (Buffer.byteLength(stdout, "utf8") + Buffer.byteLength(stderr, "utf8") > MAX_BUFFER_BYTES) {
|
|
178
|
+
overflow = true;
|
|
179
|
+
kill("overflow");
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
child.stdout.on("data", (chunk) => collect("stdout", chunk));
|
|
183
|
+
child.stderr.on("data", (chunk) => collect("stderr", chunk));
|
|
184
|
+
child.once("error", (err) => {
|
|
185
|
+
finish({
|
|
186
|
+
ok: false,
|
|
187
|
+
code: -1,
|
|
188
|
+
signal: "",
|
|
189
|
+
cancelled,
|
|
190
|
+
error: err && err.message ? err.message : "bash failed",
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
child.once("close", (code, signalName) => {
|
|
194
|
+
if (cancelled) {
|
|
195
|
+
finish({ ok: false, cancelled: true, code: "cancelled", signal: signalName || "SIGTERM", error: "CLI cancelled" });
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (timedOut) {
|
|
199
|
+
finish({ ok: false, timedOut: true, code: -1, signal: signalName || "SIGTERM", error: `command timed out after ${timeoutMs}ms` });
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (overflow) {
|
|
203
|
+
finish({ ok: false, code: -1, signal: signalName || "SIGTERM", error: "command output exceeded 2 MB" });
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (typeof code !== "number") {
|
|
207
|
+
finish({ ok: false, code: -1, signal: signalName || "", error: `command killed by signal ${signalName || "unknown"}` });
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
finish({ ok: code === 0, code, signal: signalName || "", error: code === 0 ? "" : `command exited with ${code}` });
|
|
211
|
+
});
|
|
212
|
+
timer = setTimeout(() => kill("timeout"), timeoutMs);
|
|
213
|
+
if (typeof timer.unref === "function") timer.unref();
|
|
214
|
+
if (signal && typeof signal.addEventListener === "function") {
|
|
215
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
68
220
|
module.exports = {
|
|
69
221
|
runBashTool,
|
|
222
|
+
runBashToolAsync,
|
|
70
223
|
};
|
|
@@ -28,6 +28,7 @@ const fmt = require("../ui/format");
|
|
|
28
28
|
* @param {(state: object, opts: object) => Promise<object>} [ports.runUbus]
|
|
29
29
|
* @param {(msg: string) => void} [ports.setBusyStatus]
|
|
30
30
|
* @param {() => void} [ports.clearBusyStatus]
|
|
31
|
+
* @param {(action: string) => Promise<object>|object} [ports.onQueueCommand]
|
|
31
32
|
* @param {string[]} [ports.bannerLines]
|
|
32
33
|
* @returns {Promise<{ handled: boolean, waiting?: boolean }>}
|
|
33
34
|
*/
|
|
@@ -87,6 +88,18 @@ async function dispatchUcodeSlashCommand(result, ports = {}) {
|
|
|
87
88
|
return { handled: true };
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
case "queue": {
|
|
92
|
+
if (typeof ports.onQueueCommand !== "function") {
|
|
93
|
+
appendLog("Error: queue control unavailable", "error");
|
|
94
|
+
return { handled: true };
|
|
95
|
+
}
|
|
96
|
+
const outcome = await ports.onQueueCommand(result.action || "status");
|
|
97
|
+
if (outcome && outcome.output) {
|
|
98
|
+
appendLog(outcome.output, outcome.ok === false ? "error" : "system");
|
|
99
|
+
}
|
|
100
|
+
return { handled: true, queue: outcome || null };
|
|
101
|
+
}
|
|
102
|
+
|
|
90
103
|
case "model": {
|
|
91
104
|
const applied = await applyUcodeModelCommand(state, result, { workspaceRoot });
|
|
92
105
|
appendLog(applied.output || "", applied.ok ? "system" : "error");
|
package/src/config.js
CHANGED
|
@@ -23,12 +23,14 @@ const SETTINGS_MODEL_DEFAULTS = Object.freeze({
|
|
|
23
23
|
// kimi reads its model from its own config.toml (default_model); ufoo
|
|
24
24
|
// never injects -m/--model, so keep the placeholder empty like agy.
|
|
25
25
|
kimi: "",
|
|
26
|
+
"grok-build": "grok-4.6",
|
|
26
27
|
}),
|
|
27
28
|
router: Object.freeze({
|
|
28
29
|
codex: "gpt-5.3-codex-spark",
|
|
29
30
|
claude: "sonnet-4.7",
|
|
30
31
|
agy: "",
|
|
31
32
|
kimi: "",
|
|
33
|
+
"grok-build": "grok-4.6",
|
|
32
34
|
}),
|
|
33
35
|
});
|
|
34
36
|
|
|
@@ -80,6 +82,7 @@ function normalizeAgentProvider(value) {
|
|
|
80
82
|
if (value === "claude-cli") return "claude-cli";
|
|
81
83
|
if (value === "agy-cli" || value === "agy" || value === "antigravity") return "agy-cli";
|
|
82
84
|
if (value === "kimi-cli" || value === "kimi") return "kimi-cli";
|
|
85
|
+
if (value === "grok-cli" || value === "grok" || value === "grok-build" || value === "xai") return "grok-cli";
|
|
83
86
|
return "codex-cli";
|
|
84
87
|
}
|
|
85
88
|
|
|
@@ -88,6 +91,9 @@ function providerKey(value = "") {
|
|
|
88
91
|
if (text === "claude" || text === "claude-cli" || text === "claude-code" || text === "anthropic") return "claude";
|
|
89
92
|
if (text === "agy" || text === "agy-cli" || text === "antigravity") return "agy";
|
|
90
93
|
if (text === "kimi" || text === "kimi-cli" || text === "kimi-code") return "kimi";
|
|
94
|
+
if (text === "grok" || text === "grok-cli" || text === "grok-build" || text === "grok-shell" || text === "xai") {
|
|
95
|
+
return "grok-build";
|
|
96
|
+
}
|
|
91
97
|
return "codex";
|
|
92
98
|
}
|
|
93
99
|
|
|
@@ -462,13 +462,13 @@ class Injector {
|
|
|
462
462
|
|
|
463
463
|
// 确定注入命令:
|
|
464
464
|
// - codex: 裸 "ubus"(codex 没有 slash-command 命名空间)
|
|
465
|
-
// - agy: 裸 "ubus"
|
|
465
|
+
// - agy/grok: 裸 "ubus"(它们的 `/` 是自己的 slash-command 命名空间,
|
|
466
466
|
// "/ubus" 会被识别为 unknown slash command 而不是 prompt)
|
|
467
467
|
// - claude-code 及其他: "/ubus"
|
|
468
468
|
const command = commandOverride
|
|
469
469
|
? String(commandOverride)
|
|
470
470
|
: (
|
|
471
|
-
subscriber.startsWith("codex:") || subscriber.startsWith("agy:")
|
|
471
|
+
subscriber.startsWith("codex:") || subscriber.startsWith("agy:") || subscriber.startsWith("grok:")
|
|
472
472
|
? "ubus"
|
|
473
473
|
: "/ubus"
|
|
474
474
|
);
|
|
@@ -88,7 +88,7 @@ function isAgentPidAlive(pid) {
|
|
|
88
88
|
if (!isPidAlive(pid)) return false;
|
|
89
89
|
const cmd = getPidCommand(pid);
|
|
90
90
|
if (!cmd) return true;
|
|
91
|
-
return /(claude|codex|node|pi-mono|ufoo|ucode)/i.test(cmd);
|
|
91
|
+
return /(claude|codex|agy|grok|kimi|node|pi-mono|ufoo|ucode)/i.test(cmd);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -364,6 +364,9 @@ function normalizeAgentTypeAlias(value = "") {
|
|
|
364
364
|
if (!text) return "";
|
|
365
365
|
if (text === "codex") return "codex";
|
|
366
366
|
if (text === "claude" || text === "claude-code") return "claude-code";
|
|
367
|
+
if (text === "agy") return "agy";
|
|
368
|
+
if (text === "grok" || text === "ugrok" || text === "grok-build" || text === "xai") return "grok";
|
|
369
|
+
if (text === "kimi" || text === "ukimi" || text === "kimi-cli" || text === "kimi-code") return "kimi";
|
|
367
370
|
if (text === "ufoo" || text === "ucode" || text === "ufoo-code") return "ufoo-code";
|
|
368
371
|
return text;
|
|
369
372
|
}
|
|
@@ -21,7 +21,7 @@ const ROUTING_PATTERNS = [
|
|
|
21
21
|
/\bassign (?:this|it|that)\b/i,
|
|
22
22
|
/\bforward (?:this|it|that)\b/i,
|
|
23
23
|
/\bshould (?:i|we) ask\b/i,
|
|
24
|
-
/\bnew (?:codex|claude|ucode)\b/i,
|
|
24
|
+
/\bnew (?:codex|claude|agy|grok|kimi|ucode)\b/i,
|
|
25
25
|
/交给谁/,
|
|
26
26
|
/继续给/,
|
|
27
27
|
/发送(?:这个|它|这条|这个任务)?给/,
|
|
@@ -29,7 +29,7 @@ const ROUTING_PATTERNS = [
|
|
|
29
29
|
/发给/,
|
|
30
30
|
/转给/,
|
|
31
31
|
/应该找谁/,
|
|
32
|
-
/需要新开.*(?:codex|claude|ucode)/i,
|
|
32
|
+
/需要新开.*(?:codex|claude|agy|grok|kimi|ucode)/i,
|
|
33
33
|
];
|
|
34
34
|
|
|
35
35
|
const NON_ROUTING_PATTERNS = [
|
|
@@ -34,6 +34,7 @@ function normalizeLaunchAgentForNickname(agent = "") {
|
|
|
34
34
|
const raw = asTrimmedString(agent).toLowerCase();
|
|
35
35
|
if (raw === "claude" || raw === "claude-code" || raw === "uclaude") return "claude";
|
|
36
36
|
if (raw === "codex" || raw === "ucodex") return "codex";
|
|
37
|
+
if (raw === "grok" || raw === "ugrok" || raw === "grok-build" || raw === "xai") return "grok";
|
|
37
38
|
if (raw === "ufoo" || raw === "ucode" || raw === "ufoo-code") return "ucode";
|
|
38
39
|
return "";
|
|
39
40
|
}
|
|
@@ -57,7 +58,7 @@ function extractRequestedLaunchNickname(prompt = "") {
|
|
|
57
58
|
const value = nicknameCapturePattern();
|
|
58
59
|
const patterns = [
|
|
59
60
|
new RegExp(`(?:launch|start|create|spawn|open|new|启动|新建|创建|拉起)[\\s\\S]{0,80}(?:named|name|nickname|叫做|叫|名为|昵称|取名|为)\\s*${value}`, "i"),
|
|
60
|
-
new RegExp(`(?:named|name|nickname|叫做|叫|名为|昵称|取名)\\s*${value}[\\s\\S]{0,80}(?:agent|worker|codex|claude|ucode|ufoo|代理|智能体)`, "i"),
|
|
61
|
+
new RegExp(`(?:named|name|nickname|叫做|叫|名为|昵称|取名)\\s*${value}[\\s\\S]{0,80}(?:agent|worker|codex|claude|agy|grok|kimi|ucode|ufoo|代理|智能体)`, "i"),
|
|
61
62
|
];
|
|
62
63
|
for (const re of patterns) {
|
|
63
64
|
const nickname = pickNicknameCapture(text.match(re));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const ALLOWED_AGENT_TYPES = new Set(["auto", "codex", "claude", "ucode", "agy", "kimi"]);
|
|
3
|
+
const ALLOWED_AGENT_TYPES = new Set(["auto", "codex", "claude", "ucode", "agy", "grok", "kimi"]);
|
|
4
4
|
const { resolvePromptProfileReference } = require("./promptProfiles");
|
|
5
5
|
|
|
6
6
|
function isPlainObject(value) {
|
|
@@ -8,6 +8,7 @@ function resolveSoloAgentType(config = {}, requestedAgent = "") {
|
|
|
8
8
|
const requested = asTrimmedString(requestedAgent).toLowerCase();
|
|
9
9
|
if (requested === "claude" || requested === "uclaude" || requested === "claude-code") return "claude";
|
|
10
10
|
if (requested === "codex" || requested === "ucodex" || requested === "openai") return "codex";
|
|
11
|
+
if (requested === "grok" || requested === "ugrok" || requested === "grok-build" || requested === "xai") return "grok";
|
|
11
12
|
if (requested === "ucode" || requested === "ufoo" || requested === "ufoo-code") return "ucode";
|
|
12
13
|
|
|
13
14
|
const provider = asTrimmedString(config && config.agentProvider).toLowerCase();
|
|
@@ -76,6 +76,7 @@ function normalizeBusAgentType(agentType = "") {
|
|
|
76
76
|
if (value === "codex") return "codex";
|
|
77
77
|
if (value === "claude" || value === "claude-code") return "claude-code";
|
|
78
78
|
if (value === "agy" || value === "antigravity") return "agy";
|
|
79
|
+
if (value === "grok" || value === "ugrok" || value === "grok-build" || value === "xai") return "grok";
|
|
79
80
|
if (value === "kimi" || value === "kimi-cli" || value === "kimi-code") return "kimi";
|
|
80
81
|
if (value === "ufoo" || value === "ucode" || value === "ufoo-code") return "ufoo-code";
|
|
81
82
|
return value;
|
|
@@ -86,6 +87,7 @@ function normalizeLaunchAgent(agent = "") {
|
|
|
86
87
|
if (value === "codex") return "codex";
|
|
87
88
|
if (value === "claude" || value === "claude-code") return "claude";
|
|
88
89
|
if (value === "agy" || value === "antigravity") return "agy";
|
|
90
|
+
if (value === "grok" || value === "ugrok" || value === "grok-build" || value === "xai") return "grok";
|
|
89
91
|
if (value === "kimi" || value === "kimi-cli" || value === "kimi-code") return "kimi";
|
|
90
92
|
if (value === "ufoo" || value === "ucode" || value === "ufoo-code") return "ufoo";
|
|
91
93
|
return "";
|
|
@@ -1836,7 +1838,7 @@ function startDaemon({
|
|
|
1836
1838
|
socket.write(
|
|
1837
1839
|
`${JSON.stringify({
|
|
1838
1840
|
type: IPC_RESPONSE_TYPES.ERROR,
|
|
1839
|
-
error: "launch_agent requires agent=codex|claude|agy|ucode",
|
|
1841
|
+
error: "launch_agent requires agent=codex|claude|agy|grok|kimi|ucode",
|
|
1840
1842
|
})}
|
|
1841
1843
|
`,
|
|
1842
1844
|
);
|
|
@@ -1876,9 +1878,9 @@ function startDaemon({
|
|
|
1876
1878
|
: null,
|
|
1877
1879
|
};
|
|
1878
1880
|
let soloLaunchBootstrap = null;
|
|
1879
|
-
if (requestedProfile && (normalizedAgent === "ufoo" || normalizedAgent === "claude" || normalizedAgent === "codex" || normalizedAgent === "agy" || normalizedAgent === "kimi")) {
|
|
1880
|
-
const agentTypeMap = { ufoo: "ufoo-code", claude: "claude-code", codex: "codex", agy: "agy", kimi: "kimi" };
|
|
1881
|
-
const defaultNickMap = { ufoo: "ucode", claude: "claude", codex: "codex", agy: "agy", kimi: "kimi" };
|
|
1881
|
+
if (requestedProfile && (normalizedAgent === "ufoo" || normalizedAgent === "claude" || normalizedAgent === "codex" || normalizedAgent === "agy" || normalizedAgent === "grok" || normalizedAgent === "kimi")) {
|
|
1882
|
+
const agentTypeMap = { ufoo: "ufoo-code", claude: "claude-code", codex: "codex", agy: "agy", grok: "grok", kimi: "kimi" };
|
|
1883
|
+
const defaultNickMap = { ufoo: "ucode", claude: "claude", codex: "codex", agy: "agy", grok: "grok", kimi: "kimi" };
|
|
1882
1884
|
const agentTypeForBootstrap = agentTypeMap[normalizedAgent];
|
|
1883
1885
|
const soloNickname = explicitNickname || defaultNickMap[normalizedAgent];
|
|
1884
1886
|
const profileResult = resolveSoloPromptProfile(projectRoot, requestedProfile);
|
|
@@ -1929,6 +1931,12 @@ function startDaemon({
|
|
|
1929
1931
|
...(Array.isArray(op.extra_args) ? op.extra_args : []),
|
|
1930
1932
|
"-i", built.promptText,
|
|
1931
1933
|
];
|
|
1934
|
+
} else if (normalizedAgent === "grok") {
|
|
1935
|
+
// grok: bootstrap via --rules.
|
|
1936
|
+
op.extra_args = [
|
|
1937
|
+
...(Array.isArray(op.extra_args) ? op.extra_args : []),
|
|
1938
|
+
"--rules", built.promptText,
|
|
1939
|
+
];
|
|
1932
1940
|
} else if (normalizedAgent === "kimi") {
|
|
1933
1941
|
// kimi: no initial-prompt flag — deliver the bootstrap through
|
|
1934
1942
|
// the launcher's post-launch PTY injection instead.
|
|
@@ -22,6 +22,9 @@ function normalizeAutoNicknamePrefix(agentType = "") {
|
|
|
22
22
|
const normalized = asTrimmedString(agentType).toLowerCase();
|
|
23
23
|
if (normalized === "claude" || normalized === "claude-code") return "claude";
|
|
24
24
|
if (normalized === "codex") return "codex";
|
|
25
|
+
if (normalized === "agy") return "agy";
|
|
26
|
+
if (normalized === "grok") return "grok";
|
|
27
|
+
if (normalized === "kimi" || normalized === "kimi-cli" || normalized === "kimi-code") return "kimi";
|
|
25
28
|
if (normalized === "ufoo" || normalized === "ucode" || normalized === "ufoo-code") return "ucode";
|
|
26
29
|
return "";
|
|
27
30
|
}
|
|
@@ -47,7 +50,7 @@ function isAutoGeneratedNickname(nickname = "", agentType = "") {
|
|
|
47
50
|
|
|
48
51
|
const nicknamePrefix = match[1];
|
|
49
52
|
const suffix = match[2];
|
|
50
|
-
const knownPrefixes = new Set(["claude", "codex", "ucode"]);
|
|
53
|
+
const knownPrefixes = new Set(["claude", "codex", "agy", "grok", "kimi", "ucode"]);
|
|
51
54
|
const agentPrefix = normalizeAutoNicknamePrefix(agentType);
|
|
52
55
|
if (agentPrefix) knownPrefixes.add(agentPrefix);
|
|
53
56
|
if (!knownPrefixes.has(nicknamePrefix)) return false;
|
|
@@ -22,6 +22,7 @@ function normalizeLaunchAgent(agent = "") {
|
|
|
22
22
|
if (value === "codex") return "codex";
|
|
23
23
|
if (value === "claude" || value === "claude-code") return "claude";
|
|
24
24
|
if (value === "agy" || value === "antigravity") return "agy";
|
|
25
|
+
if (value === "grok" || value === "ugrok" || value === "grok-build" || value === "xai") return "grok";
|
|
25
26
|
if (value === "kimi" || value === "kimi-cli" || value === "kimi-code") return "kimi";
|
|
26
27
|
if (value === "ufoo" || value === "ucode" || value === "ufoo-code") return "ufoo";
|
|
27
28
|
return "";
|
|
@@ -31,6 +32,7 @@ function toBusAgentType(agent = "") {
|
|
|
31
32
|
if (agent === "codex") return "codex";
|
|
32
33
|
if (agent === "claude") return "claude-code";
|
|
33
34
|
if (agent === "agy") return "agy";
|
|
35
|
+
if (agent === "grok") return "grok";
|
|
34
36
|
if (agent === "kimi") return "kimi";
|
|
35
37
|
if (agent === "ufoo") return "ufoo-code";
|
|
36
38
|
return "";
|
|
@@ -40,6 +42,7 @@ function toTerminalBinary(agent = "") {
|
|
|
40
42
|
if (agent === "codex") return "ucodex";
|
|
41
43
|
if (agent === "claude") return "uclaude";
|
|
42
44
|
if (agent === "agy") return "uagy";
|
|
45
|
+
if (agent === "grok") return "ugrok";
|
|
43
46
|
if (agent === "kimi") return "ukimi";
|
|
44
47
|
if (agent === "ufoo") return "ucode";
|
|
45
48
|
return "";
|
|
@@ -49,6 +52,7 @@ function toTmuxBinary(agent = "") {
|
|
|
49
52
|
if (agent === "codex") return "ucodex";
|
|
50
53
|
if (agent === "claude") return "uclaude";
|
|
51
54
|
if (agent === "agy") return "uagy";
|
|
55
|
+
if (agent === "grok") return "ugrok";
|
|
52
56
|
if (agent === "kimi") return "ukimi";
|
|
53
57
|
if (agent === "ufoo") return "ucode";
|
|
54
58
|
return "";
|
|
@@ -1110,7 +1114,7 @@ async function launchAgent(projectRoot, agent, count = 1, nickname = "", process
|
|
|
1110
1114
|
normalizedAgent,
|
|
1111
1115
|
nick,
|
|
1112
1116
|
processManager,
|
|
1113
|
-
|
|
1117
|
+
extraArgs,
|
|
1114
1118
|
extraEnvPrefix,
|
|
1115
1119
|
launchScope,
|
|
1116
1120
|
terminalApp
|
|
@@ -1124,6 +1128,7 @@ async function launchAgent(projectRoot, agent, count = 1, nickname = "", process
|
|
|
1124
1128
|
function normalizeAgentType(agentType) {
|
|
1125
1129
|
if (agentType === "claude-code") return "claude";
|
|
1126
1130
|
if (agentType === "codex") return "codex";
|
|
1131
|
+
if (agentType === "grok") return "grok";
|
|
1127
1132
|
if (agentType === "ufoo-code") return "ufoo";
|
|
1128
1133
|
return agentType;
|
|
1129
1134
|
}
|
|
@@ -1135,6 +1140,7 @@ function buildResumeArgs(agent, sessionId) {
|
|
|
1135
1140
|
// Agy resumes by conversation UUID; bin/uagy.js de-duplicates if the same
|
|
1136
1141
|
// flag is already injected via provider_session_id readback.
|
|
1137
1142
|
if (agent === "agy") return [`--conversation=${sessionId}`];
|
|
1143
|
+
if (agent === "grok") return ["--resume", sessionId];
|
|
1138
1144
|
// kimi resumes a session by id via `-S, --session <id>`.
|
|
1139
1145
|
if (agent === "kimi") return ["--session", sessionId];
|
|
1140
1146
|
return [];
|
|
@@ -1189,7 +1195,7 @@ function collectRecoverableAgents(projectRoot, target = "") {
|
|
|
1189
1195
|
continue;
|
|
1190
1196
|
}
|
|
1191
1197
|
const agent = normalizeAgentType(meta.agent_type);
|
|
1192
|
-
if (agent !== "codex" && agent !== "claude" && agent !== "agy" && agent !== "kimi") {
|
|
1198
|
+
if (agent !== "codex" && agent !== "claude" && agent !== "agy" && agent !== "grok" && agent !== "kimi") {
|
|
1193
1199
|
skipped.push({ id, reason: "unsupported agent type" });
|
|
1194
1200
|
continue;
|
|
1195
1201
|
}
|