langgraph_rb 0.1.1 → 0.1.2

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: 9c2d260c430ce9be20fea65d6dff4d8013a535a6db46cdd89e15b19200c8b6dd
4
- data.tar.gz: a5213444bbf90954158836c6e73237752ecc2d689e0e4de4807621edb2460f44
3
+ metadata.gz: b3189c15397a79e8ae6eb273adc89aa9148cdd82a6dfbaab22bd6ee0367c02cd
4
+ data.tar.gz: ef3b7472a7b8aea84d2dc8a80e4647a4fda9d1346169e304c16357d507b02b84
5
5
  SHA512:
6
- metadata.gz: ce7b663fb858e5c2adea131d21682df32eddc0cbb72b324773fa0b1cf932338c105d155e7b7b046556748e9f5d60342b9171537a21e1f41c7f7e4933499968cb
7
- data.tar.gz: e30e5ad223be3a455361f753b44ba928054eff285429ca0a8c73474eb851eb9c6c59c627357010032d5133d8ba9d891669225e3640aea5873017910724766536
6
+ metadata.gz: 8084cb63ceacdf4d207daa068a458efa596016232457d863f261533ba3a29de7c88bfc3bdca73a7fcac3312521091cccc61ecd1e99b2df72bfc8ae9b23c0d769
7
+ data.tar.gz: 1b2315e962fa8204b4eaa487304492435b866ff20102444f9e4ff76dc8675461131352554e311e4b32aa5106331d55d5cba3d38ff9081021e95196a8c71a2858
@@ -117,11 +117,11 @@ module LangGraphRB
117
117
 
118
118
  class NodeEvent
119
119
  attr_reader :type, :node_name, :node_class, :state_before, :state_after,
120
- :context, :thread_id, :step_number, :duration, :error, :result, :timestamp
120
+ :context, :thread_id, :step_number, :duration, :error, :result, :timestamp, :from_node
121
121
 
122
122
  def initialize(type:, node_name:, node_class: nil, state_before: nil, state_after: nil,
123
123
  context: nil, thread_id: nil, step_number: nil, duration: nil,
124
- error: nil, result: nil)
124
+ error: nil, result: nil, from_node: nil)
125
125
  @type = type
126
126
  @node_name = node_name
127
127
  @node_class = node_class
@@ -133,6 +133,7 @@ module LangGraphRB
133
133
  @duration = duration
134
134
  @error = error
135
135
  @result = result
136
+ @from_node = from_node
136
137
  @timestamp = Time.now.utc
137
138
  end
138
139
 
@@ -141,6 +142,7 @@ module LangGraphRB
141
142
  type: @type,
142
143
  node_name: @node_name,
143
144
  node_class: @node_class&.name,
145
+ from_node: @from_node,
144
146
  state_before: @state_before,
145
147
  state_after: @state_after,
146
148
  context: @context,
@@ -64,7 +64,7 @@ module LangGraphRB
64
64
  if dest_name == Graph::FINISH
65
65
  final_state = dest_state
66
66
  else
67
- next_active << ExecutionFrame.new(dest_name, dest_state, @step_number)
67
+ next_active << ExecutionFrame.new(dest_name, dest_state, @step_number, from_node: result[:node_name])
68
68
  end
69
69
  else
70
70
  # Use normal edge routing
@@ -78,7 +78,7 @@ module LangGraphRB
78
78
  if dest_name == Graph::FINISH
79
79
  final_state = dest_state
80
80
  else
81
- next_active << ExecutionFrame.new(dest_name, dest_state, @step_number)
81
+ next_active << ExecutionFrame.new(dest_name, dest_state, @step_number, from_node: result[:node_name])
82
82
  end
83
83
  end
84
84
  end
@@ -87,7 +87,7 @@ module LangGraphRB
87
87
  # Handle Send commands (map-reduce)
88
88
  result[:sends].each do |send_cmd|
89
89
  payload_state = result[:state].merge_delta(send_cmd.payload)
90
- next_active << ExecutionFrame.new(send_cmd.to, payload_state, @step_number)
90
+ next_active << ExecutionFrame.new(send_cmd.to, payload_state, @step_number, from_node: result[:node_name])
91
91
  end
92
92
 
93
93
  when :interrupt
@@ -96,7 +96,7 @@ module LangGraphRB
96
96
  user_input = @interrupt_handler.call(result[:interrupt])
97
97
  # Continue with user input merged into state
98
98
  updated_state = result[:state].merge_delta(user_input || {})
