MCPcopy Create free account
hub / github.com/agent-tower/core / buildUserMessageNDJSON

Function buildUserMessageNDJSON

packages/server/src/executors/image-utils.ts:230–256  ·  view source on GitHub ↗
(contentBlocks: ContentBlock[])

Source from the content-addressed store, hash-verified

228 * 根据 claude-cli-agent-protocol 文档,格式应该是:
229 * {"type":"user","message":{"role":"user","content":[...]}}
230 */
231export function buildUserMessageNDJSON(contentBlocks: ContentBlock[]): string {
232 const message = {
233 type: 'user',
234 message: {
235 role: 'user',
236 content: contentBlocks,
237 },
238 };
239
240 const ndjson = JSON.stringify(message) + '\n';
241
242 // 打印最终消息结构(用于调试)
243 console.log('[image-utils] buildUserMessageNDJSON:');
244 console.log(' message type:', message.type);
245 console.log(' message.message.role:', message.message.role);
246 console.log(' message.message.content blocks:', message.message.content.length);
247
248 console.log(' content summary:', message.message.content.map(block => (
249 block.type === 'image'
250 ? { type: 'image', mediaType: block.source.media_type, dataLength: block.source.data.length }
251 : { type: 'text', length: block.text.length }
252 )));
253 console.log(' NDJSON length:', ndjson.length);
254
255 // 返回 NDJSON 格式(单行 JSON + 换行符)
256 return ndjson;
257}

Callers 2

spawnMethod · 0.85
spawnFollowUpMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected