u-foo 4.0.5 → 4.0.10
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 +224 -19
- package/README.zh-CN.md +3 -3
- package/bin/ucode.js +10 -2
- package/bin/ufoo.js +3 -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/{OBSERVABILITY.md → docs/OBSERVABILITY.md} +3 -3
- package/docs/README.md +27 -0
- package/extensions/ufoo-browser/LICENSE +152 -0
- package/extensions/ufoo-browser/NOTICE +10 -0
- package/extensions/ufoo-browser/README.md +30 -0
- package/extensions/ufoo-browser/background.js +409 -0
- package/extensions/ufoo-browser/icons/icon-128.png +0 -0
- package/extensions/ufoo-browser/icons/icon-16.png +0 -0
- package/extensions/ufoo-browser/icons/icon-256.png +0 -0
- package/extensions/ufoo-browser/icons/icon-32.png +0 -0
- package/extensions/ufoo-browser/icons/icon-48.png +0 -0
- package/extensions/ufoo-browser/icons/logo.png +0 -0
- package/extensions/ufoo-browser/icons/toolbar-16.png +0 -0
- package/extensions/ufoo-browser/icons/toolbar-32.png +0 -0
- package/extensions/ufoo-browser/icons/toolbar-logo.png +0 -0
- package/extensions/ufoo-browser/manifest.json +30 -0
- package/extensions/ufoo-browser/popup.css +71 -0
- package/extensions/ufoo-browser/popup.html +44 -0
- package/extensions/ufoo-browser/popup.js +153 -0
- package/package.json +5 -3
- package/scripts/postinstall.js +6 -0
- package/src/agents/capabilities/browser/index.js +49 -0
- package/src/agents/capabilities/coding/backgroundHooks.js +94 -0
- package/src/agents/capabilities/coding/index.js +30 -1
- package/src/agents/capabilities/index.js +5 -2
- package/src/agents/capabilities/planning/index.js +44 -5
- package/src/agents/capabilities/turnRecall/index.js +341 -0
- package/src/agents/controller/controllerToolExecutor.js +2 -2
- package/src/agents/internal/internalRunner.js +30 -8
- package/src/agents/internal/taskControl.js +107 -0
- package/src/agents/profiles/coding.js +1 -1
- package/src/agents/profiles/main.js +1 -1
- package/src/agents/prompts/mainAgent.js +1 -0
- package/src/agents/prompts/native/toolDescriptions/bash.js +7 -1
- package/src/agents/providers/claudeSessionFiles.js +1 -1
- package/src/agents/providers/codexThreadProvider.js +6 -1
- package/src/agents/providers/credentials/agy.js +171 -0
- package/src/agents/providers/directAuthStatus.js +20 -2
- package/src/agents/providers/modelsCatalog.js +26 -5
- package/src/agents/providers/nativeTransport.js +36 -20
- package/src/agents/providers/providerId.js +17 -0
- package/src/agents/providers/runtimeConfig.js +26 -19
- package/src/agents/providers/transports/antigravityTransport.js +242 -0
- package/src/agents/providers/transports/index.js +1 -0
- package/src/agents/providers/transports/openaiChatTransport.js +3 -2
- package/src/agents/providers/transports/openaiResponsesTransport.js +2 -1
- package/src/agents/providers/transports/responsesProtocol.js +119 -18
- package/src/agents/providers/transports/transportContract.js +1 -0
- package/src/agents/providers/upstreamRuntime.js +3 -1
- package/src/agents/runtime/context/contextBudget.js +1 -19
- package/src/agents/runtime/context/contextWindow.js +5 -0
- package/src/agents/runtime/context/replayHistory.js +16 -10
- package/src/agents/runtime/context/runtimeStore.js +0 -2
- package/src/agents/runtime/context/sessionJournal.js +1 -1
- package/src/agents/runtime/context/slidingWindowManager.js +792 -0
- package/src/agents/runtime/context/topicSelector.js +338 -0
- package/src/agents/runtime/context/turnAnalyzer.js +767 -0
- package/src/agents/runtime/context/turnIndexStore.js +515 -0
- package/src/agents/runtime/core/agentLoop.js +95 -32
- package/src/agents/runtime/core/executionBudget.js +2 -1
- package/src/agents/runtime/core/toolErrorGuard.js +39 -0
- package/src/agents/runtime/createAgentRuntime.js +80 -7
- package/src/agents/runtime/index.js +5 -0
- package/src/agents/runtime/protocol/materialize.js +1 -1
- package/src/agents/runtime/tasks/hooks.js +137 -0
- package/src/app/chat/ChatController.js +8 -4
- package/src/app/chat/daemonMessageRouter.js +3 -1
- package/src/app/chat/inputSubmitHandler.js +2 -2
- package/src/app/chat/transport.js +1 -1
- package/src/app/cli/browserCommands.js +340 -0
- package/src/app/cli/features/doctor.js +21 -0
- package/src/app/cli/metricsCommands.js +1 -1
- package/src/app/cli/run.js +80 -1
- package/src/app/cli/setupCommands.js +200 -0
- package/src/code/UcodeController.js +31 -1
- package/src/code/agent.js +41 -7
- package/src/code/busConsumer.js +13 -12
- package/src/code/commands.js +0 -1
- package/src/code/context/assembler.js +11 -88
- package/src/code/context/planGraphService.js +83 -9
- package/src/code/context/planProjection.js +10 -2
- package/src/code/context/reducers.js +172 -4
- package/src/code/context/stateCommit.js +0 -32
- package/src/code/context/transcript.js +7 -4
- package/src/code/internalThread.js +9 -1
- package/src/code/launcher/ucode.js +4 -2
- package/src/code/nativeRunner.js +221 -10
- package/src/code/repl.js +27 -1
- package/src/code/runtime/agentWakeup.js +20 -3
- package/src/code/runtime/backgroundWakeHost.js +45 -0
- package/src/code/runtime/taskFocusContext.js +7 -0
- package/src/code/runtime/taskLoop.js +24 -1
- package/src/code/sessionStore.js +14 -10
- package/src/code/taskDecomposer.js +13 -7
- package/src/code/tools/backgroundProcess.js +23 -0
- package/src/code/tools/bash.js +764 -12
- package/src/code/tools/executor.js +12 -4
- package/src/code/tools/specs.js +60 -3
- package/src/code/tools/taskRun.js +38 -0
- package/src/config.js +92 -6
- package/src/coordination/bus/subscriber.js +1 -1
- package/src/coordination/history/agentPerformance.js +18 -18
- package/src/coordination/history/agentTrace.js +7 -3
- package/src/coordination/state/workspaceAccess.js +3 -1
- package/src/orchestration/groups/modelConfig.js +66 -0
- package/src/orchestration/groups/validateTemplate.js +2 -0
- package/src/runtime/browser/broker.js +1027 -0
- package/src/runtime/browser/brokerClient.js +108 -0
- package/src/runtime/browser/componentInstaller.js +275 -0
- package/src/runtime/browser/installState.js +329 -0
- package/src/runtime/browser/manifest.js +145 -0
- package/src/runtime/browser/native-host-runner.js +198 -0
- package/src/runtime/browser/nativeHost.js +213 -0
- package/src/runtime/browser/nativeMessagingProtocol.js +50 -0
- package/src/runtime/browser/paths.js +134 -0
- package/src/runtime/browser/playwrightSession.js +614 -0
- package/src/runtime/daemon/agentHost.js +175 -30
- package/src/runtime/daemon/busBridge.js +2 -1
- package/src/runtime/daemon/globalDaemon.js +20 -0
- package/src/runtime/daemon/groupOrchestrator.js +20 -1
- package/src/runtime/daemon/index.js +5 -4
- package/src/runtime/daemon/ops.js +14 -8
- package/src/tools/handlers/listAgents.js +1 -1
- package/src/tools/handlers/readBusSummary.js +1 -1
- package/src/tools/handlers/routeAgent.js +122 -5
- package/src/tools/schemaFixtures.js +1 -1
- package/src/ui/agentSurface.js +26 -3
- package/src/ui/format/index.js +34 -2
- package/src/ui/rustChatHost.js +22 -7
- package/src/ui/rustMultiSession.js +14 -2
- package/src/ui/rustUcodeHost.js +246 -77
- package/src/ui/ucodeAgentSession.js +88 -0
- package/templates/groups/build-lane.json +57 -3
- package/templates/groups/build-ultra.json +114 -6
- package/templates/groups/design-system.json +57 -3
- package/templates/groups/product-discovery.json +57 -3
- package/templates/groups/ui-plan-review.json +57 -3
- package/templates/groups/ui-polish.json +57 -3
- package/templates/groups/verify-ship.json +57 -3
- package/src/agents/runtime/context/checkpointStore.js +0 -52
- package/src/agents/runtime/context/compaction.js +0 -171
package/src/app/cli/run.js
CHANGED
|
@@ -1702,7 +1702,7 @@ async function runCli(argv) {
|
|
|
1702
1702
|
}
|
|
1703
1703
|
});
|
|
1704
1704
|
|
|
1705
|
-
program.command("trace").description("Inspect agent task, tool, report, queue and
|
|
1705
|
+
program.command("trace").description("Inspect agent task, tool, report, queue and context events")
|
|
1706
1706
|
.argument("[task-id]", "Delegated task ID or parent taskRunId")
|
|
1707
1707
|
.option("--task <id>", "Filter task")
|
|
1708
1708
|
.option("--agent <id>", "Filter subscriber ID or nickname")
|
|
@@ -1731,6 +1731,39 @@ async function runCli(argv) {
|
|
|
1731
1731
|
.option("--json", "Export a performance report")
|
|
1732
1732
|
.action((taskId, opts) => require("./metricsCommands").runMetricsCommand(taskId, opts));
|
|
1733
1733
|
|
|
1734
|
+
program
|
|
1735
|
+
.command("setup")
|
|
1736
|
+
.description("Interactive installation wizard for optional ufoo components (including ufoo Browser)")
|
|
1737
|
+
.option("--browser <choice>", "Explicitly choose browser setup (install|skip)")
|
|
1738
|
+
.option("--dev", "Register developer unpacked extension mode")
|
|
1739
|
+
.option("--source <path>", "Local component source directory")
|
|
1740
|
+
.option("--tarball <path>", "Component tarball path or URL")
|
|
1741
|
+
.option("--sha256 <digest>", "Expected sha256 digest for component tarball")
|
|
1742
|
+
.option("--no-open", "Do not open Chrome Web Store automatically")
|
|
1743
|
+
.option("-y, --yes", "Non-interactive defaults (does not auto-enable browser)")
|
|
1744
|
+
.option("--json", "Output JSON")
|
|
1745
|
+
.action(async (opts) => {
|
|
1746
|
+
const res = await require("./setupCommands").runSetupCommand(opts);
|
|
1747
|
+
if (res && res.exitCode) process.exitCode = res.exitCode;
|
|
1748
|
+
});
|
|
1749
|
+
|
|
1750
|
+
program
|
|
1751
|
+
.command("browser")
|
|
1752
|
+
.description("Manage optional ufoo Browser extension and runtime (install|status|doctor|enable|disable|update|uninstall)")
|
|
1753
|
+
.argument("[subcmd]", "Subcommand (install|status|doctor|enable|disable|update|uninstall)", "status")
|
|
1754
|
+
.argument("[subargs...]", "Subcommand arguments")
|
|
1755
|
+
.option("--dev", "Use unpacked developer extension mode")
|
|
1756
|
+
.option("--source <path>", "Local component source directory")
|
|
1757
|
+
.option("--tarball <path>", "Component tarball path or URL")
|
|
1758
|
+
.option("--sha256 <digest>", "Expected sha256 digest for component tarball")
|
|
1759
|
+
.option("--no-open", "Do not open Chrome Web Store automatically")
|
|
1760
|
+
.option("--no-repair", "Do not repair native host paths during doctor")
|
|
1761
|
+
.option("--json", "Output JSON")
|
|
1762
|
+
.action(async (subcmd, subargs, opts) => {
|
|
1763
|
+
const code = await require("./browserCommands").runBrowserCommand(subcmd, subargs, opts);
|
|
1764
|
+
if (code) process.exitCode = code;
|
|
1765
|
+
});
|
|
1766
|
+
|
|
1734
1767
|
const history = program.command("history").description("Agent input history timeline");
|
|
1735
1768
|
history
|
|
1736
1769
|
.command("build")
|
|
@@ -1793,6 +1826,8 @@ async function runCli(argv) {
|
|
|
1793
1826
|
console.log("");
|
|
1794
1827
|
console.log("Usage:");
|
|
1795
1828
|
console.log(" ufoo doctor");
|
|
1829
|
+
console.log(" ufoo setup [--browser=install|skip] [--dev] [--json]");
|
|
1830
|
+
console.log(" ufoo browser <install|status|doctor|enable|disable|update|uninstall> [--dev] [--json]");
|
|
1796
1831
|
console.log(" ufoo status");
|
|
1797
1832
|
console.log(" ufoo daemon --start|--stop|--status");
|
|
1798
1833
|
console.log(" ufoo -g");
|
|
@@ -2587,6 +2622,50 @@ async function runCli(argv) {
|
|
|
2587
2622
|
return;
|
|
2588
2623
|
}
|
|
2589
2624
|
|
|
2625
|
+
if (cmd === "setup") {
|
|
2626
|
+
const readFlagValue = (flag) => {
|
|
2627
|
+
const prefix = `${flag}=`;
|
|
2628
|
+
const inline = rest.find((arg) => arg.startsWith(prefix));
|
|
2629
|
+
if (inline) return inline.slice(prefix.length);
|
|
2630
|
+
const idx = rest.indexOf(flag);
|
|
2631
|
+
return idx !== -1 && rest[idx + 1] && !rest[idx + 1].startsWith("-") ? rest[idx + 1] : "";
|
|
2632
|
+
};
|
|
2633
|
+
const res = await require("./setupCommands").runSetupCommand({
|
|
2634
|
+
browser: readFlagValue("--browser"),
|
|
2635
|
+
dev: rest.includes("--dev"),
|
|
2636
|
+
source: readFlagValue("--source"),
|
|
2637
|
+
tarball: readFlagValue("--tarball"),
|
|
2638
|
+
sha256: readFlagValue("--sha256"),
|
|
2639
|
+
noOpen: rest.includes("--no-open"),
|
|
2640
|
+
yes: rest.includes("--yes") || rest.includes("-y"),
|
|
2641
|
+
json: rest.includes("--json"),
|
|
2642
|
+
});
|
|
2643
|
+
if (res && res.exitCode) process.exitCode = res.exitCode;
|
|
2644
|
+
return;
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
if (cmd === "browser") {
|
|
2648
|
+
const sub = rest[0] || "status";
|
|
2649
|
+
const readFlagValue = (flag) => {
|
|
2650
|
+
const prefix = `${flag}=`;
|
|
2651
|
+
const inline = rest.find((arg) => arg.startsWith(prefix));
|
|
2652
|
+
if (inline) return inline.slice(prefix.length);
|
|
2653
|
+
const idx = rest.indexOf(flag);
|
|
2654
|
+
return idx !== -1 && rest[idx + 1] && !rest[idx + 1].startsWith("-") ? rest[idx + 1] : "";
|
|
2655
|
+
};
|
|
2656
|
+
const code = await require("./browserCommands").runBrowserCommand(sub, rest.slice(1), {
|
|
2657
|
+
dev: rest.includes("--dev"),
|
|
2658
|
+
source: readFlagValue("--source"),
|
|
2659
|
+
tarball: readFlagValue("--tarball"),
|
|
2660
|
+
sha256: readFlagValue("--sha256"),
|
|
2661
|
+
noOpen: rest.includes("--no-open"),
|
|
2662
|
+
noRepair: rest.includes("--no-repair"),
|
|
2663
|
+
json: rest.includes("--json"),
|
|
2664
|
+
});
|
|
2665
|
+
if (code) process.exitCode = code;
|
|
2666
|
+
return;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2590
2669
|
help();
|
|
2591
2670
|
process.exitCode = 1;
|
|
2592
2671
|
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const readline = require("readline");
|
|
6
|
+
const lockfile = require("proper-lockfile");
|
|
7
|
+
const { loadGlobalBrowserConfig, saveGlobalBrowserConfig } = require("../../config");
|
|
8
|
+
const { setupLockPath } = require("../../runtime/browser/paths");
|
|
9
|
+
const {
|
|
10
|
+
runBrowserInstall,
|
|
11
|
+
formatStatusLines,
|
|
12
|
+
} = require("./browserCommands");
|
|
13
|
+
|
|
14
|
+
const FIRST_RUN_SKIP_COMMANDS = new Set([
|
|
15
|
+
"setup",
|
|
16
|
+
"browser",
|
|
17
|
+
"daemon",
|
|
18
|
+
"mcp",
|
|
19
|
+
"agent-runner",
|
|
20
|
+
"doctor",
|
|
21
|
+
"status",
|
|
22
|
+
"project",
|
|
23
|
+
"init",
|
|
24
|
+
"skills",
|
|
25
|
+
"group",
|
|
26
|
+
"solo",
|
|
27
|
+
"online",
|
|
28
|
+
"bus",
|
|
29
|
+
"ctx",
|
|
30
|
+
"history",
|
|
31
|
+
"trace",
|
|
32
|
+
"metrics",
|
|
33
|
+
"report",
|
|
34
|
+
"recover",
|
|
35
|
+
"ucode",
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
function renderChoicePromptLines() {
|
|
39
|
+
return [
|
|
40
|
+
"",
|
|
41
|
+
"选择可选组件",
|
|
42
|
+
"",
|
|
43
|
+
"[ ] ufoo Browser",
|
|
44
|
+
" 让 ufoo / ucode 操作日常 Chrome 中已登录的网页。",
|
|
45
|
+
" 启用后自动连接本机 ufoo,无需填写 key 或逐次确认连接。",
|
|
46
|
+
"",
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function askYesNo(promptText, { stdin = process.stdin, stdout = process.stdout } = {}) {
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
const rl = readline.createInterface({ input: stdin, output: stdout, terminal: Boolean(stdout?.isTTY) });
|
|
53
|
+
rl.question(promptText, (answer) => {
|
|
54
|
+
rl.close();
|
|
55
|
+
const norm = String(answer || "").trim().toLowerCase();
|
|
56
|
+
resolve(norm === "y" || norm === "yes" || norm === "install" || norm === "1");
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function parseBrowserFlag(value = "") {
|
|
62
|
+
const raw = String(value || "").trim().toLowerCase();
|
|
63
|
+
if (!raw) return "";
|
|
64
|
+
if (raw === "install" || raw === "enable" || raw === "yes") return "install";
|
|
65
|
+
if (raw === "skip" || raw === "no" || raw === "disable") return "skip";
|
|
66
|
+
throw new Error(`Invalid --browser value "${value}". Expected "install" or "skip".`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function runSetupCommand(opts = {}, {
|
|
70
|
+
env = process.env,
|
|
71
|
+
stdin = process.stdin,
|
|
72
|
+
stdout = process.stdout,
|
|
73
|
+
write = (line) => console.log(line),
|
|
74
|
+
writeError = (line) => console.error(line),
|
|
75
|
+
promptYesNo = askYesNo,
|
|
76
|
+
installImpl = runBrowserInstall,
|
|
77
|
+
} = {}) {
|
|
78
|
+
const outputJson = opts.json === true;
|
|
79
|
+
let choice = "";
|
|
80
|
+
try {
|
|
81
|
+
choice = parseBrowserFlag(opts.browser || "");
|
|
82
|
+
} catch (err) {
|
|
83
|
+
const msg = err.message || String(err);
|
|
84
|
+
if (outputJson) write(JSON.stringify({ ok: false, error: msg }, null, 2));
|
|
85
|
+
else writeError(msg);
|
|
86
|
+
return { ok: false, exitCode: 1, error: msg };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const interactive = Boolean(stdin?.isTTY && stdout?.isTTY && !env.CI && !outputJson);
|
|
90
|
+
if (!choice) {
|
|
91
|
+
if (!interactive) {
|
|
92
|
+
// Non-interactive setup (including --yes) defaults to skipping browser install.
|
|
93
|
+
choice = "skip";
|
|
94
|
+
} else {
|
|
95
|
+
for (const line of renderChoicePromptLines()) write(line);
|
|
96
|
+
const accepted = await promptYesNo("是否安装并启用 ufoo Browser?[y/N]: ", { stdin, stdout });
|
|
97
|
+
choice = accepted ? "install" : "skip";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (choice === "skip") {
|
|
102
|
+
const config = saveGlobalBrowserConfig({
|
|
103
|
+
setupChoice: "skip",
|
|
104
|
+
enabled: false,
|
|
105
|
+
});
|
|
106
|
+
const payload = { ok: true, choice: "skip", state: "not_installed", config };
|
|
107
|
+
if (outputJson) write(JSON.stringify(payload, null, 2));
|
|
108
|
+
else write("已跳过 ufoo Browser,完成 ufoo 基础配置。稍后可随时运行 `ufoo browser install`。");
|
|
109
|
+
return { ...payload, exitCode: 0 };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const installRes = await installImpl({
|
|
113
|
+
dev: opts.dev === true,
|
|
114
|
+
sourceDir: opts.source || "",
|
|
115
|
+
tarball: opts.tarball || "",
|
|
116
|
+
sha256: opts.sha256 || "",
|
|
117
|
+
openStore: opts.noOpen !== true && interactive,
|
|
118
|
+
env,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (outputJson) {
|
|
122
|
+
write(JSON.stringify({ choice: "install", ...installRes }, null, 2));
|
|
123
|
+
} else if (!installRes.ok) {
|
|
124
|
+
writeError(installRes.error || "ufoo Browser setup failed");
|
|
125
|
+
} else {
|
|
126
|
+
for (const line of formatStatusLines(installRes.status)) write(line);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
choice: "install",
|
|
130
|
+
...installRes,
|
|
131
|
+
exitCode: installRes.ok ? 0 : 1,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function shouldOfferFirstRunSetup({ surface = "ufoo", argv = [], env = process.env, stdin = process.stdin, stdout = process.stdout } = {}) {
|
|
136
|
+
if (env.UFOO_SKIP_FIRST_RUN_SETUP === "1") return false;
|
|
137
|
+
if (env.CI) return false;
|
|
138
|
+
if (!stdin?.isTTY || !stdout?.isTTY) return false;
|
|
139
|
+
if (env.UFOO_DAEMON_CHILD === "1" || env.UFOO_INTERNAL_AGENT === "1" || env.UFOO_BROWSER_BROKER_CHILD === "1") return false;
|
|
140
|
+
if (env.UFOO_SUBSCRIBER_ID) return false;
|
|
141
|
+
|
|
142
|
+
const args = Array.isArray(argv) ? argv.map((v) => String(v || "").trim()) : [];
|
|
143
|
+
if (args.some((arg) => ["--help", "-h", "--version", "-V", "--json", "-p", "--print"].includes(arg))) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
if (surface === "ufoo") {
|
|
147
|
+
const nonFlag = args.find((arg) => arg && !arg.startsWith("-"));
|
|
148
|
+
if (nonFlag && FIRST_RUN_SKIP_COMMANDS.has(nonFlag) && nonFlag !== "chat") return false;
|
|
149
|
+
}
|
|
150
|
+
const cfg = loadGlobalBrowserConfig();
|
|
151
|
+
return cfg.setupChoice === "unset";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* On the very first interactive launch of `ufoo` or `ucode`, ask once whether to install ufoo Browser.
|
|
156
|
+
* Protected by a user-level setup lock so concurrent first launches only prompt once.
|
|
157
|
+
*/
|
|
158
|
+
async function maybeRunFirstTimeSetup(options = {}) {
|
|
159
|
+
if (!shouldOfferFirstRunSetup(options)) return { prompted: false };
|
|
160
|
+
const env = options.env || process.env;
|
|
161
|
+
const lockFile = setupLockPath(env);
|
|
162
|
+
fs.mkdirSync(path.dirname(lockFile), { recursive: true, mode: 0o700 });
|
|
163
|
+
let release;
|
|
164
|
+
try {
|
|
165
|
+
release = await lockfile.lock(lockFile, {
|
|
166
|
+
realpath: false,
|
|
167
|
+
stale: 300000,
|
|
168
|
+
update: 10000,
|
|
169
|
+
retries: { retries: 3, minTimeout: 100, maxTimeout: 300 },
|
|
170
|
+
});
|
|
171
|
+
} catch (error) {
|
|
172
|
+
if (error && error.code === "ELOCKED") return { prompted: false, locked: true };
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
if (loadGlobalBrowserConfig().setupChoice !== "unset") {
|
|
177
|
+
return { prompted: false };
|
|
178
|
+
}
|
|
179
|
+
const result = await runSetupCommand({}, {
|
|
180
|
+
env,
|
|
181
|
+
stdin: options.stdin || process.stdin,
|
|
182
|
+
stdout: options.stdout || process.stdout,
|
|
183
|
+
write: options.write,
|
|
184
|
+
writeError: options.writeError,
|
|
185
|
+
promptYesNo: options.promptYesNo,
|
|
186
|
+
installImpl: options.installImpl,
|
|
187
|
+
});
|
|
188
|
+
return { prompted: true, result };
|
|
189
|
+
} finally {
|
|
190
|
+
await release().catch(() => {});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
module.exports = {
|
|
195
|
+
renderChoicePromptLines,
|
|
196
|
+
parseBrowserFlag,
|
|
197
|
+
runSetupCommand,
|
|
198
|
+
shouldOfferFirstRunSetup,
|
|
199
|
+
maybeRunFirstTimeSetup,
|
|
200
|
+
};
|
|
@@ -140,7 +140,7 @@ function createUcodeController({
|
|
|
140
140
|
if (activeTask) {
|
|
141
141
|
activeTask.cancelRequested = true;
|
|
142
142
|
try {
|
|
143
|
-
activeTask.controller.abort();
|
|
143
|
+
activeTask.controller.abort("runtime_closed");
|
|
144
144
|
} catch {
|
|
145
145
|
// ignore
|
|
146
146
|
}
|
|
@@ -223,6 +223,7 @@ function createUcodeController({
|
|
|
223
223
|
id,
|
|
224
224
|
kind: String(taskMeta.kind || "task").trim() || "task",
|
|
225
225
|
label: taskLabel(taskMeta, id),
|
|
226
|
+
promptText: String(taskMeta.promptText || ""),
|
|
226
227
|
enqueuedAt: Date.now(),
|
|
227
228
|
startedAt: 0,
|
|
228
229
|
status: "queued",
|
|
@@ -243,6 +244,34 @@ function createUcodeController({
|
|
|
243
244
|
return promise;
|
|
244
245
|
}
|
|
245
246
|
|
|
247
|
+
function drainQueuedPrompts() {
|
|
248
|
+
if (pendingTasks.length === 0) return [];
|
|
249
|
+
const drained = [];
|
|
250
|
+
const remaining = [];
|
|
251
|
+
for (const task of pendingTasks) {
|
|
252
|
+
if (task.kind === "prompt" && (task.promptText || task.label)) {
|
|
253
|
+
task.status = "injected";
|
|
254
|
+
if (!task.settled) {
|
|
255
|
+
task.settled = true;
|
|
256
|
+
task.resolve({ ok: true, injected: true });
|
|
257
|
+
}
|
|
258
|
+
drained.push({
|
|
259
|
+
id: task.id,
|
|
260
|
+
label: task.label,
|
|
261
|
+
text: String(task.promptText || task.label || ""),
|
|
262
|
+
});
|
|
263
|
+
} else {
|
|
264
|
+
remaining.push(task);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
pendingTasks.length = 0;
|
|
268
|
+
pendingTasks.push(...remaining);
|
|
269
|
+
if (drained.length > 0) {
|
|
270
|
+
notifyQueueChange("injected");
|
|
271
|
+
}
|
|
272
|
+
return drained;
|
|
273
|
+
}
|
|
274
|
+
|
|
246
275
|
return {
|
|
247
276
|
projectRoot,
|
|
248
277
|
view,
|
|
@@ -255,6 +284,7 @@ function createUcodeController({
|
|
|
255
284
|
cancelTask,
|
|
256
285
|
runExclusive,
|
|
257
286
|
clearQueue: () => clearPending("cleared"),
|
|
287
|
+
drainQueuedPrompts,
|
|
258
288
|
pauseQueue,
|
|
259
289
|
resumeQueue,
|
|
260
290
|
getQueueSnapshot: () => queueSnapshot("snapshot"),
|
package/src/code/agent.js
CHANGED
|
@@ -6,6 +6,7 @@ const { runNativeAgentTask } = require("./nativeRunner");
|
|
|
6
6
|
const { resolveTaskTimeoutMs: resolveNlTaskTimeoutMs, DEFAULT_TASK_TIMEOUT_MS: DEFAULT_NL_TASK_TIMEOUT_MS } = require("../agents/runtime/core/executionBudget");
|
|
7
7
|
const { runDecomposedTask } = require("./taskDecomposer");
|
|
8
8
|
const { loadConfig, defaultAgentModelForProvider, sameModelProvider } = require("../config");
|
|
9
|
+
const { resolveRuntimeConfig } = require("../agents/providers/runtimeConfig");
|
|
9
10
|
const {
|
|
10
11
|
resolveSessionId,
|
|
11
12
|
normalizeSessionId,
|
|
@@ -82,8 +83,7 @@ function ensureContextSessionState(state = {}) {
|
|
|
82
83
|
}
|
|
83
84
|
require("./context/planProjection").ensurePlanUiState(state.executionState);
|
|
84
85
|
if (!state.contextPolicy || typeof state.contextPolicy !== "object") {
|
|
85
|
-
|
|
86
|
-
state.contextPolicy = defaultContextPolicy();
|
|
86
|
+
state.contextPolicy = {};
|
|
87
87
|
}
|
|
88
88
|
if (!Number.isFinite(state.toolCallsSinceCommit)) state.toolCallsSinceCommit = 0;
|
|
89
89
|
ensureStateEpoch(state);
|
|
@@ -257,6 +257,10 @@ function resolveUcodeProviderModel({
|
|
|
257
257
|
|| ""
|
|
258
258
|
).trim();
|
|
259
259
|
const resolvedProvider = resolvePlannerProvider(explicitProvider || fallbackProviderFromAgent);
|
|
260
|
+
if (resolvedProvider === "agy") {
|
|
261
|
+
const runtime = resolveRuntimeConfig({ workspaceRoot: root, provider: resolvedProvider, model });
|
|
262
|
+
return { provider: runtime.provider, model: runtime.model };
|
|
263
|
+
}
|
|
260
264
|
const configuredModel = sameModelProvider(config.ucodeProvider || config.agentProvider, resolvedProvider)
|
|
261
265
|
? (config.ucodeModel || config.agentModel)
|
|
262
266
|
: "";
|
|
@@ -283,6 +287,7 @@ function resolvePlannerProvider(value = "") {
|
|
|
283
287
|
if (!text) return "";
|
|
284
288
|
if (text === "claude" || text === "claude-cli" || text === "claude-code" || text === "anthropic") return "anthropic";
|
|
285
289
|
if (text === "codex" || text === "codex-cli" || text === "codex-code") return "codex";
|
|
290
|
+
if (text === "agy" || text === "agy-cli" || text === "antigravity") return "agy";
|
|
286
291
|
if (text === "grok" || text === "grok-cli" || text === "grok-build" || text === "grok-shell" || text === "grok-api") return "grok-build";
|
|
287
292
|
if (text === "xai") return "xai";
|
|
288
293
|
if (text === "openai") return "openai";
|
|
@@ -374,7 +379,7 @@ function normalizeToolLogEvent(event = {}) {
|
|
|
374
379
|
if (!event || typeof event !== "object") return null;
|
|
375
380
|
const tool = String(event.tool || event.name || "").trim().toLowerCase();
|
|
376
381
|
if (!tool) return null;
|
|
377
|
-
if (tool !== "read" && tool !== "write" && tool !== "edit" && tool !== "bash" && tool !== "artifact_read") return null;
|
|
382
|
+
if (tool !== "read" && tool !== "write" && tool !== "edit" && tool !== "bash" && tool !== "artifact_read" && tool !== "recall_turn") return null;
|
|
378
383
|
const phase = String(event.phase || "update").trim().toLowerCase();
|
|
379
384
|
const normalizedPhase = phase === "error" ? "error" : (phase === "start" ? "start" : "");
|
|
380
385
|
if (!normalizedPhase) return null;
|
|
@@ -565,7 +570,7 @@ async function runNaturalLanguageTask(task = "", state = {}, options = {}) {
|
|
|
565
570
|
}
|
|
566
571
|
|
|
567
572
|
ensureTaskContract(state, taskText);
|
|
568
|
-
if (!shouldFrameAsUserReminder(state.executionState)) {
|
|
573
|
+
if (options.runtimeContext?.requestKind !== "system_wake" && !shouldFrameAsUserReminder(state.executionState)) {
|
|
569
574
|
state.taskContract = patchTaskContractFromUserMessage(state.taskContract, taskText);
|
|
570
575
|
}
|
|
571
576
|
|
|
@@ -660,6 +665,7 @@ async function runNaturalLanguageTask(task = "", state = {}, options = {}) {
|
|
|
660
665
|
toolEventsThisAttempt = 0;
|
|
661
666
|
const historyMessages = assembled.messages;
|
|
662
667
|
return runNativeAgentImpl({
|
|
668
|
+
runtimeHooks: state.runtimeHooks,
|
|
663
669
|
workspaceRoot,
|
|
664
670
|
provider,
|
|
665
671
|
model,
|
|
@@ -675,9 +681,14 @@ async function runNaturalLanguageTask(task = "", state = {}, options = {}) {
|
|
|
675
681
|
onPhase,
|
|
676
682
|
onContextUsage: applyContextMeter,
|
|
677
683
|
executionState: state.executionState || null,
|
|
678
|
-
onArtifactPersisted: (persisted) => recordToolCallInSession(
|
|
684
|
+
onArtifactPersisted: (persisted) => recordToolCallInSession(
|
|
685
|
+
state,
|
|
686
|
+
persisted,
|
|
687
|
+
workspaceRoot,
|
|
688
|
+
),
|
|
679
689
|
onConversationUpdate: (update) => commitConversationOutput(state, workspaceRoot, turnId, update),
|
|
680
690
|
contextPolicy: state.contextPolicy || {},
|
|
691
|
+
logicalTurnId: turnId,
|
|
681
692
|
runtimeContext: options.runtimeContext || {},
|
|
682
693
|
onRuntimeEvent: options.onRuntimeEvent,
|
|
683
694
|
onToolEvent: (event) => {
|
|
@@ -721,6 +732,7 @@ async function runNaturalLanguageTask(task = "", state = {}, options = {}) {
|
|
|
721
732
|
if (useDecomposition) {
|
|
722
733
|
const decomposedResult = await runDecomposedTask({
|
|
723
734
|
task: effectiveTaskPrompt,
|
|
735
|
+
timeoutMs,
|
|
724
736
|
onProgress: options.onProgress,
|
|
725
737
|
onToolEvent: (event) => {
|
|
726
738
|
pushToolLog(event);
|
|
@@ -816,7 +828,7 @@ async function runNaturalLanguageTask(task = "", state = {}, options = {}) {
|
|
|
816
828
|
if (typeof state.executionState.planMode !== "boolean") {
|
|
817
829
|
state.executionState.planMode = priorPlanMode;
|
|
818
830
|
}
|
|
819
|
-
if (!state.executionState.planModeSource && priorSource) {
|
|
831
|
+
if (state.executionState.planMode && !state.executionState.planModeSource && priorSource) {
|
|
820
832
|
state.executionState.planModeSource = priorSource;
|
|
821
833
|
}
|
|
822
834
|
}
|
|
@@ -861,6 +873,10 @@ async function runNaturalLanguageTask(task = "", state = {}, options = {}) {
|
|
|
861
873
|
applyContextMeter(cliRes.contextMeter);
|
|
862
874
|
}
|
|
863
875
|
if (cliRes && cliRes.waitingUserInteraction) {
|
|
876
|
+
state.pendingLogicalTurnId = turnId;
|
|
877
|
+
state.pendingTurnHistoryOffset = Array.isArray(assembled.messages)
|
|
878
|
+
? assembled.messages.filter((m) => m && m.role !== "system").length
|
|
879
|
+
: 0;
|
|
864
880
|
return {
|
|
865
881
|
ok: true,
|
|
866
882
|
summary: resolvedSummary || "Waiting for your reply",
|
|
@@ -877,6 +893,8 @@ async function runNaturalLanguageTask(task = "", state = {}, options = {}) {
|
|
|
877
893
|
usage: cliRes.usage || null,
|
|
878
894
|
};
|
|
879
895
|
}
|
|
896
|
+
state.pendingLogicalTurnId = "";
|
|
897
|
+
state.pendingTurnHistoryOffset = null;
|
|
880
898
|
return {
|
|
881
899
|
ok: true,
|
|
882
900
|
summary: resolvedSummary,
|
|
@@ -1008,6 +1026,10 @@ function buildSessionSnapshotFromState(state = {}) {
|
|
|
1008
1026
|
contextPolicy: source.contextPolicy && typeof source.contextPolicy === "object"
|
|
1009
1027
|
? source.contextPolicy
|
|
1010
1028
|
: null,
|
|
1029
|
+
pendingLogicalTurnId: String(source.pendingLogicalTurnId || "").trim(),
|
|
1030
|
+
pendingTurnHistoryOffset: Number.isInteger(source.pendingTurnHistoryOffset)
|
|
1031
|
+
? source.pendingTurnHistoryOffset
|
|
1032
|
+
: null,
|
|
1011
1033
|
toolCallsSinceCommit: Number.isFinite(source.toolCallsSinceCommit)
|
|
1012
1034
|
? Math.max(0, Math.floor(source.toolCallsSinceCommit))
|
|
1013
1035
|
: 0,
|
|
@@ -1049,7 +1071,7 @@ function persistSessionState(state = {}) {
|
|
|
1049
1071
|
return saved;
|
|
1050
1072
|
}
|
|
1051
1073
|
|
|
1052
|
-
function resumeSessionState(state = {}, sessionId = "", workspaceRoot = process.cwd()) {
|
|
1074
|
+
function resumeSessionState(state = {}, sessionId = "", workspaceRoot = (state && state.workspaceRoot) || process.cwd()) {
|
|
1053
1075
|
const targetId = normalizeSessionId(sessionId);
|
|
1054
1076
|
if (!targetId) {
|
|
1055
1077
|
return {
|
|
@@ -1085,6 +1107,10 @@ function resumeSessionState(state = {}, sessionId = "", workspaceRoot = process.
|
|
|
1085
1107
|
state.workingSet = Array.isArray(snapshot.workingSet) ? snapshot.workingSet : [];
|
|
1086
1108
|
state.executionState = snapshot.executionState || null;
|
|
1087
1109
|
state.contextPolicy = snapshot.contextPolicy || null;
|
|
1110
|
+
state.pendingLogicalTurnId = String(snapshot.pendingLogicalTurnId || "").trim();
|
|
1111
|
+
state.pendingTurnHistoryOffset = Number.isInteger(snapshot.pendingTurnHistoryOffset)
|
|
1112
|
+
? snapshot.pendingTurnHistoryOffset
|
|
1113
|
+
: null;
|
|
1088
1114
|
state.toolCallsSinceCommit = Number.isFinite(snapshot.toolCallsSinceCommit)
|
|
1089
1115
|
? snapshot.toolCallsSinceCommit
|
|
1090
1116
|
: 0;
|
|
@@ -1191,7 +1217,9 @@ async function resumeAfterUserInteraction(answerText = "", state = {}, options =
|
|
|
1191
1217
|
}
|
|
1192
1218
|
: null;
|
|
1193
1219
|
|
|
1220
|
+
const logicalTurnId = String(state.pendingLogicalTurnId || turnId).trim();
|
|
1194
1221
|
const cliRes = await runNativeAgentTask({
|
|
1222
|
+
runtimeHooks: state.runtimeHooks,
|
|
1195
1223
|
workspaceRoot,
|
|
1196
1224
|
provider: state.provider,
|
|
1197
1225
|
model: state.model,
|
|
@@ -1211,6 +1239,8 @@ async function resumeAfterUserInteraction(answerText = "", state = {}, options =
|
|
|
1211
1239
|
maxToolCalls: state.maxToolCalls,
|
|
1212
1240
|
onStreamDelta: trackingOnDelta,
|
|
1213
1241
|
contextPolicy: state.contextPolicy || {},
|
|
1242
|
+
logicalTurnId,
|
|
1243
|
+
historyOffset: Number.isInteger(state.pendingTurnHistoryOffset) ? state.pendingTurnHistoryOffset : null,
|
|
1214
1244
|
runtimeContext: options.runtimeContext || {},
|
|
1215
1245
|
onRuntimeEvent: options.onRuntimeEvent,
|
|
1216
1246
|
onConversationUpdate: (update) => commitConversationOutput(state, workspaceRoot, turnId, update),
|
|
@@ -1228,6 +1258,10 @@ async function resumeAfterUserInteraction(answerText = "", state = {}, options =
|
|
|
1228
1258
|
resume: true,
|
|
1229
1259
|
});
|
|
1230
1260
|
|
|
1261
|
+
if (cliRes && !cliRes.waitingUserInteraction) {
|
|
1262
|
+
state.pendingLogicalTurnId = "";
|
|
1263
|
+
state.pendingTurnHistoryOffset = null;
|
|
1264
|
+
}
|
|
1231
1265
|
if (cliRes && cliRes.executionState) {
|
|
1232
1266
|
state.executionState = cliRes.executionState;
|
|
1233
1267
|
}
|
package/src/code/busConsumer.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const { execSync } = require("child_process");
|
|
4
|
-
const { createBusProgressReporter } = require("./taskDecomposer");
|
|
5
4
|
const { DeliveryQueue } = require("../coordination/bus/deliveryQueue");
|
|
6
5
|
|
|
7
6
|
function shellQuote(value = "") {
|
|
@@ -307,6 +306,14 @@ function parseBusCheckOutput(raw = "") {
|
|
|
307
306
|
.filter(Boolean);
|
|
308
307
|
}
|
|
309
308
|
|
|
309
|
+
// An intentionally silent model turn must stay silent on the bus. Terminal
|
|
310
|
+
// display fallbacks ("Done") and automatic progress ACKs otherwise wake peers.
|
|
311
|
+
function formatBusReply(result, formatNl) {
|
|
312
|
+
if (result?.ok && !result.cancelled && !String(result.summary || "").trim()
|
|
313
|
+
&& !(result.artifacts || []).length) return "";
|
|
314
|
+
return String(formatNl(result, false) || "").replace(/\s+/g, " ").trim();
|
|
315
|
+
}
|
|
316
|
+
|
|
310
317
|
async function runUbusCommand(state = {}, options = {}) {
|
|
311
318
|
const runtimeWorkspace = resolveUfooProjectRoot(String(
|
|
312
319
|
options.workspaceRoot
|
|
@@ -375,16 +382,10 @@ async function runUbusCommand(state = {}, options = {}) {
|
|
|
375
382
|
});
|
|
376
383
|
}
|
|
377
384
|
|
|
378
|
-
// Create progress reporter for this message
|
|
379
|
-
const progressReporter = createBusProgressReporter(shell, message.publisher);
|
|
380
|
-
|
|
381
385
|
try {
|
|
382
|
-
// Send initial acknowledgment
|
|
383
|
-
shell(`ufoo bus send ${shellQuote(message.publisher)} ${shellQuote("🚀 Starting task...")}`);
|
|
384
|
-
|
|
385
386
|
// eslint-disable-next-line no-await-in-loop
|
|
386
387
|
nlResult = await runNl(message.task, state, {
|
|
387
|
-
onProgress:
|
|
388
|
+
onProgress: options.onProgress,
|
|
388
389
|
signal: options.signal,
|
|
389
390
|
});
|
|
390
391
|
} catch (err) {
|
|
@@ -395,8 +396,8 @@ async function runUbusCommand(state = {}, options = {}) {
|
|
|
395
396
|
shell(`ufoo bus send ${shellQuote(message.publisher)} ${shellQuote(`❌ Error: ${errorMessage}`)}`);
|
|
396
397
|
break;
|
|
397
398
|
}
|
|
398
|
-
const reply =
|
|
399
|
-
const sendRes = shell(`ufoo bus send ${shellQuote(message.publisher)} ${shellQuote(reply.slice(0, 2000))}`);
|
|
399
|
+
const reply = formatBusReply(nlResult, formatNl);
|
|
400
|
+
const sendRes = reply ? shell(`ufoo bus send ${shellQuote(message.publisher)} ${shellQuote(reply.slice(0, 2000))}`) : { ok: true };
|
|
400
401
|
if (!sendRes.ok) {
|
|
401
402
|
sendErrors.push(`reply to ${message.publisher} failed: ${sendRes.error || "send failed"}`);
|
|
402
403
|
queue.restoreClaim(claim);
|
|
@@ -446,8 +447,8 @@ async function runUbusCommand(state = {}, options = {}) {
|
|
|
446
447
|
const nlResult = await runNl(item.task, state, {
|
|
447
448
|
signal: options.signal,
|
|
448
449
|
});
|
|
449
|
-
const reply =
|
|
450
|
-
const sendRes = shell(`ufoo bus send ${shellQuote(item.publisher)} ${shellQuote(reply.slice(0, 2000))}`);
|
|
450
|
+
const reply = formatBusReply(nlResult, formatNl);
|
|
451
|
+
const sendRes = reply ? shell(`ufoo bus send ${shellQuote(item.publisher)} ${shellQuote(reply.slice(0, 2000))}`) : { ok: true };
|
|
451
452
|
if (!sendRes.ok) {
|
|
452
453
|
sendErrors.push(`reply to ${item.publisher} failed: ${sendRes.error || "send failed"}`);
|
|
453
454
|
continue;
|
package/src/code/commands.js
CHANGED