fix(directory-agents-injector): guard against non-string output.output

MCP tool responses (e.g. Serena via mcpm) can deliver output.output as
undefined or a non-string at runtime despite the TypeScript interface
declaring it as string. Add the same typeof guard already used in
tool-output-truncator and other hooks, preventing a TypeError crash.

Fixes #3800
This commit is contained in:
YeonGyu-Kim
2026-05-06 03:49:37 +09:00
parent 32fab88d68
commit bcaae1037d
3 changed files with 37 additions and 5 deletions
@@ -26,6 +26,10 @@ export async function processFilePathForAgentsInjection(input: {
sessionID: string;
output: { title: string; output: string; metadata: unknown };
}): Promise<void> {
// Guard: output.output may be non-string at runtime (e.g. MCP bridge format changes).
// Consistent with the pattern used in tool-output-truncator and other hooks.
if (typeof input.output.output !== "string") return;
const resolved = resolveFilePath(input.ctx.directory, input.filePath);
if (!resolved) return;