foliko 1.1.63 → 1.1.65

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 (48) hide show
  1. package/.agent/data/plugins-state.json +8 -0
  2. package/.agent/sessions/cli_default.json +258 -260
  3. package/cli/bin/foliko.js +2 -2
  4. package/cli/src/commands/chat.js +15 -26
  5. package/cli/src/ui/chat-ui.js +102 -165
  6. package/cli/src/ui/footer-bar.js +7 -32
  7. package/cli/src/ui/message-bubble.js +24 -2
  8. package/cli/src/ui/status-bar.js +177 -0
  9. package/package.json +1 -2
  10. package/plugins/audit-plugin.js +11 -7
  11. package/plugins/coordinator-plugin.js +14 -12
  12. package/plugins/data-splitter-plugin.js +323 -0
  13. package/plugins/default-plugins.js +12 -1
  14. package/plugins/extension-executor-plugin.js +2 -2
  15. package/plugins/file-system-plugin.js +68 -50
  16. package/plugins/gate-trading.js +10 -10
  17. package/plugins/install-plugin.js +3 -3
  18. package/plugins/memory-plugin.js +8 -11
  19. package/plugins/plugin-manager-plugin.js +9 -11
  20. package/plugins/qq-plugin.js +9 -9
  21. package/plugins/rules-plugin.js +7 -7
  22. package/plugins/scheduler-plugin.js +22 -18
  23. package/plugins/session-plugin.js +14 -14
  24. package/plugins/storage-plugin.js +11 -10
  25. package/plugins/subagent-plugin.js +13 -9
  26. package/plugins/think-plugin.js +63 -59
  27. package/plugins/tools-plugin.js +8 -8
  28. package/plugins/weixin-plugin.js +5 -5
  29. package/src/capabilities/skill-manager.js +23 -15
  30. package/src/capabilities/workflow-engine.js +2 -2
  31. package/src/core/agent-chat.js +70 -26
  32. package/src/core/agent.js +17 -27
  33. package/src/core/chat-session.js +7 -161
  34. package/src/core/constants.js +198 -0
  35. package/src/core/context-compressor.js +6 -181
  36. package/src/core/framework.js +125 -6
  37. package/src/core/plugin-base.js +7 -5
  38. package/src/core/provider.js +6 -0
  39. package/src/core/subagent.js +16 -135
  40. package/src/core/tool-executor.js +2 -70
  41. package/src/executors/mcp-executor.js +12 -10
  42. package/src/utils/chat-queue.js +11 -22
  43. package/src/utils/data-splitter.js +345 -0
  44. package/src/utils/download.js +5 -4
  45. package/src/utils/message-validator.js +283 -0
  46. package/src/utils/retry.js +168 -22
  47. package/src/utils/sandbox.js +60 -207
  48. package/cli/src/utils/debounce.js +0 -106
@@ -76,7 +76,7 @@ class FileSystemPlugin extends Plugin {
76
76
  }
77
77
  }
78
78
  readDir(dirPath)
79
- return { success: true, dirPath, items: items.slice(0, 100), total: items.length }
79
+ return { success: true, data: items.slice(0, 100), metadata: { dirPath, total: items.length } }
80
80
  } catch (error) {
81
81
  return { success: false, error: error.message }
82
82
  }
