u-foo 4.0.10 → 4.1.2

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 (71) hide show
  1. package/OPTIONAL_SKILLS/ufoo-bus-poll/SKILL.md +27 -0
  2. package/README.md +279 -789
  3. package/README.zh-CN.md +290 -439
  4. package/SKILLS/ufoo/SKILL.md +7 -0
  5. package/bin/ufoo.js +36 -3
  6. package/dist/tui/darwin-arm64/ufoo-tui +0 -0
  7. package/docs/OBSERVABILITY.md +4 -2
  8. package/docs/README.md +1 -0
  9. package/package.json +6 -2
  10. package/scripts/pack-desktop.js +174 -0
  11. package/src/agents/capabilities/coding/index.js +26 -3
  12. package/src/agents/capabilities/index.js +2 -1
  13. package/src/agents/capabilities/mac/index.js +145 -0
  14. package/src/agents/capabilities/planning/index.js +1 -1
  15. package/src/agents/capabilities/turnRecall/index.js +5 -16
  16. package/src/agents/profiles/coding.js +1 -1
  17. package/src/agents/profiles/main.js +1 -1
  18. package/src/agents/providers/nativeTransport.js +105 -116
  19. package/src/agents/providers/runtimeConfig.js +15 -4
  20. package/src/agents/providers/transports/anthropicCache.js +78 -0
  21. package/src/agents/providers/transports/antigravityTransport.js +3 -2
  22. package/src/agents/providers/transports/openaiResponsesTransport.js +7 -12
  23. package/src/agents/providers/transports/requestCacheObservation.js +61 -0
  24. package/src/agents/providers/transports/responsesProtocol.js +54 -46
  25. package/src/agents/providers/upstreamRuntime.js +2 -2
  26. package/src/agents/runtime/context/contextWindow.js +10 -0
  27. package/src/agents/runtime/context/slidingWindowManager.js +97 -41
  28. package/src/agents/runtime/context/topicSelector.js +4 -2
  29. package/src/agents/runtime/context/turnAnalyzer.js +17 -29
  30. package/src/agents/runtime/core/agentLoop.js +23 -7
  31. package/src/agents/runtime/createAgentRuntime.js +1 -1
  32. package/src/agents/runtime/protocol/auxiliaryModelRequest.js +28 -0
  33. package/src/app/chat/ChatController.js +1 -0
  34. package/src/app/chat/commandExecutor.js +25 -0
  35. package/src/app/chat/commands.js +2 -0
  36. package/src/app/chat/daemonMessageRouter.js +30 -3
  37. package/src/app/cli/appCommands.js +107 -0
  38. package/src/app/cli/features/skills.js +2 -0
  39. package/src/app/cli/macCommands.js +321 -0
  40. package/src/app/cli/metricsCommands.js +6 -1
  41. package/src/app/cli/run.js +26 -0
  42. package/src/app/cli/setupCommands.js +1 -0
  43. package/src/code/agent.js +1 -0
  44. package/src/code/context/assembler.js +8 -6
  45. package/src/code/context/promptLayers.js +3 -1
  46. package/src/code/context/stateCommit.js +2 -2
  47. package/src/code/context/transcript.js +11 -5
  48. package/src/code/nativeRunner.js +25 -5
  49. package/src/code/skills/loader.js +10 -2
  50. package/src/code/skills/render.js +8 -1
  51. package/src/config.js +42 -0
  52. package/src/coordination/bus/activate.js +44 -19
  53. package/src/coordination/history/agentPerformance.js +88 -11
  54. package/src/coordination/history/agentTrace.js +2 -0
  55. package/src/coordination/history/modelInputCost.js +52 -0
  56. package/src/runtime/contracts/uiProtocol.js +26 -0
  57. package/src/runtime/daemon/agentHost.js +35 -12
  58. package/src/runtime/daemon/mcpStdioProxy.js +3 -2
  59. package/src/runtime/mac/helperClient.js +279 -0
  60. package/src/runtime/mac/helperCompiler.js +235 -0
  61. package/src/runtime/mac/macSession.js +866 -0
  62. package/src/runtime/mac/native/ufoo_mac_helper.swift +2493 -0
  63. package/src/runtime/mac/paths.js +63 -0
  64. package/src/ui/agentSettingsController.js +12 -5
  65. package/src/ui/cliHandoff.js +484 -0
  66. package/src/ui/desktopArchive.js +41 -0
  67. package/src/ui/desktopUiHost.js +1601 -0
  68. package/src/ui/desktopUiHostCli.js +66 -0
  69. package/src/ui/format/index.js +17 -0
  70. package/src/ui/rustChatHost.js +45 -6
  71. package/src/ui/workspaceInspector.js +621 -0
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-console */
3
+ "use strict";
4
+
5
+ /**
6
+ * Sidecar entrypoint spawned by `crates/ufoo-desktop` (Tauri v2).
7
+ *
8
+ * Expects:
9
+ * --ui-socket <path>
10
+ * --project <optional-initial-project>
11
+ * UFOO_UI_TOKEN=<hex>
12
+ */
13
+
14
+ const util = require("util");
15
+
16
+ // Redirect incidental console.log from init/bootstrap helpers to stderr so
17
+ // stdout remains a clean structured control stream for the Tauri supervisor.
18
+ const rawStdoutWrite = process.stdout.write.bind(process.stdout);
19
+ console.log = (...args) => {
20
+ process.stderr.write(`${util.format(...args)}\n`);
21
+ };
22
+
23
+ const { startDesktopUiHost } = require("./desktopUiHost");
24
+
25
+ function parseArg(flag, argv = process.argv.slice(2)) {
26
+ const idx = argv.indexOf(flag);
27
+ if (idx >= 0 && idx + 1 < argv.length) return argv[idx + 1];
28
+ return "";
29
+ }
30
+
31
+ async function main() {
32
+ const socketPath = parseArg("--ui-socket") || process.env.UFOO_UI_SOCKET || "";
33
+ const initialProjectRoot = parseArg("--project") || process.env.UFOO_DESKTOP_PROJECT || "";
34
+ const authToken = process.env.UFOO_UI_TOKEN || "";
35
+
36
+ const handle = await startDesktopUiHost({
37
+ socketPath: socketPath || undefined,
38
+ authToken: authToken || undefined,
39
+ initialProjectRoot: initialProjectRoot || undefined,
40
+ });
41
+
42
+ // Emit structured readiness line on stdout for the Tauri Rust supervisor
43
+ rawStdoutWrite(`${JSON.stringify({
44
+ ready: true,
45
+ socketPath: handle.socketPath,
46
+ handoffSocketPath: handle.handoffSocketPath,
47
+ })}\n`);
48
+
49
+ let shuttingDown = false;
50
+ const shutdown = async () => {
51
+ if (shuttingDown) return;
52
+ shuttingDown = true;
53
+ await handle.close().catch(() => {});
54
+ process.exit(0);
55
+ };
56
+
57
+ process.on("SIGINT", shutdown);
58
+ process.on("SIGTERM", shutdown);
59
+ process.stdin.on("end", shutdown);
60
+ process.stdin.resume();
61
+ }
62
+
63
+ main().catch((err) => {
64
+ console.error(`[desktop-ui-host] fatal: ${err && err.stack ? err.stack : err}`);
65
+ process.exit(1);
66
+ });
@@ -38,6 +38,8 @@ const TOOL_LABELS = {
38
38
  bash: "Running command",
39
39
  artifact_read: "Reading artifact",
40
40
  recall_turn: "Recalling past turn",
41
+ browser: "Using browser",
42
+ mac_app: "Operating Mac app",
41
43
  plan_graph: "Updating plan",
42
44
  task_run: "Managing task",
43
45
  ask_user: "Asking user",
@@ -809,6 +811,21 @@ function normalizeToolLogDetail(tool = "", args = {}, payload = {}) {
809
811
  return ["search", queryText].filter(Boolean).join(" · ");
810
812
  }
811
813
 
814
+ if (name === "mac_app") {
815
+ const op = String(argObj.operation || "").trim().toLowerCase();
816
+ const target = String(
817
+ argObj.ref
818
+ || argObj.app
819
+ || argObj.bundleId
820
+ || (argObj.windowId ? `win#${argObj.windowId}` : "")
821
+ || (argObj.key ? `key:${argObj.key}` : "")
822
+ || (argObj.x != null && argObj.y != null ? `(${argObj.x}, ${argObj.y})` : "")
823
+ || resObj.app
824
+ || "",
825
+ ).trim();
826
+ return [op, shortenPathDetail(target, 42)].filter(Boolean).join(" · ");
827
+ }
828
+
812
829
  const fallback = String(argObj.path || argObj.command || argObj.cmd || "").trim();
813
830
  return shortenPathDetail(fallback);
814
831
  }
