@tencent-rtc/trtc-agent-skills 0.1.1 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/main.mdc +12 -0
- package/AGENTS.md +14 -97
- package/CLAUDE.md +15 -120
- 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 +26 -3
- 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 +155 -0
- package/knowledge-base/slices/conference/web/login-auth.md +16 -2
- package/knowledge-base/slices/conference/web/official-roomkit-login-ui.md +41 -13
- package/knowledge-base/slices/conference/web/prejoin-check.md +8 -5
- 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 -244
- 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/room-builder/assets/local-usersig/basic-info-config.ts +39 -0
- package/skills/trtc/room-builder/assets/local-usersig/lib-generate-test-usersig-es.min.d.ts +4 -0
- package/skills/trtc/room-builder/assets/local-usersig/lib-generate-test-usersig-es.min.js +2 -0
- package/skills/{trtc-topic → trtc}/runtime/README.md +2 -2
- package/skills/{trtc-onboarding/reference/reporting-protocol.md → trtc/runtime/REPORTING.md} +5 -3
- 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/runtime/usersig-handling.md +134 -0
- 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 -92
- package/ai-instructions/base.md +0 -13
- package/ai-instructions/ui-mode.md +0 -86
- package/knowledge-base/index.yaml +0 -454
- package/skills/trtc/room-builder/SKILL.md +0 -138
- 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 -839
- package/skills/trtc-onboarding/reference/path-a1-demo.md +0 -103
- package/skills/trtc-onboarding/reference/path-a2-integrate.md +0 -693
- package/skills/trtc-onboarding/reference/path-b-troubleshoot.md +0 -115
- package/skills/trtc-onboarding/reference/path-c-expand.md +0 -43
- package/skills/trtc-onboarding/reference/supported-matrix.md +0 -100
- package/skills/trtc-onboarding/reference/usersig-handling.md +0 -140
- package/skills/trtc-search/SKILL.md +0 -221
- package/skills/trtc-topic/SKILL.md +0 -638
- 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-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,64 @@
|
|
|
1
|
+
# digital-human capability self-describing manifest
|
|
2
|
+
# Type: capability (reserved placeholder)
|
|
3
|
+
#
|
|
4
|
+
# Phase 2 goal: only declare manifest, provide "integration interface contract";
|
|
5
|
+
# actual rendering / lip-sync / expression driving etc. deferred to future iterations.
|
|
6
|
+
# After injection into skeleton, this package does no code injection, only exposes REST endpoint stubs.
|
|
7
|
+
|
|
8
|
+
name: "digital-human"
|
|
9
|
+
version: "0.1.0"
|
|
10
|
+
type: "capability"
|
|
11
|
+
description: "Digital human capability placeholder (rendering / lip-sync / expression driving). Only declares interface contract; rendering layer not enabled"
|
|
12
|
+
|
|
13
|
+
dependencies:
|
|
14
|
+
- name: "conversation-core"
|
|
15
|
+
version: ">=1.0.0,<2.0.0"
|
|
16
|
+
|
|
17
|
+
extensions:
|
|
18
|
+
- inject_at: "server.router_extension"
|
|
19
|
+
inline_code: |
|
|
20
|
+
# [digital-human] mount sub-router
|
|
21
|
+
from ._capability_loader import try_load_capability as _try_load_capability
|
|
22
|
+
_dh_router_mod = _try_load_capability("digital-human", "src/router.py")
|
|
23
|
+
if _dh_router_mod is not None and hasattr(_dh_router_mod, "router"):
|
|
24
|
+
app.include_router(
|
|
25
|
+
_dh_router_mod.router, prefix="/api/v1/digital-human", tags=["digital-human"]
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
config:
|
|
29
|
+
enabled:
|
|
30
|
+
description: "Whether to enable (stub implementation, defaults to false to avoid accidental use)"
|
|
31
|
+
default: false
|
|
32
|
+
avatar_id:
|
|
33
|
+
description: "Default digital human avatar ID (used when integrating third-party rendering service)"
|
|
34
|
+
default: ""
|
|
35
|
+
lipsync_provider:
|
|
36
|
+
description: "Lip-sync provider placeholder"
|
|
37
|
+
default: "tencent-cloud-vmp"
|
|
38
|
+
expression_provider:
|
|
39
|
+
description: "Expression driving provider placeholder"
|
|
40
|
+
default: "internal-rule"
|
|
41
|
+
|
|
42
|
+
endpoints:
|
|
43
|
+
- method: GET
|
|
44
|
+
path: /api/v1/digital-human/status
|
|
45
|
+
description: Returns placeholder status and future plans
|
|
46
|
+
- method: POST
|
|
47
|
+
path: /api/v1/digital-human/render
|
|
48
|
+
description: Rendering interface contract (currently returns 501 Not Implemented)
|
|
49
|
+
|
|
50
|
+
integration:
|
|
51
|
+
mode: "manual"
|
|
52
|
+
fallback:
|
|
53
|
+
manual_api:
|
|
54
|
+
rest_endpoint: "/api/v1/digital-human"
|
|
55
|
+
sdk_packages: []
|
|
56
|
+
|
|
57
|
+
security:
|
|
58
|
+
log_redaction:
|
|
59
|
+
enabled: true
|
|
60
|
+
patterns: ["api_key", "token"]
|
|
61
|
+
|
|
62
|
+
acceptance:
|
|
63
|
+
- "Manifest passes manifest_resolver validation (dependencies / injection points valid)"
|
|
64
|
+
- "REST stub endpoints return explicit 'not implemented' marker"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""digital-human FastAPI placeholder router.
|
|
2
|
+
|
|
3
|
+
Interface contract fixed:
|
|
4
|
+
- GET /status Returns placeholder status + roadmap
|
|
5
|
+
- POST /render Returns 501 Not Implemented, deferred to future iterations
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
from fastapi import APIRouter, HTTPException
|
|
12
|
+
|
|
13
|
+
router = APIRouter()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@router.get("/status")
|
|
17
|
+
def status() -> dict:
|
|
18
|
+
return {
|
|
19
|
+
"code": 0,
|
|
20
|
+
"data": {
|
|
21
|
+
"enabled": os.getenv("DH_ENABLED", "false").lower() == "true",
|
|
22
|
+
"avatar_id": os.getenv("DH_AVATAR_ID", ""),
|
|
23
|
+
"lipsync_provider": os.getenv("DH_LIPSYNC_PROVIDER", "tencent-cloud-vmp"),
|
|
24
|
+
"expression_provider": os.getenv("DH_EXPRESSION_PROVIDER", "internal-rule"),
|
|
25
|
+
"phase": "placeholder",
|
|
26
|
+
"roadmap": [
|
|
27
|
+
"Phase 3+: Integrate third-party rendering SDK (avatar / lipsync / expression)",
|
|
28
|
+
"Support WebRTC datachannel driver data push",
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@router.post("/render")
|
|
35
|
+
def render() -> dict:
|
|
36
|
+
raise HTTPException(
|
|
37
|
+
status_code=501,
|
|
38
|
+
detail={
|
|
39
|
+
"code": "not_implemented",
|
|
40
|
+
"message": "digital-human render is a placeholder; rendering layer not shipped in Phase 2",
|
|
41
|
+
"hint": "follow capabilities/digital-human/README.md for integration roadmap",
|
|
42
|
+
},
|
|
43
|
+
)
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# human-handoff Interface Adaptation SOP
|
|
2
|
+
|
|
3
|
+
> When the user's existing ticket / agent dispatch system interface differs from this capability's default contract, follow this document for scenario-specific operations.
|
|
4
|
+
> Recommended: use `python scripts/contract-adapt.py human-handoff` for automated generation; this document is the manual fallback.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Default Contract Overview
|
|
9
|
+
|
|
10
|
+
This capability **calls** the user's ticket system interfaces (outbound):
|
|
11
|
+
|
|
12
|
+
| Contract | Method | Path | Purpose |
|
|
13
|
+
|---|---|---|---|
|
|
14
|
+
| `ticket.create` | POST | `/tickets` | Create ticket |
|
|
15
|
+
| `ticket.status_query` | GET | `/tickets/{ticket_id}` | Query ticket status |
|
|
16
|
+
| `ticket.cancel` | POST | `/tickets/{ticket_id}/cancel` | Cancel ticket |
|
|
17
|
+
| `ticket.status_callback` | POST | `/api/v1/handoff/callback/ticket-status` | Business callback (inbound) |
|
|
18
|
+
|
|
19
|
+
Full field definitions in `manifest.yaml` `business_contract.external_apis`.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Three-Layer Defense Mechanism
|
|
24
|
+
|
|
25
|
+
| Layer | Artifact Location | Applicable Scenario |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| **L1 Field Mapping** | Field name / simple type differences only | 90% of common cases |
|
|
28
|
+
| **L2 Adapter Subclass** | Auth, transport headers, error codes, URL template differences | Different auth mechanism / path/routing style |
|
|
29
|
+
| **L3 Full Custom Implementation** | Protocol-level differences (webhook / MQ / gRPC) | Non-REST protocols |
|
|
30
|
+
|
|
31
|
+
All three layers land in `capabilities/human-handoff/src/adapters/user_custom.py` and are enabled via `HH_ADAPTER=user_custom`.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 3. L1 Field Mapping (Most Common)
|
|
36
|
+
|
|
37
|
+
### 3.1 Applicability
|
|
38
|
+
|
|
39
|
+
- User interface is still REST + JSON
|
|
40
|
+
- Only field name / field path differences (within `adapter_slots` scope)
|
|
41
|
+
- Field types are consistent (string ↔ string, int ↔ int)
|
|
42
|
+
|
|
43
|
+
### 3.2 Steps
|
|
44
|
+
|
|
45
|
+
**Step 1**: Paste the user's curl or OpenAPI
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# User's ticket creation interface
|
|
49
|
+
curl -X POST https://crm.example.com/api/v2/work_orders \
|
|
50
|
+
-H 'X-Auth-Token: xxx' \
|
|
51
|
+
-d '{
|
|
52
|
+
"customer_id": "u001",
|
|
53
|
+
"title": "Refund issue",
|
|
54
|
+
"level": "P2",
|
|
55
|
+
"messages": ["..."]
|
|
56
|
+
}'
|
|
57
|
+
# Response: { "id": "WO123", "rank": 5, "wait_estimate": 150 }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Step 2**: Write mapping file `capabilities/human-handoff/src/adapters/user_custom_mapping.yaml`
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
# Field path mapping: left = default contract field, right = user's actual field
|
|
64
|
+
ticket.create:
|
|
65
|
+
request:
|
|
66
|
+
user_id: customer_id
|
|
67
|
+
subject: title
|
|
68
|
+
priority: level # Value mapping below
|
|
69
|
+
transcript: messages
|
|
70
|
+
response:
|
|
71
|
+
ticket_id: id
|
|
72
|
+
queue_position: rank
|
|
73
|
+
eta_seconds: wait_estimate
|
|
74
|
+
# Enum value mapping
|
|
75
|
+
enum_map:
|
|
76
|
+
request.priority:
|
|
77
|
+
low: P3
|
|
78
|
+
normal: P2
|
|
79
|
+
high: P1
|
|
80
|
+
urgent: P0
|
|
81
|
+
|
|
82
|
+
ticket.status_query:
|
|
83
|
+
request:
|
|
84
|
+
ticket_id: id
|
|
85
|
+
response:
|
|
86
|
+
ticket_id: id
|
|
87
|
+
status: state
|
|
88
|
+
enum_map:
|
|
89
|
+
response.status:
|
|
90
|
+
pending: queued
|
|
91
|
+
processing: in_progress
|
|
92
|
+
closed: done
|
|
93
|
+
canceled: cancelled
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Step 3**: Generate adapter (via tool)
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
python scripts/contract-adapt.py human-handoff \
|
|
100
|
+
--base-url https://crm.example.com \
|
|
101
|
+
--auth-header "X-Auth-Token" \
|
|
102
|
+
--mapping capabilities/human-handoff/src/adapters/user_custom_mapping.yaml
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The tool generates `user_custom.py` based on the mapping, automatically inheriting `DefaultRestHandoffClient` and overriding field mapping logic.
|
|
106
|
+
|
|
107
|
+
**Step 4**: Enable
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
export HH_ADAPTER=user_custom
|
|
111
|
+
export HH_REST_BASE_URL=https://crm.example.com
|
|
112
|
+
export HH_REST_TOKEN=<your-token> # Optional; leave empty if no token
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 4. L2 Adapter Subclass (Auth / Path Style Differences)
|
|
118
|
+
|
|
119
|
+
### 4.1 Applicability
|
|
120
|
+
|
|
121
|
+
- Auth method is not Bearer (e.g. `X-Auth-Token`, `HMAC-SHA256` signature, dual token)
|
|
122
|
+
- Different path templates (e.g. `/tickets/{id}` vs `/work-orders/by-id/{id}`)
|
|
123
|
+
- Error codes are not HTTP standard (e.g. returns 200 but body has `code != 0`)
|
|
124
|
+
|
|
125
|
+
### 4.2 Template Code
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
# capabilities/human-handoff/src/adapters/user_custom.py
|
|
129
|
+
from typing import List, Optional
|
|
130
|
+
|
|
131
|
+
from ..core.models import Ticket, TicketStatus
|
|
132
|
+
from .default_rest import DefaultRestHandoffClient
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class UserCustomHandoffClient(DefaultRestHandoffClient):
|
|
136
|
+
"""User ticket system adapter (L2)."""
|
|
137
|
+
|
|
138
|
+
def _headers(self) -> dict:
|
|
139
|
+
# Override auth method
|
|
140
|
+
h = {"Content-Type": "application/json"}
|
|
141
|
+
if self._token:
|
|
142
|
+
h["X-Auth-Token"] = self._token # Not Bearer
|
|
143
|
+
return h
|
|
144
|
+
|
|
145
|
+
def create_ticket(
|
|
146
|
+
self,
|
|
147
|
+
*,
|
|
148
|
+
user_id: str,
|
|
149
|
+
subject: str = "",
|
|
150
|
+
description: str = "",
|
|
151
|
+
priority: str = "normal",
|
|
152
|
+
transcript: Optional[List[str]] = None,
|
|
153
|
+
) -> Ticket:
|
|
154
|
+
# TODO Field remapping
|
|
155
|
+
payload = {
|
|
156
|
+
"customer_id": user_id,
|
|
157
|
+
"title": subject,
|
|
158
|
+
"level": {"low": "P3", "normal": "P2", "high": "P1", "urgent": "P0"}[priority],
|
|
159
|
+
"messages": list(transcript or []),
|
|
160
|
+
}
|
|
161
|
+
data = self._post("/api/v2/work_orders", payload)
|
|
162
|
+
return Ticket(
|
|
163
|
+
ticket_id=str(data["id"]),
|
|
164
|
+
user_id=user_id,
|
|
165
|
+
subject=subject,
|
|
166
|
+
description=description,
|
|
167
|
+
priority=priority,
|
|
168
|
+
queue_position=int(data.get("rank", 0)),
|
|
169
|
+
eta_seconds=int(data.get("wait_estimate", 0)),
|
|
170
|
+
transcript=list(transcript or []),
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
def query_status(self, ticket_id: str) -> Optional[TicketStatus]:
|
|
174
|
+
# TODO Path template remapping
|
|
175
|
+
data = self._get(f"/api/v2/work_orders/by-id/{ticket_id}", optional=True)
|
|
176
|
+
if data is None:
|
|
177
|
+
return None
|
|
178
|
+
# TODO Status enum remapping
|
|
179
|
+
status_map = {"queued": "pending", "in_progress": "processing", "done": "closed"}
|
|
180
|
+
return TicketStatus(
|
|
181
|
+
ticket_id=str(data["id"]),
|
|
182
|
+
status=status_map.get(data.get("state", ""), data.get("state", "pending")),
|
|
183
|
+
agent_id=data.get("operator"),
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def from_env() -> Optional["UserCustomHandoffClient"]:
|
|
188
|
+
import os
|
|
189
|
+
base = os.getenv("HH_REST_BASE_URL")
|
|
190
|
+
if not base:
|
|
191
|
+
return None
|
|
192
|
+
return UserCustomHandoffClient(
|
|
193
|
+
base_url=base,
|
|
194
|
+
token=os.getenv("HH_REST_TOKEN"),
|
|
195
|
+
timeout_ms=int(os.getenv("HH_REST_TIMEOUT_MS", "5000")),
|
|
196
|
+
)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 4.3 Enable
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
export HH_ADAPTER=user_custom
|
|
203
|
+
export HH_REST_BASE_URL=https://crm.example.com
|
|
204
|
+
export HH_REST_TOKEN=<your-token>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 5. L3 Full Custom (Protocol Differences)
|
|
210
|
+
|
|
211
|
+
### 5.1 Applicability
|
|
212
|
+
|
|
213
|
+
- Business side uses webhooks (you push messages; business side async callbacks)
|
|
214
|
+
- Business side uses message queues (Kafka / RocketMQ / RabbitMQ)
|
|
215
|
+
- Business side uses gRPC / gRPC-Web
|
|
216
|
+
- User system is fully custom; no "generic ticket interface" concept
|
|
217
|
+
|
|
218
|
+
### 5.2 Template Code
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
# capabilities/human-handoff/src/adapters/user_custom.py
|
|
222
|
+
from typing import List, Optional
|
|
223
|
+
|
|
224
|
+
from ..core.models import OverallStatus, Ticket, TicketStatus, TicketStatusEnum, now_ts
|
|
225
|
+
from ..ports.handoff_client import HandoffClient
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
class UserCustomHandoffClient(HandoffClient):
|
|
229
|
+
"""User custom protocol adapter (L3: directly implements HandoffClient)."""
|
|
230
|
+
|
|
231
|
+
def __init__(self, **kwargs):
|
|
232
|
+
# TODO Initialize your client: Kafka producer / gRPC channel / webhook poster etc.
|
|
233
|
+
...
|
|
234
|
+
|
|
235
|
+
def create_ticket(self, *, user_id, subject="", description="",
|
|
236
|
+
priority="normal", transcript=None) -> Ticket:
|
|
237
|
+
# TODO Send ticket creation message using your own protocol
|
|
238
|
+
# e.g.: self._kafka.send("ticket.create", {...})
|
|
239
|
+
ticket_id = Ticket.new_id()
|
|
240
|
+
return Ticket(
|
|
241
|
+
ticket_id=ticket_id,
|
|
242
|
+
user_id=user_id,
|
|
243
|
+
subject=subject,
|
|
244
|
+
description=description,
|
|
245
|
+
priority=priority,
|
|
246
|
+
status=TicketStatusEnum.PENDING.value,
|
|
247
|
+
transcript=list(transcript or []),
|
|
248
|
+
created_at=now_ts(),
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
def query_status(self, ticket_id: str) -> Optional[TicketStatus]:
|
|
252
|
+
# TODO Query status from your storage / API
|
|
253
|
+
...
|
|
254
|
+
|
|
255
|
+
def cancel_ticket(self, ticket_id: str, reason: str = "") -> Optional[Ticket]:
|
|
256
|
+
# TODO
|
|
257
|
+
...
|
|
258
|
+
|
|
259
|
+
def overall_status(self) -> OverallStatus:
|
|
260
|
+
return OverallStatus(
|
|
261
|
+
agent_pool_size=-1, available_agents=-1, waiting=-1, connected=-1, capacity=-1
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
def list_tickets(self, *, limit=50, status=None) -> List[Ticket]:
|
|
265
|
+
# Dashboard may use this; return empty if remote backend doesn't support enumeration
|
|
266
|
+
return []
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def from_env():
|
|
270
|
+
return UserCustomHandoffClient(
|
|
271
|
+
broker=__import__("os").getenv("HH_BROKER_URL", ""),
|
|
272
|
+
)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## 6. Inbound Callback Integration (`ticket.status_callback`)
|
|
278
|
+
|
|
279
|
+
If the user's ticket system supports proactive callbacks, enabling inbound mode is recommended:
|
|
280
|
+
|
|
281
|
+
### 6.1 Our Exposed Callback Endpoint
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
POST /api/v1/handoff/callback/ticket-status
|
|
285
|
+
Content-Type: application/json
|
|
286
|
+
{
|
|
287
|
+
"ticket_id": "WO123",
|
|
288
|
+
"status": "processing",
|
|
289
|
+
"agent_id": "alice"
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Returns `{"code": 0, "message": "ok"}`.
|
|
294
|
+
|
|
295
|
+
> **Note**: This release's router.py has **not implemented** this inbound endpoint; using inbound mode requires registering a FastAPI route in user_custom.py and implementing it yourself, or wait for Phase 4 auto-generation by contract-adapt.py.
|
|
296
|
+
|
|
297
|
+
### 6.2 Inbound Field Mapping (different callback field names)
|
|
298
|
+
|
|
299
|
+
If the user system's callback uses field names like `id` / `state` / `operator`, add inbound mapping in user_custom.py:
|
|
300
|
+
|
|
301
|
+
```python
|
|
302
|
+
# Register the callback endpoint in the router and call this method to convert the payload
|
|
303
|
+
def _map_inbound(payload: dict) -> dict:
|
|
304
|
+
return {
|
|
305
|
+
"ticket_id": payload.get("id") or payload.get("ticket_id"),
|
|
306
|
+
"status": {"queued": "pending", "in_progress": "processing"}.get(
|
|
307
|
+
payload.get("state"), payload.get("status")
|
|
308
|
+
),
|
|
309
|
+
"agent_id": payload.get("operator") or payload.get("agent_id"),
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## 7. Switch / Verify
|
|
316
|
+
|
|
317
|
+
### 7.1 Enable user_custom
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
export HH_ADAPTER=user_custom
|
|
321
|
+
# Takes effect after service restart
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### 7.2 Unit Self-Check
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
python -c "
|
|
328
|
+
from capabilities.human_handoff.src.adapters.factory import build_default
|
|
329
|
+
c = build_default()
|
|
330
|
+
print('adapter:', type(c).__name__)
|
|
331
|
+
t = c.create_ticket(user_id='u_test', subject='ping')
|
|
332
|
+
print('created:', t.to_dict())
|
|
333
|
+
print('queried:', c.query_status(t.ticket_id))
|
|
334
|
+
"
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### 7.3 End-to-End
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
curl -X POST http://localhost:3000/api/v1/handoff/request \
|
|
341
|
+
-H 'Content-Type: application/json' \
|
|
342
|
+
-d '{"session_id":"u_test","reason":"I want to complain"}'
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## 8. Security Checklist
|
|
348
|
+
|
|
349
|
+
- [ ] `HH_REST_BASE_URL` must use https:// (localhost excepted)
|
|
350
|
+
- [ ] Default reject private network addresses (9.* / 10.* / 172.16-31.* / 192.168.* / 169.254.*)
|
|
351
|
+
- [ ] Auth token only from environment variables — **no hardcoding** in user_custom.py
|
|
352
|
+
- [ ] Remote exceptions do not print response bodies (may contain PII)
|
|
353
|
+
- [ ] `Authorization` / `X-Auth-Token` headers auto-redacted in logs (handled by skeleton `log_redaction`)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# human-handoff · Handoff + Queue Status Sync
|
|
2
|
+
|
|
3
|
+
> Provides semantic-triggered human handoff + queue status sync + agent connection capabilities on top of conversation-core.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python scripts/add-capability.py human-handoff
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
| Env Variable | Default | Description |
|
|
14
|
+
|:---|:---|:---|
|
|
15
|
+
| `HH_TRIGGERS` | See below | Strong trigger keywords, CSV |
|
|
16
|
+
| `HH_INTENT_KEYWORDS` | See below | Weak intent keywords, CSV |
|
|
17
|
+
| `HH_QUEUE_CAPACITY` | 50 | Queue capacity |
|
|
18
|
+
| `HH_AGENT_POOL_SIZE` | 1 | Available agent count |
|
|
19
|
+
| `HH_WAIT_PER_SLOT` | 30 | Estimated wait seconds per slot |
|
|
20
|
+
|
|
21
|
+
Default strong triggers: `talk to agent / real person / human support`
|
|
22
|
+
Default weak triggers: `complain / manager / supervisor / not working` (negative context excluded)
|
|
23
|
+
|
|
24
|
+
## REST API
|
|
25
|
+
|
|
26
|
+
| Method | Path | Purpose |
|
|
27
|
+
|:---|:---|:---|
|
|
28
|
+
| GET | `/api/v1/handoff/status` | Overall queue status |
|
|
29
|
+
| GET | `/api/v1/handoff/{session_id}` | Single session status |
|
|
30
|
+
| POST | `/api/v1/handoff/request` | Explicit handoff request |
|
|
31
|
+
| POST | `/api/v1/handoff/connect` | Simulate agent connection |
|
|
32
|
+
| POST | `/api/v1/handoff/cancel` | Cancel request |
|
|
33
|
+
|
|
34
|
+
## State Machine
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
idle ──request──▶ waiting ──connect──▶ connected
|
|
38
|
+
│ ▲ │
|
|
39
|
+
│ │ ▼
|
|
40
|
+
cancel/timeout cancel
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Integrators should subscribe to `/handoff/status` or `/handoff/{id}` in their agent system for sync push.
|
|
44
|
+
|