added mindserver hosting controls

This commit is contained in:
MaxRobinsonTheGreat 2024-11-19 22:21:17 -06:00
parent 271d17f650
commit 210843a0ad
4 changed files with 20 additions and 4 deletions

View file

@ -20,7 +20,9 @@ function getProfiles(args) {
}
function main() {
const mindServer = createMindServer();
if (settings.host_mindserver) {
const mindServer = createMindServer();
}
const args = parseArguments();
const profiles = getProfiles(args);

View file

@ -4,6 +4,11 @@ export default
"host": "127.0.0.1", // or "localhost", "your.ip.address.here"
"port": 55916,
"auth": "offline", // or "microsoft"
// the mindserver manages all agents and hosts the UI
"host_mindserver": true, // if true, the mindserver will be hosted on this machine. otherwise, specify a public IP address
"mindserver_host": "localhost",
"mindserver_port": 8080,
"profiles": [
"./andy.json",

View file

@ -4,7 +4,7 @@ import { containsCommand } from './commands/index.js';
import { sendBotChatToServer } from './server_proxy.js';
let agent;
const agent_names = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name);
let agent_names = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name);
let inMessageTimer = null;
let MAX_TURNS = -1;
@ -13,6 +13,10 @@ export function isOtherAgent(name) {
return agent_names.some((n) => n === name);
}
export function updateAgents(names) {
agent_names = names;
}
export function initConversationManager(a) {
agent = a;
}

View file

@ -1,5 +1,6 @@
import { io } from 'socket.io-client';
import { recieveFromBot } from './conversation.js';
import { recieveFromBot, updateAgents } from './conversation.js';
import settings from '../../settings.js';
class ServerProxy {
constructor() {
@ -15,7 +16,7 @@ class ServerProxy {
connect() {
if (this.connected) return;
this.socket = io('http://localhost:8080');
this.socket = io(`http://${settings.mindserver_host}:${settings.mindserver_port}`);
this.connected = true;
this.socket.on('connect', () => {
@ -30,6 +31,10 @@ class ServerProxy {
this.socket.on('chat-message', (agentName, json) => {
recieveFromBot(agentName, json);
});
this.socket.on('agents-update', (agents) => {
updateAgents(agents);
});
}
registerAgent(agentName) {