u-foo 3.1.7 → 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.
Files changed (266) hide show
  1. package/OBSERVABILITY.md +65 -0
  2. package/README.md +238 -21
  3. package/README.zh-CN.md +165 -20
  4. package/SKILLS/ufoo/SKILL.md +40 -4
  5. package/SKILLS/ufoo-bus/SKILL.md +46 -3
  6. package/bin/uclaude.js +4 -0
  7. package/bin/ucodex.js +4 -0
  8. package/bin/ufoo.js +6 -4
  9. package/dist/tui/darwin-arm64/ufoo-tui +0 -0
  10. package/dist/tui/darwin-x64/ufoo-tui +0 -0
  11. package/dist/tui/linux-arm64/ufoo-tui +0 -0
  12. package/dist/tui/linux-x64/ufoo-tui +0 -0
  13. package/package.json +14 -7
  14. package/scripts/postinstall-skills.js +53 -0
  15. package/scripts/postinstall.js +11 -16
  16. package/scripts/smoke-native-messages.js +214 -0
  17. package/src/agents/activity/activityDetector.js +1 -1
  18. package/src/agents/activity/activityStateWriter.js +37 -38
  19. package/src/agents/capabilities/agentManagement/index.js +4 -0
  20. package/src/agents/capabilities/agentManagement/service.js +140 -0
  21. package/src/agents/capabilities/agentRouting/index.js +4 -0
  22. package/src/agents/capabilities/coding/index.js +32 -0
  23. package/src/agents/capabilities/coordination/index.js +37 -0
  24. package/src/agents/capabilities/globalRouting/index.js +5 -0
  25. package/src/agents/capabilities/groups/index.js +3 -0
  26. package/src/agents/capabilities/index.js +25 -0
  27. package/src/agents/capabilities/planning/index.js +123 -0
  28. package/src/agents/capabilities/planning/main.js +28 -0
  29. package/src/agents/capabilities/projectDiscovery/index.js +3 -0
  30. package/src/agents/capabilities/scheduling/index.js +3 -0
  31. package/src/agents/capabilities/sharedMemory/index.js +4 -0
  32. package/src/agents/capabilities/skills/index.js +12 -0
  33. package/src/agents/capabilities/taskExecution/index.js +3 -0
  34. package/src/agents/capabilities/taskReports/index.js +6 -0
  35. package/src/agents/controller/controllerToolExecutor.js +40 -22
  36. package/src/agents/controller/index.js +1 -6
  37. package/src/agents/internal/internalRunner.js +181 -76
  38. package/src/agents/launch/index.js +0 -1
  39. package/src/agents/launch/launcher.js +96 -14
  40. package/src/agents/launch/nativeCapabilities.js +40 -0
  41. package/src/agents/launch/nativeMessages.js +362 -0
  42. package/src/agents/launch/notifier.js +15 -20
  43. package/src/agents/launch/readyDetector.js +28 -14
  44. package/src/agents/profiles/coding.js +6 -0
  45. package/src/agents/profiles/globalRouter.js +2 -0
  46. package/src/agents/profiles/main.js +5 -0
  47. package/src/agents/prompts/cooperation.js +14 -0
  48. package/src/agents/prompts/defaultBootstrap.js +1 -1
  49. package/src/agents/prompts/groupBootstrap.js +32 -6
  50. package/src/agents/prompts/mainAgent.js +48 -0
  51. package/src/agents/prompts/native/system.js +4 -1
  52. package/src/agents/prompts/native/tasks.js +2 -2
  53. package/src/agents/prompts/native/ufoo.js +14 -3
  54. package/src/agents/prompts/promptProfiles.js +2 -0
  55. package/src/agents/prompts/reporting.js +16 -0
  56. package/src/agents/providers/claudeEventTranslator.js +9 -1
  57. package/src/agents/providers/claudeThreadProvider.js +47 -4
  58. package/src/agents/providers/clientIdentity.js +75 -0
  59. package/src/agents/providers/codexEventTranslator.js +68 -7
  60. package/src/agents/providers/codexThreadProvider.js +18 -8
  61. package/src/agents/providers/credentials/claude.js +10 -3
  62. package/src/agents/providers/credentials/index.js +2 -0
  63. package/src/agents/providers/directAuthStatus.js +1 -1
  64. package/src/agents/providers/index.js +1 -1
  65. package/src/agents/providers/modelSettings.js +34 -0
  66. package/src/agents/providers/modelsCatalog.js +379 -0
  67. package/src/agents/providers/nativeTransport.js +1146 -0
  68. package/src/agents/providers/runtimeConfig.js +188 -0
  69. package/src/agents/providers/thinkingLevels.js +106 -0
  70. package/src/agents/providers/transports/anthropicMessagesTransport.js +121 -0
  71. package/src/agents/providers/transports/index.js +10 -0
  72. package/src/agents/providers/transports/openaiChatTransport.js +117 -0
  73. package/src/agents/providers/transports/openaiResponsesTransport.js +120 -0
  74. package/src/agents/providers/transports/responsesProtocol.js +504 -0
  75. package/src/agents/providers/transports/systemBlocks.js +16 -0
  76. package/src/agents/providers/transports/transportContract.js +50 -0
  77. package/src/agents/providers/transports/visionBlocks.js +151 -0
  78. package/src/agents/providers/upstreamRuntime.js +135 -0
  79. package/src/agents/runtime/composeCapabilities.js +89 -0
  80. package/src/agents/runtime/context/checkpointStore.js +38 -0
  81. package/src/agents/runtime/context/commandStore.js +43 -0
  82. package/src/agents/runtime/context/compaction.js +151 -0
  83. package/src/agents/runtime/context/contextBudget.js +93 -0
  84. package/src/agents/runtime/context/contextWindow.js +119 -0
  85. package/src/agents/runtime/context/fileLock.js +36 -0
  86. package/src/agents/runtime/context/replayHistory.js +28 -0
  87. package/src/agents/runtime/context/runtimeStore.js +127 -0
  88. package/src/agents/runtime/context/sessionJournal.js +360 -0
  89. package/src/agents/runtime/context/sessionStore.js +57 -0
  90. package/src/agents/runtime/core/agentLoop.js +351 -0
  91. package/src/agents/runtime/core/executionBudget.js +36 -0
  92. package/src/agents/runtime/core/stableJson.js +29 -0
  93. package/src/agents/runtime/core/toolLoopGuard.js +55 -0
  94. package/src/agents/runtime/createAgentRuntime.js +259 -0
  95. package/src/agents/runtime/index.js +14 -0
  96. package/src/agents/runtime/prompts/responseLanguage.js +12 -0
  97. package/src/agents/runtime/protocol/faultHarness.js +90 -0
  98. package/src/agents/runtime/protocol/materialize.js +107 -0
  99. package/src/agents/runtime/protocol/runObservation.js +24 -0
  100. package/src/agents/runtime/protocol/toolCallLedger.js +221 -0
  101. package/src/agents/runtime/protocol/traceContext.js +9 -0
  102. package/src/agents/runtime/tasks/resourceLease.js +66 -0
  103. package/src/agents/runtime/tasks/scheduler.js +73 -0
  104. package/src/agents/runtime/tools/registry.js +57 -0
  105. package/src/app/chat/ChatController.js +29 -45
  106. package/src/app/chat/agentDirectory.js +9 -18
  107. package/src/app/chat/bootstrap.js +1 -2
  108. package/src/app/chat/commandExecutor.js +111 -313
  109. package/src/app/chat/commands.js +39 -45
  110. package/src/app/chat/daemonConnection.js +58 -5
  111. package/src/app/chat/daemonMessageRouter.js +61 -48
  112. package/src/app/chat/historyStore.js +12 -48
  113. package/src/app/chat/inputSubmitHandler.js +21 -35
  114. package/src/app/chat/internalAgentLogHistory.js +19 -60
  115. package/src/app/chat/launchRequestContext.js +42 -0
  116. package/src/app/chat/multiWindow/paneManager.js +91 -164
  117. package/src/app/chat/streamState.js +3 -7
  118. package/src/app/chat/transport.js +1 -1
  119. package/src/app/cli/busCoreCommands.js +9 -0
  120. package/src/app/cli/features/doctor.js +33 -0
  121. package/src/app/cli/features/init.js +5 -5
  122. package/src/app/cli/features/skills.js +16 -4
  123. package/src/app/cli/metricsCommands.js +68 -0
  124. package/src/app/cli/reportCoreCommands.js +37 -0
  125. package/src/app/cli/run.js +82 -42
  126. package/src/app/cli/traceCommands.js +36 -0
  127. package/src/code/agent.js +34 -17
  128. package/src/code/busConsumer.js +1 -3
  129. package/src/code/commands.js +1 -1
  130. package/src/code/context/artifacts.js +12 -11
  131. package/src/code/context/assembler.js +9 -9
  132. package/src/code/context/promptLayers.js +1 -13
  133. package/src/code/context/stableJson.js +2 -27
  134. package/src/code/context/stateCommit.js +2 -1
  135. package/src/code/contextWindow.js +2 -117
  136. package/src/code/conversation/sessionJournal.js +3 -349
  137. package/src/code/internalThread.js +107 -0
  138. package/src/code/launcher/ucode.js +1 -1
  139. package/src/code/launcher/ucodeBootstrap.js +1 -1
  140. package/src/code/modelCommand.js +11 -35
  141. package/src/code/nativeRunner.js +104 -2697
  142. package/src/code/protocol/faultHarness.js +2 -88
  143. package/src/code/protocol/materialize.js +2 -105
  144. package/src/code/protocol/toolCallLedger.js +5 -215
  145. package/src/code/providers/anthropicMessagesTransport.js +2 -118
  146. package/src/code/providers/modelsCatalog.js +1 -317
  147. package/src/code/providers/openaiChatTransport.js +2 -114
  148. package/src/code/providers/openaiResponsesTransport.js +2 -117
  149. package/src/code/providers/responsesProtocol.js +2 -497
  150. package/src/code/providers/transportContract.js +2 -48
  151. package/src/code/providers/visionBlocks.js +2 -149
  152. package/src/code/repl.js +2 -11
  153. package/src/code/sessionStore.js +27 -99
  154. package/src/code/taskDecomposer.js +18 -0
  155. package/src/code/thinkingLevels.js +1 -130
  156. package/src/code/toolBudget.js +1 -17
  157. package/src/code/toolLoopGuard.js +3 -49
  158. package/src/code/tools/artifactRead.js +1 -1
  159. package/src/code/tools/executor.js +373 -0
  160. package/src/code/tools/specs.js +312 -0
  161. package/src/config.js +95 -131
  162. package/src/coordination/bus/deliveryQueue.js +16 -2
  163. package/src/coordination/bus/index.js +14 -9
  164. package/src/coordination/bus/inject.js +15 -7
  165. package/src/coordination/bus/message.js +15 -1
  166. package/src/coordination/bus/nativeReceipts.js +100 -0
  167. package/src/coordination/bus/nickname.js +1 -1
  168. package/src/coordination/bus/queue.js +1 -3
  169. package/src/coordination/bus/subscriber.js +3 -2
  170. package/src/coordination/bus/utils.js +8 -4
  171. package/src/coordination/history/agentPerformance.js +279 -0
  172. package/src/coordination/history/agentSurface.js +142 -0
  173. package/src/coordination/history/agentTrace.js +249 -0
  174. package/src/coordination/memory/index.js +5 -21
  175. package/src/coordination/report/store.js +103 -83
  176. package/src/coordination/state/agentsStore.js +57 -3
  177. package/src/coordination/state/fileLock.js +2 -0
  178. package/src/coordination/state/workspaceAccess.js +36 -0
  179. package/src/orchestration/controller/index.js +1 -8
  180. package/src/orchestration/controller/launchRouting.js +1 -1
  181. package/src/orchestration/solo/commands.js +3 -1
  182. package/src/runtime/contracts/agentMode.js +26 -0
  183. package/src/runtime/contracts/eventContract.js +3 -0
  184. package/src/runtime/contracts/uiProtocol.js +20 -17
  185. package/src/runtime/daemon/agentHost.js +407 -0
  186. package/src/runtime/daemon/agentRecoveryGroups.js +70 -0
  187. package/src/runtime/daemon/busBridge.js +396 -0
  188. package/src/runtime/daemon/claudeChannel.js +159 -0
  189. package/src/runtime/daemon/controlPlaneService.js +28 -18
  190. package/src/runtime/daemon/cronOps.js +25 -17
  191. package/src/runtime/daemon/deliveryScheduler.js +32 -5
  192. package/src/runtime/daemon/globalDaemon.js +28 -1
  193. package/src/runtime/daemon/groupOrchestrator.js +21 -5
  194. package/src/runtime/daemon/groupStatus.js +20 -0
  195. package/src/runtime/daemon/index.js +120 -375
  196. package/src/runtime/daemon/ipcServer.js +32 -10
  197. package/src/runtime/daemon/mcpConfigure.js +113 -20
  198. package/src/runtime/daemon/mcpHttpServer.js +27 -5
  199. package/src/runtime/daemon/mcpServer.js +8 -5
  200. package/src/runtime/daemon/mcpStdioProxy.js +127 -10
  201. package/src/runtime/daemon/nicknameScope.js +1 -1
  202. package/src/runtime/daemon/ops.js +68 -40
  203. package/src/runtime/daemon/projectRuntimeGateway.js +2 -0
  204. package/src/runtime/daemon/promptRequest.js +92 -570
  205. package/src/runtime/daemon/providerSessions.js +67 -33
  206. package/src/runtime/daemon/reportControlBus.js +59 -25
  207. package/src/runtime/daemon/status.js +9 -6
  208. package/src/runtime/privacy/redactor.js +2 -2
  209. package/src/runtime/projects/identity.js +2 -1
  210. package/src/runtime/projects/registry.js +98 -38
  211. package/src/tools/controllerSchemas.js +28 -0
  212. package/src/tools/handlers/dispatchMessage.js +5 -2
  213. package/src/tools/handlers/listAgents.js +3 -1
  214. package/src/tools/handlers/readBusSummary.js +3 -1
  215. package/src/tools/handlers/readProjectRegistry.js +29 -2
  216. package/src/tools/handlers/routeAgent.js +35 -0
  217. package/src/tools/handlers/tier2.js +4 -2
  218. package/src/tools/index.js +1 -0
  219. package/src/tools/registry.js +6 -0
  220. package/src/tools/schemaFixtures.js +42 -5
  221. package/src/tools/tier0/readAgentMetrics.js +14 -0
  222. package/src/tools/tier0/readAgentTrace.js +12 -0
  223. package/src/tools/tier1/routeAgent.js +2 -2
  224. package/src/tools/tier2/runtimeCoordination.js +38 -0
  225. package/src/tools/types.js +2 -0
  226. package/src/ui/agentPresentation.js +109 -0
  227. package/src/ui/agentSettingsController.js +107 -0
  228. package/src/ui/agentSurface.js +270 -0
  229. package/src/ui/dashboardBridge.js +1 -1
  230. package/src/ui/format/banner.js +9 -15
  231. package/src/ui/format/index.js +14 -10
  232. package/src/ui/format/loopSummary.js +50 -0
  233. package/src/ui/format/markdownRenderer.js +3 -4
  234. package/src/ui/format/startupBanner.js +50 -0
  235. package/src/ui/multiPaneBusMirror.js +29 -3
  236. package/src/ui/rustChatHost.js +316 -599
  237. package/src/ui/rustMultiSession.js +288 -73
  238. package/src/ui/rustUcodeHost.js +21 -88
  239. package/src/ui/settingsBridge.js +34 -14
  240. package/src/ui/toolMergeBridge.js +0 -4
  241. package/src/ui/uiHostServer.js +5 -8
  242. package/src/agents/controller/loopObservability.js +0 -200
  243. package/src/agents/controller/loopRuntime.js +0 -472
  244. package/src/agents/controller/ufooAgent.js +0 -829
  245. package/src/agents/launch/ptyRunner.js +0 -1135
  246. package/src/agents/providers/upstreamTransport.js +0 -689
  247. package/src/app/chat/agentBar.js +0 -135
  248. package/src/app/chat/agentEnter.js +0 -70
  249. package/src/app/chat/agentSockets.js +0 -225
  250. package/src/app/chat/dashboardView.js +0 -405
  251. package/src/app/chat/multiWindow/index.js +0 -310
  252. package/src/app/chat/multiWindow/paneLayout.js +0 -84
  253. package/src/app/chat/multiWindow/renderer.js +0 -420
  254. package/src/app/chat/multiWindow/virtualTerminal.js +0 -327
  255. package/src/app/chat/multiWindow/vtFrame.js +0 -93
  256. package/src/app/chat/rawKeyMap.js +0 -42
  257. package/src/app/chat/settingsController.js +0 -111
  258. package/src/orchestration/controller/flags.js +0 -167
  259. package/src/orchestration/controller/gateRouter.js +0 -211
  260. package/src/orchestration/controller/routerFastPath.js +0 -22
  261. package/src/orchestration/controller/routerFinalize.js +0 -222
  262. package/src/orchestration/controller/shadowGuard.js +0 -280
  263. package/src/runtime/daemon/promptLoop.js +0 -136
  264. package/src/runtime/privacy/shadowDiff.js +0 -174
  265. package/src/ui/multiWindowHandoff.js +0 -232
  266. package/src/ui/ptyHandoff.js +0 -23
