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
package/config.py
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
"""
|
|
2
|
+
config.py - 全局配置管理模块
|
|
3
|
+
=============================
|
|
4
|
+
集中管理所有配置项,支持从环境变量、配置文件、默认值三级加载。
|
|
5
|
+
配置文件默认路径: ~/.myagent/config.json
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
import platform
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from dataclasses import dataclass, field, asdict
|
|
15
|
+
from typing import Optional, Dict, Any, List
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# ==============================================================================
|
|
19
|
+
# 配置数据类
|
|
20
|
+
# ==============================================================================
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class LLMConfig:
|
|
24
|
+
"""LLM 大模型配置"""
|
|
25
|
+
provider: str = "openai" # openai | anthropic | ollama | custom
|
|
26
|
+
api_key: str = ""
|
|
27
|
+
base_url: str = "https://api.openai.com/v1"
|
|
28
|
+
model: str = "gpt-4"
|
|
29
|
+
temperature: float = 0.1
|
|
30
|
+
max_tokens: int = 4096
|
|
31
|
+
timeout: int = 120 # 请求超时(秒)
|
|
32
|
+
max_retries: int = 3 # 最大重试次数
|
|
33
|
+
# Anthropic 专用
|
|
34
|
+
anthropic_api_key: str = ""
|
|
35
|
+
# Ollama 专用
|
|
36
|
+
ollama_base_url: str = "http://localhost:11434"
|
|
37
|
+
ollama_model: str = "llama3"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class MemoryConfig:
|
|
42
|
+
"""记忆系统配置"""
|
|
43
|
+
db_path: str = "" # SQLite 数据库路径,默认 ~/.myagent/memory.db
|
|
44
|
+
max_short_term: int = 50 # 短期记忆最大轮数
|
|
45
|
+
max_working: int = 100 # 工作记忆最大条数
|
|
46
|
+
auto_summarize: bool = True # 自动总结开关
|
|
47
|
+
summarize_threshold: int = 20 # 触发总结的对话轮数
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass
|
|
51
|
+
class ExecutorConfig:
|
|
52
|
+
"""执行引擎配置"""
|
|
53
|
+
timeout: int = 300 # 默认执行超时(秒)
|
|
54
|
+
max_retries: int = 2 # 自动重试次数
|
|
55
|
+
auto_fix: bool = True # 自动修复错误
|
|
56
|
+
max_output_length: int = 50000 # 输出最大长度
|
|
57
|
+
execution_mode: str = "local" # 执行模式: local(本机) | sandbox(沙盒)
|
|
58
|
+
sandbox_image: str = "python:3.12-slim" # 沙盒 Docker 镜像
|
|
59
|
+
sandbox_network: bool = False # 沙盒是否允许网络
|
|
60
|
+
sandbox_memory: str = "512m" # 沙盒内存限制
|
|
61
|
+
allowed_dirs: List[str] = field(default_factory=list) # 允许访问的目录(空=全部)
|
|
62
|
+
blocked_commands: List[str] = field(default_factory=lambda: [
|
|
63
|
+
"rm -rf /", "format", "del /f /s /q C:\\", "mkfs", "dd if=/dev/zero"
|
|
64
|
+
])
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@dataclass
|
|
68
|
+
class AgentConfig:
|
|
69
|
+
"""Agent 配置"""
|
|
70
|
+
max_iterations: int = 30 # 单任务最大迭代次数
|
|
71
|
+
max_parallel: int = 3 # 最大并行任务数
|
|
72
|
+
verbose: bool = True # 详细日志
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@dataclass
|
|
76
|
+
class TrayConfig:
|
|
77
|
+
"""系统托盘配置"""
|
|
78
|
+
auto_start: bool = False # 开机自启
|
|
79
|
+
show_notifications: bool = True # 显示通知
|
|
80
|
+
icon_path: str = "" # 托盘图标路径
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass
|
|
84
|
+
class ModelEntry:
|
|
85
|
+
"""模型库中的单个模型定义"""
|
|
86
|
+
id: str = "" # 唯一标识符,如 "gpt-4o", "claude-3.5-sonnet"
|
|
87
|
+
name: str = "" # 显示名称
|
|
88
|
+
provider: str = "" # openai | anthropic | ollama | zhipu | custom
|
|
89
|
+
model: str = "" # API 调用使用的实际模型字符串
|
|
90
|
+
base_url: str = "" # 自定义 Base URL(空=使用 provider 默认值)
|
|
91
|
+
api_key: str = "" # 专用 API Key(空=使用全局默认值)
|
|
92
|
+
max_tokens: int = 4096
|
|
93
|
+
temperature: float = 0.1
|
|
94
|
+
enabled: bool = True
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@dataclass
|
|
98
|
+
class ChatPlatformConfig:
|
|
99
|
+
"""单个聊天平台配置"""
|
|
100
|
+
enabled: bool = False
|
|
101
|
+
platform: str = "" # telegram | discord | feishu | qq | wechat
|
|
102
|
+
token: str = "" # Bot Token
|
|
103
|
+
app_id: str = "" # App ID (某些平台需要)
|
|
104
|
+
app_secret: str = "" # App Secret
|
|
105
|
+
webhook_url: str = "" # Webhook URL
|
|
106
|
+
allowed_users: List[str] = field(default_factory=list) # 允许的用户白名单(空=全部)
|
|
107
|
+
extra: Dict[str, Any] = field(default_factory=dict) # 平台特有配置
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@dataclass
|
|
111
|
+
class OrganizationConfig:
|
|
112
|
+
"""组织设置配置"""
|
|
113
|
+
enabled: bool = False # 默认不启用
|
|
114
|
+
# 组织知识库管理员(agent path),只有指定的agent才能修改组织知识库
|
|
115
|
+
knowledge_admin: str = "" # 如 "default" 或 "manager"
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@dataclass
|
|
119
|
+
class CommunicationConfig:
|
|
120
|
+
"""Agent 间通信配置"""
|
|
121
|
+
enabled: bool = False # 默认不启用
|
|
122
|
+
server_url: str = "wss://aicq.online/ws" # AICQ 中继服务器
|
|
123
|
+
agent_id: str = "" # 本机 Agent ID (Ed25519 公钥,空=自动生成)
|
|
124
|
+
private_key: str = "" # 本机私钥 (Ed25519,空=自动生成)
|
|
125
|
+
max_friends: int = 200
|
|
126
|
+
auto_accept: bool = False # 自动接受好友请求
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@dataclass
|
|
130
|
+
class AppConfig:
|
|
131
|
+
"""应用总配置"""
|
|
132
|
+
llm: LLMConfig = field(default_factory=LLMConfig)
|
|
133
|
+
memory: MemoryConfig = field(default_factory=MemoryConfig)
|
|
134
|
+
executor: ExecutorConfig = field(default_factory=ExecutorConfig)
|
|
135
|
+
agent: AgentConfig = field(default_factory=AgentConfig)
|
|
136
|
+
tray: TrayConfig = field(default_factory=TrayConfig)
|
|
137
|
+
organization: OrganizationConfig = field(default_factory=OrganizationConfig)
|
|
138
|
+
communication: CommunicationConfig = field(default_factory=CommunicationConfig)
|
|
139
|
+
chat_platforms: List[ChatPlatformConfig] = field(default_factory=list)
|
|
140
|
+
models_library: List[ModelEntry] = field(default_factory=list)
|
|
141
|
+
log_level: str = "INFO"
|
|
142
|
+
data_dir: str = "" # 数据目录,默认 ~/.myagent/
|
|
143
|
+
language: str = "zh-CN"
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# ==============================================================================
|
|
147
|
+
# 配置管理器
|
|
148
|
+
# ==============================================================================
|
|
149
|
+
|
|
150
|
+
class ConfigManager:
|
|
151
|
+
"""
|
|
152
|
+
配置管理器 - 三级加载策略
|
|
153
|
+
优先级: 环境变量 > 配置文件 > 默认值
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
CONFIG_DIR_NAME = ".myagent"
|
|
157
|
+
CONFIG_FILE_NAME = "config.json"
|
|
158
|
+
|
|
159
|
+
def __init__(self):
|
|
160
|
+
self._config = AppConfig()
|
|
161
|
+
self._config_dir = Path.home() / self.CONFIG_DIR_NAME
|
|
162
|
+
self._config_file = self._config_dir / self.CONFIG_FILE_NAME
|
|
163
|
+
self._data_dir = self._config_dir
|
|
164
|
+
self._ensure_dirs()
|
|
165
|
+
|
|
166
|
+
def _ensure_dirs(self):
|
|
167
|
+
"""确保必要目录存在"""
|
|
168
|
+
self._config_dir.mkdir(parents=True, exist_ok=True)
|
|
169
|
+
(self._config_dir / "data").mkdir(exist_ok=True)
|
|
170
|
+
(self._config_dir / "logs").mkdir(exist_ok=True)
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def config(self) -> AppConfig:
|
|
174
|
+
return self._config
|
|
175
|
+
|
|
176
|
+
@property
|
|
177
|
+
def config_dir(self) -> Path:
|
|
178
|
+
return self._config_dir
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def data_dir(self) -> Path:
|
|
182
|
+
return self._data_dir / "data"
|
|
183
|
+
|
|
184
|
+
@property
|
|
185
|
+
def logs_dir(self) -> Path:
|
|
186
|
+
return self._config_dir / "logs"
|
|
187
|
+
|
|
188
|
+
def load(self) -> AppConfig:
|
|
189
|
+
"""加载配置(配置文件 + 环境变量覆盖)"""
|
|
190
|
+
self._load_from_file()
|
|
191
|
+
self._load_from_env()
|
|
192
|
+
self._apply_defaults()
|
|
193
|
+
return self._config
|
|
194
|
+
|
|
195
|
+
def save(self) -> None:
|
|
196
|
+
"""保存当前配置到文件"""
|
|
197
|
+
config_dict = self._to_dict(self._config)
|
|
198
|
+
with open(self._config_file, "w", encoding="utf-8") as f:
|
|
199
|
+
json.dump(config_dict, f, ensure_ascii=False, indent=2)
|
|
200
|
+
|
|
201
|
+
def _load_from_file(self):
|
|
202
|
+
"""从配置文件加载"""
|
|
203
|
+
if not self._config_file.exists():
|
|
204
|
+
self.save() # 创建默认配置
|
|
205
|
+
return
|
|
206
|
+
try:
|
|
207
|
+
with open(self._config_file, "r", encoding="utf-8") as f:
|
|
208
|
+
data = json.load(f)
|
|
209
|
+
self._apply_dict(self._config, data)
|
|
210
|
+
except (json.JSONDecodeError, IOError) as e:
|
|
211
|
+
print(f"[CONFIG] 配置文件读取失败,使用默认值: {e}")
|
|
212
|
+
|
|
213
|
+
def _load_from_env(self):
|
|
214
|
+
"""从环境变量加载(前缀 MYAGENT_)"""
|
|
215
|
+
env_mapping = {
|
|
216
|
+
"MYAGENT_LLM_PROVIDER": ("llm", "provider"),
|
|
217
|
+
"MYAGENT_LLM_API_KEY": ("llm", "api_key"),
|
|
218
|
+
"MYAGENT_LLM_BASE_URL": ("llm", "base_url"),
|
|
219
|
+
"MYAGENT_LLM_MODEL": ("llm", "model"),
|
|
220
|
+
"MYAGENT_LLM_TEMPERATURE": ("llm", "temperature", float),
|
|
221
|
+
"MYAGENT_LLM_MAX_TOKENS": ("llm", "max_tokens", int),
|
|
222
|
+
"MYAGENT_ANTHROPIC_API_KEY": ("llm", "anthropic_api_key"),
|
|
223
|
+
"MYAGENT_OLLAMA_BASE_URL": ("llm", "ollama_base_url"),
|
|
224
|
+
"MYAGENT_OLLAMA_MODEL": ("llm", "ollama_model"),
|
|
225
|
+
"MYAGENT_LOG_LEVEL": ("log_level", None, str),
|
|
226
|
+
"MYAGENT_LANGUAGE": ("language", None, str),
|
|
227
|
+
}
|
|
228
|
+
for env_key, mapping in env_mapping.items():
|
|
229
|
+
value = os.environ.get(env_key)
|
|
230
|
+
if value is None:
|
|
231
|
+
continue
|
|
232
|
+
if len(mapping) == 3:
|
|
233
|
+
group, attr, converter = mapping
|
|
234
|
+
elif len(mapping) == 2:
|
|
235
|
+
group, attr = mapping
|
|
236
|
+
converter = str
|
|
237
|
+
else:
|
|
238
|
+
continue
|
|
239
|
+
target = getattr(self._config, group) if group else self._config
|
|
240
|
+
try:
|
|
241
|
+
setattr(target, attr, converter(value))
|
|
242
|
+
except (ValueError, AttributeError):
|
|
243
|
+
pass
|
|
244
|
+
|
|
245
|
+
# 聊天平台 Token 从环境变量加载
|
|
246
|
+
platform_env = {
|
|
247
|
+
"MYAGENT_TELEGRAM_TOKEN": "telegram",
|
|
248
|
+
"MYAGENT_DISCORD_TOKEN": "discord",
|
|
249
|
+
"MYAGENT_FEISHU_APP_ID": "feishu",
|
|
250
|
+
"MYAGENT_FEISHU_APP_SECRET": "feishu",
|
|
251
|
+
"MYAGENT_QQ_TOKEN": "qq",
|
|
252
|
+
"MYAGENT_WECHAT_TOKEN": "wechat",
|
|
253
|
+
}
|
|
254
|
+
for env_key, platform_name in platform_env.items():
|
|
255
|
+
token = os.environ.get(env_key)
|
|
256
|
+
if token:
|
|
257
|
+
self._ensure_chat_platform(platform_name, token)
|
|
258
|
+
|
|
259
|
+
def _ensure_chat_platform(self, platform: str, token: str):
|
|
260
|
+
"""确保聊天平台配置存在"""
|
|
261
|
+
for cp in self._config.chat_platforms:
|
|
262
|
+
if cp.platform == platform:
|
|
263
|
+
cp.token = token or cp.token
|
|
264
|
+
cp.enabled = True
|
|
265
|
+
return
|
|
266
|
+
cp = ChatPlatformConfig(platform=platform, token=token, enabled=True)
|
|
267
|
+
self._config.chat_platforms.append(cp)
|
|
268
|
+
|
|
269
|
+
def _apply_defaults(self):
|
|
270
|
+
"""应用平台相关的默认值"""
|
|
271
|
+
if not self._config.memory.db_path:
|
|
272
|
+
self._config.memory.db_path = str(self.data_dir / "memory.db")
|
|
273
|
+
if not self._config.data_dir:
|
|
274
|
+
self._config.data_dir = str(self._config_dir)
|
|
275
|
+
|
|
276
|
+
# 设置 Ollama base_url
|
|
277
|
+
if self._config.llm.provider == "ollama" and not self._config.llm.base_url:
|
|
278
|
+
self._config.llm.base_url = self._config.llm.ollama_base_url
|
|
279
|
+
self._config.llm.model = self._config.llm.ollama_model
|
|
280
|
+
|
|
281
|
+
def _to_dict(self, obj) -> dict:
|
|
282
|
+
"""递归 dataclass 转 dict"""
|
|
283
|
+
if hasattr(obj, '__dataclass_fields__'):
|
|
284
|
+
return {k: self._to_dict(v) for k, v in asdict(obj).items()}
|
|
285
|
+
elif isinstance(obj, list):
|
|
286
|
+
return [self._to_dict(i) for i in obj]
|
|
287
|
+
return obj
|
|
288
|
+
|
|
289
|
+
def _apply_dict(self, target, data: dict):
|
|
290
|
+
"""递归将 dict 应用到 dataclass"""
|
|
291
|
+
for key, value in data.items():
|
|
292
|
+
if not hasattr(target, key):
|
|
293
|
+
continue
|
|
294
|
+
current = getattr(target, key)
|
|
295
|
+
if isinstance(value, dict) and hasattr(current, '__dataclass_fields__'):
|
|
296
|
+
self._apply_dict(current, value)
|
|
297
|
+
elif isinstance(value, list) and key == "chat_platforms":
|
|
298
|
+
platforms = []
|
|
299
|
+
for item in value:
|
|
300
|
+
cp = ChatPlatformConfig(**{
|
|
301
|
+
k: v for k, v in item.items() if k in ChatPlatformConfig.__dataclass_fields__
|
|
302
|
+
})
|
|
303
|
+
platforms.append(cp)
|
|
304
|
+
setattr(target, key, platforms)
|
|
305
|
+
elif isinstance(value, list) and key == "models_library":
|
|
306
|
+
models = []
|
|
307
|
+
for item in value:
|
|
308
|
+
me = ModelEntry(**{
|
|
309
|
+
k: v for k, v in item.items() if k in ModelEntry.__dataclass_fields__
|
|
310
|
+
})
|
|
311
|
+
models.append(me)
|
|
312
|
+
setattr(target, key, models)
|
|
313
|
+
elif key in getattr(type(target), '__dataclass_fields__', {}):
|
|
314
|
+
setattr(target, key, value)
|
|
315
|
+
|
|
316
|
+
def get_chat_platform(self, platform: str) -> Optional[ChatPlatformConfig]:
|
|
317
|
+
"""获取指定聊天平台配置"""
|
|
318
|
+
for cp in self._config.chat_platforms:
|
|
319
|
+
if cp.platform == platform:
|
|
320
|
+
return cp
|
|
321
|
+
return None
|
|
322
|
+
|
|
323
|
+
def get_enabled_platforms(self) -> List[ChatPlatformConfig]:
|
|
324
|
+
"""获取所有启用的聊天平台"""
|
|
325
|
+
return [cp for cp in self._config.chat_platforms if cp.enabled]
|
|
326
|
+
|
|
327
|
+
# ── 热重载 ──
|
|
328
|
+
def reload(self) -> AppConfig:
|
|
329
|
+
"""从配置文件重新加载配置(热重载,不重启服务)"""
|
|
330
|
+
old_config = self._config
|
|
331
|
+
self._config = AppConfig()
|
|
332
|
+
self._load_from_file()
|
|
333
|
+
self._load_from_env()
|
|
334
|
+
self._apply_defaults()
|
|
335
|
+
return self._config
|
|
336
|
+
|
|
337
|
+
def update_llm(self, **kwargs) -> AppConfig:
|
|
338
|
+
"""更新 LLM 配置并立即生效"""
|
|
339
|
+
for k, v in kwargs.items():
|
|
340
|
+
if hasattr(self._config.llm, k):
|
|
341
|
+
setattr(self._config.llm, k, v)
|
|
342
|
+
self.save()
|
|
343
|
+
return self._config
|
|
344
|
+
|
|
345
|
+
def update_executor(self, **kwargs) -> AppConfig:
|
|
346
|
+
"""更新执行引擎配置并立即生效"""
|
|
347
|
+
for k, v in kwargs.items():
|
|
348
|
+
if hasattr(self._config.executor, k):
|
|
349
|
+
setattr(self._config.executor, k, v)
|
|
350
|
+
self.save()
|
|
351
|
+
return self._config
|
|
352
|
+
|
|
353
|
+
# ── 导入 / 导出 ──
|
|
354
|
+
def export_config(self, include_secrets: bool = False) -> dict:
|
|
355
|
+
"""导出完整配置为字典(含备份元数据)"""
|
|
356
|
+
cfg = self._to_dict(self._config)
|
|
357
|
+
if not include_secrets:
|
|
358
|
+
# 脱敏处理
|
|
359
|
+
if 'api_key' in cfg.get('llm', {}):
|
|
360
|
+
key = cfg['llm']['api_key']
|
|
361
|
+
if key:
|
|
362
|
+
cfg['llm']['api_key'] = key[:6] + '****' + key[-4:] if len(key) > 10 else '****'
|
|
363
|
+
if 'anthropic_api_key' in cfg.get('llm', {}):
|
|
364
|
+
key = cfg['llm']['anthropic_api_key']
|
|
365
|
+
if key:
|
|
366
|
+
cfg['llm']['anthropic_api_key'] = key[:6] + '****' + key[-4:] if len(key) > 10 else '****'
|
|
367
|
+
# 脱敏聊天平台 token
|
|
368
|
+
for p in cfg.get('chat_platforms', []):
|
|
369
|
+
if p.get('token'):
|
|
370
|
+
t = p['token']
|
|
371
|
+
p['token'] = t[:6] + '****' + t[-4:] if len(t) > 10 else '****'
|
|
372
|
+
if p.get('app_secret'):
|
|
373
|
+
s = p['app_secret']
|
|
374
|
+
p['app_secret'] = s[:6] + '****' + s[-4:] if len(s) > 10 else '****'
|
|
375
|
+
|
|
376
|
+
result = {
|
|
377
|
+
'_meta': {
|
|
378
|
+
'version': '1.0',
|
|
379
|
+
'exported_at': __import__('datetime').datetime.now().isoformat(),
|
|
380
|
+
'hostname': platform.node(),
|
|
381
|
+
'include_secrets': include_secrets,
|
|
382
|
+
},
|
|
383
|
+
'config': cfg,
|
|
384
|
+
}
|
|
385
|
+
return result
|
|
386
|
+
|
|
387
|
+
def import_config(self, data: dict, overwrite: bool = False) -> dict:
|
|
388
|
+
"""
|
|
389
|
+
导入配置。
|
|
390
|
+
|
|
391
|
+
Args:
|
|
392
|
+
data: 导入的配置字典(含 _meta 和 config)
|
|
393
|
+
overwrite: 是否完全覆盖(否则合并)
|
|
394
|
+
|
|
395
|
+
Returns:
|
|
396
|
+
dict: {ok, message, changed_keys}
|
|
397
|
+
"""
|
|
398
|
+
if isinstance(data, dict) and 'config' in data:
|
|
399
|
+
cfg_data = data['config']
|
|
400
|
+
elif isinstance(data, dict):
|
|
401
|
+
cfg_data = data
|
|
402
|
+
else:
|
|
403
|
+
return {'ok': False, 'message': '无效的配置格式'}
|
|
404
|
+
|
|
405
|
+
# 验证基本结构
|
|
406
|
+
if not isinstance(cfg_data, dict):
|
|
407
|
+
return {'ok': False, 'message': '配置数据必须是字典'}
|
|
408
|
+
|
|
409
|
+
changed = []
|
|
410
|
+
if overwrite:
|
|
411
|
+
# 完全覆盖
|
|
412
|
+
self._config = AppConfig()
|
|
413
|
+
self._apply_dict(self._config, cfg_data)
|
|
414
|
+
changed = list(cfg_data.keys())
|
|
415
|
+
else:
|
|
416
|
+
# 合并模式:只覆盖有意义的字段
|
|
417
|
+
for section, fields in cfg_data.items():
|
|
418
|
+
if section.startswith('_'):
|
|
419
|
+
continue
|
|
420
|
+
current = getattr(self._config, section, None)
|
|
421
|
+
if current is None or not hasattr(current, '__dataclass_fields__'):
|
|
422
|
+
continue
|
|
423
|
+
if isinstance(fields, dict):
|
|
424
|
+
for k, v in fields.items():
|
|
425
|
+
if hasattr(current, k):
|
|
426
|
+
old_val = getattr(current, k)
|
|
427
|
+
if old_val != v:
|
|
428
|
+
setattr(current, k, v)
|
|
429
|
+
changed.append(f"{section}.{k}")
|
|
430
|
+
|
|
431
|
+
# 保存并应用默认值
|
|
432
|
+
self._apply_defaults()
|
|
433
|
+
self.save()
|
|
434
|
+
return {
|
|
435
|
+
'ok': True,
|
|
436
|
+
'message': f'配置已导入({len(changed)} 项变更)',
|
|
437
|
+
'changed_keys': changed,
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
def get_full_config(self) -> dict:
|
|
441
|
+
"""获取完整配置字典(敏感字段脱敏)"""
|
|
442
|
+
return self.export_config(include_secrets=False)
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
# ==============================================================================
|
|
446
|
+
# 全局配置实例
|
|
447
|
+
# ==============================================================================
|
|
448
|
+
|
|
449
|
+
_global_config: Optional[ConfigManager] = None
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
def get_config() -> ConfigManager:
|
|
453
|
+
"""获取全局配置管理器实例"""
|
|
454
|
+
global _global_config
|
|
455
|
+
if _global_config is None:
|
|
456
|
+
_global_config = ConfigManager()
|
|
457
|
+
_global_config.load()
|
|
458
|
+
return _global_config
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
def reset_config():
|
|
462
|
+
"""重置全局配置(测试用)"""
|
|
463
|
+
global _global_config
|
|
464
|
+
_global_config = None
|
package/core/__init__.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""
|
|
2
|
+
core/__init__.py - 核心模块初始化
|
|
3
|
+
"""
|
|
4
|
+
from core.logger import setup_logger, get_logger
|
|
5
|
+
from core.utils import (
|
|
6
|
+
timestamp, generate_id, truncate_str,
|
|
7
|
+
safe_json_parse, validate_json_schema
|
|
8
|
+
)
|
|
9
|
+
from core.llm import LLMClient, get_llm_client
|
|
10
|
+
from core.task_queue import TaskQueue, TaskItem, TaskStatus
|