lex-llm-anthropic 0.2.0 → 0.2.5

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: a17bd5b25cc4b70aa861ad36f5c700dc96558efde25b11dc9a362ac7d545450e
4
- data.tar.gz: 7f02f82b866d53792ca985c45cc36672d025722922fa853c8ac36948ed9514d1
3
+ metadata.gz: 252dd911c10a76d9d23226a35240579ab7f835fae19d3974cbaaed01318f439d
4
+ data.tar.gz: e0a232078d4a3b9a74b3a4d251caa22106798a67493e0f0247f8a6cc9125558e
5
5
  SHA512:
6
- metadata.gz: b2b0860a1bb74cf8498f748aff5d709783591c8334c3f8ecfa52fd09fe6c29d84b0b74c2863fb64b76a3465520259ca26497b368e9db5cb6330a79f46a2a004c
7
- data.tar.gz: 57800905a3e9e3faf9dd34e964b01c3b66a0eda08d86d7e2e4d3a7357d46a41164ab6740d5b5f532b505e7c150749cfe59fef411dffa2a4d0b3aeffb97644623
6
+ metadata.gz: 46891728b8ba7c71c01cf07d0987023507c0e801d3de9af0f0b03ff8cab5b9bc9bb9b25f5c5757ad008763f74bf759cd39d14eb6f198f57822cbb98ef3c9db63
7
+ data.tar.gz: de200293bd0fcc79b7cf6b1c72e6bd4cb4b03083f2e64490ef0df27b2d3a63dc3bac859bf4de50a5a7f4ac301928cf3151ea0148b7e4f14c92522b28f7ee5185
@@ -8,8 +8,20 @@ jobs:
8
8
  ci:
9
9
  uses: LegionIO/.github/.github/workflows/ci.yml@main
10
10
 
11
+ excluded-files:
12
+ uses: LegionIO/.github/.github/workflows/excluded-files.yml@main
13
+
14
+ security:
15
+ uses: LegionIO/.github/.github/workflows/security-scan.yml@main
16
+
17
+ version-changelog:
18
+ uses: LegionIO/.github/.github/workflows/version-changelog.yml@main
19
+
20
+ dependency-review:
21
+ uses: LegionIO/.github/.github/workflows/dependency-review.yml@main
22
+
11
23
  release:
12
- needs: ci
24
+ needs: [ci, excluded-files, security]
13
25
  if: github.event_name == 'push' && github.ref == 'refs/heads/main'
14
26
  uses: LegionIO/.github/.github/workflows/release.yml@main
15
27
  secrets:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.5 - 2026-05-06
4
+
5
+ - Load provider-owned fleet actors through the LegionIO subscription base and the canonical Anthropic provider root.
6
+ - Keep fleet runners anchored on the provider root namespace so provider constants and instance discovery are always loaded.
7
+ - Strip temporary generic API key fields from discovered Anthropic instance configs after credential deduplication.
8
+ - Gate release publishing on the shared security workflow.
9
+
10
+ ## 0.2.4 - 2026-05-06
11
+
12
+ - Use the shared `lex-llm` fleet provider responder helper for provider-owned fleet workers.
13
+ - Remove the runtime `legion-llm` dependency and require `lex-llm >= 0.4.3` for responder-side fleet execution.
14
+ - Refresh README installation, credential discovery, and fleet ownership documentation for the runtime dependency split.
15
+
16
+ ## 0.2.3 - 2026-05-06
17
+
18
+ - Remove require-time provider self-registration; `legion-llm` now owns adapter creation and registry writes from loaded provider discovery metadata.
19
+ - Declare the `:claude` compatibility provider family through `provider_aliases`.
20
+ - Bump dependency floors to `lex-llm >= 0.4.1` and `legion-llm >= 0.9.1`.
21
+
22
+ ## 0.2.2 - 2026-05-06
23
+
24
+ - Enforce the shared keyword-only `lex-llm` provider contract with provider contract specs.
25
+ - Keep Anthropic defaults on `Legion::Extensions::Llm.provider_settings` with instance-level fleet responder settings.
26
+ - Add provider-owned fleet responder actor and runner backed by `legion-llm` fleet policy execution.
27
+ - Bump the transport dependency floor to `legion-transport >= 1.4.14`.
28
+
29
+ ## 0.2.1 - 2026-05-03
30
+
31
+ - Normalize generic settings keys to Anthropic provider config keys during instance discovery.
32
+ - Support named Anthropic instances from extension settings.
33
+
3
34
  ## 0.2.0 - 2026-05-01
