lex-gemini 0.1.4 → 0.1.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: d421ebaa8ddf2e878fadb96843748b4a24b010198c6d65a182159ae156f60789
4
- data.tar.gz: 573516ccc11f3ef6daeebee65cbc1c910f58e1f879c26474500a185bad190bb5
3
+ metadata.gz: ae34d00ad4e874b1b0b71979f4d7fe34632681f7b422626da992fa0ebe42b944
4
+ data.tar.gz: 2943e187a68e5759f67ae512b28e3a8b151307f5e53991d8cef54d67269d3791
5
5
  SHA512:
6
- metadata.gz: be475106b4bce2d0f7b49b5d4518cf1cc37d5b0cdf7f320b9ce789e5a2805f75a4dc30dd02aa21e0383d1a55958c20881956a34a4fe91b080b6e251153a41c49
7
- data.tar.gz: a612c3b7451965e3b85a5216068740ee7fcf781ec91b51e73e62fdfa1cb7e74d9e79cf0211abb88b94f78d500eb1a14e056040dbeb6930687f274d7bea53a062
6
+ metadata.gz: 417aa550be8ad9fa013f66046a264fd52fd9ea60d8ea2f2be6bc9eaae2f8881fd24936c087d0573059b686c9f34f5c6fab1a2bf73868f44f66c55f566f4abd00
7
+ data.tar.gz: 2b6fdc4f9ad52e63bcb2eac57c4fcac09b0a1e92eeab822636b7e667d80919f9c0a813c8d1de5dae22aa9ff424128ded13218d9fe956ee726ef2790b45bc4610
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.5] - 2026-04-06
4
+
5
+ ### Added
6
+ - Credential-only identity module for Phase 8 Broker integration (`Identity` module with `provide_token`)
7
+
3
8
  ## [0.1.4] - 2026-03-31
4
9
 
5
10
  ### Added
data/CLAUDE.md CHANGED
@@ -10,8 +10,8 @@ Legion Extension that connects LegionIO to Google Gemini API. Generate content,
10
10
 
11
11
  **GitHub**: https://github.com/LegionIO/lex-gemini
12
12
  **License**: MIT
13
- **Version**: 0.1.2
14
- **Specs**: 36 examples
13
+ **Version**: 0.1.5
14
+ **Specs**: 88 examples (9 spec files)
15
15
 
16
16
  ## Architecture
17
17
 
@@ -25,19 +25,20 @@ Legion::Extensions::Gemini
25
25
  │ ├── Files # upload(api_key:, file_path:, mime_type:, ...), list, get, delete
26
26
  │ └── CachedContents # create(api_key:, model:, contents:, ...), list, get, update, delete
27
27
  └── Helpers/
28
- └── Client # Faraday-based HTTP client (class, instantiated per-request)
28
+ ├── Client # Faraday-based HTTP client (class, instantiated per-request)
29
+ └── Usage # usage normalization helpers
29
30
  ```
30
31
 
31
- Unlike lex-claude and lex-openai, `Helpers::Client` is a **class** instantiated per-request. Each runner creates `Helpers::Client.new(api_key:, model:)` inline. This means no module-level `extend` is used in runners; instead, runners call `Helpers::Client.new(...)` directly.
32
+ Unlike other extensions in this category, `Helpers::Client` is a **class** instantiated per-request. Each runner creates `Helpers::Client.new(api_key:, model:)` inline. No module-level `extend` is used in runners runners call `Helpers::Client.new(...)` directly.
32
33
 
33
- `include Legion::Extensions::Helpers::Lex` guard: uses `if defined?(Legion::Extensions::Helpers::Lex)` (note: slightly different guard pattern from lex-claude/lex-openai which use `const_defined?`).
34
+ `include Legion::Extensions::Helpers::Lex` guard: uses `if defined?(Legion::Extensions::Helpers::Lex)` (note: slightly different guard pattern from other extensions which use `const_defined?`).
34
35
 
35
36
  ## Key Design Decisions
36
37
 
37
38
  - `Helpers::Client` is a class to allow per-request model selection without global state.
38
39
  - Authentication uses query parameter `?key=<api_key>` set on the Faraday connection params, so all requests automatically include it.
39
40
  - File upload falls back to raw binary upload (`X-Goog-Upload-Protocol: raw`) when `faraday-multipart` is not loaded.
40
- - `Helpers::Client#handle_response` returns the raw body on success and `{ error: body, status: code }` on failure. All runners wrap the `Helpers::Client` return value in `{ result: ... }`, so the actual runner-level return shape is `{ result: <body> }` on success and `{ result: { error: ..., status: ... } }` on failure.
41
+ - `Helpers::Client#handle_response` returns the raw body on success and `{ error: body, status: code }` on failure. All runners wrap the return value in `{ result: ... }`.
41
42
  - `gemini-2.0-flash` is the default model for Content, Tokens, and `Helpers::Client` initialization.
