@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 XIAOYIENV_PATH = "/home/sandbox/.openclaw/.xiaoyienv";
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(XIAOYIENV_PATH, "utf-8");
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] ${XIAOYIENV_PATH} not found, creating new file`);
20
- writeFileSync(XIAOYIENV_PATH, `selfEvolutionState=${state}\n`, "utf-8");
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(XIAOYIENV_PATH, `${trimmed}\n${key}=${state}\n`, "utf-8");
37
+ writeFileSync(XIAOYIRUNTIME_PATH, `${trimmed}\n${key}=${state}\n`, "utf-8");
38
38
  }
39
39
  else {
40
- writeFileSync(XIAOYIENV_PATH, updated.join("\n"), "utf-8");
40
+ writeFileSync(XIAOYIRUNTIME_PATH, updated.join("\n"), "utf-8");
41
41
  }
42
- log(`[SELF_EVOLUTION] updated selfEvolutionState=${state} in ${XIAOYIENV_PATH}`);
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 content = `SESSION_ID=${webSocketSessionId}\nCONVERSATION_ID=${conversationId}\nTASK_ID=${taskId}\n`;
32
- await fs.writeFile(RUNTIME_FILE, content, "utf-8");
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/.xiaoyienv";
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.103-beta",
3
+ "version": "0.0.104-beta",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",