codexed 0.0.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.
- codexed/README.md +70 -0
- codexed/__init__.py +266 -0
- codexed/client.py +1739 -0
- codexed/example.py +193 -0
- codexed/exceptions.py +28 -0
- codexed/helpers.py +53 -0
- codexed/log.py +25 -0
- codexed/models/__init__.py +765 -0
- codexed/models/base.py +59 -0
- codexed/models/codex_types.py +238 -0
- codexed/models/command_action.py +46 -0
- codexed/models/event_data.py +396 -0
- codexed/models/events.py +590 -0
- codexed/models/mcp_server.py +26 -0
- codexed/models/misc.py +534 -0
- codexed/models/request_params.py +448 -0
- codexed/models/response_item.py +299 -0
- codexed/models/responses.py +291 -0
- codexed/models/thread_item.py +228 -0
- codexed/models/thread_status.py +38 -0
- codexed/models/token_usage.py +31 -0
- codexed/models/tool_config.py +498 -0
- codexed/models/user_input.py +79 -0
- codexed/models/web_search.py +42 -0
- codexed/py.typed +0 -0
- codexed/request_handlers.py +113 -0
- codexed-0.0.1.dist-info/METADATA +60 -0
- codexed-0.0.1.dist-info/RECORD +30 -0
- codexed-0.0.1.dist-info/WHEEL +4 -0
- codexed-0.0.1.dist-info/licenses/LICENSE +22 -0
codexed/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Codex Adapter
|
|
2
|
+
|
|
3
|
+
Python adapter for the [Codex](https://github.com/openai/codex) app-server JSON-RPC protocol.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
import asyncio
|
|
9
|
+
from codexed import CodexClient
|
|
10
|
+
from codexed.models.events import AgentMessageDeltaEvent, TurnCompletedEvent, get_text_delta
|
|
11
|
+
|
|
12
|
+
async def main():
|
|
13
|
+
async with CodexClient() as client:
|
|
14
|
+
session = await client.thread_start(cwd="/path/to/project")
|
|
15
|
+
|
|
16
|
+
async for event in session.turn_stream("Help me refactor this code"):
|
|
17
|
+
match event:
|
|
18
|
+
case AgentMessageDeltaEvent():
|
|
19
|
+
print(get_text_delta(event), end="", flush=True)
|
|
20
|
+
case TurnCompletedEvent():
|
|
21
|
+
break
|
|
22
|
+
|
|
23
|
+
asyncio.run(main())
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Structured Responses
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from pydantic import BaseModel
|
|
30
|
+
|
|
31
|
+
class FileList(BaseModel):
|
|
32
|
+
files: list[str]
|
|
33
|
+
total: int
|
|
34
|
+
|
|
35
|
+
async with CodexClient() as client:
|
|
36
|
+
session = await client.thread_start(cwd=".")
|
|
37
|
+
result = await session.turn_stream_structured(
|
|
38
|
+
"List Python files",
|
|
39
|
+
FileList,
|
|
40
|
+
)
|
|
41
|
+
print(result.files) # Typed result
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Events
|
|
45
|
+
|
|
46
|
+
Events are a discriminated union. Use pattern matching or helper functions:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from codexed.models.events import (
|
|
50
|
+
AgentMessageDeltaEvent,
|
|
51
|
+
CommandExecutionOutputDeltaEvent,
|
|
52
|
+
TurnCompletedEvent,
|
|
53
|
+
TurnErrorEvent,
|
|
54
|
+
get_text_delta,
|
|
55
|
+
is_delta_event,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
async for event in client.turn_stream(thread_id, message):
|
|
59
|
+
match event:
|
|
60
|
+
case AgentMessageDeltaEvent() | CommandExecutionOutputDeltaEvent():
|
|
61
|
+
print(get_text_delta(event), end="")
|
|
62
|
+
case TurnCompletedEvent():
|
|
63
|
+
break
|
|
64
|
+
case TurnErrorEvent(data=data):
|
|
65
|
+
print(f"Error: {data.error}")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## See Also
|
|
69
|
+
|
|
70
|
+
- [Codex app-server docs](https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md)
|
codexed/__init__.py
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"""Codexed: main package.
|
|
2
|
+
|
|
3
|
+
Alternative codex app-server client.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from importlib.metadata import version
|
|
9
|
+
|
|
10
|
+
__version__ = version("codexed")
|
|
11
|
+
__title__ = "Codexed"
|
|
12
|
+
|
|
13
|
+
__author__ = "Philipp Temminghoff"
|
|
14
|
+
__author_email__ = "philipptemminghoff@googlemail.com"
|
|
15
|
+
__copyright__ = "Copyright (c) 2026 Philipp Temminghoff"
|
|
16
|
+
__license__ = "MIT"
|
|
17
|
+
__url__ = "https://github.com/phil65/codexed"
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"__version__",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
from codexed.client import CodexClient, Session
|
|
25
|
+
from codexed.exceptions import CodexError, CodexProcessError, CodexRequestError
|
|
26
|
+
from codexed.models import (
|
|
27
|
+
AgentMessageDeltaData,
|
|
28
|
+
AppInfo,
|
|
29
|
+
AppListUpdatedData,
|
|
30
|
+
CommandExecResponse,
|
|
31
|
+
CommandExecutionOutputDeltaData,
|
|
32
|
+
ConfigWarningData,
|
|
33
|
+
EventData,
|
|
34
|
+
ExperimentalFeature,
|
|
35
|
+
ModelData,
|
|
36
|
+
ModelReroutedData,
|
|
37
|
+
PlanDeltaData,
|
|
38
|
+
ReasoningTextDeltaData,
|
|
39
|
+
ReviewStartResponse,
|
|
40
|
+
SkillData,
|
|
41
|
+
ThreadArchivedData,
|
|
42
|
+
ThreadData,
|
|
43
|
+
ThreadListResponse,
|
|
44
|
+
ThreadNameUpdatedData,
|
|
45
|
+
ThreadReadResponse,
|
|
46
|
+
ThreadResponse,
|
|
47
|
+
ThreadRollbackResponse,
|
|
48
|
+
ThreadStartedData,
|
|
49
|
+
ThreadStatusChangedData,
|
|
50
|
+
ThreadTokenUsage,
|
|
51
|
+
ThreadUnarchivedData,
|
|
52
|
+
ThreadUnarchiveResponse,
|
|
53
|
+
TokenUsageBreakdown,
|
|
54
|
+
TurnCompletedData,
|
|
55
|
+
TurnErrorData,
|
|
56
|
+
TurnStartedData,
|
|
57
|
+
TurnSteerResponse,
|
|
58
|
+
Usage,
|
|
59
|
+
UserInput,
|
|
60
|
+
UserInputImage,
|
|
61
|
+
UserInputLocalImage,
|
|
62
|
+
UserInputMention,
|
|
63
|
+
UserInputSkill,
|
|
64
|
+
UserInputText,
|
|
65
|
+
)
|
|
66
|
+
from codexed.models.codex_types import (
|
|
67
|
+
ApprovalPolicy,
|
|
68
|
+
AskForApproval,
|
|
69
|
+
CollabAgentStatus,
|
|
70
|
+
CollabAgentTool,
|
|
71
|
+
CollabAgentToolCallStatus,
|
|
72
|
+
CollaborationMode,
|
|
73
|
+
CollaborationModeSettings,
|
|
74
|
+
CommandExecutionApprovalDecision,
|
|
75
|
+
CommandExecutionStatus,
|
|
76
|
+
DangerFullAccessSandboxPolicy,
|
|
77
|
+
DynamicToolCallStatus,
|
|
78
|
+
ExternalSandboxPolicy,
|
|
79
|
+
FileChangeApprovalDecision,
|
|
80
|
+
InputModality,
|
|
81
|
+
ItemStatus,
|
|
82
|
+
ItemType,
|
|
83
|
+
McpAuthStatusValue,
|
|
84
|
+
McpToolCallStatus,
|
|
85
|
+
MessagePhase,
|
|
86
|
+
ModeKind,
|
|
87
|
+
ModelProvider,
|
|
88
|
+
ModelRerouteReason,
|
|
89
|
+
NetworkAccess,
|
|
90
|
+
PatchApplyStatus,
|
|
91
|
+
Personality,
|
|
92
|
+
ReadOnlySandboxPolicy,
|
|
93
|
+
ReasoningEffort,
|
|
94
|
+
ReasoningSummary,
|
|
95
|
+
RejectApprovalPolicy,
|
|
96
|
+
RejectConfig,
|
|
97
|
+
ReviewDelivery,
|
|
98
|
+
SandboxMode,
|
|
99
|
+
SandboxPolicy,
|
|
100
|
+
SessionSource,
|
|
101
|
+
SkillApprovalDecision,
|
|
102
|
+
SkillScope,
|
|
103
|
+
ThreadActiveFlag,
|
|
104
|
+
ThreadSortKey,
|
|
105
|
+
ThreadSourceKind,
|
|
106
|
+
TurnStatus,
|
|
107
|
+
WorkspaceWriteSandboxPolicy,
|
|
108
|
+
)
|
|
109
|
+
from codexed.models.events import (
|
|
110
|
+
AgentMessageDeltaEvent,
|
|
111
|
+
AppListUpdatedEvent,
|
|
112
|
+
CodexEvent,
|
|
113
|
+
CommandExecutionOutputDeltaEvent,
|
|
114
|
+
ConfigWarningEvent,
|
|
115
|
+
EventType,
|
|
116
|
+
FileChangeOutputDeltaEvent,
|
|
117
|
+
ItemCompletedEvent,
|
|
118
|
+
ItemStartedEvent,
|
|
119
|
+
ModelReroutedEvent,
|
|
120
|
+
PlanDeltaEvent,
|
|
121
|
+
ReasoningTextDeltaEvent,
|
|
122
|
+
ThreadArchivedEvent,
|
|
123
|
+
ThreadCompactedEvent,
|
|
124
|
+
ThreadNameUpdatedEvent,
|
|
125
|
+
ThreadStartedEvent,
|
|
126
|
+
ThreadStatusChangedEvent,
|
|
127
|
+
ThreadUnarchivedEvent,
|
|
128
|
+
TurnCompletedEvent,
|
|
129
|
+
TurnErrorEvent,
|
|
130
|
+
TurnPlanUpdatedEvent,
|
|
131
|
+
TurnStartedEvent,
|
|
132
|
+
get_text_delta,
|
|
133
|
+
is_completed_event,
|
|
134
|
+
is_delta_event,
|
|
135
|
+
is_error_event,
|
|
136
|
+
)
|
|
137
|
+
from codexed.models.mcp_server import (
|
|
138
|
+
HttpMcpServer,
|
|
139
|
+
McpServerConfig,
|
|
140
|
+
StdioMcpServer,
|
|
141
|
+
)
|
|
142
|
+
from codexed.models.tool_config import (
|
|
143
|
+
BuiltinToolsConfig,
|
|
144
|
+
ToolConfig,
|
|
145
|
+
tools_to_config_dict,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
__all__ = [
|
|
150
|
+
"AgentMessageDeltaData",
|
|
151
|
+
"AgentMessageDeltaEvent",
|
|
152
|
+
"AppInfo",
|
|
153
|
+
"AppListUpdatedData",
|
|
154
|
+
"AppListUpdatedEvent",
|
|
155
|
+
"ApprovalPolicy",
|
|
156
|
+
"AskForApproval",
|
|
157
|
+
"BuiltinToolsConfig",
|
|
158
|
+
"CodexClient",
|
|
159
|
+
"CodexError",
|
|
160
|
+
"CodexEvent",
|
|
161
|
+
"CodexProcessError",
|
|
162
|
+
"CodexRequestError",
|
|
163
|
+
"CollabAgentStatus",
|
|
164
|
+
"CollabAgentTool",
|
|
165
|
+
"CollabAgentToolCallStatus",
|
|
166
|
+
"CollaborationMode",
|
|
167
|
+
"CollaborationModeSettings",
|
|
168
|
+
"CommandExecResponse",
|
|
169
|
+
"CommandExecutionApprovalDecision",
|
|
170
|
+
"CommandExecutionOutputDeltaData",
|
|
171
|
+
"CommandExecutionOutputDeltaEvent",
|
|
172
|
+
"CommandExecutionStatus",
|
|
173
|
+
"ConfigWarningData",
|
|
174
|
+
"ConfigWarningEvent",
|
|
175
|
+
"DangerFullAccessSandboxPolicy",
|
|
176
|
+
"DynamicToolCallStatus",
|
|
177
|
+
"EventData",
|
|
178
|
+
"EventType",
|
|
179
|
+
"ExperimentalFeature",
|
|
180
|
+
"ExternalSandboxPolicy",
|
|
181
|
+
"FileChangeApprovalDecision",
|
|
182
|
+
"FileChangeOutputDeltaEvent",
|
|
183
|
+
"HttpMcpServer",
|
|
184
|
+
"InputModality",
|
|
185
|
+
"ItemCompletedEvent",
|
|
186
|
+
"ItemStartedEvent",
|
|
187
|
+
"ItemStatus",
|
|
188
|
+
"ItemType",
|
|
189
|
+
"McpAuthStatusValue",
|
|
190
|
+
"McpServerConfig",
|
|
191
|
+
"McpToolCallStatus",
|
|
192
|
+
"MessagePhase",
|
|
193
|
+
"ModeKind",
|
|
194
|
+
"ModelData",
|
|
195
|
+
"ModelProvider",
|
|
196
|
+
"ModelRerouteReason",
|
|
197
|
+
"ModelReroutedData",
|
|
198
|
+
"ModelReroutedEvent",
|
|
199
|
+
"NetworkAccess",
|
|
200
|
+
"PatchApplyStatus",
|
|
201
|
+
"Personality",
|
|
202
|
+
"PlanDeltaData",
|
|
203
|
+
"PlanDeltaEvent",
|
|
204
|
+
"ReadOnlySandboxPolicy",
|
|
205
|
+
"ReasoningEffort",
|
|
206
|
+
"ReasoningSummary",
|
|
207
|
+
"ReasoningTextDeltaData",
|
|
208
|
+
"ReasoningTextDeltaEvent",
|
|
209
|
+
"RejectApprovalPolicy",
|
|
210
|
+
"RejectConfig",
|
|
211
|
+
"ReviewDelivery",
|
|
212
|
+
"ReviewStartResponse",
|
|
213
|
+
"SandboxMode",
|
|
214
|
+
"SandboxPolicy",
|
|
215
|
+
"Session",
|
|
216
|
+
"SessionSource",
|
|
217
|
+
"SkillApprovalDecision",
|
|
218
|
+
"SkillData",
|
|
219
|
+
"SkillScope",
|
|
220
|
+
"StdioMcpServer",
|
|
221
|
+
"ThreadActiveFlag",
|
|
222
|
+
"ThreadArchivedData",
|
|
223
|
+
"ThreadArchivedEvent",
|
|
224
|
+
"ThreadCompactedEvent",
|
|
225
|
+
"ThreadData",
|
|
226
|
+
"ThreadListResponse",
|
|
227
|
+
"ThreadNameUpdatedData",
|
|
228
|
+
"ThreadNameUpdatedEvent",
|
|
229
|
+
"ThreadReadResponse",
|
|
230
|
+
"ThreadResponse",
|
|
231
|
+
"ThreadRollbackResponse",
|
|
232
|
+
"ThreadSortKey",
|
|
233
|
+
"ThreadSourceKind",
|
|
234
|
+
"ThreadStartedData",
|
|
235
|
+
"ThreadStartedEvent",
|
|
236
|
+
"ThreadStatusChangedData",
|
|
237
|
+
"ThreadStatusChangedEvent",
|
|
238
|
+
"ThreadTokenUsage",
|
|
239
|
+
"ThreadUnarchiveResponse",
|
|
240
|
+
"ThreadUnarchivedData",
|
|
241
|
+
"ThreadUnarchivedEvent",
|
|
242
|
+
"TokenUsageBreakdown",
|
|
243
|
+
"ToolConfig",
|
|
244
|
+
"TurnCompletedData",
|
|
245
|
+
"TurnCompletedEvent",
|
|
246
|
+
"TurnErrorData",
|
|
247
|
+
"TurnErrorEvent",
|
|
248
|
+
"TurnPlanUpdatedEvent",
|
|
249
|
+
"TurnStartedData",
|
|
250
|
+
"TurnStartedEvent",
|
|
251
|
+
"TurnStatus",
|
|
252
|
+
"TurnSteerResponse",
|
|
253
|
+
"Usage",
|
|
254
|
+
"UserInput",
|
|
255
|
+
"UserInputImage",
|
|
256
|
+
"UserInputLocalImage",
|
|
257
|
+
"UserInputMention",
|
|
258
|
+
"UserInputSkill",
|
|
259
|
+
"UserInputText",
|
|
260
|
+
"WorkspaceWriteSandboxPolicy",
|
|
261
|
+
"get_text_delta",
|
|
262
|
+
"is_completed_event",
|
|
263
|
+
"is_delta_event",
|
|
264
|
+
"is_error_event",
|
|
265
|
+
"tools_to_config_dict",
|
|
266
|
+
]
|