openclaw-plugin-yuanbao 2.13.0 → 2.13.1-beta.9

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 (267) hide show
  1. package/dist/api.d.ts +4 -0
  2. package/dist/api.js +4 -0
  3. package/dist/index.js +5 -0
  4. package/dist/src/access/api.d.ts +8 -0
  5. package/dist/src/access/api.js +8 -0
  6. package/dist/src/access/http/bot-id-cache.d.ts +12 -0
  7. package/dist/src/access/http/bot-id-cache.js +12 -0
  8. package/dist/src/access/http/main.d.ts +12 -0
  9. package/dist/src/access/http/main.js +12 -0
  10. package/dist/src/access/http/request.d.ts +1 -0
  11. package/dist/src/access/http/request.js +10 -2
  12. package/dist/src/access/ws/biz-codec.d.ts +25 -0
  13. package/dist/src/access/ws/biz-codec.js +29 -0
  14. package/dist/src/access/ws/client.d.ts +31 -0
  15. package/dist/src/access/ws/client.js +73 -11
  16. package/dist/src/access/ws/conn-codec.d.ts +42 -0
  17. package/dist/src/access/ws/conn-codec.js +44 -0
  18. package/dist/src/access/ws/gateway.d.ts +1 -0
  19. package/dist/src/access/ws/gateway.js +27 -0
  20. package/dist/src/access/ws/runtime.d.ts +16 -0
  21. package/dist/src/access/ws/runtime.js +9 -0
  22. package/dist/src/access/ws/types.d.ts +33 -0
  23. package/dist/src/access/ws/types.js +7 -0
  24. package/dist/src/accounts.d.ts +17 -0
  25. package/dist/src/accounts.js +41 -1
  26. package/dist/src/business/actions/deliver.d.ts +14 -0
  27. package/dist/src/business/actions/deliver.js +12 -0
  28. package/dist/src/business/actions/handler.d.ts +21 -0
  29. package/dist/src/business/actions/handler.js +33 -0
  30. package/dist/src/business/actions/index.d.ts +16 -0
  31. package/dist/src/business/actions/index.js +24 -0
  32. package/dist/src/business/actions/media/send.d.ts +14 -0
  33. package/dist/src/business/actions/media/send.js +14 -0
  34. package/dist/src/business/actions/resolve-target.d.ts +29 -0
  35. package/dist/src/business/actions/resolve-target.js +25 -0
  36. package/dist/src/business/actions/sticker/init-builtin-stickers.d.ts +10 -0
  37. package/dist/src/business/actions/sticker/init-builtin-stickers.js +10 -0
  38. package/dist/src/business/actions/sticker/send.d.ts +19 -0
  39. package/dist/src/business/actions/sticker/send.js +19 -0
  40. package/dist/src/business/actions/sticker/sticker-cache.d.ts +28 -0
  41. package/dist/src/business/actions/sticker/sticker-cache.js +43 -2
  42. package/dist/src/business/actions/sticker/sticker-types.d.ts +8 -0
  43. package/dist/src/business/actions/sticker/sticker-types.js +3 -0
  44. package/dist/src/business/actions/text/send.d.ts +11 -0
  45. package/dist/src/business/actions/text/send.js +11 -0
  46. package/dist/src/business/commands/command-sync/index.d.ts +1 -0
  47. package/dist/src/business/commands/command-sync/index.js +3 -0
  48. package/dist/src/business/commands/log-upload/cos-upload.d.ts +11 -0
  49. package/dist/src/business/commands/log-upload/cos-upload.js +28 -0
  50. package/dist/src/business/commands/log-upload/extractor.js +15 -0
  51. package/dist/src/business/commands/log-upload/index.js +1 -0
  52. package/dist/src/business/commands/log-upload/perform.d.ts +12 -0
  53. package/dist/src/business/commands/log-upload/perform.js +18 -0
  54. package/dist/src/business/commands/upgrade/env.d.ts +15 -0
  55. package/dist/src/business/commands/upgrade/env.js +17 -0
  56. package/dist/src/business/commands/upgrade/index.d.ts +9 -0
  57. package/dist/src/business/commands/upgrade/index.js +13 -0
  58. package/dist/src/business/commands/upgrade/upgrade.d.ts +3 -0
  59. package/dist/src/business/commands/upgrade/upgrade.js +47 -0
  60. package/dist/src/business/commands/upgrade/utils.d.ts +31 -0
  61. package/dist/src/business/commands/upgrade/utils.js +45 -0
  62. package/dist/src/business/inbound/index.d.ts +13 -0
  63. package/dist/src/business/inbound/index.js +15 -0
  64. package/dist/src/business/messaging/callbacks/recall.d.ts +18 -0
  65. package/dist/src/business/messaging/callbacks/recall.js +19 -1
  66. package/dist/src/business/messaging/chat-history.d.ts +16 -0
  67. package/dist/src/business/messaging/chat-history.js +14 -0
  68. package/dist/src/business/messaging/chat-history.test.d.ts +3 -0
  69. package/dist/src/business/messaging/chat-history.test.js +7 -0
  70. package/dist/src/business/messaging/context.d.ts +5 -0
  71. package/dist/src/business/messaging/context.js +4 -0
  72. package/dist/src/business/messaging/directory.d.ts +15 -0
  73. package/dist/src/business/messaging/directory.js +26 -0
  74. package/dist/src/business/messaging/extract.d.ts +10 -0
  75. package/dist/src/business/messaging/extract.js +11 -0
  76. package/dist/src/business/messaging/extract.test.d.ts +3 -0
  77. package/dist/src/business/messaging/extract.test.js +3 -0
  78. package/dist/src/business/messaging/handlers/custom/index.d.ts +11 -0
  79. package/dist/src/business/messaging/handlers/custom/index.js +24 -0
  80. package/dist/src/business/messaging/handlers/custom/link-card.d.ts +12 -0
  81. package/dist/src/business/messaging/handlers/custom/link-card.js +13 -0
  82. package/dist/src/business/messaging/handlers/custom.d.ts +5 -0
  83. package/dist/src/business/messaging/handlers/custom.js +5 -0
  84. package/dist/src/business/messaging/handlers/custom.test.d.ts +5 -0
  85. package/dist/src/business/messaging/handlers/custom.test.js +8 -3
  86. package/dist/src/business/messaging/handlers/face.d.ts +1 -0
  87. package/dist/src/business/messaging/handlers/face.js +2 -0
  88. package/dist/src/business/messaging/handlers/face.test.d.ts +5 -0
  89. package/dist/src/business/messaging/handlers/face.test.js +5 -0
  90. package/dist/src/business/messaging/handlers/file.d.ts +6 -0
  91. package/dist/src/business/messaging/handlers/file.js +13 -0
  92. package/dist/src/business/messaging/handlers/image.d.ts +6 -0
  93. package/dist/src/business/messaging/handlers/image.js +17 -1
  94. package/dist/src/business/messaging/handlers/image.test.d.ts +5 -0
  95. package/dist/src/business/messaging/handlers/image.test.js +6 -0
  96. package/dist/src/business/messaging/handlers/index.d.ts +1 -0
  97. package/dist/src/business/messaging/handlers/index.js +9 -0
  98. package/dist/src/business/messaging/handlers/index.test.d.ts +5 -0
  99. package/dist/src/business/messaging/handlers/index.test.js +5 -0
  100. package/dist/src/business/messaging/handlers/sound.d.ts +6 -0
  101. package/dist/src/business/messaging/handlers/sound.js +10 -0
  102. package/dist/src/business/messaging/handlers/text.d.ts +5 -0
  103. package/dist/src/business/messaging/handlers/text.js +11 -0
  104. package/dist/src/business/messaging/handlers/text.test.d.ts +5 -0
  105. package/dist/src/business/messaging/handlers/text.test.js +6 -0
  106. package/dist/src/business/messaging/handlers/types.d.ts +35 -0
  107. package/dist/src/business/messaging/handlers/types.js +6 -0
  108. package/dist/src/business/messaging/handlers/video.d.ts +5 -0
  109. package/dist/src/business/messaging/handlers/video.js +12 -0
  110. package/dist/src/business/messaging/index.d.ts +1 -0
  111. package/dist/src/business/messaging/index.js +3 -0
  112. package/dist/src/business/messaging/mention.d.ts +27 -0
  113. package/dist/src/business/messaging/mention.js +27 -0
  114. package/dist/src/business/messaging/quote.d.ts +19 -0
  115. package/dist/src/business/messaging/quote.js +24 -0
  116. package/dist/src/business/messaging/quote.test.d.ts +3 -0
  117. package/dist/src/business/messaging/quote.test.js +4 -0
  118. package/dist/src/business/messaging/system-callbacks.d.ts +21 -0
  119. package/dist/src/business/messaging/system-callbacks.js +22 -0
  120. package/dist/src/business/messaging/targets.d.ts +28 -0
  121. package/dist/src/business/messaging/targets.js +37 -2
  122. package/dist/src/business/messaging/targets.test.d.ts +5 -0
  123. package/dist/src/business/messaging/targets.test.js +10 -0
  124. package/dist/src/business/outbound/create-sender.d.ts +1 -0
  125. package/dist/src/business/outbound/create-sender.js +4 -0
  126. package/dist/src/business/outbound/heartbeat.d.ts +3 -0
  127. package/dist/src/business/outbound/heartbeat.js +3 -0
  128. package/dist/src/business/outbound/index.d.ts +3 -0
  129. package/dist/src/business/outbound/index.js +3 -0
  130. package/dist/src/business/outbound/queue.d.ts +3 -0
  131. package/dist/src/business/outbound/queue.js +15 -0
  132. package/dist/src/business/outbound/types.d.ts +11 -0
  133. package/dist/src/business/outbound/types.js +5 -0
  134. package/dist/src/business/pipeline/create.d.ts +5 -0
  135. package/dist/src/business/pipeline/create.js +27 -17
  136. package/dist/src/business/pipeline/engine.d.ts +10 -0
  137. package/dist/src/business/pipeline/engine.js +11 -0
  138. package/dist/src/business/pipeline/engine.test.d.ts +3 -0
  139. package/dist/src/business/pipeline/engine.test.js +7 -0
  140. package/dist/src/business/pipeline/index.d.ts +5 -0
  141. package/dist/src/business/pipeline/index.js +5 -0
  142. package/dist/src/business/pipeline/middlewares/build-context.d.ts +4 -0
  143. package/dist/src/business/pipeline/middlewares/build-context.js +8 -0
  144. package/dist/src/business/pipeline/middlewares/build-context.test.d.ts +3 -0
  145. package/dist/src/business/pipeline/middlewares/build-context.test.js +4 -0
  146. package/dist/src/business/pipeline/middlewares/dispatch-reply.d.ts +7 -0
  147. package/dist/src/business/pipeline/middlewares/dispatch-reply.js +34 -0
  148. package/dist/src/business/pipeline/middlewares/dispatch-reply.test.d.ts +3 -0
  149. package/dist/src/business/pipeline/middlewares/dispatch-reply.test.js +12 -0
  150. package/dist/src/business/pipeline/middlewares/download-media.d.ts +4 -0
  151. package/dist/src/business/pipeline/middlewares/download-media.js +10 -0
  152. package/dist/src/business/pipeline/middlewares/download-media.test.d.ts +3 -0
  153. package/dist/src/business/pipeline/middlewares/download-media.test.js +3 -0
  154. package/dist/src/business/pipeline/middlewares/extract-content.d.ts +3 -0
  155. package/dist/src/business/pipeline/middlewares/extract-content.js +6 -0
  156. package/dist/src/business/pipeline/middlewares/extract-content.test.d.ts +3 -0
  157. package/dist/src/business/pipeline/middlewares/extract-content.test.js +5 -0
  158. package/dist/src/business/pipeline/middlewares/guard-command.d.ts +4 -0
  159. package/dist/src/business/pipeline/middlewares/guard-command.js +6 -1
  160. package/dist/src/business/pipeline/middlewares/guard-command.test.d.ts +3 -0
  161. package/dist/src/business/pipeline/middlewares/guard-command.test.js +4 -0
  162. package/dist/src/business/pipeline/middlewares/guard-group-command.d.ts +6 -0
  163. package/dist/src/business/pipeline/middlewares/guard-group-command.js +8 -1
  164. package/dist/src/business/pipeline/middlewares/guard-group-command.test.d.ts +3 -0
  165. package/dist/src/business/pipeline/middlewares/guard-group-command.test.js +4 -0
  166. package/dist/src/business/pipeline/middlewares/guard-send-access.d.ts +15 -0
  167. package/dist/src/business/pipeline/middlewares/guard-send-access.js +33 -0
  168. package/dist/src/business/pipeline/middlewares/guard-send-access.test.d.ts +3 -0
  169. package/dist/src/business/pipeline/middlewares/guard-send-access.test.js +7 -2
  170. package/dist/src/business/pipeline/middlewares/guard-special-command.d.ts +3 -0
  171. package/dist/src/business/pipeline/middlewares/guard-special-command.js +19 -3
  172. package/dist/src/business/pipeline/middlewares/guard-special-command.test.d.ts +3 -0
  173. package/dist/src/business/pipeline/middlewares/guard-special-command.test.js +4 -0
  174. package/dist/src/business/pipeline/middlewares/index.d.ts +3 -0
  175. package/dist/src/business/pipeline/middlewares/index.js +3 -0
  176. package/dist/src/business/pipeline/middlewares/prepare-sender.d.ts +3 -0
  177. package/dist/src/business/pipeline/middlewares/prepare-sender.js +6 -1
  178. package/dist/src/business/pipeline/middlewares/prepare-sender.test.d.ts +3 -0
  179. package/dist/src/business/pipeline/middlewares/prepare-sender.test.js +3 -0
  180. package/dist/src/business/pipeline/middlewares/record-member.d.ts +4 -0
  181. package/dist/src/business/pipeline/middlewares/record-member.js +4 -0
  182. package/dist/src/business/pipeline/middlewares/record-member.test.d.ts +3 -0
  183. package/dist/src/business/pipeline/middlewares/record-member.test.js +3 -0
  184. package/dist/src/business/pipeline/middlewares/resolve-mention.d.ts +6 -0
  185. package/dist/src/business/pipeline/middlewares/resolve-mention.js +9 -1
  186. package/dist/src/business/pipeline/middlewares/resolve-mention.test.d.ts +3 -0
  187. package/dist/src/business/pipeline/middlewares/resolve-mention.test.js +3 -0
  188. package/dist/src/business/pipeline/middlewares/resolve-quote.d.ts +3 -0
  189. package/dist/src/business/pipeline/middlewares/resolve-quote.js +3 -0
  190. package/dist/src/business/pipeline/middlewares/resolve-quote.test.d.ts +3 -0
  191. package/dist/src/business/pipeline/middlewares/resolve-quote.test.js +3 -0
  192. package/dist/src/business/pipeline/middlewares/resolve-route.d.ts +3 -0
  193. package/dist/src/business/pipeline/middlewares/resolve-route.js +4 -0
  194. package/dist/src/business/pipeline/middlewares/resolve-route.test.d.ts +3 -0
  195. package/dist/src/business/pipeline/middlewares/resolve-route.test.js +3 -0
  196. package/dist/src/business/pipeline/middlewares/resolve-trace.d.ts +4 -0
  197. package/dist/src/business/pipeline/middlewares/resolve-trace.js +5 -0
  198. package/dist/src/business/pipeline/middlewares/rewrite-body.d.ts +3 -0
  199. package/dist/src/business/pipeline/middlewares/rewrite-body.js +10 -0
  200. package/dist/src/business/pipeline/middlewares/rewrite-body.test.d.ts +3 -0
  201. package/dist/src/business/pipeline/middlewares/rewrite-body.test.js +4 -0
  202. package/dist/src/business/pipeline/middlewares/skip-placeholder.d.ts +6 -0
  203. package/dist/src/business/pipeline/middlewares/skip-placeholder.js +13 -0
  204. package/dist/src/business/pipeline/middlewares/skip-placeholder.test.d.ts +3 -0
  205. package/dist/src/business/pipeline/middlewares/skip-placeholder.test.js +3 -0
  206. package/dist/src/business/pipeline/middlewares/skip-self.d.ts +3 -0
  207. package/dist/src/business/pipeline/middlewares/skip-self.js +4 -1
  208. package/dist/src/business/pipeline/middlewares/skip-self.test.d.ts +3 -0
  209. package/dist/src/business/pipeline/middlewares/skip-self.test.js +3 -0
  210. package/dist/src/business/pipeline/test-helpers/mock-ctx.d.ts +10 -0
  211. package/dist/src/business/pipeline/test-helpers/mock-ctx.js +11 -0
  212. package/dist/src/business/pipeline/types.d.ts +9 -0
  213. package/dist/src/business/pipeline/types.js +4 -0
  214. package/dist/src/business/tools/group.d.ts +14 -0
  215. package/dist/src/business/tools/group.js +29 -0
  216. package/dist/src/business/tools/index.d.ts +13 -0
  217. package/dist/src/business/tools/index.js +18 -0
  218. package/dist/src/business/tools/member.d.ts +15 -0
  219. package/dist/src/business/tools/member.js +44 -1
  220. package/dist/src/business/tools/remind.d.ts +6 -0
  221. package/dist/src/business/tools/remind.js +44 -0
  222. package/dist/src/business/trace/context.d.ts +18 -1
  223. package/dist/src/business/trace/context.js +17 -1
  224. package/dist/src/business/utils/markdown.d.ts +9 -0
  225. package/dist/src/business/utils/markdown.js +47 -15
  226. package/dist/src/business/utils/media.d.ts +10 -0
  227. package/dist/src/business/utils/media.js +43 -1
  228. package/dist/src/business/utils/utils.d.ts +35 -2
  229. package/dist/src/business/utils/utils.js +33 -2
  230. package/dist/src/business/utils/utils.test.d.ts +5 -0
  231. package/dist/src/business/utils/utils.test.js +6 -0
  232. package/dist/src/channel-shared.d.ts +17 -0
  233. package/dist/src/channel-shared.js +17 -0
  234. package/dist/src/channel.d.ts +7 -0
  235. package/dist/src/channel.js +16 -0
  236. package/dist/src/channel.setup.d.ts +8 -0
  237. package/dist/src/channel.setup.js +8 -0
  238. package/dist/src/config-schema.d.ts +14 -0
  239. package/dist/src/config-schema.js +14 -0
  240. package/dist/src/dispatcher/debouncer/index.d.ts +1 -0
  241. package/dist/src/dispatcher/debouncer/index.js +13 -0
  242. package/dist/src/dispatcher/queue/session-abort-manager.d.ts +18 -0
  243. package/dist/src/dispatcher/queue/session-abort-manager.js +18 -0
  244. package/dist/src/dispatcher/queue/session-queue.d.ts +19 -0
  245. package/dist/src/dispatcher/queue/session-queue.js +22 -0
  246. package/dist/src/infra/cache/member.d.ts +3 -0
  247. package/dist/src/infra/cache/member.js +18 -0
  248. package/dist/src/infra/cache/ttl-db.d.ts +5 -0
  249. package/dist/src/infra/cache/ttl-db.js +6 -1
  250. package/dist/src/infra/cache/ttl-db.test.d.ts +3 -0
  251. package/dist/src/infra/cache/ttl-db.test.js +5 -0
  252. package/dist/src/infra/env.d.ts +12 -0
  253. package/dist/src/infra/env.js +31 -0
  254. package/dist/src/infra/transport.d.ts +7 -0
  255. package/dist/src/infra/transport.js +12 -0
  256. package/dist/src/logger.d.ts +5 -0
  257. package/dist/src/logger.js +6 -0
  258. package/dist/src/runtime.d.ts +6 -0
  259. package/dist/src/setup-core.d.ts +6 -0
  260. package/dist/src/setup-core.js +10 -0
  261. package/dist/src/setup-surface.d.ts +6 -0
  262. package/dist/src/setup-surface.js +7 -0
  263. package/dist/src/types.d.ts +16 -0
  264. package/dist/src/types.js +1 -0
  265. package/openclaw.plugin.json +1 -1
  266. package/package.json +16 -52
  267. package/README.md +0 -58
