lex-llm-anthropic 0.3.7 → 0.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: 2ee85fd86d41029ba981f01d33cce9ad7f390f65b61cdd02b2fc15193b718d11
4
- data.tar.gz: eeec4dfe3bb5d4f0815de6fefc733fa36e7cefed795d2c78462cf8283f44fa0c
3
+ metadata.gz: 9e8444443bbbabe4465a76230ce1b70e3af49ff25529870b5dea72a0f8218b76
4
+ data.tar.gz: c16f2c252c9da40e855994e9b5a1aa6924185099f5e8363aeb2c7baf6f7df42e
5
5
  SHA512:
6
- metadata.gz: d7b39fcd77411152616451c234f1994a1ddf42f6278d22ff3fbeb34580fb215130e9035a72944dc5e566fbe3a158f58a6cfaddde3bb6ac81ceba91b6e58508a3
7
- data.tar.gz: 93f22be2a6a885ead678affd737ca6c0eae9582f341b5eaf278b876fea6bd9f145281a1892f5c5f8139a9bbe612d4609b77ea29eb70eca9c54ee89be9f39ba12
6
+ metadata.gz: ebc14278592c483ab61c54fd66afcfd4de3f76b92cd5e4566f98b5b43311afc52414969125eff40de3c4b4ca0b9e48eab3855a37fed16e66e97ce8f2e5647986
7
+ data.tar.gz: d0b32ac7bd9b75d9d1b5868da6c14d757fb985fbc0f7c1d77ab0644785449e02a7adf595cff1d7ef94a663e2cb5bf12d422aa146b5ec1feb1e429290462cf69a
@@ -7,12 +7,18 @@ on:
7
7
  jobs:
8
8
  ci:
9
9
  uses: LegionIO/.github/.github/workflows/ci.yml@main
10
+ with:
11
+ companion-gems: >-
12
+ {"lex-llm":{"repository":"LegionIO/lex-llm","ref":"eedf5172abe0bfda26501967c3f3f38b7c180095"}}
10
13
 
11
14
  excluded-files:
12
15
  uses: LegionIO/.github/.github/workflows/excluded-files.yml@main
13
16
 
14
17
  security:
15
18
  uses: LegionIO/.github/.github/workflows/security-scan.yml@main
19
+ with:
20
+ companion-gems: >-
21
+ {"lex-llm":{"repository":"LegionIO/lex-llm","ref":"eedf5172abe0bfda26501967c3f3f38b7c180095"}}
16
22
 
17
23
  version-changelog:
18
24
  uses: LegionIO/.github/.github/workflows/version-changelog.yml@main
data/.gitignore CHANGED
@@ -10,3 +10,4 @@ Gemfile.lock
10
10
  .claude
11
11
  AGENTS.md
12
12
  CLAUDE.md
13
+ /.ci-dependencies/
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.8] - 2026-10-31
4
+
5
+ ### Fixed
6
+ - Render URL images with `source.url` and base64 images with `source.data` through one translator-owned image mapping used by both callable and standalone translation.
7
+ - Preserve explicit text/image cache-control metadata, including TTL, in chat and streaming requests.
8
+
9
+ ### Changed
10
+ - Require `lex-llm >= 0.8.6` for canonical image source normalization.
11
+
3
12
  ## [0.3.7] - 2026-08-25
4
13
 
5
14
  ### Fixed
data/Gemfile CHANGED
@@ -4,10 +4,10 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- # Local-tree resolution: use the adjacent lex-llm checkout when present so the
8
- # 0.8.0 conformance work resolves against the local contract cut.
7
+ # Use immutable CI companions or adjacent development checkouts when available.
9
8
  group :test do
10
- lex_llm_path = File.expand_path('../lex-llm', __dir__)
9
+ lex_llm_path = File.expand_path('.ci-dependencies/lex-llm', __dir__)
10
+ lex_llm_path = File.expand_path('../lex-llm', __dir__) unless Dir.exist?(lex_llm_path)
11
11
  gem 'lex-llm', path: lex_llm_path if Dir.exist?(lex_llm_path)
12
12
  end
13
13
 
data/README.md CHANGED
@@ -7,12 +7,17 @@ This gem provides the `:anthropic` provider family for LegionIO's LLM routing la
7
7
  **Namespace:** `Legion::Extensions::Llm::Anthropic`
8
8
  **Provider family:** `:anthropic`
9
9
  **Default model:** `claude-sonnet-4-6`
