Skip to content

feat(server): streaming chat API via SSE#12

Merged
wcatz merged 1 commit intomainfrom
feat/streaming-api
Mar 15, 2026
Merged

feat(server): streaming chat API via SSE#12
wcatz merged 1 commit intomainfrom
feat/streaming-api

Conversation

@wcatz
Copy link
Copy Markdown
Owner

@wcatz wcatz commented Mar 15, 2026

Summary

  • 6 new endpoints for frontend integration (VSCode extension, web clients):
    • POST /api/v1/sessions — create session for a project path
    • GET /api/v1/sessions — list active sessions
    • DELETE /api/v1/sessions/{id} — stop session
    • POST /api/v1/sessions/{id}/send — send message, stream response via SSE
    • POST /api/v1/sessions/{id}/approve — respond to pending tool approval
    • POST /api/v1/sessions/{id}/mode — change session mode
  • SSE event types: text, thinking, tool_use_start, tool_input_delta, tool_use_end, approval_required, done, error
  • Orchestrator wired into ghost serve — creates AI client + tool registry when API key is available
  • Chat endpoints gated behind orchestrator presence — memory-only mode still works without API key
  • Removed global 30s chi timeout middleware (it breaks SSE flushing)

This unlocks Phase 4 (VSCode extension) — any HTTP client can now have a full agentic conversation with Ghost.

Test plan

  • make build compiles
  • make vet passes
  • make test — all existing tests pass (chat routes don't interfere)
  • Manual: ghost serve + curl -N -X POST /api/v1/sessions + /send streams SSE events

New endpoints for frontend integration (VSCode, web):
- POST   /api/v1/sessions       — create session for a project path
- GET    /api/v1/sessions       — list active sessions
- DELETE /api/v1/sessions/{id}  — stop session
- POST   /api/v1/sessions/{id}/send    — send message, stream response via SSE
- POST   /api/v1/sessions/{id}/approve — respond to pending tool approval
- POST   /api/v1/sessions/{id}/mode    — change session mode

SSE event types: text, thinking, tool_use_start, tool_input_delta,
tool_use_end, approval_required, done, error.

Chat endpoints gated behind orchestrator — only available when API key
is configured. Memory-only endpoints still work without it.
Removed global 30s timeout middleware (breaks SSE streaming).
@wcatz wcatz merged commit 977827b into main Mar 15, 2026
@wcatz wcatz deleted the feat/streaming-api branch March 15, 2026 02:09
wcatz added a commit that referenced this pull request Mar 24, 2026
Address CodeQL path-injection alerts (#12, #13, #14):
- ClaudeMemoryDir: validate resolved path stays under ~/.claude/projects/
- ParseMemoryFile: filepath.Clean on input path
- importFromDir: filepath.Clean on dir, filepath.Base on entry names
wcatz added a commit that referenced this pull request Mar 24, 2026
Address CodeQL path-injection alerts (#12, #13, #14):
- ClaudeMemoryDir: validate resolved path stays under ~/.claude/projects/
- ParseMemoryFile: filepath.Clean on input path
- importFromDir: filepath.Clean on dir, filepath.Base on entry names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant