helix-protocol 0.1.0a0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.5
2
+ Name: helix-protocol
3
+ Version: 0.1.0a0
4
+ Summary: Python client SDK for the Agent Execution Protocol (AEP), the wire protocol behind Helix.
5
+ Project-URL: Homepage, https://github.com/evigauge-org/helix-sdk
6
+ Project-URL: Repository, https://github.com/evigauge-org/helix-sdk
7
+ Project-URL: Issues, https://github.com/evigauge-org/helix-sdk/issues
8
+ Author-email: "Evigauge Technologies Pvt. Ltd." <info@evigauge.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: aep,agent,agent-execution-protocol,client,helix,sdk
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: httpx>=0.27
22
+ Requires-Dist: pydantic>=2.8
23
+ Provides-Extra: dev
24
+ Requires-Dist: datamodel-code-generator>=0.26; extra == 'dev'
25
+ Requires-Dist: ruff>=0.7; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # helix-protocol
29
+
30
+ Python client SDK for the **Agent Execution Protocol** (AEP).
31
+
32
+ This package speaks the `aep-2026-04-24` wire protocol to any conforming runtime. It is a pure client — no server, no framework integrations.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ uv add helix-protocol
38
+ # or
39
+ pip install helix-protocol
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ```python
45
+ import asyncio
46
+ from helix_sdk import HelixClient
47
+
48
+ async def main():
49
+ async with HelixClient(base_url="https://runtime.example.com", bearer="...") as client:
50
+ await client.initialize(
51
+ requested_versions=["aep-2026-04-24"],
52
+ requested_capabilities={"compliance.gdpr": True, "messaging.peer": True},
53
+ )
54
+ agent = await client.agent.create(...)
55
+ run = await client.run.create(agent_id=agent.id, goal="...")
56
+ async for event in client.run.events(run.id):
57
+ print(event.type, event)
58
+
59
+ asyncio.run(main())
60
+ ```
61
+
62
+ ## Codegen
63
+
64
+ Pydantic models are generated from the canonical JSON Schema bundle at `docs/protocol/schemas/`. To regenerate:
65
+
66
+ ```bash
67
+ uv run python scripts/generate_models.py
68
+ ```
69
+
70
+ Do not hand-edit `helix_sdk/models/generated.py`.
71
+
72
+ ## License
73
+
74
+ Apache-2.0.
@@ -0,0 +1,22 @@
1
+ helix_sdk/__init__.py,sha256=oNMbCrbX7mbHLAvqJ3nxOEnPGTeXmAlL973E8uBvFwA,605
2
+ helix_sdk/capabilities.py,sha256=LL2cww7Ma5-g38_zz7yDr377VuC1pt7MU5TWa4zwowk,1778
3
+ helix_sdk/client.py,sha256=-tyMzSJuBbyb-SmAVHYlO4xodBnjuxkTBLsUrZGkjPE,2686
4
+ helix_sdk/constants.py,sha256=8OOhyfeZfgXWvBk61mbr5j2gIEEM61fv8YYZWzGU78I,522
5
+ helix_sdk/errors.py,sha256=Gkutr3p2MGPWrPvCYIy00Ltwxsp4r2vrojdDTIITEnc,2151
6
+ helix_sdk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ helix_sdk/services/__init__.py,sha256=w6_HGq510CctWxpQd1kFEvhALqr66RrCv7NAbXVVDGU,455
8
+ helix_sdk/services/agent.py,sha256=DMs5YaH7_mGuQST79GJ3qcvQW4gOuu24fAoAvlenfcc,2299
9
+ helix_sdk/services/artifact.py,sha256=n5939xfrd1A2DF6aryf2oWISueoYM8YUuKIQ8banBmI,1108
10
+ helix_sdk/services/memory.py,sha256=jIcOdmlCRwApfvTKIg6NuNVICITGvOdvFgRe-bi1xHc,2163
11
+ helix_sdk/services/message.py,sha256=JpEyX8RaBCEqGn4ib-kuCRXduaxl5e2kI5CVd_fRhd8,886
12
+ helix_sdk/services/provider.py,sha256=f38xgMkiFjEiTEg2DhlP1YOz52lUB4GubVxwt027dAw,476
13
+ helix_sdk/services/run.py,sha256=kav36f7c265tY9Rk7KV9UuRwwGs9MTvpp3MaDICTMZ0,1404
14
+ helix_sdk/services/subject.py,sha256=3tn5CkVm6q2Gzf86qmMj0gcpYi21ajoJQSMb9d0oHbg,955
15
+ helix_sdk/transport/__init__.py,sha256=6KGijO5ctKgjwHxzD__6mDAwQFWmPngdMliJNj62wSQ,243
16
+ helix_sdk/transport/binary.py,sha256=AruTStPnHc9PxOvFmJefxrYLqrpYRuH7sLV4MUb-uDI,1995
17
+ helix_sdk/transport/rpc.py,sha256=-y2Vz0VwiTpKR8K_MGHXmKLTYhgNrBtEJ94wPibTUOo,2453
18
+ helix_sdk/transport/sse.py,sha256=EWukx231ws_IYixonF5XzYeAC5jdOm7pOXGCjUnkBOQ,2710
19
+ helix_protocol-0.1.0a0.dist-info/METADATA,sha256=3FGG6ayin-P1ezWEbNE34sKVtuFa2lya-F8D_eKfeCA,2330
20
+ helix_protocol-0.1.0a0.dist-info/WHEEL,sha256=THafob7ofN-NsuMN7Mg4qZyHaQI7KkD-QlcQatYhXPo,87
21
+ helix_protocol-0.1.0a0.dist-info/licenses/LICENSE,sha256=TaEuRDnzEiEV5jrzumQOaQhGtvC0fURAtMo4zaHmCf8,11362
22
+ helix_protocol-0.1.0a0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.3
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Evigauge Technologies Pvt. Ltd.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
helix_sdk/__init__.py ADDED
@@ -0,0 +1,23 @@
1
+ # packages/python/helix_sdk/__init__.py
2
+ from .client import HelixClient
3
+ from .capabilities import Capability
4
+ from .constants import PROTOCOL_VERSION
5
+ from .errors import AEPError, AEPAuthzError, AEPTransportError, AEPErrorSymbol
6
+ from .transport import BinaryResult, SseEvent
7
+
8
+ #: Deprecated alias kept for callers written before the rename.
9
+ #: Use :class:`HelixClient`.
10
+ AEPClient = HelixClient
11
+
12
+ __all__ = [
13
+ "HelixClient",
14
+ "AEPClient",
15
+ "AEPAuthzError",
16
+ "AEPError",
17
+ "AEPErrorSymbol",
18
+ "AEPTransportError",
19
+ "BinaryResult",
20
+ "Capability",
21
+ "PROTOCOL_VERSION",
22
+ "SseEvent",
23
+ ]
@@ -0,0 +1,57 @@
1
+ # packages/python/helix_sdk/capabilities.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Literal
5
+
6
+ from .errors import AEPError
7
+
8
+ Capability = Literal[
9
+ "auth.oauth2",
10
+ "compliance.gdpr",
11
+ "tools.mcp_external",
12
+ "self.modify_prompt",
13
+ "self.spawn_subagent",
14
+ "self.learning_memory",
15
+ "messaging.peer",
16
+ "streaming.sse",
17
+ "runner.byo_llm",
18
+ ]
19
+
20
+ METHOD_CAPABILITY: dict[str, Capability] = {
21
+ "memory.read": "self.learning_memory",
22
+ "memory.write": "self.learning_memory",
23
+ "memory.search": "self.learning_memory",
24
+ "memory.delete": "self.learning_memory",
25
+ "message.send": "messaging.peer",
26
+ "message.inbox": "messaging.peer",
27
+ "message.list": "messaging.peer",
28
+ "subject.export": "compliance.gdpr",
29
+ "subject.erase": "compliance.gdpr",
30
+ "subject.read": "compliance.gdpr",
31
+ "agent.approve_prompt_change": "self.modify_prompt",
32
+ "run.events": "streaming.sse",
33
+ "provider.list": "runner.byo_llm",
34
+ }
35
+
36
+
37
+ class CapabilityGate:
38
+ def __init__(self, advertised: set[Capability]) -> None:
39
+ self._advertised = advertised
40
+
41
+ @classmethod
42
+ def from_server_response(cls, caps: dict[str, bool]) -> "CapabilityGate":
43
+ return cls({name for name, enabled in caps.items() if enabled}) # type: ignore[arg-type]
44
+
45
+ def has(self, cap: Capability) -> bool:
46
+ return cap in self._advertised
47
+
48
+ def require(self, method: str) -> None:
49
+ cap = METHOD_CAPABILITY.get(method)
50
+ if cap is not None and cap not in self._advertised:
51
+ raise AEPError(
52
+ -32002,
53
+ f"Method {method} requires capability {cap}, not advertised by runtime",
54
+ )
55
+
56
+ def update(self, other: "CapabilityGate") -> None:
57
+ self._advertised = set(other._advertised)
helix_sdk/client.py ADDED
@@ -0,0 +1,77 @@
1
+ # packages/python/helix_sdk/client.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+ import httpx
7
+
8
+ from .capabilities import Capability, CapabilityGate
9
+ from .constants import PROTOCOL_VERSION
10
+ from .errors import AEPError
11
+ from .services import (
12
+ AgentService,
13
+ ArtifactService,
14
+ MemoryService,
15
+ MessageService,
16
+ ProviderService,
17
+ RunService,
18
+ SubjectService,
19
+ )
20
+ from .transport import BinaryClient, RpcClient, SseClient
21
+
22
+
23
+ class HelixClient:
24
+ def __init__(
25
+ self,
26
+ base_url: str,
27
+ bearer: str,
28
+ http_client: httpx.AsyncClient | None = None,
29
+ ) -> None:
30
+ self._http = http_client or httpx.AsyncClient(timeout=httpx.Timeout(60.0, read=None))
31
+ self._owns_http = http_client is None
32
+
33
+ self._rpc = RpcClient(base_url=base_url, bearer=bearer, http_client=self._http)
34
+ self._sse = SseClient(base_url=base_url, bearer=bearer, http_client=self._http)
35
+ self._bin = BinaryClient(base_url=base_url, bearer=bearer, http_client=self._http)
36
+ self._gate = CapabilityGate(set())
37
+
38
+ self.agent = AgentService(self._rpc, self._gate)
39
+ self.run = RunService(self._rpc, self._sse, self._gate)
40
+ self.artifact = ArtifactService(self._rpc, self._bin)
41
+ self.memory = MemoryService(self._rpc, self._gate)
42
+ self.message = MessageService(self._rpc, self._gate)
43
+ self.provider = ProviderService(self._rpc, self._gate)
44
+ self.subject = SubjectService(self._rpc, self._gate)
45
+
46
+ async def __aenter__(self) -> "HelixClient":
47
+ return self
48
+
49
+ async def __aexit__(self, *exc_info: Any) -> None:
50
+ await self.aclose()
51
+
52
+ async def aclose(self) -> None:
53
+ if self._owns_http:
54
+ await self._http.aclose()
55
+
56
+ async def initialize(
57
+ self,
58
+ requested_versions: list[str],
59
+ requested_capabilities: dict[Capability, bool],
60
+ client_info: dict[str, str] | None = None,
61
+ ) -> dict[str, Any]:
62
+ result = await self._rpc.call(
63
+ "initialize",
64
+ {
65
+ "client_info": client_info or {"name": "helix-protocol", "version": "0.1.0a0"},
66
+ "requested_versions": requested_versions,
67
+ "requested_capabilities": requested_capabilities,
68
+ },
69
+ )
70
+ if result["protocol_version"] != PROTOCOL_VERSION:
71
+ raise AEPError(
72
+ -32009,
73
+ f"Runtime reports protocol {result['protocol_version']}, SDK expects {PROTOCOL_VERSION}",
74
+ )
75
+ self._rpc.set_session_id(result["session_id"])
76
+ self._gate.update(CapabilityGate.from_server_response(result["capabilities"]))
77
+ return result
helix_sdk/constants.py ADDED
@@ -0,0 +1,19 @@
1
+ # packages/python/helix_sdk/constants.py
2
+ from __future__ import annotations
3
+
4
+ PROTOCOL_VERSION = "aep-2026-04-24"
5
+
6
+ HEADER_PROTOCOL_VERSION = "Agent-Protocol-Version"
7
+ HEADER_SESSION_ID = "X-AEP-Session-Id"
8
+
9
+ RPC_PATH = "/aep/v1/rpc"
10
+
11
+
12
+ def run_events_path(run_id: str) -> str:
13
+ from urllib.parse import quote
14
+ return f"/aep/v1/runs/{quote(run_id, safe='')}/events"
15
+
16
+
17
+ def artifact_bytes_path(artifact_id: str) -> str:
18
+ from urllib.parse import quote
19
+ return f"/aep/v1/artifacts/{quote(artifact_id, safe='')}/bytes"
helix_sdk/errors.py ADDED
@@ -0,0 +1,69 @@
1
+ # packages/python/helix_sdk/errors.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any, Literal
5
+
6
+ AEPErrorSymbol = Literal[
7
+ "authn_failed",
8
+ "authz_denied",
9
+ "capability_not_supported",
10
+ "ceiling_exceeded",
11
+ "budget_exhausted",
12
+ "tree_boundary_violation",
13
+ "subject_not_found",
14
+ "constitution_policy_violation",
15
+ "tool_not_found",
16
+ "version_mismatch",
17
+ "session_expired",
18
+ "lifecycle_conflict",
19
+ ]
20
+
21
+ _CODE_TO_SYMBOL: dict[int, AEPErrorSymbol] = {
22
+ -32000: "authn_failed",
23
+ -32001: "authz_denied",
24
+ -32002: "capability_not_supported",
25
+ -32003: "ceiling_exceeded",
26
+ -32004: "budget_exhausted",
27
+ -32005: "tree_boundary_violation",
28
+ -32006: "subject_not_found",
29
+ -32007: "constitution_policy_violation",
30
+ -32008: "tool_not_found",
31
+ -32009: "version_mismatch",
32
+ -32010: "session_expired",
33
+ -32011: "lifecycle_conflict",
34
+ }
35
+
36
+ CODE_TO_SYMBOL = _CODE_TO_SYMBOL
37
+
38
+
39
+ class AEPError(Exception):
40
+ def __init__(self, code: int, message: str, data: Any = None) -> None:
41
+ super().__init__(message)
42
+ self.code = code
43
+ self.symbol: AEPErrorSymbol | str = _CODE_TO_SYMBOL.get(code, "unknown")
44
+ self.data = data
45
+
46
+
47
+ class AEPAuthzError(AEPError):
48
+ """Raised when the runtime rejects a method call because the caller's
49
+ token lacks the required scope (JSON-RPC error code -32001). Catch this
50
+ separately from generic AEPError to distinguish authz failures (e.g. show
51
+ a 'this key needs scope X' UI hint) from other protocol errors."""
52
+
53
+ def __init__(self, message: str, data: Any = None) -> None:
54
+ super().__init__(code=-32001, message=message, data=data)
55
+
56
+
57
+ class AEPTransportError(Exception):
58
+ def __init__(self, message: str, cause: Exception | None = None) -> None:
59
+ super().__init__(message)
60
+ self.cause = cause
61
+
62
+
63
+ def from_jsonrpc_error(payload: dict[str, Any]) -> AEPError:
64
+ code = int(payload["code"])
65
+ message = str(payload.get("message", ""))
66
+ data = payload.get("data")
67
+ if code == -32001:
68
+ return AEPAuthzError(message=message, data=data)
69
+ return AEPError(code=code, message=message, data=data)
File without changes
@@ -0,0 +1,18 @@
1
+ # packages/python/helix_sdk/services/__init__.py
2
+ from .agent import AgentService
3
+ from .run import RunService
4
+ from .artifact import ArtifactService
5
+ from .memory import MemoryService
6
+ from .message import MessageService
7
+ from .provider import ProviderService
8
+ from .subject import SubjectService
9
+
10
+ __all__ = [
11
+ "AgentService",
12
+ "RunService",
13
+ "ArtifactService",
14
+ "MemoryService",
15
+ "MessageService",
16
+ "ProviderService",
17
+ "SubjectService",
18
+ ]
@@ -0,0 +1,60 @@
1
+ # packages/python/helix_sdk/services/agent.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+ from ..capabilities import CapabilityGate
7
+ from ..transport import RpcClient
8
+
9
+
10
+ class AgentService:
11
+ def __init__(self, rpc: RpcClient, gate: CapabilityGate) -> None:
12
+ self._rpc = rpc
13
+ self._gate = gate
14
+
15
+ async def create(self, **params: Any) -> dict[str, Any]:
16
+ """Create an agent. See AEP spec for accepted params.
17
+
18
+ Notable Plan-7 addition: pass `runner={"provider_id": "...", "model": "..."}`
19
+ to use a BYO LLM provider configured via /settings/llm-providers.
20
+ Omit `runner` for managed (OpenRouter) execution.
21
+ """
22
+ return await self._rpc.call("agent.create", params)
23
+
24
+ async def get(self, agent_id: str, include: list[str] | None = None, prompt_history_cursor: str | None = None) -> dict[str, Any]:
25
+ body: dict[str, Any] = {"agent_id": agent_id}
26
+ if include is not None:
27
+ body["include"] = include
28
+ if prompt_history_cursor is not None:
29
+ body["prompt_history_cursor"] = prompt_history_cursor
30
+ return await self._rpc.call("agent.get", body)
31
+
32
+ async def list(self, **params: Any) -> dict[str, Any]:
33
+ return await self._rpc.call("agent.list", params)
34
+
35
+ async def update(self, agent_id: str, **changes: Any) -> dict[str, Any]:
36
+ body = {"agent_id": agent_id, **changes}
37
+ return await self._rpc.call("agent.update", body)
38
+
39
+ async def approve_prompt_change(
40
+ self,
41
+ agent_id: str,
42
+ pending_change_id: str,
43
+ approve: bool,
44
+ comment: str | None = None,
45
+ ) -> dict[str, Any]:
46
+ self._gate.require("agent.approve_prompt_change")
47
+ body: dict[str, Any] = {
48
+ "agent_id": agent_id,
49
+ "pending_change_id": pending_change_id,
50
+ "approve": approve,
51
+ }
52
+ if comment is not None:
53
+ body["comment"] = comment
54
+ return await self._rpc.call("agent.approve_prompt_change", body)
55
+
56
+ async def cancel(self, agent_id: str) -> dict[str, Any]:
57
+ return await self._rpc.call("agent.cancel", {"agent_id": agent_id})
58
+
59
+ async def archive(self, agent_id: str) -> dict[str, Any]:
60
+ return await self._rpc.call("agent.archive", {"agent_id": agent_id})
@@ -0,0 +1,29 @@
1
+ # packages/python/helix_sdk/services/artifact.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+ from ..transport import BinaryClient, BinaryResult, RpcClient
7
+
8
+
9
+ class ArtifactService:
10
+ def __init__(self, rpc: RpcClient, binary: BinaryClient) -> None:
11
+ self._rpc = rpc
12
+ self._binary = binary
13
+
14
+ async def get(self, artifact_id: str) -> dict[str, Any]:
15
+ return await self._rpc.call("artifact.get", {"artifact_id": artifact_id})
16
+
17
+ async def list(self, **params: Any) -> dict[str, Any]:
18
+ return await self._rpc.call("artifact.list", params)
19
+
20
+ async def delete(self, artifact_id: str) -> dict[str, Any]:
21
+ return await self._rpc.call("artifact.delete", {"artifact_id": artifact_id})
22
+
23
+ async def bytes(self, artifact_id: str) -> BinaryResult:
24
+ return await self._binary.fetch_artifact_bytes(artifact_id, self._rpc_session())
25
+
26
+ def _rpc_session(self) -> str | None:
27
+ # Router for the session id held in the RpcClient; kept as a method
28
+ # so both call sites share a single lookup strategy.
29
+ return self._rpc.get_session_id()
@@ -0,0 +1,70 @@
1
+ # packages/python/helix_sdk/services/memory.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+ from ..capabilities import CapabilityGate
7
+ from ..transport import RpcClient
8
+
9
+
10
+ class MemoryService:
11
+ def __init__(self, rpc: RpcClient, gate: CapabilityGate) -> None:
12
+ self._rpc = rpc
13
+ self._gate = gate
14
+
15
+ async def read(
16
+ self,
17
+ tree_root_id: str,
18
+ namespace: str,
19
+ key: str | None = None,
20
+ limit: int | None = None,
21
+ cursor: str | None = None,
22
+ ) -> dict[str, Any]:
23
+ self._gate.require("memory.read")
24
+ body: dict[str, Any] = {"tree_root_id": tree_root_id, "namespace": namespace}
25
+ if key is not None:
26
+ body["key"] = key
27
+ if limit is not None:
28
+ body["limit"] = limit
29
+ if cursor is not None:
30
+ body["cursor"] = cursor
31
+ return await self._rpc.call("memory.read", body)
32
+
33
+ async def write(
34
+ self,
35
+ tree_root_id: str,
36
+ namespace: str,
37
+ key: str,
38
+ value: Any,
39
+ subject_id: str | None = None,
40
+ ttl_seconds: int | None = None,
41
+ ) -> dict[str, Any]:
42
+ self._gate.require("memory.write")
43
+ body: dict[str, Any] = {
44
+ "tree_root_id": tree_root_id,
45
+ "namespace": namespace,
46
+ "key": key,
47
+ "value": value,
48
+ }
49
+ if subject_id is not None:
50
+ body["subject_id"] = subject_id
51
+ if ttl_seconds is not None:
52
+ body["ttl_seconds"] = ttl_seconds
53
+ return await self._rpc.call("memory.write", body)
54
+
55
+ async def search(
56
+ self,
57
+ tree_root_id: str,
58
+ namespace: str,
59
+ query: str,
60
+ k: int | None = None,
61
+ ) -> dict[str, Any]:
62
+ self._gate.require("memory.search")
63
+ body: dict[str, Any] = {"tree_root_id": tree_root_id, "namespace": namespace, "query": query}
64
+ if k is not None:
65
+ body["k"] = k
66
+ return await self._rpc.call("memory.search", body)
67
+
68
+ async def delete(self, **params: Any) -> dict[str, Any]:
69
+ self._gate.require("memory.delete")
70
+ return await self._rpc.call("memory.delete", params)
@@ -0,0 +1,25 @@
1
+ # packages/python/helix_sdk/services/message.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+ from ..capabilities import CapabilityGate
7
+ from ..transport import RpcClient
8
+
9
+
10
+ class MessageService:
11
+ def __init__(self, rpc: RpcClient, gate: CapabilityGate) -> None:
12
+ self._rpc = rpc
13
+ self._gate = gate
14
+
15
+ async def send(self, to_agent_id: str, body: Any) -> dict[str, Any]:
16
+ self._gate.require("message.send")
17
+ return await self._rpc.call("message.send", {"to_agent_id": to_agent_id, "body": body})
18
+
19
+ async def inbox(self, agent_id: str) -> dict[str, Any]:
20
+ self._gate.require("message.inbox")
21
+ return await self._rpc.call("message.inbox", {"agent_id": agent_id})
22
+
23
+ async def list(self, **params: Any) -> dict[str, Any]:
24
+ self._gate.require("message.list")
25
+ return await self._rpc.call("message.list", params)
@@ -0,0 +1,17 @@
1
+ # packages/python/helix_sdk/services/provider.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+ from ..capabilities import CapabilityGate
7
+ from ..transport import RpcClient
8
+
9
+
10
+ class ProviderService:
11
+ def __init__(self, rpc: RpcClient, gate: CapabilityGate) -> None:
12
+ self._rpc = rpc
13
+ self._gate = gate
14
+
15
+ async def list(self) -> dict[str, Any]:
16
+ self._gate.require("provider.list")
17
+ return await self._rpc.call("provider.list", {})
@@ -0,0 +1,35 @@
1
+ # packages/python/helix_sdk/services/run.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any, AsyncIterator
5
+
6
+ from ..capabilities import CapabilityGate
7
+ from ..transport import RpcClient, SseClient, SseEvent
8
+
9
+
10
+ class RunService:
11
+ def __init__(self, rpc: RpcClient, sse: SseClient, gate: CapabilityGate) -> None:
12
+ self._rpc = rpc
13
+ self._sse = sse
14
+ self._gate = gate
15
+
16
+ async def create(self, agent_id: str, goal: str, **opts: Any) -> dict[str, Any]:
17
+ body: dict[str, Any] = {"agent_id": agent_id, "goal": goal, **opts}
18
+ return await self._rpc.call("run.create", body)
19
+
20
+ async def get(self, run_id: str) -> dict[str, Any]:
21
+ return await self._rpc.call("run.get", {"run_id": run_id})
22
+
23
+ async def list(self, agent_id: str, **opts: Any) -> dict[str, Any]:
24
+ return await self._rpc.call("run.list", {"agent_id": agent_id, **opts})
25
+
26
+ async def cancel(self, run_id: str) -> dict[str, Any]:
27
+ return await self._rpc.call("run.cancel", {"run_id": run_id})
28
+
29
+ async def continue_(self, run_id: str) -> dict[str, Any]:
30
+ return await self._rpc.call("run.continue", {"run_id": run_id})
31
+
32
+ async def events(self, run_id: str, since: str | None = None) -> AsyncIterator[SseEvent]:
33
+ self._gate.require("run.events")
34
+ async for ev in self._sse.stream(run_id, self._rpc.get_session_id(), since=since):
35
+ yield ev
@@ -0,0 +1,25 @@
1
+ # packages/python/helix_sdk/services/subject.py
2
+ from __future__ import annotations
3
+
4
+ from typing import Any, Literal
5
+
6
+ from ..capabilities import CapabilityGate
7
+ from ..transport import RpcClient
8
+
9
+
10
+ class SubjectService:
11
+ def __init__(self, rpc: RpcClient, gate: CapabilityGate) -> None:
12
+ self._rpc = rpc
13
+ self._gate = gate
14
+
15
+ async def export(self, subject_id: str) -> dict[str, Any]:
16
+ self._gate.require("subject.export")
17
+ return await self._rpc.call("subject.export", {"subject_id": subject_id})
18
+
19
+ async def erase(self, subject_id: str, mode: Literal["hard_delete", "redact"]) -> dict[str, Any]:
20
+ self._gate.require("subject.erase")
21
+ return await self._rpc.call("subject.erase", {"subject_id": subject_id, "mode": mode})
22
+
23
+ async def read(self, subject_id: str) -> dict[str, Any]:
24
+ self._gate.require("subject.read")
25
+ return await self._rpc.call("subject.read", {"subject_id": subject_id})
@@ -0,0 +1,6 @@
1
+ # packages/python/helix_sdk/transport/__init__.py
2
+ from .rpc import RpcClient
3
+ from .sse import SseClient, SseEvent
4
+ from .binary import BinaryClient, BinaryResult
5
+
6
+ __all__ = ["RpcClient", "SseClient", "SseEvent", "BinaryClient", "BinaryResult"]
@@ -0,0 +1,59 @@
1
+ # packages/python/helix_sdk/transport/binary.py
2
+ from __future__ import annotations
3
+
4
+ from dataclasses import dataclass
5
+ from typing import AsyncIterator
6
+
7
+ import httpx
8
+
9
+ from ..constants import HEADER_PROTOCOL_VERSION, HEADER_SESSION_ID, PROTOCOL_VERSION, artifact_bytes_path
10
+ from ..errors import AEPTransportError
11
+
12
+
13
+ @dataclass
14
+ class BinaryResult:
15
+ mime_type: str
16
+ size: int
17
+ body: AsyncIterator[bytes]
18
+
19
+
20
+ class BinaryClient:
21
+ def __init__(self, base_url: str, bearer: str, http_client: httpx.AsyncClient | None = None) -> None:
22
+ self._base_url = base_url.rstrip("/")
23
+ self._bearer = bearer
24
+ self._client = http_client or httpx.AsyncClient(timeout=httpx.Timeout(60.0, read=None))
25
+ self._owns_client = http_client is None
26
+
27
+ async def aclose(self) -> None:
28
+ if self._owns_client:
29
+ await self._client.aclose()
30
+
31
+ async def fetch_artifact_bytes(self, artifact_id: str, session_id: str | None) -> BinaryResult:
32
+ headers = {
33
+ "Authorization": f"Bearer {self._bearer}",
34
+ HEADER_PROTOCOL_VERSION: PROTOCOL_VERSION,
35
+ }
36
+ if session_id:
37
+ headers[HEADER_SESSION_ID] = session_id
38
+
39
+ req = self._client.build_request(
40
+ "GET",
41
+ f"{self._base_url}{artifact_bytes_path(artifact_id)}",
42
+ headers=headers,
43
+ )
44
+ resp = await self._client.send(req, stream=True)
45
+ if resp.status_code != 200:
46
+ await resp.aclose()
47
+ raise AEPTransportError(f"Binary HTTP {resp.status_code} {resp.reason_phrase}")
48
+
49
+ mime = resp.headers.get("Content-Type", "application/octet-stream")
50
+ size = int(resp.headers.get("Content-Length", "0") or 0)
51
+
52
+ async def iterator() -> AsyncIterator[bytes]:
53
+ try:
54
+ async for chunk in resp.aiter_bytes():
55
+ yield chunk
56
+ finally:
57
+ await resp.aclose()
58
+
59
+ return BinaryResult(mime_type=mime, size=size, body=iterator())
@@ -0,0 +1,69 @@
1
+ # packages/python/helix_sdk/transport/rpc.py
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from ..constants import HEADER_PROTOCOL_VERSION, HEADER_SESSION_ID, PROTOCOL_VERSION, RPC_PATH
10
+ from ..errors import AEPTransportError, from_jsonrpc_error
11
+
12
+
13
+ class RpcClient:
14
+ def __init__(self, base_url: str, bearer: str, http_client: httpx.AsyncClient | None = None) -> None:
15
+ self._base_url = base_url.rstrip("/")
16
+ self._bearer = bearer
17
+ self._next_id = 1
18
+ self._session_id: str | None = None
19
+ self._client = http_client or httpx.AsyncClient(timeout=httpx.Timeout(60.0, read=None))
20
+ self._owns_client = http_client is None
21
+
22
+ async def aclose(self) -> None:
23
+ if self._owns_client:
24
+ await self._client.aclose()
25
+
26
+ def set_session_id(self, session_id: str) -> None:
27
+ self._session_id = session_id
28
+
29
+ def get_session_id(self) -> str | None:
30
+ return self._session_id
31
+
32
+ async def call(self, method: str, params: Any | None = None) -> Any:
33
+ req_id = self._next_id
34
+ self._next_id += 1
35
+ body: dict[str, Any] = {"jsonrpc": "2.0", "id": req_id, "method": method}
36
+ if params is not None:
37
+ body["params"] = params
38
+
39
+ headers = {
40
+ "Content-Type": "application/json",
41
+ "Accept": "application/json",
42
+ "Authorization": f"Bearer {self._bearer}",
43
+ HEADER_PROTOCOL_VERSION: PROTOCOL_VERSION,
44
+ }
45
+ if self._session_id:
46
+ headers[HEADER_SESSION_ID] = self._session_id
47
+
48
+ try:
49
+ resp = await self._client.post(
50
+ f"{self._base_url}{RPC_PATH}",
51
+ headers=headers,
52
+ content=json.dumps(body),
53
+ )
54
+ except httpx.HTTPError as e:
55
+ raise AEPTransportError("Network error during RPC call", cause=e) from e
56
+
57
+ if resp.status_code >= 500:
58
+ raise AEPTransportError(f"HTTP {resp.status_code} {resp.reason_phrase}")
59
+
60
+ try:
61
+ payload = resp.json()
62
+ except json.JSONDecodeError as e:
63
+ raise AEPTransportError("Failed to parse JSON-RPC response", cause=e) from e
64
+
65
+ if "error" in payload and payload["error"]:
66
+ raise from_jsonrpc_error(payload["error"])
67
+ if "result" not in payload:
68
+ raise AEPTransportError("JSON-RPC response missing result and error")
69
+ return payload["result"]
@@ -0,0 +1,89 @@
1
+ # packages/python/helix_sdk/transport/sse.py
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ from dataclasses import dataclass
6
+ from typing import Any, AsyncIterator
7
+
8
+ import httpx
9
+
10
+ from ..constants import HEADER_PROTOCOL_VERSION, HEADER_SESSION_ID, PROTOCOL_VERSION, run_events_path
11
+ from ..errors import AEPTransportError
12
+
13
+
14
+ @dataclass
15
+ class SseEvent:
16
+ event_id: str
17
+ run_id: str
18
+ type: str
19
+ emitted_at: str
20
+ payload: Any
21
+
22
+
23
+ class SseClient:
24
+ def __init__(self, base_url: str, bearer: str, http_client: httpx.AsyncClient | None = None) -> None:
25
+ self._base_url = base_url.rstrip("/")
26
+ self._bearer = bearer
27
+ self._client = http_client or httpx.AsyncClient(timeout=httpx.Timeout(60.0, read=None))
28
+ self._owns_client = http_client is None
29
+
30
+ async def aclose(self) -> None:
31
+ if self._owns_client:
32
+ await self._client.aclose()
33
+
34
+ async def stream(
35
+ self,
36
+ run_id: str,
37
+ session_id: str | None,
38
+ since: str | None = None,
39
+ ) -> AsyncIterator[SseEvent]:
40
+ headers = {
41
+ "Accept": "text/event-stream",
42
+ "Authorization": f"Bearer {self._bearer}",
43
+ HEADER_PROTOCOL_VERSION: PROTOCOL_VERSION,
44
+ }
45
+ if session_id:
46
+ headers[HEADER_SESSION_ID] = session_id
47
+
48
+ params = {"since": since} if since else None
49
+
50
+ async with self._client.stream(
51
+ "GET",
52
+ f"{self._base_url}{run_events_path(run_id)}",
53
+ headers=headers,
54
+ params=params,
55
+ ) as resp:
56
+ if resp.status_code != 200:
57
+ raise AEPTransportError(f"SSE HTTP {resp.status_code} {resp.reason_phrase}")
58
+
59
+ buf = ""
60
+ async for chunk in resp.aiter_text():
61
+ buf += chunk
62
+ while "\n\n" in buf:
63
+ frame, buf = buf.split("\n\n", 1)
64
+ parsed = _parse_frame(frame)
65
+ if parsed is not None:
66
+ yield parsed
67
+
68
+
69
+ def _parse_frame(raw: str) -> SseEvent | None:
70
+ event_type = "message"
71
+ data_line = ""
72
+ for line in raw.split("\n"):
73
+ if line.startswith("event:"):
74
+ event_type = line[6:].strip()
75
+ elif line.startswith("data:"):
76
+ data_line += line[5:].strip()
77
+ if not data_line:
78
+ return None
79
+ try:
80
+ parsed = json.loads(data_line)
81
+ except json.JSONDecodeError:
82
+ return None
83
+ return SseEvent(
84
+ event_id=str(parsed.get("event_id", "")),
85
+ run_id=str(parsed.get("run_id", "")),
86
+ type=str(parsed.get("type", event_type)),
87
+ emitted_at=str(parsed.get("emitted_at", "")),
88
+ payload=parsed.get("payload", parsed),
89
+ )