feat: add imessage rpc adapter

This commit is contained in:
Peter Steinberger
2026-01-02 01:19:13 +01:00
parent 3ee27a00c7
commit cbac34347b
23 changed files with 1451 additions and 15 deletions

33
src/imessage/probe.ts Normal file
View File

@@ -0,0 +1,33 @@
import { detectBinary } from "../commands/onboard-helpers.js";
import { loadConfig } from "../config/config.js";
import { createIMessageRpcClient } from "./client.js";
export type IMessageProbe = {
ok: boolean;
error?: string | null;
};
export async function probeIMessage(
timeoutMs = 2000,
): Promise<IMessageProbe> {
const cfg = loadConfig();
const cliPath = cfg.imessage?.cliPath?.trim() || "imsg";
const dbPath = cfg.imessage?.dbPath?.trim();
const detected = await detectBinary(cliPath);
if (!detected) {
return { ok: false, error: `imsg not found (${cliPath})` };
}
const client = await createIMessageRpcClient({
cliPath,
dbPath,
});
try {
await client.request("chats.list", { limit: 1 }, { timeoutMs });
return { ok: true };
} catch (err) {
return { ok: false, error: String(err) };
} finally {
await client.stop();
}
}