clawdex-mobile 1.0.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/.github/workflows/ci.yml +77 -0
- package/.github/workflows/npm-release.yml +67 -0
- package/AGENTS.md +120 -0
- package/LICENSE +21 -0
- package/README.md +648 -0
- package/STATUS.md +115 -0
- package/apps/mobile/.env.example +7 -0
- package/apps/mobile/App.tsx +589 -0
- package/apps/mobile/app.json +33 -0
- package/apps/mobile/assets/brand/adaptive-icon.png +0 -0
- package/apps/mobile/assets/brand/app-icon.png +0 -0
- package/apps/mobile/assets/brand/favicon.png +0 -0
- package/apps/mobile/assets/brand/mark.png +0 -0
- package/apps/mobile/assets/brand/splash-icon.png +0 -0
- package/apps/mobile/babel.config.js +7 -0
- package/apps/mobile/eslint.config.cjs +28 -0
- package/apps/mobile/index.js +5 -0
- package/apps/mobile/metro.config.js +3 -0
- package/apps/mobile/package.json +55 -0
- package/apps/mobile/src/api/__tests__/chatMapping.test.ts +132 -0
- package/apps/mobile/src/api/__tests__/client.test.ts +872 -0
- package/apps/mobile/src/api/__tests__/ws.test.ts +575 -0
- package/apps/mobile/src/api/chatMapping.ts +591 -0
- package/apps/mobile/src/api/client.ts +1087 -0
- package/apps/mobile/src/api/types.ts +267 -0
- package/apps/mobile/src/api/ws.ts +801 -0
- package/apps/mobile/src/components/ActivityBar.tsx +76 -0
- package/apps/mobile/src/components/ApprovalBanner.tsx +207 -0
- package/apps/mobile/src/components/BrandMark.tsx +43 -0
- package/apps/mobile/src/components/ChatHeader.tsx +106 -0
- package/apps/mobile/src/components/ChatInput.tsx +236 -0
- package/apps/mobile/src/components/ChatMessage.tsx +400 -0
- package/apps/mobile/src/components/StatusLine.tsx +52 -0
- package/apps/mobile/src/components/ToolBlock.tsx +65 -0
- package/apps/mobile/src/components/TypingIndicator.tsx +64 -0
- package/apps/mobile/src/config.ts +75 -0
- package/apps/mobile/src/navigation/DrawerContent.tsx +969 -0
- package/apps/mobile/src/screens/GitScreen.tsx +573 -0
- package/apps/mobile/src/screens/MainScreen.tsx +6905 -0
- package/apps/mobile/src/screens/PrivacyScreen.tsx +196 -0
- package/apps/mobile/src/screens/SettingsScreen.tsx +776 -0
- package/apps/mobile/src/screens/TerminalScreen.tsx +251 -0
- package/apps/mobile/src/screens/TermsScreen.tsx +192 -0
- package/apps/mobile/src/theme.ts +112 -0
- package/apps/mobile/src/types/assets.d.ts +4 -0
- package/apps/mobile/tsconfig.json +33 -0
- package/bin/clawdex.js +72 -0
- package/docs/app-review-notes.md +111 -0
- package/docs/open-source-license-requirements.md +32 -0
- package/docs/plans/2026-02-20-codex-desktop-style-redesign.md +190 -0
- package/docs/plans/2026-02-20-codex-mobile-implementation.md +1630 -0
- package/docs/plans/2026-02-21-codex-ui-redesign-design.md +101 -0
- package/docs/plans/2026-02-21-codex-ui-redesign.md +1229 -0
- package/docs/realtime-streaming-limitations.md +77 -0
- package/package.json +47 -0
- package/scripts/setup-secure-dev.sh +169 -0
- package/scripts/setup-wizard.sh +1302 -0
- package/scripts/start-bridge-secure.sh +38 -0
- package/scripts/start-expo.sh +176 -0
- package/scripts/stop-services.sh +61 -0
- package/scripts/teardown.sh +136 -0
- package/services/mac-bridge/.env.example +10 -0
- package/services/mac-bridge/codex-types/AbsolutePathBuf.ts +14 -0
- package/services/mac-bridge/codex-types/AddConversationListenerParams.ts +6 -0
- package/services/mac-bridge/codex-types/AddConversationSubscriptionResponse.ts +5 -0
- package/services/mac-bridge/codex-types/AgentMessageContent.ts +5 -0
- package/services/mac-bridge/codex-types/AgentMessageContentDeltaEvent.ts +5 -0
- package/services/mac-bridge/codex-types/AgentMessageDeltaEvent.ts +5 -0
- package/services/mac-bridge/codex-types/AgentMessageEvent.ts +5 -0
- package/services/mac-bridge/codex-types/AgentMessageItem.ts +21 -0
- package/services/mac-bridge/codex-types/AgentReasoningDeltaEvent.ts +5 -0
- package/services/mac-bridge/codex-types/AgentReasoningEvent.ts +5 -0
- package/services/mac-bridge/codex-types/AgentReasoningRawContentDeltaEvent.ts +5 -0
- package/services/mac-bridge/codex-types/AgentReasoningRawContentEvent.ts +5 -0
- package/services/mac-bridge/codex-types/AgentReasoningSectionBreakEvent.ts +5 -0
- package/services/mac-bridge/codex-types/AgentStatus.ts +8 -0
- package/services/mac-bridge/codex-types/ApplyPatchApprovalParams.ts +21 -0
- package/services/mac-bridge/codex-types/ApplyPatchApprovalRequestEvent.ts +23 -0
- package/services/mac-bridge/codex-types/ApplyPatchApprovalResponse.ts +6 -0
- package/services/mac-bridge/codex-types/ArchiveConversationParams.ts +6 -0
- package/services/mac-bridge/codex-types/ArchiveConversationResponse.ts +5 -0
- package/services/mac-bridge/codex-types/AskForApproval.ts +9 -0
- package/services/mac-bridge/codex-types/AuthMode.ts +8 -0
- package/services/mac-bridge/codex-types/AuthStatusChangeNotification.ts +9 -0
- package/services/mac-bridge/codex-types/BackgroundEventEvent.ts +5 -0
- package/services/mac-bridge/codex-types/ByteRange.ts +13 -0
- package/services/mac-bridge/codex-types/CallToolResult.ts +9 -0
- package/services/mac-bridge/codex-types/CancelLoginChatGptParams.ts +5 -0
- package/services/mac-bridge/codex-types/CancelLoginChatGptResponse.ts +5 -0
- package/services/mac-bridge/codex-types/ClientInfo.ts +5 -0
- package/services/mac-bridge/codex-types/ClientNotification.ts +5 -0
- package/services/mac-bridge/codex-types/ClientRequest.ts +60 -0
- package/services/mac-bridge/codex-types/CodexErrorInfo.ts +8 -0
- package/services/mac-bridge/codex-types/CollabAgentInteractionBeginEvent.ts +23 -0
- package/services/mac-bridge/codex-types/CollabAgentInteractionEndEvent.ts +28 -0
- package/services/mac-bridge/codex-types/CollabAgentSpawnBeginEvent.ts +19 -0
- package/services/mac-bridge/codex-types/CollabAgentSpawnEndEvent.ts +28 -0
- package/services/mac-bridge/codex-types/CollabCloseBeginEvent.ts +18 -0
- package/services/mac-bridge/codex-types/CollabCloseEndEvent.ts +24 -0
- package/services/mac-bridge/codex-types/CollabResumeBeginEvent.ts +18 -0
- package/services/mac-bridge/codex-types/CollabResumeEndEvent.ts +24 -0
- package/services/mac-bridge/codex-types/CollabWaitingBeginEvent.ts +18 -0
- package/services/mac-bridge/codex-types/CollabWaitingEndEvent.ts +19 -0
- package/services/mac-bridge/codex-types/CollaborationMode.ts +10 -0
- package/services/mac-bridge/codex-types/CollaborationModeMask.ts +11 -0
- package/services/mac-bridge/codex-types/ContentItem.ts +5 -0
- package/services/mac-bridge/codex-types/ContextCompactedEvent.ts +5 -0
- package/services/mac-bridge/codex-types/ContextCompactionItem.ts +5 -0
- package/services/mac-bridge/codex-types/ConversationGitInfo.ts +5 -0
- package/services/mac-bridge/codex-types/ConversationSummary.ts +8 -0
- package/services/mac-bridge/codex-types/CreditsSnapshot.ts +5 -0
- package/services/mac-bridge/codex-types/CustomPrompt.ts +5 -0
- package/services/mac-bridge/codex-types/DeprecationNoticeEvent.ts +13 -0
- package/services/mac-bridge/codex-types/DynamicToolCallRequest.ts +6 -0
- package/services/mac-bridge/codex-types/ElicitationRequestEvent.ts +5 -0
- package/services/mac-bridge/codex-types/ErrorEvent.ts +6 -0
- package/services/mac-bridge/codex-types/EventMsg.ts +78 -0
- package/services/mac-bridge/codex-types/ExecApprovalRequestEvent.ts +44 -0
- package/services/mac-bridge/codex-types/ExecCommandApprovalParams.ts +16 -0
- package/services/mac-bridge/codex-types/ExecCommandApprovalResponse.ts +6 -0
- package/services/mac-bridge/codex-types/ExecCommandBeginEvent.ts +35 -0
- package/services/mac-bridge/codex-types/ExecCommandEndEvent.ts +64 -0
- package/services/mac-bridge/codex-types/ExecCommandOutputDeltaEvent.ts +18 -0
- package/services/mac-bridge/codex-types/ExecCommandSource.ts +5 -0
- package/services/mac-bridge/codex-types/ExecCommandStatus.ts +5 -0
- package/services/mac-bridge/codex-types/ExecOneOffCommandParams.ts +6 -0
- package/services/mac-bridge/codex-types/ExecOneOffCommandResponse.ts +5 -0
- package/services/mac-bridge/codex-types/ExecOutputStream.ts +5 -0
- package/services/mac-bridge/codex-types/ExecPolicyAmendment.ts +12 -0
- package/services/mac-bridge/codex-types/ExitedReviewModeEvent.ts +6 -0
- package/services/mac-bridge/codex-types/FileChange.ts +5 -0
- package/services/mac-bridge/codex-types/ForcedLoginMethod.ts +5 -0
- package/services/mac-bridge/codex-types/ForkConversationParams.ts +7 -0
- package/services/mac-bridge/codex-types/ForkConversationResponse.ts +7 -0
- package/services/mac-bridge/codex-types/FunctionCallOutputBody.ts +6 -0
- package/services/mac-bridge/codex-types/FunctionCallOutputContentItem.ts +9 -0
- package/services/mac-bridge/codex-types/FunctionCallOutputPayload.ts +12 -0
- package/services/mac-bridge/codex-types/FuzzyFileSearchParams.ts +5 -0
- package/services/mac-bridge/codex-types/FuzzyFileSearchResponse.ts +6 -0
- package/services/mac-bridge/codex-types/FuzzyFileSearchResult.ts +8 -0
- package/services/mac-bridge/codex-types/FuzzyFileSearchSessionCompletedNotification.ts +5 -0
- package/services/mac-bridge/codex-types/FuzzyFileSearchSessionUpdatedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/GetAuthStatusParams.ts +5 -0
- package/services/mac-bridge/codex-types/GetAuthStatusResponse.ts +6 -0
- package/services/mac-bridge/codex-types/GetConversationSummaryParams.ts +6 -0
- package/services/mac-bridge/codex-types/GetConversationSummaryResponse.ts +6 -0
- package/services/mac-bridge/codex-types/GetHistoryEntryResponseEvent.ts +10 -0
- package/services/mac-bridge/codex-types/GetUserAgentResponse.ts +5 -0
- package/services/mac-bridge/codex-types/GetUserSavedConfigResponse.ts +6 -0
- package/services/mac-bridge/codex-types/GhostCommit.ts +8 -0
- package/services/mac-bridge/codex-types/GitDiffToRemoteParams.ts +5 -0
- package/services/mac-bridge/codex-types/GitDiffToRemoteResponse.ts +6 -0
- package/services/mac-bridge/codex-types/GitSha.ts +5 -0
- package/services/mac-bridge/codex-types/HistoryEntry.ts +5 -0
- package/services/mac-bridge/codex-types/InitializeCapabilities.ts +17 -0
- package/services/mac-bridge/codex-types/InitializeParams.ts +7 -0
- package/services/mac-bridge/codex-types/InitializeResponse.ts +5 -0
- package/services/mac-bridge/codex-types/InputItem.ts +10 -0
- package/services/mac-bridge/codex-types/InputModality.ts +8 -0
- package/services/mac-bridge/codex-types/InterruptConversationParams.ts +6 -0
- package/services/mac-bridge/codex-types/InterruptConversationResponse.ts +6 -0
- package/services/mac-bridge/codex-types/ItemCompletedEvent.ts +7 -0
- package/services/mac-bridge/codex-types/ItemStartedEvent.ts +7 -0
- package/services/mac-bridge/codex-types/ListConversationsParams.ts +5 -0
- package/services/mac-bridge/codex-types/ListConversationsResponse.ts +6 -0
- package/services/mac-bridge/codex-types/ListCustomPromptsResponseEvent.ts +9 -0
- package/services/mac-bridge/codex-types/ListRemoteSkillsResponseEvent.ts +9 -0
- package/services/mac-bridge/codex-types/ListSkillsResponseEvent.ts +9 -0
- package/services/mac-bridge/codex-types/LocalShellAction.ts +6 -0
- package/services/mac-bridge/codex-types/LocalShellExecAction.ts +5 -0
- package/services/mac-bridge/codex-types/LocalShellStatus.ts +5 -0
- package/services/mac-bridge/codex-types/LoginApiKeyParams.ts +5 -0
- package/services/mac-bridge/codex-types/LoginApiKeyResponse.ts +5 -0
- package/services/mac-bridge/codex-types/LoginChatGptCompleteNotification.ts +8 -0
- package/services/mac-bridge/codex-types/LoginChatGptResponse.ts +5 -0
- package/services/mac-bridge/codex-types/LogoutChatGptResponse.ts +5 -0
- package/services/mac-bridge/codex-types/McpAuthStatus.ts +5 -0
- package/services/mac-bridge/codex-types/McpInvocation.ts +18 -0
- package/services/mac-bridge/codex-types/McpListToolsResponseEvent.ts +25 -0
- package/services/mac-bridge/codex-types/McpStartupCompleteEvent.ts +6 -0
- package/services/mac-bridge/codex-types/McpStartupFailure.ts +5 -0
- package/services/mac-bridge/codex-types/McpStartupStatus.ts +5 -0
- package/services/mac-bridge/codex-types/McpStartupUpdateEvent.ts +14 -0
- package/services/mac-bridge/codex-types/McpToolCallBeginEvent.ts +10 -0
- package/services/mac-bridge/codex-types/McpToolCallEndEvent.ts +15 -0
- package/services/mac-bridge/codex-types/MessagePhase.ts +11 -0
- package/services/mac-bridge/codex-types/ModeKind.ts +8 -0
- package/services/mac-bridge/codex-types/ModelRerouteEvent.ts +6 -0
- package/services/mac-bridge/codex-types/ModelRerouteReason.ts +5 -0
- package/services/mac-bridge/codex-types/NetworkAccess.ts +8 -0
- package/services/mac-bridge/codex-types/NetworkApprovalContext.ts +6 -0
- package/services/mac-bridge/codex-types/NetworkApprovalProtocol.ts +5 -0
- package/services/mac-bridge/codex-types/NewConversationParams.ts +8 -0
- package/services/mac-bridge/codex-types/NewConversationResponse.ts +7 -0
- package/services/mac-bridge/codex-types/ParsedCommand.ts +12 -0
- package/services/mac-bridge/codex-types/PatchApplyBeginEvent.ts +23 -0
- package/services/mac-bridge/codex-types/PatchApplyEndEvent.ts +36 -0
- package/services/mac-bridge/codex-types/PatchApplyStatus.ts +5 -0
- package/services/mac-bridge/codex-types/Personality.ts +5 -0
- package/services/mac-bridge/codex-types/PlanDeltaEvent.ts +5 -0
- package/services/mac-bridge/codex-types/PlanItem.ts +5 -0
- package/services/mac-bridge/codex-types/PlanItemArg.ts +6 -0
- package/services/mac-bridge/codex-types/PlanType.ts +5 -0
- package/services/mac-bridge/codex-types/Profile.ts +9 -0
- package/services/mac-bridge/codex-types/RateLimitSnapshot.ts +8 -0
- package/services/mac-bridge/codex-types/RateLimitWindow.ts +17 -0
- package/services/mac-bridge/codex-types/RawResponseItemEvent.ts +6 -0
- package/services/mac-bridge/codex-types/ReadOnlyAccess.ts +19 -0
- package/services/mac-bridge/codex-types/ReasoningContentDeltaEvent.ts +5 -0
- package/services/mac-bridge/codex-types/ReasoningEffort.ts +8 -0
- package/services/mac-bridge/codex-types/ReasoningItem.ts +5 -0
- package/services/mac-bridge/codex-types/ReasoningItemContent.ts +5 -0
- package/services/mac-bridge/codex-types/ReasoningItemReasoningSummary.ts +5 -0
- package/services/mac-bridge/codex-types/ReasoningRawContentDeltaEvent.ts +5 -0
- package/services/mac-bridge/codex-types/ReasoningSummary.ts +10 -0
- package/services/mac-bridge/codex-types/RemoteSkillDownloadedEvent.ts +8 -0
- package/services/mac-bridge/codex-types/RemoteSkillSummary.ts +5 -0
- package/services/mac-bridge/codex-types/RemoveConversationListenerParams.ts +5 -0
- package/services/mac-bridge/codex-types/RemoveConversationSubscriptionResponse.ts +5 -0
- package/services/mac-bridge/codex-types/RequestId.ts +5 -0
- package/services/mac-bridge/codex-types/RequestUserInputEvent.ts +15 -0
- package/services/mac-bridge/codex-types/RequestUserInputQuestion.ts +6 -0
- package/services/mac-bridge/codex-types/RequestUserInputQuestionOption.ts +5 -0
- package/services/mac-bridge/codex-types/Resource.ts +9 -0
- package/services/mac-bridge/codex-types/ResourceTemplate.ts +9 -0
- package/services/mac-bridge/codex-types/ResponseItem.ts +18 -0
- package/services/mac-bridge/codex-types/ResumeConversationParams.ts +8 -0
- package/services/mac-bridge/codex-types/ResumeConversationResponse.ts +7 -0
- package/services/mac-bridge/codex-types/ReviewCodeLocation.ts +9 -0
- package/services/mac-bridge/codex-types/ReviewDecision.ts +9 -0
- package/services/mac-bridge/codex-types/ReviewFinding.ts +9 -0
- package/services/mac-bridge/codex-types/ReviewLineRange.ts +8 -0
- package/services/mac-bridge/codex-types/ReviewOutputEvent.ts +9 -0
- package/services/mac-bridge/codex-types/ReviewRequest.ts +9 -0
- package/services/mac-bridge/codex-types/ReviewTarget.ts +9 -0
- package/services/mac-bridge/codex-types/SandboxMode.ts +5 -0
- package/services/mac-bridge/codex-types/SandboxPolicy.ts +44 -0
- package/services/mac-bridge/codex-types/SandboxSettings.ts +6 -0
- package/services/mac-bridge/codex-types/SendUserMessageParams.ts +7 -0
- package/services/mac-bridge/codex-types/SendUserMessageResponse.ts +5 -0
- package/services/mac-bridge/codex-types/SendUserTurnParams.ts +16 -0
- package/services/mac-bridge/codex-types/SendUserTurnResponse.ts +5 -0
- package/services/mac-bridge/codex-types/ServerNotification.ts +45 -0
- package/services/mac-bridge/codex-types/ServerRequest.ts +16 -0
- package/services/mac-bridge/codex-types/SessionConfiguredEvent.ts +57 -0
- package/services/mac-bridge/codex-types/SessionConfiguredNotification.ts +8 -0
- package/services/mac-bridge/codex-types/SessionNetworkProxyRuntime.ts +5 -0
- package/services/mac-bridge/codex-types/SessionSource.ts +6 -0
- package/services/mac-bridge/codex-types/SetDefaultModelParams.ts +6 -0
- package/services/mac-bridge/codex-types/SetDefaultModelResponse.ts +5 -0
- package/services/mac-bridge/codex-types/Settings.ts +9 -0
- package/services/mac-bridge/codex-types/SkillDependencies.ts +6 -0
- package/services/mac-bridge/codex-types/SkillErrorInfo.ts +5 -0
- package/services/mac-bridge/codex-types/SkillInterface.ts +5 -0
- package/services/mac-bridge/codex-types/SkillMetadata.ts +12 -0
- package/services/mac-bridge/codex-types/SkillScope.ts +5 -0
- package/services/mac-bridge/codex-types/SkillToolDependency.ts +5 -0
- package/services/mac-bridge/codex-types/SkillsListEntry.ts +7 -0
- package/services/mac-bridge/codex-types/StepStatus.ts +5 -0
- package/services/mac-bridge/codex-types/StreamErrorEvent.ts +12 -0
- package/services/mac-bridge/codex-types/SubAgentSource.ts +6 -0
- package/services/mac-bridge/codex-types/TerminalInteractionEvent.ts +17 -0
- package/services/mac-bridge/codex-types/TextElement.ts +14 -0
- package/services/mac-bridge/codex-types/ThreadId.ts +5 -0
- package/services/mac-bridge/codex-types/ThreadNameUpdatedEvent.ts +6 -0
- package/services/mac-bridge/codex-types/ThreadRolledBackEvent.ts +9 -0
- package/services/mac-bridge/codex-types/TokenCountEvent.ts +7 -0
- package/services/mac-bridge/codex-types/TokenUsage.ts +5 -0
- package/services/mac-bridge/codex-types/TokenUsageInfo.ts +6 -0
- package/services/mac-bridge/codex-types/Tool.ts +9 -0
- package/services/mac-bridge/codex-types/Tools.ts +5 -0
- package/services/mac-bridge/codex-types/TurnAbortReason.ts +5 -0
- package/services/mac-bridge/codex-types/TurnAbortedEvent.ts +6 -0
- package/services/mac-bridge/codex-types/TurnCompleteEvent.ts +5 -0
- package/services/mac-bridge/codex-types/TurnDiffEvent.ts +5 -0
- package/services/mac-bridge/codex-types/TurnItem.ts +11 -0
- package/services/mac-bridge/codex-types/TurnStartedEvent.ts +6 -0
- package/services/mac-bridge/codex-types/UndoCompletedEvent.ts +5 -0
- package/services/mac-bridge/codex-types/UndoStartedEvent.ts +5 -0
- package/services/mac-bridge/codex-types/UpdatePlanArgs.ts +10 -0
- package/services/mac-bridge/codex-types/UserInfoResponse.ts +5 -0
- package/services/mac-bridge/codex-types/UserInput.ts +16 -0
- package/services/mac-bridge/codex-types/UserMessageEvent.ts +22 -0
- package/services/mac-bridge/codex-types/UserMessageItem.ts +6 -0
- package/services/mac-bridge/codex-types/UserSavedConfig.ts +14 -0
- package/services/mac-bridge/codex-types/Verbosity.ts +9 -0
- package/services/mac-bridge/codex-types/ViewImageToolCallEvent.ts +13 -0
- package/services/mac-bridge/codex-types/WarningEvent.ts +5 -0
- package/services/mac-bridge/codex-types/WebSearchAction.ts +5 -0
- package/services/mac-bridge/codex-types/WebSearchBeginEvent.ts +5 -0
- package/services/mac-bridge/codex-types/WebSearchEndEvent.ts +6 -0
- package/services/mac-bridge/codex-types/WebSearchItem.ts +6 -0
- package/services/mac-bridge/codex-types/WebSearchMode.ts +5 -0
- package/services/mac-bridge/codex-types/index.ts +234 -0
- package/services/mac-bridge/codex-types/serde_json/JsonValue.ts +5 -0
- package/services/mac-bridge/codex-types/v2/Account.ts +6 -0
- package/services/mac-bridge/codex-types/v2/AccountLoginCompletedNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/AccountRateLimitsUpdatedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/AccountUpdatedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/AgentMessageDeltaNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/AnalyticsConfig.ts +6 -0
- package/services/mac-bridge/codex-types/v2/AppBranding.ts +8 -0
- package/services/mac-bridge/codex-types/v2/AppDisabledReason.ts +5 -0
- package/services/mac-bridge/codex-types/v2/AppInfo.ts +19 -0
- package/services/mac-bridge/codex-types/v2/AppListUpdatedNotification.ts +9 -0
- package/services/mac-bridge/codex-types/v2/AppMetadata.ts +7 -0
- package/services/mac-bridge/codex-types/v2/AppReview.ts +5 -0
- package/services/mac-bridge/codex-types/v2/AppScreenshot.ts +5 -0
- package/services/mac-bridge/codex-types/v2/AppsConfig.ts +6 -0
- package/services/mac-bridge/codex-types/v2/AppsListParams.ts +24 -0
- package/services/mac-bridge/codex-types/v2/AppsListResponse.ts +14 -0
- package/services/mac-bridge/codex-types/v2/AskForApproval.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ByteRange.ts +5 -0
- package/services/mac-bridge/codex-types/v2/CancelLoginAccountParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/CancelLoginAccountResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/CancelLoginAccountStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ChatgptAuthTokensRefreshParams.ts +16 -0
- package/services/mac-bridge/codex-types/v2/ChatgptAuthTokensRefreshReason.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ChatgptAuthTokensRefreshResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/CodexErrorInfo.ts +11 -0
- package/services/mac-bridge/codex-types/v2/CollabAgentState.ts +6 -0
- package/services/mac-bridge/codex-types/v2/CollabAgentStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/CollabAgentTool.ts +5 -0
- package/services/mac-bridge/codex-types/v2/CollabAgentToolCallStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/CommandAction.ts +5 -0
- package/services/mac-bridge/codex-types/v2/CommandExecParams.ts +6 -0
- package/services/mac-bridge/codex-types/v2/CommandExecResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/CommandExecutionApprovalDecision.ts +6 -0
- package/services/mac-bridge/codex-types/v2/CommandExecutionOutputDeltaNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/CommandExecutionRequestApprovalParams.ts +37 -0
- package/services/mac-bridge/codex-types/v2/CommandExecutionRequestApprovalResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/CommandExecutionStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/Config.ts +17 -0
- package/services/mac-bridge/codex-types/v2/ConfigBatchWriteParams.ts +10 -0
- package/services/mac-bridge/codex-types/v2/ConfigEdit.ts +7 -0
- package/services/mac-bridge/codex-types/v2/ConfigLayer.ts +7 -0
- package/services/mac-bridge/codex-types/v2/ConfigLayerMetadata.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ConfigLayerSource.ts +16 -0
- package/services/mac-bridge/codex-types/v2/ConfigReadParams.ts +11 -0
- package/services/mac-bridge/codex-types/v2/ConfigReadResponse.ts +8 -0
- package/services/mac-bridge/codex-types/v2/ConfigRequirements.ts +9 -0
- package/services/mac-bridge/codex-types/v2/ConfigRequirementsReadResponse.ts +10 -0
- package/services/mac-bridge/codex-types/v2/ConfigValueWriteParams.ts +11 -0
- package/services/mac-bridge/codex-types/v2/ConfigWarningNotification.ts +22 -0
- package/services/mac-bridge/codex-types/v2/ConfigWriteResponse.ts +12 -0
- package/services/mac-bridge/codex-types/v2/ContextCompactedNotification.ts +8 -0
- package/services/mac-bridge/codex-types/v2/CreditsSnapshot.ts +5 -0
- package/services/mac-bridge/codex-types/v2/DeprecationNoticeNotification.ts +13 -0
- package/services/mac-bridge/codex-types/v2/DynamicToolCallOutputContentItem.ts +5 -0
- package/services/mac-bridge/codex-types/v2/DynamicToolCallParams.ts +6 -0
- package/services/mac-bridge/codex-types/v2/DynamicToolCallResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/DynamicToolSpec.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ErrorNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ExecPolicyAmendment.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ExperimentalFeature.ts +37 -0
- package/services/mac-bridge/codex-types/v2/ExperimentalFeatureListParams.ts +13 -0
- package/services/mac-bridge/codex-types/v2/ExperimentalFeatureListResponse.ts +11 -0
- package/services/mac-bridge/codex-types/v2/ExperimentalFeatureStage.ts +5 -0
- package/services/mac-bridge/codex-types/v2/FeedbackUploadParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/FeedbackUploadResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/FileChangeApprovalDecision.ts +5 -0
- package/services/mac-bridge/codex-types/v2/FileChangeOutputDeltaNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/FileChangeRequestApprovalParams.ts +14 -0
- package/services/mac-bridge/codex-types/v2/FileChangeRequestApprovalResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/FileUpdateChange.ts +6 -0
- package/services/mac-bridge/codex-types/v2/GetAccountParams.ts +13 -0
- package/services/mac-bridge/codex-types/v2/GetAccountRateLimitsResponse.ts +14 -0
- package/services/mac-bridge/codex-types/v2/GetAccountResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/GitInfo.ts +5 -0
- package/services/mac-bridge/codex-types/v2/HazelnutScope.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ItemCompletedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ItemStartedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ListMcpServerStatusParams.ts +13 -0
- package/services/mac-bridge/codex-types/v2/ListMcpServerStatusResponse.ts +11 -0
- package/services/mac-bridge/codex-types/v2/LoginAccountParams.ts +21 -0
- package/services/mac-bridge/codex-types/v2/LoginAccountResponse.ts +9 -0
- package/services/mac-bridge/codex-types/v2/LogoutAccountResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/McpAuthStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/McpServerOauthLoginCompletedNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/McpServerOauthLoginParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/McpServerOauthLoginResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/McpServerRefreshResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/McpServerStatus.ts +9 -0
- package/services/mac-bridge/codex-types/v2/McpToolCallError.ts +5 -0
- package/services/mac-bridge/codex-types/v2/McpToolCallProgressNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/McpToolCallResult.ts +6 -0
- package/services/mac-bridge/codex-types/v2/McpToolCallStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/MergeStrategy.ts +5 -0
- package/services/mac-bridge/codex-types/v2/Model.ts +8 -0
- package/services/mac-bridge/codex-types/v2/ModelListParams.ts +17 -0
- package/services/mac-bridge/codex-types/v2/ModelListResponse.ts +11 -0
- package/services/mac-bridge/codex-types/v2/ModelRerouteReason.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ModelReroutedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/NetworkAccess.ts +5 -0
- package/services/mac-bridge/codex-types/v2/NetworkRequirements.ts +5 -0
- package/services/mac-bridge/codex-types/v2/OverriddenMetadata.ts +7 -0
- package/services/mac-bridge/codex-types/v2/PatchApplyStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/PatchChangeKind.ts +5 -0
- package/services/mac-bridge/codex-types/v2/PlanDeltaNotification.ts +9 -0
- package/services/mac-bridge/codex-types/v2/ProductSurface.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ProfileV2.ts +11 -0
- package/services/mac-bridge/codex-types/v2/RateLimitSnapshot.ts +8 -0
- package/services/mac-bridge/codex-types/v2/RateLimitWindow.ts +5 -0
- package/services/mac-bridge/codex-types/v2/RawResponseItemCompletedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ReadOnlyAccess.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ReasoningEffortOption.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ReasoningSummaryPartAddedNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ReasoningSummaryTextDeltaNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ReasoningTextDeltaNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/RemoteSkillSummary.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ResidencyRequirement.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ReviewDelivery.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ReviewStartParams.ts +12 -0
- package/services/mac-bridge/codex-types/v2/ReviewStartResponse.ts +13 -0
- package/services/mac-bridge/codex-types/v2/ReviewTarget.ts +9 -0
- package/services/mac-bridge/codex-types/v2/SandboxMode.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SandboxPolicy.ts +8 -0
- package/services/mac-bridge/codex-types/v2/SandboxWorkspaceWrite.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SessionSource.ts +6 -0
- package/services/mac-bridge/codex-types/v2/SkillDependencies.ts +6 -0
- package/services/mac-bridge/codex-types/v2/SkillErrorInfo.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SkillInterface.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SkillMetadata.ts +12 -0
- package/services/mac-bridge/codex-types/v2/SkillScope.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SkillToolDependency.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SkillsConfigWriteParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SkillsConfigWriteResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SkillsListEntry.ts +7 -0
- package/services/mac-bridge/codex-types/v2/SkillsListExtraRootsForCwd.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SkillsListParams.ts +18 -0
- package/services/mac-bridge/codex-types/v2/SkillsListResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/SkillsRemoteReadParams.ts +7 -0
- package/services/mac-bridge/codex-types/v2/SkillsRemoteReadResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/SkillsRemoteWriteParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/SkillsRemoteWriteResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/TerminalInteractionNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/TextElement.ts +14 -0
- package/services/mac-bridge/codex-types/v2/TextPosition.ts +13 -0
- package/services/mac-bridge/codex-types/v2/TextRange.ts +6 -0
- package/services/mac-bridge/codex-types/v2/Thread.ts +51 -0
- package/services/mac-bridge/codex-types/v2/ThreadArchiveParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadArchiveResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadArchivedNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadCompactStartParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadCompactStartResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadForkParams.ts +28 -0
- package/services/mac-bridge/codex-types/v2/ThreadForkResponse.ts +9 -0
- package/services/mac-bridge/codex-types/v2/ThreadItem.ts +81 -0
- package/services/mac-bridge/codex-types/v2/ThreadListParams.ts +39 -0
- package/services/mac-bridge/codex-types/v2/ThreadListResponse.ts +11 -0
- package/services/mac-bridge/codex-types/v2/ThreadLoadedListParams.ts +13 -0
- package/services/mac-bridge/codex-types/v2/ThreadLoadedListResponse.ts +14 -0
- package/services/mac-bridge/codex-types/v2/ThreadNameUpdatedNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadReadParams.ts +9 -0
- package/services/mac-bridge/codex-types/v2/ThreadReadResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ThreadResumeParams.ts +37 -0
- package/services/mac-bridge/codex-types/v2/ThreadResumeResponse.ts +9 -0
- package/services/mac-bridge/codex-types/v2/ThreadRollbackParams.ts +12 -0
- package/services/mac-bridge/codex-types/v2/ThreadRollbackResponse.ts +14 -0
- package/services/mac-bridge/codex-types/v2/ThreadSetNameParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadSetNameResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadSortKey.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadSourceKind.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadStartParams.ts +17 -0
- package/services/mac-bridge/codex-types/v2/ThreadStartResponse.ts +9 -0
- package/services/mac-bridge/codex-types/v2/ThreadStartedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ThreadTokenUsage.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ThreadTokenUsageUpdatedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ThreadUnarchiveParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ThreadUnarchiveResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/ThreadUnarchivedNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/TokenUsageBreakdown.ts +5 -0
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputAnswer.ts +8 -0
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputOption.ts +8 -0
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputParams.ts +9 -0
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputQuestion.ts +9 -0
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputResponse.ts +9 -0
- package/services/mac-bridge/codex-types/v2/ToolsV2.ts +5 -0
- package/services/mac-bridge/codex-types/v2/Turn.ts +18 -0
- package/services/mac-bridge/codex-types/v2/TurnCompletedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/TurnDiffUpdatedNotification.ts +9 -0
- package/services/mac-bridge/codex-types/v2/TurnError.ts +6 -0
- package/services/mac-bridge/codex-types/v2/TurnInterruptParams.ts +5 -0
- package/services/mac-bridge/codex-types/v2/TurnInterruptResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/TurnPlanStep.ts +6 -0
- package/services/mac-bridge/codex-types/v2/TurnPlanStepStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/TurnPlanUpdatedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/TurnStartParams.ts +44 -0
- package/services/mac-bridge/codex-types/v2/TurnStartResponse.ts +6 -0
- package/services/mac-bridge/codex-types/v2/TurnStartedNotification.ts +6 -0
- package/services/mac-bridge/codex-types/v2/TurnStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/TurnSteerParams.ts +11 -0
- package/services/mac-bridge/codex-types/v2/TurnSteerResponse.ts +5 -0
- package/services/mac-bridge/codex-types/v2/UserInput.ts +10 -0
- package/services/mac-bridge/codex-types/v2/WebSearchAction.ts +5 -0
- package/services/mac-bridge/codex-types/v2/WindowsWorldWritableWarningNotification.ts +5 -0
- package/services/mac-bridge/codex-types/v2/WriteStatus.ts +5 -0
- package/services/mac-bridge/codex-types/v2/index.ts +204 -0
- package/services/mac-bridge/eslint.config.cjs +22 -0
- package/services/mac-bridge/package.json +30 -0
- package/services/mac-bridge/schema.ts +0 -0
- package/services/mac-bridge/src/index.ts +18 -0
- package/services/mac-bridge/src/server.ts +426 -0
- package/services/mac-bridge/src/services/__tests__/gitService.test.ts +157 -0
- package/services/mac-bridge/src/services/__tests__/realtimeHub.test.ts +116 -0
- package/services/mac-bridge/src/services/__tests__/terminalService.test.ts +51 -0
- package/services/mac-bridge/src/services/codexAppServerClient.ts +507 -0
- package/services/mac-bridge/src/services/codexCliAdapter.ts +622 -0
- package/services/mac-bridge/src/services/gitService.ts +61 -0
- package/services/mac-bridge/src/services/realtimeHub.ts +25 -0
- package/services/mac-bridge/src/services/terminalService.ts +226 -0
- package/services/mac-bridge/src/types.ts +151 -0
- package/services/mac-bridge/src/utils/__tests__/threadMapping.test.ts +397 -0
- package/services/mac-bridge/src/utils/threadMapping.ts +176 -0
- package/services/mac-bridge/tsconfig.json +16 -0
- package/services/mac-bridge/vitest.config.ts +9 -0
- package/services/rust-bridge/.env.example +11 -0
- package/services/rust-bridge/Cargo.lock +1127 -0
- package/services/rust-bridge/Cargo.toml +14 -0
- package/services/rust-bridge/package.json +13 -0
- package/services/rust-bridge/security_best_practices_report.md +24 -0
- package/services/rust-bridge/src/main.rs +2713 -0
- package/services/rust-bridge/src/services/git.rs +271 -0
- package/services/rust-bridge/src/services/mod.rs +5 -0
- package/services/rust-bridge/src/services/terminal.rs +267 -0
- package/tsconfig.json +4 -0
package/STATUS.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Project Status & Assessment
|
|
2
|
+
|
|
3
|
+
> Last reviewed: 2026-02-20
|
|
4
|
+
|
|
5
|
+
## Verdict
|
|
6
|
+
|
|
7
|
+
The foundation is solid. The Codex integration protocol, the bridge architecture, and the real-time streaming pipeline are all correctly implemented. What we have is a working prototype that needs hardening and polish to become production-ready.
|
|
8
|
+
|
|
9
|
+
## Open Source License Requirements
|
|
10
|
+
|
|
11
|
+
- Apply the checklist in `docs/open-source-license-requirements.md` for all distributed builds.
|
|
12
|
+
- Include third-party notices in release artifacts before submission/distribution.
|
|
13
|
+
|
|
14
|
+
## Delivery Order (Working Plan)
|
|
15
|
+
|
|
16
|
+
1. **Phase 1 (in progress)**: Security + approvals
|
|
17
|
+
- [x] Bridge token auth (REST + WS)
|
|
18
|
+
- [x] Replace auto-accept with explicit approval queue and decision API
|
|
19
|
+
- [x] Mobile approval surface for allow/decline decisions
|
|
20
|
+
2. **Phase 2 (next)**: Thread UX polish (drawer navigation, smoother mobile interactions)
|
|
21
|
+
3. **Phase 3**: Worktree/mode metadata and archive/filter flows
|
|
22
|
+
4. **Phase 4**: Reliability (WS reconnect, app-server recovery) + production hardening
|
|
23
|
+
|
|
24
|
+
## Architecture
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
Mobile App (Expo/RN) ──HTTP REST + WS──▶ mac-bridge (Fastify) ──JSON-RPC 2.0 over stdio──▶ codex app-server
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Two-layer design — the phone talks to the bridge over the network, and the bridge speaks the Codex `app-server` protocol.
|
|
31
|
+
|
|
32
|
+
## What's Working
|
|
33
|
+
|
|
34
|
+
- **Full end-to-end loop** — list threads, create threads, send messages, stream responses via WebSocket deltas
|
|
35
|
+
- **Codex `app-server` integration** — proper JSON-RPC 2.0 handshake, request correlation, notification dispatch, explicit approval routing
|
|
36
|
+
- **Real-time streaming** — `thread.message.delta` events flow from Codex → bridge → WS → mobile UI
|
|
37
|
+
- **4 functional screens** — Threads, Terminal, Git, Settings with state management, loading states, error handling
|
|
38
|
+
- **Zod validation** on the bridge API, proper error codes (409 for busy threads), typed clients on both sides
|
|
39
|
+
- **Thread management** — list, create, open, reply, status tracking (idle/running/error/complete), run event log
|
|
40
|
+
- **Terminal** — execute shell commands, view stdout/stderr/exit code/duration
|
|
41
|
+
- **Git** — view branch, status, diff, commit with custom message
|
|
42
|
+
- **Settings** — health check, live WS connection indicator
|
|
43
|
+
|
|
44
|
+
## Tech Stack
|
|
45
|
+
|
|
46
|
+
| Component | Stack |
|
|
47
|
+
|-----------|-------|
|
|
48
|
+
| Mobile | Expo 54, React Native 0.81, React 19, React Navigation v7 |
|
|
49
|
+
| Bridge | Fastify v5, @fastify/websocket v11, Zod v3, tsx |
|
|
50
|
+
| Codex IPC | JSON-RPC 2.0 over stdio (`codex app-server --listen stdio://`) |
|
|
51
|
+
| Monorepo | npm workspaces |
|
|
52
|
+
| Language | TypeScript (ES2022) throughout |
|
|
53
|
+
|
|
54
|
+
## What Needs Work (priority order)
|
|
55
|
+
|
|
56
|
+
### P0 — Security
|
|
57
|
+
|
|
58
|
+
- [x] **Bridge auth token support added** — REST + WS now support bearer token auth (`BRIDGE_AUTH_TOKEN` / `EXPO_PUBLIC_HOST_BRIDGE_TOKEN`).
|
|
59
|
+
- [ ] **Pairing flow not added yet** — auth still depends on manual token setup rather than QR/one-time pairing.
|
|
60
|
+
|
|
61
|
+
### P1 — Reliability
|
|
62
|
+
|
|
63
|
+
- [ ] **No WebSocket reconnection** — if the WS drops, it stays dead. Add auto-reconnect with exponential backoff in `HostBridgeWsClient`.
|
|
64
|
+
- [ ] **No Codex process recovery** — if `codex app-server` crashes, the bridge is stuck. Add auto-restart with a health check loop.
|
|
65
|
+
- [ ] **No error recovery** — the bridge doesn't handle the Codex process dying mid-turn.
|
|
66
|
+
|
|
67
|
+
### P2 — Functionality Gaps
|
|
68
|
+
|
|
69
|
+
- [ ] **Git staging missing** — `GitService.commit()` only runs `git commit -m`, not `git add` first. No staging area management. Users will get "nothing to commit" errors.
|
|
70
|
+
- [ ] **No markdown rendering** — assistant messages are plain `Text` blocks. Codex responses are markdown-heavy.
|
|
71
|
+
- [ ] **No dedicated thread detail view** — message content is inline in the thread list; will get cramped with longer conversations.
|
|
72
|
+
- [ ] **No push notifications** — can't be alerted when a long-running Codex task finishes.
|
|
73
|
+
|
|
74
|
+
### P3 — Polish & Production
|
|
75
|
+
|
|
76
|
+
- [ ] **No tests** — zero test coverage (unit, integration, e2e).
|
|
77
|
+
- [ ] **No EAS build configuration** — needed for distributing to real devices.
|
|
78
|
+
- [ ] **No CI/CD pipeline** — no GitHub Actions or equivalent.
|
|
79
|
+
- [ ] **Bleeding-edge dependencies** — Expo 54 + RN 0.81 + React 19 may have ecosystem compat issues.
|
|
80
|
+
|
|
81
|
+
## Design Decisions Worth Noting
|
|
82
|
+
|
|
83
|
+
- **Explicit approval flow** — thread runs now use `approvalPolicy: 'on-request'` and surface command/file approvals to the mobile client (`/approvals` + `/approvals/:id/decision`) rather than auto-accepting.
|
|
84
|
+
- **In-memory thread cache** — the `CodexCliAdapter` caches threads in a `Map`. If the bridge restarts, it re-fetches from Codex's persisted sessions on next access.
|
|
85
|
+
- **Bridge binds to 0.0.0.0** — accessible from the LAN by default, which is required for physical device testing; keep auth enabled for non-local use.
|
|
86
|
+
|
|
87
|
+
## File Map
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
apps/mobile/
|
|
91
|
+
App.tsx Root — navigation + tab setup
|
|
92
|
+
src/
|
|
93
|
+
config.ts Bridge URL from env
|
|
94
|
+
api/
|
|
95
|
+
client.ts HostBridgeApiClient (REST)
|
|
96
|
+
ws.ts HostBridgeWsClient (WebSocket)
|
|
97
|
+
types.ts Shared TypeScript types
|
|
98
|
+
screens/
|
|
99
|
+
ThreadsScreen.tsx Chat UI — list + create + reply + streaming
|
|
100
|
+
TerminalScreen.tsx Command execution UI
|
|
101
|
+
GitScreen.tsx Git status/diff/commit
|
|
102
|
+
SettingsScreen.tsx Health + connection status
|
|
103
|
+
|
|
104
|
+
services/mac-bridge/
|
|
105
|
+
src/
|
|
106
|
+
index.ts Entry — port/host config, buildServer()
|
|
107
|
+
server.ts Fastify routes + dependency wiring
|
|
108
|
+
types.ts Shared types
|
|
109
|
+
services/
|
|
110
|
+
codexAppServerClient.ts JSON-RPC over stdio client
|
|
111
|
+
codexCliAdapter.ts High-level Codex adapter
|
|
112
|
+
realtimeHub.ts WS broadcast hub
|
|
113
|
+
terminalService.ts Shell execution via spawn
|
|
114
|
+
gitService.ts Git ops via terminalService
|
|
115
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
EXPO_PUBLIC_HOST_BRIDGE_URL=http://127.0.0.1:8787
|
|
2
|
+
EXPO_PUBLIC_HOST_BRIDGE_TOKEN=change-me
|
|
3
|
+
EXPO_PUBLIC_ALLOW_QUERY_TOKEN_AUTH=false
|
|
4
|
+
EXPO_PUBLIC_ALLOW_INSECURE_REMOTE_BRIDGE=false
|
|
5
|
+
EXPO_PUBLIC_EXTERNAL_STATUS_FULL_SYNC_DEBOUNCE_MS=450
|
|
6
|
+
EXPO_PUBLIC_PRIVACY_POLICY_URL=https://example.com/privacy
|
|
7
|
+
EXPO_PUBLIC_TERMS_OF_SERVICE_URL=https://example.com/terms
|
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
import 'react-native-gesture-handler';
|
|
2
|
+
|
|
3
|
+
import * as FileSystem from 'expo-file-system/legacy';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import {
|
|
6
|
+
Animated,
|
|
7
|
+
Keyboard,
|
|
8
|
+
PanResponder,
|
|
9
|
+
Pressable,
|
|
10
|
+
StyleSheet,
|
|
11
|
+
useWindowDimensions,
|
|
12
|
+
View,
|
|
13
|
+
} from 'react-native';
|
|
14
|
+
|
|
15
|
+
import { HostBridgeApiClient } from './src/api/client';
|
|
16
|
+
import type { ApprovalMode, Chat, ReasoningEffort } from './src/api/types';
|
|
17
|
+
import { HostBridgeWsClient } from './src/api/ws';
|
|
18
|
+
import { env } from './src/config';
|
|
19
|
+
import { DrawerContent } from './src/navigation/DrawerContent';
|
|
20
|
+
import { GitScreen } from './src/screens/GitScreen';
|
|
21
|
+
import { MainScreen, type MainScreenHandle } from './src/screens/MainScreen';
|
|
22
|
+
import { PrivacyScreen } from './src/screens/PrivacyScreen';
|
|
23
|
+
import { SettingsScreen } from './src/screens/SettingsScreen';
|
|
24
|
+
import { TerminalScreen } from './src/screens/TerminalScreen';
|
|
25
|
+
import { TermsScreen } from './src/screens/TermsScreen';
|
|
26
|
+
import { colors } from './src/theme';
|
|
27
|
+
|
|
28
|
+
type Screen = 'Main' | 'ChatGit' | 'Terminal' | 'Settings' | 'Privacy' | 'Terms';
|
|
29
|
+
|
|
30
|
+
const DRAWER_WIDTH = 280;
|
|
31
|
+
const EDGE_SWIPE_WIDTH = 24;
|
|
32
|
+
const SWIPE_OPEN_DISTANCE = 56;
|
|
33
|
+
const SWIPE_CLOSE_DISTANCE = 56;
|
|
34
|
+
const SWIPE_OPEN_VELOCITY = 0.4;
|
|
35
|
+
const SWIPE_CLOSE_VELOCITY = -0.4;
|
|
36
|
+
const APP_SETTINGS_FILE = 'clawdex-app-settings.json';
|
|
37
|
+
const APP_SETTINGS_VERSION = 1;
|
|
38
|
+
|
|
39
|
+
export default function App() {
|
|
40
|
+
const ws = useMemo(
|
|
41
|
+
() =>
|
|
42
|
+
new HostBridgeWsClient(env.hostBridgeUrl, {
|
|
43
|
+
authToken: env.hostBridgeToken,
|
|
44
|
+
allowQueryTokenAuth: env.allowWsQueryTokenAuth
|
|
45
|
+
}),
|
|
46
|
+
[]
|
|
47
|
+
);
|
|
48
|
+
const api = useMemo(
|
|
49
|
+
() =>
|
|
50
|
+
new HostBridgeApiClient({
|
|
51
|
+
ws,
|
|
52
|
+
}),
|
|
53
|
+
[ws]
|
|
54
|
+
);
|
|
55
|
+
const mainRef = useRef<MainScreenHandle>(null);
|
|
56
|
+
const [currentScreen, setCurrentScreen] = useState<Screen>('Main');
|
|
57
|
+
const [selectedChatId, setSelectedChatId] = useState<string | null>(null);
|
|
58
|
+
const [activeChat, setActiveChat] = useState<Chat | null>(null);
|
|
59
|
+
const [gitChat, setGitChat] = useState<Chat | null>(null);
|
|
60
|
+
const [pendingMainChatId, setPendingMainChatId] = useState<string | null>(null);
|
|
61
|
+
const [pendingMainChatSnapshot, setPendingMainChatSnapshot] = useState<Chat | null>(null);
|
|
62
|
+
const [defaultStartCwd, setDefaultStartCwd] = useState<string | null>(null);
|
|
63
|
+
const [defaultModelId, setDefaultModelId] = useState<string | null>(null);
|
|
64
|
+
const [defaultReasoningEffort, setDefaultReasoningEffort] =
|
|
65
|
+
useState<ReasoningEffort | null>(null);
|
|
66
|
+
const [approvalMode, setApprovalMode] = useState<ApprovalMode>('normal');
|
|
67
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
68
|
+
const drawerAnim = useRef(new Animated.Value(-DRAWER_WIDTH)).current;
|
|
69
|
+
const overlayAnim = useRef(new Animated.Value(0)).current;
|
|
70
|
+
const { width: screenWidth } = useWindowDimensions();
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
ws.connect();
|
|
74
|
+
return () => ws.disconnect();
|
|
75
|
+
}, [ws]);
|
|
76
|
+
|
|
77
|
+
const saveAppSettings = useCallback(
|
|
78
|
+
async (
|
|
79
|
+
nextModelId: string | null,
|
|
80
|
+
nextEffort: ReasoningEffort | null,
|
|
81
|
+
nextApprovalMode: ApprovalMode
|
|
82
|
+
) => {
|
|
83
|
+
const settingsPath = getAppSettingsPath();
|
|
84
|
+
if (!settingsPath) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const payload = JSON.stringify({
|
|
89
|
+
version: APP_SETTINGS_VERSION,
|
|
90
|
+
defaultModelId: nextModelId,
|
|
91
|
+
defaultReasoningEffort: nextEffort,
|
|
92
|
+
approvalMode: nextApprovalMode,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
await FileSystem.writeAsStringAsync(settingsPath, payload);
|
|
97
|
+
} catch {
|
|
98
|
+
// Best effort persistence only.
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
[]
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
let cancelled = false;
|
|
106
|
+
|
|
107
|
+
const loadSettings = async () => {
|
|
108
|
+
const settingsPath = getAppSettingsPath();
|
|
109
|
+
if (!settingsPath) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
const raw = await FileSystem.readAsStringAsync(settingsPath);
|
|
115
|
+
if (cancelled) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const parsed = parseAppSettings(raw);
|
|
119
|
+
setDefaultModelId(parsed.defaultModelId);
|
|
120
|
+
setDefaultReasoningEffort(parsed.defaultReasoningEffort);
|
|
121
|
+
setApprovalMode(parsed.approvalMode);
|
|
122
|
+
} catch {
|
|
123
|
+
if (!cancelled) {
|
|
124
|
+
setDefaultModelId(null);
|
|
125
|
+
setDefaultReasoningEffort(null);
|
|
126
|
+
setApprovalMode('normal');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
void loadSettings();
|
|
132
|
+
return () => {
|
|
133
|
+
cancelled = true;
|
|
134
|
+
};
|
|
135
|
+
}, []);
|
|
136
|
+
|
|
137
|
+
const openDrawer = useCallback(() => {
|
|
138
|
+
Keyboard.dismiss();
|
|
139
|
+
setDrawerOpen(true);
|
|
140
|
+
Animated.parallel([
|
|
141
|
+
Animated.spring(drawerAnim, {
|
|
142
|
+
toValue: 0,
|
|
143
|
+
useNativeDriver: true,
|
|
144
|
+
bounciness: 0,
|
|
145
|
+
speed: 20,
|
|
146
|
+
}),
|
|
147
|
+
Animated.timing(overlayAnim, {
|
|
148
|
+
toValue: 1,
|
|
149
|
+
duration: 200,
|
|
150
|
+
useNativeDriver: true,
|
|
151
|
+
}),
|
|
152
|
+
]).start();
|
|
153
|
+
}, [drawerAnim, overlayAnim]);
|
|
154
|
+
|
|
155
|
+
const closeDrawer = useCallback(() => {
|
|
156
|
+
setDrawerOpen(false);
|
|
157
|
+
Animated.parallel([
|
|
158
|
+
Animated.spring(drawerAnim, {
|
|
159
|
+
toValue: -DRAWER_WIDTH,
|
|
160
|
+
useNativeDriver: true,
|
|
161
|
+
bounciness: 0,
|
|
162
|
+
speed: 20,
|
|
163
|
+
}),
|
|
164
|
+
Animated.timing(overlayAnim, {
|
|
165
|
+
toValue: 0,
|
|
166
|
+
duration: 200,
|
|
167
|
+
useNativeDriver: true,
|
|
168
|
+
}),
|
|
169
|
+
]).start();
|
|
170
|
+
}, [drawerAnim, overlayAnim]);
|
|
171
|
+
|
|
172
|
+
const openSwipeResponder = useMemo(
|
|
173
|
+
() =>
|
|
174
|
+
PanResponder.create({
|
|
175
|
+
onMoveShouldSetPanResponder: (_, gesture) => {
|
|
176
|
+
if (drawerOpen) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (gesture.dx <= 0) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const isMostlyHorizontal = Math.abs(gesture.dx) > Math.abs(gesture.dy);
|
|
185
|
+
const isFromEdge = gesture.moveX <= EDGE_SWIPE_WIDTH + 12;
|
|
186
|
+
|
|
187
|
+
return isMostlyHorizontal && isFromEdge && gesture.dx > 8;
|
|
188
|
+
},
|
|
189
|
+
onPanResponderRelease: (_, gesture) => {
|
|
190
|
+
if (
|
|
191
|
+
gesture.dx > SWIPE_OPEN_DISTANCE ||
|
|
192
|
+
gesture.vx > SWIPE_OPEN_VELOCITY
|
|
193
|
+
) {
|
|
194
|
+
if (currentScreen === 'ChatGit') {
|
|
195
|
+
const chatId = gitChat?.id ?? activeChat?.id ?? selectedChatId;
|
|
196
|
+
const resumeChat =
|
|
197
|
+
gitChat && gitChat.id === chatId
|
|
198
|
+
? gitChat
|
|
199
|
+
: activeChat && activeChat.id === chatId
|
|
200
|
+
? activeChat
|
|
201
|
+
: null;
|
|
202
|
+
setCurrentScreen('Main');
|
|
203
|
+
setGitChat(null);
|
|
204
|
+
if (chatId) {
|
|
205
|
+
setSelectedChatId(chatId);
|
|
206
|
+
setPendingMainChatId(chatId);
|
|
207
|
+
setPendingMainChatSnapshot(resumeChat);
|
|
208
|
+
}
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
openDrawer();
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
}),
|
|
216
|
+
[activeChat, currentScreen, drawerOpen, gitChat, openDrawer, selectedChatId]
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
const closeSwipeResponder = useMemo(
|
|
220
|
+
() =>
|
|
221
|
+
PanResponder.create({
|
|
222
|
+
onMoveShouldSetPanResponder: (_, gesture) => {
|
|
223
|
+
if (!drawerOpen) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (gesture.dx >= 0) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const isMostlyHorizontal = Math.abs(gesture.dx) > Math.abs(gesture.dy);
|
|
232
|
+
return isMostlyHorizontal && gesture.dx < -8;
|
|
233
|
+
},
|
|
234
|
+
onPanResponderRelease: (_, gesture) => {
|
|
235
|
+
if (
|
|
236
|
+
gesture.dx < -SWIPE_CLOSE_DISTANCE ||
|
|
237
|
+
gesture.vx < SWIPE_CLOSE_VELOCITY
|
|
238
|
+
) {
|
|
239
|
+
closeDrawer();
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
}),
|
|
243
|
+
[closeDrawer, drawerOpen]
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
const navigate = useCallback(
|
|
247
|
+
(screen: Screen) => {
|
|
248
|
+
setCurrentScreen(screen);
|
|
249
|
+
closeDrawer();
|
|
250
|
+
},
|
|
251
|
+
[closeDrawer]
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
const handleSelectChat = useCallback(
|
|
255
|
+
(id: string) => {
|
|
256
|
+
setSelectedChatId(id);
|
|
257
|
+
setGitChat(null);
|
|
258
|
+
setCurrentScreen('Main');
|
|
259
|
+
setPendingMainChatId(id);
|
|
260
|
+
setPendingMainChatSnapshot(null);
|
|
261
|
+
closeDrawer();
|
|
262
|
+
},
|
|
263
|
+
[closeDrawer]
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
const handleNewChat = useCallback(() => {
|
|
267
|
+
setPendingMainChatId(null);
|
|
268
|
+
setPendingMainChatSnapshot(null);
|
|
269
|
+
setSelectedChatId(null);
|
|
270
|
+
setActiveChat(null);
|
|
271
|
+
setGitChat(null);
|
|
272
|
+
setCurrentScreen('Main');
|
|
273
|
+
mainRef.current?.startNewChat();
|
|
274
|
+
closeDrawer();
|
|
275
|
+
}, [closeDrawer]);
|
|
276
|
+
|
|
277
|
+
const handleDefaultModelSettingsChange = useCallback(
|
|
278
|
+
(modelId: string | null, effort: ReasoningEffort | null) => {
|
|
279
|
+
const normalizedModelId = normalizeModelId(modelId);
|
|
280
|
+
const normalizedEffort = normalizeReasoningEffort(effort);
|
|
281
|
+
setDefaultModelId(normalizedModelId);
|
|
282
|
+
setDefaultReasoningEffort(normalizedEffort);
|
|
283
|
+
void saveAppSettings(normalizedModelId, normalizedEffort, approvalMode);
|
|
284
|
+
},
|
|
285
|
+
[approvalMode, saveAppSettings]
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
const handleApprovalModeChange = useCallback(
|
|
289
|
+
(nextMode: ApprovalMode) => {
|
|
290
|
+
const normalizedMode = normalizeApprovalMode(nextMode);
|
|
291
|
+
setApprovalMode(normalizedMode);
|
|
292
|
+
void saveAppSettings(defaultModelId, defaultReasoningEffort, normalizedMode);
|
|
293
|
+
},
|
|
294
|
+
[defaultModelId, defaultReasoningEffort, saveAppSettings]
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
const handleOpenChatGit = useCallback((chat: Chat) => {
|
|
298
|
+
setGitChat(chat);
|
|
299
|
+
setSelectedChatId(chat.id);
|
|
300
|
+
setCurrentScreen('ChatGit');
|
|
301
|
+
}, []);
|
|
302
|
+
|
|
303
|
+
const handleChatContextChange = useCallback((chat: Chat | null) => {
|
|
304
|
+
setActiveChat(chat);
|
|
305
|
+
setSelectedChatId(chat?.id ?? null);
|
|
306
|
+
}, []);
|
|
307
|
+
|
|
308
|
+
const handleGitChatUpdated = useCallback((chat: Chat) => {
|
|
309
|
+
setGitChat(chat);
|
|
310
|
+
setActiveChat((prev) => (prev?.id === chat.id ? chat : prev));
|
|
311
|
+
}, []);
|
|
312
|
+
|
|
313
|
+
const handleCloseGit = useCallback(() => {
|
|
314
|
+
const chatId = gitChat?.id ?? activeChat?.id ?? selectedChatId;
|
|
315
|
+
const resumeChat =
|
|
316
|
+
gitChat && gitChat.id === chatId
|
|
317
|
+
? gitChat
|
|
318
|
+
: activeChat && activeChat.id === chatId
|
|
319
|
+
? activeChat
|
|
320
|
+
: null;
|
|
321
|
+
setCurrentScreen('Main');
|
|
322
|
+
setGitChat(null);
|
|
323
|
+
if (chatId) {
|
|
324
|
+
setSelectedChatId(chatId);
|
|
325
|
+
setPendingMainChatId(chatId);
|
|
326
|
+
setPendingMainChatSnapshot(resumeChat);
|
|
327
|
+
}
|
|
328
|
+
}, [activeChat, gitChat, selectedChatId]);
|
|
329
|
+
|
|
330
|
+
const openPrivacy = useCallback(() => {
|
|
331
|
+
setCurrentScreen('Privacy');
|
|
332
|
+
}, []);
|
|
333
|
+
|
|
334
|
+
const openTerms = useCallback(() => {
|
|
335
|
+
setCurrentScreen('Terms');
|
|
336
|
+
}, []);
|
|
337
|
+
|
|
338
|
+
const renderScreen = () => {
|
|
339
|
+
switch (currentScreen) {
|
|
340
|
+
case 'Terminal':
|
|
341
|
+
return <TerminalScreen api={api} ws={ws} onOpenDrawer={openDrawer} />;
|
|
342
|
+
case 'ChatGit':
|
|
343
|
+
return gitChat ? (
|
|
344
|
+
<GitScreen
|
|
345
|
+
api={api}
|
|
346
|
+
chat={gitChat}
|
|
347
|
+
onBack={handleCloseGit}
|
|
348
|
+
onChatUpdated={handleGitChatUpdated}
|
|
349
|
+
/>
|
|
350
|
+
) : (
|
|
351
|
+
<MainScreen
|
|
352
|
+
ref={mainRef}
|
|
353
|
+
api={api}
|
|
354
|
+
ws={ws}
|
|
355
|
+
onOpenDrawer={openDrawer}
|
|
356
|
+
onOpenGit={handleOpenChatGit}
|
|
357
|
+
defaultStartCwd={defaultStartCwd}
|
|
358
|
+
defaultModelId={defaultModelId}
|
|
359
|
+
defaultReasoningEffort={defaultReasoningEffort}
|
|
360
|
+
approvalMode={approvalMode}
|
|
361
|
+
onDefaultStartCwdChange={setDefaultStartCwd}
|
|
362
|
+
onChatContextChange={handleChatContextChange}
|
|
363
|
+
pendingOpenChatId={pendingMainChatId}
|
|
364
|
+
pendingOpenChatSnapshot={pendingMainChatSnapshot}
|
|
365
|
+
onPendingOpenChatHandled={() => {
|
|
366
|
+
setPendingMainChatId(null);
|
|
367
|
+
setPendingMainChatSnapshot(null);
|
|
368
|
+
}}
|
|
369
|
+
/>
|
|
370
|
+
);
|
|
371
|
+
case 'Settings':
|
|
372
|
+
return (
|
|
373
|
+
<SettingsScreen
|
|
374
|
+
api={api}
|
|
375
|
+
ws={ws}
|
|
376
|
+
bridgeUrl={env.hostBridgeUrl}
|
|
377
|
+
defaultModelId={defaultModelId}
|
|
378
|
+
defaultReasoningEffort={defaultReasoningEffort}
|
|
379
|
+
onDefaultModelSettingsChange={handleDefaultModelSettingsChange}
|
|
380
|
+
approvalMode={approvalMode}
|
|
381
|
+
onApprovalModeChange={handleApprovalModeChange}
|
|
382
|
+
onOpenDrawer={openDrawer}
|
|
383
|
+
onOpenPrivacy={openPrivacy}
|
|
384
|
+
onOpenTerms={openTerms}
|
|
385
|
+
/>
|
|
386
|
+
);
|
|
387
|
+
case 'Privacy':
|
|
388
|
+
return (
|
|
389
|
+
<PrivacyScreen
|
|
390
|
+
policyUrl={env.privacyPolicyUrl}
|
|
391
|
+
onOpenDrawer={openDrawer}
|
|
392
|
+
/>
|
|
393
|
+
);
|
|
394
|
+
case 'Terms':
|
|
395
|
+
return (
|
|
396
|
+
<TermsScreen
|
|
397
|
+
termsUrl={env.termsOfServiceUrl}
|
|
398
|
+
onOpenDrawer={openDrawer}
|
|
399
|
+
/>
|
|
400
|
+
);
|
|
401
|
+
default:
|
|
402
|
+
return (
|
|
403
|
+
<MainScreen
|
|
404
|
+
ref={mainRef}
|
|
405
|
+
api={api}
|
|
406
|
+
ws={ws}
|
|
407
|
+
onOpenDrawer={openDrawer}
|
|
408
|
+
onOpenGit={handleOpenChatGit}
|
|
409
|
+
defaultStartCwd={defaultStartCwd}
|
|
410
|
+
defaultModelId={defaultModelId}
|
|
411
|
+
defaultReasoningEffort={defaultReasoningEffort}
|
|
412
|
+
approvalMode={approvalMode}
|
|
413
|
+
onDefaultStartCwdChange={setDefaultStartCwd}
|
|
414
|
+
onChatContextChange={handleChatContextChange}
|
|
415
|
+
pendingOpenChatId={pendingMainChatId}
|
|
416
|
+
pendingOpenChatSnapshot={pendingMainChatSnapshot}
|
|
417
|
+
onPendingOpenChatHandled={() => {
|
|
418
|
+
setPendingMainChatId(null);
|
|
419
|
+
setPendingMainChatSnapshot(null);
|
|
420
|
+
}}
|
|
421
|
+
/>
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
return (
|
|
427
|
+
<View style={styles.root}>
|
|
428
|
+
{/* Main content */}
|
|
429
|
+
<View style={[styles.screen, { width: screenWidth }]}>
|
|
430
|
+
{renderScreen()}
|
|
431
|
+
</View>
|
|
432
|
+
|
|
433
|
+
{/* Overlay */}
|
|
434
|
+
<Animated.View
|
|
435
|
+
pointerEvents={drawerOpen ? 'auto' : 'none'}
|
|
436
|
+
{...closeSwipeResponder.panHandlers}
|
|
437
|
+
style={[styles.overlay, { opacity: overlayAnim }]}
|
|
438
|
+
>
|
|
439
|
+
<Pressable style={StyleSheet.absoluteFill} onPress={closeDrawer} />
|
|
440
|
+
</Animated.View>
|
|
441
|
+
|
|
442
|
+
{/* Drawer */}
|
|
443
|
+
<Animated.View
|
|
444
|
+
{...closeSwipeResponder.panHandlers}
|
|
445
|
+
style={[
|
|
446
|
+
styles.drawer,
|
|
447
|
+
{ transform: [{ translateX: drawerAnim }] },
|
|
448
|
+
]}
|
|
449
|
+
>
|
|
450
|
+
<DrawerContent
|
|
451
|
+
api={api}
|
|
452
|
+
ws={ws}
|
|
453
|
+
selectedChatId={selectedChatId}
|
|
454
|
+
selectedDefaultCwd={defaultStartCwd}
|
|
455
|
+
onSelectDefaultCwd={setDefaultStartCwd}
|
|
456
|
+
onSelectChat={handleSelectChat}
|
|
457
|
+
onNewChat={handleNewChat}
|
|
458
|
+
onNavigate={navigate}
|
|
459
|
+
/>
|
|
460
|
+
</Animated.View>
|
|
461
|
+
|
|
462
|
+
<View
|
|
463
|
+
pointerEvents={drawerOpen ? 'none' : 'auto'}
|
|
464
|
+
style={styles.edgeSwipeZone}
|
|
465
|
+
{...openSwipeResponder.panHandlers}
|
|
466
|
+
/>
|
|
467
|
+
</View>
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function getAppSettingsPath(): string | null {
|
|
472
|
+
const base = FileSystem.documentDirectory;
|
|
473
|
+
if (typeof base !== 'string' || base.trim().length === 0) {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return `${base}${APP_SETTINGS_FILE}`;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function parseAppSettings(raw: string): {
|
|
481
|
+
defaultModelId: string | null;
|
|
482
|
+
defaultReasoningEffort: ReasoningEffort | null;
|
|
483
|
+
approvalMode: ApprovalMode;
|
|
484
|
+
} {
|
|
485
|
+
if (typeof raw !== 'string' || raw.trim().length === 0) {
|
|
486
|
+
return {
|
|
487
|
+
defaultModelId: null,
|
|
488
|
+
defaultReasoningEffort: null,
|
|
489
|
+
approvalMode: 'normal',
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
try {
|
|
494
|
+
const parsed = JSON.parse(raw);
|
|
495
|
+
if (
|
|
496
|
+
!parsed ||
|
|
497
|
+
typeof parsed !== 'object' ||
|
|
498
|
+
parsed.version !== APP_SETTINGS_VERSION
|
|
499
|
+
) {
|
|
500
|
+
return {
|
|
501
|
+
defaultModelId: null,
|
|
502
|
+
defaultReasoningEffort: null,
|
|
503
|
+
approvalMode: 'normal',
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return {
|
|
508
|
+
defaultModelId: normalizeModelId(
|
|
509
|
+
(parsed as { defaultModelId?: unknown }).defaultModelId
|
|
510
|
+
),
|
|
511
|
+
defaultReasoningEffort: normalizeReasoningEffort(
|
|
512
|
+
(parsed as { defaultReasoningEffort?: unknown }).defaultReasoningEffort
|
|
513
|
+
),
|
|
514
|
+
approvalMode: normalizeApprovalMode(
|
|
515
|
+
(parsed as { approvalMode?: unknown }).approvalMode
|
|
516
|
+
),
|
|
517
|
+
};
|
|
518
|
+
} catch {
|
|
519
|
+
return {
|
|
520
|
+
defaultModelId: null,
|
|
521
|
+
defaultReasoningEffort: null,
|
|
522
|
+
approvalMode: 'normal',
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function normalizeModelId(value: unknown): string | null {
|
|
528
|
+
if (typeof value !== 'string') {
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const trimmed = value.trim();
|
|
533
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function normalizeReasoningEffort(value: unknown): ReasoningEffort | null {
|
|
537
|
+
if (typeof value !== 'string') {
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const normalized = value.trim().toLowerCase();
|
|
542
|
+
if (
|
|
543
|
+
normalized === 'none' ||
|
|
544
|
+
normalized === 'minimal' ||
|
|
545
|
+
normalized === 'low' ||
|
|
546
|
+
normalized === 'medium' ||
|
|
547
|
+
normalized === 'high' ||
|
|
548
|
+
normalized === 'xhigh'
|
|
549
|
+
) {
|
|
550
|
+
return normalized;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function normalizeApprovalMode(value: unknown): ApprovalMode {
|
|
557
|
+
return value === 'yolo' ? 'yolo' : 'normal';
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const styles = StyleSheet.create({
|
|
561
|
+
root: {
|
|
562
|
+
flex: 1,
|
|
563
|
+
backgroundColor: colors.bgMain,
|
|
564
|
+
},
|
|
565
|
+
screen: {
|
|
566
|
+
flex: 1,
|
|
567
|
+
},
|
|
568
|
+
overlay: {
|
|
569
|
+
...StyleSheet.absoluteFillObject,
|
|
570
|
+
backgroundColor: 'rgba(0,0,0,0.5)',
|
|
571
|
+
zIndex: 10,
|
|
572
|
+
},
|
|
573
|
+
drawer: {
|
|
574
|
+
position: 'absolute',
|
|
575
|
+
top: 0,
|
|
576
|
+
left: 0,
|
|
577
|
+
bottom: 0,
|
|
578
|
+
width: DRAWER_WIDTH,
|
|
579
|
+
zIndex: 20,
|
|
580
|
+
},
|
|
581
|
+
edgeSwipeZone: {
|
|
582
|
+
position: 'absolute',
|
|
583
|
+
top: 0,
|
|
584
|
+
left: 0,
|
|
585
|
+
bottom: 0,
|
|
586
|
+
width: EDGE_SWIPE_WIDTH,
|
|
587
|
+
zIndex: 30,
|
|
588
|
+
},
|
|
589
|
+
});
|