|
1 | 1 | import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js"; |
2 | 2 | import { defaultRuntime } from "../runtime.js"; |
3 | 3 | import { emitSessionLifecycleEvent } from "../sessions/session-lifecycle-events.js"; |
4 | | -import { updateTaskDeliveryByRunId, updateTaskStateByRunId } from "../tasks/task-registry.js"; |
| 4 | +import { |
| 5 | + markTaskTerminalByRunId, |
| 6 | + setTaskRunDeliveryStatusByRunId, |
| 7 | +} from "../tasks/task-registry.js"; |
5 | 8 | import { normalizeDeliveryContext } from "../utils/delivery-context.js"; |
6 | 9 | import { |
7 | 10 | captureSubagentCompletionReply, |
@@ -154,7 +157,7 @@ export function createSubagentRegistryLifecycleController(params: { |
154 | 157 | entry: SubagentRunRecord; |
155 | 158 | reason: "retry-limit" | "expiry"; |
156 | 159 | }) => { |
157 | | - updateTaskDeliveryByRunId({ |
| 160 | + setTaskRunDeliveryStatusByRunId({ |
158 | 161 | runId: giveUpParams.runId, |
159 | 162 | deliveryStatus: "failed", |
160 | 163 | }); |
@@ -270,7 +273,7 @@ export function createSubagentRegistryLifecycleController(params: { |
270 | 273 | return; |
271 | 274 | } |
272 | 275 | if (didAnnounce) { |
273 | | - updateTaskDeliveryByRunId({ |
| 276 | + setTaskRunDeliveryStatusByRunId({ |
274 | 277 | runId, |
275 | 278 | deliveryStatus: "delivered", |
276 | 279 | }); |
@@ -326,7 +329,7 @@ export function createSubagentRegistryLifecycleController(params: { |
326 | 329 | } |
327 | 330 |
|
328 | 331 | if (deferredDecision.kind === "give-up") { |
329 | | - updateTaskDeliveryByRunId({ |
| 332 | + setTaskRunDeliveryStatusByRunId({ |
330 | 333 | runId, |
331 | 334 | deliveryStatus: "failed", |
332 | 335 | }); |
@@ -377,26 +380,27 @@ export function createSubagentRegistryLifecycleController(params: { |
377 | 380 | }); |
378 | 381 | }; |
379 | 382 |
|
380 | | - void params.runSubagentAnnounceFlow({ |
381 | | - childSessionKey: entry.childSessionKey, |
382 | | - childRunId: entry.runId, |
383 | | - requesterSessionKey: entry.requesterSessionKey, |
384 | | - requesterOrigin, |
385 | | - requesterDisplayKey: entry.requesterDisplayKey, |
386 | | - task: entry.task, |
387 | | - timeoutMs: params.subagentAnnounceTimeoutMs, |
388 | | - cleanup: entry.cleanup, |
389 | | - roundOneReply: entry.frozenResultText ?? undefined, |
390 | | - fallbackReply: entry.fallbackFrozenResultText ?? undefined, |
391 | | - waitForCompletion: false, |
392 | | - startedAt: entry.startedAt, |
393 | | - endedAt: entry.endedAt, |
394 | | - label: entry.label, |
395 | | - outcome: entry.outcome, |
396 | | - spawnMode: entry.spawnMode, |
397 | | - expectsCompletionMessage: entry.expectsCompletionMessage, |
398 | | - wakeOnDescendantSettle: entry.wakeOnDescendantSettle === true, |
399 | | - }) |
| 383 | + void params |
| 384 | + .runSubagentAnnounceFlow({ |
| 385 | + childSessionKey: entry.childSessionKey, |
| 386 | + childRunId: entry.runId, |
| 387 | + requesterSessionKey: entry.requesterSessionKey, |
| 388 | + requesterOrigin, |
| 389 | + requesterDisplayKey: entry.requesterDisplayKey, |
| 390 | + task: entry.task, |
| 391 | + timeoutMs: params.subagentAnnounceTimeoutMs, |
| 392 | + cleanup: entry.cleanup, |
| 393 | + roundOneReply: entry.frozenResultText ?? undefined, |
| 394 | + fallbackReply: entry.fallbackFrozenResultText ?? undefined, |
| 395 | + waitForCompletion: false, |
| 396 | + startedAt: entry.startedAt, |
| 397 | + endedAt: entry.endedAt, |
| 398 | + label: entry.label, |
| 399 | + outcome: entry.outcome, |
| 400 | + spawnMode: entry.spawnMode, |
| 401 | + expectsCompletionMessage: entry.expectsCompletionMessage, |
| 402 | + wakeOnDescendantSettle: entry.wakeOnDescendantSettle === true, |
| 403 | + }) |
400 | 404 | .then((didAnnounce) => { |
401 | 405 | finalizeAnnounceCleanup(didAnnounce); |
402 | 406 | }) |
@@ -458,7 +462,7 @@ export function createSubagentRegistryLifecycleController(params: { |
458 | 462 | if (mutated) { |
459 | 463 | params.persist(); |
460 | 464 | } |
461 | | - updateTaskStateByRunId({ |
| 465 | + markTaskTerminalByRunId({ |
462 | 466 | runId: entry.runId, |
463 | 467 | status: |
464 | 468 | completeParams.outcome.status === "ok" |
|
0 commit comments