Codex 开关(DeepSeek Harness 插件)
在 DeepSeek Harness 的输入框下方加一条控件:
显示 Codex 桌面版当前是否在运行,并直接重启或关闭它。不用再开任务管理器找 codex.exe。
● Codex 运行中 · 17 个进程 [重启] [关闭]
功能
- 状态:每 4 秒读一次 Codex 进程,显示运行中 / 未运行。
- 重启:先正常关窗(
CloseMainWindow),3.5 秒内没退就结束整个进程树,然后重新拉起 Codex。 - 关闭:需要点第二下「确认关闭」才执行,避免误点;同样先礼后兵。
- 智能体工具:
codex_control,参数action: status | stop | restart,和按钮走同一套 Host 逻辑, 所以也可以直接对智能体说「重启 Codex」。
安装
克隆或下载本仓库到本地,例如
D:\tools\dsh-codex-control。在 DSH 里让智能体把它装成 bundle:
plugin_manager install_bundle target: <仓库绝对路径>也可以手工写成一条
cordis.patch.yml的 row(包名@local/codex-control)。打开任意会话,输入框下方就会出现这条控件;没出现就刷新一下 Harness 页面。
要求:Windows 10/11、Windows PowerShell 5.1(系统自带)、Codex 桌面版(商店版自动识别,其他安装方式见下方 startExe)。
它怎么找到并控制 Codex
Windows 上的 Codex 桌面版通常是微软商店(MSIX)包 OpenAI.Codex_<商店 ID>,
装在 C:\Program Files\WindowsApps\OpenAI.Codex_<版本>_x64__<商店 ID>。
- 识别:
Get-AppxPackage OpenAI.Codex取安装目录;可执行文件路径在该目录下的进程,加上名为Codex.exe/codex.exe的进程,都算 Codex(实测主进程名可能是ChatGPT.exe,所以不能只靠进程名)。 - 关闭:对带窗口的主进程发
WM_CLOSE,等 3.5 秒;仍未退出的用taskkill /T /F结束进程树。 - 启动:
Get-StartApps取该包的 AppUserModelId(取不到就退回<包族名>!App),再用explorer.exe shell:AppsFolder\<AUMID>拉起——商店应用不能直接运行 exe,必须走这条激活路径。
配置(可选)
在 cordis.patch.yml 的那一行里加 config:
- insert:
- id: codex-control
name: '@local/codex-control'
config:
appName: OpenAI.Codex # 商店包名
startExe: '' # 非商店版:直接指定要启动的 exe
startTimeoutMs: 25000 # 启动后等待进程出现的上限(毫秒)
文件
| 文件 | 内容 |
|---|---|
index.js |
Host 半身:GET/POST /codex-control 路由、串行化操作、codex_control 工具 |
client.js |
Client 半身:conversation.composer.dock 里的一行控件,轮询状态、两次确认关闭 |
scripts/codex-probe.ps1 |
枚举 Codex 进程(安装目录 + 进程名) |
scripts/codex-stop.ps1 |
关窗 → 等待 → 强杀 |
scripts/codex-start.ps1 |
解析 AUMID 并激活应用 |
locale/*.json |
插件列表里的标题与说明 |
已知限制
- 仅 Windows;非 MSIX 安装需要配
startExe。 - 关闭会一并结束终端里的
codex.exe会话(和「完全退出 Codex」含义一致),Codex 里未保存的输入会丢失。 - 最坏情况一次关闭约 12 秒(3.5 秒等关窗 + 8 秒等强杀)。
- 页面通过本机 HTTP 路由轮询,不经过 DSH 的 Remote 通道;路由只监听本机,但同机进程都可访问。
License
MIT
English
A small row under the DSH composer that reports whether the Codex desktop app is running and offers restart and close.
The Host half exposes GET/POST /codex-control and a codex_control tool; the Client half polls that route from
conversation.composer.dock.
Windows only. The app is a Microsoft Store (MSIX) package here, so it is started through its AppUserModelId
(explorer.exe shell:AppsFolder\<AUMID>) and stopped by closing the window and, if needed, killing the process tree.
Install the directory as a DSH bundle with plugin_manager install_bundle target: <absolute repo path>.
No comments yet. Be the first to write one.