u-foo 4.0.3 → 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.
Files changed (160) hide show
  1. package/README.md +239 -19
  2. package/README.zh-CN.md +3 -3
  3. package/bin/ucode.js +10 -2
  4. package/bin/ufoo.js +3 -0
  5. package/dist/tui/darwin-arm64/ufoo-tui +0 -0
  6. package/dist/tui/darwin-x64/ufoo-tui +0 -0
  7. package/dist/tui/linux-arm64/ufoo-tui +0 -0
  8. package/dist/tui/linux-x64/ufoo-tui +0 -0
  9. package/{OBSERVABILITY.md → docs/OBSERVABILITY.md} +3 -3
  10. package/docs/README.md +27 -0
  11. package/extensions/ufoo-browser/LICENSE +152 -0
  12. package/extensions/ufoo-browser/NOTICE +10 -0
  13. package/extensions/ufoo-browser/README.md +30 -0
  14. package/extensions/ufoo-browser/background.js +409 -0
  15. package/extensions/ufoo-browser/icons/icon-128.png +0 -0
  16. package/extensions/ufoo-browser/icons/icon-16.png +0 -0
  17. package/extensions/ufoo-browser/icons/icon-256.png +0 -0
  18. package/extensions/ufoo-browser/icons/icon-32.png +0 -0
  19. package/extensions/ufoo-browser/icons/icon-48.png +0 -0
  20. package/extensions/ufoo-browser/icons/logo.png +0 -0
  21. package/extensions/ufoo-browser/icons/toolbar-16.png +0 -0
  22. package/extensions/ufoo-browser/icons/toolbar-32.png +0 -0
  23. package/extensions/ufoo-browser/icons/toolbar-logo.png +0 -0
  24. package/extensions/ufoo-browser/manifest.json +30 -0
  25. package/extensions/ufoo-browser/popup.css +71 -0
  26. package/extensions/ufoo-browser/popup.html +44 -0
  27. package/extensions/ufoo-browser/popup.js +153 -0
  28. package/package.json +7 -5
  29. package/scripts/postinstall.js +6 -0
  30. package/src/agents/capabilities/browser/index.js +49 -0
  31. package/src/agents/capabilities/coding/backgroundHooks.js +94 -0
  32. package/src/agents/capabilities/coding/index.js +30 -1
  33. package/src/agents/capabilities/index.js +5 -2
  34. package/src/agents/capabilities/planning/index.js +44 -5
  35. package/src/agents/capabilities/turnRecall/index.js +341 -0
  36. package/src/agents/controller/controllerToolExecutor.js +2 -2
  37. package/src/agents/internal/internalRunner.js +30 -8
  38. package/src/agents/internal/taskControl.js +107 -0
  39. package/src/agents/profiles/coding.js +1 -1
  40. package/src/agents/profiles/main.js +1 -1
  41. package/src/agents/prompts/mainAgent.js +1 -0
  42. package/src/agents/prompts/native/toolDescriptions/bash.js +7 -1
  43. package/src/agents/providers/claudeSessionFiles.js +1 -1
  44. package/src/agents/providers/codexThreadProvider.js +6 -1
  45. package/src/agents/providers/credentials/agy.js +171 -0
  46. package/src/agents/providers/directAuthStatus.js +20 -2
  47. package/src/agents/providers/modelsCatalog.js +26 -5
  48. package/src/agents/providers/nativeTransport.js +145 -73
  49. package/src/agents/providers/providerId.js +17 -0
  50. package/src/agents/providers/runtimeConfig.js +67 -20
  51. package/src/agents/providers/transports/antigravityTransport.js +242 -0
  52. package/src/agents/providers/transports/index.js +1 -0
  53. package/src/agents/providers/transports/openaiChatTransport.js +3 -2
  54. package/src/agents/providers/transports/openaiResponsesTransport.js +2 -1
  55. package/src/agents/providers/transports/responsesProtocol.js +119 -18
  56. package/src/agents/providers/transports/transportContract.js +1 -0
  57. package/src/agents/providers/upstreamRuntime.js +3 -1
  58. package/src/agents/runtime/context/contextBudget.js +1 -19
  59. package/src/agents/runtime/context/contextWindow.js +5 -0
  60. package/src/agents/runtime/context/replayHistory.js +16 -10
  61. package/src/agents/runtime/context/runtimeStore.js +0 -1
  62. package/src/agents/runtime/context/sessionJournal.js +1 -1
  63. package/src/agents/runtime/context/slidingWindowManager.js +792 -0
  64. package/src/agents/runtime/context/topicSelector.js +338 -0
  65. package/src/agents/runtime/context/turnAnalyzer.js +767 -0
  66. package/src/agents/runtime/context/turnIndexStore.js +515 -0
  67. package/src/agents/runtime/core/agentLoop.js +140 -35
  68. package/src/agents/runtime/core/executionBudget.js +2 -1
  69. package/src/agents/runtime/core/toolErrorGuard.js +39 -0
  70. package/src/agents/runtime/createAgentRuntime.js +80 -7
  71. package/src/agents/runtime/index.js +5 -0
  72. package/src/agents/runtime/protocol/materialize.js +1 -1
  73. package/src/agents/runtime/tasks/hooks.js +137 -0
  74. package/src/app/chat/ChatController.js +8 -4
  75. package/src/app/chat/daemonMessageRouter.js +3 -1
  76. package/src/app/chat/inputSubmitHandler.js +2 -2
  77. package/src/app/chat/transport.js +1 -1
  78. package/src/app/cli/browserCommands.js +340 -0
  79. package/src/app/cli/busCoreCommands.js +63 -3
  80. package/src/app/cli/features/doctor.js +21 -0
  81. package/src/app/cli/metricsCommands.js +1 -1
  82. package/src/app/cli/run.js +81 -1
  83. package/src/app/cli/setupCommands.js +200 -0
  84. package/src/code/UcodeController.js +31 -1
  85. package/src/code/agent.js +76 -25
  86. package/src/code/busConsumer.js +13 -12
  87. package/src/code/commands.js +0 -1
  88. package/src/code/context/assembler.js +11 -88
  89. package/src/code/context/planGraphService.js +121 -6
  90. package/src/code/context/planProjection.js +10 -2
  91. package/src/code/context/reducers.js +172 -4
  92. package/src/code/context/stateCommit.js +0 -32
  93. package/src/code/context/transcript.js +7 -4
  94. package/src/code/internalThread.js +9 -1
  95. package/src/code/launcher/ucode.js +4 -2
  96. package/src/code/modelCommand.js +6 -5
  97. package/src/code/nativeRunner.js +232 -62
  98. package/src/code/repl.js +27 -1
  99. package/src/code/runtime/agentWakeup.js +20 -3
  100. package/src/code/runtime/backgroundWakeHost.js +45 -0
  101. package/src/code/runtime/taskFocusContext.js +7 -0
  102. package/src/code/runtime/taskLoop.js +24 -1
  103. package/src/code/sessionStore.js +14 -10
  104. package/src/code/taskDecomposer.js +16 -7
  105. package/src/code/tools/backgroundProcess.js +23 -0
  106. package/src/code/tools/bash.js +764 -12
  107. package/src/code/tools/executor.js +13 -4
  108. package/src/code/tools/planGraph.js +1 -0
  109. package/src/code/tools/specs.js +62 -4
  110. package/src/code/tools/taskRun.js +38 -0
  111. package/src/config.js +92 -6
  112. package/src/coordination/bus/index.js +2 -2
  113. package/src/coordination/bus/message.js +10 -1
  114. package/src/coordination/bus/nickname.js +3 -1
  115. package/src/coordination/bus/subscriber.js +25 -10
  116. package/src/coordination/bus/utils.js +4 -0
  117. package/src/coordination/bus/wakeEndpoint.js +198 -0
  118. package/src/coordination/history/agentPerformance.js +18 -18
  119. package/src/coordination/history/agentTrace.js +7 -3
  120. package/src/coordination/state/paths.js +4 -0
  121. package/src/coordination/state/workspaceAccess.js +3 -1
  122. package/src/orchestration/groups/modelConfig.js +66 -0
  123. package/src/orchestration/groups/validateTemplate.js +2 -0
  124. package/src/runtime/browser/broker.js +1027 -0
  125. package/src/runtime/browser/brokerClient.js +108 -0
  126. package/src/runtime/browser/componentInstaller.js +275 -0
  127. package/src/runtime/browser/installState.js +329 -0
  128. package/src/runtime/browser/manifest.js +145 -0
  129. package/src/runtime/browser/native-host-runner.js +198 -0
  130. package/src/runtime/browser/nativeHost.js +213 -0
  131. package/src/runtime/browser/nativeMessagingProtocol.js +50 -0
  132. package/src/runtime/browser/paths.js +134 -0
  133. package/src/runtime/browser/playwrightSession.js +614 -0
  134. package/src/runtime/daemon/agentHost.js +175 -28
  135. package/src/runtime/daemon/busBridge.js +2 -1
  136. package/src/runtime/daemon/deliveryScheduler.js +70 -2
  137. package/src/runtime/daemon/globalDaemon.js +20 -0
  138. package/src/runtime/daemon/groupOrchestrator.js +20 -1
  139. package/src/runtime/daemon/index.js +6 -4
  140. package/src/runtime/daemon/ops.js +14 -8
  141. package/src/tools/handlers/listAgents.js +1 -1
  142. package/src/tools/handlers/readBusSummary.js +1 -1
  143. package/src/tools/handlers/routeAgent.js +122 -5
  144. package/src/tools/schemaFixtures.js +1 -1
  145. package/src/ui/agentSurface.js +60 -6
  146. package/src/ui/format/index.js +34 -2
  147. package/src/ui/format/markdownRenderer.js +4 -2
  148. package/src/ui/rustChatHost.js +22 -7
  149. package/src/ui/rustMultiSession.js +14 -2
  150. package/src/ui/rustUcodeHost.js +249 -80
  151. package/src/ui/ucodeAgentSession.js +88 -0
  152. package/templates/groups/build-lane.json +57 -3
  153. package/templates/groups/build-ultra.json +114 -6
  154. package/templates/groups/design-system.json +57 -3
  155. package/templates/groups/product-discovery.json +57 -3
  156. package/templates/groups/ui-plan-review.json +57 -3
  157. package/templates/groups/ui-polish.json +57 -3
  158. package/templates/groups/verify-ship.json +57 -3
  159. package/src/agents/runtime/context/checkpointStore.js +0 -38
  160. package/src/agents/runtime/context/compaction.js +0 -151
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { getUfooPaths } = require("../state/paths");
6
+ const { withFileLock } = require("../state/fileLock");
7
+
8
+ const WAKE_ADAPTERS = Object.freeze({
9
+ "bearer-json": Object.freeze({
10
+ acceptedStatuses: Object.freeze([200]),
11
+ }),
12
+ });
13
+
14
+ function isWakeMeta(meta) {
15
+ return Boolean(
16
+ meta
17
+ && meta.status !== "inactive"
18
+ && meta.launch_mode === "wake"
19
+ && typeof meta.wake_adapter === "string"
20
+ && WAKE_ADAPTERS[meta.wake_adapter]
21
+ );
22
+ }
23
+
24
+ function assertHttpsWakeUrl(rawUrl) {
25
+ let parsed;
26
+ try {
27
+ parsed = new URL(String(rawUrl || "").trim());
28
+ } catch {
29
+ throw new Error("wake URL must be an http(s) URL");
30
+ }
31
+ if (parsed.username || parsed.password) {
32
+ throw new Error("wake URL must not include credentials");
33
+ }
34
+ const loopback = ["localhost", "127.0.0.1", "::1", "[::1]"].includes(parsed.hostname);
35
+ if (parsed.protocol === "https:") return parsed.toString();
36
+ if (parsed.protocol === "http:" && loopback) return parsed.toString();
37
+ throw new Error("wake URL must use https");
38
+ }
39
+
40
+ function normalizeAdapter(adapter) {
41
+ const name = String(adapter || "bearer-json").trim();
42
+ if (!WAKE_ADAPTERS[name]) {
43
+ throw new Error(`Unknown wake adapter "${name}"`);
44
+ }
45
+ return name;
46
+ }
47
+
48
+ function readJsonFile(filePath) {
49
+ try {
50
+ if (!filePath || !fs.existsSync(filePath)) return null;
51
+ const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
52
+ return parsed && typeof parsed === "object" ? parsed : null;
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+
58
+ function writeJsonFile(filePath, data, mode) {
59
+ fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
60
+ const tmp = `${filePath}.${process.pid}.tmp`;
61
+ fs.writeFileSync(tmp, `${JSON.stringify(data, null, 2)}\n`, { mode });
62
+ fs.renameSync(tmp, filePath);
63
+ fs.chmodSync(filePath, mode);
64
+ }
65
+
66
+ function endpointStore(projectRoot) {
67
+ const filePath = getUfooPaths(projectRoot).wakeEndpointsFile;
68
+ const parsed = readJsonFile(filePath) || { version: 1, endpoints: {} };
69
+ if (!parsed.endpoints || typeof parsed.endpoints !== "object") parsed.endpoints = {};
70
+ parsed.version = 1;
71
+ return { filePath, data: parsed };
72
+ }
73
+
74
+ function receiptStore(projectRoot) {
75
+ const filePath = getUfooPaths(projectRoot).wakeReceiptsFile;
76
+ const parsed = readJsonFile(filePath) || { version: 1, accepted: {} };
77
+ if (!parsed.accepted || typeof parsed.accepted !== "object") parsed.accepted = {};
78
+ parsed.version = 1;
79
+ return { filePath, data: parsed };
80
+ }
81
+
82
+ function writeWakeEndpoint(projectRoot, subscriber, endpoint = {}) {
83
+ const adapter = normalizeAdapter(endpoint.adapter);
84
+ const url = assertHttpsWakeUrl(endpoint.url);
85
+ const key = String(endpoint.key || "");
86
+ if (!key.trim()) throw new Error("wake key is empty");
87
+ if (key.length > 4096) throw new Error("wake key is too long");
88
+ if (/[\r\n]/.test(key)) throw new Error("wake key must be a single line");
89
+ return withFileLock(getUfooPaths(projectRoot).wakeEndpointsFile, () => {
90
+ const store = endpointStore(projectRoot);
91
+ store.data.endpoints[subscriber] = { adapter, url, key };
92
+ writeJsonFile(store.filePath, store.data, 0o600);
93
+ return { adapter, url };
94
+ });
95
+ }
96
+
97
+ function readWakeEndpoint(projectRoot, subscriber) {
98
+ const record = endpointStore(projectRoot).data.endpoints[subscriber];
99
+ if (!record || typeof record !== "object") return null;
100
+ if (!WAKE_ADAPTERS[record.adapter] || typeof record.url !== "string" || typeof record.key !== "string") {
101
+ return null;
102
+ }
103
+ return { adapter: record.adapter, url: record.url, key: record.key };
104
+ }
105
+
106
+ function removeWakeEndpoint(projectRoot, subscriber) {
107
+ return withFileLock(getUfooPaths(projectRoot).wakeEndpointsFile, () => {
108
+ const store = endpointStore(projectRoot);
109
+ if (!store.data.endpoints[subscriber]) return false;
110
+ delete store.data.endpoints[subscriber];
111
+ writeJsonFile(store.filePath, store.data, 0o600);
112
+ withFileLock(getUfooPaths(projectRoot).wakeReceiptsFile, () => {
113
+ const receipts = receiptStore(projectRoot);
114
+ if (receipts.data.accepted[subscriber]) {
115
+ delete receipts.data.accepted[subscriber];
116
+ writeJsonFile(receipts.filePath, receipts.data, 0o600);
117
+ }
118
+ });
119
+ return true;
120
+ });
121
+ }
122
+
123
+ function hasWakeAccepted(projectRoot, subscriber, seq) {
124
+ const accepted = receiptStore(projectRoot).data.accepted[subscriber] || {};
125
+ return Boolean(accepted[String(seq)]);
126
+ }
127
+
128
+ function markWakeAccepted(projectRoot, subscriber, seq) {
129
+ return withFileLock(getUfooPaths(projectRoot).wakeReceiptsFile, () => {
130
+ const store = receiptStore(projectRoot);
131
+ if (!store.data.accepted[subscriber]) store.data.accepted[subscriber] = {};
132
+ store.data.accepted[subscriber][String(seq)] = new Date().toISOString();
133
+ writeJsonFile(store.filePath, store.data, 0o600);
134
+ });
135
+ }
136
+
137
+ function readWakeKeyFile(filePath) {
138
+ const resolved = String(filePath || "").trim();
139
+ if (!resolved) throw new Error("wake key file is required");
140
+ let key = "";
141
+ try {
142
+ key = fs.readFileSync(resolved, "utf8");
143
+ } catch (error) {
144
+ throw new Error(`cannot read wake key file: ${error.message}`);
145
+ }
146
+ key = key.replace(/\r?\n$/, "");
147
+ if (!key.trim()) throw new Error("wake key file is empty");
148
+ return key;
149
+ }
150
+
151
+ async function wakeBearerJson({ url, key, payload, fetchImpl, signal }) {
152
+ const response = await fetchImpl(url, {
153
+ method: "POST",
154
+ headers: {
155
+ "content-type": "application/json",
156
+ authorization: `Bearer ${key}`,
157
+ },
158
+ body: JSON.stringify(payload),
159
+ signal,
160
+ redirect: "error",
161
+ });
162
+ try { Promise.resolve(response.body?.cancel()).catch(() => {}); } catch { /* response body is optional */ }
163
+ return {
164
+ accepted: response.status === 200,
165
+ status: response.status,
166
+ };
167
+ }
168
+
169
+ async function wakeSubscriber(endpoint, payload, fetchImpl = global.fetch, { timeoutMs = 10000 } = {}) {
170
+ if (!endpoint) throw new Error("wake endpoint is missing");
171
+ if (typeof fetchImpl !== "function") throw new Error("wake fetch is unavailable");
172
+ if (endpoint.adapter === "bearer-json") {
173
+ const controller = new AbortController();
174
+ let timer;
175
+ const timeout = new Promise((_, reject) => {
176
+ timer = setTimeout(() => {
177
+ controller.abort();
178
+ reject(Object.assign(new Error("wake request timed out"), { code: "WAKE_TIMEOUT" }));
179
+ }, timeoutMs);
180
+ });
181
+ try { return await Promise.race([wakeBearerJson({ ...endpoint, payload, fetchImpl, signal: controller.signal }), timeout]); }
182
+ finally { clearTimeout(timer); }
183
+ }
184
+ throw new Error(`Unknown wake adapter "${endpoint.adapter}"`);
185
+ }
186
+
187
+ module.exports = {
188
+ WAKE_ADAPTERS,
189
+ isWakeMeta,
190
+ assertHttpsWakeUrl,
191
+ writeWakeEndpoint,
192
+ readWakeEndpoint,
193
+ removeWakeEndpoint,
194
+ hasWakeAccepted,
195
+ markWakeAccepted,
196
+ readWakeKeyFile,
197
+ wakeSubscriber,
198
+ };
@@ -61,9 +61,9 @@ function aggregate(runs) {
61
61
  const counts = {};
62
62
  for (const run of runs) for (const [key, value] of Object.entries(run.counts)) counts[key] = (counts[key] || 0) + value;
63
63
  const latency = {};
64
- for (const key of ["elapsedMs", "activeMs", "queueMs", "firstTextMs", "firstThinkingMs", "modelMs", "toolMs", "compactionMs", "waitingUserMs", "idleMs"]) latency[key] = distribution(runs.map(r => r.timings[key]));
64
+ for (const key of ["elapsedMs", "activeMs", "queueMs", "firstTextMs", "firstThinkingMs", "modelMs", "toolMs", "contextSelectMs", "waitingUserMs", "idleMs"]) latency[key] = distribution(runs.map(r => r.timings[key]));
65
65
  const tokenTotals = {};
66
- for (const scope of ["usage", "compactionUsage"]) {
66
+ for (const scope of ["usage"]) {
67
67
  tokenTotals[scope] = {};
68
68
  for (const key of ["input", "output", "cacheRead", "cacheCreation"]) {
69
69
  const observed = runs.map(r => r[scope][key]).filter(v => v !== null);
@@ -72,7 +72,7 @@ function aggregate(runs) {
72
72
  }
73
73
  return { runs: runs.length, outcomes, completedOfFinished: rate(outcomes.completed, finished), finished,
74
74
  counts, latency, ...tokenTotals, finalTextCharacters: distribution(runs.map(r => r.finalTextCharacters)),
75
- cache: aggregateCache(runs, "cache"), compactionCache: aggregateCache(runs, "compactionCache"),
75
+ cache: aggregateCache(runs, "cache"),
76
76
  signals: Object.fromEntries([...new Set(runs.flatMap(r => r.signals))].map(key => [key, runs.filter(r => r.signals.includes(key)).length])) };
77
77
  }
78
78
 
@@ -99,7 +99,7 @@ function summarizeAgentPerformance(events, tasks = [], queues = [], options = {}
99
99
  let uncorrelatedEvents = 0;
100
100
  for (const event of events) {
101
101
  const type = event.type || "";
102
- if (!/^(?:task\.|request.accepted|run.config|model\.|tool\.|message.delta|thinking.delta|context.compaction|loop\.|interaction\.)/.test(type)) continue;
102
+ if (!/^(?:task\.|request.accepted|run.config|model\.|tool\.|message.delta|thinking.delta|context\.(?:select|window|turn_indexed|turn_enriched)|loop\.|interaction\.)/.test(type)) continue;
103
103
  if (!event.taskRunId) { uncorrelatedEvents += 1; continue; }
104
104
  let run = runs.get(event.taskRunId);
105
105
  if (!run) {
@@ -107,10 +107,10 @@ function summarizeAgentPerformance(events, tasks = [], queues = [], options = {}
107
107
  parentTaskRunId: event.parentTaskRunId || null, traceId: event.traceId || null, status: "unknown", configuration: null,
108
108
  accepted: null, enqueued: null, started: null, ended: null, lastActivity: null, firstText: null, firstThinking: null,
109
109
  activeStart: null, pausedAt: null, activeMs: 0, waitingUserMs: 0, attempts: new Set(), tools: new Map(),
110
- usageSamples: [], modelOutcomes: 0, compactionUsageSamples: [], terminalUsage: null, finalTextCharacters: null, streamedCharacters: 0,
110
+ usageSamples: [], modelOutcomes: 0, terminalUsage: null, finalTextCharacters: null, streamedCharacters: 0,
111
111
  counts: { modelCalls: 0, sdkTurns: 0, modelFailures: 0, toolCalls: 0, toolErrors: 0, toolExceptions: 0, toolRejections: 0, unresolvedTools: 0,
112
- repeatedToolCalls: 0, loopWarnings: 0, loopStops: 0, modelRetries: 0, compactionAttempts: 0, compactions: 0, compactionFailures: 0 },
113
- modelDurations: [], modelStarts: new Map(), toolDurations: [], compactionDurations: [], fingerprints: new Map(), errorCodes: {} };
112
+ repeatedToolCalls: 0, loopWarnings: 0, loopStops: 0, modelRetries: 0, contextSelections: 0, windowProjections: 0, maxEvictionLevel: 0 },
113
+ modelDurations: [], modelStarts: new Map(), toolDurations: [], contextSelectDurations: [], fingerprints: new Map(), errorCodes: {} };
114
114
  runs.set(event.taskRunId, run);
115
115
  }
116
116
  run.agentId ||= event.agentId || "";
@@ -177,14 +177,15 @@ function summarizeAgentPerformance(events, tasks = [], queues = [], options = {}
177
177
  }
178
178
  run.tools.set(id, tool);
179
179
  }
180
- if (type === "context.compaction.started") run.counts.compactionAttempts += 1;
181
- if (type === "context.compaction.completed") {
182
- run.counts.compactions += 1;
183
- const usage = normalizedUsage(event.usage);
184
- if (usage) run.compactionUsageSamples.push(usage);
180
+ if (type === "context.select.completed") {
181
+ run.counts.contextSelections += 1;
182
+ const d = number(event.latencyMs ?? event.durationMs);
183
+ if (d !== null) run.contextSelectDurations.push(d);
184
+ }
185
+ if (type === "context.window.projected") {
186
+ run.counts.windowProjections += 1;
187
+ run.counts.maxEvictionLevel = Math.max(run.counts.maxEvictionLevel, Number(event.evictionLevel) || 0);
185
188
  }
186
- if (type === "context.compaction.failed") run.counts.compactionFailures += 1;
187
- if (["context.compaction.completed", "context.compaction.failed"].includes(type) && number(event.durationMs) !== null) run.compactionDurations.push(event.durationMs);
188
189
  const code = event.code || event.resultCode;
189
190
  if (code && (type.endsWith("failed") || type === "tool.rejected" || type === "model.retry" || event.ok === false)) run.errorCodes[code] = (run.errorCodes[code] || 0) + 1;
190
191
  }
@@ -214,7 +215,6 @@ function summarizeAgentPerformance(events, tasks = [], queues = [], options = {}
214
215
  if (run.counts.toolRejections) signals.push("rejected_tool_calls");
215
216
  if (run.counts.repeatedToolCalls) signals.push("repeated_tool_arguments");
216
217
  if (run.counts.loopStops) signals.push("loop_guard_stopped");
217
- if (run.counts.compactionFailures) signals.push("compaction_failed");
218
218
  const idleMs = terminal.has(run.status) ? null : difference(now, run.lastActivity);
219
219
  if (run.status === "running" && idleMs > (options.idleThresholdMs || 300000)) signals.push("running_without_recent_events");
220
220
  const reports = reportsByTask.get(`${run.taskId}:${run.agentId}`) || [];
@@ -226,8 +226,8 @@ function summarizeAgentPerformance(events, tasks = [], queues = [], options = {}
226
226
  parentTaskRunId: run.parentTaskRunId, traceId: run.traceId, status: run.status, provider, model,
227
227
  startedAt: run.started !== null ? new Date(run.started).toISOString() : null,
228
228
  endedAt: run.ended !== null ? new Date(run.ended).toISOString() : null,
229
- configuration: config, attempts: run.attempts.size || null, counts: run.counts, usage: sumUsage(usage), compactionUsage: sumUsage(run.compactionUsageSamples),
230
- cache, compactionCache: cacheObservation(run.compactionUsageSamples, config, provider),
229
+ configuration: config, attempts: run.attempts.size || null, counts: run.counts, usage: sumUsage(usage),
230
+ cache,
231
231
  queueTimingSource: run.enqueued !== null ? "bus.sequence" : run.accepted !== null ? "request.accepted" : "unknown",
232
232
  finalTextCharacters: run.finalTextCharacters, streamedCharacters: run.streamedCharacters,
233
233
  reportCharacters: distribution(reportLengths), errorCodes: run.errorCodes, signals,
@@ -238,7 +238,7 @@ function summarizeAgentPerformance(events, tasks = [], queues = [], options = {}
238
238
  activeMs: lifecycleComplete ? run.activeMs + (run.activeStart !== null ? difference(end, run.activeStart) || 0 : 0) : null,
239
239
  queueMs: difference(run.started, run.enqueued ?? run.accepted), firstTextMs: difference(run.firstText, run.started),
240
240
  firstThinkingMs: difference(run.firstThinking, run.started), modelMs: durations(run.modelDurations), toolMs: durations(run.toolDurations),
241
- compactionMs: durations(run.compactionDurations), waitingUserMs: run.waitingUserMs + (run.pausedAt !== null ? difference(end, run.pausedAt) || 0 : 0), idleMs } });
241
+ contextSelectMs: durations(run.contextSelectDurations), waitingUserMs: run.waitingUserMs + (run.pausedAt !== null ? difference(end, run.pausedAt) || 0 : 0), idleMs } });
242
242
  }
