codexed 1.1.9__tar.gz → 1.2.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 (35) hide show
  1. {codexed-1.1.9 → codexed-1.2.1}/PKG-INFO +1 -1
  2. {codexed-1.1.9 → codexed-1.2.1}/pyproject.toml +1 -1
  3. codexed-1.2.1/src/codexed/client/__init__.py +19 -0
  4. codexed-1.2.1/src/codexed/client/account.py +108 -0
  5. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/client/client.py +34 -73
  6. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/client/fs.py +3 -2
  7. codexed-1.2.1/src/codexed/client/marketplace.py +54 -0
  8. codexed-1.2.1/src/codexed/client/plugin.py +80 -0
  9. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/client/realtime.py +26 -21
  10. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/client/session.py +111 -6
  11. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/__init__.py +82 -16
  12. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/codex_types.py +0 -2
  13. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/events.py +14 -7
  14. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/misc.py +93 -22
  15. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/request_params.py +2 -2
  16. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/responses.py +1 -1
  17. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/tool_config.py +1 -1
  18. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/v2_protocol.py +711 -77
  19. codexed-1.1.9/src/codexed/client/__init__.py +0 -9
  20. {codexed-1.1.9 → codexed-1.2.1}/LICENSE +0 -0
  21. {codexed-1.1.9 → codexed-1.2.1}/README.md +0 -0
  22. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/README.md +0 -0
  23. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/__init__.py +0 -0
  24. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/client/dispatch.py +0 -0
  25. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/client/skills.py +0 -0
  26. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/exceptions.py +0 -0
  27. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/helpers.py +0 -0
  28. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/log.py +0 -0
  29. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/base.py +0 -0
  30. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/event_data.py +0 -0
  31. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/mcp_server.py +0 -0
  32. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/models/thread_item.py +0 -0
  33. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/py.typed +0 -0
  34. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/request_handlers.py +0 -0
  35. {codexed-1.1.9 → codexed-1.2.1}/src/codexed/transport.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codexed
3
- Version: 1.1.9
3
+ Version: 1.2.1
4
4
  Summary: Alternative codex app-server client
5
5
  Keywords:
6
6
  Author: Philipp Temminghoff
@@ -2,7 +2,7 @@
2
2
 
3
3
  [project]
4
4
  name = "codexed"
5
- version = "1.1.9"
5
+ version = "1.2.1"
6
6
  description = "Alternative codex app-server client"
7
7
  readme = "README.md"
8
8
  requires-python = ">=3.13"
