ad-agent_architecture 0.0.12 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbe6603e537c91457b8d7a3694ecaa23f77eec779bc43ae46a175f37c51e957b
4
- data.tar.gz: a65c74eae0fc6fdd21296f5da8b6b03d1ef46f6a6dd407d1b6deb38577dbf116
3
+ metadata.gz: 574aa418cb9ec56beda935dc38e6573ff0e0d5c8ea986b68ebf0b7a9df80b7b5
4
+ data.tar.gz: 2b5d33ed282079527589c6bc37ecd6369554948043d6e021f7bb557d24275547
5
5
  SHA512:
6
- metadata.gz: 9e9c114cd087a31e91352a3c9165cbad5b3e11b8668a77c37bd3226503e4746e2e6cdd53fb30b9c0b3a2bba84b4b050b32bce525b9b1d4e79ce215e9a7355f33
7
- data.tar.gz: c0473487b838ebc28e5a59ef16b9b9d77e3a4bb3ba210f1ff771a1747053736500747dd06542c482b5326a5cd97b8e1d9058a0697e02bae9b9f1dbc76e343a15
6
+ metadata.gz: 79b61a1cf84d2aa223f66d7926ba2f9e9b401f808863f6bd50af42b455acee24761c2481e82c3de8d43a49d1a4d8a5ea2f45f51af43229fb3f3519b717737072
7
+ data.tar.gz: ee02ed0f832fe470936df997d0353da6a06afa52e58bc97923f1dd5d44620a13fa18e2a382f404f176fb992a5a04c27b90ecbf94aad3ea4884909536497ef2c1
data/.builders/boot.rb CHANGED
@@ -24,6 +24,7 @@ KConfig.configure(CONFIG_KEY) do |config|
24
24
 
25
25
  config.target_folders.add(:app , base_folder)
26
26
  config.target_folders.add(:builder , builder_folder)
27
+ config.target_folders.add(:docs , :app, 'docs')
27
28
  end
28
29
 
29
30
  KConfig.configuration(CONFIG_KEY).debug
