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/rate_limiter.py | .py | # -*- coding: utf-8 -*-
"""Rate limiting utilities for authentication endpoints."""
import time
from collections import defaultdict, deque
from typing import Dict, Deque
class LoginRateLimiter:
"""In-memory rate limiter for login attempts
to prevent brute-force attacks."""
def __init__(self):
# T... | 155 | 5,769 |
QwenPaw | src/qwenpaw/app/utils.py | .py | # -*- coding: utf-8 -*-
"""Utility functions for app routers."""
import asyncio
import logging
from pathlib import Path
from typing import TYPE_CHECKING
from fastapi import HTTPException
if TYPE_CHECKING:
from fastapi import Request
from .multi_agent_manager import MultiAgentManager
logger = logging.getLogg... | 157 | 4,840 |
QwenPaw | src/qwenpaw/app/workspace_registry.py | .py | # -*- coding: utf-8 -*-
"""WorkspaceRegistry — creates bootstrapped ``Workspace`` instances.
Extends ``MultiAgentManager`` with:
- ``app_services`` reference (cross-workspace shared)
- ``bootstrap_plugins_kwargs`` — the 5 built-in class lists discovered
once at lifespan startup, injected into each new Workspace
The... | 50 | 1,605 |
QwenPaw | src/qwenpaw/app/agent_config_watcher.py | .py | # -*- coding: utf-8 -*-
"""Watch agent.json and trigger a graceful workspace reload on change.
Delegates to ``MultiAgentManager.reload_agent`` so disk-edit reloads
go through the same atomic workspace swap as frontend saves and wait
for in-flight tasks. Only triggers when ``channels`` or ``heartbeat``
hashes change, s... | 219 | 7,346 |
QwenPaw | src/qwenpaw/app/multi_agent_manager.py | .py | # -*- coding: utf-8 -*-
"""MultiAgentManager: Manages multiple agent workspaces with lazy loading.
Provides centralized management for multiple Workspace objects,
including lazy loading, lifecycle management, and hot reloading.
"""
import asyncio
import logging
import time
from typing import Callable, Dict, Set
from... | 866 | 32,480 |
QwenPaw | src/qwenpaw/app/console_push_store.py | .py | # -*- coding: utf-8 -*-
"""In-memory store for console channel push messages (e.g. cron text).
Bounded: at most _MAX_MESSAGES kept; messages older than _MAX_AGE_SECONDS
are dropped when reading. Frontend dedupes by id and caps its seen set.
"""
from __future__ import annotations
import asyncio
import time
import uuid... | 97 | 2,804 |
QwenPaw | src/qwenpaw/app/task_tracker.py | .py | # -*- coding: utf-8 -*-
"""Task tracker for background runs: streaming, reconnect, multi-subscriber.
``run_key`` is typically ``ChatSpec.id`` (chat_id). Per run: task, queues,
event buffer. Reconnects get buffer replay + new events. Cleanup when task
completes.
"""
from __future__ import annotations
import asyncio
im... | 350 | 12,041 |
QwenPaw | src/qwenpaw/app/_app.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=redefined-outer-name,unused-argument
import asyncio
import hmac
import inspect
import mimetypes
import os
import sys
import time
from contextlib import asynccontextmanager, suppress
from pathlib import Path
from typing import Any
from fastapi import FastAPI, Header, HTTPExcept... | 926 | 34,600 |
QwenPaw | src/qwenpaw/app/driver_config_watcher.py | .py | # -*- coding: utf-8 -*-
"""Watch DriverCard files and hot-reload active Drivers.
This is the protocol-neutral successor to the old MCP-only config watcher.
Console/API saves already apply runtime updates directly. This watcher
preserves the manual-edit path for ``drivers/<protocol>/<name>.yaml`` files.
"""
from __fut... | 131 | 4,348 |
QwenPaw | src/qwenpaw/app/inbox_trace_store.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
import asyncio
import time
from datetime import datetime
from pathlib import Path
from typing import Any
from ..constant import WORKING_DIR
from ..utils.io_utils import (
read_json,
run_sync_io,
unlink_async,
write_json_atomic,
)
_TRACE_DIR =... | 230 | 5,948 |
QwenPaw | src/qwenpaw/app/agent_context.py | .py | # -*- coding: utf-8 -*-
"""Agent context utilities for multi-agent support.
Provides utilities to get the correct agent instance for each request.
"""
import asyncio
from contextvars import ContextVar
from contextlib import contextmanager
from pathlib import Path
from typing import Iterator
from typing import Optional... | 311 | 8,894 |
QwenPaw | src/qwenpaw/app/auth.py | .py | # -*- coding: utf-8 -*-
"""Authentication module: password hashing, JWT tokens, and FastAPI middleware.
Login is disabled by default and only enabled when the environment
variable ``QWENPAW_AUTH_ENABLED`` is set to a truthy value (``true``,
``1``, ``yes``). Credentials are created through a web-based
registration flo... | 781 | 24,709 |
QwenPaw | src/qwenpaw/app/inbox_store.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
import asyncio
import logging
import time
import uuid
from typing import Any
from ..constant import WORKING_DIR
from ..utils.io_utils import read_json, run_sync_io, write_json_atomic
logger = logging.getLogger(__name__)
_INBOX_PATH = WORKING_DIR / "inbox_ev... | 202 | 6,023 |
QwenPaw | src/qwenpaw/app/agent_startup.py | .py | # -*- coding: utf-8 -*-
"""Shared multi-agent startup state and configuration."""
from enum import Enum
class AgentStartupStatus(str, Enum):
"""Runtime status for one configured agent."""
DISABLED = "disabled"
PENDING = "pending"
STARTING = "starting"
RUNNING = "running"
FAILED = "failed"
| 15 | 318 |
QwenPaw | src/qwenpaw/app/_api_action_routes.py | .py | # -*- coding: utf-8 -*-
"""Auto-register HTTP routes and slash commands from ``@api_action``.
``register_http_routes`` scans every :class:`ManagerBase` subclass in a
:class:`ManagerRegistry` and creates FastAPI endpoints for actions whose
``methods`` include ``"http"``.
``collect_slash_specs_from_api_actions`` does t... | 246 | 7,983 |
QwenPaw | src/qwenpaw/app/migration.py | .py | # -*- coding: utf-8 -*-
"""Configuration migration utilities for multi-agent support.
Handles migration from legacy single-agent config to new multi-agent structure.
"""
import json
import logging
import shutil
from pathlib import Path
from ..agents.templates import (
DEFAULT_AGENT_TEMPLATE,
QA_AGENT_TEMPLATE... | 889 | 30,347 |
QwenPaw | src/qwenpaw/app/workspace/workspace.py | .py | # -*- coding: utf-8 -*-
"""Workspace: Encapsulates a complete independent agent runtime.
Each Workspace represents a standalone agent workspace with its own:
- ChannelManager (communication channels)
- BaseMemoryManager (conversation memory)
- DriverManager (external capability runtime, currently MCP)
- CronManager (s... | 656 | 22,517 |
QwenPaw | src/qwenpaw/app/workspace/workspace_plugins.py | .py | # -*- coding: utf-8 -*-
"""Per-workspace pluggable layer.
Holds the three per-workspace registries that ``Runtime.run()``
reads each request:
* :class:`SlashCommandRegistry` — slash dispatch
* :class:`HookRegistry` — 8-phase hook orchestration
* ``modes`` — list of :class:`AgentMode` insta... | 70 | 2,576 |
QwenPaw | src/qwenpaw/app/workspace/__init__.py | .py | # -*- coding: utf-8 -*-
"""Workspace module for agent lifecycle management.
This module provides unified workspace management including:
- Workspace: Single agent instance manager (with per-workspace plugins)
- WorkspacePlugins: Per-workspace pluggable registries
- ServiceManager: Component lifecycle orchestration
- S... | 21 | 624 |
QwenPaw | src/qwenpaw/app/workspace/service_manager.py | .py | # -*- coding: utf-8 -*-
"""Service management system for Workspace components.
Provides unified registration, lifecycle management, and dependency handling
for all workspace services (MemoryManager, ChatManager, etc.).
"""
from __future__ import annotations
import asyncio
import logging
import time
from dataclasses i... | 496 | 17,159 |
QwenPaw | src/qwenpaw/app/workspace/local_workspace.py | .py | # -*- coding: utf-8 -*-
"""QwenPawLocalWorkspace — routes tool management to ToolRegistry.
Subclasses AgentScope's :class:`LocalWorkspace` so that
:meth:`list_tools` returns QwenPaw's own tools (managed by
:class:`ToolRegistry`) instead of AgentScope's built-in six.
All tool consumers call ``list_tools()`` — the only... | 131 | 4,504 |
QwenPaw | src/qwenpaw/app/workspace/bootstrap_factory.py | .py | # -*- coding: utf-8 -*-
"""Unified Workspace bootstrap factory.
Shared by the web app lifespan and ACP server to eliminate duplicated
bootstrap logic that previously drifted independently.
"""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from ..workspa... | 163 | 5,390 |
QwenPaw | src/qwenpaw/app/workspace/service_factories.py | .py | # -*- coding: utf-8 -*-
"""Service factory functions for workspace components.
Factory functions are used by Workspace._register_services() to create
and initialize service components. Extracted from local functions to
improve testability and code organization.
"""
from typing import TYPE_CHECKING
import logging
if ... | 225 | 7,410 |
QwenPaw | src/qwenpaw/app/app_services/approval_coordinator.py | .py | # -*- coding: utf-8 -*-
"""Façade over the existing ``ApprovalService`` singleton.
A thin pass-through that lets callers use
``ctx.app_services.approval_coordinator`` *without* changing behavior.
The wrapper is the future seam where cross-workspace approval
orchestration will land.
"""
from __future__ import annotati... | 47 | 1,399 |
QwenPaw | src/qwenpaw/app/app_services/app_service_manager.py | .py | # -*- coding: utf-8 -*-
"""The single cross-workspace service container.
Strict whitelist of three fields (``task_tracker`` / ``tool_coordinator`` /
``approval_coordinator``). Adding any other field here is a contract
break — per-workspace state belongs on ``Workspace.service_manager`` /
``Workspace.plugins`` instead.... | 92 | 3,013 |
QwenPaw | src/qwenpaw/app/app_services/__init__.py | .py | # -*- coding: utf-8 -*-
"""Cross-workspace coordination services held by FastAPI lifespan.
The AppServiceManager is the ONLY cross-workspace container, and it is
*strictly* limited to three coordinators:
* ``task_tracker`` — observability for streaming runs
* ``tool_coordinator`` — HITL tool-call coordina... | 28 | 908 |
QwenPaw | src/qwenpaw/app/app_services/_builtin_tool_commands.py | .py | # -*- coding: utf-8 -*-
"""HITL slash commands for tool-call management.
Provides ``/tools``, ``/tool-bg``, and ``/tool-cancel`` as
:class:`CommandSpec` instances registered into the per-workspace
:class:`SlashCommandRegistry` via lifespan bootstrap.
"""
from __future__ import annotations
from typing import TYPE_CHE... | 169 | 4,679 |
QwenPaw | src/qwenpaw/app/crons/contracts.py | .py | # -*- coding: utf-8 -*-
"""Backend-neutral declarations for service-contributed cron jobs."""
from __future__ import annotations
from collections.abc import Awaitable, Callable
from dataclasses import dataclass
@dataclass(frozen=True)
class ServiceCronJob:
"""A cron job declared by a workspace service.
The ... | 22 | 610 |
QwenPaw | src/qwenpaw/app/crons/models.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
from datetime import datetime
from typing import Any, Dict, Literal, Optional
from pydantic import (
BaseModel,
ConfigDict,
Field,
model_validator,
)
from ..channels.schema import DEFAULT_CHANNEL
# -------------------------------------------... | 280 | 9,111 |
QwenPaw | src/qwenpaw/app/crons/manager.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
import asyncio
import logging
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from typing import Any, Dict, Literal, Optional, Union
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
from apscheduler.events import (
... | 876 | 32,453 |
QwenPaw | src/qwenpaw/app/crons/heartbeat.py | .py | # -*- coding: utf-8 -*-
"""
Heartbeat: run agent with HEARTBEAT.md as query at interval.
Uses config functions (get_heartbeat_config, get_heartbeat_query_path,
load_config) for paths and settings.
"""
from __future__ import annotations
import asyncio
import logging
import re
import uuid
from datetime import datetime, ... | 407 | 13,525 |
QwenPaw | src/qwenpaw/app/crons/executor.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
import asyncio
import logging
import uuid
from typing import Any, Dict
from ..inbox_trace_store import (
append_trace_from_session_delta,
create_trace,
finalize_trace,
read_session_messages,
)
from .models import CronJobSpec
from ...security.t... | 310 | 11,644 |
QwenPaw | src/qwenpaw/app/crons/api.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
import uuid
from fastapi import APIRouter, Depends, HTTPException, Query, Request
from qwenpaw.exceptions import ConfigurationException
from .manager import CronManager
from .models import (
CronDispatchTargetItem,
CronDispatchTargetsResponse,
Cro... | 201 | 6,038 |
QwenPaw | src/qwenpaw/app/crons/repo/json_repo.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
import asyncio
import json
import logging
import os
import shutil
import uuid
from pathlib import Path
from urllib.parse import quote
from .base import BaseJobRepository
from ..models import CronExecutionRecord, JobsFile
from ....utils.io_utils import (
r... | 325 | 9,883 |
QwenPaw | src/qwenpaw/app/crons/repo/base.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Optional
from ..models import CronExecutionRecord, CronJobSpec, JobsFile
class BaseJobRepository(ABC):
"""Abstract repository for cron job specs persistence."""
@abstractmethod
async def lo... | 80 | 2,411 |
QwenPaw | src/qwenpaw/app/routers/skills_stream.py | .py | # -*- coding: utf-8 -*-
# flake8: noqa: E501
"""
Streaming AI skill optimization API
"""
import json
import logging
from fastapi import APIRouter
from fastapi.responses import StreamingResponse
from pydantic import BaseModel, Field
from qwenpaw.exceptions import (
AppBaseException,
)
from ...agents.model_factory... | 259 | 7,716 |
QwenPaw | src/qwenpaw/app/routers/market.py | .py | # -*- coding: utf-8 -*-
"""Skill Market HTTP routes.
"""
from __future__ import annotations
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel, Field
from ...market import (
MarketResult,
MarketSearchError,
ProviderInfo,
list_categories,
list_providers,
search_market,... | 144 | 3,840 |
QwenPaw | src/qwenpaw/app/routers/approval.py | .py | # -*- coding: utf-8 -*-
"""Approval API endpoints for tool guard approvals."""
from __future__ import annotations
import logging
from typing import Optional
from fastapi import APIRouter, HTTPException, Request
from pydantic import BaseModel, Field
from ..approvals import get_approval_service
from ..approvals.displ... | 265 | 7,822 |
QwenPaw | src/qwenpaw/app/routers/voice.py | .py | # -*- coding: utf-8 -*-
"""Voice channel router.
Exports ``voice_router`` with Twilio-facing endpoints mounted at the app root:
``/voice/incoming``, ``/voice/ws``, ``/voice/status-callback``.
"""
from __future__ import annotations
import logging
from fastapi import (
APIRouter,
Depends,
Request,
Resp... | 184 | 6,104 |
QwenPaw | src/qwenpaw/app/routers/files.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
import os
from pathlib import Path
from urllib.parse import unquote
from fastapi import APIRouter, HTTPException
from starlette.responses import FileResponse
from qwenpaw.constant import WORKING_DIR
from qwenpaw.security.tool_guard.guardians.file_guardian imp... | 92 | 2,778 |
QwenPaw | src/qwenpaw/app/routers/workspace.py | .py | # -*- coding: utf-8 -*-
"""Workspace API – download / upload the entire WORKING_DIR as a zip.
Also includes agent file management, language settings, audio/transcription
configuration, running config, and system prompt files.
"""
from __future__ import annotations
import asyncio
import copy
import io
import json
imp... | 2,004 | 64,191 |
QwenPaw | src/qwenpaw/app/routers/pawapps.py | .py | # -*- coding: utf-8 -*-
"""PawApp API router - List, manage, and serve installed PawApps.
Delegates to the PluginRegistry for app listing. Any plugin with
``meta.pawapp`` fields is automatically recognized as a PawApp.
Falls back to scanning the plugins directory for ``plugin.json`` files
with ``meta.pawapp`` when the... | 280 | 9,719 |
QwenPaw | src/qwenpaw/app/routers/mcp.py | .py | # -*- coding: utf-8 -*-
"""API routes for MCP (Model Context Protocol) clients management."""
from __future__ import annotations
from typing import Any, Dict, List, Optional
from fastapi import APIRouter, Body, Path, Request
from pydantic import BaseModel, Field
from ..mcp.config_service import (
MCPConfigServi... | 252 | 7,144 |
QwenPaw | src/qwenpaw/app/routers/provider_oauth.py | .py | # -*- coding: utf-8 -*-
"""OAuth endpoints for provider one-click authentication."""
from __future__ import annotations
import logging
from typing import Optional
from fastapi import APIRouter, Depends, HTTPException, Request
from fastapi.responses import HTMLResponse
from pydantic import BaseModel, Field
from ...p... | 264 | 7,303 |
QwenPaw | src/qwenpaw/app/routers/tool_calls.py | .py | # -*- coding: utf-8 -*-
"""API routes for tool call lifecycle management."""
from __future__ import annotations
import asyncio
import json
from typing import Any
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import StreamingResponse
from pydantic import BaseModel, Field
router = APIRo... | 303 | 8,799 |
QwenPaw | src/qwenpaw/app/routers/agent_scoped.py | .py | # -*- coding: utf-8 -*-
"""Agent-scoped router that wraps existing routers under /agents/{agentId}/
This provides agent isolation by injecting agentId into request.state,
allowing downstream APIs to access the correct agent context.
"""
from fastapi import APIRouter, Request
from starlette.middleware.base import (
... | 111 | 4,206 |
QwenPaw | src/qwenpaw/app/routers/checkpoints.py | .py | # -*- coding: utf-8 -*-
"""Agent workspace checkpoint endpoints for the Console graph page."""
from __future__ import annotations
from dataclasses import asdict
import logging
from fastapi import APIRouter, HTTPException, Query, Request
from pydantic import BaseModel, Field
from ...checkpoints.models import (
C... | 302 | 9,255 |
QwenPaw | src/qwenpaw/app/routers/__init__.py | .py | # -*- coding: utf-8 -*-
"""API routers."""
from fastapi import APIRouter
from .agents import router as agents_router
from .config import router as config_router
from .local_models import router as local_models_router
from .providers import router as providers_router
from .market import router as market_router
from .s... | 87 | 3,246 |
QwenPaw | src/qwenpaw/app/routers/loops.py | .py | # -*- coding: utf-8 -*-
"""Loop discovery, catalog, and custom mode persistence APIs."""
from __future__ import annotations
import asyncio
import logging
from collections.abc import Callable
from types import SimpleNamespace
from typing import Any, Literal
from fastapi import APIRouter, HTTPException, Query, Request,... | 417 | 13,991 |
QwenPaw | src/qwenpaw/app/routers/mcp_oauth.py | .py | # -*- coding: utf-8 -*-
"""OAuth 2.1 authorization endpoints for remote MCP clients.
Implements RFC 8414 (Authorization Server Metadata), RFC 9728
(Protected Resource Metadata), and PKCE (RFC 7636) for interactive
browser-based OAuth flows triggered from the frontend.
"""
from __future__ import annotations
import ba... | 798 | 25,381 |
QwenPaw | src/qwenpaw/app/routers/access_control.py | .py | # -*- coding: utf-8 -*-
"""API router for channel access control (whitelist / blacklist / pending)."""
from __future__ import annotations
from pathlib import Path
from typing import Dict, List
from fastapi import APIRouter, HTTPException, Request
from pydantic import BaseModel, Field
from ..channels.access_control i... | 308 | 8,514 |
QwenPaw | src/qwenpaw/app/routers/agents.py | .py | # -*- coding: utf-8 -*-
"""Multi-agent management API.
Provides RESTful API for managing multiple agent instances.
"""
import json
import logging
import shutil
from pathlib import Path
from typing import Any, Literal
from fastapi import APIRouter, Body, HTTPException, Request
from fastapi import Path as PathParam
fro... | 1,326 | 41,498 |
QwenPaw | src/qwenpaw/app/routers/harnesses.py | .py | # -*- coding: utf-8 -*-
"""Third-party agent catalog and authentication endpoints."""
from __future__ import annotations
import asyncio
from typing import Any
from fastapi import APIRouter, HTTPException, Request
from pydantic import BaseModel, Field
from ..agent_context import get_agent_for_request
from ...harness... | 205 | 6,408 |
QwenPaw | src/qwenpaw/app/routers/console.py | .py | # -*- coding: utf-8 -*-
"""Console APIs: push messages, chat, and file upload for chat."""
from __future__ import annotations
import asyncio
import json
import logging
import re
import time
import uuid
from dataclasses import dataclass
from pathlib import Path
from typing import Any, AsyncGenerator, Dict, Optional, Un... | 925 | 29,977 |
QwenPaw | src/qwenpaw/app/routers/frontend_plugin.py | .py | # -*- coding: utf-8 -*-
"""Public-facing plugin endpoints for the frontend.
These routes are intentionally served without authentication so that
unauthenticated page loads (e.g. a customised login page) can fetch the
plugin list and load plugin JS/CSS bundles.
Only read operations are exposed here. All plugin manage... | 82 | 2,519 |
QwenPaw | src/qwenpaw/app/routers/auth.py | .py | # -*- coding: utf-8 -*-
"""Authentication API endpoints."""
from __future__ import annotations
from fastapi import APIRouter, HTTPException, Request
from pydantic import BaseModel
from ...constant import EnvVarLoader
from ..auth import (
authenticate,
has_registered_users,
is_auth_enabled,
register_us... | 326 | 9,662 |
QwenPaw | src/qwenpaw/app/routers/skills.py | .py | # -*- coding: utf-8 -*-
"""Workspace and skill-pool APIs."""
from __future__ import annotations
import asyncio
import copy
import json
import logging
import shutil
import tempfile
import threading
import time
import uuid
from enum import Enum
from pathlib import Path
from typing import Any
from fastapi import APIRou... | 1,861 | 59,777 |
QwenPaw | src/qwenpaw/app/routers/messages.py | .py | # -*- coding: utf-8 -*-
"""API router for sending messages to channels."""
from __future__ import annotations
import logging
from typing import Optional
from fastapi import APIRouter, Header, HTTPException, Request
from pydantic import BaseModel, ConfigDict, Field
from qwenpaw.exceptions import (
AppBaseExceptio... | 191 | 5,444 |
QwenPaw | src/qwenpaw/app/routers/git.py | .py | # -*- coding: utf-8 -*-
"""Git integration endpoints for Coding Mode.
All endpoints are mounted under ``/workspace/git/`` and operate on the
workspace directory resolved from the request (same agent-context pattern
used by other workspace routes).
Uses the shared command runner; no extra Python deps.
"""
from __futur... | 583 | 16,800 |
QwenPaw | src/qwenpaw/app/routers/project_directory.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-statements
"""Project directory management endpoints.
Allows users to set, clear, clone, create, and list project directorys
used by every agent mode.
All endpoints are mounted under ``/workspace/project-directory/``.
"""
from __future__ import annotations
import as... | 798 | 25,272 |
QwenPaw | src/qwenpaw/app/routers/backup.py | .py | # -*- coding: utf-8 -*-
"""Backup API – create, list, restore, delete, export, import."""
from __future__ import annotations
import json
import logging
import os
import tempfile
import time
from pathlib import Path
from fastapi import APIRouter, Form, HTTPException, Request, UploadFile, File
from fastapi.responses i... | 322 | 10,826 |
QwenPaw | src/qwenpaw/app/routers/plugins.py | .py | # -*- coding: utf-8 -*-
# pylint:disable=too-many-branches
"""Plugin API routes: list plugins with UI metadata and serve plugin
static files. Also provides runtime install / uninstall endpoints."""
import asyncio
import inspect
import json
import logging
import mimetypes
import re
import shutil
import tempfile
import... | 1,077 | 35,726 |
QwenPaw | src/qwenpaw/app/routers/settings.py | .py | # -*- coding: utf-8 -*-
"""Global UI settings (language, theme, etc.).
Persisted in ``WORKING_DIR/settings.json``, independent of
per-agent configuration. All endpoints are public (no auth required).
"""
from __future__ import annotations
from fastapi import APIRouter, Body, HTTPException, Request
from pydantic impo... | 124 | 3,691 |
QwenPaw | src/qwenpaw/app/routers/agent_stats.py | .py | # -*- coding: utf-8 -*-
"""Agent statistics API for console."""
from __future__ import annotations
from datetime import date, timedelta
from fastapi import APIRouter, Query, Request
from ...agent_stats import AgentStatsSummary, get_agent_stats_service
from ..agent_context import get_agent_for_request
router = APIR... | 55 | 1,470 |
QwenPaw | src/qwenpaw/app/routers/envs.py | .py | # -*- coding: utf-8 -*-
"""API endpoints for environment variable management."""
from __future__ import annotations
from typing import Dict, List
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel, Field
from ...envs import load_envs, save_envs, delete_env_var
router = APIRouter(prefix="/en... | 81 | 2,248 |
QwenPaw | src/qwenpaw/app/routers/_backup_helpers.py | .py | # -*- coding: utf-8 -*-
"""Small helpers for backup API routes.
Kept separate from the router so trust-token validation and public response
shaping are shared by import/list/detail/restore without expanding the route
handlers themselves.
"""
from __future__ import annotations
import zipfile
from pathlib import Path
... | 129 | 4,146 |
QwenPaw | src/qwenpaw/app/routers/healthz.py | .py | # -*- coding: utf-8 -*-
"""Readiness probe endpoint."""
import asyncio
import time
from fastapi import APIRouter, Request
from fastapi.responses import JSONResponse
router = APIRouter(tags=["healthz"])
@router.get("/healthz")
async def get_healthz(request: Request):
"""Return 200 after core agents are ready, o... | 35 | 1,044 |
QwenPaw | src/qwenpaw/app/routers/schemas_config.py | .py | # -*- coding: utf-8 -*-
"""Request/response schemas for config API endpoints."""
from typing import List, Literal, Optional
from pydantic import BaseModel, Field
from ...constant import (
HEARTBEAT_DEFAULT_TIMEOUT_SECONDS,
HEARTBEAT_MAX_TIMEOUT_SECONDS,
)
from ...config.config import ActiveHoursConfig
clas... | 63 | 1,576 |
QwenPaw | src/qwenpaw/app/routers/config.py | .py | # -*- coding: utf-8 -*-
import asyncio
from datetime import datetime, timezone
from typing import Any, List, Optional
from fastapi import (
APIRouter,
Body,
Depends,
HTTPException,
Path,
Query,
Request,
)
from pydantic import BaseModel, Field
from ...agents.acp.core import ACPAgentConfig,... | 1,304 | 39,217 |
QwenPaw | src/qwenpaw/app/routers/tools.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-nested-blocks,too-many-branches
"""API routes for built-in tools management."""
from __future__ import annotations
from enum import Enum
from typing import Any, List, Optional
from fastapi import APIRouter, Body, HTTPException, Path, Request
from pydantic import Bas... | 450 | 14,341 |
QwenPaw | src/qwenpaw/app/routers/agent_status.py | .py | # -*- coding: utf-8 -*-
"""Agent status API."""
from datetime import datetime
from typing import Literal, Optional
from fastapi import APIRouter, HTTPException, Request
from pydantic import BaseModel, Field
from ...config import load_config
from ..agent_context import get_agent_for_request
router = APIRouter(prefix... | 94 | 2,762 |
QwenPaw | src/qwenpaw/app/routers/providers.py | .py | # -*- coding: utf-8 -*-
"""API routes for LLM providers and models."""
from __future__ import annotations
import logging
from typing import Dict, List, Literal, Optional
from fastapi import (
APIRouter,
Body,
Depends,
HTTPException,
Path,
Query,
Request,
)
from pydantic import BaseModel, F... | 1,021 | 32,727 |
QwenPaw | src/qwenpaw/app/routers/token_usage.py | .py | # -*- coding: utf-8 -*-
"""Token usage API for console and skill tool."""
from datetime import date, timedelta
from fastapi import APIRouter, Query
from ...token_usage import (
get_token_usage_manager,
TokenUsageSummary,
TokenUsageRecord,
)
router = APIRouter(prefix="/token-usage", tags=["token-usage"])... | 107 | 2,752 |
QwenPaw | src/qwenpaw/app/routers/local_models.py | .py | # -*- coding: utf-8 -*-
"""API endpoints for local model management."""
from __future__ import annotations
from typing import Any, List, Optional
from fastapi import APIRouter, HTTPException, Request, Depends
from pydantic import BaseModel, Field
from qwenpaw.exceptions import (
AppBaseException,
)
from ...loc... | 497 | 15,035 |
QwenPaw | src/qwenpaw/app/routers/coding_mode.py | .py | # -*- coding: utf-8 -*-
"""Coding Mode API endpoints.
Provides endpoints for reading and toggling Coding Mode per agent.
"""
from __future__ import annotations
import logging
from fastapi import APIRouter, Request
from pydantic import BaseModel
from ..agent_context import get_agent_for_request
from ..utils import s... | 106 | 2,684 |
QwenPaw | src/qwenpaw/app/routers/fork.py | .py | # -*- coding: utf-8 -*-
"""Fork subagent API endpoint.
POST /fork/agent — prepare a forked session + git worktree
for spawn_subagent(fork=True).
"""
from __future__ import annotations
import asyncio
import json
import logging
from pathlib import Path
from typing import Optional
from uuid import uuid4
from fastapi im... | 332 | 9,112 |
QwenPaw | src/qwenpaw/app/computer_use/runtime.py | .py | # -*- coding: utf-8 -*-
"""Host-provided Computer Use runtime capability and turn context."""
from __future__ import annotations
import json
import os
import socket
import sys
import threading
from contextvars import ContextVar
from dataclasses import dataclass
from typing import ClassVar
# Platforms with a native h... | 263 | 9,635 |
QwenPaw | src/qwenpaw/app/computer_use/__init__.py | .py | # -*- coding: utf-8 -*-
"""Core integration points for the Computer Use native runtime."""
from .runtime import (
COMPUTER_USE_PROTOCOL_VERSION,
HostRuntimeProvider,
RuntimeCapability,
RuntimeStatus,
get_current_computer_use_turn_id,
set_current_computer_use_turn_id,
)
__all__ = [
"COMPUTE... | 21 | 500 |
QwenPaw | src/qwenpaw/app/mcp/__init__.py | .py | # -*- coding: utf-8 -*-
"""MCP application services and API schemas."""
| 3 | 72 |
QwenPaw | src/qwenpaw/app/mcp/schemas.py | .py | # -*- coding: utf-8 -*-
"""Pydantic schemas for MCP Console APIs."""
from __future__ import annotations
from datetime import datetime
from typing import Any, Dict, List, Literal, Optional
from pydantic import BaseModel, Field
class MCPClientOAuthStatus(BaseModel):
"""Summarised OAuth status returned in client ... | 274 | 8,662 |
QwenPaw | src/qwenpaw/app/mcp/config_service.py | .py | # -*- coding: utf-8 -*-
"""Application service for Console-managed MCP Driver configuration."""
from __future__ import annotations
import asyncio
import logging
from typing import Any
from fastapi import HTTPException
from ..driver_config_service import (
DriverConfigService,
ensure_driver_active,
)
from .s... | 728 | 23,520 |
QwenPaw | src/qwenpaw/app/chats/utils.py | .py | # -*- coding: utf-8 -*-
import json
import logging
import platform
import re
from datetime import datetime, timezone
from typing import List, Optional, Union
from urllib.parse import unquote, urlparse
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
from agentscope.message import Msg
from qwenpaw.agents.context.sc... | 899 | 32,827 |
QwenPaw | src/qwenpaw/app/chats/models.py | .py | # -*- coding: utf-8 -*-
"""Chat models with UUID management."""
from __future__ import annotations
from datetime import datetime, timezone
from enum import Enum
from typing import Any, Dict, Literal, Optional
from uuid import uuid4
from pydantic import BaseModel, ConfigDict, Field, computed_field
from qwenpaw.schemas... | 129 | 3,621 |
QwenPaw | src/qwenpaw/app/chats/manager.py | .py | # -*- coding: utf-8 -*-
"""Chat manager for managing chat specifications."""
from __future__ import annotations
import asyncio
import logging
from datetime import datetime, timezone
from collections.abc import Awaitable, Callable
from typing import Optional
from .models import (
BatchArchiveResult,
BatchFail... | 555 | 18,909 |
QwenPaw | src/qwenpaw/app/chats/__init__.py | .py | # -*- coding: utf-8 -*-
"""Chat management: models, repository, session, and API."""
from .api import router
from .manager import ChatManager
from .models import (
ChatSpec,
ChatHistory,
ChatsFile,
)
from .repo import (
BaseChatRepository,
JsonChatRepository,
)
__all__ = [
"ChatManager",
"... | 25 | 435 |
QwenPaw | src/qwenpaw/app/chats/title_generator.py | .py | # -*- coding: utf-8 -*-
"""Async background task that asks the LLM to generate a chat title.
The console handler creates a chat with a placeholder name (truncated first
message) so the UI has something to show immediately. Once the chat exists
we spawn :func:`generate_and_update_title` as an ``asyncio`` task that asks... | 172 | 6,210 |
QwenPaw | src/qwenpaw/app/chats/session.py | .py | # -*- coding: utf-8 -*-
"""Safe JSON session with filename sanitization for cross-platform
compatibility.
Windows filenames cannot contain: \\ / : * ? " < > |
"""
import os
import re
import logging
import shutil
from pathlib import Path, PurePosixPath
from typing import Union, Sequence
from qwenpaw.exceptions impor... | 474 | 15,403 |
QwenPaw | src/qwenpaw/app/chats/api.py | .py | # -*- coding: utf-8 -*-
"""Chat management API."""
from __future__ import annotations
import asyncio
import logging
from pathlib import Path
from typing import Optional
from uuid import uuid4
from fastapi import APIRouter, Depends, HTTPException, Query, Request
from pydantic import BaseModel, Field
from agentscope.m... | 478 | 13,675 |
QwenPaw | src/qwenpaw/app/chats/query_error_dump.py | .py | # -*- coding: utf-8 -*-
"""Write query-handler error log and agent/memory state to a temp JSON file."""
from __future__ import annotations
import json
import logging
import os
import tempfile
import traceback
from datetime import datetime, timezone
from typing import Any
from ..channels.schema import DEFAULT_CHANNEL
... | 105 | 3,419 |
QwenPaw | src/qwenpaw/app/chats/repo/json_repo.py | .py | # -*- coding: utf-8 -*-
"""JSON-based chat repository."""
from __future__ import annotations
import json
import logging
import os
import shutil
import uuid
from pathlib import Path
from .base import BaseChatRepository
from ..models import ChatsFile
from ....utils.io_utils import read_json, run_sync_io, write_json_ato... | 147 | 4,217 |
QwenPaw | src/qwenpaw/app/chats/repo/__init__.py | .py | # -*- coding: utf-8 -*-
"""Chat repository implementations."""
from .base import BaseChatRepository
from .json_repo import JsonChatRepository
__all__ = ["BaseChatRepository", "JsonChatRepository"]
| 7 | 198 |
QwenPaw | src/qwenpaw/app/chats/repo/base.py | .py | # -*- coding: utf-8 -*-
"""Chat repository for storing chat/session specs."""
from __future__ import annotations
from abc import ABC, abstractmethod
from datetime import datetime, timezone
from typing import Optional
from ..models import ChatSpec, ChatsFile
from ...channels.schema import DEFAULT_CHANNEL
class BaseC... | 188 | 5,473 |
QwenPaw | src/qwenpaw/app/channels/renderer.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-branches,too-many-statements
"""
Pluggable message renderer: Message -> sendable parts (runtime Content).
Style/capabilities control markdown, emoji, code fence.
"""
from __future__ import annotations
import json
import logging
from dataclasses import dataclass, field... | 498 | 19,396 |
QwenPaw | src/qwenpaw/app/channels/utils.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-return-statements
"""
Bridge between channels and agent processing: factory to build
ProcessHandler from runner. Shared helpers for channels (e.g. file URL).
"""
from __future__ import annotations
import os
import re
from typing import List, Optional, Tuple
from urlli... | 259 | 8,680 |
QwenPaw | src/qwenpaw/app/channels/qrcode_auth_handler.py | .py | # -*- coding: utf-8 -*-
"""Unified QR code authorization handlers for channels.
Each channel that supports QR-code-based login/authorization implements a
concrete ``QRCodeAuthHandler`` and registers it in ``QRCODE_AUTH_HANDLERS``.
The router in *config.py* exposes two generic endpoints that delegate to
the appropriate... | 833 | 29,408 |
QwenPaw | src/qwenpaw/app/channels/manager.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
# ChannelManager is the framework owner of BaseChannel and must call
# _is_native_payload and _consume_one_request as part of the contract.
from __future__ import annotations
import asyncio
import logging
from pathlib import Path
from typing import (
Any... | 852 | 28,905 |
QwenPaw | src/qwenpaw/app/channels/__init__.py | .py | # -*- coding: utf-8 -*-
# ChannelManager is provided by __getattr__ (lazy-loaded).
# pylint: disable=undefined-all-variable
__all__ = ["ChannelManager"]
def __getattr__(name: str):
"""Lazy-load ChannelManager to avoid pulling feishu/lark_oapi on CLI."""
if name == "ChannelManager":
from .manager impor... | 14 | 443 |
QwenPaw | src/qwenpaw/app/channels/access_control.py | .py | # -*- coding: utf-8 -*-
"""Unified access control store for channel whitelist/blacklist management.
Persists per-channel whitelist, blacklist, and pending approval entries
to a JSON file under the working directory.
"""
from __future__ import annotations
import json
import logging
import threading
import time
from pa... | 547 | 18,409 |
QwenPaw | src/qwenpaw/app/channels/unified_queue_manager.py | .py | # -*- coding: utf-8 -*-
"""Unified queue manager with per-session priority queues.
This module implements the core queue management system using a three-tuple
QueueKey: (channel_id, session_id, priority_level). It enables:
1. Concurrent processing for different sessions
2. Concurrent processing for different priority... | 498 | 15,861 |
QwenPaw | src/qwenpaw/app/channels/registry.py | .py | # -*- coding: utf-8 -*-
"""Channel registry: built-in + plugin-registered channels."""
from __future__ import annotations
import importlib
import logging
import threading
from typing import TYPE_CHECKING
from .base import BaseChannel
if TYPE_CHECKING:
pass
logger = logging.getLogger(__name__)
_BUILTIN_SPECS: ... | 135 | 4,310 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.