codexed 1.0.0__tar.gz → 1.1.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.0.0 → codexed-1.1.1}/PKG-INFO +1 -1
- {codexed-1.0.0 → codexed-1.1.1}/pyproject.toml +1 -1
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/__init__.py +10 -12
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/client/__init__.py +2 -1
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/client/client.py +11 -87
- codexed-1.1.1/src/codexed/client/realtime.py +174 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/client/session.py +20 -3
- codexed-1.1.1/src/codexed/client/skills.py +104 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/__init__.py +84 -91
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/event_data.py +0 -8
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/request_params.py +6 -160
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/responses.py +0 -6
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/tool_config.py +2 -9
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/user_input.py +6 -6
- {codexed-1.0.0 → codexed-1.1.1}/LICENSE +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/README.md +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/README.md +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/client/dispatch.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/client/fs.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/exceptions.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/helpers.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/log.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/base.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/codex_types.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/events.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/mcp_server.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/misc.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/response_item.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/thread_item.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/models/v2_protocol.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/py.typed +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/request_handlers.py +0 -0
- {codexed-1.0.0 → codexed-1.1.1}/src/codexed/transport.py +0 -0
|
@@ -61,15 +61,14 @@ from codexed.models import (
|
|
|
61
61
|
ThreadUnarchiveResponse,
|
|
62
62
|
TokenUsageBreakdown,
|
|
63
63
|
TurnCompletedData,
|
|
64
|
-
TurnErrorData,
|
|
65
64
|
TurnStartedData,
|
|
66
65
|
TurnSteerResponse,
|
|
67
66
|
UserInput,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
ImageUserInput,
|
|
68
|
+
LocalImageUserInput,
|
|
69
|
+
MentionUserInput,
|
|
70
|
+
SkillUserInput,
|
|
71
|
+
TextUserInput,
|
|
73
72
|
ApprovalPolicy,
|
|
74
73
|
AskForApproval,
|
|
75
74
|
CollaborationMode,
|
|
@@ -177,6 +176,7 @@ __all__ = [
|
|
|
177
176
|
"ExternalSandboxPolicy",
|
|
178
177
|
"FsChangedMessage",
|
|
179
178
|
"HttpMcpServer",
|
|
179
|
+
"ImageUserInput",
|
|
180
180
|
"InputModality",
|
|
181
181
|
"InternalRpcError",
|
|
182
182
|
"InvalidParamsError",
|
|
@@ -189,9 +189,11 @@ __all__ = [
|
|
|
189
189
|
"ItemReasoningTextDeltaNotification",
|
|
190
190
|
"ItemStartedEvent",
|
|
191
191
|
"ItemStatus",
|
|
192
|
+
"LocalImageUserInput",
|
|
192
193
|
"McpAuthStatus",
|
|
193
194
|
"McpElicitationHandler",
|
|
194
195
|
"McpServerConfig",
|
|
196
|
+
"MentionUserInput",
|
|
195
197
|
"MessagePhase",
|
|
196
198
|
"MethodNotFoundError",
|
|
197
199
|
"ModeKind",
|
|
@@ -222,8 +224,10 @@ __all__ = [
|
|
|
222
224
|
"SkillApprovalDecision",
|
|
223
225
|
"SkillMetadata",
|
|
224
226
|
"SkillScope",
|
|
227
|
+
"SkillUserInput",
|
|
225
228
|
"StdioMcpServer",
|
|
226
229
|
"StdioTransport",
|
|
230
|
+
"TextUserInput",
|
|
227
231
|
"Thread",
|
|
228
232
|
"ThreadActiveFlag",
|
|
229
233
|
"ThreadArchivedMessage",
|
|
@@ -250,7 +254,6 @@ __all__ = [
|
|
|
250
254
|
"TransportClosedError",
|
|
251
255
|
"TurnCompletedData",
|
|
252
256
|
"TurnCompletedEvent",
|
|
253
|
-
"TurnErrorData",
|
|
254
257
|
"TurnFailedError",
|
|
255
258
|
"TurnPlanUpdatedMessage",
|
|
256
259
|
"TurnStartedData",
|
|
@@ -259,11 +262,6 @@ __all__ = [
|
|
|
259
262
|
"TurnSteerResponse",
|
|
260
263
|
"UserInput",
|
|
261
264
|
"UserInputHandler",
|
|
262
|
-
"UserInputImage",
|
|
263
|
-
"UserInputLocalImage",
|
|
264
|
-
"UserInputMention",
|
|
265
|
-
"UserInputSkill",
|
|
266
|
-
"UserInputText",
|
|
267
265
|
"WebSocketTransport",
|
|
268
266
|
"WorkspaceWriteSandboxPolicy",
|
|
269
267
|
"is_retryable_error",
|
|
@@ -44,13 +44,6 @@ from codexed.models import (
|
|
|
44
44
|
McpServerOauthLoginResponse,
|
|
45
45
|
ModelListParams,
|
|
46
46
|
ModelListResponse,
|
|
47
|
-
SkillsConfigWriteParams,
|
|
48
|
-
SkillsListParams,
|
|
49
|
-
SkillsListResponse,
|
|
50
|
-
SkillsRemoteExportParams,
|
|
51
|
-
SkillsRemoteExportResponse,
|
|
52
|
-
SkillsRemoteListParams,
|
|
53
|
-
SkillsRemoteListResponse,
|
|
54
47
|
ThreadForkParams,
|
|
55
48
|
ThreadListParams,
|
|
56
49
|
ThreadListResponse,
|
|
@@ -90,16 +83,12 @@ if TYPE_CHECKING:
|
|
|
90
83
|
DynamicToolSpec,
|
|
91
84
|
ExperimentalFeature,
|
|
92
85
|
ExternalAgentConfigMigrationItem,
|
|
93
|
-
HazelnutScope,
|
|
94
86
|
McpServerConfig,
|
|
95
87
|
MergeStrategy,
|
|
96
88
|
Model,
|
|
97
89
|
Personality,
|
|
98
|
-
ProductSurface,
|
|
99
|
-
RemoteSkillSummary,
|
|
100
90
|
SandboxMode,
|
|
101
91
|
ServiceTier,
|
|
102
|
-
SkillMetadata,
|
|
103
92
|
ThreadSortKey,
|
|
104
93
|
ThreadSourceKind,
|
|
105
94
|
ToolConfig,
|
|
@@ -177,6 +166,7 @@ class CodexClient:
|
|
|
177
166
|
on_server_request=self._handle_server_request,
|
|
178
167
|
)
|
|
179
168
|
self._turn_queues: dict[str, asyncio.Queue[CodexEvent | None]] = {}
|
|
169
|
+
self._realtime_queues: dict[str, asyncio.Queue[CodexEvent | None]] = {}
|
|
180
170
|
self._event_queue: asyncio.Queue[CodexEvent | None] = asyncio.Queue()
|
|
181
171
|
self._active_threads: set[str] = set()
|
|
182
172
|
self._mcp_elicitation_enabled = on_mcp_elicitation is not None
|
|
@@ -501,81 +491,6 @@ class CodexClient:
|
|
|
501
491
|
response = ThreadLoadedListResponse.model_validate(result)
|
|
502
492
|
return response.data
|
|
503
493
|
|
|
504
|
-
# ========================================================================
|
|
505
|
-
# Skills methods
|
|
506
|
-
# ========================================================================
|
|
507
|
-
|
|
508
|
-
async def skills_list(
|
|
509
|
-
self,
|
|
510
|
-
*,
|
|
511
|
-
cwds: list[str] | None = None,
|
|
512
|
-
force_reload: bool | None = None,
|
|
513
|
-
) -> list[SkillMetadata]:
|
|
514
|
-
"""List available skills.
|
|
515
|
-
|
|
516
|
-
Args:
|
|
517
|
-
cwds: Optional working directories to scope skills
|
|
518
|
-
force_reload: Force reload of skills cache
|
|
519
|
-
|
|
520
|
-
Returns:
|
|
521
|
-
List of skills with metadata
|
|
522
|
-
"""
|
|
523
|
-
params = SkillsListParams(cwds=cwds, force_reload=force_reload)
|
|
524
|
-
result = await self.dispatch.send_request("skills/list", params)
|
|
525
|
-
response = SkillsListResponse.model_validate(result)
|
|
526
|
-
if response.data:
|
|
527
|
-
return response.data[0].skills
|
|
528
|
-
return []
|
|
529
|
-
|
|
530
|
-
async def skills_config_write(self, path: str, *, enabled: bool) -> None:
|
|
531
|
-
"""Write skills configuration.
|
|
532
|
-
|
|
533
|
-
Args:
|
|
534
|
-
path: Path to the skill
|
|
535
|
-
enabled: Whether the skill is enabled
|
|
536
|
-
"""
|
|
537
|
-
params = SkillsConfigWriteParams(path=path, enabled=enabled)
|
|
538
|
-
await self.dispatch.send_request("skills/config/write", params)
|
|
539
|
-
|
|
540
|
-
async def skills_remote_list(
|
|
541
|
-
self,
|
|
542
|
-
*,
|
|
543
|
-
hazelnut_scope: HazelnutScope = "example",
|
|
544
|
-
product_surface: ProductSurface = "codex",
|
|
545
|
-
enabled: bool = False,
|
|
546
|
-
) -> list[RemoteSkillSummary]:
|
|
547
|
-
"""List remote skills.
|
|
548
|
-
|
|
549
|
-
Args:
|
|
550
|
-
hazelnut_scope: Scope filter (example/workspace-shared/all-shared/personal)
|
|
551
|
-
product_surface: Product surface filter (chatgpt/codex/api/atlas)
|
|
552
|
-
enabled: Whether to filter by enabled status
|
|
553
|
-
|
|
554
|
-
Returns:
|
|
555
|
-
List of remote skill summaries
|
|
556
|
-
"""
|
|
557
|
-
params = SkillsRemoteListParams(
|
|
558
|
-
hazelnut_scope=hazelnut_scope,
|
|
559
|
-
product_surface=product_surface,
|
|
560
|
-
enabled=enabled,
|
|
561
|
-
)
|
|
562
|
-
result = await self.dispatch.send_request("skills/remote/list", params)
|
|
563
|
-
response = SkillsRemoteListResponse.model_validate(result)
|
|
564
|
-
return response.data
|
|
565
|
-
|
|
566
|
-
async def skills_remote_export(self, hazelnut_id: str) -> SkillsRemoteExportResponse:
|
|
567
|
-
"""Export a skill to remote storage.
|
|
568
|
-
|
|
569
|
-
Args:
|
|
570
|
-
hazelnut_id: ID of the remote skill to export
|
|
571
|
-
|
|
572
|
-
Returns:
|
|
573
|
-
SkillsRemoteExportResponse with id and local path
|
|
574
|
-
"""
|
|
575
|
-
params = SkillsRemoteExportParams(hazelnut_id=hazelnut_id)
|
|
576
|
-
result = await self.dispatch.send_request("skills/remote/export", params)
|
|
577
|
-
return SkillsRemoteExportResponse.model_validate(result)
|
|
578
|
-
|
|
579
494
|
# ========================================================================
|
|
580
495
|
# Model methods
|
|
581
496
|
# ========================================================================
|
|
@@ -721,12 +636,13 @@ class CodexClient:
|
|
|
721
636
|
Returns:
|
|
722
637
|
LoginAccountResponse with login details
|
|
723
638
|
"""
|
|
724
|
-
|
|
639
|
+
dct = dict(
|
|
725
640
|
type=login_type,
|
|
726
641
|
api_key=api_key,
|
|
727
642
|
access_token=access_token,
|
|
728
643
|
chatgpt_account_id=chatgpt_account_id,
|
|
729
644
|
)
|
|
645
|
+
params = TypeAdapter[LoginAccountParams](LoginAccountParams).validate_python(dct)
|
|
730
646
|
result = await self.dispatch.send_request("account/login/start", params)
|
|
731
647
|
return LoginAccountResponse.model_validate(result)
|
|
732
648
|
|
|
@@ -973,6 +889,14 @@ class CodexClient:
|
|
|
973
889
|
event: CodexEvent = codex_event_adapter.validate_python(event_data)
|
|
974
890
|
|
|
975
891
|
thread_id = params.get("threadId")
|
|
892
|
+
|
|
893
|
+
# Route realtime events to the realtime session queue
|
|
894
|
+
if method.startswith("thread/realtime/") and thread_id:
|
|
895
|
+
rt_key = f"realtime:{thread_id}"
|
|
896
|
+
queue = self._realtime_queues.get(rt_key)
|
|
897
|
+
await (queue or self._event_queue).put(event)
|
|
898
|
+
return
|
|
899
|
+
|
|
976
900
|
turn_id = params.get("turnId")
|
|
977
901
|
if not turn_id and "turn" in params:
|
|
978
902
|
turn_id = params.get("turn", {}).get("id")
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""Realtime voice session — async context manager for thread-scoped realtime."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import logging
|
|
7
|
+
from typing import TYPE_CHECKING, Self
|
|
8
|
+
|
|
9
|
+
from codexed.models import (
|
|
10
|
+
ThreadRealtimeAppendAudioParams,
|
|
11
|
+
ThreadRealtimeAppendAudioResponse,
|
|
12
|
+
ThreadRealtimeAppendTextParams,
|
|
13
|
+
ThreadRealtimeAppendTextResponse,
|
|
14
|
+
ThreadRealtimeAudioChunk,
|
|
15
|
+
ThreadRealtimeClosedMessage,
|
|
16
|
+
ThreadRealtimeStartedMessage,
|
|
17
|
+
ThreadRealtimeStartParams,
|
|
18
|
+
ThreadRealtimeStartResponse,
|
|
19
|
+
ThreadRealtimeStopParams,
|
|
20
|
+
ThreadRealtimeStopResponse,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
from collections.abc import AsyncIterator
|
|
26
|
+
from types import TracebackType
|
|
27
|
+
|
|
28
|
+
from codexed.client import CodexClient
|
|
29
|
+
from codexed.models import CodexEvent
|
|
30
|
+
|
|
31
|
+
logger = logging.getLogger(__name__)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
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
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(
|
|
52
|
+
self,
|
|
53
|
+
client: CodexClient,
|
|
54
|
+
thread_id: str,
|
|
55
|
+
prompt: str,
|
|
56
|
+
*,
|
|
57
|
+
session_id: str | None = None,
|
|
58
|
+
) -> None:
|
|
59
|
+
self._client = client
|
|
60
|
+
self._thread_id = thread_id
|
|
61
|
+
self._prompt = prompt
|
|
62
|
+
self._session_id = session_id
|
|
63
|
+
self._queue: asyncio.Queue[CodexEvent | None] = asyncio.Queue()
|
|
64
|
+
self._closed = False
|
|
65
|
+
self._queue_key = f"realtime:{thread_id}"
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def thread_id(self) -> str:
|
|
69
|
+
return self._thread_id
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def session_id(self) -> str | None:
|
|
73
|
+
return self._session_id
|
|
74
|
+
|
|
75
|
+
async def __aenter__(self) -> Self:
|
|
76
|
+
# Register our queue for realtime events
|
|
77
|
+
self._client._realtime_queues[self._queue_key] = self._queue
|
|
78
|
+
|
|
79
|
+
# Send start request
|
|
80
|
+
params = ThreadRealtimeStartParams(
|
|
81
|
+
thread_id=self._thread_id,
|
|
82
|
+
prompt=self._prompt,
|
|
83
|
+
session_id=self._session_id,
|
|
84
|
+
)
|
|
85
|
+
result = await self._client.dispatch.send_request("thread/realtime/start", params)
|
|
86
|
+
ThreadRealtimeStartResponse.model_validate(result)
|
|
87
|
+
|
|
88
|
+
# Wait for the started notification
|
|
89
|
+
event = await self._queue.get()
|
|
90
|
+
if isinstance(event, ThreadRealtimeStartedMessage):
|
|
91
|
+
self._session_id = event.params.session_id
|
|
92
|
+
return self
|
|
93
|
+
|
|
94
|
+
async def __aexit__(
|
|
95
|
+
self,
|
|
96
|
+
exc_type: type[BaseException] | None,
|
|
97
|
+
exc_val: BaseException | None,
|
|
98
|
+
exc_tb: TracebackType | None,
|
|
99
|
+
) -> None:
|
|
100
|
+
try:
|
|
101
|
+
if not self._closed:
|
|
102
|
+
params = ThreadRealtimeStopParams(thread_id=self._thread_id)
|
|
103
|
+
result = await self._client.dispatch.send_request("thread/realtime/stop", params)
|
|
104
|
+
ThreadRealtimeStopResponse.model_validate(result)
|
|
105
|
+
# Drain until we get the closed notification
|
|
106
|
+
while True:
|
|
107
|
+
event = await self._queue.get()
|
|
108
|
+
if event is None or isinstance(event, ThreadRealtimeClosedMessage):
|
|
109
|
+
break
|
|
110
|
+
except Exception: # noqa: BLE001
|
|
111
|
+
logger.debug("Error during realtime cleanup", exc_info=True)
|
|
112
|
+
finally:
|
|
113
|
+
self._client._realtime_queues.pop(self._queue_key, None)
|
|
114
|
+
|
|
115
|
+
def __aiter__(self) -> AsyncIterator[CodexEvent]:
|
|
116
|
+
return self
|
|
117
|
+
|
|
118
|
+
async def __anext__(self) -> CodexEvent:
|
|
119
|
+
if self._closed:
|
|
120
|
+
raise StopAsyncIteration
|
|
121
|
+
event = await self._queue.get()
|
|
122
|
+
if event is None or isinstance(event, ThreadRealtimeClosedMessage):
|
|
123
|
+
self._closed = True
|
|
124
|
+
if isinstance(event, ThreadRealtimeClosedMessage):
|
|
125
|
+
return event
|
|
126
|
+
raise StopAsyncIteration
|
|
127
|
+
return event
|
|
128
|
+
|
|
129
|
+
async def send_text(self, text: str) -> None:
|
|
130
|
+
"""Send text input to the realtime session."""
|
|
131
|
+
params = ThreadRealtimeAppendTextParams(
|
|
132
|
+
thread_id=self._thread_id,
|
|
133
|
+
text=text,
|
|
134
|
+
)
|
|
135
|
+
result = await self._client.dispatch.send_request("thread/realtime/appendText", params)
|
|
136
|
+
ThreadRealtimeAppendTextResponse.model_validate(result)
|
|
137
|
+
|
|
138
|
+
async def send_audio(
|
|
139
|
+
self,
|
|
140
|
+
data: str,
|
|
141
|
+
*,
|
|
142
|
+
sample_rate: int = 24_000,
|
|
143
|
+
num_channels: int = 1,
|
|
144
|
+
samples_per_channel: int | None = None,
|
|
145
|
+
item_id: str | None = None,
|
|
146
|
+
) -> None:
|
|
147
|
+
"""Send an audio chunk to the realtime session.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
data: Base64-encoded audio data.
|
|
151
|
+
sample_rate: Audio sample rate in Hz.
|
|
152
|
+
num_channels: Number of audio channels.
|
|
153
|
+
samples_per_channel: Number of samples per channel.
|
|
154
|
+
item_id: Optional item ID for the audio chunk.
|
|
155
|
+
"""
|
|
156
|
+
params = ThreadRealtimeAppendAudioParams(
|
|
157
|
+
thread_id=self._thread_id,
|
|
158
|
+
audio=ThreadRealtimeAudioChunk(
|
|
159
|
+
data=data,
|
|
160
|
+
sample_rate=sample_rate,
|
|
161
|
+
num_channels=num_channels,
|
|
162
|
+
samples_per_channel=samples_per_channel,
|
|
163
|
+
item_id=item_id,
|
|
164
|
+
),
|
|
165
|
+
)
|
|
166
|
+
result = await self._client.dispatch.send_request("thread/realtime/appendAudio", params)
|
|
167
|
+
ThreadRealtimeAppendAudioResponse.model_validate(result)
|
|
168
|
+
|
|
169
|
+
def __repr__(self) -> str:
|
|
170
|
+
state = "closed" if self._closed else "active"
|
|
171
|
+
return (
|
|
172
|
+
f"RealtimeSession(thread_id={self._thread_id!r}, "
|
|
173
|
+
f"session_id={self._session_id!r}, {state})"
|
|
174
|
+
)
|
|
@@ -9,6 +9,7 @@ from typing import TYPE_CHECKING, Any, assert_never
|
|
|
9
9
|
|
|
10
10
|
from pydantic import BaseModel, TypeAdapter
|
|
11
11
|
|
|
12
|
+
from codexed.client.realtime import RealtimeSession
|
|
12
13
|
from codexed.exceptions import CodexRequestError, TurnFailedError
|
|
13
14
|
from codexed.helpers import kebab_to_camel
|
|
14
15
|
from codexed.models import (
|
|
@@ -16,6 +17,7 @@ from codexed.models import (
|
|
|
16
17
|
ErrorNotification,
|
|
17
18
|
ReviewStartParams,
|
|
18
19
|
ReviewStartResponse,
|
|
20
|
+
TextUserInput,
|
|
19
21
|
ThreadArchiveParams,
|
|
20
22
|
ThreadCompactStartParams,
|
|
21
23
|
ThreadReadParams,
|
|
@@ -37,7 +39,6 @@ from codexed.models import (
|
|
|
37
39
|
TurnStartResponse,
|
|
38
40
|
TurnSteerParams,
|
|
39
41
|
TurnSteerResponse,
|
|
40
|
-
UserInputText,
|
|
41
42
|
)
|
|
42
43
|
|
|
43
44
|
|
|
@@ -152,7 +153,7 @@ class Session:
|
|
|
152
153
|
assert_never(sandbox_policy)
|
|
153
154
|
params = TurnStartParams(
|
|
154
155
|
thread_id=self.thread_id,
|
|
155
|
-
input=[
|
|
156
|
+
input=[TextUserInput(text=user_input)] if isinstance(user_input, str) else user_input,
|
|
156
157
|
model=model,
|
|
157
158
|
effort=effort,
|
|
158
159
|
approval_policy=approval_policy,
|
|
@@ -211,7 +212,7 @@ class Session:
|
|
|
211
212
|
"""
|
|
212
213
|
params = TurnSteerParams(
|
|
213
214
|
thread_id=self.thread_id,
|
|
214
|
-
input=[
|
|
215
|
+
input=[TextUserInput(text=user_input)] if isinstance(user_input, str) else user_input,
|
|
215
216
|
expected_turn_id=expected_turn_id,
|
|
216
217
|
)
|
|
217
218
|
result = await self._client.dispatch.send_request("turn/steer", params)
|
|
@@ -321,6 +322,22 @@ class Session:
|
|
|
321
322
|
params = ThreadCompactStartParams(thread_id=self.thread_id)
|
|
322
323
|
await self._client.dispatch.send_request("thread/compact/start", params)
|
|
323
324
|
|
|
325
|
+
def realtime(self, prompt: str, *, session_id: str | None = None) -> RealtimeSession:
|
|
326
|
+
"""Open a realtime voice session on this thread.
|
|
327
|
+
|
|
328
|
+
Returns an async context manager that sends ``thread/realtime/start``
|
|
329
|
+
on enter and ``thread/realtime/stop`` on exit. Iterate over the
|
|
330
|
+
returned object to receive realtime events.
|
|
331
|
+
|
|
332
|
+
Example::
|
|
333
|
+
|
|
334
|
+
async with session.realtime(prompt="You are helpful") as rt:
|
|
335
|
+
await rt.send_text("hello")
|
|
336
|
+
async for event in rt:
|
|
337
|
+
...
|
|
338
|
+
"""
|
|
339
|
+
return RealtimeSession(self._client, self.thread_id, prompt, session_id=session_id)
|
|
340
|
+
|
|
324
341
|
async def rollback(self, turns: int) -> ThreadRollbackResponse:
|
|
325
342
|
"""Rollback the last N turns from this thread.
|
|
326
343
|
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
SkillsConfigWriteParams,
|
|
10
|
+
SkillsListParams,
|
|
11
|
+
SkillsListResponse,
|
|
12
|
+
SkillsRemoteExportParams,
|
|
13
|
+
SkillsRemoteExportResponse,
|
|
14
|
+
SkillsRemoteListParams,
|
|
15
|
+
SkillsRemoteListResponse,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if TYPE_CHECKING:
|
|
20
|
+
from codexed.client import CodexClient
|
|
21
|
+
from codexed.models import (
|
|
22
|
+
HazelnutScope,
|
|
23
|
+
ProductSurface,
|
|
24
|
+
RemoteSkillSummary,
|
|
25
|
+
SkillMetadata,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
logger = logging.getLogger(__name__)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class CodexSkills:
|
|
32
|
+
def __init__(self, client: CodexClient):
|
|
33
|
+
self._client = client
|
|
34
|
+
|
|
35
|
+
async def list_skills(
|
|
36
|
+
self,
|
|
37
|
+
*,
|
|
38
|
+
cwds: list[str] | None = None,
|
|
39
|
+
force_reload: bool | None = None,
|
|
40
|
+
) -> list[SkillMetadata]:
|
|
41
|
+
"""List available skills.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
cwds: Optional working directories to scope skills
|
|
45
|
+
force_reload: Force reload of skills cache
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
List of skills with metadata
|
|
49
|
+
"""
|
|
50
|
+
params = SkillsListParams(cwds=cwds, force_reload=force_reload)
|
|
51
|
+
result = await self._client.dispatch.send_request("skills/list", params)
|
|
52
|
+
response = SkillsListResponse.model_validate(result)
|
|
53
|
+
if response.data:
|
|
54
|
+
return response.data[0].skills
|
|
55
|
+
return []
|
|
56
|
+
|
|
57
|
+
async def config_write(self, path: str, *, enabled: bool) -> None:
|
|
58
|
+
"""Write skills configuration.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
path: Path to the skill
|
|
62
|
+
enabled: Whether the skill is enabled
|
|
63
|
+
"""
|
|
64
|
+
params = SkillsConfigWriteParams(path=path, enabled=enabled)
|
|
65
|
+
await self._client.dispatch.send_request("skills/config/write", params)
|
|
66
|
+
|
|
67
|
+
async def remote_list(
|
|
68
|
+
self,
|
|
69
|
+
*,
|
|
70
|
+
hazelnut_scope: HazelnutScope = "example",
|
|
71
|
+
product_surface: ProductSurface = "codex",
|
|
72
|
+
enabled: bool = False,
|
|
73
|
+
) -> list[RemoteSkillSummary]:
|
|
74
|
+
"""List remote skills.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
hazelnut_scope: Scope filter (example/workspace-shared/all-shared/personal)
|
|
78
|
+
product_surface: Product surface filter (chatgpt/codex/api/atlas)
|
|
79
|
+
enabled: Whether to filter by enabled status
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
List of remote skill summaries
|
|
83
|
+
"""
|
|
84
|
+
params = SkillsRemoteListParams(
|
|
85
|
+
hazelnut_scope=hazelnut_scope,
|
|
86
|
+
product_surface=product_surface,
|
|
87
|
+
enabled=enabled,
|
|
88
|
+
)
|
|
89
|
+
result = await self._client.dispatch.send_request("skills/remote/list", params)
|
|
90
|
+
response = SkillsRemoteListResponse.model_validate(result)
|
|
91
|
+
return response.data
|
|
92
|
+
|
|
93
|
+
async def remote_export(self, hazelnut_id: str) -> SkillsRemoteExportResponse:
|
|
94
|
+
"""Export a skill to remote storage.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
hazelnut_id: ID of the remote skill to export
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
SkillsRemoteExportResponse with id and local path
|
|
101
|
+
"""
|
|
102
|
+
params = SkillsRemoteExportParams(hazelnut_id=hazelnut_id)
|
|
103
|
+
result = await self._client.dispatch.send_request("skills/remote/export", params)
|
|
104
|
+
return SkillsRemoteExportResponse.model_validate(result)
|
|
@@ -27,7 +27,6 @@ from codexed.models.event_data import (
|
|
|
27
27
|
ItemStartedData,
|
|
28
28
|
RawResponseItemCompletedData,
|
|
29
29
|
ThreadStartedData,
|
|
30
|
-
TurnErrorData,
|
|
31
30
|
TurnStartedData,
|
|
32
31
|
TurnCompletedData,
|
|
33
32
|
)
|
|
@@ -40,57 +39,18 @@ from codexed.models.events import (
|
|
|
40
39
|
ItemAgentMessageDeltaNotification,
|
|
41
40
|
AppListUpdatedMessage,
|
|
42
41
|
CodexEvent,
|
|
43
|
-
ItemCommandExecutionOutputDeltaNotification,
|
|
44
|
-
ItemCommandExecutionTerminalInteractionNotification,
|
|
45
|
-
ConfigWarningMessage,
|
|
46
|
-
FsChangedMessage,
|
|
47
42
|
DeltaEvent,
|
|
48
|
-
HookCompletedMessage,
|
|
49
|
-
HookStartedMessage,
|
|
50
|
-
CommandExecOutputDeltaMessage,
|
|
51
|
-
FuzzyFileSearchSessionCompletedMessage,
|
|
52
|
-
FuzzyFileSearchSessionUpdatedMessage,
|
|
53
|
-
ThreadRealtimeClosedMessage,
|
|
54
|
-
ThreadRealtimeErrorMessage,
|
|
55
|
-
ThreadRealtimeItemAddedMessage,
|
|
56
|
-
ThreadRealtimeOutputAudioDeltaMessage,
|
|
57
|
-
ThreadRealtimeStartedMessage,
|
|
58
|
-
ThreadRealtimeTranscriptUpdatedMessage,
|
|
59
|
-
DeprecationNoticeMessage,
|
|
60
|
-
ErrorMessage,
|
|
61
43
|
EventType,
|
|
62
|
-
ItemFileChangeOutputDeltaNotification,
|
|
63
44
|
ItemCompletedEvent,
|
|
64
45
|
ItemStartedEvent,
|
|
65
|
-
McpServerOauthLoginCompletedMessage,
|
|
66
|
-
McpServerStartupStatusUpdatedNotification,
|
|
67
|
-
ItemMcpToolCallProgressNotification,
|
|
68
|
-
ModelReroutedMessage,
|
|
69
|
-
ItemPlanDeltaNotification,
|
|
70
46
|
RawResponseItemCompletedEvent,
|
|
71
|
-
ItemReasoningSummaryPartAddedNotification,
|
|
72
|
-
ItemReasoningSummaryTextDeltaNotification,
|
|
73
|
-
ItemReasoningTextDeltaNotification,
|
|
74
|
-
ServerRequestResolvedMessage,
|
|
75
|
-
ThreadArchivedMessage,
|
|
76
|
-
ThreadCompactedMessage,
|
|
77
|
-
ThreadNameUpdatedMessage,
|
|
78
47
|
ThreadStartedEvent,
|
|
79
|
-
ThreadStatusChangedMessage,
|
|
80
48
|
ThreadTokenUsageUpdatedEvent,
|
|
81
|
-
ThreadUnarchivedMessage,
|
|
82
49
|
TurnCompletedEvent,
|
|
83
|
-
TurnDiffUpdatedMessage,
|
|
84
|
-
TurnPlanUpdatedMessage,
|
|
85
50
|
TurnStartedEvent,
|
|
86
|
-
WindowsWorldWritableWarningMessage,
|
|
87
51
|
codex_event_adapter,
|
|
88
52
|
)
|
|
89
53
|
from codexed.models.mcp_server import HttpMcpServer, McpServerConfig, StdioMcpServer
|
|
90
|
-
|
|
91
|
-
# Import order matters: misc ↔ thread_item have circular imports at module level.
|
|
92
|
-
# By importing misc first (which triggers thread_item), both modules are fully
|
|
93
|
-
# initialized before event_data or events try to use them.
|
|
94
54
|
from codexed.models.misc import (
|
|
95
55
|
ExecPolicyAmendment,
|
|
96
56
|
McpResource,
|
|
@@ -108,63 +68,25 @@ from codexed.models.misc import (
|
|
|
108
68
|
TurnData,
|
|
109
69
|
)
|
|
110
70
|
from codexed.models.request_params import (
|
|
111
|
-
|
|
71
|
+
InitializeParams,
|
|
112
72
|
HazelnutScope,
|
|
113
73
|
ProductSurface,
|
|
114
|
-
CollaborationModeListParams,
|
|
115
|
-
CommandExecParams,
|
|
116
74
|
CommandExecutionRequestApprovalParams,
|
|
117
|
-
CommitReviewTarget,
|
|
118
|
-
ConfigBatchWriteParams,
|
|
119
|
-
ConfigValueWriteParams,
|
|
120
|
-
CustomReviewTarget,
|
|
121
75
|
DynamicToolCallParams,
|
|
122
|
-
ExternalAgentConfigImportParams,
|
|
123
76
|
FileChangeRequestApprovalParams,
|
|
124
|
-
InitializeParams,
|
|
125
|
-
LoginAccountParams,
|
|
126
|
-
AuthMode,
|
|
127
77
|
McpElicitationFormParams,
|
|
128
78
|
McpElicitationUrlParams,
|
|
129
79
|
McpServerElicitationRequestParams,
|
|
130
|
-
ReviewStartParams,
|
|
131
|
-
ReviewTarget,
|
|
132
80
|
SkillRequestApprovalParams,
|
|
133
|
-
SkillsListExtraRootsForCwd,
|
|
134
|
-
SkillsListParams,
|
|
135
81
|
SkillsRemoteExportParams,
|
|
136
82
|
SkillsRemoteListParams,
|
|
137
|
-
ThreadForkParams,
|
|
138
|
-
ThreadListParams,
|
|
139
|
-
ThreadLoadedListParams,
|
|
140
|
-
ThreadResumeParams,
|
|
141
|
-
ThreadStartParams,
|
|
142
83
|
ToolRequestUserInputParams,
|
|
143
|
-
TurnStartParams,
|
|
144
|
-
TurnSteerParams,
|
|
145
|
-
UncommittedChangesReviewTarget,
|
|
146
|
-
)
|
|
147
|
-
from codexed.models.response_item import (
|
|
148
|
-
CompactionResponseItem,
|
|
149
|
-
ContentItem,
|
|
150
|
-
CustomToolCallOutputResponseItem,
|
|
151
|
-
CustomToolCallResponseItem,
|
|
152
|
-
FunctionCallOutputResponseItem,
|
|
153
|
-
FunctionCallResponseItem,
|
|
154
|
-
GhostSnapshotResponseItem,
|
|
155
|
-
ImageGenerationCallResponseItem,
|
|
156
|
-
LocalShellCallResponseItem,
|
|
157
|
-
MessageResponseItem,
|
|
158
|
-
OtherResponseItem,
|
|
159
|
-
ReasoningResponseItem,
|
|
160
|
-
ResponseItem,
|
|
161
|
-
WebSearchCallResponseItem,
|
|
162
84
|
)
|
|
85
|
+
|
|
163
86
|
from codexed.models.responses import (
|
|
164
87
|
CommandExecutionRequestApprovalResponse,
|
|
165
88
|
DynamicToolCallResponse,
|
|
166
89
|
ExternalAgentConfigDetectResponse,
|
|
167
|
-
FeedbackUploadResponse,
|
|
168
90
|
FileChangeRequestApprovalResponse,
|
|
169
91
|
ListMcpServerStatusResponse,
|
|
170
92
|
LoginAccountResponse,
|
|
@@ -230,16 +152,88 @@ from codexed.models.tool_config import (
|
|
|
230
152
|
)
|
|
231
153
|
from codexed.models.user_input import (
|
|
232
154
|
UserInput,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
155
|
+
ImageUserInput,
|
|
156
|
+
LocalImageUserInput,
|
|
157
|
+
MentionUserInput,
|
|
158
|
+
SkillUserInput,
|
|
159
|
+
TextUserInput,
|
|
238
160
|
)
|
|
239
161
|
from codexed.models.v2_protocol import (
|
|
240
162
|
ByteRange,
|
|
163
|
+
ExternalAgentConfigImportParams,
|
|
164
|
+
CommandExecParams,
|
|
165
|
+
ThreadStartParams,
|
|
166
|
+
ThreadForkParams,
|
|
167
|
+
CompactionResponseItem,
|
|
168
|
+
ContentItem,
|
|
169
|
+
CustomToolCallOutputResponseItem,
|
|
170
|
+
CustomToolCallResponseItem,
|
|
171
|
+
FunctionCallOutputResponseItem,
|
|
172
|
+
FunctionCallResponseItem,
|
|
173
|
+
GhostSnapshotResponseItem,
|
|
174
|
+
ImageGenerationCallResponseItem,
|
|
175
|
+
LocalShellCallResponseItem,
|
|
176
|
+
MessageResponseItem,
|
|
177
|
+
OtherResponseItem,
|
|
178
|
+
ReasoningResponseItem,
|
|
179
|
+
ResponseItem,
|
|
180
|
+
WebSearchCallResponseItem,
|
|
181
|
+
ReviewStartParams,
|
|
182
|
+
ReviewTarget,
|
|
183
|
+
ThreadResumeParams,
|
|
184
|
+
TurnStartParams,
|
|
185
|
+
TurnSteerParams,
|
|
186
|
+
ConfigBatchWriteParams,
|
|
187
|
+
ThreadListParams,
|
|
188
|
+
FeedbackUploadResponse,
|
|
189
|
+
LoginAccountParams,
|
|
241
190
|
TextElement,
|
|
191
|
+
ThreadLoadedListParams,
|
|
192
|
+
SkillsListExtraRootsForCwd,
|
|
193
|
+
SkillsListParams,
|
|
194
|
+
BaseBranchReviewTarget,
|
|
195
|
+
ItemFileChangeOutputDeltaNotification,
|
|
196
|
+
ItemCommandExecutionOutputDeltaNotification,
|
|
197
|
+
ItemCommandExecutionTerminalInteractionNotification,
|
|
198
|
+
ConfigWarningMessage,
|
|
199
|
+
FsChangedMessage,
|
|
200
|
+
HookCompletedMessage,
|
|
201
|
+
HookStartedMessage,
|
|
202
|
+
CommandExecOutputDeltaMessage,
|
|
203
|
+
FuzzyFileSearchSessionCompletedMessage,
|
|
204
|
+
FuzzyFileSearchSessionUpdatedMessage,
|
|
205
|
+
ThreadRealtimeClosedMessage,
|
|
206
|
+
ThreadRealtimeErrorMessage,
|
|
207
|
+
ThreadRealtimeItemAddedMessage,
|
|
208
|
+
ThreadRealtimeOutputAudioDeltaMessage,
|
|
209
|
+
ThreadRealtimeStartedMessage,
|
|
210
|
+
ThreadRealtimeTranscriptUpdatedMessage,
|
|
211
|
+
DeprecationNoticeMessage,
|
|
212
|
+
ErrorMessage,
|
|
213
|
+
McpServerOauthLoginCompletedMessage,
|
|
214
|
+
McpServerStartupStatusUpdatedNotification,
|
|
215
|
+
ItemMcpToolCallProgressNotification,
|
|
216
|
+
ModelReroutedMessage,
|
|
217
|
+
ItemPlanDeltaNotification,
|
|
218
|
+
ItemReasoningSummaryPartAddedNotification,
|
|
219
|
+
ItemReasoningSummaryTextDeltaNotification,
|
|
220
|
+
ItemReasoningTextDeltaNotification,
|
|
221
|
+
ServerRequestResolvedMessage,
|
|
222
|
+
ThreadArchivedMessage,
|
|
223
|
+
ThreadCompactedMessage,
|
|
224
|
+
ThreadNameUpdatedMessage,
|
|
225
|
+
ThreadStatusChangedMessage,
|
|
226
|
+
ThreadUnarchivedMessage,
|
|
227
|
+
TurnDiffUpdatedMessage,
|
|
228
|
+
TurnPlanUpdatedMessage,
|
|
229
|
+
WindowsWorldWritableWarningMessage,
|
|
230
|
+
CollaborationModeListParams,
|
|
231
|
+
CommitReviewTarget,
|
|
232
|
+
ConfigValueWriteParams,
|
|
233
|
+
CustomReviewTarget,
|
|
234
|
+
UncommittedChangesReviewTarget,
|
|
242
235
|
MergeStrategy,
|
|
236
|
+
AuthMode,
|
|
243
237
|
WriteStatus,
|
|
244
238
|
ActiveThreadStatus,
|
|
245
239
|
GhostCommit,
|
|
@@ -632,6 +626,7 @@ __all__ = [
|
|
|
632
626
|
"IdleThreadStatus",
|
|
633
627
|
"ImageGenerationCallResponseItem",
|
|
634
628
|
"ImageGenerationToolConfig",
|
|
629
|
+
"ImageUserInput",
|
|
635
630
|
"InitializeParams",
|
|
636
631
|
"InputModality",
|
|
637
632
|
"ItemAgentMessageDeltaNotification",
|
|
@@ -657,6 +652,7 @@ __all__ = [
|
|
|
657
652
|
"ListFilesCommandAction",
|
|
658
653
|
"ListMcpServerStatusParams",
|
|
659
654
|
"ListMcpServerStatusResponse",
|
|
655
|
+
"LocalImageUserInput",
|
|
660
656
|
"LocalShellCallResponseItem",
|
|
661
657
|
"LoginAccountParams",
|
|
662
658
|
"LoginAccountResponse",
|
|
@@ -681,6 +677,7 @@ __all__ = [
|
|
|
681
677
|
"McpToolCallError",
|
|
682
678
|
"McpToolCallProgressNotification",
|
|
683
679
|
"McpToolCallResult",
|
|
680
|
+
"MentionUserInput",
|
|
684
681
|
"MergeStrategy",
|
|
685
682
|
"MessagePhase",
|
|
686
683
|
"MessageResponseItem",
|
|
@@ -756,6 +753,7 @@ __all__ = [
|
|
|
756
753
|
"SkillRequestApprovalResponse",
|
|
757
754
|
"SkillScope",
|
|
758
755
|
"SkillToolDependency",
|
|
756
|
+
"SkillUserInput",
|
|
759
757
|
"SkillsConfigWriteParams",
|
|
760
758
|
"SkillsConfigWriteResponse",
|
|
761
759
|
"SkillsListEntry",
|
|
@@ -770,6 +768,7 @@ __all__ = [
|
|
|
770
768
|
"SystemErrorThreadStatus",
|
|
771
769
|
"TerminalInteractionNotification",
|
|
772
770
|
"TextElement",
|
|
771
|
+
"TextUserInput",
|
|
773
772
|
"Thread",
|
|
774
773
|
"ThreadActiveFlag",
|
|
775
774
|
"ThreadActiveFlag",
|
|
@@ -865,7 +864,6 @@ __all__ = [
|
|
|
865
864
|
"TurnDiffUpdatedMessage",
|
|
866
865
|
"TurnDiffUpdatedNotification",
|
|
867
866
|
"TurnError",
|
|
868
|
-
"TurnErrorData",
|
|
869
867
|
"TurnInterruptParams",
|
|
870
868
|
"TurnPlanStep",
|
|
871
869
|
"TurnPlanStepStatus",
|
|
@@ -881,11 +879,6 @@ __all__ = [
|
|
|
881
879
|
"UncommittedChangesReviewTarget",
|
|
882
880
|
"UnknownCommandAction",
|
|
883
881
|
"UserInput",
|
|
884
|
-
"UserInputImage",
|
|
885
|
-
"UserInputLocalImage",
|
|
886
|
-
"UserInputMention",
|
|
887
|
-
"UserInputSkill",
|
|
888
|
-
"UserInputText",
|
|
889
882
|
"ViewImageToolConfig",
|
|
890
883
|
"WebSearchAction",
|
|
891
884
|
"WebSearchCallResponseItem",
|
|
@@ -17,28 +17,15 @@ from codexed.models.response_item import ResponseItem
|
|
|
17
17
|
from codexed.models.user_input import UserInput
|
|
18
18
|
from codexed.models.v2_protocol import (
|
|
19
19
|
ApprovalsReviewer,
|
|
20
|
-
|
|
21
|
-
BaseBranchReviewTarget,
|
|
20
|
+
AskForApproval,
|
|
22
21
|
ClientInfo,
|
|
23
22
|
CollaborationMode,
|
|
24
23
|
CommandAction,
|
|
25
|
-
CommandExecTerminalSize,
|
|
26
|
-
CommitReviewTarget,
|
|
27
|
-
ConfigEdit,
|
|
28
|
-
CustomReviewTarget,
|
|
29
|
-
DynamicToolSpec,
|
|
30
|
-
ExternalAgentConfigMigrationItem,
|
|
31
|
-
MergeStrategy,
|
|
32
24
|
Personality,
|
|
33
25
|
ReasoningEffort,
|
|
34
26
|
ReasoningSummary,
|
|
35
|
-
ReviewDelivery,
|
|
36
27
|
SandboxMode,
|
|
37
28
|
ServiceTier,
|
|
38
|
-
SkillsListExtraRootsForCwd,
|
|
39
|
-
ThreadSortKey,
|
|
40
|
-
ThreadSourceKind,
|
|
41
|
-
UncommittedChangesReviewTarget,
|
|
42
29
|
)
|
|
43
30
|
|
|
44
31
|
|
|
@@ -46,6 +33,10 @@ if TYPE_CHECKING:
|
|
|
46
33
|
from mcp.types import ElicitRequestFormParams, ElicitRequestURLParams
|
|
47
34
|
|
|
48
35
|
|
|
36
|
+
HazelnutScope = Literal["example", "workspace-shared", "all-shared", "personal"]
|
|
37
|
+
ProductSurface = Literal["chatgpt", "codex", "api", "atlas"]
|
|
38
|
+
|
|
39
|
+
|
|
49
40
|
class InitializeParams(CodexBaseModel):
|
|
50
41
|
"""Parameters for initialize request."""
|
|
51
42
|
|
|
@@ -56,27 +47,6 @@ class InitializeParams(CodexBaseModel):
|
|
|
56
47
|
return cls(client_info=ClientInfo(name=name, version=version))
|
|
57
48
|
|
|
58
49
|
|
|
59
|
-
class ThreadStartParams(CodexBaseModel):
|
|
60
|
-
"""Parameters for thread/start request."""
|
|
61
|
-
|
|
62
|
-
cwd: str | None = None
|
|
63
|
-
model: str | None = None
|
|
64
|
-
model_provider: str | None = None
|
|
65
|
-
base_instructions: str | None = None
|
|
66
|
-
developer_instructions: str | None = None
|
|
67
|
-
approval_policy: ApprovalPolicy | None = None
|
|
68
|
-
approvals_reviewer: ApprovalsReviewer | None = None
|
|
69
|
-
sandbox: SandboxMode | None = None
|
|
70
|
-
config: dict[str, Any] | None = None
|
|
71
|
-
service_name: str | None = None
|
|
72
|
-
service_tier: ServiceTier | None = None
|
|
73
|
-
personality: Personality | None = None
|
|
74
|
-
ephemeral: bool | None = None
|
|
75
|
-
dynamic_tools: list[DynamicToolSpec] | None = None
|
|
76
|
-
experimental_raw_events: bool = False
|
|
77
|
-
persist_extended_history: bool = False
|
|
78
|
-
|
|
79
|
-
|
|
80
50
|
class ThreadResumeParams(CodexBaseModel):
|
|
81
51
|
"""Parameters for thread/resume request."""
|
|
82
52
|
|
|
@@ -88,7 +58,7 @@ class ThreadResumeParams(CodexBaseModel):
|
|
|
88
58
|
model_provider: str | None = None
|
|
89
59
|
base_instructions: str | None = None
|
|
90
60
|
developer_instructions: str | None = None
|
|
91
|
-
approval_policy:
|
|
61
|
+
approval_policy: AskForApproval | None = None
|
|
92
62
|
approvals_reviewer: ApprovalsReviewer | None = None
|
|
93
63
|
sandbox: SandboxMode | None = None
|
|
94
64
|
config: dict[str, Any] | None = None
|
|
@@ -97,43 +67,6 @@ class ThreadResumeParams(CodexBaseModel):
|
|
|
97
67
|
persist_extended_history: bool = False
|
|
98
68
|
|
|
99
69
|
|
|
100
|
-
class ThreadForkParams(CodexBaseModel):
|
|
101
|
-
"""Parameters for thread/fork request."""
|
|
102
|
-
|
|
103
|
-
thread_id: str
|
|
104
|
-
path: str | None = None
|
|
105
|
-
cwd: str | None = None
|
|
106
|
-
model: str | None = None
|
|
107
|
-
model_provider: str | None = None
|
|
108
|
-
base_instructions: str | None = None
|
|
109
|
-
developer_instructions: str | None = None
|
|
110
|
-
approval_policy: ApprovalPolicy | None = None
|
|
111
|
-
approvals_reviewer: ApprovalsReviewer | None = None
|
|
112
|
-
sandbox: SandboxMode | None = None
|
|
113
|
-
config: dict[str, Any] | None = None
|
|
114
|
-
service_tier: ServiceTier | None = None
|
|
115
|
-
personality: Personality | None = None
|
|
116
|
-
ephemeral: bool | None = None
|
|
117
|
-
persist_extended_history: bool = False
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
class ThreadListParams(CodexBaseModel):
|
|
121
|
-
"""Parameters for thread/list request."""
|
|
122
|
-
|
|
123
|
-
cursor: str | None = None
|
|
124
|
-
limit: int | None = None
|
|
125
|
-
sort_key: ThreadSortKey | None = None
|
|
126
|
-
model_providers: list[str] | None = None
|
|
127
|
-
source_kinds: list[ThreadSourceKind] | None = None
|
|
128
|
-
archived: bool | None = None
|
|
129
|
-
cwd: str | None = None
|
|
130
|
-
search_term: str | None = None
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
class ThreadLoadedListParams(CodexBaseModel):
|
|
134
|
-
"""Parameters for thread/loaded/list request."""
|
|
135
|
-
|
|
136
|
-
|
|
137
70
|
class TurnStartParams(CodexBaseModel):
|
|
138
71
|
"""Parameters for turn/start request."""
|
|
139
72
|
|
|
@@ -160,34 +93,6 @@ class TurnSteerParams(CodexBaseModel):
|
|
|
160
93
|
expected_turn_id: str
|
|
161
94
|
|
|
162
95
|
|
|
163
|
-
ReviewTarget = (
|
|
164
|
-
UncommittedChangesReviewTarget
|
|
165
|
-
| BaseBranchReviewTarget
|
|
166
|
-
| CommitReviewTarget
|
|
167
|
-
| CustomReviewTarget
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
class ReviewStartParams(CodexBaseModel):
|
|
172
|
-
"""Parameters for review/start request."""
|
|
173
|
-
|
|
174
|
-
thread_id: str
|
|
175
|
-
target: ReviewTarget
|
|
176
|
-
delivery: ReviewDelivery | None = None
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
class SkillsListParams(CodexBaseModel):
|
|
180
|
-
"""Parameters for skills/list request."""
|
|
181
|
-
|
|
182
|
-
cwds: list[str] | None = None
|
|
183
|
-
force_reload: bool | None = None
|
|
184
|
-
per_cwd_extra_user_roots: list[SkillsListExtraRootsForCwd] | None = None
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
HazelnutScope = Literal["example", "workspace-shared", "all-shared", "personal"]
|
|
188
|
-
ProductSurface = Literal["chatgpt", "codex", "api", "atlas"]
|
|
189
|
-
|
|
190
|
-
|
|
191
96
|
class SkillsRemoteListParams(CodexBaseModel):
|
|
192
97
|
"""Parameters for skills/remote/list request."""
|
|
193
98
|
|
|
@@ -202,65 +107,6 @@ class SkillsRemoteExportParams(CodexBaseModel):
|
|
|
202
107
|
hazelnut_id: str
|
|
203
108
|
|
|
204
109
|
|
|
205
|
-
class CollaborationModeListParams(CodexBaseModel):
|
|
206
|
-
"""Parameters for collaborationMode/list request."""
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
class CommandExecParams(CodexBaseModel):
|
|
210
|
-
"""Parameters for command/exec request."""
|
|
211
|
-
|
|
212
|
-
command: list[str]
|
|
213
|
-
process_id: str | None = None
|
|
214
|
-
tty: bool = False
|
|
215
|
-
stream_stdin: bool = False
|
|
216
|
-
stream_stdout_stderr: bool = False
|
|
217
|
-
output_bytes_cap: int | None = None
|
|
218
|
-
disable_output_cap: bool = False
|
|
219
|
-
disable_timeout: bool = False
|
|
220
|
-
timeout_ms: int | None = None
|
|
221
|
-
cwd: str | None = None
|
|
222
|
-
env: dict[str, str | None] | None = None
|
|
223
|
-
size: CommandExecTerminalSize | None = None
|
|
224
|
-
sandbox_policy: dict[str, Any] | None = None
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
class ConfigValueWriteParams(CodexBaseModel):
|
|
228
|
-
"""Parameters for config/value/write request."""
|
|
229
|
-
|
|
230
|
-
key_path: str
|
|
231
|
-
value: Any
|
|
232
|
-
merge_strategy: MergeStrategy
|
|
233
|
-
file_path: str | None = None
|
|
234
|
-
expected_version: str | None = None
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
class ConfigBatchWriteParams(CodexBaseModel):
|
|
238
|
-
"""Parameters for config/batchWrite request."""
|
|
239
|
-
|
|
240
|
-
edits: list[ConfigEdit]
|
|
241
|
-
file_path: str | None = None
|
|
242
|
-
expected_version: str | None = None
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
class LoginAccountParams(CodexBaseModel):
|
|
246
|
-
"""Parameters for account/login/start request.
|
|
247
|
-
|
|
248
|
-
This is a discriminated union - use type field.
|
|
249
|
-
"""
|
|
250
|
-
|
|
251
|
-
type: AuthMode
|
|
252
|
-
api_key: str | None = None
|
|
253
|
-
access_token: str | None = None
|
|
254
|
-
chatgpt_account_id: str | None = None
|
|
255
|
-
chatgpt_plan_type: str | None = None
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
class ExternalAgentConfigImportParams(CodexBaseModel):
|
|
259
|
-
"""Parameters for externalAgentConfig/import request."""
|
|
260
|
-
|
|
261
|
-
migration_items: list[ExternalAgentConfigMigrationItem]
|
|
262
|
-
|
|
263
|
-
|
|
264
110
|
# ============================================================================
|
|
265
111
|
# Filesystem params
|
|
266
112
|
# ============================================================================
|
|
@@ -163,12 +163,6 @@ class LoginAccountResponse(CodexBaseModel):
|
|
|
163
163
|
auth_url: str | None = None
|
|
164
164
|
|
|
165
165
|
|
|
166
|
-
class FeedbackUploadResponse(CodexBaseModel):
|
|
167
|
-
"""Response for feedback/upload request."""
|
|
168
|
-
|
|
169
|
-
thread_id: str
|
|
170
|
-
|
|
171
|
-
|
|
172
166
|
class ExternalAgentConfigDetectResponse(CodexBaseModel):
|
|
173
167
|
"""Response for externalAgentConfig/detect request."""
|
|
174
168
|
|
|
@@ -15,6 +15,8 @@ from typing import Annotated, Any, Literal, assert_never
|
|
|
15
15
|
|
|
16
16
|
from pydantic import BaseModel, ConfigDict, Discriminator
|
|
17
17
|
|
|
18
|
+
from codexed.models.v2_protocol import WebSearchLocation
|
|
19
|
+
|
|
18
20
|
|
|
19
21
|
class _ToolConfigBase(BaseModel):
|
|
20
22
|
"""Base for individual tool configuration models."""
|
|
@@ -55,15 +57,6 @@ class ApplyPatchToolConfig(_ToolConfigBase):
|
|
|
55
57
|
# ---------------------------------------------------------------------------
|
|
56
58
|
|
|
57
59
|
|
|
58
|
-
class WebSearchLocation(_ToolConfigBase):
|
|
59
|
-
"""Location hints for web search results."""
|
|
60
|
-
|
|
61
|
-
country: str | None = None
|
|
62
|
-
region: str | None = None
|
|
63
|
-
city: str | None = None
|
|
64
|
-
timezone: str | None = None
|
|
65
|
-
|
|
66
|
-
|
|
67
60
|
class WebSearchToolConfig(_ToolConfigBase):
|
|
68
61
|
"""Configuration for the web_search tool."""
|
|
69
62
|
|
|
@@ -9,7 +9,7 @@ from codexed.models.base import CodexBaseModel
|
|
|
9
9
|
from codexed.models.v2_protocol import TextElement
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class TextUserInput(CodexBaseModel):
|
|
13
13
|
"""Text user input."""
|
|
14
14
|
|
|
15
15
|
type: Literal["text"] = "text"
|
|
@@ -17,7 +17,7 @@ class UserInputText(CodexBaseModel):
|
|
|
17
17
|
text_elements: list[TextElement] = Field(default_factory=list)
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
class
|
|
20
|
+
class ImageUserInput(CodexBaseModel):
|
|
21
21
|
"""Image URL user input."""
|
|
22
22
|
|
|
23
23
|
type: Literal["image"] = "image"
|
|
@@ -31,14 +31,14 @@ class UserInputImage(CodexBaseModel):
|
|
|
31
31
|
return cls(url=data_uri)
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
class
|
|
34
|
+
class LocalImageUserInput(CodexBaseModel):
|
|
35
35
|
"""Local image file user input."""
|
|
36
36
|
|
|
37
37
|
type: Literal["localImage"] = "localImage"
|
|
38
38
|
path: str
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
class
|
|
41
|
+
class SkillUserInput(CodexBaseModel):
|
|
42
42
|
"""Skill file user input."""
|
|
43
43
|
|
|
44
44
|
type: Literal["skill"] = "skill"
|
|
@@ -46,7 +46,7 @@ class UserInputSkill(CodexBaseModel):
|
|
|
46
46
|
path: str
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
class
|
|
49
|
+
class MentionUserInput(CodexBaseModel):
|
|
50
50
|
"""Mention user input."""
|
|
51
51
|
|
|
52
52
|
type: Literal["mention"] = "mention"
|
|
@@ -55,4 +55,4 @@ class UserInputMention(CodexBaseModel):
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
# Discriminated union of user input types
|
|
58
|
-
UserInput =
|
|
58
|
+
UserInput = TextUserInput | ImageUserInput | LocalImageUserInput | SkillUserInput | MentionUserInput
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|