10
- **Dependency:** `lex-llm >= 0.4.3` (shared provider contracts, response normalization, fleet responders)
10
+ **Dependency:** `lex-llm >= 0.8.6` (shared Canonical, Inventory and exact fleet contracts)
11
11
 
12
12
  ```ruby
13
13
  require 'legion/extensions/llm/anthropic'
14
14
  ```
15
15
 
16
+ Canonical URL images render as `source: { type: 'url', url: ... }`; base64 images
17
+ render as `source: { type: 'base64', media_type: ..., data: ... }`. The callable and
18
+ standalone translator share this mapping. Ordered text/image content and explicit
19
+ cache-control metadata, including TTL, survive chat, streaming and fleet rehydration.
20
+
16
21
  ---
17
22
 
18
23
  ## File Index
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
  # 0.8.0 is the complete contract cut: Canonical is the only internal language,
31
31
  # the legacy type set and the LegacyCoordinatorAdapter wiring are deleted, and
32
32
  # the provider funnel enforces canonical messages centrally.
33
- spec.add_dependency 'lex-llm', '>= 0.8.0'
33
+ spec.add_dependency 'lex-llm', '>= 0.8.6'
34
34
  end
@@ -159,27 +159,22 @@ module Legion
159
159
  # One canonical block to one Anthropic wire block; nil when the block
160
160
  # renders nothing (an empty text block would 400 on the API).
161
161
  def content_block_to_wire(block, cache: false)
162
- case block.type
163
- when :text
164
- return nil if block.text.to_s.empty?
165
-
166
- text_block(block.text, cache:)
167
- when :thinking
168
- thinking_block(block)
169
- when :image
170
- {
171
- type: 'image',
172
- source: {
173
- type: block.source_type || 'base64',
174
- media_type: block.media_type,
175
- data: block.data
176
- }
177
- }
178
- else
179
- raise ArgumentError,
180
- "anthropic provider cannot render content block type #{block.type.inspect} — " \
181
- 'only text, thinking, and image blocks cross this wire'
182
- end
162
+ wire = case block.type
163
+ when :text
164
+ return nil if block.text.to_s.empty?
165
+
166
+ text_block(block.text, cache:)
167
+ when :thinking
168
+ thinking_block(block)
169
+ when :image
170
+ translator.render_image_block(block:)
171
+ else
172
+ raise ArgumentError,
173
+ "anthropic provider cannot render content block type #{block.type.inspect} — " \
174
+ 'only text, thinking, and image blocks cross this wire'
175
+ end
176
+ wire[:cache_control] = block.cache_control if block.cache_control
177
+ wire
183
178
  end
184
179
 
185
180
  def text_block(text, cache: false)
@@ -91,6 +91,19 @@ module Legion
91
91
  base.compact
92
92
  end
93
93
 
94
+ # Shared by the callable render path and standalone request translation.
95
+ def render_image_block(block:)
96
+ source = case block.source_type
97
+ when :url
98
+ { type: 'url', url: block.data }
99
+ when :base64
100
+ { type: 'base64', media_type: block.media_type, data: block.data }
101
+ else
102
+ raise ArgumentError, "unsupported Anthropic image source type #{block.source_type.inspect}"
103
+ end
104
+ { type: 'image', source: source }
105
+ end
106
+
94
107
  # Parse: Anthropic wire Hash to Canonical::Response. Accepts both Anthropic wire format
95
108
  # (content: array of blocks) and canonical form (text: string) for conformance kit compatibility.
96
109
  def parse_response(wire)
@@ -269,8 +282,7 @@ module Legion
269
282
  { type: 'tool_result', tool_use_id: block.tool_use_id,
270
283
  content: [{ type: 'text', text: block.text || '' }] }
271
284
  when :image
272
- { type: 'image', source: { type: block.source_type || 'base64',
273
- media_type: block.media_type, data: block.data } }
285
+ render_image_block(block:)
274
286
  else
275
287
  { type: 'text', text: block.text || '' }
276
288
  end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Llm
6
6
  module Anthropic
7
- VERSION = '0.3.7'
7
+ VERSION = '0.3.8'
8
8
  end
9
9
  end
10
10
  end
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.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - LegionIO
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 0.8.0
74
+ version: 0.8.6
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 0.8.0
81
+ version: 0.8.6
82
82
  description: Anthropic provider integration for the LegionIO LLM routing framework.
83
83
  email:
84
84
  - matthewdiverson@gmail.com