Class: Kodo::Web::TurnContext
- Inherits:
-
Object
- Object
- Kodo::Web::TurnContext
- Defined in:
- lib/kodo/web/turn_context.rb
Overview
Created fresh for each Router#route call. Shared across all tools in a turn. The nonce is used to wrap web content in markers that cannot be forged by an attacker who knows the source code, because the nonce is generated on Kodo's machine at request time.
Instance Attribute Summary collapse
-
#nonce ⇒ Object
readonly
Returns the value of attribute nonce.
-
#web_fetched ⇒ Object
readonly
Returns the value of attribute web_fetched.
Instance Method Summary collapse
-
#initialize ⇒ TurnContext
constructor
A new instance of TurnContext.
-
#web_fetched! ⇒ Object
Called mechanically by FetchUrl and WebSearch — not by the LLM.
Constructor Details
#initialize ⇒ TurnContext
Returns a new instance of TurnContext.
14 15 16 17 |
# File 'lib/kodo/web/turn_context.rb', line 14 def initialize @nonce = SecureRandom.hex(12) # 96 bits — unguessable at page-write time @web_fetched = false end |
Instance Attribute Details
#nonce ⇒ Object (readonly)
Returns the value of attribute nonce.
12 13 14 |
# File 'lib/kodo/web/turn_context.rb', line 12 def nonce @nonce end |
#web_fetched ⇒ Object (readonly)
Returns the value of attribute web_fetched.
12 13 14 |
# File 'lib/kodo/web/turn_context.rb', line 12 def web_fetched @web_fetched end |
Instance Method Details
#web_fetched! ⇒ Object
Called mechanically by FetchUrl and WebSearch — not by the LLM.
20 21 22 |
# File 'lib/kodo/web/turn_context.rb', line 20 def web_fetched! @web_fetched = true end |