continuum-agent-sdk 1.0.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.
Files changed (53) hide show
  1. continuum_agent_sdk-1.0.0/.gitignore +55 -0
  2. continuum_agent_sdk-1.0.0/PKG-INFO +116 -0
  3. continuum_agent_sdk-1.0.0/README.md +86 -0
  4. continuum_agent_sdk-1.0.0/benchmarks/bench_agent.py +157 -0
  5. continuum_agent_sdk-1.0.0/benchmarks/bench_config.py +181 -0
  6. continuum_agent_sdk-1.0.0/benchmarks/bench_session.py +187 -0
  7. continuum_agent_sdk-1.0.0/continuum/__init__.py +14 -0
  8. continuum_agent_sdk-1.0.0/continuum/py.typed +2 -0
  9. continuum_agent_sdk-1.0.0/continuum_sdk/__init__.py +83 -0
  10. continuum_agent_sdk-1.0.0/continuum_sdk/agent/__init__.py +70 -0
  11. continuum_agent_sdk-1.0.0/continuum_sdk/agent/intelligent.py +529 -0
  12. continuum_agent_sdk-1.0.0/continuum_sdk/agent/planner.py +442 -0
  13. continuum_agent_sdk-1.0.0/continuum_sdk/agent/progress.py +291 -0
  14. continuum_agent_sdk-1.0.0/continuum_sdk/agent/runtime.py +689 -0
  15. continuum_agent_sdk-1.0.0/continuum_sdk/agent/self_correction.py +425 -0
  16. continuum_agent_sdk-1.0.0/continuum_sdk/agent/session.py +413 -0
  17. continuum_agent_sdk-1.0.0/continuum_sdk/config/__init__.py +77 -0
  18. continuum_agent_sdk-1.0.0/continuum_sdk/config/loader.py +516 -0
  19. continuum_agent_sdk-1.0.0/continuum_sdk/config/providers.py +125 -0
  20. continuum_agent_sdk-1.0.0/continuum_sdk/examples/README.md +27 -0
  21. continuum_agent_sdk-1.0.0/continuum_sdk/examples/__init__.py +1 -0
  22. continuum_agent_sdk-1.0.0/continuum_sdk/examples/advanced/__init__.py +1 -0
  23. continuum_agent_sdk-1.0.0/continuum_sdk/examples/advanced/custom_tools.py +155 -0
  24. continuum_agent_sdk-1.0.0/continuum_sdk/examples/advanced/workflow.py +161 -0
  25. continuum_agent_sdk-1.0.0/continuum_sdk/examples/basic/__init__.py +1 -0
  26. continuum_agent_sdk-1.0.0/continuum_sdk/examples/basic/hello_agent.py +36 -0
  27. continuum_agent_sdk-1.0.0/continuum_sdk/examples/basic/hello_world.py +25 -0
  28. continuum_agent_sdk-1.0.0/continuum_sdk/examples/basic/session_example.py +67 -0
  29. continuum_agent_sdk-1.0.0/continuum_sdk/llm/__init__.py +65 -0
  30. continuum_agent_sdk-1.0.0/continuum_sdk/llm/client.py +781 -0
  31. continuum_agent_sdk-1.0.0/continuum_sdk/llm/errors.py +200 -0
  32. continuum_agent_sdk-1.0.0/continuum_sdk/llm/types.py +223 -0
  33. continuum_agent_sdk-1.0.0/continuum_sdk/memory/__init__.py +13 -0
  34. continuum_agent_sdk-1.0.0/continuum_sdk/memory/layers.py +302 -0
  35. continuum_agent_sdk-1.0.0/continuum_sdk/py.typed +2 -0
  36. continuum_agent_sdk-1.0.0/continuum_sdk/tools/__init__.py +86 -0
  37. continuum_agent_sdk-1.0.0/continuum_sdk/tools/bash.py +266 -0
  38. continuum_agent_sdk-1.0.0/continuum_sdk/tools/builtin.py +291 -0
  39. continuum_agent_sdk-1.0.0/continuum_sdk/tools/custom.py +275 -0
  40. continuum_agent_sdk-1.0.0/continuum_sdk/tools/file_ops.py +476 -0
  41. continuum_agent_sdk-1.0.0/continuum_sdk/tools/search.py +287 -0
  42. continuum_agent_sdk-1.0.0/continuum_sdk/tools/types.py +85 -0
  43. continuum_agent_sdk-1.0.0/continuum_sdk/workflow/__init__.py +14 -0
  44. continuum_agent_sdk-1.0.0/continuum_sdk/workflow/dag.py +432 -0
  45. continuum_agent_sdk-1.0.0/pyproject.toml +76 -0
  46. continuum_agent_sdk-1.0.0/tests/test_agent.py +322 -0
  47. continuum_agent_sdk-1.0.0/tests/test_config.py +96 -0
  48. continuum_agent_sdk-1.0.0/tests/test_intelligent_agent.py +386 -0
  49. continuum_agent_sdk-1.0.0/tests/test_llm_real.py +421 -0
  50. continuum_agent_sdk-1.0.0/tests/test_memory.py +213 -0
  51. continuum_agent_sdk-1.0.0/tests/test_session.py +140 -0
  52. continuum_agent_sdk-1.0.0/tests/test_tools.py +277 -0
  53. continuum_agent_sdk-1.0.0/tests/test_tools_real.py +324 -0
