Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
ActiveAgent is a Rails framework for creating and managing AI agents. It provides a structured way to interact with AI services through agents that can generate text, images, speech-to-text, and text-to-speech. It includes modules for defining prompts, actions, and rendering generative UI, as well as scaling with asynchronous jobs and streaming.
Add this line to your application's Gemfile:
gem 'active_agent'
And then execute:
bundle install
rails generate agent inventory search
This will generate the following files:
app/agents/application_agent.rb
app/agents/inventory_agent.rb
app/views/inventory_agent/search.text.erb
app/views/inventory_agent/search.json.jbuilder
Agents are the core of ActiveAgent. An agent takes prompts and can perform actions to generate content. Agents are defined by a simple Ruby class that inherits from ActiveAgent::Base
and are located in the app/agents
directory.
#
inventory_agent.rb
class InventoryAgent < ActiveAgent::Base
generate_with :openai, model: 'gpt-4o-mini', temperature: 0.5, instructions: :inventory_operations
def search
@items = Item.search(params[:query])
end
def inventory_operations
@organization = Organization.find(params[:account_id])
prompt
end
end
ActiveAgent allows you to interact with various AI services to generate text, images, speech-to-text, and text-to-speech.
class SupportAgent < ActiveAgent::Base
generate_with :openai, model: 'gpt-4o-mini', instructions: :instructions
def perform(content, context)
@content = content
@context = context
end
def generate_message
provider_instance.generate(self)
end
private
def after_generate
broadcast_message
end
def broadcast_message
broadcast_append_later_to(
broadcast_stream,
target: broadcast_target,
partial: 'support_agent/message',
locals: { message: @message }
)
end
def broadcast_stream
"#{dom_id(@chat)}_messages"
end
end
ActiveAgent uses Action Prompt both for rendering instructions
prompt views as well as rendering action views. Prompts are Action Views that provide instructions for the agent to generate content.
<!--
instructions.text.erb
-->
INSTRUCTIONS: You are an inventory manager for <%= @organization.name %>. You can search for inventory or reconcile inventory using <%= assigned_actions %>
ActiveAgent supports asynchronous job processing and streaming for scalable AI interactions.
Use the generate_later
method to enqueue a job for later processing.
InventoryAgent.with(query: query).search.generate_later
Use the stream_with
method to handle streaming responses.
class InventoryAgent < ActiveAgent::Base
generate_with :openai, model: 'gpt-4o-mini', stream: :broadcast_results
private
def broadcast_results
proc do |chunk, _bytesize|
@message.content = @message.content + chunk
broadcast_append_to(
"#{dom_id(chat)}_messages",
partial: "messages/message",
locals: { message: @message, scroll_to: true },
target: "#{dom_id(chat)}_messages"
)
end
end
end
Bug reports and pull requests are welcome on GitHub at https://github.com/yourusername/active_agent.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that activeagent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.