@yulailai/openclaw-plugin-self-growth 3.1.20 → 3.1.21

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.
Files changed (2) hide show
  1. package/dist/sync-client.js +28 -11
  2. package/package.json +1 -1
@@ -82,29 +82,46 @@ export class SyncClient {
82
82
  }
83
83
  }
84
84
  async syncFiles(basePath, token) {
85
- // 同步编译后的记忆文件到 memory API
86
85
  try {
86
+ // 1. 同步人格文件 memory.md
87
87
  const compiledDir = path.join(basePath, 'memory', 'compiled');
88
- const files = ['memory.md', 'preferences.md', 'lessons.md'];
89
- for (const file of files) {
90
- const content = await fs.readFile(path.join(compiledDir, file), 'utf-8').catch(() => '');
91
- if (!content.trim())
92
- continue;
93
- const type = file.replace('.md', '') === 'memory' ? 'preference' : file.replace('.md', '');
94
- await fetch(`${this.config.serverUrl}/api/memory/${type}`, {
88
+ const memoryContent = await fs.readFile(path.join(compiledDir, 'memory.md'), 'utf-8').catch(() => '');
89
+ if (memoryContent) {
90
+ await fetch(`${this.config.serverUrl}/api/sync/push`, {
91
+ method: 'POST',
92
+ headers: {
93
+ 'Content-Type': 'application/json',
94
+ 'Authorization': `Bearer ${token}`,
95
+ },
96
+ body: JSON.stringify({
97
+ type: 'compiled_memory',
98
+ items: [{ content: memoryContent, file_path: 'memory.md' }],
99
+ }),
100
+ signal: AbortSignal.timeout(15000),
101
+ });
102
+ }
103
+ // 2. 同步 chat_logs(今天的)
104
+ const today = new Date().toISOString().split('T')[0];
105
+ const chatLogPath = path.join(basePath, 'chat_logs', `${today}.md`);
106
+ const chatContent = await fs.readFile(chatLogPath, 'utf-8').catch(() => '');
107
+ if (chatContent) {
108
+ await fetch(`${this.config.serverUrl}/api/sync/push`, {
95
109
  method: 'POST',
96
110
  headers: {
97
111
  'Content-Type': 'application/json',
98
112
  'Authorization': `Bearer ${token}`,
99
113
  },
100
- body: JSON.stringify({ content, confidence: 3 }),
114
+ body: JSON.stringify({
115
+ type: 'chat_logs',
116
+ items: [{ content: chatContent, file_path: `${today}.md` }],
117
+ }),
101
118
  signal: AbortSignal.timeout(15000),
102
119
  });
103
120
  }
104
- console.log('[SyncClient] 记忆文件同步完成');
121
+ console.log('[SyncClient] 同步文件完成');
105
122
  }
106
123
  catch (err) {
107
- console.error('[SyncClient] 文件同步失败:', err);
124
+ console.error('[SyncClient] 同步文件失败:', err);
108
125
  }
109
126
  }
110
127
  parsePreferences(markdown) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yulailai/openclaw-plugin-self-growth",
3
- "version": "3.1.20",
3
+ "version": "3.1.21",
4
4
  "description": "让 Agent 具备自我成长、复盘与技能进化能力的插件",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",