mini-swe-agent 1.17.4__py3-none-any.whl → 2.0.0a1__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 (74) hide show
  1. {mini_swe_agent-1.17.4.dist-info → mini_swe_agent-2.0.0a1.dist-info}/METADATA +36 -52
  2. mini_swe_agent-2.0.0a1.dist-info/RECORD +70 -0
  3. {mini_swe_agent-1.17.4.dist-info → mini_swe_agent-2.0.0a1.dist-info}/WHEEL +1 -1
  4. mini_swe_agent-2.0.0a1.dist-info/entry_points.txt +5 -0
  5. minisweagent/__init__.py +19 -26
  6. minisweagent/agents/default.py +128 -113
  7. minisweagent/agents/interactive.py +119 -58
  8. minisweagent/config/README.md +3 -4
  9. minisweagent/config/__init__.py +36 -1
  10. minisweagent/config/benchmarks/swebench.yaml +156 -0
  11. minisweagent/config/{extra/swebench.yaml → benchmarks/swebench_backticks.yaml} +69 -64
  12. minisweagent/config/benchmarks/swebench_modal.yaml +47 -0
  13. minisweagent/config/{extra → benchmarks}/swebench_xml.yaml +73 -70
  14. minisweagent/config/default.yaml +24 -21
  15. minisweagent/config/inspector.tcss +42 -0
  16. minisweagent/config/mini.yaml +53 -71
  17. minisweagent/config/{github_issue.yaml → mini_textbased.yaml} +43 -29
  18. minisweagent/environments/__init__.py +1 -0
  19. minisweagent/environments/docker.py +67 -20
  20. minisweagent/environments/extra/bubblewrap.py +86 -47
  21. minisweagent/environments/extra/swerex_docker.py +53 -20
  22. minisweagent/environments/extra/swerex_modal.py +90 -0
  23. minisweagent/environments/local.py +62 -21
  24. minisweagent/environments/singularity.py +59 -18
  25. minisweagent/exceptions.py +22 -0
  26. minisweagent/models/__init__.py +6 -7
  27. minisweagent/models/extra/roulette.py +20 -17
  28. minisweagent/models/litellm_model.py +90 -44
  29. minisweagent/models/litellm_response_model.py +80 -0
  30. minisweagent/models/litellm_textbased_model.py +45 -0
  31. minisweagent/models/openrouter_model.py +87 -45
  32. minisweagent/models/openrouter_response_model.py +123 -0
  33. minisweagent/models/openrouter_textbased_model.py +76 -0
  34. minisweagent/models/portkey_model.py +84 -42
  35. minisweagent/models/portkey_response_model.py +163 -0
  36. minisweagent/models/requesty_model.py +91 -41
  37. minisweagent/models/test_models.py +246 -19
  38. minisweagent/models/utils/actions_text.py +60 -0
  39. minisweagent/models/utils/actions_toolcall.py +102 -0
  40. minisweagent/models/utils/actions_toolcall_response.py +110 -0
  41. minisweagent/models/utils/anthropic_utils.py +28 -0
  42. minisweagent/models/utils/cache_control.py +15 -2
  43. minisweagent/models/utils/content_string.py +74 -0
  44. minisweagent/models/utils/openai_multimodal.py +50 -0
  45. minisweagent/models/utils/retry.py +25 -0
  46. minisweagent/run/benchmarks/__init__.py +1 -0
  47. minisweagent/run/{extra → benchmarks}/swebench.py +57 -36
  48. minisweagent/run/benchmarks/swebench_single.py +89 -0
  49. minisweagent/run/{extra → benchmarks}/utils/batch_progress.py +1 -1
  50. minisweagent/run/hello_world.py +6 -0
  51. minisweagent/run/mini.py +54 -63
  52. minisweagent/run/utilities/__init__.py +1 -0
  53. minisweagent/run/{extra → utilities}/config.py +2 -0
  54. minisweagent/run/{inspector.py → utilities/inspector.py} +90 -11
  55. minisweagent/run/{mini_extra.py → utilities/mini_extra.py} +9 -5
  56. minisweagent/utils/serialize.py +26 -0
  57. mini_swe_agent-1.17.4.dist-info/RECORD +0 -61
  58. mini_swe_agent-1.17.4.dist-info/entry_points.txt +0 -5
  59. minisweagent/agents/interactive_textual.py +0 -450
  60. minisweagent/config/extra/swebench_roulette.yaml +0 -233
  61. minisweagent/config/mini.tcss +0 -86
  62. minisweagent/models/anthropic.py +0 -35
  63. minisweagent/models/litellm_response_api_model.py +0 -82
  64. minisweagent/models/portkey_response_api_model.py +0 -75
  65. minisweagent/models/utils/key_per_thread.py +0 -20
  66. minisweagent/models/utils/openai_utils.py +0 -41
  67. minisweagent/run/extra/swebench_single.py +0 -79
  68. minisweagent/run/github_issue.py +0 -87
  69. minisweagent/run/utils/__init__.py +0 -0
  70. minisweagent/run/utils/save.py +0 -78
  71. {mini_swe_agent-1.17.4.dist-info → mini_swe_agent-2.0.0a1.dist-info}/licenses/LICENSE.md +0 -0
  72. {mini_swe_agent-1.17.4.dist-info → mini_swe_agent-2.0.0a1.dist-info}/top_level.txt +0 -0
  73. /minisweagent/config/{extra → benchmarks}/__init__.py +0 -0
  74. /minisweagent/run/{extra → benchmarks}/utils/__init__.py +0 -0
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env python3
2
- import os
3
- from pathlib import Path
4
-
5
- import requests
6
- import typer
7
- import yaml
8
- from rich.console import Console
9
-
10
- from minisweagent.agents.interactive import InteractiveAgent
11
- from minisweagent.config import builtin_config_dir, get_config_path
12
- from minisweagent.environments.docker import DockerEnvironment
13
- from minisweagent.models import get_model
14
- from minisweagent.run.extra.config import configure_if_first_time
15
- from minisweagent.run.utils.save import save_traj
16
-
17
- DEFAULT_CONFIG = Path(os.getenv("MSWEA_GITHUB_CONFIG_PATH", builtin_config_dir / "github_issue.yaml"))
18
- console = Console(highlight=False)
19
- app = typer.Typer(rich_markup_mode="rich", add_completion=False)
20
-
21
-
22
- def fetch_github_issue(issue_url: str) -> str:
23
- """Fetch GitHub issue text from the URL."""
24
- # Convert GitHub issue URL to API URL
25
- api_url = issue_url.replace("github.com", "api.github.com/repos").replace("/issues/", "/issues/")
26
-
27
- headers = {}
28
- if github_token := os.getenv("GITHUB_TOKEN"):
29
- headers["Authorization"] = f"token {github_token}"
30
-
31
- response = requests.get(api_url, headers=headers)
32
- issue_data = response.json()
33
-
34
- title = issue_data["title"]
35
- body = issue_data["body"] or ""
36
-
37
- return f"GitHub Issue: {title}\n\n{body}"
38
-
39
-
40
- # fmt: off
41
- @app.command()
42
- def main(
43
- issue_url: str = typer.Option(prompt="Enter GitHub issue URL", help="GitHub issue URL"),
44
- config: Path = typer.Option(DEFAULT_CONFIG, "-c", "--config", help="Path to config file"),
45
- model: str | None = typer.Option(None, "-m", "--model", help="Model to use"),
46
- model_class: str | None = typer.Option(None, "--model-class", help="Model class to use (e.g., 'anthropic' or 'minisweagent.models.anthropic.AnthropicModel')", rich_help_panel="Advanced"),
47
- yolo: bool = typer.Option(False, "-y", "--yolo", help="Run without confirmation"),
48
- ) -> InteractiveAgent:
49
- # fmt: on
50
- """Run mini-SWE-agent on a GitHub issue"""
51
- configure_if_first_time()
52
-
53
- config_path = get_config_path(config)
54
- console.print(f"Loading agent config from [bold green]'{config_path}'[/bold green]")
55
- _config = yaml.safe_load(config_path.read_text())
56
- _agent_config = _config.setdefault("agent", {})
57
- if yolo:
58
- _agent_config["mode"] = "yolo"
59
- if model_class is not None:
60
- _config.setdefault("model", {})["model_class"] = model_class
61
-
62
- task = fetch_github_issue(issue_url)
63
-
64
- agent = InteractiveAgent(
65
- get_model(model, _config.get("model", {})),
66
- DockerEnvironment(**_config.get("environment", {})),
67
- **_agent_config,
68
- )
69
-
70
- repo_url = issue_url.split("/issues/")[0]
71
- if github_token := os.getenv("GITHUB_TOKEN"):
72
- repo_url = repo_url.replace("https://github.com/", f"https://{github_token}@github.com/") + ".git"
73
-
74
- agent.env.execute(f"git clone {repo_url} /testbed", cwd="/")
75
-
76
- exit_status, result = None, None
77
- try:
78
- exit_status, result = agent.run(task)
79
- except KeyboardInterrupt:
80
- console.print("\n[bold red]KeyboardInterrupt -- goodbye[/bold red]")
81
- finally:
82
- save_traj(agent, Path("traj.json"), exit_status=exit_status, result=result)
83
- return agent
84
-
85
-
86
- if __name__ == "__main__":
87
- app()
File without changes
@@ -1,78 +0,0 @@
1
- import dataclasses
2
- import json
3
- from collections.abc import Callable
4
- from pathlib import Path
5
- from typing import Any
6
-
7
- from minisweagent import Agent, __version__
8
-
9
-
10
- def _get_class_name_with_module(obj: Any) -> str:
11
- """Get the full class name with module path."""
12
- return f"{obj.__class__.__module__}.{obj.__class__.__name__}"
13
-
14
-
15
- def _asdict(obj: Any) -> dict:
16
- """Convert config objects to dicts."""
17
- if dataclasses.is_dataclass(obj):
18
- return dataclasses.asdict(obj) # type: ignore[arg-type]
19
- return obj # let's try our luck
20
-
21
-
22
- def save_traj(
23
- agent: Agent | None,
24
- path: Path | None,
25
- *,
26
- print_path: bool = True,
27
- exit_status: str | None = None,
28
- result: str | None = None,
29
- extra_info: dict | None = None,
30
- print_fct: Callable = print,
31
- **kwargs,
32
- ):
33
- """Save the trajectory of the agent to a file.
34
-
35
- Args:
36
- agent: The agent to save the trajectory of.
37
- path: The path to save the trajectory to.
38
- print_path: Whether to print confirmation of path to the terminal.
39
- exit_status: The exit status of the agent.
40
- result: The result/submission of the agent.
41
- extra_info: Extra information to save (will be merged into the info dict).
42
- **kwargs: Additional information to save (will be merged into top level)
43
-
44
- """
45
- if path is None:
46
- return
47
- data = {
48
- "info": {
49
- "exit_status": exit_status,
50
- "submission": result,
51
- "model_stats": {
52
- "instance_cost": 0.0,
53
- "api_calls": 0,
54
- },
55
- "mini_version": __version__,
56
- },
57
- "messages": [],
58
- "trajectory_format": "mini-swe-agent-1",
59
- } | kwargs
60
- if agent is not None:
61
- data["info"]["model_stats"]["instance_cost"] = agent.model.cost
62
- data["info"]["model_stats"]["api_calls"] = agent.model.n_calls
63
- data["messages"] = agent.messages
64
- data["info"]["config"] = {
65
- "agent": _asdict(agent.config),
66
- "model": _asdict(agent.model.config),
67
- "environment": _asdict(agent.env.config),
68
- "agent_type": _get_class_name_with_module(agent),
69
- "model_type": _get_class_name_with_module(agent.model),
70
- "environment_type": _get_class_name_with_module(agent.env),
71
- }
72
- if extra_info:
73
- data["info"].update(extra_info)
74
-
75
- path.parent.mkdir(parents=True, exist_ok=True)
76
- path.write_text(json.dumps(data, indent=2))
77
- if print_path:
78
- print_fct(f"Saved trajectory to '{path}'")
File without changes