@@ -15,7 +15,6 @@ import {
|
15 | 15 | } from "../../../packages/gateway-protocol/src/index.js"; |
16 | 16 | import { resolveSessionAgentId } from "../../agents/agent-scope.js"; |
17 | 17 | import { sendDurableMessageBatch } from "../../channels/message/runtime.js"; |
18 | | -import { normalizeMessageChannel } from "../../utils/message-channel.js"; |
19 | 18 | import { dispatchChannelMessageAction } from "../../channels/plugins/message-action-dispatch.js"; |
20 | 19 | import { createOutboundSendDeps } from "../../cli/deps.js"; |
21 | 20 | import { |
@@ -49,6 +48,7 @@ import {
|
49 | 48 | normalizeSessionKeyPreservingOpaquePeerIds, |
50 | 49 | parseThreadSessionSuffix, |
51 | 50 | } from "../../sessions/session-key-utils.js"; |
| 51 | +import { INTERNAL_MESSAGE_CHANNEL, normalizeMessageChannel } from "../../utils/message-channel.js"; |
52 | 52 | import { ADMIN_SCOPE } from "../operator-scopes.js"; |
53 | 53 | import { resolveGatewayPluginConfig } from "../runtime-plugin-config.js"; |
54 | 54 | import { formatForLog } from "../ws-log.js"; |
@@ -178,16 +178,15 @@ async function resolveRequestedChannel(params: {
|
178 | 178 | > { |
179 | 179 | const channelInput = readStringValue(params.requestChannel); |
180 | 180 | const normalizedChannel = channelInput ? normalizeMessageChannel(channelInput) : undefined; |
| 181 | +if (params.rejectWebchatAsInternalOnly && normalizedChannel === INTERNAL_MESSAGE_CHANNEL) { |
| 182 | +return { |
| 183 | +error: errorShape( |
| 184 | +ErrorCodes.INVALID_REQUEST, |
| 185 | +"unsupported channel: webchat (internal-only). Use `chat.send` for WebChat UI messages or choose a deliverable channel.", |
| 186 | +), |
| 187 | +}; |
| 188 | +} |
181 | 189 | if (channelInput && !normalizedChannel) { |
182 | | -const normalizedInput = normalizeOptionalLowercaseString(channelInput) ?? ""; |
183 | | -if (params.rejectWebchatAsInternalOnly && normalizedInput === "webchat") { |
184 | | -return { |
185 | | -error: errorShape( |
186 | | -ErrorCodes.INVALID_REQUEST, |
187 | | -"unsupported channel: webchat (internal-only). Use `chat.send` for WebChat UI messages or choose a deliverable channel.", |
188 | | -), |
189 | | -}; |
190 | | -} |
191 | 190 | return { |
192 | 191 | error: errorShape(ErrorCodes.INVALID_REQUEST, params.unsupportedMessage(channelInput)), |
193 | 192 | }; |
|