Files
openclaw/extensions/imessage/src/actions-rpc.ts
Peter Steinberger 71a33f07a9 fix(imessage): make SSH-backed sends and actions reliable (#121038)
* fix(imessage): harden remote Mac transport

Route SSH-backed iMessage actions through JSON-RPC, preserve remote database paths, and stage outbound files on the Messages Mac with bounded cleanup. Keep local action semantics intact while failing closed on ambiguous wrappers and surfacing the remaining imsg v0.13.4 limits.

* fix(imessage): remove test-only exports
2026-08-09 04:48:38 -07:00

39 lines
1.0 KiB
TypeScript

import { createIMessageRpcClient } from "./client.js";
export type IMessageActionTransportOptions = {
cliPath: string;
dbPath?: string;
remoteHost?: string;
timeoutMs?: number;
};
class IMessageRemoteUnsupportedError extends Error {
readonly code = "IMESSAGE_REMOTE_UNSUPPORTED";
constructor(message: string) {
super(message);
this.name = "IMessageRemoteUnsupportedError";
}
}
export function throwIMessageRemoteUnsupported(message: string): never {
throw new IMessageRemoteUnsupportedError(`iMessage Remote Mac limitation: ${message}`);
}
export async function requestIMessageActionRpc<T extends Record<string, unknown>>(
method: string,
params: Record<string, unknown>,
options: IMessageActionTransportOptions,
): Promise<T> {
const client = await createIMessageRpcClient({
cliPath: options.cliPath,
dbPath: options.dbPath,
remoteHost: options.remoteHost,
});
try {
return await client.request<T>(method, params, { timeoutMs: options.timeoutMs });
} finally {
await client.stop();
}
}