MCPcopy Create free account
hub / github.com/Noumena-Network/code / getQueuedCommandAttachments

Function getQueuedCommandAttachments

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

Source from the content-addressed store, hash-verified

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

Callers 2

getAttachmentsFunction · 0.85
REPLFunction · 0.85

Calls 4

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

Tested by

no test coverage detected