243
243
  rows.sort((a, b) => String(a.startedAt || "").localeCompare(String(b.startedAt || "")) || a.taskRunId.localeCompare(b.taskRunId));
244
244
  const groups = new Map();
@@ -94,7 +94,9 @@ function readAgentTrace(projectRoot, options = {}) {
94
94
  ...(event.binding ? { binding: event.binding } : {}), ...(event.code ? { code: event.code } : {}), ...(event.outcome ? { outcome: event.outcome } : {}),
95
95
  ...(event.warning ? { warning: event.warning } : {}),
96
96
  ...(event.error ? { error: event.error } : {}),
97
- ...(String(event.type || "").startsWith("context.compaction") ? { coveredCount: event.coveredCount, batchCount: event.batchCount, checkpointVersion: event.version, sourceArchive: event.sourceArchive } : {}) };
97
+ ...(String(event.type || "").startsWith("context.select") ? { mode: event.mode, activeTopics: event.activeTopics, selectedTurnIds: event.selectedTurnIds, latencyMs: event.latencyMs, cached: event.cached } : {}),
98
+ ...(String(event.type || "").startsWith("context.window") ? { evictionLevel: event.evictionLevel, rawTurnCount: event.rawTurnCount, totalTurns: event.totalTurns, offWindowCount: event.offWindowCount, estimatedTokens: event.estimatedTokens } : {}),
99
+ ...(event.type === "context.turn_indexed" || event.type === "context.turn_enriched" ? { turnId: event.turnId, topic: event.topic, turnKind: event.turnKind, outcome: event.outcome } : {}) };
98
100
  }
