Skip to content

tri-bot: Replace claude CLI with direct Anthropic API (SSE streaming) #62

@gHashTag

Description

@gHashTag

Problem

tri-bot streams via claude -p --output-format stream-json — spawns Node.js/TypeScript Claude CLI as subprocess. This is the last TypeScript dependency in the Telegram→Claude pipeline.

Solution

Rewrite claude_stream.zig to POST directly to api.anthropic.com/v1/messages with "stream": true, parse SSE events inline.

Changes

  • claude_stream.zig — FULL REWRITE: std.http.Client + SSE parser replaces std.process.Child
  • telegram_api.zig — add api_key to BotConfig
  • handlers.zig/status uses git commands directly (no claude), /sessions stubbed
  • bot_loop.zig/continue, /resume deferred to Phase 5 (sessions)
  • main.zig (bot) — read ANTHROPIC_API_KEY from env

Architecture after

Telegram → tri-bot (Zig) → api.anthropic.com (HTTPS/SSE)

Zero Node.js. Zero subprocess. Pure Zig HTTP.

Acceptance Criteria

  • tri-bot compiles and runs
  • /ask streams text via SSE from Anthropic API directly
  • /stop cancels HTTP connection (no SIGTERM)
  • /status shows git info without claude CLI
  • No std.process.Child calls to claude binary remain

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions