返回 CodeWhale
1 export const name = 'dsh-attachments-render'
2 export const inject = ['tools']
3
4 export function apply(ctx) {
5 ctx.tools.register({
6 name: 'render_attachment_result',
7 description: 'Return either a rendered { type: image, attachment } block or plain text.',
8 parameters: {
9 type: 'object',
10 properties: {
11 attachmentId: { type: 'string' },
12 textOnly: { type: 'string' },
13 },
14 additionalProperties: false,
15 },
16 output: {
17 schema: {
18 type: 'object',
19 properties: {
20 attachmentId: { type: 'string' },
21 textOnly: { type: 'string' },
22 },
23 },
24 render: (_args, value) => {
25 if (typeof value.textOnly === 'string') {
26 return [{ type: 'text', text: value.textOnly }]
27 }
28 return [
29 { type: 'text', text: `image ${value.attachmentId}` },
30 { type: 'image', attachment: { attachmentId: value.attachmentId } },
31 ]
32 },
33 },
34 execute: (input) => input,
35 })
36 }
37
37 lines Plain Text