@ynhcj/xiaoyi-channel 0.0.103-beta → 0.0.104-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from "fs";
|
|
2
|
-
const
|
|
2
|
+
const XIAOYIRUNTIME_PATH = "/home/sandbox/.openclaw/.xiaoyiruntime";
|
|
3
3
|
export function handleSelfEvolutionEvent(context, runtime) {
|
|
4
4
|
const log = runtime?.log ?? console.log;
|
|
5
5
|
const error = runtime?.error ?? console.error;
|
|
@@ -12,12 +12,12 @@ export function handleSelfEvolutionEvent(context, runtime) {
|
|
|
12
12
|
log(`[SELF_EVOLUTION] received state: ${state}`);
|
|
13
13
|
let content;
|
|
14
14
|
try {
|
|
15
|
-
content = readFileSync(
|
|
15
|
+
content = readFileSync(XIAOYIRUNTIME_PATH, "utf-8");
|
|
16
16
|
}
|
|
17
17
|
catch {
|
|
18
18
|
// File doesn't exist yet — create it
|
|
19
|
-
log(`[SELF_EVOLUTION] ${
|
|
20
|
-
writeFileSync(
|
|
19
|
+
log(`[SELF_EVOLUTION] ${XIAOYIRUNTIME_PATH} not found, creating new file`);
|
|
20
|
+
writeFileSync(XIAOYIRUNTIME_PATH, `selfEvolutionState=${state}\n`, "utf-8");
|
|
21
21
|
log(`[SELF_EVOLUTION] wrote selfEvolutionState=${state}`);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
@@ -34,12 +34,12 @@ export function handleSelfEvolutionEvent(context, runtime) {
|
|
|
34
34
|
if (!found) {
|
|
35
35
|
// Ensure trailing newline before appending
|
|
36
36
|
const trimmed = content.trimEnd();
|
|
37
|
-
writeFileSync(
|
|
37
|
+
writeFileSync(XIAOYIRUNTIME_PATH, `${trimmed}\n${key}=${state}\n`, "utf-8");
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
writeFileSync(
|
|
40
|
+
writeFileSync(XIAOYIRUNTIME_PATH, updated.join("\n"), "utf-8");
|
|
41
41
|
}
|
|
42
|
-
log(`[SELF_EVOLUTION] updated selfEvolutionState=${state} in ${
|
|
42
|
+
log(`[SELF_EVOLUTION] updated selfEvolutionState=${state} in ${XIAOYIRUNTIME_PATH}`);
|
|
43
43
|
}
|
|
44
44
|
catch (err) {
|
|
45
45
|
error("[SELF_EVOLUTION] failed to handle event:", err);
|
|
@@ -28,8 +28,30 @@ export async function saveRuntimeInfo(webSocketSessionId, conversationId, taskId
|
|
|
28
28
|
}
|
|
29
29
|
try {
|
|
30
30
|
await ensureDirectoryExists(RUNTIME_FILE);
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const updates = {
|
|
32
|
+
SESSION_ID: webSocketSessionId,
|
|
33
|
+
CONVERSATION_ID: conversationId,
|
|
34
|
+
TASK_ID: taskId,
|
|
35
|
+
};
|
|
36
|
+
let lines = [];
|
|
37
|
+
try {
|
|
38
|
+
const content = await fs.readFile(RUNTIME_FILE, "utf-8");
|
|
39
|
+
lines = content.split("\n");
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// File doesn't exist yet
|
|
43
|
+
}
|
|
44
|
+
for (const [key, value] of Object.entries(updates)) {
|
|
45
|
+
const index = lines.findIndex((line) => line.startsWith(`${key}=`));
|
|
46
|
+
if (index !== -1) {
|
|
47
|
+
lines[index] = `${key}=${value}`;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
lines.push(`${key}=${value}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const result = lines.filter((line) => line.trim() !== "").join("\n") + "\n";
|
|
54
|
+
await fs.writeFile(RUNTIME_FILE, result, "utf-8");
|
|
33
55
|
logger.log(`[RuntimeManager] ✅ Saved runtime info to .xiaoyiruntime`);
|
|
34
56
|
logger.log(`[RuntimeManager] - SESSION_ID: ${webSocketSessionId}`);
|
|
35
57
|
logger.log(`[RuntimeManager] - CONVERSATION_ID: ${conversationId}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
-
const SELF_EVOLUTION_ENV_FILE = "/home/sandbox/.openclaw/.
|
|
2
|
+
const SELF_EVOLUTION_ENV_FILE = "/home/sandbox/.openclaw/.xiaoyiruntime";
|
|
3
3
|
const SELF_EVOLUTION_ENV_KEY = "selfEvolutionState";
|
|
4
4
|
function parseBooleanLike(value) {
|
|
5
5
|
const normalized = value.trim().toLowerCase();
|