@tencent-rtc/trtc-agent-skills 0.1.3 → 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.
- package/.cursor/rules/main.mdc +12 -0
- package/AGENTS.md +14 -104
- package/CLAUDE.md +15 -127
- package/CODEBUDDY.md +32 -118
- package/README.md +7 -5
- package/README.zh.md +7 -5
- package/bin/cli.js +133 -41
- package/hooks/__pycache__/cursor-adapter.cpython-313.pyc +0 -0
- package/hooks/cursor-adapter.py +45 -18
- package/hooks/hooks-cursor.json +5 -18
- package/hooks/hooks.json +6 -31
- package/knowledge-base/conference/web/index.yaml +143 -0
- package/knowledge-base/platform-slice-template.md +1041 -133
- package/knowledge-base/products.yaml +76 -0
- package/knowledge-base/scenario-spec.md +1316 -115
- package/knowledge-base/scenarios/conference/base/general-conference.md +22 -2
- package/knowledge-base/scenarios/conference/base/webinar-conference.md +14 -0
- package/knowledge-base/scenarios/conference/medical/1v1-video-consultation.md +19 -0
- package/knowledge-base/scenarios/conference/medical/medical-multidoctor-consultation.md +13 -0
- package/knowledge-base/scenarios/live/entertainment-live-room.md +12 -0
- package/knowledge-base/slice-spec.md +2377 -299
- package/knowledge-base/slices/conference/web/integration-audit.md +1 -1
- package/knowledge-base/slices/conference/web/login-auth.md +14 -1
- package/knowledge-base/tooling/aliases.yaml +92 -0
- package/knowledge-base/tooling/intent-signals.yaml +181 -0
- package/knowledge-base/tooling/symptom-keywords.yaml +21 -0
- package/package.json +1 -1
- package/skills/trtc/SKILL.md +202 -245
- package/skills/trtc/hooks/__pycache__/report_prompt.cpython-313.pyc +0 -0
- package/skills/{trtc-topic/guardrails → trtc/hooks}/gate_slice_read.py +12 -8
- package/skills/{trtc-topic/guardrails → trtc/hooks}/gate_slice_write.py +16 -12
- package/skills/{trtc-topic/guardrails → trtc/hooks}/stop_require_apply_evidence.py +22 -14
- package/skills/trtc/hooks/topic_phase_gate.py +161 -0
- package/skills/{trtc-topic → trtc}/runtime/README.md +2 -2
- package/skills/{trtc-onboarding/reference/reporting-protocol.md → trtc/runtime/REPORTING.md} +5 -5
- package/skills/{trtc-topic → trtc}/runtime/RUNTIME.md +5 -5
- package/skills/trtc/runtime/lib/__init__.py +0 -0
- package/skills/{trtc-topic → trtc}/runtime/package-lock.json +2 -2
- package/skills/{trtc-topic → trtc}/runtime/package.json +2 -2
- package/skills/{trtc-topic → trtc}/runtime/telemetry-bridge.mjs +1 -1
- package/skills/{trtc-topic/scripts → trtc/tools}/STATE-MACHINE-GUIDE.md +23 -23
- package/skills/trtc/tools/__init__.py +2 -0
- package/skills/trtc/tools/__pycache__/__init__.cpython-313.pyc +0 -0
- package/skills/trtc/tools/__pycache__/query_classifier.cpython-313.pyc +0 -0
- package/skills/trtc/tools/__pycache__/reporting.cpython-313.pyc +0 -0
- package/skills/trtc/tools/__pycache__/search.cpython-313.pyc +0 -0
- package/skills/trtc/tools/__pycache__/session.cpython-313.pyc +0 -0
- package/skills/trtc/tools/apply.py +540 -0
- package/skills/trtc/tools/docs.py +712 -0
- package/skills/trtc/tools/docsbot.py +182 -0
- package/skills/trtc/tools/entry/render_ai_instructions.py +92 -0
- package/skills/trtc/tools/flow.py +1089 -0
- package/skills/{trtc-topic/scripts → trtc/tools}/init_slice_queue.py +5 -4
- package/skills/{trtc-topic/scripts → trtc/tools}/next_slice.py +5 -4
- package/skills/trtc/tools/query_classifier.py +301 -0
- package/skills/trtc/tools/reporting.py +447 -0
- package/skills/trtc/tools/search.py +817 -0
- package/skills/trtc/tools/session.py +1261 -0
- package/skills/trtc/tools/state_machine.py +690 -0
- package/skills/trtc-ai-service/README.md +195 -0
- package/skills/trtc-ai-service/README.zh-CN.md +193 -0
- package/skills/trtc-ai-service/SKILL.md +945 -0
- package/skills/trtc-ai-service/auto_adapters/README.md +40 -0
- package/skills/trtc-ai-service/auto_adapters/frontend-spa/README.md +27 -0
- package/skills/trtc-ai-service/auto_adapters/frontend-spa/angular/voice-agent.component.ts.tpl +131 -0
- package/skills/trtc-ai-service/auto_adapters/frontend-spa/manifest.yaml +57 -0
- package/skills/trtc-ai-service/auto_adapters/frontend-spa/react/VoiceAgent.tsx.tpl +142 -0
- package/skills/trtc-ai-service/auto_adapters/frontend-spa/vue/VoiceAgent.vue.tpl +121 -0
- package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-backend.md +45 -0
- package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-frontend.md +51 -0
- package/skills/trtc-ai-service/auto_adapters/integration_templates/generic-rest-api.md +93 -0
- package/skills/trtc-ai-service/auto_adapters/java-backend/README.md +25 -0
- package/skills/trtc-ai-service/auto_adapters/java-backend/manifest.yaml +30 -0
- package/skills/trtc-ai-service/auto_adapters/java-backend/quarkus/VoiceAgentFilter.java.tpl +64 -0
- package/skills/trtc-ai-service/auto_adapters/java-backend/springboot/VoiceAgentFilter.java.tpl +91 -0
- package/skills/trtc-ai-service/auto_adapters/manifest.yaml +43 -0
- package/skills/trtc-ai-service/auto_adapters/node-backend/README.md +25 -0
- package/skills/trtc-ai-service/auto_adapters/node-backend/express.js.tpl +40 -0
- package/skills/trtc-ai-service/auto_adapters/node-backend/fastify.js.tpl +27 -0
- package/skills/trtc-ai-service/auto_adapters/node-backend/koa.js.tpl +31 -0
- package/skills/trtc-ai-service/auto_adapters/node-backend/manifest.yaml +47 -0
- package/skills/trtc-ai-service/auto_adapters/python-backend/README.md +22 -0
- package/skills/trtc-ai-service/auto_adapters/python-backend/django.py.tpl +32 -0
- package/skills/trtc-ai-service/auto_adapters/python-backend/fastapi.py.tpl +35 -0
- package/skills/trtc-ai-service/auto_adapters/python-backend/flask.py.tpl +31 -0
- package/skills/trtc-ai-service/auto_adapters/python-backend/manifest.yaml +45 -0
- package/skills/trtc-ai-service/capabilities/__init__.py +43 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/.env.example +29 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/INTEGRATION.md +134 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/INTERFACE_ADAPT.md +111 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/QUICK_START.md +62 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/manifest.yaml +250 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/requirements.txt +6 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/__init__.py +10 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/_capability_loader.py +218 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/agent.py +231 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/credentials.py +132 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/health.py +355 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/log_filter.py +76 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/modality.py +109 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/server.py +312 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/trtc_client.py +315 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/src/usersig.py +90 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/tests/test_skeleton.py +216 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/README.md +48 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/app.js +415 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/index.html +68 -0
- package/skills/trtc-ai-service/capabilities/conversation-core/web-demo/styles.css +136 -0
- package/skills/trtc-ai-service/capabilities/digital-human/README.md +31 -0
- package/skills/trtc-ai-service/capabilities/digital-human/manifest.yaml +64 -0
- package/skills/trtc-ai-service/capabilities/digital-human/src/__init__.py +2 -0
- package/skills/trtc-ai-service/capabilities/digital-human/src/router.py +43 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/INTERFACE_ADAPT.md +353 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/README.md +44 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/manifest.yaml +227 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/__init__.py +2 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/__init__.py +9 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/default_rest.py +242 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/factory.py +89 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/local_queue.py +258 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/adapters/mock.py +132 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/core/__init__.py +25 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/core/intent_detector.py +75 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/core/models.py +163 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/core/service.py +192 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/feedback_store.py +54 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/ports/__init__.py +4 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/ports/handoff_client.py +86 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/queue.py +62 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/router.py +201 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/summary_link.py +77 -0
- package/skills/trtc-ai-service/capabilities/human-handoff/src/trigger.py +25 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/INTERFACE_ADAPT.md +297 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/README.md +51 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/data/faq.json +20 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/manifest.yaml +211 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/__init__.py +8 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/__init__.py +9 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/default_rest.py +209 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/factory.py +86 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/local_json.py +172 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/adapters/mock.py +91 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/__init__.py +12 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/models.py +77 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/scoring.py +73 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/core/service.py +78 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/ports/__init__.py +4 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/ports/kb_client.py +61 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/retriever.py +56 -0
- package/skills/trtc-ai-service/capabilities/knowledge-base/src/router.py +85 -0
- package/skills/trtc-ai-service/capabilities/session-summary/INTERFACE_ADAPT.md +99 -0
- package/skills/trtc-ai-service/capabilities/session-summary/README.md +47 -0
- package/skills/trtc-ai-service/capabilities/session-summary/data/test_session.json +18 -0
- package/skills/trtc-ai-service/capabilities/session-summary/manifest.yaml +165 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/__init__.py +2 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/__init__.py +5 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/base.py +31 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/default_rest.py +67 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/factory.py +51 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/local_json.py +42 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/adapters/mock.py +22 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/recorder.py +210 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/router.py +93 -0
- package/skills/trtc-ai-service/capabilities/session-summary/src/summarizer.py +163 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/INTERFACE_ADAPT.md +158 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/README.md +50 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/data/tools.yaml +58 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/examples/__init__.py +1 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/examples/local_tools.py +101 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/manifest.yaml +146 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/src/__init__.py +8 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/src/dispatcher.py +54 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/src/registry.py +219 -0
- package/skills/trtc-ai-service/capabilities/tool-calling/src/router.py +50 -0
- package/skills/trtc-ai-service/references/business-contract-spec.md +263 -0
- package/skills/trtc-ai-service/scenarios/custom-builder/README.md +86 -0
- package/skills/trtc-ai-service/scenarios/custom-builder/output-templates/recipe.yaml.j2 +194 -0
- package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q1-business-scenario.md +43 -0
- package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q2-io-modality.md +57 -0
- package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q3-ui-form.md +55 -0
- package/skills/trtc-ai-service/scenarios/custom-builder/prompts/q4-capabilities.md +78 -0
- package/skills/trtc-ai-service/scenarios/customer-service/README.md +114 -0
- package/skills/trtc-ai-service/scenarios/customer-service/recipe.yaml +154 -0
- package/skills/trtc-ai-service/scenarios/customer-service/sample-data/README.md +32 -0
- package/skills/trtc-ai-service/scenarios/customer-service/sample-data/faq-sample.json +37 -0
- package/skills/trtc-ai-service/scenarios/customer-service/system-prompt.template.md +94 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/app.js +347 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/index.html +125 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/styles.css +487 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/admin-board/tokens.css +71 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/design-system/DESIGN_GUIDELINES.md +370 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/README.md +68 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/app.js +1307 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/data.js +40 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/index.html +233 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/mock-shop.json +21 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/styles.css +603 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/voice-customer-service/tokens.css +71 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/agent-link.js +323 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/app.js +458 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/index.html +109 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/styles.css +489 -0
- package/skills/trtc-ai-service/scenarios/customer-service/ui/widget-floating/tokens.css +59 -0
- package/skills/trtc-ai-service/scripts/add-capability.py +364 -0
- package/skills/trtc-ai-service/scripts/contract-adapt.py +334 -0
- package/skills/trtc-ai-service/scripts/detect-stack.py +40 -0
- package/skills/trtc-ai-service/scripts/lib/__init__.py +20 -0
- package/skills/trtc-ai-service/scripts/lib/adapter_codegen.py +509 -0
- package/skills/trtc-ai-service/scripts/lib/arbitrator.py +152 -0
- package/skills/trtc-ai-service/scripts/lib/contract_resolver.py +519 -0
- package/skills/trtc-ai-service/scripts/lib/credential_validators.py +253 -0
- package/skills/trtc-ai-service/scripts/lib/curl_parser.py +303 -0
- package/skills/trtc-ai-service/scripts/lib/degrader.py +140 -0
- package/skills/trtc-ai-service/scripts/lib/injector.py +347 -0
- package/skills/trtc-ai-service/scripts/lib/manifest_resolver.py +288 -0
- package/skills/trtc-ai-service/scripts/lib/openapi_parser.py +289 -0
- package/skills/trtc-ai-service/scripts/lib/stack_detector.py +159 -0
- package/skills/trtc-ai-service/scripts/lib/tokens_compile.py +204 -0
- package/skills/trtc-ai-service/scripts/post-install-patch.py +225 -0
- package/skills/trtc-ai-service/scripts/setup-credentials.py +393 -0
- package/skills/trtc-ai-service/scripts/verify-credentials.py +108 -0
- package/skills/trtc-ai-service/start.sh +111 -0
- package/skills/trtc-ai-service/tests/__init__.py +1 -0
- package/skills/trtc-ai-service/tests/test_arbitrator.py +64 -0
- package/skills/trtc-ai-service/tests/test_capability_overlay.py +85 -0
- package/skills/trtc-ai-service/tests/test_contract_resolver.py +190 -0
- package/skills/trtc-ai-service/tests/test_handoff_ports.py +195 -0
- package/skills/trtc-ai-service/tests/test_kb_ports.py +195 -0
- package/skills/trtc-ai-service/tests/test_manifest_resolver.py +95 -0
- package/skills/trtc-ai-service/tests/test_recipe_assembly.py +175 -0
- package/skills/trtc-ai-service/tests/test_stack_and_degrader.py +101 -0
- package/skills/trtc-ai-service/tests/test_verify_credentials.py +285 -0
- package/skills/trtc-ai-service/triggers.yaml +29 -0
- package/skills/trtc-conference/SKILL.md +324 -0
- package/skills/trtc-conference/flows/onboarding.md +205 -0
- package/skills/trtc-conference/flows/topic.md +474 -0
- package/skills/trtc-conference/flows/troubleshoot.md +85 -0
- package/skills/trtc-conference/hooks/pretooluse_require_business_decisions.py +213 -0
- package/skills/trtc-conference/playbooks/medical-quickstart.md +84 -0
- package/skills/trtc-conference/playbooks/official-roomkit.md +97 -0
- package/skills/trtc-conference/references/local-usersig/basic-info-config.ts +39 -0
- package/skills/trtc-conference/references/usersig-handling.md +134 -0
- package/skills/trtc-conference/templates/medical-consultation/src/config/lib-generate-test-usersig-es.min.d.ts +4 -0
- package/skills/trtc-conference/templates/medical-consultation/src/config/lib-generate-test-usersig-es.min.js +2 -0
- package/skills/trtc-conference/tests/__pycache__/test_conference_onboarding_contract.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-conference/tests/__pycache__/test_conference_topic_flow_contract.cpython-313-pytest-9.0.2.pyc +0 -0
- package/skills/trtc-conference/tests/test_conference_index_contract.py +43 -0
- package/skills/trtc-conference/tests/test_conference_onboarding_contract.py +103 -0
- package/skills/trtc-conference/tests/test_conference_template_contract.py +25 -0
- package/skills/trtc-conference/tests/test_conference_topic_flow_contract.py +132 -0
- package/skills/trtc-conference/tools/apply_checks.py +328 -0
- package/skills/trtc-conference/verify_lib/__init__.py +0 -0
- package/skills/{trtc-apply/guardrails/apply_lib → trtc-conference/verify_lib}/rule_parser.py +1 -1
- package/skills/trtc-docs/SKILL.md +91 -119
- package/.cursor/rules/ui-mode.mdc +0 -99
- package/ai-instructions/base.md +0 -13
- package/ai-instructions/ui-mode.md +0 -93
- package/knowledge-base/index.yaml +0 -462
- package/skills/trtc/room-builder/SKILL.md +0 -133
- package/skills/trtc/room-builder/templates/scenarios/medical-consultation/README.md +0 -108
- package/skills/trtc/room-builder/tools/render_ai_instructions.py +0 -226
- package/skills/trtc-apply/SKILL.md +0 -97
- package/skills/trtc-onboarding/SKILL.md +0 -841
- package/skills/trtc-onboarding/reference/path-a1-demo.md +0 -103
- package/skills/trtc-onboarding/reference/path-a2-integrate.md +0 -737
- package/skills/trtc-onboarding/reference/path-b-troubleshoot.md +0 -186
- package/skills/trtc-onboarding/reference/path-c-expand.md +0 -43
- package/skills/trtc-onboarding/reference/supported-matrix.md +0 -100
- package/skills/trtc-search/SKILL.md +0 -228
- package/skills/trtc-topic/SKILL.md +0 -622
- package/skills/trtc-topic/scripts/apply.py +0 -581
- package/skills/trtc-topic/scripts/lib/state_machine.py +0 -328
- package/skills/trtc-topic/tests/README.md +0 -70
- package/skills/trtc-topic/tests/conftest.py +0 -72
- package/skills/trtc-topic/tests/test_apply_cli.py +0 -480
- package/skills/trtc-topic/tests/test_end_to_end.py +0 -305
- package/skills/trtc-topic/tests/test_finalize_session.py +0 -51
- package/skills/trtc-topic/tests/test_gates.py +0 -316
- package/skills/trtc-topic/tests/test_session_resolver.py +0 -260
- package/skills/trtc-topic/tests/test_state_machine.py +0 -414
- package/skills/trtc-topic/tests/test_stop_require_apply.py +0 -99
- package/skills/trtc-topic/tests/test_topic_skill_invariants.py +0 -130
- /package/skills/{trtc-topic → trtc}/runtime/lib/platforms.py +0 -0
- /package/skills/{trtc-topic → trtc}/runtime/telemetry_collector.py +0 -0
- /package/skills/{trtc-onboarding/reference → trtc/runtime}/usersig-handling.md +0 -0
- /package/skills/{trtc-topic/scripts → trtc/tools}/finalize_session.py +0 -0
- /package/skills/{trtc-apply/guardrails/apply_lib → trtc-ai-service/capabilities/conversation-core/tests}/__init__.py +0 -0
- /package/skills/{trtc-topic → trtc-conference}/references/execution-units.yaml +0 -0
- /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
- /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
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/backend-contract.zh-CN.md +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/integration.zh-CN.md +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/docs/theme.zh-CN.md +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/index.html +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/package.json +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/postcss.config.js +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/App.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/ConsultationManagePanel.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/LanguageSwitch.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/LoadingSpinner.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalAlert.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalBusinessPanel.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalButton.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalConfirmDialog.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalDataPanel.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/MedicalRecordPanel.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/components/PrescriptionPanel.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/config/basic-info-config.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/config/runtime-config.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/env.d.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationChatPanel.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationMembersPanel.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationTranscriptionPanel.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/ConsultationVideoStage.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/InviteDoctorDialog.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/components/KickMemberConfirmDialog.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/types.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationChat.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationDevices.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationParticipants.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/useConsultationPermissions.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/features/consultation/utils.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/en-US/index.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/index.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/medicalTranslate.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/state.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/i18n/zh-CN/index.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/main.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/mock/appointments.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/mock/users.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/router/index.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/index.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/appointmentService.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/authService.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/launchContext.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/integration/userService.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/appointmentService.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/authService.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/mock/userService.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/services/adapters/types.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/shared/icons.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/index.css +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/tailwind.css +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/styles/theme.css +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/auth.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/format.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/navigation.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/utils/session.ts +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/DoctorConsultationView.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/DoctorDashboardView.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/LoginView.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientConsultationFinishedView.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientConsultationView.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientSelectDoctorView.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/src/views/PatientWaitingView.vue +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/tsconfig.json +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/tsconfig.node.json +0 -0
- /package/skills/{trtc/room-builder/templates/scenarios → trtc-conference/templates}/medical-consultation/vite.config.ts +0 -0
- /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
- /package/skills/{trtc-topic/runtime/lib → trtc-conference/tools}/__init__.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""init_slice_queue.py —
|
|
2
|
+
"""init_slice_queue.py — Materialise execution_queue from session.
|
|
3
3
|
|
|
4
4
|
Usage:
|
|
5
5
|
python3 init_slice_queue.py # auto-resolves session path
|
|
@@ -30,8 +30,9 @@ import sys
|
|
|
30
30
|
from pathlib import Path
|
|
31
31
|
|
|
32
32
|
HERE = Path(__file__).resolve().parent
|
|
33
|
-
sys.path.insert(0, str(HERE
|
|
34
|
-
|
|
33
|
+
sys.path.insert(0, str(HERE.parent.parent.parent))
|
|
34
|
+
|
|
35
|
+
from skills.trtc.tools import state_machine # noqa: E402
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
def _resolve_session_path() -> Path:
|
|
@@ -71,7 +72,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
71
72
|
|
|
72
73
|
try:
|
|
73
74
|
state_machine.init_queue(session_path)
|
|
74
|
-
except
|
|
75
|
+
except state_machine.StateMachineError as exc:
|
|
75
76
|
print(f"error: {exc}", file=sys.stderr)
|
|
76
77
|
return 1
|
|
77
78
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""next_slice.py —
|
|
2
|
+
"""next_slice.py — Query and advance the execution cursor.
|
|
3
3
|
|
|
4
4
|
The topic skill drives one execution step at a time by calling this between
|
|
5
5
|
steps. An execution step may be one slice or one delivery unit containing
|
|
@@ -40,8 +40,9 @@ import sys
|
|
|
40
40
|
from pathlib import Path
|
|
41
41
|
|
|
42
42
|
HERE = Path(__file__).resolve().parent
|
|
43
|
-
sys.path.insert(0, str(HERE
|
|
44
|
-
|
|
43
|
+
sys.path.insert(0, str(HERE.parent.parent.parent))
|
|
44
|
+
|
|
45
|
+
from skills.trtc.tools import state_machine # noqa: E402
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
def _resolve_session_path() -> Path:
|
|
@@ -75,7 +76,7 @@ def _print_status(session_path: Path, as_json: bool) -> int:
|
|
|
75
76
|
def _do_advance(session_path: Path, transition: str, as_json: bool) -> int:
|
|
76
77
|
try:
|
|
77
78
|
new_state = state_machine.advance(session_path, transition)
|
|
78
|
-
except
|
|
79
|
+
except state_machine.StateMachineError as exc:
|
|
79
80
|
if as_json:
|
|
80
81
|
print(jsonlib.dumps({"ok": False, "error": str(exc)}, ensure_ascii=False))
|
|
81
82
|
else:
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"""Deterministic query kind classifier for dispatcher/domain skill routing.
|
|
2
|
+
|
|
3
|
+
两级分类:
|
|
4
|
+
|
|
5
|
+
Level 1 — detect_query_kind()
|
|
6
|
+
返回 "error_code" | "symptom_like" | "capability"
|
|
7
|
+
区分 troubleshoot 类(错误码 / 症状描述)和功能类查询。
|
|
8
|
+
|
|
9
|
+
Level 2 — detect_capability_intent()(仅在 Level 1 返回 "capability" 时调用)
|
|
10
|
+
返回 "integrate" | "lookup" | "ambiguous"
|
|
11
|
+
区分"想做集成/构建"和"想了解/查文档",辅助 dispatcher 路由决策:
|
|
12
|
+
integrate → domain skill onboarding(写代码路径)
|
|
13
|
+
lookup → trtc-docs(文档查询路径,默认兜底)
|
|
14
|
+
ambiguous → 仅保留给空 query 等无法判别场景
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import os
|
|
20
|
+
import json
|
|
21
|
+
import re
|
|
22
|
+
import sys
|
|
23
|
+
from functools import lru_cache
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
from typing import Iterable, Optional
|
|
26
|
+
|
|
27
|
+
import yaml
|
|
28
|
+
|
|
29
|
+
THIS_FILE = Path(__file__).resolve()
|
|
30
|
+
DEFAULT_REPO_ROOT = THIS_FILE.parent.parent.parent.parent
|
|
31
|
+
ENV_REPO_ROOT = "TRTC_REPO_ROOT"
|
|
32
|
+
_ERROR_CODE_RE = re.compile(
|
|
33
|
+
r"(?:"
|
|
34
|
+
r"(?:error[_\s]?code|错误码|ERR[_-]?)\s*[::\s]?\s*-?\d{4,6}" # 显式上下文 + 数字
|
|
35
|
+
r"|\w+Error[::]" # TUICallEngineError: 等命名错误模式
|
|
36
|
+
r"|(?<![A-Za-z0-9])-?\d{5,6}(?![A-Za-z0-9])" # 独立 5-6 位数字(4位太易误判端口/版本号)
|
|
37
|
+
r")",
|
|
38
|
+
re.IGNORECASE
|
|
39
|
+
)
|
|
40
|
+
_ERROR_CODE_HINT_RE = re.compile(r"(?:error[_\s]?code|错误码)", re.IGNORECASE)
|
|
41
|
+
_MINIMAL_SYMPTOMS = (
|
|
42
|
+
"失败", "报错", "黑屏", "黑帧", "crash", "error", "闪退",
|
|
43
|
+
"没声音", "无声音", "听不到", "看不到", "收不到", "卡住", "超时",
|
|
44
|
+
"断开", "进不去", "不工作", "定格", "升级后", "无法",
|
|
45
|
+
"canceled", "cancelled", "没有响应", "没反应",
|
|
46
|
+
)
|
|
47
|
+
# 词表缺失时的最小内置信号,覆盖最常见的中英文表达
|
|
48
|
+
_MINIMAL_INTEGRATE_SIGNALS = (
|
|
49
|
+
"接入", "集成", "搭建", "我要做", "我想做", "做一个", "快速接入",
|
|
50
|
+
"如何实现", "怎么实现",
|
|
51
|
+
"how to build", "how to implement", "how to integrate",
|
|
52
|
+
"how to set up", "how to add", "integrate", "implement",
|
|
53
|
+
"build a", "create a", "set up", "get started", "quickstart",
|
|
54
|
+
)
|
|
55
|
+
_MINIMAL_LOOKUP_SIGNALS = (
|
|
56
|
+
"是什么", "有哪些", "支持吗", "能否", "可以吗", "有什么区别", "对比", "原理",
|
|
57
|
+
"what is", "what are", "does it support", "can it",
|
|
58
|
+
"how does it work", "how does", "vs", "compared to",
|
|
59
|
+
"difference between", "overview", "explain",
|
|
60
|
+
)
|
|
61
|
+
_BUILD_PATTERNS = (
|
|
62
|
+
re.compile(r"^[\w\u4e00-\u9fff\s.+/-]{1,48}(?:集成|接入|搭建)$", re.IGNORECASE),
|
|
63
|
+
re.compile(r"(?:如何|怎么|how to).{0,12}(?:实现|集成|接入|搭建|新增|添加|嵌入|迁移|改造|重构|定制)", re.IGNORECASE),
|
|
64
|
+
re.compile(r"(?:帮我|请|继续|需要|我要|我想|想要|想做).{0,12}(?:实现|集成|接入|搭建|新增|添加|迁移|做)", re.IGNORECASE),
|
|
65
|
+
re.compile(r"(?:给现有项目加|加到项目里|接到现有项目里|接到项目里|接进现有项目里|接进项目里)", re.IGNORECASE),
|
|
66
|
+
re.compile(r"(?:在|给).{0,16}(?:项目|应用|页面|直播间|房间).{0,16}(?:集成|接入|增加|新增|添加|加)", re.IGNORECASE),
|
|
67
|
+
re.compile(r"(?:实现|implement).{0,24}(?:功能|页面|模块|场景|workflow|battle|gift|barrage|co-guest|cohost|comments?|feature)", re.IGNORECASE),
|
|
68
|
+
re.compile(r"(?:add|integrate|implement|wire up|migrate).{0,28}(?:to|into|in).{0,16}(?:my|our|existing).{0,16}(?:project|app|vue|react|ios|android|flutter)", re.IGNORECASE),
|
|
69
|
+
re.compile(r"(?:walk me through|help me (?:build|integrate|implement)|how to (?:build|integrate|implement|set up|add)|get started with|quick start(?: for)?)", re.IGNORECASE),
|
|
70
|
+
)
|
|
71
|
+
_LOOKUP_PATTERNS = (
|
|
72
|
+
re.compile(r"(?:是什么|有哪些|是否支持|支持什么|支持.{0,16}吗|能否|可以吗|有没有|什么区别|有什么区别|有什么不同|对比|原理|机制|概念|说明|介绍一下|了解)", re.IGNORECASE),
|
|
73
|
+
re.compile(r"(?:如何|怎么|how to).{0,12}(?:配置|开启|调用|使用|获取|展示|显示|判断|查看|填写|设置|导入)", re.IGNORECASE),
|
|
74
|
+
re.compile(r"(?:获取|查询|查找|看看).{0,16}(?:文档|docs|documentation|说明)", re.IGNORECASE),
|
|
75
|
+
re.compile(r"(?:错误码|error code|字段含义|调用方式|从哪里来|在哪里|官方方式|导入和使用方式|api 用法|api 调用方式|技术实现细节|基础集成文档|对照表)", re.IGNORECASE),
|
|
76
|
+
re.compile(r"(?:what is|what are|does it support|can it|is it possible|how does it work|difference between|what's the difference|compared to|vs|overview|concept|explain|documentation|docs)", re.IGNORECASE),
|
|
77
|
+
)
|
|
78
|
+
_QUESTION_STARTERS = (
|
|
79
|
+
"什么", "为什么", "为何", "怎么", "如何", "是否", "能否", "可以", "支持", "有没有",
|
|
80
|
+
"what", "why", "how", "does", "can", "is", "which", "where",
|
|
81
|
+
"了解", "查询", "获取",
|
|
82
|
+
)
|
|
83
|
+
_GENERIC_INTEGRATE_SIGNALS = {
|
|
84
|
+
"接入", "集成", "integrate", "implement", "build a", "create a", "set up", "get started", "quickstart", "quick start",
|
|
85
|
+
}
|
|
86
|
+
_INTEGRATION_CONTEXT_PATTERNS = (
|
|
87
|
+
re.compile(r"(?:已|已经|当前).{0,4}(?:集成|接入)", re.IGNORECASE),
|
|
88
|
+
re.compile(r"(?:集成|接入)(?:中|后)", re.IGNORECASE),
|
|
89
|
+
re.compile(r"integrated?\s+(?:with|in)", re.IGNORECASE),
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _repo_root() -> Path:
|
|
94
|
+
env = os.environ.get(ENV_REPO_ROOT)
|
|
95
|
+
return Path(env).resolve() if env else DEFAULT_REPO_ROOT
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _symptom_keywords_path() -> Path:
|
|
99
|
+
return _repo_root() / "knowledge-base" / "tooling" / "symptom-keywords.yaml"
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _intent_signals_path() -> Path:
|
|
103
|
+
return _repo_root() / "knowledge-base" / "tooling" / "intent-signals.yaml"
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@lru_cache(maxsize=1)
|
|
107
|
+
def load_symptom_keywords() -> tuple[str, ...]:
|
|
108
|
+
path = _symptom_keywords_path()
|
|
109
|
+
if not path.exists():
|
|
110
|
+
# fail-open:系统词表缺失时退回最小内置词集,而不是让调用方整体失效。
|
|
111
|
+
return _MINIMAL_SYMPTOMS
|
|
112
|
+
try:
|
|
113
|
+
data = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
|
114
|
+
except Exception:
|
|
115
|
+
return _MINIMAL_SYMPTOMS
|
|
116
|
+
raw = data.get("symptom_keywords") or []
|
|
117
|
+
values = list(_MINIMAL_SYMPTOMS)
|
|
118
|
+
for item in raw:
|
|
119
|
+
text = str(item).strip().lower()
|
|
120
|
+
if text and text not in values:
|
|
121
|
+
values.append(text)
|
|
122
|
+
return tuple(values)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@lru_cache(maxsize=1)
|
|
126
|
+
def load_intent_signals() -> tuple[tuple[str, ...], tuple[str, ...]]:
|
|
127
|
+
"""加载 integrate / lookup 信号词。
|
|
128
|
+
|
|
129
|
+
返回 (integrate_signals, lookup_signals),两者均已 lowercase。
|
|
130
|
+
fail-open:文件缺失或解析失败时退回最小内置信号集。
|
|
131
|
+
"""
|
|
132
|
+
path = _intent_signals_path()
|
|
133
|
+
if not path.exists():
|
|
134
|
+
return _MINIMAL_INTEGRATE_SIGNALS, _MINIMAL_LOOKUP_SIGNALS
|
|
135
|
+
try:
|
|
136
|
+
data = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
|
137
|
+
except Exception:
|
|
138
|
+
return _MINIMAL_INTEGRATE_SIGNALS, _MINIMAL_LOOKUP_SIGNALS
|
|
139
|
+
|
|
140
|
+
def _load_list(key: str, defaults: tuple[str, ...]) -> tuple[str, ...]:
|
|
141
|
+
raw = data.get(key) or []
|
|
142
|
+
values = list(defaults)
|
|
143
|
+
for item in raw:
|
|
144
|
+
text = str(item).strip().lower()
|
|
145
|
+
if text and text not in values:
|
|
146
|
+
values.append(text)
|
|
147
|
+
return tuple(values)
|
|
148
|
+
|
|
149
|
+
integrate = _load_list("integrate_signals", _MINIMAL_INTEGRATE_SIGNALS)
|
|
150
|
+
lookup = _load_list("lookup_signals", _MINIMAL_LOOKUP_SIGNALS)
|
|
151
|
+
return integrate, lookup
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _normalize_query(query: str) -> str:
|
|
155
|
+
# classifier 只做轻量空白归一化;更重的 normalize 留给 search.py。
|
|
156
|
+
return " ".join((query or "").strip().lower().split())
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _has_error_code(query: str) -> bool:
|
|
160
|
+
query = query or ""
|
|
161
|
+
normalized = _normalize_query(query)
|
|
162
|
+
if re.fullmatch(r"-?\d{4,6}", normalized):
|
|
163
|
+
return True
|
|
164
|
+
return bool(_ERROR_CODE_RE.search(query) or _ERROR_CODE_HINT_RE.search(query))
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _has_symptom_token(query: str, keywords: Iterable[str]) -> bool:
|
|
168
|
+
normalized = _normalize_query(query)
|
|
169
|
+
return any(token and token in normalized for token in keywords)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def _matches_any(query: str, patterns: Iterable[re.Pattern[str]]) -> bool:
|
|
173
|
+
return any(pattern.search(query) for pattern in patterns)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _has_non_generic_integrate_signal(query: str, signals: Iterable[str]) -> bool:
|
|
177
|
+
hits = [sig for sig in signals if sig and sig in query and sig not in _GENERIC_INTEGRATE_SIGNALS]
|
|
178
|
+
return bool(hits)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _looks_like_question(query: str, raw_query: str) -> bool:
|
|
182
|
+
if "?" in raw_query or "?" in raw_query:
|
|
183
|
+
return True
|
|
184
|
+
return query.startswith(_QUESTION_STARTERS)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _is_integration_context_only(query: str) -> bool:
|
|
188
|
+
return _matches_any(query, _INTEGRATION_CONTEXT_PATTERNS)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def detect_query_kind(query: str, symptom_keywords: Optional[Iterable[str]] = None) -> str:
|
|
192
|
+
normalized = _normalize_query(query)
|
|
193
|
+
if not normalized:
|
|
194
|
+
return "capability"
|
|
195
|
+
if _has_error_code(normalized):
|
|
196
|
+
# error code 是最强 troubleshoot 信号,优先于其他症状词判断。
|
|
197
|
+
return "error_code"
|
|
198
|
+
keywords = tuple(symptom_keywords) if symptom_keywords is not None else load_symptom_keywords()
|
|
199
|
+
if _has_symptom_token(normalized, keywords):
|
|
200
|
+
# symptom_like 只负责快慢路径分流,不在这里继续做产品/能力级分类。
|
|
201
|
+
return "symptom_like"
|
|
202
|
+
return "capability"
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def detect_capability_intent(
|
|
206
|
+
query: str,
|
|
207
|
+
integrate_signals: Optional[Iterable[str]] = None,
|
|
208
|
+
lookup_signals: Optional[Iterable[str]] = None,
|
|
209
|
+
) -> str:
|
|
210
|
+
"""capability 查询的二级意图分类。
|
|
211
|
+
|
|
212
|
+
仅在 detect_query_kind() 返回 "capability" 后调用。
|
|
213
|
+
|
|
214
|
+
Returns:
|
|
215
|
+
"integrate" 用户想在项目里接入 / 构建功能 → domain skill onboarding
|
|
216
|
+
"lookup" 用户想了解 / 查阅文档 → trtc-docs
|
|
217
|
+
"ambiguous" 仅用于空 query 等无法判别场景
|
|
218
|
+
|
|
219
|
+
判断逻辑:
|
|
220
|
+
- 只看 query 里是否含有信号词(substring,已 lowercase),不看 session 状态。
|
|
221
|
+
- 只要命中强 integration 规则,就走 integrate。
|
|
222
|
+
- 其他所有 capability 查询默认都走 lookup,优先保证 docs 召回。
|
|
223
|
+
"""
|
|
224
|
+
raw_query = query or ""
|
|
225
|
+
normalized = _normalize_query(raw_query)
|
|
226
|
+
if not normalized:
|
|
227
|
+
return "ambiguous"
|
|
228
|
+
|
|
229
|
+
build_match = _matches_any(normalized, _BUILD_PATTERNS)
|
|
230
|
+
lookup_match = _matches_any(normalized, _LOOKUP_PATTERNS)
|
|
231
|
+
|
|
232
|
+
# 白名单策略:只有任务级集成/改造诉求才进入 integrate。
|
|
233
|
+
if build_match:
|
|
234
|
+
return "integrate"
|
|
235
|
+
|
|
236
|
+
# 文档/API/字段/错误码/组件用法查询优先判 lookup。
|
|
237
|
+
if lookup_match:
|
|
238
|
+
return "lookup"
|
|
239
|
+
|
|
240
|
+
loaded_int, loaded_lkp = load_intent_signals()
|
|
241
|
+
int_sigs = tuple(integrate_signals) if integrate_signals is not None else loaded_int
|
|
242
|
+
lkp_sigs = tuple(lookup_signals) if lookup_signals is not None else loaded_lkp
|
|
243
|
+
|
|
244
|
+
has_integrate = _has_non_generic_integrate_signal(normalized, int_sigs)
|
|
245
|
+
has_lookup = any(sig and sig in normalized for sig in lkp_sigs)
|
|
246
|
+
|
|
247
|
+
# “集成中 / 接入后 / 已集成” 这类是上下文说明,不应单独触发 integrate。
|
|
248
|
+
if not has_integrate and _is_integration_context_only(normalized):
|
|
249
|
+
has_lookup = True or has_lookup
|
|
250
|
+
|
|
251
|
+
if has_integrate and not has_lookup:
|
|
252
|
+
return "integrate"
|
|
253
|
+
if has_lookup:
|
|
254
|
+
return "lookup"
|
|
255
|
+
|
|
256
|
+
# 两边都没命中时,只要整体像提问,就保守落到 docs 路径,避免漏掉文档查询。
|
|
257
|
+
if _looks_like_question(normalized, raw_query):
|
|
258
|
+
return "lookup"
|
|
259
|
+
|
|
260
|
+
# 默认兜底到 docs:模糊 prompt 也优先给文档检索,避免漏路由。
|
|
261
|
+
return "lookup"
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _parse_args(argv: list[str]) -> dict[str, str | bool]:
|
|
265
|
+
out: dict[str, str | bool] = {}
|
|
266
|
+
i = 0
|
|
267
|
+
while i < len(argv):
|
|
268
|
+
arg = argv[i]
|
|
269
|
+
if arg.startswith("--"):
|
|
270
|
+
key = arg[2:]
|
|
271
|
+
if i + 1 < len(argv) and not argv[i + 1].startswith("--"):
|
|
272
|
+
out[key] = argv[i + 1]
|
|
273
|
+
i += 2
|
|
274
|
+
else:
|
|
275
|
+
out[key] = True
|
|
276
|
+
i += 1
|
|
277
|
+
else:
|
|
278
|
+
i += 1
|
|
279
|
+
return out
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def main() -> int:
|
|
283
|
+
argv = sys.argv[1:]
|
|
284
|
+
if not argv:
|
|
285
|
+
print(__doc__)
|
|
286
|
+
return 0
|
|
287
|
+
kv = _parse_args(argv)
|
|
288
|
+
query = kv.get("query")
|
|
289
|
+
if not query or isinstance(query, bool):
|
|
290
|
+
print("ERROR: --query 必须提供", file=sys.stderr)
|
|
291
|
+
return 1
|
|
292
|
+
kind = detect_query_kind(str(query))
|
|
293
|
+
result: dict = {"query": query, "kind": kind}
|
|
294
|
+
if kind == "capability":
|
|
295
|
+
result["capability_intent"] = detect_capability_intent(str(query))
|
|
296
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
297
|
+
return 0
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
if __name__ == "__main__":
|
|
301
|
+
raise SystemExit(main())
|