fix: honor imessage probe account config

This commit is contained in:
Tak Hoffman
2026-04-03 11:40:35 -05:00
parent b473e056a0
commit b63a175d3d
3 changed files with 54 additions and 4 deletions

View File

@@ -41,8 +41,15 @@ export async function notifyIMessageApproval(id: string): Promise<void> {
await sendMessageIMessage(id, PAIRING_APPROVED_MESSAGE);
}
export async function probeIMessageAccount(timeoutMs?: number) {
return await probeIMessage(timeoutMs);
export async function probeIMessageAccount(params?: {
timeoutMs?: number;
cliPath?: string;
dbPath?: string;
}) {
return await probeIMessage(params?.timeoutMs, {
cliPath: params?.cliPath,
dbPath: params?.dbPath,
});
}
export async function startIMessageGatewayAccount(

View File

@@ -193,8 +193,12 @@ export const imessagePlugin: ChannelPlugin<ResolvedIMessageAccount, IMessageProb
cliPath: snapshot.cliPath ?? null,
dbPath: snapshot.dbPath ?? null,
}),
probeAccount: async ({ timeoutMs }) =>
await (await loadIMessageChannelRuntime()).probeIMessageAccount(timeoutMs),
probeAccount: async ({ account, timeoutMs }) =>
await (await loadIMessageChannelRuntime()).probeIMessageAccount({
timeoutMs,
cliPath: account.config.cliPath,
dbPath: account.config.dbPath,
}),
resolveAccountSnapshot: ({ account, runtime }) => ({
accountId: account.accountId,
name: account.name,

View File

@@ -2,6 +2,8 @@ import * as processRuntime from "openclaw/plugin-sdk/process-runtime";
import * as setupRuntime from "openclaw/plugin-sdk/setup";
import { beforeEach, describe, expect, it, vi } from "vitest";
import * as clientModule from "./client.js";
import { imessagePlugin } from "./channel.js";
import * as channelRuntimeModule from "./channel.runtime.js";
import {
resolveIMessageGroupRequireMention,
resolveIMessageGroupToolPolicy,
@@ -260,4 +262,41 @@ describe("probeIMessage", () => {
expect(result.error).toMatch(/rpc/i);
expect(createIMessageRpcClientMock).not.toHaveBeenCalled();
});
it("status probe uses account-scoped cliPath and dbPath", async () => {
const probeAccount = imessagePlugin.status?.probeAccount;
if (!probeAccount) {
throw new Error("imessage status.probeAccount unavailable");
}
const probeSpy = vi.spyOn(channelRuntimeModule, "probeIMessageAccount").mockResolvedValue({
ok: true,
cliPath: "imsg-work",
dbPath: "/tmp/work-db",
} as Awaited<ReturnType<typeof channelRuntimeModule.probeIMessageAccount>>);
const cfg = {
channels: {
imessage: {
cliPath: "imsg-root",
dbPath: "/tmp/root-db",
accounts: {
work: {
cliPath: "imsg-work",
dbPath: "/tmp/work-db",
},
},
},
},
} as const;
const account = imessagePlugin.config.resolveAccount(cfg, "work");
await probeAccount({ account, cfg, timeoutMs: 2500 } as never);
expect(probeSpy).toHaveBeenCalledWith({
timeoutMs: 2500,
cliPath: "imsg-work",
dbPath: "/tmp/work-db",
});
});
});