package/dist/api.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Aggregated export file
3
+ * 供 index.ts 通过 loadBundledEntryExportSync 懒加载引用
4
+ */
1
5
  export { yuanbaoPlugin } from "./src/channel.js";
2
6
  export { yuanbaoSetupPlugin } from "./src/channel.setup.js";
3
7
  export { initLogger } from "./src/logger.js";
package/dist/api.js CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Aggregated export file
3
+ * 供 index.ts 通过 loadBundledEntryExportSync 懒加载引用
4
+ */
1
5
  export { yuanbaoPlugin } from "./src/channel.js";
2
6
  export { yuanbaoSetupPlugin } from "./src/channel.setup.js";
3
7
  export { initLogger } from "./src/logger.js";
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { defineBundledChannelEntry, loadBundledEntryExportSync, } from "openclaw/plugin-sdk/channel-entry-contract";
2
2
  import { YUANBAO_PLUGIN_ID } from "./src/channel-shared.js";
3
+ /** 懒加载注册工具 */
3
4
  function registerTools(api) {
4
5
  const register = loadBundledEntryExportSync(import.meta.url, {
5
6
  specifier: "./api.js",
@@ -7,6 +8,7 @@ function registerTools(api) {
7
8
  });
8
9
  register(api);
9
10
  }
11
+ /** Lazy-load and register all slash commands */
10
12
  function registerCommands(api) {
11
13
  const yuanbaoUpgradeCommand = loadBundledEntryExportSync(import.meta.url, { specifier: "./api.js", exportName: "yuanbaoUpgradeCommand" });
12
14
  const yuanbaobotUpgradeCommand = loadBundledEntryExportSync(import.meta.url, { specifier: "./api.js", exportName: "yuanbaobotUpgradeCommand" });
@@ -15,6 +17,7 @@ function registerCommands(api) {
15
17
  api.registerCommand(yuanbaobotUpgradeCommand);
16
18
  api.registerCommand(logUploadCommandDefinition);
17
19
  }
20
+ /** 懒加载初始化内置表情缓存 */
18
21
  function initBuiltinStickers() {
19
22
  const init = loadBundledEntryExportSync(import.meta.url, {
20
23
  specifier: "./api.js",
@@ -22,6 +25,7 @@ function initBuiltinStickers() {
22
25
  });
23
26
  init();
24
27
  }
28
+ /** 懒加载初始化环境变量 */
25
29
  function initEnv(api) {
26
30
  const init = loadBundledEntryExportSync(import.meta.url, {
27
31
  specifier: "./api.js",
@@ -29,6 +33,7 @@ function initEnv(api) {
29
33
  });
30
34
  init(api);
31
35
  }
36
+ /** 懒加载初始化日志 */
32
37
  function initLogger(api) {
33
38
  const init = loadBundledEntryExportSync(import.meta.url, {
34
39
  specifier: "./api.js",
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Yuanbao API client.
3
+ *
4
+ * Backward-compatible re-export entry point.
5
+ * Implementation split into:
6
+ * - http/request.ts — Types, token cache, signing, auth headers, HTTP utilities
7
+ * - http/main.ts — Business APIs (uploadInfo / downloadUrl)
8
+ */
1
9
  export type { SignTokenData, AuthHeaders, CosUploadConfig, Log } from "./http/request.js";
2
10
  export { clearSignTokenCache, clearAllSignTokenCache, getTokenStatus, verifySignature, getSignToken, forceRefreshSignToken, getAuthHeaders, yuanbaoPost, yuanbaoGet, } from "./http/request.js";
3
11
  export { apiGetUploadInfo, apiGetDownloadUrl } from "./http/main.js";
@@ -1,2 +1,10 @@
1
+ /**
2
+ * Yuanbao API client.
3
+ *
4
+ * Backward-compatible re-export entry point.
5
+ * Implementation split into:
6
+ * - http/request.ts — Types, token cache, signing, auth headers, HTTP utilities
7
+ * - http/main.ts — Business APIs (uploadInfo / downloadUrl)
8
+ */
1
9
  export { clearSignTokenCache, clearAllSignTokenCache, getTokenStatus, verifySignature, getSignToken, forceRefreshSignToken, getAuthHeaders, yuanbaoPost, yuanbaoGet, } from "./http/request.js";
2
10
  export { apiGetUploadInfo, apiGetDownloadUrl } from "./http/main.js";
@@ -1,3 +1,15 @@
1
+ /**
2
+ * Lightweight botId cache shared between the HTTP sign-token client and
3
+ * account resolution.
4
+ *
5
+ * Kept in its own module (rather than inlined in `request.ts`) so that
6
+ * `accounts.ts` — which is on the `openclaw setup` / `openclaw configure`
7
+ * code path — can look up a previously-resolved botId without statically
8
+ * pulling in the full HTTP/crypto/env runtime stack.
9
+ */
10
+ /** Read the last-known botId for an account, if any. */
1
11
  export declare function getCachedBotId(accountId: string): string | undefined;
12
+ /** Record a botId obtained during sign-token exchange. */
2
13
  export declare function setCachedBotId(accountId: string, botId: string | undefined): void;
14
+ /** Clear the cached botId (e.g. when tearing down an account). */
3
15
  export declare function clearCachedBotId(accountId: string): void;
@@ -1,14 +1,26 @@
1
+ /**
2
+ * Lightweight botId cache shared between the HTTP sign-token client and
3
+ * account resolution.
4
+ *
5
+ * Kept in its own module (rather than inlined in `request.ts`) so that
6
+ * `accounts.ts` — which is on the `openclaw setup` / `openclaw configure`
7
+ * code path — can look up a previously-resolved botId without statically
8
+ * pulling in the full HTTP/crypto/env runtime stack.
9
+ */
1
10
  const botIdCache = new Map();
11
+ /** Read the last-known botId for an account, if any. */
2
12
  export function getCachedBotId(accountId) {
3
13
  const value = botIdCache.get(accountId);
4
14
  return value && value.length > 0 ? value : undefined;
5
15
  }
16
+ /** Record a botId obtained during sign-token exchange. */
6
17
  export function setCachedBotId(accountId, botId) {
7
18
  if (!accountId || !botId) {
8
19
  return;
9
20
  }
10
21
  botIdCache.set(accountId, botId);
11
22
  }
23
+ /** Clear the cached botId (e.g. when tearing down an account). */
12
24
  export function clearCachedBotId(accountId) {
13
25
  botIdCache.delete(accountId);
14
26
  }
@@ -1,4 +1,16 @@
1
+ /**
2
+ * Yuanbao business API.
3
+ *
4
+ * Upload pre-sign config retrieval, resource download URL retrieval, etc.
5
+ * Auth and HTTP utilities are in request.ts.
6
+ */
1
7
  import type { ResolvedYuanbaoAccount } from "../../types.js";
2
8
  import type { Log, CosUploadConfig } from "./request.js";
9
+ /**
10
+ * Get COS upload pre-sign config.
11
+ */
3
12
  export declare function apiGetUploadInfo(account: ResolvedYuanbaoAccount, fileName: string, fileId: string, log?: Log): Promise<CosUploadConfig>;
13
+ /**
14
+ * Get COS download URL for a given resourceId.
15
+ */
4
16
  export declare function apiGetDownloadUrl(account: ResolvedYuanbaoAccount, resourceId: string, log?: Log): Promise<string>;
@@ -1,6 +1,15 @@
1
+ /**
2
+ * Yuanbao business API.
3
+ *
4
+ * Upload pre-sign config retrieval, resource download URL retrieval, etc.
5
+ * Auth and HTTP utilities are in request.ts.
6
+ */
1
7
  import { yuanbaoPost, yuanbaoGet } from "./request.js";
2
8
  const UPLOAD_INFO_PATH = "/api/resource/genUploadInfo";
3
9
  const DOWNLOAD_INFO_PATH = "/api/resource/v1/download";
10
+ /**
11
+ * Get COS upload pre-sign config.
12
+ */
4
13
  export async function apiGetUploadInfo(account, fileName, fileId, log) {
5
14
  const data = await yuanbaoPost(account, UPLOAD_INFO_PATH, { fileName, fileId, docFrom: "localDoc", docOpenId: "" }, log);
6
15
  if (!data.bucketName || !data.location) {
@@ -8,6 +17,9 @@ export async function apiGetUploadInfo(account, fileName, fileId, log) {
8
17
  }
9
18
  return data;
10
19
  }
20
+ /**
21
+ * Get COS download URL for a given resourceId.
22
+ */
11
23
  export async function apiGetDownloadUrl(account, resourceId, log) {
12
24
  const data = await yuanbaoGet(account, DOWNLOAD_INFO_PATH, { resourceId }, log);
13
25
  const downloadUrl = data.url ?? data.realUrl;
@@ -1,3 +1,4 @@
1
+ /** Yuanbao HTTP request base layer — token cache, signature, auth headers, and HTTP utilities. */
1
2
  import type { ResolvedYuanbaoAccount } from "../../types.js";
2
3
  export { getCachedBotId } from "./bot-id-cache.js";
3
4
  export type SignTokenData = {
@@ -1,3 +1,4 @@
1
+ /** Yuanbao HTTP request base layer — token cache, signature, auth headers, and HTTP utilities. */
1
2
  import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
2
3
  import { getOpenclawVersion, getOperationSystem, getPluginVersion } from "../../infra/env.js";
3
4
  import { createLog } from "../../logger.js";
@@ -10,6 +11,7 @@ const RETRYABLE_SIGN_CODE = 10099;
10
11
  const SIGN_MAX_RETRIES = 3;
11
12
  const SIGN_RETRY_DELAY_MS = 1000;
12
13
  const CACHE_REFRESH_MARGIN_MS = 5 * 60 * 1000;
14
+ // Max safe setTimeout delay (ms): ~24 days, prevents 32-bit overflow
13
15
  const MAX_SAFE_TIMEOUT_MS = 24 * 24 * 3600 * 1000;
14
16
  const HTTP_AUTH_RETRY_MAX = 1;
15
17
  const tokenCacheMap = new Map();
@@ -46,8 +48,7 @@ export function getTokenStatus(accountId) {
46
48
  }
47
49
  function computeSignature(params) {
48
50
  const plain = params.nonce + params.timestamp + params.appKey + params.appSecret;
49
- return createHmac("sha256", params.appSecret).update(plain)
50
- .digest("hex");
51
+ return createHmac("sha256", params.appSecret).update(plain).digest("hex");
51
52
  }
52
53
  export function verifySignature(expected, actual) {
53
54
  const expectedBuf = Buffer.from(expected, "hex");
@@ -113,6 +114,7 @@ function scheduleTokenRefresh(account, durationSec, log) {
113
114
  if (existing) {
114
115
  clearTimeout(existing);
115
116
  }
117
+ // Clamp: min 60s, max MAX_SAFE_TIMEOUT_MS (prevent setTimeout 32-bit integer overflow)
116
118
  const rawMs = durationSec * 1000 - CACHE_REFRESH_MARGIN_MS;
117
119
  const refreshAfterMs = Math.min(Math.max(rawMs, 60_000), MAX_SAFE_TIMEOUT_MS);
118
120
  const clampedHint = rawMs > MAX_SAFE_TIMEOUT_MS ? ", clamped to max safe timeout" : "";
@@ -128,6 +130,7 @@ function scheduleTokenRefresh(account, durationSec, log) {
128
130
  }
129
131
  catch (err) {
130
132
  mlog.error(`[${account.accountId}][token-timer] scheduled refresh failed: ${String(err)}, retrying in 30s`);
133
+ // Retry after short delay on scheduled refresh failure to avoid losing the timer
131
134
  const retryTimer = setTimeout(async () => {
132
135
  tokenRefreshTimers.delete(account.accountId);
133
136
  try {
@@ -144,6 +147,7 @@ function scheduleTokenRefresh(account, durationSec, log) {
144
147
  tokenRefreshTimers.set(account.accountId, timer);
145
148
  }
146
149
  export async function getSignToken(account, log) {
150
+ // Static token takes priority
147
151
  if (account.token) {
148
152
  return {
149
153
  bot_id: account.botId || "",
@@ -160,6 +164,7 @@ export async function getSignToken(account, log) {
160
164
  tlog.info(`[${account.accountId}] using cached token (${remainSec}s remaining)`);
161
165
  return cached.data;
162
166
  }
167
+ // Singleflight: reuse in-flight request if one exists
163
168
  let fetchPromise = tokenFetchPromises.get(account.accountId);
164
169
  if (fetchPromise) {
165
170
  tlog.info(`[${account.accountId}] sign-token in progress, waiting for existing request`);
@@ -187,6 +192,7 @@ export async function forceRefreshSignToken(account, log) {
187
192
  const flog = createLog("http", log);
188
193
  flog.warn(`[${account.accountId}][force-refresh] clearing cache and re-signing token`);
189
194
  clearSignTokenCache(account.accountId);
195
+ // Also clear in-flight singleflight promise to ensure a fresh request
190
196
  tokenFetchPromises.delete(account.accountId);
191
197
  return getSignToken(account, log);
192
198
  }
@@ -222,6 +228,7 @@ export async function yuanbaoPost(account, path, body, log) {
222
228
  },
223
229
  body: JSON.stringify(body),
224
230
  });
231
+ // HTTP 401: token expired, force-refresh and retry once
225
232
  if (response.status === 401 && attempt < HTTP_AUTH_RETRY_MAX) {
226
233
  plog.warn(`[post][${account.accountId}] ${path} received 401, refreshing token and retrying (attempt=${attempt + 1})`);
227
234
  await forceRefreshSignToken(account, log);
@@ -251,6 +258,7 @@ export async function yuanbaoGet(account, path, params, log) {
251
258
  ...authHeaders,
252
259
  },
253
260
  });
261
+ // HTTP 401: token expired, force-refresh and retry once
254
262
  if (response.status === 401 && attempt < HTTP_AUTH_RETRY_MAX) {
255
263
  glog.warn(`[get][${account.accountId}] ${path} received 401, refreshing token and retrying (attempt=${attempt + 1})`);
256
264
  await forceRefreshSignToken(account, log);
@@ -1,3 +1,4 @@
1
+ /** Business-layer Protobuf codec — encode/decode for business messages. */
1
2
  import type { YuanbaoInboundMessage, YuanbaoMsgBodyElement } from "../../types.js";
2
3
  import type { WsSendC2CMessageData, WsSendGroupMessageData, WsSendMessageResponse, WsSendPrivateHeartbeatData, WsSendGroupHeartbeatData, WsHeartbeatResponse, WsQueryGroupInfoData, WsQueryGroupInfoResponse, WsGetGroupMemberListData, WsGetGroupMemberListResponse, WsSyncInformationData, WsSyncInformationResponse } from "./types.js";
3
4
  export declare const BIZ_MSG_TYPES: {
@@ -21,21 +22,45 @@ export declare const BIZ_MSG_TYPES: {
21
22
  };
22
23
  export declare function encodeBizPB(key: string, value: Record<string, unknown>): Uint8Array | null;
23
24
  export declare function decodeBizPB(key: string, data: Uint8Array | ArrayBuffer): unknown;
25
+ /** Convert TS MsgBodyElement[] to protobuf format. */
24
26
  export declare function toProtoMsgBody(elements: YuanbaoMsgBodyElement[]): Record<string, unknown>[];
27
+ /** Convert protobuf format message body back to TS MsgBodyElement[]. */
25
28
  export declare function fromProtoMsgBody(elements: Array<Record<string, unknown>>): YuanbaoMsgBodyElement[];
29
+ /** Encode a C2C send message request. */
26
30
  export declare function encodeSendC2CMessageReq(data: WsSendC2CMessageData): Uint8Array | null;
31
+ /** Encode group message send request. */
27
32
  export declare function encodeSendGroupMessageReq(data: WsSendGroupMessageData): Uint8Array | null;
33
+ /** Encode direct chat reply status heartbeat request. */
28
34
  export declare function encodeSendPrivateHeartbeatReq(data: WsSendPrivateHeartbeatData): Uint8Array | null;
35
+ /** Encode group chat reply status heartbeat request. */
29
36
  export declare function encodeSendGroupHeartbeatReq(data: WsSendGroupHeartbeatData): Uint8Array | null;
37
+ /** Decode inbound message proto bytes into YuanbaoInboundMessage. */
30
38
  export declare function decodeInboundMessage(data: Uint8Array | ArrayBuffer): YuanbaoInboundMessage | null;
39
+ /** Decode C2C outbound response. */
31
40
  export declare function decodeSendC2CMessageRsp(data: Uint8Array | ArrayBuffer, msgId: string): WsSendMessageResponse | null;
41
+ /** Decode group message outbound response. */
32
42
  export declare function decodeSendGroupMessageRsp(data: Uint8Array | ArrayBuffer, msgId: string): WsSendMessageResponse | null;
43
+ /** Decode outbound response (compatible with both C2C and group). */
33
44
  export declare function decodeSendMessageRsp(data: Uint8Array | ArrayBuffer, msgId: string): WsSendMessageResponse | null;
45
+ /** Encode query group info request. */
34
46
  export declare function encodeQueryGroupInfoReq(data: WsQueryGroupInfoData): Uint8Array | null;
47
+ /** Decode query group info response. */
35
48
  export declare function decodeQueryGroupInfoRsp(data: Uint8Array | ArrayBuffer, msgId: string): WsQueryGroupInfoResponse | null;
49
+ /** Encode get group member list request. */
36
50
  export declare function encodeGetGroupMemberListReq(data: WsGetGroupMemberListData): Uint8Array | null;
51
+ /** Decode get group member list response. */
37
52
  export declare function decodeGetGroupMemberListRsp(data: Uint8Array | ArrayBuffer, msgId: string): WsGetGroupMemberListResponse | null;
53
+ /**
54
+ * Decode direct chat reply status heartbeat response.
55
+ * Preserves request-side msgId for stable request-response correlation.
56
+ */
38
57
  export declare function decodeSendPrivateHeartbeatRsp(data: Uint8Array | ArrayBuffer, msgId: string): WsHeartbeatResponse | null;
58
+ /**
59
+ * Decode group chat reply status heartbeat response.
60
+ * Carries original msgId for correct request-response matching.
61
+ */
39
62
  export declare function decodeSendGroupHeartbeatRsp(data: Uint8Array | ArrayBuffer, msgId: string): WsHeartbeatResponse | null;
63
+ /** Encode SyncInformationReq (sync command list to backend). */
40
64
  export declare function encodeSyncInformationReq(data: WsSyncInformationData): Uint8Array | null;
65
+ /** Decode SyncInformationRsp. */
41
66
  export declare function decodeSyncInformationRsp(data: Uint8Array | ArrayBuffer, msgId: string): WsSyncInformationResponse | null;
@@ -1,5 +1,7 @@
1
+ /** Business-layer Protobuf codec — encode/decode for business messages. */
1
2
  import protobuf from "protobufjs";
2
3
  import { createLog } from "../../logger.js";
4
+ import { EnumCLawMsgType } from "../../types.js";
3
5
  import bizDescriptor from "./proto/biz.json" with { type: "json" };
4
6
  let root = null;
5
7
  function getRoot() {
@@ -47,9 +49,11 @@ export function decodeBizPB(key, data) {
47
49
  return type.decode(buf);
48
50
  }
49
51
  catch {
52
+ // protobuf decode failure is expected, silently return null
50
53
  return null;
51
54
  }
52
55
  }
56
+ /** Convert TS MsgBodyElement[] to protobuf format. */
53
57
  export function toProtoMsgBody(elements) {
54
58
  return elements.map((el) => {
55
59
  const c = el.msg_content;
@@ -72,6 +76,7 @@ export function toProtoMsgBody(elements) {
72
76
  };
73
77
  });
74
78
  }
79
+ /** Convert protobuf format message body back to TS MsgBodyElement[]. */
75
80
  export function fromProtoMsgBody(elements) {
76
81
  if (!elements || !Array.isArray(elements)) {
77
82
  return [];
@@ -125,6 +130,7 @@ function toProtoLogExt(logExt, traceId) {
125
130
  const resolvedTraceId = traceId?.trim() || logExt?.trace_id?.trim();
126
131
  return resolvedTraceId ? { traceId: resolvedTraceId } : undefined;
127
132
  }
133
+ /** Encode a C2C send message request. */
128
134
  export function encodeSendC2CMessageReq(data) {
129
135
  const logExt = toProtoLogExt(undefined, data.trace_id);
130
136
  const log = createLog("biz-codec");
@@ -144,6 +150,7 @@ export function encodeSendC2CMessageReq(data) {
144
150
  ...(logExt ? { logExt } : {}),
145
151
  });
146
152
  }
153
+ /** Encode group message send request. */
147
154
  export function encodeSendGroupMessageReq(data) {
148
155
  const logExt = toProtoLogExt(undefined, data.trace_id);
149
156
  const log = createLog("biz-codec");
@@ -164,14 +171,17 @@ export function encodeSendGroupMessageReq(data) {
164
171
  ...(logExt ? { logExt } : {}),
165
172
  });
166
173
  }
174
+ /** Encode direct chat reply status heartbeat request. */
167
175
  export function encodeSendPrivateHeartbeatReq(data) {
168
176
  return encodeBizPB(BIZ_MSG_TYPES.SendPrivateHeartbeatReq, {
177
+ // Dual-write fromAccount/fromtAccount for backward compatibility with old descriptor typo
169
178
  fromAccount: data.from_account,
170
179
  fromtAccount: data.from_account,
171
180
  toAccount: data.to_account,
172
181
  heartbeat: data.heartbeat,
173
182
  });
174
183
  }
184
+ /** Encode group chat reply status heartbeat request. */
175
185
  export function encodeSendGroupHeartbeatReq(data) {
176
186
  return encodeBizPB(BIZ_MSG_TYPES.SendGroupHeartbeatReq, {
177
187
  fromAccount: data.from_account,
@@ -181,6 +191,7 @@ export function encodeSendGroupHeartbeatReq(data) {
181
191
  heartbeat: data.heartbeat,
182
192
  });
183
193
  }
194
+ /** Decode inbound message proto bytes into YuanbaoInboundMessage. */
184
195
  export function decodeInboundMessage(data) {
185
196
  const decoded = decodeBizPB(BIZ_MSG_TYPES.InboundMessagePush, data);
186
197
  if (!decoded) {
@@ -220,6 +231,7 @@ export function decodeInboundMessage(data) {
220
231
  seq_id: seqId,
221
232
  };
222
233
  }
234
+ /** Decode C2C outbound response. */
223
235
  export function decodeSendC2CMessageRsp(data, msgId) {
224
236
  const decoded = decodeBizPB(BIZ_MSG_TYPES.SendC2CMessageRsp, data);
225
237
  if (!decoded) {
@@ -231,6 +243,7 @@ export function decodeSendC2CMessageRsp(data, msgId) {
231
243
  message: decoded.message || "",
232
244
  };
233
245
  }
246
+ /** Decode group message outbound response. */
234
247
  export function decodeSendGroupMessageRsp(data, msgId) {
235
248
  const decoded = decodeBizPB(BIZ_MSG_TYPES.SendGroupMessageRsp, data);
236
249
  if (!decoded) {
@@ -242,14 +255,18 @@ export function decodeSendGroupMessageRsp(data, msgId) {
242
255
  message: decoded.message || "",
243
256
  };
244
257
  }
258
+ /** Decode outbound response (compatible with both C2C and group). */
245
259
  export function decodeSendMessageRsp(data, msgId) {
260
+ // C2C and group Rsp share the same structure (code + message); try C2C first
246
261
  return decodeSendC2CMessageRsp(data, msgId) ?? decodeSendGroupMessageRsp(data, msgId);
247
262
  }
263
+ /** Encode query group info request. */
248
264
  export function encodeQueryGroupInfoReq(data) {
249
265
  return encodeBizPB(BIZ_MSG_TYPES.QueryGroupInfoReq, {
250
266
  groupCode: data.group_code,
251
267
  });
252
268
  }
269
+ /** Decode query group info response. */
253
270
  export function decodeQueryGroupInfoRsp(data, msgId) {
254
271
  const decoded = decodeBizPB(BIZ_MSG_TYPES.QueryGroupInfoRsp, data);
255
272
  if (!decoded) {
@@ -270,11 +287,13 @@ export function decodeQueryGroupInfoRsp(data, msgId) {
270
287
  : undefined,
271
288
  };
272
289
  }
290
+ /** Encode get group member list request. */
273
291
  export function encodeGetGroupMemberListReq(data) {
274
292
  return encodeBizPB(BIZ_MSG_TYPES.GetGroupMemberListReq, {
275
293
  groupCode: data.group_code,
276
294
  });
277
295
  }
296
+ /** Decode get group member list response. */
278
297
  export function decodeGetGroupMemberListRsp(data, msgId) {
279
298
  const decoded = decodeBizPB(BIZ_MSG_TYPES.GetGroupMemberListRsp, data);
280
299
  if (!decoded) {
@@ -294,6 +313,10 @@ export function decodeGetGroupMemberListRsp(data, msgId) {
294
313
  member_list: memberList,
295
314
  };
296
315
  }
316
+ /**
317
+ * Decode direct chat reply status heartbeat response.
318
+ * Preserves request-side msgId for stable request-response correlation.
319
+ */
297
320
  export function decodeSendPrivateHeartbeatRsp(data, msgId) {
298
321
  const decoded = decodeBizPB(BIZ_MSG_TYPES.SendPrivateHeartbeatRsp, data);
299
322
  if (!decoded) {
@@ -306,6 +329,10 @@ export function decodeSendPrivateHeartbeatRsp(data, msgId) {
306
329
  message: decoded.msg || "",
307
330
  };
308
331
  }
332
+ /**
333
+ * Decode group chat reply status heartbeat response.
334
+ * Carries original msgId for correct request-response matching.
335
+ */
309
336
  export function decodeSendGroupHeartbeatRsp(data, msgId) {
310
337
  const decoded = decodeBizPB(BIZ_MSG_TYPES.SendGroupHeartbeatRsp, data);
311
338
  if (!decoded) {
@@ -318,6 +345,7 @@ export function decodeSendGroupHeartbeatRsp(data, msgId) {
318
345
  message: decoded.msg || "",
319
346
  };
320
347
  }
348
+ /** Encode SyncInformationReq (sync command list to backend). */
321
349
  export function encodeSyncInformationReq(data) {
322
350
  return encodeBizPB(BIZ_MSG_TYPES.SyncInformationReq, {
323
351
  syncType: data.syncType,
@@ -326,6 +354,7 @@ export function encodeSyncInformationReq(data) {
326
354
  ...(data.commandData ? { commandData: data.commandData } : {}),
327
355
  });
328
356
  }
357
+ /** Decode SyncInformationRsp. */
329
358
  export function decodeSyncInformationRsp(data, msgId) {
330
359
  const decoded = decodeBizPB(BIZ_MSG_TYPES.SyncInformationRsp, data);
331
360
  if (!decoded) {
@@ -1,7 +1,11 @@
1
+ /** WebSocket client — connection management, auth, heartbeat, and auto-reconnect. */
1
2
  import type { LogSink } from "../../logger.js";
2
3
  import type { WsClientCallbacks, WsClientConfig, WsClientState, WsConnectionConfig, WsSendMessageResponse, WsSendC2CMessageData, WsSendGroupMessageData, WsSendPrivateHeartbeatData, WsSendGroupHeartbeatData, WsHeartbeatResponse, WsQueryGroupInfoData, WsQueryGroupInfoResponse, WsGetGroupMemberListData, WsGetGroupMemberListResponse, WsSyncInformationData, WsSyncInformationResponse } from "./types.js";
4
+ /** Outbound business commands */
3
5
  export declare const BIZ_CMD: {
6
+ /** Send C2C message */
4
7
  readonly SendC2CMessage: "send_c2c_message";
8
+ /** Send group message */
5
9
  readonly SendGroupMessage: "send_group_message";
6
10
  readonly QueryGroupInfo: "query_group_info";
7
11
  readonly GetGroupMemberList: "get_group_member_list";
@@ -9,6 +13,11 @@ export declare const BIZ_CMD: {
9
13
  readonly SendGroupHeartbeat: "send_group_heartbeat";
10
14
  readonly SyncInformation: "sync_information";
11
15
  };
16
+ /**
17
+ * Yuanbao WebSocket client.
18
+ * Implements connection lifecycle, auth, heartbeat, auto-reconnect,
19
+ * send/receive, and request-response matching via msgId.
20
+ */
12
21
  export declare class YuanbaoWsClient {
13
22
  private connectionConfig;
14
23
  private readonly clientConfig;
@@ -33,35 +42,57 @@ export declare class YuanbaoWsClient {
33
42
  callbacks?: WsClientCallbacks;
34
43
  log?: LogSink;
35
44
  });
45
+ /** Update auth info (used for reconnect after token refresh). */
36
46
  updateAuth(auth: WsConnectionConfig["auth"]): void;
37
47
  connect(): void;
38
48
  disconnect(): void;
39
49
  getState(): WsClientState;
40
50
  getConnectId(): string | null;
51
+ /** Send raw binary data. */
41
52
  sendBinary(data: Uint8Array): boolean;
53
+ /** Send a business request and wait for the response matching the same msgId. */
42
54
  sendAndWait(cmd: string, module: string, data: Uint8Array, timeoutMs?: number): Promise<WsSendMessageResponse>;
43
55
  sendC2CMessage(data: WsSendC2CMessageData): Promise<WsSendMessageResponse>;
44
56
  sendGroupMessage(data: WsSendGroupMessageData): Promise<WsSendMessageResponse>;
57
+ /** Send a business request and wait for the response (supports custom decoders). */
45
58
  sendAndWaitWith<T>(cmd: string, module: string, data: Uint8Array, decoder: (data: Uint8Array | ArrayBuffer, msgId: string) => T | null, timeoutMs?: number): Promise<T>;
59
+ /** Query group info. */
46
60
  queryGroupInfo(data: WsQueryGroupInfoData): Promise<WsQueryGroupInfoResponse>;
61
+ /** Get group member list. */
47
62
  getGroupMemberList(data: WsGetGroupMemberListData): Promise<WsGetGroupMemberListResponse>;
63
+ /** Send direct-chat reply status heartbeat. */
48
64
  sendPrivateHeartbeat(data: WsSendPrivateHeartbeatData): Promise<WsHeartbeatResponse>;
65
+ /** Send group-chat reply status heartbeat. */
49
66
  sendGroupHeartbeat(data: WsSendGroupHeartbeatData): Promise<WsHeartbeatResponse>;
67
+ /** Sync information to the backend (command list, etc.). */
50
68
  syncInformation(data: WsSyncInformationData): Promise<WsSyncInformationResponse>;
69
+ /** Establish WebSocket connection and bind event handlers. */
51
70
  private doConnect;
52
71
  private onMessage;
53
72
  private handleConnMsg;
54
73
  private onResponse;
55
74
  private sendAuthBind;
75
+ /**
76
+ * Try triggering onAuthFailed callback for token refresh and reconnect.
77
+ * Uses the same scheduleReconnect delay strategy as close events.
78
+ */
56
79
  private tryAuthFailedRefresh;
80
+ /**
81
+ * After token signing failure, consume one reconnect attempt and retry after a delay.
82
+ * Avoids wasting a reconnect attempt on a connection with a known-expired token.
83
+ */
57
84
  private retryAuthRefreshAfterDelay;
85
+ /** Handle auth response: verify status code, start heartbeat, fire onReady. */
58
86
  private onAuthBindResponse;
59
87
  private startHeartbeat;
60
88
  private stopHeartbeat;
89
+ /** Schedule the next sendPing call without resetting heartbeatAckReceived (for consecutive timeout detection) */
61
90
  private scheduleNextPingCheck;
62
91
  private sendPing;
63
92
  private onPingResponse;
93
+ /** Handle a downstream push (cmdType=2). Sends ACK, handles kickout, dispatches events. */
64
94
  private onPush;
95
+ /** Handle a business response (cmdType=1, non-auth/ping). Matches pending requests by msgId. */
65
96
  private onBusinessResponse;
66
97
  private getReconnectDelay;
67
98
  private scheduleReconnect;