ad-agent_architecture 0.0.22 → 0.0.23

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.
@@ -9,11 +9,16 @@ module Ad
9
9
 
10
10
  attr_reader :data
11
11
 
12
- def initialize(name)
13
- @data = { name: name, sections: [], attributes: {}, prompts: {}, settings: {} }
12
+ def initialize(name, description: nil)
13
+ @data = { name: name, description: description, sections: [], attributes: {}, prompts: {}, settings: {} }
14
14
  @current_section_order = 1
15
15
  end
16
16
 
17
+ def description(description)
18
+ @data[:description] = description
19
+ self
20
+ end
21
+
17
22
  def settings(&block)
18
23
  dsl = SettingsDsl.new(self)
19
24
  dsl.instance_eval(&block) if block_given?
@@ -32,8 +37,8 @@ module Ad
32
37
  dsl
33
38
  end
34
39
 
35
- def section(name, &block)
36
- dsl = SectionDsl.new(self, name, @current_section_order)
40
+ def section(name, description: nil, &block)
41
+ dsl = SectionDsl.new(self, name, @current_section_order, description: description)
37
42
  @current_section_order += 1
38
43
  dsl.instance_eval(&block) if block_given?
39
44
  dsl
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ad
4
+ module AgentArchitecture
5
+ module Report
6
+ # This class is responsible for building the agent data for export or visualization
7
+ class AgentDataBuilder
8
+ attr_reader :workflow_id, :data
9
+
10
+ def initialize(workflow_id)
11
+ @workflow_id = workflow_id
12
+ @data = {}
13
+ end
14
+
15
+ def build
16
+ fetch_workflow
17
+ fetch_sections
18
+ fetch_attributes
19
+ fetch_prompts
20
+ data
21
+ end
22
+
23
+ private
24
+
25
+ def fetch_workflow
26
+ workflow = Ad::AgentArchitecture::Database::Workflow.where(id: workflow_id).first
27
+
28
+ @data[:name] = workflow.name
29
+ @data[:title] = Cmdlet::Case::Title.new.call(workflow.name)
30
+ @data[:description] = workflow.description
31
+ @data[:settings] = fetch_settings(workflow)
32
+ end
33
+
34
+ def fetch_sections
35
+ @data[:sections] = []
36
+ sections = Ad::AgentArchitecture::Database::Section.where(workflow_id: workflow_id).order(:order)
37
+ sections.each do |section|
38
+ section_data = {
39
+ name: section.name,
40
+ title: Cmdlet::Case::Title.new.call(section.name),
41
+ order: section.order,
42
+ description: section.description,
43
+ steps: fetch_steps(section.id)
44
+ }
45
+ @data[:sections] << section_data
46
+ end
47
+ end
48
+
49
+ def fetch_steps(section_id)
50
+ steps = Ad::AgentArchitecture::Database::Step.where(section_id: section_id).order(:order)
51
+ steps.map do |step|
52
+ {
53
+ name: step.name,
54
+ title: Cmdlet::Case::Title.new.call(step.name),
55
+ order: step.order,
56
+ description: step.description,
57
+ prompt: step.prompt,
58
+ input_attributes: fetch_input_attributes(step.id),
59
+ output_attributes: fetch_output_attributes(step.id)
60
+ }
61
+ end
62
+ end
63
+
64
+ def fetch_input_attributes(step_id)
65
+ Ad::AgentArchitecture::Database::InputAttribute.where(step_id: step_id).map do |input|
66
+ attribute = input.attribute
67
+ {
68
+ name: attribute.name,
69
+ type: attribute.type,
70
+ is_array: attribute.is_array,
71
+ description: attribute.description,
72
+ title: Cmdlet::Case::Title.new.call(attribute.name)
73
+ }
74
+ end
75
+ end
76
+
77
+ def fetch_output_attributes(step_id)
78
+ Ad::AgentArchitecture::Database::OutputAttribute.where(step_id: step_id).map do |output|
79
+ attribute = output.attribute
80
+ {
81
+ name: attribute.name,
82
+ type: attribute.type,
83
+ is_array: attribute.is_array,
84
+ description: attribute.description,
85
+ title: Cmdlet::Case::Title.new.call(attribute.name)
86
+ }
87
+ end
88
+ end
89
+
90
+ def fetch_attributes
91
+ @data[:attributes] = {}
92
+ attributes = Ad::AgentArchitecture::Database::Attribute.where(workflow_id: workflow_id)
93
+ attributes.each do |attr|
94
+ @data[:attributes][attr.name.to_sym] = {
95
+ name: attr.name,
96
+ type: attr.type,
97
+ is_array: attr.is_array,
98
+ description: attr.description,
99
+ title: Cmdlet::Case::Title.new.call(attr.name)
100
+ }
101
+ end
102
+ end
103
+
104
+ def fetch_prompts
105
+ @data[:prompts] = {}
106
+ prompts = Ad::AgentArchitecture::Database::Prompt.where(workflow_id: workflow_id)
107
+ prompts.each do |prompt|
108
+ @data[:prompts][prompt.name.to_sym] = {
109
+ name: prompt.name,
110
+ content: prompt.content,
111
+ description: prompt.description,
112
+ title: Cmdlet::Case::Title.new.call(prompt.name)
113
+ }
114
+ end
115
+ end
116
+
117
+ def fetch_settings(_workflow)
118
+ result = {}
119
+ settings = Ad::AgentArchitecture::Database::Setting.where(workflow_id: workflow_id)
120
+ settings.each do |setting|
121
+ result[setting.name.to_sym] = {
122
+ value: setting.value,
123
+ description: setting.description,
124
+ title: Cmdlet::Case::Title.new.call(setting.name)
125
+ }
126
+ end
127
+ result
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ad
4
4
  module AgentArchitecture
