agent-harness 0.3.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb82dfba3d7a36312cfcb32c86b39f88726b558828643361be96a3b69ca1a3ea
4
- data.tar.gz: 19d643749ed639f4932f82ebdb8ef92f984cb7a4fc12c8c3d05a201103464d5a
3
+ metadata.gz: a3f57fefa5527c5cdc436d4da8c10e5f638c69363b32e689213feb9bdccadf7d
4
+ data.tar.gz: ae98c1fc1f1a919adf7919f8d4dc0dc308286f1cb0e02d4a719d9060e29451b4
5
5
  SHA512:
6
- metadata.gz: 575d764e422d9b465233ea8ffd0db147165be8cc6f6e70fd19cb549d13677da5054acf8d2ec0632d20a95f22c02d27a9add9c12f137a62133a88ebce0b00a70b
7
- data.tar.gz: 87122eb8b3feef772bbd7b8d8fb6a29bd99a18cadd5e260eb74b00a55c489b01e5b0c9d82d93412e270b339ca7fab5ab559999fcd1a9171a2ab7c79325bd688d
6
+ metadata.gz: eeafca1c0fe7183572056d50caf4e30f28e7a410a5fdb0f2bd3271ae3c0ef5a679f48c559266143a14cd03130de714a6e9af286d7e6e990eb8977fa3972c74df
7
+ data.tar.gz: c29ad51bcd248190e44d089d28daf6914a319a800536a3dfce25be6ad9b993a1582b6f317bf7df5f0989864c0a6b663cbb76de1921155b2c2f1aad10037bdd9e
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.3.0"
2
+ ".": "0.4.0"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0](https://github.com/viamin/agent-harness/compare/agent-harness/v0.3.0...agent-harness/v0.4.0) (2026-02-16)
4
+
5
+
6
+ ### Features
7
+
8
+ * add DockerCommandExecutor for container-based command execution ([85826e5](https://github.com/viamin/agent-harness/commit/85826e5ece76d9f073329902769093f846cfd8b7))
9
+ * add DockerCommandExecutor for container-based command execution ([cb18f2e](https://github.com/viamin/agent-harness/commit/cb18f2e2f1d16ef52ea2ce54c51970d73fcae6c8))
10
+
3
11
  ## [0.3.0](https://github.com/viamin/agent-harness/compare/agent-harness-v0.2.2...agent-harness/v0.3.0) (2026-01-26)
4
12
 
5
13
 
@@ -87,7 +87,7 @@ module AgentHarness
87
87
  !which(binary).nil?
88
88
  end
89
89
 
90
- private
90
+ protected
91
91
 
92
92
  def normalize_command(command)
93
93
  case command
@@ -100,6 +100,8 @@ module AgentHarness
100
100
  end
101
101
  end
102
102
 
103
+ private
104
+
103
105
  def execute_with_timeout(cmd_array, timeout:, env:, stdin_data:)
104
106
  stdout = ""
105
107
  stderr = ""
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AgentHarness
4
+ # Executes commands inside a Docker container
5
+ #
6
+ # Wraps commands with `docker exec` so they run inside
7
+ # the specified container rather than on the host.
8
+ #
9
+ # @example Basic usage
10
+ # executor = AgentHarness::DockerCommandExecutor.new(container_id: "abc123")
11
+ # result = executor.execute(["python", "script.py"])
12
+ #
13
+ # @example With environment variables
14
+ # result = executor.execute("echo $FOO", env: { "FOO" => "bar" })
15
+ class DockerCommandExecutor < CommandExecutor
16
+ attr_reader :container_id
17
+
18
+ # Initialize the Docker command executor
19
+ #
20
+ # @param container_id [String] the Docker container ID or name
21
+ # @param logger [Logger, nil] optional logger
22
+ # @raise [CommandExecutionError] if Docker CLI is not found on the host
23
+ def initialize(container_id:, logger: nil)
24
+ raise ArgumentError, "container_id cannot be nil or empty" if container_id.nil? || container_id.empty?
25
+
26
+ super(logger: logger)
27
+ @container_id = container_id
28
+ validate_docker!
29
+ end
30
+
31
+ # Execute a command inside the Docker container
32
+ #
33
+ # Wraps the given command with `docker exec` and delegates
34
+ # to the parent class for actual process execution.
35
+ #
36
+ # @param command [Array<String>, String] command to execute
37
+ # @param timeout [Integer, nil] timeout in seconds
38
+ # @param env [Hash] environment variables to set in the container
39
+ # @param stdin_data [String, nil] data to send to stdin
40
+ # @return [Result] execution result
41
+ def execute(command, timeout: nil, env: {}, stdin_data: nil)
42
+ docker_cmd = build_docker_command(command, env: env, stdin_data: stdin_data)
43
+ super(docker_cmd, timeout: timeout, env: {}, stdin_data: stdin_data)
44
+ end
45
+
46
+ # Check if a binary exists inside the container
47
+ #
48
+ # @param binary [String] binary name
49
+ # @return [String, nil] full path or nil
50
+ def which(binary)
51
+ result = execute(["which", binary], timeout: 5)
52
+ result.success? ? result.stdout.strip : nil
53
+ end
54
+
55
+ private
56
+
57
+ def validate_docker!
58
+ return if ENV["PATH"]&.split(File::PATH_SEPARATOR)&.any? { |path| File.executable?(File.join(path, "docker")) }
59
+
60
+ raise CommandExecutionError, "Docker CLI not found on host PATH"
61
+ end
62
+
63
+ def build_docker_command(command, env:, stdin_data:)
64
+ cmd = ["docker", "exec"]
65
+
66
+ env.each { |key, value| cmd.push("--env", "#{key}=#{value}") }
67
+ cmd.push("-i") if stdin_data
68
+
69
+ cmd.push(@container_id)
70
+
71
+ cmd.concat(normalize_command(command))
72
+ end
73
+ end
74
+ end
@@ -32,7 +32,8 @@ module AgentHarness
32
32
  class Base
33
33
  include Adapter
34
34
 
35
- attr_reader :config, :executor, :logger
35
+ attr_reader :config, :logger
36
+ attr_accessor :executor
36
37
 
37
38
  # Initialize the provider
38
39
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AgentHarness
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/agent_harness.rb CHANGED
@@ -89,6 +89,7 @@ end
89
89
  require_relative "agent_harness/errors"
90
90
  require_relative "agent_harness/configuration"
91
91
  require_relative "agent_harness/command_executor"
92
+ require_relative "agent_harness/docker_command_executor"
92
93
  require_relative "agent_harness/response"
93
94
  require_relative "agent_harness/token_tracker"
94
95
  require_relative "agent_harness/error_taxonomy"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agent-harness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bart Agapinan
@@ -78,6 +78,7 @@ files:
78
78
  - lib/agent_harness.rb
79
79
  - lib/agent_harness/command_executor.rb
80
80
  - lib/agent_harness/configuration.rb
81
+ - lib/agent_harness/docker_command_executor.rb
81
82
  - lib/agent_harness/error_taxonomy.rb
82
83
  - lib/agent_harness/errors.rb
83
84
  - lib/agent_harness/orchestration/circuit_breaker.rb