circle-codex 0.154.1__py3-none-any.whl
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.
- circle_codex-0.154.1.dist-info/METADATA +148 -0
- circle_codex-0.154.1.dist-info/RECORD +25 -0
- circle_codex-0.154.1.dist-info/WHEEL +4 -0
- openai_codex/__init__.py +95 -0
- openai_codex/_approval_mode.py +51 -0
- openai_codex/_goal.py +448 -0
- openai_codex/_initialize_metadata.py +54 -0
- openai_codex/_inputs.py +103 -0
- openai_codex/_login.py +172 -0
- openai_codex/_message_router.py +389 -0
- openai_codex/_run.py +135 -0
- openai_codex/_runtime_requirements.py +64 -0
- openai_codex/_sandbox.py +78 -0
- openai_codex/_version.py +36 -0
- openai_codex/api.py +901 -0
- openai_codex/async_client.py +413 -0
- openai_codex/client.py +924 -0
- openai_codex/errors.py +121 -0
- openai_codex/generated/__init__.py +1 -0
- openai_codex/generated/notification_registry.py +314 -0
- openai_codex/generated/v2_all.py +14112 -0
- openai_codex/models.py +76 -0
- openai_codex/py.typed +0 -0
- openai_codex/retry.py +41 -0
- openai_codex/types.py +81 -0
openai_codex/models.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import TypeAlias
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel
|
|
7
|
+
|
|
8
|
+
from .generated.notification_registry import KnownNotificationPayload as _KnownNotificationPayload
|
|
9
|
+
|
|
10
|
+
# Preserve the notification names previously importable from this module.
|
|
11
|
+
from .generated.v2_all import (
|
|
12
|
+
AccountLoginCompletedNotification as AccountLoginCompletedNotification,
|
|
13
|
+
AccountRateLimitsUpdatedNotification as AccountRateLimitsUpdatedNotification,
|
|
14
|
+
AccountUpdatedNotification as AccountUpdatedNotification,
|
|
15
|
+
AgentMessageDeltaNotification as AgentMessageDeltaNotification,
|
|
16
|
+
AppListUpdatedNotification as AppListUpdatedNotification,
|
|
17
|
+
CommandExecutionOutputDeltaNotification as CommandExecutionOutputDeltaNotification,
|
|
18
|
+
ConfigWarningNotification as ConfigWarningNotification,
|
|
19
|
+
ContextCompactedNotification as ContextCompactedNotification,
|
|
20
|
+
DeprecationNoticeNotification as DeprecationNoticeNotification,
|
|
21
|
+
ErrorNotification as ErrorNotification,
|
|
22
|
+
FileChangeOutputDeltaNotification as FileChangeOutputDeltaNotification,
|
|
23
|
+
ItemCompletedNotification as ItemCompletedNotification,
|
|
24
|
+
ItemStartedNotification as ItemStartedNotification,
|
|
25
|
+
McpServerOauthLoginCompletedNotification as McpServerOauthLoginCompletedNotification,
|
|
26
|
+
McpToolCallProgressNotification as McpToolCallProgressNotification,
|
|
27
|
+
PlanDeltaNotification as PlanDeltaNotification,
|
|
28
|
+
RawResponseItemCompletedNotification as RawResponseItemCompletedNotification,
|
|
29
|
+
ReasoningSummaryPartAddedNotification as ReasoningSummaryPartAddedNotification,
|
|
30
|
+
ReasoningSummaryTextDeltaNotification as ReasoningSummaryTextDeltaNotification,
|
|
31
|
+
ReasoningTextDeltaNotification as ReasoningTextDeltaNotification,
|
|
32
|
+
TerminalInteractionNotification as TerminalInteractionNotification,
|
|
33
|
+
ThreadGoalClearedNotification as ThreadGoalClearedNotification,
|
|
34
|
+
ThreadGoalUpdatedNotification as ThreadGoalUpdatedNotification,
|
|
35
|
+
ThreadNameUpdatedNotification as ThreadNameUpdatedNotification,
|
|
36
|
+
ThreadStartedNotification as ThreadStartedNotification,
|
|
37
|
+
ThreadTokenUsageUpdatedNotification as ThreadTokenUsageUpdatedNotification,
|
|
38
|
+
TurnCompletedNotification as TurnCompletedNotification,
|
|
39
|
+
TurnDiffUpdatedNotification as TurnDiffUpdatedNotification,
|
|
40
|
+
TurnPlanUpdatedNotification as TurnPlanUpdatedNotification,
|
|
41
|
+
TurnStartedNotification as TurnStartedNotification,
|
|
42
|
+
WindowsWorldWritableWarningNotification as WindowsWorldWritableWarningNotification,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
JsonScalar: TypeAlias = str | int | float | bool | None
|
|
46
|
+
JsonValue: TypeAlias = JsonScalar | dict[str, "JsonValue"] | list["JsonValue"]
|
|
47
|
+
JsonObject: TypeAlias = dict[str, JsonValue]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass(slots=True)
|
|
51
|
+
class UnknownNotification:
|
|
52
|
+
params: JsonObject
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# Preserve the existing raw-item type, which app-server omits from its notification schema.
|
|
56
|
+
NotificationPayload: TypeAlias = (
|
|
57
|
+
_KnownNotificationPayload | RawResponseItemCompletedNotification | UnknownNotification
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclass(slots=True)
|
|
62
|
+
class Notification:
|
|
63
|
+
method: str
|
|
64
|
+
payload: NotificationPayload
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class ServerInfo(BaseModel):
|
|
68
|
+
name: str | None = None
|
|
69
|
+
version: str | None = None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class InitializeResponse(BaseModel):
|
|
73
|
+
serverInfo: ServerInfo | None = None
|
|
74
|
+
userAgent: str | None = None
|
|
75
|
+
platformFamily: str | None = None
|
|
76
|
+
platformOs: str | None = None
|
openai_codex/py.typed
ADDED
|
File without changes
|
openai_codex/retry.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import random
|
|
4
|
+
import time
|
|
5
|
+
from typing import Callable, TypeVar
|
|
6
|
+
|
|
7
|
+
from .errors import is_retryable_error
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def retry_on_overload(
|
|
13
|
+
op: Callable[[], T],
|
|
14
|
+
*,
|
|
15
|
+
max_attempts: int = 3,
|
|
16
|
+
initial_delay_s: float = 0.25,
|
|
17
|
+
max_delay_s: float = 2.0,
|
|
18
|
+
jitter_ratio: float = 0.2,
|
|
19
|
+
) -> T:
|
|
20
|
+
"""Retry helper for transient server-overload errors."""
|
|
21
|
+
|
|
22
|
+
if max_attempts < 1:
|
|
23
|
+
raise ValueError("max_attempts must be >= 1")
|
|
24
|
+
|
|
25
|
+
delay = initial_delay_s
|
|
26
|
+
attempt = 0
|
|
27
|
+
while True:
|
|
28
|
+
attempt += 1
|
|
29
|
+
try:
|
|
30
|
+
return op()
|
|
31
|
+
except Exception as exc:
|
|
32
|
+
if attempt >= max_attempts:
|
|
33
|
+
raise
|
|
34
|
+
if not is_retryable_error(exc):
|
|
35
|
+
raise
|
|
36
|
+
|
|
37
|
+
jitter = delay * jitter_ratio
|
|
38
|
+
sleep_for = min(max_delay_s, delay) + random.uniform(-jitter, jitter)
|
|
39
|
+
if sleep_for > 0:
|
|
40
|
+
time.sleep(sleep_for)
|
|
41
|
+
delay = min(max_delay_s, delay * 2)
|
openai_codex/types.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Public Codex protocol model exports for type annotations and matching."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from .generated.v2_all import (
|
|
6
|
+
Account,
|
|
7
|
+
AccountLoginCompletedNotification,
|
|
8
|
+
ApprovalsReviewer,
|
|
9
|
+
AskForApproval,
|
|
10
|
+
CancelLoginAccountResponse,
|
|
11
|
+
CancelLoginAccountStatus,
|
|
12
|
+
GetAccountResponse,
|
|
13
|
+
ModelListResponse,
|
|
14
|
+
Personality,
|
|
15
|
+
PlanType,
|
|
16
|
+
ReasoningEffort,
|
|
17
|
+
ReasoningSummary,
|
|
18
|
+
SandboxMode,
|
|
19
|
+
SandboxPolicy,
|
|
20
|
+
SortDirection,
|
|
21
|
+
ThreadArchiveResponse,
|
|
22
|
+
ThreadCompactStartResponse,
|
|
23
|
+
ThreadItem,
|
|
24
|
+
ThreadListCwdFilter,
|
|
25
|
+
ThreadListResponse,
|
|
26
|
+
ThreadReadResponse,
|
|
27
|
+
ThreadSetNameResponse,
|
|
28
|
+
ThreadSortKey,
|
|
29
|
+
ThreadSource,
|
|
30
|
+
ThreadSourceKind,
|
|
31
|
+
ThreadStartSource,
|
|
32
|
+
ThreadTokenUsage,
|
|
33
|
+
ThreadTokenUsageUpdatedNotification,
|
|
34
|
+
Turn,
|
|
35
|
+
TurnCompletedNotification,
|
|
36
|
+
TurnError,
|
|
37
|
+
TurnInterruptResponse,
|
|
38
|
+
TurnStatus,
|
|
39
|
+
TurnSteerResponse,
|
|
40
|
+
)
|
|
41
|
+
from .models import InitializeResponse, JsonObject, Notification
|
|
42
|
+
|
|
43
|
+
__all__ = [
|
|
44
|
+
"Account",
|
|
45
|
+
"AccountLoginCompletedNotification",
|
|
46
|
+
"ApprovalsReviewer",
|
|
47
|
+
"AskForApproval",
|
|
48
|
+
"CancelLoginAccountResponse",
|
|
49
|
+
"CancelLoginAccountStatus",
|
|
50
|
+
"GetAccountResponse",
|
|
51
|
+
"InitializeResponse",
|
|
52
|
+
"JsonObject",
|
|
53
|
+
"ModelListResponse",
|
|
54
|
+
"Notification",
|
|
55
|
+
"Personality",
|
|
56
|
+
"PlanType",
|
|
57
|
+
"ReasoningEffort",
|
|
58
|
+
"ReasoningSummary",
|
|
59
|
+
"SandboxMode",
|
|
60
|
+
"SandboxPolicy",
|
|
61
|
+
"SortDirection",
|
|
62
|
+
"ThreadArchiveResponse",
|
|
63
|
+
"ThreadCompactStartResponse",
|
|
64
|
+
"ThreadItem",
|
|
65
|
+
"ThreadListCwdFilter",
|
|
66
|
+
"ThreadListResponse",
|
|
67
|
+
"ThreadReadResponse",
|
|
68
|
+
"ThreadSetNameResponse",
|
|
69
|
+
"ThreadSortKey",
|
|
70
|
+
"ThreadSource",
|
|
71
|
+
"ThreadSourceKind",
|
|
72
|
+
"ThreadStartSource",
|
|
73
|
+
"ThreadTokenUsage",
|
|
74
|
+
"ThreadTokenUsageUpdatedNotification",
|
|
75
|
+
"Turn",
|
|
76
|
+
"TurnCompletedNotification",
|
|
77
|
+
"TurnError",
|
|
78
|
+
"TurnInterruptResponse",
|
|
79
|
+
"TurnStatus",
|
|
80
|
+
"TurnSteerResponse",
|
|
81
|
+
]
|