Module: PWN::AI::Agent::OpenGoal
- Defined in:
- lib/pwn/ai/agent/open_goal.rb
Overview
One unfinished host-work request, persisted so the next pwn-ai activation can continue instead of starting a fresh essay.
Constant Summary collapse
- GOAL_FILE =
File.join(Dir.home, '.pwn', 'open_goal.json')
- CONTINUE_RX =
/\A\s*(continue|resume|keep going|pick up|carry on)(?:\s+(?:please|the\s+)?(?:goal|task|work))?\s*[.!]?\s*\z/i
Class Method Summary collapse
- .authors ⇒ Object
- .begin!(opts = {}) ⇒ Object
- .clear!(opts = {}) ⇒ Object
- .current ⇒ Object
- .goal_file ⇒ Object
- .help ⇒ Object
- .resume?(opts = {}) ⇒ Boolean
Class Method Details
.authors ⇒ Object
65 66 67 |
# File 'lib/pwn/ai/agent/open_goal.rb', line 65 public_class_method def self. "AUTHOR(S):\n 0day Inc. <support@0dayinc.com>\n" end |
.begin!(opts = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pwn/ai/agent/open_goal.rb', line 32 public_class_method def self.begin!(opts = {}) request = opts[:request].to_s.strip return if request.empty? FileUtils.mkdir_p(File.dirname(goal_file)) row = { request: request, session_id: opts[:session_id].to_s, updated_at: Time.now.utc.iso8601 } File.write(goal_file, "#{JSON.pretty_generate(row)}\n") row end |
.clear!(opts = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/pwn/ai/agent/open_goal.rb', line 46 public_class_method def self.clear!(opts = {}) return :ok unless opts.is_a?(Hash) return :ok unless File.file?(goal_file) File.delete(goal_file) :ok rescue StandardError :ok end |
.current ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pwn/ai/agent/open_goal.rb', line 20 public_class_method def self.current path = goal_file return unless File.file?(path) row = JSON.parse(File.read(path), symbolize_names: true) return if row[:request].to_s.strip.empty? row rescue StandardError nil end |
.goal_file ⇒ Object
16 17 18 |
# File 'lib/pwn/ai/agent/open_goal.rb', line 16 public_class_method def self.goal_file GOAL_FILE end |
.help ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/pwn/ai/agent/open_goal.rb', line 69 public_class_method def self.help puts <<~USAGE USAGE: PWN::AI::Agent::OpenGoal.begin!(request: '...', session_id: '...') PWN::AI::Agent::OpenGoal.current PWN::AI::Agent::OpenGoal.resume?(request: 'continue') PWN::AI::Agent::OpenGoal.clear! #{self}.authors USAGE end |
.resume?(opts = {}) ⇒ Boolean
56 57 58 59 60 61 62 63 |
# File 'lib/pwn/ai/agent/open_goal.rb', line 56 public_class_method def self.resume?(opts = {}) req = opts[:request].to_s return false if current.nil? req.match?(CONTINUE_RX) rescue StandardError false end |