codexed 1.2.1__tar.gz → 1.2.6__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.
- {codexed-1.2.1 → codexed-1.2.6}/PKG-INFO +1 -1
- codexed-1.2.6/pyproject.toml +293 -0
- codexed-1.2.1/pyproject.toml → codexed-1.2.6/pyproject.toml.orig +3 -1
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/README.md +9 -3
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/__init__.py +2 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/client.py +49 -2
- codexed-1.2.6/src/codexed/client/device.py +67 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/marketplace.py +8 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/realtime.py +1 -1
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/session.py +32 -3
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/__init__.py +8 -6
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/mcp_server.py +4 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/misc.py +116 -1
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/request_params.py +25 -9
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/responses.py +24 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/thread_item.py +2 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/v2_protocol.py +623 -21
- {codexed-1.2.1 → codexed-1.2.6}/LICENSE +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/README.md +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/__init__.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/account.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/dispatch.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/fs.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/plugin.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/client/skills.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/exceptions.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/helpers.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/log.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/base.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/codex_types.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/event_data.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/events.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/models/tool_config.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/py.typed +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/request_handlers.py +0 -0
- {codexed-1.2.1 → codexed-1.2.6}/src/codexed/transport.py +0 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "codexed"
|
|
3
|
+
version = "1.2.6"
|
|
4
|
+
description = "Alternative codex app-server client"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
keywords = []
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 4 - Beta",
|
|
12
|
+
"Framework :: Pydantic",
|
|
13
|
+
"Framework :: Pydantic :: 2",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
21
|
+
"Topic :: Documentation",
|
|
22
|
+
"Topic :: Software Development",
|
|
23
|
+
"Topic :: Utilities",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"anyenv>=2.0.15",
|
|
28
|
+
"mcp>=1.27.0",
|
|
29
|
+
"pydantic",
|
|
30
|
+
"schemez",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[[project.authors]]
|
|
34
|
+
name = "Philipp Temminghoff"
|
|
35
|
+
email = "philipptemminghoff@googlemail.com"
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
"Code coverage" = "https://app.codecov.io/gh/phil65/codexed"
|
|
39
|
+
Discussions = "https://github.com/phil65/codexed/discussions"
|
|
40
|
+
Documentation = "https://phil65.github.io/codexed/"
|
|
41
|
+
Issues = "https://github.com/phil65/codexed/issues"
|
|
42
|
+
Source = "https://github.com/phil65/codexed"
|
|
43
|
+
|
|
44
|
+
[project.optional-dependencies]
|
|
45
|
+
websocket = ["websockets>=13.0"]
|
|
46
|
+
|
|
47
|
+
[dependency-groups]
|
|
48
|
+
dev = [
|
|
49
|
+
"devtools",
|
|
50
|
+
"pyreadline3",
|
|
51
|
+
"pytest",
|
|
52
|
+
"pytest-cov",
|
|
53
|
+
"pytest-asyncio>=1.5.0",
|
|
54
|
+
]
|
|
55
|
+
benchmark = ["pyinstrument"]
|
|
56
|
+
docs = [
|
|
57
|
+
"mkdocs-material",
|
|
58
|
+
"mkdocs-mknodes",
|
|
59
|
+
]
|
|
60
|
+
lint = [
|
|
61
|
+
"mypy; python_version >= '3.14'",
|
|
62
|
+
"mypy[faster-cache]; python_version < '3.14'",
|
|
63
|
+
"ruff",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
[build-system]
|
|
67
|
+
requires = ["uv_build>=0.8.22"]
|
|
68
|
+
build-backend = "uv_build"
|
|
69
|
+
|
|
70
|
+
[tool.coverage.report]
|
|
71
|
+
exclude_lines = [
|
|
72
|
+
"pragma: no cover",
|
|
73
|
+
"if TYPE_CHECKING:",
|
|
74
|
+
"@overload",
|
|
75
|
+
"except ImportError",
|
|
76
|
+
'if __name__ == "__main__":',
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[tool.mknodes]
|
|
80
|
+
allowed-commit-types = [
|
|
81
|
+
"fix",
|
|
82
|
+
"feat",
|
|
83
|
+
"refactor",
|
|
84
|
+
"docs",
|
|
85
|
+
"test",
|
|
86
|
+
"build",
|
|
87
|
+
"chore",
|
|
88
|
+
]
|
|
89
|
+
docstring-style = "google"
|
|
90
|
+
|
|
91
|
+
[tool.mypy]
|
|
92
|
+
python_version = "3.13"
|
|
93
|
+
disable_error_code = [
|
|
94
|
+
"misc",
|
|
95
|
+
"import",
|
|
96
|
+
]
|
|
97
|
+
pretty = true
|
|
98
|
+
check_untyped_defs = true
|
|
99
|
+
exclude = [
|
|
100
|
+
"venv/",
|
|
101
|
+
".venv/",
|
|
102
|
+
"src/codexed/models/v2_protocol.py",
|
|
103
|
+
]
|
|
104
|
+
plugins = ["pydantic.mypy"]
|
|
105
|
+
|
|
106
|
+
[tool.pyright]
|
|
107
|
+
venvPath = "."
|
|
108
|
+
venv = ".venv"
|
|
109
|
+
pythonVersion = "3.13"
|
|
110
|
+
pythonPlatform = "All"
|
|
111
|
+
typeCheckingMode = "basic"
|
|
112
|
+
deprecateTypingAliases = true
|
|
113
|
+
reportMissingTypeStubs = false
|
|
114
|
+
reportUnusedCallResult = false
|
|
115
|
+
reportUnknownVariableType = false
|
|
116
|
+
reportAny = false
|
|
117
|
+
reportImplicitOverride = false
|
|
118
|
+
reportUnusedFunction = false
|
|
119
|
+
reportImplicitStringConcatenation = false
|
|
120
|
+
reportIgnoreCommentWithoutRule = false
|
|
121
|
+
reportUnannotatedClassAttribute = false
|
|
122
|
+
reportSelfClsParameterName = false
|
|
123
|
+
reportPrivateImportUsage = false
|
|
124
|
+
|
|
125
|
+
[tool.pytest]
|
|
126
|
+
log_cli = true
|
|
127
|
+
log_date_format = "%Y-%m-%d %H:%M:%S"
|
|
128
|
+
log_format = "%(asctime)s %(levelname)s %(message)s"
|
|
129
|
+
minversion = "9.0"
|
|
130
|
+
testpaths = ["tests/"]
|
|
131
|
+
asyncio_mode = "auto"
|
|
132
|
+
|
|
133
|
+
[tool.ruff]
|
|
134
|
+
line-length = 100
|
|
135
|
+
extend-exclude = [
|
|
136
|
+
"docs",
|
|
137
|
+
"src/codexed/models/v2_protocol.py",
|
|
138
|
+
]
|
|
139
|
+
target-version = "py313"
|
|
140
|
+
|
|
141
|
+
[tool.ruff.lint]
|
|
142
|
+
future-annotations = true
|
|
143
|
+
select = [
|
|
144
|
+
"A",
|
|
145
|
+
"B",
|
|
146
|
+
"BLE",
|
|
147
|
+
"C",
|
|
148
|
+
"C4",
|
|
149
|
+
"COM",
|
|
150
|
+
"D",
|
|
151
|
+
"E",
|
|
152
|
+
"EM",
|
|
153
|
+
"EXE",
|
|
154
|
+
"F",
|
|
155
|
+
"FA",
|
|
156
|
+
"FLY",
|
|
157
|
+
"G",
|
|
158
|
+
"I",
|
|
159
|
+
"ICN",
|
|
160
|
+
"INP",
|
|
161
|
+
"INT",
|
|
162
|
+
"ISC",
|
|
163
|
+
"N",
|
|
164
|
+
"PERF",
|
|
165
|
+
"PIE",
|
|
166
|
+
"PLE",
|
|
167
|
+
"PLC",
|
|
168
|
+
"PLR",
|
|
169
|
+
"PT",
|
|
170
|
+
"PTH",
|
|
171
|
+
"PYI",
|
|
172
|
+
"Q",
|
|
173
|
+
"RET",
|
|
174
|
+
"RSE",
|
|
175
|
+
"RUF",
|
|
176
|
+
"SIM",
|
|
177
|
+
"SLF",
|
|
178
|
+
"SLOT",
|
|
179
|
+
"T10",
|
|
180
|
+
"TC",
|
|
181
|
+
"TID",
|
|
182
|
+
"TRY",
|
|
183
|
+
"UP",
|
|
184
|
+
"W",
|
|
185
|
+
"YTT",
|
|
186
|
+
]
|
|
187
|
+
ignore = [
|
|
188
|
+
"C408",
|
|
189
|
+
"B905",
|
|
190
|
+
"C901",
|
|
191
|
+
"COM812",
|
|
192
|
+
"D100",
|
|
193
|
+
"D101",
|
|
194
|
+
"D102",
|
|
195
|
+
"D103",
|
|
196
|
+
"D104",
|
|
197
|
+
"D105",
|
|
198
|
+
"D106",
|
|
199
|
+
"D107",
|
|
200
|
+
"D203",
|
|
201
|
+
"D204",
|
|
202
|
+
"D213",
|
|
203
|
+
"D215",
|
|
204
|
+
"D400",
|
|
205
|
+
"D401",
|
|
206
|
+
"D404",
|
|
207
|
+
"D406",
|
|
208
|
+
"D407",
|
|
209
|
+
"D408",
|
|
210
|
+
"D409",
|
|
211
|
+
"D413",
|
|
212
|
+
"EM101",
|
|
213
|
+
"EM102",
|
|
214
|
+
"ISC001",
|
|
215
|
+
"PLC0415",
|
|
216
|
+
"PLR0912",
|
|
217
|
+
"PLR0913",
|
|
218
|
+
"PLR0917",
|
|
219
|
+
"PLR0915",
|
|
220
|
+
"SLF001",
|
|
221
|
+
"TRY003",
|
|
222
|
+
"TC006",
|
|
223
|
+
]
|
|
224
|
+
|
|
225
|
+
[tool.ruff.lint.flake8-quotes]
|
|
226
|
+
docstring-quotes = "double"
|
|
227
|
+
|
|
228
|
+
[tool.ruff.lint.flake8-type-checking]
|
|
229
|
+
runtime-evaluated-base-classes = [
|
|
230
|
+
"pydantic.BaseModel",
|
|
231
|
+
"sqlalchemy.orm.DeclarativeBase",
|
|
232
|
+
"schemez.Schema",
|
|
233
|
+
"sqlmodel.SQLModel",
|
|
234
|
+
"codexed.models.base.CodexBaseModel",
|
|
235
|
+
]
|
|
236
|
+
runtime-evaluated-decorators = [
|
|
237
|
+
"pydantic.validate_call",
|
|
238
|
+
"fastapi.FastAPI.get",
|
|
239
|
+
"fastapi.FastAPI.post",
|
|
240
|
+
"fastmcp.FastMCP.tool",
|
|
241
|
+
"typer.Typer.command",
|
|
242
|
+
]
|
|
243
|
+
|
|
244
|
+
[tool.ruff.lint.isort]
|
|
245
|
+
lines-after-imports = 2
|
|
246
|
+
force-sort-within-sections = true
|
|
247
|
+
combine-as-imports = true
|
|
248
|
+
|
|
249
|
+
[tool.ruff.lint.mccabe]
|
|
250
|
+
max-complexity = 15
|
|
251
|
+
|
|
252
|
+
[tool.ruff.lint.per-file-ignores]
|
|
253
|
+
"__init__.py" = [
|
|
254
|
+
"E402",
|
|
255
|
+
"I001",
|
|
256
|
+
]
|
|
257
|
+
"scripts/*" = ["INP001"]
|
|
258
|
+
"*tests/*" = ["D100"]
|
|
259
|
+
|
|
260
|
+
[tool.ruff.format]
|
|
261
|
+
preview = true
|
|
262
|
+
|
|
263
|
+
[tool.ty.src]
|
|
264
|
+
exclude = ["src/codexed/models/v2_protocol.py"]
|
|
265
|
+
|
|
266
|
+
[tool.ty.environment]
|
|
267
|
+
python-version = "3.13"
|
|
268
|
+
python-platform = "all"
|
|
269
|
+
|
|
270
|
+
[tool.uv]
|
|
271
|
+
default-groups = [
|
|
272
|
+
"dev",
|
|
273
|
+
"lint",
|
|
274
|
+
"docs",
|
|
275
|
+
]
|
|
276
|
+
|
|
277
|
+
[tool.uv.build-backend]
|
|
278
|
+
wheel-exclude = [
|
|
279
|
+
".mypy_cache/**",
|
|
280
|
+
"__pycache__/**",
|
|
281
|
+
"*.pyc",
|
|
282
|
+
"*.pyo",
|
|
283
|
+
".pytest_cache/**",
|
|
284
|
+
".ruff_cache/**",
|
|
285
|
+
]
|
|
286
|
+
source-exclude = [
|
|
287
|
+
".mypy_cache/**",
|
|
288
|
+
"__pycache__/**",
|
|
289
|
+
"*.pyc",
|
|
290
|
+
"*.pyo",
|
|
291
|
+
".pytest_cache/**",
|
|
292
|
+
".ruff_cache/**",
|
|
293
|
+
]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[project]
|
|
4
4
|
name = "codexed"
|
|
5
|
-
version = "1.2.
|
|
5
|
+
version = "1.2.6"
|
|
6
6
|
description = "Alternative codex app-server client"
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
requires-python = ">=3.13"
|
|
@@ -53,6 +53,7 @@ dev = [
|
|
|
53
53
|
"pytest",
|
|
54
54
|
"pytest-cov",
|
|
55
55
|
# Only add below (Copier)
|
|
56
|
+
"pytest-asyncio>=1.5.0",
|
|
56
57
|
]
|
|
57
58
|
benchmark = ["pyinstrument"]
|
|
58
59
|
docs = [
|
|
@@ -227,6 +228,7 @@ ignore = [
|
|
|
227
228
|
"PLC0415",
|
|
228
229
|
"PLR0912", # Too many branches
|
|
229
230
|
"PLR0913", # Too many arguments to function call
|
|
231
|
+
"PLR0917", # Too many positional arguments
|
|
230
232
|
"PLR0915", # Too many statements
|
|
231
233
|
# "PLR2004", # Magic values instead of named consts
|
|
232
234
|
"SLF001", # Private member accessed
|
|
@@ -9,10 +9,11 @@ import asyncio
|
|
|
9
9
|
from codexed import CodexClient
|
|
10
10
|
from codexed.models import ItemAgentMessageDeltaNotification, TurnCompletedEvent
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
async def main():
|
|
13
14
|
async with CodexClient() as client:
|
|
14
15
|
session = await client.thread_start(cwd="/path/to/project")
|
|
15
|
-
|
|
16
|
+
|
|
16
17
|
async for event in session.turn_stream("Help me refactor this code"):
|
|
17
18
|
match event:
|
|
18
19
|
case ItemAgentMessageDeltaNotification(data=data):
|
|
@@ -20,6 +21,7 @@ async def main():
|
|
|
20
21
|
case TurnCompletedEvent():
|
|
21
22
|
break
|
|
22
23
|
|
|
24
|
+
|
|
23
25
|
asyncio.run(main())
|
|
24
26
|
```
|
|
25
27
|
|
|
@@ -28,10 +30,12 @@ asyncio.run(main())
|
|
|
28
30
|
```python
|
|
29
31
|
from pydantic import BaseModel
|
|
30
32
|
|
|
33
|
+
|
|
31
34
|
class FileList(BaseModel):
|
|
32
35
|
files: list[str]
|
|
33
36
|
total: int
|
|
34
37
|
|
|
38
|
+
|
|
35
39
|
async with CodexClient() as client:
|
|
36
40
|
session = await client.thread_start(cwd=".")
|
|
37
41
|
result = await session.turn_stream_structured(
|
|
@@ -54,11 +58,13 @@ from codexed.models import (
|
|
|
54
58
|
|
|
55
59
|
async for event in session.turn_stream(message):
|
|
56
60
|
match event:
|
|
57
|
-
case
|
|
61
|
+
case (
|
|
62
|
+
ItemAgentMessageDeltaNotification(data=data)
|
|
63
|
+
| ItemCommandExecutionOutputDeltaNotification(data=data)
|
|
64
|
+
):
|
|
58
65
|
print(data.delta, end="")
|
|
59
66
|
case TurnCompletedEvent():
|
|
60
67
|
break
|
|
61
|
-
|
|
62
68
|
```
|
|
63
69
|
|
|
64
70
|
## See Also
|
|
@@ -5,11 +5,13 @@ from .fs import CodexFS
|
|
|
5
5
|
from .skills import CodexSkills
|
|
6
6
|
from .plugin import CodexPlugin
|
|
7
7
|
from .marketplace import CodexMarketPlace
|
|
8
|
+
from .device import CodexDevice
|
|
8
9
|
from .realtime import RealtimeSession
|
|
9
10
|
from .session import Session
|
|
10
11
|
|
|
11
12
|
__all__ = [
|
|
12
13
|
"CodexClient",
|
|
14
|
+
"CodexDevice",
|
|
13
15
|
"CodexFS",
|
|
14
16
|
"CodexMarketPlace",
|
|
15
17
|
"CodexPlugin",
|
|
@@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, Any
|
|
|
10
10
|
from pydantic import TypeAdapter
|
|
11
11
|
|
|
12
12
|
from codexed.client.account import CodexAccount
|
|
13
|
+
from codexed.client.device import CodexDevice
|
|
13
14
|
from codexed.client.dispatch import Dispatch
|
|
14
15
|
from codexed.client.fs import CodexFS
|
|
15
16
|
from codexed.client.marketplace import CodexMarketPlace
|
|
@@ -37,6 +38,8 @@ from codexed.models import (
|
|
|
37
38
|
FeedbackUploadResponse,
|
|
38
39
|
ListMcpServerStatusParams,
|
|
39
40
|
ListMcpServerStatusResponse,
|
|
41
|
+
McpResourceReadParams,
|
|
42
|
+
McpResourceReadResponse,
|
|
40
43
|
McpServerOauthLoginParams,
|
|
41
44
|
McpServerOauthLoginResponse,
|
|
42
45
|
MemoryResetResponse,
|
|
@@ -50,9 +53,10 @@ from codexed.models import (
|
|
|
50
53
|
ThreadResponse,
|
|
51
54
|
ThreadResumeParams,
|
|
52
55
|
ThreadStartParams,
|
|
56
|
+
WarningNotification,
|
|
53
57
|
codex_event_adapter,
|
|
54
58
|
)
|
|
55
|
-
from codexed.models.
|
|
59
|
+
from codexed.models.mcp_server import ResourceContents
|
|
56
60
|
from codexed.request_handlers import (
|
|
57
61
|
SERVER_REQUEST_COMMAND_APPROVAL,
|
|
58
62
|
SERVER_REQUEST_DYNAMIC_TOOL_CALL,
|
|
@@ -69,6 +73,8 @@ from codexed.transport import StdioTransport
|
|
|
69
73
|
if TYPE_CHECKING:
|
|
70
74
|
from typing import Self
|
|
71
75
|
|
|
76
|
+
from pydantic import BaseModel
|
|
77
|
+
|
|
72
78
|
from codexed.client.session import Session
|
|
73
79
|
from codexed.models import (
|
|
74
80
|
AppInfo,
|
|
@@ -84,6 +90,7 @@ if TYPE_CHECKING:
|
|
|
84
90
|
McpServerConfig,
|
|
85
91
|
McpServerStatusDetail,
|
|
86
92
|
MergeStrategy,
|
|
93
|
+
PermissionProfile,
|
|
87
94
|
Personality,
|
|
88
95
|
SandboxMode,
|
|
89
96
|
SandboxPolicy,
|
|
@@ -93,7 +100,9 @@ if TYPE_CHECKING:
|
|
|
93
100
|
ThreadSourceKind,
|
|
94
101
|
ThreadStartSource,
|
|
95
102
|
ToolConfig,
|
|
103
|
+
TurnEnvironmentParams,
|
|
96
104
|
)
|
|
105
|
+
from codexed.models.v2_protocol import ThreadListCwdFilter
|
|
97
106
|
from codexed.request_handlers import (
|
|
98
107
|
ApprovalHandler,
|
|
99
108
|
DynamicToolCallHandler,
|
|
@@ -175,6 +184,7 @@ class CodexClient:
|
|
|
175
184
|
self._server_request_handlers: dict[str, ServerRequestHandler] = {}
|
|
176
185
|
self.account = CodexAccount(self)
|
|
177
186
|
self.fs = CodexFS(self)
|
|
187
|
+
self.device = CodexDevice(self)
|
|
178
188
|
self.plugins = CodexPlugin(self)
|
|
179
189
|
self.marketplace = CodexMarketPlace(self)
|
|
180
190
|
self.skills = CodexSkills(self)
|
|
@@ -234,6 +244,7 @@ class CodexClient:
|
|
|
234
244
|
experimental_raw_events: bool = False,
|
|
235
245
|
persist_extended_history: bool = False,
|
|
236
246
|
session_start_source: ThreadStartSource | None = None,
|
|
247
|
+
environments: list[TurnEnvironmentParams] | None = None,
|
|
237
248
|
) -> Session:
|
|
238
249
|
"""Start a new conversation thread.
|
|
239
250
|
|
|
@@ -261,6 +272,7 @@ class CodexClient:
|
|
|
261
272
|
experimental_raw_events: Emit raw Responses API items (internal)
|
|
262
273
|
persist_extended_history: Persist full history for resume/fork/read
|
|
263
274
|
session_start_source: Source of the session start
|
|
275
|
+
environments: List of environment variables to set for the thread
|
|
264
276
|
|
|
265
277
|
Returns:
|
|
266
278
|
Session wrapping the new thread
|
|
@@ -292,6 +304,7 @@ class CodexClient:
|
|
|
292
304
|
experimental_raw_events=experimental_raw_events,
|
|
293
305
|
persist_extended_history=persist_extended_history,
|
|
294
306
|
session_start_source=session_start_source,
|
|
307
|
+
environments=environments,
|
|
295
308
|
)
|
|
296
309
|
result = await self.dispatch.send_request("thread/start", params)
|
|
297
310
|
response = ThreadResponse.model_validate(result)
|
|
@@ -318,6 +331,8 @@ class CodexClient:
|
|
|
318
331
|
personality: Personality | None = None,
|
|
319
332
|
mcp_servers: Mapping[str, McpServerConfig] | None = None,
|
|
320
333
|
persist_extended_history: bool = False,
|
|
334
|
+
exclude_turns: bool | None = None,
|
|
335
|
+
permission_profile: PermissionProfile | None = None,
|
|
321
336
|
) -> Session:
|
|
322
337
|
"""Resume an existing thread by ID.
|
|
323
338
|
|
|
@@ -339,6 +354,8 @@ class CodexClient:
|
|
|
339
354
|
personality: Personality override
|
|
340
355
|
mcp_servers: Per-thread MCP server configurations
|
|
341
356
|
persist_extended_history: Persist full history for resume/fork/read
|
|
357
|
+
exclude_turns: If true, exclude turns from the thread's history
|
|
358
|
+
permission_profile: Permission profile override
|
|
342
359
|
|
|
343
360
|
Returns:
|
|
344
361
|
Session wrapping the resumed thread
|
|
@@ -367,6 +384,8 @@ class CodexClient:
|
|
|
367
384
|
service_tier=service_tier,
|
|
368
385
|
personality=personality,
|
|
369
386
|
persist_extended_history=persist_extended_history,
|
|
387
|
+
exclude_turns=exclude_turns,
|
|
388
|
+
permission_profile=permission_profile,
|
|
370
389
|
)
|
|
371
390
|
result = await self.dispatch.send_request("thread/resume", params)
|
|
372
391
|
response = ThreadResponse.model_validate(result)
|
|
@@ -394,6 +413,8 @@ class CodexClient:
|
|
|
394
413
|
mcp_servers: Mapping[str, McpServerConfig] | None = None,
|
|
395
414
|
turn_id: str | None = None,
|
|
396
415
|
persist_extended_history: bool = False,
|
|
416
|
+
exclude_turns: bool | None = None,
|
|
417
|
+
permission_profile: PermissionProfile | None = None,
|
|
397
418
|
) -> Session:
|
|
398
419
|
"""Fork an existing thread into a new thread with copied history.
|
|
399
420
|
|
|
@@ -417,6 +438,10 @@ class CodexClient:
|
|
|
417
438
|
mcp_servers: Per-thread MCP server configurations
|
|
418
439
|
turn_id: If provided, rollback the forked thread to this turn
|
|
419
440
|
persist_extended_history: Persist full history for resume/fork/read
|
|
441
|
+
exclude_turns: When true, return only thread metadata and live fork state
|
|
442
|
+
without populating `thread.turns`. This is useful when
|
|
443
|
+
the client plans to call `thread/turns/list` immediately after forking.
|
|
444
|
+
permission_profile: Permission profile for forked thread
|
|
420
445
|
|
|
421
446
|
Returns:
|
|
422
447
|
Session wrapping the new forked thread
|
|
@@ -445,6 +470,8 @@ class CodexClient:
|
|
|
445
470
|
service_tier=service_tier,
|
|
446
471
|
ephemeral=ephemeral,
|
|
447
472
|
persist_extended_history=persist_extended_history,
|
|
473
|
+
exclude_turns=exclude_turns,
|
|
474
|
+
permission_profile=permission_profile,
|
|
448
475
|
)
|
|
449
476
|
result = await self.dispatch.send_request("thread/fork", params)
|
|
450
477
|
response = ThreadResponse.model_validate(result)
|
|
@@ -463,9 +490,10 @@ class CodexClient:
|
|
|
463
490
|
model_providers: list[str] | None = None,
|
|
464
491
|
source_kinds: list[ThreadSourceKind] | None = None,
|
|
465
492
|
archived: bool | None = None,
|
|
466
|
-
cwd:
|
|
493
|
+
cwd: ThreadListCwdFilter | None = None,
|
|
467
494
|
search_term: str | None = None,
|
|
468
495
|
sort_direction: SortDirection | None = None,
|
|
496
|
+
use_state_db_only: bool | None = None,
|
|
469
497
|
) -> ThreadListResponse:
|
|
470
498
|
"""List stored threads with pagination.
|
|
471
499
|
|
|
@@ -479,6 +507,7 @@ class CodexClient:
|
|
|
479
507
|
cwd: Filter by working directory
|
|
480
508
|
search_term: Substring filter for thread title
|
|
481
509
|
sort_direction: Sort direction (asc or desc)
|
|
510
|
+
use_state_db_only: If true, only return threads from the state DB
|
|
482
511
|
|
|
483
512
|
Returns:
|
|
484
513
|
ThreadListResponse with data (list of threads) and next_cursor
|
|
@@ -493,6 +522,7 @@ class CodexClient:
|
|
|
493
522
|
cwd=cwd,
|
|
494
523
|
search_term=search_term,
|
|
495
524
|
sort_direction=sort_direction,
|
|
525
|
+
use_state_db_only=use_state_db_only,
|
|
496
526
|
)
|
|
497
527
|
result = await self.dispatch.send_request("thread/list", params)
|
|
498
528
|
return ThreadListResponse.model_validate(result)
|
|
@@ -563,6 +593,7 @@ class CodexClient:
|
|
|
563
593
|
sandbox_policy: SandboxPolicy | None = None,
|
|
564
594
|
output_bytes_cap: int | None = None,
|
|
565
595
|
timeout_ms: int | None = None,
|
|
596
|
+
permission_profile: PermissionProfile | None = None,
|
|
566
597
|
) -> CommandExecResponse:
|
|
567
598
|
"""Execute a command without creating a thread/turn.
|
|
568
599
|
|
|
@@ -572,6 +603,7 @@ class CodexClient:
|
|
|
572
603
|
sandbox_policy: Sandbox policy override
|
|
573
604
|
output_bytes_cap: Cap output based on bytes
|
|
574
605
|
timeout_ms: Timeout in milliseconds
|
|
606
|
+
permission_profile: Permission profile override
|
|
575
607
|
|
|
576
608
|
Returns:
|
|
577
609
|
CommandExecResponse with exit_code, stdout, stderr
|
|
@@ -582,6 +614,7 @@ class CodexClient:
|
|
|
582
614
|
output_bytes_cap=output_bytes_cap,
|
|
583
615
|
sandbox_policy=sandbox_policy,
|
|
584
616
|
timeout_ms=timeout_ms,
|
|
617
|
+
permission_profile=permission_profile,
|
|
585
618
|
)
|
|
586
619
|
result = await self.dispatch.send_request("command/exec", params)
|
|
587
620
|
return CommandExecResponse.model_validate(result)
|
|
@@ -637,6 +670,20 @@ class CodexClient:
|
|
|
637
670
|
response = McpServerOauthLoginResponse.model_validate(result)
|
|
638
671
|
return response.authorization_url
|
|
639
672
|
|
|
673
|
+
async def read_resource(self, server: str, uri: str) -> list[ResourceContents]:
|
|
674
|
+
"""Read a resource from the MCP server."""
|
|
675
|
+
params = McpResourceReadParams(server=server, uri=uri)
|
|
676
|
+
result = await self.dispatch.send_request("mcpServer/resource/read", params)
|
|
677
|
+
data = McpResourceReadResponse.model_validate(result)
|
|
678
|
+
ta = TypeAdapter[ResourceContents](ResourceContents)
|
|
679
|
+
|
|
680
|
+
def convert(old: BaseModel) -> ResourceContents:
|
|
681
|
+
dct = old.model_dump()
|
|
682
|
+
dct["_meta"] = dct.pop("field_meta")
|
|
683
|
+
return ta.validate_python(dct)
|
|
684
|
+
|
|
685
|
+
return [convert(i) for i in data.contents]
|
|
686
|
+
|
|
640
687
|
# ========================================================================
|
|
641
688
|
# Config methods
|
|
642
689
|
# ========================================================================
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Codex app-server client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from codexed.models.v2_protocol import (
|
|
9
|
+
DeviceKeyCreateParams,
|
|
10
|
+
DeviceKeyCreateResponse,
|
|
11
|
+
DeviceKeyPublicParams,
|
|
12
|
+
DeviceKeyPublicResponse,
|
|
13
|
+
DeviceKeySignParams,
|
|
14
|
+
DeviceKeySignResponse,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from codexed.client import CodexClient
|
|
20
|
+
from codexed.models.v2_protocol import DeviceKeyProtectionPolicy, DeviceKeySignPayload
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CodexDevice:
|
|
26
|
+
def __init__(self, client: CodexClient):
|
|
27
|
+
self._client = client
|
|
28
|
+
|
|
29
|
+
async def create_key(
|
|
30
|
+
self,
|
|
31
|
+
account_user_id: str,
|
|
32
|
+
client_id: str,
|
|
33
|
+
protection_policy: DeviceKeyProtectionPolicy | None = None,
|
|
34
|
+
) -> DeviceKeyCreateResponse:
|
|
35
|
+
"""Add a marketplace to the app-server."""
|
|
36
|
+
params = DeviceKeyCreateParams(
|
|
37
|
+
account_user_id=account_user_id,
|
|
38
|
+
client_id=client_id,
|
|
39
|
+
protection_policy=protection_policy,
|
|
40
|
+
)
|
|
41
|
+
response = await self._client.dispatch.send_request("device/key/create", params)
|
|
42
|
+
return DeviceKeyCreateResponse.model_validate(response)
|
|
43
|
+
|
|
44
|
+
async def public_key(self, key_id: str) -> DeviceKeyPublicResponse:
|
|
45
|
+
"""Get the public key for a device key."""
|
|
46
|
+
params = DeviceKeyPublicParams(key_id=key_id)
|
|
47
|
+
response = await self._client.dispatch.send_request("device/key/public", params=params)
|
|
48
|
+
return DeviceKeyPublicResponse.model_validate(response)
|
|
49
|
+
|
|
50
|
+
async def sign_key(self, key_id: str, payload: DeviceKeySignPayload) -> DeviceKeySignResponse:
|
|
51
|
+
"""Sign a key using the device key."""
|
|
52
|
+
params = DeviceKeySignParams(key_id=key_id, payload=payload)
|
|
53
|
+
response = await self._client.dispatch.send_request("device/key/sign", params=params)
|
|
54
|
+
return DeviceKeySignResponse.model_validate(response)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
import asyncio
|
|
59
|
+
|
|
60
|
+
from codexed.client import CodexClient
|
|
61
|
+
|
|
62
|
+
async def main():
|
|
63
|
+
client = CodexClient()
|
|
64
|
+
async with client:
|
|
65
|
+
_test = await client.marketplace.add("test")
|
|
66
|
+
|
|
67
|
+
asyncio.run(main())
|
|
@@ -10,6 +10,8 @@ from codexed.models import (
|
|
|
10
10
|
MarketplaceAddResponse,
|
|
11
11
|
MarketplaceRemoveParams,
|
|
12
12
|
MarketplaceRemoveResponse,
|
|
13
|
+
MarketplaceUpgradeParams,
|
|
14
|
+
MarketplaceUpgradeResponse,
|
|
13
15
|
)
|
|
14
16
|
|
|
15
17
|
|
|
@@ -40,6 +42,12 @@ class CodexMarketPlace:
|
|
|
40
42
|
response = await self._client.dispatch.send_request("marketplace/remove", params)
|
|
41
43
|
return MarketplaceRemoveResponse.model_validate(response)
|
|
42
44
|
|
|
45
|
+
async def upgrade(self, marketplace_name: str | None = None):
|
|
46
|
+
"""Upgrade a marketplace to the latest version."""
|
|
47
|
+
params = MarketplaceUpgradeParams(marketplace_name=marketplace_name)
|
|
48
|
+
response = await self._client.dispatch.send_request("marketplace/upgrade", params)
|
|
49
|
+
return MarketplaceUpgradeResponse.model_validate(response)
|
|
50
|
+
|
|
43
51
|
|
|
44
52
|
if __name__ == "__main__":
|
|
45
53
|
import asyncio
|
|
@@ -108,7 +108,7 @@ class RealtimeSession:
|
|
|
108
108
|
event = await self._queue.get()
|
|
109
109
|
if event is None or isinstance(event, ThreadRealtimeClosedMessage):
|
|
110
110
|
break
|
|
111
|
-
except Exception:
|
|
111
|
+
except Exception:
|
|
112
112
|
logger.debug("Error during realtime cleanup", exc_info=True)
|
|
113
113
|
finally:
|
|
114
114
|
self._client._realtime_queues.pop(self._queue_key, None)
|