Skip to content

Commit 958a93b

Browse files
committed
fix: align release healthcheck with sdk workflow
1 parent ef76575 commit 958a93b

File tree

7 files changed

+87
-17
lines changed

7 files changed

+87
-17
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
env:
1919
BOT_TOKEN: "ci-bot-token"
2020
ALLOWED_USER_IDS: "1"
21+
CODEX_BACKEND: "sdk"
2122
CODEX_COMMAND: "node"
2223
CODEX_WORKDIR: "."
2324
WORKSPACE_ROOT: "."

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
env:
1818
BOT_TOKEN: "ci-bot-token"
1919
ALLOWED_USER_IDS: "1"
20+
CODEX_BACKEND: "sdk"
2021
CODEX_COMMAND: "node"
2122
CODEX_WORKDIR: "."
2223
WORKSPACE_ROOT: "."

docs/release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Manual checks:
3838
git checkout main
3939
git pull --ff-only
4040
BOT_TOKEN=dummy-token ALLOWED_USER_IDS=1 npm run release:check
41-
git tag v0.2.0
41+
git tag v0.2.1
4242
git push origin main --tags
4343
```
4444

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codex-telegram-claws",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "A super Telegram bot that securely orchestrates Codex via SDK or CLI/PTy streaming, MCP routing, and GitHub automation skills.",
55
"type": "module",
66
"main": "src/index.ts",

src/ops/healthcheck.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { spawn } from "node:child_process";
33
import path from "node:path";
44
import process from "node:process";
55
import type { AppConfig } from "../config.js";
6-
import { repairNodePtySpawnHelperPermissions } from "../runner/ptyPreflight.js";
6+
import {
7+
repairNodePtySpawnHelperPermissions,
8+
type ExecutablePermissionResult
9+
} from "../runner/ptyPreflight.js";
710
import { extractCodexExecResponse } from "../bot/formatter.js";
811
import { toErrorMessage } from "../lib/errors.js";
912

@@ -39,6 +42,7 @@ interface HealthcheckOptions {
3942
telegramLiveCheck?: boolean;
4043
codexLiveCheck?: boolean;
4144
codexLiveRunner?: (config: AppConfig) => Promise<CodexLiveCheckResult>;
45+
ptyHelperProbe?: () => ExecutablePermissionResult;
4246
}
4347

4448
interface TelegramGetMeResponse {
@@ -258,21 +262,30 @@ export async function runHealthcheck(
258262
)
259263
);
260264

261-
const ptyHelper = repairNodePtySpawnHelperPermissions();
262-
if (ptyHelper.error) {
263-
checks.push(
264-
makeCheck("node-pty helper", strict ? "fail" : "warn", ptyHelper.error)
265-
);
266-
} else if (ptyHelper.changed) {
265+
if (config.runner.backend === "sdk") {
267266
checks.push(
268-
makeCheck(
269-
"node-pty helper",
270-
"pass",
271-
`Repaired execute permissions: ${ptyHelper.path}`
272-
)
267+
makeCheck("node-pty helper", "pass", "Not required for sdk backend.")
273268
);
274269
} else {
275-
checks.push(makeCheck("node-pty helper", "pass", ptyHelper.path));
270+
const ptyHelperProbe =
271+
options.ptyHelperProbe || repairNodePtySpawnHelperPermissions;
272+
const ptyHelper = ptyHelperProbe();
273+
274+
if (ptyHelper.error) {
275+
checks.push(
276+
makeCheck("node-pty helper", strict ? "fail" : "warn", ptyHelper.error)
277+
);
278+
} else if (ptyHelper.changed) {
279+
checks.push(
280+
makeCheck(
281+
"node-pty helper",
282+
"pass",
283+
`Repaired execute permissions: ${ptyHelper.path}`
284+
)
285+
);
286+
} else {
287+
checks.push(makeCheck("node-pty helper", "pass", ptyHelper.path));
288+
}
276289
}
277290

278291
const liveTelegramCheck = Boolean(options.telegramLiveCheck);

tests/healthcheck.test.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,58 @@ test("runHealthcheck reports a failing live Codex probe when the backend check f
175175
true
176176
);
177177
});
178+
179+
test("runHealthcheck does not fail strict mode on sdk backend when node-pty helper is unavailable", async () => {
180+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "claws-health-"));
181+
const config = createConfig(root);
182+
183+
const result = await runHealthcheck(config, {
184+
env: process.env,
185+
strict: true,
186+
ptyHelperProbe: () => ({
187+
path: "",
188+
changed: false,
189+
executable: false,
190+
error: "missing helper"
191+
})
192+
});
193+
194+
assert.equal(result.ok, true);
195+
assert.equal(
196+
result.checks.some(
197+
(check) =>
198+
check.name === "node-pty helper" &&
199+
check.status === "pass" &&
200+
check.detail.includes("sdk backend")
201+
),
202+
true
203+
);
204+
});
205+
206+
test("runHealthcheck still fails strict mode on cli backend when node-pty helper is unavailable", async () => {
207+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "claws-health-"));
208+
const config = createConfig(root);
209+
config.runner.backend = "cli";
210+
211+
const result = await runHealthcheck(config, {
212+
env: process.env,
213+
strict: true,
214+
ptyHelperProbe: () => ({
215+
path: "",
216+
changed: false,
217+
executable: false,
218+
error: "missing helper"
219+
})
220+
});
221+
222+
assert.equal(result.ok, false);
223+
assert.equal(
224+
result.checks.some(
225+
(check) =>
226+
check.name === "node-pty helper" &&
227+
check.status === "fail" &&
228+
check.detail.includes("missing helper")
229+
),
230+
true
231+
);
232+
});

0 commit comments

Comments
 (0)