codexed 1.2.0__tar.gz → 1.2.2__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 (36) hide show
  1. {codexed-1.2.0 → codexed-1.2.2}/PKG-INFO +1 -1
  2. {codexed-1.2.0 → codexed-1.2.2}/pyproject.toml +1 -1
  3. codexed-1.2.2/src/codexed/client/__init__.py +21 -0
  4. codexed-1.2.2/src/codexed/client/account.py +108 -0
  5. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/client/client.py +61 -82
  6. codexed-1.2.2/src/codexed/client/device.py +67 -0
  7. codexed-1.2.2/src/codexed/client/marketplace.py +62 -0
  8. codexed-1.2.2/src/codexed/client/plugin.py +80 -0
  9. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/client/realtime.py +3 -2
  10. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/client/session.py +78 -9
  11. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/__init__.py +40 -0
  12. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/mcp_server.py +4 -0
  13. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/request_params.py +2 -2
  14. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/responses.py +1 -1
  15. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/tool_config.py +1 -1
  16. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/v2_protocol.py +836 -48
  17. codexed-1.2.0/src/codexed/client/__init__.py +0 -9
  18. {codexed-1.2.0 → codexed-1.2.2}/LICENSE +0 -0
  19. {codexed-1.2.0 → codexed-1.2.2}/README.md +0 -0
  20. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/README.md +0 -0
  21. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/__init__.py +0 -0
  22. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/client/dispatch.py +0 -0
  23. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/client/fs.py +0 -0
  24. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/client/skills.py +0 -0
  25. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/exceptions.py +0 -0
  26. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/helpers.py +0 -0
  27. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/log.py +0 -0
  28. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/base.py +0 -0
  29. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/codex_types.py +0 -0
  30. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/event_data.py +0 -0
  31. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/events.py +0 -0
  32. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/misc.py +0 -0
  33. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/models/thread_item.py +0 -0
  34. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/py.typed +0 -0
  35. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/request_handlers.py +0 -0
  36. {codexed-1.2.0 → codexed-1.2.2}/src/codexed/transport.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codexed
3
- Version: 1.2.0
3
+ Version: 1.2.2
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.2.0"
5
+ version = "1.2.2"
6
6
  description = "Alternative codex app-server client"
7
7
  readme = "README.md"
8
8
  requires-python = ">=3.13"
@@ -0,0 +1,21 @@
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 .device import CodexDevice
9
+ from .realtime import RealtimeSession
10
+ from .session import Session
11
+
12
+ __all__ = [
13
+ "CodexClient",
14
+ "CodexDevice",
15
+ "CodexFS",
16
+ "CodexMarketPlace",
17
+ "CodexPlugin",
18
+ "CodexSkills",
19
+ "RealtimeSession",
20
+ "Session",
21
+ ]
@@ -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,17 @@ from typing import TYPE_CHECKING, Any
9
9
 
10
10
  from pydantic import TypeAdapter
11
11
 
12
+ from codexed.client.account import CodexAccount
13
+ from codexed.client.device import CodexDevice
12
14
  from codexed.client.dispatch import Dispatch
13
15
  from codexed.client.fs import CodexFS
16
+ from codexed.client.marketplace import CodexMarketPlace
17
+ from codexed.client.plugin import CodexPlugin
14
18
  from codexed.client.skills import CodexSkills
15
19
  from codexed.helpers import merge_config
