codexed 1.1.6__tar.gz → 1.1.8__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 (32) hide show
  1. {codexed-1.1.6 → codexed-1.1.8}/PKG-INFO +2 -1
  2. {codexed-1.1.6 → codexed-1.1.8}/pyproject.toml +2 -1
  3. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/client/client.py +6 -3
  4. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/client/session.py +46 -5
  5. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/__init__.py +6 -10
  6. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/event_data.py +0 -9
  7. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/events.py +2 -2
  8. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/misc.py +6 -84
  9. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/request_params.py +5 -33
  10. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/responses.py +10 -20
  11. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/thread_item.py +1 -2
  12. {codexed-1.1.6 → codexed-1.1.8}/LICENSE +0 -0
  13. {codexed-1.1.6 → codexed-1.1.8}/README.md +0 -0
  14. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/README.md +0 -0
  15. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/__init__.py +0 -0
  16. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/client/__init__.py +0 -0
  17. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/client/dispatch.py +0 -0
  18. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/client/fs.py +0 -0
  19. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/client/realtime.py +0 -0
  20. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/client/skills.py +0 -0
  21. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/exceptions.py +0 -0
  22. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/helpers.py +0 -0
  23. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/log.py +0 -0
  24. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/base.py +0 -0
  25. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/codex_types.py +0 -0
  26. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/mcp_server.py +0 -0
  27. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/tool_config.py +0 -0
  28. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/user_input.py +0 -0
  29. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/models/v2_protocol.py +0 -0
  30. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/py.typed +0 -0
  31. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/request_handlers.py +0 -0
  32. {codexed-1.1.6 → codexed-1.1.8}/src/codexed/transport.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codexed
3
- Version: 1.1.6
3
+ Version: 1.1.8
4
4
  Summary: Alternative codex app-server client
5
5
  Keywords:
6
6
  Author: Philipp Temminghoff
@@ -22,6 +22,7 @@ Classifier: Topic :: Software Development
22
22
  Classifier: Topic :: Utilities
23
23
  Classifier: Typing :: Typed
24
24
  Requires-Dist: anyenv>=2.0.15
25
+ Requires-Dist: mcp>=1.27.0
25
26
  Requires-Dist: pydantic
26
27
  Requires-Dist: schemez
27
28
  Requires-Dist: websockets>=13.0 ; extra == 'websocket'
@@ -2,7 +2,7 @@
2
2
 
3
3
  [project]
4
4
  name = "codexed"
5
- version = "1.1.6"
5
+ version = "1.1.8"
6
6
  description = "Alternative codex app-server client"
7
7
  readme = "README.md"
8
8
  requires-python = ">=3.13"
@@ -30,6 +30,7 @@ classifiers = [
30
30
  ]
31
31
  dependencies = [
32
32
  "anyenv>=2.0.15",
33
+ "mcp>=1.27.0",
33
34
  "pydantic",
34
35
  "schemez",
35
36
  # Only add below (Copier)
@@ -190,11 +190,14 @@ class CodexClient:
190
190
  async def __aenter__(self) -> Self:
191
191
  """Async context manager entry - starts the app-server."""
192
192
  import codexed
193
- from codexed.models import ClientInfo, InitializeParams
193
+ from codexed.models import ClientInfo, InitializeCapabilities, InitializeParams
194
194
 
195
195
  await self.dispatch.start()
196
196
  version = codexed.__version__
197
- init_params = InitializeParams(client_info=ClientInfo(name="codexed", version=version))
197
+ init_params = InitializeParams(
198
+ client_info=ClientInfo(name="codexed", version=version),
199
+ capabilities=InitializeCapabilities(experimental_api=True),
200
+ )
198
201
  await self.dispatch.send_request("initialize", init_params)
199
202
  return self
200
203
 
@@ -648,7 +651,7 @@ class CodexClient:
648
651
  )
649
652
  params = TypeAdapter[LoginAccountParams](LoginAccountParams).validate_python(dct)
650
653
  result = await self.dispatch.send_request("account/login/start", params)
651
- return LoginAccountResponse.model_validate(result)
654
+ return TypeAdapter[LoginAccountResponse](LoginAccountResponse).validate_python(result)
652
655
 
653
656
  async def account_login_cancel(self, login_id: str) -> CancelLoginAccountStatus:
654
657
  """Cancel an in-progress account login."""
@@ -197,12 +197,12 @@ class Session:
197
197
  case ErrorMessage(data=ErrorNotification(error=error)):
198
198
  yield event
199
199
  raise TurnFailedError(error.message, turn_id=turn_id)