@@ -0,0 +1,19 @@
1
+ """Codex client."""
2
+
3
+ from .client import CodexClient
4
+ from .fs import CodexFS
5
+ from .skills import CodexSkills
6
+ from .plugin import CodexPlugin
7
+ from .marketplace import CodexMarketPlace
8
+ from .realtime import RealtimeSession
9
+ from .session import Session
10
+
11
+ __all__ = [
12
+ "CodexClient",
13
+ "CodexFS",
14
+ "CodexMarketPlace",
15
+ "CodexPlugin",
16
+ "CodexSkills",
17
+ "RealtimeSession",
18
+ "Session",
19
+ ]
@@ -0,0 +1,108 @@
1
+ """Codex app-server client."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ from typing import TYPE_CHECKING
7
+
8
+ from pydantic import TypeAdapter
9
+
10
+ from codexed.models import (
11
+ CancelLoginAccountParams,
12
+ CancelLoginAccountResponse,
13
+ GetAccountParams,
14
+ GetAccountRateLimitsResponse,
15
+ GetAccountResponse,
16
+ LoginAccountParams,
17
+ LoginAccountResponse,
18
+ SendAddCreditsNudgeEmailParams,
19
+ )
20
+
21
+
22
+ if TYPE_CHECKING:
23
+ from codexed.client import CodexClient
24
+ from codexed.models import AddCreditsNudgeCreditType, AuthMode, CancelLoginAccountStatus
25
+
26
+ logger = logging.getLogger(__name__)
27
+
28
+
29
+ class CodexAccount:
30
+ def __init__(self, client: CodexClient):
31
+ self._client = client
32
+
33
+ async def read(self, *, refresh_token: bool = False) -> GetAccountResponse:
34
+ """Read account information.
35
+
36
+ Args:
37
+ refresh_token: When true, trigger a proactive token refresh
38
+
39
+ Returns:
40
+ GetAccountResponse with account info
41
+ """
42
+ params = GetAccountParams(refresh_token=refresh_token)
43
+ result = await self._client.dispatch.send_request("account/read", params)
44
+ return GetAccountResponse.model_validate(result)
45
+
46
+ async def login_start(
47
+ self,
48
+ login_type: AuthMode,
49
+ *,
50
+ api_key: str | None = None,
51
+ access_token: str | None = None,
52
+ chatgpt_account_id: str | None = None,
53
+ ) -> LoginAccountResponse:
54
+ """Start account login.
55
+
56
+ Args:
57
+ login_type: Login type (apiKey, chatgpt, chatgptAuthTokens)
58
+ api_key: API key (for apiKey type)
59
+ access_token: Access token (for chatgptAuthTokens type)
60
+ chatgpt_account_id: ChatGPT account ID (for chatgptAuthTokens type)
61
+
62
+ Returns:
63
+ LoginAccountResponse with login details
64
+ """
65
+ dct = dict(
66
+ type=login_type,
67
+ api_key=api_key,
68
+ access_token=access_token,
69
+ chatgpt_account_id=chatgpt_account_id,
70
+ )
71
+ params = TypeAdapter[LoginAccountParams](LoginAccountParams).validate_python(dct)
72
+ result = await self._client.dispatch.send_request("account/login/start", params)
73
+ return TypeAdapter[LoginAccountResponse](LoginAccountResponse).validate_python(result)
74
+
75
+ async def login_cancel(self, login_id: str) -> CancelLoginAccountStatus:
76
+ """Cancel an in-progress account login."""
77
+ params = CancelLoginAccountParams(login_id=login_id)
78
+ result = await self._client.dispatch.send_request("account/login/cancel", params)
79
+ response = CancelLoginAccountResponse.model_validate(result)
80
+ return response.status
81
+
82
+ async def logout(self) -> None:
83
+ """Logout from the current account."""
84
+ await self._client.dispatch.send_request("account/logout")
85
+
86
+ async def rate_limits_read(self) -> GetAccountRateLimitsResponse:
87
+ """Read account rate limits."""
88
+ result = await self._client.dispatch.send_request("account/rateLimits/read")
89
+ return GetAccountRateLimitsResponse.model_validate(result)
90
+
91
+ async def send_add_credits_nudge_email(self, credit_type: AddCreditsNudgeCreditType) -> None:
92
+ """Send an add credits nudge email."""
93
+ params = SendAddCreditsNudgeEmailParams(credit_type=credit_type)
94
+ await self._client.dispatch.send_request("account/sendAddCreditsNudgeEmail", params)
95
+
96
+
97
+ if __name__ == "__main__":
98
+ import asyncio
99
+
100
+ from codexed.client import CodexClient
101
+
102
+ async def main():
103
+ client = CodexClient()
104
+ async with client:
105
+ response = await client.account.read()
106
+ print(response)
107
+
108
+ asyncio.run(main())
@@ -9,15 +9,16 @@ from typing import TYPE_CHECKING, Any
9
9
 
10
10
  from pydantic import TypeAdapter
11
11
 
12
+ from codexed.client.account import CodexAccount
12
13
  from codexed.client.dispatch import Dispatch
13
14
  from codexed.client.fs import CodexFS
15
+ from codexed.client.marketplace import CodexMarketPlace
16
+ from codexed.client.plugin import CodexPlugin
14
17
  from codexed.client.skills import CodexSkills
15
18
  from codexed.helpers import merge_config
16
19
  from codexed.models import (
17
20
  AppsListParams,
18
21
  AppsListResponse,
19
- CancelLoginAccountParams,
20
- CancelLoginAccountResponse,
21
22
  CollaborationModeListResponse,
22
23
  CommandExecParams,
23
24
  CommandExecResponse,
@@ -34,15 +35,11 @@ from codexed.models import (
34
35
  ExternalAgentConfigImportParams,
35
36
  FeedbackUploadParams,
36
37
  FeedbackUploadResponse,
37
- GetAccountParams,
38
- GetAccountRateLimitsResponse,
39
- GetAccountResponse,
40
38
  ListMcpServerStatusParams,
41
39
  ListMcpServerStatusResponse,
42
- LoginAccountParams,
43
- LoginAccountResponse,
44
40
  McpServerOauthLoginParams,
45
41
  McpServerOauthLoginResponse,
42
+ MemoryResetResponse,
46
43
  ModelListParams,
47
44
  ModelListResponse,
48
45
  ThreadForkParams,
@@ -55,6 +52,7 @@ from codexed.models import (
55
52
  ThreadStartParams,
56
53
  codex_event_adapter,
57
54
  )
55
+ from codexed.models.v2_protocol import WarningNotification
58
56
  from codexed.request_handlers import (
59
57
  SERVER_REQUEST_COMMAND_APPROVAL,
60
58
  SERVER_REQUEST_DYNAMIC_TOOL_CALL,
@@ -76,8 +74,6 @@ if TYPE_CHECKING:
76
74
  AppInfo,
77
75
  ApprovalsReviewer,
78
76
  AskForApproval,
79
- AuthMode,
80
- CancelLoginAccountStatus,
81
77
  CodexEvent,
82
78
  CollaborationModeMask,
83
79
  ConfigEdit,
@@ -86,13 +82,16 @@ if TYPE_CHECKING:
86
82
  ExperimentalFeature,
87
83
  ExternalAgentConfigMigrationItem,
88
84
  McpServerConfig,
85
+ McpServerStatusDetail,
89
86
  MergeStrategy,
90
87
  Personality,
91
88
  SandboxMode,
92
89
  SandboxPolicy,
93
90
  ServiceTier,
91
+ SortDirection,
94
92
  ThreadSortKey,
95
93
  ThreadSourceKind,
94
+ ThreadStartSource,
96
95
  ToolConfig,
97
96
  )
98
97
  from codexed.request_handlers import (
@@ -174,7 +173,10 @@ class CodexClient:
174
173
  self._mcp_elicitation_enabled = on_mcp_elicitation is not None
175
174
  self._mcp_elicitation_for_approvals = mcp_elicitation_for_approvals
176
175
  self._server_request_handlers: dict[str, ServerRequestHandler] = {}
176
+ self.account = CodexAccount(self)
177
177
  self.fs = CodexFS(self)
178
+ self.plugins = CodexPlugin(self)
179
+ self.marketplace = CodexMarketPlace(self)
178
180
  self.skills = CodexSkills(self)
179
181
  if on_approval:
180
182
  self.register_handler(SERVER_REQUEST_COMMAND_APPROVAL, on_approval) # type: ignore[arg-type]
@@ -231,6 +233,7 @@ class CodexClient:
231
233
  mcp_servers: Mapping[str, McpServerConfig] | None = None,
232
234
  experimental_raw_events: bool = False,
233
235
  persist_extended_history: bool = False,
236
+ session_start_source: ThreadStartSource | None = None,
234
237
  ) -> Session:
235
238
  """Start a new conversation thread.
