better-codex 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 +26 -0
- package/apps/backend/README.md +46 -0
- package/apps/backend/bun.lock +64 -0
- package/apps/backend/package.json +18 -0
- package/apps/backend/scripts/generate-protocol.ts +32 -0
- package/apps/backend/src/analytics/service.ts +219 -0
- package/apps/backend/src/analytics/store.ts +284 -0
- package/apps/backend/src/config.ts +98 -0
- package/apps/backend/src/core/app-server.ts +131 -0
- package/apps/backend/src/core/jsonrpc.ts +166 -0
- package/apps/backend/src/protocol/AbsolutePathBuf.ts +14 -0
- package/apps/backend/src/protocol/AddConversationListenerParams.ts +6 -0
- package/apps/backend/src/protocol/AddConversationSubscriptionResponse.ts +5 -0
- package/apps/backend/src/protocol/AgentMessageContent.ts +5 -0
- package/apps/backend/src/protocol/AgentMessageContentDeltaEvent.ts +5 -0
- package/apps/backend/src/protocol/AgentMessageDeltaEvent.ts +5 -0
- package/apps/backend/src/protocol/AgentMessageEvent.ts +5 -0
- package/apps/backend/src/protocol/AgentMessageItem.ts +6 -0
- package/apps/backend/src/protocol/AgentReasoningDeltaEvent.ts +5 -0
- package/apps/backend/src/protocol/AgentReasoningEvent.ts +5 -0
- package/apps/backend/src/protocol/AgentReasoningRawContentDeltaEvent.ts +5 -0
- package/apps/backend/src/protocol/AgentReasoningRawContentEvent.ts +5 -0
- package/apps/backend/src/protocol/AgentReasoningSectionBreakEvent.ts +5 -0
- package/apps/backend/src/protocol/Annotations.ts +9 -0
- package/apps/backend/src/protocol/ApplyPatchApprovalParams.ts +21 -0
- package/apps/backend/src/protocol/ApplyPatchApprovalRequestEvent.ts +23 -0
- package/apps/backend/src/protocol/ApplyPatchApprovalResponse.ts +6 -0
- package/apps/backend/src/protocol/ArchiveConversationParams.ts +6 -0
- package/apps/backend/src/protocol/ArchiveConversationResponse.ts +5 -0
- package/apps/backend/src/protocol/AskForApproval.ts +9 -0
- package/apps/backend/src/protocol/AudioContent.ts +9 -0
- package/apps/backend/src/protocol/AuthMode.ts +5 -0
- package/apps/backend/src/protocol/AuthStatusChangeNotification.ts +9 -0
- package/apps/backend/src/protocol/BackgroundEventEvent.ts +5 -0
- package/apps/backend/src/protocol/BlobResourceContents.ts +5 -0
- package/apps/backend/src/protocol/CallToolResult.ts +10 -0
- package/apps/backend/src/protocol/CancelLoginChatGptParams.ts +5 -0
- package/apps/backend/src/protocol/CancelLoginChatGptResponse.ts +5 -0
- package/apps/backend/src/protocol/ClientInfo.ts +5 -0
- package/apps/backend/src/protocol/ClientNotification.ts +5 -0
- package/apps/backend/src/protocol/ClientRequest.ts +46 -0
- package/apps/backend/src/protocol/CodexErrorInfo.ts +8 -0
- package/apps/backend/src/protocol/ContentBlock.ts +10 -0
- package/apps/backend/src/protocol/ContentItem.ts +5 -0
- package/apps/backend/src/protocol/ContextCompactedEvent.ts +5 -0
- package/apps/backend/src/protocol/ConversationGitInfo.ts +5 -0
- package/apps/backend/src/protocol/ConversationId.ts +5 -0
- package/apps/backend/src/protocol/ConversationSummary.ts +8 -0
- package/apps/backend/src/protocol/CreditsSnapshot.ts +5 -0
- package/apps/backend/src/protocol/CustomPrompt.ts +5 -0
- package/apps/backend/src/protocol/DeprecationNoticeEvent.ts +13 -0
- package/apps/backend/src/protocol/ElicitationRequestEvent.ts +6 -0
- package/apps/backend/src/protocol/EmbeddedResource.ts +13 -0
- package/apps/backend/src/protocol/EmbeddedResourceResource.ts +7 -0
- package/apps/backend/src/protocol/ErrorEvent.ts +6 -0
- package/apps/backend/src/protocol/EventMsg.ts +60 -0
- package/apps/backend/src/protocol/ExecApprovalRequestEvent.ts +32 -0
- package/apps/backend/src/protocol/ExecCommandApprovalParams.ts +12 -0
- package/apps/backend/src/protocol/ExecCommandApprovalResponse.ts +6 -0
- package/apps/backend/src/protocol/ExecCommandBeginEvent.ts +35 -0
- package/apps/backend/src/protocol/ExecCommandEndEvent.ts +59 -0
- package/apps/backend/src/protocol/ExecCommandOutputDeltaEvent.ts +18 -0
- package/apps/backend/src/protocol/ExecCommandSource.ts +5 -0
- package/apps/backend/src/protocol/ExecOneOffCommandParams.ts +6 -0
- package/apps/backend/src/protocol/ExecOneOffCommandResponse.ts +5 -0
- package/apps/backend/src/protocol/ExecOutputStream.ts +5 -0
- package/apps/backend/src/protocol/ExecPolicyAmendment.ts +12 -0
- package/apps/backend/src/protocol/ExitedReviewModeEvent.ts +6 -0
- package/apps/backend/src/protocol/FileChange.ts +5 -0
- package/apps/backend/src/protocol/ForcedLoginMethod.ts +5 -0
- package/apps/backend/src/protocol/FunctionCallOutputContentItem.ts +9 -0
- package/apps/backend/src/protocol/FunctionCallOutputPayload.ts +15 -0
- package/apps/backend/src/protocol/FuzzyFileSearchParams.ts +5 -0
- package/apps/backend/src/protocol/FuzzyFileSearchResponse.ts +6 -0
- package/apps/backend/src/protocol/FuzzyFileSearchResult.ts +8 -0
- package/apps/backend/src/protocol/GetAuthStatusParams.ts +5 -0
- package/apps/backend/src/protocol/GetAuthStatusResponse.ts +6 -0
- package/apps/backend/src/protocol/GetConversationSummaryParams.ts +6 -0
- package/apps/backend/src/protocol/GetConversationSummaryResponse.ts +6 -0
- package/apps/backend/src/protocol/GetHistoryEntryResponseEvent.ts +10 -0
- package/apps/backend/src/protocol/GetUserAgentResponse.ts +5 -0
- package/apps/backend/src/protocol/GetUserSavedConfigResponse.ts +6 -0
- package/apps/backend/src/protocol/GhostCommit.ts +8 -0
- package/apps/backend/src/protocol/GitDiffToRemoteParams.ts +5 -0
- package/apps/backend/src/protocol/GitDiffToRemoteResponse.ts +6 -0
- package/apps/backend/src/protocol/GitSha.ts +5 -0
- package/apps/backend/src/protocol/HistoryEntry.ts +5 -0
- package/apps/backend/src/protocol/ImageContent.ts +9 -0
- package/apps/backend/src/protocol/InitializeParams.ts +6 -0
- package/apps/backend/src/protocol/InitializeResponse.ts +5 -0
- package/apps/backend/src/protocol/InputItem.ts +5 -0
- package/apps/backend/src/protocol/InterruptConversationParams.ts +6 -0
- package/apps/backend/src/protocol/InterruptConversationResponse.ts +6 -0
- package/apps/backend/src/protocol/ItemCompletedEvent.ts +7 -0
- package/apps/backend/src/protocol/ItemStartedEvent.ts +7 -0
- package/apps/backend/src/protocol/ListConversationsParams.ts +5 -0
- package/apps/backend/src/protocol/ListConversationsResponse.ts +6 -0
- package/apps/backend/src/protocol/ListCustomPromptsResponseEvent.ts +9 -0
- package/apps/backend/src/protocol/ListSkillsResponseEvent.ts +9 -0
- package/apps/backend/src/protocol/LocalShellAction.ts +6 -0
- package/apps/backend/src/protocol/LocalShellExecAction.ts +5 -0
- package/apps/backend/src/protocol/LocalShellStatus.ts +5 -0
- package/apps/backend/src/protocol/LoginApiKeyParams.ts +5 -0
- package/apps/backend/src/protocol/LoginApiKeyResponse.ts +5 -0
- package/apps/backend/src/protocol/LoginChatGptCompleteNotification.ts +8 -0
- package/apps/backend/src/protocol/LoginChatGptResponse.ts +5 -0
- package/apps/backend/src/protocol/LogoutChatGptResponse.ts +5 -0
- package/apps/backend/src/protocol/McpAuthStatus.ts +5 -0
- package/apps/backend/src/protocol/McpInvocation.ts +18 -0
- package/apps/backend/src/protocol/McpListToolsResponseEvent.ts +25 -0
- package/apps/backend/src/protocol/McpStartupCompleteEvent.ts +6 -0
- package/apps/backend/src/protocol/McpStartupFailure.ts +5 -0
- package/apps/backend/src/protocol/McpStartupStatus.ts +5 -0
- package/apps/backend/src/protocol/McpStartupUpdateEvent.ts +14 -0
- package/apps/backend/src/protocol/McpToolCallBeginEvent.ts +10 -0
- package/apps/backend/src/protocol/McpToolCallEndEvent.ts +15 -0
- package/apps/backend/src/protocol/NetworkAccess.ts +8 -0
- package/apps/backend/src/protocol/NewConversationParams.ts +8 -0
- package/apps/backend/src/protocol/NewConversationResponse.ts +7 -0
- package/apps/backend/src/protocol/ParsedCommand.ts +12 -0
- package/apps/backend/src/protocol/PatchApplyBeginEvent.ts +23 -0
- package/apps/backend/src/protocol/PatchApplyEndEvent.ts +31 -0
- package/apps/backend/src/protocol/PlanItemArg.ts +6 -0
- package/apps/backend/src/protocol/PlanType.ts +5 -0
- package/apps/backend/src/protocol/Profile.ts +9 -0
- package/apps/backend/src/protocol/README.md +11 -0
- package/apps/backend/src/protocol/RateLimitSnapshot.ts +8 -0
- package/apps/backend/src/protocol/RateLimitWindow.ts +17 -0
- package/apps/backend/src/protocol/RawResponseItemEvent.ts +6 -0
- package/apps/backend/src/protocol/ReasoningContentDeltaEvent.ts +5 -0
- package/apps/backend/src/protocol/ReasoningEffort.ts +8 -0
- package/apps/backend/src/protocol/ReasoningItem.ts +5 -0
- package/apps/backend/src/protocol/ReasoningItemContent.ts +5 -0
- package/apps/backend/src/protocol/ReasoningItemReasoningSummary.ts +5 -0
- package/apps/backend/src/protocol/ReasoningRawContentDeltaEvent.ts +5 -0
- package/apps/backend/src/protocol/ReasoningSummary.ts +10 -0
- package/apps/backend/src/protocol/RemoveConversationListenerParams.ts +5 -0
- package/apps/backend/src/protocol/RemoveConversationSubscriptionResponse.ts +5 -0
- package/apps/backend/src/protocol/RequestId.ts +5 -0
- package/apps/backend/src/protocol/Resource.ts +9 -0
- package/apps/backend/src/protocol/ResourceLink.ts +11 -0
- package/apps/backend/src/protocol/ResourceTemplate.ts +9 -0
- package/apps/backend/src/protocol/ResponseItem.ts +17 -0
- package/apps/backend/src/protocol/ResumeConversationParams.ts +8 -0
- package/apps/backend/src/protocol/ResumeConversationResponse.ts +7 -0
- package/apps/backend/src/protocol/ReviewCodeLocation.ts +9 -0
- package/apps/backend/src/protocol/ReviewDecision.ts +9 -0
- package/apps/backend/src/protocol/ReviewFinding.ts +9 -0
- package/apps/backend/src/protocol/ReviewLineRange.ts +8 -0
- package/apps/backend/src/protocol/ReviewOutputEvent.ts +9 -0
- package/apps/backend/src/protocol/ReviewRequest.ts +9 -0
- package/apps/backend/src/protocol/ReviewTarget.ts +9 -0
- package/apps/backend/src/protocol/Role.ts +8 -0
- package/apps/backend/src/protocol/SandboxMode.ts +5 -0
- package/apps/backend/src/protocol/SandboxPolicy.ts +35 -0
- package/apps/backend/src/protocol/SandboxSettings.ts +6 -0
- package/apps/backend/src/protocol/SendUserMessageParams.ts +7 -0
- package/apps/backend/src/protocol/SendUserMessageResponse.ts +5 -0
- package/apps/backend/src/protocol/SendUserTurnParams.ts +11 -0
- package/apps/backend/src/protocol/SendUserTurnResponse.ts +5 -0
- package/apps/backend/src/protocol/ServerNotification.ts +36 -0
- package/apps/backend/src/protocol/ServerRequest.ts +13 -0
- package/apps/backend/src/protocol/SessionConfiguredEvent.ts +48 -0
- package/apps/backend/src/protocol/SessionConfiguredNotification.ts +8 -0
- package/apps/backend/src/protocol/SessionSource.ts +6 -0
- package/apps/backend/src/protocol/SetDefaultModelParams.ts +6 -0
- package/apps/backend/src/protocol/SetDefaultModelResponse.ts +5 -0
- package/apps/backend/src/protocol/SkillErrorInfo.ts +5 -0
- package/apps/backend/src/protocol/SkillMetadata.ts +6 -0
- package/apps/backend/src/protocol/SkillScope.ts +5 -0
- package/apps/backend/src/protocol/SkillsListEntry.ts +7 -0
- package/apps/backend/src/protocol/StepStatus.ts +5 -0
- package/apps/backend/src/protocol/StreamErrorEvent.ts +6 -0
- package/apps/backend/src/protocol/SubAgentSource.ts +5 -0
- package/apps/backend/src/protocol/TaskCompleteEvent.ts +5 -0
- package/apps/backend/src/protocol/TaskStartedEvent.ts +5 -0
- package/apps/backend/src/protocol/TerminalInteractionEvent.ts +17 -0
- package/apps/backend/src/protocol/TextContent.ts +9 -0
- package/apps/backend/src/protocol/TextResourceContents.ts +5 -0
- package/apps/backend/src/protocol/TokenCountEvent.ts +7 -0
- package/apps/backend/src/protocol/TokenUsage.ts +5 -0
- package/apps/backend/src/protocol/TokenUsageInfo.ts +6 -0
- package/apps/backend/src/protocol/Tool.ts +11 -0
- package/apps/backend/src/protocol/ToolAnnotations.ts +15 -0
- package/apps/backend/src/protocol/ToolInputSchema.ts +9 -0
- package/apps/backend/src/protocol/ToolOutputSchema.ts +10 -0
- package/apps/backend/src/protocol/Tools.ts +5 -0
- package/apps/backend/src/protocol/TurnAbortReason.ts +5 -0
- package/apps/backend/src/protocol/TurnAbortedEvent.ts +6 -0
- package/apps/backend/src/protocol/TurnDiffEvent.ts +5 -0
- package/apps/backend/src/protocol/TurnItem.ts +9 -0
- package/apps/backend/src/protocol/UndoCompletedEvent.ts +5 -0
- package/apps/backend/src/protocol/UndoStartedEvent.ts +5 -0
- package/apps/backend/src/protocol/UpdatePlanArgs.ts +6 -0
- package/apps/backend/src/protocol/UserInfoResponse.ts +5 -0
- package/apps/backend/src/protocol/UserInput.ts +8 -0
- package/apps/backend/src/protocol/UserMessageEvent.ts +5 -0
- package/apps/backend/src/protocol/UserMessageItem.ts +6 -0
- package/apps/backend/src/protocol/UserSavedConfig.ts +14 -0
- package/apps/backend/src/protocol/Verbosity.ts +9 -0
- package/apps/backend/src/protocol/ViewImageToolCallEvent.ts +13 -0
- package/apps/backend/src/protocol/WarningEvent.ts +5 -0
- package/apps/backend/src/protocol/WebSearchAction.ts +5 -0
- package/apps/backend/src/protocol/WebSearchBeginEvent.ts +5 -0
- package/apps/backend/src/protocol/WebSearchEndEvent.ts +5 -0
- package/apps/backend/src/protocol/WebSearchItem.ts +5 -0
- package/apps/backend/src/protocol/index.ts +198 -0
- package/apps/backend/src/protocol/serde_json/JsonValue.ts +5 -0
- package/apps/backend/src/protocol/v2/Account.ts +6 -0
- package/apps/backend/src/protocol/v2/AccountLoginCompletedNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/AccountRateLimitsUpdatedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/AccountUpdatedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/AgentMessageDeltaNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/ApprovalDecision.ts +6 -0
- package/apps/backend/src/protocol/v2/AskForApproval.ts +5 -0
- package/apps/backend/src/protocol/v2/CancelLoginAccountParams.ts +5 -0
- package/apps/backend/src/protocol/v2/CancelLoginAccountResponse.ts +6 -0
- package/apps/backend/src/protocol/v2/CancelLoginAccountStatus.ts +5 -0
- package/apps/backend/src/protocol/v2/CodexErrorInfo.ts +11 -0
- package/apps/backend/src/protocol/v2/CommandAction.ts +5 -0
- package/apps/backend/src/protocol/v2/CommandExecParams.ts +6 -0
- package/apps/backend/src/protocol/v2/CommandExecResponse.ts +5 -0
- package/apps/backend/src/protocol/v2/CommandExecutionOutputDeltaNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/CommandExecutionRequestApprovalParams.ts +14 -0
- package/apps/backend/src/protocol/v2/CommandExecutionRequestApprovalResponse.ts +6 -0
- package/apps/backend/src/protocol/v2/CommandExecutionStatus.ts +5 -0
- package/apps/backend/src/protocol/v2/Config.ts +15 -0
- package/apps/backend/src/protocol/v2/ConfigBatchWriteParams.ts +10 -0
- package/apps/backend/src/protocol/v2/ConfigEdit.ts +7 -0
- package/apps/backend/src/protocol/v2/ConfigLayer.ts +7 -0
- package/apps/backend/src/protocol/v2/ConfigLayerMetadata.ts +6 -0
- package/apps/backend/src/protocol/v2/ConfigLayerSource.ts +6 -0
- package/apps/backend/src/protocol/v2/ConfigReadParams.ts +5 -0
- package/apps/backend/src/protocol/v2/ConfigReadResponse.ts +8 -0
- package/apps/backend/src/protocol/v2/ConfigValueWriteParams.ts +11 -0
- package/apps/backend/src/protocol/v2/ConfigWriteResponse.ts +12 -0
- package/apps/backend/src/protocol/v2/ContextCompactedNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/CreditsSnapshot.ts +5 -0
- package/apps/backend/src/protocol/v2/DeprecationNoticeNotification.ts +13 -0
- package/apps/backend/src/protocol/v2/ErrorNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/ExecPolicyAmendment.ts +5 -0
- package/apps/backend/src/protocol/v2/FeedbackUploadParams.ts +5 -0
- package/apps/backend/src/protocol/v2/FeedbackUploadResponse.ts +5 -0
- package/apps/backend/src/protocol/v2/FileChangeOutputDeltaNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/FileChangeRequestApprovalParams.ts +14 -0
- package/apps/backend/src/protocol/v2/FileChangeRequestApprovalResponse.ts +6 -0
- package/apps/backend/src/protocol/v2/FileUpdateChange.ts +6 -0
- package/apps/backend/src/protocol/v2/GetAccountParams.ts +5 -0
- package/apps/backend/src/protocol/v2/GetAccountRateLimitsResponse.ts +6 -0
- package/apps/backend/src/protocol/v2/GetAccountResponse.ts +6 -0
- package/apps/backend/src/protocol/v2/GitInfo.ts +5 -0
- package/apps/backend/src/protocol/v2/ItemCompletedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/ItemStartedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/ListMcpServerStatusParams.ts +13 -0
- package/apps/backend/src/protocol/v2/ListMcpServerStatusResponse.ts +11 -0
- package/apps/backend/src/protocol/v2/LoginAccountParams.ts +5 -0
- package/apps/backend/src/protocol/v2/LoginAccountResponse.ts +9 -0
- package/apps/backend/src/protocol/v2/LogoutAccountResponse.ts +5 -0
- package/apps/backend/src/protocol/v2/McpAuthStatus.ts +5 -0
- package/apps/backend/src/protocol/v2/McpServerOauthLoginCompletedNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/McpServerOauthLoginParams.ts +5 -0
- package/apps/backend/src/protocol/v2/McpServerOauthLoginResponse.ts +5 -0
- package/apps/backend/src/protocol/v2/McpServerStatus.ts +9 -0
- package/apps/backend/src/protocol/v2/McpToolCallError.ts +5 -0
- package/apps/backend/src/protocol/v2/McpToolCallProgressNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/McpToolCallResult.ts +7 -0
- package/apps/backend/src/protocol/v2/McpToolCallStatus.ts +5 -0
- package/apps/backend/src/protocol/v2/MergeStrategy.ts +5 -0
- package/apps/backend/src/protocol/v2/Model.ts +7 -0
- package/apps/backend/src/protocol/v2/ModelListParams.ts +13 -0
- package/apps/backend/src/protocol/v2/ModelListResponse.ts +11 -0
- package/apps/backend/src/protocol/v2/NetworkAccess.ts +5 -0
- package/apps/backend/src/protocol/v2/OverriddenMetadata.ts +7 -0
- package/apps/backend/src/protocol/v2/PatchApplyStatus.ts +5 -0
- package/apps/backend/src/protocol/v2/PatchChangeKind.ts +5 -0
- package/apps/backend/src/protocol/v2/ProfileV2.ts +10 -0
- package/apps/backend/src/protocol/v2/RateLimitSnapshot.ts +8 -0
- package/apps/backend/src/protocol/v2/RateLimitWindow.ts +5 -0
- package/apps/backend/src/protocol/v2/RawResponseItemCompletedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/ReasoningEffortOption.ts +6 -0
- package/apps/backend/src/protocol/v2/ReasoningSummaryPartAddedNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/ReasoningSummaryTextDeltaNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/ReasoningTextDeltaNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/ReviewDelivery.ts +5 -0
- package/apps/backend/src/protocol/v2/ReviewStartParams.ts +12 -0
- package/apps/backend/src/protocol/v2/ReviewStartResponse.ts +13 -0
- package/apps/backend/src/protocol/v2/ReviewTarget.ts +9 -0
- package/apps/backend/src/protocol/v2/SandboxMode.ts +5 -0
- package/apps/backend/src/protocol/v2/SandboxPolicy.ts +7 -0
- package/apps/backend/src/protocol/v2/SandboxWorkspaceWrite.ts +5 -0
- package/apps/backend/src/protocol/v2/SessionSource.ts +5 -0
- package/apps/backend/src/protocol/v2/SkillErrorInfo.ts +5 -0
- package/apps/backend/src/protocol/v2/SkillMetadata.ts +6 -0
- package/apps/backend/src/protocol/v2/SkillScope.ts +5 -0
- package/apps/backend/src/protocol/v2/SkillsListEntry.ts +7 -0
- package/apps/backend/src/protocol/v2/SkillsListParams.ts +13 -0
- package/apps/backend/src/protocol/v2/SkillsListResponse.ts +6 -0
- package/apps/backend/src/protocol/v2/TerminalInteractionNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/Thread.ts +46 -0
- package/apps/backend/src/protocol/v2/ThreadArchiveParams.ts +5 -0
- package/apps/backend/src/protocol/v2/ThreadArchiveResponse.ts +5 -0
- package/apps/backend/src/protocol/v2/ThreadItem.ts +48 -0
- package/apps/backend/src/protocol/v2/ThreadListParams.ts +18 -0
- package/apps/backend/src/protocol/v2/ThreadListResponse.ts +11 -0
- package/apps/backend/src/protocol/v2/ThreadResumeParams.ts +35 -0
- package/apps/backend/src/protocol/v2/ThreadResumeResponse.ts +9 -0
- package/apps/backend/src/protocol/v2/ThreadStartParams.ts +15 -0
- package/apps/backend/src/protocol/v2/ThreadStartResponse.ts +9 -0
- package/apps/backend/src/protocol/v2/ThreadStartedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/ThreadTokenUsage.ts +6 -0
- package/apps/backend/src/protocol/v2/ThreadTokenUsageUpdatedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/TokenUsageBreakdown.ts +5 -0
- package/apps/backend/src/protocol/v2/ToolsV2.ts +5 -0
- package/apps/backend/src/protocol/v2/Turn.ts +18 -0
- package/apps/backend/src/protocol/v2/TurnCompletedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/TurnDiffUpdatedNotification.ts +9 -0
- package/apps/backend/src/protocol/v2/TurnError.ts +6 -0
- package/apps/backend/src/protocol/v2/TurnInterruptParams.ts +5 -0
- package/apps/backend/src/protocol/v2/TurnInterruptResponse.ts +5 -0
- package/apps/backend/src/protocol/v2/TurnPlanStep.ts +6 -0
- package/apps/backend/src/protocol/v2/TurnPlanStepStatus.ts +5 -0
- package/apps/backend/src/protocol/v2/TurnPlanUpdatedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/TurnStartParams.ts +34 -0
- package/apps/backend/src/protocol/v2/TurnStartResponse.ts +6 -0
- package/apps/backend/src/protocol/v2/TurnStartedNotification.ts +6 -0
- package/apps/backend/src/protocol/v2/TurnStatus.ts +5 -0
- package/apps/backend/src/protocol/v2/UserInput.ts +5 -0
- package/apps/backend/src/protocol/v2/WindowsWorldWritableWarningNotification.ts +5 -0
- package/apps/backend/src/protocol/v2/WriteStatus.ts +5 -0
- package/apps/backend/src/protocol/v2/index.ts +123 -0
- package/apps/backend/src/reviews/service.ts +27 -0
- package/apps/backend/src/reviews/store.ts +124 -0
- package/apps/backend/src/server.ts +531 -0
- package/apps/backend/src/services/profile-store.ts +114 -0
- package/apps/backend/src/services/supervisor.ts +102 -0
- package/apps/backend/src/thread-index/service.ts +75 -0
- package/apps/backend/src/thread-index/store.ts +195 -0
- package/apps/backend/src/ws/messages.ts +73 -0
- package/apps/backend/tsconfig.json +20 -0
- package/apps/web/README.md +24 -0
- package/apps/web/bun.lock +1062 -0
- package/apps/web/eslint.config.js +23 -0
- package/apps/web/index.html +16 -0
- package/apps/web/package.json +38 -0
- package/apps/web/src/app.tsx +83 -0
- package/apps/web/src/components/composer/slash-command-menu.tsx +47 -0
- package/apps/web/src/components/index.ts +2 -0
- package/apps/web/src/components/layout/account-usage-panel.tsx +167 -0
- package/apps/web/src/components/layout/analytics-view.tsx +296 -0
- package/apps/web/src/components/layout/index.ts +7 -0
- package/apps/web/src/components/layout/mobile-header.tsx +56 -0
- package/apps/web/src/components/layout/reviews-view.tsx +848 -0
- package/apps/web/src/components/layout/session-view.tsx +1374 -0
- package/apps/web/src/components/layout/settings-dialog.tsx +322 -0
- package/apps/web/src/components/layout/side-bar.tsx +417 -0
- package/apps/web/src/components/layout/thread-list.tsx +488 -0
- package/apps/web/src/components/layout/virtualized-message-list.tsx +748 -0
- package/apps/web/src/components/loading/startup-ascii.ts +652 -0
- package/apps/web/src/components/loading/startup-loader.tsx +37 -0
- package/apps/web/src/components/session-view/file-mention-menu.tsx +46 -0
- package/apps/web/src/components/session-view/session-auth-banner.tsx +61 -0
- package/apps/web/src/components/session-view/session-composer.tsx +328 -0
- package/apps/web/src/components/session-view/session-dialogs.tsx +280 -0
- package/apps/web/src/components/session-view/session-empty.tsx +47 -0
- package/apps/web/src/components/session-view/session-header.tsx +49 -0
- package/apps/web/src/components/ui/avatar.tsx +19 -0
- package/apps/web/src/components/ui/badge.tsx +21 -0
- package/apps/web/src/components/ui/button.tsx +47 -0
- package/apps/web/src/components/ui/collapsible-content.tsx +114 -0
- package/apps/web/src/components/ui/contribution-graph.tsx +182 -0
- package/apps/web/src/components/ui/dialog-box.tsx +203 -0
- package/apps/web/src/components/ui/icon-button.tsx +32 -0
- package/apps/web/src/components/ui/icons.tsx +187 -0
- package/apps/web/src/components/ui/index.tsx +15 -0
- package/apps/web/src/components/ui/input.tsx +43 -0
- package/apps/web/src/components/ui/markdown-stream.tsx +21 -0
- package/apps/web/src/components/ui/mobile-drawer.tsx +124 -0
- package/apps/web/src/components/ui/section-header.tsx +13 -0
- package/apps/web/src/components/ui/select.tsx +217 -0
- package/apps/web/src/components/ui/shimmer.tsx +138 -0
- package/apps/web/src/components/ui/status-dot.tsx +24 -0
- package/apps/web/src/config.ts +5 -0
- package/apps/web/src/hooks/index.ts +3 -0
- package/apps/web/src/hooks/use-analytics.ts +122 -0
- package/apps/web/src/hooks/use-hub-connection.ts +587 -0
- package/apps/web/src/hooks/use-mobile.ts +76 -0
- package/apps/web/src/hooks/use-thread-history.ts +210 -0
- package/apps/web/src/index.css +269 -0
- package/apps/web/src/main.tsx +10 -0
- package/apps/web/src/services/hub-client.ts +358 -0
- package/apps/web/src/store/index.ts +528 -0
- package/apps/web/src/types/index.ts +119 -0
- package/apps/web/src/utils/account-refresh.ts +168 -0
- package/apps/web/src/utils/approval-policy.ts +53 -0
- package/apps/web/src/utils/init-prompt.ts +41 -0
- package/apps/web/src/utils/item-format.ts +170 -0
- package/apps/web/src/utils/prompt-expander.ts +62 -0
- package/apps/web/src/utils/reasoning-summary.ts +48 -0
- package/apps/web/src/utils/slash-commands.ts +98 -0
- package/apps/web/tsconfig.app.json +28 -0
- package/apps/web/tsconfig.json +7 -0
- package/apps/web/tsconfig.node.json +26 -0
- package/apps/web/vite.config.ts +8 -0
- package/bin/better-codex.cjs +199 -0
- package/package.json +20 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { HUB_TOKEN, HUB_URL } from '../config'
|
|
2
|
+
|
|
3
|
+
export type HubProfile = {
|
|
4
|
+
id: string
|
|
5
|
+
name: string
|
|
6
|
+
codexHome: string
|
|
7
|
+
createdAt: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type PromptSummary = {
|
|
11
|
+
name: string
|
|
12
|
+
description?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type ThreadSearchResult = {
|
|
16
|
+
threadId: string
|
|
17
|
+
profileId: string
|
|
18
|
+
preview: string | null
|
|
19
|
+
modelProvider: string | null
|
|
20
|
+
createdAt: number | null
|
|
21
|
+
path: string | null
|
|
22
|
+
cwd: string | null
|
|
23
|
+
source: string | null
|
|
24
|
+
cliVersion: string | null
|
|
25
|
+
status: 'active' | 'archived'
|
|
26
|
+
archivedAt: number | null
|
|
27
|
+
lastSeenAt: number | null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ReviewSessionResult = {
|
|
31
|
+
id: string
|
|
32
|
+
threadId: string
|
|
33
|
+
profileId: string
|
|
34
|
+
label: string | null
|
|
35
|
+
status: 'pending' | 'running' | 'completed' | 'failed'
|
|
36
|
+
startedAt: number
|
|
37
|
+
completedAt: number | null
|
|
38
|
+
model: string | null
|
|
39
|
+
cwd: string | null
|
|
40
|
+
review: string | null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type WsEvent =
|
|
44
|
+
| {
|
|
45
|
+
type: 'rpc.event'
|
|
46
|
+
profileId: string
|
|
47
|
+
method: string
|
|
48
|
+
params?: unknown
|
|
49
|
+
}
|
|
50
|
+
| {
|
|
51
|
+
type: 'rpc.serverRequest'
|
|
52
|
+
profileId: string
|
|
53
|
+
id: number
|
|
54
|
+
method: string
|
|
55
|
+
params?: unknown
|
|
56
|
+
}
|
|
57
|
+
| {
|
|
58
|
+
type: 'profile.exit'
|
|
59
|
+
profileId: string
|
|
60
|
+
code: number | null
|
|
61
|
+
}
|
|
62
|
+
| {
|
|
63
|
+
type: 'profile.error'
|
|
64
|
+
profileId: string
|
|
65
|
+
message: string
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
type: 'profile.diagnostic'
|
|
69
|
+
profileId: string
|
|
70
|
+
message: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type WsResponse =
|
|
74
|
+
| {
|
|
75
|
+
type: 'rpc.response'
|
|
76
|
+
requestId: string
|
|
77
|
+
result?: unknown
|
|
78
|
+
error?: string
|
|
79
|
+
}
|
|
80
|
+
| {
|
|
81
|
+
type: 'profile.started'
|
|
82
|
+
profileId: string
|
|
83
|
+
}
|
|
84
|
+
| {
|
|
85
|
+
type: 'profile.stopped'
|
|
86
|
+
profileId: string
|
|
87
|
+
}
|
|
88
|
+
| {
|
|
89
|
+
type: 'error'
|
|
90
|
+
message: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type WsRequest =
|
|
94
|
+
| {
|
|
95
|
+
type: 'rpc.request'
|
|
96
|
+
requestId: string
|
|
97
|
+
profileId: string
|
|
98
|
+
method: string
|
|
99
|
+
params?: unknown
|
|
100
|
+
}
|
|
101
|
+
| {
|
|
102
|
+
type: 'rpc.response'
|
|
103
|
+
profileId: string
|
|
104
|
+
id: number
|
|
105
|
+
result?: unknown
|
|
106
|
+
error?: { code?: number; message: string }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type EventListener = (event: WsEvent) => void
|
|
110
|
+
|
|
111
|
+
type PendingRequest = {
|
|
112
|
+
resolve: (value: unknown) => void
|
|
113
|
+
reject: (reason: Error) => void
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const toWsUrl = (baseUrl: string, token: string) => {
|
|
117
|
+
const url = new URL('/ws', baseUrl)
|
|
118
|
+
url.searchParams.set('token', token)
|
|
119
|
+
return url.toString().replace(/^http/, 'ws')
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
class HubClient {
|
|
123
|
+
private ws: WebSocket | null = null
|
|
124
|
+
private readonly pending = new Map<string, PendingRequest>()
|
|
125
|
+
private readonly listeners = new Set<EventListener>()
|
|
126
|
+
|
|
127
|
+
async connect(): Promise<void> {
|
|
128
|
+
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
if (!HUB_TOKEN) {
|
|
132
|
+
throw new Error('Missing VITE_CODEX_HUB_TOKEN')
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const ws = new WebSocket(toWsUrl(HUB_URL, HUB_TOKEN))
|
|
136
|
+
this.ws = ws
|
|
137
|
+
|
|
138
|
+
ws.onmessage = (event) => {
|
|
139
|
+
const data = event.data
|
|
140
|
+
if (typeof data === 'string') {
|
|
141
|
+
this.handleMessage(data)
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
if (data instanceof Blob) {
|
|
145
|
+
data.text().then((text) => this.handleMessage(text))
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
if (data instanceof ArrayBuffer) {
|
|
149
|
+
const text = new TextDecoder().decode(data)
|
|
150
|
+
this.handleMessage(text)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
ws.onclose = () => {
|
|
155
|
+
this.ws = null
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
await new Promise<void>((resolve, reject) => {
|
|
159
|
+
ws.onopen = () => resolve()
|
|
160
|
+
ws.onerror = () => reject(new Error('WebSocket connection failed'))
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
disconnect(): void {
|
|
165
|
+
this.ws?.close()
|
|
166
|
+
this.ws = null
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async listProfiles(): Promise<HubProfile[]> {
|
|
170
|
+
const response = await fetch(`${HUB_URL}/profiles`)
|
|
171
|
+
if (!response.ok) {
|
|
172
|
+
throw new Error('Failed to load profiles')
|
|
173
|
+
}
|
|
174
|
+
const data = (await response.json()) as { profiles: HubProfile[] }
|
|
175
|
+
return data.profiles ?? []
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async createProfile(name?: string): Promise<HubProfile> {
|
|
179
|
+
const response = await fetch(`${HUB_URL}/profiles`, {
|
|
180
|
+
method: 'POST',
|
|
181
|
+
headers: { 'Content-Type': 'application/json' },
|
|
182
|
+
body: JSON.stringify({ name }),
|
|
183
|
+
})
|
|
184
|
+
if (!response.ok) {
|
|
185
|
+
throw new Error('Failed to create profile')
|
|
186
|
+
}
|
|
187
|
+
const data = (await response.json()) as { profile: HubProfile }
|
|
188
|
+
return data.profile
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async startProfile(profileId: string): Promise<void> {
|
|
192
|
+
const response = await fetch(`${HUB_URL}/profiles/${profileId}/start`, {
|
|
193
|
+
method: 'POST',
|
|
194
|
+
})
|
|
195
|
+
if (!response.ok) {
|
|
196
|
+
throw new Error('Failed to start profile')
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async stopProfile(profileId: string): Promise<void> {
|
|
201
|
+
const response = await fetch(`${HUB_URL}/profiles/${profileId}/stop`, {
|
|
202
|
+
method: 'POST',
|
|
203
|
+
})
|
|
204
|
+
if (!response.ok) {
|
|
205
|
+
throw new Error('Failed to stop profile')
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async deleteProfile(profileId: string): Promise<void> {
|
|
210
|
+
const response = await fetch(`${HUB_URL}/profiles/${profileId}`, {
|
|
211
|
+
method: 'DELETE',
|
|
212
|
+
})
|
|
213
|
+
if (!response.ok) {
|
|
214
|
+
throw new Error('Failed to remove profile')
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async listPrompts(profileId: string): Promise<PromptSummary[]> {
|
|
219
|
+
const response = await fetch(`${HUB_URL}/profiles/${profileId}/prompts`)
|
|
220
|
+
if (!response.ok) {
|
|
221
|
+
throw new Error('Failed to load prompts')
|
|
222
|
+
}
|
|
223
|
+
const data = (await response.json()) as { prompts: PromptSummary[] }
|
|
224
|
+
return data.prompts ?? []
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async readPrompt(profileId: string, name: string): Promise<string> {
|
|
228
|
+
const response = await fetch(`${HUB_URL}/profiles/${profileId}/prompts/${encodeURIComponent(name)}`)
|
|
229
|
+
if (!response.ok) {
|
|
230
|
+
throw new Error('Failed to load prompt')
|
|
231
|
+
}
|
|
232
|
+
const data = (await response.json()) as { content?: string }
|
|
233
|
+
return data.content ?? ''
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
async searchThreads(params: {
|
|
237
|
+
query?: string
|
|
238
|
+
profileId?: string
|
|
239
|
+
model?: string
|
|
240
|
+
status?: 'active' | 'archived'
|
|
241
|
+
createdAfter?: number
|
|
242
|
+
createdBefore?: number
|
|
243
|
+
limit?: number
|
|
244
|
+
offset?: number
|
|
245
|
+
}): Promise<ThreadSearchResult[]> {
|
|
246
|
+
const url = new URL('/threads/search', HUB_URL)
|
|
247
|
+
if (params.query) url.searchParams.set('q', params.query)
|
|
248
|
+
if (params.profileId) url.searchParams.set('profileId', params.profileId)
|
|
249
|
+
if (params.model) url.searchParams.set('model', params.model)
|
|
250
|
+
if (params.status) url.searchParams.set('status', params.status)
|
|
251
|
+
if (params.createdAfter) url.searchParams.set('createdAfter', String(params.createdAfter))
|
|
252
|
+
if (params.createdBefore) url.searchParams.set('createdBefore', String(params.createdBefore))
|
|
253
|
+
if (params.limit) url.searchParams.set('limit', String(params.limit))
|
|
254
|
+
if (params.offset) url.searchParams.set('offset', String(params.offset))
|
|
255
|
+
const response = await fetch(url.toString())
|
|
256
|
+
if (!response.ok) {
|
|
257
|
+
throw new Error('Failed to search threads')
|
|
258
|
+
}
|
|
259
|
+
const data = (await response.json()) as { threads?: ThreadSearchResult[] }
|
|
260
|
+
return data.threads ?? []
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async listReviews(params?: { profileId?: string; limit?: number; offset?: number }): Promise<ReviewSessionResult[]> {
|
|
264
|
+
const url = new URL('/reviews', HUB_URL)
|
|
265
|
+
if (params?.profileId) url.searchParams.set('profileId', params.profileId)
|
|
266
|
+
if (params?.limit) url.searchParams.set('limit', String(params.limit))
|
|
267
|
+
if (params?.offset) url.searchParams.set('offset', String(params.offset))
|
|
268
|
+
const response = await fetch(url.toString())
|
|
269
|
+
if (!response.ok) {
|
|
270
|
+
throw new Error('Failed to load reviews')
|
|
271
|
+
}
|
|
272
|
+
const data = (await response.json()) as { sessions?: ReviewSessionResult[] }
|
|
273
|
+
return data.sessions ?? []
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
async request(profileId: string, method: string, params?: unknown): Promise<unknown> {
|
|
277
|
+
if (!this.ws) {
|
|
278
|
+
console.error('[HubClient] WebSocket not connected')
|
|
279
|
+
throw new Error('WebSocket not connected')
|
|
280
|
+
}
|
|
281
|
+
const requestId = crypto.randomUUID()
|
|
282
|
+
const payload: WsRequest = { type: 'rpc.request', requestId, profileId, method, params }
|
|
283
|
+
// console.log('[HubClient] Sending request:', { profileId, method, requestId })
|
|
284
|
+
this.ws.send(JSON.stringify(payload))
|
|
285
|
+
return new Promise((resolve, reject) => {
|
|
286
|
+
const timeout = window.setTimeout(() => {
|
|
287
|
+
if (this.pending.has(requestId)) {
|
|
288
|
+
this.pending.delete(requestId)
|
|
289
|
+
console.error('[HubClient] Request timed out:', { profileId, method, requestId })
|
|
290
|
+
reject(new Error('Request timed out'))
|
|
291
|
+
}
|
|
292
|
+
}, 15000)
|
|
293
|
+
this.pending.set(requestId, {
|
|
294
|
+
resolve: (value) => {
|
|
295
|
+
window.clearTimeout(timeout)
|
|
296
|
+
// console.log('[HubClient] Response received:', { profileId, method, requestId })
|
|
297
|
+
resolve(value)
|
|
298
|
+
},
|
|
299
|
+
reject: (error) => {
|
|
300
|
+
window.clearTimeout(timeout)
|
|
301
|
+
console.error('[HubClient] Request error:', { profileId, method, requestId, error })
|
|
302
|
+
reject(error)
|
|
303
|
+
},
|
|
304
|
+
})
|
|
305
|
+
})
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
respond(profileId: string, id: number, result?: unknown, error?: { code?: number; message: string }) {
|
|
309
|
+
if (!this.ws) {
|
|
310
|
+
return
|
|
311
|
+
}
|
|
312
|
+
const payload: WsRequest = { type: 'rpc.response', profileId, id, result, error }
|
|
313
|
+
this.ws.send(JSON.stringify(payload))
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
onEvent(listener: EventListener): () => void {
|
|
317
|
+
this.listeners.add(listener)
|
|
318
|
+
return () => {
|
|
319
|
+
this.listeners.delete(listener)
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
private handleMessage(raw: string): void {
|
|
324
|
+
let payload: WsEvent | WsResponse | null = null
|
|
325
|
+
try {
|
|
326
|
+
payload = JSON.parse(raw) as WsEvent | WsResponse
|
|
327
|
+
} catch {
|
|
328
|
+
return
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (!payload) {
|
|
332
|
+
return
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (payload.type === 'rpc.response') {
|
|
336
|
+
const pending = this.pending.get(payload.requestId)
|
|
337
|
+
if (!pending) {
|
|
338
|
+
return
|
|
339
|
+
}
|
|
340
|
+
this.pending.delete(payload.requestId)
|
|
341
|
+
if (payload.error) {
|
|
342
|
+
pending.reject(new Error(payload.error))
|
|
343
|
+
} else {
|
|
344
|
+
pending.resolve(payload.result)
|
|
345
|
+
}
|
|
346
|
+
return
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (payload.type === 'error') {
|
|
350
|
+
console.error(payload.message)
|
|
351
|
+
return
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
this.listeners.forEach((listener) => listener(payload as WsEvent))
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export const hubClient = new HubClient()
|