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
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
use std::{path::PathBuf, sync::Arc};
|
|
2
|
+
|
|
3
|
+
use crate::{
|
|
4
|
+
normalize_path, BridgeError, GitCommitResponse, GitDiffResponse, GitPushResponse,
|
|
5
|
+
GitStatusResponse,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
use super::TerminalService;
|
|
9
|
+
|
|
10
|
+
#[derive(Clone)]
|
|
11
|
+
pub(crate) struct GitService {
|
|
12
|
+
terminal: Arc<TerminalService>,
|
|
13
|
+
root: PathBuf,
|
|
14
|
+
allow_outside_root: bool,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
impl GitService {
|
|
18
|
+
pub(crate) fn new(
|
|
19
|
+
terminal: Arc<TerminalService>,
|
|
20
|
+
root: PathBuf,
|
|
21
|
+
allow_outside_root: bool,
|
|
22
|
+
) -> Self {
|
|
23
|
+
Self {
|
|
24
|
+
terminal,
|
|
25
|
+
root,
|
|
26
|
+
allow_outside_root,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fn resolve_repo_path(&self, raw_cwd: Option<&str>) -> Result<PathBuf, BridgeError> {
|
|
31
|
+
resolve_git_cwd(raw_cwd, &self.root, self.allow_outside_root)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pub(crate) async fn get_status(
|
|
35
|
+
&self,
|
|
36
|
+
raw_cwd: Option<&str>,
|
|
37
|
+
) -> Result<GitStatusResponse, BridgeError> {
|
|
38
|
+
let repo_path = self.resolve_repo_path(raw_cwd)?;
|
|
39
|
+
let args = vec![
|
|
40
|
+
"-C".to_string(),
|
|
41
|
+
repo_path.to_string_lossy().to_string(),
|
|
42
|
+
"status".to_string(),
|
|
43
|
+
"--short".to_string(),
|
|
44
|
+
"--branch".to_string(),
|
|
45
|
+
];
|
|
46
|
+
let result = self
|
|
47
|
+
.terminal
|
|
48
|
+
.execute_binary("git", &args, repo_path.clone(), None)
|
|
49
|
+
.await?;
|
|
50
|
+
|
|
51
|
+
if result.code != Some(0) {
|
|
52
|
+
return Err(BridgeError::server(
|
|
53
|
+
&(if !result.stderr.is_empty() {
|
|
54
|
+
result.stderr.clone()
|
|
55
|
+
} else if !result.stdout.is_empty() {
|
|
56
|
+
result.stdout.clone()
|
|
57
|
+
} else {
|
|
58
|
+
"git status failed".to_string()
|
|
59
|
+
}),
|
|
60
|
+
));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let lines = result
|
|
64
|
+
.stdout
|
|
65
|
+
.lines()
|
|
66
|
+
.filter(|line| !line.trim().is_empty())
|
|
67
|
+
.collect::<Vec<_>>();
|
|
68
|
+
|
|
69
|
+
let branch = lines
|
|
70
|
+
.iter()
|
|
71
|
+
.find(|line| line.starts_with("## "))
|
|
72
|
+
.map(|line| {
|
|
73
|
+
line.trim_start_matches("## ")
|
|
74
|
+
.split("...")
|
|
75
|
+
.next()
|
|
76
|
+
.unwrap_or("unknown")
|
|
77
|
+
})
|
|
78
|
+
.unwrap_or("unknown")
|
|
79
|
+
.to_string();
|
|
80
|
+
|
|
81
|
+
let clean = lines.iter().filter(|line| !line.starts_with("## ")).count() == 0;
|
|
82
|
+
|
|
83
|
+
Ok(GitStatusResponse {
|
|
84
|
+
branch,
|
|
85
|
+
clean,
|
|
86
|
+
raw: result.stdout,
|
|
87
|
+
cwd: repo_path.to_string_lossy().to_string(),
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
pub(crate) async fn get_diff(
|
|
92
|
+
&self,
|
|
93
|
+
raw_cwd: Option<&str>,
|
|
94
|
+
) -> Result<GitDiffResponse, BridgeError> {
|
|
95
|
+
let repo_path = self.resolve_repo_path(raw_cwd)?;
|
|
96
|
+
let args = vec![
|
|
97
|
+
"-C".to_string(),
|
|
98
|
+
repo_path.to_string_lossy().to_string(),
|
|
99
|
+
"diff".to_string(),
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
let result = self
|
|
103
|
+
.terminal
|
|
104
|
+
.execute_binary("git", &args, repo_path.clone(), None)
|
|
105
|
+
.await?;
|
|
106
|
+
|
|
107
|
+
if result.code != Some(0) {
|
|
108
|
+
return Err(BridgeError::server(
|
|
109
|
+
&(if !result.stderr.is_empty() {
|
|
110
|
+
result.stderr.clone()
|
|
111
|
+
} else if !result.stdout.is_empty() {
|
|
112
|
+
result.stdout.clone()
|
|
113
|
+
} else {
|
|
114
|
+
"git diff failed".to_string()
|
|
115
|
+
}),
|
|
116
|
+
));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
Ok(GitDiffResponse {
|
|
120
|
+
diff: result.stdout,
|
|
121
|
+
cwd: repo_path.to_string_lossy().to_string(),
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
pub(crate) async fn commit(
|
|
126
|
+
&self,
|
|
127
|
+
message: String,
|
|
128
|
+
raw_cwd: Option<&str>,
|
|
129
|
+
) -> Result<GitCommitResponse, BridgeError> {
|
|
130
|
+
let repo_path = self.resolve_repo_path(raw_cwd)?;
|
|
131
|
+
let add_args = vec![
|
|
132
|
+
"-C".to_string(),
|
|
133
|
+
repo_path.to_string_lossy().to_string(),
|
|
134
|
+
"add".to_string(),
|
|
135
|
+
"-A".to_string(),
|
|
136
|
+
];
|
|
137
|
+
let add_result = self
|
|
138
|
+
.terminal
|
|
139
|
+
.execute_binary("git", &add_args, repo_path.clone(), None)
|
|
140
|
+
.await?;
|
|
141
|
+
if add_result.code != Some(0) {
|
|
142
|
+
return Ok(GitCommitResponse {
|
|
143
|
+
code: add_result.code,
|
|
144
|
+
stdout: add_result.stdout,
|
|
145
|
+
stderr: if !add_result.stderr.is_empty() {
|
|
146
|
+
add_result.stderr
|
|
147
|
+
} else {
|
|
148
|
+
"git add -A failed".to_string()
|
|
149
|
+
},
|
|
150
|
+
committed: false,
|
|
151
|
+
cwd: repo_path.to_string_lossy().to_string(),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
let args = vec![
|
|
156
|
+
"-C".to_string(),
|
|
157
|
+
repo_path.to_string_lossy().to_string(),
|
|
158
|
+
"commit".to_string(),
|
|
159
|
+
"-m".to_string(),
|
|
160
|
+
message,
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
let result = self
|
|
164
|
+
.terminal
|
|
165
|
+
.execute_binary("git", &args, repo_path.clone(), None)
|
|
166
|
+
.await?;
|
|
167
|
+
|
|
168
|
+
Ok(GitCommitResponse {
|
|
169
|
+
code: result.code,
|
|
170
|
+
stdout: result.stdout,
|
|
171
|
+
stderr: result.stderr,
|
|
172
|
+
committed: result.code == Some(0),
|
|
173
|
+
cwd: repo_path.to_string_lossy().to_string(),
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
pub(crate) async fn push(&self, raw_cwd: Option<&str>) -> Result<GitPushResponse, BridgeError> {
|
|
178
|
+
let repo_path = self.resolve_repo_path(raw_cwd)?;
|
|
179
|
+
let args = vec![
|
|
180
|
+
"-C".to_string(),
|
|
181
|
+
repo_path.to_string_lossy().to_string(),
|
|
182
|
+
"push".to_string(),
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
let result = self
|
|
186
|
+
.terminal
|
|
187
|
+
.execute_binary("git", &args, repo_path.clone(), None)
|
|
188
|
+
.await?;
|
|
189
|
+
|
|
190
|
+
Ok(GitPushResponse {
|
|
191
|
+
code: result.code,
|
|
192
|
+
stdout: result.stdout,
|
|
193
|
+
stderr: result.stderr,
|
|
194
|
+
pushed: result.code == Some(0),
|
|
195
|
+
cwd: repo_path.to_string_lossy().to_string(),
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
fn resolve_git_cwd(
|
|
201
|
+
raw_cwd: Option<&str>,
|
|
202
|
+
root: &PathBuf,
|
|
203
|
+
allow_outside_root: bool,
|
|
204
|
+
) -> Result<PathBuf, BridgeError> {
|
|
205
|
+
let normalized_root = normalize_path(root);
|
|
206
|
+
let requested = match raw_cwd {
|
|
207
|
+
Some(raw) if !raw.trim().is_empty() => {
|
|
208
|
+
let path = PathBuf::from(raw);
|
|
209
|
+
if path.is_absolute() {
|
|
210
|
+
path
|
|
211
|
+
} else {
|
|
212
|
+
root.join(path)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
_ => root.to_path_buf(),
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
let normalized = normalize_path(&requested);
|
|
219
|
+
if !allow_outside_root && !normalized.starts_with(&normalized_root) {
|
|
220
|
+
return Err(BridgeError::invalid_params(
|
|
221
|
+
"cwd must stay within BRIDGE_WORKDIR",
|
|
222
|
+
));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
Ok(normalized)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
#[cfg(test)]
|
|
229
|
+
mod tests {
|
|
230
|
+
use super::resolve_git_cwd;
|
|
231
|
+
use std::path::PathBuf;
|
|
232
|
+
|
|
233
|
+
#[test]
|
|
234
|
+
fn resolves_relative_cwd_against_root() {
|
|
235
|
+
let root = PathBuf::from("/bridge/root");
|
|
236
|
+
let resolved =
|
|
237
|
+
resolve_git_cwd(Some("workspace/repo"), &root, false).expect("resolve relative cwd");
|
|
238
|
+
assert_eq!(resolved, PathBuf::from("/bridge/root/workspace/repo"));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
#[test]
|
|
242
|
+
fn rejects_absolute_cwd_outside_root_by_default() {
|
|
243
|
+
let root = PathBuf::from("/bridge/root");
|
|
244
|
+
let error = resolve_git_cwd(Some("/external/repo"), &root, false)
|
|
245
|
+
.expect_err("reject outside-root cwd");
|
|
246
|
+
assert_eq!(error.code, -32602);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
#[test]
|
|
250
|
+
fn rejects_relative_cwd_that_escapes_root() {
|
|
251
|
+
let root = PathBuf::from("/bridge/root");
|
|
252
|
+
let error =
|
|
253
|
+
resolve_git_cwd(Some("../outside"), &root, false).expect_err("reject escaped cwd");
|
|
254
|
+
assert_eq!(error.code, -32602);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
#[test]
|
|
258
|
+
fn allows_absolute_cwd_outside_root_when_enabled() {
|
|
259
|
+
let root = PathBuf::from("/bridge/root");
|
|
260
|
+
let resolved =
|
|
261
|
+
resolve_git_cwd(Some("/external/repo"), &root, true).expect("allow outside root");
|
|
262
|
+
assert_eq!(resolved, PathBuf::from("/external/repo"));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
#[test]
|
|
266
|
+
fn falls_back_to_root_when_cwd_missing() {
|
|
267
|
+
let root = PathBuf::from("/bridge/root");
|
|
268
|
+
let resolved = resolve_git_cwd(None, &root, false).expect("fallback to root");
|
|
269
|
+
assert_eq!(resolved, root);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
use std::{
|
|
2
|
+
collections::HashSet,
|
|
3
|
+
path::PathBuf,
|
|
4
|
+
process::Stdio,
|
|
5
|
+
time::{Duration, Instant},
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
use tokio::{io::AsyncReadExt, process::Command, time::timeout};
|
|
9
|
+
|
|
10
|
+
use crate::{
|
|
11
|
+
contains_disallowed_control_chars, normalize_path, BridgeError, TerminalExecRequest,
|
|
12
|
+
TerminalExecResponse,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
#[derive(Clone)]
|
|
16
|
+
pub(crate) struct TerminalService {
|
|
17
|
+
root: PathBuf,
|
|
18
|
+
allowed_commands: HashSet<String>,
|
|
19
|
+
disabled: bool,
|
|
20
|
+
allow_outside_root: bool,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
impl TerminalService {
|
|
24
|
+
pub(crate) fn new(
|
|
25
|
+
root: PathBuf,
|
|
26
|
+
allowed_commands: HashSet<String>,
|
|
27
|
+
disabled: bool,
|
|
28
|
+
allow_outside_root: bool,
|
|
29
|
+
) -> Self {
|
|
30
|
+
Self {
|
|
31
|
+
root,
|
|
32
|
+
allowed_commands,
|
|
33
|
+
disabled,
|
|
34
|
+
allow_outside_root,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
pub(crate) async fn execute_shell(
|
|
39
|
+
&self,
|
|
40
|
+
request: TerminalExecRequest,
|
|
41
|
+
) -> Result<TerminalExecResponse, BridgeError> {
|
|
42
|
+
if self.disabled {
|
|
43
|
+
return Err(BridgeError::forbidden(
|
|
44
|
+
"terminal_exec_disabled",
|
|
45
|
+
"Terminal execution is disabled on this bridge.",
|
|
46
|
+
));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let command = request.command.trim();
|
|
50
|
+
if command.is_empty() {
|
|
51
|
+
return Err(BridgeError::invalid_params("command must not be empty"));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if contains_disallowed_control_chars(command) {
|
|
55
|
+
return Err(BridgeError::invalid_params(
|
|
56
|
+
"command contains disallowed control characters",
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let tokens = shlex::split(command)
|
|
61
|
+
.ok_or_else(|| BridgeError::invalid_params("invalid command quoting"))?;
|
|
62
|
+
if tokens.is_empty() {
|
|
63
|
+
return Err(BridgeError::invalid_params("command must not be empty"));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let binary = tokens[0].clone();
|
|
67
|
+
if !self.allowed_commands.is_empty() && !self.allowed_commands.contains(&binary) {
|
|
68
|
+
let mut allowed = self.allowed_commands.iter().cloned().collect::<Vec<_>>();
|
|
69
|
+
allowed.sort();
|
|
70
|
+
return Err(BridgeError::invalid_params(&format!(
|
|
71
|
+
"Command \"{binary}\" is not allowed. Allowed commands: {}",
|
|
72
|
+
allowed.join(", ")
|
|
73
|
+
)));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let args = tokens[1..].to_vec();
|
|
77
|
+
let cwd = resolve_exec_cwd(request.cwd.as_deref(), &self.root, self.allow_outside_root)?;
|
|
78
|
+
|
|
79
|
+
self.execute_binary_internal(
|
|
80
|
+
binary.as_str(),
|
|
81
|
+
&args,
|
|
82
|
+
command.to_string(),
|
|
83
|
+
cwd,
|
|
84
|
+
request.timeout_ms,
|
|
85
|
+
)
|
|
86
|
+
.await
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
pub(crate) async fn execute_binary(
|
|
90
|
+
&self,
|
|
91
|
+
binary: &str,
|
|
92
|
+
args: &[String],
|
|
93
|
+
cwd: PathBuf,
|
|
94
|
+
timeout_ms: Option<u64>,
|
|
95
|
+
) -> Result<TerminalExecResponse, BridgeError> {
|
|
96
|
+
let cwd = normalize_path(&cwd);
|
|
97
|
+
if !self.allow_outside_root {
|
|
98
|
+
let normalized_root = normalize_path(&self.root);
|
|
99
|
+
if !cwd.starts_with(&normalized_root) {
|
|
100
|
+
return Err(BridgeError::invalid_params(
|
|
101
|
+
"cwd must stay within BRIDGE_WORKDIR",
|
|
102
|
+
));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let display = std::iter::once(binary.to_string())
|
|
107
|
+
.chain(args.iter().cloned())
|
|
108
|
+
.collect::<Vec<_>>()
|
|
109
|
+
.join(" ");
|
|
110
|
+
|
|
111
|
+
self.execute_binary_internal(binary, args, display, cwd, timeout_ms)
|
|
112
|
+
.await
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async fn execute_binary_internal(
|
|
116
|
+
&self,
|
|
117
|
+
binary: &str,
|
|
118
|
+
args: &[String],
|
|
119
|
+
display_command: String,
|
|
120
|
+
cwd: PathBuf,
|
|
121
|
+
timeout_ms: Option<u64>,
|
|
122
|
+
) -> Result<TerminalExecResponse, BridgeError> {
|
|
123
|
+
let timeout_ms = timeout_ms.unwrap_or(30_000).clamp(100, 120_000);
|
|
124
|
+
let started_at = Instant::now();
|
|
125
|
+
|
|
126
|
+
let mut child = Command::new(binary)
|
|
127
|
+
.args(args)
|
|
128
|
+
.current_dir(&cwd)
|
|
129
|
+
.stdin(Stdio::null())
|
|
130
|
+
.stdout(Stdio::piped())
|
|
131
|
+
.stderr(Stdio::piped())
|
|
132
|
+
.spawn()
|
|
133
|
+
.map_err(|error| BridgeError::server(&format!("failed to spawn command: {error}")))?;
|
|
134
|
+
|
|
135
|
+
let mut stdout = child
|
|
136
|
+
.stdout
|
|
137
|
+
.take()
|
|
138
|
+
.ok_or_else(|| BridgeError::server("failed to capture stdout"))?;
|
|
139
|
+
let mut stderr = child
|
|
140
|
+
.stderr
|
|
141
|
+
.take()
|
|
142
|
+
.ok_or_else(|| BridgeError::server("failed to capture stderr"))?;
|
|
143
|
+
|
|
144
|
+
let stdout_task = tokio::spawn(async move {
|
|
145
|
+
let mut bytes = Vec::new();
|
|
146
|
+
let _ = stdout.read_to_end(&mut bytes).await;
|
|
147
|
+
bytes
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
let stderr_task = tokio::spawn(async move {
|
|
151
|
+
let mut bytes = Vec::new();
|
|
152
|
+
let _ = stderr.read_to_end(&mut bytes).await;
|
|
153
|
+
bytes
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
let mut timed_out = false;
|
|
157
|
+
let mut exit_code = None;
|
|
158
|
+
let mut wait_error: Option<String> = None;
|
|
159
|
+
|
|
160
|
+
match timeout(Duration::from_millis(timeout_ms), child.wait()).await {
|
|
161
|
+
Ok(Ok(status)) => {
|
|
162
|
+
exit_code = status.code();
|
|
163
|
+
}
|
|
164
|
+
Ok(Err(error)) => {
|
|
165
|
+
wait_error = Some(error.to_string());
|
|
166
|
+
exit_code = Some(-1);
|
|
167
|
+
}
|
|
168
|
+
Err(_) => {
|
|
169
|
+
timed_out = true;
|
|
170
|
+
let _ = child.kill().await;
|
|
171
|
+
let _ = child.wait().await;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let stdout_bytes = stdout_task.await.unwrap_or_default();
|
|
176
|
+
let stderr_bytes = stderr_task.await.unwrap_or_default();
|
|
177
|
+
|
|
178
|
+
let stdout_text = String::from_utf8_lossy(&stdout_bytes)
|
|
179
|
+
.trim_end()
|
|
180
|
+
.to_string();
|
|
181
|
+
let mut stderr_text = String::from_utf8_lossy(&stderr_bytes)
|
|
182
|
+
.trim_end()
|
|
183
|
+
.to_string();
|
|
184
|
+
if let Some(wait_error) = wait_error {
|
|
185
|
+
if !stderr_text.is_empty() {
|
|
186
|
+
stderr_text.push('\n');
|
|
187
|
+
}
|
|
188
|
+
stderr_text.push_str(&wait_error);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
Ok(TerminalExecResponse {
|
|
192
|
+
command: display_command,
|
|
193
|
+
cwd: cwd.to_string_lossy().to_string(),
|
|
194
|
+
code: exit_code,
|
|
195
|
+
stdout: stdout_text,
|
|
196
|
+
stderr: stderr_text,
|
|
197
|
+
timed_out,
|
|
198
|
+
duration_ms: started_at.elapsed().as_millis() as u64,
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
fn resolve_exec_cwd(
|
|
204
|
+
raw_cwd: Option<&str>,
|
|
205
|
+
root: &PathBuf,
|
|
206
|
+
allow_outside_root: bool,
|
|
207
|
+
) -> Result<PathBuf, BridgeError> {
|
|
208
|
+
let normalized_root = normalize_path(root);
|
|
209
|
+
let requested = match raw_cwd {
|
|
210
|
+
Some(raw) if !raw.trim().is_empty() => {
|
|
211
|
+
let path = PathBuf::from(raw);
|
|
212
|
+
if path.is_absolute() {
|
|
213
|
+
path
|
|
214
|
+
} else {
|
|
215
|
+
root.join(path)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
_ => root.to_path_buf(),
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
let normalized = normalize_path(&requested);
|
|
222
|
+
if !allow_outside_root && !normalized.starts_with(&normalized_root) {
|
|
223
|
+
return Err(BridgeError::invalid_params(
|
|
224
|
+
"cwd must stay within BRIDGE_WORKDIR",
|
|
225
|
+
));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
Ok(normalized)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
#[cfg(test)]
|
|
232
|
+
mod tests {
|
|
233
|
+
use super::resolve_exec_cwd;
|
|
234
|
+
use std::path::PathBuf;
|
|
235
|
+
|
|
236
|
+
#[test]
|
|
237
|
+
fn resolves_relative_exec_cwd_against_root() {
|
|
238
|
+
let root = PathBuf::from("/bridge/root");
|
|
239
|
+
let resolved =
|
|
240
|
+
resolve_exec_cwd(Some("workspace/repo"), &root, false).expect("resolve relative cwd");
|
|
241
|
+
assert_eq!(resolved, PathBuf::from("/bridge/root/workspace/repo"));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
#[test]
|
|
245
|
+
fn rejects_absolute_exec_cwd_outside_root_by_default() {
|
|
246
|
+
let root = PathBuf::from("/bridge/root");
|
|
247
|
+
let error = resolve_exec_cwd(Some("/external/repo"), &root, false)
|
|
248
|
+
.expect_err("reject outside-root cwd");
|
|
249
|
+
assert_eq!(error.code, -32602);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
#[test]
|
|
253
|
+
fn rejects_relative_exec_cwd_that_escapes_root() {
|
|
254
|
+
let root = PathBuf::from("/bridge/root");
|
|
255
|
+
let error =
|
|
256
|
+
resolve_exec_cwd(Some("../outside"), &root, false).expect_err("reject escape path");
|
|
257
|
+
assert_eq!(error.code, -32602);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
#[test]
|
|
261
|
+
fn allows_absolute_exec_cwd_outside_root_when_enabled() {
|
|
262
|
+
let root = PathBuf::from("/bridge/root");
|
|
263
|
+
let resolved =
|
|
264
|
+
resolve_exec_cwd(Some("/external/repo"), &root, true).expect("allow outside root");
|
|
265
|
+
assert_eq!(resolved, PathBuf::from("/external/repo"));
|
|
266
|
+
}
|
|
267
|
+
}
|
package/tsconfig.json
ADDED