@@ -204,6 +204,8 @@ async function runChatRust(projectRoot, options = {}) {
204
204
  let activeProjectRoot = projectRoot;
205
205
  let globalScope = "controller";
206
206
  let multiSession = null;
207
+ let initialHandoffApplied = false;
208
+ const ownRequestIds = new Set();
207
209
  const internalSubmissions = new Map();
208
210
  /** Internal pane agents currently BUS_WATCH'd for multi/side inbound. */
209
211
  const watchedInternalAgents = new Set();
@@ -217,15 +219,18 @@ async function runChatRust(projectRoot, options = {}) {
217
219
  })();
218
220
 
219
221
  async function applyAgentSettings(patch) {
222
+ const root = activeProjectRoot;
220
223
  const model = patch.agent_model ?? patch.agentModel;
221
224
  if (model) {
222
- const current = loadConfig(activeProjectRoot);
225
+ const current = loadConfig(root);
223
226
  const provider = patch.agent_provider ?? patch.agentProvider ?? current.agentProvider;
224
- const confirmation = await require("../agents/providers/modelSettings").confirmAgentModel(activeProjectRoot, model,
225
- { config: { ...current, agentProvider: provider } });
227
+ const agentBaseUrl = patch.agent_base_url ?? patch.agentBaseUrl ?? current.agentBaseUrl;
228
+ const confirmation = await require("../agents/providers/modelSettings").confirmAgentModel(root, model,
229
+ { config: { ...current, agentProvider: provider, agentBaseUrl } });
226
230
  if (!confirmation.allowed) return { ok: false, error: confirmation.error };
227
231
  }
228
- const applied = applySettingsPatch(activeProjectRoot, patch);
232
+ if (root !== activeProjectRoot) return { ok: false, error: "The active workspace changed. Try again." };
233
+ const applied = applySettingsPatch(root, patch);
229
234
  if (!applied.ok) return applied;
230
235
  Object.assign(settings, loadConfig(activeProjectRoot));
231
236
  publish("settings.snapshot", applied.settings);
@@ -719,6 +724,20 @@ async function runChatRust(projectRoot, options = {}) {
719
724
  }
720
725
  publish("prompt.set_text", { text: "/resume ", if_empty: true });
721
726
  },
