@tencent-rtc/mcp 1.6.7 → 1.7.0
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/CHANGELOG.md +25 -0
- package/README.md +53 -39
- package/knowledge/build-index.js +31 -4
- package/knowledge/chunker.js +82 -14
- package/knowledge/chunking-policy.js +100 -0
- package/knowledge/content-loader.js +3 -1
- package/knowledge/frontmatter-meta.js +167 -0
- package/knowledge/path-meta.js +28 -6
- package/knowledge/search/exact-lookup.js +9 -227
- package/knowledge/search/filter-pool.js +17 -26
- package/knowledge/search/framework-fallback.js +22 -0
- package/knowledge/search/intent-router.js +13 -0
- package/knowledge/search/query-normalizer.js +129 -0
- package/knowledge/search/search-core.js +391 -0
- package/knowledge/search/search-knowledge.js +351 -323
- package/knowledge/search/search-message.js +87 -0
- package/knowledge/search/search-pass.js +428 -0
- package/knowledge/search/search-types.js +1 -0
- package/knowledge/search/url-row-scorer.js +258 -0
- package/package.json +1 -1
- package/resource/_schema/feature-aliases.yaml +1 -0
- package/resource/_schema/query-normalization.yaml +9 -0
- package/resource/index/manifest.json +1 -1
- package/resource/integration/callkit/preset/android/integration.md +3 -14
- package/resource/integration/callkit/preset/flutter/integration.md +1 -12
- package/resource/integration/callkit/preset/ios/integration.md +2 -12
- package/resource/integration/callkit/preset/react/integration.md +1 -14
- package/resource/integration/callkit/preset/vue/integration.md +1 -14
- package/resource/integration/chat/preset/android/integration.md +6 -13
- package/resource/integration/chat/preset/flutter/integration.md +1 -8
- package/resource/integration/chat/preset/ios/integration.md +4 -12
- package/resource/integration/chat/preset/react/integration.md +6 -16
- package/resource/integration/chat/preset/vue/integration.md +0 -9
- package/resource/integration/livekit/preset/live/android/live-audience-integration.md +2 -6
- package/resource/integration/livekit/preset/live/android/live-host-integration.md +1 -11
- package/resource/integration/livekit/preset/live/android/live-list-integration.md +2 -6
- package/resource/integration/livekit/preset/live/android/prepare-integration.md +2 -7
- package/resource/integration/livekit/preset/live/ios/live-audience-integration.md +2 -7
- package/resource/integration/livekit/preset/live/ios/live-host-integration.md +1 -13
- package/resource/integration/livekit/preset/live/ios/live-list-integration.md +2 -10
- package/resource/integration/livekit/preset/live/ios/prepare-integration.md +3 -8
- package/resource/integration/livekit/preset/live/vue/live-list-integration.md +0 -4
- package/resource/integration/livekit/preset/live/vue/live-player-desk-integration.md +1 -5
- package/resource/integration/livekit/preset/live/vue/live-player-h5-integration.md +2 -7
- package/resource/integration/livekit/preset/live/vue/live-pusher-integration.md +2 -8
- package/resource/integration/roomkit/preset/vue/integration.md +0 -11
- package/resource/knowledge/callkit/best-practice/callkit-miniprogram/uniapp-shrink.md +60 -0
- package/resource/knowledge/callkit/best-practice/common/call-autoplay-blocked.md +77 -0
- package/resource/knowledge/callkit/best-practice/common/call-message-in-chat.md +78 -0
- package/resource/knowledge/callkit/best-practice/common/call-vs-calls.md +110 -0
- package/resource/knowledge/callkit/best-practice/common/callengine-call-flow.md +123 -0
- package/resource/knowledge/callkit/best-practice/common/callengine-log-level.md +67 -0
- package/resource/knowledge/callkit/best-practice/common/callkit-get-engine-instance.md +81 -0
- package/resource/knowledge/callkit/best-practice/common/callkit-get-roomid.md +78 -0
- package/resource/knowledge/callkit/best-practice/common/callkit-limitations.md +37 -0
- package/resource/knowledge/callkit/best-practice/common/callkit-user-register-and-kicked.md +98 -0
- package/resource/knowledge/callkit/core-sdk/android/answer-call.md +0 -7
- package/resource/knowledge/callkit/core-sdk/android/make-call.md +0 -8
- package/resource/knowledge/callkit/core-sdk/android/offline-push.md +1 -9
- package/resource/knowledge/callkit/core-sdk/flutter/answer-call.md +2 -8
- package/resource/knowledge/callkit/core-sdk/flutter/make-call.md +2 -8
- package/resource/knowledge/callkit/core-sdk/flutter/offline-push.md +1 -16
- package/resource/knowledge/callkit/core-sdk/ios/answer-call.md +0 -8
- package/resource/knowledge/callkit/core-sdk/ios/make-call.md +0 -8
- package/resource/knowledge/callkit/core-sdk/ios/offline-push.md +0 -11
- package/resource/knowledge/callkit/core-sdk/uni-app/answer-call.md +178 -200
- package/resource/knowledge/callkit/core-sdk/uni-app/make-call.md +195 -217
- package/resource/knowledge/callkit/faq/android.md +4 -14
- package/resource/knowledge/callkit/faq/common.md +0 -2
- package/resource/knowledge/callkit/faq/error-code.md +2 -4
- package/resource/knowledge/callkit/faq/ios.md +1 -4
- package/resource/knowledge/callkit/preset/android/api.md +0 -6
- package/resource/knowledge/callkit/preset/ios/api.md +0 -4
- package/resource/knowledge/callkit/preset/react/api.md +3 -4
- package/resource/knowledge/callkit/preset/vue/api.md +3 -4
- package/resource/knowledge/chat/best-practice/common/avchatroom-message-loss-diagnosis.md +65 -0
- package/resource/knowledge/chat/best-practice/common/group-conversation-cleanup-on-system-notice.md +62 -0
- package/resource/knowledge/chat/best-practice/common/image-message-url-lifecycle.md +59 -0
- package/resource/knowledge/chat/best-practice/common/login-repeat-2025-diagnosis.md +61 -0
- package/resource/knowledge/chat/best-practice/common/message-read-report-and-receipt.md +64 -0
- package/resource/knowledge/chat/best-practice/common/message-receive-event.md +65 -0
- package/resource/knowledge/chat/best-practice/common/message-risk-error-and-render.md +65 -0
- package/resource/knowledge/chat/best-practice/common/message-unread-count.md +71 -0
- package/resource/knowledge/chat/best-practice/miniprogram/audio-message-send.md +113 -0
- package/resource/knowledge/chat/best-practice/miniprogram/login-timeout-2801-diagnosis.md +63 -0
- package/resource/knowledge/chat/best-practice/miniprogram/media-upload-fail-diagnosis.md +64 -0
- package/resource/knowledge/chat/best-practice/web/audio-message-send.md +118 -0
- package/resource/knowledge/chat/preset/android/features/chat-setting.md +0 -5
- package/resource/knowledge/chat/preset/android/features/contact-list.md +0 -7
- package/resource/knowledge/chat/preset/android/features/conversation-list.md +0 -6
- package/resource/knowledge/chat/preset/android/features/language.md +0 -8
- package/resource/knowledge/chat/preset/android/features/message-input.md +0 -6
- package/resource/knowledge/chat/preset/android/features/message-list.md +0 -8
- package/resource/knowledge/chat/preset/android/features/search.md +0 -7
- package/resource/knowledge/chat/preset/android/features/theme.md +0 -4
- package/resource/knowledge/chat/preset/android-view/integration.md +0 -6
- package/resource/knowledge/chat/preset/flutter/features/chat-setting.md +0 -4
- package/resource/knowledge/chat/preset/flutter/features/contact-list.md +0 -9
- package/resource/knowledge/chat/preset/flutter/features/conversation-list.md +0 -7
- package/resource/knowledge/chat/preset/flutter/features/language.md +0 -5
- package/resource/knowledge/chat/preset/flutter/features/message-input.md +0 -6
- package/resource/knowledge/chat/preset/flutter/features/message-list.md +0 -8
- package/resource/knowledge/chat/preset/flutter/features/search.md +0 -5
- package/resource/knowledge/chat/preset/flutter/features/theme.md +0 -4
- package/resource/knowledge/chat/preset/ios/features/chat-setting.md +0 -5
- package/resource/knowledge/chat/preset/ios/features/contact-list.md +0 -5
- package/resource/knowledge/chat/preset/ios/features/conversation-list.md +0 -7
- package/resource/knowledge/chat/preset/ios/features/language.md +1 -8
- package/resource/knowledge/chat/preset/ios/features/message-input.md +0 -6
- package/resource/knowledge/chat/preset/ios/features/message-list.md +0 -8
- package/resource/knowledge/chat/preset/ios/features/search.md +0 -5
- package/resource/knowledge/chat/preset/ios/features/theme.md +0 -4
- package/resource/knowledge/chat/preset/ios-uikit/integration.md +0 -6
- package/resource/knowledge/chat/preset/react/features/contact-list.md +0 -23
- package/resource/knowledge/chat/preset/react/features/conversation-actions.md +2 -11
- package/resource/knowledge/chat/preset/react/features/conversation-list.md +4 -26
- package/resource/knowledge/chat/preset/react/features/conversation-preview.md +0 -6
- package/resource/knowledge/chat/preset/react/features/search.md +0 -1
- package/resource/knowledge/chat/preset/react/features/theme.md +0 -1
- package/resource/knowledge/chat/preset/vue/features/contact-list.md +3 -9
- package/resource/knowledge/chat/preset/vue/features/conversation-actions.md +0 -3
- package/resource/knowledge/chat/preset/vue/features/conversation-list.md +2 -13
- package/resource/knowledge/chat/preset/vue/features/conversation-preview.md +2 -3
- package/resource/knowledge/chat/preset/vue/features/conversation-search.md +1 -0
- package/resource/knowledge/chat/preset/vue/features/search.md +4 -3
- package/resource/knowledge/chat/urls/sdk/web.md +1 -1
- package/resource/knowledge/livekit/best-practice/android/voice-room-anchor-start.md +120 -0
- package/resource/knowledge/livekit/best-practice/common/admin-take-seat.md +73 -0
- package/resource/knowledge/livekit/best-practice/common/audience-leave-live.md +81 -0
- package/resource/knowledge/livekit/best-practice/common/voice-room-no-audio-troubleshoot.md +100 -0
- package/resource/knowledge/livekit/best-practice/common/voice-room-seat-list-change.md +65 -0
- package/resource/knowledge/livekit/best-practice/flutter/voice-room-anchor-start.md +122 -0
- package/resource/knowledge/livekit/best-practice/ios/voice-room-anchor-start.md +126 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/AudioEffectStore.md +0 -7
- package/resource/knowledge/livekit/core-sdk/api-reference/android/BarrageStore.md +0 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/android/BattleStore.md +0 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/android/CameraView.md +0 -1
- package/resource/knowledge/livekit/core-sdk/api-reference/android/CoGuestStore.md +0 -5
- package/resource/knowledge/livekit/core-sdk/api-reference/android/CoHostStore.md +0 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/android/DeviceStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/android/GiftStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LikeStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveAudienceStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveCoreView.md +0 -1
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveSeatStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LoginStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/AudioEffectStore.md +0 -7
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BarrageStore.md +0 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BaseBeautyStore.md +0 -1
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BattleStore.md +0 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/CoGuestStore.md +0 -5
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/CoHostStore.md +0 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/DeviceStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/GiftStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LikeStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveAudienceStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveCoreView.md +0 -1
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveSeatStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LoginStore.md +1 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/AudioEffectStore.md +0 -7
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/BarrageStore.md +0 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/BaseBeautyStore.md +0 -1
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/BattleStore.md +0 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/CoGuestStore.md +0 -5
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/CoHostStore.md +0 -3
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/DeviceStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/GiftStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LikeStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveAudienceStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveCoreView.md +0 -1
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveSeatStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LoginStore.md +0 -2
- package/resource/knowledge/livekit/core-sdk/features/android/audience-list.md +2 -2
- package/resource/knowledge/livekit/core-sdk/features/android/audio-effect.md +2 -3
- package/resource/knowledge/livekit/core-sdk/features/android/barrage.md +2 -2
- package/resource/knowledge/livekit/core-sdk/features/android/base-beauty.md +2 -2
- package/resource/knowledge/livekit/core-sdk/features/android/gift.md +2 -7
- package/resource/knowledge/livekit/core-sdk/features/android/live-list.md +3 -4
- package/resource/knowledge/livekit/core-sdk/features/flutter/audience-list.md +2 -2
- package/resource/knowledge/livekit/core-sdk/features/flutter/audio-effect.md +2 -4
- package/resource/knowledge/livekit/core-sdk/features/flutter/barrage.md +2 -2
- package/resource/knowledge/livekit/core-sdk/features/flutter/base-beauty.md +0 -2
- package/resource/knowledge/livekit/core-sdk/features/flutter/gift.md +2 -7
- package/resource/knowledge/livekit/core-sdk/features/flutter/live-list.md +3 -2
- package/resource/knowledge/livekit/core-sdk/features/ios/audience-list.md +2 -2
- package/resource/knowledge/livekit/core-sdk/features/ios/audio-effect.md +2 -4
- package/resource/knowledge/livekit/core-sdk/features/ios/barrage.md +2 -2
- package/resource/knowledge/livekit/core-sdk/features/ios/base-beauty.md +2 -2
- package/resource/knowledge/livekit/core-sdk/features/ios/gift.md +2 -7
- package/resource/knowledge/livekit/core-sdk/features/ios/live-list.md +3 -4
- package/resource/knowledge/livekit/core-sdk/live/android/co-guest-interaction.md +0 -3
- package/resource/knowledge/livekit/core-sdk/live/android/host-interaction.md +0 -4
- package/resource/knowledge/livekit/core-sdk/live/android/integration.md +1 -4
- package/resource/knowledge/livekit/core-sdk/live/flutter/co-guest-interaction.md +1 -3
- package/resource/knowledge/livekit/core-sdk/live/flutter/host-interaction.md +0 -1
- package/resource/knowledge/livekit/core-sdk/live/flutter/integration.md +1 -4
- package/resource/knowledge/livekit/core-sdk/live/ios/co-guest-interaction.md +0 -3
- package/resource/knowledge/livekit/core-sdk/live/ios/host-interaction.md +0 -3
- package/resource/knowledge/livekit/core-sdk/live/ios/integration.md +1 -4
- package/resource/knowledge/livekit/core-sdk/voice/android/co-guest-interaction.md +0 -2
- package/resource/knowledge/livekit/core-sdk/voice/android/host-interaction.md +0 -5
- package/resource/knowledge/livekit/core-sdk/voice/android/integration.md +1 -4
- package/resource/knowledge/livekit/core-sdk/voice/flutter/co-guest-interaction.md +1 -4
- package/resource/knowledge/livekit/core-sdk/voice/flutter/integration.md +3 -6
- package/resource/knowledge/livekit/core-sdk/voice/ios/co-guest-interaction.md +0 -2
- package/resource/knowledge/livekit/core-sdk/voice/ios/host-interaction.md +0 -4
- package/resource/knowledge/livekit/core-sdk/voice/ios/integration.md +1 -4
- package/resource/knowledge/livekit/faq/error-code.md +0 -1
- package/resource/knowledge/livekit/preset/live/vue/features/barrage.md +2 -3
- package/resource/knowledge/livekit/preset/live/vue/features/live-audience-list.md +3 -3
- package/resource/knowledge/livekit/preset/live/vue/features/live-view.md +3 -3
- package/resource/knowledge/push/api-reference/android.md +0 -1
- package/resource/knowledge/push/api-reference/harmonyos.md +0 -2
- package/resource/knowledge/push/api-reference/react-native.md +3 -5
- package/resource/knowledge/push/api-reference/uni-app.md +3 -5
- package/resource/knowledge/push/api-reference/unity.md +0 -1
- package/resource/knowledge/push/api-reference/unreal-engine.md +0 -1
- package/resource/knowledge/push/config/android.md +0 -24
- package/resource/knowledge/push/config/harmonyos.md +0 -1
- package/resource/knowledge/push/config/ios.md +0 -3
- package/resource/knowledge/push/config/react-native.md +0 -29
- package/resource/knowledge/push/config/unity.md +1 -24
- package/resource/knowledge/push/config/unreal-engine.md +1 -24
- package/resource/knowledge/push/integration/android.md +0 -14
- package/resource/knowledge/push/integration/flutter.md +0 -19
- package/resource/knowledge/push/integration/harmonyos.md +0 -2
- package/resource/knowledge/push/integration/ios.md +0 -3
- package/resource/knowledge/push/integration/react-native.md +0 -24
- package/resource/knowledge/push/integration/uni-app.md +1 -11
- package/resource/knowledge/push/integration/unity.md +0 -9
- package/resource/knowledge/push/integration/unreal-engine.md +1 -17
- package/resource/knowledge/roomkit/best-practice/common/room-ghost-member.md +70 -0
- package/resource/knowledge/roomkit/best-practice/common/room-limit-and-multi.md +83 -0
- package/resource/knowledge/roomkit/best-practice/common/room-screen-share-preview.md +83 -0
- package/resource/knowledge/roomkit/best-practice/common/room-status-after-all-leave.md +69 -0
- package/resource/knowledge/roomkit/best-practice/vue/room-uikit-vs-atomicx.md +111 -0
- package/resource/knowledge/roomkit/core-sdk/android/call-user-to-room.md +0 -4
- package/resource/knowledge/roomkit/core-sdk/android/room-participant-state.md +0 -4
- package/resource/knowledge/roomkit/core-sdk/android/room-state.md +0 -4
- package/resource/knowledge/roomkit/core-sdk/android/schedule-room.md +1 -5
- package/resource/knowledge/roomkit/core-sdk/ios/call-user-to-room.md +0 -4
- package/resource/knowledge/roomkit/core-sdk/ios/room-participant-state.md +0 -4
- package/resource/knowledge/roomkit/core-sdk/ios/room-state.md +0 -4
- package/resource/knowledge/roomkit/core-sdk/ios/schedule-room.md +1 -5
- package/resource/knowledge/roomkit/core-sdk/vue/call-user-to-room.md +1 -1
- package/resource/knowledge/roomkit/core-sdk/vue/device-state.md +0 -6
- package/resource/knowledge/roomkit/core-sdk/vue/free-beauty-panel.md +0 -9
- package/resource/knowledge/roomkit/core-sdk/vue/room-chat.md +0 -11
- package/resource/knowledge/roomkit/core-sdk/vue/room-participant-state.md +1 -5
- package/resource/knowledge/roomkit/core-sdk/vue/room-state.md +1 -8
- package/resource/knowledge/roomkit/core-sdk/vue/room-view.md +0 -3
- package/resource/knowledge/roomkit/core-sdk/vue/screen-share.md +0 -3
- package/resource/knowledge/roomkit/core-sdk/vue/virtual-background.md +0 -5
- package/resource/knowledge/roomkit/preset/android/integration.md +0 -4
- package/resource/knowledge/roomkit/preset/flutter/integration.md +1 -13
- package/resource/knowledge/roomkit/preset/ios/integration.md +0 -6
- package/resource/knowledge/roomkit/preset/react/integration.md +0 -16
- package/resource/knowledge/rtcengine/web/api.md +1 -8
- package/resource/knowledge/rtcengine/web/faq.md +3 -5
- package/resource/knowledge/rtcengine/web/how_to_integrated_web_sdk.md +0 -6
- package/resource/knowledge/rtcengine/web/plugin/20-advanced-customized-capture-rendering.md +1 -1
- package/resource/knowledge/rtcengine/web/plugin/21-advanced-auto-play-policy.md +1 -1
- package/resource/knowledge/rtcengine/web/plugin/26-advanced-publish-cdn-stream.md +1 -1
- package/resource/knowledge/rtcengine/web/plugin/27-advanced-small-stream.md +1 -1
- package/resource/knowledge/rtcengine/web/plugin/30-advanced-cross-room-link.md +2 -0
- package/resource/knowledge/rtcengine/web/plugin/31-advanced-plugins-overview.md +1 -3
- package/resource/knowledge/rtcengine/web/plugin/34-advanced-proxy.md +2 -4
- package/resource/knowledge/rtcengine/web/plugin/36-advanced-virtual-background.md +0 -4
- package/resource/knowledge/rtcengine/web/plugin/39-advanced-video-decoder.md +1 -1
- package/resource/knowledge/trtc/android/TRTCCloud.md +8 -56
- package/resource/knowledge/trtc/android/TRTCCloudDef.md +6 -7
- package/resource/knowledge/trtc/android/TRTCCloudListener.md +1 -18
- package/resource/knowledge/trtc/android/TXAudioEffectManager.md +0 -14
- package/resource/knowledge/trtc/android/TXDeviceManager.md +0 -1
- package/resource/knowledge/trtc/android/TXLiteAVCode.md +1 -1
- package/resource/knowledge/trtc/c++/ITRTCCloud.md +7 -59
- package/resource/knowledge/trtc/c++/ITXAudioEffectManager.md +0 -14
- package/resource/knowledge/trtc/c++/ITXDeviceManager.md +0 -4
- package/resource/knowledge/trtc/c++/TRTCCloudCallback.md +1 -19
- package/resource/knowledge/trtc/c++/TRTCTypeDef.md +6 -7
- package/resource/knowledge/trtc/c++/TXLiteAVCode.md +1 -1
- package/resource/knowledge/trtc/ios/TRTCCloud.md +9 -60
- package/resource/knowledge/trtc/ios/TRTCCloudDef.md +6 -7
- package/resource/knowledge/trtc/ios/TRTCCloudDelegate.md +1 -19
- package/resource/knowledge/trtc/ios/TXAudioEffectManager.md +0 -13
- package/resource/knowledge/trtc/ios/TXDeviceManager.md +0 -4
- package/resource/knowledge/trtc/ios/TXLiteAVCode.md +1 -1
- package/server.js +27 -22
- package/tools/common/finalize_answer.js +9 -1
- package/tools/common/search_trtc_knowledge.js +3 -1
- package/tools/definitions/finalize_answer_def.js +2 -2
- package/tools/definitions/integration-boundary.js +2 -1
- package/tools/definitions/search_trtc_knowledge_def.js +2 -1
- package/utils/report-cls-client.js +3 -3
- package/utils/report-es-client.js +1 -1
- package/cursor-setting.png +0 -0
- package/mcp-server-prompt.png +0 -0
- package/resource/knowledge/callkit/best-practice/web/callengine-invitation.md +0 -80
- package/resource/knowledge/callkit/best-practice/web/callengine-log-control.md +0 -24
- package/resource/knowledge/callkit/best-practice/web/callkit-call-vs-calls.md +0 -116
- package/resource/knowledge/callkit/preset/react/uikit-api-reference.md +0 -445
- package/resource/knowledge/callkit/preset/vue/uikit-api-reference.md +0 -465
- package/resource/knowledge/chat/best-practice/web/image-message-url-handling.md +0 -16
- package/resource/knowledge/roomkit/core-sdk/flutter/call-user-to-room.md +0 -230
- package/resource/knowledge/roomkit/core-sdk/flutter/room-participant-state.md +0 -797
- package/resource/knowledge/roomkit/core-sdk/flutter/room-state.md +0 -325
- package/resource/knowledge/roomkit/core-sdk/flutter/schedule-room.md +0 -325
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## Version 1.7.0 @2026.08.02
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Added and synchronized best-practice docs across product domains including Chat / Call / Live / Room to improve knowledge coverage.
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- Continued refactoring of the bilingual retrieval pipeline, including query normalization, intent routing, candidate filtering, and exact-match strategies.
|
|
10
|
+
- Improved recall and ranking for best-practice and URL-based documents to increase answer usability and stability.
|
|
11
|
+
- Improved `search_trtc_knowledge` definitions and answer constraints for better readability and executability.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- Fixed off-topic retrieval in some complex queries, reducing high-score false-positive hits.
|
|
15
|
+
|
|
16
|
+
## Version 1.6.6 @2026.07.18
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- Added support for `get_native_live_uikit_integration`, enabling LiveKit(Android/iOS) UI integration guidance.
|
|
20
|
+
|
|
21
|
+
## Version 1.6.0 @2026.07.01
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- Refactored MCP retrieval capabilities and consolidated the MCP toolset.
|
|
25
|
+
- Added support for `search_trtc_knowledge` to retrieve real-time audio/video (TRTC/IM) documentation.
|
package/README.md
CHANGED
|
@@ -1,45 +1,27 @@
|
|
|
1
|
-
## Tencent SDK
|
|
2
|
-
|
|
3
|
-
This repository provides a CLI-based Model Context Protocol (MCP) server that exposes Tencent SDK documentation and Tencent API resources to LLM-powered tools.
|
|
4
|
-
This improves the LLM AI Agent's ability to understand and interact with Tencent's SDKs and APIs.
|
|
1
|
+
## Tencent RTC SDK MCP Server Guide
|
|
5
2
|
|
|
3
|
+
This repository provides a CLI-based Model Context Protocol (MCP) Server that exposes Tencent RTC SDK documentation and API resources to LLM tools, helping AI agents deliver more accurate implementation guidance and integration support.
|
|
6
4
|
|
|
7
5
|
## Features
|
|
8
6
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
- TUICallKit SDK topics: configuration, calls function.
|
|
17
|
-
- Retrieve official Tencent ChatUIKit documentation (HTML → Markdown) for:
|
|
18
|
-
- ChatUIKit SDK languages: JavaScript, Kotlin, Swift.
|
|
19
|
-
- ChatUIKit SDK topics: configuration, chat function.
|
|
20
|
-
- Converts remote HTML articles to Markdown using `jsdom` and `turndown` for consistent documentation formatting.
|
|
21
|
-
- Input validation via Zod schemas for all tool parameters, ensuring robust error handling.
|
|
22
|
-
- Extensible tool definitions leveraging the Model Context Protocol SDK (`@modelcontextprotocol/sdk`) with `McpServer` and `StdioServerTransport`.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## Prerequisites
|
|
26
|
-
- Node.js (>= 18) and npm
|
|
27
|
-
- Cursor IDE with MCP support
|
|
28
|
-
|
|
7
|
+
- **Efficient retrieval**: Supports Tencent RTC documentation retrieval for fast access to official references and best practices.
|
|
8
|
+
- **Broad coverage**: Covers Chat (IM), Call, Live, Room, RTCEngine (TRTC SDK), and TIMPush domains.
|
|
9
|
+
- **Intelligent routing**: Supports product/platform intent disambiguation and prompts for missing platform/framework information when needed.
|
|
10
|
+
- **Integration-friendly**: In addition to documentation Q&A, provides integration entry points for Web / Android / iOS / Flutter, including UI-based integration directions.
|
|
11
|
+
- **Reliable source**: Grounded in official Tencent Cloud materials to improve answer reliability and implementation readiness.
|
|
12
|
+
- **Wide compatibility**: Exposes MCP capabilities over STDIN/STDOUT JSON-RPC, compatible with MCP clients such as Cursor / Codex / Claude / CodeBuddy.
|
|
13
|
+
- **Quick start**: Run with `npx` and get started with minimal setup.
|
|
29
14
|
|
|
30
|
-
##
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
- Step1: Installation.
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
npx -y @tencent-rtc/mcp
|
|
37
|
-
```
|
|
15
|
+
## Requirements
|
|
16
|
+
- Node.js (>= 18) and npm
|
|
17
|
+
- An MCP-capable IDE
|
|
38
18
|
|
|
19
|
+
## Usage
|
|
20
|
+
### Standard setup flow
|
|
39
21
|
|
|
40
|
-
-
|
|
22
|
+
- Step1: In your Cursor project, create or edit `.cursor/mcp.json` or `~/.cursor/mcp.json` and add the following configuration.
|
|
41
23
|
|
|
42
|
-
```
|
|
24
|
+
```json
|
|
43
25
|
{
|
|
44
26
|
"mcpServers": {
|
|
45
27
|
"tencent-rtc": {
|
|
@@ -53,16 +35,48 @@ npx -y @tencent-rtc/mcp
|
|
|
53
35
|
}
|
|
54
36
|
}
|
|
55
37
|
```
|
|
56
|
-
|
|
38
|
+
After saving, a prompt appears. Click **Enable** in the prompt.
|
|
57
39
|
|
|
58
40
|

