Module: PWN::AI::Agent::Introspection

Defined in:
lib/pwn/ai/agent/introspection.rb

Overview

PWN::AI::Agent::Introspection is the inward-facing counterpart to PWN::AI::Agent::Extrospection. Where Extrospection looks OUTWARD at the world the agent operates in (host state, toolchain, network, threat-intel), Introspection looks INWARD - it lets pwn hand a request to the active AI engine and reflect on its own artifacts, transcripts, findings, code, or decisions.

This module is gated by PWN::Env[:ai][:introspection] so that potentially-sensitive local data is never shipped to a remote LLM unless the operator has explicitly opted in via pwn-vault / config.

It is the single choke-point every PWN::AI::Agent::* domain agent (Assembly, BurpSuite, GQRX, HackerOne, SAST, VulnGen, ...) routes through when it wants an LLM opinion on locally-produced data, and it is also what PWN::AI::Agent::Learning.reflect uses to distill session transcripts into durable PWN::Memory lessons.

Class Method Summary collapse

Class Method Details

.authorsObject

Author(s)

0day Inc. support@0dayinc.com



68
69
70
71
72
# File 'lib/pwn/ai/agent/introspection.rb', line 68

public_class_method def self.authors
  "AUTHOR(S):
    0day Inc. <support@0dayinc.com>
  "
end

.helpObject

Display Usage for this Module



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/pwn/ai/agent/introspection.rb', line 76

public_class_method def self.help
  puts "USAGE:
    #{self}.reflect_on(
      request: 'required - String - What you want the AI to reflect on',
      system_role_content: 'optional - context to set up the model behavior for reflection',
      spinner: 'optional - Boolean - Display spinner during operation (default: false)',
      suppress_pii_warning: 'optional - Boolean - Suppress PII Warnings (default: false)'
    )

    #{self}.authors
  "
end

.reflect_on(opts = {}) ⇒ Object

Supported Method Parameters

response = PWN::AI::Agent::Introspection.reflect_on( request: 'required - String - What you want the AI to reflect on', system_role_content: 'optional - context to set up the model behavior for reflection', spinner: 'optional - Boolean - Display spinner during operation (default: false)', suppress_pii_warning: 'optional - Boolean - Suppress PII Warnings (default: false)' )



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/pwn/ai/agent/introspection.rb', line 33

public_class_method def self.reflect_on(opts = {})
  request = opts[:request]
  raise 'ERROR: request must be provided' if request.nil?

  system_role_content = opts[:system_role_content]

  spinner = opts[:spinner] || false

  suppress_pii_warning = opts[:suppress_pii_warning] || false

  response = nil

  ai_introspection = PWN::Env[:ai][:introspection]

  if ai_introspection && request.length.positive?
    engine = PWN::Env[:ai][:active].to_s.downcase.to_sym
    valid_ai_engines = PWN::AI.help.reject { |e| e.downcase == :agent }.map(&:downcase)
    raise "ERROR: Unsupported AI engine. Supported engines are: #{valid_ai_engines}" unless valid_ai_engines.include?(engine)

    warn "AI Introspection is enabled.  Ensure #{engine} has been authorized for use and/or requests are sanitized properly." unless suppress_pii_warning
    response = PWN::AI::Agent::Loop.run(
      request: request.chomp,
      system_role_content: system_role_content,
      enabled_toolsets: [],
      spinner: spinner
    )
  end

  response
rescue StandardError => e
  raise e
end