ampup-harness 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.
Files changed (42) hide show
  1. ampup_harness-0.1.0/.gitignore +4 -0
  2. ampup_harness-0.1.0/LICENSE +202 -0
  3. ampup_harness-0.1.0/PKG-INFO +73 -0
  4. ampup_harness-0.1.0/PYPI.md +55 -0
  5. ampup_harness-0.1.0/ampup_harness/__init__.py +6 -0
  6. ampup_harness-0.1.0/ampup_harness/_http.py +126 -0
  7. ampup_harness-0.1.0/ampup_harness/_version.py +3 -0
  8. ampup_harness-0.1.0/ampup_harness/agno/__init__.py +10 -0
  9. ampup_harness-0.1.0/ampup_harness/agno/_agno_params.py +113 -0
  10. ampup_harness-0.1.0/ampup_harness/agno/agent/__init__.py +9 -0
  11. ampup_harness-0.1.0/ampup_harness/agno/agent/agent.py +831 -0
  12. ampup_harness-0.1.0/ampup_harness/agno/db/__init__.py +8 -0
  13. ampup_harness-0.1.0/ampup_harness/agno/db/base.py +31 -0
  14. ampup_harness-0.1.0/ampup_harness/agno/db/in_memory.py +29 -0
  15. ampup_harness-0.1.0/ampup_harness/agno/db/postgres.py +29 -0
  16. ampup_harness-0.1.0/ampup_harness/agno/db/sqlite.py +63 -0
  17. ampup_harness-0.1.0/ampup_harness/agno/exceptions.py +159 -0
  18. ampup_harness-0.1.0/ampup_harness/agno/knowledge/__init__.py +5 -0
  19. ampup_harness-0.1.0/ampup_harness/agno/knowledge/knowledge.py +16 -0
  20. ampup_harness-0.1.0/ampup_harness/agno/memory/__init__.py +16 -0
  21. ampup_harness-0.1.0/ampup_harness/agno/models/__init__.py +5 -0
  22. ampup_harness-0.1.0/ampup_harness/agno/models/anthropic/__init__.py +13 -0
  23. ampup_harness-0.1.0/ampup_harness/agno/models/base.py +112 -0
  24. ampup_harness-0.1.0/ampup_harness/agno/models/deepseek/__init__.py +13 -0
  25. ampup_harness-0.1.0/ampup_harness/agno/models/google/__init__.py +13 -0
  26. ampup_harness-0.1.0/ampup_harness/agno/models/groq/__init__.py +13 -0
  27. ampup_harness-0.1.0/ampup_harness/agno/models/message.py +5 -0
  28. ampup_harness-0.1.0/ampup_harness/agno/models/mistral/__init__.py +13 -0
  29. ampup_harness-0.1.0/ampup_harness/agno/models/ollama/__init__.py +13 -0
  30. ampup_harness-0.1.0/ampup_harness/agno/models/openai/__init__.py +6 -0
  31. ampup_harness-0.1.0/ampup_harness/agno/models/openai/chat.py +19 -0
  32. ampup_harness-0.1.0/ampup_harness/agno/models/openai/like.py +21 -0
  33. ampup_harness-0.1.0/ampup_harness/agno/models/openrouter/__init__.py +13 -0
  34. ampup_harness-0.1.0/ampup_harness/agno/models/xai/__init__.py +13 -0
  35. ampup_harness-0.1.0/ampup_harness/agno/run/__init__.py +17 -0
  36. ampup_harness-0.1.0/ampup_harness/agno/run/agent.py +268 -0
  37. ampup_harness-0.1.0/ampup_harness/agno/team/__init__.py +42 -0
  38. ampup_harness-0.1.0/ampup_harness/agno/tools/__init__.py +286 -0
  39. ampup_harness-0.1.0/ampup_harness/agno/tools/function.py +5 -0
  40. ampup_harness-0.1.0/ampup_harness/agno/workflow/__init__.py +230 -0
  41. ampup_harness-0.1.0/ampup_harness/py.typed +0 -0
  42. ampup_harness-0.1.0/pyproject.toml +42 -0
