active_harness 0.2.29 → 0.2.30

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: 7146a492cd9454703ab47eb1c6222962587b4fe5585aaef2a5390349da394a1a
4
- data.tar.gz: 476ee4d22259b10fa7d58cd25208ea5c900e6523991b1f17e288f7c3104cfd92
3
+ metadata.gz: f5f759449bd21052f986bc092a621f2ce39cb4faa630ba1bc759419bc27aac37
4
+ data.tar.gz: 94e8abc9d0a0ca7ef877ea0f1e66ac68899236d7d33f10ac754f3541b3a29d1b
5
5
  SHA512:
6
- metadata.gz: d211c987a80244262c35fbc83202491b61807ee98f092808ca801cfcc57eb1ad58e4f48ccf8e364078b99a267e14816e8551b55c5b2a3de2fe8e6828321bc2b6
7
- data.tar.gz: 71244082f0e0c81d9fe7d0271e05dd53ebf0e5a727ced5554d637e84aed8a58b6a014e8b0537ff2dcc10cc501385905b78c5aae8f328c1d774a874fc30d3c7b3
6
+ metadata.gz: 8a9529f9391337660a325993adf7db17bd2f470f6b2e69cab256a1ac907616d0c76a5c5b4c56f9850399fbfb8d886b3f2d2c2241c6ceb66ea0d83cb0e2d4c724
7
+ data.tar.gz: e1ae97b30a763b761ae28d20b957670d5b8a774d249456cfd84da09830ce6ebc8661c2d19790a69ff2889ff585ce7af307beb13b5d46886708db041fd1c33d73
@@ -21,15 +21,37 @@ module ActiveHarness
21
21
  lam ? @stop_if = lam : @stop_if
22
22
  end
23
23
 
24
+ # DSL: define how to extract the new payload from a result.
25
+ # When provided, the step always updates the payload — even if stop_if is also set.
26
+ # The block receives the Result and must return the new payload value.
27
+ #
28
+ # step :laundry do
29
+ # use PromptLaundryPipeline
30
+ # transform { |result| result.output }
31
+ # stop_if ->(result) { result.processed["stopped"] == true }
32
+ # end
33
+ def transform(&block)
34
+ @transform_block = block if block
35
+ @transform_block
36
+ end
37
+
24
38
  # True if agent_class is a Tribunal subclass — tribunal steps do not update payload.
25
39
  def tribunal?
26
40
  @agent_class.is_a?(Class) && @agent_class <= ActiveHarness::Tribunal
27
41
  end
28
42
 
29
- # Transform steps update payload to result.output after execution.
30
- # Guard steps (stop_if present) and tribunal steps leave payload unchanged.
43
+ # Returns true when this step should update the pipeline payload after execution.
44
+ # A step transforms when:
45
+ # - an explicit transform block is defined (overrides default), OR
46
+ # - no stop_if and not a tribunal (legacy default)
31
47
  def transform?
32
- !tribunal? && @stop_if.nil?
48
+ @transform_block ? true : (!tribunal? && @stop_if.nil?)
49
+ end
50
+
51
+ # Extract the new payload value from result.
52
+ # Uses the user-defined transform block when present; falls back to result.output.
53
+ def extract_payload(result)
54
+ @transform_block ? @transform_block.call(result) : result.output
33
55
  end
34
56
  end
35
57
  end
@@ -140,6 +140,20 @@ module ActiveHarness
140
140
  @stopped
141
141
  end
142
142
 
143
+ # Wraps pipeline outcome into a Result so a pipeline can be used as a step
144
+ # inside another pipeline, matching the same interface as Agent and Tribunal.
145
+ #
146
+ # output — final payload (nil when stopped)
147
+ # processed — { "stopped" => bool, "stopped_at" => step_name_string_or_nil }
148
+ def result
149
+ Result.new(
150
+ input: @original_input,
151
+ output: @output,
152
+ processed: { "stopped" => @stopped, "stopped_at" => @stopped_at&.to_s },
153
+ execution_time: @execution_time
154
+ )
155
+ end
156
+
143
157
  # Execute all steps sequentially. Returns self for chaining.
144
158
  def call
145
159
  config = self.class.pipeline_config
@@ -155,7 +169,7 @@ module ActiveHarness
155
169
 
156
170
  @step_results[step.name] = result
157
171
  @context[step.name] = result
158
- @payload = result.output if step.transform?
172
+ @payload = step.extract_payload(result) if step.transform?
159
173
 
160
174
  fire(:after_step, step.name, result, config)
161
175
  fire_step(:after_step, step.name, result, config)
@@ -210,7 +224,12 @@ module ActiveHarness
210
224
  end
211
225
 
212
226
  def execute_step(step)
213
- streams = { token: @token_stream, agent: @agent_event_stream, tribunal: @tribunal_event_stream }.compact
227
+ streams = {
228
+ token: @token_stream,
229
+ agent: @agent_event_stream,
230
+ tribunal: @tribunal_event_stream,
231
+ pipeline: @pipeline_event_stream
232
+ }.compact
214
233
  step.agent_class.new(
215
234
  input: @payload,
216
235
  context: @context.dup,
@@ -30,7 +30,7 @@ require_relative "active_harness/pipeline"
30
30
  require_relative "active_harness/railtie" if defined?(Rails::Railtie)
31
31
 
32
32
  module ActiveHarness
33
- VERSION = "0.2.29"
33
+ VERSION = "0.2.30"
34
34
 
35
35
  class << self
36
36
  # Configure ActiveHarness.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_harness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.29
4
+ version: 0.2.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - the-teacher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-10 00:00:00.000000000 Z
11
+ date: 2026-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby