@jrkropp/codex-js 0.1.3 → 0.2.0
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.
- package/CHANGELOG.md +10 -0
- package/README.md +57 -617
- package/dist/client/index.d.ts +2 -16
- package/dist/client/index.js +2522 -16
- package/dist/index.d.ts +2 -25
- package/dist/index.js +699 -20
- package/dist/internal/codex/app-server/src/bespoke_event_handling.d.ts +5 -0
- package/dist/internal/codex/app-server/src/connection_rpc_gate.d.ts +11 -0
- package/dist/internal/codex/app-server/src/dynamic_tools.d.ts +5 -0
- package/dist/internal/codex/app-server/src/message_processor.d.ts +88 -0
- package/dist/internal/codex/app-server/src/outgoing_message.d.ts +73 -0
- package/dist/internal/codex/app-server/src/request_processors/common.d.ts +25 -0
- package/dist/internal/codex/app-server/src/request_processors/mcp_processor.d.ts +32 -0
- package/dist/internal/codex/app-server/src/request_processors/request_errors.d.ts +9 -0
- package/dist/internal/codex/app-server/src/request_processors/thread_processor.d.ts +38 -0
- package/dist/internal/codex/app-server/src/request_processors/token_usage_replay.d.ts +22 -0
- package/dist/internal/codex/app-server/src/request_processors/turn_processor.d.ts +21 -0
- package/dist/internal/codex/app-server/src/request_processors.d.ts +5 -0
- package/dist/internal/codex/app-server/src/request_serialization.d.ts +7 -0
- package/dist/internal/codex/app-server/src/runtime.d.ts +96 -0
- package/dist/internal/codex/app-server/src/server_request_response.d.ts +30 -0
- package/dist/internal/codex/app-server/src/session_factory.d.ts +30 -0
- package/dist/internal/codex/app-server/src/session_task_runner.d.ts +44 -0
- package/dist/internal/codex/app-server/src/thread_state.d.ts +56 -0
- package/dist/internal/codex/app-server-client/src/lib.d.ts +48 -0
- package/dist/{index-77U_Oc-a.d.ts → internal/codex/app-server-client/src/pending_requests.d.ts} +7 -18
- package/dist/internal/codex/app-server-client/src/remote.d.ts +18 -0
- package/dist/{session-BRYzi8OT.d.ts → internal/codex/app-server-client/src/session.d.ts} +5 -9
- package/dist/{thread_event_store-C0zYzukG.d.ts → internal/codex/app-server-client/src/thread_event_store.d.ts} +14 -14
- package/dist/internal/codex/app-server-client/src/thread_projection.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/AbsolutePathBuf.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/AgentPath.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ApplyPatchApprovalParams.d.ts +22 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ApplyPatchApprovalResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/AuthMode.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ClientInfo.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ClientNotification.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ClientRequest.d.ts +410 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/CollaborationMode.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ContentItem.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ConversationGitInfo.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ConversationSummary.d.ts +15 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ExecCommandApprovalParams.d.ts +18 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ExecCommandApprovalResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ExecPolicyAmendment.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/FileChange.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ForcedLoginMethod.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/FunctionCallOutputBody.d.ts +2 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/FunctionCallOutputContentItem.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/FuzzyFileSearchMatchType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/FuzzyFileSearchParams.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/FuzzyFileSearchResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/FuzzyFileSearchResult.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/FuzzyFileSearchSessionCompletedNotification.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/FuzzyFileSearchSessionUpdatedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/GetAuthStatusParams.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/GetAuthStatusResponse.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/GetConversationSummaryParams.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/GetConversationSummaryResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/GitDiffToRemoteParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/GitDiffToRemoteResponse.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/GitSha.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ImageDetail.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/InitializeCapabilities.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/InitializeParams.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/InitializeResponse.d.ts +18 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/InputModality.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/InternalSessionSource.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/LocalShellAction.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/LocalShellExecAction.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/LocalShellStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/MessagePhase.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ModeKind.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/NetworkPolicyAmendment.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/NetworkPolicyRuleAction.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ParsedCommand.d.ts +24 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/Personality.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/PlanType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/RealtimeConversationVersion.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/RealtimeOutputModality.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/RealtimeVoice.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/RealtimeVoicesList.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ReasoningEffort.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ReasoningItemContent.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ReasoningItemReasoningSummary.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ReasoningSummary.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/RequestId.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/Resource.d.ts +15 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ResourceContent.d.ts +21 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ResourceTemplate.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ResponseItem.d.ts +78 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ReviewDecision.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ServerNotification.d.ts +260 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ServerRequest.d.ts +50 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/SessionSource.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/Settings.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/SubAgentSource.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ThreadId.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/ThreadMemoryMode.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/Tool.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/Verbosity.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/WebSearchAction.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/WebSearchContextSize.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/WebSearchLocation.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/WebSearchMode.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/WebSearchToolConfig.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/index.d.ts +77 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/serde_json/JsonValue.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/Account.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AccountLoginCompletedNotification.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AccountRateLimitsUpdatedNotification.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AccountUpdatedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ActivePermissionProfile.d.ts +18 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ActivePermissionProfileModification.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AddCreditsNudgeCreditType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AddCreditsNudgeEmailStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AdditionalFileSystemPermissions.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AdditionalNetworkPermissions.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AdditionalPermissionProfile.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AgentMessageDeltaNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AnalyticsConfig.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppBranding.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppInfo.d.ts +30 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppListUpdatedNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppMetadata.d.ts +16 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppReview.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppScreenshot.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppSummary.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppToolApproval.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppToolsConfig.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ApprovalsReviewer.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppsConfig.d.ts +15 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppsDefaultConfig.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppsListParams.d.ts +21 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AppsListResponse.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AskForApproval.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/AutoReviewDecisionSource.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ByteRange.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CancelLoginAccountParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CancelLoginAccountResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CancelLoginAccountStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ChatgptAuthTokensRefreshParams.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ChatgptAuthTokensRefreshReason.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ChatgptAuthTokensRefreshResponse.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CodexErrorInfo.d.ts +28 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CollabAgentState.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CollabAgentStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CollabAgentTool.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CollabAgentToolCallStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CollaborationModeListParams.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CollaborationModeListResponse.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CollaborationModeMask.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandAction.d.ts +19 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecOutputDeltaNotification.d.ts +27 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecOutputStream.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecParams.d.ts +82 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecResizeParams.d.ts +15 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecResizeResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecResponse.d.ts +21 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecTerminalSize.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecTerminateParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecTerminateResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecWriteParams.d.ts +19 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecWriteResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecutionApprovalDecision.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecutionOutputDeltaNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecutionRequestApprovalParams.d.ts +40 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecutionRequestApprovalResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecutionSource.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandExecutionStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CommandMigration.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/Config.d.ts +47 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigBatchWriteParams.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigEdit.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigLayer.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigLayerMetadata.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigLayerSource.d.ts +30 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigReadParams.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigReadResponse.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigRequirements.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigRequirementsReadResponse.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigValueWriteParams.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigWarningNotification.d.ts +19 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfigWriteResponse.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfiguredHookHandler.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ConfiguredHookMatcherGroup.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ContextCompactedNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/CreditsSnapshot.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeprecationNoticeNotification.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeyAlgorithm.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeyCreateParams.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeyCreateResponse.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeyProtectionClass.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeyProtectionPolicy.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeyPublicParams.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeyPublicResponse.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeySignParams.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeySignPayload.d.ts +62 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DeviceKeySignResponse.d.ts +16 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DynamicToolCallOutputContentItem.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DynamicToolCallParams.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DynamicToolCallResponse.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DynamicToolCallStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/DynamicToolSpec.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ErrorNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExecPolicyAmendment.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExperimentalFeature.d.ts +34 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExperimentalFeatureEnablementSetParams.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExperimentalFeatureEnablementSetResponse.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExperimentalFeatureListParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExperimentalFeatureListResponse.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExperimentalFeatureStage.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExternalAgentConfigDetectParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExternalAgentConfigDetectResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportCompletedNotification.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportParams.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExternalAgentConfigImportResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExternalAgentConfigMigrationItem.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ExternalAgentConfigMigrationItemType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FeedbackUploadParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FeedbackUploadResponse.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileChangeApprovalDecision.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileChangeOutputDeltaNotification.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileChangePatchUpdatedNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileChangeRequestApprovalParams.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileChangeRequestApprovalResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileSystemAccessMode.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileSystemPath.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileSystemSandboxEntry.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileSystemSpecialPath.d.ts +16 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FileUpdateChange.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsChangedNotification.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsCopyParams.d.ts +18 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsCopyResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsCreateDirectoryParams.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsCreateDirectoryResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsGetMetadataParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsGetMetadataResponse.d.ts +25 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsReadDirectoryEntry.d.ts +17 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsReadDirectoryParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsReadDirectoryResponse.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsReadFileParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsReadFileResponse.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsRemoveParams.d.ts +18 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsRemoveResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsUnwatchParams.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsUnwatchResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsWatchParams.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsWatchResponse.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsWriteFileParams.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/FsWriteFileResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GetAccountParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GetAccountRateLimitsResponse.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GetAccountResponse.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GitInfo.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GrantedPermissionProfile.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GuardianApprovalReview.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GuardianApprovalReviewAction.d.ts +37 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GuardianApprovalReviewStatus.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GuardianCommandSource.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GuardianRiskLevel.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GuardianUserAuthorization.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/GuardianWarningNotification.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookCompletedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookErrorInfo.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookEventName.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookExecutionMode.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookHandlerType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookMetadata.d.ts +22 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookMigration.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookOutputEntry.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookOutputEntryKind.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookPromptFragment.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookRunStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookRunSummary.d.ts +24 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookScope.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookSource.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookStartedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HookTrustStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HooksListEntry.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HooksListParams.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/HooksListResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ItemCompletedNotification.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ItemGuardianApprovalReviewCompletedNotification.d.ts +32 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ItemGuardianApprovalReviewStartedNotification.d.ts +30 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ItemStartedNotification.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ListMcpServerStatusParams.d.ts +16 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ListMcpServerStatusResponse.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/LoginAccountParams.d.ts +27 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/LoginAccountResponse.d.ts +23 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/LogoutAccountResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ManagedHooksRequirements.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MarketplaceAddParams.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MarketplaceAddResponse.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MarketplaceInterface.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MarketplaceLoadErrorInfo.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MarketplaceRemoveParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MarketplaceRemoveResponse.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MarketplaceUpgradeErrorInfo.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MarketplaceUpgradeParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MarketplaceUpgradeResponse.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpAuthStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationArrayType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationBooleanSchema.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationBooleanType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationConstOption.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationEnumSchema.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationLegacyTitledEnumSchema.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationMultiSelectEnumSchema.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationNumberSchema.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationNumberType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationObjectType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationPrimitiveSchema.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationSchema.d.ts +16 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationSingleSelectEnumSchema.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationStringFormat.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationStringSchema.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationStringType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationTitledEnumItems.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationTitledMultiSelectEnumSchema.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationTitledSingleSelectEnumSchema.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationUntitledEnumItems.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationUntitledMultiSelectEnumSchema.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpElicitationUntitledSingleSelectEnumSchema.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpResourceReadParams.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpResourceReadResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerElicitationAction.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerElicitationRequestParams.d.ts +26 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerElicitationRequestResponse.d.ts +15 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerMigration.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerOauthLoginCompletedNotification.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerOauthLoginParams.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerOauthLoginResponse.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerRefreshResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerStartupState.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerStatus.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerStatusDetail.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerStatusUpdatedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerToolCallParams.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpServerToolCallResponse.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpToolCallError.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpToolCallProgressNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpToolCallResult.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/McpToolCallStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MemoryCitation.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MemoryCitationEntry.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MergeStrategy.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/MigrationDetails.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/Model.d.ts +26 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelAvailabilityNux.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelListParams.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelListResponse.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelProviderCapabilitiesReadParams.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelProviderCapabilitiesReadResponse.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelRerouteReason.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelReroutedNotification.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelServiceTier.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelUpgradeInfo.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelVerification.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ModelVerificationNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/NetworkAccess.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/NetworkApprovalContext.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/NetworkApprovalProtocol.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/NetworkDomainPermission.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/NetworkPolicyAmendment.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/NetworkPolicyRuleAction.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/NetworkRequirements.d.ts +40 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/NetworkUnixSocketPermission.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/NonSteerableTurnKind.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/OverriddenMetadata.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PatchApplyStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PatchChangeKind.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PermissionGrantScope.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PermissionProfile.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PermissionProfileFileSystemPermissions.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PermissionProfileModificationParams.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PermissionProfileNetworkPermissions.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PermissionProfileSelectionParams.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PermissionsRequestApprovalParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PermissionsRequestApprovalResponse.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PlanDeltaNotification.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginAuthPolicy.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginAvailability.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginDetail.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginInstallParams.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginInstallPolicy.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginInstallResponse.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginInterface.d.ts +42 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginListMarketplaceKind.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginListParams.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginListResponse.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginMarketplaceEntry.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginReadParams.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginReadResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareContext.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareDeleteParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareDeleteResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareDiscoverability.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareListItem.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareListParams.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareListResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginSharePrincipal.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginSharePrincipalType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareSaveParams.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareSaveResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareTarget.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareUpdateTargetsParams.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginShareUpdateTargetsResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginSkillReadParams.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginSkillReadResponse.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginSource.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginSummary.d.ts +25 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginUninstallParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginUninstallResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/PluginsMigration.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ProcessExitedNotification.d.ts +39 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ProcessOutputDeltaNotification.d.ts +23 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ProcessOutputStream.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ProcessTerminalSize.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ProfileV2.d.ts +29 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/RateLimitReachedType.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/RateLimitSnapshot.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/RateLimitWindow.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/RawResponseItemCompletedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ReasoningEffortOption.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ReasoningSummaryPartAddedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ReasoningSummaryTextDeltaNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ReasoningTextDeltaNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/RemoteControlClientConnectionAudience.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/RemoteControlClientEnrollmentAudience.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/RemoteControlConnectionStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/RemoteControlStatusChangedNotification.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/RequestPermissionProfile.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ResidencyRequirement.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ReviewDelivery.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ReviewStartParams.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ReviewStartResponse.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ReviewTarget.d.ts +16 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SandboxMode.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SandboxPolicy.d.ts +17 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SandboxWorkspaceWrite.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SendAddCreditsNudgeEmailParams.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SendAddCreditsNudgeEmailResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ServerRequestResolvedNotification.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SessionMigration.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SessionSource.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillDependencies.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillErrorInfo.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillInterface.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillMetadata.d.ts +17 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillScope.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillSummary.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillToolDependency.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillsChangedNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillsConfigWriteParams.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillsConfigWriteResponse.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillsListEntry.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillsListExtraRootsForCwd.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillsListParams.d.ts +15 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SkillsListResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SortDirection.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/SubagentMigration.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TerminalInteractionNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TextElement.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TextPosition.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TextRange.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/Thread.d.ts +84 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadActiveFlag.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadApproveGuardianDeniedActionParams.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadApproveGuardianDeniedActionResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadArchiveParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadArchiveResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadArchivedNotification.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadClosedNotification.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadCompactStartParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadCompactStartResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadForkParams.d.ts +38 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadForkResponse.d.ts +26 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadGoal.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadGoalClearedNotification.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadGoalStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadGoalUpdatedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadInjectItemsParams.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadInjectItemsResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadItem.d.ts +180 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadListParams.d.ts +51 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadListResponse.d.ts +16 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadLoadedListParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadLoadedListResponse.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadMetadataGitInfoUpdateParams.d.ts +17 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadMetadataUpdateParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadMetadataUpdateResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadNameUpdatedNotification.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadReadParams.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadReadResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeAudioChunk.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeClosedNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeErrorNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeItemAddedNotification.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeOutputAudioDeltaNotification.d.ts +8 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeSdpNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeStartTransport.d.ts +13 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeStartedNotification.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeTranscriptDeltaNotification.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRealtimeTranscriptDoneNotification.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadResumeParams.d.ts +37 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadResumeResponse.d.ts +26 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRollbackParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadRollbackResponse.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadSetNameParams.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadSetNameResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadShellCommandParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadShellCommandResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadSortKey.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadSource.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadSourceKind.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadStartParams.d.ts +31 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadStartResponse.d.ts +26 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadStartSource.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadStartedNotification.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadStatus.d.ts +11 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadStatusChangedNotification.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadTokenUsage.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadTokenUsageUpdatedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadUnarchiveParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadUnarchiveResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadUnarchivedNotification.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadUnsubscribeParams.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadUnsubscribeResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ThreadUnsubscribeStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TokenUsageBreakdown.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ToolRequestUserInputAnswer.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ToolRequestUserInputOption.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ToolRequestUserInputParams.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ToolRequestUserInputQuestion.d.ts +12 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ToolRequestUserInputResponse.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/ToolsV2.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/Turn.d.ts +32 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnCompletedNotification.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnDiffUpdatedNotification.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnEnvironmentParams.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnError.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnInterruptParams.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnInterruptResponse.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnItemsView.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnPlanStep.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnPlanStepStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnPlanUpdatedNotification.d.ts +7 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnStartParams.d.ts +44 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnStartResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnStartedNotification.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnSteerParams.d.ts +9 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/TurnSteerResponse.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/UserInput.d.ts +23 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WarningNotification.d.ts +10 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WebSearchAction.d.ts +14 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WindowsSandboxReadiness.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WindowsSandboxReadinessResponse.d.ts +4 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WindowsSandboxSetupCompletedNotification.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WindowsSandboxSetupMode.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WindowsSandboxSetupStartParams.d.ts +6 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WindowsSandboxSetupStartResponse.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WindowsWorldWritableWarningNotification.d.ts +5 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/WriteStatus.d.ts +1 -0
- package/dist/internal/codex/app-server-protocol/schema/typescript/v2/index.d.ts +457 -0
- package/dist/internal/codex/app-server-protocol/src/protocol/common.d.ts +36 -0
- package/dist/internal/codex/app-server-protocol/src/protocol/event-mapping.d.ts +41 -0
- package/dist/internal/codex/app-server-protocol/src/protocol/index.d.ts +3 -0
- package/dist/internal/codex/app-server-protocol/src/protocol/thread-resume.d.ts +11 -0
- package/dist/internal/codex/app-server-transport/src/outgoing_message.d.ts +27 -0
- package/dist/internal/codex/app-server-transport/src/transport/mod.d.ts +78 -0
- package/dist/internal/codex/codex-api/src/common.d.ts +100 -0
- package/dist/internal/codex/codex-api/src/endpoint/responses.d.ts +28 -0
- package/dist/internal/codex/codex-api/src/endpoint/responses_websocket.d.ts +54 -0
- package/dist/internal/codex/codex-api/src/error.d.ts +21 -0
- package/dist/internal/codex/codex-api/src/index.d.ts +9 -0
- package/dist/internal/codex/codex-api/src/provider.d.ts +22 -0
- package/dist/internal/codex/codex-api/src/rate_limits.d.ts +3 -0
- package/dist/internal/codex/codex-api/src/requests/responses.d.ts +16 -0
- package/dist/internal/codex/codex-api/src/sse/responses.d.ts +13 -0
- package/dist/internal/codex/codex-api/src/stream_events_utils.d.ts +23 -0
- package/dist/internal/codex/codex-mcp/src/auth_elicitation.d.ts +41 -0
- package/dist/internal/codex/codex-mcp/src/codex_apps.d.ts +57 -0
- package/dist/internal/codex/codex-mcp/src/connection_manager.d.ts +72 -0
- package/dist/internal/codex/codex-mcp/src/elicitation.d.ts +77 -0
- package/dist/internal/codex/codex-mcp/src/mcp/auth.d.ts +64 -0
- package/dist/internal/codex/codex-mcp/src/mcp/mod.d.ts +16 -0
- package/dist/internal/codex/codex-mcp/src/rmcp_client.d.ts +221 -0
- package/dist/internal/codex/codex-mcp/src/tools.d.ts +37 -0
- package/dist/internal/codex/config/src/config_toml.d.ts +14 -0
- package/dist/internal/codex/config/src/index.d.ts +7 -0
- package/dist/internal/codex/config/src/loader/mod.d.ts +21 -0
- package/dist/internal/codex/config/src/merge.d.ts +22 -0
- package/dist/internal/codex/config/src/permissions_toml.d.ts +6 -0
- package/dist/internal/codex/config/src/profile_toml.d.ts +1 -0
- package/dist/internal/codex/config/src/thread_config.d.ts +43 -0
- package/dist/internal/codex/config/src/types.d.ts +121 -0
- package/dist/internal/codex/core/src/agent/agent_resolver.d.ts +3 -0
- package/dist/internal/codex/core/src/agent/control.d.ts +76 -0
- package/dist/internal/codex/core/src/agent/mailbox.d.ts +28 -0
- package/dist/internal/codex/core/src/agent/mod.d.ts +6 -0
- package/dist/internal/codex/core/src/agent/registry.d.ts +54 -0
- package/dist/internal/codex/core/src/agent/role.d.ts +19 -0
- package/dist/internal/codex/core/src/agent/status.d.ts +3 -0
- package/dist/internal/codex/core/src/auth.d.ts +65 -0
- package/dist/internal/codex/core/src/client.d.ts +129 -0
- package/dist/internal/codex/core/src/collaboration-mode-presets.d.ts +9 -0
- package/dist/internal/codex/core/src/compact-task-runner.d.ts +18 -0
- package/dist/internal/codex/core/src/compact.d.ts +12 -0
- package/dist/internal/codex/core/src/config/agent_roles.d.ts +6 -0
- package/dist/internal/codex/core/src/config/managed_features.d.ts +7 -0
- package/dist/internal/codex/core/src/config/mod.d.ts +9 -0
- package/dist/internal/codex/core/src/config/network_proxy_spec.d.ts +5 -0
- package/dist/internal/codex/core/src/config/permissions.d.ts +30 -0
- package/dist/internal/codex/core/src/config-types.d.ts +28 -0
- package/dist/internal/codex/core/src/context/collaboration-mode-instructions.d.ts +10 -0
- package/dist/internal/codex/core/src/context/context-updates.d.ts +10 -0
- package/dist/internal/codex/core/src/context/environment-context.d.ts +24 -0
- package/dist/internal/codex/core/src/context/fragment.d.ts +22 -0
- package/dist/internal/codex/core/src/context/permissions-instructions.d.ts +8 -0
- package/dist/internal/codex/core/src/context/prompt-context.d.ts +8 -0
- package/dist/internal/codex/core/src/context/turn-aborted.d.ts +3 -0
- package/dist/internal/codex/core/src/context/user-instructions.d.ts +7 -0
- package/dist/internal/codex/core/src/context_manager/history.d.ts +60 -0
- package/dist/internal/codex/core/src/context_manager/normalize.d.ts +6 -0
- package/dist/internal/codex/core/src/event-mapping.d.ts +9 -0
- package/dist/internal/codex/core/src/exec-output.d.ts +20 -0
- package/dist/internal/codex/core/src/goals/index.d.ts +2 -0
- package/dist/internal/codex/core/src/goals/runtime.d.ts +32 -0
- package/dist/internal/codex/core/src/goals/types.d.ts +95 -0
- package/dist/internal/codex/core/src/goals.d.ts +1 -0
- package/dist/internal/codex/core/src/hooks/dispatcher.d.ts +5 -0
- package/dist/internal/codex/core/src/hooks/index.d.ts +4 -0
- package/dist/internal/codex/core/src/hooks/output-parser.d.ts +9 -0
- package/dist/internal/codex/core/src/hooks/runtime.d.ts +125 -0
- package/dist/internal/codex/core/src/hooks/types.d.ts +40 -0
- package/dist/internal/codex/core/src/ids.d.ts +5 -0
- package/dist/internal/codex/core/src/index.d.ts +98 -0
- package/dist/internal/codex/core/src/items.d.ts +137 -0
- package/dist/internal/codex/core/src/mcp/index.d.ts +10 -0
- package/dist/internal/codex/core/src/mcp/manager.d.ts +73 -0
- package/dist/internal/codex/core/src/mcp/types.d.ts +165 -0
- package/dist/internal/codex/core/src/mcp.d.ts +1 -0
- package/dist/internal/codex/core/src/memory.d.ts +21 -0
- package/dist/internal/codex/core/src/model-provider.d.ts +193 -0
- package/dist/internal/codex/core/src/models.d.ts +158 -0
- package/dist/internal/codex/core/src/plan-mode.d.ts +1 -0
- package/dist/internal/codex/core/src/protocol/dynamic_tools.d.ts +48 -0
- package/dist/internal/codex/core/src/protocol/user_input.d.ts +30 -0
- package/dist/internal/codex/core/src/protocol.d.ts +893 -0
- package/dist/internal/codex/core/src/rendered-thread.d.ts +30 -0
- package/dist/internal/codex/core/src/request_permissions.d.ts +52 -0
- package/dist/internal/codex/core/src/request_user_input.d.ts +47 -0
- package/dist/internal/codex/core/src/session/rollout-reconstruction.d.ts +11 -0
- package/dist/internal/codex/core/src/session/session-settings.d.ts +29 -0
- package/dist/internal/codex/core/src/session/session.d.ts +226 -0
- package/dist/internal/codex/core/src/session/turn-context.d.ts +71 -0
- package/dist/internal/codex/core/src/session/turn-timing.d.ts +12 -0
- package/dist/internal/codex/core/src/session/turn.d.ts +35 -0
- package/dist/internal/codex/core/src/state/session.d.ts +40 -0
- package/dist/internal/codex/core/src/state/turn.d.ts +83 -0
- package/dist/internal/codex/core/src/stream-parser.d.ts +36 -0
- package/dist/internal/codex/core/src/stream_events_utils.d.ts +43 -0
- package/dist/internal/codex/core/src/tasks/compact.d.ts +26 -0
- package/dist/internal/codex/core/src/tasks/mod.d.ts +43 -0
- package/dist/internal/codex/core/src/tasks/regular.d.ts +27 -0
- package/dist/internal/codex/core/src/templates.d.ts +12 -0
- package/dist/{thread-history-builder-zW0zeqcS.d.ts → internal/codex/core/src/thread-history-builder.d.ts} +14 -16
- package/dist/internal/codex/core/src/thread-store/index.d.ts +3 -0
- package/dist/{live-thread-BMvlflzM.d.ts → internal/codex/core/src/thread-store/live-thread.d.ts} +7 -8
- package/dist/{store-AGRxhgQ3.d.ts → internal/codex/core/src/thread-store/store.d.ts} +3 -6
- package/dist/{types-BTeabLYr.d.ts → internal/codex/core/src/thread-store/types.d.ts} +25 -26
- package/dist/internal/codex/core/src/tools/code_mode/execute_handler.d.ts +7 -0
- package/dist/internal/codex/core/src/tools/code_mode/execute_spec.d.ts +13 -0
- package/dist/internal/codex/core/src/tools/code_mode/mod.d.ts +5 -0
- package/dist/internal/codex/core/src/tools/code_mode/response_adapter.d.ts +2 -0
- package/dist/internal/codex/core/src/tools/code_mode/wait_handler.d.ts +7 -0
- package/dist/internal/codex/core/src/tools/code_mode/wait_spec.d.ts +13 -0
- package/dist/internal/codex/core/src/tools/context.d.ts +155 -0
- package/dist/internal/codex/core/src/tools/events.d.ts +50 -0
- package/dist/internal/codex/core/src/tools/handlers/apply_patch.d.ts +14 -0
- package/dist/internal/codex/core/src/tools/handlers/apply_patch_spec.d.ts +16 -0
- package/dist/internal/codex/core/src/tools/handlers/dynamic.d.ts +17 -0
- package/dist/internal/codex/core/src/tools/handlers/goal.d.ts +20 -0
- package/dist/internal/codex/core/src/tools/handlers/goal_spec.d.ts +51 -0
- package/dist/internal/codex/core/src/tools/handlers/mcp.d.ts +23 -0
- package/dist/internal/codex/core/src/tools/handlers/mcp_resource.d.ts +24 -0
- package/dist/internal/codex/core/src/tools/handlers/mcp_resource_spec.d.ts +61 -0
- package/dist/internal/codex/core/src/tools/handlers/multi_agents.d.ts +50 -0
- package/dist/internal/codex/core/src/tools/handlers/multi_agents_common.d.ts +3 -0
- package/dist/internal/codex/core/src/tools/handlers/multi_agents_spec.d.ts +5 -0
- package/dist/internal/codex/core/src/tools/handlers/multi_agents_v2.d.ts +1 -0
- package/dist/internal/codex/core/src/tools/handlers/plan.d.ts +8 -0
- package/dist/internal/codex/core/src/tools/handlers/plan_spec.d.ts +35 -0
- package/dist/internal/codex/core/src/tools/handlers/request_permissions.d.ts +7 -0
- package/dist/internal/codex/core/src/tools/handlers/request_permissions_spec.d.ts +1 -0
- package/dist/internal/codex/core/src/tools/handlers/request_plugin_install.d.ts +8 -0
- package/dist/internal/codex/core/src/tools/handlers/request_plugin_install_spec.d.ts +12 -0
- package/dist/internal/codex/core/src/tools/handlers/request_user_input.d.ts +13 -0
- package/dist/internal/codex/core/src/tools/handlers/request_user_input_spec.d.ts +1 -0
- package/dist/internal/codex/core/src/tools/handlers/shell_spec.d.ts +60 -0
- package/dist/internal/codex/core/src/tools/handlers/test_sync.d.ts +1 -0
- package/dist/internal/codex/core/src/tools/handlers/test_sync_spec.d.ts +12 -0
- package/dist/internal/codex/core/src/tools/handlers/tool_search.d.ts +28 -0
- package/dist/internal/codex/core/src/tools/handlers/tool_search_spec.d.ts +21 -0
- package/dist/internal/codex/core/src/tools/handlers/unavailable_tool.d.ts +10 -0
- package/dist/internal/codex/core/src/tools/handlers/unified_exec/exec_command.d.ts +13 -0
- package/dist/internal/codex/core/src/tools/handlers/unified_exec/write_stdin.d.ts +8 -0
- package/dist/internal/codex/core/src/tools/handlers/unified_exec.d.ts +2 -0
- package/dist/internal/codex/core/src/tools/hook_names.d.ts +6 -0
- package/dist/internal/codex/core/src/tools/hosted_spec.d.ts +9 -0
- package/dist/internal/codex/core/src/tools/network_approval.d.ts +11 -0
- package/dist/internal/codex/core/src/tools/orchestrator.d.ts +28 -0
- package/dist/internal/codex/core/src/tools/parallel.d.ts +33 -0
- package/dist/internal/codex/core/src/tools/registry.d.ts +27 -0
- package/dist/internal/codex/core/src/tools/responses_api.d.ts +34 -0
- package/dist/internal/codex/core/src/tools/router.d.ts +50 -0
- package/dist/internal/codex/core/src/tools/runtimes/apply_patch.d.ts +2 -0
- package/dist/internal/codex/core/src/tools/runtimes/mod.d.ts +4 -0
- package/dist/internal/codex/core/src/tools/runtimes/shell.d.ts +2 -0
- package/dist/internal/codex/core/src/tools/runtimes/unified_exec.d.ts +2 -0
- package/dist/internal/codex/core/src/tools/sandboxing.d.ts +36 -0
- package/dist/internal/codex/core/src/tools/spec.d.ts +10 -0
- package/dist/internal/codex/core/src/tools/spec_plan.d.ts +2 -0
- package/dist/internal/codex/core/src/tools/spec_plan_types.d.ts +93 -0
- package/dist/internal/codex/core/src/tools/tool_dispatch_trace.d.ts +12 -0
- package/dist/internal/codex/core/src/tools/tool_name.d.ts +17 -0
- package/dist/internal/codex/core/src/tools/tool_search_entry.d.ts +35 -0
- package/dist/internal/codex/core/src/tools/tool_spec.d.ts +29 -0
- package/dist/{mod-DYVLSWO4.d.ts → internal/codex/thread-store/src/in_memory.d.ts} +8 -39
- package/dist/internal/codex/thread-store/src/index.d.ts +6 -0
- package/dist/internal/codex/thread-store/src/local/mod.d.ts +32 -0
- package/dist/internal/codex/utils/output-truncation/src/lib.d.ts +19 -0
- package/dist/internal/codex/utils/string/src/lib.d.ts +1 -0
- package/dist/internal/codex/utils/string/src/truncate.d.ts +5 -0
- package/dist/runtime/index.d.ts +47 -0
- package/dist/server/index.d.ts +2 -29
- package/dist/server/index.js +20488 -15
- package/dist/testing/index.d.ts +2 -9
- package/dist/testing/index.js +1698 -15
- package/package.json +9 -100
- package/dist/ClientNotification-B6-FhXQf.d.ts +0 -5
- package/dist/DynamicToolCallResponse-82DFjES2.d.ts +0 -8
- package/dist/DynamicToolSpec-CfnhqAYK.d.ts +0 -29
- package/dist/PermissionsRequestApprovalResponse-DxzPPDRb.d.ts +0 -55
- package/dist/ProviderStatusBanner-BlP6lzwE.d.ts +0 -441
- package/dist/ServerRequest-B5cKVJjr.d.ts +0 -2181
- package/dist/ThreadResumeResponse-DvmE1juU.d.ts +0 -1542
- package/dist/ToolRequestUserInputQuestion-CeZa5X1J.d.ts +0 -23
- package/dist/ToolRequestUserInputResponse-zcPLwbiK.d.ts +0 -17
- package/dist/TurnSteerResponse-0kBCfplh.d.ts +0 -209
- package/dist/WebSearchToolConfig-D3ep0625.d.ts +0 -18
- package/dist/chat-runtime-B6azJyKo.d.ts +0 -381
- package/dist/chunk-2DZRMCI2.js +0 -1258
- package/dist/chunk-2DZRMCI2.js.map +0 -1
- package/dist/chunk-4DPLJPB5.js +0 -396
- package/dist/chunk-4DPLJPB5.js.map +0 -1
- package/dist/chunk-5JMJ6OI5.js +0 -3
- package/dist/chunk-5JMJ6OI5.js.map +0 -1
- package/dist/chunk-6ZMJ34KE.js +0 -1153
- package/dist/chunk-6ZMJ34KE.js.map +0 -1
- package/dist/chunk-CGBS37IU.js +0 -128
- package/dist/chunk-CGBS37IU.js.map +0 -1
- package/dist/chunk-DCMKA2A6.js +0 -18
- package/dist/chunk-DCMKA2A6.js.map +0 -1
- package/dist/chunk-DYLHN3HG.js +0 -937
- package/dist/chunk-DYLHN3HG.js.map +0 -1
- package/dist/chunk-FN3SWHRH.js +0 -934
- package/dist/chunk-FN3SWHRH.js.map +0 -1
- package/dist/chunk-ILXA6HLX.js +0 -1973
- package/dist/chunk-ILXA6HLX.js.map +0 -1
- package/dist/chunk-LWQNX4LI.js +0 -13755
- package/dist/chunk-LWQNX4LI.js.map +0 -1
- package/dist/chunk-NCI4MAWZ.js +0 -7733
- package/dist/chunk-NCI4MAWZ.js.map +0 -1
- package/dist/chunk-O44XP7LH.js +0 -214
- package/dist/chunk-O44XP7LH.js.map +0 -1
- package/dist/chunk-PST3ZWX2.js +0 -555
- package/dist/chunk-PST3ZWX2.js.map +0 -1
- package/dist/chunk-SYPHCDRD.js +0 -1133
- package/dist/chunk-SYPHCDRD.js.map +0 -1
- package/dist/chunk-V4BMZWBM.js +0 -2401
- package/dist/chunk-V4BMZWBM.js.map +0 -1
- package/dist/chunk-YHVCFD2D.js +0 -117
- package/dist/chunk-YHVCFD2D.js.map +0 -1
- package/dist/chunk-Z63UPBS3.js +0 -152
- package/dist/chunk-Z63UPBS3.js.map +0 -1
- package/dist/chunk-ZX5OIIJX.js +0 -3
- package/dist/chunk-ZX5OIIJX.js.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/codex-rs/app-server/index.d.ts +0 -161
- package/dist/codex-rs/app-server/index.js +0 -13
- package/dist/codex-rs/app-server/index.js.map +0 -1
- package/dist/codex-rs/app-server-protocol/index.d.ts +0 -1722
- package/dist/codex-rs/app-server-protocol/index.js +0 -6
- package/dist/codex-rs/app-server-protocol/index.js.map +0 -1
- package/dist/codex-rs/app-server-protocol/protocol.d.ts +0 -19
- package/dist/codex-rs/app-server-protocol/protocol.js +0 -4
- package/dist/codex-rs/app-server-protocol/protocol.js.map +0 -1
- package/dist/codex-rs/codex-api/index.d.ts +0 -104
- package/dist/codex-rs/codex-api/index.js +0 -11
- package/dist/codex-rs/codex-api/index.js.map +0 -1
- package/dist/codex-rs/config/index.d.ts +0 -88
- package/dist/codex-rs/config/index.js +0 -4
- package/dist/codex-rs/config/index.js.map +0 -1
- package/dist/codex-rs/core/config/index.d.ts +0 -61
- package/dist/codex-rs/core/config/index.js +0 -5
- package/dist/codex-rs/core/config/index.js.map +0 -1
- package/dist/codex-rs/core/index.d.ts +0 -1393
- package/dist/codex-rs/core/index.js +0 -11
- package/dist/codex-rs/core/index.js.map +0 -1
- package/dist/codex-rs/model-provider/index.d.ts +0 -2
- package/dist/codex-rs/model-provider/index.js +0 -4
- package/dist/codex-rs/model-provider/index.js.map +0 -1
- package/dist/codex-rs/models-manager/index.d.ts +0 -2
- package/dist/codex-rs/models-manager/index.js +0 -4
- package/dist/codex-rs/models-manager/index.js.map +0 -1
- package/dist/codex-rs/parity.d.ts +0 -26
- package/dist/codex-rs/parity.js +0 -3
- package/dist/codex-rs/parity.js.map +0 -1
- package/dist/codex-rs/thread-store/index.d.ts +0 -5
- package/dist/codex-rs/thread-store/index.js +0 -4
- package/dist/codex-rs/thread-store/index.js.map +0 -1
- package/dist/codex-rs/unsupported.d.ts +0 -15
- package/dist/codex-rs/unsupported.js +0 -22
- package/dist/codex-rs/unsupported.js.map +0 -1
- package/dist/codex-rs/utils/output-truncation.d.ts +0 -21
- package/dist/codex-rs/utils/output-truncation.js +0 -4
- package/dist/codex-rs/utils/output-truncation.js.map +0 -1
- package/dist/codex-rs/utils/string.d.ts +0 -7
- package/dist/codex-rs/utils/string.js +0 -3
- package/dist/codex-rs/utils/string.js.map +0 -1
- package/dist/common-CTyph5x8.d.ts +0 -40
- package/dist/event-mapping-CbISdQ1D.d.ts +0 -43
- package/dist/history-CfM-4V7b.d.ts +0 -1654
- package/dist/index-CoDZosq0.d.ts +0 -261
- package/dist/index.js.map +0 -1
- package/dist/lib-nXlaKiS-.d.ts +0 -48
- package/dist/merge-B_AWVmnI.d.ts +0 -24
- package/dist/plan-mode-Cv6KWb_S.d.ts +0 -14
- package/dist/proposed-plan-DpN1ma0Y.d.ts +0 -53
- package/dist/protocol-mpBcYHrm.d.ts +0 -1655
- package/dist/react/index.d.ts +0 -41
- package/dist/react/index.js +0 -19
- package/dist/react/index.js.map +0 -1
- package/dist/remote-ClZbq9KN.d.ts +0 -21
- package/dist/rendered-thread-AOxw3V5b.d.ts +0 -29
- package/dist/responses_websocket-BhxSgCzK.d.ts +0 -183
- package/dist/runtime-Cm6ml53h.d.ts +0 -528
- package/dist/server/index.js.map +0 -1
- package/dist/shadcn/index.d.ts +0 -68
- package/dist/shadcn/index.js +0 -334
- package/dist/shadcn/index.js.map +0 -1
- package/dist/sidebar-DMMij22z.d.ts +0 -87
- package/dist/spec_plan_types-CmsJ-Tfn.d.ts +0 -260
- package/dist/styles.css +0 -1
- package/dist/t3code/apps/web/components/chat.d.ts +0 -508
- package/dist/t3code/apps/web/components/chat.js +0 -12
- package/dist/t3code/apps/web/components/chat.js.map +0 -1
- package/dist/t3code/apps/web/index.d.ts +0 -12
- package/dist/t3code/apps/web/index.js +0 -13
- package/dist/t3code/apps/web/index.js.map +0 -1
- package/dist/testing/index.js.map +0 -1
package/dist/client/index.js
CHANGED
|
@@ -1,16 +1,2522 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
// src/internal/codex/core/src/protocol.ts
|
|
2
|
+
var BASE_INSTRUCTIONS_DEFAULT = `You are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI on a user's computer.
|
|
3
|
+
|
|
4
|
+
## General
|
|
5
|
+
|
|
6
|
+
- Prefer to be concise, direct, and useful.
|
|
7
|
+
- When asked to modify code, inspect the repository first and follow existing patterns.
|
|
8
|
+
- Do not make unrelated changes.
|
|
9
|
+
- If you run commands or edit files, summarize what changed and how you verified it.`;
|
|
10
|
+
|
|
11
|
+
// src/internal/codex/app-server-protocol/src/protocol/event-mapping.ts
|
|
12
|
+
function durationMsFromString(value) {
|
|
13
|
+
if (!value) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const parsed = Number.parseFloat(value);
|
|
17
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
18
|
+
}
|
|
19
|
+
function threadTokenUsageFromTokenUsageInfo(info) {
|
|
20
|
+
return {
|
|
21
|
+
total: appServerTokenUsageBreakdown(info.total_token_usage),
|
|
22
|
+
last: appServerTokenUsageBreakdown(info.last_token_usage),
|
|
23
|
+
modelContextWindow: info.model_context_window ?? null
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function appServerTokenUsageBreakdown(usage) {
|
|
27
|
+
return {
|
|
28
|
+
totalTokens: usage.total_tokens,
|
|
29
|
+
inputTokens: usage.input_tokens,
|
|
30
|
+
cachedInputTokens: usage.cached_input_tokens,
|
|
31
|
+
outputTokens: usage.output_tokens,
|
|
32
|
+
reasoningOutputTokens: usage.reasoning_output_tokens
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function appServerUserInputsFromCore(inputs) {
|
|
36
|
+
return inputs.map((input) => {
|
|
37
|
+
if (input.type === "text") {
|
|
38
|
+
return {
|
|
39
|
+
type: "text",
|
|
40
|
+
text: input.text,
|
|
41
|
+
text_elements: appServerTextElementsFromCore(input.text_elements ?? [])
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (input.type === "image") {
|
|
45
|
+
return { type: "image", url: input.image_url };
|
|
46
|
+
}
|
|
47
|
+
if (input.type === "local_image") {
|
|
48
|
+
return { type: "localImage", path: input.path };
|
|
49
|
+
}
|
|
50
|
+
return input;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function appServerTextElementsFromCore(elements) {
|
|
54
|
+
return elements.map((element) => ({
|
|
55
|
+
byteRange: element.byte_range,
|
|
56
|
+
placeholder: element.placeholder ?? null
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
function appServerMessagePhase(value) {
|
|
60
|
+
return value === "commentary" || value === "final_answer" ? value : null;
|
|
61
|
+
}
|
|
62
|
+
function appServerMemoryCitationFromCore(citation) {
|
|
63
|
+
return citation ? {
|
|
64
|
+
entries: citation.entries,
|
|
65
|
+
threadIds: citation.rolloutIds ?? []
|
|
66
|
+
} : null;
|
|
67
|
+
}
|
|
68
|
+
function coreTurnItemToThreadItem(item) {
|
|
69
|
+
if (!item || typeof item !== "object" || !("type" in item)) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const value = item;
|
|
73
|
+
switch (value.type) {
|
|
74
|
+
case "UserMessage":
|
|
75
|
+
return {
|
|
76
|
+
type: "userMessage",
|
|
77
|
+
id: String(value.id ?? ""),
|
|
78
|
+
content: appServerUserInputsFromCore(value.content ?? [])
|
|
79
|
+
};
|
|
80
|
+
case "AgentMessage":
|
|
81
|
+
return {
|
|
82
|
+
type: "agentMessage",
|
|
83
|
+
id: String(value.id ?? ""),
|
|
84
|
+
text: (value.content ?? []).map((part) => part.text ?? "").join(""),
|
|
85
|
+
phase: appServerMessagePhase(value.phase),
|
|
86
|
+
memoryCitation: appServerMemoryCitationFromCore(
|
|
87
|
+
value.memory_citation ?? null
|
|
88
|
+
)
|
|
89
|
+
};
|
|
90
|
+
case "Plan":
|
|
91
|
+
return {
|
|
92
|
+
type: "plan",
|
|
93
|
+
id: String(value.id ?? ""),
|
|
94
|
+
text: String(value.text ?? "")
|
|
95
|
+
};
|
|
96
|
+
case "Reasoning":
|
|
97
|
+
return {
|
|
98
|
+
type: "reasoning",
|
|
99
|
+
id: String(value.id ?? ""),
|
|
100
|
+
summary: value.summary_text ?? [],
|
|
101
|
+
content: value.raw_content ?? []
|
|
102
|
+
};
|
|
103
|
+
case "WebSearch": {
|
|
104
|
+
const action = appServerWebSearchAction(value.action);
|
|
105
|
+
return {
|
|
106
|
+
type: "webSearch",
|
|
107
|
+
id: String(value.id ?? ""),
|
|
108
|
+
query: typeof value.query === "string" ? value.query : webSearchActionDetail(action),
|
|
109
|
+
action
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
case "CommandExecution":
|
|
113
|
+
return {
|
|
114
|
+
type: "commandExecution",
|
|
115
|
+
id: String(value.id ?? ""),
|
|
116
|
+
command: (value.command ?? []).join(" "),
|
|
117
|
+
cwd: String(value.cwd ?? ""),
|
|
118
|
+
processId: null,
|
|
119
|
+
source: "agent",
|
|
120
|
+
status: commandStatusToAppServer(value.status),
|
|
121
|
+
commandActions: [],
|
|
122
|
+
aggregatedOutput: [value.stdout, value.stderr].filter(Boolean).join("") || null,
|
|
123
|
+
exitCode: typeof value.exit_code === "number" ? value.exit_code : null,
|
|
124
|
+
durationMs: typeof value.duration_ms === "number" ? value.duration_ms : null
|
|
125
|
+
};
|
|
126
|
+
case "FileChange":
|
|
127
|
+
return {
|
|
128
|
+
type: "fileChange",
|
|
129
|
+
id: String(value.id ?? ""),
|
|
130
|
+
changes: [],
|
|
131
|
+
status: value.status ?? "completed"
|
|
132
|
+
};
|
|
133
|
+
case "DynamicToolCall":
|
|
134
|
+
return {
|
|
135
|
+
type: "dynamicToolCall",
|
|
136
|
+
id: String(value.id ?? ""),
|
|
137
|
+
namespace: value.namespace ?? null,
|
|
138
|
+
tool: String(value.tool ?? ""),
|
|
139
|
+
arguments: value.arguments ?? null,
|
|
140
|
+
status: dynamicToolStatusToAppServer(value.status),
|
|
141
|
+
contentItems: value.content_items ?? null,
|
|
142
|
+
success: value.success ?? null,
|
|
143
|
+
durationMs: durationMsFromString(value.duration)
|
|
144
|
+
};
|
|
145
|
+
case "ContextCompaction":
|
|
146
|
+
return {
|
|
147
|
+
type: "contextCompaction",
|
|
148
|
+
id: String(value.id ?? "")
|
|
149
|
+
};
|
|
150
|
+
default:
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function appServerWebSearchAction(action) {
|
|
155
|
+
if (!action || typeof action !== "object") {
|
|
156
|
+
return { type: "other" };
|
|
157
|
+
}
|
|
158
|
+
const record = action;
|
|
159
|
+
if (record.type === "search") {
|
|
160
|
+
return {
|
|
161
|
+
type: "search",
|
|
162
|
+
query: typeof record.query === "string" ? record.query : null,
|
|
163
|
+
queries: Array.isArray(record.queries) ? record.queries.filter((query) => typeof query === "string") : null
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (record.type === "open_page" || record.type === "openPage") {
|
|
167
|
+
return {
|
|
168
|
+
type: "openPage",
|
|
169
|
+
url: typeof record.url === "string" ? record.url : null
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (record.type === "find_in_page" || record.type === "findInPage") {
|
|
173
|
+
return {
|
|
174
|
+
type: "findInPage",
|
|
175
|
+
url: typeof record.url === "string" ? record.url : null,
|
|
176
|
+
pattern: typeof record.pattern === "string" ? record.pattern : null
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return { type: "other" };
|
|
180
|
+
}
|
|
181
|
+
function webSearchActionDetail(action) {
|
|
182
|
+
switch (action.type) {
|
|
183
|
+
case "search":
|
|
184
|
+
return action.query ?? action.queries?.join(", ") ?? "";
|
|
185
|
+
case "openPage":
|
|
186
|
+
return action.url ?? "";
|
|
187
|
+
case "findInPage": {
|
|
188
|
+
const pattern = action.pattern ?? "";
|
|
189
|
+
const url = action.url ?? "";
|
|
190
|
+
return pattern && url ? `'${pattern}' in ${url}` : pattern || url;
|
|
191
|
+
}
|
|
192
|
+
case "other":
|
|
193
|
+
return "";
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function commandStatusToAppServer(value) {
|
|
197
|
+
if (value === "completed" || value === "failed") {
|
|
198
|
+
return value;
|
|
199
|
+
}
|
|
200
|
+
if (value === "cancelled") {
|
|
201
|
+
return "failed";
|
|
202
|
+
}
|
|
203
|
+
return "inProgress";
|
|
204
|
+
}
|
|
205
|
+
function dynamicToolStatusToAppServer(value) {
|
|
206
|
+
if (value === "completed" || value === "failed") {
|
|
207
|
+
return value;
|
|
208
|
+
}
|
|
209
|
+
return "inProgress";
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/internal/codex/core/src/event-mapping.ts
|
|
213
|
+
function isContextualUserMessageContent(message) {
|
|
214
|
+
return message.some(isContextualUserFragment);
|
|
215
|
+
}
|
|
216
|
+
function parseUserMessage(id, message) {
|
|
217
|
+
if (isContextualUserMessageContent(message)) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
const content = [];
|
|
221
|
+
for (const [index, contentItem] of message.entries()) {
|
|
222
|
+
if (contentItem.type === "input_text") {
|
|
223
|
+
if ((isLocalImageOpenTagText(contentItem.text) || isImageOpenTagText(contentItem.text)) && message[index + 1]?.type === "input_image" || index > 0 && (isLocalImageCloseTagText(contentItem.text) || isImageCloseTagText(contentItem.text)) && message[index - 1]?.type === "input_image") {
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
content.push({
|
|
227
|
+
type: "text",
|
|
228
|
+
text: contentItem.text,
|
|
229
|
+
text_elements: []
|
|
230
|
+
});
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (contentItem.type === "input_image") {
|
|
234
|
+
content.push({
|
|
235
|
+
type: "image",
|
|
236
|
+
image_url: contentItem.image_url
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
type: "UserMessage",
|
|
242
|
+
id: id ?? "",
|
|
243
|
+
content
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function parseAgentMessage(id, message, phase) {
|
|
247
|
+
const content = [];
|
|
248
|
+
for (const contentItem of message) {
|
|
249
|
+
if (contentItem.type === "input_text" || contentItem.type === "output_text") {
|
|
250
|
+
content.push({ type: "Text", text: contentItem.text });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
type: "AgentMessage",
|
|
255
|
+
id: id ?? "",
|
|
256
|
+
content,
|
|
257
|
+
phase: phase ?? null,
|
|
258
|
+
memory_citation: null
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function parseVisibleHookPromptMessage(id, message) {
|
|
262
|
+
const fragments = [];
|
|
263
|
+
for (const contentItem of message) {
|
|
264
|
+
if (contentItem.type !== "input_text") {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
const fragment = parseHookPromptFragment(contentItem.text);
|
|
268
|
+
if (fragment) {
|
|
269
|
+
fragments.push(fragment);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (isStandardContextualUserText(contentItem.text)) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
if (fragments.length === 0) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
type: "HookPrompt",
|
|
282
|
+
id: id ?? "",
|
|
283
|
+
fragments
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function parseTurnItem(item) {
|
|
287
|
+
switch (item.type) {
|
|
288
|
+
case "message":
|
|
289
|
+
if (item.role === "user") {
|
|
290
|
+
return parseVisibleHookPromptMessage(item.id, item.content) ?? parseUserMessage(item.id, item.content);
|
|
291
|
+
}
|
|
292
|
+
if (item.role === "assistant" || !item.role) {
|
|
293
|
+
return parseAgentMessage(item.id, item.content, item.phase);
|
|
294
|
+
}
|
|
295
|
+
return null;
|
|
296
|
+
case "reasoning":
|
|
297
|
+
return parseReasoningItem(item);
|
|
298
|
+
case "web_search_call":
|
|
299
|
+
return parseWebSearchCall(item);
|
|
300
|
+
case "image_generation_call":
|
|
301
|
+
return parseImageGenerationCall(item);
|
|
302
|
+
default:
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function parseReasoningItem(item) {
|
|
307
|
+
return {
|
|
308
|
+
type: "Reasoning",
|
|
309
|
+
id: item.id ?? "",
|
|
310
|
+
summary_text: item.summary.flatMap((entry) => {
|
|
311
|
+
if (typeof entry.text === "string") {
|
|
312
|
+
return [entry.text];
|
|
313
|
+
}
|
|
314
|
+
return [];
|
|
315
|
+
}),
|
|
316
|
+
raw_content: (item.content ?? []).flatMap((entry) => {
|
|
317
|
+
if ((entry.type === "reasoning_text" || entry.type === "text") && typeof entry.text === "string") {
|
|
318
|
+
return [entry.text];
|
|
319
|
+
}
|
|
320
|
+
return [];
|
|
321
|
+
})
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function parseWebSearchCall(item) {
|
|
325
|
+
const action = webSearchActionFromRecord(item.action);
|
|
326
|
+
return {
|
|
327
|
+
type: "WebSearch",
|
|
328
|
+
id: item.id ?? "",
|
|
329
|
+
query: webSearchActionDetail2(action),
|
|
330
|
+
action
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function parseImageGenerationCall(item) {
|
|
334
|
+
return {
|
|
335
|
+
type: "ImageGeneration",
|
|
336
|
+
id: item.id,
|
|
337
|
+
status: item.status,
|
|
338
|
+
revised_prompt: item.revised_prompt ?? void 0,
|
|
339
|
+
result: item.result,
|
|
340
|
+
saved_path: item.saved_path
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function webSearchActionFromRecord(action) {
|
|
344
|
+
if (!action) {
|
|
345
|
+
return { type: "other" };
|
|
346
|
+
}
|
|
347
|
+
if (action.type === "search") {
|
|
348
|
+
return {
|
|
349
|
+
type: "search",
|
|
350
|
+
...typeof action.query === "string" ? { query: action.query } : {},
|
|
351
|
+
...Array.isArray(action.queries) ? { queries: action.queries.filter(isString) } : {}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
if (action.type === "open_page") {
|
|
355
|
+
return {
|
|
356
|
+
type: "open_page",
|
|
357
|
+
...typeof action.url === "string" ? { url: action.url } : {}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
if (action.type === "find_in_page") {
|
|
361
|
+
return {
|
|
362
|
+
type: "find_in_page",
|
|
363
|
+
...typeof action.url === "string" ? { url: action.url } : {},
|
|
364
|
+
...typeof action.pattern === "string" ? { pattern: action.pattern } : {}
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
return { type: "other" };
|
|
368
|
+
}
|
|
369
|
+
function webSearchActionDetail2(action) {
|
|
370
|
+
switch (action.type) {
|
|
371
|
+
case "search":
|
|
372
|
+
return action.query ?? action.queries?.join(", ") ?? "";
|
|
373
|
+
case "open_page":
|
|
374
|
+
return action.url ?? "";
|
|
375
|
+
case "find_in_page": {
|
|
376
|
+
const pattern = action.pattern ?? "";
|
|
377
|
+
const url = action.url ?? "";
|
|
378
|
+
return pattern && url ? `'${pattern}' in ${url}` : pattern || url;
|
|
379
|
+
}
|
|
380
|
+
case "other":
|
|
381
|
+
return "";
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function isContextualUserFragment(contentItem) {
|
|
385
|
+
return contentItem.type === "input_text" && (parseHookPromptFragment(contentItem.text) !== null || isStandardContextualUserText(contentItem.text));
|
|
386
|
+
}
|
|
387
|
+
function isStandardContextualUserText(text) {
|
|
388
|
+
const trimmed = text.trimStart();
|
|
389
|
+
return trimmed.startsWith("# AGENTS.md instructions for ") || trimmed.startsWith("<environment_context>") || trimmed.startsWith("<skill>") || trimmed.startsWith("<user_shell_command>") || trimmed.startsWith("<turn_aborted>") || trimmed.startsWith("<thread_goal_budget_limit>") || trimmed.startsWith("<subagent_notification>");
|
|
390
|
+
}
|
|
391
|
+
function parseHookPromptFragment(text) {
|
|
392
|
+
const trimmed = text.trim();
|
|
393
|
+
const match = trimmed.match(
|
|
394
|
+
/^<hook_prompt\s+hook_run_id=(["'])(.*?)\1>([\s\S]*)<\/hook_prompt>$/u
|
|
395
|
+
);
|
|
396
|
+
if (!match) {
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
const hookRunId = decodeXmlEntities(match[2] ?? "").trim();
|
|
400
|
+
if (!hookRunId) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
hookRunId,
|
|
405
|
+
text: decodeXmlEntities(match[3] ?? "")
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
function isImageOpenTagText(text) {
|
|
409
|
+
return text === "<image>";
|
|
410
|
+
}
|
|
411
|
+
function isImageCloseTagText(text) {
|
|
412
|
+
return text === "</image>";
|
|
413
|
+
}
|
|
414
|
+
function isLocalImageOpenTagText(text) {
|
|
415
|
+
return text.startsWith("<image name=") && text.endsWith(">");
|
|
416
|
+
}
|
|
417
|
+
function isLocalImageCloseTagText(text) {
|
|
418
|
+
return isImageCloseTagText(text);
|
|
419
|
+
}
|
|
420
|
+
function decodeXmlEntities(value) {
|
|
421
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll(""", '"').replaceAll("'", "'");
|
|
422
|
+
}
|
|
423
|
+
function isString(value) {
|
|
424
|
+
return typeof value === "string";
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// src/internal/codex/core/src/thread-history-builder.ts
|
|
428
|
+
var ThreadHistoryBuilder = class _ThreadHistoryBuilder {
|
|
429
|
+
turns = [];
|
|
430
|
+
next_item_index = 1;
|
|
431
|
+
static fromTurns(turns) {
|
|
432
|
+
const builder = new _ThreadHistoryBuilder();
|
|
433
|
+
builder.turns = turns.map((turn) => ({
|
|
434
|
+
...cloneTurn(turn),
|
|
435
|
+
opened_explicitly: true
|
|
436
|
+
}));
|
|
437
|
+
builder.next_item_index = nextItemIndexFromTurns(turns);
|
|
438
|
+
return builder;
|
|
439
|
+
}
|
|
440
|
+
handle_rollout_item(item, index = this.next_item_index) {
|
|
441
|
+
if (item.type === "event_msg") {
|
|
442
|
+
this.handle_event(item.payload, `rollout-${index}`);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (item.type === "response_item") {
|
|
446
|
+
this.handle_response_item(item.payload, `response-${index}`);
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (item.type === "compacted") {
|
|
450
|
+
this.append_to_current_turn({
|
|
451
|
+
type: "ContextCompaction",
|
|
452
|
+
id: `compacted-${index}`
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
handle_event(event, eventId = `event-${this.next_item_index}`) {
|
|
457
|
+
switch (event.type) {
|
|
458
|
+
case "turn_started":
|
|
459
|
+
this.open_explicit_turn(event.turn_id);
|
|
460
|
+
if (event.started_at !== void 0 && event.started_at !== null) {
|
|
461
|
+
const turn = this.turn_by_id(event.turn_id);
|
|
462
|
+
if (turn) {
|
|
463
|
+
turn.started_at = event.started_at;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return;
|
|
467
|
+
case "turn_complete":
|
|
468
|
+
this.complete_turn(event.turn_id, {
|
|
469
|
+
status: "completed",
|
|
470
|
+
completed_at: event.completed_at ?? null,
|
|
471
|
+
duration_ms: event.duration_ms ?? null
|
|
472
|
+
});
|
|
473
|
+
return;
|
|
474
|
+
case "turn_aborted":
|
|
475
|
+
this.complete_turn(event.turn_id, {
|
|
476
|
+
status: "interrupted",
|
|
477
|
+
completed_at: event.completed_at ?? event.aborted_at ?? null,
|
|
478
|
+
duration_ms: event.duration_ms ?? null
|
|
479
|
+
});
|
|
480
|
+
return;
|
|
481
|
+
case "user_message":
|
|
482
|
+
this.append_user_message(userMessageTurnItem(event, userMessageId(eventId)), {
|
|
483
|
+
replaceDuplicate: true
|
|
484
|
+
});
|
|
485
|
+
return;
|
|
486
|
+
case "agent_message":
|
|
487
|
+
this.upsert_agent_message({
|
|
488
|
+
type: "AgentMessage",
|
|
489
|
+
id: agentMessageId(eventId),
|
|
490
|
+
content: [{ type: "Text", text: event.message }],
|
|
491
|
+
phase: event.phase ?? null,
|
|
492
|
+
memory_citation: event.memory_citation ?? null
|
|
493
|
+
});
|
|
494
|
+
return;
|
|
495
|
+
case "item_started":
|
|
496
|
+
this.upsert_item_in_turn(event.turn_id, event.item, {
|
|
497
|
+
started: true
|
|
498
|
+
});
|
|
499
|
+
return;
|
|
500
|
+
case "item_completed":
|
|
501
|
+
this.upsert_item_in_turn(event.turn_id, completedItem(event.item));
|
|
502
|
+
return;
|
|
503
|
+
case "agent_message_content_delta":
|
|
504
|
+
this.apply_agent_message_delta(event.item_id, event.delta);
|
|
505
|
+
return;
|
|
506
|
+
case "plan_delta":
|
|
507
|
+
this.apply_plan_delta(event.item_id, event.delta);
|
|
508
|
+
return;
|
|
509
|
+
case "exec_command_begin":
|
|
510
|
+
this.upsert_item_in_turn(event.turn_id, {
|
|
511
|
+
type: "CommandExecution",
|
|
512
|
+
id: event.call_id,
|
|
513
|
+
command: event.command,
|
|
514
|
+
cwd: event.cwd,
|
|
515
|
+
status: "in_progress"
|
|
516
|
+
});
|
|
517
|
+
return;
|
|
518
|
+
case "exec_command_output_delta":
|
|
519
|
+
this.apply_exec_command_output_delta(event);
|
|
520
|
+
return;
|
|
521
|
+
case "exec_command_end":
|
|
522
|
+
this.apply_exec_command_end(event);
|
|
523
|
+
return;
|
|
524
|
+
case "patch_apply_updated":
|
|
525
|
+
this.upsert_item_in_current_or_existing_turn(event.call_id, {
|
|
526
|
+
type: "FileChange",
|
|
527
|
+
id: event.call_id,
|
|
528
|
+
changes: event.changes,
|
|
529
|
+
status: event.status ?? null,
|
|
530
|
+
auto_approved: false,
|
|
531
|
+
stdout: event.stdout ?? "",
|
|
532
|
+
stderr: event.stderr ?? ""
|
|
533
|
+
});
|
|
534
|
+
return;
|
|
535
|
+
case "dynamic_tool_call_request":
|
|
536
|
+
this.upsert_item_in_turn(event.turn_id, dynamicToolRequestTurnItem(event));
|
|
537
|
+
return;
|
|
538
|
+
case "dynamic_tool_call_response":
|
|
539
|
+
this.upsert_item_in_turn(event.turn_id, {
|
|
540
|
+
type: "DynamicToolCall",
|
|
541
|
+
id: event.call_id,
|
|
542
|
+
namespace: event.namespace ?? null,
|
|
543
|
+
tool: event.tool,
|
|
544
|
+
arguments: event.arguments,
|
|
545
|
+
status: event.success ? "completed" : "failed",
|
|
546
|
+
content_items: event.content_items,
|
|
547
|
+
success: event.success,
|
|
548
|
+
duration: event.duration
|
|
549
|
+
});
|
|
550
|
+
return;
|
|
551
|
+
case "mcp_tool_call_progress":
|
|
552
|
+
this.upsert_item_in_turn(event.turn_id, {
|
|
553
|
+
type: "McpToolCall",
|
|
554
|
+
id: event.call_id,
|
|
555
|
+
server: event.server_name,
|
|
556
|
+
tool: event.tool_name,
|
|
557
|
+
arguments: {},
|
|
558
|
+
status: "inProgress",
|
|
559
|
+
result: event.progress ?? event.message ?? null
|
|
560
|
+
});
|
|
561
|
+
return;
|
|
562
|
+
case "image_generation_end":
|
|
563
|
+
this.upsert_item_in_current_or_existing_turn(
|
|
564
|
+
event.call_id,
|
|
565
|
+
imageGenerationTurnItem(event, eventId)
|
|
566
|
+
);
|
|
567
|
+
return;
|
|
568
|
+
case "error": {
|
|
569
|
+
const turn = this.active_turn();
|
|
570
|
+
if (turn) {
|
|
571
|
+
turn.status = "failed";
|
|
572
|
+
turn.error = {
|
|
573
|
+
message: event.message,
|
|
574
|
+
codex_error_info: event.codex_error_info ?? null
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
default:
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
handle_response_item(item, id) {
|
|
584
|
+
const turnItem = parseTurnItem(item);
|
|
585
|
+
if (!turnItem) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
const itemWithFallbackId = turnItem.id.length > 0 ? turnItem : { ...turnItem, id };
|
|
589
|
+
if (itemWithFallbackId.type === "AgentMessage") {
|
|
590
|
+
this.upsert_agent_message(itemWithFallbackId);
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (itemWithFallbackId.type === "UserMessage") {
|
|
594
|
+
this.append_user_message(itemWithFallbackId, {
|
|
595
|
+
replaceDuplicate: false
|
|
596
|
+
});
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
this.append_to_current_turn(itemWithFallbackId);
|
|
600
|
+
}
|
|
601
|
+
active_turn_snapshot() {
|
|
602
|
+
const turn = this.active_turn();
|
|
603
|
+
return turn ? stripInternalTurn(turn) : null;
|
|
604
|
+
}
|
|
605
|
+
active_turn_position() {
|
|
606
|
+
const turn = this.active_turn();
|
|
607
|
+
return turn ? this.turns.indexOf(turn) : null;
|
|
608
|
+
}
|
|
609
|
+
finish() {
|
|
610
|
+
return this.turns.map(stripInternalTurn);
|
|
611
|
+
}
|
|
612
|
+
has_active_turn() {
|
|
613
|
+
return this.active_turn() !== null;
|
|
614
|
+
}
|
|
615
|
+
reset() {
|
|
616
|
+
this.turns = [];
|
|
617
|
+
this.next_item_index = 1;
|
|
618
|
+
}
|
|
619
|
+
open_explicit_turn(turnId) {
|
|
620
|
+
const existing = this.turns.find((turn) => turn.id === turnId);
|
|
621
|
+
if (existing) {
|
|
622
|
+
existing.status = "in_progress";
|
|
623
|
+
existing.opened_explicitly = true;
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
this.turns.push(newTurn(turnId, true));
|
|
627
|
+
}
|
|
628
|
+
complete_turn(turnId, input) {
|
|
629
|
+
const turn = this.turn_by_id(turnId) ?? this.ensure_turn(turnId, true);
|
|
630
|
+
turn.status = input.status;
|
|
631
|
+
turn.completed_at = input.completed_at;
|
|
632
|
+
turn.duration_ms = input.duration_ms;
|
|
633
|
+
}
|
|
634
|
+
append_user_message(item, options) {
|
|
635
|
+
const active = this.active_turn();
|
|
636
|
+
if (!active || !active.opened_explicitly && active.items.length > 0) {
|
|
637
|
+
this.turns.push(newTurn(`turn-${this.turns.length + 1}`, false));
|
|
638
|
+
}
|
|
639
|
+
const turn = this.active_turn() ?? this.ensure_turn();
|
|
640
|
+
const lastItem = turn.items.at(-1);
|
|
641
|
+
if (lastItem?.type === "UserMessage" && userMessageFingerprint(lastItem) === userMessageFingerprint(item)) {
|
|
642
|
+
if (options.replaceDuplicate) {
|
|
643
|
+
turn.items[turn.items.length - 1] = item;
|
|
644
|
+
}
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
turn.items.push(item);
|
|
648
|
+
}
|
|
649
|
+
upsert_agent_message(item) {
|
|
650
|
+
const turn = this.ensure_turn();
|
|
651
|
+
const lastItem = turn.items.at(-1);
|
|
652
|
+
if (item.phase === "streaming") {
|
|
653
|
+
if (lastItem?.type === "AgentMessage" && lastItem.phase === "streaming") {
|
|
654
|
+
turn.items[turn.items.length - 1] = { ...item, id: lastItem.id };
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
turn.items.push({ ...item, id: `streaming-${item.id}` });
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
if (lastItem?.type === "AgentMessage" && lastItem.phase === "streaming") {
|
|
661
|
+
turn.items[turn.items.length - 1] = { ...item, id: lastItem.id };
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (lastItem?.type === "AgentMessage" && agentMessageText(lastItem) === agentMessageText(item)) {
|
|
665
|
+
turn.items[turn.items.length - 1] = { ...item, id: lastItem.id };
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
turn.items.push(item);
|
|
669
|
+
}
|
|
670
|
+
upsert_item_in_turn(turnId, item, options = {}) {
|
|
671
|
+
const turn = turnId ? this.ensure_turn(turnId, true) : this.ensure_turn();
|
|
672
|
+
upsertItem(turn, options.started ? startedItem(item) : item);
|
|
673
|
+
}
|
|
674
|
+
upsert_item_in_current_or_existing_turn(itemId, item) {
|
|
675
|
+
const existingTurn = this.turns.find(
|
|
676
|
+
(turn) => turn.items.some((candidate) => candidate.id === itemId)
|
|
677
|
+
);
|
|
678
|
+
upsertItem(existingTurn ?? this.ensure_turn(), item);
|
|
679
|
+
}
|
|
680
|
+
append_to_current_turn(item) {
|
|
681
|
+
this.ensure_turn().items.push(item);
|
|
682
|
+
}
|
|
683
|
+
apply_agent_message_delta(itemId, delta) {
|
|
684
|
+
const existing = this.find_item(itemId);
|
|
685
|
+
if (!existing || existing.item.type !== "AgentMessage") {
|
|
686
|
+
this.append_to_current_turn({
|
|
687
|
+
type: "AgentMessage",
|
|
688
|
+
id: itemId,
|
|
689
|
+
content: [{ type: "Text", text: delta }],
|
|
690
|
+
phase: "streaming",
|
|
691
|
+
memory_citation: null
|
|
692
|
+
});
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
const item = existing.item;
|
|
696
|
+
const lastContent = item.content.at(-1);
|
|
697
|
+
const nextContent = lastContent?.type === "Text" ? [
|
|
698
|
+
...item.content.slice(0, -1),
|
|
699
|
+
{ type: "Text", text: `${lastContent.text}${delta}` }
|
|
700
|
+
] : [...item.content, { type: "Text", text: delta }];
|
|
701
|
+
existing.turn.items[existing.index] = {
|
|
702
|
+
...item,
|
|
703
|
+
content: nextContent,
|
|
704
|
+
phase: "streaming"
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
apply_plan_delta(itemId, delta) {
|
|
708
|
+
const existing = this.find_item(itemId);
|
|
709
|
+
if (!existing || existing.item.type !== "Plan") {
|
|
710
|
+
this.append_to_current_turn({ type: "Plan", id: itemId, text: delta });
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
existing.turn.items[existing.index] = {
|
|
714
|
+
...existing.item,
|
|
715
|
+
text: `${existing.item.text}${delta}`
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
apply_exec_command_output_delta(msg) {
|
|
719
|
+
const existing = this.find_item(msg.call_id);
|
|
720
|
+
if (!existing || existing.item.type !== "CommandExecution") {
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
existing.turn.items[existing.index] = {
|
|
724
|
+
...existing.item,
|
|
725
|
+
stdout: msg.stream === "stdout" ? `${existing.item.stdout ?? ""}${msg.chunk}` : existing.item.stdout,
|
|
726
|
+
stderr: msg.stream === "stderr" ? `${existing.item.stderr ?? ""}${msg.chunk}` : existing.item.stderr
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
apply_exec_command_end(msg) {
|
|
730
|
+
const existing = this.find_item(msg.call_id);
|
|
731
|
+
const item = existing?.item.type === "CommandExecution" ? existing.item : null;
|
|
732
|
+
const turn = msg.turn_id ? this.ensure_turn(msg.turn_id, true) : existing?.turn ?? this.ensure_turn();
|
|
733
|
+
upsertItem(turn, {
|
|
734
|
+
type: "CommandExecution",
|
|
735
|
+
id: msg.call_id,
|
|
736
|
+
command: item?.command ?? [],
|
|
737
|
+
cwd: item?.cwd ?? "",
|
|
738
|
+
status: msg.status === "completed" ? "completed" : msg.status === "cancelled" ? "cancelled" : "failed",
|
|
739
|
+
stdout: msg.stdout ?? msg.output?.stdout.text ?? item?.stdout ?? "",
|
|
740
|
+
stderr: msg.stderr ?? msg.output?.stderr.text ?? item?.stderr ?? "",
|
|
741
|
+
exit_code: msg.exit_code,
|
|
742
|
+
duration_ms: msg.duration_ms ?? msg.output?.duration_ms ?? null
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
ensure_turn(id, explicit = false) {
|
|
746
|
+
if (id) {
|
|
747
|
+
const existing = this.turn_by_id(id);
|
|
748
|
+
if (existing) {
|
|
749
|
+
return existing;
|
|
750
|
+
}
|
|
751
|
+
const turn2 = newTurn(id, explicit);
|
|
752
|
+
this.turns.push(turn2);
|
|
753
|
+
return turn2;
|
|
754
|
+
}
|
|
755
|
+
const active = this.active_turn();
|
|
756
|
+
if (active) {
|
|
757
|
+
return active;
|
|
758
|
+
}
|
|
759
|
+
const turn = newTurn(`turn-${this.turns.length + 1}`, false);
|
|
760
|
+
this.turns.push(turn);
|
|
761
|
+
return turn;
|
|
762
|
+
}
|
|
763
|
+
active_turn() {
|
|
764
|
+
for (let index = this.turns.length - 1; index >= 0; index -= 1) {
|
|
765
|
+
const turn = this.turns[index];
|
|
766
|
+
if (turn?.status === "in_progress") {
|
|
767
|
+
return turn;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return null;
|
|
771
|
+
}
|
|
772
|
+
turn_by_id(id) {
|
|
773
|
+
return this.turns.find((turn) => turn.id === id) ?? null;
|
|
774
|
+
}
|
|
775
|
+
find_item(itemId) {
|
|
776
|
+
for (const turn of this.turns) {
|
|
777
|
+
const index = turn.items.findIndex((item) => item.id === itemId);
|
|
778
|
+
if (index !== -1) {
|
|
779
|
+
return { turn, item: turn.items[index], index };
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return null;
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
function newTurn(id, openedExplicitly) {
|
|
786
|
+
return {
|
|
787
|
+
id,
|
|
788
|
+
items: [],
|
|
789
|
+
items_view: "full",
|
|
790
|
+
status: "in_progress",
|
|
791
|
+
error: null,
|
|
792
|
+
started_at: null,
|
|
793
|
+
completed_at: null,
|
|
794
|
+
duration_ms: null,
|
|
795
|
+
opened_explicitly: openedExplicitly
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function stripInternalTurn(turn) {
|
|
799
|
+
const { opened_explicitly, ...publicTurn } = turn;
|
|
800
|
+
return cloneTurn(publicTurn);
|
|
801
|
+
}
|
|
802
|
+
function cloneTurn(turn) {
|
|
803
|
+
return {
|
|
804
|
+
...turn,
|
|
805
|
+
items: turn.items.map((item) => structuredClone(item)),
|
|
806
|
+
error: turn.error ? { ...turn.error } : null
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
function nextItemIndexFromTurns(turns) {
|
|
810
|
+
return turns.reduce((count, turn) => count + turn.items.length, 0) + 1;
|
|
811
|
+
}
|
|
812
|
+
function upsertItem(turn, item) {
|
|
813
|
+
const index = turn.items.findIndex((candidate) => candidate.id === item.id);
|
|
814
|
+
if (index === -1) {
|
|
815
|
+
turn.items.push(item);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
turn.items[index] = item;
|
|
819
|
+
}
|
|
820
|
+
function startedItem(item) {
|
|
821
|
+
return item.type === "AgentMessage" ? { ...item, phase: item.phase ?? "streaming" } : item;
|
|
822
|
+
}
|
|
823
|
+
function completedItem(item) {
|
|
824
|
+
return item.type === "AgentMessage" ? { ...item, phase: item.phase ?? null } : item;
|
|
825
|
+
}
|
|
826
|
+
function dynamicToolRequestTurnItem(request) {
|
|
827
|
+
return {
|
|
828
|
+
type: "DynamicToolCall",
|
|
829
|
+
id: request.call_id,
|
|
830
|
+
namespace: request.namespace ?? null,
|
|
831
|
+
tool: request.tool,
|
|
832
|
+
arguments: request.arguments,
|
|
833
|
+
status: "inProgress",
|
|
834
|
+
content_items: null,
|
|
835
|
+
success: null,
|
|
836
|
+
duration: null
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
function userMessageId(eventId) {
|
|
840
|
+
return `user-${eventId}`;
|
|
841
|
+
}
|
|
842
|
+
function agentMessageId(eventId) {
|
|
843
|
+
return `agent-${eventId}`;
|
|
844
|
+
}
|
|
845
|
+
function userMessageTurnItem(msg, id) {
|
|
846
|
+
return {
|
|
847
|
+
type: "UserMessage",
|
|
848
|
+
id,
|
|
849
|
+
content: userInputFromUserMessage(msg)
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
function userInputFromUserMessage(msg) {
|
|
853
|
+
const items = [];
|
|
854
|
+
if (msg.message.length > 0) {
|
|
855
|
+
items.push({
|
|
856
|
+
type: "text",
|
|
857
|
+
text: msg.message,
|
|
858
|
+
text_elements: msg.text_elements
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
for (const imageUrl of msg.images ?? []) {
|
|
862
|
+
items.push({ type: "image", image_url: imageUrl });
|
|
863
|
+
}
|
|
864
|
+
for (const path of msg.local_images ?? []) {
|
|
865
|
+
items.push({ type: "local_image", path });
|
|
866
|
+
}
|
|
867
|
+
return items;
|
|
868
|
+
}
|
|
869
|
+
function imageGenerationTurnItem(msg, id) {
|
|
870
|
+
return {
|
|
871
|
+
type: "ImageGeneration",
|
|
872
|
+
id: msg.call_id || id,
|
|
873
|
+
status: msg.status,
|
|
874
|
+
revised_prompt: msg.revised_prompt,
|
|
875
|
+
result: msg.result,
|
|
876
|
+
saved_path: msg.saved_path
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
function agentMessageText(item) {
|
|
880
|
+
return item.content.map((part) => part.text).join("");
|
|
881
|
+
}
|
|
882
|
+
function userMessageFingerprint(item) {
|
|
883
|
+
return item.content.map((content) => {
|
|
884
|
+
if (content.type === "text") {
|
|
885
|
+
return `text:${content.text}`;
|
|
886
|
+
}
|
|
887
|
+
if (content.type === "image") {
|
|
888
|
+
return `image:${content.image_url}`;
|
|
889
|
+
}
|
|
890
|
+
if (content.type === "local_image") {
|
|
891
|
+
return `local_image:${content.path}`;
|
|
892
|
+
}
|
|
893
|
+
if (content.type === "skill") {
|
|
894
|
+
return `skill:${content.name}:${content.path}`;
|
|
895
|
+
}
|
|
896
|
+
return `mention:${content.name}:${content.path}`;
|
|
897
|
+
}).join("\n");
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// src/internal/codex/app-server-protocol/src/protocol/thread-resume.ts
|
|
901
|
+
function appServerTurnFromCoreTurn(turn) {
|
|
902
|
+
return {
|
|
903
|
+
id: turn.id,
|
|
904
|
+
items: turn.items.map(coreTurnItemToThreadItem).filter((item) => item !== null),
|
|
905
|
+
itemsView: turn.items_view === "not_loaded" ? "notLoaded" : turn.items_view,
|
|
906
|
+
status: coreTurnStatusToAppServer(turn.status),
|
|
907
|
+
error: turn.error ? {
|
|
908
|
+
message: turn.error.message,
|
|
909
|
+
codexErrorInfo: turn.error.codex_error_info ?? null,
|
|
910
|
+
additionalDetails: turn.error.additional_details ?? null
|
|
911
|
+
} : null,
|
|
912
|
+
startedAt: epochSeconds(turn.started_at),
|
|
913
|
+
completedAt: epochSeconds(turn.completed_at),
|
|
914
|
+
durationMs: turn.duration_ms
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
function coreTurnStatusToAppServer(status) {
|
|
918
|
+
if (status === "in_progress") {
|
|
919
|
+
return "inProgress";
|
|
920
|
+
}
|
|
921
|
+
return status;
|
|
922
|
+
}
|
|
923
|
+
function epochSeconds(value) {
|
|
924
|
+
return typeof value === "number" ? value / 1e3 : null;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
// src/internal/codex/app-server-transport/src/transport/mod.ts
|
|
928
|
+
function parseJsonRpcTransportPayload(payload) {
|
|
929
|
+
let value;
|
|
930
|
+
if (typeof payload === "string") {
|
|
931
|
+
try {
|
|
932
|
+
value = JSON.parse(payload);
|
|
933
|
+
} catch {
|
|
934
|
+
return {
|
|
935
|
+
error: jsonRpcParseError("Parse error"),
|
|
936
|
+
id: null,
|
|
937
|
+
type: "invalid"
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
} else if (payload instanceof ArrayBuffer || ArrayBuffer.isView(payload)) {
|
|
941
|
+
const bytes = payload instanceof ArrayBuffer ? new Uint8Array(payload) : new Uint8Array(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
942
|
+
try {
|
|
943
|
+
value = JSON.parse(new TextDecoder().decode(bytes));
|
|
944
|
+
} catch {
|
|
945
|
+
return {
|
|
946
|
+
error: jsonRpcParseError("Parse error"),
|
|
947
|
+
id: null,
|
|
948
|
+
type: "invalid"
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
} else {
|
|
952
|
+
value = payload;
|
|
953
|
+
}
|
|
954
|
+
return parseJsonRpcMessage(value);
|
|
955
|
+
}
|
|
956
|
+
function parseJsonRpcMessage(value) {
|
|
957
|
+
if (!isRecord(value)) {
|
|
958
|
+
return {
|
|
959
|
+
error: jsonRpcInvalidRequestError("Invalid JSON-RPC message"),
|
|
960
|
+
id: null,
|
|
961
|
+
type: "invalid"
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
const candidateId = requestIdFromValue(value.id);
|
|
965
|
+
const id = candidateId ?? null;
|
|
966
|
+
if (typeof value.method === "string") {
|
|
967
|
+
if (candidateId !== null) {
|
|
968
|
+
return {
|
|
969
|
+
message: jsonRpcRequest(value.method, candidateId, value.params),
|
|
970
|
+
type: "ok"
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
if (Object.prototype.hasOwnProperty.call(value, "id")) {
|
|
974
|
+
return {
|
|
975
|
+
error: jsonRpcInvalidRequestError("Invalid JSON-RPC request id"),
|
|
976
|
+
id: null,
|
|
977
|
+
type: "invalid"
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
return {
|
|
981
|
+
message: jsonRpcNotification(value.method, value.params),
|
|
982
|
+
type: "ok"
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
if (Object.prototype.hasOwnProperty.call(value, "error")) {
|
|
986
|
+
if (!isJsonRpcErrorError(value.error)) {
|
|
987
|
+
return {
|
|
988
|
+
error: jsonRpcInvalidRequestError("Invalid JSON-RPC error object"),
|
|
989
|
+
id,
|
|
990
|
+
type: "invalid"
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
return {
|
|
994
|
+
message: { error: value.error, id },
|
|
995
|
+
type: "ok"
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
if (Object.prototype.hasOwnProperty.call(value, "result")) {
|
|
999
|
+
if (candidateId === null) {
|
|
1000
|
+
return {
|
|
1001
|
+
error: jsonRpcInvalidRequestError("Invalid JSON-RPC response id"),
|
|
1002
|
+
id: null,
|
|
1003
|
+
type: "invalid"
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
return {
|
|
1007
|
+
message: { id: candidateId, result: value.result },
|
|
1008
|
+
type: "ok"
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
return {
|
|
1012
|
+
error: jsonRpcInvalidRequestError("Invalid JSON-RPC message"),
|
|
1013
|
+
id,
|
|
1014
|
+
type: "invalid"
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
function parseClientTransportPayload(payload) {
|
|
1018
|
+
const parsed = parseJsonRpcTransportPayload(payload);
|
|
1019
|
+
if (parsed.type === "invalid") {
|
|
1020
|
+
return parsed;
|
|
1021
|
+
}
|
|
1022
|
+
return {
|
|
1023
|
+
message: clientTransportMessage(parsed.message),
|
|
1024
|
+
type: "ok"
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
function serializeOutgoingMessage(message) {
|
|
1028
|
+
return JSON.stringify(message);
|
|
1029
|
+
}
|
|
1030
|
+
function serializeJsonRpcResponse(id, result) {
|
|
1031
|
+
return serializeOutgoingMessage({ id, result });
|
|
1032
|
+
}
|
|
1033
|
+
function serializeJsonRpcError(id, error) {
|
|
1034
|
+
return JSON.stringify({ error, id });
|
|
1035
|
+
}
|
|
1036
|
+
function jsonRpcParseError(message) {
|
|
1037
|
+
return { code: -32700, message };
|
|
1038
|
+
}
|
|
1039
|
+
function jsonRpcInvalidRequestError(message) {
|
|
1040
|
+
return { code: -32600, message };
|
|
1041
|
+
}
|
|
1042
|
+
function clientTransportMessage(message) {
|
|
1043
|
+
if (isRequest(message)) {
|
|
1044
|
+
return { request: message, type: "server_request" };
|
|
1045
|
+
}
|
|
1046
|
+
if (isNotification(message)) {
|
|
1047
|
+
return {
|
|
1048
|
+
notification: message,
|
|
1049
|
+
type: "server_notification"
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
if (isError(message)) {
|
|
1053
|
+
return { error: message, type: "error" };
|
|
1054
|
+
}
|
|
1055
|
+
return { response: message, type: "response" };
|
|
1056
|
+
}
|
|
1057
|
+
function jsonRpcRequest(method, id, params) {
|
|
1058
|
+
return params === void 0 ? { id, method } : { id, method, params };
|
|
1059
|
+
}
|
|
1060
|
+
function jsonRpcNotification(method, params) {
|
|
1061
|
+
return params === void 0 ? { method } : { method, params };
|
|
1062
|
+
}
|
|
1063
|
+
function isRequest(message) {
|
|
1064
|
+
return typeof message.method === "string" && Object.prototype.hasOwnProperty.call(message, "id");
|
|
1065
|
+
}
|
|
1066
|
+
function isNotification(message) {
|
|
1067
|
+
return typeof message.method === "string" && !Object.prototype.hasOwnProperty.call(message, "id");
|
|
1068
|
+
}
|
|
1069
|
+
function isError(message) {
|
|
1070
|
+
return Object.prototype.hasOwnProperty.call(message, "error");
|
|
1071
|
+
}
|
|
1072
|
+
function requestIdFromValue(value) {
|
|
1073
|
+
return typeof value === "string" || typeof value === "number" ? value : null;
|
|
1074
|
+
}
|
|
1075
|
+
function isJsonRpcErrorError(value) {
|
|
1076
|
+
return isRecord(value) && typeof value.code === "number" && typeof value.message === "string";
|
|
1077
|
+
}
|
|
1078
|
+
function isRecord(value) {
|
|
1079
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// src/internal/codex/app-server-client/src/remote.ts
|
|
1083
|
+
var CodexAppServerClientTransportError = class extends Error {
|
|
1084
|
+
constructor(message, status, body) {
|
|
1085
|
+
super(message);
|
|
1086
|
+
this.status = status;
|
|
1087
|
+
this.body = body;
|
|
1088
|
+
this.name = "CodexAppServerClientTransportError";
|
|
1089
|
+
}
|
|
1090
|
+
status;
|
|
1091
|
+
body;
|
|
1092
|
+
};
|
|
1093
|
+
function createCodexAppServerClient(options) {
|
|
1094
|
+
let socket = null;
|
|
1095
|
+
let openPromise = null;
|
|
1096
|
+
let initializePromise = null;
|
|
1097
|
+
let initialized = false;
|
|
1098
|
+
const pendingRequests = /* @__PURE__ */ new Map();
|
|
1099
|
+
const eventQueue = createEventQueue();
|
|
1100
|
+
async function ensureOpenSocket() {
|
|
1101
|
+
const openState = 1;
|
|
1102
|
+
if (socket?.readyState === openState) {
|
|
1103
|
+
return socket;
|
|
1104
|
+
}
|
|
1105
|
+
openPromise ??= openSocket();
|
|
1106
|
+
return openPromise;
|
|
1107
|
+
}
|
|
1108
|
+
async function ensureInitialized() {
|
|
1109
|
+
if (initialized) {
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
initializePromise ??= sendClientRequest({
|
|
1113
|
+
id: 0,
|
|
1114
|
+
method: "initialize",
|
|
1115
|
+
params: await resolveInitializeParams(options.initializeParams)
|
|
1116
|
+
});
|
|
1117
|
+
await initializePromise;
|
|
1118
|
+
initialized = true;
|
|
1119
|
+
}
|
|
1120
|
+
async function request(request2) {
|
|
1121
|
+
if (request2.method !== "initialize") {
|
|
1122
|
+
await ensureInitialized();
|
|
1123
|
+
return sendClientRequest(request2);
|
|
1124
|
+
}
|
|
1125
|
+
const result = await sendClientRequest(request2);
|
|
1126
|
+
initialized = true;
|
|
1127
|
+
return result;
|
|
1128
|
+
}
|
|
1129
|
+
async function sendClientRequest(request2) {
|
|
1130
|
+
const websocket = await ensureOpenSocket();
|
|
1131
|
+
return new Promise((resolve, reject) => {
|
|
1132
|
+
pendingRequests.set(request2.id, { reject, resolve });
|
|
1133
|
+
try {
|
|
1134
|
+
websocket.send(JSON.stringify(request2));
|
|
1135
|
+
} catch (error) {
|
|
1136
|
+
pendingRequests.delete(request2.id);
|
|
1137
|
+
reject(error);
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
async function sendClientResponse(requestId, result) {
|
|
1142
|
+
const websocket = await ensureOpenSocket();
|
|
1143
|
+
websocket.send(serializeJsonRpcResponse(requestId, result));
|
|
1144
|
+
}
|
|
1145
|
+
async function sendClientError(requestId, error) {
|
|
1146
|
+
const websocket = await ensureOpenSocket();
|
|
1147
|
+
websocket.send(serializeJsonRpcError(requestId, error));
|
|
1148
|
+
}
|
|
1149
|
+
async function openSocket() {
|
|
1150
|
+
options.onConnectionStatus?.("connecting");
|
|
1151
|
+
eventQueue.reopen();
|
|
1152
|
+
const WebSocketCtor = options.WebSocket ?? WebSocket;
|
|
1153
|
+
const websocketUrl = await resolveUrl(options.url);
|
|
1154
|
+
return new Promise((resolve, reject) => {
|
|
1155
|
+
let settled = false;
|
|
1156
|
+
const nextSocket = new WebSocketCtor(websocketUrl);
|
|
1157
|
+
socket = nextSocket;
|
|
1158
|
+
nextSocket.addEventListener("open", () => {
|
|
1159
|
+
settled = true;
|
|
1160
|
+
options.onConnectionStatus?.("connected");
|
|
1161
|
+
resolve(nextSocket);
|
|
1162
|
+
});
|
|
1163
|
+
nextSocket.addEventListener("message", (message) => {
|
|
1164
|
+
handleSocketMessage(message.data);
|
|
1165
|
+
});
|
|
1166
|
+
nextSocket.addEventListener("close", () => {
|
|
1167
|
+
const error = new CodexAppServerClientTransportError(
|
|
1168
|
+
"Codex app-server WebSocket closed."
|
|
1169
|
+
);
|
|
1170
|
+
closeSocketState(error);
|
|
1171
|
+
eventQueue.push({ message: "closed", type: "disconnected" });
|
|
1172
|
+
eventQueue.close();
|
|
1173
|
+
options.onConnectionStatus?.("closed");
|
|
1174
|
+
if (!settled) {
|
|
1175
|
+
reject(error);
|
|
1176
|
+
}
|
|
1177
|
+
});
|
|
1178
|
+
nextSocket.addEventListener("error", () => {
|
|
1179
|
+
const error = new CodexAppServerClientTransportError(
|
|
1180
|
+
"Codex app-server WebSocket failed."
|
|
1181
|
+
);
|
|
1182
|
+
closeSocketState(error);
|
|
1183
|
+
eventQueue.fail(error);
|
|
1184
|
+
options.onConnectionStatus?.("error");
|
|
1185
|
+
if (!settled) {
|
|
1186
|
+
reject(error);
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
function handleSocketMessage(value) {
|
|
1192
|
+
const parsed = parseClientTransportPayload(value);
|
|
1193
|
+
if (parsed.type === "invalid") {
|
|
1194
|
+
const event = options.parseEvent?.(value);
|
|
1195
|
+
if (event) {
|
|
1196
|
+
eventQueue.push(event);
|
|
1197
|
+
}
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
const message = parsed.message;
|
|
1201
|
+
switch (message.type) {
|
|
1202
|
+
case "response": {
|
|
1203
|
+
const pending = pendingRequests.get(message.response.id);
|
|
1204
|
+
if (!pending) {
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
pendingRequests.delete(message.response.id);
|
|
1208
|
+
pending.resolve(message.response.result);
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
case "error": {
|
|
1212
|
+
if (message.error.id === null) {
|
|
1213
|
+
eventQueue.fail(message.error.error);
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
const pending = pendingRequests.get(message.error.id);
|
|
1217
|
+
if (!pending) {
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
pendingRequests.delete(message.error.id);
|
|
1221
|
+
pending.reject(message.error.error);
|
|
1222
|
+
return;
|
|
1223
|
+
}
|
|
1224
|
+
case "server_notification":
|
|
1225
|
+
eventQueue.push({
|
|
1226
|
+
notification: message.notification,
|
|
1227
|
+
type: "server_notification"
|
|
1228
|
+
});
|
|
1229
|
+
return;
|
|
1230
|
+
case "server_request":
|
|
1231
|
+
eventQueue.push({ request: message.request, type: "server_request" });
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
function closeSocketState(error) {
|
|
1236
|
+
socket = null;
|
|
1237
|
+
openPromise = null;
|
|
1238
|
+
initializePromise = null;
|
|
1239
|
+
initialized = false;
|
|
1240
|
+
for (const pending of pendingRequests.values()) {
|
|
1241
|
+
pending.reject(error);
|
|
1242
|
+
}
|
|
1243
|
+
pendingRequests.clear();
|
|
1244
|
+
}
|
|
1245
|
+
function close() {
|
|
1246
|
+
const currentSocket = socket;
|
|
1247
|
+
closeSocketState(
|
|
1248
|
+
new CodexAppServerClientTransportError(
|
|
1249
|
+
"Codex app-server WebSocket closed."
|
|
1250
|
+
)
|
|
1251
|
+
);
|
|
1252
|
+
eventQueue.close();
|
|
1253
|
+
if (currentSocket && currentSocket.readyState !== 3) {
|
|
1254
|
+
currentSocket.close();
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
return {
|
|
1258
|
+
close,
|
|
1259
|
+
events() {
|
|
1260
|
+
void ensureInitialized().catch((error) => eventQueue.fail(error));
|
|
1261
|
+
return eventQueue.iterable();
|
|
1262
|
+
},
|
|
1263
|
+
request,
|
|
1264
|
+
requestTyped(clientRequest) {
|
|
1265
|
+
return requestTyped(clientRequest, request);
|
|
1266
|
+
},
|
|
1267
|
+
rejectServerRequest(requestId, error) {
|
|
1268
|
+
return sendClientError(requestId, error);
|
|
1269
|
+
},
|
|
1270
|
+
resolveServerRequest(requestId, result) {
|
|
1271
|
+
return sendClientResponse(requestId, result);
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
function parseCodexAppServerEvent(value) {
|
|
1276
|
+
const parsed = parseClientTransportPayload(value);
|
|
1277
|
+
if (parsed.type === "ok") {
|
|
1278
|
+
switch (parsed.message.type) {
|
|
1279
|
+
case "server_notification":
|
|
1280
|
+
return {
|
|
1281
|
+
notification: parsed.message.notification,
|
|
1282
|
+
type: "server_notification"
|
|
1283
|
+
};
|
|
1284
|
+
case "server_request":
|
|
1285
|
+
return { request: parsed.message.request, type: "server_request" };
|
|
1286
|
+
case "error":
|
|
1287
|
+
case "response":
|
|
1288
|
+
return null;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
if (typeof value !== "string") {
|
|
1292
|
+
return appServerEventFromParsed(value);
|
|
1293
|
+
}
|
|
1294
|
+
try {
|
|
1295
|
+
return appServerEventFromParsed(JSON.parse(value));
|
|
1296
|
+
} catch {
|
|
1297
|
+
return null;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
async function resolveInitializeParams(params) {
|
|
1301
|
+
if (typeof params === "function") {
|
|
1302
|
+
return params();
|
|
1303
|
+
}
|
|
1304
|
+
return params ?? defaultInitializeParams();
|
|
1305
|
+
}
|
|
1306
|
+
async function resolveUrl(url) {
|
|
1307
|
+
return typeof url === "function" ? await url() : url;
|
|
1308
|
+
}
|
|
1309
|
+
function defaultInitializeParams() {
|
|
1310
|
+
return {
|
|
1311
|
+
capabilities: {
|
|
1312
|
+
experimentalApi: false,
|
|
1313
|
+
optOutNotificationMethods: []
|
|
1314
|
+
},
|
|
1315
|
+
clientInfo: {
|
|
1316
|
+
name: "codex-js",
|
|
1317
|
+
title: null,
|
|
1318
|
+
version: "0.0.0"
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
function appServerEventFromParsed(value) {
|
|
1323
|
+
if (isObject(value) && typeof value.type === "string") {
|
|
1324
|
+
if (value.type === "server_notification" || value.type === "server_request" || value.type === "lagged" || value.type === "disconnected") {
|
|
1325
|
+
return value;
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
if (isObject(value) && typeof value.method === "string" && "params" in value) {
|
|
1329
|
+
if ("id" in value) {
|
|
1330
|
+
return { request: value, type: "server_request" };
|
|
1331
|
+
}
|
|
1332
|
+
return {
|
|
1333
|
+
notification: value,
|
|
1334
|
+
type: "server_notification"
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
return null;
|
|
1338
|
+
}
|
|
1339
|
+
function isObject(value) {
|
|
1340
|
+
return typeof value === "object" && value !== null;
|
|
1341
|
+
}
|
|
1342
|
+
function createEventQueue() {
|
|
1343
|
+
const values = [];
|
|
1344
|
+
const waiters = [];
|
|
1345
|
+
let closed = false;
|
|
1346
|
+
let failure = null;
|
|
1347
|
+
return {
|
|
1348
|
+
close() {
|
|
1349
|
+
closed = true;
|
|
1350
|
+
for (const waiter of waiters.splice(0)) {
|
|
1351
|
+
waiter.settled = true;
|
|
1352
|
+
waiter.resolve({ done: true, value: void 0 });
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
fail(error) {
|
|
1356
|
+
failure = error;
|
|
1357
|
+
for (const waiter of waiters.splice(0)) {
|
|
1358
|
+
waiter.settled = true;
|
|
1359
|
+
waiter.reject(error);
|
|
1360
|
+
}
|
|
1361
|
+
},
|
|
1362
|
+
push(value) {
|
|
1363
|
+
while (waiters.length > 0) {
|
|
1364
|
+
const waiter = waiters.shift();
|
|
1365
|
+
if (waiter.settled) {
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
waiter.settled = true;
|
|
1369
|
+
waiter.resolve({ done: false, value });
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
values.push(value);
|
|
1373
|
+
},
|
|
1374
|
+
reopen() {
|
|
1375
|
+
values.splice(0);
|
|
1376
|
+
closed = false;
|
|
1377
|
+
failure = null;
|
|
1378
|
+
},
|
|
1379
|
+
iterable(options = {}) {
|
|
1380
|
+
return {
|
|
1381
|
+
[Symbol.asyncIterator]() {
|
|
1382
|
+
let active = true;
|
|
1383
|
+
let pendingWaiter = null;
|
|
1384
|
+
return {
|
|
1385
|
+
next() {
|
|
1386
|
+
if (!active) {
|
|
1387
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
1388
|
+
}
|
|
1389
|
+
if (failure) {
|
|
1390
|
+
return Promise.reject(failure);
|
|
1391
|
+
}
|
|
1392
|
+
if (values.length > 0) {
|
|
1393
|
+
return Promise.resolve({
|
|
1394
|
+
done: false,
|
|
1395
|
+
value: values.shift()
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
if (closed) {
|
|
1399
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
1400
|
+
}
|
|
1401
|
+
return new Promise((resolve, reject) => {
|
|
1402
|
+
const waiter = { reject, resolve, settled: false };
|
|
1403
|
+
pendingWaiter = waiter;
|
|
1404
|
+
waiters.push(waiter);
|
|
1405
|
+
});
|
|
1406
|
+
},
|
|
1407
|
+
return() {
|
|
1408
|
+
options.onReturn?.();
|
|
1409
|
+
active = false;
|
|
1410
|
+
if (pendingWaiter && !pendingWaiter.settled) {
|
|
1411
|
+
pendingWaiter.settled = true;
|
|
1412
|
+
const index = waiters.indexOf(pendingWaiter);
|
|
1413
|
+
if (index !== -1) {
|
|
1414
|
+
waiters.splice(index, 1);
|
|
1415
|
+
}
|
|
1416
|
+
pendingWaiter.resolve({ done: true, value: void 0 });
|
|
1417
|
+
}
|
|
1418
|
+
return Promise.resolve({ done: true, value: void 0 });
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
// src/internal/codex/app-server-client/src/session.ts
|
|
1428
|
+
var AppServerSession = class {
|
|
1429
|
+
constructor(client) {
|
|
1430
|
+
this.client = client;
|
|
1431
|
+
}
|
|
1432
|
+
client;
|
|
1433
|
+
nextRequestIdValue = 1;
|
|
1434
|
+
nextRequestId() {
|
|
1435
|
+
const requestId = this.nextRequestIdValue;
|
|
1436
|
+
this.nextRequestIdValue += 1;
|
|
1437
|
+
return requestId;
|
|
1438
|
+
}
|
|
1439
|
+
nextEvent() {
|
|
1440
|
+
return this.client.nextEvent?.() ?? Promise.resolve(null);
|
|
1441
|
+
}
|
|
1442
|
+
events() {
|
|
1443
|
+
return this.client.events?.() ?? null;
|
|
1444
|
+
}
|
|
1445
|
+
requestTyped(request) {
|
|
1446
|
+
return this.client.requestTyped(request);
|
|
1447
|
+
}
|
|
1448
|
+
initialize(params = defaultInitializeParams2()) {
|
|
1449
|
+
return this.requestTyped({
|
|
1450
|
+
id: this.nextRequestId(),
|
|
1451
|
+
method: "initialize",
|
|
1452
|
+
params
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
threadStart(params) {
|
|
1456
|
+
return this.requestTyped({
|
|
1457
|
+
id: this.nextRequestId(),
|
|
1458
|
+
method: "thread/start",
|
|
1459
|
+
params
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
threadResume(params) {
|
|
1463
|
+
return this.requestTyped({
|
|
1464
|
+
id: this.nextRequestId(),
|
|
1465
|
+
method: "thread/resume",
|
|
1466
|
+
params
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
threadList(params = {}) {
|
|
1470
|
+
return this.requestTyped({
|
|
1471
|
+
id: this.nextRequestId(),
|
|
1472
|
+
method: "thread/list",
|
|
1473
|
+
params
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
collaborationModeList(params = {}) {
|
|
1477
|
+
return this.requestTyped({
|
|
1478
|
+
id: this.nextRequestId(),
|
|
1479
|
+
method: "collaborationMode/list",
|
|
1480
|
+
params
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
configMcpServerReload() {
|
|
1484
|
+
return this.requestTyped({
|
|
1485
|
+
id: this.nextRequestId(),
|
|
1486
|
+
method: "config/mcpServer/reload",
|
|
1487
|
+
params: void 0
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
mcpServerStatusList(params = {}) {
|
|
1491
|
+
return this.requestTyped({
|
|
1492
|
+
id: this.nextRequestId(),
|
|
1493
|
+
method: "mcpServerStatus/list",
|
|
1494
|
+
params
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
mcpResourceRead(params) {
|
|
1498
|
+
return this.requestTyped({
|
|
1499
|
+
id: this.nextRequestId(),
|
|
1500
|
+
method: "mcpServer/resource/read",
|
|
1501
|
+
params
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
mcpServerToolCall(params) {
|
|
1505
|
+
return this.requestTyped({
|
|
1506
|
+
id: this.nextRequestId(),
|
|
1507
|
+
method: "mcpServer/tool/call",
|
|
1508
|
+
params
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
mcpServerOauthLogin(params) {
|
|
1512
|
+
return this.requestTyped({
|
|
1513
|
+
id: this.nextRequestId(),
|
|
1514
|
+
method: "mcpServer/oauth/login",
|
|
1515
|
+
params
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
threadRead(params) {
|
|
1519
|
+
return this.requestTyped({
|
|
1520
|
+
id: this.nextRequestId(),
|
|
1521
|
+
method: "thread/read",
|
|
1522
|
+
params
|
|
1523
|
+
});
|
|
1524
|
+
}
|
|
1525
|
+
threadNameSet(params) {
|
|
1526
|
+
return this.requestTyped({
|
|
1527
|
+
id: this.nextRequestId(),
|
|
1528
|
+
method: "thread/name/set",
|
|
1529
|
+
params
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
threadArchive(params) {
|
|
1533
|
+
return this.requestTyped({
|
|
1534
|
+
id: this.nextRequestId(),
|
|
1535
|
+
method: "thread/archive",
|
|
1536
|
+
params
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
threadUnarchive(params) {
|
|
1540
|
+
return this.requestTyped({
|
|
1541
|
+
id: this.nextRequestId(),
|
|
1542
|
+
method: "thread/unarchive",
|
|
1543
|
+
params
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
threadMetadataUpdate(params) {
|
|
1547
|
+
return this.requestTyped({
|
|
1548
|
+
id: this.nextRequestId(),
|
|
1549
|
+
method: "thread/metadata/update",
|
|
1550
|
+
params
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
turnStart(params) {
|
|
1554
|
+
return this.requestTyped({
|
|
1555
|
+
id: this.nextRequestId(),
|
|
1556
|
+
method: "turn/start",
|
|
1557
|
+
params
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
turnSteer(params) {
|
|
1561
|
+
return this.requestTyped({
|
|
1562
|
+
id: this.nextRequestId(),
|
|
1563
|
+
method: "turn/steer",
|
|
1564
|
+
params
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
turnInterrupt(params) {
|
|
1568
|
+
return this.requestTyped({
|
|
1569
|
+
id: this.nextRequestId(),
|
|
1570
|
+
method: "turn/interrupt",
|
|
1571
|
+
params
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
threadCompactStart(params) {
|
|
1575
|
+
return this.requestTyped({
|
|
1576
|
+
id: this.nextRequestId(),
|
|
1577
|
+
method: "thread/compact/start",
|
|
1578
|
+
params
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
resolveServerRequest(requestId, result) {
|
|
1582
|
+
return this.client.resolveServerRequest(requestId, result);
|
|
1583
|
+
}
|
|
1584
|
+
rejectServerRequest(requestId, error) {
|
|
1585
|
+
return this.client.rejectServerRequest(requestId, error);
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
function defaultInitializeParams2() {
|
|
1589
|
+
return {
|
|
1590
|
+
capabilities: {
|
|
1591
|
+
experimentalApi: false,
|
|
1592
|
+
optOutNotificationMethods: []
|
|
1593
|
+
},
|
|
1594
|
+
clientInfo: {
|
|
1595
|
+
name: "codex-js",
|
|
1596
|
+
title: null,
|
|
1597
|
+
version: "0.0.0"
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
// src/internal/codex/app-server-client/src/pending_requests.ts
|
|
1603
|
+
var PendingAppServerRequests = class {
|
|
1604
|
+
dynamicToolCalls = /* @__PURE__ */ new Map();
|
|
1605
|
+
execApprovals = /* @__PURE__ */ new Map();
|
|
1606
|
+
fileChangeApprovals = /* @__PURE__ */ new Map();
|
|
1607
|
+
mcpRequests = /* @__PURE__ */ new Map();
|
|
1608
|
+
permissionsApprovals = /* @__PURE__ */ new Map();
|
|
1609
|
+
userInputs = /* @__PURE__ */ new Map();
|
|
1610
|
+
clear() {
|
|
1611
|
+
this.dynamicToolCalls.clear();
|
|
1612
|
+
this.execApprovals.clear();
|
|
1613
|
+
this.fileChangeApprovals.clear();
|
|
1614
|
+
this.mcpRequests.clear();
|
|
1615
|
+
this.permissionsApprovals.clear();
|
|
1616
|
+
this.userInputs.clear();
|
|
1617
|
+
}
|
|
1618
|
+
noteServerRequest(request) {
|
|
1619
|
+
switch (request.method) {
|
|
1620
|
+
case "item/commandExecution/requestApproval": {
|
|
1621
|
+
const id = request.params.approvalId ?? request.params.itemId;
|
|
1622
|
+
this.execApprovals.set(id, request.id);
|
|
1623
|
+
return null;
|
|
1624
|
+
}
|
|
1625
|
+
case "item/fileChange/requestApproval":
|
|
1626
|
+
this.fileChangeApprovals.set(request.params.itemId, request.id);
|
|
1627
|
+
return null;
|
|
1628
|
+
case "item/permissions/requestApproval":
|
|
1629
|
+
this.permissionsApprovals.set(request.params.itemId, request.id);
|
|
1630
|
+
return null;
|
|
1631
|
+
case "item/tool/requestUserInput": {
|
|
1632
|
+
const queue = this.userInputs.get(request.params.turnId) ?? [];
|
|
1633
|
+
queue.push({
|
|
1634
|
+
itemId: request.params.itemId,
|
|
1635
|
+
requestId: request.id
|
|
1636
|
+
});
|
|
1637
|
+
this.userInputs.set(request.params.turnId, queue);
|
|
1638
|
+
return null;
|
|
1639
|
+
}
|
|
1640
|
+
case "mcpServer/elicitation/request":
|
|
1641
|
+
this.mcpRequests.set(
|
|
1642
|
+
mcpRequestKey(request.params.serverName, request.id),
|
|
1643
|
+
request.id
|
|
1644
|
+
);
|
|
1645
|
+
return null;
|
|
1646
|
+
case "item/tool/call":
|
|
1647
|
+
this.dynamicToolCalls.set(request.params.callId, request.id);
|
|
1648
|
+
return null;
|
|
1649
|
+
default:
|
|
1650
|
+
return {
|
|
1651
|
+
message: `Unsupported Codex app-server request: ${request.method}`,
|
|
1652
|
+
requestId: request.id
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
takeCommandExecutionApprovalResolution(id, response) {
|
|
1657
|
+
return takeMapResolution(this.execApprovals, id, response);
|
|
1658
|
+
}
|
|
1659
|
+
takeFileChangeApprovalResolution(id, response) {
|
|
1660
|
+
return takeMapResolution(this.fileChangeApprovals, id, response);
|
|
1661
|
+
}
|
|
1662
|
+
takePermissionsApprovalResolution(id, response) {
|
|
1663
|
+
return takeMapResolution(this.permissionsApprovals, id, response);
|
|
1664
|
+
}
|
|
1665
|
+
takeDynamicToolCallResolution(callId, response) {
|
|
1666
|
+
return takeMapResolution(this.dynamicToolCalls, callId, response);
|
|
1667
|
+
}
|
|
1668
|
+
takeUserInputResolution(turnId, response) {
|
|
1669
|
+
const pending = this.popUserInputRequestForTurn(turnId);
|
|
1670
|
+
return pending ? { requestId: pending.requestId, result: response } : null;
|
|
1671
|
+
}
|
|
1672
|
+
takeMcpElicitationResolution(serverName, requestId, response) {
|
|
1673
|
+
return takeMapResolution(
|
|
1674
|
+
this.mcpRequests,
|
|
1675
|
+
mcpRequestKey(serverName, requestId),
|
|
1676
|
+
response
|
|
1677
|
+
);
|
|
1678
|
+
}
|
|
1679
|
+
resolveNotification(requestId) {
|
|
1680
|
+
const execApproval = removeValue(this.execApprovals, requestId);
|
|
1681
|
+
if (execApproval) {
|
|
1682
|
+
return { id: execApproval, type: "exec_approval" };
|
|
1683
|
+
}
|
|
1684
|
+
const fileChangeApproval = removeValue(
|
|
1685
|
+
this.fileChangeApprovals,
|
|
1686
|
+
requestId
|
|
1687
|
+
);
|
|
1688
|
+
if (fileChangeApproval) {
|
|
1689
|
+
return { id: fileChangeApproval, type: "file_change_approval" };
|
|
1690
|
+
}
|
|
1691
|
+
const permissionsApproval = removeValue(
|
|
1692
|
+
this.permissionsApprovals,
|
|
1693
|
+
requestId
|
|
1694
|
+
);
|
|
1695
|
+
if (permissionsApproval) {
|
|
1696
|
+
return { id: permissionsApproval, type: "permissions_approval" };
|
|
1697
|
+
}
|
|
1698
|
+
const userInput = this.removeUserInputRequest(requestId);
|
|
1699
|
+
if (userInput) {
|
|
1700
|
+
return { itemId: userInput.itemId, type: "user_input" };
|
|
1701
|
+
}
|
|
1702
|
+
const dynamicToolCall = removeValue(this.dynamicToolCalls, requestId);
|
|
1703
|
+
if (dynamicToolCall) {
|
|
1704
|
+
return { callId: dynamicToolCall, type: "dynamic_tool_call" };
|
|
1705
|
+
}
|
|
1706
|
+
const mcpRequest = removeValue(this.mcpRequests, requestId);
|
|
1707
|
+
if (mcpRequest) {
|
|
1708
|
+
const [serverName] = mcpRequest.split(":");
|
|
1709
|
+
return { requestId, serverName, type: "mcp_elicitation" };
|
|
1710
|
+
}
|
|
1711
|
+
return null;
|
|
1712
|
+
}
|
|
1713
|
+
containsServerRequest(request) {
|
|
1714
|
+
return this.requestIds().some((requestId) => requestId === request.id);
|
|
1715
|
+
}
|
|
1716
|
+
requestIds() {
|
|
1717
|
+
return [
|
|
1718
|
+
...this.execApprovals.values(),
|
|
1719
|
+
...this.fileChangeApprovals.values(),
|
|
1720
|
+
...this.permissionsApprovals.values(),
|
|
1721
|
+
...this.dynamicToolCalls.values(),
|
|
1722
|
+
...this.mcpRequests.values(),
|
|
1723
|
+
...Array.from(this.userInputs.values()).flatMap(
|
|
1724
|
+
(queue) => queue.map((request) => request.requestId)
|
|
1725
|
+
)
|
|
1726
|
+
];
|
|
1727
|
+
}
|
|
1728
|
+
popUserInputRequestForTurn(turnId) {
|
|
1729
|
+
const queue = this.userInputs.get(turnId);
|
|
1730
|
+
const pending = queue?.shift() ?? null;
|
|
1731
|
+
if (queue && queue.length === 0) {
|
|
1732
|
+
this.userInputs.delete(turnId);
|
|
1733
|
+
}
|
|
1734
|
+
return pending;
|
|
1735
|
+
}
|
|
1736
|
+
removeUserInputRequest(requestId) {
|
|
1737
|
+
for (const [turnId, queue] of this.userInputs) {
|
|
1738
|
+
const index = queue.findIndex((pending2) => pending2.requestId === requestId);
|
|
1739
|
+
if (index === -1) {
|
|
1740
|
+
continue;
|
|
1741
|
+
}
|
|
1742
|
+
const [pending] = queue.splice(index, 1);
|
|
1743
|
+
if (queue.length === 0) {
|
|
1744
|
+
this.userInputs.delete(turnId);
|
|
1745
|
+
}
|
|
1746
|
+
return pending ?? null;
|
|
1747
|
+
}
|
|
1748
|
+
return null;
|
|
1749
|
+
}
|
|
1750
|
+
};
|
|
1751
|
+
function takeMapResolution(map, key, result) {
|
|
1752
|
+
const requestId = map.get(key);
|
|
1753
|
+
if (requestId === void 0) {
|
|
1754
|
+
return null;
|
|
1755
|
+
}
|
|
1756
|
+
map.delete(key);
|
|
1757
|
+
return { requestId, result };
|
|
1758
|
+
}
|
|
1759
|
+
function removeValue(map, value) {
|
|
1760
|
+
for (const [key, current] of map) {
|
|
1761
|
+
if (current === value) {
|
|
1762
|
+
map.delete(key);
|
|
1763
|
+
return key;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
return null;
|
|
1767
|
+
}
|
|
1768
|
+
function mcpRequestKey(serverName, requestId) {
|
|
1769
|
+
return `${serverName}:${requestId}`;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
// src/internal/codex/app-server-client/src/thread_event_store.ts
|
|
1773
|
+
var ThreadEventStore = class _ThreadEventStore {
|
|
1774
|
+
accountRateLimits = null;
|
|
1775
|
+
activeTurnIds = /* @__PURE__ */ new Set();
|
|
1776
|
+
bufferedEvents = [];
|
|
1777
|
+
connectionStatus = "idle";
|
|
1778
|
+
errors = [];
|
|
1779
|
+
pendingRequests = /* @__PURE__ */ new Map();
|
|
1780
|
+
resolvedRequestIds = [];
|
|
1781
|
+
thread = null;
|
|
1782
|
+
tokenUsage = null;
|
|
1783
|
+
turns = [];
|
|
1784
|
+
warnings = [];
|
|
1785
|
+
static fromThread(thread) {
|
|
1786
|
+
const store = new _ThreadEventStore();
|
|
1787
|
+
store.setThread(thread);
|
|
1788
|
+
return store;
|
|
1789
|
+
}
|
|
1790
|
+
applyNotification(notification) {
|
|
1791
|
+
applyServerNotificationToThreadEventStore(this, notification);
|
|
1792
|
+
return this.snapshot();
|
|
1793
|
+
}
|
|
1794
|
+
applyRequest(request) {
|
|
1795
|
+
applyServerRequestToThreadEventStore(this, request);
|
|
1796
|
+
return this.snapshot();
|
|
1797
|
+
}
|
|
1798
|
+
setConnectionStatus(status) {
|
|
1799
|
+
this.connectionStatus = status;
|
|
1800
|
+
return this.snapshot();
|
|
1801
|
+
}
|
|
1802
|
+
setThread(thread) {
|
|
1803
|
+
this.thread = cloneThread(thread);
|
|
1804
|
+
this.turns = thread.turns.map(cloneTurn2);
|
|
1805
|
+
this.activeTurnIds = new Set(
|
|
1806
|
+
this.turns.filter((turn) => turn.status === "inProgress").map((turn) => turn.id)
|
|
1807
|
+
);
|
|
1808
|
+
return this.snapshot();
|
|
1809
|
+
}
|
|
1810
|
+
snapshot() {
|
|
1811
|
+
return {
|
|
1812
|
+
activeTurnIds: [...this.activeTurnIds],
|
|
1813
|
+
accountRateLimits: this.accountRateLimits ? { ...this.accountRateLimits } : null,
|
|
1814
|
+
bufferedEvents: [...this.bufferedEvents],
|
|
1815
|
+
connectionStatus: this.connectionStatus,
|
|
1816
|
+
errors: [...this.errors],
|
|
1817
|
+
pendingRequests: [...this.pendingRequests.values()],
|
|
1818
|
+
resolvedRequestIds: [...this.resolvedRequestIds],
|
|
1819
|
+
thread: this.thread ? cloneThread(this.thread) : null,
|
|
1820
|
+
tokenUsage: this.tokenUsage ? {
|
|
1821
|
+
...this.tokenUsage,
|
|
1822
|
+
tokenUsage: cloneThreadTokenUsage(this.tokenUsage.tokenUsage)
|
|
1823
|
+
} : null,
|
|
1824
|
+
turns: this.turns.map(cloneTurn2),
|
|
1825
|
+
warnings: [...this.warnings]
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
noteNotification(notification) {
|
|
1829
|
+
this.bufferedEvents = [...this.bufferedEvents, { notification, type: "notification" }];
|
|
1830
|
+
switch (notification.method) {
|
|
1831
|
+
case "thread/started":
|
|
1832
|
+
this.setThread(notification.params.thread);
|
|
1833
|
+
return;
|
|
1834
|
+
case "thread/status/changed":
|
|
1835
|
+
if (this.thread) {
|
|
1836
|
+
this.thread = { ...this.thread, status: notification.params.status };
|
|
1837
|
+
}
|
|
1838
|
+
return;
|
|
1839
|
+
case "thread/name/updated":
|
|
1840
|
+
if (this.thread) {
|
|
1841
|
+
this.thread = { ...this.thread, name: notification.params.threadName ?? null };
|
|
1842
|
+
}
|
|
1843
|
+
return;
|
|
1844
|
+
case "thread/archived":
|
|
1845
|
+
case "thread/unarchived":
|
|
1846
|
+
case "thread/closed":
|
|
1847
|
+
case "thread/goal/updated":
|
|
1848
|
+
case "thread/goal/cleared":
|
|
1849
|
+
return;
|
|
1850
|
+
case "thread/tokenUsage/updated":
|
|
1851
|
+
this.tokenUsage = {
|
|
1852
|
+
threadId: notification.params.threadId,
|
|
1853
|
+
tokenUsage: cloneThreadTokenUsage(notification.params.tokenUsage),
|
|
1854
|
+
turnId: notification.params.turnId,
|
|
1855
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1856
|
+
};
|
|
1857
|
+
return;
|
|
1858
|
+
case "turn/started":
|
|
1859
|
+
this.upsertTurn(notification.params.turn);
|
|
1860
|
+
this.activeTurnIds.add(notification.params.turn.id);
|
|
1861
|
+
return;
|
|
1862
|
+
case "turn/diff/updated":
|
|
1863
|
+
case "turn/plan/updated":
|
|
1864
|
+
this.ensureTurn(notification.params.turnId);
|
|
1865
|
+
return;
|
|
1866
|
+
case "turn/completed":
|
|
1867
|
+
this.upsertTurn(notification.params.turn);
|
|
1868
|
+
this.activeTurnIds.delete(notification.params.turn.id);
|
|
1869
|
+
if (notification.params.turn.error?.message) {
|
|
1870
|
+
this.errors = appendUnique(this.errors, notification.params.turn.error.message);
|
|
1871
|
+
}
|
|
1872
|
+
return;
|
|
1873
|
+
case "item/started":
|
|
1874
|
+
case "item/completed":
|
|
1875
|
+
this.upsertItem(notification.params.turnId, notification.params.item);
|
|
1876
|
+
return;
|
|
1877
|
+
case "item/agentMessage/delta":
|
|
1878
|
+
this.applyAgentMessageDelta(
|
|
1879
|
+
notification.params.turnId,
|
|
1880
|
+
notification.params.itemId,
|
|
1881
|
+
notification.params.delta
|
|
1882
|
+
);
|
|
1883
|
+
return;
|
|
1884
|
+
case "item/plan/delta":
|
|
1885
|
+
this.applyPlanDelta(
|
|
1886
|
+
notification.params.turnId,
|
|
1887
|
+
notification.params.itemId,
|
|
1888
|
+
notification.params.delta
|
|
1889
|
+
);
|
|
1890
|
+
return;
|
|
1891
|
+
case "item/reasoning/summaryPartAdded":
|
|
1892
|
+
this.applyReasoningSummaryPartAdded(
|
|
1893
|
+
notification.params.turnId,
|
|
1894
|
+
notification.params.itemId,
|
|
1895
|
+
notification.params.summaryIndex
|
|
1896
|
+
);
|
|
1897
|
+
return;
|
|
1898
|
+
case "item/reasoning/summaryTextDelta":
|
|
1899
|
+
this.applyReasoningSummaryTextDelta(
|
|
1900
|
+
notification.params.turnId,
|
|
1901
|
+
notification.params.itemId,
|
|
1902
|
+
notification.params.summaryIndex,
|
|
1903
|
+
notification.params.delta
|
|
1904
|
+
);
|
|
1905
|
+
return;
|
|
1906
|
+
case "item/reasoning/textDelta":
|
|
1907
|
+
this.applyReasoningTextDelta(
|
|
1908
|
+
notification.params.turnId,
|
|
1909
|
+
notification.params.itemId,
|
|
1910
|
+
notification.params.contentIndex,
|
|
1911
|
+
notification.params.delta
|
|
1912
|
+
);
|
|
1913
|
+
return;
|
|
1914
|
+
case "item/commandExecution/outputDelta":
|
|
1915
|
+
this.applyCommandOutputDelta(
|
|
1916
|
+
notification.params.turnId,
|
|
1917
|
+
notification.params.itemId,
|
|
1918
|
+
notification.params.delta
|
|
1919
|
+
);
|
|
1920
|
+
return;
|
|
1921
|
+
case "item/fileChange/outputDelta":
|
|
1922
|
+
this.ensureTurn(notification.params.turnId);
|
|
1923
|
+
return;
|
|
1924
|
+
case "item/fileChange/patchUpdated":
|
|
1925
|
+
this.applyFileChangePatchUpdated(
|
|
1926
|
+
notification.params.turnId,
|
|
1927
|
+
notification.params.itemId,
|
|
1928
|
+
notification.params.changes
|
|
1929
|
+
);
|
|
1930
|
+
return;
|
|
1931
|
+
case "item/mcpToolCall/progress":
|
|
1932
|
+
case "item/commandExecution/terminalInteraction":
|
|
1933
|
+
case "command/exec/outputDelta":
|
|
1934
|
+
case "process/outputDelta":
|
|
1935
|
+
case "process/exited":
|
|
1936
|
+
case "rawResponseItem/completed":
|
|
1937
|
+
case "hook/started":
|
|
1938
|
+
case "hook/completed":
|
|
1939
|
+
case "item/autoApprovalReview/started":
|
|
1940
|
+
case "item/autoApprovalReview/completed":
|
|
1941
|
+
return;
|
|
1942
|
+
case "thread/compacted":
|
|
1943
|
+
this.upsertItem(notification.params.turnId, {
|
|
1944
|
+
id: `compacted-${notification.params.turnId}`,
|
|
1945
|
+
type: "contextCompaction"
|
|
1946
|
+
});
|
|
1947
|
+
return;
|
|
1948
|
+
case "serverRequest/resolved":
|
|
1949
|
+
this.pendingRequests.delete(notification.params.requestId);
|
|
1950
|
+
this.resolvedRequestIds = appendUnique(
|
|
1951
|
+
this.resolvedRequestIds,
|
|
1952
|
+
notification.params.requestId
|
|
1953
|
+
);
|
|
1954
|
+
return;
|
|
1955
|
+
case "warning":
|
|
1956
|
+
this.warnings = appendUnique(this.warnings, notification.params.message);
|
|
1957
|
+
return;
|
|
1958
|
+
case "error":
|
|
1959
|
+
this.errors = appendUnique(this.errors, notification.params.error.message);
|
|
1960
|
+
return;
|
|
1961
|
+
case "guardianWarning":
|
|
1962
|
+
this.warnings = appendUnique(this.warnings, notification.params.message);
|
|
1963
|
+
return;
|
|
1964
|
+
case "deprecationNotice":
|
|
1965
|
+
this.warnings = appendUnique(this.warnings, notification.params.summary);
|
|
1966
|
+
return;
|
|
1967
|
+
case "configWarning":
|
|
1968
|
+
this.warnings = appendUnique(this.warnings, notification.params.summary);
|
|
1969
|
+
return;
|
|
1970
|
+
case "account/rateLimits/updated":
|
|
1971
|
+
this.accountRateLimits = { ...notification.params.rateLimits };
|
|
1972
|
+
return;
|
|
1973
|
+
case "thread/realtime/started":
|
|
1974
|
+
case "thread/realtime/itemAdded":
|
|
1975
|
+
case "thread/realtime/transcript/delta":
|
|
1976
|
+
case "thread/realtime/transcript/done":
|
|
1977
|
+
case "thread/realtime/outputAudio/delta":
|
|
1978
|
+
case "thread/realtime/sdp":
|
|
1979
|
+
case "thread/realtime/error":
|
|
1980
|
+
case "thread/realtime/closed":
|
|
1981
|
+
case "fs/changed":
|
|
1982
|
+
case "model/rerouted":
|
|
1983
|
+
case "model/verification":
|
|
1984
|
+
case "mcpServer/oauthLogin/completed":
|
|
1985
|
+
case "mcpServer/startupStatus/updated":
|
|
1986
|
+
case "fuzzyFileSearch/sessionUpdated":
|
|
1987
|
+
case "fuzzyFileSearch/sessionCompleted":
|
|
1988
|
+
case "windows/worldWritableWarning":
|
|
1989
|
+
case "windowsSandbox/setupCompleted":
|
|
1990
|
+
return;
|
|
1991
|
+
default:
|
|
1992
|
+
if (notificationThreadId(notification)) {
|
|
1993
|
+
this.warnings = appendUnique(
|
|
1994
|
+
this.warnings,
|
|
1995
|
+
`Unsupported Codex app-server notification: ${notification.method}`
|
|
1996
|
+
);
|
|
1997
|
+
}
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
noteRequest(request) {
|
|
2002
|
+
this.bufferedEvents = [...this.bufferedEvents, { request, type: "request" }];
|
|
2003
|
+
this.pendingRequests.set(request.id, request);
|
|
2004
|
+
}
|
|
2005
|
+
upsertTurn(turn) {
|
|
2006
|
+
const index = this.turns.findIndex((candidate) => candidate.id === turn.id);
|
|
2007
|
+
if (index === -1) {
|
|
2008
|
+
this.turns = [...this.turns, cloneTurn2(turn)];
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
const current = this.turns[index];
|
|
2012
|
+
this.turns = replaceAt(this.turns, index, {
|
|
2013
|
+
...current,
|
|
2014
|
+
...turn,
|
|
2015
|
+
items: turn.items.length > 0 ? turn.items.map(cloneThreadItem) : current.items
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
upsertItem(turnId, item) {
|
|
2019
|
+
const turn = this.ensureTurn(turnId);
|
|
2020
|
+
const itemIndex = turn.items.findIndex((candidate) => candidate.id === item.id);
|
|
2021
|
+
const nextItems = itemIndex === -1 ? [...turn.items, cloneThreadItem(item)] : replaceAt(turn.items, itemIndex, cloneThreadItem(item));
|
|
2022
|
+
this.replaceTurn({ ...turn, items: nextItems, itemsView: "full" });
|
|
2023
|
+
}
|
|
2024
|
+
applyAgentMessageDelta(turnId, itemId, delta) {
|
|
2025
|
+
const turn = this.ensureTurn(turnId);
|
|
2026
|
+
const item = turn.items.find((candidate) => candidate.id === itemId);
|
|
2027
|
+
if (item?.type === "agentMessage") {
|
|
2028
|
+
this.upsertItem(turnId, { ...item, text: `${item.text}${delta}` });
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
this.upsertItem(turnId, {
|
|
2032
|
+
id: itemId,
|
|
2033
|
+
memoryCitation: null,
|
|
2034
|
+
phase: "commentary",
|
|
2035
|
+
text: delta,
|
|
2036
|
+
type: "agentMessage"
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
applyPlanDelta(turnId, itemId, delta) {
|
|
2040
|
+
const turn = this.ensureTurn(turnId);
|
|
2041
|
+
const item = turn.items.find((candidate) => candidate.id === itemId);
|
|
2042
|
+
if (item?.type === "plan") {
|
|
2043
|
+
this.upsertItem(turnId, { ...item, text: `${item.text}${delta}` });
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
this.upsertItem(turnId, {
|
|
2047
|
+
id: itemId,
|
|
2048
|
+
text: delta,
|
|
2049
|
+
type: "plan"
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
applyReasoningSummaryPartAdded(turnId, itemId, summaryIndex) {
|
|
2053
|
+
const item = this.reasoningItem(turnId, itemId);
|
|
2054
|
+
const summary = replaceAtOrAppend(item.summary, summaryIndex, "");
|
|
2055
|
+
this.upsertItem(turnId, { ...item, summary });
|
|
2056
|
+
}
|
|
2057
|
+
applyReasoningSummaryTextDelta(turnId, itemId, summaryIndex, delta) {
|
|
2058
|
+
const item = this.reasoningItem(turnId, itemId);
|
|
2059
|
+
const current = item.summary[summaryIndex] ?? "";
|
|
2060
|
+
const summary = replaceAtOrAppend(item.summary, summaryIndex, `${current}${delta}`);
|
|
2061
|
+
this.upsertItem(turnId, { ...item, summary });
|
|
2062
|
+
}
|
|
2063
|
+
applyReasoningTextDelta(turnId, itemId, contentIndex, delta) {
|
|
2064
|
+
const item = this.reasoningItem(turnId, itemId);
|
|
2065
|
+
const current = item.content[contentIndex] ?? "";
|
|
2066
|
+
const content = replaceAtOrAppend(item.content, contentIndex, `${current}${delta}`);
|
|
2067
|
+
this.upsertItem(turnId, { ...item, content });
|
|
2068
|
+
}
|
|
2069
|
+
applyCommandOutputDelta(turnId, itemId, delta) {
|
|
2070
|
+
const turn = this.ensureTurn(turnId);
|
|
2071
|
+
const item = turn.items.find((candidate) => candidate.id === itemId);
|
|
2072
|
+
if (item?.type !== "commandExecution") {
|
|
2073
|
+
return;
|
|
2074
|
+
}
|
|
2075
|
+
this.upsertItem(turnId, {
|
|
2076
|
+
...item,
|
|
2077
|
+
aggregatedOutput: `${item.aggregatedOutput ?? ""}${delta}`
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
applyFileChangePatchUpdated(turnId, itemId, changes) {
|
|
2081
|
+
const turn = this.ensureTurn(turnId);
|
|
2082
|
+
const item = turn.items.find((candidate) => candidate.id === itemId);
|
|
2083
|
+
if (item?.type !== "fileChange") {
|
|
2084
|
+
return;
|
|
2085
|
+
}
|
|
2086
|
+
this.upsertItem(turnId, { ...item, changes });
|
|
2087
|
+
}
|
|
2088
|
+
reasoningItem(turnId, itemId) {
|
|
2089
|
+
const turn = this.ensureTurn(turnId);
|
|
2090
|
+
const item = turn.items.find((candidate) => candidate.id === itemId);
|
|
2091
|
+
if (item?.type === "reasoning") {
|
|
2092
|
+
return item;
|
|
2093
|
+
}
|
|
2094
|
+
return {
|
|
2095
|
+
content: [],
|
|
2096
|
+
id: itemId,
|
|
2097
|
+
summary: [],
|
|
2098
|
+
type: "reasoning"
|
|
2099
|
+
};
|
|
2100
|
+
}
|
|
2101
|
+
ensureTurn(turnId) {
|
|
2102
|
+
const existing = this.turns.find((turn2) => turn2.id === turnId);
|
|
2103
|
+
if (existing) {
|
|
2104
|
+
return existing;
|
|
2105
|
+
}
|
|
2106
|
+
const turn = {
|
|
2107
|
+
completedAt: null,
|
|
2108
|
+
durationMs: null,
|
|
2109
|
+
error: null,
|
|
2110
|
+
id: turnId,
|
|
2111
|
+
items: [],
|
|
2112
|
+
itemsView: "full",
|
|
2113
|
+
startedAt: null,
|
|
2114
|
+
status: "inProgress"
|
|
2115
|
+
};
|
|
2116
|
+
this.turns = [...this.turns, turn];
|
|
2117
|
+
this.activeTurnIds.add(turnId);
|
|
2118
|
+
return turn;
|
|
2119
|
+
}
|
|
2120
|
+
replaceTurn(turn) {
|
|
2121
|
+
const index = this.turns.findIndex((candidate) => candidate.id === turn.id);
|
|
2122
|
+
this.turns = index === -1 ? [...this.turns, turn] : replaceAt(this.turns, index, turn);
|
|
2123
|
+
}
|
|
2124
|
+
};
|
|
2125
|
+
function applyServerNotificationToThreadEventStore(store, notification) {
|
|
2126
|
+
store.noteNotification(notification);
|
|
2127
|
+
return store.snapshot();
|
|
2128
|
+
}
|
|
2129
|
+
function applyServerRequestToThreadEventStore(store, request) {
|
|
2130
|
+
store.noteRequest(request);
|
|
2131
|
+
return store.snapshot();
|
|
2132
|
+
}
|
|
2133
|
+
function serverRequestThreadId(request) {
|
|
2134
|
+
if ("params" in request && request.params && typeof request.params === "object") {
|
|
2135
|
+
const threadId = request.params.threadId;
|
|
2136
|
+
return typeof threadId === "string" ? threadId : null;
|
|
2137
|
+
}
|
|
2138
|
+
return null;
|
|
2139
|
+
}
|
|
2140
|
+
function serverNotificationThreadTarget(notification) {
|
|
2141
|
+
const threadId = notificationThreadId(notification);
|
|
2142
|
+
if (!threadId) {
|
|
2143
|
+
return { type: "global" };
|
|
2144
|
+
}
|
|
2145
|
+
return isUuidLike(threadId) ? { threadId, type: "thread" } : { threadId, type: "invalid_thread_id" };
|
|
2146
|
+
}
|
|
2147
|
+
function threadEventSnapshotHasStarted(snapshot) {
|
|
2148
|
+
if (!snapshot) {
|
|
2149
|
+
return false;
|
|
2150
|
+
}
|
|
2151
|
+
return snapshot.turns.some((turn) => turn.items.length > 0) || snapshot.activeTurnIds.length > 0 || snapshot.pendingRequests.length > 0 || snapshot.warnings.length > 0 || snapshot.errors.length > 0;
|
|
2152
|
+
}
|
|
2153
|
+
function notificationThreadId(notification) {
|
|
2154
|
+
if (notification.method === "thread/started") {
|
|
2155
|
+
return notification.params.thread.id;
|
|
2156
|
+
}
|
|
2157
|
+
if ("params" in notification && notification.params && typeof notification.params === "object") {
|
|
2158
|
+
const threadId = notification.params.threadId;
|
|
2159
|
+
return typeof threadId === "string" ? threadId : null;
|
|
2160
|
+
}
|
|
2161
|
+
return null;
|
|
2162
|
+
}
|
|
2163
|
+
function cloneThread(thread) {
|
|
2164
|
+
return {
|
|
2165
|
+
...thread,
|
|
2166
|
+
turns: thread.turns.map(cloneTurn2)
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
function cloneTurn2(turn) {
|
|
2170
|
+
return {
|
|
2171
|
+
...turn,
|
|
2172
|
+
items: turn.items.map(cloneThreadItem)
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2175
|
+
function cloneThreadItem(item) {
|
|
2176
|
+
return { ...item };
|
|
2177
|
+
}
|
|
2178
|
+
function cloneThreadTokenUsage(tokenUsage) {
|
|
2179
|
+
return {
|
|
2180
|
+
last: { ...tokenUsage.last },
|
|
2181
|
+
modelContextWindow: tokenUsage.modelContextWindow,
|
|
2182
|
+
total: { ...tokenUsage.total }
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2185
|
+
function replaceAt(items, index, item) {
|
|
2186
|
+
return [...items.slice(0, index), item, ...items.slice(index + 1)];
|
|
2187
|
+
}
|
|
2188
|
+
function replaceAtOrAppend(items, index, item) {
|
|
2189
|
+
if (index < items.length) {
|
|
2190
|
+
return replaceAt(items, index, item);
|
|
2191
|
+
}
|
|
2192
|
+
return [...items, item];
|
|
2193
|
+
}
|
|
2194
|
+
function appendUnique(items, item) {
|
|
2195
|
+
return items.includes(item) ? [...items] : [...items, item];
|
|
2196
|
+
}
|
|
2197
|
+
function isUuidLike(value) {
|
|
2198
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(value);
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
// src/internal/codex/app-server-client/src/lib.ts
|
|
2202
|
+
async function requestTyped(request, send) {
|
|
2203
|
+
try {
|
|
2204
|
+
return await send(request);
|
|
2205
|
+
} catch (source) {
|
|
2206
|
+
if (isJsonRpcError(source)) {
|
|
2207
|
+
throw {
|
|
2208
|
+
method: request.method,
|
|
2209
|
+
source,
|
|
2210
|
+
type: "server"
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
throw {
|
|
2214
|
+
method: request.method,
|
|
2215
|
+
source,
|
|
2216
|
+
type: "transport"
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
function serverNotificationRequiresDelivery(notification) {
|
|
2221
|
+
return notification.method === "turn/completed" || notification.method === "item/completed" || notification.method === "item/agentMessage/delta" || notification.method === "item/plan/delta" || notification.method === "item/reasoning/summaryTextDelta" || notification.method === "item/reasoning/textDelta";
|
|
2222
|
+
}
|
|
2223
|
+
function requestMethodName(request) {
|
|
2224
|
+
return request.method;
|
|
2225
|
+
}
|
|
2226
|
+
function isJsonRpcError(value) {
|
|
2227
|
+
return typeof value === "object" && value !== null && typeof value.code === "number" && typeof value.message === "string";
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
// src/internal/codex/core/src/model-provider.ts
|
|
2231
|
+
var defaultCodexModel = "gpt-5.5";
|
|
2232
|
+
var defaultCodexReasoningEffort = "medium";
|
|
2233
|
+
var DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT = 95;
|
|
2234
|
+
var reasoningOptions = [
|
|
2235
|
+
{ reasoning_effort: "low", description: "Fast responses with lighter reasoning." },
|
|
2236
|
+
{ reasoning_effort: "medium", description: "Balanced speed and reasoning depth." },
|
|
2237
|
+
{ reasoning_effort: "high", description: "Deeper reasoning for complex planning." },
|
|
2238
|
+
{ reasoning_effort: "xhigh", description: "Maximum reasoning depth for hard tasks." }
|
|
2239
|
+
];
|
|
2240
|
+
var StaticModelsManager = class {
|
|
2241
|
+
models;
|
|
2242
|
+
constructor(models = defaultCodexModelInfo()) {
|
|
2243
|
+
this.models = [...models];
|
|
2244
|
+
}
|
|
2245
|
+
list_models(params = {}) {
|
|
2246
|
+
const presets = this.build_available_models();
|
|
2247
|
+
const visible = params.include_hidden ? presets : presets.filter((model) => !model.hidden);
|
|
2248
|
+
const total = visible.length;
|
|
2249
|
+
const limit = Math.max(1, Math.min(total || 1, params.limit ?? (total || 1)));
|
|
2250
|
+
const start = params.cursor ? Number.parseInt(params.cursor, 10) : 0;
|
|
2251
|
+
if (!Number.isInteger(start) || start < 0 || start > total) {
|
|
2252
|
+
throw new Error(`invalid cursor: ${params.cursor}`);
|
|
2253
|
+
}
|
|
2254
|
+
const end = Math.min(total, start + limit);
|
|
2255
|
+
return {
|
|
2256
|
+
data: visible.slice(start, end),
|
|
2257
|
+
next_cursor: end < total ? String(end) : null
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
raw_model_catalog() {
|
|
2261
|
+
return { models: [...this.models] };
|
|
2262
|
+
}
|
|
2263
|
+
get_model_info(model) {
|
|
2264
|
+
return findModelByLongestPrefix(model, this.models) ?? findModelByNamespacedSuffix(model, this.models) ?? modelInfoFromSlug(model);
|
|
2265
|
+
}
|
|
2266
|
+
get_default_model(model) {
|
|
2267
|
+
if (model) {
|
|
2268
|
+
return model;
|
|
2269
|
+
}
|
|
2270
|
+
const selected = this.build_available_models().find((preset) => preset.is_default);
|
|
2271
|
+
return selected?.model ?? this.build_available_models()[0]?.model ?? defaultCodexModel;
|
|
2272
|
+
}
|
|
2273
|
+
default_reasoning_effort(model) {
|
|
2274
|
+
const info = this.get_model_info(this.get_default_model(model));
|
|
2275
|
+
return info.default_reasoning_level ?? defaultCodexReasoningEffort;
|
|
2276
|
+
}
|
|
2277
|
+
build_available_models() {
|
|
2278
|
+
const sorted = [...this.models].sort((left, right) => left.priority - right.priority);
|
|
2279
|
+
const presets = sorted.map(modelInfoToPreset);
|
|
2280
|
+
markDefaultByPickerVisibility(presets);
|
|
2281
|
+
return presets;
|
|
2282
|
+
}
|
|
2283
|
+
};
|
|
2284
|
+
function defaultModelsManager() {
|
|
2285
|
+
return new StaticModelsManager();
|
|
2286
|
+
}
|
|
2287
|
+
function defaultCodexModelInfo() {
|
|
2288
|
+
return [
|
|
2289
|
+
{
|
|
2290
|
+
slug: "gpt-5.5",
|
|
2291
|
+
display_name: "GPT-5.5",
|
|
2292
|
+
description: "Frontier model for complex planning and implementation.",
|
|
2293
|
+
default_reasoning_level: defaultCodexReasoningEffort,
|
|
2294
|
+
supported_reasoning_levels: reasoningOptions,
|
|
2295
|
+
visibility: "list",
|
|
2296
|
+
supported_in_api: true,
|
|
2297
|
+
priority: 0,
|
|
2298
|
+
upgrade: null,
|
|
2299
|
+
upgrade_info: null,
|
|
2300
|
+
availability_nux: null,
|
|
2301
|
+
input_modalities: ["text", "image"],
|
|
2302
|
+
supports_personality: true,
|
|
2303
|
+
additional_speed_tiers: [],
|
|
2304
|
+
service_tiers: [],
|
|
2305
|
+
base_instructions: BASE_INSTRUCTIONS_DEFAULT,
|
|
2306
|
+
model_messages: null,
|
|
2307
|
+
context_window: 272e3,
|
|
2308
|
+
max_context_window: null,
|
|
2309
|
+
auto_compact_token_limit: null,
|
|
2310
|
+
effective_context_window_percent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT
|
|
2311
|
+
},
|
|
2312
|
+
{
|
|
2313
|
+
slug: "gpt-5.4",
|
|
2314
|
+
display_name: "GPT-5.4",
|
|
2315
|
+
description: "Strong everyday model for coding and product work.",
|
|
2316
|
+
default_reasoning_level: defaultCodexReasoningEffort,
|
|
2317
|
+
supported_reasoning_levels: reasoningOptions,
|
|
2318
|
+
visibility: "list",
|
|
2319
|
+
supported_in_api: true,
|
|
2320
|
+
priority: 1,
|
|
2321
|
+
upgrade: null,
|
|
2322
|
+
upgrade_info: null,
|
|
2323
|
+
availability_nux: null,
|
|
2324
|
+
input_modalities: ["text", "image"],
|
|
2325
|
+
supports_personality: true,
|
|
2326
|
+
additional_speed_tiers: [],
|
|
2327
|
+
service_tiers: [],
|
|
2328
|
+
base_instructions: BASE_INSTRUCTIONS_DEFAULT,
|
|
2329
|
+
model_messages: null,
|
|
2330
|
+
context_window: 272e3,
|
|
2331
|
+
max_context_window: null,
|
|
2332
|
+
auto_compact_token_limit: null,
|
|
2333
|
+
effective_context_window_percent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT
|
|
2334
|
+
},
|
|
2335
|
+
{
|
|
2336
|
+
slug: "gpt-5.4-mini",
|
|
2337
|
+
display_name: "GPT-5.4 Mini",
|
|
2338
|
+
description: "Faster, smaller model for simple chat and iteration.",
|
|
2339
|
+
default_reasoning_level: defaultCodexReasoningEffort,
|
|
2340
|
+
supported_reasoning_levels: reasoningOptions.filter(
|
|
2341
|
+
(option) => option.reasoning_effort !== "xhigh"
|
|
2342
|
+
),
|
|
2343
|
+
visibility: "list",
|
|
2344
|
+
supported_in_api: true,
|
|
2345
|
+
priority: 2,
|
|
2346
|
+
upgrade: null,
|
|
2347
|
+
upgrade_info: null,
|
|
2348
|
+
availability_nux: null,
|
|
2349
|
+
input_modalities: ["text", "image"],
|
|
2350
|
+
supports_personality: true,
|
|
2351
|
+
additional_speed_tiers: [],
|
|
2352
|
+
service_tiers: [],
|
|
2353
|
+
base_instructions: BASE_INSTRUCTIONS_DEFAULT,
|
|
2354
|
+
model_messages: null,
|
|
2355
|
+
context_window: 128e3,
|
|
2356
|
+
max_context_window: null,
|
|
2357
|
+
auto_compact_token_limit: null,
|
|
2358
|
+
effective_context_window_percent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT
|
|
2359
|
+
}
|
|
2360
|
+
];
|
|
2361
|
+
}
|
|
2362
|
+
function modelInfoToPreset(info) {
|
|
2363
|
+
return {
|
|
2364
|
+
id: info.slug,
|
|
2365
|
+
model: info.slug,
|
|
2366
|
+
upgrade: info.upgrade,
|
|
2367
|
+
upgrade_info: info.upgrade_info,
|
|
2368
|
+
availability_nux: info.availability_nux,
|
|
2369
|
+
display_name: info.display_name,
|
|
2370
|
+
description: info.description ?? info.display_name,
|
|
2371
|
+
hidden: info.visibility !== "list",
|
|
2372
|
+
supported_reasoning_efforts: info.supported_reasoning_levels,
|
|
2373
|
+
default_reasoning_effort: info.default_reasoning_level ?? defaultCodexReasoningEffort,
|
|
2374
|
+
input_modalities: info.input_modalities,
|
|
2375
|
+
supports_personality: info.supports_personality,
|
|
2376
|
+
additional_speed_tiers: info.additional_speed_tiers,
|
|
2377
|
+
service_tiers: info.service_tiers,
|
|
2378
|
+
is_default: false,
|
|
2379
|
+
supported_in_api: info.supported_in_api
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2382
|
+
function modelInfoFromSlug(slug) {
|
|
2383
|
+
const known = defaultCodexModelInfo().find((model) => model.slug === slug);
|
|
2384
|
+
if (known) {
|
|
2385
|
+
return known;
|
|
2386
|
+
}
|
|
2387
|
+
return {
|
|
2388
|
+
slug,
|
|
2389
|
+
display_name: slug,
|
|
2390
|
+
description: null,
|
|
2391
|
+
default_reasoning_level: defaultCodexReasoningEffort,
|
|
2392
|
+
supported_reasoning_levels: reasoningOptions,
|
|
2393
|
+
visibility: "none",
|
|
2394
|
+
supported_in_api: true,
|
|
2395
|
+
priority: 99,
|
|
2396
|
+
upgrade: null,
|
|
2397
|
+
upgrade_info: null,
|
|
2398
|
+
availability_nux: null,
|
|
2399
|
+
input_modalities: ["text", "image"],
|
|
2400
|
+
supports_personality: false,
|
|
2401
|
+
additional_speed_tiers: [],
|
|
2402
|
+
service_tiers: [],
|
|
2403
|
+
base_instructions: BASE_INSTRUCTIONS_DEFAULT,
|
|
2404
|
+
model_messages: null,
|
|
2405
|
+
context_window: null,
|
|
2406
|
+
max_context_window: null,
|
|
2407
|
+
auto_compact_token_limit: null,
|
|
2408
|
+
effective_context_window_percent: DEFAULT_EFFECTIVE_CONTEXT_WINDOW_PERCENT
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
function isReasoningEffortSupported(model, effort, manager = defaultModelsManager()) {
|
|
2412
|
+
if (!effort) {
|
|
2413
|
+
return false;
|
|
2414
|
+
}
|
|
2415
|
+
return manager.get_model_info(model).supported_reasoning_levels.some((option) => option.reasoning_effort === effort);
|
|
2416
|
+
}
|
|
2417
|
+
function resolveReasoningEffortForModel(model, effort, manager = defaultModelsManager()) {
|
|
2418
|
+
return isReasoningEffortSupported(model, effort, manager) ? effort : manager.default_reasoning_effort(model);
|
|
2419
|
+
}
|
|
2420
|
+
function markDefaultByPickerVisibility(presets) {
|
|
2421
|
+
for (const preset of presets) {
|
|
2422
|
+
preset.is_default = false;
|
|
2423
|
+
}
|
|
2424
|
+
const visibleDefault = presets.find((preset) => preset.model === defaultCodexModel && !preset.hidden) ?? presets.find((preset) => !preset.hidden) ?? presets[0];
|
|
2425
|
+
if (visibleDefault) {
|
|
2426
|
+
visibleDefault.is_default = true;
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
function findModelByLongestPrefix(model, candidates) {
|
|
2430
|
+
let best = null;
|
|
2431
|
+
for (const candidate of candidates) {
|
|
2432
|
+
if (!model.startsWith(candidate.slug)) {
|
|
2433
|
+
continue;
|
|
2434
|
+
}
|
|
2435
|
+
if (!best || candidate.slug.length > best.slug.length) {
|
|
2436
|
+
best = candidate;
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
return best;
|
|
2440
|
+
}
|
|
2441
|
+
function findModelByNamespacedSuffix(model, candidates) {
|
|
2442
|
+
const [namespace, suffix, extra] = model.split("/");
|
|
2443
|
+
if (!namespace || !suffix || extra) {
|
|
2444
|
+
return null;
|
|
2445
|
+
}
|
|
2446
|
+
if (!/^[A-Za-z0-9_-]+$/.test(namespace)) {
|
|
2447
|
+
return null;
|
|
2448
|
+
}
|
|
2449
|
+
return findModelByLongestPrefix(suffix, candidates);
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
// src/internal/codex/core/src/ids.ts
|
|
2453
|
+
function asThreadId(value) {
|
|
2454
|
+
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
2455
|
+
if (!uuidPattern.test(value)) {
|
|
2456
|
+
throw new Error(`Invalid ThreadId: ${value}`);
|
|
2457
|
+
}
|
|
2458
|
+
return value;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
// src/internal/codex/app-server/src/request_processors/token_usage_replay.ts
|
|
2462
|
+
function latest_token_usage_turn_id_from_rollout_items(rolloutItems, turns) {
|
|
2463
|
+
const builder = new ThreadHistoryBuilder();
|
|
2464
|
+
let tokenUsageTurnOwner = null;
|
|
2465
|
+
for (const item of rolloutItems) {
|
|
2466
|
+
if (item.type === "event_msg" && item.payload.type === "token_count") {
|
|
2467
|
+
const turn = builder.active_turn_snapshot();
|
|
2468
|
+
tokenUsageTurnOwner = turn ? {
|
|
2469
|
+
id: appServerTurnFromCoreTurn(turn).id,
|
|
2470
|
+
position: builder.active_turn_position()
|
|
2471
|
+
} : null;
|
|
2472
|
+
}
|
|
2473
|
+
builder.handle_rollout_item(item);
|
|
2474
|
+
}
|
|
2475
|
+
if (!tokenUsageTurnOwner) {
|
|
2476
|
+
return null;
|
|
2477
|
+
}
|
|
2478
|
+
if (turns.some((turn) => turn.id === tokenUsageTurnOwner.id)) {
|
|
2479
|
+
return tokenUsageTurnOwner.id;
|
|
2480
|
+
}
|
|
2481
|
+
return tokenUsageTurnOwner.position === null ? null : turns[tokenUsageTurnOwner.position]?.id ?? null;
|
|
2482
|
+
}
|
|
2483
|
+
function latest_token_usage_turn_id(thread) {
|
|
2484
|
+
return [...thread.turns].reverse().find((turn) => turn.status === "completed" || turn.status === "failed")?.id ?? thread.turns.at(-1)?.id ?? "";
|
|
2485
|
+
}
|
|
2486
|
+
function last_token_info_from_rollout_items(rolloutItems) {
|
|
2487
|
+
for (let index = rolloutItems.length - 1; index >= 0; index -= 1) {
|
|
2488
|
+
const item = rolloutItems[index];
|
|
2489
|
+
if (item?.type === "event_msg" && item.payload.type === "token_count" && item.payload.info) {
|
|
2490
|
+
return item.payload.info;
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
return null;
|
|
2494
|
+
}
|
|
2495
|
+
function thread_token_usage_updated_notification_from_info(input) {
|
|
2496
|
+
const params = {
|
|
2497
|
+
threadId: String(input.threadId),
|
|
2498
|
+
turnId: input.tokenUsageTurnId ?? latest_token_usage_turn_id(input.thread),
|
|
2499
|
+
tokenUsage: threadTokenUsageFromTokenUsageInfo(input.tokenUsageInfo)
|
|
2500
|
+
};
|
|
2501
|
+
return {
|
|
2502
|
+
method: "thread/tokenUsage/updated",
|
|
2503
|
+
params
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
function thread_token_usage_updated_notification_from_rollout_items(input) {
|
|
2507
|
+
const tokenUsageInfo = last_token_info_from_rollout_items(input.rolloutItems);
|
|
2508
|
+
if (!tokenUsageInfo) {
|
|
2509
|
+
return null;
|
|
2510
|
+
}
|
|
2511
|
+
return thread_token_usage_updated_notification_from_info({
|
|
2512
|
+
thread: input.thread,
|
|
2513
|
+
threadId: input.threadId,
|
|
2514
|
+
tokenUsageInfo,
|
|
2515
|
+
tokenUsageTurnId: latest_token_usage_turn_id_from_rollout_items(
|
|
2516
|
+
input.rolloutItems,
|
|
2517
|
+
input.thread.turns
|
|
2518
|
+
)
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
export { AppServerSession, CodexAppServerClientTransportError, PendingAppServerRequests, ThreadEventStore, asThreadId, createCodexAppServerClient, defaultModelsManager, parseCodexAppServerEvent, requestMethodName, requestTyped, resolveReasoningEffortForModel, serverNotificationRequiresDelivery, serverNotificationThreadTarget, serverRequestThreadId, threadEventSnapshotHasStarted, thread_token_usage_updated_notification_from_rollout_items };
|