@xopcai/xopc 0.0.463 → 0.0.465
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/browser-ext/dist/sidepanel.js +5 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/adapters/cli-login.js +23 -49
- package/dist/extensions/feishu/src/adapters/gateway-setup.d.ts +3 -0
- package/dist/extensions/feishu/src/adapters/gateway-setup.js +180 -128
- package/dist/extensions/feishu/src/adapters/onboard-cli.d.ts +1 -1
- package/dist/extensions/feishu/src/adapters/onboard-cli.js +27 -15
- package/dist/extensions/feishu/src/auth/app-registration.d.ts +1 -0
- package/dist/extensions/feishu/src/auth/app-registration.js +12 -9
- package/dist/extensions/feishu/src/outbound/outbound-adapter.js +40 -16
- package/dist/extensions/feishu/src/plugin.d.ts +2 -0
- package/dist/extensions/feishu/src/plugin.js +37 -23
- package/dist/extensions/feishu/src/status/status-adapter.d.ts +1 -1
- package/dist/extensions/feishu/src/status/status-adapter.js +8 -5
- package/dist/extensions/feishu/src/streaming/streaming-adapter.js +97 -69
- package/dist/extensions/feishu/src/transport/client/bot-info.d.ts +10 -0
- package/dist/extensions/feishu/src/transport/client/bot-info.js +34 -0
- package/dist/extensions/feishu/src/transport/client/client.d.ts +7 -1
- package/dist/extensions/feishu/src/transport/client/client.js +6 -5
- package/dist/extensions/feishu/src/transport/client/install-sdk.d.ts +2 -0
- package/dist/extensions/feishu/src/transport/client/install-sdk.js +77 -0
- package/dist/extensions/feishu/src/transport/client/lark-sdk.d.ts +2 -0
- package/dist/extensions/feishu/src/transport/client/lark-sdk.js +27 -3
- package/dist/extensions/feishu/src/transport/client/sdk-catalog.d.ts +1 -0
- package/dist/extensions/feishu/src/transport/client/sdk-catalog.js +317 -0
- package/dist/extensions/feishu/src/transport/reliability/inbound-pipeline.d.ts +1 -1
- package/dist/extensions/feishu/src/transport/reliability/inbound-pipeline.js +13 -5
- package/dist/extensions/feishu/src/transport/reliability/message-ingress.d.ts +21 -0
- package/dist/extensions/feishu/src/transport/reliability/message-ingress.js +313 -0
- package/dist/extensions/feishu/src/transport/socket-mode/monitor.d.ts +1 -0
- package/dist/extensions/feishu/src/transport/socket-mode/monitor.js +56 -171
- package/dist/extensions/feishu/src/transport/webhook/monitor.d.ts +1 -0
- package/dist/extensions/feishu/src/transport/webhook/monitor.js +10 -102
- package/dist/extensions/telegram/src/account-manager.d.ts +1 -0
- package/dist/extensions/telegram/src/account-manager.js +3 -0
- package/dist/extensions/telegram/src/adapters/debounce-keys.js +7 -2
- package/dist/extensions/telegram/src/adapters/gateway-setup.js +113 -63
- package/dist/extensions/telegram/src/adapters/streaming-adapter.js +8 -4
- package/dist/extensions/telegram/src/doctor.js +1 -1
- package/dist/extensions/telegram/src/inbound-coalescer.d.ts +8 -6
- package/dist/extensions/telegram/src/inbound-coalescer.js +47 -88
- package/dist/extensions/telegram/src/inbound-processor.js +5 -1
- package/dist/extensions/telegram/src/outbound-sender.js +16 -23
- package/dist/extensions/telegram/src/plugin.js +80 -57
- package/dist/extensions/telegram/src/polling-session.d.ts +3 -6
- package/dist/extensions/telegram/src/polling-session.js +107 -94
- package/dist/extensions/telegram/src/rich-message.d.ts +4 -0
- package/dist/extensions/telegram/src/rich-message.js +23 -0
- package/dist/extensions/telegram/src/timeout-abort.d.ts +1 -1
- package/dist/extensions/telegram/src/timeout-abort.js +9 -3
- package/dist/extensions/telegram/src/update-offset-store.d.ts +1 -0
- package/dist/extensions/telegram/src/update-offset-store.js +6 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/api/api.d.ts +1 -0
- package/dist/extensions/weixin/src/api/api.js +12 -6
- package/dist/extensions/weixin/src/api/types.d.ts +5 -2
- package/dist/extensions/weixin/src/auth/login-qr.d.ts +7 -1
- package/dist/extensions/weixin/src/auth/login-qr.js +48 -13
- package/dist/extensions/weixin/src/cdn/pic-decrypt.d.ts +2 -2
- package/dist/extensions/weixin/src/cdn/pic-decrypt.js +37 -25
- package/dist/extensions/weixin/src/cli/gateway-qr-login.d.ts +8 -0
- package/dist/extensions/weixin/src/cli/gateway-qr-login.js +45 -6
- package/dist/extensions/weixin/src/cli/qr-login.d.ts +1 -1
- package/dist/extensions/weixin/src/cli/qr-login.js +9 -3
- package/dist/extensions/weixin/src/media/media-download.d.ts +1 -0
- package/dist/extensions/weixin/src/media/media-download.js +4 -5
- package/dist/extensions/weixin/src/messaging/process-message.d.ts +2 -0
- package/dist/extensions/weixin/src/messaging/process-message.js +90 -65
- package/dist/extensions/weixin/src/messaging/quote-cache.d.ts +10 -0
- package/dist/extensions/weixin/src/messaging/quote-cache.js +46 -0
- package/dist/extensions/weixin/src/monitor/monitor.d.ts +3 -3
- package/dist/extensions/weixin/src/monitor/monitor.js +108 -104
- package/dist/extensions/weixin/src/plugin.d.ts +5 -1
- package/dist/extensions/weixin/src/plugin.js +138 -42
- package/dist/gateway/static/root/assets/{activity-store-CQHh48Zf.js → activity-store-B9heFbtJ.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CAz-Ke6Q.js → agent-avatar-dicebear-nzhB7Xjk.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-loBdGw_i.js → agent-avatar-display-DBzgoHMD.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-By2Q-6JS.js → agent-defaults-settings-panel-BJrNV93g.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-C_rlXuEe.js → agent-plugin-dialog-DLbTHALG.js} +1 -1
- package/dist/gateway/static/root/assets/agents-C2xG8f56.js +77 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-D0N09mqJ.js → agents-admin-api-CqQbYIiY.js} +1 -1
- package/dist/gateway/static/root/assets/{api-B1J5ajiP.js → api-8tNOT72p.js} +1 -1
- package/dist/gateway/static/root/assets/{api-B4FJ51EC.js → api-BGodd--L.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BHlUDZOG.js → app-management-settings-panel-Q7apF7KE.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Du5JLyV1.js → appearance-settings-ClVZeUmo.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-D1qzENN_.js → apps-page-BsJJwpKj.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BAvglLfu.js → archive-plugin-Bl_M0WJp.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-DxBmyzp0.js → automation-api-BOnIc_vw.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-result-state-CAsqgMNR.js → automation-result-state-BwDSJs05.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-run-list-BmYeWB_N.js → automation-run-list-CqlIq4BG.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-task-card-CJbIHRxN.js → automation-task-card-D3WXVKRs.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-HYFnPiNG.js → automations-page-Bimqx5Pc.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-2SOvmw-f.js +9 -0
- package/dist/gateway/static/root/assets/{binary-plugins-D2bFqG6K.js → binary-plugins-DDNKe1Io.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DrZyRQQ0.js → block-editor-BQ3amsRP.js} +5 -5
- package/dist/gateway/static/root/assets/{browser-settings-page-CGcgZOWh.js → browser-settings-page-CHf1_RVl.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-hSb-qEgL.js → capabilities-C5oWMC-Z.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-Dr-vvMez.js → capabilities-Cj8vl1ZY.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-U_hQx5ou.js +2 -0
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-B08mjrGB.js → capabilities-settings-panel-k5CcwhXN.js} +1 -1
- package/dist/gateway/static/root/assets/channels-BUzno8Pi.js +1 -0
- package/dist/gateway/static/root/assets/chat-agents-api-C3JChTsh.js +1 -0
- package/dist/gateway/static/root/assets/{chat-chart-block-ClCZyIi0.js → chat-chart-block-DrtmYOIo.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-page-CalELOKj.js → chat-page-qnsMsF_s.js} +29 -29
- package/dist/gateway/static/root/assets/{chat-terminal-dock-eneTvxV3.js → chat-terminal-dock-B0D220I-.js} +1 -1
- package/dist/gateway/static/root/assets/{command-palette-api-CP0F6sIm.js → command-palette-api-CkJ6_Yf3.js} +1 -1
- package/dist/gateway/static/root/assets/composer-handoff-params-GKGdXjMZ.js +1 -0
- package/dist/gateway/static/root/assets/{composer-model-config-control-DAagrRx_.js → composer-model-config-control-DQCOWHzJ.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-notifications-CqV6Xj-H.js → composer-notifications-D__OU_xx.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-payload-handoff-Dc43dgSg.js → composer-payload-handoff-BBTbJ1bO.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-f-vcEpeF.js → computer-settings-page-DGRUCkOt.js} +1 -1
- package/dist/gateway/static/root/assets/{connected-providers-grid-CZ-FXxaW.js → connected-providers-grid-BoDipD2g.js} +1 -1
- package/dist/gateway/static/root/assets/{connection-usage-guide-Cibh2lrV.js → connection-usage-guide-B1VUqibv.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-Btz68iy8.js → connector-service-page-bwQ1PekA.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-CTuVWwBf.js → connectors-api-BvYGL65q.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-B9mpz_Rt.js → connectors-page-BX6Jt6w5.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-XnE3iFhG.js → date-picker-ClRDaNBJ.js} +1 -1
- package/dist/gateway/static/root/assets/{date-time-picker-VGKm0HVn.js → date-time-picker-CA6H47M6.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CBm3DySQ.js → desktop-pet-Bi8Hgf-x.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-6O77QXGo.js → desktop-pet-settings-CQ6qE8lf.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-B8fGILny.js → dev-view-store-UCqQeWa2.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-qtUvtdDT.js → device-pairing-wizard-gC-XZxt2.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-ByDqf5fE.js → directory-picker-path-field-Y8snl5Xl.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-authoritative-grants-BfL8dMBf.js → extension-authoritative-grants-D2abOXTl.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-Bn_5xu_M.js → extension-debug-page-OOlRCInL.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-Vs6USa0c.js → extension-iframe-host-D_WXBf6a.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-BIzkukYp.js → extension-marketplace-api-Bmtm6-L1.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-GIekDj_w.js → extension-message-router-xqjjSxcp.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C_3bIjSB.js → extension-page-bpQnyNz-.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-D-LolObs.js → extension-provider-l7SvHEK1.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BvUtZGLT.js +1 -0
- package/dist/gateway/static/root/assets/{file-preview-surface-i5UOFnQF.js → file-preview-surface-B-r2ZnCV.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-1Rk0LeEM.js → gateway-config-swr-DOwezeL2.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-DIs1pjkQ.js → gateway-realtime-Br7dErHY.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-OaEqjNTb.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-DTmlcJps.js → gateway-restart-B3Xro3qd.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-ClcCloqQ.js → gateway-settings-DCnP-HPj.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-D6WPS0RW.js → gateway-startup-retry-vteSIhYI.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-BpDMnJe7.js → global-defaults-api-Bpje9rVk.js} +1 -1
- package/dist/gateway/static/root/assets/grip-horizontal-CqVA8V1e.js +1 -0
- package/dist/gateway/static/root/assets/home-page-CNEgNWEQ.js +8 -0
- package/dist/gateway/static/root/assets/{image-generation-api-sbtx4NiC.js → image-generation-api-BvpAa3Lj.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-CBlaxUhl.js → imports-page-Dx5T5pqw.js} +1 -1
- package/dist/gateway/static/root/assets/index-Cdo4_zon.js +11 -0
- package/dist/gateway/static/root/assets/index-DYTktubl.css +1 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-DxSv1wS2.js → install-connector-dialog-Cb4ufypG.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CnAV96nr.js → keyboard-shortcuts-settings-BEuXrnv0.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CfnixDO3.js → local-app-workbench-page-CPFIbEbv.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-BI3Be5qo.js → local-apps-page-DxHcRSxc.js} +1 -1
- package/dist/gateway/static/root/assets/local-session-drafts-Cmc-GCVa.js +4 -0
- package/dist/gateway/static/root/assets/{locale-store-Dy1EByeG.js → locale-store-tI9VX7dp.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CMW34T31.js → logs-page-BcibwftP.js} +1 -1
- package/dist/gateway/static/root/assets/{management-api-B5w5DdXH.js → management-api-C9tFjLcE.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-DfcMIqbQ.js → management-settings-DbnAlXoB.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-CNJaAdNN.js → markdown-view-CSpQhSka.js} +1 -1
- package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-DCIEL5bA.js → mcp-conversation-setup-page-DedbjJbF.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DGhWjPIU.js → media-plugins-BYnP_orq.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-BAnhwALN.js → messages-e5MhDONm.js} +2 -2
- package/dist/gateway/static/root/assets/{model-selector-C-CqPBao.js → model-selector-B4oTiJI6.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-Bgh3Gfgl.js → models-hub-cache-DpEClnsE.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-DsXb1qjW.js → note-detail-panel-D8asMfBm.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-DcDw5kp4.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-BOIM9Q_D.js → notes-api-pVC1amyp.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BTpiOw67.js → notes-page-CG1_6PLz.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-B560CHeD.js → oauth-api-BsVPwufr.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-D63M8Iv7.js → oauth-provider-connect-Bu20kmPq.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-B_Vdo2Ai.js → page-context-capture-button-CDsnNXjS.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-Cr5GqS2D.js → page-context-draft-D6tu8c_9.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-DeaRqZgV.js +1 -0
- package/dist/gateway/static/root/assets/panels-top-left-BKvp2Dag.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-BMRVyTrE.js → personal-avatar-BboNc6e2.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-I3IGVSJh.js → personal-page-gMRmLCWG.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-profile-settings-C4CxmQLQ.js → personal-profile-settings-Cd4QyseL.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-CnxI2TL0.js → personal-settings-panel-CtBY_Uk1.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-flTci8mm.js → phone-dependencies-card-BgH1LluB.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-connection-Vi_Swyv6.js → phone-model-connection-DkdKU5Kv.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-BOv3mb_F.js → phone-model-picker-0g1z4RPL.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-vD0bTcHj.js → phone-settings-page-DlIUajBY.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-Ltrevdsx.js → phone-workspace-store-DW2sZtkh.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-F08k_k2u.js → plugin-details-dialog-9KUkZk_t.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-D1pZekPs.js → preference-select-fields-DH5QZhIc.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-CGso8wGv.js → product-automation-feedback-a1thJ0M9.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BO8lUvw3.js → product-open-page-DCzQh7tr.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-Dgtb4LF7.js → product-preview-content-C5TLcagj.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-C35EWUps.js → product-preview-modal-D9f-7kcI.js} +2 -2
- package/dist/gateway/static/root/assets/{project-detail-page-Dy46uSEt.js → project-detail-page-C4Z2HTRZ.js} +2 -2
- package/dist/gateway/static/root/assets/{project-understanding-Cg8WbBNB.js → project-understanding-CoPBvlqf.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-C6Pt6OdT.js → projects-page-k1v8Fry8.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-Nytkkop9.js → providers-api-BSJZyO8n.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-CFX7CANT.js → recording-upload-CExCePtr.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-DuDIthjL.js → registry-api-CqcJj60w.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-DePwafOK.js → remote-access-hub-BLFkNl1y.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-BRKhKJA0.js → resource-unavailable-B_BXTQa7.js} +1 -1
- package/dist/gateway/static/root/assets/{right-workspace-store-HPw7Gw0n.js → right-workspace-store-OceFhUjM.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-ClsAFFQc.js +2 -0
- package/dist/gateway/static/root/assets/{routine-panel-KH1VaEdC.js → routine-panel-BsE9o9uu.js} +2 -2
- package/dist/gateway/static/root/assets/{runtime-tools-api-Dd8a07eo.js → runtime-tools-api-aAZChVm4.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CvHQoqHu.js → runtime-tools-settings-panel-Bn9HTrK5.js} +1 -1
- package/dist/gateway/static/root/assets/schema-form-BxBDgLrg.js +1 -0
- package/dist/gateway/static/root/assets/{service-recommendation-list-BmRtbJz2.js → service-recommendation-list-BNIVRGDf.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-BFiIYodK.js → session-api-DdW7Wix2.js} +1 -1
- package/dist/gateway/static/root/assets/session-channel-icon-DUJbB-Km.js +1 -0
- package/dist/gateway/static/root/assets/{session-identity-label-D5SAi0Uh.js → session-identity-label-DjhlQ6LU.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-XgtApqIh.js +25 -0
- package/dist/gateway/static/root/assets/sessions-page-CfhKeUkZ.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BBG8dTIY.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-B-H1gYOs.js → settings-advanced-section-BOoJfJuB.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-YH60sibB.js → settings-mode-store-BMh_BQ9a.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-C39lKVRv.js → settings-page-M6XwzIyu.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-DEZZ8D0S.js → settings-page-header-Bfu4cuQd.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-De2j64Lo.js → settings-page-layout-BnZa1qHH.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-interaction-page-Dh6BPwv0.js → setup-interaction-page-CVlrVNrm.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-DGAAczL-.js → setup-status-panel-FFyDODEx.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-C1t_HB6f.js → share-link-dialog-Cv-eDEw_.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-Cqy-7-rd.js → share-preview-page-BctH6eFs.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-Dm07CnXw.js → shares-api-cLTEcQLE.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DcetAN8K.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-BV8oFqeE.js → skill-api-CgEZJoy9.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-1o_YRCu9.js → skill-list-api-BWVr2PL5.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-fGsO9Y86.js → skill-reload-api-BLhHNvaK.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DReUQ4Ug.js → skills-page-DIjcAvA0.js} +1 -1
- package/dist/gateway/static/root/assets/sliding-segmented-DagP0myu.js +1 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CUI6QHEP.js → system-settings-panel-C7LAPaN_.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-D1dNWTnP.js → task-detail-page-DmNEMg-l.js} +1 -1
- package/dist/gateway/static/root/assets/{task-result-evidence-CW_tN93T.js → task-result-evidence-BsBn3n_l.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-Du53Upr2.js → terminal-panel-store-DJbLuUku.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BaWep_o7.js → theme-store-QGcjV6pN.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-CnciBMVH.js → tracing-settings-page-BKCiPwYL.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-Iz7JCBt3.js → tunnel-api-S7J5Lpzt.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-BFc8PamJ.js → understanding-activity-store-BNVhtJkn.js} +1 -1
- package/dist/gateway/static/root/assets/understanding-refresh-store-CM6bUcaJ.js +1 -0
- package/dist/gateway/static/root/assets/undo-2-6IMTwK4M.js +1 -0
- package/dist/gateway/static/root/assets/{unlink-BEuthaaq.js → unlink-NsCMuCT1.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-DL2fmeOh.js → usage-page-D-AqzjIx.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-N_SjHXTw.js → use-autosave-CqZbhhCc.js} +1 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-BfLhIb2_.js +2 -0
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-D0IBFhM9.js → use-file-preview-expanded-DufxDues.js} +3 -3
- package/dist/gateway/static/root/assets/{use-personal-profile-C1vqD9yV.js → use-personal-profile-RnjxZnLa.js} +1 -1
- package/dist/gateway/static/root/assets/{use-realtime-voice-B5IsKrRW.js → use-realtime-voice-w3aHR2dr.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-7X2ydgS8.js → use-workspace-tree-2Ck-ql5c.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CBcGMhrR.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-B_GApUQP.js → voice-api-key-field-C4rhpgco.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-DhJ3l8fk.js → voice-config-api-7AHN-ns6.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-CEeFBhp3.js → voice-input-shortcut-events-BbRrj833.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-57pwZeKD.js → voice-settings-wamtp0lg.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BJ15p4rH.js → work-discovery-overlay-fVofN7aP.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-8XciWNs5.js → work-discovery-page-DcQG5GWy.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-BGZduAXV.js → working-directory-picker-modal-D8Stwszr.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-Dd_UDfeo.js → workspace-api-D3iuTdNK.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-C-J7vr2o.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-Clj9hMj5.js → workspace-file-preview-dialog-BXbL5Y1h.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-CvZxU9de.js → workspace-open-location-menu-1gFO_BdL.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-preview-store-imhtuEIP.js → workspace-preview-store-adwmi4nx.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-Q_jezTUy.js → xopc-cloud-account-card-DhGh4rm7.js} +1 -1
- package/dist/gateway/static/root/index.html +97 -93
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/session-input-command.js +5 -0
- package/dist/src/agent/inbound/inbound-loop.js +14 -0
- package/dist/src/agent/messaging/outbound-coordinator.js +1 -1
- package/dist/src/agent/prompt/response-language.js +9 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +3 -0
- package/dist/src/channels/connection-probe.d.ts +23 -0
- package/dist/src/channels/connection-probe.js +98 -0
- package/dist/src/channels/manager.d.ts +2 -0
- package/dist/src/channels/manager.js +5 -0
- package/dist/src/channels/message-journal.d.ts +25 -0
- package/dist/src/channels/message-journal.js +79 -0
- package/dist/src/channels/outbound-sender.d.ts +8 -0
- package/dist/src/channels/outbound-sender.js +60 -1
- package/dist/src/channels/plugins/types.adapters.d.ts +4 -0
- package/dist/src/channels/verified-inbound.js +20 -14
- package/dist/src/cli/commands/gateway/lifecycle.js +2 -2
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/config/schema.d.ts +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
- package/dist/src/gateway/hono/middleware/auth.js +1 -1
- package/dist/src/gateway/hono/routes/channels.js +23 -10
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/desktop-host.js +1 -1
- package/dist/src/gateway/hono/routes/imports.js +1 -1
- package/dist/src/gateway/hono/routes/personal-agent.js +3 -3
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/hono/routes/user-model.js +48 -20
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +2 -2
- package/dist/src/gateway/service/agent-runner.js +1 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service.js +8 -8
- package/dist/src/i18n/response-language.d.ts +1 -1
- package/dist/src/infra/bus/index.d.ts +1 -1
- package/dist/src/infra/bus/queue.d.ts +16 -3
- package/dist/src/infra/bus/queue.js +74 -3
- package/dist/src/infra/debounce.d.ts +1 -0
- package/dist/src/infra/debounce.js +40 -35
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +2 -2
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/knowledge-memory/index.js +2 -2
- package/dist/src/knowledge-memory/repository.d.ts +9 -0
- package/dist/src/knowledge-memory/repository.js +12 -2
- package/dist/src/notifications/service.js +2 -2
- package/dist/src/phone/stream-gateway.js +1 -1
- package/dist/src/runtime-tools/types.d.ts +1 -1
- package/dist/src/storage/sqlite/session-creation-repository.js +6 -1
- package/dist/src/user-context/config.d.ts +1 -1
- package/package.json +4 -5
- package/dist/extensions/demo-memory/src/index.d.ts +0 -6
- package/dist/extensions/demo-memory/src/index.js +0 -146
- package/dist/extensions/demo-memory/xopc.extension.json +0 -15
- package/dist/gateway/static/root/assets/agents-DC0lHtl5.js +0 -77
- package/dist/gateway/static/root/assets/automations-workspace-JCQ1IXFk.js +0 -9
- package/dist/gateway/static/root/assets/capabilities-page-kPv2dOzf.js +0 -2
- package/dist/gateway/static/root/assets/channels-B--IHNs4.js +0 -1
- package/dist/gateway/static/root/assets/chat-agents-api-CjlzCSmC.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BV51dk16.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-sx7B8kdC.js +0 -1
- package/dist/gateway/static/root/assets/home-page-DefKShSW.js +0 -8
- package/dist/gateway/static/root/assets/index-CChzK_5b.css +0 -1
- package/dist/gateway/static/root/assets/index-DUo6H0PC.js +0 -11
- package/dist/gateway/static/root/assets/local-session-drafts-BIBHRkpM.js +0 -4
- package/dist/gateway/static/root/assets/note-image-lightbox-D6mvMSKr.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-Bm8oxpFR.js +0 -1
- package/dist/gateway/static/root/assets/route-preload-ChTaYgpA.js +0 -2
- package/dist/gateway/static/root/assets/schema-form-C9TYGa0_.js +0 -1
- package/dist/gateway/static/root/assets/session-channel-icon-BzkFo-Ci.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-63NaXb1s.js +0 -25
- package/dist/gateway/static/root/assets/sessions-page-DQEq_VJS.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Cvx7DnU8.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BDr50uTV.js +0 -1
- package/dist/gateway/static/root/assets/sliding-segmented-CgQ3BFdb.js +0 -1
- package/dist/gateway/static/root/assets/understanding-refresh-store-CdEfR40A.js +0 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-Xn6eUus2.js +0 -2
- package/dist/gateway/static/root/assets/user-model-page-D2FHjLi7.js +0 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-DVPJcbuE.js +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { persistInboundAttachments } from "../../../../src/channels/attachments/inbound-persist.js";
|
|
1
2
|
import { resolveWeixinRootDir } from "../storage/state-dir.js";
|
|
2
3
|
import { logger } from "../util/logger.js";
|
|
3
4
|
import { resolveWeixinPairingPath } from "../../../../src/channels/pairing/paths.js";
|
|
4
5
|
import { issuePairingChallenge } from "../../../../src/channels/pairing/pairing-challenge.js";
|
|
5
6
|
import { evaluateAccess } from "../../../../src/channels/security.js";
|
|
7
|
+
import { handleChannelConnectionProbe } from "../../../../src/channels/connection-probe.js";
|
|
6
8
|
import { MessageItemType } from "../api/types.js";
|
|
7
9
|
import { isMediaItem, setContextToken, weixinMessageToMsgContext } from "./inbound.js";
|
|
8
10
|
import { readFrameworkAllowFromList } from "../auth/pairing.js";
|
|
@@ -10,10 +12,11 @@ import { downloadMediaFromItem } from "../media/media-download.js";
|
|
|
10
12
|
import { isDebugMode } from "./debug-mode.js";
|
|
11
13
|
import { sendMessageWeixin } from "./send.js";
|
|
12
14
|
import { handleSlashCommand } from "./slash-commands.js";
|
|
15
|
+
import { getWeixinQuotedMessage, rememberWeixinQuotedMessage } from "./quote-cache.js";
|
|
13
16
|
import { generateWeixinConversationIdWithRouting } from "../routing-integration.js";
|
|
14
17
|
import path from "node:path";
|
|
15
18
|
import { randomBytes } from "node:crypto";
|
|
16
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
19
|
+
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
17
20
|
//#region extensions/weixin/src/messaging/process-message.ts
|
|
18
21
|
function extractTextBody(itemList) {
|
|
19
22
|
if (!itemList?.length) return "";
|
|
@@ -25,7 +28,7 @@ function mergeAllowFrom(account, accountId) {
|
|
|
25
28
|
return [...new Set([...(account.allowFrom ?? []).map(String), ...store])];
|
|
26
29
|
}
|
|
27
30
|
async function saveMediaBuffer(buffer, contentType, _subdir, maxBytes, originalFilename) {
|
|
28
|
-
const cap = maxBytes ??
|
|
31
|
+
const cap = Math.min(maxBytes ?? Infinity, 5 * 1024 * 1024);
|
|
29
32
|
if (buffer.length > cap) throw new Error(`weixin media exceeds max bytes (${cap})`);
|
|
30
33
|
const dir = path.join(resolveWeixinRootDir(), "media", "inbound-temp");
|
|
31
34
|
await mkdir(dir, { recursive: true });
|
|
@@ -40,17 +43,22 @@ async function processWeixinInboundMessage(full, deps) {
|
|
|
40
43
|
const senderId = full.from_user_id ?? "";
|
|
41
44
|
if (full.context_token?.trim() && senderId) setContextToken(deps.accountId, senderId, full.context_token, { sendToUserId: senderId });
|
|
42
45
|
const textBody = extractTextBody(full.item_list);
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
if (senderId && full.context_token && await handleChannelConnectionProbe({
|
|
47
|
+
channel: "weixin",
|
|
48
|
+
accountId: deps.accountId,
|
|
49
|
+
senderId,
|
|
50
|
+
text: textBody,
|
|
51
|
+
reply: (text) => sendMessageWeixin({
|
|
52
|
+
to: senderId,
|
|
53
|
+
text,
|
|
54
|
+
opts: {
|
|
55
|
+
baseUrl: deps.baseUrl,
|
|
56
|
+
token: deps.token,
|
|
57
|
+
contextToken: full.context_token,
|
|
58
|
+
routeTag: deps.routeTag
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
})) return;
|
|
54
62
|
const mergedAllow = mergeAllowFrom(deps.account, deps.accountId);
|
|
55
63
|
const access = evaluateAccess({
|
|
56
64
|
context: {
|
|
@@ -94,63 +102,80 @@ async function processWeixinInboundMessage(full, deps) {
|
|
|
94
102
|
else logger.info(`weixin: dropped message from=${senderId} dmPolicy=${deps.account.dmPolicy ?? "open"} reason=${access.reason ?? "not allowed"}`);
|
|
95
103
|
return;
|
|
96
104
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
if (textBody.startsWith("/")) {
|
|
106
|
+
if ((await handleSlashCommand(textBody, {
|
|
107
|
+
to: full.from_user_id ?? "",
|
|
108
|
+
contextToken: full.context_token,
|
|
109
|
+
baseUrl: deps.baseUrl,
|
|
110
|
+
token: deps.token,
|
|
111
|
+
accountId: deps.accountId,
|
|
112
|
+
log: () => {},
|
|
113
|
+
errLog: () => {}
|
|
114
|
+
}, receivedAt, full.create_time_ms)).handled) return;
|
|
115
|
+
}
|
|
116
|
+
const currentAttachments = [];
|
|
117
|
+
const quotedAttachments = [];
|
|
118
|
+
const incoming = (full.item_list ?? []).filter((item) => isMediaItem(item) && !item.voice_item?.text);
|
|
119
|
+
const quoted = (full.item_list ?? []).flatMap((item) => {
|
|
120
|
+
const ref = item.ref_msg?.message_item;
|
|
121
|
+
return ref && isMediaItem(ref) && !ref.voice_item?.text ? [ref] : [];
|
|
122
|
+
});
|
|
123
|
+
let totalBytes = 0;
|
|
124
|
+
for (const [index, item] of [...incoming, ...quoted].slice(0, 8).entries()) {
|
|
125
|
+
deps.abortSignal?.throwIfAborted();
|
|
126
|
+
let savedPath;
|
|
127
|
+
try {
|
|
128
|
+
const media = await downloadMediaFromItem(item, {
|
|
129
|
+
cdnBaseUrl: deps.cdnBaseUrl,
|
|
130
|
+
saveMedia: saveMediaBuffer,
|
|
131
|
+
log: (m) => logger.debug(m),
|
|
132
|
+
errLog: (m) => logger.warn(m),
|
|
133
|
+
label: index < incoming.length ? "inbound" : "ref",
|
|
134
|
+
signal: deps.abortSignal
|
|
135
|
+
});
|
|
136
|
+
savedPath = media.decryptedPicPath ?? media.decryptedVoicePath ?? media.decryptedFilePath ?? media.decryptedVideoPath;
|
|
137
|
+
if (!savedPath) continue;
|
|
138
|
+
const type = media.decryptedPicPath ? "image" : media.decryptedVoicePath ? "audio" : "file";
|
|
139
|
+
const mimeType = media.decryptedPicPath ? "image/jpeg" : media.decryptedVoicePath ? media.voiceMediaType ?? "audio/wav" : media.decryptedVideoPath ? "video/mp4" : media.fileMediaType ?? "application/octet-stream";
|
|
140
|
+
const buffer = await readFile(savedPath);
|
|
141
|
+
if (totalBytes + buffer.length > 20 * 1024 * 1024) break;
|
|
142
|
+
totalBytes += buffer.length;
|
|
143
|
+
(index < incoming.length ? currentAttachments : quotedAttachments).push({
|
|
144
|
+
type,
|
|
145
|
+
mimeType,
|
|
146
|
+
data: buffer.toString("base64"),
|
|
147
|
+
name: path.basename(savedPath)
|
|
148
|
+
});
|
|
149
|
+
} catch (err) {
|
|
150
|
+
logger.warn({
|
|
151
|
+
accountId: deps.accountId,
|
|
152
|
+
errorType: err instanceof Error ? err.name : typeof err
|
|
153
|
+
}, "Weixin attachment could not be prepared");
|
|
154
|
+
} finally {
|
|
155
|
+
if (savedPath) await unlink(savedPath).catch(() => {});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const ctx = weixinMessageToMsgContext(full, deps.accountId);
|
|
159
|
+
let body = ctx.Body?.trim() ?? "";
|
|
160
|
+
const currentRefs = await persistInboundAttachments(currentAttachments);
|
|
161
|
+
const stableMessageId = full.message_id == null ? void 0 : String(full.message_id);
|
|
162
|
+
if (stableMessageId && deps.delivery) rememberWeixinQuotedMessage(deps.delivery.scope, senderId, stableMessageId, textBody || body, currentRefs);
|
|
163
|
+
if (deps.delivery) for (const item of full.item_list ?? []) {
|
|
164
|
+
const ref = item.ref_msg;
|
|
165
|
+
if (!ref?.svr_id || ref.message_item || ref.svr_id === stableMessageId) continue;
|
|
166
|
+
const cached = await getWeixinQuotedMessage(deps.delivery.scope, senderId, ref.svr_id);
|
|
167
|
+
if (!cached) continue;
|
|
168
|
+
if (!ref.title && cached.text) body = `[引用: ${cached.text}]\n${body}`;
|
|
169
|
+
quotedAttachments.push(...cached.attachments);
|
|
112
170
|
}
|
|
113
|
-
const
|
|
114
|
-
const body = ctx.Body?.trim() ?? "";
|
|
171
|
+
const attachments = [...currentRefs ?? [], ...quotedAttachments];
|
|
115
172
|
const conversationId = generateWeixinConversationIdWithRouting({
|
|
116
173
|
accountId: deps.accountId,
|
|
117
174
|
senderId
|
|
118
175
|
}, deps.config);
|
|
119
|
-
const attachments = [];
|
|
120
|
-
if (mediaOpts.decryptedPicPath) {
|
|
121
|
-
const buf = await readFile(mediaOpts.decryptedPicPath);
|
|
122
|
-
attachments.push({
|
|
123
|
-
type: "image",
|
|
124
|
-
mimeType: "image/jpeg",
|
|
125
|
-
data: buf.toString("base64"),
|
|
126
|
-
name: path.basename(mediaOpts.decryptedPicPath)
|
|
127
|
-
});
|
|
128
|
-
} else if (mediaOpts.decryptedVoicePath) {
|
|
129
|
-
const buf = await readFile(mediaOpts.decryptedVoicePath);
|
|
130
|
-
attachments.push({
|
|
131
|
-
type: "audio",
|
|
132
|
-
mimeType: mediaOpts.voiceMediaType ?? "audio/wav",
|
|
133
|
-
data: buf.toString("base64"),
|
|
134
|
-
name: path.basename(mediaOpts.decryptedVoicePath)
|
|
135
|
-
});
|
|
136
|
-
} else if (mediaOpts.decryptedFilePath) {
|
|
137
|
-
const buf = await readFile(mediaOpts.decryptedFilePath);
|
|
138
|
-
attachments.push({
|
|
139
|
-
type: "file",
|
|
140
|
-
mimeType: mediaOpts.fileMediaType ?? "application/octet-stream",
|
|
141
|
-
data: buf.toString("base64"),
|
|
142
|
-
name: path.basename(mediaOpts.decryptedFilePath)
|
|
143
|
-
});
|
|
144
|
-
} else if (mediaOpts.decryptedVideoPath) {
|
|
145
|
-
const buf = await readFile(mediaOpts.decryptedVideoPath);
|
|
146
|
-
attachments.push({
|
|
147
|
-
type: "file",
|
|
148
|
-
mimeType: "video/mp4",
|
|
149
|
-
data: buf.toString("base64"),
|
|
150
|
-
name: path.basename(mediaOpts.decryptedVideoPath)
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
176
|
if (isDebugMode(deps.accountId)) logger.debug(`weixin debug inbound from=${senderId} bodyLen=${body.length} attachments=${attachments.length}`);
|
|
177
|
+
deps.abortSignal?.throwIfAborted();
|
|
178
|
+
if (!body && !attachments.length) return;
|
|
154
179
|
await deps.bus.publishInbound({
|
|
155
180
|
channel: "weixin",
|
|
156
181
|
sender_id: senderId,
|
|
@@ -165,7 +190,7 @@ async function processWeixinInboundMessage(full, deps) {
|
|
|
165
190
|
contextToken: ctx.context_token
|
|
166
191
|
},
|
|
167
192
|
attachments: attachments.length ? attachments : void 0
|
|
168
|
-
});
|
|
193
|
+
}, deps.delivery);
|
|
169
194
|
}
|
|
170
195
|
//#endregion
|
|
171
196
|
export { processWeixinInboundMessage };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MediaRef } from '@xopcai/xopc/media/types.js';
|
|
2
|
+
type QuotedMessage = {
|
|
3
|
+
id: string;
|
|
4
|
+
text: string;
|
|
5
|
+
attachments: MediaRef[];
|
|
6
|
+
timestamp: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function rememberWeixinQuotedMessage(scope: string, sender: string, id: string, text: string, attachments?: MediaRef[]): void;
|
|
9
|
+
export declare function getWeixinQuotedMessage(scope: string, sender: string, id: string): Promise<QuotedMessage | undefined>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DurableState } from "../../../../src/storage/sqlite/durable-state.js";
|
|
2
|
+
import { resolveMediaReference } from "../../../../src/media/media-reference.js";
|
|
3
|
+
import { logger } from "../util/logger.js";
|
|
4
|
+
//#region extensions/weixin/src/messaging/quote-cache.ts
|
|
5
|
+
const cache = new DurableState("weixin-quoted-messages");
|
|
6
|
+
const RETENTION_MS = 10080 * 6e4;
|
|
7
|
+
const MAX_MESSAGES_PER_CHAT = 64;
|
|
8
|
+
function chatKey(scope, sender) {
|
|
9
|
+
return JSON.stringify([scope, sender]);
|
|
10
|
+
}
|
|
11
|
+
function rememberWeixinQuotedMessage(scope, sender, id, text, attachments) {
|
|
12
|
+
try {
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
cache.update(chatKey(scope, sender), (entries) => ({
|
|
15
|
+
value: [...(entries ?? []).filter((entry) => entry.id !== id && now - entry.timestamp <= RETENTION_MS).slice(-(MAX_MESSAGES_PER_CHAT - 1)), {
|
|
16
|
+
id,
|
|
17
|
+
text: text.slice(0, 4e3),
|
|
18
|
+
attachments: (attachments ?? []).slice(0, 8),
|
|
19
|
+
timestamp: now
|
|
20
|
+
}],
|
|
21
|
+
result: void 0
|
|
22
|
+
}));
|
|
23
|
+
} catch {
|
|
24
|
+
logger.debug("Weixin quote cache could not store the message");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function getWeixinQuotedMessage(scope, sender, id) {
|
|
28
|
+
try {
|
|
29
|
+
const now = Date.now();
|
|
30
|
+
const entry = cache.get(chatKey(scope, sender))?.find((row) => row.id === id && now - row.timestamp <= RETENTION_MS);
|
|
31
|
+
if (!entry) return;
|
|
32
|
+
const attachments = [];
|
|
33
|
+
for (const attachment of entry.attachments) try {
|
|
34
|
+
await resolveMediaReference(attachment.uri);
|
|
35
|
+
attachments.push(attachment);
|
|
36
|
+
} catch {}
|
|
37
|
+
return {
|
|
38
|
+
...entry,
|
|
39
|
+
attachments
|
|
40
|
+
};
|
|
41
|
+
} catch {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { getWeixinQuotedMessage, rememberWeixinQuotedMessage };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Config } from '@xopcai/xopc/config/schema.js';
|
|
2
2
|
import type { MessageBus } from '@xopcai/xopc/infra/bus/index.js';
|
|
3
3
|
import type { ResolvedWeixinAccount } from '../auth/accounts.js';
|
|
4
|
+
export type WeixinMonitorState = 'connecting' | 'polling' | 'reconnect-required';
|
|
4
5
|
export type MonitorWeixinOpts = {
|
|
5
6
|
account: ResolvedWeixinAccount;
|
|
6
7
|
config: Config;
|
|
7
8
|
bus: MessageBus;
|
|
8
9
|
abortSignal?: AbortSignal;
|
|
9
10
|
longPollTimeoutMs?: number;
|
|
11
|
+
onState?: (state: WeixinMonitorState) => void;
|
|
10
12
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Long-poll loop: getUpdates → process inbound.
|
|
13
|
-
*/
|
|
13
|
+
/** Persist each fetched batch before using the next platform cursor. */
|
|
14
14
|
export declare function monitorWeixinProvider(opts: MonitorWeixinOpts): Promise<void>;
|
|
@@ -1,131 +1,135 @@
|
|
|
1
|
-
import { loadGetUpdatesBuf
|
|
1
|
+
import { loadGetUpdatesBuf } from "../storage/sync-buf.js";
|
|
2
2
|
import { logger } from "../util/logger.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ChannelMessageJournal } from "../../../../src/channels/message-journal.js";
|
|
4
|
+
import { MessageItemType } from "../api/types.js";
|
|
4
5
|
import { getUpdates } from "../api/api.js";
|
|
5
6
|
import { WeixinConfigManager } from "../api/config-cache.js";
|
|
6
7
|
import { getRemainingPauseMs, pauseSession } from "../api/session-guard.js";
|
|
7
8
|
import { processWeixinInboundMessage } from "../messaging/process-message.js";
|
|
8
9
|
import { setWeixinTypingTicket } from "../messaging/typing-ticket-store.js";
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
import { setTimeout } from "node:timers/promises";
|
|
9
12
|
//#region extensions/weixin/src/monitor/monitor.ts
|
|
10
13
|
const DEFAULT_LONG_POLL_TIMEOUT_MS = 35e3;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const MAX_LONG_POLL_TIMEOUT_MS = 9e4;
|
|
15
|
+
function inboundId(message) {
|
|
16
|
+
const messageId = String(message.message_id ?? "");
|
|
17
|
+
const sequence = String(message.seq ?? "");
|
|
18
|
+
const identity = (messageId !== "0" ? messageId : "") || message.client_id || (sequence !== "0" ? sequence : "") || createHash("sha256").update(JSON.stringify(message)).digest("hex");
|
|
19
|
+
return JSON.stringify([message.from_user_id, String(identity)]);
|
|
20
|
+
}
|
|
21
|
+
/** Persist each fetched batch before using the next platform cursor. */
|
|
17
22
|
async function monitorWeixinProvider(opts) {
|
|
18
23
|
const { account, config, bus, abortSignal, longPollTimeoutMs } = opts;
|
|
19
|
-
const accountId = account
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const configLog = (msg) => {
|
|
30
|
-
aLog.debug(msg);
|
|
31
|
-
};
|
|
24
|
+
const { accountId, baseUrl, cdnBaseUrl, token, routeTag } = account;
|
|
25
|
+
const scope = JSON.stringify([accountId, baseUrl]);
|
|
26
|
+
const journal = new ChannelMessageJournal("weixin", scope);
|
|
27
|
+
const interrupted = journal.recoverInterrupted();
|
|
28
|
+
if (interrupted) logger.warn({
|
|
29
|
+
accountId,
|
|
30
|
+
interrupted
|
|
31
|
+
}, "Weixin messages interrupted during dispatch");
|
|
32
|
+
bus.restoreDurableInbound?.("weixin", scope);
|
|
33
|
+
let cursor = journal.cursor() ?? loadGetUpdatesBuf(accountId) ?? "";
|
|
32
34
|
const configManager = new WeixinConfigManager({
|
|
33
35
|
baseUrl,
|
|
34
36
|
token,
|
|
35
37
|
routeTag
|
|
36
|
-
},
|
|
37
|
-
let
|
|
38
|
+
}, (msg) => logger.debug(msg));
|
|
39
|
+
let timeoutMs = longPollTimeoutMs ?? DEFAULT_LONG_POLL_TIMEOUT_MS;
|
|
38
40
|
let consecutiveFailures = 0;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
abortSignal
|
|
50
|
-
});
|
|
51
|
-
aLog.debug(`getUpdates response: ret=${resp.ret}, msgs=${resp.msgs?.length ?? 0}, get_updates_buf_length=${resp.get_updates_buf?.length ?? 0}`);
|
|
52
|
-
if (resp.longpolling_timeout_ms != null && resp.longpolling_timeout_ms > 0) {
|
|
53
|
-
nextTimeoutMs = resp.longpolling_timeout_ms;
|
|
54
|
-
aLog.debug(`Updated next poll timeout: ${nextTimeoutMs}ms`);
|
|
55
|
-
}
|
|
56
|
-
if (resp.ret !== void 0 && resp.ret !== 0 || resp.errcode !== void 0 && resp.errcode !== 0) {
|
|
57
|
-
if (resp.errcode === -14 || resp.ret === -14) {
|
|
58
|
-
pauseSession(accountId);
|
|
59
|
-
const pauseMs = getRemainingPauseMs(accountId);
|
|
60
|
-
aLog.error(`getUpdates: session expired (errcode=${resp.errcode} ret=${resp.ret}), pausing all requests for ${Math.ceil(pauseMs / 6e4)} min`);
|
|
61
|
-
consecutiveFailures = 0;
|
|
62
|
-
await sleep(pauseMs, abortSignal);
|
|
63
|
-
continue;
|
|
41
|
+
opts.onState?.("connecting");
|
|
42
|
+
while (!abortSignal?.aborted) {
|
|
43
|
+
const pending = journal.pending();
|
|
44
|
+
if (pending.length) {
|
|
45
|
+
const senders = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const entry of pending) {
|
|
47
|
+
const sender = entry.payload.from_user_id ?? "";
|
|
48
|
+
const entries = senders.get(sender) ?? [];
|
|
49
|
+
entries.push(entry);
|
|
50
|
+
senders.set(sender, entries);
|
|
64
51
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
const groups = [...senders.values()];
|
|
53
|
+
for (let index = 0; index < groups.length; index += 4) await Promise.all(groups.slice(index, index + 4).map(async (entries) => {
|
|
54
|
+
for (const { id, payload } of entries) {
|
|
55
|
+
const text = payload.item_list?.find((item) => item.type === MessageItemType.TEXT)?.text_item?.text?.trim() ?? "";
|
|
56
|
+
const replayable = !text.startsWith("/") && !/^xopc_[a-f0-9]{32}$/.test(text);
|
|
57
|
+
if (abortSignal?.aborted || !journal.begin(id, replayable)) return;
|
|
58
|
+
try {
|
|
59
|
+
const senderId = payload.from_user_id;
|
|
60
|
+
if (senderId) configManager.getForUser(senderId, payload.context_token).then((cached) => {
|
|
61
|
+
if (!abortSignal?.aborted) setWeixinTypingTicket(accountId, senderId, cached.typingTicket);
|
|
62
|
+
}).catch(() => {});
|
|
63
|
+
await processWeixinInboundMessage(payload, {
|
|
64
|
+
account,
|
|
65
|
+
accountId,
|
|
66
|
+
config,
|
|
67
|
+
bus,
|
|
68
|
+
baseUrl,
|
|
69
|
+
cdnBaseUrl,
|
|
70
|
+
token,
|
|
71
|
+
routeTag,
|
|
72
|
+
delivery: {
|
|
73
|
+
scope,
|
|
74
|
+
id
|
|
75
|
+
},
|
|
76
|
+
abortSignal
|
|
77
|
+
});
|
|
78
|
+
journal.finish(id, "completed");
|
|
79
|
+
} catch (err) {
|
|
80
|
+
if (abortSignal?.aborted && replayable) return;
|
|
81
|
+
journal.finish(id, "interrupted");
|
|
82
|
+
logger.warn({
|
|
83
|
+
accountId,
|
|
84
|
+
errorType: err instanceof Error ? err.name : typeof err
|
|
85
|
+
}, "Weixin message dispatch interrupted");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
72
89
|
continue;
|
|
73
90
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
saveGetUpdatesBuf(accountId, resp.get_updates_buf);
|
|
77
|
-
getUpdatesBuf = resp.get_updates_buf;
|
|
78
|
-
aLog.debug(`Saved new get_updates_buf (${getUpdatesBuf.length} bytes)`);
|
|
79
|
-
}
|
|
80
|
-
const list = resp.msgs ?? [];
|
|
81
|
-
for (const full of list) {
|
|
82
|
-
aLog.info(`inbound message: from=${full.from_user_id} types=${full.item_list?.map((i) => i.type).join(",") ?? "none"}`);
|
|
83
|
-
const fromUserId = full.from_user_id ?? "";
|
|
84
|
-
setWeixinTypingTicket(accountId, fromUserId, (await configManager.getForUser(fromUserId, full.context_token)).typingTicket);
|
|
85
|
-
await processWeixinInboundMessage(full, {
|
|
86
|
-
accountId,
|
|
87
|
-
account,
|
|
88
|
-
config,
|
|
89
|
-
bus,
|
|
91
|
+
try {
|
|
92
|
+
const response = await getUpdates({
|
|
90
93
|
baseUrl,
|
|
91
|
-
cdnBaseUrl,
|
|
92
94
|
token,
|
|
93
|
-
|
|
95
|
+
get_updates_buf: cursor,
|
|
96
|
+
timeoutMs,
|
|
97
|
+
routeTag,
|
|
98
|
+
abortSignal
|
|
94
99
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
if (abortSignal?.aborted) return;
|
|
101
|
+
if (response.ret === -14 || response.errcode === -14) {
|
|
102
|
+
opts.onState?.("reconnect-required");
|
|
103
|
+
pauseSession(accountId);
|
|
104
|
+
await setTimeout(getRemainingPauseMs(accountId), void 0, { signal: abortSignal });
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if ((response.ret ?? 0) !== 0 || (response.errcode ?? 0) !== 0) throw new Error(`Weixin poll rejected (ret=${response.ret ?? 0}, errcode=${response.errcode ?? 0})`);
|
|
108
|
+
const next = response.get_updates_buf || cursor;
|
|
109
|
+
const messages = response.msgs ?? [];
|
|
110
|
+
if (next !== cursor || messages.length) {
|
|
111
|
+
journal.accept(messages.map((payload) => ({
|
|
112
|
+
id: inboundId(payload),
|
|
113
|
+
payload
|
|
114
|
+
})), next);
|
|
115
|
+
cursor = next;
|
|
116
|
+
}
|
|
117
|
+
if (!response.timedOut) opts.onState?.("polling");
|
|
108
118
|
consecutiveFailures = 0;
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
119
|
+
if (response.longpolling_timeout_ms && response.longpolling_timeout_ms > 0) timeoutMs = Math.min(response.longpolling_timeout_ms, MAX_LONG_POLL_TIMEOUT_MS);
|
|
120
|
+
} catch (err) {
|
|
121
|
+
if (abortSignal?.aborted) return;
|
|
122
|
+
opts.onState?.("connecting");
|
|
123
|
+
consecutiveFailures += 1;
|
|
124
|
+
const retryMs = Math.min(3e4, 2e3 * 2 ** Math.min(4, consecutiveFailures - 1));
|
|
125
|
+
if (consecutiveFailures === 1) logger.warn({
|
|
126
|
+
accountId,
|
|
127
|
+
retryMs,
|
|
128
|
+
errorType: err instanceof Error ? err.name : typeof err
|
|
129
|
+
}, "Weixin polling failed; retrying");
|
|
130
|
+
await setTimeout(retryMs, void 0, { signal: abortSignal });
|
|
116
131
|
}
|
|
117
|
-
lastHealthCheck = now;
|
|
118
132
|
}
|
|
119
|
-
aLog.info(`Weixin monitor ended`);
|
|
120
|
-
}
|
|
121
|
-
function sleep(ms, signal) {
|
|
122
|
-
return new Promise((resolve, reject) => {
|
|
123
|
-
const t = setTimeout(resolve, ms);
|
|
124
|
-
signal?.addEventListener("abort", () => {
|
|
125
|
-
clearTimeout(t);
|
|
126
|
-
reject(Object.assign(/* @__PURE__ */ new Error("aborted"), { name: "AbortError" }));
|
|
127
|
-
}, { once: true });
|
|
128
|
-
});
|
|
129
133
|
}
|
|
130
134
|
//#endregion
|
|
131
135
|
export { monitorWeixinProvider };
|
|
@@ -5,6 +5,7 @@ import './pairing-config-resolver.js';
|
|
|
5
5
|
import type { Config } from '@xopcai/xopc/config/schema.js';
|
|
6
6
|
import type { MessageBus } from '@xopcai/xopc/infra/bus/index.js';
|
|
7
7
|
import type { ChannelCapabilities, ChannelPlugin, ChannelPluginDefaults, ChannelPluginInitOptions, ChannelPluginReloadMeta, ChannelPluginStartOptions, ChannelSecurityContext, ChannelStreamingAdapter } from '@xopcai/xopc/channels/plugin-types.js';
|
|
8
|
+
import { type WeixinMonitorState } from './monitor/monitor.js';
|
|
8
9
|
import type { ChannelCliLoginAdapter, ChannelCronDeliveryAdapter, ChannelRuntimeActionAdapter } from '@xopcai/xopc/channels/plugins/types.adapters.js';
|
|
9
10
|
import { type ResolvedWeixinAccount } from './auth/accounts.js';
|
|
10
11
|
import { weixinTextChunker } from './outbound-send.js';
|
|
@@ -41,6 +42,9 @@ export declare class WeixinChannelPlugin implements ChannelPlugin<ResolvedWeixin
|
|
|
41
42
|
private bus;
|
|
42
43
|
private cfg;
|
|
43
44
|
private abortControllers;
|
|
45
|
+
private monitorTasks;
|
|
46
|
+
private setupSessions;
|
|
47
|
+
private monitorStates;
|
|
44
48
|
config: {
|
|
45
49
|
listAccountIds: (cfg: Config) => string[];
|
|
46
50
|
resolveAccount: (cfg: Config, accountId?: string | null) => ResolvedWeixinAccount;
|
|
@@ -51,7 +55,7 @@ export declare class WeixinChannelPlugin implements ChannelPlugin<ResolvedWeixin
|
|
|
51
55
|
name: string;
|
|
52
56
|
enabled: boolean;
|
|
53
57
|
configured: boolean;
|
|
54
|
-
status:
|
|
58
|
+
status: WeixinMonitorState;
|
|
55
59
|
};
|
|
56
60
|
};
|
|
57
61
|
security: {
|