fixed restart

This commit is contained in:
MaxRobinsonTheGreat 2023-12-12 13:39:35 -06:00
parent 48fd28a10f
commit 90ac954c04
3 changed files with 8 additions and 5 deletions

View file

@ -1,8 +1,11 @@
import { spawn } from 'child_process'; import { spawn } from 'child_process';
export class AgentProcess { export class AgentProcess {
constructor(name, clear_memory=false, autostart=false) { constructor(name) {
let args = ['controller/init-agent.js', name]; this.name = name;
}
start(clear_memory=false, autostart=false) {
let args = ['controller/init-agent.js', this.name];
if (clear_memory) if (clear_memory)
args.push('-c'); args.push('-c');
if (autostart) if (autostart)

View file

@ -1,3 +1,3 @@
import { AgentProcess } from './controller/agent-process.js'; import { AgentProcess } from './controller/agent-process.js';
new AgentProcess('andy', true, false); new AgentProcess('andy').start(true, false);

View file

@ -91,7 +91,7 @@ export class Coder {
this.current_code = this.queued_code; this.current_code = this.queued_code;
this.executing = true; this.executing = true;
TIMEOUT = this._startTimeout(1); TIMEOUT = this._startTimeout(10);
await execution_file.main(this.agent.bot); // open fire await execution_file.main(this.agent.bot); // open fire
this.executing = false; this.executing = false;
clearTimeout(TIMEOUT); clearTimeout(TIMEOUT);
@ -160,7 +160,7 @@ export class Coder {
if (this.executing) { if (this.executing) {
console.error(`Failed to stop. Killing process. Goodbye.`); console.error(`Failed to stop. Killing process. Goodbye.`);
this.agent.bot.output += `\nForce stop failed! Process was killed and will be restarted. Goodbye world.`; this.agent.bot.output += `\nForce stop failed! Process was killed and will be restarted. Goodbye world.`;
this.bot.chat('Goodbye world.'); this.agent.bot.chat('Goodbye world.');
let output = this.formatOutput(this.agent.bot); let output = this.formatOutput(this.agent.bot);
this.agent.history.add('system', output); this.agent.history.add('system', output);
this.agent.history.save(); this.agent.history.save();