5
- VERSION = '0.0.22'
5
+ VERSION = '0.0.23'
6
6
  end
7
7
  end
@@ -3,6 +3,7 @@
3
3
  require 'sequel'
4
4
  require 'sqlite3'
5
5
  require 'k_log'
6
+ require 'cmdlet'
6
7
 
7
8
  require 'ad/agent_architecture/version'
8
9
  require 'ad/agent_architecture/database/create_schema'
@@ -26,6 +27,7 @@ require 'ad/agent_architecture/dsl/actions/save_database'
26
27
  require 'ad/agent_architecture/dsl/actions/save_json'
27
28
  require 'ad/agent_architecture/dsl/actions/save_yaml'
28
29
  require 'ad/agent_architecture/report/dsl_generator'
30
+ require 'ad/agent_architecture/report/agent_data_builder'
29
31
  require 'ad/agent_architecture/report/workflow_detail_report'
30
32
  require 'ad/agent_architecture/report/workflow_list_report'
31
33
 
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ad-agent_architecture",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "ad-agent_architecture",
9
- "version": "0.0.22",
9
+ "version": "0.0.23",
10
10
  "devDependencies": {
11
11
  "@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
12
12
  "@semantic-release/changelog": "^6.0.3",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ad-agent_architecture",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "Architecture/Schema for AI Agents",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ad-agent_architecture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-04 00:00:00.000000000 Z
11
+ date: 2024-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cmdlet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: k_log
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +88,8 @@ files:
74
88
  - LICENSE.txt
75
89
  - README.md
76
90
  - Rakefile
91
+ - a1.json
92
+ - a2.json
77
93
  - bin/console
78
94
  - bin/setup
79
95
  - bin/watch.rb
@@ -102,6 +118,7 @@ files:
102
118
  - lib/ad/agent_architecture/dsl/settings_dsl.rb
103
119
  - lib/ad/agent_architecture/dsl/step_dsl.rb
104
120
  - lib/ad/agent_architecture/dsl/workflow_dsl.rb
121
+ - lib/ad/agent_architecture/report/agent_data_builder.rb
105
122
  - lib/ad/agent_architecture/report/dsl_generator.rb
106
123
  - lib/ad/agent_architecture/report/workflow_detail_report.rb
107
124
  - lib/ad/agent_architecture/report/workflow_list_report.rb