From 90ac954c0459bb187a06da1aa2f5eea79e69badf Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Tue, 12 Dec 2023 13:39:35 -0600 Subject: [PATCH] fixed restart --- controller/agent-process.js | 7 +++++-- main.js | 2 +- utils/coder.js | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/controller/agent-process.js b/controller/agent-process.js index cfeb159..53fdf1b 100644 --- a/controller/agent-process.js +++ b/controller/agent-process.js @@ -1,8 +1,11 @@ import { spawn } from 'child_process'; export class AgentProcess { - constructor(name, clear_memory=false, autostart=false) { - let args = ['controller/init-agent.js', name]; + constructor(name) { + this.name = name; + } + start(clear_memory=false, autostart=false) { + let args = ['controller/init-agent.js', this.name]; if (clear_memory) args.push('-c'); if (autostart) diff --git a/main.js b/main.js index 9ed8af8..ea78372 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,3 @@ import { AgentProcess } from './controller/agent-process.js'; -new AgentProcess('andy', true, false); \ No newline at end of file +new AgentProcess('andy').start(true, false); \ No newline at end of file diff --git a/utils/coder.js b/utils/coder.js index 61f3211..f6040d1 100644 --- a/utils/coder.js +++ b/utils/coder.js @@ -91,7 +91,7 @@ export class Coder { this.current_code = this.queued_code; this.executing = true; - TIMEOUT = this._startTimeout(1); + TIMEOUT = this._startTimeout(10); await execution_file.main(this.agent.bot); // open fire this.executing = false; clearTimeout(TIMEOUT); @@ -160,7 +160,7 @@ export class Coder { if (this.executing) { 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.bot.chat('Goodbye world.'); + this.agent.bot.chat('Goodbye world.'); let output = this.formatOutput(this.agent.bot); this.agent.history.add('system', output); this.agent.history.save();