crystil 0.5.0

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.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +77 -0
  3. data/LICENSE +21 -0
  4. data/README.md +112 -0
  5. data/lib/crystil/api/base.rb +104 -0
  6. data/lib/crystil/api/invocation.rb +59 -0
  7. data/lib/crystil/api/sentinel.rb +11 -0
  8. data/lib/crystil/api/workflow.rb +34 -0
  9. data/lib/crystil/api/workflows.rb +39 -0
  10. data/lib/crystil/attribution.rb +66 -0
  11. data/lib/crystil/client.rb +95 -0
  12. data/lib/crystil/collector.rb +88 -0
  13. data/lib/crystil/config.rb +79 -0
  14. data/lib/crystil/errors.rb +35 -0
  15. data/lib/crystil/sentinel.rb +100 -0
  16. data/lib/crystil/version.rb +5 -0
  17. data/lib/crystil/wrappers/anthropic.rb +112 -0
  18. data/lib/crystil/wrappers/base.rb +259 -0
  19. data/lib/crystil/wrappers/constants.rb +12 -0
  20. data/lib/crystil/wrappers/geminiai.rb +173 -0
  21. data/lib/crystil/wrappers/google.rb +133 -0
  22. data/lib/crystil/wrappers/groq.rb +295 -0
  23. data/lib/crystil/wrappers/openai.rb +249 -0
  24. data/lib/crystil/wrappers/ruby_llm.rb +170 -0
  25. data/lib/crystil.rb +52 -0
  26. data/sig/crystil/api/base.rbs +24 -0
  27. data/sig/crystil/api/invocation.rbs +16 -0
  28. data/sig/crystil/api/sentinel.rbs +9 -0
  29. data/sig/crystil/api/workflow.rbs +15 -0
  30. data/sig/crystil/api/workflows.rbs +16 -0
  31. data/sig/crystil/attribution.rbs +17 -0
  32. data/sig/crystil/client.rbs +29 -0
  33. data/sig/crystil/collector.rbs +20 -0
  34. data/sig/crystil/config.rbs +33 -0
  35. data/sig/crystil/errors.rbs +28 -0
  36. data/sig/crystil/sentinel.rbs +17 -0
  37. data/sig/crystil/version.rbs +5 -0
  38. data/sig/crystil/wrappers/anthropic.rbs +18 -0
  39. data/sig/crystil/wrappers/base.rbs +21 -0
  40. data/sig/crystil/wrappers/constants.rbs +10 -0
  41. data/sig/crystil/wrappers/geminiai.rbs +19 -0
  42. data/sig/crystil/wrappers/google.rbs +19 -0
  43. data/sig/crystil/wrappers/groq.rbs +22 -0
  44. data/sig/crystil/wrappers/openai.rbs +19 -0
  45. data/sig/crystil/wrappers/ruby_llm.rbs +21 -0
  46. metadata +100 -0
