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,124 @@
|
|
|
1
|
+
import { useEffect, type ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
interface MobileDrawerProps {
|
|
4
|
+
open: boolean
|
|
5
|
+
onClose: () => void
|
|
6
|
+
children: ReactNode
|
|
7
|
+
side?: 'left' | 'right'
|
|
8
|
+
className?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function MobileDrawer({
|
|
12
|
+
open,
|
|
13
|
+
onClose,
|
|
14
|
+
children,
|
|
15
|
+
side = 'left',
|
|
16
|
+
className = ''
|
|
17
|
+
}: MobileDrawerProps) {
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (open) {
|
|
20
|
+
document.body.style.overflow = 'hidden'
|
|
21
|
+
return () => {
|
|
22
|
+
document.body.style.overflow = ''
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}, [open])
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const handleEscape = (e: KeyboardEvent) => {
|
|
29
|
+
if (e.key === 'Escape' && open) {
|
|
30
|
+
onClose()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
document.addEventListener('keydown', handleEscape)
|
|
34
|
+
return () => document.removeEventListener('keydown', handleEscape)
|
|
35
|
+
}, [open, onClose])
|
|
36
|
+
|
|
37
|
+
const translateClass = side === 'left'
|
|
38
|
+
? open ? 'translate-x-0' : '-translate-x-full'
|
|
39
|
+
: open ? 'translate-x-0' : 'translate-x-full'
|
|
40
|
+
|
|
41
|
+
const positionClass = side === 'left' ? 'left-0' : 'right-0'
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<div
|
|
46
|
+
className={`fixed inset-0 z-40 bg-black/60 backdrop-blur-mobile transition-opacity duration-300 ${
|
|
47
|
+
open ? 'opacity-100' : 'opacity-0 pointer-events-none'
|
|
48
|
+
}`}
|
|
49
|
+
onClick={onClose}
|
|
50
|
+
aria-hidden="true"
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<div
|
|
54
|
+
className={`fixed top-0 ${positionClass} z-50 w-[280px] max-w-[85vw] bg-bg-secondary border-r border-border transform transition-transform duration-300 ease-out ${translateClass} ${className}`}
|
|
55
|
+
style={{ height: 'calc(var(--vh, 1vh) * 100)' }}
|
|
56
|
+
role="dialog"
|
|
57
|
+
aria-modal="true"
|
|
58
|
+
>
|
|
59
|
+
{children}
|
|
60
|
+
</div>
|
|
61
|
+
</>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface MobileSheetProps {
|
|
66
|
+
open: boolean
|
|
67
|
+
onClose: () => void
|
|
68
|
+
children: ReactNode
|
|
69
|
+
className?: string
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function MobileSheet({
|
|
73
|
+
open,
|
|
74
|
+
onClose,
|
|
75
|
+
children,
|
|
76
|
+
className = ''
|
|
77
|
+
}: MobileSheetProps) {
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (open) {
|
|
80
|
+
document.body.style.overflow = 'hidden'
|
|
81
|
+
return () => {
|
|
82
|
+
document.body.style.overflow = ''
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, [open])
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const handleEscape = (e: KeyboardEvent) => {
|
|
89
|
+
if (e.key === 'Escape' && open) {
|
|
90
|
+
onClose()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
document.addEventListener('keydown', handleEscape)
|
|
94
|
+
return () => document.removeEventListener('keydown', handleEscape)
|
|
95
|
+
}, [open, onClose])
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<>
|
|
99
|
+
<div
|
|
100
|
+
className={`fixed inset-0 z-40 bg-black/60 backdrop-blur-mobile transition-opacity duration-300 ${
|
|
101
|
+
open ? 'opacity-100' : 'opacity-0 pointer-events-none'
|
|
102
|
+
}`}
|
|
103
|
+
onClick={onClose}
|
|
104
|
+
aria-hidden="true"
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
<div
|
|
108
|
+
className={`fixed inset-x-0 bottom-0 z-50 bg-bg-secondary border-t border-border rounded-t-2xl transform transition-transform duration-300 ease-out ${
|
|
109
|
+
open ? 'translate-y-0' : 'translate-y-full'
|
|
110
|
+
} ${className}`}
|
|
111
|
+
style={{ maxHeight: 'calc(var(--vh, 1vh) * 85)' }}
|
|
112
|
+
role="dialog"
|
|
113
|
+
aria-modal="true"
|
|
114
|
+
>
|
|
115
|
+
<div className="flex justify-center py-2">
|
|
116
|
+
<div className="w-10 h-1 bg-border rounded-full" />
|
|
117
|
+
</div>
|
|
118
|
+
<div className="overflow-y-auto touch-scroll pb-safe">
|
|
119
|
+
{children}
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
</>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
interface SectionHeaderProps {
|
|
4
|
+
children: ReactNode
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function SectionHeader({ children }: SectionHeaderProps) {
|
|
8
|
+
return (
|
|
9
|
+
<h2 className="text-xs font-medium text-text-muted uppercase tracking-wider px-2 mb-2">
|
|
10
|
+
{children}
|
|
11
|
+
</h2>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from 'react'
|
|
2
|
+
import { createPortal } from 'react-dom'
|
|
3
|
+
import { Icons } from './icons'
|
|
4
|
+
import { MobileSheet } from './mobile-drawer'
|
|
5
|
+
import { useIsMobile } from '../../hooks/use-mobile'
|
|
6
|
+
|
|
7
|
+
export interface SelectOption {
|
|
8
|
+
value: string
|
|
9
|
+
label: string
|
|
10
|
+
description?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface SelectProps {
|
|
14
|
+
options: SelectOption[]
|
|
15
|
+
value: string
|
|
16
|
+
onChange: (value: string) => void
|
|
17
|
+
placeholder?: string
|
|
18
|
+
size?: 'sm' | 'md'
|
|
19
|
+
className?: string
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
label?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Select({
|
|
25
|
+
options,
|
|
26
|
+
value,
|
|
27
|
+
onChange,
|
|
28
|
+
placeholder = 'Select...',
|
|
29
|
+
size = 'md',
|
|
30
|
+
className = '',
|
|
31
|
+
disabled = false,
|
|
32
|
+
label,
|
|
33
|
+
}: SelectProps) {
|
|
34
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
35
|
+
const [dropdownPosition, setDropdownPosition] = useState({ top: 0, left: 0, width: 0, direction: 'down' as 'down' | 'up', height: 200 })
|
|
36
|
+
const buttonRef = useRef<HTMLButtonElement>(null)
|
|
37
|
+
const containerRef = useRef<HTMLDivElement>(null)
|
|
38
|
+
const dropdownRef = useRef<HTMLDivElement>(null)
|
|
39
|
+
const isMobile = useIsMobile()
|
|
40
|
+
|
|
41
|
+
const selectedOption = options.find((opt) => opt.value === value)
|
|
42
|
+
|
|
43
|
+
const updateDropdownPosition = useCallback(() => {
|
|
44
|
+
if (!isOpen || !buttonRef.current || isMobile) return
|
|
45
|
+
|
|
46
|
+
const rect = buttonRef.current.getBoundingClientRect()
|
|
47
|
+
const estimatedHeight = Math.min(options.length * 36, 200)
|
|
48
|
+
const availableBelow = window.innerHeight - (rect.top + rect.height)
|
|
49
|
+
const availableAbove = rect.top
|
|
50
|
+
const openUp = availableBelow < estimatedHeight && availableAbove > availableBelow
|
|
51
|
+
const maxHeight = openUp
|
|
52
|
+
? Math.max(0, Math.min(estimatedHeight, availableAbove - 8))
|
|
53
|
+
: Math.max(0, Math.min(estimatedHeight, availableBelow - 8))
|
|
54
|
+
|
|
55
|
+
setDropdownPosition({
|
|
56
|
+
top: openUp ? rect.top - maxHeight - 4 : rect.top + rect.height + 4,
|
|
57
|
+
left: rect.left,
|
|
58
|
+
width: rect.width,
|
|
59
|
+
direction: openUp ? 'up' : 'down',
|
|
60
|
+
height: maxHeight || estimatedHeight,
|
|
61
|
+
})
|
|
62
|
+
}, [isOpen, isMobile, options.length])
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
updateDropdownPosition()
|
|
66
|
+
}, [updateDropdownPosition])
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!isOpen || isMobile) return
|
|
70
|
+
|
|
71
|
+
const handleWindowChange = () => {
|
|
72
|
+
updateDropdownPosition()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
window.addEventListener('resize', handleWindowChange)
|
|
76
|
+
window.addEventListener('scroll', handleWindowChange, true)
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
window.removeEventListener('resize', handleWindowChange)
|
|
80
|
+
window.removeEventListener('scroll', handleWindowChange, true)
|
|
81
|
+
}
|
|
82
|
+
}, [isOpen, isMobile, updateDropdownPosition])
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const handleClickOutside = (e: MouseEvent) => {
|
|
86
|
+
const target = e.target as Node
|
|
87
|
+
if (containerRef.current?.contains(target)) return
|
|
88
|
+
if (dropdownRef.current?.contains(target)) return
|
|
89
|
+
setIsOpen(false)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (isOpen) {
|
|
93
|
+
document.addEventListener('mousedown', handleClickOutside)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return () => {
|
|
97
|
+
document.removeEventListener('mousedown', handleClickOutside)
|
|
98
|
+
}
|
|
99
|
+
}, [isOpen])
|
|
100
|
+
|
|
101
|
+
const sizeStyles = {
|
|
102
|
+
sm: 'px-2 py-1 text-[11px]',
|
|
103
|
+
md: 'px-3 py-1.5 text-xs',
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const dropdownSizeStyles = {
|
|
107
|
+
sm: 'text-[11px]',
|
|
108
|
+
md: 'text-xs',
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const handleSelect = (optionValue: string) => {
|
|
112
|
+
onChange(optionValue)
|
|
113
|
+
setIsOpen(false)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const handleButtonClick = (e: React.MouseEvent) => {
|
|
117
|
+
e.preventDefault()
|
|
118
|
+
e.stopPropagation()
|
|
119
|
+
if (!disabled) {
|
|
120
|
+
setIsOpen(!isOpen)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const DropdownContent = !isMobile && isOpen && (
|
|
125
|
+
<div
|
|
126
|
+
ref={dropdownRef}
|
|
127
|
+
className="fixed bg-bg-secondary border border-border rounded-lg shadow-xl z-[9999] overflow-hidden"
|
|
128
|
+
style={{
|
|
129
|
+
top: `${dropdownPosition.top}px`,
|
|
130
|
+
left: `${dropdownPosition.left}px`,
|
|
131
|
+
minWidth: `${dropdownPosition.width}px`,
|
|
132
|
+
maxWidth: '280px',
|
|
133
|
+
maxHeight: `${dropdownPosition.height}px`,
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
136
|
+
<div className="overflow-y-auto py-1" style={{ maxHeight: `${dropdownPosition.height}px` }}>
|
|
137
|
+
{options.map((option) => (
|
|
138
|
+
<button
|
|
139
|
+
key={option.value}
|
|
140
|
+
type="button"
|
|
141
|
+
onMouseDown={(e) => {
|
|
142
|
+
e.preventDefault()
|
|
143
|
+
e.stopPropagation()
|
|
144
|
+
handleSelect(option.value)
|
|
145
|
+
}}
|
|
146
|
+
className={`w-full text-left px-3 py-2 hover:bg-bg-hover transition-colors ${dropdownSizeStyles[size]} ${
|
|
147
|
+
option.value === value ? 'bg-bg-elevated text-text-primary' : 'text-text-secondary'
|
|
148
|
+
}`}
|
|
149
|
+
>
|
|
150
|
+
<div className="font-medium truncate">{option.label}</div>
|
|
151
|
+
{option.description && (
|
|
152
|
+
<div className="text-[10px] text-text-muted truncate mt-0.5">{option.description}</div>
|
|
153
|
+
)}
|
|
154
|
+
</button>
|
|
155
|
+
))}
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div ref={containerRef} className={`relative ${className}`}>
|
|
162
|
+
<button
|
|
163
|
+
ref={buttonRef}
|
|
164
|
+
type="button"
|
|
165
|
+
onClick={handleButtonClick}
|
|
166
|
+
disabled={disabled}
|
|
167
|
+
className={`flex items-center justify-between gap-1.5 w-full bg-bg-tertiary border border-border rounded-lg ${sizeStyles[size]} text-text-secondary hover:bg-bg-hover hover:border-text-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed min-w-0`}
|
|
168
|
+
>
|
|
169
|
+
<span className="truncate">{selectedOption?.label || placeholder}</span>
|
|
170
|
+
<Icons.ChevronDown className={`w-3 h-3 shrink-0 transition-transform ${isOpen ? 'rotate-180' : ''}`} />
|
|
171
|
+
</button>
|
|
172
|
+
|
|
173
|
+
{!isMobile && DropdownContent && createPortal(DropdownContent, document.body)}
|
|
174
|
+
|
|
175
|
+
{isMobile && (
|
|
176
|
+
<MobileSheet open={isOpen} onClose={() => setIsOpen(false)}>
|
|
177
|
+
<div className="px-4 pb-4">
|
|
178
|
+
{label && (
|
|
179
|
+
<h3 className="text-sm font-semibold text-text-primary mb-3">{label}</h3>
|
|
180
|
+
)}
|
|
181
|
+
{!label && placeholder && (
|
|
182
|
+
<h3 className="text-sm font-semibold text-text-primary mb-3">{placeholder}</h3>
|
|
183
|
+
)}
|
|
184
|
+
<div className="space-y-1">
|
|
185
|
+
{options.map((option) => (
|
|
186
|
+
<button
|
|
187
|
+
key={option.value}
|
|
188
|
+
type="button"
|
|
189
|
+
onClick={() => handleSelect(option.value)}
|
|
190
|
+
className={`w-full text-left px-4 py-3 rounded-lg transition-colors ${
|
|
191
|
+
option.value === value
|
|
192
|
+
? 'bg-accent-green/10 border border-accent-green/30'
|
|
193
|
+
: 'bg-bg-tertiary border border-border hover:bg-bg-hover'
|
|
194
|
+
}`}
|
|
195
|
+
>
|
|
196
|
+
<div className="flex items-center justify-between">
|
|
197
|
+
<div className="min-w-0 flex-1">
|
|
198
|
+
<div className={`text-sm font-medium truncate ${option.value === value ? 'text-accent-green' : 'text-text-primary'}`}>
|
|
199
|
+
{option.label}
|
|
200
|
+
</div>
|
|
201
|
+
{option.description && (
|
|
202
|
+
<div className="text-xs text-text-muted truncate mt-0.5">{option.description}</div>
|
|
203
|
+
)}
|
|
204
|
+
</div>
|
|
205
|
+
{option.value === value && (
|
|
206
|
+
<Icons.Check className="w-4 h-4 text-accent-green shrink-0 ml-2" />
|
|
207
|
+
)}
|
|
208
|
+
</div>
|
|
209
|
+
</button>
|
|
210
|
+
))}
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</MobileSheet>
|
|
214
|
+
)}
|
|
215
|
+
</div>
|
|
216
|
+
)
|
|
217
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
interface ShimmerTextProps {
|
|
4
|
+
text: string
|
|
5
|
+
className?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function ShimmerText({ text, className = '' }: ShimmerTextProps) {
|
|
9
|
+
const [position, setPosition] = useState(0)
|
|
10
|
+
const chars = text.split('')
|
|
11
|
+
const padding = 10
|
|
12
|
+
const period = chars.length + padding * 2
|
|
13
|
+
const sweepDuration = 2000
|
|
14
|
+
const bandHalfWidth = 5
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const startTime = Date.now()
|
|
18
|
+
let animationFrame: number
|
|
19
|
+
|
|
20
|
+
const animate = () => {
|
|
21
|
+
const elapsed = (Date.now() - startTime) % sweepDuration
|
|
22
|
+
const pos = (elapsed / sweepDuration) * period
|
|
23
|
+
setPosition(pos)
|
|
24
|
+
animationFrame = requestAnimationFrame(animate)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
animationFrame = requestAnimationFrame(animate)
|
|
28
|
+
return () => cancelAnimationFrame(animationFrame)
|
|
29
|
+
}, [period, sweepDuration])
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<span className={className}>
|
|
33
|
+
{chars.map((char, i) => {
|
|
34
|
+
const iPos = i + padding
|
|
35
|
+
const dist = Math.abs(iPos - position)
|
|
36
|
+
|
|
37
|
+
const t = dist <= bandHalfWidth
|
|
38
|
+
? 0.5 * (1 + Math.cos(Math.PI * (dist / bandHalfWidth)))
|
|
39
|
+
: 0
|
|
40
|
+
|
|
41
|
+
const opacity = 0.4 + (t * 0.6)
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<span
|
|
45
|
+
key={i}
|
|
46
|
+
style={{
|
|
47
|
+
opacity,
|
|
48
|
+
fontWeight: t > 0.3 ? 600 : 400,
|
|
49
|
+
transition: 'opacity 0.05s, font-weight 0.05s',
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
{char}
|
|
53
|
+
</span>
|
|
54
|
+
)
|
|
55
|
+
})}
|
|
56
|
+
</span>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface ShimmerDotsProps {
|
|
61
|
+
className?: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function ShimmerDots({ className = '' }: ShimmerDotsProps) {
|
|
65
|
+
const [frame, setFrame] = useState(0)
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const interval = setInterval(() => {
|
|
69
|
+
setFrame(f => (f + 1) % 4)
|
|
70
|
+
}, 400)
|
|
71
|
+
return () => clearInterval(interval)
|
|
72
|
+
}, [])
|
|
73
|
+
|
|
74
|
+
const dots = ['', '.', '..', '...']
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<span className={className}>
|
|
78
|
+
<span className="inline-block w-[1.5em] text-left">{dots[frame]}</span>
|
|
79
|
+
</span>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface ThinkingIndicatorProps {
|
|
84
|
+
message?: string
|
|
85
|
+
elapsed?: number
|
|
86
|
+
className?: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function ThinkingIndicator({
|
|
90
|
+
message = 'Thinking',
|
|
91
|
+
elapsed,
|
|
92
|
+
className = ''
|
|
93
|
+
}: ThinkingIndicatorProps) {
|
|
94
|
+
const [elapsedTime, setElapsedTime] = useState(elapsed ?? 0)
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (elapsed !== undefined) {
|
|
98
|
+
setElapsedTime(elapsed)
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const start = Date.now()
|
|
103
|
+
const interval = setInterval(() => {
|
|
104
|
+
setElapsedTime(Math.floor((Date.now() - start) / 1000))
|
|
105
|
+
}, 1000)
|
|
106
|
+
return () => clearInterval(interval)
|
|
107
|
+
}, [elapsed])
|
|
108
|
+
|
|
109
|
+
const formatElapsed = (secs: number) => {
|
|
110
|
+
if (secs < 60) return `${secs}s`
|
|
111
|
+
if (secs < 3600) {
|
|
112
|
+
const m = Math.floor(secs / 60)
|
|
113
|
+
const s = secs % 60
|
|
114
|
+
return `${m}m ${s.toString().padStart(2, '0')}s`
|
|
115
|
+
}
|
|
116
|
+
const h = Math.floor(secs / 3600)
|
|
117
|
+
const m = Math.floor((secs % 3600) / 60)
|
|
118
|
+
const s = secs % 60
|
|
119
|
+
return `${h}h ${m.toString().padStart(2, '0')}m ${s.toString().padStart(2, '0')}s`
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<div className={`flex items-center gap-2 text-sm ${className}`}>
|
|
124
|
+
<ShimmerText text={message} className="text-text-primary" />
|
|
125
|
+
<span className="text-text-muted">({formatElapsed(elapsedTime)})</span>
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface PulsingDotProps {
|
|
131
|
+
className?: string
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function PulsingDot({ className = '' }: PulsingDotProps) {
|
|
135
|
+
return (
|
|
136
|
+
<span className={`inline-block w-2 h-2 rounded-full bg-accent-green animate-pulse ${className}`} />
|
|
137
|
+
)
|
|
138
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface StatusDotProps {
|
|
2
|
+
status: 'online' | 'degraded' | 'offline' | 'active' | 'idle'
|
|
3
|
+
size?: 'sm' | 'md'
|
|
4
|
+
pulse?: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function StatusDot({ status, size = 'sm', pulse = false }: StatusDotProps) {
|
|
8
|
+
const colorMap = {
|
|
9
|
+
online: 'bg-accent-green',
|
|
10
|
+
active: 'bg-accent-green',
|
|
11
|
+
degraded: 'bg-yellow-500',
|
|
12
|
+
offline: 'bg-text-muted',
|
|
13
|
+
idle: 'bg-text-muted',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const sizeStyles = {
|
|
17
|
+
sm: 'w-2 h-2',
|
|
18
|
+
md: 'w-3 h-3',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<span className={`rounded-full ${colorMap[status]} ${sizeStyles[size]} ${pulse ? 'animate-pulse' : ''}`} />
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from 'react'
|
|
2
|
+
import { HUB_URL } from '../config'
|
|
3
|
+
|
|
4
|
+
export interface DailyDataPoint {
|
|
5
|
+
date: string
|
|
6
|
+
count: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface AnalyticsSeries {
|
|
10
|
+
metric: string
|
|
11
|
+
series: DailyDataPoint[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type AnalyticsMetric =
|
|
15
|
+
| 'turns_started'
|
|
16
|
+
| 'turns_completed'
|
|
17
|
+
| 'threads_started'
|
|
18
|
+
| 'command_exec'
|
|
19
|
+
| 'approvals_requested_command'
|
|
20
|
+
| 'approvals_requested_file'
|
|
21
|
+
| 'approvals_accept'
|
|
22
|
+
| 'approvals_decline'
|
|
23
|
+
|
|
24
|
+
export const METRIC_LABELS: Record<AnalyticsMetric, string> = {
|
|
25
|
+
turns_started: 'Turns Started',
|
|
26
|
+
turns_completed: 'Turns Completed',
|
|
27
|
+
threads_started: 'Sessions Started',
|
|
28
|
+
command_exec: 'Commands Executed',
|
|
29
|
+
approvals_requested_command: 'Command Approvals',
|
|
30
|
+
approvals_requested_file: 'File Approvals',
|
|
31
|
+
approvals_accept: 'Approvals Accepted',
|
|
32
|
+
approvals_decline: 'Approvals Declined',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function useAnalytics(
|
|
36
|
+
metric: AnalyticsMetric = 'turns_started',
|
|
37
|
+
profileId?: string,
|
|
38
|
+
model?: string,
|
|
39
|
+
days = 365
|
|
40
|
+
) {
|
|
41
|
+
const [data, setData] = useState<DailyDataPoint[]>([])
|
|
42
|
+
const [loading, setLoading] = useState(true)
|
|
43
|
+
const [error, setError] = useState<string | null>(null)
|
|
44
|
+
|
|
45
|
+
const fetchData = useCallback(async () => {
|
|
46
|
+
setLoading(true)
|
|
47
|
+
setError(null)
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
const params = new URLSearchParams({ metric, days: String(days) })
|
|
51
|
+
if (profileId) params.set('profileId', profileId)
|
|
52
|
+
if (model) params.set('model', model)
|
|
53
|
+
|
|
54
|
+
const response = await fetch(`${HUB_URL}/analytics/daily?${params}`)
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
throw new Error(`Failed to fetch analytics: ${response.statusText}`)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const result: AnalyticsSeries = await response.json()
|
|
60
|
+
setData(result.series)
|
|
61
|
+
} catch (err) {
|
|
62
|
+
setError(err instanceof Error ? err.message : 'Failed to fetch analytics')
|
|
63
|
+
setData([])
|
|
64
|
+
} finally {
|
|
65
|
+
setLoading(false)
|
|
66
|
+
}
|
|
67
|
+
}, [metric, profileId, model, days])
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
void fetchData()
|
|
71
|
+
}, [fetchData])
|
|
72
|
+
|
|
73
|
+
return { data, loading, error, refetch: fetchData }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function useMultipleMetrics(
|
|
77
|
+
metrics: AnalyticsMetric[],
|
|
78
|
+
profileId?: string,
|
|
79
|
+
days = 365
|
|
80
|
+
) {
|
|
81
|
+
const [data, setData] = useState<Record<AnalyticsMetric, DailyDataPoint[]>>({} as Record<AnalyticsMetric, DailyDataPoint[]>)
|
|
82
|
+
const [loading, setLoading] = useState(true)
|
|
83
|
+
const [error, setError] = useState<string | null>(null)
|
|
84
|
+
|
|
85
|
+
const fetchAll = useCallback(async () => {
|
|
86
|
+
setLoading(true)
|
|
87
|
+
setError(null)
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const results = await Promise.all(
|
|
91
|
+
metrics.map(async (metric) => {
|
|
92
|
+
const params = new URLSearchParams({ metric, days: String(days) })
|
|
93
|
+
if (profileId) params.set('profileId', profileId)
|
|
94
|
+
|
|
95
|
+
const response = await fetch(`${HUB_URL}/analytics/daily?${params}`)
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
throw new Error(`Failed to fetch ${metric}`)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const result: AnalyticsSeries = await response.json()
|
|
101
|
+
return { metric, series: result.series }
|
|
102
|
+
})
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
const dataMap = {} as Record<AnalyticsMetric, DailyDataPoint[]>
|
|
106
|
+
for (const { metric, series } of results) {
|
|
107
|
+
dataMap[metric as AnalyticsMetric] = series
|
|
108
|
+
}
|
|
109
|
+
setData(dataMap)
|
|
110
|
+
} catch (err) {
|
|
111
|
+
setError(err instanceof Error ? err.message : 'Failed to fetch analytics')
|
|
112
|
+
} finally {
|
|
113
|
+
setLoading(false)
|
|
114
|
+
}
|
|
115
|
+
}, [metrics, profileId, days])
|
|
116
|
+
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
void fetchAll()
|
|
119
|
+
}, [fetchAll])
|
|
120
|
+
|
|
121
|
+
return { data, loading, error, refetch: fetchAll }
|
|
122
|
+
}
|