()
| 4262 | } |
| 4263 | |
| 4264 | async function quitCodexDesktopApp() { |
| 4265 | if (!await isCodexDesktopAppRunning()) { |
| 4266 | return { |
| 4267 | ok: true, |
| 4268 | summary: "Codex desktop already stopped", |
| 4269 | reply: "Codex 现在本来就是关闭的。" |
| 4270 | }; |
| 4271 | } |
| 4272 | |
| 4273 | const quota = await readLatestCodexQuotaSnapshot().catch(() => state.maintenance.codex.quota); |
| 4274 | if (quota) state.maintenance.codex.quota = quota; |
| 4275 | await runCommand("/usr/bin/osascript", ["-e", 'tell application "Codex" to quit'], { timeout: 12000, allowFailure: true }); |
| 4276 | await sleep(1800); |
| 4277 | const running = await isCodexDesktopAppRunning(); |
| 4278 | return { |
| 4279 | ok: !running, |
| 4280 | summary: running ? "Codex desktop quit pending" : "Codex desktop quit", |
| 4281 | reply: !running |
| 4282 | ? quota |
| 4283 | ? `Codex 已按应用退出。\n\n${formatCodexQuotaDetail("退出前额度快照:", quota)}` |
| 4284 | : "Codex 已按应用退出。" |
| 4285 | : "我已经发了退出指令,但它现在看起来还没完全退掉。" |
| 4286 | }; |
| 4287 | } |
| 4288 | |
| 4289 | function scheduleSystemSleep() { |
| 4290 | const child = spawn("/bin/zsh", ["-lc", "sleep 2; /usr/bin/osascript -e 'tell application \"System Events\" to sleep' >/dev/null 2>&1 || /usr/bin/pmset sleepnow >/dev/null 2>&1"], { |
no test coverage detected