codex-agent-framework 0.1.1__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 (49) hide show
  1. codex_agent_framework-0.1.1/CHANGELOG.md +22 -0
  2. codex_agent_framework-0.1.1/LICENSE +21 -0
  3. codex_agent_framework-0.1.1/MANIFEST.in +7 -0
  4. codex_agent_framework-0.1.1/PKG-INFO +361 -0
  5. codex_agent_framework-0.1.1/README.md +314 -0
  6. codex_agent_framework-0.1.1/codex_agent/__init__.py +38 -0
  7. codex_agent_framework-0.1.1/codex_agent/__main__.py +18 -0
  8. codex_agent_framework-0.1.1/codex_agent/agent.py +1179 -0
  9. codex_agent_framework-0.1.1/codex_agent/ai.py +494 -0
  10. codex_agent_framework-0.1.1/codex_agent/builtin_commands.py +136 -0
  11. codex_agent_framework-0.1.1/codex_agent/builtin_providers.py +42 -0
  12. codex_agent_framework-0.1.1/codex_agent/builtin_tools.py +418 -0
  13. codex_agent_framework-0.1.1/codex_agent/chat.py +139 -0
  14. codex_agent_framework-0.1.1/codex_agent/command.py +19 -0
  15. codex_agent_framework-0.1.1/codex_agent/event.py +136 -0
  16. codex_agent_framework-0.1.1/codex_agent/get_text/__init__.py +20 -0
  17. codex_agent_framework-0.1.1/codex_agent/get_text/default_gitignore +110 -0
  18. codex_agent_framework-0.1.1/codex_agent/get_text/get_text.py +1240 -0
  19. codex_agent_framework-0.1.1/codex_agent/get_text/simpler_get_text.py +184 -0
  20. codex_agent_framework-0.1.1/codex_agent/get_webdriver.py +44 -0
  21. codex_agent_framework-0.1.1/codex_agent/image.py +304 -0
  22. codex_agent_framework-0.1.1/codex_agent/latex.py +165 -0
  23. codex_agent_framework-0.1.1/codex_agent/memory.py +318 -0
  24. codex_agent_framework-0.1.1/codex_agent/message.py +423 -0
  25. codex_agent_framework-0.1.1/codex_agent/prompts/image_generation_system_prompt.txt +13 -0
  26. codex_agent_framework-0.1.1/codex_agent/prompts/system_prompt.txt +88 -0
  27. codex_agent_framework-0.1.1/codex_agent/provider.py +19 -0
  28. codex_agent_framework-0.1.1/codex_agent/stream_utils.py +645 -0
  29. codex_agent_framework-0.1.1/codex_agent/tool.py +235 -0
  30. codex_agent_framework-0.1.1/codex_agent/utils.py +374 -0
  31. codex_agent_framework-0.1.1/codex_agent/voice.py +353 -0
  32. codex_agent_framework-0.1.1/codex_agent/worker.py +190 -0
  33. codex_agent_framework-0.1.1/codex_agent_framework.egg-info/PKG-INFO +361 -0
  34. codex_agent_framework-0.1.1/codex_agent_framework.egg-info/SOURCES.txt +47 -0
  35. codex_agent_framework-0.1.1/codex_agent_framework.egg-info/dependency_links.txt +1 -0
  36. codex_agent_framework-0.1.1/codex_agent_framework.egg-info/entry_points.txt +2 -0
  37. codex_agent_framework-0.1.1/codex_agent_framework.egg-info/requires.txt +30 -0
  38. codex_agent_framework-0.1.1/codex_agent_framework.egg-info/top_level.txt +1 -0
  39. codex_agent_framework-0.1.1/pyproject.toml +71 -0
  40. codex_agent_framework-0.1.1/setup.cfg +4 -0
  41. codex_agent_framework-0.1.1/tests/test_agent.py +1318 -0
  42. codex_agent_framework-0.1.1/tests/test_ai.py +40 -0
  43. codex_agent_framework-0.1.1/tests/test_chat.py +47 -0
  44. codex_agent_framework-0.1.1/tests/test_events.py +76 -0
  45. codex_agent_framework-0.1.1/tests/test_image_message.py +161 -0
  46. codex_agent_framework-0.1.1/tests/test_memory.py +380 -0
  47. codex_agent_framework-0.1.1/tests/test_messages.py +265 -0
  48. codex_agent_framework-0.1.1/tests/test_utils.py +88 -0
  49. codex_agent_framework-0.1.1/tests/test_worker.py +188 -0
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ This project loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and uses semantic versioning where practical.
6
+ ## [0.1.1] - 2026-05-03
7
+ ### Fixed
8
+ - Validate `ImageMessage` content before adding it to session state.
9
+ - Prevent invalid or inaccessible observed images from polluting a session and breaking later SDK calls.
10
+
11
+ ### Tests
12
+ - Add regression coverage for valid and invalid `ImageMessage` validation.
13
+ - Verify `Agent.add_image()` rejects invalid images without appending a broken session message.
14
+
15
+
16
+ ## [0.1.0] - 2026-05-03
17
+
18
+ ### Added
19
+
20
+ - Initial package metadata and console entry point.
21
+ - Event-driven agent runtime, session persistence, tools, providers, commands, voice, image, and document extraction modules.
22
+ - Test suite for core agent behavior, events, messages, image messages, utilities, and workers.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Baptiste
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.
@@ -0,0 +1,7 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ recursive-include codex_agent/prompts *.txt
5
+ include codex_agent/get_text/default_gitignore
6
+ recursive-exclude * __pycache__
7
+ recursive-exclude * *.py[co]
@@ -0,0 +1,361 @@
1
+ Metadata-Version: 2.4
2
+ Name: codex-agent-framework
3
+ Version: 0.1.1
4
+ Summary: A lightweight event-driven Codex agent runtime.
5
+ Author: Baptiste
6
+ License-Expression: MIT
7
+ Keywords: agent,ai,codex,openai,tools
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: beautifulsoup4
19
+ Requires-Dist: codex-backend-sdk
20
+ Requires-Dist: filetype
21
+ Requires-Dist: get-gecko-driver
22
+ Requires-Dist: modict
23
+ Requires-Dist: numpy
24
+ Requires-Dist: odfpy
25
+ Requires-Dist: openai
26
+ Requires-Dist: openpyxl
27
+ Requires-Dist: pathspec
28
+ Requires-Dist: pillow
29
+ Requires-Dist: prompt_toolkit
30
+ Requires-Dist: pydub
31
+ Requires-Dist: PyPDF2
32
+ Requires-Dist: pynteract
33
+ Requires-Dist: python-docx
34
+ Requires-Dist: PyYAML
35
+ Requires-Dist: regex
36
+ Requires-Dist: requests
37
+ Requires-Dist: rich
38
+ Requires-Dist: selenium
39
+ Requires-Dist: tiktoken
40
+ Requires-Dist: trafilatura
41
+ Provides-Extra: dev
42
+ Requires-Dist: build; extra == "dev"
43
+ Requires-Dist: pytest; extra == "dev"
44
+ Provides-Extra: streamlit
45
+ Requires-Dist: streamlit; extra == "streamlit"
46
+ Dynamic: license-file
47
+
48
+ # codex-agent
49
+
50
+ `codex-agent-framework` is a lightweight Python runtime for building interactive, tool-using AI agents.
51
+
52
+ It provides a reusable `Agent` abstraction with persistent sessions, local tools, slash commands, contextual providers, voice hooks, image handling, and document-reading helpers. The package can be used as a CLI assistant or embedded as a library in your own application.
53
+
54
+ > Status: early alpha. APIs are still evolving.
55
+
56
+ ## Highlights
57
+
58
+ - Interactive terminal agent exposed as `codex-agent`.
59
+ - Persistent JSON sessions with `latest`, explicit session IDs, and session navigation commands.
60
+ - Built-in local tools for reading, writing, editing, showing, observing, Bash, and Python execution.
61
+ - Extensible tool, command, and provider decorators.
62
+ - Event-driven internals for UI, streaming, voice, and automation integrations.
63
+ - Document extraction helpers for folders, text files, URLs, PDFs, DOCX, XLSX, ODT, HTML, and more.
64
+ - Optional image generation, image observation, voice, LaTeX, and Streamlit-oriented integration points.
65
+ - Packaged prompt assets and runtime defaults.
66
+
67
+ ## Requirements
68
+
69
+ - Python 3.10 or newer.
70
+ - A working model backend configuration compatible with `codex-backend-sdk` / OpenAI usage.
71
+ - Firefox / GeckoDriver may be needed for Selenium-backed web extraction paths.
72
+
73
+ ## Installation
74
+
75
+ From a local checkout:
76
+
77
+ ```bash
78
+ python -m pip install -e .
79
+ ```
80
+
81
+ For development:
82
+
83
+ ```bash
84
+ python -m pip install -e '.[dev]'
85
+ ```
86
+
87
+ Optional Streamlit support:
88
+
89
+ ```bash
90
+ python -m pip install -e '.[streamlit]'
91
+ ```
92
+
93
+ ## Quick start
94
+
95
+ Run the bundled terminal assistant:
96
+
97
+ ```bash
98
+ codex-agent
99
+ ```
100
+
101
+ Or use the agent from Python:
102
+
103
+ ```python
104
+ from codex_agent import Agent
105
+
106
+ agent = Agent(
107
+ session="new",
108
+ username="Baptiste",
109
+ voice_enabled=False,
110
+ )
111
+
112
+ agent("Summarize this project in three bullet points.")
113
+ ```
114
+
115
+ For an interactive Python-driven session:
116
+
117
+ ```python
118
+ from codex_agent import Agent
119
+
120
+ agent = Agent(session="latest", voice_enabled=False)
121
+ agent.interact()
122
+ ```
123
+
124
+ ## Runtime directory and sessions
125
+
126
+ By default, local runtime state is stored in:
127
+
128
+ ```text
129
+ ~/.agent_runtime
130
+ ```
131
+
132
+ This directory contains, among other things:
133
+
134
+ ```text
135
+ sessions/ persisted conversation histories as JSON
136
+ workfolder/ generated or uploaded files
137
+ tools/ user runtime tools
138
+ providers/ user runtime context providers
139
+ commands/ user runtime slash commands
140
+ images/ generated or persisted image outputs
141
+ ```
142
+
143
+ You can override the runtime location with:
144
+
145
+ ```bash
146
+ AGENT_RUNTIME_DIR=/tmp/my-agent-runtime codex-agent
147
+ ```
148
+
149
+ Session behavior:
150
+
151
+ - `Agent(session="new")` starts a fresh session.
152
+ - `Agent(session="latest")` resumes the newest saved session.
153
+ - `Agent(session="<session_id>")` loads a specific saved session.
154
+ - `Agent(session="/path/to/session.json")` loads a session file directly.
155
+
156
+ Session IDs are timestamp-based and lexicographically sortable.
157
+
158
+ ## Built-in slash commands
159
+
160
+ Inside the interactive agent, commands start with `/`.
161
+
162
+ Common commands:
163
+
164
+ ```text
165
+ /help list available commands
166
+ /sessions list saved sessions
167
+ /new_session create a new session
168
+ /load_session latest load latest session
169
+ /load_session <session_id> load a specific session
170
+ /delete_session <session_id> delete a session
171
+ /next_session move to the next/newer session
172
+ /previous_session move to the previous/older session
173
+ /compact compact completed history turns
174
+ /config show model-related config
175
+ /config model=gpt-test verbosity=low
176
+ /model show current model
177
+ /model gpt-test update model
178
+ /reasoning high update reasoning effort
179
+ /verbosity low update verbosity
180
+ ```
181
+
182
+ ## Built-in tools
183
+
184
+ The default agent registers local tools that can be exposed to the model:
185
+
186
+ | Tool | Purpose |
187
+ | --- | --- |
188
+ | `read` | Extract text from files, folders, URLs, and common document formats. |
189
+ | `write` | Write or overwrite one or more complete UTF-8 text files. |
190
+ | `edit` | Apply exact-string replacements to local text files. |
191
+ | `python` | Execute Python in a persistent interactive shell. |
192
+ | `bash` | Execute shell commands. |
193
+ | `observe` | Load an image into the conversation for visual analysis. |
194
+ | `show` | Open a file, folder, or URL with the system default app/browser. |
195
+
196
+ Use these with care: Bash, Python, write, and edit run with the current user's privileges.
197
+
198
+ ## Extending the agent
199
+
200
+ ### Define a tool
201
+
202
+ ```python
203
+ from codex_agent import Agent, tool
204
+
205
+ @tool
206
+ def add(a: int, b: int) -> int:
207
+ """Return the sum of two integers."""
208
+ return a + b
209
+
210
+ agent = Agent(session="new", voice_enabled=False)
211
+ agent.add_tool(add)
212
+ ```
213
+
214
+ ### Define a slash command
215
+
216
+ ```python
217
+ from codex_agent import Agent, command, get_agent
218
+
219
+ @command
220
+ def hello(name="world"):
221
+ return f"Hello, {name}! Current session: {get_agent().current_session_id}"
222
+
223
+ agent = Agent(session="new", voice_enabled=False)
224
+ agent.add_command(hello)
225
+ print(agent("/hello Baptiste"))
226
+ ```
227
+
228
+ ### Define a context provider
229
+
230
+ Providers inject ephemeral context into each model call. Their output is not persisted in the session.
231
+
232
+ ```python
233
+ from codex_agent import Agent, provider
234
+
235
+ @provider
236
+ def app_context():
237
+ return "The user is working on the codex-agent repository."
238
+
239
+ agent = Agent(session="new", voice_enabled=False)
240
+ agent.add_provider(app_context)
241
+ ```
242
+
243
+ ### Runtime extensions
244
+
245
+ The agent also loads Python modules from the runtime directory:
246
+
247
+ ```text
248
+ ~/.agent_runtime/tools/*.py
249
+ ~/.agent_runtime/providers/*.py
250
+ ~/.agent_runtime/commands/*.py
251
+ ```
252
+
253
+ Decorated functions in those files are registered automatically when the agent starts.
254
+
255
+ ## Events
256
+
257
+ `Agent` exposes an event bus for UI and automation integrations.
258
+
259
+ Example:
260
+
261
+ ```python
262
+ from codex_agent import Agent, MessageAddedEvent
263
+
264
+ agent = Agent(session="new", voice_enabled=False)
265
+
266
+ @agent.on(MessageAddedEvent)
267
+ def log_message(event):
268
+ print(event.message.type)
269
+ ```
270
+
271
+ Useful exported events include:
272
+
273
+ - `MessageAddedEvent`
274
+ - `ResponseStartEvent`
275
+ - `ResponseContentDeltaEvent`
276
+ - `ResponseDoneEvent`
277
+ - `ToolCallStartEvent`
278
+ - `ToolCallDoneEvent`
279
+ - `AgentInterruptedEvent`
280
+ - `AudioPlaybackEvent`
281
+
282
+ ## Configuration
283
+
284
+ `Agent` accepts configuration through keyword arguments:
285
+
286
+ ```python
287
+ agent = Agent(
288
+ session="latest",
289
+ model="gpt-5.4",
290
+ reasoning_effort="medium",
291
+ verbosity="medium",
292
+ input_token_limit=128000,
293
+ auto_compact=True,
294
+ web_search_enabled=False,
295
+ image_generation_enabled=False,
296
+ voice_enabled=False,
297
+ )
298
+ ```
299
+
300
+ Configuration is persisted to `agent_config.json` in the runtime directory when updated through agent helpers or slash commands.
301
+
302
+ ## Project layout
303
+
304
+ ```text
305
+ codex_agent/ Python package
306
+ codex_agent/agent.py Agent, AgentConfig, AgentSession
307
+ codex_agent/builtin_tools.py Built-in local tools
308
+ codex_agent/builtin_commands.py Built-in slash commands
309
+ codex_agent/builtin_providers.py Built-in context providers
310
+ codex_agent/prompts/ Packaged prompt templates
311
+ codex_agent/get_text/ Document extraction helpers
312
+ tests/ Test suite
313
+ pyproject.toml Package metadata and build config
314
+ MANIFEST.in Source distribution includes
315
+ ```
316
+
317
+ ## Testing
318
+
319
+ Run the full suite:
320
+
321
+ ```bash
322
+ python -m pytest
323
+ ```
324
+
325
+ The tests isolate `AGENT_RUNTIME_DIR` automatically, so they should not create or resume sessions from your real `~/.agent_runtime`.
326
+
327
+ Current baseline:
328
+
329
+ ```text
330
+ 102 passed
331
+ ```
332
+
333
+ ## Packaging
334
+
335
+ Build source and wheel distributions with:
336
+
337
+ ```bash
338
+ python -m pip install build
339
+ python -m build
340
+ ```
341
+
342
+ The distribution includes prompt text files and `codex_agent/get_text/default_gitignore` through package data and `MANIFEST.in`.
343
+
344
+ ## Recent changes
345
+ - `0.1.1`: image observations are now validated before session persistence, preventing broken `ImageMessage` entries from poisoning later turns.
346
+
347
+ ## Safety notes
348
+
349
+ This project is designed to let an AI assistant act on the local machine. That is powerful and potentially risky.
350
+
351
+ Recommended practices:
352
+
353
+ - Use a dedicated runtime directory for experiments.
354
+ - Review tool calls before enabling autonomous workflows.
355
+ - Avoid running the agent with elevated privileges.
356
+ - Keep secrets out of prompts, logs, and committed runtime files.
357
+ - Prefer temporary workfolders in tests and demos.
358
+
359
+ ## License
360
+
361
+ MIT. See [LICENSE](LICENSE).