mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
ff6764e808
## TL;DR Bring the Python app-server SDK from `main-with-prs-13953-and-14232` onto current `main` as a standalone SDK-only PR. - adds the new `sdk/python` and `sdk/python-runtime` package trees - keeps the scope to the SDK payload only, without the unrelated branch-history or workflow changes from the source branch - regenerates `sdk/python/src/codex_app_server/generated/v2_all.py` against current `main` schema so the extracted SDK matches today's protocol definitions ## Validation - `PYTHONPATH=sdk/python/src python3 -m pytest sdk/python/tests` Co-authored-by: Codex <noreply@openai.com>
98 lines
2.8 KiB
Python
98 lines
2.8 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import TypeAlias
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from .generated.v2_all import (
|
|
AccountLoginCompletedNotification,
|
|
AccountRateLimitsUpdatedNotification,
|
|
AccountUpdatedNotification,
|
|
AgentMessageDeltaNotification,
|
|
AppListUpdatedNotification,
|
|
CommandExecutionOutputDeltaNotification,
|
|
ConfigWarningNotification,
|
|
ContextCompactedNotification,
|
|
DeprecationNoticeNotification,
|
|
ErrorNotification,
|
|
FileChangeOutputDeltaNotification,
|
|
ItemCompletedNotification,
|
|
ItemStartedNotification,
|
|
McpServerOauthLoginCompletedNotification,
|
|
McpToolCallProgressNotification,
|
|
PlanDeltaNotification,
|
|
RawResponseItemCompletedNotification,
|
|
ReasoningSummaryPartAddedNotification,
|
|
ReasoningSummaryTextDeltaNotification,
|
|
ReasoningTextDeltaNotification,
|
|
TerminalInteractionNotification,
|
|
ThreadNameUpdatedNotification,
|
|
ThreadStartedNotification,
|
|
ThreadTokenUsageUpdatedNotification,
|
|
TurnCompletedNotification,
|
|
TurnDiffUpdatedNotification,
|
|
TurnPlanUpdatedNotification,
|
|
TurnStartedNotification,
|
|
WindowsWorldWritableWarningNotification,
|
|
)
|
|
|
|
JsonScalar: TypeAlias = str | int | float | bool | None
|
|
JsonValue: TypeAlias = JsonScalar | dict[str, "JsonValue"] | list["JsonValue"]
|
|
JsonObject: TypeAlias = dict[str, JsonValue]
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class UnknownNotification:
|
|
params: JsonObject
|
|
|
|
|
|
NotificationPayload: TypeAlias = (
|
|
AccountLoginCompletedNotification
|
|
| AccountRateLimitsUpdatedNotification
|
|
| AccountUpdatedNotification
|
|
| AgentMessageDeltaNotification
|
|
| AppListUpdatedNotification
|
|
| CommandExecutionOutputDeltaNotification
|
|
| ConfigWarningNotification
|
|
| ContextCompactedNotification
|
|
| DeprecationNoticeNotification
|
|
| ErrorNotification
|
|
| FileChangeOutputDeltaNotification
|
|
| ItemCompletedNotification
|
|
| ItemStartedNotification
|
|
| McpServerOauthLoginCompletedNotification
|
|
| McpToolCallProgressNotification
|
|
| PlanDeltaNotification
|
|
| RawResponseItemCompletedNotification
|
|
| ReasoningSummaryPartAddedNotification
|
|
| ReasoningSummaryTextDeltaNotification
|
|
| ReasoningTextDeltaNotification
|
|
| TerminalInteractionNotification
|
|
| ThreadNameUpdatedNotification
|
|
| ThreadStartedNotification
|
|
| ThreadTokenUsageUpdatedNotification
|
|
| TurnCompletedNotification
|
|
| TurnDiffUpdatedNotification
|
|
| TurnPlanUpdatedNotification
|
|
| TurnStartedNotification
|
|
| WindowsWorldWritableWarningNotification
|
|
| UnknownNotification
|
|
)
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class Notification:
|
|
method: str
|
|
payload: NotificationPayload
|
|
|
|
|
|
class ServerInfo(BaseModel):
|
|
name: str | None = None
|
|
version: str | None = None
|
|
|
|
|
|
class InitializeResponse(BaseModel):
|
|
serverInfo: ServerInfo | None = None
|
|
userAgent: str | None = None
|