16
20
  from codexed.models import (
17
21
  AppsListParams,
18
22
  AppsListResponse,
19
- CancelLoginAccountParams,
20
- CancelLoginAccountResponse,
21
23
  CollaborationModeListResponse,
22
24
  CommandExecParams,
23
25
  CommandExecResponse,
@@ -34,15 +36,10 @@ from codexed.models import (
34
36
  ExternalAgentConfigImportParams,
35
37
  FeedbackUploadParams,
36
38
  FeedbackUploadResponse,
37
- GetAccountParams,
38
- GetAccountRateLimitsResponse,
39
- GetAccountResponse,
40
39
  ListMcpServerStatusParams,
41
40
  ListMcpServerStatusResponse,
42
- LoginAccountParams,
43
- LoginAccountResponse,
44
- MarketplaceAddParams,
45
- MarketplaceAddResponse,
41
+ McpResourceReadParams,
42
+ McpResourceReadResponse,
46
43
  McpServerOauthLoginParams,
47
44
  McpServerOauthLoginResponse,
48
45
  MemoryResetResponse,
@@ -56,8 +53,10 @@ from codexed.models import (
56
53
  ThreadResponse,
57
54
  ThreadResumeParams,
58
55
  ThreadStartParams,
56
+ WarningNotification,
59
57
  codex_event_adapter,
60
58
  )
59
+ from codexed.models.mcp_server import ResourceContents
61
60
  from codexed.request_handlers import (
62
61
  SERVER_REQUEST_COMMAND_APPROVAL,
63
62
  SERVER_REQUEST_DYNAMIC_TOOL_CALL,
@@ -74,13 +73,13 @@ from codexed.transport import StdioTransport
74
73
  if TYPE_CHECKING:
75
74
  from typing import Self
76
75
 
76
+ from pydantic import BaseModel
77
+
77
78
  from codexed.client.session import Session
78
79
  from codexed.models import (
79
80
  AppInfo,
80
81
  ApprovalsReviewer,
81
82
  AskForApproval,
82
- AuthMode,
83
- CancelLoginAccountStatus,
84
83
  CodexEvent,
85
84
  CollaborationModeMask,
86
85
  ConfigEdit,
@@ -91,15 +90,19 @@ if TYPE_CHECKING:
91
90
  McpServerConfig,
92
91
  McpServerStatusDetail,
93
92
  MergeStrategy,
93
+ PermissionProfile,
94
94
  Personality,
95
95
  SandboxMode,
96
96
  SandboxPolicy,
97
97
  ServiceTier,
98
+ SortDirection,
98
99
  ThreadSortKey,
99
100
  ThreadSourceKind,
100
101
  ThreadStartSource,
101
102
  ToolConfig,
103
+ TurnEnvironmentParams,
102
104
  )
105
+ from codexed.models.v2_protocol import ThreadListCwdFilter
103
106
  from codexed.request_handlers import (
104
107
  ApprovalHandler,
105
108
  DynamicToolCallHandler,
@@ -179,7 +182,11 @@ class CodexClient:
179
182
  self._mcp_elicitation_enabled = on_mcp_elicitation is not None
180
183
  self._mcp_elicitation_for_approvals = mcp_elicitation_for_approvals
181
184
  self._server_request_handlers: dict[str, ServerRequestHandler] = {}
185
+ self.account = CodexAccount(self)
182
186
  self.fs = CodexFS(self)
187
+ self.device = CodexDevice(self)
188
+ self.plugins = CodexPlugin(self)
189
+ self.marketplace = CodexMarketPlace(self)
183
190
  self.skills = CodexSkills(self)
184
191
  if on_approval:
185
192
  self.register_handler(SERVER_REQUEST_COMMAND_APPROVAL, on_approval) # type: ignore[arg-type]
@@ -237,6 +244,7 @@ class CodexClient:
237
244
  experimental_raw_events: bool = False,
238
245
  persist_extended_history: bool = False,
239
246
  session_start_source: ThreadStartSource | None = None,
247
+ environments: list[TurnEnvironmentParams] | None = None,
240
248
  ) -> Session:
241
249
  """Start a new conversation thread.
242
250
 
@@ -264,6 +272,7 @@ class CodexClient:
264
272
  experimental_raw_events: Emit raw Responses API items (internal)
265
273
  persist_extended_history: Persist full history for resume/fork/read
266
274
  session_start_source: Source of the session start
275
+ environments: List of environment variables to set for the thread
267
276
 
268
277
  Returns:
269
278
  Session wrapping the new thread
@@ -295,6 +304,7 @@ class CodexClient:
295
304
  experimental_raw_events=experimental_raw_events,
296
305
  persist_extended_history=persist_extended_history,
297
306
  session_start_source=session_start_source,
307
+ environments=environments,
298
308
  )
299
309
  result = await self.dispatch.send_request("thread/start", params)
300
310
  response = ThreadResponse.model_validate(result)
@@ -321,6 +331,8 @@ class CodexClient:
321
331
  personality: Personality | None = None,
322
332
  mcp_servers: Mapping[str, McpServerConfig] | None = None,
323
333
  persist_extended_history: bool = False,
334
+ exclude_turns: bool | None = None,
335
+ permission_profile: PermissionProfile | None = None,
324
336
  ) -> Session:
325
337
  """Resume an existing thread by ID.
326
338
 
@@ -342,6 +354,8 @@ class CodexClient:
342
354
  personality: Personality override
343
355
  mcp_servers: Per-thread MCP server configurations
344
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
345
359
 
346
360
  Returns:
347
361
  Session wrapping the resumed thread
@@ -370,6 +384,8 @@ class CodexClient:
370
384
  service_tier=service_tier,
371
385
  personality=personality,
372
386
  persist_extended_history=persist_extended_history,
387
+ exclude_turns=exclude_turns,
388
+ permission_profile=permission_profile,
373
389
  )
374
390
  result = await self.dispatch.send_request("thread/resume", params)
375
391
  response = ThreadResponse.model_validate(result)
@@ -397,6 +413,8 @@ class CodexClient:
397
413
  mcp_servers: Mapping[str, McpServerConfig] | None = None,
398
414
  turn_id: str | None = None,
399
415
  persist_extended_history: bool = False,
416
+ exclude_turns: bool | None = None,
417
+ permission_profile: PermissionProfile | None = None,
400
418
  ) -> Session:
401
419
  """Fork an existing thread into a new thread with copied history.
402
420
 
@@ -420,6 +438,10 @@ class CodexClient:
420
438
  mcp_servers: Per-thread MCP server configurations
421
439
  turn_id: If provided, rollback the forked thread to this turn
422
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
423
445
 
424
446
  Returns:
425
447
  Session wrapping the new forked thread
@@ -448,6 +470,8 @@ class CodexClient:
448
470
  service_tier=service_tier,
449
471
  ephemeral=ephemeral,
450
472
  persist_extended_history=persist_extended_history,
473
+ exclude_turns=exclude_turns,
474
+ permission_profile=permission_profile,
451
475
  )
452
476
  result = await self.dispatch.send_request("thread/fork", params)
453
477
  response = ThreadResponse.model_validate(result)
@@ -466,8 +490,10 @@ class CodexClient:
466
490
  model_providers: list[str] | None = None,
467
491
  source_kinds: list[ThreadSourceKind] | None = None,
468
492
  archived: bool | None = None,
469
- cwd: str | None = None,
493
+ cwd: ThreadListCwdFilter | None = None,
470
494
  search_term: str | None = None,
495
+ sort_direction: SortDirection | None = None,
496
+ use_state_db_only: bool | None = None,
471
497
  ) -> ThreadListResponse:
472
498
  """List stored threads with pagination.
473
499
 
@@ -480,6 +506,8 @@ class CodexClient:
480
506
  archived: If true, only return archived threads
481
507
  cwd: Filter by working directory
482
508
  search_term: Substring filter for thread title
509
+ sort_direction: Sort direction (asc or desc)
510
+ use_state_db_only: If true, only return threads from the state DB
483
511
 
484
512
  Returns:
485
513
  ThreadListResponse with data (list of threads) and next_cursor
@@ -493,6 +521,8 @@ class CodexClient:
493
521
  archived=archived,
494
522
  cwd=cwd,
495
523
  search_term=search_term,
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,67 +670,19 @@ class CodexClient:
637
670
  response = McpServerOauthLoginResponse.model_validate(result)
638
671
  return response.authorization_url
639
672
 
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.
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)
666
679
 
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)
680
+ def convert(old: BaseModel) -> ResourceContents:
681
+ dct = old.model_dump()
682
+ dct["_meta"] = dct.pop("field_meta")
683
+ return ta.validate_python(dct)
672
684
 
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)
685
+ return [convert(i) for i in data.contents]
701
686
 
