pyxis-harness-launcher 0.1.1.dev9__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.
- pyxis_harness_launcher-0.1.1.dev9/.gitignore +27 -0
- pyxis_harness_launcher-0.1.1.dev9/AGENTS.md +197 -0
- pyxis_harness_launcher-0.1.1.dev9/LICENSE +21 -0
- pyxis_harness_launcher-0.1.1.dev9/PKG-INFO +218 -0
- pyxis_harness_launcher-0.1.1.dev9/pyproject.toml +40 -0
- pyxis_harness_launcher-0.1.1.dev9/pyxis_harness_launcher/__init__.py +25 -0
- pyxis_harness_launcher-0.1.1.dev9/pyxis_harness_launcher/cli.py +165 -0
- pyxis_harness_launcher-0.1.1.dev9/pyxis_harness_launcher/environment.py +269 -0
- pyxis_harness_launcher-0.1.1.dev9/pyxis_harness_launcher/layout.py +151 -0
- pyxis_harness_launcher-0.1.1.dev9/pyxis_harness_launcher/project.py +176 -0
- pyxis_harness_launcher-0.1.1.dev9/pyxis_harness_launcher/protocol.py +18 -0
- pyxis_harness_launcher-0.1.1.dev9/pyxis_harness_launcher/supervisor.py +227 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
|
|
8
|
+
# Environments
|
|
9
|
+
.venv/
|
|
10
|
+
.env
|
|
11
|
+
|
|
12
|
+
# Tooling
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.coverage
|
|
15
|
+
htmlcov/
|
|
16
|
+
.idea/
|
|
17
|
+
.vscode/
|
|
18
|
+
.DS_Store
|
|
19
|
+
|
|
20
|
+
# Local harness state
|
|
21
|
+
.pyharness/
|
|
22
|
+
*.sqlite
|
|
23
|
+
*.sqlite-*
|
|
24
|
+
|
|
25
|
+
# Claude desktop app
|
|
26
|
+
.claude/
|
|
27
|
+
/manual/*.pdf
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# pyxis-harness-launcher
|
|
2
|
+
|
|
3
|
+
启动器:`pyh` 命令、profile 的 uv 项目与环境、supervisor。harness 自身是 profile 项目的一个依赖,装在 profile 的环境里。
|
|
4
|
+
|
|
5
|
+
| 项 | 值 |
|
|
6
|
+
|---|---|
|
|
7
|
+
| 分发包 | `pyxis-harness-launcher` |
|
|
8
|
+
| 模块 | `pyxis_harness_launcher` |
|
|
9
|
+
| 命令 | `pyh`(`pyxis_harness_launcher.cli:main`) |
|
|
10
|
+
| 依赖 | `uv`(版本锁定) |
|
|
11
|
+
| 插件 entry point | 无 |
|
|
12
|
+
|
|
13
|
+
## 使用
|
|
14
|
+
|
|
15
|
+
| 步骤 | 命令 |
|
|
16
|
+
|---|---|
|
|
17
|
+
| 安装 | 在一个 uv 项目里 `uv add pyxis-harness-launcher`;Python 3.12 及以上 |
|
|
18
|
+
| 创建 profile | `uv run pyh init`;首次联网,把 harness 装进 profile 的环境 |
|
|
19
|
+
| 启动 | `uv run pyh run`;浏览器打开 <http://127.0.0.1:8765> |
|
|
20
|
+
| 文档 | <https://github.com/Onenightcarnival/pyharness> |
|
|
21
|
+
|
|
22
|
+
## 文件
|
|
23
|
+
|
|
24
|
+
| 文件 | 内容 |
|
|
25
|
+
|---|---|
|
|
26
|
+
| `__init__.py` | 公开名称 |
|
|
27
|
+
| `protocol.py` | 启动器与环境内 harness 的约定 |
|
|
28
|
+
| `layout.py` | profile 的文件:路径、快照、last-known-good、锁对应的环境 |
|
|
29
|
+
| `project.py` | profile 的 `pyproject.toml`;harness 作为依赖的声明 |
|
|
30
|
+
| `environment.py` | uv 的调用:锁定、构建、wheel、迁移、清理 |
|
|
31
|
+
| `supervisor.py` | 一次运行一代 worker;重启与回滚 |
|
|
32
|
+
| `cli.py` | `pyh` 命令行 |
|
|
33
|
+
|
|
34
|
+
## 两处安装
|
|
35
|
+
|
|
36
|
+
| 安装 | 内容 | 版本 |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| 启动器所在的环境:用户的 uv 项目 | 本包与 `uv` | 该项目的 `uv.lock` |
|
|
39
|
+
| profile 的环境(`envs/<键>/`) | harness(`pyxis-harness`)、它的全部依赖、装进 profile 的包 | `uv.lock` 记录的版本 |
|
|
40
|
+
|
|
41
|
+
环境内的 harness 也依赖本包:`manage` 用同一组函数改声明、锁定、构建。两处的本包版本可以不同,靠 `protocol.py` 互通。
|
|
42
|
+
|
|
43
|
+
## 约定(`protocol.py`)
|
|
44
|
+
|
|
45
|
+
| 名称 | 值 | 含义 |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `KERNEL` | `pyxis-harness` | profile 项目依赖的分发包:harness |
|
|
48
|
+
| `KERNEL_SOURCE_ENV` | `PYH_KERNEL_SOURCE` | harness 取自该检出目录,不取自索引 |
|
|
49
|
+
| `CLI_MODULE` | `pyxis_harness.cli` | `python -m`:harness 的全部命令 |
|
|
50
|
+
| `WORKER_MODULE` | `pyxis_harness.worker` | `python -m`:一代 |
|
|
51
|
+
| `PREFLIGHT_MODULE` | `pyxis_harness.preflight` | `python -m`:试启动;能启动时退出 0 |
|
|
52
|
+
| `BUNDLE_GROUP` | `pyxis_harness.bundles` | bundle 的 entry point 组 |
|
|
53
|
+
| `RESTART_EXIT_CODE` | 75 | worker:启动下一代 |
|
|
54
|
+
| `BOOT_FAILURE_EXIT_CODE` | 3 | worker:本代启动失败 |
|
|
55
|
+
| `ENV_READY` | `.pyxis-harness-ready` | 环境内的文件:已完整建成 |
|
|
56
|
+
|
|
57
|
+
文件上的约定:`pyproject.toml`、`uv.lock`、`envs/<键>/`、`wheels/<哈希>/`、`runtime/` 下的 ready 标记、`boot-error.json`、`rollback.json`、`supervisor.pid`、`last-known-good/`。
|
|
58
|
+
|
|
59
|
+
## Profile 的文件(`layout.py`)
|
|
60
|
+
|
|
61
|
+
`ProfileDir`:不读 YAML;harness 的 `Profile` 继承它。
|
|
62
|
+
|
|
63
|
+
| 路径 | 内容 |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `pyproject.toml` | profile 的包:一个 uv 项目的声明 |
|
|
66
|
+
| `uv.lock` | 该声明解析出的版本与哈希 |
|
|
67
|
+
| `wheels/<哈希>/` | 从本地目录安装的包:构建出的 wheel |
|
|
68
|
+
| `envs/<键>/` | 按 `uv.lock` 构建的环境;键由锁文件内容与解释器版本算出 |
|
|
69
|
+
|
|
70
|
+
| 方法 | 返回 |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `env()` | `uv.lock` 对应的已建成环境;没有时 `None` |
|
|
73
|
+
| `python()` | 该环境的解释器;没有环境时为当前解释器 |
|
|
74
|
+
| `site_packages()` | 该环境的 `site-packages`;旧版本的 `site/`;都没有时 `None` |
|
|
75
|
+
|
|
76
|
+
快照与 last-known-good 是同一组文件:`profile.yaml`、profile patch、`pyproject.toml`、`uv.lock`。
|
|
77
|
+
|
|
78
|
+
## 项目声明(`project.py`)
|
|
79
|
+
|
|
80
|
+
```toml
|
|
81
|
+
[project]
|
|
82
|
+
name = "pyxis-harness-profile"
|
|
83
|
+
version = "0"
|
|
84
|
+
requires-python = "==3.12.*"
|
|
85
|
+
dependencies = [
|
|
86
|
+
"pyxis-harness==0.1.1",
|
|
87
|
+
"pyh-todo",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[tool.uv]
|
|
91
|
+
package = false
|
|
92
|
+
|
|
93
|
+
[tool.uv.sources]
|
|
94
|
+
"pyh-todo" = { path = "wheels/c37b630f4ae3355d/pyh_todo-0.1.0-py3-none-any.whl" }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| 包的来源 | 声明 |
|
|
98
|
+
|---|---|
|
|
99
|
+
| 本地目录、源码包、wheel | 构建为 wheel,存入 `wheels/<哈希>/`;`tool.uv.sources` 指向它,锁文件记录其哈希 |
|
|
100
|
+
| 索引中的包 | 需求原文;`--index-url` 时另加一个 `explicit` 索引 |
|
|
101
|
+
|
|
102
|
+
harness 的声明(`declare_kernel`):
|
|
103
|
+
|
|
104
|
+
| `kernel_source()` | 声明 |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `PYH_KERNEL_SOURCE` 指向的检出目录 | `pyxis-harness`,以可编辑方式取自 `<检出目录>/packages/meta` |
|
|
107
|
+
| 本包以可编辑方式装自一个检出目录 | 同上,取自该检出目录 |
|
|
108
|
+
| 无 | `pyxis-harness==<本包的版本>` |
|
|
109
|
+
|
|
110
|
+
`write_project` 写入的项目总是声明 harness。
|
|
111
|
+
|
|
112
|
+
## 环境(`environment.py`)
|
|
113
|
+
|
|
114
|
+
| 文件 | 含义 | 写入 |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| `pyproject.toml` | 期望:装哪些包、各自的来源 | `write_project` |
|
|
117
|
+
| `uv.lock` | 事实:每个包的版本与哈希 | `uv lock` |
|
|
118
|
+
| `envs/<键>/` | 由 `uv.lock` 推导;可删除,可重建 | `uv sync --frozen` |
|
|
119
|
+
|
|
120
|
+
环境是不可变的:同一份锁对应同一个目录,变更产生新目录。
|
|
121
|
+
|
|
122
|
+
| 函数 | 效果 |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `lock` | `uv lock`;已锁定的版本保持,先用缓存,缺文件时联网;`upgrade=<名称>` 把该包升到需求允许的最新版 |
|
|
125
|
+
| `build` | `uv sync --frozen` 到 `envs/<键>/`;已建成的环境保持 |
|
|
126
|
+
| `prune` | 删除当前文件与 last-known-good 都不指向的环境和 wheel |
|
|
127
|
+
| `prepare` | 一代启动之前:见下表 |
|
|
128
|
+
| `migrate` | 旧版本的 `site/` → 项目、锁、环境 |
|
|
129
|
+
|
|
130
|
+
| `prepare` 遇到 | 动作 |
|
|
131
|
+
|---|---|
|
|
132
|
+
| 旧版本的 `site/` | `migrate` |
|
|
133
|
+
| 没有 `pyproject.toml` | `bootstrap=True`:声明 harness,锁定、构建;否则无 |
|
|
134
|
+
| 项目没有声明 harness | 声明,锁定、构建 |
|
|
135
|
+
| harness 取自检出目录 | 锁定、构建 |
|
|
136
|
+
| 没有 `uv.lock` | 锁定、构建 |
|
|
137
|
+
| 没有 `uv.lock` 对应的环境 | 构建 |
|
|
138
|
+
|
|
139
|
+
`migrate`:
|
|
140
|
+
|
|
141
|
+
| 步骤 | 效果 |
|
|
142
|
+
|---|---|
|
|
143
|
+
| 1 | `site/` 中带 bundle 的每个分发包:按已安装的文件重新打包进 `wheels/`,写入声明 |
|
|
144
|
+
| 2 | 锁定、构建 |
|
|
145
|
+
| 3 | `site/` 改名为 `site.migrated/`;声明与锁并入 last-known-good |
|
|
146
|
+
| 失败 | 恢复原文件;`site/` 继续使用 |
|
|
147
|
+
|
|
148
|
+
联网的 uv 调用把输出写到 stderr(`echo`):首次构建下载 harness 的全部依赖。
|
|
149
|
+
|
|
150
|
+
## Supervisor(`supervisor.py`)
|
|
151
|
+
|
|
152
|
+
一次运行一代 worker;每一代用 `ProfileDir.python()`:当时的 `uv.lock` 所对应环境的解释器。
|
|
153
|
+
|
|
154
|
+
每一代启动之前:`prepare`;未解决的问题记入日志与 `environment` 事件,该代照常启动。
|
|
155
|
+
|
|
156
|
+
| worker 结果 | supervisor 动作 |
|
|
157
|
+
|---|---|
|
|
158
|
+
| 写出 ready 标记 | 记录 `ready` |
|
|
159
|
+
| 退出 75 | 启动下一代 |
|
|
160
|
+
| 退出 0,或收到 SIGINT / SIGTERM | 停止 |
|
|
161
|
+
| 启动失败 | 恢复 last-known-good,写 `rollback.json`,再启动;仅一次 |
|
|
162
|
+
| 启动失败,无可恢复的文件 | 退出 3 |
|
|
163
|
+
| 启动中被转发的信号终止 | 再启动;不回滚 |
|
|
164
|
+
| 启动后其他退出 | 退避重启;`crash_window` 内超过 `max_crashes` 次则停止 |
|
|
165
|
+
|
|
166
|
+
恢复的文件包含 `uv.lock`:harness 的版本与装进 profile 的包随配置一起回到上一次能启动的状态。
|
|
167
|
+
|
|
168
|
+
| supervisor 收到的信号 | 效果 |
|
|
169
|
+
|---|---|
|
|
170
|
+
| SIGINT、SIGTERM | 停止 worker,退出 0 |
|
|
171
|
+
| SIGHUP | 转发;worker 在 hold 全部释放后重启 |
|
|
172
|
+
|
|
173
|
+
事件追加写入 `runtime/supervisor.log.jsonl`。
|
|
174
|
+
|
|
175
|
+
## 命令行(`cli.py`)
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
pyh [--home HOME] <command> [-p PROFILE] ...
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
| 命令 | 运行处 | 效果 |
|
|
182
|
+
|---|---|---|
|
|
183
|
+
| `run` | 启动器 | `prepare`;profile 不存在时在环境内 `init`;supervisor |
|
|
184
|
+
| `run --no-supervisor` | 环境 | 一代,不受管理 |
|
|
185
|
+
| `upgrade [--to VERSION]` | 启动器 | 把 profile 的 harness 换到本启动器的版本或指定版本 |
|
|
186
|
+
| 其余(`init`、`plugin`、`exec`、`preflight`、`dump-config`、`restart`) | 环境 | `prepare`,然后 `<环境的解释器> -m pyxis_harness.cli <原参数>` |
|
|
187
|
+
|
|
188
|
+
`upgrade`:
|
|
189
|
+
|
|
190
|
+
| 步骤 | 效果 |
|
|
191
|
+
|---|---|
|
|
192
|
+
| 1 | 声明 harness 的新版本 |
|
|
193
|
+
| 2 | 锁定(harness 升级,其余已锁定的版本保持)、构建新环境 |
|
|
194
|
+
| 3 | 在新环境内预检 |
|
|
195
|
+
| 4 | 能启动:保留,向运行中的 supervisor 发重启信号;不能:恢复原文件 |
|
|
196
|
+
|
|
197
|
+
启动器不自行改动 profile 的 harness 版本:两者不同时 `run` 打印一行提示。
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Onenightcarnival
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pyxis-harness-launcher
|
|
3
|
+
Version: 0.1.1.dev9
|
|
4
|
+
Summary: PyxisHarness launcher: the pyh command, the profile's uv project and environments, the supervisor
|
|
5
|
+
Project-URL: Homepage, https://github.com/Onenightcarnival/pyharness
|
|
6
|
+
Project-URL: Repository, https://github.com/Onenightcarnival/pyharness
|
|
7
|
+
Project-URL: Issues, https://github.com/Onenightcarnival/pyharness/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/Onenightcarnival/pyharness/tree/main/packages/launcher
|
|
9
|
+
Author: Onenightcarnival
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
Keywords: agent,deepagents,harness,langgraph,llm,plugin
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Requires-Dist: uv==0.13.6
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# pyxis-harness-launcher
|
|
23
|
+
|
|
24
|
+
启动器:`pyh` 命令、profile 的 uv 项目与环境、supervisor。harness 自身是 profile 项目的一个依赖,装在 profile 的环境里。
|
|
25
|
+
|
|
26
|
+
| 项 | 值 |
|
|
27
|
+
|---|---|
|
|
28
|
+
| 分发包 | `pyxis-harness-launcher` |
|
|
29
|
+
| 模块 | `pyxis_harness_launcher` |
|
|
30
|
+
| 命令 | `pyh`(`pyxis_harness_launcher.cli:main`) |
|
|
31
|
+
| 依赖 | `uv`(版本锁定) |
|
|
32
|
+
| 插件 entry point | 无 |
|
|
33
|
+
|
|
34
|
+
## 使用
|
|
35
|
+
|
|
36
|
+
| 步骤 | 命令 |
|
|
37
|
+
|---|---|
|
|
38
|
+
| 安装 | 在一个 uv 项目里 `uv add pyxis-harness-launcher`;Python 3.12 及以上 |
|
|
39
|
+
| 创建 profile | `uv run pyh init`;首次联网,把 harness 装进 profile 的环境 |
|
|
40
|
+
| 启动 | `uv run pyh run`;浏览器打开 <http://127.0.0.1:8765> |
|
|
41
|
+
| 文档 | <https://github.com/Onenightcarnival/pyharness> |
|
|
42
|
+
|
|
43
|
+
## 文件
|
|
44
|
+
|
|
45
|
+
| 文件 | 内容 |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `__init__.py` | 公开名称 |
|
|
48
|
+
| `protocol.py` | 启动器与环境内 harness 的约定 |
|
|
49
|
+
| `layout.py` | profile 的文件:路径、快照、last-known-good、锁对应的环境 |
|
|
50
|
+
| `project.py` | profile 的 `pyproject.toml`;harness 作为依赖的声明 |
|
|
51
|
+
| `environment.py` | uv 的调用:锁定、构建、wheel、迁移、清理 |
|
|
52
|
+
| `supervisor.py` | 一次运行一代 worker;重启与回滚 |
|
|
53
|
+
| `cli.py` | `pyh` 命令行 |
|
|
54
|
+
|
|
55
|
+
## 两处安装
|
|
56
|
+
|
|
57
|
+
| 安装 | 内容 | 版本 |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| 启动器所在的环境:用户的 uv 项目 | 本包与 `uv` | 该项目的 `uv.lock` |
|
|
60
|
+
| profile 的环境(`envs/<键>/`) | harness(`pyxis-harness`)、它的全部依赖、装进 profile 的包 | `uv.lock` 记录的版本 |
|
|
61
|
+
|
|
62
|
+
环境内的 harness 也依赖本包:`manage` 用同一组函数改声明、锁定、构建。两处的本包版本可以不同,靠 `protocol.py` 互通。
|
|
63
|
+
|
|
64
|
+
## 约定(`protocol.py`)
|
|
65
|
+
|
|
66
|
+
| 名称 | 值 | 含义 |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| `KERNEL` | `pyxis-harness` | profile 项目依赖的分发包:harness |
|
|
69
|
+
| `KERNEL_SOURCE_ENV` | `PYH_KERNEL_SOURCE` | harness 取自该检出目录,不取自索引 |
|
|
70
|
+
| `CLI_MODULE` | `pyxis_harness.cli` | `python -m`:harness 的全部命令 |
|
|
71
|
+
| `WORKER_MODULE` | `pyxis_harness.worker` | `python -m`:一代 |
|
|
72
|
+
| `PREFLIGHT_MODULE` | `pyxis_harness.preflight` | `python -m`:试启动;能启动时退出 0 |
|
|
73
|
+
| `BUNDLE_GROUP` | `pyxis_harness.bundles` | bundle 的 entry point 组 |
|
|
74
|
+
| `RESTART_EXIT_CODE` | 75 | worker:启动下一代 |
|
|
75
|
+
| `BOOT_FAILURE_EXIT_CODE` | 3 | worker:本代启动失败 |
|
|
76
|
+
| `ENV_READY` | `.pyxis-harness-ready` | 环境内的文件:已完整建成 |
|
|
77
|
+
|
|
78
|
+
文件上的约定:`pyproject.toml`、`uv.lock`、`envs/<键>/`、`wheels/<哈希>/`、`runtime/` 下的 ready 标记、`boot-error.json`、`rollback.json`、`supervisor.pid`、`last-known-good/`。
|
|
79
|
+
|
|
80
|
+
## Profile 的文件(`layout.py`)
|
|
81
|
+
|
|
82
|
+
`ProfileDir`:不读 YAML;harness 的 `Profile` 继承它。
|
|
83
|
+
|
|
84
|
+
| 路径 | 内容 |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `pyproject.toml` | profile 的包:一个 uv 项目的声明 |
|
|
87
|
+
| `uv.lock` | 该声明解析出的版本与哈希 |
|
|
88
|
+
| `wheels/<哈希>/` | 从本地目录安装的包:构建出的 wheel |
|
|
89
|
+
| `envs/<键>/` | 按 `uv.lock` 构建的环境;键由锁文件内容与解释器版本算出 |
|
|
90
|
+
|
|
91
|
+
| 方法 | 返回 |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `env()` | `uv.lock` 对应的已建成环境;没有时 `None` |
|
|
94
|
+
| `python()` | 该环境的解释器;没有环境时为当前解释器 |
|
|
95
|
+
| `site_packages()` | 该环境的 `site-packages`;旧版本的 `site/`;都没有时 `None` |
|
|
96
|
+
|
|
97
|
+
快照与 last-known-good 是同一组文件:`profile.yaml`、profile patch、`pyproject.toml`、`uv.lock`。
|
|
98
|
+
|
|
99
|
+
## 项目声明(`project.py`)
|
|
100
|
+
|
|
101
|
+
```toml
|
|
102
|
+
[project]
|
|
103
|
+
name = "pyxis-harness-profile"
|
|
104
|
+
version = "0"
|
|
105
|
+
requires-python = "==3.12.*"
|
|
106
|
+
dependencies = [
|
|
107
|
+
"pyxis-harness==0.1.1",
|
|
108
|
+
"pyh-todo",
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
[tool.uv]
|
|
112
|
+
package = false
|
|
113
|
+
|
|
114
|
+
[tool.uv.sources]
|
|
115
|
+
"pyh-todo" = { path = "wheels/c37b630f4ae3355d/pyh_todo-0.1.0-py3-none-any.whl" }
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| 包的来源 | 声明 |
|
|
119
|
+
|---|---|
|
|
120
|
+
| 本地目录、源码包、wheel | 构建为 wheel,存入 `wheels/<哈希>/`;`tool.uv.sources` 指向它,锁文件记录其哈希 |
|
|
121
|
+
| 索引中的包 | 需求原文;`--index-url` 时另加一个 `explicit` 索引 |
|
|
122
|
+
|
|
123
|
+
harness 的声明(`declare_kernel`):
|
|
124
|
+
|
|
125
|
+
| `kernel_source()` | 声明 |
|
|
126
|
+
|---|---|
|
|
127
|
+
| `PYH_KERNEL_SOURCE` 指向的检出目录 | `pyxis-harness`,以可编辑方式取自 `<检出目录>/packages/meta` |
|
|
128
|
+
| 本包以可编辑方式装自一个检出目录 | 同上,取自该检出目录 |
|
|
129
|
+
| 无 | `pyxis-harness==<本包的版本>` |
|
|
130
|
+
|
|
131
|
+
`write_project` 写入的项目总是声明 harness。
|
|
132
|
+
|
|
133
|
+
## 环境(`environment.py`)
|
|
134
|
+
|
|
135
|
+
| 文件 | 含义 | 写入 |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| `pyproject.toml` | 期望:装哪些包、各自的来源 | `write_project` |
|
|
138
|
+
| `uv.lock` | 事实:每个包的版本与哈希 | `uv lock` |
|
|
139
|
+
| `envs/<键>/` | 由 `uv.lock` 推导;可删除,可重建 | `uv sync --frozen` |
|
|
140
|
+
|
|
141
|
+
环境是不可变的:同一份锁对应同一个目录,变更产生新目录。
|
|
142
|
+
|
|
143
|
+
| 函数 | 效果 |
|
|
144
|
+
|---|---|
|
|
145
|
+
| `lock` | `uv lock`;已锁定的版本保持,先用缓存,缺文件时联网;`upgrade=<名称>` 把该包升到需求允许的最新版 |
|
|
146
|
+
| `build` | `uv sync --frozen` 到 `envs/<键>/`;已建成的环境保持 |
|
|
147
|
+
| `prune` | 删除当前文件与 last-known-good 都不指向的环境和 wheel |
|
|
148
|
+
| `prepare` | 一代启动之前:见下表 |
|
|
149
|
+
| `migrate` | 旧版本的 `site/` → 项目、锁、环境 |
|
|
150
|
+
|
|
151
|
+
| `prepare` 遇到 | 动作 |
|
|
152
|
+
|---|---|
|
|
153
|
+
| 旧版本的 `site/` | `migrate` |
|
|
154
|
+
| 没有 `pyproject.toml` | `bootstrap=True`:声明 harness,锁定、构建;否则无 |
|
|
155
|
+
| 项目没有声明 harness | 声明,锁定、构建 |
|
|
156
|
+
| harness 取自检出目录 | 锁定、构建 |
|
|
157
|
+
| 没有 `uv.lock` | 锁定、构建 |
|
|
158
|
+
| 没有 `uv.lock` 对应的环境 | 构建 |
|
|
159
|
+
|
|
160
|
+
`migrate`:
|
|
161
|
+
|
|
162
|
+
| 步骤 | 效果 |
|
|
163
|
+
|---|---|
|
|
164
|
+
| 1 | `site/` 中带 bundle 的每个分发包:按已安装的文件重新打包进 `wheels/`,写入声明 |
|
|
165
|
+
| 2 | 锁定、构建 |
|
|
166
|
+
| 3 | `site/` 改名为 `site.migrated/`;声明与锁并入 last-known-good |
|
|
167
|
+
| 失败 | 恢复原文件;`site/` 继续使用 |
|
|
168
|
+
|
|
169
|
+
联网的 uv 调用把输出写到 stderr(`echo`):首次构建下载 harness 的全部依赖。
|
|
170
|
+
|
|
171
|
+
## Supervisor(`supervisor.py`)
|
|
172
|
+
|
|
173
|
+
一次运行一代 worker;每一代用 `ProfileDir.python()`:当时的 `uv.lock` 所对应环境的解释器。
|
|
174
|
+
|
|
175
|
+
每一代启动之前:`prepare`;未解决的问题记入日志与 `environment` 事件,该代照常启动。
|
|
176
|
+
|
|
177
|
+
| worker 结果 | supervisor 动作 |
|
|
178
|
+
|---|---|
|
|
179
|
+
| 写出 ready 标记 | 记录 `ready` |
|
|
180
|
+
| 退出 75 | 启动下一代 |
|
|
181
|
+
| 退出 0,或收到 SIGINT / SIGTERM | 停止 |
|
|
182
|
+
| 启动失败 | 恢复 last-known-good,写 `rollback.json`,再启动;仅一次 |
|
|
183
|
+
| 启动失败,无可恢复的文件 | 退出 3 |
|
|
184
|
+
| 启动中被转发的信号终止 | 再启动;不回滚 |
|
|
185
|
+
| 启动后其他退出 | 退避重启;`crash_window` 内超过 `max_crashes` 次则停止 |
|
|
186
|
+
|
|
187
|
+
恢复的文件包含 `uv.lock`:harness 的版本与装进 profile 的包随配置一起回到上一次能启动的状态。
|
|
188
|
+
|
|
189
|
+
| supervisor 收到的信号 | 效果 |
|
|
190
|
+
|---|---|
|
|
191
|
+
| SIGINT、SIGTERM | 停止 worker,退出 0 |
|
|
192
|
+
| SIGHUP | 转发;worker 在 hold 全部释放后重启 |
|
|
193
|
+
|
|
194
|
+
事件追加写入 `runtime/supervisor.log.jsonl`。
|
|
195
|
+
|
|
196
|
+
## 命令行(`cli.py`)
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
pyh [--home HOME] <command> [-p PROFILE] ...
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
| 命令 | 运行处 | 效果 |
|
|
203
|
+
|---|---|---|
|
|
204
|
+
| `run` | 启动器 | `prepare`;profile 不存在时在环境内 `init`;supervisor |
|
|
205
|
+
| `run --no-supervisor` | 环境 | 一代,不受管理 |
|
|
206
|
+
| `upgrade [--to VERSION]` | 启动器 | 把 profile 的 harness 换到本启动器的版本或指定版本 |
|
|
207
|
+
| 其余(`init`、`plugin`、`exec`、`preflight`、`dump-config`、`restart`) | 环境 | `prepare`,然后 `<环境的解释器> -m pyxis_harness.cli <原参数>` |
|
|
208
|
+
|
|
209
|
+
`upgrade`:
|
|
210
|
+
|
|
211
|
+
| 步骤 | 效果 |
|
|
212
|
+
|---|---|
|
|
213
|
+
| 1 | 声明 harness 的新版本 |
|
|
214
|
+
| 2 | 锁定(harness 升级,其余已锁定的版本保持)、构建新环境 |
|
|
215
|
+
| 3 | 在新环境内预检 |
|
|
216
|
+
| 4 | 能启动:保留,向运行中的 supervisor 发重启信号;不能:恢复原文件 |
|
|
217
|
+
|
|
218
|
+
启动器不自行改动 profile 的 harness 版本:两者不同时 `run` 打印一行提示。
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pyxis-harness-launcher"
|
|
3
|
+
version = "0.1.1.dev9"
|
|
4
|
+
description = "PyxisHarness launcher: the pyh command, the profile's uv project and environments, the supervisor"
|
|
5
|
+
license = "MIT"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
readme = "AGENTS.md"
|
|
8
|
+
authors = [{ name = "Onenightcarnival" }]
|
|
9
|
+
keywords = ["agent", "llm", "harness", "plugin", "langgraph", "deepagents"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.12",
|
|
15
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
16
|
+
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
17
|
+
]
|
|
18
|
+
dependencies = ["uv==0.13.6"]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
pyh = "pyxis_harness_launcher.cli:main"
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/Onenightcarnival/pyharness"
|
|
25
|
+
Repository = "https://github.com/Onenightcarnival/pyharness"
|
|
26
|
+
Issues = "https://github.com/Onenightcarnival/pyharness/issues"
|
|
27
|
+
Documentation = "https://github.com/Onenightcarnival/pyharness/tree/main/packages/launcher"
|
|
28
|
+
|
|
29
|
+
[build-system]
|
|
30
|
+
requires = ["hatchling"]
|
|
31
|
+
build-backend = "hatchling.build"
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.targets.wheel]
|
|
34
|
+
packages = ["pyxis_harness_launcher"]
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
37
|
+
"AGENTS.md" = "pyxis_harness_launcher/AGENTS.md"
|
|
38
|
+
|
|
39
|
+
[tool.hatch.build.targets.sdist.force-include]
|
|
40
|
+
"../../LICENSE" = "LICENSE"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .layout import ProfileDir, harness_home
|
|
4
|
+
from .project import Project, declare_kernel, kernel_source, normalize, read_project, requirement_name, write_project
|
|
5
|
+
from .protocol import BOOT_FAILURE_EXIT_CODE, BUNDLE_GROUP, KERNEL, RESTART_EXIT_CODE
|
|
6
|
+
from .supervisor import Supervisor, SupervisorError, signal_restart
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"BOOT_FAILURE_EXIT_CODE",
|
|
10
|
+
"BUNDLE_GROUP",
|
|
11
|
+
"KERNEL",
|
|
12
|
+
"RESTART_EXIT_CODE",
|
|
13
|
+
"ProfileDir",
|
|
14
|
+
"Project",
|
|
15
|
+
"Supervisor",
|
|
16
|
+
"SupervisorError",
|
|
17
|
+
"declare_kernel",
|
|
18
|
+
"harness_home",
|
|
19
|
+
"kernel_source",
|
|
20
|
+
"normalize",
|
|
21
|
+
"read_project",
|
|
22
|
+
"requirement_name",
|
|
23
|
+
"signal_restart",
|
|
24
|
+
"write_project",
|
|
25
|
+
]
|