@ynhcj/xiaoyi-channel 0.0.6-next → 0.0.6-release20260606

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 (262) hide show
  1. package/dist/index.d.ts +3 -16
  2. package/dist/index.js +293 -11
  3. package/dist/provider-discovery.d.ts +2 -0
  4. package/dist/provider-discovery.js +4 -0
  5. package/dist/src/acp-session-binding.d.ts +37 -0
  6. package/dist/src/acp-session-binding.js +237 -0
  7. package/dist/src/approval-bridge.d.ts +48 -0
  8. package/dist/src/approval-bridge.js +382 -0
  9. package/dist/src/bot.d.ts +9 -0
  10. package/dist/src/bot.js +375 -157
  11. package/dist/src/channel.js +100 -23
  12. package/dist/src/client.d.ts +4 -3
  13. package/dist/src/client.js +32 -46
  14. package/dist/src/cron-command.d.ts +17 -0
  15. package/dist/src/cron-command.js +55 -0
  16. package/dist/src/cron-query-handler.d.ts +7 -0
  17. package/dist/src/cron-query-handler.js +345 -0
  18. package/dist/src/cron-recovery.d.ts +23 -0
  19. package/dist/src/cron-recovery.js +619 -0
  20. package/dist/src/cspl/call-api.d.ts +9 -0
  21. package/dist/src/cspl/call-api.js +110 -0
  22. package/dist/src/cspl/call_api.d.ts +7 -0
  23. package/dist/src/cspl/call_api.js +103 -0
  24. package/dist/src/cspl/config.d.ts +15 -0
  25. package/dist/src/cspl/config.js +119 -0
  26. package/dist/src/cspl/configs.json +10 -0
  27. package/dist/src/cspl/constants.d.ts +105 -0
  28. package/dist/src/cspl/constants.js +73 -0
  29. package/dist/src/cspl/middleware.d.ts +8 -0
  30. package/dist/src/cspl/middleware.js +90 -0
  31. package/dist/src/cspl/sentinel_hook.d.ts +2 -0
  32. package/dist/src/cspl/sentinel_hook.js +108 -0
  33. package/dist/src/cspl/steer-context.d.ts +21 -0
  34. package/dist/src/cspl/steer-context.js +78 -0
  35. package/dist/src/cspl/upload_file.d.ts +1 -0
  36. package/dist/src/cspl/upload_file.js +210 -0
  37. package/dist/src/cspl/utils.d.ts +37 -0
  38. package/dist/src/cspl/utils.js +359 -0
  39. package/dist/src/file-download.js +2 -4
  40. package/dist/src/file-upload.d.ts +10 -0
  41. package/dist/src/file-upload.js +249 -17
  42. package/dist/src/formatter.d.ts +59 -1
  43. package/dist/src/formatter.js +265 -82
  44. package/dist/src/heartbeat.js +4 -7
  45. package/dist/src/log-reporter/config-loader.d.ts +11 -0
  46. package/dist/src/log-reporter/config-loader.js +68 -0
  47. package/dist/src/log-reporter/cursor-store.d.ts +5 -0
  48. package/dist/src/log-reporter/cursor-store.js +26 -0
  49. package/dist/src/log-reporter/index.d.ts +10 -0
  50. package/dist/src/log-reporter/index.js +206 -0
  51. package/dist/src/log-reporter/openclaw-parser.d.ts +18 -0
  52. package/dist/src/log-reporter/openclaw-parser.js +94 -0
  53. package/dist/src/log-reporter/path-resolver.d.ts +5 -0
  54. package/dist/src/log-reporter/path-resolver.js +50 -0
  55. package/dist/src/log-reporter/reporter.d.ts +6 -0
  56. package/dist/src/log-reporter/reporter.js +56 -0
  57. package/dist/src/log-reporter/scanner.d.ts +10 -0
  58. package/dist/src/log-reporter/scanner.js +78 -0
  59. package/dist/src/log-reporter/types.d.ts +58 -0
  60. package/dist/src/log-reporter/types.js +2 -0
  61. package/dist/src/log-reporter/uploader.d.ts +7 -0
  62. package/dist/src/log-reporter/uploader.js +55 -0
  63. package/dist/src/login-token-handler.d.ts +8 -0
  64. package/dist/src/login-token-handler.js +63 -0
  65. package/dist/src/memory-query-handler.d.ts +1 -0
  66. package/dist/src/memory-query-handler.js +283 -0
  67. package/dist/src/message-queue.d.ts +17 -0
  68. package/dist/src/message-queue.js +52 -0
  69. package/dist/src/monitor.js +186 -57
  70. package/dist/src/onboarding.d.ts +3 -4
  71. package/dist/src/onboarding.js +2 -2
  72. package/dist/src/outbound.d.ts +2 -1
  73. package/dist/src/outbound.js +66 -35
  74. package/dist/src/parser.d.ts +33 -1
  75. package/dist/src/parser.js +135 -0
  76. package/dist/src/provider.d.ts +3 -0
  77. package/dist/src/provider.js +693 -0
  78. package/dist/src/push.d.ts +19 -2
  79. package/dist/src/push.js +128 -56
  80. package/dist/src/reply-dispatcher.d.ts +10 -1
  81. package/dist/src/reply-dispatcher.js +322 -168
  82. package/dist/src/runtime.d.ts +3 -11
  83. package/dist/src/runtime.js +6 -18
  84. package/dist/src/self-evolution-handler.d.ts +7 -0
  85. package/dist/src/self-evolution-handler.js +149 -0
  86. package/dist/src/self-evolution-keyword.d.ts +9 -0
  87. package/dist/src/self-evolution-keyword.js +147 -0
  88. package/dist/src/self-evolution-tool-result-nudge.d.ts +3 -0
  89. package/dist/src/self-evolution-tool-result-nudge.js +96 -0
  90. package/dist/src/sensitive-redactor.d.ts +4 -0
  91. package/dist/src/sensitive-redactor.js +364 -0
  92. package/dist/src/skill-retriever/config.d.ts +4 -0
  93. package/dist/src/skill-retriever/config.js +25 -0
  94. package/dist/src/skill-retriever/hooks.d.ts +22 -0
  95. package/dist/src/skill-retriever/hooks.js +83 -0
  96. package/dist/src/skill-retriever/tool-search.d.ts +19 -0
  97. package/dist/src/skill-retriever/tool-search.js +184 -0
  98. package/dist/src/skill-retriever/types.d.ts +37 -0
  99. package/dist/src/skill-retriever/types.js +1 -0
  100. package/dist/src/steer-injector.d.ts +16 -0
  101. package/dist/src/steer-injector.js +74 -0
  102. package/dist/src/steer-queue.d.ts +1 -0
  103. package/dist/src/steer-queue.js +9 -0
  104. package/dist/src/subagent-wait-state.d.ts +66 -0
  105. package/dist/src/subagent-wait-state.js +226 -0
  106. package/dist/src/task-manager.d.ts +13 -31
  107. package/dist/src/task-manager.js +32 -83
  108. package/dist/src/thread-bindings.d.ts +54 -0
  109. package/dist/src/thread-bindings.js +214 -0
  110. package/dist/src/tools/agent-as-skill-tool.d.ts +46 -0
  111. package/dist/src/tools/agent-as-skill-tool.js +183 -0
  112. package/dist/src/tools/calendar-tool.d.ts +24 -1
  113. package/dist/src/tools/calendar-tool.js +10 -46
  114. package/dist/src/tools/call-device-tool.d.ts +20 -0
  115. package/dist/src/tools/call-device-tool.js +131 -0
  116. package/dist/src/tools/call-phone-tool.d.ts +21 -1
  117. package/dist/src/tools/call-phone-tool.js +10 -68
  118. package/dist/src/tools/check-plugin-privilege-tool.d.ts +20 -0
  119. package/dist/src/tools/check-plugin-privilege-tool.js +180 -0
  120. package/dist/src/tools/create-alarm-tool.d.ts +39 -1
  121. package/dist/src/tools/create-alarm-tool.js +18 -131
  122. package/dist/src/tools/create-all-tools.d.ts +16 -0
  123. package/dist/src/tools/create-all-tools.js +62 -0
  124. package/dist/src/tools/delete-alarm-tool.d.ts +15 -1
  125. package/dist/src/tools/delete-alarm-tool.js +14 -82
  126. package/dist/src/tools/device-tool-map.d.ts +4 -0
  127. package/dist/src/tools/device-tool-map.js +45 -0
  128. package/dist/src/tools/discover-cross-devices-tool.d.ts +16 -0
  129. package/dist/src/tools/discover-cross-devices-tool.js +232 -0
  130. package/dist/src/tools/display-a2ui-card-bypath-tool.d.ts +21 -0
  131. package/dist/src/tools/display-a2ui-card-bypath-tool.js +65 -0
  132. package/dist/src/tools/display-a2ui-card-tool.d.ts +2 -0
  133. package/dist/src/tools/display-a2ui-card-tool.js +85 -0
  134. package/dist/src/tools/find-pc-devices-tool.d.ts +6 -0
  135. package/dist/src/tools/find-pc-devices-tool.js +95 -0
  136. package/dist/src/tools/get-alarm-tool-schema.d.ts +16 -0
  137. package/dist/src/tools/get-alarm-tool-schema.js +11 -0
  138. package/dist/src/tools/get-calendar-tool-schema.d.ts +16 -0
  139. package/dist/src/tools/get-calendar-tool-schema.js +9 -0
  140. package/dist/src/tools/get-collection-tool-schema.d.ts +16 -0
  141. package/dist/src/tools/get-collection-tool-schema.js +10 -0
  142. package/dist/src/tools/get-contact-tool-schema.d.ts +16 -0
  143. package/dist/src/tools/get-contact-tool-schema.js +11 -0
  144. package/dist/src/tools/get-device-file-tool-schema.d.ts +16 -0
  145. package/dist/src/tools/get-device-file-tool-schema.js +10 -0
  146. package/dist/src/tools/get-email-tool-schema.d.ts +16 -0
  147. package/dist/src/tools/get-email-tool-schema.js +9 -0
  148. package/dist/src/tools/get-note-tool-schema.d.ts +16 -0
  149. package/dist/src/tools/get-note-tool-schema.js +10 -0
  150. package/dist/src/tools/get-photo-tool-schema.d.ts +16 -0
  151. package/dist/src/tools/get-photo-tool-schema.js +10 -0
  152. package/dist/src/tools/hmos-cli.d.ts +109 -0
  153. package/dist/src/tools/hmos-cli.js +558 -0
  154. package/dist/src/tools/image-reading-tool.d.ts +32 -0
  155. package/dist/src/tools/image-reading-tool.js +246 -0
  156. package/dist/src/tools/invoke.d.ts +88 -0
  157. package/dist/src/tools/invoke.js +1209 -0
  158. package/dist/src/tools/location-tool.d.ts +11 -1
  159. package/dist/src/tools/location-tool.js +17 -49
  160. package/dist/src/tools/login-token-tool.d.ts +24 -0
  161. package/dist/src/tools/login-token-tool.js +142 -0
  162. package/dist/src/tools/modify-alarm-tool.d.ts +47 -1
  163. package/dist/src/tools/modify-alarm-tool.js +41 -144
  164. package/dist/src/tools/modify-note-tool.d.ts +20 -1
  165. package/dist/src/tools/modify-note-tool.js +11 -50
  166. package/dist/src/tools/note-tool.d.ts +20 -1
  167. package/dist/src/tools/note-tool.js +12 -25
  168. package/dist/src/tools/query-app-message-tool.d.ts +31 -0
  169. package/dist/src/tools/query-app-message-tool.js +138 -0
  170. package/dist/src/tools/query-memory-data-tool.d.ts +31 -0
  171. package/dist/src/tools/query-memory-data-tool.js +154 -0
  172. package/dist/src/tools/query-todo-task-tool.d.ts +27 -0
  173. package/dist/src/tools/query-todo-task-tool.js +133 -0
  174. package/dist/src/tools/save-file-to-phone-tool.d.ts +28 -0
  175. package/dist/src/tools/save-file-to-phone-tool.js +165 -0
  176. package/dist/src/tools/save-media-to-gallery-tool.d.ts +28 -0
  177. package/dist/src/tools/save-media-to-gallery-tool.js +173 -0
  178. package/dist/src/tools/save-self-evolution-skill-tool.d.ts +54 -0
  179. package/dist/src/tools/save-self-evolution-skill-tool.js +410 -0
  180. package/dist/src/tools/schema-tool-factory.d.ts +27 -0
  181. package/dist/src/tools/schema-tool-factory.js +32 -0
  182. package/dist/src/tools/search-alarm-tool.d.ts +34 -1
  183. package/dist/src/tools/search-alarm-tool.js +26 -140
  184. package/dist/src/tools/search-calendar-tool.d.ts +24 -1
  185. package/dist/src/tools/search-calendar-tool.js +14 -90
  186. package/dist/src/tools/search-contact-tool.d.ts +16 -1
  187. package/dist/src/tools/search-contact-tool.js +10 -64
  188. package/dist/src/tools/search-email-tool.d.ts +25 -0
  189. package/dist/src/tools/search-email-tool.js +136 -0
  190. package/dist/src/tools/search-file-tool.d.ts +16 -1
  191. package/dist/src/tools/search-file-tool.js +17 -77
  192. package/dist/src/tools/search-message-tool.d.ts +16 -1
  193. package/dist/src/tools/search-message-tool.js +10 -67
  194. package/dist/src/tools/search-note-tool.d.ts +16 -1
  195. package/dist/src/tools/search-note-tool.js +12 -31
  196. package/dist/src/tools/search-photo-gallery-tool.d.ts +21 -1
  197. package/dist/src/tools/search-photo-gallery-tool.js +18 -68
  198. package/dist/src/tools/send-command-to-car-tool.d.ts +5 -0
  199. package/dist/src/tools/send-command-to-car-tool.js +85 -0
  200. package/dist/src/tools/send-cross-device-task-tool.d.ts +35 -0
  201. package/dist/src/tools/send-cross-device-task-tool.js +365 -0
  202. package/dist/src/tools/send-email-tool.d.ts +27 -0
  203. package/dist/src/tools/send-email-tool.js +134 -0
  204. package/dist/src/tools/send-file-to-user-tool.d.ts +20 -1
  205. package/dist/src/tools/send-file-to-user-tool.js +47 -60
  206. package/dist/src/tools/send-html-card-tool.d.ts +25 -0
  207. package/dist/src/tools/send-html-card-tool.js +111 -0
  208. package/dist/src/tools/send-message-tool.d.ts +20 -1
  209. package/dist/src/tools/send-message-tool.js +12 -64
  210. package/dist/src/tools/session-helper.d.ts +24 -0
  211. package/dist/src/tools/session-helper.js +45 -0
  212. package/dist/src/tools/session-manager.d.ts +35 -28
  213. package/dist/src/tools/session-manager.js +138 -132
  214. package/dist/src/tools/timestamp-to-utc8-tool.d.ts +12 -0
  215. package/dist/src/tools/timestamp-to-utc8-tool.js +104 -0
  216. package/dist/src/tools/upload-file-tool.d.ts +20 -1
  217. package/dist/src/tools/upload-file-tool.js +16 -65
  218. package/dist/src/tools/upload-photo-tool.d.ts +20 -1
  219. package/dist/src/tools/upload-photo-tool.js +14 -57
  220. package/dist/src/tools/view-push-result-tool.d.ts +5 -0
  221. package/dist/src/tools/view-push-result-tool.js +107 -0
  222. package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +35 -0
  223. package/dist/src/tools/xiaoyi-add-collection-tool.js +192 -0
  224. package/dist/src/tools/xiaoyi-collection-tool.d.ts +20 -1
  225. package/dist/src/tools/xiaoyi-collection-tool.js +54 -97
  226. package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +18 -0
  227. package/dist/src/tools/xiaoyi-delete-collection-tool.js +162 -0
  228. package/dist/src/tools/xiaoyi-gui-tool.d.ts +16 -1
  229. package/dist/src/tools/xiaoyi-gui-tool.js +13 -43
  230. package/dist/src/trigger-handler.d.ts +22 -0
  231. package/dist/src/trigger-handler.js +55 -0
  232. package/dist/src/types.d.ts +25 -1
  233. package/dist/src/utils/config-manager.d.ts +3 -2
  234. package/dist/src/utils/config-manager.js +25 -8
  235. package/dist/src/utils/cron-push-map.d.ts +26 -0
  236. package/dist/src/utils/cron-push-map.js +131 -0
  237. package/dist/src/utils/logger.d.ts +8 -0
  238. package/dist/src/utils/logger.js +128 -18
  239. package/dist/src/utils/pushdata-manager.d.ts +28 -0
  240. package/dist/src/utils/pushdata-manager.js +167 -0
  241. package/dist/src/utils/pushid-manager.d.ts +12 -0
  242. package/dist/src/utils/pushid-manager.js +104 -0
  243. package/dist/src/utils/runtime-manager.d.ts +7 -0
  244. package/dist/src/utils/runtime-manager.js +61 -0
  245. package/dist/src/utils/self-evolution-manager.d.ts +10 -0
  246. package/dist/src/utils/self-evolution-manager.js +69 -0
  247. package/dist/src/utils/skills-logger.d.ts +5 -0
  248. package/dist/src/utils/skills-logger.js +76 -0
  249. package/dist/src/utils/throw.d.ts +5 -0
  250. package/dist/src/utils/throw.js +10 -0
  251. package/dist/src/utils/tool-call-nudge-manager.d.ts +16 -0
  252. package/dist/src/utils/tool-call-nudge-manager.js +47 -0
  253. package/dist/src/websocket.d.ts +8 -1
  254. package/dist/src/websocket.js +391 -48
  255. package/dist/src/xy-session-store.d.ts +79 -0
  256. package/dist/src/xy-session-store.js +153 -0
  257. package/openclaw.plugin.json +26 -0
  258. package/package.json +9 -8
  259. package/dist/src/tools/search-photo-tool.d.ts +0 -9
  260. package/dist/src/tools/search-photo-tool.js +0 -270
  261. package/dist/src/utils/session.d.ts +0 -34
  262. package/dist/src/utils/session.js +0 -50
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
- };
15
- export default plugin;
16
- export { xyPlugin };
1
+ import { definePluginEntry } from "openclaw/plugin-sdk/core";
2
+ declare const pluginEntry: ReturnType<typeof definePluginEntry>;
3
+ export default pluginEntry;
package/dist/index.js CHANGED
@@ -1,21 +1,303 @@
1
- import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
1
+ import { definePluginEntry } from "openclaw/plugin-sdk/core";
2
+ import { xiaoyiProvider } from "./src/provider.js";
2
3
  import { xyPlugin } from "./src/channel.js";
