correctover 2.0.2__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- correctover-2.1.0/LICENSE +7 -0
- correctover-2.1.0/MANIFEST.in +2 -0
- correctover-2.1.0/PKG-INFO +49 -0
- correctover-2.1.0/README.md +21 -0
- correctover-2.1.0/correctover/__init__.py +310 -0
- correctover-2.1.0/correctover/__pycache__/__init__.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/_checkup.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/_engine.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/_fixes.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/_fixes2.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/_guard.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/_ping.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/_security.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/_types.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/_version.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/bounty_rules.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/ccs_scanner.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/chain.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/cli.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/cloudkill.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/license.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/__pycache__/mcs_scanner.cpython-312.pyc +0 -0
- correctover-2.1.0/correctover/_checkup.py +335 -0
- correctover-2.1.0/correctover/_core.py +1557 -0
- correctover-2.1.0/correctover/_device.py +294 -0
- correctover-2.1.0/correctover/_engine.py +2779 -0
- correctover-2.1.0/correctover/_fixes.py +209 -0
- correctover-2.1.0/correctover/_fixes2.py +178 -0
- correctover-2.1.0/correctover/_guard.py +169 -0
- correctover-2.1.0/correctover/_ping.py +296 -0
- correctover-2.1.0/correctover/_security.py +127 -0
- correctover-2.1.0/correctover/_sentry.py +360 -0
- correctover-2.1.0/correctover/_stats.py +519 -0
- correctover-2.1.0/correctover/_tracker.py +191 -0
- correctover-2.1.0/correctover/_types.py +64 -0
- correctover-2.1.0/correctover/_version.py +5 -0
- correctover-2.1.0/correctover/benchmark/__init__.py +6 -0
- correctover-2.1.0/correctover/benchmark/fault_injector.py +129 -0
- correctover-2.1.0/correctover/benchmark/metrics_collector.py +222 -0
- correctover-2.1.0/correctover/benchmark/run_benchmark.py +211 -0
- correctover-2.1.0/correctover/benchmark/scenarios.py +123 -0
- correctover-2.1.0/correctover/bounty_rules.py +806 -0
- correctover-2.1.0/correctover/carbon.py +454 -0
- correctover-2.1.0/correctover/ccs_scanner.py +653 -0
- correctover-2.1.0/correctover/chain.py +951 -0
- correctover-2.1.0/correctover/checkpoint.py +805 -0
- correctover-2.1.0/correctover/classifier.py +212 -0
- correctover-2.1.0/correctover/cli.py +1048 -0
- correctover-2.1.0/correctover/client.py +400 -0
- correctover-2.1.0/correctover/cloudkill.py +446 -0
- correctover-2.1.0/correctover/cost_tracker.py +62 -0
- correctover-2.1.0/correctover/dashboard.py +1157 -0
- correctover-2.1.0/correctover/demo.py +466 -0
- correctover-2.1.0/correctover/diagnoser.py +34 -0
- correctover-2.1.0/correctover/drift.py +262 -0
- correctover-2.1.0/correctover/free_provider.py +186 -0
- correctover-2.1.0/correctover/gateway.py +732 -0
- correctover-2.1.0/correctover/health_scorer.py +54 -0
- correctover-2.1.0/correctover/integrity.py +56 -0
- correctover-2.1.0/correctover/license.py +861 -0
- correctover-2.1.0/correctover/logging_config.py +84 -0
- correctover-2.1.0/correctover/mcs_scanner.py +561 -0
- correctover-2.1.0/correctover/router.py +279 -0
- correctover-2.1.0/correctover/run.py +139 -0
- correctover-2.1.0/correctover/shield.py +366 -0
- correctover-2.1.0/correctover/smart_router.py +13 -0
- correctover-2.1.0/correctover/state_machine.py +84 -0
- correctover-2.1.0/correctover/status.py +514 -0
- correctover-2.1.0/correctover/telemetry.py +308 -0
- correctover-2.1.0/correctover/tracing.py +89 -0
- correctover-2.1.0/correctover.egg-info/PKG-INFO +49 -0
- correctover-2.1.0/correctover.egg-info/SOURCES.txt +77 -0
- correctover-2.1.0/correctover.egg-info/entry_points.txt +5 -0
- correctover-2.1.0/correctover.egg-info/requires.txt +2 -0
- correctover-2.1.0/pyproject.toml +43 -0
- {correctover-2.0.2 → correctover-2.1.0}/setup.cfg +4 -4
- correctover-2.1.0/setup.py +40 -0
- correctover-2.0.2/LICENSE +0 -8
- correctover-2.0.2/PKG-INFO +0 -94
- correctover-2.0.2/README.md +0 -55
- correctover-2.0.2/correctover/__init__.py +0 -12
- correctover-2.0.2/correctover/validator.py +0 -98
- correctover-2.0.2/correctover.egg-info/PKG-INFO +0 -94
- correctover-2.0.2/correctover.egg-info/SOURCES.txt +0 -10
- correctover-2.0.2/correctover.egg-info/requires.txt +0 -1
- correctover-2.0.2/setup.py +0 -39
- {correctover-2.0.2 → correctover-2.1.0}/correctover.egg-info/dependency_links.txt +0 -0
- {correctover-2.0.2 → correctover-2.1.0}/correctover.egg-info/top_level.txt +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,49 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: correctover
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: Correctover — Failure is not fatal. Protocol-level contract validation with automatic verified failover for LLM APIs.
|
|
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
|
|
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.
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install correctover
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import correctover
|
|
43
|
+
result = correctover.run("Hello!")
|
|
44
|
+
print(result)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
Proprietary Commercial License. See LICENSE file.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Correctover SDK
|
|
2
|
+
|
|
3
|
+
**Failure is not fatal.** Protocol-level contract validation with automatic verified failover for LLM APIs.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install correctover
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import correctover
|
|
15
|
+
result = correctover.run("Hello!")
|
|
16
|
+
print(result)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
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}")
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|