langgraph-platform 0.1.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.
@@ -0,0 +1,55 @@
1
+ module LanggraphPlatform
2
+ module Resources
3
+ class Store < BaseResource
4
+ def get(namespace, key)
5
+ response = @client.get("/store/#{namespace}/#{key}")
6
+ Models::StoreItem.new(response)
7
+ end
8
+
9
+ def put(namespace, key, **params)
10
+ body = compact_params(params)
11
+ response = @client.put("/store/#{namespace}/#{key}", body)
12
+ Models::StoreItem.new(response)
13
+ end
14
+
15
+ def delete(namespace, key) # rubocop:disable Naming/PredicateMethod
16
+ @client.delete("/store/#{namespace}/#{key}")
17
+ true
18
+ end
19
+
20
+ def list(namespace, **params)
21
+ params[:limit] ||= 10
22
+ params[:offset] ||= 0
23
+ query_params = compact_params(params)
24
+ response = @client.get("/store/#{namespace}", query_params)
25
+ response.map { |item_data| Models::StoreItem.new(item_data) }
26
+ end
27
+
28
+ def search(**params)
29
+ params[:limit] ||= 10
30
+ params[:offset] ||= 0
31
+ body = compact_params(params)
32
+ response = @client.post('/store/search', body)
33
+ response.map { |item_data| Models::StoreItem.new(item_data) }
34
+ end
35
+
36
+ def batch_get(**params)
37
+ body = compact_params(params)
38
+ response = @client.post('/store/batch', body)
39
+ response.map { |item_data| Models::StoreItem.new(item_data) }
40
+ end
41
+
42
+ def batch_put(**params)
43
+ body = compact_params(params)
44
+ response = @client.put('/store/batch', body)
45
+ response.map { |item_data| Models::StoreItem.new(item_data) }
46
+ end
47
+
48
+ def batch_delete(**params) # rubocop:disable Naming/PredicateMethod
49
+ body = compact_params(params)
50
+ @client.delete('/store/batch', body)
51
+ true
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,63 @@
1
+ module LanggraphPlatform
2
+ module Resources
3
+ class Threads < BaseResource
4
+ def create(**params)
5
+ params[:metadata] ||= {}
6
+ body = compact_params(params)
7
+ response = @client.post('/threads', body)
8
+ Models::Thread.new(response)
9
+ end
10
+
11
+ def find(thread_id)
12
+ response = @client.get("/threads/#{thread_id}")
13
+ Models::Thread.new(response)
14
+ end
15
+
16
+ def update(thread_id, **params)
17
+ params[:metadata] ||= {}
18
+ body = compact_params(params)
19
+ response = @client.patch("/threads/#{thread_id}", body)
20
+ Models::Thread.new(response)
21
+ end
22
+
23
+ def delete(thread_id) # rubocop:disable Naming/PredicateMethod
24
+ @client.delete("/threads/#{thread_id}")
25
+ true
26
+ end
27
+
28
+ def search(**params)
29
+ params[:metadata] ||= {}
30
+ params[:values] ||= {}
31
+ params[:limit] ||= 10
32
+ params[:offset] ||= 0
33
+ body = compact_params(params)
34
+ response = @client.post('/threads/search', body)
35
+ response.map { |thread_data| Models::Thread.new(thread_data) }
36
+ end
37
+
38
+ def state(thread_id, **params)
39
+ params[:subgraphs] ||= false
40
+ query_params = compact_params(params)
41
+ response = @client.get("/threads/#{thread_id}/state", query_params)
42
+ Models::ThreadState.new(response)
43
+ end
44
+
45
+ def update_state(thread_id, **params)
46
+ body = compact_params(params)
47
+ @client.post("/threads/#{thread_id}/state", body)
48
+ end
49
+
50
+ def history(thread_id, **params)
51
+ params[:limit] ||= 10
52
+ query_params = compact_params(params)
53
+ response = @client.get("/threads/#{thread_id}/history", query_params)
54
+ response.map { |state_data| Models::ThreadState.new(state_data) }
55
+ end
56
+
57
+ def copy(thread_id)
58
+ response = @client.post("/threads/#{thread_id}/copy")
59
+ Models::Thread.new(response)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,60 @@
1
+ module LanggraphPlatform
2
+ module Utils
3
+ class Paginator
4
+ include Enumerable
5
+
6
+ def initialize(resource, method, *args, **kwargs)
7
+ @resource = resource
8
+ @method = method
9
+ @args = args
10
+ @kwargs = kwargs
11
+ @limit = kwargs[:limit] || 10
12
+ @offset = kwargs[:offset] || 0
13
+ end
14
+
15
+ def each(&block)
16
+ return enum_for(:each) unless block_given?
17
+
18
+ current_offset = @offset
19
+
20
+ loop do
21
+ params = @kwargs.merge(limit: @limit, offset: current_offset)
22
+ results = @resource.send(@method, *@args, **params)
23
+
24
+ break if results.empty?
25
+
26
+ results.each(&block)
27
+
28
+ break if results.length < @limit
29
+
30
+ current_offset += @limit
31
+ end
32
+ end
33
+
34
+ def first(count = nil)
35
+ if count
36
+ take(count)
37
+ else
38
+ params = @kwargs.merge(limit: 1, offset: @offset)
39
+ results = @resource.send(@method, *@args, **params)
40
+ results.first
41
+ end
42
+ end
43
+
44
+ def page(page_number, per_page = @limit)
45
+ offset = (page_number - 1) * per_page
46
+ params = @kwargs.merge(limit: per_page, offset: offset)
47
+ @resource.send(@method, *@args, **params)
48
+ end
49
+
50
+ def count
51
+ # TODO: Implement count method
52
+ nil
53
+ end
54
+
55
+ def all
56
+ to_a
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,77 @@
1
+ module LanggraphPlatform
2
+ module Utils
3
+ class Validator
4
+ def self.validate_required_params(params, required_keys)
5
+ missing_keys = required_keys - params.keys
6
+
7
+ return if missing_keys.empty?
8
+
9
+ raise ArgumentError, "Missing required parameters: #{missing_keys.join(', ')}"
10
+ end
11
+
12
+ def self.validate_param_types(params, type_map)
13
+ type_map.each do |key, expected_type|
14
+ value = params[key]
15
+ next if value.nil?
16
+
17
+ unless value.is_a?(expected_type)
18
+ raise ArgumentError, "Parameter '#{key}' must be of type #{expected_type}, got #{value.class}"
19
+ end
20
+ end
21
+ end
22
+
23
+ def self.validate_enum_values(params, enum_map)
24
+ enum_map.each do |key, allowed_values|
25
+ value = params[key]
26
+ next if value.nil?
27
+
28
+ unless allowed_values.include?(value)
29
+ raise ArgumentError, "Parameter '#{key}' must be one of #{allowed_values.join(', ')}, got '#{value}'"
30
+ end
31
+ end
32
+ end
33
+
34
+ def self.validate_assistant_id(assistant_id)
35
+ return unless assistant_id.nil? || assistant_id.to_s.strip.empty?
36
+
37
+ raise ArgumentError, 'Assistant ID cannot be nil or empty'
38
+ end
39
+
40
+ def self.validate_thread_id(thread_id)
41
+ return unless thread_id.nil? || thread_id.to_s.strip.empty?
42
+
43
+ raise ArgumentError, 'Thread ID cannot be nil or empty'
44
+ end
45
+
46
+ def self.validate_run_id(run_id)
47
+ return unless run_id.nil? || run_id.to_s.strip.empty?
48
+
49
+ raise ArgumentError, 'Run ID cannot be nil or empty'
50
+ end
51
+
52
+ def self.validate_cron_schedule(schedule)
53
+ raise ArgumentError, 'Cron schedule cannot be nil or empty' if schedule.nil? || schedule.to_s.strip.empty?
54
+
55
+ # Basic cron validation - should have 5 or 6 parts
56
+ parts = schedule.split(' ')
57
+ return if [5, 6].include?(parts.length)
58
+
59
+ raise ArgumentError, "Invalid cron schedule format. Expected 5 or 6 parts, got #{parts.length}"
60
+ end
61
+
62
+ def self.validate_pagination_params(limit, offset)
63
+ raise ArgumentError, 'Limit must be a positive integer' if limit && (!limit.is_a?(Integer) || limit < 1)
64
+
65
+ return unless offset && (!offset.is_a?(Integer) || offset.negative?)
66
+
67
+ raise ArgumentError, 'Offset must be a non-negative integer'
68
+ end
69
+
70
+ def self.validate_metadata(metadata)
71
+ return if metadata.is_a?(Hash)
72
+
73
+ raise ArgumentError, 'Metadata must be a Hash'
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,3 @@
1
+ module LanggraphPlatform
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'http'
4
+ require 'multi_json'
5
+ require 'ostruct'
6
+ require 'time'
7
+ require 'zeitwerk'
8
+ require 'event_stream_parser'
9
+
10
+ Zeitwerk::Loader.for_gem.setup
11
+
12
+ module LanggraphPlatform
13
+ class Error < StandardError; end
14
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: langgraph-platform
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gys Muller
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: event_stream_parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: http
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.15'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: zeitwerk
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.6'
69
+ description: An unoffical Ruby SDK for interacting with LangGraph Platform APIs
70
+ email:
71
+ - gysmuller@users.noreply.github.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - CHANGELOG.md
77
+ - LICENSE.txt
78
+ - README.md
79
+ - lib/langgraph_platform.rb
80
+ - lib/langgraph_platform/base_client.rb
81
+ - lib/langgraph_platform/client.rb
82
+ - lib/langgraph_platform/configuration.rb
83
+ - lib/langgraph_platform/errors.rb
84
+ - lib/langgraph_platform/models/assistant.rb
85
+ - lib/langgraph_platform/models/checkpoint.rb
86
+ - lib/langgraph_platform/models/cron.rb
87
+ - lib/langgraph_platform/models/run.rb
88
+ - lib/langgraph_platform/models/store_item.rb
89
+ - lib/langgraph_platform/models/thread.rb
90
+ - lib/langgraph_platform/models/thread_state.rb
91
+ - lib/langgraph_platform/resources/assistants.rb
92
+ - lib/langgraph_platform/resources/base_resource.rb
93
+ - lib/langgraph_platform/resources/crons.rb
94
+ - lib/langgraph_platform/resources/mcp.rb
95
+ - lib/langgraph_platform/resources/runs.rb
96
+ - lib/langgraph_platform/resources/store.rb
97
+ - lib/langgraph_platform/resources/threads.rb
98
+ - lib/langgraph_platform/utils/paginator.rb
99
+ - lib/langgraph_platform/utils/validator.rb
100
+ - lib/langgraph_platform/version.rb
101
+ homepage: https://github.com/gysmuller/langgraph-platform
102
+ licenses:
103
+ - MIT
104
+ metadata:
105
+ rubygems_mfa_required: 'true'
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 2.7.0
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubygems_version: 3.5.16
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Ruby SDK for LangGraph Platform API
125
+ test_files: []