MCPcopy
hub / github.com/codeaashu/claude-code / getQueuedCommandAttachments

Function getQueuedCommandAttachments

src/utils/attachments.ts:1046–1083  ·  view source on GitHub ↗
(
  queuedCommands: QueuedCommand[],
)

Source from the content-addressed store, hash-verified

1044const INLINE_NOTIFICATION_MODES = new Set(['prompt', 'task-notification'])
1045
1046export 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
1085export function getAgentPendingMessageAttachments(
1086 toolUseContext: ToolUseContext,

Callers 2

getAttachmentsFunction · 0.85
REPLFunction · 0.85

Calls 4

buildImageContentBlocksFunction · 0.85
getImagePasteIdsFunction · 0.85
extractTextContentFunction · 0.70
hasMethod · 0.45

Tested by

no test coverage detected