aigency 0.4.0 → 0.5.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +1 -1
- data/lib/aigency/aigent/shell.rb +22 -6
- data/lib/aigency/aigent.rb +65 -8
- data/lib/aigency/sandbox/copy_from_tempdir.rb +30 -0
- data/lib/aigency/sandbox/copy_to_tempdir.rb +30 -0
- data/lib/aigency/sandbox/helpers.rb +15 -0
- data/lib/aigency/sandbox.rb +4 -1
- data/lib/aigency/tempdir/list.rb +2 -1
- data/lib/aigency/tempdir/read.rb +2 -6
- data/lib/aigency/tempdir/write.rb +1 -1
- data/lib/aigency/version.rb +1 -1
- data/lib/aigency/workspace/cmd.rb +1 -1
- data/lib/aigency/workspace/{copy_tempdir_file.rb → copy_from_tempdir.rb} +6 -5
- data/lib/aigency/workspace/copy_to_tempdir.rb +29 -0
- data/lib/aigency/workspace.rb +3 -2
- metadata +8 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 873660a498f3b272c6ed8e29c970a90f2d68efea0581de2f73fae64f3c400c8e
|
|
4
|
+
data.tar.gz: 830594c5ce2d4b37ab09e678c93633716ce6ee1e0937a8c14f12e42063ee464e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7af922b9e3a2cc281f8696dd778a69f696a58193578bae541bb7a24fb1ac93e07e6ab5071d8fe160a6fed801c278be7cb58b4bd78e054c5cb2d8a5ae4af5281
|
|
7
|
+
data.tar.gz: 7f20a0f6fa6e7de82aa1df2069d5fe397c797793790d772f1961c88b353301fad2ed6cd242cecac9190f900aaff5cc7ada36a2399c319d5474654ead6db853d9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ A framework for creating AI agents with RubyLLM.
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
7
7
|
- Ruby 3.2+
|
|
8
|
-
- Docker 29+ (required for sandbox)
|
|
8
|
+
- Docker 29+ (optional; required for the sandbox plugin)
|
|
9
9
|
|
|
10
10
|
(Note: Aigency is not tested on Windows. Some features are known to be Windows-incompatible.)
|
|
11
11
|
|
data/lib/aigency/aigent/shell.rb
CHANGED
|
@@ -29,13 +29,20 @@ module Aigency
|
|
|
29
29
|
puts aigent.tools.map(&:to_s).sort
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
desc "plugins", "Get a list of installed plugins"
|
|
33
|
+
def plugins
|
|
34
|
+
puts aigent.plugins.map(&:name).sort
|
|
35
|
+
end
|
|
36
|
+
|
|
32
37
|
desc "status", "Get the aigent's current status"
|
|
33
38
|
def status
|
|
34
39
|
puts "Name: #{aigent.config('aigent')['name']}"
|
|
35
40
|
puts "Busy: #{aigent.busy?}"
|
|
36
41
|
if aigent.busy?
|
|
37
|
-
puts "Process: #{
|
|
42
|
+
puts "Process: #{aigent.lock_owner || 'unknown'}"
|
|
38
43
|
end
|
|
44
|
+
puts "Plugins: #{aigent.plugins.length}"
|
|
45
|
+
puts "Tools: #{aigent.tools.length}"
|
|
39
46
|
end
|
|
40
47
|
|
|
41
48
|
desc "instructions", "List base instructions"
|
|
@@ -71,15 +78,24 @@ module Aigency
|
|
|
71
78
|
desc "kill", "Kill a blocking process"
|
|
72
79
|
long_desc <<~DESC
|
|
73
80
|
Kill the process that owns an exclusive lock on the aigent's data/lock file.
|
|
81
|
+
(This is the process that flags the aigent as `busy`.)
|
|
74
82
|
DESC
|
|
75
83
|
def kill
|
|
76
|
-
|
|
77
|
-
pid = File.read(aigent.data('lock')).to_i
|
|
78
|
-
puts "Killing process #{pid}"
|
|
79
|
-
Process.kill 'TERM', pid
|
|
80
|
-
else
|
|
84
|
+
unless aigent.busy?
|
|
81
85
|
puts "No blocking process exists."
|
|
86
|
+
return
|
|
87
|
+
end
|
|
88
|
+
pid = aigent.lock_owner
|
|
89
|
+
if pid.nil?
|
|
90
|
+
puts "Could not determine the PID of the blocking process."
|
|
91
|
+
return
|
|
82
92
|
end
|
|
93
|
+
puts "Killing process #{pid}"
|
|
94
|
+
Process.kill 'TERM', pid
|
|
95
|
+
rescue Errno::ESRCH
|
|
96
|
+
puts "Process #{pid} no longer exists."
|
|
97
|
+
rescue Errno::EPERM
|
|
98
|
+
puts "Permission denied to kill process #{pid}."
|
|
83
99
|
end
|
|
84
100
|
|
|
85
101
|
class << self
|
data/lib/aigency/aigent.rb
CHANGED
|
@@ -15,6 +15,7 @@ module Aigency
|
|
|
15
15
|
def initialize(directory)
|
|
16
16
|
@base_directory = File.absolute_path(directory)
|
|
17
17
|
@log = $stdout
|
|
18
|
+
preload
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
# @return [String]
|
|
@@ -44,7 +45,7 @@ module Aigency
|
|
|
44
45
|
# @param except [Array<Class<Tool>>] Tools to exclude from this chat
|
|
45
46
|
# @return [RubyLLM::Chat]
|
|
46
47
|
def brief(*extra, except: [])
|
|
47
|
-
chat = rubyllm_context.chat(provider: :openai, protocol:
|
|
48
|
+
chat = rubyllm_context.chat(provider: :openai, protocol: 'chat_completions').with_thinking(effort: :medium)
|
|
48
49
|
(tools - except).each { |klass| chat.with_tools(klass.new(self)) }
|
|
49
50
|
chat.with_instructions(build_instructions(extra).join, append: true)
|
|
50
51
|
chat.with_provider_options(max_tokens: max_tokens)
|
|
@@ -71,12 +72,14 @@ module Aigency
|
|
|
71
72
|
def stream text, *extra, attach: [], except: [], out: $stdout
|
|
72
73
|
original_log = @log
|
|
73
74
|
@log = out
|
|
74
|
-
response = brief(*extra, except: except).ask text, with: attach
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
response = brief(*extra, except: except).ask text, with: attach do |chunk|
|
|
76
|
+
@log.print chunk.thinking&.text
|
|
77
|
+
end
|
|
77
78
|
@log.puts response.content
|
|
78
79
|
@log.puts "Input tokens: #{response.tokens.input}"
|
|
79
80
|
@log.puts "Output tokens: #{response.tokens.output}"
|
|
81
|
+
@log.puts "Cache read: #{response.tokens.cache_read}"
|
|
82
|
+
@log.puts "Cache write: #{response.tokens.cache_write}"
|
|
80
83
|
response
|
|
81
84
|
rescue StandardError => e
|
|
82
85
|
message = "[#{e.class}] #{e.message}\n" + e.backtrace.map { |line| " #{line}\n" }.join
|
|
@@ -89,7 +92,7 @@ module Aigency
|
|
|
89
92
|
# @param name [String]
|
|
90
93
|
# @return [Hash]
|
|
91
94
|
def config(name)
|
|
92
|
-
configs[name] ||= read_config(name)
|
|
95
|
+
configs[File.basename(name, '.*')] ||= read_config(name)
|
|
93
96
|
end
|
|
94
97
|
|
|
95
98
|
# Initialize the aigent's plugin configurations.
|
|
@@ -102,8 +105,10 @@ module Aigency
|
|
|
102
105
|
# Run code in an exclusive lock
|
|
103
106
|
#
|
|
104
107
|
def block(&block)
|
|
105
|
-
File.open(data('lock'),
|
|
108
|
+
File.open(data('lock'), File::RDWR | File::CREAT, 0o644) do |file|
|
|
106
109
|
file.flock(File::LOCK_EX)
|
|
110
|
+
file.truncate(0)
|
|
111
|
+
file.rewind
|
|
107
112
|
file.write(Process.pid)
|
|
108
113
|
file.flush
|
|
109
114
|
block&.call
|
|
@@ -115,9 +120,11 @@ module Aigency
|
|
|
115
120
|
# Run code if an exclusive lock is available or skip if a lock exists
|
|
116
121
|
#
|
|
117
122
|
def try_with_lock(&block)
|
|
118
|
-
File.open(data('lock'),
|
|
123
|
+
File.open(data('lock'), File::RDWR | File::CREAT, 0o644) do |file|
|
|
119
124
|
acquired = file.flock(File::LOCK_EX|File::LOCK_NB)
|
|
120
125
|
return unless acquired
|
|
126
|
+
file.truncate(0)
|
|
127
|
+
file.rewind
|
|
121
128
|
file.write(Process.pid)
|
|
122
129
|
file.flush
|
|
123
130
|
block&.call
|
|
@@ -135,6 +142,20 @@ module Aigency
|
|
|
135
142
|
end
|
|
136
143
|
alias busy? locked?
|
|
137
144
|
|
|
145
|
+
# Get the PID of the process holding the exclusive lock (if any)
|
|
146
|
+
#
|
|
147
|
+
# Reads the PID from the lockfile and verifies that the process exists.
|
|
148
|
+
# If the lockfile PID is missing or stale, falls back to inspecting the
|
|
149
|
+
# OS lock table (Linux /proc/locks) for the flock owner.
|
|
150
|
+
#
|
|
151
|
+
# @return [Integer, nil]
|
|
152
|
+
def lock_owner
|
|
153
|
+
return nil unless locked?
|
|
154
|
+
pid = File.read(data('lock')).to_i
|
|
155
|
+
return pid if pid > 0 && process_exists?(pid)
|
|
156
|
+
proc_locks_owner
|
|
157
|
+
end
|
|
158
|
+
|
|
138
159
|
# @return [String]
|
|
139
160
|
def instructions
|
|
140
161
|
@instructions ||= build_instructions([]).join("\n\n")
|
|
@@ -145,7 +166,7 @@ module Aigency
|
|
|
145
166
|
config('aigent').fetch('plugins', [])
|
|
146
167
|
.unshift('aigent')
|
|
147
168
|
.uniq
|
|
148
|
-
.
|
|
169
|
+
.filter_map { |name| Plugin.registry[name] }
|
|
149
170
|
end
|
|
150
171
|
|
|
151
172
|
def tools
|
|
@@ -154,6 +175,13 @@ module Aigency
|
|
|
154
175
|
|
|
155
176
|
private
|
|
156
177
|
|
|
178
|
+
# Eager load plugin configurations. This is useful in situations where the
|
|
179
|
+
# environment variables might change after the aigent was instantiated.
|
|
180
|
+
#
|
|
181
|
+
def preload
|
|
182
|
+
plugins.each { |plugin| config(plugin.name) }
|
|
183
|
+
end
|
|
184
|
+
|
|
157
185
|
# @param plugin [Plugin]
|
|
158
186
|
def boot(plugin)
|
|
159
187
|
plugin.directories.each do |dir|
|
|
@@ -243,6 +271,35 @@ module Aigency
|
|
|
243
271
|
end
|
|
244
272
|
end
|
|
245
273
|
|
|
274
|
+
# @return [Boolean] True if a process with the given PID exists
|
|
275
|
+
def process_exists?(pid)
|
|
276
|
+
Process.kill 0, pid
|
|
277
|
+
true
|
|
278
|
+
rescue Errno::ESRCH
|
|
279
|
+
false
|
|
280
|
+
rescue Errno::EPERM
|
|
281
|
+
true
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Parse the Linux /proc/locks table for the PID holding a flock on the lockfile
|
|
285
|
+
#
|
|
286
|
+
# @return [Integer, nil]
|
|
287
|
+
def proc_locks_owner
|
|
288
|
+
return nil unless File.exist?("/proc/locks")
|
|
289
|
+
stat = File.stat(data('lock'))
|
|
290
|
+
File.foreach("/proc/locks") do |line|
|
|
291
|
+
fields = line.split
|
|
292
|
+
next unless fields[1] == "FLOCK"
|
|
293
|
+
major, minor, ino = fields[5].to_s.split(":")
|
|
294
|
+
next unless major.to_i(16) == ((stat.dev >> 8) & 0xfff)
|
|
295
|
+
next unless minor.to_i(16) == ((stat.dev & 0xff) | ((stat.dev >> 12) & 0xffffff00))
|
|
296
|
+
next unless ino.to_i == stat.ino # inode is decimal in /proc/locks
|
|
297
|
+
owner = fields[4].to_i
|
|
298
|
+
return owner if owner > 0 && owner != Process.pid
|
|
299
|
+
end
|
|
300
|
+
nil
|
|
301
|
+
end
|
|
302
|
+
|
|
246
303
|
Plugin.register Plugin.new(
|
|
247
304
|
'aigent',
|
|
248
305
|
tools: [CurrentTime],
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'aigency/tempdir'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
module Aigency
|
|
7
|
+
module Sandbox
|
|
8
|
+
class CopyFromTempdir < Tool
|
|
9
|
+
include Helpers
|
|
10
|
+
include Tempdir::Helpers
|
|
11
|
+
|
|
12
|
+
description 'Copy a file from tempdir to sandbox'
|
|
13
|
+
|
|
14
|
+
parameters do
|
|
15
|
+
string :tempdir_source, description: "A destination filename in tempdir", required: true
|
|
16
|
+
string :sandbox_destination, description: "A relative path to a sandbox file", required: true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def execute(tempdir_source:, sandbox_destination:)
|
|
20
|
+
aigent.log.puts "[Sandbox::CopyToTempdir] #{tempdir_source} #{sandbox_destination}"
|
|
21
|
+
abs_tempdir = expand_in_tempdir(tempdir_source)
|
|
22
|
+
abs_sandbox = expand_in_sandbox(sandbox_destination)
|
|
23
|
+
FileUtils.copy_file abs_tempdir, abs_sandbox
|
|
24
|
+
{ success: true, file: abs_sandbox[aigent.data('sandbox').length..]}
|
|
25
|
+
rescue StandardError => e
|
|
26
|
+
{ success: false, error: "[#{e.class}] #{e.message}"}
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'aigency/tempdir'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
module Aigency
|
|
7
|
+
module Sandbox
|
|
8
|
+
class CopyToTempdir < Tool
|
|
9
|
+
include Helpers
|
|
10
|
+
include Tempdir::Helpers
|
|
11
|
+
|
|
12
|
+
description 'Copy a file from sandbox to tempdir'
|
|
13
|
+
|
|
14
|
+
parameters do
|
|
15
|
+
string :sandbox_source, description: "A relative path to a sandbox file", required: true
|
|
16
|
+
string :tempdir_destination, description: "A destination filename in tempdir", required: true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def execute(sandbox_source:, tempdir_destination:)
|
|
20
|
+
aigent.log.puts "[Sandbox::CopyToTempdir] #{sandbox_source} #{tempdir_destination}"
|
|
21
|
+
abs_sandbox = expand_in_sandbox(sandbox_source)
|
|
22
|
+
abs_tempdir = expand_in_tempdir(tempdir_destination)
|
|
23
|
+
FileUtils.copy_file abs_sandbox, abs_tempdir
|
|
24
|
+
{ success: true, file: abs_sandbox }
|
|
25
|
+
rescue StandardError => e
|
|
26
|
+
{ success: false, error: "[#{e.class}] #{e.message}"}
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Aigency
|
|
4
|
+
module Sandbox
|
|
5
|
+
module Helpers
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
def expand_in_sandbox path
|
|
9
|
+
absolute = File.absolute_path(path, aigent.data('sandbox'))
|
|
10
|
+
raise PathError, "#{path} is not relative to tempdir" unless absolute.start_with?(aigent.data('sandbox'))
|
|
11
|
+
absolute
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/aigency/sandbox.rb
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
module Aigency
|
|
4
4
|
module Sandbox
|
|
5
|
+
require 'aigency/sandbox/helpers'
|
|
5
6
|
require 'aigency/sandbox/exec'
|
|
7
|
+
require 'aigency/sandbox/copy_from_tempdir'
|
|
8
|
+
require 'aigency/sandbox/copy_to_tempdir'
|
|
6
9
|
|
|
7
10
|
Plugin.register Plugin.new(
|
|
8
11
|
'sandbox',
|
|
9
|
-
tools: [
|
|
12
|
+
tools: [Exec, CopyFromTempdir, CopyToTempdir],
|
|
10
13
|
directories: ['sandbox', 'data/sandbox', 'data/sandbox_ssh'],
|
|
11
14
|
files: {
|
|
12
15
|
'sandbox/Dockerfile' => File.read(File.join(GEM_PATH, 'scaffold', 'sandbox', 'Dockerfile')),
|
data/lib/aigency/tempdir/list.rb
CHANGED
|
@@ -7,9 +7,10 @@ module Aigency
|
|
|
7
7
|
|
|
8
8
|
def execute
|
|
9
9
|
aigent.log.puts "[Tempdir::List]"
|
|
10
|
+
files = Dir.glob(File.join(PATH, '**', '*'))
|
|
10
11
|
{
|
|
11
12
|
success: true,
|
|
12
|
-
|
|
13
|
+
files: files.map { |file| { path: file, size: File.size(file)} }
|
|
13
14
|
}
|
|
14
15
|
end
|
|
15
16
|
end
|
data/lib/aigency/tempdir/read.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Aigency
|
|
|
5
5
|
class Read < Tool
|
|
6
6
|
include Helpers
|
|
7
7
|
|
|
8
|
-
description "Read a file
|
|
8
|
+
description "Read a file from the temp directory"
|
|
9
9
|
|
|
10
10
|
parameters do
|
|
11
11
|
string :filename, description: "The file to read"
|
|
@@ -18,11 +18,7 @@ module Aigency
|
|
|
18
18
|
if File.size(absolute_path) > 500_000
|
|
19
19
|
{ success: false, error: "File is too large to read (max 500000 bytes)"}
|
|
20
20
|
else
|
|
21
|
-
{
|
|
22
|
-
success: true,
|
|
23
|
-
absolute_path: absolute_path,
|
|
24
|
-
content: File.read(File.join(PATH, filename))
|
|
25
|
-
}
|
|
21
|
+
{ success: true, filename: File.basename(absolute_path), content: File.read(absolute_path).scrub }
|
|
26
22
|
end
|
|
27
23
|
rescue StandardError => e
|
|
28
24
|
{ success: false, error: "[#{e.class}] #{e.message}"}
|
|
@@ -15,7 +15,7 @@ module Aigency
|
|
|
15
15
|
def execute(filename:, content:)
|
|
16
16
|
aigent.log.puts "[Tempdir::Write] #{filename}"
|
|
17
17
|
absolute_path = expand_in_tempdir(filename)
|
|
18
|
-
File.
|
|
18
|
+
File.binwrite absolute_path, content
|
|
19
19
|
{
|
|
20
20
|
success: true,
|
|
21
21
|
absolute_path: absolute_path
|
data/lib/aigency/version.rb
CHANGED
|
@@ -28,7 +28,7 @@ module Aigency
|
|
|
28
28
|
end
|
|
29
29
|
validate_path_arguments(arguments, non_path_arguments.length)
|
|
30
30
|
output, error, result = Open3.capture3(command, *arguments, chdir: resolved)
|
|
31
|
-
{ success: result.success?, stdout: output, stderr: error }
|
|
31
|
+
{ success: result.success?, stdout: output.scrub, stderr: error.scrub }
|
|
32
32
|
rescue StandardError => e
|
|
33
33
|
{ success: false, error: "[#{e.class}] #{e.message}" }
|
|
34
34
|
end
|
|
@@ -4,7 +4,7 @@ require 'fileutils'
|
|
|
4
4
|
|
|
5
5
|
module Aigency
|
|
6
6
|
module Workspace
|
|
7
|
-
class
|
|
7
|
+
class CopyFromTempdir < Tool
|
|
8
8
|
include Tempdir::Helpers
|
|
9
9
|
include Workspace::Helpers
|
|
10
10
|
|
|
@@ -12,14 +12,15 @@ module Aigency
|
|
|
12
12
|
|
|
13
13
|
parameters do
|
|
14
14
|
string :tempdir_source, description: "A source filename in tempdir", required: true
|
|
15
|
-
string :
|
|
15
|
+
string :workspace_destination, description: "A destination filename in workspace", required: true
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def execute(tempdir_source:,
|
|
19
|
-
aigent.log.puts "[Workspace::CopyTempdirFile] #{tempdir_source.inspect} #{
|
|
18
|
+
def execute(tempdir_source:, workspace_destination:)
|
|
19
|
+
aigent.log.puts "[Workspace::CopyTempdirFile] #{tempdir_source.inspect} #{workspace_destination.inspect}"
|
|
20
20
|
abs_tempdir = expand_in_tempdir(tempdir_source)
|
|
21
|
-
abs_workspace = expand_in_workspace(
|
|
21
|
+
abs_workspace = expand_in_workspace(workspace_destination)
|
|
22
22
|
FileUtils.copy_file abs_tempdir, abs_workspace
|
|
23
|
+
{ success: true, file: abs_workspace }
|
|
23
24
|
rescue StandardError => e
|
|
24
25
|
{ success: false, error: "[#{e.class}] #{e.message}"}
|
|
25
26
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
module Aigency
|
|
6
|
+
module Workspace
|
|
7
|
+
class CopyToTempdir < Tool
|
|
8
|
+
include Tempdir::Helpers
|
|
9
|
+
include Workspace::Helpers
|
|
10
|
+
|
|
11
|
+
description 'Copy a file from workspace to tempdir'
|
|
12
|
+
|
|
13
|
+
parameters do
|
|
14
|
+
string :workspace_source, description: "A source filename in workspace", required: true
|
|
15
|
+
string :tempdir_destination, description: "A destination filename in tempdir", required: true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def execute(workspace_source:, tempdir_destination:)
|
|
19
|
+
aigent.log.puts "[Workspace::CopyTempdirFile] #{workspace_source} #{tempdir_destination}"
|
|
20
|
+
abs_workspace = expand_in_workspace(workspace_source)
|
|
21
|
+
abs_tempdir = expand_in_tempdir(tempdir_destination)
|
|
22
|
+
FileUtils.copy_file abs_workspace, abs_tempdir
|
|
23
|
+
{ success: true, file: abs_tempdir }
|
|
24
|
+
rescue StandardError => e
|
|
25
|
+
{ success: false, error: "[#{e.class}] #{e.message}"}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/aigency/workspace.rb
CHANGED
|
@@ -14,12 +14,13 @@ module Aigency
|
|
|
14
14
|
require 'aigency/workspace/rm'
|
|
15
15
|
require 'aigency/workspace/wc'
|
|
16
16
|
require 'aigency/workspace/write'
|
|
17
|
-
require 'aigency/workspace/
|
|
17
|
+
require 'aigency/workspace/copy_from_tempdir'
|
|
18
|
+
require 'aigency/workspace/copy_to_tempdir'
|
|
18
19
|
|
|
19
20
|
Plugin.register Plugin.new(
|
|
20
21
|
'workspace',
|
|
21
22
|
directories: ['data/workspace'],
|
|
22
|
-
tools: [Cat, Cp, Diff, Grep, Ls, Mkdir, Mv, Rm, Wc, Write,
|
|
23
|
+
tools: [Cat, Cp, Diff, Grep, Ls, Mkdir, Mv, Rm, Wc, Write, CopyFromTempdir, CopyToTempdir],
|
|
23
24
|
config: <<~FILE
|
|
24
25
|
prompt: "The workspace tools provide access to a readable and writeable directory."
|
|
25
26
|
FILE
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aigency
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fred Snyder
|
|
@@ -141,7 +141,10 @@ files:
|
|
|
141
141
|
- lib/aigency/plugin/shell.rb
|
|
142
142
|
- lib/aigency/rake.rb
|
|
143
143
|
- lib/aigency/sandbox.rb
|
|
144
|
+
- lib/aigency/sandbox/copy_from_tempdir.rb
|
|
145
|
+
- lib/aigency/sandbox/copy_to_tempdir.rb
|
|
144
146
|
- lib/aigency/sandbox/exec.rb
|
|
147
|
+
- lib/aigency/sandbox/helpers.rb
|
|
145
148
|
- lib/aigency/shell.rb
|
|
146
149
|
- lib/aigency/tempdir.rb
|
|
147
150
|
- lib/aigency/tempdir/helpers.rb
|
|
@@ -155,7 +158,8 @@ files:
|
|
|
155
158
|
- lib/aigency/workspace.rb
|
|
156
159
|
- lib/aigency/workspace/cat.rb
|
|
157
160
|
- lib/aigency/workspace/cmd.rb
|
|
158
|
-
- lib/aigency/workspace/
|
|
161
|
+
- lib/aigency/workspace/copy_from_tempdir.rb
|
|
162
|
+
- lib/aigency/workspace/copy_to_tempdir.rb
|
|
159
163
|
- lib/aigency/workspace/cp.rb
|
|
160
164
|
- lib/aigency/workspace/diff.rb
|
|
161
165
|
- lib/aigency/workspace/grep.rb
|
|
@@ -191,14 +195,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
191
195
|
requirements:
|
|
192
196
|
- - ">="
|
|
193
197
|
- !ruby/object:Gem::Version
|
|
194
|
-
version: 3.
|
|
198
|
+
version: 3.4.1
|
|
195
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
200
|
requirements:
|
|
197
201
|
- - ">="
|
|
198
202
|
- !ruby/object:Gem::Version
|
|
199
203
|
version: '0'
|
|
200
204
|
requirements: []
|
|
201
|
-
rubygems_version: 4.0.
|
|
205
|
+
rubygems_version: 4.0.16
|
|
202
206
|
specification_version: 4
|
|
203
207
|
summary: A framework for building agentic AI workers.
|
|
204
208
|
test_files: []
|