fix: use fileURLToPath for Windows compatibility

This commit is contained in:
Roopak Nijhara 2026-01-27 22:52:04 +05:30 committed by Ayaan Zaidi
parent 4289a2b255
commit f362a76e38

View File

@ -8,6 +8,7 @@
import fs from "node:fs/promises"; import fs from "node:fs/promises";
import path from "node:path"; import path from "node:path";
import os from "node:os"; import os from "node:os";
import { fileURLToPath } from "node:url";
import type { MoltbotConfig } from "../../../config/config.js"; import type { MoltbotConfig } from "../../../config/config.js";
import { resolveAgentWorkspaceDir } from "../../../agents/agent-scope.js"; import { resolveAgentWorkspaceDir } from "../../../agents/agent-scope.js";
import { resolveAgentIdFromSessionKey } from "../../../routing/session-key.js"; import { resolveAgentIdFromSessionKey } from "../../../routing/session-key.js";
@ -116,10 +117,7 @@ const saveSessionToMemory: HookHandler = async (event) => {
// Dynamically import the LLM slug generator (avoids module caching issues) // Dynamically import the LLM slug generator (avoids module caching issues)
// When compiled, handler is at dist/hooks/bundled/session-memory/handler.js // When compiled, handler is at dist/hooks/bundled/session-memory/handler.js
// Going up ../.. puts us at dist/hooks/, so just add llm-slug-generator.js // Going up ../.. puts us at dist/hooks/, so just add llm-slug-generator.js
const moltbotRoot = path.resolve( const moltbotRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
path.dirname(import.meta.url.replace("file://", "")),
"../..",
);
const slugGenPath = path.join(moltbotRoot, "llm-slug-generator.js"); const slugGenPath = path.join(moltbotRoot, "llm-slug-generator.js");
const { generateSlugViaLLM } = await import(slugGenPath); const { generateSlugViaLLM } = await import(slugGenPath);