99
- next_active << ExecutionFrame.new(result[:node_name], updated_state, @step_number)
99
+ next_active << ExecutionFrame.new(result[:node_name], updated_state, @step_number, from_node: result[:node_name])
100
100
  else
101
101
  # No interrupt handler, treat as completion
102
102
  final_state = result[:state]
@@ -193,7 +193,7 @@ module LangGraphRB
193
193
  notify_observers(:on_graph_end, event)
194
194
  end
195
195
 
196
- def notify_node_start(node, state, context)
196
+ def notify_node_start(node, state, context, from_node: nil)
197
197
  event = Observers::NodeEvent.new(
198
198
  type: :start,
199
199
  node_name: node.name,
@@ -201,12 +201,13 @@ module LangGraphRB
201
201
  state_before: state,
202
202
  context: context,
203
203
  thread_id: @thread_id,
204
- step_number: @step_number
204
+ step_number: @step_number,
205
+ from_node: from_node
205
206
  )
206
207
  notify_observers(:on_node_start, event)
207
208
  end
208
209
 
209
- def notify_node_end(node, state_before, state_after, result, duration)
210
+ def notify_node_end(node, state_before, state_after, result, duration, from_node: nil)
210
211
  event = Observers::NodeEvent.new(
211
212
  type: :end,
212
213
  node_name: node.name,
@@ -216,12 +217,13 @@ module LangGraphRB
216
217
  result: result,
217
218
  duration: duration,
218
219
  thread_id: @thread_id,
219
- step_number: @step_number
220
+ step_number: @step_number,
221
+ from_node: from_node
220
222
  )
221
223
  notify_observers(:on_node_end, event)
222
224
  end
223
225
 
224
- def notify_node_error(node, state, error)
226
+ def notify_node_error(node, state, error, from_node: nil)
225
227
  event = Observers::NodeEvent.new(
226
228
  type: :error,
227
229
  node_name: node.name,
@@ -229,7 +231,8 @@ module LangGraphRB
229
231
  state_before: state,
230
232
  error: error,
231
233
  thread_id: @thread_id,
232
- step_number: @step_number
234
+ step_number: @step_number,
235
+ from_node: from_node
233
236
  )
234
237
  notify_observers(:on_node_error, event)
235
238
  end
@@ -251,7 +254,7 @@ module LangGraphRB
251
254
  # Execute each frame for this node
252
255
  executions.each do |frame|
253
256
  thread = Thread.new do
254
- execute_node_safely(node, frame.state, context, frame.step)
257
+ execute_node_safely(node, frame.state, context, frame.step, from_node: frame.from_node)
255
258
  end
256
259
  threads << thread
257
260
  end
@@ -267,8 +270,8 @@ module LangGraphRB
267
270
  end
268
271
 
269
272
  # Safely execute a single node
270
- def execute_node_safely(node, state, context, step)
271
- notify_node_start(node, state, context)
273
+ def execute_node_safely(node, state, context, step, from_node: nil)
274
+ notify_node_start(node, state, context, from_node: from_node)
272
275
 
273
276
  start_time = Time.now
274
277
  begin
@@ -285,11 +288,11 @@ module LangGraphRB
285
288
  state
286
289
  end
287
290
 
288
- notify_node_end(node, state, final_state, result, duration)
291
+ notify_node_end(node, state, final_state, result, duration, from_node: from_node)
289
292
  processed_result
290
293
  rescue => error
291
294
  duration = Time.now - start_time
292
- notify_node_error(node, state, error)
295
+ notify_node_error(node, state, error, from_node: from_node)
293
296
 
294
297
  {
295
298
  type: :error,
@@ -421,16 +424,17 @@ module LangGraphRB
421
424
 
422
425
  # Execution frame for tracking active node executions
423
426
  class ExecutionFrame
424
- attr_reader :node_name, :state, :step
427
+ attr_reader :node_name, :state, :step, :from_node
425
428
 
426
- def initialize(node_name, state, step)
429
+ def initialize(node_name, state, step, from_node: nil)
427
430
  @node_name = node_name.to_sym
428
431
  @state = state
429
432
  @step = step
433
+ @from_node = from_node
430
434
  end
431
435
 
432
436
  def to_s
433
- "#<ExecutionFrame node: #{@node_name}, step: #{@step}>"
437
+ "#<ExecutionFrame node: #{@node_name}, step: #{@step}, from: #{@from_node}>"
434
438
  end
435
439
  end
436
440
  end
@@ -1,3 +1,3 @@
1
1
  module LangGraphRB
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: langgraph_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Toro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-05 00:00:00.000000000 Z
11
+ date: 2025-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json