Module: Ask::Agent
- Defined in:
- lib/ask/agent.rb,
lib/ask/agent.rb,
lib/ask/agent/cli.rb,
lib/ask/agent/chat.rb,
lib/ask/agent/loop.rb,
lib/ask/agent/test.rb,
lib/ask/agent/hooks.rb,
lib/ask/agent/events.rb,
lib/ask/agent/memory.rb,
lib/ask/agent/session.rb,
lib/ask/agent/version.rb,
lib/ask/agent/compactor.rb,
lib/ask/agent/evaluator.rb,
lib/ask/agent/reflector.rb,
lib/ask/agent/scheduler.rb,
lib/ask/agent/streaming.rb,
lib/ask/agent/sub_agent.rb,
lib/ask/agent/telemetry.rb,
lib/ask/agent/todo_list.rb,
lib/ask/agent/definition.rb,
lib/ask/agent/meta_agent.rb,
lib/ask/agent/todo_write.rb,
lib/ask/agent/output_read.rb,
lib/ask/agent/memory_write.rb,
lib/ask/agent/configuration.rb,
lib/ask/agent/memory_search.rb,
lib/ask/agent/tool_executor.rb,
lib/ask/agent/approval_queue.rb,
lib/ask/agent/artifact_store.rb,
lib/ask/agent/context_source.rb,
lib/ask/agent/exit_plan_mode.rb,
lib/ask/agent/system_context.rb,
lib/ask/agent/context_sources.rb,
lib/ask/agent/middleware/base.rb,
lib/ask/agent/checkpoint_store.rb,
lib/ask/agent/memory_extractor.rb,
lib/ask/agent/persistence/base.rb,
lib/ask/agent/tool_call_repair.rb,
lib/ask/agent/tool_output_store.rb,
lib/ask/agent/policies/audit_log.rb,
lib/ask/agent/middleware/pipeline.rb,
lib/ask/agent/middleware/log_calls.rb,
lib/ask/agent/policies/permissions.rb,
lib/ask/agent/persistence/in_memory.rb,
lib/ask/agent/policies/rate_limiter.rb,
lib/ask/agent/tool_abort_controller.rb,
lib/ask/agent/stream_transforms/base.rb,
lib/ask/agent/policies/approval_policy.rb,
lib/ask/agent/middleware/model_fallback.rb,
lib/ask/agent/policies/permission_rules.rb,
lib/ask/agent/stream_transforms/pipeline.rb,
lib/ask/agent/middleware/default_settings.rb,
lib/ask/agent/middleware/retry_on_failure.rb,
lib/ask/agent/stream_transforms/text_buffer.rb,
lib/ask/agent/stream_transforms/extract_json.rb,
lib/ask/agent/stream_transforms/thinking_separator.rb,
lib/ask/agent/policies/audit_log/active_record_writer.rb
Defined Under Namespace
Modules: CLI, ContextSources, Events, Middleware, Persistence, Policies, StreamTransforms, Streaming, Test Classes: Aborted, ApprovalQueue, ArtifactStore, Chat, ChatChunk, CheckpointStore, CompactionFailed, Compactor, Configuration, ContextSource, Definition, Error, Evaluator, ExitPlanMode, Hooks, Loop, LoopDetected, MaxTurnsExceeded, Memory, MemoryExtractor, MemorySearch, MemoryWrite, MetaAgent, OutputRead, Reflector, ResponseMessage, Scheduler, SchedulerConfig, Session, SessionNotPersisted, SubAgent, SystemContext, Telemetry, TodoList, TodoWrite, ToolAbortController, ToolCallInfo, ToolCallRepair, ToolExecutionError, ToolExecutor, ToolOutputStore, UnknownAgent
Constant Summary collapse
- VERSION =
"0.38.0"
Class Method Summary collapse
-
.configuration ⇒ Object
Register the global config.
- .configure {|configuration| ... } ⇒ Object
-
.current_session ⇒ Ask::Agent::Session?
The session running on this thread.
- .current_session=(session) ⇒ Object
-
.current_tool_call_id ⇒ String?
The tool call id being executed on this thread.
-
.default_agent_paths ⇒ Object
Paths where agent directories are discovered.
-
.definitions ⇒ Hash<String, Array(Class, String)>
All discovered agent definitions, keyed by name.
- .load_policies ⇒ Object
-
.new(name, **opts) ⇒ Session
Create a new agent session from a named definition.
-
.rediscover! ⇒ Object
Force re-discovery of agent definitions.
-
.resolve_tool_symbol(symbol) ⇒ Object
Resolve a tool symbol to a tool class.
Class Method Details
.configuration ⇒ Object
Register the global config
260 261 262 |
# File 'lib/ask/agent.rb', line 260 def self.configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
264 265 266 |
# File 'lib/ask/agent.rb', line 264 def self.configure yield configuration end |
.current_session ⇒ Ask::Agent::Session?
Returns the session running on this thread.
314 315 316 |
# File 'lib/ask/agent.rb', line 314 def current_session Thread.current[:ask_agent_current_session] end |
.current_session=(session) ⇒ Object
319 320 321 |
# File 'lib/ask/agent.rb', line 319 def current_session=(session) Thread.current[:ask_agent_current_session] = session end |
.current_tool_call_id ⇒ String?
Returns the tool call id being executed on this thread.
324 325 326 |
# File 'lib/ask/agent.rb', line 324 def current_tool_call_id Thread.current[:ask_agent_tool_call_id] end |
.default_agent_paths ⇒ Object
Paths where agent directories are discovered.
107 108 109 110 111 112 |
# File 'lib/ask/agent.rb', line 107 def default_agent_paths [ File.join(Dir.pwd, "agents"), File.join(Dir.pwd, "app", "agents") ] end |
.definitions ⇒ Hash<String, Array(Class, String)>
All discovered agent definitions, keyed by name. Triggers discovery on first call.
79 80 81 82 |
# File 'lib/ask/agent.rb', line 79 def definitions discover! @registry.dup end |
.load_policies ⇒ Object
268 269 270 271 |
# File 'lib/ask/agent.rb', line 268 def self.load_policies Dir[File.("agent/policies/*.rb", __dir__)].each { |f| require f } rescue Errno::ENOENT end |
.new(name, **opts) ⇒ Session
Create a new agent session from a named definition.
90 91 92 93 94 95 96 97 |
# File 'lib/ask/agent.rb', line 90 def new(name, **opts) discover! entry = @registry[name.to_s] raise UnknownAgent, "Unknown agent: #{name.inspect}. Searched agents/ and app/agents/." unless entry klass, dir = entry build_session_from_definition(klass, dir, opts) end |
.rediscover! ⇒ Object
Force re-discovery of agent definitions.
100 101 102 103 104 |
# File 'lib/ask/agent.rb', line 100 def rediscover! @discovered = false @registry = {} discover! end |
.resolve_tool_symbol(symbol) ⇒ Object
Resolve a tool symbol to a tool class. Checks the shared tools directory first, then falls back to the global tool registry from ask-tools.
117 118 119 120 121 122 123 |
# File 'lib/ask/agent.rb', line 117 def resolve_tool_symbol(symbol) @shared_tools[symbol.to_s] || begin Ask::Tools[symbol.to_s] rescue StandardError nil end end |