synth-ai 0.2.4.dev6__py3-none-any.whl → 0.2.4.dev7__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.
Files changed (229) hide show
  1. synth_ai/__init__.py +18 -9
  2. synth_ai/cli/__init__.py +10 -5
  3. synth_ai/cli/balance.py +22 -17
  4. synth_ai/cli/calc.py +2 -3
  5. synth_ai/cli/demo.py +3 -5
  6. synth_ai/cli/legacy_root_backup.py +58 -32
  7. synth_ai/cli/man.py +22 -19
  8. synth_ai/cli/recent.py +9 -8
  9. synth_ai/cli/root.py +58 -13
  10. synth_ai/cli/status.py +13 -6
  11. synth_ai/cli/traces.py +45 -21
  12. synth_ai/cli/watch.py +40 -37
  13. synth_ai/config/base_url.py +1 -3
  14. synth_ai/core/experiment.py +1 -2
  15. synth_ai/environments/__init__.py +2 -6
  16. synth_ai/environments/environment/artifacts/base.py +3 -1
  17. synth_ai/environments/environment/db/sqlite.py +1 -1
  18. synth_ai/environments/environment/registry.py +19 -20
  19. synth_ai/environments/environment/resources/sqlite.py +2 -3
  20. synth_ai/environments/environment/rewards/core.py +3 -2
  21. synth_ai/environments/environment/tools/__init__.py +6 -4
  22. synth_ai/environments/examples/crafter_classic/__init__.py +1 -1
  23. synth_ai/environments/examples/crafter_classic/engine.py +13 -13
  24. synth_ai/environments/examples/crafter_classic/engine_deterministic_patch.py +1 -0
  25. synth_ai/environments/examples/crafter_classic/engine_helpers/action_map.py +2 -1
  26. synth_ai/environments/examples/crafter_classic/engine_helpers/serialization.py +2 -1
  27. synth_ai/environments/examples/crafter_classic/engine_serialization_patch_v3.py +3 -2
  28. synth_ai/environments/examples/crafter_classic/environment.py +16 -15
  29. synth_ai/environments/examples/crafter_classic/taskset.py +2 -2
  30. synth_ai/environments/examples/crafter_classic/trace_hooks_v3.py +2 -3
  31. synth_ai/environments/examples/crafter_classic/world_config_patch_simple.py +2 -1
  32. synth_ai/environments/examples/crafter_custom/crafter/__init__.py +2 -2
  33. synth_ai/environments/examples/crafter_custom/crafter/config.py +2 -2
  34. synth_ai/environments/examples/crafter_custom/crafter/env.py +1 -5
  35. synth_ai/environments/examples/crafter_custom/crafter/objects.py +1 -2
  36. synth_ai/environments/examples/crafter_custom/crafter/worldgen.py +1 -2
  37. synth_ai/environments/examples/crafter_custom/dataset_builder.py +5 -5
  38. synth_ai/environments/examples/crafter_custom/environment.py +13 -13
  39. synth_ai/environments/examples/crafter_custom/run_dataset.py +5 -5
  40. synth_ai/environments/examples/enron/art_helpers/email_search_tools.py +2 -2
  41. synth_ai/environments/examples/enron/art_helpers/local_email_db.py +5 -4
  42. synth_ai/environments/examples/enron/art_helpers/types_enron.py +2 -1
  43. synth_ai/environments/examples/enron/engine.py +18 -14
  44. synth_ai/environments/examples/enron/environment.py +12 -11
  45. synth_ai/environments/examples/enron/taskset.py +7 -7
  46. synth_ai/environments/examples/minigrid/__init__.py +6 -6
  47. synth_ai/environments/examples/minigrid/engine.py +6 -6
  48. synth_ai/environments/examples/minigrid/environment.py +6 -6
  49. synth_ai/environments/examples/minigrid/puzzle_loader.py +3 -2
  50. synth_ai/environments/examples/minigrid/taskset.py +13 -13
  51. synth_ai/environments/examples/nethack/achievements.py +1 -1
  52. synth_ai/environments/examples/nethack/engine.py +8 -7
  53. synth_ai/environments/examples/nethack/environment.py +10 -9
  54. synth_ai/environments/examples/nethack/helpers/__init__.py +8 -9
  55. synth_ai/environments/examples/nethack/helpers/action_mapping.py +1 -1
  56. synth_ai/environments/examples/nethack/helpers/nle_wrapper.py +2 -1
  57. synth_ai/environments/examples/nethack/helpers/observation_utils.py +1 -1
  58. synth_ai/environments/examples/nethack/helpers/recording_wrapper.py +3 -4
  59. synth_ai/environments/examples/nethack/helpers/trajectory_recorder.py +6 -5
  60. synth_ai/environments/examples/nethack/helpers/visualization/replay_viewer.py +5 -5
  61. synth_ai/environments/examples/nethack/helpers/visualization/visualizer.py +7 -6
  62. synth_ai/environments/examples/nethack/taskset.py +5 -5
  63. synth_ai/environments/examples/red/engine.py +9 -8
  64. synth_ai/environments/examples/red/engine_helpers/reward_components.py +2 -1
  65. synth_ai/environments/examples/red/engine_helpers/reward_library/__init__.py +7 -7
  66. synth_ai/environments/examples/red/engine_helpers/reward_library/adaptive_rewards.py +2 -1
  67. synth_ai/environments/examples/red/engine_helpers/reward_library/battle_rewards.py +2 -1
  68. synth_ai/environments/examples/red/engine_helpers/reward_library/composite_rewards.py +2 -1
  69. synth_ai/environments/examples/red/engine_helpers/reward_library/economy_rewards.py +2 -1
  70. synth_ai/environments/examples/red/engine_helpers/reward_library/efficiency_rewards.py +2 -1
  71. synth_ai/environments/examples/red/engine_helpers/reward_library/exploration_rewards.py +2 -1
  72. synth_ai/environments/examples/red/engine_helpers/reward_library/novelty_rewards.py +2 -1
  73. synth_ai/environments/examples/red/engine_helpers/reward_library/pallet_town_rewards.py +2 -1
  74. synth_ai/environments/examples/red/engine_helpers/reward_library/pokemon_rewards.py +2 -1
  75. synth_ai/environments/examples/red/engine_helpers/reward_library/social_rewards.py +2 -1
  76. synth_ai/environments/examples/red/engine_helpers/reward_library/story_rewards.py +2 -1
  77. synth_ai/environments/examples/red/engine_helpers/screen_analysis.py +3 -2
  78. synth_ai/environments/examples/red/engine_helpers/state_extraction.py +2 -1
  79. synth_ai/environments/examples/red/environment.py +18 -15
  80. synth_ai/environments/examples/red/taskset.py +5 -3
  81. synth_ai/environments/examples/sokoban/engine.py +16 -13
  82. synth_ai/environments/examples/sokoban/engine_helpers/room_utils.py +3 -2
  83. synth_ai/environments/examples/sokoban/engine_helpers/vendored/__init__.py +2 -1
  84. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/__init__.py +1 -1
  85. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/boxoban_env.py +7 -5
  86. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/render_utils.py +1 -1
  87. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/room_utils.py +2 -1
  88. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env.py +5 -4
  89. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_fixed_targets.py +3 -2
  90. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_pull.py +2 -1
  91. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_two_player.py +5 -4
  92. synth_ai/environments/examples/sokoban/engine_helpers/vendored/envs/sokoban_env_variations.py +1 -1
  93. synth_ai/environments/examples/sokoban/environment.py +15 -14
  94. synth_ai/environments/examples/sokoban/generate_verified_puzzles.py +5 -3
  95. synth_ai/environments/examples/sokoban/puzzle_loader.py +3 -2
  96. synth_ai/environments/examples/sokoban/taskset.py +13 -10
  97. synth_ai/environments/examples/tictactoe/engine.py +6 -6
  98. synth_ai/environments/examples/tictactoe/environment.py +8 -7
  99. synth_ai/environments/examples/tictactoe/taskset.py +6 -5
  100. synth_ai/environments/examples/verilog/engine.py +4 -3
  101. synth_ai/environments/examples/verilog/environment.py +11 -10
  102. synth_ai/environments/examples/verilog/taskset.py +14 -12
  103. synth_ai/environments/examples/wordle/__init__.py +5 -5
  104. synth_ai/environments/examples/wordle/engine.py +32 -25
  105. synth_ai/environments/examples/wordle/environment.py +21 -16
  106. synth_ai/environments/examples/wordle/helpers/generate_instances_wordfreq.py +6 -6
  107. synth_ai/environments/examples/wordle/taskset.py +20 -12
  108. synth_ai/environments/reproducibility/core.py +1 -1
  109. synth_ai/environments/reproducibility/tree.py +21 -21
  110. synth_ai/environments/service/app.py +3 -2
  111. synth_ai/environments/service/core_routes.py +104 -110
  112. synth_ai/environments/service/external_registry.py +1 -2
  113. synth_ai/environments/service/registry.py +1 -1
  114. synth_ai/environments/stateful/core.py +1 -2
  115. synth_ai/environments/stateful/engine.py +1 -1
  116. synth_ai/environments/tasks/api.py +4 -4
  117. synth_ai/environments/tasks/core.py +14 -12
  118. synth_ai/environments/tasks/filters.py +6 -4
  119. synth_ai/environments/tasks/utils.py +13 -11
  120. synth_ai/evals/base.py +2 -3
  121. synth_ai/experimental/synth_oss.py +4 -4
  122. synth_ai/learning/gateway.py +1 -3
  123. synth_ai/learning/prompts/banking77_injection_eval.py +15 -10
  124. synth_ai/learning/prompts/hello_world_in_context_injection_ex.py +26 -14
  125. synth_ai/learning/prompts/mipro.py +61 -52
  126. synth_ai/learning/prompts/random_search.py +42 -43
  127. synth_ai/learning/prompts/run_mipro_banking77.py +32 -20
  128. synth_ai/learning/prompts/run_random_search_banking77.py +71 -52
  129. synth_ai/lm/__init__.py +5 -5
  130. synth_ai/lm/caching/ephemeral.py +9 -9
  131. synth_ai/lm/caching/handler.py +20 -20
  132. synth_ai/lm/caching/persistent.py +10 -10
  133. synth_ai/lm/config.py +3 -3
  134. synth_ai/lm/constants.py +7 -7
  135. synth_ai/lm/core/all.py +17 -3
  136. synth_ai/lm/core/exceptions.py +0 -2
  137. synth_ai/lm/core/main.py +26 -41
  138. synth_ai/lm/core/main_v3.py +20 -10
  139. synth_ai/lm/core/vendor_clients.py +18 -17
  140. synth_ai/lm/injection.py +7 -8
  141. synth_ai/lm/overrides.py +21 -19
  142. synth_ai/lm/provider_support/__init__.py +1 -1
  143. synth_ai/lm/provider_support/anthropic.py +15 -15
  144. synth_ai/lm/provider_support/openai.py +23 -21
  145. synth_ai/lm/structured_outputs/handler.py +34 -32
  146. synth_ai/lm/structured_outputs/inject.py +24 -27
  147. synth_ai/lm/structured_outputs/rehabilitate.py +19 -15
  148. synth_ai/lm/tools/base.py +17 -16
  149. synth_ai/lm/unified_interface.py +17 -18
  150. synth_ai/lm/vendors/base.py +20 -18
  151. synth_ai/lm/vendors/core/anthropic_api.py +36 -27
  152. synth_ai/lm/vendors/core/gemini_api.py +31 -36
  153. synth_ai/lm/vendors/core/mistral_api.py +19 -19
  154. synth_ai/lm/vendors/core/openai_api.py +11 -10
  155. synth_ai/lm/vendors/openai_standard.py +113 -87
  156. synth_ai/lm/vendors/openai_standard_responses.py +74 -61
  157. synth_ai/lm/vendors/retries.py +9 -1
  158. synth_ai/lm/vendors/supported/custom_endpoint.py +26 -26
  159. synth_ai/lm/vendors/supported/deepseek.py +10 -10
  160. synth_ai/lm/vendors/supported/grok.py +8 -8
  161. synth_ai/lm/vendors/supported/ollama.py +2 -1
  162. synth_ai/lm/vendors/supported/openrouter.py +11 -9
  163. synth_ai/lm/vendors/synth_client.py +69 -63
  164. synth_ai/lm/warmup.py +8 -7
  165. synth_ai/tracing/__init__.py +22 -10
  166. synth_ai/tracing_v1/__init__.py +22 -20
  167. synth_ai/tracing_v3/__init__.py +7 -7
  168. synth_ai/tracing_v3/abstractions.py +56 -52
  169. synth_ai/tracing_v3/config.py +4 -2
  170. synth_ai/tracing_v3/db_config.py +6 -8
  171. synth_ai/tracing_v3/decorators.py +29 -30
  172. synth_ai/tracing_v3/examples/basic_usage.py +12 -12
  173. synth_ai/tracing_v3/hooks.py +21 -21
  174. synth_ai/tracing_v3/llm_call_record_helpers.py +85 -98
  175. synth_ai/tracing_v3/lm_call_record_abstractions.py +2 -4
  176. synth_ai/tracing_v3/migration_helper.py +3 -5
  177. synth_ai/tracing_v3/replica_sync.py +30 -32
  178. synth_ai/tracing_v3/session_tracer.py +35 -29
  179. synth_ai/tracing_v3/storage/__init__.py +1 -1
  180. synth_ai/tracing_v3/storage/base.py +8 -7
  181. synth_ai/tracing_v3/storage/config.py +4 -4
  182. synth_ai/tracing_v3/storage/factory.py +4 -4
  183. synth_ai/tracing_v3/storage/utils.py +9 -9
  184. synth_ai/tracing_v3/turso/__init__.py +3 -3
  185. synth_ai/tracing_v3/turso/daemon.py +9 -9
  186. synth_ai/tracing_v3/turso/manager.py +60 -48
  187. synth_ai/tracing_v3/turso/models.py +24 -19
  188. synth_ai/tracing_v3/utils.py +5 -5
  189. synth_ai/tui/__main__.py +1 -1
  190. synth_ai/tui/cli/query_experiments.py +2 -3
  191. synth_ai/tui/cli/query_experiments_v3.py +2 -3
  192. synth_ai/tui/dashboard.py +97 -86
  193. synth_ai/v0/tracing/abstractions.py +28 -28
  194. synth_ai/v0/tracing/base_client.py +9 -9
  195. synth_ai/v0/tracing/client_manager.py +7 -7
  196. synth_ai/v0/tracing/config.py +7 -7
  197. synth_ai/v0/tracing/context.py +6 -6
  198. synth_ai/v0/tracing/decorators.py +6 -5
  199. synth_ai/v0/tracing/events/manage.py +1 -1
  200. synth_ai/v0/tracing/events/store.py +5 -4
  201. synth_ai/v0/tracing/immediate_client.py +4 -5
  202. synth_ai/v0/tracing/local.py +3 -3
  203. synth_ai/v0/tracing/log_client_base.py +4 -5
  204. synth_ai/v0/tracing/retry_queue.py +5 -6
  205. synth_ai/v0/tracing/trackers.py +25 -25
  206. synth_ai/v0/tracing/upload.py +6 -0
  207. synth_ai/v0/tracing_v1/__init__.py +1 -1
  208. synth_ai/v0/tracing_v1/abstractions.py +28 -28
  209. synth_ai/v0/tracing_v1/base_client.py +9 -9
  210. synth_ai/v0/tracing_v1/client_manager.py +7 -7
  211. synth_ai/v0/tracing_v1/config.py +7 -7
  212. synth_ai/v0/tracing_v1/context.py +6 -6
  213. synth_ai/v0/tracing_v1/decorators.py +7 -6
  214. synth_ai/v0/tracing_v1/events/manage.py +1 -1
  215. synth_ai/v0/tracing_v1/events/store.py +5 -4
  216. synth_ai/v0/tracing_v1/immediate_client.py +4 -5
  217. synth_ai/v0/tracing_v1/local.py +3 -3
  218. synth_ai/v0/tracing_v1/log_client_base.py +4 -5
  219. synth_ai/v0/tracing_v1/retry_queue.py +5 -6
  220. synth_ai/v0/tracing_v1/trackers.py +25 -25
  221. synth_ai/v0/tracing_v1/upload.py +25 -24
  222. synth_ai/zyk/__init__.py +1 -0
  223. {synth_ai-0.2.4.dev6.dist-info → synth_ai-0.2.4.dev7.dist-info}/METADATA +1 -11
  224. synth_ai-0.2.4.dev7.dist-info/RECORD +299 -0
  225. synth_ai-0.2.4.dev6.dist-info/RECORD +0 -299
  226. {synth_ai-0.2.4.dev6.dist-info → synth_ai-0.2.4.dev7.dist-info}/WHEEL +0 -0
  227. {synth_ai-0.2.4.dev6.dist-info → synth_ai-0.2.4.dev7.dist-info}/entry_points.txt +0 -0
  228. {synth_ai-0.2.4.dev6.dist-info → synth_ai-0.2.4.dev7.dist-info}/licenses/LICENSE +0 -0
  229. {synth_ai-0.2.4.dev6.dist-info → synth_ai-0.2.4.dev7.dist-info}/top_level.txt +0 -0
