codexed 1.2.1__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.
- {codexed-1.2.1 → codexed-1.2.2}/PKG-INFO +1 -1
- {codexed-1.2.1 → codexed-1.2.2}/pyproject.toml +1 -1
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/__init__.py +2 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/client.py +49 -2
- codexed-1.2.2/src/codexed/client/device.py +67 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/marketplace.py +8 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/session.py +32 -3
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/__init__.py +8 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/mcp_server.py +4 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/v2_protocol.py +623 -21
- {codexed-1.2.1 → codexed-1.2.2}/LICENSE +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/README.md +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/README.md +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/__init__.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/account.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/dispatch.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/fs.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/plugin.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/realtime.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/client/skills.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/exceptions.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/helpers.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/log.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/base.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/codex_types.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/event_data.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/events.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/misc.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/request_params.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/responses.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/thread_item.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/models/tool_config.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/py.typed +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/request_handlers.py +0 -0
- {codexed-1.2.1 → codexed-1.2.2}/src/codexed/transport.py +0 -0
|
@@ -5,11 +5,13 @@ from .fs import CodexFS
|
|
|
5
5
|
from .skills import CodexSkills
|
|
6
6
|
from .plugin import CodexPlugin
|
|
7
7
|
from .marketplace import CodexMarketPlace
|
|
8
|
+
from .device import CodexDevice
|
|
8
9
|
from .realtime import RealtimeSession
|
|
9
10
|
from .session import Session
|
|
10
11
|
|
|
11
12
|
__all__ = [
|
|
12
13
|
"CodexClient",
|
|
14
|
+
"CodexDevice",
|
|
13
15
|
"CodexFS",
|
|
14
16
|
"CodexMarketPlace",
|
|
15
17
|
"CodexPlugin",
|
|
@@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, Any
|
|
|
10
10
|
from pydantic import TypeAdapter
|
|
11
11
|
|
|
12
12
|
from codexed.client.account import CodexAccount
|
|
13
|
+
from codexed.client.device import CodexDevice
|
|
13
14
|
from codexed.client.dispatch import Dispatch
|
|
14
15
|
from codexed.client.fs import CodexFS
|
|
15
16
|
from codexed.client.marketplace import CodexMarketPlace
|
|
@@ -37,6 +38,8 @@ from codexed.models import (
|
|
|
37
38
|
FeedbackUploadResponse,
|
|
38
39
|
ListMcpServerStatusParams,
|
|
39
40
|
ListMcpServerStatusResponse,
|
|
41
|
+
McpResourceReadParams,
|
|
42
|
+
McpResourceReadResponse,
|
|
40
43
|
McpServerOauthLoginParams,
|
|
41
44
|
McpServerOauthLoginResponse,
|
|
42
45
|
MemoryResetResponse,
|
|
@@ -50,9 +53,10 @@ from codexed.models import (
|
|
|
50
53
|
ThreadResponse,
|
|
51
54
|
ThreadResumeParams,
|
|
52
55
|
ThreadStartParams,
|
|
56
|
+
WarningNotification,
|
|
53
57
|
codex_event_adapter,
|
|
54
58
|
)
|
|
55
|
-
from codexed.models.
|
|
59
|
+
from codexed.models.mcp_server import ResourceContents
|
|
56
60
|
from codexed.request_handlers import (
|
|
57
61
|
SERVER_REQUEST_COMMAND_APPROVAL,
|
|
58
62
|
SERVER_REQUEST_DYNAMIC_TOOL_CALL,
|
|
@@ -69,6 +73,8 @@ from codexed.transport import StdioTransport
|
|
|
69
73
|
if TYPE_CHECKING:
|
|
70
74
|
from typing import Self
|
|
71
75
|
|
|
76
|
+
from pydantic import BaseModel
|
|
77
|
+
|
|
72
78
|
from codexed.client.session import Session
|
|
73
79
|
from codexed.models import (
|
|
74
80
|
AppInfo,
|
|
@@ -84,6 +90,7 @@ if TYPE_CHECKING:
|
|
|
84
90
|
McpServerConfig,
|
|
85
91
|
McpServerStatusDetail,
|
|
86
92
|
MergeStrategy,
|
|
93
|
+
PermissionProfile,
|
|
87
94
|
Personality,
|
|
88
95
|
SandboxMode,
|
|
89
96
|
SandboxPolicy,
|
|
@@ -93,7 +100,9 @@ if TYPE_CHECKING:
|
|
|
93
100
|
ThreadSourceKind,
|
|
94
101
|
ThreadStartSource,
|
|
95
102
|
ToolConfig,
|
|
103
|
+
TurnEnvironmentParams,
|
|
96
104
|
)
|
|
105
|
+
from codexed.models.v2_protocol import ThreadListCwdFilter
|
|
97
106
|
from codexed.request_handlers import (
|
|
98
107
|
ApprovalHandler,
|
|
99
108
|
DynamicToolCallHandler,
|
|
@@ -175,6 +184,7 @@ class CodexClient:
|
|
|
175
184
|
self._server_request_handlers: dict[str, ServerRequestHandler] = {}
|
|
176
185
|
self.account = CodexAccount(self)
|
|
177
186
|
self.fs = CodexFS(self)
|
|
187
|
+
self.device = CodexDevice(self)
|
|
178
188
|
self.plugins = CodexPlugin(self)
|
|
179
189
|
self.marketplace = CodexMarketPlace(self)
|
|
180
190
|
self.skills = CodexSkills(self)
|
|
@@ -234,6 +244,7 @@ class CodexClient:
|
|
|
234
244
|
experimental_raw_events: bool = False,
|
|
235
245
|
persist_extended_history: bool = False,
|
|
236
246
|
session_start_source: ThreadStartSource | None = None,
|
|
247
|
+
environments: list[TurnEnvironmentParams] | None = None,
|
|
237
248
|
) -> Session:
|
|
238
249
|
"""Start a new conversation thread.
|
|
239
250
|
|
|
@@ -261,6 +272,7 @@ class CodexClient:
|
|
|
261
272
|
experimental_raw_events: Emit raw Responses API items (internal)
|
|
262
273
|
persist_extended_history: Persist full history for resume/fork/read
|
|
263
274
|
session_start_source: Source of the session start
|
|
275
|
+
environments: List of environment variables to set for the thread
|
|
264
276
|
|
|
265
277
|
Returns:
|
|
266
278
|
Session wrapping the new thread
|
|
@@ -292,6 +304,7 @@ class CodexClient:
|
|
|
292
304
|
experimental_raw_events=experimental_raw_events,
|
|
293
305
|
persist_extended_history=persist_extended_history,
|
|
294
306
|
session_start_source=session_start_source,
|
|
307
|
+
environments=environments,
|
|
295
308
|
)
|
|
296
309
|
result = await self.dispatch.send_request("thread/start", params)
|
|
297
310
|
response = ThreadResponse.model_validate(result)
|
|
@@ -318,6 +331,8 @@ class CodexClient:
|
|
|
318
331
|
personality: Personality | None = None,
|
|
319
332
|
mcp_servers: Mapping[str, McpServerConfig] | None = None,
|
|
320
333
|
persist_extended_history: bool = False,
|
|
334
|
+
exclude_turns: bool | None = None,
|
|
335
|
+
permission_profile: PermissionProfile | None = None,
|
|
321
336
|
) -> Session:
|
|
322
337
|
"""Resume an existing thread by ID.
|
|
323
338
|
|
|
@@ -339,6 +354,8 @@ class CodexClient:
|
|
|
339
354
|
personality: Personality override
|
|
340
355
|
mcp_servers: Per-thread MCP server configurations
|
|
341
356
|
persist_extended_history: Persist full history for resume/fork/read
|
|
357
|
+
exclude_turns: If true, exclude turns from the thread's history
|
|
358
|
+
permission_profile: Permission profile override
|
|
342
359
|
|
|
343
360
|
Returns:
|
|
344
361
|
Session wrapping the resumed thread
|
|
@@ -367,6 +384,8 @@ class CodexClient:
|
|
|
367
384
|
service_tier=service_tier,
|
|
368
385
|
personality=personality,
|
|
369
386
|
persist_extended_history=persist_extended_history,
|
|
387
|
+
exclude_turns=exclude_turns,
|
|
388
|
+
permission_profile=permission_profile,
|
|
370
389
|
)
|
|
371
390
|
result = await self.dispatch.send_request("thread/resume", params)
|
|
372
391
|
response = ThreadResponse.model_validate(result)
|
|
@@ -394,6 +413,8 @@ class CodexClient:
|
|
|
394
413
|
mcp_servers: Mapping[str, McpServerConfig] | None = None,
|
|
395
414
|
turn_id: str | None = None,
|
|
396
415
|
persist_extended_history: bool = False,
|
|
416
|
+
exclude_turns: bool | None = None,
|
|
417
|
+
permission_profile: PermissionProfile | None = None,
|
|
397
418
|
) -> Session:
|
|
398
419
|
"""Fork an existing thread into a new thread with copied history.
|
|
399
420
|
|
|
@@ -417,6 +438,10 @@ class CodexClient:
|
|
|
417
438
|
mcp_servers: Per-thread MCP server configurations
|
|
418
439
|
turn_id: If provided, rollback the forked thread to this turn
|
|
419
440
|
persist_extended_history: Persist full history for resume/fork/read
|
|
441
|
+
exclude_turns: When true, return only thread metadata and live fork state
|
|
442
|
+
without populating `thread.turns`. This is useful when
|
|
443
|
+
the client plans to call `thread/turns/list` immediately after forking.
|
|
444
|
+
permission_profile: Permission profile for forked thread
|
|
420
445
|
|
|
421
446
|
Returns:
|
|
422
447
|
Session wrapping the new forked thread
|
|
@@ -445,6 +470,8 @@ class CodexClient:
|
|
|
445
470
|
service_tier=service_tier,
|
|
446
471
|
ephemeral=ephemeral,
|
|
447
472
|
persist_extended_history=persist_extended_history,
|
|
473
|
+
exclude_turns=exclude_turns,
|
|
474
|
+
permission_profile=permission_profile,
|
|
448
475
|
)
|
|
449
476
|
result = await self.dispatch.send_request("thread/fork", params)
|
|
450
477
|
response = ThreadResponse.model_validate(result)
|
|
@@ -463,9 +490,10 @@ class CodexClient:
|
|
|
463
490
|
model_providers: list[str] | None = None,
|
|
464
491
|
source_kinds: list[ThreadSourceKind] | None = None,
|
|
465
492
|
archived: bool | None = None,
|
|
466
|
-
cwd:
|
|
493
|
+
cwd: ThreadListCwdFilter | None = None,
|
|
467
494
|
search_term: str | None = None,
|
|
468
495
|
sort_direction: SortDirection | None = None,
|
|
496
|
+
use_state_db_only: bool | None = None,
|
|
469
497
|
) -> ThreadListResponse:
|
|
470
498
|
"""List stored threads with pagination.
|
|
471
499
|
|
|
@@ -479,6 +507,7 @@ class CodexClient:
|
|
|
479
507
|
cwd: Filter by working directory
|
|
480
508
|
search_term: Substring filter for thread title
|
|
481
509
|
sort_direction: Sort direction (asc or desc)
|
|
510
|
+
use_state_db_only: If true, only return threads from the state DB
|
|
482
511
|
|
|
483
512
|
Returns:
|
|
484
513
|
ThreadListResponse with data (list of threads) and next_cursor
|
|
@@ -493,6 +522,7 @@ class CodexClient:
|
|
|
493
522
|
cwd=cwd,
|
|
494
523
|
search_term=search_term,
|
|
495
524
|
sort_direction=sort_direction,
|
|
525
|
+
use_state_db_only=use_state_db_only,
|
|
496
526
|
)
|
|
497
527
|
result = await self.dispatch.send_request("thread/list", params)
|
|
498
528
|
return ThreadListResponse.model_validate(result)
|
|
@@ -563,6 +593,7 @@ class CodexClient:
|
|
|
563
593
|
sandbox_policy: SandboxPolicy | None = None,
|
|
564
594
|
output_bytes_cap: int | None = None,
|
|
565
595
|
timeout_ms: int | None = None,
|
|
596
|
+
permission_profile: PermissionProfile | None = None,
|
|
566
597
|
) -> CommandExecResponse:
|
|
567
598
|
"""Execute a command without creating a thread/turn.
|
|
568
599
|
|
|
@@ -572,6 +603,7 @@ class CodexClient:
|
|
|
572
603
|
sandbox_policy: Sandbox policy override
|
|
573
604
|
output_bytes_cap: Cap output based on bytes
|
|
574
605
|
timeout_ms: Timeout in milliseconds
|
|
606
|
+
permission_profile: Permission profile override
|
|
575
607
|
|
|
576
608
|
Returns:
|
|
577
609
|
CommandExecResponse with exit_code, stdout, stderr
|
|
@@ -582,6 +614,7 @@ class CodexClient:
|
|
|
582
614
|
output_bytes_cap=output_bytes_cap,
|
|
583
615
|
sandbox_policy=sandbox_policy,
|
|
584
616
|
timeout_ms=timeout_ms,
|
|
617
|
+
permission_profile=permission_profile,
|
|
585
618
|
)
|
|
586
619
|
result = await self.dispatch.send_request("command/exec", params)
|
|
587
620
|
return CommandExecResponse.model_validate(result)
|
|
@@ -637,6 +670,20 @@ class CodexClient:
|
|
|
637
670
|
response = McpServerOauthLoginResponse.model_validate(result)
|
|
638
671
|
return response.authorization_url
|
|
639
672
|
|
|
673
|
+
async def read_resource(self, server: str, uri: str) -> list[ResourceContents]:
|
|
674
|
+
"""Read a resource from the MCP server."""
|
|
675
|
+
params = McpResourceReadParams(server=server, uri=uri)
|
|
676
|
+
result = await self.dispatch.send_request("mcpServer/resource/read", params)
|
|
677
|
+
data = McpResourceReadResponse.model_validate(result)
|
|
678
|
+
ta = TypeAdapter[ResourceContents](ResourceContents)
|
|
679
|
+
|
|
680
|
+
def convert(old: BaseModel) -> ResourceContents:
|
|
681
|
+
dct = old.model_dump()
|
|
682
|
+
dct["_meta"] = dct.pop("field_meta")
|
|
683
|
+
return ta.validate_python(dct)
|
|
684
|
+
|
|
685
|
+
return [convert(i) for i in data.contents]
|
|
686
|
+
|
|
640
687
|
# ========================================================================
|
|
641
688
|
# Config methods
|
|
642
689
|
# ========================================================================
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Codex app-server client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from codexed.models.v2_protocol import (
|
|
9
|
+
DeviceKeyCreateParams,
|
|
10
|
+
DeviceKeyCreateResponse,
|
|
11
|
+
DeviceKeyPublicParams,
|
|
12
|
+
DeviceKeyPublicResponse,
|
|
13
|
+
DeviceKeySignParams,
|
|
14
|
+
DeviceKeySignResponse,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from codexed.client import CodexClient
|
|
20
|
+
from codexed.models.v2_protocol import DeviceKeyProtectionPolicy, DeviceKeySignPayload
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CodexDevice:
|
|
26
|
+
def __init__(self, client: CodexClient):
|
|
27
|
+
self._client = client
|
|
28
|
+
|
|
29
|
+
async def create_key(
|
|
30
|
+
self,
|
|
31
|
+
account_user_id: str,
|
|
32
|
+
client_id: str,
|
|
33
|
+
protection_policy: DeviceKeyProtectionPolicy | None = None,
|
|
34
|
+
) -> DeviceKeyCreateResponse:
|
|
35
|
+
"""Add a marketplace to the app-server."""
|
|
36
|
+
params = DeviceKeyCreateParams(
|
|
37
|
+
account_user_id=account_user_id,
|
|
38
|
+
client_id=client_id,
|
|
39
|
+
protection_policy=protection_policy,
|
|
40
|
+
)
|
|
41
|
+
response = await self._client.dispatch.send_request("device/key/create", params)
|
|
42
|
+
return DeviceKeyCreateResponse.model_validate(response)
|
|
43
|
+
|
|
44
|
+
async def public_key(self, key_id: str) -> DeviceKeyPublicResponse:
|
|
45
|
+
"""Get the public key for a device key."""
|
|
46
|
+
params = DeviceKeyPublicParams(key_id=key_id)
|
|
47
|
+
response = await self._client.dispatch.send_request("device/key/public", params=params)
|
|
48
|
+
return DeviceKeyPublicResponse.model_validate(response)
|
|
49
|
+
|
|
50
|
+
async def sign_key(self, key_id: str, payload: DeviceKeySignPayload) -> DeviceKeySignResponse:
|
|
51
|
+
"""Sign a key using the device key."""
|
|
52
|
+
params = DeviceKeySignParams(key_id=key_id, payload=payload)
|
|
53
|
+
response = await self._client.dispatch.send_request("device/key/sign", params=params)
|
|
54
|
+
return DeviceKeySignResponse.model_validate(response)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
import asyncio
|
|
59
|
+
|
|
60
|
+
from codexed.client import CodexClient
|
|
61
|
+
|
|
62
|
+
async def main():
|
|
63
|
+
client = CodexClient()
|
|
64
|
+
async with client:
|
|
65
|
+
_test = await client.marketplace.add("test")
|
|
66
|
+
|
|
67
|
+
asyncio.run(main())
|
|
@@ -10,6 +10,8 @@ from codexed.models import (
|
|
|
10
10
|
MarketplaceAddResponse,
|
|
11
11
|
MarketplaceRemoveParams,
|
|
12
12
|
MarketplaceRemoveResponse,
|
|
13
|
+
MarketplaceUpgradeParams,
|
|
14
|
+
MarketplaceUpgradeResponse,
|
|
13
15
|
)
|
|
14
16
|
|
|
15
17
|
|
|
@@ -40,6 +42,12 @@ class CodexMarketPlace:
|
|
|
40
42
|
response = await self._client.dispatch.send_request("marketplace/remove", params)
|
|
41
43
|
return MarketplaceRemoveResponse.model_validate(response)
|
|
42
44
|
|
|
45
|
+
async def upgrade(self, marketplace_name: str | None = None):
|
|
46
|
+
"""Upgrade a marketplace to the latest version."""
|
|
47
|
+
params = MarketplaceUpgradeParams(marketplace_name=marketplace_name)
|
|
48
|
+
response = await self._client.dispatch.send_request("marketplace/upgrade", params)
|
|
49
|
+
return MarketplaceUpgradeResponse.model_validate(response)
|
|
50
|
+
|
|
43
51
|
|
|
44
52
|
if __name__ == "__main__":
|
|
45
53
|
import asyncio
|
|
@@ -7,7 +7,7 @@ from collections.abc import AsyncIterator, Mapping, Sequence # noqa: TC003
|
|
|
7
7
|
import logging
|
|
8
8
|
from typing import TYPE_CHECKING, Any, assert_never
|
|
9
9
|
|
|
10
|
-
from mcp.types import
|
|
10
|
+
from mcp.types import CallToolResult
|
|
11
11
|
from pydantic import BaseModel, TypeAdapter
|
|
12
12
|
|
|
13
13
|
from codexed.client.realtime import RealtimeSession
|
|
@@ -55,6 +55,11 @@ from codexed.models import (
|
|
|
55
55
|
WarningNotification,
|
|
56
56
|
WorkspaceWriteSandboxPolicy,
|
|
57
57
|
)
|
|
58
|
+
from codexed.models.mcp_server import ResourceContents
|
|
59
|
+
from codexed.models.v2_protocol import (
|
|
60
|
+
GuardianWarningNotification,
|
|
61
|
+
ThreadApproveGuardianDeniedActionParams,
|
|
62
|
+
)
|
|
58
63
|
|
|
59
64
|
|
|
60
65
|
if TYPE_CHECKING:
|
|
@@ -67,6 +72,7 @@ if TYPE_CHECKING:
|
|
|
67
72
|
CodexEvent,
|
|
68
73
|
CollaborationMode,
|
|
69
74
|
McpServerConfig,
|
|
75
|
+
PermissionProfile,
|
|
70
76
|
Personality,
|
|
71
77
|
RealtimeOutputModality,
|
|
72
78
|
ReasoningEffort,
|
|
@@ -81,13 +87,12 @@ if TYPE_CHECKING:
|
|
|
81
87
|
ThreadTokenUsage,
|
|
82
88
|
ToolConfig,
|
|
83
89
|
Turn,
|
|
90
|
+
TurnEnvironmentParams,
|
|
84
91
|
UserInput,
|
|
85
92
|
)
|
|
86
93
|
|
|
87
94
|
logger = logging.getLogger(__name__)
|
|
88
95
|
|
|
89
|
-
ResourceContents = TextResourceContents | BlobResourceContents
|
|
90
|
-
|
|
91
96
|
|
|
92
97
|
class Session:
|
|
93
98
|
"""Runtime handle for an active Codex thread.
|
|
@@ -134,6 +139,8 @@ class Session:
|
|
|
134
139
|
summary: ReasoningSummary | None = None,
|
|
135
140
|
collaboration_mode: CollaborationMode | None = None,
|
|
136
141
|
responsesapi_client_metadata: dict[str, Any] | None = None,
|
|
142
|
+
environments: list[TurnEnvironmentParams] | None = None,
|
|
143
|
+
permission_profile: PermissionProfile | None = None,
|
|
137
144
|
) -> AsyncIterator[CodexEvent]:
|
|
138
145
|
"""Start a turn and stream events.
|
|
139
146
|
|
|
@@ -151,6 +158,8 @@ class Session:
|
|
|
151
158
|
summary: Optional reasoning summary mode
|
|
152
159
|
collaboration_mode: Optional collaboration mode preset (experimental)
|
|
153
160
|
responsesapi_client_metadata: Optional turn-scoped Responses API client metadata.
|
|
161
|
+
environments: Optional list of environment variables to set for this turn.
|
|
162
|
+
permission_profile: Optional permission profile to use for this turn.
|
|
154
163
|
|
|
155
164
|
Yields:
|
|
156
165
|
CodexEvent: Streaming events from the turn
|
|
@@ -199,6 +208,8 @@ class Session:
|
|
|
199
208
|
summary=summary,
|
|
200
209
|
collaboration_mode=collaboration_mode,
|
|
201
210
|
responsesapi_client_metadata=responsesapi_client_metadata,
|
|
211
|
+
environments=environments,
|
|
212
|
+
permission_profile=permission_profile,
|
|
202
213
|
)
|
|
203
214
|
turn_result = await self._client.dispatch.send_request("turn/start", params)
|
|
204
215
|
response = TurnStartResponse.model_validate(turn_result)
|
|
@@ -545,6 +556,8 @@ class Session:
|
|
|
545
556
|
mcp_servers: Mapping[str, McpServerConfig] | None = None,
|
|
546
557
|
turn_id: str | None = None,
|
|
547
558
|
persist_extended_history: bool = False,
|
|
559
|
+
exclude_turns: bool | None = None,
|
|
560
|
+
permission_profile: PermissionProfile | None = None,
|
|
548
561
|
) -> Session:
|
|
549
562
|
"""Fork this thread into a new thread with copied history.
|
|
550
563
|
|
|
@@ -566,6 +579,10 @@ class Session:
|
|
|
566
579
|
mcp_servers: Per-thread MCP server configurations
|
|
567
580
|
turn_id: If provided, rollback the forked thread to this turn
|
|
568
581
|
persist_extended_history: Persist full history for resume/fork/read
|
|
582
|
+
exclude_turns: When true, return only thread metadata and live fork state
|
|
583
|
+
without populating `thread.turns`. This is useful when
|
|
584
|
+
the client plans to call `thread/turns/list` immediately after forking.
|
|
585
|
+
permission_profile: Permission profile for forked thread
|
|
569
586
|
|
|
570
587
|
Returns:
|
|
571
588
|
Session wrapping the new forked thread
|
|
@@ -589,6 +606,8 @@ class Session:
|
|
|
589
606
|
mcp_servers=mcp_servers,
|
|
590
607
|
turn_id=turn_id,
|
|
591
608
|
persist_extended_history=persist_extended_history,
|
|
609
|
+
exclude_turns=exclude_turns,
|
|
610
|
+
permission_profile=permission_profile,
|
|
592
611
|
)
|
|
593
612
|
|
|
594
613
|
async def read_resource(self, server: str, uri: str) -> list[ResourceContents]:
|
|
@@ -646,3 +665,13 @@ class Session:
|
|
|
646
665
|
"""Send a thread-related warning message to the app-server."""
|
|
647
666
|
params = WarningNotification(message=message, thread_id=self.thread_id)
|
|
648
667
|
await self._client.dispatch.send_request("warning", params)
|
|
668
|
+
|
|
669
|
+
async def guardian_warning(self, message: str) -> None:
|
|
670
|
+
"""Send a thread-related guardian warning message to the app-server."""
|
|
671
|
+
params = GuardianWarningNotification(message=message, thread_id=self.thread_id)
|
|
672
|
+
await self._client.dispatch.send_request("warning", params)
|
|
673
|
+
|
|
674
|
+
async def approve_guardian_denied_action(self, event: Any) -> None:
|
|
675
|
+
"""Send a request to the server to approve a guardian denied action."""
|
|
676
|
+
params = ThreadApproveGuardianDeniedActionParams(event=event, thread_id=self.thread_id)
|
|
677
|
+
await self._client.dispatch.send_request("thread/approveGuardianDeniedAction", params)
|
|
@@ -134,6 +134,8 @@ from codexed.models.v2_protocol import (
|
|
|
134
134
|
CollabAgentState,
|
|
135
135
|
NetworkDomainPermission,
|
|
136
136
|
SortDirection,
|
|
137
|
+
MarketplaceUpgradeParams,
|
|
138
|
+
MarketplaceUpgradeResponse,
|
|
137
139
|
WarningNotification,
|
|
138
140
|
ThreadTurnsListParams,
|
|
139
141
|
ThreadTurnsListResponse,
|
|
@@ -455,6 +457,7 @@ from codexed.models.v2_protocol import (
|
|
|
455
457
|
SkillToolDependency,
|
|
456
458
|
TurnError,
|
|
457
459
|
McpServerToolCallParams,
|
|
460
|
+
PermissionProfile,
|
|
458
461
|
CommandExecOutputStream,
|
|
459
462
|
CommandExecOutputDeltaNotification,
|
|
460
463
|
CommandExecResizeResponse,
|
|
@@ -471,6 +474,7 @@ from codexed.models.v2_protocol import (
|
|
|
471
474
|
ThreadRealtimeAppendTextParams,
|
|
472
475
|
ThreadRealtimeAppendAudioParams,
|
|
473
476
|
WebSearchAction,
|
|
477
|
+
TurnEnvironmentParams,
|
|
474
478
|
FindInPageWebSearchAction,
|
|
475
479
|
OpenPageWebSearchAction,
|
|
476
480
|
OtherWebSearchAction,
|
|
@@ -686,6 +690,8 @@ __all__ = [
|
|
|
686
690
|
"MarketplaceAddResponse",
|
|
687
691
|
"MarketplaceRemoveParams",
|
|
688
692
|
"MarketplaceRemoveResponse",
|
|
693
|
+
"MarketplaceUpgradeParams",
|
|
694
|
+
"MarketplaceUpgradeResponse",
|
|
689
695
|
"McpAuthStatus",
|
|
690
696
|
"McpElicitationFormParams",
|
|
691
697
|
"McpElicitationUrlParams",
|
|
@@ -735,6 +741,7 @@ __all__ = [
|
|
|
735
741
|
"OtherWebSearchAction",
|
|
736
742
|
"PatchApplyStatus",
|
|
737
743
|
"PatchChangeKind",
|
|
744
|
+
"PermissionProfile",
|
|
738
745
|
"Personality",
|
|
739
746
|
"PlanDeltaNotification",
|
|
740
747
|
"PlanToolConfig",
|
|
@@ -916,6 +923,7 @@ __all__ = [
|
|
|
916
923
|
"TurnData",
|
|
917
924
|
"TurnDiffUpdatedMessage",
|
|
918
925
|
"TurnDiffUpdatedNotification",
|
|
926
|
+
"TurnEnvironmentParams",
|
|
919
927
|
"TurnError",
|
|
920
928
|
"TurnInterruptParams",
|
|
921
929
|
"TurnPlanStep",
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from mcp.types import BlobResourceContents, TextResourceContents
|
|
5
6
|
from pydantic import BaseModel
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
ResourceContents = TextResourceContents | BlobResourceContents
|
|
10
|
+
|
|
11
|
+
|
|
8
12
|
class StdioMcpServer(BaseModel):
|
|
9
13
|
"""MCP server running as a subprocess via stdio transport."""
|
|
10
14
|
|