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/utils/port.py
.py
# -*- coding: utf-8 -*- """Port persistence utilities for desktop backends. Provides helpers to persist and reuse the backend port across restarts so that the browser origin (http://127.0.0.1:{port}) stays stable and localStorage data (selected agent, plugin flags, etc.) survives. Supports user-configured fixed ports...
177
6,010
QwenPaw
src/qwenpaw/utils/json_utils.py
.py
# -*- coding: utf-8 -*- """JSON utilities with corruption recovery.""" import json import logging logger = logging.getLogger(__name__) _NOT_DICT_MSG = "File %s parsed as %s, not dict; returning {}." _NOT_DICT_RAW_MSG = "File %s raw_decode recovered %s, not dict; returning {}." def safe_json_loads(content: str, file...
67
2,088
QwenPaw
src/qwenpaw/utils/__init__.py
.py
# -*- coding: utf-8 -*- from .system_info import ( get_architecture, get_cuda_version, get_memory_size_gb, get_os_name, get_system_info, get_vram_size_gb, ) __all__ = [ "get_architecture", "get_cuda_version", "get_memory_size_gb", "get_os_name", "get_system_info", "get_v...
19
336
QwenPaw
src/qwenpaw/utils/tool_call_extra.py
.py
# -*- coding: utf-8 -*- """Persist provider-specific tool-call fields without extending AgentScope. AgentScope's ``ToolCallBlock`` is a strict Pydantic model, so provider extensions such as Gemini's ``extra_content`` cannot be assigned as normal fields. The stream parser attaches the extension transiently, and ``Qwen...
130
4,530
QwenPaw
src/qwenpaw/utils/http.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import ipaddress from urllib.parse import urlparse _LOOPBACK_HOSTNAMES = {"localhost"} # Wildcard bind addresses mapped to the loopback address of the same # address family. Winsock rejects ``INADDR_ANY`` and ``in6addr_any`` as # ``connect`` targets with ``W...
52
1,812
QwenPaw
src/qwenpaw/utils/system_info.py
.py
# -*- coding: utf-8 -*- """Helpers for collecting normalized system hardware information.""" from __future__ import annotations import ctypes import os import platform import re import subprocess import sys from collections.abc import Mapping from typing import Any _BYTES_PER_GB = float(1024**3) _CUDA_VERSION_PATTER...
255
7,354
QwenPaw
src/qwenpaw/utils/platform.py
.py
# -*- coding: utf-8 -*- """Platform-specific utility helpers.""" from __future__ import annotations import logging import sys logger = logging.getLogger(__name__) def is_windows_admin() -> bool: """Return True if the current Windows process has admin privileges. On non-Windows platforms, returns True (not...
65
2,100
QwenPaw
src/qwenpaw/utils/console_static.py
.py
# -*- coding: utf-8 -*- """Resolve the web console static assets directory (shared by app and CLI).""" from __future__ import annotations import os from pathlib import Path from ..constant import EnvVarLoader # Primary env key (``COPAW_CONSOLE_STATIC_DIR`` is accepted as a legacy # fallback via :class:`~qwenpaw.cons...
70
2,328
QwenPaw
src/qwenpaw/utils/io_utils.py
.py
# -*- coding: utf-8 -*- """Async and atomic filesystem utilities. Choose an API by the required filesystem semantics: * Use :func:`read_text_async` or :func:`read_bytes_async` for standalone reads. * Use :func:`append_text_async` when content must remain in the same file and replacing the whole file would be inco...
508
15,318
QwenPaw
src/qwenpaw/utils/startup_display.py
.py
# -*- coding: utf-8 -*- """Fancy startup display utilities using rich.""" import logging from typing import Optional, Tuple, cast from rich import box from rich.console import Console, Group from rich.file_proxy import FileProxy from rich.live import Live from rich.panel import Panel from rich.progress import ( Ba...
310
9,822
QwenPaw
src/qwenpaw/utils/model_response.py
.py
# -*- coding: utf-8 -*- """Read text out of a chat-model response, defensively. ``agentscope.model.ChatResponse`` extends ``dict`` with ``__getattr__ = dict.__getitem__``, so ``getattr(resp, "text", None)`` raises ``KeyError`` instead of defaulting — and providers differ over whether a reply is a single response or a ...
80
2,569
QwenPaw
src/qwenpaw/utils/stdio.py
.py
# -*- coding: utf-8 -*- """Helpers for sanitizing process standard streams.""" from __future__ import annotations import atexit import os import sys from typing import TextIO, cast _FALLBACK_STREAMS: list[TextIO] = [] _FALLBACK_STREAMS_BY_ENCODING: dict[str, TextIO] = {} _FALLBACK_CLEANUP_REGISTERED = False def en...
88
2,130
QwenPaw
src/qwenpaw/cli/mission_cmd.py
.py
# -*- coding: utf-8 -*- """CLI entry for Mission Mode — ``qwenpaw mission``.""" from __future__ import annotations import click from .http import client, print_json, resolve_base_url @click.group("mission") def mission_group(): """Mission Mode — autonomous iterative agent for complex tasks.""" @mission_group....
87
2,508
QwenPaw
src/qwenpaw/cli/main.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import logging from pathlib import Path import sys import time import click from ..utils.stdio import ensure_standard_streams # On Windows, force UTF-8 for stdout/stderr so cron and other commands # can handle Chinese and other non-ASCII (Linux is UTF-8 by ...
220
7,775
QwenPaw
src/qwenpaw/cli/utils.py
.py
# -*- coding: utf-8 -*- """Shared interactive prompt helpers used by CLI commands. All terminal interaction with *questionary* is centralised here so that the rest of the CLI code never imports questionary directly. """ from __future__ import annotations from pathlib import Path from typing import Optional import cli...
226
6,652
QwenPaw
src/qwenpaw/cli/doctor_registry.py
.py
# -*- coding: utf-8 -*- """Extensible hooks for `qwenpaw doctor` (entry points + programmatic registration). Plugins can expose a setuptools entry point in group ``qwenpaw.doctor``:: [project.entry-points."qwenpaw.doctor"] my_pkg = "my_pkg.doctor:doctor_notes" The group ``copaw.doctor`` is still discovered w...
126
3,774
QwenPaw
src/qwenpaw/cli/env_cmd.py
.py
# -*- coding: utf-8 -*- """CLI commands for environment variable management.""" from __future__ import annotations import click from ..envs import load_envs, set_env_var, delete_env_var @click.group("env") def env_group() -> None: """Manage environment variables.""" # -----------------------------------------...
99
2,667
QwenPaw
src/qwenpaw/cli/doctor_checks.py
.py
# -*- coding: utf-8 -*- """Read-only diagnostics for `qwenpaw doctor` (no config or disk mutations).""" from __future__ import annotations # pylint: disable=too-many-branches,too-many-statements # pylint: disable=too-many-return-statements import asyncio import json import ntpath import os import platform import subp...
1,312
46,486
QwenPaw
src/qwenpaw/cli/app_cmd.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import logging import os import click import uvicorn from ..app.auth import is_auth_enabled from ..browser.control_link.chrome.protocol import NM_MAX_INBOUND_BYTES from ..config.utils import write_last_api from ..constant import LOG_LEVEL_ENV from ..utils.ht...
164
5,110
QwenPaw
src/qwenpaw/cli/doctor_cmd.py
.py
# -*- coding: utf-8 -*- """`qwenpaw doctor` — read-only checks. `qwenpaw doctor fix` — conservative repairs with backup. """ from __future__ import annotations # pylint: disable=too-many-branches,too-many-statements import asyncio import json import os import sys from pathlib import Path import click import httpx ...
1,090
37,516
QwenPaw
src/qwenpaw/cli/providers_cmd.py
.py
# -*- coding: utf-8 -*- """CLI commands for managing LLM providers.""" from __future__ import annotations import asyncio import time from typing import Optional import click from qwenpaw.exceptions import ( AppBaseException, ) from ..providers.provider import ModelInfo, Provider, ProviderInfo from ..providers.p...
831
26,674
QwenPaw
src/qwenpaw/cli/shutdown_cmd.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import os import signal import subprocess import sys import time from pathlib import Path from typing import Optional import click from .process_utils import ( _is_qwenpaw_wrapper_process, _process_table, _windows_process_snapshot, ) _PROJECT_R...
386
11,386
QwenPaw
src/qwenpaw/cli/doctor_connectivity.py
.py
# -*- coding: utf-8 -*- """Optional ``--deep`` network reachability checks for enabled channels. Failures are reported as non-fatal notes (firewalls and offline use are common). Built-in probes live here; custom channels can override :class:`~qwenpaw.app.channels.base.BaseChannel`.doctor_connectivity_notes. """ from _...
362
10,485
QwenPaw
src/qwenpaw/cli/agents_cmd.py
.py
# -*- coding: utf-8 -*- """CLI commands for managing agents and inter-agent communication.""" # pylint:disable=too-many-branches,too-many-statements from __future__ import annotations import shutil from pathlib import Path from typing import Optional, Dict, Any import click import httpx from ..agents.tools import ag...
970
28,375
QwenPaw
src/qwenpaw/cli/channels_cmd.py
.py
# -*- coding: utf-8 -*- """CLI channel: list and interactively configure channels in config.json.""" from __future__ import annotations import asyncio from types import SimpleNamespace from typing import Optional import click from fastapi import FastAPI from qwenpaw.exceptions import ( AppBaseException, ) from ....
1,034
29,418
QwenPaw
src/qwenpaw/cli/uninstall_cmd.py
.py
# -*- coding: utf-8 -*- """qwenpaw uninstall — remove the QwenPaw environment and CLI wrapper.""" from __future__ import annotations import shutil import re from pathlib import Path import click from ..constant import WORKING_DIR # Directories created by the installer (relative to WORKING_DIR). _INSTALLER_DIRS = (...
90
2,357
QwenPaw
src/qwenpaw/cli/chats_cmd.py
.py
# -*- coding: utf-8 -*- """CLI commands for managing chats via HTTP API (/chats).""" from __future__ import annotations import json from pathlib import Path from typing import Optional import click from .http import client, print_json, resolve_base_url from ..app.channels.schema import DEFAULT_CHANNEL @click.group...
276
7,333
QwenPaw
src/qwenpaw/cli/http.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import json from typing import Any, Optional import click import httpx from ..utils.http import trust_env_for_url DEFAULT_BASE_URL = "http://127.0.0.1:8088" def client(base_url: str) -> httpx.Client: """Create HTTP client with /api prefix added to al...
50
1,239
QwenPaw
src/qwenpaw/cli/acp_cmd.py
.py
# -*- coding: utf-8 -*- """``qwenpaw acp`` — run QwenPaw as an ACP agent over stdio.""" from __future__ import annotations import asyncio import logging import click @click.command("acp") @click.option( "--agent", default=None, help="Agent ID to use (defaults to active agent)", ) @click.option( "--w...
85
2,109
QwenPaw
src/qwenpaw/cli/skills_cmd.py
.py
# -*- coding: utf-8 -*- """CLI skill: list, inspect, and interactively configure workspace skills.""" from __future__ import annotations import asyncio from pathlib import Path import click from ..agents.skill_system import ( SkillConflictError, SkillPoolService, SkillService, get_workspace_skills_di...
572
18,115
QwenPaw
src/qwenpaw/cli/update_cmd.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import json import os import signal import shutil import subprocess import sys import time from dataclasses import asdict, dataclass from importlib import metadata from pathlib import Path from typing import Any from urllib.parse import urlparse import click ...
781
23,934
QwenPaw
src/qwenpaw/cli/auth_cmd.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import secrets import click from ..app.auth import ( _hash_password, _load_auth_data, _save_auth_data, is_auth_enabled, ) @click.group("auth", help="Manage web authentication.") def auth_group() -> None: """Manage web authentication."""...
67
1,692
QwenPaw
src/qwenpaw/cli/process_utils.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import csv import io import json import re import subprocess import sys from typing import Optional _PORT_ARG_PATTERN = re.compile(r"(?:^|\s)--port(?:=|\s+)(\d+)(?=\s|$)") def _coerce_optional_int(value: object) -> Optional[int]: """Best-effort convers...
237
6,893
QwenPaw
src/qwenpaw/cli/init_cmd.py
.py
# -*- coding: utf-8 -*- # flake8: noqa: E501 """CLI init: interactively create working_dir config.json and HEARTBEAT.md.""" from __future__ import annotations from pathlib import Path import click from rich.console import Console from rich.panel import Panel from .channels_cmd import configure_channels_interactive f...
531
18,782
QwenPaw
src/qwenpaw/cli/plugin_commands.py
.py
# -*- coding: utf-8 -*- # pylint:disable=too-many-return-statements,too-many-branches # pylint:disable=too-many-statements """Plugin management CLI commands.""" import json import logging import os import shutil import subprocess import sys import tempfile import urllib.error import urllib.request import zipfile from ...
894
27,826
QwenPaw
src/qwenpaw/cli/clean_cmd.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import shutil from pathlib import Path import click from ..constant import WORKING_DIR from ..utils.telemetry import TELEMETRY_MARKER_FILE def _iter_children(p: Path) -> list[Path]: if not p.exists(): return [] return sorted(list(p.iterdir(...
77
2,009
QwenPaw
src/qwenpaw/cli/cron_cmd.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import copy import json from pathlib import Path from typing import Any, Dict, Optional import click from .http import client, print_json from ..app.channels.schema import DEFAULT_CHANNEL def _base_url(ctx: click.Context, base_url: Optional[str]) -> str: ...
1,071
30,945
QwenPaw
src/qwenpaw/cli/daemon_cmd.py
.py
# -*- coding: utf-8 -*- """CLI daemon subcommands: status, restart, reload-config, version, logs. Shares execution with in-chat /daemon <sub> via daemon_commands. """ from __future__ import annotations import asyncio from pathlib import Path import click from ..runtime.commands.daemon import ( DaemonContext, ...
117
3,027
QwenPaw
src/qwenpaw/cli/task_cmd.py
.py
# -*- coding: utf-8 -*- from __future__ import annotations import asyncio import json import logging import sys import tempfile import time from contextlib import contextmanager from pathlib import Path from typing import Iterator import click logger = logging.getLogger(__name__) _SKILL_FS_NAMES = {"skills", "skil...
313
9,215
QwenPaw
src/qwenpaw/cli/doctor_fix_runner.py
.py
# -*- coding: utf-8 -*- """Conservative filesystem repairs for ``qwenpaw doctor fix``. Backup, allowlist, atomic write. Includes ``reconcile-workspace-skills``, which calls the same ``reconcile_workspace_manifest`` as the app (CLI-only, no server). ``rebuild-console-npm`` runs ``npm ci && npm run build`` under ``cons...
848
28,497
QwenPaw
src/qwenpaw/cli/desktop_cmd.py
.py
# -*- coding: utf-8 -*- """CLI command: run QwenPaw app on a free port in a native webview window.""" # pylint:disable=too-many-branches,too-many-statements,consider-using-with from __future__ import annotations import json import logging import os import socket import subprocess import sys import threading import ti...
393
14,009
QwenPaw
src/qwenpaw/cli/tui/normalize.py
.py
# -*- coding: utf-8 -*- """Translate ACP ``session_update`` objects into normalized ``TuiEvent``s. Kept free of Textual and of the connection runtime so it is trivially unit-testable (see ``tests/cli/test_tui_normalize.py``). The shapes here match the ``acp.schema`` types verified against ``agent-client-protocol`` 0.9...
313
11,142
QwenPaw
src/qwenpaw/cli/tui/app.py
.py
# -*- coding: utf-8 -*- """The paw terminal chat application (Textual).""" from __future__ import annotations import base64 import binascii import json import mimetypes import os import re import shlex import shutil from dataclasses import dataclass from pathlib import Path from urllib.parse import unquote, urlparse ...
1,452
54,150
QwenPaw
src/qwenpaw/cli/tui/__init__.py
.py
# -*- coding: utf-8 -*- """QwenPaw terminal chat UI (TUI). A Textual front-end, bundled into QwenPaw, that drives the agent over ACP by spawning ``qwenpaw acp`` as a subprocess. The UI layer only ever sees the normalized :class:`~qwenpaw.cli.tui.transport.base.TuiTransport` interface and the :mod:`~qwenpaw.cli.tui.eve...
24
792
QwenPaw
src/qwenpaw/cli/tui/themes.py
.py
# -*- coding: utf-8 -*- """Fun terminal theme gallery for QwenPaw.""" from __future__ import annotations from dataclasses import dataclass @dataclass(frozen=True) class ThemeInfo: id: str name: str emoji: str prompt: str screen: str prompt_bg: str chrome: str accent: str text: st...
176
4,001
QwenPaw
src/qwenpaw/cli/tui/__version__.py
.py
# -*- coding: utf-8 -*- __version__ = "0.1.0"
3
46
QwenPaw
src/qwenpaw/cli/tui/compat.py
.py
# -*- coding: utf-8 -*- """Compatibility fixes for Textual releases supported by the TUI.""" from __future__ import annotations from typing import Any from textual.screen import Screen _ORIGINAL_GET_WIDGET_AND_OFFSET_AT = Screen.get_widget_and_offset_at _COMPAT_APPLIED = False def _safe_get_widget_and_offset_at(...
43
1,310
QwenPaw
src/qwenpaw/cli/tui/paths.py
.py
# -*- coding: utf-8 -*- """Where paw keeps its own state (logs, etc.). Self-owned so paw never depends on QwenPaw's working dir. Honors ``PAW_STATE_DIR`` and ``XDG_STATE_HOME``; falls back to a platform default. """ from __future__ import annotations import os import sys from pathlib import Path def state_dir() ->...
35
1,048
QwenPaw
src/qwenpaw/cli/tui/launch.py
.py
# -*- coding: utf-8 -*- """Launch the QwenPaw TUI. ``qwenpaw`` open an interactive chat with the active agent ``qwenpaw tui`` same, with explicit options ``qwenpaw tui --agent NAME`` chat with a specific agent ``qwenpaw tui --resume ID`` resume a previous session and continue it ...
235
7,133
QwenPaw
src/qwenpaw/cli/tui/events.py
.py
# -*- coding: utf-8 -*- """Normalized TUI event types. The ACP subprocess transport translates its wire format into this small union so the UI layer is transport-agnostic. This is the ``TuiEvent`` contract referenced in the design doc (§4.2/§4.3). """ from __future__ import annotations from dataclasses import datacl...
228
5,316
QwenPaw
src/qwenpaw/cli/tui/widgets/permission_modal.py
.py
# -*- coding: utf-8 -*- """Modal overlay for tool-permission requests.""" from __future__ import annotations from textual.app import ComposeResult from textual.containers import Vertical from textual.screen import ModalScreen from textual.widgets import Button, Static from ..events import PermissionRequest # allow_...
66
2,068
QwenPaw
src/qwenpaw/cli/tui/widgets/tool_panel.py
.py
# -*- coding: utf-8 -*- """Collapsible tool-call panel (merges start + update by tool_call_id). The panel is expanded while the tool is pending/running so the user can watch it, then auto-collapses to a one-line summary once it completes or fails. The header (status, title, params summary) stays visible; the body — la...
183
6,325
QwenPaw
src/qwenpaw/cli/tui/widgets/__init__.py
.py
# -*- coding: utf-8 -*- """Textual widgets for the QwenPaw TUI.""" from __future__ import annotations from .command_menu import CommandMenu, CommandSuggester, PromptInput from .messages import ( ActivityLine, AgentLabel, AssistantMessage, ErrorMessage, FileLinkBox, InfoMessage, PushMessage...
49
1,072
QwenPaw
src/qwenpaw/cli/tui/widgets/theme_picker.py
.py
# -*- coding: utf-8 -*- """Theme gallery picker.""" from __future__ import annotations from rich.text import Text from textual import events from textual.app import ComposeResult from textual.binding import Binding from textual.containers import Vertical from textual.screen import ModalScreen from textual.widgets imp...
144
4,597
QwenPaw
src/qwenpaw/cli/tui/widgets/status_bar.py
.py
# -*- coding: utf-8 -*- """Top status bar: agent, model, session, token usage, busy state.""" from __future__ import annotations from rich.text import Text from textual.widgets import Static from ._anim import TICK, pulse, spinner # Public field name -> internal attribute. Internal names are namespaced with # ``_sb...
249
9,446
QwenPaw
src/qwenpaw/cli/tui/widgets/messages.py
.py
# -*- coding: utf-8 -*- """Transcript message widgets (user / assistant / thinking / errors).""" from __future__ import annotations import math import time from rich.text import Text from textual.app import ComposeResult from textual.widget import Widget from textual.widgets import Collapsible, Markdown, Static fro...
656
22,498
QwenPaw
src/qwenpaw/cli/tui/widgets/session_picker.py
.py
# -*- coding: utf-8 -*- """Picker for resuming a previous session.""" from __future__ import annotations from datetime import datetime, timezone from rich.text import Text from textual import events from textual.app import ComposeResult from textual.binding import Binding from textual.containers import Vertical from...
165
5,350
QwenPaw
src/qwenpaw/cli/tui/widgets/permission_overlay.py
.py
# -*- coding: utf-8 -*- """Inline overlay for tool-permission requests.""" from __future__ import annotations import math import time from rich.text import Text from textual.widgets import OptionList from textual.widgets.option_list import Option from ..events import PermissionRequest _MAX_PARAM_LINES = 6 _MAX_PAR...
261
8,113
QwenPaw
src/qwenpaw/cli/tui/widgets/command_menu.py
.py
# -*- coding: utf-8 -*- """Slash-command auto-suggestion: an inline ghost completion plus a filtered dropdown list. The agent advertises its commands over ACP (``available_commands_update``); :class:`CommandSuggester` drives the single inline ghost completion on the ``TextArea`` and :class:`CommandMenu` renders the na...
263
8,657
QwenPaw
src/qwenpaw/cli/tui/widgets/_anim.py
.py
# -*- coding: utf-8 -*- """Tiny animation helpers shared by live widgets (thinking lane, running tool panels): a braille spinner and a pulsing blue→purple colour cycle. Frame-indexed so callers just keep a counter and tick it on a timer.""" from __future__ import annotations # Braille spinner frames (smooth, monospa...
34
859
QwenPaw
src/qwenpaw/cli/tui/widgets/_format.py
.py
# -*- coding: utf-8 -*- """Text-formatting helpers shared by the transcript widgets.""" from __future__ import annotations # One-line param summaries (panel titles, the activity line) cap here. _SUMMARY_LIMIT = 72 def summarize_params(params: str | None, limit: int = _SUMMARY_LIMIT) -> str: """A compact one-lin...
21
724
QwenPaw
src/qwenpaw/cli/tui/transport/__init__.py
.py
# -*- coding: utf-8 -*- """TUI transports: ACP subprocess.""" from __future__ import annotations from .base import TuiTransport __all__ = ["TuiTransport"]
9
158
QwenPaw
src/qwenpaw/cli/tui/transport/acp.py
.py
# -*- coding: utf-8 -*- """Default TUI transport: drive ``qwenpaw acp`` over ACP/stdio. The transport spawns ``qwenpaw acp`` as a subprocess and connects an ACP client to it (the same ``spawn_agent_process`` plumbing the in-process ACP service uses, see ``qwenpaw/agents/acp/service.py``). All agent capabilities — tool...
729
26,681
QwenPaw
src/qwenpaw/cli/tui/transport/base.py
.py
# -*- coding: utf-8 -*- """The transport interface shared by all TUI back-ends.""" from __future__ import annotations from typing import AsyncIterator, Protocol, runtime_checkable from ..events import Connected, SessionSummary, TuiEvent @runtime_checkable class TuiTransport(Protocol): """Drives one agent conve...
46
1,489
QwenPaw
src/qwenpaw/envs/store.py
.py
# -*- coding: utf-8 -*- """Reading and writing environment variables. Persistence strategy (two layers): 1. **envs.json** – canonical store, survives process restarts. 2. **os.environ** – injected into the current Python process so that ``os.getenv()`` and child subprocesses (``subprocess.run``, etc.) can read ...
270
7,763
QwenPaw
src/qwenpaw/envs/__init__.py
.py
# -*- coding: utf-8 -*- """Environment variable management.""" from .store import ( delete_env_var, load_envs, load_envs_into_environ, save_envs, set_env_var, ) __all__ = [ "delete_env_var", "load_envs", "load_envs_into_environ", "save_envs", "set_env_var", ]
18
301
QwenPaw
src/qwenpaw/checkpoints/render.py
.py
# -*- coding: utf-8 -*- """Markdown rendering for checkpoint command results.""" from __future__ import annotations from datetime import datetime from .policy import ref_display_name, ref_kind, ref_session_key from .models import CheckpointEntry, GcResult, RestoreResult def render_timeline( entries: list[Check...
310
10,266
QwenPaw
src/qwenpaw/checkpoints/repository.py
.py
# -*- coding: utf-8 -*- """Shadow Git persistence and restore orchestration.""" from __future__ import annotations import hashlib import os import shutil import stat import subprocess from pathlib import Path from ..utils.io_utils import read_json, write_json_atomic, write_text_atomic from .policy import ( DEFAU...
480
17,506
QwenPaw
src/qwenpaw/checkpoints/runtime.py
.py
# -*- coding: utf-8 -*- """Workspace service lifecycle and automatic snapshot scheduling.""" from __future__ import annotations import asyncio import logging import threading import time from pathlib import Path from typing import Any, Callable, Coroutine from ..utils.io_utils import run_sync_io from .policy import ...
322
11,005
QwenPaw
src/qwenpaw/checkpoints/models.py
.py
# -*- coding: utf-8 -*- """Data models and the shared error type for the checkpoints subsystem.""" from __future__ import annotations from dataclasses import dataclass class CheckpointError(RuntimeError): """Raised when a checkpoint operation cannot complete.""" @dataclass(frozen=True) class CheckpointEntry: ...
80
1,837
QwenPaw
src/qwenpaw/checkpoints/restore.py
.py
# -*- coding: utf-8 -*- """Transactional restore orchestration for checkpoints.""" from __future__ import annotations import asyncio import logging import os from collections.abc import Callable from dataclasses import dataclass from pathlib import Path from pathlib import PurePosixPath from typing import TYPE_CHECKI...
759
25,597
QwenPaw
src/qwenpaw/checkpoints/tree_entries.py
.py
# -*- coding: utf-8 -*- """Git tree entry metadata used by checkpoint restore.""" from __future__ import annotations from dataclasses import dataclass from .models import CheckpointError REGULAR_TREE_MODES = {"100644": 0o644, "100755": 0o755} SYMLINK_TREE_MODE = "120000" _RESTORABLE_TREE_MODES = frozenset( {*RE...
61
1,665
QwenPaw
src/qwenpaw/checkpoints/policy.py
.py
# -*- coding: utf-8 -*- """Checkpoint configuration, identity rules, and snapshot boundaries.""" from __future__ import annotations import shutil import re import hashlib import json import unicodedata from pathlib import Path from typing import Any, TypeVar, cast from ..utils.io_utils import get_sync_path_lock, wri...
598
18,918
QwenPaw
src/qwenpaw/checkpoints/git_batch.py
.py
# -*- coding: utf-8 -*- """Scoped reader for Git's long-lived ``cat-file --batch`` protocol.""" from __future__ import annotations import subprocess import threading from contextlib import contextmanager from collections.abc import Iterator, Mapping, Sequence from pathlib import Path from types import TracebackType f...
288
9,361
QwenPaw
src/qwenpaw/checkpoints/__init__.py
.py
# -*- coding: utf-8 -*- """QwenPaw 2.0 built-in conversation checkpoints. A workspace-scoped shadow Git store under ``checkpoints/`` supports optional automatic snapshots and exposes timeline / snapshot / restore / gc / reset through the ``/checkpoint`` slash command. This package is 2.0-only and does not read legacy...
38
912
QwenPaw
src/qwenpaw/checkpoints/hooks.py
.py
# -*- coding: utf-8 -*- """Runtime hooks for built-in conversation checkpoints.""" from __future__ import annotations import logging from ..hooks.base import LifecycleHook from ..hooks.session.signals import SESSION_SAVE_SUCCEEDED_KEY from ..runtime.hooks import HookContext, HookResult from ..runtime.phases import P...
89
2,682
QwenPaw
src/qwenpaw/checkpoints/safe_workspace_fs.py
.py
# -*- coding: utf-8 -*- """Safe, byte-preserving filesystem operations for checkpoint restore.""" from __future__ import annotations import os import stat import tempfile from io import BytesIO from pathlib import Path from typing import Protocol from .models import CheckpointError from .tree_entries import REGULAR_...
431
15,511
QwenPaw
src/qwenpaw/checkpoints/service.py
.py
# -*- coding: utf-8 -*- """Checkpoint application service: snapshot, timeline, GC, and reset.""" # Synchronous Git helpers run through run_sync_io. # pylint: disable=too-many-arguments # pylint: disable=too-many-public-methods from __future__ import annotations import asyncio import logging import time import weakre...
1,005
31,348
QwenPaw
src/qwenpaw/browser/handoff_signal.py
.py
# -*- coding: utf-8 -*- """Process-local browser handoff signals consumed by the ReAct loop.""" from __future__ import annotations _PENDING: dict[str, dict[str, str]] = {} def set_pending(session_id: str, info: dict[str, str]) -> None: """Record a browser handoff until the stop gate consumes it.""" _PENDING...
22
654
QwenPaw
src/qwenpaw/browser/errors.py
.py
# -*- coding: utf-8 -*- """Unified browser error contracts and classification.""" from __future__ import annotations from dataclasses import dataclass from enum import StrEnum from .governance.error_codes import BrowserErrorCode class ErrorCategory(StrEnum): """Closed set of recovery categories for browser fai...
130
3,831
QwenPaw
src/qwenpaw/browser/__init__.py
.py
# -*- coding: utf-8 -*- """Core browser-control abstractions.""" from typing import TYPE_CHECKING if TYPE_CHECKING: from .sdk.facade import Browser from .sdk.page import Page __all__ = ["Browser", "Page"] def __getattr__(name: str) -> object: """Lazily expose the SDK entrypoints from the package path (...
28
729
QwenPaw
src/qwenpaw/browser/tool_entrypoint.py
.py
# -*- coding: utf-8 -*- """Wire-only control-plane entrypoint for the Browser SDK tool.""" from __future__ import annotations import atexit import hashlib import logging import uuid from pathlib import Path from typing import Any from agentscope.message import TextBlock, ToolResultState from agentscope.tool import T...
204
7,171
QwenPaw
src/qwenpaw/browser/_proc.py
.py
# -*- coding: utf-8 -*- """Shared synchronous process lifecycle helpers for browser resources.""" from __future__ import annotations import contextlib from typing import Any def _alive(proc: Any) -> bool: """Return whether either supported process family is still running.""" poll = getattr(proc, "poll", Non...
42
1,284
QwenPaw
src/qwenpaw/browser/governance/error_codes.py
.py
# -*- coding: utf-8 -*- """Stable browser error codes (core source of truth).""" from enum import StrEnum class BrowserErrorCode(StrEnum): """Error codes shared by browser transport implementations.""" UNKNOWN = "unknown" BRIDGE_DISCONNECTED = "bridge_disconnected" BRIDGE_REQUEST_TIMEOUT = "bridge_r...
19
555
QwenPaw
src/qwenpaw/browser/governance/__init__.py
.py
# -*- coding: utf-8 -*- """Browser governance primitives."""
3
61
QwenPaw
src/qwenpaw/browser/control_link/cdp_tree.py
.py
# -*- coding: utf-8 -*- """Shared pure CDP accessibility/DOM tree projection helpers.""" from __future__ import annotations from dataclasses import dataclass import json import re from typing import Any, Mapping, Sequence from ..errors import BrowserError, ErrorCause, ErrorCategory _ATTR_WHITELIST = frozenset( ...
438
14,608
QwenPaw
src/qwenpaw/browser/control_link/__init__.py
.py
# -*- coding: utf-8 -*- """Browser variant control-link packages.""" _registered = False def register_builtin_control_links() -> None: """Idempotently self-register first-party control links.""" global _registered if _registered: return from .chrome.adapter import register as register_chrome ...
20
533
QwenPaw
src/qwenpaw/browser/control_link/identity.py
.py
# -*- coding: utf-8 -*- """Strict wire-level ownership identity helpers.""" from __future__ import annotations from typing import Any, Mapping from ..errors import BrowserError, ErrorCause, ErrorCategory OwnerKey = tuple[str, str] def require_owner(params: Mapping[str, Any]) -> OwnerKey: """Return a complete ...
28
894
QwenPaw
src/qwenpaw/browser/control_link/cdp_verbs.py
.py
# -*- coding: utf-8 -*- """Shared implementations for links backed by Chrome DevTools Protocol.""" from __future__ import annotations import asyncio import base64 import hashlib import json import time from pathlib import Path from typing import Any, Mapping from ...config.context import get_current_workspace_dir fr...
1,095
35,919
QwenPaw
src/qwenpaw/browser/control_link/chrome/state.py
.py
# -*- coding: utf-8 -*- """Native Messaging bridge route state.""" from __future__ import annotations from dataclasses import dataclass from pathlib import Path @dataclass class NMBridgeRouteState: """State shared by Chrome route module instances.""" token: str | None = None config_path: Path | None = ...
27
550
QwenPaw
src/qwenpaw/browser/control_link/chrome/bridge.py
.py
# -*- coding: utf-8 -*- # pylint:disable=too-many-public-methods """Native Messaging bridge state for Chrome browser control mode.""" from __future__ import annotations import asyncio import contextlib import inspect import json import logging from collections import defaultdict from collections.abc import Callable f...
864
30,476
QwenPaw
src/qwenpaw/browser/control_link/chrome/__init__.py
.py
# -*- coding: utf-8 -*- """Chrome control-link package placeholder."""
3
71
QwenPaw
src/qwenpaw/browser/control_link/chrome/protocol.py
.py
# -*- coding: utf-8 -*- """Frozen wire-protocol source-of-truth for the core Chrome backend.""" from __future__ import annotations from enum import StrEnum PROTOCOL_VERSION = 2 # Chrome Native Messaging hard limits. These are protocol facts, not tunables: # a message from the extension to the host may be up to 64 M...
129
4,509
QwenPaw
src/qwenpaw/browser/control_link/chrome/observe.py
.py
# -*- coding: utf-8 -*- """Connection observation for the core Chrome bridge.""" from __future__ import annotations import json import sys from datetime import UTC, datetime from pathlib import Path from time import perf_counter from typing import Any from fastapi import APIRouter, Query from ....config.utils impor...
386
12,834
QwenPaw
src/qwenpaw/browser/control_link/chrome/ws_handler.py
.py
# -*- coding: utf-8 -*- """Core Native Messaging WebSocket route for Chrome control links.""" # pylint: disable=too-many-branches,too-many-statements from __future__ import annotations import contextlib import json import logging import secrets from datetime import UTC, datetime from pathlib import Path from typing ...
304
9,916
QwenPaw
src/qwenpaw/browser/control_link/chrome/adapter.py
.py
# -*- coding: utf-8 -*- """Chrome ControlLink composed from Native Messaging ``tab.*`` commands.""" from __future__ import annotations import asyncio import base64 import contextlib import inspect import logging import uuid from typing import Any, Awaitable, Callable, Mapping from ...errors import BrowserError, Erro...
690
24,864
QwenPaw
src/qwenpaw/browser/control_link/injected/__init__.py
.py
# -*- coding: utf-8 -*- """Browser-side engine source bundled with the CDP control link.""" from pathlib import Path _ENGINE_SOURCE: str | None = None def get_engine_source() -> str: """Return the cached self-contained browser injection source.""" global _ENGINE_SOURCE if _ENGINE_SOURCE is None: ...
17
453
QwenPaw
src/qwenpaw/browser/control_link/cdp/transport.py
.py
# -*- coding: utf-8 -*- """Minimal WebSocket JSON-RPC transport for the Chrome DevTools Protocol.""" from __future__ import annotations import asyncio from typing import Any, Callable, Mapping from ...errors import BrowserError, ErrorCategory class CdpTransport: def __init__(self) -> None: self._ws: Any ...
131
4,729
QwenPaw
src/qwenpaw/browser/control_link/cdp/__init__.py
.py
# -*- coding: utf-8 -*- """Raw CDP ControlLink backend."""
3
59
QwenPaw
src/qwenpaw/browser/control_link/cdp/discovery.py
.py
# -*- coding: utf-8 -*- """Local endpoint discovery for debuggable CDP browsers.""" from __future__ import annotations import asyncio from typing import Any, Mapping import httpx _DEFAULT_PORT_MIN = 9222 _DEFAULT_PORT_MAX = 9232 _TARGET_FIELDS = ("id", "type", "url", "title", "webSocketDebuggerUrl") async def fet...
80
2,338