u-foo 4.0.3 → 4.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +239 -19
  2. package/README.zh-CN.md +3 -3
  3. package/bin/ucode.js +10 -2
  4. package/bin/ufoo.js +3 -0
  5. package/dist/tui/darwin-arm64/ufoo-tui +0 -0
  6. package/dist/tui/darwin-x64/ufoo-tui +0 -0
  7. package/dist/tui/linux-arm64/ufoo-tui +0 -0
  8. package/dist/tui/linux-x64/ufoo-tui +0 -0
  9. package/{OBSERVABILITY.md → docs/OBSERVABILITY.md} +3 -3
  10. package/docs/README.md +27 -0
  11. package/extensions/ufoo-browser/LICENSE +152 -0
  12. package/extensions/ufoo-browser/NOTICE +10 -0
  13. package/extensions/ufoo-browser/README.md +30 -0
  14. package/extensions/ufoo-browser/background.js +409 -0
  15. package/extensions/ufoo-browser/icons/icon-128.png +0 -0
  16. package/extensions/ufoo-browser/icons/icon-16.png +0 -0
  17. package/extensions/ufoo-browser/icons/icon-256.png +0 -0
  18. package/extensions/ufoo-browser/icons/icon-32.png +0 -0
  19. package/extensions/ufoo-browser/icons/icon-48.png +0 -0
  20. package/extensions/ufoo-browser/icons/logo.png +0 -0
  21. package/extensions/ufoo-browser/icons/toolbar-16.png +0 -0
  22. package/extensions/ufoo-browser/icons/toolbar-32.png +0 -0
  23. package/extensions/ufoo-browser/icons/toolbar-logo.png +0 -0
  24. package/extensions/ufoo-browser/manifest.json +30 -0
  25. package/extensions/ufoo-browser/popup.css +71 -0
  26. package/extensions/ufoo-browser/popup.html +44 -0
  27. package/extensions/ufoo-browser/popup.js +153 -0
  28. package/package.json +7 -5
  29. package/scripts/postinstall.js +6 -0
  30. package/src/agents/capabilities/browser/index.js +49 -0
  31. package/src/agents/capabilities/coding/backgroundHooks.js +94 -0
  32. package/src/agents/capabilities/coding/index.js +30 -1
  33. package/src/agents/capabilities/index.js +5 -2
  34. package/src/agents/capabilities/planning/index.js +44 -5
  35. package/src/agents/capabilities/turnRecall/index.js +341 -0
  36. package/src/agents/controller/controllerToolExecutor.js +2 -2
  37. package/src/agents/internal/internalRunner.js +30 -8
  38. package/src/agents/internal/taskControl.js +107 -0
  39. package/src/agents/profiles/coding.js +1 -1
  40. package/src/agents/profiles/main.js +1 -1
  41. package/src/agents/prompts/mainAgent.js +1 -0
  42. package/src/agents/prompts/native/toolDescriptions/bash.js +7 -1
  43. package/src/agents/providers/claudeSessionFiles.js +1 -1
  44. package/src/agents/providers/codexThreadProvider.js +6 -1
  45. package/src/agents/providers/credentials/agy.js +171 -0
  46. package/src/agents/providers/directAuthStatus.js +20 -2
  47. package/src/agents/providers/modelsCatalog.js +26 -5
  48. package/src/agents/providers/nativeTransport.js +145 -73
  49. package/src/agents/providers/providerId.js +17 -0
  50. package/src/agents/providers/runtimeConfig.js +67 -20
  51. package/src/agents/providers/transports/antigravityTransport.js +242 -0
  52. package/src/agents/providers/transports/index.js +1 -0
  53. package/src/agents/providers/transports/openaiChatTransport.js +3 -2
  54. package/src/agents/providers/transports/openaiResponsesTransport.js +2 -1
  55. package/src/agents/providers/transports/responsesProtocol.js +119 -18
  56. package/src/agents/providers/transports/transportContract.js +1 -0
  57. package/src/agents/providers/upstreamRuntime.js +3 -1
  58. package/src/agents/runtime/context/contextBudget.js +1 -19
  59. package/src/agents/runtime/context/contextWindow.js +5 -0
  60. package/src/agents/runtime/context/replayHistory.js +16 -10
  61. package/src/agents/runtime/context/runtimeStore.js +0 -1
  62. package/src/agents/runtime/context/sessionJournal.js +1 -1
  63. package/src/agents/runtime/context/slidingWindowManager.js +792 -0
  64. package/src/agents/runtime/context/topicSelector.js +338 -0
  65. package/src/agents/runtime/context/turnAnalyzer.js +767 -0
  66. package/src/agents/runtime/context/turnIndexStore.js +515 -0
  67. package/src/agents/runtime/core/agentLoop.js +140 -35
  68. package/src/agents/runtime/core/executionBudget.js +2 -1
  69. package/src/agents/runtime/core/toolErrorGuard.js +39 -0
  70. package/src/agents/runtime/createAgentRuntime.js +80 -7
  71. package/src/agents/runtime/index.js +5 -0
  72. package/src/agents/runtime/protocol/materialize.js +1 -1
  73. package/src/agents/runtime/tasks/hooks.js +137 -0
  74. package/src/app/chat/ChatController.js +8 -4
  75. package/src/app/chat/daemonMessageRouter.js +3 -1
  76. package/src/app/chat/inputSubmitHandler.js +2 -2
  77. package/src/app/chat/transport.js +1 -1
  78. package/src/app/cli/browserCommands.js +340 -0
  79. package/src/app/cli/busCoreCommands.js +63 -3
  80. package/src/app/cli/features/doctor.js +21 -0
  81. package/src/app/cli/metricsCommands.js +1 -1
  82. package/src/app/cli/run.js +81 -1
  83. package/src/app/cli/setupCommands.js +200 -0
  84. package/src/code/UcodeController.js +31 -1
  85. package/src/code/agent.js +76 -25
  86. package/src/code/busConsumer.js +13 -12
  87. package/src/code/commands.js +0 -1
  88. package/src/code/context/assembler.js +11 -88
  89. package/src/code/context/planGraphService.js +121 -6
  90. package/src/code/context/planProjection.js +10 -2
  91. package/src/code/context/reducers.js +172 -4
  92. package/src/code/context/stateCommit.js +0 -32
  93. package/src/code/context/transcript.js +7 -4
  94. package/src/code/internalThread.js +9 -1
  95. package/src/code/launcher/ucode.js +4 -2
  96. package/src/code/modelCommand.js +6 -5
  97. package/src/code/nativeRunner.js +232 -62
  98. package/src/code/repl.js +27 -1
  99. package/src/code/runtime/agentWakeup.js +20 -3
  100. package/src/code/runtime/backgroundWakeHost.js +45 -0
  101. package/src/code/runtime/taskFocusContext.js +7 -0
  102. package/src/code/runtime/taskLoop.js +24 -1
  103. package/src/code/sessionStore.js +14 -10
  104. package/src/code/taskDecomposer.js +16 -7
  105. package/src/code/tools/backgroundProcess.js +23 -0
  106. package/src/code/tools/bash.js +764 -12
  107. package/src/code/tools/executor.js +13 -4
  108. package/src/code/tools/planGraph.js +1 -0
  109. package/src/code/tools/specs.js +62 -4
  110. package/src/code/tools/taskRun.js +38 -0
  111. package/src/config.js +92 -6
  112. package/src/coordination/bus/index.js +2 -2
  113. package/src/coordination/bus/message.js +10 -1
  114. package/src/coordination/bus/nickname.js +3 -1
  115. package/src/coordination/bus/subscriber.js +25 -10
  116. package/src/coordination/bus/utils.js +4 -0
  117. package/src/coordination/bus/wakeEndpoint.js +198 -0
  118. package/src/coordination/history/agentPerformance.js +18 -18
  119. package/src/coordination/history/agentTrace.js +7 -3
  120. package/src/coordination/state/paths.js +4 -0
  121. package/src/coordination/state/workspaceAccess.js +3 -1
  122. package/src/orchestration/groups/modelConfig.js +66 -0
  123. package/src/orchestration/groups/validateTemplate.js +2 -0
  124. package/src/runtime/browser/broker.js +1027 -0
  125. package/src/runtime/browser/brokerClient.js +108 -0
  126. package/src/runtime/browser/componentInstaller.js +275 -0
  127. package/src/runtime/browser/installState.js +329 -0
  128. package/src/runtime/browser/manifest.js +145 -0
  129. package/src/runtime/browser/native-host-runner.js +198 -0
  130. package/src/runtime/browser/nativeHost.js +213 -0
  131. package/src/runtime/browser/nativeMessagingProtocol.js +50 -0
  132. package/src/runtime/browser/paths.js +134 -0
  133. package/src/runtime/browser/playwrightSession.js +614 -0
  134. package/src/runtime/daemon/agentHost.js +175 -28
  135. package/src/runtime/daemon/busBridge.js +2 -1
  136. package/src/runtime/daemon/deliveryScheduler.js +70 -2
  137. package/src/runtime/daemon/globalDaemon.js +20 -0
  138. package/src/runtime/daemon/groupOrchestrator.js +20 -1
  139. package/src/runtime/daemon/index.js +6 -4
  140. package/src/runtime/daemon/ops.js +14 -8
  141. package/src/tools/handlers/listAgents.js +1 -1
  142. package/src/tools/handlers/readBusSummary.js +1 -1
  143. package/src/tools/handlers/routeAgent.js +122 -5
  144. package/src/tools/schemaFixtures.js +1 -1
  145. package/src/ui/agentSurface.js +60 -6
  146. package/src/ui/format/index.js +34 -2
  147. package/src/ui/format/markdownRenderer.js +4 -2
  148. package/src/ui/rustChatHost.js +22 -7
  149. package/src/ui/rustMultiSession.js +14 -2
  150. package/src/ui/rustUcodeHost.js +249 -80
  151. package/src/ui/ucodeAgentSession.js +88 -0
  152. package/templates/groups/build-lane.json +57 -3
  153. package/templates/groups/build-ultra.json +114 -6
  154. package/templates/groups/design-system.json +57 -3
  155. package/templates/groups/product-discovery.json +57 -3
  156. package/templates/groups/ui-plan-review.json +57 -3
  157. package/templates/groups/ui-polish.json +57 -3
  158. package/templates/groups/verify-ship.json +57 -3
  159. package/src/agents/runtime/context/checkpointStore.js +0 -38
  160. package/src/agents/runtime/context/compaction.js +0 -151
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ const { createRuntimeHooks, formatWakeEvent } = require("../../agents/runtime/tasks/hooks");
4
+ const { createRuntimeStore } = require("../../agents/runtime/context/runtimeStore");
5
+ const { createBackgroundHookSource } = require("../../agents/capabilities/coding/backgroundHooks");
6
+ const { hasPendingUserInteraction } = require("../context/userInteraction");
7
+
8
+ /** A coding host outlives individual native loops and binds wakes to an exact session. */
9
+ function createUcodeWakeHost({ state, canDeliver = () => true, deliver, onError = () => {} }) {
10
+ let hooks = null;
11
+ let identity = "";
12
+ let closed = false;
13
+ let timer = null;
14
+ function current() {
15
+ if (closed || !state.sessionId || !state.workspaceRoot) return null;
16
+ const next = JSON.stringify([state.workspaceRoot, state.sessionId]);
17
+ if (next === identity) return hooks;
18
+ hooks?.close();
19
+ hooks = null;
20
+ hooks = createRuntimeHooks({
21
+ store: createRuntimeStore({ workspaceRoot: state.workspaceRoot, namespace: "ucode-hooks", sessionId: state.sessionId }),
22
+ sources: { background: createBackgroundHookSource(state.workspaceRoot) },
23
+ canDeliver: () => !closed && next === JSON.stringify([state.workspaceRoot, state.sessionId]) && !hasPendingUserInteraction(state.executionState) && canDeliver(),
24
+ deliver: (event, claim) => deliver(event, claim, formatWakeEvent(event)), onError,
25
+ });
26
+ identity = next;
27
+ hooks.start();
28
+ return hooks;
29
+ }
30
+ Object.defineProperty(state, "runtimeHooks", { configurable: true, enumerable: false, get: current });
31
+ const api = {
32
+ get hooks() { return current(); },
33
+ async tick() { return current()?.tick(); },
34
+ start() {
35
+ if (timer || closed) return;
36
+ current();
37
+ timer = setInterval(() => { try { current(); } catch (error) { onError(error); } }, 500);
38
+ timer.unref?.();
39
+ },
40
+ close() { closed = true; clearInterval(timer); hooks?.close(); },
41
+ };
42
+ return api;
43
+ }
44
+
45
+ module.exports = { createUcodeWakeHost };
@@ -97,6 +97,13 @@ function compactChildGraphHint(executionState = null, run = null) {
97
97
  ];
