Metadata-Version: 2.4
Name: acps-scenario-buddy
Version: 1.0.0
Summary: An ACPs multi-agent companion for real-world English. A scenario NPC (waiter, hotel receptionist, doctor, passer-by) role-plays immersive dialogue; a Guide Agent supplies idiomatic rescue phrases the moment the learner gets stuck; a Culture Agent debriefs etiquette, tipping and small talk. Built on acps-sdk 2.1.0 with independent AIP v2 JSON-RPC services, ADP discovery, typed products and auditable task traces for travel, relocation and healthcare.
Author: ACPs Scenario Buddy Engineering
License-Expression: MIT
Project-URL: Homepage, https://pypi.org/project/acps-scenario-buddy/
Project-URL: Source, https://github.com/acps-labs/acps-scenario-buddy
Keywords: acps,acps-sdk,multi-agent,english-conversation,scenario-roleplay,travel-english,culture-etiquette
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: End Users/Desktop
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Education
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: acps-sdk==2.1.0
Requires-Dist: fastapi>=0.100.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: uvicorn>=0.27.0
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: ruff>=0.6.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"
Dynamic: license-file

# ACPs Scenario Buddy

**Scenario Buddy is a protocol-native multi-agent companion for real-world English.** An NPC Agent role-plays the waiter, hotel receptionist, doctor or passer-by; a Guide Agent steps in with immediately speakable rescue phrases when the learner stalls; a Culture Agent debriefs etiquette, tipping and small-talk norms after the scene.

The name joins **Scenario** (a concrete real-life setting such as ordering food, checking into a hotel, seeing a doctor or asking for directions) with **Buddy** (a companion that stays with the learner through the whole encounter rather than acting as a one-off quiz). Version **1.0.0** is a typed Python package and distributable wheel built on **`acps-sdk==2.1.0`**, not a notebook or a mocked chat script.

## Why it is useful

- **NPC Agent** opens the scene in character, tracks turn order, keeps the dialogue coherent, and flags hesitation it observes.
- **Guide Agent** receives the stalled utterance plus the NPC's last line and returns three contextual phrases with Chinese support and one delivery strategy.
- **Culture Agent** consumes the finished transcript and produces a structured briefing: etiquette, taboos, safe small talk, tipping and reusable patterns.
- **Scenario Leader** discovers skills through ADP, checks real HTTP heartbeats, orchestrates AIP v2 JSON-RPC tasks, routes rescues mid-turn, transfers typed memory and audits every stage transition.

The engine is deterministic and offline after installation: it needs no LLM key and makes no claim to be a calibrated speaking test. Every turn is reproducible, which makes the package suitable for classrooms, self-study routines and integration tests.

## Metadata description (under 500 characters)

> An ACPs multi-agent companion for real-world English. A scenario NPC (waiter, hotel receptionist, doctor, passer-by) role-plays immersive dialogue; a Guide Agent supplies idiomatic rescue phrases the moment the learner gets stuck; a Culture Agent debriefs etiquette, tipping and small talk. Built on acps-sdk 2.1.0 with independent AIP v2 JSON-RPC services, ADP discovery, typed products and auditable task traces for travel, relocation and healthcare.

## Collaboration architecture

```text
Learner turns
     │
     ▼
Scenario Leader ── ADP DiscoveryRequest + HTTP /healthz ──► Agent Registry
     │
     ├── AIP v2 JSON-RPC ──► NPC Agent
     │      opening → role-play turns → closing
     │
     ├── AIP v2 JSON-RPC (only when stuck) ──► Guide Agent
     │      trigger + stalled utterance + NPC line → 3 rescue phrases
     │
     ├── AIP v2 JSON-RPC + full transcript ──► Culture Agent
     │      etiquette + taboos + small talk + tipping
     │
     └── non-empty END_SESSION broadcast + ControlAck from all agents
```

Every partner runs as an independent FastAPI/uvicorn service on an ephemeral loopback port. Commands and products use `acps-sdk==2.1.0` AIP models. Application envelopes carry validated `session_id`, `task_id`, `stage` and a non-empty typed payload; the stage machine rejects skipped or reversed phases.

## Project structure

