refactor(cli): split outbound send deps

This commit is contained in:
Peter Steinberger
2026-01-17 05:04:40 +00:00
parent bc49c20434
commit 572e04d5fb
5 changed files with 30 additions and 4 deletions

View File

@@ -0,0 +1,23 @@
import type { OutboundSendDeps } from "../infra/outbound/deliver.js";
export type CliDeps = {
sendMessageWhatsApp: NonNullable<OutboundSendDeps["sendWhatsApp"]>;
sendMessageTelegram: NonNullable<OutboundSendDeps["sendTelegram"]>;
sendMessageDiscord: NonNullable<OutboundSendDeps["sendDiscord"]>;
sendMessageSlack: NonNullable<OutboundSendDeps["sendSlack"]>;
sendMessageSignal: NonNullable<OutboundSendDeps["sendSignal"]>;
sendMessageIMessage: NonNullable<OutboundSendDeps["sendIMessage"]>;
};
// Provider docking: extend this mapping when adding new outbound send deps.
export function createOutboundSendDeps(deps: CliDeps): OutboundSendDeps {
return {
sendWhatsApp: deps.sendMessageWhatsApp,
sendTelegram: deps.sendMessageTelegram,
sendDiscord: deps.sendMessageDiscord,
sendSlack: deps.sendMessageSlack,
sendSignal: deps.sendMessageSignal,
sendIMessage: deps.sendMessageIMessage,
};
}

View File

@@ -1,8 +1,7 @@
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
import type { ChannelOutboundTargetMode } from "../../channels/plugins/types.js";
import { DEFAULT_CHAT_CHANNEL } from "../../channels/registry.js";
import type { CliDeps } from "../../cli/deps.js";
import { createOutboundSendDeps } from "../../cli/deps.js";
import { createOutboundSendDeps, type CliDeps } from "../../cli/outbound-send-deps.js";
import type { ClawdbotConfig } from "../../config/config.js";
import type { SessionEntry } from "../../config/sessions.js";
import { deliverOutboundPayloads } from "../../infra/outbound/deliver.js";

View File

@@ -316,6 +316,10 @@ vi.mock("./doctor-state-migrations.js", () => ({
}),
}));
vi.mock("./doctor-update.js", () => ({
maybeOfferUpdateBeforeDoctor: vi.fn().mockResolvedValue({ handled: false }),
}));
describe("doctor command", () => {
it("warns when the state directory is missing", async () => {
readConfigFileSnapshot.mockResolvedValue({

View File

@@ -2,7 +2,7 @@ import {
CHANNEL_MESSAGE_ACTION_NAMES,
type ChannelMessageActionName,
} from "../channels/plugins/types.js";
import { createOutboundSendDeps, type CliDeps } from "../cli/deps.js";
import { createOutboundSendDeps, type CliDeps } from "../cli/outbound-send-deps.js";
import { withProgress } from "../cli/progress.js";
import { loadConfig } from "../config/config.js";
import type { OutboundSendDeps } from "../infra/outbound/deliver.js";

View File

@@ -29,7 +29,7 @@ import {
normalizeThinkLevel,
supportsXHighThinking,
} from "../../auto-reply/thinking.js";
import { createOutboundSendDeps, type CliDeps } from "../../cli/deps.js";
import { createOutboundSendDeps, type CliDeps } from "../../cli/outbound-send-deps.js";
import type { ClawdbotConfig } from "../../config/config.js";
import { resolveSessionTranscriptPath, updateSessionStore } from "../../config/sessions.js";
import type { AgentDefaultsConfig } from "../../config/types.js";