Class: Agent::Workspace::Container
- Inherits:
-
Local
- Object
- Local
- Agent::Workspace::Container
show all
- Defined in:
- app/services/agent/workspace.rb
Overview
EXPERIMENTAL — written against the cage model; needs a host with Docker
to exercise. Git stays host-side; only the agent process is jailed.
Constant Summary
collapse
- WORKDIR =
"/workspace/repo"
Constants inherited
from Local
Local::ROOT
Instance Attribute Summary
Attributes inherited from Local
#card, #path
Instance Method Summary
collapse
Methods inherited from Local
#ahead_of_default?, attach, #commit_all!, #commits_since, #head, #initialize, provision, #provision, #push!, #salvage_dirty_tree!
Instance Method Details
#agent_spawn(cmd) ⇒ Object
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'app/services/agent/workspace.rb', line 127
def agent_spawn(cmd)
docker = ["docker", "run", "--rm", "-i",
"--name", container_name,
"--label", "cardinal=agent",
"-v", "#{path}:#{WORKDIR}",
"-w", WORKDIR]
docker += ["-e", "ANTHROPIC_API_KEY=#{ENV["ANTHROPIC_API_KEY"]}"] if ENV["ANTHROPIC_API_KEY"].present?
docker += ["-e", "CLAUDE_CODE_OAUTH_TOKEN=#{ENV["CLAUDE_CODE_OAUTH_TOKEN"]}"] if ENV["CLAUDE_CODE_OAUTH_TOKEN"].present?
[docker + [image] + cmd, {}]
end
|
#container_name ⇒ Object
125
|
# File 'app/services/agent/workspace.rb', line 125
def container_name = "cardinal-card-#{card.number}"
|
#image ⇒ Object
124
|
# File 'app/services/agent/workspace.rb', line 124
def image = ENV.fetch("CARDINAL_AGENT_IMAGE", "cardinal-agent:latest")
|
#teardown ⇒ Object
142
143
144
|
# File 'app/services/agent/workspace.rb', line 142
def teardown
Open3.capture2e("docker", "rm", "-f", container_name)
end
|