Normalize agent attachment output (#122)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
normalizeEjclawStructuredOutput,
|
||||
normalizeAgentOutput,
|
||||
type RunnerOutputAttachment,
|
||||
} from 'ejclaw-runners-shared';
|
||||
|
||||
@@ -28,7 +28,7 @@ export interface SendMessageIpcPayload {
|
||||
export function buildSendMessageIpcPayload(
|
||||
input: SendMessageIpcPayloadInput,
|
||||
): SendMessageIpcPayload {
|
||||
const normalized = normalizeEjclawStructuredOutput(input.text);
|
||||
const normalized = normalizeAgentOutput(input.text);
|
||||
const output =
|
||||
normalized.output?.visibility === 'public' ? normalized.output : null;
|
||||
const text = output?.text ?? normalized.result ?? '';
|
||||
|
||||
@@ -3,7 +3,7 @@ import path from 'path';
|
||||
|
||||
import {
|
||||
extractImageTagPaths,
|
||||
normalizeEjclawStructuredOutput,
|
||||
normalizeAgentOutput,
|
||||
type RunnerStructuredOutput,
|
||||
writeProtocolOutput,
|
||||
} from 'ejclaw-runners-shared';
|
||||
@@ -151,7 +151,7 @@ export function normalizeStructuredOutput(result: string | null): {
|
||||
result: string | null;
|
||||
output?: RunnerOutput['output'];
|
||||
} {
|
||||
return normalizeEjclawStructuredOutput(result);
|
||||
return normalizeAgentOutput(result);
|
||||
}
|
||||
|
||||
export function extractAssistantText(message: unknown): string | null {
|
||||
|
||||
@@ -103,6 +103,32 @@ describe('agent runner IPC message payload', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('normalizes markdown image output and preserves attachments', () => {
|
||||
expect(
|
||||
buildSendMessageIpcPayload({
|
||||
chatJid: 'dc:123',
|
||||
text: `TASK_DONE
|
||||
|
||||
스크린샷입니다.
|
||||
`,
|
||||
groupFolder: 'discord-review',
|
||||
timestamp: '2026-04-04T13:45:00.000Z',
|
||||
}),
|
||||
).toEqual({
|
||||
type: 'message',
|
||||
chatJid: 'dc:123',
|
||||
text: 'TASK_DONE\n\n스크린샷입니다.',
|
||||
groupFolder: 'discord-review',
|
||||
timestamp: '2026-04-04T13:45:00.000Z',
|
||||
attachments: [
|
||||
{
|
||||
path: '/tmp/ejclaw-markdown.png',
|
||||
name: 'ejclaw-markdown.png',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('turns silent EJClaw envelopes into empty no-op messages', () => {
|
||||
expect(
|
||||
buildSendMessageIpcPayload({
|
||||
|
||||
Reference in New Issue
Block a user