aria-code 0.52.0__py3-none-any.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_code/__init__.py +42 -0
- aria_code/_version.py +20 -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 +34 -0
- aria_code/agents/base.py +318 -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 +303 -0
- aria_code/agents/financial/fundamental.py +191 -0
- aria_code/agents/financial/macro.py +99 -0
- aria_code/agents/financial/news.py +207 -0
- aria_code/agents/financial/risk.py +165 -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 +258 -0
- aria_code/agents/orchestrator.py +44 -0
- aria_code/agents/portfolio_agent.py +363 -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 +158 -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 +492 -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/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 +15 -0
- aria_code/apps/channels/__init__.py +17 -0
- aria_code/apps/channels/intake.py +92 -0
- aria_code/apps/channels/registry.py +95 -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/bootstrap.py +145 -0
- aria_code/apps/cli/broker_render.py +206 -0
- aria_code/apps/cli/codegen_paths.py +29 -0
- aria_code/apps/cli/commands/__init__.py +16 -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 +369 -0
- aria_code/apps/cli/commands/ashare_prediction_cmds.py +327 -0
- aria_code/apps/cli/commands/auth_cmds.py +239 -0
- aria_code/apps/cli/commands/backtest_cmds.py +2543 -0
- aria_code/apps/cli/commands/broker_cmds.py +1234 -0
- aria_code/apps/cli/commands/business_workflow_cmds.py +319 -0
- aria_code/apps/cli/commands/canvas_cmds.py +77 -0
- aria_code/apps/cli/commands/catalog.py +87 -0
- aria_code/apps/cli/commands/core_cmds.py +2520 -0
- aria_code/apps/cli/commands/data_cmds.py +457 -0
- aria_code/apps/cli/commands/diagnostic_cmds.py +230 -0
- aria_code/apps/cli/commands/diagnostic_ops_cmds.py +813 -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 +434 -0
- aria_code/apps/cli/commands/market_cmds.py +1381 -0
- aria_code/apps/cli/commands/market_context.py +425 -0
- aria_code/apps/cli/commands/market_render.py +7 -0
- aria_code/apps/cli/commands/model_cmds.py +2153 -0
- aria_code/apps/cli/commands/ops_cmds.py +721 -0
- aria_code/apps/cli/commands/orchestrator_cmds.py +179 -0
- aria_code/apps/cli/commands/pdf_export_cmds.py +125 -0
- aria_code/apps/cli/commands/portfolio_cmds.py +1278 -0
- aria_code/apps/cli/commands/report.py +437 -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 +669 -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 +79 -0
- aria_code/apps/cli/commands/workflow_cmds.py +480 -0
- aria_code/apps/cli/commands/workspace_cmds.py +1494 -0
- aria_code/apps/cli/config_paths.py +73 -0
- aria_code/apps/cli/config_store.py +78 -0
- aria_code/apps/cli/constants.py +88 -0
- aria_code/apps/cli/context.py +34 -0
- aria_code/apps/cli/deterministic.py +191 -0
- aria_code/apps/cli/direct.py +48 -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 +196 -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 +1309 -0
- aria_code/apps/cli/handlers/market_handlers.py +2513 -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/helpers.py +302 -0
- aria_code/apps/cli/hooks.py +180 -0
- aria_code/apps/cli/i18n.py +297 -0
- aria_code/apps/cli/intent.py +136 -0
- aria_code/apps/cli/intent_router.py +276 -0
- aria_code/apps/cli/intent_signals.py +344 -0
- aria_code/apps/cli/lifecycle_hooks.py +48 -0
- aria_code/apps/cli/local_tool_schemas.py +536 -0
- aria_code/apps/cli/main.py +29 -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/model_catalog.py +620 -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 +59 -0
- aria_code/apps/cli/prompts/__init__.py +0 -0
- aria_code/apps/cli/prompts/coding.py +53 -0
- aria_code/apps/cli/prompts/select.py +142 -0
- aria_code/apps/cli/prompts/system_prompts.py +552 -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 +521 -0
- aria_code/apps/cli/providers/chat_routing.py +128 -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 +1594 -0
- aria_code/apps/cli/providers/llm/response_cache.py +60 -0
- aria_code/apps/cli/providers/llm/sse_stream.py +257 -0
- aria_code/apps/cli/providers/runtime_bridge.py +353 -0
- aria_code/apps/cli/providers/vertexai_stream.py +316 -0
- aria_code/apps/cli/runtime_consumer.py +657 -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_store.py +112 -0
- aria_code/apps/cli/skills_catalog.py +273 -0
- aria_code/apps/cli/todo_tracker.py +190 -0
- aria_code/apps/cli/tool_executor.py +823 -0
- aria_code/apps/cli/tool_registry.py +34 -0
- aria_code/apps/cli/tool_scope.py +106 -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 +180 -0
- aria_code/apps/cli/tools/market_tools.py +620 -0
- aria_code/apps/cli/tools/notebook_tools.py +111 -0
- aria_code/apps/cli/tools/system_tools.py +726 -0
- aria_code/apps/cli/tools/write_tools.py +845 -0
- aria_code/apps/cli/tradingview_bridge.py +529 -0
- aria_code/apps/cli/turn_planning.py +137 -0
- aria_code/apps/cli/update_check.py +153 -0
- aria_code/apps/cli/utils/__init__.py +0 -0
- aria_code/apps/cli/utils/market_detect.py +1597 -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 +6743 -0
- aria_code/aria_daemon.py +1398 -0
- aria_code/aria_feishu_bot.py +1423 -0
- aria_code/aria_mcp_server.py +7 -0
- aria_code/aria_relay_client.py +4 -0
- aria_code/aria_relay_server.py +490 -0
- aria_code/aria_telegram_bot.py +202 -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 +182 -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 +1976 -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 +181 -0
- aria_code/command_safety.py +19 -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/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/demo_player.py +207 -0
- aria_code/doctor.py +813 -0
- aria_code/domain/__init__.py +0 -0
- aria_code/domain/backtest_engine.py +354 -0
- aria_code/domain/backtest_report.py +472 -0
- aria_code/domain/finance_formulas.py +389 -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/harness.py +598 -0
- aria_code/evals/runner.py +238 -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 +386 -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 +639 -0
- aria_code/memory_manager.py +246 -0
- aria_code/model_capability.py +486 -0
- aria_code/notification_tools.py +4 -0
- aria_code/openai_image_client.py +4 -0
- aria_code/packages/__init__.py +23 -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 +52 -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 +201 -0
- aria_code/packages/aria_mcp/circuit.py +82 -0
- aria_code/packages/aria_mcp/config.py +111 -0
- aria_code/packages/aria_mcp/installer.py +95 -0
- aria_code/packages/aria_mcp/server.py +1550 -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 +396 -0
- aria_code/packages/aria_sdk/providers.py +70 -0
- aria_code/packages/aria_sdk/streaming.py +79 -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 +268 -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 +57 -0
- aria_code/packages/aria_services/research_quality.py +186 -0
- aria_code/packages/aria_services/settings.py +157 -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 +8 -0
- aria_code/packages/aria_tools/financial/_paths.py +130 -0
- aria_code/packages/aria_tools/financial/compliance.py +31 -0
- aria_code/packages/aria_tools/financial/factors.py +33 -0
- aria_code/packages/aria_tools/financial/risk_tools.py +33 -0
- aria_code/packages/aria_tools/financial/strategy.py +31 -0
- aria_code/packages/aria_tools/registry.py +128 -0
- aria_code/packages/quant_engine/__init__.py +34 -0
- aria_code/packages/quant_engine/_namespace.py +62 -0
- aria_code/packages/quant_engine/backtest/__init__.py +14 -0
- aria_code/packages/quant_engine/backtest/core.py +53 -0
- aria_code/packages/quant_engine/backtest/engine.py +96 -0
- aria_code/packages/quant_engine/portfolio/__init__.py +13 -0
- aria_code/packages/quant_engine/portfolio/optimizer.py +85 -0
- aria_code/packages/quant_engine/sports/__init__.py +80 -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/ml_model.py +377 -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 +35 -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/logistics/__init__.py +169 -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/llm/__init__.py +19 -0
- aria_code/providers/llm/anthropic.py +184 -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 +129 -0
- aria_code/providers/llm/openai_compat.py +313 -0
- aria_code/providers/llm/registry.py +444 -0
- aria_code/providers/local_image_provider.py +202 -0
- aria_code/providers/local_llm_provider.py +589 -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/runtime/__init__.py +169 -0
- aria_code/runtime/acceptance.py +481 -0
- aria_code/runtime/agent_loop.py +1520 -0
- aria_code/runtime/approval.py +57 -0
- aria_code/runtime/budget.py +232 -0
- aria_code/runtime/checkpoints.py +432 -0
- aria_code/runtime/crash_report.py +174 -0
- aria_code/runtime/events.py +113 -0
- aria_code/runtime/gateway.py +150 -0
- aria_code/runtime/lsp.py +484 -0
- aria_code/runtime/orchestrator.py +55 -0
- aria_code/runtime/repo_map.py +700 -0
- aria_code/runtime/run_state.py +127 -0
- aria_code/runtime/run_store.py +450 -0
- aria_code/runtime/self_healing.py +422 -0
- aria_code/runtime/subagent.py +547 -0
- aria_code/runtime/task_ledger.py +86 -0
- aria_code/runtime/task_orchestrator.py +90 -0
- aria_code/runtime/tool_executor.py +217 -0
- aria_code/runtime/tool_policy.py +107 -0
- aria_code/runtime/worktrees.py +215 -0
- aria_code/runway_video_client.py +4 -0
- aria_code/safety/__init__.py +23 -0
- aria_code/safety/permissions.py +306 -0
- aria_code/safety/service.py +102 -0
- aria_code/setup_wizard.py +673 -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 +504 -0
- aria_code/tools/data_analysis_tools.py +809 -0
- aria_code/tools/enterprise_finance_tools.py +156 -0
- aria_code/tools/extended_tools.py +240 -0
- aria_code/tools/file_analysis_tools.py +885 -0
- aria_code/tools/image_gen_tools.py +114 -0
- aria_code/tools/local_finance_tools.py +3417 -0
- aria_code/tools/logistics_tools.py +135 -0
- aria_code/tools/macro_tools.py +369 -0
- aria_code/tools/notification_tools.py +249 -0
- aria_code/tools/project_tools.py +525 -0
- aria_code/tools/realty_data_tools.py +659 -0
- aria_code/tools/spreadsheet_tools.py +388 -0
- aria_code/tools/stripe_tools.py +115 -0
- aria_code/ui/__init__.py +105 -0
- aria_code/ui/banner.py +508 -0
- aria_code/ui/completer.py +501 -0
- aria_code/ui/console.py +281 -0
- aria_code/ui/image_render.py +243 -0
- aria_code/ui/input_box.py +488 -0
- aria_code/ui/picker.py +201 -0
- aria_code/ui/render/__init__.py +11 -0
- aria_code/ui/render/finance.py +1705 -0
- aria_code/ui/render/market.py +225 -0
- aria_code/ui/render/output.py +775 -0
- aria_code/ui/render/responsive.py +75 -0
- aria_code/ui/render/team.py +354 -0
- aria_code/ui/robot.py +235 -0
- aria_code/ui/startup_dashboard.py +109 -0
- aria_code/utils/vscode_uri.py +37 -0
- aria_code/video_analysis.py +147 -0
- aria_code/video_editor.py +271 -0
- aria_code/workspace/__init__.py +6 -0
- aria_code/workspace/files.py +193 -0
- aria_code/workspace/verify.py +113 -0
- aria_code/workspace_changes.py +199 -0
- aria_code/workspace_context.py +233 -0
- aria_code/workspace_service.py +196 -0
- aria_code/workspace_tools.py +150 -0
- aria_code-0.52.0.dist-info/METADATA +237 -0
- aria_code-0.52.0.dist-info/RECORD +478 -0
- aria_code-0.52.0.dist-info/WHEEL +5 -0
- aria_code-0.52.0.dist-info/entry_points.txt +3 -0
- aria_code-0.52.0.dist-info/licenses/LICENSE +201 -0
- aria_code-0.52.0.dist-info/licenses/NOTICE +49 -0
- aria_code-0.52.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"""
|
|
2
|
+
agents/realty/fulfillment_risk.py — 履约风控 Agent
|
|
3
|
+
===================================================
|
|
4
|
+
监控合同履约和资金风险,生成风险等级和处置建议。
|
|
5
|
+
|
|
6
|
+
输入数据(data dict keys):
|
|
7
|
+
invoices — 账单列表(应收/实收/逾期情况)
|
|
8
|
+
contract_rules — 合同规则(保底/保证金/结算周期等)
|
|
9
|
+
cashflow_status — 最新流水核验状态
|
|
10
|
+
account_changes — 收款账户变更记录
|
|
11
|
+
compliance_flags— 合规预警标志(私自换码/改业态等)
|
|
12
|
+
|
|
13
|
+
输出:
|
|
14
|
+
analysis — 风险报告
|
|
15
|
+
signal — GOOD=低风险 / WATCH=中等风险 / CONCERN=高风险 / SEVERE=极高风险
|
|
16
|
+
(地产健康度尺度,见 signal_scheme.py)
|
|
17
|
+
key_points — 风险事项清单(按级别)
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from typing import Any, Dict, List
|
|
22
|
+
from ..base import BaseAgent, AgentResult
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class FulfillmentRiskAgent(BaseAgent):
|
|
26
|
+
name = "fulfillment_risk"
|
|
27
|
+
description = "履约风控:监控逾期/保底/保证金/私账/业态合规,生成风险等级和处置建议"
|
|
28
|
+
|
|
29
|
+
_SYSTEM = (
|
|
30
|
+
"你是一名专业的不动产合同履约风险管理专家。\n"
|
|
31
|
+
"请对履约风险评估结果进行分析:\n"
|
|
32
|
+
" 1. 逾期风险:账单逾期天数、逾期金额、逾期频次\n"
|
|
33
|
+
" 2. 保底风险:实际流水是否持续低于保底标准\n"
|
|
34
|
+
" 3. 保证金风险:保证金余额是否充足(低于1个月保底需预警)\n"
|
|
35
|
+
" 4. 资金风险:是否存在私自更换收款码、现金比例过高\n"
|
|
36
|
+
" 5. 合规风险:是否擅自改变业态、违规装修、无照经营\n"
|
|
37
|
+
" 6. 综合风险等级:[低] / [中] / [高] / [极高]\n"
|
|
38
|
+
" 7. 处置建议:催缴/整改通知/保证金扣除/退出清算(分级建议)"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
async def analyze(self, symbol: str, data: Dict[str, Any]) -> AgentResult:
|
|
42
|
+
invoices = data.get("invoices", [])
|
|
43
|
+
rules = data.get("contract_rules", {})
|
|
44
|
+
cf_status = data.get("cashflow_status", {})
|
|
45
|
+
acct_chg = data.get("account_changes", [])
|
|
46
|
+
flags = data.get("compliance_flags", [])
|
|
47
|
+
|
|
48
|
+
risk = _assess_risk(invoices, rules, cf_status, acct_chg, flags)
|
|
49
|
+
|
|
50
|
+
user_prompt = (
|
|
51
|
+
f"履约风险评估:\n"
|
|
52
|
+
f" 逾期账单: {risk['overdue_count']}张 逾期金额: {risk['overdue_amount']:,.2f}元\n"
|
|
53
|
+
f" 最长逾期: {risk['max_overdue_days']}天\n"
|
|
54
|
+
f" 保底覆盖率: {risk['guaranteed_coverage_pct']:.1f}%(近3期平均)\n"
|
|
55
|
+
f" 保证金余额: {risk['deposit_balance']:,.2f}元 "
|
|
56
|
+
f" 要求: {risk['deposit_required']:,.2f}元\n"
|
|
57
|
+
f" 账户变更记录: {len(acct_chg)}次\n"
|
|
58
|
+
f" 合规标志: {', '.join(flags) or '无'}\n\n"
|
|
59
|
+
f"风险事项({risk['risk_count']}项):\n"
|
|
60
|
+
+ "\n".join(f" [{item['level']}] {item['desc']}" for item in risk["risk_items"])
|
|
61
|
+
+ "\n\n请完成风险报告并给出处置建议。"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
analysis = await self._call_llm(self._SYSTEM, user_prompt, max_tokens=700)
|
|
65
|
+
if not analysis:
|
|
66
|
+
analysis = _template_risk_report(risk, rules)
|
|
67
|
+
|
|
68
|
+
signal = _risk_signal(risk)
|
|
69
|
+
confidence = _risk_confidence(risk, invoices)
|
|
70
|
+
key_points = _risk_key_points(risk)
|
|
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 = {"risk_assessment": risk},
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# ── 风险评估逻辑 ──────────────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
def _assess_risk(
|
|
86
|
+
invoices: List[Dict], rules: Dict, cf: Dict,
|
|
87
|
+
acct_changes: List[Dict], flags: List[str],
|
|
88
|
+
) -> Dict:
|
|
89
|
+
guaranteed = rules.get("guaranteed_monthly", 0)
|
|
90
|
+
deposit_req = rules.get("deposit_amount", 0)
|
|
91
|
+
deposit_bal = rules.get("deposit_balance", deposit_req) # 当前余额
|
|
92
|
+
|
|
93
|
+
risk_items: List[Dict] = []
|
|
94
|
+
|
|
95
|
+
# 1. 逾期账单分析
|
|
96
|
+
overdue = [inv for inv in invoices if inv.get("status") in ("overdue", "逾期")]
|
|
97
|
+
overdue_amount = sum(inv.get("amount", 0) - inv.get("paid", 0) for inv in overdue)
|
|
98
|
+
max_overdue_days = max((inv.get("overdue_days", 0) for inv in overdue), default=0)
|
|
99
|
+
|
|
100
|
+
if overdue_amount > 0:
|
|
101
|
+
level = "极高" if max_overdue_days > 60 else ("高" if max_overdue_days > 30 else "中")
|
|
102
|
+
risk_items.append({"level": level,
|
|
103
|
+
"desc": f"共{len(overdue)}张账单逾期,金额{overdue_amount:,.2f}元,最长{max_overdue_days}天"})
|
|
104
|
+
|
|
105
|
+
# 2. 保底覆盖率(取近几期)
|
|
106
|
+
recent_revenues = [inv.get("revenue", 0) for inv in invoices[-3:] if inv.get("revenue")]
|
|
107
|
+
if recent_revenues and guaranteed > 0:
|
|
108
|
+
avg_coverage = sum(r / guaranteed * 100 for r in recent_revenues) / len(recent_revenues)
|
|
109
|
+
if avg_coverage < 60:
|
|
110
|
+
risk_items.append({"level": "高",
|
|
111
|
+
"desc": f"近{len(recent_revenues)}期流水平均仅覆盖保底{avg_coverage:.1f}%"})
|
|
112
|
+
elif avg_coverage < 80:
|
|
113
|
+
risk_items.append({"level": "中",
|
|
114
|
+
"desc": f"近期流水覆盖保底{avg_coverage:.1f}%,持续偏低"})
|
|
115
|
+
else:
|
|
116
|
+
avg_coverage = 100.0
|
|
117
|
+
|
|
118
|
+
# 3. 保证金不足
|
|
119
|
+
if deposit_req > 0 and deposit_bal < deposit_req * 0.5:
|
|
120
|
+
risk_items.append({"level": "高",
|
|
121
|
+
"desc": f"保证金余额{deposit_bal:,.0f}元不足要求{deposit_req:,.0f}元的50%"})
|
|
122
|
+
elif deposit_req > 0 and deposit_bal < deposit_req:
|
|
123
|
+
risk_items.append({"level": "中",
|
|
124
|
+
"desc": f"保证金余额{deposit_bal:,.0f}元低于合同要求{deposit_req:,.0f}元"})
|
|
125
|
+
|
|
126
|
+
# 4. 账户变更
|
|
127
|
+
if len(acct_changes) > 0:
|
|
128
|
+
unauth = [c for c in acct_changes if not c.get("approved")]
|
|
129
|
+
if unauth:
|
|
130
|
+
risk_items.append({"level": "极高",
|
|
131
|
+
"desc": f"发现{len(unauth)}次未授权收款账户变更,疑似私账行为"})
|
|
132
|
+
else:
|
|
133
|
+
risk_items.append({"level": "低",
|
|
134
|
+
"desc": f"共{len(acct_changes)}次账户变更,已审批"})
|
|
135
|
+
|
|
136
|
+
# 5. 流水核验异常
|
|
137
|
+
cf_signal = cf.get("signal", "")
|
|
138
|
+
if cf_signal in ("CONCERN", "SEVERE"):
|
|
139
|
+
risk_items.append({"level": "高",
|
|
140
|
+
"desc": f"流水核验异常({cf.get('anomaly_summary','')}),需稽查"})
|
|
141
|
+
|
|
142
|
+
# 6. 合规标志
|
|
143
|
+
for flag in flags:
|
|
144
|
+
risk_items.append({"level": "高", "desc": f"合规违规: {flag}"})
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
"overdue_count": len(overdue),
|
|
148
|
+
"overdue_amount": overdue_amount,
|
|
149
|
+
"max_overdue_days": max_overdue_days,
|
|
150
|
+
"guaranteed_coverage_pct": avg_coverage,
|
|
151
|
+
"deposit_balance": deposit_bal,
|
|
152
|
+
"deposit_required": deposit_req,
|
|
153
|
+
"risk_items": risk_items,
|
|
154
|
+
"risk_count": len(risk_items),
|
|
155
|
+
"has_extreme_risk": any(r["level"] == "极高" for r in risk_items),
|
|
156
|
+
"has_high_risk": any(r["level"] == "高" for r in risk_items),
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _risk_signal(risk: Dict) -> str:
|
|
161
|
+
if risk.get("has_extreme_risk"): return "SEVERE"
|
|
162
|
+
if risk.get("has_high_risk"): return "CONCERN"
|
|
163
|
+
mid_count = sum(1 for r in risk.get("risk_items", []) if r["level"] == "中")
|
|
164
|
+
if mid_count >= 2: return "CONCERN"
|
|
165
|
+
if mid_count >= 1: return "WATCH"
|
|
166
|
+
return "GOOD"
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _risk_confidence(risk: Dict, invoices: List) -> float:
|
|
170
|
+
data_points = sum([
|
|
171
|
+
1 if invoices else 0,
|
|
172
|
+
1 if risk.get("deposit_required", 0) > 0 else 0,
|
|
173
|
+
1 if risk.get("guaranteed_coverage_pct", 100) < 100 else 0,
|
|
174
|
+
])
|
|
175
|
+
return round(0.6 + 0.1 * data_points, 2)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def _risk_key_points(risk: Dict) -> List[str]:
|
|
179
|
+
pts = []
|
|
180
|
+
if risk["overdue_amount"] > 0:
|
|
181
|
+
pts.append(f"逾期金额: {risk['overdue_amount']:,.2f}元(最长{risk['max_overdue_days']}天)")
|
|
182
|
+
pts.append(f"保底覆盖率: {risk['guaranteed_coverage_pct']:.1f}%")
|
|
183
|
+
pts.append(f"保证金: {risk['deposit_balance']:,.2f}/{risk['deposit_required']:,.2f}元")
|
|
184
|
+
for item in [r for r in risk["risk_items"] if r["level"] in ("极高", "高")][:2]:
|
|
185
|
+
pts.append(f"[{item['level']}风险] {item['desc'][:50]}")
|
|
186
|
+
return pts[:5]
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _template_risk_report(risk: Dict, rules: Dict) -> str:
|
|
190
|
+
level_map = {True: "极高", False: ""}
|
|
191
|
+
overall = "极高" if risk["has_extreme_risk"] else ("高" if risk["has_high_risk"] else
|
|
192
|
+
("中" if risk["risk_count"] > 0 else "低"))
|
|
193
|
+
return (
|
|
194
|
+
f"履约风控报告(模板):\n"
|
|
195
|
+
f" 综合风险等级: {overall}\n"
|
|
196
|
+
f" 逾期账单: {risk['overdue_count']}张 逾期金额: {risk['overdue_amount']:,.2f}元\n"
|
|
197
|
+
f" 最长逾期天数: {risk['max_overdue_days']}天\n"
|
|
198
|
+
f" 保底覆盖率: {risk['guaranteed_coverage_pct']:.1f}%\n"
|
|
199
|
+
f" 保证金: {risk['deposit_balance']:,.2f}/{risk['deposit_required']:,.2f}元\n"
|
|
200
|
+
f" 风险事项 ({risk['risk_count']}项):\n"
|
|
201
|
+
+ "\n".join(f" [{r['level']}] {r['desc']}" for r in risk["risk_items"])
|
|
202
|
+
+ "\n 处置建议: "
|
|
203
|
+
+ ("立即启动退出清算程序" if overall == "极高" else
|
|
204
|
+
"发出整改通知,7日内未整改启动违约程序" if overall == "高" else
|
|
205
|
+
"发出催缴通知,持续监控" if overall == "中" else "保持正常监控")
|
|
206
|
+
)
|
|
@@ -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
|
+
)
|