activeagent 1.0.2 → 1.1.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 +71 -0
- data/README.md +26 -0
- data/lib/active_agent/base.rb +4 -0
- data/lib/active_agent/concerns/view.rb +1 -1
- data/lib/active_agent/dashboard/app/controllers/active_agent/dashboard/api/traces_controller.rb +27 -6
- data/lib/active_agent/dashboard/app/controllers/active_agent/dashboard/application_controller.rb +11 -1
- data/lib/active_agent/dashboard/app/controllers/active_agent/dashboard/dashboard_controller.rb +15 -12
- data/lib/active_agent/dashboard/app/controllers/active_agent/dashboard/traces_controller.rb +27 -7
- data/lib/active_agent/dashboard/app/jobs/active_agent/process_telemetry_traces_job.rb +9 -0
- data/lib/active_agent/dashboard/app/models/active_agent/dashboard/agent.rb +1 -1
- data/lib/active_agent/dashboard/app/models/active_agent/telemetry_trace.rb +18 -2
- data/lib/active_agent/dashboard/app/views/active_agent/dashboard/traces/_trace_detail.html.erb +15 -3
- data/lib/active_agent/dashboard/app/views/active_agent/dashboard/traces/metrics.html.erb +3 -1
- data/lib/active_agent/dashboard/app/views/layouts/active_agent/dashboard/application.html.erb +4 -4
- data/lib/active_agent/dashboard/config/routes.rb +5 -64
- data/lib/active_agent/dashboard/engine.rb +19 -15
- data/lib/active_agent/dashboard.rb +13 -3
- data/lib/active_agent/model_capabilities.rb +89 -0
- data/lib/active_agent/providers/_base_provider.rb +23 -2
- data/lib/active_agent/providers/anthropic/request.rb +3 -1
- data/lib/active_agent/providers/anthropic/transforms.rb +88 -0
- data/lib/active_agent/providers/bedrock_provider.rb +2 -2
- data/lib/active_agent/providers/concerns/exception_handler.rb +12 -1
- data/lib/active_agent/providers/errors.rb +140 -0
- data/lib/active_agent/providers/mock/request.rb +1 -4
- data/lib/active_agent/providers/ollama/chat/transforms.rb +9 -3
- data/lib/active_agent/providers/open_ai/chat_provider.rb +3 -3
- data/lib/active_agent/providers/requesty/_types.rb +16 -0
- data/lib/active_agent/providers/requesty/options.rb +39 -0
- data/lib/active_agent/providers/requesty_provider.rb +63 -0
- data/lib/active_agent/railtie.rb +5 -0
- data/lib/active_agent/telemetry/configuration.rb +112 -172
- data/lib/active_agent/telemetry/instrumentation.rb +137 -14
- data/lib/active_agent/telemetry/reporter.rb +12 -165
- data/lib/active_agent/telemetry/span.rb +18 -245
- data/lib/active_agent/telemetry/tracer.rb +67 -70
- data/lib/active_agent/telemetry.rb +1 -2
- data/lib/active_agent/version.rb +1 -1
- data/lib/active_agent.rb +5 -0
- data/lib/generators/active_agent/dashboard/install_generator.rb +30 -2
- data/lib/generators/active_agent/dashboard/templates/active_agent_dashboard.rb.erb +41 -4
- data/lib/generators/active_agent/dashboard/templates/create_active_agent_telemetry_traces.rb.erb +20 -4
- metadata +39 -16
- data/lib/generators/active_agent/dashboard/install/install_generator.rb +0 -96
- data/lib/generators/active_agent/dashboard/install/templates/initializer.rb +0 -89
- data/lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_agent_runs.rb +0 -42
- data/lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_agent_templates.rb +0 -38
- data/lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_agent_versions.rb +0 -22
- data/lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_agents.rb +0 -53
- data/lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_sandbox_runs.rb +0 -28
- data/lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_sandbox_sessions.rb +0 -43
- data/lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_session_recordings.rb +0 -44
- data/lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_telemetry_traces.rb +0 -56
data/lib/active_agent/version.rb
CHANGED
data/lib/active_agent.rb
CHANGED
|
@@ -16,6 +16,10 @@ require "active_support/lazy_load_hooks"
|
|
|
16
16
|
# Module Level Extensions
|
|
17
17
|
require "active_agent/configuration"
|
|
18
18
|
require "active_agent/railtie" if defined?(Rails)
|
|
19
|
+
# The dashboard is a Rails engine; engines must be defined when the gem is
|
|
20
|
+
# required (before the host app collects railtie initializers), so it
|
|
21
|
+
# cannot be left to the Dashboard autoload above.
|
|
22
|
+
require "active_agent/dashboard" if defined?(Rails)
|
|
19
23
|
|
|
20
24
|
# ActiveAgent is a framework for building AI agents with Rails-like conventions.
|
|
21
25
|
#
|
|
@@ -101,6 +105,7 @@ module ActiveAgent
|
|
|
101
105
|
autoload :Preview, "active_agent/concerns/preview"
|
|
102
106
|
autoload :Previews, "active_agent/concerns/preview"
|
|
103
107
|
autoload :GenerationJob
|
|
108
|
+
autoload :ModelCapabilities
|
|
104
109
|
autoload :Observers, "active_agent/concerns/observers"
|
|
105
110
|
autoload :Provider, "active_agent/concerns/provider"
|
|
106
111
|
autoload :Rescue, "active_agent/concerns/rescue"
|
|
@@ -22,7 +22,18 @@ module ActiveAgent
|
|
|
22
22
|
|
|
23
23
|
desc "Installs the ActiveAgent Dashboard with telemetry storage"
|
|
24
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
|
+
|
|
25
34
|
def copy_migrations
|
|
35
|
+
return if options[:skip_migrations]
|
|
36
|
+
|
|
26
37
|
migration_template(
|
|
27
38
|
"create_active_agent_telemetry_traces.rb.erb",
|
|
28
39
|
"db/migrate/create_active_agent_telemetry_traces.rb"
|
|
@@ -30,7 +41,19 @@ module ActiveAgent
|
|
|
30
41
|
end
|
|
31
42
|
|
|
32
43
|
def add_route
|
|
33
|
-
|
|
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"'
|
|
34
57
|
end
|
|
35
58
|
|
|
36
59
|
def create_initializer
|
|
@@ -50,7 +73,7 @@ module ActiveAgent
|
|
|
50
73
|
say " telemetry:"
|
|
51
74
|
say " enabled: true"
|
|
52
75
|
say " local_storage: true"
|
|
53
|
-
say " 3. Visit /
|
|
76
|
+
say " 3. Visit /activeagents to view the dashboard"
|
|
54
77
|
say "\n"
|
|
55
78
|
end
|
|
56
79
|
|
|
@@ -59,6 +82,11 @@ module ActiveAgent
|
|
|
59
82
|
def migration_version
|
|
60
83
|
"[#{ActiveRecord::Migration.current_version}]"
|
|
61
84
|
end
|
|
85
|
+
|
|
86
|
+
# Consumed by the migration template.
|
|
87
|
+
def multi_tenant?
|
|
88
|
+
options[:multi_tenant]
|
|
89
|
+
end
|
|
62
90
|
end
|
|
63
91
|
end
|
|
64
92
|
end
|
|
@@ -3,13 +3,17 @@
|
|
|
3
3
|
# ActiveAgent Dashboard Configuration
|
|
4
4
|
#
|
|
5
5
|
# This file configures the ActiveAgent telemetry dashboard.
|
|
6
|
-
# The dashboard is mounted at /
|
|
6
|
+
# The dashboard is mounted at /activeagents by default (see config/routes.rb).
|
|
7
7
|
|
|
8
8
|
ActiveAgent::Dashboard.configure do |config|
|
|
9
|
-
#
|
|
10
|
-
#
|
|
9
|
+
# ==========================================================================
|
|
10
|
+
# Authentication (required in production)
|
|
11
|
+
# ==========================================================================
|
|
11
12
|
#
|
|
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.
|
|
13
17
|
#
|
|
14
18
|
# Basic auth:
|
|
15
19
|
# config.authentication_method = ->(controller) {
|
|
@@ -27,4 +31,37 @@ ActiveAgent::Dashboard.configure do |config|
|
|
|
27
31
|
# config.authentication_method = nil
|
|
28
32
|
#
|
|
29
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"
|
|
30
67
|
end
|
data/lib/generators/active_agent/dashboard/templates/create_active_agent_telemetry_traces.rb.erb
CHANGED
|
@@ -3,13 +3,21 @@
|
|
|
3
3
|
class CreateActiveAgentTelemetryTraces < ActiveRecord::Migration<%= migration_version %>
|
|
4
4
|
def change
|
|
5
5
|
create_table :active_agent_telemetry_traces do |t|
|
|
6
|
-
|
|
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
|
|
7
15
|
t.string :service_name
|
|
8
16
|
t.string :environment
|
|
9
17
|
t.datetime :timestamp, index: true
|
|
10
|
-
t.
|
|
11
|
-
t.
|
|
12
|
-
t.
|
|
18
|
+
t.json :spans, default: []
|
|
19
|
+
t.json :resource_attributes, default: {}
|
|
20
|
+
t.json :sdk_info, default: {}
|
|
13
21
|
t.decimal :total_duration_ms, precision: 12, scale: 3
|
|
14
22
|
t.integer :total_input_tokens, default: 0
|
|
15
23
|
t.integer :total_output_tokens, default: 0
|
|
@@ -22,6 +30,14 @@ class CreateActiveAgentTelemetryTraces < ActiveRecord::Migration<%= migration_ve
|
|
|
22
30
|
t.timestamps
|
|
23
31
|
end
|
|
24
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 -%>
|
|
25
41
|
add_index :active_agent_telemetry_traces, :status
|
|
26
42
|
add_index :active_agent_telemetry_traces, [:agent_class, :agent_action]
|
|
27
43
|
add_index :active_agent_telemetry_traces, [:service_name, :environment]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activeagent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Bowen
|
|
@@ -109,6 +109,20 @@ dependencies:
|
|
|
109
109
|
- - "<="
|
|
110
110
|
- !ruby/object:Gem::Version
|
|
111
111
|
version: '9.0'
|
|
112
|
+
- !ruby/object:Gem::Dependency
|
|
113
|
+
name: activeagents-telemetry
|
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - "~>"
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0.1'
|
|
119
|
+
type: :runtime
|
|
120
|
+
prerelease: false
|
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - "~>"
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0.1'
|
|
112
126
|
- !ruby/object:Gem::Dependency
|
|
113
127
|
name: jbuilder
|
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -269,16 +283,30 @@ dependencies:
|
|
|
269
283
|
requirements:
|
|
270
284
|
- - ">="
|
|
271
285
|
- !ruby/object:Gem::Version
|
|
272
|
-
version: '
|
|
286
|
+
version: '6.4'
|
|
273
287
|
type: :development
|
|
274
288
|
prerelease: false
|
|
275
289
|
version_requirements: !ruby/object:Gem::Requirement
|
|
276
290
|
requirements:
|
|
277
291
|
- - ">="
|
|
278
292
|
- !ruby/object:Gem::Version
|
|
279
|
-
version: '
|
|
293
|
+
version: '6.4'
|
|
280
294
|
- !ruby/object:Gem::Dependency
|
|
281
295
|
name: webmock
|
|
296
|
+
requirement: !ruby/object:Gem::Requirement
|
|
297
|
+
requirements:
|
|
298
|
+
- - ">="
|
|
299
|
+
- !ruby/object:Gem::Version
|
|
300
|
+
version: '3.26'
|
|
301
|
+
type: :development
|
|
302
|
+
prerelease: false
|
|
303
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
304
|
+
requirements:
|
|
305
|
+
- - ">="
|
|
306
|
+
- !ruby/object:Gem::Version
|
|
307
|
+
version: '3.26'
|
|
308
|
+
- !ruby/object:Gem::Dependency
|
|
309
|
+
name: cgi
|
|
282
310
|
requirement: !ruby/object:Gem::Requirement
|
|
283
311
|
requirements:
|
|
284
312
|
- - ">="
|
|
@@ -297,14 +325,14 @@ dependencies:
|
|
|
297
325
|
requirements:
|
|
298
326
|
- - ">="
|
|
299
327
|
- !ruby/object:Gem::Version
|
|
300
|
-
version: '
|
|
328
|
+
version: '3.2'
|
|
301
329
|
type: :development
|
|
302
330
|
prerelease: false
|
|
303
331
|
version_requirements: !ruby/object:Gem::Requirement
|
|
304
332
|
requirements:
|
|
305
333
|
- - ">="
|
|
306
334
|
- !ruby/object:Gem::Version
|
|
307
|
-
version: '
|
|
335
|
+
version: '3.2'
|
|
308
336
|
- !ruby/object:Gem::Dependency
|
|
309
337
|
name: pry
|
|
310
338
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -404,6 +432,7 @@ files:
|
|
|
404
432
|
- lib/active_agent/generation.rb
|
|
405
433
|
- lib/active_agent/generation_job.rb
|
|
406
434
|
- lib/active_agent/inline_preview_interceptor.rb
|
|
435
|
+
- lib/active_agent/model_capabilities.rb
|
|
407
436
|
- lib/active_agent/providers/_base_provider.rb
|
|
408
437
|
- lib/active_agent/providers/anthropic/_types.rb
|
|
409
438
|
- lib/active_agent/providers/anthropic/options.rb
|
|
@@ -439,6 +468,7 @@ files:
|
|
|
439
468
|
- lib/active_agent/providers/concerns/instrumentation.rb
|
|
440
469
|
- lib/active_agent/providers/concerns/previewable.rb
|
|
441
470
|
- lib/active_agent/providers/concerns/tool_choice_clearing.rb
|
|
471
|
+
- lib/active_agent/providers/errors.rb
|
|
442
472
|
- lib/active_agent/providers/gemini/_types.rb
|
|
443
473
|
- lib/active_agent/providers/gemini/options.rb
|
|
444
474
|
- lib/active_agent/providers/gemini_provider.rb
|
|
@@ -497,6 +527,9 @@ files:
|
|
|
497
527
|
- lib/active_agent/providers/open_router_provider.rb
|
|
498
528
|
- lib/active_agent/providers/openai_provider.rb
|
|
499
529
|
- lib/active_agent/providers/openrouter_provider.rb
|
|
530
|
+
- lib/active_agent/providers/requesty/_types.rb
|
|
531
|
+
- lib/active_agent/providers/requesty/options.rb
|
|
532
|
+
- lib/active_agent/providers/requesty_provider.rb
|
|
500
533
|
- lib/active_agent/providers/ruby_llm/_types.rb
|
|
501
534
|
- lib/active_agent/providers/ruby_llm/embedding_request.rb
|
|
502
535
|
- lib/active_agent/providers/ruby_llm/messages/_types.rb
|
|
@@ -523,16 +556,6 @@ files:
|
|
|
523
556
|
- lib/activeagent.rb
|
|
524
557
|
- lib/generators/active_agent/agent/USAGE
|
|
525
558
|
- lib/generators/active_agent/agent/agent_generator.rb
|
|
526
|
-
- lib/generators/active_agent/dashboard/install/install_generator.rb
|
|
527
|
-
- lib/generators/active_agent/dashboard/install/templates/initializer.rb
|
|
528
|
-
- lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_agent_runs.rb
|
|
529
|
-
- lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_agent_templates.rb
|
|
530
|
-
- lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_agent_versions.rb
|
|
531
|
-
- lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_agents.rb
|
|
532
|
-
- lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_sandbox_runs.rb
|
|
533
|
-
- lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_sandbox_sessions.rb
|
|
534
|
-
- lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_session_recordings.rb
|
|
535
|
-
- lib/generators/active_agent/dashboard/install/templates/migrations/create_active_agent_telemetry_traces.rb
|
|
536
559
|
- lib/generators/active_agent/dashboard/install_generator.rb
|
|
537
560
|
- lib/generators/active_agent/dashboard/templates/active_agent_dashboard.rb.erb
|
|
538
561
|
- lib/generators/active_agent/dashboard/templates/create_active_agent_telemetry_traces.rb.erb
|
|
@@ -576,7 +599,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
576
599
|
- !ruby/object:Gem::Version
|
|
577
600
|
version: '0'
|
|
578
601
|
requirements: []
|
|
579
|
-
rubygems_version:
|
|
602
|
+
rubygems_version: 4.0.6
|
|
580
603
|
specification_version: 4
|
|
581
604
|
summary: Rails AI Agents Framework
|
|
582
605
|
test_files: []
|
|
@@ -1,96 +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
|
-
module Generators
|
|
9
|
-
# Generator for installing the ActiveAgent Dashboard engine.
|
|
10
|
-
#
|
|
11
|
-
# Usage:
|
|
12
|
-
# rails generate active_agent:dashboard:install
|
|
13
|
-
#
|
|
14
|
-
# This will:
|
|
15
|
-
# - Copy migration files for all dashboard models
|
|
16
|
-
# - Create an initializer for configuration
|
|
17
|
-
# - Add the engine mount to routes.rb
|
|
18
|
-
# - Seed default agent templates
|
|
19
|
-
#
|
|
20
|
-
class InstallGenerator < Rails::Generators::Base
|
|
21
|
-
include ActiveRecord::Generators::Migration
|
|
22
|
-
|
|
23
|
-
source_root File.expand_path("templates", __dir__)
|
|
24
|
-
|
|
25
|
-
class_option :multi_tenant, type: :boolean, default: false,
|
|
26
|
-
desc: "Configure for multi-tenant mode with account association"
|
|
27
|
-
|
|
28
|
-
class_option :skip_migrations, type: :boolean, default: false,
|
|
29
|
-
desc: "Skip copying migration files"
|
|
30
|
-
|
|
31
|
-
class_option :skip_routes, type: :boolean, default: false,
|
|
32
|
-
desc: "Skip adding route mount"
|
|
33
|
-
|
|
34
|
-
def copy_migrations
|
|
35
|
-
return if options[:skip_migrations]
|
|
36
|
-
|
|
37
|
-
migration_template "migrations/create_active_agent_agents.rb",
|
|
38
|
-
"db/migrate/create_active_agent_agents.rb"
|
|
39
|
-
|
|
40
|
-
migration_template "migrations/create_active_agent_agent_versions.rb",
|
|
41
|
-
"db/migrate/create_active_agent_agent_versions.rb"
|
|
42
|
-
|
|
43
|
-
migration_template "migrations/create_active_agent_agent_runs.rb",
|
|
44
|
-
"db/migrate/create_active_agent_agent_runs.rb"
|
|
45
|
-
|
|
46
|
-
migration_template "migrations/create_active_agent_agent_templates.rb",
|
|
47
|
-
"db/migrate/create_active_agent_agent_templates.rb"
|
|
48
|
-
|
|
49
|
-
migration_template "migrations/create_active_agent_sandbox_sessions.rb",
|
|
50
|
-
"db/migrate/create_active_agent_sandbox_sessions.rb"
|
|
51
|
-
|
|
52
|
-
migration_template "migrations/create_active_agent_sandbox_runs.rb",
|
|
53
|
-
"db/migrate/create_active_agent_sandbox_runs.rb"
|
|
54
|
-
|
|
55
|
-
migration_template "migrations/create_active_agent_session_recordings.rb",
|
|
56
|
-
"db/migrate/create_active_agent_session_recordings.rb"
|
|
57
|
-
|
|
58
|
-
migration_template "migrations/create_active_agent_telemetry_traces.rb",
|
|
59
|
-
"db/migrate/create_active_agent_telemetry_traces.rb"
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def create_initializer
|
|
63
|
-
template "initializer.rb", "config/initializers/active_agent_dashboard.rb"
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def mount_engine
|
|
67
|
-
return if options[:skip_routes]
|
|
68
|
-
|
|
69
|
-
route 'mount ActiveAgent::Dashboard::Engine => "/active_agent"'
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def show_post_install
|
|
73
|
-
say ""
|
|
74
|
-
say "ActiveAgent Dashboard installed!", :green
|
|
75
|
-
say ""
|
|
76
|
-
say "Next steps:"
|
|
77
|
-
say " 1. Run migrations: rails db:migrate"
|
|
78
|
-
say " 2. Seed templates: rails active_agent:dashboard:seed"
|
|
79
|
-
say " 3. Configure authentication in config/initializers/active_agent_dashboard.rb"
|
|
80
|
-
say " 4. Visit /active_agent to access the dashboard"
|
|
81
|
-
say ""
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
private
|
|
85
|
-
|
|
86
|
-
def migration_version
|
|
87
|
-
"[#{ActiveRecord::Migration.current_version}]"
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def multi_tenant?
|
|
91
|
-
options[:multi_tenant]
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# ActiveAgent Dashboard Configuration
|
|
4
|
-
#
|
|
5
|
-
# This initializer configures the ActiveAgent Dashboard engine.
|
|
6
|
-
# See https://docs.activeagents.ai/dashboard for full documentation.
|
|
7
|
-
|
|
8
|
-
ActiveAgent::Dashboard.configure do |config|
|
|
9
|
-
# ==========================================================================
|
|
10
|
-
# Authentication
|
|
11
|
-
# ==========================================================================
|
|
12
|
-
|
|
13
|
-
# Set an authentication method that will be called on all dashboard controllers.
|
|
14
|
-
# This should authenticate the user and redirect/raise if unauthorized.
|
|
15
|
-
#
|
|
16
|
-
# Examples:
|
|
17
|
-
# config.authentication_method = ->(controller) { controller.authenticate_admin! }
|
|
18
|
-
# config.authentication_method = ->(controller) { controller.authenticate_user! }
|
|
19
|
-
#
|
|
20
|
-
# config.authentication_method = nil
|
|
21
|
-
|
|
22
|
-
<% if multi_tenant? -%>
|
|
23
|
-
# ==========================================================================
|
|
24
|
-
# Multi-tenant Mode
|
|
25
|
-
# ==========================================================================
|
|
26
|
-
|
|
27
|
-
# Enable multi-tenant mode for SaaS deployments with multiple accounts.
|
|
28
|
-
config.multi_tenant = true
|
|
29
|
-
|
|
30
|
-
# The Account model class name
|
|
31
|
-
config.account_class = "Account"
|
|
32
|
-
|
|
33
|
-
# The User model class name
|
|
34
|
-
config.user_class = "User"
|
|
35
|
-
|
|
36
|
-
# Method to call on controllers to get the current account
|
|
37
|
-
config.current_account_method = :current_account
|
|
38
|
-
|
|
39
|
-
# Method to call on controllers to get the current user
|
|
40
|
-
config.current_user_method = :current_user
|
|
41
|
-
|
|
42
|
-
<% else -%>
|
|
43
|
-
# ==========================================================================
|
|
44
|
-
# Local Mode (default)
|
|
45
|
-
# ==========================================================================
|
|
46
|
-
|
|
47
|
-
# Multi-tenant mode is disabled by default.
|
|
48
|
-
# Set to true if you're building a SaaS platform with multiple accounts.
|
|
49
|
-
# config.multi_tenant = false
|
|
50
|
-
|
|
51
|
-
# Optional: Associate agents with users
|
|
52
|
-
# config.user_class = "User"
|
|
53
|
-
# config.current_user_method = :current_user
|
|
54
|
-
|
|
55
|
-
<% end -%>
|
|
56
|
-
# ==========================================================================
|
|
57
|
-
# Sandbox Configuration
|
|
58
|
-
# ==========================================================================
|
|
59
|
-
|
|
60
|
-
# Sandbox service type for agent execution environments.
|
|
61
|
-
# Options: :local (Docker/Incus), :cloud_run, :kubernetes
|
|
62
|
-
config.sandbox_service = :local
|
|
63
|
-
|
|
64
|
-
# Custom sandbox limits (optional)
|
|
65
|
-
# config.sandbox_limits = {
|
|
66
|
-
# max_runs: 10,
|
|
67
|
-
# timeout_seconds: 300,
|
|
68
|
-
# max_tokens: 50_000,
|
|
69
|
-
# session_duration_minutes: 15
|
|
70
|
-
# }
|
|
71
|
-
|
|
72
|
-
# ==========================================================================
|
|
73
|
-
# UI Configuration
|
|
74
|
-
# ==========================================================================
|
|
75
|
-
|
|
76
|
-
# Use Inertia.js with React for the frontend (requires additional setup)
|
|
77
|
-
# config.use_inertia = false
|
|
78
|
-
|
|
79
|
-
# Custom layout for dashboard views
|
|
80
|
-
# config.layout = "application"
|
|
81
|
-
|
|
82
|
-
# ==========================================================================
|
|
83
|
-
# Storage Configuration
|
|
84
|
-
# ==========================================================================
|
|
85
|
-
|
|
86
|
-
# Storage service for screenshots and snapshots.
|
|
87
|
-
# Must respond to #signed_url_for(key, expires_in:) and #fetch_snapshot(key)
|
|
88
|
-
# config.storage_service = MyStorageService.new
|
|
89
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CreateActiveAgentAgentRuns < ActiveRecord::Migration<%= migration_version %>
|
|
4
|
-
def change
|
|
5
|
-
create_table :active_agent_agent_runs do |t|
|
|
6
|
-
t.references :agent, null: false, foreign_key: { to_table: :active_agent_agents }
|
|
7
|
-
|
|
8
|
-
# Input
|
|
9
|
-
t.text :input_prompt
|
|
10
|
-
t.jsonb :input_params, default: {}
|
|
11
|
-
|
|
12
|
-
# Output
|
|
13
|
-
t.text :output
|
|
14
|
-
t.jsonb :output_metadata, default: {}
|
|
15
|
-
|
|
16
|
-
# Execution details
|
|
17
|
-
t.integer :status, default: 0, null: false
|
|
18
|
-
t.integer :duration_ms
|
|
19
|
-
t.datetime :started_at
|
|
20
|
-
t.datetime :completed_at
|
|
21
|
-
|
|
22
|
-
# Token usage
|
|
23
|
-
t.integer :input_tokens
|
|
24
|
-
t.integer :output_tokens
|
|
25
|
-
t.integer :total_tokens
|
|
26
|
-
|
|
27
|
-
# Error tracking
|
|
28
|
-
t.text :error_message
|
|
29
|
-
t.text :error_backtrace
|
|
30
|
-
|
|
31
|
-
# Trace for debugging
|
|
32
|
-
t.string :trace_id
|
|
33
|
-
t.jsonb :logs, default: []
|
|
34
|
-
|
|
35
|
-
t.timestamps
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
add_index :active_agent_agent_runs, :status
|
|
39
|
-
add_index :active_agent_agent_runs, :trace_id
|
|
40
|
-
add_index :active_agent_agent_runs, :created_at
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CreateActiveAgentAgentTemplates < ActiveRecord::Migration<%= migration_version %>
|
|
4
|
-
def change
|
|
5
|
-
create_table :active_agent_agent_templates do |t|
|
|
6
|
-
t.string :name, null: false
|
|
7
|
-
t.string :slug, null: false
|
|
8
|
-
t.text :description
|
|
9
|
-
t.string :category
|
|
10
|
-
|
|
11
|
-
# Template configuration (same as agents)
|
|
12
|
-
t.string :provider, default: "openai"
|
|
13
|
-
t.string :model, default: "gpt-4o-mini"
|
|
14
|
-
t.text :instructions
|
|
15
|
-
t.string :preset_type
|
|
16
|
-
t.jsonb :appearance, default: {}
|
|
17
|
-
t.jsonb :instruction_sets, default: []
|
|
18
|
-
t.jsonb :tools, default: []
|
|
19
|
-
t.jsonb :mcp_servers, default: {}
|
|
20
|
-
t.jsonb :model_config, default: {}
|
|
21
|
-
|
|
22
|
-
# Metadata
|
|
23
|
-
t.string :icon
|
|
24
|
-
t.integer :usage_count, default: 0
|
|
25
|
-
t.boolean :featured, default: false
|
|
26
|
-
t.boolean :public, default: true
|
|
27
|
-
t.boolean :free_tier, default: true
|
|
28
|
-
|
|
29
|
-
t.timestamps
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
add_index :active_agent_agent_templates, :slug, unique: true
|
|
33
|
-
add_index :active_agent_agent_templates, :category
|
|
34
|
-
add_index :active_agent_agent_templates, :featured
|
|
35
|
-
add_index :active_agent_agent_templates, :usage_count
|
|
36
|
-
add_index :active_agent_agent_templates, :free_tier
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CreateActiveAgentAgentVersions < ActiveRecord::Migration<%= migration_version %>
|
|
4
|
-
def change
|
|
5
|
-
create_table :active_agent_agent_versions do |t|
|
|
6
|
-
t.references :agent, null: false, foreign_key: { to_table: :active_agent_agents }
|
|
7
|
-
|
|
8
|
-
t.integer :version_number, null: false, default: 1
|
|
9
|
-
t.string :change_summary
|
|
10
|
-
|
|
11
|
-
# Snapshot of agent configuration at this version
|
|
12
|
-
t.jsonb :configuration_snapshot, null: false, default: {}
|
|
13
|
-
|
|
14
|
-
# Who made the change
|
|
15
|
-
t.string :created_by
|
|
16
|
-
|
|
17
|
-
t.timestamps
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
add_index :active_agent_agent_versions, [:agent_id, :version_number], unique: true
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CreateActiveAgentAgents < ActiveRecord::Migration<%= migration_version %>
|
|
4
|
-
def change
|
|
5
|
-
create_table :active_agent_agents do |t|
|
|
6
|
-
t.string :name, null: false
|
|
7
|
-
t.text :description
|
|
8
|
-
t.string :slug, null: false
|
|
9
|
-
|
|
10
|
-
# Agent class configuration
|
|
11
|
-
t.string :agent_class_name
|
|
12
|
-
t.string :provider, default: "openai"
|
|
13
|
-
t.string :model, default: "gpt-4o-mini"
|
|
14
|
-
|
|
15
|
-
# Instructions and system prompt
|
|
16
|
-
t.text :instructions
|
|
17
|
-
|
|
18
|
-
# Avatar/appearance configuration
|
|
19
|
-
t.string :preset_type
|
|
20
|
-
t.jsonb :appearance, default: {}
|
|
21
|
-
|
|
22
|
-
# Capabilities
|
|
23
|
-
t.jsonb :instruction_sets, default: []
|
|
24
|
-
t.jsonb :tools, default: []
|
|
25
|
-
t.jsonb :mcp_servers, default: []
|
|
26
|
-
|
|
27
|
-
# Model configuration
|
|
28
|
-
t.jsonb :model_config, default: {}
|
|
29
|
-
|
|
30
|
-
# Response format
|
|
31
|
-
t.jsonb :response_format, default: {}
|
|
32
|
-
|
|
33
|
-
# Status
|
|
34
|
-
t.integer :status, default: 0, null: false
|
|
35
|
-
|
|
36
|
-
# Owner associations (optional)
|
|
37
|
-
t.references :user, foreign_key: true, null: true
|
|
38
|
-
<% if multi_tenant? -%>
|
|
39
|
-
t.references :account, foreign_key: true, null: true
|
|
40
|
-
<% end -%>
|
|
41
|
-
|
|
42
|
-
t.timestamps
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
<% if multi_tenant? -%>
|
|
46
|
-
add_index :active_agent_agents, [:account_id, :slug], unique: true
|
|
47
|
-
<% else -%>
|
|
48
|
-
add_index :active_agent_agents, [:user_id, :slug], unique: true
|
|
49
|
-
<% end -%>
|
|
50
|
-
add_index :active_agent_agents, :status
|
|
51
|
-
add_index :active_agent_agents, :provider
|
|
52
|
-
end
|
|
53
|
-
end
|