u-foo 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/OBSERVABILITY.md +65 -0
  2. package/README.md +88 -30
  3. package/README.zh-CN.md +76 -26
  4. package/SKILLS/ufoo/SKILL.md +25 -1
  5. package/SKILLS/ufoo-bus/SKILL.md +25 -2
  6. package/bin/ufoo.js +3 -3
  7. package/dist/tui/darwin-arm64/ufoo-tui +0 -0
  8. package/dist/tui/darwin-x64/ufoo-tui +0 -0
  9. package/dist/tui/linux-arm64/ufoo-tui +0 -0
  10. package/dist/tui/linux-x64/ufoo-tui +0 -0
  11. package/package.json +6 -6
  12. package/src/agents/activity/activityDetector.js +1 -1
  13. package/src/agents/capabilities/agentManagement/service.js +40 -13
  14. package/src/agents/capabilities/coordination/index.js +1 -1
  15. package/src/agents/capabilities/taskReports/index.js +1 -1
  16. package/src/agents/controller/controllerToolExecutor.js +36 -20
  17. package/src/agents/controller/index.js +1 -6
  18. package/src/agents/internal/internalRunner.js +90 -56
  19. package/src/agents/launch/index.js +0 -1
  20. package/src/agents/launch/launcher.js +8 -8
  21. package/src/agents/launch/notifier.js +2 -2
  22. package/src/agents/launch/readyDetector.js +2 -2
  23. package/src/agents/profiles/main.js +1 -1
  24. package/src/agents/prompts/cooperation.js +14 -0
  25. package/src/agents/prompts/defaultBootstrap.js +1 -1
  26. package/src/agents/prompts/groupBootstrap.js +23 -7
  27. package/src/agents/prompts/mainAgent.js +11 -2
  28. package/src/agents/prompts/native/system.js +4 -1
  29. package/src/agents/prompts/native/ufoo.js +11 -3
  30. package/src/agents/prompts/promptProfiles.js +2 -0
  31. package/src/agents/prompts/reporting.js +16 -0
  32. package/src/agents/providers/claudeEventTranslator.js +3 -0
  33. package/src/agents/providers/claudeThreadProvider.js +3 -2
  34. package/src/agents/providers/clientIdentity.js +75 -0
  35. package/src/agents/providers/codexEventTranslator.js +23 -2
  36. package/src/agents/providers/codexThreadProvider.js +15 -6
  37. package/src/agents/providers/credentials/index.js +2 -0
  38. package/src/agents/providers/directAuthStatus.js +1 -1
  39. package/src/agents/providers/index.js +1 -1
  40. package/src/agents/providers/modelSettings.js +34 -0
  41. package/src/agents/providers/modelsCatalog.js +379 -0
  42. package/src/agents/providers/nativeTransport.js +50 -39
  43. package/src/agents/providers/runtimeConfig.js +10 -8
  44. package/src/agents/providers/thinkingLevels.js +10 -36
  45. package/src/agents/providers/transports/responsesProtocol.js +11 -6
  46. package/src/agents/providers/upstreamRuntime.js +135 -0
  47. package/src/agents/runtime/context/checkpointStore.js +38 -0
  48. package/src/agents/runtime/context/compaction.js +151 -0
  49. package/src/agents/runtime/context/contextBudget.js +93 -0
  50. package/src/agents/runtime/context/replayHistory.js +28 -0
  51. package/src/agents/runtime/context/runtimeStore.js +2 -1
  52. package/src/agents/runtime/core/agentLoop.js +99 -18
  53. package/src/agents/runtime/core/executionBudget.js +36 -0
  54. package/src/agents/runtime/createAgentRuntime.js +16 -4
  55. package/src/agents/runtime/prompts/responseLanguage.js +12 -0
  56. package/src/agents/runtime/protocol/runObservation.js +24 -0
  57. package/src/agents/runtime/protocol/traceContext.js +9 -0
  58. package/src/app/chat/ChatController.js +26 -53
  59. package/src/app/chat/agentDirectory.js +1 -16
  60. package/src/app/chat/bootstrap.js +1 -2
  61. package/src/app/chat/commandExecutor.js +93 -285
  62. package/src/app/chat/commands.js +32 -45
  63. package/src/app/chat/daemonMessageRouter.js +0 -45
  64. package/src/app/chat/historyStore.js +12 -48
  65. package/src/app/chat/inputSubmitHandler.js +7 -33
  66. package/src/app/chat/internalAgentLogHistory.js +19 -60
  67. package/src/app/chat/multiWindow/paneManager.js +10 -3
  68. package/src/app/chat/streamState.js +0 -4
  69. package/src/app/cli/features/init.js +5 -5
  70. package/src/app/cli/metricsCommands.js +68 -0
  71. package/src/app/cli/run.js +42 -3
  72. package/src/app/cli/traceCommands.js +36 -0
  73. package/src/code/agent.js +18 -13
  74. package/src/code/busConsumer.js +1 -3
  75. package/src/code/commands.js +1 -1
  76. package/src/code/context/assembler.js +7 -8
  77. package/src/code/context/stateCommit.js +2 -1
  78. package/src/code/internalThread.js +10 -3
  79. package/src/code/launcher/ucode.js +1 -1
  80. package/src/code/launcher/ucodeBootstrap.js +1 -1
  81. package/src/code/modelCommand.js +11 -35
  82. package/src/code/nativeRunner.js +55 -17
  83. package/src/code/providers/modelsCatalog.js +1 -317
  84. package/src/code/repl.js +2 -11
  85. package/src/code/sessionStore.js +3 -3
  86. package/src/code/taskDecomposer.js +18 -0
  87. package/src/code/toolBudget.js +1 -17
  88. package/src/config.js +22 -72
  89. package/src/coordination/bus/index.js +12 -3
  90. package/src/coordination/bus/inject.js +2 -2
  91. package/src/coordination/bus/message.js +15 -1
  92. package/src/coordination/bus/nickname.js +1 -1
  93. package/src/coordination/bus/subscriber.js +3 -2
  94. package/src/coordination/bus/utils.js +1 -1
  95. package/src/coordination/history/agentPerformance.js +279 -0
  96. package/src/coordination/history/agentTrace.js +249 -0
  97. package/src/coordination/state/workspaceAccess.js +1 -1
  98. package/src/orchestration/controller/index.js +1 -8
  99. package/src/orchestration/controller/launchRouting.js +1 -1
  100. package/src/orchestration/solo/commands.js +3 -1
  101. package/src/runtime/contracts/agentMode.js +11 -2
  102. package/src/runtime/contracts/uiProtocol.js +18 -19
  103. package/src/runtime/daemon/agentHost.js +57 -25
  104. package/src/runtime/daemon/agentRecoveryGroups.js +70 -0
  105. package/src/runtime/daemon/busBridge.js +1 -1
  106. package/src/runtime/daemon/controlPlaneService.js +1 -1
  107. package/src/runtime/daemon/groupOrchestrator.js +20 -5
  108. package/src/runtime/daemon/groupStatus.js +20 -0
  109. package/src/runtime/daemon/index.js +19 -44
  110. package/src/runtime/daemon/mcpServer.js +1 -1
  111. package/src/runtime/daemon/nicknameScope.js +1 -1
  112. package/src/runtime/daemon/ops.js +46 -23
  113. package/src/runtime/daemon/projectRuntimeGateway.js +2 -0
  114. package/src/runtime/daemon/promptRequest.js +92 -589
  115. package/src/runtime/daemon/status.js +5 -6
  116. package/src/tools/controllerSchemas.js +6 -2
  117. package/src/tools/handlers/tier2.js +4 -2
  118. package/src/tools/registry.js +4 -0
  119. package/src/tools/schemaFixtures.js +26 -2
  120. package/src/tools/tier0/readAgentMetrics.js +14 -0
  121. package/src/tools/tier0/readAgentTrace.js +12 -0
  122. package/src/ui/agentSettingsController.js +107 -0
  123. package/src/ui/agentSurface.js +1 -1
  124. package/src/ui/dashboardBridge.js +1 -1
  125. package/src/ui/format/banner.js +1 -4
  126. package/src/ui/format/index.js +14 -10
  127. package/src/ui/format/loopSummary.js +50 -0
  128. package/src/ui/format/markdownRenderer.js +3 -4
  129. package/src/ui/rustChatHost.js +191 -206
  130. package/src/ui/rustMultiSession.js +77 -36
  131. package/src/ui/rustUcodeHost.js +1 -1
  132. package/src/ui/settingsBridge.js +33 -16
  133. package/src/ui/toolMergeBridge.js +0 -4
  134. package/src/ui/uiHostServer.js +5 -8
  135. package/src/agents/controller/loopObservability.js +0 -200
  136. package/src/agents/controller/loopRuntime.js +0 -336
  137. package/src/agents/controller/ufooAgent.js +0 -830
  138. package/src/agents/launch/ptyRunner.js +0 -1135
  139. package/src/agents/providers/controllerJsonTransport.js +0 -28
  140. package/src/agents/providers/upstreamTransport.js +0 -698
  141. package/src/app/chat/agentBar.js +0 -135
  142. package/src/app/chat/agentSockets.js +0 -225
  143. package/src/app/chat/dashboardView.js +0 -405
  144. package/src/app/chat/rawKeyMap.js +0 -42
  145. package/src/app/chat/settingsController.js +0 -111
  146. package/src/coordination/history/controllerSummary.js +0 -23
  147. package/src/orchestration/controller/flags.js +0 -167
  148. package/src/orchestration/controller/gateRouter.js +0 -211
  149. package/src/orchestration/controller/routerFastPath.js +0 -22
  150. package/src/orchestration/controller/routerFinalize.js +0 -222
  151. package/src/orchestration/controller/shadowGuard.js +0 -280
  152. package/src/runtime/daemon/executionPaths.js +0 -30
  153. package/src/runtime/daemon/promptLoop.js +0 -136
  154. package/src/runtime/privacy/shadowDiff.js +0 -174
@@ -32,6 +32,7 @@ function projectEvent(state, event) {
32
32
  if (event.type === "runtime.opened" && !state.capabilities) state.capabilities = event.owner.capabilities;
33
33
  if (event.type === "runtime.closed") state.owner = null;
34
34
  if (event.type === "runtime.binding") state.binding = event.binding;
35
+ if (event.type === "context.checkpoint") state.contextCheckpoint = event.checkpoint;
35
36
  if (event.type === "capability.state_committed") state.capabilityState[event.capabilityId] = { version: event.version, value: event.value };
36
37
  if (event.type === "command.started") state.commands[event.commandId] = { ...event, status: "uncertain" };
37
38
  if (event.type === "command.resolved") Object.assign(state.commands[event.commandId], { status: "resolved", result: event.result });
@@ -51,7 +52,7 @@ function projectEvent(state, event) {
51
52
  Object.assign(task, { status: "queued", answer: event.answer, answeredInteractionId: event.interactionId });
52
53
  }
53
54
  if (["task.completed", "task.failed", "task.cancelled", "task.interrupted"].includes(event.type)) {
54
- const result = event.result ? { text: event.result.text, usage: event.result.usage, toolCallsExecuted: event.result.toolCallsExecuted,
55
+ const result = event.result ? { text: event.result.text, ...(typeof event.result.finalText === "string" ? { finalText: event.result.finalText } : {}), usage: event.result.usage, toolCallsExecuted: event.result.toolCallsExecuted,
55
56
  streamed: event.result.streamed } : null;
56
57
  // Full terminal transcripts remain in the journal; projections carry only summaries.
57
58
  Object.assign(task, { status: event.type.split(".")[1], result, error: event.error || "", interactionId: "" });
@@ -6,6 +6,8 @@ const { materializeResolvedToolResults } = require("../protocol/materialize");
6
6
  const { withFaultPoint } = require("../protocol/faultHarness");
7
7
  const { ToolLoopGuard } = require("./toolLoopGuard");
8
8
  const { buildContextMeter, contextTokensFromUsage } = require("../context/contextWindow");
9
+ const { isContextOverflow } = require("../context/compaction");
10
+ const { buildRunObservation, observationFingerprint } = require("../protocol/runObservation");
9
11
 
10
12
  const clone = (value) => JSON.parse(JSON.stringify(value));
11
13
  const count = (value) => Number.isFinite(Number(value)) && Number(value) > 0 ? Math.floor(Number(value)) : 0;
@@ -23,6 +25,7 @@ async function runAgentLoop({
23
25
  transport, tools, policies = [], workspaceRoot = process.cwd(),
24
26
  prompt = "", systemPrompt = "", systemBlocks = null, historyMessages = [],
25
27
  model = "", baseUrl = "", apiKey = "", provider = "", accountId = "", requestHeaders = {}, requestProfile = "",
28
+ thinkingLevel = "", requestKind = "unknown",
26
29
  timeoutMs = 43200000, onStreamDelta = null, onThinkingDelta = null,
27
30
  onPhase = null, onToolEvent = null, onArtifactPersisted = null, onContextUsage = null,
28
31
  sessionId = "", signal = null, guards = null, executionState: initialState = null,
@@ -30,7 +33,9 @@ async function runAgentLoop({
30
33
  sanitizeMessages = (messages) => messages, retireImages = () => {},
31
34
  providerTurnGate = null, maxRounds = Infinity, onEvent = null,
32
35
  projectId = "", agentId = "", taskId = "", taskRunId = "", attemptId = "", requestId = "",
36
+ traceId = "", parentTaskRunId = "", parentSessionId = "",
33
37
  artifactNamespace = "ucode",
38
+ contextManager = null, historyOffset: restoredHistoryOffset = null,
34
39
  } = {}) {
35
40
  const requestModel = String(model || "").trim();
36
41
  if (!requestModel) throw new Error("agent model is not configured");
@@ -40,6 +45,7 @@ async function runAgentLoop({
40
45
  const signalGuards = createExecutionGuards({ signal, timeoutMs });
41
46
  const activeGuards = guards ? { ensureActive() { signalGuards.ensureActive(); guards.ensureActive(); } } : signalGuards;
42
47
  const messages = sanitizeMessages(clone(historyMessages));
48
+ const historyOffset = restoredHistoryOffset ?? (resume ? 0 : messages.filter(message => message.role !== "system").length);
43
49
  if (!resume) transport.prepareMessages({ messages, systemPrompt, prompt });
44
50
  const outputStart = messages.length;
45
51
  const currentTurnItems = () => clone(messages.slice(outputStart)).filter((message) => (
@@ -64,9 +70,13 @@ async function runAgentLoop({
64
70
  let providerMessages = messages;
65
71
  let isolatedPrefix = 0;
66
72
  let turnId = "";
73
+ let lastContextEstimate = 0;
74
+ let forceCompaction = false;
75
+ let contextRetry = false;
67
76
  const context = () => ({ executionState, messages, loopGuard, usage, toolCallsExecuted, toolErrors, turnId });
68
77
  const event = async (type, data = {}) => {
69
- if (onEvent) await onEvent({ type, projectId, agentId, sessionId, taskId, taskRunId, attemptId, requestId, turnId, ...data });
78
+ if (onEvent) await onEvent({ type, time: new Date().toISOString(), projectId, agentId, sessionId, taskId, taskRunId, attemptId, requestId, turnId,
79
+ traceId: traceId || taskId || taskRunId, parentTaskRunId, parentSessionId, ...data });
70
80
  };
71
81
  const policyStop = async (hook, extra = {}) => {
72
82
  for (const policy of policies) {
@@ -84,9 +94,9 @@ async function runAgentLoop({
84
94
  isolatedPrefix = providerMessages.length;
85
95
  };
86
96
  const finish = (extra = {}) => ({
87
- text: aggregated, streamed, toolCallsExecuted, messages,
97
+ text: aggregated, finalText: "", streamed, toolCallsExecuted, messages,
88
98
  turnItems: currentTurnItems(), usage, executionState,
89
- protocolLedger: lastLedger || ledgerApi.snapshotLedger(activeLedger), ...extra,
99
+ protocolLedger: lastLedger || ledgerApi.snapshotLedger(activeLedger), historyOffset, ...extra,
90
100
  });
91
101
  const flush = (calls) => {
92
102
  const pendingById = Object.fromEntries(calls.map((call) => [callId(call), call]));
@@ -101,8 +111,12 @@ async function runAgentLoop({
101
111
  }
102
112
  return null;
103
113
  };
104
- const toolContext = (extra = {}) => ({ workspaceRoot, onToolEvent, sessionId, onArtifactPersisted, executionState, signal,
105
- projectId, agentId, taskId, taskRunId, attemptId, requestId, turnId, artifactNamespace, ...extra });
114
+ const toolContext = (extra = {}) => ({ workspaceRoot, onToolEvent: typeof onToolEvent === "function" ? event => onToolEvent({ ...event,
115
+ ...(event.origin ? { parentToolCallId: extra.toolCallId } : { toolCallId: extra.toolCallId }) }) : null, sessionId, onArtifactPersisted, executionState, signal,
116
+ projectId, agentId, taskId, taskRunId, attemptId, requestId, turnId, traceId: traceId || taskId || taskRunId, parentTaskRunId, parentSessionId, artifactNamespace, ...extra });
117
+ if (onEvent) await event("run.config", { configuration: buildRunObservation({ provider, model: requestModel,
118
+ transport: transport.name || transport.id || "", thinkingLevel, systemPrompt, systemBlocks, prompt,
119
+ tools: tools.toOpenAiTools(), resume, requestKind, engineFingerprint: LOOP_IMPLEMENTATION_FINGERPRINT }) });
106
120
  if (resume) await withFaultPoint("before_provider_resume", () => {});
107
121
 
108
122
  while (true) {
@@ -113,7 +127,7 @@ async function runAgentLoop({
113
127
  turnId = `turn_${randomUUID()}`;
114
128
  providerMessages = messages;
115
129
  for (const policy of policies) {
116
- if (policy.prepareTurn) providerMessages = policy.prepareTurn({ ...context(), providerMessages }) || providerMessages;
130
+ if (policy.prepareTurn) providerMessages = await policy.prepareTurn({ ...context(), providerMessages }) || providerMessages;
117
131
  }
118
132
  isolatedPrefix = providerMessages.length;
119
133
  if (activeLedger) {
@@ -123,17 +137,54 @@ async function runAgentLoop({
123
137
  }
124
138
  }
125
139
  const action = loopGuard.nextAction();
140
+ if (action) await event(`loop.${action.kind === "stop" ? "stopped" : "warning"}`, { code: "repeated_tool_calls", repeatedSteps: loopGuard.count, toolNames: loopGuard.names });
126
141
  if (action && action.kind === "stop") return finish({ error: action.message, stopReason: "repeated_tool_calls" });
127
142
  if (action && action.kind === "warn") providerMessages.push({ role: "user", content: action.message });
143
+ mirror();
144
+
145
+ let maxOutputTokens;
146
+ if (contextManager) {
147
+ let prepared;
148
+ try { prepared = await contextManager.prepare({ messages: providerMessages, model: requestModel, systemPrompt, systemBlocks,
149
+ tools: tools.toOpenAiTools(), transport, signal, onPhase, onEvent: event,
150
+ lastUsage: usage.lastContextTokens, lastEstimate: lastContextEstimate,
151
+ force: forceCompaction,
152
+ request: { url: requestUrl, apiKey, provider, accountId, requestHeaders, requestProfile, sessionId } }); }
153
+ catch (error) {
154
+ // Preflight runs only after tool results are paired. Keep this complete
155
+ // transcript even when compression is cancelled or storage is broken.
156
+ return finish({ error: error.message, stopReason: error.code || "context_compression_failed" });
157
+ }
158
+ providerMessages = prepared.messages;
159
+ lastContextEstimate = prepared.estimatedTokens;
160
+ maxOutputTokens = prepared.maxOutputTokens;
161
+ forceCompaction = false;
162
+ }
163
+ // Only newly generated messages are mirrored into the full transcript.
164
+ isolatedPrefix = providerMessages.length;
128
165
 
129
- await event("model.started");
166
+ try { activeGuards.ensureActive(); }
167
+ catch (error) { return finish({ error: error.message, stopReason: error.code || "runtime_error" }); }
168
+ const modelStarted = Date.now();
169
+ await event("model.started", { provider, model: requestModel, transport: transport.name || transport.id || "", estimatedInputTokens: lastContextEstimate });
130
170
  const streamEvents = [];
131
171
  let streamEventError = null;
132
172
  let turnResult;
173
+ let turnError = null;
174
+ const outputBeforeTurn = aggregated.length;
133
175
  try { turnResult = await transport.runTurn({
134
- url: requestUrl, apiKey, model: requestModel, provider, accountId, requestHeaders, requestProfile,
176
+ url: requestUrl, apiKey, model: requestModel, provider, accountId, requestHeaders, requestProfile, thinkingLevel,
135
177
  systemPrompt, systemBlocks, messages: providerMessages, tools: tools.toOpenAiTools(),
136
- sessionId, signal, timeoutMs, onPhase, onThinkingDelta,
178
+ ...(maxOutputTokens ? { maxOutputTokens } : {}),
179
+ sessionId, signal, timeoutMs,
180
+ onPhase(phase) {
181
+ streamEvents.push(event("model.phase", { phase }).catch(error => { streamEventError ||= error; }));
182
+ onPhase?.(phase);
183
+ },
184
+ onThinkingDelta(delta) {
185
+ streamEvents.push(event("thinking.delta", { text: String(delta || "") }).catch(error => { streamEventError ||= error; }));
186
+ onThinkingDelta?.(delta);
187
+ },
137
188
  onTextDelta(chunk) {
138
189
  const text = String(chunk || "");
139
190
  if (!text) return;
@@ -144,17 +195,27 @@ async function runAgentLoop({
144
195
  }
145
196
  if (typeof onStreamDelta === "function") { streamed = true; onStreamDelta(text); }
146
197
  },
147
- }); } finally {
198
+ }); } catch (error) { turnError = error; } finally {
148
199
  await Promise.all(streamEvents);
149
200
  if (streamEventError) throw streamEventError;
150
201
  }
202
+ if (turnError) {
203
+ await event("model.failed", { error: turnError.message, code: turnError.code || "provider_error", durationMs: Date.now() - modelStarted });
204
+ if (!contextManager || !isContextOverflow(turnError)) throw turnError;
205
+ if (contextRetry || aggregated.length !== outputBeforeTurn) return finish({ error: turnError.message, stopReason: "context_budget_exceeded" });
206
+ contextRetry = true;
207
+ forceCompaction = true;
208
+ await event("model.retry", { code: "context_overflow", retry: 1 });
209
+ continue;
210
+ }
211
+ contextRetry = false;
151
212
  activeGuards.ensureActive();
152
213
  retireImages(providerMessages);
153
214
  if (providerMessages !== messages) retireImages(messages);
154
215
  usage.turns += 1;
155
216
  for (const key of ["input", "output", "cacheRead", "cacheCreation"]) usage[key] += count(turnResult && turnResult.usage && turnResult.usage[key]);
156
217
  usage.lastContextTokens = contextTokensFromUsage(turnResult && turnResult.usage);
157
- await event("model.completed", { usage: turnResult && turnResult.usage || {} });
218
+ await event("model.completed", { usage: turnResult && turnResult.usage || {}, durationMs: Date.now() - modelStarted });
158
219
  if (typeof onContextUsage === "function") {
159
220
  try { onContextUsage(buildContextMeter({ usedTokens: usage.lastContextTokens, model: requestModel })); } catch { /* observer only */ }
160
221
  }
@@ -165,6 +226,7 @@ async function runAgentLoop({
165
226
  if (!text && toolCallsExecuted > 0) {
166
227
  if (emptyRetries >= 2) throw new Error("model returned an empty response after tool execution");
167
228
  emptyRetries += 1;
229
+ await event("model.retry", { code: "empty_response", retry: emptyRetries });
168
230
  providerMessages.push({ role: "user", content: "Continue the current task after the tool results. Call any remaining tools, or provide a concrete final answer to the user. Do not end the turn with an empty response." });
169
231
  mirror();
170
232
  continue;
@@ -194,8 +256,11 @@ async function runAgentLoop({
194
256
  }
195
257
  }
196
258
  }
197
- if (continuation) continue;
198
- return finish();
259
+ if (continuation) {
260
+ await event("model.retry", { code: "auto_continue", retry: autoContinues });
261
+ continue;
262
+ }
263
+ return finish({ finalText: text });
199
264
  }
200
265
  emptyContinues = 0;
201
266
  emptyRetries = 0;
@@ -217,7 +282,10 @@ async function runAgentLoop({
217
282
  let batchError = null;
218
283
  for (const policy of policies) if (policy.validateBatch) { batchError = policy.validateBatch(pending); if (batchError) break; }
219
284
  if (batchError) {
220
- for (const call of pending) { resolve(call, batchError); toolCallsExecuted += 1; toolErrors += 1; }
285
+ for (const call of pending) {
286
+ await event("tool.rejected", { toolCallId: callId(call), toolName: call.name, code: batchError.code || "invalid_batch", argumentFingerprint: observationFingerprint(call.args) });
287
+ resolve(call, batchError); toolCallsExecuted += 1; toolErrors += 1;
288
+ }
221
289
  flush(pending);
222
290
  continue;
223
291
  }
@@ -228,17 +296,28 @@ async function runAgentLoop({
228
296
  const before = toolStop || await policyStop("beforeTool", { call });
229
297
  if (before) {
230
298
  toolStop = before;
299
+ await event("tool.rejected", { toolCallId: callId(call), toolName: name, code: before.stopReason || "stopped", argumentFingerprint: observationFingerprint(call.args) });
231
300
  resolve(call, { ok: false, code: before.stopReason || "stopped", error: "execution stopped before tool invocation" });
232
301
  continue;
233
302
  }
234
303
  let blocked = null;
235
304
  for (const policy of policies) if (policy.validateTool) { blocked = policy.validateTool(name, executionState); if (blocked) break; }
236
- if (blocked) { toolCallsExecuted += 1; toolErrors += 1; resolve(call, blocked); continue; }
305
+ if (blocked) {
306
+ await event("tool.rejected", { toolCallId: callId(call), toolName: name, code: blocked.code || "tool_not_allowed", argumentFingerprint: observationFingerprint(call.args) });
307
+ toolCallsExecuted += 1; toolErrors += 1; resolve(call, blocked); continue;
308
+ }
237
309
  const resumeCall = tools.deferableTools().includes(name) ? { toolCallId: callId(call), toolName: name, call: { name: call.name, args: call.args, source: call.source } } : null;
238
310
  ledgerApi.markExecuting(activeLedger, callId(call));
239
311
  activeGuards.ensureActive();
240
- await event("tool.started", { toolCallId: callId(call), toolName: name, args: call.args });
241
- const result = await tools.execute(name, call.args, toolContext({ resume: resumeCall, toolCallId: callId(call) }));
312
+ await event("tool.started", { toolCallId: callId(call), toolName: name, args: call.args, argumentFingerprint: observationFingerprint(call.args) });
313
+ const toolStarted = Date.now();
314
+ let result;
315
+ try { result = await tools.execute(name, call.args, toolContext({ resume: resumeCall, toolCallId: callId(call) })); }
316
+ catch (error) {
317
+ await event("tool.failed", { toolCallId: callId(call), toolName: name, error: error.message, code: error.code || "tool_execution_failed",
318
+ outcome: "unknown", durationMs: Date.now() - toolStarted });
319
+ throw error;
320
+ }
242
321
  activeGuards.ensureActive();
243
322
  if (result && result.executionState) executionState = result.executionState;
244
323
  toolCallsExecuted += 1;
@@ -251,7 +330,7 @@ async function runAgentLoop({
251
330
  continue;
252
331
  }
253
332
  resolve(call, result);
254
- await event("tool.completed", { toolCallId: callId(call), toolName: name, result: sanitizeResult(result) });
333
+ await event("tool.completed", { toolCallId: callId(call), toolName: name, result: sanitizeResult(result), durationMs: Date.now() - toolStarted });
255
334
  toolStop = await policyStop("afterTool", { call, result });
256
335
  if (toolStop) continue;
257
336
  if (toolBudget.maxToolCalls != null && toolCallsExecuted >= toolBudget.maxToolCalls) throw new Error(`tool call budget exceeded (${toolBudget.maxToolCalls})`);
@@ -267,4 +346,6 @@ async function runAgentLoop({
267
346
  }
268
347
  }
269
348
 
349
+ const LOOP_IMPLEMENTATION_FINGERPRINT = observationFingerprint(runAgentLoop.toString());
350
+
270
351
  module.exports = { runAgentLoop, createExecutionGuards };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ const DEFAULT_TASK_TIMEOUT_MS = 43200000;
4
+ const DEFAULT_MAX_TOOL_ERRORS = 20;
5
+
6
+ function parseMaxToolCalls(value) {
7
+ if (value == null || String(value).trim().toLowerCase() === "none") return null;
8
+ const text = String(value).trim();
9
+ const count = Number(text);
10
+ if (!/^\d+$/.test(text) || !Number.isSafeInteger(count) || count <= 0) {
11
+ throw new Error("max tool calls must be a positive integer or none");
12
+ }
13
+ return count;
14
+ }
15
+
16
+ function resolveMaxToolCalls(value, env = process.env) {
17
+ if (value !== undefined) return parseMaxToolCalls(value);
18
+ const configured = env.UFOO_UCODE_MAX_TOOL_CALLS;
19
+ return configured == null || String(configured).trim() === "" ? null : parseMaxToolCalls(configured);
20
+ }
21
+
22
+ function resolveToolBudget(maxToolCalls, env = process.env) {
23
+ const errors = Number.parseInt(String(env.UFOO_UCODE_MAX_TOOL_ERRORS || ""), 10);
24
+ return {
25
+ maxToolCalls: resolveMaxToolCalls(maxToolCalls, env),
26
+ maxToolErrors: Number.isFinite(errors) && errors > 0 ? errors : DEFAULT_MAX_TOOL_ERRORS,
27
+ };
28
+ }
29
+
30
+ function resolveTaskTimeoutMs(value, env = process.env) {
31
+ if (Number.isFinite(value) && value > 0) return Math.max(1000, Math.floor(value));
32
+ const configured = Number(env.UFOO_UCODE_TASK_TIMEOUT_MS);
33
+ return Number.isFinite(configured) && configured > 0 ? Math.max(1000, Math.floor(configured)) : DEFAULT_TASK_TIMEOUT_MS;
34
+ }
35
+
36
+ module.exports = { DEFAULT_TASK_TIMEOUT_MS, DEFAULT_MAX_TOOL_ERRORS, parseMaxToolCalls, resolveMaxToolCalls, resolveToolBudget, resolveTaskTimeoutMs };
@@ -10,6 +10,13 @@ const { stableStringify } = require("./core/stableJson");
10
10
  const terminal = new Set(["completed", "failed", "cancelled", "interrupted", "waiting_user"]);
11
11
  const pidAlive = (pid) => { try { process.kill(pid, 0); return true; } catch (error) { return error.code !== "ESRCH"; } };
12
12
 
13
+ function terminalResult(result) {
14
+ if (!Array.isArray(result?.messages) || !Number.isInteger(result.historyOffset)) return result;
15
+ // Persist this invocation once, rather than repeating all preceding turns.
16
+ // Paused invocations retain their full input separately for tool resume.
17
+ return { ...result, messages: result.messages.filter(message => message.role !== "system").slice(result.historyOffset), historyOffset: 0 };
18
+ }
19
+
13
20
  /** A host injects persistence and preparation; core owns accepted invocation lifecycle. */
14
21
  function createAgentRuntime({ profile, transport, capabilities, host = {}, defaults = {} } = {}) {
15
22
  assertTransport(transport);
@@ -66,7 +73,9 @@ function createAgentRuntime({ profile, transport, capabilities, host = {}, defau
66
73
  const before = store.read();
67
74
  const task = before.tasks[event.taskRunId];
68
75
  event = { version: 1, projectId: host.projectId || "", agentId: host.agentId || "", sessionId: before.sessionId,
69
- requestId: task?.request.requestId || "", taskId: task?.request.taskId || event.taskRunId || "", attemptId: task?.attemptId || "", ...event };
76
+ requestId: task?.request.requestId || "", taskId: task?.request.taskId || event.taskRunId || "", attemptId: task?.attemptId || "",
77
+ traceId: task?.request.traceId || task?.request.taskId || event.taskRunId || "",
78
+ parentTaskRunId: task?.request.parentTaskRunId || "", parentSessionId: task?.request.parentSessionId || "", ...event };
70
79
  let sequence;
71
80
  const snapshot = store.transaction((state) => { sequence = state.sequence + 1; return [event]; });
72
81
  const committed = store.events({ after: sequence - 1 }).find((entry) => entry.sequence === sequence);
@@ -100,21 +109,24 @@ function createAgentRuntime({ profile, transport, capabilities, host = {}, defau
100
109
  : host.prepareRequest ? await host.prepareRequest(task.request, task) : { prompt: task.request.text };
101
110
  return runtime.run({ ...prepared, requestId: task.request.requestId,
102
111
  taskId: task.request.taskId || task.taskRunId, taskRunId: task.taskRunId, attemptId,
112
+ traceId: task.request.traceId || task.request.taskId || task.taskRunId,
113
+ parentTaskRunId: task.request.parentTaskRunId || "", parentSessionId: task.request.parentSessionId || "",
103
114
  signal, onEvent: record });
104
115
  };
105
116
  const result = host.taskScheduler
106
117
  ? await host.taskScheduler.schedule({ id: task.taskRunId, resourceKey: task.request.resourceKey || "", signal: controller.signal }, execute)
107
118
  : await execute(controller.signal);
108
119
  if (controller.signal.aborted) throw Object.assign(new Error("agent cancelled"), { code: "cancelled" });
109
- if (result.error || result.stopReason) throw Object.assign(new Error(result.error || `agent stopped: ${result.stopReason}`), { code: result.stopReason || "runtime_error" });
110
- await record({ type: result.waitingUserInteraction ? "task.paused" : "task.completed", taskRunId: activeTask, result });
120
+ if (result.error || result.stopReason) throw Object.assign(new Error(result.error || `agent stopped: ${result.stopReason}`), { code: result.stopReason || "runtime_error", result });
121
+ await record({ type: result.waitingUserInteraction ? "task.paused" : "task.completed", taskRunId: activeTask,
122
+ result: result.waitingUserInteraction ? result : terminalResult(result) });
111
123
  } catch (error) {
112
124
  if (store.read().tasks[activeTask]?.status === "completed") {
113
125
  if (host.onError) host.onError(error);
114
126
  continue;
115
127
  }
116
128
  await record({ type: controller.signal.aborted || error.code === "cancelled" ? "task.cancelled" : "task.failed",
117
- taskRunId: activeTask, error: error.message });
129
+ taskRunId: activeTask, error: error.message, code: error.code || "runtime_error", ...(error.result ? { result: terminalResult(error.result) } : {}) });
118
130
  } finally { activeTask = ""; controller = null; }
119
131
  }
120
132
  }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ const RESPONSE_LANGUAGE_GUIDANCE = [
4
+ "Response language:",
5
+ "- Use the same natural language as the user's prompt for the current task, unless the user explicitly requests another language. This applies to replies, acknowledgements, progress updates, report summaries, handoffs, and final answers.",
6
+ "- For delegated work, follow the original user's language or the response-language requirement passed by the parent. English system instructions, tool output, and bus protocol text do not change the response language.",
7
+ "- When delegating, preserve the user's language in the task text or explicitly pass the required response language to the worker.",
8
+ "- For brief or ambiguous continuations, keep the language established by the user's substantive request. For multilingual prompts, follow an explicit language preference or the primary language of the user's prose.",
9
+ "- Keep code, commands, paths, identifiers, quoted error text, and required protocol keys and enum values literal.",
10
+ ].join("\n");
11
+
12
+ module.exports = { RESPONSE_LANGUAGE_GUIDANCE };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ const { createHash } = require("crypto");
4
+ const { stableStringify } = require("../core/stableJson");
5
+ const { version } = require("../../../../package.json");
6
+
7
+ function observationFingerprint(value) {
8
+ return createHash("sha256").update(stableStringify(value) || "null").digest("hex");
9
+ }
10
+
11
+ // Configuration evidence only: no credentials, headers, URLs or prompt bodies.
12
+ function buildRunObservation({ provider = "", model = "", transport = "", thinkingLevel = "",
13
+ systemPrompt = "", systemBlocks = null, prompt = "", tools = [], resume = false, executionKind = "native", engineFingerprint = null, requestKind = "unknown" } = {}) {
14
+ const config = { version: 1, runtimeVersion: version, engineFingerprint, executionKind, provider, model, transport,
15
+ thinkingLevel, requestKind, resumed: Boolean(resume),
16
+ promptFingerprint: observationFingerprint(systemBlocks || systemPrompt),
17
+ inputFingerprint: prompt ? observationFingerprint(prompt) : null,
18
+ toolSchemaFingerprint: tools.length ? observationFingerprint(tools) : null,
19
+ toolCount: executionKind === "sdk" && !tools.length ? null : tools.length,
20
+ toolInventoryScope: executionKind === "sdk" ? "ufoo-exposed" : "runtime" };
21
+ return { ...config, configurationFingerprint: observationFingerprint({ ...config, inputFingerprint: undefined, resumed: undefined }) };
22
+ }
23
+
24
+ module.exports = { buildRunObservation, observationFingerprint };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ // Correlation metadata is observational. It never grants authority or identity.
4
+ const TRACE_FIELDS = Object.freeze(["traceId", "taskId", "taskRunId", "parentTaskRunId", "parentSessionId", "parentRequestId", "requestId", "attemptId"]);
5
+ function normalizeTraceContext(input = {}) {
6
+ return Object.fromEntries(TRACE_FIELDS.filter(key => typeof input?.[key] === "string" && input[key].length <= 256 && input[key].trim())
7
+ .map(key => [key, input[key].trim()]));
8
+ }
9
+ module.exports = { normalizeTraceContext };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  /**
4
- * Headless ChatController — composition root for Ink + Rust chat adapters.
4
+ * Headless ChatController — composition root for Rust chat.
5
5
  *
6
6
  * Owns stream state, STATUS→agents snapshot, slash/submit wiring ports.
7
7
  * View adapters attach via `ports` (dispatch / publish / log / setStatus).
@@ -21,7 +21,6 @@ const {
21
21
  buildAgentMaps,
22
22
  resolveAgentId,
23
23
  normalizeStatusToAgentsSnapshot,
24
- toInkAgentsDispatchList,
25
24
  } = require("./agentDirectory");
26
25
  const { buildPromptIpcRequest, buildDirectBusSendRequest } = require("./ipcBuilders");
27
26
  const { IPC_REQUEST_TYPES } = require("../../runtime/contracts/eventContract");
@@ -29,7 +28,6 @@ const { IPC_REQUEST_TYPES } = require("../../runtime/contracts/eventContract");
29
28
  function createChatController({
30
29
  projectRoot = process.cwd(),
31
30
  globalMode = false,
32
- internalOnly = false,
33
31
  ports = {},
34
32
  } = {}) {
35
33
  const view = {
@@ -38,9 +36,6 @@ function createChatController({
38
36
  setStatus: typeof ports.setStatus === "function" ? ports.setStatus : () => {},
39
37
  publish: typeof ports.publish === "function" ? ports.publish : () => {},
40
38
  getState: typeof ports.getState === "function" ? ports.getState : () => ({}),
41
- mapAgentsForDispatch: typeof ports.mapAgentsForDispatch === "function"
42
- ? ports.mapAgentsForDispatch
43
- : (snapshot) => snapshot.agents,
44
39
  appendHistory: typeof ports.appendHistory === "function"
45
40
  ? ports.appendHistory
46
41
  : (type, text, meta) => appendChatHistory(projectRoot, type, text, meta, { globalMode }),
@@ -72,12 +67,13 @@ function createChatController({
72
67
 
73
68
  function setSend(fn) {
74
69
  daemonSend = typeof fn === "function" ? (req) => fn(req.type === IPC_REQUEST_TYPES.PROMPT || req.type === IPC_REQUEST_TYPES.AGENT_RUNTIME
75
- ? { ...req, request_id: req.request_id || require("crypto").randomUUID(), session_id: req.session_id || session.runtimeSessionId } : req) : () => {};
70
+ ? { ...req, request_id: req.request_id || require("crypto").randomUUID(), session_id: req.session_id
71
+ || require("../../config").loadConfig(ports.getActiveProjectRoot?.() || projectRoot).agentConversationId || session.runtimeSessionId } : req) : () => {};
76
72
  }
77
73
  setSend(view.send);
78
74
 
79
75
  function applyStatus(data = {}) {
80
- const snapshot = normalizeStatusToAgentsSnapshot(data, { internalOnly });
76
+ const snapshot = normalizeStatusToAgentsSnapshot(data, { internalOnly: true });
81
77
  session.agents = snapshot.agents.map((row) => row.id || row.fullId);
82
78
  session.metaMap = snapshot.metaMap;
83
79
  session.labelMap = snapshot.labelMap;
@@ -95,20 +91,20 @@ function createChatController({
95
91
  cron: snapshot.cron,
96
92
  loop: snapshot.loop,
97
93
  });
98
- view.dispatch({ type: "agents/set", list: view.mapAgentsForDispatch(snapshot) });
94
+ view.dispatch({ type: "agents/set", list: snapshot.agents });
99
95
  return snapshot;
100
96
  }
101
97
 
102
98
  function patchAgentActivity(agentId, patch = {}) {
103
99
  if (!agentId) return;
104
- if (internalOnly && !session.metaMap.has(agentId)) return;
100
+ if (!session.metaMap.has(agentId)) return;
105
101
  const existing = session.metaMap.get(agentId) || { id: agentId };
106
102
  const next = { ...existing, ...patch };
107
103
  session.metaMap.set(agentId, next);
108
104
  const rebuilt = normalizeStatusToAgentsSnapshot({
109
105
  active: session.agents,
110
106
  active_meta: session.agents.map((id) => session.metaMap.get(id) || { id }),
111
- }, { internalOnly });
107
+ }, { internalOnly: true });
112
108
  session.footer = rebuilt.footer;
113
109
  view.publish("agents.patch", {
114
110
  agents: rebuilt.agents.map((row) => ({
@@ -130,12 +126,10 @@ function createChatController({
130
126
  const { createCommandExecutor } = require("./commandExecutor");
131
127
  const { parseCommand } = require("./commands");
132
128
  const { startDaemon, stopDaemon } = require("./transport");
133
- const AgentActivator = require("../../coordination/bus/activate");
134
129
  const fs = require("fs");
135
130
 
136
131
  commandExecutor = createCommandExecutor({
137
132
  projectRoot,
138
- internalOnly,
139
133
  getActiveProjectRoot: typeof ports.getActiveProjectRoot === "function"
140
134
  ? ports.getActiveProjectRoot
141
135
  : () => projectRoot,
@@ -174,18 +168,22 @@ function createChatController({
174
168
  ? ports.restartDaemon
175
169
  : async () => {},
176
170
  send: (req) => daemonSend(req),
177
- setRuntimeSession: (id) => { session.runtimeSessionId = id; },
178
- getRuntimeSession: () => session.runtimeSessionId,
171
+ setRuntimeSession: (id) => {
172
+ session.runtimeSessionId = id;
173
+ require("../../config").saveConfig(ports.getActiveProjectRoot?.() || projectRoot, { agentConversationId: id });
174
+ },
175
+ getRuntimeSession: () => require("../../config").loadConfig(ports.getActiveProjectRoot?.() || projectRoot).agentConversationId || session.runtimeSessionId,
176
+ openAgentSettings: ports.openAgentSettings,
177
+ applyAgentModel: ports.applyAgentModel,
178
+ applyAgentSettings: ports.applyAgentSettings,
179
179
  requestStatus: () => {
180
180
  if (typeof requestDaemonStatus === "function") requestDaemonStatus();
181
181
  else daemonSend({ type: IPC_REQUEST_TYPES.STATUS });
182
182
  },
183
183
  requestCron: (payload = {}) => daemonSend({ type: IPC_REQUEST_TYPES.CRON, ...payload }),
184
184
  activateAgent: async (target) => {
185
- if (typeof ports.activateAgent === "function") return ports.activateAgent(target);
186
- if (internalOnly) return;
187
- const activator = new AgentActivator(projectRoot);
188
- await activator.activate(target);
185
+ if (!session.metaMap.has(target)) return;
186
+ return ports.activateInternalAgent?.(target);
189
187
  },
190
188
  globalMode: Boolean(globalMode),
191
189
  listProjects: typeof ports.listProjects === "function"
@@ -197,14 +195,15 @@ function createChatController({
197
195
  switchProject: typeof ports.switchProject === "function"
198
196
  ? ports.switchProject
199
197
  : async () => ({ ok: false, error: "project switching unavailable" }),
200
- toggleMultiWindow: typeof ports.toggleMultiWindow === "function"
201
- ? ports.toggleMultiWindow
198
+ setWindowLayout: typeof ports.setWindowLayout === "function"
199
+ ? ports.setWindowLayout
202
200
  : () => {
203
- view.logMessage("system", "Multi-window unavailable in this host.");
201
+ view.logMessage("system", "Window layouts unavailable in this host.");
204
202
  },
205
203
  applyChatSettings: typeof ports.applyChatSettings === "function"
206
204
  ? ports.applyChatSettings
207
205
  : null,
206
+ openResumeMenu: typeof ports.openResumeMenu === "function" ? ports.openResumeMenu : null,
208
207
  });
209
208
  return commandExecutor;
210
209
  }
@@ -233,7 +232,7 @@ function createChatController({
233
232
  });
234
233
  submitHandler = createInputSubmitHandler({
235
234
  state: submitState,
236
- requireKnownTarget: internalOnly,
235
+ requireKnownTarget: true,
237
236
  parseAtTarget,
238
237
  resolveAgentId: (label) => resolveAgentId({
239
238
  label,
@@ -275,35 +274,10 @@ function createChatController({
275
274
  const label = getAgentLabel(agentId);
276
275
  view.publish("prompt.set_prefix", { prefix: `›@${label} ` });
277
276
  },
278
- enterAgentView: (agentId, options = {}) => {
279
- if (typeof ports.enterAgentView === "function") {
280
- return ports.enterAgentView(agentId, options);
281
- }
282
- view.logMessage("system", "Agent enter unavailable in this host.");
283
- },
284
- getAgentAdapter: (agentId) => {
285
- if (typeof ports.getAgentAdapter === "function") {
286
- return ports.getAgentAdapter(agentId);
287
- }
288
- try {
289
- const { createTerminalAdapterRouter } = require("../../runtime/terminal/adapterRouter");
290
- const meta = session.metaMap.get(agentId) || {};
291
- const launchMode = String(meta.launch_mode || meta.launchMode || "").trim();
292
- return createTerminalAdapterRouter().getAdapter({ launchMode, agentId, meta });
293
- } catch {
294
- return null;
295
- }
296
- },
297
- activateAgent: async (agentId) => {
298
- if (typeof ports.activateAgent === "function") {
299
- return ports.activateAgent(agentId);
300
- }
301
- const AgentActivator = require("../../coordination/bus/activate");
302
- const root = typeof ports.getActiveProjectRoot === "function"
303
- ? ports.getActiveProjectRoot()
304
- : projectRoot;
305
- const activator = new AgentActivator(root || projectRoot);
306
- await activator.activate(agentId);
277
+ activateInternalAgent: (agentId) => {
278
+ if (!session.metaMap.has(agentId)) return { ok: false, error: "Unknown internal agent" };
279
+ if (typeof ports.activateInternalAgent === "function") return ports.activateInternalAgent(agentId);
280
+ return { ok: false, error: "Internal pane unavailable in this host" };
307
281
  },
308
282
  focusMultiPane: typeof ports.focusMultiPane === "function"
309
283
  ? ports.focusMultiPane
@@ -440,5 +414,4 @@ function createChatController({
440
414
 
441
415
  module.exports = {
442
416
  createChatController,
443
- toInkAgentsDispatchList,
444
417
  };
@@ -83,7 +83,7 @@ function clampAgentWindowWithSelection({
83
83
 
84
84
  /**
85
85
  * Normalize daemon STATUS payload into agents list + footer string.
86
- * Shared by Ink dashboard and Rust `agents.snapshot`.
86
+ * Used by Rust `agents.snapshot`.
87
87
  */
88
88
  function normalizeStatusToAgentsSnapshot(data = {}, { internalOnly = false } = {}) {
89
89
  let activeIds = Array.isArray(data.active) ? data.active : [];
@@ -132,20 +132,6 @@ function normalizeStatusToAgentsSnapshot(data = {}, { internalOnly = false } = {
132
132
  };
133
133
  }
134
134
 
135
- /**
136
- * Ink chatReducer expects `id` as the short agent id and `fullId` as the key.
137
- * Shared so ChatController and ChatApp stay aligned.
138
- */
139
- function toInkAgentsDispatchList(snapshot = {}) {
140
- const agents = Array.isArray(snapshot.agents) ? snapshot.agents : [];
141
- return agents.map((row) => ({
142
- ...row,
143
- fullId: row.fullId || row.id,
144
- id: row.agentId || row.id,
145
- nickname: row.label || row.nickname,
146
- }));
147
- }
148
-
149
135
  module.exports = {
150
136
  buildAgentMaps,
151
137
  getAgentLabel,
@@ -153,5 +139,4 @@ module.exports = {
153
139
  resolveAgentDisplayName,
154
140
  clampAgentWindowWithSelection,
155
141
  normalizeStatusToAgentsSnapshot,
156
- toInkAgentsDispatchList,
157
142
  };
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  /**
4
- * Chat bootstrap helpers (Phase 0B extraction from ChatApp).
5
- * Headless — safe for ChatController and unit tests without Ink.
4
+ * Headless chat bootstrap helpers shared by ChatController and tests.
6
5
  */
7
6
 
8
7
  const path = require("path");