99
101
  for (const record of records) {
100
102
  const e = record.value;
@@ -232,8 +234,10 @@ function readAgentTrace(projectRoot, options = {}) {
232
234
  modelFailures: matched.filter(e => e.type === "model.failed").length, toolCalls: toolCalls.size,
233
235
  toolErrors: [...toolCalls.values()].filter(t => t.outcome === "error").length,
234
236
  unresolvedTools: [...toolCalls.values()].filter(t => !t.ended || t.outcome === "unknown").length,
235
- compactions: matched.filter(e => e.type === "context.compaction.completed").length,
236
- compactionFailures: matched.filter(e => e.type === "context.compaction.failed").length },
237
+ contextSelections: matched.filter(e => e.type === "context.select.completed").length,
238
+ windowProjections: matched.filter(e => e.type === "context.window.projected").length,
239
+ turnsIndexed: matched.filter(e => e.type === "context.turn_indexed").length,
240
+ turnsEnriched: matched.filter(e => e.type === "context.turn_enriched").length },
237
241
  tools: [...toolCalls.values()],
238
242
  performance,
239
243
  queues: selectedQueues.slice(-100),
@@ -6,6 +6,8 @@ function getUfooPaths(projectRoot) {
6
6
  const agentDir = path.join(ufooDir, "agent");
7
7
  const memoryDir = path.join(ufooDir, "memory");
8
8
  const agentsFile = path.join(agentDir, "all-agents.json");
9
+ const wakeEndpointsFile = path.join(agentDir, "wake-endpoints.json");
10
+ const wakeReceiptsFile = path.join(busDir, "wake-receipts.json");
9
11
  const memoryFile = path.join(memoryDir, "memory.jsonl");
10
12
 
11
13
  const busQueuesDir = path.join(busDir, "queues");
@@ -33,6 +35,8 @@ function getUfooPaths(projectRoot) {
33
35
  agentDir,
34
36
  memoryDir,
35
37
  agentsFile,
38
+ wakeEndpointsFile,
39
+ wakeReceiptsFile,
36
40
  memoryFile,
37
41
  busQueuesDir,
38
42
  busEventsDir,
@@ -20,7 +20,9 @@ function createWorkspaceAccess({ projectRoot, externalWriters = () => [] } = {})
20
20
  return Object.freeze({
21
21
  leases,
22
22
  async run(context, operation) {
23
- if (!["write", "edit", "bash"].includes(context.tool)) return operation();
23
+ const readOnlyBash = context.tool === "bash"
24
+ && ["logs", "status", "list"].includes(String((context.args && context.args.action) || "").trim().toLowerCase());
25
+ if (!["write", "edit", "bash"].includes(context.tool) || readOnlyBash) return operation();
24
26
  const workspace = key(context.workspaceRoot);
25
27
  const writers = workspace === root ? externalWriters(context) : [];
26
28
  if (writers.length) return { ok: false, code: "workspace_busy", error: "Workers own or may write this workspace. Delegate to them, wait, read files, or use an isolated worktree. Do not close workers to bypass this lease.", owners: writers };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ const { normalizeProvider } = require("../../agents/providers/providerId");
4
+
5
+ const EFFORTS = new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max"]);
6
+ const text = value => typeof value === "string" ? value.trim() : "";
7
+ const object = value => Boolean(value) && typeof value === "object" && !Array.isArray(value);
8
+
9
+ function validateModelConfig(config, basePath) {
10
+ const errors = [];
11
+ const error = (path, message) => errors.push({ path, message });
12
+ if (config === undefined) return errors;
13
+ if (!object(config)) return [{ path: basePath, message: "model_config must be an object" }];
14
+ for (const [key, setting] of Object.entries(config)) {
15
+ const prefix = `${basePath}.${key}`;
16
+ if (!["codex", "claude", "agy", "override"].includes(key)) {
17
+ error(prefix, "model_config supports codex, claude, agy and override");
18
+ continue;
19
+ }
20
+ if (!object(setting)) { error(prefix, "model setting must be an object"); continue; }
21
+ for (const field of Object.keys(setting)) {
22
+ if (!["model", "reasoning_effort"].includes(field)) error(`${prefix}.${field}`, "unknown model setting");
23
+ }
24
+ if (setting.model !== undefined && typeof setting.model !== "string") error(`${prefix}.model`, "model must be a string");
25
+ if (setting.reasoning_effort !== undefined && (typeof setting.reasoning_effort !== "string"
26
+ || (text(setting.reasoning_effort) && !EFFORTS.has(text(setting.reasoning_effort))))) {
27
+ error(`${prefix}.reasoning_effort`, "invalid reasoning_effort");
28
+ }
29
+ if (key === "override" && text(setting.reasoning_effort) && !text(setting.model)) {
30
+ error(`${prefix}.model`, "override model is required when overriding reasoning_effort");
31
+ }
32
+ }
33
+ return errors;
34
+ }
35
+
36
+ function resolveGroupModelConfig(config, type, provider = "") {
37
+ const nativeProvider = type === "ucode" ? normalizeProvider(provider) : "";
38
+ const modelProvider = nativeProvider === "anthropic" ? "claude" : nativeProvider || type;
39
+ if (!config || (!["codex", "claude", "agy"].includes(modelProvider) && !nativeProvider)) return {};
40
+ const source = text(config.override?.model) ? "override" : modelProvider;
41
+ const setting = config[source] || {};
42
+ const model = text(setting.model);
43
+ const effort = text(setting.reasoning_effort);
44
+ return model || effort ? { model, reasoning_effort: effort, model_source: source,
45
+ ...(nativeProvider ? { model_provider: nativeProvider } : {}) } : {};
46
+ }
47
+
48
+ function buildGroupModelArgs(type, setting = {}) {
49
+ const native = type === "ucode";
50
+ if (!["codex", "claude", "agy"].includes(type) && !native) return [];
51
+ const args = [];
52
+ if (text(setting.model)) args.push("--model", text(setting.model));
53
+ if (text(setting.reasoning_effort) && !native) {
54
+ if (type === "codex") args.push("-c", `model_reasoning_effort=${JSON.stringify(text(setting.reasoning_effort))}`);
55
+ else args.push("--effort", text(setting.reasoning_effort));
56
+ }
57
+ return args;
58
+ }
59
+
60
+ function buildGroupModelEnv(type, setting = {}) {
61
+ if (type !== "ucode") return {};
62
+ return { ...(text(setting.model_provider) ? { UFOO_UCODE_PROVIDER: text(setting.model_provider) } : {}),
63
+ ...(text(setting.reasoning_effort) ? { UFOO_UCODE_THINKING: text(setting.reasoning_effort) } : {}) };
64
+ }
65
+
66
+ module.exports = { validateModelConfig, resolveGroupModelConfig, buildGroupModelArgs, buildGroupModelEnv };
@@ -2,6 +2,7 @@
2
2
 
3
3
  const ALLOWED_AGENT_TYPES = new Set(["auto", "codex", "claude", "ucode", "agy", "grok", "kimi"]);
4
4
  const { resolvePromptProfileReference } = require("./promptProfiles");
5
+ const { validateModelConfig } = require("./modelConfig");
5
6
 
6
7
  function isPlainObject(value) {
7
8
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
@@ -139,6 +140,7 @@ function validateTemplate(doc, options = {}) {
139
140
  }
140
141
 
141
142
  const nickname = asTrimmedString(agent.nickname);
143
+ errors.push(...validateModelConfig(agent.model_config, `${basePath}.model_config`));
142
144
  if (!nickname) {
143
145
  addError(errors, `${basePath}.nickname`, "nickname is required");
144
146
  } else if (knownNicknames.has(nickname)) {