4
+ import registerSentinelHook from "./src/cspl/sentinel_hook.js";
3
5
  import { setXYRuntime } from "./src/runtime.js";
6
+ import { markCronToolCall, clearCronToolCall, getCurrentSessionContext } from "./src/tools/session-manager.js";
7
+ import { configManager } from "./src/utils/config-manager.js";
8
+ import { setJobPushId } from "./src/utils/cron-push-map.js";
9
+ import { getAllPushIds } from "./src/utils/pushid-manager.js";
10
+ import { registerSelfEvolutionToolResultNudge } from "./src/self-evolution-tool-result-nudge.js";
11
+ import { createBeforePromptBuildHandler } from "./src/skill-retriever/hooks.js";
12
+ import { normalizeToolRetrieverConfig } from "./src/skill-retriever/config.js";
13
+ import { registerCLIHook } from "./src/tools/hmos-cli.js";
14
+ import { recoverCronState } from "./src/cron-recovery.js";
15
+ import { writeSkillUsage } from "./src/utils/skills-logger.js";
16
+ import { logger } from "./src/utils/logger.js";
4
17
  /**
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.
18
+ * Parse a file path string to detect if it refers to a SKILL.md file within
19
+ * a skills directory. Returns the skill name (parent directory) if so.
20
+ *
21
+ * Matches paths like:
22
+ * ~/.openclaw/workspace/skills/my-skill/SKILL.md
23
+ * /home/user/core_skills/my-skill/SKILL.md
24
+ * skills/my-skill/SKILL.md
8
25
  */
