@@ -37,7 +37,6 @@ import {
3737} from "./channel-api.js" ;
3838import { IrcChannelConfigSchema } from "./config-schema.js" ;
3939import { collectIrcMutableAllowlistWarnings } from "./doctor.js" ;
40- import { monitorIrcProvider } from "./monitor.js" ;
4140import {
4241 normalizeIrcMessagingTarget ,
4342 looksLikeIrcTargetId ,
@@ -48,7 +47,6 @@ import { resolveIrcGroupMatch, resolveIrcRequireMention } from "./policy.js";
4847import { probeIrc } from "./probe.js" ;
4948import { getIrcRuntime } from "./runtime.js" ;
5049import { collectRuntimeConfigAssignments , secretTargetRegistryEntries } from "./secret-contract.js" ;
51- import { sendMessageIrc } from "./send.js" ;
5250import { ircSetupAdapter } from "./setup-core.js" ;
5351import { ircSetupWizard } from "./setup-surface.js" ;
5452import type { CoreConfig , IrcProbe } from "./types.js" ;
@@ -66,6 +64,15 @@ const meta = {
6664 markdownCapable : true ,
6765} ;
6866
67+ type IrcChannelRuntimeModule = typeof import ( "./channel-runtime.js" ) ;
68+
69+ let ircChannelRuntimePromise : Promise < IrcChannelRuntimeModule > | undefined ;
70+
71+ async function loadIrcChannelRuntime ( ) : Promise < IrcChannelRuntimeModule > {
72+ ircChannelRuntimePromise ??= import ( "./channel-runtime.js" ) ;
73+ return await ircChannelRuntimePromise ;
74+ }
75+
6976function normalizePairingTarget ( raw : string ) : string {
7077 const normalized = normalizeIrcAllowEntry ( raw ) ;
7178 if ( ! normalized ) {
@@ -325,6 +332,7 @@ export const ircPlugin: ChannelPlugin<ResolvedIrcAccount, IrcProbe> = createChat
325332 ctx . log ?. info (
326333 `[${ account . accountId } ] starting IRC provider (${ account . host } :${ account . port } ${ account . tls ? " tls" : "" } )` ,
327334 ) ;
335+ const { monitorIrcProvider } = await loadIrcChannelRuntime ( ) ;
328336 await runStoppablePassiveMonitor ( {
329337 abortSignal : ctx . abortSignal ,
330338 start : async ( ) =>
@@ -349,6 +357,7 @@ export const ircPlugin: ChannelPlugin<ResolvedIrcAccount, IrcProbe> = createChat
349357 if ( ! target ) {
350358 throw new Error ( `invalid IRC pairing id: ${ id } ` ) ;
351359 }
360+ const { sendMessageIrc } = await loadIrcChannelRuntime ( ) ;
352361 await sendMessageIrc ( target , message ) ;
353362 } ,
354363 } ,
@@ -367,18 +376,22 @@ export const ircPlugin: ChannelPlugin<ResolvedIrcAccount, IrcProbe> = createChat
367376 } ,
368377 attachedResults : {
369378 channel : "irc" ,
370- sendText : async ( { cfg, to, text, accountId, replyToId } ) =>
371- await sendMessageIrc ( to , text , {
379+ sendText : async ( { cfg, to, text, accountId, replyToId } ) => {
380+ const { sendMessageIrc } = await loadIrcChannelRuntime ( ) ;
381+ return await sendMessageIrc ( to , text , {
372382 cfg : cfg as CoreConfig ,
373383 accountId : accountId ?? undefined ,
374384 replyTo : replyToId ?? undefined ,
375- } ) ,
376- sendMedia : async ( { cfg, to, text, mediaUrl, accountId, replyToId } ) =>
377- await sendMessageIrc ( to , mediaUrl ? `${ text } \n\nAttachment: ${ mediaUrl } ` : text , {
385+ } ) ;
386+ } ,
387+ sendMedia : async ( { cfg, to, text, mediaUrl, accountId, replyToId } ) => {
388+ const { sendMessageIrc } = await loadIrcChannelRuntime ( ) ;
389+ return await sendMessageIrc ( to , mediaUrl ? `${ text } \n\nAttachment: ${ mediaUrl } ` : text , {
378390 cfg : cfg as CoreConfig ,
379391 accountId : accountId ?? undefined ,
380392 replyTo : replyToId ?? undefined ,
381- } ) ,
393+ } ) ;
394+ } ,
382395 } ,
383396 } ,
384397} ) ;
0 commit comments