import assert from "node:assert/strict"; import type { AgentToolResult } from "@earendil-works/pi-agent-core"; import type { ErrorCode, Report } from "./report-schema.ts"; import { detailsReport } from "./report.ts"; /** Assert execution failures through the returned model/TUI report, without changing tool semantics. */ export async function expectToolFailure( pending: Promise & { isError?: boolean }>, code: ErrorCode, inspect?: (report: Report) => void, ): Promise { const result = await pending; assert.equal(result.isError, true); const report = detailsReport(result.details); assert.ok(report); assert.equal(report.error, code); inspect?.(report); return report; }