codexed 1.2.0__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.
- {codexed-1.2.0 → codexed-1.2.1}/PKG-INFO +1 -1
- {codexed-1.2.0 → codexed-1.2.1}/pyproject.toml +1 -1
- codexed-1.2.1/src/codexed/client/__init__.py +19 -0
- codexed-1.2.1/src/codexed/client/account.py +108 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/client/client.py +16 -84
- codexed-1.2.1/src/codexed/client/marketplace.py +54 -0
- codexed-1.2.1/src/codexed/client/plugin.py +80 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/client/realtime.py +3 -2
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/client/session.py +46 -6
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/__init__.py +32 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/request_params.py +2 -2
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/responses.py +1 -1
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/tool_config.py +1 -1
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/v2_protocol.py +215 -29
- codexed-1.2.0/src/codexed/client/__init__.py +0 -9
- {codexed-1.2.0 → codexed-1.2.1}/LICENSE +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/README.md +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/README.md +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/__init__.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/client/dispatch.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/client/fs.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/client/skills.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/exceptions.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/helpers.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/log.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/base.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/codex_types.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/event_data.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/events.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/mcp_server.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/misc.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/models/thread_item.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/py.typed +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/request_handlers.py +0 -0
- {codexed-1.2.0 → codexed-1.2.1}/src/codexed/transport.py +0 -0
|
@@ -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,8 @@ 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
|
-
MarketplaceAddParams,
|
|
45
|
-
MarketplaceAddResponse,
|
|
46
40
|
McpServerOauthLoginParams,
|
|
47
41
|
McpServerOauthLoginResponse,
|
|
48
42
|
MemoryResetResponse,
|
|
@@ -58,6 +52,7 @@ from codexed.models import (
|
|
|
58
52
|
ThreadStartParams,
|
|
59
53
|
codex_event_adapter,
|
|
60
54
|
)
|
|
55
|
+
from codexed.models.v2_protocol import WarningNotification
|
|
61
56
|
from codexed.request_handlers import (
|
|
62
57
|
SERVER_REQUEST_COMMAND_APPROVAL,
|
|
63
58
|
SERVER_REQUEST_DYNAMIC_TOOL_CALL,
|
|
@@ -79,8 +74,6 @@ if TYPE_CHECKING:
|
|
|
79
74
|
AppInfo,
|
|
80
75
|
ApprovalsReviewer,
|
|
81
76
|
AskForApproval,
|
|
82
|
-
AuthMode,
|
|
83
|
-
CancelLoginAccountStatus,
|
|
84
77
|
CodexEvent,
|
|
85
78
|
CollaborationModeMask,
|
|
86
79
|
ConfigEdit,
|
|
@@ -95,6 +88,7 @@ if TYPE_CHECKING:
|
|
|
95
88
|
SandboxMode,
|
|
96
89
|
SandboxPolicy,
|
|
97
90
|
ServiceTier,
|
|
91
|
+
SortDirection,
|
|
98
92
|
ThreadSortKey,
|
|
99
93
|
ThreadSourceKind,
|
|
100
94
|
ThreadStartSource,
|
|
@@ -179,7 +173,10 @@ class CodexClient:
|
|
|
179
173
|
self._mcp_elicitation_enabled = on_mcp_elicitation is not None
|
|
180
174
|
self._mcp_elicitation_for_approvals = mcp_elicitation_for_approvals
|
|
181
175
|
self._server_request_handlers: dict[str, ServerRequestHandler] = {}
|
|
176
|
+
self.account = CodexAccount(self)
|
|
182
177
|
self.fs = CodexFS(self)
|
|
178
|
+
self.plugins = CodexPlugin(self)
|
|
179
|
+
self.marketplace = CodexMarketPlace(self)
|
|
183
180
|
self.skills = CodexSkills(self)
|
|
184
181
|
if on_approval:
|
|
185
182
|
self.register_handler(SERVER_REQUEST_COMMAND_APPROVAL, on_approval) # type: ignore[arg-type]
|
|
@@ -468,6 +465,7 @@ class CodexClient:
|
|
|
468
465
|
archived: bool | None = None,
|
|
469
466
|
cwd: str | None = None,
|
|
470
467
|
search_term: str | None = None,
|
|
468
|
+
sort_direction: SortDirection | None = None,
|
|
471
469
|
) -> ThreadListResponse:
|
|
472
470
|
"""List stored threads with pagination.
|
|
473
471
|
|
|
@@ -480,6 +478,7 @@ class CodexClient:
|
|
|
480
478
|
archived: If true, only return archived threads
|
|
481
479
|
cwd: Filter by working directory
|
|
482
480
|
search_term: Substring filter for thread title
|
|
481
|
+
sort_direction: Sort direction (asc or desc)
|
|
483
482
|
|
|
484
483
|
Returns:
|
|
485
484
|
ThreadListResponse with data (list of threads) and next_cursor
|
|
@@ -493,6 +492,7 @@ class CodexClient:
|
|
|
493
492
|
archived=archived,
|
|
494
493
|
cwd=cwd,
|
|
495
494
|
search_term=search_term,
|
|
495
|
+
sort_direction=sort_direction,
|
|
496
496
|
)
|
|
497
497
|
result = await self.dispatch.send_request("thread/list", params)
|
|
498
498
|
return ThreadListResponse.model_validate(result)
|
|
@@ -637,68 +637,6 @@ class CodexClient:
|
|
|
637
637
|
response = McpServerOauthLoginResponse.model_validate(result)
|
|
638
638
|
return response.authorization_url
|
|
639
639
|
|
|
640
|
-
# ========================================================================
|
|
641
|
-
# Account methods
|
|
642
|
-
# ========================================================================
|
|
643
|
-
|
|
644
|
-
async def account_read(self, *, refresh_token: bool = False) -> GetAccountResponse:
|
|
645
|
-
"""Read account information.
|
|
646
|
-
|
|
647
|
-
Args:
|
|
648
|
-
refresh_token: When true, trigger a proactive token refresh
|
|
649
|
-
|
|
650
|
-
Returns:
|
|
651
|
-
GetAccountResponse with account info
|
|
652
|
-
"""
|
|
653
|
-
params = GetAccountParams(refresh_token=refresh_token)
|
|
654
|
-
result = await self.dispatch.send_request("account/read", params)
|
|
655
|
-
return GetAccountResponse.model_validate(result)
|
|
656
|
-
|
|
657
|
-
async def account_login_start(
|
|
658
|
-
self,
|
|
659
|
-
login_type: AuthMode,
|
|
660
|
-
*,
|
|
661
|
-
api_key: str | None = None,
|
|
662
|
-
access_token: str | None = None,
|
|
663
|
-
chatgpt_account_id: str | None = None,
|
|
664
|
-
) -> LoginAccountResponse:
|
|
665
|
-
"""Start account login.
|
|
666
|
-
|
|
667
|
-
Args:
|
|
668
|
-
login_type: Login type (apiKey, chatgpt, chatgptAuthTokens)
|
|
669
|
-
api_key: API key (for apiKey type)
|
|
670
|
-
access_token: Access token (for chatgptAuthTokens type)
|
|
671
|
-
chatgpt_account_id: ChatGPT account ID (for chatgptAuthTokens type)
|
|
672
|
-
|
|
673
|
-
Returns:
|
|
674
|
-
LoginAccountResponse with login details
|
|
675
|
-
"""
|
|
676
|
-
dct = dict(
|
|
677
|
-
type=login_type,
|
|
678
|
-
api_key=api_key,
|
|
679
|
-
access_token=access_token,
|
|
680
|
-
chatgpt_account_id=chatgpt_account_id,
|
|
681
|
-
)
|
|
682
|
-
params = TypeAdapter[LoginAccountParams](LoginAccountParams).validate_python(dct)
|
|
683
|
-
result = await self.dispatch.send_request("account/login/start", params)
|
|
684
|
-
return TypeAdapter[LoginAccountResponse](LoginAccountResponse).validate_python(result)
|
|
685
|
-
|
|
686
|
-
async def account_login_cancel(self, login_id: str) -> CancelLoginAccountStatus:
|
|
687
|
-
"""Cancel an in-progress account login."""
|
|
688
|
-
params = CancelLoginAccountParams(login_id=login_id)
|
|
689
|
-
result = await self.dispatch.send_request("account/login/cancel", params)
|
|
690
|
-
response = CancelLoginAccountResponse.model_validate(result)
|
|
691
|
-
return response.status
|
|
692
|
-
|
|
693
|
-
async def account_logout(self) -> None:
|
|
694
|
-
"""Logout from the current account."""
|
|
695
|
-
await self.dispatch.send_request("account/logout")
|
|
696
|
-
|
|
697
|
-
async def account_rate_limits_read(self) -> GetAccountRateLimitsResponse:
|
|
698
|
-
"""Read account rate limits."""
|
|
699
|
-
result = await self.dispatch.send_request("account/rateLimits/read")
|
|
700
|
-
return GetAccountRateLimitsResponse.model_validate(result)
|
|
701
|
-
|
|
702
640
|
# ========================================================================
|
|
703
641
|
# Config methods
|
|
704
642
|
# ========================================================================
|
|
@@ -1007,22 +945,16 @@ class CodexClient:
|
|
|
1007
945
|
"""
|
|
1008
946
|
self._server_request_handlers = create_auto_approve_dict()
|
|
1009
947
|
|
|
1010
|
-
async def add_marketplace(
|
|
1011
|
-
self,
|
|
1012
|
-
ref_name: str | None,
|
|
1013
|
-
source: str,
|
|
1014
|
-
sparse_paths: list[str] | None = None,
|
|
1015
|
-
) -> MarketplaceAddResponse:
|
|
1016
|
-
"""Add a marketplace to the app-server."""
|
|
1017
|
-
params = MarketplaceAddParams(ref_name=ref_name, source=source, sparse_paths=sparse_paths)
|
|
1018
|
-
response = await self.dispatch.send_request("marketplace/add", params)
|
|
1019
|
-
return MarketplaceAddResponse.model_validate(response)
|
|
1020
|
-
|
|
1021
948
|
async def reset_memory(self) -> MemoryResetResponse:
|
|
1022
949
|
"""Reset the app-server memory."""
|
|
1023
950
|
response = await self.dispatch.send_request("memory/reset")
|
|
1024
951
|
return MemoryResetResponse.model_validate(response)
|
|
1025
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
|
+
|
|
1026
958
|
|
|
1027
959
|
if __name__ == "__main__":
|
|
1028
960
|
|
|
@@ -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())
|
|
@@ -46,10 +46,10 @@ class RealtimeSession:
|
|
|
46
46
|
self,
|
|
47
47
|
client: CodexClient,
|
|
48
48
|
thread_id: str,
|
|
49
|
+
output_modality: RealtimeOutputModality,
|
|
49
50
|
prompt: str | None = None,
|
|
50
51
|
*,
|
|
51
52
|
session_id: str | None = None,
|
|
52
|
-
output_modality: RealtimeOutputModality | None = None,
|
|
53
53
|
transport: ThreadRealtimeStartTransport | None = None,
|
|
54
54
|
voice: RealtimeVoice | None = None,
|
|
55
55
|
) -> None:
|
|
@@ -60,7 +60,7 @@ class RealtimeSession:
|
|
|
60
60
|
self._queue: asyncio.Queue[CodexEvent | None] = asyncio.Queue()
|
|
61
61
|
self._closed = False
|
|
62
62
|
self._queue_key = f"realtime:{thread_id}"
|
|
63
|
-
self._output_modality = output_modality
|
|
63
|
+
self._output_modality: RealtimeOutputModality = output_modality
|
|
64
64
|
self._transport = transport
|
|
65
65
|
self._voice = voice
|
|
66
66
|
|
|
@@ -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)
|
|
@@ -39,6 +39,8 @@ from codexed.models import (
|
|
|
39
39
|
ThreadShellCommandParams,
|
|
40
40
|
ThreadTokenUsageUpdatedEvent,
|
|
41
41
|
ThreadTokenUsageUpdatedNotification,
|
|
42
|
+
ThreadTurnsListParams,
|
|
43
|
+
ThreadTurnsListResponse,
|
|
42
44
|
ThreadUnarchiveParams,
|
|
43
45
|
ThreadUnarchiveResponse,
|
|
44
46
|
ThreadUnsubscribeParams,
|
|
@@ -50,6 +52,7 @@ from codexed.models import (
|
|
|
50
52
|
TurnStartResponse,
|
|
51
53
|
TurnSteerParams,
|
|
52
54
|
TurnSteerResponse,
|
|
55
|
+
WarningNotification,
|
|
53
56
|
WorkspaceWriteSandboxPolicy,
|
|
54
57
|
)
|
|
55
58
|
|
|
@@ -65,12 +68,14 @@ if TYPE_CHECKING:
|
|
|
65
68
|
CollaborationMode,
|
|
66
69
|
McpServerConfig,
|
|
67
70
|
Personality,
|
|
71
|
+
RealtimeOutputModality,
|
|
68
72
|
ReasoningEffort,
|
|
69
73
|
ReasoningSummary,
|
|
70
74
|
ReviewDelivery,
|
|
71
75
|
ReviewTarget,
|
|
72
76
|
SandboxMode,
|
|
73
77
|
ServiceTier,
|
|
78
|
+
SortDirection,
|
|
74
79
|
ThreadMemoryMode,
|
|
75
80
|
ThreadResponse,
|
|
76
81
|
ThreadTokenUsage,
|
|
@@ -176,7 +181,9 @@ class Session:
|
|
|
176
181
|
policy = sandbox_policy
|
|
177
182
|
case _:
|
|
178
183
|
assert_never(sandbox_policy)
|
|
179
|
-
in_
|
|
184
|
+
in_: list[UserInput] = (
|
|
185
|
+
[TextUserInput(text=user_input)] if isinstance(user_input, str) else list(user_input)
|
|
186
|
+
)
|
|
180
187
|
params = TurnStartParams(
|
|
181
188
|
thread_id=self.thread_id,
|
|
182
189
|
input=in_,
|
|
@@ -241,7 +248,7 @@ class Session:
|
|
|
241
248
|
"""
|
|
242
249
|
params = TurnSteerParams(
|
|
243
250
|
thread_id=self.thread_id,
|
|
244
|
-
input=[TextUserInput(text=user_input)]
|
|
251
|
+
input=[TextUserInput(text=user_input)] # pyright: ignore[reportCallIssue, reportArgumentType]
|
|
245
252
|
if isinstance(user_input, str)
|
|
246
253
|
else list(user_input),
|
|
247
254
|
expected_turn_id=expected_turn_id,
|
|
@@ -354,7 +361,13 @@ class Session:
|
|
|
354
361
|
params = ThreadCompactStartParams(thread_id=self.thread_id)
|
|
355
362
|
await self._client.dispatch.send_request("thread/compact/start", params)
|
|
356
363
|
|
|
357
|
-
def realtime(
|
|
364
|
+
def realtime(
|
|
365
|
+
self,
|
|
366
|
+
output_modality: RealtimeOutputModality,
|
|
367
|
+
prompt: str | None = None,
|
|
368
|
+
*,
|
|
369
|
+
session_id: str | None = None,
|
|
370
|
+
) -> RealtimeSession:
|
|
358
371
|
"""Open a realtime voice session on this thread.
|
|
359
372
|
|
|
360
373
|
Returns an async context manager that sends ``thread/realtime/start``
|
|
@@ -368,7 +381,29 @@ class Session:
|
|
|
368
381
|
async for event in rt:
|
|
369
382
|
...
|
|
370
383
|
"""
|
|
371
|
-
return RealtimeSession(
|
|
384
|
+
return RealtimeSession(
|
|
385
|
+
self._client,
|
|
386
|
+
self.thread_id,
|
|
387
|
+
output_modality=output_modality,
|
|
388
|
+
prompt=prompt,
|
|
389
|
+
session_id=session_id,
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
async def list_turns(
|
|
393
|
+
self,
|
|
394
|
+
cursor: str | None = None,
|
|
395
|
+
limit: int | None = None,
|
|
396
|
+
sort_direction: SortDirection | None = None,
|
|
397
|
+
) -> ThreadTurnsListResponse:
|
|
398
|
+
"""List all turns in this thread."""
|
|
399
|
+
params = ThreadTurnsListParams(
|
|
400
|
+
cursor=cursor,
|
|
401
|
+
limit=limit,
|
|
402
|
+
sort_direction=sort_direction,
|
|
403
|
+
thread_id=self.thread_id,
|
|
404
|
+
)
|
|
405
|
+
result = await self._client.dispatch.send_request("thread/turns/list", params)
|
|
406
|
+
return ThreadTurnsListResponse.model_validate(result)
|
|
372
407
|
|
|
373
408
|
async def rollback(self, turns: int) -> ThreadRollbackResponse:
|
|
374
409
|
"""Rollback the last N turns from this thread.
|
|
@@ -589,9 +624,9 @@ class Session:
|
|
|
589
624
|
data = McpServerToolCallResponse.model_validate(result)
|
|
590
625
|
return CallToolResult(
|
|
591
626
|
structuredContent=data.structured_content,
|
|
592
|
-
isError=data.is_error,
|
|
627
|
+
isError=bool(data.is_error),
|
|
593
628
|
content=data.content,
|
|
594
|
-
|
|
629
|
+
meta=data.field_meta,
|
|
595
630
|
)
|
|
596
631
|
|
|
597
632
|
def __repr__(self) -> str:
|
|
@@ -606,3 +641,8 @@ class Session:
|
|
|
606
641
|
"""Set the thread's memory mode."""
|
|
607
642
|
params = ThreadMemoryModeSetParams(mode=mode, thread_id=self.thread_id)
|
|
608
643
|
await self._client.dispatch.send_request("thread/memoryMode/set", params)
|
|
644
|
+
|
|
645
|
+
async def warning(self, message: str) -> None:
|
|
646
|
+
"""Send a thread-related warning message to the app-server."""
|
|
647
|
+
params = WarningNotification(message=message, thread_id=self.thread_id)
|
|
648
|
+
await self._client.dispatch.send_request("warning", params)
|