42
43
  - `gemini-embedding-exp` is the default model for Embeddings runners.
43
44
 
@@ -51,15 +52,17 @@ Unlike lex-claude and lex-openai, `Helpers::Client` is a **class** instantiated
51
52
  |-----|---------|
52
53
  | `faraday` >= 2.0 | HTTP client for Gemini REST API |
53
54
  | `faraday-multipart` | File uploads (optional — falls back to raw binary upload if not available) |
55
+ | `legion-cache`, `legion-crypt`, `legion-data`, `legion-json`, `legion-logging`, `legion-settings`, `legion-transport` | LegionIO core |
54
56
 
55
57
  ## Testing
56
58
 
57
59
  ```bash
58
60
  bundle install
59
- bundle exec rspec # 36 examples
61
+ bundle exec rspec # 88 examples
60
62
  bundle exec rubocop
61
63
  ```
62
64
 
63
65
  ---
64
66
 
65
67
  **Maintained By**: Matthew Iverson (@Esity)
68
+ **Last Updated**: 2026-04-06
data/README.md CHANGED
@@ -109,6 +109,10 @@ puts tokens['totalTokens']
109
109
  - `legion-llm` — High-level LLM interface including Gemini via ruby_llm
110
110
  - `extensions-ai/CLAUDE.md` — Architecture patterns shared across all AI extensions
111
111
 
112
+ ## Version
113
+
114
+ 0.1.5
115
+
112
116
  ## License
113
117
 
114
118
  MIT
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Gemini
6
+ module Identity
7
+ module_function
8
+
9
+ def provider_name = :gemini
10
+ def provider_type = :credential
11
+ def facing = nil
12
+ def capabilities = %i[credentials]
13
+
14
+ def resolve(canonical_name: nil) # rubocop:disable Lint/UnusedMethodArgument
15
+ nil
16
+ end
17
+
18
+ def provide_token
19
+ api_key = resolve_api_key
20
+ return nil unless api_key
21
+
22
+ Legion::Identity::Lease.new(
23
+ provider: :gemini,
24
+ credential: api_key,
25
+ expires_at: nil,
26
+ renewable: false,
27
+ issued_at: Time.now,
28
+ metadata: { credential_type: :api_key }
29
+ )
30
+ end
31
+
32
+ def resolve_api_key
33
+ return nil unless defined?(Legion::Settings)
34
+
35
+ value = Legion::Settings.dig(:llm, :providers, :gemini, :api_key)
36
+ value = value.find { |v| v && !v.empty? } if value.is_a?(Array)
37
+ value unless value.nil? || (value.is_a?(String) && (value.empty? || value.start_with?('env://')))
38
+ end
39
+
40
+ private_class_method :resolve_api_key
41
+ end
42
+ end
43
+ end
44
+ end
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Gemini
6
- VERSION = '0.1.4'
6
+ VERSION = '0.1.5'
7
7
  end
8
8
  end
9
9
  end
@@ -9,6 +9,7 @@ require 'legion/extensions/gemini/runners/models'
9
9
  require 'legion/extensions/gemini/runners/tokens'
10
10
  require 'legion/extensions/gemini/runners/files'
11
11
  require 'legion/extensions/gemini/runners/cached_contents'
12
+ require 'legion/extensions/gemini/identity'
12
13
 
13
14
  module Legion
14
15
  module Extensions
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-gemini
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -144,6 +144,7 @@ files:
144
144
  - lib/legion/extensions/gemini.rb
145
145
  - lib/legion/extensions/gemini/helpers/client.rb
146
146
  - lib/legion/extensions/gemini/helpers/usage.rb
147
+ - lib/legion/extensions/gemini/identity.rb
147
148
  - lib/legion/extensions/gemini/runners/cached_contents.rb
148
149
  - lib/legion/extensions/gemini/runners/content.rb
149
150
  - lib/legion/extensions/gemini/runners/embeddings.rb