Class: Insika::Commands::MemoryAddNote
- Inherits:
-
Object
- Object
- Insika::Commands::MemoryAddNote
- Defined in:
- lib/insika/commands/memory_add_note.rb
Overview
Control command: appends a free-form note
(append-only) to the agent's memory (MemoryStore, notes layer). Scoped
by tenant. Synchronous; does not create a Task. -> Note.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(memory_store:, event_stream:) ⇒ MemoryAddNote
constructor
A new instance of MemoryAddNote.
Constructor Details
#initialize(memory_store:, event_stream:) ⇒ MemoryAddNote
Returns a new instance of MemoryAddNote.
11 12 13 14 |
# File 'lib/insika/commands/memory_add_note.rb', line 11 def initialize(memory_store:, event_stream:) @memory_store = memory_store @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/insika/commands/memory_add_note.rb', line 16 def call(command) p = AgentPayload.symbolize(command.payload) text = AgentPayload.presence(p[:text]) raise Insika::ValidationError, "text is required" if text.nil? tenant = AgentPayload.presence(p[:tenant]) || command.[:tenant] note = @memory_store.add_note(tenant: tenant, text: text) @event_stream.emit(Insika::Event.new( type: :memory_note_added, data: { tenant: tenant, note_id: note.id }, meta: { at: Time.now.utc.iso8601 } )) note end |