@tencent-rtc/trtc-agent-skills 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (366) hide show
  1. package/.cursor/rules/main.mdc +12 -0
  2. package/AGENTS.md +14 -97
  3. package/CLAUDE.md +15 -120
  4. package/CODEBUDDY.md +32 -118
  5. package/README.md +7 -5
  6. package/README.zh.md +7 -5
  7. package/bin/cli.js +133 -41
  8. package/hooks/__pycache__/cursor-adapter.cpython-313.pyc +0 -0
  9. package/hooks/cursor-adapter.py +45 -18
  10. package/hooks/hooks-cursor.json +5 -18
  11. package/hooks/hooks.json +6 -31
  12. package/knowledge-base/conference/web/index.yaml +143 -0
  13. package/knowledge-base/platform-slice-template.md +1041 -133
  14. package/knowledge-base/products.yaml +76 -0
  15. package/knowledge-base/scenario-spec.md +1316 -115
  16. package/knowledge-base/scenarios/conference/base/general-conference.md +26 -3
  17. package/knowledge-base/scenarios/conference/base/webinar-conference.md +14 -0
  18. package/knowledge-base/scenarios/conference/medical/1v1-video-consultation.md +19 -0
  19. package/knowledge-base/scenarios/conference/medical/medical-multidoctor-consultation.md +13 -0
  20. package/knowledge-base/scenarios/live/entertainment-live-room.md +12 -0
  21. package/knowledge-base/slice-spec.md +2377 -299
  22. package/knowledge-base/slices/conference/web/integration-audit.md +155 -0
  23. package/knowledge-base/slices/conference/web/login-auth.md +16 -2
  24. package/knowledge-base/slices/conference/web/official-roomkit-login-ui.md +41 -13
  25. package/knowledge-base/slices/conference/web/prejoin-check.md +8 -5
  26. package/knowledge-base/tooling/aliases.yaml +92 -0
  27. package/knowledge-base/tooling/intent-signals.yaml +181 -0
  28. package/knowledge-base/tooling/symptom-keywords.yaml +21 -0
  29. package/package.json +1 -1
  30. package/skills/trtc/SKILL.md +202 -244
  31. package/skills/trtc/hooks/__pycache__/report_prompt.cpython-313.pyc +0 -0
  32. package/skills/{trtc-topic/guardrails → trtc/hooks}/gate_slice_read.py +12 -8
  33. package/skills/{trtc-topic/guardrails → trtc/hooks}/gate_slice_write.py +16 -12
  34. package/skills/{trtc-topic/guardrails → trtc/hooks}/stop_require_apply_evidence.py +22 -14
  35. package/skills/trtc/hooks/topic_phase_gate.py +161 -0
  36. package/skills/trtc/room-builder/assets/local-usersig/basic-info-config.ts +39 -0
  37. package/skills/trtc/room-builder/assets/local-usersig/lib-generate-test-usersig-es.min.d.ts +4 -0
  38. package/skills/trtc/room-builder/assets/local-usersig/lib-generate-test-usersig-es.min.js +2 -0
  39. package/skills/{trtc-topic → trtc}/runtime/README.md +2 -2
  40. package/skills/{trtc-onboarding/reference/reporting-protocol.md → trtc/runtime/REPORTING.md} +5 -3
  41. package/skills/{trtc-topic → trtc}/runtime/RUNTIME.md +5 -5
  42. package/skills/trtc/runtime/lib/__init__.py +0 -0
  43. package/skills/{trtc-topic → trtc}/runtime/package-lock.json +2 -2
  44. package/skills/{trtc-topic → trtc}/runtime/package.json +2 -2
  45. package/skills/{trtc-topic → trtc}/runtime/telemetry-bridge.mjs +1 -1
  46. package/skills/trtc/runtime/usersig-handling.md +134 -0
  47. package/skills/{trtc-topic/scripts → trtc/tools}/STATE-MACHINE-GUIDE.md +23 -23
  48. package/skills/trtc/tools/__init__.py +2 -0
  49. package/skills/trtc/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  50. package/skills/trtc/tools/__pycache__/query_classifier.cpython-313.pyc +0 -0
  51. package/skills/trtc/tools/__pycache__/reporting.cpython-313.pyc +0 -0
  52. package/skills/trtc/tools/__pycache__/search.cpython-313.pyc +0 -0
  53. package/skills/trtc/tools/__pycache__/session.cpython-313.pyc +0 -0
  54. package/skills/trtc/tools/apply.py +540 -0
  55. package/skills/trtc/tools/docs.py +712 -0
  56. package/skills/trtc/tools/docsbot.py +182 -0
  57. package/skills/trtc/tools/entry/render_ai_instructions.py +92 -0
  58. package/skills/trtc/tools/flow.py +1089 -0
  59. package/skills/{trtc-topic/scripts → trtc/tools}/init_slice_queue.py +5 -4
  60. package/skills/{trtc-topic/scripts → trtc/tools}/next_slice.py +5 -4
  61. package/skills/trtc/tools/query_classifier.py +301 -0
  62. package/skills/trtc/tools/reporting.py +447 -0
  63. package/skills/trtc/tools/search.py +817 -0
  64. package/skills/trtc/tools/session.py +1261 -0
  65. package/skills/trtc/tools/state_machine.py +690 -0
  66. package/skills/trtc-ai-service/README.md +195 -0
  67. package/skills/trtc-ai-service/README.zh-CN.md +193 -0
  68. package/skills/trtc-ai-service/SKILL.md +945 -0
  69. package/skills/trtc-ai-service/auto_adapters/README.md +40 -0
  70. package/skills/trtc-ai-service/auto_adapters/frontend-spa/README.md +27 -0
  71. package/skills/trtc-ai-service/auto_adapters/frontend-spa/angular/voice-agent.component.ts.tpl +131 -0
  72. package/skills/trtc-ai-service/auto_adapters/frontend-spa/manifest.yaml +57 -0
  73. package/skills/trtc-ai-service/auto_adapters/frontend-spa/react/VoiceAgent.tsx.tpl +142 -0
  74. package/skills/trtc-ai-service/auto_adapters/frontend-spa/vue/VoiceAgent.vue.tpl +121 -0
  75. package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-backend.md +45 -0
  76. package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-frontend.md +51 -0
  77. package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-rest-api.md +93 -0
  78. package/skills/trtc-ai-service/auto_adapters/java-backend/README.md +25 -0
  79. package/skills/trtc-ai-service/auto_adapters/java-backend/manifest.yaml +30 -0
  80. package/skills/trtc-ai-service/auto_adapters/java-backend/quarkus/VoiceAgentFilter.java.tpl +64 -0
  81. package/skills/trtc-ai-service/auto_adapters/java-backend/springboot/VoiceAgentFilter.java.tpl +91 -0
  82. package/skills/trtc-ai-service/auto_adapters/manifest.yaml +43 -0
  83. package/skills/trtc-ai-service/auto_adapters/node-backend/README.md +25 -0
  84. package/skills/trtc-ai-service/auto_adapters/node-backend/express.js.tpl +40 -0
  85. package/skills/trtc-ai-service/auto_adapters/node-backend/fastify.js.tpl +27 -0
  86. package/skills/trtc-ai-service/auto_adapters/node-backend/koa.js.tpl +31 -0
  87. package/skills/trtc-ai-service/auto_adapters/node-backend/manifest.yaml +47 -0
  88. package/skills/trtc-ai-service/auto_adapters/python-backend/README.md +22 -0
  89. package/skills/trtc-ai-service/auto_adapters/python-backend/django.py.tpl +32 -0
  90. package/skills/trtc-ai-service/auto_adapters/python-backend/fastapi.py.tpl +35 -0
  91. package/skills/trtc-ai-service/auto_adapters/python-backend/flask.py.tpl +31 -0
  92. package/skills/trtc-ai-service/auto_adapters/python-backend/manifest.yaml +45 -0
  93. package/skills/trtc-ai-service/capabilities/__init__.py +43 -0
  94. package/skills/trtc-ai-service/capabilities/conversation-core/.env.example +29 -0
  95. package/skills/trtc-ai-service/capabilities/conversation-core/INTEGRATION.md +134 -0
  96. package/skills/trtc-ai-service/capabilities/conversation-core/INTERFACE_ADAPT.md +111 -0
  97. package/skills/trtc-ai-service/capabilities/conversation-core/QUICK_START.md +62 -0
  98. package/skills/trtc-ai-service/capabilities/conversation-core/manifest.yaml +250 -0
  99. package/skills/trtc-ai-service/capabilities/conversation-core/requirements.txt +6 -0
  100. package/skills/trtc-ai-service/capabilities/conversation-core/src/__init__.py +10 -0
  101. package/skills/trtc-ai-service/capabilities/conversation-core/src/_capability_loader.py +218 -0
  102. package/skills/trtc-ai-service/capabilities/conversation-core/src/agent.py +231 -0
  103. package/skills/trtc-ai-service/capabilities/conversation-core/src/credentials.py +132 -0
  104. package/skills/trtc-ai-service/capabilities/conversation-core/src/health.py +355 -0
  105. package/skills/trtc-ai-service/capabilities/conversation-core/src/log_filter.py +76 -0
  106. package/skills/trtc-ai-service/capabilities/conversation-core/src/modality.py +109 -0
  107. package/skills/trtc-ai-service/capabilities/conversation-core/src/server.py +312 -0
  108. package/skills/trtc-ai-service/capabilities/conversation-core/src/trtc_client.py +315 -0
  109. package/skills/trtc-ai-service/capabilities/conversation-core/src/usersig.py +90 -0
  110. package/skills/trtc-ai-service/capabilities/conversation-core/tests/test_skeleton.py +216 -0
  111. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/README.md +48 -0
  112. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/app.js +415 -0
  113. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/index.html +68 -0
  114. package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/styles.css +136 -0
  115. package/skills/trtc-ai-service/capabilities/digital-human/README.md +31 -0
  116. package/skills/trtc-ai-service/capabilities/digital-human/manifest.yaml +64 -0
  117. package/skills/trtc-ai-service/capabilities/digital-human/src/__init__.py +2 -0
  118. package/skills/trtc-ai-service/capabilities/digital-human/src/router.py +43 -0
  119. package/skills/trtc-ai-service/capabilities/human-handoff/INTERFACE_ADAPT.md +353 -0
  120. package/skills/trtc-ai-service/capabilities/human-handoff/README.md +44 -0
  121. package/skills/trtc-ai-service/capabilities/human-handoff/manifest.yaml +227 -0
  122. package/skills/trtc-ai-service/capabilities/human-handoff/src/__init__.py +2 -0
  123. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/__init__.py +9 -0
  124. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/default_rest.py +242 -0
  125. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/factory.py +89 -0
  126. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/local_queue.py +258 -0
  127. package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/mock.py +132 -0
  128. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/__init__.py +25 -0
  129. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/intent_detector.py +75 -0
  130. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/models.py +163 -0
  131. package/skills/trtc-ai-service/capabilities/human-handoff/src/core/service.py +192 -0
  132. package/skills/trtc-ai-service/capabilities/human-handoff/src/feedback_store.py +54 -0
  133. package/skills/trtc-ai-service/capabilities/human-handoff/src/ports/__init__.py +4 -0
  134. package/skills/trtc-ai-service/capabilities/human-handoff/src/ports/handoff_client.py +86 -0
  135. package/skills/trtc-ai-service/capabilities/human-handoff/src/queue.py +62 -0
  136. package/skills/trtc-ai-service/capabilities/human-handoff/src/router.py +201 -0
  137. package/skills/trtc-ai-service/capabilities/human-handoff/src/summary_link.py +77 -0
  138. package/skills/trtc-ai-service/capabilities/human-handoff/src/trigger.py +25 -0
  139. package/skills/trtc-ai-service/capabilities/knowledge-base/INTERFACE_ADAPT.md +297 -0
  140. package/skills/trtc-ai-service/capabilities/knowledge-base/README.md +51 -0
  141. package/skills/trtc-ai-service/capabilities/knowledge-base/data/faq.json +20 -0
  142. package/skills/trtc-ai-service/capabilities/knowledge-base/manifest.yaml +211 -0
  143. package/skills/trtc-ai-service/capabilities/knowledge-base/src/__init__.py +8 -0
  144. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/__init__.py +9 -0
  145. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/default_rest.py +209 -0
  146. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/factory.py +86 -0
  147. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/local_json.py +172 -0
  148. package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/mock.py +91 -0
  149. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/__init__.py +12 -0
  150. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/models.py +77 -0
  151. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/scoring.py +73 -0
  152. package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/service.py +78 -0
  153. package/skills/trtc-ai-service/capabilities/knowledge-base/src/ports/__init__.py +4 -0
  154. package/skills/trtc-ai-service/capabilities/knowledge-base/src/ports/kb_client.py +61 -0
  155. package/skills/trtc-ai-service/capabilities/knowledge-base/src/retriever.py +56 -0
  156. package/skills/trtc-ai-service/capabilities/knowledge-base/src/router.py +85 -0
  157. package/skills/trtc-ai-service/capabilities/session-summary/INTERFACE_ADAPT.md +99 -0
  158. package/skills/trtc-ai-service/capabilities/session-summary/README.md +47 -0
  159. package/skills/trtc-ai-service/capabilities/session-summary/data/test_session.json +18 -0
  160. package/skills/trtc-ai-service/capabilities/session-summary/manifest.yaml +165 -0
  161. package/skills/trtc-ai-service/capabilities/session-summary/src/__init__.py +2 -0
  162. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/__init__.py +5 -0
  163. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/base.py +31 -0
  164. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/default_rest.py +67 -0
  165. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/factory.py +51 -0
  166. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/local_json.py +42 -0
  167. package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/mock.py +22 -0
  168. package/skills/trtc-ai-service/capabilities/session-summary/src/recorder.py +210 -0
  169. package/skills/trtc-ai-service/capabilities/session-summary/src/router.py +93 -0
  170. package/skills/trtc-ai-service/capabilities/session-summary/src/summarizer.py +163 -0
  171. package/skills/trtc-ai-service/capabilities/tool-calling/INTERFACE_ADAPT.md +158 -0
  172. package/skills/trtc-ai-service/capabilities/tool-calling/README.md +50 -0
  173. package/skills/trtc-ai-service/capabilities/tool-calling/data/tools.yaml +58 -0
  174. package/skills/trtc-ai-service/capabilities/tool-calling/examples/__init__.py +1 -0
  175. package/skills/trtc-ai-service/capabilities/tool-calling/examples/local_tools.py +101 -0
  176. package/skills/trtc-ai-service/capabilities/tool-calling/manifest.yaml +146 -0
  177. package/skills/trtc-ai-service/capabilities/tool-calling/src/__init__.py +8 -0
  178. package/skills/trtc-ai-service/capabilities/tool-calling/src/dispatcher.py +54 -0
  179. package/skills/trtc-ai-service/capabilities/tool-calling/src/registry.py +219 -0
  180. package/skills/trtc-ai-service/capabilities/tool-calling/src/router.py +50 -0
  181. package/skills/trtc-ai-service/references/business-contract-spec.md +263 -0
  182. package/skills/trtc-ai-service/scenarios/custom-builder/README.md +86 -0
  183. package/skills/trtc-ai-service/scenarios/custom-builder/output-templates/recipe.yaml.j2 +194 -0
  184. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q1-business-scenario.md +43 -0
  185. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q2-io-modality.md +57 -0
  186. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q3-ui-form.md +55 -0
  187. package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q4-capabilities.md +78 -0
  188. package/skills/trtc-ai-service/scenarios/customer-service/README.md +114 -0
  189. package/skills/trtc-ai-service/scenarios/customer-service/recipe.yaml +154 -0
  190. package/skills/trtc-ai-service/scenarios/customer-service/sample-data/README.md +32 -0
  191. package/skills/trtc-ai-service/scenarios/customer-service/sample-data/faq-sample.json +37 -0
  192. package/skills/trtc-ai-service/scenarios/customer-service/system-prompt.template.md +94 -0
  193. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/app.js +347 -0
  194. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/index.html +125 -0
  195. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/styles.css +487 -0
  196. package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/tokens.css +71 -0
  197. package/skills/trtc-ai-service/scenarios/customer-service/ui/design-system/DESIGN_GUIDELINES.md +370 -0
  198. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/README.md +68 -0
  199. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/app.js +1307 -0
  200. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/data.js +40 -0
  201. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/index.html +233 -0
  202. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/mock-shop.json +21 -0
  203. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/styles.css +603 -0
  204. package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/tokens.css +71 -0
  205. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/agent-link.js +323 -0
  206. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/app.js +458 -0
  207. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/index.html +109 -0
  208. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/styles.css +489 -0
  209. package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/tokens.css +59 -0
  210. package/skills/trtc-ai-service/scripts/add-capability.py +364 -0
  211. package/skills/trtc-ai-service/scripts/contract-adapt.py +334 -0
  212. package/skills/trtc-ai-service/scripts/detect-stack.py +40 -0
  213. package/skills/trtc-ai-service/scripts/lib/__init__.py +20 -0
  214. package/skills/trtc-ai-service/scripts/lib/adapter_codegen.py +509 -0
  215. package/skills/trtc-ai-service/scripts/lib/arbitrator.py +152 -0
  216. package/skills/trtc-ai-service/scripts/lib/contract_resolver.py +519 -0
  217. package/skills/trtc-ai-service/scripts/lib/credential_validators.py +253 -0
  218. package/skills/trtc-ai-service/scripts/lib/curl_parser.py +303 -0
  219. package/skills/trtc-ai-service/scripts/lib/degrader.py +140 -0
  220. package/skills/trtc-ai-service/scripts/lib/injector.py +347 -0
  221. package/skills/trtc-ai-service/scripts/lib/manifest_resolver.py +288 -0
  222. package/skills/trtc-ai-service/scripts/lib/openapi_parser.py +289 -0
  223. package/skills/trtc-ai-service/scripts/lib/stack_detector.py +159 -0
  224. package/skills/trtc-ai-service/scripts/lib/tokens_compile.py +204 -0
  225. package/skills/trtc-ai-service/scripts/post-install-patch.py +225 -0
  226. package/skills/trtc-ai-service/scripts/setup-credentials.py +393 -0
  227. package/skills/trtc-ai-service/scripts/verify-credentials.py +108 -0
  228. package/skills/trtc-ai-service/start.sh +111 -0
  229. package/skills/trtc-ai-service/tests/__init__.py +1 -0
  230. package/skills/trtc-ai-service/tests/test_arbitrator.py +64 -0
  231. package/skills/trtc-ai-service/tests/test_capability_overlay.py +85 -0
  232. package/skills/trtc-ai-service/tests/test_contract_resolver.py +190 -0
  233. package/skills/trtc-ai-service/tests/test_handoff_ports.py +195 -0
  234. package/skills/trtc-ai-service/tests/test_kb_ports.py +195 -0
  235. package/skills/trtc-ai-service/tests/test_manifest_resolver.py +95 -0
  236. package/skills/trtc-ai-service/tests/test_recipe_assembly.py +175 -0
  237. package/skills/trtc-ai-service/tests/test_stack_and_degrader.py +101 -0
  238. package/skills/trtc-ai-service/tests/test_verify_credentials.py +285 -0
  239. package/skills/trtc-ai-service/triggers.yaml +29 -0
  240. package/skills/trtc-conference/SKILL.md +324 -0
  241. package/skills/trtc-conference/flows/onboarding.md +205 -0
  242. package/skills/trtc-conference/flows/topic.md +474 -0
  243. package/skills/trtc-conference/flows/troubleshoot.md +85 -0
  244. package/skills/trtc-conference/hooks/pretooluse_require_business_decisions.py +213 -0
  245. package/skills/trtc-conference/playbooks/medical-quickstart.md +84 -0
  246. package/skills/trtc-conference/playbooks/official-roomkit.md +97 -0
  247. package/skills/trtc-conference/references/local-usersig/basic-info-config.ts +39 -0
  248. package/skills/trtc-conference/references/usersig-handling.md +134 -0
  249. package/skills/trtc-conference/templates/medical-consultation/src/config/lib-generate-test-usersig-es.min.d.ts +4 -0
  250. package/skills/trtc-conference/templates/medical-consultation/src/config/lib-generate-test-usersig-es.min.js +2 -0
  251. package/skills/trtc-conference/tests/__pycache__/test_conference_onboarding_contract.cpython-313-pytest-9.0.2.pyc +0 -0
  252. package/skills/trtc-conference/tests/__pycache__/test_conference_topic_flow_contract.cpython-313-pytest-9.0.2.pyc +0 -0
  253. package/skills/trtc-conference/tests/test_conference_index_contract.py +43 -0
  254. package/skills/trtc-conference/tests/test_conference_onboarding_contract.py +103 -0
  255. package/skills/trtc-conference/tests/test_conference_template_contract.py +25 -0
  256. package/skills/trtc-conference/tests/test_conference_topic_flow_contract.py +132 -0
  257. package/skills/trtc-conference/tools/apply_checks.py +328 -0
  258. package/skills/trtc-conference/verify_lib/__init__.py +0 -0
  259. package/skills/{trtc-apply/guardrails/apply_lib → trtc-conference/verify_lib}/rule_parser.py +1 -1
  260. package/skills/trtc-docs/SKILL.md +91 -119
  261. package/.cursor/rules/ui-mode.mdc +0 -92
  262. package/ai-instructions/base.md +0 -13
  263. package/ai-instructions/ui-mode.md +0 -86
  264. package/knowledge-base/index.yaml +0 -454
  265. package/skills/trtc/room-builder/SKILL.md +0 -138
  266. package/skills/trtc/room-builder/templates/scenarios/medical-consultation/README.md +0 -108
  267. package/skills/trtc/room-builder/tools/render_ai_instructions.py +0 -226
  268. package/skills/trtc-apply/SKILL.md +0 -97
  269. package/skills/trtc-onboarding/SKILL.md +0 -839
  270. package/skills/trtc-onboarding/reference/path-a1-demo.md +0 -103
  271. package/skills/trtc-onboarding/reference/path-a2-integrate.md +0 -693
  272. package/skills/trtc-onboarding/reference/path-b-troubleshoot.md +0 -115
  273. package/skills/trtc-onboarding/reference/path-c-expand.md +0 -43
  274. package/skills/trtc-onboarding/reference/supported-matrix.md +0 -100
  275. package/skills/trtc-onboarding/reference/usersig-handling.md +0 -140
  276. package/skills/trtc-search/SKILL.md +0 -221
  277. package/skills/trtc-topic/SKILL.md +0 -638
  278. package/skills/trtc-topic/scripts/apply.py +0 -581
  279. package/skills/trtc-topic/scripts/lib/state_machine.py +0 -328
  280. package/skills/trtc-topic/tests/README.md +0 -70
  281. package/skills/trtc-topic/tests/conftest.py +0 -72
  282. package/skills/trtc-topic/tests/test_apply_cli.py +0 -480
  283. package/skills/trtc-topic/tests/test_end_to_end.py +0 -305
  284. package/skills/trtc-topic/tests/test_finalize_session.py +0 -51
  285. package/skills/trtc-topic/tests/test_gates.py +0 -316
  286. package/skills/trtc-topic/tests/test_session_resolver.py +0 -260
  287. package/skills/trtc-topic/tests/test_state_machine.py +0 -414
  288. package/skills/trtc-topic/tests/test_stop_require_apply.py +0 -99
  289. package/skills/trtc-topic/tests/test_topic_skill_invariants.py +0 -130
  290. /package/skills/{trtc-topic → trtc}/runtime/lib/platforms.py +0 -0
  291. /package/skills/{trtc-topic → trtc}/runtime/telemetry_collector.py +0 -0
  292. /package/skills/{trtc-topic/scripts → trtc/tools}/finalize_session.py +0 -0
  293. /package/skills/{trtc-apply/guardrails/apply_lib → trtc-ai-service/capabilities/conversation-core/tests}/__init__.py +0 -0
  294. /package/skills/{trtc-topic → trtc-conference}/references/execution-units.yaml +0 -0
  295. /package/skills/{trtc/room-builder/templates/scenarios/medical-consultation/src/config → trtc-conference/references/local-usersig}/lib-generate-test-usersig-es.min.d.ts +0 -0
  296. /package/skills/{trtc/room-builder/templates/scenarios/medical-consultation/src/config → trtc-conference/references/local-usersig}/lib-generate-test-usersig-es.min.js +0 -0
  297. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/backend-contract.zh-CN.md +0 -0
  298. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/integration.zh-CN.md +0 -0
  299. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/theme.zh-CN.md +0 -0
  300. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/index.html +0 -0
  301. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/package.json +0 -0
  302. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/postcss.config.js +0 -0
  303. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/App.vue +0 -0
  304. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/ConsultationManagePanel.vue +0 -0
  305. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/LanguageSwitch.vue +0 -0
  306. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/LoadingSpinner.vue +0 -0
  307. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalAlert.vue +0 -0
  308. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalBusinessPanel.vue +0 -0
  309. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalButton.vue +0 -0
  310. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalConfirmDialog.vue +0 -0
  311. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalDataPanel.vue +0 -0
  312. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalRecordPanel.vue +0 -0
  313. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/PrescriptionPanel.vue +0 -0
  314. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/config/basic-info-config.ts +0 -0
  315. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/config/runtime-config.ts +0 -0
  316. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/env.d.ts +0 -0
  317. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationChatPanel.vue +0 -0
  318. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationMembersPanel.vue +0 -0
  319. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationTranscriptionPanel.vue +0 -0
  320. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationVideoStage.vue +0 -0
  321. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/InviteDoctorDialog.vue +0 -0
  322. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/KickMemberConfirmDialog.vue +0 -0
  323. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/types.ts +0 -0
  324. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationChat.ts +0 -0
  325. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationDevices.ts +0 -0
  326. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationParticipants.ts +0 -0
  327. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationPermissions.ts +0 -0
  328. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/utils.ts +0 -0
  329. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/en-US/index.ts +0 -0
  330. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/index.ts +0 -0
  331. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/medicalTranslate.ts +0 -0
  332. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/state.ts +0 -0
  333. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/zh-CN/index.ts +0 -0
  334. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/main.ts +0 -0
  335. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/mock/appointments.ts +0 -0
  336. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/mock/users.ts +0 -0
  337. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/router/index.ts +0 -0
  338. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/index.ts +0 -0
  339. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/appointmentService.ts +0 -0
  340. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/authService.ts +0 -0
  341. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/launchContext.ts +0 -0
  342. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/userService.ts +0 -0
  343. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/appointmentService.ts +0 -0
  344. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/authService.ts +0 -0
  345. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/userService.ts +0 -0
  346. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/types.ts +0 -0
  347. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/shared/icons.ts +0 -0
  348. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/index.css +0 -0
  349. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/tailwind.css +0 -0
  350. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/theme.css +0 -0
  351. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/auth.ts +0 -0
  352. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/format.ts +0 -0
  353. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/navigation.ts +0 -0
  354. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/session.ts +0 -0
  355. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/DoctorConsultationView.vue +0 -0
  356. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/DoctorDashboardView.vue +0 -0
  357. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/LoginView.vue +0 -0
  358. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientConsultationFinishedView.vue +0 -0
  359. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientConsultationView.vue +0 -0
  360. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientSelectDoctorView.vue +0 -0
  361. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientWaitingView.vue +0 -0
  362. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/tsconfig.json +0 -0
  363. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/tsconfig.node.json +0 -0
  364. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/vite.config.ts +0 -0
  365. /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation//346/216/245/345/205/245/350/257/264/346/230/216.md" +0 -0
  366. /package/skills/{trtc-topic/runtime/lib → trtc-conference/tools}/__init__.py +0 -0
