implement std practices #44
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_aibroker#44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
use skills
/hero_crates_best_practices_check
/hero_proc_service_selfstart
/hero_ui_dashboard
large refactor needed
make sure all functionality is in hero_aibroker_server
or if needed hero_aibroker_lib and make modular there
the the hero_aibroker_server has only openrpc interface
hero_aibroker_sdk is openrpc macro towards the openrpc interface
the hero_aibroker crate is the cmdline and uses hero_aibroker_sdk
make sure the openrpc interface is complete and all is there
Implementation Spec — Issue #44: Implement Std Practices
Summary
Large refactor to align with Hero standard practices:
hero_aibrokerlibrary →hero_aibroker_lib(frees the name for CLI)hero_aibroker_server= pure OpenRPC only — remove all/v1/*HTTP REST routesai.*RPC methods — chat, TTS, STT, embeddings accessible via JSON-RPCopenrpc.json— complete spec with all methodshero_aibroker_uitranslates HTTP→RPC — OpenAI-compatible HTTP translation layer using SDKhero_aibrokerCLI uses SDK — replace raw HTTP with typed SDK callshero_aibroker_daemon/→hero_aibroker/— package name matches binary nameArchitecture After Refactor
New OpenRPC Methods
ai.chatai.modelsai.ttsai.transcribeai.embedPlus missing admin methods:
providers.list/add_key/remove_key,mcp.add_server/remove_serverImplementation Steps
hero_aibroker→hero_aibroker_lib, update all referencesai.*RPC handlers to server + updateopenrpc.jsonsrc/api/chat.rs,tts.rs,stt.rs,embedding.rs,models.rs)src/openai.rs)hero_aibrokerCLI to use SDK instead of raw HTTPhero_aibroker_daemon/→hero_aibroker/Key Design Decisions
ai.chatreturns complete response. SSE streaming stays in the UI translation layer.info.titlein openrpc.json unchanged to avoid struct name churn.Generated by Claude Code — awaiting approval before implementation
Spec Correction — Dual-Socket Server
The previous spec was wrong on one point: do NOT remove the REST routes.
The server keeps all REST compatibility (OpenAI, MCP, Anthropic) but binds two separate Unix sockets:
Two Sockets from One Server Binary
~/hero/var/sockets/hero_aibroker_server.sock~/hero/var/sockets/hero_aibroker_server_rest.sockBoth sockets share the same in-process AppState (same providers, registry, services, metrics, etc.).
Updated Architecture
What Changes
main.rsspawns twoUnixListenertasks sharing the sameAppState/rpc→server.sock,/v1/*→server_rest.sockhero_aibroker_daemonregisters both sockets in hero_proc health checksProceeding with implementation based on this corrected design.
Test Results
cargo check --workspacedead_codewarning)cargo test --workspaceFinal Implementation Summary
Architecture: Dual Unix Socket Design
The server now binds two Unix sockets sharing the same
AppState:~/hero/var/sockets/hero_aibroker_server.sock~/hero/var/sockets/hero_aibroker_server_rest.sockFiles Changed
1.
crates/hero_aibroker_server/src/main.rsBinds both sockets sharing the same
AppState.2.
crates/hero_aibroker_server/src/api/mod.rscreate_rpc_router()returns(Router, AppState)— serves/rpc,/health,/openrpc.json,/.well-known/heroservice.jsoncreate_rest_router(state)— serves/v1/chat/completions,/v1/models,/v1/audio/speech,/v1/audio/transcriptions,/v1/embeddings,/metrics,/healthai.chat,ai.models,ai.tts,ai.transcribe,ai.embed3.
crates/hero_aibroker_server/openrpc.jsonAdded methods:
ai.chat,ai.models,ai.tts,ai.transcribe,ai.embed,providers.list,mcp.add_server,mcp.remove_server.Added schemas:
Message,ChatResponse.4.
crates/hero_aibroker_ui/src/api/mod.rsUI now proxies to two sockets:
/rpc,/openrpc.json→hero_aibroker_server.sock/v1/*,/metrics,/health→hero_aibroker_server_rest.sock5.
crates/hero_aibroker_ui/src/main.rsPasses both socket paths to the router.
6.
crates/hero_aibroker/(washero_aibroker_daemon/)Renamed package to
hero_aibroker. CLI commands useAIBrokerAdminAPIClientSDK.7.
crates/hero_aibroker_lib/(wascrates/hero_aibroker/)Library renamed to
hero_aibroker_lib, freeing thehero_aibrokername for the CLI binary.Implementation committed:
70a4792— feat: implement standard three-crate architectureb6bd05b— feat: implement working CLI chat via ai.chat RPCBrowse:
b6bd05b