```text
acps-scenario-buddy/
├── pyproject.toml                  # setuptools metadata, dependencies, CLI, tool config
├── README.md
├── LICENSE
├── .gitignore
├── examples/
│   └── restaurant_demo.py          # one-command public-API example
├── src/scenario_buddy/
│   ├── __init__.py                 # versioned public API
│   ├── __main__.py                 # python -m scenario_buddy
│   ├── py.typed                    # PEP 561 typing marker
│   ├── cli.py                      # scripted and interactive CLI
│   ├── demo.py                     # realistic four-turn fixtures per scenario
│   ├── leader.py                   # ADP discovery, AIP dispatch, rescue routing, fan-in
│   ├── mesh.py                     # lifecycle of three local partner services
│   ├── registry.py                 # ACS publication and ADP discovery
│   ├── runtime.py                  # AIP v2 JSON-RPC hosting and structured products
│   ├── protocol.py                 # message codec and four-stage state machine
│   ├── models.py                   # typed domain, wire and collaboration contracts
│   ├── identity.py                 # AIC identity helpers and project version
│   ├── scenarios.py                # NPC openings, turn replies and visible goals
│   ├── guide_bank.py               # stuck detection and contextual rescue phrases
│   ├── culture_bank.py             # curated cultural debriefs
│   ├── report.py                   # human-readable Markdown renderer
│   └── agents/
│       ├── base.py                 # shared AIP task lifecycle and control handling
│       ├── npc.py                  # in-character role-play partner
│       ├── guide.py                # just-in-time phrase rescue partner
│       └── culture.py              # post-scene cultural debrief partner
└── tests/
    └── test_scenario_buddy.py      # protocol, stuck detection and full-mesh integration
```

## Install and run

```bash
# from the repository root
python -m venv .venv
source .venv/bin/activate           # Windows: .venv\Scripts\activate
python -m pip install -e ".[dev]"

# one-command scripted restaurant demo
python -m scenario_buddy demo --scenario restaurant

# interactive practice (type your own English turns)
python -m scenario_buddy chat --scenario hotel

# or use the installed console script
scenario-buddy demo --scenario clinic --destination "Toronto, Canada"
```

The scripted demo needs no keyboard input. The `chat` command prompts for four turns and uses the same multi-agent pipeline.

### Expected demo excerpt

```text
[NPC Agent · opening]
Good evening, welcome to The Thames Bistro. Do you have a reservation?

[Learner · turn 2/4]
I want the... uh... the chicken thing. How do you say?

[Guide Agent · rescue for turn 2]
  Trigger: explicit help request: 'how do you say'
  1. Could I have the grilled chicken, please?
     请给我一份烤鸡，谢谢。 · Could I have… 是点餐最礼貌、最通用的句式。
  2. What would you recommend?
     您推荐什么？ · 不确定菜名时，把选择权交给服务员。
  3. Sorry, what do you call this dish in English?
     不好意思，这道菜英文怎么说？ · 直接问菜名，比沉默或只指菜单更自然。
  Tip: 用 'Could I have…' 代替 'I want…' 更礼貌；先报菜名，再回答熟度（medium / well done）。

[NPC Agent · turn 2]
The grilled chicken is an excellent choice. How would you like it cooked — medium or well done?

[Culture Agent] Debrief ready: 英式餐厅点餐：礼貌句式、出餐节奏与小费
```

The final report also contains the AIP task audit table, all four dialogue turns, the rescue log and the full cultural briefing.

## Programmatic API

```python
import asyncio

from scenario_buddy import LearnerProfile, LocalAgentMesh, Scenario, ScenarioSession


async def main() -> None:
    learner = LearnerProfile(
        name="Alex Chen",
        scenario=Scenario.RESTAURANT,
        destination="London, UK",
    )
    turns = [
        "Do you have a table for two, please?",
        "I want the... uh... the chicken thing.",
        "Medium, please. And a sparkling water.",
        "Could we have the bill, please?",
    ]
    with LocalAgentMesh() as mesh:
        async with ScenarioSession(mesh.registry, learner) as session:
            result = await session.run(turns)
    print(result.culture.headline)
    print(result.rescues[0].phrases[0].english)


asyncio.run(main())
```

## Build the wheel and upload to PyPI

```bash
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*

# TestPyPI first
python -m twine upload --repository testpypi dist/*

# Production PyPI
export TWINE_USERNAME=__token__
export TWINE_PASSWORD=pypi-<your-api-token>
python -m twine upload dist/*
```

Windows PowerShell equivalents:

```powershell
$env:TWINE_USERNAME = "__token__"
$env:TWINE_PASSWORD = "pypi-<your-api-token>"
python -m twine upload dist/*
```

The build produces `dist/acps_scenario_buddy-1.0.0-py3-none-any.whl` and the source distribution.

## Verify the package

```bash
python -m pytest
python -m ruff check .
python -m twine check dist/*
```

## Design boundaries

- The scene scripts are curated and deterministic; they are designed for repeatable practice, not for open-ended generation.
- The Guide Agent triggers on observable signals (Chinese characters, explicit help phrases, hesitation markers, unfinished utterances) rather than on a hidden model.
- The Culture Agent provides general guidance for UK-oriented settings; regional norms vary and should be checked for a specific destination.
- AIP task state is held in the SDK's in-process `TaskManager`; this local mesh is intended for single-process practice and CI, not multi-tenant deployment.

## License

MIT. See [LICENSE](LICENSE).