200
+ case ThreadTokenUsageUpdatedEvent(
201
+ data=ThreadTokenUsageUpdatedNotification(token_usage=usage)
202
+ ):
203
+ self.usage = usage
204
+ yield event
200
205
  case _:
201
- match event:
202
- case ThreadTokenUsageUpdatedEvent(
203
- data=ThreadTokenUsageUpdatedNotification(token_usage=usage)
204
- ):
205
- self.usage = usage
206
206
  yield event
207
207
  finally:
208
208
  if turn_key in self._client._turn_queues:
@@ -422,6 +422,47 @@ class Session:
422
422
  result = await self._client.dispatch.send_request("review/start", params)
423
423
  return ReviewStartResponse.model_validate(result)
424
424
 
425
+ async def review_stream(
426
+ self,
427
+ target: ReviewTarget,
428
+ *,
429
+ delivery: ReviewDelivery | None = None,
430
+ ) -> AsyncIterator[CodexEvent]:
431
+ """Start a code review and stream events.
432
+
433
+ Args:
434
+ target: Review target (uncommittedChanges, baseBranch, commit, or custom)
435
+ delivery: Where to run the review (inline or detached)
436
+
437
+ Yields:
438
+ CodexEvent: Streaming events from the review turn
439
+ """
440
+ params = ReviewStartParams(thread_id=self.thread_id, target=target, delivery=delivery)
441
+ result = await self._client.dispatch.send_request("review/start", params)
442
+ response = ReviewStartResponse.model_validate(result)
443
+ turn_id = response.turn.id
444
+ review_thread_id = response.review_thread_id
445
+ turn_queue: asyncio.Queue[CodexEvent | None] = asyncio.Queue()
446
+ turn_key = f"{review_thread_id}:{turn_id}"
447
+ self._client._turn_queues[turn_key] = turn_queue
448
+ try:
449
+ while True:
450
+ event = await turn_queue.get()
451
+ match event:
452
+ case None:
453
+ break
454
+ case TurnCompletedEvent():
455
+ yield event
456
+ break
457
+ case ErrorMessage(data=ErrorNotification(error=error)):
458
+ yield event
459
+ raise TurnFailedError(error.message, turn_id=turn_id)
460
+ case _:
461
+ yield event
462
+ finally:
463
+ if turn_key in self._client._turn_queues:
464
+ del self._client._turn_queues[turn_key]
465
+
425
466
  # -- Fork ----------------------------------------------------------------
426
467
 