@@ -95,7 +95,7 @@ class FileSystemPlugin extends Plugin {
95
95
  const dirPath = args.path || args.dirPath
96
96
  try {
97
97
  fs.mkdirSync(dirPath, { recursive: true })
98
- return { success: true, message: `目录已创建: ${dirPath}` }
98
+ return { success: true, data: `目录已创建: ${dirPath}` }
99
99
  } catch (error) {
100
100
  return { success: false, error: error.message }
101
101
  }
@@ -140,10 +140,12 @@ class FileSystemPlugin extends Plugin {
140
140
  }
141
141
  return {
142
142
  success: true,
143
- filePath: pathCheck.resolved,
144
- content,
145
- size: stat.size,
146
- lines: lines ? null : content.split('\n').length
143
+ data: content,
144
+ metadata: {
145
+ filePath: pathCheck.resolved,
146
+ size: stat.size,
147
+ lines: lines ? null : content.split('\n').length
148
+ }
147
149
  }
148
150
  } catch (error) {
149
151
  return { success: false, error: error.message }
@@ -210,10 +212,12 @@ class FileSystemPlugin extends Plugin {
210
212
  if (err) reject(err)
211
213
  else resolve({
212
214
  success: true,
213
- message: `文件已${mode === 'append' ? '追加' : '写入'}: ${pathCheck.resolved}`,
214
- filePath: pathCheck.resolved,
215
- size: content.length,
216
- mode
215
+ data: `文件已${mode === 'append' ? '追加' : '写入'}: ${pathCheck.resolved}`,
216
+ metadata: {
217
+ filePath: pathCheck.resolved,
218
+ size: content.length,
219
+ mode
220
+ }
217
221
  })
218
222
  })
219
223
  })
@@ -254,9 +258,11 @@ class FileSystemPlugin extends Plugin {
254
258
  fs.appendFileSync(pathCheck.resolved, content, 'utf8')
255
259
  return {
256
260
  success: true,
257
- message: `已追加内容到: ${pathCheck.resolved}`,
258
- filePath: pathCheck.resolved,
259
- appendedSize: content.length
261
+ data: `已追加内容到: ${pathCheck.resolved}`,
262
+ metadata: {
263
+ filePath: pathCheck.resolved,
264
+ appendedSize: content.length
265
+ }
260
266
  }
261
267
  } catch (error) {
262
268
  return { success: false, error: error.message }
@@ -297,7 +303,7 @@ class FileSystemPlugin extends Plugin {
297
303
  } else {
298
304
  fs.unlinkSync(pathCheck.resolved)
299
305
  }
300
- return { success: true, message: `已删除: ${pathCheck.resolved}` }
306
+ return { success: true, data: `已删除: ${pathCheck.resolved}` }
301
307
  } catch (error) {
302
308
  return { success: false, error: error.message }
303
309
  }
@@ -660,13 +666,15 @@ edits 数组可以包含多个不重叠的替换操作,每个操作通过 oldT
660
666
 
661
667
  return {
662
668
  success: true,
663
- pattern,
664
- results: results.slice(0, maxResults),
665
- total: results.length,
666
- stats: {
667
- filesWithMatches,
668
- totalMatches,
669
- searchPath: targetFile || dirPath
669
+ data: results.slice(0, maxResults),
670
+ metadata: {
671
+ pattern,
672
+ total: results.length,
673
+ stats: {
674
+ filesWithMatches,
675
+ totalMatches,
676
+ searchPath: targetFile || dirPath
677
+ }
670
678
  }
671
679
  }
672
680
  } catch (error) {
@@ -817,19 +825,23 @@ edits 数组可以包含多个不重叠的替换操作,每个操作通过 oldT
817
825
  if (error) {
818
826
  resolve({
819
827
  success: false,
820
- command,
821
828
  error: error.message,
822
- stderr: stderr.substring(0, 2000),
823
- stdout: stdout.substring(0, 2000),
824
- duration
829
+ metadata: {
830
+ command,
831
+ stderr: stderr.substring(0, 2000),
832
+ stdout: stdout.substring(0, 2000),
833
+ duration
834
+ }
825
835
  })
826
836
  } else {
827
837
  resolve({
828
838
  success: true,
829
- command,
830
- stdout: stdout.substring(0, 10000),
831
- stderr: stderr.substring(0, 1000),
832
- duration
839
+ data: stdout.substring(0, 10000),
840
+ metadata: {
841
+ command,
842
+ stderr: stderr.substring(0, 1000),
843
+ duration
844
+ }
833
845
  })
834
846
  }
835
847
  }