@@ -0,0 +1,28 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ class Error < StandardError
5
+ end
6
+
7
+ class MissingAPIKeyError < Error
8
+ def initialize: (?String msg) -> void
9
+ end
10
+
11
+ class ValidationError < Error
12
+ end
13
+
14
+ class RegistrationError < Error
15
+ end
16
+
17
+ class APIError < Error
18
+ attr_reader status_code: Integer?
19
+ attr_reader response_body: String?
20
+ def initialize: (String message, ?status_code: Integer?, ?response_body: String?) -> void
21
+ end
22
+
23
+ class CrystilRequestInterceptedError < Error
24
+ end
25
+
26
+ class StreamError < Error
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ class Sentinel
5
+ @config: Crystil::Config
6
+
7
+ def initialize: (Crystil::Config config) -> void
8
+ def raise_if_irrelevant: (?enabled: bool) -> self
9
+ def set_secs_irrelevant_request_timeout: (Numeric timeout) -> self
10
+ def raise_if_irrelevant!: (title: String?, request: Hash[Symbol, untyped], ?provider: String?, ?version: String?) -> void
11
+
12
+ private
13
+ def make_relevance_intercept_request: (title: String?, request: Hash[Symbol, untyped], ?provider: String?, ?version: String?) -> [bool, String?]
14
+ def normalize_request: (Hash[Symbol, untyped] request) -> untyped
15
+ def remove_procs: (untyped obj) -> untyped
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ VERSION: String
5
+ end
@@ -0,0 +1,18 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ module Wrappers
5
+ class Anthropic
6
+ @config: Crystil::Config
7
+ @collector: Crystil::Collector
8
+ @sentinel: Crystil::Sentinel?
9
+
10
+ def initialize: (Crystil::Config config, Crystil::Collector collector, ?Crystil::Sentinel? sentinel) -> void
11
+ def register: (untyped client) -> untyped
12
+
13
+ private
14
+ def validate_client!: (untyped client) -> void
15
+ def wrap_messages_method: (untyped client) -> void
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ module Wrappers
5
+ module Base
6
+ def crystil_wrap_method: (Symbol method_name, String _provider_name) -> void
7
+ def crystil_submit_analytics: (method: Symbol, args: Array[untyped], kwargs: Hash[Symbol, untyped], response: untyped, start_time: Time, end_time: Time, ?provider: String?, ?title: String?, ?version: String?, ?status: String, ?exception: String?) -> void
8
+ def crystil_submit_error_analytics: (method: Symbol, args: Array[untyped], kwargs: Hash[Symbol, untyped], error: StandardError, start_time: Time, end_time: Time, ?provider: String?, ?title: String?, ?version: String?, ?response: untyped) -> void
9
+ def crystil_merge_streaming_chunk: (Hash[String | Symbol, untyped] accumulated, Hash[String | Symbol, untyped] chunk) -> Hash[String | Symbol, untyped]
10
+ def crystil_normalize_openai_chunk: (untyped chunk) -> untyped
11
+
12
+ private
13
+ def extract_query: (Symbol _method, Array[untyped] _args, Hash[Symbol, untyped] kwargs) -> Hash[Symbol, untyped]
14
+ def extract_response: (untyped response) -> untyped
15
+ def extract_instance_variables: (untyped obj) -> Hash[Symbol, untyped]
16
+ def serialize_value: (untyped value) -> untyped
17
+ def deep_copy: (untyped obj) -> untyped
18
+ def build_payload: (query: Hash[Symbol, untyped], response: untyped, start_time: Time, end_time: Time, config: Crystil::Config, status: String, ?provider: String?, ?title: String?, ?version: String?, ?exception: String?) -> Hash[Symbol, untyped]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ # Classes
2
+ module Crystil
3
+ module Wrappers
4
+ OPENAI_CLIENT_TITLE: String
5
+ ANTHROPIC_CLIENT_TITLE: String
6
+ GOOGLE_CLIENT_TITLE: String
7
+ RUBY_LLM_PROVIDER: String
8
+ GROQ_PROVIDER: String
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ module Wrappers
5
+ class GeminiAI
6
+ @config: Crystil::Config
7
+ @collector: Crystil::Collector
8
+ @sentinel: Crystil::Sentinel?
9
+
10
+ def initialize: (Crystil::Config config, Crystil::Collector collector, ?Crystil::Sentinel? sentinel) -> void
11
+ def register: (untyped client) -> untyped
12
+
13
+ private
14
+ def validate_client!: (untyped client) -> void
15
+ def wrap_generate_content_method: (untyped client) -> void
16
+ def wrap_stream_generate_content_method: (untyped client) -> void
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ module Wrappers
5
+ class Google
6
+ @config: Crystil::Config
7
+ @collector: Crystil::Collector
8
+ @sentinel: Crystil::Sentinel?
9
+
10
+ def initialize: (Crystil::Config config, Crystil::Collector collector, ?Crystil::Sentinel? sentinel) -> void
11
+ def register: (untyped client) -> untyped
12
+
13
+ private
14
+ def validate_client!: (untyped client) -> void
15
+ def patch_response_class!: -> void
16
+ def wrap_generate_content_method: (untyped client) -> void
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ module Wrappers
5
+ class Groq
6
+ CHAT_COMPLETIONS_PATH: String
7
+ @config: Crystil::Config
8
+ @collector: Crystil::Collector
9
+ @sentinel: Crystil::Sentinel?
10
+
11
+ def initialize: (Crystil::Config config, Crystil::Collector collector, ?Crystil::Sentinel? sentinel) -> void
12
+ def register: (untyped client) -> untyped
13
+ def self.extract_model_title: (untyped model, String fallback) -> String
14
+ def self.build_error_response: (streaming: bool, accumulated: Hash[untyped, untyped]?, error: Exception) -> Hash[untyped, untyped]
15
+
16
+ private
17
+ def validate_client!: (untyped client) -> void
18
+ def patch_stream_handler!: () -> void
19
+ def wrap_post_method: (untyped client) -> void
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ module Wrappers
5
+ class OpenAI
6
+ @config: Crystil::Config
7
+ @collector: Crystil::Collector
8
+ @sentinel: Crystil::Sentinel?
9
+
10
+ def initialize: (Crystil::Config config, Crystil::Collector collector, ?Crystil::Sentinel? sentinel) -> void
11
+ def register: (untyped client) -> untyped
12
+
13
+ private
14
+ def wrap_responses_method: (untyped client) -> void
15
+ def validate_client!: (untyped client) -> void
16
+ def wrap_chat_method: (untyped client) -> void
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ # Starter signatures generated by typeprof + hand-refined; see CLAUDE.md
2
+ # "Code style: type signatures (RBS)" for the refinement convention.
3
+ module Crystil
4
+ module Wrappers
5
+ class RubyLLM
6
+ @config: Crystil::Config
7
+ @collector: Crystil::Collector
8
+ @sentinel: Crystil::Sentinel?
9
+
10
+ def initialize: (Crystil::Config config, Crystil::Collector collector, ?Crystil::Sentinel? sentinel) -> void
11
+ def register: (untyped client) -> untyped
12
+
13
+ private
14
+ def validate_client!: (untyped client) -> void
15
+ def wrap_ask_method: (untyped client) -> void
16
+ def build_query: (String provider, String model_id, Array[Hash[Symbol, untyped]] messages, Hash[Symbol, untyped] tools) -> Hash[Symbol, untyped]
17
+ def build_messages_query: (String model_id, Array[Hash[Symbol, untyped]] messages, Hash[Symbol, untyped] tools) -> Hash[Symbol, untyped]
18
+ def build_google_query: (String model_id, Array[Hash[Symbol, untyped]] messages, Hash[Symbol, untyped] tools) -> Hash[Symbol, untyped]
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crystil
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Crystil
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: concurrent-ruby
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.2'
26
+ description: Crystil gives AI teams real-time visibility into the true costs of deploying
27
+ agents - across tasks, workflows, and customers.
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - CHANGELOG.md
33
+ - LICENSE
34
+ - README.md
35
+ - lib/crystil.rb
36
+ - lib/crystil/api/base.rb
37
+ - lib/crystil/api/invocation.rb
38
+ - lib/crystil/api/sentinel.rb
39
+ - lib/crystil/api/workflow.rb
40
+ - lib/crystil/api/workflows.rb
41
+ - lib/crystil/attribution.rb
42
+ - lib/crystil/client.rb
43
+ - lib/crystil/collector.rb
44
+ - lib/crystil/config.rb
45
+ - lib/crystil/errors.rb
46
+ - lib/crystil/sentinel.rb
47
+ - lib/crystil/version.rb
48
+ - lib/crystil/wrappers/anthropic.rb
49
+ - lib/crystil/wrappers/base.rb
50
+ - lib/crystil/wrappers/constants.rb
51
+ - lib/crystil/wrappers/geminiai.rb
52
+ - lib/crystil/wrappers/google.rb
53
+ - lib/crystil/wrappers/groq.rb
54
+ - lib/crystil/wrappers/openai.rb
55
+ - lib/crystil/wrappers/ruby_llm.rb
56
+ - sig/crystil/api/base.rbs
57
+ - sig/crystil/api/invocation.rbs
58
+ - sig/crystil/api/sentinel.rbs
59
+ - sig/crystil/api/workflow.rbs
60
+ - sig/crystil/api/workflows.rbs
61
+ - sig/crystil/attribution.rbs
62
+ - sig/crystil/client.rbs
63
+ - sig/crystil/collector.rbs
64
+ - sig/crystil/config.rbs
65
+ - sig/crystil/errors.rbs
66
+ - sig/crystil/sentinel.rbs
67
+ - sig/crystil/version.rbs
68
+ - sig/crystil/wrappers/anthropic.rbs
69
+ - sig/crystil/wrappers/base.rbs
70
+ - sig/crystil/wrappers/constants.rbs
71
+ - sig/crystil/wrappers/geminiai.rbs
72
+ - sig/crystil/wrappers/google.rbs
73
+ - sig/crystil/wrappers/groq.rbs
74
+ - sig/crystil/wrappers/openai.rbs
75
+ - sig/crystil/wrappers/ruby_llm.rbs
76
+ homepage: https://crystil.com
77
+ licenses:
78
+ - MIT
79
+ metadata:
80
+ homepage_uri: https://crystil.com
81
+ documentation_uri: https://developers.crystil.com
82
+ rubygems_mfa_required: 'true'
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 2.7.0
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubygems_version: 4.0.18
98
+ specification_version: 4
99
+ summary: Cost visibility for AI agents
100
+ test_files: []