4
35
 
5
36
  - Add auto-discovery via CredentialSources and AutoRegistration from lex-llm 0.3.0
data/Gemfile CHANGED
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  group :test do
6
6
  llm_base_path = ENV.fetch('LEX_LLM_PATH', File.expand_path('../lex-llm', __dir__))
7
+ transport_path = ENV.fetch('LEGION_TRANSPORT_PATH', File.expand_path('../../legion-transport', __dir__))
8
+ gem 'legion-transport', path: transport_path if File.directory?(transport_path)
7
9
  gem 'lex-llm', path: llm_base_path if File.directory?(llm_base_path)
8
10
  end
9
11
 
data/README.md CHANGED
@@ -2,10 +2,18 @@
2
2
 
3
3
  LegionIO LLM provider extension for Anthropic.
4
4
 
5
- This gem lives under `Legion::Extensions::Llm::Anthropic` and depends on `lex-llm` for shared provider-neutral routing, fleet, and schema primitives.
5
+ This gem lives under `Legion::Extensions::Llm::Anthropic` and depends on `lex-llm >= 0.4.3` for shared provider contracts, response normalization, fleet responder helpers, and schema primitives. It does not require `legion-llm` at runtime.
6
6
 
7
7
  Load it with `require 'legion/extensions/llm/anthropic'`.
8
8
 
9
+ ## Installation
10
+
11
+ ```ruby
12
+ gem 'lex-llm-anthropic', '~> 0.2'
13
+ ```
14
+
15
+ Anthropic credentials are discovered from `ANTHROPIC_API_KEY`, Claude config, configured provider instances, or an identity broker when one is available.
16
+
9
17
  ## Provider
10
18
 
11
19
  `Legion::Extensions::Llm::Anthropic::Provider` registers with `Legion::Extensions::Llm::Provider` as `:anthropic` and uses Anthropic's Messages API:
@@ -28,3 +36,25 @@ end
28
36
  ```
29
37
 
30
38
  `anthropic_api_base` can override the default `https://api.anthropic.com` endpoint for tests or compatible Anthropic gateways.
39
+
40
+ Named instances can use generic provider keys such as `api_key`, `endpoint`, and `version`; the extension normalizes them to Anthropic-specific provider options during discovery.
41
+
42
+ ## Fleet Responder
43
+
44
+ Provider instances can opt in to consuming Legion LLM fleet requests. The provider-owned fleet actor only starts when at least one configured instance enables `respond_to_requests`.
45
+
46
+ ```yaml
47
+ extensions:
48
+ llm:
49
+ anthropic:
50
+ instances:
51
+ local:
52
+ fleet:
53
+ enabled: true
54
+ respond_to_requests: true
55
+ capabilities:
56
+ - chat
57
+ - stream_chat
58
+ ```
59
+
60
+ Fleet execution is delegated to `Legion::Extensions::Llm::Fleet::ProviderResponder` from `lex-llm`. The responder owns provider invocation for this gem; routing and fleet request publication remain outside this provider extension.
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'legion-json', '>= 1.2.1'
27
27
  spec.add_dependency 'legion-logging', '>= 1.3.2'
28
28
  spec.add_dependency 'legion-settings', '>= 1.3.14'