|
|
59
41
|
|
|
60
|
-
-
|
|
42
|
+
- Step2: Go to **Cursor Settings** (top-right gear icon) -> **MCP**, and make sure `tencent-rtc` is enabled.
|
|
61
43
|
|
|
62
44
|

|
|
63
45
|
|
|
46
|
+
- Step3: Describe your requirements directly in the IDE, and let the AI complete implementation or troubleshooting based on Tencent Cloud SDK documentation.
|
|
47
|
+
|
|
48
|
+
### Optional: global install
|
|
49
|
+
|
|
50
|
+
If you want quick global invocation locally, run:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx -y @tencent-rtc/mcp
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Changelog
|
|
57
|
+
|
|
58
|
+
> Only recent updates are listed here. For full history, see `CHANGELOG.md`.
|
|
59
|
+
|
|
60
|
+
### Version 1.7.0 @2026.08.02
|
|
61
|
+
|
|
62
|
+
#### Added
|
|
63
|
+
- Added and synchronized best-practice docs across product domains including Chat / Call / Live / Room to improve knowledge coverage.
|
|
64
|
+
|
|
65
|
+
#### Changed
|
|
66
|
+
- Continued refactoring of the bilingual retrieval pipeline, including query normalization, intent routing, candidate filtering, and exact-match strategies.
|
|
67
|
+
- Improved recall and ranking for best-practice and URL-based documents to increase answer usability and stability.
|
|
68
|
+
- Improved `search_trtc_knowledge` definitions and answer constraints for better readability and executability.
|
|
69
|
+
|
|
70
|
+
#### Fixed
|
|
71
|
+
- Fixed off-topic retrieval in some complex queries, reducing high-score false-positive hits.
|
|
72
|
+
|
|
73
|
+
### Version 1.6.6 @2026.07.18
|
|
74
|
+
|
|
75
|
+
#### Added
|
|
76
|
+
- Added support for `get_native_live_uikit_integration`, enabling LiveKit(Android/iOS) UI integration guidance.
|
|
64
77
|
|
|
65
|
-
|
|
78
|
+
### Version 1.6.0 @2026.07.01
|
|
66
79
|
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
#### Added
|
|
81
|
+
- Refactored MCP retrieval capabilities and consolidated the MCP toolset.
|
|
82
|
+
- Added support for `search_trtc_knowledge` to retrieve real-time audio/video (TRTC/IM) documentation.
|
package/knowledge/build-index.js
CHANGED
|
@@ -3,8 +3,13 @@ import path from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { chunkMarkdown, toManifestChunk } from './chunker.js';
|
|
5
5
|
import { buildDocSourceUrlMap } from './doc-url-resolver.js';
|
|
6
|
+
import { mergePathMetaWithFrontmatter, resolveFrontmatterMeta } from './frontmatter-meta.js';
|
|
6
7
|
import { inferPathMeta } from './path-meta.js';
|
|
8
|
+
import { loadChunkingPolicy, resolveChunkingRule, resolvePolicyFilePath } from './chunking-policy.js';
|
|
7
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
// 构建期写入索引到 dist/resource/index/:
|
|
11
|
+
// dist/knowledge/ → ../resource/ → dist/resource/
|
|
12
|
+
// 必须在 scripts/copy-resource.js 之后执行,否则目标目录不存在。
|
|
8
13
|
const RESOURCE_ROOT = path.resolve(__dirname, '../resource');
|
|
9
14
|
function walkMarkdownFiles(dir, baseRel) {
|
|
10
15
|
if (!fs.existsSync(dir))
|
|
@@ -42,11 +47,32 @@ export function buildKnowledgeIndex() {
|
|
|
42
47
|
...walkMarkdownFiles(path.join(RESOURCE_ROOT, 'integration'), 'integration'),
|
|
43
48
|
];
|
|
44
49
|
const chunks = [];
|
|
50
|
+
let frontmatterFileCount = 0;
|
|
51
|
+
let frontmatterMergedCount = 0;
|
|
52
|
+
let frontmatterParseErrorCount = 0;
|
|
53
|
+
const chunkingPolicyPath = resolvePolicyFilePath(__dirname);
|
|
54
|
+
const chunkingPolicy = loadChunkingPolicy(chunkingPolicyPath);
|
|
45
55
|
for (const source of sources) {
|
|
46
56
|
const abs = path.join(RESOURCE_ROOT, source);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
const rawContent = fs.readFileSync(abs, 'utf-8');
|
|
58
|
+
// Phase A(兼容期):frontmatter 优先,未声明字段继续走路径推断 fallback。
|
|
59
|
+
const pathMeta = inferPathMeta(source);
|
|
60
|
+
const fm = resolveFrontmatterMeta(rawContent);
|
|
61
|
+
const meta = mergePathMetaWithFrontmatter(pathMeta, fm.frontmatterMeta, fm.overrideFields);
|
|
62
|
+
if (fm.hasFrontmatter)
|
|
63
|
+
frontmatterFileCount += 1;
|
|
64
|
+
if (meta.meta_source === 'merged')
|
|
65
|
+
frontmatterMergedCount += 1;
|
|
66
|
+
if (fm.parseError) {
|
|
67
|
+
frontmatterParseErrorCount += 1;
|
|
68
|
+
console.warn(`[build-knowledge-index] frontmatter parse failed: ${source} - ${fm.parseError}`);
|
|
69
|
+
}
|
|
70
|
+
const policyRule = resolveChunkingRule(source, chunkingPolicy);
|
|
71
|
+
chunks.push(...chunkMarkdown(source, fm.content, meta, {
|
|
72
|
+
baseOffset: fm.contentOffset,
|
|
73
|
+
policyRule,
|
|
74
|
+
defaultSplitTokenThreshold: chunkingPolicy.default.split_token_threshold,
|
|
75
|
+
}).map(toManifestChunk));
|
|
50
76
|
}
|
|
51
77
|
const indexDir = path.join(RESOURCE_ROOT, 'index');
|
|
52
78
|
fs.mkdirSync(indexDir, { recursive: true });
|
|
@@ -65,5 +91,6 @@ export function buildKnowledgeIndex() {
|
|
|
65
91
|
if (fs.existsSync(staleSearchIndex)) {
|
|
66
92
|
fs.unlinkSync(staleSearchIndex);
|
|
67
93
|
}
|
|
68
|
-
console.warn(`build-knowledge-index: ${chunks.length} chunks (manifest-lite) from ${sources.length} files`
|
|
94
|
+
console.warn(`build-knowledge-index: ${chunks.length} chunks (manifest-lite) from ${sources.length} files; `
|
|
95
|
+
+ `frontmatter files=${frontmatterFileCount}, merged=${frontmatterMergedCount}, parse_errors=${frontmatterParseErrorCount}`);
|
|
69
96
|
}
|
package/knowledge/chunker.js
CHANGED
|
@@ -42,6 +42,34 @@ function isFaqLike(source, content) {
|
|
|
42
42
|
function shouldForceSectionSplit(source, meta) {
|
|
43
43
|
return source.endsWith('unsupported-features.md') || meta.doc_kind === 'unsupported_summary';
|
|
44
44
|
}
|
|
45
|
+
function isBestPracticeSource(source) {
|
|
46
|
+
return /\/best-practice\//i.test(source.replace(/\\/g, '/'));
|
|
47
|
+
}
|
|
48
|
+
const BEST_PRACTICE_SINGLE_CHUNK_MAX_TOKENS = 4096;
|
|
49
|
+
const LEGACY_SINGLE_CHUNK_CHAR_THRESHOLD = 2048;
|
|
50
|
+
function estimateTextTokens(text) {
|
|
51
|
+
let tokens = 0;
|
|
52
|
+
for (const ch of text) {
|
|
53
|
+
tokens += /[A-Za-z]/.test(ch) ? 0.5 : 1;
|
|
54
|
+
}
|
|
55
|
+
return tokens;
|
|
56
|
+
}
|
|
57
|
+
function estimateMarkdownTokens(content) {
|
|
58
|
+
let tokens = 0;
|
|
59
|
+
let cursor = 0;
|
|
60
|
+
const codeBlockRE = /```[\s\S]*?```/g;
|
|
61
|
+
for (const match of content.matchAll(codeBlockRE)) {
|
|
62
|
+
const start = match.index ?? cursor;
|
|
63
|
+
const end = start + match[0].length;
|
|
64
|
+
tokens += estimateTextTokens(content.slice(cursor, start));
|
|
65
|
+
tokens += match[0].length * 1.3;
|
|
66
|
+
cursor = end;
|
|
67
|
+
}
|
|
68
|
+
if (cursor < content.length) {
|
|
69
|
+
tokens += estimateTextTokens(content.slice(cursor));
|
|
70
|
+
}
|
|
71
|
+
return tokens;
|
|
72
|
+
}
|
|
45
73
|
function isChatUrlMapping(source) {
|
|
46
74
|
return /knowledge\/chat\/urls\/.+\.md$/i.test(source.replace(/\\/g, '/'));
|
|
47
75
|
}
|
|
@@ -86,7 +114,7 @@ function extractKeyPhrases(title, body) {
|
|
|
86
114
|
.slice(0, 8);
|
|
87
115
|
return [...new Set(phrases)];
|
|
88
116
|
}
|
|
89
|
-
function buildChunk(meta, source, title, body, id, char_start, char_end) {
|
|
117
|
+
function buildChunk(meta, source, title, body, id, char_start, char_end, extra) {
|
|
90
118
|
const api_names = extractApiNames(body);
|
|
91
119
|
const key_phrases = extractKeyPhrases(title, body);
|
|
92
120
|
return {
|
|
@@ -101,6 +129,8 @@ function buildChunk(meta, source, title, body, id, char_start, char_end) {
|
|
|
101
129
|
doc_kind: meta.doc_kind,
|
|
102
130
|
capability_status: meta.capability_status,
|
|
103
131
|
retrievable_scope: meta.retrievable_scope,
|
|
132
|
+
meta_source: meta.meta_source,
|
|
133
|
+
meta_override_fields: meta.meta_override_fields,
|
|
104
134
|
title,
|
|
105
135
|
source,
|
|
106
136
|
content: body,
|
|
@@ -109,14 +139,15 @@ function buildChunk(meta, source, title, body, id, char_start, char_end) {
|
|
|
109
139
|
...(api_names.length ? { api_names } : {}),
|
|
110
140
|
...(containsCodeBlock(body) ? { contains_code: true } : {}),
|
|
111
141
|
...(key_phrases.length ? { key_phrases } : {}),
|
|
142
|
+
...(extra ?? {}),
|
|
112
143
|
char_start,
|
|
113
144
|
char_end,
|
|
114
145
|
};
|
|
115
146
|
}
|
|
116
|
-
function parseUrlMappingRows(content) {
|
|
147
|
+
function parseUrlMappingRows(content, baseOffset) {
|
|
117
148
|
const lines = content.split('\n');
|
|
118
149
|
let sectionTitle = '';
|
|
119
|
-
let offset =
|
|
150
|
+
let offset = baseOffset;
|
|
120
151
|
const rows = [];
|
|
121
152
|
for (const line of lines) {
|
|
122
153
|
const lineStart = offset;
|
|
@@ -144,8 +175,8 @@ function parseUrlMappingRows(content) {
|
|
|
144
175
|
}
|
|
145
176
|
return rows;
|
|
146
177
|
}
|
|
147
|
-
function chunkUrlMapping(source, content, meta) {
|
|
148
|
-
const rows = parseUrlMappingRows(content);
|
|
178
|
+
function chunkUrlMapping(source, content, meta, baseOffset) {
|
|
179
|
+
const rows = parseUrlMappingRows(content, baseOffset);
|
|
149
180
|
if (rows.length === 0) {
|
|
150
181
|
return [];
|
|
151
182
|
}
|
|
@@ -157,33 +188,70 @@ function chunkUrlMapping(source, content, meta) {
|
|
|
157
188
|
return buildChunk(meta, source, row.label, body, `${baseSlug}#${headingSlug}`, row.lineStart, row.lineEnd);
|
|
158
189
|
});
|
|
159
190
|
}
|
|
160
|
-
export function chunkMarkdown(source, content, meta) {
|
|
191
|
+
export function chunkMarkdown(source, content, meta, options) {
|
|
161
192
|
const chunks = [];
|
|
162
193
|
const baseSlug = sourceSlug(source);
|
|
163
|
-
|
|
164
|
-
|
|
194
|
+
const baseOffset = options?.baseOffset ?? 0;
|
|
195
|
+
const policyRule = options?.policyRule;
|
|
196
|
+
if (isChatUrlMapping(source) || policyRule?.strategy === 'by_row') {
|
|
197
|
+
const urlChunks = chunkUrlMapping(source, content, meta, baseOffset);
|
|
165
198
|
if (urlChunks.length > 0) {
|
|
166
199
|
return urlChunks;
|
|
167
200
|
}
|
|
168
201
|
}
|
|
169
202
|
const forceSectionSplit = shouldForceSectionSplit(source, meta);
|
|
170
|
-
|
|
171
|
-
|
|
203
|
+
const isBestPractice = isBestPracticeSource(source);
|
|
204
|
+
const estimatedTokenCount = estimateMarkdownTokens(content);
|
|
205
|
+
const defaultSplitThreshold = options?.defaultSplitTokenThreshold ?? LEGACY_SINGLE_CHUNK_CHAR_THRESHOLD;
|
|
206
|
+
const singleChunkMaxTokens = policyRule?.max_tokens
|
|
207
|
+
?? (isBestPractice ? BEST_PRACTICE_SINGLE_CHUNK_MAX_TOKENS : undefined);
|
|
208
|
+
const shouldSingleChunk = policyRule?.strategy === 'single_chunk_per_file'
|
|
209
|
+
|| (isBestPractice && !policyRule?.strategy);
|
|
210
|
+
if (shouldSingleChunk && singleChunkMaxTokens !== undefined && estimatedTokenCount <= singleChunkMaxTokens) {
|
|
211
|
+
const { body, char_start, char_end } = trimSliceOffsets(content, baseOffset);
|
|
172
212
|
if (!body)
|
|
173
213
|
return chunks;
|
|
174
214
|
chunks.push(buildChunk(meta, source, pathBasename(source), body, `${baseSlug}#full`, char_start, char_end));
|
|
175
215
|
return chunks;
|
|
176
216
|
}
|
|
177
|
-
|
|
217
|
+
if (!shouldSingleChunk
|
|
218
|
+
&& !forceSectionSplit
|
|
219
|
+
&& content.length < (policyRule?.split_token_threshold ?? defaultSplitThreshold)) {
|
|
220
|
+
const { body, char_start, char_end } = trimSliceOffsets(content, baseOffset);
|
|
221
|
+
if (!body)
|
|
222
|
+
return chunks;
|
|
223
|
+
chunks.push(buildChunk(meta, source, pathBasename(source), body, `${baseSlug}#full`, char_start, char_end));
|
|
224
|
+
return chunks;
|
|
225
|
+
}
|
|
226
|
+
const fallbackStrategy = policyRule?.split_fallback ?? policyRule?.strategy ?? 'by_h2';
|
|
227
|
+
const level = forceSectionSplit
|
|
228
|
+
? 3
|
|
229
|
+
: fallbackStrategy === 'by_h3'
|
|
230
|
+
? 3
|
|
231
|
+
: (isFaqLike(source, content) ? 3 : 2);
|
|
178
232
|
const sections = splitByHeading(content, level);
|
|
179
233
|
for (const section of sections) {
|
|
180
|
-
const { body, char_start, char_end } = trimSliceOffsets(section.raw, section.start);
|
|
234
|
+
const { body, char_start, char_end } = trimSliceOffsets(section.raw, section.start + baseOffset);
|
|
181
235
|
if (!body)
|
|
182
236
|
continue;
|
|
183
237
|
const headingSlug = slugify(section.title);
|
|
184
|
-
|
|
238
|
+
const fallbackMeta = shouldSingleChunk && singleChunkMaxTokens !== undefined && estimatedTokenCount > singleChunkMaxTokens
|
|
239
|
+
? {
|
|
240
|
+
split_reason: 'exceed_token_threshold',
|
|
241
|
+
original_file_token_count: Math.ceil(estimatedTokenCount),
|
|
242
|
+
aggregable: policyRule?.split_aggregable ?? isBestPractice,
|
|
243
|
+
parent_h2: section.title,
|
|
244
|
+
}
|
|
245
|
+
: undefined;
|
|
246
|
+
chunks.push(buildChunk(meta, source, section.title, body, `${baseSlug}#${headingSlug}`, char_start, char_end, fallbackMeta));
|
|
185
247
|
}
|
|
186
|
-
return chunks.length > 0
|
|
248
|
+
return chunks.length > 0
|
|
249
|
+
? chunks
|
|
250
|
+
: chunkMarkdown(source, content.slice(0, defaultSplitThreshold), meta, {
|
|
251
|
+
baseOffset,
|
|
252
|
+
policyRule,
|
|
253
|
+
defaultSplitTokenThreshold: defaultSplitThreshold,
|
|
254
|
+
});
|
|
187
255
|
}
|
|
188
256
|
export function toManifestChunk(chunk) {
|
|
189
257
|
const { content: _content, ...manifestChunk } = chunk;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import * as yaml from 'js-yaml';
|
|
4
|
+
const DEFAULT_POLICY = {
|
|
5
|
+
default: {
|
|
6
|
+
strategy: 'by_h2',
|
|
7
|
+
split_token_threshold: 2048,
|
|
8
|
+
},
|
|
9
|
+
rules: [
|
|
10
|
+
{
|
|
11
|
+
path_prefix: 'knowledge/chat/best-practice/',
|
|
12
|
+
strategy: 'single_chunk_per_file',
|
|
13
|
+
max_tokens: 4096,
|
|
14
|
+
hard_max_tokens: 8192,
|
|
15
|
+
split_fallback: 'by_h2',
|
|
16
|
+
split_aggregable: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
path_prefix: 'knowledge/chat/urls/',
|
|
20
|
+
strategy: 'by_row',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
function toPolicy(raw) {
|
|
25
|
+
if (!raw || typeof raw !== 'object')
|
|
26
|
+
return DEFAULT_POLICY;
|
|
27
|
+
const root = raw;
|
|
28
|
+
const policyObj = (root.chunking_policy && typeof root.chunking_policy === 'object')
|
|
29
|
+
? root.chunking_policy
|
|
30
|
+
: null;
|
|
31
|
+
if (!policyObj)
|
|
32
|
+
return DEFAULT_POLICY;
|
|
33
|
+
const rawDefault = (policyObj.default && typeof policyObj.default === 'object')
|
|
34
|
+
? policyObj.default
|
|
35
|
+
: {};
|
|
36
|
+
const strategy = rawDefault.strategy === 'by_h3' ? 'by_h3' : 'by_h2';
|
|
37
|
+
const splitThreshold = typeof rawDefault.split_token_threshold === 'number'
|
|
38
|
+
? rawDefault.split_token_threshold
|
|
39
|
+
: 2048;
|
|
40
|
+
const rules = Array.isArray(policyObj.rules)
|
|
41
|
+
? policyObj.rules
|
|
42
|
+
.map((item) => {
|
|
43
|
+
if (!item || typeof item !== 'object')
|
|
44
|
+
return null;
|
|
45
|
+
const rule = item;
|
|
46
|
+
const pathPrefix = typeof rule.path_prefix === 'string' ? rule.path_prefix.trim() : '';
|
|
47
|
+
const strategyValue = typeof rule.strategy === 'string' ? rule.strategy : '';
|
|
48
|
+
if (!pathPrefix || !['single_chunk_per_file', 'by_h2', 'by_h3', 'by_row'].includes(strategyValue)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
path_prefix: pathPrefix,
|
|
53
|
+
strategy: strategyValue,
|
|
54
|
+
max_tokens: typeof rule.max_tokens === 'number' ? rule.max_tokens : undefined,
|
|
55
|
+
hard_max_tokens: typeof rule.hard_max_tokens === 'number' ? rule.hard_max_tokens : undefined,
|
|
56
|
+
split_fallback: rule.split_fallback === 'by_h3' ? 'by_h3' : (rule.split_fallback === 'by_h2' ? 'by_h2' : undefined),
|
|
57
|
+
split_aggregable: typeof rule.split_aggregable === 'boolean' ? rule.split_aggregable : undefined,
|
|
58
|
+
split_token_threshold: typeof rule.split_token_threshold === 'number' ? rule.split_token_threshold : undefined,
|
|
59
|
+
};
|
|
60
|
+
})
|
|
61
|
+
.filter((rule) => Boolean(rule))
|
|
62
|
+
: [];
|
|
63
|
+
return {
|
|
64
|
+
default: {
|
|
65
|
+
strategy,
|
|
66
|
+
split_token_threshold: splitThreshold,
|
|
67
|
+
},
|
|
68
|
+
rules,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function extractYamlBlock(markdown) {
|
|
72
|
+
const match = markdown.match(/```ya?ml\n([\s\S]*?)\n```/i);
|
|
73
|
+
return match?.[1] ?? null;
|
|
74
|
+
}
|
|
75
|
+
export function loadChunkingPolicy(policyFilePath) {
|
|
76
|
+
if (!fs.existsSync(policyFilePath)) {
|
|
77
|
+
return DEFAULT_POLICY;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const markdown = fs.readFileSync(policyFilePath, 'utf-8');
|
|
81
|
+
const yamlBlock = extractYamlBlock(markdown);
|
|
82
|
+
if (!yamlBlock)
|
|
83
|
+
return DEFAULT_POLICY;
|
|
84
|
+
const parsed = yaml.load(yamlBlock);
|
|
85
|
+
return toPolicy(parsed);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return DEFAULT_POLICY;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export function resolveChunkingRule(source, policy) {
|
|
92
|
+
const normalized = source.replace(/\\/g, '/');
|
|
93
|
+
const matched = policy.rules
|
|
94
|
+
.filter((rule) => normalized.startsWith(rule.path_prefix.replace(/\\/g, '/')))
|
|
95
|
+
.sort((a, b) => b.path_prefix.length - a.path_prefix.length);
|
|
96
|
+
return matched[0];
|
|
97
|
+
}
|
|
98
|
+
export function resolvePolicyFilePath(knowledgeDirname) {
|
|
99
|
+
return path.resolve(knowledgeDirname, '../../../chunking-policy.md');
|
|
100
|
+
}
|
|
@@ -4,7 +4,9 @@ import { fileURLToPath } from 'url';
|
|
|
4
4
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
5
|
const fileCache = new Map();
|
|
6
6
|
function resolveResourceRoot() {
|
|
7
|
-
//
|
|
7
|
+
// 运行时读 md 源目录(与 knowledge/ 同级的 resource/):
|
|
8
|
+
// npm 包:<pkg>/knowledge/ → <pkg>/resource/
|
|
9
|
+
// 本地: dist/knowledge/ → dist/resource/(依赖 build 时 copy-resource.js)
|
|
8
10
|
return path.resolve(__dirname, '../resource');
|
|
9
11
|
}
|
|
10
12
|
function readSourceFile(source) {
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import * as yaml from 'js-yaml';
|
|
2
|
+
const FRONTMATTER_RE = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
3
|
+
function uniq(arr) {
|
|
4
|
+
return [...new Set(arr)];
|
|
5
|
+
}
|
|
6
|
+
function normalizeString(value) {
|
|
7
|
+
if (typeof value !== 'string')
|
|
8
|
+
return undefined;
|
|
9
|
+
const normalized = value.trim();
|
|
10
|
+
return normalized ? normalized : undefined;
|
|
11
|
+
}
|
|
12
|
+
function normalizeStringArray(value) {
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
const normalized = value
|
|
15
|
+
.map((item) => (typeof item === 'string' ? item.trim() : ''))
|
|
16
|
+
.filter(Boolean);
|
|
17
|
+
return normalized.length ? uniq(normalized) : undefined;
|
|
18
|
+
}
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
const normalized = value
|
|
21
|
+
.split(',')
|
|
22
|
+
.map((item) => item.trim())
|
|
23
|
+
.filter(Boolean);
|
|
24
|
+
return normalized.length ? uniq(normalized) : undefined;
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
function normalizeScenario(value) {
|
|
29
|
+
if (value === 'live' || value === 'voice')
|
|
30
|
+
return value;
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
function normalizeVariant(value) {
|
|
34
|
+
if (value === 'core-sdk' || value === 'preset')
|
|
35
|
+
return value;
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
function normalizeDocKind(value) {
|
|
39
|
+
if (value === 'capability_matrix' || value === 'unsupported_summary' || value === 'negative_faq') {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
function normalizeCapabilityStatus(value) {
|
|
45
|
+
if (value === 'supported' || value === 'unsupported' || value === 'partial' || value === 'version_gated') {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
function normalizeRetrievableScope(value) {
|
|
51
|
+
if (value === 'always')
|
|
52
|
+
return 'always';
|
|
53
|
+
return normalizeStringArray(value);
|
|
54
|
+
}
|
|
55
|
+
function parseFrontmatterObject(input) {
|
|
56
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
return input;
|
|
60
|
+
}
|
|
61
|
+
export function resolveFrontmatterMeta(rawMarkdown) {
|
|
62
|
+
const match = rawMarkdown.match(FRONTMATTER_RE);
|
|
63
|
+
if (!match) {
|
|
64
|
+
return {
|
|
65
|
+
content: rawMarkdown,
|
|
66
|
+
contentOffset: 0,
|
|
67
|
+
hasFrontmatter: false,
|
|
68
|
+
frontmatterMeta: {},
|
|
69
|
+
overrideFields: [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const rawBlock = match[1] ?? '';
|
|
73
|
+
const contentOffset = match[0].length;
|
|
74
|
+
const content = rawMarkdown.slice(contentOffset);
|
|
75
|
+
let parsed;
|
|
76
|
+
try {
|
|
77
|
+
parsed = yaml.load(rawBlock);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const parseError = error instanceof Error ? error.message : String(error);
|
|
81
|
+
return {
|
|
82
|
+
content,
|
|
83
|
+
contentOffset,
|
|
84
|
+
hasFrontmatter: true,
|
|
85
|
+
parseError,
|
|
86
|
+
frontmatterMeta: {},
|
|
87
|
+
overrideFields: [],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const fm = parseFrontmatterObject(parsed);
|
|
91
|
+
const frontmatterMeta = {};
|
|
92
|
+
const overrideFields = [];
|
|
93
|
+
const product = normalizeString(fm.product);
|
|
94
|
+
if (product) {
|
|
95
|
+
frontmatterMeta.product = product;
|
|
96
|
+
overrideFields.push('product');
|
|
97
|
+
}
|
|
98
|
+
const framework = normalizeStringArray(fm.frameworks) ?? normalizeStringArray(fm.framework);
|
|
99
|
+
if (framework?.length) {
|
|
100
|
+
frontmatterMeta.framework = framework;
|
|
101
|
+
overrideFields.push('framework');
|
|
102
|
+
}
|
|
103
|
+
const types = normalizeStringArray(fm.types);
|
|
104
|
+
if (types?.length) {
|
|
105
|
+
frontmatterMeta.types = types;
|
|
106
|
+
overrideFields.push('types');
|
|
107
|
+
}
|
|
108
|
+
const scenario = normalizeScenario(fm.scenario);
|
|
109
|
+
if (scenario !== undefined) {
|
|
110
|
+
frontmatterMeta.scenario = scenario;
|
|
111
|
+
overrideFields.push('scenario');
|
|
112
|
+
}
|
|
113
|
+
const variant = normalizeVariant(fm.variant);
|
|
114
|
+
if (variant) {
|
|
115
|
+
frontmatterMeta.variant = variant;
|
|
116
|
+
overrideFields.push('variant');
|
|
117
|
+
}
|
|
118
|
+
const scope = normalizeString(fm.scope);
|
|
119
|
+
if (scope) {
|
|
120
|
+
frontmatterMeta.scope = scope;
|
|
121
|
+
overrideFields.push('scope');
|
|
122
|
+
}
|
|
123
|
+
const docKind = normalizeDocKind(fm.doc_kind);
|
|
124
|
+
if (docKind) {
|
|
125
|
+
frontmatterMeta.doc_kind = docKind;
|
|
126
|
+
overrideFields.push('doc_kind');
|
|
127
|
+
}
|
|
128
|
+
const capabilityStatus = normalizeCapabilityStatus(fm.capability_status);
|
|
129
|
+
if (capabilityStatus) {
|
|
130
|
+
frontmatterMeta.capability_status = capabilityStatus;
|
|
131
|
+
overrideFields.push('capability_status');
|
|
132
|
+
}
|
|
133
|
+
const retrievableScope = normalizeRetrievableScope(fm.retrievable_scope);
|
|
134
|
+
if (retrievableScope) {
|
|
135
|
+
frontmatterMeta.retrievable_scope = retrievableScope;
|
|
136
|
+
overrideFields.push('retrievable_scope');
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
content,
|
|
140
|
+
contentOffset,
|
|
141
|
+
hasFrontmatter: true,
|
|
142
|
+
frontmatterMeta,
|
|
143
|
+
overrideFields: uniq(overrideFields),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
export function mergePathMetaWithFrontmatter(pathMeta, frontmatterMeta, overrideFields) {
|
|
147
|
+
if (!overrideFields.length) {
|
|
148
|
+
return {
|
|
149
|
+
...pathMeta,
|
|
150
|
+
meta_source: 'path',
|
|
151
|
+
meta_override_fields: [],
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const merged = {
|
|
155
|
+
...pathMeta,
|
|
156
|
+
meta_source: 'merged',
|
|
157
|
+
meta_override_fields: uniq(overrideFields),
|
|
158
|
+
};
|
|
159
|
+
for (const field of overrideFields) {
|
|
160
|
+
const value = frontmatterMeta[field];
|
|
161
|
+
if (value === undefined)
|
|
162
|
+
continue;
|
|
163
|
+
// PathMeta 字段由 frontmatter 显式声明时优先;未声明字段保留路径推断兜底。
|
|
164
|
+
merged[field] = value;
|
|
165
|
+
}
|
|
166
|
+
return merged;
|
|
167
|
+
}
|