circuit_breaker-wf 0.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.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/CHANGELOG.md +52 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +116 -0
  6. data/LICENSE +21 -0
  7. data/README.md +324 -0
  8. data/examples/document/README.md +150 -0
  9. data/examples/document/document_assistant.rb +535 -0
  10. data/examples/document/document_rules.rb +60 -0
  11. data/examples/document/document_token.rb +83 -0
  12. data/examples/document/document_workflow.rb +114 -0
  13. data/examples/document/mock_executor.rb +80 -0
  14. data/lib/circuit_breaker/executors/README.md +664 -0
  15. data/lib/circuit_breaker/executors/agent_executor.rb +187 -0
  16. data/lib/circuit_breaker/executors/assistant_executor.rb +245 -0
  17. data/lib/circuit_breaker/executors/base_executor.rb +56 -0
  18. data/lib/circuit_breaker/executors/docker_executor.rb +56 -0
  19. data/lib/circuit_breaker/executors/dsl.rb +97 -0
  20. data/lib/circuit_breaker/executors/llm/memory.rb +82 -0
  21. data/lib/circuit_breaker/executors/llm/tools.rb +94 -0
  22. data/lib/circuit_breaker/executors/nats_executor.rb +230 -0
  23. data/lib/circuit_breaker/executors/serverless_executor.rb +25 -0
  24. data/lib/circuit_breaker/executors/step_executor.rb +47 -0
  25. data/lib/circuit_breaker/history.rb +81 -0
  26. data/lib/circuit_breaker/rules.rb +251 -0
  27. data/lib/circuit_breaker/templates/mermaid.html.erb +51 -0
  28. data/lib/circuit_breaker/templates/plantuml.html.erb +55 -0
  29. data/lib/circuit_breaker/token.rb +486 -0
  30. data/lib/circuit_breaker/visualizer.rb +173 -0
  31. data/lib/circuit_breaker/workflow_dsl.rb +359 -0
  32. data/lib/circuit_breaker.rb +236 -0
  33. data/workflow-editor/.gitignore +24 -0
  34. data/workflow-editor/README.md +106 -0
  35. data/workflow-editor/eslint.config.js +28 -0
  36. data/workflow-editor/index.html +13 -0
  37. data/workflow-editor/package-lock.json +6864 -0
  38. data/workflow-editor/package.json +50 -0
  39. data/workflow-editor/postcss.config.js +6 -0
  40. data/workflow-editor/public/vite.svg +1 -0
  41. data/workflow-editor/src/App.css +42 -0
  42. data/workflow-editor/src/App.tsx +365 -0
  43. data/workflow-editor/src/assets/react.svg +1 -0
  44. data/workflow-editor/src/components/AddNodeButton.tsx +68 -0
  45. data/workflow-editor/src/components/EdgeDetails.tsx +175 -0
  46. data/workflow-editor/src/components/NodeDetails.tsx +177 -0
  47. data/workflow-editor/src/components/ResizablePanel.tsx +74 -0
  48. data/workflow-editor/src/components/SaveButton.tsx +45 -0
  49. data/workflow-editor/src/config/change_workflow.yaml +59 -0
  50. data/workflow-editor/src/config/constants.ts +11 -0
  51. data/workflow-editor/src/config/flowConfig.ts +189 -0
  52. data/workflow-editor/src/config/uiConfig.ts +77 -0
  53. data/workflow-editor/src/config/workflow.yaml +58 -0
  54. data/workflow-editor/src/hooks/useKeyPress.ts +29 -0
  55. data/workflow-editor/src/index.css +34 -0
  56. data/workflow-editor/src/main.tsx +10 -0
  57. data/workflow-editor/src/server/saveWorkflow.ts +81 -0
  58. data/workflow-editor/src/utils/saveWorkflow.ts +92 -0
  59. data/workflow-editor/src/utils/workflowLoader.ts +26 -0
  60. data/workflow-editor/src/utils/workflowTransformer.ts +91 -0
  61. data/workflow-editor/src/vite-env.d.ts +1 -0
  62. data/workflow-editor/src/yaml.d.ts +4 -0
  63. data/workflow-editor/tailwind.config.js +15 -0
  64. data/workflow-editor/tsconfig.app.json +26 -0
  65. data/workflow-editor/tsconfig.json +7 -0
  66. data/workflow-editor/tsconfig.node.json +24 -0
  67. data/workflow-editor/vite.config.ts +8 -0
  68. metadata +267 -0
