mcp-codex-worker 0.1.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/README.md +135 -0
- package/bin/mcp-codex-worker.mjs +17 -0
- package/dist/src/app.d.ts +29 -0
- package/dist/src/app.js +353 -0
- package/dist/src/app.js.map +1 -0
- package/dist/src/config/defaults.d.ts +11 -0
- package/dist/src/config/defaults.js +12 -0
- package/dist/src/config/defaults.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +64 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/tool-definitions.d.ts +180 -0
- package/dist/src/mcp/tool-definitions.js +241 -0
- package/dist/src/mcp/tool-definitions.js.map +1 -0
- package/dist/src/services/app-server-client.d.ts +65 -0
- package/dist/src/services/app-server-client.js +511 -0
- package/dist/src/services/app-server-client.js.map +1 -0
- package/dist/src/services/codex-runtime.d.ts +84 -0
- package/dist/src/services/codex-runtime.js +371 -0
- package/dist/src/services/codex-runtime.js.map +1 -0
- package/dist/src/services/fleet-mode.d.ts +3 -0
- package/dist/src/services/fleet-mode.js +21 -0
- package/dist/src/services/fleet-mode.js.map +1 -0
- package/dist/src/services/model-catalog.d.ts +22 -0
- package/dist/src/services/model-catalog.js +51 -0
- package/dist/src/services/model-catalog.js.map +1 -0
- package/dist/src/services/profile-manager.d.ts +29 -0
- package/dist/src/services/profile-manager.js +82 -0
- package/dist/src/services/profile-manager.js.map +1 -0
- package/dist/src/types/codex.d.ts +50 -0
- package/dist/src/types/codex.js +2 -0
- package/dist/src/types/codex.js.map +1 -0
- package/package.json +53 -0
- package/src/app.ts +417 -0
- package/src/config/defaults.ts +14 -0
- package/src/index.ts +84 -0
- package/src/mcp/tool-definitions.ts +280 -0
- package/src/protocol/AbsolutePathBuf.ts +14 -0
- package/src/protocol/AgentPath.ts +5 -0
- package/src/protocol/ApplyPatchApprovalParams.ts +21 -0
- package/src/protocol/ApplyPatchApprovalResponse.ts +6 -0
- package/src/protocol/AuthMode.ts +8 -0
- package/src/protocol/ClientInfo.ts +5 -0
- package/src/protocol/ClientNotification.ts +5 -0
- package/src/protocol/ClientRequest.ts +67 -0
- package/src/protocol/CollaborationMode.ts +10 -0
- package/src/protocol/ContentItem.ts +5 -0
- package/src/protocol/ConversationGitInfo.ts +5 -0
- package/src/protocol/ConversationSummary.ts +8 -0
- package/src/protocol/ExecCommandApprovalParams.ts +16 -0
- package/src/protocol/ExecCommandApprovalResponse.ts +6 -0
- package/src/protocol/ExecPolicyAmendment.ts +12 -0
- package/src/protocol/FileChange.ts +5 -0
- package/src/protocol/ForcedLoginMethod.ts +5 -0
- package/src/protocol/FunctionCallOutputBody.ts +6 -0
- package/src/protocol/FunctionCallOutputContentItem.ts +10 -0
- package/src/protocol/FuzzyFileSearchMatchType.ts +5 -0
- package/src/protocol/FuzzyFileSearchParams.ts +5 -0
- package/src/protocol/FuzzyFileSearchResponse.ts +6 -0
- package/src/protocol/FuzzyFileSearchResult.ts +9 -0
- package/src/protocol/FuzzyFileSearchSessionCompletedNotification.ts +5 -0
- package/src/protocol/FuzzyFileSearchSessionUpdatedNotification.ts +6 -0
- package/src/protocol/GetAuthStatusParams.ts +5 -0
- package/src/protocol/GetAuthStatusResponse.ts +6 -0
- package/src/protocol/GetConversationSummaryParams.ts +6 -0
- package/src/protocol/GetConversationSummaryResponse.ts +6 -0
- package/src/protocol/GhostCommit.ts +8 -0
- package/src/protocol/GitDiffToRemoteParams.ts +5 -0
- package/src/protocol/GitDiffToRemoteResponse.ts +6 -0
- package/src/protocol/GitSha.ts +5 -0
- package/src/protocol/ImageDetail.ts +5 -0
- package/src/protocol/InitializeCapabilities.ts +17 -0
- package/src/protocol/InitializeParams.ts +7 -0
- package/src/protocol/InitializeResponse.ts +20 -0
- package/src/protocol/InputModality.ts +8 -0
- package/src/protocol/LocalShellAction.ts +6 -0
- package/src/protocol/LocalShellExecAction.ts +5 -0
- package/src/protocol/LocalShellStatus.ts +5 -0
- package/src/protocol/MessagePhase.ts +11 -0
- package/src/protocol/ModeKind.ts +8 -0
- package/src/protocol/NetworkPolicyAmendment.ts +6 -0
- package/src/protocol/NetworkPolicyRuleAction.ts +5 -0
- package/src/protocol/ParsedCommand.ts +12 -0
- package/src/protocol/Personality.ts +5 -0
- package/src/protocol/PlanType.ts +5 -0
- package/src/protocol/RealtimeConversationVersion.ts +5 -0
- package/src/protocol/ReasoningEffort.ts +8 -0
- package/src/protocol/ReasoningItemContent.ts +5 -0
- package/src/protocol/ReasoningItemReasoningSummary.ts +5 -0
- package/src/protocol/ReasoningSummary.ts +10 -0
- package/src/protocol/RequestId.ts +5 -0
- package/src/protocol/Resource.ts +9 -0
- package/src/protocol/ResourceTemplate.ts +9 -0
- package/src/protocol/ResponseItem.ts +18 -0
- package/src/protocol/ReviewDecision.ts +10 -0
- package/src/protocol/ServerNotification.ts +60 -0
- package/src/protocol/ServerRequest.ts +18 -0
- package/src/protocol/ServiceTier.ts +5 -0
- package/src/protocol/SessionSource.ts +6 -0
- package/src/protocol/Settings.ts +9 -0
- package/src/protocol/SubAgentSource.ts +7 -0
- package/src/protocol/ThreadId.ts +5 -0
- package/src/protocol/Tool.ts +9 -0
- package/src/protocol/Verbosity.ts +9 -0
- package/src/protocol/WebSearchAction.ts +5 -0
- package/src/protocol/WebSearchContextSize.ts +5 -0
- package/src/protocol/WebSearchLocation.ts +5 -0
- package/src/protocol/WebSearchMode.ts +5 -0
- package/src/protocol/WebSearchToolConfig.ts +7 -0
- package/src/protocol/index.ts +75 -0
- package/src/protocol/serde_json/JsonValue.ts +5 -0
- package/src/protocol/v2/Account.ts +6 -0
- package/src/protocol/v2/AccountLoginCompletedNotification.ts +5 -0
- package/src/protocol/v2/AccountRateLimitsUpdatedNotification.ts +6 -0
- package/src/protocol/v2/AccountUpdatedNotification.ts +7 -0
- package/src/protocol/v2/AdditionalFileSystemPermissions.ts +6 -0
- package/src/protocol/v2/AdditionalNetworkPermissions.ts +5 -0
- package/src/protocol/v2/AdditionalPermissionProfile.ts +7 -0
- package/src/protocol/v2/AgentMessageDeltaNotification.ts +5 -0
- package/src/protocol/v2/AnalyticsConfig.ts +6 -0
- package/src/protocol/v2/AppBranding.ts +8 -0
- package/src/protocol/v2/AppInfo.ts +19 -0
- package/src/protocol/v2/AppListUpdatedNotification.ts +9 -0
- package/src/protocol/v2/AppMetadata.ts +7 -0
- package/src/protocol/v2/AppReview.ts +5 -0
- package/src/protocol/v2/AppScreenshot.ts +5 -0
- package/src/protocol/v2/AppSummary.ts +8 -0
- package/src/protocol/v2/AppToolApproval.ts +5 -0
- package/src/protocol/v2/AppToolsConfig.ts +6 -0
- package/src/protocol/v2/ApprovalsReviewer.ts +12 -0
- package/src/protocol/v2/AppsConfig.ts +8 -0
- package/src/protocol/v2/AppsDefaultConfig.ts +5 -0
- package/src/protocol/v2/AppsListParams.ts +24 -0
- package/src/protocol/v2/AppsListResponse.ts +14 -0
- package/src/protocol/v2/AskForApproval.ts +5 -0
- package/src/protocol/v2/ByteRange.ts +5 -0
- package/src/protocol/v2/CancelLoginAccountParams.ts +5 -0
- package/src/protocol/v2/CancelLoginAccountResponse.ts +6 -0
- package/src/protocol/v2/CancelLoginAccountStatus.ts +5 -0
- package/src/protocol/v2/ChatgptAuthTokensRefreshParams.ts +16 -0
- package/src/protocol/v2/ChatgptAuthTokensRefreshReason.ts +5 -0
- package/src/protocol/v2/ChatgptAuthTokensRefreshResponse.ts +5 -0
- package/src/protocol/v2/CodexErrorInfo.ts +12 -0
- package/src/protocol/v2/CollabAgentState.ts +6 -0
- package/src/protocol/v2/CollabAgentStatus.ts +5 -0
- package/src/protocol/v2/CollabAgentTool.ts +5 -0
- package/src/protocol/v2/CollabAgentToolCallStatus.ts +5 -0
- package/src/protocol/v2/CollaborationModeMask.ts +10 -0
- package/src/protocol/v2/CommandAction.ts +5 -0
- package/src/protocol/v2/CommandExecOutputDeltaNotification.ts +30 -0
- package/src/protocol/v2/CommandExecOutputStream.ts +8 -0
- package/src/protocol/v2/CommandExecParams.ts +97 -0
- package/src/protocol/v2/CommandExecResizeParams.ts +18 -0
- package/src/protocol/v2/CommandExecResizeResponse.ts +8 -0
- package/src/protocol/v2/CommandExecResponse.ts +24 -0
- package/src/protocol/v2/CommandExecTerminalSize.ts +16 -0
- package/src/protocol/v2/CommandExecTerminateParams.ts +13 -0
- package/src/protocol/v2/CommandExecTerminateResponse.ts +8 -0
- package/src/protocol/v2/CommandExecWriteParams.ts +22 -0
- package/src/protocol/v2/CommandExecWriteResponse.ts +8 -0
- package/src/protocol/v2/CommandExecutionApprovalDecision.ts +7 -0
- package/src/protocol/v2/CommandExecutionOutputDeltaNotification.ts +5 -0
- package/src/protocol/v2/CommandExecutionRequestApprovalParams.ts +57 -0
- package/src/protocol/v2/CommandExecutionRequestApprovalResponse.ts +6 -0
- package/src/protocol/v2/CommandExecutionSource.ts +5 -0
- package/src/protocol/v2/CommandExecutionStatus.ts +5 -0
- package/src/protocol/v2/Config.ts +23 -0
- package/src/protocol/v2/ConfigBatchWriteParams.ts +14 -0
- package/src/protocol/v2/ConfigEdit.ts +7 -0
- package/src/protocol/v2/ConfigLayer.ts +7 -0
- package/src/protocol/v2/ConfigLayerMetadata.ts +6 -0
- package/src/protocol/v2/ConfigLayerSource.ts +16 -0
- package/src/protocol/v2/ConfigReadParams.ts +11 -0
- package/src/protocol/v2/ConfigReadResponse.ts +8 -0
- package/src/protocol/v2/ConfigRequirements.ts +9 -0
- package/src/protocol/v2/ConfigRequirementsReadResponse.ts +10 -0
- package/src/protocol/v2/ConfigValueWriteParams.ts +11 -0
- package/src/protocol/v2/ConfigWarningNotification.ts +22 -0
- package/src/protocol/v2/ConfigWriteResponse.ts +12 -0
- package/src/protocol/v2/ContextCompactedNotification.ts +8 -0
- package/src/protocol/v2/CreditsSnapshot.ts +5 -0
- package/src/protocol/v2/DeprecationNoticeNotification.ts +13 -0
- package/src/protocol/v2/DynamicToolCallOutputContentItem.ts +5 -0
- package/src/protocol/v2/DynamicToolCallParams.ts +6 -0
- package/src/protocol/v2/DynamicToolCallResponse.ts +6 -0
- package/src/protocol/v2/DynamicToolCallStatus.ts +5 -0
- package/src/protocol/v2/DynamicToolSpec.ts +6 -0
- package/src/protocol/v2/ErrorNotification.ts +6 -0
- package/src/protocol/v2/ExecPolicyAmendment.ts +5 -0
- package/src/protocol/v2/ExperimentalFeature.ts +37 -0
- package/src/protocol/v2/ExperimentalFeatureEnablementSetParams.ts +12 -0
- package/src/protocol/v2/ExperimentalFeatureEnablementSetResponse.ts +9 -0
- package/src/protocol/v2/ExperimentalFeatureListParams.ts +13 -0
- package/src/protocol/v2/ExperimentalFeatureListResponse.ts +11 -0
- package/src/protocol/v2/ExperimentalFeatureStage.ts +5 -0
- package/src/protocol/v2/ExternalAgentConfigDetectParams.ts +13 -0
- package/src/protocol/v2/ExternalAgentConfigDetectResponse.ts +6 -0
- package/src/protocol/v2/ExternalAgentConfigImportParams.ts +6 -0
- package/src/protocol/v2/ExternalAgentConfigImportResponse.ts +5 -0
- package/src/protocol/v2/ExternalAgentConfigMigrationItem.ts +10 -0
- package/src/protocol/v2/ExternalAgentConfigMigrationItemType.ts +5 -0
- package/src/protocol/v2/FeedbackUploadParams.ts +5 -0
- package/src/protocol/v2/FeedbackUploadResponse.ts +5 -0
- package/src/protocol/v2/FileChangeApprovalDecision.ts +5 -0
- package/src/protocol/v2/FileChangeOutputDeltaNotification.ts +5 -0
- package/src/protocol/v2/FileChangeRequestApprovalParams.ts +14 -0
- package/src/protocol/v2/FileChangeRequestApprovalResponse.ts +6 -0
- package/src/protocol/v2/FileUpdateChange.ts +6 -0
- package/src/protocol/v2/FsChangedNotification.ts +17 -0
- package/src/protocol/v2/FsCopyParams.ts +21 -0
- package/src/protocol/v2/FsCopyResponse.ts +8 -0
- package/src/protocol/v2/FsCreateDirectoryParams.ts +17 -0
- package/src/protocol/v2/FsCreateDirectoryResponse.ts +8 -0
- package/src/protocol/v2/FsGetMetadataParams.ts +13 -0
- package/src/protocol/v2/FsGetMetadataResponse.ts +24 -0
- package/src/protocol/v2/FsReadDirectoryEntry.ts +20 -0
- package/src/protocol/v2/FsReadDirectoryParams.ts +13 -0
- package/src/protocol/v2/FsReadDirectoryResponse.ts +13 -0
- package/src/protocol/v2/FsReadFileParams.ts +13 -0
- package/src/protocol/v2/FsReadFileResponse.ts +12 -0
- package/src/protocol/v2/FsRemoveParams.ts +21 -0
- package/src/protocol/v2/FsRemoveResponse.ts +8 -0
- package/src/protocol/v2/FsUnwatchParams.ts +12 -0
- package/src/protocol/v2/FsUnwatchResponse.ts +8 -0
- package/src/protocol/v2/FsWatchParams.ts +13 -0
- package/src/protocol/v2/FsWatchResponse.ts +17 -0
- package/src/protocol/v2/FsWriteFileParams.ts +17 -0
- package/src/protocol/v2/FsWriteFileResponse.ts +8 -0
- package/src/protocol/v2/GetAccountParams.ts +13 -0
- package/src/protocol/v2/GetAccountRateLimitsResponse.ts +14 -0
- package/src/protocol/v2/GetAccountResponse.ts +6 -0
- package/src/protocol/v2/GitInfo.ts +5 -0
- package/src/protocol/v2/GrantedPermissionProfile.ts +7 -0
- package/src/protocol/v2/GuardianApprovalReview.ts +12 -0
- package/src/protocol/v2/GuardianApprovalReviewStatus.ts +8 -0
- package/src/protocol/v2/GuardianRiskLevel.ts +8 -0
- package/src/protocol/v2/HookCompletedNotification.ts +6 -0
- package/src/protocol/v2/HookEventName.ts +5 -0
- package/src/protocol/v2/HookExecutionMode.ts +5 -0
- package/src/protocol/v2/HookHandlerType.ts +5 -0
- package/src/protocol/v2/HookOutputEntry.ts +6 -0
- package/src/protocol/v2/HookOutputEntryKind.ts +5 -0
- package/src/protocol/v2/HookPromptFragment.ts +5 -0
- package/src/protocol/v2/HookRunStatus.ts +5 -0
- package/src/protocol/v2/HookRunSummary.ts +11 -0
- package/src/protocol/v2/HookScope.ts +5 -0
- package/src/protocol/v2/HookStartedNotification.ts +6 -0
- package/src/protocol/v2/ItemCompletedNotification.ts +6 -0
- package/src/protocol/v2/ItemGuardianApprovalReviewCompletedNotification.ts +15 -0
- package/src/protocol/v2/ItemGuardianApprovalReviewStartedNotification.ts +15 -0
- package/src/protocol/v2/ItemStartedNotification.ts +6 -0
- package/src/protocol/v2/ListMcpServerStatusParams.ts +13 -0
- package/src/protocol/v2/ListMcpServerStatusResponse.ts +11 -0
- package/src/protocol/v2/LoginAccountParams.ts +21 -0
- package/src/protocol/v2/LoginAccountResponse.ts +17 -0
- package/src/protocol/v2/LogoutAccountResponse.ts +5 -0
- package/src/protocol/v2/MarketplaceInterface.ts +5 -0
- package/src/protocol/v2/MarketplaceLoadErrorInfo.ts +6 -0
- package/src/protocol/v2/McpAuthStatus.ts +5 -0
- package/src/protocol/v2/McpElicitationArrayType.ts +5 -0
- package/src/protocol/v2/McpElicitationBooleanSchema.ts +6 -0
- package/src/protocol/v2/McpElicitationBooleanType.ts +5 -0
- package/src/protocol/v2/McpElicitationConstOption.ts +5 -0
- package/src/protocol/v2/McpElicitationEnumSchema.ts +8 -0
- package/src/protocol/v2/McpElicitationLegacyTitledEnumSchema.ts +6 -0
- package/src/protocol/v2/McpElicitationMultiSelectEnumSchema.ts +7 -0
- package/src/protocol/v2/McpElicitationNumberSchema.ts +6 -0
- package/src/protocol/v2/McpElicitationNumberType.ts +5 -0
- package/src/protocol/v2/McpElicitationObjectType.ts +5 -0
- package/src/protocol/v2/McpElicitationPrimitiveSchema.ts +9 -0
- package/src/protocol/v2/McpElicitationSchema.ts +13 -0
- package/src/protocol/v2/McpElicitationSingleSelectEnumSchema.ts +7 -0
- package/src/protocol/v2/McpElicitationStringFormat.ts +5 -0
- package/src/protocol/v2/McpElicitationStringSchema.ts +7 -0
- package/src/protocol/v2/McpElicitationStringType.ts +5 -0
- package/src/protocol/v2/McpElicitationTitledEnumItems.ts +6 -0
- package/src/protocol/v2/McpElicitationTitledMultiSelectEnumSchema.ts +7 -0
- package/src/protocol/v2/McpElicitationTitledSingleSelectEnumSchema.ts +7 -0
- package/src/protocol/v2/McpElicitationUntitledEnumItems.ts +6 -0
- package/src/protocol/v2/McpElicitationUntitledMultiSelectEnumSchema.ts +7 -0
- package/src/protocol/v2/McpElicitationUntitledSingleSelectEnumSchema.ts +6 -0
- package/src/protocol/v2/McpServerElicitationAction.ts +5 -0
- package/src/protocol/v2/McpServerElicitationRequestParams.ts +16 -0
- package/src/protocol/v2/McpServerElicitationRequestResponse.ts +17 -0
- package/src/protocol/v2/McpServerOauthLoginCompletedNotification.ts +5 -0
- package/src/protocol/v2/McpServerOauthLoginParams.ts +5 -0
- package/src/protocol/v2/McpServerOauthLoginResponse.ts +5 -0
- package/src/protocol/v2/McpServerRefreshResponse.ts +5 -0
- package/src/protocol/v2/McpServerStartupState.ts +5 -0
- package/src/protocol/v2/McpServerStatus.ts +9 -0
- package/src/protocol/v2/McpServerStatusUpdatedNotification.ts +6 -0
- package/src/protocol/v2/McpToolCallError.ts +5 -0
- package/src/protocol/v2/McpToolCallProgressNotification.ts +5 -0
- package/src/protocol/v2/McpToolCallResult.ts +6 -0
- package/src/protocol/v2/McpToolCallStatus.ts +5 -0
- package/src/protocol/v2/MemoryCitation.ts +6 -0
- package/src/protocol/v2/MemoryCitationEntry.ts +5 -0
- package/src/protocol/v2/MergeStrategy.ts +5 -0
- package/src/protocol/v2/Model.ts +10 -0
- package/src/protocol/v2/ModelAvailabilityNux.ts +5 -0
- package/src/protocol/v2/ModelListParams.ts +17 -0
- package/src/protocol/v2/ModelListResponse.ts +11 -0
- package/src/protocol/v2/ModelRerouteReason.ts +5 -0
- package/src/protocol/v2/ModelReroutedNotification.ts +6 -0
- package/src/protocol/v2/ModelUpgradeInfo.ts +5 -0
- package/src/protocol/v2/NetworkAccess.ts +5 -0
- package/src/protocol/v2/NetworkApprovalContext.ts +6 -0
- package/src/protocol/v2/NetworkApprovalProtocol.ts +5 -0
- package/src/protocol/v2/NetworkDomainPermission.ts +5 -0
- package/src/protocol/v2/NetworkPolicyAmendment.ts +6 -0
- package/src/protocol/v2/NetworkPolicyRuleAction.ts +5 -0
- package/src/protocol/v2/NetworkRequirements.ts +32 -0
- package/src/protocol/v2/NetworkUnixSocketPermission.ts +5 -0
- package/src/protocol/v2/NonSteerableTurnKind.ts +5 -0
- package/src/protocol/v2/OverriddenMetadata.ts +7 -0
- package/src/protocol/v2/PatchApplyStatus.ts +5 -0
- package/src/protocol/v2/PatchChangeKind.ts +5 -0
- package/src/protocol/v2/PermissionGrantScope.ts +5 -0
- package/src/protocol/v2/PermissionsRequestApprovalParams.ts +6 -0
- package/src/protocol/v2/PermissionsRequestApprovalResponse.ts +7 -0
- package/src/protocol/v2/PlanDeltaNotification.ts +9 -0
- package/src/protocol/v2/PluginAuthPolicy.ts +5 -0
- package/src/protocol/v2/PluginDetail.ts +9 -0
- package/src/protocol/v2/PluginInstallParams.ts +10 -0
- package/src/protocol/v2/PluginInstallPolicy.ts +5 -0
- package/src/protocol/v2/PluginInstallResponse.ts +7 -0
- package/src/protocol/v2/PluginInterface.ts +11 -0
- package/src/protocol/v2/PluginListParams.ts +16 -0
- package/src/protocol/v2/PluginListResponse.ts +7 -0
- package/src/protocol/v2/PluginMarketplaceEntry.ts +8 -0
- package/src/protocol/v2/PluginReadParams.ts +6 -0
- package/src/protocol/v2/PluginReadResponse.ts +6 -0
- package/src/protocol/v2/PluginSource.ts +6 -0
- package/src/protocol/v2/PluginSummary.ts +9 -0
- package/src/protocol/v2/PluginUninstallParams.ts +9 -0
- package/src/protocol/v2/PluginUninstallResponse.ts +5 -0
- package/src/protocol/v2/ProfileV2.ts +19 -0
- package/src/protocol/v2/RateLimitSnapshot.ts +8 -0
- package/src/protocol/v2/RateLimitWindow.ts +5 -0
- package/src/protocol/v2/RawResponseItemCompletedNotification.ts +6 -0
- package/src/protocol/v2/ReadOnlyAccess.ts +6 -0
- package/src/protocol/v2/ReasoningEffortOption.ts +6 -0
- package/src/protocol/v2/ReasoningSummaryPartAddedNotification.ts +5 -0
- package/src/protocol/v2/ReasoningSummaryTextDeltaNotification.ts +5 -0
- package/src/protocol/v2/ReasoningTextDeltaNotification.ts +5 -0
- package/src/protocol/v2/RequestPermissionProfile.ts +7 -0
- package/src/protocol/v2/ResidencyRequirement.ts +5 -0
- package/src/protocol/v2/ReviewDelivery.ts +5 -0
- package/src/protocol/v2/ReviewStartParams.ts +12 -0
- package/src/protocol/v2/ReviewStartResponse.ts +13 -0
- package/src/protocol/v2/ReviewTarget.ts +9 -0
- package/src/protocol/v2/SandboxMode.ts +5 -0
- package/src/protocol/v2/SandboxPolicy.ts +8 -0
- package/src/protocol/v2/SandboxWorkspaceWrite.ts +5 -0
- package/src/protocol/v2/ServerRequestResolvedNotification.ts +6 -0
- package/src/protocol/v2/SessionSource.ts +6 -0
- package/src/protocol/v2/SkillDependencies.ts +6 -0
- package/src/protocol/v2/SkillErrorInfo.ts +5 -0
- package/src/protocol/v2/SkillInterface.ts +5 -0
- package/src/protocol/v2/SkillMetadata.ts +12 -0
- package/src/protocol/v2/SkillScope.ts +5 -0
- package/src/protocol/v2/SkillSummary.ts +6 -0
- package/src/protocol/v2/SkillToolDependency.ts +5 -0
- package/src/protocol/v2/SkillsChangedNotification.ts +11 -0
- package/src/protocol/v2/SkillsConfigWriteParams.ts +14 -0
- package/src/protocol/v2/SkillsConfigWriteResponse.ts +5 -0
- package/src/protocol/v2/SkillsListEntry.ts +7 -0
- package/src/protocol/v2/SkillsListExtraRootsForCwd.ts +5 -0
- package/src/protocol/v2/SkillsListParams.ts +18 -0
- package/src/protocol/v2/SkillsListResponse.ts +6 -0
- package/src/protocol/v2/TerminalInteractionNotification.ts +5 -0
- package/src/protocol/v2/TextElement.ts +14 -0
- package/src/protocol/v2/TextPosition.ts +13 -0
- package/src/protocol/v2/TextRange.ts +6 -0
- package/src/protocol/v2/Thread.ts +72 -0
- package/src/protocol/v2/ThreadActiveFlag.ts +5 -0
- package/src/protocol/v2/ThreadArchiveParams.ts +5 -0
- package/src/protocol/v2/ThreadArchiveResponse.ts +5 -0
- package/src/protocol/v2/ThreadArchivedNotification.ts +5 -0
- package/src/protocol/v2/ThreadClosedNotification.ts +5 -0
- package/src/protocol/v2/ThreadCompactStartParams.ts +5 -0
- package/src/protocol/v2/ThreadCompactStartResponse.ts +5 -0
- package/src/protocol/v2/ThreadForkParams.ts +34 -0
- package/src/protocol/v2/ThreadForkResponse.ts +15 -0
- package/src/protocol/v2/ThreadItem.ts +100 -0
- package/src/protocol/v2/ThreadListParams.ts +43 -0
- package/src/protocol/v2/ThreadListResponse.ts +11 -0
- package/src/protocol/v2/ThreadLoadedListParams.ts +13 -0
- package/src/protocol/v2/ThreadLoadedListResponse.ts +14 -0
- package/src/protocol/v2/ThreadMetadataGitInfoUpdateParams.ts +20 -0
- package/src/protocol/v2/ThreadMetadataUpdateParams.ts +12 -0
- package/src/protocol/v2/ThreadMetadataUpdateResponse.ts +6 -0
- package/src/protocol/v2/ThreadNameUpdatedNotification.ts +5 -0
- package/src/protocol/v2/ThreadReadParams.ts +9 -0
- package/src/protocol/v2/ThreadReadResponse.ts +6 -0
- package/src/protocol/v2/ThreadRealtimeAudioChunk.ts +8 -0
- package/src/protocol/v2/ThreadRealtimeClosedNotification.ts +8 -0
- package/src/protocol/v2/ThreadRealtimeErrorNotification.ts +8 -0
- package/src/protocol/v2/ThreadRealtimeItemAddedNotification.ts +9 -0
- package/src/protocol/v2/ThreadRealtimeOutputAudioDeltaNotification.ts +9 -0
- package/src/protocol/v2/ThreadRealtimeStartedNotification.ts +9 -0
- package/src/protocol/v2/ThreadRealtimeTranscriptUpdatedNotification.ts +9 -0
- package/src/protocol/v2/ThreadResumeParams.ts +43 -0
- package/src/protocol/v2/ThreadResumeResponse.ts +15 -0
- package/src/protocol/v2/ThreadRollbackParams.ts +12 -0
- package/src/protocol/v2/ThreadRollbackResponse.ts +14 -0
- package/src/protocol/v2/ThreadSetNameParams.ts +5 -0
- package/src/protocol/v2/ThreadSetNameResponse.ts +5 -0
- package/src/protocol/v2/ThreadShellCommandParams.ts +12 -0
- package/src/protocol/v2/ThreadShellCommandResponse.ts +5 -0
- package/src/protocol/v2/ThreadSortKey.ts +5 -0
- package/src/protocol/v2/ThreadSourceKind.ts +5 -0
- package/src/protocol/v2/ThreadStartParams.ts +23 -0
- package/src/protocol/v2/ThreadStartResponse.ts +15 -0
- package/src/protocol/v2/ThreadStartedNotification.ts +6 -0
- package/src/protocol/v2/ThreadStatus.ts +6 -0
- package/src/protocol/v2/ThreadStatusChangedNotification.ts +6 -0
- package/src/protocol/v2/ThreadTokenUsage.ts +6 -0
- package/src/protocol/v2/ThreadTokenUsageUpdatedNotification.ts +6 -0
- package/src/protocol/v2/ThreadUnarchiveParams.ts +5 -0
- package/src/protocol/v2/ThreadUnarchiveResponse.ts +6 -0
- package/src/protocol/v2/ThreadUnarchivedNotification.ts +5 -0
- package/src/protocol/v2/ThreadUnsubscribeParams.ts +5 -0
- package/src/protocol/v2/ThreadUnsubscribeResponse.ts +6 -0
- package/src/protocol/v2/ThreadUnsubscribeStatus.ts +5 -0
- package/src/protocol/v2/TokenUsageBreakdown.ts +5 -0
- package/src/protocol/v2/ToolRequestUserInputAnswer.ts +8 -0
- package/src/protocol/v2/ToolRequestUserInputOption.ts +8 -0
- package/src/protocol/v2/ToolRequestUserInputParams.ts +9 -0
- package/src/protocol/v2/ToolRequestUserInputQuestion.ts +9 -0
- package/src/protocol/v2/ToolRequestUserInputResponse.ts +9 -0
- package/src/protocol/v2/ToolsV2.ts +6 -0
- package/src/protocol/v2/Turn.ts +18 -0
- package/src/protocol/v2/TurnCompletedNotification.ts +6 -0
- package/src/protocol/v2/TurnDiffUpdatedNotification.ts +9 -0
- package/src/protocol/v2/TurnError.ts +6 -0
- package/src/protocol/v2/TurnInterruptParams.ts +5 -0
- package/src/protocol/v2/TurnInterruptResponse.ts +5 -0
- package/src/protocol/v2/TurnPlanStep.ts +6 -0
- package/src/protocol/v2/TurnPlanStepStatus.ts +5 -0
- package/src/protocol/v2/TurnPlanUpdatedNotification.ts +6 -0
- package/src/protocol/v2/TurnStartParams.ts +54 -0
- package/src/protocol/v2/TurnStartResponse.ts +6 -0
- package/src/protocol/v2/TurnStartedNotification.ts +6 -0
- package/src/protocol/v2/TurnStatus.ts +5 -0
- package/src/protocol/v2/TurnSteerParams.ts +11 -0
- package/src/protocol/v2/TurnSteerResponse.ts +5 -0
- package/src/protocol/v2/UserInput.ts +10 -0
- package/src/protocol/v2/WebSearchAction.ts +5 -0
- package/src/protocol/v2/WindowsSandboxSetupCompletedNotification.ts +6 -0
- package/src/protocol/v2/WindowsSandboxSetupMode.ts +5 -0
- package/src/protocol/v2/WindowsSandboxSetupStartParams.ts +7 -0
- package/src/protocol/v2/WindowsSandboxSetupStartResponse.ts +5 -0
- package/src/protocol/v2/WindowsWorldWritableWarningNotification.ts +5 -0
- package/src/protocol/v2/WriteStatus.ts +5 -0
- package/src/protocol/v2/index.ts +346 -0
- package/src/services/app-server-client.ts +636 -0
- package/src/services/codex-runtime.ts +500 -0
- package/src/services/fleet-mode.ts +29 -0
- package/src/services/model-catalog.ts +86 -0
- package/src/services/profile-manager.ts +113 -0
- package/src/types/codex.ts +57 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { APP_NAME, APP_TITLE, OPERATION_BRIDGE_TIMEOUT_MS, OPERATION_POLL_INTERVAL_MS, REQUEST_TIMEOUT_MS, } from '../config/defaults.js';
|
|
4
|
+
const SERVER_REQUEST_METHODS = new Set([
|
|
5
|
+
'item/commandExecution/requestApproval',
|
|
6
|
+
'item/fileChange/requestApproval',
|
|
7
|
+
'item/tool/requestUserInput',
|
|
8
|
+
'mcpServer/elicitation/request',
|
|
9
|
+
'item/permissions/requestApproval',
|
|
10
|
+
'item/tool/call',
|
|
11
|
+
'account/chatgptAuthTokens/refresh',
|
|
12
|
+
'applyPatchApproval',
|
|
13
|
+
'execCommandApproval',
|
|
14
|
+
]);
|
|
15
|
+
const TURN_LIFECYCLE_METHODS = new Set([
|
|
16
|
+
'turn/start',
|
|
17
|
+
'turn/steer',
|
|
18
|
+
'review/start',
|
|
19
|
+
]);
|
|
20
|
+
function asObject(value) {
|
|
21
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
function requestIdKey(id) {
|
|
27
|
+
return typeof id === 'number' ? `n:${id}` : `s:${id}`;
|
|
28
|
+
}
|
|
29
|
+
export class AppServerClient extends EventEmitter {
|
|
30
|
+
options;
|
|
31
|
+
pendingRequests = new Map();
|
|
32
|
+
serverRequests = new Map();
|
|
33
|
+
operations = new Map();
|
|
34
|
+
operationsByRequestId = new Map();
|
|
35
|
+
threadEvents = new Map();
|
|
36
|
+
process;
|
|
37
|
+
nextRequestCounter = 1;
|
|
38
|
+
nextOperationCounter = 1;
|
|
39
|
+
buffer = '';
|
|
40
|
+
started = false;
|
|
41
|
+
constructor(options) {
|
|
42
|
+
super();
|
|
43
|
+
this.options = options;
|
|
44
|
+
}
|
|
45
|
+
async start() {
|
|
46
|
+
if (this.started) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const child = spawn(this.options.command, this.options.args, {
|
|
50
|
+
cwd: process.cwd(),
|
|
51
|
+
env: {
|
|
52
|
+
...this.options.env,
|
|
53
|
+
CODEX_HOME: this.options.codexHome,
|
|
54
|
+
},
|
|
55
|
+
stdio: 'pipe',
|
|
56
|
+
});
|
|
57
|
+
this.process = child;
|
|
58
|
+
this.started = true;
|
|
59
|
+
child.stdout.setEncoding('utf8');
|
|
60
|
+
child.stdout.on('data', (chunk) => this.consumeStdout(String(chunk)));
|
|
61
|
+
child.stderr.setEncoding('utf8');
|
|
62
|
+
child.stderr.on('data', (chunk) => {
|
|
63
|
+
this.emit('stderr', String(chunk));
|
|
64
|
+
});
|
|
65
|
+
child.on('exit', (code, signal) => {
|
|
66
|
+
const message = `Codex app-server exited (code=${String(code)}, signal=${String(signal)})`;
|
|
67
|
+
this.started = false;
|
|
68
|
+
this.process = undefined;
|
|
69
|
+
for (const binding of this.pendingRequests.values()) {
|
|
70
|
+
clearTimeout(binding.timeout);
|
|
71
|
+
binding.reject(new Error(message));
|
|
72
|
+
}
|
|
73
|
+
this.pendingRequests.clear();
|
|
74
|
+
this.emit('exit', { code, signal });
|
|
75
|
+
});
|
|
76
|
+
const initializeParams = {
|
|
77
|
+
clientInfo: {
|
|
78
|
+
name: this.options.appName ?? APP_NAME,
|
|
79
|
+
title: APP_TITLE,
|
|
80
|
+
version: this.options.appVersion ?? '0.0.0',
|
|
81
|
+
},
|
|
82
|
+
capabilities: {
|
|
83
|
+
experimentalApi: false,
|
|
84
|
+
optOutNotificationMethods: null,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
await this.request('initialize', initializeParams);
|
|
88
|
+
}
|
|
89
|
+
async stop() {
|
|
90
|
+
if (!this.process) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.process.kill('SIGTERM');
|
|
94
|
+
this.process = undefined;
|
|
95
|
+
this.started = false;
|
|
96
|
+
}
|
|
97
|
+
async request(method, params, options = {}) {
|
|
98
|
+
const sent = this.sendRequest(method, params, options.timeoutMs);
|
|
99
|
+
return sent.promise;
|
|
100
|
+
}
|
|
101
|
+
async requestWithBridge(method, params, options = {}) {
|
|
102
|
+
const sent = this.sendRequest(method, params, options.timeoutMs);
|
|
103
|
+
const operationId = `op-${this.nextOperationCounter++}`;
|
|
104
|
+
const requestIdKeyValue = requestIdKey(sent.requestId);
|
|
105
|
+
const threadId = options.threadId ?? this.extractThreadIdFromParams(params);
|
|
106
|
+
const waitsForTurnCompletion = TURN_LIFECYCLE_METHODS.has(method);
|
|
107
|
+
const operation = {
|
|
108
|
+
operationId,
|
|
109
|
+
requestId: sent.requestId,
|
|
110
|
+
method,
|
|
111
|
+
threadId,
|
|
112
|
+
startedAt: new Date().toISOString(),
|
|
113
|
+
status: 'running',
|
|
114
|
+
pendingRequestIds: [],
|
|
115
|
+
};
|
|
116
|
+
this.operations.set(operationId, operation);
|
|
117
|
+
this.operationsByRequestId.set(requestIdKeyValue, operationId);
|
|
118
|
+
sent.promise.then((result) => {
|
|
119
|
+
const current = this.operations.get(operationId);
|
|
120
|
+
if (!current) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
current.result = result;
|
|
124
|
+
const turnId = this.extractTurnId(result);
|
|
125
|
+
if (turnId) {
|
|
126
|
+
current.turnId = turnId;
|
|
127
|
+
}
|
|
128
|
+
if (!waitsForTurnCompletion) {
|
|
129
|
+
current.status = 'completed';
|
|
130
|
+
current.completedAt = new Date().toISOString();
|
|
131
|
+
}
|
|
132
|
+
}, (error) => {
|
|
133
|
+
const current = this.operations.get(operationId);
|
|
134
|
+
if (!current) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
current.status = 'failed';
|
|
138
|
+
current.completedAt = new Date().toISOString();
|
|
139
|
+
current.error = error instanceof Error ? error.message : String(error);
|
|
140
|
+
});
|
|
141
|
+
const bridgeTimeoutMs = options.bridgeTimeoutMs ?? OPERATION_BRIDGE_TIMEOUT_MS;
|
|
142
|
+
const result = await new Promise((resolve, reject) => {
|
|
143
|
+
let settled = false;
|
|
144
|
+
const cleanup = () => {
|
|
145
|
+
this.off('server-request', onServerRequest);
|
|
146
|
+
this.off('notification', onNotification);
|
|
147
|
+
clearTimeout(timeout);
|
|
148
|
+
};
|
|
149
|
+
const resolveOnce = (value) => {
|
|
150
|
+
if (settled) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
settled = true;
|
|
154
|
+
cleanup();
|
|
155
|
+
resolve(value);
|
|
156
|
+
};
|
|
157
|
+
const rejectOnce = (error) => {
|
|
158
|
+
if (settled) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
settled = true;
|
|
162
|
+
cleanup();
|
|
163
|
+
reject(error);
|
|
164
|
+
};
|
|
165
|
+
const snapshot = () => {
|
|
166
|
+
const current = this.operations.get(operationId);
|
|
167
|
+
return {
|
|
168
|
+
status: current?.status === 'completed' ? 'completed' : 'running',
|
|
169
|
+
operationId,
|
|
170
|
+
requestId: sent.requestId,
|
|
171
|
+
pendingRequestIds: [...(current?.pendingRequestIds ?? [])],
|
|
172
|
+
...(current?.result !== undefined ? { result: current.result } : {}),
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
const onServerRequest = (pending) => {
|
|
176
|
+
const current = this.operations.get(operationId);
|
|
177
|
+
if (!current || current.status !== 'running') {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const pendingThreadId = this.extractThreadIdFromParams(pending.params);
|
|
181
|
+
if (threadId && pendingThreadId && pendingThreadId !== threadId) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (!current.pendingRequestIds.some((id) => requestIdKey(id) === requestIdKey(pending.id))) {
|
|
185
|
+
current.pendingRequestIds.push(pending.id);
|
|
186
|
+
}
|
|
187
|
+
resolveOnce({
|
|
188
|
+
status: 'pending_request',
|
|
189
|
+
operationId,
|
|
190
|
+
requestId: sent.requestId,
|
|
191
|
+
pendingRequestIds: [...current.pendingRequestIds],
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
const onNotification = () => {
|
|
195
|
+
const current = this.operations.get(operationId);
|
|
196
|
+
if (!current || current.status === 'running') {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (current.status === 'failed') {
|
|
200
|
+
rejectOnce(new Error(current.error ?? `Operation ${operationId} failed.`));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
resolveOnce(snapshot());
|
|
204
|
+
};
|
|
205
|
+
this.on('server-request', onServerRequest);
|
|
206
|
+
this.on('notification', onNotification);
|
|
207
|
+
sent.promise.then((response) => {
|
|
208
|
+
const current = this.operations.get(operationId);
|
|
209
|
+
if (!waitsForTurnCompletion) {
|
|
210
|
+
resolveOnce({
|
|
211
|
+
status: 'completed',
|
|
212
|
+
operationId,
|
|
213
|
+
requestId: sent.requestId,
|
|
214
|
+
pendingRequestIds: [...(current?.pendingRequestIds ?? [])],
|
|
215
|
+
result: response,
|
|
216
|
+
});
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (current?.status === 'completed') {
|
|
220
|
+
resolveOnce(snapshot());
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (current?.status === 'failed') {
|
|
224
|
+
rejectOnce(new Error(current.error ?? `Operation ${operationId} failed.`));
|
|
225
|
+
}
|
|
226
|
+
}).catch((error) => {
|
|
227
|
+
rejectOnce(error);
|
|
228
|
+
});
|
|
229
|
+
const timeout = setTimeout(() => {
|
|
230
|
+
resolveOnce(snapshot());
|
|
231
|
+
}, bridgeTimeoutMs);
|
|
232
|
+
timeout.unref();
|
|
233
|
+
});
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
async waitForOperation(operationId, options = {}) {
|
|
237
|
+
const timeoutMs = options.timeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
238
|
+
const pollIntervalMs = options.pollIntervalMs ?? OPERATION_POLL_INTERVAL_MS;
|
|
239
|
+
const start = Date.now();
|
|
240
|
+
while (Date.now() - start <= timeoutMs) {
|
|
241
|
+
const operation = this.operations.get(operationId);
|
|
242
|
+
if (!operation) {
|
|
243
|
+
throw new Error(`Operation not found: ${operationId}`);
|
|
244
|
+
}
|
|
245
|
+
if (operation.status === 'completed' || operation.status === 'failed') {
|
|
246
|
+
return { ...operation, pendingRequestIds: [...operation.pendingRequestIds] };
|
|
247
|
+
}
|
|
248
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
249
|
+
}
|
|
250
|
+
throw new Error(`Timed out waiting for operation ${operationId}`);
|
|
251
|
+
}
|
|
252
|
+
getOperation(operationId) {
|
|
253
|
+
const operation = this.operations.get(operationId);
|
|
254
|
+
if (!operation) {
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
return { ...operation, pendingRequestIds: [...operation.pendingRequestIds] };
|
|
258
|
+
}
|
|
259
|
+
listOperations() {
|
|
260
|
+
return [...this.operations.values()].map((operation) => ({
|
|
261
|
+
...operation,
|
|
262
|
+
pendingRequestIds: [...operation.pendingRequestIds],
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
listServerRequests(includeResolved = false) {
|
|
266
|
+
return [...this.serverRequests.values()]
|
|
267
|
+
.filter((request) => includeResolved || request.status === 'pending')
|
|
268
|
+
.map((request) => ({ ...request }));
|
|
269
|
+
}
|
|
270
|
+
getServerRequest(id) {
|
|
271
|
+
const request = this.serverRequests.get(requestIdKey(id));
|
|
272
|
+
return request ? { ...request } : undefined;
|
|
273
|
+
}
|
|
274
|
+
async respondToServerRequest(id, payload) {
|
|
275
|
+
const requestKey = requestIdKey(id);
|
|
276
|
+
const request = this.serverRequests.get(requestKey);
|
|
277
|
+
if (!request) {
|
|
278
|
+
throw new Error(`Pending server request not found: ${String(id)}`);
|
|
279
|
+
}
|
|
280
|
+
if (!this.process || !this.started) {
|
|
281
|
+
throw new Error('Codex app-server is not running');
|
|
282
|
+
}
|
|
283
|
+
this.writeLine({
|
|
284
|
+
id,
|
|
285
|
+
result: payload,
|
|
286
|
+
});
|
|
287
|
+
request.response = payload;
|
|
288
|
+
request.status = 'resolved';
|
|
289
|
+
request.resolvedAt = new Date().toISOString();
|
|
290
|
+
}
|
|
291
|
+
getThreadEvents(threadId) {
|
|
292
|
+
return [...(this.threadEvents.get(threadId) ?? [])];
|
|
293
|
+
}
|
|
294
|
+
sendRequest(method, params, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
295
|
+
if (!this.process || !this.started) {
|
|
296
|
+
throw new Error('Codex app-server is not running');
|
|
297
|
+
}
|
|
298
|
+
const requestId = `client-${this.nextRequestCounter++}`;
|
|
299
|
+
const key = requestIdKey(requestId);
|
|
300
|
+
const promise = new Promise((resolve, reject) => {
|
|
301
|
+
const timeout = setTimeout(() => {
|
|
302
|
+
this.pendingRequests.delete(key);
|
|
303
|
+
reject(new Error(`Timed out waiting for ${method} response`));
|
|
304
|
+
}, timeoutMs);
|
|
305
|
+
timeout.unref();
|
|
306
|
+
this.pendingRequests.set(key, {
|
|
307
|
+
resolve,
|
|
308
|
+
reject,
|
|
309
|
+
timeout,
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
const message = { method, id: requestId, params };
|
|
313
|
+
this.writeLine(message);
|
|
314
|
+
return { requestId, promise };
|
|
315
|
+
}
|
|
316
|
+
consumeStdout(chunk) {
|
|
317
|
+
this.buffer += chunk;
|
|
318
|
+
while (true) {
|
|
319
|
+
const lineBreak = this.buffer.indexOf('\n');
|
|
320
|
+
if (lineBreak === -1) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const line = this.buffer.slice(0, lineBreak).trim();
|
|
324
|
+
this.buffer = this.buffer.slice(lineBreak + 1);
|
|
325
|
+
if (!line) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
let message;
|
|
329
|
+
try {
|
|
330
|
+
message = JSON.parse(line);
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
this.emit('parse-error', error);
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
this.handleMessage(message);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
handleMessage(message) {
|
|
340
|
+
const asResponse = asObject(message);
|
|
341
|
+
if (!asResponse) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const hasMethod = typeof asResponse.method === 'string';
|
|
345
|
+
const hasId = typeof asResponse.id === 'string' || typeof asResponse.id === 'number';
|
|
346
|
+
if (hasMethod && hasId) {
|
|
347
|
+
const request = message;
|
|
348
|
+
const key = requestIdKey(request.id);
|
|
349
|
+
if (this.pendingRequests.has(key)) {
|
|
350
|
+
this.resolveClientRequest(request.id, request);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
this.storeServerRequest(request);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (hasId) {
|
|
357
|
+
this.resolveClientRequest(message.id, message);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (hasMethod) {
|
|
361
|
+
this.handleNotification(message);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
resolveClientRequest(id, response) {
|
|
365
|
+
const key = requestIdKey(id);
|
|
366
|
+
const binding = this.pendingRequests.get(key);
|
|
367
|
+
if (!binding) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
clearTimeout(binding.timeout);
|
|
371
|
+
this.pendingRequests.delete(key);
|
|
372
|
+
if ('error' in response && response.error !== undefined) {
|
|
373
|
+
binding.reject(new Error(typeof response.error === 'string'
|
|
374
|
+
? response.error
|
|
375
|
+
: JSON.stringify(response.error)));
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
binding.resolve(response.result);
|
|
379
|
+
}
|
|
380
|
+
storeServerRequest(request) {
|
|
381
|
+
if (!SERVER_REQUEST_METHODS.has(request.method)) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const key = requestIdKey(request.id);
|
|
385
|
+
const pending = {
|
|
386
|
+
id: request.id,
|
|
387
|
+
method: request.method,
|
|
388
|
+
params: request.params,
|
|
389
|
+
createdAt: new Date().toISOString(),
|
|
390
|
+
status: 'pending',
|
|
391
|
+
};
|
|
392
|
+
this.serverRequests.set(key, pending);
|
|
393
|
+
this.emit('server-request', pending);
|
|
394
|
+
}
|
|
395
|
+
handleNotification(notification) {
|
|
396
|
+
if (notification.method === 'serverRequest/resolved') {
|
|
397
|
+
const params = asObject(notification.params);
|
|
398
|
+
const requestId = params?.requestId;
|
|
399
|
+
if (typeof requestId === 'string' || typeof requestId === 'number') {
|
|
400
|
+
const request = this.serverRequests.get(requestIdKey(requestId));
|
|
401
|
+
if (request) {
|
|
402
|
+
request.status = 'resolved';
|
|
403
|
+
request.resolvedAt = new Date().toISOString();
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
this.updateOperationsFromNotification(notification);
|
|
408
|
+
const threadId = this.extractThreadIdFromParams(notification.params);
|
|
409
|
+
if (threadId) {
|
|
410
|
+
const events = this.threadEvents.get(threadId) ?? [];
|
|
411
|
+
events.push({
|
|
412
|
+
receivedAt: new Date().toISOString(),
|
|
413
|
+
method: notification.method,
|
|
414
|
+
params: notification.params,
|
|
415
|
+
});
|
|
416
|
+
this.threadEvents.set(threadId, events.slice(-200));
|
|
417
|
+
}
|
|
418
|
+
this.emit('notification', notification);
|
|
419
|
+
}
|
|
420
|
+
updateOperationsFromNotification(notification) {
|
|
421
|
+
const threadId = this.extractThreadIdFromParams(notification.params);
|
|
422
|
+
if (!threadId) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (notification.method === 'turn/completed') {
|
|
426
|
+
const params = asObject(notification.params);
|
|
427
|
+
const turn = asObject(params?.turn);
|
|
428
|
+
const turnId = typeof turn?.id === 'string' ? turn.id : undefined;
|
|
429
|
+
const turnStatus = typeof turn?.status === 'string' ? turn.status : undefined;
|
|
430
|
+
for (const operation of this.operations.values()) {
|
|
431
|
+
if (operation.status !== 'running' || operation.threadId !== threadId || !TURN_LIFECYCLE_METHODS.has(operation.method)) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
if (turnId) {
|
|
435
|
+
operation.turnId = operation.turnId ?? turnId;
|
|
436
|
+
if (operation.turnId !== turnId) {
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (turnStatus === 'completed' || turnStatus === 'interrupted') {
|
|
441
|
+
operation.status = 'completed';
|
|
442
|
+
operation.completedAt = new Date().toISOString();
|
|
443
|
+
operation.result = { turn };
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
operation.status = 'failed';
|
|
447
|
+
operation.completedAt = new Date().toISOString();
|
|
448
|
+
operation.error = this.extractTurnError(turn) ?? `Turn finished with status ${turnStatus ?? 'unknown'}.`;
|
|
449
|
+
operation.result = { turn };
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (notification.method === 'error') {
|
|
455
|
+
const params = asObject(notification.params);
|
|
456
|
+
const message = typeof params?.message === 'string' ? params.message : 'Codex reported an error.';
|
|
457
|
+
for (const operation of this.operations.values()) {
|
|
458
|
+
if (operation.status === 'running' && operation.threadId === threadId && TURN_LIFECYCLE_METHODS.has(operation.method)) {
|
|
459
|
+
operation.status = 'failed';
|
|
460
|
+
operation.completedAt = new Date().toISOString();
|
|
461
|
+
operation.error = message;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
extractThreadIdFromParams(params) {
|
|
467
|
+
const object = asObject(params);
|
|
468
|
+
const threadId = object?.threadId;
|
|
469
|
+
if (typeof threadId === 'string') {
|
|
470
|
+
return threadId;
|
|
471
|
+
}
|
|
472
|
+
const thread = asObject(object?.thread);
|
|
473
|
+
const threadIdFromThread = thread?.id;
|
|
474
|
+
if (typeof threadIdFromThread === 'string') {
|
|
475
|
+
return threadIdFromThread;
|
|
476
|
+
}
|
|
477
|
+
return undefined;
|
|
478
|
+
}
|
|
479
|
+
extractTurnId(payload) {
|
|
480
|
+
const object = asObject(payload);
|
|
481
|
+
const turn = asObject(object?.turn);
|
|
482
|
+
if (typeof turn?.id === 'string') {
|
|
483
|
+
return turn.id;
|
|
484
|
+
}
|
|
485
|
+
if (typeof object?.turnId === 'string') {
|
|
486
|
+
return object.turnId;
|
|
487
|
+
}
|
|
488
|
+
return undefined;
|
|
489
|
+
}
|
|
490
|
+
extractTurnError(turn) {
|
|
491
|
+
if (!turn) {
|
|
492
|
+
return undefined;
|
|
493
|
+
}
|
|
494
|
+
const error = turn.error;
|
|
495
|
+
if (typeof error === 'string') {
|
|
496
|
+
return error;
|
|
497
|
+
}
|
|
498
|
+
const object = asObject(error);
|
|
499
|
+
if (typeof object?.message === 'string') {
|
|
500
|
+
return object.message;
|
|
501
|
+
}
|
|
502
|
+
return undefined;
|
|
503
|
+
}
|
|
504
|
+
writeLine(message) {
|
|
505
|
+
if (!this.process || !this.started) {
|
|
506
|
+
throw new Error('Codex app-server is not running');
|
|
507
|
+
}
|
|
508
|
+
this.process.stdin.write(`${JSON.stringify(message)}\n`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
//# sourceMappingURL=app-server-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-server-client.js","sourceRoot":"","sources":["../../../src/services/app-server-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAuC,MAAM,oBAAoB,CAAC;AAEhF,OAAO,EACL,QAAQ,EACR,SAAS,EACT,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAiD/B,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,uCAAuC;IACvC,iCAAiC;IACjC,4BAA4B;IAC5B,+BAA+B;IAC/B,kCAAkC;IAClC,gBAAgB;IAChB,mCAAmC;IACnC,oBAAoB;IACpB,qBAAqB;CACtB,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,YAAY;IACZ,YAAY;IACZ,cAAc;CACf,CAAC,CAAC;AAEH,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,KAAgC,CAAC;AAC1C,CAAC;AAED,SAAS,YAAY,CAAC,EAAa;IACjC,OAAO,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,EAA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AQ,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,CAAC;QACD,IAAI,OAAO,MAAM,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;YACvC,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,gBAAgB,CAAC,IAAyC;QAChE,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,OAAO,MAAM,EAAE,OAAO,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,SAAS,CAAC,OAA6D;QAC7E,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { PendingServerRequest } from '../types/codex.js';
|
|
2
|
+
import { type BridgedOperationResult } from './app-server-client.js';
|
|
3
|
+
import { type ModelInfo } from './model-catalog.js';
|
|
4
|
+
interface RuntimeRequestOptions {
|
|
5
|
+
timeoutMs?: number | undefined;
|
|
6
|
+
}
|
|
7
|
+
interface RuntimeBridgeOptions extends RuntimeRequestOptions {
|
|
8
|
+
threadId?: string | undefined;
|
|
9
|
+
bridgeTimeoutMs?: number | undefined;
|
|
10
|
+
}
|
|
11
|
+
interface RuntimeCommandOptions {
|
|
12
|
+
command?: string | undefined;
|
|
13
|
+
args?: string[] | undefined;
|
|
14
|
+
env?: NodeJS.ProcessEnv | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface ModelResolutionResult {
|
|
17
|
+
resolvedModel: string;
|
|
18
|
+
remappedFrom?: string | undefined;
|
|
19
|
+
allowedModels: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare class CodexRuntime {
|
|
22
|
+
private readonly profileManager;
|
|
23
|
+
private readonly command;
|
|
24
|
+
private readonly args;
|
|
25
|
+
private readonly env;
|
|
26
|
+
private readonly clients;
|
|
27
|
+
private readonly effectiveCodexHomes;
|
|
28
|
+
private modelCatalog?;
|
|
29
|
+
private readonly knownThreadIds;
|
|
30
|
+
private readonly loadedThreadIds;
|
|
31
|
+
constructor(commandOptions?: RuntimeCommandOptions);
|
|
32
|
+
shutdown(): Promise<void>;
|
|
33
|
+
getPendingServerRequests(includeResolved?: boolean): PendingServerRequest[];
|
|
34
|
+
getPendingServerRequest(id: string | number): PendingServerRequest | undefined;
|
|
35
|
+
respondToServerRequest(id: string | number, payload: unknown): Promise<void>;
|
|
36
|
+
waitForOperation(operationId: string, timeoutMs: number, pollIntervalMs: number): Promise<import("../types/codex.js").RuntimeOperation>;
|
|
37
|
+
getOperation(operationId: string): import("../types/codex.js").RuntimeOperation | undefined;
|
|
38
|
+
request(method: string, params: unknown, options?: RuntimeRequestOptions): Promise<unknown>;
|
|
39
|
+
requestWithBridge(method: string, params: unknown, options?: RuntimeBridgeOptions): Promise<BridgedOperationResult>;
|
|
40
|
+
listModels(includeHidden?: boolean): Promise<ModelInfo[]>;
|
|
41
|
+
resolveRequestedModel(requestedModel?: string | undefined): Promise<ModelResolutionResult>;
|
|
42
|
+
listVisibleModelIds(): Promise<string[]>;
|
|
43
|
+
buildThreadStartParams(input: {
|
|
44
|
+
model?: string | undefined;
|
|
45
|
+
cwd?: string | undefined;
|
|
46
|
+
developerInstructions?: string | undefined;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
params: Record<string, unknown>;
|
|
49
|
+
remappedFrom?: string | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
buildThreadResumeParams(input: {
|
|
52
|
+
threadId: string;
|
|
53
|
+
model?: string | undefined;
|
|
54
|
+
cwd?: string | undefined;
|
|
55
|
+
developerInstructions?: string | undefined;
|
|
56
|
+
}): Promise<{
|
|
57
|
+
params: Record<string, unknown>;
|
|
58
|
+
remappedFrom?: string | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
buildTurnStartParams(input: {
|
|
61
|
+
threadId: string;
|
|
62
|
+
userInput: string;
|
|
63
|
+
model?: string | undefined;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
params: Record<string, unknown>;
|
|
66
|
+
remappedFrom?: string | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
buildTurnSteerParams(input: {
|
|
69
|
+
threadId: string;
|
|
70
|
+
expectedTurnId: string;
|
|
71
|
+
userInput: string;
|
|
72
|
+
}): Record<string, unknown>;
|
|
73
|
+
getThreadEvents(threadId: string): Promise<unknown[]>;
|
|
74
|
+
rememberThreadId(threadId: string): void;
|
|
75
|
+
listKnownThreadIds(): string[];
|
|
76
|
+
ensureThreadLoaded(threadId: string, model?: string | undefined): Promise<void>;
|
|
77
|
+
private withFailover;
|
|
78
|
+
private getCurrentClient;
|
|
79
|
+
private getClient;
|
|
80
|
+
private activateCompatibilityClient;
|
|
81
|
+
private createCompatibilityHome;
|
|
82
|
+
private trackLoadedThread;
|
|
83
|
+
}
|
|
84
|
+
export {};
|