mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-31 16:57:08 +02:00
15 lines
632 B
TypeScript
15 lines
632 B
TypeScript
import type { CallToolResult } from './types';
|
|
|
|
/** Extract text from the first content block, throwing if it isn't a text block. */
|
|
export function textOf(result: CallToolResult): string {
|
|
const item = result.content[0];
|
|
if (item.type !== 'text') throw new Error(`Expected text content, got ${item.type}`);
|
|
return item.text;
|
|
}
|
|
|
|
/** Extract structuredContent from a result, throwing if it isn't present. */
|
|
export function structuredOf(result: CallToolResult): Record<string, unknown> {
|
|
if (!result.structuredContent) throw new Error('Expected structuredContent');
|
|
return result.structuredContent as Record<string, unknown>;
|
|
}
|