@@ -0,0 +1,4 @@
1
+ __pycache__/
2
+ .venv/
3
+ .pytest_cache/
4
+ dist/
@@ -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 [yyyy] [name of copyright owner]
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.
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.5
2
+ Name: ampup-harness
3
+ Version: 0.1.0
4
+ Summary: AmpUp Harness Python SDK, including an Agno-compatible API (ampup_harness.agno)
5
+ Author: AmpUp
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Keywords: agents,agno,ampup,harness,llm
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Topic :: Software Development :: Libraries
15
+ Classifier: Typing :: Typed
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+
19
+ # ampup-harness
20
+
21
+ Python SDK for AmpUp Harness. Python 3.10+, standard library only (no dependencies).
22
+
23
+ ```sh
24
+ uv add ampup-harness
25
+ ```
26
+
27
+ Point it at a harness with environment variables:
28
+
29
+ ```sh
30
+ export AMPUP_HARNESS_URL=https://harness.example.com
31
+ export AMPUP_HARNESS_API_KEY=...
32
+ # optional: send every model as an OpenRouter slug (for runtimes with only an OpenRouter key)
33
+ export AMPUP_HARNESS_AGNO_ROUTE=openrouter
34
+ ```
35
+
36
+ ## Agno-compatible API (`ampup_harness.agno`)
37
+
38
+ Code written for [Agno](https://github.com/agno-agi/agno) runs on the harness after changing
39
+ `from agno.` to `from ampup_harness.agno.` in its imports:
40
+
41
+ ```python
42
+ from ampup_harness.agno.agent import Agent
43
+ from ampup_harness.agno.models.openai import OpenAIChat
44
+
45
+ agent = Agent(model=OpenAIChat(id="gpt-5"), instructions="Be terse.", markdown=True)
46
+ agent.print_response("Share a two-line story.", stream=True)
47
+ ```
48
+
49
+ - **Agents without Python tools** become harness agent templates and run server-side; sessions,
50
+ memory blocks and harness tools (`tools=["calculator"]`) live on the harness.
51
+ - **Agents with Python function tools** (functions, `@tool`, `Toolkit`, `Function`) run Agno's
52
+ tool loop in your process over the harness gateway (`/v1/messages`); async tools run on the
53
+ caller's event loop under `arun`.
54
+ - `run` / `arun` / `print_response`, streaming events, `Message`-list input, `cancel_run`,
55
+ `agno.exceptions` and sequential `Workflow`s follow Agno 3.x. A provider failure ends a run the
56
+ way Agno does: a `RunErrorEvent` in a stream, or `RunOutput.status == ERROR`.
57
+
58
+ Not covered yet: `Team`, knowledge bases (RAG), structured outputs, media inputs, reasoning
59
+ models, human-in-the-loop tools, and pre/post hooks. Arguments the harness cannot honour raise
60
+ `NotImplementedError` (when ignoring them would change the result) or warn.
61
+
62
+ ## Low-level client
63
+
64
+ ```python
65
+ from ampup_harness import HarnessConfig, HarnessError
66
+
67
+ config = HarnessConfig.from_env() # AMPUP_HARNESS_URL, AMPUP_HARNESS_API_KEY
68
+ ```
69
+
70
+ Use HTTPS beyond trusted loopback. Credentials stay in headers, redirects are refused, and URLs
71
+ carrying credentials, a query or a fragment are rejected.
72
+
73
+ License: Apache-2.0.
@@ -0,0 +1,55 @@
1
+ # ampup-harness
2
+
3
+ Python SDK for AmpUp Harness. Python 3.10+, standard library only (no dependencies).
4
+
5
+ ```sh
6
+ uv add ampup-harness
7
+ ```
8
+
9
+ Point it at a harness with environment variables:
10
+
11
+ ```sh
12
+ export AMPUP_HARNESS_URL=https://harness.example.com
13
+ export AMPUP_HARNESS_API_KEY=...
14
+ # optional: send every model as an OpenRouter slug (for runtimes with only an OpenRouter key)
15
+ export AMPUP_HARNESS_AGNO_ROUTE=openrouter
16
+ ```
17
+
18
+ ## Agno-compatible API (`ampup_harness.agno`)
19
+
20
+ Code written for [Agno](https://github.com/agno-agi/agno) runs on the harness after changing
21
+ `from agno.` to `from ampup_harness.agno.` in its imports:
22
+
23
+ ```python
24
+ from ampup_harness.agno.agent import Agent
25
+ from ampup_harness.agno.models.openai import OpenAIChat
26
+
27
+ agent = Agent(model=OpenAIChat(id="gpt-5"), instructions="Be terse.", markdown=True)
28
+ agent.print_response("Share a two-line story.", stream=True)
29
+ ```
30
+
31
+ - **Agents without Python tools** become harness agent templates and run server-side; sessions,
32
+ memory blocks and harness tools (`tools=["calculator"]`) live on the harness.
33
+ - **Agents with Python function tools** (functions, `@tool`, `Toolkit`, `Function`) run Agno's
34
+ tool loop in your process over the harness gateway (`/v1/messages`); async tools run on the
35
+ caller's event loop under `arun`.
36
+ - `run` / `arun` / `print_response`, streaming events, `Message`-list input, `cancel_run`,
37
+ `agno.exceptions` and sequential `Workflow`s follow Agno 3.x. A provider failure ends a run the
38
+ way Agno does: a `RunErrorEvent` in a stream, or `RunOutput.status == ERROR`.
39
+
40
+ Not covered yet: `Team`, knowledge bases (RAG), structured outputs, media inputs, reasoning
41
+ models, human-in-the-loop tools, and pre/post hooks. Arguments the harness cannot honour raise
42
+ `NotImplementedError` (when ignoring them would change the result) or warn.
43
+
44
+ ## Low-level client
45
+
46
+ ```python
47
+ from ampup_harness import HarnessConfig, HarnessError
48
+
49
+ config = HarnessConfig.from_env() # AMPUP_HARNESS_URL, AMPUP_HARNESS_API_KEY
50
+ ```
51
+
52
+ Use HTTPS beyond trusted loopback. Credentials stay in headers, redirects are refused, and URLs
53
+ carrying credentials, a query or a fragment are rejected.
54
+
55
+ License: Apache-2.0.
@@ -0,0 +1,6 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """AmpUp Harness Python SDK. ``ampup_harness.agno`` mirrors Agno's API on the harness."""
3
+ from ampup_harness._http import HarnessConfig, HarnessError
4
+ from ampup_harness._version import __version__
5
+
6
+ __all__ = ["HarnessConfig", "HarnessError", "__version__"]
@@ -0,0 +1,126 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Minimal JSON + SSE transport for the harness API, standard library only.
3
+
4
+ Credentials stay in headers and redirects are refused, as in ``ampup.py``.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import json
9
+ import os
10
+ from collections.abc import Iterator
11
+ from dataclasses import dataclass
12
+ from typing import Any
13
+ from urllib.error import HTTPError, URLError
14
+ from urllib.parse import urlsplit
15
+ from urllib.request import HTTPRedirectHandler, OpenerDirector, Request, build_opener
16
+
17
+ from ampup_harness._version import __version__
18
+
19
+ DEFAULT_URL = "http://127.0.0.1:4320"
20
+ # Edge proxies (Cloudflare error 1010) refuse urllib's default "Python-urllib/x.y" agent.
21
+ USER_AGENT = f"ampup-harness-python/{__version__}"
22
+ MAX_FRAME_BYTES = 16_000_000
23
+
24
+
25
+ class HarnessError(Exception):
26
+ """A non-2xx answer, a broken stream, or an ``event: error`` from the harness."""
27
+
28
+ def __init__(self, status: int | None, error_type: str, message: str) -> None:
29
+ self.status = status
30
+ self.error_type = error_type
31
+ self.message = message
32
+ where = f"HTTP {status}" if status is not None else "stream"
33
+ super().__init__(f"Harness request failed ({where}, {error_type}): {message}")
34
+
35
+
36
+ class _NoRedirect(HTTPRedirectHandler):
37
+ def redirect_request(self, req: Request, fp: Any, code: int, msg: str,
38
+ headers: Any, newurl: str) -> None:
39
+ return None
40
+
41
+
42
+ @dataclass(frozen=True)
43
+ class HarnessConfig:
44
+ """Where the harness is and which key to send."""
45
+
46
+ base_url: str
47
+ api_key: str | None
48
+ timeout: float = 960.0
49
+
50
+ @classmethod
51
+ def from_env(cls) -> "HarnessConfig":
52
+ """Read ``AMPUP_HARNESS_URL`` and ``AMPUP_HARNESS_API_KEY`` (or ``RUNTIME_TOKEN``)."""
53
+ key = os.environ.get("AMPUP_HARNESS_API_KEY") or os.environ.get("RUNTIME_TOKEN") or None
54
+ return cls(os.environ.get("AMPUP_HARNESS_URL", DEFAULT_URL), key)
55
+
56
+
57
+ def _error_from_body(status: int | None, raw: bytes) -> HarnessError:
58
+ try:
59
+ body = json.loads(raw)
60
+ except ValueError:
61
+ return HarnessError(status, "http_error", raw[:300].decode("utf-8", "replace"))
62
+ err = body.get("error") if isinstance(body, dict) else None
63
+ if isinstance(err, dict):
64
+ kind = str(err.get("type") or err.get("code") or "error")
65
+ return HarnessError(status, kind, str(err.get("message", "")))
66
+ return HarnessError(status, "error", str(body)[:300])
67
+
68
+
69
+ class HarnessHTTP:
70
+ """JSON requests and Anthropic-style SSE streams against one harness."""
71
+
72
+ def __init__(self, config: HarnessConfig) -> None:
73
+ parsed = urlsplit(config.base_url)
74
+ if (parsed.scheme not in ("http", "https") or not parsed.hostname or parsed.username
75
+ or parsed.password or parsed.query or parsed.fragment):
76
+ raise ValueError("AMPUP_HARNESS_URL must be an HTTP(S) URL without credentials, "
77
+ "query or fragment")
78
+ self.config = config
79
+ self.base = config.base_url.rstrip("/")
80
+ self._opener: OpenerDirector = build_opener(_NoRedirect())
81
+
82
+ def _open(self, method: str, path: str, body: Any | None, accept: str) -> Any:
83
+ headers = {"Accept": accept, "User-Agent": USER_AGENT}
84
+ if self.config.api_key:
85
+ headers["Authorization"] = f"Bearer {self.config.api_key}"
86
+ data = None
87
+ if body is not None:
88
+ data = json.dumps(body, allow_nan=False).encode("utf-8")
89
+ headers["Content-Type"] = "application/json"
90
+ request = Request(self.base + path, data=data, headers=headers, method=method)
91
+ try:
92
+ return self._opener.open(request, timeout=self.config.timeout)
93
+ except HTTPError as error:
94
+ with error:
95
+ raise _error_from_body(error.code, error.read(65536)) from None
96
+ except URLError as error:
97
+ raise HarnessError(None, "connection_error",
98
+ f"cannot reach {self.base}: {error.reason}") from None
99
+
100
+ def request(self, method: str, path: str, body: Any | None = None) -> Any:
101
+ """Send one JSON request and return the decoded answer."""
102
+ with self._open(method, path, body, "application/json") as response:
103
+ raw = response.read()
104
+ return json.loads(raw) if raw else None
105
+
106
+ def stream(self, path: str, body: Any) -> Iterator[tuple[str, dict[str, Any]]]:
107
+ """POST and yield ``(event, data)`` for each SSE frame. ``event: error`` raises."""
108
+ with self._open("POST", path, body, "text/event-stream") as response:
109
+ event, data, size = "message", [], 0
110
+ for raw in response:
111
+ size += len(raw)
112
+ if size > MAX_FRAME_BYTES:
113
+ raise HarnessError(None, "stream_error", "SSE frame exceeds 16 MB")
114
+ line = raw.decode("utf-8").rstrip("\r\n")
115
+ if line.startswith("event:"):
116
+ event = line[6:].strip()
117
+ elif line.startswith("data:"):
118
+ data.append(line[5:].lstrip(" "))
119
+ elif not line and data:
120
+ payload = json.loads("\n".join(data))
121
+ if event == "error" or payload.get("type") == "error":
122
+ raise _error_from_body(None, json.dumps(payload).encode())
123
+ yield event, payload
124
+ event, data, size = "message", [], 0
125
+ elif not line:
126
+ event, size = "message", 0
@@ -0,0 +1,3 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """The package version: the one place it is set (pyproject reads it; the User-Agent sends it)."""
3
+ __version__ = "0.1.0"
@@ -0,0 +1,10 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Agno-compatible API on AmpUp Harness: change ``agno.`` to ``ampup_harness.agno.`` in imports.
3
+
4
+ See docs/agno-compat.md for what maps where and what is not covered.
5
+ """
6
+ from ampup_harness._http import HarnessConfig, HarnessError
7
+
8
+ AGNO_COMPAT_VERSION = "3.2.1"
9
+
10
+ __all__ = ["AGNO_COMPAT_VERSION", "HarnessConfig", "HarnessError"]
@@ -0,0 +1,113 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Parameter names of agno==3.2.1, recorded with inspect.signature (see tests/test_parity.py)."""
3
+
4
+ AGENT_INIT = frozenset({
5
+ "model", "fallback_config", "fallback_models", "name", "id", "user_id", "session_id",
6
+ "session_state", "add_session_state_to_context", "overwrite_db_session_state",
7
+ "enable_agentic_state", "cache_session", "search_past_sessions",
8
+ "num_past_sessions_to_search", "num_past_session_runs_in_search", "dependencies",
9
+ "add_dependencies_to_context", "db", "filesystem", "checkpoint", "memory_manager",
10
+ "enable_agentic_memory", "update_memory_on_run", "add_memories_to_context",
11
+ "enable_session_summaries", "add_session_summary_to_context", "session_summary_manager",
12
+ "compaction", "compress_tool_results", "compression_manager", "offload_tool_results",
13
+ "add_history_to_context", "num_history_runs", "num_history_messages",
14
+ "max_tool_calls_from_history", "store_media", "media_storage", "store_tool_messages",
15
+ "store_history_messages", "knowledge", "knowledge_filters",
16
+ "enable_agentic_knowledge_filters", "add_knowledge_to_context", "knowledge_retriever",
17
+ "references_format", "skills", "metadata", "tools", "tool_call_limit", "tool_choice",
18
+ "tool_hooks", "pre_hooks", "post_hooks", "reasoning_model", "reasoning_agent",
19
+ "read_chat_history", "search_knowledge", "add_search_knowledge_instructions",
20
+ "update_knowledge", "read_tool_call_history", "send_media_to_model", "system_message",
21
+ "system_message_role", "introduction", "build_context", "description", "instructions",
22
+ "use_instruction_tags", "expected_output", "additional_context", "markdown",
23
+ "add_name_to_context", "add_datetime_to_context", "add_location_to_context",
24
+ "datetime_format", "timezone_identifier", "resolve_in_context", "learning",
25
+ "add_learnings_to_context", "additional_input", "user_message_role",
26
+ "build_user_context", "retries", "delay_between_retries", "exponential_backoff",
27
+ "parser_model", "parser_model_prompt", "input_schema", "output_schema",
28
+ "parse_response", "output_model", "output_model_prompt", "structured_outputs",
29
+ "use_json_mode", "save_response_to_file", "followups", "num_followups",
30
+ "followup_model", "stream", "stream_events", "store_events", "events_to_skip", "role",
31
+ "debug_mode", "debug_level", "telemetry", "cache_callables", "callable_tools_cache_key",
32
+ "callable_knowledge_cache_key", "sandbox",
33
+ })
34
+
35
+ AGENT_RUN = frozenset({
36
+ "input", "stream", "stream_events", "user_id", "session_id", "session_state",
37
+ "run_context", "run_id", "audio", "images", "videos", "files", "knowledge_filters",
38
+ "add_history_to_context", "add_dependencies_to_context", "add_session_state_to_context",
39
+ "dependencies", "metadata", "output_schema", "yield_run_output", "debug_mode",
40
+ })
41
+
42
+ AGENT_ARUN = frozenset({
43
+ "input", "stream", "user_id", "session_id", "session_state", "run_context", "run_id",
44
+ "audio", "images", "videos", "files", "stream_events", "knowledge_filters",
45
+ "add_history_to_context", "add_dependencies_to_context", "add_session_state_to_context",
46
+ "dependencies", "metadata", "output_schema", "yield_run_output", "debug_mode",
47
+ "background",
48
+ })
49
+
50
+ AGENT_PRINT_RESPONSE = frozenset({
51
+ "input", "session_id", "session_state", "user_id", "run_id", "audio", "images",
52
+ "videos", "files", "stream", "markdown", "knowledge_filters", "add_history_to_context",
53
+ "add_dependencies_to_context", "dependencies", "add_session_state_to_context",
54
+ "metadata", "debug_mode", "show_message", "show_reasoning", "show_full_reasoning",
55
+ "console", "tags_to_include_in_markdown",
56
+ })
57
+
58
+ TEAM_INIT = frozenset({
59
+ "members", "id", "model", "fallback_config", "fallback_models", "name", "role", "mode",
60
+ "respond_directly", "determine_input_for_members", "delegate_to_all_members",
61
+ "max_iterations", "user_id", "session_id", "session_state",
62
+ "add_session_state_to_context", "enable_agentic_state", "overwrite_db_session_state",
63
+ "resolve_in_context", "cache_session", "add_team_history_to_members",
64
+ "num_team_history_runs", "search_past_sessions", "num_past_sessions_to_search",
65
+ "num_past_session_runs_in_search", "description", "instructions",
66
+ "use_instruction_tags", "expected_output", "additional_context", "markdown",
67
+ "add_datetime_to_context", "add_location_to_context", "datetime_format",
68
+ "timezone_identifier", "add_name_to_context", "add_member_tools_to_context",
69
+ "system_message", "system_message_role", "introduction", "additional_input",
70
+ "dependencies", "add_dependencies_to_context", "knowledge", "knowledge_filters",
71
+ "add_knowledge_to_context", "enable_agentic_knowledge_filters", "update_knowledge",
72
+ "knowledge_retriever", "references_format", "share_member_interactions",
73
+ "get_member_information_tool", "search_knowledge", "add_search_knowledge_instructions",
74
+ "read_chat_history", "store_media", "media_storage", "store_tool_messages",
75
+ "store_history_messages", "send_media_to_model", "add_history_to_context",
76
+ "num_history_runs", "num_history_messages", "max_tool_calls_from_history", "skills",
77
+ "tools", "tool_call_limit", "tool_choice", "tool_hooks", "pre_hooks", "post_hooks",
78
+ "input_schema", "output_schema", "parser_model", "parser_model_prompt", "output_model",
79
+ "output_model_prompt", "use_json_mode", "parse_response", "db", "checkpoint",
80
+ "enable_agentic_memory", "update_memory_on_run", "add_memories_to_context",
81
+ "memory_manager", "enable_session_summaries", "session_summary_manager",
82
+ "add_session_summary_to_context", "learning", "add_learnings_to_context",
83
+ "compress_tool_results", "compression_manager", "offload_tool_results", "metadata",
84
+ "reasoning_model", "reasoning_agent", "followups", "num_followups", "followup_model",
85
+ "stream", "stream_events", "store_events", "events_to_skip", "store_member_responses",
86
+ "stream_member_events", "debug_mode", "debug_level", "show_members_responses",
87
+ "retries", "delay_between_retries", "exponential_backoff", "telemetry",
88
+ "cache_callables", "callable_tools_cache_key", "callable_knowledge_cache_key",
89
+ "callable_members_cache_key",
90
+ })
91
+
92
+ WORKFLOW_INIT = frozenset({
93
+ "id", "name", "description", "db", "steps", "agent", "session_id", "session_state",
94
+ "overwrite_db_session_state", "user_id", "debug_level", "debug_mode", "stream",
95
+ "stream_events", "stream_executor_events", "store_events", "store_media",
96
+ "media_storage", "events_to_skip", "store_executor_outputs", "input_schema", "metadata",
97
+ "dependencies", "add_dependencies_to_context", "add_session_state_to_context",
98
+ "cache_session", "telemetry", "add_workflow_history_to_steps", "num_history_runs",
99
+ })
100
+
101
+ WORKFLOW_RUN = frozenset({
102
+ "input", "additional_data", "user_id", "run_id", "session_id", "session_state", "audio",
103
+ "images", "videos", "files", "stream", "stream_events", "background",
104
+ "background_tasks", "dependencies", "metadata", "add_dependencies_to_context",
105
+ "add_session_state_to_context",
106
+ })
107
+
108
+ STEP_INIT = frozenset({
109
+ "name", "agent", "team", "executor", "workflow", "step_id", "description",
110
+ "max_retries", "skip_on_failure", "strict_input_validation", "add_workflow_history",
111
+ "num_history_runs", "human_review",
112
+ })
113
+
@@ -0,0 +1,9 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """``agno.agent``."""
3
+ from ampup_harness.agno.agent.agent import Agent
4
+ from ampup_harness.agno.run.agent import (
5
+ Message, RunEvent, RunOutput, RunOutputEvent, RunResponse, ToolExecution,
6
+ )
7
+
8
+ __all__ = ["Agent", "Message", "RunEvent", "RunOutput", "RunOutputEvent", "RunResponse",
9
+ "ToolExecution"]