Missing hero_proxy support for REST API #45

Closed
opened 2026-04-21 11:06:42 +00:00 by fatmaebrahim · 4 comments
Member

Problem

The POST /v1/audio/speech endpoint was unreachable via the hero_proxy at http://127.0.0.1:9988/hero_aibroker/v1/audio/speech.

Root Causes

1. Missing web_v1.sock socket (main.rs)

The server only created rest.sock, but the hero_proxy expects web_v1.sock to route HTTP traffic.

2. Route prefix mismatch (api/mod.rs)

The hero_proxy strips /hero_aibroker/v1 from the URL before forwarding to web_v1.sock.
So a request to /hero_aibroker/v1/audio/speech arrives at the socket as just /audio/speech. But routes were registered as /v1/audio/speech.

3. Groq Orpheus TTS compatibility (service/tts.rs — user-modified)

Groq's Orpheus backend only supports wav format and has different voice names than OpenAI.

### Problem The POST /v1/audio/speech endpoint was unreachable via the hero_proxy at http://127.0.0.1:9988/hero_aibroker/v1/audio/speech. ### Root Causes #### 1. Missing web_v1.sock socket (main.rs) The server only created rest.sock, but the hero_proxy expects web_v1.sock to route HTTP traffic. #### 2. Route prefix mismatch (api/mod.rs) The hero_proxy strips /hero_aibroker/v1 from the URL before forwarding to web_v1.sock. So a request to /hero_aibroker/v1/audio/speech arrives at the socket as just /audio/speech. But routes were registered as /v1/audio/speech. #### 3. Groq Orpheus TTS compatibility (service/tts.rs — user-modified) Groq's Orpheus backend only supports wav format and has different voice names than OpenAI.
Author
Member

Implementation Spec for Issue #45

Objective

Add hero_proxy support for the REST API so that endpoints like /v1/audio/speech are reachable via http://127.0.0.1:9988/hero_aibroker/v1/....

Requirements

  • The server must expose a web_v1.sock socket for hero_proxy routing
  • The existing rest.sock must be preserved for direct socket consumers (e.g. hero_agent)
  • Routes must work both via hero_proxy (prefix stripped) and via direct socket access (/v1/... prefix)
  • Groq Orpheus TTS backend must force wav format and truncate input to 1000 chars

Files to Modify

  • crates/hero_aibroker_server/src/main.rs - Add web_v1.sock alongside rest.sock
  • crates/hero_aibroker_server/src/api/mod.rs - Dual route registration (root + /v1 prefix)
  • crates/hero_aibroker_lib/src/service/tts.rs - Groq format/input handling

Implementation Plan

Step 1: Add proxy socket (main.rs)

  • Add proxy_socket_path() returning web_v1.sock
  • Bind and serve the REST app on both rest.sock and web_v1.sock
  • Clean up both sockets on shutdown

Step 2: Dual route registration (api/mod.rs)

  • Split routes into v1_routes (API endpoints without /v1 prefix) and misc routes
  • Register v1_routes at root (for hero_proxy which strips /hero_aibroker/v1) via .merge()
  • Also nest under /v1 for direct socket access via .nest("/v1", ...)

Step 3: Groq TTS compatibility (service/tts.rs)

  • Force response_format: "wav" for Groq backends
  • Truncate input to 1000 chars for Groq backends

Acceptance Criteria

  • POST http://127.0.0.1:9988/hero_aibroker/v1/audio/speech returns 200 with audio data
  • POST via direct rest.sock at /v1/audio/speech returns 200 with audio data
  • Both rest.sock and web_v1.sock are created on startup
  • All three sockets cleaned up on shutdown
## Implementation Spec for Issue #45 ### Objective Add hero_proxy support for the REST API so that endpoints like `/v1/audio/speech` are reachable via `http://127.0.0.1:9988/hero_aibroker/v1/...`. ### Requirements - The server must expose a `web_v1.sock` socket for hero_proxy routing - The existing `rest.sock` must be preserved for direct socket consumers (e.g. hero_agent) - Routes must work both via hero_proxy (prefix stripped) and via direct socket access (`/v1/...` prefix) - Groq Orpheus TTS backend must force `wav` format and truncate input to 1000 chars ### Files to Modify - `crates/hero_aibroker_server/src/main.rs` - Add `web_v1.sock` alongside `rest.sock` - `crates/hero_aibroker_server/src/api/mod.rs` - Dual route registration (root + `/v1` prefix) - `crates/hero_aibroker_lib/src/service/tts.rs` - Groq format/input handling ### Implementation Plan #### Step 1: Add proxy socket (main.rs) - Add `proxy_socket_path()` returning `web_v1.sock` - Bind and serve the REST app on both `rest.sock` and `web_v1.sock` - Clean up both sockets on shutdown #### Step 2: Dual route registration (api/mod.rs) - Split routes into `v1_routes` (API endpoints without `/v1` prefix) and misc routes - Register v1_routes at root (for hero_proxy which strips `/hero_aibroker/v1`) via `.merge()` - Also nest under `/v1` for direct socket access via `.nest("/v1", ...)` #### Step 3: Groq TTS compatibility (service/tts.rs) - Force `response_format: "wav"` for Groq backends - Truncate input to 1000 chars for Groq backends ### Acceptance Criteria - [ ] `POST http://127.0.0.1:9988/hero_aibroker/v1/audio/speech` returns 200 with audio data - [ ] `POST` via direct `rest.sock` at `/v1/audio/speech` returns 200 with audio data - [ ] Both `rest.sock` and `web_v1.sock` are created on startup - [ ] All three sockets cleaned up on shutdown
Author
Member

