u-foo 4.0.0 → 4.0.1
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/OBSERVABILITY.md +65 -0
- package/README.md +88 -30
- package/README.zh-CN.md +76 -26
- package/SKILLS/ufoo/SKILL.md +25 -1
- package/SKILLS/ufoo-bus/SKILL.md +25 -2
- package/bin/ufoo.js +3 -3
- 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 +6 -6
- package/src/agents/activity/activityDetector.js +1 -1
- package/src/agents/capabilities/agentManagement/service.js +40 -13
- package/src/agents/capabilities/coordination/index.js +1 -1
- package/src/agents/capabilities/taskReports/index.js +1 -1
- package/src/agents/controller/controllerToolExecutor.js +36 -20
- package/src/agents/controller/index.js +1 -6
- package/src/agents/internal/internalRunner.js +90 -56
- package/src/agents/launch/index.js +0 -1
- package/src/agents/launch/launcher.js +8 -8
- package/src/agents/launch/notifier.js +2 -2
- package/src/agents/launch/readyDetector.js +2 -2
- package/src/agents/profiles/main.js +1 -1
- package/src/agents/prompts/cooperation.js +14 -0
- package/src/agents/prompts/defaultBootstrap.js +1 -1
- package/src/agents/prompts/groupBootstrap.js +23 -7
- package/src/agents/prompts/mainAgent.js +11 -2
- package/src/agents/prompts/native/system.js +4 -1
- package/src/agents/prompts/native/ufoo.js +11 -3
- package/src/agents/prompts/promptProfiles.js +2 -0
- package/src/agents/prompts/reporting.js +16 -0
- package/src/agents/providers/claudeEventTranslator.js +3 -0
- package/src/agents/providers/claudeThreadProvider.js +3 -2
- package/src/agents/providers/clientIdentity.js +75 -0
- package/src/agents/providers/codexEventTranslator.js +23 -2
- package/src/agents/providers/codexThreadProvider.js +15 -6
- package/src/agents/providers/credentials/index.js +2 -0
- package/src/agents/providers/directAuthStatus.js +1 -1
- package/src/agents/providers/index.js +1 -1
- package/src/agents/providers/modelSettings.js +34 -0
- package/src/agents/providers/modelsCatalog.js +379 -0
- package/src/agents/providers/nativeTransport.js +50 -39
- package/src/agents/providers/runtimeConfig.js +10 -8
- package/src/agents/providers/thinkingLevels.js +10 -36
- package/src/agents/providers/transports/responsesProtocol.js +11 -6
- package/src/agents/providers/upstreamRuntime.js +135 -0
- package/src/agents/runtime/context/checkpointStore.js +38 -0
- package/src/agents/runtime/context/compaction.js +151 -0
- package/src/agents/runtime/context/contextBudget.js +93 -0
- package/src/agents/runtime/context/replayHistory.js +28 -0
- package/src/agents/runtime/context/runtimeStore.js +2 -1
- package/src/agents/runtime/core/agentLoop.js +99 -18
- package/src/agents/runtime/core/executionBudget.js +36 -0
- package/src/agents/runtime/createAgentRuntime.js +16 -4
- package/src/agents/runtime/prompts/responseLanguage.js +12 -0
- package/src/agents/runtime/protocol/runObservation.js +24 -0
- package/src/agents/runtime/protocol/traceContext.js +9 -0
- package/src/app/chat/ChatController.js +26 -53
- package/src/app/chat/agentDirectory.js +1 -16
- package/src/app/chat/bootstrap.js +1 -2
- package/src/app/chat/commandExecutor.js +93 -285
- package/src/app/chat/commands.js +32 -45
- package/src/app/chat/daemonMessageRouter.js +0 -45
- package/src/app/chat/historyStore.js +12 -48
- package/src/app/chat/inputSubmitHandler.js +7 -33
- package/src/app/chat/internalAgentLogHistory.js +19 -60
- package/src/app/chat/multiWindow/paneManager.js +10 -3
- package/src/app/chat/streamState.js +0 -4
- package/src/app/cli/features/init.js +5 -5
- package/src/app/cli/metricsCommands.js +68 -0
- package/src/app/cli/run.js +42 -3
- package/src/app/cli/traceCommands.js +36 -0
- package/src/code/agent.js +18 -13
- package/src/code/busConsumer.js +1 -3
- package/src/code/commands.js +1 -1
- package/src/code/context/assembler.js +7 -8
- package/src/code/context/stateCommit.js +2 -1
- package/src/code/internalThread.js +10 -3
- package/src/code/launcher/ucode.js +1 -1
- package/src/code/launcher/ucodeBootstrap.js +1 -1
- package/src/code/modelCommand.js +11 -35
- package/src/code/nativeRunner.js +55 -17
- package/src/code/providers/modelsCatalog.js +1 -317
- package/src/code/repl.js +2 -11
- package/src/code/sessionStore.js +3 -3
- package/src/code/taskDecomposer.js +18 -0
- package/src/code/toolBudget.js +1 -17
- package/src/config.js +22 -72
- package/src/coordination/bus/index.js +12 -3
- package/src/coordination/bus/inject.js +2 -2
- package/src/coordination/bus/message.js +15 -1
- package/src/coordination/bus/nickname.js +1 -1
- package/src/coordination/bus/subscriber.js +3 -2
- package/src/coordination/bus/utils.js +1 -1
- package/src/coordination/history/agentPerformance.js +279 -0
- package/src/coordination/history/agentTrace.js +249 -0
- package/src/coordination/state/workspaceAccess.js +1 -1
- package/src/orchestration/controller/index.js +1 -8
- package/src/orchestration/controller/launchRouting.js +1 -1
- package/src/orchestration/solo/commands.js +3 -1
- package/src/runtime/contracts/agentMode.js +11 -2
- package/src/runtime/contracts/uiProtocol.js +18 -19
- package/src/runtime/daemon/agentHost.js +57 -25
- package/src/runtime/daemon/agentRecoveryGroups.js +70 -0
- package/src/runtime/daemon/busBridge.js +1 -1
- package/src/runtime/daemon/controlPlaneService.js +1 -1
- package/src/runtime/daemon/groupOrchestrator.js +20 -5
- package/src/runtime/daemon/groupStatus.js +20 -0
- package/src/runtime/daemon/index.js +19 -44
- package/src/runtime/daemon/mcpServer.js +1 -1
- package/src/runtime/daemon/nicknameScope.js +1 -1
- package/src/runtime/daemon/ops.js +46 -23
- package/src/runtime/daemon/projectRuntimeGateway.js +2 -0
- package/src/runtime/daemon/promptRequest.js +92 -589
- package/src/runtime/daemon/status.js +5 -6
- package/src/tools/controllerSchemas.js +6 -2
- package/src/tools/handlers/tier2.js +4 -2
- package/src/tools/registry.js +4 -0
- package/src/tools/schemaFixtures.js +26 -2
- package/src/tools/tier0/readAgentMetrics.js +14 -0
- package/src/tools/tier0/readAgentTrace.js +12 -0
- package/src/ui/agentSettingsController.js +107 -0
- package/src/ui/agentSurface.js +1 -1
- package/src/ui/dashboardBridge.js +1 -1
- package/src/ui/format/banner.js +1 -4
- package/src/ui/format/index.js +14 -10
- package/src/ui/format/loopSummary.js +50 -0
- package/src/ui/format/markdownRenderer.js +3 -4
- package/src/ui/rustChatHost.js +191 -206
- package/src/ui/rustMultiSession.js +77 -36
- package/src/ui/rustUcodeHost.js +1 -1
- package/src/ui/settingsBridge.js +33 -16
- package/src/ui/toolMergeBridge.js +0 -4
- package/src/ui/uiHostServer.js +5 -8
- package/src/agents/controller/loopObservability.js +0 -200
- package/src/agents/controller/loopRuntime.js +0 -336
- package/src/agents/controller/ufooAgent.js +0 -830
- package/src/agents/launch/ptyRunner.js +0 -1135
- package/src/agents/providers/controllerJsonTransport.js +0 -28
- package/src/agents/providers/upstreamTransport.js +0 -698
- package/src/app/chat/agentBar.js +0 -135
- package/src/app/chat/agentSockets.js +0 -225
- package/src/app/chat/dashboardView.js +0 -405
- package/src/app/chat/rawKeyMap.js +0 -42
- package/src/app/chat/settingsController.js +0 -111
- package/src/coordination/history/controllerSummary.js +0 -23
- package/src/orchestration/controller/flags.js +0 -167
- package/src/orchestration/controller/gateRouter.js +0 -211
- package/src/orchestration/controller/routerFastPath.js +0 -22
- package/src/orchestration/controller/routerFinalize.js +0 -222
- package/src/orchestration/controller/shadowGuard.js +0 -280
- package/src/runtime/daemon/executionPaths.js +0 -30
- package/src/runtime/daemon/promptLoop.js +0 -136
- package/src/runtime/privacy/shadowDiff.js +0 -174
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
const { clampAgentWindowWithSelection } = require("./agentDirectory");
|
|
2
|
-
|
|
3
|
-
const DEFAULT_MODE_OPTIONS = ["auto", "host", "terminal", "tmux", "internal"];
|
|
4
|
-
|
|
5
|
-
function providerLabel(value) {
|
|
6
|
-
if (value === "claude-cli") return "claude";
|
|
7
|
-
if (value === "agy-cli" || value === "agy" || value === "antigravity") return "agy";
|
|
8
|
-
if (value === "kimi-cli" || value === "kimi" || value === "kimi-code") return "kimi";
|
|
9
|
-
if (value === "ucode" || value === "ufoo" || value === "ufoo-code") return "ucode";
|
|
10
|
-
return "codex";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function ensureAtPrefix(value) {
|
|
14
|
-
const text = String(value || "").trim();
|
|
15
|
-
if (!text) return text;
|
|
16
|
-
return text.startsWith("@") ? text : `@${text}`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function activityMarker(state = "") {
|
|
20
|
-
const normalized = String(state || "").trim().toLowerCase();
|
|
21
|
-
if (normalized === "working") return "*";
|
|
22
|
-
if (normalized === "waiting_input") return "?";
|
|
23
|
-
if (normalized === "blocked") return "!";
|
|
24
|
-
return "";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function withActivityMarker(label = "", state = "") {
|
|
28
|
-
const marker = activityMarker(state);
|
|
29
|
-
if (!marker) return label;
|
|
30
|
-
return `${marker}${label}`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function buildSummaryLine(options = {}) {
|
|
34
|
-
const {
|
|
35
|
-
activeAgents = [],
|
|
36
|
-
getAgentLabel = (id) => id,
|
|
37
|
-
getAgentState = () => "",
|
|
38
|
-
launchMode = "terminal",
|
|
39
|
-
agentProvider = "codex-cli",
|
|
40
|
-
cronTasks = [],
|
|
41
|
-
loopSummary = null,
|
|
42
|
-
} = options;
|
|
43
|
-
const agents = activeAgents.length > 0
|
|
44
|
-
? activeAgents.slice(0, 3)
|
|
45
|
-
.map((id) => withActivityMarker(ensureAtPrefix(getAgentLabel(id)), getAgentState(id)))
|
|
46
|
-
.join(", ")
|
|
47
|
-
+ (activeAgents.length > 3 ? ` +${activeAgents.length - 3}` : "")
|
|
48
|
-
: "none";
|
|
49
|
-
let line = `{gray-fg}Agents:{/gray-fg} {cyan-fg}${agents}{/cyan-fg}`
|
|
50
|
-
+ ` {gray-fg}Mode:{/gray-fg} {cyan-fg}${launchMode}{/cyan-fg}`
|
|
51
|
-
+ ` {gray-fg}Agent:{/gray-fg} {cyan-fg}${providerLabel(agentProvider)}{/cyan-fg}`;
|
|
52
|
-
const cronCount = Array.isArray(cronTasks) ? cronTasks.length : 0;
|
|
53
|
-
if (cronCount > 0) {
|
|
54
|
-
line += ` {gray-fg}Cron:{/gray-fg} {cyan-fg}${cronCount}{/cyan-fg}`;
|
|
55
|
-
}
|
|
56
|
-
const loopPart = formatLoopSummary(loopSummary);
|
|
57
|
-
if (loopPart) {
|
|
58
|
-
line += ` {gray-fg}Loop:{/gray-fg} {cyan-fg}${loopPart}{/cyan-fg}`;
|
|
59
|
-
}
|
|
60
|
-
return line;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function formatToolDistribution(items = []) {
|
|
64
|
-
const tools = Array.isArray(items) ? items : [];
|
|
65
|
-
if (tools.length === 0) return "";
|
|
66
|
-
const visible = tools.slice(0, 2).map((item) => `${item.name}x${item.count}`);
|
|
67
|
-
if (tools.length > 2) {
|
|
68
|
-
visible.push(`+${tools.length - 2}`);
|
|
69
|
-
}
|
|
70
|
-
return visible.join(",");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function formatLoopSummary(loopSummary) {
|
|
74
|
-
if (!loopSummary || typeof loopSummary !== "object") return "";
|
|
75
|
-
const rounds = Number(loopSummary.rounds) || 0;
|
|
76
|
-
const toolCalls = Number(loopSummary.tool_calls) || 0;
|
|
77
|
-
const totalTokens = Number(loopSummary.total_tokens) || 0;
|
|
78
|
-
const inputTokens = Number(loopSummary.input_tokens) || 0;
|
|
79
|
-
const cacheReadTokens = Number(loopSummary.cache_read_tokens) || 0;
|
|
80
|
-
const cacheCreationTokens = Number(loopSummary.cache_creation_tokens) || 0;
|
|
81
|
-
const terminalReason = String(loopSummary.terminal_reason || "").trim();
|
|
82
|
-
const toolDistribution = formatToolDistribution(loopSummary.tools);
|
|
83
|
-
|
|
84
|
-
if (rounds <= 0 && toolCalls <= 0 && totalTokens <= 0 && !terminalReason && !toolDistribution) {
|
|
85
|
-
return "";
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const parts = [
|
|
89
|
-
`r${rounds}`,
|
|
90
|
-
`tc${toolCalls}`,
|
|
91
|
-
`tok${totalTokens}`,
|
|
92
|
-
];
|
|
93
|
-
if (cacheReadTokens > 0 || cacheCreationTokens > 0) {
|
|
94
|
-
let cachePart = `cache${cacheReadTokens}/${cacheCreationTokens}`;
|
|
95
|
-
if (cacheReadTokens > 0) {
|
|
96
|
-
const hitRate = Math.round((cacheReadTokens / (cacheReadTokens + inputTokens)) * 100);
|
|
97
|
-
cachePart += `(${hitRate}%)`;
|
|
98
|
-
}
|
|
99
|
-
parts.push(cachePart);
|
|
100
|
-
}
|
|
101
|
-
if (toolDistribution) {
|
|
102
|
-
parts.push(toolDistribution);
|
|
103
|
-
}
|
|
104
|
-
if (terminalReason) {
|
|
105
|
-
parts.push(terminalReason);
|
|
106
|
-
}
|
|
107
|
-
return parts.join(" ");
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function buildProjectRailLine(options = {}) {
|
|
111
|
-
const {
|
|
112
|
-
projects = [],
|
|
113
|
-
selectedProjectIndex = -1,
|
|
114
|
-
projectListWindowStart = 0,
|
|
115
|
-
maxProjectWindow = 5,
|
|
116
|
-
activeProjectRoot = "",
|
|
117
|
-
projectsFocused = false,
|
|
118
|
-
globalScope = "",
|
|
119
|
-
dashboardHint = "",
|
|
120
|
-
} = options;
|
|
121
|
-
const rows = Array.isArray(projects) ? projects : [];
|
|
122
|
-
let windowStart = projectListWindowStart;
|
|
123
|
-
if (rows.length === 0) {
|
|
124
|
-
return {
|
|
125
|
-
hasProjects: false,
|
|
126
|
-
line: " {gray-fg}Projects:{/gray-fg} {cyan-fg}none{/cyan-fg}",
|
|
127
|
-
windowStart,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const activeRoot = String(activeProjectRoot || "");
|
|
132
|
-
const fallbackIndex = rows.findIndex((row) => String((row || {}).project_root || "") === activeRoot);
|
|
133
|
-
const normalizedSelectedIndex = Number.isFinite(selectedProjectIndex)
|
|
134
|
-
? Math.trunc(selectedProjectIndex)
|
|
135
|
-
: -1;
|
|
136
|
-
const safeSelectedIndex = normalizedSelectedIndex >= 0 && normalizedSelectedIndex < rows.length
|
|
137
|
-
? normalizedSelectedIndex
|
|
138
|
-
: (fallbackIndex >= 0 ? fallbackIndex : 0);
|
|
139
|
-
|
|
140
|
-
windowStart = clampAgentWindowWithSelection({
|
|
141
|
-
activeCount: rows.length,
|
|
142
|
-
maxWindow: Math.max(1, maxProjectWindow),
|
|
143
|
-
windowStart,
|
|
144
|
-
selectionIndex: safeSelectedIndex,
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const maxItems = Math.max(1, Math.min(Math.max(1, maxProjectWindow), rows.length));
|
|
148
|
-
const start = windowStart;
|
|
149
|
-
const end = start + maxItems;
|
|
150
|
-
const visibleRows = rows.slice(start, end);
|
|
151
|
-
const projectParts = visibleRows.map((row, i) => {
|
|
152
|
-
const absoluteIndex = start + i;
|
|
153
|
-
const name = String((row && row.project_name) || (row && row.project_root) || "-");
|
|
154
|
-
const rowRoot = String((row && row.project_root) || "");
|
|
155
|
-
const isActiveProject = globalScope !== "controller" && Boolean(activeRoot && rowRoot === activeRoot);
|
|
156
|
-
const isSelected = absoluteIndex === safeSelectedIndex;
|
|
157
|
-
if (projectsFocused && isSelected) {
|
|
158
|
-
return `{inverse}${name}{/inverse}`;
|
|
159
|
-
}
|
|
160
|
-
if (isActiveProject) {
|
|
161
|
-
return `{bold}{cyan-fg}${name}{/cyan-fg}{/bold}`;
|
|
162
|
-
}
|
|
163
|
-
return `{cyan-fg}${name}{/cyan-fg}`;
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
const leftMore = start > 0 ? "{gray-fg}<{/gray-fg} " : "";
|
|
167
|
-
const rightMore = end < rows.length ? " {gray-fg}>{/gray-fg}" : "";
|
|
168
|
-
const hintPart = dashboardHint ? `{|}{gray-fg}${dashboardHint}{/gray-fg}` : "";
|
|
169
|
-
return {
|
|
170
|
-
hasProjects: true,
|
|
171
|
-
line: ` {gray-fg}Projects:{/gray-fg} ${leftMore}${projectParts.join(" ")}${rightMore}${hintPart}`,
|
|
172
|
-
windowStart,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function buildDashboardDetailLine(options = {}) {
|
|
177
|
-
const {
|
|
178
|
-
globalMode = false,
|
|
179
|
-
dashboardView = "agents",
|
|
180
|
-
activeAgents = [],
|
|
181
|
-
selectedAgentIndex = -1,
|
|
182
|
-
agentListWindowStart = 0,
|
|
183
|
-
maxAgentWindow = 4,
|
|
184
|
-
getAgentLabel = (id) => id,
|
|
185
|
-
getAgentState = () => "",
|
|
186
|
-
selectedModeIndex = 0,
|
|
187
|
-
selectedProviderIndex = 0,
|
|
188
|
-
selectedCronIndex = -1,
|
|
189
|
-
cronTasks = [],
|
|
190
|
-
providerOptions = [],
|
|
191
|
-
dashHints = {},
|
|
192
|
-
modeOptions = DEFAULT_MODE_OPTIONS,
|
|
193
|
-
} = options;
|
|
194
|
-
|
|
195
|
-
let content = " ";
|
|
196
|
-
let windowStart = agentListWindowStart;
|
|
197
|
-
|
|
198
|
-
if (dashboardView === "mode") {
|
|
199
|
-
const modeParts = modeOptions.map((mode, i) => {
|
|
200
|
-
if (i === selectedModeIndex) {
|
|
201
|
-
return `{inverse}${mode}{/inverse}`;
|
|
202
|
-
}
|
|
203
|
-
return `{cyan-fg}${mode}{/cyan-fg}`;
|
|
204
|
-
});
|
|
205
|
-
content += `{gray-fg}Mode:{/gray-fg} ${modeParts.join(" ")}`;
|
|
206
|
-
content += ` {gray-fg}│ ${dashHints.mode || ""}{/gray-fg}`;
|
|
207
|
-
return { content, windowStart };
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (dashboardView === "provider") {
|
|
211
|
-
const providerParts = providerOptions.map((opt, i) => {
|
|
212
|
-
if (i === selectedProviderIndex) {
|
|
213
|
-
return `{inverse}${opt.label}{/inverse}`;
|
|
214
|
-
}
|
|
215
|
-
return `{cyan-fg}${opt.label}{/cyan-fg}`;
|
|
216
|
-
});
|
|
217
|
-
content += `{gray-fg}Agent:{/gray-fg} ${providerParts.join(" ")}`;
|
|
218
|
-
content += ` {gray-fg}│ ${dashHints.provider || ""}{/gray-fg}`;
|
|
219
|
-
return { content, windowStart };
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (dashboardView === "cron") {
|
|
223
|
-
const items = Array.isArray(cronTasks) ? cronTasks : [];
|
|
224
|
-
const summary = items.length > 0
|
|
225
|
-
? items.map((item, index) => {
|
|
226
|
-
const label = item.label || item.summary || item.id || "";
|
|
227
|
-
if (!label) return "";
|
|
228
|
-
return index === selectedCronIndex
|
|
229
|
-
? `{inverse}${label}{/inverse}`
|
|
230
|
-
: `{cyan-fg}${label}{/cyan-fg}`;
|
|
231
|
-
}).filter(Boolean).join(", ")
|
|
232
|
-
: "{cyan-fg}none{/cyan-fg}";
|
|
233
|
-
content += `{gray-fg}Cron:{/gray-fg} ${summary}`;
|
|
234
|
-
content += ` {gray-fg}│ ${dashHints.cron || ""}{/gray-fg}`;
|
|
235
|
-
return { content, windowStart };
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (activeAgents.length > 0) {
|
|
239
|
-
windowStart = clampAgentWindowWithSelection({
|
|
240
|
-
activeCount: activeAgents.length,
|
|
241
|
-
maxWindow: maxAgentWindow,
|
|
242
|
-
windowStart,
|
|
243
|
-
selectionIndex: selectedAgentIndex,
|
|
244
|
-
});
|
|
245
|
-
const maxItems = Math.max(1, Math.min(maxAgentWindow, activeAgents.length));
|
|
246
|
-
const start = windowStart;
|
|
247
|
-
const end = start + maxItems;
|
|
248
|
-
const visibleAgents = activeAgents.slice(start, end);
|
|
249
|
-
const agentParts = visibleAgents.map((agent, i) => {
|
|
250
|
-
const absoluteIndex = start + i;
|
|
251
|
-
const label = withActivityMarker(
|
|
252
|
-
ensureAtPrefix(getAgentLabel(agent)),
|
|
253
|
-
getAgentState(agent)
|
|
254
|
-
);
|
|
255
|
-
if (absoluteIndex === selectedAgentIndex) {
|
|
256
|
-
return `{inverse}${label}{/inverse}`;
|
|
257
|
-
}
|
|
258
|
-
return `{cyan-fg}${label}{/cyan-fg}`;
|
|
259
|
-
});
|
|
260
|
-
const leftMore = start > 0 ? "{gray-fg}<{/gray-fg} " : "";
|
|
261
|
-
const rightMore = end < activeAgents.length ? " {gray-fg}>{/gray-fg}" : "";
|
|
262
|
-
content += `{gray-fg}Agents:{/gray-fg} ${leftMore}${agentParts.join(" ")}${rightMore}`;
|
|
263
|
-
const agentsHint = globalMode
|
|
264
|
-
? (dashHints.agentsGlobal || dashHints.agents || "")
|
|
265
|
-
: (dashHints.agents || "");
|
|
266
|
-
content += ` {gray-fg}│ ${agentsHint}{/gray-fg}`;
|
|
267
|
-
} else {
|
|
268
|
-
content += "{gray-fg}Agents:{/gray-fg} {cyan-fg}none{/cyan-fg}";
|
|
269
|
-
content += ` {gray-fg}│ ${dashHints.agentsEmpty || ""}{/gray-fg}`;
|
|
270
|
-
}
|
|
271
|
-
return { content, windowStart };
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function computeDashboardContent(options = {}) {
|
|
275
|
-
const {
|
|
276
|
-
globalMode = false,
|
|
277
|
-
globalScope = "controller",
|
|
278
|
-
focusMode = "input",
|
|
279
|
-
dashboardView = "agents",
|
|
280
|
-
activeAgents = [],
|
|
281
|
-
projects = [],
|
|
282
|
-
selectedProjectIndex = -1,
|
|
283
|
-
projectListWindowStart = 0,
|
|
284
|
-
maxProjectWindow = 5,
|
|
285
|
-
activeProjectRoot = "",
|
|
286
|
-
selectedAgentIndex = -1,
|
|
287
|
-
agentListWindowStart = 0,
|
|
288
|
-
maxAgentWindow = 4,
|
|
289
|
-
getAgentLabel = (id) => id,
|
|
290
|
-
getAgentState = () => "",
|
|
291
|
-
launchMode = "terminal",
|
|
292
|
-
agentProvider = "codex-cli",
|
|
293
|
-
selectedModeIndex = 0,
|
|
294
|
-
selectedProviderIndex = 0,
|
|
295
|
-
selectedCronIndex = -1,
|
|
296
|
-
cronTasks = [],
|
|
297
|
-
loopSummary = null,
|
|
298
|
-
pendingReports = 0,
|
|
299
|
-
providerOptions = [],
|
|
300
|
-
dashHints = {},
|
|
301
|
-
modeOptions = DEFAULT_MODE_OPTIONS,
|
|
302
|
-
} = options;
|
|
303
|
-
|
|
304
|
-
if (globalMode) {
|
|
305
|
-
const projectsFocused = focusMode === "dashboard" && dashboardView === "projects";
|
|
306
|
-
let dashboardHint = "";
|
|
307
|
-
if (projectsFocused) {
|
|
308
|
-
dashboardHint = globalScope === "controller" ? "Enter\u2192project" : "Esc\u2192global";
|
|
309
|
-
}
|
|
310
|
-
const rail = buildProjectRailLine({
|
|
311
|
-
projects,
|
|
312
|
-
selectedProjectIndex,
|
|
313
|
-
projectListWindowStart,
|
|
314
|
-
maxProjectWindow,
|
|
315
|
-
activeProjectRoot,
|
|
316
|
-
projectsFocused,
|
|
317
|
-
globalScope,
|
|
318
|
-
dashboardHint,
|
|
319
|
-
});
|
|
320
|
-
if (!rail.hasProjects) {
|
|
321
|
-
const line2 = ` {gray-fg}${dashHints.projectsEmpty || "Run ufoo chat/daemon in projects to populate registry"}{/gray-fg}`;
|
|
322
|
-
return {
|
|
323
|
-
content: `${rail.line}\n${line2}`,
|
|
324
|
-
windowStart: rail.windowStart,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (focusMode !== "dashboard" || projectsFocused) {
|
|
329
|
-
const line2 = buildSummaryLine({
|
|
330
|
-
activeAgents,
|
|
331
|
-
getAgentLabel,
|
|
332
|
-
getAgentState,
|
|
333
|
-
launchMode,
|
|
334
|
-
agentProvider,
|
|
335
|
-
cronTasks,
|
|
336
|
-
loopSummary,
|
|
337
|
-
});
|
|
338
|
-
return {
|
|
339
|
-
content: `${rail.line}\n ${line2}`,
|
|
340
|
-
windowStart: rail.windowStart,
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
const detail = buildDashboardDetailLine({
|
|
345
|
-
globalMode,
|
|
346
|
-
dashboardView,
|
|
347
|
-
activeAgents,
|
|
348
|
-
selectedAgentIndex,
|
|
349
|
-
agentListWindowStart,
|
|
350
|
-
maxAgentWindow,
|
|
351
|
-
getAgentLabel,
|
|
352
|
-
getAgentState,
|
|
353
|
-
selectedModeIndex,
|
|
354
|
-
selectedProviderIndex,
|
|
355
|
-
selectedCronIndex,
|
|
356
|
-
cronTasks,
|
|
357
|
-
providerOptions,
|
|
358
|
-
dashHints,
|
|
359
|
-
modeOptions,
|
|
360
|
-
});
|
|
361
|
-
return {
|
|
362
|
-
content: `${rail.line}\n${detail.content}`,
|
|
363
|
-
windowStart: detail.windowStart,
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (focusMode === "dashboard") {
|
|
368
|
-
return buildDashboardDetailLine({
|
|
369
|
-
globalMode,
|
|
370
|
-
dashboardView,
|
|
371
|
-
activeAgents,
|
|
372
|
-
selectedAgentIndex,
|
|
373
|
-
agentListWindowStart,
|
|
374
|
-
maxAgentWindow,
|
|
375
|
-
getAgentLabel,
|
|
376
|
-
getAgentState,
|
|
377
|
-
selectedModeIndex,
|
|
378
|
-
selectedProviderIndex,
|
|
379
|
-
selectedCronIndex,
|
|
380
|
-
cronTasks,
|
|
381
|
-
providerOptions,
|
|
382
|
-
dashHints,
|
|
383
|
-
modeOptions,
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
let content = " ";
|
|
388
|
-
content += buildSummaryLine({
|
|
389
|
-
activeAgents,
|
|
390
|
-
getAgentLabel,
|
|
391
|
-
getAgentState,
|
|
392
|
-
launchMode,
|
|
393
|
-
agentProvider,
|
|
394
|
-
cronTasks,
|
|
395
|
-
loopSummary,
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
return { content, windowStart: agentListWindowStart };
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
module.exports = {
|
|
402
|
-
computeDashboardContent,
|
|
403
|
-
providerLabel,
|
|
404
|
-
formatLoopSummary,
|
|
405
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
function keyToRaw(ch, key) {
|
|
2
|
-
if (ch && ch.length === 1) return ch;
|
|
3
|
-
if (!key) return null;
|
|
4
|
-
|
|
5
|
-
switch (key.name) {
|
|
6
|
-
case "return":
|
|
7
|
-
case "enter":
|
|
8
|
-
return "\r";
|
|
9
|
-
case "backspace":
|
|
10
|
-
return "\x7f";
|
|
11
|
-
case "tab":
|
|
12
|
-
return "\t";
|
|
13
|
-
case "escape":
|
|
14
|
-
return "\x1b";
|
|
15
|
-
case "up":
|
|
16
|
-
return "\x1b[A";
|
|
17
|
-
case "down":
|
|
18
|
-
return "\x1b[B";
|
|
19
|
-
case "right":
|
|
20
|
-
return "\x1b[C";
|
|
21
|
-
case "left":
|
|
22
|
-
return "\x1b[D";
|
|
23
|
-
case "home":
|
|
24
|
-
return "\x1b[H";
|
|
25
|
-
case "end":
|
|
26
|
-
return "\x1b[F";
|
|
27
|
-
case "pageup":
|
|
28
|
-
return "\x1b[5~";
|
|
29
|
-
case "pagedown":
|
|
30
|
-
return "\x1b[6~";
|
|
31
|
-
case "delete":
|
|
32
|
-
return "\x1b[3~";
|
|
33
|
-
case "insert":
|
|
34
|
-
return "\x1b[2~";
|
|
35
|
-
default:
|
|
36
|
-
return ch || null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = {
|
|
41
|
-
keyToRaw,
|
|
42
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
|
|
3
|
-
function createSettingsController(options = {}) {
|
|
4
|
-
const {
|
|
5
|
-
projectRoot,
|
|
6
|
-
saveConfig = () => {},
|
|
7
|
-
normalizeLaunchMode = (value) => value,
|
|
8
|
-
normalizeAgentProvider = (value) => value,
|
|
9
|
-
fsModule,
|
|
10
|
-
getUfooPaths = () => ({ agentDir: "" }),
|
|
11
|
-
logMessage = () => {},
|
|
12
|
-
resolveStatusLine = null,
|
|
13
|
-
renderDashboard = () => {},
|
|
14
|
-
renderScreen = () => {},
|
|
15
|
-
restartDaemon = () => {},
|
|
16
|
-
getLaunchMode = () => "terminal",
|
|
17
|
-
setLaunchModeState = () => {},
|
|
18
|
-
setSelectedModeIndex = () => {},
|
|
19
|
-
getAgentProvider = () => "codex-cli",
|
|
20
|
-
setAgentProviderState = () => {},
|
|
21
|
-
setSelectedProviderIndex = () => {},
|
|
22
|
-
providerOptions = [],
|
|
23
|
-
modeOptions = [],
|
|
24
|
-
getAutoResume = () => true,
|
|
25
|
-
setAutoResumeState = () => {},
|
|
26
|
-
setSelectedResumeIndex = () => {},
|
|
27
|
-
} = options;
|
|
28
|
-
|
|
29
|
-
if (!projectRoot) {
|
|
30
|
-
throw new Error("createSettingsController requires projectRoot");
|
|
31
|
-
}
|
|
32
|
-
if (!fsModule) {
|
|
33
|
-
throw new Error("createSettingsController requires fsModule");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function providerLabel(value) {
|
|
37
|
-
return value === "claude-cli" ? "claude" : "codex";
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function clearUfooAgentIdentity() {
|
|
41
|
-
const agentDir = getUfooPaths(projectRoot).agentDir;
|
|
42
|
-
const stateFile = path.join(agentDir, "ufoo-agent.json");
|
|
43
|
-
const historyFile = path.join(agentDir, "ufoo-agent.history.jsonl");
|
|
44
|
-
try {
|
|
45
|
-
fsModule.rmSync(stateFile, { force: true });
|
|
46
|
-
} catch {
|
|
47
|
-
// Ignore cleanup failures.
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
fsModule.rmSync(historyFile, { force: true });
|
|
51
|
-
} catch {
|
|
52
|
-
// Ignore cleanup failures.
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function setLaunchMode(mode) {
|
|
57
|
-
const next = normalizeLaunchMode(mode);
|
|
58
|
-
if (next === getLaunchMode()) return false;
|
|
59
|
-
setLaunchModeState(next);
|
|
60
|
-
const nextIndex = modeOptions.findIndex((opt) => opt === next);
|
|
61
|
-
setSelectedModeIndex(nextIndex >= 0 ? nextIndex : 0);
|
|
62
|
-
saveConfig(projectRoot, { launchMode: next });
|
|
63
|
-
const statusMsg = resolveStatusLine || ((text) => logMessage("status", text));
|
|
64
|
-
statusMsg(`{gray-fg}⚙{/gray-fg} Launch mode: ${next}`);
|
|
65
|
-
renderDashboard();
|
|
66
|
-
renderScreen();
|
|
67
|
-
void restartDaemon();
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function setAgentProvider(provider) {
|
|
72
|
-
const next = normalizeAgentProvider(provider);
|
|
73
|
-
if (next === getAgentProvider()) return false;
|
|
74
|
-
setAgentProviderState(next);
|
|
75
|
-
setSelectedProviderIndex(Math.max(0, providerOptions.findIndex((opt) => opt.value === next)));
|
|
76
|
-
saveConfig(projectRoot, { agentProvider: next });
|
|
77
|
-
clearUfooAgentIdentity();
|
|
78
|
-
const statusMsg = resolveStatusLine || ((text) => logMessage("status", text));
|
|
79
|
-
statusMsg(`{gray-fg}⚙{/gray-fg} ufoo-agent: ${providerLabel(next)}`);
|
|
80
|
-
renderDashboard();
|
|
81
|
-
renderScreen();
|
|
82
|
-
void restartDaemon();
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function setAutoResume(value) {
|
|
87
|
-
const next = value !== false;
|
|
88
|
-
if (next === getAutoResume()) return false;
|
|
89
|
-
setAutoResumeState(next);
|
|
90
|
-
setSelectedResumeIndex(next ? 0 : 1);
|
|
91
|
-
saveConfig(projectRoot, { autoResume: next });
|
|
92
|
-
const label = next ? "Resume previous session" : "Start new session";
|
|
93
|
-
const statusMsg = resolveStatusLine || ((text) => logMessage("status", text));
|
|
94
|
-
statusMsg(`{gray-fg}⚙{/gray-fg} Resume mode: ${label}`);
|
|
95
|
-
renderDashboard();
|
|
96
|
-
renderScreen();
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
providerLabel,
|
|
102
|
-
clearUfooAgentIdentity,
|
|
103
|
-
setLaunchMode,
|
|
104
|
-
setAgentProvider,
|
|
105
|
-
setAutoResume,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
module.exports = {
|
|
110
|
-
createSettingsController,
|
|
111
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
|
|
5
|
-
/** Legacy output is evidence, never a fabricated native tool transcript. */
|
|
6
|
-
function readControllerSummary(projectRoot) {
|
|
7
|
-
const file = path.join(projectRoot, ".ufoo", "agent", "ufoo-agent.history.jsonl");
|
|
8
|
-
let fd;
|
|
9
|
-
try {
|
|
10
|
-
fd = fs.openSync(file, "r");
|
|
11
|
-
const size = fs.fstatSync(fd).size;
|
|
12
|
-
const length = Math.min(size, 65536);
|
|
13
|
-
const buffer = Buffer.alloc(length); fs.readSync(fd, buffer, 0, length, size - length);
|
|
14
|
-
const lines = buffer.toString("utf8").split("\n");
|
|
15
|
-
if (size > length) lines.shift();
|
|
16
|
-
return { source: "legacy-controller-history", trust: "untrusted", entries: lines.filter(Boolean).slice(-6).flatMap((line) => {
|
|
17
|
-
try { const item = JSON.parse(line); return [{ prompt: String(item.prompt || "").slice(0, 2000), reply: String(item.reply || "").slice(0, 4000) }]; }
|
|
18
|
-
catch { return []; }
|
|
19
|
-
}) };
|
|
20
|
-
} catch (error) { return { source: "legacy-controller-history", entries: [], error: error.code === "ENOENT" ? "" : "unreadable" }; }
|
|
21
|
-
finally { if (fd !== undefined) fs.closeSync(fd); }
|
|
22
|
-
}
|
|
23
|
-
module.exports = { readControllerSummary };
|