702
687
  # ========================================================================
703
688
  # Config methods
@@ -1007,22 +992,16 @@ class CodexClient:
1007
992
  """
1008
993
  self._server_request_handlers = create_auto_approve_dict()
1009
994
 
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
995
  async def reset_memory(self) -> MemoryResetResponse:
1022
996
  """Reset the app-server memory."""
1023
997
  response = await self.dispatch.send_request("memory/reset")
1024
998
  return MemoryResetResponse.model_validate(response)
1025
999
 
1000
+ async def warning(self, message: str) -> None:
1001
+ """Send a warning message to the app-server."""
1002
+ params = WarningNotification(message=message)
1003
+ await self.dispatch.send_request("warning", params)
1004
+
1026
1005
 
1027
1006
  if __name__ == "__main__":
1028
1007
 
@@ -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())
@@ -0,0 +1,62 @@
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
+ MarketplaceUpgradeParams,
14
+ MarketplaceUpgradeResponse,
15
+ )
16
+
17
+
18
+ if TYPE_CHECKING:
19
+ from codexed.client import CodexClient
20
+
21
+ logger = logging.getLogger(__name__)
22
+
23
+
24
+ class CodexMarketPlace:
25
+ def __init__(self, client: CodexClient):
26
+ self._client = client
27
+
28
+ async def add(
29
+ self,
30
+ source: str,
31
+ ref_name: str | None = None,
32
+ sparse_paths: list[str] | None = None,
33
+ ) -> MarketplaceAddResponse:
34
+ """Add a marketplace to the app-server."""
35
+ params = MarketplaceAddParams(ref_name=ref_name, source=source, sparse_paths=sparse_paths)
36
+ response = await self._client.dispatch.send_request("marketplace/add", params)
37
+ return MarketplaceAddResponse.model_validate(response)
38
+
39
+ async def remove(self, ref_name: str):
40
+ """Remove a marketplace from the app-server."""
41
+ params = MarketplaceRemoveParams(marketplace_name=ref_name)
42
+ response = await self._client.dispatch.send_request("marketplace/remove", params)
43
+ return MarketplaceRemoveResponse.model_validate(response)
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
+
51
+
52
+ if __name__ == "__main__":
53
+ import asyncio
54
+
55
+ from codexed.client import CodexClient
56
+
57
+ async def main():
58
+ client = CodexClient()
59
+ async with client:
60
+ _test = await client.marketplace.add("test")
61
+
62
+ 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())