98
98
  if (waiting && waiting.id) {
99
99
  lines.push(` waitingFor: ${waiting.type || "node"}:${waiting.id}`);
100
+ } else if (nodes.length > 0) {
101
+ const failedCount = nodes.filter((n) => n && (n.status === "failed" || n.status === "blocked")).length;
102
+ lines.push(
103
+ failedCount > 0
104
+ ? ` status: stopped (${failedCount} failed/blocked node(s)) — complete_task / fail_task or patch ${child.graphId}`
105
+ : ` status: all child nodes completed — awaiting complete_task for taskRunId=${run.id}`,
106
+ );
100
107
  }
101
108
  const pending = nodes
102
109
  .filter((n) => n && (n.status === "pending" || n.status === "ready" || n.status === "waiting_llm"))
@@ -115,17 +115,29 @@ function syncParentNodeFromRun(executionState = null, run = null) {
115
115
  node.runtime.phase = run.phase;
116
116
  if (run.status === "running" || run.status === "queued" || run.status === "cancelling") {
117
117
  node.status = "running";
118
+ if (parent.waitingFor && parent.waitingFor.id === node.id) {
119
+ parent.waitingFor = null;
120
+ }
118
121
  } else if (run.status === "succeeded") {
119
122
  node.status = "succeeded";
120
123
  node.result = run.result;
121
124
  node.runtime.result = run.result;
125
+ if (parent.waitingFor && parent.waitingFor.id === node.id) {
126
+ parent.waitingFor = null;
127
+ }
122
128
  } else if (run.status === "failed") {
123
129
  node.status = "failed";
124
130
  node.error = (run.error && run.error.message) || run.error || "task failed";
125
131
  node.runtime.error = run.error;
132
+ if (parent.waitingFor && parent.waitingFor.id === node.id) {
133
+ parent.waitingFor = null;
134
+ }
126
135
  } else if (run.status === "cancelled") {
127
136
  node.status = "cancelled";
128
137
  node.runtime.error = run.error;
138
+ if (parent.waitingFor && parent.waitingFor.id === node.id) {
139
+ parent.waitingFor = null;
140
+ }
129
141
  }
130
142
  setGraph(executionState, parent);
131
143
  if (executionState.planGraph && executionState.planGraph.graphId === parent.graphId) {
@@ -133,6 +145,15 @@ function syncParentNodeFromRun(executionState = null, run = null) {
133
145
  }
134
146
  }
135
147
 
148
+ function clearLeakedChildFromPrimarySlot(executionState = null, taskRunId = "") {
149
+ if (!executionState || !executionState.planGraph || !executionState.planGraph.graphId) return;
150
+ const owner = executionState.planGraph.owner;
151
+ if (!owner || owner.kind !== "task_loop") return;
152
+ if (taskRunId && owner.taskRunId && owner.taskRunId !== taskRunId) return;
153
+ executionState.planGraph = emptyPlanGraphState();
154
+ executionState.mode = "single_action";
155
+ }
156
+
136
157
  function finalizeSuccess(executionState = null, taskRunId = "", result = {}) {
137
158
  const provenanceFiles = getProvenanceChangedFiles(executionState, taskRunId);
138
159
  const mergedResult = result && typeof result === "object" ? { ...result } : {};
@@ -148,6 +169,7 @@ function finalizeSuccess(executionState = null, taskRunId = "", result = {}) {
148
169
  if (!cas.ok) return cas;
149
170
  releaseTaskWriteLease(executionState, taskRunId);
150
171
  syncParentNodeFromRun(executionState, cas.run);
172
+ clearLeakedChildFromPrimarySlot(executionState, taskRunId);
151
173
  enqueueAgentRuntime(executionState, createRuntimeEvent("task_succeeded", {
152
174
  taskId: cas.run.parentNodeId,
153
175
  taskRunId: cas.run.id,
@@ -178,6 +200,7 @@ function finalizeFailure(executionState = null, taskRunId = "", error = {}, expe
178
200
  }
179
201
  releaseTaskWriteLease(executionState, taskRunId);
180
202
  syncParentNodeFromRun(executionState, cas.run);
203
+ clearLeakedChildFromPrimarySlot(executionState, taskRunId);
181
204
  const eventType = cas.run.status === "cancelled" ? "task_cancelled" : "task_failed";
182
205
  enqueueAgentRuntime(executionState, createRuntimeEvent(eventType, {
183
206
  taskId: cas.run.parentNodeId,
@@ -317,7 +340,7 @@ function processTaskRun(executionState = null, taskRunId = "", options = {}) {
317
340
  casTaskRunStatus(executionState, live.id, {
318
341
  expectedStatus: "running",
319
342
  nextStatus: "running",
320
- phase: after && after.waitingFor ? "waiting_model" : "executing_tools",
343
+ phase: "waiting_model",
321
344
  });
322
345
  syncParentNodeFromRun(executionState, getTaskRun(executionState, taskRunId));
323
346
 
@@ -11,7 +11,6 @@ const {
11
11
  const { getJournalPath, deleteSessionJournal } = require("./conversation/sessionJournal");
12
12
  const { deleteSessionArtifacts } = require("./context/artifacts");
13
13
  const { deleteSessionCommitLog, maybeGcSessionArtifacts } = require("./context/artifactGc");
14
- const { defaultContextPolicy } = require("./context/assembler");
15
14
  const { emptyTaskContract } = require("./context/stateCommit");
16
15
  const { emptyWorkingSet } = require("./context/workingSet");
17
16
  const { emptyExecutionState } = require("./context/executionSegment");
@@ -69,14 +68,19 @@ function cloneMessages(value = []) {
69
68
  }
70
69
 
71
70
  function normalizeContextPolicy(value = {}) {
72
- const defaults = defaultContextPolicy();
73
- const source = value && typeof value === "object" ? value : {};
74
- return {
75
- ...defaults,
76
- ...source,
77
- maxMessages: Number.isFinite(source.maxMessages) ? Math.max(1, Math.floor(source.maxMessages)) : defaults.maxMessages,
78
- keepRecentUnits: Number.isFinite(source.keepRecentUnits) ? Math.max(1, Math.floor(source.keepRecentUnits)) : defaults.keepRecentUnits,
79
- };
71
+ const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
72
+ const out = { ...source };
73
+ if (Number.isFinite(source.maxMessages)) {
74
+ out.maxMessages = Math.max(1, Math.floor(source.maxMessages));
75
+ } else {
76
+ delete out.maxMessages;
77
+ }
78
+ if (Number.isFinite(source.keepRecentUnits)) {
79
+ out.keepRecentUnits = Math.max(1, Math.floor(source.keepRecentUnits));
80
+ } else {
81
+ delete out.keepRecentUnits;
82
+ }
83
+ return out;
80
84
  }
81
85
 
82
86
  function buildSessionSnapshot(input = {}) {
@@ -267,7 +271,7 @@ function deleteSessionData(workspaceRoot = process.cwd(), sessionId = "") {
267
271
  deleteTranscript(workspaceRoot, normalizedId);
268
272
  deleteSessionArtifacts(workspaceRoot, normalizedId);
269
273
  deleteSessionCommitLog(workspaceRoot, normalizedId);
270
- require("../agents/runtime/context/checkpointStore").createCheckpointStore({ workspaceRoot, namespace: "ucode", sessionId: normalizedId }).remove();
274
+ require("../agents/runtime/context/turnIndexStore").createTurnIndexStore({ workspaceRoot, namespace: "ucode", sessionId: normalizedId }).remove();
271
275
  return { ok: true, error: "" };
272
276
  } catch (err) {
273
277
  return {
@@ -13,6 +13,7 @@ const {
13
13
  const { sanitizeSkillContent } = require("./skills/injection");
14
14
  const { randomUUID } = require("crypto");
15
15
  const { normalizeTraceContext } = require("../agents/runtime/protocol/traceContext");
16
+ const { resolveTaskTimeoutMs } = require("../agents/runtime/core/executionBudget");
16
17
 
17
18
  function renderActiveSkillBodiesFromState(state = {}) {
18
19
  const skills = Array.isArray(state.activeSkills) ? state.activeSkills : [];
@@ -51,7 +52,6 @@ function decomposeBugFixTask(task) {
51
52
  id: "identify",
52
53
  name: "Identifying the issue",
53
54
  prompt: `Task context:\n${taskContext}\n\nIdentify the specific problem.\n\nBe concise. Focus only on:\n1. What is broken\n2. What file/function is likely involved\n3. What the expected behavior should be\n\nDo NOT analyze entire codebases. Find the specific issue quickly.`,
54
- timeoutMs: 30000, // 30 seconds
55
55
  earlyExit: true,
56
56
  });
57
57
 
@@ -59,7 +59,6 @@ function decomposeBugFixTask(task) {
59
59
  id: "locate",
60
60
  name: "Locating relevant code",
61
61
  prompt: `Task context:\n${taskContext}\n\nBased on the identified issue, find the exact location of the bug.\n\nSearch for and read ONLY the relevant function/file. Stop as soon as you find the problematic code.`,
62
- timeoutMs: 30000,
63
62
  earlyExit: true,
64
63
  });
65
64
 
@@ -67,7 +66,6 @@ function decomposeBugFixTask(task) {
67
66
  id: "fix",
68
67
  name: "Applying the fix",
69
68
  prompt: `Task context:\n${taskContext}\n\nApply the minimal fix needed. Do NOT refactor or improve unrelated code. Just fix the specific issue.`,
70
- timeoutMs: 60000,
71
69
  earlyExit: false,
72
70
  });
73
71
 
@@ -75,7 +73,6 @@ function decomposeBugFixTask(task) {
75
73
  id: "verify",
76
74
  name: "Verifying the fix",
77
75
  prompt: `Task context:\n${taskContext}\n\nVerify the fix resolves the issue. Check that:\n1. The specific problem is fixed\n2. No new issues were introduced\n\nBe brief.`,
78
- timeoutMs: 20000,
79
76
  earlyExit: false,
80
77
  });
81
78
  } else {
@@ -84,7 +81,6 @@ function decomposeBugFixTask(task) {
84
81
  id: "execute",
85
82
  name: "Executing task",
86
83
  prompt: task,
87
- timeoutMs: 120000,
88
84
  earlyExit: false,
89
85
  });
90
86
  }
@@ -166,12 +162,16 @@ async function runDecomposedTask({
166
162
  systemBlocks = null,
167
163
  runtimeContext = {},
168
164
  onRuntimeEvent = null,
165
+ onConversationUpdate = null,
169
166
  onStreamDelta = null,
170
167
  onThinkingDelta = null,
171
168
  onPhase = null,
172
169
  onContextUsage = null,
173
170
  contextPolicy = {},
171
+ timeoutMs,
174
172
  }) {
173
+ const budgetMs = resolveTaskTimeoutMs(timeoutMs ?? state?.timeoutMs);
174
+ const deadline = Date.now() + budgetMs;
175
175
  const steps = decomposeBugFixTask(task);
176
176
  const results = [];
177
177
  const turnItems = [];
@@ -203,7 +203,7 @@ async function runDecomposedTask({
203
203
  });
204
204
 
205
205
  try {
206
- // Run the step with its own timeout
206
+ // All steps share one deadline, including context assembly between steps.
207
207
  const stepPrompt = buildStepPrompt(step, results);
208
208
  let stepMessages = messages;
209
209
  let stepSystemPrompt = systemPrompt;
@@ -221,7 +221,14 @@ async function runDecomposedTask({
221
221
  stepSystemBlocks = assembled.systemBlocks;
222
222
  }
223
223
  const inherited = normalizeTraceContext(runtimeContext);
224
+ const remainingMs = deadline - Date.now();
225
+ // Native transports clamp timeouts to at least one second. Do not start
226
+ // another step if that minimum would extend the task deadline.
227
+ if (remainingMs < 1000) {
228
+ throw new Error(`agent timeout (${budgetMs}ms)`);
229
+ }
224
230
  const stepResult = await runNativeAgentTask({
231
+ runtimeHooks: state?.runtimeHooks,
225
232
  workspaceRoot,
226
233
  provider,
227
234
  model,
@@ -230,12 +237,14 @@ async function runDecomposedTask({
230
237
  systemBlocks: stepSystemBlocks,
231
238
  messages: stepMessages,
232
239
  sessionId,
233
- timeoutMs: step.timeoutMs,
240
+ timeoutMs: remainingMs,
234
241
  maxToolCalls: state ? state.maxToolCalls : undefined,
235
242
  onToolEvent,
236
243
  runtimeContext: inherited.taskRunId ? { ...inherited, parentTaskRunId: inherited.taskRunId,
237
244
  taskRunId: `segment-${randomUUID()}`, requestId: `${inherited.requestId || "step"}:${step.id}`, attemptId: `attempt-${randomUUID()}` } : inherited,
238
245
  onRuntimeEvent,
246
+ onConversationUpdate: onConversationUpdate
247
+ ? update => onConversationUpdate({ ...update, turnItems: [...turnItems, ...update.turnItems] }) : null,
239
248
  onStreamDelta,
240
249
  onThinkingDelta,
241
250
  onPhase,
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ // A detached supervisor persists the real shell outcome even if its agent host
4
+ // exits. It shares the command's process group so explicit stop still kills both.
5
+ const fs = require("fs");
6
+ const { spawn } = require("child_process");
7
+ const [recordPath, command] = process.argv.slice(2);
8
+ let finished = false;
9
+ function finish(code, signal, error) {
10
+ if (finished) return;
11
+ finished = true;
12
+ try {
13
+ const record = JSON.parse(fs.readFileSync(recordPath, "utf8"));
14
+ const temporary = `${recordPath}.${process.pid}.exit.tmp`;
15
+ fs.writeFileSync(temporary, JSON.stringify({ ...record, status: record.status === "stopped" ? "stopped" : "exited",
16
+ exitCode: code, signal: signal || "", ...(error ? { error } : {}), endedAt: new Date().toISOString() }), { mode: 0o600 });
17
+ fs.renameSync(temporary, recordPath);
18
+ } catch { /* Parent can still report an unknown outcome from liveness. */ }
19
+ process.exitCode = typeof code === "number" ? code : 1;
20
+ }
21
+ const child = spawn(command, { shell: true, stdio: "inherit", windowsHide: true });
22
+ child.once("error", error => finish(-1, "", error.message));
23
+ child.once("exit", (code, signal) => finish(code, signal));