myagent-ai 1.0.0
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/Dockerfile +30 -0
- package/README.md +333 -0
- package/agents/__init__.py +6 -0
- package/agents/__pycache__/main_agent.cpython-312.pyc +0 -0
- package/agents/base.py +115 -0
- package/agents/main_agent.py +695 -0
- package/agents/memory_agent.py +313 -0
- package/agents/tool_agent.py +248 -0
- package/chatbot/__init__.py +5 -0
- package/chatbot/base.py +124 -0
- package/chatbot/discord_bot.py +146 -0
- package/chatbot/feishu_bot.py +548 -0
- package/chatbot/manager.py +164 -0
- package/chatbot/qq_bot.py +189 -0
- package/chatbot/telegram_bot.py +167 -0
- package/chatbot/wechat_bot.py +558 -0
- package/communication/__init__.py +66 -0
- package/communication/channel.py +576 -0
- package/communication/crypto.py +347 -0
- package/communication/manager.py +397 -0
- package/communication/peer.py +156 -0
- package/config.py +464 -0
- package/core/__init__.py +10 -0
- package/core/config_broadcast.py +276 -0
- package/core/llm.py +878 -0
- package/core/logger.py +241 -0
- package/core/task_queue.py +362 -0
- package/core/utils.py +184 -0
- package/executor/__init__.py +4 -0
- package/executor/__pycache__/engine.cpython-312.pyc +0 -0
- package/executor/engine.py +1215 -0
- package/groups/__init__.py +15 -0
- package/groups/manager.py +724 -0
- package/knowledge/__init__.py +4 -0
- package/knowledge/rag.py +444 -0
- package/main.py +801 -0
- package/memory/__init__.py +4 -0
- package/memory/manager.py +840 -0
- package/organization/__init__.py +4 -0
- package/organization/manager.py +350 -0
- package/package.json +58 -0
- package/requirements.txt +59 -0
- package/setup.py +40 -0
- package/skills/ASR/LICENSE.txt +21 -0
- package/skills/ASR/SKILL.md +580 -0
- package/skills/ASR/scripts/asr.ts +27 -0
- package/skills/LLM/LICENSE.txt +21 -0
- package/skills/LLM/SKILL.md +856 -0
- package/skills/LLM/scripts/chat.ts +32 -0
- package/skills/TTS/LICENSE.txt +21 -0
- package/skills/TTS/SKILL.md +735 -0
- package/skills/TTS/tts.ts +25 -0
- package/skills/VLM/LICENSE.txt +21 -0
- package/skills/VLM/SKILL.md +588 -0
- package/skills/VLM/scripts/vlm.ts +57 -0
- package/skills/__init__.py +5 -0
- package/skills/agent-browser/SKILL.md +328 -0
- package/skills/ai-news-collectors/SKILL.md +157 -0
- package/skills/ai-news-collectors/_meta.json +6 -0
- package/skills/ai-news-collectors/references/sources.md +128 -0
- package/skills/aminer-open-academic/SKILL.md +312 -0
- package/skills/aminer-open-academic/_meta.json +6 -0
- package/skills/aminer-open-academic/evals/evals.json +46 -0
- package/skills/aminer-open-academic/references/api-catalog.md +1032 -0
- package/skills/aminer-open-academic/scripts/__pycache__/aminer_client.cpython-312.pyc +0 -0
- package/skills/aminer-open-academic/scripts/aminer_client.py +875 -0
- package/skills/auto-target-tracker/SKILL.md +317 -0
- package/skills/base.py +147 -0
- package/skills/blog-writer/2024-02-17-radical-transparency-sales.md +35 -0
- package/skills/blog-writer/2024-02-17-raycast-spotlight-superpowers.md +33 -0
- package/skills/blog-writer/2024-02-17-short-form-content-marketing.md +47 -0
- package/skills/blog-writer/2024-02-17-typing-speed-benefits.md +33 -0
- package/skills/blog-writer/2024-03-14-effective-ai-prompts.md +55 -0
- package/skills/blog-writer/2024-11-08-ai-revolutionizing-entry-level-sales.md +43 -0
- package/skills/blog-writer/2025-11-12-why-ai-art-is-useless.md +49 -0
- package/skills/blog-writer/README.md +2 -0
- package/skills/blog-writer/SKILL.md +158 -0
- package/skills/blog-writer/__pycache__/manage_examples.cpython-312.pyc +0 -0
- package/skills/blog-writer/_meta.json +6 -0
- package/skills/blog-writer/manage_examples.py +90 -0
- package/skills/blog-writer/style-guide.md +160 -0
- package/skills/browser_skill.py +146 -0
- package/skills/coding-agent/SKILL.md +120 -0
- package/skills/coding-agent/_meta.json +6 -0
- package/skills/coding-agent/criteria.md +48 -0
- package/skills/coding-agent/execution.md +42 -0
- package/skills/coding-agent/memory-template.md +38 -0
- package/skills/coding-agent/planning.md +31 -0
- package/skills/coding-agent/state.md +60 -0
- package/skills/coding-agent/verification.md +39 -0
- package/skills/content-strategy/SKILL.md +181 -0
- package/skills/content-strategy/_meta.json +6 -0
- package/skills/contentanalysis/ExtractWisdom/SKILL.md +229 -0
- package/skills/contentanalysis/ExtractWisdom/Workflows/Extract.md +60 -0
- package/skills/contentanalysis/SKILL.md +14 -0
- package/skills/docx/CHANGELOG.md +85 -0
- package/skills/docx/LICENSE.txt +30 -0
- package/skills/docx/SKILL.md +455 -0
- package/skills/docx/docx-js.md +681 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/docx/ooxml/scripts/__pycache__/pack.cpython-312.pyc +0 -0
- package/skills/docx/ooxml/scripts/__pycache__/unpack.cpython-312.pyc +0 -0
- package/skills/docx/ooxml/scripts/__pycache__/validate.cpython-312.pyc +0 -0
- package/skills/docx/ooxml/scripts/pack.py +159 -0
- package/skills/docx/ooxml/scripts/unpack.py +29 -0
- package/skills/docx/ooxml/scripts/validate.py +69 -0
- package/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/docx/ooxml/scripts/validation/__pycache__/__init__.cpython-312.pyc +0 -0
- package/skills/docx/ooxml/scripts/validation/__pycache__/base.cpython-312.pyc +0 -0
- package/skills/docx/ooxml/scripts/validation/__pycache__/docx.cpython-312.pyc +0 -0
- package/skills/docx/ooxml/scripts/validation/__pycache__/pptx.cpython-312.pyc +0 -0
- package/skills/docx/ooxml/scripts/validation/__pycache__/redlining.cpython-312.pyc +0 -0
- package/skills/docx/ooxml/scripts/validation/base.py +951 -0
- package/skills/docx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/docx/ooxml.md +615 -0
- package/skills/docx/scripts/__init__.py +1 -0
- package/skills/docx/scripts/__pycache__/__init__.cpython-312.pyc +0 -0
- package/skills/docx/scripts/__pycache__/add_toc_placeholders.cpython-312.pyc +0 -0
- package/skills/docx/scripts/__pycache__/document.cpython-312.pyc +0 -0
- package/skills/docx/scripts/__pycache__/utilities.cpython-312.pyc +0 -0
- package/skills/docx/scripts/add_toc_placeholders.py +220 -0
- package/skills/docx/scripts/document.py +1302 -0
- package/skills/docx/scripts/templates/comments.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/skills/docx/scripts/templates/people.xml +3 -0
- package/skills/docx/scripts/utilities.py +374 -0
- package/skills/dream-interpreter/SKILL.md +88 -0
- package/skills/dream-interpreter/assets/example_asset.txt +24 -0
- package/skills/dream-interpreter/references/api_reference.md +34 -0
- package/skills/dream-interpreter/references/interpretation-guide.md +83 -0
- package/skills/dream-interpreter/references/output-schema.md +65 -0
- package/skills/dream-interpreter/references/questioning-strategy.md +62 -0
- package/skills/dream-interpreter/references/visual-mapping.md +81 -0
- package/skills/dream-interpreter/scripts/__pycache__/example.cpython-312.pyc +0 -0
- package/skills/dream-interpreter/scripts/example.py +19 -0
- package/skills/dream-interpreter/skill.json +7 -0
- package/skills/file_skill.py +246 -0
- package/skills/finance/Finance_API_Doc.md +445 -0
- package/skills/finance/SKILL.md +53 -0
- package/skills/fullstack-dev/SKILL.md +205 -0
- package/skills/get-fortune-analysis/SKILL.md +370 -0
- package/skills/get-fortune-analysis/lunar_python.py +91 -0
- package/skills/gift-evaluator/SKILL.md +83 -0
- package/skills/gift-evaluator/__pycache__/html_tools.cpython-312.pyc +0 -0
- package/skills/gift-evaluator/html_tools.py +268 -0
- package/skills/image-edit/LICENSE.txt +21 -0
- package/skills/image-edit/SKILL.md +896 -0
- package/skills/image-edit/scripts/image-edit.ts +36 -0
- package/skills/image-generation/LICENSE.txt +21 -0
- package/skills/image-generation/SKILL.md +583 -0
- package/skills/image-generation/scripts/image-generation.ts +28 -0
- package/skills/image-understand/LICENSE.txt +21 -0
- package/skills/image-understand/SKILL.md +855 -0
- package/skills/image-understand/scripts/image-understand.ts +41 -0
- package/skills/interview-designer/README.md +70 -0
- package/skills/interview-designer/SKILL.md +53 -0
- package/skills/interview-designer/_meta.json +6 -0
- package/skills/interview-designer/references/design_rationale.md +43 -0
- package/skills/interview-designer/templates/interview_guide_template.md +62 -0
- package/skills/market-research-reports/SKILL.md +901 -0
- package/skills/market-research-reports/assets/FORMATTING_GUIDE.md +428 -0
- package/skills/market-research-reports/assets/market_report_template.tex +1380 -0
- package/skills/market-research-reports/assets/market_research.sty +564 -0
- package/skills/market-research-reports/references/data_analysis_patterns.md +548 -0
- package/skills/market-research-reports/references/report_structure_guide.md +999 -0
- package/skills/market-research-reports/references/visual_generation_guide.md +1077 -0
- package/skills/market-research-reports/scripts/__pycache__/generate_market_visuals.cpython-312.pyc +0 -0
- package/skills/market-research-reports/scripts/generate_market_visuals.py +529 -0
- package/skills/marketing-mode/README.md +49 -0
- package/skills/marketing-mode/SKILL.md +693 -0
- package/skills/marketing-mode/_meta.json +6 -0
- package/skills/marketing-mode/mode-prompt.md +39 -0
- package/skills/marketing-mode/skill.json +51 -0
- package/skills/mindfulness-meditation/SKILL.md +65 -0
- package/skills/mindfulness-meditation/_meta.json +6 -0
- package/skills/multi-search-engine/CHANGELOG.md +15 -0
- package/skills/multi-search-engine/CHANNELLOG.md +48 -0
- package/skills/multi-search-engine/SKILL.md +78 -0
- package/skills/multi-search-engine/_meta.json +6 -0
- package/skills/multi-search-engine/config.json +14 -0
- package/skills/multi-search-engine/metadata.json +7 -0
- package/skills/multi-search-engine/references/international-search.md +651 -0
- package/skills/pdf/LICENSE.txt +30 -0
- package/skills/pdf/SKILL.md +1534 -0
- package/skills/pdf/forms.md +205 -0
- package/skills/pdf/reference.md +765 -0
- package/skills/pdf/scripts/__pycache__/add_zai_metadata.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/__pycache__/check_bounding_boxes.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/__pycache__/check_bounding_boxes_test.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/__pycache__/check_fillable_fields.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/__pycache__/convert_pdf_to_images.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/__pycache__/create_validation_image.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/__pycache__/extract_form_field_info.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/__pycache__/fill_fillable_fields.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/__pycache__/fill_pdf_form_with_annotations.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/__pycache__/sanitize_code.cpython-312.pyc +0 -0
- package/skills/pdf/scripts/add_zai_metadata.py +172 -0
- package/skills/pdf/scripts/check_bounding_boxes.py +70 -0
- package/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/skills/pdf/scripts/check_fillable_fields.py +12 -0
- package/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/skills/pdf/scripts/create_validation_image.py +41 -0
- package/skills/pdf/scripts/extract_form_field_info.py +152 -0
- package/skills/pdf/scripts/fill_fillable_fields.py +114 -0
- package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/skills/pdf/scripts/sanitize_code.py +110 -0
- package/skills/podcast-generate/LICENSE.txt +21 -0
- package/skills/podcast-generate/SKILL.md +198 -0
- package/skills/podcast-generate/generate.ts +661 -0
- package/skills/podcast-generate/package.json +30 -0
- package/skills/podcast-generate/readme.md +177 -0
- package/skills/podcast-generate/test_data/segments.jsonl +3 -0
- package/skills/podcast-generate/tsconfig.json +26 -0
- package/skills/pptx/LICENSE.txt +30 -0
- package/skills/pptx/SKILL.md +507 -0
- package/skills/pptx/html2pptx.md +625 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/pptx/ooxml/scripts/__pycache__/pack.cpython-312.pyc +0 -0
- package/skills/pptx/ooxml/scripts/__pycache__/unpack.cpython-312.pyc +0 -0
- package/skills/pptx/ooxml/scripts/__pycache__/validate.cpython-312.pyc +0 -0
- package/skills/pptx/ooxml/scripts/pack.py +159 -0
- package/skills/pptx/ooxml/scripts/unpack.py +29 -0
- package/skills/pptx/ooxml/scripts/validate.py +69 -0
- package/skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/pptx/ooxml/scripts/validation/__pycache__/__init__.cpython-312.pyc +0 -0
- package/skills/pptx/ooxml/scripts/validation/__pycache__/base.cpython-312.pyc +0 -0
- package/skills/pptx/ooxml/scripts/validation/__pycache__/docx.cpython-312.pyc +0 -0
- package/skills/pptx/ooxml/scripts/validation/__pycache__/pptx.cpython-312.pyc +0 -0
- package/skills/pptx/ooxml/scripts/validation/__pycache__/redlining.cpython-312.pyc +0 -0
- package/skills/pptx/ooxml/scripts/validation/base.py +951 -0
- package/skills/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/skills/pptx/ooxml.md +427 -0
- package/skills/pptx/scripts/__pycache__/inventory.cpython-312.pyc +0 -0
- package/skills/pptx/scripts/__pycache__/inventory.cpython-313.pyc +0 -0
- package/skills/pptx/scripts/__pycache__/rearrange.cpython-312.pyc +0 -0
- package/skills/pptx/scripts/__pycache__/replace.cpython-312.pyc +0 -0
- package/skills/pptx/scripts/__pycache__/thumbnail.cpython-312.pyc +0 -0
- package/skills/pptx/scripts/html2pptx.js +1044 -0
- package/skills/pptx/scripts/inventory.py +1020 -0
- package/skills/pptx/scripts/rearrange.py +231 -0
- package/skills/pptx/scripts/replace.py +385 -0
- package/skills/pptx/scripts/thumbnail.py +450 -0
- package/skills/qingyan-research/SKILL.md +294 -0
- package/skills/qingyan-research/__pycache__/generate_html.cpython-312.pyc +0 -0
- package/skills/qingyan-research/generate_html.py +33 -0
- package/skills/registry.py +344 -0
- package/skills/search_skill.py +228 -0
- package/skills/seo-content-writer/SKILL.md +661 -0
- package/skills/seo-content-writer/_meta.json +6 -0
- package/skills/seo-content-writer/references/content-structure-templates.md +875 -0
- package/skills/seo-content-writer/references/title-formulas.md +339 -0
- package/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skill-creator/SKILL.md +485 -0
- package/skills/skill-creator/agents/analyzer.md +274 -0
- package/skills/skill-creator/agents/comparator.md +202 -0
- package/skills/skill-creator/agents/grader.md +223 -0
- package/skills/skill-creator/assets/eval_review.html +146 -0
- package/skills/skill-creator/eval-viewer/__pycache__/generate_review.cpython-312.pyc +0 -0
- package/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/skills/skill-creator/references/schemas.md +430 -0
- package/skills/skill-creator/scripts/__init__.py +0 -0
- package/skills/skill-creator/scripts/__pycache__/__init__.cpython-312.pyc +0 -0
- package/skills/skill-creator/scripts/__pycache__/aggregate_benchmark.cpython-312.pyc +0 -0
- package/skills/skill-creator/scripts/__pycache__/generate_report.cpython-312.pyc +0 -0
- package/skills/skill-creator/scripts/__pycache__/improve_description.cpython-312.pyc +0 -0
- package/skills/skill-creator/scripts/__pycache__/package_skill.cpython-312.pyc +0 -0
- package/skills/skill-creator/scripts/__pycache__/quick_validate.cpython-312.pyc +0 -0
- package/skills/skill-creator/scripts/__pycache__/run_eval.cpython-312.pyc +0 -0
- package/skills/skill-creator/scripts/__pycache__/run_loop.cpython-312.pyc +0 -0
- package/skills/skill-creator/scripts/__pycache__/utils.cpython-312.pyc +0 -0
- package/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/skills/skill-creator/scripts/generate_report.py +326 -0
- package/skills/skill-creator/scripts/improve_description.py +236 -0
- package/skills/skill-creator/scripts/package_skill.py +136 -0
- package/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/skills/skill-creator/scripts/run_eval.py +310 -0
- package/skills/skill-creator/scripts/run_loop.py +328 -0
- package/skills/skill-creator/scripts/utils.py +47 -0
- package/skills/skill-finder-cn/SKILL.md +66 -0
- package/skills/skill-finder-cn/_meta.json +6 -0
- package/skills/skill-finder-cn/package.json +5 -0
- package/skills/skill-finder-cn/scripts/search.sh +15 -0
- package/skills/skill-vetter/SKILL.md +137 -0
- package/skills/stock-analysis-skill/SKILL.md +156 -0
- package/skills/stock-analysis-skill/package.json +21 -0
- package/skills/stock-analysis-skill/src/analyzer.ts +264 -0
- package/skills/stock-analysis-skill/src/dataFetcher.ts +130 -0
- package/skills/stock-analysis-skill/src/dividend.ts +226 -0
- package/skills/stock-analysis-skill/src/index.ts +327 -0
- package/skills/stock-analysis-skill/src/rumorScanner.ts +200 -0
- package/skills/stock-analysis-skill/src/types.ts +167 -0
- package/skills/stock-analysis-skill/src/watchlist.ts +292 -0
- package/skills/stock-analysis-skill/tsconfig.json +15 -0
- package/skills/storyboard-manager/SKILL.md +532 -0
- package/skills/storyboard-manager/index.js +9 -0
- package/skills/storyboard-manager/package.json +11 -0
- package/skills/storyboard-manager/references/character_development.md +232 -0
- package/skills/storyboard-manager/references/story_structures.md +148 -0
- package/skills/storyboard-manager/scripts/__pycache__/consistency_checker.cpython-312.pyc +0 -0
- package/skills/storyboard-manager/scripts/__pycache__/timeline_tracker.cpython-312.pyc +0 -0
- package/skills/storyboard-manager/scripts/consistency_checker.py +391 -0
- package/skills/storyboard-manager/scripts/timeline_tracker.py +352 -0
- package/skills/system_skill.py +249 -0
- package/skills/ui-ux-pro-max/SKILL.md +43 -0
- package/skills/ui-ux-pro-max/_meta.json +6 -0
- package/skills/ui-ux-pro-max/assets/data/charts.csv +26 -0
- package/skills/ui-ux-pro-max/assets/data/colors.csv +97 -0
- package/skills/ui-ux-pro-max/assets/data/icons.csv +101 -0
- package/skills/ui-ux-pro-max/assets/data/landing.csv +31 -0
- package/skills/ui-ux-pro-max/assets/data/products.csv +97 -0
- package/skills/ui-ux-pro-max/assets/data/react-performance.csv +45 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/astro.csv +54 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/flutter.csv +53 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/html-tailwind.csv +56 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/jetpack-compose.csv +53 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/nextjs.csv +53 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/nuxt-ui.csv +51 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/nuxtjs.csv +59 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/react-native.csv +52 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/react.csv +54 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/shadcn.csv +61 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/svelte.csv +54 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/swiftui.csv +51 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/vue.csv +50 -0
- package/skills/ui-ux-pro-max/assets/data/styles.csv +68 -0
- package/skills/ui-ux-pro-max/assets/data/typography.csv +58 -0
- package/skills/ui-ux-pro-max/assets/data/ui-reasoning.csv +101 -0
- package/skills/ui-ux-pro-max/assets/data/ux-guidelines.csv +100 -0
- package/skills/ui-ux-pro-max/assets/data/web-interface.csv +31 -0
- package/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/skills/ui-ux-pro-max/references/upstream-README.md +488 -0
- package/skills/ui-ux-pro-max/references/upstream-skill-content.md +288 -0
- package/skills/ui-ux-pro-max/scripts/__init__.py +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/__init__.cpython-312.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-312.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-312.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/__pycache__/search.cpython-312.pyc +0 -0
- package/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/skills/ui-ux-pro-max/scripts/design_system.py +1071 -0
- package/skills/ui-ux-pro-max/scripts/search.py +111 -0
- package/skills/video-generation/LICENSE.txt +21 -0
- package/skills/video-generation/SKILL.md +1082 -0
- package/skills/video-generation/scripts/video.ts +168 -0
- package/skills/video-understand/LICENSE.txt +21 -0
- package/skills/video-understand/SKILL.md +916 -0
- package/skills/video-understand/scripts/video-understand.ts +41 -0
- package/skills/visual-design-foundations/SKILL.md +318 -0
- package/skills/visual-design-foundations/references/color-systems.md +417 -0
- package/skills/visual-design-foundations/references/spacing-iconography.md +425 -0
- package/skills/visual-design-foundations/references/typography-systems.md +432 -0
- package/skills/web-reader/LICENSE.txt +21 -0
- package/skills/web-reader/SKILL.md +1140 -0
- package/skills/web-reader/scripts/web-reader.ts +37 -0
- package/skills/web-search/LICENSE.txt +21 -0
- package/skills/web-search/SKILL.md +912 -0
- package/skills/web-search/scripts/web_search.ts +44 -0
- package/skills/web-shader-extractor/SKILL.md +145 -0
- package/skills/web-shader-extractor/references/config-extraction.md +50 -0
- package/skills/web-shader-extractor/references/encoded-definitions.md +53 -0
- package/skills/web-shader-extractor/references/extraction-workflow.md +61 -0
- package/skills/web-shader-extractor/references/porting-strategy.md +164 -0
- package/skills/web-shader-extractor/references/shader-injection.md +126 -0
- package/skills/web-shader-extractor/references/shaders-com.md +190 -0
- package/skills/web-shader-extractor/references/tech-signatures.md +54 -0
- package/skills/web-shader-extractor/references/tsl-extraction.md +41 -0
- package/skills/web-shader-extractor/references/unicorn-studio.md +353 -0
- package/skills/web-shader-extractor/scripts/fetch-rendered-dom.mjs +153 -0
- package/skills/web-shader-extractor/scripts/scan-bundle.sh +76 -0
- package/skills/writing-plans/SKILL.md +116 -0
- package/skills/writing-plans/_meta.json +6 -0
- package/skills/xlsx/LICENSE.txt +30 -0
- package/skills/xlsx/SKILL.md +496 -0
- package/skills/xlsx/__pycache__/recalc.cpython-312.pyc +0 -0
- package/skills/xlsx/recalc.py +178 -0
- package/start.sh +36 -0
- package/web/__init__.py +1 -0
- package/web/__pycache__/api_server.cpython-312.pyc +0 -0
- package/web/api_server.py +2043 -0
- package/web/ui/chat.html +3235 -0
- package/web/ui/index.html +458 -0
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
"""
|
|
2
|
+
chatbot/wechat_bot.py - 微信机器人
|
|
3
|
+
=====================================
|
|
4
|
+
微信机器人适配器。
|
|
5
|
+
|
|
6
|
+
注意: 微信没有官方的个人号第三方机器人 API。
|
|
7
|
+
本实现支持以下模式:
|
|
8
|
+
1. WxPusher (微信公众号消息推送 + 接收用户消息回调)
|
|
9
|
+
2. HTTP 桥接模式 (通过 wechaty / comwechat 等桥接)
|
|
10
|
+
3. 企业微信 Webhook (单向推送)
|
|
11
|
+
|
|
12
|
+
推荐方案:
|
|
13
|
+
- 需要双向通信: HTTP 桥接模式
|
|
14
|
+
- 只需推送: WxPusher / 企业微信 Webhook
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import asyncio
|
|
19
|
+
import json
|
|
20
|
+
import hashlib
|
|
21
|
+
import time
|
|
22
|
+
from typing import Optional, Dict, Any
|
|
23
|
+
|
|
24
|
+
from chatbot.base import BaseChatBot, ChatMessage, ChatResponse
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
import aiohttp
|
|
28
|
+
HAS_AIOHTTP = True
|
|
29
|
+
except ImportError:
|
|
30
|
+
HAS_AIOHTTP = False
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class WeChatBot(BaseChatBot):
|
|
34
|
+
"""
|
|
35
|
+
微信机器人适配器。
|
|
36
|
+
|
|
37
|
+
配置要求(根据模式不同):
|
|
38
|
+
- WxPusher 模式 (mode="wxpusher"):
|
|
39
|
+
- app_id: WxPusher 应用 Token (appToken)
|
|
40
|
+
- app_secret: WxPusher 应用 Secret (用于回调验证)
|
|
41
|
+
|
|
42
|
+
- HTTP 桥接模式 (mode="http_bridge"):
|
|
43
|
+
- token: HTTP 桥接 API 地址 (如 http://localhost:3000)
|
|
44
|
+
- extra.callback_port: 回调监听端口,默认 8100
|
|
45
|
+
- extra.callback_token: 回调验证 Token
|
|
46
|
+
|
|
47
|
+
- 企业微信 Webhook (mode="wework_webhook"):
|
|
48
|
+
- token: Webhook Key (https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx)
|
|
49
|
+
|
|
50
|
+
额外配置 (kwargs):
|
|
51
|
+
- mode: "wxpusher" | "http_bridge" | "wework_webhook"
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
platform_name = "wechat"
|
|
55
|
+
|
|
56
|
+
def __init__(self, app_id: str = "", app_secret: str = "", **kwargs):
|
|
57
|
+
super().__init__(**kwargs)
|
|
58
|
+
self.app_id = app_id
|
|
59
|
+
self.app_secret = app_secret
|
|
60
|
+
self._session: Optional[aiohttp.ClientSession] = None
|
|
61
|
+
self._mode = kwargs.get("mode", "")
|
|
62
|
+
|
|
63
|
+
# 根据配置自动选择模式
|
|
64
|
+
if not self._mode:
|
|
65
|
+
if app_id:
|
|
66
|
+
self._mode = "wxpusher"
|
|
67
|
+
elif self.token:
|
|
68
|
+
# 判断是否为企业微信 Webhook URL
|
|
69
|
+
if "qyapi.weixin.qq.com" in self.token:
|
|
70
|
+
self._mode = "wework_webhook"
|
|
71
|
+
else:
|
|
72
|
+
self._mode = "http_bridge"
|
|
73
|
+
else:
|
|
74
|
+
self._mode = "http_bridge"
|
|
75
|
+
|
|
76
|
+
# HTTP 桥接模式的回调配置
|
|
77
|
+
self._callback_port = kwargs.get("callback_port", 8100)
|
|
78
|
+
self._callback_token = kwargs.get("callback_token", "")
|
|
79
|
+
# 消息去重
|
|
80
|
+
self._processed_msg_ids: Dict[str, float] = {}
|
|
81
|
+
|
|
82
|
+
async def start(self):
|
|
83
|
+
"""启动微信机器人"""
|
|
84
|
+
if not HAS_AIOHTTP:
|
|
85
|
+
self.logger.error("请安装 aiohttp: pip install aiohttp")
|
|
86
|
+
return
|
|
87
|
+
|
|
88
|
+
self._session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=10))
|
|
89
|
+
self._running = True
|
|
90
|
+
|
|
91
|
+
if self._mode == "wxpusher":
|
|
92
|
+
await self._start_wxpusher()
|
|
93
|
+
elif self._mode == "http_bridge":
|
|
94
|
+
await self._start_http_bridge()
|
|
95
|
+
elif self._mode == "wework_webhook":
|
|
96
|
+
self.logger.info("企业微信 Webhook 模式已启动 (仅支持推送)")
|
|
97
|
+
while self._running:
|
|
98
|
+
await asyncio.sleep(1)
|
|
99
|
+
else:
|
|
100
|
+
self.logger.warning(f"未知模式: {self._mode}")
|
|
101
|
+
while self._running:
|
|
102
|
+
await asyncio.sleep(1)
|
|
103
|
+
|
|
104
|
+
async def stop(self):
|
|
105
|
+
"""停止微信机器人"""
|
|
106
|
+
self._running = False
|
|
107
|
+
if self._session:
|
|
108
|
+
await self._session.close()
|
|
109
|
+
self.logger.info("微信机器人已停止")
|
|
110
|
+
|
|
111
|
+
async def send_message(self, response: ChatResponse) -> bool:
|
|
112
|
+
"""发送消息到微信"""
|
|
113
|
+
if not self._session:
|
|
114
|
+
return False
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
if self._mode == "wxpusher":
|
|
118
|
+
return await self._send_wxpusher(response)
|
|
119
|
+
elif self._mode == "http_bridge":
|
|
120
|
+
return await self._send_http_bridge(response)
|
|
121
|
+
elif self._mode == "wework_webhook":
|
|
122
|
+
return await self._send_wework_webhook(response)
|
|
123
|
+
else:
|
|
124
|
+
self.logger.error(f"不支持的发送模式: {self._mode}")
|
|
125
|
+
return False
|
|
126
|
+
except Exception as e:
|
|
127
|
+
self.logger.error(f"微信发送消息异常: {e}")
|
|
128
|
+
return False
|
|
129
|
+
|
|
130
|
+
# ==========================================================================
|
|
131
|
+
# WxPusher 模式
|
|
132
|
+
# ==========================================================================
|
|
133
|
+
|
|
134
|
+
async def _start_wxpusher(self):
|
|
135
|
+
"""启动 WxPusher 模式(含消息接收回调服务器)"""
|
|
136
|
+
if not self.app_id:
|
|
137
|
+
self.logger.error("WxPusher 模式需要配置 app_id (appToken)")
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
self.logger.info(
|
|
141
|
+
f"微信机器人(WxPusher 模式)已启动 - AppToken: {self.app_id[:8]}..."
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# 如果配置了 app_secret,启动回调服务器接收用户消息
|
|
145
|
+
if self.app_secret:
|
|
146
|
+
asyncio.create_task(self._wxpusher_callback_server())
|
|
147
|
+
self.logger.info(f"WxPusher 回调服务器已启动: 0.0.0.0:{self._callback_port}")
|
|
148
|
+
else:
|
|
149
|
+
self.logger.warning(
|
|
150
|
+
"WxPusher 模式未配置 app_secret,无法接收用户消息。"
|
|
151
|
+
"如需双向通信,请在 WxPusher 管理后台配置回调地址。"
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
while self._running:
|
|
155
|
+
await asyncio.sleep(1)
|
|
156
|
+
|
|
157
|
+
async def _wxpusher_callback_server(self):
|
|
158
|
+
"""WxPusher 消息接收回调服务器"""
|
|
159
|
+
try:
|
|
160
|
+
from aiohttp import web
|
|
161
|
+
except ImportError:
|
|
162
|
+
self.logger.error("需要 aiohttp: pip install aiohttp")
|
|
163
|
+
return
|
|
164
|
+
|
|
165
|
+
app = web.Application()
|
|
166
|
+
app.router.add_post("/wxpusher/callback", self._handle_wxpusher_callback)
|
|
167
|
+
app.router.add_get("/wxpusher/health", self._health_check)
|
|
168
|
+
|
|
169
|
+
runner = web.AppRunner(app)
|
|
170
|
+
await runner.setup()
|
|
171
|
+
site = web.TCPSite(runner, "0.0.0.0", self._callback_port)
|
|
172
|
+
await site.start()
|
|
173
|
+
|
|
174
|
+
while self._running:
|
|
175
|
+
await asyncio.sleep(1)
|
|
176
|
+
|
|
177
|
+
async def _handle_wxpusher_callback(self, request):
|
|
178
|
+
"""处理 WxPusher 消息回调"""
|
|
179
|
+
try:
|
|
180
|
+
from aiohttp import web
|
|
181
|
+
data = await request.json()
|
|
182
|
+
|
|
183
|
+
# WxPusher 验证签名
|
|
184
|
+
signature = request.headers.get("Signature", "")
|
|
185
|
+
if signature and self.app_secret:
|
|
186
|
+
body = await request.text()
|
|
187
|
+
expected = self._wxpusher_sign(body, self.app_secret)
|
|
188
|
+
if signature != expected:
|
|
189
|
+
self.logger.warning("WxPusher 签名验证失败")
|
|
190
|
+
return web.json_response({"code": -1, "msg": "签名错误"})
|
|
191
|
+
|
|
192
|
+
action = data.get("action", "")
|
|
193
|
+
data_type = data.get("type", "")
|
|
194
|
+
|
|
195
|
+
# 验证消息(首次配置回调时的验证请求)
|
|
196
|
+
if action == "appVerify":
|
|
197
|
+
verify_token = data.get("data", {}).get("verifyToken", "")
|
|
198
|
+
if verify_token == self.app_secret:
|
|
199
|
+
return web.json_response({"code": 0, "msg": "ok"})
|
|
200
|
+
return web.json_response({"code": -1, "msg": "验证失败"})
|
|
201
|
+
|
|
202
|
+
# 处理用户消息
|
|
203
|
+
if data_type == "msg":
|
|
204
|
+
msg_data = data.get("data", {})
|
|
205
|
+
user_id = msg_data.get("from", "")
|
|
206
|
+
msg_id = msg_data.get("msgId", "")
|
|
207
|
+
content = msg_data.get("content", "")
|
|
208
|
+
|
|
209
|
+
if self._is_duplicate_msg(msg_id):
|
|
210
|
+
return web.json_response({"code": 0})
|
|
211
|
+
|
|
212
|
+
self._mark_msg_processed(msg_id)
|
|
213
|
+
|
|
214
|
+
# 消息内容解析
|
|
215
|
+
# WxPusher content 格式: {"type":"text","content":"xxx"} 或纯文本
|
|
216
|
+
if isinstance(content, str):
|
|
217
|
+
try:
|
|
218
|
+
content_obj = json.loads(content)
|
|
219
|
+
text = content_obj.get("content", content)
|
|
220
|
+
except json.JSONDecodeError:
|
|
221
|
+
text = content
|
|
222
|
+
else:
|
|
223
|
+
text = str(content)
|
|
224
|
+
|
|
225
|
+
if not text.strip():
|
|
226
|
+
return web.json_response({"code": 0})
|
|
227
|
+
|
|
228
|
+
message = ChatMessage(
|
|
229
|
+
platform=self.platform_name,
|
|
230
|
+
chat_id=f"wxpusher_{user_id}",
|
|
231
|
+
user_id=user_id,
|
|
232
|
+
username=msg_data.get("fromName", user_id),
|
|
233
|
+
text=text.strip(),
|
|
234
|
+
is_group=False,
|
|
235
|
+
raw_data={"wxpusher_data": msg_data},
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
# 异步处理消息
|
|
239
|
+
asyncio.create_task(self._handle_message(message))
|
|
240
|
+
|
|
241
|
+
return web.json_response({"code": 0, "msg": "success"})
|
|
242
|
+
|
|
243
|
+
except Exception as e:
|
|
244
|
+
self.logger.error(f"WxPusher 回调处理失败: {e}")
|
|
245
|
+
from aiohttp import web
|
|
246
|
+
return web.json_response({"code": -1, "msg": str(e)})
|
|
247
|
+
|
|
248
|
+
async def _send_wxpusher(self, response: ChatResponse) -> bool:
|
|
249
|
+
"""通过 WxPusher 发送消息"""
|
|
250
|
+
if not self.app_id:
|
|
251
|
+
return False
|
|
252
|
+
|
|
253
|
+
url = "https://wxpusher.zjiecode.com/api/send/message"
|
|
254
|
+
payload = {
|
|
255
|
+
"appToken": self.app_id,
|
|
256
|
+
"content": response.text[:5000],
|
|
257
|
+
"contentType": 1, # 1=文本, 2=HTML, 3=Markdown
|
|
258
|
+
"uids": [response.user_id] if response.user_id else [],
|
|
259
|
+
"topicIds": [],
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
# 如果是回复消息,添加引用
|
|
263
|
+
if response.reply_to:
|
|
264
|
+
payload["reference"] = {
|
|
265
|
+
"msgId": response.reply_to,
|
|
266
|
+
"type": 1,
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async with self._session.post(url, json=payload) as resp:
|
|
270
|
+
result = await resp.json()
|
|
271
|
+
if result.get("code") == 1000:
|
|
272
|
+
return True
|
|
273
|
+
self.logger.error(f"WxPusher 发送失败: {result}")
|
|
274
|
+
return False
|
|
275
|
+
|
|
276
|
+
@staticmethod
|
|
277
|
+
def _wxpusher_sign(body: str, token: str) -> str:
|
|
278
|
+
"""WxPusher 签名计算"""
|
|
279
|
+
return hashlib.sha1(f"{body}{token}".encode()).hexdigest()
|
|
280
|
+
|
|
281
|
+
# ==========================================================================
|
|
282
|
+
# HTTP 桥接模式
|
|
283
|
+
# ==========================================================================
|
|
284
|
+
|
|
285
|
+
async def _start_http_bridge(self):
|
|
286
|
+
"""启动 HTTP 桥接模式"""
|
|
287
|
+
bridge_url = self.token or ""
|
|
288
|
+
if not bridge_url:
|
|
289
|
+
self.logger.warning(
|
|
290
|
+
"HTTP 桥接模式未配置 API 地址 (token)。"
|
|
291
|
+
"请设置微信桥接服务的地址 (如 http://localhost:3000)。"
|
|
292
|
+
)
|
|
293
|
+
else:
|
|
294
|
+
self.logger.info(f"微信机器人(HTTP 桥接模式)已启动: {bridge_url}")
|
|
295
|
+
|
|
296
|
+
# 启动回调接收服务器
|
|
297
|
+
asyncio.create_task(self._bridge_callback_server())
|
|
298
|
+
|
|
299
|
+
while self._running:
|
|
300
|
+
await asyncio.sleep(1)
|
|
301
|
+
|
|
302
|
+
async def _bridge_callback_server(self):
|
|
303
|
+
"""HTTP 桥接回调服务器"""
|
|
304
|
+
try:
|
|
305
|
+
from aiohttp import web
|
|
306
|
+
except ImportError:
|
|
307
|
+
self.logger.error("需要 aiohttp: pip install aiohttp")
|
|
308
|
+
return
|
|
309
|
+
|
|
310
|
+
app = web.Application()
|
|
311
|
+
app.router.add_post("/wechat/callback", self._handle_bridge_callback)
|
|
312
|
+
app.router.add_get("/wechat/health", self._health_check)
|
|
313
|
+
|
|
314
|
+
runner = web.AppRunner(app)
|
|
315
|
+
await runner.setup()
|
|
316
|
+
site = web.TCPSite(runner, "0.0.0.0", self._callback_port)
|
|
317
|
+
await site.start()
|
|
318
|
+
self.logger.info(
|
|
319
|
+
f"微信桥接回调服务器已启动: http://0.0.0.0:{self._callback_port}/wechat/callback"
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
while self._running:
|
|
323
|
+
await asyncio.sleep(1)
|
|
324
|
+
|
|
325
|
+
async def _handle_bridge_callback(self, request):
|
|
326
|
+
"""
|
|
327
|
+
处理 HTTP 桥接回调。
|
|
328
|
+
|
|
329
|
+
兼容多种桥接协议格式:
|
|
330
|
+
- wechaty-puppet: {"from": "xxx", "to": "xxx", "text": "xxx", "room": "..."}
|
|
331
|
+
- comwechat: {"data": {"fromUser": "xxx", "toUser": "xxx", "content": "xxx"}}
|
|
332
|
+
- 通用格式: {"user_id": "xxx", "message": "xxx", "group_id": "..."}
|
|
333
|
+
"""
|
|
334
|
+
try:
|
|
335
|
+
from aiohttp import web
|
|
336
|
+
data = await request.json()
|
|
337
|
+
|
|
338
|
+
# Token 验证
|
|
339
|
+
if self._callback_token:
|
|
340
|
+
auth = request.headers.get("Authorization", "")
|
|
341
|
+
if auth != f"Bearer {self._callback_token}":
|
|
342
|
+
self.logger.warning("桥接回调 Token 验证失败")
|
|
343
|
+
return web.json_response({"code": 403})
|
|
344
|
+
|
|
345
|
+
# 尝试多种格式解析
|
|
346
|
+
message = self._parse_bridge_message(data)
|
|
347
|
+
if message and message.text.strip():
|
|
348
|
+
asyncio.create_task(self._handle_message(message))
|
|
349
|
+
|
|
350
|
+
return web.json_response({"code": 0})
|
|
351
|
+
|
|
352
|
+
except Exception as e:
|
|
353
|
+
self.logger.error(f"桥接回调处理失败: {e}")
|
|
354
|
+
from aiohttp import web
|
|
355
|
+
return web.json_response({"code": 500, "msg": str(e)})
|
|
356
|
+
|
|
357
|
+
def _parse_bridge_message(self, data: dict) -> Optional[ChatMessage]:
|
|
358
|
+
"""
|
|
359
|
+
解析桥接消息,兼容多种协议格式。
|
|
360
|
+
|
|
361
|
+
支持的格式:
|
|
362
|
+
1. wechaty: {"from": "wxid_xxx", "text": "hello", "room": "roomid"}
|
|
363
|
+
2. comwechat: {"data": {"fromUser": "wxid_xxx", "content": "hello", "isGroup": 0}}
|
|
364
|
+
3. 通用: {"user_id": "xxx", "message": "xxx", "group_id": "xxx"}
|
|
365
|
+
"""
|
|
366
|
+
text = ""
|
|
367
|
+
user_id = ""
|
|
368
|
+
chat_id = ""
|
|
369
|
+
username = ""
|
|
370
|
+
is_group = False
|
|
371
|
+
msg_id = ""
|
|
372
|
+
|
|
373
|
+
# 格式1: wechaty-puppet
|
|
374
|
+
if "from" in data and "text" in data:
|
|
375
|
+
user_id = data["from"]
|
|
376
|
+
text = data["text"]
|
|
377
|
+
room = data.get("room", "")
|
|
378
|
+
is_group = bool(room)
|
|
379
|
+
chat_id = room if room else user_id
|
|
380
|
+
username = data.get("name", data.get("from", ""))
|
|
381
|
+
msg_id = data.get("id", "")
|
|
382
|
+
|
|
383
|
+
# 格式2: comwechat
|
|
384
|
+
elif "data" in data:
|
|
385
|
+
inner = data["data"]
|
|
386
|
+
user_id = inner.get("fromUser", inner.get("fromGroup", ""))
|
|
387
|
+
text = inner.get("content", inner.get("msg", ""))
|
|
388
|
+
chat_id = inner.get("toUser", "")
|
|
389
|
+
is_group = inner.get("isGroup", 0) == 1
|
|
390
|
+
if is_group:
|
|
391
|
+
chat_id = inner.get("fromGroup", chat_id)
|
|
392
|
+
else:
|
|
393
|
+
chat_id = user_id
|
|
394
|
+
username = inner.get("fromName", user_id)
|
|
395
|
+
msg_id = inner.get("msgId", inner.get("newMsgId", ""))
|
|
396
|
+
|
|
397
|
+
# 格式3: 通用格式
|
|
398
|
+
elif "user_id" in data or "message" in data:
|
|
399
|
+
user_id = data.get("user_id", "")
|
|
400
|
+
text = data.get("message", data.get("text", data.get("content", "")))
|
|
401
|
+
chat_id = data.get("group_id", data.get("chat_id", user_id))
|
|
402
|
+
is_group = bool(data.get("group_id", ""))
|
|
403
|
+
username = data.get("username", user_id)
|
|
404
|
+
msg_id = data.get("msg_id", "")
|
|
405
|
+
|
|
406
|
+
else:
|
|
407
|
+
self.logger.debug(f"无法识别的桥接消息格式: {list(data.keys())}")
|
|
408
|
+
return None
|
|
409
|
+
|
|
410
|
+
if self._is_duplicate_msg(msg_id):
|
|
411
|
+
return None
|
|
412
|
+
self._mark_msg_processed(msg_id)
|
|
413
|
+
|
|
414
|
+
return ChatMessage(
|
|
415
|
+
platform=self.platform_name,
|
|
416
|
+
chat_id=chat_id,
|
|
417
|
+
user_id=user_id,
|
|
418
|
+
username=username,
|
|
419
|
+
text=text.strip(),
|
|
420
|
+
is_group=is_group,
|
|
421
|
+
reply_to=msg_id,
|
|
422
|
+
raw_data={"bridge_data": data},
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
async def _send_http_bridge(self, response: ChatResponse) -> bool:
|
|
426
|
+
"""通过 HTTP 桥接发送消息"""
|
|
427
|
+
if not self.token:
|
|
428
|
+
return False
|
|
429
|
+
|
|
430
|
+
base_url = self.token.rstrip("/")
|
|
431
|
+
headers = {}
|
|
432
|
+
if self._callback_token:
|
|
433
|
+
headers["Authorization"] = f"Bearer {self._callback_token}"
|
|
434
|
+
|
|
435
|
+
payload = {
|
|
436
|
+
"to": response.user_id or response.chat_id,
|
|
437
|
+
"message": response.text,
|
|
438
|
+
"type": "text",
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
# 群聊消息需要指定群
|
|
442
|
+
if hasattr(response, "metadata") and response.metadata.get("is_group"):
|
|
443
|
+
payload["room"] = response.chat_id
|
|
444
|
+
payload["to"] = response.user_id # @指定用户或空
|
|
445
|
+
|
|
446
|
+
try:
|
|
447
|
+
async with self._session.post(
|
|
448
|
+
f"{base_url}/send",
|
|
449
|
+
json=payload,
|
|
450
|
+
headers=headers,
|
|
451
|
+
) as resp:
|
|
452
|
+
if resp.status == 200:
|
|
453
|
+
result = await resp.json()
|
|
454
|
+
if result.get("code", 0) == 0 or result.get("success", True):
|
|
455
|
+
return True
|
|
456
|
+
self.logger.error(f"HTTP 桥接发送失败: {resp.status}")
|
|
457
|
+
return False
|
|
458
|
+
except Exception as e:
|
|
459
|
+
self.logger.error(f"HTTP 桥接发送异常: {e}")
|
|
460
|
+
return False
|
|
461
|
+
|
|
462
|
+
# ==========================================================================
|
|
463
|
+
# 企业微信 Webhook 模式
|
|
464
|
+
# ==========================================================================
|
|
465
|
+
|
|
466
|
+
async def _send_wework_webhook(self, response: ChatResponse) -> bool:
|
|
467
|
+
"""通过企业微信 Webhook 发送"""
|
|
468
|
+
if not self.token:
|
|
469
|
+
return False
|
|
470
|
+
|
|
471
|
+
# 支持 Webhook Key 或完整 URL
|
|
472
|
+
if self.token.startswith("http"):
|
|
473
|
+
url = self.token
|
|
474
|
+
else:
|
|
475
|
+
url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={self.token}"
|
|
476
|
+
|
|
477
|
+
# 支持 Markdown 格式
|
|
478
|
+
msg_type = "markdown" if response.parse_mode == "markdown" else "text"
|
|
479
|
+
payload: Dict[str, Any] = {
|
|
480
|
+
"msgtype": msg_type,
|
|
481
|
+
msg_type: {
|
|
482
|
+
"content": response.text[:4096],
|
|
483
|
+
},
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
# 支持提及指定人
|
|
487
|
+
if response.user_id:
|
|
488
|
+
mentioned_list = [response.user_id]
|
|
489
|
+
if msg_type == "text":
|
|
490
|
+
payload["text"]["mentioned_list"] = mentioned_list
|
|
491
|
+
|
|
492
|
+
async with self._session.post(url, json=payload) as resp:
|
|
493
|
+
result = await resp.json()
|
|
494
|
+
if result.get("errcode") == 0:
|
|
495
|
+
return True
|
|
496
|
+
self.logger.error(f"企业微信 Webhook 发送失败: {result}")
|
|
497
|
+
return False
|
|
498
|
+
|
|
499
|
+
# ==========================================================================
|
|
500
|
+
# 辅助方法
|
|
501
|
+
# ==========================================================================
|
|
502
|
+
|
|
503
|
+
async def _health_check(self, request):
|
|
504
|
+
"""健康检查端点"""
|
|
505
|
+
from aiohttp import web
|
|
506
|
+
return web.json_response({
|
|
507
|
+
"status": "ok",
|
|
508
|
+
"mode": self._mode,
|
|
509
|
+
"running": self._running,
|
|
510
|
+
})
|
|
511
|
+
|
|
512
|
+
def _is_duplicate_msg(self, msg_id: str) -> bool:
|
|
513
|
+
"""消息去重检查"""
|
|
514
|
+
if not msg_id:
|
|
515
|
+
return False
|
|
516
|
+
return msg_id in self._processed_msg_ids
|
|
517
|
+
|
|
518
|
+
def _mark_msg_processed(self, msg_id: str):
|
|
519
|
+
"""标记消息已处理"""
|
|
520
|
+
if not msg_id:
|
|
521
|
+
return
|
|
522
|
+
self._processed_msg_ids[msg_id] = time.time()
|
|
523
|
+
# 清理 5 分钟前的记录
|
|
524
|
+
now = time.time()
|
|
525
|
+
expired = [
|
|
526
|
+
mid for mid, ts in self._processed_msg_ids.items()
|
|
527
|
+
if now - ts > 300
|
|
528
|
+
]
|
|
529
|
+
for mid in expired:
|
|
530
|
+
del self._processed_msg_ids[mid]
|
|
531
|
+
|
|
532
|
+
async def send_markdown(self, response: ChatResponse) -> bool:
|
|
533
|
+
"""发送 Markdown 格式消息(WxPusher/企业微信支持)"""
|
|
534
|
+
response_copy = ChatResponse(
|
|
535
|
+
chat_id=response.chat_id,
|
|
536
|
+
user_id=response.user_id,
|
|
537
|
+
text=response.text,
|
|
538
|
+
parse_mode="markdown",
|
|
539
|
+
reply_to=response.reply_to,
|
|
540
|
+
metadata=response.metadata,
|
|
541
|
+
)
|
|
542
|
+
# WxPusher 支持内容类型 3=Markdown
|
|
543
|
+
if self._mode == "wxpusher":
|
|
544
|
+
try:
|
|
545
|
+
url = "https://wxpusher.zjiecode.com/api/send/message"
|
|
546
|
+
payload = {
|
|
547
|
+
"appToken": self.app_id,
|
|
548
|
+
"content": response.text[:5000],
|
|
549
|
+
"contentType": 3, # Markdown
|
|
550
|
+
"uids": [response.user_id] if response.user_id else [],
|
|
551
|
+
}
|
|
552
|
+
async with self._session.post(url, json=payload) as resp:
|
|
553
|
+
result = await resp.json()
|
|
554
|
+
return result.get("code") == 1000
|
|
555
|
+
except Exception as e:
|
|
556
|
+
self.logger.error(f"WxPusher Markdown 发送失败: {e}")
|
|
557
|
+
return False
|
|
558
|
+
return await self.send_message(response_copy)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""
|
|
2
|
+
communication - Agent-to-Agent Encrypted Communication Module
|
|
3
|
+
==============================================================
|
|
4
|
+
Provides end-to-end encrypted messaging between MyAgent instances using:
|
|
5
|
+
- Ed25519 for identity (signing, agent ID)
|
|
6
|
+
- X25519 for key exchange (Diffie-Hellman)
|
|
7
|
+
- AES-256-GCM for message encryption
|
|
8
|
+
- WebSocket for real-time remote messaging (AICQ relay)
|
|
9
|
+
- asyncio queues for local same-machine messaging
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from .crypto import (
|
|
13
|
+
generate_ed25519_keypair,
|
|
14
|
+
generate_agent_id,
|
|
15
|
+
generate_x25519_keypair,
|
|
16
|
+
ed25519_to_x25519_private,
|
|
17
|
+
ed25519_to_x25519_public,
|
|
18
|
+
x25519_key_exchange,
|
|
19
|
+
derive_shared_key,
|
|
20
|
+
encrypt,
|
|
21
|
+
decrypt,
|
|
22
|
+
encrypt_message,
|
|
23
|
+
decrypt_message,
|
|
24
|
+
sign,
|
|
25
|
+
verify,
|
|
26
|
+
serialize_public_key,
|
|
27
|
+
deserialize_public_key,
|
|
28
|
+
serialize_private_key,
|
|
29
|
+
deserialize_private_key,
|
|
30
|
+
_HAS_CRYPTOGRAPHY,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
from .peer import Peer, PeerStore
|
|
34
|
+
from .channel import Message, LocalChannel, RemoteChannel
|
|
35
|
+
from .manager import CommunicationManager
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
# Crypto
|
|
39
|
+
"generate_ed25519_keypair",
|
|
40
|
+
"generate_agent_id",
|
|
41
|
+
"generate_x25519_keypair",
|
|
42
|
+
"ed25519_to_x25519_private",
|
|
43
|
+
"ed25519_to_x25519_public",
|
|
44
|
+
"x25519_key_exchange",
|
|
45
|
+
"derive_shared_key",
|
|
46
|
+
"encrypt",
|
|
47
|
+
"decrypt",
|
|
48
|
+
"encrypt_message",
|
|
49
|
+
"decrypt_message",
|
|
50
|
+
"sign",
|
|
51
|
+
"verify",
|
|
52
|
+
"serialize_public_key",
|
|
53
|
+
"deserialize_public_key",
|
|
54
|
+
"serialize_private_key",
|
|
55
|
+
"deserialize_private_key",
|
|
56
|
+
"_HAS_CRYPTOGRAPHY",
|
|
57
|
+
# Peer
|
|
58
|
+
"Peer",
|
|
59
|
+
"PeerStore",
|
|
60
|
+
# Channel
|
|
61
|
+
"Message",
|
|
62
|
+
"LocalChannel",
|
|
63
|
+
"RemoteChannel",
|
|
64
|
+
# Manager
|
|
65
|
+
"CommunicationManager",
|
|
66
|
+
]
|