- Added `/tools` slash command to display agent-visible tools in interactive sessions. - Added `handleToolsCommand()` method to InteractiveMode to delegate tools display to command controller. - Added `buildToolsMarkdown()` utility function to generate formatted markdown table of available tools. - Refactored `showMarkdownPanel()` helper to reduce duplication in markdown display logic across commands.
28 lines
712 B
TypeScript
28 lines
712 B
TypeScript
import type { Tool } from "../../tools";
|
|
|
|
export interface ToolsMarkdownBindings {
|
|
tools: ReadonlyArray<Pick<Tool, "description" | "name">>;
|
|
}
|
|
|
|
function escapeTableCell(value: string): string {
|
|
return value
|
|
.replace(/\|/g, "\\|")
|
|
.replace(/\r?\n+/g, " ")
|
|
.trim();
|
|
}
|
|
|
|
export function buildToolsMarkdown(bindings: ToolsMarkdownBindings): string {
|
|
if (bindings.tools.length === 0) {
|
|
return "No tools are currently visible to the agent.";
|
|
}
|
|
|
|
return [
|
|
"| Tool | Description |",
|
|
"|------|-------------|",
|
|
...bindings.tools.map(tool => {
|
|
const description = escapeTableCell(tool.description) || "No description provided.";
|
|
return `| \`${tool.name}\` | ${description} |`;
|
|
}),
|
|
].join("\n");
|
|
}
|