Module: Xeno
- Defined in:
- lib/xeno.rb,
lib/xeno/info.rb,
lib/xeno/tool.rb,
lib/xeno/hooks.rb,
lib/xeno/engine.rb,
lib/xeno/errors.rb,
lib/xeno/inputs.rb,
lib/xeno/reaper.rb,
lib/xeno/version.rb,
lib/xeno/channels.rb,
lib/xeno/arguments.rb,
lib/xeno/schedules.rb,
lib/xeno/compaction.rb,
lib/xeno/standalone.rb,
app/models/xeno/chat.rb,
app/models/xeno/turn.rb,
lib/xeno/turn_runner.rb,
app/models/xeno/dedup.rb,
app/models/xeno/event.rb,
lib/xeno/agent_config.rb,
lib/xeno/ask_question.rb,
app/jobs/xeno/turn_job.rb,
app/models/xeno/action.rb,
lib/xeno/configuration.rb,
lib/xeno/session_state.rb,
app/models/xeno/message.rb,
app/models/xeno/session.rb,
lib/xeno/channels/slack.rb,
app/jobs/xeno/reaper_job.rb,
lib/xeno/agent_definition.rb,
lib/xeno/approval_context.rb,
app/jobs/xeno/schedule_job.rb,
app/jobs/xeno/application_job.rb,
app/jobs/xeno/slack_event_job.rb,
app/models/xeno/pending_message.rb,
lib/xeno/standalone/local_secret.rb,
lib/xeno/standalone/model_refresh.rb,
app/models/xeno/application_record.rb,
app/controllers/xeno/api_controller.rb,
app/controllers/xeno/dev_controller.rb,
app/helpers/xeno/application_helper.rb,
app/mailers/xeno/application_mailer.rb,
app/controllers/xeno/slack_controller.rb,
app/controllers/xeno/dev_ui_controller.rb,
app/controllers/xeno/health_controller.rb,
app/controllers/xeno/streams_controller.rb,
lib/generators/xeno/tool/tool_generator.rb,
app/controllers/xeno/sessions_controller.rb,
app/controllers/xeno/application_controller.rb,
lib/generators/xeno/install/install_generator.rb
Defined Under Namespace
Modules: ApplicationHelper, Arguments, Channels, Compaction, Generators, Hooks, Info, Inputs, Reaper, Schedules, Standalone Classes: Action, AgentConfig, AgentDefinition, ApiController, ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, ApprovalContext, AskQuestion, BudgetExceeded, Chat, Configuration, Dedup, DevController, DevUiController, Engine, Error, Event, Fenced, HealthController, Interrupted, MaxStepsExceeded, Message, Parked, PendingMessage, ReaperJob, ScheduleJob, Session, SessionState, SessionsController, SlackController, SlackEventJob, StandaloneApplication, StreamsController, Tool, Turn, TurnJob, TurnRunner
Constant Summary collapse
- VERSION =
"0.0.1"
Class Attribute Summary collapse
Class Method Summary collapse
-
.agent(&block) ⇒ Object
The agent/agent.rb entry point:.
-
.capture_agent_config ⇒ Object
:nodoc: loader bookkeeping around
load agent.rb. -
.capture_hooks ⇒ Object
:nodoc: loader bookkeeping around
load hooks/*.rb. -
.capture_instructions ⇒ Object
:nodoc: loader bookkeeping around
load instructions.rb. -
.captured_agent_config ⇒ Object
:nodoc:.
-
.captured_instructions ⇒ Object
:nodoc:.
- .channel(name, &block) ⇒ Object
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
- .default_agent_name ⇒ Object
-
.definition ⇒ Object
The resolved agent definition, discovered on first use and cached.
-
.dev_routes_enabled? ⇒ Boolean
Dev routes exist in development, or when XENO_DEV_ROUTES is exactly "1"/"true" (a truthy-check would let "0" enable them — S5).
-
.hook(event_type, &block) ⇒ Object
The agent/hooks/.rb entry point — observe-only handlers for stream events (any type from the vocabulary, or ""):.
-
.instructions(&block) ⇒ Object
The agent/instructions.rb entry point — dynamic instructions resolved at turn-stage time with the session context:.
- .rails_app ⇒ Object
- .reset_definition! ⇒ Object
Class Attribute Details
.agent_root ⇒ Object
28 29 30 |
# File 'lib/xeno.rb', line 28 def agent_root @agent_root ||= Rails.root.join("agent") end |
Class Method Details
.agent(&block) ⇒ Object
The agent/agent.rb entry point:
Xeno.agent do
model "anthropic/claude-sonnet-5"
end
38 39 40 41 42 |
# File 'lib/xeno.rb', line 38 def agent(&block) config = AgentConfig.new config.instance_eval(&block) if block @captured_agent_config = config end |
.capture_agent_config ⇒ Object
:nodoc: loader bookkeeping around load agent.rb
44 45 46 47 |
# File 'lib/xeno.rb', line 44 def capture_agent_config # :nodoc: loader bookkeeping around `load agent.rb` @captured_agent_config = nil yield end |
.capture_hooks ⇒ Object
:nodoc: loader bookkeeping around load hooks/*.rb
91 92 93 94 95 |
# File 'lib/xeno.rb', line 91 def capture_hooks # :nodoc: loader bookkeeping around `load hooks/*.rb` @captured_hooks = {} yield @captured_hooks end |
.capture_instructions ⇒ Object
:nodoc: loader bookkeeping around load instructions.rb
66 67 68 69 |
# File 'lib/xeno.rb', line 66 def capture_instructions # :nodoc: loader bookkeeping around `load instructions.rb` @captured_instructions = nil yield end |
.captured_agent_config ⇒ Object
:nodoc:
49 50 51 |
# File 'lib/xeno.rb', line 49 def captured_agent_config # :nodoc: @captured_agent_config end |
.captured_instructions ⇒ Object
:nodoc:
71 72 73 |
# File 'lib/xeno.rb', line 71 def captured_instructions # :nodoc: @captured_instructions end |
.channel(name, &block) ⇒ Object
63 64 65 66 67 |
# File 'lib/xeno/channels.rb', line 63 def self.channel(name, &block) channel = Channels.build(name, &block) Channels.register(name, channel) channel end |
.config ⇒ Object
110 111 112 |
# File 'lib/xeno/configuration.rb', line 110 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
114 115 116 |
# File 'lib/xeno/configuration.rb', line 114 def configure yield config end |
.default_agent_name ⇒ Object
107 108 109 |
# File 'lib/xeno.rb', line 107 def default_agent_name Rails.application.class.module_parent_name.underscore end |
.definition ⇒ Object
The resolved agent definition, discovered on first use and cached. Rails reloading resets it (see engine's to_prepare).
99 100 101 |
# File 'lib/xeno.rb', line 99 def definition @definition ||= AgentDefinition.load(agent_root, name: default_agent_name) end |
.dev_routes_enabled? ⇒ Boolean
Dev routes exist in development, or when XENO_DEV_ROUTES is exactly "1"/"true" (a truthy-check would let "0" enable them — S5).
113 114 115 |
# File 'lib/xeno.rb', line 113 def dev_routes_enabled? Rails.env.development? || %w[1 true].include?(ENV["XENO_DEV_ROUTES"].to_s) end |
.hook(event_type, &block) ⇒ Object
The agent/hooks/.rb entry point — observe-only handlers for stream events (any type from the vocabulary, or ""):
Xeno.hook "turn.completed" do |event|
Metrics.increment("agent.turns")
end
Handlers fire after the event commits, at-least-once (replays re-emit). Raising never breaks the runtime.
84 85 86 87 88 89 |
# File 'lib/xeno.rb', line 84 def hook(event_type, &block) raise ArgumentError, "Xeno.hook requires a block" unless block (@captured_hooks ||= {})[event_type.to_s] ||= [] @captured_hooks[event_type.to_s] << block end |
.instructions(&block) ⇒ Object
The agent/instructions.rb entry point — dynamic instructions resolved at turn-stage time with the session context:
Xeno.instructions do |context|
"You are helping #{context.principal&.dig("name") || "a guest"}."
end
Composes with the static instructions.md: static first, the block's return appended. The block runs on EVERY turn stage — keep it fast.
62 63 64 |
# File 'lib/xeno.rb', line 62 def instructions(&block) @captured_instructions = block end |
.rails_app ⇒ Object
133 134 135 |
# File 'lib/xeno/standalone.rb', line 133 def self.rails_app Standalone.boot! end |
.reset_definition! ⇒ Object
103 104 105 |
# File 'lib/xeno.rb', line 103 def reset_definition! @definition = nil end |