@@ -848,16 +860,18 @@ edits 数组可以包含多个不重叠的替换操作,每个操作通过 oldT
848
860
  const beijingTime = new Date(now.getTime() + (8 * 60 * 60 * 1000))
849
861
  return {
850
862
  success: true,
851
- beijingTime: beijingTime.toISOString().replace('T', ' ').substring(0, 19),
852
- timestamp: now.getTime(),
853
- timezone: 'Asia/Shanghai (UTC+8)',
854
- formatted: {
855
- year: beijingTime.getUTCFullYear(),
856
- month: String(beijingTime.getUTCMonth() + 1).padStart(2, '0'),
857
- day: String(beijingTime.getUTCDate()).padStart(2, '0'),
858
- hour: String(beijingTime.getUTCHours()).padStart(2, '0'),
859
- minute: String(beijingTime.getUTCMinutes()).padStart(2, '0'),
860
- second: String(beijingTime.getUTCMinutes()).padStart(2, '0')
863
+ data: beijingTime.toISOString().replace('T', ' ').substring(0, 19),
864
+ metadata: {
865
+ timestamp: now.getTime(),
866
+ timezone: 'Asia/Shanghai (UTC+8)',
867
+ formatted: {
868
+ year: beijingTime.getUTCFullYear(),
869
+ month: String(beijingTime.getUTCMonth() + 1).padStart(2, '0'),
870
+ day: String(beijingTime.getUTCDate()).padStart(2, '0'),
871
+ hour: String(beijingTime.getUTCHours()).padStart(2, '0'),
872
+ minute: String(beijingTime.getUTCMinutes()).padStart(2, '0'),
873
+ second: String(beijingTime.getUTCMinutes()).padStart(2, '0')
874
+ }
861
875
  }
862
876
  }
863
877
  }
@@ -983,21 +997,25 @@ edits 数组可以包含多个不重叠的替换操作,每个操作通过 oldT
983
997
  : data
984
998
  return {
985
999
  success: true,
986
- status: response.status,
987
- statusText: response.statusText,
988
- headers: Object.fromEntries(response.headers.entries()),
989
- usedProxy: proxy,
990
- body: truncatedData,
991
- originalLength: typeof data === 'string' ? data.length : null,
992
- truncated: maxLength && typeof data === 'string' && data.length > maxLength
1000
+ data: truncatedData,
1001
+ metadata: {
1002
+ status: response.status,
1003
+ statusText: response.statusText,
1004
+ headers: Object.fromEntries(response.headers.entries()),
1005
+ usedProxy: proxy,
1006
+ originalLength: typeof data === 'string' ? data.length : null,
1007
+ truncated: maxLength && typeof data === 'string' && data.length > maxLength
1008
+ }
993
1009
  }
994
1010
  } catch (error) {
995
1011
  return {
996
1012
  success: false,
997
1013
  error: error.message,
998
- url,
999
- method,
1000
- hint: '如果访问失败,可尝试设置 proxy: true'
1014
+ metadata: {
1015
+ url,
1016
+ method,
1017
+ hint: '如果访问失败,可尝试设置 proxy: true'
1018
+ }
1001
1019
  }
1002
1020
  }
1003
1021
  }
@@ -1026,7 +1044,7 @@ edits 数组可以包含多个不重叠的替换操作,每个操作通过 oldT
1026
1044
  sessionId,
1027
1045
  timestamp: new Date().toISOString()
1028
1046
  })
1029
- return { success: true, message: '通知已发送' }
1047
+ return { success: true, data: '通知已发送' }
1030
1048
  } catch (error) {
1031
1049
  return { success: false, error: error.message }
1032
1050
  }
