Module: Muxi
- Defined in:
- lib/muxi.rb,
lib/muxi/auth.rb,
lib/muxi/errors.rb,
lib/muxi/version.rb,
lib/muxi/webhook.rb,
lib/muxi/transport.rb,
lib/muxi/server_client.rb,
lib/muxi/version_check.rb,
lib/muxi/formation_client.rb
Defined Under Namespace
Modules: Auth, VersionCheck, Webhook Classes: AuthenticationError, AuthorizationError, ConflictError, ConnectionError, FormationClient, FormationConfig, FormationTransport, MuxiError, NotFoundError, RateLimitError, ServerClient, ServerConfig, ServerError, Transport, ValidationError
Constant Summary collapse
- VERSION =
"1.20260713.0"
Class Attribute Summary collapse
-
.debug ⇒ Object
Returns the value of attribute debug.
Class Method Summary collapse
- .debug? ⇒ Boolean
- .map_error(status, code, message, details = nil, retry_after = nil) ⇒ Object
-
.parse_ui_widgets(event) ⇒ Object
Widgets from an
event: uistream frame; [] for other frames.
Class Attribute Details
.debug ⇒ Object
Returns the value of attribute debug.
14 15 16 |
# File 'lib/muxi.rb', line 14 def debug @debug end |
Class Method Details
.debug? ⇒ Boolean
16 17 18 |
# File 'lib/muxi.rb', line 16 def debug? @debug || ENV["MUXI_DEBUG"] == "1" end |
.map_error(status, code, message, details = nil, retry_after = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/muxi/errors.rb', line 34 def map_error(status, code, , details = nil, retry_after = nil) case status when 401 AuthenticationError.new(code || "UNAUTHORIZED", , status, details) when 403 AuthorizationError.new(code || "FORBIDDEN", , status, details) when 404 NotFoundError.new(code || "NOT_FOUND", , status, details) when 409 ConflictError.new(code || "CONFLICT", , status, details) when 422 ValidationError.new(code || "VALIDATION_ERROR", , status, details) when 429 RateLimitError.new( || "Too Many Requests", status, retry_after: retry_after, details: details) when 500..599 ServerError.new(code || "SERVER_ERROR", , status, details) else MuxiError.new(code || "ERROR", , status, details) end end |
.parse_ui_widgets(event) ⇒ Object
Widgets from an event: ui stream frame; [] for other frames.
The runtime delivers the response envelope's optional ui array
(options, action_link, mcp_resource widgets) as a single event: ui
SSE frame before event: done. Unknown widget types should be
ignored (progressive enhancement).
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/muxi/formation_client.rb', line 15 def self.(event) return [] unless event.is_a?(Hash) && event["event"] == "ui" begin parsed = JSON.parse(event["data"].to_s) rescue JSON::ParserError return [] end ui = parsed.is_a?(Hash) ? parsed["ui"] : nil ui.is_a?(Array) ? ui : [] end |