meta_workflows 0.9.16 → 0.9.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf87bca0ce45dc8b835c415c61203e0678cdb8a66e8668cb9997e12b76a9a164
4
- data.tar.gz: 19c97c95dfecc3260c7869983c7281a498f623eac0e0636f50ada1e0a25eec70
3
+ metadata.gz: f70452cae76da68d70cc4e7b0f5c311ca8d287aac2526983fcee42e5cdb6555a
4
+ data.tar.gz: 47d7637b8ec224c160b62ac55f363b07515d1e6d6a43350dc4127afb0839f32e
5
5
  SHA512:
6
- metadata.gz: e4009226f5d3cd1bafb0d676a29ba21fcd4e181208e20801fab0a892cf50bae9bdb9df895c8d9b3cb919170193dae295d482bb9c67c357efda1d2c8f8f2ef430
7
- data.tar.gz: 7af79ba6d4d8469e36e9be797abaafe8c1f0262e8fc90457ef1cd862a146a846ad455ef56cf3b442f195ddb6db98240af1dcbd1e6e8ed8f53444b48b1edc1f69
6
+ metadata.gz: 3b4bce3cecda4fa622ecc808fd5293f47e321c29bcd6ba1afb4b06f0aad1766307459275bb5bfaa89a03f0fd47f0dcc15cd55acbef3f33cfc8d42c7aa0690694
7
+ data.tar.gz: a1881bb94b04d89dba925e60d1915a16db2b32f0fd28a60bb1fa1517743e52be625bbbb7a32e69c7c264e95235b3b4848cf151dccf27aa7c0a8ac5e1f3574f76
@@ -9,7 +9,7 @@ export default class extends Controller {
9
9
 
10
10
  connect() {
11
11
  if (!this.hasPhrasesValue || this.phrasesValue.length === 0) {
12
- this.phrasesValue = ["Talking to the LLM..."]
12
+ this.phrasesValue = ["Thinking"]
13
13
  }
14
14
 
15
15
  this.currentIndex = 0
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MetaWorkflows
4
+ module Streamable
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include MetaWorkflows::MetaWorkflowsHelper
9
+ end
10
+
11
+ private
12
+
13
+ # Broadcasts loader message with step progress
14
+ def broadcast_loader_stream(workflow_execution)
15
+ step_progress = workflow_execution.step_progress(workflow_execution.current_step) || default_step_progress
16
+ record = workflow_execution.record
17
+
18
+ Turbo::StreamsChannel.broadcast_replace_to(
19
+ turbo_stream_name(record),
20
+ target: target_frame_id(record, loader: true),
21
+ partial: meta_loader_message,
22
+ locals: { record: record, step_progress: step_progress }
23
+ )
24
+ end
25
+
26
+ # Broadcasts error response when workflow fails
27
+ def broadcast_error_response(workflow_execution)
28
+ record = workflow_execution.record
29
+
30
+ Turbo::StreamsChannel.broadcast_replace_to(
31
+ turbo_stream_name(record),
32
+ target: target_frame_id(record, loader: true),
33
+ partial: meta_error_message,
34
+ locals: { record: record }
35
+ )
36
+ end
37
+
38
+ # Builds loader stream for direct response
39
+ def build_loader_stream(record:, workflow_execution:)
40
+ step_progress = workflow_execution.step_progress(workflow_execution.current_step) || default_step_progress
41
+
42
+ turbo_stream.replace(
43
+ target_frame_id(record, loader: true),
44
+ partial: meta_loader_message,
45
+ locals: { record: record, step_progress: step_progress }
46
+ )
47
+ end
48
+
49
+ # Builds response form stream for direct response
50
+ def build_response_form_stream(record:, workflow_execution:, response_enabled:, responding:, chat_id:)
51
+ turbo_stream.replace(
52
+ target_frame_id(record, form: true),
53
+ partial: meta_response_form,
54
+ locals: build_response_form_locals(record:, workflow_execution:, response_enabled:, responding:, chat_id:)
55
+ )
56
+ end
57
+
58
+ # Builds locals hash for response form
59
+ def build_response_form_locals(record:, workflow_execution:, response_enabled:, responding:, chat_id:)
60
+ {
61
+ record: record,
62
+ workflow_execution_id: workflow_execution.id,
63
+ chat_id: chat_id,
64
+ response_enabled: response_enabled,
65
+ responding: responding,
66
+ step_has_repetitions: current_step_has_repetitions?(workflow_execution)
67
+ }
68
+ end
69
+ end
70
+ end
@@ -3,12 +3,16 @@
3
3
  module MetaWorkflows
4
4
  class HumansController < MetaController
5
5
  include MetaWorkflows::MetaWorkflowsHelper
6
+ include MetaWorkflows::Streamable
6
7
  before_action :set_workflow_data, only: [:update]
7
8
 
8
9
  def update
9
- if params[:advance].present? || should_auto_advance?
10
+ auto_advancing = should_auto_advance?
11
+
12
+ if params[:advance].present? || auto_advancing
13
+ @workflow_execution.increment_step
10
14
  render_loader_stream
11
- process_human_input(auto_advancing: should_auto_advance?, manual_advancing: params[:advance].present?)
15
+ process_human_input(auto_advancing:, manual_advancing: params[:advance].present?)
12
16
  else
13
17
  render_response_form_stream
14
18
  process_human_input
@@ -44,19 +48,9 @@ module MetaWorkflows
44
48
  respond_to do |format|
45
49
  format.turbo_stream do
46
50
  render turbo_stream: [
47
- turbo_stream.replace(
48
- target_frame_id(@record, loader: true),
49
- partial: meta_loader_message,
50
- locals: {
51
- record: @record,
52
- step_progress: fetch_step_progress
53
- }
54
- ),
55
- turbo_stream.replace(
56
- target_frame_id(@record, form: true),
57
- partial: meta_response_form,
58
- locals: response_form_locals(response_enabled: false)
59
- )
51
+ build_loader_stream(record: @record, workflow_execution: @workflow_execution),
52
+ build_response_form_stream(record: @record, workflow_execution: @workflow_execution,
53
+ response_enabled: false, responding: false, chat_id: params[:chat_id])
60
54
  ]
61
55
  end
62
56
  end
@@ -65,24 +59,15 @@ module MetaWorkflows
65
59
  def render_response_form_stream
66
60
  respond_to do |format|
67
61
  format.turbo_stream do
68
- render turbo_stream: turbo_stream.replace(
69
- target_frame_id(@record, form: true),
70
- partial: meta_response_form,
71
- locals: response_form_locals(response_enabled: true, responding: true)
62
+ render turbo_stream: build_response_form_stream(
63
+ record: @record,
64
+ workflow_execution: @workflow_execution,
65
+ response_enabled: true,
66
+ responding: true,
67
+ chat_id: params[:chat_id]
72
68
  )
73
69
  end
74
70
  end
75
71
  end
76
-
77
- def response_form_locals(response_enabled: true, responding: false)
78
- {
79
- record: @record,
80
- workflow_execution_id: @workflow_execution.id,
81
- chat_id: params[:chat_id],
82
- response_enabled: response_enabled,
83
- responding: responding,
84
- step_has_repetitions: current_step_has_repetitions?(@workflow_execution)
85
- }
86
- end
87
72
  end
88
73
  end
@@ -57,8 +57,6 @@ module MetaWorkflows
57
57
 
58
58
  def advance_workflow(params)
59
59
  dialogue = collect_messages_from_chat(params)
60
- workflow_execution = active_workflow_execution
61
- workflow_execution.increment_step
62
60
 
63
61
  MetaWorkflows::MetaWorkflowJob.perform_later(
64
62
  record_id: @record.id,
@@ -2,6 +2,8 @@
2
2
 
3
3
  module MetaWorkflows
4
4
  class MetaJob < MetaWorkflows::ApplicationJob
5
+ include MetaWorkflows::Streamable
6
+
5
7
  attr_accessor :chat, :inputs, :full_response, :user_id, :record, :auto_advancing, :manual_advancing
6
8
 
7
9
  private
@@ -42,14 +44,15 @@ module MetaWorkflows
42
44
  end
43
45
 
44
46
  def process_and_broadcast(conversation)
45
- workflow_step = current_workflow_step
47
+ workflow_execution = active_workflow_execution
48
+ workflow_step = current_workflow_step(workflow_execution)
46
49
 
47
50
  begin
48
51
  clear_previous_errors(workflow_step)
49
52
  execute_llm_conversation(conversation)
50
53
  finalize_conversation(conversation)
51
54
  rescue StandardError => e
52
- handle_llm_error(e, workflow_step, conversation)
55
+ handle_llm_error(e, workflow_step, workflow_execution, conversation)
53
56
  raise
54
57
  end
55
58
  end
@@ -70,10 +73,10 @@ module MetaWorkflows
70
73
  broadcast_form(chat) unless auto_advancing
71
74
  end
72
75
 
73
- def handle_llm_error(error, workflow_step, conversation)
76
+ def handle_llm_error(error, workflow_step, workflow_execution, conversation)
74
77
  log_error(error)
75
78
  store_error_in_workflow_step(error, workflow_step, conversation)
76
- broadcast_error_response
79
+ broadcast_error_response(workflow_execution)
77
80
  end
78
81
 
79
82
  def log_error(error)
@@ -90,25 +93,12 @@ module MetaWorkflows
90
93
  })
91
94
  end
92
95
 
93
- def current_workflow_step
94
- workflow_execution = active_workflow_execution
96
+ def current_workflow_step(workflow_execution)
95
97
  return nil unless workflow_execution
96
98
 
97
99
  workflow_execution.workflow_steps.find_by(step: workflow_execution.current_step)
98
100
  end
99
101
 
100
- def broadcast_error_response
101
- # Replace loader with error message
102
- Turbo::StreamsChannel.broadcast_replace_to(
103
- turbo_stream_name(record),
104
- target: target_frame_id(record, loader: true),
105
- partial: 'meta_workflows/error_message',
106
- locals: {
107
- record: record
108
- }
109
- )
110
- end
111
-
112
102
  def broadcast_form(chat)
113
103
  raise NotImplementedError
114
104
  end
@@ -1,3 +1,4 @@
1
+ <%= turbo_frame_tag target_frame_id(record, loader: true) do %>
1
2
  <div class="lexi-message-assistant">
2
3
  <div class="lexi-message-bubble-assistant">
3
4
  <div class="lexi-message-content-assistant">
@@ -11,4 +12,5 @@
11
12
  </div>
12
13
  </div>
13
14
  </div>
14
- </div>
15
+ </div>
16
+ <% end %>
@@ -1,3 +1,4 @@
1
+ <%= turbo_frame_tag target_frame_id(record, loader: true) do %>
1
2
  <div class="lexi-message-assistant">
2
3
  <div class="lexi-loader-bubble">
3
4
  <div class="lexi-message-content-assistant"
@@ -13,4 +14,5 @@
13
14
  </span>
14
15
  </div>
15
16
  </div>
16
- </div>
17
+ </div>
18
+ <% end %>
@@ -3,7 +3,7 @@
3
3
  module MetaWorkflows
4
4
  MAJOR = 0
5
5
  MINOR = 9
6
- PATCH = 16 # this is automatically incremented by the build process
6
+ PATCH = 18 # this is automatically incremented by the build process
7
7
 
8
8
  VERSION = "#{MetaWorkflows::MAJOR}.#{MetaWorkflows::MINOR}.#{MetaWorkflows::PATCH}".freeze
9
9
  end
@@ -3,6 +3,9 @@
3
3
  module Services
4
4
  module MetaWorkflows
5
5
  class MetaWorkflowService
6
+ include ::MetaWorkflows::MetaWorkflowsHelper
7
+ include ::MetaWorkflows::Streamable
8
+
6
9
  ACTIONS_WITHOUT_CONVERSATION = %w[record_redirect collection_create record_update].freeze
7
10
 
8
11
  attr_reader :record, :workflow_name, :user, :inputs, :workflow_params
@@ -35,6 +38,8 @@ module Services
35
38
  private
36
39
 
37
40
  def process_action(execution_step, conversation, workflow_execution, workflow)
41
+ broadcast_loader_stream(workflow_execution)
42
+
38
43
  case execution_step['action']
39
44
  when 'agent'
40
45
  process_agent_action(conversation, workflow_execution, workflow)
@@ -102,6 +107,7 @@ module Services
102
107
  Rails.logger.error(error.backtrace.join("\n"))
103
108
 
104
109
  record_error_details(error, workflow_step, workflow, workflow_execution) if workflow_step
110
+ broadcast_error_response(workflow_execution)
105
111
  end
106
112
 
107
113
  def record_error_details(error, workflow_step, workflow, workflow_execution)
@@ -145,6 +151,7 @@ module Services
145
151
  continue_workflow(workflow_execution)
146
152
  rescue StandardError => e
147
153
  Rails.logger.error("Error creating collection: #{e.message}")
154
+ broadcast_error_response(workflow_execution)
148
155
  # The workflow should halt on error per requirements - do not increment step
149
156
  end
150
157
  end
@@ -158,6 +165,7 @@ module Services
158
165
  continue_workflow(workflow_execution)
159
166
  rescue StandardError => e
160
167
  Rails.logger.error("Error updating record: #{e.message}")
168
+ broadcast_error_response(workflow_execution)
161
169
  # Let Sidekiq handle retry - reraise the error
162
170
  raise
163
171
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_workflows
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.16
4
+ version: 0.9.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Medovyy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-07-11 00:00:00.000000000 Z
12
+ date: 2025-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -128,6 +128,7 @@ files:
128
128
  - app/assets/javascripts/meta_workflows/controllers/tray_controller.js
129
129
  - app/assets/javascripts/meta_workflows_manifest.js
130
130
  - app/assets/stylesheets/meta_workflows/application.css
131
+ - app/controllers/concerns/meta_workflows/streamable.rb
131
132
  - app/controllers/concerns/tray_configurable.rb
132
133
  - app/controllers/meta_workflows/application_controller.rb
133
134
  - app/controllers/meta_workflows/base_debug_controller.rb