727
+ openDesktopApp: async (args = []) => {
728
+ const { openInDesktopApp } = require("./cliHandoff");
729
+ const snap = multiSession ? multiSession.getSnapshot() : { mode: "main", focus: {} };
730
+ const explicitAgent = String(args[0] || "").trim();
731
+ const focusedAgent = explicitAgent
732
+ || (snap.focus?.target === "agent" ? snap.focus.agent_id : "")
733
+ || controller.session.targetAgent
734
+ || "";
735
+ return openInDesktopApp({
736
+ projectRoot: activeProjectRoot || projectRoot,
737
+ target: focusedAgent || "main",
738
+ windowMode: focusedAgent ? "" : (snap.mode || "main"),
739
+ });
740
+ },
722
741
  applyChatSettings: (patch = {}) => {
723
742
  if (patch.agentProvider != null) settings.agentProvider = patch.agentProvider;
724
743
  publish("settings.snapshot", buildSettingsSnapshot(settings));
@@ -900,8 +919,7 @@ async function runChatRust(projectRoot, options = {}) {
900
919
  }
901
920
  if (completionRoot !== activeProjectRoot) return { ok: true, stale: true };
902
921
  }
903
- const settingsLists = /^\/settings\s+agent\s+(?:model|thinking)(?:\s|$)/.test(String(payload.text || "").trimStart())
904
- ? await agentSettings.completions(String(payload.text || "")) : {};
922
+ const settingsLists = await agentSettings.completions(String(payload.text || ""));
905
923
  if (completionRoot !== activeProjectRoot) return { ok: true, stale: true };
906
924
  const items = fmt.buildCompletions({
907
925
  text: String(payload.text || ""),
@@ -1112,6 +1130,8 @@ async function runChatRust(projectRoot, options = {}) {
1112
1130
  escapeBlessed: (value) => String(value || ""),
1113
1131
  resolveAgentDisplayName: getAgentLabel,
1114
1132
  stripBlessedTags: stripTags,
1133
+ isOwnRequestId: (id) => ownRequestIds.has(id),
1134
+ onInteractionClear: () => publish("interaction.clear", {}),
1115
1135
  logMessage: (kind, text) => {
1116
1136
  const normalized = kind === "error" ? "error"
1117
1137
  : kind === "user" ? "user"
@@ -1124,6 +1144,20 @@ async function runChatRust(projectRoot, options = {}) {
1124
1144
  controller.applyStatus(data);
1125
1145
  publishDashboardFromStatus(data);
1126
1146
  if (env.globalMode) publishProjects();
1147
+ if (!initialHandoffApplied && (options.initialAgentId || options.initialWindowMode)) {
1148
+ if (options.initialAgentId && hostApi.isKnownAgent(options.initialAgentId)) {
1149
+ initialHandoffApplied = true;
1150
+ if (hostApi.isInternalAgent(options.initialAgentId)) {
1151
+ hostApi.startSide(options.initialAgentId);
1152
+ } else {
1153
+ controller.session.targetAgent = options.initialAgentId;
1154
+ publish("prompt.set_prefix", { prefix: `›@${getAgentLabel(options.initialAgentId)} ` });
1155
+ }
1156
+ } else if (!options.initialAgentId && options.initialWindowMode) {
1157
+ initialHandoffApplied = true;
1158
+ changeWindowLayout(options.initialWindowMode);
1159
+ }
1160
+ }
1127
1161
  },
1128
1162
  requestStatus: () => controller.requestDaemonStatus(),
1129
1163
  getPending: () => controller.session.pending,
@@ -1234,6 +1268,11 @@ async function runChatRust(projectRoot, options = {}) {
1234
1268
 
1235
1269
  await daemonConnection.connect();
1236
1270
  daemonSend = (req) => {
1271
+ const reqId = req && (req.request_id || req.id);
1272
+ if (reqId) {
1273
+ ownRequestIds.add(String(reqId));
1274
+ if (ownRequestIds.size > 500) ownRequestIds.delete(ownRequestIds.values().next().value);
1275
+ }
1237
1276
  if (req.type === IPC_REQUEST_TYPES.PROMPT) mainSubmissionRev += 1;
1238
1277
  return daemonConnection.send(req);
1239
1278
  };