u-foo 3.0.29 → 3.0.32
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/notifier.js +25 -3
- 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/deliveryQueue.js +30 -9
- package/src/coordination/bus/inject.js +2 -2
- package/src/coordination/bus/message.js +1 -1
- 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/deliveryScheduler.js +53 -7
- 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
|
@@ -166,7 +166,24 @@ class DeliveryScheduler {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
readPendingEvents(queue) {
|
|
170
|
+
try {
|
|
171
|
+
return queue && typeof queue.readPending === "function"
|
|
172
|
+
? queue.readPending().filter(Boolean)
|
|
173
|
+
: [];
|
|
174
|
+
} catch {
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
eventNeedsIdleGate(event) {
|
|
180
|
+
if (!event) return true;
|
|
181
|
+
const envelope = normalizeQueueEnvelope(event);
|
|
182
|
+
const delivery = envelope.delivery || {};
|
|
183
|
+
return delivery.mode === "inject" && delivery.gate === "idle";
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
shouldDeliver(subscriber, options = {}) {
|
|
170
187
|
const { meta } = this.getAgentMeta(subscriber);
|
|
171
188
|
if (!meta || meta.status === "inactive") {
|
|
172
189
|
return { ok: false, reason: "missing_or_inactive" };
|
|
@@ -179,6 +196,9 @@ class DeliveryScheduler {
|
|
|
179
196
|
if (!adapter.capabilities.supportsNotifierInjector) {
|
|
180
197
|
return { ok: false, reason: launchMode ? "unsupported_launch_mode" : "missing_launch_mode" };
|
|
181
198
|
}
|
|
199
|
+
if (options.requireIdle === false) {
|
|
200
|
+
return { ok: true, reason: "deliverable" };
|
|
201
|
+
}
|
|
182
202
|
const activityState = asState(meta.activity_state);
|
|
183
203
|
if (!isDeliverableActivityState(activityState)) {
|
|
184
204
|
if (activityState === "waiting_input" || activityState === "blocked") {
|
|
@@ -225,7 +245,9 @@ class DeliveryScheduler {
|
|
|
225
245
|
this.forceWarned.delete(trackingKey);
|
|
226
246
|
this.forceRetries.delete(trackingKey);
|
|
227
247
|
}
|
|
228
|
-
|
|
248
|
+
if (!event || !tracked || tracked.key === key) {
|
|
249
|
+
this.pendingSeen.delete(subscriber);
|
|
250
|
+
}
|
|
229
251
|
}
|
|
230
252
|
|
|
231
253
|
clearTrackedKey(subscriber, key) {
|
|
@@ -292,9 +314,12 @@ class DeliveryScheduler {
|
|
|
292
314
|
}
|
|
293
315
|
|
|
294
316
|
resolveGate(subscriber, queue, eventOverride = null) {
|
|
295
|
-
const
|
|
317
|
+
const event = eventOverride || this.readPendingEvents(queue)[0] || null;
|
|
318
|
+
const gate = this.shouldDeliver(subscriber, {
|
|
319
|
+
requireIdle: this.eventNeedsIdleGate(event),
|
|
320
|
+
});
|
|
296
321
|
if (gate.ok || !gate.activityBlocked) return gate;
|
|
297
|
-
const pending = this.resolvePendingWait(subscriber, queue,
|
|
322
|
+
const pending = this.resolvePendingWait(subscriber, queue, event);
|
|
298
323
|
if (!pending || pending.waitedMs < this.forceDeliveryAfterMs) return gate;
|
|
299
324
|
const retry = this.forceRetries.get(`${subscriber}:${pending.key}`);
|
|
300
325
|
if (retry && this.now() < retry.nextAtMs) {
|
|
@@ -323,7 +348,25 @@ class DeliveryScheduler {
|
|
|
323
348
|
this.locks.set(subscriber, { sinceMs: this.now(), lastWarnAtMs: 0 });
|
|
324
349
|
try {
|
|
325
350
|
const queue = this.queueFactory(subscriber);
|
|
326
|
-
const
|
|
351
|
+
const transportGate = this.shouldDeliver(subscriber, { requireIdle: false });
|
|
352
|
+
if (!transportGate.ok) {
|
|
353
|
+
this.noteDeferral(subscriber, transportGate.reason);
|
|
354
|
+
return { ok: true, delivered: 0, deferred: true, reason: transportGate.reason };
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const pendingEvents = this.readPendingEvents(queue);
|
|
358
|
+
let selectedEvent = pendingEvents[0] || null;
|
|
359
|
+
let gate = this.resolveGate(subscriber, queue, selectedEvent);
|
|
360
|
+
if (!gate.ok) {
|
|
361
|
+
// A queued item must not head-of-line block a later immediate message.
|
|
362
|
+
// This also lets explicit immediate delivery ignore stale/incorrect
|
|
363
|
+
// activity snapshots, notably Grok Build's current working state.
|
|
364
|
+
const bypassEvent = pendingEvents.find((event) => !this.eventNeedsIdleGate(event));
|
|
365
|
+
if (bypassEvent && bypassEvent !== selectedEvent) {
|
|
366
|
+
selectedEvent = bypassEvent;
|
|
367
|
+
gate = this.resolveGate(subscriber, queue, selectedEvent);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
327
370
|
if (!gate.ok) {
|
|
328
371
|
this.noteDeferral(subscriber, gate.reason);
|
|
329
372
|
return { ok: true, delivered: 0, deferred: true, reason: gate.reason };
|
|
@@ -335,9 +378,12 @@ class DeliveryScheduler {
|
|
|
335
378
|
}
|
|
336
379
|
this.clearDeferral(subscriber);
|
|
337
380
|
|
|
338
|
-
const
|
|
381
|
+
const selectedKey = selectedEvent ? this.pendingEventKey(selectedEvent) : "";
|
|
382
|
+
const claim = queue.claimNext(selectedKey
|
|
383
|
+
? (event) => this.pendingEventKey(event) === selectedKey
|
|
384
|
+
: undefined);
|
|
339
385
|
if (!claim) {
|
|
340
|
-
this.clearPendingTracking(subscriber);
|
|
386
|
+
if (pendingEvents.length === 0) this.clearPendingTracking(subscriber);
|
|
341
387
|
return { ok: true, delivered: 0, reason: "empty" };
|
|
342
388
|
}
|
|
343
389
|
|
|
@@ -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
|
}
|
package/src/ui/rustUcodeHost.js
CHANGED
|
@@ -266,7 +266,12 @@ async function runUcodeRust(props = {}) {
|
|
|
266
266
|
let backgroundSeq = 0;
|
|
267
267
|
let requestExit = false;
|
|
268
268
|
const MARKDOWN_LOG_KINDS = new Set(["assistant", "error"]);
|
|
269
|
-
const controller = createUcodeController({
|
|
269
|
+
const controller = createUcodeController({
|
|
270
|
+
projectRoot: workspaceRoot,
|
|
271
|
+
ports: {
|
|
272
|
+
onQueueChange: (snapshot) => publish("task.queue", snapshot),
|
|
273
|
+
},
|
|
274
|
+
});
|
|
270
275
|
|
|
271
276
|
function publish(name, payload) {
|
|
272
277
|
if (!hostRef) return;
|
|
@@ -351,6 +356,20 @@ async function runUcodeRust(props = {}) {
|
|
|
351
356
|
});
|
|
352
357
|
}
|
|
353
358
|
|
|
359
|
+
function formatQueueSnapshot(snapshot = controller.getQueueSnapshot()) {
|
|
360
|
+
const active = snapshot && snapshot.active;
|
|
361
|
+
const queued = Array.isArray(snapshot && snapshot.queued) ? snapshot.queued : [];
|
|
362
|
+
const activeText = active
|
|
363
|
+
? `active #${active.id} ${active.label || active.kind || "task"}`
|
|
364
|
+
: "active none";
|
|
365
|
+
const lines = [`Queue: ${activeText} · pending ${queued.length}`];
|
|
366
|
+
for (const task of queued.slice(0, 8)) {
|
|
367
|
+
lines.push(` ${task.position}. #${task.id} ${task.label || task.kind || "task"}`);
|
|
368
|
+
}
|
|
369
|
+
if (queued.length > 8) lines.push(` … ${queued.length - 8} more`);
|
|
370
|
+
return lines.join("\n");
|
|
371
|
+
}
|
|
372
|
+
|
|
354
373
|
function publishPlan(activityMessage = "") {
|
|
355
374
|
const payload = buildPlanSetPayload(props.state && props.state.executionState, {
|
|
356
375
|
activityMessage,
|
|
@@ -549,6 +568,7 @@ async function runUcodeRust(props = {}) {
|
|
|
549
568
|
agents: agentsSnap.agents,
|
|
550
569
|
attachment_count: pendingAttachments.length,
|
|
551
570
|
usage: String((meter && meter.label) || ""),
|
|
571
|
+
task_queue: controller.getQueueSnapshot(),
|
|
552
572
|
};
|
|
553
573
|
}
|
|
554
574
|
|
|
@@ -577,7 +597,7 @@ async function runUcodeRust(props = {}) {
|
|
|
577
597
|
}
|
|
578
598
|
}
|
|
579
599
|
|
|
580
|
-
async function resumeInteraction(answerText) {
|
|
600
|
+
async function resumeInteraction(answerText, meta = {}) {
|
|
581
601
|
return controller.runExclusive(async (abort) => {
|
|
582
602
|
const submit = typeof props.submitUserInteractionAnswer === "function"
|
|
583
603
|
? props.submitUserInteractionAnswer
|
|
@@ -621,8 +641,10 @@ async function runUcodeRust(props = {}) {
|
|
|
621
641
|
publishPlan();
|
|
622
642
|
publishUsageFromResult(result);
|
|
623
643
|
if (publishPendingInteraction()) {
|
|
644
|
+
controller.pauseQueue("waiting for reply");
|
|
624
645
|
return { ok: true, waiting: true };
|
|
625
646
|
}
|
|
647
|
+
controller.resumeQueue();
|
|
626
648
|
return { ok: true, waiting: false };
|
|
627
649
|
} catch (err) {
|
|
628
650
|
tools.flush();
|
|
@@ -635,10 +657,15 @@ async function runUcodeRust(props = {}) {
|
|
|
635
657
|
appendLog(`Error: ${err && err.message ? err.message : err}`, "error");
|
|
636
658
|
return { ok: false };
|
|
637
659
|
}
|
|
660
|
+
}, {
|
|
661
|
+
kind: "interaction",
|
|
662
|
+
label: "reply",
|
|
663
|
+
priority: meta.priority === true,
|
|
638
664
|
});
|
|
639
665
|
}
|
|
640
666
|
|
|
641
|
-
async function runNaturalLanguage(text) {
|
|
667
|
+
async function runNaturalLanguage(text, meta = {}) {
|
|
668
|
+
const label = String(meta.label || text || "prompt").trim().replace(/\s+/g, " ");
|
|
642
669
|
return controller.runExclusive(async (abort) => {
|
|
643
670
|
if (typeof props.runNaturalLanguageTask !== "function") {
|
|
644
671
|
appendLog("runNaturalLanguageTask unavailable", "error");
|
|
@@ -692,8 +719,10 @@ async function runUcodeRust(props = {}) {
|
|
|
692
719
|
publishPlan();
|
|
693
720
|
publishUsageFromResult(nlResult);
|
|
694
721
|
if (publishPendingInteraction()) {
|
|
722
|
+
controller.pauseQueue("waiting for reply");
|
|
695
723
|
return { ok: true, waiting: true };
|
|
696
724
|
}
|
|
725
|
+
controller.resumeQueue();
|
|
697
726
|
return { ok: true, waiting: false, result: nlResult };
|
|
698
727
|
} catch (err) {
|
|
699
728
|
tools.flush();
|
|
@@ -706,6 +735,9 @@ async function runUcodeRust(props = {}) {
|
|
|
706
735
|
appendLog(`Error: ${err && err.message ? err.message : err}`, "error");
|
|
707
736
|
return { ok: false };
|
|
708
737
|
}
|
|
738
|
+
}, {
|
|
739
|
+
kind: String(meta.kind || "prompt").trim() || "prompt",
|
|
740
|
+
label: label.length > 80 ? `${label.slice(0, 77)}…` : label,
|
|
709
741
|
});
|
|
710
742
|
}
|
|
711
743
|
|
|
@@ -760,7 +792,7 @@ async function runUcodeRust(props = {}) {
|
|
|
760
792
|
publish("status.set", { text: "ready", busy: false });
|
|
761
793
|
}
|
|
762
794
|
}
|
|
763
|
-
});
|
|
795
|
+
}, { kind: "bus", label: "bus messages" });
|
|
764
796
|
}
|
|
765
797
|
|
|
766
798
|
function scheduleAutoBus() {
|
|
@@ -803,11 +835,11 @@ async function runUcodeRust(props = {}) {
|
|
|
803
835
|
|
|
804
836
|
if (name === "app.exit") {
|
|
805
837
|
closing = true;
|
|
806
|
-
controller.
|
|
838
|
+
controller.stop();
|
|
807
839
|
return { ok: true };
|
|
808
840
|
}
|
|
809
841
|
if (name === "task.cancel") {
|
|
810
|
-
controller.cancelTask();
|
|
842
|
+
controller.cancelTask("user");
|
|
811
843
|
publish("status.set", { text: "cancelling…", busy: true });
|
|
812
844
|
appendLog("• Cancellation requested. Stopping the current task...", "system");
|
|
813
845
|
return { ok: true };
|
|
@@ -861,12 +893,15 @@ async function runUcodeRust(props = {}) {
|
|
|
861
893
|
if (payload.cancelled) {
|
|
862
894
|
appendLog("interaction cancelled", "system");
|
|
863
895
|
publish("interaction.clear", {});
|
|
896
|
+
controller.resumeQueue();
|
|
864
897
|
publish("status.set", { text: "ready", busy: false });
|
|
865
898
|
return { ok: true, cancelled: true };
|
|
866
899
|
}
|
|
867
900
|
publish("interaction.clear", {});
|
|
868
901
|
publish("status.set", { text: "applying reply…", busy: true });
|
|
869
|
-
const
|
|
902
|
+
const resume = resumeInteraction(String(payload.text || ""), { priority: true });
|
|
903
|
+
controller.resumeQueue();
|
|
904
|
+
const result = await resume;
|
|
870
905
|
if (!result.waiting) {
|
|
871
906
|
publish("status.set", { text: "ready", busy: false });
|
|
872
907
|
}
|
|
@@ -877,14 +912,15 @@ async function runUcodeRust(props = {}) {
|
|
|
877
912
|
const { modelText, logText, attachments } = composeSubmitText(rawText);
|
|
878
913
|
if (!modelText && attachments.length === 0) return { ok: true, empty: true };
|
|
879
914
|
clearAttachments();
|
|
880
|
-
tools.beginScope();
|
|
881
915
|
|
|
882
916
|
try {
|
|
883
917
|
const { hasPendingUserInteraction } = require("../code/context/userInteraction");
|
|
884
918
|
if (props.state && hasPendingUserInteraction(props.state.executionState)) {
|
|
885
919
|
appendLog(`› ${logText || rawText}`, "user");
|
|
886
920
|
publishStatus("applying reply…", true);
|
|
887
|
-
const
|
|
921
|
+
const resume = resumeInteraction(modelText || rawText, { priority: true });
|
|
922
|
+
controller.resumeQueue();
|
|
923
|
+
const result = await resume;
|
|
888
924
|
if (!result.waiting) publishStatus("ready", false);
|
|
889
925
|
return { ok: true, routed: "interaction" };
|
|
890
926
|
}
|
|
@@ -910,6 +946,7 @@ async function runUcodeRust(props = {}) {
|
|
|
910
946
|
parsed = null;
|
|
911
947
|
}
|
|
912
948
|
if (parsed) {
|
|
949
|
+
if (parsed.kind === "tool") tools.beginScope();
|
|
913
950
|
const dispatched = await dispatchUcodeSlashCommand(parsed, {
|
|
914
951
|
state: props.state,
|
|
915
952
|
workspaceRoot,
|
|
@@ -1004,6 +1041,42 @@ async function runUcodeRust(props = {}) {
|
|
|
1004
1041
|
});
|
|
1005
1042
|
},
|
|
1006
1043
|
onNaturalLanguage: async (task) => runNaturalLanguage(task),
|
|
1044
|
+
onQueueCommand: (action) => {
|
|
1045
|
+
const normalized = String(action || "status").trim().toLowerCase();
|
|
1046
|
+
if (normalized === "status") {
|
|
1047
|
+
return { ok: true, output: formatQueueSnapshot() };
|
|
1048
|
+
}
|
|
1049
|
+
if (normalized === "cancel") {
|
|
1050
|
+
const snapshot = controller.getQueueSnapshot();
|
|
1051
|
+
if (!snapshot.active) {
|
|
1052
|
+
return { ok: true, output: "Queue: no active task." };
|
|
1053
|
+
}
|
|
1054
|
+
controller.cancelTask("queue cancel");
|
|
1055
|
+
publishStatus("cancelling…", true);
|
|
1056
|
+
return { ok: true, output: `Cancellation requested for #${snapshot.active.id}.` };
|
|
1057
|
+
}
|
|
1058
|
+
if (normalized === "clear") {
|
|
1059
|
+
const count = controller.clearQueue();
|
|
1060
|
+
if (!controller.isBusy()) publishStatus("ready", false);
|
|
1061
|
+
return { ok: true, output: count
|
|
1062
|
+
? `Cleared ${count} pending task${count === 1 ? "" : "s"}.`
|
|
1063
|
+
: "Queue: no pending tasks." };
|
|
1064
|
+
}
|
|
1065
|
+
if (normalized === "stop") {
|
|
1066
|
+
const snapshot = controller.getQueueSnapshot();
|
|
1067
|
+
const cancelled = controller.cancelTask("queue stop");
|
|
1068
|
+
const cleared = controller.clearQueue();
|
|
1069
|
+
if (cancelled) publishStatus("cancelling…", true);
|
|
1070
|
+
else if (!controller.isBusy()) publishStatus("ready", false);
|
|
1071
|
+
return {
|
|
1072
|
+
ok: true,
|
|
1073
|
+
output: `Queue stopped: ${cancelled ? "active cancellation requested" : "no active task"}; cleared ${cleared} pending.`,
|
|
1074
|
+
active: snapshot.active,
|
|
1075
|
+
cleared,
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
return { ok: false, output: "usage: /queue [status|clear|cancel|stop]" };
|
|
1079
|
+
},
|
|
1007
1080
|
runUbus: typeof props.runUbusCommand === "function"
|
|
1008
1081
|
? (state, opts) => props.runUbusCommand(state, opts)
|
|
1009
1082
|
: null,
|
|
@@ -1027,7 +1100,10 @@ async function runUcodeRust(props = {}) {
|
|
|
1027
1100
|
} finally {
|
|
1028
1101
|
try {
|
|
1029
1102
|
const { hasPendingUserInteraction } = require("../code/context/userInteraction");
|
|
1030
|
-
if (
|
|
1103
|
+
if (
|
|
1104
|
+
!(props.state && hasPendingUserInteraction(props.state.executionState))
|
|
1105
|
+
&& !controller.isBusy()
|
|
1106
|
+
) {
|
|
1031
1107
|
publishStatus("ready", false);
|
|
1032
1108
|
}
|
|
1033
1109
|
} catch {
|