correctover 2.2.0__tar.gz → 2.3.1__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.
Files changed (72) hide show
  1. correctover-2.3.1/LICENSE +7 -0
  2. correctover-2.3.1/MANIFEST.in +2 -0
  3. correctover-2.3.1/PKG-INFO +122 -0
  4. correctover-2.3.1/README.md +94 -0
  5. correctover-2.3.1/correctover/__init__.py +310 -0
  6. correctover-2.3.1/correctover/_checkup.py +335 -0
  7. correctover-2.3.1/correctover/_core.py +1557 -0
  8. correctover-2.3.1/correctover/_device.py +294 -0
  9. correctover-2.3.1/correctover/_engine.py +2779 -0
  10. correctover-2.3.1/correctover/_fixes.py +209 -0
  11. correctover-2.3.1/correctover/_fixes2.py +178 -0
  12. correctover-2.3.1/correctover/_guard.py +169 -0
  13. correctover-2.3.1/correctover/_ping.py +298 -0
  14. correctover-2.3.1/correctover/_security.py +127 -0
  15. correctover-2.3.1/correctover/_sentry.py +360 -0
  16. correctover-2.3.1/correctover/_stats.py +519 -0
  17. correctover-2.3.1/correctover/_tracker.py +191 -0
  18. correctover-2.3.1/correctover/_types.py +64 -0
  19. correctover-2.3.1/correctover/_version.py +5 -0
  20. correctover-2.3.1/correctover/benchmark/__init__.py +6 -0
  21. correctover-2.3.1/correctover/benchmark/fault_injector.py +129 -0
  22. correctover-2.3.1/correctover/benchmark/metrics_collector.py +222 -0
  23. correctover-2.3.1/correctover/benchmark/run_benchmark.py +211 -0
  24. correctover-2.3.1/correctover/benchmark/scenarios.py +123 -0
  25. correctover-2.3.1/correctover/bounty_rules.py +810 -0
  26. correctover-2.3.1/correctover/carbon.py +454 -0
  27. correctover-2.3.1/correctover/ccs_scanner.py +888 -0
  28. correctover-2.3.1/correctover/chain.py +951 -0
  29. correctover-2.3.1/correctover/checkpoint.py +806 -0
  30. correctover-2.3.1/correctover/classifier.py +212 -0
  31. correctover-2.3.1/correctover/cli.py +1886 -0
  32. correctover-2.3.1/correctover/client.py +400 -0
  33. correctover-2.3.1/correctover/cloudkill.py +446 -0
  34. correctover-2.3.1/correctover/cost_tracker.py +62 -0
  35. correctover-2.3.1/correctover/dashboard.py +1161 -0
  36. correctover-2.3.1/correctover/demo.py +466 -0
  37. correctover-2.3.1/correctover/diagnoser.py +34 -0
  38. correctover-2.3.1/correctover/drift.py +262 -0
  39. correctover-2.3.1/correctover/free_provider.py +186 -0
  40. correctover-2.3.1/correctover/gateway.py +732 -0
  41. correctover-2.3.1/correctover/health_scorer.py +54 -0
  42. correctover-2.3.1/correctover/integrity.py +56 -0
  43. correctover-2.3.1/correctover/license.py +861 -0
  44. correctover-2.3.1/correctover/logging_config.py +84 -0
  45. correctover-2.3.1/correctover/mcs_scanner.py +681 -0
  46. correctover-2.3.1/correctover/router.py +279 -0
  47. correctover-2.3.1/correctover/run.py +139 -0
  48. correctover-2.3.1/correctover/shield.py +368 -0
  49. correctover-2.3.1/correctover/smart_router.py +13 -0
  50. correctover-2.3.1/correctover/state_machine.py +84 -0
  51. correctover-2.3.1/correctover/status.py +514 -0
  52. correctover-2.3.1/correctover/telemetry.py +308 -0
  53. correctover-2.3.1/correctover/tracing.py +89 -0
  54. correctover-2.3.1/correctover.egg-info/PKG-INFO +122 -0
  55. correctover-2.3.1/correctover.egg-info/SOURCES.txt +62 -0
  56. correctover-2.3.1/correctover.egg-info/entry_points.txt +5 -0
  57. correctover-2.3.1/correctover.egg-info/requires.txt +2 -0
  58. correctover-2.3.1/pyproject.toml +43 -0
  59. correctover-2.3.1/setup.py +40 -0
  60. correctover-2.3.1/tests/test_false_positive_fixes.py +236 -0
  61. correctover-2.3.1/tests/test_real_project_patterns.py +193 -0
  62. correctover-2.2.0/PKG-INFO +0 -12
  63. correctover-2.2.0/pyproject.toml +0 -21
  64. correctover-2.2.0/src/correctover/__init__.py +0 -22
  65. correctover-2.2.0/src/correctover/guardrail.py +0 -211
  66. correctover-2.2.0/src/correctover/validator.py +0 -37
  67. correctover-2.2.0/src/correctover.egg-info/PKG-INFO +0 -12
  68. correctover-2.2.0/src/correctover.egg-info/SOURCES.txt +0 -9
  69. correctover-2.2.0/src/correctover.egg-info/requires.txt +0 -1
  70. {correctover-2.2.0/src → correctover-2.3.1}/correctover.egg-info/dependency_links.txt +0 -0
  71. {correctover-2.2.0/src → correctover-2.3.1}/correctover.egg-info/top_level.txt +0 -0
  72. {correctover-2.2.0 → correctover-2.3.1}/setup.cfg +0 -0
