activeagent 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +185 -0
- data/README.md +58 -14
- data/lib/active_agent/base.rb +11 -2
- data/lib/active_agent/concerns/delegation.rb +385 -0
- data/lib/active_agent/delegation/backend.rb +109 -0
- data/lib/active_agent/delegation/budget.rb +138 -0
- data/lib/active_agent/delegation/contract.rb +117 -0
- data/lib/active_agent/delegation/definition.rb +95 -0
- data/lib/active_agent/delegation/ledger.rb +56 -0
- data/lib/active_agent/delegation/pricing.rb +106 -0
- data/lib/active_agent/delegation/runner.rb +283 -0
- data/lib/active_agent/delegation/schema.rb +220 -0
- data/lib/active_agent/providers/_base_provider.rb +97 -1
- data/lib/active_agent/providers/open_ai/chat_provider.rb +21 -2
- data/lib/active_agent/telemetry/configuration.rb +13 -9
- data/lib/active_agent/telemetry/instrumentation.rb +38 -1
- data/lib/active_agent/telemetry/tool_origin.rb +90 -0
- data/lib/active_agent/telemetry.rb +1 -0
- data/lib/active_agent/version.rb +1 -1
- data/lib/active_agent.rb +1 -5
- metadata +31 -32
- data/lib/active_agent/dashboard/app/controllers/active_agent/dashboard/api/traces_controller.rb +0 -138
- data/lib/active_agent/dashboard/app/controllers/active_agent/dashboard/application_controller.rb +0 -64
- data/lib/active_agent/dashboard/app/controllers/active_agent/dashboard/dashboard_controller.rb +0 -129
- data/lib/active_agent/dashboard/app/controllers/active_agent/dashboard/traces_controller.rb +0 -123
- data/lib/active_agent/dashboard/app/jobs/active_agent/dashboard/agent_execution_job.rb +0 -56
- data/lib/active_agent/dashboard/app/jobs/active_agent/dashboard/application_job.rb +0 -14
- data/lib/active_agent/dashboard/app/jobs/active_agent/dashboard/sandbox_cleanup_job.rb +0 -49
- data/lib/active_agent/dashboard/app/jobs/active_agent/dashboard/sandbox_provision_job.rb +0 -65
- data/lib/active_agent/dashboard/app/jobs/active_agent/process_telemetry_traces_job.rb +0 -86
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/agent.rb +0 -256
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/agent_run.rb +0 -113
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/agent_template.rb +0 -208
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/agent_version.rb +0 -60
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/application_record.rb +0 -46
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/recording_action.rb +0 -125
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/recording_snapshot.rb +0 -83
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/sandbox_run.rb +0 -52
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/sandbox_session.rb +0 -169
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/session_recording.rb +0 -193
- data/lib/active_agent/dashboard/app/models/active_agent/telemetry_trace.rb +0 -214
- data/lib/active_agent/dashboard/app/views/active_agent/dashboard/traces/_trace_detail.html.erb +0 -117
- data/lib/active_agent/dashboard/app/views/active_agent/dashboard/traces/index.html.erb +0 -135
- data/lib/active_agent/dashboard/app/views/active_agent/dashboard/traces/metrics.html.erb +0 -145
- data/lib/active_agent/dashboard/app/views/active_agent/dashboard/traces/show.html.erb +0 -36
- data/lib/active_agent/dashboard/app/views/layouts/active_agent/dashboard/application.html.erb +0 -94
- data/lib/active_agent/dashboard/config/routes.rb +0 -19
- data/lib/active_agent/dashboard/engine.rb +0 -43
- data/lib/active_agent/dashboard.rb +0 -161
- data/lib/generators/active_agent/dashboard/install_generator.rb +0 -92
- data/lib/generators/active_agent/dashboard/templates/active_agent_dashboard.rb.erb +0 -67
- data/lib/generators/active_agent/dashboard/templates/create_active_agent_telemetry_traces.rb.erb +0 -46
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rails/generators"
|
|
4
|
-
require "rails/generators/active_record"
|
|
5
|
-
|
|
6
|
-
module ActiveAgent
|
|
7
|
-
module Dashboard
|
|
8
|
-
# Generator for installing the ActiveAgent Dashboard.
|
|
9
|
-
#
|
|
10
|
-
# @example Run the generator
|
|
11
|
-
# rails generate active_agent:dashboard:install
|
|
12
|
-
#
|
|
13
|
-
# This will:
|
|
14
|
-
# - Create the telemetry_traces table migration
|
|
15
|
-
# - Add mount directive to routes
|
|
16
|
-
# - Create initializer for dashboard configuration
|
|
17
|
-
#
|
|
18
|
-
class InstallGenerator < Rails::Generators::Base
|
|
19
|
-
include ActiveRecord::Generators::Migration
|
|
20
|
-
|
|
21
|
-
source_root File.expand_path("templates", __dir__)
|
|
22
|
-
|
|
23
|
-
desc "Installs the ActiveAgent Dashboard with telemetry storage"
|
|
24
|
-
|
|
25
|
-
class_option :multi_tenant, type: :boolean, default: false,
|
|
26
|
-
desc: "Scope traces to an Account (adds account_id to the migration)"
|
|
27
|
-
|
|
28
|
-
class_option :skip_migrations, type: :boolean, default: false,
|
|
29
|
-
desc: "Skip copying the telemetry traces migration"
|
|
30
|
-
|
|
31
|
-
class_option :skip_routes, type: :boolean, default: false,
|
|
32
|
-
desc: "Skip adding the engine mount to routes.rb"
|
|
33
|
-
|
|
34
|
-
def copy_migrations
|
|
35
|
-
return if options[:skip_migrations]
|
|
36
|
-
|
|
37
|
-
migration_template(
|
|
38
|
-
"create_active_agent_telemetry_traces.rb.erb",
|
|
39
|
-
"db/migrate/create_active_agent_telemetry_traces.rb"
|
|
40
|
-
)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def add_route
|
|
44
|
-
return if options[:skip_routes]
|
|
45
|
-
|
|
46
|
-
# Rails' `route` action is only idempotent on an exact string match,
|
|
47
|
-
# so an app installed before the default path changed would get a
|
|
48
|
-
# second mount — and two unnamed mounts of the same engine raise
|
|
49
|
-
# "Invalid route name, already in use: 'active_agent'" at boot.
|
|
50
|
-
routes_file = File.join(destination_root, "config/routes.rb")
|
|
51
|
-
if File.exist?(routes_file) && File.read(routes_file).include?("ActiveAgent::Dashboard::Engine")
|
|
52
|
-
say_status :skip, "engine already mounted in config/routes.rb", :yellow
|
|
53
|
-
return
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
route 'mount ActiveAgent::Dashboard::Engine => "/activeagents"'
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def create_initializer
|
|
60
|
-
template(
|
|
61
|
-
"active_agent_dashboard.rb.erb",
|
|
62
|
-
"config/initializers/active_agent_dashboard.rb"
|
|
63
|
-
)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def show_readme
|
|
67
|
-
say "\n"
|
|
68
|
-
say "ActiveAgent Dashboard installed successfully!", :green
|
|
69
|
-
say "\n"
|
|
70
|
-
say "Next steps:"
|
|
71
|
-
say " 1. Run migrations: rails db:migrate"
|
|
72
|
-
say " 2. Configure telemetry in config/active_agent.yml:"
|
|
73
|
-
say " telemetry:"
|
|
74
|
-
say " enabled: true"
|
|
75
|
-
say " local_storage: true"
|
|
76
|
-
say " 3. Visit /activeagents to view the dashboard"
|
|
77
|
-
say "\n"
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
private
|
|
81
|
-
|
|
82
|
-
def migration_version
|
|
83
|
-
"[#{ActiveRecord::Migration.current_version}]"
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
# Consumed by the migration template.
|
|
87
|
-
def multi_tenant?
|
|
88
|
-
options[:multi_tenant]
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# ActiveAgent Dashboard Configuration
|
|
4
|
-
#
|
|
5
|
-
# This file configures the ActiveAgent telemetry dashboard.
|
|
6
|
-
# The dashboard is mounted at /activeagents by default (see config/routes.rb).
|
|
7
|
-
|
|
8
|
-
ActiveAgent::Dashboard.configure do |config|
|
|
9
|
-
# ==========================================================================
|
|
10
|
-
# Authentication (required in production)
|
|
11
|
-
# ==========================================================================
|
|
12
|
-
#
|
|
13
|
-
# Provide a lambda that receives the controller and performs
|
|
14
|
-
# authentication. Return false or raise to deny access. Without one, the
|
|
15
|
-
# dashboard serves a 403 in production — traces contain prompts, outputs
|
|
16
|
-
# and error messages.
|
|
17
|
-
#
|
|
18
|
-
# Basic auth:
|
|
19
|
-
# config.authentication_method = ->(controller) {
|
|
20
|
-
# controller.authenticate_or_request_with_http_basic do |username, password|
|
|
21
|
-
# username == "admin" && password == Rails.application.credentials.dashboard_password
|
|
22
|
-
# end
|
|
23
|
-
# }
|
|
24
|
-
#
|
|
25
|
-
# Devise:
|
|
26
|
-
# config.authentication_method = ->(controller) {
|
|
27
|
-
# controller.authenticate_admin!
|
|
28
|
-
# }
|
|
29
|
-
#
|
|
30
|
-
# No authentication (development only!):
|
|
31
|
-
# config.authentication_method = nil
|
|
32
|
-
#
|
|
33
|
-
config.authentication_method = nil
|
|
34
|
-
|
|
35
|
-
# ==========================================================================
|
|
36
|
-
# Ingest API authentication
|
|
37
|
-
# ==========================================================================
|
|
38
|
-
#
|
|
39
|
-
# Bearer token other apps must send when posting traces to the mounted
|
|
40
|
-
# ingest endpoint (/activeagents/api/traces). Leave unset only when the
|
|
41
|
-
# mount is not reachable beyond your own machine.
|
|
42
|
-
#
|
|
43
|
-
# config.ingest_api_key = Rails.application.credentials.dig(:active_agent, :ingest_api_key)
|
|
44
|
-
|
|
45
|
-
# ==========================================================================
|
|
46
|
-
# Multi-tenant mode (SaaS platforms only)
|
|
47
|
-
# ==========================================================================
|
|
48
|
-
#
|
|
49
|
-
# Scopes traces per account and authenticates ingest with per-account
|
|
50
|
-
# keys. Most self-hosted installs should leave this off.
|
|
51
|
-
#
|
|
52
|
-
# config.multi_tenant = true
|
|
53
|
-
# config.account_class = "Account"
|
|
54
|
-
# config.user_class = "User"
|
|
55
|
-
# config.current_account_method = :current_account
|
|
56
|
-
# config.current_user_method = :current_user
|
|
57
|
-
|
|
58
|
-
# ==========================================================================
|
|
59
|
-
# UI
|
|
60
|
-
# ==========================================================================
|
|
61
|
-
#
|
|
62
|
-
# Custom layout for dashboard views (the default layout loads Tailwind,
|
|
63
|
-
# Turbo and Stimulus from CDNs — override for CSP-strict or air-gapped
|
|
64
|
-
# environments).
|
|
65
|
-
#
|
|
66
|
-
# config.layout = "application"
|
|
67
|
-
end
|
data/lib/generators/active_agent/dashboard/templates/create_active_agent_telemetry_traces.rb.erb
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CreateActiveAgentTelemetryTraces < ActiveRecord::Migration<%= migration_version %>
|
|
4
|
-
def change
|
|
5
|
-
create_table :active_agent_telemetry_traces do |t|
|
|
6
|
-
<% if multi_tenant? -%>
|
|
7
|
-
# Multi-tenant mode: every query is scoped through `for_account`, and
|
|
8
|
-
# ingest authenticates a per-account key. The foreign key requires an
|
|
9
|
-
# existing `accounts` table — on PostgreSQL/MySQL this migration must
|
|
10
|
-
# run after the one that creates it (drop `foreign_key: true` if your
|
|
11
|
-
# tenant table is named differently).
|
|
12
|
-
t.references :account, null: false, foreign_key: true
|
|
13
|
-
<% end -%>
|
|
14
|
-
t.string :trace_id, null: false
|
|
15
|
-
t.string :service_name
|
|
16
|
-
t.string :environment
|
|
17
|
-
t.datetime :timestamp, index: true
|
|
18
|
-
t.json :spans, default: []
|
|
19
|
-
t.json :resource_attributes, default: {}
|
|
20
|
-
t.json :sdk_info, default: {}
|
|
21
|
-
t.decimal :total_duration_ms, precision: 12, scale: 3
|
|
22
|
-
t.integer :total_input_tokens, default: 0
|
|
23
|
-
t.integer :total_output_tokens, default: 0
|
|
24
|
-
t.integer :total_thinking_tokens, default: 0
|
|
25
|
-
t.string :status
|
|
26
|
-
t.string :agent_class, index: true
|
|
27
|
-
t.string :agent_action
|
|
28
|
-
t.text :error_message
|
|
29
|
-
|
|
30
|
-
t.timestamps
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
<% if multi_tenant? -%>
|
|
34
|
-
# Ingest dedupes on trace_id (per account when multi-tenant); the unique
|
|
35
|
-
# index makes that dedupe race-proof rather than check-then-insert.
|
|
36
|
-
add_index :active_agent_telemetry_traces, [:account_id, :trace_id], unique: true
|
|
37
|
-
add_index :active_agent_telemetry_traces, [:account_id, :timestamp]
|
|
38
|
-
<% else -%>
|
|
39
|
-
add_index :active_agent_telemetry_traces, :trace_id, unique: true
|
|
40
|
-
<% end -%>
|
|
41
|
-
add_index :active_agent_telemetry_traces, :status
|
|
42
|
-
add_index :active_agent_telemetry_traces, [:agent_class, :agent_action]
|
|
43
|
-
add_index :active_agent_telemetry_traces, [:service_name, :environment]
|
|
44
|
-
add_index :active_agent_telemetry_traces, :created_at
|
|
45
|
-
end
|
|
46
|
-
end
|