fix: recover interrupted controller cycles
This commit is contained in:
parent
380fca2b9f
commit
05aeab4817
3 changed files with 49 additions and 3 deletions
|
|
@ -28,6 +28,9 @@ function digestFile(file) {
|
|||
function sourceFingerprint() {
|
||||
const sources = [
|
||||
runtimePath,
|
||||
path.join(moduleDir, "controller-engine.mjs"),
|
||||
path.join(moduleDir, "model-client.mjs"),
|
||||
path.join(moduleDir, "server.mjs"),
|
||||
path.join(
|
||||
repositoryRoot,
|
||||
"tcs-core/zhuyuan-brain/runtime/brain-runtime-contract.json",
|
||||
|
|
@ -111,7 +114,14 @@ export class ControllerEngine {
|
|||
|
||||
initialize() {
|
||||
fs.mkdirSync(this.exchangeDir, { recursive: true });
|
||||
const stateFile = path.join(this.stateDir, "state.json");
|
||||
let stateFile = path.join(this.stateDir, "state.json");
|
||||
if (fs.existsSync(stateFile)) {
|
||||
const existing = this.status();
|
||||
if (existing.status === "PERCEIVING" && existing.active_cycle_id) {
|
||||
this.stateDir = `${this.stateDir}-technical-recovery-${Date.now()}`;
|
||||
stateFile = path.join(this.stateDir, "state.json");
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync(stateFile)) {
|
||||
runRuntime("enter", [
|
||||
"--state-dir",
|
||||
|
|
|
|||
Loading…
Reference in a new issue