@@ -27,19 +27,18 @@ Example:
27
27
  >>> env_instance = env_cls(task_config)
28
28
  """
29
29
 
30
- from typing import Type, Dict, List
31
- import logging
32
30
  import importlib.metadata
31
+ import logging
33
32
 
34
33
  from synth_ai.environments.stateful.core import StatefulEnvironment
35
34
 
36
35
  logger = logging.getLogger(__name__)
37
36
 
38
37
  # Global registry for environment types
39
- ENV_REGISTRY: Dict[str, Type[StatefulEnvironment]] = {}
38
+ ENV_REGISTRY: dict[str, type[StatefulEnvironment]] = {}
40
39
 
41
40
 
42
- def register_environment(name: str, cls: Type[StatefulEnvironment]) -> None:
41
+ def register_environment(name: str, cls: type[StatefulEnvironment]) -> None:
43
42
  """
44
43
  Register an environment class under a unique name.
45
44
 
@@ -78,7 +77,7 @@ def register_environment(name: str, cls: Type[StatefulEnvironment]) -> None:
78
77
  ENV_REGISTRY[name] = cls
79
78
 
80
79
 
81
- def get_environment_cls(env_type: str) -> Type[StatefulEnvironment]:
80
+ def get_environment_cls(env_type: str) -> type[StatefulEnvironment]:
82
81
  """
83
82
  Retrieve a registered environment class by name.
84
83
 
@@ -122,10 +121,10 @@ def get_environment_cls(env_type: str) -> Type[StatefulEnvironment]:
122
121
  available_types = list(ENV_REGISTRY.keys())
123
122
  raise ValueError(
124
123
  f"Unsupported environment type: '{env_type}'. Available types: {available_types}"
125
- )
124
+ ) from None
126
125
 
127
126
 
128
- def list_supported_env_types() -> List[str]:
127
+ def list_supported_env_types() -> list[str]:
129
128
  """
