ai_sentinel 0.1.1 → 0.1.2
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 +4 -4
- data/lib/ai_sentinel/cli.rb +20 -0
- data/lib/ai_sentinel/config_loader.rb +2 -1
- data/lib/ai_sentinel/configuration.rb +3 -2
- data/lib/ai_sentinel/scheduler.rb +2 -1
- data/lib/ai_sentinel/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3fbc0d9833c0562b188f975fa0d32cb8f175bda40149d1e3c3aa0ec64863f4ad
|
|
4
|
+
data.tar.gz: 4fb375aa24d1dfa447bf9a52a10f06a03cde84610f75dcdf875cc2aff93b3f97
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3516b53aeea1e1175b0d96849a12a3d79ca1ad3c65e91c559f6b746ba2b091f1fd333fe2934abfe14aef82d1da8cc7998a58ca9caba4299332ebd3b226487563
|
|
7
|
+
data.tar.gz: 9bf82e503bddd8194bf5b492097d507a95e494a48dc9ea4ca2f650638ca48a161e4c50ad922c95495e66d20cd67fb5fd71c23635372c4c5a063223536d34825e
|
data/lib/ai_sentinel/cli.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'fileutils'
|
|
3
4
|
require 'thor'
|
|
4
5
|
require_relative 'cli/helpers'
|
|
5
6
|
require_relative 'cli/context_display'
|
|
@@ -28,6 +29,25 @@ module AiSentinel
|
|
|
28
29
|
AiSentinel.start(daemonize: options[:daemonize])
|
|
29
30
|
end
|
|
30
31
|
|
|
32
|
+
desc 'stop', 'Stop a running daemon'
|
|
33
|
+
method_option :config, type: :string, aliases: '-c', desc: 'Path to config file'
|
|
34
|
+
def stop
|
|
35
|
+
load_config
|
|
36
|
+
pid_path = AiSentinel.configuration.pid_file
|
|
37
|
+
|
|
38
|
+
unless File.exist?(pid_path)
|
|
39
|
+
say "No PID file found at #{pid_path}. Is the daemon running?"
|
|
40
|
+
return
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
pid = File.read(pid_path).strip.to_i
|
|
44
|
+
Process.kill('TERM', pid)
|
|
45
|
+
say "Sent TERM signal to process #{pid}."
|
|
46
|
+
rescue Errno::ESRCH
|
|
47
|
+
say "Process #{pid} not found. Removing stale PID file."
|
|
48
|
+
FileUtils.rm_f(pid_path)
|
|
49
|
+
end
|
|
50
|
+
|
|
31
51
|
desc 'run WORKFLOW', 'Manually trigger a workflow immediately'
|
|
32
52
|
def run_workflow(workflow_name)
|
|
33
53
|
load_config
|
|
@@ -20,7 +20,8 @@ module AiSentinel
|
|
|
20
20
|
'log_files' => ->(config, val) { config.log_files = val },
|
|
21
21
|
'on_prompt_change' => ->(config, val) { config.on_prompt_change = val.to_sym },
|
|
22
22
|
'tool_safety' => ->(config, val) { config.tool_safety = val.transform_keys(&:to_sym) },
|
|
23
|
-
'max_tool_rounds' => ->(config, val) { config.max_tool_rounds = val }
|
|
23
|
+
'max_tool_rounds' => ->(config, val) { config.max_tool_rounds = val },
|
|
24
|
+
'pid_file' => ->(config, val) { config.pid_file = File.expand_path(val) }
|
|
24
25
|
}.freeze
|
|
25
26
|
|
|
26
27
|
attr_reader :config_path, :raw_config
|
|
@@ -31,7 +31,7 @@ module AiSentinel
|
|
|
31
31
|
attr_accessor :provider, :api_key, :database_path, :max_context_messages,
|
|
32
32
|
:compaction_threshold, :compaction_buffer, :log_file,
|
|
33
33
|
:log_file_size, :log_files, :on_prompt_change,
|
|
34
|
-
:tool_safety, :max_tool_rounds
|
|
34
|
+
:tool_safety, :max_tool_rounds, :pid_file
|
|
35
35
|
attr_writer :model, :base_url, :logger
|
|
36
36
|
|
|
37
37
|
def initialize
|
|
@@ -50,6 +50,7 @@ module AiSentinel
|
|
|
50
50
|
@on_prompt_change = :ask
|
|
51
51
|
@tool_safety = nil
|
|
52
52
|
@max_tool_rounds = DEFAULT_MAX_TOOL_ROUNDS
|
|
53
|
+
@pid_file = File.join(Dir.home, '.ai_sentinel', 'ai_sentinel.pid')
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def logger
|
|
@@ -73,7 +74,7 @@ module AiSentinel
|
|
|
73
74
|
"database_path=#{database_path} log_file=#{log_file || 'STDOUT'} " \
|
|
74
75
|
"max_context_messages=#{max_context_messages} " \
|
|
75
76
|
"compaction_threshold=#{compaction_threshold} compaction_buffer=#{compaction_buffer} " \
|
|
76
|
-
"max_tool_rounds=#{max_tool_rounds} " \
|
|
77
|
+
"max_tool_rounds=#{max_tool_rounds} pid_file=#{pid_file} " \
|
|
77
78
|
"api_key=#{api_key ? '[FILTERED]' : 'nil'}>"
|
|
78
79
|
end
|
|
79
80
|
alias to_s inspect
|
|
@@ -44,12 +44,13 @@ module AiSentinel
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def pid_file
|
|
47
|
-
@pid_file ||=
|
|
47
|
+
@pid_file ||= configuration.pid_file
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
private
|
|
51
51
|
|
|
52
52
|
def write_pid_file
|
|
53
|
+
FileUtils.mkdir_p(File.dirname(pid_file))
|
|
53
54
|
File.write(pid_file, Process.pid.to_s)
|
|
54
55
|
end
|
|
55
56
|
|
data/lib/ai_sentinel/version.rb
CHANGED