legion-settings 1.3.6 → 1.3.8

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: 226a1ae2303f64b96fc48bd42101545a9d06b73aefab19278f27007c406c39d2
4
- data.tar.gz: 4cbf2414166794436869ed44646f86c2860e7bdad4a07feebbd2536fe0e15276
3
+ metadata.gz: 1f33fc603ef7e3e977a241fce4e06dc22d3d63dc1781c99108a13f3b13b139dc
4
+ data.tar.gz: dc072b339d377a53bab15abee76acb38be1774658f5e6bd89b76c30b468781bb
5
5
  SHA512:
6
- metadata.gz: 0b719320bd415ffbf14d68c5a43122dddf8182a0cfddca05915ba8f36490ede658abcb74fa499f320711a20fb5ec67d4f108c17fa4a1b35ee6a51dac801d0402
7
- data.tar.gz: 88220500e2cc7a8542ce32b26c94b8ccf143d6b90d7ef0054a32f8d4507d175534dd8ac4ddae724ac8cfaa1fb4e88ac099200ca7d028fe4e258fe945398d939a
6
+ metadata.gz: 21767fcba605c3bd7e81191ed5f0268d743735ac71d8c3158cb3a0f5e615cbf809ac172f725110bb857ee511758d4c9d2b05b5063efb7425244879789c878dc3
7
+ data.tar.gz: 4cc7013a89fe254b562d8f3eb325b004f858ca8928cc50e91b58014213608f36c14a892f5a3b15758a5795acf133300d4ab9e395b0d998d328a97afe61a0677a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Legion::Settings Changelog
2
2
 
3
+ ## [1.3.8] - 2026-03-20
4
+
5
+ ### Added
6
+ - `AgentLoader` module for loading YAML/JSON agent definitions from a directory
7
+ - `AgentLoader.load_agents(directory)` — returns validated agent definitions as symbol-keyed hashes
8
+ - `AgentLoader.load_file(path)` — parses `.yaml`, `.yml`, and `.json` agent definition files
9
+ - `AgentLoader.valid?(definition)` — validates required `name` and `runner.functions` keys
10
+
11
+ ## [1.3.7] - 2026-03-20
12
+
13
+ ### Added
14
+ - `enterprise_privacy?` class method: returns true when `LEGION_ENTERPRISE_PRIVACY=true` env var or `enterprise_data_privacy` setting is set
15
+ - `LEGION_ENTERPRISE_PRIVACY` env var loaded into settings via `Loader#load_privacy_env`
16
+
3
17
  ## [1.3.6] - 2026-03-20
4
18
 
5
19
  ### Fixed
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+ require 'json'
5
+
6
+ module Legion
7
+ module Settings
8
+ module AgentLoader
9
+ EXTENSIONS = %w[.yaml .yml .json].freeze
10
+ GLOB = '*.{yaml,yml,json}'
11
+
12
+ class << self
13
+ def load_agents(directory)
14
+ return [] unless directory && Dir.exist?(directory)
15
+
16
+ Dir.glob(File.join(directory, GLOB)).filter_map do |path|
17
+ definition = load_file(path)
18
+ next unless definition && valid?(definition)
19
+
20
+ definition.merge(_source_path: path, _source_mtime: File.mtime(path))
21
+ end
22
+ end
23
+
24
+ def load_file(path)
25
+ content = File.read(path)
26
+ case File.extname(path).downcase
27
+ when '.yaml', '.yml' then YAML.safe_load(content, symbolize_names: true)
28
+ when '.json' then ::JSON.parse(content, symbolize_names: true)
29
+ end
30
+ rescue StandardError
31
+ nil
32
+ end
33
+
34
+ def valid?(definition)
35
+ return false unless definition.is_a?(Hash)
36
+ return false unless definition[:name].is_a?(String) && !definition[:name].empty?
37
+ return false unless definition.dig(:runner, :functions).is_a?(Array)
38
+ return false if definition[:runner][:functions].empty?
39
+
40
+ true
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -128,6 +128,7 @@ module Legion
128
128
 
129
129
  def load_env
130
130
  load_api_env
131
+ load_privacy_env
131
132
  end
132
133
 
133
134
  def load_dns_bootstrap(cache_dir: nil)
@@ -289,6 +290,13 @@ module Legion
289
290
  @indifferent_access = false
290
291
  end
291
292
 
293
+ def load_privacy_env
294
+ return unless ENV['LEGION_ENTERPRISE_PRIVACY'] == 'true'
295
+
296
+ @settings[:enterprise_data_privacy] = true
297
+ @indifferent_access = false
298
+ end
299
+
292
300
  def read_config_file(file)
293
301
  contents = File.read(file).dup
294
302
  if contents.respond_to?(:force_encoding)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Settings
5
- VERSION = '1.3.6'
5
+ VERSION = '1.3.8'
6
6
  end
7
7
  end
@@ -75,6 +75,14 @@ module Legion
75
75
  false
76
76
  end
77
77
 
78
+ def enterprise_privacy?
79
+ return true if ENV['LEGION_ENTERPRISE_PRIVACY'] == 'true'
80
+
81
+ Legion::Settings[:enterprise_data_privacy] ? true : false
82
+ rescue StandardError
83
+ false
84
+ end
85
+
78
86
  def validate!
79
87
  @loader = load if @loader.nil?
80
88
  revalidate_all_modules
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -46,6 +46,7 @@ files:
46
46
  - docs/plans/2026-03-17-config-error-filename-implementation.md
47
47
  - legion-settings.gemspec
48
48
  - lib/legion/settings.rb
49
+ - lib/legion/settings/agent_loader.rb
49
50
  - lib/legion/settings/dns_bootstrap.rb
50
51
  - lib/legion/settings/loader.rb
51
52
  - lib/legion/settings/os.rb