@@ -0,0 +1,7 @@
1
+ CORRECTOVER SDK — PROPRIETARY COMMERCIAL LICENSE
2
+ Copyright (c) 2024-2026 Correctover Team. All rights reserved.
3
+
4
+ This software is NOT open source. It is distributed as compiled
5
+ bytecode only. Redistribution requires a valid commercial license.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
@@ -0,0 +1,2 @@
1
+ recursive-include correctover *.pyc
2
+ recursive-include correctover/benchmark *.pyc
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.1
2
+ Name: correctover
3
+ Version: 2.3.1
4
+ Summary: Correctover — LLM Reliability Engineering platform. Protocol-level contract validation, verified failover (DeepSeek/OpenAI/Anthropic), MCP security, CCS v1.0 standard, 84.1% self-heal rate across 20K+ trajectories.
5
+ Home-page: https://correctover.com
6
+ Author: Correctover Team
7
+ Author-email: Correctover Team <team@correctover.com>
8
+ Maintainer-email: Correctover Team <team@correctover.com>
9
+ License: Proprietary Commercial License — see LICENSE
10
+ Project-URL: Homepage, https://correctover.com
11
+ Project-URL: Documentation, https://correctover.com/docs
12
+ Project-URL: Changelog, https://correctover.com/docs/changelog
13
+ Project-URL: Bug Tracker, https://correctover.com/support
14
+ Keywords: llm,self-healing,failover,circuit-breaker,api-resilience,openai,anthropic,deepseek,contract-validation,correctover,ai-gateway,semantic-verification,mcp,security,ccs,runtime-guard,agent-reliability,llmre
15
+ Classifier: Development Status :: 5 - Production/Stable
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: Other/Proprietary License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.12
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: httpx>=0.24.0
27
+ Requires-Dist: aiohttp>=3.8.0
28
+
29
+ # Correctover SDK
30
+
31
+ **Failure is not fatal.** Protocol-level contract validation with automatic verified failover for LLM APIs — now with MCP security, CCS v1.0 standard, and runtime guardrails.
32
+
33
+ [![PyPI version](https://img.shields.io/pypi/v/correctover.svg)](https://pypi.org/project/correctover/)
34
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
35
+ [![License: Proprietary](https://img.shields.io/badge/license-Proprietary-red.svg)](LICENSE)
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ pip install correctover
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ```python
46
+ import correctover
47
+
48
+ # Automatic failover with verified contract validation
49
+ result = correctover.run("Hello!")
50
+ print(result)
51
+ ```
52
+
53
+ ## What It Does
54
+
55
+ Correctover is the **LLM Reliability Engineering (LLMRE)** platform for AI agents:
56
+
57
+ | Capability | Description |
58
+ |------------|-------------|
59
+ | **Contract Validation** | Protocol-level output verification — schema, semantic, safety |
60
+ | **Verified Failover** | Automatic retry to DeepSeek/OpenAI/Anthropic on failure |
61
+ | **Self-Healing** | 84.1% success rate across 20K+ decision trajectories |
62
+ | **MCP Security** | 14 OWASP AISVS 1.0 checks for Model Context Protocol configs |
63
+ | **Runtime Guard** | 22µs P50 RCE/SSRF/credential leak interception |
64
+ | **CCS v1.0 Standard** | First formal conformance standard for agentic runtimes (DOI: 10.5281/zenodo.21234580) |
65
+
66
+ ## CLI Tools
67
+
68
+ ```bash
69
+ correctover-shield # Runtime guard daemon
70
+ correctover-ccs # CCS v1.0 conformance scanner
71
+ correctover-mcs # MCP security scanner
72
+ correctover-hunt # Vulnerability hunter
73
+ ```
74
+
75
+ ## Key Metrics
76
+
77
+ | Metric | Value |
78
+ |--------|-------|
79
+ | Self-heal success rate | 84.1% |
80
+ | Failover latency | 0.4–0.7ms |
81
+ | Runtime guard P50 | 22µs |
82
+ | Test trajectories | 20,071 |
83
+ | CVEs filed | 6 (AutoGen ×2, CrewAI, Semantic Kernel, MS AGT) |
84
+ | Fault types | 215 |
85
+
86
+ ## Supported Providers
87
+
88
+ - **DeepSeek** (primary failover target)
89
+ - **OpenAI** (GPT-4o, GPT-4-turbo)
90
+ - **Anthropic** (Claude 3.5 Sonnet)
91
+
92
+ ## Free Tier
93
+
94
+ 50 calls/day — no credit card required.
95
+
96
+ Unlock unlimited: [correctover.com/checkout](https://correctover.com/checkout)
97
+
98
+ ```bash
99
+ export CORRECTOVER_LICENSE_KEY=your-key-here
100
+ ```
101
+
102
+ ## Related Correctover Tools
103
+
104
+ | Tool | Install | Description |
105
+ |------|---------|-------------|
106
+ | **Security Scanner** | `npx correctover-scan` | MCP config security audit (14 checks) |
107
+ | **Self-Healing Test** | `pip install correctover-test` | Agent self-healing test suite |
108
+ | **Vulnerability Scan** | `pip install correctover-security-audit` | 215 fault type scanner |
109
+ | **Compliance Check** | `pip install correctover-compliance-check` | OAuth 2.1 + CCS v1.0 |
110
+ | **Runtime Guard** | `pip install correctover-runtime-guard` | 22µs RCE/SSRF interception |
111
+ | **MCP Server** | `npm install correctover-mcp-server` | 6-dimension validation |
112
+
113
+ ## Links
114
+
115
+ - **Website**: [correctover.com](https://correctover.com)
116
+ - **GitHub**: [github.com/Correctover](https://github.com/Correctover)
117
+ - **CCS Standard**: [DOI: 10.5281/zenodo.21234580](https://doi.org/10.5281/zenodo.21234580)
118
+ - **Checkout**: [correctover.com/checkout](https://correctover.com/checkout)
119
+
120
+ ## License
121
+
122
+ Proprietary Commercial License. See LICENSE file.
@@ -0,0 +1,94 @@
1
+ # Correctover SDK
2
+
3
+ **Failure is not fatal.** Protocol-level contract validation with automatic verified failover for LLM APIs — now with MCP security, CCS v1.0 standard, and runtime guardrails.
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/correctover.svg)](https://pypi.org/project/correctover/)
6
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
7
+ [![License: Proprietary](https://img.shields.io/badge/license-Proprietary-red.svg)](LICENSE)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install correctover
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```python
18
+ import correctover
19
+
20
+ # Automatic failover with verified contract validation
21
+ result = correctover.run("Hello!")
22
+ print(result)
23
+ ```
24
+
25
+ ## What It Does
26
+
27
+ Correctover is the **LLM Reliability Engineering (LLMRE)** platform for AI agents:
28
+
29
+ | Capability | Description |
30
+ |------------|-------------|
31
+ | **Contract Validation** | Protocol-level output verification — schema, semantic, safety |
32
+ | **Verified Failover** | Automatic retry to DeepSeek/OpenAI/Anthropic on failure |
33
+ | **Self-Healing** | 84.1% success rate across 20K+ decision trajectories |
34
+ | **MCP Security** | 14 OWASP AISVS 1.0 checks for Model Context Protocol configs |
35
+ | **Runtime Guard** | 22µs P50 RCE/SSRF/credential leak interception |
36
+ | **CCS v1.0 Standard** | First formal conformance standard for agentic runtimes (DOI: 10.5281/zenodo.21234580) |
37
+
38
+ ## CLI Tools
39
+
40
+ ```bash
41
+ correctover-shield # Runtime guard daemon
42
+ correctover-ccs # CCS v1.0 conformance scanner
43
+ correctover-mcs # MCP security scanner
44
+ correctover-hunt # Vulnerability hunter
45
+ ```
46
+
47
+ ## Key Metrics
48
+
49
+ | Metric | Value |
50
+ |--------|-------|
51
+ | Self-heal success rate | 84.1% |
52
+ | Failover latency | 0.4–0.7ms |
53
+ | Runtime guard P50 | 22µs |
54
+ | Test trajectories | 20,071 |
55
+ | CVEs filed | 6 (AutoGen ×2, CrewAI, Semantic Kernel, MS AGT) |
56
+ | Fault types | 215 |
57
+
58
+ ## Supported Providers
59
+
60
+ - **DeepSeek** (primary failover target)
61
+ - **OpenAI** (GPT-4o, GPT-4-turbo)
62
+ - **Anthropic** (Claude 3.5 Sonnet)
63
+
64
+ ## Free Tier
65
+
66
+ 50 calls/day — no credit card required.
67
+
68
+ Unlock unlimited: [correctover.com/checkout](https://correctover.com/checkout)
69
+
70
+ ```bash
71
+ export CORRECTOVER_LICENSE_KEY=your-key-here
72
+ ```
73
+
74
+ ## Related Correctover Tools
75
+
76
+ | Tool | Install | Description |
77
+ |------|---------|-------------|
78
+ | **Security Scanner** | `npx correctover-scan` | MCP config security audit (14 checks) |
79
+ | **Self-Healing Test** | `pip install correctover-test` | Agent self-healing test suite |
80
+ | **Vulnerability Scan** | `pip install correctover-security-audit` | 215 fault type scanner |
81
+ | **Compliance Check** | `pip install correctover-compliance-check` | OAuth 2.1 + CCS v1.0 |
82
+ | **Runtime Guard** | `pip install correctover-runtime-guard` | 22µs RCE/SSRF interception |
83
+ | **MCP Server** | `npm install correctover-mcp-server` | 6-dimension validation |
84
+
85
+ ## Links
86
+
87
+ - **Website**: [correctover.com](https://correctover.com)
88
+ - **GitHub**: [github.com/Correctover](https://github.com/Correctover)
89
+ - **CCS Standard**: [DOI: 10.5281/zenodo.21234580](https://doi.org/10.5281/zenodo.21234580)
90
+ - **Checkout**: [correctover.com/checkout](https://correctover.com/checkout)
91
+
92
+ ## License
93
+
94
+ Proprietary Commercial License. See LICENSE file.
@@ -0,0 +1,310 @@
1
+ # Copyright 2024-2026 Correctover Team
2
+ # Licensed under the Apache License, Version 2.0 (the "License")
3
+ # Correctover™ — Proprietary MAPE-K Adaptive Loop Architecture
4
+
5
+ #
6
+ """Correctover SDK — Agent stability SDK. Smart routing, auto-failover, crash recovery."""
7
+ from correctover._version import __version__
8
+ version = __version__
9
+
10
+ # 懒加载字典:所有模块延迟加载
11
+ _lazy = {
12
+ # Core engine
13
+ "SelfHealingEngine": ("correctover._engine", "SelfHealingEngine"),
14
+ "CallResult": ("correctover._engine", "CallResult"),
15
+ "ProviderConfig": ("correctover._engine", "ProviderConfig"),
16
+ "APIError": ("correctover._engine", "APIError"),
17
+ # Diagnoser
18
+ "FaultCategory": ("correctover._engine", "FaultCategory"),
19
+ "Diagnosis": ("correctover._engine", "Diagnosis"),
20
+ "Diagnoser": ("correctover.diagnoser", "Diagnoser"),
21
+ # HA components
22
+ "CircuitBreaker": ("correctover._engine", "CircuitBreaker"),
23
+ "CircuitState": ("correctover._engine", "CircuitState"),
24
+ "RateLimiter": ("correctover._engine", "RateLimiter"),
25
+ "Bulkhead": ("correctover._engine", "Bulkhead"),
26
+ # Semantic topology
27
+ "SemanticTopology": ("correctover._engine", "SemanticTopology"),
28
+ "SemanticDomain": ("correctover._engine", "SemanticDomain"),
29
+ "SemanticClassification": ("correctover._engine", "SemanticClassification"),
30
+ # Flywheel
31
+ "FlywheelLearner": ("correctover._engine", "FlywheelLearner"),
32
+ "LearnedRule": ("correctover._engine", "LearnedRule"),
33
+ "MetricsCollector": ("correctover._engine", "MetricsCollector"),
34
+ # MAPE-K Trace
35
+ "MapeKPhase": ("correctover._engine", "MapeKPhase"),
36
+ "MapeKTrace": ("correctover._engine", "MapeKTrace"),
37
+ # Contract Validator
38
+ "Contract": ("correctover._engine", "Contract"),
39
+ "ContractCheck": ("correctover._engine", "ContractCheck"),
40
+ "ContractResult": ("correctover._engine", "ContractResult"),
41
+ "ContractViolationError": ("correctover._engine", "ContractViolationError"),
42
+ "SemanticBoundaryViolationError": ("correctover._engine", "SemanticBoundaryViolationError"),
43
+ # Compatibility modules
44
+ "HealthScorer": ("correctover.health_scorer", "HealthScorer"),
45
+ "CostTracker": ("correctover.cost_tracker", "CostTracker"),
46
+ "IntegrityChecker": ("correctover.integrity", "IntegrityChecker"),
47
+ "EngineStateMachine": ("correctover.state_machine", "EngineStateMachine"),
48
+ "CorrectoverTelemetry": ("correctover.telemetry", "CorrectoverTelemetry"),
49
+ "TelemetryCollector": ("correctover.telemetry", "TelemetryCollector"),
50
+ "TelemetryConfig": ("correctover.telemetry", "TelemetryConfig"),
51
+ "run": ("correctover.run", "run"),
52
+ "Run": ("correctover.run", "Run"),
53
+ "RecoveryLevel": ("correctover._types", "RecoveryLevel"),
54
+ "DiagnosisResult": ("correctover._types", "DiagnosisResult"),
55
+ "RecoveryAction": ("correctover._types", "RecoveryAction"),
56
+ "RoutingStrategy": ("correctover._types", "RoutingStrategy"),
57
+ # Gateway proxy
58
+ "GatewayConfig": ("correctover.gateway", "GatewayConfig"),
59
+ "serve": ("correctover.gateway", "serve"),
60
+ # License system
61
+ "activate": ("correctover.license", "activate"),
62
+ "verify": ("correctover.license", "verify"),
63
+ "get_plan": ("correctover.license", "get_plan"),
64
+ "is_pro": ("correctover.license", "is_pro"),
65
+ "is_trial": ("correctover.license", "is_trial"),
66
+ "is_enterprise": ("correctover.license", "is_enterprise"),
67
+ "is_expired": ("correctover.license", "is_expired"),
68
+ "is_device_bound": ("correctover.license", "is_device_bound"),
69
+ "require_pro": ("correctover.license", "require_pro"),
70
+ "days_remaining": ("correctover.license", "days_remaining"),
71
+ "max_providers": ("correctover.license", "max_providers"),
72
+ "max_heal_level": ("correctover.license", "max_heal_level"),
73
+ "feature_gate": ("correctover.license", "feature_gate"),
74
+ "watermark_enabled": ("correctover.license", "watermark_enabled"),
75
+ "consume_repair": ("correctover.license", "consume_repair"),
76
+ "can_repair": ("correctover.license", "can_repair"),
77
+ "diagnose_free": ("correctover.license", "diagnose_free"),
78
+ "plan_summary": ("correctover.license", "plan_summary"),
79
+ "LicenseInfo": ("correctover.license", "LicenseInfo"),
80
+ "LicenseError": ("correctover.license", "LicenseError"),
81
+ "RepairLockedError": ("correctover.license", "RepairLockedError"),
82
+ "LicenseExpiredError": ("correctover.license", "LicenseExpiredError"),
83
+ "DeviceMismatchError": ("correctover.license", "DeviceMismatchError"),
84
+ "PLAN_PRICES": ("correctover.license", "PLAN_PRICES"),
85
+ "PLAN_LABELS": ("correctover.license", "PLAN_LABELS"),
86
+ "REPAIR_ACTIONS": ("correctover.license", "REPAIR_ACTIONS"),
87
+ # Device fingerprint
88
+ "device_fingerprint": ("correctover._device", "device_fingerprint"),
89
+ "device_info": ("correctover._device", "device_info"),
90
+ # Stats & ROI
91
+ "savings_report": ("correctover._stats", "savings_report"),
92
+ "console_summary": ("correctover._stats", "console_summary"),
93
+ "dashboard_data": ("correctover._stats", "dashboard_data"),
94
+ "weekly_summary": ("correctover._stats", "weekly_summary"),
95
+ "upgrade_triggers": ("correctover._stats", "upgrade_triggers"),
96
+ # Router + Client (v5.0)
97
+ "Client": ("correctover.client", "Client"),
98
+ "ChatResponse": ("correctover.client", "ChatResponse"),
99
+ "CostReport": ("correctover.client", "CostReport"),
100
+ "Router": ("correctover.router", "Router"),
101
+ "RoutingDecision": ("correctover.router", "RoutingDecision"),
102
+ "Strategy": ("correctover.router", "Strategy"),
103
+ "Complexity": ("correctover.classifier", "Complexity"),
104
+ "classify": ("correctover.classifier", "classify"),
105
+ # Checkpoint — Agent crash recovery (v4.3)
106
+ "Checkpoint": ("correctover.checkpoint", "Checkpoint"),
107
+ "StepResult": ("correctover.checkpoint", "StepResult"),
108
+ "AgentSession": ("correctover.checkpoint", "AgentSession"),
109
+ "RunContext": ("correctover.checkpoint", "RunContext"),
110
+ "CheckpointStore": ("correctover.checkpoint", "CheckpointStore"),
111
+ "FileCheckpointStore": ("correctover.checkpoint", "FileCheckpointStore"),
112
+ "MemoryCheckpointStore": ("correctover.checkpoint", "MemoryCheckpointStore"),
113
+ # Cloud Kill-Switch (v4.3)
114
+ "CloudKillGuardian": ("correctover.cloudkill", "CloudKillGuardian"),
115
+ "detect_tamper": ("correctover.cloudkill", "detect_tamper"),
116
+ "report_tamper": ("correctover.cloudkill", "report_tamper"),
117
+ "check_revoked": ("correctover.cloudkill", "check_revoked"),
118
+ "quick_check": ("correctover.cloudkill", "quick_check"),
119
+ # Telemetry
120
+ "ping": ("correctover._ping", "ping"),
121
+ # Carbon Tracker (v4.4.2)
122
+ "CarbonTracker": ("correctover.carbon", "CarbonTracker"),
123
+ "estimate_wh": ("correctover.carbon", "estimate_wh"),
124
+ "estimate_co2_kg": ("correctover.carbon", "estimate_co2_kg"),
125
+ "MODEL_ENERGY": ("correctover.carbon", "MODEL_ENERGY"),
126
+ "CARBON_INTENSITY_GRID": ("correctover.carbon", "CARBON_INTENSITY_GRID"),
127
+ "DriftMonitor": ("correctover.drift", "DriftMonitor"),
128
+ "DriftAlert": ("correctover.drift", "DriftAlert"),
129
+ # Dashboard (v4.4.2)
130
+ "dashboard": ("correctover.dashboard", "dashboard"),
131
+ "stop_dashboard": ("correctover.dashboard", "stop_dashboard"),
132
+ "dashboard_url": ("correctover.dashboard", "dashboard_url"),
133
+ "dashboard_status": ("correctover.dashboard", "dashboard_status"),
134
+ # Agent Chain Correctover™ (v5.3.0)
135
+ "ChainBuilder": ("correctover.chain", "ChainBuilder"),
136
+ "AgentChain": ("correctover.chain", "AgentChain"),
137
+ "AgentNode": ("correctover.chain", "AgentNode"),
138
+ "NodeResult": ("correctover.chain", "NodeResult"),
139
+ "ChainContext": ("correctover.chain", "ChainContext"),
140
+ "ChainResult": ("correctover.chain", "ChainResult"),
141
+ "CompensationStrategy": ("correctover.chain", "CompensationStrategy"),
142
+ }
143
+
144
+ __all__ = list(_lazy.keys()) + ["checkup"]
145
+
146
+
147
+ def __getattr__(name):
148
+ """懒加载:只在首次访问时导入模块"""
149
+ if name in _lazy:
150
+ import importlib
151
+ mod_path, cls_name = _lazy[name]
152
+ mod = importlib.import_module(mod_path)
153
+ obj = getattr(mod, cls_name)
154
+ globals()[name] = obj
155
+ return obj
156
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
157
+
158
+
159
+ def __dir__():
160
+ """返回完整的导出列表"""
161
+ return __all__
162
+
163
+
164
+ # ── Telemetry (opt-in, default OFF) ──────────────────────────────
165
+ import os as _os
166
+ # Telemetry is OFF by default. Set CORRECTOVER_TELEMETRY=1 to enable.
167
+ # This collects anonymous usage data (version, OS, plan) to improve the SDK.
168
+ # See https://correctover.cn/docs/telemetry for details.
169
+ # Telemetry is OFF by default. Set CORRECTOVER_TELEMETRY=1 to enable.
170
+ if _os.environ.get("CORRECTOVER_TELEMETRY") != "1":
171
+ _os.environ["CORRECTOVER_TELEMETRY"] = "0"
172
+ if not _os.environ.get("CORRECTOVER_TELEMETRY_URL"):
173
+ _os.environ["CORRECTOVER_TELEMETRY_URL"] = "https://license-api-correctover-hk.oss-cn-hongkong.aliyuncs.com/api/v1/telemetry"
174
+
175
+ # ── Auto-ping on import (only if telemetry is opted-in) ─────────
176
+ if _os.environ.get("CORRECTOVER_TELEMETRY") == "1":
177
+ try:
178
+ from correctover._ping import ping as _auto_ping
179
+ _auto_ping()
180
+ except Exception:
181
+ pass
182
+
183
+
184
+ # ── First-run checkup ────────────────────────────────────────────
185
+ def checkup():
186
+ """手动触发体检 (重新检测所有 provider 和连通性)."""
187
+ from correctover._checkup import force_run
188
+ force_run()
189
+
190
+ try:
191
+ from correctover._checkup import run as _checkup_run
192
+ _checkup_run()
193
+ except Exception:
194
+ pass
195
+
196
+
197
+ # ══════════════════════════════════════════════════════════════════
198
+ # SECURITY LAYER — All logic lives in _security.so (compiled)
199
+ # ══════════════════════════════════════════════════════════════════
200
+
201
+ # ── Step 1: Initialize tracker (silent, non-blocking) ──────────
202
+ try:
203
+ # [FIXED] tracker only loaded when telemetry explicitly opted in
204
+ if _os.environ.get('CORRECTOVER_TELEMETRY') == '1':
205
+ from correctover._tracker import report as _track_report
206
+ from correctover._tracker import flush as _track_flush
207
+ else:
208
+ _track_report = None
209
+ _track_flush = None
210
+ except ImportError as _e:
211
+ _track_report = None
212
+ _track_flush = None
213
+ import sys as _sys
214
+ if "cpython" in str(_e).lower() or "magic" in str(_e).lower():
215
+ print(f"[Correctover] WARNING: _tracker module incompatible with Python {_sys.version_info.major}.{_sys.version_info.minor}. "
216
+ f"Security tracking disabled. Reinstall from source: pip install --no-binary correctover-sdk correctover-sdk", file=_sys.stderr)
217
+ except Exception:
218
+ _track_report = None
219
+ _track_flush = None
220
+
221
+
222
+ # ── Step 2-5: Security init (compiled — logic not readable) ────
223
+ try:
224
+ from correctover._security import init as _security_init
225
+ _security_init()
226
+ except ImportError as _e:
227
+ import sys as _sys
228
+ if "cpython" in str(_e).lower() or "magic" in str(_e).lower():
229
+ print(f"[Correctover] WARNING: _security module incompatible with Python {_sys.version_info.major}.{_sys.version_info.minor}. "
230
+ f"Security init skipped. Reinstall from source: pip install --no-binary correctover-sdk correctover-sdk", file=_sys.stderr)
231
+ except Exception:
232
+ pass
233
+
234
+
235
+ # ── Step 6: Flush pending tracker events ───────────────────────
236
+ try:
237
+ if _track_flush:
238
+ _track_flush()
239
+ except Exception:
240
+ pass
241
+
242
+
243
+ # ── Step 7: Cloud Kill-Switch guardian ─────────────────────────
244
+ # Background thread: periodically checks for tampering + cloud revocation
245
+ try:
246
+ from correctover.cloudkill import CloudKillGuardian
247
+ if _os.environ.get("CORRECTOVER_CLOUDKILL", "0") == "1": # [FIXED] opt-in
248
+ CloudKillGuardian.start(interval=3600)
249
+ except Exception:
250
+ pass
251
+
252
+
253
+ # ══════════════════════════════════════════════════════════════════
254
+ # Anthropic 推荐:最简一行调用(Less is More + ACI 设计原则)
255
+ # ══════════════════════════════════════════════════════════════════
256
+
257
+ def run(prompt="", provider="", **kwargs):
258
+ """一行代码调用 AI,自动配置、自动自愈。
259
+
260
+ Anthropic《构建高效的 Agents》核心原则:
261
+ - Less is More:从最简单开始,一行代码
262
+ - 好的 ACI 设计:用户不需要了解内部细节
263
+
264
+ 用法:
265
+ import correctover as nb
266
+ result = nb.run("你好") # 自动读环境变量
267
+ print(result.summary()) # 透明度:看到完整调用链
268
+
269
+ 环境变量: DEEPSEEK_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, DASHSCOPE_API_KEY
270
+ """
271
+ import asyncio, os
272
+ from correctover._engine import SelfHealingEngine, ProviderConfig
273
+
274
+ engine = SelfHealingEngine()
275
+ api_key = kwargs.pop("api_key", "") or os.environ.get("CUSTOM_API_KEY", "")
276
+ candidates = [provider] if provider else ["deepseek", "openai", "anthropic", "dashscope", "agnes"]
277
+
278
+ for p in candidates:
279
+ env_key = api_key or os.environ.get(f"{p.upper()}_API_KEY", "")
280
+ if not env_key:
281
+ continue
282
+ try:
283
+ cfg = ProviderConfig(name=p, base_url=ProviderConfig._get_base_url(p), api_key=env_key)
284
+ engine.add_provider(cfg)
285
+ except Exception:
286
+ continue
287
+ break
288
+
289
+ if prompt:
290
+ return asyncio.run(engine.call(prompt, **kwargs))
291
+ return engine
292
+
293
+
294
+ # ── Apply runtime patches for known bugs ──────────────────────────
295
+ # Bug #2 (latency), #3 (5xx), and the historical fixes in _fixes.pyc
296
+ # are applied here at import time.
297
+ import os as _patch_os
298
+ try:
299
+ from correctover._fixes import _apply_patches as _apply_fixes
300
+ _apply_fixes()
301
+ except Exception as _fix_err:
302
+ if _patch_os.environ.get("CORRECTOVER_DEBUG"):
303
+ print(f"[Correctover] _fixes load warning: {_fix_err}")
304
+
305
+ try:
306
+ from correctover._fixes2 import _apply_patches as _apply_fixes2
307
+ _apply_fixes2()
308
+ except Exception as _fix2_err:
309
+ if _patch_os.environ.get("CORRECTOVER_DEBUG"):
310
+ print(f"[Correctover] _fixes2 load warning: {_fix2_err}")