@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
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""Three-key credential-less validation script (Phase 3 Stage 5).
|
|
4
|
+
|
|
5
|
+
Design Goals
|
|
6
|
+
------------
|
|
7
|
+
**The "atomic tool" for AI-driven key configuration flow**:
|
|
8
|
+
1. The AI writes user-pasted keys into ``.env`` via ``write_to_file``
|
|
9
|
+
2. The AI calls ``python scripts/verify-credentials.py [--type tencent|trtc|llm]``
|
|
10
|
+
3. This script **only** reads from .env / environment variables; it does **not** accept any keys as CLI arguments
|
|
11
|
+
4. Outputs **structured JSON** to stdout; the AI parses it to determine ok / failure and responds per SKILL.md §5.5
|
|
12
|
+
|
|
13
|
+
Output format (always valid JSON)::
|
|
14
|
+
|
|
15
|
+
Single: {"ok": true, "type": "tencent", "error": "", "message": "...", "latency_ms": 320}
|
|
16
|
+
Single: {"ok": false, "type": "trtc", "error": "E002", "message": "...", "latency_ms": 0}
|
|
17
|
+
Batch: {"ok": true, "type": "all", "items": [ ... ]}
|
|
18
|
+
|
|
19
|
+
Exit code: ``0`` means all passed; non-zero means at least one failure (for shell scripting).
|
|
20
|
+
|
|
21
|
+
Usage
|
|
22
|
+
-----
|
|
23
|
+
python3 scripts/verify-credentials.py # validate all three
|
|
24
|
+
python3 scripts/verify-credentials.py --type tencent # Tencent Cloud only
|
|
25
|
+
python3 scripts/verify-credentials.py --type trtc # TRTC only
|
|
26
|
+
python3 scripts/verify-credentials.py --type llm # LLM only
|
|
27
|
+
python3 scripts/verify-credentials.py --no-deep # TRTC skip deep OpenAPI validation
|
|
28
|
+
|
|
29
|
+
Security Constraints (Red Lines)
|
|
30
|
+
--------------------------------
|
|
31
|
+
- Never pass keys via CLI arguments (no --secret-id / --api-key parameters)
|
|
32
|
+
- Never echo credential plaintext to stdout / stderr
|
|
33
|
+
- ``.env`` permissions (600) are set by the caller at write time (this script does not re-process)
|
|
34
|
+
"""
|
|
35
|
+
from __future__ import annotations
|
|
36
|
+
|
|
37
|
+
import argparse
|
|
38
|
+
import json
|
|
39
|
+
import sys
|
|
40
|
+
import warnings
|
|
41
|
+
from pathlib import Path
|
|
42
|
+
|
|
43
|
+
# Suppress warnings from third-party libraries (e.g., urllib3 / NotOpenSSLWarning) sent to stderr,
|
|
44
|
+
# keeping stdout pure JSON and stderr silent — no noise for AI parsing
|
|
45
|
+
warnings.filterwarnings("ignore")
|
|
46
|
+
|
|
47
|
+
_HERE = Path(__file__).resolve().parent
|
|
48
|
+
_ROOT = _HERE.parent
|
|
49
|
+
if str(_ROOT) not in sys.path:
|
|
50
|
+
sys.path.insert(0, str(_ROOT))
|
|
51
|
+
|
|
52
|
+
from scripts.lib import credential_validators as cv # noqa: E402
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _print_json(data: dict) -> None:
|
|
56
|
+
sys.stdout.write(json.dumps(data, ensure_ascii=False))
|
|
57
|
+
sys.stdout.write("\n")
|
|
58
|
+
sys.stdout.flush()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def main(argv=None) -> int:
|
|
62
|
+
parser = argparse.ArgumentParser(
|
|
63
|
+
prog="verify-credentials",
|
|
64
|
+
description="Credential-less validation of three keys (reads from .env only, outputs structured JSON)",
|
|
65
|
+
)
|
|
66
|
+
parser.add_argument(
|
|
67
|
+
"--type",
|
|
68
|
+
choices=["tencent", "trtc", "llm", "all"],
|
|
69
|
+
default="all",
|
|
70
|
+
help="Validate a single key; default is all",
|
|
71
|
+
)
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
"--no-deep",
|
|
74
|
+
action="store_true",
|
|
75
|
+
help="Skip deep OpenAPI validation for TRTC; only local UserSig self-consistency check",
|
|
76
|
+
)
|
|
77
|
+
parser.add_argument(
|
|
78
|
+
"--env-file",
|
|
79
|
+
default="",
|
|
80
|
+
help="Optional: specify .env path (default: capabilities/conversation-core/.env)",
|
|
81
|
+
)
|
|
82
|
+
args = parser.parse_args(argv)
|
|
83
|
+
|
|
84
|
+
cv.load_dotenv(Path(args.env_file) if args.env_file else None)
|
|
85
|
+
|
|
86
|
+
if args.type == "tencent":
|
|
87
|
+
result = cv.validate_tencent()
|
|
88
|
+
_print_json(result.to_dict())
|
|
89
|
+
return 0 if result.ok else 1
|
|
90
|
+
|
|
91
|
+
if args.type == "trtc":
|
|
92
|
+
result = cv.validate_trtc(deep=not args.no_deep)
|
|
93
|
+
_print_json(result.to_dict())
|
|
94
|
+
return 0 if result.ok else 1
|
|
95
|
+
|
|
96
|
+
if args.type == "llm":
|
|
97
|
+
result = cv.validate_llm()
|
|
98
|
+
_print_json(result.to_dict())
|
|
99
|
+
return 0 if result.ok else 1
|
|
100
|
+
|
|
101
|
+
# all
|
|
102
|
+
batch = cv.validate_all()
|
|
103
|
+
_print_json(batch.to_dict())
|
|
104
|
+
return 0 if batch.ok else 1
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
if __name__ == "__main__":
|
|
108
|
+
sys.exit(main())
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# =====================================================================
|
|
3
|
+
# conversation-core · Launch script (slim / Phase 3 Stage 5)
|
|
4
|
+
#
|
|
5
|
+
# Assumes: .env already exists (key collection & writing hosted by AI;
|
|
6
|
+
# or developer runs `python scripts/setup-credentials.py` as fallback).
|
|
7
|
+
# Does only four things:
|
|
8
|
+
# 1. Detect Python ≥ 3.9
|
|
9
|
+
# 2. Create / reuse venv (does not pollute global environment)
|
|
10
|
+
# 3. Install / verify dependencies (Tsinghua mirror first, fallback to official source)
|
|
11
|
+
# 4. Launch FastAPI uvicorn (HTTP; --https uses self-signed cert)
|
|
12
|
+
#
|
|
13
|
+
# Usage:
|
|
14
|
+
# ./start.sh # HTTP launch (default port 3000)
|
|
15
|
+
# ./start.sh --https # HTTPS launch (self-signed)
|
|
16
|
+
# ./start.sh --rebuild # Force venv rebuild
|
|
17
|
+
# ./start.sh --port 8080 # Custom port
|
|
18
|
+
# =====================================================================
|
|
19
|
+
set -e
|
|
20
|
+
|
|
21
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
22
|
+
cd "$SCRIPT_DIR"
|
|
23
|
+
|
|
24
|
+
CORE_DIR="$SCRIPT_DIR/capabilities/conversation-core"
|
|
25
|
+
ENV_FILE="$CORE_DIR/.env"
|
|
26
|
+
REQUIREMENTS="$CORE_DIR/requirements.txt"
|
|
27
|
+
VENV_DIR="$SCRIPT_DIR/.venv"
|
|
28
|
+
MIN_PY_MAJOR=3; MIN_PY_MINOR=9
|
|
29
|
+
PORT=3000; REBUILD=0; USE_HTTPS=0
|
|
30
|
+
|
|
31
|
+
if [ -t 1 ]; then
|
|
32
|
+
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; CYAN='\033[0;36m'; BOLD='\033[1m'; NC='\033[0m'
|
|
33
|
+
else GREEN=''; YELLOW=''; RED=''; CYAN=''; BOLD=''; NC=''; fi
|
|
34
|
+
log() { printf "${CYAN}[%s]${NC} %s\n" "$(date +%H:%M:%S)" "$*"; }
|
|
35
|
+
ok() { printf "${GREEN}✓${NC} %s\n" "$*"; }
|
|
36
|
+
warn() { printf "${YELLOW}⚠${NC} %s\n" "$*"; }
|
|
37
|
+
die() { printf "${RED}✗${NC} %s\n" "$*" >&2; exit 1; }
|
|
38
|
+
|
|
39
|
+
while [ $# -gt 0 ]; do
|
|
40
|
+
case "$1" in
|
|
41
|
+
--rebuild) REBUILD=1 ;;
|
|
42
|
+
--https) USE_HTTPS=1 ;;
|
|
43
|
+
--port) shift; PORT="$1" ;;
|
|
44
|
+
--help|-h) sed -n '2,18p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
45
|
+
*) warn "Ignoring unknown argument: $1" ;;
|
|
46
|
+
esac
|
|
47
|
+
shift
|
|
48
|
+
done
|
|
49
|
+
|
|
50
|
+
# ---------------- Step 1: Prerequisites ----------------
|
|
51
|
+
[ -f "$ENV_FILE" ] || die ".env not found: $ENV_FILE\n Please first complete the 3-key configuration in the Coding Agent per SKILL.md §7;\n or developer fallback: python3 scripts/setup-credentials.py"
|
|
52
|
+
|
|
53
|
+
PY_CMD=""
|
|
54
|
+
for cand in python3.12 python3.11 python3.10 python3.9 python3 python; do
|
|
55
|
+
if command -v "$cand" >/dev/null 2>&1; then
|
|
56
|
+
VER=$("$cand" -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null || echo "0.0")
|
|
57
|
+
MAJOR=$(echo "$VER" | cut -d. -f1); MINOR=$(echo "$VER" | cut -d. -f2)
|
|
58
|
+
if [ "$MAJOR" -gt "$MIN_PY_MAJOR" ] || { [ "$MAJOR" -eq "$MIN_PY_MAJOR" ] && [ "$MINOR" -ge "$MIN_PY_MINOR" ]; }; then
|
|
59
|
+
PY_CMD="$cand"; ok "Python $VER -> $(command -v "$cand")"; break
|
|
60
|
+
fi
|
|
61
|
+
fi
|
|
62
|
+
done
|
|
63
|
+
[ -z "$PY_CMD" ] && die "No Python ≥ ${MIN_PY_MAJOR}.${MIN_PY_MINOR} detected"
|
|
64
|
+
|
|
65
|
+
# ---------------- Step 2: venv ----------------
|
|
66
|
+
[ "$REBUILD" -eq 1 ] && [ -d "$VENV_DIR" ] && { warn "Rebuilding venv..."; rm -rf "$VENV_DIR"; }
|
|
67
|
+
NEED_INSTALL=0
|
|
68
|
+
if [ ! -d "$VENV_DIR" ]; then
|
|
69
|
+
log "Creating virtual environment..."
|
|
70
|
+
"$PY_CMD" -m venv "$VENV_DIR" || die "venv creation failed (Linux may need: apt install python3-venv)"
|
|
71
|
+
NEED_INSTALL=1
|
|
72
|
+
fi
|
|
73
|
+
# shellcheck disable=SC1091
|
|
74
|
+
source "$VENV_DIR/bin/activate"
|
|
75
|
+
VENV_PY="$VENV_DIR/bin/python"; VENV_PIP="$VENV_DIR/bin/pip"
|
|
76
|
+
|
|
77
|
+
# ---------------- Step 3: Dependencies ----------------
|
|
78
|
+
[ "$NEED_INSTALL" -eq 0 ] && ! "$VENV_PY" -c "import fastapi, uvicorn, requests, dotenv, pydantic" 2>/dev/null && NEED_INSTALL=1
|
|
79
|
+
if [ "$NEED_INSTALL" -eq 1 ]; then
|
|
80
|
+
log "Installing dependencies..."
|
|
81
|
+
"$VENV_PIP" install --upgrade pip >/dev/null 2>&1 || true
|
|
82
|
+
if "$VENV_PIP" install -r "$REQUIREMENTS" -i "https://pypi.tuna.tsinghua.edu.cn/simple" --timeout 15 >/dev/null 2>&1; then
|
|
83
|
+
ok "Dependencies installed (Tsinghua mirror)"
|
|
84
|
+
else
|
|
85
|
+
warn "Mirror source failed, switching to official source..."
|
|
86
|
+
"$VENV_PIP" install -r "$REQUIREMENTS" >/dev/null || die "Dependency installation failed"
|
|
87
|
+
ok "Dependencies installed (official source)"
|
|
88
|
+
fi
|
|
89
|
+
else ok "Dependencies ready"; fi
|
|
90
|
+
|
|
91
|
+
# ---------------- Step 4: Launch ----------------
|
|
92
|
+
SSL_ARGS=""
|
|
93
|
+
if [ "$USE_HTTPS" -eq 1 ]; then
|
|
94
|
+
CERT_DIR="$SCRIPT_DIR/certs"; CERT_FILE="$CERT_DIR/cert.pem"; KEY_FILE="$CERT_DIR/key.pem"
|
|
95
|
+
if [ ! -f "$CERT_FILE" ] || [ ! -f "$KEY_FILE" ]; then
|
|
96
|
+
command -v openssl >/dev/null 2>&1 || die "openssl not installed"
|
|
97
|
+
mkdir -p "$CERT_DIR"
|
|
98
|
+
openssl req -x509 -newkey rsa:2048 -nodes -keyout "$KEY_FILE" -out "$CERT_FILE" \
|
|
99
|
+
-days 365 -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1" 2>/dev/null
|
|
100
|
+
ok "Self-signed certificate generated"
|
|
101
|
+
fi
|
|
102
|
+
SSL_ARGS="--ssl-keyfile $KEY_FILE --ssl-certfile $CERT_FILE"
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
SCHEME="http"; [ "$USE_HTTPS" -eq 1 ] && SCHEME="https"
|
|
106
|
+
printf "%b🚀 Launching conversation-core: %s://localhost:%s%b (Ctrl+C to stop)\n" "$GREEN" "$SCHEME" "$PORT" "$NC"
|
|
107
|
+
|
|
108
|
+
cd "$CORE_DIR"
|
|
109
|
+
export HOST="${HOST:-0.0.0.0}"; export PORT="$PORT"
|
|
110
|
+
# shellcheck disable=SC2086
|
|
111
|
+
exec "$VENV_PY" -m uvicorn src.server:app --host "$HOST" --port "$PORT" $SSL_ARGS
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Phase 2 integration test suite (stdlib only, run via python -m tests)."""
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""α/β dual-track arbitration tests."""
|
|
2
|
+
import sys
|
|
3
|
+
import unittest
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
_ROOT = Path(__file__).resolve().parent.parent
|
|
7
|
+
sys.path.insert(0, str(_ROOT))
|
|
8
|
+
|
|
9
|
+
from scripts.lib.arbitrator import AlphaTool, BetaTool, ToolRegistry
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ArbitratorTests(unittest.TestCase):
|
|
13
|
+
|
|
14
|
+
def test_alpha_first_when_both_available(self):
|
|
15
|
+
r = ToolRegistry(default_priority="alpha")
|
|
16
|
+
r.register_alpha(AlphaTool(name="echo", func=lambda **kw: {"track": "alpha", "kw": kw}))
|
|
17
|
+
r.register_beta(BetaTool(name="echo", endpoint="https://example.com"))
|
|
18
|
+
result = r.call("echo", {"x": 1})
|
|
19
|
+
self.assertEqual(result.track, "alpha")
|
|
20
|
+
self.assertTrue(result.ok)
|
|
21
|
+
self.assertEqual(result.fallback_chain, ["alpha"])
|
|
22
|
+
|
|
23
|
+
def test_alpha_failure_falls_back_to_beta(self):
|
|
24
|
+
r = ToolRegistry(default_priority="alpha")
|
|
25
|
+
|
|
26
|
+
def boom(**_kw):
|
|
27
|
+
raise RuntimeError("alpha down")
|
|
28
|
+
|
|
29
|
+
r.register_alpha(AlphaTool(name="echo", func=boom))
|
|
30
|
+
r.register_beta(BetaTool(name="echo", endpoint="https://example.com"))
|
|
31
|
+
|
|
32
|
+
def fake_beta(tool, params):
|
|
33
|
+
return {"track": "beta", "ep": tool.endpoint, "params": params}
|
|
34
|
+
|
|
35
|
+
result = r.call("echo", {"x": 1}, beta_invoker=fake_beta)
|
|
36
|
+
self.assertEqual(result.track, "beta")
|
|
37
|
+
self.assertTrue(result.ok)
|
|
38
|
+
self.assertEqual(result.fallback_chain, ["alpha", "beta"])
|
|
39
|
+
|
|
40
|
+
def test_beta_priority_explicit(self):
|
|
41
|
+
r = ToolRegistry(default_priority="beta")
|
|
42
|
+
r.register_alpha(AlphaTool(name="echo", func=lambda **kw: {"a": True}))
|
|
43
|
+
r.register_beta(BetaTool(name="echo", endpoint="https://example.com"))
|
|
44
|
+
|
|
45
|
+
result = r.call("echo", {}, beta_invoker=lambda t, p: {"b": True})
|
|
46
|
+
self.assertEqual(result.track, "beta")
|
|
47
|
+
|
|
48
|
+
def test_no_track_available_yields_failure(self):
|
|
49
|
+
r = ToolRegistry()
|
|
50
|
+
result = r.call("nonexistent", {})
|
|
51
|
+
self.assertFalse(result.ok)
|
|
52
|
+
self.assertIn("no track", result.error)
|
|
53
|
+
|
|
54
|
+
def test_alpha_only_when_beta_invoker_missing(self):
|
|
55
|
+
r = ToolRegistry()
|
|
56
|
+
r.register_beta(BetaTool(name="x", endpoint="https://example.com"))
|
|
57
|
+
# No beta_invoker provided
|
|
58
|
+
result = r.call("x", {})
|
|
59
|
+
self.assertFalse(result.ok)
|
|
60
|
+
self.assertIn("beta_invoker not provided", result.error)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
if __name__ == "__main__":
|
|
64
|
+
unittest.main()
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Capability overlay end-to-end tests: add-capability dry-run + adapter rendering against the real repo."""
|
|
2
|
+
import json
|
|
3
|
+
import subprocess
|
|
4
|
+
import sys
|
|
5
|
+
import tempfile
|
|
6
|
+
import unittest
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
_ROOT = Path(__file__).resolve().parent.parent
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _run(*args: str) -> dict:
|
|
13
|
+
proc = subprocess.run(
|
|
14
|
+
[sys.executable, str(_ROOT / "scripts" / "add-capability.py"), *args, "--json"],
|
|
15
|
+
cwd=str(_ROOT),
|
|
16
|
+
capture_output=True,
|
|
17
|
+
text=True,
|
|
18
|
+
timeout=20,
|
|
19
|
+
)
|
|
20
|
+
if proc.returncode != 0:
|
|
21
|
+
raise RuntimeError(f"add-capability failed: {proc.stderr}")
|
|
22
|
+
return json.loads(proc.stdout)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CapabilityOverlayTests(unittest.TestCase):
|
|
26
|
+
|
|
27
|
+
def test_list_includes_all_capabilities(self):
|
|
28
|
+
out = _run("--list")
|
|
29
|
+
self.assertEqual(out["skeleton"], "conversation-core")
|
|
30
|
+
names = {c["name"] for c in out["capabilities"]}
|
|
31
|
+
for n in ("knowledge-base", "tool-calling", "human-handoff",
|
|
32
|
+
"session-summary", "digital-human"):
|
|
33
|
+
self.assertIn(n, names)
|
|
34
|
+
|
|
35
|
+
def test_install_dry_run_topological_order(self):
|
|
36
|
+
out = _run("session-summary", "knowledge-base", "tool-calling")
|
|
37
|
+
order = out["install_order"]
|
|
38
|
+
self.assertTrue(set(order).issuperset({"knowledge-base", "tool-calling", "session-summary"}))
|
|
39
|
+
self.assertTrue(out["dry_run"])
|
|
40
|
+
for r in out["reports"]:
|
|
41
|
+
self.assertIn("skeleton_injection", r)
|
|
42
|
+
for inj in r["skeleton_injection"]:
|
|
43
|
+
# Injection plan must locate anchor (dry-run so applied may be True/False; key is no error)
|
|
44
|
+
if inj["error"]:
|
|
45
|
+
self.fail(f"injection error for {r['capability']}: {inj}")
|
|
46
|
+
|
|
47
|
+
def test_adapter_l1_render_for_react_project(self):
|
|
48
|
+
with tempfile.TemporaryDirectory() as td:
|
|
49
|
+
user_proj = Path(td) / "react-app"
|
|
50
|
+
user_proj.mkdir()
|
|
51
|
+
(user_proj / "package.json").write_text(
|
|
52
|
+
json.dumps({"dependencies": {"react": "^18.2.0"}}), encoding="utf-8"
|
|
53
|
+
)
|
|
54
|
+
out = _run(
|
|
55
|
+
"knowledge-base",
|
|
56
|
+
"--target-project", str(user_proj),
|
|
57
|
+
"--apply",
|
|
58
|
+
)
|
|
59
|
+
kb_report = next(r for r in out["reports"] if r["capability"] == "knowledge-base")
|
|
60
|
+
self.assertEqual(kb_report["adapter"]["adapter"], "frontend-spa")
|
|
61
|
+
self.assertEqual(kb_report["degrade"]["level"], "L1")
|
|
62
|
+
# Expected generated file exists
|
|
63
|
+
target = user_proj / "src" / "components" / "VoiceAgent.tsx"
|
|
64
|
+
self.assertTrue(target.exists(), f"expected {target} to exist")
|
|
65
|
+
content = target.read_text(encoding="utf-8")
|
|
66
|
+
# Placeholder variables have been substituted
|
|
67
|
+
self.assertIn("http://localhost:3000", content)
|
|
68
|
+
self.assertNotIn("${SKELETON_BASE_URL}", content)
|
|
69
|
+
|
|
70
|
+
def test_adapter_l3_when_unknown_stack(self):
|
|
71
|
+
with tempfile.TemporaryDirectory() as td:
|
|
72
|
+
user_proj = Path(td) / "exotic"
|
|
73
|
+
user_proj.mkdir()
|
|
74
|
+
(user_proj / "manifest.toml").write_text("# nothing recognisable\n", encoding="utf-8")
|
|
75
|
+
out = _run(
|
|
76
|
+
"knowledge-base",
|
|
77
|
+
"--target-project", str(user_proj),
|
|
78
|
+
)
|
|
79
|
+
kb_report = next(r for r in out["reports"] if r["capability"] == "knowledge-base")
|
|
80
|
+
self.assertIsNone(kb_report["adapter"]["tech_stack_used"])
|
|
81
|
+
self.assertEqual(kb_report["degrade"]["level"], "L3")
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
unittest.main()
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""Phase 3 阶段 6:scripts/lib/contract_resolver.py 单元测试。
|
|
2
|
+
|
|
3
|
+
覆盖目标:
|
|
4
|
+
- load_business_contract:能加载 human-handoff / knowledge-base 两个能力包并通过 BC001~BC006 校验
|
|
5
|
+
- diff_contracts:同名同类型 → 无 diff(L1);rename 候选命中同义词字典;类型不兼容 → L2
|
|
6
|
+
- decide_level:protocol 级别 method/body 不一致 → L3;out-of-slot rename → L2;slot 内 rename → L1
|
|
7
|
+
- validate_manifest:能产出(或不产出)warning 列表
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import sys
|
|
12
|
+
import unittest
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
_ROOT = Path(__file__).resolve().parent.parent
|
|
16
|
+
sys.path.insert(0, str(_ROOT))
|
|
17
|
+
|
|
18
|
+
from scripts.lib.contract_resolver import ( # noqa: E402
|
|
19
|
+
BusinessContract,
|
|
20
|
+
ContractError,
|
|
21
|
+
DegradeLevel,
|
|
22
|
+
decide_level,
|
|
23
|
+
diff_contracts,
|
|
24
|
+
load_business_contract,
|
|
25
|
+
validate_manifest,
|
|
26
|
+
)
|
|
27
|
+
from scripts.lib.curl_parser import AuthSpec, ParsedApi # noqa: E402
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
_HH_DIR = _ROOT / "capabilities" / "human-handoff"
|
|
31
|
+
_KB_DIR = _ROOT / "capabilities" / "knowledge-base"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class LoadBusinessContractTests(unittest.TestCase):
|
|
35
|
+
"""Read real manifests and verify correct field parsing."""
|
|
36
|
+
|
|
37
|
+
def test_load_human_handoff_outbound_apis(self):
|
|
38
|
+
bc = load_business_contract(_HH_DIR)
|
|
39
|
+
self.assertEqual(bc.capability, "human-handoff")
|
|
40
|
+
self.assertTrue(bc.port_class.endswith("HandoffClient"))
|
|
41
|
+
outs = bc.outbound_apis()
|
|
42
|
+
names = {a.name for a in outs}
|
|
43
|
+
# At least three outbound ticket APIs
|
|
44
|
+
self.assertIn("ticket.create", names)
|
|
45
|
+
self.assertIn("ticket.status_query", names)
|
|
46
|
+
self.assertIn("ticket.cancel", names)
|
|
47
|
+
# Inbound APIs should not mix into outbound
|
|
48
|
+
for a in outs:
|
|
49
|
+
self.assertEqual(a.direction, "outbound")
|
|
50
|
+
|
|
51
|
+
def test_load_knowledge_base_outbound_apis(self):
|
|
52
|
+
bc = load_business_contract(_KB_DIR)
|
|
53
|
+
self.assertEqual(bc.capability, "knowledge-base")
|
|
54
|
+
names = {a.name for a in bc.outbound_apis()}
|
|
55
|
+
# At least faq.search
|
|
56
|
+
self.assertIn("faq.search", names)
|
|
57
|
+
|
|
58
|
+
def test_get_api_lookup(self):
|
|
59
|
+
bc = load_business_contract(_HH_DIR)
|
|
60
|
+
api = bc.get_api("ticket.create")
|
|
61
|
+
self.assertIsNotNone(api)
|
|
62
|
+
self.assertEqual(api.method, "POST")
|
|
63
|
+
self.assertIn("user_id", api.request_schema)
|
|
64
|
+
self.assertIn("response.ticket_id", api.adapter_slots)
|
|
65
|
+
|
|
66
|
+
def test_load_missing_manifest_raises(self):
|
|
67
|
+
with self.assertRaises(ContractError) as ctx:
|
|
68
|
+
load_business_contract(_ROOT / "no_such_capability_dir")
|
|
69
|
+
self.assertEqual(ctx.exception.code, "BC000")
|
|
70
|
+
|
|
71
|
+
def test_validate_manifest_runs(self):
|
|
72
|
+
# validate_manifest must not raise fatal; BC004 warnings are allowed (array-type slot paths may hit hits[])
|
|
73
|
+
warnings_hh = validate_manifest(_HH_DIR)
|
|
74
|
+
self.assertIsInstance(warnings_hh, list)
|
|
75
|
+
warnings_kb = validate_manifest(_KB_DIR)
|
|
76
|
+
self.assertIsInstance(warnings_kb, list)
|
|
77
|
+
# Warning strings should start with BC prefix
|
|
78
|
+
for w in warnings_hh + warnings_kb:
|
|
79
|
+
self.assertTrue(w.startswith("BC"), w)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class DiffContractsTests(unittest.TestCase):
|
|
83
|
+
"""构造默认契约 + 用户 ParsedApi,验证 diff / level 决策。"""
|
|
84
|
+
|
|
85
|
+
def setUp(self):
|
|
86
|
+
bc = load_business_contract(_HH_DIR)
|
|
87
|
+
self.api = bc.get_api("ticket.create")
|
|
88
|
+
self.assertIsNotNone(self.api)
|
|
89
|
+
|
|
90
|
+
def _make_user(
|
|
91
|
+
self,
|
|
92
|
+
*,
|
|
93
|
+
method="POST",
|
|
94
|
+
path="/tickets",
|
|
95
|
+
request_schema=None,
|
|
96
|
+
body_format="json",
|
|
97
|
+
):
|
|
98
|
+
return ParsedApi(
|
|
99
|
+
method=method,
|
|
100
|
+
base_url="https://crm.example.com",
|
|
101
|
+
path=path,
|
|
102
|
+
headers={},
|
|
103
|
+
auth=AuthSpec(type="bearer", location="header", name="Authorization"),
|
|
104
|
+
request_schema=request_schema or {},
|
|
105
|
+
response_schema={},
|
|
106
|
+
body_format=body_format,
|
|
107
|
+
source="curl",
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
def test_l1_when_same_field_names(self):
|
|
111
|
+
"""Same field names + same types + method/path match → L1."""
|
|
112
|
+
user = self._make_user(
|
|
113
|
+
request_schema={
|
|
114
|
+
"user_id": "string",
|
|
115
|
+
"subject": "string",
|
|
116
|
+
"description": "string",
|
|
117
|
+
"priority": "string",
|
|
118
|
+
"transcript": "string[]",
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
diff = diff_contracts(self.api, user)
|
|
122
|
+
self.assertFalse(diff.protocol_mismatch)
|
|
123
|
+
self.assertEqual(decide_level(diff), DegradeLevel.L1)
|
|
124
|
+
|
|
125
|
+
def test_l1_when_slot_rename(self):
|
|
126
|
+
"""subject → title (synonym, inside adapter_slots) → still L1."""
|
|
127
|
+
user = self._make_user(
|
|
128
|
+
request_schema={
|
|
129
|
+
"user_id": "string",
|
|
130
|
+
"title": "string", # subject → title(slot 内)
|
|
131
|
+
"description": "string",
|
|
132
|
+
"priority": "string", # priority 仍同名
|
|
133
|
+
"transcript": "string[]",
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
diff = diff_contracts(self.api, user)
|
|
137
|
+
self.assertEqual(decide_level(diff), DegradeLevel.L1)
|
|
138
|
+
# Must have a rename record (subject → title) that is in-slot
|
|
139
|
+
renames = [f for f in diff.fields if f.kind == "rename"]
|
|
140
|
+
self.assertTrue(any(f.in_slot and "subject" in f.path for f in renames))
|
|
141
|
+
|
|
142
|
+
def test_l2_when_out_of_slot_rename(self):
|
|
143
|
+
"""user_id → customer_id (synonym, but user_id not in adapter_slots) → L2."""
|
|
144
|
+
user = self._make_user(
|
|
145
|
+
request_schema={
|
|
146
|
+
"customer_id": "string", # user_id 重命名(不在 slot)
|
|
147
|
+
"subject": "string",
|
|
148
|
+
"description": "string",
|
|
149
|
+
"priority": "string",
|
|
150
|
+
"transcript": "string[]",
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
diff = diff_contracts(self.api, user)
|
|
154
|
+
self.assertEqual(decide_level(diff), DegradeLevel.L2)
|
|
155
|
+
|
|
156
|
+
def test_l3_when_method_mismatch(self):
|
|
157
|
+
"""方法不一致(POST → PUT)→ protocol_mismatch → L3。"""
|
|
158
|
+
user = self._make_user(method="PUT")
|
|
159
|
+
diff = diff_contracts(self.api, user)
|
|
160
|
+
self.assertTrue(diff.protocol_mismatch)
|
|
161
|
+
self.assertEqual(decide_level(diff), DegradeLevel.L3)
|
|
162
|
+
|
|
163
|
+
def test_l3_when_raw_body_format(self):
|
|
164
|
+
"""body_format=raw (non-JSON) → protocol_mismatch → L3."""
|
|
165
|
+
user = self._make_user(body_format="raw")
|
|
166
|
+
diff = diff_contracts(self.api, user)
|
|
167
|
+
self.assertTrue(diff.protocol_mismatch)
|
|
168
|
+
self.assertEqual(decide_level(diff), DegradeLevel.L3)
|
|
169
|
+
|
|
170
|
+
def test_response_missing_does_not_block_l1(self):
|
|
171
|
+
"""User did not provide response → not counted as a protocol/L2/L3 obstacle."""
|
|
172
|
+
user = self._make_user(
|
|
173
|
+
request_schema={
|
|
174
|
+
"user_id": "string",
|
|
175
|
+
"subject": "string",
|
|
176
|
+
"description": "string",
|
|
177
|
+
"priority": "string",
|
|
178
|
+
"transcript": "string[]",
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
# response 留空
|
|
182
|
+
diff = diff_contracts(self.api, user)
|
|
183
|
+
self.assertEqual(decide_level(diff), DegradeLevel.L1)
|
|
184
|
+
# 但应有 user_response_missing 记录
|
|
185
|
+
kinds = {f.kind for f in diff.fields}
|
|
186
|
+
self.assertIn("user_response_missing", kinds)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
if __name__ == "__main__":
|
|
190
|
+
unittest.main()
|