@ynhcj/xiaoyi-channel 0.0.38-beta → 0.0.38-release2026060602

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 (310) hide show
  1. package/dist/index.d.ts +2 -15
  2. package/dist/index.js +532 -10
  3. package/dist/plugin-scope/call_api.d.ts +2 -0
  4. package/dist/plugin-scope/call_api.js +107 -0
  5. package/dist/plugin-scope/config.d.ts +15 -0
  6. package/dist/plugin-scope/config.js +119 -0
  7. package/dist/plugin-scope/configs.json +10 -0
  8. package/dist/plugin-scope/constants.d.ts +105 -0
  9. package/dist/plugin-scope/constants.js +42 -0
  10. package/dist/plugin-scope/openclaw-install-guard.d.ts +2 -0
  11. package/dist/plugin-scope/openclaw-install-guard.js +87 -0
  12. package/dist/plugin-scope/skill_scope_hook.d.ts +18 -0
  13. package/dist/plugin-scope/skill_scope_hook.js +133 -0
  14. package/dist/plugin-scope/utils.d.ts +26 -0
  15. package/dist/plugin-scope/utils.js +346 -0
  16. package/dist/provider-discovery.d.ts +2 -0
  17. package/dist/provider-discovery.js +4 -0
  18. package/dist/src/acp-session-binding.d.ts +37 -0
  19. package/dist/src/acp-session-binding.js +237 -0
  20. package/dist/src/approval-bridge.d.ts +48 -0
  21. package/dist/src/approval-bridge.js +382 -0
  22. package/dist/src/channel.js +103 -28
  23. package/dist/src/compaction-provider.d.ts +54 -0
  24. package/dist/src/compaction-provider.js +316 -0
  25. package/dist/src/config-schema.d.ts +13 -0
  26. package/dist/src/config-schema.js +11 -0
  27. package/dist/src/config.js +7 -2
  28. package/dist/src/conversation/conversation-manager.d.ts +103 -0
  29. package/dist/src/conversation/conversation-manager.js +493 -0
  30. package/dist/src/conversation/conversation-session.d.ts +64 -0
  31. package/dist/src/conversation/conversation-session.js +23 -0
  32. package/dist/src/conversation/cron-buffer.d.ts +58 -0
  33. package/dist/src/conversation/cron-buffer.js +321 -0
  34. package/dist/src/conversation/outbound-gateway.d.ts +56 -0
  35. package/dist/src/conversation/outbound-gateway.js +110 -0
  36. package/dist/src/conversation/outbound-queue.d.ts +35 -0
  37. package/dist/src/conversation/outbound-queue.js +96 -0
  38. package/dist/src/conversation/steer-service.d.ts +29 -0
  39. package/dist/src/conversation/steer-service.js +52 -0
  40. package/dist/src/conversation/stream-assembler.d.ts +52 -0
  41. package/dist/src/conversation/stream-assembler.js +122 -0
  42. package/dist/src/cron-command.d.ts +17 -0
  43. package/dist/src/cron-command.js +33 -0
  44. package/dist/src/cron-query-handler.d.ts +27 -0
  45. package/dist/src/cron-query-handler.js +636 -0
  46. package/dist/src/cron-recovery.d.ts +25 -0
  47. package/dist/src/cron-recovery.js +587 -0
  48. package/dist/src/cron-scheduled-tasks-sync.d.ts +15 -0
  49. package/dist/src/cron-scheduled-tasks-sync.js +105 -0
  50. package/dist/src/cspl/call_api.d.ts +8 -0
  51. package/dist/src/cspl/call_api.js +158 -0
  52. package/dist/src/cspl/config.d.ts +15 -0
  53. package/dist/src/cspl/config.js +119 -0
  54. package/dist/src/cspl/configs.json +10 -0
  55. package/dist/src/cspl/constants.d.ts +106 -0
  56. package/dist/src/cspl/constants.js +75 -0
  57. package/dist/src/cspl/sentinel_hook.d.ts +2 -0
  58. package/dist/src/cspl/sentinel_hook.js +105 -0
  59. package/dist/src/cspl/skill_scope_hook.d.ts +17 -0
  60. package/dist/src/cspl/skill_scope_hook.js +125 -0
  61. package/dist/src/cspl/upload_file.d.ts +1 -0
  62. package/dist/src/cspl/upload_file.js +213 -0
  63. package/dist/src/cspl/utils.d.ts +46 -0
  64. package/dist/src/cspl/utils.js +465 -0
  65. package/dist/src/{bot.d.ts → dispatch/bot.d.ts} +6 -1
  66. package/dist/src/dispatch/bot.js +660 -0
  67. package/dist/src/dispatch/monitor.js +363 -0
  68. package/dist/src/{outbound.d.ts → dispatch/outbound.d.ts} +2 -1
  69. package/dist/src/dispatch/outbound.js +287 -0
  70. package/dist/src/{reply-dispatcher.d.ts → dispatch/reply-dispatcher.d.ts} +7 -1
  71. package/dist/src/dispatch/reply-dispatcher.js +706 -0
  72. package/dist/src/dynamic-skill-trigger.d.ts +8 -0
  73. package/dist/src/dynamic-skill-trigger.js +62 -0
  74. package/dist/src/file-download.d.ts +1 -0
  75. package/dist/src/file-download.js +3 -4
  76. package/dist/src/file-upload.d.ts +18 -0
  77. package/dist/src/file-upload.js +258 -17
  78. package/dist/src/formatter.d.ts +95 -1
  79. package/dist/src/formatter.js +326 -133
  80. package/dist/src/legacy/formatter.d.ts +188 -0
  81. package/dist/src/legacy/formatter.js +488 -0
  82. package/dist/src/legacy/keepalive.d.ts +17 -0
  83. package/dist/src/legacy/keepalive.js +119 -0
  84. package/dist/src/legacy/reply-dispatcher.d.ts +22 -0
  85. package/dist/src/legacy/reply-dispatcher.js +710 -0
  86. package/dist/src/legacy/types.d.ts +192 -0
  87. package/dist/src/legacy/types.js +6 -0
  88. package/dist/src/login-token-handler.d.ts +8 -0
  89. package/dist/src/login-token-handler.js +63 -0
  90. package/dist/src/memory-query-handler.d.ts +22 -0
  91. package/dist/src/memory-query-handler.js +448 -0
  92. package/dist/src/onboarding.d.ts +3 -4
  93. package/dist/src/onboarding.js +2 -2
  94. package/dist/src/parser.d.ts +33 -1
  95. package/dist/src/parser.js +135 -0
  96. package/dist/src/provider.d.ts +11 -0
  97. package/dist/src/provider.js +1075 -0
  98. package/dist/src/runtime.d.ts +3 -11
  99. package/dist/src/runtime.js +6 -18
  100. package/dist/src/self-evolution-handler.d.ts +7 -0
  101. package/dist/src/self-evolution-handler.js +149 -0
  102. package/dist/src/self-evolution-keyword.d.ts +9 -0
  103. package/dist/src/self-evolution-keyword.js +147 -0
  104. package/dist/src/self-evolution-tool-result-nudge.d.ts +3 -0
  105. package/dist/src/self-evolution-tool-result-nudge.js +96 -0
  106. package/dist/src/sensitive-redactor.d.ts +4 -0
  107. package/dist/src/sensitive-redactor.js +364 -0
  108. package/dist/src/skill-retriever/config.d.ts +4 -0
  109. package/dist/src/skill-retriever/config.js +25 -0
  110. package/dist/src/skill-retriever/hooks.d.ts +39 -0
  111. package/dist/src/skill-retriever/hooks.js +224 -0
  112. package/dist/src/skill-retriever/skill-status.d.ts +22 -0
  113. package/dist/src/skill-retriever/skill-status.js +125 -0
  114. package/dist/src/skill-retriever/tool-search.d.ts +21 -0
  115. package/dist/src/skill-retriever/tool-search.js +246 -0
  116. package/dist/src/skill-retriever/types.d.ts +38 -0
  117. package/dist/src/skill-retriever/types.js +1 -0
  118. package/dist/src/tool-status-hook.d.ts +7 -0
  119. package/dist/src/tool-status-hook.js +113 -0
  120. package/dist/src/tools/agent-as-skill-tool.d.ts +46 -0
  121. package/dist/src/tools/agent-as-skill-tool.js +183 -0
  122. package/dist/src/tools/ask-user-tool.d.ts +92 -0
  123. package/dist/src/tools/ask-user-tool.js +237 -0
  124. package/dist/src/tools/calendar-tool.d.ts +24 -1
  125. package/dist/src/tools/calendar-tool.js +10 -46
  126. package/dist/src/tools/call-device-tool.d.ts +20 -0
  127. package/dist/src/tools/call-device-tool.js +153 -0
  128. package/dist/src/tools/call-phone-tool.d.ts +20 -1
  129. package/dist/src/tools/call-phone-tool.js +16 -75
  130. package/dist/src/tools/check-plugin-privilege-tool.d.ts +20 -0
  131. package/dist/src/tools/check-plugin-privilege-tool.js +180 -0
  132. package/dist/src/tools/create-alarm-tool.d.ts +39 -1
  133. package/dist/src/tools/create-alarm-tool.js +18 -131
  134. package/dist/src/tools/cron-tool-guard.d.ts +12 -0
  135. package/dist/src/tools/cron-tool-guard.js +46 -0
  136. package/dist/src/tools/delete-alarm-tool.d.ts +15 -1
  137. package/dist/src/tools/delete-alarm-tool.js +14 -82
  138. package/dist/src/tools/device-tool-map.d.ts +4 -0
  139. package/dist/src/tools/device-tool-map.js +97 -0
  140. package/dist/src/tools/discover-cross-devices-tool.d.ts +16 -0
  141. package/dist/src/tools/discover-cross-devices-tool.js +232 -0
  142. package/dist/src/tools/display-a2ui-card-bypath-tool.d.ts +21 -0
  143. package/dist/src/tools/display-a2ui-card-bypath-tool.js +98 -0
  144. package/dist/src/tools/get-alarm-tool-schema.d.ts +16 -0
  145. package/dist/src/tools/get-alarm-tool-schema.js +11 -0
  146. package/dist/src/tools/get-calendar-tool-schema.d.ts +16 -0
  147. package/dist/src/tools/get-calendar-tool-schema.js +9 -0
  148. package/dist/src/tools/get-collection-tool-schema.d.ts +16 -0
  149. package/dist/src/tools/get-collection-tool-schema.js +10 -0
  150. package/dist/src/tools/get-contact-tool-schema.d.ts +16 -0
  151. package/dist/src/tools/get-contact-tool-schema.js +11 -0
  152. package/dist/src/tools/get-device-file-tool-schema.d.ts +16 -0
  153. package/dist/src/tools/get-device-file-tool-schema.js +10 -0
  154. package/dist/src/tools/get-email-tool-schema.d.ts +16 -0
  155. package/dist/src/tools/get-email-tool-schema.js +9 -0
  156. package/dist/src/tools/get-note-tool-schema.d.ts +16 -0
  157. package/dist/src/tools/get-note-tool-schema.js +10 -0
  158. package/dist/src/tools/get-photo-tool-schema.d.ts +16 -0
  159. package/dist/src/tools/get-photo-tool-schema.js +10 -0
  160. package/dist/src/tools/hmos-cli.d.ts +109 -0
  161. package/dist/src/tools/hmos-cli.js +558 -0
  162. package/dist/src/tools/image-reading-tool.d.ts +32 -0
  163. package/dist/src/tools/image-reading-tool.js +287 -0
  164. package/dist/src/tools/invoke.d.ts +88 -0
  165. package/dist/src/tools/invoke.js +1217 -0
  166. package/dist/src/tools/location-tool.d.ts +11 -1
  167. package/dist/src/tools/location-tool.js +17 -49
  168. package/dist/src/tools/login-token-tool.d.ts +24 -0
  169. package/dist/src/tools/login-token-tool.js +142 -0
  170. package/dist/src/tools/modify-alarm-tool.d.ts +47 -1
  171. package/dist/src/tools/modify-alarm-tool.js +41 -144
  172. package/dist/src/tools/modify-note-tool.d.ts +20 -1
  173. package/dist/src/tools/modify-note-tool.js +11 -50
  174. package/dist/src/tools/note-tool.d.ts +20 -1
  175. package/dist/src/tools/note-tool.js +12 -25
  176. package/dist/src/tools/query-app-message-tool.d.ts +31 -0
  177. package/dist/src/tools/query-app-message-tool.js +138 -0
  178. package/dist/src/tools/query-memory-data-tool.d.ts +31 -0
  179. package/dist/src/tools/query-memory-data-tool.js +154 -0
  180. package/dist/src/tools/query-todo-task-tool.d.ts +27 -0
  181. package/dist/src/tools/query-todo-task-tool.js +133 -0
  182. package/dist/src/tools/save-file-to-phone-tool.d.ts +28 -0
  183. package/dist/src/tools/save-file-to-phone-tool.js +165 -0
  184. package/dist/src/tools/save-media-to-gallery-tool.d.ts +28 -0
  185. package/dist/src/tools/save-media-to-gallery-tool.js +173 -0
  186. package/dist/src/tools/save-self-evolution-skill-tool.d.ts +54 -0
  187. package/dist/src/tools/save-self-evolution-skill-tool.js +410 -0
  188. package/dist/src/tools/schema-tool-factory.d.ts +27 -0
  189. package/dist/src/tools/schema-tool-factory.js +32 -0
  190. package/dist/src/tools/search-alarm-tool.d.ts +34 -1
  191. package/dist/src/tools/search-alarm-tool.js +26 -140
  192. package/dist/src/tools/search-calendar-tool.d.ts +24 -1
  193. package/dist/src/tools/search-calendar-tool.js +14 -90
  194. package/dist/src/tools/search-contact-tool.d.ts +16 -1
  195. package/dist/src/tools/search-contact-tool.js +10 -64
  196. package/dist/src/tools/search-email-tool.d.ts +25 -0
  197. package/dist/src/tools/search-email-tool.js +136 -0
  198. package/dist/src/tools/search-file-tool.d.ts +16 -1
  199. package/dist/src/tools/search-file-tool.js +17 -77
  200. package/dist/src/tools/search-message-tool.d.ts +16 -1
  201. package/dist/src/tools/search-message-tool.js +10 -67
  202. package/dist/src/tools/search-note-tool.d.ts +16 -1
  203. package/dist/src/tools/search-note-tool.js +12 -31
  204. package/dist/src/tools/search-photo-gallery-tool.d.ts +21 -1
  205. package/dist/src/tools/search-photo-gallery-tool.js +48 -70
  206. package/dist/src/tools/send-cross-device-task-tool.d.ts +35 -0
  207. package/dist/src/tools/send-cross-device-task-tool.js +365 -0
  208. package/dist/src/tools/send-email-tool.d.ts +27 -0
  209. package/dist/src/tools/send-email-tool.js +134 -0
  210. package/dist/src/tools/send-file-to-user-tool.d.ts +20 -1
  211. package/dist/src/tools/send-file-to-user-tool.js +53 -65
  212. package/dist/src/tools/send-html-card-tool.d.ts +25 -0
  213. package/dist/src/tools/send-html-card-tool.js +111 -0
  214. package/dist/src/tools/send-message-tool.d.ts +20 -1
  215. package/dist/src/tools/send-message-tool.js +14 -64
  216. package/dist/src/tools/session-manager.d.ts +47 -28
  217. package/dist/src/tools/session-manager.js +186 -132
  218. package/dist/src/tools/step-info-tool.d.ts +21 -0
  219. package/dist/src/tools/step-info-tool.js +421 -0
  220. package/dist/src/tools/timestamp-to-utc8-tool.d.ts +12 -0
  221. package/dist/src/tools/timestamp-to-utc8-tool.js +104 -0
  222. package/dist/src/tools/tool-visibility.d.ts +6 -0
  223. package/dist/src/tools/tool-visibility.js +15 -0
  224. package/dist/src/tools/upload-file-tool.d.ts +20 -1
  225. package/dist/src/tools/upload-file-tool.js +16 -65
  226. package/dist/src/tools/upload-photo-tool.d.ts +20 -1
  227. package/dist/src/tools/upload-photo-tool.js +14 -57
  228. package/dist/src/tools/view-push-result-tool.d.ts +5 -0
  229. package/dist/src/tools/view-push-result-tool.js +107 -0
  230. package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +35 -0
  231. package/dist/src/tools/xiaoyi-add-collection-tool.js +192 -0
  232. package/dist/src/tools/xiaoyi-append-reference.d.ts +47 -0
  233. package/dist/src/tools/xiaoyi-append-reference.js +107 -0
  234. package/dist/src/tools/xiaoyi-collection-tool.d.ts +24 -0
  235. package/dist/src/tools/xiaoyi-collection-tool.js +147 -0
  236. package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +18 -0
  237. package/dist/src/tools/xiaoyi-delete-collection-tool.js +162 -0
  238. package/dist/src/tools/xiaoyi-gui-tool.d.ts +16 -1
  239. package/dist/src/tools/xiaoyi-gui-tool.js +23 -44
  240. package/dist/src/{client.d.ts → transport/client.d.ts} +5 -4
  241. package/dist/src/transport/client.js +120 -0
  242. package/dist/src/{heartbeat.js → transport/heartbeat.js} +4 -7
  243. package/dist/src/transport/message-queue.d.ts +17 -0
  244. package/dist/src/transport/message-queue.js +52 -0
  245. package/dist/src/transport/push.d.ts +44 -0
  246. package/dist/src/transport/push.js +230 -0
  247. package/dist/src/{websocket.d.ts → transport/websocket.d.ts} +33 -33
  248. package/dist/src/transport/websocket.js +857 -0
  249. package/dist/src/trigger-handler.d.ts +22 -0
  250. package/dist/src/trigger-handler.js +55 -0
  251. package/dist/src/types.d.ts +34 -9
  252. package/dist/src/types.js +4 -0
  253. package/dist/src/update-task-conv-id-handler.d.ts +1 -0
  254. package/dist/src/update-task-conv-id-handler.js +54 -0
  255. package/dist/src/utils/app-version.d.ts +8 -0
  256. package/dist/src/utils/app-version.js +41 -0
  257. package/dist/src/utils/async-mutex.d.ts +5 -0
  258. package/dist/src/utils/async-mutex.js +14 -0
  259. package/dist/src/utils/body-text-state.d.ts +6 -0
  260. package/dist/src/utils/body-text-state.js +29 -0
  261. package/dist/src/utils/config-manager.d.ts +3 -2
  262. package/dist/src/utils/config-manager.js +25 -8
  263. package/dist/src/utils/cron-conv-map.d.ts +23 -0
  264. package/dist/src/utils/cron-conv-map.js +117 -0
  265. package/dist/src/utils/cron-push-map.d.ts +26 -0
  266. package/dist/src/utils/cron-push-map.js +139 -0
  267. package/dist/src/utils/cron-run-logger.d.ts +22 -0
  268. package/dist/src/utils/cron-run-logger.js +82 -0
  269. package/dist/src/utils/logger.d.ts +8 -0
  270. package/dist/src/utils/logger.js +214 -18
  271. package/dist/src/utils/pushdata-manager.d.ts +36 -0
  272. package/dist/src/utils/pushdata-manager.js +176 -0
  273. package/dist/src/utils/pushid-manager.d.ts +12 -0
  274. package/dist/src/utils/pushid-manager.js +104 -0
  275. package/dist/src/utils/reasoning-state.d.ts +8 -0
  276. package/dist/src/utils/reasoning-state.js +32 -0
  277. package/dist/src/utils/runtime-manager.d.ts +7 -0
  278. package/dist/src/utils/runtime-manager.js +61 -0
  279. package/dist/src/utils/self-evolution-manager.d.ts +10 -0
  280. package/dist/src/utils/self-evolution-manager.js +69 -0
  281. package/dist/src/utils/skills-logger.d.ts +5 -0
  282. package/dist/src/utils/skills-logger.js +76 -0
  283. package/dist/src/utils/status-card-seq.d.ts +11 -0
  284. package/dist/src/utils/status-card-seq.js +29 -0
  285. package/dist/src/utils/streaming-text-id.d.ts +23 -0
  286. package/dist/src/utils/streaming-text-id.js +53 -0
  287. package/dist/src/utils/think-index.d.ts +10 -0
  288. package/dist/src/utils/think-index.js +34 -0
  289. package/dist/src/utils/throw.d.ts +5 -0
  290. package/dist/src/utils/throw.js +10 -0
  291. package/dist/src/utils/tool-call-nudge-manager.d.ts +16 -0
  292. package/dist/src/utils/tool-call-nudge-manager.js +47 -0
  293. package/openclaw.plugin.json +26 -0
  294. package/package.json +13 -9
  295. package/dist/src/bot.js +0 -308
  296. package/dist/src/client.js +0 -147
  297. package/dist/src/monitor.js +0 -221
  298. package/dist/src/outbound.js +0 -222
  299. package/dist/src/push.d.ts +0 -23
  300. package/dist/src/push.js +0 -146
  301. package/dist/src/reply-dispatcher.js +0 -315
  302. package/dist/src/task-manager.d.ts +0 -55
  303. package/dist/src/task-manager.js +0 -136
  304. package/dist/src/tools/search-photo-tool.d.ts +0 -9
  305. package/dist/src/tools/search-photo-tool.js +0 -270
  306. package/dist/src/utils/session.d.ts +0 -34
  307. package/dist/src/utils/session.js +0 -50
  308. package/dist/src/websocket.js +0 -559
  309. /package/dist/src/{monitor.d.ts → dispatch/monitor.d.ts} +0 -0
  310. /package/dist/src/{heartbeat.d.ts → transport/heartbeat.d.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,16 +1,3 @@
1
- import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
2
- import { xyPlugin } from "./src/channel.js";
3
- /**
4
- * Xiaoyi Channel Plugin Entry Point.
5
- * Exports the plugin for OpenClaw to load.
6
- * Located at root level following feishu pattern for proper plugin registration.
7
- */
8
- declare const plugin: {
9
- id: string;
10
- name: string;
11
- description: string;
12
- configSchema: import("openclaw/plugin-sdk").OpenClawPluginConfigSchema;
13
- register(api: OpenClawPluginApi): void;
14
- };
1
+ import { type OpenClawPluginDefinition } from "openclaw/plugin-sdk/core";
2
+ declare const plugin: OpenClawPluginDefinition;
15
3
  export default plugin;
16
- export { xyPlugin };
package/dist/index.js CHANGED
@@ -1,21 +1,543 @@
1
- import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
1
+ import { definePluginEntry } from "openclaw/plugin-sdk/core";
2
+ import { xiaoyiProvider } from "./src/provider.js";
3
+ import { xiaoyiCompactionProvider } from "./src/compaction-provider.js";
2
4
  import { xyPlugin } from "./src/channel.js";
5
+ import registerSentinelHook from "./src/cspl/sentinel_hook.js";
6
+ import registerSkillScopeHook from "./src/cspl/skill_scope_hook.js";
3
7
  import { setXYRuntime } from "./src/runtime.js";
8
+ import { markCronToolCall, clearCronToolCall, getCurrentSessionContext, setCronToolRunInfo, clearCronToolRunInfo, isCronActive } from "./src/tools/session-manager.js";
9
+ import { parseCronJobIdFromSessionKey, registerCronToolGuard } from "./src/tools/cron-tool-guard.js";
10
+ import { configManager } from "./src/utils/config-manager.js";
11
+ import { setJobPushId } from "./src/utils/cron-push-map.js";
12
+ import { getAllPushIds } from "./src/utils/pushid-manager.js";
13
+ import { registerSelfEvolutionToolResultNudge } from "./src/self-evolution-tool-result-nudge.js";
14
+ import { createBeforePromptBuildHandler } from "./src/skill-retriever/hooks.js";
15
+ import { normalizeToolRetrieverConfig } from "./src/skill-retriever/config.js";
16
+ import { registerCLIHook } from "./src/tools/hmos-cli.js";
17
+ import { recoverCronState } from "./src/cron-recovery.js";
18
+ import { writeSkillUsage } from "./src/utils/skills-logger.js";
19
+ import { markSubagentSpawned, markSubagentEnded, deliverSubagentFinalResult, } from "./src/conversation/conversation-manager.js";
20
+ import { captureCronAssistantText, notifyCronAgentEnd } from "./src/conversation/cron-buffer.js";
21
+ import { logger } from "./src/utils/logger.js";
4
22
  /**
5
- * Xiaoyi Channel Plugin Entry Point.
6
- * Exports the plugin for OpenClaw to load.
7
- * Located at root level following feishu pattern for proper plugin registration.
23
+ * Parse a file path string to detect if it refers to a SKILL.md file within
24
+ * a skills directory. Returns the skill name (parent directory) if so.
25
+ *
26
+ * Matches paths like:
27
+ * ~/.openclaw/workspace/skills/my-skill/SKILL.md
28
+ * /home/user/core_skills/my-skill/SKILL.md
29
+ * skills/my-skill/SKILL.md
8
30
  */
9
- const plugin = {
31
+ function extractSkillNameFromPath(filePath) {
32
+ if (typeof filePath !== "string" || !filePath)
33
+ return null;
34
+ // Normalize common path prefixes
35
+ const normalized = filePath.replace(/^~\//, "/home/").replace(/\\/g, "/");
36
+ // Match: .../skills/<skillName>/SKILL.md or .../skills/<skillName>/...
37
+ // Also match: .../core_skills/<skillName>/SKILL.md
38
+ const match = normalized.match(/\/(?:core_)?skills\/([^/]+)\/SKILL\.md$/i);
39
+ return match ? match[1] : null;
40
+ }
41
+ /**
42
+ * Register the skills diagnostic event listener via after_tool_call hook.
43
+ *
44
+ * When openclaw fires a `skill.used` diagnostic event, the skill's SKILL.md
45
+ * is typically read by the model first. We detect SKILL.md reads through
46
+ * the `after_tool_call` hook and write the skill name to the skills log.
47
+ */
48
+ function registerSkillsDiagnosticHook(api) {
49
+ // Skill name → tool names mapping for direct tool-based skill usage logging
50
+ const SKILL_TOOLS = {
51
+ GetCurrentLocation: ["get_user_location"],
52
+ Schedule: ["create_calendar_event", "search_calendar_event"],
53
+ memorandum: ["create_note", "search_notes", "modify_note"],
54
+ gallery: ["search_photo_gallery", "save_media_to_gallery"],
55
+ contact: ["search_contact"],
56
+ file: ["search_file", "upload_file", "save_file_to_file_manager"],
57
+ clock: ["create_alarm", "delete_alarm", "search_alarm", "modify_alarm"],
58
+ message: ["search_message", "send_message"],
59
+ phone: ["call_phone"],
60
+ "xiaoyi-collection": ["add_collection", "query_collection", "delete_collection"],
61
+ "xiaoyi-image-understanding": ["image_reading"],
62
+ };
63
+ // Inverted to tool name → skill name for lookup
64
+ const TOOL_SKILL_MAP = Object.fromEntries(Object.entries(SKILL_TOOLS).flatMap(([skill, tools]) => tools.map((t) => [t, skill])));
65
+ // Resolve the actual tool name from call_device_tool wrapper.
66
+ // The model calls call_device_tool({ toolName: "...", arguments: {...} })
67
+ // — the real tool name is inside params, not event.toolName.
68
+ function resolveActualToolName(event) {
69
+ if (event.toolName === "call_device_tool") {
70
+ const inner = event.params?.toolName;
71
+ if (typeof inner === "string" && inner.length > 0)
72
+ return inner;
73
+ }
74
+ return event.toolName;
75
+ }
76
+ // Log skill usage for known device tools on before_tool_call
77
+ api.on("before_tool_call", async (event, _ctx) => {
78
+ const actualToolName = resolveActualToolName(event);
79
+ const skillName = TOOL_SKILL_MAP[actualToolName];
80
+ if (skillName) {
81
+ writeSkillUsage(skillName);
82
+ }
83
+ });
84
+ // Detect SKILL.md reads on after_tool_call (original behavior)
85
+ api.on("after_tool_call", async (event, _ctx) => {
86
+ if (event.toolName === "read") {
87
+ const skillName = extractSkillNameFromPath(event.params?.path);
88
+ if (skillName) {
89
+ writeSkillUsage(skillName);
90
+ }
91
+ }
92
+ });
93
+ }
94
+ /**
95
+ * Register the cron detection hook.
96
+ *
97
+ * When openclaw's cron runner triggers a tool call, the sessionKey has the
98
+ * format "cron:<jobId>"(或 agent 展开后的 `agent:<id>:cron:<jobId>:run:<ts>`)。
99
+ * We use this to mark the toolCallId in a global Map
100
+ * so that sendCommand() can route the command through the push channel
101
+ * instead of the (non-existent) WebSocket session.
102
+ */
103
+ function registerCronDetectionHook(api) {
104
+ api.on("before_tool_call", async (event, ctx) => {
105
+ // sessionKey 前缀依赖 openclaw 版本行为,不一定可靠;isCronActive(jobId)
106
+ // 按 jobId 精确判断(provider 已从消息 [cron:...] 标记过该 job),替代
107
+ // 原先的全局 120s 时间戳,避免把普通对话/其它 job 的工具调用误判为 cron。
108
+ const sessionKey = ctx.sessionKey ?? "";
109
+ const sessionJobId = parseCronJobIdFromSessionKey(sessionKey);
110
+ if ((sessionKey.includes("cron:") || isCronActive(sessionJobId)) && event.toolCallId) {
111
+ markCronToolCall(event.toolCallId);
112
+ // 存储 runId,供 call_device_tool 在 ALS 缺失时构造合成 SessionContext
113
+ if (event.runId) {
114
+ setCronToolRunInfo(event.toolCallId, event.runId);
115
+ }
116
+ }
117
+ });
118
+ api.on("after_tool_call", async (event, ctx) => {
119
+ if (event.toolCallId) {
120
+ clearCronToolCall(event.toolCallId);
121
+ clearCronToolRunInfo(event.toolCallId);
122
+ }
123
+ // 捕获对话创建的 cron job:agent 调 cron(add) 后,从 result 拿 jobId,
124
+ // 配合当前会话的 pushId,写入 jobId↔pushId 映射,供 fire 时反查设备。
125
+ await captureCronAddMapping(event, ctx).catch((err) => {
126
+ // 捕获失败不影响工具结果
127
+ console.error("[xy] captureCronAddMapping failed:", err);
128
+ });
129
+ });
130
+ }
131
+ /** 从 cron add 工具结果中提取 jobId 并写入 pushId 映射。 */
132
+ async function captureCronAddMapping(event, ctx) {
133
+ // 两条创建路径都要捕获:
134
+ // 1) cron agent 工具:toolName==="cron", params.action==="add"
135
+ // 2) exec 跑 CLI:toolName==="exec", params.command 含 "cron add"
136
+ // (agent 实际用的是这条:openclaw cron add --name ... --cron ... --message ...)
137
+ const isCronAddTool = event.toolName === "cron" &&
138
+ (event.params?.action === "add" || event.params?.action === "create");
139
+ const isExecCronAdd = event.toolName === "exec" && isExecCronAddCommand(event.params?.command);
140
+ if (!isCronAddTool && !isExecCronAdd)
141
+ return;
142
+ console.log(`[CRONMAP] after_tool_call path=${event.toolName}, resultType=${typeof event.result}`);
143
+ const jobId = readJobIdFromResult(event.result);
144
+ if (!jobId) {
145
+ console.log(`[CRONMAP] skip: could not extract jobId. preview=${preview(event.result)}`);
146
+ return;
147
+ }
148
+ console.log(`[CRONMAP] extracted jobId=${jobId}`);
149
+ const sessionCtx = getCurrentSessionContext();
150
+ const sessionId = sessionCtx?.sessionId;
151
+ if (!sessionId) {
152
+ console.log(`[CRONMAP] skip: no sessionId in ALS scope (ctxFound=${!!sessionCtx})`);
153
+ return;
154
+ }
155
+ const pushId = await resolvePushId(sessionId);
156
+ if (!pushId) {
157
+ console.log(`[CRONMAP] skip: no pushId available for sessionId=${sessionId} (no session match, no global, no file)`);
158
+ return;
159
+ }
160
+ console.log(`[CRONMAP] writing map: jobId=${jobId}, sessionId=${sessionId}, pushId=${pushId.substring(0, 16)}...`);
161
+ await setJobPushId(jobId, {
162
+ pushId,
163
+ sessionId,
164
+ deviceType: sessionCtx?.deviceType,
165
+ source: event.toolName === "exec" ? "exec-cli" : "conversation",
166
+ });
167
+ console.log(`[CRONMAP] map written OK`);
168
+ }
169
+ /** 回退链取 pushId:当前会话 → 全局兜底 → 本地文件首个(保底)。 */
170
+ async function resolvePushId(sessionId) {
171
+ // 1. 同会话
172
+ const session = configManager.getPushId(sessionId);
173
+ if (session)
174
+ return session;
175
+ // 2. 全局(任何会话注册过的)
176
+ const global = configManager.getPushId();
177
+ if (global)
178
+ return global;
179
+ // 3. 文件兜底
180
+ try {
181
+ const all = await getAllPushIds();
182
+ if (all.length > 0)
183
+ return all[0];
184
+ }
185
+ catch {
186
+ // ignore
187
+ }
188
+ return null;
189
+ }
190
+ /** 判断 exec 命令是否为 cron add(匹配 "openclaw cron add" 或裸 "cron add",排除 list/remove 等)。 */
191
+ function isExecCronAddCommand(command) {
192
+ if (typeof command !== "string")
193
+ return false;
194
+ return /\bcron\s+add\b/.test(command);
195
+ }
196
+ /** 取结果的短预览,用于诊断。 */
197
+ function preview(value) {
198
+ if (value == null)
199
+ return String(value);
200
+ const s = typeof value === "string" ? value : JSON.stringify(value);
201
+ return s.length > 200 ? s.slice(0, 200) + "…" : s;
202
+ }
203
+ /** 防御性地从 cron add 结果中取 job id。
204
+ * 覆盖:裸 job 对象、JSON 字符串、exec 输出文本、
205
+ * {content:[{text}]} / {stdout} / data/result/job 嵌套。 */
206
+ function readJobIdFromResult(result) {
207
+ if (!result)
208
+ return undefined;
209
+ // {content: [{type:"text", text: "..."}]} — exec 工具的输出信封
210
+ if (result && typeof result === "object") {
211
+ const contentArr = result.content;
212
+ if (Array.isArray(contentArr)) {
213
+ for (const item of contentArr) {
214
+ if (item && typeof item === "object") {
215
+ const text = item.text;
216
+ if (typeof text === "string" && text.trim()) {
217
+ const fromContent = readJobIdFromResult(text);
218
+ if (fromContent)
219
+ return fromContent;
220
+ }
221
+ }
222
+ }
223
+ }
224
+ }
225
+ // {stdout} — 备选 exec 输出信封
226
+ if (result && typeof result === "object") {
227
+ const stdout = result.stdout;
228
+ if (typeof stdout === "string" && stdout.trim()) {
229
+ const fromStdout = readJobIdFromResult(stdout);
230
+ if (fromStdout)
231
+ return fromStdout;
232
+ }
233
+ }
234
+ let obj = result;
235
+ if (typeof result === "string") {
236
+ try {
237
+ obj = JSON.parse(result);
238
+ }
239
+ catch {
240
+ // 纯文本:可能含 stderr 前缀行 + JSON。用正则抓 "id":"..."。
241
+ const m = result.match(/"id"\s*:\s*"([^"]+)"/);
242
+ if (m)
243
+ return m[1];
244
+ return undefined;
245
+ }
246
+ }
247
+ if (obj && typeof obj === "object") {
248
+ const id = obj.id;
249
+ if (typeof id === "string" && id.trim())
250
+ return id.trim();
251
+ for (const k of ["data", "result", "job"]) {
252
+ const inner = obj[k];
253
+ if (inner && typeof inner === "object") {
254
+ const innerId = inner.id;
255
+ if (typeof innerId === "string" && innerId.trim())
256
+ return innerId.trim();
257
+ }
258
+ }
259
+ }
260
+ return undefined;
261
+ }
262
+ // ── Gateway startup: cron state recovery ────────────────────────────────────
263
+ /**
264
+ * Register the gateway_start hook for cron state recovery.
265
+ *
266
+ * On gateway startup, checks .openclaw/cron/ for legacy JSON/JSONL files
267
+ * and migrates them into the SQLite state database:
268
+ * - Reads legacy jobs.json + jobs-state.json → imports into cron_jobs table
269
+ * - Reads legacy runs/*.jsonl → imports into cron_run_logs table
270
+ * - Archives migrated files with .migrated suffix
271
+ *
272
+ * Pattern follows legacy-store-migration.ts and legacy-run-log-migration.ts:
273
+ * check → load → import into SQLite → archive old files.
274
+ */
275
+ function registerCronRecoveryHook(api) {
276
+ api.on("gateway_start", async (_event, _ctx) => {
277
+ const logTag = "[CRON-RECOVERY-HOOK]";
278
+ const startTime = Date.now();
279
+ logger.log(`${logTag} ═══════════════════════════════════════════`);
280
+ logger.log(`${logTag} gateway_start fired — checking for legacy cron files`);
281
+ logger.log(`${logTag} Timestamp: ${new Date().toISOString()}`);
282
+ logger.log(`${logTag} Plugin registration mode: ${api.registrationMode ?? "unknown"}`);
283
+ let result;
284
+ try {
285
+ result = await recoverCronState();
286
+ }
287
+ catch (err) {
288
+ const errMsg = err instanceof Error ? err.message : String(err);
289
+ const errStack = err instanceof Error ? err.stack : undefined;
290
+ logger.error(`${logTag} cron state recovery threw: ${errMsg}`);
291
+ if (errStack)
292
+ logger.error(`${logTag} Stack: ${errStack}`);
293
+ // Don't let a recovery failure block gateway startup.
294
+ logger.log(`${logTag} Recovery failed after ${Date.now() - startTime}ms — gateway startup continues`);
295
+ return;
296
+ }
297
+ const elapsed = Date.now() - startTime;
298
+ if (result.recovered) {
299
+ logger.log(`${logTag} ✅ Migration performed successfully in ${elapsed}ms:` +
300
+ ` storeMigrated=${result.storeMigrated}, ` +
301
+ ` runLogFilesImported=${result.runLogFilesImported}`);
302
+ }
303
+ else {
304
+ logger.log(`${logTag} ℹ️ No legacy cron files migrated in ${elapsed}ms ` +
305
+ `(nothing to migrate or database unavailable)`);
306
+ }
307
+ // Log diagnostics summary
308
+ const warnings = result.diagnostics.filter((d) => d.includes("skipping") || d.includes("locked") || d.includes("unavailable"));
309
+ const errors = result.diagnostics.filter((d) => d.includes("error") || d.includes("failed") || d.includes("Failed"));
310
+ if (warnings.length > 0) {
311
+ logger.warn(`${logTag} ${warnings.length} warning(s) from migration:`);
312
+ for (const w of warnings) {
313
+ logger.warn(`${logTag} ⚠ ${w}`);
314
+ }
315
+ }
316
+ if (errors.length > 0) {
317
+ logger.error(`${logTag} ${errors.length} error(s) from migration:`);
318
+ for (const e of errors) {
319
+ logger.error(`${logTag} ✗ ${e}`);
320
+ }
321
+ }
322
+ if (warnings.length === 0 && errors.length === 0) {
323
+ logger.log(`${logTag} All diagnostics clean, no warnings or errors`);
324
+ }
325
+ logger.log(`${logTag} ═══════════════════════════════════════════`);
326
+ });
327
+ }
328
+ /**
329
+ * 从 sessions_spawn 工具结果中提取 ACP child sessionKey。
330
+ * 兼容三种 result 形态:{status, childSessionKey} 直返、JSON 字符串、
331
+ * {content:[{text: "<json>"}], details:{...}} 工具信封。
332
+ * 仅接受 status="accepted" 且 key 形如 agent:<id>:acp:<uuid> 的结果。
333
+ */
334
+ function extractAcceptedAcpChildSessionKey(result) {
335
+ const pick = (obj) => {
336
+ if (!obj || typeof obj !== "object")
337
+ return null;
338
+ const record = obj;
339
+ if (record.status !== "accepted")
340
+ return null;
341
+ const key = record.childSessionKey;
342
+ return typeof key === "string" && key.includes(":acp:") ? key : null;
343
+ };
344
+ const direct = pick(result);
345
+ if (direct)
346
+ return direct;
347
+ const envelope = result;
348
+ const fromDetails = pick(envelope?.details);
349
+ if (fromDetails)
350
+ return fromDetails;
351
+ if (Array.isArray(envelope?.content)) {
352
+ for (const item of envelope.content) {
353
+ if (typeof item?.text !== "string")
354
+ continue;
355
+ try {
356
+ const fromText = pick(JSON.parse(item.text));
357
+ if (fromText)
358
+ return fromText;
359
+ }
360
+ catch {
361
+ // 非 JSON 文本,忽略
362
+ }
363
+ }
364
+ }
365
+ if (typeof result === "string") {
366
+ try {
367
+ return pick(JSON.parse(result));
368
+ }
369
+ catch {
370
+ return null;
371
+ }
372
+ }
373
+ return null;
374
+ }
375
+ function registerSubagentHooks(api) {
376
+ // subagent_spawned: fires after a subagent run is successfully registered.
377
+ // We increment the expected completion count so that onIdle knows to wait.
378
+ api.on("subagent_spawned", async (_event, ctx) => {
379
+ const requesterSessionKey = ctx?.requesterSessionKey;
380
+ if (!requesterSessionKey)
381
+ return;
382
+ const count = markSubagentSpawned(requesterSessionKey);
383
+ if (count > 0) {
384
+ logger.log(`[XY-SUBAGENT] spawned, requesterSessionKey=${requesterSessionKey.slice(0, 30)}, expected=${count}`);
385
+ }
386
+ });
387
+ // ACP SPAWN TRACKING: openclaw 的 subagent_spawned hook 仅由内嵌 subagent
388
+ // 路径(subagent-spawn.ts)发射;acp-spawn.ts(runtime="acp",如 Claude Code)
389
+ // 不发射 —— 实测 ACP run 仅在结束时经 run registry 触发 subagent_ended,
390
+ // 导致等待态从未建立、父 turn onIdle 直接发 final 结束对话。
391
+ // 因此在 after_tool_call 补记:sessions_spawn 成功且 childSessionKey 为 ACP
392
+ // 形态时递增等待计数。内嵌 subagent 的 childKey 形如 agent:<id>:subagent:<id>,
393
+ // 不命中此分支,仍由 subagent_spawned hook 负责,不会重复计数。
394
+ api.on("after_tool_call", async (event, ctx) => {
395
+ try {
396
+ if (event?.toolName !== "sessions_spawn" || event?.error)
397
+ return;
398
+ const childKey = extractAcceptedAcpChildSessionKey(event?.result);
399
+ if (!childKey)
400
+ return;
401
+ const sessionKey = ctx?.sessionKey;
402
+ if (!sessionKey)
403
+ return;
404
+ const count = markSubagentSpawned(sessionKey);
405
+ if (count > 0) {
406
+ logger.log(`[XY-SUBAGENT] ACP spawned, childSessionKey=${childKey.slice(0, 40)}, expected=${count}`);
407
+ }
408
+ }
409
+ catch (err) {
410
+ logger.error(`[XY-SUBAGENT] Error tracking ACP spawn:`, err);
411
+ }
412
+ });
413
+ // subagent_ended: fires when a subagent run terminates (complete/error/killed).
414
+ // This is the PRIMARY delivery tracking mechanism. When all expected
415
+ // subagents have ended and parent has settled, we finalize the A2A session.
416
+ api.on("subagent_ended", async (event, ctx) => {
417
+ try {
418
+ const requesterSessionKey = ctx?.requesterSessionKey;
419
+ if (!requesterSessionKey) {
420
+ logger.log(`[XY-SUBAGENT-END] no requesterSessionKey in ctx`);
421
+ return;
422
+ }
423
+ const transition = markSubagentEnded(requesterSessionKey);
424
+ logger.log(`[XY-SUBAGENT-END] ended, targetSessionKey=${event?.targetSessionKey?.slice(0, 30)}, outcome=${event?.outcome}, complete=${transition?.isComplete ?? false}, shouldFinalize=${transition?.shouldFinalize ?? false}, transition=${!!transition}`);
425
+ if (transition?.shouldFinalize) {
426
+ logger.log(`[XY-SUBAGENT-END] Starting finalization...`);
427
+ // Grace: announce 投递的 sendText 与 subagent_ended hook 并发到达
428
+ // (实测 sendText 可能先于 hook 约 1s,也可能晚于 hook;长文本还会
429
+ // 被 textChunkLimit 分片成多次 sendText)。捕获窗口直到
430
+ // finalDeliveryStarted 才关闭,此处的等待直接扩大迟到来片的入窗机会。
431
+ await new Promise((r) => setTimeout(r, 3000));
432
+ // 最终交付由对话管理层统一负责(含 config 解析、final 帧、清理)
433
+ await deliverSubagentFinalResult({
434
+ state: transition.state,
435
+ reason: "all-subagents-ended-after-parent-settled",
436
+ });
437
+ logger.log(`[XY-SUBAGENT-END] Finalized A2A session after all subagents ended`);
438
+ }
439
+ }
440
+ catch (err) {
441
+ logger.error(`[XY-SUBAGENT-END] Error in subagent_ended hook:`, err);
442
+ }
443
+ });
444
+ }
445
+ function registerFullHooks(api) {
446
+ // SUBAGENT HOOKS: track subagent spawn/end lifecycle for session keep-alive
447
+ registerSubagentHooks(api);
448
+ // CRON AGGREGATION: 通过 agent 事件总线收集 cron isolated run 的每轮
449
+ // assistant 正文并感知结束。announce 只携带最后一条 assistant 文本,正文后
450
+ // 若还有工具调用/补充说明,仅监听 sendText 会丢失前序正文。
451
+ // 注意:agent_end 插件 hook 只在 dispatch-from-config 路径触发,cron
452
+ // isolated run 不会触发它;embedded run 的 lifecycle 事件才是可靠信号。
453
+ api.agent.events.registerAgentEventSubscription({
454
+ id: "xy-cron-turn-tracker",
455
+ description: "Aggregate cron assistant text and track run completion",
456
+ streams: ["lifecycle", "assistant"],
457
+ handle: (event) => {
458
+ try {
459
+ const sessionKey = event?.sessionKey ?? "";
460
+ // 从 sessionKey(agent:<id>:cron:<jobId>:run:<ts>)解析 jobId,只处理
461
+ // 该 job 的 turn;isCronActive(jobId) 作为无 cron 前缀版本的兜底(按
462
+ // jobId 精确判断,普通对话的 assistant/lifecycle 不会命中)。
463
+ const cronJobId = parseCronJobIdFromSessionKey(sessionKey);
464
+ if (!sessionKey.includes("cron:") && !sessionKey.startsWith("cron:") && !isCronActive(cronJobId))
465
+ return;
466
+ if (event.stream === "assistant") {
467
+ captureCronAssistantText(cronJobId, typeof event.data?.text === "string" ? event.data.text : undefined, event.data?.replace === true);
468
+ return;
469
+ }
470
+ // 仅 phase=end 是 run 级终态信号;phase=error 可能是单次模型调用
471
+ // 失败(后续还有重试/start),不能据此放行 announce。
472
+ // 真正失败的 run(无 end)由 120s 安全超时兜底 flush 缓冲文本。
473
+ if (event.stream !== "lifecycle" || event?.data?.phase !== "end")
474
+ return;
475
+ logger.log(`[XY-CRON] Cron run lifecycle end, sessionKey=${sessionKey || "unknown"}, jobId=${cronJobId ?? "-"}`);
476
+ notifyCronAgentEnd(cronJobId);
477
+ }
478
+ catch (err) {
479
+ logger.error(`[XY-CRON] Error in cron event subscription:`, err);
480
+ }
481
+ },
482
+ });
483
+ // SKILL RETRIEVER HOOK: before_prompt_build hook
484
+ const pluginConfig = api.pluginConfig || {};
485
+ const skillRetrieverConfig = normalizeToolRetrieverConfig({
486
+ enabled: pluginConfig.skillRetrieverEnabled ?? true,
487
+ maxTools: pluginConfig.skillRetrieverMaxTools ?? 6,
488
+ includeUninstalledOnly: true,
489
+ envFilePath: "~/.openclaw/.xiaoyienv",
490
+ timeoutMs: pluginConfig.skillRetrieverTimeoutMs ?? 10000,
491
+ });
492
+ const beforePromptBuildHandler = createBeforePromptBuildHandler(skillRetrieverConfig);
493
+ api.on("before_prompt_build", async (event, ctx) => {
494
+ logger.log(`[BEFORE_PROMPT_BUILD] hook fired, sessionKey=${ctx.sessionKey || "undefined"}, sessionId=${ctx.sessionId || "undefined"}`);
495
+ return beforePromptBuildHandler(event, ctx);
496
+ });
497
+ registerSelfEvolutionToolResultNudge(api);
498
+ }
499
+ const plugin = definePluginEntry({
10
500
  id: "xiaoyi-channel",
11
501
  name: "Xiaoyi Channel",
12
502
  description: "Xiaoyi channel plugin - Xiaoyi A2A protocol integration",
13
- configSchema: emptyPluginConfigSchema(),
14
503
  register(api) {
15
- setXYRuntime(api.runtime);
504
+ // Always register the provider so wrapStreamFn/prepareExtraParams work
505
+ // in ALL registration modes (not just "full").
506
+ api.registerProvider(xiaoyiProvider);
507
+ // Register the compaction provider so openclaw's safeguard hook uses
508
+ // our summarization path (which injects x-hag-trace-id) instead of the
509
+ // built-in LLM path that bypasses wrapStreamFn.
510
+ api.registerCompactionProvider(xiaoyiCompactionProvider);
511
+ if (api.registrationMode === "cli-metadata") {
512
+ return;
513
+ }
514
+ if (api.registrationMode === "tool-discovery") {
515
+ registerFullHooks(api);
516
+ return;
517
+ }
518
+ // Register channel plugin and set runtime
16
519
  api.registerChannel({ plugin: xyPlugin });
520
+ setXYRuntime(api.runtime);
521
+ if (api.registrationMode === "discovery") {
522
+ return;
523
+ }
524
+ if (api.registrationMode === "full") {
525
+ registerFullHooks(api);
526
+ // CSPL sentinel hook: before_tool_call + after_tool_call security scanning
527
+ registerSentinelHook(api);
528
+ // CSPL skill scope hook: before_install security scanning
529
+ registerSkillScopeHook(api);
530
+ // Cron tool guard: rejects unsupported tools before they can produce side effects
531
+ registerCronToolGuard(api);
532
+ // Cron detection hook: marks toolCallIds from cron sessions
533
+ registerCronDetectionHook(api);
534
+ // CLI exec hook: intercepts built-in exec for HarmonyOS CLI skill tools
535
+ registerCLIHook(api);
536
+ // Cron recovery hook: prunes stale cron-push-map and pushData on gateway startup
537
+ registerCronRecoveryHook(api);
538
+ // Skills diagnostic hook: log skill usage (detected via SKILL.md reads)
539
+ registerSkillsDiagnosticHook(api);
540
+ }
17
541
  },
18
- };
542
+ });
19
543
  export default plugin;
20
- // Also export the plugin directly for testing
21
- export { xyPlugin };
@@ -0,0 +1,2 @@
1
+ import { ApiResponse } from './constants.js';
2
+ export declare function callSkillScanApi(url_suffix: string, payload: object, api: any, sessionId: string): Promise<ApiResponse>;