Google Chat: lazy-load runtime-heavy channel paths

This commit is contained in:
Vincent Koc
2026-03-15 18:01:04 -07:00
parent 66a8c257b9
commit ae6ee73097
2 changed files with 14 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
export { probeGoogleChat, sendGoogleChatMessage, uploadGoogleChatAttachment } from "./api.js";
export { resolveGoogleChatWebhookPath, startGoogleChatMonitor } from "./monitor.js";

View File

@@ -34,8 +34,6 @@ import {
type ResolvedGoogleChatAccount,
} from "./accounts.js";
import { googlechatMessageActions } from "./actions.js";
import { sendGoogleChatMessage, uploadGoogleChatAttachment, probeGoogleChat } from "./api.js";
import { resolveGoogleChatWebhookPath, startGoogleChatMonitor } from "./monitor.js";
import { getGoogleChatRuntime } from "./runtime.js";
import { googlechatSetupAdapter, googlechatSetupWizard } from "./setup-surface.js";
import {
@@ -47,6 +45,10 @@ import {
const meta = getChatChannelMeta("googlechat");
async function loadGoogleChatChannelRuntime() {
return await import("./channel.runtime.js");
}
const formatAllowFromEntry = (entry: string) =>
entry
.trim()
@@ -145,6 +147,7 @@ export const googlechatPlugin: ChannelPlugin<ResolvedGoogleChatAccount> = {
const user = normalizeGoogleChatTarget(id) ?? id;
const target = isGoogleChatUserTarget(user) ? user : `users/${user}`;
const space = await resolveGoogleChatOutboundSpace({ account, target });
const { sendGoogleChatMessage } = await loadGoogleChatChannelRuntime();
await sendGoogleChatMessage({
account,
space,
@@ -300,6 +303,7 @@ export const googlechatPlugin: ChannelPlugin<ResolvedGoogleChatAccount> = {
});
const space = await resolveGoogleChatOutboundSpace({ account, target: to });
const thread = (threadId ?? replyToId ?? undefined) as string | undefined;
const { sendGoogleChatMessage } = await loadGoogleChatChannelRuntime();
const result = await sendGoogleChatMessage({
account,
space,
@@ -353,6 +357,8 @@ export const googlechatPlugin: ChannelPlugin<ResolvedGoogleChatAccount> = {
maxBytes: effectiveMaxBytes,
localRoots: mediaLocalRoots?.length ? mediaLocalRoots : undefined,
});
const { sendGoogleChatMessage, uploadGoogleChatAttachment } =
await loadGoogleChatChannelRuntime();
const upload = await uploadGoogleChatAttachment({
account,
space,
@@ -421,7 +427,8 @@ export const googlechatPlugin: ChannelPlugin<ResolvedGoogleChatAccount> = {
webhookPath: snapshot.webhookPath ?? null,
webhookUrl: snapshot.webhookUrl ?? null,
}),
probeAccount: async ({ account }) => probeGoogleChat(account),
probeAccount: async ({ account }) =>
(await loadGoogleChatChannelRuntime()).probeGoogleChat(account),
buildAccountSnapshot: ({ account, runtime, probe }) => {
const base = buildComputedAccountStatusSnapshot({
accountId: account.accountId,
@@ -450,6 +457,8 @@ export const googlechatPlugin: ChannelPlugin<ResolvedGoogleChatAccount> = {
setStatus: ctx.setStatus,
});
ctx.log?.info(`[${account.accountId}] starting Google Chat webhook`);
const { resolveGoogleChatWebhookPath, startGoogleChatMonitor } =
await loadGoogleChatChannelRuntime();
statusSink({
running: true,
lastStartAt: Date.now(),