import { listRunningBackgroundTasks, type BackgroundTaskState } from '../tools/tasks/backgroundTaskService.js'; export interface PendingBackgroundTask { task_id: string; command: string; } /** One-shot hosts cannot certify work whose processes are still outstanding. */ export function backgroundCompletionFields(state?: BackgroundTaskState): { completionStatus?: 'delivery_incomplete'; pendingBackground?: PendingBackgroundTask[]; } { const tasks = listRunningBackgroundTasks(state); return tasks.length ? { completionStatus: 'delivery_incomplete', pendingBackground: tasks.map(task => ({ task_id: task.id, command: task.command.slice(0, 200) })), } : {}; }