-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresetWorld.mjs
37 lines (30 loc) · 1.22 KB
/
resetWorld.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { globalAgents } from "./core/agents/Agent.mjs";
import { globalTime } from "./core/globalTime.mjs";
import { getAgentsPath, getProjectPath } from "./filepath.mjs";
import { writeJsonFileAsync } from "./helper.mjs";
await clearAgentsMemos();
await clearDialogs();
await clearTasks();
globalTime.setTime(0, 0, 0);
async function clearAgentsMemos() {
const clearPromises = Array.from(globalAgents.values()).map(async (agent) => {
await agent.clearNextActions();
await agent.clearInstantMemories();
await agent.clearMemories();
});
await Promise.all(clearPromises);
}
async function clearDialogs() {
const filepath = getAgentsPath() + `/globalDialogs.json`;
await writeJsonFileAsync(filepath, []);
}
async function clearTasks() {
const clearPromises = Array.from(globalAgents.values()).map(async (agent) => {
await agent.clearTask();
});
await Promise.all(clearPromises);
const projectInfoPath = getProjectPath() + "/project_info.json";
const projectHistoryPath = getProjectPath() + "/project_history.json";
await writeJsonFileAsync(projectInfoPath, { finalGoal: "", currentPhase: 0, phases: [], tasks: [] });
await writeJsonFileAsync(projectHistoryPath, []);
}