@waelio/negotiate
v0.1.0
Published
NPM wrapper CLI for the waelio negotiate service
Maintainers
Readme
negotiate
Python service for authenticating two AI prompts against a shared session, with all session and prompt records stored as markdown (.md) files.
What it does
- Creates a shared session and returns:
session_idshared_secret
- Authenticates
prompt_aandprompt_busing the sameshared_secret - Persists everything in markdown files under
data/sessions/
Project structure
app/main.py— FastAPI app and endpointsapp/storage.py— markdown-backed session store and auth logic.env— containsAPP_MASTER_KEY
Setup
- Create a virtual environment and install dependencies from
requirements.txt - Set a strong value in
.envforAPP_MASTER_KEY - Start the API with Uvicorn
Example run target:
- app import path:
app.main:app - host:
0.0.0.0 - port:
8000
Quickstart (usable command line)
Use these commands from the project root:
- Setup local environment and dependencies:
make setup
- Start dev server:
make dev
- In another terminal, confirm health:
make health
- Run one full end-to-end negotiation cycle:
make demo
- Run tests:
make test
CLI script entrypoint:
scripts/negotiate_cli.py
Supported CLI commands:
python3 scripts/negotiate_cli.py healthpython3 scripts/negotiate_cli.py demo-cyclepython3 scripts/negotiate_cli.py kickoff --prompt-text "..." --goal "..."python3 scripts/negotiate_cli.py auth <session_id> prompt_b --shared-secret "..." --prompt-text "..."python3 scripts/negotiate_cli.py status <session_id>python3 scripts/negotiate_cli.py handoff-get <session_id>python3 scripts/negotiate_cli.py handoff-save <session_id> --goal "..." --current-status "..." --last-successful-step "..." --current-blocker "..." --next-exact-step "..." --paste-ready-inputs "..."
Optional base URL override:
python3 scripts/negotiate_cli.py --base-url http://127.0.0.1:8000 health
Example full cycle with the enhanced existing CLI:
- Kickoff with prompt A:
python3 scripts/negotiate_cli.py kickoff --prompt-text "Prompt A opens with proposal" --goal "Reach agreement"
- Authenticate prompt B with returned values:
python3 scripts/negotiate_cli.py auth <session_id> prompt_b --shared-secret "<shared_secret>" --prompt-text "Prompt B counter-offer"
- Read completion status:
python3 scripts/negotiate_cli.py status <session_id>
- Read shared handoff markdown:
python3 scripts/negotiate_cli.py handoff-get <session_id>
API
Health check
GET /health
Create shared session
POST /sessions
Response:
session_idshared_secretcreated_at
Kickoff negotiation with prompt A (recommended first step)
POST /sessions/kickoff
This endpoint does three things in one call:
- Creates a new session
- Authenticates
prompt_ausing an internally generated shared secret - Saves initial shared progress to
handoff.md
Request body:
prompt_text(opening message from prompt A)goalcurrent_blockernext_exact_steppaste_ready_inputs(optional; auto-generated if empty)
Response includes:
session_idshared_secret(use this for prompt B)prompt_a_authenticated(true)prompt_b_authenticated(false initially)handoff_saved(true)
Authenticate prompt A or B
POST /sessions/{session_id}/prompts/{role}rolemust beprompt_aorprompt_b
Request body:
shared_secret(the one returned by session creation)prompt_text
Once both prompts authenticate successfully, the session is marked complete.
Get session status
GET /sessions/{session_id}
Returns whether each prompt is authenticated and whether the session is complete.
Save shared handoff (resume context)
POST /sessions/{session_id}/handoff
Request body fields:
goalcurrent_statuslast_successful_stepcurrent_blockernext_exact_steppaste_ready_inputs
This writes data/sessions/{session_id}/handoff.md so you can pause in one AI tool and resume in another.
Read shared handoff
GET /sessions/{session_id}/handoff
Returns session_id, updated_at, and markdown body for easy resume.
Markdown output
Files are written to:
data/sessions/{session_id}.md— session frontmatter + summarydata/sessions/{session_id}/prompt_a.md— authenticated prompt A textdata/sessions/{session_id}/prompt_b.md— authenticated prompt B text
Publishing this repository
This repository now supports two publish paths:
- npm wrapper package (
@waelio/negotiate) - Python package (
waelio-negotiate)
npm publish path (@waelio/negotiate)
The npm package is a wrapper CLI that provides:
negotiate servenegotiate healthnegotiate demonegotiate py-cli ...
From the repo root:
- Dry-run npm publish:
npm publish --dry-run
- Publish to npm:
npm publish --access public
After install (npm i -g @waelio/negotiate), use:
negotiate helpnegotiate serve --host 127.0.0.1 --port 8000negotiate health --base-url http://127.0.0.1:8000negotiate demo --base-url http://127.0.0.1:8000
Python publish path (waelio-negotiate)
Use Python packaging (pyproject.toml) + PyPI/TestPyPI.
From the repo root:
- Build package artifacts:
make package
- Validate package metadata:
make package-check
- Optional test publish:
make publish-test
For production PyPI publishing, use Twine in your authenticated environment:
python3 -m twine upload dist/*