@@ -64,7 +64,7 @@ class GateTradingPlugin extends Plugin {
64
64
  this.secretKey = args.secret;
65
65
  const fs = require('fs');
66
66
  fs.writeFileSync(__dirname + '/.env', `GATE_API_KEY=${args.api_key}\nGATE_SECRET_KEY=${args.secret}\n`);
67
- return { success: true, message: 'Gate API 密钥已成功配置' };
67
+ return { success: true, data: 'Gate API 密钥已成功配置' };
68
68
  },
69
69
  });
70
70
 
@@ -86,7 +86,7 @@ class GateTradingPlugin extends Plugin {
86
86
  this.apiKey = '';
87
87
  this.secretKey = '';
88
88
  try { require('fs').unlinkSync(__dirname + '/.env'); } catch (e) {}
89
- return { success: true, message: 'API 配置已清除' };
89
+ return { success: true, data: 'API 配置已清除' };
90
90
  },
91
91
  });
92
92
 
@@ -99,7 +99,7 @@ class GateTradingPlugin extends Plugin {
99
99
  this._checkAuth();
100
100
  const spotApi = this._createSpotApi();
101
101
  const currencies = await spotApi.listCurrencies();
102
- return { success: true, message: 'API 连接成功,密钥有效', currencyCount: currencies.body.length };
102
+ return { success: true, data: 'API 连接成功,密钥有效', metadata: { currencyCount: currencies.body.length } };
103
103
  } catch (error) { return { success: false, error: error.message }; }
104
104
  },
105
105
  });
@@ -118,18 +118,18 @@ class GateTradingPlugin extends Plugin {
118
118
  const { currency_pair, info_type } = args;
119
119
  if (info_type === 'book' || !info_type) {
120
120
  const book = await spotApi.listOrderBook(currency_pair, { limit: 10 });
121
- return { success: true, type: 'order_book', currency_pair, bids: book.body.bids, asks: book.body.asks };
121
+ return { success: true, data: { bids: book.body.bids, asks: book.body.asks }, metadata: { type: 'order_book', currency_pair } };
122
122
  } else if (info_type === 'tickers') {
123
123
  const tickers = await spotApi.listTickers(currency_pair);
124
124
  const t = tickers.body.find(x => x.currencyPair === currency_pair) || tickers.body[0];
125
125
  return {
126
- success: true, type: 'ticker', currency_pair: t.currencyPair,
126
+ success: true, data: { type: 'ticker', currency_pair: t.currencyPair,
127
127
  last: t.last, high_24h: t.high24h, low_24h: t.low24h,
128
- volume_24h: t.baseVolume, quote_volume_24h: t.quoteVolume, change_percentage_24h: t.changePercentage,
128
+ volume_24h: t.baseVolume, quote_volume_24h: t.quoteVolume, change_percentage_24h: t.changePercentage },
129
129
  };
130
130
  } else if (info_type === 'trades') {
131
131
  const trades = await spotApi.listTrades(currency_pair);
132
- return { success: true, type: 'trades', currency_pair, trades: trades.body.slice(0, 20) };
132
+ return { success: true, data: trades.body.slice(0, 20), metadata: { type: 'trades', currency_pair } };
133
133
  }
134
134
  return { success: false, error: '未知的信息类型' };
135
135
  } catch (error) { return { success: false, error: error.message }; }
