Files
paseo/packages/server
Ouyang Xingyuan c17e7c5b64 fix(server): release a provider turn the daemon force-canceled
Cancelling a foreground turn can leave two owners of "is a turn running". The
manager force-cancels after its 2 s settle window: it synthesizes turn_canceled
and reports the agent idle. The provider session never confirmed that turn
ended, so it still holds the slot. Every later prompt then fails with "A
foreground turn is already active" until the agent is reloaded.

ACP is the reproducible case. ACPAgentSession.interrupt() sends session/cancel,
which is a notification: it resolves as soon as it is written. An agent that
answers cancelled but keeps working in the same process, or never answers at
all, leaves activeForegroundTurnId set. This is the failure observed locally on
2026-10-20 with a droid-magpie agent: five "[System Error] A foreground turn is
already active" rows and no way to send anything afterwards.

Add AgentSession.abandonForegroundTurn? as the seam for that state. The manager
calls it after a forced settlement, and only then; a cancel that settles keeps
today's path. A provider that implements it must make the session usable again
rather than clear a local flag, because reusing a runtime that may still be
working is the split-brain shape docs/agent-lifecycle.md forbids.

wrapSessionProvider forwards the hook. Without that line the manager only sees
the wrapper's fixed member list, so an optional method added to the interface is
silently dropped for every wrapped provider.

The ACP adapter kills the process that owned the abandoned turn, drops the slot,
and synthesizes cancelled tool calls for rows that were still running. Its next
startTurn resumes the durable session in a new process and drops the replayed
history rows, since the daemon already has them. A kill-timeout rejects, which
leaves the agent as it was.

Tests: a force-canceled turn releases the session and the next prompt starts, a
settled cancel does not call the hook, a rejected release still settles, the
wrapper forwards the hook or omits it, and the ACP adapter reconnects on the
next turn without replaying history twice.
2026-10-20 13:52:24 +08:00
..
2026-10-19 08:45:41 +02:00
2026-04-23 21:44:48 +07:00

Voice Assistant

A voice-controlled terminal assistant that runs as a single local service.

Quick Start

# Install dependencies
npm install

# Copy environment variables
cp .env.example .env
# Edit .env and add your API keys (OpenAI, Deepgram)

# Run development servers
npm run dev

# Open browser to http://localhost:5173

Architecture

  • Express Server (port 3000) - Serves API and built UI in production
  • Vite Dev Server (port 5173) - Hot-reload React UI in development
  • WebSocket (/ws) - Real-time bidirectional communication
  • Agent - STT → LLM → TTS pipeline with terminal control
  • Daemon - tmux-based terminal management (in-process)

Development

# Run both servers (recommended)
npm run dev

# Or run separately:
npm run dev:server  # Express on port 3000
npm run dev:ui      # Vite on port 5173

# Type checking
npm run typecheck

# Build for production
npm run build

# Start production server
npm start

Project Status

✅ Completed (Phases 1-2):

  • Package setup and configuration
  • Express server with WebSocket
  • React UI with Vite
  • WebSocket client with ping/pong testing

⏳ In Progress (Phase 3):

  • Terminal control (tmux integration)

📋 Planned (Phases 4-9):

  • LLM integration (OpenAI GPT-4)
  • Agent orchestrator
  • Speech-to-Text (Deepgram)
  • Text-to-Speech (OpenAI)
  • Audio streaming
  • UI polish

See IMPLEMENTATION_PLAN.md for complete details.

Environment Variables

OPENAI_API_KEY=your-openai-key-here      # GPT-4 and TTS
DEEPGRAM_API_KEY=your-deepgram-key-here  # Streaming STT
STT_MODEL=whisper-1        # Optional: override to gpt-4o-transcribe, etc.
STT_CONFIDENCE_THRESHOLD=-3.0  # Optional: reject low-confidence clips
STT_DEBUG_AUDIO_DIR=.stt-debug # Optional: persist raw dictation audio for debugging
PASEO_HOME=~/.paseo        # Runtime state directory (agents/, etc.)
PASEO_LISTEN=127.0.0.1:6767  # Listen address (host:port or /path/to/socket)

PASEO_HOME defaults to ~/.paseo and isolates runtime artifacts like agents/. PASEO_LISTEN controls the daemon listen address. For blue/green testing you can run a parallel server without touching production state:

PASEO_HOME=~/.paseo-blue PASEO_LISTEN=127.0.0.1:7777 npm run dev

Tech Stack

  • Server: Express, TypeScript, ws (WebSocket)
  • Client: React 18, Vite, TypeScript
  • Terminal: tmux (via child_process)
  • AI: OpenAI (LLM + TTS), Deepgram (STT)

Testing

Currently manual testing via:

  1. Start servers: npm run dev
  2. Open http://localhost:5173
  3. Test WebSocket connection (green status indicator)
  4. Click "Send Ping" button to test communication

More testing guidance as features are implemented.

License

MIT