unexhub-agent 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.
- unexhub_agent-0.1.0/.gitignore +16 -0
- unexhub_agent-0.1.0/Dockerfile +14 -0
- unexhub_agent-0.1.0/LICENSE +202 -0
- unexhub_agent-0.1.0/Makefile +27 -0
- unexhub_agent-0.1.0/NOTICE +10 -0
- unexhub_agent-0.1.0/PKG-INFO +99 -0
- unexhub_agent-0.1.0/README.md +144 -0
- unexhub_agent-0.1.0/README.pypi.md +65 -0
- unexhub_agent-0.1.0/docs/invocation.schema.json +337 -0
- unexhub_agent-0.1.0/docs/platform-integration.md +59 -0
- unexhub_agent-0.1.0/docs/protocol.md +135 -0
- unexhub_agent-0.1.0/docs/releasing.md +105 -0
- unexhub_agent-0.1.0/docs/verification.md +58 -0
- unexhub_agent-0.1.0/examples/README.md +13 -0
- unexhub_agent-0.1.0/examples/browser-assistant/agent.yaml +6 -0
- unexhub_agent-0.1.0/examples/browser-assistant/instructions.md +5 -0
- unexhub_agent-0.1.0/examples/file-organizer/agent.py +16 -0
- unexhub_agent-0.1.0/examples/file-organizer/agent.yaml +6 -0
- unexhub_agent-0.1.0/examples/file-organizer/instructions.md +4 -0
- unexhub_agent-0.1.0/examples/monitoring/agent.py +16 -0
- unexhub_agent-0.1.0/examples/monitoring/agent.yaml +6 -0
- unexhub_agent-0.1.0/examples/monitoring/instructions.md +3 -0
- unexhub_agent-0.1.0/pyproject.toml +107 -0
- unexhub_agent-0.1.0/requirements.runtime.txt +131 -0
- unexhub_agent-0.1.0/scripts/release.py +297 -0
- unexhub_agent-0.1.0/scripts/smoke_container.py +170 -0
- unexhub_agent-0.1.0/scripts/smoke_package.py +203 -0
- unexhub_agent-0.1.0/src/unexhub_agent/__init__.py +8 -0
- unexhub_agent-0.1.0/src/unexhub_agent/__main__.py +5 -0
- unexhub_agent-0.1.0/src/unexhub_agent/artifacts.py +123 -0
- unexhub_agent-0.1.0/src/unexhub_agent/checker.py +138 -0
- unexhub_agent-0.1.0/src/unexhub_agent/cli.py +101 -0
- unexhub_agent-0.1.0/src/unexhub_agent/config.py +131 -0
- unexhub_agent-0.1.0/src/unexhub_agent/context.py +117 -0
- unexhub_agent-0.1.0/src/unexhub_agent/errors.py +30 -0
- unexhub_agent-0.1.0/src/unexhub_agent/loop.py +214 -0
- unexhub_agent-0.1.0/src/unexhub_agent/model.py +154 -0
- unexhub_agent-0.1.0/src/unexhub_agent/protocol.py +117 -0
- unexhub_agent-0.1.0/src/unexhub_agent/py.typed +0 -0
- unexhub_agent-0.1.0/src/unexhub_agent/runs.py +302 -0
- unexhub_agent-0.1.0/src/unexhub_agent/scaffold.py +107 -0
- unexhub_agent-0.1.0/src/unexhub_agent/server.py +254 -0
- unexhub_agent-0.1.0/src/unexhub_agent/tools.py +137 -0
- unexhub_agent-0.1.0/template/.dockerignore +11 -0
- unexhub_agent-0.1.0/template/.env.example +3 -0
- unexhub_agent-0.1.0/template/.gitignore +6 -0
- unexhub_agent-0.1.0/template/Dockerfile +14 -0
- unexhub_agent-0.1.0/template/README.md +24 -0
- unexhub_agent-0.1.0/template/agent.py +8 -0
- unexhub_agent-0.1.0/template/agent.yaml +13 -0
- unexhub_agent-0.1.0/template/instructions.md +6 -0
- unexhub_agent-0.1.0/template/knowledge/README.md +4 -0
- unexhub_agent-0.1.0/template/requirements.txt +2 -0
- unexhub_agent-0.1.0/template/vendor/LICENSE.unexhub-agent +202 -0
- unexhub_agent-0.1.0/template/vendor/NOTICE.unexhub-agent +10 -0
- unexhub_agent-0.1.0/template/vendor/README.md +5 -0
- unexhub_agent-0.1.0/tests/__init__.py +1 -0
- unexhub_agent-0.1.0/tests/conftest.py +36 -0
- unexhub_agent-0.1.0/tests/support.py +164 -0
- unexhub_agent-0.1.0/tests/test_artifacts_checker.py +110 -0
- unexhub_agent-0.1.0/tests/test_context_lifecycle.py +71 -0
- unexhub_agent-0.1.0/tests/test_model_mcp.py +269 -0
- unexhub_agent-0.1.0/tests/test_native_turn_completion.py +47 -0
- unexhub_agent-0.1.0/tests/test_protocol.py +250 -0
- unexhub_agent-0.1.0/tests/test_release.py +191 -0
- unexhub_agent-0.1.0/tests/test_scaffold_config.py +175 -0
- unexhub_agent-0.1.0/tests/test_stream_lifecycle.py +67 -0
- unexhub_agent-0.1.0/tests/test_tool_catalog.py +104 -0
- unexhub_agent-0.1.0/uv.lock +1655 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
FROM python:3.12-slim@sha256:5e2bdb1b0d542d5039cffb8181c65930093949194a65c365dfb1b0fe13a4fa5b
|
|
2
|
+
WORKDIR /app
|
|
3
|
+
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
|
4
|
+
COPY requirements.runtime.txt /tmp/requirements.lock
|
|
5
|
+
COPY dist/unexhub_agent-*.whl /tmp/runtime/
|
|
6
|
+
RUN pip install --no-cache-dir -r /tmp/requirements.lock \
|
|
7
|
+
&& pip install --no-cache-dir --no-deps /tmp/runtime/unexhub_agent-*.whl
|
|
8
|
+
COPY template/ /app/
|
|
9
|
+
RUN chown -R 10001:10001 /app
|
|
10
|
+
USER 10001:10001
|
|
11
|
+
EXPOSE 8080
|
|
12
|
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
|
|
13
|
+
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health', timeout=2)"
|
|
14
|
+
ENTRYPOINT ["unexhub-agent", "serve", "--config", "/app/agent.yaml"]
|
|
@@ -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,27 @@
|
|
|
1
|
+
.PHONY: setup check test build schema smoke-package smoke-container release-prepare release-check release-plan publish-testpypi publish-pypi
|
|
2
|
+
setup:
|
|
3
|
+
uv sync --frozen --python 3.12
|
|
4
|
+
check:
|
|
5
|
+
uv run ruff check src tests examples scripts template/agent.py
|
|
6
|
+
uv run ruff format --check src tests examples scripts template/agent.py
|
|
7
|
+
uv run mypy src/unexhub_agent
|
|
8
|
+
test:
|
|
9
|
+
uv run pytest
|
|
10
|
+
build:
|
|
11
|
+
uv build --wheel
|
|
12
|
+
schema:
|
|
13
|
+
uv run unexhub-agent schema --output docs/invocation.schema.json
|
|
14
|
+
smoke-package:
|
|
15
|
+
uv run python scripts/smoke_package.py
|
|
16
|
+
smoke-container:
|
|
17
|
+
uv run python scripts/smoke_container.py
|
|
18
|
+
release-prepare:
|
|
19
|
+
uv run --frozen python scripts/release.py prepare
|
|
20
|
+
release-check:
|
|
21
|
+
uv run --frozen python scripts/release.py check
|
|
22
|
+
release-plan:
|
|
23
|
+
uv run --frozen python scripts/release.py publish --repository pypi --dry-run
|
|
24
|
+
publish-testpypi:
|
|
25
|
+
uv run --frozen python scripts/release.py publish --repository testpypi
|
|
26
|
+
publish-pypi:
|
|
27
|
+
uv run --frozen python scripts/release.py publish --repository pypi
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
UnexHub Agent Runtime
|
|
2
|
+
Copyright 2026 UnexHub
|
|
3
|
+
|
|
4
|
+
This Runtime, its starter template and examples are licensed under the
|
|
5
|
+
Apache License, Version 2.0. A copy is provided in LICENSE (or
|
|
6
|
+
LICENSE.unexhub-agent in a generated business project).
|
|
7
|
+
|
|
8
|
+
The Runtime license does not determine the license of independent business
|
|
9
|
+
code added by Agent developers. Third-party dependencies retain their own
|
|
10
|
+
licenses and notices.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: unexhub-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: UnexHub Agent runtime, Python starter and unex-agent-v1 protocol checker
|
|
5
|
+
Project-URL: Homepage, https://unexhub.ai
|
|
6
|
+
Project-URL: Documentation, https://unexhub.ai/agent-doc
|
|
7
|
+
Author: UnexHub
|
|
8
|
+
Maintainer: UnexHub
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: agent,cli,mcp,runtime,unexhub
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: <3.15,>=3.11
|
|
24
|
+
Requires-Dist: fastapi<1,>=0.115
|
|
25
|
+
Requires-Dist: httpx<1,>=0.28
|
|
26
|
+
Requires-Dist: jsonschema<5,>=4.23
|
|
27
|
+
Requires-Dist: mcp<2,>=1.30
|
|
28
|
+
Requires-Dist: openai<3,>=2.0
|
|
29
|
+
Requires-Dist: pydantic<3,>=2.11
|
|
30
|
+
Requires-Dist: pyyaml<7,>=6.0.2
|
|
31
|
+
Requires-Dist: referencing<1,>=0.36
|
|
32
|
+
Requires-Dist: uvicorn<1,>=0.34
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# UnexHub Agent Runtime
|
|
36
|
+
|
|
37
|
+
Build a chat Agent by supplying instructions, knowledge, and optional Python business logic. The official Runtime handles the `unex-agent-v1` container API, a default model/tool loop, streaming events, user questions, and cancellation. UnexHub supplies model and MCP capabilities for each authorized Run; UNH executes the local tools.
|
|
38
|
+
|
|
39
|
+
Requires Python 3.11–3.14. The package includes the CLI, starter template, dependency lock, and three examples. Developers do not need to clone the Runtime repository or build it from source.
|
|
40
|
+
|
|
41
|
+
## Create an Agent
|
|
42
|
+
|
|
43
|
+
Once the selected version is available on PyPI:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
pip install unexhub-agent
|
|
47
|
+
unexhub-agent init my-agent
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or let uv manage the tool environment:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
uvx --from unexhub-agent==0.1.0 unexhub-agent init my-agent
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Initialization makes no network requests. `requirements.runtime.txt` pins the CLI's exact Runtime version; image builds resolve that version from the configured package index. Upgrading your local CLI does not alter existing projects or released images.
|
|
57
|
+
|
|
58
|
+
Before publication, or to carry the Runtime with the project, install a maintainer-provided wheel and initialize with it:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
python -m pip install /path/to/unexhub_agent-0.1.0-py3-none-any.whl
|
|
62
|
+
unexhub-agent init my-agent \
|
|
63
|
+
--runtime-wheel /path/to/unexhub_agent-0.1.0-py3-none-any.whl
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The wheel must match the installed CLI version. It is copied into `vendor/` and referenced with a relative path. Fully disconnected builds also require a source or cache for third-party and business dependencies.
|
|
67
|
+
|
|
68
|
+
## Add your business rules
|
|
69
|
+
|
|
70
|
+
Edit `agent.yaml`, `instructions.md`, and `knowledge/`. The default `entrypoint: null` uses the official loop. To add Python logic, set `entrypoint: agent:run` and implement:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from unexhub_agent import AgentContext
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
async def run(ctx: AgentContext) -> str:
|
|
77
|
+
await ctx.emit("Starting the task", kind="run.progress")
|
|
78
|
+
return await ctx.run_agent()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use `--example browser-assistant`, `--example file-organizer`, or `--example monitoring` to initialize a complete example. The local wheel option can be combined with any example. Browser tools must be active in UNH; artifact publishing requires the platform artifact service.
|
|
82
|
+
|
|
83
|
+
## Build and cloud-test
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
cd my-agent
|
|
87
|
+
unexhub-agent check-config --config agent.yaml
|
|
88
|
+
docker build --platform linux/amd64 -t my-agent:0.1.0 .
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The image listens on `0.0.0.0:8080` and provides `/health`. Use the existing UnexHub Mode A/B image validation, deployment, self-test, and review workflow. Configure chat or hybrid interaction, protocol `unex-agent-v1`, and the Runtime version inside the image. Connect an online UNH device signed into the same account and environment, then send the task in UNH.
|
|
92
|
+
|
|
93
|
+
The platform owns container creation, renewal, stopping, and cleanup. A test Run borrows an existing cloud self-test environment and does not destroy or extend it when the task ends. This package does not connect UNH directly to an Agent on the developer's machine. Container files are temporary; persist business data explicitly. Unknown outcomes must be reconciled rather than blindly replayed.
|
|
94
|
+
|
|
95
|
+
[UnexHub](https://unexhub.ai) · [Developer Center](https://unexhub.ai/agent-doc)
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
The Runtime, starter template, and examples are licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). Generated projects retain Runtime license and attribution files in `vendor/`. Independent business code and third-party dependencies retain their respective licenses.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# UnexHub Agent Template
|
|
2
|
+
|
|
3
|
+
修改提示词和业务代码,构建能够通过 UnexHub 调用模型与用户 UNH 工具的 Agent 镜像。这个独立项目同时维护官方 Python 运行时、业务项目模板、三个示例和协议检查器。
|
|
4
|
+
|
|
5
|
+
当前版本 `0.1.0` 提供可独立安装的运行时、CLI、模板和协议检查器。平台与 UNH 的接入说明见[平台集成](docs/platform-integration.md)。本仓库不修改现有模式 A/B 的业务逻辑;官方包尚未发布到 PyPI。
|
|
6
|
+
|
|
7
|
+
## 创建一个 Agent
|
|
8
|
+
|
|
9
|
+
需要 Python 3.11–3.14;镜像构建需要 Docker。运行时安装包已经包含模板和示例,开发者无需克隆本仓库或构建 wheel。正式发布到 PyPI 后,安装入口为:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
python -m pip install unexhub-agent
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
当前尚未发布官方 PyPI 包;本地验收可以用 `python -m pip install /path/to/unexhub_agent-0.1.0-py3-none-any.whl` 安装维护者提供的 wheel。安装完成后,一条命令创建项目:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
unexhub-agent init my-agent
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
修改项目内 `agent.yaml` 的名称与说明、`instructions.md` 的业务规则和 `knowledge/` 的资料,再构建镜像:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
cd my-agent
|
|
25
|
+
unexhub-agent check-config --config agent.yaml
|
|
26
|
+
docker build --platform linux/amd64 -t my-agent:0.1.0 .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`init` 不联网。默认生成 `unexhub-agent==当前 CLI 版本` 的依赖声明,镜像构建时从配置的包仓库安装该准确版本。安装包携带第三方依赖锁定清单,Dockerfile 在同一次解析中安装运行时、锁定依赖和业务依赖;存在版本冲突时明确失败。升级本机 CLI 不会修改已有项目或已发布 Agent 的版本。
|
|
30
|
+
|
|
31
|
+
默认模式要求构建时的包仓库中已有该准确版本。官方包发布前,直接构建项目应使用下述本地 wheel 方式;本地验证脚本使用隔离包源验证默认模式,不依赖或发布未上线的 PyPI 包。
|
|
32
|
+
|
|
33
|
+
生成项目的主要文件:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
my-agent/
|
|
37
|
+
agent.yaml # 名称、提示词、业务入口和运行配置
|
|
38
|
+
instructions.md # 任务规则与完成条件
|
|
39
|
+
knowledge/ # 随镜像提供的小型业务资料
|
|
40
|
+
agent.py # 可选的 async def run(ctx)
|
|
41
|
+
requirements.txt # 开发者的额外业务依赖
|
|
42
|
+
requirements.runtime.txt # 初始化时固定的运行时版本或相对 wheel 路径
|
|
43
|
+
requirements.lock # 官方运行时的固定第三方依赖
|
|
44
|
+
vendor/ # 可选的本地运行时 wheel
|
|
45
|
+
Dockerfile
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 使用本地 wheel
|
|
49
|
+
|
|
50
|
+
需要随项目携带运行时,或所用版本尚未发布到包仓库时,保留显式 wheel 初始化:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
unexhub-agent init my-agent \
|
|
54
|
+
--runtime-wheel /path/to/unexhub_agent-0.1.0-py3-none-any.whl
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
CLI 在创建项目之前检查 wheel 的包名与版本,要求与当前 CLI 一致。wheel 复制到 `vendor/`,生成的依赖使用相对路径,项目搬到其他目录或构建机器仍可安装。两种方式使用同一个 Dockerfile,均不选择最新版本。此选项只提供运行时 wheel;完全断网构建还需要准备第三方及业务依赖的包源或缓存。
|
|
58
|
+
|
|
59
|
+
## 添加业务函数
|
|
60
|
+
|
|
61
|
+
简单 Agent 使用默认循环即可。需要业务逻辑时,在 `agent.yaml` 设置 `entrypoint: agent:run`:
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from unexhub_agent import AgentContext
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
async def run(ctx: AgentContext) -> str:
|
|
68
|
+
await ctx.emit("开始处理业务任务。", kind="run.progress")
|
|
69
|
+
return await ctx.run_agent(instructions="按照本项目的业务规则处理任务。")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
业务函数可以使用自己的框架,调用 `ctx.model` 和标准 MCP;运行时继续处理 HTTP、事件、问答与取消。入口是项目根目录 Python 文件中的异步函数。模块导入期间避免产生业务副作用。
|
|
73
|
+
|
|
74
|
+
## 使用完整示例
|
|
75
|
+
|
|
76
|
+
在 `init` 命令增加 `--example`,可直接生成对应项目:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
unexhub-agent init browser-agent --example browser-assistant
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
| 示例名 | 行为 |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `file-organizer` | 使用 UNH 文件工具整理指定目录,云端生成报告并保存为平台产物 |
|
|
85
|
+
| `browser-assistant` | 根据动态目录使用浏览器工具,支持图片结果 |
|
|
86
|
+
| `monitoring` | 持续只读巡检、逐轮报告和可取消等待,没有固定任务总时长 |
|
|
87
|
+
|
|
88
|
+
示例的能力依赖与预期结果见 [examples/README.md](examples/README.md)。所有示例使用同一个运行时和 Dockerfile,业务代码没有模式 A/B 分支。
|
|
89
|
+
|
|
90
|
+
## 运行和检查容器
|
|
91
|
+
|
|
92
|
+
镜像在 `0.0.0.0:8080` 启动,提供轻量健康检查和内置状态页面。平台需要提供独立的 `UNEX_RUNTIME_TOKEN` 控制凭据;模型、MCP、产物凭据通过每次受保护调用交付,业务开发者无需在提示词中配置 Key。
|
|
93
|
+
|
|
94
|
+
平台接入细节、现有云端自测与待补接口见[平台集成说明](docs/platform-integration.md)。包含新后端改动的部署会为新自测实例注入独立控制凭据;旧实例须按原流程显式重启,再从本人 UNH 选择并发送任务。本仓库不提供 UNH 直连开发者本机 Agent 的功能。
|
|
95
|
+
|
|
96
|
+
维护者可使用独立随机控制凭据运行隔离协议验证:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
export UNEX_RUNTIME_TOKEN="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')"
|
|
100
|
+
uv run unexhub-agent serve --config template/agent.yaml
|
|
101
|
+
# 另一个继承相同环境的终端执行:
|
|
102
|
+
uv run unexhub-agent check http://127.0.0.1:8080
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
默认 `check` 只读健康信息并检查访问控制,不调用模型。只有显式提供 `--invoke 私有请求.json` 才执行任务;需要回答时使用 `--answer`,测试取消时使用 `--cancel`。超时或结果未知时不会自动重放任务。回环 HTTP 仅用于隔离测试,项目配置须显式设置 `runtime.allow_loopback_http: true` 才能调用本机模型/MCP 夹具。
|
|
106
|
+
|
|
107
|
+
## 运行时边界
|
|
108
|
+
|
|
109
|
+
- 工具通过标准 MCP 动态发现和调用;工具变更、分页、名称映射都由运行时处理。没有按工具名称编写的专用 SDK 或授权白名单,目录过大时明确失败。
|
|
110
|
+
- 模型调用使用平台兼容接口;自动重试关闭,原生工具错误和结构化结果保留,图片需要平台声明的视觉能力。
|
|
111
|
+
- HTTP/SSE 断开只结束该订阅。停止任务要显式取消;容器的创建、续租、销毁以及模型预算由 UnexHub 后端负责。
|
|
112
|
+
- 运行记录和有限回放窗口保存在本进程;平台负责持久保存事件与历史。进程重启、记录淘汰或回放过期后,平台应核对任务,不能把未知状态视为未执行。
|
|
113
|
+
- 产物通过平台确认后才发出保存事件;容器临时文件不是跨任务存储。
|
|
114
|
+
- 输入目前支持文字和内联图片。音频/视频的原生模型输入、平台附件下载和完整跨设备历史恢复留待对应适配器及平台接口。
|
|
115
|
+
|
|
116
|
+
具体状态、幂等、资源上限和协议字段见[协议参考](docs/protocol.md)与生成的 [JSON Schema](docs/invocation.schema.json)。
|
|
117
|
+
|
|
118
|
+
## 项目维护
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
make check # Ruff、格式、Mypy
|
|
122
|
+
make test # 协议与真实 HTTP/MCP 合成服务测试,无需模型 Key
|
|
123
|
+
make build # 生成独立运行时 wheel
|
|
124
|
+
make schema # 更新调用 JSON Schema
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
依赖通过 `uv.lock` 固定。调整依赖后执行 `uv sync`,再用下列命令同步镜像与脚手架依赖:
|
|
128
|
+
|
|
129
|
+
```sh
|
|
130
|
+
uv export --frozen --no-dev --no-emit-project --format requirements-txt \
|
|
131
|
+
--no-hashes --output-file requirements.runtime.txt
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
源码布局、验证结果见[验证记录](docs/verification.md)。容器底层镜像固定 manifest digest;本仓库没有自动发布 Python 包、镜像或云端资源。
|
|
135
|
+
|
|
136
|
+
## PyPI 发布准备
|
|
137
|
+
|
|
138
|
+
维护者通过 `make release-prepare` 执行质量检查、测试、wheel/源码包构建、元数据严格校验、源码包重建比对、独立 pip 安装和两种镜像验证,产物写入 `dist/release/<版本>/`。`make release-check` 复核准备好的产物,`make release-plan` 只输出本地上传计划。它们均不上传到 PyPI 或 TestPyPI。
|
|
139
|
+
|
|
140
|
+
完整操作、版本更新、Token/Trusted Publishing 与显式上传命令见[发布维护指南](docs/releasing.md)。当前仍未发布 PyPI;本地预检不能证明远端包名归属、账号权限或实际上传成功。
|
|
141
|
+
|
|
142
|
+
## 许可证
|
|
143
|
+
|
|
144
|
+
Runtime、模板和示例采用 [Apache-2.0](LICENSE),归属声明见 [NOTICE](NOTICE)。生成项目的 `vendor/` 保留 Runtime 的许可和归属副本;开发者新增的独立业务代码和第三方依赖各自适用其许可证。
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# UnexHub Agent Runtime
|
|
2
|
+
|
|
3
|
+
Build a chat Agent by supplying instructions, knowledge, and optional Python business logic. The official Runtime handles the `unex-agent-v1` container API, a default model/tool loop, streaming events, user questions, and cancellation. UnexHub supplies model and MCP capabilities for each authorized Run; UNH executes the local tools.
|
|
4
|
+
|
|
5
|
+
Requires Python 3.11–3.14. The package includes the CLI, starter template, dependency lock, and three examples. Developers do not need to clone the Runtime repository or build it from source.
|
|
6
|
+
|
|
7
|
+
## Create an Agent
|
|
8
|
+
|
|
9
|
+
Once the selected version is available on PyPI:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pip install unexhub-agent
|
|
13
|
+
unexhub-agent init my-agent
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or let uv manage the tool environment:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
uvx --from unexhub-agent==0.1.0 unexhub-agent init my-agent
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Initialization makes no network requests. `requirements.runtime.txt` pins the CLI's exact Runtime version; image builds resolve that version from the configured package index. Upgrading your local CLI does not alter existing projects or released images.
|
|
23
|
+
|
|
24
|
+
Before publication, or to carry the Runtime with the project, install a maintainer-provided wheel and initialize with it:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
python -m pip install /path/to/unexhub_agent-0.1.0-py3-none-any.whl
|
|
28
|
+
unexhub-agent init my-agent \
|
|
29
|
+
--runtime-wheel /path/to/unexhub_agent-0.1.0-py3-none-any.whl
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The wheel must match the installed CLI version. It is copied into `vendor/` and referenced with a relative path. Fully disconnected builds also require a source or cache for third-party and business dependencies.
|
|
33
|
+
|
|
34
|
+
## Add your business rules
|
|
35
|
+
|
|
36
|
+
Edit `agent.yaml`, `instructions.md`, and `knowledge/`. The default `entrypoint: null` uses the official loop. To add Python logic, set `entrypoint: agent:run` and implement:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from unexhub_agent import AgentContext
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
async def run(ctx: AgentContext) -> str:
|
|
43
|
+
await ctx.emit("Starting the task", kind="run.progress")
|
|
44
|
+
return await ctx.run_agent()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Use `--example browser-assistant`, `--example file-organizer`, or `--example monitoring` to initialize a complete example. The local wheel option can be combined with any example. Browser tools must be active in UNH; artifact publishing requires the platform artifact service.
|
|
48
|
+
|
|
49
|
+
## Build and cloud-test
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
cd my-agent
|
|
53
|
+
unexhub-agent check-config --config agent.yaml
|
|
54
|
+
docker build --platform linux/amd64 -t my-agent:0.1.0 .
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The image listens on `0.0.0.0:8080` and provides `/health`. Use the existing UnexHub Mode A/B image validation, deployment, self-test, and review workflow. Configure chat or hybrid interaction, protocol `unex-agent-v1`, and the Runtime version inside the image. Connect an online UNH device signed into the same account and environment, then send the task in UNH.
|
|
58
|
+
|
|
59
|
+
The platform owns container creation, renewal, stopping, and cleanup. A test Run borrows an existing cloud self-test environment and does not destroy or extend it when the task ends. This package does not connect UNH directly to an Agent on the developer's machine. Container files are temporary; persist business data explicitly. Unknown outcomes must be reconciled rather than blindly replayed.
|
|
60
|
+
|
|
61
|
+
[UnexHub](https://unexhub.ai) · [Developer Center](https://unexhub.ai/agent-doc)
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
The Runtime, starter template, and examples are licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). Generated projects retain Runtime license and attribution files in `vendor/`. Independent business code and third-party dependencies retain their respective licenses.
|