diff --git a/apps/server/src/agents/pin-write.ts b/apps/server/src/agents/pin-write.ts index a1b355488..116492f4c 100644 --- a/apps/server/src/agents/pin-write.ts +++ b/apps/server/src/agents/pin-write.ts @@ -6,6 +6,7 @@ import { validatePinValue, type PinType, } from "../pins.js"; +import { errorMessage } from "../shared/lib/error-message.js"; import { AgentError } from "./errors.js"; import { finalizePin, mergePin, type DraftPin } from "./pin-merge.js"; import type { AgentPin } from "./types.js"; @@ -48,10 +49,7 @@ function validateStoredPin(pin: DraftPin): AgentPin { validatePinValue(stored.type, stored.value); if (stored.type === "shortcut") validatePinShortcutFields(stored); } catch (error) { - throw new AgentError( - error instanceof Error ? error.message : String(error), - 400 - ); + throw new AgentError(errorMessage(error), 400); } return stored; } diff --git a/apps/server/src/shared/mcp/whiteboard-tools.ts b/apps/server/src/shared/mcp/whiteboard-tools.ts index df0976678..61f90402d 100644 --- a/apps/server/src/shared/mcp/whiteboard-tools.ts +++ b/apps/server/src/shared/mcp/whiteboard-tools.ts @@ -1,6 +1,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import * as z from "zod/v4"; +import { errorMessage } from "../lib/error-message.js"; import { jsonText } from "./response.js"; import { toToolError } from "./tool-error.js"; import type { @@ -335,7 +336,7 @@ export function registerWhiteboardTools( // caller that guessed at the element shape gets told where it lives. return toToolError( new Error( - `${error instanceof Error ? error.message : String(error)} — call whiteboard_howto for the element format.` + `${errorMessage(error)} — call whiteboard_howto for the element format.` ) ); } diff --git a/apps/server/src/shared/plugin-status.ts b/apps/server/src/shared/plugin-status.ts index 59e6cd27e..6c6e939dd 100644 --- a/apps/server/src/shared/plugin-status.ts +++ b/apps/server/src/shared/plugin-status.ts @@ -38,6 +38,7 @@ import { readFile } from "node:fs/promises"; import { isPluginAgentType, PLUGIN_AGENT_TYPES } from "./agent-types.js"; import type { PluginAgentType } from "./agent-types.js"; import { compareSemver } from "./lib/compare-semver.js"; +import { errorMessage } from "./lib/error-message.js"; import { runCommand, type CommandRunner } from "./lib/run-command.js"; export { isPluginAgentType, PLUGIN_AGENT_TYPES }; @@ -121,7 +122,7 @@ async function runStep( const result = await run(bin, args, { timeoutMs }); return { stdout: result.stdout }; } catch (err) { - return { error: err instanceof Error ? err.message : String(err) }; + return { error: errorMessage(err) }; } }