Function: formatToolResult()¶
formatToolResult(
raw):object
Defined in: src/formatters/output.ts:17
Parses a raw tool result into a renderable shape: rows (for tabular JSON —
{ rows: [...] }, a query page { columns, rows }, or a top-level array of
objects) or text (a key: value rendering of an object that reads as text,
never JSON, or the raw string when it isn't JSON).
Parameters¶
raw¶
string
Returns¶
rows¶
rows:
Record\<string,string>[] |null
Row-shaped result for a table view, or null when not tabular.
text¶
text:
string
Text rendering of the result when it is not tabular.
Example¶
import { formatToolResult } from "@pgege/kaboo-react";
const { rows } = formatToolResult('{"rows":[{"id":"1"}]}');
// rows?.length === 1