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
@@ -1,3 +1,4 @@
1
+ const { normalizeInternalAgentType } = require("../../runtime/contracts/agentMode");
1
2
  const path = require("path");
2
3
  const EventBus = require("../../coordination/bus");
3
4
  const { IPC_REQUEST_TYPES } = require("../../runtime/contracts/eventContract");
@@ -8,20 +9,18 @@ const {
8
9
  saveConfig: saveProjectConfig,
9
10
  loadGlobalUcodeConfig,
10
11
  saveGlobalUcodeConfig,
11
- normalizeControllerMode,
12
- normalizeLaunchMode,
13
12
  SETTINGS_MODEL_DEFAULTS,
14
13
  defaultAgentModelForProvider,
15
- defaultRouterModelForProvider,
16
14
  } = require("../../config");
15
+ const { DEFAULT_THINKING_LEVEL } = require("../../agents/providers/thinkingLevels");
17
16
 
18
- const LAUNCH_MODE_OPTIONS = Object.freeze(["auto", "host", "terminal", "tmux", "internal"]);
19
17
  const AGENT_PROVIDER_OPTIONS = Object.freeze([
20
18
  { label: "codex", value: "codex-cli" },
21
19
  { label: "claude", value: "claude-cli" },
22
20
  { label: "agy", value: "agy-cli" },
23
21
  { label: "kimi", value: "kimi-cli" },
24
22
  { label: "grok", value: "grok-cli" },
23
+ { label: "custom", value: "custom" },
25
24
  ]);
26
25
  const { resolveTransport } = require("../../code/nativeRunner");
27
26
  const { resolveDisplayNickname } = require("../../runtime/daemon/nicknameScope");
@@ -54,15 +53,9 @@ function defaultCreateSkills(projectRoot) {
54
53
  return new UfooSkills(projectRoot);
55
54
  }
56
55
 
