Add generic memory gateway v1
This commit is contained in:
2
memory_gateway/skills/__init__.py
Normal file
2
memory_gateway/skills/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
"""Skill skeletons for Memory Gateway processing units."""
|
||||
|
||||
21
memory_gateway/skills/base.py
Normal file
21
memory_gateway/skills/base.py
Normal file
@ -0,0 +1,21 @@
|
||||
"""Shared skill contracts."""
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
|
||||
@dataclass
|
||||
class SkillResult:
|
||||
status: str
|
||||
output: dict[str, Any] = field(default_factory=dict)
|
||||
writes_long_term_memory: bool = False
|
||||
|
||||
|
||||
class MemorySkill:
|
||||
name = "memory_skill"
|
||||
writes_long_term_memory = False
|
||||
|
||||
async def run(self, payload: dict[str, Any]) -> SkillResult:
|
||||
raise NotImplementedError
|
||||
|
||||
9
memory_gateway/skills/classify_memory_skill.py
Normal file
9
memory_gateway/skills/classify_memory_skill.py
Normal file
@ -0,0 +1,9 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class ClassifyMemorySkill(MemorySkill):
|
||||
name = "classify_memory_skill"
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
return SkillResult(status="ok", output={"memory_type": payload.get("memory_type", "fact"), "visibility": payload.get("visibility", "private")})
|
||||
|
||||
10
memory_gateway/skills/commit_memory_skill.py
Normal file
10
memory_gateway/skills/commit_memory_skill.py
Normal file
@ -0,0 +1,10 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class CommitMemorySkill(MemorySkill):
|
||||
name = "commit_memory_skill"
|
||||
writes_long_term_memory = True
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
return SkillResult(status="ok", output={"committed": payload}, writes_long_term_memory=True)
|
||||
|
||||
9
memory_gateway/skills/export_to_obsidian_skill.py
Normal file
9
memory_gateway/skills/export_to_obsidian_skill.py
Normal file
@ -0,0 +1,9 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class ExportToObsidianSkill(MemorySkill):
|
||||
name = "export_to_obsidian_skill"
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
return SkillResult(status="ok", output={"draft_path": payload.get("draft_path")})
|
||||
|
||||
11
memory_gateway/skills/extract_memory_skill.py
Normal file
11
memory_gateway/skills/extract_memory_skill.py
Normal file
@ -0,0 +1,11 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class ExtractMemorySkill(MemorySkill):
|
||||
name = "extract_memory_skill"
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
text = payload.get("content", "")
|
||||
candidates = [{"content": text, "confidence": 0.5}] if text else []
|
||||
return SkillResult(status="ok", output={"candidates": candidates})
|
||||
|
||||
10
memory_gateway/skills/import_from_obsidian_skill.py
Normal file
10
memory_gateway/skills/import_from_obsidian_skill.py
Normal file
@ -0,0 +1,10 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class ImportFromObsidianSkill(MemorySkill):
|
||||
name = "import_from_obsidian_skill"
|
||||
writes_long_term_memory = True
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
return SkillResult(status="ok", output={"imported_path": payload.get("path")}, writes_long_term_memory=True)
|
||||
|
||||
9
memory_gateway/skills/ingest_skill.py
Normal file
9
memory_gateway/skills/ingest_skill.py
Normal file
@ -0,0 +1,9 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class IngestSkill(MemorySkill):
|
||||
name = "ingest_skill"
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
return SkillResult(status="ok", output={"normalized": payload})
|
||||
|
||||
10
memory_gateway/skills/merge_memory_skill.py
Normal file
10
memory_gateway/skills/merge_memory_skill.py
Normal file
@ -0,0 +1,10 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class MergeMemorySkill(MemorySkill):
|
||||
name = "merge_memory_skill"
|
||||
writes_long_term_memory = True
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
return SkillResult(status="ok", output={"merged": payload.get("memory_ids", [])}, writes_long_term_memory=True)
|
||||
|
||||
10
memory_gateway/skills/prune_memory_skill.py
Normal file
10
memory_gateway/skills/prune_memory_skill.py
Normal file
@ -0,0 +1,10 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class PruneMemorySkill(MemorySkill):
|
||||
name = "prune_memory_skill"
|
||||
writes_long_term_memory = True
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
return SkillResult(status="ok", output={"pruned": payload.get("memory_ids", [])}, writes_long_term_memory=True)
|
||||
|
||||
9
memory_gateway/skills/retrieve_context_skill.py
Normal file
9
memory_gateway/skills/retrieve_context_skill.py
Normal file
@ -0,0 +1,9 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class RetrieveContextSkill(MemorySkill):
|
||||
name = "retrieve_context_skill"
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
return SkillResult(status="ok", output={"query": payload.get("query"), "contexts": []})
|
||||
|
||||
10
memory_gateway/skills/summarize_episode_skill.py
Normal file
10
memory_gateway/skills/summarize_episode_skill.py
Normal file
@ -0,0 +1,10 @@
|
||||
from .base import MemorySkill, SkillResult
|
||||
|
||||
|
||||
class SummarizeEpisodeSkill(MemorySkill):
|
||||
name = "summarize_episode_skill"
|
||||
|
||||
async def run(self, payload: dict) -> SkillResult:
|
||||
content = payload.get("content", "")
|
||||
return SkillResult(status="ok", output={"summary": content[:500]})
|
||||
|
||||
Reference in New Issue
Block a user