refactor: isolate runtime contracts and enforce import boundaries (#6166)

* test: enforce Python import ownership boundaries

* test: protect client import boundaries and rehome shared UI contracts

* refactor: remove gateway and client dependency inversions

* fix: detect dynamic imports in conditional expressions

* refactor(tools): keep configuration contracts with their owners

* docs: keep design guidance focused on ownership and checks

* fix: preserve default threaded turn delivery
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-13 13:56:28 +08:00
1 parent cd2a863710
commit 328e933d36
162 files changed
+3449 -1888

No files matched your search

+1 -1
View File
@@ -20,7 +20,7 @@ from pydantic import Field
from nanobot.bus.events import OutboundMessage
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
from nanobot.security.network import validate_resolved_url, validate_url_target
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -19,7 +19,7 @@ from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.command.builtin import build_help_text
from nanobot.config.paths import get_media_dir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.utils.helpers import safe_filename, split_message
DISCORD_AVAILABLE = importlib.util.find_spec("discord") is not None
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -28,7 +28,7 @@ from nanobot.bus.outbound_events import ProgressEvent
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_media_dir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
from nanobot.utils.helpers import safe_filename
+1 -1
View File
@@ -4,7 +4,7 @@ import type { ChannelUiContribution } from "@/channel-plugins/types";
import {
type ChannelProviderPresetDefinition,
chatAppGuideUrl,
} from "@/components/settings/channels/catalog";
} from "@/channel-plugins/catalog";
const EMAIL_PROVIDER_PRESETS: ChannelProviderPresetDefinition[] = [
{
+1 -1
View File
@@ -4,7 +4,7 @@ from typing import Literal
from pydantic import Field
from nanobot.config.schema import Base
from nanobot.config_base import Base
class FeishuConfig(Base):
+1 -1
View File
@@ -1,7 +1,7 @@
import { lazy } from "react";
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
const FeishuAssistantsPanel = lazy(() =>
import("./FeishuAssistantsPanel").then(({ FeishuAssistantsPanel: component }) => ({
@@ -3,7 +3,7 @@ import { Loader2 } from "lucide-react";
import { useTranslation } from "react-i18next";
import { channelTranslator } from "@/channel-plugins/i18n";
import type { ChannelConfigField } from "@/components/settings/channels/catalog";
import type { ChannelConfigField } from "@/channel-plugins/catalog";
import { channelFieldInputId, defaultChannelFieldValues } from "@/components/settings/channels/CredentialForm";
import { Button } from "@/components/ui/button";
import {
@@ -3,7 +3,7 @@ import { Eye, EyeOff } from "lucide-react";
import { useTranslation } from "react-i18next";
import { channelTranslator } from "@/channel-plugins/i18n";
import type { ChannelConfigField } from "@/components/settings/channels/catalog";
import type { ChannelConfigField } from "@/channel-plugins/catalog";
import { channelFieldInputId } from "@/components/settings/channels/CredentialForm";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
+1 -1
View File
@@ -1,7 +1,7 @@
import { lazy } from "react";
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
import { LinearHelpContent } from "./LinearHelpContent";
+1 -1
View File
@@ -63,7 +63,7 @@ from nanobot.bus.outbound_events import ProgressEvent
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_data_dir, get_media_dir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
from nanobot.utils.helpers import safe_filename
from nanobot.utils.logging_bridge import redirect_lib_logging
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -19,7 +19,7 @@ from nanobot.bus.events import OutboundMessage
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_runtime_subdir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
try:
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -39,7 +39,7 @@ from nanobot.bus.events import OutboundMessage
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_workspace_path
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
MSTEAMS_AVAILABLE = (
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -23,7 +23,7 @@ from nanobot.bus.events import OutboundMessage
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_media_dir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
from nanobot.security.network import validate_url_target
from nanobot.utils.helpers import safe_filename
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+11
View File
@@ -21,3 +21,14 @@ def notification_metadata(channel: str, source: Mapping[str, Any]) -> dict[str,
fields = ("thread_ts",) if channel_type == "slack" else ("root_id", "thread_ts")
metadata[channel_type] = {key: nested[key] for key in fields if key in nested}
return deepcopy(metadata)
def system_reply_metadata(channel: str, session_key: str) -> dict[str, Any]:
"""Restore the thread address for an independently dispatched system reply."""
if (
channel == "slack"
and session_key.startswith("slack:")
and session_key.count(":") >= 2
):
return {"slack": {"thread_ts": session_key.split(":", 2)[2]}}
return {}
+1 -1
View File
@@ -41,7 +41,7 @@ from nanobot.bus.events import OutboundMessage
from nanobot.bus.outbound_events import ContextCompactionEvent
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.security.network import validate_url_target
from nanobot.utils.logging_bridge import redirect_lib_logging
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -22,7 +22,7 @@ from nanobot.bus.outbound_events import ProgressEvent
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_media_dir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
from nanobot.pairing import is_approved
from nanobot.utils.helpers import safe_filename, split_message
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -19,7 +19,7 @@ from nanobot.bus.outbound_events import ProgressEvent
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_media_dir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
from nanobot.pairing import is_approved
from nanobot.security.network import (
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
const SLACK_SOCKET_MODE_MANIFEST = `display_information:
name: nanobot
+1 -1
View File
@@ -35,7 +35,7 @@ from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.command.builtin import build_help_text
from nanobot.config.paths import get_media_dir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
from nanobot.security.network import validate_url_target
from nanobot.utils.helpers import split_message
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -28,7 +28,7 @@ from nanobot.bus.events import (
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.channels.websocket.binary_http import BinaryHTTPBridge
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.session.webui_turns import (
clear_websocket_turn_if_current,
mark_websocket_turn_transcript_persistence_failed,
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
import { WebSocketIcon } from "./WebSocketIcon";
+1 -1
View File
@@ -17,7 +17,7 @@ from nanobot.bus.outbound_events import ProgressEvent
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_media_dir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
WECOM_AVAILABLE = importlib.util.find_spec("wecom_aibot_sdk") is not None
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
export default {
presentation: {
+1 -1
View File
@@ -36,7 +36,7 @@ from nanobot.bus.outbound_events import ProgressEvent
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_media_dir, get_runtime_subdir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
from nanobot.utils.logging_bridge import redirect_lib_logging
@@ -7,7 +7,7 @@ import { channelLocaleMessages } from "@/channel-plugins/locale-registry";
import type { ChannelPluginPanelProps } from "@/channel-plugins/types";
import {
type ChannelConfigField,
} from "@/components/settings/channels/catalog";
} from "@/channel-plugins/catalog";
import {
CredentialForm,
channelValuesForSave,
+1 -1
View File
@@ -1,7 +1,7 @@
import { lazy } from "react";
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
import {
WEIXIN_ADVANCED_FIELD_KEYS,
+2
View File
@@ -32,6 +32,8 @@ PLUGIN = ChannelPlugin(
management=ChannelManagementSpec(local_state_present=local_state_present),
dependencies=(
"neonize>=0.4.3.post0,<0.5.0",
"python-magic>=0.4.27; sys_platform != 'win32'",
"python-magic-bin>=0.4.14; sys_platform == 'win32'",
"segno>=1.6.1,<2.0.0",
),
webui="webui/index.tsx",
+1 -1
View File
@@ -22,7 +22,7 @@ from nanobot.bus.events import OutboundMessage
from nanobot.bus.queue import MessageBus
from nanobot.channels.base import BaseChannel
from nanobot.config.paths import get_media_dir, get_runtime_subdir
from nanobot.config.schema import Base
from nanobot.config_base import Base
from nanobot.events import ContextCompactionEvent
from nanobot.security.network import PinnedDNSAsyncTransport
+1 -1
View File
@@ -1,7 +1,7 @@
import { MessageCircle } from "lucide-react";
import type { ChannelUiContribution } from "@/channel-plugins/types";
import { chatAppGuideUrl } from "@/components/settings/channels/catalog";
import { chatAppGuideUrl } from "@/channel-plugins/catalog";
import { WhatsAppConnectFlow } from "./WhatsAppConnectFlow";