Class: Insika::Commands::MemoryPutFact
- Inherits:
-
Object
- Object
- Insika::Commands::MemoryPutFact
- Defined in:
- lib/insika/commands/memory_put_fact.rb
Overview
Control command: writes a stable fact to the agent's
memory (MemoryStore, profile layer). Until now memory was only written
from WITHIN the turn (the remember tool); this Command is the HTTP surface the
Studio uses to edit facts directly. Scoped by tenant (nil = _default).
Synchronous; does not create a Task. -> Fact.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(memory_store:, event_stream:) ⇒ MemoryPutFact
constructor
A new instance of MemoryPutFact.
Constructor Details
#initialize(memory_store:, event_stream:) ⇒ MemoryPutFact
Returns a new instance of MemoryPutFact.
13 14 15 16 |
# File 'lib/insika/commands/memory_put_fact.rb', line 13 def initialize(memory_store:, event_stream:) @memory_store = memory_store @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/insika/commands/memory_put_fact.rb', line 18 def call(command) p = AgentPayload.symbolize(command.payload) key = AgentPayload.presence(p[:key]) raise Insika::ValidationError, "key is required" if key.nil? raise Insika::ValidationError, "value is required" if p[:value].nil? tenant = AgentPayload.presence(p[:tenant]) || command.[:tenant] fact = @memory_store.put_fact(tenant: tenant, key: key, value: p[:value]) @event_stream.emit(Insika::Event.new( type: :memory_fact_put, data: { tenant: tenant, key: key }, meta: { at: Time.now.utc.iso8601 } )) fact end |