fix: harden imessage probe timeouts (#8662) (thanks @yudshj)

This commit is contained in:
Peter Steinberger
2026-02-04 03:25:39 -08:00
parent 09b6ea40f3
commit e085433fd0
5 changed files with 43 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ Docs: https://docs.openclaw.ai
### Fixes
- iMessage: add configurable probe timeout and raise defaults for SSH probe/RPC checks. (#8662) Thanks @yudshj.
- Telegram: honor session model overrides in inline model selection. (#8193) Thanks @gildo.
- Web UI: resolve header logo path when `gateway.controlUi.basePath` is set. (#7178) Thanks @Yeom-JinHo.
- Web UI: apply button styling to the new-messages indicator.

View File

@@ -190,6 +190,7 @@ Notes:
- Ensure the Mac is signed in to Messages, and Remote Login is enabled.
- Use SSH keys so `ssh bot@mac-mini.tailnet-1234.ts.net` works without prompts.
- `remoteHost` should match the SSH target so SCP can fetch attachments.
- If SSH probes time out, set `channels.imessage.probeTimeoutMs` (default: 10000).
Multi-account support: use `channels.imessage.accounts` with per-account config and optional `name`. See [`gateway/configuration`](/gateway/configuration#telegramaccounts--discordaccounts--slackaccounts--signalaccounts--imessageaccounts) for the shared pattern. Don't commit `~/.openclaw/openclaw.json` (it often contains tokens).

View File

@@ -370,6 +370,7 @@ const FIELD_LABELS: Record<string, string> = {
"channels.mattermost.requireMention": "Mattermost Require Mention",
"channels.signal.account": "Signal Account",
"channels.imessage.cliPath": "iMessage CLI Path",
"channels.imessage.probeTimeoutMs": "iMessage Probe Timeout (ms)",
"agents.list[].skills": "Agent Skill Filter",
"agents.list[].identity.avatar": "Agent Avatar",
"discovery.mdns.mode": "mDNS Discovery Mode",
@@ -679,6 +680,8 @@ const FIELD_HELP: Record<string, string> = {
"Allow Signal to write config in response to channel events/commands (default: true).",
"channels.imessage.configWrites":
"Allow iMessage to write config in response to channel events/commands (default: true).",
"channels.imessage.probeTimeoutMs":
"Timeout in ms for iMessage probe/RPC checks (default: 10000).",
"channels.msteams.configWrites":
"Allow Microsoft Teams to write config in response to channel events/commands (default: true).",
"channels.discord.commands.native": 'Override native commands for Discord (bool or "auto").',

View File

@@ -623,6 +623,7 @@ export const IMessageAccountSchemaBase = z
cliPath: ExecutableTokenSchema.optional(),
dbPath: z.string().optional(),
remoteHost: z.string().optional(),
probeTimeoutMs: z.number().int().positive().optional(),
service: z.union([z.literal("imessage"), z.literal("sms"), z.literal("auto")]).optional(),
region: z.string().optional(),
dmPolicy: DmPolicySchema.optional().default("pairing"),

View File

@@ -1,14 +1,18 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { probeIMessage } from "./probe.js";
const detectBinaryMock = vi.hoisted(() => vi.fn());
const runCommandWithTimeoutMock = vi.hoisted(() => vi.fn());
const createIMessageRpcClientMock = vi.hoisted(() => vi.fn());
const loadConfigMock = vi.hoisted(() => vi.fn());
vi.mock("../commands/onboard-helpers.js", () => ({
detectBinary: (...args: unknown[]) => detectBinaryMock(...args),
}));
vi.mock("../config/config.js", () => ({
loadConfig: (...args: unknown[]) => loadConfigMock(...args),
}));
vi.mock("../process/exec.js", () => ({
runCommandWithTimeout: (...args: unknown[]) => runCommandWithTimeoutMock(...args),
}));
@@ -18,6 +22,7 @@ vi.mock("./client.js", () => ({
}));
beforeEach(() => {
vi.resetModules();
detectBinaryMock.mockReset().mockResolvedValue(true);
runCommandWithTimeoutMock.mockReset().mockResolvedValue({
stdout: "",
@@ -27,14 +32,45 @@ beforeEach(() => {
killed: false,
});
createIMessageRpcClientMock.mockReset();
loadConfigMock.mockReset().mockReturnValue({});
});
describe("probeIMessage", () => {
it("marks unknown rpc subcommand as fatal", async () => {
const { probeIMessage } = await import("./probe.js");
const result = await probeIMessage(1000, { cliPath: "imsg" });
expect(result.ok).toBe(false);
expect(result.fatal).toBe(true);
expect(result.error).toMatch(/rpc/i);
expect(createIMessageRpcClientMock).not.toHaveBeenCalled();
});
it("uses config probeTimeoutMs when not explicitly provided", async () => {
const requestMock = vi.fn().mockResolvedValue({});
createIMessageRpcClientMock.mockResolvedValue({
request: requestMock,
stop: vi.fn().mockResolvedValue(undefined),
});
runCommandWithTimeoutMock.mockResolvedValue({
stdout: "",
stderr: "",
code: 0,
signal: null,
killed: false,
});
loadConfigMock.mockReturnValue({
channels: {
imessage: {
probeTimeoutMs: 15_000,
},
},
});
const { probeIMessage } = await import("./probe.js");
const result = await probeIMessage();
expect(result.ok).toBe(true);
expect(runCommandWithTimeoutMock).toHaveBeenCalledWith(["imsg", "rpc", "--help"], {
timeoutMs: 15_000,
});
expect(requestMock).toHaveBeenCalledWith("chats.list", { limit: 1 }, { timeoutMs: 15_000 });
});
});