236
239
 
@@ -257,6 +260,7 @@ class CodexClient:
257
260
  Merged into ``config`` under the ``mcp_servers`` key.
258
261
  experimental_raw_events: Emit raw Responses API items (internal)
259
262
  persist_extended_history: Persist full history for resume/fork/read
263
+ session_start_source: Source of the session start
260
264
 
261
265
  Returns:
262
266
  Session wrapping the new thread
@@ -287,6 +291,7 @@ class CodexClient:
287
291
  dynamic_tools=dynamic_tools,
288
292
  experimental_raw_events=experimental_raw_events,
289
293
  persist_extended_history=persist_extended_history,
294
+ session_start_source=session_start_source,
290
295
  )
291
296
  result = await self.dispatch.send_request("thread/start", params)
292
297
  response = ThreadResponse.model_validate(result)
@@ -460,6 +465,7 @@ class CodexClient:
460
465
  archived: bool | None = None,
461
466
  cwd: str | None = None,
462
467
  search_term: str | None = None,
468
+ sort_direction: SortDirection | None = None,
463
469
  ) -> ThreadListResponse:
464
470
  """List stored threads with pagination.
465
471
 
@@ -472,6 +478,7 @@ class CodexClient:
472
478
  archived: If true, only return archived threads
473
479
  cwd: Filter by working directory
474
480
  search_term: Substring filter for thread title
481
+ sort_direction: Sort direction (asc or desc)
475
482
 
476
483
  Returns:
477
484
  ThreadListResponse with data (list of threads) and next_cursor
@@ -485,6 +492,7 @@ class CodexClient:
485
492
  archived=archived,
486
493
  cwd=cwd,
487
494
  search_term=search_term,
495
+ sort_direction=sort_direction,
488
496
  )
489
497
  result = await self.dispatch.send_request("thread/list", params)
490
498
  return ThreadListResponse.model_validate(result)
@@ -589,19 +597,21 @@ class CodexClient:
589
597
  async def mcp_server_status_list(
590
598
  self,
591
599
  *,
600
+ detail: McpServerStatusDetail | None = None,
592
601
  cursor: str | None = None,
593
602
  limit: int | None = None,
594
603
  ) -> ListMcpServerStatusResponse:
595
604
  """List MCP server status with tool and resource information.