@@ -0,0 +1,55 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ venv/
26
+ ENV/
27
+
28
+ # IDE
29
+ .idea/
30
+ .vscode/
31
+ *.swp
32
+ *.swo
33
+
34
+ # Testing
35
+ .pytest_cache/
36
+ .coverage
37
+ htmlcov/
38
+
39
+ # Rust build artifacts
40
+ target/
41
+ *.pdb
42
+
43
+ # Project specific
44
+ .egg/
45
+ *.log
46
+ .env
47
+ .env.local
48
+ .env.test
49
+ test,env
50
+ *.bak
51
+
52
+ # Secrets - never commit
53
+ *_key*
54
+ *_secret*
55
+ *_token*
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: continuum-agent-sdk
3
+ Version: 1.0.0
4
+ Summary: Production-Grade Agent Framework with Crash Safety Guarantees
5
+ Project-URL: Homepage, https://github.com/continuum-ai/continuum
6
+ Project-URL: Documentation, https://continuum-agent-sdk.readthedocs.io
7
+ Project-URL: Repository, https://github.com/continuum-ai/continuum
8
+ Project-URL: Issues, https://github.com/continuum-ai/continuum/issues
9
+ Author: Continuum Team
10
+ License: MIT
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: httpx>=0.25.0
23
+ Requires-Dist: pydantic>=2.0.0
24
+ Requires-Dist: toml>=0.10.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
28
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Continuum Python SDK
32
+
33
+ A production-grade agent framework with crash safety guarantees.
34
+
35
+ ## Quick Start (3 steps)
36
+
37
+ ```python
38
+ from continuum import Agent
39
+
40
+ agent = Agent() # Auto-loads config from environment
41
+ result = agent.run("your task")
42
+ ```
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install continuum
48
+ ```
49
+
50
+ ## Configuration
51
+
52
+ ### Environment Variables
53
+
54
+ Priority: `CONTINUUM_*` > `CONTINUUM_*` > `ANTHROPIC_*`
55
+
56
+ ```bash
57
+ export CONTINUUM_API_KEY=your_api_key
58
+ export CONTINUUM_PROVIDER=anthropic # or openai, google
59
+ export CONTINUUM_MODEL=claude-sonnet-4-6
60
+ ```
61
+
62
+ ### Config File
63
+
64
+ Create `~/.continuum/config.toml`:
65
+
66
+ ```toml
67
+ [providers.anthropic]
68
+ api_key = "${ANTHROPIC_API_KEY}"
69
+ base_url = "https://api.anthropic.com/v1"
70
+ model = "claude-sonnet-4-6"
71
+
72
+ [providers.openai]
73
+ api_key = "${OPENAI_API_KEY}"
74
+ base_url = "https://api.openai.com/v1"
75
+ model = "gpt-4"
76
+
77
+ [settings]
78
+ session_auto_save = true
79
+ checkpoint_enabled = true
80
+ audit_enabled = true
81
+ ```
82
+
83
+ ## Features
84
+
85
+ - **Agent**: One-line agent creation with automatic configuration
86
+ - **Session**: Conversation history management with checkpoint support
87
+ - **Tools**: Built-in and custom tool registration
88
+ - **Memory**: Multi-layer memory system (episodic, semantic, procedural)
89
+ - **Config**: Multi-provider configuration with environment variable support
90
+
91
+ ## API Reference
92
+
93
+ ```python
94
+ from continuum import Agent, Session, Config
95
+
96
+ # Agent
97
+ agent = Agent(name="my-agent", model="claude-sonnet-4-6")
98
+ agent.run("task description") # One-shot task execution
99
+ agent.chat("message") # Interactive chat
100
+ agent.start() # Start agent runtime
101
+
102
+ # Session
103
+ session = agent.create_session()
104
+ session.add_message("user", "Hello")
105
+ session.save() # Persist to storage
106
+ session.load(session_id) # Resume session
107
+
108
+ # Config
109
+ config = Config.from_env() # Load from environment
110
+ config = Config.from_file("~/.continuum/config.toml") # Load from file
111
+ config.use("openai") # Switch provider
112
+ ```
113
+
114
+ ## License
115
+
116
+ MIT License
@@ -0,0 +1,86 @@
1
+ # Continuum Python SDK
2
+
3
+ A production-grade agent framework with crash safety guarantees.
4
+
5
+ ## Quick Start (3 steps)
6
+
7
+ ```python
8
+ from continuum import Agent
9
+
10
+ agent = Agent() # Auto-loads config from environment
11
+ result = agent.run("your task")
12
+ ```
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install continuum
18
+ ```
19
+
20
+ ## Configuration
21
+
22
+ ### Environment Variables
23
+
24
+ Priority: `CONTINUUM_*` > `CONTINUUM_*` > `ANTHROPIC_*`
25
+
26
+ ```bash
27
+ export CONTINUUM_API_KEY=your_api_key
28
+ export CONTINUUM_PROVIDER=anthropic # or openai, google
29
+ export CONTINUUM_MODEL=claude-sonnet-4-6
30
+ ```
31
+
32
+ ### Config File
33
+
34
+ Create `~/.continuum/config.toml`:
35
+
36
+ ```toml
37
+ [providers.anthropic]
38
+ api_key = "${ANTHROPIC_API_KEY}"
39
+ base_url = "https://api.anthropic.com/v1"
40
+ model = "claude-sonnet-4-6"
41
+
42
+ [providers.openai]
43
+ api_key = "${OPENAI_API_KEY}"
44
+ base_url = "https://api.openai.com/v1"
45
+ model = "gpt-4"
46
+
47
+ [settings]
48
+ session_auto_save = true
49
+ checkpoint_enabled = true
50
+ audit_enabled = true
51
+ ```
52
+
53
+ ## Features
54
+
55
+ - **Agent**: One-line agent creation with automatic configuration
56
+ - **Session**: Conversation history management with checkpoint support
57
+ - **Tools**: Built-in and custom tool registration
58
+ - **Memory**: Multi-layer memory system (episodic, semantic, procedural)
59
+ - **Config**: Multi-provider configuration with environment variable support
60
+
61
+ ## API Reference
62
+
63
+ ```python
64
+ from continuum import Agent, Session, Config
65
+
66
+ # Agent
67
+ agent = Agent(name="my-agent", model="claude-sonnet-4-6")
68
+ agent.run("task description") # One-shot task execution
69
+ agent.chat("message") # Interactive chat
70
+ agent.start() # Start agent runtime
71
+
72
+ # Session
73
+ session = agent.create_session()
74
+ session.add_message("user", "Hello")
75
+ session.save() # Persist to storage
76
+ session.load(session_id) # Resume session
77
+
78
+ # Config
79
+ config = Config.from_env() # Load from environment
80
+ config = Config.from_file("~/.continuum/config.toml") # Load from file
81
+ config.use("openai") # Switch provider
82
+ ```
83
+
84
+ ## License
85
+
86
+ MIT License
@@ -0,0 +1,157 @@
1
+ """Agent 性能基准测试"""
2
+
3
+ import sys
4
+ import os
5
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6
+
7
+ import time
8
+ import statistics
9
+ from typing import List, Callable
10
+
11
+ # 简单基准测试框架(避免pytest-benchmark依赖)
12
+ class BenchResult:
13
+ def __init__(self, name: str):
14
+ self.name = name
15
+ self.times: List[float] = []
16
+ self.result = None
17
+
18
+ def add(self, elapsed: float):
19
+ self.times.append(elapsed)
20
+
21
+ @property
22
+ def mean(self) -> float:
23
+ return statistics.mean(self.times) if self.times else 0
24
+
25
+ @property
26
+ def median(self) -> float:
27
+ return statistics.median(self.times) if self.times else 0
28
+
29
+ @property
30
+ def stdev(self) -> float:
31
+ return statistics.stdev(self.times) if len(self.times) > 1 else 0
32
+
33
+ @property
34
+ def min(self) -> float:
35
+ return min(self.times) if self.times else 0
36
+
37
+ @property
38
+ def max(self) -> float:
39
+ return max(self.times) if self.times else 0
40
+
41
+
42
+ def bench(func: Callable, iterations: int = 100) -> BenchResult:
43
+ """运行基准测试"""
44
+ result = BenchResult(func.__name__)
45
+
46
+ # 预热
47
+ func()
48
+
49
+ # 正式测试
50
+ for _ in range(iterations):
51
+ start = time.perf_counter()
52
+ func()
53
+ elapsed = time.perf_counter() - start
54
+ result.add(elapsed)
55
+
56
+ return result
57
+
58
+
59
+ def format_result(result: BenchResult) -> str:
60
+ """格式化结果"""
61
+ return f"""
62
+ {result.name}:
63
+ Iterations: {len(result.times)}
64
+ Mean: {result.mean*1000:.4f} ms
65
+ Median: {result.median*1000:.4f} ms
66
+ StdDev: {result.stdev*1000:.4f} ms
67
+ Min: {result.min*1000:.4f} ms
68
+ Max: {result.max*1000:.4f} ms
69
+ """
70
+
71
+
72
+ # ========================================
73
+ # Agent 基准测试
74
+ # ========================================
75
+
76
+ def bench_agent_creation():
77
+ """测试 Agent 创建时间"""
78
+ from continuum_sdk import Agent
79
+ return Agent()
80
+
81
+
82
+ def bench_agent_start():
83
+ """测试 Agent 启动时间"""
84
+ from continuum_sdk import Agent
85
+ agent = Agent()
86
+ agent.start()
87
+ return agent
88
+
89
+
90
+ def bench_agent_run():
91
+ """测试 Agent run 方法时间"""
92
+ from continuum_sdk import Agent
93
+ agent = Agent()
94
+ agent.start()
95
+ return agent.run("test task", auto_start=False)
96
+
97
+
98
+ def bench_agent_chat():
99
+ """测试 Agent chat 方法时间"""
100
+ from continuum_sdk import Agent
101
+ agent = Agent()
102
+ agent.start()
103
+ return agent.chat("hello")
104
+
105
+
106
+ def bench_agent_with_config():
107
+ """测试带配置的 Agent 创建时间"""
108
+ from continuum_sdk import Agent, Config
109
+ config = Config(provider="anthropic", model="claude-sonnet-4-6")
110
+ return Agent(config=config)
111
+
112
+
113
+ def bench_agent_create_session():
114
+ """测试会话创建时间"""
115
+ from continuum_sdk import Agent
116
+ agent = Agent()
117
+ return agent.create_session()
118
+
119
+
120
+ def bench_agent_register_tool():
121
+ """测试工具注册时间"""
122
+ from continuum_sdk import Agent
123
+ agent = Agent()
124
+ for i in range(10):
125
+ agent.register_tool(f"tool_{i}", lambda x: x)
126
+ return agent
127
+
128
+
129
+ def run_agent_benchmarks():
130
+ """运行所有 Agent 基准测试"""
131
+ print("=" * 50)
132
+ print("Agent Performance Benchmarks")
133
+ print("=" * 50)
134
+
135
+ tests = [
136
+ ("Agent Creation", bench_agent_creation, 1000),
137
+ ("Agent with Config", bench_agent_with_config, 1000),
138
+ ("Agent Start", bench_agent_start, 100),
139
+ ("Agent Run", bench_agent_run, 100),
140
+ ("Agent Chat", bench_agent_chat, 100),
141
+ ("Create Session", bench_agent_create_session, 1000),
142
+ ("Register 10 Tools", bench_agent_register_tool, 100),
143
+ ]
144
+
145
+ results = []
146
+ for name, func, iterations in tests:
147
+ print(f"\nRunning: {name}...")
148
+ func.__name__ = name
149
+ result = bench(func, iterations)
150
+ results.append(result)
151
+ print(format_result(result))
152
+
153
+ return results
154
+
155
+
156
+ if __name__ == "__main__":
157
+ run_agent_benchmarks()
@@ -0,0 +1,181 @@
1
+ """Config 性能基准测试"""
2
+
3
+ import sys
4
+ import os
5
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6
+
7
+ import time
8
+ import statistics
9
+
10
+
11
+ class BenchResult:
12
+ def __init__(self, name: str):
13
+ self.name = name
14
+ self.times = []
15
+
16
+ def add(self, elapsed: float):
17
+ self.times.append(elapsed)
18
+
19
+ @property
20
+ def mean(self) -> float:
21
+ return statistics.mean(self.times) if self.times else 0
22
+
23
+ @property
24
+ def median(self) -> float:
25
+ return statistics.median(self.times) if self.times else 0
26
+
27
+ @property
28
+ def stdev(self) -> float:
29
+ return statistics.stdev(self.times) if len(self.times) > 1 else 0
30
+
31
+ @property
32
+ def min(self) -> float:
33
+ return min(self.times) if self.times else 0
34
+
35
+ @property
36
+ def max(self) -> float:
37
+ return max(self.times) if self.times else 0
38
+
39
+
40
+ def bench(func, iterations=100):
41
+ """运行基准测试"""
42
+ result = BenchResult(func.__name__)
43
+
44
+ # 预热
45
+ func()
46
+
47
+ # 正式测试
48
+ for _ in range(iterations):
49
+ start = time.perf_counter()
50
+ func()
51
+ elapsed = time.perf_counter() - start
52
+ result.add(elapsed)
53
+
54
+ return result
55
+
56
+
57
+ def format_result(result):
58
+ return f"""
59
+ {result.name}:
60
+ Iterations: {len(result.times)}
61
+ Mean: {result.mean*1000:.4f} ms
62
+ Median: {result.median*1000:.4f} ms
63
+ StdDev: {result.stdev*1000:.4f} ms
64
+ Min: {result.min*1000:.4f} ms
65
+ Max: {result.max*1000:.4f} ms
66
+ """
67
+
68
+
69
+ # ========================================
70
+ # Config 基准测试
71
+ # ========================================
72
+
73
+ def bench_config_creation():
74
+ """测试 Config 创建时间"""
75
+ from continuum_sdk import Config
76
+ return Config()
77
+
78
+
79
+ def bench_config_from_env():
80
+ """测试从环境变量加载"""
81
+ from continuum_sdk import Config
82
+ return Config.from_env()
83
+
84
+
85
+ def bench_config_from_default():
86
+ """测试默认加载"""
87
+ from continuum_sdk import Config
88
+ return Config.from_default()
89
+
90
+
91
+ def bench_config_with_params():
92
+ """测试带参数创建"""
93
+ from continuum_sdk import Config
94
+ return Config(
95
+ provider="anthropic",
96
+ api_key="test-key",
97
+ model="claude-sonnet-4-6",
98
+ max_tokens=8192,
99
+ temperature=0.7
100
+ )
101
+
102
+
103
+ def bench_config_use_provider():
104
+ """测试提供商切换"""
105
+ from continuum_sdk import Config
106
+ config = Config()
107
+ config.add_provider("test", api_key="test-key")
108
+ config.use("test")
109
+ return config
110
+
111
+
112
+ def bench_config_to_dict():
113
+ """测试序列化"""
114
+ from continuum_sdk import Config
115
+ config = Config(provider="anthropic", model="claude-sonnet-4-6")
116
+ return config.to_dict()
117
+
118
+
119
+ def bench_config_from_dict():
120
+ """测试反序列化"""
121
+ from continuum_sdk import Config
122
+ data = {"provider": "anthropic", "model": "claude-sonnet-4-6"}
123
+ return Config.from_dict(data)
124
+
125
+
126
+ def bench_config_load_toml():
127
+ """测试TOML文件加载"""
128
+ from continuum_sdk import Config
129
+ from pathlib import Path
130
+ template_path = Path(__file__).parent.parent.parent / "templates" / "config.toml"
131
+ if template_path.exists():
132
+ return Config.from_file(str(template_path))
133
+ return Config()
134
+
135
+
136
+ def bench_config_add_provider():
137
+ """测试添加提供商"""
138
+ from continuum_sdk import Config
139
+ config = Config()
140
+ config.add_provider("custom", api_key="key", model="model")
141
+ return config
142
+
143
+
144
+ def bench_config_list_providers():
145
+ """测试列出提供商"""
146
+ from continuum_sdk.config import list_providers
147
+ return list_providers()
148
+
149
+
150
+ def run_config_benchmarks():
151
+ """运行所有 Config 基准测试"""
152
+ print("=" * 50)
153
+ print("Config Performance Benchmarks")
154
+ print("=" * 50)
155
+
156
+ tests = [
157
+ ("Config Creation", bench_config_creation, 1000),
158
+ ("Config from env", bench_config_from_env, 500),
159
+ ("Config from default", bench_config_from_default, 500),
160
+ ("Config with params", bench_config_with_params, 1000),
161
+ ("Config use provider", bench_config_use_provider, 1000),
162
+ ("Config to_dict", bench_config_to_dict, 5000),
163
+ ("Config from_dict", bench_config_from_dict, 5000),
164
+ ("Config load TOML", bench_config_load_toml, 100),
165
+ ("Config add provider", bench_config_add_provider, 1000),
166
+ ("List providers", bench_config_list_providers, 1000),
167
+ ]
168
+
169
+ results = []
170
+ for name, func, iterations in tests:
171
+ print(f"\nRunning: {name}...")
172
+ func.__name__ = name
173
+ result = bench(func, iterations)
174
+ results.append(result)
175
+ print(format_result(result))
176
+
177
+ return results
178
+
179
+
180
+ if __name__ == "__main__":
181
+ run_config_benchmarks()