@@ -0,0 +1,65 @@
1
+ # ufoo agent 表现观测
2
+
3
+ 观测用于定位行为、建立基线和比较优化前后的表现。执行完成、worker 报告完成和主 agent 验收通过是三个不同的事实,不合并成一个“成功率”。指标不自动判断代码质量,也不触发重试、投递、消费消息或验收。
4
+
5
+ ## 使用
6
+
7
+ ```sh
8
+ # 当前项目汇总;完全本地查询,无模型请求,也不启动 daemon
9
+ ufoo metrics
10
+
11
+ # 查一个任务及其子任务,或一个 agent
12
+ ufoo metrics <task-id> --json
13
+ ufoo metrics --agent reviewer --json
14
+
15
+ # 时间窗口按运行开始时间选择,保留选中运行的完整可见生命周期
16
+ ufoo metrics --since 2026-10-11T00:00:00Z --until 2026-10-12T00:00:00Z --json
17
+
18
+ # 保存基线、之后比较
19
+ ufoo metrics --json > baseline.json
20
+ ufoo metrics --baseline baseline.json --json > comparison.json
21
+
22
+ # 从汇总定位到过程和经过脱敏的工具参数/结果
23
+ ufoo trace <task-id> --details --json
24
+ ufoo trace --agent reviewer --follow --json
25
+ ```
26
+
27
+ MCP 提供只读 `read_agent_metrics`;`read_agent_trace` 的结果及 JSONL follow 状态也包含表现汇总。指标与 trace 来自同一批 journal、worker surface、报告和队列。分页只限制返回的运行记录:默认最近 20 条,`--limit` 最大 100,汇总使用全部已读取且匹配的运行。Trace 附带汇总不返回完整运行列表。
28
+
29
+ ## 指标口径
30
+
31
+ | 维度 | 观测内容 | 解释 |
32
+ |---|---|---|
33
+ | 执行 | completed、failed、cancelled、interrupted、running、waiting_user、queued | 每个 taskRunId 只计一次;恢复后续执行仍属于原运行。completedOfFinished 的分母只包括四种结束状态。 |
34
+ | 响应 | 排队、首段文字、首段思考摘要、总耗时、活动时间、等待用户时间 | 时间单位为毫秒;首段文字是已观察到的文本输出,不保证是给用户的最终回复。缺失起点/终点返回 null。 |
35
+ | 模型 | 主模型调用、SDK turns、失败、空回复重试、上下文溢出重试、自动续跑 | SDK 内部 HTTP 次数不可见,不推算。模型阶段与工具阶段累计耗时是服务时间,不能当作互不重叠的总耗时分解。 |
36
+ | 工具 | 执行、错误、执行异常、校验拒绝、未配对调用、相同工具参数重复、loop guard 警告/停止 | 执行异常单独计数并保留副作用未知的状态。同参数重复是调查线索,合法轮询或重读也可能重复。进行中的工具及等待用户的工具可以暂时未配对;这不等于失败。 |
37
+ | 用量 | input、output、cacheRead、cacheCreation | 按已有 provider 解析器的字段语义分别汇总,不把 SDK/API 数据或缓存字段重复相加。未回传 usage 不按零计算。部分回传仅汇总可见部分,并标出完整用量覆盖率;不估算费用。 |
38
+ | 缓存 | cache.hitRate、cachedTokens、promptTokens、样本和完整覆盖率 | 按 tokens 加权:命中 tokens 总量 / 同批样本的输入总量。OpenAI 的输入总量已含缓存;Anthropic 的分母为 input + cacheRead + cacheCreation。缺少缓存字段或无法确定输入口径的样本不参加缓存率计算;明确回传 cached_tokens=0 才能作为零命中样本。压缩缓存另列 compactionCache。 |
39
+ | 压缩 | 尝试、完成、失败、耗时、压缩调用用量 | 压缩用量单独放在 compactionUsage,避免藏在主模型用量里。 |
40
+ | 协作 | 委派数、报告数、待验收、accepted、rejected、投递不确定、报告到验收延迟 | acceptedOfReviewed = accepted / (accepted + rejected);没有验收样本时为 null。不会用 done 报告代替 accepted。 |
41
+ | 输出 | 流式文字量、最终回复长度、报告长度 | 按 Unicode 字符计数;报告超过协议默认 600 字符会出现 long_report 线索。最终回复与过程流分开计数。 |
42
+ | 活动 | 最后事件距今时间、队列年龄 | running 五分钟无可见事件会标出线索;模型/SDK 可能仍在工作,不自动判定卡死。排队耗时只来自 request.accepted 或精确匹配的 bus sequence。 |
43
+
44
+ 每个运行记录包含 provider、model、thinking、ufoo 版本、执行循环/SDK runner 指纹、实际提示词和工具 schema 指纹、输入指纹,以及请求类型。主 agent 区分用户请求、worker 报告唤醒、独立编码任务和任务结果唤醒;无法辨认的来源保留 unknown。面板 worker 区分已指派任务和其他 bus 消息。配置记录只保留这些元数据和指纹,不新增凭据、header、URL 或提示词正文。
45
+
46
+ Provider/model、thinking、版本、执行引擎指纹、请求类型形成 cohort,API 与 SDK 分开聚合。提示词指纹包含运行时上下文,适合查明某次运行实际用了哪份输入,不应当作稳定实验分组。引擎指纹覆盖共享循环或 SDK runner 函数,不能代表整个仓库或 SDK 内部实现;依赖或其他 host/capability 改动仍需保存源码版本。
47
+
48
+ ## 后续优化方法
49
+
50
+ 1. 选一组固定的开发任务,保存任务说明、仓库起点、预期产物和验证命令;同时覆盖直接编码、委派、group、错误纠正和长会话。
51
+ 2. 固定模型、thinking、凭据来源和任务环境;运行后保存 metrics JSON、精确任务的 trace,以及代码 diff 和验证结果。
52
+ 3. 一次改一个变量,例如系统提示词、路由策略、报告约束或压缩策略;复跑同一任务集。
53
+ 4. 对比验收、错误和重复行为,再看耗时、用量及输出长度;同时人工检查真实产物。快、少 tokens 或短报告本身不代表质量提高。
54
+
55
+ `--baseline` 输出指标差值和变化比例;不同任务、样本量、模型或不完整来源可能影响结果,因此它是观测差异,不是因果结论。没有真实质量评分或独立验收的数据,不生成质量评分。
56
+
57
+ 缓存统计同时出现在 CLI、JSON、MCP 和各个 cohort。缓存率只使用同时具备命中量和可确定输入总量的样本,旁边显示样本覆盖情况。基线缓存率比较要求双方所有运行具有完整缓存观测,否则差值保留 null。Responses API 读取 `usage.input_tokens_details.cached_tokens`,Chat Completions 读取 `usage.prompt_tokens_details.cached_tokens`;写缓存 tokens 计入 cacheCreation,不当作缓存命中。指标口径参考 [OpenAI 官方缓存文档](https://developers.openai.com/api/docs/guides/prompt-caching)。旧解析器遗漏后写成零的日志无法还原真实命中量;修复作用于新请求。
58
+
59
+ ## 数据与边界
60
+
61
+ 源数据使用已有 `.ufoo/agent/*/runtimes/*/events.jsonl`、bus surface、`reports.jsonl` 和活动队列,不引入第二份可变执行状态。旧日志仍可查询,缺少配置、身份关联或生命周期时使用 unknown/null 和 coverage;不补造旧事件。queues 是查询当下的待处理/已领取消息快照,不是时间窗口内的历史队列重建,provider/model 过滤也不改变这份快照。
62
+
63
+ 查询沿用 trace 的读取限制:最多 200 个 runtime journal、14 个 bus 日文件、每文件 2 MiB、总计 32 MiB。截断、损坏记录和读取失败会出现在 warnings/incomplete;指标仅代表已读取的样本。最多返回 100 个 cohort,超出时同样告知。没有事件的项目也不被初始化或修复。
64
+
65
+ 源代码入口:`src/agents/runtime/protocol/runObservation.js` 生成配置指纹;共享循环和 internal runner 写既有观测事件;`src/coordination/history/agentTrace.js` 读取并归一化;`agentPerformance.js` 计算指标;`src/app/cli/metricsCommands.js` 与共享 MCP 工具提供查询。
package/README.md CHANGED
@@ -2,10 +2,11 @@
2
2
 
3
3
  [中文](README.zh-CN.md)
4
4
 
5
- ufoo is a project-scoped multi-agent workspace runtime. It wraps Claude Code,
6
- OpenAI Codex, Antigravity, Grok Build, Kimi Code, and ufoo's native `ucode`
7
- agent with a shared chat dashboard, daemon, event bus, memory, reports, group
8
- orchestration, and terminal launch modes.
5
+ ufoo is a project-scoped multi-agent workspace runtime with two ways to work.
6
+ Keep using Claude Code, OpenAI Codex, and other supported CLIs through wrappers
7
+ and MCP for messages and shared context. Or open the ufoo dashboard to work with
8
+ a main agent and internal Codex, Claude, and `ucode` agents in one terminal.
9
+ Both share a daemon, event bus, memory, reports, and group orchestration.
9
10
 
10
11
  Package: [u-foo on npm](https://www.npmjs.com/package/u-foo)
11
12
 
@@ -17,14 +18,16 @@ Package: [u-foo on npm](https://www.npmjs.com/package/u-foo)
17
18
 
18
19
  ## Highlights
19
20
 
20
- - One TUI dashboard for launching, watching, messaging, and resuming agents.
21
+ - One TUI dashboard for a main agent and internal child agents, with shared input,
22
+ live output, status, and three layouts.
21
23
  - One user-scoped daemon over `~/.ufoo/run/ufoo.sock`, hosting isolated project
22
24
  runtimes for launch/resume, reports, groups, cron, and controller routing.
23
25
  - Project-local event bus for agent-to-agent messages, wakeups, queue checks,
24
26
  and activation.
25
27
  - Shared context primitives: decisions, durable memory, prompt history, reports,
26
28
  and agent registry state.
27
- - Launch modes for internal, tmux, host, Terminal.app, and iTerm2 workflows.
29
+ - Wrappers and MCP keep external CLI workflows connected; dashboard child agents
30
+ run internally without opening external terminals.
28
31
  - Built-in group templates for launching and orchestrating multi-agent workflows.
29
32
  - `ucode`, a native ufoo coding-agent runtime.
30
33
  - One loopback Streamable HTTP MCP server inside the home-scoped global
@@ -32,7 +35,7 @@ Package: [u-foo on npm](https://www.npmjs.com/package/u-foo)
32
35
 
33
36
  ## Requirements
34
37
 
35
- - Node.js 18 or newer.
38
+ - Node.js 18.17 or newer.
36
39
  - macOS for Terminal.app/iTerm2 integration.
37
40
  - Claude Code, Codex CLI, Antigravity CLI, Grok Build, or Kimi Code installed
38
41
  when using the matching wrappers: `uclaude`, `ucodex`, `uagy`, `ugrok`, or
@@ -52,6 +55,7 @@ Or link this repository for local development:
52
55
  git clone https://github.com/Icyoung/ufoo.git
53
56
  cd ufoo
54
57
  npm install
58
+ npm run pack:tui
55
59
  npm link
56
60
  ```
57
61
 
@@ -124,7 +128,9 @@ ufoo mcp configure codex
124
128
  ```
125
129
 
126
130
  The configuration points all three Codex surfaces at the same authenticated
127
- loopback endpoint. Restart the Codex surface after configuring it.
131
+ loopback endpoint. Existing ufoo authentication fields and headers are retained.
132
+ Use `ufoo mcp configure codex --dry-run` to preview the change with credentials
133
+ redacted. Restart the Codex surface after configuring it.
128
134
 
129
135
  For a host that has not been verified with direct HTTP, keep the compatible
130
136
  stdio configuration:
@@ -173,6 +179,10 @@ inherited `UFOO_SUBSCRIBER_ID` before any helper terminal is started:
173
179
  activity and injection endpoint, so bus messages can be injected directly.
174
180
  These Agents reuse the environment identity and do not register through MCP
175
181
  or run a resident bus poll.
182
+ Current wrappers also provide `UFOO_AGENT_HANDLE` so the Agent can use the
183
+ shared MCP `dispatch_message`, `ack_bus`, and `report_agent_status` tools.
184
+ The CLI remains available when MCP is not configured. Receive, activity,
185
+ and shutdown stay with the wrapper.
176
186
  - Externally hosted Agents have no wrapper-provided subscriber environment.
177
187
  They register themselves once through MCP `register_agent`, retain the
178
188
  returned subscriber plus opaque `agent_handle`, and select the host App's
@@ -191,6 +201,72 @@ Chat is a UI client. The daemon owns project runtime state. Agents communicate
191
201
  through bus queues, prompt injection, shared memory, reports, and tool handlers
192
202
  instead of importing chat UI code.
193
203
 
204
+ MCP sends confirm durable queue persistence, not delivery or task completion.
205
+ The result reports `delivery_status: "queued"`, `queued: <target count>`, and
206
+ `delivered: 0`. Registry reads return up to 100 existing project paths per page;
207
+ follow `next_offset` for more, or set `include_missing: true` for diagnostics.
208
+ To archive abandoned records for deleted workspaces, preview with
209
+ `ufoo project prune`, then run `ufoo project prune --apply`. Original JSON
210
+ records remain recoverable under `~/.ufoo/projects/archive/`.
211
+
212
+ The stdio proxy reconnects after listener restarts and preserves the Agent's
213
+ registration. It automatically replays reads; an uncertain write returns
214
+ `UFOO_MCP_OUTCOME_UNKNOWN` so its persisted result can be checked before retrying.
215
+ Run `ufoo doctor` to detect outdated Codex MCP configuration, and
216
+ `ufoo mcp configure codex` to refresh it with a backup.
217
+
218
+ Codex and Claude Code wrappers use native incoming-message transports by
219
+ default for interactive launches on macOS/Linux:
220
+
221
+ ```bash
222
+ ucodex
223
+ uclaude
224
+ ```
225
+
226
+ Codex connects its TUI to a private local app-server. ufoo observes the TUI's
227
+ exact thread response, preserves its requests and approvals, and sends bus
228
+ work through `thread/queue/add`. Claude uses a launch-local stdio MCP channel
229
+ and retains Claude's development-channel confirmation. Its startup probe must
230
+ arrive through the native channel before any bus work is sent. Channels are a
231
+ [Claude research preview](https://code.claude.com/docs/en/channels); account and
232
+ organization availability rules still apply. Existing MCP configuration and
233
+ credentials remain intact; these launches do not write global host settings.
234
+
235
+ Native receivers admit work while busy. A queue receipt confirms transport
236
+ acceptance, not task completion. Stable delivery IDs and project-local native
237
+ receipts prevent duplicate retries; uncertain writes retain the bus event for
238
+ inspection rather than falling back to keyboard injection. The wrapper still
239
+ owns terminal rendering, identity, activity, and shutdown. Use
240
+ `--no-native-messages` or `UFOO_NATIVE_MESSAGES=0` to select the existing delivery
241
+ path; `--native-messages` explicitly overrides that environment setting.
242
+ Headless commands such as `ucodex exec` and `uclaude --print`, help/version,
243
+ internal agents, and other providers keep their existing launch behavior.
244
+ Launchers check CLI versions against the tested baselines (Codex 0.160.1 and
245
+ Claude Code 2.1.204), and check Codex remote support. Older CLIs use legacy
246
+ delivery with a diagnostic; explicit `--native-messages` requires compatibility.
247
+ `ufoo doctor` shows versions, receiver readiness, and uncertain receipts.
248
+
249
+ Inspect or explicitly resolve an uncertain receipt:
250
+
251
+ ```bash
252
+ ufoo bus deliveries <subscriber>
253
+ ufoo bus deliveries <subscriber> <receipt-id> accepted
254
+ ufoo bus deliveries <subscriber> <receipt-id> retry
255
+ ```
256
+
257
+ Use `accepted` after verifying the receiving session got the work. `retry`
258
+ allows another submission and can duplicate work if the first submission
259
+ succeeded. A live in-flight submission cannot be resolved.
260
+
261
+ Codex resume pickers and `resume --last` bind the exact session returned by the
262
+ TUI after selection.
263
+
264
+ The integration tests use real Unix sockets, WebSockets, and stdio MCP. Optional
265
+ vendor CLI smoke tests use isolated homes and a fake local model endpoint:
266
+ `node scripts/smoke-native-messages.js codex` and
267
+ `node scripts/smoke-native-messages.js claude`. Verified locally with Codex
268
+ 0.160.1 and Claude Code 2.1.204.
269
+
194
270
  ## Daily Usage
195
271
 
196
272
  The normal workflow is to enter chat first, then launch agents and run project
@@ -205,6 +281,20 @@ ufoo -g
205
281
  between registered projects. The global daemon starts once and project runtimes
206
282
  activate lazily.
207
283
 
284
+ The project main agent shares a composable runtime with `ucode`. It can read and
285
+ edit code, run validation, delegate to internal agents, or start independent
286
+ tasks. The global profile selects projects before coding begins. Long tasks run
287
+ in the daemon; disconnecting chat does not cancel them, and reconnecting replays
288
+ runtime events.
289
+
290
+ All main conversations use the shared runtime. Use `/session new` to start a
291
+ conversation with current settings; existing provider/model bindings stay pinned.
292
+ A crash during an active round marks it interrupted: inspect actual
293
+ effects before resubmitting. Writes, shell commands, launches, and uncertain
294
+ deliveries are not automatically replayed. Managed writers share directory
295
+ leases; verified git worktrees can run independently. These checks are not an OS
296
+ sandbox for shell commands. See the [runtime implementation record](AGENT_RUNTIME_REFACTOR.md).
297
+
208
298
  ### Chat Commands
209
299
 
210
300
  ```text
@@ -215,14 +305,71 @@ activate lazily.
215
305
  @reviewer inspect the current diff and list release risks
216
306
 
217
307
  /status
308
+ /task list
309
+ /task inspect <run-id>
310
+ /task cancel <run-id>
311
+ /answer <interaction-id> <reply>
312
+ /session show
313
+ /session new
218
314
  /settings
219
- /multi
220
- /resume list
315
+ /window main
316
+ /window side
317
+ /window multi
318
+ /resume
221
319
  /project list
222
320
  /project switch 2
223
321
  /open /path/to/project
224
322
  ```
225
323
 
324
+ The dashboard keeps three layouts: `main` (main agent only), `side` (main plus
325
+ one selected internal agent), and `multi` (main plus all internal agents). Wrapper and MCP agents stay
326
+ outside the dashboard. Dashboard child launches use internal mode and never
327
+ open an external terminal. A project with no chat or input history shows the
328
+ existing compact ufoo banner as its welcome screen.
329
+ `Ctrl+W` cycles `main → side → multi → main`.
330
+ `/window main`, `/window side` and `/window multi`
331
+ select each layout directly. The one-child layout selects the most recently
332
+ activated live internal agent, or the first agent when none has been activated.
333
+ With no children, split modes remain selected while showing only the full-width
334
+ main pane; new children appear automatically when they become available.
335
+ In either split layout, `Esc` and `Ctrl+C` first leave the footer if it has focus,
336
+ then return child focus to the main agent, then close the split. Drafts and
337
+ running tasks are preserved while moving through these layers. Both keys also
338
+ dismiss command completion and follow the main input's cancellation and project
339
+ return layers. At the main-only root, `Esc` keeps the application open and only
340
+ `Ctrl+C` exits. `Ctrl+Q` or `/window main` closes either split directly.
341
+ Drag over visible text in the main or an internal agent pane to select it;
342
+ releasing the mouse copies it to the clipboard. Selection stays within that pane,
343
+ excluding its border and adjacent agents. Local macOS uses the system clipboard;
344
+ other terminals use OSC 52 and require terminal clipboard support.
345
+ `/resume` opens a second-level menu of recoverable internal sessions. Independent
346
+ agents appear individually; group members appear together as `group:<group-id>`.
347
+ Selecting a group resumes its inactive members with saved sessions, skips members
348
+ that are already active, and updates the group's member identities. Native
349
+ coding agents register as `agent_type: ucode` with `ucode:<session>` identities;
350
+ their saved conversations remain under `.ufoo/agent/ucode/`.
351
+ `Tab` cycles keyboard focus through the main agent and the visible child panes;
352
+ all agents share one bottom input, which follows the selected agent while
353
+ preserving each draft. Each agent's live status sits in its pane's bottom border;
354
+ the main agent's input is labelled `main`, and its status stays independent of
355
+ child selection, focus changes and child activity.
356
+ Internal Codex enables network access within its workspace sandbox, including
357
+ local services such as ADB and Gradle. Peer replies contain the final answer;
358
+ progress and tool output stay visible in the agent's pane. Reports and handoffs
359
+ default to 1-4 short lines with checks and blockers; longer evidence is saved in
360
+ a referenced workspace file.
361
+ The selected pane's body uses the terminal's default foreground. In the main-only
362
+ layout, `Tab` selects the first agent in the bottom bar, then advances through
363
+ the agents and wraps to the first. `Esc` returns to
364
+ the main input. Command completion keeps its existing `Tab` behavior in the
365
+ main-only layout. An open completion menu also owns `Tab` in split layouts.
366
+ Layout commands also work from an internal child's input. Switching layouts
367
+ keeps unsent child drafts and does not stop running agents.
368
+ With a child active, `Down` from an empty input or a footer click opens the Agents
369
+ selector. `Down` then opens provider settings and cron controls; `Esc` returns to
370
+ the same agent's input. In the selector, `Enter` opens the selected internal
371
+ agent. The provider caption in the footer also opens its settings directly.
372
+
226
373
  Direct wrapper commands such as `uclaude`, `ucodex`, `uagy`, `ugrok`, `ukimi`, and
227
374
  `ucode` are still available, but the normal ufoo workflow is to work from chat.
228
375
 
@@ -312,7 +459,11 @@ remains available through the controller/CLI rename path.
312
459
  Both paths keep idle queue checks outside the LLM. A background PTY alone is
313
460
  not a wake mechanism in Codex App.
314
461
 
315
- The poll skill is not installed by postinstall or `skills install all`.
462
+ The poll skill is opt-in. Postinstall refreshes only verified ufoo-owned links;
463
+ user directories, files, and foreign links are preserved. `skills install all`
464
+ refreshes an already-installed optional skill with a backup, but does not
465
+ install it for a new host. Explicit skill installs retain previous contents in
466
+ a sibling `.backup-*` path.
316
467
  Wrapper-managed Agents skip MCP registration and external waiting when
317
468
  `UFOO_SUBSCRIBER_ID` was present in the Agent's inherited launch environment.
318
469
  A value exported later inside a Cursor listener terminal does not rerun this
@@ -344,11 +495,27 @@ ufoo history prompt 30
344
495
  ufoo report start "Implement README refresh" --task docs-readme --agent builder
345
496
  ufoo report done "README updated" --task docs-readme --agent builder
346
497
  ufoo report list
498
+
499
+ ufoo trace <task-id> --json
500
+ ufoo trace --agent <id-or-nickname> --follow
501
+ ufoo trace --details --limit 2000
347
502
  ```
348
503
 
349
504
  Use decisions only for plan-level constraints. Durable project facts belong in
350
505
  memory.
351
506
 
507
+ `trace` links parent/worker model and tool events, reports, queue claims and
508
+ context compression without starting a daemon or calling a model. MCP exposes
509
+ the same read-only view as `read_agent_trace`. Parameters and results are
510
+ redacted; bounded or incomplete source reads are explicitly marked in JSON.
511
+
512
+ `ufoo metrics --json` summarizes observed outcomes, latency, tokens, tool
513
+ errors/repetition, report size and delegation acceptance. Save a report and use
514
+ `ufoo metrics --baseline baseline.json --json` to compare later samples. MCP
515
+ provides `read_agent_metrics`; metric definitions and an optimization workflow
516
+ are in [OBSERVABILITY.md](OBSERVABILITY.md). Missing evidence stays unknown,
517
+ and execution completion is separate from acceptance.
518
+
352
519
  ### Groups
353
520
 
354
521
  Built-in group templates live in `templates/groups/`.
@@ -378,6 +545,17 @@ ufoo online inbox builder --unread
378
545
  The default public service URL is `https://online.ufoo.dev`. Local development
379
546
  can run its own relay with `ufoo online server`.
380
547
 
548
+ Internal Codex, Claude Code and ucode panes share the standalone ucode TUI's
549
+ transcript renderer and one bottom multiline input. Submitting immediately shows
550
+ loading; waiting, thinking, generating, tool execution, user interaction, errors,
551
+ elapsed time, context usage and plans follow the selected agent's actual events.
552
+ Provider-specific retry, compaction and background task events use the same status
553
+ surface. Text, thinking and tool
554
+ results update from provider events; Ctrl+O expands the newest thinking/tool
555
+ block in the focused pane. Display observations are separate from agent inboxes,
556
+ so peer-routed tasks remain visible without waking the main agent. Output and
557
+ drafts survive switching between main-only, focused-child and all-child layouts.
558
+
381
559
  ### Native ucode Runtime
382
560
 
383
561
  ```bash
@@ -400,23 +578,54 @@ Common project settings:
400
578
  {
401
579
  "launchMode": "auto",
402
580
  "agentProvider": "codex-cli",
403
- "controllerMode": "main",
404
- "codexInternalThreadMode": "api",
405
581
  "codexAuthPath": "",
406
582
  "codexOauthRefreshWindowSec": 300,
407
583
  "claudeOauthProfile": "",
408
584
  "claudeOauthTokenPath": "",
409
585
  "claudeOauthRefreshWindowSec": 300,
410
- "routerProvider": "",
411
- "routerModel": "",
412
586
  "agentModel": "",
413
- "autoResume": true
587
+ "autoResume": false
414
588
  }
415
589
  ```
416
590
 
591
+ Internal Codex and Claude always use their SDKs; there is no thread-mode setting.
592
+
417
593
  Supported `launchMode` values: `auto`, `internal`, `tmux`, `terminal`, and
418
- `host`. `controllerMode` accepts `main`, `shadow`, `loop`, and legacy
419
- compatibility values.
594
+ `host`. The dashboard supports internal Codex, Claude and ucode workers only; provider selections remain independent.
595
+
596
+ The dashboard always uses internal children and has no `/mode` command;
597
+ the binary has no `ufoo mode` command either.
598
+ Manual `ucodex` and `uclaude` wrappers detect tmux, host sessions, Terminal.app
599
+ and iTerm2 from their environment, then register the actual terminal type, TTY
600
+ and delivery channels with the daemon. Their event-bus communication works
601
+ without a dashboard. MCP agents communicate through MCP message interfaces
602
+ without requiring a terminal adapter.
603
+ The main agent uses one runtime for coding and routing, configured by
604
+ `agentProvider` and `agentModel`. `/settings agent` manages these settings;
605
+ `/settings ucode` manages the independent ucode gateway settings.
606
+
607
+ The bottom Settings bar includes `custom`, `model`, and `thinking`. Select
608
+ `custom` to enter an API URL and hidden API key, then choose its model and
609
+ thinking intensity. `/settings agent custom`, `/settings agent model`, and
610
+ `/settings agent thinking` open the same controls. Model menus fetch the current
611
+ provider's complete selectable catalog, including paginated results; Codex
612
+ menus omit entries marked hidden by the provider. Endpoints without a
613
+ models route also allow a manually entered model ID. Changing model or thinking
614
+ applies to the next request and keeps the current conversation. Changing provider
615
+ starts a new conversation, retaining the old one in runtime storage.
616
+ OpenAI thinking choices include separate `xhigh` and `max` values, preserved in
617
+ requests. When a provider uses a configured gateway, the model list comes from
618
+ that gateway; upgrading an agent SDK does not change the gateway's catalog.
619
+
620
+ Custom main-agent settings use `agentProvider: "custom"`, `agentBaseUrl`,
621
+ `agentApiKey`, `agentModel`, and `agentThinking` in `.ufoo/config.json`.
622
+ Custom APIs use OpenAI Chat Completions by default, or Responses when the URL
623
+ ends in `/responses`. There is no Anthropic protocol selector for custom APIs.
624
+ Internal Claude retains its native provider transport and credentials.
625
+
626
+ Ordinary provider sessions authenticate through their provider-owned adapters;
627
+ MCP `agent_handle` is never model authentication. Standalone and internal ucode
628
+ use the independent gateway settings below.
420
629
 
421
630
  Global `ucode` settings:
422
631
 
@@ -440,8 +649,8 @@ src/
440
649
  runtime/ daemon, projects, terminal adapters, contracts, privacy, process helpers
441
650
  coordination/ bus, context, memory, history, reports, state, status
442
651
  orchestration/ router/controller logic, groups, solo roles
443
- agents/ launchers, providers, prompts, internal runner, activity, controller
444
- code/ native ucode runtime, launcher, skills, file/shell tools
652
+ agents/ shared runtime, capabilities, profiles, providers, launchers, prompts
653
+ code/ native ucode host, launcher, skills, file/shell tools
445
654
  tools/ shared controller/worker tool registry and handlers
446
655
  online/ relay client/server/runner/token helpers
447
656
  ```
@@ -449,10 +658,18 @@ src/
449
658
  See [PROJECT.md](PROJECT.md) for the maintainer-facing map and detailed package
450
659
  ownership.
451
660
 
661
+ Reports share one task ID across lifecycle phases. Pass `--task <id>` to
662
+ `ufoo report`, or `task_id` to MCP `report_agent_status`. Without an explicit ID,
663
+ CLI progress/done/error attach to the agent's single active task; multiple
664
+ active tasks require an ID. Reports are acknowledged after persistence, and
665
+ ordinary bus replies do not imply task completion. `autoResume` defaults to
666
+ `false` consistently before and after partial configuration updates.
667
+
452
668
  ## Development
453
669
 
454
670
  ```bash
455
671
  npm install
672
+ npm run pack:tui
456
673
  npm link
457
674
  node bin/ufoo.js --help
458
675
  npm test
@@ -465,7 +682,7 @@ npm run test:watch
465
682
  npm run test:coverage
466
683
  ```
467
684
 
468
- The repository is CommonJS, targets Node.js 18+, and ships a Rust TTY UI
685
+ The repository is CommonJS, targets Node.js 18.17+, and ships a Rust TTY UI
469
686
  (`crates/ufoo-tui`) as platform binaries under `dist/tui/`.
470
687
 
471
688
  ## Release