| 28 | } |
| 29 | |
| 30 | export function validateArgs(args: CompressMessageToolArgs): void { |
| 31 | if (typeof args.topic !== "string" || args.topic.trim().length === 0) { |
| 32 | throw new Error("topic is required and must be a non-empty string") |
| 33 | } |
| 34 | |
| 35 | if (!Array.isArray(args.content) || args.content.length === 0) { |
| 36 | throw new Error("content is required and must be a non-empty array") |
| 37 | } |
| 38 | |
| 39 | for (let index = 0; index < args.content.length; index++) { |
| 40 | const entry = args.content[index] |
| 41 | const prefix = `content[${index}]` |
| 42 | |
| 43 | if (typeof entry?.messageId !== "string" || entry.messageId.trim().length === 0) { |
| 44 | throw new Error(`${prefix}.messageId is required and must be a non-empty string`) |
| 45 | } |
| 46 | |
| 47 | if (typeof entry?.topic !== "string" || entry.topic.trim().length === 0) { |
| 48 | throw new Error(`${prefix}.topic is required and must be a non-empty string`) |
| 49 | } |
| 50 | |
| 51 | if (typeof entry?.summary !== "string" || entry.summary.trim().length === 0) { |
| 52 | throw new Error(`${prefix}.summary is required and must be a non-empty string`) |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | export function formatResult( |
| 58 | processedCount: number, |