130
129
  List all registered environment type names.
131
130
 
@@ -165,36 +164,36 @@ def list_supported_env_types() -> List[str]:
165
164
  This function returns a copy of the environment names, so modifying
166
165
  the returned list will not affect the registry.
167
166
  """
168
- return sorted(list(ENV_REGISTRY.keys()))
167
+ return sorted(ENV_REGISTRY.keys())
169
168
 
170
169
 
171
170
  def discover_entry_point_environments() -> None:
172
171
  """
173
172
  Discover and register environments from entry points.
174
-
173
+
175
174
  This function scans for environments registered via setuptools entry points
176
175
  under the group 'synth_ai.environments'. This allows third-party packages
177
176
  to register environments by declaring them in their pyproject.toml:
178
-
177
+
179
178
  [project.entry-points."synth_ai.environments"]
180
179
  my_env = "my_package.my_env:MyEnvironment"
181
180
  another_env = "my_package.other:AnotherEnv"
182
-
181
+
183
182
  The function will automatically import and register all discovered environments.
184
183
  """
185
184
  try:
186
185
  entry_points = importlib.metadata.entry_points()
187
- if hasattr(entry_points, 'select'):
186
+ if hasattr(entry_points, "select"):
188
187
  # Python 3.10+
189
- env_entry_points = entry_points.select(group='synth_ai.environments')
188
+ env_entry_points = entry_points.select(group="synth_ai.environments")
190
189
  else:
191
190
  # Python 3.9 and below
192
- env_entry_points = entry_points.get('synth_ai.environments', [])
193
-
191
+ env_entry_points = entry_points.get("synth_ai.environments", [])
192
+
194
193
  for entry_point in env_entry_points:
195
194
  try:
196
195
  env_cls = entry_point.load()
197
-
196
+
198
197
  # Validate that it's a StatefulEnvironment subclass
199
198
  if not issubclass(env_cls, StatefulEnvironment):
200
199
  logger.warning(
@@ -202,10 +201,10 @@ def discover_entry_point_environments() -> None:
202
201
  f"is not a StatefulEnvironment subclass. Skipping."
203
202
  )
204
203
  continue
205
-
204
+
206
205
  register_environment(entry_point.name, env_cls)
207
206
  logger.info(f"Registered environment '{entry_point.name}' from entry point")
208
-
207
+
209
208
  except Exception as e:
210
209
  logger.error(
211
210
  f"Failed to load environment entry point '{entry_point.name}' "
@@ -218,11 +217,11 @@ def discover_entry_point_environments() -> None:
218
217
  def auto_discover_environments() -> None:
219
218
  """