29
- spec.add_dependency 'lex-llm', '>= 0.3.0'
29
+ spec.add_dependency 'legion-transport', '>= 1.4.14'
30
+ spec.add_dependency 'lex-llm', '>= 0.4.3'
30
31
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'legion/extensions/actors/subscription'
5
+ rescue LoadError => e
6
+ warn(e.message) if $VERBOSE
7
+ end
8
+
9
+ unless defined?(Legion::Extensions::Actors::Subscription)
10
+ raise LoadError, 'LegionIO actor runtime is required for Anthropic fleet worker'
11
+ end
12
+
13
+ require 'legion/extensions/llm/anthropic'
14
+ require 'legion/extensions/llm/fleet/provider_responder'
15
+
16
+ module Legion
17
+ module Extensions
18
+ module Llm
19
+ module Anthropic
20
+ module Actor
21
+ # Subscription actor for Anthropic fleet request consumption.
22
+ class FleetWorker < Legion::Extensions::Actors::Subscription
23
+ def runner_class
24
+ 'Legion::Extensions::Llm::Anthropic::Runners::FleetWorker'
25
+ end
26
+
27
+ def runner_function
28
+ 'handle_fleet_request'
29
+ end
30
+
31
+ def use_runner?
32
+ false
33
+ end
34
+
35
+ def enabled?
36
+ Legion::Extensions::Llm::Fleet::ProviderResponder.enabled_for?(Anthropic.discover_instances)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -47,7 +47,7 @@ module Legion
47
47
  def stream_url = completion_url
48
48
  def models_url = '/v1/models'
49
49
 
50
- def embed(_text, model:, dimensions:)
50
+ def embed(**_provider_options)
51
51
  raise NotImplementedError, 'Anthropic does not expose embeddings through this provider'
52
52
  end
53
53
 
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'legion/extensions/llm/fleet/provider_responder'
4
+ require 'legion/extensions/llm/anthropic'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module Llm
9
+ module Anthropic
10
+ module Runners
11
+ # Runner entrypoint for Anthropic fleet request execution.
12
+ module FleetWorker
13
+ module_function
14
+
15
+ def handle_fleet_request(payload, delivery: nil, properties: nil)
16
+ Legion::Extensions::Llm::Fleet::ProviderResponder.call(
17
+ payload: payload,
18
+ provider_family: Anthropic::PROVIDER_FAMILY,
19
+ provider_class: Anthropic::Provider,
20
+ provider_instances: -> { Anthropic.discover_instances },
21
+ delivery: delivery,
22
+ properties: properties
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Llm
6
6
  module Anthropic
7
- VERSION = '0.2.0'
7
+ VERSION = '0.2.5'
8
8
  end
9
9
  end
10
10
  end
@@ -24,8 +24,16 @@ module Legion
24
24
  tier: :frontier,
25
25
  transport: :http,
26
26
  credentials: { api_key: 'env://ANTHROPIC_API_KEY' },
27
- usage: { inference: true, embedding: false },
28
- limits: { concurrency: 4 }
27
+ usage: { inference: true, embedding: false, image: false },
28
+ limits: { concurrency: 4 },
29
+ fleet: {
30
+ enabled: false,
31
+ respond_to_requests: false,
32
+ capabilities: %i[chat stream_chat],
33
+ lanes: [],
34
+ concurrency: 4,
35
+ queue_suffix: nil
36
+ }
29
37
  }
30
38
  )
31
39
  end
@@ -34,7 +42,11 @@ module Legion
34
42
  Provider
35
43
  end
36
44
 
37
- def self.discover_instances # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
45
+ def self.provider_aliases
46
+ [:claude]
47
+ end
48
+
49
+ def self.discover_instances # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
38
50
  candidates = {}
39
51
 
40
52
  env_key = CredentialSources.env('ANTHROPIC_API_KEY')
@@ -59,11 +71,22 @@ module Legion
59
71
  if settings_config.is_a?(Hash)
60
72
  settings_key = settings_config[:api_key] || settings_config['api_key']
61
73
  if settings_key
