export type TextToolResult = { content: Array<{ type: "text"; text: string }>; details?: T; isError?: boolean; }; export function textToolResult(text: string, details?: T, options: { isError?: boolean } = {}): TextToolResult { return { content: [{ type: "text", text }], ...(details === undefined ? {} : { details }), ...(options.isError === undefined ? {} : { isError: options.isError }), }; } export function jsonToolResult(payload: T, options: { space?: number; isError?: boolean } = {}): TextToolResult { return textToolResult(JSON.stringify(payload, null, options.space ?? 2), payload, { isError: options.isError }); }