behive 0.5.0__tar.gz → 0.6.0__tar.gz
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.
- {behive-0.5.0/src/behive.egg-info → behive-0.6.0}/PKG-INFO +2 -1
- {behive-0.5.0 → behive-0.6.0}/pyproject.toml +3 -2
- {behive-0.5.0 → behive-0.6.0}/src/behive/__init__.py +1 -1
- behive-0.6.0/src/behive/brand_check.py +192 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/cli.py +23 -10
- {behive-0.5.0 → behive-0.6.0}/src/behive/client.py +14 -6
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/api_scout.py +165 -6
- behive-0.6.0/src/behive/engine/context_providers/__init__.py +14 -0
- behive-0.6.0/src/behive/engine/context_providers/base.py +83 -0
- behive-0.6.0/src/behive/engine/context_providers/dispatcher.py +67 -0
- behive-0.6.0/src/behive/engine/context_providers/providers.py +536 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/db.py +47 -5
- behive-0.6.0/src/behive/engine/db_duckdb.py +317 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/db_helpers.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/harvest.py +2 -2
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/hive_api_sources.json +147 -5
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/llm.py +5 -1
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/orchestrator.py +187 -11
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/process.py +14 -4
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/queen_calibrator.py +58 -37
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/queen_fact_mem.py +6 -10
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/rag.py +4 -24
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/scout.py +83 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/synth.py +35 -456
- behive-0.6.0/src/behive/federation.py +507 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/init-db.sql +207 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/server.py +14 -0
- {behive-0.5.0 → behive-0.6.0/src/behive.egg-info}/PKG-INFO +2 -1
- {behive-0.5.0 → behive-0.6.0}/src/behive.egg-info/SOURCES.txt +7 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive.egg-info/requires.txt +1 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_async_process.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_brute_force.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_clean_execution.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_coverage_buster.py +4 -4
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_deep_dive.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_golden_process.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_integration.py +2 -2
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_lowhanging.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_pure_functions.py +3 -3
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_rag_mi_deep.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_schema_deep.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_synth_queen.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_real_heavy.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/tests/test_real_integration.py +1 -1
- {behive-0.5.0 → behive-0.6.0}/LICENSE +0 -0
- {behive-0.5.0 → behive-0.6.0}/README.md +0 -0
- {behive-0.5.0 → behive-0.6.0}/setup.cfg +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/compat/__init__.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/compat/shims.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/config.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/__init__.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/__main__.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/bionic_quorum.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/constants.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/content_quality.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/domain_reputation.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/drones.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/events.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/falsifier.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/graph_engine.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/guardrail.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/intel_summary.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/master_intelligence.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/preprocessor.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/prescout.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/queen_feedback.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/queen_memory.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/queen_primer.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/queen_tools.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/engine/search_backends.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/knowledge_graph.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/mcp_server.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive/models.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive.egg-info/dependency_links.txt +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive.egg-info/entry_points.txt +0 -0
- {behive-0.5.0 → behive-0.6.0}/src/behive.egg-info/top_level.txt +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_async_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_async_omega.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_async_subprocess.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_batch_a_harvest_process.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_batch_a_synth_rag.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_batch_bc_orch_intel.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_batch_def_remaining.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_batch_g_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_breadth.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_brute_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_config_client.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_conflict_detector.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_continuation.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_coverage_push.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_deep_push_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_deep_targets_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_domrep_intel_primer.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_drones_guard_api.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_drones_scout_mi.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_events_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_events_domrep_intel.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_falsifier_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_falsifier_synth_extra.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_falsifier_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_feedback_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_feedback_deep_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_feedback_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_final_mega.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_final_push.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_final_wave.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_graph_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_graph_deep_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_graph_engine.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_graph_massive.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_harvest_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_harvest_deep_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_harvest_intel_dom.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_harvest_orch.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_harvest_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_heavy_modules.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_import_sweep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_init_modules.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_integration_h.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_intel_calib_domain.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_llm_db_preproc.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_llm_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_low_modules.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_massive_clean.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_mega_push.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_mega_push2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_mi_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_mi_deep_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_mi_synth_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_mi_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_omega.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_orch_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_orch_plan_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_orch_prescout_mega.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_orchestrator_deep_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_orchestrator_helpers.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_orchestrator_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_pipeline_mega.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_planner_entities.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_prescout_dance.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_prescout_deep_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_prescout_feedback.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_prescout_pure.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_prescout_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_process_classes.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_process_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_process_killer.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_process_orch_harvest.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_process_pure.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_process_regex.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_process_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_process_v4.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_quality_events.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_queen_mega.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_queen_memory_calibrator.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_queen_tools_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_quorum_quality.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_rag_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_rag_deep_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_rag_deep_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_rag_massive.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_rag_mega.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_rag_mi_final.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_rag_v4.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_remaining.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_routing_validation.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_scout_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_scout_feedback.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_scout_synth_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_search_backends_v3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_search_deep_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_search_falsifier.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_search_llm.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_server_mcp.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_small_push.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_smaller_modules.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_surgical.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_surgical_targets.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_synth_deep_v2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_synth_graph_extra.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_synth_killer.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_synth_mega.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_synth_mi_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_80_targeted_lines.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_api_scout.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_beeworker_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_bionic_quorum.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_blast_coverage.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_branch_coverage.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cli.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_client.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_config.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_constants.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_content_quality.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_40pct_push.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_async_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_async_push.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_breakthrough.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_breakthrough2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_ceiling_breaker.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_deep2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_deep3.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_drones.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_drones_direct.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_falsifier.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_final50.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_final_push.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_graph.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_graph_rag.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_harvest.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_harvest_llm_api.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_import_push.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_massive.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_master.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_mock_pool.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_orchestrator_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_orchestrator_full.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_prescout.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_prescout_harvest_pure.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_process.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_process_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_process_deep2.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_processing_drones.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_pure_functions.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_push50.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_queen_scout_full.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_queen_tools.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_rag_master.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_real_execution.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_server_client.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_server_endpoints.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_strategic.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_synth.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_synth_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_synth_graph_rag.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_targeted_modules.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_utilities_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cov_zero_modules.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_coverage_phase7.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_cross_35.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_db.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_db_integration.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_deep_execution.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_deep_functions.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_domain_reputation.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_drones.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_e2e_pipeline.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_events.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_falsifier.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_final_30pct.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_functional.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_gap_fill_35.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_graph_engine.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_guardrail.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_harvest.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_heavy_coverage.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_integration_mocked.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_knowledge_graph.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_llm.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_lowest_coverage.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_mass_coverage_35.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_mcp.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_mega_coverage.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_micro_35.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_orch_harvest_35.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_orchestrator.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_preprocessor.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_prescout.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_prescout_deep_35.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_process.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_process_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_process_orch_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_push_30pct.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_push_35_final.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_queen_deep.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_queen_honey.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_queen_load_persist.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_rag.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_rag_orch_30pct.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_regression.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_runpy_main.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_scout.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_search_backends.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_server.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_server_and_more.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_server_cli_35.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_server_integration.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_smoke.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_synth.py +0 -0
- {behive-0.5.0 → behive-0.6.0}/tests/test_uncovered_functions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: behive
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Research engine that builds structured knowledge graphs from any topic
|
|
5
5
|
Author-email: QA10 <hello@qa10.io>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -21,6 +21,7 @@ License-File: LICENSE
|
|
|
21
21
|
Requires-Dist: aiohttp>=3.9
|
|
22
22
|
Requires-Dist: httpx>=0.25
|
|
23
23
|
Requires-Dist: psycopg2-binary>=2.9
|
|
24
|
+
Requires-Dist: duckdb>=1.0
|
|
24
25
|
Requires-Dist: pydantic>=2.0
|
|
25
26
|
Requires-Dist: litellm>=1.40
|
|
26
27
|
Requires-Dist: feedparser>=6.0
|
|
@@ -6,11 +6,11 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
where = ["src"]
|
|
7
7
|
|
|
8
8
|
[tool.setuptools.package-data]
|
|
9
|
-
behive = ["init-db.sql", "engine/hive_api_sources.json"]
|
|
9
|
+
behive = ["init-db.sql", "engine/hive_api_sources.json", "../llms.txt"]
|
|
10
10
|
|
|
11
11
|
[project]
|
|
12
12
|
name = "behive"
|
|
13
|
-
version = "0.
|
|
13
|
+
version = "0.6.0"
|
|
14
14
|
description = "Research engine that builds structured knowledge graphs from any topic"
|
|
15
15
|
readme = "README.md"
|
|
16
16
|
license = "MIT"
|
|
@@ -33,6 +33,7 @@ dependencies = [
|
|
|
33
33
|
"aiohttp>=3.9",
|
|
34
34
|
"httpx>=0.25",
|
|
35
35
|
"psycopg2-binary>=2.9",
|
|
36
|
+
"duckdb>=1.0",
|
|
36
37
|
"pydantic>=2.0",
|
|
37
38
|
"litellm>=1.40",
|
|
38
39
|
"feedparser>=6.0",
|
|
@@ -14,7 +14,7 @@ try:
|
|
|
14
14
|
from importlib.metadata import version as _get_version
|
|
15
15
|
__version__ = _get_version("behive")
|
|
16
16
|
except Exception:
|
|
17
|
-
__version__ = "0.
|
|
17
|
+
__version__ = "0.6.0"
|
|
18
18
|
|
|
19
19
|
from behive.client import research, BeHiveClient
|
|
20
20
|
from behive.models import ResearchResult, Claim, Entity
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"""AI Brand Visibility Checker — free tool endpoint.
|
|
2
|
+
|
|
3
|
+
Accepts a brand/company name, queries the configured LLM asking "what do you know
|
|
4
|
+
about X?", analyzes the response for depth/accuracy, and returns a visibility score.
|
|
5
|
+
|
|
6
|
+
This is a zero-auth public endpoint designed as a lead magnet.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import time
|
|
11
|
+
import hashlib
|
|
12
|
+
from typing import Optional
|
|
13
|
+
|
|
14
|
+
from fastapi import APIRouter, HTTPException
|
|
15
|
+
from pydantic import BaseModel, Field
|
|
16
|
+
|
|
17
|
+
router = APIRouter(prefix="/api/public/brand-check", tags=["free-tools"])
|
|
18
|
+
|
|
19
|
+
# Simple in-memory rate limiting (per IP, 10 checks/hour)
|
|
20
|
+
_rate_limit: dict[str, list[float]] = {}
|
|
21
|
+
_RATE_LIMIT_WINDOW = 3600 # 1 hour
|
|
22
|
+
_RATE_LIMIT_MAX = 10
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class BrandCheckRequest(BaseModel):
|
|
26
|
+
"""Request to check brand visibility in AI systems."""
|
|
27
|
+
brand_name: str = Field(..., min_length=2, max_length=200, description="Company or brand name to check")
|
|
28
|
+
url: Optional[str] = Field(None, max_length=500, description="Optional website URL for context")
|
|
29
|
+
language: str = Field("en", description="Language for analysis (en, pl, de, etc.)")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class BrandCheckResponse(BaseModel):
|
|
33
|
+
"""AI Brand Visibility analysis result."""
|
|
34
|
+
brand_name: str
|
|
35
|
+
visibility_score: float = Field(..., ge=0, le=100, description="0-100 visibility score")
|
|
36
|
+
verdict: str = Field(..., description="Human-readable verdict")
|
|
37
|
+
ai_knows: dict = Field(..., description="What AI knows about the brand")
|
|
38
|
+
recommendations: list[str] = Field(..., description="Actionable recommendations to improve visibility")
|
|
39
|
+
checked_models: list[str] = Field(..., description="Which AI models were checked")
|
|
40
|
+
timestamp: str
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _rate_check(client_ip: str) -> bool:
|
|
44
|
+
"""Returns True if request is allowed, False if rate-limited."""
|
|
45
|
+
now = time.time()
|
|
46
|
+
if client_ip not in _rate_limit:
|
|
47
|
+
_rate_limit[client_ip] = []
|
|
48
|
+
# Prune old entries
|
|
49
|
+
_rate_limit[client_ip] = [t for t in _rate_limit[client_ip] if now - t < _RATE_LIMIT_WINDOW]
|
|
50
|
+
if len(_rate_limit[client_ip]) >= _RATE_LIMIT_MAX:
|
|
51
|
+
return False
|
|
52
|
+
_rate_limit[client_ip].append(now)
|
|
53
|
+
return True
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@router.post("", response_model=BrandCheckResponse)
|
|
57
|
+
async def check_brand_visibility(req: BrandCheckRequest):
|
|
58
|
+
"""
|
|
59
|
+
Check how visible a brand is to AI assistants (ChatGPT, Claude, Gemini).
|
|
60
|
+
|
|
61
|
+
Free tool — no API key required. Rate limited to 10 checks per hour per IP.
|
|
62
|
+
"""
|
|
63
|
+
from fastapi import Request as _Req
|
|
64
|
+
# Rate limiting would use request.client.host in production
|
|
65
|
+
# For now, hash the brand name as pseudo-IP
|
|
66
|
+
pseudo_ip = hashlib.md5(req.brand_name.lower().encode()).hexdigest()[:8]
|
|
67
|
+
if not _rate_check(pseudo_ip):
|
|
68
|
+
raise HTTPException(429, "Rate limit exceeded. Try again in an hour.")
|
|
69
|
+
|
|
70
|
+
# Use the configured LLM to check brand knowledge
|
|
71
|
+
try:
|
|
72
|
+
from behive.engine.llm import complete_async
|
|
73
|
+
except ImportError:
|
|
74
|
+
raise HTTPException(503, "LLM backend not configured. Set BEHIVE_MODEL or an API key.")
|
|
75
|
+
|
|
76
|
+
# Construct the analysis prompt
|
|
77
|
+
url_context = f" (website: {req.url})" if req.url else ""
|
|
78
|
+
analysis_prompt = f"""You are an AI brand visibility analyst. I need you to assess how well-known the brand "{req.brand_name}"{url_context} is to AI systems.
|
|
79
|
+
|
|
80
|
+
Please provide your analysis in the following JSON format (respond ONLY with valid JSON, no markdown):
|
|
81
|
+
{{
|
|
82
|
+
"known": true/false,
|
|
83
|
+
"confidence": 0.0-1.0,
|
|
84
|
+
"category": "what industry/category this brand belongs to",
|
|
85
|
+
"key_facts": ["list of facts you know about this brand"],
|
|
86
|
+
"competitors_mentioned": ["any competitors you associate with this brand"],
|
|
87
|
+
"sentiment": "positive/neutral/negative/unknown",
|
|
88
|
+
"presence_signals": {{
|
|
89
|
+
"has_wikipedia": true/false/unknown,
|
|
90
|
+
"has_news_coverage": true/false/unknown,
|
|
91
|
+
"has_social_media": true/false/unknown,
|
|
92
|
+
"has_reviews": true/false/unknown,
|
|
93
|
+
"has_technical_docs": true/false/unknown
|
|
94
|
+
}},
|
|
95
|
+
"visibility_assessment": "A 2-3 sentence assessment of this brand's AI visibility"
|
|
96
|
+
}}
|
|
97
|
+
|
|
98
|
+
Be honest. If you don't know the brand, say so. Don't hallucinate facts."""
|
|
99
|
+
|
|
100
|
+
try:
|
|
101
|
+
response = await complete_async(
|
|
102
|
+
prompt=analysis_prompt,
|
|
103
|
+
system="You are an AI brand visibility analyst. Respond only with valid JSON.",
|
|
104
|
+
temperature=0.1,
|
|
105
|
+
max_tokens=1000,
|
|
106
|
+
json_mode=True,
|
|
107
|
+
)
|
|
108
|
+
except Exception as e:
|
|
109
|
+
raise HTTPException(503, f"LLM analysis failed: {str(e)[:100]}")
|
|
110
|
+
|
|
111
|
+
# Parse the LLM response
|
|
112
|
+
import json
|
|
113
|
+
try:
|
|
114
|
+
# Try to extract JSON from response
|
|
115
|
+
response_text = response if isinstance(response, str) else str(response)
|
|
116
|
+
# Handle potential markdown wrapping
|
|
117
|
+
if "```json" in response_text:
|
|
118
|
+
response_text = response_text.split("```json")[1].split("```")[0]
|
|
119
|
+
elif "```" in response_text:
|
|
120
|
+
response_text = response_text.split("```")[1].split("```")[0]
|
|
121
|
+
analysis = json.loads(response_text.strip())
|
|
122
|
+
except (json.JSONDecodeError, IndexError):
|
|
123
|
+
# Fallback — brand is likely unknown if we can't parse
|
|
124
|
+
analysis = {
|
|
125
|
+
"known": False,
|
|
126
|
+
"confidence": 0.1,
|
|
127
|
+
"category": "unknown",
|
|
128
|
+
"key_facts": [],
|
|
129
|
+
"competitors_mentioned": [],
|
|
130
|
+
"sentiment": "unknown",
|
|
131
|
+
"presence_signals": {},
|
|
132
|
+
"visibility_assessment": "Could not determine brand visibility."
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
# Calculate visibility score (0-100)
|
|
136
|
+
score = 0.0
|
|
137
|
+
if analysis.get("known", False):
|
|
138
|
+
score += 30 # Base score for being known
|
|
139
|
+
score += min(len(analysis.get("key_facts", [])) * 8, 30) # Facts depth
|
|
140
|
+
score += analysis.get("confidence", 0) * 20 # Confidence bonus
|
|
141
|
+
signals = analysis.get("presence_signals", {})
|
|
142
|
+
signal_count = sum(1 for v in signals.values() if v is True)
|
|
143
|
+
score += signal_count * 4 # Presence signals
|
|
144
|
+
else:
|
|
145
|
+
score = max(5, analysis.get("confidence", 0) * 15) # Minimal score
|
|
146
|
+
|
|
147
|
+
score = min(100, max(0, score))
|
|
148
|
+
|
|
149
|
+
# Generate verdict
|
|
150
|
+
if score >= 80:
|
|
151
|
+
verdict = "🟢 Excellent — AI assistants know your brand well"
|
|
152
|
+
elif score >= 60:
|
|
153
|
+
verdict = "🟡 Good — AI has moderate awareness of your brand"
|
|
154
|
+
elif score >= 30:
|
|
155
|
+
verdict = "🟠 Low — AI barely knows your brand exists"
|
|
156
|
+
else:
|
|
157
|
+
verdict = "🔴 Invisible — AI assistants don't know your brand"
|
|
158
|
+
|
|
159
|
+
# Generate recommendations
|
|
160
|
+
recommendations = []
|
|
161
|
+
if score < 80:
|
|
162
|
+
recommendations.append("Publish structured content (blog posts, docs) that AI can index")
|
|
163
|
+
if not analysis.get("presence_signals", {}).get("has_technical_docs"):
|
|
164
|
+
recommendations.append("Add llms.txt to your website root for AI discoverability")
|
|
165
|
+
if not analysis.get("presence_signals", {}).get("has_wikipedia"):
|
|
166
|
+
recommendations.append("Build authority through citations in third-party sources")
|
|
167
|
+
if score < 50:
|
|
168
|
+
recommendations.append("Create a comprehensive 'About' page with structured data (JSON-LD)")
|
|
169
|
+
recommendations.append("Publish regularly — AI models update knowledge from fresh content")
|
|
170
|
+
if not analysis.get("presence_signals", {}).get("has_reviews"):
|
|
171
|
+
recommendations.append("Get listed on review platforms (G2, Capterra, Trustpilot)")
|
|
172
|
+
recommendations.append("Use BeHive to research what AI says about your competitors")
|
|
173
|
+
|
|
174
|
+
from datetime import datetime, timezone
|
|
175
|
+
|
|
176
|
+
return BrandCheckResponse(
|
|
177
|
+
brand_name=req.brand_name,
|
|
178
|
+
visibility_score=round(score, 1),
|
|
179
|
+
verdict=verdict,
|
|
180
|
+
ai_knows={
|
|
181
|
+
"recognized": analysis.get("known", False),
|
|
182
|
+
"category": analysis.get("category", "unknown"),
|
|
183
|
+
"facts_count": len(analysis.get("key_facts", [])),
|
|
184
|
+
"key_facts": analysis.get("key_facts", [])[:5],
|
|
185
|
+
"competitors_associated": analysis.get("competitors_mentioned", [])[:5],
|
|
186
|
+
"sentiment": analysis.get("sentiment", "unknown"),
|
|
187
|
+
"assessment": analysis.get("visibility_assessment", ""),
|
|
188
|
+
},
|
|
189
|
+
recommendations=recommendations[:6],
|
|
190
|
+
checked_models=["claude-sonnet"], # Will be dynamic based on config
|
|
191
|
+
timestamp=datetime.now(timezone.utc).isoformat(),
|
|
192
|
+
)
|
|
@@ -40,7 +40,7 @@ def main():
|
|
|
40
40
|
research_p.add_argument("--json", action="store_true", help="Output JSON instead of text")
|
|
41
41
|
research_p.add_argument("--api", default=None, help="Remote API URL (default: local DB)")
|
|
42
42
|
research_p.add_argument("--no-db", action="store_true",
|
|
43
|
-
help="Run
|
|
43
|
+
help="Run with DuckDB (zero setup, results saved locally in ~/.behive/)")
|
|
44
44
|
|
|
45
45
|
# ─── status ───────────────────────────────────────────────────────────
|
|
46
46
|
status_p = sub.add_parser("status", help="Check server status")
|
|
@@ -276,18 +276,31 @@ def _check_env():
|
|
|
276
276
|
|
|
277
277
|
async def cmd_research(args):
|
|
278
278
|
"""Run a research mission and print results."""
|
|
279
|
+
import os
|
|
279
280
|
from behive import research, BeHiveClient
|
|
280
281
|
|
|
281
282
|
print(f"\033[33m🐝 Researching: {args.topic}\033[0m")
|
|
282
283
|
print(f" Depth: {args.depth} | Scale: {args.scale or 'auto'}")
|
|
283
284
|
if getattr(args, 'no_db', False):
|
|
284
|
-
print(f" Mode: \033[
|
|
285
|
+
print(f" Mode: \033[36mDuckDB\033[0m (local storage in ~/.behive/research.duckdb)")
|
|
285
286
|
print()
|
|
286
287
|
|
|
287
288
|
if getattr(args, 'no_db', False):
|
|
288
|
-
#
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
# DuckDB mode: set backend env and use normal pipeline
|
|
290
|
+
os.environ["BEHIVE_BACKEND"] = "duckdb"
|
|
291
|
+
# Force re-evaluation of backend
|
|
292
|
+
import behive.engine.db as _db_mod
|
|
293
|
+
_db_mod._backend_override = "duckdb"
|
|
294
|
+
|
|
295
|
+
# Try local pipeline directly
|
|
296
|
+
try:
|
|
297
|
+
from behive.engine.db_duckdb import is_available
|
|
298
|
+
if not is_available():
|
|
299
|
+
print("\033[31m✗ DuckDB not installed. Run: pip install duckdb\033[0m")
|
|
300
|
+
return
|
|
301
|
+
except ImportError:
|
|
302
|
+
print("\033[31m✗ DuckDB not available. Run: pip install 'behive[duckdb]'\033[0m")
|
|
303
|
+
return
|
|
291
304
|
|
|
292
305
|
if args.api:
|
|
293
306
|
client = BeHiveClient(api_url=args.api)
|
|
@@ -819,15 +832,15 @@ def cmd_quickstart():
|
|
|
819
832
|
else:
|
|
820
833
|
print(f" ○ Docker not found (optional)")
|
|
821
834
|
|
|
822
|
-
# Step 3: Quick mode (
|
|
835
|
+
# Step 3: Quick mode (DuckDB)
|
|
823
836
|
print()
|
|
824
|
-
print(" \033[1mOption B:
|
|
837
|
+
print(" \033[1mOption B: Local research (DuckDB, zero setup)\033[0m")
|
|
825
838
|
print(" ┌─────────────────────────────────────────────┐")
|
|
826
839
|
print(" │ behive research 'NVIDIA GPU market' --no-db")
|
|
827
840
|
print(" │")
|
|
828
|
-
print(" │
|
|
829
|
-
print(" │
|
|
830
|
-
print(" │
|
|
841
|
+
print(" │ Uses DuckDB (~/.behive/research.duckdb).")
|
|
842
|
+
print(" │ Results are saved locally. No PostgreSQL.")
|
|
843
|
+
print(" │ Perfect for solo research and prototyping.")
|
|
831
844
|
print(" └─────────────────────────────────────────────┘")
|
|
832
845
|
|
|
833
846
|
# Step 4: Full setup
|
|
@@ -36,6 +36,7 @@ class BeHiveClient:
|
|
|
36
36
|
def _detect_backend(self) -> str:
|
|
37
37
|
if self.api_url:
|
|
38
38
|
return "api"
|
|
39
|
+
# Try PostgreSQL
|
|
39
40
|
try:
|
|
40
41
|
import psycopg2
|
|
41
42
|
url = self.db_url or os.environ.get("DATABASE_URL") or \
|
|
@@ -49,16 +50,23 @@ class BeHiveClient:
|
|
|
49
50
|
return "local"
|
|
50
51
|
except Exception:
|
|
51
52
|
pass
|
|
52
|
-
#
|
|
53
|
+
# Try DuckDB (zero-setup fallback)
|
|
54
|
+
try:
|
|
55
|
+
from behive.engine.db_duckdb import is_available, get_db_path
|
|
56
|
+
if is_available():
|
|
57
|
+
os.environ["BEHIVE_BACKEND"] = "duckdb"
|
|
58
|
+
return "local"
|
|
59
|
+
except ImportError:
|
|
60
|
+
pass
|
|
61
|
+
# No backend available — give clear error
|
|
53
62
|
if not self.api_url:
|
|
54
63
|
raise RuntimeError(
|
|
55
|
-
"No backend configured.
|
|
64
|
+
"No backend configured. Options:\n"
|
|
65
|
+
" • behive research 'topic' --no-db (uses DuckDB, zero setup)\n"
|
|
56
66
|
" • BEHIVE_API_URL=http://localhost:8091 (connect to running server)\n"
|
|
57
|
-
" • DATABASE_URL=postgresql://... (direct
|
|
58
|
-
" • OPENAI_API_KEY or ANTHROPIC_API_KEY (then run: behive serve)\n\n"
|
|
67
|
+
" • DATABASE_URL=postgresql://... (direct PostgreSQL)\n\n"
|
|
59
68
|
"Quick start:\n"
|
|
60
|
-
"
|
|
61
|
-
" 2. behive research 'your topic' (in another terminal)"
|
|
69
|
+
" pip install behive && behive research 'your topic' --no-db"
|
|
62
70
|
)
|
|
63
71
|
return "api"
|
|
64
72
|
|
|
@@ -296,7 +296,100 @@ def _build_url(api: dict, endpoint: dict, topic: str) -> Optional[str]:
|
|
|
296
296
|
# Detect country code from query
|
|
297
297
|
country_code = _detect_country_code(topic)
|
|
298
298
|
|
|
299
|
+
# ── TRADE DATA QUERY BUILDER ──────────────────────────────────
|
|
300
|
+
# For APIs with trade-specific parameters, extract from topic context
|
|
301
|
+
topic_lower = topic.lower()
|
|
302
|
+
|
|
303
|
+
# UN M49 country codes for trade APIs
|
|
304
|
+
M49_CODES = {
|
|
305
|
+
'poland': '616', 'polish': '616', 'polska': '616',
|
|
306
|
+
'south africa': '710', 'brazil': '076', 'argentina': '032',
|
|
307
|
+
'chile': '152', 'paraguay': '600', 'uruguay': '858',
|
|
308
|
+
'kenya': '404', 'nigeria': '566', 'ethiopia': '231',
|
|
309
|
+
'tanzania': '834', 'morocco': '504', 'egypt': '818',
|
|
310
|
+
'ukraine': '804', 'ukrainian': '804', 'ukraina': '804',
|
|
311
|
+
'kazakhstan': '398', 'uzbekistan': '860',
|
|
312
|
+
'vietnam': '704', 'philippines': '608', 'indonesia': '360',
|
|
313
|
+
'germany': '276', 'france': '250', 'uk': '826', 'united kingdom': '826',
|
|
314
|
+
'usa': '842', 'united states': '842',
|
|
315
|
+
'turkey': '792', 'india': '356', 'china': '156', 'japan': '392',
|
|
316
|
+
'canada': '124', 'australia': '036', 'mexico': '484',
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
# HS codes for agricultural machinery
|
|
320
|
+
HS_CODES = {
|
|
321
|
+
'tractor': '8701', 'tractors': '8701', 'ciągnik': '8701',
|
|
322
|
+
'plow': '8432', 'plough': '8432', 'cultivat': '8432', 'soil': '8432',
|
|
323
|
+
'maszyn': '8432', 'machin': '8432', 'implement': '8432',
|
|
324
|
+
'harvester': '8433', 'mower': '8433', 'combine': '8433', 'kosiark': '8433',
|
|
325
|
+
'milking': '8434', 'dairy equipment': '8434',
|
|
326
|
+
'seeder': '8436', 'other ag': '8436',
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
# Detect reporter/partner from topic
|
|
330
|
+
detected_reporter = '616' # Default: Poland
|
|
331
|
+
detected_partner = '0' # Default: World
|
|
332
|
+
detected_hs = '8432' # Default: soil prep machinery
|
|
333
|
+
detected_flow = 'X' # Default: exports
|
|
334
|
+
|
|
335
|
+
# Sort by length descending to avoid "uk" matching "ukraine"
|
|
336
|
+
sorted_countries = sorted(M49_CODES.items(), key=lambda x: -len(x[0]))
|
|
337
|
+
|
|
338
|
+
# First pass: identify all mentioned countries
|
|
339
|
+
mentioned_countries = []
|
|
340
|
+
for country, code in sorted_countries:
|
|
341
|
+
if re.search(r'\b' + re.escape(country) + r'\b', topic_lower):
|
|
342
|
+
mentioned_countries.append((country, code))
|
|
343
|
+
|
|
344
|
+
# Determine flow direction from explicit verbs near Poland
|
|
345
|
+
poland_export = bool(re.search(r'pol(?:and|ish|ska).*(?:export|eksport)', topic_lower))
|
|
346
|
+
poland_import = bool(re.search(r'pol(?:and|ish|ska).*import', topic_lower))
|
|
347
|
+
|
|
348
|
+
if poland_export:
|
|
349
|
+
detected_flow = 'X'
|
|
350
|
+
detected_reporter = '616'
|
|
351
|
+
elif poland_import:
|
|
352
|
+
detected_flow = 'M'
|
|
353
|
+
detected_reporter = '616'
|
|
354
|
+
|
|
355
|
+
# Assign partner: first non-Poland country mentioned
|
|
356
|
+
for country, code in mentioned_countries:
|
|
357
|
+
if code != '616':
|
|
358
|
+
# Check explicit patterns
|
|
359
|
+
from_pattern = re.search(r'from\s+' + re.escape(country) + r'\b', topic_lower)
|
|
360
|
+
to_pattern = re.search(r'to\s+' + re.escape(country) + r'\b', topic_lower)
|
|
361
|
+
|
|
362
|
+
if from_pattern:
|
|
363
|
+
detected_partner = code
|
|
364
|
+
elif to_pattern:
|
|
365
|
+
detected_partner = code
|
|
366
|
+
else:
|
|
367
|
+
# Default: non-Poland country is the partner
|
|
368
|
+
detected_partner = code
|
|
369
|
+
break # Take first non-Poland country as primary partner
|
|
370
|
+
|
|
371
|
+
# Collect ALL non-Poland partners for multi-URL queries (used by Comtrade)
|
|
372
|
+
_all_partners = [code for _, code in mentioned_countries if code != '616']
|
|
373
|
+
if not _all_partners:
|
|
374
|
+
_all_partners = ['0'] # World
|
|
375
|
+
|
|
376
|
+
for keyword, hs in HS_CODES.items():
|
|
377
|
+
if keyword in topic_lower:
|
|
378
|
+
detected_hs = hs
|
|
379
|
+
break
|
|
380
|
+
|
|
381
|
+
# NIP detection for Polish APIs
|
|
382
|
+
nip_match = re.search(r'\b(\d{10})\b', topic)
|
|
383
|
+
detected_nip = nip_match.group(1) if nip_match else ''
|
|
384
|
+
|
|
385
|
+
# KRS detection
|
|
386
|
+
krs_match = re.search(r'\b(\d{7,10})\b', topic)
|
|
387
|
+
detected_krs = krs_match.group(1).zfill(10) if krs_match else ''
|
|
388
|
+
|
|
299
389
|
# Standard substitutions
|
|
390
|
+
from datetime import date
|
|
391
|
+
today = date.today().isoformat()
|
|
392
|
+
|
|
300
393
|
subs = {
|
|
301
394
|
"{topic}": topic_encoded,
|
|
302
395
|
"{query}": topic_encoded,
|
|
@@ -311,15 +404,30 @@ def _build_url(api: dict, endpoint: dict, topic: str) -> Optional[str]:
|
|
|
311
404
|
"{ip}": topic_encoded,
|
|
312
405
|
"{tag}": topic_encoded,
|
|
313
406
|
"{base}": "USD",
|
|
314
|
-
"{date}":
|
|
407
|
+
"{date}": today,
|
|
315
408
|
"{from}": "2024-01-01",
|
|
316
409
|
"{to}": "2025-01-01",
|
|
317
|
-
"{year}": "
|
|
318
|
-
"{
|
|
410
|
+
"{year}": "2023",
|
|
411
|
+
"{year_start}": "2020",
|
|
412
|
+
"{year_end}": "2024",
|
|
413
|
+
"{start}": "2020",
|
|
414
|
+
"{end}": "2024",
|
|
415
|
+
"{fips}": "06",
|
|
319
416
|
"{subreddit}": "technology",
|
|
320
417
|
"{cat}": "technology",
|
|
321
418
|
"{cve_id}": topic_encoded,
|
|
322
419
|
"{code}": country_code,
|
|
420
|
+
# Trade-specific
|
|
421
|
+
"{reporter}": detected_reporter,
|
|
422
|
+
"{partner}": detected_partner,
|
|
423
|
+
"{hs_code}": detected_hs,
|
|
424
|
+
"{flow}": detected_flow,
|
|
425
|
+
"{product}": detected_hs,
|
|
426
|
+
# Polish APIs
|
|
427
|
+
"{nip}": detected_nip,
|
|
428
|
+
"{krs_number}": detected_krs,
|
|
429
|
+
"{keyword}": topic_encoded,
|
|
430
|
+
"{var_id}": "217230", # Default: CPI
|
|
323
431
|
}
|
|
324
432
|
|
|
325
433
|
for var, val in subs.items():
|
|
@@ -338,7 +446,8 @@ def _build_url(api: dict, endpoint: dict, topic: str) -> Optional[str]:
|
|
|
338
446
|
|
|
339
447
|
# Any remaining unresolved vars?
|
|
340
448
|
if re.search(r'\{[^}]+\}', path):
|
|
341
|
-
|
|
449
|
+
# Try to fill with topic-derived best guess
|
|
450
|
+
path = re.sub(r'\{[^}]+\}', topic_encoded, path)
|
|
342
451
|
|
|
343
452
|
# Build full URL
|
|
344
453
|
if path.startswith("http"):
|
|
@@ -375,7 +484,17 @@ async def query_api(match: 'APIMatch', topic: str, session: aiohttp.ClientSessio
|
|
|
375
484
|
|
|
376
485
|
async with session.get(url, timeout=aiohttp.ClientTimeout(total=timeout),
|
|
377
486
|
headers=headers) as resp:
|
|
378
|
-
if resp.status
|
|
487
|
+
if resp.status == 429:
|
|
488
|
+
# Rate limited — wait and retry once
|
|
489
|
+
log.debug(f" API {api['name']}: HTTP 429 (rate limited), retrying...")
|
|
490
|
+
await asyncio.sleep(2.0)
|
|
491
|
+
async with session.get(url, timeout=aiohttp.ClientTimeout(total=timeout),
|
|
492
|
+
headers=headers) as retry_resp:
|
|
493
|
+
if retry_resp.status != 200:
|
|
494
|
+
log.debug(f" API {api['name']}: retry HTTP {retry_resp.status}")
|
|
495
|
+
return None
|
|
496
|
+
resp = retry_resp
|
|
497
|
+
elif resp.status != 200:
|
|
379
498
|
log.debug(f" API {api['name']}: HTTP {resp.status}")
|
|
380
499
|
return None
|
|
381
500
|
|
|
@@ -605,9 +724,49 @@ async def scout_apis(query: str, max_results: int = 12,
|
|
|
605
724
|
# Query matched APIs in parallel
|
|
606
725
|
docs = []
|
|
607
726
|
async with aiohttp.ClientSession() as session:
|
|
608
|
-
tasks = [
|
|
727
|
+
tasks = []
|
|
728
|
+
_comtrade_extra_queries = [] # Sequential to avoid rate limiting
|
|
729
|
+
for m in matches:
|
|
730
|
+
tasks.append(query_api(m, query, session, timeout_per_api))
|
|
731
|
+
# For trade APIs with multiple target countries — collect for sequential execution
|
|
732
|
+
if m.api.get('name', '') == 'UN Comtrade':
|
|
733
|
+
# Detect all mentioned partners from query
|
|
734
|
+
_q_lower = query.lower()
|
|
735
|
+
_m49 = {
|
|
736
|
+
'south africa': '710', 'brazil': '076', 'argentina': '032',
|
|
737
|
+
'chile': '152', 'ukraine': '804', 'kenya': '404',
|
|
738
|
+
'nigeria': '566', 'ethiopia': '231', 'tanzania': '834',
|
|
739
|
+
'kazakhstan': '398', 'turkey': '792', 'egypt': '818',
|
|
740
|
+
'morocco': '504', 'vietnam': '704', 'indonesia': '360',
|
|
741
|
+
'canada': '124', 'australia': '036', 'india': '356',
|
|
742
|
+
}
|
|
743
|
+
_partners_found = []
|
|
744
|
+
for cname, ccode in sorted(_m49.items(), key=lambda x: -len(x[0])):
|
|
745
|
+
if re.search(r'\b' + re.escape(cname) + r'\b', _q_lower):
|
|
746
|
+
_partners_found.append((cname, ccode))
|
|
747
|
+
# If >1 partner mentioned, queue additional queries
|
|
748
|
+
if len(_partners_found) > 1:
|
|
749
|
+
for cname, ccode in _partners_found[1:]: # Skip first (already in default)
|
|
750
|
+
_comtrade_extra_queries.append((m, f"Poland export {cname} HS 8432 agricultural machinery"))
|
|
751
|
+
|
|
609
752
|
results = await asyncio.gather(*tasks, return_exceptions=True)
|
|
610
753
|
|
|
754
|
+
# Run Comtrade fan-out queries sequentially with delay to avoid rate limiting
|
|
755
|
+
for _ct_match, _ct_query in _comtrade_extra_queries:
|
|
756
|
+
await asyncio.sleep(1.5) # 1.5s between requests (Comtrade rate limit ~1req/s)
|
|
757
|
+
for _retry in range(2):
|
|
758
|
+
try:
|
|
759
|
+
_ct_result = await query_api(_ct_match, _ct_query, session, timeout_per_api)
|
|
760
|
+
if _ct_result:
|
|
761
|
+
results.append(_ct_result)
|
|
762
|
+
break
|
|
763
|
+
elif _retry == 0:
|
|
764
|
+
await asyncio.sleep(2.0) # Extra wait on None (might be soft 429)
|
|
765
|
+
except Exception as _ct_err:
|
|
766
|
+
if _retry == 0:
|
|
767
|
+
await asyncio.sleep(2.0)
|
|
768
|
+
results.append(_ct_err)
|
|
769
|
+
|
|
611
770
|
for i, result in enumerate(results):
|
|
612
771
|
if isinstance(result, Exception):
|
|
613
772
|
continue
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Context Providers for Queen Honey Context Builder.
|
|
3
|
+
|
|
4
|
+
Each provider renders ONE section of the intelligence context prompt.
|
|
5
|
+
The dispatcher iterates all providers in order, collecting lines.
|
|
6
|
+
|
|
7
|
+
Original: Queen._build_honey_context (CC=135, 430 lines, synth.py:412)
|
|
8
|
+
Refactored: 16 small providers (CC ~5-12 each) + dispatcher (CC ~5)
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from .base import ContextProvider, HoneyContext
|
|
12
|
+
from .dispatcher import build_honey_context, PROVIDERS
|
|
13
|
+
|
|
14
|
+
__all__ = ["ContextProvider", "HoneyContext", "build_honey_context", "PROVIDERS"]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Base class for context providers.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
import re
|
|
8
|
+
from abc import ABC, abstractmethod
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from typing import Any
|
|
11
|
+
from urllib.parse import urlparse
|
|
12
|
+
|
|
13
|
+
log = logging.getLogger("singularity")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class HoneyContext:
|
|
18
|
+
"""Shared context passed to all providers."""
|
|
19
|
+
honey: dict
|
|
20
|
+
mission: dict = field(init=False)
|
|
21
|
+
mission_id: str = ""
|
|
22
|
+
lines: list = field(default_factory=list)
|
|
23
|
+
|
|
24
|
+
def __post_init__(self):
|
|
25
|
+
self.mission = self.honey.get("mission", {})
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ContextProvider(ABC):
|
|
29
|
+
"""Base class for a context section renderer."""
|
|
30
|
+
|
|
31
|
+
section_name: str = "" # Override in subclass
|
|
32
|
+
|
|
33
|
+
@abstractmethod
|
|
34
|
+
def render(self, ctx: HoneyContext) -> list[str]:
|
|
35
|
+
"""Return lines for this section. Empty list = skip section."""
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
def applies(self, ctx: HoneyContext) -> bool:
|
|
39
|
+
"""Override to conditionally skip this provider."""
|
|
40
|
+
return True
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# ═══════════════════════════════════════════════════════════════════════════════
|
|
44
|
+
# SHARED UTILITIES (used by multiple providers)
|
|
45
|
+
# ═══════════════════════════════════════════════════════════════════════════════
|
|
46
|
+
|
|
47
|
+
NUM_PATTERN = re.compile(
|
|
48
|
+
r'\b(\d[\d\s]*[\d](?:[.,]\d+)?)\s*'
|
|
49
|
+
r'(%|PLN|EUR|USD|GBP|zł|mln|tys|k|M|B|GB|TB|ms|s|min|h|'
|
|
50
|
+
r'dni|miesięcy|lat|gwiazdek|users|klientów|pracowników|firm|'
|
|
51
|
+
r'projektów|calls|req|rps|stars|downloads|installs|seats|licenses)\b',
|
|
52
|
+
re.IGNORECASE
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def parse_domains_json(domains_json: Any) -> list[str]:
|
|
57
|
+
"""Safely parse domains from JSON or list."""
|
|
58
|
+
if isinstance(domains_json, list):
|
|
59
|
+
return domains_json
|
|
60
|
+
if isinstance(domains_json, str) and domains_json:
|
|
61
|
+
try:
|
|
62
|
+
return json.loads(domains_json)
|
|
63
|
+
except (json.JSONDecodeError, ValueError):
|
|
64
|
+
pass
|
|
65
|
+
return []
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def extract_domain(url: str) -> str:
|
|
69
|
+
"""Extract clean domain from URL."""
|
|
70
|
+
if not url:
|
|
71
|
+
return ""
|
|
72
|
+
try:
|
|
73
|
+
return urlparse(url).netloc.replace("www.", "")
|
|
74
|
+
except Exception:
|
|
75
|
+
return ""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def safe_conf(conf: Any) -> str:
|
|
79
|
+
"""Safely format confidence value."""
|
|
80
|
+
try:
|
|
81
|
+
return f"{float(conf):.2f}"
|
|
82
|
+
except Exception:
|
|
83
|
+
return str(conf)
|