From 1b43d7144083079f737a893ede45c855dbb2fdbd Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 13 Jul 2026 22:35:26 +0800 Subject: [PATCH] refactor(channels): privatize approval channel list (#106447) --- scripts/deadcode-exports.baseline.mjs | 1 - src/utils/message-channel-constants.ts | 10 +++++----- src/utils/message-channel.test.ts | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/scripts/deadcode-exports.baseline.mjs b/scripts/deadcode-exports.baseline.mjs index 11dfba63f8ef..2fe24940a073 100644 --- a/scripts/deadcode-exports.baseline.mjs +++ b/scripts/deadcode-exports.baseline.mjs @@ -2226,7 +2226,6 @@ export const KNIP_UNUSED_EXPORT_BASELINE = [ "src/tui/tui-plugin-approvals.ts: parseTuiPluginApproval", "src/tui/tui-task-suggestions.ts: parseTuiTaskSuggestion", "src/tui/tui-waiting.ts: pickWaitingPhrase", - "src/utils/message-channel-constants.ts: NATIVE_APPROVAL_CHANNELS", "src/video-generation/runtime-types.ts: ListRuntimeVideoGenerationProvidersParams", "src/video-generation/runtime-types.ts: RuntimeVideoGenerationProvider", "src/web-search/runtime-types.ts: ListWebSearchProvidersParams", diff --git a/src/utils/message-channel-constants.ts b/src/utils/message-channel-constants.ts index 49acca3f17d5..95b1f07566fd 100644 --- a/src/utils/message-channel-constants.ts +++ b/src/utils/message-channel-constants.ts @@ -29,11 +29,11 @@ export function isInternalNonDeliveryChannel( // in place and the agent can wait inline for the result instead of falling // back to a fire-and-forget followup that loses the agent's session. // -// Keep this list aligned with bundled extensions that publish -// `approval-handler.runtime` and a `resolveApproveCommandBehavior` capability; -// adding an extension without the runtime, or listing one without the runtime, -// re-introduces the "approval loop" the inline path was added to avoid. -export const NATIVE_APPROVAL_CHANNELS = [ +// Keep this list aligned with bundled channels whose +// `approvalCapability.nativeRuntime` handles exec approvals; webchat is +// core-owned. Listing a channel without that runtime re-introduces the +// "approval loop" the inline path was added to avoid. +const NATIVE_APPROVAL_CHANNELS = [ "webchat", "discord", "googlechat", diff --git a/src/utils/message-channel.test.ts b/src/utils/message-channel.test.ts index cca401fddf7d..98b188ef200a 100644 --- a/src/utils/message-channel.test.ts +++ b/src/utils/message-channel.test.ts @@ -4,7 +4,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { ChannelPlugin } from "../channels/plugins/types.public.js"; import { setActivePluginRegistry } from "../plugins/runtime.js"; import { createChannelTestPluginBase, createTestRegistry } from "../test-utils/channel-plugins.js"; -import { NATIVE_APPROVAL_CHANNELS } from "./message-channel-constants.js"; import { isEphemeralGatewayClient, isInternalNonDeliveryChannel, @@ -93,10 +92,21 @@ describe("message-channel", () => { }); it("lists native chat exec approval channels", () => { - for (const channel of NATIVE_APPROVAL_CHANNELS) { + for (const channel of [ + "webchat", + "discord", + "googlechat", + "imessage", + "matrix", + "qqbot", + "signal", + "slack", + "telegram", + "whatsapp", + ]) { expect(isNativeApprovalChannel(channel)).toBe(true); } - // Channels without a bundled approval-handler.runtime must not claim native approval. + // Channels without a bundled exec-capable native approval runtime must not claim it. expect(isNativeApprovalChannel("feishu")).toBe(false); expect(isNativeApprovalChannel("msteams")).toBe(false); expect(isNativeApprovalChannel("line")).toBe(false);