62
- candidates[:settings] = settings_config.merge(
74
+ candidates[:settings] = normalize_instance_config(settings_config).merge(
75
+ api_key: settings_key,
63
76
  anthropic_api_key: settings_key,
64
77
  tier: :frontier
65
78
  )
66
79
  end
80
+
81
+ settings_instances(settings_config).each do |name, config|
82
+ next unless config.is_a?(Hash)
83
+
84
+ normalized = normalize_instance_config(config)
85
+ next unless normalized[:anthropic_api_key]
86
+
87
+ normalized[:api_key] = normalized[:anthropic_api_key]
88
+ candidates[name.to_sym] = normalized.merge(tier: :frontier)
89
+ end
67
90
  end
68
91
 
69
92
  if defined?(Legion::Identity::Broker)
@@ -77,20 +100,31 @@ module Legion
77
100
  end
78
101
  end
79
102
 
80
- CredentialSources.dedup_credentials(candidates)
103
+ CredentialSources.dedup_credentials(candidates).transform_values { |config| sanitize_instance_config(config) }
81
104
  end
82
105
 
83
- def self.register_discovered_instances
84
- super
85
- return unless defined?(Legion::LLM::Call::Registry)
106
+ def self.settings_instances(config)
107
+ instances = config[:instances] || config['instances']
108
+ instances.is_a?(Hash) ? instances : {}
109
+ end
86
110
 
87
- Legion::LLM::Call::Registry.instances_for(:anthropic).each do |instance_id, adapter|
88
- Legion::LLM::Call::Registry.register(:claude, adapter, instance: instance_id)
89
- end
111
+ def self.normalize_instance_config(config) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
112
+ normalized = config.to_h.transform_keys { |key| key.respond_to?(:to_sym) ? key.to_sym : key }
113
+ normalized[:anthropic_api_key] ||= normalized.delete(:api_key)
114
+ normalized[:anthropic_api_base] ||= normalized.delete(:base_url)
115
+ normalized[:anthropic_api_base] ||= normalized.delete(:api_base)
116
+ normalized[:anthropic_api_base] ||= normalized.delete(:endpoint)
117
+ normalized[:anthropic_version] ||= normalized.delete(:version)
118
+ normalized.compact.except(:instances)
119
+ end
120
+
121
+ def self.sanitize_instance_config(config)
122
+ config.except(:api_key)
90
123
  end
124
+
125
+ Legion::Extensions::Llm::Configuration.register_provider_options(Provider.configuration_options) if
126
+ Legion::Extensions::Llm::Configuration.respond_to?(:register_provider_options)
91
127
  end
92
128
  end
93
129
  end
94
130
  end
95
-
96
- Legion::Extensions::Llm::Anthropic.register_discovered_instances
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-llm-anthropic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - LegionIO
@@ -51,20 +51,34 @@ dependencies:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: 1.3.14
54
+ - !ruby/object:Gem::Dependency
55
+ name: legion-transport
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.4.14
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 1.4.14
54
68
  - !ruby/object:Gem::Dependency
55
69
  name: lex-llm
56
70
  requirement: !ruby/object:Gem::Requirement
57
71
  requirements:
58
72
  - - ">="
59
73
  - !ruby/object:Gem::Version
60
- version: 0.3.0
74
+ version: 0.4.3
61
75
  type: :runtime
62
76
  prerelease: false
63
77
  version_requirements: !ruby/object:Gem::Requirement
64
78
  requirements:
65
79
  - - ">="
66
80
  - !ruby/object:Gem::Version
67
- version: 0.3.0
81
+ version: 0.4.3
68
82
  description: Anthropic provider integration for the LegionIO LLM routing framework.
69
83
  email:
70
84
  - matthewdiverson@gmail.com
@@ -83,9 +97,11 @@ files:
83
97
  - README.md
84
98
  - lex-llm-anthropic.gemspec
85
99
  - lib/legion/extensions/llm/anthropic.rb
100
+ - lib/legion/extensions/llm/anthropic/actors/fleet_worker.rb
86
101
  - lib/legion/extensions/llm/anthropic/provider.rb
87
102
  - lib/legion/extensions/llm/anthropic/registry_event_builder.rb
88
103
  - lib/legion/extensions/llm/anthropic/registry_publisher.rb
104
+ - lib/legion/extensions/llm/anthropic/runners/fleet_worker.rb
89
105
  - lib/legion/extensions/llm/anthropic/transport/exchanges/llm_registry.rb
90
106
  - lib/legion/extensions/llm/anthropic/transport/messages/registry_event.rb
91
107
  - lib/legion/extensions/llm/anthropic/version.rb