Module: Rubino
- Defined in:
- lib/rubino.rb,
lib/rubino.rb,
lib/rubino/ui.rb,
lib/rubino/mcp.rb,
lib/rubino/modes.rb,
lib/rubino/trust.rb,
lib/rubino/errors.rb,
lib/rubino/logger.rb,
lib/rubino/ui/api.rb,
lib/rubino/ui/cli.rb,
lib/rubino/api/tls.rb,
lib/rubino/metrics.rb,
lib/rubino/plugins.rb,
lib/rubino/ui/base.rb,
lib/rubino/ui/null.rb,
lib/rubino/version.rb,
lib/rubino/documents.rb,
lib/rubino/workspace.rb,
lib/rubino/agent/loop.rb,
lib/rubino/api/router.rb,
lib/rubino/api/server.rb,
lib/rubino/jobs/queue.rb,
lib/rubino/tools/base.rb,
lib/rubino/api/request.rb,
lib/rubino/api/schemas.rb,
lib/rubino/jobs/runner.rb,
lib/rubino/jobs/worker.rb,
lib/rubino/llm/request.rb,
lib/rubino/mcp/manager.rb,
lib/rubino/ui/notifier.rb,
lib/rubino/util/output.rb,
lib/rubino/active_skill.rb,
lib/rubino/agent/router.rb,
lib/rubino/agent/runner.rb,
lib/rubino/cli/commands.rb,
lib/rubino/memory/store.rb,
lib/rubino/run/executor.rb,
lib/rubino/run/recorder.rb,
lib/rubino/skills/skill.rb,
lib/rubino/tools/result.rb,
lib/rubino/update_check.rb,
lib/rubino/api/responses.rb,
lib/rubino/config/loader.rb,
lib/rubino/config/writer.rb,
lib/rubino/jobs/registry.rb,
lib/rubino/session/store.rb,
lib/rubino/skills/toggle.rb,
lib/rubino/ui/status_bar.rb,
lib/rubino/util/duration.rb,
lib/rubino/cli/trust_gate.rb,
lib/rubino/documents/html.rb,
lib/rubino/jobs/scheduler.rb,
lib/rubino/memory/backend.rb,
lib/rubino/memory/flusher.rb,
lib/rubino/oauth/provider.rb,
lib/rubino/oauth/registry.rb,
lib/rubino/run/repository.rb,
lib/rubino/tools/git_tool.rb,
lib/rubino/tools/registry.rb,
lib/rubino/ui/indented_io.rb,
lib/rubino/ui/live_region.rb,
lib/rubino/ui/paste_store.rb,
lib/rubino/util/hyperlink.rb,
lib/rubino/commands/loader.rb,
lib/rubino/config/defaults.rb,
lib/rubino/documents/table.rb,
lib/rubino/files/workspace.rb,
lib/rubino/llm/tool_bridge.rb,
lib/rubino/memory/backends.rb,
lib/rubino/run/event_store.rb,
lib/rubino/session/message.rb,
lib/rubino/skills/registry.rb,
lib/rubino/tools/edit_tool.rb,
lib/rubino/tools/glob_tool.rb,
lib/rubino/tools/grep_tool.rb,
lib/rubino/tools/read_tool.rb,
lib/rubino/tools/ruby_tool.rb,
lib/rubino/tools/task_tool.rb,
lib/rubino/tools/test_tool.rb,
lib/rubino/tools/todo_tool.rb,
lib/rubino/ui/printer_base.rb,
lib/rubino/ui/stdout_proxy.rb,
lib/rubino/agent/definition.rb,
lib/rubino/cli/chat_command.rb,
lib/rubino/cli/jobs_command.rb,
lib/rubino/commands/command.rb,
lib/rubino/memory/extractor.rb,
lib/rubino/memory/retriever.rb,
lib/rubino/plugins/registry.rb,
lib/rubino/session/exporter.rb,
lib/rubino/tools/patch_tool.rb,
lib/rubino/tools/probe_tool.rb,
lib/rubino/tools/shell_tool.rb,
lib/rubino/tools/steer_tool.rb,
lib/rubino/tools/write_tool.rb,
lib/rubino/ui/escape_reader.rb,
lib/rubino/ui/input_history.rb,
lib/rubino/ui/subagent_view.rb,
lib/rubino/cli/setup_command.rb,
lib/rubino/cli/tools_command.rb,
lib/rubino/commands/executor.rb,
lib/rubino/database/migrator.rb,
lib/rubino/interaction/probe.rb,
lib/rubino/interaction/state.rb,
lib/rubino/llm/fake_provider.rb,
lib/rubino/llm/model_catalog.rb,
lib/rubino/run/approval_gate.rb,
lib/rubino/run/gate_registry.rb,
lib/rubino/skills/skill_tool.rb,
lib/rubino/tools/github_tool.rb,
lib/rubino/tools/memory_tool.rb,
lib/rubino/tools/vision_tool.rb,
lib/rubino/ui/subagent_cards.rb,
lib/rubino/util/secrets_mask.rb,
lib/rubino/attachments/defang.rb,
lib/rubino/attachments/policy.rb,
lib/rubino/cli/config_command.rb,
lib/rubino/cli/doctor_command.rb,
lib/rubino/cli/memory_command.rb,
lib/rubino/cli/server_command.rb,
lib/rubino/cli/skills_command.rb,
lib/rubino/commands/built_ins.rb,
lib/rubino/context/compressor.rb,
lib/rubino/documents/registry.rb,
lib/rubino/interaction/events.rb,
lib/rubino/session/repository.rb,
lib/rubino/tools/read_tracker.rb,
lib/rubino/ui/bottom_composer.rb,
lib/rubino/ui/completion_menu.rb,
lib/rubino/agent/tool_executor.rb,
lib/rubino/api/middleware/auth.rb,
lib/rubino/boot/encryption_key.rb,
lib/rubino/cli/chat/bang_shell.rb,
lib/rubino/cli/session_command.rb,
lib/rubino/database/connection.rb,
lib/rubino/llm/adapter_factory.rb,
lib/rubino/llm/content_builder.rb,
lib/rubino/llm/scenario_loader.rb,
lib/rubino/memory/deduplicator.rb,
lib/rubino/memory/sqlite_graph.rb,
lib/rubino/skills/prompt_index.rb,
lib/rubino/tools/question_tool.rb,
lib/rubino/tools/webfetch_tool.rb,
lib/rubino/agent/agent_registry.rb,
lib/rubino/agent/backoff_policy.rb,
lib/rubino/agent/fallback_chain.rb,
lib/rubino/attachments/classify.rb,
lib/rubino/attachments/preamble.rb,
lib/rubino/cli/chat/image_inbox.rb,
lib/rubino/config/configuration.rb,
lib/rubino/context/token_budget.rb,
lib/rubino/llm/adapter_response.rb,
lib/rubino/llm/auxiliary_client.rb,
lib/rubino/llm/credential_check.rb,
lib/rubino/llm/error_classifier.rb,
lib/rubino/llm/ruby_llm_adapter.rb,
lib/rubino/llm/thinking_support.rb,
lib/rubino/mcp/mcp_tool_wrapper.rb,
lib/rubino/tools/shell_registry.rb,
lib/rubino/tools/subagent_probe.rb,
lib/rubino/tools/task_stop_tool.rb,
lib/rubino/tools/websearch_tool.rb,
lib/rubino/ui/completion_source.rb,
lib/rubino/ui/markdown_renderer.rb,
lib/rubino/ui/queued_indicators.rb,
lib/rubino/cli/onboarding_wizard.rb,
lib/rubino/commands/handlers/mcp.rb,
lib/rubino/interaction/event_bus.rb,
lib/rubino/interaction/lifecycle.rb,
lib/rubino/jobs/webhook_delivery.rb,
lib/rubino/llm/provider_resolver.rb,
lib/rubino/llm/reasoning_manager.rb,
lib/rubino/llm/scenario_selector.rb,
lib/rubino/memory/threat_scanner.rb,
lib/rubino/oauth/provider/github.rb,
lib/rubino/oauth/provider/google.rb,
lib/rubino/oauth/token_encryptor.rb,
lib/rubino/session/summary_store.rb,
lib/rubino/tools/ask_parent_tool.rb,
lib/rubino/tools/multi_edit_tool.rb,
lib/rubino/tools/shell_kill_tool.rb,
lib/rubino/tools/shell_tail_tool.rb,
lib/rubino/ui/streaming_markdown.rb,
lib/rubino/agent/iteration_budget.rb,
lib/rubino/commands/handlers/help.rb,
lib/rubino/commands/handlers/jobs.rb,
lib/rubino/config/reasoning_prefs.rb,
lib/rubino/context/file_discovery.rb,
lib/rubino/memory/backends/sqlite.rb,
lib/rubino/tools/attach_file_tool.rb,
lib/rubino/tools/background_tasks.rb,
lib/rubino/tools/shell_input_tool.rb,
lib/rubino/tools/task_result_tool.rb,
lib/rubino/agent/model_call_runner.rb,
lib/rubino/cli/chat/idle_card_host.rb,
lib/rubino/context/summary_builder.rb,
lib/rubino/interaction/image_input.rb,
lib/rubino/interaction/input_queue.rb,
lib/rubino/llm/inline_think_filter.rb,
lib/rubino/memory/backends/default.rb,
lib/rubino/security/deny_persister.rb,
lib/rubino/security/hardline_guard.rb,
lib/rubino/security/prefix_deriver.rb,
lib/rubino/skills/state_repository.rb,
lib/rubino/tools/answer_child_tool.rb,
lib/rubino/tools/shell_output_tool.rb,
lib/rubino/ui/probe_wait_indicator.rb,
lib/rubino/agent/response_validator.rb,
lib/rubino/commands/handlers/agents.rb,
lib/rubino/commands/handlers/config.rb,
lib/rubino/commands/handlers/memory.rb,
lib/rubino/commands/handlers/skills.rb,
lib/rubino/commands/handlers/status.rb,
lib/rubino/context/message_boundary.rb,
lib/rubino/context/prompt_assembler.rb,
lib/rubino/documents/converters/csv.rb,
lib/rubino/documents/converters/pdf.rb,
lib/rubino/documents/converters/xml.rb,
lib/rubino/interaction/cancel_token.rb,
lib/rubino/jobs/cron_job_repository.rb,
lib/rubino/security/approval_policy.rb,
lib/rubino/security/pattern_matcher.rb,
lib/rubino/tools/custom_tool_loader.rb,
lib/rubino/tools/custom_tool_loader.rb,
lib/rubino/agent/degenerate_recovery.rb,
lib/rubino/api/middleware/rate_limit.rb,
lib/rubino/cli/chat/session_resolver.rb,
lib/rubino/documents/converters/docx.rb,
lib/rubino/documents/converters/html.rb,
lib/rubino/documents/converters/json.rb,
lib/rubino/documents/converters/pptx.rb,
lib/rubino/documents/converters/xlsx.rb,
lib/rubino/llm/bedrock_bearer_client.rb,
lib/rubino/run/attachment_downloader.rb,
lib/rubino/tools/session_search_tool.rb,
lib/rubino/tools/summarize_file_tool.rb,
lib/rubino/api/middleware/json_parser.rb,
lib/rubino/attachments/classification.rb,
lib/rubino/commands/handlers/sessions.rb,
lib/rubino/documents/converters/plain.rb,
lib/rubino/run/session_approval_cache.rb,
lib/rubino/security/command_allowlist.rb,
lib/rubino/security/readonly_commands.rb,
lib/rubino/tools/read_attachment_tool.rb,
lib/rubino/tools/tool_call_repository.rb,
lib/rubino/cli/chat/completion_builder.rb,
lib/rubino/context/tool_pair_sanitizer.rb,
lib/rubino/interaction/clipboard_image.rb,
lib/rubino/oauth/connection_repository.rb,
lib/rubino/security/dangerous_patterns.rb,
lib/rubino/security/doom_loop_detector.rb,
lib/rubino/api/middleware/error_handler.rb,
lib/rubino/api/middleware/observability.rb,
lib/rubino/security/allowlist_persister.rb,
lib/rubino/agent/truncation_continuation.rb,
lib/rubino/context/environment_inspector.rb,
lib/rubino/api/operations/health_operation.rb,
lib/rubino/api/operations/oauth/serializer.rb,
lib/rubino/api/operations/tasks/serializer.rb,
lib/rubino/jobs/handlers/distill_skill_job.rb,
lib/rubino/memory/sqlite_extraction_prompt.rb,
lib/rubino/api/operations/metrics_operation.rb,
lib/rubino/jobs/handlers/extract_memory_job.rb,
lib/rubino/jobs/handlers/compact_session_job.rb,
lib/rubino/api/operations/mode/show_operation.rb,
lib/rubino/api/operations/runs/stop_operation.rb,
lib/rubino/jobs/handlers/cleanup_sessions_job.rb,
lib/rubino/api/operations/files/read_operation.rb,
lib/rubino/api/operations/tasks/show_operation.rb,
lib/rubino/api/operations/tasks/stop_operation.rb,
lib/rubino/jobs/handlers/summarize_session_job.rb,
lib/rubino/api/operations/mode/update_operation.rb,
lib/rubino/api/operations/models/list_operation.rb,
lib/rubino/api/operations/runs/create_operation.rb,
lib/rubino/api/operations/runs/events_operation.rb,
lib/rubino/api/operations/skills/list_operation.rb,
lib/rubino/api/operations/tasks/index_operation.rb,
lib/rubino/api/operations/files/upload_operation.rb,
lib/rubino/api/operations/memory/index_operation.rb,
lib/rubino/api/operations/memory/stats_operation.rb,
lib/rubino/api/operations/memory/delete_operation.rb,
lib/rubino/api/operations/sessions/show_operation.rb,
lib/rubino/api/operations/sessions/undo_operation.rb,
lib/rubino/api/operations/skills/toggle_operation.rb,
lib/rubino/api/operations/cron_jobs/list_operation.rb,
lib/rubino/api/operations/cron_jobs/show_operation.rb,
lib/rubino/api/operations/sessions/index_operation.rb,
lib/rubino/api/operations/sessions/retry_operation.rb,
lib/rubino/api/operations/cron_jobs/pause_operation.rb,
lib/rubino/api/operations/sessions/create_operation.rb,
lib/rubino/api/operations/sessions/delete_operation.rb,
lib/rubino/api/operations/approvals/decide_operation.rb,
lib/rubino/api/operations/cron_jobs/create_operation.rb,
lib/rubino/api/operations/cron_jobs/delete_operation.rb,
lib/rubino/api/operations/cron_jobs/resume_operation.rb,
lib/rubino/api/operations/cron_jobs/update_operation.rb,
lib/rubino/api/operations/cron_jobs/trigger_operation.rb,
lib/rubino/api/operations/cron_jobs/schedule_validation.rb,
lib/rubino/api/operations/oauth/providers/list_operation.rb,
lib/rubino/api/operations/clarifications/decide_operation.rb,
lib/rubino/api/operations/oauth/connections/list_operation.rb,
lib/rubino/api/operations/oauth/providers/connect_operation.rb,
lib/rubino/api/operations/oauth/providers/callback_operation.rb,
lib/rubino/api/operations/oauth/connections/disconnect_operation.rb
Overview
Module-level DSL method for defining custom tools
Defined Under Namespace
Modules: API, ActiveSkill, Agent, Attachments, Boot, CLI, Commands, Config, Context, Database, Documents, Files, Interaction, Jobs, LLM, MCP, Memory, Metrics, Modes, OAuth, Plugins, Run, Security, Session, Skills, Tools, Trust, UI, UpdateCheck, Util, Workspace Classes: AmbiguousSessionError, CompactionError, ConfigurationError, ConflictError, DatabaseError, EmptyModelResponseError, Error, Interrupted, JobError, Logger, NotFoundError, PayloadTooLargeError, SessionError, StreamInterruptedError, ToolError, UnauthorizedError, UpstreamError, ValidationError
Constant Summary collapse
- VERSION =
"0.3.0"
Class Attribute Summary collapse
-
.agent_registry ⇒ Object
Returns the shared agent registry (primary/subagent/utility definitions).
-
.logger ⇒ Object
Returns the current structured logger.
-
.ui ⇒ Object
Returns the current UI adapter instance.
Class Method Summary collapse
-
.active_event_bus ⇒ Object
The EventBus of the CURRENTLY-RUNNING parent turn.
-
.background_sink ⇒ Object
The InputQueue of the CURRENTLY-RUNNING parent turn, if any.
-
.configuration ⇒ Object
Returns the current configuration instance.
-
.configure {|configuration| ... } ⇒ Object
Yields the configuration for block-style setup.
-
.current_subagent_id ⇒ Object
The BackgroundTasks entry id of the subagent run executing on THIS thread, if any.
-
.database ⇒ Object
Returns the database connection.
- .define_tool ⇒ Object
-
.ensure_database_ready! ⇒ Object
First-run guard for any DB-touching entry point.
-
.ensure_directories! ⇒ Object
Ensures the home directory and subdirectories exist.
-
.event_bus ⇒ Object
Returns the event bus instance.
-
.home_path ⇒ Object
Returns the home directory path.
-
.loader ⇒ Object
Returns the Zeitwerk loader for autoloading.
-
.plugin ⇒ Object
DSL for defining plugins.
-
.plugin_registry ⇒ Object
Returns the plugin registry.
-
.reload_configuration! ⇒ Object
Drops the memoized configuration so the next #configuration reload reads config.yml / .env fresh.
-
.reset! ⇒ Object
Resets all memoized state (useful for testing).
-
.with_background_sink(queue) ⇒ Object
Binds
queueas the background-subagent notification sink for the duration of the block (set by Interaction::Lifecycle around the turn, exactly like #with_ui binds the run’s UI). -
.with_current_subagent_id(id) ⇒ Object
Binds
idas the current subagent id for the duration of the block (set by TaskTool around the child run, exactly like #with_ui / the background sink). -
.with_event_bus(bus) ⇒ Object
Binds
busas the turn-scoped event bus for the duration of the block (set by Interaction::Lifecycle around the loop run, like #with_ui binds the UI). -
.with_ui(adapter) ⇒ Object
Runs the block with
adapteras the thread-scoped UI, restoring the previous value afterwards (nested-safe).
Class Attribute Details
.agent_registry ⇒ Object
Returns the shared agent registry (primary/subagent/utility definitions). Memoized process-wide so the ‘task` tool can resolve a subagent by name at call time without each boot path having to thread an instance through the tool executor. Both entry points (CLI ChatCommand, API ServerCommand) touch this at boot so delegation works identically over /v1 and in chat; the tool also reads it lazily here, so a stripped boot still resolves.
254 255 256 |
# File 'lib/rubino.rb', line 254 def agent_registry @agent_registry ||= Agent::AgentRegistry.new end |
.logger ⇒ Object
Returns the current structured logger.
207 208 209 |
# File 'lib/rubino.rb', line 207 def logger @logger ||= Logger.new end |
.ui ⇒ Object
Returns the current UI adapter instance.
A thread-local override (set via #with_ui) wins over the process-global adapter. This is what lets the API server run many runs concurrently: each run executes in its own thread (Run::Executor#start) with its own gated UI::API, and tools that reach for the global adapter (QuestionTool#ask, TaskTool) resolve to THAT run’s UI — not a shared, gate-less global that would silently drop interactive prompts (the clarify/‘question` flow) and could cross-talk between runs.
120 121 122 |
# File 'lib/rubino.rb', line 120 def ui Thread.current[:rubino_ui] || (@ui ||= UI.build(configuration.ui_adapter)) end |
Class Method Details
.active_event_bus ⇒ Object
The EventBus of the CURRENTLY-RUNNING parent turn. The API/server path injects a fresh per-run bus (Run::Executor) that its Recorder is attached to; the CLI path uses the process-global bus. A backgrounded ‘task` subagent emits its SPAWNED/COMPLETED/FAILED lifecycle events here so they reach THAT run’s recorder (and SSE stream) rather than a detached global bus. Falls back to the global bus when no turn-scoped bus is bound.
145 146 147 |
# File 'lib/rubino.rb', line 145 def active_event_bus Thread.current[:rubino_event_bus] || event_bus end |
.background_sink ⇒ Object
The InputQueue of the CURRENTLY-RUNNING parent turn, if any. A background subagent (TaskTool) reads this to deliver its completion notification back into the parent’s live loop — the parent picks it up at its next iteration boundary via Loop#inject_steered_input, so the notice lands as a user message between turns, NEVER between an assistant tool_use and its results. Nil on the API/server path (no steering queue) — there the result is still reachable via the BackgroundTasks registry / ‘task_result`.
167 168 169 |
# File 'lib/rubino.rb', line 167 def background_sink Thread.current[:rubino_background_sink] end |
.configuration ⇒ Object
Returns the current configuration instance
93 94 95 |
# File 'lib/rubino.rb', line 93 def configuration @configuration ||= Config::Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Yields the configuration for block-style setup
98 99 100 101 |
# File 'lib/rubino.rb', line 98 def configure yield(configuration) if block_given? configuration end |
.current_subagent_id ⇒ Object
The BackgroundTasks entry id of the subagent run executing on THIS thread, if any. Set by TaskTool#run_child_thread around the child Runner#run! so a tool the child invokes (today: ask_parent) can find its own registry entry — the card it surfaces on, the steer queue it receives answers through —without threading the id through the loop/executor/tool signatures. Nil on the parent thread and on any non-delegated (top-level) run, which is the signal ask_parent uses to refuse (a top-level agent has no parent to ask).
190 191 192 |
# File 'lib/rubino.rb', line 190 def current_subagent_id Thread.current[:rubino_current_subagent_id] end |
.database ⇒ Object
Returns the database connection
215 216 217 |
# File 'lib/rubino.rb', line 215 def database @database ||= Database::Connection.new(configuration.database_path) end |
.define_tool ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/rubino/tools/custom_tool_loader.rb', line 112 def self.define_tool(&) builder = Tools::CustomToolBuilder.new builder.instance_eval(&) tool = builder.build Tools::Registry.register(tool) tool end |
.ensure_database_ready! ⇒ Object
First-run guard for any DB-touching entry point. A brand-new RUBINO_HOME has no schema yet (setup/chat hasn’t migrated it), so a read path like ‘rubino sessions list` would otherwise hit a raw `SQLite3::SQLException: no such table` backtrace (#35). `healthy?` only runs `SELECT 1`, which passes the moment SQLite lazily creates the empty file — the tables are still missing — so we also check migrator.pending?. Migrations are idempotent, so this is safe to call on every command. This is the same logic the interactive `chat` command already used; promoted here so the read CLIs (sessions/memory/jobs) share one implementation. Returns true when the schema is ready, false when initialization failed (callers decide whether that’s fatal or degrades to an empty state).
230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/rubino.rb', line 230 def ensure_database_ready! connection = database migrator = Database::Migrator.new(connection) return true unless connection.healthy? == false || migrator.pending? ensure_directories! migrator.migrate! true rescue StandardError => e logger.debug(event: "ensure_database_ready_failed", error: "#{e.class}: #{e.}") false end |
.ensure_directories! ⇒ Object
Ensures the home directory and subdirectories exist. The home holds secrets (.env) and the database, so it is forced to 0700 here — the single code path every entry point (setup/chat/prompt/doctor) goes through to materialize the home — not just when ‘setup` ran first (#65): an auto-created home used to be left at the umask’s 0755.
296 297 298 299 300 301 302 303 304 |
# File 'lib/rubino.rb', line 296 def ensure_directories! home = home_path FileUtils.mkdir_p(home) File.chmod(0o700, home) %w[memories sessions logs skills commands tools plugins].each do |subdir| dir = File.join(home, subdir) FileUtils.mkdir_p(dir) unless File.directory?(dir) end end |
.event_bus ⇒ Object
Returns the event bus instance
244 245 246 |
# File 'lib/rubino.rb', line 244 def event_bus @event_bus ||= Interaction::EventBus.new end |
.home_path ⇒ Object
Returns the home directory path. Delegates to the SAME resolver the config Loader uses (RUBINO_HOME → else ~/.rubino) so the server (which loads config.yml through the Loader) and the CLI (config/setup/ doctor + ensure_directories!) never disagree about where state lives. Previously this read the YAML ‘paths.home` default (~/.rubino) and ignored $RUBINO_HOME, splitting the brain at first boot / for .env.
287 288 289 |
# File 'lib/rubino.rb', line 287 def home_path Rubino::Config::Loader.default_home_path end |
.loader ⇒ Object
Returns the Zeitwerk loader for autoloading
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rubino.rb', line 50 def loader @loader ||= begin loader = Zeitwerk::Loader.for_gem loader.inflector.inflect( # Acronym modules "cli" => "CLI", "llm" => "LLM", "ui" => "UI", "api" => "API", "tls" => "TLS", "mcp" => "MCP", "oauth" => "OAuth", # Files with compound names that need exact mapping "ruby_llm_adapter" => "RubyLLMAdapter", "mcp_tool_wrapper" => "MCPToolWrapper", "bedrock_bearer_client" => "BedrockBearerClient", "adapter_response" => "AdapterResponse", "indented_io" => "IndentedIO", "webfetch_tool" => "WebFetchTool", "websearch_tool" => "WebSearchTool", "github_tool" => "GitHubTool", "skill_tool" => "SkillTool", "custom_tool_loader" => "CustomToolLoader", "custom_tool_builder" => "CustomToolBuilder", "tool_pair_sanitizer" => "ToolPairSanitizer", "degenerate_recovery" => "DegenerateResponseRecovery" ) # Migrations are plain SQL files, not Ruby constants loader.ignore( File.("rubino/database/migrations", __dir__) ) # errors.rb defines multiple constants in Rubino (NotFoundError, ...), # not a single Rubino::Errors module — loaded manually via require_relative. loader.ignore(File.("rubino/errors.rb", __dir__)) # rubino-agent.rb is a require shim matching the gem name; it maps to no # Rubino constant (and "Rubino-agent" isn't a valid cname). Zeitwerk must # not try to manage it. loader.ignore(File.("rubino-agent.rb", __dir__)) loader end end |
.plugin ⇒ Object
DSL for defining plugins
267 268 269 |
# File 'lib/rubino.rb', line 267 def plugin(&) Plugins.registry.instance_eval(&) end |
.plugin_registry ⇒ Object
Returns the plugin registry
262 263 264 |
# File 'lib/rubino.rb', line 262 def plugin_registry Plugins.registry end |
.reload_configuration! ⇒ Object
Drops the memoized configuration so the next #configuration reload reads config.yml / .env fresh. Used after the first-run onboarding wizard writes them mid-process so the just-saved key is visible without a restart.
106 107 108 109 |
# File 'lib/rubino.rb', line 106 def reload_configuration! @configuration = nil configuration end |
.reset! ⇒ Object
Resets all memoized state (useful for testing)
272 273 274 275 276 277 278 279 |
# File 'lib/rubino.rb', line 272 def reset! @configuration = nil @ui = nil @database = nil @event_bus = nil @agent_registry = nil Plugins.reset! end |
.with_background_sink(queue) ⇒ Object
Binds queue as the background-subagent notification sink for the duration of the block (set by Interaction::Lifecycle around the turn, exactly like #with_ui binds the run’s UI). Thread-local so a tool can reach it with zero signature churn through the loop/executor.
175 176 177 178 179 180 181 |
# File 'lib/rubino.rb', line 175 def with_background_sink(queue) prev = Thread.current[:rubino_background_sink] Thread.current[:rubino_background_sink] = queue yield ensure Thread.current[:rubino_background_sink] = prev end |
.with_current_subagent_id(id) ⇒ Object
Binds id as the current subagent id for the duration of the block (set by TaskTool around the child run, exactly like #with_ui / the background sink). Thread-local so the child’s tools reach it with zero signature churn.
198 199 200 201 202 203 204 |
# File 'lib/rubino.rb', line 198 def with_current_subagent_id(id) prev = Thread.current[:rubino_current_subagent_id] Thread.current[:rubino_current_subagent_id] = id yield ensure Thread.current[:rubino_current_subagent_id] = prev end |
.with_event_bus(bus) ⇒ Object
Binds bus as the turn-scoped event bus for the duration of the block (set by Interaction::Lifecycle around the loop run, like #with_ui binds the UI). Thread-local so a tool reaches it with no signature churn.
152 153 154 155 156 157 158 |
# File 'lib/rubino.rb', line 152 def with_event_bus(bus) prev = Thread.current[:rubino_event_bus] Thread.current[:rubino_event_bus] = bus yield ensure Thread.current[:rubino_event_bus] = prev end |
.with_ui(adapter) ⇒ Object
Runs the block with adapter as the thread-scoped UI, restoring the previous value afterwards (nested-safe). Used by Run::Executor to bind the run’s gated UI::API for the duration of the worker thread so global ‘Rubino.ui` lookups inside tools hit the right, gated instance.
131 132 133 134 135 136 137 |
# File 'lib/rubino.rb', line 131 def with_ui(adapter) prev = Thread.current[:rubino_ui] Thread.current[:rubino_ui] = adapter yield ensure Thread.current[:rubino_ui] = prev end |