aria-code 0.167.0__py3-none-win_amd64.whl
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.
- aria_bots/__init__.py +7 -0
- aria_bots/channels/README.md +97 -0
- aria_bots/channels/__init__.py +1 -0
- aria_bots/channels/approvals.py +263 -0
- aria_bots/channels/conversation.py +280 -0
- aria_bots/channels/digest.py +186 -0
- aria_bots/channels/registry.py +95 -0
- aria_bots/engine.py +144 -0
- aria_bots/feishu_bot.py +1385 -0
- aria_bots/logistics/__init__.py +1 -0
- aria_bots/logistics/carriers.py +253 -0
- aria_bots/logistics/freight.py +154 -0
- aria_bots/logistics/inventory.py +242 -0
- aria_bots/logistics/mcp_server.py +156 -0
- aria_bots/logistics/records.py +119 -0
- aria_bots/logistics/tenancy.py +152 -0
- aria_bots/market.py +91 -0
- aria_bots/relay_client.py +326 -0
- aria_bots/telegram_bot.py +299 -0
- aria_code/__init__.py +111 -0
- aria_code/_bin/aria-native.exe +0 -0
- aria_code/_bin/aria-runtime.exe +0 -0
- aria_code/_version.py +20 -0
- aria_code/account_memory.py +296 -0
- aria_code/account_session.py +166 -0
- aria_code/adk_apps/__init__.py +1 -0
- aria_code/adk_apps/aria_code_review/__init__.py +1 -0
- aria_code/adk_apps/aria_code_review/agent.py +32 -0
- aria_code/adk_apps/aria_research/__init__.py +1 -0
- aria_code/adk_apps/aria_research/agent.py +31 -0
- aria_code/agents/__init__.py +49 -0
- aria_code/agents/base.py +329 -0
- aria_code/agents/code_review.py +200 -0
- aria_code/agents/deep/__init__.py +37 -0
- aria_code/agents/deep/calibration_loop.py +144 -0
- aria_code/agents/deep/critic.py +125 -0
- aria_code/agents/deep/deepen.py +193 -0
- aria_code/agents/deep/models.py +149 -0
- aria_code/agents/deep/pipeline.py +164 -0
- aria_code/agents/deep/quant_fusion.py +192 -0
- aria_code/agents/deep/themes.py +95 -0
- aria_code/agents/deep/tiers.py +106 -0
- aria_code/agents/engineering/__init__.py +14 -0
- aria_code/agents/engineering/coder.py +222 -0
- aria_code/agents/engineering/tester.py +145 -0
- aria_code/agents/financial/__init__.py +21 -0
- aria_code/agents/financial/cashflow_burn.py +119 -0
- aria_code/agents/financial/catalyst.py +279 -0
- aria_code/agents/financial/corporate_finance.py +175 -0
- aria_code/agents/financial/debate.py +224 -0
- aria_code/agents/financial/earnings.py +315 -0
- aria_code/agents/financial/fundamental.py +178 -0
- aria_code/agents/financial/macro.py +111 -0
- aria_code/agents/financial/news.py +231 -0
- aria_code/agents/financial/risk.py +146 -0
- aria_code/agents/financial/sector.py +279 -0
- aria_code/agents/financial/strategist.py +121 -0
- aria_code/agents/financial/stripe_revenue.py +127 -0
- aria_code/agents/financial/synthesis.py +274 -0
- aria_code/agents/financial/technical.py +277 -0
- aria_code/agents/orchestrator.py +44 -0
- aria_code/agents/portfolio_agent.py +392 -0
- aria_code/agents/realty/__init__.py +62 -0
- aria_code/agents/realty/asset_diagnosis.py +152 -0
- aria_code/agents/realty/business_match.py +166 -0
- aria_code/agents/realty/cashflow_verify.py +209 -0
- aria_code/agents/realty/contract_rules.py +210 -0
- aria_code/agents/realty/energy_anomaly.py +189 -0
- aria_code/agents/realty/exit_settlement.py +208 -0
- aria_code/agents/realty/fulfillment_risk.py +206 -0
- aria_code/agents/realty/ops_optimize.py +160 -0
- aria_code/agents/realty/revenue_share.py +215 -0
- aria_code/agents/registry.py +168 -0
- aria_code/agents/signal_scheme.py +111 -0
- aria_code/agents/sports/__init__.py +0 -0
- aria_code/agents/sports/football_agent.py +197 -0
- aria_code/agents/supervisor.py +113 -0
- aria_code/agents/team.py +500 -0
- aria_code/agents/video/__init__.py +16 -0
- aria_code/agents/video/director.py +376 -0
- aria_code/agents/video/qa_agent.py +143 -0
- aria_code/agents/video/script_doctor.py +112 -0
- aria_code/agents/warehouse/__init__.py +25 -0
- aria_code/agents/warehouse/contracts.py +26 -0
- aria_code/agents/warehouse/dashboard.py +155 -0
- aria_code/agents/warehouse/fulfillment_leadtime.py +95 -0
- aria_code/agents/warehouse/inbound_exceptions.py +25 -0
- aria_code/agents/warehouse/inventory_health.py +24 -0
- aria_code/agents/warehouse/local_run.py +71 -0
- aria_code/agents/warehouse/local_snapshot.py +132 -0
- aria_code/agents/warehouse/logistics_cost.py +84 -0
- aria_code/agents/warehouse/logistics_sync.py +21 -0
- aria_code/agents/warehouse/navigation.schema.json +110 -0
- aria_code/agents/warehouse/task_agent.py +172 -0
- aria_code/agents/warehouse/workflow.py +31 -0
- aria_code/aliyun_data_client.py +4 -0
- aria_code/apps/README.md +12 -0
- aria_code/apps/__init__.py +2 -0
- aria_code/apps/channels/README.md +9 -0
- aria_code/apps/channels/__init__.py +17 -0
- aria_code/apps/channels/approvals.py +11 -0
- aria_code/apps/channels/conversation.py +11 -0
- aria_code/apps/channels/digest.py +11 -0
- aria_code/apps/channels/intake.py +92 -0
- aria_code/apps/channels/registry.py +11 -0
- aria_code/apps/channels/tradingview.py +94 -0
- aria_code/apps/cli/README.md +13 -0
- aria_code/apps/cli/__init__.py +2 -0
- aria_code/apps/cli/_optional.py +120 -0
- aria_code/apps/cli/app_server.py +656 -0
- aria_code/apps/cli/auto_update.py +125 -0
- aria_code/apps/cli/bootstrap.py +206 -0
- aria_code/apps/cli/broker_render.py +206 -0
- aria_code/apps/cli/chat_turn.py +1327 -0
- aria_code/apps/cli/cloud_models.py +231 -0
- aria_code/apps/cli/codegen_paths.py +29 -0
- aria_code/apps/cli/commands/__init__.py +34 -0
- aria_code/apps/cli/commands/_business_render.py +78 -0
- aria_code/apps/cli/commands/_ui.py +71 -0
- aria_code/apps/cli/commands/analysis_cmds.py +378 -0
- aria_code/apps/cli/commands/ashare_prediction_cmds.py +327 -0
- aria_code/apps/cli/commands/auth_cmds.py +215 -0
- aria_code/apps/cli/commands/backtest_cmds.py +2518 -0
- aria_code/apps/cli/commands/broker_cmds.py +1236 -0
- aria_code/apps/cli/commands/business_workflow_cmds.py +379 -0
- aria_code/apps/cli/commands/canvas_cmds.py +77 -0
- aria_code/apps/cli/commands/catalog.py +189 -0
- aria_code/apps/cli/commands/core_cmds.py +2748 -0
- aria_code/apps/cli/commands/data_cmds.py +521 -0
- aria_code/apps/cli/commands/diagnostic_cmds.py +285 -0
- aria_code/apps/cli/commands/diagnostic_ops_cmds.py +813 -0
- aria_code/apps/cli/commands/engineering_cmds.py +399 -0
- aria_code/apps/cli/commands/file_cmds.py +312 -0
- aria_code/apps/cli/commands/finance_service_cmds.py +60 -0
- aria_code/apps/cli/commands/fx_commodity_cmds.py +123 -0
- aria_code/apps/cli/commands/market.py +544 -0
- aria_code/apps/cli/commands/market_cmds.py +1419 -0
- aria_code/apps/cli/commands/market_context.py +432 -0
- aria_code/apps/cli/commands/market_render.py +7 -0
- aria_code/apps/cli/commands/model_cmds.py +2374 -0
- aria_code/apps/cli/commands/ops_cmds.py +721 -0
- aria_code/apps/cli/commands/orchestrator_cmds.py +181 -0
- aria_code/apps/cli/commands/pdf_export_cmds.py +125 -0
- aria_code/apps/cli/commands/portfolio_cmds.py +1316 -0
- aria_code/apps/cli/commands/report.py +476 -0
- aria_code/apps/cli/commands/scaffold_templates.py +617 -0
- aria_code/apps/cli/commands/session_cmds.py +236 -0
- aria_code/apps/cli/commands/session_ux_cmds.py +359 -0
- aria_code/apps/cli/commands/team.py +723 -0
- aria_code/apps/cli/commands/team_render.py +8 -0
- aria_code/apps/cli/commands/ui_cmds.py +401 -0
- aria_code/apps/cli/commands/warehouse_cmds.py +297 -0
- aria_code/apps/cli/commands/workflow_cmds.py +629 -0
- aria_code/apps/cli/commands/workspace_cmds.py +1543 -0
- aria_code/apps/cli/config_paths.py +73 -0
- aria_code/apps/cli/config_store.py +158 -0
- aria_code/apps/cli/constants.py +88 -0
- aria_code/apps/cli/context.py +34 -0
- aria_code/apps/cli/conversation_policy.py +53 -0
- aria_code/apps/cli/deterministic.py +200 -0
- aria_code/apps/cli/direct.py +48 -0
- aria_code/apps/cli/earnings_view.py +172 -0
- aria_code/apps/cli/endpoint_migration.py +64 -0
- aria_code/apps/cli/exec_events.py +255 -0
- aria_code/apps/cli/file_references.py +155 -0
- aria_code/apps/cli/finance_service_catalog.py +111 -0
- aria_code/apps/cli/football_reports.py +231 -0
- aria_code/apps/cli/github_app_auth.py +135 -0
- aria_code/apps/cli/google_login.py +239 -0
- aria_code/apps/cli/handlers/__init__.py +11 -0
- aria_code/apps/cli/handlers/broker_handlers.py +122 -0
- aria_code/apps/cli/handlers/chart_handlers.py +1314 -0
- aria_code/apps/cli/handlers/market_handlers.py +2570 -0
- aria_code/apps/cli/handlers/realty_handlers.py +114 -0
- aria_code/apps/cli/handlers/sports_handlers.py +22 -0
- aria_code/apps/cli/handlers/strategy_advice.py +82 -0
- aria_code/apps/cli/headless.py +352 -0
- aria_code/apps/cli/helpers.py +326 -0
- aria_code/apps/cli/hooks.py +180 -0
- aria_code/apps/cli/i18n.py +310 -0
- aria_code/apps/cli/intent.py +136 -0
- aria_code/apps/cli/intent_router.py +305 -0
- aria_code/apps/cli/intent_shadow.py +72 -0
- aria_code/apps/cli/intent_signals.py +347 -0
- aria_code/apps/cli/lifecycle_hooks.py +48 -0
- aria_code/apps/cli/local_tool_schemas.py +550 -0
- aria_code/apps/cli/main.py +39 -0
- aria_code/apps/cli/market_hours.py +100 -0
- aria_code/apps/cli/market_metadata.py +135 -0
- aria_code/apps/cli/market_universe.py +487 -0
- aria_code/apps/cli/message_processing.py +310 -0
- aria_code/apps/cli/mixin_binding.py +32 -0
- aria_code/apps/cli/model_catalog.py +652 -0
- aria_code/apps/cli/model_probe.py +169 -0
- aria_code/apps/cli/model_retirement.py +65 -0
- aria_code/apps/cli/native_branding.py +12 -0
- aria_code/apps/cli/native_bridge.py +118 -0
- aria_code/apps/cli/native_entry.py +58 -0
- aria_code/apps/cli/pdf_report.py +977 -0
- aria_code/apps/cli/plan_mode.py +139 -0
- aria_code/apps/cli/plotly_html.py +15 -0
- aria_code/apps/cli/prediction_feedback.py +202 -0
- aria_code/apps/cli/preflight.py +502 -0
- aria_code/apps/cli/project_aria.py +60 -0
- aria_code/apps/cli/prompt_assembly.py +78 -0
- aria_code/apps/cli/prompts/__init__.py +0 -0
- aria_code/apps/cli/prompts/coding.py +71 -0
- aria_code/apps/cli/prompts/select.py +193 -0
- aria_code/apps/cli/prompts/system_prompts.py +562 -0
- aria_code/apps/cli/prompts/ui.py +436 -0
- aria_code/apps/cli/provider_endpoints.py +237 -0
- aria_code/apps/cli/provider_keys.py +73 -0
- aria_code/apps/cli/providers/__init__.py +1 -0
- aria_code/apps/cli/providers/base.py +775 -0
- aria_code/apps/cli/providers/chat_routing.py +139 -0
- aria_code/apps/cli/providers/collaboration.py +98 -0
- aria_code/apps/cli/providers/llm/__init__.py +1 -0
- aria_code/apps/cli/providers/llm/offline_responses.py +68 -0
- aria_code/apps/cli/providers/llm/ollama_stream.py +1574 -0
- aria_code/apps/cli/providers/llm/response_cache.py +60 -0
- aria_code/apps/cli/providers/llm/sse_stream.py +298 -0
- aria_code/apps/cli/providers/runtime_bridge.py +586 -0
- aria_code/apps/cli/providers/vertexai_stream.py +592 -0
- aria_code/apps/cli/release_download.py +159 -0
- aria_code/apps/cli/review_runner.py +111 -0
- aria_code/apps/cli/runtime_consumer.py +769 -0
- aria_code/apps/cli/sandbox.py +32 -0
- aria_code/apps/cli/session_export.py +120 -0
- aria_code/apps/cli/session_jsonl.py +208 -0
- aria_code/apps/cli/session_refresh.py +123 -0
- aria_code/apps/cli/session_store.py +125 -0
- aria_code/apps/cli/skills_catalog.py +273 -0
- aria_code/apps/cli/task_isolation.py +211 -0
- aria_code/apps/cli/terminal_chrome.py +412 -0
- aria_code/apps/cli/todo_tracker.py +190 -0
- aria_code/apps/cli/tool_executor.py +932 -0
- aria_code/apps/cli/tool_registry.py +34 -0
- aria_code/apps/cli/tool_scope.py +113 -0
- aria_code/apps/cli/tools/__init__.py +40 -0
- aria_code/apps/cli/tools/context.py +46 -0
- aria_code/apps/cli/tools/file_tools.py +181 -0
- aria_code/apps/cli/tools/market_tools.py +626 -0
- aria_code/apps/cli/tools/notebook_tools.py +111 -0
- aria_code/apps/cli/tools/system_tools.py +656 -0
- aria_code/apps/cli/tools/write_tools.py +961 -0
- aria_code/apps/cli/tradingview_bridge.py +529 -0
- aria_code/apps/cli/transactions.py +269 -0
- aria_code/apps/cli/turn_planning.py +137 -0
- aria_code/apps/cli/update_check.py +257 -0
- aria_code/apps/cli/updater.py +373 -0
- aria_code/apps/cli/utils/__init__.py +0 -0
- aria_code/apps/cli/utils/market_detect.py +1663 -0
- aria_code/apps/cli/web_login.py +136 -0
- aria_code/apps/cli/workflow_runner.py +127 -0
- aria_code/apps/cli/workspace_route.py +121 -0
- aria_code/apps/daemon/README.md +14 -0
- aria_code/apps/vscode/README.md +115 -0
- aria_code/apps/vscode/package.json +70 -0
- aria_code/aria_cli.py +5244 -0
- aria_code/aria_daemon.py +1372 -0
- aria_code/aria_feishu_bot.py +16 -0
- aria_code/aria_mcp_server.py +61 -0
- aria_code/aria_relay_client.py +4 -0
- aria_code/aria_telegram_bot.py +11 -0
- aria_code/ariarc.py +385 -0
- aria_code/artifacts.py +581 -0
- aria_code/backtest_engine.py +4 -0
- aria_code/backtest_report.py +4 -0
- aria_code/brokers/__init__.py +78 -0
- aria_code/brokers/automation.py +193 -0
- aria_code/brokers/base.py +231 -0
- aria_code/brokers/capabilities.py +264 -0
- aria_code/brokers/cn/__init__.py +10 -0
- aria_code/brokers/cn/easytrader_broker.py +193 -0
- aria_code/brokers/cn/futu_broker.py +194 -0
- aria_code/brokers/cn/longbridge_broker.py +190 -0
- aria_code/brokers/cn/tiger_broker.py +196 -0
- aria_code/brokers/cn/xtquant_broker.py +225 -0
- aria_code/brokers/config.py +414 -0
- aria_code/brokers/intl/__init__.py +5 -0
- aria_code/brokers/intl/alpaca_broker.py +183 -0
- aria_code/brokers/intl/ibkr_broker.py +215 -0
- aria_code/brokers/intl/trading212_broker.py +183 -0
- aria_code/brokers/intl/webull_broker.py +156 -0
- aria_code/brokers/paper_broker.py +266 -0
- aria_code/brokers/planning.py +296 -0
- aria_code/brokers/registry.py +213 -0
- aria_code/brokers/trading.py +267 -0
- aria_code/canva_client.py +4 -0
- aria_code/change_store.py +127 -0
- aria_code/clients/__init__.py +0 -0
- aria_code/clients/aliyun_data_client.py +660 -0
- aria_code/clients/aria_relay_client.py +16 -0
- aria_code/clients/canva_client.py +284 -0
- aria_code/clients/figma_client.py +100 -0
- aria_code/clients/football_data_client.py +1671 -0
- aria_code/clients/kling_video_client.py +182 -0
- aria_code/clients/market_data_client.py +1985 -0
- aria_code/clients/openai_image_client.py +242 -0
- aria_code/clients/runway_video_client.py +157 -0
- aria_code/clients/warehouse_erp_client.py +105 -0
- aria_code/cloud_memory.py +190 -0
- aria_code/command_safety.py +19 -0
- aria_code/computer_use_server.py +276 -0
- aria_code/computer_use_tools.py +4 -0
- aria_code/dashboard_generator.py +579 -0
- aria_code/data_analysis_tools.py +4 -0
- aria_code/data_cleaner.py +483 -0
- aria_code/data_service.py +513 -0
- aria_code/datasources/__init__.py +23 -0
- aria_code/datasources/base.py +166 -0
- aria_code/datasources/router.py +253 -0
- aria_code/datasources/sec_statements.py +217 -0
- aria_code/datasources/sources/__init__.py +15 -0
- aria_code/datasources/sources/akshare_source.py +269 -0
- aria_code/datasources/sources/alpha_vantage_source.py +203 -0
- aria_code/datasources/sources/edgar_source.py +219 -0
- aria_code/datasources/sources/finnhub_source.py +198 -0
- aria_code/datasources/sources/fred_source.py +223 -0
- aria_code/datasources/sources/tushare_source.py +143 -0
- aria_code/datasources/sources/web_scraper_source.py +278 -0
- aria_code/datasources/sources/world_bank_source.py +206 -0
- aria_code/datasources/sources/yfinance_source.py +152 -0
- aria_code/doctor.py +860 -0
- aria_code/domain/__init__.py +0 -0
- aria_code/domain/_finance_core/__init__.py +5 -0
- aria_code/domain/_finance_core/backtest_engine.py +325 -0
- aria_code/domain/_finance_core/performance_stats.py +101 -0
- aria_code/domain/backtest_engine.py +75 -0
- aria_code/domain/backtest_report.py +488 -0
- aria_code/domain/finance_formulas.py +389 -0
- aria_code/domain/performance_stats.py +6 -0
- aria_code/domain/portfolio_ledger.py +307 -0
- aria_code/domain/strategy_vault.py +421 -0
- aria_code/evals/__init__.py +37 -0
- aria_code/evals/behavior.py +113 -0
- aria_code/evals/gap.py +93 -0
- aria_code/evals/harness.py +949 -0
- aria_code/evals/review_probe.py +132 -0
- aria_code/evals/runner.py +425 -0
- aria_code/evals/scorecard.py +322 -0
- aria_code/evals/summary.py +125 -0
- aria_code/external_agent_runner.py +115 -0
- aria_code/figma_client.py +4 -0
- aria_code/file_analysis_tools.py +4 -0
- aria_code/finance_formulas.py +4 -0
- aria_code/football_data_client.py +4 -0
- aria_code/image_gen_tools.py +4 -0
- aria_code/intent_classifier.py +459 -0
- aria_code/kling_video_client.py +4 -0
- aria_code/licensing.py +151 -0
- aria_code/local_finance_tools.py +4 -0
- aria_code/local_image_provider.py +4 -0
- aria_code/local_llm_provider.py +4 -0
- aria_code/macro_tools.py +4 -0
- aria_code/markdown_pdf.py +289 -0
- aria_code/market_data_client.py +4 -0
- aria_code/mcp_client.py +744 -0
- aria_code/memory_manager.py +273 -0
- aria_code/model_capability.py +512 -0
- aria_code/notification_tools.py +4 -0
- aria_code/openai_image_client.py +4 -0
- aria_code/packages/__init__.py +26 -0
- aria_code/packages/adk_bridge/__init__.py +11 -0
- aria_code/packages/adk_bridge/code_review_tools.py +49 -0
- aria_code/packages/adk_bridge/market_tools.py +125 -0
- aria_code/packages/aria_agents/__init__.py +5 -0
- aria_code/packages/aria_agents/manifest.py +78 -0
- aria_code/packages/aria_core/__init__.py +34 -0
- aria_code/packages/aria_core/architecture.py +269 -0
- aria_code/packages/aria_core/export.py +147 -0
- aria_code/packages/aria_core/manifest.py +65 -0
- aria_code/packages/aria_core/paths.py +57 -0
- aria_code/packages/aria_core/secure_file.py +68 -0
- aria_code/packages/aria_infra/__init__.py +15 -0
- aria_code/packages/aria_infra/arthera.py +58 -0
- aria_code/packages/aria_infra/doctor.py +246 -0
- aria_code/packages/aria_infra/product.py +40 -0
- aria_code/packages/aria_mcp/__init__.py +25 -0
- aria_code/packages/aria_mcp/bridge.py +232 -0
- aria_code/packages/aria_mcp/circuit.py +82 -0
- aria_code/packages/aria_mcp/config.py +162 -0
- aria_code/packages/aria_mcp/installer.py +95 -0
- aria_code/packages/aria_mcp/server.py +1705 -0
- aria_code/packages/aria_mcp/tools.py +81 -0
- aria_code/packages/aria_sdk/__init__.py +19 -0
- aria_code/packages/aria_sdk/client.py +393 -0
- aria_code/packages/aria_sdk/providers.py +70 -0
- aria_code/packages/aria_sdk/streaming.py +75 -0
- aria_code/packages/aria_sdk/types.py +86 -0
- aria_code/packages/aria_services/__init__.py +92 -0
- aria_code/packages/aria_services/cache.py +60 -0
- aria_code/packages/aria_services/context.py +356 -0
- aria_code/packages/aria_services/context_checkpoints.py +157 -0
- aria_code/packages/aria_services/data.py +11 -0
- aria_code/packages/aria_services/provider_health.py +304 -0
- aria_code/packages/aria_services/references.py +247 -0
- aria_code/packages/aria_services/registry.py +249 -0
- aria_code/packages/aria_services/research_protocol.py +137 -0
- aria_code/packages/aria_services/research_quality.py +186 -0
- aria_code/packages/aria_services/settings.py +160 -0
- aria_code/packages/aria_services/usage.py +151 -0
- aria_code/packages/aria_skills/__init__.py +46 -0
- aria_code/packages/aria_skills/catalog.py +149 -0
- aria_code/packages/aria_skills/loader.py +455 -0
- aria_code/packages/aria_skills/registry.py +84 -0
- aria_code/packages/aria_tools/__init__.py +5 -0
- aria_code/packages/aria_tools/financial/__init__.py +5 -0
- aria_code/packages/aria_tools/financial/_paths.py +92 -0
- aria_code/packages/aria_tools/registry.py +129 -0
- aria_code/packages/quant_engine/__init__.py +33 -0
- aria_code/packages/quant_engine/_namespace.py +24 -0
- aria_code/packages/quant_engine/backtest/__init__.py +10 -0
- aria_code/packages/quant_engine/backtest/core.py +53 -0
- aria_code/packages/quant_engine/backtest/engine.py +102 -0
- aria_code/packages/quant_engine/portfolio/__init__.py +9 -0
- aria_code/packages/quant_engine/portfolio/optimizer.py +85 -0
- aria_code/packages/quant_engine/sports/__init__.py +76 -0
- aria_code/packages/quant_engine/sports/calibrator.py +354 -0
- aria_code/packages/quant_engine/sports/dixon_coles.py +234 -0
- aria_code/packages/quant_engine/sports/elo.py +300 -0
- aria_code/packages/quant_engine/sports/form.py +188 -0
- aria_code/packages/quant_engine/sports/h2h.py +195 -0
- aria_code/packages/quant_engine/sports/predictor.py +312 -0
- aria_code/packages/quant_engine/sports/tracker.py +665 -0
- aria_code/packages/quant_engine/stochastic/__init__.py +31 -0
- aria_code/packages/quant_engine/stochastic/gbm_enhanced.py +195 -0
- aria_code/packages/quant_engine/stochastic/ito_calculus.py +477 -0
- aria_code/packages/quant_engine/stochastic/kelly_criterion.py +181 -0
- aria_code/packages/quant_engine/stochastic/monte_carlo_advanced.py +95 -0
- aria_code/packages/quant_engine/stochastic/options_pricing.py +576 -0
- aria_code/packages/quant_engine/stochastic/stochastic_processes.py +90 -0
- aria_code/packs/__init__.py +85 -0
- aria_code/packs/base.py +168 -0
- aria_code/packs/finance/__init__.py +250 -0
- aria_code/packs/healthcare/__init__.py +40 -0
- aria_code/packs/logistics/__init__.py +171 -0
- aria_code/packs/payments/__init__.py +139 -0
- aria_code/packs/realty/__init__.py +190 -0
- aria_code/packs/registry.py +202 -0
- aria_code/packs/rules.py +90 -0
- aria_code/plan_utils.py +194 -0
- aria_code/plugin_loader.py +328 -0
- aria_code/portfolio_ledger.py +4 -0
- aria_code/preview_server.py +449 -0
- aria_code/privacy/__init__.py +5 -0
- aria_code/privacy/feedback.py +123 -0
- aria_code/project_review.py +278 -0
- aria_code/project_review_api.py +235 -0
- aria_code/project_review_server.py +18 -0
- aria_code/project_tools.py +4 -0
- aria_code/providers/__init__.py +30 -0
- aria_code/providers/google_video_provider.py +256 -0
- aria_code/providers/llm/__init__.py +19 -0
- aria_code/providers/llm/anthropic.py +184 -0
- aria_code/providers/llm/arthera_gateway.py +90 -0
- aria_code/providers/llm/autoconfig.py +213 -0
- aria_code/providers/llm/base.py +139 -0
- aria_code/providers/llm/custom.py +158 -0
- aria_code/providers/llm/ollama.py +137 -0
- aria_code/providers/llm/openai_compat.py +350 -0
- aria_code/providers/llm/registry.py +457 -0
- aria_code/providers/local_image_provider.py +202 -0
- aria_code/providers/local_llm_provider.py +549 -0
- aria_code/providers/ollama_models.py +79 -0
- aria_code/providers/openai_params.py +32 -0
- aria_code/providers/tool_messages.py +100 -0
- aria_code/realty_data_tools.py +4 -0
- aria_code/report_exporters.py +150 -0
- aria_code/report_generator.py +1764 -0
- aria_code/review_service.py +497 -0
- aria_code/runtime/__init__.py +176 -0
- aria_code/runtime/acceptance.py +632 -0
- aria_code/runtime/agent_loop.py +1851 -0
- aria_code/runtime/agent_profiles.py +75 -0
- aria_code/runtime/approval.py +71 -0
- aria_code/runtime/baseline.py +219 -0
- aria_code/runtime/budget.py +232 -0
- aria_code/runtime/checkpoints.py +481 -0
- aria_code/runtime/consult.py +65 -0
- aria_code/runtime/contract.py +282 -0
- aria_code/runtime/delivery.py +432 -0
- aria_code/runtime/events.py +113 -0
- aria_code/runtime/gateway.py +167 -0
- aria_code/runtime/lsp.py +484 -0
- aria_code/runtime/native_index.py +153 -0
- aria_code/runtime/orchestrator.py +55 -0
- aria_code/runtime/processes.py +343 -0
- aria_code/runtime/project_graph.py +614 -0
- aria_code/runtime/repo_map.py +712 -0
- aria_code/runtime/research_bundle.py +105 -0
- aria_code/runtime/review.py +269 -0
- aria_code/runtime/run_state.py +127 -0
- aria_code/runtime/run_store.py +522 -0
- aria_code/runtime/scoped_runs.py +113 -0
- aria_code/runtime/self_healing.py +422 -0
- aria_code/runtime/semantic_diff.py +171 -0
- aria_code/runtime/subagent.py +721 -0
- aria_code/runtime/symbol_edit.py +117 -0
- aria_code/runtime/task_brief.py +46 -0
- aria_code/runtime/task_context.py +145 -0
- aria_code/runtime/task_ledger.py +108 -0
- aria_code/runtime/task_orchestrator.py +90 -0
- aria_code/runtime/task_outcome.py +33 -0
- aria_code/runtime/task_verification.py +266 -0
- aria_code/runtime/task_worktree.py +448 -0
- aria_code/runtime/tool_executor.py +329 -0
- aria_code/runtime/tool_policy.py +107 -0
- aria_code/runtime/transactions.py +216 -0
- aria_code/runtime/windows_job.py +115 -0
- aria_code/runtime/workflows.py +222 -0
- aria_code/runtime/worktrees.py +215 -0
- aria_code/runway_video_client.py +4 -0
- aria_code/safety/__init__.py +27 -0
- aria_code/safety/client_isolation.py +178 -0
- aria_code/safety/permissions.py +339 -0
- aria_code/safety/risk.py +699 -0
- aria_code/safety/sandbox.py +148 -0
- aria_code/safety/service.py +102 -0
- aria_code/service_endpoints.py +14 -0
- aria_code/setup_wizard.py +684 -0
- aria_code/spreadsheet_tools.py +4 -0
- aria_code/strategy_vault.py +4 -0
- aria_code/tools/__init__.py +0 -0
- aria_code/tools/artifact_tools.py +252 -0
- aria_code/tools/broker_tools.py +92 -0
- aria_code/tools/build_quant_engine.py +97 -0
- aria_code/tools/code_audit_tools.py +192 -0
- aria_code/tools/computer_use_tools.py +509 -0
- aria_code/tools/data_analysis_tools.py +831 -0
- aria_code/tools/enterprise_finance_tools.py +202 -0
- aria_code/tools/extended_tools.py +240 -0
- aria_code/tools/file_analysis_tools.py +880 -0
- aria_code/tools/image_gen_tools.py +114 -0
- aria_code/tools/local_finance_tools.py +3488 -0
- aria_code/tools/logistics_carriers.py +11 -0
- aria_code/tools/logistics_inventory.py +11 -0
- aria_code/tools/logistics_io.py +11 -0
- aria_code/tools/logistics_tenancy.py +11 -0
- aria_code/tools/logistics_tools.py +11 -0
- aria_code/tools/macro_tools.py +412 -0
- aria_code/tools/notification_tools.py +249 -0
- aria_code/tools/project_tools.py +525 -0
- aria_code/tools/realty_data_tools.py +662 -0
- aria_code/tools/spreadsheet_tools.py +399 -0
- aria_code/tools/stripe_tools.py +115 -0
- aria_code/tools/video_tools.py +500 -0
- aria_code/training/__init__.py +1 -0
- aria_code/training/compare.py +117 -0
- aria_code/training/prelude_commands.py +111 -0
- aria_code/training/prelude_eval.py +390 -0
- aria_code/training/prelude_real.py +183 -0
- aria_code/training/prelude_train.py +248 -0
- aria_code/training/sft_dataset.py +230 -0
- aria_code/training/trajectory_dataset.py +263 -0
- aria_code/ui/__init__.py +105 -0
- aria_code/ui/banner.py +404 -0
- aria_code/ui/completer.py +571 -0
- aria_code/ui/console.py +285 -0
- aria_code/ui/input_box.py +505 -0
- aria_code/ui/mentions.py +206 -0
- aria_code/ui/picker.py +248 -0
- aria_code/ui/render/__init__.py +11 -0
- aria_code/ui/render/actions.py +297 -0
- aria_code/ui/render/finance.py +1732 -0
- aria_code/ui/render/market.py +253 -0
- aria_code/ui/render/output.py +954 -0
- aria_code/ui/render/responsive.py +75 -0
- aria_code/ui/render/team.py +367 -0
- aria_code/ui/robot.py +239 -0
- aria_code/ui/startup_dashboard.py +110 -0
- aria_code/video_analysis.py +147 -0
- aria_code/video_editor.py +518 -0
- aria_code/video_workflow/__init__.py +8 -0
- aria_code/video_workflow/__main__.py +61 -0
- aria_code/video_workflow/engines/__init__.py +18 -0
- aria_code/video_workflow/engines/base.py +69 -0
- aria_code/video_workflow/engines/custom_model.py +204 -0
- aria_code/video_workflow/engines/google_veo.py +94 -0
- aria_code/video_workflow/engines/local_engine.py +71 -0
- aria_code/video_workflow/engines/registry.py +98 -0
- aria_code/video_workflow/google_models.py +278 -0
- aria_code/video_workflow/music/__init__.py +5 -0
- aria_code/video_workflow/music/foley_service.py +132 -0
- aria_code/video_workflow/music/service.py +212 -0
- aria_code/video_workflow/pipeline.py +620 -0
- aria_code/video_workflow/plan.py +202 -0
- aria_code/video_workflow/session.py +297 -0
- aria_code/workspace/__init__.py +6 -0
- aria_code/workspace/files.py +219 -0
- aria_code/workspace/verify.py +167 -0
- aria_code/workspace_changes.py +199 -0
- aria_code/workspace_service.py +196 -0
- aria_code/workspace_tools.py +150 -0
- aria_code-0.167.0.dist-info/METADATA +330 -0
- aria_code-0.167.0.dist-info/RECORD +601 -0
- aria_code-0.167.0.dist-info/WHEEL +5 -0
- aria_code-0.167.0.dist-info/entry_points.txt +5 -0
- aria_code-0.167.0.dist-info/licenses/LICENSE +201 -0
- aria_code-0.167.0.dist-info/licenses/NOTICE +49 -0
- aria_code-0.167.0.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"""
|
|
2
|
+
agents/realty/ops_optimize.py — 运营提升 Agent
|
|
3
|
+
===============================================
|
|
4
|
+
分析坪效、客流、商品排行、活动效果,提出经营优化建议。
|
|
5
|
+
|
|
6
|
+
输入数据(data dict keys):
|
|
7
|
+
project_info — 项目基本信息(面积/业态/开业时间)
|
|
8
|
+
performance_data — 经营绩效数据(坪效/客流/流水趋势/商品排行)
|
|
9
|
+
marketing_data — 营销活动数据(会员/优惠券/外卖/团购)
|
|
10
|
+
peer_benchmarks — 同业基准数据(可选)
|
|
11
|
+
|
|
12
|
+
输出:
|
|
13
|
+
analysis — 运营优化建议
|
|
14
|
+
signal — GOOD=经营健康/高潜力 / WATCH=有改善空间 / CONCERN=经营不佳 / SEVERE=急需干预
|
|
15
|
+
(地产健康度尺度,见 signal_scheme.py)
|
|
16
|
+
key_points — Top3 优化建议
|
|
17
|
+
"""
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
from typing import Any, Dict, List
|
|
21
|
+
from ..base import BaseAgent, AgentResult
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class OpsOptimizeAgent(BaseAgent):
|
|
25
|
+
name = "ops_optimize"
|
|
26
|
+
description = "运营提升:分析坪效/客流/营销效果,提出招商补位和经营优化建议"
|
|
27
|
+
|
|
28
|
+
_SYSTEM = (
|
|
29
|
+
"你是一名资深的商业空间运营顾问,专注于帮助经营方提升业绩。\n"
|
|
30
|
+
"请基于以下经营数据给出针对性的优化建议:\n"
|
|
31
|
+
" 1. 坪效分析(当前坪效 vs 行业基准,提升空间)\n"
|
|
32
|
+
" 2. 客流优化(高峰时段利用率、低谷期激活策略)\n"
|
|
33
|
+
" 3. 商品/品类优化(畅销/滞销商品,品类结构调整)\n"
|
|
34
|
+
" 4. 营销活动效果评估(会员召回、优惠券核销率、外卖占比)\n"
|
|
35
|
+
" 5. 营业时间优化建议\n"
|
|
36
|
+
" 6. 招商补位建议(空置面积是否可引入互补业态)\n"
|
|
37
|
+
" 7. 优先级最高的3项具体可执行建议(含预期效果)"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
async def analyze(self, symbol: str, data: Dict[str, Any]) -> AgentResult:
|
|
41
|
+
project = data.get("project_info", {})
|
|
42
|
+
perf = data.get("performance_data", {})
|
|
43
|
+
marketing= data.get("marketing_data", {})
|
|
44
|
+
bench = data.get("peer_benchmarks", {})
|
|
45
|
+
|
|
46
|
+
metrics = _calc_metrics(project, perf, marketing, bench)
|
|
47
|
+
|
|
48
|
+
user_prompt = (
|
|
49
|
+
f"项目信息:{project.get('name','未命名')} "
|
|
50
|
+
f"({project.get('area',0)}m² {project.get('business_type','未知业态')})\n"
|
|
51
|
+
f"开业: {project.get('open_date','未知')}\n\n"
|
|
52
|
+
f"经营绩效:\n"
|
|
53
|
+
f" 月均流水: {perf.get('monthly_revenue',0):,.2f}元\n"
|
|
54
|
+
f" 坪效: {metrics['revenue_per_sqm']:.1f}元/m²/月 行业基准: {bench.get('revenue_per_sqm',300):.1f}\n"
|
|
55
|
+
f" 日均客流: {perf.get('daily_visits',0):.0f}人次 转化率: {metrics['conversion_rate']:.1%}\n"
|
|
56
|
+
f" 会员复购率: {marketing.get('member_repurchase_pct',0):.1f}%\n"
|
|
57
|
+
f" 外卖收入占比: {metrics['delivery_pct']:.1f}%\n"
|
|
58
|
+
f" 优惠券核销率: {marketing.get('coupon_redemption_pct',0):.1f}%\n\n"
|
|
59
|
+
f"Top10商品: {perf.get('top_products', [])[:5]}\n"
|
|
60
|
+
f"垫底商品: {perf.get('bottom_products', [])[:3]}\n\n"
|
|
61
|
+
"请给出运营优化建议。"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
analysis = await self._call_llm(self._SYSTEM, user_prompt, max_tokens=700)
|
|
65
|
+
if not analysis:
|
|
66
|
+
analysis = _template_ops(metrics, perf, marketing, bench)
|
|
67
|
+
|
|
68
|
+
signal = _ops_signal(metrics, bench)
|
|
69
|
+
confidence = _ops_confidence(perf, marketing)
|
|
70
|
+
key_points = _ops_key_points(metrics, perf, marketing, bench)
|
|
71
|
+
|
|
72
|
+
return AgentResult(
|
|
73
|
+
agent = self.name,
|
|
74
|
+
symbol = symbol,
|
|
75
|
+
analysis = analysis,
|
|
76
|
+
confidence = confidence,
|
|
77
|
+
signal = signal,
|
|
78
|
+
key_points = key_points,
|
|
79
|
+
data_used = {"metrics": metrics},
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# ── 辅助逻辑 ──────────────────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
def _calc_metrics(project: Dict, perf: Dict, marketing: Dict, bench: Dict) -> Dict:
|
|
86
|
+
area = project.get("area", 1)
|
|
87
|
+
revenue = perf.get("monthly_revenue", 0)
|
|
88
|
+
visits = perf.get("daily_visits", 0) * 30
|
|
89
|
+
orders = perf.get("monthly_orders", 0)
|
|
90
|
+
delivery = marketing.get("delivery_revenue", 0)
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
"revenue_per_sqm": revenue / area if area else 0,
|
|
94
|
+
"conversion_rate": orders / visits if visits else 0,
|
|
95
|
+
"delivery_pct": delivery / revenue * 100 if revenue else 0,
|
|
96
|
+
"bench_psm": bench.get("revenue_per_sqm", 300),
|
|
97
|
+
"psm_gap_pct": (revenue / area - bench.get("revenue_per_sqm", 300))
|
|
98
|
+
/ bench.get("revenue_per_sqm", 300) * 100 if area else 0,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _ops_signal(metrics: Dict, bench: Dict) -> str:
|
|
103
|
+
psm = metrics.get("revenue_per_sqm", 0)
|
|
104
|
+
bench_psm = metrics.get("bench_psm", 300)
|
|
105
|
+
if bench_psm <= 0: return "WATCH"
|
|
106
|
+
ratio = psm / bench_psm
|
|
107
|
+
if ratio >= 1.2: return "GOOD"
|
|
108
|
+
if ratio >= 0.8: return "WATCH"
|
|
109
|
+
if ratio >= 0.5: return "CONCERN"
|
|
110
|
+
return "SEVERE"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _ops_confidence(perf: Dict, marketing: Dict) -> float:
|
|
114
|
+
has = sum([
|
|
115
|
+
1 if perf.get("monthly_revenue") else 0,
|
|
116
|
+
1 if perf.get("daily_visits") else 0,
|
|
117
|
+
1 if marketing.get("member_count") else 0,
|
|
118
|
+
1 if perf.get("top_products") else 0,
|
|
119
|
+
])
|
|
120
|
+
return round(0.5 + 0.1 * has, 2)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _ops_key_points(metrics: Dict, perf: Dict, marketing: Dict, bench: Dict) -> List[str]:
|
|
124
|
+
pts = []
|
|
125
|
+
psm = metrics.get("revenue_per_sqm", 0)
|
|
126
|
+
bench_psm = metrics.get("bench_psm", 300)
|
|
127
|
+
|
|
128
|
+
pts.append(f"坪效: {psm:.1f}元/m²/月 行业基准: {bench_psm:.1f} 差距: {metrics['psm_gap_pct']:+.1f}%")
|
|
129
|
+
pts.append(f"转化率: {metrics['conversion_rate']:.1%} 外卖占比: {metrics['delivery_pct']:.1f}%")
|
|
130
|
+
|
|
131
|
+
if psm < bench_psm * 0.7:
|
|
132
|
+
pts.append("坪效显著低于基准,建议重新评估业态或开展营销活动")
|
|
133
|
+
if marketing.get("coupon_redemption_pct", 50) < 20:
|
|
134
|
+
pts.append("优惠券核销率低,营销触达效果需改善")
|
|
135
|
+
if marketing.get("member_repurchase_pct", 0) < 30:
|
|
136
|
+
pts.append("会员复购率偏低,建议加强会员运营和精准推送")
|
|
137
|
+
return pts[:5]
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def _template_ops(metrics: Dict, perf: Dict, marketing: Dict, bench: Dict) -> str:
|
|
141
|
+
psm = metrics.get("revenue_per_sqm", 0)
|
|
142
|
+
bench_psm = metrics.get("bench_psm", 300)
|
|
143
|
+
gap = metrics.get("psm_gap_pct", 0)
|
|
144
|
+
|
|
145
|
+
recs = []
|
|
146
|
+
if psm < bench_psm:
|
|
147
|
+
recs.append("1. 引入高客单价品类或体验型业态,提升坪效")
|
|
148
|
+
if metrics.get("delivery_pct", 0) < 20:
|
|
149
|
+
recs.append("2. 开通美团/饿了么外卖渠道,提高营业时段覆盖")
|
|
150
|
+
if marketing.get("member_count", 0) < 500:
|
|
151
|
+
recs.append("3. 启动会员招募计划,目标500+活跃会员")
|
|
152
|
+
recs.append("4. 分析低峰时段,设计限时优惠活动激活非高峰客流")
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
f"运营提升建议(模板):\n"
|
|
156
|
+
f" 坪效: {psm:.1f}元/m²/月({'+' if gap >= 0 else ''}{gap:.1f}% vs 行业)\n"
|
|
157
|
+
f" 转化率: {metrics['conversion_rate']:.1%} 外卖占比: {metrics['delivery_pct']:.1f}%\n\n"
|
|
158
|
+
f"优化建议:\n"
|
|
159
|
+
+ "\n".join(f" {r}" for r in recs)
|
|
160
|
+
)
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"""
|
|
2
|
+
agents/realty/revenue_share.py — 分账规则 Agent
|
|
3
|
+
================================================
|
|
4
|
+
根据合同规则和实际流水,计算各方收益并生成分账配置建议。
|
|
5
|
+
|
|
6
|
+
输入数据(data dict keys):
|
|
7
|
+
contract_rules — 合同规则(保底/分润比例/阶梯/服务费/风险准备金等)
|
|
8
|
+
transaction_data — 本期实际流水数据(总流水/支付渠道明细/退款等)
|
|
9
|
+
accounts — 各方收款账户信息(可选,用于分账配置验证)
|
|
10
|
+
|
|
11
|
+
输出:
|
|
12
|
+
analysis — 分账计算说明文本
|
|
13
|
+
signal — GOOD=分账正常 / WATCH=有补足情况 / CONCERN=流水勉强覆盖 / SEVERE=流水严重不足
|
|
14
|
+
(地产健康度尺度,见 signal_scheme.py)
|
|
15
|
+
key_points — 各方金额摘要
|
|
16
|
+
data_used — 包含 split_result(可直接入库)
|
|
17
|
+
"""
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
from decimal import Decimal, ROUND_HALF_UP
|
|
21
|
+
from typing import Any, Dict, List
|
|
22
|
+
from ..base import BaseAgent, AgentResult
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RevenueShareAgent(BaseAgent):
|
|
26
|
+
name = "revenue_share"
|
|
27
|
+
description = "分账规则:根据合同和实际流水计算各方应得金额,生成分账配置建议"
|
|
28
|
+
|
|
29
|
+
_SYSTEM = (
|
|
30
|
+
"你是一名分账与财务核算专家,专注于不动产经营权共创模式下的收益分配。\n"
|
|
31
|
+
"请对分账计算结果进行解读和说明:\n"
|
|
32
|
+
" 1. 说明本期各方应得金额的计算过程(分润基数→分润金额→保底补足→扣除项)\n"
|
|
33
|
+
" 2. 分析流水与保底的差距,判断经营状态(正常/偏低/严重不足)\n"
|
|
34
|
+
" 3. 如有阶梯分成被触发,解释阶梯规则的执行情况\n"
|
|
35
|
+
" 4. 给出本期结算的注意事项或风险提示\n"
|
|
36
|
+
" 5. 对下期经营给出1-2条改善建议"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
async def analyze(self, symbol: str, data: Dict[str, Any]) -> AgentResult:
|
|
40
|
+
rules = data.get("contract_rules", {})
|
|
41
|
+
txn = data.get("transaction_data", {})
|
|
42
|
+
accts = data.get("accounts", {})
|
|
43
|
+
|
|
44
|
+
split = _calculate_split(rules, txn)
|
|
45
|
+
|
|
46
|
+
user_prompt = (
|
|
47
|
+
f"本期分账计算结果:\n"
|
|
48
|
+
f" 实际总流水: {split['gross_revenue']:,.2f}元\n"
|
|
49
|
+
f" 参与分润流水: {split['net_revenue']:,.2f}元\n"
|
|
50
|
+
f" 保底金额: {split['guaranteed']:,.2f}元\n"
|
|
51
|
+
f" 分润比例: {split['share_pct']}%\n"
|
|
52
|
+
f" 资产方分润金额: {split['owner_share']:,.2f}元\n"
|
|
53
|
+
f" 保底补足金额: {split['top_up']:,.2f}元(需经营方补缴)\n"
|
|
54
|
+
f" 资产方实得: {split['owner_total']:,.2f}元\n"
|
|
55
|
+
f" 平台服务费: {split['platform_fee']:,.2f}元\n"
|
|
56
|
+
f" 风险准备金: {split['risk_reserve']:,.2f}元\n"
|
|
57
|
+
f" 经营方实得: {split['operator_net']:,.2f}元\n"
|
|
58
|
+
f" 结算周期: {rules.get('settlement_cycle','月结')}\n\n"
|
|
59
|
+
f"合同规则: 保底{rules.get('guaranteed_monthly',0):,}元/月, "
|
|
60
|
+
f"流水分润{rules.get('revenue_share_pct',0)}%, "
|
|
61
|
+
f"平台{rules.get('platform_fee_pct',5)}%, "
|
|
62
|
+
f"风险准备金{rules.get('risk_reserve_pct',3)}%\n\n"
|
|
63
|
+
"请对以上分账结果进行解读和说明。"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
analysis = await self._call_llm(self._SYSTEM, user_prompt, max_tokens=600)
|
|
67
|
+
if not analysis:
|
|
68
|
+
analysis = _template_split_analysis(split, rules)
|
|
69
|
+
|
|
70
|
+
signal = _split_signal(split)
|
|
71
|
+
confidence = 0.95 # 分账计算是确定性逻辑,置信度高
|
|
72
|
+
key_points = _split_key_points(split)
|
|
73
|
+
|
|
74
|
+
return AgentResult(
|
|
75
|
+
agent = self.name,
|
|
76
|
+
symbol = symbol,
|
|
77
|
+
analysis = analysis,
|
|
78
|
+
confidence = confidence,
|
|
79
|
+
signal = signal,
|
|
80
|
+
key_points = key_points,
|
|
81
|
+
data_used = {"split_result": split, "contract_rules": rules},
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# ── 核心计算逻辑(Decimal精度) ────────────────────────────────────────────────
|
|
86
|
+
|
|
87
|
+
def _calculate_split(rules: Dict, txn: Dict) -> Dict:
|
|
88
|
+
"""
|
|
89
|
+
分账计算(精确到分)
|
|
90
|
+
|
|
91
|
+
分配顺序:
|
|
92
|
+
1. 从总流水中扣除: 平台服务费 + 风险准备金 + 退款
|
|
93
|
+
2. 剩余净流水 vs 分润基数 → 计算资产方分润
|
|
94
|
+
3. 资产方分润 vs 保底 → 计算保底补足
|
|
95
|
+
4. 经营方实得 = 净流水 - 资产方总收益 - 平台费 - 风险准备金
|
|
96
|
+
"""
|
|
97
|
+
D = Decimal
|
|
98
|
+
|
|
99
|
+
gross = D(str(txn.get("gross_revenue", 0)))
|
|
100
|
+
refunds = D(str(txn.get("refunds", 0)))
|
|
101
|
+
guaranteed = D(str(rules.get("guaranteed_monthly", 0)))
|
|
102
|
+
share_pct = D(str(rules.get("revenue_share_pct", 0))) / D("100")
|
|
103
|
+
base_revenue = D(str(rules.get("revenue_share_base", 0)))
|
|
104
|
+
platform_pct = D(str(rules.get("platform_fee_pct", 5))) / D("100")
|
|
105
|
+
reserve_pct = D(str(rules.get("risk_reserve_pct", 3))) / D("100")
|
|
106
|
+
|
|
107
|
+
# 各扣除项
|
|
108
|
+
net_revenue = gross - refunds
|
|
109
|
+
platform_fee = (net_revenue * platform_pct).quantize(D("0.01"), ROUND_HALF_UP)
|
|
110
|
+
risk_reserve = (net_revenue * reserve_pct).quantize(D("0.01"), ROUND_HALF_UP)
|
|
111
|
+
distributable = net_revenue - platform_fee - risk_reserve
|
|
112
|
+
|
|
113
|
+
# 资产方分润(超出分润基数部分 * 分润比例)
|
|
114
|
+
shareable_revenue = max(D("0"), distributable - base_revenue)
|
|
115
|
+
owner_share = (shareable_revenue * share_pct).quantize(D("0.01"), ROUND_HALF_UP)
|
|
116
|
+
|
|
117
|
+
# 保底补足(若分润不足保底,经营方须补足)
|
|
118
|
+
top_up = max(D("0"), guaranteed - owner_share)
|
|
119
|
+
|
|
120
|
+
owner_total = owner_share + top_up
|
|
121
|
+
operator_net = distributable - owner_total
|
|
122
|
+
|
|
123
|
+
# 阶梯分成(如有)
|
|
124
|
+
tiered_triggered = _apply_tiered(rules.get("tiered_rules", []), net_revenue)
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
"gross_revenue": float(gross),
|
|
128
|
+
"refunds": float(refunds),
|
|
129
|
+
"net_revenue": float(net_revenue),
|
|
130
|
+
"platform_fee": float(platform_fee),
|
|
131
|
+
"risk_reserve": float(risk_reserve),
|
|
132
|
+
"distributable": float(distributable),
|
|
133
|
+
"guaranteed": float(guaranteed),
|
|
134
|
+
"share_pct": float(rules.get("revenue_share_pct", 0)),
|
|
135
|
+
"owner_share": float(owner_share),
|
|
136
|
+
"top_up": float(top_up),
|
|
137
|
+
"owner_total": float(owner_total),
|
|
138
|
+
"operator_net": float(operator_net),
|
|
139
|
+
"tiered_triggered": tiered_triggered,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _apply_tiered(tiered_rules: List[Dict], revenue: Decimal) -> List[Dict]:
|
|
144
|
+
"""计算触发的阶梯分成规则"""
|
|
145
|
+
triggered = []
|
|
146
|
+
for rule in tiered_rules:
|
|
147
|
+
threshold = Decimal(str(rule.get("threshold", 0)))
|
|
148
|
+
pct = rule.get("pct", 0)
|
|
149
|
+
if revenue >= threshold:
|
|
150
|
+
triggered.append({"threshold": float(threshold), "pct": pct,
|
|
151
|
+
"status": "triggered"})
|
|
152
|
+
else:
|
|
153
|
+
triggered.append({"threshold": float(threshold), "pct": pct,
|
|
154
|
+
"status": "not_triggered"})
|
|
155
|
+
return triggered
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _split_signal(split: Dict) -> str:
|
|
159
|
+
net = split.get("net_revenue", 0)
|
|
160
|
+
guaranteed = split.get("guaranteed", 0)
|
|
161
|
+
op_net = split.get("operator_net", 0)
|
|
162
|
+
|
|
163
|
+
if guaranteed <= 0: return "WATCH"
|
|
164
|
+
coverage = net / guaranteed if guaranteed else 0
|
|
165
|
+
if coverage >= 2.0 and op_net > 0: return "GOOD"
|
|
166
|
+
if coverage >= 1.0 and op_net > 0: return "WATCH"
|
|
167
|
+
if op_net > 0 and coverage >= 0.5: return "CONCERN" # 经营方能勉强覆盖
|
|
168
|
+
return "SEVERE" # 经营方净收入为负或流水极低
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _split_status(split: Dict) -> str:
|
|
172
|
+
"""根据分账结果给出人读友好状态描述"""
|
|
173
|
+
top_up = split.get("top_up", 0)
|
|
174
|
+
op_net = split.get("operator_net", 0)
|
|
175
|
+
guaranteed = split.get("guaranteed", 0)
|
|
176
|
+
if top_up == 0:
|
|
177
|
+
return "流水分润超过保底,经营状况良好"
|
|
178
|
+
if op_net >= guaranteed * 0.5:
|
|
179
|
+
return "保底兜底生效(属正常),经营方净收入尚可"
|
|
180
|
+
if op_net > 0:
|
|
181
|
+
return "保底兜底生效,经营方净收入偏低,建议持续关注"
|
|
182
|
+
return "经营方净收入为负,无法自覆保底,需紧急处置"
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _split_key_points(split: Dict) -> List[str]:
|
|
186
|
+
pts = []
|
|
187
|
+
pts.append(f"本期总流水: {split['gross_revenue']:,.2f}元")
|
|
188
|
+
pts.append(f"资产方实得: {split['owner_total']:,.2f}元"
|
|
189
|
+
+ (f"(含补足{split['top_up']:,.2f}元)" if split['top_up'] > 0 else ""))
|
|
190
|
+
pts.append(f"经营方实得: {split['operator_net']:,.2f}元")
|
|
191
|
+
pts.append(f"平台服务费: {split['platform_fee']:,.2f}元 风险准备金: {split['risk_reserve']:,.2f}元")
|
|
192
|
+
if split.get("top_up", 0) > 0:
|
|
193
|
+
pts.append(f"保底补足: {split['top_up']:,.2f}元(需经营方在结算日前缴纳)")
|
|
194
|
+
return pts
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _template_split_analysis(split: Dict, rules: Dict) -> str:
|
|
198
|
+
top_up_line = (
|
|
199
|
+
"保底补足: {:,.2f}元(须补缴)".format(split['top_up'])
|
|
200
|
+
if split['top_up'] > 0 else "流水覆盖保底,无需补足"
|
|
201
|
+
)
|
|
202
|
+
return (
|
|
203
|
+
f"分账计算说明(模板):\n"
|
|
204
|
+
f" 本期总流水: {split['gross_revenue']:,.2f}元 退款: {split['refunds']:,.2f}元\n"
|
|
205
|
+
f" 净流水: {split['net_revenue']:,.2f}元\n"
|
|
206
|
+
f" 平台服务费 ({rules.get('platform_fee_pct',5)}%): -{split['platform_fee']:,.2f}元\n"
|
|
207
|
+
f" 风险准备金 ({rules.get('risk_reserve_pct',3)}%): -{split['risk_reserve']:,.2f}元\n"
|
|
208
|
+
f" 可分配金额: {split['distributable']:,.2f}元\n"
|
|
209
|
+
f" 资产方分润: {split['owner_share']:,.2f}元\n"
|
|
210
|
+
f" 保底收益: {split['guaranteed']:,.2f}元\n"
|
|
211
|
+
f" {top_up_line}\n"
|
|
212
|
+
f" 资产方实得: {split['owner_total']:,.2f}元\n"
|
|
213
|
+
f" 经营方实得: {split['operator_net']:,.2f}元\n"
|
|
214
|
+
f" 状态: {_split_status(split)}"
|
|
215
|
+
)
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""
|
|
2
|
+
agents/registry.py — Agent 注册与自动发现
|
|
3
|
+
==========================================
|
|
4
|
+
1. 内置 agent 预注册(technical / fundamental / macro / risk)
|
|
5
|
+
2. 扫描 ./aria_agents/ → 自动注册用户自定义 agent
|
|
6
|
+
3. 提供 get() / list() / register() 接口
|
|
7
|
+
|
|
8
|
+
自定义 Agent 放置规则:
|
|
9
|
+
项目根/aria_agents/my_agent.py
|
|
10
|
+
类需继承 BaseAgent,且声明 name 属性
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import importlib.util
|
|
16
|
+
import inspect
|
|
17
|
+
import logging
|
|
18
|
+
import sys
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from typing import Dict, List, Optional, Type
|
|
21
|
+
|
|
22
|
+
from .base import BaseAgent
|
|
23
|
+
from .financial.technical import TechnicalAgent
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
# ── 内置 agent 预注册 ─────────────────────────────────────────────────────────
|
|
28
|
+
_BUILTIN: Dict[str, Type[BaseAgent]] = {
|
|
29
|
+
"technical": TechnicalAgent,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# 尝试加载其他内置 agent(文件存在则注册)
|
|
33
|
+
# The package this module was loaded as: "aria_code.agents", or "agents" when the
|
|
34
|
+
# CLI's bare import root is in use. The built-ins were imported by the fixed
|
|
35
|
+
# name "aria_code.agents.…" — a second copy of the package under the other
|
|
36
|
+
# root, whose classes subclass a different BaseAgent. issubclass() then said
|
|
37
|
+
# no and they were dropped without a word: /team announced four analysts and
|
|
38
|
+
# only "technical" (imported relatively, above) ever ran.
|
|
39
|
+
_PACKAGE = __package__ or "aria_code.agents"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _try_import_builtin(module_path: str, name: str) -> None:
|
|
43
|
+
if module_path.startswith("aria_code.agents."):
|
|
44
|
+
module_path = _PACKAGE + module_path[len("aria_code.agents"):]
|
|
45
|
+
try:
|
|
46
|
+
mod = importlib.import_module(module_path)
|
|
47
|
+
for _, cls in inspect.getmembers(mod, inspect.isclass):
|
|
48
|
+
if issubclass(cls, BaseAgent) and cls is not BaseAgent:
|
|
49
|
+
_BUILTIN[cls.name] = cls
|
|
50
|
+
except ImportError:
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
_try_import_builtin("aria_code.agents.financial.macro", "macro")
|
|
55
|
+
_try_import_builtin("aria_code.agents.financial.fundamental", "fundamental")
|
|
56
|
+
_try_import_builtin("aria_code.agents.financial.risk", "risk")
|
|
57
|
+
_try_import_builtin("aria_code.agents.financial.synthesis", "synthesis")
|
|
58
|
+
_try_import_builtin("aria_code.agents.financial.news", "news")
|
|
59
|
+
_try_import_builtin("aria_code.agents.financial.catalyst", "catalyst")
|
|
60
|
+
_try_import_builtin("aria_code.agents.financial.debate", "debate")
|
|
61
|
+
_try_import_builtin("aria_code.agents.financial.earnings", "earnings")
|
|
62
|
+
_try_import_builtin("aria_code.agents.financial.sector", "sector")
|
|
63
|
+
_try_import_builtin("aria_code.agents.financial.strategist", "strategist")
|
|
64
|
+
_try_import_builtin("aria_code.agents.engineering.coder", "coder")
|
|
65
|
+
_try_import_builtin("aria_code.agents.engineering.tester", "tester")
|
|
66
|
+
_try_import_builtin("aria_code.agents.financial.corporate_finance", "corporate_finance")
|
|
67
|
+
_try_import_builtin("aria_code.agents.financial.cashflow_burn", "cashflow_burn")
|
|
68
|
+
_try_import_builtin("aria_code.agents.financial.stripe_revenue", "stripe_revenue")
|
|
69
|
+
_try_import_builtin("aria_code.agents.portfolio_agent", "portfolio")
|
|
70
|
+
_try_import_builtin("aria_code.agents.supervisor", "supervisor")
|
|
71
|
+
|
|
72
|
+
# ── 经营权共创平台 Agent 包 ────────────────────────────────────────────────────
|
|
73
|
+
_try_import_builtin("aria_code.agents.realty.asset_diagnosis", "asset_diagnosis")
|
|
74
|
+
_try_import_builtin("aria_code.agents.realty.business_match", "business_match")
|
|
75
|
+
_try_import_builtin("aria_code.agents.realty.contract_rules", "contract_rules")
|
|
76
|
+
_try_import_builtin("aria_code.agents.realty.revenue_share", "revenue_share")
|
|
77
|
+
_try_import_builtin("aria_code.agents.realty.cashflow_verify", "cashflow_verify")
|
|
78
|
+
_try_import_builtin("aria_code.agents.realty.energy_anomaly", "energy_anomaly")
|
|
79
|
+
_try_import_builtin("aria_code.agents.realty.fulfillment_risk", "fulfillment_risk")
|
|
80
|
+
_try_import_builtin("aria_code.agents.realty.ops_optimize", "ops_optimize")
|
|
81
|
+
_try_import_builtin("aria_code.agents.realty.exit_settlement", "exit_settlement")
|
|
82
|
+
|
|
83
|
+
# ── 海外仓与物流供应链 Agent 包 ──────────────────────────────────────────────────
|
|
84
|
+
_try_import_builtin("aria_code.agents.warehouse.logistics_sync", "warehouse_logistics_sync")
|
|
85
|
+
_try_import_builtin("aria_code.agents.warehouse.inbound_exceptions", "warehouse_inbound_exceptions")
|
|
86
|
+
_try_import_builtin("aria_code.agents.warehouse.inventory_health", "warehouse_inventory_health")
|
|
87
|
+
_try_import_builtin("aria_code.agents.warehouse.logistics_cost", "warehouse_logistics_cost")
|
|
88
|
+
_try_import_builtin("aria_code.agents.warehouse.fulfillment_leadtime", "warehouse_fulfillment_leadtime")
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class AgentRegistry:
|
|
92
|
+
"""
|
|
93
|
+
Agent 注册中心(单例)。
|
|
94
|
+
|
|
95
|
+
用法:
|
|
96
|
+
registry = get_registry()
|
|
97
|
+
registry.register(MyAgent)
|
|
98
|
+
agent_cls = registry.get("my_agent")
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
def __init__(self):
|
|
102
|
+
self._agents: Dict[str, Type[BaseAgent]] = dict(_BUILTIN)
|
|
103
|
+
self._scanned = False
|
|
104
|
+
|
|
105
|
+
def register(self, cls: Type[BaseAgent]) -> None:
|
|
106
|
+
"""手动注册一个 Agent 类"""
|
|
107
|
+
if not (isinstance(cls, type) and issubclass(cls, BaseAgent)):
|
|
108
|
+
raise TypeError(f"{cls} 不是 BaseAgent 子类")
|
|
109
|
+
self._agents[cls.name] = cls
|
|
110
|
+
logger.info(f"✓ 注册 Agent: {cls.name}")
|
|
111
|
+
|
|
112
|
+
def get(self, name: str) -> Optional[Type[BaseAgent]]:
|
|
113
|
+
"""按名称获取 Agent 类"""
|
|
114
|
+
self._ensure_scanned()
|
|
115
|
+
return self._agents.get(name.lower())
|
|
116
|
+
|
|
117
|
+
def list(self) -> List[Dict]:
|
|
118
|
+
"""列出所有已注册 Agent"""
|
|
119
|
+
self._ensure_scanned()
|
|
120
|
+
return [
|
|
121
|
+
{"name": name, "description": cls.description, "builtin": name in _BUILTIN}
|
|
122
|
+
for name, cls in self._agents.items()
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
def _ensure_scanned(self) -> None:
|
|
126
|
+
if not self._scanned:
|
|
127
|
+
self._scan_project()
|
|
128
|
+
self._scanned = True
|
|
129
|
+
|
|
130
|
+
def _scan_project(self) -> None:
|
|
131
|
+
"""扫描当前工作目录及父级的 aria_agents/ 目录"""
|
|
132
|
+
search_paths = [Path.cwd(), Path.cwd().parent]
|
|
133
|
+
for base in search_paths:
|
|
134
|
+
agents_dir = base / "aria_agents"
|
|
135
|
+
if not agents_dir.is_dir():
|
|
136
|
+
continue
|
|
137
|
+
for py_file in sorted(agents_dir.glob("*.py")):
|
|
138
|
+
if py_file.name.startswith("_"):
|
|
139
|
+
continue
|
|
140
|
+
self._load_file(py_file)
|
|
141
|
+
break # 找到第一个 aria_agents/ 即停止向上搜索
|
|
142
|
+
|
|
143
|
+
def _load_file(self, path: Path) -> None:
|
|
144
|
+
"""加载一个 .py 文件,自动注册其中的 BaseAgent 子类"""
|
|
145
|
+
try:
|
|
146
|
+
spec = importlib.util.spec_from_file_location(path.stem, path)
|
|
147
|
+
module = importlib.util.module_from_spec(spec)
|
|
148
|
+
spec.loader.exec_module(module)
|
|
149
|
+
for _, cls in inspect.getmembers(module, inspect.isclass):
|
|
150
|
+
if (cls.__module__ == module.__name__
|
|
151
|
+
and issubclass(cls, BaseAgent)
|
|
152
|
+
and cls is not BaseAgent
|
|
153
|
+
and hasattr(cls, "name")
|
|
154
|
+
and cls.name != "base"):
|
|
155
|
+
self._agents[cls.name] = cls
|
|
156
|
+
logger.info(f"✓ 自动发现 Agent: {cls.name} ({path.name})")
|
|
157
|
+
except Exception as e:
|
|
158
|
+
logger.warning(f"加载 agent 文件 {path} 失败: {e}")
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
# ── 单例 ──────────────────────────────────────────────────────────────────────
|
|
162
|
+
_registry: Optional[AgentRegistry] = None
|
|
163
|
+
|
|
164
|
+
def get_registry() -> AgentRegistry:
|
|
165
|
+
global _registry
|
|
166
|
+
if _registry is None:
|
|
167
|
+
_registry = AgentRegistry()
|
|
168
|
+
return _registry
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""
|
|
2
|
+
agents/signal_scheme.py — 领域可插拔的信号词汇表
|
|
3
|
+
====================================================
|
|
4
|
+
team.py 里的表决(_vote_signal)、辩论触发(_needs_debate)原本硬编码了金融的
|
|
5
|
+
BUY/HOLD/SELL/STRONG_BUY/STRONG_SELL 五级词汇。realty 的 9 个 agent 长期以来
|
|
6
|
+
借用同一套词汇表达完全不同的含义(BUY=推荐共创、流水真实、条款清晰、低风险……
|
|
7
|
+
每个文件的 BUY 意思都不一样,只在各自 docstring 里注明),靠 aria_cli.py 里
|
|
8
|
+
一张 _SIGNAL_LABELS 翻译表在展示层补救。这意味着一旦有人把多个 realty agent
|
|
9
|
+
接进 AgentTeam 做 vote/debate(cashflow_verify 的 SELL=疑似造假 和
|
|
10
|
+
ops_optimize 的 SELL=经营不佳需干预 完全不是同一个维度),_vote_signal 会把
|
|
11
|
+
它们当同一根多空轴数值平均,产出一个语义上没有意义的"共识"。
|
|
12
|
+
|
|
13
|
+
SignalScheme 把这套词汇表和打分/辩论触发规则抽成领域可配置的对象,
|
|
14
|
+
AgentTeam 默认用 FINANCIAL_SCHEME(对现有金融调用方零行为变化),
|
|
15
|
+
其他领域注册自己的词汇表即可复用同一套并行/表决/辩论/synthesis 编排逻辑,
|
|
16
|
+
而不必借用金融的 BUY/SELL 语义或答案词不达意。
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from dataclasses import dataclass
|
|
22
|
+
from typing import Dict, List, Tuple
|
|
23
|
+
|
|
24
|
+
from .base import AgentResult
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class SignalScheme:
|
|
29
|
+
"""一套领域信号词汇表:多空打分 + 辩论触发条件。
|
|
30
|
+
|
|
31
|
+
upper_thresholds / lower_thresholds 特意分成两条腿而不是一条单向扫描的
|
|
32
|
+
区间列表——原始金融判定逻辑本身就是两段非对称的边界(上方 >= 含右端点,
|
|
33
|
+
下方 <= 含左端点,中间落空隙才算 neutral_default),一条单向 >= 扫描的
|
|
34
|
+
区间列表没法同时正确表达"上方含端点"和"下方也含端点"这两种边界方向,
|
|
35
|
+
会把 avg_score=0 这种中性分数错误地吃进最负的那个区间(已在 fuzz 测试里
|
|
36
|
+
实测过这个 bug:单向列表版本对 avg_score=0 的输入返回了 STRONG_SELL)。
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
name: str
|
|
40
|
+
# 信号 → 打分(用于表决时按置信度加权平均);分数越高越"正面"。
|
|
41
|
+
scores: Dict[str, int]
|
|
42
|
+
# 从高到低排列;第一个满足 avg_score >= threshold 的胜出。
|
|
43
|
+
upper_thresholds: List[Tuple[float, str]]
|
|
44
|
+
# 按"最极端优先"排列(比如先检查 <=-1.5 再检查 <=-0.5);
|
|
45
|
+
# 第一个满足 avg_score <= threshold 的胜出。
|
|
46
|
+
lower_thresholds: List[Tuple[float, str]]
|
|
47
|
+
# 触发 debate 的两组信号(出现其一 + 另一组其一即触发,比如金融的"多"与"空")
|
|
48
|
+
positive_signals: frozenset
|
|
49
|
+
negative_signals: frozenset
|
|
50
|
+
neutral_default: str = "HOLD"
|
|
51
|
+
|
|
52
|
+
def vote(self, results: List[AgentResult]) -> Tuple[str, float]:
|
|
53
|
+
valid = [r for r in results if r.success and r.signal in self.scores]
|
|
54
|
+
if not valid:
|
|
55
|
+
return self.neutral_default, 0.0
|
|
56
|
+
avg_score = sum(self.scores[r.signal] * r.confidence for r in valid) / len(valid)
|
|
57
|
+
avg_conf = sum(r.confidence for r in valid) / len(valid)
|
|
58
|
+
for threshold, label in self.upper_thresholds:
|
|
59
|
+
if avg_score >= threshold:
|
|
60
|
+
return label, avg_conf
|
|
61
|
+
for threshold, label in self.lower_thresholds:
|
|
62
|
+
if avg_score <= threshold:
|
|
63
|
+
return label, avg_conf
|
|
64
|
+
return self.neutral_default, avg_conf
|
|
65
|
+
|
|
66
|
+
def needs_debate(self, results: List[AgentResult]) -> bool:
|
|
67
|
+
signals = [r.signal for r in results if r.success and r.signal]
|
|
68
|
+
has_positive = any(s in self.positive_signals for s in signals)
|
|
69
|
+
has_negative = any(s in self.negative_signals for s in signals)
|
|
70
|
+
return has_positive and has_negative
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# ── 金融:既有行为,原样保留(upper/lower 拆分精确复刻原 if/elif 分支)────────
|
|
74
|
+
FINANCIAL_SCHEME = SignalScheme(
|
|
75
|
+
name="financial",
|
|
76
|
+
scores={"STRONG_BUY": 2, "BUY": 1, "HOLD": 0, "SELL": -1, "STRONG_SELL": -2},
|
|
77
|
+
upper_thresholds=[(1.5, "STRONG_BUY"), (0.5, "BUY")],
|
|
78
|
+
lower_thresholds=[(-1.5, "STRONG_SELL"), (-0.5, "SELL")],
|
|
79
|
+
positive_signals=frozenset({"BUY", "STRONG_BUY"}),
|
|
80
|
+
negative_signals=frozenset({"SELL", "STRONG_SELL"}),
|
|
81
|
+
neutral_default="HOLD",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# ── 地产资管:健康度评估,不是交易动作 ──────────────────────────────────────
|
|
85
|
+
# GOOD/WATCH/CONCERN/SEVERE —— 这条轴描述"这个维度是否健康",不是"要不要买"。
|
|
86
|
+
# 9 个 realty agent 各自评估不同维度(流水真实性、合同风险、能耗异常、履约风险
|
|
87
|
+
# 等),但共享同一个"健康 → 需关注 → 有问题 → 严重"的四级尺度,用领域自己的
|
|
88
|
+
# 词汇表述比借用股票的 BUY/SELL 更准确,也让 vote/debate 的语义站得住脚。
|
|
89
|
+
REALTY_SCHEME = SignalScheme(
|
|
90
|
+
name="realty",
|
|
91
|
+
scores={"GOOD": 2, "WATCH": 0, "CONCERN": -1, "SEVERE": -2},
|
|
92
|
+
upper_thresholds=[(1.0, "GOOD")],
|
|
93
|
+
lower_thresholds=[(-1.5, "SEVERE"), (-0.5, "CONCERN")],
|
|
94
|
+
positive_signals=frozenset({"GOOD"}),
|
|
95
|
+
negative_signals=frozenset({"CONCERN", "SEVERE"}),
|
|
96
|
+
neutral_default="WATCH",
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# ── 仓储 ERP:同样是运营健康度,不是交易动作 ────────────────────────────────
|
|
100
|
+
# Warehouse agents assess carrier synchronisation, inbound exceptions and stock
|
|
101
|
+
# health. Keeping a named scheme prevents callers from accidentally applying
|
|
102
|
+
# the financial BUY/HOLD/SELL vote to these operational signals.
|
|
103
|
+
WAREHOUSE_SCHEME = SignalScheme(
|
|
104
|
+
name="warehouse",
|
|
105
|
+
scores={"GOOD": 2, "WATCH": 0, "CONCERN": -1, "SEVERE": -2},
|
|
106
|
+
upper_thresholds=[(1.0, "GOOD")],
|
|
107
|
+
lower_thresholds=[(-1.5, "SEVERE"), (-0.5, "CONCERN")],
|
|
108
|
+
positive_signals=frozenset({"GOOD"}),
|
|
109
|
+
negative_signals=frozenset({"CONCERN", "SEVERE"}),
|
|
110
|
+
neutral_default="WATCH",
|
|
111
|
+
)
|
|
File without changes
|