UNPKG

query-agent

Version:

An AI-powered database query agent that integrates with existing Express apps using Socket.IO and HTTP routes

42 lines (36 loc) 1.18 kB
// CommonJS wrapper for query-agent // This file provides CommonJS compatibility for the ESM package const { createRequire } = require("module"); const require = createRequire(import.meta.url); // Dynamic import for ESM compatibility async function loadESM() { try { const { default: init, agentLog } = await import("./index.js"); return { init, agentLog }; } catch (error) { console.error("Failed to load ESM module:", error); throw error; } } // Export a function that returns the ESM module module.exports = async function () { return await loadESM(); }; // Also export a synchronous version (limited functionality) module.exports.sync = function () { console.warn( "Warning: Using sync version with limited functionality. Use async version for full features." ); // Return a basic wrapper that will work with dynamic imports return { init: async function (app, serverOrIo, options = {}) { const { init } = await loadESM(); return init(app, serverOrIo, options); }, agentLog: function (message, ...args) { if (process.env.agentLog === "1") { console.log(message, ...args); } }, }; };