feat: extend verbose tool feedback

This commit is contained in:
Peter Steinberger
2026-01-17 05:33:27 +00:00
parent 4d314db750
commit 99dd428862
31 changed files with 208 additions and 34 deletions

View File

@@ -33,6 +33,24 @@ export function sanitizeToolResult(result: unknown): unknown {
return { ...record, content: sanitized };
}
export function extractToolResultText(result: unknown): string | undefined {
if (!result || typeof result !== "object") return undefined;
const record = result as Record<string, unknown>;
const content = Array.isArray(record.content) ? record.content : null;
if (!content) return undefined;
const texts = content
.map((item) => {
if (!item || typeof item !== "object") return undefined;
const entry = item as Record<string, unknown>;
if (entry.type !== "text" || typeof entry.text !== "string") return undefined;
const trimmed = entry.text.trim();
return trimmed ? trimmed : undefined;
})
.filter((value): value is string => Boolean(value));
if (texts.length === 0) return undefined;
return texts.join("\n");
}
export function isToolResultError(result: unknown): boolean {
if (!result || typeof result !== "object") return false;
const record = result as { details?: unknown };