codex-agent-framework 0.1.1__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.
- codex_agent/__init__.py +38 -0
- codex_agent/__main__.py +18 -0
- codex_agent/agent.py +1179 -0
- codex_agent/ai.py +494 -0
- codex_agent/builtin_commands.py +136 -0
- codex_agent/builtin_providers.py +42 -0
- codex_agent/builtin_tools.py +418 -0
- codex_agent/chat.py +139 -0
- codex_agent/command.py +19 -0
- codex_agent/event.py +136 -0
- codex_agent/get_text/__init__.py +20 -0
- codex_agent/get_text/default_gitignore +110 -0
- codex_agent/get_text/get_text.py +1240 -0
- codex_agent/get_text/simpler_get_text.py +184 -0
- codex_agent/get_webdriver.py +44 -0
- codex_agent/image.py +304 -0
- codex_agent/latex.py +165 -0
- codex_agent/memory.py +318 -0
- codex_agent/message.py +423 -0
- codex_agent/prompts/image_generation_system_prompt.txt +13 -0
- codex_agent/prompts/system_prompt.txt +88 -0
- codex_agent/provider.py +19 -0
- codex_agent/stream_utils.py +645 -0
- codex_agent/tool.py +235 -0
- codex_agent/utils.py +374 -0
- codex_agent/voice.py +353 -0
- codex_agent/worker.py +190 -0
- codex_agent_framework-0.1.1.dist-info/METADATA +361 -0
- codex_agent_framework-0.1.1.dist-info/RECORD +33 -0
- codex_agent_framework-0.1.1.dist-info/WHEEL +5 -0
- codex_agent_framework-0.1.1.dist-info/entry_points.txt +2 -0
- codex_agent_framework-0.1.1.dist-info/licenses/LICENSE +21 -0
- codex_agent_framework-0.1.1.dist-info/top_level.txt +1 -0
codex_agent/event.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
from modict import modict
|
|
2
|
+
from .utils import snake_case_type, timestamp
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AgentInterrupted(Exception):
|
|
6
|
+
"""Raised internally when the current agent turn is interrupted."""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Event(modict):
|
|
10
|
+
"""Base runtime event."""
|
|
11
|
+
|
|
12
|
+
timestamp = modict.factory(lambda: timestamp())
|
|
13
|
+
|
|
14
|
+
def __init__(self, *args, **kwargs):
|
|
15
|
+
super().__init__(*args, **kwargs)
|
|
16
|
+
self['type'] = snake_case_type(type(self))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ResponseStartEvent(Event):
|
|
20
|
+
message = None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ResponseContentDeltaEvent(Event):
|
|
24
|
+
delta = ''
|
|
25
|
+
content = ''
|
|
26
|
+
chunk = None
|
|
27
|
+
message = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ResponseReasoningDeltaEvent(Event):
|
|
31
|
+
delta = ''
|
|
32
|
+
reasoning = ''
|
|
33
|
+
chunk = None
|
|
34
|
+
message = None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ResponseToolCallsDeltaEvent(Event):
|
|
38
|
+
tool_calls = None
|
|
39
|
+
chunk = None
|
|
40
|
+
message = None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ResponseOutputItemEvent(Event):
|
|
44
|
+
item = None
|
|
45
|
+
chunk = None
|
|
46
|
+
message = None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class ResponseMessageDeltaEvent(Event):
|
|
50
|
+
chunk = None
|
|
51
|
+
message = None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ResponseDoneEvent(Event):
|
|
55
|
+
message = None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class MessageAddedEvent(Event):
|
|
59
|
+
message = None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class ToolCallStartEvent(Event):
|
|
63
|
+
tool_call = None
|
|
64
|
+
tool = None
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class ToolCallDoneEvent(Event):
|
|
68
|
+
tool_call = None
|
|
69
|
+
tool = None
|
|
70
|
+
content = ''
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class ServerToolCallEvent(Event):
|
|
74
|
+
item = None
|
|
75
|
+
tool = None
|
|
76
|
+
name = ''
|
|
77
|
+
call_id = ''
|
|
78
|
+
status = ''
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class AgentInterruptedEvent(Event):
|
|
82
|
+
reason = ''
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class AudioPlaybackEvent(Event):
|
|
86
|
+
audio = None
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class EventBus:
|
|
90
|
+
"""Small synchronous event bus with decorator registration."""
|
|
91
|
+
|
|
92
|
+
def __init__(self):
|
|
93
|
+
self.handlers = {}
|
|
94
|
+
|
|
95
|
+
def event_type(self, event):
|
|
96
|
+
if event == '*':
|
|
97
|
+
return event
|
|
98
|
+
if isinstance(event, type) and issubclass(event, Event):
|
|
99
|
+
return snake_case_type(event)
|
|
100
|
+
if isinstance(event, Event):
|
|
101
|
+
return event.type
|
|
102
|
+
raise TypeError(f"Expected Event subclass, Event instance, or '*', got {type(event).__name__}")
|
|
103
|
+
|
|
104
|
+
def on(self, event, handler=None):
|
|
105
|
+
event_type = self.event_type(event)
|
|
106
|
+
if handler is None:
|
|
107
|
+
def decorator(func):
|
|
108
|
+
self.handlers.setdefault(event_type, []).append(func)
|
|
109
|
+
return func
|
|
110
|
+
return decorator
|
|
111
|
+
|
|
112
|
+
self.handlers.setdefault(event_type, []).append(handler)
|
|
113
|
+
return handler
|
|
114
|
+
|
|
115
|
+
def off(self, event, handler):
|
|
116
|
+
handlers = self.handlers.get(self.event_type(event))
|
|
117
|
+
if handlers and handler in handlers:
|
|
118
|
+
handlers.remove(handler)
|
|
119
|
+
return handler
|
|
120
|
+
|
|
121
|
+
def has_handlers(self, event):
|
|
122
|
+
event_type = self.event_type(event)
|
|
123
|
+
return bool(self.handlers.get(event_type) or self.handlers.get('*'))
|
|
124
|
+
|
|
125
|
+
def emit(self, event, **data):
|
|
126
|
+
if isinstance(event, type) and issubclass(event, Event):
|
|
127
|
+
event = event(**data)
|
|
128
|
+
elif not isinstance(event, Event):
|
|
129
|
+
raise TypeError(f"Expected Event subclass or Event instance, got {type(event).__name__}")
|
|
130
|
+
|
|
131
|
+
event_type = event.type
|
|
132
|
+
for handler in self.handlers.get(event_type, ()):
|
|
133
|
+
handler(event)
|
|
134
|
+
for handler in self.handlers.get('*', ()):
|
|
135
|
+
handler(event)
|
|
136
|
+
return event
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
def get_text(source, **kwargs):
|
|
3
|
+
"""Get text from a source using the full or simpler implementation.
|
|
4
|
+
|
|
5
|
+
Args:
|
|
6
|
+
source: The source to get text from.
|
|
7
|
+
**kwargs: Additional keyword arguments.
|
|
8
|
+
Returns:
|
|
9
|
+
Text content from the source.
|
|
10
|
+
"""
|
|
11
|
+
# Try to import full get_text with all document processing capabilities
|
|
12
|
+
# Fall back to simpler version if dependencies are missing
|
|
13
|
+
try:
|
|
14
|
+
from importlib import import_module
|
|
15
|
+
get_text_func = import_module(".get_text", __package__).get_text
|
|
16
|
+
except ImportError:
|
|
17
|
+
from importlib import import_module
|
|
18
|
+
get_text_func = import_module(".simpler_get_text", __package__).get_text
|
|
19
|
+
|
|
20
|
+
return get_text_func(source, **kwargs)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Default exclusions for get_text directory scanning
|
|
2
|
+
# This file contains sensible defaults to avoid scanning junk directories
|
|
3
|
+
|
|
4
|
+
# Version Control
|
|
5
|
+
.git/
|
|
6
|
+
.svn/
|
|
7
|
+
.hg/
|
|
8
|
+
.bzr/
|
|
9
|
+
|
|
10
|
+
# Python
|
|
11
|
+
__pycache__/
|
|
12
|
+
*.py[cod]
|
|
13
|
+
*$py.class
|
|
14
|
+
*.so
|
|
15
|
+
.Python
|
|
16
|
+
build/
|
|
17
|
+
develop-eggs/
|
|
18
|
+
dist/
|
|
19
|
+
downloads/
|
|
20
|
+
eggs/
|
|
21
|
+
.eggs/
|
|
22
|
+
lib/
|
|
23
|
+
lib64/
|
|
24
|
+
parts/
|
|
25
|
+
sdist/
|
|
26
|
+
var/
|
|
27
|
+
wheels/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
.installed.cfg
|
|
30
|
+
*.egg
|
|
31
|
+
.pytest_cache/
|
|
32
|
+
.mypy_cache/
|
|
33
|
+
.dmypy.json
|
|
34
|
+
dmypy.json
|
|
35
|
+
.ruff_cache/
|
|
36
|
+
.pytype/
|
|
37
|
+
.coverage
|
|
38
|
+
htmlcov/
|
|
39
|
+
.tox/
|
|
40
|
+
.nox/
|
|
41
|
+
|
|
42
|
+
# Node.js / JavaScript
|
|
43
|
+
node_modules/
|
|
44
|
+
npm-debug.log*
|
|
45
|
+
yarn-debug.log*
|
|
46
|
+
yarn-error.log*
|
|
47
|
+
.npm/
|
|
48
|
+
.yarn/
|
|
49
|
+
bower_components/
|
|
50
|
+
|
|
51
|
+
# IDEs and Editors
|
|
52
|
+
.vscode/
|
|
53
|
+
.idea/
|
|
54
|
+
*.swp
|
|
55
|
+
*.swo
|
|
56
|
+
*~
|
|
57
|
+
.DS_Store
|
|
58
|
+
|
|
59
|
+
# Build artifacts
|
|
60
|
+
*.o
|
|
61
|
+
*.obj
|
|
62
|
+
*.exe
|
|
63
|
+
*.dll
|
|
64
|
+
*.so
|
|
65
|
+
*.dylib
|
|
66
|
+
*.class
|
|
67
|
+
*.jar
|
|
68
|
+
*.war
|
|
69
|
+
*.ear
|
|
70
|
+
target/
|
|
71
|
+
out/
|
|
72
|
+
cmake-build-*/
|
|
73
|
+
|
|
74
|
+
# Logs and databases
|
|
75
|
+
*.log
|
|
76
|
+
*.sql
|
|
77
|
+
*.sqlite
|
|
78
|
+
*.db
|
|
79
|
+
|
|
80
|
+
# OS
|
|
81
|
+
Thumbs.db
|
|
82
|
+
.Spotlight-V100
|
|
83
|
+
.Trashes
|
|
84
|
+
|
|
85
|
+
# Temporary files
|
|
86
|
+
tmp/
|
|
87
|
+
temp/
|
|
88
|
+
*.tmp
|
|
89
|
+
*.temp
|
|
90
|
+
*.cache
|
|
91
|
+
|
|
92
|
+
# Virtual environments
|
|
93
|
+
venv/
|
|
94
|
+
env/
|
|
95
|
+
ENV/
|
|
96
|
+
virtualenv/
|
|
97
|
+
.venv/
|
|
98
|
+
|
|
99
|
+
# Package managers
|
|
100
|
+
vendor/
|
|
101
|
+
.bundle/
|
|
102
|
+
|
|
103
|
+
# Documentation builds
|
|
104
|
+
docs/_build/
|
|
105
|
+
site/
|
|
106
|
+
_site/
|
|
107
|
+
|
|
108
|
+
# Compiled documentation
|
|
109
|
+
*.pdf
|
|
110
|
+
*.epub
|