Test Results

  • Build: OK (release profile, no errors)
  • Unit tests: all passed
  • Doc tests: 1 passed
  • Integration test (test_server_rpc_methods): SKIPPED (pre-existing failure unrelated to this change -- server health check timeout in test environment)

Manual Verification

  • POST http://127.0.0.1:9988/hero_aibroker/v1/audio/speech -- 200 OK, valid WAV audio returned
  • POST via direct rest.sock at /v1/audio/speech -- 200 OK, valid WAV audio returned
  • Both rest.sock and web_v1.sock created on startup
  • All sockets cleaned up on shutdown
## Test Results - Build: OK (release profile, no errors) - Unit tests: all passed - Doc tests: 1 passed - Integration test (`test_server_rpc_methods`): SKIPPED (pre-existing failure unrelated to this change -- server health check timeout in test environment) ### Manual Verification - `POST http://127.0.0.1:9988/hero_aibroker/v1/audio/speech` -- 200 OK, valid WAV audio returned - `POST` via direct `rest.sock` at `/v1/audio/speech` -- 200 OK, valid WAV audio returned - Both `rest.sock` and `web_v1.sock` created on startup - All sockets cleaned up on shutdown
Author
Member

Implementation Summary

Changes Made

1. crates/hero_aibroker_server/src/main.rs (+14 lines)

  • Added proxy_socket_path() returning web_v1.sock
  • Server now binds and serves the REST app on both rest.sock (direct access) and web_v1.sock (hero_proxy)
  • Both sockets cleaned up on shutdown

2. crates/hero_aibroker_server/src/api/mod.rs (+13/-5 lines)

  • Extracted API routes into v1_routes (without /v1 prefix)
  • Registered routes at root via .merge() (for hero_proxy which strips /hero_aibroker/v1)
  • Also nested under /v1 via .nest() (for direct socket access)

3. crates/hero_aibroker_lib/src/service/tts.rs (+14/-2 lines)

  • Force response_format: "wav" for Groq backends (Orpheus only supports wav)
  • Truncate input to 1000 chars for Groq backends

Verification

  • Proxy access: POST http://127.0.0.1:9988/hero_aibroker/v1/audio/speech returns 200 with valid WAV audio
  • Direct socket: POST /v1/audio/speech via rest.sock returns 200 with valid WAV audio
  • All tests pass (pre-existing integration test failure excluded)
## Implementation Summary ### Changes Made **1. `crates/hero_aibroker_server/src/main.rs`** (+14 lines) - Added `proxy_socket_path()` returning `web_v1.sock` - Server now binds and serves the REST app on both `rest.sock` (direct access) and `web_v1.sock` (hero_proxy) - Both sockets cleaned up on shutdown **2. `crates/hero_aibroker_server/src/api/mod.rs`** (+13/-5 lines) - Extracted API routes into `v1_routes` (without `/v1` prefix) - Registered routes at root via `.merge()` (for hero_proxy which strips `/hero_aibroker/v1`) - Also nested under `/v1` via `.nest()` (for direct socket access) **3. `crates/hero_aibroker_lib/src/service/tts.rs`** (+14/-2 lines) - Force `response_format: "wav"` for Groq backends (Orpheus only supports wav) - Truncate input to 1000 chars for Groq backends ### Verification - Proxy access: `POST http://127.0.0.1:9988/hero_aibroker/v1/audio/speech` returns 200 with valid WAV audio - Direct socket: `POST /v1/audio/speech` via `rest.sock` returns 200 with valid WAV audio - All tests pass (pre-existing integration test failure excluded)
Author
Member

Pull request opened: #46

This PR implements the changes discussed in this issue.

Pull request opened: https://forge.ourworld.tf/lhumina_code/hero_aibroker/pulls/46 This PR implements the changes discussed in this issue.
fatmaebrahim referenced this issue from a commit 2026-04-21 11:58:41 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_aibroker#45
No description provided.