From bd2dabfa8fcf81c4d8e1ba5ea2a7023a877eb242 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 3 Jan 2026 12:34:59 +0000 Subject: [PATCH] fix(agents): load tool display config from disk --- src/agents/tool-display.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/agents/tool-display.ts b/src/agents/tool-display.ts index 12c727b33..6975675f5 100644 --- a/src/agents/tool-display.ts +++ b/src/agents/tool-display.ts @@ -1,5 +1,5 @@ +import fs from "node:fs"; import { shortenHomeInString } from "../utils.js"; -import rawConfig from "./tool-display.json" assert { type: "json" }; type ToolDisplayActionSpec = { label?: string; @@ -29,7 +29,17 @@ export type ToolDisplay = { detail?: string; }; -const TOOL_DISPLAY_CONFIG = rawConfig as ToolDisplayConfig; +const TOOL_DISPLAY_CONFIG: ToolDisplayConfig = (() => { + try { + const raw = fs.readFileSync( + new URL("./tool-display.json", import.meta.url), + "utf8", + ); + return JSON.parse(raw) as ToolDisplayConfig; + } catch { + return {}; + } +})(); const FALLBACK = TOOL_DISPLAY_CONFIG.fallback ?? { emoji: "🧩" }; const TOOL_MAP = TOOL_DISPLAY_CONFIG.tools ?? {}; @@ -91,7 +101,10 @@ function lookupValueByPath(args: unknown, path: string): unknown { return current; } -function resolveDetailFromKeys(args: unknown, keys: string[]): string | undefined { +function resolveDetailFromKeys( + args: unknown, + keys: string[], +): string | undefined { for (const key of keys) { const value = lookupValueByPath(args, key); const display = coerceDisplayValue(value);