220
219
  Automatically discover and register environments from multiple sources.
221
-
220
+
222
221
  This function combines multiple discovery mechanisms:
223
222
  1. Entry points (setuptools plugins)
224
223
  2. Could be extended with more discovery methods in the future
225
-
224
+
226
225
  This should be called once at application startup to populate the registry
227
226
  with all available environments.
228
227
  """
@@ -1,8 +1,7 @@
1
+ import contextlib
1
2
  import sqlite3
2
3
  import threading
3
- import contextlib
4
4
  from pathlib import Path
5
- from typing import Optional
6
5
 
7
6
 
8
7
  class SQLiteManager:
@@ -36,7 +35,7 @@ class SQLiteManager:
36
35
  self._conn.close()
37
36
  self._conn = None
38
37
 
39
- def reset(self, new_db_path: Optional[Path] = None):
38
+ def reset(self, new_db_path: Path | None = None):
40
39
  """Resets the connection, optionally switching to a new database path for a fresh session."""
41
40
  with self._lock:
42
41
  if self._conn:
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
+
2
3
  from abc import ABC, abstractmethod
3
- from typing import List, Any
4
+ from typing import Any
4
5
 
5
6
 
6
7
  class RewardComponent(ABC):
@@ -17,7 +18,7 @@ class RewardComponent(ABC):
17
18
  class RewardStack:
18
19
  """Aggregates multiple RewardComponent instances to compute a total reward."""
19
20
 
20
- def __init__(self, components: List[RewardComponent]):
21
+ def __init__(self, components: list[RewardComponent]):
21
22
  self.components = components
22
23
 
23
24
  async def step_reward(self, state: Any, action: Any) -> float:
@@ -1,7 +1,9 @@
1
1
  from __future__ import annotations
2
+
2
3
  from abc import ABC, abstractmethod
4
+ from typing import Any
5
+
3
6
  from pydantic import BaseModel, Field
4
- from typing import Any, Dict, Type
5
7
 
6
8
 
7
9
  class EnvToolCall(BaseModel):
@@ -38,7 +40,7 @@ class EnvToolCall(BaseModel):
38
40
  """
