seedproject-web/agents/console/server.mjs

34 lines
1.1 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
/**
* AstroAgent console runner bootstrap.
*
* Loads the generic host, then registers ONLY the agents this project enables
* (astroagent.config.json agents.enabled, exposed via site.agents), passing
* each its per-agent settings. Each capability is a module under ./agents/
* exporting register(host, settings).
*
* Runs AS the confined agent user, binds 127.0.0.1, reached only through nginx
* (auth_request against the PHP admin session). Node built-ins only.
*/
import { host } from "./host.mjs";
import { site } from "./site.mjs";
const { enabled, settings } = site.agents;
for (const name of enabled) {
try {
const mod = await import(`./agents/${name}.mjs`);
if (typeof mod.register === "function") {
mod.register(host, settings[name] || {});
console.log(`[console] agent enabled: ${name}`);
} else {
console.warn(`[console] agent '${name}' has no register() — skipped`);
}
} catch (err) {
console.error(`[console] agent '${name}' failed to load: ${err.message}`);
}
}
host.listen();