596
605
 
597
606
  Args:
607
+ detail: Level of detail to include in the response
598
608
  cursor: Pagination cursor from previous call
599
609
  limit: Maximum number of servers to return
600
610
 
601
611
  Returns:
602
612
  Response with server status entries and optional next_cursor
603
613
  """
604
- params = ListMcpServerStatusParams(cursor=cursor, limit=limit)
614
+ params = ListMcpServerStatusParams(cursor=cursor, limit=limit, detail=detail)
605
615
  result = await self.dispatch.send_request("mcpServerStatus/list", params)
606
616
  return ListMcpServerStatusResponse.model_validate(result)
607
617
 
@@ -627,68 +637,6 @@ class CodexClient:
627
637
  response = McpServerOauthLoginResponse.model_validate(result)
628
638
  return response.authorization_url
629
639
 
630
- # ========================================================================
631
- # Account methods
632
- # ========================================================================
633
-
634
- async def account_read(self, *, refresh_token: bool = False) -> GetAccountResponse:
635
- """Read account information.
636
-
637
- Args:
638
- refresh_token: When true, trigger a proactive token refresh
639
-
640
- Returns:
641
- GetAccountResponse with account info
642
- """
643
- params = GetAccountParams(refresh_token=refresh_token)
644
- result = await self.dispatch.send_request("account/read", params)
645
- return GetAccountResponse.model_validate(result)
646
-
647
- async def account_login_start(
648
- self,
649
- login_type: AuthMode,
650
- *,
651
- api_key: str | None = None,
652
- access_token: str | None = None,
653
- chatgpt_account_id: str | None = None,
654
- ) -> LoginAccountResponse:
655
- """Start account login.
656
-
657
- Args:
658
- login_type: Login type (apiKey, chatgpt, chatgptAuthTokens)
659
- api_key: API key (for apiKey type)
660
- access_token: Access token (for chatgptAuthTokens type)
661
- chatgpt_account_id: ChatGPT account ID (for chatgptAuthTokens type)
662
-
663
- Returns:
664
- LoginAccountResponse with login details
665
- """
666
- dct = dict(
667
- type=login_type,
668
- api_key=api_key,
669
- access_token=access_token,
670
- chatgpt_account_id=chatgpt_account_id,
671
- )
672
- params = TypeAdapter[LoginAccountParams](LoginAccountParams).validate_python(dct)
673
- result = await self.dispatch.send_request("account/login/start", params)
674
- return TypeAdapter[LoginAccountResponse](LoginAccountResponse).validate_python(result)
675
-
676
- async def account_login_cancel(self, login_id: str) -> CancelLoginAccountStatus:
677
- """Cancel an in-progress account login."""
678
- params = CancelLoginAccountParams(login_id=login_id)
679
- result = await self.dispatch.send_request("account/login/cancel", params)
680
- response = CancelLoginAccountResponse.model_validate(result)
681
- return response.status
682
-
683
- async def account_logout(self) -> None:
684
- """Logout from the current account."""
685
- await self.dispatch.send_request("account/logout")
686
-
687
- async def account_rate_limits_read(self) -> GetAccountRateLimitsResponse:
688
- """Read account rate limits."""
689
- result = await self.dispatch.send_request("account/rateLimits/read")
690
- return GetAccountRateLimitsResponse.model_validate(result)
691
-
692
640
  # ========================================================================
693
641
  # Config methods
694
642
  # ========================================================================
@@ -841,6 +789,7 @@ class CodexClient:
841
789
  *,
842
790
  reason: str | None = None,
843
791
  thread_id: str | None = None,
792
+ tags: dict[str, Any] | None = None,
844
793
  include_logs: bool = False,
845
794
  extra_log_files: list[str] | None = None,
846
795
  ) -> str:
@@ -850,6 +799,7 @@ class CodexClient:
850
799
  classification: Feedback classification
851
800
  reason: Optional reason text
852
801
  thread_id: Optional thread ID to associate
802
+ tags: Optional tags to associate with the feedback
853
803
  include_logs: Whether to include logs
854
804
  extra_log_files: Additional log files to include
855
805
 
@@ -860,6 +810,7 @@ class CodexClient:
860
810
  classification=classification,
861
811
  reason=reason,
862
812
  thread_id=thread_id,
813
+ tags=tags,
863
814
  include_logs=include_logs,
864
815
  extra_log_files=extra_log_files,
865
816
  )
@@ -913,7 +864,7 @@ class CodexClient:
913
864
  return
914
865
 
915
866
  event_data = {"method": method, "params": params}
916
- event: CodexEvent = codex_event_adapter.validate_python(event_data)
867
+ event = codex_event_adapter.validate_python(event_data)
917
868
 
918
869
  thread_id = params.get("threadId")
919
870
 
@@ -994,6 +945,16 @@ class CodexClient:
994
945
  """