39
41
 
40
42
  tool: str
41
- args: Dict[str, Any] = Field(default_factory=dict)
43
+ args: dict[str, Any] = Field(default_factory=dict)
42
44
 
43
45
 
44
46
  class ToolResult(BaseModel):
@@ -123,8 +125,8 @@ class AbstractTool(ABC):
123
125
  """
124
126
 
125
127
  name: str
126
- call_schema: Type[BaseModel]
127
- result_schema: Type[BaseModel] = ToolResult
128
+ call_schema: type[BaseModel]
129
+ result_schema: type[BaseModel] = ToolResult
128
130
 
129
131
  @abstractmethod
130
132
  async def __call__(self, call: EnvToolCall) -> ToolResult:
@@ -1,6 +1,6 @@
1
1
  from .config_logging import configure_logging
2
- from .environment import CrafterClassicEnvironment
3
2
  from .engine import CrafterEngine
3
+ from .environment import CrafterClassicEnvironment
4
4
 
5
5
  # Configure logging when crafter_classic module is imported
6
6
  configure_logging()
@@ -4,32 +4,32 @@ This file follows the same structure as the SokobanEngine shown earlier.
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
- # Import logging configuration first to suppress JAX debug messages
8
- from .config_logging import safe_compare
9
-
10
- # Import patches
11
- from . import engine_deterministic_patch # Ensures deterministic behavior
12
- from . import engine_serialization_patch_v3 as engine_serialization_patch # Adds save/load methods
13
- from . import world_config_patch_simple as world_config_patch # Adds configurable world generation
14
-
7
+ import copy
8
+ import dataclasses
15
9
  import logging
16
10
  import time
17
11
  from dataclasses import dataclass
18
12
  from typing import Any, Dict, Optional, Tuple, Union
19
13
 
20
- import numpy as np
21
14
  import crafter # type: ignore
22
- import copy
23
- import dataclasses
15
+ import numpy as np
24
16
 
17
+ from synth_ai.environments.environment.rewards.core import RewardComponent, RewardStack # Added
25
18
  from synth_ai.environments.environment.shared_engine import (
26
19
  GetObservationCallable,
27
20
  InternalObservation,
28
21
  )
22
+ from synth_ai.environments.reproducibility.core import IReproducibleEngine
29
23
  from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
30
24
  from synth_ai.environments.tasks.core import TaskInstance
31
- from synth_ai.environments.reproducibility.core import IReproducibleEngine
32
- from synth_ai.environments.environment.rewards.core import RewardStack, RewardComponent # Added
25
+
26
+ # Import patches
27
+ from . import engine_deterministic_patch # Ensures deterministic behavior
28
+ from . import engine_serialization_patch_v3 as engine_serialization_patch # Adds save/load methods
29
+ from . import world_config_patch_simple as world_config_patch # Adds configurable world generation
30
+
31
+ # Import logging configuration first to suppress JAX debug messages
32
+ from .config_logging import safe_compare
33
33
 
34
34
  # Local helper imports (must exist relative to this file)
35
35
  from .engine_helpers.action_map import CRAFTER_ACTION_MAP # action‑name → int
@@ -6,6 +6,7 @@ the hash-based set-iteration nondeterminism that caused the drift.
6
6
  """
