repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
QwenPaw | src/qwenpaw/app/channels/command_registry.py | .py | # -*- coding: utf-8 -*-
"""Command registry for priority-based message routing.
This module provides a centralized command registration system that maps
commands to priority levels. It supports flexible priority assignment
with 0/10/20/30 intervals for extensibility.
Example:
>>> registry = CommandRegistry()
... | 291 | 9,895 |
QwenPaw | src/qwenpaw/app/channels/schema.py | .py | # -*- coding: utf-8 -*-
"""
Channel schema: channel type identifiers, routing (ChannelAddress),
and conversion protocol.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Dict, Optional, Protocol, runtime_checkable
@dataclass
class ChannelAddress:
"""
Unified ro... | 74 | 1,919 |
QwenPaw | src/qwenpaw/app/channels/conflict.py | .py | # -*- coding: utf-8 -*-
"""Helpers for detecting duplicate Bot identities across channels."""
from __future__ import annotations
from collections.abc import Mapping
from typing import Any, Optional
_CHANNEL_IDENTITY_FIELDS: dict[str, tuple[str, ...]] = {
"discord": ("bot_token",),
"telegram": ("bot_token",)... | 76 | 2,114 |
QwenPaw | src/qwenpaw/app/channels/base.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-branches,too-many-statements,unused-argument
# pylint: disable=too-many-public-methods,unnecessary-pass
"""
Base Channel: bound to AgentRequest/AgentResponse, unified by process.
"""
from __future__ import annotations
import asyncio
import json
import logging
import t... | 2,273 | 80,775 |
QwenPaw | src/qwenpaw/app/channels/wecom/utils.py | .py | # -*- coding: utf-8 -*-
"""WeCom channel utilities."""
from __future__ import annotations
import io
import logging
import re
from pathlib import Path
from typing import List, Tuple
logger = logging.getLogger(__name__)
# WeCom image upload limit (2MB), use 1.9MB as safe threshold
_WECOM_IMAGE_MAX_SIZE = 1.9 * 1024 * ... | 222 | 7,105 |
QwenPaw | src/qwenpaw/app/channels/wecom/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-statements,too-many-branches
# pylint: disable=too-many-return-statements,too-many-instance-attributes
# pylint: disable=too-many-nested-blocks
# pylint: disable=protected-access # bypass SDK MessageHandler filter
# pylint: disable=broad-exception-caught
"""WeCom (Ent... | 1,688 | 61,601 |
QwenPaw | src/qwenpaw/app/channels/wecom/__init__.py | .py | # -*- coding: utf-8 -*-
"""WeCom (Enterprise WeChat) channel package."""
from .channel import WecomChannel
__all__ = ["WecomChannel"]
| 7 | 136 |
QwenPaw | src/qwenpaw/app/channels/wecom/cards/__init__.py | .py | # -*- coding: utf-8 -*-
"""WeCom interactive template-card subsystem.
* :mod:`.dispatcher` — routing-only ``WecomCardHandler``: matches
outbound ``message_type`` and inbound ``task_id`` prefixes against
registered card kinds.
* :mod:`.context` — shared helpers (meta/body extraction, session
context builder, s... | 22 | 851 |
QwenPaw | src/qwenpaw/app/channels/wecom/cards/context.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Shared helpers used by individual card kinds.
Covers WeCom-specific plumbing: extracting metadata / body text from
runtime ``Msg`` objects, building stateless routing context for
callbacks, and draining the active "🤔 Thinking..." stream before
sending a ca... | 125 | 3,978 |
QwenPaw | src/qwenpaw/app/channels/wecom/cards/dispatcher.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""WeCom interactive template-card dispatcher (routing-only).
Two lookup tables drive the dispatch:
* ``_by_message_type`` — outbound: ``metadata.message_type`` → ``render``.
* ``_by_task_id_prefix`` — inbound: ``task_id`` prefix → ``handle``.
Publi... | 201 | 6,463 |
QwenPaw | src/qwenpaw/app/channels/wecom/cards/tool_guard.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""WeCom tool-guard approval card (self-contained).
Builders + callback parser + outbound ``render`` + inbound ``handle``
all live here; the dispatcher reads the module-level metadata
(``NAME`` / ``MESSAGE_TYPE`` / ``TASK_ID_PREFIX``) plus ``render`` /
``handl... | 438 | 12,701 |
QwenPaw | src/qwenpaw/app/channels/dingtalk/utils.py | .py | # -*- coding: utf-8 -*-
"""DingTalk channel helpers (media suffix guess, etc.)."""
from pathlib import Path
from typing import Optional
# Magic bytes -> suffix for .file fallback (DingTalk URLs often return .file).
# AMR-NB voice: "#!AMR\n"
DINGTALK_MAGIC_SUFFIX: list[tuple[bytes, str]] = [
(b"%PDF", ".pdf"),
... | 34 | 979 |
QwenPaw | src/qwenpaw/app/channels/dingtalk/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-statements,too-many-branches
# pylint: disable=too-many-return-statements
"""DingTalk Channel.
The handler ACKs the DingTalk Stream callback immediately. All actual
replies are delivered asynchronously via sessionWebhook, AI Card streaming
updates, or Open API. The ba... | 3,724 | 137,769 |
QwenPaw | src/qwenpaw/app/channels/dingtalk/content_utils.py | .py | # -*- coding: utf-8 -*-
"""DingTalk content parsing and session helpers."""
from __future__ import annotations
import base64
import binascii
import re
from typing import Any, Optional
from urllib.parse import parse_qs, urlparse
from qwenpaw.schemas import (
AudioContent,
FileContent,
ImageContent,
Vi... | 146 | 4,267 |
QwenPaw | src/qwenpaw/app/channels/dingtalk/__init__.py | .py | # -*- coding: utf-8 -*-
"""DingTalk channel package."""
from .channel import DingTalkChannel
__all__ = ["DingTalkChannel"]
| 6 | 124 |
QwenPaw | src/qwenpaw/app/channels/dingtalk/markdown.py | .py | # -*- coding: utf-8 -*-
"""DingTalk Markdown normalization helpers."""
import re
def ensure_list_spacing(text: str) -> str:
"""
Ensure there is a blank line before numbered list items (e.g. "1. ..."),
to avoid DingTalk merging the list item into the previous paragraph and
breaking Markdown parsing.
... | 111 | 3,192 |
QwenPaw | src/qwenpaw/app/channels/dingtalk/constants.py | .py | # -*- coding: utf-8 -*-
"""DingTalk channel constants."""
# Token cache TTL (1 hour)
DINGTALK_TOKEN_TTL_SECONDS = 3600
# Short suffix length for session_id from conversation_id
DINGTALK_SESSION_ID_SUFFIX_LEN = 8
# DingTalk message type to runtime content type
DINGTALK_TYPE_MAPPING = {
"picture": "image",
"vo... | 19 | 548 |
QwenPaw | src/qwenpaw/app/channels/dingtalk/ai_card.py | .py | # -*- coding: utf-8 -*-
"""DingTalk AI Card helpers."""
from __future__ import annotations
import json
import time
from dataclasses import dataclass
from pathlib import Path
from typing import Dict, List
PROCESSING = "1"
INPUTING = "2"
FINISHED = "3"
FAILED = "5"
_TERMINAL_STATES = {FINISHED, FAILED}
@dataclass
cl... | 79 | 2,064 |
QwenPaw | src/qwenpaw/app/channels/dingtalk/handler.py | .py | # -*- coding: utf-8 -*-
"""DingTalk Stream callback handler: message -> native dict -> reply."""
from __future__ import annotations
import asyncio
import logging
from typing import Any, Callable, Dict, List, Optional
import dingtalk_stream
from dingtalk_stream import CallbackMessage, ChatbotMessage
from qwenpaw.sche... | 594 | 21,928 |
QwenPaw | src/qwenpaw/app/channels/slack/utils.py | .py | # -*- coding: utf-8 -*-
"""Slack channel utility functions.
Pure helpers with no side effects — string manipulation, session-id
generation, dedup-key construction, and light data extraction.
"""
from __future__ import annotations
import asyncio
import mimetypes
import os
from typing import Any, Dict, List, Optional,... | 227 | 6,415 |
QwenPaw | src/qwenpaw/app/channels/slack/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-statements,too-many-branches
# pylint: disable=too-many-return-statements,protected-access
"""Slack Channel — streaming via chat.update edits.
Streaming output uses the base class hook system:
on_streaming_start → chat.postMessage placeholder
on_streaming_del... | 902 | 31,044 |
QwenPaw | src/qwenpaw/app/channels/slack/format.py | .py | # -*- coding: utf-8 -*-
"""Slack mrkdwn formatting, escaping, and text chunking.
Slack uses a superset of Markdown called "mrkdwn". This module handles:
- Escaping unsafe characters while preserving Slack angle-bracket tokens
- Converting generic Markdown to Slack mrkdwn
- Splitting long messages at paragraph boundari... | 217 | 6,366 |
QwenPaw | src/qwenpaw/app/channels/slack/__init__.py | .py | # -*- coding: utf-8 -*-
"""Slack channel package."""
from .channel import SlackChannel
__all__ = ["SlackChannel"]
| 6 | 115 |
QwenPaw | src/qwenpaw/app/channels/slack/constants.py | .py | # -*- coding: utf-8 -*-
"""Slack channel constants."""
# ── Text Length Limits ──
# Maximum text length per Slack message (mrkdown)
SLACK_TEXT_LIMIT: int = 30000
# ── Duplicate Removal ──
# Deduplication window (seconds);
# messages with the same event_id within this window are considered duplicates
SLACK_DEDUP_WIN... | 49 | 1,428 |
QwenPaw | src/qwenpaw/app/channels/slack/sender.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Slack outbound message sender.
Handles text, image, and file delivery through the Slack Web API.
Text messages are formatted as mrkdwn and automatically split at
the 40,000-character limit. Image and file uploads use Slack's
``files.uploadV2`` (for simple ... | 531 | 16,700 |
QwenPaw | src/qwenpaw/app/channels/slack/handler.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access,unused-argument
"""Slack Socket Mode inbound event handler.
Registers callbacks on a ``slack_bolt.AsyncApp`` for ``message`` and
``app_mention`` events, converts Slack's native payload into a
unified ``native`` dict, and enqueues it for the processing pipeline... | 806 | 26,748 |
QwenPaw | src/qwenpaw/app/channels/wechat/utils.py | .py | # -*- coding: utf-8 -*-
"""WeChat iLink channel utilities."""
from __future__ import annotations
import base64
import secrets
from typing import Dict
def make_headers(bot_token: str = "") -> Dict[str, str]:
"""Build iLink API request headers.
X-WECHAT-UIN: base64(str(random_uint32)) — anti-replay, per requ... | 123 | 3,902 |
QwenPaw | src/qwenpaw/app/channels/wechat/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-statements,too-many-branches
# pylint: disable=too-many-return-statements,too-many-instance-attributes
"""WeChat (iLink Bot) Channel.
Uses the official WeChat iLink Bot HTTP API to receive and send messages.
Incoming messages are fetched via long-polling (getupdates);... | 1,824 | 68,907 |
QwenPaw | src/qwenpaw/app/channels/wechat/__init__.py | .py | # -*- coding: utf-8 -*-
"""WeChat (iLink Bot) channel package."""
from .channel import WeChatChannel
__all__ = ["WeChatChannel"]
| 7 | 131 |
QwenPaw | src/qwenpaw/app/channels/wechat/client.py | .py | # -*- coding: utf-8 -*-
"""iLink Bot HTTP client for WeChat (WeChat personal account Bot API).
All iLink API endpoints live under https://ilinkai.weixin.qq.com.
Protocol: HTTP/JSON, no third-party SDK required.
Authentication flow:
1. GET /ilink/bot/get_bot_qrcode?bot_type=3 → qrcode + qrcode_img_content
2. Poll GET... | 725 | 24,300 |
QwenPaw | src/qwenpaw/app/channels/yuanbao/media.py | .py | # -*- coding: utf-8 -*-
"""Yuanbao media upload: COS pre-signed upload via genUploadInfo API.
Flow:
1. Call /api/resource/genUploadInfo to get COS temporary credentials
2. PUT upload to Tencent COS with HMAC-SHA1 signature
3. Return the CDN resourceUrl for use in TIMImageElem / TIMFileElem
"""
from __future__ import ... | 478 | 13,786 |
QwenPaw | src/qwenpaw/app/channels/yuanbao/utils.py | .py | # -*- coding: utf-8 -*-
"""Yuanbao channel utilities for file handling and media operations."""
from __future__ import annotations
import logging
import mimetypes
import uuid
from pathlib import Path
from typing import Optional
import aiohttp
from .constants import MEDIA_MAX_BYTES
logger = logging.getLogger(__name... | 160 | 5,034 |
QwenPaw | src/qwenpaw/app/channels/yuanbao/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-instance-attributes
"""Yuanbao Channel: WebSocket-based bot messaging for Tencent Yuanbao.
Uses protobuf binary protocol over WebSocket with sign-token authentication.
Supports C2C (direct) and group chat with streaming output.
"""
from __future__ import annotations
... | 1,758 | 60,595 |
QwenPaw | src/qwenpaw/app/channels/yuanbao/__init__.py | .py | # -*- coding: utf-8 -*-
"""Yuanbao (元宝) channel module.
Tencent Yuanbao is an AI assistant platform with bot capabilities.
This module implements WebSocket-based channel support for C2C and group chat.
"""
from .channel import YuanbaoChannel
__all__ = [
"YuanbaoChannel",
]
| 13 | 285 |
QwenPaw | src/qwenpaw/app/channels/yuanbao/constants.py | .py | # -*- coding: utf-8 -*-
"""Yuanbao channel constants."""
# Default WebSocket gateway URL (binary protobuf protocol)
DEFAULT_WS_URL = "wss://bot-wss.yuanbao.tencent.com/wss/connection"
# Default API domain (REST endpoints for sign-token, media upload, etc.)
DEFAULT_API_DOMAIN = "bot.yuanbao.tencent.com"
# Sign-token ... | 66 | 1,866 |
QwenPaw | src/qwenpaw/app/channels/yuanbao/auth.py | .py | # -*- coding: utf-8 -*-
"""Yuanbao sign-token authentication.
Yuanbao bot gateway requires a token obtained via the sign-token REST API.
The token is then used for WebSocket AuthBind protobuf handshake.
"""
from __future__ import annotations
import asyncio
import hashlib
import hmac
import logging
import os
import t... | 273 | 8,944 |
QwenPaw | src/qwenpaw/app/channels/yuanbao/codec.py | .py | # -*- coding: utf-8 -*-
"""Protobuf codec for Yuanbao WebSocket protocol.
Uses protobufjs-compatible JSON descriptors (conn.json / biz.json)
to encode/decode the binary wire protocol without .proto compilation.
"""
import json
import logging
import random
import uuid
from pathlib import Path
from typing import Any, D... | 668 | 20,465 |
QwenPaw | src/qwenpaw/app/channels/console/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-branches,too-many-statements
"""Console Channel.
A lightweight channel that prints all agent responses to stdout.
Messages are sent to the agent via POST /api/console/chat. This channel
handles the **output** side: whenever a completed message event or a
proactive se... | 737 | 27,783 |
QwenPaw | src/qwenpaw/app/channels/console/__init__.py | .py | # -*- coding: utf-8 -*-
"""Console channel package."""
from .channel import ConsoleChannel
__all__ = ["ConsoleChannel"]
| 6 | 121 |
QwenPaw | src/qwenpaw/app/channels/voice/twiml.py | .py | # -*- coding: utf-8 -*-
"""TwiML generation helpers for the Voice channel."""
from __future__ import annotations
import xml.etree.ElementTree as ET
def build_conversation_relay_twiml(
ws_url: str,
*,
welcome_greeting: str = "Hi! How can I help you?",
tts_provider: str = "google",
tts_voice: str =... | 62 | 1,870 |
QwenPaw | src/qwenpaw/app/channels/voice/channel.py | .py | # -*- coding: utf-8 -*-
"""Voice Channel: Twilio ConversationRelay + Cloudflare Tunnel."""
from __future__ import annotations
import collections
import logging
import secrets
from typing import Any, Dict, Optional
from ..renderer import ChannelDisplayConfig
from ..base import BaseChannel, OnReplySent, ProcessHandler
... | 267 | 8,793 |
QwenPaw | src/qwenpaw/app/channels/voice/conversation_relay.py | .py | # -*- coding: utf-8 -*-
"""ConversationRelay WebSocket handler for a single call."""
from __future__ import annotations
import json
import logging
from typing import TYPE_CHECKING, Any
from fastapi import WebSocketDisconnect
from qwenpaw.schemas import (
ContentType,
MessageType,
RunStatus,
)
from .sess... | 289 | 9,760 |
QwenPaw | src/qwenpaw/app/channels/voice/__init__.py | .py | # -*- coding: utf-8 -*-
"""Voice channel: Twilio ConversationRelay + Cloudflare Tunnel."""
from .channel import VoiceChannel # noqa: F401
__all__ = ["VoiceChannel"]
| 7 | 168 |
QwenPaw | src/qwenpaw/app/channels/voice/twilio_manager.py | .py | # -*- coding: utf-8 -*-
"""Twilio API wrapper for the Voice channel."""
from __future__ import annotations
import asyncio
import logging
from functools import partial
logger = logging.getLogger(__name__)
class TwilioManager:
"""Async wrapper around the synchronous ``twilio`` Python SDK."""
def __init__(sel... | 58 | 1,762 |
QwenPaw | src/qwenpaw/app/channels/voice/session.py | .py | # -*- coding: utf-8 -*-
"""Call session management for the Voice channel."""
from __future__ import annotations
import logging
from dataclasses import dataclass
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from .conversation_relay import ConversationRelayHan... | 73 | 2,063 |
QwenPaw | src/qwenpaw/app/channels/telegram/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-branches
"""Telegram channel: Bot API with polling; receive/send via chat_id."""
from __future__ import annotations
import asyncio
import html
import logging
import re
import uuid
from pathlib import Path
from typing import Any, Dict, Optional, Union
from telegram i... | 1,594 | 56,657 |
QwenPaw | src/qwenpaw/app/channels/telegram/__init__.py | .py | # -*- coding: utf-8 -*-
"""Telegram channel package."""
from .channel import TelegramChannel
__all__ = ["TelegramChannel"]
| 6 | 124 |
QwenPaw | src/qwenpaw/app/channels/telegram/format_html.py | .py | # -*- coding: utf-8 -*-
"""Convert standard Markdown to Telegram-compatible HTML.
Telegram Bot API supports a subset of HTML tags:
<b>, <i>, <u>, <s>, <code>, <pre>, <a>, <tg-spoiler>, <blockquote>
Standard Markdown (as produced by LLMs) uses **bold**, *italic*, `code`,
```code blocks```, [links](url), > blockquote... | 194 | 6,440 |
QwenPaw | src/qwenpaw/app/channels/telegram/cards/__init__.py | .py | # -*- coding: utf-8 -*-
"""Telegram channel interactive card support (inline keyboard buttons)."""
from .dispatcher import CardKind, TelegramCardHandler
__all__ = ["TelegramCardHandler", "CardKind"]
| 6 | 200 |
QwenPaw | src/qwenpaw/app/channels/telegram/cards/context.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Shared helpers used by Telegram card kinds.
Covers extracting metadata / body text from runtime Msg objects and
building stateless routing context for button callbacks.
"""
from __future__ import annotations
import logging
from typing import Any, Dict, Opt... | 83 | 2,557 |
QwenPaw | src/qwenpaw/app/channels/telegram/cards/dispatcher.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Telegram interactive card dispatcher (routing-only).
Two lookup tables drive the dispatch:
* ``_by_message_type`` — outbound: message_type → render.
* ``_by_callback_data_prefix`` — inbound: prefix → handle.
Public entry-points (called by :class:`~..chan... | 164 | 4,730 |
QwenPaw | src/qwenpaw/app/channels/telegram/cards/tool_guard.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Telegram tool-guard approval card (inline keyboard buttons).
Uses Telegram's InlineKeyboardMarkup to send approve/deny buttons.
Inbound button clicks arrive as CallbackQuery updates.
Non-streaming: body text + inline keyboard in one message; after
approval... | 486 | 14,942 |
QwenPaw | src/qwenpaw/app/channels/feishu/utils.py | .py | # -*- coding: utf-8 -*-
"""Feishu channel helpers (session id, sender display, markdown, table)."""
import json
import re
from typing import Any, Dict, List, Optional
from .constants import FEISHU_SESSION_ID_SUFFIX_LEN
def short_session_id_from_full_id(full_id: str) -> str:
"""Use last N chars of full_id (chat_... | 486 | 15,572 |
QwenPaw | src/qwenpaw/app/channels/feishu/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-statements,too-many-branches,protected-access
# pylint: disable=too-many-return-statements,unused-argument
"""Feishu (Lark) Channel.
Uses lark-oapi (https://github.com/larksuite/oapi-sdk-python) WebSocket
long connection to receive events (no public IP). Sends via Ope... | 2,824 | 105,110 |
QwenPaw | src/qwenpaw/app/channels/feishu/card_handler.py | .py | # -*- coding: utf-8 -*-
"""Feishu interactive-card handler.
Dispatches all interactive-card work (both outbound rendering and
inbound ``card.action.trigger`` callbacks) for :class:`FeishuChannel`.
The lark_oapi SDK only allows **one** ``p2.card.action.trigger``
callback per dispatcher (see ``EventDispatcherHandlerBui... | 486 | 17,436 |
QwenPaw | src/qwenpaw/app/channels/feishu/__init__.py | .py | # -*- coding: utf-8 -*-
"""Feishu channel package."""
from .channel import FeishuChannel
__all__ = ["FeishuChannel"]
| 6 | 118 |
QwenPaw | src/qwenpaw/app/channels/feishu/constants.py | .py | # -*- coding: utf-8 -*-
"""Feishu channel constants."""
# Token cache: refresh 1 min before expire
FEISHU_TOKEN_REFRESH_BEFORE_SECONDS = 60
# Max size for Feishu file upload (30MB)
FEISHU_FILE_MAX_BYTES = 30 * 1024 * 1024
# Dedup cache max size
FEISHU_PROCESSED_IDS_MAX = 1000
# Nickname cache max size (open_id -> n... | 42 | 1,360 |
QwenPaw | src/qwenpaw/app/channels/feishu/card_templates.py | .py | # -*- coding: utf-8 -*-
"""Feishu interactive-card templates.
Pure, side-effect-free helpers that build card JSON payloads and parse
``card.action.trigger`` values. Grouped by card kind; when more card
kinds are added (e.g. poll, form), put their builders + parsers here.
Kept separate from :mod:`card_handler` so the ... | 239 | 7,612 |
QwenPaw | src/qwenpaw/app/channels/feishu/cards/__init__.py | .py | # -*- coding: utf-8 -*-
"""Feishu interactive card subsystem.
* :mod:`.dispatcher` — routing-only ``FeishuCardHandler``: matches
outbound ``message_type`` and inbound ``action_type`` against
registered card kinds.
* :mod:`.context` — shared helpers (meta/body extraction, session
context builder) used by indiv... | 21 | 795 |
QwenPaw | src/qwenpaw/app/channels/feishu/cards/context.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Shared helpers used by individual Feishu card kinds.
Covers extracting metadata / body text from runtime ``Msg`` objects and
building stateless routing context for card action callbacks.
"""
from __future__ import annotations
import logging
from typing imp... | 83 | 2,675 |
QwenPaw | src/qwenpaw/app/channels/feishu/cards/dispatcher.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Feishu interactive card dispatcher (routing-only).
Two lookup tables drive the dispatch:
* ``_by_message_type`` — outbound: ``metadata.message_type`` → ``render``.
* ``_by_action_type`` — inbound: button ``value.type`` → ``handle``.
Public entry-poi... | 195 | 6,454 |
QwenPaw | src/qwenpaw/app/channels/feishu/cards/tool_guard.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Feishu tool-guard approval card (self-contained).
Builders + callback parser + outbound ``render`` + inbound ``handle``
all live here; the dispatcher reads the module-level metadata
(``NAME`` / ``MESSAGE_TYPE`` / ``ACTION_TYPE``) plus ``render`` /
``handle`... | 447 | 13,883 |
QwenPaw | src/qwenpaw/app/channels/qq/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-branches,too-many-statements
"""QQ Channel.
QQ uses WebSocket for incoming events and HTTP API for replies.
No request-reply coupling: handler enqueues Incoming, consumer processes
and sends reply via send_c2c_message / send_channel_message /
send_group_message.
Rich ... | 2,319 | 74,256 |
QwenPaw | src/qwenpaw/app/channels/qq/__init__.py | .py | # -*- coding: utf-8 -*-
"""QQ channel package."""
from .channel import QQChannel
__all__ = ["QQChannel"]
| 6 | 106 |
QwenPaw | src/qwenpaw/app/channels/qq/cards/__init__.py | .py | # -*- coding: utf-8 -*-
"""QQ channel interactive card support."""
| 3 | 67 |
QwenPaw | src/qwenpaw/app/channels/qq/cards/context.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Shared helpers used by QQ card kinds.
Covers extracting metadata / body text from runtime Msg objects and
building stateless routing context for button callbacks.
"""
from __future__ import annotations
import logging
from typing import Any, Dict, Optional
... | 85 | 2,591 |
QwenPaw | src/qwenpaw/app/channels/qq/cards/dispatcher.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""QQ interactive card dispatcher (routing-only).
Two lookup tables drive the dispatch:
* ``_by_message_type`` — outbound: ``metadata.message_type`` → ``render``.
* ``_by_action_data_prefix`` — inbound: ``action.data`` prefix → ``handle``.
Public entry-... | 194 | 5,726 |
QwenPaw | src/qwenpaw/app/channels/qq/cards/tool_guard.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""QQ tool-guard approval card (keyboard buttons).
Uses QQ's markdown + keyboard mechanism to send approval buttons.
Inbound button clicks arrive as INTERACTION_CREATE WebSocket events.
QQ API refs:
https://bot.q.qq.com/wiki/develop/api-v2/server-inter/mess... | 561 | 16,451 |
QwenPaw | src/qwenpaw/app/channels/discord_/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-branches,too-many-statements
from __future__ import annotations
import os
import logging
import asyncio
import mimetypes
import re
import tempfile
from collections import deque
from pathlib import Path
from urllib.parse import urlparse
from typing import Any, Dict, Op... | 1,067 | 38,526 |
QwenPaw | src/qwenpaw/app/channels/discord_/__init__.py | .py | # -*- coding: utf-8 -*-
"""Discord channel package."""
from .channel import DiscordChannel
__all__ = ["DiscordChannel"]
| 6 | 121 |
QwenPaw | src/qwenpaw/app/channels/matrix/channel.py | .py | # -*- coding: utf-8 -*-
"""
MatrixChannel: QwenPaw BaseChannel implementation for Matrix (via matrix-nio).
"""
from __future__ import annotations
import asyncio
import html
import inspect
import io
import logging
import mimetypes
import os
import re
import time
import urllib.parse
from collections import OrderedDict... | 3,376 | 124,792 |
QwenPaw | src/qwenpaw/app/channels/matrix/__init__.py | .py | # -*- coding: utf-8 -*-
from .channel import MatrixChannel
__all__ = ["MatrixChannel"]
| 5 | 88 |
QwenPaw | src/qwenpaw/app/channels/sip/sip_client.py | .py | # -*- coding: utf-8 -*-
"""SIP outbound call management."""
from __future__ import annotations
import logging
logger = logging.getLogger(__name__)
FAILED_HANGUP_CAUSES = {
"NO_ANSWER",
"USER_BUSY",
"CALL_REJECTED",
"NO_USER_RESPONSE",
"NETWORK_OUT_OF_ORDER",
"DESTINATION_OUT_OF_ORDER",
"N... | 34 | 701 |
QwenPaw | src/qwenpaw/app/channels/sip/pyvoip_backend.py | .py | # -*- coding: utf-8 -*-
"""PyVoIP backend -- pure-Python SIP/RTP for local dev.
**Dev / local mode only.** Single-concurrency, no jitter
buffer, no NAT traversal.
"""
from __future__ import annotations
import asyncio
import logging
import time
from typing import Any, Optional
from .backend import CallEndedCallback,... | 249 | 7,449 |
QwenPaw | src/qwenpaw/app/channels/sip/__init__.py | .py | # -*- coding: utf-8 -*-
"""SIP voice channel -- dual-track architecture.
Two backend modes via ``SIPChannelConfig.sip_mode``:
* ``"dev"`` -- **PyVoIPBackend**: pure-Python pyVoIP.
* ``"livekit"`` -- **LiveKitBackend**: LiveKit SIP Server.
"""
from __future__ import annotations
import asyncio
import logging
impor... | 823 | 25,937 |
QwenPaw | src/qwenpaw/app/channels/sip/livekit_backend.py | .py | # -*- coding: utf-8 -*-
"""LiveKit backend -- production-grade SIP/RTP (event-driven).
Architecture::
SIP Phone -> LiveKit SIP Server (Go)
-> LiveKit Room (WebRTC)
-> This Backend (STT/TTS bridge)
The backend connects to a pre-configured room on startup and waits
for a SIP participant... | 449 | 14,079 |
QwenPaw | src/qwenpaw/app/channels/sip/mini_registrar.py | .py | # -*- coding: utf-8 -*-
"""Built-in SIP registrar for zero-config Dev mode.
A minimal SIP registrar + proxy (pure Python, zero dependencies)
that lets softphones register and call each other without an
external SIP server like Asterisk or FreeSWITCH.
Usage (embedded)::
registrar = MiniRegistrar(bind="127.0.0.1",... | 225 | 6,914 |
QwenPaw | src/qwenpaw/app/channels/sip/session.py | .py | # -*- coding: utf-8 -*-
"""Call session management for the SIP channel."""
from __future__ import annotations
import asyncio
import logging
from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import Any, Optional
logger = logging.getLogger(__name__)
@dataclass
class SIPCallS... | 92 | 2,235 |
QwenPaw | src/qwenpaw/app/channels/sip/stt_engine.py | .py | # -*- coding: utf-8 -*-
"""STT streaming abstraction for the SIP channel."""
from __future__ import annotations
import asyncio
import logging
import os
from typing import (
Any,
Awaitable,
Callable,
Optional,
Protocol,
runtime_checkable,
)
logger = logging.getLogger(__name__)
TranscriptCallba... | 153 | 4,222 |
QwenPaw | src/qwenpaw/app/channels/sip/_audioop_compat.py | .py | # -*- coding: utf-8 -*-
"""audioop compatibility polyfill for Python 3.13+.
The ``audioop`` module was removed in Python 3.13 (PEP 594).
This shim imports the built-in module when available (<=3.12)
and falls back to the ``audioop-lts`` package on 3.13+.
The module is injected into ``sys.modules["audioop"]`` so that
... | 31 | 938 |
QwenPaw | src/qwenpaw/app/channels/sip/stt_tts.py | .py | # -*- coding: utf-8 -*-
"""STT/TTS factory functions for the SIP voice channel."""
from __future__ import annotations
import asyncio
import logging
import os
import queue as thread_queue
import threading
from typing import AsyncIterator
from .stt_engine import AliyunSTTStream, STTStreamEngine
logger = logging.getLog... | 218 | 5,906 |
QwenPaw | src/qwenpaw/app/channels/sip/backend.py | .py | # -*- coding: utf-8 -*-
"""SipBackend Protocol -- abstraction for Dev / Production.
* **PyVoIPBackend** (``sip_mode="dev"``)
* **LiveKitBackend** (``sip_mode="livekit"``)
"""
from __future__ import annotations
import asyncio
from typing import (
Any,
Callable,
Coroutine,
Optional,
Protocol,
ru... | 55 | 1,081 |
QwenPaw | src/qwenpaw/app/channels/onebot/media.py | .py | # -*- coding: utf-8 -*-
"""Inbound media localization for the OneBot channel."""
from __future__ import annotations
import asyncio
import logging
import mimetypes
import os
import re
import urllib.parse
import uuid
from collections.abc import Awaitable, Callable
from pathlib import Path
from typing import Any
import... | 583 | 17,348 |
QwenPaw | src/qwenpaw/app/channels/onebot/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-branches,too-many-statements
"""OneBot v11 Channel.
Reverse WebSocket server for NapCat, go-cqhttp, Lagrange, or any
OneBot v11 implementation. Listens on a configurable port;
the OneBot client connects as a WebSocket client.
Message flow:
NapCat → reverse WS → pa... | 1,664 | 60,058 |
QwenPaw | src/qwenpaw/app/channels/onebot/__init__.py | .py | # -*- coding: utf-8 -*-
from .channel import OneBotChannel
__all__ = ["OneBotChannel"]
| 5 | 88 |
QwenPaw | src/qwenpaw/app/channels/xiaoyi/utils.py | .py | # -*- coding: utf-8 -*-
"""XiaoYi channel utilities for file handling."""
import mimetypes
from pathlib import Path
from typing import Optional
import aiohttp
async def download_file(
url: str,
media_dir: Path,
filename: str,
) -> Optional[str]:
"""Download file from URL to media_dir, return local p... | 54 | 1,555 |
QwenPaw | src/qwenpaw/app/channels/xiaoyi/channel.py | .py | # -*- coding: utf-8 -*-
"""XiaoYi Channel implementation.
XiaoYi uses A2A (Agent-to-Agent) protocol over dual WebSocket connections
(primary domain + backup IP) for redundancy.
"""
from __future__ import annotations
import asyncio
import json
import logging
import platform
import re
import time
import uuid
from coll... | 1,691 | 57,653 |
QwenPaw | src/qwenpaw/app/channels/xiaoyi/__init__.py | .py | # -*- coding: utf-8 -*-
"""XiaoYi channel module.
XiaoYi (小艺) is Huawei's voice assistant platform.
This module implements A2A (Agent-to-Agent) protocol support.
"""
from .channel import XiaoYiChannel
from .auth import generate_auth_headers
__all__ = [
"XiaoYiChannel",
"generate_auth_headers",
]
| 15 | 312 |
QwenPaw | src/qwenpaw/app/channels/xiaoyi/constants.py | .py | # -*- coding: utf-8 -*-
"""XiaoYi channel constants."""
# Default WebSocket URL
DEFAULT_WS_URL = "wss://hag.cloud.huawei.com/openclaw/v1/ws/link"
# Default backup WebSocket URL (IP direct)
DEFAULT_WS_URL_BACKUP = "wss://116.63.174.231/openclaw/v1/ws/link"
# Heartbeat interval (seconds)
HEARTBEAT_INTERVAL = 30
# Rec... | 26 | 673 |
QwenPaw | src/qwenpaw/app/channels/xiaoyi/auth.py | .py | # -*- coding: utf-8 -*-
"""
XiaoYi authentication using AK/SK mechanism.
"""
from __future__ import annotations
import base64
import hashlib
import hmac
import time
from typing import Dict
def generate_signature(sk: str, timestamp: str) -> str:
"""Generate HMAC-SHA256 signature.
Format: Base64(HMAC-SHA256(... | 51 | 1,131 |
QwenPaw | src/qwenpaw/app/channels/imessage/channel.py | .py | # -*- coding: utf-8 -*-
# pylint:disable=too-many-return-statements
from __future__ import annotations
import logging
import os
import time
import sqlite3
import subprocess
import threading
import shutil
import asyncio
import base64
import hashlib
from pathlib import Path
from typing import Any, Dict, Optional, List
... | 719 | 25,423 |
QwenPaw | src/qwenpaw/app/channels/imessage/__init__.py | .py | # -*- coding: utf-8 -*-
"""iMessage channel package."""
from .channel import IMessageChannel
__all__ = ["IMessageChannel"]
| 6 | 124 |
QwenPaw | src/qwenpaw/app/channels/mattermost/channel.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-instance-attributes,too-many-arguments
"""Mattermost channel: WebSocket event listener + REST API replies."""
from __future__ import annotations
import asyncio
import json
import logging
import re
import uuid
from collections import OrderedDict
from pathlib import Pat... | 1,107 | 40,818 |
QwenPaw | src/qwenpaw/app/channels/mattermost/__init__.py | .py | # -*- coding: utf-8 -*-
from .channel import MattermostChannel
__all__ = ["MattermostChannel"]
| 5 | 96 |
QwenPaw | src/qwenpaw/app/channels/mqtt/channel.py | .py | # -*- coding: utf-8 -*-
"""MQTT Channel for IoT devices and robots"""
from __future__ import annotations
import json
import uuid
import logging
import threading
from typing import Any, Dict, Optional, Union
import paho.mqtt.client as mqtt
from paho.mqtt import MQTTException
from qwenpaw.schemas import (
TextCont... | 511 | 17,535 |
QwenPaw | src/qwenpaw/app/channels/mqtt/__init__.py | .py | # -*- coding: utf-8 -*-
"""MQTT channel package."""
from .channel import MQTTChannel
__all__ = ["MQTTChannel"]
| 6 | 112 |
QwenPaw | src/qwenpaw/app/approvals/display.py | .py | # -*- coding: utf-8 -*-
"""Presentation helpers for approval records."""
from __future__ import annotations
from typing import Any
def approval_display_fields(pending: Any) -> dict[str, Any]:
"""Return UI-facing tool display metadata for one pending approval.
``is_generalized`` lets the console render the ... | 29 | 1,035 |
QwenPaw | src/qwenpaw/app/approvals/models.py | .py | # -*- coding: utf-8 -*-
"""Shared approval data models."""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any
@dataclass(frozen=True)
class ApprovalRequestSummary:
"""Generic approval summary for non-ToolGuard approval sources."""
source_type: str
name: s... | 20 | 467 |
QwenPaw | src/qwenpaw/app/approvals/__init__.py | .py | # -*- coding: utf-8 -*-
"""Approval service exports."""
from .service import (
ApprovalService,
PendingApproval,
get_approval_service,
)
from .models import ApprovalRequestSummary
__all__ = [
"ApprovalService",
"ApprovalRequestSummary",
"PendingApproval",
"get_approval_service",
]
| 17 | 312 |
QwenPaw | src/qwenpaw/app/approvals/driver_gate.py | .py | # -*- coding: utf-8 -*-
"""QwenPaw application approval gate for Driver policy."""
from __future__ import annotations
from ...constant import TOOL_GUARD_APPROVAL_TIMEOUT_SECONDS
from ...drivers.errors import (
ApprovalRequiredError,
DriverPermissionDeniedError,
)
from ...drivers.policy import DriverInvocation... | 120 | 4,412 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.