Skip to main content

Python convenience wrapper around the Rust xiaoguai CLI.

Project description

xiaoguai (Python wrapper)

pip install xiaoguai — a thin Python launcher that bundles the Rust xiaoguai CLI binary inside a platform-specific wheel.

On Debian 12 / Ubuntu 24 and other PEP 668 "externally-managed" systems, pip install into the system Python is blocked. Use pipx instead: sudo apt install -y pipx && pipx ensurepath && pipx install xiaoguai.

After install:

xiaoguai --help
xiaoguai chat --mock --prompt "hello"
xiaoguai doctor    # self-check: database / providers / Ollama / port

To keep xiaoguai serve running in the background across reboots: xiaoguai service install (systemd on Linux — needs sudo; a per-user launchd agent on macOS — no root).

The console script forwards every argument to the bundled native binary. There is no Python agent logic in this package — it exists so pip users have an install path alongside Cargo, Homebrew, and the standalone tarball.

Supported platforms

The CI matrix produces wheels for:

Target triple Wheel tag (approx.)
aarch64-apple-darwin macosx_11_0_arm64
x86_64-apple-darwin macosx_10_12_x86_64
x86_64-unknown-linux-gnu manylinux_2_28_x86_64
aarch64-unknown-linux-gnu manylinux_2_28_aarch64

Other platforms (Alpine / musl, Windows, FreeBSD) are out of scope for v1.1.7. Build from source instead:

cargo install --path crates/xiaoguai-cli

Offline hosts: the wheel bundles the native binary, so it installs without network on the target. Download it on a connected machine and carry it over:

pip download xiaoguai --no-deps --only-binary=:all: \
  --platform manylinux_2_28_x86_64 --python-version 3.12 -d ./offline
# transfer ./offline, then on the air-gapped host:
pip install --no-index ./offline/xiaoguai-*.whl

For the systemd/package route and the SEC-01 credential step, see Offline / air-gapped install.

HTTP client (wave-3)

pip install 'xiaoguai[client]' — adds xiaoguai.client.XiaoguaiClient, a synchronous HTTP client for the xiaoguai-api REST server (requires httpx>=0.25).

Note: the client snippets below predate the single-user pivot (DEC-033). The live API now serves on :7600 with optional HTTP Basic auth and no tenant scoping. The bundled binary launcher above is the supported path; treat these examples as illustrative pending a client refresh.

Covered endpoints (v1.2.x)

Domain Methods
HotL list_hotl_policies, create_hotl_policy, delete_hotl_policy
Outcomes record_outcome, outcomes_summary, outcomes_timeseries
Skills list_skill_catalog, list_installed_skills, install_skill, uninstall_skill

Quick start

from xiaoguai.client import XiaoguaiClient

with XiaoguaiClient("http://localhost:7600", token="my-bearer-token") as c:
    # HotL — boundary policy admin
    policy = c.create_hotl_policy(
        tenant_id="my-tenant-uuid",
        scope="llm_call",
        window_seconds=3600,
        max_count=100,
        escalate_to="ops@example.com",
    )
    policies = c.list_hotl_policies(tenant_id="my-tenant-uuid", scope="llm_call")
    c.delete_hotl_policy(policy.id)

    # Outcomes — ROI telemetry
    c.record_outcome(
        tenant_id="my-tenant",
        agent_name="sales-bot",
        kind="revenue_usd",
        value=1500.0,
        description="Closed enterprise deal",
    )
    summary = c.outcomes_summary(tenant_id="my-tenant", range="7d")
    ts = c.outcomes_timeseries(tenant_id="my-tenant", range="30d", kind="hours_saved")

    # Skills — pack marketplace
    catalog = c.list_skill_catalog()
    pack = c.install_skill(tenant_id="my-tenant", pack_slug="rag-legal")
    installed = c.list_installed_skills(tenant_id="my-tenant")
    c.uninstall_skill(pack.id)

Error handling

from xiaoguai.client import (
    XiaoguaiNotFoundError,
    XiaoguaiValidationError,
    XiaoguaiConflictError,
)

try:
    c.install_skill(tenant_id="t1", pack_slug="rag-legal")
except XiaoguaiConflictError:
    print("already installed")
except XiaoguaiNotFoundError:
    print("unknown pack slug")

Typed models

HotlPolicy, HotlVerdict, OutcomeRecord, OutcomeSummary, OutcomeTimeseries, InstalledSkillPack, SkillPackEntry — all frozen dataclasses with from_dict class methods.

Troubleshooting

If xiaoguai after a fresh install prints "native binary not bundled", the wheel matched on architecture but its package data is empty (rare — usually an sdist install rather than a wheel). Set XIAOGUAI_PY_DEBUG=1 to see the resolution path the launcher tried.

Documentation

Full documentation, configuration, and architecture notes live in the upstream repository — see the main README.

License

Apache-2.0. Same license as the upstream Rust project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

xiaoguai-1.34.3-py3-none-manylinux_2_28_x86_64.whl (9.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

xiaoguai-1.34.3-py3-none-manylinux_2_28_aarch64.whl (9.1 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

xiaoguai-1.34.3-py3-none-macosx_11_0_x86_64.whl (9.4 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

xiaoguai-1.34.3-py3-none-macosx_11_0_arm64.whl (8.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file xiaoguai-1.34.3-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xiaoguai-1.34.3-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 123124b3ef2ffa81fe6a07e9557cacff28ac5771a793a33f37416657a46c6145
MD5 be6d309b3f877ea4945e1497acde9e72
BLAKE2b-256 884e6052ae8e530c0c89889a43b3b29421d163c610f96ece983314a7e6e01001

See more details on using hashes here.

File details

Details for the file xiaoguai-1.34.3-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for xiaoguai-1.34.3-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 493403208467e677a3de728d84663ae0b9bd8039608cd078f51b8c9b51cfb5a5
MD5 959d9cc70964b3e115d96d57f1777fac
BLAKE2b-256 0fce9c2cc29fbd3b7d11d24eb0ed913760ad9f2e2ce368b4ddef41d90b20f24c

See more details on using hashes here.

File details

Details for the file xiaoguai-1.34.3-py3-none-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for xiaoguai-1.34.3-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a88da2e771d6d73790bbd69c55876b54ddcd062f946501a23fd9b1fa1aea4c88
MD5 4c1367c27c0d7a4e3d5dbe447251c780
BLAKE2b-256 76ab9e8b3626c6ceb1419dcad31d97f474bd49521e676b05e53173508569a867

See more details on using hashes here.

File details

Details for the file xiaoguai-1.34.3-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for xiaoguai-1.34.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e58ae02b671bff78dbc1e75e43e8e7f9e55ea55f02c0dcfb4c43f5f2f6635708
MD5 8ed0f3e52004e2dcbd1fe100176f337d
BLAKE2b-256 9c3d57cb51990502899f73df8381efc867fce291de795e14b39ac84b5ab919af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page