@@ -0,0 +1,101 @@
1
+ """Tech stack detection + three-tier fallback tests."""
2
+ import json
3
+ import os
4
+ import sys
5
+ import tempfile
6
+ import unittest
7
+ from pathlib import Path
8
+
9
+ _ROOT = Path(__file__).resolve().parent.parent
10
+ sys.path.insert(0, str(_ROOT))
11
+
12
+ from scripts.lib import stack_detector as sd
13
+ from scripts.lib import degrader as dg
14
+
15
+
16
+ def _mkproj(files: dict) -> Path:
17
+ tmp = Path(tempfile.mkdtemp(prefix="stack_"))
18
+ for name, content in files.items():
19
+ p = tmp / name
20
+ p.parent.mkdir(parents=True, exist_ok=True)
21
+ p.write_text(content, encoding="utf-8")
22
+ return tmp
23
+
24
+
25
+ class StackDetectorTests(unittest.TestCase):
26
+
27
+ def test_react_project(self):
28
+ proj = _mkproj({
29
+ "package.json": json.dumps({"dependencies": {"react": "^18.2.0", "react-dom": "^18.2.0"}}),
30
+ })
31
+ res = sd.detect(proj)
32
+ self.assertEqual(res.primary, "react")
33
+ self.assertIn("react", res.candidates)
34
+
35
+ def test_next_priority_over_react(self):
36
+ proj = _mkproj({
37
+ "package.json": json.dumps({"dependencies": {"next": "^14", "react": "^18"}}),
38
+ })
39
+ res = sd.detect(proj)
40
+ self.assertEqual(res.primary, "next")
41
+
42
+ def test_express_node_backend(self):
43
+ proj = _mkproj({"package.json": json.dumps({"dependencies": {"express": "^4"}})})
44
+ self.assertEqual(sd.detect(proj).primary, "express")
45
+
46
+ def test_spring_boot_pom(self):
47
+ proj = _mkproj({"pom.xml": "<artifactId>spring-boot-starter-web</artifactId>"})
48
+ self.assertEqual(sd.detect(proj).primary, "spring-boot")
49
+
50
+ def test_python_fastapi_priority_over_flask(self):
51
+ proj = _mkproj({"requirements.txt": "fastapi==0.110\nflask==3.0\n"})
52
+ self.assertEqual(sd.detect(proj).primary, "fastapi")
53
+
54
+ def test_unknown_returns_none(self):
55
+ proj = _mkproj({"random.txt": "hello"})
56
+ self.assertIsNone(sd.detect(proj).primary)
57
+
58
+ def test_match_adapter(self):
59
+ adapters = [
60
+ {"tech_stack": ["react", "vue"], "adapter": "frontend-spa"},
61
+ {"tech_stack": ["express"], "adapter": "node-backend"},
62
+ ]
63
+ self.assertEqual(sd.match_adapter("react", adapters), "frontend-spa")
64
+ self.assertEqual(sd.match_adapter("express", adapters), "node-backend")
65
+ self.assertIsNone(sd.match_adapter("unknown", adapters))
66
+
67
+
68
+ class DegraderTests(unittest.TestCase):
69
+
70
+ def test_l1_when_match_and_codegen_ok(self):
71
+ d = dg.decide("react", "frontend-spa", True)
72
+ self.assertEqual(d.level, dg.DegradeLevel.L1_AUTO)
73
+
74
+ def test_l2_when_match_but_codegen_failed(self):
75
+ fb = {"guided_templates": ["x.md"]}
76
+ d = dg.decide("react", "frontend-spa", False, fallback=fb, code_gen_error="conflict")
77
+ self.assertEqual(d.level, dg.DegradeLevel.L2_GUIDED)
78
+ self.assertIn("x.md", d.artifacts)
79
+ self.assertIn("conflict", d.reason)
80
+
81
+ def test_l3_when_no_tech_stack(self):
82
+ fb = {"manual_api": {"rest_endpoint": "/api/v1", "sdk_packages": [{"npm": "x"}]}}
83
+ d = dg.decide(None, None, False, fallback=fb)
84
+ self.assertEqual(d.level, dg.DegradeLevel.L3_MANUAL)
85
+ self.assertTrue(any("rest_endpoint:/api/v1" in a for a in d.artifacts))
86
+ self.assertTrue(any("sdk:npm:x" in a for a in d.artifacts))
87
+
88
+ def test_l3_when_stack_known_but_no_adapter(self):
89
+ d = dg.decide("svelte", None, False, fallback={"manual_api": {}})
90
+ self.assertEqual(d.level, dg.DegradeLevel.L3_MANUAL)
91
+ self.assertIn("no adapter for tech_stack=svelte", d.reason)
92
+
93
+ def test_channel_matrix_has_16_rows(self):
94
+ rows = dg.channel_combinations_matrix()
95
+ self.assertEqual(len(rows), 16)
96
+ verdicts = {r["verdict"] for r in rows}
97
+ self.assertIn("silent_wait", verdicts)
98
+
99
+
100
+ if __name__ == "__main__":
101
+ unittest.main()
@@ -0,0 +1,285 @@
1
+ """Phase 3 Stage 6: scripts/verify-credentials.py + scripts/lib/credential_validators tests.
2
+
3
+ Coverage targets:
4
+ - Unit: ValidationResult / BatchResult / load_dotenv / hint error code mapping
5
+ - Integration (subprocess): run verify-credentials.py in a **clean environment**
6
+ → All three keys unconfigured → must output valid JSON with error == "E000" and non-zero exit code
7
+ - Unit (mock all three services): via patch of ``health.check_*`` verify
8
+ validate_tencent / validate_trtc / validate_llm / validate_all chain
9
+ returned ValidationResult fields match ``{ok, type, error, message, latency_ms}``
10
+
11
+ Red lines (aligned with SKILL.md §12 Tool Whitelist):
12
+ - Verification script **does not** accept keys as CLI arguments → tests only use .env and patch
13
+ - Output JSON must not contain credential plaintext (latency_ms / error code only)
14
+ """
15
+ from __future__ import annotations
16
+
17
+ import json
18
+ import os
19
+ import subprocess
20
+ import sys
21
+ import tempfile
22
+ import unittest
23
+ from pathlib import Path
24
+ from unittest.mock import patch
25
+
26
+
27
+ _ROOT = Path(__file__).resolve().parent.parent
28
+ sys.path.insert(0, str(_ROOT))
29
+
30
+
31
+ def _run_cli(env_extra=None, args=None):
32
+ """Fork a verify-credentials.py subprocess in an isolated environment.
33
+
34
+ Explicitly empties all three Key env variables to prevent .env file fallback overrides
35
+ (load_dotenv uses setdefault; empty strings in env prevent real values from .env injection).
36
+ """
37
+ env = {
38
+ "PATH": os.environ.get("PATH", ""),
39
+ "HOME": os.environ.get("HOME", ""),
40
+ "PYTHONPATH": str(_ROOT),
41
+ # Force clear all candidate env variables to ensure ``configured`` is False
42
+ "TENCENT_CLOUD_SECRET_ID": "",
43
+ "TENCENT_CLOUD_SECRET_KEY": "",
44
+ "TRTC_SDK_APP_ID": "",
45
+ "TRTC_SDK_SECRET_KEY": "",
46
+ "LLM_API_KEY": "",
47
+ "LLM_API_URL": "",
48
+ "LLM_MODEL": "",
49
+ }
50
+ if env_extra:
51
+ env.update(env_extra)
52
+ cmd = [sys.executable, str(_ROOT / "scripts" / "verify-credentials.py")]
53
+ if args:
54
+ cmd.extend(args)
55
+ proc = subprocess.run(
56
+ cmd,
57
+ cwd=str(_ROOT),
58
+ capture_output=True,
59
+ text=True,
60
+ timeout=20,
61
+ env=env,
62
+ )
63
+ return proc
64
+
65
+
66
+ class CredentialValidatorsUnitTests(unittest.TestCase):
67
+ """Pure unit tests for the credential_validators module (no network calls)."""
68
+
69
+ def test_validation_result_to_dict_keys(self):
70
+ from scripts.lib.credential_validators import ValidationResult
71
+ r = ValidationResult(ok=True, type="tencent", message="ok", latency_ms=42)
72
+ d = r.to_dict()
73
+ self.assertSetEqual(
74
+ set(d.keys()), {"ok", "type", "error", "message", "latency_ms"}
75
+ )
76
+ self.assertTrue(d["ok"])
77
+ self.assertEqual(d["type"], "tencent")
78
+
79
+ def test_batch_result_aggregates(self):
80
+ from scripts.lib.credential_validators import BatchResult, ValidationResult
81
+ b = BatchResult(
82
+ ok=False,
83
+ items=[
84
+ ValidationResult(ok=True, type="tencent"),
85
+ ValidationResult(ok=False, type="trtc", error="E002", message="fail"),
86
+ ValidationResult(ok=True, type="llm"),
87
+ ],
88
+ )
89
+ d = b.to_dict()
90
+ self.assertEqual(d["type"], "all")
91
+ self.assertFalse(d["ok"])
92
+ self.assertEqual(len(d["items"]), 3)
93
+ self.assertEqual(d["items"][1]["error"], "E002")
94
+
95
+ def test_hint_returns_known_codes(self):
96
+ from scripts.lib.credential_validators import hint
97
+ self.assertIn("腾讯云", hint("E001"))
98
+ self.assertIn("TRTC", hint("E002"))
99
+ self.assertIn("LLM", hint("E003"))
100
+ # Unknown error code → empty string
101
+ self.assertEqual(hint("E999"), "")
102
+
103
+ def test_load_dotenv_reads_kv(self):
104
+ from scripts.lib.credential_validators import load_dotenv
105
+ with tempfile.TemporaryDirectory() as td:
106
+ envf = Path(td) / ".env"
107
+ envf.write_text(
108
+ "FAKE_KEY_FOR_TEST=hello\n# comment\nFAKE_QUOTED=\"world\"\n",
109
+ encoding="utf-8",
110
+ )
111
+ try:
112
+ # Clear same-name process-level vars to ensure reading from file
113
+ os.environ.pop("FAKE_KEY_FOR_TEST", None)
114
+ os.environ.pop("FAKE_QUOTED", None)
115
+ seen = load_dotenv(envf)
116
+ self.assertEqual(seen.get("FAKE_KEY_FOR_TEST"), "hello")
117
+ self.assertEqual(seen.get("FAKE_QUOTED"), "world")
118
+ self.assertEqual(os.environ.get("FAKE_KEY_FOR_TEST"), "hello")
119
+ finally:
120
+ os.environ.pop("FAKE_KEY_FOR_TEST", None)
121
+ os.environ.pop("FAKE_QUOTED", None)
122
+
123
+
124
+ class VerifyCredentialsCliEmptyEnvTests(unittest.TestCase):
125
+ """Subprocess: verify-credentials.py behavior in a clean environment (no .env, no keys)."""
126
+
127
+ def setUp(self):
128
+ # Use a clean tmp directory as cwd stand-in: point --env-file to a non-existent path
129
+ # while eliminating the chance of hitting the repo root .env / capabilities/conversation-core/.env
130
+ self.tmp = tempfile.TemporaryDirectory()
131
+ self.empty_env = Path(self.tmp.name) / "no.env"
132
+ self.empty_env.write_text("# empty\n", encoding="utf-8")
133
+
134
+ def tearDown(self):
135
+ self.tmp.cleanup()
136
+
137
+ def _run(self, *extra_args):
138
+ return _run_cli(args=["--env-file", str(self.empty_env), *extra_args])
139
+
140
+ def test_tencent_empty_returns_e000(self):
141
+ proc = self._run("--type", "tencent")
142
+ self.assertNotEqual(proc.returncode, 0, proc.stderr)
143
+ out = json.loads(proc.stdout.strip())
144
+ self.assertFalse(out["ok"])
145
+ self.assertEqual(out["type"], "tencent")
146
+ self.assertEqual(out["error"], "E000")
147
+ self.assertSetEqual(
148
+ set(out.keys()), {"ok", "type", "error", "message", "latency_ms"}
149
+ )
150
+ # Output must not contain real keys (empty_env also ensures this)
151
+ self.assertNotIn("AKID", proc.stdout)
152
+ self.assertNotIn("AKID", proc.stderr)
153
+
154
+ def test_trtc_empty_returns_e000(self):
155
+ proc = self._run("--type", "trtc")
156
+ out = json.loads(proc.stdout.strip())
157
+ self.assertFalse(out["ok"])
158
+ self.assertEqual(out["type"], "trtc")
159
+ self.assertEqual(out["error"], "E000")
160
+
161
+ def test_llm_empty_returns_e000(self):
162
+ proc = self._run("--type", "llm")
163
+ out = json.loads(proc.stdout.strip())
164
+ self.assertFalse(out["ok"])
165
+ self.assertEqual(out["type"], "llm")
166
+ self.assertEqual(out["error"], "E000")
167
+
168
+ def test_all_empty_returns_three_items(self):
169
+ proc = self._run("--type", "all")
170
+ self.assertNotEqual(proc.returncode, 0)
171
+ out = json.loads(proc.stdout.strip())
172
+ self.assertEqual(out["type"], "all")
173
+ self.assertFalse(out["ok"])
174
+ types = {item["type"] for item in out["items"]}
175
+ self.assertSetEqual(types, {"tencent", "trtc", "llm"})
176
+
177
+
178
+ class VerifyCredentialsMockedNetworkTests(unittest.TestCase):
179
+ """Patch health.check_* to simulate success / failure responses from all three services."""
180
+
181
+ def setUp(self):
182
+ # Inject fake keys at process level (only to make ``configured`` return True)
183
+ self._keys = {
184
+ "TENCENT_CLOUD_SECRET_ID": "AKID_TEST_FAKE_FAKE_FAKE_FAKE_FAKE_X",
185
+ "TENCENT_CLOUD_SECRET_KEY": "FakeKeyFakeKeyFakeKeyFakeKeyFakeKey",
186
+ "TRTC_SDK_APP_ID": "1400000001",
187
+ "TRTC_SDK_SECRET_KEY": "FakeTRTCSdkSecretKeyFakeTRTCSdkSecretKey",
188
+ "LLM_API_KEY": "sk-fake-test-key",
189
+ "LLM_API_URL": "https://api.openai.example/v1/chat/completions",
190
+ "LLM_MODEL": "gpt-test",
191
+ "LLM_TYPE": "openai",
192
+ }
193
+ self._saved = {k: os.environ.get(k) for k in self._keys}
194
+ for k, v in self._keys.items():
195
+ os.environ[k] = v
196
+
197
+ def tearDown(self):
198
+ for k, prev in self._saved.items():
199
+ if prev is None:
200
+ os.environ.pop(k, None)
201
+ else:
202
+ os.environ[k] = prev
203
+
204
+ def _import_health(self):
205
+ """Explicitly import conversation-core's health module for patching.
206
+
207
+ Clean all cached ``src.*`` modules (side effect from test_handoff_ports / test_kb_ports),
208
+ and push conversation-core to the top of sys.path so ``src`` resolves back to this capability.
209
+ """
210
+ core_dir = _ROOT / "capabilities" / "conversation-core"
211
+ # First clean up src.* modules injected by previous tests
212
+ for name in [k for k in list(sys.modules) if k == "src" or k.startswith("src.")]:
213
+ del sys.modules[name]
214
+ # Also remove other capabilities paths from sys.path to avoid ambiguity
215
+ sys.path[:] = [p for p in sys.path if "/capabilities/" not in p]
216
+ sys.path.insert(0, str(core_dir))
217
+ import importlib # noqa: WPS433
218
+ return importlib.import_module("src.health")
219
+
220
+ def test_tencent_ok(self):
221
+ h = self._import_health()
222
+ from scripts.lib.credential_validators import validate_tencent
223
+ with patch.object(h, "check_tencent_cloud") as m:
224
+ m.return_value = h.CheckResult(ok=True, latency_ms=120, detail="sts ok")
225
+ r = validate_tencent()
226
+ self.assertTrue(r.ok)
227
+ self.assertEqual(r.type, "tencent")
228
+ self.assertEqual(r.error, "")
229
+ self.assertEqual(r.latency_ms, 120)
230
+
231
+ def test_tencent_failure_maps_to_e001(self):
232
+ h = self._import_health()
233
+ from scripts.lib.credential_validators import validate_tencent
234
+ with patch.object(h, "check_tencent_cloud") as m:
235
+ m.return_value = h.CheckResult(
236
+ ok=False, latency_ms=33, error_code="E001", detail="AuthFailure"
237
+ )
238
+ r = validate_tencent()
239
+ self.assertFalse(r.ok)
240
+ self.assertEqual(r.error, "E001")
241
+ # Must not echo key plaintext
242
+ self.assertNotIn("FakeKey", r.message)
243
+
244
+ def test_trtc_ok_local_only(self):
245
+ h = self._import_health()
246
+ from scripts.lib.credential_validators import validate_trtc
247
+ with patch.object(h, "check_trtc") as m:
248
+ m.return_value = h.CheckResult(ok=True, latency_ms=12, detail="local-only")
249
+ r = validate_trtc(deep=False)
250
+ self.assertTrue(r.ok)
251
+ self.assertEqual(r.type, "trtc")
252
+
253
+ def test_llm_failure_maps_to_e003(self):
254
+ h = self._import_health()
255
+ from scripts.lib.credential_validators import validate_llm
256
+ with patch.object(h, "check_llm") as m:
257
+ m.return_value = h.CheckResult(
258
+ ok=False, latency_ms=55, error_code="E003", detail="401 Unauthorized"
259
+ )
260
+ r = validate_llm()
261
+ self.assertFalse(r.ok)
262
+ self.assertEqual(r.error, "E003")
263
+ self.assertEqual(r.type, "llm")
264
+ # Output message must not contain raw sk-* credentials
265
+ self.assertNotIn("sk-fake", r.message)
266
+
267
+ def test_validate_all_aggregates(self):
268
+ h = self._import_health()
269
+ from scripts.lib.credential_validators import validate_all
270
+ with patch.object(h, "check_tencent_cloud") as a, \
271
+ patch.object(h, "check_trtc") as b, \
272
+ patch.object(h, "check_llm") as c:
273
+ a.return_value = h.CheckResult(ok=True, latency_ms=100)
274
+ b.return_value = h.CheckResult(ok=True, latency_ms=80, detail="ok")
275
+ c.return_value = h.CheckResult(ok=False, latency_ms=20, error_code="E003", detail="boom")
276
+ batch = validate_all()
277
+ self.assertFalse(batch.ok)
278
+ items = batch.to_dict()["items"]
279
+ self.assertEqual(len(items), 3)
280
+ # Order is fixed: tencent → trtc → llm
281
+ self.assertEqual([i["type"] for i in items], ["tencent", "trtc", "llm"])
282
+
283
+
284
+ if __name__ == "__main__":
285
+ unittest.main()
@@ -0,0 +1,29 @@
1
+ # trtc-ai-service trigger word registry
2
+ #
3
+ # Documentation only — routing logic is inlined in skills/trtc/SKILL.md.
4
+ # Do NOT reference this file as a runtime routing dependency.
5
+ #
6
+ # Purpose: single source of truth for what triggers the AI service fast-path,
7
+ # so edits happen here and get back-ported to SKILL.md manually.
8
+
9
+ triggers:
10
+ include:
11
+ # Chinese
12
+ - "AI客服"
13
+ - "智能客服"
14
+ - "搭建AI客服"
15
+ - "集成AI客服"
16
+ - "对话式AI"
17
+ - "语音助手 + 客服" # both tokens must appear together
18
+ # English
19
+ - "AI customer service"
20
+ - "AI customer service agent"
21
+ - "conversational AI"
22
+ - "TRTC Conversational AI"
23
+ - "voice agent + customer service" # both tokens must appear together
24
+
25
+ removed_from_pr:
26
+ # Removed — too broad, causes false positives on unrelated TRTC queries
27
+ - "intelligent Q&A"
28
+ - "智能问答"
29
+ - "build AI agent" # no customer-service modifier → too wide