Project Files
runtime.js
/**
* @fileoverview Self-contained runtime entry point for the Web Search Crawler Plugin.
* This bypasses the potentially flawed lms dev module loader by explicitly
* importing and running the compiled JavaScript modules.
*/
// Import the tool directly from its source file.
// Note: In a production environment, this should point to the compiled .js file in /dist.
const { searchWebTool } = require('./src/tools/searchWeb');
/**
* Main entry point to run the plugin logic.
* This function mimics the role of the original lms dev command but uses direct Node.js requires.
*/
async function initializePlugin() {
console.log("[Runtime Initialized] Web Search Plugin ready.");
}
/**
* Public facing execution method that can be called by a calling process
* (e.g., a testing harness or the LLM wrapper).
* @param inputData The data structured for the web search tool.
* @returns A promise resolving to the search response.
*/
async function callToolImplementation(tool, input) {
if (tool && typeof tool.implementation === 'function') {
return await tool.implementation(input);
} else {
throw new Error("Tool implementation not found or not a function.");
}
}
async function executeWebSearchTool(inputData) {
try {
const result = await callToolImplementation(searchWebTool, inputData);
console.log("[Runtime Success] Tool executed successfully.");
return result;
} catch (error) {
console.error("[Runtime Error] Failed to execute tool:", error);
throw new Error(`Web Search Tool Failure: ${error instanceof Error ? error.message : String(error)}`);
}
}
// Exporting the functions so they can be required by other scripts if needed
module.exports = {
initializePlugin,
executeWebSearchTool
};