openclaw-plugin-yuanbao 2.12.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.
- package/dist/api.d.ts +4 -0
- package/dist/api.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -1
- package/dist/setup-entry.d.ts +1 -1
- package/dist/src/access/api.d.ts +8 -0
- package/dist/src/access/api.js +8 -0
- package/dist/src/access/http/bot-id-cache.d.ts +12 -0
- package/dist/src/access/http/bot-id-cache.js +12 -0
- package/dist/src/access/http/main.d.ts +12 -0
- package/dist/src/access/http/main.js +12 -0
- package/dist/src/access/http/request.d.ts +1 -0
- package/dist/src/access/http/request.js +10 -2
- package/dist/src/access/ws/biz-codec.d.ts +25 -0
- package/dist/src/access/ws/biz-codec.js +29 -0
- package/dist/src/access/ws/client.d.ts +31 -0
- package/dist/src/access/ws/client.js +73 -11
- package/dist/src/access/ws/conn-codec.d.ts +42 -0
- package/dist/src/access/ws/conn-codec.js +44 -0
- package/dist/src/access/ws/gateway.d.ts +1 -0
- package/dist/src/access/ws/gateway.js +27 -0
- package/dist/src/access/ws/runtime.d.ts +16 -0
- package/dist/src/access/ws/runtime.js +9 -0
- package/dist/src/access/ws/types.d.ts +33 -0
- package/dist/src/access/ws/types.js +7 -0
- package/dist/src/accounts.d.ts +17 -0
- package/dist/src/accounts.js +41 -1
- package/dist/src/business/actions/deliver.d.ts +14 -0
- package/dist/src/business/actions/deliver.js +12 -0
- package/dist/src/business/actions/handler.d.ts +21 -0
- package/dist/src/business/actions/handler.js +33 -0
- package/dist/src/business/actions/index.d.ts +16 -0
- package/dist/src/business/actions/index.js +24 -0
- package/dist/src/business/actions/media/send.d.ts +14 -0
- package/dist/src/business/actions/media/send.js +14 -0
- package/dist/src/business/actions/resolve-target.d.ts +29 -0
- package/dist/src/business/actions/resolve-target.js +25 -0
- package/dist/src/business/actions/sticker/init-builtin-stickers.d.ts +10 -0
- package/dist/src/business/actions/sticker/init-builtin-stickers.js +10 -0
- package/dist/src/business/actions/sticker/send.d.ts +19 -0
- package/dist/src/business/actions/sticker/send.js +19 -0
- package/dist/src/business/actions/sticker/sticker-cache.d.ts +28 -0
- package/dist/src/business/actions/sticker/sticker-cache.js +43 -2
- package/dist/src/business/actions/sticker/sticker-types.d.ts +8 -0
- package/dist/src/business/actions/sticker/sticker-types.js +3 -0
- package/dist/src/business/actions/text/send.d.ts +11 -0
- package/dist/src/business/actions/text/send.js +11 -0
- package/dist/src/business/commands/command-sync/index.d.ts +1 -0
- package/dist/src/business/commands/command-sync/index.js +3 -0
- package/dist/src/business/commands/log-upload/cos-upload.d.ts +11 -0
- package/dist/src/business/commands/log-upload/cos-upload.js +28 -0
- package/dist/src/business/commands/log-upload/extractor.js +16 -1
- package/dist/src/business/commands/log-upload/index.js +1 -0
- package/dist/src/business/commands/log-upload/perform.d.ts +12 -0
- package/dist/src/business/commands/log-upload/perform.js +18 -0
- package/dist/src/business/commands/upgrade/env.d.ts +15 -0
- package/dist/src/business/commands/upgrade/env.js +18 -1
- package/dist/src/business/commands/upgrade/index.d.ts +9 -0
- package/dist/src/business/commands/upgrade/index.js +13 -0
- package/dist/src/business/commands/upgrade/upgrade.d.ts +3 -0
- package/dist/src/business/commands/upgrade/upgrade.js +58 -1
- package/dist/src/business/commands/upgrade/utils.d.ts +33 -1
- package/dist/src/business/commands/upgrade/utils.js +97 -3
- package/dist/src/business/inbound/index.d.ts +13 -0
- package/dist/src/business/inbound/index.js +15 -0
- package/dist/src/business/messaging/callbacks/recall.d.ts +18 -0
- package/dist/src/business/messaging/callbacks/recall.js +19 -1
- package/dist/src/business/messaging/chat-history.d.ts +16 -0
- package/dist/src/business/messaging/chat-history.js +14 -0
- package/dist/src/business/messaging/chat-history.test.d.ts +3 -0
- package/dist/src/business/messaging/chat-history.test.js +7 -0
- package/dist/src/business/messaging/context.d.ts +5 -0
- package/dist/src/business/messaging/context.js +4 -0
- package/dist/src/business/messaging/directory.d.ts +15 -0
- package/dist/src/business/messaging/directory.js +26 -0
- package/dist/src/business/messaging/extract.d.ts +10 -0
- package/dist/src/business/messaging/extract.js +11 -0
- package/dist/src/business/messaging/extract.test.d.ts +3 -0
- package/dist/src/business/messaging/extract.test.js +3 -0
- package/dist/src/business/messaging/handlers/custom/index.d.ts +11 -0
- package/dist/src/business/messaging/handlers/custom/index.js +24 -0
- package/dist/src/business/messaging/handlers/custom/link-card.d.ts +12 -0
- package/dist/src/business/messaging/handlers/custom/link-card.js +13 -0
- package/dist/src/business/messaging/handlers/custom.d.ts +5 -0
- package/dist/src/business/messaging/handlers/custom.js +5 -0
- package/dist/src/business/messaging/handlers/custom.test.d.ts +5 -0
- package/dist/src/business/messaging/handlers/custom.test.js +8 -3
- package/dist/src/business/messaging/handlers/face.d.ts +1 -0
- package/dist/src/business/messaging/handlers/face.js +2 -0
- package/dist/src/business/messaging/handlers/face.test.d.ts +5 -0
- package/dist/src/business/messaging/handlers/face.test.js +5 -0
- package/dist/src/business/messaging/handlers/file.d.ts +6 -0
- package/dist/src/business/messaging/handlers/file.js +13 -0
- package/dist/src/business/messaging/handlers/image.d.ts +6 -0
- package/dist/src/business/messaging/handlers/image.js +17 -1
- package/dist/src/business/messaging/handlers/image.test.d.ts +5 -0
- package/dist/src/business/messaging/handlers/image.test.js +6 -0
- package/dist/src/business/messaging/handlers/index.d.ts +1 -0
- package/dist/src/business/messaging/handlers/index.js +9 -0
- package/dist/src/business/messaging/handlers/index.test.d.ts +5 -0
- package/dist/src/business/messaging/handlers/index.test.js +5 -0
- package/dist/src/business/messaging/handlers/sound.d.ts +6 -0
- package/dist/src/business/messaging/handlers/sound.js +10 -0
- package/dist/src/business/messaging/handlers/text.d.ts +5 -0
- package/dist/src/business/messaging/handlers/text.js +11 -0
- package/dist/src/business/messaging/handlers/text.test.d.ts +5 -0
- package/dist/src/business/messaging/handlers/text.test.js +6 -0
- package/dist/src/business/messaging/handlers/types.d.ts +35 -0
- package/dist/src/business/messaging/handlers/types.js +6 -0
- package/dist/src/business/messaging/handlers/video.d.ts +5 -0
- package/dist/src/business/messaging/handlers/video.js +12 -0
- package/dist/src/business/messaging/index.d.ts +1 -0
- package/dist/src/business/messaging/index.js +3 -0
- package/dist/src/business/messaging/mention.d.ts +27 -0
- package/dist/src/business/messaging/mention.js +27 -0
- package/dist/src/business/messaging/quote.d.ts +19 -0
- package/dist/src/business/messaging/quote.js +24 -0
- package/dist/src/business/messaging/quote.test.d.ts +3 -0
- package/dist/src/business/messaging/quote.test.js +4 -0
- package/dist/src/business/messaging/system-callbacks.d.ts +21 -0
- package/dist/src/business/messaging/system-callbacks.js +22 -0
- package/dist/src/business/messaging/targets.d.ts +28 -0
- package/dist/src/business/messaging/targets.js +37 -2
- package/dist/src/business/messaging/targets.test.d.ts +5 -0
- package/dist/src/business/messaging/targets.test.js +10 -0
- package/dist/src/business/outbound/create-sender.d.ts +1 -0
- package/dist/src/business/outbound/create-sender.js +4 -0
- package/dist/src/business/outbound/heartbeat.d.ts +3 -0
- package/dist/src/business/outbound/heartbeat.js +3 -0
- package/dist/src/business/outbound/index.d.ts +3 -0
- package/dist/src/business/outbound/index.js +3 -0
- package/dist/src/business/outbound/queue.d.ts +3 -0
- package/dist/src/business/outbound/queue.js +15 -0
- package/dist/src/business/outbound/types.d.ts +11 -0
- package/dist/src/business/outbound/types.js +5 -0
- package/dist/src/business/pipeline/create.d.ts +5 -0
- package/dist/src/business/pipeline/create.js +27 -17
- package/dist/src/business/pipeline/engine.d.ts +10 -0
- package/dist/src/business/pipeline/engine.js +11 -0
- package/dist/src/business/pipeline/engine.test.d.ts +3 -0
- package/dist/src/business/pipeline/engine.test.js +7 -0
- package/dist/src/business/pipeline/index.d.ts +5 -0
- package/dist/src/business/pipeline/index.js +5 -0
- package/dist/src/business/pipeline/middlewares/build-context.d.ts +4 -0
- package/dist/src/business/pipeline/middlewares/build-context.js +8 -0
- package/dist/src/business/pipeline/middlewares/build-context.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/build-context.test.js +4 -0
- package/dist/src/business/pipeline/middlewares/dispatch-reply.d.ts +7 -0
- package/dist/src/business/pipeline/middlewares/dispatch-reply.js +34 -0
- package/dist/src/business/pipeline/middlewares/dispatch-reply.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/dispatch-reply.test.js +12 -0
- package/dist/src/business/pipeline/middlewares/download-media.d.ts +4 -0
- package/dist/src/business/pipeline/middlewares/download-media.js +10 -0
- package/dist/src/business/pipeline/middlewares/download-media.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/download-media.test.js +3 -0
- package/dist/src/business/pipeline/middlewares/extract-content.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/extract-content.js +6 -0
- package/dist/src/business/pipeline/middlewares/extract-content.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/extract-content.test.js +5 -0
- package/dist/src/business/pipeline/middlewares/guard-command.d.ts +4 -0
- package/dist/src/business/pipeline/middlewares/guard-command.js +6 -1
- package/dist/src/business/pipeline/middlewares/guard-command.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/guard-command.test.js +4 -0
- package/dist/src/business/pipeline/middlewares/guard-group-command.d.ts +6 -0
- package/dist/src/business/pipeline/middlewares/guard-group-command.js +8 -1
- package/dist/src/business/pipeline/middlewares/guard-group-command.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/guard-group-command.test.js +4 -0
- package/dist/src/business/pipeline/middlewares/guard-send-access.d.ts +15 -0
- package/dist/src/business/pipeline/middlewares/guard-send-access.js +33 -0
- package/dist/src/business/pipeline/middlewares/guard-send-access.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/guard-send-access.test.js +7 -2
- package/dist/src/business/pipeline/middlewares/guard-special-command.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/guard-special-command.js +19 -3
- package/dist/src/business/pipeline/middlewares/guard-special-command.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/guard-special-command.test.js +4 -0
- package/dist/src/business/pipeline/middlewares/index.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/index.js +3 -0
- package/dist/src/business/pipeline/middlewares/prepare-sender.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/prepare-sender.js +6 -1
- package/dist/src/business/pipeline/middlewares/prepare-sender.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/prepare-sender.test.js +3 -0
- package/dist/src/business/pipeline/middlewares/record-member.d.ts +4 -0
- package/dist/src/business/pipeline/middlewares/record-member.js +4 -0
- package/dist/src/business/pipeline/middlewares/record-member.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/record-member.test.js +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-mention.d.ts +6 -0
- package/dist/src/business/pipeline/middlewares/resolve-mention.js +9 -1
- package/dist/src/business/pipeline/middlewares/resolve-mention.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-mention.test.js +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-quote.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-quote.js +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-quote.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-quote.test.js +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-route.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-route.js +4 -0
- package/dist/src/business/pipeline/middlewares/resolve-route.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-route.test.js +3 -0
- package/dist/src/business/pipeline/middlewares/resolve-trace.d.ts +4 -0
- package/dist/src/business/pipeline/middlewares/resolve-trace.js +5 -0
- package/dist/src/business/pipeline/middlewares/rewrite-body.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/rewrite-body.js +10 -0
- package/dist/src/business/pipeline/middlewares/rewrite-body.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/rewrite-body.test.js +4 -0
- package/dist/src/business/pipeline/middlewares/skip-placeholder.d.ts +6 -0
- package/dist/src/business/pipeline/middlewares/skip-placeholder.js +13 -0
- package/dist/src/business/pipeline/middlewares/skip-placeholder.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/skip-placeholder.test.js +3 -0
- package/dist/src/business/pipeline/middlewares/skip-self.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/skip-self.js +4 -1
- package/dist/src/business/pipeline/middlewares/skip-self.test.d.ts +3 -0
- package/dist/src/business/pipeline/middlewares/skip-self.test.js +3 -0
- package/dist/src/business/pipeline/test-helpers/mock-ctx.d.ts +10 -0
- package/dist/src/business/pipeline/test-helpers/mock-ctx.js +11 -0
- package/dist/src/business/pipeline/types.d.ts +9 -0
- package/dist/src/business/pipeline/types.js +4 -0
- package/dist/src/business/tools/group.d.ts +14 -0
- package/dist/src/business/tools/group.js +29 -0
- package/dist/src/business/tools/index.d.ts +13 -0
- package/dist/src/business/tools/index.js +18 -0
- package/dist/src/business/tools/member.d.ts +15 -0
- package/dist/src/business/tools/member.js +44 -1
- package/dist/src/business/tools/remind.d.ts +6 -0
- package/dist/src/business/tools/remind.js +44 -0
- package/dist/src/business/trace/context.d.ts +18 -1
- package/dist/src/business/trace/context.js +17 -1
- package/dist/src/business/utils/markdown.d.ts +9 -0
- package/dist/src/business/utils/markdown.js +47 -15
- package/dist/src/business/utils/media.d.ts +10 -0
- package/dist/src/business/utils/media.js +43 -1
- package/dist/src/business/utils/utils.d.ts +35 -2
- package/dist/src/business/utils/utils.js +33 -2
- package/dist/src/business/utils/utils.test.d.ts +5 -0
- package/dist/src/business/utils/utils.test.js +6 -0
- package/dist/src/channel-shared.d.ts +20 -2
- package/dist/src/channel-shared.js +19 -1
- package/dist/src/channel.d.ts +7 -0
- package/dist/src/channel.js +16 -0
- package/dist/src/channel.setup.d.ts +8 -0
- package/dist/src/channel.setup.js +8 -0
- package/dist/src/config-schema.d.ts +14 -0
- package/dist/src/config-schema.js +14 -0
- package/dist/src/dispatcher/debouncer/index.d.ts +1 -0
- package/dist/src/dispatcher/debouncer/index.js +13 -0
- package/dist/src/dispatcher/queue/session-abort-manager.d.ts +18 -0
- package/dist/src/dispatcher/queue/session-abort-manager.js +18 -0
- package/dist/src/dispatcher/queue/session-queue.d.ts +19 -0
- package/dist/src/dispatcher/queue/session-queue.js +22 -0
- package/dist/src/infra/cache/member.d.ts +3 -0
- package/dist/src/infra/cache/member.js +18 -0
- package/dist/src/infra/cache/ttl-db.d.ts +5 -0
- package/dist/src/infra/cache/ttl-db.js +6 -1
- package/dist/src/infra/cache/ttl-db.test.d.ts +3 -0
- package/dist/src/infra/cache/ttl-db.test.js +5 -0
- package/dist/src/infra/env.d.ts +12 -0
- package/dist/src/infra/env.js +53 -0
- package/dist/src/infra/transport.d.ts +7 -0
- package/dist/src/infra/transport.js +12 -0
- package/dist/src/logger.d.ts +5 -0
- package/dist/src/logger.js +6 -0
- package/dist/src/runtime.d.ts +6 -0
- package/dist/src/setup-core.d.ts +6 -0
- package/dist/src/setup-core.js +10 -0
- package/dist/src/setup-surface.d.ts +6 -0
- package/dist/src/setup-surface.js +7 -0
- package/dist/src/types.d.ts +16 -0
- package/dist/src/types.js +1 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +21 -60
- package/README.md +0 -58
- package/api.ts +0 -16
- package/index.ts +0 -83
- package/runtime-api.ts +0 -9
- package/setup-entry.ts +0 -9
- package/src/access/api.ts +0 -22
- package/src/access/http/bot-id-cache.ts +0 -30
- package/src/access/http/main.ts +0 -59
- package/src/access/http/request.ts +0 -415
- package/src/access/ws/biz-codec.ts +0 -506
- package/src/access/ws/client.ts +0 -978
- package/src/access/ws/conn-codec.ts +0 -226
- package/src/access/ws/gateway.ts +0 -444
- package/src/access/ws/index.ts +0 -77
- package/src/access/ws/proto/biz/get_group_member_list.proto +0 -29
- package/src/access/ws/proto/biz/inbound_message.proto +0 -44
- package/src/access/ws/proto/biz/msg_body.proto +0 -54
- package/src/access/ws/proto/biz/openclaw_proxy_svr.proto +0 -29
- package/src/access/ws/proto/biz/query_group_info.proto +0 -30
- package/src/access/ws/proto/biz/send_c2c_message.proto +0 -33
- package/src/access/ws/proto/biz/send_group_heartbeat.proto +0 -27
- package/src/access/ws/proto/biz/send_group_message.proto +0 -33
- package/src/access/ws/proto/biz/send_private_heartbeat.proto +0 -30
- package/src/access/ws/proto/biz.json +0 -552
- package/src/access/ws/proto/conn.json +0 -391
- package/src/access/ws/proto/conn.proto +0 -176
- package/src/access/ws/runtime.ts +0 -35
- package/src/access/ws/types.ts +0 -202
- package/src/accounts.ts +0 -183
- package/src/business/actions/deliver.ts +0 -58
- package/src/business/actions/handler.ts +0 -181
- package/src/business/actions/index.ts +0 -46
- package/src/business/actions/media/send.ts +0 -64
- package/src/business/actions/resolve-target.ts +0 -115
- package/src/business/actions/sticker/builtin-stickers.json +0 -542
- package/src/business/actions/sticker/init-builtin-stickers.ts +0 -31
- package/src/business/actions/sticker/send.ts +0 -93
- package/src/business/actions/sticker/sticker-cache.ts +0 -344
- package/src/business/actions/sticker/sticker-types.ts +0 -35
- package/src/business/actions/text/send.ts +0 -38
- package/src/business/commands/command-sync/index.ts +0 -118
- package/src/business/commands/log-upload/cos-upload.ts +0 -181
- package/src/business/commands/log-upload/extractor.ts +0 -307
- package/src/business/commands/log-upload/index.ts +0 -33
- package/src/business/commands/log-upload/perform.ts +0 -212
- package/src/business/commands/log-upload/types.ts +0 -49
- package/src/business/commands/upgrade/env.ts +0 -64
- package/src/business/commands/upgrade/index.ts +0 -62
- package/src/business/commands/upgrade/upgrade.ts +0 -414
- package/src/business/commands/upgrade/utils.ts +0 -267
- package/src/business/inbound/index.ts +0 -67
- package/src/business/messaging/callbacks/recall.ts +0 -127
- package/src/business/messaging/chat-history.test.ts +0 -61
- package/src/business/messaging/chat-history.ts +0 -50
- package/src/business/messaging/context.ts +0 -27
- package/src/business/messaging/directory.ts +0 -152
- package/src/business/messaging/extract.test.ts +0 -82
- package/src/business/messaging/extract.ts +0 -51
- package/src/business/messaging/handlers/custom/index.ts +0 -120
- package/src/business/messaging/handlers/custom/link-card.ts +0 -109
- package/src/business/messaging/handlers/custom.test.ts +0 -99
- package/src/business/messaging/handlers/custom.ts +0 -6
- package/src/business/messaging/handlers/face.test.ts +0 -72
- package/src/business/messaging/handlers/face.ts +0 -56
- package/src/business/messaging/handlers/file.ts +0 -50
- package/src/business/messaging/handlers/image.test.ts +0 -67
- package/src/business/messaging/handlers/image.ts +0 -58
- package/src/business/messaging/handlers/index.test.ts +0 -89
- package/src/business/messaging/handlers/index.ts +0 -176
- package/src/business/messaging/handlers/sound.ts +0 -25
- package/src/business/messaging/handlers/text.test.ts +0 -59
- package/src/business/messaging/handlers/text.ts +0 -36
- package/src/business/messaging/handlers/types.ts +0 -113
- package/src/business/messaging/handlers/video.ts +0 -48
- package/src/business/messaging/index.ts +0 -30
- package/src/business/messaging/mention.ts +0 -134
- package/src/business/messaging/quote.test.ts +0 -85
- package/src/business/messaging/quote.ts +0 -81
- package/src/business/messaging/system-callbacks.ts +0 -58
- package/src/business/messaging/targets.test.ts +0 -56
- package/src/business/messaging/targets.ts +0 -93
- package/src/business/outbound/create-sender.ts +0 -93
- package/src/business/outbound/heartbeat.ts +0 -184
- package/src/business/outbound/index.ts +0 -8
- package/src/business/outbound/queue.ts +0 -341
- package/src/business/outbound/types.ts +0 -52
- package/src/business/pipeline/create.ts +0 -54
- package/src/business/pipeline/engine.test.ts +0 -217
- package/src/business/pipeline/engine.ts +0 -75
- package/src/business/pipeline/index.ts +0 -9
- package/src/business/pipeline/middlewares/build-context.test.ts +0 -156
- package/src/business/pipeline/middlewares/build-context.ts +0 -125
- package/src/business/pipeline/middlewares/dispatch-reply.test.ts +0 -245
- package/src/business/pipeline/middlewares/dispatch-reply.ts +0 -271
- package/src/business/pipeline/middlewares/download-media.test.ts +0 -139
- package/src/business/pipeline/middlewares/download-media.ts +0 -94
- package/src/business/pipeline/middlewares/extract-content.test.ts +0 -125
- package/src/business/pipeline/middlewares/extract-content.ts +0 -57
- package/src/business/pipeline/middlewares/guard-command.test.ts +0 -156
- package/src/business/pipeline/middlewares/guard-command.ts +0 -44
- package/src/business/pipeline/middlewares/guard-group-command.test.ts +0 -144
- package/src/business/pipeline/middlewares/guard-group-command.ts +0 -54
- package/src/business/pipeline/middlewares/guard-send-access.test.ts +0 -97
- package/src/business/pipeline/middlewares/guard-send-access.ts +0 -137
- package/src/business/pipeline/middlewares/guard-special-command.test.ts +0 -183
- package/src/business/pipeline/middlewares/guard-special-command.ts +0 -125
- package/src/business/pipeline/middlewares/index.ts +0 -21
- package/src/business/pipeline/middlewares/prepare-sender.test.ts +0 -151
- package/src/business/pipeline/middlewares/prepare-sender.ts +0 -50
- package/src/business/pipeline/middlewares/record-member.test.ts +0 -80
- package/src/business/pipeline/middlewares/record-member.ts +0 -20
- package/src/business/pipeline/middlewares/resolve-mention.test.ts +0 -149
- package/src/business/pipeline/middlewares/resolve-mention.ts +0 -80
- package/src/business/pipeline/middlewares/resolve-quote.test.ts +0 -67
- package/src/business/pipeline/middlewares/resolve-quote.ts +0 -21
- package/src/business/pipeline/middlewares/resolve-route.test.ts +0 -107
- package/src/business/pipeline/middlewares/resolve-route.ts +0 -37
- package/src/business/pipeline/middlewares/resolve-trace.ts +0 -25
- package/src/business/pipeline/middlewares/rewrite-body.test.ts +0 -142
- package/src/business/pipeline/middlewares/rewrite-body.ts +0 -68
- package/src/business/pipeline/middlewares/skip-placeholder.test.ts +0 -134
- package/src/business/pipeline/middlewares/skip-placeholder.ts +0 -58
- package/src/business/pipeline/middlewares/skip-self.test.ts +0 -44
- package/src/business/pipeline/middlewares/skip-self.ts +0 -16
- package/src/business/pipeline/test-helpers/mock-ctx.ts +0 -125
- package/src/business/pipeline/types.ts +0 -108
- package/src/business/tools/group.ts +0 -89
- package/src/business/tools/index.ts +0 -32
- package/src/business/tools/member.ts +0 -199
- package/src/business/tools/remind.ts +0 -396
- package/src/business/trace/context.ts +0 -116
- package/src/business/utils/markdown.ts +0 -491
- package/src/business/utils/media.ts +0 -598
- package/src/business/utils/utils.test.ts +0 -51
- package/src/business/utils/utils.ts +0 -96
- package/src/channel-shared.ts +0 -126
- package/src/channel.setup.ts +0 -31
- package/src/channel.ts +0 -212
- package/src/config-schema.ts +0 -125
- package/src/dispatcher/debouncer/index.ts +0 -283
- package/src/dispatcher/queue/session-abort-manager.ts +0 -49
- package/src/dispatcher/queue/session-queue.ts +0 -69
- package/src/infra/cache/member.ts +0 -478
- package/src/infra/cache/ttl-db.test.ts +0 -71
- package/src/infra/cache/ttl-db.ts +0 -93
- package/src/infra/env.ts +0 -58
- package/src/infra/transport.ts +0 -160
- package/src/logger.ts +0 -238
- package/src/runtime.ts +0 -11
- package/src/setup-core.ts +0 -82
- package/src/setup-surface.ts +0 -150
- package/src/types.ts +0 -219
package/dist/api.d.ts
CHANGED
package/dist/api.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelEntryContract<import("openclaw/plugin-sdk
|
|
1
|
+
declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelEntryContract<import("openclaw/plugin-sdk").ChannelPlugin>;
|
|
2
2
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { defineBundledChannelEntry, loadBundledEntryExportSync, } from "openclaw/plugin-sdk/channel-entry-contract";
|
|
2
|
+
import { YUANBAO_PLUGIN_ID } from "./src/channel-shared.js";
|
|
3
|
+
/** 懒加载注册工具 */
|
|
2
4
|
function registerTools(api) {
|
|
3
5
|
const register = loadBundledEntryExportSync(import.meta.url, {
|
|
4
6
|
specifier: "./api.js",
|
|
@@ -6,6 +8,7 @@ function registerTools(api) {
|
|
|
6
8
|
});
|
|
7
9
|
register(api);
|
|
8
10
|
}
|
|
11
|
+
/** Lazy-load and register all slash commands */
|
|
9
12
|
function registerCommands(api) {
|
|
10
13
|
const yuanbaoUpgradeCommand = loadBundledEntryExportSync(import.meta.url, { specifier: "./api.js", exportName: "yuanbaoUpgradeCommand" });
|
|
11
14
|
const yuanbaobotUpgradeCommand = loadBundledEntryExportSync(import.meta.url, { specifier: "./api.js", exportName: "yuanbaobotUpgradeCommand" });
|
|
@@ -14,6 +17,7 @@ function registerCommands(api) {
|
|
|
14
17
|
api.registerCommand(yuanbaobotUpgradeCommand);
|
|
15
18
|
api.registerCommand(logUploadCommandDefinition);
|
|
16
19
|
}
|
|
20
|
+
/** 懒加载初始化内置表情缓存 */
|
|
17
21
|
function initBuiltinStickers() {
|
|
18
22
|
const init = loadBundledEntryExportSync(import.meta.url, {
|
|
19
23
|
specifier: "./api.js",
|
|
@@ -21,6 +25,7 @@ function initBuiltinStickers() {
|
|
|
21
25
|
});
|
|
22
26
|
init();
|
|
23
27
|
}
|
|
28
|
+
/** 懒加载初始化环境变量 */
|
|
24
29
|
function initEnv(api) {
|
|
25
30
|
const init = loadBundledEntryExportSync(import.meta.url, {
|
|
26
31
|
specifier: "./api.js",
|
|
@@ -28,6 +33,7 @@ function initEnv(api) {
|
|
|
28
33
|
});
|
|
29
34
|
init(api);
|
|
30
35
|
}
|
|
36
|
+
/** 懒加载初始化日志 */
|
|
31
37
|
function initLogger(api) {
|
|
32
38
|
const init = loadBundledEntryExportSync(import.meta.url, {
|
|
33
39
|
specifier: "./api.js",
|
|
@@ -36,7 +42,7 @@ function initLogger(api) {
|
|
|
36
42
|
init(api);
|
|
37
43
|
}
|
|
38
44
|
export default defineBundledChannelEntry({
|
|
39
|
-
id:
|
|
45
|
+
id: YUANBAO_PLUGIN_ID,
|
|
40
46
|
name: "YuanBao",
|
|
41
47
|
description: "YuanBao channel plugin",
|
|
42
48
|
importMetaUrl: import.meta.url,
|
package/dist/setup-entry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelSetupEntryContract<import("openclaw/plugin-sdk
|
|
1
|
+
declare const _default: import("openclaw/plugin-sdk/channel-entry-contract").BundledChannelSetupEntryContract<import("openclaw/plugin-sdk").ChannelPlugin>;
|
|
2
2
|
export default _default;
|
package/dist/src/access/api.d.ts
CHANGED
|
@@ -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";
|
package/dist/src/access/api.js
CHANGED
|
@@ -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 { 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;
|