Add structured Discord attachments

This commit is contained in:
ejclaw
2026-04-25 09:20:28 +09:00
parent 65dd82ba6b
commit 4e329a7717
24 changed files with 891 additions and 53 deletions

View File

@@ -13,6 +13,12 @@ describe('shared agent protocol helpers', () => {
cleanText: 'hello',
imagePaths: ['/tmp/a.png'],
});
expect(
extractImageTagPaths('hello [Image: screenshot.png → /tmp/a.png]'),
).toEqual({
cleanText: 'hello',
imagePaths: ['/tmp/a.png'],
});
expect(extractImageTagPaths('[Image: /tmp/b.png] second')).toEqual({
cleanText: 'second',
imagePaths: ['/tmp/b.png'],
@@ -45,6 +51,41 @@ describe('shared agent protocol helpers', () => {
});
});
it('parses public ejclaw attachments', () => {
expect(
normalizeEjclawStructuredOutput(
JSON.stringify({
ejclaw: {
visibility: 'public',
text: '이미지를 생성했습니다.',
verdict: 'done',
attachments: [
{
path: '/tmp/image.png',
name: 'image.png',
mime: 'image/png',
},
],
},
}),
),
).toEqual({
result: '이미지를 생성했습니다.',
output: {
visibility: 'public',
text: '이미지를 생성했습니다.',
verdict: 'done',
attachments: [
{
path: '/tmp/image.png',
name: 'image.png',
mime: 'image/png',
},
],
},
});
});
it('falls back to visible raw text on invalid public verdicts', () => {
const raw = JSON.stringify({
ejclaw: {