Files
openclaw/extensions/imessage/src/setup-surface.ts
2026-03-17 06:24:01 +00:00

48 lines
1.6 KiB
TypeScript

import { setSetupChannelEnabled, type ChannelSetupWizard } from "openclaw/plugin-sdk/setup";
import { detectBinary } from "../../../src/plugins/setup-binary.js";
import { listIMessageAccountIds, resolveIMessageAccount } from "./accounts.js";
import {
createIMessageCliPathTextInput,
imessageCompletionNote,
imessageDmPolicy,
imessageSetupAdapter,
imessageSetupStatusBase,
parseIMessageAllowFromEntries,
} from "./setup-core.js";
const channel = "imessage" as const;
export const imessageSetupWizard: ChannelSetupWizard = {
channel,
status: {
...imessageSetupStatusBase,
resolveStatusLines: async ({ cfg, configured }) => {
const cliPath = cfg.channels?.imessage?.cliPath ?? "imsg";
const cliDetected = await detectBinary(cliPath);
return [
`iMessage: ${configured ? "configured" : "needs setup"}`,
`imsg: ${cliDetected ? "found" : "missing"} (${cliPath})`,
];
},
resolveSelectionHint: async ({ cfg }) => {
const cliPath = cfg.channels?.imessage?.cliPath ?? "imsg";
return (await detectBinary(cliPath)) ? "imsg found" : "imsg missing";
},
resolveQuickstartScore: async ({ cfg }) => {
const cliPath = cfg.channels?.imessage?.cliPath ?? "imsg";
return (await detectBinary(cliPath)) ? 1 : 0;
},
},
credentials: [],
textInputs: [
createIMessageCliPathTextInput(async ({ currentValue }) => {
return !(await detectBinary(currentValue ?? "imsg"));
}),
],
completionNote: imessageCompletionNote,
dmPolicy: imessageDmPolicy,
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false),
};
export { imessageSetupAdapter, parseIMessageAllowFromEntries };