@@ -0,0 +1,106 @@
1
+ # Workflow Editor
2
+
3
+ A visual editor for creating and modifying workflow configurations using React Flow. This editor allows you to create, edit, and visualize workflow states and transitions in a user-friendly interface.
4
+
5
+ ## Features
6
+
7
+ - Interactive graph visualization of workflow states and transitions
8
+ - Real-time editing of nodes (states) and edges (transitions)
9
+ - Automatic layout using the Dagre algorithm
10
+ - Details panel for editing node and edge properties
11
+ - YAML configuration file integration
12
+ - Smooth edges with directional arrows
13
+ - Auto-save functionality
14
+
15
+ ## Getting Started
16
+
17
+ 1. Install dependencies:
18
+ ```bash
19
+ npm install
20
+ ```
21
+
22
+ 2. Start the development server:
23
+ ```bash
24
+ npm start
25
+ ```
26
+
27
+ This will start both the Vite development server and the backend server for handling workflow saves.
28
+
29
+ ## Usage Guide
30
+
31
+ ### Adding New Nodes
32
+
33
+ 1. Click the "Add Node" button in the top-left corner
34
+ 2. A new node will be created with a default name
35
+ 3. Select the node to edit its properties in the details panel
36
+ 4. The node will be automatically positioned in the graph
37
+
38
+ ### Creating Transitions
39
+
40
+ 1. Hover over a node to see the connection handle
41
+ 2. Click and drag from one node to another to create a transition
42
+ 3. The transition will be created with a default name
43
+ 4. Select the transition to edit its properties
44
+
45
+ ### Editing Properties
46
+
47
+ #### Node Details
48
+ - When a node is selected, the details panel shows:
49
+ - Node label (editable)
50
+ - Node type (regular or special)
51
+ - Node description
52
+ - Connected transitions
53
+
54
+ #### Edge Details
55
+ - When a transition is selected, the details panel shows:
56
+ - Transition name (editable)
57
+ - Source and target states
58
+ - Requirements list (can be added/removed)
59
+
60
+ ### Saving Changes
61
+
62
+ The workflow is automatically saved when:
63
+ - A new node is added
64
+ - A transition is created or modified
65
+ - Node or edge properties are updated
66
+
67
+ The save process:
68
+ 1. Converts the visual graph to YAML format
69
+ 2. Saves to `src/config/workflow.yaml`
70
+ 3. Updates the graph to reflect any changes
71
+
72
+ ## Configuration Files
73
+
74
+ ### workflow.yaml
75
+ - Located in `src/config/workflow.yaml`
76
+ - Contains the workflow configuration in YAML format
77
+ - Structure:
78
+ ```yaml
79
+ object_type: Issue
80
+ places:
81
+ states: [...]
82
+ special_states: [...]
83
+ transitions:
84
+ regular: [...]
85
+ ```
86
+
87
+ ### flowConfig.ts
88
+ - Located in `src/config/flowConfig.ts`
89
+ - Defines visual styles for nodes and edges
90
+ - Configures graph layout settings
91
+
92
+ ## Development
93
+
94
+ ### Key Components
95
+
96
+ - `App.tsx`: Main application component
97
+ - `Flow.tsx`: React Flow configuration and event handlers
98
+ - `EdgeDetails.tsx`: Edge property editor
99
+ - `NodeDetails.tsx`: Node property editor
100
+ - `saveWorkflow.ts`: Workflow save functionality
101
+
102
+ ### State Management
103
+
104
+ - Node positions and connections are managed by React Flow
105
+ - Node and edge data is synchronized with the YAML configuration
106
+ - Real-time updates are handled through React state and callbacks
@@ -0,0 +1,28 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import tseslint from 'typescript-eslint'
6
+
7
+ export default tseslint.config(
8
+ { ignores: ['dist'] },
9
+ {
10
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
+ files: ['**/*.{ts,tsx}'],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ },
16
+ plugins: {
17
+ 'react-hooks': reactHooks,
18
+ 'react-refresh': reactRefresh,
19
+ },
20
+ rules: {
21
+ ...reactHooks.configs.recommended.rules,
22
+ 'react-refresh/only-export-components': [
23
+ 'warn',
24
+ { allowConstantExport: true },
25
+ ],
26
+ },
27
+ },
28
+ )
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + React + TS</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>