@@ -152,7 +152,7 @@ class GateTradingPlugin extends Plugin {
152
152
  const nonZero = balances.filter(b => parseFloat(b.available) > 0 || parseFloat(b.locked) > 0);
153
153
  return {
154
154
  success: true,
155
- balances: nonZero.map(b => ({
155
+ data: nonZero.map(b => ({
156
156
  currency: b.currency, available: b.available, locked: b.locked,
157
157
  total: parseFloat(b.available) + parseFloat(b.locked),
158
158
  })),
@@ -180,9 +180,9 @@ class GateTradingPlugin extends Plugin {
180
180
  const result = await spotApi.createOrder(order);
181
181
  const r = result.body;
182
182
  return {
183
- success: true, order_id: r.id, currency_pair: r.currency_pair,
183
+ success: true, data: { order_id: r.id, currency_pair: r.currency_pair,
184
184
  type: r.type, side: r.side, amount: r.amount,
185
- price: r.price, status: r.status, create_time: r.create_time,
185
+ price: r.price, status: r.status, create_time: r.create_time },
186
186
  };
187
187
  } catch (error) { return { success: false, error: error.message }; }
188
188
  },
@@ -104,7 +104,7 @@ class InstallPlugin extends Plugin {
104
104
 
105
105
  return {
106
106
  success: true,
107
- message: `Successfully installed ${packageName} to ${installPath}`
107
+ data: `Successfully installed ${packageName} to ${installPath}`
108
108
  }
109
109
  } catch (err) {
110
110
  return {
@@ -141,7 +141,7 @@ class InstallPlugin extends Plugin {
141
141
  }
142
142
 
143
143
  if (packages.length === 0) {
144
- return { success: true, message: 'No dependencies to install' }
144
+ return { success: true, data: 'No dependencies to install' }
145
145
  }
146
146
 
147
147
  // 确保目标目录存在
@@ -159,7 +159,7 @@ class InstallPlugin extends Plugin {
159
159
 
160
160
  return {
161
161
  success: true,
162
- message: `Successfully installed ${packages.length} dependencies to ${installPath}`
162
+ data: `Successfully installed ${packages.length} dependencies to ${installPath}`
163
163
  }
164
164
  } catch (err) {
165
165
  return {
@@ -625,8 +625,7 @@ class MemoryPlugin extends Plugin {
625
625
 
626
626
  return {
627
627
  success: true,
628
- count: results.length,
629
- memories: results.map(m => ({
628
+ data: results.map(m => ({
630
629
  id: m.id,
631
630
  name: m.name,
632
631
  type: m.type,
@@ -665,8 +664,8 @@ class MemoryPlugin extends Plugin {
665
664
 
666
665
  return {
667
666
  success: true,
668
- id: memory.id,
669
- message: `Memory created: ${memory.id}`
667
+ data: `Memory created: ${memory.id}`,
668
+ metadata: { id: memory.id }
670
669
  }
671
670
  } catch (err) {
672
671
  return { success: false, error: err.message }
@@ -694,8 +693,7 @@ class MemoryPlugin extends Plugin {
694
693
 
695
694
  return {
696
695
  success: true,
697
- count: memories.length,
698
- memories: memories.map(m => ({
696
+ data: memories.map(m => ({
699
697
  id: m.id,
700
698
  name: m.name,
701
699
  type: m.type,
@@ -752,8 +750,8 @@ class MemoryPlugin extends Plugin {
752
750
  const memory = this._store.update(args.id, updates)
753
751
  return {
754
752
  success: true,
755
- id: memory.id,
756
- message: `Memory updated: ${memory.id}`
753
+ data: `Memory updated: ${memory.id}`,
754
+ metadata: { id: memory.id }
757
755
  }
758
756
  } catch (err) {
759
757
  return { success: false, error: err.message }
@@ -776,7 +774,7 @@ class MemoryPlugin extends Plugin {
776
774
  }
777
775
  return {
778
776
  success: true,
779
- memory: {
777
+ data: {
780
778
  id: memory.id,
781
779
  name: memory.name,
782
780
  type: memory.type,
@@ -803,8 +801,7 @@ class MemoryPlugin extends Plugin {
803
801
  const projects = this._store.getProjects()
804
802
  return {
805
803
  success: true,
806
- stats,
807
- projects
804
+ data: { stats, projects }
808
805
  }
809
806
  } catch (err) {
810
807
  return { success: false, error: err.message }
@@ -160,7 +160,7 @@ class PluginManagerPlugin extends Plugin {
160
160
  const contents = await response.json();
161
161
 
162
162
  if (!Array.isArray(contents) || contents.length === 0) {
163
- return { success: true, plugins: [], message: 'No plugins found in repository' };
163
+ return { success: true, data: [], metadata: { message: 'No plugins found in repository' } };
164
164
  }
165
165
 
166
166
  const plugins = [];
@@ -198,9 +198,8 @@ class PluginManagerPlugin extends Plugin {
198
198
 
199
199
  return {
200
200
  success: true,
201
- plugins,
202
- repo,
203
- count: plugins.length,
201
+ data: plugins,
202
+ metadata: { repo, count: plugins.length },
204
203
  };
205
204
 
206
205
  } catch (err) {
@@ -303,8 +302,8 @@ class PluginManagerPlugin extends Plugin {
303
302
  if (!status.trim()) {
304
303
  return {
305
304
  success: true,
306
- message: `No changes to commit for plugin "${pluginName}"`,
307
- repo,
305
+ data: `No changes to commit for plugin "${pluginName}"`,
306
+ metadata: { repo },
308
307
  };
309
308
  }
310
309
 
@@ -315,9 +314,8 @@ class PluginManagerPlugin extends Plugin {
315
314
 
316
315
  return {
317
316
  success: true,
318
- message: `Plugin "${pluginName}" published successfully`,
319
- repo,
320
- path: `${pluginName}/${pluginName}.js`,
317
+ data: `Plugin "${pluginName}" published successfully`,
318
+ metadata: { repo, path: `${pluginName}/${pluginName}.js` },
321
319
  };
322
320
 
323
321
  } catch (err) {
@@ -387,8 +385,8 @@ class PluginManagerPlugin extends Plugin {
387
385
 
388
386
  return {
389
387
  success: true,
390
- message: `Plugin "${pluginName}" installed successfully`,
391
- path: targetDir,
388
+ data: `Plugin "${pluginName}" installed successfully`,
389
+ metadata: { path: targetDir },
392
390
  };
393
391
 
394
392
  } catch (err) {
@@ -175,7 +175,7 @@ class QQPlugin extends Plugin {
175
175
  // 降级为普通发送
176
176
  await this._client.sendC2CMessage({ openid, content })
177
177
  }
178
- return { success: true, message: '消息发送成功' }
178
+ return { success: true, data: '消息发送成功' }
179
179
  } catch (err) {
180
180
  log.error(`消息发送失败: ${err.message}`)
181
181
  return { error: err.message }
@@ -198,7 +198,7 @@ class QQPlugin extends Plugin {
198
198
  imageUrl,
199
199
  content,
200
200
  })
201
- return { success: true, message: '图片发送成功' }
201
+ return { success: true, data: '图片发送成功' }
202
202
  } catch (err) {
203
203
  log.error(`图片发送失败: ${err.message}`)
204
204
  return { error: err.message }
@@ -227,13 +227,13 @@ class QQPlugin extends Plugin {
227
227
  try {
228
228
  if (imageExts.includes(ext)) {
229
229
  await this._client.sendC2CLocalImageMessage({ openid, filePath, content })
230
- return { success: true, message: '图片发送成功' }
230
+ return { success: true, data: '图片发送成功' }
231
231
  } else if (voiceExts.includes(ext)) {
232
232
  await this._client.sendC2CLocalVoiceMessage({ openid, filePath })
233
- return { success: true, message: '语音发送成功' }
233
+ return { success: true, data: '语音发送成功' }
234
234
  } else if (videoExts.includes(ext)) {
235
235
  await this._client.sendC2CLocalVideoMessage({ openid, filePath, content })
236
- return { success: true, message: '视频发送成功' }
236
+ return { success: true, data: '视频发送成功' }
237
237
  } else {
238
238
  // 未知格式,当作文件处理
239
239
  return this._sendFile(openid, filePath, content)
@@ -263,7 +263,7 @@ class QQPlugin extends Plugin {
263
263
  filePath,
264
264
  content,
265
265
  })
266
- return { success: true, message: '文件发送成功' }
266
+ return { success: true, data: '文件发送成功' }
267
267
  } catch (err) {
268
268
  log.error(`文件发送失败: ${err.message}`)
269
269
  return { error: err.message }
@@ -285,7 +285,7 @@ class QQPlugin extends Plugin {
285
285
  groupOpenid,
286
286
  content,
287
287
  })
288
- return { success: true, message: '群消息发送成功' }
288
+ return { success: true, data: '群消息发送成功' }
289
289
  } catch (err) {
290
290
  log.error(`群消息发送失败: ${err.message}`)
291
291
  return { error: err.message }
@@ -311,7 +311,7 @@ class QQPlugin extends Plugin {
311
311
  filePath: imagePath,
312
312
  content,
313
313
  })
314
- return { success: true, message: '群图片发送成功' }
314
+ return { success: true, data: '群图片发送成功' }
315
315
  } catch (err) {
316
316
  log.error(`群图片发送失败: ${err.message}`)
317
317
  return { error: err.message }
@@ -919,7 +919,7 @@ class QQPlugin extends Plugin {
919
919
  for (const streamSession of this._streamSessions.values()) {
920
920
  try {
921
921
  streamSession.done?.()
922
- } catch {}
922
+ } catch (e) { /* streamSession.done 可能已完成 */ }
923
923
  }
924
924
  this._streamSessions.clear()
925
925
 
@@ -74,14 +74,14 @@ class RulesPlugin extends Plugin {
74
74
  execute: async () => {
75
75
  return {
76
76
  success: true,
77
- rules: this._rules.map(r => ({
77
+ data: this._rules.map(r => ({
78
78
  name: r.name,
79
79
  type: r.type,
80
80
  target: r.target,
81
81
  description: r.description,
82
82
  enabled: r.enabled
83
83
  })),
84
- total: this._rules.length
84
+ metadata: { total: this._rules.length }
85
85
  }
86
86
  }
87
87
  })
@@ -108,7 +108,7 @@ class RulesPlugin extends Plugin {
108
108
  enabled: true
109
109
  }
110
110
  this._rules.push(rule)
111
- return { success: true, rule: rule.name }
111
+ return { success: true, data: `规则已添加: ${rule.name}` }
112
112
  }
113
113
  })
114
114
 
@@ -124,7 +124,7 @@ class RulesPlugin extends Plugin {
124
124
  return { success: false, error: 'Rule not found' }
125
125
  }
126
126
  this._rules.splice(index, 1)
127
- return { success: true, removed: args.name }
127
+ return { success: true, data: `规则已移除: ${args.name}` }
128
128
  }
129
129
  })
130
130
 
@@ -135,7 +135,7 @@ class RulesPlugin extends Plugin {
135
135
  execute: async () => {
136
136
  return {
137
137
  success: true,
138
- stats: { ...this._ruleStats }
138
+ data: { ...this._ruleStats }
139
139
  }
140
140
  }
141
141
  })
@@ -151,8 +151,8 @@ class RulesPlugin extends Plugin {
151
151
  const result = this.evaluate(args.target, args.input || {})
152
152
  return {
153
153
  success: true,
154
- target: args.target,
155
- result: {
154
+ data: {
155
+ target: args.target,
156
156
  allowed: result.allowed,
157
157
  ruleName: result.rule?.name || null,
158
158
  ruleType: result.rule?.type || null
@@ -227,15 +227,17 @@ class SchedulerPlugin extends Plugin {
227
227
  this._saveTasks()
228
228
  return {
229
229
  success: true,
230
- taskId: task.id,
231
- name: task.name,
232
- type: 'shell',
233
- shell,
234
- scheduleTime,
235
- cronExpression: task.cronExpression,
236
- message: repeat ? 'Shell 定时任务已创建 (重复执行)' : 'Shell 任务已创建',
237
- sessionId: sessionId || 'default',
238
- notify: task.notify
230
+ data: repeat ? 'Shell 定时任务已创建 (重复执行)' : 'Shell 任务已创建',
231
+ metadata: {
232
+ taskId: task.id,
233
+ name: task.name,
234
+ type: 'shell',
235
+ shell,
236
+ scheduleTime,
237
+ cronExpression: task.cronExpression,
238
+ sessionId: sessionId || 'default',
239
+ notify: task.notify
240
+ }
239
241
  }
240
242
  } else {
241
243
  // 一次性 Shell 任务
@@ -276,15 +278,17 @@ class SchedulerPlugin extends Plugin {
276
278
  this._saveTasks()
277
279
  return {
278
280
  success: true,
279
- taskId: task.id,
280
- name: task.name,
281
- type: 'shell',
282
- shell,
283
- scheduleTime,
284
- executeAt: runAt.toISOString(),
285
- message: 'Shell 任务已创建',
286
- sessionId: sessionId || 'default',
287
- notify: task.notify
281
+ data: 'Shell 任务已创建',
282
+ metadata: {
283
+ taskId: task.id,
284
+ name: task.name,
285
+ type: 'shell',
286
+ shell,
287
+ scheduleTime,
288
+ executeAt: runAt.toISOString(),
289
+ sessionId: sessionId || 'default',
290
+ notify: task.notify
291
+ }
288
292
  }
289
293
  }
290
294
  }
@@ -173,8 +173,7 @@ class SessionPlugin extends Plugin {
173
173
  const session = this.createSession(sessionId, { metadata: args.metadata })
174
174
  return {
175
175
  success: true,
176
- sessionId: session.id,
177
- createdAt: session.createdAt
176
+ data: { sessionId: session.id, createdAt: session.createdAt }
178
177
  }
179
178
  }
180
179
  })
@@ -192,11 +191,13 @@ class SessionPlugin extends Plugin {
192
191
  }
193
192
  return {
194
193
  success: true,
195
- sessionId: session.id,
196
- messageCount: session.messages.length,
197
- variables: Object.keys(session.variables),
198
- createdAt: session.createdAt,
199
- lastActive: session.lastActive
194
+ data: {
195
+ sessionId: session.id,
196
+ messageCount: session.messages.length,
197
+ variables: Object.keys(session.variables),
198
+ createdAt: session.createdAt,
199
+ lastActive: session.lastActive
200
+ }
200
201
  }
201
202
  }
202
203
  })
@@ -209,8 +210,8 @@ class SessionPlugin extends Plugin {
209
210
  const sessions = this.listSessions()
210
211
  return {
211
212
  success: true,
212
- sessions,
213
- total: sessions.length
213
+ data: sessions,
214
+ metadata: { total: sessions.length }
214
215
  }
215
216
  }
216
217
  })
@@ -223,7 +224,7 @@ class SessionPlugin extends Plugin {
223
224
  }),
224
225
  execute: async (args) => {
225
226
  const deleted = this.deleteSession(args.sessionId)
226
- return { success: deleted, deleted: args.sessionId }
227
+ return { success: deleted, data: `会话 ${args.sessionId} 已${deleted ? '删除' : '删除失败'}` }
227
228
  }
228
229
  })
229
230
 
@@ -238,9 +239,8 @@ class SessionPlugin extends Plugin {
238
239
  const history = this.getHistory(args.sessionId, args.limit)
239
240
  return {
240
241
  success: true,
241
- sessionId: args.sessionId,
242
- messages: history,
243
- count: history.length
242
+ data: history,
243
+ metadata: { sessionId: args.sessionId, count: history.length }
244
244
  }
245
245
  }
246
246
  })
@@ -252,7 +252,7 @@ class SessionPlugin extends Plugin {
252
252
  execute: async () => {
253
253
  return {
254
254
  success: true,
255
- stats: this.getMemoryStats()
255
+ data: this.getMemoryStats()
256
256
  }
257
257
  }
258
258
  })