( queuedCommands: QueuedCommand[], )
| 1044 | const INLINE_NOTIFICATION_MODES = new Set(['prompt', 'task-notification']) |
| 1045 | |
| 1046 | export async function getQueuedCommandAttachments( |
| 1047 | queuedCommands: QueuedCommand[], |
| 1048 | ): Promise<Attachment[]> { |
| 1049 | if (!queuedCommands) { |
| 1050 | return [] |
| 1051 | } |
| 1052 | // Include both 'prompt' and 'task-notification' commands as attachments. |
| 1053 | // During proactive agentic loops, task-notification commands would otherwise |
| 1054 | // stay in the queue permanently (useQueueProcessor can't run while a query |
| 1055 | // is active), causing hasPendingNotifications() to return true and Sleep to |
| 1056 | // wake immediately with 0ms duration in an infinite loop. |
| 1057 | const filtered = queuedCommands.filter(_ => |
| 1058 | INLINE_NOTIFICATION_MODES.has(_.mode), |
| 1059 | ) |
| 1060 | return Promise.all( |
| 1061 | filtered.map(async _ => { |
| 1062 | const imageBlocks = await buildImageContentBlocks(_.pastedContents) |
| 1063 | let prompt: string | Array<ContentBlockParam> = _.value |
| 1064 | if (imageBlocks.length > 0) { |
| 1065 | // Build content block array with text + images so the model sees them |
| 1066 | const textValue = |
| 1067 | typeof _.value === 'string' |
| 1068 | ? _.value |
| 1069 | : extractTextContent(_.value, '\n') |
| 1070 | prompt = [{ type: 'text' as const, text: textValue }, ...imageBlocks] |
| 1071 | } |
| 1072 | return { |
| 1073 | type: 'queued_command' as const, |
| 1074 | prompt, |
| 1075 | source_uuid: _.uuid, |
| 1076 | imagePasteIds: getImagePasteIds(_.pastedContents), |
| 1077 | commandMode: _.mode, |
| 1078 | origin: _.origin, |
| 1079 | isMeta: _.isMeta, |
| 1080 | } |
| 1081 | }), |
| 1082 | ) |
| 1083 | } |
| 1084 | |
| 1085 | export function getAgentPendingMessageAttachments( |
| 1086 | toolUseContext: ToolUseContext, |
no test coverage detected