995
946
  self._server_request_handlers = create_auto_approve_dict()
996
947
 
948
+ async def reset_memory(self) -> MemoryResetResponse:
949
+ """Reset the app-server memory."""
950
+ response = await self.dispatch.send_request("memory/reset")
951
+ return MemoryResetResponse.model_validate(response)
952
+
953
+ async def warning(self, message: str) -> None:
954
+ """Send a warning message to the app-server."""
955
+ params = WarningNotification(message=message)
956
+ await self.dispatch.send_request("warning", params)
957
+
997
958
 
998
959
  if __name__ == "__main__":
999
960
 
@@ -135,16 +135,17 @@ class CodexFS:
135
135
  params = FsCopyParams(source_path=source, destination_path=destination, recursive=recursive)
136
136
  await self._client.dispatch.send_request("fs/copy", params)
137
137
 
138
- async def watch(self, path: str) -> FsWatchResponse:
138
+ async def watch(self, path: str, watch_id: str) -> FsWatchResponse:
139
139
  """Start filesystem watch notifications for an absolute path.
140
140
 
141
141
  Args:
142
142
  path: Absolute file or directory path to watch.
143
+ watch_id: Watch identifier to associate with the path.
143
144
 
144
145
  Returns:
145
146
  FsWatchResponse with watch_id and canonicalized path.
146
147
  """
147
- params = FsWatchParams(path=path)
148
+ params = FsWatchParams(path=path, watch_id=watch_id)
148
149
  result = await self._client.dispatch.send_request("fs/watch", params)
149
150
  return FsWatchResponse.model_validate(result)
150
151
 
