Skip to content

Commit c3048fd

Browse files
committed
fix(cli): gate outbound factories by channel id
1 parent 2e1354c commit c3048fd

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/cli/deps.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { normalizeChannelId } from "../channels/registry.js";
12
import type { OutboundSendDeps } from "../infra/outbound/send-deps.js";
23
import { createLazyRuntimeSurface } from "../shared/lazy-runtime.js";
34
import type { CliDeps } from "./deps.types.js";
@@ -25,7 +26,6 @@ const NON_CHANNEL_DEP_KEYS = new Set([
2526
"cronConfig",
2627
"cronEnabled",
2728
"defaultAgentId",
28-
"discordVoice",
2929
"enqueueSystemEvent",
3030
"getQueueSize",
3131
"hasOwnProperty",
@@ -40,7 +40,6 @@ const NON_CHANNEL_DEP_KEYS = new Set([
4040
"runIsolatedAgentJob",
4141
"runtime",
4242
"sendCronFailureAlert",
43-
"sendDiscordVoice",
4443
"sessionStorePath",
4544
"storePath",
4645
"then",
@@ -49,6 +48,10 @@ const NON_CHANNEL_DEP_KEYS = new Set([
4948
"valueOf",
5049
]);
5150

51+
function resolveKnownChannelId(raw: string): string | undefined {
52+
return normalizeChannelId(raw) ?? undefined;
53+
}
54+
5255
// Per-channel module caches for lazy loading.
5356
const senderCache = new Map<string, Promise<RuntimeSend>>();
5457

@@ -102,7 +105,11 @@ export function createDefaultDeps(): CliDeps {
102105
if (existing !== undefined || NON_CHANNEL_DEP_KEYS.has(property)) {
103106
return existing;
104107
}
105-
const sender = resolveSender(property);
108+
const channelId = resolveKnownChannelId(property);
109+
if (!channelId) {
110+
return existing;
111+
}
112+
const sender = resolveSender(channelId);
106113
Reflect.set(target, property, sender, receiver);
107114
return sender;
108115
},

src/cli/outbound-send-mapping.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { normalizeChannelId } from "../channels/registry.js";
12
import {
23
resolveLegacyOutboundSendDepKeys,
34
type OutboundSendDeps,
@@ -18,8 +19,6 @@ export type CliOutboundSendSource = {
1819
[CLI_OUTBOUND_SEND_FACTORY]?: CliOutboundSendFactory;
1920
};
2021

21-
const NON_CHANNEL_OUTBOUND_KEYS = new Set(["discordVoice", "discordvoice", "sendDiscordVoice"]);
22-
2322
function normalizeLegacyChannelStem(raw: string): string {
2423
const normalized = normalizeLowercaseStringOrEmpty(
2524
raw
@@ -48,6 +47,10 @@ function resolveChannelIdFromLegacyOutboundKey(key: string): string | undefined
4847
return normalizedStem || undefined;
4948
}
5049

50+
function resolveKnownChannelId(raw: string): string | undefined {
51+
return normalizeChannelId(raw) ?? undefined;
52+
}
53+
5154
/**
5255
* Pass CLI send sources through as-is — both CliOutboundSendSource and
5356
* OutboundSendDeps are now channel-ID-keyed records.
@@ -84,17 +87,12 @@ export function createOutboundSendDepsFromCliSource(deps: CliOutboundSendSource)
8487
}
8588

8689
const resolveFactoryValue = (key: string): unknown => {
87-
if (NON_CHANNEL_OUTBOUND_KEYS.has(key)) {
88-
return undefined;
89-
}
90-
const channelId =
90+
const candidate =
9191
outbound[key] === undefined ? (resolveChannelIdFromLegacyOutboundKey(key) ?? key) : key;
92+
const channelId = resolveKnownChannelId(candidate);
9293
if (!channelId || channelId === "then" || channelId === "toJSON") {
9394
return undefined;
9495
}
95-
if (NON_CHANNEL_OUTBOUND_KEYS.has(channelId)) {
96-
return undefined;
97-
}
9896
const value = sendFactory(channelId);
9997
if (value !== undefined) {
10098
outbound[channelId] = value;

0 commit comments

Comments
 (0)