427
468
  async def fork(
@@ -20,7 +20,6 @@ from codexed.models.codex_types import (
20
20
  from codexed.models.event_data import (
21
21
  ItemCompletedData,
22
22
  ItemStartedData,
23
- RawResponseItemCompletedData,
24
23
  ThreadStartedData,
25
24
  TurnStartedData,
26
25
  TurnCompletedData,
@@ -47,10 +46,7 @@ from codexed.models.events import (
47
46
  from codexed.models.mcp_server import HttpMcpServer, McpServerConfig, StdioMcpServer
48
47
  from codexed.models.misc import (
49
48
  ExecPolicyAmendment,
50
- McpResource,
51
- McpResourceTemplate,
52
49
  McpServerStatusEntry,
53
- McpTool,
54
50
  NetworkApprovalContext,
55
51
  NetworkPolicyAmendment,
56
52
  SkillRequestApprovalResponse,
@@ -66,7 +62,6 @@ from codexed.models.request_params import (
66
62
  ProductSurface,
67
63
  CommandExecutionRequestApprovalParams,
68
64
  DynamicToolCallParams,
69
- ThreadResumeParams,
70
65
  FileChangeRequestApprovalParams,
71
66
  McpElicitationFormParams,
72
67
  McpElicitationUrlParams,
@@ -82,7 +77,6 @@ from codexed.models.responses import (
82
77
  DynamicToolCallResponse,
83
78
  FileChangeRequestApprovalResponse,
84
79
  ListMcpServerStatusResponse,
85
- LoginAccountResponse,
86
80
  McpServerElicitationResponse,
87
81
  RemoteSkillSummary,
88
82
  ReviewStartResponse,
@@ -153,6 +147,10 @@ from codexed.models.user_input import (
153
147
  )
154
148
  from codexed.models.v2_protocol import (
155
149
  ByteRange,
150
+ InitializeCapabilities,
151
+ LoginAccountResponse,
152
+ ThreadResumeParams,
153
+ RawResponseItemCompletedNotification,
156
154
  ExternalAgentConfigImportParams,
157
155
  InitializeParams,
158
156
  CommandExecParams,
@@ -623,6 +621,7 @@ __all__ = [
623
621
  "ImageGenerationCallResponseItem",
624
622
  "ImageGenerationToolConfig",
625
623
  "ImageUserInput",
624
+ "InitializeCapabilities",
626
625
  "InitializeParams",
627
626
  "InputModality",
628
627
  "ItemAgentMessageDeltaNotification",
@@ -654,8 +653,6 @@ __all__ = [
654
653
  "McpAuthStatus",
655
654
  "McpElicitationFormParams",
656
655
  "McpElicitationUrlParams",
657
- "McpResource",
658
- "McpResourceTemplate",
659
656
  "McpResourceToolsConfig",
660
657
  "McpServerConfig",
661
658
  "McpServerElicitationRequestParams",
@@ -668,7 +665,6 @@ __all__ = [
668
665
  "McpServerStartupStatusUpdatedNotification",
669
666
  "McpServerStatusEntry",
670
667
  "McpServerStatusUpdatedNotification",
671
- "McpTool",
672
668
  "McpToolCallError",
673
669
  "McpToolCallProgressNotification",
674
670
  "McpToolCallResult",
@@ -704,8 +700,8 @@ __all__ = [
704
700
  "ProductSurface",
705
701
  "RateLimitSnapshot",
706
702
  "RateLimitWindow",
707
- "RawResponseItemCompletedData",
708
703
  "RawResponseItemCompletedEvent",
704
+ "RawResponseItemCompletedNotification",
709
705
  "ReadCommandAction",
710
706
  "ReadFileToolConfig",
711
707
  "ReadOnlyAccess",
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
  from codexed.models.base import CodexBaseModel
4
4
  from codexed.models.misc import Thread, Turn
5
5
  from codexed.models.thread_item import ThreadItem
6
- from codexed.models.v2_protocol import ResponseItem
7
6
 
8
7
 
9
8
  # Item lifecycle notifications
@@ -25,14 +24,6 @@ class ItemCompletedData(CodexBaseModel):
25
24
  item: ThreadItem
26
25
 
27
26
 
28
- class RawResponseItemCompletedData(CodexBaseModel):
29
- """Payload for rawResponseItem/completed notification."""
30
-
31
- thread_id: str
32
- turn_id: str
33
- item: ResponseItem
34
-
35
-
36
27
  class ThreadStartedData(CodexBaseModel):
37
28
  """Payload for thread/started notification (V2 protocol)."""
38
29
 
@@ -14,7 +14,6 @@ from codexed.models.base import CodexBaseModel
14
14
  from codexed.models.event_data import (
15
15
  ItemCompletedData,
16
16
  ItemStartedData,
17
- RawResponseItemCompletedData,
18
17
  ThreadStartedData,
19
18
  TurnCompletedData,
20
19
  TurnStartedData,
@@ -45,6 +44,7 @@ from codexed.models.v2_protocol import (
45
44
  McpServerOauthLoginCompletedMessage,
46
45
  McpServerStartupStatusUpdatedNotification,
47
46
  ModelReroutedMessage,
47
+ RawResponseItemCompletedNotification,
48
48
  ServerRequestResolvedMessage,
49
49
  ThreadArchivedMessage,
50
50
  ThreadCompactedMessage,
@@ -144,7 +144,7 @@ class RawResponseItemCompletedEvent(CodexBaseModel):
144
144
  """Raw response item completed event."""
145
145
 
146
146
  method: Literal["rawResponseItem/completed"] = "rawResponseItem/completed"
147
- params: RawResponseItemCompletedData
147
+ params: RawResponseItemCompletedNotification
148
148
 
149
149
 
150
150
  # ============================================================================
@@ -2,10 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import TYPE_CHECKING, Any
5
+ from typing import Any
6
6
 
7
- from mcp.types import Annotations, Icon, ToolAnnotations
8
- from pydantic import AnyUrl, Field
7
+ from mcp.types import Resource, ResourceTemplate, Tool
8
+ from pydantic import Field
9
9
 
10
10
  from codexed.models.base import CodexBaseModel
11
11
  from codexed.models.codex_types import (
@@ -24,10 +24,6 @@ from codexed.models.v2_protocol import (
24
24
  )
25
25
 
26
26
 
27
- if TYPE_CHECKING:
28
- from mcp.types import Resource, ResourceTemplate, Tool
29
-
30
-
31
27
  class NetworkApprovalContext(CodexBaseModel):
32
28
  """Network approval context for command approvals."""
33
29
 
@@ -169,85 +165,11 @@ class TurnData(CodexBaseModel):
169
165
  error: str | None = None
170
166
 
171
167
 
172
- class McpTool(CodexBaseModel):
173
- """Tool exposed by an MCP server. Mirrors `mcp.types.Tool`."""
174
-
175
- name: str
176
- title: str | None = None
177
- description: str | None = None
178
- input_schema: dict[str, Any]
179
- output_schema: dict[str, Any] | None = None
180
- annotations: ToolAnnotations | None = None
181
- icons: list[Icon] | None = None
182
-
183
- def to_mcp_tool(self) -> Tool:
184
- from mcp.types import Tool
185
-
186
- return Tool(
187
- name=self.name,
188
- title=self.title,
189
- description=self.description,
190
- inputSchema=self.input_schema,
191
- outputSchema=self.output_schema,
192
- annotations=self.annotations,
193
- icons=self.icons,
194
- )
195
-
196
-
197
- class McpResource(CodexBaseModel):
198
- """Resource exposed by an MCP server. Mirrors `mcp.types.Resource`."""
199
-
200
- uri: str
201
- name: str
202
- title: str | None = None
203
- description: str | None = None
204
- mime_type: str | None = None
205
- size: int | None = None
206
- annotations: Annotations | None = None
207
- icons: list[Icon] | None = None
208
-
209
- def to_mcp_resource(self) -> Resource:
210
- from mcp.types import Resource
211
-
212
- return Resource(
213
- uri=AnyUrl(self.uri),
214
- name=self.name,
215
- title=self.title,
216
- description=self.description,
217
- mimeType=self.mime_type,
218
- size=self.size,
219
- annotations=self.annotations,
220
- icons=self.icons,
221
- )
222
-
223
-
224
- class McpResourceTemplate(CodexBaseModel):
225
- """Resource template exposed by an MCP server. Mirrors `mcp.types.ResourceTemplate`."""
226
-
227
- uri_template: str
228
- name: str
229
- title: str | None = None
230
- description: str | None = None
231
- mime_type: str | None = None
232
- annotations: Annotations | None = None
233
-
234
- def to_mcp_resource(self) -> ResourceTemplate:
235
- from mcp.types import ResourceTemplate
236
-
237
- return ResourceTemplate(
238
- uriTemplate=self.uri_template,
239
- name=self.name,
240
- title=self.title,
241
- description=self.description,
242
- annotations=self.annotations,
243
- )
244
-
245
-
246
168
  class McpServerStatusEntry(CodexBaseModel):
247
169
  """Status of a single MCP server."""
248
170
 
249
171
  name: str
250
- tools: dict[str, McpTool] = Field(default_factory=dict)
251
- resources: list[McpResource] = Field(default_factory=list)
252
- resource_templates: list[McpResourceTemplate] = Field(default_factory=list)
172
+ tools: dict[str, Tool] = Field(default_factory=dict)
173
+ resources: list[Resource] = Field(default_factory=list)
174
+ resource_templates: list[ResourceTemplate] = Field(default_factory=list)
253
175
  auth_status: McpAuthStatus = "unsupported"
@@ -12,15 +12,7 @@ from codexed.models.misc import (
12
12
  NetworkPolicyAmendment,
13
13
  ToolRequestUserInputQuestion,
14
14
  )
15
- from codexed.models.v2_protocol import (
16
- ApprovalsReviewer,
17
- AskForApproval,
18
- CommandAction,
19
- Personality,
20
- ResponseItem,
21
- SandboxMode,
22
- ServiceTier,
23
- )
15
+ from codexed.models.v2_protocol import CommandAction
24
16
 
25
17
 
26
18
  if TYPE_CHECKING:
@@ -32,26 +24,6 @@ ProductSurface = Literal["chatgpt", "codex", "api", "atlas"]
32
24
  PersistOption = Literal["session", "always"]
33
25
 
34
26
 
35
- class ThreadResumeParams(CodexBaseModel):
36
- """Parameters for thread/resume request."""
37
-
38
- thread_id: str
39
- history: list[ResponseItem] | None = None
40
- path: str | None = None
41
- cwd: str | None = None
42
- model: str | None = None
43
- model_provider: str | None = None
44
- base_instructions: str | None = None
45
- developer_instructions: str | None = None
46
- approval_policy: AskForApproval | None = None
47
- approvals_reviewer: ApprovalsReviewer | None = None
48
- sandbox: SandboxMode | None = None
49
- config: dict[str, Any] | None = None
50
- service_tier: ServiceTier | None = None
51
- personality: Personality | None = None
52
- persist_extended_history: bool = False
53
-
54
-
55
27
  class SkillsRemoteListParams(CodexBaseModel):
56
28
  """Parameters for skills/remote/list request."""
57
29
 
@@ -166,12 +138,12 @@ class McpElicitationFormParams(_McpElicitationBase):
166
138
  requested_schema: dict[str, Any]
167
139
 
168
140
  def to_mcp(self) -> ElicitRequestFormParams:
169
- from mcp.types import ElicitRequestFormParams, RequestParams
141
+ from mcp.types import ElicitRequestFormParams
170
142
 
171
143
  return ElicitRequestFormParams(
172
144
  message=self.message,
173
145
  requestedSchema=self.requested_schema,
174
- _meta=RequestParams.Meta(**self.meta) if self.meta else None, # pyright: ignore[reportArgumentType]
146
+ _meta=ElicitRequestFormParams.Meta(**self.meta) if self.meta else None, # pyright: ignore[reportArgumentType]
175
147
  )
176
148
 
177
149
  @classmethod
@@ -201,13 +173,13 @@ class McpElicitationUrlParams(_McpElicitationBase):
201
173
  elicitation_id: str
202
174
 
203
175
  def to_mcp(self) -> ElicitRequestURLParams:
204
- from mcp.types import ElicitRequestURLParams, RequestParams
176
+ from mcp.types import ElicitRequestURLParams
205
177
 
206
178
  return ElicitRequestURLParams(
207
179
  message=self.message,
208
180
  url=self.url,
209
181
  elicitationId=self.elicitation_id,
210
- _meta=RequestParams.Meta(**self.meta) if self.meta else None, # pyright: ignore[reportArgumentType]
182
+ _meta=ElicitRequestURLParams.Meta(**self.meta) if self.meta else None, # pyright: ignore[reportArgumentType]
211
183
  )
212
184
 
213
185
  @classmethod
@@ -1,8 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any
4
-
5
- import mcp.types
3
+ from typing import TYPE_CHECKING, Any
6
4
 
7
5
  from codexed.models.base import CodexBaseModel
8
6
  from codexed.models.codex_types import ApprovalDecision, ElicitationAction
@@ -15,7 +13,6 @@ from codexed.models.misc import (
15
13
  )
16
14
  from codexed.models.v2_protocol import (
17
15
  AskForApproval,
18
- AuthMode,
19
16
  DynamicToolCallOutputContentItem,
20
17
  ReasoningEffort,
21
18
  SandboxPolicy,
@@ -23,6 +20,10 @@ from codexed.models.v2_protocol import (
23
20
  )
24
21
 
25
22
 
23
+ if TYPE_CHECKING:
24
+ from mcp.types import ElicitResult
25
+
26
+
26
27
  class CommandExecutionRequestApprovalResponse(CodexBaseModel):
27
28
  """Response for item/commandExecution/requestApproval server request."""
28
29
 
@@ -63,11 +64,13 @@ class McpServerElicitationResponse(CodexBaseModel):
63
64
  Must be one of the options listed in the request's ``meta.persist``.
64
65
  """
65
66
 
66
- def to_mcp(self) -> mcp.types.ElicitResult:
67
- return mcp.types.ElicitResult(action=self.action, content=self.content, _meta=self.meta)
67
+ def to_mcp(self) -> ElicitResult:
68
+ from mcp.types import ElicitResult
69
+
70
+ return ElicitResult(action=self.action, content=self.content, _meta=self.meta)
68
71
 
69
72
  @classmethod
70
- def from_mcp(cls, result: mcp.types.ElicitResult) -> McpServerElicitationResponse:
73
+ def from_mcp(cls, result: ElicitResult) -> McpServerElicitationResponse:
71
74
  """Create from MCP ElicitResult."""
72
75
  return cls(action=result.action, content=result.content, meta=result.meta)
73
76
 
@@ -150,16 +153,3 @@ class ListMcpServerStatusResponse(CodexBaseModel):
150
153
 
151
154
  data: list[McpServerStatusEntry]
152
155
  next_cursor: str | None = None
153
-
154
-
155
- # ============================================================================
156
- # Account models
157
- # ============================================================================
158
-
159
-
160
- class LoginAccountResponse(CodexBaseModel):
161
- """Response for account/login/start request."""
162
-
163
- type: AuthMode
164
- login_id: str | None = None
165
- auth_url: str | None = None
@@ -111,9 +111,8 @@ class ThreadItemCommandExecution(BaseThreadItem):
111
111
  @property
112
112
  def item_summary(self) -> str:
113
113
  """Human-readable summary of this command execution."""
114
- output = self.aggregated_output or ""
115
114
  msg = f"[Executed: {self.command}]"
116
- if output:
115
+ if output := self.aggregated_output:
117
116
  msg += f"\n{output[:200]}"
118
117
  return msg
119
118
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes