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
@@ -1,26 +1,27 @@
1
1
  # environment.py
2
2
  from __future__ import annotations
3
- from typing import List, Optional, Dict, Any, Union
4
- from pydantic import BaseModel, Field
5
3
 
4
+ from typing import Any, Dict, List, Optional, Union
5
+
6
+ from pydantic import BaseModel, Field
7
+ from synth_ai.environments.environment.shared_engine import (
8
+ GetObservationCallable,
9
+ InternalObservation,
10
+ )
6
11
  from synth_ai.environments.environment.tools import (
12
+ TOOL_REGISTRY,
7
13
  EnvToolCall,
8
14
  ToolResult,
9
- TOOL_REGISTRY,
10
15
  register_tool,
11
16
  )
12
- from synth_ai.environments.environment.shared_engine import (
13
- GetObservationCallable,
14
- InternalObservation,
15
- )
16
- from synth_ai.environments.stateful.core import StatefulEnvironment
17
17
  from synth_ai.environments.examples.enron.engine import (
18
- EnronEngine,
19
- ACTION_SEARCH,
20
- ACTION_READ,
21
18
  ACTION_ANSWER,
19
+ ACTION_READ,
20
+ ACTION_SEARCH,
21
+ EnronEngine,
22
22
  )
23
23
  from synth_ai.environments.examples.enron.taskset import EnronTaskInstance
24
+ from synth_ai.environments.stateful.core import StatefulEnvironment
24
25
 
25
26
 
26
27
  # -------- pydantic schemas (used by agent / LLM function calls)
@@ -1,20 +1,20 @@
1
1
  # taskset.py
2
2
  from __future__ import annotations
3
+
3
4
  import asyncio
4
- from uuid import uuid4
5
5
  import os
6
+ from dataclasses import asdict, dataclass
7
+ from uuid import uuid4
6
8
 
7
9
  from datasets import load_dataset
8
- from dataclasses import dataclass, asdict
9
-
10
10
  from synth_ai.environments.tasks.core import (
11
+ Impetus,
12
+ Intent,
13
+ SplitInfo,
11
14
  Task,
12
15
  TaskInstance,
13
- TaskInstanceSet,
14
16
  TaskInstanceMetadata,
15
- SplitInfo,
16
- Impetus,
17
- Intent,
17
+ TaskInstanceSet,
18
18
  )
19
19
 
20
20
  enron_task = Task(
@@ -5,23 +5,23 @@ with full state management, tool-based interaction, and task generation.
5
5
  """
6
6
 
7
7
  from synth_ai.environments.examples.minigrid.engine import (
8
+ MiniGridCheckpointObservationCallable,
8
9
  MiniGridEngine,
9
- MiniGridPublicState,
10
- MiniGridPrivateState,
11
10
  MiniGridGoalReachedComponent,
12
- MiniGridStepPenaltyComponent,
13
11
  MiniGridObservationCallable,
14
- MiniGridCheckpointObservationCallable,
12
+ MiniGridPrivateState,
13
+ MiniGridPublicState,
14
+ MiniGridStepPenaltyComponent,
15
15
  )
16
16
  from synth_ai.environments.examples.minigrid.environment import (
17
+ MiniGridActionInput,
17
18
  MiniGridEnvironment,
18
19
  MiniGridInteractTool,
19
- MiniGridActionInput,
20
20
  )
21
21
  from synth_ai.environments.examples.minigrid.taskset import (
22
+ DEFAULT_MINIGRID_TASK,
22
23
  MiniGridTaskInstance,
23
24
  MiniGridTaskInstanceMetadata,
24
- DEFAULT_MINIGRID_TASK,
25
25
  create_minigrid_taskset,
26
26
  taskset,
27
27
  )
@@ -8,25 +8,25 @@ from __future__ import annotations
8
8
 
9
9
  import json
10
10
  from dataclasses import dataclass, field
11
- from typing import Any, Dict, Optional, Tuple, Union, List
11
+ from typing import Any, Dict, List, Optional, Tuple, Union
12
12
 
13
13
  import gymnasium as gym
14
14
  import numpy as np
15
- from minigrid.core.constants import OBJECT_TO_IDX, COLOR_TO_IDX, STATE_TO_IDX
15
+ from minigrid.core.constants import COLOR_TO_IDX, OBJECT_TO_IDX, STATE_TO_IDX
16
16
 
17
- from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
18
- from synth_ai.environments.reproducibility.core import IReproducibleEngine
19
17
  from synth_ai.environments.environment.rewards.core import RewardComponent, RewardStack
20
18
  from synth_ai.environments.environment.shared_engine import (
21
19
  GetObservationCallable,
22
20
  InternalObservation,
23
21
  )
24
- from synth_ai.environments.tasks.core import TaskInstance
25
22
  from synth_ai.environments.examples.minigrid.environment_mapping import (
26
- get_environment_from_seed,
27
23
  get_difficulty_from_seed,
24
+ get_environment_from_seed,
28
25
  validate_environment_name,
29
26
  )
27
+ from synth_ai.environments.reproducibility.core import IReproducibleEngine
28
+ from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
29
+ from synth_ai.environments.tasks.core import TaskInstance
30
30
 
31
31
 
32
32
  @dataclass
@@ -12,20 +12,20 @@ from typing import Any, Callable, Dict, List, Optional, Union
12
12
  import numpy as np
13
13
  from pydantic import BaseModel, Field
14
14
 
15
- from synth_ai.environments.environment.tools import AbstractTool, EnvToolCall, ToolResult
16
- from synth_ai.environments.stateful.core import StatefulEnvironment
17
- from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
18
15
  from synth_ai.environments.environment.shared_engine import (
19
16
  GetObservationCallable,
20
17
  InternalObservation,
21
18
  )
19
+ from synth_ai.environments.environment.tools import AbstractTool, EnvToolCall, ToolResult
22
20
  from synth_ai.environments.examples.minigrid.engine import (
21
+ MiniGridCheckpointObservationCallable,
23
22
  MiniGridEngine,
24
- MiniGridPublicState,
25
- MiniGridPrivateState,
26
23
  MiniGridObservationCallable,
27
- MiniGridCheckpointObservationCallable,
24
+ MiniGridPrivateState,
25
+ MiniGridPublicState,
28
26
  )
27
+ from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
28
+ from synth_ai.environments.stateful.core import StatefulEnvironment
29
29
  from synth_ai.environments.tasks.core import TaskInstance
30
30
 
31
31
 
@@ -6,8 +6,9 @@ with deterministic seed-based selection and difficulty filtering.
6
6
  """
7
7
 
8
8
  import logging
9
- from dataclasses import dataclass, asdict
10
- from typing import Dict, List, Optional, Tuple, Any
9
+ from dataclasses import asdict, dataclass
10
+ from typing import Any, Dict, List, Optional, Tuple
11
+
11
12
  from synth_ai.environments.examples.minigrid.environment_mapping import ENVIRONMENT_MAPPING
12
13
 
13
14
  logger = logging.getLogger(__name__)
@@ -12,24 +12,24 @@ from dataclasses import dataclass, field
12
12
  from typing import Any, Dict, List, Optional, Set, Tuple
13
13
  from uuid import uuid4
14
14
 
15
- from synth_ai.environments.tasks.api import (
16
- Task,
17
- TaskInstance,
18
- TaskInstanceMetadata,
19
- TaskInstanceSet,
20
- SplitInfo,
21
- Impetus,
22
- Intent,
23
- )
24
15
  from synth_ai.environments.examples.minigrid.environment_mapping import (
25
- get_environment_from_seed,
26
- get_difficulty_from_seed,
27
16
  get_all_environments,
17
+ get_difficulty_from_seed,
18
+ get_environment_from_seed,
28
19
  )
29
20
  from synth_ai.environments.examples.minigrid.puzzle_loader import (
30
- get_puzzle_loader,
31
- get_puzzle_by_seed,
32
21
  MiniGridPuzzle,
22
+ get_puzzle_by_seed,
23
+ get_puzzle_loader,
24
+ )
25
+ from synth_ai.environments.tasks.api import (
26
+ Impetus,
27
+ Intent,
28
+ SplitInfo,
29
+ Task,
30
+ TaskInstance,
31
+ TaskInstanceMetadata,
32
+ TaskInstanceSet,
33
33
  )
34
34
 
35
35
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  import json
4
4
  import os
5
- from typing import Dict, Any, Optional, Tuple
6
5
  from dataclasses import dataclass, field
6
+ from typing import Any, Dict, Optional, Tuple
7
7
 
8
8
 
9
9
  # Exact copy of Balrog's Progress class
@@ -4,27 +4,28 @@ from __future__ import annotations
4
4
 
5
5
  import asyncio
6
6
  import base64
7
+ import logging
7
8
  from dataclasses import dataclass, field
8
- from typing import Dict, Any, Optional, Tuple, List, TYPE_CHECKING, cast
9
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, cast
10
+
9
11
  import numpy as np
10
- import logging
11
12
 
12
- from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
13
- from synth_ai.environments.reproducibility.core import IReproducibleEngine
14
- from synth_ai.environments.environment.rewards.core import RewardStack, RewardComponent
13
+ from synth_ai.environments.environment.rewards.core import RewardComponent, RewardStack
15
14
  from synth_ai.environments.environment.shared_engine import (
16
15
  GetObservationCallable,
17
16
  InternalObservation,
18
17
  )
18
+ from synth_ai.environments.reproducibility.core import IReproducibleEngine
19
+ from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
19
20
  from synth_ai.environments.tasks.core import TaskInstance
20
21
 
21
22
  logger = logging.getLogger(__name__)
22
23
 
23
24
  # NLE imports are required
24
25
  try:
25
- from .helpers.nle_wrapper import NLEWrapper
26
- from .helpers.action_mapping import convert_action_to_nle
27
26
  from .achievements import NetHackAchievements, calculate_balrog_reward
27
+ from .helpers.action_mapping import convert_action_to_nle
28
+ from .helpers.nle_wrapper import NLEWrapper
28
29
  except ImportError as e:
29
30
  raise ImportError(
30
31
  "NLE (NetHack Learning Environment) is required but not installed. "
@@ -3,30 +3,31 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
- from typing import Dict, Any, Optional, List, Union
6
+ from typing import Any, Dict, List, Optional, Union
7
+
7
8
  from pydantic import BaseModel
8
9
 
9
- from synth_ai.environments.stateful.core import StatefulEnvironment
10
- from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
11
- from synth_ai.environments.environment.tools import AbstractTool, EnvToolCall, ToolResult
12
10
  from synth_ai.environments.environment.shared_engine import (
13
11
  GetObservationCallable,
14
12
  InternalObservation,
15
13
  )
14
+ from synth_ai.environments.environment.tools import AbstractTool, EnvToolCall, ToolResult
15
+ from synth_ai.environments.reproducibility.core import ReproducibleEnvironment
16
+ from synth_ai.environments.stateful.core import StatefulEnvironment
16
17
  from synth_ai.environments.tasks.core import TaskInstance
17
18
 
18
19
  from .engine import (
20
+ NetHackCheckpointObservationCallable,
19
21
  NetHackEngine,
20
22
  NetHackObservationCallable,
21
- NetHackCheckpointObservationCallable,
22
- NetHackPublicState,
23
23
  NetHackPrivateState,
24
+ NetHackPublicState,
24
25
  )
25
26
  from .helpers import (
26
- validate_action,
27
- get_action_description,
28
- NETHACK_ACTIONS,
29
27
  MENU_ACTIONS,
28
+ NETHACK_ACTIONS,
29
+ get_action_description,
30
+ validate_action,
30
31
  )
31
32
 
32
33
 
@@ -1,24 +1,23 @@
1
1
  """Helper utilities for NetHack environment."""
2
2
 
3
3
  from .action_mapping import (
4
- NETHACK_ACTIONS,
5
- MENU_ACTIONS,
6
- ALL_ACTIONS,
7
4
  ACTION_CATEGORIES,
8
- validate_action,
5
+ ALL_ACTIONS,
6
+ MENU_ACTIONS,
7
+ NETHACK_ACTIONS,
8
+ convert_action_to_nle,
9
9
  get_action_description,
10
10
  get_actions_for_context,
11
- convert_action_to_nle,
12
11
  parse_compound_action,
12
+ validate_action,
13
13
  )
14
-
15
14
  from .observation_utils import (
16
- format_observation_for_llm,
17
- parse_ascii_map,
18
15
  extract_game_context,
19
- simplify_observation,
20
16
  extract_inventory_from_message,
17
+ format_observation_for_llm,
21
18
  identify_item_type,
19
+ parse_ascii_map,
20
+ simplify_observation,
22
21
  )
23
22
 
24
23
  __all__ = [
@@ -1,7 +1,7 @@
1
1
  """Action mapping and validation for NetHack."""
2
2
 
3
- from typing import Dict, List, Optional, Tuple
4
3
  from dataclasses import dataclass
4
+ from typing import Dict, List, Optional, Tuple
5
5
 
6
6
 
7
7
  @dataclass
@@ -1,6 +1,7 @@
1
1
  """NLE integration wrapper for NetHack environment."""
2
2
 
3
- from typing import Dict, Any, Optional, Tuple, List
3
+ from typing import Any, Dict, List, Optional, Tuple
4
+
4
5
  import numpy as np
5
6
 
6
7
  try:
@@ -1,7 +1,7 @@
1
1
  """Observation processing utilities for NetHack."""
2
2
 
3
- from typing import Dict, Any, List, Optional, Tuple
4
3
  import re
4
+ from typing import Any, Dict, List, Optional, Tuple
5
5
 
6
6
 
7
7
  def format_observation_for_llm(observation: Dict[str, Any]) -> str:
@@ -1,15 +1,14 @@
1
1
  """Environment wrapper that adds trajectory recording capabilities."""
2
2
 
3
- from typing import Dict, Any, Optional, Tuple
4
- from pathlib import Path
5
3
  import logging
4
+ from pathlib import Path
5
+ from typing import Any, Dict, Optional, Tuple
6
6
 
7
+ from src.synth_env.environment.tools import EnvToolCall
7
8
  from src.synth_env.examples.nethack.environment import NetHackEnvironment
8
9
  from src.synth_env.examples.nethack.helpers.trajectory_recorder import (
9
10
  TrajectoryRecorder,
10
11
  )
11
- from src.synth_env.environment.tools import EnvToolCall
12
-
13
12
 
14
13
  logger = logging.getLogger(__name__)
15
14
 
@@ -1,14 +1,15 @@
1
1
  """Trajectory recording and replay functionality for NetHack."""
2
2
 
3
+ import base64
4
+ import gzip
3
5
  import json
4
6
  import pickle
5
- import gzip
6
- from pathlib import Path
7
- from typing import Dict, Any, List, Optional, Tuple
7
+ from dataclasses import asdict, dataclass
8
8
  from datetime import datetime
9
+ from pathlib import Path
10
+ from typing import Any, Dict, List, Optional, Tuple
11
+
9
12
  import numpy as np
10
- from dataclasses import dataclass, asdict
11
- import base64
12
13
 
13
14
 
14
15
  @dataclass
@@ -1,19 +1,19 @@
1
1
  """Interactive replay viewer for NetHack trajectories."""
2
2
 
3
+ import gzip
4
+ import json
3
5
  import os
4
6
  import sys
5
- from pathlib import Path
6
- from typing import List, Dict, Any, Optional, Tuple
7
- import json
8
- import gzip
9
7
  from datetime import datetime
8
+ from pathlib import Path
9
+ from typing import Any, Dict, List, Optional, Tuple
10
10
 
11
11
  # Add parent directory to path for imports
12
12
  sys.path.append(str(Path(__file__).parent.parent.parent.parent.parent.parent))
13
13
 
14
14
  from src.synth_env.examples.nethack.helpers.trajectory_recorder import (
15
- TrajectoryRecorder,
16
15
  TrajectoryFrame,
16
+ TrajectoryRecorder,
17
17
  )
18
18
  from src.synth_env.examples.nethack.helpers.visualization.visualizer import (
19
19
  NetHackVisualizer,
@@ -1,14 +1,15 @@
1
1
  """Visualization tools for NetHack trajectories."""
2
2
 
3
- import numpy as np
4
- from typing import List, Dict, Any, Optional, Tuple
3
+ import json
4
+ from datetime import datetime
5
5
  from pathlib import Path
6
- import matplotlib.pyplot as plt
6
+ from typing import Any, Dict, List, Optional, Tuple
7
+
7
8
  import matplotlib.animation as animation
8
- from matplotlib.patches import Rectangle
9
+ import matplotlib.pyplot as plt
10
+ import numpy as np
9
11
  import seaborn as sns
10
- from datetime import datetime
11
- import json
12
+ from matplotlib.patches import Rectangle
12
13
 
13
14
  try:
14
15
  from PIL import Image, ImageDraw, ImageFont
@@ -3,17 +3,17 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import random
6
- from uuid import uuid4
7
6
  from dataclasses import dataclass
8
- from typing import Dict, Any, List, Optional, Set
7
+ from typing import Any, Dict, List, Optional, Set
8
+ from uuid import uuid4
9
9
 
10
10
  from synth_ai.environments.tasks.core import (
11
- TaskInstance,
12
- TaskInstanceMetadata,
13
- TaskInstanceSet,
14
11
  Impetus,
15
12
  Intent,
16
13
  SplitInfo,
14
+ TaskInstance,
15
+ TaskInstanceMetadata,
16
+ TaskInstanceSet,
17
17
  )
18
18
 
19
19
 
@@ -1,25 +1,26 @@
1
1
  from __future__ import annotations
2
+
2
3
  import logging
3
- from pathlib import Path
4
- from typing import Dict, Any, Optional, List
5
4
  from dataclasses import dataclass
5
+ from pathlib import Path
6
+ from typing import Any, Dict, List, Optional
6
7
 
7
- # Import logging configuration first to suppress JAX debug messages
8
+ from synth_ai.environments.environment.rewards.core import RewardStack
9
+ from synth_ai.environments.reproducibility.core import IReproducibleEngine
8
10
 
11
+ # Import logging configuration first to suppress JAX debug messages
9
12
  from synth_ai.environments.stateful.engine import StatefulEngine, StatefulEngineSnapshot
10
- from synth_ai.environments.reproducibility.core import IReproducibleEngine
11
- from synth_ai.environments.environment.rewards.core import RewardStack
12
13
  from synth_ai.environments.tasks.core import TaskInstance
13
14
 
14
- from .engine_helpers.state_extraction import extract_game_state
15
15
  from .engine_helpers.reward_components import (
16
16
  BadgeRewardComponent,
17
- MapTransitionComponent,
18
17
  BattleVictoryComponent,
19
18
  LevelUpComponent,
20
- XPGainComponent,
19
+ MapTransitionComponent,
21
20
  StepPenaltyComponent,
21
+ XPGainComponent,
22
22
  )
23
+ from .engine_helpers.state_extraction import extract_game_state
23
24
 
24
25
  try:
25
26
  from pyboy import PyBoy
@@ -1,5 +1,6 @@
1
+ from typing import Any, Dict, Set
2
+
1
3
  from synth_ai.environments.environment.rewards.core import RewardComponent
2
- from typing import Dict, Any, Set
3
4
 
4
5
 
5
6
  class BadgeRewardComponent(RewardComponent):
@@ -4,17 +4,17 @@ Pokemon Red Reward Library
4
4
  Comprehensive collection of reward components organized by category.
5
5
  """
6
6
 
7
- from .pallet_town_rewards import *
8
- from .exploration_rewards import *
9
- from .social_rewards import *
10
- from .pokemon_rewards import *
7
+ from .adaptive_rewards import *
11
8
  from .battle_rewards import *
12
- from .story_rewards import *
9
+ from .composite_rewards import *
13
10
  from .economy_rewards import *
14
11
  from .efficiency_rewards import *
12
+ from .exploration_rewards import *
15
13
  from .novelty_rewards import *
16
- from .adaptive_rewards import *
17
- from .composite_rewards import *
14
+ from .pallet_town_rewards import *
15
+ from .pokemon_rewards import *
16
+ from .social_rewards import *
17
+ from .story_rewards import *
18
18
 
19
19
  __all__ = [
20
20
  # Pallet Town Early Game
@@ -4,8 +4,9 @@ Adaptive & Learning Reward Components
4
4
  Rewards for improvement over time and meta-learning.
5
5
  """
6
6
 
7
+ from typing import Any, Dict
8
+
7
9
  from synth_ai.environments.environment.rewards.core import RewardComponent
8
- from typing import Dict, Any
9
10
 
10
11
 
11
12
  class MistakeRecoveryReward(RewardComponent):
@@ -4,8 +4,9 @@ Battle & Combat Reward Components
4
4
  Rewards for battle victories, combat strategy, and battle efficiency.
5
5
  """
6
6
 
7
+ from typing import Any, Dict, Set
8
+
7
9
  from synth_ai.environments.environment.rewards.core import RewardComponent
8
- from typing import Dict, Any, Set
9
10
 
10
11
 
11
12
  class WildPokemonDefeatedReward(RewardComponent):
@@ -4,8 +4,9 @@ Composite & Milestone Reward Components
4
4
  Rewards for achievement combinations and progression streaks.
5
5
  """
6
6
 
7
+ from typing import Any, Dict, Set
8
+
7
9
  from synth_ai.environments.environment.rewards.core import RewardComponent
8
- from typing import Dict, Any, Set
9
10
 
10
11
 
11
12
  class PerfectGymRunReward(RewardComponent):
@@ -4,8 +4,9 @@ Economy & Resource Management Reward Components
4
4
  Rewards for money management and inventory optimization.
5
5
  """
6
6
 
7
+ from typing import Any, Dict, Set
8
+
7
9
  from synth_ai.environments.environment.rewards.core import RewardComponent
8
- from typing import Dict, Any, Set
9
10
 
10
11
 
11
12
  class FirstEarningsReward(RewardComponent):
@@ -4,8 +4,9 @@ Efficiency & Optimization Reward Components
4
4
  Rewards for optimal play, routing, and game knowledge.
5
5
  """
6
6
 
7
+ from typing import Any, Dict
8
+
7
9
  from synth_ai.environments.environment.rewards.core import RewardComponent
8
- from typing import Dict, Any
9
10
 
10
11
 
11
12
  class FastTravelUsageReward(RewardComponent):
@@ -4,8 +4,9 @@ Exploration & Discovery Reward Components
4
4
  Rewards for map exploration, item discovery, and world interaction.
5
5
  """
6
6
 
7
+ from typing import Any, Dict, Set
8
+
7
9
  from synth_ai.environments.environment.rewards.core import RewardComponent
8
- from typing import Dict, Any, Set
9
10
 
10
11
 
11
12
  class NewAreaDiscoveryReward(RewardComponent):
@@ -4,8 +4,9 @@ Novelty & Exploration Bonus Reward Components
4
4
  Rewards for first-time experiences and curiosity.
5
5
  """
6
6
 
7
+ from typing import Any, Dict, Set
8
+
7
9
  from synth_ai.environments.environment.rewards.core import RewardComponent
8
- from typing import Dict, Any, Set
9
10
 
10
11
 
11
12
  class FirstBattleReward(RewardComponent):
@@ -5,8 +5,9 @@ Rewards specifically designed for the first 50 steps of Pokemon Red,
5
5
  focusing on house exploration, town discovery, and story triggers.
6
6
  """
7
7
 
8
+ from typing import Any, Dict, Set
9
+
8
10
  from synth_ai.environments.environment.rewards.core import RewardComponent
9
- from typing import Dict, Any, Set
10
11
 
11
12
 
12
13
  class LeaveStartingRoomReward(RewardComponent):
@@ -4,8 +4,9 @@ Pokemon Collection & Management Reward Components
4
4
  Rewards for catching Pokemon, Pokedex progress, and Pokemon development.
5
5
  """
6
6
 
7
+ from typing import Any, Dict, Set
8
+
7
9
  from synth_ai.environments.environment.rewards.core import RewardComponent
8
- from typing import Dict, Any, Set
9
10
 
10
11
 
11
12
  class FirstPokemonCaughtReward(RewardComponent):
@@ -4,8 +4,9 @@ Social & NPC Interaction Reward Components
4
4
  Rewards for dialogue, information gathering, and NPC interactions.
5
5
  """
6
6
 
7
+ from typing import Any, Dict, Set
8
+
7
9
  from synth_ai.environments.environment.rewards.core import RewardComponent
8
- from typing import Dict, Any, Set
9
10
 
10
11
 
11
12
  class NewNPCConversationReward(RewardComponent):