@@ -0,0 +1,54 @@
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 import (
9
+ MarketplaceAddParams,
10
+ MarketplaceAddResponse,
11
+ MarketplaceRemoveParams,
12
+ MarketplaceRemoveResponse,
13
+ )
14
+
15
+
16
+ if TYPE_CHECKING:
17
+ from codexed.client import CodexClient
18
+
19
+ logger = logging.getLogger(__name__)
20
+
21
+
22
+ class CodexMarketPlace:
23
+ def __init__(self, client: CodexClient):
24
+ self._client = client
25
+
26
+ async def add(
27
+ self,
28
+ source: str,
29
+ ref_name: str | None = None,
30
+ sparse_paths: list[str] | None = None,
31
+ ) -> MarketplaceAddResponse:
32
+ """Add a marketplace to the app-server."""
33
+ params = MarketplaceAddParams(ref_name=ref_name, source=source, sparse_paths=sparse_paths)
34
+ response = await self._client.dispatch.send_request("marketplace/add", params)
35
+ return MarketplaceAddResponse.model_validate(response)
36
+
37
+ async def remove(self, ref_name: str):
38
+ """Remove a marketplace from the app-server."""
39
+ params = MarketplaceRemoveParams(marketplace_name=ref_name)
40
+ response = await self._client.dispatch.send_request("marketplace/remove", params)
41
+ return MarketplaceRemoveResponse.model_validate(response)
42
+
43
+
44
+ if __name__ == "__main__":
45
+ import asyncio
46
+
47
+ from codexed.client import CodexClient
48
+
49
+ async def main():
50
+ client = CodexClient()
51
+ async with client:
52
+ _test = await client.marketplace.add("test")
53
+
54
+ asyncio.run(main())
@@ -0,0 +1,80 @@
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 import (
9
+ PluginInstallParams,
10
+ PluginInstallResponse,
11
+ PluginListParams,
12
+ PluginListResponse,
13
+ PluginReadParams,
14
+ PluginReadResponse,
15
+ PluginUninstallParams,
16
+ )
17
+
18
+
19
+ if TYPE_CHECKING:
20
+ from codexed.client import CodexClient
21
+
22
+ logger = logging.getLogger(__name__)
23
+
24
+
25
+ class CodexPlugin:
26
+ def __init__(self, client: CodexClient):
27
+ self._client = client
28
+
29
+ async def install(
30
+ self,
31
+ plugin_name: str,
32
+ marketplace_path: str | None = None,
33
+ remote_marketplace_name: str | None = None,
34
+ ) -> PluginInstallResponse:
35
+ """Install a plugin on the app-server."""
36
+ params = PluginInstallParams(
37
+ marketplace_path=marketplace_path,
38
+ plugin_name=plugin_name,
39
+ remote_marketplace_name=remote_marketplace_name,
40
+ )
41
+ response = await self._client.dispatch.send_request("plugin/install", params)
42
+ return PluginInstallResponse.model_validate(response)
43
+
44
+ async def uninstall(self, plugin_id: str) -> None:
45
+ """Uninstall a plugin from the app-server."""
46
+ params = PluginUninstallParams(plugin_id=plugin_id)
47
+ await self._client.dispatch.send_request("plugin/uninstall", params)
48
+
49
+ async def list(self, cwds: list[str] | None = None) -> PluginListResponse:
50
+ params = PluginListParams(cwds=cwds)
51
+ response = await self._client.dispatch.send_request("plugin/list", params)
52
+ return PluginListResponse.model_validate(response)
53
+
54
+ async def read(
55
+ self,
56
+ plugin_name: str,
57
+ marketplace_path: str | None = None,
58
+ remote_marketplace_name: str | None = None,
59
+ ) -> PluginReadResponse:
60
+ params = PluginReadParams(
61
+ marketplace_path=marketplace_path,
62
+ plugin_name=plugin_name,
63
+ remote_marketplace_name=remote_marketplace_name,
64
+ )
65
+ response = await self._client.dispatch.send_request("plugin/read", params)
66
+ return PluginReadResponse.model_validate(response)
67
+
68
+
69
+ if __name__ == "__main__":
70
+ import asyncio
71
+
72
+ from codexed.client import CodexClient
73
+
74
+ async def main():
75
+ client = CodexClient()
76
+ async with client:
77
+ response = await client.plugins.list()
78
+ print(response)
79
+
80
+ asyncio.run(main())
@@ -13,6 +13,8 @@ from codexed.models import (
13
13
  ThreadRealtimeAppendTextResponse,
14
14
  ThreadRealtimeAudioChunk,
15
15
  ThreadRealtimeClosedMessage,
16
+ ThreadRealtimeListVoicesParams,
17
+ ThreadRealtimeListVoicesResponse,
16
18
  ThreadRealtimeStartedMessage,
17
19
  ThreadRealtimeStartParams,
18
20
  ThreadRealtimeStartResponse,
@@ -26,35 +28,30 @@ if TYPE_CHECKING:
26
28
  from types import TracebackType
27
29
 
28
30
  from codexed.client import CodexClient
29
- from codexed.models import CodexEvent
31
+ from codexed.models import (
32
+ CodexEvent,
33
+ RealtimeOutputModality,
34
+ RealtimeVoice,
35
+ RealtimeVoicesList,
36
+ ThreadRealtimeStartTransport,
37
+ )
30
38
 
31
39
  logger = logging.getLogger(__name__)
32
40
 
33
41
 
34
42
  class RealtimeSession:
35
- """Async context manager for a thread-scoped realtime voice session.
36
-
37
- Usage::
38
-
39
- async with session.realtime(prompt="You are helpful") as rt:
40
- await rt.send_text("hello")
41
- async for event in rt:
42
- match event:
43
- case ThreadRealtimeOutputAudioDeltaMessage():
44
- play(event.params.audio)
45
- case ThreadRealtimeTranscriptUpdatedMessage():
46
- print(event.params.text)
47
- case ThreadRealtimeClosedMessage():
48
- break
49
- """
43
+ """Async context manager for a thread-scoped realtime voice session."""
50
44
 
51
45
  def __init__(
52
46
  self,
53
47
  client: CodexClient,
54
48
  thread_id: str,
55
- prompt: str,
49
+ output_modality: RealtimeOutputModality,
50
+ prompt: str | None = None,
56
51
  *,
57
52
  session_id: str | None = None,
53
+ transport: ThreadRealtimeStartTransport | None = None,
54
+ voice: RealtimeVoice | None = None,
58
55
  ) -> None:
59
56
  self._client = client
60
57
  self._thread_id = thread_id
@@ -63,6 +60,9 @@ class RealtimeSession:
63
60
  self._queue: asyncio.Queue[CodexEvent | None] = asyncio.Queue()
64
61
  self._closed = False
65
62
  self._queue_key = f"realtime:{thread_id}"
63
+ self._output_modality: RealtimeOutputModality = output_modality
64
+ self._transport = transport
65
+ self._voice = voice
66
66
 
67
67
  @property
68
68
  def thread_id(self) -> str:
@@ -81,6 +81,7 @@ class RealtimeSession:
81
81
  thread_id=self._thread_id,
82
82
  prompt=self._prompt,
83
83
  session_id=self._session_id,
84
+ output_modality=self._output_modality,
84
85
  )
85
86
  result = await self._client.dispatch.send_request("thread/realtime/start", params)
86
87
  ThreadRealtimeStartResponse.model_validate(result)
@@ -128,13 +129,17 @@ class RealtimeSession:
128
129
 
129
130
  async def send_text(self, text: str) -> None:
130
131
  """Send text input to the realtime session."""
131
- params = ThreadRealtimeAppendTextParams(
132
- thread_id=self._thread_id,
133
- text=text,
134
- )
132
+ params = ThreadRealtimeAppendTextParams(thread_id=self._thread_id, text=text)
135
133
  result = await self._client.dispatch.send_request("thread/realtime/appendText", params)
136
134
  ThreadRealtimeAppendTextResponse.model_validate(result)
137
135
 
136
+ async def list_voices(self) -> RealtimeVoicesList:
137
+ """List available voices for the realtime session."""
138
+ params = ThreadRealtimeListVoicesParams()
139
+ result = await self._client.dispatch.send_request("thread/realtime/listVoices", params)
140
+ data = ThreadRealtimeListVoicesResponse.model_validate(result)
141
+ return data.voices
142
+
138
143
  async def send_audio(
139
144
  self,
140
145
  data: str,