@magclaw/cli-core 0.1.33 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/mcp-bridge.js CHANGED
@@ -246,6 +246,36 @@ const tools = [
246
246
  targetAgent: { type: 'string' },
247
247
  }),
248
248
  },
249
+ {
250
+ name: 'read_agent_avatar',
251
+ description: 'Read a MagClaw agent avatar image for visual comparison with uploaded attachments.',
252
+ inputSchema: schema({
253
+ targetAgentId: { type: 'string' },
254
+ targetAgent: { type: 'string' },
255
+ maxBytes: { type: 'number' },
256
+ }),
257
+ },
258
+ {
259
+ name: 'list_attachments',
260
+ description: 'List MagClaw attachment metadata visible to this agent.',
261
+ inputSchema: schema({
262
+ target: { type: 'string' },
263
+ channel: { type: 'string' },
264
+ workItemId: { type: 'string' },
265
+ messageId: { type: 'string' },
266
+ limit: { type: 'number' },
267
+ }),
268
+ },
269
+ {
270
+ name: 'read_attachment',
271
+ description: 'Read an uploaded MagClaw attachment original file. Image attachments are returned as MCP image content when possible.',
272
+ inputSchema: schema({
273
+ attachmentId: { type: 'string' },
274
+ id: { type: 'string' },
275
+ maxBytes: { type: 'number' },
276
+ format: { type: 'string' },
277
+ }),
278
+ },
249
279
  {
250
280
  name: 'write_memory',
251
281
  description: 'Record a concise durable memory for this agent.',
@@ -358,8 +388,20 @@ function sendError(id, code, message, data = null) {
358
388
  process.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', id, error: { code, message, data } })}\n`);
359
389
  }
360
390
 
361
- function textResult(text) {
362
- return { content: [{ type: 'text', text: String(text || '') }] };
391
+ function imageResultContent(value = {}) {
392
+ const type = String(value?.avatar?.type || value?.file?.type || value?.attachment?.type || '').toLowerCase();
393
+ if (!type.startsWith('image/')) return null;
394
+ if (value?.file?.truncated || value?.avatar?.truncated) return null;
395
+ const data = String(value?.contentBase64 || '').trim();
396
+ if (!data) return null;
397
+ return { type: 'image', data, mimeType: type };
398
+ }
399
+
400
+ function contentResult(value) {
401
+ const content = [{ type: 'text', text: jsonText(value) }];
402
+ const image = imageResultContent(value);
403
+ if (image) content.push(image);
404
+ return { content };
363
405
  }
364
406
 
365
407
  function jsonText(value) {
@@ -511,6 +553,33 @@ async function callTool(name, rawArgs = {}) {
511
553
  targetAgentId: args.targetAgentId || args.targetAgent,
512
554
  },
513
555
  });
556
+ case 'read_agent_avatar':
557
+ return request('/api/agent-tools/agents/avatar/read', {
558
+ query: {
559
+ agentId: args.agentId,
560
+ targetAgentId: args.targetAgentId || args.targetAgent,
561
+ maxBytes: args.maxBytes || args.max_bytes,
562
+ },
563
+ });
564
+ case 'list_attachments':
565
+ return request('/api/agent-tools/attachments', {
566
+ query: {
567
+ agentId: args.agentId,
568
+ target: args.target || args.channel,
569
+ workItemId: args.workItemId || args.work_item_id,
570
+ messageId: args.messageId || args.message_id,
571
+ limit: args.limit,
572
+ },
573
+ });
574
+ case 'read_attachment':
575
+ return request('/api/agent-tools/attachments/read', {
576
+ query: {
577
+ agentId: args.agentId,
578
+ attachmentId: args.attachmentId || args.attachment_id || args.id,
579
+ maxBytes: args.maxBytes || args.max_bytes,
580
+ format: args.format,
581
+ },
582
+ });
514
583
  case 'list_tasks':
515
584
  return request('/api/agent-tools/tasks', {
516
585
  query: {
@@ -587,7 +656,7 @@ async function handle(message) {
587
656
  }
588
657
  if (message.method === 'tools/call') {
589
658
  const result = await callTool(message.params?.name, message.params?.arguments || {});
590
- send(id, textResult(jsonText(result)));
659
+ send(id, contentResult(result));
591
660
  return;
592
661
  }
593
662
  if (message.method === 'notifications/initialized' || message.method === 'initialized') return;