Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0 // Ruby on Rails Mountable Engine #420

Draft
wants to merge 60 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c039328
Create the new engine base structure
matthewblack Jun 27, 2024
d3db4d6
Set up engine routes and service configurations
emorissettegregoire Jul 11, 2024
e392c0e
WIP - Implement Stealth.event method to support new DSL for event dec…
emorissettegregoire Jul 19, 2024
f39ca09
Update MIT-LICENSE
matthewblack Jul 21, 2024
49e6c43
Setup a ServiceMessage
emorissettegregoire Aug 8, 2024
da51f07
Update copyright
emorissettegregoire Aug 8, 2024
fff945d
Separate routes & controllers for messages and calls
emorissettegregoire Aug 9, 2024
44e848e
Ruby Versions
matthewblack Aug 15, 2024
dc1e144
Base Service Client
matthewblack Aug 15, 2024
6a6d7f9
Add Slack Config
matthewblack Aug 15, 2024
099ab0e
Move everything to base
matthewblack Aug 15, 2024
3ec4057
Threads, Errors and Loggers
matthewblack Aug 15, 2024
f0ca069
TID belongs at module level
matthewblack Aug 15, 2024
06dc82e
Refactor down to dispatcher
matthewblack Aug 15, 2024
71ba312
Just change to event controller
matthewblack Aug 15, 2024
b8a8ae3
Refactoring down to event controller, dispatcher and a unified servic…
matthewblack Aug 15, 2024
3fff994
Get rid of service call and service message. Refactor this down to se…
matthewblack Aug 15, 2024
83f995b
Remove Bandwidth.
matthewblack Aug 18, 2024
b1a6304
require stealth/engine
emorissettegregoire Aug 21, 2024
babb2e6
Use single quote in base file
emorissettegregoire Aug 21, 2024
9df71aa
Rename dispatch_event method to avoid potential conflicts and fix JSO…
emorissettegregoire Aug 27, 2024
2b70214
Webhook subscription logic to EventController and add attributes to S…
emorissettegregoire Aug 29, 2024
b493b40
Add an event mapping
emorissettegregoire Sep 2, 2024
dd0815a
Add session file and expose convenience methods in DSL - WIP
emorissettegregoire Sep 5, 2024
cc88564
Update Gemfile.lock
emorissettegregoire Sep 10, 2024
9ed1ca4
Define Stealth::EventContext with core methods for accessing controll…
emorissettegregoire Sep 10, 2024
0480633
WIP - Add FlowManager class to support flow DSL
emorissettegregoire Sep 17, 2024
252f500
Remove unused files
emorissettegregoire Sep 17, 2024
cb20e69
Fix trigger_flow and ensure string sanitization in say method
emorissettegregoire Sep 20, 2024
f63809a
Refactor - Move say method to RepliesController
emorissettegregoire Sep 25, 2024
29fccd7
Add ReplyManager class to support reply DSL
emorissettegregoire Sep 25, 2024
51a1a67
Added idea to gitignore
kladaFOX Oct 7, 2024
a9ec5a2
Added intent classifier (#425)
kladaFOX Oct 14, 2024
b87521a
Setup ScheduledReplyJob and handle blank flow or state for session tr…
emorissettegregoire Oct 14, 2024
b9278ee
commit
emorissettegregoire Oct 14, 2024
78fa4ad
Fix typo in method name
emorissettegregoire Oct 14, 2024
e350a6b
Added ability to pass locals to step_to and update_session_to
kladaFOX Oct 16, 2024
3b96aed
Merge pull request #426 from hellostealth/feature/3.0-mountable-sessi…
matthewblack Oct 18, 2024
b400025
Dev Jumps
matthewblack Oct 18, 2024
fcf625b
Remove private so we can access in rails app
matthewblack Oct 18, 2024
e1b4653
WIP - Add support for dropdown message types
emorissettegregoire Nov 1, 2024
aaab2f3
Added locals logic
kladaFOX Nov 27, 2024
3d69f4d
Updated intent_classifier system prompt
kladaFOX Nov 28, 2024
9a6d7a5
Refactor load_previous_locals and load_before_update_session_to_locals
kladaFOX Dec 2, 2024
c888055
Rename Sidekiq queues to prevent conflict with Stealth 2.0
emorissettegregoire Dec 3, 2024
a21e8cd
Merge branch '3.0-mountable' into feature/3.0-mountable-locals
kladaFOX Dec 3, 2024
1434a46
Added ability to use thread_ts in say function
kladaFOX Dec 11, 2024
1a66ba5
Persist locals
emorissettegregoire Dec 13, 2024
7f3f367
Removed unnecessary persist_locals
kladaFOX Dec 13, 2024
6ff701e
Added interactive_response_received event
kladaFOX Dec 13, 2024
b77649d
Clean up comments
matthewblack Dec 13, 2024
c899bc8
Remove comment
matthewblack Dec 13, 2024
2bdeba8
Changed thread_ts to thread_id
kladaFOX Dec 16, 2024
2ca6354
Added text_changed event
kladaFOX Dec 16, 2024
1245d3b
Merge pull request #427 from hellostealth/feature/3.0-mountable-locals
matthewblack Dec 16, 2024
99f5a00
Safe navigation in intent_classifier
kladaFOX Dec 19, 2024
6000245
Correct if block to prevent nil intents when no categories
kladaFOX Dec 19, 2024
672dddf
feature/delete-message (#428)
emorissettegregoire Jan 14, 2025
c554b02
Defaulting env to be Rails env (#430)
kladaFOX Jan 16, 2025
1dcdc7d
Added ollama options for spectre (#436)
kladaFOX Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions app/controllers/stealth/service_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ def service_handler

case service
when 'bandwidth'
handle_bandwidth
handle_bandwidth(request)
# else
# WIP will add more services here...
end
end

private

def handle_bandwidth
bandwidth_config = Stealth.configurations[:bandwidth]
account_id = bandwidth_config.account_id
api_username = bandwidth_config.api_username
api_password = bandwidth_config.api_password
application_id = bandwidth_config.application_id
def handle_bandwidth(request)
event_type = Stealth::Services::Bandwidth::EventHandler.determine_event_type(request)

case event_type
when :text_message_receive
Stealth.trigger_event(:text_message, :receive, request)
# when :text_message_unsubscribe
end

# WIP will trigger the stealth-bandwidth driver here...
head :no_content
end

end
end
4 changes: 4 additions & 0 deletions lib/stealth.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
require "stealth/version"
require "stealth/engine"
require "stealth/configuration/bandwidth"
require "stealth/event_manager"
require "stealth/event_triggers"

module Stealth
class << self
include Stealth::EventTriggers

attr_accessor :configurations

def setup
Expand Down
4 changes: 4 additions & 0 deletions lib/stealth/engine.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module Stealth
class Engine < ::Rails::Engine
isolate_namespace Stealth

initializer 'stealth' do
require 'stealth/services/bandwidth/event_handler'
end
end
end
39 changes: 39 additions & 0 deletions lib/stealth/event_manager.rb
matthewblack marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Stealth
class EventManager
def initialize
@events = Hash.new { |hash, key| hash[key] = {} }
end

def register_event(event_name, &block)
@current_event = event_name
instance_eval(&block)
@current_event = nil
end

def on(action_name, &block)
@events[@current_event][action_name] = block
end

def trigger_event(event_name, action_name, request)
if @events[event_name] && @events[event_name][action_name]
@events[event_name][action_name].call(request)
else
Rails.logger.warn "No handler for #{event_name} #{action_name}"
end
end

def self.instance
@instance ||= new
end

def self.event(event_name, &block)
instance.register_event(event_name, &block)
end

def self.trigger_event(event_name, action_name, request)
instance.trigger_event(event_name, action_name, request)
end

end
end

11 changes: 11 additions & 0 deletions lib/stealth/event_triggers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Stealth
module EventTriggers
def trigger_event(event_name, action_name, request)
EventManager.trigger_event(event_name, action_name, request)
end

def event(event_name, &block)
EventManager.event(event_name, &block)
end
end
end
Loading