@tencent-rtc/mcp 1.4.6 → 1.6.0-beta.1
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/cursor-setting.png +0 -0
- package/knowledge/bm25-cache.js +74 -0
- package/knowledge/bm25-cache.js.map +1 -0
- package/knowledge/bm25.js +148 -0
- package/knowledge/bm25.js.map +1 -0
- package/knowledge/build-index.js +70 -0
- package/knowledge/build-index.js.map +1 -0
- package/knowledge/chunker.js +168 -0
- package/knowledge/chunker.js.map +1 -0
- package/knowledge/content-loader.js +40 -0
- package/knowledge/content-loader.js.map +1 -0
- package/knowledge/doc-url-resolver.js +143 -0
- package/knowledge/doc-url-resolver.js.map +1 -0
- package/knowledge/extractors.js +26 -0
- package/knowledge/extractors.js.map +1 -0
- package/knowledge/path-meta.js +185 -0
- package/knowledge/path-meta.js.map +1 -0
- package/knowledge/search/exact-lookup.js +498 -0
- package/knowledge/search/exact-lookup.js.map +1 -0
- package/knowledge/search/filter-pool.js +105 -0
- package/knowledge/search/filter-pool.js.map +1 -0
- package/knowledge/search/product-scope-intent.js +41 -0
- package/knowledge/search/product-scope-intent.js.map +1 -0
- package/knowledge/search/requires-framework.js +82 -0
- package/knowledge/search/requires-framework.js.map +1 -0
- package/knowledge/search/search-knowledge.js +230 -0
- package/knowledge/search/search-knowledge.js.map +1 -0
- package/mcp-server-prompt.png +0 -0
- package/package.json +1 -1
- package/resource/_schema/feature-aliases.yaml +10 -0
- package/resource/_schema/goal-tags.yaml +72 -0
- package/resource/_schema/products.yaml +19 -0
- package/resource/_schema/trtc-intents.yaml +27 -0
- package/resource/_schema/types.yaml +43 -0
- package/resource/index/component-slugs.json +1 -0
- package/resource/index/doc-source-urls.json +1 -0
- package/resource/index/manifest.json +1 -0
- package/resource/{doc → integration}/callkit/preset/android/integration.md +34 -28
- package/resource/integration/callkit/preset/flutter/integration.md +346 -0
- package/resource/integration/callkit/preset/ios/integration.md +408 -0
- package/resource/integration/callkit/preset/react/integration.md +362 -0
- package/resource/integration/callkit/preset/vue/integration.md +356 -0
- package/resource/integration/chat/preset/android/integration.md +500 -0
- package/resource/integration/chat/preset/flutter/integration.md +370 -0
- package/resource/integration/chat/preset/ios/integration.md +566 -0
- package/resource/integration/chat/preset/react/integration.md +490 -0
- package/resource/integration/chat/preset/vue/integration.md +504 -0
- package/resource/{doc → integration}/livekit/preset/live/vue/live-list-integration.md +26 -22
- package/resource/{doc → integration}/livekit/preset/live/vue/live-player-desk-integration.md +22 -18
- package/resource/integration/livekit/preset/live/vue/live-player-h5-integration.md +309 -0
- package/resource/{doc → integration}/livekit/preset/live/vue/live-pusher-integration.md +47 -39
- package/resource/integration/roomkit/preset/vue/integration.md +562 -0
- package/resource/knowledge/callkit/core-sdk/android/answer-call.md +828 -0
- package/resource/knowledge/callkit/core-sdk/android/make-call.md +897 -0
- package/resource/knowledge/callkit/core-sdk/android/offline-push.md +363 -0
- package/resource/knowledge/callkit/core-sdk/flutter/answer-call.md +1111 -0
- package/resource/knowledge/callkit/core-sdk/flutter/make-call.md +1132 -0
- package/resource/{doc → knowledge}/callkit/core-sdk/flutter/offline-push.md +174 -151
- package/resource/knowledge/callkit/core-sdk/ios/answer-call.md +1084 -0
- package/resource/knowledge/callkit/core-sdk/ios/make-call.md +1252 -0
- package/resource/knowledge/callkit/core-sdk/ios/offline-push.md +534 -0
- package/resource/knowledge/callkit/core-sdk/uni-app/answer-call.md +953 -0
- package/resource/knowledge/callkit/core-sdk/uni-app/make-call.md +1061 -0
- package/resource/knowledge/callkit/faq/android.md +92 -0
- package/resource/{doc/callkit/faq/android-faq.md → knowledge/callkit/faq/common.md} +11 -12
- package/resource/knowledge/callkit/faq/error-code.md +67 -0
- package/resource/knowledge/callkit/faq/flutter.md +52 -0
- package/resource/knowledge/callkit/faq/ios.md +104 -0
- package/resource/knowledge/callkit/faq/web.md +74 -0
- package/resource/knowledge/callkit/preset/android/api.md +412 -0
- package/resource/knowledge/callkit/preset/flutter/api.md +22 -0
- package/resource/knowledge/callkit/preset/ios/api.md +234 -0
- package/resource/knowledge/callkit/preset/web/api.md +83 -0
- package/resource/knowledge/chat/preset/android/features/chat-setting.md +74 -0
- package/resource/knowledge/chat/preset/android/features/contact-list.md +43 -0
- package/resource/knowledge/chat/preset/android/features/conversation-list.md +117 -0
- package/resource/knowledge/chat/preset/android/features/language.md +136 -0
- package/resource/knowledge/chat/preset/android/features/message-input.md +57 -0
- package/resource/knowledge/chat/preset/android/features/message-list.md +142 -0
- package/resource/knowledge/chat/preset/android/features/search.md +64 -0
- package/resource/knowledge/chat/preset/android/features/theme.md +222 -0
- package/resource/knowledge/chat/preset/android-view/integration.md +300 -0
- package/resource/knowledge/chat/preset/flutter/features/chat-setting.md +64 -0
- package/resource/knowledge/chat/preset/flutter/features/contact-list.md +40 -0
- package/resource/knowledge/chat/preset/flutter/features/conversation-list.md +129 -0
- package/resource/knowledge/chat/preset/flutter/features/language.md +104 -0
- package/resource/knowledge/chat/preset/flutter/features/message-input.md +54 -0
- package/resource/knowledge/chat/preset/flutter/features/message-list.md +158 -0
- package/resource/knowledge/chat/preset/flutter/features/search.md +59 -0
- package/resource/knowledge/chat/preset/flutter/features/theme.md +261 -0
- package/resource/knowledge/chat/preset/ios/features/chat-setting.md +94 -0
- package/resource/knowledge/chat/preset/ios/features/contact-list.md +119 -0
- package/resource/knowledge/chat/preset/ios/features/conversation-list.md +134 -0
- package/resource/knowledge/chat/preset/ios/features/language.md +125 -0
- package/resource/knowledge/chat/preset/ios/features/message-input.md +69 -0
- package/resource/knowledge/chat/preset/ios/features/message-list.md +162 -0
- package/resource/knowledge/chat/preset/ios/features/search.md +93 -0
- package/resource/knowledge/chat/preset/ios/features/theme.md +270 -0
- package/resource/{doc/chatkit/ios → knowledge/chat/preset/ios-uikit}/integration.md +160 -158
- package/resource/knowledge/chat/preset/react/features/chat-setting.md +101 -0
- package/resource/{doc/chatkit/react/components → knowledge/chat/preset/react/features}/contact-list.md +43 -41
- package/resource/knowledge/chat/preset/react/features/conversation-actions.md +215 -0
- package/resource/knowledge/chat/preset/react/features/conversation-list.md +339 -0
- package/resource/knowledge/chat/preset/react/features/conversation-preview.md +101 -0
- package/resource/knowledge/chat/preset/react/features/conversation-search.md +61 -0
- package/resource/{doc/chatkit/react/components → knowledge/chat/preset/react/features}/message-input.md +117 -156
- package/resource/knowledge/chat/preset/react/features/message-list.md +297 -0
- package/resource/{doc/chatkit/react/components → knowledge/chat/preset/react/features}/search.md +65 -59
- package/resource/knowledge/chat/preset/react/features/theme.md +93 -0
- package/resource/knowledge/chat/preset/vue/features/chat-header.md +331 -0
- package/resource/knowledge/chat/preset/vue/features/chat-setting.md +79 -0
- package/resource/knowledge/chat/preset/vue/features/contact-list.md +277 -0
- package/resource/knowledge/chat/preset/vue/features/conversation-actions.md +234 -0
- package/resource/knowledge/chat/preset/vue/features/conversation-list.md +331 -0
- package/resource/knowledge/chat/preset/vue/features/conversation-preview.md +216 -0
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/conversation-search.md +13 -13
- package/resource/knowledge/chat/preset/vue/features/message-input.md +551 -0
- package/resource/knowledge/chat/preset/vue/features/message-list.md +350 -0
- package/resource/{doc/chatkit/vue/components → knowledge/chat/preset/vue/features}/search.md +79 -73
- package/resource/knowledge/chat/preset/vue/features/theme.md +136 -0
- package/resource/knowledge/chat/urls/error-code.md +17 -0
- package/resource/knowledge/chat/urls/product.md +43 -0
- package/resource/knowledge/chat/urls/restapi.md +204 -0
- package/resource/knowledge/chat/urls/sdk/android.md +80 -0
- package/resource/knowledge/chat/urls/sdk/flutter.md +71 -0
- package/resource/knowledge/chat/urls/sdk/ios.md +80 -0
- package/resource/knowledge/chat/urls/sdk/web.md +80 -0
- package/resource/knowledge/chat/urls/webhook.md +68 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/AudioEffectStore.md +286 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/BarrageStore.md +174 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/BattleStore.md +329 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/CameraView.md +55 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/CoGuestStore.md +434 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/CoHostStore.md +362 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/DeviceStore.md +466 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/GiftStore.md +173 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LikeStore.md +51 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveAudienceStore.md +291 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveCoreView.md +78 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveSeatStore.md +488 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/android/LoginStore.md +219 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/AudioEffectStore.md +282 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BarrageStore.md +212 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BaseBeautyStore.md +153 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BattleStore.md +312 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/CoGuestStore.md +404 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/CoHostStore.md +334 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/DeviceStore.md +426 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/GiftStore.md +166 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LikeStore.md +52 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveAudienceStore.md +281 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveCoreView.md +150 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveSeatStore.md +438 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LoginStore.md +190 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/AudioEffectStore.md +291 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/BarrageStore.md +192 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/BaseBeautyStore.md +146 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/BattleStore.md +309 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/CoGuestStore.md +370 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/CoHostStore.md +339 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/DeviceStore.md +503 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/GiftStore.md +188 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LikeStore.md +51 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveAudienceStore.md +289 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveCoreView.md +78 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveSeatStore.md +487 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/ios/LoginStore.md +183 -0
- package/resource/knowledge/livekit/core-sdk/api-reference/web/index.md +736 -0
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-audience-list.md +53 -47
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-audio-effect.md +28 -24
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-barrage.md +22 -18
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-base-beauty.md +17 -15
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-co-guest-interaction.md +19 -18
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-gift.md +102 -89
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-host-interaction.md +41 -37
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-integration.md +45 -43
- package/resource/{doc → knowledge}/livekit/core-sdk/live/android/live-live-list.md +23 -20
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-audience-list.md +41 -41
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-audio-effect.md +70 -69
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-barrage.md +68 -71
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-base-beauty.md +43 -47
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-co-guest-interaction.md +59 -56
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-gift.md +103 -105
- package/resource/knowledge/livekit/core-sdk/live/flutter/live-host-interaction.md +869 -0
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-integration.md +84 -87
- package/resource/{doc → knowledge}/livekit/core-sdk/live/flutter/live-live-list.md +43 -40
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-audience-list.md +11 -10
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-audio-effect.md +28 -24
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-barrage.md +22 -18
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-base-beauty.md +15 -14
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-co-guest-interaction.md +19 -18
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-gift.md +54 -50
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-host-interaction.md +41 -37
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-integration.md +40 -40
- package/resource/{doc → knowledge}/livekit/core-sdk/live/ios/live-live-list.md +19 -18
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-audience-list.md +53 -47
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-audio-effect.md +28 -24
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-barrage.md +22 -18
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-co-guest-interaction.md +41 -33
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-gift.md +94 -81
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-host-interaction.md +35 -30
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-integration.md +45 -42
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/android/voice-room-list.md +23 -20
- package/resource/knowledge/livekit/core-sdk/voice/flutter/voice-audience-list.md +260 -0
- package/resource/knowledge/livekit/core-sdk/voice/flutter/voice-audio-effect.md +598 -0
- package/resource/knowledge/livekit/core-sdk/voice/flutter/voice-barrage.md +490 -0
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/flutter/voice-co-guest-interaction.md +65 -59
- package/resource/knowledge/livekit/core-sdk/voice/flutter/voice-gift.md +424 -0
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/flutter/voice-integration.md +69 -76
- package/resource/knowledge/livekit/core-sdk/voice/flutter/voice-room-list.md +726 -0
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-audience-list.md +11 -10
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-audio-effect.md +28 -24
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-barrage.md +22 -18
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-co-guest-interaction.md +41 -33
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-gift.md +54 -50
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-host-interaction.md +35 -30
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-integration.md +49 -46
- package/resource/{doc → knowledge}/livekit/core-sdk/voice/ios/voice-room-list.md +19 -18
- package/resource/knowledge/livekit/faq/error-code.md +193 -0
- package/resource/{doc/livekit/preset/live/vue/components → knowledge/livekit/preset/live/vue/features}/barrage.md +56 -53
- package/resource/{doc/livekit/preset/live/vue/components → knowledge/livekit/preset/live/vue/features}/live-audience-list.md +22 -21
- package/resource/{doc/livekit/preset/live/vue/components → knowledge/livekit/preset/live/vue/features}/live-view.md +34 -32
- package/resource/knowledge/push/config/android.md +92 -0
- package/resource/knowledge/push/config/harmonyos.md +83 -0
- package/resource/knowledge/push/config/ios.md +254 -0
- package/resource/knowledge/push/config/react-native.md +254 -0
- package/resource/knowledge/push/config/unity.md +209 -0
- package/resource/knowledge/push/config/unreal-engine.md +194 -0
- package/resource/knowledge/push/integration/android.md +404 -0
- package/resource/knowledge/push/integration/flutter.md +465 -0
- package/resource/knowledge/push/integration/harmonyos.md +63 -0
- package/resource/knowledge/push/integration/ios.md +246 -0
- package/resource/knowledge/push/integration/react-native.md +366 -0
- package/resource/knowledge/push/integration/uni-app.md +208 -0
- package/resource/knowledge/push/integration/unity.md +389 -0
- package/resource/knowledge/push/integration/unreal-engine.md +390 -0
- package/resource/knowledge/push/overview/prepare.md +60 -0
- package/resource/knowledge/roomkit/core-sdk/android/call-user-to-room.md +241 -0
- package/resource/knowledge/roomkit/core-sdk/android/room-participant-state.md +588 -0
- package/resource/knowledge/roomkit/core-sdk/android/room-state.md +364 -0
- package/resource/knowledge/roomkit/core-sdk/android/schedule-room.md +340 -0
- package/resource/knowledge/roomkit/core-sdk/flutter/call-user-to-room.md +230 -0
- package/resource/knowledge/roomkit/core-sdk/flutter/room-participant-state.md +797 -0
- package/resource/knowledge/roomkit/core-sdk/flutter/room-state.md +325 -0
- package/resource/knowledge/roomkit/core-sdk/flutter/schedule-room.md +325 -0
- package/resource/knowledge/roomkit/core-sdk/ios/call-user-to-room.md +233 -0
- package/resource/knowledge/roomkit/core-sdk/ios/room-participant-state.md +569 -0
- package/resource/knowledge/roomkit/core-sdk/ios/room-state.md +325 -0
- package/resource/knowledge/roomkit/core-sdk/ios/schedule-room.md +322 -0
- package/resource/knowledge/roomkit/core-sdk/vue/call-user-to-room.md +221 -0
- package/resource/{doc/roomkit/vue/features → knowledge/roomkit/core-sdk/vue}/device-detection.md +49 -48
- package/resource/knowledge/roomkit/core-sdk/vue/device-state.md +461 -0
- package/resource/knowledge/roomkit/core-sdk/vue/free-beauty-panel.md +216 -0
- package/resource/knowledge/roomkit/core-sdk/vue/room-chat.md +370 -0
- package/resource/{doc/roomkit/vue/features → knowledge/roomkit/core-sdk/vue}/room-participant-state.md +61 -60
- package/resource/knowledge/roomkit/core-sdk/vue/room-state.md +280 -0
- package/resource/{doc/roomkit/vue/features → knowledge/roomkit/core-sdk/vue}/room-view.md +57 -56
- package/resource/knowledge/roomkit/core-sdk/vue/schedule-room.md +319 -0
- package/resource/knowledge/roomkit/core-sdk/vue/screen-share.md +267 -0
- package/resource/knowledge/roomkit/core-sdk/vue/virtual-background.md +261 -0
- package/resource/knowledge/roomkit/preset/android/integration.md +396 -0
- package/resource/knowledge/roomkit/preset/flutter/integration.md +404 -0
- package/resource/knowledge/roomkit/preset/ios/integration.md +369 -0
- package/resource/knowledge/roomkit/preset/react/integration.md +576 -0
- package/resource/knowledge/rtcengine/web/how_to_run_web_sdk_demo.md +44 -0
- package/resource/{doc → knowledge}/rtcengine/web/plugin/21-advanced-auto-play-policy.md +8 -2
- package/resource/{doc → knowledge}/rtcengine/web/plugin/22-advanced-audio-mixer.md +19 -1
- package/resource/{doc → knowledge}/rtcengine/web/plugin/23-advanced-support-detection.md +1 -1
- package/resource/{doc → knowledge}/rtcengine/web/plugin/24-advanced-network-quality.md +8 -8
- package/resource/{doc → knowledge}/rtcengine/web/plugin/25-advanced-device-change.md +1 -1
- package/resource/{doc → knowledge}/rtcengine/web/plugin/26-advanced-publish-cdn-stream.md +6 -6
- package/resource/{doc → knowledge}/rtcengine/web/plugin/27-advanced-small-stream.md +3 -3
- package/resource/{doc → knowledge}/rtcengine/web/plugin/29-advanced-water-mark.md +18 -0
- package/resource/{doc → knowledge}/rtcengine/web/plugin/31-advanced-plugins-overview.md +1 -1
- package/resource/{doc → knowledge}/rtcengine/web/plugin/34-advanced-proxy.md +2 -2
- package/resource/{doc → knowledge}/rtcengine/web/plugin/35-advanced-ai-denoiser.md +1 -1
- package/resource/knowledge/trtc/android/TRTCCloud.md +1915 -0
- package/resource/knowledge/trtc/android/TRTCCloudDef.md +1029 -0
- package/resource/knowledge/trtc/android/TRTCCloudListener.md +1095 -0
- package/resource/knowledge/trtc/android/TRTCStatistics.md +68 -0
- package/resource/knowledge/trtc/android/TXAudioEffectManager.md +502 -0
- package/resource/knowledge/trtc/android/TXBeautyManager.md +415 -0
- package/resource/knowledge/trtc/android/TXDeviceManager.md +169 -0
- package/resource/knowledge/trtc/android/TXLiteAVCode.md +125 -0
- package/resource/knowledge/trtc/c++/ITRTCCloud.md +2069 -0
- package/resource/knowledge/trtc/c++/ITRTCStatistics.md +73 -0
- package/resource/knowledge/trtc/c++/ITXAudioEffectManager.md +502 -0
- package/resource/knowledge/trtc/c++/ITXDeviceManager.md +391 -0
- package/resource/knowledge/trtc/c++/TRTCCloudCallback.md +1191 -0
- package/resource/knowledge/trtc/c++/TRTCTypeDef.md +931 -0
- package/resource/knowledge/trtc/c++/TXLiteAVCode.md +127 -0
- package/resource/knowledge/trtc/ios/TRTCCloud.md +2118 -0
- package/resource/knowledge/trtc/ios/TRTCCloudDef.md +975 -0
- package/resource/knowledge/trtc/ios/TRTCCloudDelegate.md +1131 -0
- package/resource/knowledge/trtc/ios/TRTCStatistics.md +68 -0
- package/resource/knowledge/trtc/ios/TXAudioEffectManager.md +423 -0
- package/resource/knowledge/trtc/ios/TXBeautyManager.md +416 -0
- package/resource/knowledge/trtc/ios/TXDeviceManager.md +387 -0
- package/resource/knowledge/trtc/ios/TXLiteAVCode.md +127 -0
- package/server.js +35 -10
- package/server.js.map +1 -1
- package/tools/call/get_native_call_uikit_integration.js +2 -3
- package/tools/call/get_native_call_uikit_integration.js.map +1 -1
- package/tools/call/get_native_callkit_core_integration.js +2 -5
- package/tools/call/get_native_callkit_core_integration.js.map +1 -1
- package/tools/call/get_web_call_uikit_integration.js +2 -3
- package/tools/call/get_web_call_uikit_integration.js.map +1 -1
- package/tools/chat/get_native_chat_uikit_integration.js +2 -3
- package/tools/chat/get_native_chat_uikit_integration.js.map +1 -1
- package/tools/chat/get_web_chat_uikit_integration.js +2 -3
- package/tools/chat/get_web_chat_uikit_integration.js.map +1 -1
- package/tools/common/present_framework_choice.js +19 -13
- package/tools/common/present_framework_choice.js.map +1 -1
- package/tools/common/record_answer.js +19 -25
- package/tools/common/record_answer.js.map +1 -1
- package/tools/common/record_feedback.js +17 -30
- package/tools/common/record_feedback.js.map +1 -1
- package/tools/common/search_trtc_knowledge.js +45 -0
- package/tools/common/search_trtc_knowledge.js.map +1 -0
- package/tools/definitions/get_native_call_uikit_integration_def.js +3 -1
- package/tools/definitions/get_native_call_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_native_callkit_core_integration_def.js +5 -3
- package/tools/definitions/get_native_callkit_core_integration_def.js.map +1 -1
- package/tools/definitions/get_native_chat_uikit_integration_def.js +5 -2
- package/tools/definitions/get_native_chat_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_native_livekit_core_integration_def.js +6 -5
- package/tools/definitions/get_native_livekit_core_integration_def.js.map +1 -1
- package/tools/definitions/get_web_call_uikit_integration_def.js +4 -2
- package/tools/definitions/get_web_call_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_web_chat_uikit_integration_def.js +2 -0
- package/tools/definitions/get_web_chat_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_web_live_uikit_integration_def.js +5 -5
- package/tools/definitions/get_web_live_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_web_room_core_integration_def.js +50 -0
- package/tools/definitions/get_web_room_core_integration_def.js.map +1 -0
- package/tools/definitions/get_web_room_uikit_integration_def.js +5 -4
- package/tools/definitions/get_web_room_uikit_integration_def.js.map +1 -1
- package/tools/definitions/integration-boundary.js +6 -0
- package/tools/definitions/integration-boundary.js.map +1 -0
- package/tools/definitions/present_framework_choice_def.js +12 -10
- package/tools/definitions/present_framework_choice_def.js.map +1 -1
- package/tools/definitions/record_answer_def.js +19 -17
- package/tools/definitions/record_answer_def.js.map +1 -1
- package/tools/definitions/record_feedback_def.js +14 -13
- package/tools/definitions/record_feedback_def.js.map +1 -1
- package/tools/definitions/search_trtc_knowledge_def.js +40 -0
- package/tools/definitions/search_trtc_knowledge_def.js.map +1 -0
- package/tools/index.js +5 -36
- package/tools/index.js.map +1 -1
- package/tools/live/get_native_livekit_core_integration.js +1 -3
- package/tools/live/get_native_livekit_core_integration.js.map +1 -1
- package/tools/live/get_web_live_uikit_integration.js +2 -4
- package/tools/live/get_web_live_uikit_integration.js.map +1 -1
- package/tools/room/get_web_room_core_integration.js +48 -0
- package/tools/room/get_web_room_core_integration.js.map +1 -0
- package/tools/room/get_web_room_uikit_integration.js +2 -3
- package/tools/room/get_web_room_uikit_integration.js.map +1 -1
- package/utils/generate-structured-result.js +24 -30
- package/utils/generate-structured-result.js.map +1 -1
- package/utils/get-doc-content.js +14 -8
- package/utils/get-doc-content.js.map +1 -1
- package/utils/report-cls-client.js +18 -20
- package/utils/report-cls-client.js.map +1 -1
- package/utils/report-es-client.js +1 -1
- package/resource/doc/callkit/core-sdk/.gitkeep +0 -0
- package/resource/doc/callkit/core-sdk/android/answer-call.md +0 -852
- package/resource/doc/callkit/core-sdk/android/make-call.md +0 -954
- package/resource/doc/callkit/core-sdk/android/offline-push.md +0 -361
- package/resource/doc/callkit/core-sdk/flutter/answer-call.md +0 -1160
- package/resource/doc/callkit/core-sdk/flutter/make-call.md +0 -1205
- package/resource/doc/callkit/core-sdk/ios/answer-call.md +0 -1090
- package/resource/doc/callkit/core-sdk/ios/make-call.md +0 -1248
- package/resource/doc/callkit/core-sdk/ios/offline-push.md +0 -485
- package/resource/doc/callkit/core-sdk/uni-app/answer-call.md +0 -950
- package/resource/doc/callkit/core-sdk/uni-app/make-call.md +0 -1052
- package/resource/doc/callkit/faq/common/error-code.md +0 -47
- package/resource/doc/callkit/faq/flutter-faq.md +0 -115
- package/resource/doc/callkit/faq/ios-faq.md +0 -115
- package/resource/doc/callkit/faq/web-faq.md +0 -36
- package/resource/doc/callkit/preset/android/api.md +0 -296
- package/resource/doc/callkit/preset/flutter/api.md +0 -410
- package/resource/doc/callkit/preset/flutter/integration.md +0 -164
- package/resource/doc/callkit/preset/ios/api.md +0 -80
- package/resource/doc/callkit/preset/ios/integration.md +0 -187
- package/resource/doc/callkit/preset/react/api.md +0 -501
- package/resource/doc/callkit/preset/react/integration.md +0 -86
- package/resource/doc/callkit/preset/vue/api.md +0 -501
- package/resource/doc/callkit/preset/vue/integration.md +0 -83
- package/resource/doc/chatkit/android/faq.md +0 -111
- package/resource/doc/chatkit/android/features/theme.md +0 -219
- package/resource/doc/chatkit/android/integration.md +0 -490
- package/resource/doc/chatkit/faq/android_sdk/client-api.md +0 -281
- package/resource/doc/chatkit/faq/common/product.md +0 -7
- package/resource/doc/chatkit/faq/common/server.md +0 -44
- package/resource/doc/chatkit/faq/common/server_error_code.md +0 -74
- package/resource/doc/chatkit/faq/flutter_sdk/client-api.md +0 -199
- package/resource/doc/chatkit/faq/flutter_sdk/faq.md +0 -53
- package/resource/doc/chatkit/faq/ios_sdk/client-api.md +0 -235
- package/resource/doc/chatkit/faq/web_sdk/error_code.md +0 -47
- package/resource/doc/chatkit/faq/web_sdk/faq.md +0 -287
- package/resource/doc/chatkit/flutter/faq.md +0 -23
- package/resource/doc/chatkit/flutter/features/theme.md +0 -235
- package/resource/doc/chatkit/flutter/integration.md +0 -344
- package/resource/doc/chatkit/ios/faq.md +0 -111
- package/resource/doc/chatkit/ios/features/theme.md +0 -267
- package/resource/doc/chatkit/react/components/avatar.md +0 -104
- package/resource/doc/chatkit/react/components/chat-header.md +0 -148
- package/resource/doc/chatkit/react/components/chat-setting.md +0 -57
- package/resource/doc/chatkit/react/components/chat.md +0 -38
- package/resource/doc/chatkit/react/components/component-list.md +0 -37
- package/resource/doc/chatkit/react/components/conversation-actions.md +0 -174
- package/resource/doc/chatkit/react/components/conversation-list.md +0 -333
- package/resource/doc/chatkit/react/components/conversation-preview.md +0 -118
- package/resource/doc/chatkit/react/components/conversation-search.md +0 -60
- package/resource/doc/chatkit/react/components/message-list.md +0 -293
- package/resource/doc/chatkit/react/components/tuikit.md +0 -34
- package/resource/doc/chatkit/react/faq.md +0 -26
- package/resource/doc/chatkit/react/integration.md +0 -416
- package/resource/doc/chatkit/vue/components/avatar.md +0 -104
- package/resource/doc/chatkit/vue/components/chat-header.md +0 -148
- package/resource/doc/chatkit/vue/components/chat-setting.md +0 -62
- package/resource/doc/chatkit/vue/components/chat.md +0 -45
- package/resource/doc/chatkit/vue/components/component-list.md +0 -87
- package/resource/doc/chatkit/vue/components/contact-list.md +0 -271
- package/resource/doc/chatkit/vue/components/conversation-actions.md +0 -228
- package/resource/doc/chatkit/vue/components/conversation-list.md +0 -320
- package/resource/doc/chatkit/vue/components/conversation-preview.md +0 -213
- package/resource/doc/chatkit/vue/components/message-input.md +0 -1054
- package/resource/doc/chatkit/vue/components/message-list.md +0 -433
- package/resource/doc/chatkit/vue/components/tuikit.md +0 -31
- package/resource/doc/chatkit/vue/components/userpicker.md +0 -256
- package/resource/doc/chatkit/vue/faq.md +0 -36
- package/resource/doc/chatkit/vue/integration.md +0 -428
- package/resource/doc/livekit/core-sdk/live/flutter/live-host-interaction.md +0 -866
- package/resource/doc/livekit/faq/common/error-code.md +0 -88
- package/resource/doc/livekit/preset/live/vue/api-reference/index.md +0 -780
- package/resource/doc/livekit/preset/live/vue/components/co-guest-panel.md +0 -91
- package/resource/doc/livekit/preset/live/vue/components/live-scene-panel.md +0 -112
- package/resource/doc/livekit/preset/live/vue/components/stream-mixer.md +0 -215
- package/resource/doc/livekit/preset/live/vue/live-player-h5-integration.md +0 -300
- package/resource/doc/roomkit/faq/common/error-code.md +0 -67
- package/resource/doc/roomkit/vue/features/call-user-to-room.md +0 -220
- package/resource/doc/roomkit/vue/features/device-state.md +0 -460
- package/resource/doc/roomkit/vue/features/free-beauty-panel.md +0 -215
- package/resource/doc/roomkit/vue/features/room-chat.md +0 -369
- package/resource/doc/roomkit/vue/features/room-state.md +0 -282
- package/resource/doc/roomkit/vue/features/schedule-room.md +0 -318
- package/resource/doc/roomkit/vue/features/screen-share.md +0 -265
- package/resource/doc/roomkit/vue/features/virtual-background.md +0 -271
- package/resource/doc/roomkit/vue/integration.md +0 -315
- package/resource/doc/rtcengine/faq/common/error_code.md +0 -1
- package/resource/doc/rtcengine/faq/web_sdk/.gitkeep +0 -0
- package/resource/doc/rtcengine/web/.gitkeep +0 -0
- package/resource/doc/rtcengine/web/how_to_run_web_sdk_demo.md +0 -59
- package/resource/doc/trtc/C++/ITRTCCloud.md +0 -1970
- package/resource/doc/trtc/C++/ITRTCStatistics.md +0 -70
- package/resource/doc/trtc/C++/ITXAudioEffectManager.md +0 -469
- package/resource/doc/trtc/C++/ITXDeviceManager.md +0 -387
- package/resource/doc/trtc/C++/TRTCCloudCallback.md +0 -1082
- package/resource/doc/trtc/C++/TRTCTypeDef.md +0 -925
- package/resource/doc/trtc/C++/TXLiteAVCode.md +0 -129
- package/resource/doc/trtc/android/TRTCCloud.md +0 -1815
- package/resource/doc/trtc/android/TRTCCloudDef.md +0 -992
- package/resource/doc/trtc/android/TRTCCloudListener.md +0 -1004
- package/resource/doc/trtc/android/TRTCStatistics.md +0 -65
- package/resource/doc/trtc/android/TXAudioEffectManager.md +0 -469
- package/resource/doc/trtc/android/TXBeautyManager.md +0 -402
- package/resource/doc/trtc/android/TXDeviceManager.md +0 -173
- package/resource/doc/trtc/android/TXLiteAVCode.md +0 -127
- package/resource/doc/trtc/iOS/TRTCCloud.md +0 -2028
- package/resource/doc/trtc/iOS/TRTCCloudDef.md +0 -958
- package/resource/doc/trtc/iOS/TRTCCloudDelegate.md +0 -1046
- package/resource/doc/trtc/iOS/TRTCStatistics.md +0 -65
- package/resource/doc/trtc/iOS/TXAudioEffectManager.md +0 -397
- package/resource/doc/trtc/iOS/TXBeautyManager.md +0 -403
- package/resource/doc/trtc/iOS/TXDeviceManager.md +0 -381
- package/resource/doc/trtc/iOS/TXLiteAVCode.md +0 -130
- package/tools/call/get_callkit_api.js +0 -33
- package/tools/call/get_callkit_api.js.map +0 -1
- package/tools/chat/get_native_chat_uikit_feature_detail.js +0 -35
- package/tools/chat/get_native_chat_uikit_feature_detail.js.map +0 -1
- package/tools/chat/get_web_chat_uikit_component_detail.js +0 -35
- package/tools/chat/get_web_chat_uikit_component_detail.js.map +0 -1
- package/tools/common/get_faq.js +0 -266
- package/tools/common/get_faq.js.map +0 -1
- package/tools/common/record_skill_session.js +0 -69
- package/tools/common/record_skill_session.js.map +0 -1
- package/tools/definitions/get_callkit_api_def.js +0 -29
- package/tools/definitions/get_callkit_api_def.js.map +0 -1
- package/tools/definitions/get_faq_def.js +0 -49
- package/tools/definitions/get_faq_def.js.map +0 -1
- package/tools/definitions/get_native_chat_uikit_feature_detail_def.js +0 -31
- package/tools/definitions/get_native_chat_uikit_feature_detail_def.js.map +0 -1
- package/tools/definitions/get_native_livekit_core_features_def.js +0 -34
- package/tools/definitions/get_native_livekit_core_features_def.js.map +0 -1
- package/tools/definitions/get_native_trtc_sdk_docs_def.js +0 -32
- package/tools/definitions/get_native_trtc_sdk_docs_def.js.map +0 -1
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js +0 -31
- package/tools/definitions/get_web_chat_uikit_component_detail_def.js.map +0 -1
- package/tools/definitions/get_web_livekit_api_def.js +0 -30
- package/tools/definitions/get_web_livekit_api_def.js.map +0 -1
- package/tools/definitions/get_web_livekit_component_detail_def.js +0 -32
- package/tools/definitions/get_web_livekit_component_detail_def.js.map +0 -1
- package/tools/definitions/get_web_roomkit_feature_detail_def.js +0 -31
- package/tools/definitions/get_web_roomkit_feature_detail_def.js.map +0 -1
- package/tools/definitions/get_web_trtc_sdk_api_def.js +0 -27
- package/tools/definitions/get_web_trtc_sdk_api_def.js.map +0 -1
- package/tools/definitions/get_web_trtc_sdk_integration_def.js +0 -27
- package/tools/definitions/get_web_trtc_sdk_integration_def.js.map +0 -1
- package/tools/definitions/get_web_trtc_sdk_plugin_def.js +0 -27
- package/tools/definitions/get_web_trtc_sdk_plugin_def.js.map +0 -1
- package/tools/definitions/record_skill_session_def.js +0 -31
- package/tools/definitions/record_skill_session_def.js.map +0 -1
- package/tools/live/get_native_livekit_core_features.js +0 -68
- package/tools/live/get_native_livekit_core_features.js.map +0 -1
- package/tools/live/get_web_livekit_api.js +0 -33
- package/tools/live/get_web_livekit_api.js.map +0 -1
- package/tools/live/get_web_livekit_component_detail.js +0 -35
- package/tools/live/get_web_livekit_component_detail.js.map +0 -1
- package/tools/room/get_web_roomkit_feature_detail.js +0 -69
- package/tools/room/get_web_roomkit_feature_detail.js.map +0 -1
- package/tools/rtcengine/get_web_trtc_sdk_api.js +0 -32
- package/tools/rtcengine/get_web_trtc_sdk_api.js.map +0 -1
- package/tools/rtcengine/get_web_trtc_sdk_integration.js +0 -32
- package/tools/rtcengine/get_web_trtc_sdk_integration.js.map +0 -1
- package/tools/rtcengine/get_web_trtc_sdk_plugin.js +0 -32
- package/tools/rtcengine/get_web_trtc_sdk_plugin.js.map +0 -1
- package/tools/trtc/get_native_trtc_sdk_docs.js +0 -74
- package/tools/trtc/get_native_trtc_sdk_docs.js.map +0 -1
- package/utils/build-session-directives.js +0 -120
- package/utils/build-session-directives.js.map +0 -1
- package/utils/handle-framework.js +0 -9
- package/utils/handle-framework.js.map +0 -1
- package/utils/handle-state-name.js +0 -29
- package/utils/handle-state-name.js.map +0 -1
- package/utils/report-runtime-error-cls-client.js +0 -91
- package/utils/report-runtime-error-cls-client.js.map +0 -1
- /package/resource/{doc/livekit/preset/live/vue/faq.md → knowledge/push/config/donut.md} +0 -0
- /package/resource/{doc/roomkit/vue/faq.md → knowledge/push/integration/donut.md} +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/api.md +0 -0
- /package/resource/{doc/rtcengine/faq/web/web.md → knowledge/rtcengine/web/faq.md} +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/how_to_integrated_web_sdk.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/20-advanced-customized-capture-rendering.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/28-advanced-beauty.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/30-advanced-cross-room-link.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/36-advanced-virtual-background.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/37-advanced-voice-changer.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/39-advanced-video-decoder.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/40-advanced-video-mixer.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/41-advanced-small-stream-auto-switcher.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/42-advanced-realtime-transcriber.md +0 -0
- /package/resource/{doc → knowledge}/rtcengine/web/plugin/43-advanced-face-detection.md +0 -0
package/cursor-setting.png
CHANGED
|
Binary file
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { attachPoolContent } from './content-loader.js';
|
|
2
|
+
import { buildBM25Index, chunkSearchText } from './bm25.js';
|
|
3
|
+
/**
|
|
4
|
+
* 按 product 维度 lazy 构建 BM25 索引并进程内缓存。
|
|
5
|
+
*
|
|
6
|
+
* 设计要点:
|
|
7
|
+
* - cache key = product(未指定时用 '*',对全 manifest 建索引)
|
|
8
|
+
* - 索引基于该 product 全部 chunks(含 integration corpus),子集 ranking 只看 filteredPool.map(id)
|
|
9
|
+
* - 首次按 product 触发,后续命中缓存零开销;约 8 个 product 自然分摊冷启动成本
|
|
10
|
+
* - 不落盘,纯进程常驻;体积粗估 8~12MB(postings + idf)
|
|
11
|
+
*/
|
|
12
|
+
const indexCache = new Map();
|
|
13
|
+
const GLOBAL_KEY = '*';
|
|
14
|
+
function cacheKey(product) {
|
|
15
|
+
return product ?? GLOBAL_KEY;
|
|
16
|
+
}
|
|
17
|
+
function selectProductChunks(allChunks, product) {
|
|
18
|
+
if (!product)
|
|
19
|
+
return allChunks;
|
|
20
|
+
return allChunks.filter((chunk) => chunk.product === product || chunk.product === '*');
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 获取 product 级 BM25 索引:缓存命中则零开销,否则按 product 切 chunks,
|
|
24
|
+
* attachPoolContent 拉正文后一次性建索引并入缓存。
|
|
25
|
+
*
|
|
26
|
+
* 性能特征:
|
|
27
|
+
* - 命中:O(1)
|
|
28
|
+
* - miss:O(P · avgDocLen) 仅一次,P 为该 product 的 chunk 数
|
|
29
|
+
*/
|
|
30
|
+
export function getProductBM25Index(allChunks, product) {
|
|
31
|
+
const key = cacheKey(product);
|
|
32
|
+
const cached = indexCache.get(key);
|
|
33
|
+
if (cached)
|
|
34
|
+
return cached;
|
|
35
|
+
const productChunks = selectProductChunks(allChunks, product);
|
|
36
|
+
const withContent = attachPoolContent(productChunks);
|
|
37
|
+
const index = buildBM25Index(withContent.map((chunk) => ({
|
|
38
|
+
id: chunk.id,
|
|
39
|
+
text: chunkSearchText(chunk),
|
|
40
|
+
})));
|
|
41
|
+
indexCache.set(key, index);
|
|
42
|
+
return index;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 多 product BM25 索引:products 数组中有任一未缓存时,
|
|
46
|
+
* 合并所有指定 product 的 chunks 构建索引并缓存(key = 排序 join)。
|
|
47
|
+
*/
|
|
48
|
+
export function getProductsBM25Index(allChunks, products) {
|
|
49
|
+
if (!products || products.length === 0)
|
|
50
|
+
return getProductBM25Index(allChunks, undefined);
|
|
51
|
+
if (products.length === 1)
|
|
52
|
+
return getProductBM25Index(allChunks, products[0]);
|
|
53
|
+
const key = [...products].sort().join('|');
|
|
54
|
+
const cached = indexCache.get(key);
|
|
55
|
+
if (cached)
|
|
56
|
+
return cached;
|
|
57
|
+
const productChunks = allChunks.filter((chunk) => products.includes(chunk.product) || chunk.product === '*');
|
|
58
|
+
const withContent = attachPoolContent(productChunks);
|
|
59
|
+
const index = buildBM25Index(withContent.map((chunk) => ({
|
|
60
|
+
id: chunk.id,
|
|
61
|
+
text: chunkSearchText(chunk),
|
|
62
|
+
})));
|
|
63
|
+
indexCache.set(key, index);
|
|
64
|
+
return index;
|
|
65
|
+
}
|
|
66
|
+
/** 测试用:清空缓存(生产代码不应调用) */
|
|
67
|
+
export function clearBM25Cache() {
|
|
68
|
+
indexCache.clear();
|
|
69
|
+
}
|
|
70
|
+
/** 调试用:返回当前缓存的 product 列表 */
|
|
71
|
+
export function listCachedProducts() {
|
|
72
|
+
return [...indexCache.keys()];
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=bm25-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bm25-cache.js","sourceRoot":"","sources":["../../src/knowledge/bm25-cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAkB,MAAM,WAAW,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;AAEhD,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,SAAS,QAAQ,CAAC,OAAgB;IAChC,OAAO,OAAO,IAAI,UAAU,CAAC;AAC/B,CAAC;AAED,SAAS,mBAAmB,CAAC,SAA0B,EAAE,OAAgB;IACvE,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,GAAG,CAAC,CAAC;AACzF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAA0B,EAAE,OAAgB;IAC9E,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,MAAM;QAAE,OAAO,MAAM,CA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C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1B,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC;KAC7B,CAAC,CAAC,CACJ,CAAC;IACF,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,yBAAyB;AACzB,MAAM,UAAU,cAAc;IAC5B,UAAU,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,kBAAkB;IAChC,OAAO,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const K1 = 1.5;
|
|
2
|
+
const B = 0.75;
|
|
3
|
+
/**
|
|
4
|
+
* 中文停用词:高频功能词,参与 BM25 会稀释关键术语权重。
|
|
5
|
+
* 覆盖:疑问代词、助词、人称、连接词、模糊量词、敬辞。
|
|
6
|
+
*/
|
|
7
|
+
const CN_STOPWORDS = new Set([
|
|
8
|
+
'怎么', '如何', '什么', '哪些', '哪个', '为何', '为啥', '是否',
|
|
9
|
+
'可以', '能够', '需要', '想要', '应该', '请问', '麻烦',
|
|
10
|
+
'一下', '一个', '这个', '那个', '这些', '那些', '里面', '外面',
|
|
11
|
+
'使用', '用法', '用于', '用来', '进行', '实现', '提供', '支持',
|
|
12
|
+
'问题', '情况', '场景', '方式', '方法', '功能', '能力',
|
|
13
|
+
'我们', '你们', '他们', '自己', '大家',
|
|
14
|
+
'以及', '或者', '还是', '但是', '然后', '所以', '因为', '如果',
|
|
15
|
+
'已经', '正在', '马上', '立即', '总是', '一直',
|
|
16
|
+
]);
|
|
17
|
+
/** 英文停用词:限制在常见 query 噪声词,避免误删技术语义词(如 'use', 'set' 这种命名前缀保留) */
|
|
18
|
+
const EN_STOPWORDS = new Set([
|
|
19
|
+
'a', 'an', 'the', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
20
|
+
'and', 'or', 'but', 'if', 'then', 'so', 'as', 'of', 'at', 'by', 'for', 'in', 'on', 'to',
|
|
21
|
+
'do', 'does', 'did', 'have', 'has', 'had',
|
|
22
|
+
'this', 'that', 'these', 'those',
|
|
23
|
+
'how', 'what', 'why', 'when', 'where', 'which', 'who',
|
|
24
|
+
'i', 'we', 'you', 'they', 'it', 'me', 'us', 'them',
|
|
25
|
+
'pls', 'please', 'thanks',
|
|
26
|
+
]);
|
|
27
|
+
function isStopwordCJK(token) {
|
|
28
|
+
return CN_STOPWORDS.has(token);
|
|
29
|
+
}
|
|
30
|
+
function isStopwordEN(token) {
|
|
31
|
+
return EN_STOPWORDS.has(token);
|
|
32
|
+
}
|
|
33
|
+
export function tokenize(text) {
|
|
34
|
+
const tokens = [];
|
|
35
|
+
const lower = text.toLowerCase();
|
|
36
|
+
// 英文/数字 token:跳过停用词;保留长度 ≥ 2 的(避免单字符 'i', 'a' 漏入)
|
|
37
|
+
for (const match of lower.matchAll(/[a-z0-9_]+/g)) {
|
|
38
|
+
const tok = match[0];
|
|
39
|
+
if (tok.length === 1)
|
|
40
|
+
continue;
|
|
41
|
+
if (isStopwordEN(tok))
|
|
42
|
+
continue;
|
|
43
|
+
tokens.push(tok);
|
|
44
|
+
}
|
|
45
|
+
// 中文 token:bigram + unigram 两级
|
|
46
|
+
// - bigram:跳过包含停用词单字的组合(如「怎么调用」的「怎么」)以及任一位是常见停用字
|
|
47
|
+
// - unigram:跳过纯停用单字(用一个收敛的单字停用集合)
|
|
48
|
+
const cjk = text.replace(/[^\u4e00-\u9fff]/g, '');
|
|
49
|
+
for (let i = 0; i < cjk.length - 1; i += 1) {
|
|
50
|
+
const bigram = cjk.slice(i, i + 2);
|
|
51
|
+
if (isStopwordCJK(bigram))
|
|
52
|
+
continue;
|
|
53
|
+
tokens.push(bigram);
|
|
54
|
+
}
|
|
55
|
+
// 单字仅保留有信息量的(中文单字普遍信息量低,全部塞入会拉低 IDF;
|
|
56
|
+
// 简化策略:只在 bigram 路径之外补充长度 ≥ 3 的连续单字组合的首尾,避免噪声爆炸)
|
|
57
|
+
// 实践上保留 unigram 但不参与停用词过滤——让 BM25 的 IDF 自然衰减它们的权重。
|
|
58
|
+
for (let i = 0; i < cjk.length; i += 1) {
|
|
59
|
+
tokens.push(cjk[i]);
|
|
60
|
+
}
|
|
61
|
+
return tokens;
|
|
62
|
+
}
|
|
63
|
+
export function buildBM25Index(documents) {
|
|
64
|
+
const postings = {};
|
|
65
|
+
const docLengths = {};
|
|
66
|
+
const docFreq = {};
|
|
67
|
+
let totalLength = 0;
|
|
68
|
+
for (const doc of documents) {
|
|
69
|
+
const tokens = tokenize(doc.text);
|
|
70
|
+
docLengths[doc.id] = tokens.length;
|
|
71
|
+
totalLength += tokens.length;
|
|
72
|
+
const termFreq = {};
|
|
73
|
+
for (const token of tokens) {
|
|
74
|
+
termFreq[token] = (termFreq[token] ?? 0) + 1;
|
|
75
|
+
}
|
|
76
|
+
for (const [term, freq] of Object.entries(termFreq)) {
|
|
77
|
+
if (!postings[term])
|
|
78
|
+
postings[term] = {};
|
|
79
|
+
postings[term][doc.id] = freq;
|
|
80
|
+
docFreq[term] = (docFreq[term] ?? 0) + 1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const n = documents.length;
|
|
84
|
+
const avgDocLength = n > 0 ? totalLength / n : 0;
|
|
85
|
+
const idf = {};
|
|
86
|
+
for (const [term, df] of Object.entries(docFreq)) {
|
|
87
|
+
idf[term] = Math.log(1 + (n - df + 0.5) / (df + 0.5));
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
version: 1,
|
|
91
|
+
avgDocLength,
|
|
92
|
+
docLengths,
|
|
93
|
+
idf,
|
|
94
|
+
postings,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export function scoreBM25(query, chunkId, index) {
|
|
98
|
+
const tokens = tokenize(query);
|
|
99
|
+
const docLength = index.docLengths[chunkId] ?? 0;
|
|
100
|
+
if (docLength === 0)
|
|
101
|
+
return 0;
|
|
102
|
+
let score = 0;
|
|
103
|
+
for (const term of tokens) {
|
|
104
|
+
const tf = index.postings[term]?.[chunkId] ?? 0;
|
|
105
|
+
if (tf === 0)
|
|
106
|
+
continue;
|
|
107
|
+
const idf = index.idf[term] ?? 0;
|
|
108
|
+
const numerator = tf * (K1 + 1);
|
|
109
|
+
const denominator = tf + K1 * (1 - B + B * (docLength / (index.avgDocLength || 1)));
|
|
110
|
+
score += idf * (numerator / denominator);
|
|
111
|
+
}
|
|
112
|
+
return score;
|
|
113
|
+
}
|
|
114
|
+
export function rankBM25(query, chunkIds, index, boosts = {}) {
|
|
115
|
+
return chunkIds
|
|
116
|
+
.map((id) => ({
|
|
117
|
+
id,
|
|
118
|
+
score: scoreBM25(query, id, index) + (boosts[id] ?? 0),
|
|
119
|
+
}))
|
|
120
|
+
.sort((a, b) => b.score - a.score);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* BM25 检索文本:title 重复 3 次以提权(标题语义浓度远高于正文,按业界惯例 boost)。
|
|
124
|
+
* symbols / error_codes 同样保留以便精确名匹配;正文走原内容。
|
|
125
|
+
*/
|
|
126
|
+
export function chunkSearchText(parts) {
|
|
127
|
+
const titleBoosted = [parts.title, parts.title, parts.title].filter(Boolean).join(' ');
|
|
128
|
+
return [titleBoosted, parts.content ?? '', ...parts.symbols, ...parts.error_codes].filter(Boolean).join(' ');
|
|
129
|
+
}
|
|
130
|
+
export function rankPoolBM25(query, pool, boosts = {}) {
|
|
131
|
+
if (pool.length === 0)
|
|
132
|
+
return [];
|
|
133
|
+
const index = buildBM25Index(pool.map((chunk) => ({
|
|
134
|
+
id: chunk.id,
|
|
135
|
+
text: chunkSearchText(chunk),
|
|
136
|
+
})));
|
|
137
|
+
return rankBM25(query, pool.map((chunk) => chunk.id), index, boosts);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 基于预构建的 BM25 索引对一个 chunk-id 子集打分,跳过 tokenize + IDF 重算。
|
|
141
|
+
* 调用方需保证 chunkIds ⊆ index 已收录的 id 集合,否则未收录的 id 会返回 score=0。
|
|
142
|
+
*/
|
|
143
|
+
export function rankSubsetWithIndex(query, chunkIds, index, boosts = {}) {
|
|
144
|
+
if (chunkIds.length === 0)
|
|
145
|
+
return [];
|
|
146
|
+
return rankBM25(query, chunkIds, index, boosts);
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=bm25.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bm25.js","sourceRoot":"","sources":["../../src/knowledge/bm25.ts"],"names":[],"mappings":"AAQA,MAAM,EAAE,GAAG,GAAG,CAAC;AACf,MAAM,CAAC,GAAG,IAAI,CAAC;AAEf;;;GAGG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC9C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IACxC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC9C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC9C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IACxC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC9C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,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AE,KAAK,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { chunkMarkdown, toManifestChunk } from './chunker.js';
|
|
5
|
+
import { buildDocSourceUrlMap } from './doc-url-resolver.js';
|
|
6
|
+
import { inferPathMeta } from './path-meta.js';
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const RESOURCE_ROOT = path.resolve(__dirname, '../resource');
|
|
9
|
+
function walkMarkdownFiles(dir, baseRel) {
|
|
10
|
+
if (!fs.existsSync(dir))
|
|
11
|
+
return [];
|
|
12
|
+
const files = [];
|
|
13
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
14
|
+
const rel = `${baseRel}/${entry.name}`.replace(/\\/g, '/');
|
|
15
|
+
const abs = path.join(dir, entry.name);
|
|
16
|
+
if (entry.isDirectory()) {
|
|
17
|
+
if (entry.name === 'native_live')
|
|
18
|
+
continue;
|
|
19
|
+
files.push(...walkMarkdownFiles(abs, rel));
|
|
20
|
+
}
|
|
21
|
+
else if (entry.name.endsWith('.md') && entry.name !== 'workflow.md') {
|
|
22
|
+
files.push(rel);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return files;
|
|
26
|
+
}
|
|
27
|
+
function collectComponentSlugs(chunks) {
|
|
28
|
+
const slugs = {};
|
|
29
|
+
for (const chunk of chunks) {
|
|
30
|
+
const componentsMatch = chunk.source.match(/components\/([^/]+)\.md$/);
|
|
31
|
+
const chatFeaturesMatch = chunk.source.match(/^knowledge\/chat\/preset\/(vue|react)\/features\/([^/]+)\.md$/);
|
|
32
|
+
const slug = componentsMatch?.[1] ?? chatFeaturesMatch?.[2];
|
|
33
|
+
if (!slug)
|
|
34
|
+
continue;
|
|
35
|
+
slugs[slug] = [slug, slug.replace(/-/g, ''), slug.replace(/-/g, '_')];
|
|
36
|
+
}
|
|
37
|
+
return slugs;
|
|
38
|
+
}
|
|
39
|
+
export function buildKnowledgeIndex() {
|
|
40
|
+
const sources = [
|
|
41
|
+
...walkMarkdownFiles(path.join(RESOURCE_ROOT, 'knowledge'), 'knowledge'),
|
|
42
|
+
...walkMarkdownFiles(path.join(RESOURCE_ROOT, 'integration'), 'integration'),
|
|
43
|
+
];
|
|
44
|
+
const chunks = [];
|
|
45
|
+
for (const source of sources) {
|
|
46
|
+
const abs = path.join(RESOURCE_ROOT, source);
|
|
47
|
+
const content = fs.readFileSync(abs, 'utf-8');
|
|
48
|
+
const meta = inferPathMeta(source);
|
|
49
|
+
chunks.push(...chunkMarkdown(source, content, meta).map(toManifestChunk));
|
|
50
|
+
}
|
|
51
|
+
const indexDir = path.join(RESOURCE_ROOT, 'index');
|
|
52
|
+
fs.mkdirSync(indexDir, { recursive: true });
|
|
53
|
+
const manifest = {
|
|
54
|
+
version: 1,
|
|
55
|
+
built_at: new Date().toISOString(),
|
|
56
|
+
chunks,
|
|
57
|
+
};
|
|
58
|
+
const componentSlugs = collectComponentSlugs(chunks);
|
|
59
|
+
fs.writeFileSync(path.join(indexDir, 'manifest.json'), JSON.stringify(manifest));
|
|
60
|
+
fs.writeFileSync(path.join(indexDir, 'component-slugs.json'), JSON.stringify(componentSlugs));
|
|
61
|
+
const syncManifestPath = path.resolve(__dirname, '../../sync/sync-manifest.json');
|
|
62
|
+
const docSourceUrls = buildDocSourceUrlMap(syncManifestPath);
|
|
63
|
+
fs.writeFileSync(path.join(indexDir, 'doc-source-urls.json'), JSON.stringify(docSourceUrls));
|
|
64
|
+
const staleSearchIndex = path.join(indexDir, 'search-index.json');
|
|
65
|
+
if (fs.existsSync(staleSearchIndex)) {
|
|
66
|
+
fs.unlinkSync(staleSearchIndex);
|
|
67
|
+
}
|
|
68
|
+
console.warn(`build-knowledge-index: ${chunks.length} chunks (manifest-lite) from ${sources.length} files`);
|
|
69
|
+
}
|
|
70
|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AC,aAAa,CAAC,CAAC,CAAC;IAE7F,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;IAClE,IAAI,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACpC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,0BAA0B,MAAM,CAAC,MAAM,gCAAgC,OAAO,CAAC,MAAM,QAAQ,CAAC,CAAC;AAC9G,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { extractErrorCodes, extractSymbols } from './extractors.js';
|
|
2
|
+
function slugify(text) {
|
|
3
|
+
return text
|
|
4
|
+
.trim()
|
|
5
|
+
.toLowerCase()
|
|
6
|
+
.replace(/[^\w\u4e00-\u9fff]+/g, '-')
|
|
7
|
+
.replace(/^-+|-+$/g, '') || 'section';
|
|
8
|
+
}
|
|
9
|
+
function sourceSlug(source) {
|
|
10
|
+
return source.replace(/\.md$/, '').replace(/[/\\]/g, '-');
|
|
11
|
+
}
|
|
12
|
+
function trimSliceOffsets(raw, fileStart) {
|
|
13
|
+
const leading = raw.length - raw.trimStart().length;
|
|
14
|
+
const trailing = raw.length - raw.trimEnd().length;
|
|
15
|
+
const char_start = fileStart + leading;
|
|
16
|
+
const char_end = fileStart + raw.length - trailing;
|
|
17
|
+
return { body: raw.slice(leading, raw.length - trailing), char_start, char_end };
|
|
18
|
+
}
|
|
19
|
+
function splitByHeading(content, level) {
|
|
20
|
+
const regex = new RegExp(`^${'#'.repeat(level)}\\s+(.+)$`, 'gm');
|
|
21
|
+
const sections = [];
|
|
22
|
+
const matches = [...content.matchAll(regex)];
|
|
23
|
+
if (matches.length === 0) {
|
|
24
|
+
return [{ title: 'full', raw: content, start: 0 }];
|
|
25
|
+
}
|
|
26
|
+
for (let i = 0; i < matches.length; i += 1) {
|
|
27
|
+
const match = matches[i];
|
|
28
|
+
const start = match.index ?? 0;
|
|
29
|
+
const end = i + 1 < matches.length ? (matches[i + 1].index ?? content.length) : content.length;
|
|
30
|
+
sections.push({
|
|
31
|
+
title: match[1].trim(),
|
|
32
|
+
raw: content.slice(start, end),
|
|
33
|
+
start,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return sections;
|
|
37
|
+
}
|
|
38
|
+
function isFaqLike(source, content) {
|
|
39
|
+
return /faq|error-code|error_code|TXLiteAVCode/i.test(source) || (content.match(/^###\s+/gm) ?? []).length >= 3;
|
|
40
|
+
}
|
|
41
|
+
function isChatUrlMapping(source) {
|
|
42
|
+
return /knowledge\/chat\/urls\/.+\.md$/i.test(source.replace(/\\/g, '/'));
|
|
43
|
+
}
|
|
44
|
+
function parseUrlMappingRows(content) {
|
|
45
|
+
const lines = content.split('\n');
|
|
46
|
+
let sectionTitle = '';
|
|
47
|
+
let offset = 0;
|
|
48
|
+
const rows = [];
|
|
49
|
+
for (const line of lines) {
|
|
50
|
+
const lineStart = offset;
|
|
51
|
+
const lineEnd = offset + line.length;
|
|
52
|
+
const heading = line.match(/^#{2,3}\s+(.+)$/);
|
|
53
|
+
if (heading) {
|
|
54
|
+
sectionTitle = heading[1].trim();
|
|
55
|
+
offset = lineEnd + 1;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const rowMatch = line.match(/^\|\s*([^|]+?)\s*\|\s*`?(https?:\/\/[^|`\s]+)`?\s*\|/);
|
|
59
|
+
if (rowMatch) {
|
|
60
|
+
const label = rowMatch[1].trim();
|
|
61
|
+
if (label && label !== '子问题' && label !== 'Query' && label !== 'Topic' && !/^-+$/.test(label)) {
|
|
62
|
+
rows.push({
|
|
63
|
+
label,
|
|
64
|
+
url: rowMatch[2],
|
|
65
|
+
sectionTitle,
|
|
66
|
+
lineStart,
|
|
67
|
+
lineEnd,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
offset = lineEnd + 1;
|
|
72
|
+
}
|
|
73
|
+
return rows;
|
|
74
|
+
}
|
|
75
|
+
function chunkUrlMapping(source, content, meta) {
|
|
76
|
+
const rows = parseUrlMappingRows(content);
|
|
77
|
+
if (rows.length === 0) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
const baseSlug = sourceSlug(source);
|
|
81
|
+
const chunks = [];
|
|
82
|
+
for (const row of rows) {
|
|
83
|
+
const sectionLine = row.sectionTitle ? `### ${row.sectionTitle}\n\n` : '';
|
|
84
|
+
const body = `${sectionLine}| Query | Documentation |\n|-------|---------------|\n| ${row.label} | \`${row.url}\` |`;
|
|
85
|
+
const headingSlug = slugify(row.label);
|
|
86
|
+
chunks.push({
|
|
87
|
+
id: `${baseSlug}#${headingSlug}`,
|
|
88
|
+
corpus: meta.corpus,
|
|
89
|
+
product: meta.product,
|
|
90
|
+
framework: meta.framework,
|
|
91
|
+
types: meta.types,
|
|
92
|
+
scenario: meta.scenario,
|
|
93
|
+
title: row.label,
|
|
94
|
+
source,
|
|
95
|
+
content: body,
|
|
96
|
+
symbols: extractSymbols(body),
|
|
97
|
+
error_codes: extractErrorCodes(body),
|
|
98
|
+
char_start: row.lineStart,
|
|
99
|
+
char_end: row.lineEnd,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return chunks;
|
|
103
|
+
}
|
|
104
|
+
export function chunkMarkdown(source, content, meta) {
|
|
105
|
+
const chunks = [];
|
|
106
|
+
const baseSlug = sourceSlug(source);
|
|
107
|
+
if (isChatUrlMapping(source)) {
|
|
108
|
+
const urlChunks = chunkUrlMapping(source, content, meta);
|
|
109
|
+
if (urlChunks.length > 0) {
|
|
110
|
+
return urlChunks;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (content.length < 2048) {
|
|
114
|
+
const { body, char_start, char_end } = trimSliceOffsets(content, 0);
|
|
115
|
+
if (!body)
|
|
116
|
+
return chunks;
|
|
117
|
+
chunks.push({
|
|
118
|
+
id: `${baseSlug}#full`,
|
|
119
|
+
corpus: meta.corpus,
|
|
120
|
+
product: meta.product,
|
|
121
|
+
framework: meta.framework,
|
|
122
|
+
types: meta.types,
|
|
123
|
+
scenario: meta.scenario,
|
|
124
|
+
title: pathBasename(source),
|
|
125
|
+
source,
|
|
126
|
+
content: body,
|
|
127
|
+
symbols: extractSymbols(body),
|
|
128
|
+
error_codes: extractErrorCodes(body),
|
|
129
|
+
char_start,
|
|
130
|
+
char_end,
|
|
131
|
+
});
|
|
132
|
+
return chunks;
|
|
133
|
+
}
|
|
134
|
+
const level = isFaqLike(source, content) ? 3 : 2;
|
|
135
|
+
const sections = splitByHeading(content, level);
|
|
136
|
+
for (const section of sections) {
|
|
137
|
+
const { body, char_start, char_end } = trimSliceOffsets(section.raw, section.start);
|
|
138
|
+
if (!body)
|
|
139
|
+
continue;
|
|
140
|
+
const headingSlug = slugify(section.title);
|
|
141
|
+
chunks.push({
|
|
142
|
+
id: `${baseSlug}#${headingSlug}`,
|
|
143
|
+
corpus: meta.corpus,
|
|
144
|
+
product: meta.product,
|
|
145
|
+
framework: meta.framework,
|
|
146
|
+
types: meta.types,
|
|
147
|
+
scenario: meta.scenario,
|
|
148
|
+
title: section.title,
|
|
149
|
+
source,
|
|
150
|
+
content: body,
|
|
151
|
+
symbols: extractSymbols(body),
|
|
152
|
+
error_codes: extractErrorCodes(body),
|
|
153
|
+
char_start,
|
|
154
|
+
char_end,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return chunks.length > 0 ? chunks : chunkMarkdown(source, content.slice(0, 2048), meta);
|
|
158
|
+
}
|
|
159
|
+
export function toManifestChunk(chunk) {
|
|
160
|
+
const { content: _content, ...manifestChunk } = chunk;
|
|
161
|
+
return manifestChunk;
|
|
162
|
+
}
|
|
163
|
+
function pathBasename(source) {
|
|
164
|
+
const parts = source.split('/');
|
|
165
|
+
const file = parts[parts.length - 1] ?? source;
|
|
166
|
+
return file.replace(/\.md$/, '');
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=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AAC;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
const fileCache = new Map();
|
|
6
|
+
function resolveResourceRoot() {
|
|
7
|
+
// npm: knowledge/ → ../resource/ 到包根;dev: dist/knowledge/ → ../resource/ 到 dist/resource/
|
|
8
|
+
return path.resolve(__dirname, '../resource');
|
|
9
|
+
}
|
|
10
|
+
function readSourceFile(source) {
|
|
11
|
+
const cached = fileCache.get(source);
|
|
12
|
+
if (cached !== undefined)
|
|
13
|
+
return cached;
|
|
14
|
+
const abs = path.join(resolveResourceRoot(), source);
|
|
15
|
+
const text = fs.readFileSync(abs, 'utf-8');
|
|
16
|
+
fileCache.set(source, text);
|
|
17
|
+
return text;
|
|
18
|
+
}
|
|
19
|
+
export function getSourceFileContent(source) {
|
|
20
|
+
return readSourceFile(source);
|
|
21
|
+
}
|
|
22
|
+
/** 按 build 时写入的 char 偏移从 md 源文件切片(方案 B:manifest 不存 content) */
|
|
23
|
+
export function getChunkContent(chunk) {
|
|
24
|
+
const full = readSourceFile(chunk.source);
|
|
25
|
+
return full.slice(chunk.char_start, chunk.char_end);
|
|
26
|
+
}
|
|
27
|
+
export function attachChunkContent(chunk) {
|
|
28
|
+
return { ...chunk, content: getChunkContent(chunk) };
|
|
29
|
+
}
|
|
30
|
+
/** 预读 pool 涉及的唯一 source,再批量挂载 content(供 BM25 与 fragments 使用) */
|
|
31
|
+
export function attachPoolContent(pool) {
|
|
32
|
+
for (const source of new Set(pool.map((chunk) => chunk.source))) {
|
|
33
|
+
readSourceFile(source);
|
|
34
|
+
}
|
|
35
|
+
return pool.map((chunk) => attachChunkContent(chunk));
|
|
36
|
+
}
|
|
37
|
+
export function clearContentCache() {
|
|
38
|
+
fileCache.clear();
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=content-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-loader.js","sourceRoot":"","sources":["../../src/knowledge/content-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE5C,SAAS,mBAAmB;IAC1B,0FAA0F;IAC1F,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,cAAc,CAAC,MAAc;IACpC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,MAAM,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3C,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,eAAe,CAAC,KAAgE;IAC9F,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,IAAI,CAA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