codexed 1.1.9__tar.gz → 1.2.0__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.1.9 → codexed-1.2.0}/PKG-INFO +1 -1
- {codexed-1.1.9 → codexed-1.2.0}/pyproject.toml +1 -1
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/client/client.py +31 -2
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/client/fs.py +3 -2
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/client/realtime.py +25 -21
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/client/session.py +68 -3
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/__init__.py +50 -16
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/codex_types.py +0 -2
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/events.py +14 -7
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/misc.py +93 -22
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/v2_protocol.py +502 -54
- {codexed-1.1.9 → codexed-1.2.0}/LICENSE +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/README.md +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/README.md +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/__init__.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/client/__init__.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/client/dispatch.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/client/skills.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/exceptions.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/helpers.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/log.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/base.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/event_data.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/mcp_server.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/request_params.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/responses.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/thread_item.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/models/tool_config.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/py.typed +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/request_handlers.py +0 -0
- {codexed-1.1.9 → codexed-1.2.0}/src/codexed/transport.py +0 -0
|
@@ -41,8 +41,11 @@ from codexed.models import (
|
|
|
41
41
|
ListMcpServerStatusResponse,
|
|
42
42
|
LoginAccountParams,
|
|
43
43
|
LoginAccountResponse,
|
|
44
|
+
MarketplaceAddParams,
|
|
45
|
+
MarketplaceAddResponse,
|
|
44
46
|
McpServerOauthLoginParams,
|
|
45
47
|
McpServerOauthLoginResponse,
|
|
48
|
+
MemoryResetResponse,
|
|
46
49
|
ModelListParams,
|
|
47
50
|
ModelListResponse,
|
|
48
51
|
ThreadForkParams,
|
|
@@ -86,6 +89,7 @@ if TYPE_CHECKING:
|
|
|
86
89
|
ExperimentalFeature,
|
|
87
90
|
ExternalAgentConfigMigrationItem,
|
|
88
91
|
McpServerConfig,
|
|
92
|
+
McpServerStatusDetail,
|
|
89
93
|
MergeStrategy,
|
|
90
94
|
Personality,
|
|
91
95
|
SandboxMode,
|
|
@@ -93,6 +97,7 @@ if TYPE_CHECKING:
|
|
|
93
97
|
ServiceTier,
|
|
94
98
|
ThreadSortKey,
|
|
95
99
|
ThreadSourceKind,
|
|
100
|
+
ThreadStartSource,
|
|
96
101
|
ToolConfig,
|
|
97
102
|
)
|
|
98
103
|
from codexed.request_handlers import (
|
|
@@ -231,6 +236,7 @@ class CodexClient:
|
|
|
231
236
|
mcp_servers: Mapping[str, McpServerConfig] | None = None,
|
|
232
237
|
experimental_raw_events: bool = False,
|
|
233
238
|
persist_extended_history: bool = False,
|
|
239
|
+
session_start_source: ThreadStartSource | None = None,
|
|
234
240
|
) -> Session:
|
|
235
241
|
"""Start a new conversation thread.
|
|
236
242
|
|
|
@@ -257,6 +263,7 @@ class CodexClient:
|
|
|
257
263
|
Merged into ``config`` under the ``mcp_servers`` key.
|
|
258
264
|
experimental_raw_events: Emit raw Responses API items (internal)
|
|
259
265
|
persist_extended_history: Persist full history for resume/fork/read
|
|
266
|
+
session_start_source: Source of the session start
|
|
260
267
|
|
|
261
268
|
Returns:
|
|
262
269
|
Session wrapping the new thread
|
|
@@ -287,6 +294,7 @@ class CodexClient:
|
|
|
287
294
|
dynamic_tools=dynamic_tools,
|
|
288
295
|
experimental_raw_events=experimental_raw_events,
|
|
289
296
|
persist_extended_history=persist_extended_history,
|
|
297
|
+
session_start_source=session_start_source,
|
|
290
298
|
)
|
|
291
299
|
result = await self.dispatch.send_request("thread/start", params)
|
|
292
300
|
response = ThreadResponse.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
|
|
|
@@ -841,6 +851,7 @@ class CodexClient:
|
|
|
841
851
|
*,
|
|
842
852
|
reason: str | None = None,
|
|
843
853
|
thread_id: str | None = None,
|
|
854
|
+
tags: dict[str, Any] | None = None,
|
|
844
855
|
include_logs: bool = False,
|
|
845
856
|
extra_log_files: list[str] | None = None,
|
|
846
857
|
) -> str:
|
|
@@ -850,6 +861,7 @@ class CodexClient:
|
|
|
850
861
|
classification: Feedback classification
|
|
851
862
|
reason: Optional reason text
|
|
852
863
|
thread_id: Optional thread ID to associate
|
|
864
|
+
tags: Optional tags to associate with the feedback
|
|
853
865
|
include_logs: Whether to include logs
|
|
854
866
|
extra_log_files: Additional log files to include
|
|
855
867
|
|
|
@@ -860,6 +872,7 @@ class CodexClient:
|
|
|
860
872
|
classification=classification,
|
|
861
873
|
reason=reason,
|
|
862
874
|
thread_id=thread_id,
|
|
875
|
+
tags=tags,
|
|
863
876
|
include_logs=include_logs,
|
|
864
877
|
extra_log_files=extra_log_files,
|
|
865
878
|
)
|
|
@@ -913,7 +926,7 @@ class CodexClient:
|
|
|
913
926
|
return
|
|
914
927
|
|
|
915
928
|
event_data = {"method": method, "params": params}
|
|
916
|
-
event
|
|
929
|
+
event = codex_event_adapter.validate_python(event_data)
|
|
917
930
|
|
|
918
931
|
thread_id = params.get("threadId")
|
|
919
932
|
|
|
@@ -994,6 +1007,22 @@ class CodexClient:
|
|
|
994
1007
|
"""
|
|
995
1008
|
self._server_request_handlers = create_auto_approve_dict()
|
|
996
1009
|
|
|
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
|
+
async def reset_memory(self) -> MemoryResetResponse:
|
|
1022
|
+
"""Reset the app-server memory."""
|
|
1023
|
+
response = await self.dispatch.send_request("memory/reset")
|
|
1024
|
+
return MemoryResetResponse.model_validate(response)
|
|
1025
|
+
|
|
997
1026
|
|
|
998
1027
|
if __name__ == "__main__":
|
|
999
1028
|
|
|
@@ -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
|
|
|
@@ -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
|
|
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
|
+
prompt: str | None = None,
|
|
56
50
|
*,
|
|
57
51
|
session_id: str | None = None,
|
|
52
|
+
output_modality: RealtimeOutputModality | 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 = output_modality
|
|
64
|
+
self._transport = transport
|
|
65
|
+
self._voice = voice
|
|
66
66
|
|
|
67
67
|
@property
|
|
68
68
|
def thread_id(self) -> str:
|
|
@@ -128,13 +128,17 @@ class RealtimeSession:
|
|
|
128
128
|
|
|
129
129
|
async def send_text(self, text: str) -> None:
|
|
130
130
|
"""Send text input to the realtime session."""
|
|
131
|
-
params = ThreadRealtimeAppendTextParams(
|
|
132
|
-
thread_id=self._thread_id,
|
|
133
|
-
text=text,
|
|
134
|
-
)
|
|
131
|
+
params = ThreadRealtimeAppendTextParams(thread_id=self._thread_id, text=text)
|
|
135
132
|
result = await self._client.dispatch.send_request("thread/realtime/appendText", params)
|
|
136
133
|
ThreadRealtimeAppendTextResponse.model_validate(result)
|
|
137
134
|
|
|
135
|
+
async def list_voices(self) -> RealtimeVoicesList:
|
|
136
|
+
"""List available voices for the realtime session."""
|
|
137
|
+
params = ThreadRealtimeListVoicesParams()
|
|
138
|
+
result = await self._client.dispatch.send_request("thread/realtime/listVoices", params)
|
|
139
|
+
data = ThreadRealtimeListVoicesResponse.model_validate(result)
|
|
140
|
+
return data.voices
|
|
141
|
+
|
|
138
142
|
async def send_audio(
|
|
139
143
|
self,
|
|
140
144
|
data: str,
|
|
@@ -7,6 +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 BlobResourceContents, CallToolResult, TextResourceContents
|
|
10
11
|
from pydantic import BaseModel, TypeAdapter
|
|
11
12
|
|
|
12
13
|
from codexed.client.realtime import RealtimeSession
|
|
@@ -17,6 +18,10 @@ from codexed.models import (
|
|
|
17
18
|
ErrorMessage,
|
|
18
19
|
ErrorNotification,
|
|
19
20
|
ExternalSandboxSandboxPolicy,
|
|
21
|
+
McpResourceReadParams,
|
|
22
|
+
McpResourceReadResponse,
|
|
23
|
+
McpServerToolCallParams,
|
|
24
|
+
McpServerToolCallResponse,
|
|
20
25
|
ReadOnlySandboxPolicy,
|
|
21
26
|
ReviewStartParams,
|
|
22
27
|
ReviewStartResponse,
|
|
@@ -24,6 +29,8 @@ from codexed.models import (
|
|
|
24
29
|
TextUserInput,
|
|
25
30
|
ThreadArchiveParams,
|
|
26
31
|
ThreadCompactStartParams,
|
|
32
|
+
ThreadInjectItemsParams,
|
|
33
|
+
ThreadMemoryModeSetParams,
|
|
27
34
|
ThreadReadParams,
|
|
28
35
|
ThreadReadResponse,
|
|
29
36
|
ThreadRollbackParams,
|
|
@@ -48,6 +55,8 @@ from codexed.models import (
|
|
|
48
55
|
|
|
49
56
|
|
|
50
57
|
if TYPE_CHECKING:
|
|
58
|
+
from openai.types.responses import ResponseItem
|
|
59
|
+
|
|
51
60
|
from codexed.client import CodexClient
|
|
52
61
|
from codexed.models import (
|
|
53
62
|
ApprovalsReviewer,
|
|
@@ -62,6 +71,7 @@ if TYPE_CHECKING:
|
|
|
62
71
|
ReviewTarget,
|
|
63
72
|
SandboxMode,
|
|
64
73
|
ServiceTier,
|
|
74
|
+
ThreadMemoryMode,
|
|
65
75
|
ThreadResponse,
|
|
66
76
|
ThreadTokenUsage,
|
|
67
77
|
ToolConfig,
|
|
@@ -71,6 +81,8 @@ if TYPE_CHECKING:
|
|
|
71
81
|
|
|
72
82
|
logger = logging.getLogger(__name__)
|
|
73
83
|
|
|
84
|
+
ResourceContents = TextResourceContents | BlobResourceContents
|
|
85
|
+
|
|
74
86
|
|
|
75
87
|
class Session:
|
|
76
88
|
"""Runtime handle for an active Codex thread.
|
|
@@ -116,6 +128,7 @@ class Session:
|
|
|
116
128
|
service_tier: ServiceTier | None = None,
|
|
117
129
|
summary: ReasoningSummary | None = None,
|
|
118
130
|
collaboration_mode: CollaborationMode | None = None,
|
|
131
|
+
responsesapi_client_metadata: dict[str, Any] | None = None,
|
|
119
132
|
) -> AsyncIterator[CodexEvent]:
|
|
120
133
|
"""Start a turn and stream events.
|
|
121
134
|
|
|
@@ -132,6 +145,7 @@ class Session:
|
|
|
132
145
|
service_tier: Optional service tier (fast/flex)
|
|
133
146
|
summary: Optional reasoning summary mode
|
|
134
147
|
collaboration_mode: Optional collaboration mode preset (experimental)
|
|
148
|
+
responsesapi_client_metadata: Optional turn-scoped Responses API client metadata.
|
|
135
149
|
|
|
136
150
|
Yields:
|
|
137
151
|
CodexEvent: Streaming events from the turn
|
|
@@ -162,11 +176,10 @@ class Session:
|
|
|
162
176
|
policy = sandbox_policy
|
|
163
177
|
case _:
|
|
164
178
|
assert_never(sandbox_policy)
|
|
179
|
+
in_ = [TextUserInput(text=user_input)] if isinstance(user_input, str) else list(user_input)
|
|
165
180
|
params = TurnStartParams(
|
|
166
181
|
thread_id=self.thread_id,
|
|
167
|
-
input=
|
|
168
|
-
if isinstance(user_input, str)
|
|
169
|
-
else list(user_input),
|
|
182
|
+
input=in_,
|
|
170
183
|
model=model,
|
|
171
184
|
effort=effort,
|
|
172
185
|
approval_policy=approval_policy,
|
|
@@ -178,6 +191,7 @@ class Session:
|
|
|
178
191
|
personality=personality,
|
|
179
192
|
summary=summary,
|
|
180
193
|
collaboration_mode=collaboration_mode,
|
|
194
|
+
responsesapi_client_metadata=responsesapi_client_metadata,
|
|
181
195
|
)
|
|
182
196
|
turn_result = await self._client.dispatch.send_request("turn/start", params)
|
|
183
197
|
response = TurnStartResponse.model_validate(turn_result)
|
|
@@ -213,12 +227,14 @@ class Session:
|
|
|
213
227
|
user_input: str | Sequence[UserInput],
|
|
214
228
|
*,
|
|
215
229
|
expected_turn_id: str,
|
|
230
|
+
responsesapi_client_metadata: dict[str, Any] | None = None,
|
|
216
231
|
) -> TurnSteerResponse:
|
|
217
232
|
"""Steer a running turn with additional input.
|
|
218
233
|
|
|
219
234
|
Args:
|
|
220
235
|
user_input: Additional user input
|
|
221
236
|
expected_turn_id: The expected active turn ID (precondition)
|
|
237
|
+
responsesapi_client_metadata: Optional turn-scoped Responses API client metadata.
|
|
222
238
|
|
|
223
239
|
Returns:
|
|
224
240
|
TurnSteerResponse with the turn ID
|
|
@@ -229,6 +245,7 @@ class Session:
|
|
|
229
245
|
if isinstance(user_input, str)
|
|
230
246
|
else list(user_input),
|
|
231
247
|
expected_turn_id=expected_turn_id,
|
|
248
|
+
responsesapi_client_metadata=responsesapi_client_metadata,
|
|
232
249
|
)
|
|
233
250
|
result = await self._client.dispatch.send_request("turn/steer", params)
|
|
234
251
|
return TurnSteerResponse.model_validate(result)
|
|
@@ -539,5 +556,53 @@ class Session:
|
|
|
539
556
|
persist_extended_history=persist_extended_history,
|
|
540
557
|
)
|
|
541
558
|
|
|
559
|
+
async def read_resource(self, server: str, uri: str) -> list[ResourceContents]:
|
|
560
|
+
"""Read a resource from the MCP server."""
|
|
561
|
+
params = McpResourceReadParams(server=server, thread_id=self.thread_id, uri=uri)
|
|
562
|
+
result = await self._client.dispatch.send_request("mcpServer/resource/read", params)
|
|
563
|
+
data = McpResourceReadResponse.model_validate(result)
|
|
564
|
+
ta = TypeAdapter[ResourceContents](ResourceContents)
|
|
565
|
+
|
|
566
|
+
def convert(old: BaseModel) -> ResourceContents:
|
|
567
|
+
dct = old.model_dump()
|
|
568
|
+
dct["_meta"] = dct.pop("field_meta")
|
|
569
|
+
return ta.validate_python(dct)
|
|
570
|
+
|
|
571
|
+
return [convert(i) for i in data.contents]
|
|
572
|
+
|
|
573
|
+
async def tool_call(
|
|
574
|
+
self,
|
|
575
|
+
server: str,
|
|
576
|
+
tool: str,
|
|
577
|
+
arguments: Any | None = None,
|
|
578
|
+
meta: dict[str, Any] | None = None,
|
|
579
|
+
) -> CallToolResult:
|
|
580
|
+
"""Call a tool on the MCP server."""
|
|
581
|
+
params = McpServerToolCallParams(
|
|
582
|
+
server=server,
|
|
583
|
+
thread_id=self.thread_id,
|
|
584
|
+
tool=tool,
|
|
585
|
+
arguments=arguments,
|
|
586
|
+
field_meta=meta,
|
|
587
|
+
)
|
|
588
|
+
result = await self._client.dispatch.send_request("mcpServer/tool/call", params)
|
|
589
|
+
data = McpServerToolCallResponse.model_validate(result)
|
|
590
|
+
return CallToolResult(
|
|
591
|
+
structuredContent=data.structured_content,
|
|
592
|
+
isError=data.is_error,
|
|
593
|
+
content=data.content,
|
|
594
|
+
_meta=data.field_meta,
|
|
595
|
+
)
|
|
596
|
+
|
|
542
597
|
def __repr__(self) -> str:
|
|
543
598
|
return f"Session(thread_id={self.thread_id!r})"
|
|
599
|
+
|
|
600
|
+
async def inject_items(self, items: list[ResponseItem]) -> None:
|
|
601
|
+
"""Inject raw responses-API Items into the thread's model-visible history."""
|
|
602
|
+
params = ThreadInjectItemsParams(items=items, thread_id=self.thread_id)
|
|
603
|
+
await self._client.dispatch.send_request("thread/inject_items", params)
|
|
604
|
+
|
|
605
|
+
async def set_memory_mode(self, mode: ThreadMemoryMode) -> None:
|
|
606
|
+
"""Set the thread's memory mode."""
|
|
607
|
+
params = ThreadMemoryModeSetParams(mode=mode, thread_id=self.thread_id)
|
|
608
|
+
await self._client.dispatch.send_request("thread/memoryMode/set", params)
|
|
@@ -9,13 +9,7 @@ from codexed.models.base import (
|
|
|
9
9
|
JsonRpcRequest,
|
|
10
10
|
JsonRpcResponse,
|
|
11
11
|
)
|
|
12
|
-
from codexed.models.codex_types import
|
|
13
|
-
ElicitationAction,
|
|
14
|
-
ApprovalDecision,
|
|
15
|
-
NetworkApprovalProtocol,
|
|
16
|
-
NetworkPolicyRuleAction,
|
|
17
|
-
SkillApprovalDecision,
|
|
18
|
-
)
|
|
12
|
+
from codexed.models.codex_types import ElicitationAction, ApprovalDecision, SkillApprovalDecision
|
|
19
13
|
|
|
20
14
|
from codexed.models.event_data import (
|
|
21
15
|
ItemCompletedData,
|
|
@@ -42,6 +36,7 @@ from codexed.models.events import (
|
|
|
42
36
|
TurnCompletedEvent,
|
|
43
37
|
TurnStartedEvent,
|
|
44
38
|
codex_event_adapter,
|
|
39
|
+
RealtimeEvent,
|
|
45
40
|
)
|
|
46
41
|
from codexed.models.mcp_server import HttpMcpServer, McpServerConfig, StdioMcpServer
|
|
47
42
|
from codexed.models.misc import (
|
|
@@ -91,8 +86,6 @@ from codexed.models.responses import (
|
|
|
91
86
|
TurnStartResponse,
|
|
92
87
|
)
|
|
93
88
|
from codexed.models.thread_item import (
|
|
94
|
-
CollabAgentState,
|
|
95
|
-
McpToolCallError,
|
|
96
89
|
McpToolCallResult,
|
|
97
90
|
ThreadItem,
|
|
98
91
|
ThreadItemAgentMessage,
|
|
@@ -138,6 +131,21 @@ from codexed.models.tool_config import (
|
|
|
138
131
|
|
|
139
132
|
from codexed.models.v2_protocol import (
|
|
140
133
|
ByteRange,
|
|
134
|
+
CollabAgentState,
|
|
135
|
+
NetworkDomainPermission,
|
|
136
|
+
ThreadStartSource,
|
|
137
|
+
MemoryResetResponse,
|
|
138
|
+
RealtimeOutputModality,
|
|
139
|
+
ThreadRealtimeListVoicesParams,
|
|
140
|
+
RealtimeVoicesList,
|
|
141
|
+
ThreadMemoryMode,
|
|
142
|
+
ThreadInjectItemsParams,
|
|
143
|
+
NetworkApprovalProtocol,
|
|
144
|
+
MarketplaceAddParams,
|
|
145
|
+
MarketplaceAddResponse,
|
|
146
|
+
ThreadRealtimeListVoicesResponse,
|
|
147
|
+
McpToolCallError,
|
|
148
|
+
McpServerStatusDetail,
|
|
141
149
|
InitializeCapabilities,
|
|
142
150
|
UserInput,
|
|
143
151
|
ImageUserInput,
|
|
@@ -183,6 +191,8 @@ from codexed.models.v2_protocol import (
|
|
|
183
191
|
ThreadLoadedListParams,
|
|
184
192
|
SkillsListExtraRootsForCwd,
|
|
185
193
|
SkillsListParams,
|
|
194
|
+
McpResourceReadParams,
|
|
195
|
+
McpResourceReadResponse,
|
|
186
196
|
BaseBranchReviewTarget,
|
|
187
197
|
ItemFileChangeOutputDeltaNotification,
|
|
188
198
|
ItemCommandExecutionOutputDeltaNotification,
|
|
@@ -199,7 +209,6 @@ from codexed.models.v2_protocol import (
|
|
|
199
209
|
ThreadRealtimeItemAddedMessage,
|
|
200
210
|
ThreadRealtimeOutputAudioDeltaMessage,
|
|
201
211
|
ThreadRealtimeStartedMessage,
|
|
202
|
-
ThreadRealtimeTranscriptUpdatedMessage,
|
|
203
212
|
DeprecationNoticeMessage,
|
|
204
213
|
ErrorMessage,
|
|
205
214
|
McpServerOauthLoginCompletedMessage,
|
|
@@ -229,7 +238,7 @@ from codexed.models.v2_protocol import (
|
|
|
229
238
|
WriteStatus,
|
|
230
239
|
ActiveThreadStatus,
|
|
231
240
|
GhostCommit,
|
|
232
|
-
ThreadStatus
|
|
241
|
+
ThreadStatus,
|
|
233
242
|
IdleThreadStatus,
|
|
234
243
|
NotLoadedThreadStatus,
|
|
235
244
|
SystemErrorThreadStatus,
|
|
@@ -238,6 +247,8 @@ from codexed.models.v2_protocol import (
|
|
|
238
247
|
ConfigRequirementsReadResponse,
|
|
239
248
|
DynamicToolCallOutputContentItem,
|
|
240
249
|
ThreadTokenUsage,
|
|
250
|
+
RealtimeVoice,
|
|
251
|
+
ThreadRealtimeStartTransport,
|
|
241
252
|
ModelListResponse,
|
|
242
253
|
ConfigReadResponse,
|
|
243
254
|
ConfigWriteResponse,
|
|
@@ -320,7 +331,8 @@ from codexed.models.v2_protocol import (
|
|
|
320
331
|
ThreadRealtimeClosedNotification,
|
|
321
332
|
RealtimeConversationVersion,
|
|
322
333
|
ThreadRealtimeStartedNotification,
|
|
323
|
-
|
|
334
|
+
ThreadRealtimeTranscriptDeltaMessage,
|
|
335
|
+
ThreadRealtimeTranscriptDoneMessage,
|
|
324
336
|
WindowsWorldWritableWarningNotification,
|
|
325
337
|
SkillsListResponse,
|
|
326
338
|
CollaborationModeListResponse,
|
|
@@ -412,6 +424,7 @@ from codexed.models.v2_protocol import (
|
|
|
412
424
|
ReasoningSummaryPartAddedNotification,
|
|
413
425
|
ReasoningSummaryTextDeltaNotification,
|
|
414
426
|
ReasoningTextDeltaNotification,
|
|
427
|
+
ThreadMemoryModeSetParams,
|
|
415
428
|
FuzzyFileSearchMatchType,
|
|
416
429
|
FuzzyFileSearchParams,
|
|
417
430
|
FuzzyFileSearchSessionStartParams,
|
|
@@ -420,6 +433,7 @@ from codexed.models.v2_protocol import (
|
|
|
420
433
|
AppMetadata,
|
|
421
434
|
AppReview,
|
|
422
435
|
AppScreenshot,
|
|
436
|
+
McpServerToolCallResponse,
|
|
423
437
|
GitInfo,
|
|
424
438
|
ModelAvailabilityNux,
|
|
425
439
|
NetworkRequirements,
|
|
@@ -429,6 +443,7 @@ from codexed.models.v2_protocol import (
|
|
|
429
443
|
SkillInterface,
|
|
430
444
|
SkillToolDependency,
|
|
431
445
|
TurnError,
|
|
446
|
+
McpServerToolCallParams,
|
|
432
447
|
CommandExecOutputStream,
|
|
433
448
|
CommandExecOutputDeltaNotification,
|
|
434
449
|
CommandExecResizeResponse,
|
|
@@ -649,9 +664,13 @@ __all__ = [
|
|
|
649
664
|
"LocalShellCallResponseItem",
|
|
650
665
|
"LoginAccountParams",
|
|
651
666
|
"LoginAccountResponse",
|
|
667
|
+
"MarketplaceAddParams",
|
|
668
|
+
"MarketplaceAddResponse",
|
|
652
669
|
"McpAuthStatus",
|
|
653
670
|
"McpElicitationFormParams",
|
|
654
671
|
"McpElicitationUrlParams",
|
|
672
|
+
"McpResourceReadParams",
|
|
673
|
+
"McpResourceReadResponse",
|
|
655
674
|
"McpResourceToolsConfig",
|
|
656
675
|
"McpServerConfig",
|
|
657
676
|
"McpServerElicitationRequestParams",
|
|
@@ -662,11 +681,15 @@ __all__ = [
|
|
|
662
681
|
"McpServerOauthLoginResponse",
|
|
663
682
|
"McpServerRefreshResponse",
|
|
664
683
|
"McpServerStartupStatusUpdatedNotification",
|
|
684
|
+
"McpServerStatusDetail",
|
|
665
685
|
"McpServerStatusEntry",
|
|
666
686
|
"McpServerStatusUpdatedNotification",
|
|
687
|
+
"McpServerToolCallParams",
|
|
688
|
+
"McpServerToolCallResponse",
|
|
667
689
|
"McpToolCallError",
|
|
668
690
|
"McpToolCallProgressNotification",
|
|
669
691
|
"McpToolCallResult",
|
|
692
|
+
"MemoryResetResponse",
|
|
670
693
|
"MentionUserInput",
|
|
671
694
|
"MergeStrategy",
|
|
672
695
|
"MessagePhase",
|
|
@@ -683,8 +706,8 @@ __all__ = [
|
|
|
683
706
|
"NetworkAccess",
|
|
684
707
|
"NetworkApprovalContext",
|
|
685
708
|
"NetworkApprovalProtocol",
|
|
709
|
+
"NetworkDomainPermission",
|
|
686
710
|
"NetworkPolicyAmendment",
|
|
687
|
-
"NetworkPolicyRuleAction",
|
|
688
711
|
"NetworkRequirements",
|
|
689
712
|
"NotLoadedThreadStatus",
|
|
690
713
|
"OpenPageWebSearchAction",
|
|
@@ -706,6 +729,10 @@ __all__ = [
|
|
|
706
729
|
"ReadOnlyAccess",
|
|
707
730
|
"ReadOnlySandboxPolicy",
|
|
708
731
|
"RealtimeConversationVersion",
|
|
732
|
+
"RealtimeEvent",
|
|
733
|
+
"RealtimeOutputModality",
|
|
734
|
+
"RealtimeVoice",
|
|
735
|
+
"RealtimeVoicesList",
|
|
709
736
|
"ReasoningEffort",
|
|
710
737
|
"ReasoningEffortOption",
|
|
711
738
|
"ReasoningResponseItem",
|
|
@@ -767,6 +794,7 @@ __all__ = [
|
|
|
767
794
|
"ThreadCompactedMessage",
|
|
768
795
|
"ThreadCompactedMessage",
|
|
769
796
|
"ThreadForkParams",
|
|
797
|
+
"ThreadInjectItemsParams",
|
|
770
798
|
"ThreadItem",
|
|
771
799
|
"ThreadItemAgentMessage",
|
|
772
800
|
"ThreadItemCollabAgentToolCall",
|
|
@@ -786,6 +814,8 @@ __all__ = [
|
|
|
786
814
|
"ThreadListResponse",
|
|
787
815
|
"ThreadLoadedListParams",
|
|
788
816
|
"ThreadLoadedListResponse",
|
|
817
|
+
"ThreadMemoryMode",
|
|
818
|
+
"ThreadMemoryModeSetParams",
|
|
789
819
|
"ThreadNameUpdatedMessage",
|
|
790
820
|
"ThreadNameUpdatedNotification",
|
|
791
821
|
"ThreadReadParams",
|
|
@@ -801,17 +831,20 @@ __all__ = [
|
|
|
801
831
|
"ThreadRealtimeErrorNotification",
|
|
802
832
|
"ThreadRealtimeItemAddedMessage",
|
|
803
833
|
"ThreadRealtimeItemAddedNotification",
|
|
834
|
+
"ThreadRealtimeListVoicesParams",
|
|
835
|
+
"ThreadRealtimeListVoicesResponse",
|
|
804
836
|
"ThreadRealtimeOutputAudioDeltaMessage",
|
|
805
837
|
"ThreadRealtimeOutputAudioDeltaNotification",
|
|
806
838
|
"ThreadRealtimeStartParams",
|
|
807
839
|
"ThreadRealtimeStartResponse",
|
|
808
840
|
"ThreadRealtimeStartResponse",
|
|
841
|
+
"ThreadRealtimeStartTransport",
|
|
809
842
|
"ThreadRealtimeStartedMessage",
|
|
810
843
|
"ThreadRealtimeStartedNotification",
|
|
811
844
|
"ThreadRealtimeStopParams",
|
|
812
845
|
"ThreadRealtimeStopResponse",
|
|
813
|
-
"
|
|
814
|
-
"
|
|
846
|
+
"ThreadRealtimeTranscriptDeltaMessage",
|
|
847
|
+
"ThreadRealtimeTranscriptDoneMessage",
|
|
815
848
|
"ThreadResponse",
|
|
816
849
|
"ThreadResumeParams",
|
|
817
850
|
"ThreadRollbackParams",
|
|
@@ -822,11 +855,12 @@ __all__ = [
|
|
|
822
855
|
"ThreadSortKey",
|
|
823
856
|
"ThreadSourceKind",
|
|
824
857
|
"ThreadStartParams",
|
|
858
|
+
"ThreadStartSource",
|
|
825
859
|
"ThreadStartedData",
|
|
826
860
|
"ThreadStartedEvent",
|
|
861
|
+
"ThreadStatus",
|
|
827
862
|
"ThreadStatusChangedMessage",
|
|
828
863
|
"ThreadStatusChangedNotification",
|
|
829
|
-
"ThreadStatusUnion",
|
|
830
864
|
"ThreadTokenUsage",
|
|
831
865
|
"ThreadTokenUsageUpdatedEvent",
|
|
832
866
|
"ThreadTokenUsageUpdatedNotification",
|
|
@@ -9,5 +9,3 @@ from typing import Literal
|
|
|
9
9
|
ApprovalDecision = Literal["allow", "allowForSession", "deny", "denyForSession"]
|
|
10
10
|
SkillApprovalDecision = Literal["allow", "deny"]
|
|
11
11
|
ElicitationAction = Literal["accept", "decline", "cancel"]
|
|
12
|
-
NetworkApprovalProtocol = Literal["http", "https", "socks5Tcp", "socks5Udp"]
|
|
13
|
-
NetworkPolicyRuleAction = Literal["allow", "deny"]
|
|
@@ -53,8 +53,10 @@ from codexed.models.v2_protocol import (
|
|
|
53
53
|
ThreadRealtimeErrorMessage,
|
|
54
54
|
ThreadRealtimeItemAddedMessage,
|
|
55
55
|
ThreadRealtimeOutputAudioDeltaMessage,
|
|
56
|
+
ThreadRealtimeSdpMessage,
|
|
56
57
|
ThreadRealtimeStartedMessage,
|
|
57
|
-
|
|
58
|
+
ThreadRealtimeTranscriptDeltaMessage,
|
|
59
|
+
ThreadRealtimeTranscriptDoneMessage,
|
|
58
60
|
ThreadStatusChangedMessage,
|
|
59
61
|
ThreadTokenUsageUpdatedNotification,
|
|
60
62
|
ThreadUnarchivedMessage,
|
|
@@ -151,6 +153,16 @@ class RawResponseItemCompletedEvent(CodexBaseModel):
|
|
|
151
153
|
# Discriminated union of all event types
|
|
152
154
|
# ============================================================================
|
|
153
155
|
|
|
156
|
+
RealtimeEvent = (
|
|
157
|
+
ThreadRealtimeStartedMessage
|
|
158
|
+
| ThreadRealtimeItemAddedMessage
|
|
159
|
+
| ThreadRealtimeTranscriptDeltaMessage
|
|
160
|
+
| ThreadRealtimeTranscriptDoneMessage
|
|
161
|
+
| ThreadRealtimeOutputAudioDeltaMessage
|
|
162
|
+
| ThreadRealtimeSdpMessage
|
|
163
|
+
| ThreadRealtimeErrorMessage
|
|
164
|
+
| ThreadRealtimeClosedMessage
|
|
165
|
+
)
|
|
154
166
|
|
|
155
167
|
CodexEvent = Annotated[
|
|
156
168
|
# Error events
|
|
@@ -171,12 +183,7 @@ CodexEvent = Annotated[
|
|
|
171
183
|
| HookStartedMessage
|
|
172
184
|
| HookCompletedMessage
|
|
173
185
|
# Realtime voice events (EXPERIMENTAL)
|
|
174
|
-
|
|
|
175
|
-
| ThreadRealtimeItemAddedMessage
|
|
176
|
-
| ThreadRealtimeTranscriptUpdatedMessage
|
|
177
|
-
| ThreadRealtimeOutputAudioDeltaMessage
|
|
178
|
-
| ThreadRealtimeErrorMessage
|
|
179
|
-
| ThreadRealtimeClosedMessage
|
|
186
|
+
| RealtimeEvent
|
|
180
187
|
# Terminal control events
|
|
181
188
|
| CommandExecOutputDeltaMessage
|
|
182
189
|
# Fuzzy file search events (EXPERIMENTAL)
|