


















@@ -42,6 +42,12 @@ type DiscordHealthAccount = {
4242configured: boolean;
4343};
444445+type IMessageHealthAccount = {
46+accountId: string;
47+enabled: boolean;
48+configured: boolean;
49+};
50+4551async function loadFreshHealthModulesForTest() {
4652vi.doMock("../config/config.js", () => ({
4753getRuntimeConfig: () => testConfig,
@@ -405,6 +411,43 @@ function createDiscordHealthPlugin(): HealthTestPlugin {
405411};
406412}
407413414+function createIMessageHealthPlugin(): HealthTestPlugin {
415+return {
416+ ...createChannelTestPluginBase({ id: "imessage", label: "iMessage" }),
417+config: {
418+listAccountIds: () => ["default"],
419+resolveAccount: (_cfg, accountId) => ({
420+accountId: accountId?.trim() || "default",
421+enabled: true,
422+configured: true,
423+}),
424+inspectAccount: (_cfg, accountId) => ({
425+accountId: accountId?.trim() || "default",
426+enabled: true,
427+configured: true,
428+}),
429+isEnabled: (account) => (account as IMessageHealthAccount).enabled,
430+isConfigured: (account) => (account as IMessageHealthAccount).configured,
431+},
432+status: {
433+buildChannelSummary: ({ snapshot }) => ({
434+accountId: snapshot.accountId,
435+configured: Boolean(snapshot.configured),
436+ ...(snapshot.probe && typeof snapshot.probe === "object" ? { probe: snapshot.probe } : {}),
437+}),
438+probeAccount: async () => ({
439+ok: false,
440+error:
441+"imsg cannot access /Users/alice/Library/Messages/chat.db. Grant Full Disk Access to the Gateway/launcher process and restart Gateway. privateApi=/tmp/openclaw/private.sock",
442+privateApi: {
443+rpcCommand: "imsg rpc --json",
444+diagnostics: "sensitive transport details",
445+},
446+}),
447+},
448+};
449+}
450+408451describe("getHealthSnapshot", () => {
409452beforeAll(async () => {
410453({
@@ -744,6 +787,75 @@ describe("getHealthSnapshot", () => {
744787expect(telegram.accounts?.default?.channelAccessToken).toBeUndefined();
745788});
746789790+it("keeps redacted failed probes in non-sensitive health snapshots", async () => {
791+healthPluginsForTest = [createIMessageHealthPlugin()];
792+testConfig = { channels: { imessage: { enabled: true } } };
793+testStore = {};
794+795+const snap = await getHealthSnapshot({
796+timeoutMs: 25,
797+includeSensitive: false,
798+});
799+const imessage = snap.channels.imessage as {
800+configured?: boolean;
801+probe?: {
802+ok?: boolean;
803+error?: string;
804+privateApi?: unknown;
805+};
806+accounts?: Record<
807+string,
808+{
809+probe?: {
810+ok?: boolean;
811+error?: string;
812+privateApi?: unknown;
813+};
814+}
815+>;
816+};
817+818+expect(imessage.configured).toBe(true);
819+expect(imessage.probe).toMatchObject({
820+ok: false,
821+error:
822+"imsg cannot access ~/Library/Messages/chat.db. Grant Full Disk Access to the Gateway/launcher process and restart Gateway.",
823+});
824+expect(imessage.probe?.privateApi).toBeUndefined();
825+expect(imessage.accounts?.default?.probe).toMatchObject({
826+ok: false,
827+error:
828+"imsg cannot access ~/Library/Messages/chat.db. Grant Full Disk Access to the Gateway/launcher process and restart Gateway.",
829+});
830+expect(imessage.accounts?.default?.probe?.privateApi).toBeUndefined();
831+});
832+833+it("omits generic failed probe errors from non-sensitive health snapshots", async () => {
834+testConfig = { channels: { telegram: { botToken: "bad-token" } } };
835+testStore = {};
836+vi.stubEnv("DISCORD_BOT_TOKEN", "");
837+vi.stubGlobal(
838+"fetch",
839+vi.fn(async () => {
840+throw new Error("network down with private diagnostic");
841+}),
842+);
843+844+const snap = await getHealthSnapshot({
845+timeoutMs: 25,
846+includeSensitive: false,
847+});
848+const telegram = snap.channels.telegram as {
849+configured?: boolean;
850+probe?: unknown;
851+accounts?: Record<string, { probe?: unknown }>;
852+};
853+854+expect(telegram.configured).toBe(true);
855+expect(telegram.probe).toBeUndefined();
856+expect(telegram.accounts?.default?.probe).toBeUndefined();
857+});
858+747859it("returns structured telegram probe errors", async () => {
748860testConfig = { channels: { telegram: { botToken: "bad-token" } } };
749861testStore = {};
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。