luna-agent-bridge 0.1.1__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.
- luna_agent_bridge-0.1.1/CODE_OF_CONDUCT.md +15 -0
- luna_agent_bridge-0.1.1/CONTRIBUTING.md +23 -0
- luna_agent_bridge-0.1.1/LICENSE +21 -0
- luna_agent_bridge-0.1.1/MANIFEST.in +17 -0
- luna_agent_bridge-0.1.1/PKG-INFO +173 -0
- luna_agent_bridge-0.1.1/README.md +162 -0
- luna_agent_bridge-0.1.1/SECURITY.md +19 -0
- luna_agent_bridge-0.1.1/assets/AGENTS.block.md +8 -0
- luna_agent_bridge-0.1.1/assets/SKILL.md +32 -0
- luna_agent_bridge-0.1.1/docs/superpowers/plans/2026-08-14-luna-agent-session-isolation-plan.md +241 -0
- luna_agent_bridge-0.1.1/docs/superpowers/plans/2026-08-14-native-luna-subagent-plan.md +196 -0
- luna_agent_bridge-0.1.1/docs/superpowers/plans/2026-08-14-open-source-packaging-plan.md +69 -0
- luna_agent_bridge-0.1.1/docs/superpowers/plans/2026-08-14-readme-positioning-plan.md +174 -0
- luna_agent_bridge-0.1.1/docs/superpowers/specs/2026-08-14-luna-agent-session-isolation-design.md +117 -0
- luna_agent_bridge-0.1.1/docs/superpowers/specs/2026-08-14-native-luna-subagent-design.md +146 -0
- luna_agent_bridge-0.1.1/docs/superpowers/specs/2026-08-14-open-source-packaging-design.md +36 -0
- luna_agent_bridge-0.1.1/docs/superpowers/specs/2026-08-14-readme-positioning-design.md +32 -0
- luna_agent_bridge-0.1.1/packages/native-luna-subagents/SKILL.md +47 -0
- luna_agent_bridge-0.1.1/packages/native-luna-subagents/agents/openai.yaml +7 -0
- luna_agent_bridge-0.1.1/plugins/luna-agent-bridge/.codex-plugin/plugin.json +29 -0
- luna_agent_bridge-0.1.1/plugins/luna-agent-bridge/skills/luna-agent-bridge/SKILL.md +41 -0
- luna_agent_bridge-0.1.1/plugins/luna-agent-bridge/skills/luna-agent-bridge/agents/openai.yaml +7 -0
- luna_agent_bridge-0.1.1/pyproject.toml +20 -0
- luna_agent_bridge-0.1.1/setup.cfg +4 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/__init__.py +3 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/__main__.py +7 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/cli.py +384 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/codex_adapter.py +129 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/config.py +76 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/domain.py +133 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/installer.py +238 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/paths.py +94 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/pipe_client.py +65 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/pipe_server.py +137 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/process_control.py +185 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/protocol.py +163 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/scheduler.py +103 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/service.py +383 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/session.py +36 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge/storage.py +563 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge.egg-info/PKG-INFO +173 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge.egg-info/SOURCES.txt +57 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge.egg-info/dependency_links.txt +1 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge.egg-info/entry_points.txt +2 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge.egg-info/requires.txt +3 -0
- luna_agent_bridge-0.1.1/src/luna_agent_bridge.egg-info/top_level.txt +1 -0
- luna_agent_bridge-0.1.1/tests/__init__.py +0 -0
- luna_agent_bridge-0.1.1/tests/fake_codex.py +32 -0
- luna_agent_bridge-0.1.1/tests/test_cli.py +123 -0
- luna_agent_bridge-0.1.1/tests/test_codex_adapter.py +61 -0
- luna_agent_bridge-0.1.1/tests/test_config_domain.py +50 -0
- luna_agent_bridge-0.1.1/tests/test_end_to_end.py +107 -0
- luna_agent_bridge-0.1.1/tests/test_installer.py +73 -0
- luna_agent_bridge-0.1.1/tests/test_process_scheduler.py +63 -0
- luna_agent_bridge-0.1.1/tests/test_protocol_pipe.py +73 -0
- luna_agent_bridge-0.1.1/tests/test_release_layout.py +115 -0
- luna_agent_bridge-0.1.1/tests/test_service.py +89 -0
- luna_agent_bridge-0.1.1/tests/test_session.py +26 -0
- luna_agent_bridge-0.1.1/tests/test_storage.py +165 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# 行为准则
|
|
2
|
+
|
|
3
|
+
## 我们的承诺
|
|
4
|
+
|
|
5
|
+
为了营造开放、友善和安全的协作环境,参与者应尊重不同经验、背景和观点,并以建设性方式讨论技术取舍。
|
|
6
|
+
|
|
7
|
+
## 不可接受的行为
|
|
8
|
+
|
|
9
|
+
- 人身攻击、骚扰、歧视、威胁或公开他人私人信息。
|
|
10
|
+
- 发布凭据、恶意载荷或未经授权的第三方数据。
|
|
11
|
+
- 在代码审查、Issue 或社区讨论中持续扰乱协作。
|
|
12
|
+
|
|
13
|
+
## 执行
|
|
14
|
+
|
|
15
|
+
请通过仓库维护者提供的私有渠道报告问题。维护者可以删除不当内容、限制参与权限,或在必要时终止参与资格。所有处理都会尽量保密并保持一致性。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# 贡献指南
|
|
2
|
+
|
|
3
|
+
感谢参与 Luna Agent Bridge。项目包含两个有意分离的发布面:
|
|
4
|
+
|
|
5
|
+
- `packages/native-luna-subagents`:只指导 Codex 原生子 Agent 的 Skill。
|
|
6
|
+
- `plugins/luna-agent-bridge`:用户主动选择的 Windows 外部桥接插件。
|
|
7
|
+
|
|
8
|
+
## 开发约束
|
|
9
|
+
|
|
10
|
+
1. 不把外部 Broker、SQLite 持久化或 `luna-agent` CLI 描述为 Codex 原生能力。
|
|
11
|
+
2. 原生 Skill 不得启动后台进程、修改 PATH、保存凭据或绕过沙箱。
|
|
12
|
+
3. 外部桥接器的进程、Named Pipe、自动批准和数据目录变更必须补充测试和安全说明。
|
|
13
|
+
4. 修改 Python 代码后运行:
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
.\.venv\Scripts\python.exe -m unittest discover -s tests -q
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
5. 使用 `pip install -e ".[dev]"` 安装 `PyYAML` 后,修改 Skill 或插件清单时运行对应的官方校验脚本。
|
|
20
|
+
|
|
21
|
+
## 提交内容
|
|
22
|
+
|
|
23
|
+
提交说明应包含变更范围、测试命令和已知风险。不要提交 `.venv`、`build`、`dist`、`outputs`、`__pycache__` 或运行日志。
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Luna Agent Bridge contributors
|
|
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,17 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include CONTRIBUTING.md
|
|
4
|
+
include SECURITY.md
|
|
5
|
+
include CODE_OF_CONDUCT.md
|
|
6
|
+
recursive-include src *.py
|
|
7
|
+
recursive-include tests *.py
|
|
8
|
+
recursive-include assets *
|
|
9
|
+
recursive-include packages *
|
|
10
|
+
recursive-include plugins *
|
|
11
|
+
recursive-include docs *.md
|
|
12
|
+
global-exclude *.py[cod]
|
|
13
|
+
global-exclude *.log
|
|
14
|
+
prune .venv
|
|
15
|
+
prune build
|
|
16
|
+
prune dist
|
|
17
|
+
prune outputs
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: luna-agent-bridge
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Cost-conscious local bridge for routing Codex sub-agent tasks to gpt-5.6-luna with optional cross-session persistence
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Provides-Extra: dev
|
|
9
|
+
Requires-Dist: PyYAML>=6.0; extra == "dev"
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# Luna Agent Bridge
|
|
13
|
+
|
|
14
|
+
让 Codex 用户把适合的子 Agent 任务路由到 `gpt-5.6-luna`,在主 Agent 保持高能力的同时,为高频、边界清晰的任务提供更可控的成本与质量选择;需要时再启用本地队列和跨会话恢复。
|
|
15
|
+
|
|
16
|
+
## 为什么做这个项目
|
|
17
|
+
|
|
18
|
+
Codex 主 Agent 通常负责需求理解、方案判断和最终整合。代码审查、测试执行、资料整理、局部搜索等子任务边界更清晰,用户可能希望用更适合高频任务的模型配置,而不是让每个子任务都沿用主 Agent 的配置。
|
|
19
|
+
|
|
20
|
+
这个项目把两个概念明确分开:`gpt-5.6-luna` 是模型,`max` 是推理强度;本项目的桥接运行时会将这组配置传给 Codex CLI。这样做的目标是让用户可以对不同任务做有意识的模型路由,并据自己的任务、账号和运行环境测量成本、延迟与质量。它不承诺固定比例的省钱效果,也不保证所有 Codex 运行环境都开放该模型。
|
|
21
|
+
|
|
22
|
+
可以把任务流理解为:
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
主 Agent(负责规划、判断和整合)
|
|
26
|
+
├─ 复杂或高风险任务 ───────────────→ 主 Agent 使用的高能力模型
|
|
27
|
+
└─ 高频、边界清晰的子任务 ─────────→ gpt-5.6-luna + max
|
|
28
|
+
└─ 可选:本地队列与跨会话恢复
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 选择哪条路径
|
|
32
|
+
|
|
33
|
+
| 需求 | 推荐路径 |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| 普通拆解、代码审查、测试或资料整理 | Codex 原生子 Agent + 本项目提供的 Skill |
|
|
36
|
+
| 希望显式指定 `gpt-5.6-luna` 和 `max` | 外部桥接器(在运行环境允许时) |
|
|
37
|
+
| 需要跨 Codex 会话保存、恢复或接管任务 | 外部桥接器 |
|
|
38
|
+
| 只需要当前会话内的并发协作 | 优先使用 Codex 原生子 Agent |
|
|
39
|
+
|
|
40
|
+
原生子 Agent 由 Codex 运行环境负责调度,通常是最轻量的路径。外部桥接器是可选兼容层,不是 Codex 官方原生功能;它不能把原生子 Agent 的内部通道、侧边栏展示或生命周期承诺扩展到所有环境。
|
|
41
|
+
|
|
42
|
+
## 推荐路径:原生 Skill
|
|
43
|
+
|
|
44
|
+
这是普通任务拆解的默认入口。Skill 只提供拆解、并发、文件归属、消息交接和验证规则,不启动 Broker、不修改 PATH、不保存凭据,也不承诺跨会话持久化。
|
|
45
|
+
|
|
46
|
+
将 Skill 复制到用户级 Skill 目录(Windows PowerShell):
|
|
47
|
+
|
|
48
|
+
```powershell
|
|
49
|
+
$skillRoot = if ($env:CODEX_HOME) { Join-Path $env:CODEX_HOME 'skills' } else { Join-Path $env:USERPROFILE '.codex\skills' }
|
|
50
|
+
Copy-Item -Recurse -Force '.\packages\native-luna-subagents' (Join-Path $skillRoot 'native-luna-subagents')
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
若运行环境支持用户级 Agent 配置,可以将模型和推理强度设为:
|
|
54
|
+
|
|
55
|
+
```toml
|
|
56
|
+
[agents]
|
|
57
|
+
enabled = true
|
|
58
|
+
max_concurrent_threads_per_session = 4
|
|
59
|
+
default_subagent_model = "gpt-5.6-luna"
|
|
60
|
+
default_subagent_reasoning_effort = "max"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
模型是否可用、子 Agent 是否显示在侧边栏,以及会话关闭后的生命周期,仍由 Codex 运行环境决定;本项目不把它们包装成持久化保证。
|
|
64
|
+
|
|
65
|
+
## 可选路径:外部桥接器
|
|
66
|
+
|
|
67
|
+
只有在用户明确要求跨 Codex 会话保存、恢复或接管任务,或需要在本地运行时强制路由到 `gpt-5.6-luna` + `max` 时,才考虑安装外部桥接器。它要求 Windows 和 Python 3.12 或更高版本:
|
|
68
|
+
|
|
69
|
+
发布版本可直接从 PyPI 安装:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
python -m pip install luna-agent-bridge
|
|
73
|
+
luna-agent install
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
也可以从 [GitHub Releases](https://github.com/ZaviWayne/luna-agent-bridge/releases/latest) 下载 Windows 单文件 `luna-agent.exe`,无需配置 Python。下载后可用 `.\luna-agent.exe --help` 查看命令;首次使用外部桥接器前运行 `.\luna-agent.exe install`。
|
|
77
|
+
|
|
78
|
+
如果需要从源码开发或测试,再使用下面的可编辑安装方式:
|
|
79
|
+
|
|
80
|
+
```powershell
|
|
81
|
+
python -m venv .venv
|
|
82
|
+
.\.venv\Scripts\Activate.ps1
|
|
83
|
+
python -m pip install -e ".[dev]"
|
|
84
|
+
luna-agent install
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
激活成功后,当前 PowerShell 提示符会带有 `(.venv)`,后续可以直接使用 `luna-agent`。如果不希望激活虚拟环境,改用虚拟环境中的完整路径:
|
|
88
|
+
|
|
89
|
+
```powershell
|
|
90
|
+
.\.venv\Scripts\python.exe -m pip install -e ".[dev]"
|
|
91
|
+
.\.venv\Scripts\luna-agent.exe install
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
如果 PowerShell 阻止执行 `Activate.ps1`,可以在当前窗口临时放宽策略后重试,或直接使用上面的完整路径方式:
|
|
95
|
+
|
|
96
|
+
```powershell
|
|
97
|
+
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
常用命令:
|
|
101
|
+
|
|
102
|
+
以下命令假设虚拟环境已经激活;未激活时,请将命令前缀替换为 `.\.venv\Scripts\luna-agent.exe`。
|
|
103
|
+
|
|
104
|
+
```powershell
|
|
105
|
+
luna-agent spawn --name reviewer --cwd <workspace-path> --task "检查当前修改"
|
|
106
|
+
luna-agent status <agent-id>
|
|
107
|
+
luna-agent send <agent-id> "补充检查边界条件"
|
|
108
|
+
luna-agent wait <agent-id> --timeout 300
|
|
109
|
+
luna-agent result <agent-id>
|
|
110
|
+
luna-agent interrupt <agent-id>
|
|
111
|
+
luna-agent archive <agent-id>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
桥接器通过本地 Codex CLI 启动任务,并传递:
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
--model gpt-5.6-luna
|
|
118
|
+
--config model_reasoning_effort="max"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
本地状态默认保存到 `%LOCALAPPDATA%\CodexLunaAgent`,包括任务元数据、事件和恢复所需的队列状态。运行中的消息会排队到当前轮次边界,不能像原生内部通道一样即时注入模型生成过程。
|
|
122
|
+
|
|
123
|
+
用户准备关闭 Codex 时,必须先中断仍在运行的外部 Agent,再执行:
|
|
124
|
+
|
|
125
|
+
```powershell
|
|
126
|
+
luna-agent broker shutdown
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
不要假设关闭 Codex 会自动回收外部 Broker。普通卸载保留数据库;只有用户明确确认后才执行:
|
|
130
|
+
|
|
131
|
+
```powershell
|
|
132
|
+
luna-agent uninstall --purge-data --yes
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 能力边界
|
|
136
|
+
|
|
137
|
+
桥接器提供:
|
|
138
|
+
|
|
139
|
+
- 面向本地 Codex CLI 的显式模型与推理强度路由。
|
|
140
|
+
- SQLite 状态存储、任务事件、消息队列和恢复入口。
|
|
141
|
+
- 在工作区切换或重新打开 Codex 后,通过任务 ID 查询、发送、等待和接管。
|
|
142
|
+
- 最多 4 个本地 Worker,并在 Broker 关闭时停止其管理的进程。
|
|
143
|
+
|
|
144
|
+
桥接器不提供:
|
|
145
|
+
|
|
146
|
+
- Codex 官方原生子 Agent、官方侧边栏展示或官方生命周期保证。
|
|
147
|
+
- 绕过账号权限、模型可用性、沙箱或批准策略的能力。
|
|
148
|
+
- 固定的成本节省比例、固定延迟或跨账号的模型可用性承诺。
|
|
149
|
+
- 远程 TCP 控制;状态和控制面默认只在本机 Named Pipe 上工作。
|
|
150
|
+
|
|
151
|
+
## 插件入口
|
|
152
|
+
|
|
153
|
+
`plugins/luna-agent-bridge` 包含 `.codex-plugin/plugin.json` 和一个明确标注为“可选兼容层”的 Skill。它不会自动安装可执行文件、修改全局配置或添加个人 Marketplace 条目;请通过 Codex 的本地插件安装流程显式添加。
|
|
154
|
+
|
|
155
|
+
## 安全边界
|
|
156
|
+
|
|
157
|
+
- 不开放 TCP 远程控制。
|
|
158
|
+
- 不读取或保存 Codex 凭据。
|
|
159
|
+
- 不提供完全绕过沙箱的模式。
|
|
160
|
+
- Named Pipe、自动批准、用户数据目录和进程生命周期都属于外部桥接器的安全审查范围。
|
|
161
|
+
- 不要把外部桥接器或其跨会话恢复能力描述为 Codex 官方原生 Luna。
|
|
162
|
+
|
|
163
|
+
## 开发与测试
|
|
164
|
+
|
|
165
|
+
```powershell
|
|
166
|
+
.\.venv\Scripts\python.exe -m unittest discover -s tests -q
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`tests/fixtures` 中的 JSONL 文件是确定性的 Codex CLI 响应样本,用于在不访问网络、不消耗模型调用额度的情况下覆盖解析、事件和恢复逻辑;它们是测试输入,不会被打包到运行时。
|
|
170
|
+
|
|
171
|
+
发布前请移除 `.venv`、`build`、`dist`、`outputs`、`__pycache__` 和运行日志。Skill 与插件清单应通过对应的官方校验脚本。
|
|
172
|
+
|
|
173
|
+
项目采用 MIT License,详见 [LICENSE](LICENSE)。
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Luna Agent Bridge
|
|
2
|
+
|
|
3
|
+
让 Codex 用户把适合的子 Agent 任务路由到 `gpt-5.6-luna`,在主 Agent 保持高能力的同时,为高频、边界清晰的任务提供更可控的成本与质量选择;需要时再启用本地队列和跨会话恢复。
|
|
4
|
+
|
|
5
|
+
## 为什么做这个项目
|
|
6
|
+
|
|
7
|
+
Codex 主 Agent 通常负责需求理解、方案判断和最终整合。代码审查、测试执行、资料整理、局部搜索等子任务边界更清晰,用户可能希望用更适合高频任务的模型配置,而不是让每个子任务都沿用主 Agent 的配置。
|
|
8
|
+
|
|
9
|
+
这个项目把两个概念明确分开:`gpt-5.6-luna` 是模型,`max` 是推理强度;本项目的桥接运行时会将这组配置传给 Codex CLI。这样做的目标是让用户可以对不同任务做有意识的模型路由,并据自己的任务、账号和运行环境测量成本、延迟与质量。它不承诺固定比例的省钱效果,也不保证所有 Codex 运行环境都开放该模型。
|
|
10
|
+
|
|
11
|
+
可以把任务流理解为:
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
主 Agent(负责规划、判断和整合)
|
|
15
|
+
├─ 复杂或高风险任务 ───────────────→ 主 Agent 使用的高能力模型
|
|
16
|
+
└─ 高频、边界清晰的子任务 ─────────→ gpt-5.6-luna + max
|
|
17
|
+
└─ 可选:本地队列与跨会话恢复
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 选择哪条路径
|
|
21
|
+
|
|
22
|
+
| 需求 | 推荐路径 |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| 普通拆解、代码审查、测试或资料整理 | Codex 原生子 Agent + 本项目提供的 Skill |
|
|
25
|
+
| 希望显式指定 `gpt-5.6-luna` 和 `max` | 外部桥接器(在运行环境允许时) |
|
|
26
|
+
| 需要跨 Codex 会话保存、恢复或接管任务 | 外部桥接器 |
|
|
27
|
+
| 只需要当前会话内的并发协作 | 优先使用 Codex 原生子 Agent |
|
|
28
|
+
|
|
29
|
+
原生子 Agent 由 Codex 运行环境负责调度,通常是最轻量的路径。外部桥接器是可选兼容层,不是 Codex 官方原生功能;它不能把原生子 Agent 的内部通道、侧边栏展示或生命周期承诺扩展到所有环境。
|
|
30
|
+
|
|
31
|
+
## 推荐路径:原生 Skill
|
|
32
|
+
|
|
33
|
+
这是普通任务拆解的默认入口。Skill 只提供拆解、并发、文件归属、消息交接和验证规则,不启动 Broker、不修改 PATH、不保存凭据,也不承诺跨会话持久化。
|
|
34
|
+
|
|
35
|
+
将 Skill 复制到用户级 Skill 目录(Windows PowerShell):
|
|
36
|
+
|
|
37
|
+
```powershell
|
|
38
|
+
$skillRoot = if ($env:CODEX_HOME) { Join-Path $env:CODEX_HOME 'skills' } else { Join-Path $env:USERPROFILE '.codex\skills' }
|
|
39
|
+
Copy-Item -Recurse -Force '.\packages\native-luna-subagents' (Join-Path $skillRoot 'native-luna-subagents')
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
若运行环境支持用户级 Agent 配置,可以将模型和推理强度设为:
|
|
43
|
+
|
|
44
|
+
```toml
|
|
45
|
+
[agents]
|
|
46
|
+
enabled = true
|
|
47
|
+
max_concurrent_threads_per_session = 4
|
|
48
|
+
default_subagent_model = "gpt-5.6-luna"
|
|
49
|
+
default_subagent_reasoning_effort = "max"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
模型是否可用、子 Agent 是否显示在侧边栏,以及会话关闭后的生命周期,仍由 Codex 运行环境决定;本项目不把它们包装成持久化保证。
|
|
53
|
+
|
|
54
|
+
## 可选路径:外部桥接器
|
|
55
|
+
|
|
56
|
+
只有在用户明确要求跨 Codex 会话保存、恢复或接管任务,或需要在本地运行时强制路由到 `gpt-5.6-luna` + `max` 时,才考虑安装外部桥接器。它要求 Windows 和 Python 3.12 或更高版本:
|
|
57
|
+
|
|
58
|
+
发布版本可直接从 PyPI 安装:
|
|
59
|
+
|
|
60
|
+
```powershell
|
|
61
|
+
python -m pip install luna-agent-bridge
|
|
62
|
+
luna-agent install
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
也可以从 [GitHub Releases](https://github.com/ZaviWayne/luna-agent-bridge/releases/latest) 下载 Windows 单文件 `luna-agent.exe`,无需配置 Python。下载后可用 `.\luna-agent.exe --help` 查看命令;首次使用外部桥接器前运行 `.\luna-agent.exe install`。
|
|
66
|
+
|
|
67
|
+
如果需要从源码开发或测试,再使用下面的可编辑安装方式:
|
|
68
|
+
|
|
69
|
+
```powershell
|
|
70
|
+
python -m venv .venv
|
|
71
|
+
.\.venv\Scripts\Activate.ps1
|
|
72
|
+
python -m pip install -e ".[dev]"
|
|
73
|
+
luna-agent install
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
激活成功后,当前 PowerShell 提示符会带有 `(.venv)`,后续可以直接使用 `luna-agent`。如果不希望激活虚拟环境,改用虚拟环境中的完整路径:
|
|
77
|
+
|
|
78
|
+
```powershell
|
|
79
|
+
.\.venv\Scripts\python.exe -m pip install -e ".[dev]"
|
|
80
|
+
.\.venv\Scripts\luna-agent.exe install
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
如果 PowerShell 阻止执行 `Activate.ps1`,可以在当前窗口临时放宽策略后重试,或直接使用上面的完整路径方式:
|
|
84
|
+
|
|
85
|
+
```powershell
|
|
86
|
+
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
常用命令:
|
|
90
|
+
|
|
91
|
+
以下命令假设虚拟环境已经激活;未激活时,请将命令前缀替换为 `.\.venv\Scripts\luna-agent.exe`。
|
|
92
|
+
|
|
93
|
+
```powershell
|
|
94
|
+
luna-agent spawn --name reviewer --cwd <workspace-path> --task "检查当前修改"
|
|
95
|
+
luna-agent status <agent-id>
|
|
96
|
+
luna-agent send <agent-id> "补充检查边界条件"
|
|
97
|
+
luna-agent wait <agent-id> --timeout 300
|
|
98
|
+
luna-agent result <agent-id>
|
|
99
|
+
luna-agent interrupt <agent-id>
|
|
100
|
+
luna-agent archive <agent-id>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
桥接器通过本地 Codex CLI 启动任务,并传递:
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
--model gpt-5.6-luna
|
|
107
|
+
--config model_reasoning_effort="max"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
本地状态默认保存到 `%LOCALAPPDATA%\CodexLunaAgent`,包括任务元数据、事件和恢复所需的队列状态。运行中的消息会排队到当前轮次边界,不能像原生内部通道一样即时注入模型生成过程。
|
|
111
|
+
|
|
112
|
+
用户准备关闭 Codex 时,必须先中断仍在运行的外部 Agent,再执行:
|
|
113
|
+
|
|
114
|
+
```powershell
|
|
115
|
+
luna-agent broker shutdown
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
不要假设关闭 Codex 会自动回收外部 Broker。普通卸载保留数据库;只有用户明确确认后才执行:
|
|
119
|
+
|
|
120
|
+
```powershell
|
|
121
|
+
luna-agent uninstall --purge-data --yes
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 能力边界
|
|
125
|
+
|
|
126
|
+
桥接器提供:
|
|
127
|
+
|
|
128
|
+
- 面向本地 Codex CLI 的显式模型与推理强度路由。
|
|
129
|
+
- SQLite 状态存储、任务事件、消息队列和恢复入口。
|
|
130
|
+
- 在工作区切换或重新打开 Codex 后,通过任务 ID 查询、发送、等待和接管。
|
|
131
|
+
- 最多 4 个本地 Worker,并在 Broker 关闭时停止其管理的进程。
|
|
132
|
+
|
|
133
|
+
桥接器不提供:
|
|
134
|
+
|
|
135
|
+
- Codex 官方原生子 Agent、官方侧边栏展示或官方生命周期保证。
|
|
136
|
+
- 绕过账号权限、模型可用性、沙箱或批准策略的能力。
|
|
137
|
+
- 固定的成本节省比例、固定延迟或跨账号的模型可用性承诺。
|
|
138
|
+
- 远程 TCP 控制;状态和控制面默认只在本机 Named Pipe 上工作。
|
|
139
|
+
|
|
140
|
+
## 插件入口
|
|
141
|
+
|
|
142
|
+
`plugins/luna-agent-bridge` 包含 `.codex-plugin/plugin.json` 和一个明确标注为“可选兼容层”的 Skill。它不会自动安装可执行文件、修改全局配置或添加个人 Marketplace 条目;请通过 Codex 的本地插件安装流程显式添加。
|
|
143
|
+
|
|
144
|
+
## 安全边界
|
|
145
|
+
|
|
146
|
+
- 不开放 TCP 远程控制。
|
|
147
|
+
- 不读取或保存 Codex 凭据。
|
|
148
|
+
- 不提供完全绕过沙箱的模式。
|
|
149
|
+
- Named Pipe、自动批准、用户数据目录和进程生命周期都属于外部桥接器的安全审查范围。
|
|
150
|
+
- 不要把外部桥接器或其跨会话恢复能力描述为 Codex 官方原生 Luna。
|
|
151
|
+
|
|
152
|
+
## 开发与测试
|
|
153
|
+
|
|
154
|
+
```powershell
|
|
155
|
+
.\.venv\Scripts\python.exe -m unittest discover -s tests -q
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`tests/fixtures` 中的 JSONL 文件是确定性的 Codex CLI 响应样本,用于在不访问网络、不消耗模型调用额度的情况下覆盖解析、事件和恢复逻辑;它们是测试输入,不会被打包到运行时。
|
|
159
|
+
|
|
160
|
+
发布前请移除 `.venv`、`build`、`dist`、`outputs`、`__pycache__` 和运行日志。Skill 与插件清单应通过对应的官方校验脚本。
|
|
161
|
+
|
|
162
|
+
项目采用 MIT License,详见 [LICENSE](LICENSE)。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# 安全策略
|
|
2
|
+
|
|
3
|
+
## 范围
|
|
4
|
+
|
|
5
|
+
原生 Skill 不执行外部进程,也不提供持久化服务。安全风险主要位于可选的 `luna-agent-bridge` 外部桥接器:它会启动本地 Codex CLI 子进程、使用 Windows Named Pipe,并将 Agent、消息、轮次和恢复状态写入用户数据目录。
|
|
6
|
+
|
|
7
|
+
## 当前边界
|
|
8
|
+
|
|
9
|
+
- 不开放 TCP 监听或远程控制端口。
|
|
10
|
+
- 不读取或保存 Codex 凭据。
|
|
11
|
+
- 桥接器默认使用 `workspace-write` 和 Codex CLI 的显式批准参数,不提供完全绕过沙箱的模式。
|
|
12
|
+
- `--purge-data --yes` 是显式的数据删除操作,普通卸载不应删除任务数据库。
|
|
13
|
+
- 用户关闭 Codex 前必须显式中断外部 Agent 并关闭 Broker;不能把外部桥接器当作原生生命周期管理。
|
|
14
|
+
|
|
15
|
+
## 报告漏洞
|
|
16
|
+
|
|
17
|
+
请不要在公开 Issue 中发布凭据、Named Pipe 细节、可执行载荷或可复现的本地提权步骤。先通过仓库维护者提供的私有渠道报告,并附上受影响版本、Windows/Python 版本、复现步骤和最小化日志。
|
|
18
|
+
|
|
19
|
+
在尚未配置专用安全邮箱前,维护者应在发布页提供私有报告渠道;安全修复发布前不公开利用细节。
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<!-- 已弃用:不要将本文件复制为全局 AGENTS.md;仅由显式执行 luna-agent install 的旧版外部桥接器使用。 -->
|
|
2
|
+
<!-- BEGIN CODEX LUNA AGENT BRIDGE -->
|
|
3
|
+
## Luna 子 Agent(旧版外部桥接)
|
|
4
|
+
|
|
5
|
+
仅当用户明确要求外部持久化时,使用用户级 `luna-agent` CLI;普通任务请使用 packages/native-luna-subagents。外部桥接默认使用 `gpt-5.6-luna`、`max`、`workspace-write`,最多 4 个并发 Agent。
|
|
6
|
+
|
|
7
|
+
跨工作区或跨主会话通信使用全局 Agent ID。CLI 通过显式 `--session` 或 Codex Desktop 的 `CODEX_THREAD_ID` 区分主会话;新主会话接管时必须保留 Agent ID。关闭 Codex 前先中断外部 Agent,再执行 `luna-agent broker shutdown`。
|
|
8
|
+
<!-- END CODEX LUNA AGENT BRIDGE -->
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: luna-agent-bridge-legacy
|
|
3
|
+
description: 已弃用的外部桥接 Skill,仅供用户明确安装旧版 luna-agent CLI 时使用;普通任务请使用 packages/native-luna-subagents。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Luna Agent Bridge(已弃用兼容入口)
|
|
7
|
+
|
|
8
|
+
<!--
|
|
9
|
+
本文件只服务于显式执行 `luna-agent install` 的旧版外部桥接器。
|
|
10
|
+
普通任务不得复制或启用本文件;请使用 packages/native-luna-subagents。
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
需要跨会话持久化的外部桥接任务时,使用用户级 `luna-agent` CLI,不要将其描述为 Codex 原生子 Agent。固定策略为 `gpt-5.6-luna`、`max`、`workspace-write`,最多四个并发 Agent。
|
|
14
|
+
|
|
15
|
+
常用命令:
|
|
16
|
+
|
|
17
|
+
```powershell
|
|
18
|
+
luna-agent spawn --name reviewer --cwd <workspace-path> --task "检查当前修改"
|
|
19
|
+
luna-agent send reviewer "重点检查事务边界"
|
|
20
|
+
luna-agent status reviewer
|
|
21
|
+
luna-agent list --all-sessions
|
|
22
|
+
luna-agent adopt <global-agent-id>
|
|
23
|
+
luna-agent wait reviewer --timeout 300
|
|
24
|
+
luna-agent result reviewer
|
|
25
|
+
luna-agent interrupt reviewer
|
|
26
|
+
luna-agent resume reviewer
|
|
27
|
+
luna-agent archive reviewer
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
会话隔离规则:CLI 优先使用显式 `--session`,其次使用 Codex Desktop 注入的 `CODEX_THREAD_ID`,没有会话上下文时使用 `standalone`。跨项目或跨主会话操作使用全局 Agent ID;新主会话接管时应在交接信息中保留该 Agent ID。
|
|
31
|
+
|
|
32
|
+
用户关闭 Codex 前必须先中断外部 Agent,再执行 `luna-agent broker shutdown`。消息会排队到轮次边界,不能在模型生成过程中即时注入。
|