EvoScientist 0.0.1.dev2__py3-none-any.whl → 0.0.1.dev4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,35 +1,80 @@
1
1
  """Middleware configuration for the EvoScientist agent."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  from pathlib import Path
6
+ from typing import TYPE_CHECKING
4
7
 
8
+ from deepagents.backends import FilesystemBackend
5
9
  from deepagents.middleware.skills import SkillsMiddleware
6
10
 
7
11
  from .backends import MergedReadOnlyBackend
12
+ from .memory import EvoMemoryMiddleware
13
+ from .paths import MEMORY_DIR as _DEFAULT_MEMORY_DIR
14
+
15
+ if TYPE_CHECKING:
16
+ from langchain.chat_models import BaseChatModel
8
17
 
9
18
  _DEFAULT_SKILLS_DIR = str(Path(__file__).parent / "skills")
10
19
 
11
20
 
12
21
  def create_skills_middleware(
13
22
  skills_dir: str = _DEFAULT_SKILLS_DIR,
14
- workspace_dir: str = "./workspace/",
23
+ workspace_dir: str = ".",
24
+ user_skills_dir: str | None = None,
15
25
  ) -> SkillsMiddleware:
16
26
  """Create a SkillsMiddleware that loads skills.
17
27
 
18
- Merges user-installed skills (workspace/skills/) with system skills
28
+ Merges user-installed skills (./skills/) with system skills
19
29
  (package built-in). User skills take priority on name conflicts.
20
30
 
21
31
  Args:
22
32
  skills_dir: Path to the system skills directory (package built-in)
23
- workspace_dir: Path to the workspace root (user skills live under workspace/skills/)
33
+ workspace_dir: Path to the project root (user skills live under {workspace_dir}/skills/)
34
+ user_skills_dir: Optional explicit path for user-installed skills. If set,
35
+ this path is used directly instead of {workspace_dir}/skills.
24
36
 
25
37
  Returns:
26
38
  Configured SkillsMiddleware instance
27
39
  """
40
+ if user_skills_dir is None:
41
+ user_skills_dir = str(Path(workspace_dir) / "skills")
28
42
  merged = MergedReadOnlyBackend(
29
- primary_dir=str(Path(workspace_dir) / "skills"),
43
+ primary_dir=user_skills_dir,
30
44
  secondary_dir=skills_dir,
31
45
  )
32
46
  return SkillsMiddleware(
33
47
  backend=merged,
34
48
  sources=["/"],
35
49
  )
50
+
51
+
52
+ def create_memory_middleware(
53
+ memory_dir: str = str(_DEFAULT_MEMORY_DIR),
54
+ extraction_model: BaseChatModel | None = None,
55
+ trigger: tuple[str, int] = ("messages", 20),
56
+ ) -> EvoMemoryMiddleware:
57
+ """Create an EvoMemoryMiddleware for long-term memory.
58
+
59
+ Uses a FilesystemBackend rooted at ``memory_dir`` so that memory
60
+ persists across threads and sessions.
61
+
62
+ Args:
63
+ memory_dir: Path to the shared memory directory (not per-session).
64
+ extraction_model: Chat model for auto-extraction (optional; if None,
65
+ only prompt-guided manual memory updates via edit_file will work).
66
+ trigger: When to auto-extract. Default: every 20 human messages.
67
+
68
+ Returns:
69
+ Configured EvoMemoryMiddleware instance.
70
+ """
71
+ memory_backend = FilesystemBackend(
72
+ root_dir=memory_dir,
73
+ virtual_mode=True,
74
+ )
75
+ return EvoMemoryMiddleware(
76
+ backend=memory_backend,
77
+ memory_path="/MEMORY.md",
78
+ extraction_model=extraction_model,
79
+ trigger=trigger,
80
+ )