openconstruct 0.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SuperInstance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: openconstruct
3
+ Version: 0.1.0
4
+ Summary: Python thin client for OpenConstruct - SuperInstance ecosystem onboarding
5
+ Author-email: SuperInstance <contact@superinstance.dev>
6
+ Project-URL: Homepage, https://github.com/SuperInstance/openconstruct-python
7
+ Project-URL: Repository, https://github.com/SuperInstance/openconstruct-python
8
+ Project-URL: Issues, https://github.com/SuperInstance/openconstruct-python/issues
9
+ Keywords: openconstruct,agent,onboarding,superinstance
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0; extra == "dev"
24
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # OpenConstruct Python — Thin Client for Agent Onboarding
28
+
29
+ Python client for [OpenConstruct](https://github.com/SuperInstance/OpenConstruct). Onboard agents into the SuperInstance ecosystem in under 10 lines.
30
+
31
+ ## What This Gives You
32
+
33
+ - **5-phase onboarding** — `start()` → `declare_agent()` → `select_modules()` → `choose_interface()` → `generate_config()`
34
+ - **Module registry** — domain-filtered catalog of available modules
35
+ - **Pip-installable** — `pip install openconstruct`
36
+ - **Zero runtime dependencies** — pure Python, no native extensions
37
+
38
+ ## Quick Start
39
+
40
+ ```python
41
+ from openconstruct import OpenConstructClient, AgentIdentity
42
+
43
+ client = OpenConstructClient()
44
+ client.start()
45
+
46
+ identity = AgentIdentity(
47
+ name="my-agent",
48
+ model="claude-4",
49
+ capabilities=["code_generation", "web_search", "file_ops"],
50
+ tools=["exec", "read", "write"]
51
+ )
52
+ client.declare_agent(identity)
53
+
54
+ modules = client.list_modules(domain="math")
55
+ client.select_modules(["spectral-graph-core", "plato-room"])
56
+ client.choose_interface(["cli", "api"])
57
+
58
+ config = client.generate_config()
59
+ print(config)
60
+ ```
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ pip install openconstruct
66
+ ```
67
+
68
+ ## Testing
69
+
70
+ ```bash
71
+ pip install -e ".[dev]"
72
+ pytest
73
+ ```
74
+
75
+ ## How It Fits
76
+
77
+ One of the [polyglot OpenConstruct bindings](https://github.com/SuperInstance/OpenConstruct). Used by [openconstruct-jupyter](https://github.com/SuperInstance/openconstruct-jupyter) for notebook integration. See [openconstruct-examples](https://github.com/SuperInstance/openconstruct-examples) for a Python onboarding walkthrough.
78
+
79
+ ## License
80
+
81
+ MIT
@@ -0,0 +1,55 @@
1
+ # OpenConstruct Python — Thin Client for Agent Onboarding
2
+
3
+ Python client for [OpenConstruct](https://github.com/SuperInstance/OpenConstruct). Onboard agents into the SuperInstance ecosystem in under 10 lines.
4
+
5
+ ## What This Gives You
6
+
7
+ - **5-phase onboarding** — `start()` → `declare_agent()` → `select_modules()` → `choose_interface()` → `generate_config()`
8
+ - **Module registry** — domain-filtered catalog of available modules
9
+ - **Pip-installable** — `pip install openconstruct`
10
+ - **Zero runtime dependencies** — pure Python, no native extensions
11
+
12
+ ## Quick Start
13
+
14
+ ```python
15
+ from openconstruct import OpenConstructClient, AgentIdentity
16
+
17
+ client = OpenConstructClient()
18
+ client.start()
19
+
20
+ identity = AgentIdentity(
21
+ name="my-agent",
22
+ model="claude-4",
23
+ capabilities=["code_generation", "web_search", "file_ops"],
24
+ tools=["exec", "read", "write"]
25
+ )
26
+ client.declare_agent(identity)
27
+
28
+ modules = client.list_modules(domain="math")
29
+ client.select_modules(["spectral-graph-core", "plato-room"])
30
+ client.choose_interface(["cli", "api"])
31
+
32
+ config = client.generate_config()
33
+ print(config)
34
+ ```
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install openconstruct
40
+ ```
41
+
42
+ ## Testing
43
+
44
+ ```bash
45
+ pip install -e ".[dev]"
46
+ pytest
47
+ ```
48
+
49
+ ## How It Fits
50
+
51
+ One of the [polyglot OpenConstruct bindings](https://github.com/SuperInstance/OpenConstruct). Used by [openconstruct-jupyter](https://github.com/SuperInstance/openconstruct-jupyter) for notebook integration. See [openconstruct-examples](https://github.com/SuperInstance/openconstruct-examples) for a Python onboarding walkthrough.
52
+
53
+ ## License
54
+
55
+ MIT
@@ -0,0 +1,15 @@
1
+ """OpenConstruct - Python thin client for SuperInstance ecosystem onboarding."""
2
+
3
+ from openconstruct.client import OpenConstructClient
4
+ from openconstruct.registry import ModuleRegistry
5
+ from openconstruct.types import AgentIdentity, ModuleInfo, OnboardingConfig
6
+
7
+ __version__ = "0.1.0"
8
+
9
+ __all__ = [
10
+ "OpenConstructClient",
11
+ "ModuleRegistry",
12
+ "AgentIdentity",
13
+ "ModuleInfo",
14
+ "OnboardingConfig",
15
+ ]
@@ -0,0 +1,165 @@
1
+ """Main OpenConstruct client for agent onboarding."""
2
+
3
+ import uuid
4
+ from datetime import datetime
5
+ from typing import Any, Dict, List, Optional
6
+
7
+ from openconstruct.registry import ModuleRegistry
8
+ from openconstruct.types import AgentIdentity, ModuleInfo, OnboardingConfig
9
+
10
+
11
+ class OpenConstructClient:
12
+ """Main client class for OpenConstruct onboarding."""
13
+
14
+ def __init__(self):
15
+ """Initialize the OpenConstruct client."""
16
+ self._session_id: Optional[str] = None
17
+ self._started = False
18
+ self._identity: Optional[AgentIdentity] = None
19
+ self._selected_modules: List[ModuleInfo] = []
20
+ self._selected_interfaces: List[str] = []
21
+ self._registry = ModuleRegistry()
22
+
23
+ def start(self) -> str:
24
+ """
25
+ Start a new onboarding session.
26
+
27
+ Returns:
28
+ Session ID for the new session
29
+ """
30
+ self._session_id = str(uuid.uuid4())
31
+ self._started = True
32
+ self._identity = None
33
+ self._selected_modules = []
34
+ self._selected_interfaces = []
35
+ return self._session_id
36
+
37
+ def declare_agent(self, identity: AgentIdentity) -> None:
38
+ """
39
+ Declare agent identity.
40
+
41
+ Args:
42
+ identity: AgentIdentity object with agent details
43
+
44
+ Raises:
45
+ RuntimeError: If session not started
46
+ """
47
+ if not self._started:
48
+ raise RuntimeError("Session not started. Call start() first.")
49
+ self._identity = identity
50
+
51
+ def list_modules(self, domain: Optional[str] = None) -> List[Dict[str, Any]]:
52
+ """
53
+ List available modules, optionally filtered by domain.
54
+
55
+ Args:
56
+ domain: Optional domain filter
57
+
58
+ Returns:
59
+ List of module dictionaries
60
+ """
61
+ modules = self._registry.list_modules(domain)
62
+ return [m.to_dict() for m in modules]
63
+
64
+ def select_modules(self, module_ids: List[str]) -> None:
65
+ """
66
+ Select modules for the agent.
67
+
68
+ Args:
69
+ module_ids: List of module IDs to select
70
+
71
+ Raises:
72
+ RuntimeError: If session not started
73
+ ValueError: If any module ID is invalid
74
+ """
75
+ if not self._started:
76
+ raise RuntimeError("Session not started. Call start() first.")
77
+
78
+ for module_id in module_ids:
79
+ if not self._registry.module_exists(module_id):
80
+ raise ValueError(f"Module '{module_id}' not found")
81
+
82
+ self._selected_modules = [
83
+ self._registry.get_module(mid) for mid in module_ids if self._registry.get_module(mid)
84
+ ]
85
+
86
+ def choose_interface(self, interfaces: List[str]) -> None:
87
+ """
88
+ Choose interface types for the agent.
89
+
90
+ Args:
91
+ interfaces: List of interface types (e.g., ["cli", "api"])
92
+
93
+ Raises:
94
+ RuntimeError: If session not started
95
+ """
96
+ if not self._started:
97
+ raise RuntimeError("Session not started. Call start() first.")
98
+ self._selected_interfaces = interfaces
99
+
100
+ def generate_config(self) -> Dict[str, Any]:
101
+ """
102
+ Generate the final onboarding configuration.
103
+
104
+ Returns:
105
+ Dictionary containing the complete onboarding configuration
106
+
107
+ Raises:
108
+ RuntimeError: If session not started or identity not declared
109
+ """
110
+ if not self._started:
111
+ raise RuntimeError("Session not started. Call start() first.")
112
+
113
+ if not self._identity:
114
+ raise RuntimeError("Agent identity not declared. Call declare_agent() first.")
115
+
116
+ config = OnboardingConfig(
117
+ session_id=self._session_id,
118
+ agent=self._identity.to_dict(),
119
+ selected_modules=[m.to_dict() for m in self._selected_modules],
120
+ selected_interfaces=self._selected_interfaces,
121
+ workspace=self._build_workspace_config(),
122
+ created_at=datetime.utcnow().isoformat() + "Z",
123
+ )
124
+
125
+ return config.to_dict()
126
+
127
+ def _build_workspace_config(self) -> Dict[str, Any]:
128
+ """
129
+ Build workspace configuration based on selections.
130
+
131
+ Returns:
132
+ Dictionary with workspace configuration
133
+ """
134
+ workspace_config = {
135
+ "agent_name": self._identity.name if self._identity else "",
136
+ "modules": [m.id for m in self._selected_modules],
137
+ "interfaces": self._selected_interfaces,
138
+ "environment_variables": {
139
+ "OPENCONSTRUCT_SESSION_ID": self._session_id or "",
140
+ },
141
+ }
142
+
143
+ # Add module-specific configurations
144
+ for module in self._selected_modules:
145
+ workspace_config[f"module_{module.id}_config"] = {
146
+ "version": module.version,
147
+ "enabled": True,
148
+ }
149
+
150
+ return workspace_config
151
+
152
+ @property
153
+ def session_id(self) -> Optional[str]:
154
+ """Get the current session ID."""
155
+ return self._session_id
156
+
157
+ @property
158
+ def is_started(self) -> bool:
159
+ """Check if a session is started."""
160
+ return self._started
161
+
162
+ @property
163
+ def identity(self) -> Optional[AgentIdentity]:
164
+ """Get the declared agent identity."""
165
+ return self._identity
@@ -0,0 +1,112 @@
1
+ """Module registry for browsing available modules."""
2
+
3
+ import uuid
4
+ from typing import List, Optional
5
+
6
+ from openconstruct.types import ModuleInfo
7
+
8
+
9
+ class ModuleRegistry:
10
+ """Registry of available OpenConstruct modules."""
11
+
12
+ def __init__(self):
13
+ """Initialize the module registry with sample modules."""
14
+ self._modules = self._initialize_modules()
15
+
16
+ def _initialize_modules(self) -> dict:
17
+ """Initialize with sample modules."""
18
+ return {
19
+ "spectral-graph-core": ModuleInfo(
20
+ id="spectral-graph-core",
21
+ name="Spectral Graph Core",
22
+ domain="math",
23
+ description="Core spectral graph theory operations and algorithms",
24
+ version="1.0.0",
25
+ dependencies=[],
26
+ requires_agent_capabilities=["computation"],
27
+ ),
28
+ "plato-room": ModuleInfo(
29
+ id="plato-room",
30
+ name="Plato Room",
31
+ domain="collaboration",
32
+ description="Virtual collaboration space for agent discussions",
33
+ version="0.9.0",
34
+ dependencies=["spectral-graph-core"],
35
+ requires_agent_capabilities=["communication"],
36
+ ),
37
+ "tensor-flow": ModuleInfo(
38
+ id="tensor-flow",
39
+ name="Tensor Flow Operations",
40
+ domain="math",
41
+ description="Advanced tensor manipulation and operations",
42
+ version="2.1.0",
43
+ dependencies=[],
44
+ requires_agent_capabilities=["computation"],
45
+ ),
46
+ "memory-bank": ModuleInfo(
47
+ id="memory-bank",
48
+ name="Memory Bank",
49
+ domain="storage",
50
+ description="Persistent memory storage for agents",
51
+ version="1.2.0",
52
+ dependencies=[],
53
+ requires_agent_capabilities=["persistence"],
54
+ ),
55
+ "code-analyzer": ModuleInfo(
56
+ id="code-analyzer",
57
+ name="Code Analyzer",
58
+ domain="analysis",
59
+ description="Static code analysis and quality checks",
60
+ version="0.8.0",
61
+ dependencies=[],
62
+ requires_agent_capabilities=["code_generation"],
63
+ ),
64
+ "web-crawler": ModuleInfo(
65
+ id="web-crawler",
66
+ name="Web Crawler",
67
+ domain="web",
68
+ description="Efficient web crawling and data extraction",
69
+ version="1.5.0",
70
+ dependencies=[],
71
+ requires_agent_capabilities=["web_search"],
72
+ ),
73
+ }
74
+
75
+ def list_modules(self, domain: Optional[str] = None) -> List[ModuleInfo]:
76
+ """
77
+ List all available modules, optionally filtered by domain.
78
+
79
+ Args:
80
+ domain: Optional domain filter (e.g., "math", "collaboration")
81
+
82
+ Returns:
83
+ List of ModuleInfo objects
84
+ """
85
+ modules = list(self._modules.values())
86
+ if domain:
87
+ modules = [m for m in modules if m.domain == domain]
88
+ return modules
89
+
90
+ def get_module(self, module_id: str) -> Optional[ModuleInfo]:
91
+ """
92
+ Get a specific module by ID.
93
+
94
+ Args:
95
+ module_id: The module identifier
96
+
97
+ Returns:
98
+ ModuleInfo if found, None otherwise
99
+ """
100
+ return self._modules.get(module_id)
101
+
102
+ def module_exists(self, module_id: str) -> bool:
103
+ """
104
+ Check if a module exists.
105
+
106
+ Args:
107
+ module_id: The module identifier
108
+
109
+ Returns:
110
+ True if module exists, False otherwise
111
+ """
112
+ return module_id in self._modules
@@ -0,0 +1,75 @@
1
+ """Data types for OpenConstruct."""
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Any, Dict, List, Optional
5
+
6
+
7
+ @dataclass
8
+ class AgentIdentity:
9
+ """Agent self-declaration for onboarding."""
10
+
11
+ name: str
12
+ model: str
13
+ capabilities: List[str] = field(default_factory=list)
14
+ tools: List[str] = field(default_factory=list)
15
+ description: Optional[str] = None
16
+ version: Optional[str] = None
17
+
18
+ def to_dict(self) -> Dict[str, Any]:
19
+ """Convert identity to dictionary."""
20
+ return {
21
+ "name": self.name,
22
+ "model": self.model,
23
+ "capabilities": self.capabilities,
24
+ "tools": self.tools,
25
+ "description": self.description,
26
+ "version": self.version,
27
+ }
28
+
29
+
30
+ @dataclass
31
+ class ModuleInfo:
32
+ """Information about an available module."""
33
+
34
+ id: str
35
+ name: str
36
+ domain: str
37
+ description: str
38
+ version: str
39
+ dependencies: List[str] = field(default_factory=list)
40
+ requires_agent_capabilities: List[str] = field(default_factory=list)
41
+
42
+ def to_dict(self) -> Dict[str, Any]:
43
+ """Convert module info to dictionary."""
44
+ return {
45
+ "id": self.id,
46
+ "name": self.name,
47
+ "domain": self.domain,
48
+ "description": self.description,
49
+ "version": self.version,
50
+ "dependencies": self.dependencies,
51
+ "requires_agent_capabilities": self.requires_agent_capabilities,
52
+ }
53
+
54
+
55
+ @dataclass
56
+ class OnboardingConfig:
57
+ """Final onboarding configuration output."""
58
+
59
+ session_id: str
60
+ agent: Dict[str, Any]
61
+ selected_modules: List[Dict[str, Any]]
62
+ selected_interfaces: List[str]
63
+ workspace: Dict[str, Any] = field(default_factory=dict)
64
+ created_at: str = ""
65
+
66
+ def to_dict(self) -> Dict[str, Any]:
67
+ """Convert config to dictionary."""
68
+ return {
69
+ "session_id": self.session_id,
70
+ "agent": self.agent,
71
+ "selected_modules": self.selected_modules,
72
+ "selected_interfaces": self.selected_interfaces,
73
+ "workspace": self.workspace,
74
+ "created_at": self.created_at,
75
+ }
@@ -0,0 +1,81 @@
1
+ Metadata-Version: 2.4
2
+ Name: openconstruct
3
+ Version: 0.1.0
4
+ Summary: Python thin client for OpenConstruct - SuperInstance ecosystem onboarding
5
+ Author-email: SuperInstance <contact@superinstance.dev>
6
+ Project-URL: Homepage, https://github.com/SuperInstance/openconstruct-python
7
+ Project-URL: Repository, https://github.com/SuperInstance/openconstruct-python
8
+ Project-URL: Issues, https://github.com/SuperInstance/openconstruct-python/issues
9
+ Keywords: openconstruct,agent,onboarding,superinstance
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0; extra == "dev"
24
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # OpenConstruct Python — Thin Client for Agent Onboarding
28
+
29
+ Python client for [OpenConstruct](https://github.com/SuperInstance/OpenConstruct). Onboard agents into the SuperInstance ecosystem in under 10 lines.
30
+
31
+ ## What This Gives You
32
+
33
+ - **5-phase onboarding** — `start()` → `declare_agent()` → `select_modules()` → `choose_interface()` → `generate_config()`
34
+ - **Module registry** — domain-filtered catalog of available modules
35
+ - **Pip-installable** — `pip install openconstruct`
36
+ - **Zero runtime dependencies** — pure Python, no native extensions
37
+
38
+ ## Quick Start
39
+
40
+ ```python
41
+ from openconstruct import OpenConstructClient, AgentIdentity
42
+
43
+ client = OpenConstructClient()
44
+ client.start()
45
+
46
+ identity = AgentIdentity(
47
+ name="my-agent",
48
+ model="claude-4",
49
+ capabilities=["code_generation", "web_search", "file_ops"],
50
+ tools=["exec", "read", "write"]
51
+ )
52
+ client.declare_agent(identity)
53
+
54
+ modules = client.list_modules(domain="math")
55
+ client.select_modules(["spectral-graph-core", "plato-room"])
56
+ client.choose_interface(["cli", "api"])
57
+
58
+ config = client.generate_config()
59
+ print(config)
60
+ ```
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ pip install openconstruct
66
+ ```
67
+
68
+ ## Testing
69
+
70
+ ```bash
71
+ pip install -e ".[dev]"
72
+ pytest
73
+ ```
74
+
75
+ ## How It Fits
76
+
77
+ One of the [polyglot OpenConstruct bindings](https://github.com/SuperInstance/OpenConstruct). Used by [openconstruct-jupyter](https://github.com/SuperInstance/openconstruct-jupyter) for notebook integration. See [openconstruct-examples](https://github.com/SuperInstance/openconstruct-examples) for a Python onboarding walkthrough.
78
+
79
+ ## License
80
+
81
+ MIT
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ openconstruct/__init__.py
5
+ openconstruct/client.py
6
+ openconstruct/registry.py
7
+ openconstruct/types.py
8
+ openconstruct.egg-info/PKG-INFO
9
+ openconstruct.egg-info/SOURCES.txt
10
+ openconstruct.egg-info/dependency_links.txt
11
+ openconstruct.egg-info/requires.txt
12
+ openconstruct.egg-info/top_level.txt
13
+ tests/test_client.py
@@ -0,0 +1,4 @@
1
+
2
+ [dev]
3
+ pytest>=7.0
4
+ pytest-cov>=4.0
@@ -0,0 +1 @@
1
+ openconstruct
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "openconstruct"
7
+ version = "0.1.0"
8
+ description = "Python thin client for OpenConstruct - SuperInstance ecosystem onboarding"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ authors = [
12
+ {name = "SuperInstance", email = "contact@superinstance.dev"}
13
+ ]
14
+ keywords = ["openconstruct", "agent", "onboarding", "superinstance"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.8",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ ]
26
+ dependencies = []
27
+
28
+ [project.optional-dependencies]
29
+ dev = ["pytest>=7.0", "pytest-cov>=4.0"]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/SuperInstance/openconstruct-python"
33
+ Repository = "https://github.com/SuperInstance/openconstruct-python"
34
+ Issues = "https://github.com/SuperInstance/openconstruct-python/issues"
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["."]
38
+ include = ["openconstruct*"]
39
+
40
+ [tool.pytest.ini_options]
41
+ testpaths = ["tests"]
42
+ python_files = ["test_*.py"]
43
+ python_classes = ["Test*"]
44
+ python_functions = ["test_*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,247 @@
1
+ """Tests for OpenConstructClient."""
2
+
3
+ import pytest
4
+
5
+ from openconstruct import OpenConstructClient, AgentIdentity
6
+
7
+
8
+ class TestClientStart:
9
+ """Tests for client start functionality."""
10
+
11
+ def test_start_creates_session(self):
12
+ """Test that start() creates a session with a valid ID."""
13
+ client = OpenConstructClient()
14
+ session_id = client.start()
15
+
16
+ assert isinstance(session_id, str)
17
+ assert len(session_id) > 0
18
+ assert client.is_started
19
+ assert client.session_id == session_id
20
+
21
+
22
+ class TestClientDeclareAgent:
23
+ """Tests for agent declaration."""
24
+
25
+ def test_declare_agent_stores_identity(self):
26
+ """Test that declare_agent() stores the identity."""
27
+ client = OpenConstructClient()
28
+ client.start()
29
+
30
+ identity = AgentIdentity(
31
+ name="test-agent",
32
+ model="gpt-4",
33
+ capabilities=["test"],
34
+ tools=["exec"]
35
+ )
36
+ client.declare_agent(identity)
37
+
38
+ assert client.identity is not None
39
+ assert client.identity.name == "test-agent"
40
+ assert client.identity.model == "gpt-4"
41
+
42
+ def test_declare_agent_fails_without_start(self):
43
+ """Test that declare_agent() raises error without start()."""
44
+ client = OpenConstructClient()
45
+ identity = AgentIdentity(name="test", model="gpt-4")
46
+
47
+ with pytest.raises(RuntimeError, match="Session not started"):
48
+ client.declare_agent(identity)
49
+
50
+
51
+ class TestClientListModules:
52
+ """Tests for module listing."""
53
+
54
+ def test_list_modules_returns_list(self):
55
+ """Test that list_modules() returns a list."""
56
+ client = OpenConstructClient()
57
+ client.start()
58
+
59
+ modules = client.list_modules()
60
+
61
+ assert isinstance(modules, list)
62
+ assert len(modules) > 0
63
+ assert all(isinstance(m, dict) for m in modules)
64
+
65
+ def test_list_modules_filters_by_domain(self):
66
+ """Test that list_modules(domain=X) filters correctly."""
67
+ client = OpenConstructClient()
68
+ client.start()
69
+
70
+ math_modules = client.list_modules(domain="math")
71
+ all_modules = client.list_modules()
72
+
73
+ assert len(math_modules) < len(all_modules)
74
+ assert all(m["domain"] == "math" for m in math_modules)
75
+
76
+ def test_list_modules_with_unknown_domain(self):
77
+ """Test that list_modules() with unknown domain returns empty list."""
78
+ client = OpenConstructClient()
79
+ client.start()
80
+
81
+ modules = client.list_modules(domain="nonexistent")
82
+
83
+ assert isinstance(modules, list)
84
+ assert len(modules) == 0
85
+
86
+
87
+ class TestClientSelectModules:
88
+ """Tests for module selection."""
89
+
90
+ def test_select_modules_stores_selection(self):
91
+ """Test that select_modules() stores the selection."""
92
+ client = OpenConstructClient()
93
+ client.start()
94
+ client.declare_agent(AgentIdentity(name="test", model="gpt-4"))
95
+
96
+ client.select_modules(["spectral-graph-core", "plato-room"])
97
+
98
+ config = client.generate_config()
99
+ assert len(config["selected_modules"]) == 2
100
+
101
+ def test_select_modules_fails_without_start(self):
102
+ """Test that select_modules() raises error without start()."""
103
+ client = OpenConstructClient()
104
+
105
+ with pytest.raises(RuntimeError, match="Session not started"):
106
+ client.select_modules(["spectral-graph-core"])
107
+
108
+ def test_select_modules_fails_with_invalid_module(self):
109
+ """Test that select_modules() raises error with invalid module."""
110
+ client = OpenConstructClient()
111
+ client.start()
112
+
113
+ with pytest.raises(ValueError, match="not found"):
114
+ client.select_modules(["nonexistent-module"])
115
+
116
+ def test_select_modules_with_mixed_valid_invalid(self):
117
+ """Test that select_modules() fails with mix of valid and invalid modules."""
118
+ client = OpenConstructClient()
119
+ client.start()
120
+
121
+ with pytest.raises(ValueError, match="not found"):
122
+ client.select_modules(["spectral-graph-core", "invalid-module"])
123
+
124
+
125
+ class TestClientChooseInterface:
126
+ """Tests for interface selection."""
127
+
128
+ def test_choose_interface_stores_choice(self):
129
+ """Test that choose_interface() stores the choice."""
130
+ client = OpenConstructClient()
131
+ client.start()
132
+ client.declare_agent(AgentIdentity(name="test", model="gpt-4"))
133
+
134
+ client.choose_interface(["cli", "api"])
135
+
136
+ config = client.generate_config()
137
+ assert config["selected_interfaces"] == ["cli", "api"]
138
+
139
+ def test_choose_interface_fails_without_start(self):
140
+ """Test that choose_interface() raises error without start()."""
141
+ client = OpenConstructClient()
142
+
143
+ with pytest.raises(RuntimeError, match="Session not started"):
144
+ client.choose_interface(["cli"])
145
+
146
+
147
+ class TestClientGenerateConfig:
148
+ """Tests for configuration generation."""
149
+
150
+ def test_generate_config_produces_dict(self):
151
+ """Test that generate_config() produces a dictionary."""
152
+ client = OpenConstructClient()
153
+ client.start()
154
+ client.declare_agent(AgentIdentity(name="test", model="gpt-4"))
155
+
156
+ config = client.generate_config()
157
+
158
+ assert isinstance(config, dict)
159
+
160
+ def test_generate_config_has_required_fields(self):
161
+ """Test that generate_config() has all required fields."""
162
+ client = OpenConstructClient()
163
+ client.start()
164
+ client.declare_agent(AgentIdentity(name="test", model="gpt-4"))
165
+
166
+ config = client.generate_config()
167
+
168
+ assert "session_id" in config
169
+ assert "agent" in config
170
+ assert "selected_modules" in config
171
+ assert "selected_interfaces" in config
172
+ assert "workspace" in config
173
+ assert "created_at" in config
174
+
175
+ def test_generate_config_fails_without_start(self):
176
+ """Test that generate_config() raises error without start()."""
177
+ client = OpenConstructClient()
178
+
179
+ with pytest.raises(RuntimeError, match="Session not started"):
180
+ client.generate_config()
181
+
182
+ def test_generate_config_fails_without_identity(self):
183
+ """Test that generate_config() raises error without identity."""
184
+ client = OpenConstructClient()
185
+ client.start()
186
+
187
+ with pytest.raises(RuntimeError, match="Agent identity not declared"):
188
+ client.generate_config()
189
+
190
+
191
+ class TestClientFullLifecycle:
192
+ """Tests for the complete client lifecycle."""
193
+
194
+ def test_full_lifecycle(self):
195
+ """Test the complete onboarding flow."""
196
+ client = OpenConstructClient()
197
+
198
+ # Start session
199
+ session_id = client.start()
200
+ assert session_id is not None
201
+
202
+ # Declare agent
203
+ identity = AgentIdentity(
204
+ name="my-agent",
205
+ model="claude-4",
206
+ capabilities=["code_generation", "web_search", "file_ops"],
207
+ tools=["exec", "read", "write"]
208
+ )
209
+ client.declare_agent(identity)
210
+ assert client.identity.name == "my-agent"
211
+
212
+ # List and select modules
213
+ modules = client.list_modules(domain="math")
214
+ assert len(modules) > 0
215
+
216
+ client.select_modules(["spectral-graph-core", "plato-room"])
217
+
218
+ # Choose interfaces
219
+ client.choose_interface(["cli", "api"])
220
+
221
+ # Generate config
222
+ config = client.generate_config()
223
+
224
+ # Verify structure
225
+ assert config["session_id"] == session_id
226
+ assert config["agent"]["name"] == "my-agent"
227
+ assert len(config["selected_modules"]) == 2
228
+ assert config["selected_interfaces"] == ["cli", "api"]
229
+ assert "workspace" in config
230
+ assert config["created_at"] != ""
231
+
232
+ def test_lifecycle_with_multiple_sessions(self):
233
+ """Test that starting a new session resets state."""
234
+ client = OpenConstructClient()
235
+
236
+ # First session
237
+ client.start()
238
+ client.declare_agent(AgentIdentity(name="agent1", model="gpt-4"))
239
+ session1_id = client.session_id
240
+
241
+ # Second session
242
+ client.start()
243
+ client.declare_agent(AgentIdentity(name="agent2", model="claude-4"))
244
+ session2_id = client.session_id
245
+
246
+ assert session1_id != session2_id
247
+ assert client.identity.name == "agent2"