feat(coding-agent): Custom tool export rendering in export (#702)

* coding-agent: add ANSI-to-HTML converter for export

* coding-agent: add getToolDefinition method to ExtensionRunner

* coding-agent: add tool HTML renderer factory for custom tools

* coding-agent: add custom tool pre-rendering to HTML export

* coding-agent: render pre-rendered custom tools in HTML export

* coding-agent: integrate tool renderer in exportToHtml
This commit is contained in:
Aliou Diallo 2026-01-16 00:32:31 +01:00 committed by GitHub
parent ce7e73b503
commit 0c6ac46646
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 502 additions and 9 deletions

View file

@ -24,6 +24,7 @@ import type {
import type { AssistantMessage, ImageContent, Message, Model, TextContent } from "@mariozechner/pi-ai";
import { isContextOverflow, modelsAreEqual, supportsXhigh } from "@mariozechner/pi-ai";
import { getAuthPath } from "../config.js";
import { theme } from "../modes/interactive/theme/theme.js";
import { type BashResult, executeBash as executeBashCommand, executeBashWithOperations } from "./bash-executor.js";
import {
type CompactionResult,
@ -34,7 +35,8 @@ import {
prepareCompaction,
shouldCompact,
} from "./compaction/index.js";
import { exportSessionToHtml } from "./export-html/index.js";
import { exportSessionToHtml, type ToolHtmlRenderer } from "./export-html/index.js";
import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
import type {
ExtensionRunner,
SessionBeforeCompactResult,
@ -2148,7 +2150,21 @@ export class AgentSession {
*/
async exportToHtml(outputPath?: string): Promise<string> {
const themeName = this.settingsManager.getTheme();
return await exportSessionToHtml(this.sessionManager, this.state, { outputPath, themeName });
// Create tool renderer if we have an extension runner (for custom tool HTML rendering)
let toolRenderer: ToolHtmlRenderer | undefined;
if (this._extensionRunner) {
toolRenderer = createToolHtmlRenderer({
getToolDefinition: (name) => this._extensionRunner!.getToolDefinition(name),
theme,
});
}
return await exportSessionToHtml(this.sessionManager, this.state, {
outputPath,
themeName,
toolRenderer,
});
}
// =========================================================================