7
7
 
8
8
  import collections
9
+
9
10
  import crafter
10
11
 
11
12
  print("[PATCH] Attempting to apply Crafter deterministic patch...")
@@ -1,5 +1,6 @@
1
- import crafter.constants as C
2
1
  from typing import Dict
3
2
 
3
+ import crafter.constants as C
4
+
4
5
  # Map each action name to its corresponding index in the crafter package
5
6
  CRAFTER_ACTION_MAP: Dict[str, int] = {action_name: idx for idx, action_name in enumerate(C.actions)}
@@ -1,7 +1,8 @@
1
1
  import importlib
2
- import numpy as np
3
2
  from typing import Any, Dict
4
3
 
4
+ import numpy as np
5
+
5
6
  # Minimal attributes to serialize per object type
6
7
  BASIC_ATTRS: Dict[str, list] = {
7
8
  "Player": [
@@ -5,10 +5,11 @@ This version handles player references for Zombie and Skeleton objects.
5
5
 
6
6
  import collections
7
7
  import pickle
8
- import numpy as np
8
+ from typing import Any, Dict, Optional, Set
9
+
9
10
  import crafter
11
+ import numpy as np
10
12
  from crafter import objects
11
- from typing import Dict, Any, Optional, Set
12
13
 
13
14
  print("[PATCH] Attempting to apply Crafter serialization patch v3...")
14
15
 
@@ -2,13 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List, Optional, Any, Dict, Union
6
5
  import dataclasses
7
6
  import logging
8
7
  import time
9
-
10
- # Import logging configuration to suppress JAX debug messages
11
- from .config_logging import safe_compare
8
+ from typing import Any, Dict, List, Optional, Union
12
9
 
13
10
  # Import tracing abstractions
14
11
  from synth_ai.tracing_v3.abstractions import (
@@ -17,29 +14,33 @@ from synth_ai.tracing_v3.abstractions import (
17
14
  TimeRecord,
18
15
  )
19
16
 
17
+ # Import logging configuration to suppress JAX debug messages
18
+ from .config_logging import safe_compare
19
+
20
20
  logger = logging.getLogger(__name__)
21
21
 
22
- from synth_ai.environments.examples.crafter_classic.engine import (
23
- CrafterEngine,
24
- CrafterPrivateState,
25
- CrafterPublicState,
26
- CrafterEngineSnapshot,
27
- )
28
- from synth_ai.environments.examples.crafter_classic.taskset import CrafterTaskInstance
22
+ from pydantic import BaseModel, Field
23
+
29
24
  from synth_ai.environments.environment.shared_engine import (
30
25
  GetObservationCallable,
31
26
  InternalObservation,
32
27
  )
33
- from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
34
- from synth_ai.environments.stateful.core import StatefulEnvironment
35
28
  from synth_ai.environments.environment.tools import (
29
+ TOOL_REGISTRY,
36
30
  AbstractTool,
37
31
  EnvToolCall,
38
32
  ToolResult,
39
- TOOL_REGISTRY,
40
33
  register_tool,
41
34
  )
42
- from pydantic import BaseModel, Field
35
+ from synth_ai.environments.examples.crafter_classic.engine import (
36
+ CrafterEngine,
37
+ CrafterEngineSnapshot,
38
+ CrafterPrivateState,
39
+ CrafterPublicState,
40
+ )
41
+ from synth_ai.environments.examples.crafter_classic.taskset import CrafterTaskInstance
42
+ from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
43
+ from synth_ai.environments.stateful.core import StatefulEnvironment
43
44
 
44
45
 
45
46
  # --- Tool Definition ---
@@ -6,12 +6,12 @@ from __future__ import annotations
6
6
 
7
7
  import asyncio
8
8
  import random
9
- from dataclasses import dataclass, asdict, fields
9
+ from dataclasses import asdict, dataclass, fields
10
10
  from typing import Dict, List
11
11
  from uuid import UUID, uuid4
12
12
 
13
- import numpy as np
14
13
  import crafter
14
+ import numpy as np
15
15
  from crafter import objects
16
16
 
17
17
  from synth_ai.environments.tasks.core import (
@@ -3,12 +3,11 @@ Trace hooks for Crafter Classic environment - v3 version.
3
3
  Updated to use the v3 tracing architecture with async support.
4
4
  """
5
5
 
6
- from typing import Any, Optional, Dict, Set
7
6
  from datetime import datetime
7
+ from typing import Any, Dict, Optional, Set
8
8
 
9
- from synth_ai.tracing_v3.hooks import HookManager
10
9
  from synth_ai.tracing_v3.abstractions import BaseEvent, EnvironmentEvent
11
-
10
+ from synth_ai.tracing_v3.hooks import HookManager
12
11
 
13
12
  # Achievement categorization by difficulty
14
13
  EASY_ACHIEVEMENTS = {
@@ -5,7 +5,8 @@ This version modifies generation parameters rather than rewriting functions.
5
5
 
6
6
  import json
7
7
  import os
8
- from typing import Dict, Any, Optional
8
+ from typing import Any, Dict, Optional
9
+
9
10
  import crafter
10
11
 
11
12
  print("[PATCH] Attempting to apply simplified Crafter world configuration patch...")
@@ -1,7 +1,7 @@
1
+ from . import constants
2
+ from .config import PRESETS, WorldGenConfig
1
3
  from .env import Env
2
4
  from .recorder import Recorder
3
- from .config import WorldGenConfig, PRESETS
4
- from . import constants
5
5
 
6
6
  # Note: We don't register with gym since this is a custom version
7
7
  # Users should import directly from this module
@@ -4,8 +4,8 @@ Configuration system for customizable Crafter environment.
4
4
 
5
5
  import json
6
6
  import os
7
- from dataclasses import dataclass, field, asdict
8
- from typing import Dict, Any, Optional
7
+ from dataclasses import asdict, dataclass, field
8
+ from typing import Any, Dict, Optional
9
9
 
10
10
 
11
11
  @dataclass
@@ -2,13 +2,9 @@ import collections
2
2
 
3
3
  import numpy as np
4
4
 
5
- from . import constants
6
- from . import engine
7
- from . import objects
8
- from . import worldgen
5
+ from . import constants, engine, objects, worldgen
9
6
  from .config import WorldGenConfig
10
7
 
11
-
12
8
  # Gym is an optional dependency.
13
9
  try:
14
10
  import gym
@@ -1,7 +1,6 @@
1
1
  import numpy as np
2
2
 
3
- from . import constants
4
- from . import engine
3
+ from . import constants, engine
5
4
 
6
5
 
7
6
  class Object:
@@ -3,8 +3,7 @@ import functools
3
3
  import numpy as np
4
4
  import opensimplex
5
5
 
6
- from . import constants
7
- from . import objects
6
+ from . import constants, objects
8
7
  from .config import WorldGenConfig
9
8
 
10
9
 
@@ -3,14 +3,14 @@
3
3
  Dataset builder for Crafter Custom Environments
4
4
  """
5
5
 
6
+ import gzip
6
7
  import json
8
+ import pickle
9
+ import random
7
10
  import uuid
8
- from dataclasses import dataclass, asdict
11
+ from dataclasses import asdict, dataclass
9
12
  from pathlib import Path
10
- from typing import Any, Dict, Optional, List, Set
11
- import random
12
- import gzip
13
- import pickle
13
+ from typing import Any, Dict, List, Optional, Set
14
14
 
15
15
 
16
16
  @dataclass
@@ -2,10 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List, Optional, Any, Dict, Union
6
5
  import dataclasses
7
6
  import logging
8
7
  import time
8
+ from typing import Any, Dict, List, Optional, Union
9
9
 
10
10
  # Import logging configuration to suppress JAX debug messages
11
11
  from synth_ai.environments.examples.crafter_classic.config_logging import safe_compare
@@ -20,28 +20,25 @@ from synth_ai.tracing_v3.abstractions import (
20
20
  logger = logging.getLogger(__name__)
21
21
 
22
22
  # Import the base Crafter components
23
- from synth_ai.environments.examples.crafter_classic.engine import (
24
- CrafterEngine,
25
- CrafterPrivateState,
26
- CrafterPublicState,
27
- CrafterEngineSnapshot,
28
- )
29
- from synth_ai.environments.examples.crafter_classic.taskset import CrafterTaskInstance
23
+ from pydantic import BaseModel, Field
24
+
30
25
  from synth_ai.environments.environment.shared_engine import (
31
26
  GetObservationCallable,
32
27
  InternalObservation,
33
28
  )
34
- from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
35
- from synth_ai.environments.stateful.core import StatefulEnvironment
36
29
  from synth_ai.environments.environment.tools import (
30
+ TOOL_REGISTRY,
37
31
  AbstractTool,
38
32
  EnvToolCall,
39
33
  ToolResult,
40
- TOOL_REGISTRY,
41
34
  register_tool,
42
35
  )
43
- from pydantic import BaseModel, Field
44
-
36
+ from synth_ai.environments.examples.crafter_classic.engine import (
37
+ CrafterEngine,
38
+ CrafterEngineSnapshot,
39
+ CrafterPrivateState,
40
+ CrafterPublicState,
41
+ )
45
42
 
46
43
  # Use the same tool and observation classes as CrafterClassic
47
44
  from synth_ai.environments.examples.crafter_classic.environment import (
@@ -49,6 +46,9 @@ from synth_ai.environments.examples.crafter_classic.environment import (
49
46
  CrafterInteractTool,
50
47
  SynthCrafterObservationCallable,
51
48
  )
49
+ from synth_ai.environments.examples.crafter_classic.taskset import CrafterTaskInstance
50
+ from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
51
+ from synth_ai.environments.stateful.core import StatefulEnvironment
52
52
 
53
53
 
54
54
  class CrafterCustomEnvironment(StatefulEnvironment, ReproducibleEnvironment[CrafterEngine]):
@@ -3,14 +3,14 @@
3
3
  Run script for Crafter dataset instances
4
4
  """
5
5
 
6
- import json
7
6
  import argparse
8
- import random
9
- from pathlib import Path
10
- from typing import List, Optional, Dict, Any
11
- import uuid
7
+ import json
12
8
  import os
9
+ import random
13
10
  import sys
11
+ import uuid
12
+ from pathlib import Path
13
+ from typing import Any, Dict, List, Optional
14
14
 
15
15
  sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
16
16
 
@@ -1,8 +1,8 @@
1
- import sqlite3
2
1
  import logging
2
+ import sqlite3
3
3
  import textwrap
4
- from typing import List, Optional
5
4
  from dataclasses import dataclass
5
+ from typing import List, Optional
6
6
 
7
7
  from synth_ai.environments.environment.db.sqlite import SQLiteManager
8
8
  from synth_ai.environments.examples.enron.art_helpers.types_enron import Email
@@ -1,10 +1,11 @@
1
- import sqlite3
2
- import os
3
1
  import logging
4
- from datasets import load_dataset, Dataset, Features, Value, Sequence
5
- from tqdm import tqdm
2
+ import os
3
+ import sqlite3
6
4
  from datetime import datetime
7
5
 
6
+ from datasets import Dataset, Features, Sequence, Value, load_dataset
7
+ from tqdm import tqdm
8
+
8
9
  # Resolve paths relative to this file so it works regardless of the current working directory
9
10
  BASE_DIR = os.path.dirname(os.path.abspath(__file__))
10
11
  # Database will live in "../data/enron_emails.db" relative to project root
@@ -1,6 +1,7 @@
1
- from pydantic import BaseModel
2
1
  from typing import List, Optional
3
2
 
3
+ from pydantic import BaseModel
4
+
4
5
 
5
6
  class SyntheticQuery(BaseModel):
6
7
  id: int
@@ -1,28 +1,32 @@
1
1
  # engine.py
2
2
  from __future__ import annotations
3
- from dataclasses import dataclass, asdict
4
- from typing import Any, Dict, Tuple, Optional, List
5
- from pydantic import BaseModel
3
+
4
+ from dataclasses import asdict, dataclass
6
5
  from pathlib import Path
6
+ from typing import Any, Dict, List, Optional, Tuple
7
7
 
8
- from synth_ai.environments.examples.enron.art_helpers.types_enron import Email
8
+ from pydantic import BaseModel
9
+ from synth_ai.environments.environment.db.sqlite import SQLiteManager
10
+ from synth_ai.environments.environment.rewards.core import RewardComponent, RewardStack
9
11
  from synth_ai.environments.examples.enron.art_helpers.email_search_tools import (
10
- search_emails as helper_search_emails,
11
- read_email as helper_read_email,
12
12
  SearchResult,
13
13
  )
14
-
15
- # SQLite-backed helpers
16
- from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
17
- from synth_ai.environments.examples.enron.taskset import EnronTaskInstance
18
- from synth_ai.zyk import LM # Import LM class
19
-
20
- from synth_ai.environments.environment.db.sqlite import SQLiteManager
21
- from synth_ai.environments.environment.rewards.core import RewardStack, RewardComponent
14
+ from synth_ai.environments.examples.enron.art_helpers.email_search_tools import (
15
+ read_email as helper_read_email,
16
+ )
17
+ from synth_ai.environments.examples.enron.art_helpers.email_search_tools import (
18
+ search_emails as helper_search_emails,
19
+ )
22
20
  from synth_ai.environments.examples.enron.art_helpers.local_email_db import (
23
21
  DEFAULT_DB_PATH,
24
22
  generate_database,
25
23
  )
24
+ from synth_ai.environments.examples.enron.art_helpers.types_enron import Email
25
+ from synth_ai.environments.examples.enron.taskset import EnronTaskInstance
26
+
27
+ # SQLite-backed helpers
28
+ from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
29
+ from synth_ai.zyk import LM # Import LM class
26
30
 
27
31
  # --------------------------------------------------------------------------- actions
28
32
  ACTION_SEARCH = "search"