57
- function defaultResolveTerminalApp() {
58
- const program = String(process.env.TERM_PROGRAM || "").trim();
59
- if (program === "Apple_Terminal") return "terminal";
60
- if (program === "iTerm.app" || process.env.ITERM_SESSION_ID) return "iterm2";
61
- return "";
62
- }
63
-
64
56
  function normalizeSettingsProvider(value = "", fallback = "codex-cli") {
65
57
  const text = String(value || "").trim().toLowerCase();
58
+ if (text === "custom") return "custom";
66
59
  if (text === "claude" || text === "claude-cli" || text === "claude-code" || text === "anthropic") {
67
60
  return "claude-cli";
68
61
  }
@@ -87,45 +80,10 @@ function agentProviderKey(value = "") {
87
80
  if (provider === "agy-cli") return "agy";
88
81
  if (provider === "kimi-cli") return "kimi";
89
82
  if (provider === "grok-cli") return "grok";
83
+ if (provider === "custom") return "custom";
90
84
  return "codex";
91
85
  }
92
86
 
93
- function defaultGateModelForProvider(value = "") {
94
- return defaultRouterModelForProvider(value);
95
- }
96
-
97
- function collectHostLaunchRequestContext(env = process.env) {
98
- const hostInjectSock = String(env.UFOO_HOST_INJECT_SOCK || env.HORIZON_INJECT_SOCK || "").trim();
99
- const hostDaemonSock = String(env.UFOO_HOST_DAEMON_SOCK || "").trim();
100
- const hostName = String(env.UFOO_HOST_NAME || "").trim();
101
- const hostSessionId = String(env.UFOO_HOST_SESSION_ID || env.HORIZON_SESSION_ID || "").trim();
102
- const context = {};
103
- if (hostInjectSock) context.host_inject_sock = hostInjectSock;
104
- if (hostDaemonSock) context.host_daemon_sock = hostDaemonSock;
105
- if (hostName) context.host_name = hostName;
106
- if (hostSessionId) context.host_session_id = hostSessionId;
107
- return context;
108
- }
109
-
110
- function collectTerminalLaunchRequestContext(resolveTerminalApp = defaultResolveTerminalApp) {
111
- const terminalApp = String(resolveTerminalApp() || "").trim().toLowerCase();
112
- if (terminalApp === "terminal" || terminalApp === "iterm2") {
113
- return { terminal_app: terminalApp };
114
- }
115
- return {};
116
- }
117
-
118
- function collectTmuxLaunchRequestContext(env = process.env) {
119
- const tmuxTarget = String(env.UFOO_TMUX_TARGET || "").trim();
120
- const tmuxPane = String(env.UFOO_TMUX_PANE || env.TMUX_PANE || "").trim();
121
- const tmuxSession = String(env.UFOO_TMUX_SESSION || "").trim();
122
- const context = {};
123
- if (tmuxTarget) context.tmux_target = tmuxTarget;
124
- if (tmuxPane) context.tmux_pane = tmuxPane;
125
- if (tmuxSession) context.tmux_session = tmuxSession;
126
- return context;
127
- }
128
-
129
87
  async function withCapturedConsole(capture, fn) {
130
88
  const originalLog = console.log;
131
89
  const originalError = console.error;
@@ -187,12 +145,12 @@ function createCommandExecutor(options = {}) {
187
145
  listProjects = () => [],
188
146
  getCurrentProject = () => ({ projectRoot }),
189
147
  switchProject = async () => ({ ok: false, error: "project switching unavailable" }),
190
- resolveTerminalApp = defaultResolveTerminalApp,
191
148
  sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
192
149
  schedule = (fn, ms) => setTimeout(fn, ms),
193
150
  clearLog = null,
194
151
  fetchModelsImpl = null,
195
152
  applyChatSettings = null,
153
+ openResumeMenu = null,
196
154
  } = options;
197
155
 
198
156
  if (!projectRoot) {
@@ -634,22 +592,16 @@ function createCommandExecutor(options = {}) {
634
592
  if (args.length === 0) {
635
593
  logMessage(
636
594
  "error",
637
- "{white-fg}✗{/white-fg} Usage: /launch <claude|codex|agy|grok|kimi|ucode> [nickname=<name>] [profile=<id>] [count=<n>] [scope=inplace|window]"
595
+ "{white-fg}✗{/white-fg} Usage: /launch <claude|codex|ucode> [nickname=<name>] [profile=<id>] [count=<n>]"
638
596
  );
639
597
  return;
640
598
  }
641
599
 
642
- const agentTypeInput = String(args[0] || "").trim().toLowerCase();
643
- // Accept friendly aliases the same way `ufoo launch` does in cli.js.
644
- let agentType = agentTypeInput;
645
- if (agentTypeInput === "antigravity" || agentTypeInput === "uagy") agentType = "agy";
646
- if (agentTypeInput === "grok-build" || agentTypeInput === "ugrok" || agentTypeInput === "xai") agentType = "grok";
647
- if (agentTypeInput === "kimi-cli" || agentTypeInput === "kimi-code" || agentTypeInput === "ukimi") agentType = "kimi";
648
- if (agentType !== "claude" && agentType !== "codex" && agentType !== "agy" && agentType !== "grok" && agentType !== "kimi" && agentType !== "ucode") {
649
- logMessage("error", "{white-fg}✗{/white-fg} Unknown agent type. Use: claude, codex, agy, grok, kimi, or ucode");
600
+ const normalizedAgent = normalizeInternalAgentType(args[0]);
601
+ if (!normalizedAgent) {
602
+ logMessage("error", "Unknown internal agent type. Use: claude, codex or ucode");
650
603
  return;
651
604
  }
652
- const normalizedAgent = agentType === "ucode" ? "ufoo" : agentType;
653
605
 
654
606
  const parsedOptions = {};
655
607
  for (let i = 1; i < args.length; i += 1) {
@@ -660,51 +612,9 @@ function createCommandExecutor(options = {}) {
660
612
  }
661
613
  }
662
614
 
663
- function normalizeLaunchScopeOption(value, fallback = "inplace") {
664
- const raw = String(value || "").trim().toLowerCase();
665
- if (!raw) return fallback;
666
- if (raw === "inplace" || raw === "same" || raw === "current" || raw === "tab" || raw === "pane") {
667
- return "inplace";
668
- }
669
- if (
670
- raw === "window"
671
- || raw === "separate"
672
- || raw === "new"
673
- || raw === "new-window"
674
- || raw === "external"
675
- || raw === "1"
676
- || raw === "true"
677
- || raw === "yes"
678
- || raw === "y"
679
- || raw === "on"
680
- ) {
681
- return "window";
682
- }
683
- if (raw === "0" || raw === "false" || raw === "no" || raw === "n" || raw === "off") {
684
- return "inplace";
685
- }
686
- return "";
687
- }
688
-
689
615
  const nickname = parsedOptions.nickname || "";
690
616
  const promptProfile = parsedOptions.profile || parsedOptions.prompt_profile || "";
691
617
  const count = parseInt(parsedOptions.count || "1", 10);
692
- const scopeRaw = parsedOptions.scope || parsedOptions.launch_scope || parsedOptions.window || "";
693
- let launchScope = normalizeLaunchScopeOption(scopeRaw, "inplace");
694
- if (scopeRaw && !launchScope) {
695
- logMessage("error", "{white-fg}✗{/white-fg} scope must be inplace|window");
696
- return;
697
- }
698
- const rawFlags = args
699
- .slice(1)
700
- .filter((arg) => !String(arg || "").includes("="))
701
- .map((arg) => String(arg || "").trim().toLowerCase())
702
- .filter(Boolean);
703
- for (const flag of rawFlags) {
704
- const normalized = normalizeLaunchScopeOption(flag, "");
705
- if (normalized) launchScope = normalized;
706
- }
707
- if (!launchScope) launchScope = "inplace";
708
618
  if (nickname && count > 1) {
709
619
  logMessage("error", "{white-fg}✗{/white-fg} nickname requires count=1");
710
620
  return;
@@ -721,10 +631,7 @@ function createCommandExecutor(options = {}) {
721
631
  count: Number.isFinite(count) ? count : 1,
722
632
  nickname,
723
633
  prompt_profile: promptProfile,
724
- launch_scope: launchScope,
725
- ...collectHostLaunchRequestContext(),
726
- ...collectTerminalLaunchRequestContext(resolveTerminalApp),
727
- ...collectTmuxLaunchRequestContext(),
634
+ internal_only: true,
728
635
  };
729
636
  send(request);
730
637
  schedule(requestStatus, 1000);
@@ -822,7 +729,7 @@ function createCommandExecutor(options = {}) {
822
729
 
823
730
  const profile = String(args[1] || "").trim();
824
731
  if (!profile) {
825
- logMessage("error", "{white-fg}✗{/white-fg} Usage: /solo run <prompt-profile> [agent=codex|claude|agy|grok|ucode] [nickname=<name>] [scope=inplace|window]");
732
+ logMessage("error", "{white-fg}✗{/white-fg} Usage: /solo run <prompt-profile> [agent=codex|claude|ucode] [nickname=<name>]");
826
733
  return;
827
734
  }
828
735
 
@@ -835,39 +742,23 @@ function createCommandExecutor(options = {}) {
835
742
  }
836
743
  }
837
744
 
838
- function normalizeLaunchScopeOption(value, fallback = "inplace") {
839
- const raw = String(value || "").trim().toLowerCase();
840
- if (!raw) return fallback;
841
- if (raw === "inplace" || raw === "same" || raw === "current" || raw === "tab" || raw === "pane") {
842
- return "inplace";
843
- }
844
- if (raw === "window" || raw === "separate" || raw === "new" || raw === "new-window" || raw === "external") {
845
- return "window";
846
- }
847
- return "";
848
- }
849
-
850
745
  const config = loadConfig(projectRoot);
851
- const agent = resolveSoloAgentType(config, parsedOptions.agent || parsedOptions.type || "");
852
- const nickname = String(parsedOptions.nickname || "").trim();
853
- const scopeRaw = parsedOptions.scope || parsedOptions.launch_scope || "";
854
- const launchScope = normalizeLaunchScopeOption(scopeRaw, "inplace");
855
- if (scopeRaw && !launchScope) {
856
- logMessage("error", "{white-fg}✗{/white-fg} scope must be inplace|window");
746
+ const requested = parsedOptions.agent || parsedOptions.type || "";
747
+ const agent = normalizeInternalAgentType(resolveSoloAgentType(config, requested));
748
+ if (!agent) {
749
+ logMessage("error", "Unknown internal agent type. Use: claude, codex or ucode");
857
750
  return;
858
751
  }
752
+ const nickname = String(parsedOptions.nickname || "").trim();
859
753
 
860
754
  try {
861
755
  send({
862
756
  type: IPC_REQUEST_TYPES.LAUNCH_AGENT,
863
- agent: agent === "ucode" ? "ufoo" : agent,
757
+ agent,
864
758
  count: 1,
865
759
  nickname,
866
760
  prompt_profile: profile,
867
- launch_scope: launchScope,
868
- ...collectHostLaunchRequestContext(),
869
- ...collectTerminalLaunchRequestContext(resolveTerminalApp),
870
- ...collectTmuxLaunchRequestContext(),
761
+ internal_only: true,
871
762
  });
872
763
  schedule(requestStatus, 1000);
873
764
  } catch (err) {
@@ -876,20 +767,19 @@ function createCommandExecutor(options = {}) {
876
767
  }
877
768
 
878
769
  async function handleResumeCommand(args = []) {
879
- const action = String(args[0] || "").toLowerCase();
880
- if (action === "list" || action === "ls") {
881
- const target = args[1] || "";
882
- const label = target ? ` (${target})` : "";
883
- logMessage("system", `{white-fg}⚙{/white-fg} Listing recoverable agents${label}...`);
884
- send({ type: IPC_REQUEST_TYPES.LIST_RECOVERABLE_AGENTS, target });
885
- schedule(requestStatus, 1000);
770
+ if (args.length === 0) {
771
+ if (typeof openResumeMenu === "function") await openResumeMenu();
772
+ else logMessage("system", "Choose an agent or group from the /resume menu.");
773
+ return;
774
+ }
775
+ if (args.length !== 1 || ["list", "ls"].includes(args[0])) {
776
+ logMessage("error", "Use /resume to select an agent or group; /resume list has been removed.");
886
777
  return;
887
778
  }
888
-
889
779
  const target = args[0] || "";
890
780
  const label = target ? ` (${target})` : "";
891
781
  logMessage("system", `{white-fg}⚙{/white-fg} Resuming agents${label}...`);
892
- send({ type: IPC_REQUEST_TYPES.RESUME_AGENTS, target });
782
+ send({ type: IPC_REQUEST_TYPES.RESUME_AGENTS, target, internal_only: true });
893
783
  schedule(requestStatus, 1000);
894
784
  }
895
785
 
@@ -1033,18 +923,6 @@ function createCommandExecutor(options = {}) {
1033
923
  return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
1034
924
  }
1035
925
 
1036
- function clearUfooAgentIdentity() {
1037
- try {
1038
- const { getUfooPaths } = require("../../coordination/state/paths");
1039
- const agentDir = getUfooPaths(projectRoot).agentDir;
1040
- const fsModule = require("fs");
1041
- fsModule.rmSync(path.join(agentDir, "ufoo-agent.json"), { force: true });
1042
- fsModule.rmSync(path.join(agentDir, "ufoo-agent.history.jsonl"), { force: true });
1043
- } catch {
1044
- // Ignore cleanup failures.
1045
- }
1046
- }
1047
-
1048
926
  async function notifyChatSettings(patch = {}) {
1049
927
  if (typeof applyChatSettings !== "function") return;
1050
928
  try {
@@ -1054,41 +932,9 @@ function createCommandExecutor(options = {}) {
1054
932
  }
1055
933
  }
1056
934
 
1057
- async function handleModeCommand(args = []) {
1058
- const action = String(args[0] || "").trim().toLowerCase();
1059
- const config = loadConfig(projectRoot) || {};
1060
- const current = normalizeLaunchMode(config.launchMode || "auto");
1061
-
1062
- if (!action || action === "show" || action === "status") {
1063
- logMessage("system", "{cyan-fg}launch mode:{/cyan-fg}");
1064
- logMessage("system", ` • current: ${current}`);
1065
- logMessage("system", ` • options: ${LAUNCH_MODE_OPTIONS.join(", ")}`);
1066
- logMessage("system", " • use: /mode <auto|host|terminal|tmux|internal>");
1067
- return;
1068
- }
1069
-
1070
- if (!LAUNCH_MODE_OPTIONS.includes(action)) {
1071
- logMessage(
1072
- "error",
1073
- `{white-fg}✗{/white-fg} Unknown mode: ${action}. Use: ${LAUNCH_MODE_OPTIONS.join("|")}`
1074
- );
1075
- return;
1076
- }
1077
-
1078
- const next = normalizeLaunchMode(action);
1079
- if (next === current) {
1080
- logMessage("system", `{cyan-fg}launch mode:{/cyan-fg} already ${next}`);
1081
- return;
1082
- }
1083
-
1084
- saveConfig(projectRoot, { launchMode: next });
1085
- logMessage("system", `{white-fg}✓{/white-fg} Launch mode: ${next}`);
1086
- await notifyChatSettings({ launchMode: next });
1087
- await restartDaemon(projectRoot);
1088
- }
1089
-
1090
935
  async function handleProviderCommand(args = []) {
1091
936
  const action = String(args[0] || "").trim().toLowerCase();
937
+ if (action === "custom" && options.openAgentSettings) return options.openAgentSettings("custom");
1092
938
  const config = loadConfig(projectRoot) || {};
1093
939
  const current = normalizeSettingsProvider(config.agentProvider);
1094
940
  const labels = AGENT_PROVIDER_OPTIONS.map((opt) => opt.label).join(", ");
@@ -1116,8 +962,12 @@ function createCommandExecutor(options = {}) {
1116
962
  return;
1117
963
  }
1118
964
 
965
+ if (options.applyAgentSettings) {
966
+ const result = await options.applyAgentSettings({ agentProvider: next });
967
+ if (!result.ok) logMessage("error", result.error);
968
+ return;
969
+ }
1119
970
  saveConfig(projectRoot, { agentProvider: next });
1120
- clearUfooAgentIdentity();
1121
971
  logMessage("system", `{white-fg}✓{/white-fg} ufoo-agent: ${agentProviderKey(next)}`);
1122
972
  await notifyChatSettings({ agentProvider: next });
1123
973
  await restartDaemon(projectRoot);
@@ -1367,9 +1217,7 @@ function createCommandExecutor(options = {}) {
1367
1217
  alias,
1368
1218
  instance,
1369
1219
  dry_run: dryRun,
1370
- ...collectHostLaunchRequestContext(),
1371
- ...collectTerminalLaunchRequestContext(resolveTerminalApp),
1372
- ...collectTmuxLaunchRequestContext(),
1220
+ internal_only: true,
1373
1221
  });
1374
1222
  schedule(requestStatus, 1000);
1375
1223
  return;
@@ -1456,12 +1304,6 @@ function createCommandExecutor(options = {}) {
1456
1304
  return;
1457
1305
  }
1458
1306
 
1459
- if (section === "router") {
1460
- const subArgs = args.slice(1);
1461
- await handleRouterSettingsCommand(subArgs);
1462
- return;
1463
- }
1464
-
1465
1307
  if (section === "ucode") {
1466
1308
  const subArgs = args.slice(1);
1467
1309
  if (subArgs.length === 0) {
@@ -1472,7 +1314,7 @@ function createCommandExecutor(options = {}) {
1472
1314
  return;
1473
1315
  }
1474
1316
 
1475
- logMessage("error", "{white-fg}✗{/white-fg} Unknown settings section. Use: show, agent, router, ucode");
1317
+ logMessage("error", "{white-fg}✗{/white-fg} Unknown settings section. Use: show, agent, ucode");
1476
1318
  }
1477
1319
 
1478
1320
  async function handleSettingsOverviewCommand() {
@@ -1480,22 +1322,35 @@ function createCommandExecutor(options = {}) {
1480
1322
  const agentProvider = normalizeSettingsProvider(config.agentProvider);
1481
1323
  const agentKey = agentProviderKey(agentProvider);
1482
1324
  const agentModel = String(config.agentModel || "").trim();
1483
- const routerMode = normalizeControllerMode(config.controllerMode);
1484
- const routerProvider = String(config.routerProvider || "").trim();
1485
- const routerModel = String(config.routerModel || "").trim();
1486
1325
  const ucodeConfig = loadUcodeConfig() || {};
1487
1326
  const ucodeProvider = String(ucodeConfig.ucodeProvider || "").trim();
1488
1327
  const ucodeModel = String(ucodeConfig.ucodeModel || "").trim();
1489
1328
 
1490
1329
  logMessage("system", "{cyan-fg}settings:{/cyan-fg}");
1491
1330
  logMessage("system", ` • agent: ${agentKey} · model ${agentModel || `(unset, recommended ${defaultAgentModelForProvider(agentProvider)})`}`);
1492
- logMessage("system", ` • router: mode ${routerMode} · provider ${routerProvider || "(unset)"} · model ${routerModel || "(unset)"}`);
1493
1331
  logMessage("system", ` • ucode: provider ${ucodeProvider || "(unset)"} · model ${ucodeModel || "(unset)"}`);
1494
- logMessage("system", " • use: /settings agent | /settings router | /settings ucode");
1332
+ logMessage("system", " • use: /settings agent | /settings ucode");
1495
1333
  }
1496
1334
 
1497
1335
  async function handleAgentSettingsCommand(args = []) {
1498
1336
  const first = String(args[0] || "").trim().toLowerCase();
1337
+ if (first === "custom" && options.openAgentSettings) return options.openAgentSettings("custom");
1338
+ if (first === "model") {
1339
+ if (args.length === 1 && options.openAgentSettings) return options.openAgentSettings("model");
1340
+ if (options.applyAgentModel) {
1341
+ const result = await options.applyAgentModel(args[1], args[2]);
1342
+ if (!result.ok) logMessage("error", result.error);
1343
+ return;
1344
+ }
1345
+ }
1346
+ if (first === "thinking") {
1347
+ if (args.length === 1 && options.openAgentSettings) return options.openAgentSettings("thinking");
1348
+ if (options.applyAgentSettings) {
1349
+ const result = await options.applyAgentSettings({ agent_thinking: args[1] });
1350
+ if (!result.ok) logMessage("error", result.error);
1351
+ return;
1352
+ }
1353
+ }
1499
1354
  const hasInlineKv = args.some((item) => String(item || "").includes("="));
1500
1355
  const action = !first ? "show" : (hasInlineKv ? "set" : first);
1501
1356
 
@@ -1508,7 +1363,12 @@ function createCommandExecutor(options = {}) {
1508
1363
  logMessage("system", ` • provider: ${key}`);
1509
1364
  logMessage("system", ` • model: ${model || `(unset, recommended ${defaultAgentModelForProvider(provider)})`}`);
1510
1365
  logMessage("system", ` • defaults: codex=${SETTINGS_MODEL_DEFAULTS.agent.codex}, claude=${SETTINGS_MODEL_DEFAULTS.agent.claude}`);
1511
- logMessage("system", " • use: /settings agent set provider=<codex|claude|agy> model=<id>");
1366
+ logMessage("system", ` • thinking: ${config.agentThinking || "medium"}`);
1367
+ if (provider === "custom") {
1368
+ logMessage("system", ` • url: ${config.agentBaseUrl || "(unset)"}`);
1369
+ logMessage("system", ` • key: ${config.agentApiKey ? "(configured)" : "(unset)"}`);
1370
+ }
1371
+ logMessage("system", " • use: /settings agent custom | model | thinking");
1512
1372
  return;
1513
1373
  }
1514
1374
 
@@ -1520,10 +1380,14 @@ function createCommandExecutor(options = {}) {
1520
1380
  ? "agy-cli"
1521
1381
  : (action === "kimi" ? "kimi-cli" : (action === "grok" ? "grok-cli" : "codex-cli")));
1522
1382
  const model = String(kv.model || defaultAgentModelForProvider(provider)).trim();
1523
- saveConfig(projectRoot, {
1524
- agentProvider: provider,
1525
- agentModel: model,
1526
- });
1383
+ const patch = { agentProvider: provider, agentModel: model,
1384
+ ...(action === "codex" ? { agentThinking: DEFAULT_THINKING_LEVEL } : {}) };
1385
+ if (options.applyAgentSettings) {
1386
+ const result = await options.applyAgentSettings(patch);
1387
+ if (!result.ok) logMessage("error", result.error);
1388
+ return;
1389
+ }
1390
+ saveConfig(projectRoot, patch);
1527
1391
  logMessage("system", "{white-fg}✓{/white-fg} ufoo-agent config updated");
1528
1392
  logMessage("system", ` • provider: ${agentProviderKey(provider)}`);
1529
1393
  logMessage("system", ` • model: ${model}`);
@@ -1556,6 +1420,12 @@ function createCommandExecutor(options = {}) {
1556
1420
  return;
1557
1421
  }
1558
1422
 
1423
+ if (options.applyAgentSettings) {
1424
+ const result = await options.applyAgentSettings(updates);
1425
+ if (!result.ok) logMessage("error", result.error);
1426
+ return;
1427
+ }
1428
+
1559
1429
  saveConfig(projectRoot, updates);
1560
1430
  logMessage("system", "{white-fg}✓{/white-fg} ufoo-agent config updated");
1561
1431
  if (Object.prototype.hasOwnProperty.call(updates, "agentProvider")) {
@@ -1579,110 +1449,18 @@ function createCommandExecutor(options = {}) {
1579
1449
  logMessage("error", "{white-fg}✗{/white-fg} Usage: /settings agent clear [provider|model|all]");
1580
1450
  return;
1581
1451
  }
1582
- saveConfig(projectRoot, updates);
1583
- logMessage("system", "{white-fg}✓{/white-fg} ufoo-agent config cleared");
1584
- await restartDaemon(projectRoot);
1585
- return;
1586
- }
1587
-
1588
- logMessage("error", "{white-fg}✗{/white-fg} Unknown settings agent action. Use: show, set, clear, codex, claude, agy, kimi, grok");
1589
- }
1590
-
1591
- async function handleRouterSettingsCommand(args = []) {
1592
- const first = String(args[0] || "").trim().toLowerCase();
1593
- const hasInlineKv = args.some((item) => String(item || "").includes("="));
1594
- const action = !first ? "show" : (hasInlineKv ? "set" : first);
1595
-
1596
- if (action === "show" || action === "status") {
1597
- const config = loadConfig(projectRoot) || {};
1598
- const mode = normalizeControllerMode(config.controllerMode);
1599
- logMessage("system", "{cyan-fg}gate router config:{/cyan-fg}");
1600
- logMessage("system", ` • controllerMode: ${mode}`);
1601
- logMessage("system", ` • provider: ${String(config.routerProvider || "").trim() || "(unset)"}`);
1602
- logMessage("system", ` • model: ${String(config.routerModel || "").trim() || "(unset)"}`);
1603
- logMessage("system", " • allowed modes: main | loop | legacy | shadow");
1604
- logMessage("system", ` • defaults: codex=${SETTINGS_MODEL_DEFAULTS.router.codex}, claude=${SETTINGS_MODEL_DEFAULTS.router.claude}`);
1605
- return;
1606
- }
1607
-
1608
- if (action === "codex" || action === "claude") {
1609
- const kv = parseKeyValueArgs(args.slice(1));
1610
- const provider = action;
1611
- const model = String(kv.model || defaultGateModelForProvider(provider)).trim();
1612
- saveConfig(projectRoot, {
1613
- routerProvider: provider,
1614
- routerModel: model,
1615
- });
1616
- logMessage("system", "{white-fg}✓{/white-fg} gate router config updated");
1617
- logMessage("system", ` • provider: ${provider}`);
1618
- logMessage("system", ` • model: ${model}`);
1619
- await restartDaemon(projectRoot);
1620
- return;
1621
- }
1622
-
1623
- if (action === "set") {
1624
- const kvArgs = hasInlineKv ? args : args.slice(1);
1625
- const kv = parseKeyValueArgs(kvArgs);
1626
- const updates = {};
1627
-
1628
- if (Object.prototype.hasOwnProperty.call(kv, "mode")) {
1629
- const nextMode = normalizeControllerMode(kv.mode);
1630
- if (!["main", "loop", "legacy", "shadow"].includes(nextMode) || nextMode !== String(kv.mode || "").trim().toLowerCase()) {
1631
- logMessage("error", "{white-fg}✗{/white-fg} Usage: /settings router set mode=<main|loop|legacy|shadow> provider=<id> model=<id>");
1632
- return;
1633
- }
1634
- updates.controllerMode = nextMode;
1635
- }
1636
- if (Object.prototype.hasOwnProperty.call(kv, "provider")) updates.routerProvider = String(kv.provider || "").trim();
1637
- if (Object.prototype.hasOwnProperty.call(kv, "model")) updates.routerModel = String(kv.model || "").trim();
1638
-
1639
- if (Object.keys(updates).length === 0) {
1640
- logMessage("error", "{white-fg}✗{/white-fg} Usage: /settings router set mode=<main|loop|legacy|shadow> provider=<id> model=<id>");
1641
- return;
1642
- }
1643
-
1644
- saveConfig(projectRoot, updates);
1645
- logMessage("system", "{white-fg}✓{/white-fg} gate router config updated");
1646
- if (Object.prototype.hasOwnProperty.call(updates, "controllerMode")) {
1647
- logMessage("system", ` • controllerMode: ${updates.controllerMode}`);
1648
- }
1649
- if (Object.prototype.hasOwnProperty.call(updates, "routerProvider")) {
1650
- logMessage("system", ` • provider: ${updates.routerProvider || "(unset)"}`);
1651
- }
1652
- if (Object.prototype.hasOwnProperty.call(updates, "routerModel")) {
1653
- logMessage("system", ` • model: ${updates.routerModel || "(unset)"}`);
1654
- }
1655
- await restartDaemon(projectRoot);
1656
- return;
1657
- }
1658
-
1659
- if (action === "clear") {
1660
- const fieldsRaw = args.slice(1).map((item) => String(item || "").trim().toLowerCase()).filter(Boolean);
1661
- const fields = fieldsRaw.length === 0 ? ["all"] : fieldsRaw;
1662
- const updates = {};
1663
- const clearAll = fields.includes("all");
1664
- if (clearAll || fields.includes("mode")) updates.controllerMode = "main";
1665
- if (clearAll || fields.includes("provider")) updates.routerProvider = "";
1666
- if (clearAll || fields.includes("model")) updates.routerModel = "";
1667
- if (Object.keys(updates).length === 0) {
1668
- logMessage("error", "{white-fg}✗{/white-fg} Usage: /settings router clear [mode|provider|model|all]");
1452
+ if (options.applyAgentSettings) {
1453
+ const result = await options.applyAgentSettings(updates);
1454
+ if (!result.ok) logMessage("error", result.error);
1669
1455
  return;
1670
1456
  }
1671
1457
  saveConfig(projectRoot, updates);
1672
- logMessage("system", "{white-fg}✓{/white-fg} gate router config cleared");
1458
+ logMessage("system", "{white-fg}✓{/white-fg} ufoo-agent config cleared");
1673
1459
  await restartDaemon(projectRoot);
1674
1460
  return;
1675
1461
  }
1676
1462
 
1677
- const nextMode = normalizeControllerMode(action);
1678
- if (nextMode !== action || !["main", "loop", "legacy", "shadow"].includes(nextMode)) {
1679
- logMessage("error", "{white-fg}✗{/white-fg} Usage: /settings router <main|loop|legacy|shadow>");
1680
- return;
1681
- }
1682
-
1683
- saveConfig(projectRoot, { controllerMode: nextMode });
1684
- logMessage("system", `{white-fg}✓{/white-fg} gate router mode set to ${nextMode}`);
1685
- await restartDaemon(projectRoot);
1463
+ logMessage("error", "{white-fg}✗{/white-fg} Unknown settings agent action. Use: show, set, clear, codex, claude, agy, kimi, grok");
1686
1464
  }
1687
1465
 
1688
1466
  function parseUcodeConfigKv(args = []) {
@@ -1788,7 +1566,13 @@ function createCommandExecutor(options = {}) {
1788
1566
  const kvArgs = hasInlineKv ? args : args.slice(1);
1789
1567
  const kv = parseUcodeConfigKv(kvArgs);
1790
1568
  const updates = {};
1791
- if (Object.prototype.hasOwnProperty.call(kv, "provider")) updates.ucodeProvider = String(kv.provider || "").trim();
1569
+ if (Object.prototype.hasOwnProperty.call(kv, "provider")) {
1570
+ updates.ucodeProvider = String(kv.provider || "").trim();
1571
+ if (["anthropic", "anthropic-messages"].includes(updates.ucodeProvider.toLowerCase())) {
1572
+ logMessage("error", "Custom APIs use OpenAI protocol. Use provider=openai; internal Claude retains its native connection.");
1573
+ return;
1574
+ }
1575
+ }
1792
1576
  if (Object.prototype.hasOwnProperty.call(kv, "model")) updates.ucodeModel = String(kv.model || "").trim();
1793
1577
  if (Object.prototype.hasOwnProperty.call(kv, "url")) updates.ucodeBaseUrl = String(kv.url || "").trim();
1794
1578
  if (Object.prototype.hasOwnProperty.call(kv, "baseurl")) updates.ucodeBaseUrl = String(kv.baseurl || "").trim();
@@ -1797,9 +1581,12 @@ function createCommandExecutor(options = {}) {
1797
1581
  if (Object.prototype.hasOwnProperty.call(kv, "apikey")) updates.ucodeApiKey = String(kv.apikey || "").trim();
1798
1582
  if (Object.prototype.hasOwnProperty.call(kv, "api_key")) updates.ucodeApiKey = String(kv.api_key || "").trim();
1799
1583
  if (Object.prototype.hasOwnProperty.call(kv, "token")) updates.ucodeApiKey = String(kv.token || "").trim();
1584
+ if ((updates.ucodeBaseUrl || updates.ucodeApiKey) && !updates.ucodeProvider && !(loadUcodeConfig() || {}).ucodeProvider) {
1585
+ updates.ucodeProvider = "openai";
1586
+ }
1800
1587
 
1801
1588
  if (Object.keys(updates).length === 0) {
1802
- logMessage("error", "{white-fg}✗{/white-fg} Usage: /settings ucode set provider=<openai|anthropic> model=<id> url=<baseUrl> key=<apiKey>");
1589
+ logMessage("error", "{white-fg}✗{/white-fg} Usage: /settings ucode set provider=openai model=<id> url=<baseUrl> key=<apiKey>");
1803
1590
  return;
1804
1591
  }
1805
1592
 
@@ -1930,6 +1717,24 @@ function createCommandExecutor(options = {}) {
1930
1717
  const { command, args } = parsed;
1931
1718
 
1932
1719
  switch (command) {
1720
+ case "session": {
1721
+ if (args[0] === "new") options.setRuntimeSession?.(`main-${require("crypto").randomUUID()}`);
1722
+ logMessage("system", `Conversation: ${options.getRuntimeSession?.() || "main-default"}`);
1723
+ return true;
1724
+ }
1725
+ case "task": {
1726
+ const operation = args[0] || "list";
1727
+ if (operation === "list") send({ type: IPC_REQUEST_TYPES.AGENT_RUNTIME, operation: "status" });
1728
+ else if (operation === "cancel" && args[1]) send({ type: IPC_REQUEST_TYPES.AGENT_RUNTIME, operation: "cancel", task_run_id: args[1] });
1729
+ else if (operation === "inspect" && args[1]) send({ type: IPC_REQUEST_TYPES.AGENT_RUNTIME, operation: "tasks", arguments: { operation: "inspect", task_run_id: args[1] } });
1730
+ else logMessage("error", "Usage: /task list | inspect <run-id> | cancel <run-id>");
1731
+ return true;
1732
+ }
1733
+ case "answer": {
1734
+ if (args.length < 2) logMessage("error", "Usage: /answer <interaction-id> <reply>");
1735
+ else send({ type: IPC_REQUEST_TYPES.AGENT_RUNTIME, operation: "resume", interaction_id: args[0], answer: args.slice(1).join(" ") });
1736
+ return true;
1737
+ }
1933
1738
  case "clear":
1934
1739
  if (typeof clearLog === "function") {
1935
1740
  clearLog();
@@ -1937,11 +1742,11 @@ function createCommandExecutor(options = {}) {
1937
1742
  logMessage("error", "{white-fg}✗{/white-fg} /clear is not available in this view");
1938
1743
  }
1939
1744
  return true;
1940
- case "multi":
1941
- if (typeof options.toggleMultiWindow === "function") {
1942
- options.toggleMultiWindow();
1745
+ case "window":
1746
+ if (typeof options.setWindowLayout === "function") {
1747
+ await options.setWindowLayout(args);
1943
1748
  } else {
1944
- logMessage("error", "{white-fg}✗{/white-fg} Multi-window mode is not available");
1749
+ logMessage("error", "{white-fg}✗{/white-fg} Window layouts are not available");
1945
1750
  }
1946
1751
  return true;
1947
1752
  case "mcp":
@@ -1989,9 +1794,6 @@ function createCommandExecutor(options = {}) {
1989
1794
  case "cron":
1990
1795
  await handleCronCommand(args);
1991
1796
  return true;
1992
- case "mode":
1993
- await handleModeCommand(args);
1994
- return true;
1995
1797
  case "provider":
1996
1798
  await handleProviderCommand(args);
1997
1799
  return true;
@@ -2027,7 +1829,6 @@ function createCommandExecutor(options = {}) {
2027
1829
  handleRoleCommand,
2028
1830
  handleSoloCommand,
2029
1831
  handleCronCommand,
2030
- handleModeCommand,
2031
1832
  handleProviderCommand,
2032
1833
  handleGroupCommand,
2033
1834
  handleSettingsCommand,
@@ -2038,7 +1839,4 @@ function createCommandExecutor(options = {}) {
2038
1839
 
2039
1840
  module.exports = {
2040
1841
  createCommandExecutor,
2041
- collectHostLaunchRequestContext,
2042
- collectTerminalLaunchRequestContext,
2043
- collectTmuxLaunchRequestContext,
2044
1842
  };