@@ -0,0 +1,49 @@
1
+ KManager.action :project_plan do
2
+ action do
3
+
4
+ DrawioDsl::Drawio
5
+ .init(k_builder, on_exist: :write, on_action: :execute)
6
+ .diagram(rounded: 1, glass: 1)
7
+ .page('In progress', theme: :style_03, margin_left: 0, margin_top: 0) do
8
+
9
+ # h5(x: 300, y: -50, w: 400, h: 80, title: 'DrawIO DSL')
10
+
11
+ grid_layout(y: 190, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
12
+
13
+ # Prompts need to support file read operation
14
+
15
+ todo(title: 'Include a report_attribute method or DSL under the tool namespace')
16
+ end
17
+ .page('To Do', theme: :style_02, margin_left: 0, margin_top: 0) do
18
+
19
+ # h5(x: 300, y: 0, w: 400, h: 80, title: 'DrawIO DSL')
20
+
21
+ grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
22
+
23
+ todo(title: 'Visual graph of the workflow')
24
+ todo(title: 'Horizontal')
25
+ todo(title: 'Clicking on sections will show the steps in that section')
26
+ todo(title: 'Clicking on attributes will show all attributes in the workflow')
27
+ todo(title: 'Clicking on prompts will show all prompts in the workflow')
28
+ todo(title: 'Clicking on dashboard will show visual hierarchy of the workflow')
29
+ todo(title: 'Need a runs button')
30
+ todo(title: 'VCode Editor: https://chatgpt.com/c/e09e1367-db5e-4786-b362-db35805b1e20')
31
+
32
+ end
33
+ .page('Done', theme: :style_06, margin_left: 0, margin_top: 0) do
34
+
35
+ # h5(x: 300, y: 0, w: 400, h: 80, title: 'DrawIO DSL')
36
+
37
+ grid_layout(y:90, direction: :horizontal, grid_h: 80, grid_w: 320, wrap_at: 3, grid: 0)
38
+
39
+ todo(title: 'Attributes are auto created when used in a step, but not preconfigured')
40
+ todo(title: 'Add support for project plan')
41
+ todo(title: 'Fix the DB issue introduced via DSL refactor')
42
+ end
43
+ .cd(:docs)
44
+ .save('project-plan/project.drawio')
45
+ .export_svg('project-plan/project_in_progress', page: 1)
46
+ .export_svg('project-plan/project_todo' , page: 2)
47
+ .export_svg('project-plan/project_done' , page: 3)
48
+ end
49
+ end
data/.rubocop.yml CHANGED
@@ -90,10 +90,15 @@ Lint/AmbiguousBlockAssociation:
90
90
 
91
91
  Style/AccessorGrouping:
92
92
  Enabled: false
93
+
93
94
  Metrics/AbcSize:
94
95
  Exclude:
95
96
  - "lib/ad/agent_architecture/**/*"
96
97
 
98
+ Metrics/PerceivedComplexity:
99
+ Exclude:
100
+ - "lib/ad/agent_architecture/dsl/actions/save_database.rb"
101
+
97
102
  Layout/SpaceBeforeComma:
98
103
  Enabled: false
99
104
  # My Preferences - End
@@ -125,3 +130,5 @@ RSpec/MultipleMemoizedHelpers:
125
130
  Metrics/CyclomaticComplexity:
126
131
  Exclude:
127
132
  - "lib/ad/agent_architecture/dsl/actions/save_database.rb"
133
+
134
+
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [0.0.13](https://github.com/appydave/ad-agent_architecture/compare/v0.0.12...v0.0.13) (2024-07-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add listen GEM and watch RBS files, plus bugs in database save ([b95e9ff](https://github.com/appydave/ad-agent_architecture/commit/b95e9ffec2fd03780e890a9ec7ca3708a53c17ef))
7
+
8
+ ## [0.0.12](https://github.com/appydave/ad-agent_architecture/compare/v0.0.11...v0.0.12) (2024-07-02)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * refactor DSL and Child DSL components, add support for prompt loading ([f260260](https://github.com/appydave/ad-agent_architecture/commit/f260260ea416d0c9d3a39dc1dd7fd0b66d145a80))
14
+
1
15
  ## [0.0.11](https://github.com/appydave/ad-agent_architecture/compare/v0.0.10...v0.0.11) (2024-06-29)
2
16
 
3
17
 
data/Gemfile CHANGED
@@ -10,6 +10,7 @@ group :development, :test do
10
10
  gem 'guard-rspec'
11
11
  gem 'guard-rubocop'
12
12
  gem 'guard-shell'
13
+ gem 'listen'
13
14
  gem 'rake'
14
15
  gem 'rake-compiler', require: false
15
16
  gem 'rspec', '~> 3.0'
data/Guardfile CHANGED
@@ -27,10 +27,4 @@ group :green_pass_then_cop, halt_on_fail: true do
27
27
  watch(/{.+\.rb$/)
28
28
  watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
29
29
  end
30
-
31
- # guard :shell do
32
- # watch(%r{^spec/usecases/.+\.rbx$}) do |m|
33
- # `ruby -r ./spec/usecases/dsl_initialize.rb #{m[0]}`
34
- # end
35
- # end
36
30
  end
data/README.md CHANGED
@@ -28,7 +28,7 @@ gem install ad-agent_architecture
28
28
 
29
29
  As a Developer, I want to understand the object graph and workflows for AI agents in multiple scenarios, so that I can build out AI applications effectively
30
30
 
31
- See all [stories](./STORIES.md)
31
+ See [project plan](./docs/project-plan/project-plan.md)
32
32
 
33
33
 
34
34
  ## Usage
data/bin/watch.rb ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ puts 'Watch Agent Workflow DSLs'
5
+
6
+ require 'pry'
7
+ require 'listen'
8
+
9
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
10
+
11
+ require 'ad/agent_architecture'
12
+
13
+ directory_to_watch = File.expand_path('../spec/usecases', __dir__)
14
+
15
+ callback = proc do |modified, added, _removed|
16
+ (modified + added).each do |file|
17
+ if file.match(%r{spec/usecases/.+\.rbx$})
18
+ # puts "Detected change in #{file}, running command..."
19
+ load file
20
+ end
21
+ end
22
+ end
23
+
24
+ listener = Listen.to(directory_to_watch, &callback)
25
+ listener.start
26
+
27
+ puts "Listening for changes in #{directory_to_watch}..."
28
+
29
+ sleep
@@ -0,0 +1,25 @@
1
+ # Drawio Dsl - Project Plan
2
+
3
+ ## In Progress
4
+
5
+ The next ticket to work on
6
+
7
+ ![](project_in_progress.svg)
8
+
9
+ ## To Do
10
+
11
+
12
+ List of tickets to do
13
+
14
+ ![](project_todo.svg)
15
+
16
+ ## Complete
17
+
18
+ List of completed tickets
19
+
20
+ ![](project_done.svg)
21
+
22
+
23
+ ## Copyright
24
+
25
+ Copyright (c) David Cruwys. See [MIT License](LICENSE.txt) for further details.
@@ -0,0 +1,62 @@
1
+ <mxfile host="OWd">
2
+ <diagram id="iN9" name="In progress">
3
+ <mxGraphModel dx="0" dy="0" background="#FFFAFA" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
4
+ <root>
5
+ <mxCell id="page_root_iN9" parent="iN9"/>
6
+ <mxCell id="node_root_iN9" parent="page_root_iN9"/>
7
+ <mxCell id="iN9-2" value="Include a report_attribute method or DSL under the tool namespace" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_iN9">
8
+ <mxGeometry x="10" y="10" width="300" height="60" as="geometry"/>
9
+ </mxCell>
10
+ </root>
11
+ </mxGraphModel>
12
+ </diagram>
13
+ <diagram id="97Z" name="To Do">
14
+ <mxGraphModel dx="0" dy="0" background="#FFFAFA" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
15
+ <root>
16
+ <mxCell id="page_root_97Z" parent="97Z"/>
17
+ <mxCell id="node_root_97Z" parent="page_root_97Z"/>
18
+ <mxCell id="97Z-2" value="Visual graph of the workflow" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_97Z">
19
+ <mxGeometry x="10" y="10" width="300" height="60" as="geometry"/>
20
+ </mxCell>
21
+ <mxCell id="97Z-3" value="Horizontal" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_97Z">
22
+ <mxGeometry x="330" y="10" width="300" height="60" as="geometry"/>
23
+ </mxCell>
24
+ <mxCell id="97Z-4" value="Clicking on sections will show the steps in that section" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_97Z">
25
+ <mxGeometry x="650" y="10" width="300" height="60" as="geometry"/>
26
+ </mxCell>
27
+ <mxCell id="97Z-5" value="Clicking on attributes will show all attributes in the workflow" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_97Z">
28
+ <mxGeometry x="10" y="90" width="300" height="60" as="geometry"/>
29
+ </mxCell>
30
+ <mxCell id="97Z-6" value="Clicking on prompts will show all prompts in the workflow" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_97Z">
31
+ <mxGeometry x="330" y="90" width="300" height="60" as="geometry"/>
32
+ </mxCell>
33
+ <mxCell id="97Z-7" value="Clicking on dashboard will show visual hierarchy of the workflow" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_97Z">
34
+ <mxGeometry x="650" y="90" width="300" height="60" as="geometry"/>
35
+ </mxCell>
36
+ <mxCell id="97Z-8" value="Need a runs button" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_97Z">
37
+ <mxGeometry x="10" y="170" width="300" height="60" as="geometry"/>
38
+ </mxCell>
39
+ <mxCell id="97Z-9" value="VCode Editor: https://chatgpt.com/c/e09e1367-db5e-4786-b362-db35805b1e20" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#dae8fc;strokeColor=#6c8ebf;fontColor=#333333" vertex="1" parent="node_root_97Z">
40
+ <mxGeometry x="330" y="170" width="300" height="60" as="geometry"/>
41
+ </mxCell>
42
+ </root>
43
+ </mxGraphModel>
44
+ </diagram>
45
+ <diagram id="n1O" name="Done">
46
+ <mxGraphModel dx="0" dy="0" background="#FFFAFA" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
47
+ <root>
48
+ <mxCell id="page_root_n1O" parent="n1O"/>
49
+ <mxCell id="node_root_n1O" parent="page_root_n1O"/>
50
+ <mxCell id="n1O-2" value="Attributes are auto created when used in a step, but not preconfigured" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_n1O">
51
+ <mxGeometry x="10" y="10" width="300" height="60" as="geometry"/>
52
+ </mxCell>
53
+ <mxCell id="n1O-3" value="Add support for project plan" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_n1O">
54
+ <mxGeometry x="330" y="10" width="300" height="60" as="geometry"/>
55
+ </mxCell>
56
+ <mxCell id="n1O-4" value="Fix the DB issue introduced via DSL refactor" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#f8cecc;strokeColor=#b85450;fontColor=#333333" vertex="1" parent="node_root_n1O">
57
+ <mxGeometry x="650" y="10" width="300" height="60" as="geometry"/>
58
+ </mxCell>
59
+ </root>
60
+ </mxGraphModel>
61
+ </diagram>
62
+ </mxfile>
@@ -0,0 +1,3 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="942px" height="62px" viewBox="-0.5 -0.5 942 62"><defs><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-ffffff-0.9-ffffff-0.1-s-0"><stop offset="0%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.9;"/><stop offset="100%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.1;"/></linearGradient></defs><g><g data-cell-id="page_root_n1O"><g data-cell-id="node_root_n1O"><g data-cell-id="n1O-2"><g><rect x="0" y="0" width="300" height="60" rx="9" ry="9" fill="#f8cecc" stroke="#b85450" pointer-events="all"/><path d="M 10.15 -1 Q -1 -1 -1 10.15 L -1 24 Q 150 42 301 24 L 301 10.15 Q 301 -1 289.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Attributes are auto created when used in a step, but not preconfigured</div></div></div></foreignObject><text x="150" y="34" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Attributes are auto created when used in a step, b...</text></switch></g></g></g><g data-cell-id="n1O-3"><g><rect x="320" y="0" width="300" height="60" rx="9" ry="9" fill="#f8cecc" stroke="#b85450" pointer-events="all"/><path d="M 330.15 -1 Q 319 -1 319 10.15 L 319 24 Q 470 42 621 24 L 621 10.15 Q 621 -1 609.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 321px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Add support for project plan</div></div></div></foreignObject><text x="470" y="34" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Add support for project plan</text></switch></g></g></g><g data-cell-id="n1O-4"><g><rect x="640" y="0" width="300" height="60" rx="9" ry="9" fill="#f8cecc" stroke="#b85450" pointer-events="all"/><path d="M 650.15 -1 Q 639 -1 639 10.15 L 639 24 Q 790 42 941 24 L 941 10.15 Q 941 -1 929.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 641px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Fix the DB issue introduced via DSL refactor</div></div></div></foreignObject><text x="790" y="34" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Fix the DB issue introduced via DSL refactor</text></switch></g></g></g></g></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.drawio.com/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Text is not SVG - cannot display</text></a></switch></svg>
@@ -0,0 +1,3 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="302px" height="62px" viewBox="-0.5 -0.5 302 62"><defs><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-ffffff-0.9-ffffff-0.1-s-0"><stop offset="0%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.9;"/><stop offset="100%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.1;"/></linearGradient></defs><g><g data-cell-id="page_root_iN9"><g data-cell-id="node_root_iN9"><g data-cell-id="iN9-2"><g><rect x="0" y="0" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 10.15 -1 Q -1 -1 -1 10.15 L -1 24 Q 150 42 301 24 L 301 10.15 Q 301 -1 289.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Include a report_attribute method or DSL under the tool namespace</div></div></div></foreignObject><text x="150" y="34" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Include a report_attribute method or DSL under the...</text></switch></g></g></g></g></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.drawio.com/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Text is not SVG - cannot display</text></a></switch></svg>
@@ -0,0 +1,3 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="942px" height="222px" viewBox="-0.5 -0.5 942 222"><defs><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-ffffff-0.9-ffffff-0.1-s-0"><stop offset="0%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.9;"/><stop offset="100%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.1;"/></linearGradient></defs><g><g data-cell-id="page_root_97Z"><g data-cell-id="node_root_97Z"><g data-cell-id="97Z-2"><g><rect x="0" y="0" width="300" height="60" rx="9" ry="9" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><path d="M 10.15 -1 Q -1 -1 -1 10.15 L -1 24 Q 150 42 301 24 L 301 10.15 Q 301 -1 289.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Visual graph of the workflow</div></div></div></foreignObject><text x="150" y="34" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Visual graph of the workflow</text></switch></g></g></g><g data-cell-id="97Z-3"><g><rect x="320" y="0" width="300" height="60" rx="9" ry="9" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><path d="M 330.15 -1 Q 319 -1 319 10.15 L 319 24 Q 470 42 621 24 L 621 10.15 Q 621 -1 609.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 321px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Horizontal</div></div></div></foreignObject><text x="470" y="34" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Horizontal</text></switch></g></g></g><g data-cell-id="97Z-4"><g><rect x="640" y="0" width="300" height="60" rx="9" ry="9" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><path d="M 650.15 -1 Q 639 -1 639 10.15 L 639 24 Q 790 42 941 24 L 941 10.15 Q 941 -1 929.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 641px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Clicking on sections will show the steps in that section</div></div></div></foreignObject><text x="790" y="34" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Clicking on sections will show the steps in that s...</text></switch></g></g></g><g data-cell-id="97Z-5"><g><rect x="0" y="80" width="300" height="60" rx="9" ry="9" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><path d="M 10.15 79 Q -1 79 -1 90.15 L -1 104 Q 150 122 301 104 L 301 90.15 Q 301 79 289.85 79 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 110px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Clicking on attributes will show all attributes in the workflow</div></div></div></foreignObject><text x="150" y="114" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Clicking on attributes will show all attributes in...</text></switch></g></g></g><g data-cell-id="97Z-6"><g><rect x="320" y="80" width="300" height="60" rx="9" ry="9" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><path d="M 330.15 79 Q 319 79 319 90.15 L 319 104 Q 470 122 621 104 L 621 90.15 Q 621 79 609.85 79 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 110px; margin-left: 321px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Clicking on prompts will show all prompts in the workflow</div></div></div></foreignObject><text x="470" y="114" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Clicking on prompts will show all prompts in the w...</text></switch></g></g></g><g data-cell-id="97Z-7"><g><rect x="640" y="80" width="300" height="60" rx="9" ry="9" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><path d="M 650.15 79 Q 639 79 639 90.15 L 639 104 Q 790 122 941 104 L 941 90.15 Q 941 79 929.85 79 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 110px; margin-left: 641px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Clicking on dashboard will show visual hierarchy of the workflow</div></div></div></foreignObject><text x="790" y="114" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Clicking on dashboard will show visual hierarchy o...</text></switch></g></g></g><g data-cell-id="97Z-8"><g><rect x="0" y="160" width="300" height="60" rx="9" ry="9" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><path d="M 10.15 159 Q -1 159 -1 170.15 L -1 184 Q 150 202 301 184 L 301 170.15 Q 301 159 289.85 159 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 190px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">Need a runs button</div></div></div></foreignObject><text x="150" y="194" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">Need a runs button</text></switch></g></g></g><g data-cell-id="97Z-9"><g><rect x="320" y="160" width="300" height="60" rx="9" ry="9" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><path d="M 330.15 159 Q 319 159 319 170.15 L 319 184 Q 470 202 621 184 L 621 170.15 Q 621 159 609.85 159 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/></g><g><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 190px; margin-left: 321px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">VCode Editor: https://chatgpt.com/c/e09e1367-db5e-4786-b362-db35805b1e20</div></div></div></foreignObject><text x="470" y="194" fill="#333333" font-family="&quot;Helvetica&quot;" font-size="12px" text-anchor="middle">VCode Editor: https://chatgpt.com/c/e09e1367-db5e-...</text></switch></g></g></g></g></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.drawio.com/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Text is not SVG - cannot display</text></a></switch></svg>
@@ -11,12 +11,15 @@ module Ad
11
11
  end
12
12
 
13
13
  def save
14
+ # puts JSON.pretty_generate(@workflow_hash)
14
15
  DB.transaction do
16
+ # puts "Saving Workflow: #{@workflow_hash[:name]}"
15
17
  # Save workflow
16
18
  workflow_record = Ad::AgentArchitecture::Database::Workflow.create(name: @workflow_hash[:name])
17
19
 
18
- # Save attributes
20
+ # Saving attributes
19
21
  attribute_records = @workflow_hash[:attributes].map do |_name, attr|
22
+ # puts "Saving Attribute: #{attr}"
20
23
  Ad::AgentArchitecture::Database::Attribute.create(
21
24
  name: attr[:name], type: attr[:type], is_array: attr[:is_array], workflow: workflow_record
22
25
  )
@@ -26,6 +29,7 @@ module Ad
26
29
 
27
30
  # Save prompts
28
31
  @workflow_hash[:prompts].each_value do |prompt|
32
+ # puts "Saving Prompt: #{prompt}"
29
33
  Ad::AgentArchitecture::Database::Prompt.create(
30
34
  name: prompt[:name], path: prompt[:path], content: prompt[:content], workflow: workflow_record
31
35
  )
@@ -33,22 +37,26 @@ module Ad
33
37
 
34
38
  # Save sections and steps
35
39
  @workflow_hash[:sections].each do |section|
40
+ # puts "Saving Section: #{section}"
36
41
  section_record = Ad::AgentArchitecture::Database::Section.create(
37
42
  name: section[:name], order: section[:order], workflow: workflow_record
38
43
  )
39
44
 
40
45
  section[:steps].each do |step|
46
+ # puts "Saving Step: #{step}"
41
47
  step_record = Ad::AgentArchitecture::Database::Step.create(
42
48
  name: step[:name], order: step[:order], prompt: step[:prompt], section: section_record
43
49
  )
44
50
 
45
51
  step[:input_attributes].each do |attr_name|
52
+ # puts "Saving Input Attribute for Step: #{attr_name}"
46
53
  Ad::AgentArchitecture::Database::InputAttribute.create(
47
54
  step: step_record, attribute: attribute_map[attr_name.to_sym]
48
55
  )
49
56
  end
50
57
 
51
58
  step[:output_attributes].each do |attr_name|
59
+ # puts "Saving Output Attribute for Step: #{attr_name}"
52
60
  Ad::AgentArchitecture::Database::OutputAttribute.create(
53
61
  step: step_record, attribute: attribute_map[attr_name.to_sym]
54
62
  )
@@ -56,6 +64,9 @@ module Ad
56
64
  end
57
65
  end
58
66
  end
67
+ rescue StandardError => e
68
+ puts "An error occurred: #{e.message}"
69
+ raise
59
70
  end
60
71
  end
61
72
  end
@@ -7,13 +7,15 @@ module Ad
7
7
  class AgentDsl
8
8
  attr_reader :workflow
9
9
 
10
- def self.create(name:, &block)
10
+ def self.create(name, &block)
11
11
  new(name).tap do |dsl|
12
12
  dsl.instance_eval(&block) if block_given?
13
13
  end
14
14
  end
15
15
 
16
16
  def initialize(name)
17
+ raise ArgumentError, 'Agent name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
18
+
17
19
  @workflow = WorkflowDsl.new(name)
18
20
  end
19
21
 
@@ -30,6 +32,8 @@ module Ad
30
32
  end
31
33
 
32
34
  def section(name, &block)
35
+ raise ArgumentError, 'Section name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
36
+
33
37
  @workflow.section(name, &block)
34
38
  end
35
39
 
@@ -6,8 +6,20 @@ module Ad
6
6
  # This class is responsible for defining the attributes of a workflow
7
7
  class AttributeDsl < ChildDsl
8
8
  def attribute(name, type:, is_array: false)
9
+ raise ArgumentError, 'Attribute name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
10
+
9
11
  workflow[:attributes][name] = { name: name, type: type, is_array: is_array }
10
12
  end
13
+
14
+ def infer_attribute(name)
15
+ raise ArgumentError, 'Attribute name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
16
+
17
+ return if workflow[:attributes].key?(name)
18
+
19
+ # May want to add more sophisticated type inference here
20
+ type = name.to_s.end_with?('s') ? 'array' : 'string'
21
+ workflow[:attributes][name] = { name: name, type: type, is_array: type == 'array' }
22
+ end
11
23
  end
12
24
  end
13
25
  end
@@ -6,12 +6,14 @@ module Ad
6
6
  # This class is responsible for defining the prompts of a workflow
7
7
  class PromptDsl < ChildDsl
8
8
  def prompt(name, path: nil, content: nil)
9
+ raise ArgumentError, 'Prompt name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
10
+
9
11
  workflow[:prompts][name] = { name: name, content: content }
10
12
  end
11
13
 
12
14
  def prompt_file(file)
13
15
  prompt_path = workflow[:settings][:prompt_path]
14
- raise 'Prompt path not defined in settings' unless prompt_path
16
+ raise 'Prompt path not defined in settings. Set "prompt_path" to the path where you are keping prompts' unless prompt_path
15
17
 
16
18
  full_path = File.join(prompt_path, file)
17
19
  File.read(full_path)
@@ -13,7 +13,9 @@ module Ad
13
13
  @current_step_order = 1
14
14
  end
15
15
 
16
- def step(name:, &block)
16
+ def step(name, &block)
17
+ raise ArgumentError, 'Step name must be a string or symbol' unless name.is_a?(String) || name.is_a?(Symbol)
18
+
17
19
  StepDsl.new(workflow, @section, name, @current_step_order).instance_eval(&block)
18
20
  @current_step_order += 1
19
21
  end
@@ -1,11 +1,17 @@
1
+ # file: lib/ad/agent_architecture/dsl/step_dsl.rb
2
+
1
3
  # frozen_string_literal: true
2
4
 
3
5
  module Ad
4
6
  module AgentArchitecture
5
7
  module Dsl
6
8
  # This class is responsible for defining the steps of a section
7
- class StepDsl
8
- def initialize(_workflow, section, name, order)
9
+ class StepDsl < ChildDsl
10
+ attr_reader :section
11
+ attr_reader :step
12
+
13
+ def initialize(workflow, section, name, order)
14
+ super(workflow)
9
15
  @step = {
10
16
  name: name,
11
17
  order: order,
@@ -14,19 +20,28 @@ module Ad
14
20
  output_attributes: []
15
21
  }
16
22
 
17
- section[:steps] << @step
23
+ @section = section
24
+ @section[:steps] << @step
18
25
  end
19
26
 
20
- def input(attr_name, **_opts)
21
- @step[:input_attributes] << attr_name
27
+ def input(name, **_opts)
28
+ infer_attribute(name)
29
+ @step[:input_attributes] << name
22
30
  end
23
31
 
24
- def output(attr_name, **_opts)
25
- @step[:output_attributes] << attr_name
32
+ def output(name, **_opts)
33
+ infer_attribute(name)
34
+ @step[:output_attributes] << name
26
35
  end
27
36
 
28
- def prompt(prompt_text, **_opts)
29
- @step[:prompt] = prompt_text
37
+ def prompt(prompt, **_opts)
38
+ @step[:prompt] = prompt
39
+ end
40
+
41
+ private
42
+
43
+ def infer_attribute(name)
44
+ AttributeDsl.new(workflow).infer_attribute(name)
30
45
  end
31
46
  end
32
47
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ad
4
4
  module AgentArchitecture
5
- VERSION = '0.0.12'
5
+ VERSION = '0.0.14'
6
6
  end
7
7
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ad-agent_architecture",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "ad-agent_architecture",
9
- "version": "0.0.12",
9
+ "version": "0.0.14",
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.12",
3
+ "version": "0.0.14",
4
4
  "description": "Architecture/Schema for AI Agents",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ad-agent_architecture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
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-02 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k_log
@@ -62,6 +62,7 @@ files:
62
62
  - ".builders/_.rb"
63
63
  - ".builders/boot.rb"
64
64
  - ".builders/generators/01-bootstrap.rb"
65
+ - ".builders/generators/project-plan.rb"
65
66
  - ".releaserc.json"
66
67
  - ".rspec"
67
68
  - ".rubocop.yml"
@@ -75,8 +76,14 @@ files:
75
76
  - Rakefile
76
77
  - bin/console
77
78
  - bin/setup
79
+ - bin/watch.rb
78
80
  - docs/erd.svg
79
81
  - docs/images/sample-workflow.png
82
+ - docs/project-plan/project-plan.md
83
+ - docs/project-plan/project.drawio
84
+ - docs/project-plan/project_done.svg
85
+ - docs/project-plan/project_in_progress.svg
86
+ - docs/project-plan/project_todo.svg
80
87
  - docs/requirements.md
81
88
  - docs/structure-youtube-script.yaml
82
89
  - lib/ad/agent_architecture.rb
@@ -87,7 +94,6 @@ files:
87
94
  - lib/ad/agent_architecture/dsl/actions/save_json.rb
88
95
  - lib/ad/agent_architecture/dsl/actions/save_yaml.rb
89
96
  - lib/ad/agent_architecture/dsl/agent_dsl.rb
90
- - lib/ad/agent_architecture/dsl/agent_workflow_dsl.rb.old
91
97
  - lib/ad/agent_architecture/dsl/attribute_dsl.rb
92
98
  - lib/ad/agent_architecture/dsl/child_dsl.rb
93
99
  - lib/ad/agent_architecture/dsl/prompt_dsl.rb
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ad
4
- module AgentArchitecture
5
- module Dsl
6
- # DSL for defining agent workflows
7
- class AgentWorkflowDsl
8
- def self.create(name:, &block)
9
- new(name).tap do |dsl|
10
- dsl.instance_eval(&block) if block_given?
11
- end
12
- end
13
-
14
- def initialize(name)
15
- @workflow = { name: name, sections: [], attributes: {}, prompts: [] }
16
- @current_section_order = 1
17
- end
18
-
19
- def attributes(&block)
20
- instance_eval(&block) if block_given?
21
- end
22
-
23
- def attribute(name, type:, is_array: false)
24
- @workflow[:attributes][name] = { name: name, type: type, is_array: is_array }
25
- end
26
-
27
- def prompts(&block)
28
- instance_eval(&block) if block_given?
29
- end
30
-
31
- def define_prompt(name, path: nil, content: nil)
32
- @workflow[:prompts] << { name: name, path: path, content: content }
33
- end
34
-
35
- def section(name:, &block)
36
- @current_step_order = 1
37
- @current_section = { name: name, order: @current_section_order, steps: [] }
38
- @current_section_order += 1
39
- instance_eval(&block) if block_given?
40
- @workflow[:sections] << @current_section
41
- end
42
-
43
- def step(name:, &block)
44
- @current_step = { name: name, order: @current_step_order, input_attributes: [], output_attributes: [] }
45
- @current_step_order += 1
46
- instance_eval(&block) if block_given?
47
- @current_section[:steps] << @current_step
48
- end
49
-
50
- def input(attr_name, **_opts)
51
- @current_step[:input_attributes] << attr_name
52
- end
53
-
54
- def output(attr_name, **_opts)
55
- @current_step[:output_attributes] << attr_name
56
- end
57
-
58
- def prompt(prompt_text, **_opts)
59
- @current_step[:prompt] = prompt_text
60
- end
61
-
62
- def save
63
- Ad::AgentArchitecture::Dsl::Actions::SaveDatabase.new(@workflow).save
64
-
65
- self
66
- end
67
-
68
- def save_json(file_name: nil)
69
- full_file_name = file_name || 'workflow.json'
70
- Ad::AgentArchitecture::Dsl::Actions::SaveJson.new(@workflow).save(full_file_name)
71
-
72
- self
73
- end
74
-
75
- def save_yaml(file_name: nil)
76
- full_file_name = file_name || 'workflow.yaml'
77
- Ad::AgentArchitecture::Dsl::Actions::SaveYaml.new(@workflow).save(full_file_name)
78
-
79
- self
80
- end
81
- end
82
- end
83
- end
84
- end