abstractagent 0.2.0__tar.gz

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 (35) hide show
  1. abstractagent-0.2.0/LICENSE +25 -0
  2. abstractagent-0.2.0/PKG-INFO +134 -0
  3. abstractagent-0.2.0/README.md +121 -0
  4. abstractagent-0.2.0/pyproject.toml +25 -0
  5. abstractagent-0.2.0/setup.cfg +4 -0
  6. abstractagent-0.2.0/src/abstractagent/__init__.py +49 -0
  7. abstractagent-0.2.0/src/abstractagent/adapters/__init__.py +6 -0
  8. abstractagent-0.2.0/src/abstractagent/adapters/codeact_runtime.py +397 -0
  9. abstractagent-0.2.0/src/abstractagent/adapters/react_runtime.py +390 -0
  10. abstractagent-0.2.0/src/abstractagent/agents/__init__.py +15 -0
  11. abstractagent-0.2.0/src/abstractagent/agents/base.py +421 -0
  12. abstractagent-0.2.0/src/abstractagent/agents/codeact.py +194 -0
  13. abstractagent-0.2.0/src/abstractagent/agents/react.py +210 -0
  14. abstractagent-0.2.0/src/abstractagent/logic/__init__.py +19 -0
  15. abstractagent-0.2.0/src/abstractagent/logic/builtins.py +29 -0
  16. abstractagent-0.2.0/src/abstractagent/logic/codeact.py +166 -0
  17. abstractagent-0.2.0/src/abstractagent/logic/react.py +126 -0
  18. abstractagent-0.2.0/src/abstractagent/logic/types.py +30 -0
  19. abstractagent-0.2.0/src/abstractagent/repl.py +457 -0
  20. abstractagent-0.2.0/src/abstractagent/sandbox/__init__.py +7 -0
  21. abstractagent-0.2.0/src/abstractagent/sandbox/interface.py +22 -0
  22. abstractagent-0.2.0/src/abstractagent/sandbox/local.py +68 -0
  23. abstractagent-0.2.0/src/abstractagent/tools/__init__.py +58 -0
  24. abstractagent-0.2.0/src/abstractagent/tools/code_execution.py +45 -0
  25. abstractagent-0.2.0/src/abstractagent/tools/self_improve.py +56 -0
  26. abstractagent-0.2.0/src/abstractagent/ui/__init__.py +5 -0
  27. abstractagent-0.2.0/src/abstractagent/ui/question.py +197 -0
  28. abstractagent-0.2.0/src/abstractagent.egg-info/PKG-INFO +134 -0
  29. abstractagent-0.2.0/src/abstractagent.egg-info/SOURCES.txt +33 -0
  30. abstractagent-0.2.0/src/abstractagent.egg-info/dependency_links.txt +1 -0
  31. abstractagent-0.2.0/src/abstractagent.egg-info/entry_points.txt +2 -0
  32. abstractagent-0.2.0/src/abstractagent.egg-info/requires.txt +5 -0
  33. abstractagent-0.2.0/src/abstractagent.egg-info/top_level.txt +1 -0
  34. abstractagent-0.2.0/tests/test_session_memory.py +32 -0
  35. abstractagent-0.2.0/tests/test_tools_editing.py +82 -0
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Laurent-Philippe Albou
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+
24
+
25
+
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: abstractagent
3
+ Version: 0.2.0
4
+ Summary: Agent implementations using AbstractRuntime and AbstractCore
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: abstractcore
9
+ Requires-Dist: abstractruntime
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest>=7.0; extra == "dev"
12
+ Dynamic: license-file
13
+
14
+ # AbstractAgent
15
+
16
+ Agent implementations using AbstractRuntime and AbstractCore.
17
+
18
+ ## Features
19
+
20
+ - **ReAct Agent**: Reason-Act-Observe loop with tool calling
21
+ - **Async REPL**: Interactive agent with real-time step visibility
22
+ - **Pause/Resume**: Durable agent state with interrupt/resume capability
23
+ - **Ask User**: Agent can ask questions with multiple choice + free text
24
+ - **Ledger Recording**: All tool calls recorded for auditability
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install -e .
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ ### Simple (Factory)
35
+
36
+ ```python
37
+ from abstractagent import create_react_agent
38
+
39
+ # One-liner agent creation
40
+ agent = create_react_agent()
41
+ agent.start("List the files in the current directory")
42
+ state = agent.run_to_completion()
43
+ print(state.output["answer"])
44
+ ```
45
+
46
+ ### With Custom Tools
47
+
48
+ ```python
49
+ from abstractagent import create_react_agent
50
+ from abstractcore.tools import tool
51
+
52
+ @tool(name="my_tool", description="My custom tool")
53
+ def my_tool(query: str) -> str:
54
+ """My custom tool."""
55
+ return f"Result for {query}"
56
+
57
+ agent = create_react_agent(tools=[my_tool])
58
+ ```
59
+
60
+ ### Full Control
61
+
62
+ ```python
63
+ from abstractruntime.integrations.abstractcore import create_local_runtime
64
+ from abstractagent import ReactAgent, list_files, read_file
65
+
66
+ # Create runtime
67
+ runtime = create_local_runtime(
68
+ provider="ollama",
69
+ model="qwen3:4b-instruct-2507-q4_K_M",
70
+ )
71
+
72
+ # Create agent with specific tools
73
+ agent = ReactAgent(
74
+ runtime=runtime,
75
+ tools=[list_files, read_file],
76
+ )
77
+
78
+ agent.start("List the files in the current directory")
79
+ state = agent.run_to_completion()
80
+ print(state.output["answer"])
81
+ ```
82
+
83
+ ## State Persistence
84
+
85
+ Resume agents across process restarts:
86
+
87
+ ```python
88
+ agent = create_react_agent()
89
+ agent.start("Long running task")
90
+
91
+ # Save state before exit
92
+ agent.save_state("agent_state.json")
93
+
94
+ # ... process restarts ...
95
+
96
+ # Load and resume
97
+ agent = create_react_agent()
98
+ agent.load_state("agent_state.json")
99
+ state = agent.run_to_completion()
100
+
101
+ # Cleanup
102
+ agent.clear_state("agent_state.json")
103
+ ```
104
+
105
+ ## REPL Usage
106
+
107
+ ```bash
108
+ # Start the ReAct agent REPL
109
+ python -m abstractagent.repl --provider ollama --model qwen3:4b-instruct-2507-q4_K_M
110
+ ```
111
+
112
+ ## Architecture
113
+
114
+ ```
115
+ AbstractAgent
116
+
117
+ ├── Uses AbstractRuntime for durable execution
118
+ │ - Workflows survive crashes
119
+ │ - Pause/resume capability
120
+ │ - Ledger tracks all actions (LLM calls, tool calls)
121
+
122
+ └── Uses AbstractCore for LLM/tools
123
+ - Provider-agnostic LLM calls
124
+ - Tool registration and execution
125
+ - Tool call parsing for all model architectures
126
+ ```
127
+
128
+ ## Available Tools
129
+
130
+ - `list_files(path)` - List files and directories
131
+ - `read_file(path)` - Read file contents
132
+ - `search_files(pattern, path)` - Search for files matching a glob pattern
133
+ - `execute_command(command)` - Execute a shell command (with safety restrictions)
134
+ - `ask_user(question, choices)` - Ask the user a question (built-in)
@@ -0,0 +1,121 @@
1
+ # AbstractAgent
2
+
3
+ Agent implementations using AbstractRuntime and AbstractCore.
4
+
5
+ ## Features
6
+
7
+ - **ReAct Agent**: Reason-Act-Observe loop with tool calling
8
+ - **Async REPL**: Interactive agent with real-time step visibility
9
+ - **Pause/Resume**: Durable agent state with interrupt/resume capability
10
+ - **Ask User**: Agent can ask questions with multiple choice + free text
11
+ - **Ledger Recording**: All tool calls recorded for auditability
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install -e .
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ### Simple (Factory)
22
+
23
+ ```python
24
+ from abstractagent import create_react_agent
25
+
26
+ # One-liner agent creation
27
+ agent = create_react_agent()
28
+ agent.start("List the files in the current directory")
29
+ state = agent.run_to_completion()
30
+ print(state.output["answer"])
31
+ ```
32
+
33
+ ### With Custom Tools
34
+
35
+ ```python
36
+ from abstractagent import create_react_agent
37
+ from abstractcore.tools import tool
38
+
39
+ @tool(name="my_tool", description="My custom tool")
40
+ def my_tool(query: str) -> str:
41
+ """My custom tool."""
42
+ return f"Result for {query}"
43
+
44
+ agent = create_react_agent(tools=[my_tool])
45
+ ```
46
+
47
+ ### Full Control
48
+
49
+ ```python
50
+ from abstractruntime.integrations.abstractcore import create_local_runtime
51
+ from abstractagent import ReactAgent, list_files, read_file
52
+
53
+ # Create runtime
54
+ runtime = create_local_runtime(
55
+ provider="ollama",
56
+ model="qwen3:4b-instruct-2507-q4_K_M",
57
+ )
58
+
59
+ # Create agent with specific tools
60
+ agent = ReactAgent(
61
+ runtime=runtime,
62
+ tools=[list_files, read_file],
63
+ )
64
+
65
+ agent.start("List the files in the current directory")
66
+ state = agent.run_to_completion()
67
+ print(state.output["answer"])
68
+ ```
69
+
70
+ ## State Persistence
71
+
72
+ Resume agents across process restarts:
73
+
74
+ ```python
75
+ agent = create_react_agent()
76
+ agent.start("Long running task")
77
+
78
+ # Save state before exit
79
+ agent.save_state("agent_state.json")
80
+
81
+ # ... process restarts ...
82
+
83
+ # Load and resume
84
+ agent = create_react_agent()
85
+ agent.load_state("agent_state.json")
86
+ state = agent.run_to_completion()
87
+
88
+ # Cleanup
89
+ agent.clear_state("agent_state.json")
90
+ ```
91
+
92
+ ## REPL Usage
93
+
94
+ ```bash
95
+ # Start the ReAct agent REPL
96
+ python -m abstractagent.repl --provider ollama --model qwen3:4b-instruct-2507-q4_K_M
97
+ ```
98
+
99
+ ## Architecture
100
+
101
+ ```
102
+ AbstractAgent
103
+
104
+ ├── Uses AbstractRuntime for durable execution
105
+ │ - Workflows survive crashes
106
+ │ - Pause/resume capability
107
+ │ - Ledger tracks all actions (LLM calls, tool calls)
108
+
109
+ └── Uses AbstractCore for LLM/tools
110
+ - Provider-agnostic LLM calls
111
+ - Tool registration and execution
112
+ - Tool call parsing for all model architectures
113
+ ```
114
+
115
+ ## Available Tools
116
+
117
+ - `list_files(path)` - List files and directories
118
+ - `read_file(path)` - Read file contents
119
+ - `search_files(pattern, path)` - Search for files matching a glob pattern
120
+ - `execute_command(command)` - Execute a shell command (with safety restrictions)
121
+ - `ask_user(question, choices)` - Ask the user a question (built-in)
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "abstractagent"
7
+ version = "0.2.0"
8
+ description = "Agent implementations using AbstractRuntime and AbstractCore"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "abstractcore",
13
+ "abstractruntime",
14
+ ]
15
+
16
+ [project.optional-dependencies]
17
+ dev = [
18
+ "pytest>=7.0",
19
+ ]
20
+
21
+ [tool.setuptools.packages.find]
22
+ where = ["src"]
23
+
24
+ [project.scripts]
25
+ react-agent = "abstractagent.repl:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,49 @@
1
+ """AbstractAgent - Agent implementations using AbstractRuntime and AbstractCore."""
2
+
3
+ from .agents import (
4
+ BaseAgent,
5
+ ReactAgent,
6
+ create_react_workflow,
7
+ create_react_agent,
8
+ CodeActAgent,
9
+ create_codeact_workflow,
10
+ create_codeact_agent,
11
+ )
12
+ from .tools import (
13
+ ALL_TOOLS,
14
+ list_files,
15
+ read_file,
16
+ search_files,
17
+ execute_command,
18
+ write_file,
19
+ edit_file,
20
+ web_search,
21
+ fetch_url,
22
+ execute_python,
23
+ self_improve,
24
+ )
25
+
26
+ __all__ = [
27
+ # Base class for custom agents
28
+ "BaseAgent",
29
+ # ReAct agent
30
+ "ReactAgent",
31
+ "create_react_workflow",
32
+ "create_react_agent",
33
+ # CodeAct agent
34
+ "CodeActAgent",
35
+ "create_codeact_workflow",
36
+ "create_codeact_agent",
37
+ # Tools
38
+ "ALL_TOOLS",
39
+ "list_files",
40
+ "read_file",
41
+ "search_files",
42
+ "execute_command",
43
+ "write_file",
44
+ "edit_file",
45
+ "web_search",
46
+ "fetch_url",
47
+ "execute_python",
48
+ "self_improve",
49
+ ]
@@ -0,0 +1,6 @@
1
+ """Runtime adapters for agent logic."""
2
+
3
+ from .codeact_runtime import create_codeact_workflow
4
+ from .react_runtime import create_react_workflow
5
+
6
+ __all__ = ["create_react_workflow", "create_codeact_workflow"]