contextsynapse 1.0.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.
- contextsynapse/__init__.py +107 -0
- contextsynapse/__main__.py +9 -0
- contextsynapse/a2a/__init__.py +28 -0
- contextsynapse/a2a/client.py +120 -0
- contextsynapse/a2a/discovery.py +128 -0
- contextsynapse/a2a/handlers.py +164 -0
- contextsynapse/a2a/models.py +246 -0
- contextsynapse/a2a/streaming.py +92 -0
- contextsynapse/a2a/task_manager.py +275 -0
- contextsynapse/adapters/__init__.py +98 -0
- contextsynapse/adapters/_base.py +298 -0
- contextsynapse/adapters/autogen/__init__.py +4 -0
- contextsynapse/adapters/autogen/tools.py +34 -0
- contextsynapse/adapters/crewai/__init__.py +4 -0
- contextsynapse/adapters/crewai/tools.py +63 -0
- contextsynapse/adapters/langchain/__init__.py +19 -0
- contextsynapse/adapters/langchain/message_history.py +17 -0
- contextsynapse/adapters/langchain/retriever.py +158 -0
- contextsynapse/adapters/langchain/tools.py +43 -0
- contextsynapse/adapters/langgraph/__init__.py +21 -0
- contextsynapse/adapters/langgraph/checkpoint.py +223 -0
- contextsynapse/adapters/langgraph/context_tools.py +341 -0
- contextsynapse/adapters/langgraph/message_history.py +138 -0
- contextsynapse/adapters/langgraph/tools.py +43 -0
- contextsynapse/adapters/llamaindex/__init__.py +4 -0
- contextsynapse/adapters/llamaindex/tools.py +64 -0
- contextsynapse/adapters/openai/__init__.py +24 -0
- contextsynapse/adapters/openai/tools.py +206 -0
- contextsynapse/adapters/pydantic_ai/__init__.py +4 -0
- contextsynapse/adapters/pydantic_ai/tools.py +36 -0
- contextsynapse/adapters/swarm/__init__.py +4 -0
- contextsynapse/adapters/swarm/tools.py +44 -0
- contextsynapse/agents/__init__.py +6 -0
- contextsynapse/agents/auto_capture.py +80 -0
- contextsynapse/agents/dispatcher.py +299 -0
- contextsynapse/agents/notifications.py +112 -0
- contextsynapse/aiql/__init__.py +71 -0
- contextsynapse/aiql/cache.py +341 -0
- contextsynapse/aiql/compiler/__init__.py +62 -0
- contextsynapse/aiql/compiler/optimizer.py +126 -0
- contextsynapse/aiql/compiler/planner.py +366 -0
- contextsynapse/aiql/compiler/statistics.py +235 -0
- contextsynapse/aiql/compiler/validator.py +425 -0
- contextsynapse/aiql/engine/__init__.py +11 -0
- contextsynapse/aiql/engine/chunk_storage.py +2584 -0
- contextsynapse/aiql/engine/executor.py +7737 -0
- contextsynapse/aiql/engine/extraction_integration.py +442 -0
- contextsynapse/aiql/engine/graph_builder.py +405 -0
- contextsynapse/aiql/engine/node_creation_from_normalized.py +691 -0
- contextsynapse/aiql/engine/performance_monitor.py +289 -0
- contextsynapse/aiql/engine/postprocessing.py +365 -0
- contextsynapse/aiql/engine/ray_stage_executors.py +918 -0
- contextsynapse/aiql/engine/redis_cache.py +106 -0
- contextsynapse/aiql/engine/streaming_json.py +366 -0
- contextsynapse/aiql/engine/streaming_parquet.py +568 -0
- contextsynapse/aiql/engine/streaming_ray_chunking.py +419 -0
- contextsynapse/aiql/grammar/__init__.py +14 -0
- contextsynapse/aiql/grammar/aiql_grammar.py +1822 -0
- contextsynapse/aiql/grammar/base.py +71 -0
- contextsynapse/aiql/parser/__init__.py +46 -0
- contextsynapse/aiql/parser/aiql_parser.py +11330 -0
- contextsynapse/aiql/parser/base_parser.py +47 -0
- contextsynapse/api/__init__.py +5 -0
- contextsynapse/api/a2a_router.py +233 -0
- contextsynapse/api/admin_router.py +140 -0
- contextsynapse/api/agent_worker_router.py +978 -0
- contextsynapse/api/algorithms_router.py +317 -0
- contextsynapse/api/api.py +4144 -0
- contextsynapse/api/audit.py +204 -0
- contextsynapse/api/auth.py +441 -0
- contextsynapse/api/auth_router.py +537 -0
- contextsynapse/api/billing.py +261 -0
- contextsynapse/api/billing_router.py +275 -0
- contextsynapse/api/boundary_router.py +452 -0
- contextsynapse/api/cognition_router.py +116 -0
- contextsynapse/api/connector_router.py +237 -0
- contextsynapse/api/context_router.py +1619 -0
- contextsynapse/api/dashboard_router.py +11367 -0
- contextsynapse/api/errors.py +183 -0
- contextsynapse/api/events.py +88 -0
- contextsynapse/api/experiment_bootstrap.py +321 -0
- contextsynapse/api/experiment_orchestrator.py +1078 -0
- contextsynapse/api/experiment_router.py +2089 -0
- contextsynapse/api/feature_gate.py +89 -0
- contextsynapse/api/federation_router.py +108 -0
- contextsynapse/api/integrations.py +567 -0
- contextsynapse/api/integrations_router.py +461 -0
- contextsynapse/api/intelligence_router.py +1028 -0
- contextsynapse/api/metering.py +155 -0
- contextsynapse/api/metrics.py +112 -0
- contextsynapse/api/models.py +38 -0
- contextsynapse/api/monitoring_router.py +174 -0
- contextsynapse/api/pipeline_router.py +1437 -0
- contextsynapse/api/playground_conn.py +116 -0
- contextsynapse/api/projects_router.py +131 -0
- contextsynapse/api/queries_router.py +282 -0
- contextsynapse/api/quota.py +95 -0
- contextsynapse/api/rate_limit.py +64 -0
- contextsynapse/api/search_router.py +261 -0
- contextsynapse/api/shield_router.py +447 -0
- contextsynapse/api/tenant_guard.py +103 -0
- contextsynapse/api/tenant_quotas.py +231 -0
- contextsynapse/api/tenants.py +305 -0
- contextsynapse/api/users.py +646 -0
- contextsynapse/api/v1.py +167 -0
- contextsynapse/api/vertical_builder_router.py +387 -0
- contextsynapse/benchmark/__init__.py +15 -0
- contextsynapse/benchmark/__main__.py +64 -0
- contextsynapse/benchmark/agents.py +338 -0
- contextsynapse/benchmark/live_ab.py +338 -0
- contextsynapse/benchmark/reporter.py +149 -0
- contextsynapse/benchmark/runner.py +264 -0
- contextsynapse/benchmark/savings.py +266 -0
- contextsynapse/benchmark/token_counter.py +212 -0
- contextsynapse/benchmark/workloads.py +289 -0
- contextsynapse/buffer/__init__.py +154 -0
- contextsynapse/buffer/base.py +257 -0
- contextsynapse/buffer/duckdb_buffer.py +246 -0
- contextsynapse/buffer/file_buffer.py +229 -0
- contextsynapse/buffer/lmdb_buffer.py +286 -0
- contextsynapse/buffer/local_buffer.py +154 -0
- contextsynapse/buffer/redis_buffer.py +211 -0
- contextsynapse/buffer/sqlite_buffer.py +266 -0
- contextsynapse/cache.py +2 -0
- contextsynapse/cli/__init__.py +40 -0
- contextsynapse/cli/cli.py +475 -0
- contextsynapse/cli/config_cli.py +177 -0
- contextsynapse/cli/scaffold.py +465 -0
- contextsynapse/cognition/__init__.py +31 -0
- contextsynapse/cognition/derivation.py +55 -0
- contextsynapse/cognition/events.py +135 -0
- contextsynapse/cognition/feedback.py +52 -0
- contextsynapse/cognition/hallucination.py +90 -0
- contextsynapse/cognition/invalidation.py +70 -0
- contextsynapse/cognition/read_tracker.py +50 -0
- contextsynapse/collaboration.py +2 -0
- contextsynapse/comparison.py +2 -0
- contextsynapse/config/__init__.py +10 -0
- contextsynapse/config/connectors/amfi_nav.yaml +18 -0
- contextsynapse/config/connectors/auto_sector.yaml +20 -0
- contextsynapse/config/connectors/banking_sector.yaml +20 -0
- contextsynapse/config/connectors/energy_sector.yaml +20 -0
- contextsynapse/config/connectors/fmcg_sector.yaml +20 -0
- contextsynapse/config/connectors/nsdl_fpi.yaml +9 -0
- contextsynapse/config/connectors/nse_price.yaml +61 -0
- contextsynapse/config/connectors/pharma_sector.yaml +20 -0
- contextsynapse/config/connectors/rbi_dbie.yaml +12 -0
- contextsynapse/config/context_presets/ai_research.json +25 -0
- contextsynapse/config/context_presets/chatgpt_conversations.json +19 -0
- contextsynapse/config/context_presets/claude_conversations.json +19 -0
- contextsynapse/config/context_presets/legal_compliance.json +21 -0
- contextsynapse/config/context_presets/meeting_notes.json +21 -0
- contextsynapse/config/context_presets/slack_engineering.json +21 -0
- contextsynapse/config/context_presets/tech_climate.json +24 -0
- contextsynapse/config/context_presets/toi_politics.json +25 -0
- contextsynapse/config/database_config.py +453 -0
- contextsynapse/config/deployment.py +221 -0
- contextsynapse/config/gpt_action_schema.json +164 -0
- contextsynapse/config/indicators/india_macro.yaml +213 -0
- contextsynapse/config/logging_config.py +88 -0
- contextsynapse/config/mode_config.py +223 -0
- contextsynapse/config/schemas/api_spec.yaml +48 -0
- contextsynapse/config/schemas/architecture_doc.yaml +51 -0
- contextsynapse/config/schemas/chat_history.yaml +90 -0
- contextsynapse/config/schemas/chatgpt_conversation.yaml +101 -0
- contextsynapse/config/schemas/claude_conversation.yaml +148 -0
- contextsynapse/config/schemas/contract.yaml +48 -0
- contextsynapse/config/schemas/conversation.yaml +167 -0
- contextsynapse/config/schemas/database.yaml +74 -0
- contextsynapse/config/schemas/decision.yaml +72 -0
- contextsynapse/config/schemas/ecommerce.yaml +56 -0
- contextsynapse/config/schemas/education.yaml +42 -0
- contextsynapse/config/schemas/healthcare.yaml +133 -0
- contextsynapse/config/schemas/hr_document.yaml +48 -0
- contextsynapse/config/schemas/invoice.yaml +40 -0
- contextsynapse/config/schemas/knowledge_base.yaml +75 -0
- contextsynapse/config/schemas/legal.yaml +42 -0
- contextsynapse/config/schemas/marketing_content.yaml +48 -0
- contextsynapse/config/schemas/meeting_notes.yaml +51 -0
- contextsynapse/config/schemas/news_article.yaml +61 -0
- contextsynapse/config/schemas/real_estate.yaml +49 -0
- contextsynapse/config/schemas/requirements_doc.yaml +48 -0
- contextsynapse/config/schemas/research_paper.yaml +56 -0
- contextsynapse/config/schemas/resume.yaml +49 -0
- contextsynapse/config/schemas/retail.yaml +42 -0
- contextsynapse/config/schemas/rule_meta.yaml +173 -0
- contextsynapse/config/schemas/rules.yaml +72 -0
- contextsynapse/config/schemas/screener_meta.yaml +236 -0
- contextsynapse/config/schemas/sdlc.yaml +103 -0
- contextsynapse/config/schemas/session_graph.yaml +172 -0
- contextsynapse/config/schemas/support_ticket.yaml +48 -0
- contextsynapse/config/schemas/web.yaml +64 -0
- contextsynapse/config/sensors/earnings_calendar.yaml +52 -0
- contextsynapse/config/sensors/global_risk.yaml +53 -0
- contextsynapse/config/sensors/government_policy.yaml +54 -0
- contextsynapse/config/sensors/supply_chain.yaml +50 -0
- contextsynapse/config/sensors/templates/behavioral.yaml +56 -0
- contextsynapse/config/sensors/templates/equity_sentiment.yaml +48 -0
- contextsynapse/config/sensors/templates/global_macro.yaml +47 -0
- contextsynapse/config/sensors/templates/market_data.yaml +118 -0
- contextsynapse/config/sensors/templates/sector_technical.yaml +47 -0
- contextsynapse/config/sensors/weather.yaml +52 -0
- contextsynapse/config/storage_strategy.py +202 -0
- contextsynapse/config/templates/competitive_intel.yaml +39 -0
- contextsynapse/config/templates/geopolitical_risk.yaml +46 -0
- contextsynapse/config/templates/market_analysis.yaml +58 -0
- contextsynapse/connectors/__init__.py +15 -0
- contextsynapse/connectors/api_router.py +121 -0
- contextsynapse/connectors/base.py +357 -0
- contextsynapse/connectors/financial/audio.py +170 -0
- contextsynapse/connectors/financial/youtube.py +272 -0
- contextsynapse/connectors/github.py +164 -0
- contextsynapse/connectors/jira.py +120 -0
- contextsynapse/connectors/kafka_connector.py +124 -0
- contextsynapse/connectors/pipeline_connector.py +747 -0
- contextsynapse/connectors/registry.py +116 -0
- contextsynapse/connectors/scheduler.py +87 -0
- contextsynapse/connectors/universal.py +360 -0
- contextsynapse/context/__init__.py +96 -0
- contextsynapse/context/__main__.py +4 -0
- contextsynapse/context/acl.py +125 -0
- contextsynapse/context/agent_card.py +201 -0
- contextsynapse/context/agent_memory.py +814 -0
- contextsynapse/context/agents.py +472 -0
- contextsynapse/context/agents_redis.py +391 -0
- contextsynapse/context/assembled.py +204 -0
- contextsynapse/context/attribution.py +113 -0
- contextsynapse/context/blob.py +184 -0
- contextsynapse/context/boundaries.py +187 -0
- contextsynapse/context/boundary.py +507 -0
- contextsynapse/context/bundle.py +155 -0
- contextsynapse/context/cli.py +519 -0
- contextsynapse/context/collaboration.py +165 -0
- contextsynapse/context/compiler.py +604 -0
- contextsynapse/context/composite.py +536 -0
- contextsynapse/context/compression.py +147 -0
- contextsynapse/context/context_manager.py +888 -0
- contextsynapse/context/context_schema.py +90 -0
- contextsynapse/context/context_schema.yaml +105 -0
- contextsynapse/context/context_units.py +891 -0
- contextsynapse/context/conversation.py +488 -0
- contextsynapse/context/dedup.py +207 -0
- contextsynapse/context/document_processor.py +698 -0
- contextsynapse/context/embedding_hooks.py +338 -0
- contextsynapse/context/execution_schema.py +274 -0
- contextsynapse/context/fan_out.py +138 -0
- contextsynapse/context/frozen.py +80 -0
- contextsynapse/context/gravity.py +227 -0
- contextsynapse/context/hub.py +1401 -0
- contextsynapse/context/ingest.py +391 -0
- contextsynapse/context/injection.py +226 -0
- contextsynapse/context/interaction_graphifier.py +562 -0
- contextsynapse/context/layers.py +574 -0
- contextsynapse/context/projection.py +1195 -0
- contextsynapse/context/promotion.py +634 -0
- contextsynapse/context/proof.py +131 -0
- contextsynapse/context/propagation.py +577 -0
- contextsynapse/context/pubsub.py +135 -0
- contextsynapse/context/quality.py +1054 -0
- contextsynapse/context/quality_tracker.py +270 -0
- contextsynapse/context/scoping.py +370 -0
- contextsynapse/context/seed.py +992 -0
- contextsynapse/context/session.py +1142 -0
- contextsynapse/context/session_graph.py +593 -0
- contextsynapse/context/session_memory.py +309 -0
- contextsynapse/context/session_resolver.py +111 -0
- contextsynapse/context/skill_learning.py +237 -0
- contextsynapse/context/smart_budget.py +129 -0
- contextsynapse/context/source_policy.py +242 -0
- contextsynapse/context/store_factory.py +53 -0
- contextsynapse/context/sync.py +648 -0
- contextsynapse/context/token.py +236 -0
- contextsynapse/context/vector_integration.py +297 -0
- contextsynapse/context/webhooks.py +194 -0
- contextsynapse/context/working_memory.py +224 -0
- contextsynapse/core/__init__.py +18 -0
- contextsynapse/core/archiver.py +237 -0
- contextsynapse/core/change_stream.py +282 -0
- contextsynapse/core/checkpoint.py +310 -0
- contextsynapse/core/cloud_storage.py +387 -0
- contextsynapse/core/context_state.py +651 -0
- contextsynapse/core/cron.py +324 -0
- contextsynapse/core/datasource.py +643 -0
- contextsynapse/core/db.py +289 -0
- contextsynapse/core/federation.py +283 -0
- contextsynapse/core/graph_coordinator.py +201 -0
- contextsynapse/core/graph_intelligence.py +388 -0
- contextsynapse/core/graph_structures.py +106 -0
- contextsynapse/core/graph_sync.py +157 -0
- contextsynapse/core/hybrid_graph_storage.py +2998 -0
- contextsynapse/core/lifecycle.py +691 -0
- contextsynapse/core/multiworker.py +378 -0
- contextsynapse/core/pruning.py +312 -0
- contextsynapse/core/redis_registry.py +524 -0
- contextsynapse/core/registry.py +1043 -0
- contextsynapse/core/registry_factory.py +51 -0
- contextsynapse/core/registry_metadata.py +294 -0
- contextsynapse/core/replay.py +354 -0
- contextsynapse/core/replication.py +339 -0
- contextsynapse/core/time_travel.py +260 -0
- contextsynapse/core/write_behind.py +152 -0
- contextsynapse/core/write_context.py +39 -0
- contextsynapse/db/__init__.py +1 -0
- contextsynapse/db/postgres.py +267 -0
- contextsynapse/db/profile.py +236 -0
- contextsynapse/db/rules.py +328 -0
- contextsynapse/demo/__init__.py +0 -0
- contextsynapse/demo/report.py +147 -0
- contextsynapse/demo/runner.py +520 -0
- contextsynapse/demo/scenario.py +165 -0
- contextsynapse/demo/session_demo.py +280 -0
- contextsynapse/demo/session_report.py +143 -0
- contextsynapse/demo/universal_runner.py +257 -0
- contextsynapse/engine/__init__.py +15 -0
- contextsynapse/engine/core.py +555 -0
- contextsynapse/extraction/__init__.py +69 -0
- contextsynapse/extraction/cli.py +274 -0
- contextsynapse/extraction/config.py +107 -0
- contextsynapse/extraction/examples/example_usage.py +118 -0
- contextsynapse/extraction/examples/sample_manifest.json +53 -0
- contextsynapse/extraction/examples/sample_normalized.json +185 -0
- contextsynapse/extraction/extract_engine.py +440 -0
- contextsynapse/extraction/extractors/__init__.py +37 -0
- contextsynapse/extraction/extractors/chat_export_extractor.py +189 -0
- contextsynapse/extraction/extractors/csv_extractor.py +83 -0
- contextsynapse/extraction/extractors/docx_extractor.py +129 -0
- contextsynapse/extraction/extractors/excel_extractor.py +152 -0
- contextsynapse/extraction/extractors/html_extractor.py +146 -0
- contextsynapse/extraction/extractors/pdf_extractor.py +635 -0
- contextsynapse/extraction/extractors/pdf_extractor_layoutparser.py +408 -0
- contextsynapse/extraction/extractors/register_extractors.py +63 -0
- contextsynapse/extraction/extractors/text_extractor.py +65 -0
- contextsynapse/extraction/extractors/txt_extractor.py +120 -0
- contextsynapse/extraction/extractors/website_extractor.py +246 -0
- contextsynapse/extraction/fact_extractor.py +236 -0
- contextsynapse/extraction/file_manager.py +353 -0
- contextsynapse/extraction/hierarchy.py +239 -0
- contextsynapse/extraction/id_generator.py +450 -0
- contextsynapse/extraction/layout_detector.py +409 -0
- contextsynapse/extraction/llm_entity_extractor.py +301 -0
- contextsynapse/extraction/normalized_store.py +480 -0
- contextsynapse/extraction/normalizer.py +594 -0
- contextsynapse/extraction/parquet_writer.py +598 -0
- contextsynapse/extraction/post_processors/__init__.py +40 -0
- contextsynapse/extraction/post_processors/column_reorganizer.py +507 -0
- contextsynapse/extraction/ray_normalization.py +233 -0
- contextsynapse/extraction/ray_runner.py +207 -0
- contextsynapse/extraction/redis_schema_registry.py +222 -0
- contextsynapse/extraction/registry.py +204 -0
- contextsynapse/extraction/schema_loader.py +663 -0
- contextsynapse/extraction/schema_registry.py +230 -0
- contextsynapse/extraction/semantic_normalizer.py +245 -0
- contextsynapse/extraction/version_manager.py +314 -0
- contextsynapse/gateway/__init__.py +24 -0
- contextsynapse/gateway/action_emitter.py +212 -0
- contextsynapse/gateway/cost_tracker.py +508 -0
- contextsynapse/gateway/gateway.py +377 -0
- contextsynapse/gateway/policy.py +303 -0
- contextsynapse/governance/__init__.py +13 -0
- contextsynapse/governance/layer.py +513 -0
- contextsynapse/ingestion/__init__.py +15 -0
- contextsynapse/ingestion/amplifier.py +288 -0
- contextsynapse/ingestion/async_ingest.py +463 -0
- contextsynapse/ingestion/chunker.py +303 -0
- contextsynapse/ingestion/chunking.py +58 -0
- contextsynapse/ingestion/cleaner.py +190 -0
- contextsynapse/ingestion/cleanse.py +252 -0
- contextsynapse/ingestion/connectors/__init__.py +38 -0
- contextsynapse/ingestion/connectors/base.py +300 -0
- contextsynapse/ingestion/connectors/chatgpt_memory.py +247 -0
- contextsynapse/ingestion/connectors/claude_memory.py +274 -0
- contextsynapse/ingestion/connectors/sap_ingestor.py +208 -0
- contextsynapse/ingestion/content_detector.py +80 -0
- contextsynapse/ingestion/content_monitor.py +502 -0
- contextsynapse/ingestion/dedup.py +106 -0
- contextsynapse/ingestion/feed.py +640 -0
- contextsynapse/ingestion/filters.py +461 -0
- contextsynapse/ingestion/graph_builder.py +705 -0
- contextsynapse/ingestion/input_classifier.py +307 -0
- contextsynapse/ingestion/job_manager.py +571 -0
- contextsynapse/ingestion/llm_extractor.py +610 -0
- contextsynapse/ingestion/orchestrator.py +116 -0
- contextsynapse/ingestion/parsers/__init__.py +19 -0
- contextsynapse/ingestion/parsers/graph_parser_registry.py +103 -0
- contextsynapse/ingestion/parsers/graphml_parser.py +141 -0
- contextsynapse/ingestion/parsers/jsonld_parser.py +171 -0
- contextsynapse/ingestion/parsers/rdf_parser.py +150 -0
- contextsynapse/ingestion/pipeline_context.py +228 -0
- contextsynapse/ingestion/pipeline_store.py +1195 -0
- contextsynapse/ingestion/queue.py +133 -0
- contextsynapse/ingestion/reprocess.py +179 -0
- contextsynapse/ingestion/scenario_router.py +224 -0
- contextsynapse/ingestion/schema_extractor.py +759 -0
- contextsynapse/ingestion/schema_validator.py +274 -0
- contextsynapse/ingestion/sdlc_ingest.py +87 -0
- contextsynapse/ingestion/smart_ingest.py +2451 -0
- contextsynapse/ingestion/source_connector.py +171 -0
- contextsynapse/ingestion/stage_executor.py +2095 -0
- contextsynapse/ingestion/stages/__init__.py +9 -0
- contextsynapse/ingestion/stages/tabular_to_graph.py +289 -0
- contextsynapse/ingestion/strategies.py +386 -0
- contextsynapse/ingestion/universal/__init__.py +4 -0
- contextsynapse/ingestion/universal/_operator_registry.py +59 -0
- contextsynapse/ingestion/universal/ingest_content.py +32 -0
- contextsynapse/ingestion/universal/operators/__init__.py +1 -0
- contextsynapse/ingestion/universal/operators/base.py +19 -0
- contextsynapse/ingestion/universal/operators/build_edges.py +75 -0
- contextsynapse/ingestion/universal/operators/cluster_topics.py +397 -0
- contextsynapse/ingestion/universal/operators/deduplicate.py +45 -0
- contextsynapse/ingestion/universal/operators/detect_signals.py +90 -0
- contextsynapse/ingestion/universal/operators/embed.py +80 -0
- contextsynapse/ingestion/universal/operators/extract_entities.py +253 -0
- contextsynapse/ingestion/universal/operators/extract_preferences.py +117 -0
- contextsynapse/ingestion/universal/operators/filter_content.py +69 -0
- contextsynapse/ingestion/universal/operators/index_bm25.py +52 -0
- contextsynapse/ingestion/universal/operators/infer_domains.py +69 -0
- contextsynapse/ingestion/universal/operators/link_cross_reference.py +210 -0
- contextsynapse/ingestion/universal/operators/parse_records.py +66 -0
- contextsynapse/ingestion/universal/operators/resolve_entities.py +261 -0
- contextsynapse/ingestion/universal/operators/scanners/__init__.py +16 -0
- contextsynapse/ingestion/universal/operators/scanners/edges.py +173 -0
- contextsynapse/ingestion/universal/operators/scanners/git.py +187 -0
- contextsynapse/ingestion/universal/operators/scanners/github.py +135 -0
- contextsynapse/ingestion/universal/operators/scanners/github_api.py +509 -0
- contextsynapse/ingestion/universal/operators/scanners/helpers.py +67 -0
- contextsynapse/ingestion/universal/operators/scanners/jira.py +65 -0
- contextsynapse/ingestion/universal/operators/scanners/llm_enrichment.py +82 -0
- contextsynapse/ingestion/universal/operators/scanners/repo.py +149 -0
- contextsynapse/ingestion/universal/operators/sdlc_scan.py +213 -0
- contextsynapse/ingestion/universal/operators/spec_scanner.py +149 -0
- contextsynapse/ingestion/universal/operators/store_documents.py +72 -0
- contextsynapse/ingestion/universal/operators/synthesize_cu.py +180 -0
- contextsynapse/ingestion/universal/operators/validate_gate.py +65 -0
- contextsynapse/ingestion/universal/parsers/__init__.py +5 -0
- contextsynapse/ingestion/universal/parsers/record_parser.py +203 -0
- contextsynapse/ingestion/universal/parsers/turn_parser.py +329 -0
- contextsynapse/ingestion/universal/shared_signals.py +161 -0
- contextsynapse/ingestion/universal/stage_executor.py +219 -0
- contextsynapse/ingestion/web_crawler.py +265 -0
- contextsynapse/intelligence/__init__.py +53 -0
- contextsynapse/intelligence/alerts.py +198 -0
- contextsynapse/intelligence/collector.py +655 -0
- contextsynapse/intelligence/comparison.py +198 -0
- contextsynapse/intelligence/config.py +56 -0
- contextsynapse/intelligence/conflict_detector.py +182 -0
- contextsynapse/intelligence/context_gaps.py +192 -0
- contextsynapse/intelligence/context_radar.py +135 -0
- contextsynapse/intelligence/correlation_engine.py +416 -0
- contextsynapse/intelligence/correlation_template.py +120 -0
- contextsynapse/intelligence/dedup.py +296 -0
- contextsynapse/intelligence/event_bus.py +91 -0
- contextsynapse/intelligence/feedback_loop.py +101 -0
- contextsynapse/intelligence/freshness.py +307 -0
- contextsynapse/intelligence/fundamental_feed.py +551 -0
- contextsynapse/intelligence/geo_data.py +170 -0
- contextsynapse/intelligence/geo_reference.py +112 -0
- contextsynapse/intelligence/graph_fusion.py +465 -0
- contextsynapse/intelligence/heuristics.py +176 -0
- contextsynapse/intelligence/impact_tracker.py +336 -0
- contextsynapse/intelligence/macro_indicators.py +319 -0
- contextsynapse/intelligence/ocr.py +104 -0
- contextsynapse/intelligence/persistence.py +267 -0
- contextsynapse/intelligence/pipeline_health.py +130 -0
- contextsynapse/intelligence/price_feed.py +221 -0
- contextsynapse/intelligence/rate_limiter.py +130 -0
- contextsynapse/intelligence/reactive.py +411 -0
- contextsynapse/intelligence/runtime_context.py +390 -0
- contextsynapse/intelligence/sentiment_decay.py +426 -0
- contextsynapse/intelligence/session.py +277 -0
- contextsynapse/intelligence/signal_hierarchy.py +438 -0
- contextsynapse/intelligence/signals.py +185 -0
- contextsynapse/intelligence/source_watcher.py +132 -0
- contextsynapse/intelligence/table_enricher.py +256 -0
- contextsynapse/intelligence/tagger.py +319 -0
- contextsynapse/intelligence/timeseries.py +209 -0
- contextsynapse/intelligence/tracker.py +318 -0
- contextsynapse/intelligence/watchdog.py +392 -0
- contextsynapse/intelligence/watchdog_manager.py +263 -0
- contextsynapse/intelligence/webhook_receiver.py +165 -0
- contextsynapse/intelligence/weight_learner.py +234 -0
- contextsynapse/llm/__init__.py +8 -0
- contextsynapse/llm/client.py +348 -0
- contextsynapse/llm/rate_limiter.py +166 -0
- contextsynapse/logging_config.py +2 -0
- contextsynapse/marketplace/__init__.py +7 -0
- contextsynapse/marketplace/registry.py +173 -0
- contextsynapse/mcp/__init__.py +11 -0
- contextsynapse/mcp/__main__.py +4 -0
- contextsynapse/mcp/auth_middleware.py +212 -0
- contextsynapse/mcp/connection_pool.py +128 -0
- contextsynapse/mcp/server.py +986 -0
- contextsynapse/mcp/session_context.py +67 -0
- contextsynapse/memory/__init__.py +34 -0
- contextsynapse/memory/engine.py +475 -0
- contextsynapse/memory/temporal.py +327 -0
- contextsynapse/metadata/__init__.py +12 -0
- contextsynapse/metadata/metadata_db.py +272 -0
- contextsynapse/metadata/metadata_query_tool.py +300 -0
- contextsynapse/metadata/metadata_tracker.py +425 -0
- contextsynapse/models/__init__.py +27 -0
- contextsynapse/models/embedding_service.py +360 -0
- contextsynapse/models/model_registry.py +228 -0
- contextsynapse/multiworker.py +2 -0
- contextsynapse/pipelines/__init__.py +1 -0
- contextsynapse/pipelines/executor.py +851 -0
- contextsynapse/pipelines/filters.py +189 -0
- contextsynapse/pipelines/models.py +176 -0
- contextsynapse/pipelines/scheduler.py +268 -0
- contextsynapse/playground/__init__.py +1 -0
- contextsynapse/playground/templates.py +85 -0
- contextsynapse/plugins/__init__.py +43 -0
- contextsynapse/plugins/api.py +66 -0
- contextsynapse/plugins/base.py +350 -0
- contextsynapse/plugins/domain_interface.py +508 -0
- contextsynapse/plugins/domain_loader.py +241 -0
- contextsynapse/plugins/loader.py +148 -0
- contextsynapse/plugins/registry.py +265 -0
- contextsynapse/project/__init__.py +11 -0
- contextsynapse/project/code_context.py +807 -0
- contextsynapse/project/connectors/__init__.py +4 -0
- contextsynapse/project/connectors/github_connector.py +113 -0
- contextsynapse/project/connectors/jira_connector.py +160 -0
- contextsynapse/project/graph.py +1023 -0
- contextsynapse/project/project_context.py +545 -0
- contextsynapse/project/scanner_registry.py +61 -0
- contextsynapse/project/schema_manager.py +322 -0
- contextsynapse/project/schemas/knowledge.yaml +59 -0
- contextsynapse/project/schemas/sdlc.yaml +369 -0
- contextsynapse/project/sdlc_schema.py +172 -0
- contextsynapse/project/spec_parser.py +85 -0
- contextsynapse/project/task_lock.py +181 -0
- contextsynapse/project/task_stream.py +203 -0
- contextsynapse/project/team_tools.py +537 -0
- contextsynapse/py.typed +0 -0
- contextsynapse/realtime/__init__.py +6 -0
- contextsynapse/realtime/collaboration.py +147 -0
- contextsynapse/rules/__init__.py +10 -0
- contextsynapse/rules/engine.py +116 -0
- contextsynapse/rules/evaluators/__init__.py +6 -0
- contextsynapse/rules/evaluators/aggregate.py +205 -0
- contextsynapse/rules/evaluators/custom.py +170 -0
- contextsynapse/rules/evaluators/pre_action.py +125 -0
- contextsynapse/rules/evaluators/temporal.py +129 -0
- contextsynapse/rules/loader.py +52 -0
- contextsynapse/rules/models.py +124 -0
- contextsynapse/rules/universal.py +393 -0
- contextsynapse/scheduler.py +229 -0
- contextsynapse/schema/__init__.py +42 -0
- contextsynapse/schema/compiler.py +252 -0
- contextsynapse/schema/composer.py +158 -0
- contextsynapse/schema/dedup.py +73 -0
- contextsynapse/schema/derivation.py +172 -0
- contextsynapse/schema/sdl.py +326 -0
- contextsynapse/schema/validation_gate.py +124 -0
- contextsynapse/sdk/__init__.py +63 -0
- contextsynapse/sdk/agent.py +214 -0
- contextsynapse/sdk/client.py +269 -0
- contextsynapse/sdk/exceptions.py +23 -0
- contextsynapse/sdk/models.py +78 -0
- contextsynapse/sdk/session.py +408 -0
- contextsynapse/sdk/tracked.py +218 -0
- contextsynapse/sdk/worker.py +266 -0
- contextsynapse/sdk/workspace_client.py +98 -0
- contextsynapse/sdk/ws.py +41 -0
- contextsynapse/search/__init__.py +20 -0
- contextsynapse/search/embedding_cache.py +140 -0
- contextsynapse/search/enhanced_search.py +152 -0
- contextsynapse/search/fulltext.py +130 -0
- contextsynapse/search/graph_search.py +634 -0
- contextsynapse/search/lmdb_index.py +1218 -0
- contextsynapse/search/nl_to_aiql.py +199 -0
- contextsynapse/search/rag.py +1346 -0
- contextsynapse/search/rag_cache.py +167 -0
- contextsynapse/search/reasoning_chain.py +231 -0
- contextsynapse/search/redis_search.py +207 -0
- contextsynapse/search/retrieval_quality.py +314 -0
- contextsynapse/search/semantic_query.py +455 -0
- contextsynapse/search/text_resolver.py +159 -0
- contextsynapse/search/whoosh_search.py +373 -0
- contextsynapse/security/__init__.py +17 -0
- contextsynapse/security/audit.py +297 -0
- contextsynapse/security/audit_logger.py +97 -0
- contextsynapse/security/audit_trail.py +270 -0
- contextsynapse/security/auth_unified.py +284 -0
- contextsynapse/security/auto_tagger.py +230 -0
- contextsynapse/security/data_security.py +218 -0
- contextsynapse/security/encryption.py +207 -0
- contextsynapse/security/identity.py +447 -0
- contextsynapse/security/jwt_identity.py +59 -0
- contextsynapse/security/middleware.py +336 -0
- contextsynapse/security/pii.py +233 -0
- contextsynapse/security/rbac.py +96 -0
- contextsynapse/security/rls.py +205 -0
- contextsynapse/security/sanitize.py +233 -0
- contextsynapse/security/scoped_encryption.py +131 -0
- contextsynapse/security/tenant.py +401 -0
- contextsynapse/shield/__init__.py +21 -0
- contextsynapse/shield/anomaly.py +56 -0
- contextsynapse/shield/permissions.py +99 -0
- contextsynapse/shield/profile.py +103 -0
- contextsynapse/shield/shield.py +108 -0
- contextsynapse/shield/trust_engine.py +69 -0
- contextsynapse/skills/__init__.py +14 -0
- contextsynapse/skills/engine.py +233 -0
- contextsynapse/skills/loader.py +59 -0
- contextsynapse/skills/models.py +139 -0
- contextsynapse/storage/__init__.py +7 -0
- contextsynapse/storage/cache.py +208 -0
- contextsynapse/storage/columnar_store_v2.py +178 -0
- contextsynapse/storage/csr_graph_storage.py +587 -0
- contextsynapse/storage/csr_store.py +388 -0
- contextsynapse/storage/document_store.py +491 -0
- contextsynapse/storage/hnsw_index.py +294 -0
- contextsynapse/storage/hybrid_store_v2.py +278 -0
- contextsynapse/storage/lmdb_graph_storage.py +366 -0
- contextsynapse/storage/migration.py +279 -0
- contextsynapse/storage/namespace_store.py +346 -0
- contextsynapse/storage/pure_graph_storage.py +185 -0
- contextsynapse/storage/redis_graph_adapter.py +186 -0
- contextsynapse/storage/redis_graph_storage.py +375 -0
- contextsynapse/storage/router/__init__.py +29 -0
- contextsynapse/storage/router/duckdb_store.py +398 -0
- contextsynapse/storage/router/factory.py +83 -0
- contextsynapse/storage/router/interface.py +125 -0
- contextsynapse/storage/router/postgres_store.py +339 -0
- contextsynapse/storage/router/resolver.py +192 -0
- contextsynapse/storage/router/router.py +300 -0
- contextsynapse/storage/single_file_storage.py +391 -0
- contextsynapse/storage/storage_manager.py +214 -0
- contextsynapse/storage/storage_query_optimizer.py +314 -0
- contextsynapse/storage/wal.py +359 -0
- contextsynapse/temporal/__init__.py +0 -0
- contextsynapse/temporal/storage.py +106 -0
- contextsynapse/tests/__init__.py +11 -0
- contextsynapse/tests/regression/__init__.py +1 -0
- contextsynapse/tests/regression/add_metadata.py +395 -0
- contextsynapse/tests/regression/add_skip_flags.py +85 -0
- contextsynapse/tests/regression/cases/test_basic_create_node.yaml +20 -0
- contextsynapse/tests/regression/cases/test_basic_select.yaml +21 -0
- contextsynapse/tests/regression/cases/test_blockchain_audit_trail.yaml +37 -0
- contextsynapse/tests/regression/cases/test_blockchain_audit_trail_filtered.yaml +39 -0
- contextsynapse/tests/regression/cases/test_blockchain_blocks_range.yaml +39 -0
- contextsynapse/tests/regression/cases/test_blockchain_get_block.yaml +35 -0
- contextsynapse/tests/regression/cases/test_blockchain_latest_block.yaml +35 -0
- contextsynapse/tests/regression/cases/test_blockchain_length.yaml +37 -0
- contextsynapse/tests/regression/cases/test_blockchain_merkle_root.yaml +37 -0
- contextsynapse/tests/regression/cases/test_blockchain_verify.yaml +35 -0
- contextsynapse/tests/regression/cases/test_blockchain_verify_block.yaml +35 -0
- contextsynapse/tests/regression/cases/test_create_edge.yaml +28 -0
- contextsynapse/tests/regression/cases/test_delete_edge_basic.yaml +29 -0
- contextsynapse/tests/regression/cases/test_delete_node_basic.yaml +29 -0
- contextsynapse/tests/regression/cases/test_evaluation_mrr.yaml +40 -0
- contextsynapse/tests/regression/cases/test_evaluation_ndcg.yaml +40 -0
- contextsynapse/tests/regression/cases/test_evaluation_precision.yaml +40 -0
- contextsynapse/tests/regression/cases/test_evaluation_recall.yaml +40 -0
- contextsynapse/tests/regression/cases/test_group_by_basic.yaml +56 -0
- contextsynapse/tests/regression/cases/test_match_node_basic.yaml +29 -0
- contextsynapse/tests/regression/cases/test_match_node_with_order_limit.yaml +31 -0
- contextsynapse/tests/regression/cases/test_namespace_switch.yaml +18 -0
- contextsynapse/tests/regression/cases/test_pipeline_cascaded.yaml +61 -0
- contextsynapse/tests/regression/cases/test_pipeline_fixed_size_chunking.yaml +48 -0
- contextsynapse/tests/regression/cases/test_pipeline_gpt4_chunking.yaml +54 -0
- contextsynapse/tests/regression/cases/test_pipeline_hybrid_indexing.yaml +57 -0
- contextsynapse/tests/regression/cases/test_pipeline_large_embedding.yaml +52 -0
- contextsynapse/tests/regression/cases/test_pipeline_paragraph_chunking.yaml +49 -0
- contextsynapse/tests/regression/cases/test_pipeline_recursive_chunking.yaml +47 -0
- contextsynapse/tests/regression/cases/test_pipeline_run_pipeline.yaml +56 -0
- contextsynapse/tests/regression/cases/test_pipeline_section_based_chunking.yaml +53 -0
- contextsynapse/tests/regression/cases/test_pipeline_semantic_chunking.yaml +51 -0
- contextsynapse/tests/regression/cases/test_pipeline_with_entity_extraction.yaml +57 -0
- contextsynapse/tests/regression/cases/test_pipeline_with_relationships.yaml +62 -0
- contextsynapse/tests/regression/cases/test_rag_evaluation.yaml +38 -0
- contextsynapse/tests/regression/cases/test_rag_graph_bfs_with_eval.yaml +48 -0
- contextsynapse/tests/regression/cases/test_rag_graph_centrality.yaml +40 -0
- contextsynapse/tests/regression/cases/test_rag_graph_centrality_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_community.yaml +40 -0
- contextsynapse/tests/regression/cases/test_rag_graph_community_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_dfs_with_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_multi_hop_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_path.yaml +40 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_basic.yaml +38 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_bfs.yaml +52 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_dfs.yaml +41 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_multi_hop.yaml +43 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_shortest_path.yaml +41 -0
- contextsynapse/tests/regression/cases/test_rag_graph_search_weighted.yaml +43 -0
- contextsynapse/tests/regression/cases/test_rag_graph_shortest_path_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_graph_traversal.yaml +30 -0
- contextsynapse/tests/regression/cases/test_rag_graph_weighted_eval.yaml +35 -0
- contextsynapse/tests/regression/cases/test_rag_hybrid_search.yaml +33 -0
- contextsynapse/tests/regression/cases/test_rag_hybrid_with_prompt_embedding.yaml +44 -0
- contextsynapse/tests/regression/cases/test_rag_keyword_search.yaml +32 -0
- contextsynapse/tests/regression/cases/test_rag_multi_hop_graph.yaml +32 -0
- contextsynapse/tests/regression/cases/test_rag_path_based.yaml +34 -0
- contextsynapse/tests/regression/cases/test_rag_profile_based.yaml +32 -0
- contextsynapse/tests/regression/cases/test_rag_vector_search.yaml +32 -0
- contextsynapse/tests/regression/cases/test_rag_weighted_graph.yaml +34 -0
- contextsynapse/tests/regression/cases/test_rag_weighted_hybrid.yaml +31 -0
- contextsynapse/tests/regression/cases/test_semantic_boundary_chunking.yaml +57 -0
- contextsynapse/tests/regression/cases/test_semantic_boundary_detection.yaml +33 -0
- contextsynapse/tests/regression/cases/test_semantic_hash_function.yaml +30 -0
- contextsynapse/tests/regression/cases/test_semantic_hash_with_model.yaml +31 -0
- contextsynapse/tests/regression/cases/test_tcs_ingestion_fixed_size.yaml +44 -0
- contextsynapse/tests/regression/cases/test_tcs_ingestion_recursive.yaml +46 -0
- contextsynapse/tests/regression/cases/test_tcs_ingestion_section.yaml +46 -0
- contextsynapse/tests/regression/cases/test_tcs_ingestion_semantic.yaml +44 -0
- contextsynapse/tests/regression/cases/test_time_travel_as_of.yaml +35 -0
- contextsynapse/tests/regression/cases/test_time_travel_at_commit.yaml +33 -0
- contextsynapse/tests/regression/cases/test_time_travel_at_timestamp.yaml +33 -0
- contextsynapse/tests/regression/cases/test_time_travel_for_system_time_all.yaml +37 -0
- contextsynapse/tests/regression/cases/test_time_travel_versions_between.yaml +39 -0
- contextsynapse/tests/regression/cases/test_traverse_basic.yaml +31 -0
- contextsynapse/tests/regression/cases/test_traverse_max_depth.yaml +34 -0
- contextsynapse/tests/regression/cases/test_update_edge_basic.yaml +29 -0
- contextsynapse/tests/regression/evaluation_metrics.py +227 -0
- contextsynapse/tests/regression/regression_runner.py +1081 -0
- contextsynapse/tests/regression/setup_regression_data.py +212 -0
- contextsynapse/tests/regression/test_basic_only.py +84 -0
- contextsynapse/tests/regression/test_namespace_creation.py +29 -0
- contextsynapse/tests/regression/test_single_fix.py +61 -0
- contextsynapse/tests/regression/test_single_query.py +20 -0
- contextsynapse/tests/regression/validate_test_syntax.py +179 -0
- contextsynapse/tests/test_advanced_features.py +347 -0
- contextsynapse/tests/test_aiql_summary.py +283 -0
- contextsynapse/tests/test_all_aiql_queries.py +948 -0
- contextsynapse/tests/test_all_create_queries.py +213 -0
- contextsynapse/tests/test_api_vs_native.py +280 -0
- contextsynapse/tests/test_chunking_dedup.py +199 -0
- contextsynapse/tests/test_connectors.py +171 -0
- contextsynapse/tests/test_edges_and_match.py +202 -0
- contextsynapse/tests/test_extraction_pipeline_integration.py +581 -0
- contextsynapse/tests/test_name_property.py +224 -0
- contextsynapse/tests/test_node_edge_metadata.py +250 -0
- contextsynapse/tests/test_playground_conn.py +114 -0
- contextsynapse/tests/test_query_cache.py +213 -0
- contextsynapse/tests/test_source_policy_auth.py +348 -0
- contextsynapse/tests/test_temporal_and_domain.py +224 -0
- contextsynapse/tests/test_time_travel_e2e.py +571 -0
- contextsynapse/tests/test_traversal_and_aggregation.py +275 -0
- contextsynapse/tools/__init__.py +36 -0
- contextsynapse/tools/a2a_tools.py +106 -0
- contextsynapse/tools/cognition_tools.py +118 -0
- contextsynapse/tools/context.py +905 -0
- contextsynapse/tools/formatting.py +92 -0
- contextsynapse/tools/gateway_tools.py +186 -0
- contextsynapse/tools/graph.py +1700 -0
- contextsynapse/tools/intelligence.py +235 -0
- contextsynapse/tools/memory.py +118 -0
- contextsynapse/tools/registry.py +373 -0
- contextsynapse/tools/shield_tools.py +159 -0
- contextsynapse/tools/tasks.py +341 -0
- contextsynapse/tools/workspace_tools.py +124 -0
- contextsynapse/utils/__init__.py +15 -0
- contextsynapse/utils/config_loader.py +198 -0
- contextsynapse/utils/env_loader.py +156 -0
- contextsynapse/utils/file_utils.py +288 -0
- contextsynapse/utils/logging_optimizer.py +119 -0
- contextsynapse/vector/__init__.py +30 -0
- contextsynapse/vector/chroma_vector_store.py +152 -0
- contextsynapse/vector/custom_vector_store.py +537 -0
- contextsynapse/vector/faiss_vector_store.py +296 -0
- contextsynapse/vector/qdrant_vector_store.py +163 -0
- contextsynapse/vector/vector_db.py +953 -0
- contextsynapse/vector/vector_db_manager.py +197 -0
- contextsynapse/workspace/__init__.py +27 -0
- contextsynapse/workspace/base.py +94 -0
- contextsynapse/workspace/git.py +228 -0
- contextsynapse/workspace/github.py +78 -0
- contextsynapse/workspace/local.py +73 -0
- contextsynapse/workspace/tools.py +222 -0
- contextsynapse-1.0.0.dist-info/METADATA +847 -0
- contextsynapse-1.0.0.dist-info/RECORD +776 -0
- contextsynapse-1.0.0.dist-info/WHEEL +5 -0
- contextsynapse-1.0.0.dist-info/entry_points.txt +4 -0
- contextsynapse-1.0.0.dist-info/licenses/LICENSE +200 -0
- contextsynapse-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
AIContextDB Interactive CLI
|
|
4
|
+
Connect to server and run AIQL queries interactively
|
|
5
|
+
Supports both direct file access (local) and HTTP access (remote)
|
|
6
|
+
"""
|
|
7
|
+
import sys
|
|
8
|
+
import requests
|
|
9
|
+
import json
|
|
10
|
+
import time
|
|
11
|
+
from typing import Optional
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
class AIContextDBCLI:
|
|
15
|
+
"""Interactive CLI for AIContextDB."""
|
|
16
|
+
|
|
17
|
+
def __init__(self, connection_string: str = None, server_url: str = None, tinker_mode: bool = False):
|
|
18
|
+
"""
|
|
19
|
+
Initialize AIContextDB CLI with auto-detection.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
connection_string:
|
|
23
|
+
- Local path: "contextcore_data/namespaces/tcs_analysis" → Direct file access
|
|
24
|
+
- HTTP URL: "http://localhost:8000" → HTTP access
|
|
25
|
+
- None: Try local default → Direct file access
|
|
26
|
+
server_url: Legacy parameter (use connection_string instead)
|
|
27
|
+
tinker_mode: Legacy parameter (for backward compatibility)
|
|
28
|
+
"""
|
|
29
|
+
# Handle legacy parameters
|
|
30
|
+
if server_url and not connection_string:
|
|
31
|
+
connection_string = server_url
|
|
32
|
+
|
|
33
|
+
# Auto-detect mode based on connection_string
|
|
34
|
+
if connection_string:
|
|
35
|
+
if connection_string.startswith("http://") or connection_string.startswith("https://"):
|
|
36
|
+
# Remote: HTTP mode
|
|
37
|
+
self.mode = "http"
|
|
38
|
+
self.server_url = connection_string.rstrip("/")
|
|
39
|
+
self.tinker_mode = tinker_mode
|
|
40
|
+
if tinker_mode:
|
|
41
|
+
self.server_url = self.server_url.replace(':8000', ':8001')
|
|
42
|
+
self.session_id = None
|
|
43
|
+
self.active_namespace = None
|
|
44
|
+
print(f"[MODE] HTTP: Connecting to {self.server_url}")
|
|
45
|
+
else:
|
|
46
|
+
# Local: Direct file access
|
|
47
|
+
self.mode = "direct"
|
|
48
|
+
self.db_path = Path(connection_string)
|
|
49
|
+
self._init_direct_connection()
|
|
50
|
+
else:
|
|
51
|
+
# Default: Try local direct access
|
|
52
|
+
self.mode = "direct"
|
|
53
|
+
self._init_local_default()
|
|
54
|
+
|
|
55
|
+
def _init_direct_connection(self):
|
|
56
|
+
"""Initialize direct file access."""
|
|
57
|
+
from ...core.hybrid_graph_storage import AIContextDB
|
|
58
|
+
from ...aiql.engine import AIQLExecutor
|
|
59
|
+
|
|
60
|
+
# Extract namespace from path
|
|
61
|
+
namespace = self.db_path.name
|
|
62
|
+
|
|
63
|
+
# Create graph instance
|
|
64
|
+
graph = AIContextDB(name=namespace, storage_backend='csr')
|
|
65
|
+
|
|
66
|
+
# Try to load graph file (check multiple possible locations/formats)
|
|
67
|
+
graph_file = None
|
|
68
|
+
|
|
69
|
+
# Check for HDF5 format (preferred)
|
|
70
|
+
h5_file = self.db_path / "graph.h5"
|
|
71
|
+
json_file = self.db_path / "graph.json"
|
|
72
|
+
|
|
73
|
+
if h5_file.exists():
|
|
74
|
+
graph_file = h5_file
|
|
75
|
+
elif json_file.exists():
|
|
76
|
+
graph_file = json_file
|
|
77
|
+
|
|
78
|
+
# Also check parent directory (namespace-centric structure)
|
|
79
|
+
if not graph_file:
|
|
80
|
+
parent_h5 = self.db_path.parent / namespace / "graph.h5"
|
|
81
|
+
parent_json = self.db_path.parent / namespace / "graph.json"
|
|
82
|
+
if parent_h5.exists():
|
|
83
|
+
graph_file = parent_h5
|
|
84
|
+
elif parent_json.exists():
|
|
85
|
+
graph_file = parent_json
|
|
86
|
+
|
|
87
|
+
# Load graph if file exists
|
|
88
|
+
if graph_file and graph_file.exists():
|
|
89
|
+
success = graph.load(str(graph_file))
|
|
90
|
+
if success:
|
|
91
|
+
print(f"[OK] Loaded graph from {graph_file}")
|
|
92
|
+
else:
|
|
93
|
+
print(f"[WARN] Graph file exists but failed to load, using empty graph")
|
|
94
|
+
else:
|
|
95
|
+
print(f"[INFO] No graph file found, using empty graph (will create on first write)")
|
|
96
|
+
|
|
97
|
+
# Initialize executor
|
|
98
|
+
self.graph = graph
|
|
99
|
+
self.executor = AIQLExecutor(contextcore=graph)
|
|
100
|
+
self.executor.active_namespace = namespace
|
|
101
|
+
print(f"[OK] Direct file access initialized for namespace: {namespace}")
|
|
102
|
+
|
|
103
|
+
def _init_local_default(self):
|
|
104
|
+
"""Initialize with local default path."""
|
|
105
|
+
default_path = Path("contextcore_data/namespaces/default")
|
|
106
|
+
if default_path.exists():
|
|
107
|
+
self.db_path = default_path
|
|
108
|
+
self._init_direct_connection()
|
|
109
|
+
else:
|
|
110
|
+
# Create default namespace
|
|
111
|
+
default_path.mkdir(parents=True, exist_ok=True)
|
|
112
|
+
self.db_path = default_path
|
|
113
|
+
self._init_direct_connection()
|
|
114
|
+
|
|
115
|
+
def execute_query(self, query: str) -> dict:
|
|
116
|
+
"""Execute a query and return result."""
|
|
117
|
+
if self.mode == "http":
|
|
118
|
+
return self._execute_http_query(query)
|
|
119
|
+
else:
|
|
120
|
+
return self._execute_direct_query(query)
|
|
121
|
+
|
|
122
|
+
def _execute_http_query(self, query: str) -> dict:
|
|
123
|
+
"""Execute query via HTTP API."""
|
|
124
|
+
try:
|
|
125
|
+
# Use session endpoint if available
|
|
126
|
+
endpoint = f"{self.server_url}/query/grql"
|
|
127
|
+
if self.session_id:
|
|
128
|
+
endpoint = f"{self.server_url}/session/{self.session_id}/query/grql"
|
|
129
|
+
|
|
130
|
+
payload = {
|
|
131
|
+
"query": query,
|
|
132
|
+
"namespace": self.active_namespace
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
response = requests.post(endpoint, json=payload, timeout=30)
|
|
136
|
+
response.raise_for_status()
|
|
137
|
+
|
|
138
|
+
result = response.json()
|
|
139
|
+
|
|
140
|
+
# Update session info if provided
|
|
141
|
+
if 'session_id' in result:
|
|
142
|
+
self.session_id = result['session_id']
|
|
143
|
+
if 'active_namespace' in result:
|
|
144
|
+
self.active_namespace = result['active_namespace']
|
|
145
|
+
|
|
146
|
+
return result
|
|
147
|
+
except requests.exceptions.RequestException as e:
|
|
148
|
+
return {
|
|
149
|
+
"success": False,
|
|
150
|
+
"error": f"HTTP request failed: {str(e)}",
|
|
151
|
+
"result": None
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
def _execute_direct_query(self, query: str) -> dict:
|
|
155
|
+
"""Execute query via direct file access."""
|
|
156
|
+
try:
|
|
157
|
+
result = self.executor.execute(query)
|
|
158
|
+
|
|
159
|
+
# Auto-save for direct mode
|
|
160
|
+
if self.executor.active_namespace:
|
|
161
|
+
namespace = self.executor.active_namespace
|
|
162
|
+
graph_file = self.db_path / "graph.h5"
|
|
163
|
+
if not graph_file.exists():
|
|
164
|
+
graph_file = self.db_path / "graph.json"
|
|
165
|
+
|
|
166
|
+
# Save graph after successful query
|
|
167
|
+
if hasattr(self.executor, 'graph_registry') and self.executor.graph_registry:
|
|
168
|
+
self.executor.graph_registry.save_graph(namespace)
|
|
169
|
+
elif self.graph:
|
|
170
|
+
self.graph.save(str(graph_file))
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
"success": True,
|
|
174
|
+
"result": result,
|
|
175
|
+
"namespace": self.executor.active_namespace
|
|
176
|
+
}
|
|
177
|
+
except Exception as e:
|
|
178
|
+
import traceback
|
|
179
|
+
return {
|
|
180
|
+
"success": False,
|
|
181
|
+
"error": str(e),
|
|
182
|
+
"traceback": traceback.format_exc(),
|
|
183
|
+
"result": None
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
def format_result(self, result: dict) -> str:
|
|
187
|
+
"""Format query result for display."""
|
|
188
|
+
if not result.get('success'):
|
|
189
|
+
error = result.get('error', 'Unknown error')
|
|
190
|
+
traceback = result.get('traceback', '')
|
|
191
|
+
return f"[ERROR] {error}\n{traceback}" if traceback else f"[ERROR] {error}"
|
|
192
|
+
|
|
193
|
+
data = result.get('result', {})
|
|
194
|
+
if not data:
|
|
195
|
+
return "[OK] Query executed (no result)"
|
|
196
|
+
|
|
197
|
+
# Format based on result type
|
|
198
|
+
if isinstance(data, dict):
|
|
199
|
+
if 'nodes' in data:
|
|
200
|
+
nodes = data['nodes']
|
|
201
|
+
edges = data.get('edges', [])
|
|
202
|
+
output = f"[OK] Query executed successfully\n"
|
|
203
|
+
output += f"Nodes: {len(nodes)}\n"
|
|
204
|
+
if nodes:
|
|
205
|
+
output += f"Sample node: {nodes[0] if len(nodes) > 0 else 'N/A'}\n"
|
|
206
|
+
if edges:
|
|
207
|
+
output += f"Edges: {len(edges)}\n"
|
|
208
|
+
return output
|
|
209
|
+
elif 'message' in data:
|
|
210
|
+
return f"[OK] {data['message']}"
|
|
211
|
+
else:
|
|
212
|
+
return f"[OK] {json.dumps(data, indent=2, default=str)}"
|
|
213
|
+
elif isinstance(data, list):
|
|
214
|
+
return f"[OK] Query returned {len(data)} items\n{json.dumps(data[:5], indent=2, default=str)}"
|
|
215
|
+
else:
|
|
216
|
+
return f"[OK] {str(data)}"
|
|
217
|
+
|
|
218
|
+
def interactive_mode(self):
|
|
219
|
+
"""Run interactive CLI mode."""
|
|
220
|
+
print("=" * 80)
|
|
221
|
+
print("AIContextDB Interactive CLI")
|
|
222
|
+
print("=" * 80)
|
|
223
|
+
print(f"Mode: {self.mode.upper()}")
|
|
224
|
+
if self.mode == "http":
|
|
225
|
+
print(f"Server: {self.server_url}")
|
|
226
|
+
else:
|
|
227
|
+
print(f"Database: {self.db_path}")
|
|
228
|
+
print("\nType 'help' for commands, 'exit' to quit")
|
|
229
|
+
print("=" * 80 + "\n")
|
|
230
|
+
|
|
231
|
+
while True:
|
|
232
|
+
try:
|
|
233
|
+
# Get input
|
|
234
|
+
if self.active_namespace or (hasattr(self, 'executor') and self.executor.active_namespace):
|
|
235
|
+
namespace = self.active_namespace or self.executor.active_namespace
|
|
236
|
+
prompt = f"contextcore[{namespace}]> "
|
|
237
|
+
else:
|
|
238
|
+
prompt = "contextcore> "
|
|
239
|
+
|
|
240
|
+
query = input(prompt).strip()
|
|
241
|
+
|
|
242
|
+
if not query:
|
|
243
|
+
continue
|
|
244
|
+
|
|
245
|
+
# Handle commands
|
|
246
|
+
if query.lower() == 'exit' or query.lower() == 'quit':
|
|
247
|
+
print("Goodbye!")
|
|
248
|
+
break
|
|
249
|
+
elif query.lower() == 'help':
|
|
250
|
+
self.show_help()
|
|
251
|
+
continue
|
|
252
|
+
elif query.lower().startswith('use namespace'):
|
|
253
|
+
# Handle namespace switching
|
|
254
|
+
parts = query.split()
|
|
255
|
+
if len(parts) >= 3:
|
|
256
|
+
namespace = parts[2]
|
|
257
|
+
self.active_namespace = namespace
|
|
258
|
+
if self.mode == "direct" and hasattr(self, 'executor'):
|
|
259
|
+
self.executor.active_namespace = namespace
|
|
260
|
+
print(f"[OK] Switched to namespace: {namespace}")
|
|
261
|
+
continue
|
|
262
|
+
|
|
263
|
+
# Execute query
|
|
264
|
+
result = self.execute_query(query)
|
|
265
|
+
print(self.format_result(result))
|
|
266
|
+
print() # Empty line for readability
|
|
267
|
+
|
|
268
|
+
except KeyboardInterrupt:
|
|
269
|
+
print("\n\nGoodbye!")
|
|
270
|
+
break
|
|
271
|
+
except EOFError:
|
|
272
|
+
print("\n\nGoodbye!")
|
|
273
|
+
break
|
|
274
|
+
except Exception as e:
|
|
275
|
+
print(f"[ERROR] Unexpected error: {e}")
|
|
276
|
+
import traceback
|
|
277
|
+
traceback.print_exc()
|
|
278
|
+
|
|
279
|
+
def show_help(self):
|
|
280
|
+
"""Show help information."""
|
|
281
|
+
print("\n" + "=" * 80)
|
|
282
|
+
print("AIContextDB CLI Help")
|
|
283
|
+
print("=" * 80)
|
|
284
|
+
print("\nCommands:")
|
|
285
|
+
print(" help - Show this help message")
|
|
286
|
+
print(" exit / quit - Exit the CLI")
|
|
287
|
+
print(" USE NAMESPACE <name> - Switch to a namespace")
|
|
288
|
+
print("\nQuery Examples:")
|
|
289
|
+
print(" CREATE NODE (name: 'Alice', type: 'Person')")
|
|
290
|
+
print(" SELECT * FROM Person")
|
|
291
|
+
print(" MATCH (a:Person)-[r:KNOWS]->(b:Person) RETURN a, r, b")
|
|
292
|
+
print("\nFor more information, see the AIQL documentation.")
|
|
293
|
+
print("=" * 80 + "\n")
|
|
294
|
+
|
|
295
|
+
def _cmd_server(args):
|
|
296
|
+
"""Start the API server."""
|
|
297
|
+
import uvicorn
|
|
298
|
+
import os
|
|
299
|
+
host = args.host or os.environ.get("CONTEXTSYNAPSE_API_HOST") or os.environ.get("AICONTEXTDB_API_HOST", "0.0.0.0")
|
|
300
|
+
port = args.port or int(os.environ.get("CONTEXTSYNAPSE_API_PORT") or os.environ.get("AICONTEXTDB_API_PORT", "8000"))
|
|
301
|
+
workers = args.workers or int(os.environ.get("CONTEXTSYNAPSE_API_WORKERS") or os.environ.get("AICONTEXTDB_API_WORKERS", "1"))
|
|
302
|
+
print(f"Starting AIContextDB on {host}:{port}")
|
|
303
|
+
uvicorn.run("contextsynapse.api.api:app", host=host, port=port, workers=workers,
|
|
304
|
+
reload=args.reload, log_level="info")
|
|
305
|
+
|
|
306
|
+
def _cmd_status(args):
|
|
307
|
+
"""Show system status."""
|
|
308
|
+
import os
|
|
309
|
+
from contextsynapse.core.registry import GraphRegistry
|
|
310
|
+
from pathlib import Path as _P
|
|
311
|
+
registry = GraphRegistry()
|
|
312
|
+
graphs = registry.list_graphs()
|
|
313
|
+
data_dir = _P("contextcore_data")
|
|
314
|
+
storage = "—"
|
|
315
|
+
if data_dir.exists():
|
|
316
|
+
total = sum(f.stat().st_size for f in data_dir.rglob("*") if f.is_file())
|
|
317
|
+
storage = f"{total / 1_000_000:.1f} MB" if total > 1_000_000 else f"{total / 1000:.0f} KB"
|
|
318
|
+
total_nodes = sum(g.get("num_nodes", 0) for g in graphs)
|
|
319
|
+
print(f"AIContextDB Status\n{'='*40}")
|
|
320
|
+
print(f" Graphs: {len(graphs)}")
|
|
321
|
+
print(f" Nodes: {total_nodes}")
|
|
322
|
+
print(f" Storage: {storage}")
|
|
323
|
+
for key, name in [("OPENAI_API_KEY", "OpenAI"), ("GROQ_API_KEY", "Groq"), ("ANTHROPIC_API_KEY", "Anthropic")]:
|
|
324
|
+
print(f" {name + ':':12s} {'configured' if os.environ.get(key) else 'not set'}")
|
|
325
|
+
|
|
326
|
+
def _cmd_graphs(args):
|
|
327
|
+
"""List all graphs."""
|
|
328
|
+
from contextsynapse.core.registry import GraphRegistry
|
|
329
|
+
registry = GraphRegistry()
|
|
330
|
+
graphs = registry.list_graphs()
|
|
331
|
+
if args.json_out:
|
|
332
|
+
print(json.dumps(graphs, indent=2, default=str))
|
|
333
|
+
else:
|
|
334
|
+
print(f"{'Name':<40} {'Nodes':>8} {'Edges':>8}")
|
|
335
|
+
print("-" * 60)
|
|
336
|
+
for g in graphs:
|
|
337
|
+
name = g.get("name", "?")
|
|
338
|
+
print(f"{name:<40} {g.get('num_nodes', 0):>8} {g.get('num_edges', 0):>8}")
|
|
339
|
+
|
|
340
|
+
def _cmd_export(args):
|
|
341
|
+
"""Export a graph."""
|
|
342
|
+
from contextsynapse.core.registry import GraphRegistry
|
|
343
|
+
registry = GraphRegistry()
|
|
344
|
+
graph = registry.get_graph(args.graph, load_if_missing=True)
|
|
345
|
+
if not graph:
|
|
346
|
+
print(f"Error: Graph '{args.graph}' not found"); sys.exit(1)
|
|
347
|
+
nodes = [{"id": n.id, "label": n.label, "properties": dict(n.properties)} for n in graph.get_all_nodes()]
|
|
348
|
+
edges = [{"source": e.source if hasattr(e, "source") else e.get("source",""),
|
|
349
|
+
"target": e.target if hasattr(e, "target") else e.get("target",""),
|
|
350
|
+
"label": e.label if hasattr(e, "label") else e.get("label","")} for e in graph.get_all_edges()]
|
|
351
|
+
data = {"graph": args.graph, "nodes": nodes, "edges": edges}
|
|
352
|
+
if args.output:
|
|
353
|
+
with open(args.output, "w") as f: json.dump(data, f, indent=2, default=str)
|
|
354
|
+
print(f"Exported {len(nodes)} nodes, {len(edges)} edges → {args.output}")
|
|
355
|
+
else:
|
|
356
|
+
print(json.dumps(data, indent=2, default=str))
|
|
357
|
+
|
|
358
|
+
def _cmd_mcp(args):
|
|
359
|
+
"""Start MCP server."""
|
|
360
|
+
sys.argv = ["mcp"]
|
|
361
|
+
if args.api_key: sys.argv.extend(["--api-key", args.api_key])
|
|
362
|
+
if args.session: sys.argv.extend(["--session", args.session])
|
|
363
|
+
from contextsynapse.mcp.server import main as mcp_main
|
|
364
|
+
mcp_main()
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def _cmd_create_vertical(args):
|
|
368
|
+
"""Create a new vertical plugin project."""
|
|
369
|
+
from contextsynapse.cli.scaffold import scaffold_vertical
|
|
370
|
+
try:
|
|
371
|
+
project_dir = scaffold_vertical(
|
|
372
|
+
name=args.name,
|
|
373
|
+
output_dir=args.output,
|
|
374
|
+
author=args.author,
|
|
375
|
+
description=args.description,
|
|
376
|
+
)
|
|
377
|
+
print(f"\nCreated vertical '{args.name}' at {project_dir}\n")
|
|
378
|
+
print("Next steps:")
|
|
379
|
+
print(f" 1. cd {project_dir}")
|
|
380
|
+
print(f" 2. Edit schemas.py — define your node/edge types")
|
|
381
|
+
print(f" 3. Edit sensors/ — add your data feeds")
|
|
382
|
+
print(f" 4. Edit api/routes.py — add your endpoints")
|
|
383
|
+
print(f" 5. pip install -e . && contextcore serve")
|
|
384
|
+
print(f" 6. Visit http://localhost:8000/plugins/ to verify")
|
|
385
|
+
except FileExistsError as e:
|
|
386
|
+
print(f"Error: {e}")
|
|
387
|
+
sys.exit(1)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def main():
|
|
391
|
+
"""Main entry point."""
|
|
392
|
+
import argparse
|
|
393
|
+
|
|
394
|
+
parser = argparse.ArgumentParser(
|
|
395
|
+
prog="contextsynapse",
|
|
396
|
+
description="AIContextDB — Shared context platform for AI agents",
|
|
397
|
+
)
|
|
398
|
+
sub = parser.add_subparsers(dest="subcommand")
|
|
399
|
+
|
|
400
|
+
# Subcommands
|
|
401
|
+
p = sub.add_parser("server", help="Start API server")
|
|
402
|
+
p.add_argument("--host", default=None); p.add_argument("--port", type=int, default=None)
|
|
403
|
+
p.add_argument("--workers", type=int, default=None); p.add_argument("--reload", action="store_true")
|
|
404
|
+
|
|
405
|
+
sub.add_parser("status", help="System status")
|
|
406
|
+
|
|
407
|
+
p = sub.add_parser("graphs", help="List graphs")
|
|
408
|
+
p.add_argument("--json", dest="json_out", action="store_true")
|
|
409
|
+
|
|
410
|
+
p = sub.add_parser("export", help="Export graph as JSON")
|
|
411
|
+
p.add_argument("graph"); p.add_argument("-o", "--output")
|
|
412
|
+
|
|
413
|
+
p = sub.add_parser("mcp", help="Start MCP server")
|
|
414
|
+
p.add_argument("--api-key", default=None); p.add_argument("--session", default=None)
|
|
415
|
+
|
|
416
|
+
p = sub.add_parser("create-vertical", help="Create a new vertical plugin project")
|
|
417
|
+
p.add_argument("name", help="Vertical name (e.g. legal, healthcare, logistics)")
|
|
418
|
+
p.add_argument("--author", default="ContextCore Developer", help="Author name")
|
|
419
|
+
p.add_argument("--description", default="", help="Plugin description")
|
|
420
|
+
p.add_argument("--output", default=".", help="Output directory")
|
|
421
|
+
|
|
422
|
+
# Legacy flags (backward compat)
|
|
423
|
+
parser.add_argument("--local", type=str,
|
|
424
|
+
help="Local database path (direct file access)")
|
|
425
|
+
parser.add_argument("--remote", type=str, default="http://localhost:8000",
|
|
426
|
+
help="Remote server URL")
|
|
427
|
+
parser.add_argument("--server", type=str, help=argparse.SUPPRESS)
|
|
428
|
+
parser.add_argument("--tinker", action="store_true", help=argparse.SUPPRESS)
|
|
429
|
+
parser.add_argument("--query", help="Execute a single query and exit")
|
|
430
|
+
parser.add_argument("--file", help="Execute queries from file")
|
|
431
|
+
|
|
432
|
+
args = parser.parse_args()
|
|
433
|
+
|
|
434
|
+
# Handle subcommands
|
|
435
|
+
if args.subcommand == "server": return _cmd_server(args)
|
|
436
|
+
if args.subcommand == "status": return _cmd_status(args)
|
|
437
|
+
if args.subcommand == "graphs": return _cmd_graphs(args)
|
|
438
|
+
if args.subcommand == "export": return _cmd_export(args)
|
|
439
|
+
if args.subcommand == "mcp": return _cmd_mcp(args)
|
|
440
|
+
if args.subcommand == "create-vertical": return _cmd_create_vertical(args)
|
|
441
|
+
|
|
442
|
+
# Determine connection string
|
|
443
|
+
if args.local:
|
|
444
|
+
connection_string = args.local
|
|
445
|
+
elif args.server:
|
|
446
|
+
connection_string = args.server # Legacy support
|
|
447
|
+
elif args.remote:
|
|
448
|
+
connection_string = args.remote
|
|
449
|
+
else:
|
|
450
|
+
connection_string = None # Auto-detect
|
|
451
|
+
|
|
452
|
+
cli = AIContextDBCLI(connection_string=connection_string, tinker_mode=args.tinker)
|
|
453
|
+
|
|
454
|
+
if args.query:
|
|
455
|
+
# Single query mode
|
|
456
|
+
result = cli.execute_query(args.query)
|
|
457
|
+
print(json.dumps(result, indent=2, default=str))
|
|
458
|
+
sys.exit(0 if result.get('success') else 1)
|
|
459
|
+
elif args.file:
|
|
460
|
+
# File mode
|
|
461
|
+
with open(args.file, 'r') as f:
|
|
462
|
+
queries = f.read().split(';')
|
|
463
|
+
for query in queries:
|
|
464
|
+
query = query.strip()
|
|
465
|
+
if query:
|
|
466
|
+
print(f"\nExecuting: {query}")
|
|
467
|
+
result = cli.execute_query(query + ';')
|
|
468
|
+
print(cli.format_result(result))
|
|
469
|
+
else:
|
|
470
|
+
# Interactive mode
|
|
471
|
+
cli.interactive_mode()
|
|
472
|
+
|
|
473
|
+
if __name__ == "__main__":
|
|
474
|
+
main()
|
|
475
|
+
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Configuration CLI Tool
|
|
4
|
+
|
|
5
|
+
Manage AIContextDB configuration files, similar to:
|
|
6
|
+
- PostgreSQL: psql -c "SHOW config_file"
|
|
7
|
+
- MySQL: mysqladmin variables
|
|
8
|
+
- MongoDB: mongosh admin --eval "db.getSiblingDB('admin').runCommand({getParameter: 1})"
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import click
|
|
12
|
+
import sys
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Optional
|
|
15
|
+
from ..config.database_config import (
|
|
16
|
+
DatabaseConfigManager,
|
|
17
|
+
DatabaseConfig,
|
|
18
|
+
ConfigFormat,
|
|
19
|
+
get_config_manager
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@click.group()
|
|
24
|
+
def config():
|
|
25
|
+
"""AIContextDB Configuration Management"""
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@config.command()
|
|
30
|
+
@click.option('--file', '-f', help='Configuration file path')
|
|
31
|
+
@click.option('--format', type=click.Choice(['yaml', 'json']), default='yaml', help='Output format')
|
|
32
|
+
def show(file: Optional[str], format: str):
|
|
33
|
+
"""Show current configuration"""
|
|
34
|
+
manager = get_config_manager(file)
|
|
35
|
+
config = manager.get_config()
|
|
36
|
+
|
|
37
|
+
if format == 'yaml':
|
|
38
|
+
import yaml
|
|
39
|
+
config_dict = manager._config_to_dict(config)
|
|
40
|
+
print(yaml.dump(config_dict, default_flow_style=False, sort_keys=False))
|
|
41
|
+
else:
|
|
42
|
+
import json
|
|
43
|
+
config_dict = manager._config_to_dict(config)
|
|
44
|
+
print(json.dumps(config_dict, indent=2))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@config.command()
|
|
48
|
+
@click.option('--file', '-f', help='Output file path')
|
|
49
|
+
@click.option('--format', type=click.Choice(['yaml', 'json']), default='yaml', help='File format')
|
|
50
|
+
def init(file: Optional[str], format: str):
|
|
51
|
+
"""Create default configuration file"""
|
|
52
|
+
if file:
|
|
53
|
+
manager = DatabaseConfigManager(file)
|
|
54
|
+
else:
|
|
55
|
+
manager = get_config_manager()
|
|
56
|
+
|
|
57
|
+
manager.create_default_config()
|
|
58
|
+
print(f"[EMOJI] Default configuration created at: {manager.config_file}")
|
|
59
|
+
print(f" Edit this file to customize your settings")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@config.command()
|
|
63
|
+
@click.argument('section')
|
|
64
|
+
@click.argument('key')
|
|
65
|
+
@click.argument('value')
|
|
66
|
+
@click.option('--file', '-f', help='Configuration file path')
|
|
67
|
+
def set(section: str, key: str, value: str, file: Optional[str]):
|
|
68
|
+
"""Set a configuration value"""
|
|
69
|
+
manager = get_config_manager(file)
|
|
70
|
+
|
|
71
|
+
# Parse value (try int, float, bool, then string)
|
|
72
|
+
try:
|
|
73
|
+
if value.lower() in ('true', 'yes', 'on'):
|
|
74
|
+
value = True
|
|
75
|
+
elif value.lower() in ('false', 'no', 'off'):
|
|
76
|
+
value = False
|
|
77
|
+
elif '.' in value:
|
|
78
|
+
value = float(value)
|
|
79
|
+
else:
|
|
80
|
+
value = int(value)
|
|
81
|
+
except ValueError:
|
|
82
|
+
pass # Keep as string
|
|
83
|
+
|
|
84
|
+
manager.update_config(section, **{key: value})
|
|
85
|
+
manager.save_config()
|
|
86
|
+
print(f"[EMOJI] Set {section}.{key} = {value}")
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@config.command()
|
|
90
|
+
@click.argument('section')
|
|
91
|
+
@click.argument('key')
|
|
92
|
+
@click.option('--file', '-f', help='Configuration file path')
|
|
93
|
+
def get(section: str, key: str, file: Optional[str]):
|
|
94
|
+
"""Get a configuration value"""
|
|
95
|
+
manager = get_config_manager(file)
|
|
96
|
+
config = manager.get_config()
|
|
97
|
+
|
|
98
|
+
if not hasattr(config, section):
|
|
99
|
+
print(f"[EMOJI] Unknown section: {section}", file=sys.stderr)
|
|
100
|
+
sys.exit(1)
|
|
101
|
+
|
|
102
|
+
section_obj = getattr(config, section)
|
|
103
|
+
if not hasattr(section_obj, key):
|
|
104
|
+
print(f"[EMOJI] Unknown key: {section}.{key}", file=sys.stderr)
|
|
105
|
+
sys.exit(1)
|
|
106
|
+
|
|
107
|
+
value = getattr(section_obj, key)
|
|
108
|
+
print(value)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@config.command()
|
|
112
|
+
@click.option('--file', '-f', help='Configuration file path')
|
|
113
|
+
def validate(file: Optional[str]):
|
|
114
|
+
"""Validate configuration file"""
|
|
115
|
+
manager = get_config_manager(file)
|
|
116
|
+
config = manager.get_config()
|
|
117
|
+
|
|
118
|
+
errors = []
|
|
119
|
+
warnings = []
|
|
120
|
+
|
|
121
|
+
# Validate performance settings
|
|
122
|
+
if config.performance.max_nodes_in_memory < 1000:
|
|
123
|
+
warnings.append("max_nodes_in_memory is very low (< 1000)")
|
|
124
|
+
|
|
125
|
+
if config.performance.cache_size_mb < 64:
|
|
126
|
+
warnings.append("cache_size_mb is very low (< 64 MB)")
|
|
127
|
+
|
|
128
|
+
# Validate storage settings
|
|
129
|
+
if config.storage.storage_format not in ['multi_file', 'single_file']:
|
|
130
|
+
errors.append(f"Invalid storage_format: {config.storage.storage_format}")
|
|
131
|
+
|
|
132
|
+
# Validate connection settings
|
|
133
|
+
if config.connection.api_port < 1024:
|
|
134
|
+
warnings.append("API port < 1024 may require root privileges")
|
|
135
|
+
|
|
136
|
+
if config.connection.api_port > 65535:
|
|
137
|
+
errors.append(f"Invalid API port: {config.connection.api_port}")
|
|
138
|
+
|
|
139
|
+
# Validate logging
|
|
140
|
+
if config.logging.log_level not in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']:
|
|
141
|
+
errors.append(f"Invalid log_level: {config.logging.log_level}")
|
|
142
|
+
|
|
143
|
+
# Print results
|
|
144
|
+
if errors:
|
|
145
|
+
print("[EMOJI] Configuration Errors:")
|
|
146
|
+
for error in errors:
|
|
147
|
+
print(f" - {error}")
|
|
148
|
+
|
|
149
|
+
if warnings:
|
|
150
|
+
print("[EMOJI][EMOJI] Configuration Warnings:")
|
|
151
|
+
for warning in warnings:
|
|
152
|
+
print(f" - {warning}")
|
|
153
|
+
|
|
154
|
+
if not errors and not warnings:
|
|
155
|
+
print("[EMOJI] Configuration is valid")
|
|
156
|
+
|
|
157
|
+
sys.exit(1 if errors else 0)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
@config.command()
|
|
161
|
+
@click.option('--file', '-f', help='Configuration file path')
|
|
162
|
+
def location(file: Optional[str]):
|
|
163
|
+
"""Show configuration file location"""
|
|
164
|
+
manager = get_config_manager(file)
|
|
165
|
+
print(f"Configuration file: {manager.config_file}")
|
|
166
|
+
print(f"Exists: {manager.config_file.exists()}")
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
if __name__ == '__main__':
|
|
170
|
+
config()
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|