Class: GDKBox::Harness

Inherits:
Object
  • Object
show all
Defined in:
lib/gdkbox/harness.rb

Overview

An agent CLI ("harness") that can be installed into a box and dispatched to run tasks headlessly. gdkbox ships a small registry of harnesses; each box runs exactly one, chosen at gdkbox up --harness.

The npm-installable harnesses reuse the same mise-aware install path as Claude Code (install into ~/.local, symlink the binary + node into /usr/local/bin). A harness declares the env var its provider reads for credentials and the config.yml key gdkbox looks under for a default.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, bin:, key_env:, config_key:, summary:, run:, skills_subdir:, npm_package: nil, npm_flags: nil) ⇒ Harness

Returns a new instance of Harness.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/gdkbox/harness.rb', line 45

def initialize(id:, bin:, key_env:, config_key:, summary:, run:, skills_subdir:,
  npm_package: nil, npm_flags: nil)
  @id = id
  @npm_package = npm_package
  @npm_flags = npm_flags
  @bin = bin
  @key_env = key_env
  @config_key = config_key
  @summary = summary
  @run = run
  @skills_subdir = skills_subdir
end

Instance Attribute Details

#binObject (readonly)

Returns the value of attribute bin.



42
43
44
# File 'lib/gdkbox/harness.rb', line 42

def bin
  @bin
end

#config_keyObject (readonly)

Returns the value of attribute config_key.



42
43
44
# File 'lib/gdkbox/harness.rb', line 42

def config_key
  @config_key
end

#idObject (readonly)

Returns the value of attribute id.



42
43
44
# File 'lib/gdkbox/harness.rb', line 42

def id
  @id
end

#key_envObject (readonly)

Returns the value of attribute key_env.



42
43
44
# File 'lib/gdkbox/harness.rb', line 42

def key_env
  @key_env
end

#npm_flagsObject (readonly)

Returns the value of attribute npm_flags.



42
43
44
# File 'lib/gdkbox/harness.rb', line 42

def npm_flags
  @npm_flags
end

#npm_packageObject (readonly)

Returns the value of attribute npm_package.



42
43
44
# File 'lib/gdkbox/harness.rb', line 42

def npm_package
  @npm_package
end

#skills_subdirObject (readonly)

Returns the value of attribute skills_subdir.



42
43
44
# File 'lib/gdkbox/harness.rb', line 42

def skills_subdir
  @skills_subdir
end

#summaryObject (readonly)

Returns the value of attribute summary.



42
43
44
# File 'lib/gdkbox/harness.rb', line 42

def summary
  @summary
end

Class Method Details

.[](id) ⇒ Object



22
23
24
25
26
# File 'lib/gdkbox/harness.rb', line 22

def [](id)
  @registry.fetch(id.to_s) do
    raise Error, "Unknown harness '#{id}'. Available: #{ids.join(', ')}."
  end
end

.allObject



28
29
30
# File 'lib/gdkbox/harness.rb', line 28

def all
  @registry.values
end

.defaultObject

The harness used when none is specified.



37
38
39
# File 'lib/gdkbox/harness.rb', line 37

def default
  "claude"
end

.idsObject



32
33
34
# File 'lib/gdkbox/harness.rb', line 32

def ids
  @registry.keys
end

.register(**kwargs) ⇒ Object



16
17
18
19
20
# File 'lib/gdkbox/harness.rb', line 16

def register(**kwargs)
  harness = new(**kwargs)
  @registry[harness.id] = harness
  harness
end

Instance Method Details

#agent_command(json:, yolo:) ⇒ Object

The in-box shell snippet that runs the agent against $GDKBOX_TASK. The caller wraps it with a timeout and sources the seeded API key.



65
66
67
# File 'lib/gdkbox/harness.rb', line 65

def agent_command(json:, yolo:)
  @run.call(json: json, yolo: yolo)
end

#installable?Boolean

True when gdkbox knows how to install this harness automatically.

Returns:

  • (Boolean)


59
60
61
# File 'lib/gdkbox/harness.rb', line 59

def installable?
  !@npm_package.nil?
end