MCPcopy Create free account
hub / github.com/Epic0522/Codex-Remote-Contact / importOptionalModule

Function importOptionalModule

src/server.js:85–100  ·  view source on GitHub ↗
(label, candidates)

Source from the content-addressed store, hash-verified

83let stripQqImageAttachmentMarkers = (text) => String(text || "").trim();
84
85async function importOptionalModule(label, candidates) {
86 for (const candidate of candidates.filter(Boolean)) {
87 try {
88 const specifier = candidate.startsWith("file:") || candidate.startsWith(".")
89 ? candidate
90 : pathToFileURL(candidate).href;
91 return await import(specifier);
92 } catch (error) {
93 if (error?.code && !["ERR_MODULE_NOT_FOUND", "ERR_INVALID_FILE_URL_PATH", "ERR_UNSUPPORTED_ESM_URL_SCHEME"].includes(error.code)) {
94 console.warn(`${label} failed to load from ${candidate}: ${error.message}`);
95 }
96 }
97 }
98 console.warn(`${label} not installed; continuing with built-in fallback.`);
99 return null;
100}
101
102const unifiedMemoryModule = await importOptionalModule("unified-memory", [
103 process.env.CODEX_REMOTE_CONTACT_UNIFIED_MEMORY_MODULE,

Callers 1

server.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected