Skip to content
Kward Search API index

Module: Kward::RPC::MemoryMethods

Included in:
SessionManager
Defined in:
lib/kward/rpc/memory_methods.rb

Overview

Memory-related RPC method implementations mixed into SessionManager.

Instance Method Summary collapse

Instance Method Details

#memory_add(text:, scope: nil, tags: []) ⇒ Object



42
43
44
# File 'lib/kward/rpc/memory_methods.rb', line 42

def memory_add(text:, scope: nil, tags: [])
  { memory: memory_manager.add_soft(text, scope: scope || "global", tags: tags) }
end

#memory_add_core(text:, scope: nil, tags: []) ⇒ Object



46
47
48
# File 'lib/kward/rpc/memory_methods.rb', line 46

def memory_add_core(text:, scope: nil, tags: [])
  { memory: memory_manager.add_core(text, scope: scope || "global", tags: tags) }
end

#memory_auto_summary_disableObject



33
34
35
36
# File 'lib/kward/rpc/memory_methods.rb', line 33

def memory_auto_summary_disable
  memory_manager.auto_summary_disable
  { autoSummary: false }
end

#memory_auto_summary_enableObject



28
29
30
31
# File 'lib/kward/rpc/memory_methods.rb', line 28

def memory_auto_summary_enable
  memory_manager.auto_summary_enable
  { autoSummary: true }
end

#memory_disableObject



23
24
25
26
# File 'lib/kward/rpc/memory_methods.rb', line 23

def memory_disable
  memory_manager.disable
  { enabled: false }
end

#memory_enableObject



18
19
20
21
# File 'lib/kward/rpc/memory_methods.rb', line 18

def memory_enable
  memory_manager.enable
  { enabled: true }
end

#memory_forget(id:) ⇒ Object



50
51
52
# File 'lib/kward/rpc/memory_methods.rb', line 50

def memory_forget(id:)
  { forgotten: memory_manager.forget_memory(id) }
end

#memory_inspectObject



62
63
64
# File 'lib/kward/rpc/memory_methods.rb', line 62

def memory_inspect
  memory_manager.inspect_memory
end

#memory_list(include_inactive: false, workspace_root: Dir.pwd) ⇒ Object



38
39
40
# File 'lib/kward/rpc/memory_methods.rb', line 38

def memory_list(include_inactive: false, workspace_root: Dir.pwd)
  memory_manager.hierarchy(include_inactive: include_inactive, workspace_root: workspace_root)
end

#memory_managerObject



9
10
11
# File 'lib/kward/rpc/memory_methods.rb', line 9

def memory_manager
  Memory::Manager.for_config_dir(@config_dir)
end

#memory_promote(id:) ⇒ Object



54
55
56
# File 'lib/kward/rpc/memory_methods.rb', line 54

def memory_promote(id:)
  { memory: memory_manager.promote_memory(id) }
end

#memory_relax(id:, workspace_root: Dir.pwd) ⇒ Object



58
59
60
# File 'lib/kward/rpc/memory_methods.rb', line 58

def memory_relax(id:, workspace_root: Dir.pwd)
  { memory: memory_manager.relax_core(id, workspace_root: workspace_root) }
end

#memory_statusObject



13
14
15
16
# File 'lib/kward/rpc/memory_methods.rb', line 13

def memory_status
  manager = memory_manager
  { enabled: manager.enabled?, autoSummary: manager.auto_summary_enabled?, paths: manager.paths }
end

#memory_summarize(session_id:) ⇒ Object



75
76
77
78
79
80
# File 'lib/kward/rpc/memory_methods.rb', line 75

def memory_summarize(session_id:)
  rpc_session = fetch_session(session_id)
  records = memory_manager.summarize_conversation(rpc_session.conversation, client: @client)
  persist_memory_state(rpc_session)
  { memories: records }
end

#memory_why(session_id: nil) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/kward/rpc/memory_methods.rb', line 66

def memory_why(session_id: nil)
  if session_id
    rpc_session = fetch_session(session_id)
    return rpc_session.conversation.last_memory_retrieval || memory_manager.explain_retrieval
  end

  memory_manager.explain_retrieval
end