9
- const plugin = {
26
+ function extractSkillNameFromPath(filePath) {
27
+ if (typeof filePath !== "string" || !filePath)
28
+ return null;
29
+ // Normalize common path prefixes
30
+ const normalized = filePath.replace(/^~\//, "/home/").replace(/\\/g, "/");
31
+ // Match: .../skills/<skillName>/SKILL.md or .../skills/<skillName>/...
32
+ // Also match: .../core_skills/<skillName>/SKILL.md
33
+ const match = normalized.match(/\/(?:core_)?skills\/([^/]+)\/SKILL\.md$/i);
34
+ return match ? match[1] : null;
35
+ }
36
+ /**
37
+ * Register the skills diagnostic event listener via after_tool_call hook.
38
+ *
39
+ * When openclaw fires a `skill.used` diagnostic event, the skill's SKILL.md
40
+ * is typically read by the model first. We detect SKILL.md reads through
41
+ * the `after_tool_call` hook and write the skill name to the skills log.
42
+ */
43
+ function registerSkillsDiagnosticHook(api) {
44
+ api.on("after_tool_call", async (event, _ctx) => {
45
+ if (event.toolName !== "read")
46
+ return;
47
+ const skillName = extractSkillNameFromPath(event.params?.path);
48
+ if (skillName) {
49
+ writeSkillUsage(skillName);
50
+ }
51
+ });
52
+ }
53
+ /**
54
+ * Register the cron detection hook.
55
+ *
56
+ * When openclaw's cron runner triggers a tool call, the sessionKey has the
57
+ * format "cron:<jobId>". We use this to mark the toolCallId in a global Map
58
+ * so that sendCommand() can route the command through the push channel
59
+ * instead of the (non-existent) WebSocket session.
60
+ */
61
+ function registerCronDetectionHook(api) {
62
+ api.on("before_tool_call", async (event, ctx) => {
63
+ if (ctx.sessionKey?.startsWith("cron:") && event.toolCallId) {
64
+ markCronToolCall(event.toolCallId);
65
+ }
66
+ });
67
+ api.on("after_tool_call", async (event, ctx) => {
68
+ if (event.toolCallId) {
69
+ clearCronToolCall(event.toolCallId);
70
+ }
71
+ // 捕获对话创建的 cron job:agent 调 cron(add) 后,从 result 拿 jobId,
72
+ // 配合当前会话的 pushId,写入 jobId↔pushId 映射,供 fire 时反查设备。
73
+ await captureCronAddMapping(event, ctx).catch((err) => {
74
+ // 捕获失败不影响工具结果
75
+ console.error("[xy] captureCronAddMapping failed:", err);
76
+ });
77
+ });
78
+ }
79
+ /** 从 cron add 工具结果中提取 jobId 并写入 pushId 映射。 */
80
+ async function captureCronAddMapping(event, ctx) {
81
+ // 两条创建路径都要捕获:
82
+ // 1) cron agent 工具:toolName==="cron", params.action==="add"
83
+ // 2) exec 跑 CLI:toolName==="exec", params.command 含 "cron add"
84
+ // (agent 实际用的是这条:openclaw cron add --name ... --cron ... --message ...)
85
+ const isCronAddTool = event.toolName === "cron" &&
86
+ (event.params?.action === "add" || event.params?.action === "create");
87
+ const isExecCronAdd = event.toolName === "exec" && isExecCronAddCommand(event.params?.command);
88
+ if (!isCronAddTool && !isExecCronAdd)
89
+ return;
90
+ console.log(`[CRONMAP] after_tool_call path=${event.toolName}, resultType=${typeof event.result}`);
91
+ const jobId = readJobIdFromResult(event.result);
92
+ if (!jobId) {
93
+ console.log(`[CRONMAP] skip: could not extract jobId. preview=${preview(event.result)}`);
94
+ return;
95
+ }
96
+ console.log(`[CRONMAP] extracted jobId=${jobId}`);
97
+ const sessionCtx = getCurrentSessionContext();
98
+ const sessionId = sessionCtx?.sessionId;
99
+ if (!sessionId) {
100
+ console.log(`[CRONMAP] skip: no sessionId in ALS scope (ctxFound=${!!sessionCtx})`);
101
+ return;
102
+ }
103
+ const pushId = await resolvePushId(sessionId);
104
+ if (!pushId) {
105
+ console.log(`[CRONMAP] skip: no pushId available for sessionId=${sessionId} (no session match, no global, no file)`);
106
+ return;
107
+ }
108
+ console.log(`[CRONMAP] writing map: jobId=${jobId}, sessionId=${sessionId}, pushId=${pushId.substring(0, 16)}...`);
109
+ await setJobPushId(jobId, {
110
+ pushId,
111
+ sessionId,
112
+ deviceType: sessionCtx?.deviceType,
113
+ source: event.toolName === "exec" ? "exec-cli" : "conversation",
114
+ });
115
+ console.log(`[CRONMAP] map written OK`);
116
+ }
117
+ /** 回退链取 pushId:当前会话 → 全局兜底 → 本地文件首个(保底)。 */
118
+ async function resolvePushId(sessionId) {
119
+ // 1. 同会话
120
+ const session = configManager.getPushId(sessionId);
121
+ if (session)
122
+ return session;
123
+ // 2. 全局(任何会话注册过的)
124
+ const global = configManager.getPushId();
125
+ if (global)
126
+ return global;
127
+ // 3. 文件兜底
128
+ try {
129
+ const all = await getAllPushIds();
130
+ if (all.length > 0)
131
+ return all[0];
132
+ }
133
+ catch {
134
+ // ignore
135
+ }
136
+ return null;
137
+ }
138
+ /** 判断 exec 命令是否为 cron add(匹配 "openclaw cron add" 或裸 "cron add",排除 list/remove 等)。 */
139
+ function isExecCronAddCommand(command) {
140
+ if (typeof command !== "string")
141
+ return false;
142
+ return /\bcron\s+add\b/.test(command);
143
+ }
144
+ /** 取结果的短预览,用于诊断。 */
145
+ function preview(value) {
146
+ if (value == null)
147
+ return String(value);
148
+ const s = typeof value === "string" ? value : JSON.stringify(value);
149
+ return s.length > 200 ? s.slice(0, 200) + "…" : s;
150
+ }
151
+ /** 防御性地从 cron add 结果中取 job id。
152
+ * 覆盖:裸 job 对象、JSON 字符串、exec 输出文本、
153
+ * {content:[{text}]} / {stdout} / data/result/job 嵌套。 */
154
+ function readJobIdFromResult(result) {
155
+ if (!result)
156
+ return undefined;
157
+ // {content: [{type:"text", text: "..."}]} — exec 工具的输出信封
158
+ if (result && typeof result === "object") {
159
+ const contentArr = result.content;
160
+ if (Array.isArray(contentArr)) {
161
+ for (const item of contentArr) {
162
+ if (item && typeof item === "object") {
163
+ const text = item.text;
164
+ if (typeof text === "string" && text.trim()) {
165
+ const fromContent = readJobIdFromResult(text);
166
+ if (fromContent)
167
+ return fromContent;
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
173
+ // {stdout} — 备选 exec 输出信封
174
+ if (result && typeof result === "object") {
175
+ const stdout = result.stdout;
176
+ if (typeof stdout === "string" && stdout.trim()) {
177
+ const fromStdout = readJobIdFromResult(stdout);
178
+ if (fromStdout)
179
+ return fromStdout;
180
+ }
181
+ }
182
+ let obj = result;
183
+ if (typeof result === "string") {
184
+ try {
185
+ obj = JSON.parse(result);
186
+ }
187
+ catch {
188
+ // 纯文本:可能含 stderr 前缀行 + JSON。用正则抓 "id":"..."。
189
+ const m = result.match(/"id"\s*:\s*"([^"]+)"/);
190
+ if (m)
191
+ return m[1];
192
+ return undefined;
193
+ }
194
+ }
195
+ if (obj && typeof obj === "object") {
196
+ const id = obj.id;
197
+ if (typeof id === "string" && id.trim())
198
+ return id.trim();
199
+ for (const k of ["data", "result", "job"]) {
200
+ const inner = obj[k];
201
+ if (inner && typeof inner === "object") {
202
+ const innerId = inner.id;
203
+ if (typeof innerId === "string" && innerId.trim())
204
+ return innerId.trim();
205
+ }
206
+ }
207
+ }
208
+ return undefined;
209
+ }
210
+ // ── Gateway startup: cron state recovery ────────────────────────────────────
211
+ /**
212
+ * Register the gateway_start hook for cron state recovery.
213
+ *
214
+ * On gateway startup, checks .openclaw/cron/ for legacy JSON/JSONL files
215
+ * and migrates them into the SQLite state database:
216
+ * - Reads legacy jobs.json + jobs-state.json → imports into cron_jobs table
217
+ * - Reads legacy runs/*.jsonl → imports into cron_run_logs table
218
+ * - Archives migrated files with .migrated suffix
219
+ *
220
+ * Pattern follows legacy-store-migration.ts and legacy-run-log-migration.ts:
221
+ * check → load → import into SQLite → archive old files.
222
+ */
223
+ function registerCronRecoveryHook(api) {
224
+ api.on("gateway_start", async (_event, _ctx) => {
225
+ const logTag = "[CRON-RECOVERY-HOOK]";
226
+ logger.log(`${logTag} gateway_start fired — checking for legacy cron files`);
227
+ let result;
228
+ try {
229
+ result = await recoverCronState();
230
+ }
231
+ catch (err) {
232
+ logger.error(`${logTag} cron state recovery threw:`, err);
233
+ // Don't let a recovery failure block gateway startup.
234
+ return;
235
+ }
236
+ if (result.recovered) {
237
+ logger.log(`${logTag} migration performed: ` +
238
+ `storeMigrated=${result.storeMigrated}, ` +
239
+ `runLogFilesImported=${result.runLogFilesImported}`);
240
+ }
241
+ else {
242
+ logger.log(`${logTag} no legacy cron files found, nothing to migrate`);
243
+ }
244
+ // Log full diagnostics
245
+ for (const diag of result.diagnostics) {
246
+ logger.log(`${logTag} diag: ${diag}`);
247
+ }
248
+ });
249
+ }
250
+ function registerFullHooks(api) {
251
+ // SKILL RETRIEVER HOOK: before_prompt_build hook
252
+ const pluginConfig = api.pluginConfig || {};
253
+ const skillRetrieverConfig = normalizeToolRetrieverConfig({
254
+ enabled: pluginConfig.skillRetrieverEnabled ?? true,
255
+ maxTools: pluginConfig.skillRetrieverMaxTools ?? 2,
256
+ includeUninstalledOnly: true,
257
+ envFilePath: "~/.openclaw/.xiaoyienv",
258
+ timeoutMs: pluginConfig.skillRetrieverTimeoutMs ?? 1000,
259
+ });
260
+ const beforePromptBuildHandler = createBeforePromptBuildHandler(skillRetrieverConfig);
261
+ api.on("before_prompt_build", async (event, ctx) => {
262
+ logger.log(`[BEFORE_PROMPT_BUILD] hook fired, sessionKey=${ctx.sessionKey || "undefined"}, sessionId=${ctx.sessionId || "undefined"}`);
263
+ return beforePromptBuildHandler(event, ctx);
264
+ });
265
+ registerSelfEvolutionToolResultNudge(api);
266
+ }
267
+ const pluginEntry = definePluginEntry({
10
268
  id: "xiaoyi-channel",
11
269
  name: "Xiaoyi Channel",
12
270
  description: "Xiaoyi channel plugin - Xiaoyi A2A protocol integration",
13
- configSchema: emptyPluginConfigSchema(),
14
271
  register(api) {
15
- setXYRuntime(api.runtime);
272
+ // Always register the provider so wrapStreamFn/prepareExtraParams work
273
+ // in ALL registration modes (not just "full").
274
+ api.registerProvider(xiaoyiProvider);
275
+ if (api.registrationMode === "cli-metadata") {
276
+ return;
277
+ }
278
+ if (api.registrationMode === "tool-discovery") {
279
+ registerFullHooks(api);
280
+ return;
281
+ }
282
+ // Register channel plugin and set runtime
16
283
  api.registerChannel({ plugin: xyPlugin });
284
+ setXYRuntime(api.runtime);
285
+ if (api.registrationMode === "discovery") {
286
+ return;
287
+ }
288
+ if (api.registrationMode === "full") {
289
+ registerFullHooks(api);
290
+ // CSPL sentinel hook: before_tool_call + after_tool_call security scanning
291
+ registerSentinelHook(api);
292
+ // Cron detection hook: marks toolCallIds from cron sessions
293
+ registerCronDetectionHook(api);
294
+ // CLI exec hook: intercepts built-in exec for HarmonyOS CLI skill tools
295
+ registerCLIHook(api);
296
+ // Cron recovery hook: prunes stale cron-push-map and pushData on gateway startup
297
+ registerCronRecoveryHook(api);
298
+ // Skills diagnostic hook: log skill usage (detected via SKILL.md reads)
299
+ registerSkillsDiagnosticHook(api);
300
+ }
17
301
  },
18
- };
19
- export default plugin;
20
- // Also export the plugin directly for testing
21
- export { xyPlugin };
302
+ });
303
+ export default pluginEntry;
@@ -0,0 +1,2 @@
1
+ import { xiaoyiProvider } from "./src/provider.js";
2
+ export default xiaoyiProvider;
@@ -0,0 +1,4 @@
1
+ // Provider discovery entry for fast-path provider resolution.
2
+ // Exported as default so normalizeDiscoveryModule can unwrap it via .default.
3
+ import { xiaoyiProvider } from "./src/provider.js";
4
+ export default xiaoyiProvider;
@@ -0,0 +1,37 @@
1
+ import { type BindingTargetKind } from "openclaw/plugin-sdk/conversation-runtime";
2
+ type XyBindingTargetKind = "subagent" | "acp";
3
+ type XyAcpBindingRecord = {
4
+ accountId: string;
5
+ conversationId: string;
6
+ parentConversationId?: string;
7
+ deliveryTo?: string;
8
+ targetKind: XyBindingTargetKind;
9
+ targetSessionKey: string;
10
+ agentId?: string;
11
+ label?: string;
12
+ boundBy?: string;
13
+ boundAt: number;
14
+ lastActivityAt: number;
15
+ };
16
+ type XyAcpBindingManager = {
17
+ accountId: string;
18
+ getByConversationId: (conversationId: string) => XyAcpBindingRecord | undefined;
19
+ listBySessionKey: (targetSessionKey: string) => XyAcpBindingRecord[];
20
+ bindConversation: (params: {
21
+ conversationId: string;
22
+ parentConversationId?: string;
23
+ targetKind: BindingTargetKind;
24
+ targetSessionKey: string;
25
+ metadata?: Record<string, unknown>;
26
+ }) => XyAcpBindingRecord | null;
27
+ touchConversation: (conversationId: string, at?: number) => XyAcpBindingRecord | null;
28
+ unbindConversation: (conversationId: string) => XyAcpBindingRecord | null;
29
+ unbindBySessionKey: (targetSessionKey: string) => XyAcpBindingRecord[];
30
+ stop: () => void;
31
+ };
32
+ export declare function createXyAcpBindingManager(params: {
33
+ accountId?: string;
34
+ cfg: any;
35
+ }): XyAcpBindingManager;
36
+ export declare function getXyAcpBindingManager(accountId?: string): XyAcpBindingManager | null;
37
+ export {};
@@ -0,0 +1,237 @@
1
+ // ACP Session Binding Adapter for xiaoyi-channel.
2
+ // Follows the feishu thread-bindings.ts pattern.
3
+ //
4
+ // Maps A2A sessionId (stable conversation identifier) to ACP/subagent
5
+ // session keys so that openclaw can bind spawned sessions to the
6
+ // current xiaoyi conversation.
7
+ //
8
+ // Key design: xiaoyi-channel only supports `placement: "current"` —
9
+ // it cannot create child threads (unlike Discord). All spawned sessions
10
+ // are bound to the current A2A conversation identified by sessionId.
11
+ // NOTE: Using `any` for cfg type to avoid version mismatch between
12
+ // local and global openclaw installs (auth.profiles.aws-sdk union).
13
+ import { resolveThreadBindingIdleTimeoutMsForChannel, resolveThreadBindingMaxAgeMsForChannel, resolveThreadBindingConversationIdFromBindingId, registerSessionBindingAdapter, unregisterSessionBindingAdapter, } from "openclaw/plugin-sdk/conversation-runtime";
14
+ import { normalizeAccountId, resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/routing";
15
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
16
+ import { logger } from "./utils/logger.js";
17
+ // ─── Global state (survives module dedup) ─────────────────────
18
+ const XY_ACP_BINDINGS_KEY = Symbol.for("openclaw.xyAcpBindingsState");
19
+ let state;
20
+ function getState() {
21
+ if (!state) {
22
+ const globalStore = globalThis;
23
+ state = globalStore[XY_ACP_BINDINGS_KEY] ?? {
24
+ managersByAccountId: new Map(),
25
+ bindingsByAccountConversation: new Map(),
26
+ };
27
+ globalStore[XY_ACP_BINDINGS_KEY] = state;
28
+ }
29
+ return state;
30
+ }
31
+ function resolveBindingKey(params) {
32
+ return `${params.accountId}:${params.conversationId}`;
33
+ }
34
+ // ─── Kind conversion ──────────────────────────────────────────
35
+ function toSessionBindingTargetKind(raw) {
36
+ return raw === "subagent" ? "subagent" : "session";
37
+ }
38
+ function toXyTargetKind(raw) {
39
+ return raw === "subagent" ? "subagent" : "acp";
40
+ }
41
+ // ─── Record conversion ────────────────────────────────────────
42
+ function toSessionBindingRecord(record, defaults) {
43
+ const idleExpiresAt = defaults.idleTimeoutMs > 0 ? record.lastActivityAt + defaults.idleTimeoutMs : undefined;
44
+ const maxAgeExpiresAt = defaults.maxAgeMs > 0 ? record.boundAt + defaults.maxAgeMs : undefined;
45
+ const expiresAt = idleExpiresAt != null && maxAgeExpiresAt != null
46
+ ? Math.min(idleExpiresAt, maxAgeExpiresAt)
47
+ : (idleExpiresAt ?? maxAgeExpiresAt);
48
+ return {
49
+ bindingId: resolveBindingKey({
50
+ accountId: record.accountId,
51
+ conversationId: record.conversationId,
52
+ }),
53
+ targetSessionKey: record.targetSessionKey,
54
+ targetKind: toSessionBindingTargetKind(record.targetKind),
55
+ conversation: {
56
+ channel: "xiaoyi-channel",
57
+ accountId: record.accountId,
58
+ conversationId: record.conversationId,
59
+ parentConversationId: record.parentConversationId,
60
+ },
61
+ status: "active",
62
+ boundAt: record.boundAt,
63
+ expiresAt,
64
+ metadata: {
65
+ agentId: record.agentId,
66
+ label: record.label,
67
+ boundBy: record.boundBy,
68
+ deliveryTo: record.deliveryTo,
69
+ lastActivityAt: record.lastActivityAt,
70
+ idleTimeoutMs: defaults.idleTimeoutMs,
71
+ maxAgeMs: defaults.maxAgeMs,
72
+ },
73
+ };
74
+ }
75
+ // ─── Manager factory ──────────────────────────────────────────
76
+ export function createXyAcpBindingManager(params) {
77
+ const accountId = normalizeAccountId(params.accountId);
78
+ const existing = getState().managersByAccountId.get(accountId);
79
+ if (existing) {
80
+ return existing;
81
+ }
82
+ const idleTimeoutMs = resolveThreadBindingIdleTimeoutMsForChannel({
83
+ cfg: params.cfg,
84
+ channel: "xiaoyi-channel",
85
+ accountId,
86
+ });
87
+ const maxAgeMs = resolveThreadBindingMaxAgeMsForChannel({
88
+ cfg: params.cfg,
89
+ channel: "xiaoyi-channel",
90
+ accountId,
91
+ });
92
+ const log = logger.withContext("", "");
93
+ const manager = {
94
+ accountId,
95
+ getByConversationId: (conversationId) => getState().bindingsByAccountConversation.get(resolveBindingKey({ accountId, conversationId })),
96
+ listBySessionKey: (targetSessionKey) => [...getState().bindingsByAccountConversation.values()].filter((record) => record.accountId === accountId && record.targetSessionKey === targetSessionKey),
97
+ bindConversation: ({ conversationId, parentConversationId, targetKind, targetSessionKey, metadata, }) => {
98
+ const normalizedConversationId = conversationId.trim();
99
+ const normalizedTargetSessionKey = targetSessionKey.trim();
100
+ if (!normalizedConversationId || !normalizedTargetSessionKey) {
101
+ return null;
102
+ }
103
+ const existingLocal = getState().bindingsByAccountConversation.get(resolveBindingKey({ accountId, conversationId: normalizedConversationId }));
104
+ const now = Date.now();
105
+ const record = {
106
+ accountId,
107
+ conversationId: normalizedConversationId,
108
+ parentConversationId: normalizeOptionalString(parentConversationId) ?? existingLocal?.parentConversationId,
109
+ deliveryTo: typeof metadata?.deliveryTo === "string" && metadata.deliveryTo.trim()
110
+ ? metadata.deliveryTo.trim()
111
+ : existingLocal?.deliveryTo,
112
+ targetKind: toXyTargetKind(targetKind),
113
+ targetSessionKey: normalizedTargetSessionKey,
114
+ agentId: typeof metadata?.agentId === "string" && metadata.agentId.trim()
115
+ ? metadata.agentId.trim()
116
+ : (existingLocal?.agentId ?? resolveAgentIdFromSessionKey(normalizedTargetSessionKey)),
117
+ label: typeof metadata?.label === "string" && metadata.label.trim()
118
+ ? metadata.label.trim()
119
+ : existingLocal?.label,
120
+ boundBy: typeof metadata?.boundBy === "string" && metadata.boundBy.trim()
121
+ ? metadata.boundBy.trim()
122
+ : existingLocal?.boundBy,
123
+ boundAt: now,
124
+ lastActivityAt: now,
125
+ };
126
+ getState().bindingsByAccountConversation.set(resolveBindingKey({ accountId, conversationId: normalizedConversationId }), record);
127
+ log.log(`[XY-ACP-BIND] Bound ${targetKind} session ${normalizedTargetSessionKey.slice(0, 30)} to conversation ${normalizedConversationId.slice(0, 12)}`);
128
+ return record;
129
+ },
130
+ touchConversation: (conversationId, at = Date.now()) => {
131
+ const key = resolveBindingKey({ accountId, conversationId });
132
+ const existingRecord = getState().bindingsByAccountConversation.get(key);
133
+ if (!existingRecord) {
134
+ return null;
135
+ }
136
+ const updated = { ...existingRecord, lastActivityAt: at };
137
+ getState().bindingsByAccountConversation.set(key, updated);
138
+ return updated;
139
+ },
140
+ unbindConversation: (conversationId) => {
141
+ const key = resolveBindingKey({ accountId, conversationId });
142
+ const existingRecord = getState().bindingsByAccountConversation.get(key);
143
+ if (!existingRecord) {
144
+ return null;
145
+ }
146
+ getState().bindingsByAccountConversation.delete(key);
147
+ return existingRecord;
148
+ },
149
+ unbindBySessionKey: (targetSessionKey) => {
150
+ const removed = [];
151
+ for (const record of getState().bindingsByAccountConversation.values()) {
152
+ if (record.accountId !== accountId || record.targetSessionKey !== targetSessionKey) {
153
+ continue;
154
+ }
155
+ getState().bindingsByAccountConversation.delete(resolveBindingKey({ accountId, conversationId: record.conversationId }));
156
+ removed.push(record);
157
+ }
158
+ return removed;
159
+ },
160
+ stop: () => {
161
+ for (const key of getState().bindingsByAccountConversation.keys()) {
162
+ if (key.startsWith(`${accountId}:`)) {
163
+ getState().bindingsByAccountConversation.delete(key);
164
+ }
165
+ }
166
+ getState().managersByAccountId.delete(accountId);
167
+ unregisterSessionBindingAdapter({
168
+ channel: "xiaoyi-channel",
169
+ accountId,
170
+ adapter: sessionBindingAdapter,
171
+ });
172
+ log.log(`[XY-ACP-BIND] Stopped binding manager for account ${accountId}`);
173
+ },
174
+ };
175
+ const sessionBindingAdapter = {
176
+ channel: "xiaoyi-channel",
177
+ accountId,
178
+ capabilities: {
179
+ placements: ["current"],
180
+ },
181
+ bind: async (input) => {
182
+ if (input.conversation.channel !== "xiaoyi-channel" || input.placement === "child") {
183
+ return null;
184
+ }
185
+ const bound = manager.bindConversation({
186
+ conversationId: input.conversation.conversationId,
187
+ parentConversationId: input.conversation.parentConversationId,
188
+ targetKind: input.targetKind,
189
+ targetSessionKey: input.targetSessionKey,
190
+ metadata: input.metadata,
191
+ });
192
+ return bound ? toSessionBindingRecord(bound, { idleTimeoutMs, maxAgeMs }) : null;
193
+ },
194
+ listBySession: (targetSessionKey) => manager
195
+ .listBySessionKey(targetSessionKey)
196
+ .map((entry) => toSessionBindingRecord(entry, { idleTimeoutMs, maxAgeMs })),
197
+ resolveByConversation: (ref) => {
198
+ if (ref.channel !== "xiaoyi-channel") {
199
+ return null;
200
+ }
201
+ const found = manager.getByConversationId(ref.conversationId);
202
+ return found ? toSessionBindingRecord(found, { idleTimeoutMs, maxAgeMs }) : null;
203
+ },
204
+ touch: (bindingId, at) => {
205
+ const conversationId = resolveThreadBindingConversationIdFromBindingId({
206
+ accountId,
207
+ bindingId,
208
+ });
209
+ if (conversationId) {
210
+ manager.touchConversation(conversationId, at);
211
+ }
212
+ },
213
+ unbind: async (input) => {
214
+ if (input.targetSessionKey?.trim()) {
215
+ return manager
216
+ .unbindBySessionKey(input.targetSessionKey.trim())
217
+ .map((entry) => toSessionBindingRecord(entry, { idleTimeoutMs, maxAgeMs }));
218
+ }
219
+ const conversationId = resolveThreadBindingConversationIdFromBindingId({
220
+ accountId,
221
+ bindingId: input.bindingId,
222
+ });
223
+ if (!conversationId) {
224
+ return [];
225
+ }
226
+ const removed = manager.unbindConversation(conversationId);
227
+ return removed ? [toSessionBindingRecord(removed, { idleTimeoutMs, maxAgeMs })] : [];
228
+ },
229
+ };
230
+ registerSessionBindingAdapter(sessionBindingAdapter);
231
+ getState().managersByAccountId.set(accountId, manager);
232
+ log.log(`[XY-ACP-BIND] Created binding manager for account ${accountId} (idleTimeout=${idleTimeoutMs}ms, maxAge=${maxAgeMs}ms)`);
233
+ return manager;
234
+ }
235
+ export function getXyAcpBindingManager(accountId) {
236
+ return getState().managersByAccountId.get(normalizeAccountId(accountId)) ?? null;
237
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Approval bridge for Xiaoyi channel.
3
+ *
4
+ * 目标:
5
+ * 1. 把 OpenClaw 发出的 /approve 文本提示,改写成更适合 Xiaoyi 用户理解的自然语言确认提示。
6
+ * 2. 仅在当前 session 确实存在待审批状态时,才把用户回复的“确认 / 拒绝”等短指令回写成 /approve。
7
+ * 3. 每个 session 只保留最新的一条待审批记录,避免桥接状态无限累积。
8
+ *
9
+ * 注意:
10
+ * - 这里的 Map 只是桥接层缓存,不是真正的审批来源。
11
+ * - 真正的审批状态仍然由 OpenClaw gateway 维护。
12
+ */
13
+ /**
14
+ * 出站改写:
15
+ * - 如果是审批提示,则记录待审批状态,并输出更友好的确认文案。
16
+ * - 如果是 /approve 的成功或失败回执,则改写成用户更容易理解的文本。
17
+ */
18
+ export declare function rewriteOutboundApprovalText(sessionId: any, text: any): any;
19
+ /**
20
+ * 入站改写:
21
+ * - 先检查当前 session 是否存在有效待审批状态。
22
+ * - 只有存在待审批状态时,才把“确认 / 拒绝”等短回复翻译成 /approve。
23
+ * - 没有待审批状态时,完全不介入,避免影响普通对话。
24
+ */
25
+ export declare function rewriteInboundApprovalText(sessionId: any, text: any): {
26
+ matched: boolean;
27
+ rewrittenText: any;
28
+ decision?: undefined;
29
+ approvalId?: undefined;
30
+ } | {
31
+ matched: boolean;
32
+ decision: string;
33
+ approvalId: any;
34
+ rewrittenText: string;
35
+ };
36
+ /**
37
+ * 清理指定 session 的待审批状态。
38
+ * 用于 clearContext / cancel 等显式结束会话的场景。
39
+ */
40
+ export declare function clearPendingApproval(sessionId: any): void;
41
+ /**
42
+ * 仅用于本地调试或测试。
43
+ */
44
+ export declare function getPendingApproval(sessionId: any): any;
45
+ /**
46
+ * 仅用于本地调试或测试。
47
+ */
48
+ export declare function clearAllPendingApprovals(): void;