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/modes/mission/gates.py | .py | # -*- coding: utf-8 -*-
"""MissionGate — Gate-driven Mission Mode Phase 2.
Replaces the custom ``run_mission_phase2`` executor
with a StopHandler-compatible gate that checks
``prd.json`` completion after each agent turn.
"""
from __future__ import annotations
import asyncio
import logging
from dataclasses import data... | 276 | 7,960 |
QwenPaw | src/qwenpaw/modes/mission/handler.py | .py | # -*- coding: utf-8 -*-
"""Mission Mode command helpers.
Called by ``MissionMode._mission_handler`` (registered via
``SlashCommandRegistry``) to process ``/mission`` sub-commands.
"""
from __future__ import annotations
import asyncio
import logging
from pathlib import Path
from typing import Any
from .prompts import... | 290 | 8,697 |
QwenPaw | src/qwenpaw/modes/mission/prompts.py | .py | # -*- coding: utf-8 -*-
"""Prompt templates for Mission Mode.
The worker prompt is adapted from the Ralph project
(https://github.com/snarktank/ralph) by snarktank, MIT License.
See design/ralph/LICENSE for the full license text.
"""
from __future__ import annotations
# -----------------------------------------------... | 890 | 31,569 |
QwenPaw | src/qwenpaw/modes/mission/contributor.py | .py | # -*- coding: utf-8 -*-
"""Mission mode prompt contributor.
NOTE: ``build_mission_system_prompt`` was removed
(dead code — never existed in prompts.py). This
contributor is retained as a no-op placeholder for
the MissionMode prompt contributor registry.
"""
from __future__ import annotations
import logging
from typ... | 43 | 991 |
QwenPaw | src/qwenpaw/modes/default/__init__.py | .py | # -*- coding: utf-8 -*-
"""Public API for the default loop mode."""
from __future__ import annotations
from .mode import DefaultMode, resolve_max_iterations
__all__ = ["DefaultMode", "resolve_max_iterations"]
| 9 | 212 |
QwenPaw | src/qwenpaw/modes/default/mode.py | .py | # -*- coding: utf-8 -*-
"""Default loop mode for ordinary ReAct requests."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any
from ..base import AgentMode
from ...loop.gates import (
StopGate,
StopHandler,
StopHandlerRegistration,
)
from ...loop.gates.doom_loop impor... | 133 | 4,396 |
QwenPaw | src/qwenpaw/plugins/architecture.py | .py | # -*- coding: utf-8 -*-
"""Plugin architecture definitions."""
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, ConfigDict, Field, model_validator
class PluginType(str, Enum):
"""Canonical plugin ... | 239 | 7,984 |
QwenPaw | src/qwenpaw/plugins/runtime.py | .py | # -*- coding: utf-8 -*-
"""Runtime helper functions for plugins."""
from typing import List
import logging
logger = logging.getLogger(__name__)
class RuntimeHelpers:
"""Runtime helper functions accessible to plugins."""
def __init__(self, provider_manager=None):
"""Initialize runtime helpers.
... | 68 | 1,607 |
QwenPaw | src/qwenpaw/plugins/__init__.py | .py | # -*- coding: utf-8 -*-
"""QwenPaw Plugin System."""
from .loader import PluginLoader
from .registry import PluginRegistry
from .api import PluginApi, get_tool_config
from .architecture import PluginManifest, PluginRecord
__all__ = [
"PluginLoader",
"PluginRegistry",
"PluginApi",
"PluginManifest",
... | 17 | 362 |
QwenPaw | src/qwenpaw/plugins/download_catalog.py | .py | # -*- coding: utf-8 -*-
"""Proxy-fetch official plugin catalog from the download CDN."""
from __future__ import annotations
import asyncio
import gzip
import json
import logging
import urllib.error
import urllib.request
from typing import Any
from packaging.version import InvalidVersion, Version
from .._version_com... | 284 | 9,226 |
QwenPaw | src/qwenpaw/plugins/registry.py | .py | # -*- coding: utf-8 -*-
# pylint:disable=too-many-nested-blocks
"""Central plugin registry."""
from typing import Any, Callable, Dict, List, Optional, Type
from dataclasses import dataclass, field
import logging
from fastapi import APIRouter
logger = logging.getLogger(__name__)
# Registered on the console SPA catch... | 1,098 | 35,365 |
QwenPaw | src/qwenpaw/plugins/api.py | .py | # -*- coding: utf-8 -*-
"""Plugin API for plugin developers."""
import logging
import threading
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Type
logger = logging.getLogger(__name__)
def get_tool_config(tool_name: str) -> Optional[Dict[str, Any]]:
"""Get tool configuration fo... | 1,635 | 55,729 |
QwenPaw | src/qwenpaw/plugins/loader.py | .py | # -*- coding: utf-8 -*-
"""Plugin loader for discovering and loading plugins."""
import asyncio
import importlib.util
import inspect
import json
import logging
import os
import platform
import shutil
import subprocess
import sys
import threading
from contextlib import asynccontextmanager
from contextvars import Contex... | 1,443 | 52,416 |
QwenPaw | src/qwenpaw/plugins/install_lock.py | .py | # -*- coding: utf-8 -*-
"""Cross-process advisory lock for plugin dependency installation.
The plugin loader installs third-party Python dependencies with
``pip install`` / ``pip install --target``. In the frozen desktop build
several backend processes can run at once (e.g. an orphaned backend left
over from a crash p... | 155 | 4,877 |
QwenPaw | src/qwenpaw/plugins/validation.py | .py | # -*- coding: utf-8 -*-
"""Plugin module-loading validation utilities.
This module provides the core validation logic used by both the CLI
``plugin install`` and ``plugin validate`` commands. It replicates
the module-loading semantics of PluginLoader.load_plugin so that
plugins are validated under the same conditions ... | 78 | 2,684 |
QwenPaw | src/qwenpaw/runtime/phases.py | .py | # -*- coding: utf-8 -*-
"""Runtime hook phase enum.
Eight phase points covering the full request lifecycle::
PRE_DISPATCH — request normalization, before slash dispatch
POST_DISPATCH — slash dispatch finished without a match
PRE_AGENT_BUILD — session.load and other pre-build setup
POST_AGEN... | 42 | 1,424 |
QwenPaw | src/qwenpaw/runtime/builder.py | .py | # -*- coding: utf-8 -*-
"""Per-request agent assembly.
:class:`AgentBuilder` fully constructs a :class:`QwenPawAgent` for each
request. It obtains tools from the per-workspace
:class:`QwenPawLocalWorkspace` (via ``list_tools``), the system prompt
from :class:`PromptManager`, and the model from the factory, then
injec... | 1,239 | 45,427 |
QwenPaw | src/qwenpaw/runtime/runtime.py | .py | # -*- coding: utf-8 -*-
"""8-phase request orchestration.
Delegates to:
* ``Envelope`` — SSE state machine
* ``AgentBuilder`` — per-request agent assembly
* ``AgentExecutor`` — heartbeat-wrapped reply stream
All insertable features live in ``LifecycleHook`` / ``AgentMode``
instances registered in the per-wo... | 531 | 20,104 |
QwenPaw | src/qwenpaw/runtime/_state_utils.py | .py | # -*- coding: utf-8 -*-
"""Shared session-state utilities."""
from __future__ import annotations
class StateProxy:
"""Minimal proxy satisfying SafeJSONSession's state_module protocol.
Used by session hooks and builtin commands to load/save AgentState
without instantiating a full agent.
"""
def _... | 24 | 530 |
QwenPaw | src/qwenpaw/runtime/heartbeat.py | .py | # -*- coding: utf-8 -*-
"""SSE heartbeat wrapper for async iterators."""
from __future__ import annotations
import asyncio
HEARTBEAT_INTERVAL_SECONDS = 25.0
_HEARTBEAT_TICK = object()
async def _iter_with_heartbeat(source_iter, interval: float):
"""Wrap an async-iter so it yields ``_HEARTBEAT_TICK`` on idle.
... | 41 | 1,314 |
QwenPaw | src/qwenpaw/runtime/hooks.py | .py | # -*- coding: utf-8 -*-
"""Runtime hook abstraction — context, action, base class, registry.
Hooks here are the **runtime-orchestration** layer, executed by
``Runtime.run()`` around the fixed build/execute steps. They are distinct
from ``agentscope.middleware`` (which wraps an individual agent's reply
loop) and from `... | 338 | 11,341 |
QwenPaw | src/qwenpaw/runtime/executor.py | .py | # -*- coding: utf-8 -*-
"""Agent execution driver.
Drives ``agent.reply_stream(inputs=msgs)`` with heartbeat wrapping
and delegates each ``EventType`` event to ``Envelope.translate_event()``.
"""
from __future__ import annotations
import logging
from typing import Any, AsyncGenerator
from .envelope import Envelope
... | 61 | 1,730 |
QwenPaw | src/qwenpaw/runtime/builtin_commands.py | .py | # -*- coding: utf-8 -*-
"""Built-in slash command adapters.
Wraps the four existing command mechanisms (daemon, control,
conversation, skill) as :class:`CommandSpec` instances registered
into a single :class:`SlashCommandRegistry`. Each adapter reads
from :class:`HookContext` (``ctx.workspace``, ``ctx.agent``, etc.)
... | 735 | 23,035 |
QwenPaw | src/qwenpaw/runtime/prompt_contributors.py | .py | # -*- coding: utf-8 -*-
"""Built-in :class:`PromptContributor` implementations.
Each contributor is responsible for one fragment of the system prompt.
``build_default_prompt_manager`` assembles a :class:`PromptManager`
pre-loaded with the built-in contributors, ready for ``build_sync(ctx)``.
Contributors read configu... | 396 | 13,048 |
QwenPaw | src/qwenpaw/runtime/prompt_manager.py | .py | # -*- coding: utf-8 -*-
"""Per-workspace system-prompt assembly.
Each contributor declares one fragment of the system prompt;
``PromptManager`` orders them by priority and joins non-empty results
with ``PROMPT_SEPARATOR``.
``PROMPT_SEPARATOR`` is intentionally a module-level constant so
parity tests can pin the exact... | 146 | 4,912 |
QwenPaw | src/qwenpaw/runtime/message_convert.py | .py | # -*- coding: utf-8 -*-
"""Message conversion between AgentRequest and agentscope Msg."""
from __future__ import annotations
import logging
import mimetypes
from typing import Any, List
from urllib.parse import urlparse
from ..constant import (
EXTERNAL_USER_QUERY_MESSAGE_TAG,
QWENPAW_MESSAGE_TAG_KEY,
)
from ... | 169 | 5,417 |
QwenPaw | src/qwenpaw/runtime/slash_command_registry.py | .py | # -*- coding: utf-8 -*-
"""Per-workspace slash-command registry.
Named ``SlashCommandRegistry`` (not ``CommandRegistry``) to avoid clashing
with ``app/channels/command_registry.py:CommandRegistry`` — that one is the
IM-channel priority router and is unrelated to runtime slash dispatch.
Unifies the four previously-par... | 165 | 5,574 |
QwenPaw | src/qwenpaw/runtime/tool_guard.py | .py | # -*- coding: utf-8 -*-
"""GuardedFunctionTool — permission-checked tool wrapper."""
from __future__ import annotations
import asyncio
import logging
import uuid
from typing import Any
logger = logging.getLogger(__name__)
class GuardedFunctionTool:
"""Permission-checked tool wrapper using qwenpaw's tool-guard e... | 428 | 15,017 |
QwenPaw | src/qwenpaw/runtime/envelope.py | .py | # -*- coding: utf-8 -*-
"""SSE envelope state machine.
Translates agentscope ``EventType`` events into the frontend's
streaming envelope protocol. Tracks per-request state (text blocks,
reasoning blocks, tool calls) and emits the correct event sequence
that ``Builder.tsx`` expects.
"""
from __future__ import annotat... | 938 | 33,930 |
QwenPaw | src/qwenpaw/runtime/tool_registry.py | .py | # -*- coding: utf-8 -*-
"""Per-workspace tool registry.
Each builtin tool function carries a ``ToolDescriptor``
(via ``@tool_descriptor``); the registry exposes a single
``filter(...)`` entry point that ``AgentBuilder.build_toolkit`` calls
to decide which descriptors should be wrapped into ``GuardedFunctionTool``.
"""... | 323 | 11,831 |
QwenPaw | src/qwenpaw/runtime/commands/__init__.py | .py | # -*- coding: utf-8 -*-
"""Runtime command implementations: daemon and control commands."""
| 3 | 92 |
QwenPaw | src/qwenpaw/runtime/commands/daemon.py | .py | # -*- coding: utf-8 -*-
"""Daemon command execution layer and DaemonCommandHandlerMixin.
Shared by in-chat /daemon <sub> and the CLI daemon command.
Logs: tail the project log file. Restart: in-process reload of channels,
cron and MCP (no process exit); works on Mac/Windows without a process manager.
"""
# pylint: dis... | 278 | 9,301 |
QwenPaw | src/qwenpaw/runtime/commands/control/stop_handler.py | .py | # -*- coding: utf-8 -*-
"""Handler for /stop command.
The /stop command immediately terminates an ongoing agent task.
"""
from __future__ import annotations
import logging
from .base import BaseControlCommandHandler, ControlContext
logger = logging.getLogger(__name__)
class StopCommandHandler(BaseControlCommandH... | 108 | 3,323 |
QwenPaw | src/qwenpaw/runtime/commands/control/skills_handler.py | .py | # -*- coding: utf-8 -*-
"""Handler for /skills command.
Lists enabled skills for the current channel in a compact format.
"""
from __future__ import annotations
from pathlib import Path
import frontmatter as fm
from ....agents.skill_system import (
get_workspace_skills_dir,
reconcile_workspace_manifest,
)
... | 101 | 3,026 |
QwenPaw | src/qwenpaw/runtime/commands/control/__init__.py | .py | # -*- coding: utf-8 -*-
"""Control commands module.
Provides centralized command registration and dispatch for control commands
like /stop that require immediate response and special handling.
Usage:
# Check if a query is a control command
if is_control_command(query):
response = await handle_control_... | 271 | 7,976 |
QwenPaw | src/qwenpaw/runtime/commands/control/approval_handler.py | .py | # -*- coding: utf-8 -*-
# pylint:disable=protected-access
"""Handler for /approval command.
Manages tool guard approval requests through unified control commands.
"""
from __future__ import annotations
import logging
import time
from ....app.approvals import (
ApprovalService,
PendingApproval,
get_appro... | 411 | 14,823 |
QwenPaw | src/qwenpaw/runtime/commands/control/checkpoint_handler.py | .py | # -*- coding: utf-8 -*-
"""Built-in ``/checkpoint`` control command handler."""
from __future__ import annotations
import shlex
from ....checkpoints.policy import context_channel
from ....checkpoints.models import CheckpointError
from ....checkpoints.render import render_gc, render_restore, render_timeline
from ....... | 443 | 16,367 |
QwenPaw | src/qwenpaw/runtime/commands/control/model_handler.py | .py | # -*- coding: utf-8 -*-
# pylint:disable=too-many-return-statements
"""Handler for /model command.
The /model command manages model configuration for the current agent.
"""
from __future__ import annotations
import logging
from .base import BaseControlCommandHandler, ControlContext
logger = logging.getLogger(__nam... | 502 | 16,592 |
QwenPaw | src/qwenpaw/runtime/commands/control/base.py | .py | # -*- coding: utf-8 -*-
"""Base classes for control command handlers.
Control commands are high-priority commands like /stop that require
immediate response and special handling outside the normal agent flow.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from dataclasses import dataclass... | 76 | 2,145 |
QwenPaw | src/qwenpaw/providers/provider.py | .py | # -*- coding: utf-8 -*-
"""Definition of Provider."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Type
from agentscope.model import ChatModelBase
from pydantic import BaseModel, ConfigDict, Field, model_validator
from qwenpaw.exc... | 672 | 25,111 |
QwenPaw | src/qwenpaw/providers/anthropic_provider.py | .py | # -*- coding: utf-8 -*-
"""An Anthropic provider implementation."""
from __future__ import annotations
import json
import logging
import time
from datetime import datetime
from typing import Any, Dict, List
import httpx
from agentscope.model import ChatModelBase
import anthropic
from pydantic import Field
from qwen... | 702 | 24,977 |
QwenPaw | src/qwenpaw/providers/gemini_provider.py | .py | # -*- coding: utf-8 -*-
"""A Google Gemini provider implementation using AgentScope's native
GeminiChatModel."""
from __future__ import annotations
import copy
import logging
import time
from typing import Any, List
from agentscope.model import ChatModelBase
from google import genai
from google.genai import errors a... | 639 | 23,392 |
QwenPaw | src/qwenpaw/providers/rate_limiter.py | .py | # -*- coding: utf-8 -*-
"""Per-model LLM request rate limiter.
Each unique ``"provider_id:model_name"`` pair gets its own
``LLMRateLimiter`` instance via ``get_rate_limiter(limiter_key=...)``.
A 429 on one model therefore cannot stall calls to other models or
providers — background tasks (dream, heartbeat) that exhaus... | 356 | 14,072 |
QwenPaw | src/qwenpaw/providers/dashscope_provider.py | .py | # -*- coding: utf-8 -*-
"""DashScope provider using agentscope 2.0 native ``DashScopeChatModel``.
Most surface area (connection check, model listing, multimodal probe) is
reused from :class:`OpenAIProvider` because DashScope's
``compatible-mode/v1`` endpoint speaks OpenAI HTTP. Only
:meth:`get_chat_model_instance` is... | 316 | 12,103 |
QwenPaw | src/qwenpaw/providers/openai_chat_model_compat.py | .py | # -*- coding: utf-8 -*-
"""OpenAI chat model compatibility wrappers."""
from __future__ import annotations
import inspect
import json
import logging
import re
from datetime import datetime
from types import SimpleNamespace
from typing import Any, AsyncGenerator, Callable
from agentscope.message import ToolCallBlock
... | 956 | 33,936 |
QwenPaw | src/qwenpaw/providers/provider_manager.py | .py | # -*- coding: utf-8 -*-
"""A Manager class to handle all providers, including built-in and custom ones.
It provides a unified interface to manage providers, such as listing available
providers, adding/removing custom providers, and fetching provider details."""
import asyncio
import json
import logging
import os
from ... | 2,595 | 84,705 |
QwenPaw | src/qwenpaw/providers/openai_response_provider.py | .py | # -*- coding: utf-8 -*-
"""An OpenAI Responses API provider implementation."""
from __future__ import annotations
import logging
import time
from typing import Any
from agentscope.model import ChatModelBase, OpenAIResponseModel
from .capping_formatter import _CappingOpenAIResponseFormatter
from .openai_provider imp... | 390 | 13,060 |
QwenPaw | src/qwenpaw/providers/__init__.py | .py | # -*- coding: utf-8 -*-
"""Provider management — models, registry + persistent store."""
from .provider import Provider, ProviderInfo, ModelInfo
from .provider_manager import ProviderManager
__all__ = [
"ModelInfo",
"Provider",
"ProviderManager",
"ProviderInfo",
]
| 13 | 285 |
QwenPaw | src/qwenpaw/providers/capability_baseline.py | .py | # -*- coding: utf-8 -*-
"""Capability baseline — expected multimodal capabilities and discrepancy
reporting for all built-in providers.
"""
from __future__ import annotations
from dataclasses import dataclass, field
from enum import Enum
class ProbeSource(str, Enum):
"""Source of probe result."""
DOCUMENTA... | 875 | 30,696 |
QwenPaw | src/qwenpaw/providers/model_capability_cache.py | .py | # -*- coding: utf-8 -*-
"""Learned model capability cache.
When the system discovers model capabilities through trial-and-error
(e.g. a model requires ``reasoning_content`` on every assistant message,
or rejects multimodal input despite being marked as supporting it),
those findings are cached here by ``provider_id:mo... | 141 | 4,859 |
QwenPaw | src/qwenpaw/providers/retry_chat_model.py | .py | # -*- coding: utf-8 -*-
"""Retry wrapper for ChatModelBase instances.
Transparently retries LLM API calls on transient errors (rate-limit,
timeout, connection) with configurable exponential back-off.
Concurrency and rate-limit control (LLMRateLimiter):
- A global semaphore caps the number of concurrent in-flight LLM ... | 714 | 26,264 |
QwenPaw | src/qwenpaw/providers/context_windows.py | .py | # -*- coding: utf-8 -*-
"""Static catalog of known model context windows (input tokens).
The compaction trigger scales with ``model.context_size``
(= ``ModelInfo.max_input_length``), but built-in provider catalogs never set
that field, so every model used to inherit the 128k default — a 1M-context
model compacted exac... | 147 | 6,043 |
QwenPaw | src/qwenpaw/providers/ollama_provider.py | .py | # -*- coding: utf-8 -*-
"""An Ollama provider implementation."""
import os
from typing import Any
from agentscope.model import ChatModelBase
from openai import AsyncOpenAI
from qwenpaw.providers.capping_formatter import _CappingOpenAIFormatter
from qwenpaw.providers.openai_provider import OpenAIProvider
class Olla... | 106 | 3,953 |
QwenPaw | src/qwenpaw/providers/error_utils.py | .py | # -*- coding: utf-8 -*-
"""Shared helpers for normalizing provider SDK exceptions."""
from __future__ import annotations
import re
from collections.abc import Iterator
from typing import Any
_STREAMING_ERROR_STATUS_RE = re.compile(
r"\bStreaming response failed\s*:\s*\[\s*([1-5]\d{2})\s*\]",
re.IGNORECASE,
... | 102 | 3,292 |
QwenPaw | src/qwenpaw/providers/openai_provider.py | .py | # -*- coding: utf-8 -*-
"""An OpenAI provider implementation."""
from __future__ import annotations
import importlib.util
import json
import logging
import os
import re
import time
from typing import TYPE_CHECKING, Any, List
from urllib.parse import urlparse
import httpx
from agentscope.model import ChatModelBase
fr... | 937 | 33,244 |
QwenPaw | src/qwenpaw/providers/capping_formatter.py | .py | # -*- coding: utf-8 -*-
"""Capping formatters that refuse to inline oversized local media.
agentscope's chat formatters (OpenAI, Anthropic, Gemini, DashScope, …) all
read every local ``file://`` media source off disk and base64-encode the
*entire* file into the request body on every API call. When a large file
persis... | 296 | 10,975 |
QwenPaw | src/qwenpaw/providers/openrouter_provider.py | .py | # -*- coding: utf-8 -*-
"""An OpenRouter provider implementation."""
from __future__ import annotations
from decimal import Decimal, InvalidOperation
from typing import Any, List, Optional
from agentscope.model import ChatModelBase
from openai import APIError, AsyncOpenAI
from pydantic import Field
from qwenpaw.exc... | 461 | 16,456 |
QwenPaw | src/qwenpaw/providers/multimodal_prober.py | .py | # -*- coding: utf-8 -*-
"""Multimodal capability probing — shared constants and data types.
Provider-specific probe logic lives in each provider class
(e.g. ``OpenAIProvider._probe_image_support``).
"""
import logging
import time
from dataclasses import dataclass
logger = logging.getLogger(__name__)
# 32x32 red PNG... | 261 | 8,765 |
QwenPaw | src/qwenpaw/providers/lmstudio_provider.py | .py | # -*- coding: utf-8 -*-
"""LM Studio Provider implementation."""
from qwenpaw.providers.openai_provider import OpenAIProvider
class LMStudioProvider(OpenAIProvider):
"""Provider implementation for LM Studio local LLM hosting platform."""
async def check_model_connection(
self,
model_id: str,... | 20 | 634 |
QwenPaw | src/qwenpaw/providers/oauth/openrouter_flow.py | .py | # -*- coding: utf-8 -*-
"""OpenRouter OAuth flow: browser redirect -> code -> permanent API Key."""
from __future__ import annotations
from urllib.parse import quote
import httpx
from .base import (
OAuthFlow,
OAuthStartResult,
OAuthTokenResult,
generate_state,
)
class OpenRouterOAuthFlow(OAuthFlo... | 52 | 1,422 |
QwenPaw | src/qwenpaw/providers/oauth/__init__.py | .py | # -*- coding: utf-8 -*-
"""Provider OAuth module for one-click authentication."""
from .base import OAuthFlow, OAuthStartResult, OAuthTokenResult
from .session_store import OAuthSessionStore
from .openrouter_flow import OpenRouterOAuthFlow
__all__ = [
"OAuthFlow",
"OAuthStartResult",
"OAuthTokenResult",
... | 15 | 373 |
QwenPaw | src/qwenpaw/providers/oauth/session_store.py | .py | # -*- coding: utf-8 -*-
"""In-memory OAuth session store with TTL expiration."""
from __future__ import annotations
import time
from dataclasses import dataclass, field
from typing import Dict, Optional
_TTL_SECONDS = 600 # 10 minutes
@dataclass
class OAuthSession:
"""Transient state for a single OAuth round... | 115 | 3,306 |
QwenPaw | src/qwenpaw/providers/oauth/base.py | .py | # -*- coding: utf-8 -*-
"""Base class and models for provider OAuth flows."""
from __future__ import annotations
import base64
import hashlib
import secrets
from abc import ABC, abstractmethod
from typing import Optional
from pydantic import BaseModel, Field
class OAuthStartResult(BaseModel):
"""Result of star... | 113 | 3,014 |
QwenPaw | src/qwenpaw/agents/middlewares.py | .py | # -*- coding: utf-8 -*-
"""Native AgentScope 2.0 middleware implementations for QwenPaw.
Most per-request setup (ContextVars,
bootstrap injection, skill env overrides, file/media processing) is
handled by lifecycle hooks.
Middlewares in this module wrap the agent's inner reasoning loop via
agentscope's ``MiddlewareBa... | 984 | 33,759 |
QwenPaw | src/qwenpaw/agents/model_factory.py | .py | # -*- coding: utf-8 -*-
"""Factory for creating chat models and formatters.
This module provides a unified factory for creating chat model instances
and their corresponding formatters based on configuration.
Example:
>>> from qwenpaw.agents.model_factory import create_model_and_formatter
>>> model, formatter ... | 1,636 | 61,264 |
QwenPaw | src/qwenpaw/agents/command_handler.py | .py | # -*- coding: utf-8 -*-
"""Agent command handler for system commands.
This module handles system commands like /compact, /new, /clear, etc.
"""
import json
import logging
from pathlib import Path
from typing import Any, TYPE_CHECKING
from agentscope.message import HintBlock, Msg, TextBlock
from .context.scroll.cont... | 1,442 | 55,315 |
QwenPaw | src/qwenpaw/agents/__init__.py | .py | # -*- coding: utf-8 -*-
"""QwenPaw Agents Module.
This module provides the main agent implementation and supporting utilities
for building AI agents with tools, skills, and memory management.
Public API:
- QwenPawAgent: Main agent class
- create_model_and_formatter: Factory for creating models and formatters
Example... | 35 | 1,167 |
QwenPaw | src/qwenpaw/agents/offloader.py | .py | # -*- coding: utf-8 -*-
"""Offloader for persisting compressed context and tool results.
Implements the agentscope ``Offloader`` protocol so the native
``Agent.compress_context()`` automatically persists evicted messages
to date-grouped JSONL files and truncated tool results to individual
text files.
"""
from __future... | 176 | 5,517 |
QwenPaw | src/qwenpaw/agents/prompt_builder.py | .py | # -*- coding: utf-8 -*-
"""Assemble system prompt from host anchors and plugin sections."""
from __future__ import annotations
import logging
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, List, Optional
if TYPE_CHECKING:
from ..plugins.registry import PluginRegistry
logger = logging.ge... | 85 | 2,611 |
QwenPaw | src/qwenpaw/agents/routing_chat_model.py | .py | # -*- coding: utf-8 -*-
"""ChatModel router for local/cloud model selection."""
from __future__ import annotations
import logging
from dataclasses import dataclass, field
from typing import Any, AsyncGenerator, Literal, Type
from agentscope.formatter import FormatterBase
from agentscope.model import ChatModelBase
fr... | 130 | 3,858 |
QwenPaw | src/qwenpaw/agents/react_agent.py | .py | # -*- coding: utf-8 -*-
"""QwenPaw Agent - Main agent implementation.
This module provides the main QwenPawAgent class built on ReActAgent,
with integrated tools, skills, and memory management.
Agent construction is fully delegated to :class:`AgentBuilder` — the
agent accepts all dependencies (model, prompt, toolkit,... | 1,126 | 42,023 |
QwenPaw | src/qwenpaw/agents/prompt.py | .py | # -*- coding: utf-8 -*-
# flake8: noqa: E501
"""System prompt building utilities.
This module provides utilities for building system prompts from
markdown configuration files in the working directory.
"""
import logging
import re
from pathlib import Path
from typing import Any
from qwenpaw.exceptions import (
Con... | 566 | 19,723 |
QwenPaw | src/qwenpaw/agents/templates.py | .py | # -*- coding: utf-8 -*-
"""Shared agent template definitions and builders."""
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
from ..config.config import (
AgentProfileConfig,
ChannelConfig,
HeartbeatConfig,
MCPConfig,
ToolsConfig,
build_local_age... | 137 | 4,404 |
QwenPaw | src/qwenpaw/agents/fork_project.py | .py | # -*- coding: utf-8 -*-
"""Fork worktree path validation and integration registry."""
from __future__ import annotations
import errno
import hashlib
import json
import logging
import os
import subprocess
import threading
import time
import uuid
from contextlib import contextmanager
from pathlib import Path
from typin... | 1,685 | 56,617 |
QwenPaw | src/qwenpaw/agents/acp/server.py | .py | # -*- coding: utf-8 -*-
"""QwenPaw ACP Agent server.
Exposes QwenPaw as an ACP-compliant agent that external clients
(Zed, OpenCode, etc.) can connect to via stdio JSON-RPC.
Uses the full ``Workspace`` lifecycle so the ACP agent has exactly
the same capabilities as the web console (MCP tools, memory,
sub-agent delega... | 1,575 | 55,903 |
QwenPaw | src/qwenpaw/agents/acp/runtime_provider.py | .py | # -*- coding: utf-8 -*-
"""Ephemeral model providers for headless ACP runtimes."""
from __future__ import annotations
import json
import os
from dataclasses import dataclass
from typing import Any, Mapping
from urllib.parse import urlparse
from ...config.config import ModelSlotConfig
from ...providers.openai_provide... | 150 | 4,805 |
QwenPaw | src/qwenpaw/agents/acp/__init__.py | .py | # -*- coding: utf-8 -*-
"""ACP client and server exports.
``.server`` and ``.service`` are heavy modules: they pull in the full
qwenpaw envelope schema and the ACP transport stack. Eagerly importing
them here would slow down every consumer of ``qwenpaw.agents.acp`` —
including ``delegate_external_agent`` which only n... | 63 | 1,906 |
QwenPaw | src/qwenpaw/agents/acp/tool_adapter.py | .py | # -*- coding: utf-8 -*-
"""ACP to ToolChunk adapter helpers for delegate_external_agent."""
from pathlib import Path
from typing import Any, Optional, Tuple
from agentscope.message import TextBlock
from agentscope.tool import ToolChunk
from agentscope.message import ToolResultState
def _text_block(text: str) -> Tex... | 249 | 7,369 |
QwenPaw | src/qwenpaw/agents/acp/client.py | .py | # -*- coding: utf-8 -*-
"""ACP client adapter built on the official Python SDK."""
from __future__ import annotations
import asyncio
from typing import Any, Awaitable, Callable, NoReturn
from acp import RequestError, session_notification
from acp.contrib.session_state import SessionAccumulator, ToolCallView
from acp.... | 552 | 18,068 |
QwenPaw | src/qwenpaw/agents/acp/permissions.py | .py | # -*- coding: utf-8 -*-
"""ACP permission handling."""
from __future__ import annotations
from pathlib import Path
from typing import Any
from acp.schema import AllowedOutcome, DeniedOutcome, RequestPermissionResponse
from .core import SuspendedPermission
class ACPPermissionAdapter:
def __init__(self, cwd: str... | 234 | 8,279 |
QwenPaw | src/qwenpaw/agents/acp/session_mcp.py | .py | # -*- coding: utf-8 -*-
"""ACP session MCP normalization for QwenPaw transient Drivers."""
from __future__ import annotations
import hashlib
from typing import Any, TypeAlias
from acp.schema import HttpMcpServer, McpServerStdio, SseMcpServer
from ...drivers.constants import POLICY_EFFECT_ASK, PROTOCOL_MCP
from ...d... | 152 | 4,835 |
QwenPaw | src/qwenpaw/agents/acp/service.py | .py | # -*- coding: utf-8 -*-
"""High-level ACP service built on the official Python SDK."""
from __future__ import annotations
import asyncio
import atexit
import os
import shutil
from contextlib import AsyncExitStack
from dataclasses import dataclass
from typing import Any, Awaitable, Callable
import psutil
from acp imp... | 521 | 16,981 |
QwenPaw | src/qwenpaw/agents/acp/node_runtime.py | .py | # -*- coding: utf-8 -*-
from __future__ import annotations
import os
import shutil
import subprocess
from pathlib import Path
from pydantic import BaseModel, Field
from ...constant import WORKING_DIR
DESKTOP_NODE_RUNTIME_ENV = "QWENPAW_DESKTOP_NODE_RUNTIME"
NPM_CACHE_ENV = "NPM_CONFIG_CACHE"
class ACPNodeRuntimeC... | 286 | 7,910 |
QwenPaw | src/qwenpaw/agents/acp/meta.py | .py | # -*- coding: utf-8 -*-
"""Shared ACP metadata keys.
This module is intentionally lightweight so CLI code can import constants
without importing the ACP server implementation.
"""
ACP_PROJECT_DIR_META_KEY = "qwenpaw.project_dir"
ACP_EPHEMERAL_META_KEY = "qwenpaw.ephemeral"
ACP_APPROVAL_EXPIRES_AT_META_KEY = "qwenpaw.... | 17 | 458 |
QwenPaw | src/qwenpaw/agents/acp/core.py | .py | # -*- coding: utf-8 -*-
"""ACP shared definitions."""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any
from ...config.config import ACPAgentConfig, ACPConfig
from ...exceptions import (
ACPConfigurationError,
ACPError,
ACPProtocolError,
ACPSessionError... | 45 | 956 |
QwenPaw | src/qwenpaw/agents/hooks/bootstrap.py | .py | # -*- coding: utf-8 -*-
"""Bootstrap hook for first-time user interaction guidance.
This hook checks for BOOTSTRAP.md on the first user interaction and
prepends guidance to help set up the agent's identity and preferences.
"""
import logging
from pathlib import Path
from typing import Any
from ..prompt import build_b... | 104 | 3,036 |
QwenPaw | src/qwenpaw/agents/hooks/__init__.py | .py | # -*- coding: utf-8 -*-
"""Agent hooks package.
This package provides hook implementations for QwenPawAgent that follow
AgentScope's hook interface (any Callable).
Available Hooks:
- BootstrapHook: First-time setup guidance
"""
from .bootstrap import BootstrapHook
__all__ = [
"BootstrapHook",
]
| 16 | 308 |
QwenPaw | src/qwenpaw/agents/tools/ast_tool.py | .py | # -*- coding: utf-8 -*-
"""AST search tool — multi-language structural pattern matching.
Thin wrapper around the ``ast-grep`` CLI (PyPI distribution
``ast-grep-cli``). Exposes a single read-only ``ast_search`` function
for use inside Coding Mode.
The tool is strictly read-only by design: when the agent wants to
appl... | 341 | 10,711 |
QwenPaw | src/qwenpaw/agents/tools/utils.py | .py | # -*- coding: utf-8 -*-
# flake8: noqa: E501
# pylint: disable=line-too-long
"""Shared utilities for file and shell tools."""
import logging
import os
import re
import uuid
from pathlib import Path
from typing import Any
from ...constant import TRUNCATION_NOTICE_MARKER
from ...utils.io_utils import run_sync_io
logge... | 555 | 19,094 |
QwenPaw | src/qwenpaw/agents/tools/send_file.py | .py | # -*- coding: utf-8 -*-
# flake8: noqa: E501
# pylint: disable=line-too-long,too-many-return-statements
import os
import mimetypes
import unicodedata
from urllib.parse import unquote
from agentscope.tool import ToolChunk
from agentscope.message import ToolResultState
from agentscope.message import TextBlock, DataBlock... | 106 | 3,005 |
QwenPaw | src/qwenpaw/agents/tools/view_media.py | .py | # -*- coding: utf-8 -*-
"""Load image or video files into the LLM context for analysis."""
import logging
import mimetypes
import os
import unicodedata
import urllib.parse
from urllib.parse import unquote
from pathlib import Path
from typing import Optional
from agentscope.message import (
DataBlock,
TextBloc... | 518 | 16,607 |
QwenPaw | src/qwenpaw/agents/tools/delegate_external_agent.py | .py | # -*- coding: utf-8 -*-
"""Built-in tool for delegating tasks to external agent runners.
Uses the ACP protocol.
"""
import asyncio
import logging
import time
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, AsyncGenerator, Callable, Optional, cast
from agentscope.message impo... | 1,046 | 32,760 |
QwenPaw | src/qwenpaw/agents/tools/file_io.py | .py | # -*- coding: utf-8 -*-
# flake8: noqa: E501
# pylint: disable=line-too-long
import os
from pathlib import Path
from typing import Optional
from agentscope.message import TextBlock, ToolResultState
from agentscope.tool import ToolChunk
from .utils import (
build_truncation_metadata,
truncate_text_output,
... | 537 | 15,884 |
QwenPaw | src/qwenpaw/agents/tools/__init__.py | .py | # -*- coding: utf-8 -*-
"""Built-in tool functions for QwenPaw agents.
Every tool function decorated with ``@tool_descriptor`` is automatically
collected into a global registry at import time. Adding a new built-in
tool requires only two things:
1. Decorate the function with ``@tool_descriptor(...)`` (include
gov... | 165 | 5,698 |
QwenPaw | src/qwenpaw/agents/tools/get_current_time.py | .py | # -*- coding: utf-8 -*-
"""Tools for getting and setting the user timezone."""
import logging
from datetime import datetime, timezone
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
from agentscope.message import TextBlock
from agentscope.tool import ToolChunk
from agentscope.message import ToolResultState
from... | 121 | 3,510 |
QwenPaw | src/qwenpaw/agents/tools/desktop_screenshot.py | .py | # -*- coding: utf-8 -*-
"""Desktop/screen screenshot tool."""
import json
import os
import platform
import time
import mimetypes
from agentscope.message import DataBlock, TextBlock, URLSource
from agentscope.tool import ToolChunk
from agentscope.message import ToolResultState
from ...config.context import get_current... | 198 | 6,261 |
QwenPaw | src/qwenpaw/agents/tools/web_search.py | .py | # -*- coding: utf-8 -*-
# flake8: noqa: E501
# pylint: disable=line-too-long
"""Web search and fetch tools.
web_search uses Tavily keyless API.
web_fetch uses direct HTTP GET + html2text.
"""
import logging
import re
import ssl
from urllib.parse import urlparse
import html2text
import httpx
from agentscope.message... | 332 | 10,178 |
QwenPaw | src/qwenpaw/agents/tools/lsp_tool.py | .py | # -*- coding: utf-8 -*-
"""LSP tool — single ``lsp`` function with operation dispatch.
Built dynamically by :func:`make_lsp_tool` so the agent only sees the
languages whose servers were discovered at toolkit-creation time
(see PROPOSAL §3.2). Unsupported languages return an error string
that nudges the agent toward `... | 281 | 9,765 |
QwenPaw | src/qwenpaw/agents/tools/file_search.py | .py | # -*- coding: utf-8 -*-
# flake8: noqa: E501
# pylint: disable=line-too-long
"""File search tools: grep (content search) and glob (file discovery)."""
import asyncio
import fnmatch
import os
import re
import threading
from collections import deque
from pathlib import Path
from typing import Optional
from agentscope.m... | 791 | 25,161 |
QwenPaw | src/qwenpaw/agents/tools/agent_management.py | .py | # -*- coding: utf-8 -*-
"""Tools and shared helpers for agent discovery and inter-agent chat."""
import asyncio
import json
import logging
import math
import re
import time
from typing import Any, Callable, Dict, Optional
from uuid import uuid4
import httpx
from agentscope.message import TextBlock
from agentscope.too... | 1,655 | 55,542 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.