mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-19 22:01:38 +00:00
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:
parent
ce7e73b503
commit
0c6ac46646
6 changed files with 502 additions and 9 deletions
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue