clawdex-mobile 5.0.1 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/docs/setup-and-operations.md +3 -1
- package/docs/troubleshooting.md +1 -0
- package/package.json +18 -8
- package/scripts/setup-secure-dev.sh +26 -17
- package/services/rust-bridge/Cargo.lock +1 -1
- package/services/rust-bridge/Cargo.toml +1 -1
- package/vendor/bridge-binaries/darwin-arm64/codex-rust-bridge +0 -0
- package/vendor/bridge-binaries/darwin-x64/codex-rust-bridge +0 -0
- package/vendor/bridge-binaries/linux-x64/codex-rust-bridge +0 -0
- package/vendor/bridge-binaries/win32-x64/codex-rust-bridge.exe +0 -0
- package/.artifacts/bridge-binaries/bridge-binaries-darwin-arm64/codex-rust-bridge +0 -0
- package/.artifacts/bridge-binaries/bridge-binaries-darwin-x64/codex-rust-bridge +0 -0
- package/.artifacts/bridge-binaries/bridge-binaries-linux-x64/codex-rust-bridge +0 -0
- package/.artifacts/bridge-binaries/bridge-binaries-win32-x64/codex-rust-bridge.exe +0 -0
- package/.github/workflows/ci.yml +0 -80
- package/.github/workflows/npm-release.yml +0 -208
- package/.github/workflows/pages.yml +0 -41
- package/AGENTS.md +0 -273
- package/STATUS.md +0 -115
- package/apps/mobile/.env.example +0 -6
- package/apps/mobile/App.tsx +0 -943
- package/apps/mobile/app.json +0 -77
- 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-white.png +0 -0
- package/apps/mobile/assets/brand/splash-icon.png +0 -0
- package/apps/mobile/babel.config.js +0 -7
- package/apps/mobile/eas.json +0 -40
- package/apps/mobile/eslint.config.cjs +0 -28
- package/apps/mobile/index.js +0 -5
- package/apps/mobile/package.json +0 -57
- package/apps/mobile/plugins/withAndroidCleartextTraffic.js +0 -14
- package/apps/mobile/src/api/__tests__/chatMapping.test.ts +0 -351
- package/apps/mobile/src/api/__tests__/client.test.ts +0 -1494
- package/apps/mobile/src/api/__tests__/ws.test.ts +0 -640
- package/apps/mobile/src/api/account.ts +0 -47
- package/apps/mobile/src/api/chatMapping.ts +0 -1048
- package/apps/mobile/src/api/client.ts +0 -1430
- package/apps/mobile/src/api/rateLimits.ts +0 -143
- package/apps/mobile/src/api/types.ts +0 -435
- package/apps/mobile/src/api/ws.ts +0 -852
- package/apps/mobile/src/bridgeUrl.ts +0 -105
- package/apps/mobile/src/components/ActivityBar.tsx +0 -95
- package/apps/mobile/src/components/ApprovalBanner.tsx +0 -207
- package/apps/mobile/src/components/BrandMark.tsx +0 -43
- package/apps/mobile/src/components/ChatHeader.tsx +0 -107
- package/apps/mobile/src/components/ChatInput.tsx +0 -457
- package/apps/mobile/src/components/ChatMessage.tsx +0 -959
- package/apps/mobile/src/components/ComposerUsageLimits.tsx +0 -167
- package/apps/mobile/src/components/SelectionSheet.tsx +0 -466
- package/apps/mobile/src/components/StatusLine.tsx +0 -52
- package/apps/mobile/src/components/ToolBlock.tsx +0 -67
- package/apps/mobile/src/components/TypingIndicator.tsx +0 -64
- package/apps/mobile/src/components/VoiceRecordingWaveform.tsx +0 -181
- package/apps/mobile/src/components/WorkspacePickerModal.tsx +0 -812
- package/apps/mobile/src/components/__tests__/chat-input-layout.test.ts +0 -35
- package/apps/mobile/src/components/__tests__/chatImageSource.test.ts +0 -44
- package/apps/mobile/src/components/__tests__/composerUsageLimits.test.ts +0 -138
- package/apps/mobile/src/components/__tests__/voiceWaveform.test.ts +0 -31
- package/apps/mobile/src/components/chat-input-layout.ts +0 -59
- package/apps/mobile/src/components/chatImageSource.ts +0 -86
- package/apps/mobile/src/components/usageLimitBadges.ts +0 -109
- package/apps/mobile/src/components/voiceWaveform.ts +0 -46
- package/apps/mobile/src/config.ts +0 -64
- package/apps/mobile/src/hooks/useVoiceRecorder.ts +0 -271
- package/apps/mobile/src/navigation/DrawerContent.tsx +0 -1129
- package/apps/mobile/src/navigation/__tests__/chatThreadTree.test.ts +0 -89
- package/apps/mobile/src/navigation/__tests__/drawerChats.test.ts +0 -65
- package/apps/mobile/src/navigation/chatThreadTree.ts +0 -191
- package/apps/mobile/src/navigation/drawerChats.ts +0 -9
- package/apps/mobile/src/screens/GitScreen.tsx +0 -1489
- package/apps/mobile/src/screens/MainScreen.tsx +0 -10511
- package/apps/mobile/src/screens/OnboardingScreen.tsx +0 -1746
- package/apps/mobile/src/screens/PrivacyScreen.tsx +0 -196
- package/apps/mobile/src/screens/SettingsScreen.tsx +0 -870
- package/apps/mobile/src/screens/TerminalScreen.tsx +0 -248
- package/apps/mobile/src/screens/TermsScreen.tsx +0 -192
- package/apps/mobile/src/screens/__tests__/agentThreadDisplay.test.ts +0 -80
- package/apps/mobile/src/screens/__tests__/agentThreads.test.ts +0 -170
- package/apps/mobile/src/screens/__tests__/gitDiff.test.ts +0 -131
- package/apps/mobile/src/screens/__tests__/planCardState.test.ts +0 -88
- package/apps/mobile/src/screens/__tests__/subAgentTranscript.test.ts +0 -102
- package/apps/mobile/src/screens/__tests__/transcriptMessages.test.ts +0 -97
- package/apps/mobile/src/screens/agentThreadDisplay.ts +0 -261
- package/apps/mobile/src/screens/agentThreads.ts +0 -167
- package/apps/mobile/src/screens/gitDiff.ts +0 -380
- package/apps/mobile/src/screens/planCardState.ts +0 -40
- package/apps/mobile/src/screens/subAgentTranscript.ts +0 -149
- package/apps/mobile/src/screens/transcriptMessages.ts +0 -102
- package/apps/mobile/src/theme.ts +0 -106
- package/apps/mobile/src/types/assets.d.ts +0 -4
- package/apps/mobile/tsconfig.json +0 -33
- package/docs/app-review-notes.md +0 -116
- package/docs/codex-app-server-cli-gap-tracker.md +0 -90
- package/docs/eas-builds.md +0 -91
- package/docs/open-source-license-requirements.md +0 -32
- package/docs/plans/2026-02-20-codex-desktop-style-redesign.md +0 -190
- package/docs/plans/2026-02-20-codex-mobile-implementation.md +0 -1630
- package/docs/plans/2026-02-21-codex-ui-redesign-design.md +0 -101
- package/docs/plans/2026-02-21-codex-ui-redesign.md +0 -1229
- package/docs/privacy-policy.md +0 -54
- package/docs/realtime-streaming-limitations.md +0 -161
- package/docs/terms-of-service.md +0 -33
- package/docs/voice-transcription.md +0 -87
- package/scripts/codex-live-demo.sh +0 -69
- package/scripts/start-bridge-secure.sh +0 -5
- package/scripts/start-expo.sh +0 -176
- package/scripts/sync-versions.js +0 -63
- package/scripts/teardown.sh +0 -136
- package/services/mac-bridge/.env.example +0 -10
- package/services/mac-bridge/codex-types/AbsolutePathBuf.ts +0 -14
- package/services/mac-bridge/codex-types/AddConversationListenerParams.ts +0 -6
- package/services/mac-bridge/codex-types/AddConversationSubscriptionResponse.ts +0 -5
- package/services/mac-bridge/codex-types/AgentMessageContent.ts +0 -5
- package/services/mac-bridge/codex-types/AgentMessageContentDeltaEvent.ts +0 -5
- package/services/mac-bridge/codex-types/AgentMessageDeltaEvent.ts +0 -5
- package/services/mac-bridge/codex-types/AgentMessageEvent.ts +0 -5
- package/services/mac-bridge/codex-types/AgentMessageItem.ts +0 -21
- package/services/mac-bridge/codex-types/AgentReasoningDeltaEvent.ts +0 -5
- package/services/mac-bridge/codex-types/AgentReasoningEvent.ts +0 -5
- package/services/mac-bridge/codex-types/AgentReasoningRawContentDeltaEvent.ts +0 -5
- package/services/mac-bridge/codex-types/AgentReasoningRawContentEvent.ts +0 -5
- package/services/mac-bridge/codex-types/AgentReasoningSectionBreakEvent.ts +0 -5
- package/services/mac-bridge/codex-types/AgentStatus.ts +0 -8
- package/services/mac-bridge/codex-types/ApplyPatchApprovalParams.ts +0 -21
- package/services/mac-bridge/codex-types/ApplyPatchApprovalRequestEvent.ts +0 -23
- package/services/mac-bridge/codex-types/ApplyPatchApprovalResponse.ts +0 -6
- package/services/mac-bridge/codex-types/ArchiveConversationParams.ts +0 -6
- package/services/mac-bridge/codex-types/ArchiveConversationResponse.ts +0 -5
- package/services/mac-bridge/codex-types/AskForApproval.ts +0 -9
- package/services/mac-bridge/codex-types/AuthMode.ts +0 -8
- package/services/mac-bridge/codex-types/AuthStatusChangeNotification.ts +0 -9
- package/services/mac-bridge/codex-types/BackgroundEventEvent.ts +0 -5
- package/services/mac-bridge/codex-types/ByteRange.ts +0 -13
- package/services/mac-bridge/codex-types/CallToolResult.ts +0 -9
- package/services/mac-bridge/codex-types/CancelLoginChatGptParams.ts +0 -5
- package/services/mac-bridge/codex-types/CancelLoginChatGptResponse.ts +0 -5
- package/services/mac-bridge/codex-types/ClientInfo.ts +0 -5
- package/services/mac-bridge/codex-types/ClientNotification.ts +0 -5
- package/services/mac-bridge/codex-types/ClientRequest.ts +0 -60
- package/services/mac-bridge/codex-types/CodexErrorInfo.ts +0 -8
- package/services/mac-bridge/codex-types/CollabAgentInteractionBeginEvent.ts +0 -23
- package/services/mac-bridge/codex-types/CollabAgentInteractionEndEvent.ts +0 -28
- package/services/mac-bridge/codex-types/CollabAgentSpawnBeginEvent.ts +0 -19
- package/services/mac-bridge/codex-types/CollabAgentSpawnEndEvent.ts +0 -28
- package/services/mac-bridge/codex-types/CollabCloseBeginEvent.ts +0 -18
- package/services/mac-bridge/codex-types/CollabCloseEndEvent.ts +0 -24
- package/services/mac-bridge/codex-types/CollabResumeBeginEvent.ts +0 -18
- package/services/mac-bridge/codex-types/CollabResumeEndEvent.ts +0 -24
- package/services/mac-bridge/codex-types/CollabWaitingBeginEvent.ts +0 -18
- package/services/mac-bridge/codex-types/CollabWaitingEndEvent.ts +0 -19
- package/services/mac-bridge/codex-types/CollaborationMode.ts +0 -10
- package/services/mac-bridge/codex-types/CollaborationModeMask.ts +0 -11
- package/services/mac-bridge/codex-types/ContentItem.ts +0 -5
- package/services/mac-bridge/codex-types/ContextCompactedEvent.ts +0 -5
- package/services/mac-bridge/codex-types/ContextCompactionItem.ts +0 -5
- package/services/mac-bridge/codex-types/ConversationGitInfo.ts +0 -5
- package/services/mac-bridge/codex-types/ConversationSummary.ts +0 -8
- package/services/mac-bridge/codex-types/CreditsSnapshot.ts +0 -5
- package/services/mac-bridge/codex-types/CustomPrompt.ts +0 -5
- package/services/mac-bridge/codex-types/DeprecationNoticeEvent.ts +0 -13
- package/services/mac-bridge/codex-types/DynamicToolCallRequest.ts +0 -6
- package/services/mac-bridge/codex-types/ElicitationRequestEvent.ts +0 -5
- package/services/mac-bridge/codex-types/ErrorEvent.ts +0 -6
- package/services/mac-bridge/codex-types/EventMsg.ts +0 -78
- package/services/mac-bridge/codex-types/ExecApprovalRequestEvent.ts +0 -44
- package/services/mac-bridge/codex-types/ExecCommandApprovalParams.ts +0 -16
- package/services/mac-bridge/codex-types/ExecCommandApprovalResponse.ts +0 -6
- package/services/mac-bridge/codex-types/ExecCommandBeginEvent.ts +0 -35
- package/services/mac-bridge/codex-types/ExecCommandEndEvent.ts +0 -64
- package/services/mac-bridge/codex-types/ExecCommandOutputDeltaEvent.ts +0 -18
- package/services/mac-bridge/codex-types/ExecCommandSource.ts +0 -5
- package/services/mac-bridge/codex-types/ExecCommandStatus.ts +0 -5
- package/services/mac-bridge/codex-types/ExecOneOffCommandParams.ts +0 -6
- package/services/mac-bridge/codex-types/ExecOneOffCommandResponse.ts +0 -5
- package/services/mac-bridge/codex-types/ExecOutputStream.ts +0 -5
- package/services/mac-bridge/codex-types/ExecPolicyAmendment.ts +0 -12
- package/services/mac-bridge/codex-types/ExitedReviewModeEvent.ts +0 -6
- package/services/mac-bridge/codex-types/FileChange.ts +0 -5
- package/services/mac-bridge/codex-types/ForcedLoginMethod.ts +0 -5
- package/services/mac-bridge/codex-types/ForkConversationParams.ts +0 -7
- package/services/mac-bridge/codex-types/ForkConversationResponse.ts +0 -7
- package/services/mac-bridge/codex-types/FunctionCallOutputBody.ts +0 -6
- package/services/mac-bridge/codex-types/FunctionCallOutputContentItem.ts +0 -9
- package/services/mac-bridge/codex-types/FunctionCallOutputPayload.ts +0 -12
- package/services/mac-bridge/codex-types/FuzzyFileSearchParams.ts +0 -5
- package/services/mac-bridge/codex-types/FuzzyFileSearchResponse.ts +0 -6
- package/services/mac-bridge/codex-types/FuzzyFileSearchResult.ts +0 -8
- package/services/mac-bridge/codex-types/FuzzyFileSearchSessionCompletedNotification.ts +0 -5
- package/services/mac-bridge/codex-types/FuzzyFileSearchSessionUpdatedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/GetAuthStatusParams.ts +0 -5
- package/services/mac-bridge/codex-types/GetAuthStatusResponse.ts +0 -6
- package/services/mac-bridge/codex-types/GetConversationSummaryParams.ts +0 -6
- package/services/mac-bridge/codex-types/GetConversationSummaryResponse.ts +0 -6
- package/services/mac-bridge/codex-types/GetHistoryEntryResponseEvent.ts +0 -10
- package/services/mac-bridge/codex-types/GetUserAgentResponse.ts +0 -5
- package/services/mac-bridge/codex-types/GetUserSavedConfigResponse.ts +0 -6
- package/services/mac-bridge/codex-types/GhostCommit.ts +0 -8
- package/services/mac-bridge/codex-types/GitDiffToRemoteParams.ts +0 -5
- package/services/mac-bridge/codex-types/GitDiffToRemoteResponse.ts +0 -6
- package/services/mac-bridge/codex-types/GitSha.ts +0 -5
- package/services/mac-bridge/codex-types/HistoryEntry.ts +0 -5
- package/services/mac-bridge/codex-types/InitializeCapabilities.ts +0 -17
- package/services/mac-bridge/codex-types/InitializeParams.ts +0 -7
- package/services/mac-bridge/codex-types/InitializeResponse.ts +0 -5
- package/services/mac-bridge/codex-types/InputItem.ts +0 -10
- package/services/mac-bridge/codex-types/InputModality.ts +0 -8
- package/services/mac-bridge/codex-types/InterruptConversationParams.ts +0 -6
- package/services/mac-bridge/codex-types/InterruptConversationResponse.ts +0 -6
- package/services/mac-bridge/codex-types/ItemCompletedEvent.ts +0 -7
- package/services/mac-bridge/codex-types/ItemStartedEvent.ts +0 -7
- package/services/mac-bridge/codex-types/ListConversationsParams.ts +0 -5
- package/services/mac-bridge/codex-types/ListConversationsResponse.ts +0 -6
- package/services/mac-bridge/codex-types/ListCustomPromptsResponseEvent.ts +0 -9
- package/services/mac-bridge/codex-types/ListRemoteSkillsResponseEvent.ts +0 -9
- package/services/mac-bridge/codex-types/ListSkillsResponseEvent.ts +0 -9
- package/services/mac-bridge/codex-types/LocalShellAction.ts +0 -6
- package/services/mac-bridge/codex-types/LocalShellExecAction.ts +0 -5
- package/services/mac-bridge/codex-types/LocalShellStatus.ts +0 -5
- package/services/mac-bridge/codex-types/LoginApiKeyParams.ts +0 -5
- package/services/mac-bridge/codex-types/LoginApiKeyResponse.ts +0 -5
- package/services/mac-bridge/codex-types/LoginChatGptCompleteNotification.ts +0 -8
- package/services/mac-bridge/codex-types/LoginChatGptResponse.ts +0 -5
- package/services/mac-bridge/codex-types/LogoutChatGptResponse.ts +0 -5
- package/services/mac-bridge/codex-types/McpAuthStatus.ts +0 -5
- package/services/mac-bridge/codex-types/McpInvocation.ts +0 -18
- package/services/mac-bridge/codex-types/McpListToolsResponseEvent.ts +0 -25
- package/services/mac-bridge/codex-types/McpStartupCompleteEvent.ts +0 -6
- package/services/mac-bridge/codex-types/McpStartupFailure.ts +0 -5
- package/services/mac-bridge/codex-types/McpStartupStatus.ts +0 -5
- package/services/mac-bridge/codex-types/McpStartupUpdateEvent.ts +0 -14
- package/services/mac-bridge/codex-types/McpToolCallBeginEvent.ts +0 -10
- package/services/mac-bridge/codex-types/McpToolCallEndEvent.ts +0 -15
- package/services/mac-bridge/codex-types/MessagePhase.ts +0 -11
- package/services/mac-bridge/codex-types/ModeKind.ts +0 -8
- package/services/mac-bridge/codex-types/ModelRerouteEvent.ts +0 -6
- package/services/mac-bridge/codex-types/ModelRerouteReason.ts +0 -5
- package/services/mac-bridge/codex-types/NetworkAccess.ts +0 -8
- package/services/mac-bridge/codex-types/NetworkApprovalContext.ts +0 -6
- package/services/mac-bridge/codex-types/NetworkApprovalProtocol.ts +0 -5
- package/services/mac-bridge/codex-types/NewConversationParams.ts +0 -8
- package/services/mac-bridge/codex-types/NewConversationResponse.ts +0 -7
- package/services/mac-bridge/codex-types/ParsedCommand.ts +0 -12
- package/services/mac-bridge/codex-types/PatchApplyBeginEvent.ts +0 -23
- package/services/mac-bridge/codex-types/PatchApplyEndEvent.ts +0 -36
- package/services/mac-bridge/codex-types/PatchApplyStatus.ts +0 -5
- package/services/mac-bridge/codex-types/Personality.ts +0 -5
- package/services/mac-bridge/codex-types/PlanDeltaEvent.ts +0 -5
- package/services/mac-bridge/codex-types/PlanItem.ts +0 -5
- package/services/mac-bridge/codex-types/PlanItemArg.ts +0 -6
- package/services/mac-bridge/codex-types/PlanType.ts +0 -5
- package/services/mac-bridge/codex-types/Profile.ts +0 -9
- package/services/mac-bridge/codex-types/RateLimitSnapshot.ts +0 -8
- package/services/mac-bridge/codex-types/RateLimitWindow.ts +0 -17
- package/services/mac-bridge/codex-types/RawResponseItemEvent.ts +0 -6
- package/services/mac-bridge/codex-types/ReadOnlyAccess.ts +0 -19
- package/services/mac-bridge/codex-types/ReasoningContentDeltaEvent.ts +0 -5
- package/services/mac-bridge/codex-types/ReasoningEffort.ts +0 -8
- package/services/mac-bridge/codex-types/ReasoningItem.ts +0 -5
- package/services/mac-bridge/codex-types/ReasoningItemContent.ts +0 -5
- package/services/mac-bridge/codex-types/ReasoningItemReasoningSummary.ts +0 -5
- package/services/mac-bridge/codex-types/ReasoningRawContentDeltaEvent.ts +0 -5
- package/services/mac-bridge/codex-types/ReasoningSummary.ts +0 -10
- package/services/mac-bridge/codex-types/RemoteSkillDownloadedEvent.ts +0 -8
- package/services/mac-bridge/codex-types/RemoteSkillSummary.ts +0 -5
- package/services/mac-bridge/codex-types/RemoveConversationListenerParams.ts +0 -5
- package/services/mac-bridge/codex-types/RemoveConversationSubscriptionResponse.ts +0 -5
- package/services/mac-bridge/codex-types/RequestId.ts +0 -5
- package/services/mac-bridge/codex-types/RequestUserInputEvent.ts +0 -15
- package/services/mac-bridge/codex-types/RequestUserInputQuestion.ts +0 -6
- package/services/mac-bridge/codex-types/RequestUserInputQuestionOption.ts +0 -5
- package/services/mac-bridge/codex-types/Resource.ts +0 -9
- package/services/mac-bridge/codex-types/ResourceTemplate.ts +0 -9
- package/services/mac-bridge/codex-types/ResponseItem.ts +0 -18
- package/services/mac-bridge/codex-types/ResumeConversationParams.ts +0 -8
- package/services/mac-bridge/codex-types/ResumeConversationResponse.ts +0 -7
- package/services/mac-bridge/codex-types/ReviewCodeLocation.ts +0 -9
- package/services/mac-bridge/codex-types/ReviewDecision.ts +0 -9
- package/services/mac-bridge/codex-types/ReviewFinding.ts +0 -9
- package/services/mac-bridge/codex-types/ReviewLineRange.ts +0 -8
- package/services/mac-bridge/codex-types/ReviewOutputEvent.ts +0 -9
- package/services/mac-bridge/codex-types/ReviewRequest.ts +0 -9
- package/services/mac-bridge/codex-types/ReviewTarget.ts +0 -9
- package/services/mac-bridge/codex-types/SandboxMode.ts +0 -5
- package/services/mac-bridge/codex-types/SandboxPolicy.ts +0 -44
- package/services/mac-bridge/codex-types/SandboxSettings.ts +0 -6
- package/services/mac-bridge/codex-types/SendUserMessageParams.ts +0 -7
- package/services/mac-bridge/codex-types/SendUserMessageResponse.ts +0 -5
- package/services/mac-bridge/codex-types/SendUserTurnParams.ts +0 -16
- package/services/mac-bridge/codex-types/SendUserTurnResponse.ts +0 -5
- package/services/mac-bridge/codex-types/ServerNotification.ts +0 -45
- package/services/mac-bridge/codex-types/ServerRequest.ts +0 -16
- package/services/mac-bridge/codex-types/SessionConfiguredEvent.ts +0 -57
- package/services/mac-bridge/codex-types/SessionConfiguredNotification.ts +0 -8
- package/services/mac-bridge/codex-types/SessionNetworkProxyRuntime.ts +0 -5
- package/services/mac-bridge/codex-types/SessionSource.ts +0 -6
- package/services/mac-bridge/codex-types/SetDefaultModelParams.ts +0 -6
- package/services/mac-bridge/codex-types/SetDefaultModelResponse.ts +0 -5
- package/services/mac-bridge/codex-types/Settings.ts +0 -9
- package/services/mac-bridge/codex-types/SkillDependencies.ts +0 -6
- package/services/mac-bridge/codex-types/SkillErrorInfo.ts +0 -5
- package/services/mac-bridge/codex-types/SkillInterface.ts +0 -5
- package/services/mac-bridge/codex-types/SkillMetadata.ts +0 -12
- package/services/mac-bridge/codex-types/SkillScope.ts +0 -5
- package/services/mac-bridge/codex-types/SkillToolDependency.ts +0 -5
- package/services/mac-bridge/codex-types/SkillsListEntry.ts +0 -7
- package/services/mac-bridge/codex-types/StepStatus.ts +0 -5
- package/services/mac-bridge/codex-types/StreamErrorEvent.ts +0 -12
- package/services/mac-bridge/codex-types/SubAgentSource.ts +0 -6
- package/services/mac-bridge/codex-types/TerminalInteractionEvent.ts +0 -17
- package/services/mac-bridge/codex-types/TextElement.ts +0 -14
- package/services/mac-bridge/codex-types/ThreadId.ts +0 -5
- package/services/mac-bridge/codex-types/ThreadNameUpdatedEvent.ts +0 -6
- package/services/mac-bridge/codex-types/ThreadRolledBackEvent.ts +0 -9
- package/services/mac-bridge/codex-types/TokenCountEvent.ts +0 -7
- package/services/mac-bridge/codex-types/TokenUsage.ts +0 -5
- package/services/mac-bridge/codex-types/TokenUsageInfo.ts +0 -6
- package/services/mac-bridge/codex-types/Tool.ts +0 -9
- package/services/mac-bridge/codex-types/Tools.ts +0 -5
- package/services/mac-bridge/codex-types/TurnAbortReason.ts +0 -5
- package/services/mac-bridge/codex-types/TurnAbortedEvent.ts +0 -6
- package/services/mac-bridge/codex-types/TurnCompleteEvent.ts +0 -5
- package/services/mac-bridge/codex-types/TurnDiffEvent.ts +0 -5
- package/services/mac-bridge/codex-types/TurnItem.ts +0 -11
- package/services/mac-bridge/codex-types/TurnStartedEvent.ts +0 -6
- package/services/mac-bridge/codex-types/UndoCompletedEvent.ts +0 -5
- package/services/mac-bridge/codex-types/UndoStartedEvent.ts +0 -5
- package/services/mac-bridge/codex-types/UpdatePlanArgs.ts +0 -10
- package/services/mac-bridge/codex-types/UserInfoResponse.ts +0 -5
- package/services/mac-bridge/codex-types/UserInput.ts +0 -16
- package/services/mac-bridge/codex-types/UserMessageEvent.ts +0 -22
- package/services/mac-bridge/codex-types/UserMessageItem.ts +0 -6
- package/services/mac-bridge/codex-types/UserSavedConfig.ts +0 -14
- package/services/mac-bridge/codex-types/Verbosity.ts +0 -9
- package/services/mac-bridge/codex-types/ViewImageToolCallEvent.ts +0 -13
- package/services/mac-bridge/codex-types/WarningEvent.ts +0 -5
- package/services/mac-bridge/codex-types/WebSearchAction.ts +0 -5
- package/services/mac-bridge/codex-types/WebSearchBeginEvent.ts +0 -5
- package/services/mac-bridge/codex-types/WebSearchEndEvent.ts +0 -6
- package/services/mac-bridge/codex-types/WebSearchItem.ts +0 -6
- package/services/mac-bridge/codex-types/WebSearchMode.ts +0 -5
- package/services/mac-bridge/codex-types/index.ts +0 -234
- package/services/mac-bridge/codex-types/serde_json/JsonValue.ts +0 -5
- package/services/mac-bridge/codex-types/v2/Account.ts +0 -6
- package/services/mac-bridge/codex-types/v2/AccountLoginCompletedNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/AccountRateLimitsUpdatedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/AccountUpdatedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/AgentMessageDeltaNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/AnalyticsConfig.ts +0 -6
- package/services/mac-bridge/codex-types/v2/AppBranding.ts +0 -8
- package/services/mac-bridge/codex-types/v2/AppDisabledReason.ts +0 -5
- package/services/mac-bridge/codex-types/v2/AppInfo.ts +0 -19
- package/services/mac-bridge/codex-types/v2/AppListUpdatedNotification.ts +0 -9
- package/services/mac-bridge/codex-types/v2/AppMetadata.ts +0 -7
- package/services/mac-bridge/codex-types/v2/AppReview.ts +0 -5
- package/services/mac-bridge/codex-types/v2/AppScreenshot.ts +0 -5
- package/services/mac-bridge/codex-types/v2/AppsConfig.ts +0 -6
- package/services/mac-bridge/codex-types/v2/AppsListParams.ts +0 -24
- package/services/mac-bridge/codex-types/v2/AppsListResponse.ts +0 -14
- package/services/mac-bridge/codex-types/v2/AskForApproval.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ByteRange.ts +0 -5
- package/services/mac-bridge/codex-types/v2/CancelLoginAccountParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/CancelLoginAccountResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/CancelLoginAccountStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ChatgptAuthTokensRefreshParams.ts +0 -16
- package/services/mac-bridge/codex-types/v2/ChatgptAuthTokensRefreshReason.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ChatgptAuthTokensRefreshResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/CodexErrorInfo.ts +0 -11
- package/services/mac-bridge/codex-types/v2/CollabAgentState.ts +0 -6
- package/services/mac-bridge/codex-types/v2/CollabAgentStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/CollabAgentTool.ts +0 -5
- package/services/mac-bridge/codex-types/v2/CollabAgentToolCallStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/CommandAction.ts +0 -5
- package/services/mac-bridge/codex-types/v2/CommandExecParams.ts +0 -6
- package/services/mac-bridge/codex-types/v2/CommandExecResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/CommandExecutionApprovalDecision.ts +0 -6
- package/services/mac-bridge/codex-types/v2/CommandExecutionOutputDeltaNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/CommandExecutionRequestApprovalParams.ts +0 -37
- package/services/mac-bridge/codex-types/v2/CommandExecutionRequestApprovalResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/CommandExecutionStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/Config.ts +0 -17
- package/services/mac-bridge/codex-types/v2/ConfigBatchWriteParams.ts +0 -10
- package/services/mac-bridge/codex-types/v2/ConfigEdit.ts +0 -7
- package/services/mac-bridge/codex-types/v2/ConfigLayer.ts +0 -7
- package/services/mac-bridge/codex-types/v2/ConfigLayerMetadata.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ConfigLayerSource.ts +0 -16
- package/services/mac-bridge/codex-types/v2/ConfigReadParams.ts +0 -11
- package/services/mac-bridge/codex-types/v2/ConfigReadResponse.ts +0 -8
- package/services/mac-bridge/codex-types/v2/ConfigRequirements.ts +0 -9
- package/services/mac-bridge/codex-types/v2/ConfigRequirementsReadResponse.ts +0 -10
- package/services/mac-bridge/codex-types/v2/ConfigValueWriteParams.ts +0 -11
- package/services/mac-bridge/codex-types/v2/ConfigWarningNotification.ts +0 -22
- package/services/mac-bridge/codex-types/v2/ConfigWriteResponse.ts +0 -12
- package/services/mac-bridge/codex-types/v2/ContextCompactedNotification.ts +0 -8
- package/services/mac-bridge/codex-types/v2/CreditsSnapshot.ts +0 -5
- package/services/mac-bridge/codex-types/v2/DeprecationNoticeNotification.ts +0 -13
- package/services/mac-bridge/codex-types/v2/DynamicToolCallOutputContentItem.ts +0 -5
- package/services/mac-bridge/codex-types/v2/DynamicToolCallParams.ts +0 -6
- package/services/mac-bridge/codex-types/v2/DynamicToolCallResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/DynamicToolSpec.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ErrorNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ExecPolicyAmendment.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ExperimentalFeature.ts +0 -37
- package/services/mac-bridge/codex-types/v2/ExperimentalFeatureListParams.ts +0 -13
- package/services/mac-bridge/codex-types/v2/ExperimentalFeatureListResponse.ts +0 -11
- package/services/mac-bridge/codex-types/v2/ExperimentalFeatureStage.ts +0 -5
- package/services/mac-bridge/codex-types/v2/FeedbackUploadParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/FeedbackUploadResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/FileChangeApprovalDecision.ts +0 -5
- package/services/mac-bridge/codex-types/v2/FileChangeOutputDeltaNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/FileChangeRequestApprovalParams.ts +0 -14
- package/services/mac-bridge/codex-types/v2/FileChangeRequestApprovalResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/FileUpdateChange.ts +0 -6
- package/services/mac-bridge/codex-types/v2/GetAccountParams.ts +0 -13
- package/services/mac-bridge/codex-types/v2/GetAccountRateLimitsResponse.ts +0 -14
- package/services/mac-bridge/codex-types/v2/GetAccountResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/GitInfo.ts +0 -5
- package/services/mac-bridge/codex-types/v2/HazelnutScope.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ItemCompletedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ItemStartedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ListMcpServerStatusParams.ts +0 -13
- package/services/mac-bridge/codex-types/v2/ListMcpServerStatusResponse.ts +0 -11
- package/services/mac-bridge/codex-types/v2/LoginAccountParams.ts +0 -21
- package/services/mac-bridge/codex-types/v2/LoginAccountResponse.ts +0 -9
- package/services/mac-bridge/codex-types/v2/LogoutAccountResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/McpAuthStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/McpServerOauthLoginCompletedNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/McpServerOauthLoginParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/McpServerOauthLoginResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/McpServerRefreshResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/McpServerStatus.ts +0 -9
- package/services/mac-bridge/codex-types/v2/McpToolCallError.ts +0 -5
- package/services/mac-bridge/codex-types/v2/McpToolCallProgressNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/McpToolCallResult.ts +0 -6
- package/services/mac-bridge/codex-types/v2/McpToolCallStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/MergeStrategy.ts +0 -5
- package/services/mac-bridge/codex-types/v2/Model.ts +0 -8
- package/services/mac-bridge/codex-types/v2/ModelListParams.ts +0 -17
- package/services/mac-bridge/codex-types/v2/ModelListResponse.ts +0 -11
- package/services/mac-bridge/codex-types/v2/ModelRerouteReason.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ModelReroutedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/NetworkAccess.ts +0 -5
- package/services/mac-bridge/codex-types/v2/NetworkRequirements.ts +0 -5
- package/services/mac-bridge/codex-types/v2/OverriddenMetadata.ts +0 -7
- package/services/mac-bridge/codex-types/v2/PatchApplyStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/PatchChangeKind.ts +0 -5
- package/services/mac-bridge/codex-types/v2/PlanDeltaNotification.ts +0 -9
- package/services/mac-bridge/codex-types/v2/ProductSurface.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ProfileV2.ts +0 -11
- package/services/mac-bridge/codex-types/v2/RateLimitSnapshot.ts +0 -8
- package/services/mac-bridge/codex-types/v2/RateLimitWindow.ts +0 -5
- package/services/mac-bridge/codex-types/v2/RawResponseItemCompletedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ReadOnlyAccess.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ReasoningEffortOption.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ReasoningSummaryPartAddedNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ReasoningSummaryTextDeltaNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ReasoningTextDeltaNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/RemoteSkillSummary.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ResidencyRequirement.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ReviewDelivery.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ReviewStartParams.ts +0 -12
- package/services/mac-bridge/codex-types/v2/ReviewStartResponse.ts +0 -13
- package/services/mac-bridge/codex-types/v2/ReviewTarget.ts +0 -9
- package/services/mac-bridge/codex-types/v2/SandboxMode.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SandboxPolicy.ts +0 -8
- package/services/mac-bridge/codex-types/v2/SandboxWorkspaceWrite.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SessionSource.ts +0 -6
- package/services/mac-bridge/codex-types/v2/SkillDependencies.ts +0 -6
- package/services/mac-bridge/codex-types/v2/SkillErrorInfo.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SkillInterface.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SkillMetadata.ts +0 -12
- package/services/mac-bridge/codex-types/v2/SkillScope.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SkillToolDependency.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SkillsConfigWriteParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SkillsConfigWriteResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SkillsListEntry.ts +0 -7
- package/services/mac-bridge/codex-types/v2/SkillsListExtraRootsForCwd.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SkillsListParams.ts +0 -18
- package/services/mac-bridge/codex-types/v2/SkillsListResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/SkillsRemoteReadParams.ts +0 -7
- package/services/mac-bridge/codex-types/v2/SkillsRemoteReadResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/SkillsRemoteWriteParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/SkillsRemoteWriteResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/TerminalInteractionNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/TextElement.ts +0 -14
- package/services/mac-bridge/codex-types/v2/TextPosition.ts +0 -13
- package/services/mac-bridge/codex-types/v2/TextRange.ts +0 -6
- package/services/mac-bridge/codex-types/v2/Thread.ts +0 -51
- package/services/mac-bridge/codex-types/v2/ThreadArchiveParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadArchiveResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadArchivedNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadCompactStartParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadCompactStartResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadForkParams.ts +0 -28
- package/services/mac-bridge/codex-types/v2/ThreadForkResponse.ts +0 -9
- package/services/mac-bridge/codex-types/v2/ThreadItem.ts +0 -81
- package/services/mac-bridge/codex-types/v2/ThreadListParams.ts +0 -39
- package/services/mac-bridge/codex-types/v2/ThreadListResponse.ts +0 -11
- package/services/mac-bridge/codex-types/v2/ThreadLoadedListParams.ts +0 -13
- package/services/mac-bridge/codex-types/v2/ThreadLoadedListResponse.ts +0 -14
- package/services/mac-bridge/codex-types/v2/ThreadNameUpdatedNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadReadParams.ts +0 -9
- package/services/mac-bridge/codex-types/v2/ThreadReadResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ThreadResumeParams.ts +0 -37
- package/services/mac-bridge/codex-types/v2/ThreadResumeResponse.ts +0 -9
- package/services/mac-bridge/codex-types/v2/ThreadRollbackParams.ts +0 -12
- package/services/mac-bridge/codex-types/v2/ThreadRollbackResponse.ts +0 -14
- package/services/mac-bridge/codex-types/v2/ThreadSetNameParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadSetNameResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadSortKey.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadSourceKind.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadStartParams.ts +0 -17
- package/services/mac-bridge/codex-types/v2/ThreadStartResponse.ts +0 -9
- package/services/mac-bridge/codex-types/v2/ThreadStartedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ThreadTokenUsage.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ThreadTokenUsageUpdatedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ThreadUnarchiveParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ThreadUnarchiveResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/ThreadUnarchivedNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/TokenUsageBreakdown.ts +0 -5
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputAnswer.ts +0 -8
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputOption.ts +0 -8
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputParams.ts +0 -9
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputQuestion.ts +0 -9
- package/services/mac-bridge/codex-types/v2/ToolRequestUserInputResponse.ts +0 -9
- package/services/mac-bridge/codex-types/v2/ToolsV2.ts +0 -5
- package/services/mac-bridge/codex-types/v2/Turn.ts +0 -18
- package/services/mac-bridge/codex-types/v2/TurnCompletedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/TurnDiffUpdatedNotification.ts +0 -9
- package/services/mac-bridge/codex-types/v2/TurnError.ts +0 -6
- package/services/mac-bridge/codex-types/v2/TurnInterruptParams.ts +0 -5
- package/services/mac-bridge/codex-types/v2/TurnInterruptResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/TurnPlanStep.ts +0 -6
- package/services/mac-bridge/codex-types/v2/TurnPlanStepStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/TurnPlanUpdatedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/TurnStartParams.ts +0 -44
- package/services/mac-bridge/codex-types/v2/TurnStartResponse.ts +0 -6
- package/services/mac-bridge/codex-types/v2/TurnStartedNotification.ts +0 -6
- package/services/mac-bridge/codex-types/v2/TurnStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/TurnSteerParams.ts +0 -11
- package/services/mac-bridge/codex-types/v2/TurnSteerResponse.ts +0 -5
- package/services/mac-bridge/codex-types/v2/UserInput.ts +0 -10
- package/services/mac-bridge/codex-types/v2/WebSearchAction.ts +0 -5
- package/services/mac-bridge/codex-types/v2/WindowsWorldWritableWarningNotification.ts +0 -5
- package/services/mac-bridge/codex-types/v2/WriteStatus.ts +0 -5
- package/services/mac-bridge/codex-types/v2/index.ts +0 -204
- package/services/mac-bridge/eslint.config.cjs +0 -22
- package/services/mac-bridge/package.json +0 -30
- package/services/mac-bridge/schema.ts +0 -0
- package/services/mac-bridge/src/index.ts +0 -18
- package/services/mac-bridge/src/server.ts +0 -426
- package/services/mac-bridge/src/services/__tests__/gitService.test.ts +0 -157
- package/services/mac-bridge/src/services/__tests__/realtimeHub.test.ts +0 -116
- package/services/mac-bridge/src/services/__tests__/terminalService.test.ts +0 -51
- package/services/mac-bridge/src/services/codexAppServerClient.ts +0 -507
- package/services/mac-bridge/src/services/codexCliAdapter.ts +0 -622
- package/services/mac-bridge/src/services/gitService.ts +0 -61
- package/services/mac-bridge/src/services/realtimeHub.ts +0 -25
- package/services/mac-bridge/src/services/terminalService.ts +0 -226
- package/services/mac-bridge/src/types.ts +0 -151
- package/services/mac-bridge/src/utils/__tests__/threadMapping.test.ts +0 -397
- package/services/mac-bridge/src/utils/threadMapping.ts +0 -176
- package/services/mac-bridge/tsconfig.json +0 -16
- package/services/mac-bridge/vitest.config.ts +0 -9
- package/services/rust-bridge/.env.example +0 -14
- package/services/rust-bridge/package.json +0 -13
- package/services/rust-bridge/security_best_practices_report.md +0 -24
- package/site/index.html +0 -54
- package/site/privacy/index.html +0 -80
- package/site/styles.css +0 -135
- package/site/support/index.html +0 -51
- package/site/terms/index.html +0 -68
- package/tsconfig.json +0 -4
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
import cors from '@fastify/cors';
|
|
2
|
-
import websocket from '@fastify/websocket';
|
|
3
|
-
import { isAbsolute, resolve as resolvePath } from 'node:path';
|
|
4
|
-
import Fastify, {
|
|
5
|
-
type FastifyInstance,
|
|
6
|
-
type FastifyReply,
|
|
7
|
-
type FastifyRequest
|
|
8
|
-
} from 'fastify';
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
|
|
11
|
-
import { CodexCliAdapter, ThreadBusyError } from './services/codexCliAdapter';
|
|
12
|
-
import { GitService } from './services/gitService';
|
|
13
|
-
import { RealtimeHub } from './services/realtimeHub';
|
|
14
|
-
import {
|
|
15
|
-
TerminalCommandRejectedError,
|
|
16
|
-
TerminalService
|
|
17
|
-
} from './services/terminalService';
|
|
18
|
-
import type {
|
|
19
|
-
ApprovalDecision,
|
|
20
|
-
BridgeWsEvent,
|
|
21
|
-
CreateThreadInput,
|
|
22
|
-
SendThreadMessageInput
|
|
23
|
-
} from './types';
|
|
24
|
-
|
|
25
|
-
const createThreadSchema = z.object({
|
|
26
|
-
title: z.string().trim().min(1).max(120).optional(),
|
|
27
|
-
message: z.string().trim().min(1).max(20_000).optional()
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const sendMessageSchema = z.object({
|
|
31
|
-
content: z.string().trim().min(1).max(20_000),
|
|
32
|
-
role: z.enum(['user', 'assistant', 'system']).optional()
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const terminalExecSchema = z.object({
|
|
36
|
-
command: z.string().trim().min(1),
|
|
37
|
-
cwd: z.string().trim().min(1).optional(),
|
|
38
|
-
timeoutMs: z.number().int().min(100).max(120_000).optional()
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const gitCommitSchema = z.object({
|
|
42
|
-
message: z.string().trim().min(1).max(500)
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const approvalDecisionSchema = z.object({
|
|
46
|
-
decision: z.enum(['accept', 'acceptForSession', 'decline', 'cancel'])
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
interface IdParams {
|
|
50
|
-
id: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
type CreateThreadRequest = FastifyRequest<{ Body: CreateThreadInput }>;
|
|
54
|
-
type MessageRequest = FastifyRequest<{
|
|
55
|
-
Params: IdParams;
|
|
56
|
-
Body: SendThreadMessageInput;
|
|
57
|
-
}>;
|
|
58
|
-
type ThreadByIdRequest = FastifyRequest<{ Params: IdParams }>;
|
|
59
|
-
type TerminalExecBody = z.infer<typeof terminalExecSchema>;
|
|
60
|
-
type TerminalRequest = FastifyRequest<{ Body: TerminalExecBody }>;
|
|
61
|
-
type GitCommitBody = z.infer<typeof gitCommitSchema>;
|
|
62
|
-
type GitCommitRequest = FastifyRequest<{ Body: GitCommitBody }>;
|
|
63
|
-
type ApprovalDecisionBody = z.infer<typeof approvalDecisionSchema>;
|
|
64
|
-
type ApprovalDecisionRequest = FastifyRequest<{
|
|
65
|
-
Params: IdParams;
|
|
66
|
-
Body: ApprovalDecisionBody;
|
|
67
|
-
}>;
|
|
68
|
-
|
|
69
|
-
export async function buildServer(): Promise<FastifyInstance> {
|
|
70
|
-
const app = Fastify({
|
|
71
|
-
logger: true
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const startupAt = Date.now();
|
|
75
|
-
const bridgeWorkdir = resolvePath(process.env.BRIDGE_WORKDIR ?? process.cwd());
|
|
76
|
-
const bridgeAuthToken = process.env.BRIDGE_AUTH_TOKEN?.trim() ?? '';
|
|
77
|
-
const allowInsecureNoAuth = parseBoolean(process.env.BRIDGE_ALLOW_INSECURE_NO_AUTH);
|
|
78
|
-
const allowQueryTokenAuth = parseBoolean(process.env.BRIDGE_ALLOW_QUERY_TOKEN_AUTH);
|
|
79
|
-
const terminalEnabled = !parseBoolean(process.env.BRIDGE_DISABLE_TERMINAL_EXEC);
|
|
80
|
-
const terminalAllowedCommands = parseCsvList(process.env.BRIDGE_TERMINAL_ALLOWED_COMMANDS, [
|
|
81
|
-
'pwd',
|
|
82
|
-
'ls',
|
|
83
|
-
'cat',
|
|
84
|
-
'git'
|
|
85
|
-
]);
|
|
86
|
-
const corsOrigins = parseCsvList(process.env.BRIDGE_CORS_ORIGINS);
|
|
87
|
-
|
|
88
|
-
if (!bridgeAuthToken && !allowInsecureNoAuth) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
'BRIDGE_AUTH_TOKEN is required. Set BRIDGE_ALLOW_INSECURE_NO_AUTH=true only for local development.'
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const authEnabled = bridgeAuthToken.length > 0;
|
|
95
|
-
const realtime = new RealtimeHub();
|
|
96
|
-
|
|
97
|
-
const codex = new CodexCliAdapter({
|
|
98
|
-
workdir: bridgeWorkdir,
|
|
99
|
-
cliBin: process.env.CODEX_CLI_BIN ?? undefined,
|
|
100
|
-
cliTimeoutMs: parseTimeoutMs(process.env.CODEX_CLI_TIMEOUT_MS),
|
|
101
|
-
emitEvent: (event) => {
|
|
102
|
-
realtime.broadcast(event);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
const terminal = new TerminalService({
|
|
106
|
-
allowedCommands: terminalAllowedCommands
|
|
107
|
-
});
|
|
108
|
-
const git = new GitService(terminal, bridgeWorkdir);
|
|
109
|
-
|
|
110
|
-
await app.register(cors, {
|
|
111
|
-
origin: corsOrigins.length > 0 ? corsOrigins : false
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
await app.register(websocket);
|
|
115
|
-
|
|
116
|
-
if (!authEnabled && allowInsecureNoAuth) {
|
|
117
|
-
app.log.warn(
|
|
118
|
-
'bridge auth is disabled by BRIDGE_ALLOW_INSECURE_NO_AUTH=true (local development only)'
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
if (allowQueryTokenAuth) {
|
|
122
|
-
app.log.warn(
|
|
123
|
-
'query-token auth is enabled (BRIDGE_ALLOW_QUERY_TOKEN_AUTH=true); prefer Authorization headers instead'
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
if (corsOrigins.length === 0) {
|
|
127
|
-
app.log.info(
|
|
128
|
-
'CORS response headers are disabled. Set BRIDGE_CORS_ORIGINS to allow browser origins.'
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
if (!terminalEnabled) {
|
|
132
|
-
app.log.warn('terminal exec endpoint is disabled by BRIDGE_DISABLE_TERMINAL_EXEC=true');
|
|
133
|
-
} else if (terminalAllowedCommands.length === 0) {
|
|
134
|
-
app.log.warn(
|
|
135
|
-
'terminal allowlist is empty; all commands are currently permitted. Set BRIDGE_TERMINAL_ALLOWED_COMMANDS to restrict.'
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
app.addHook('onRequest', async (request, reply) => {
|
|
140
|
-
if (!authEnabled) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (request.url === '/health' || request.url.startsWith('/health?')) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (isAuthorized(request, bridgeAuthToken, allowQueryTokenAuth)) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return reply.code(401).send({
|
|
153
|
-
error: 'unauthorized',
|
|
154
|
-
message: 'Missing or invalid bridge token'
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
app.get('/ws', { websocket: true }, (socket) => {
|
|
159
|
-
realtime.addClient(socket);
|
|
160
|
-
|
|
161
|
-
const healthEvent: BridgeWsEvent = {
|
|
162
|
-
type: 'health',
|
|
163
|
-
payload: {
|
|
164
|
-
status: 'ok',
|
|
165
|
-
at: new Date().toISOString()
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
socket.send(JSON.stringify(healthEvent));
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
app.get('/health', async () => {
|
|
173
|
-
return {
|
|
174
|
-
status: 'ok' as const,
|
|
175
|
-
at: new Date().toISOString(),
|
|
176
|
-
uptimeSec: Math.floor((Date.now() - startupAt) / 1000)
|
|
177
|
-
};
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
app.get('/threads', async () => {
|
|
181
|
-
return codex.listThreads();
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
app.post('/threads', async (request: CreateThreadRequest, reply: FastifyReply) => {
|
|
185
|
-
const parsed = createThreadSchema.safeParse((request.body ?? {}) as CreateThreadInput);
|
|
186
|
-
if (!parsed.success) {
|
|
187
|
-
return reply.code(400).send({ error: parsed.error.flatten() });
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const thread = await codex.createThread(parsed.data);
|
|
191
|
-
return reply.code(201).send(thread);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
app.get('/threads/:id', async (request: ThreadByIdRequest, reply: FastifyReply) => {
|
|
195
|
-
const thread = await codex.getThread(request.params.id);
|
|
196
|
-
if (!thread) {
|
|
197
|
-
return reply.code(404).send({ error: 'thread_not_found' });
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return thread;
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
app.post(
|
|
204
|
-
'/threads/:id/message',
|
|
205
|
-
async (request: MessageRequest, reply: FastifyReply) => {
|
|
206
|
-
const parsed = sendMessageSchema.safeParse(
|
|
207
|
-
(request.body ?? {}) as SendThreadMessageInput
|
|
208
|
-
);
|
|
209
|
-
if (!parsed.success) {
|
|
210
|
-
return reply.code(400).send({ error: parsed.error.flatten() });
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
try {
|
|
214
|
-
const thread = await codex.appendMessage(request.params.id, parsed.data);
|
|
215
|
-
if (!thread) {
|
|
216
|
-
return reply.code(404).send({ error: 'thread_not_found' });
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return thread;
|
|
220
|
-
} catch (error) {
|
|
221
|
-
if (error instanceof ThreadBusyError) {
|
|
222
|
-
return reply.code(409).send({
|
|
223
|
-
error: error.code,
|
|
224
|
-
message: error.message,
|
|
225
|
-
threadId: error.threadId
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return reply.code(500).send({
|
|
230
|
-
error: 'thread_message_failed',
|
|
231
|
-
message: (error as Error).message
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
app.get('/approvals', async () => {
|
|
238
|
-
return codex.listPendingApprovals();
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
app.post(
|
|
242
|
-
'/approvals/:id/decision',
|
|
243
|
-
async (request: ApprovalDecisionRequest, reply: FastifyReply) => {
|
|
244
|
-
const parsed = approvalDecisionSchema.safeParse(request.body ?? {});
|
|
245
|
-
if (!parsed.success) {
|
|
246
|
-
return reply.code(400).send({ error: parsed.error.flatten() });
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const resolved = await codex.resolveApproval(
|
|
250
|
-
request.params.id,
|
|
251
|
-
parsed.data.decision as ApprovalDecision
|
|
252
|
-
);
|
|
253
|
-
if (!resolved) {
|
|
254
|
-
return reply.code(404).send({ error: 'approval_not_found' });
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return {
|
|
258
|
-
ok: true as const,
|
|
259
|
-
approval: resolved,
|
|
260
|
-
decision: parsed.data.decision
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
app.post('/terminal/exec', async (request: TerminalRequest, reply: FastifyReply) => {
|
|
266
|
-
const parsed = terminalExecSchema.safeParse(request.body ?? {});
|
|
267
|
-
if (!parsed.success) {
|
|
268
|
-
return reply.code(400).send({ error: parsed.error.flatten() });
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (!terminalEnabled) {
|
|
272
|
-
return reply.code(403).send({
|
|
273
|
-
error: 'terminal_exec_disabled',
|
|
274
|
-
message: 'Terminal execution is disabled on this bridge.'
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const resolvedCwd = resolveTerminalCwd(parsed.data.cwd, bridgeWorkdir);
|
|
279
|
-
|
|
280
|
-
try {
|
|
281
|
-
const result = await terminal.executeShell(parsed.data.command, {
|
|
282
|
-
cwd: resolvedCwd,
|
|
283
|
-
timeoutMs: parsed.data.timeoutMs
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
realtime.broadcast({
|
|
287
|
-
type: 'terminal.executed',
|
|
288
|
-
payload: result
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
return result;
|
|
292
|
-
} catch (error) {
|
|
293
|
-
if (error instanceof TerminalCommandRejectedError) {
|
|
294
|
-
return reply.code(400).send({
|
|
295
|
-
error: error.code,
|
|
296
|
-
message: error.message
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return reply.code(500).send({
|
|
301
|
-
error: 'terminal_exec_failed',
|
|
302
|
-
message: (error as Error).message
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
app.get('/git/status', async (_request: FastifyRequest, reply: FastifyReply) => {
|
|
308
|
-
try {
|
|
309
|
-
return await git.getStatus();
|
|
310
|
-
} catch (error) {
|
|
311
|
-
return reply.code(500).send({
|
|
312
|
-
error: 'git_status_failed',
|
|
313
|
-
message: (error as Error).message
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
app.get('/git/diff', async (_request: FastifyRequest, reply: FastifyReply) => {
|
|
319
|
-
try {
|
|
320
|
-
return await git.getDiff();
|
|
321
|
-
} catch (error) {
|
|
322
|
-
return reply.code(500).send({
|
|
323
|
-
error: 'git_diff_failed',
|
|
324
|
-
message: (error as Error).message
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
app.post('/git/commit', async (request: GitCommitRequest, reply: FastifyReply) => {
|
|
330
|
-
const parsed = gitCommitSchema.safeParse(request.body ?? {});
|
|
331
|
-
if (!parsed.success) {
|
|
332
|
-
return reply.code(400).send({ error: parsed.error.flatten() });
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
try {
|
|
336
|
-
const commit = await git.commit(parsed.data.message);
|
|
337
|
-
const status = await git.getStatus();
|
|
338
|
-
|
|
339
|
-
realtime.broadcast({
|
|
340
|
-
type: 'git.updated',
|
|
341
|
-
payload: status
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
return commit;
|
|
345
|
-
} catch (error) {
|
|
346
|
-
return reply.code(500).send({
|
|
347
|
-
error: 'git_commit_failed',
|
|
348
|
-
message: (error as Error).message
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
return app;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function parseTimeoutMs(value: string | undefined): number | undefined {
|
|
357
|
-
if (!value) {
|
|
358
|
-
return undefined;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const parsed = Number(value);
|
|
362
|
-
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
363
|
-
return undefined;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
return Math.floor(parsed);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function isAuthorized(
|
|
370
|
-
request: FastifyRequest,
|
|
371
|
-
token: string,
|
|
372
|
-
allowQueryTokenAuth: boolean
|
|
373
|
-
): boolean {
|
|
374
|
-
const authHeader = request.headers.authorization;
|
|
375
|
-
if (typeof authHeader === 'string' && authHeader.startsWith('Bearer ')) {
|
|
376
|
-
const bearer = authHeader.slice('Bearer '.length).trim();
|
|
377
|
-
if (bearer === token) {
|
|
378
|
-
return true;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
if (allowQueryTokenAuth) {
|
|
383
|
-
const queryToken = (() => {
|
|
384
|
-
try {
|
|
385
|
-
const parsedUrl = new URL(request.url, 'http://localhost');
|
|
386
|
-
return parsedUrl.searchParams.get('token');
|
|
387
|
-
} catch {
|
|
388
|
-
return null;
|
|
389
|
-
}
|
|
390
|
-
})();
|
|
391
|
-
|
|
392
|
-
if (queryToken && queryToken === token) {
|
|
393
|
-
return true;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
return false;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function parseBoolean(value: string | undefined): boolean {
|
|
401
|
-
if (!value) {
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
return value.trim().toLowerCase() === 'true';
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function parseCsvList(value: string | undefined, fallback: string[] = []): string[] {
|
|
409
|
-
if (!value) {
|
|
410
|
-
return [...fallback];
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
return value
|
|
414
|
-
.split(',')
|
|
415
|
-
.map((entry) => entry.trim())
|
|
416
|
-
.filter(Boolean);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
function resolveTerminalCwd(rawCwd: string | undefined, root: string): string {
|
|
420
|
-
const normalizedRoot = resolvePath(root);
|
|
421
|
-
if (!rawCwd || rawCwd.trim().length === 0) {
|
|
422
|
-
return normalizedRoot;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
return isAbsolute(rawCwd) ? resolvePath(rawCwd) : resolvePath(normalizedRoot, rawCwd);
|
|
426
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import type { TerminalExecResponse } from '../../types';
|
|
2
|
-
import { GitService } from '../gitService';
|
|
3
|
-
import type { TerminalService } from '../terminalService';
|
|
4
|
-
|
|
5
|
-
function createMockTerminal(response: Partial<TerminalExecResponse> = {}) {
|
|
6
|
-
const defaults: TerminalExecResponse = {
|
|
7
|
-
command: '',
|
|
8
|
-
cwd: '/repo',
|
|
9
|
-
code: 0,
|
|
10
|
-
stdout: '',
|
|
11
|
-
stderr: '',
|
|
12
|
-
timedOut: false,
|
|
13
|
-
durationMs: 10,
|
|
14
|
-
...response,
|
|
15
|
-
};
|
|
16
|
-
return {
|
|
17
|
-
executeBinary: vi.fn().mockResolvedValue(defaults),
|
|
18
|
-
executeShell: vi.fn(),
|
|
19
|
-
} as unknown as TerminalService;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe('GitService', () => {
|
|
23
|
-
const repoPath = '/repo';
|
|
24
|
-
|
|
25
|
-
describe('getStatus', () => {
|
|
26
|
-
it('parses branch from ## main...origin/main', async () => {
|
|
27
|
-
const terminal = createMockTerminal({
|
|
28
|
-
stdout: '## main...origin/main',
|
|
29
|
-
});
|
|
30
|
-
const git = new GitService(terminal, repoPath);
|
|
31
|
-
|
|
32
|
-
const status = await git.getStatus();
|
|
33
|
-
|
|
34
|
-
expect(status.branch).toBe('main');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('parses branch without tracking info: ## feature-x', async () => {
|
|
38
|
-
const terminal = createMockTerminal({
|
|
39
|
-
stdout: '## feature-x',
|
|
40
|
-
});
|
|
41
|
-
const git = new GitService(terminal, repoPath);
|
|
42
|
-
|
|
43
|
-
const status = await git.getStatus();
|
|
44
|
-
|
|
45
|
-
expect(status.branch).toBe('feature-x');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('reports clean: true when only branch line present', async () => {
|
|
49
|
-
const terminal = createMockTerminal({
|
|
50
|
-
stdout: '## main...origin/main',
|
|
51
|
-
});
|
|
52
|
-
const git = new GitService(terminal, repoPath);
|
|
53
|
-
|
|
54
|
-
const status = await git.getStatus();
|
|
55
|
-
|
|
56
|
-
expect(status.clean).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('reports clean: false when modified files are present', async () => {
|
|
60
|
-
const terminal = createMockTerminal({
|
|
61
|
-
stdout: '## main\n M src/index.ts',
|
|
62
|
-
});
|
|
63
|
-
const git = new GitService(terminal, repoPath);
|
|
64
|
-
|
|
65
|
-
const status = await git.getStatus();
|
|
66
|
-
|
|
67
|
-
expect(status.clean).toBe(false);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('throws when exit code is non-zero', async () => {
|
|
71
|
-
const terminal = createMockTerminal({
|
|
72
|
-
code: 128,
|
|
73
|
-
stderr: 'fatal: not a git repository',
|
|
74
|
-
});
|
|
75
|
-
const git = new GitService(terminal, repoPath);
|
|
76
|
-
|
|
77
|
-
await expect(git.getStatus()).rejects.toThrow(
|
|
78
|
-
'fatal: not a git repository'
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('returns raw field with full stdout', async () => {
|
|
83
|
-
const stdout = '## main...origin/main\n M src/index.ts';
|
|
84
|
-
const terminal = createMockTerminal({ stdout });
|
|
85
|
-
const git = new GitService(terminal, repoPath);
|
|
86
|
-
|
|
87
|
-
const status = await git.getStatus();
|
|
88
|
-
|
|
89
|
-
expect(status.raw).toBe(stdout);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('getDiff', () => {
|
|
94
|
-
it('returns diff from stdout', async () => {
|
|
95
|
-
const diff = 'diff --git a/file.ts b/file.ts\n--- a/file.ts\n+++ b/file.ts';
|
|
96
|
-
const terminal = createMockTerminal({ stdout: diff });
|
|
97
|
-
const git = new GitService(terminal, repoPath);
|
|
98
|
-
|
|
99
|
-
const result = await git.getDiff();
|
|
100
|
-
|
|
101
|
-
expect(result.diff).toBe(diff);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('throws when exit code is non-zero', async () => {
|
|
105
|
-
const terminal = createMockTerminal({
|
|
106
|
-
code: 1,
|
|
107
|
-
stderr: 'error: could not read diff',
|
|
108
|
-
});
|
|
109
|
-
const git = new GitService(terminal, repoPath);
|
|
110
|
-
|
|
111
|
-
await expect(git.getDiff()).rejects.toThrow(
|
|
112
|
-
'error: could not read diff'
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe('commit', () => {
|
|
118
|
-
it('returns committed: true when code is 0', async () => {
|
|
119
|
-
const terminal = createMockTerminal({
|
|
120
|
-
code: 0,
|
|
121
|
-
stdout: '[main abc1234] my commit message',
|
|
122
|
-
});
|
|
123
|
-
const git = new GitService(terminal, repoPath);
|
|
124
|
-
|
|
125
|
-
const result = await git.commit('my commit message');
|
|
126
|
-
|
|
127
|
-
expect(result.committed).toBe(true);
|
|
128
|
-
expect(result.code).toBe(0);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('returns committed: false when code is non-zero', async () => {
|
|
132
|
-
const terminal = createMockTerminal({
|
|
133
|
-
code: 1,
|
|
134
|
-
stderr: 'nothing to commit',
|
|
135
|
-
});
|
|
136
|
-
const git = new GitService(terminal, repoPath);
|
|
137
|
-
|
|
138
|
-
const result = await git.commit('my commit message');
|
|
139
|
-
|
|
140
|
-
expect(result.committed).toBe(false);
|
|
141
|
-
expect(result.code).toBe(1);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('passes message as git commit argument', async () => {
|
|
145
|
-
const terminal = createMockTerminal({ code: 0 });
|
|
146
|
-
const git = new GitService(terminal, repoPath);
|
|
147
|
-
|
|
148
|
-
await git.commit('fix: resolve bug');
|
|
149
|
-
|
|
150
|
-
expect(terminal.executeBinary).toHaveBeenCalledWith(
|
|
151
|
-
'git',
|
|
152
|
-
['-C', repoPath, 'commit', '-m', 'fix: resolve bug'],
|
|
153
|
-
{ cwd: repoPath }
|
|
154
|
-
);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
});
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { RealtimeHub } from '../realtimeHub';
|
|
2
|
-
import type { BridgeWsEvent } from '../../types';
|
|
3
|
-
import type { WebSocket } from '@fastify/websocket';
|
|
4
|
-
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// Mock WebSocket client helper
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
interface MockClient {
|
|
10
|
-
readyState: number;
|
|
11
|
-
send: ReturnType<typeof vi.fn>;
|
|
12
|
-
on: ReturnType<typeof vi.fn>;
|
|
13
|
-
_triggerClose: () => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function createMockClient(readyState = 1): MockClient {
|
|
17
|
-
const handlers: Record<string, () => void> = {};
|
|
18
|
-
return {
|
|
19
|
-
readyState,
|
|
20
|
-
send: vi.fn(),
|
|
21
|
-
on: vi.fn((event: string, handler: () => void) => {
|
|
22
|
-
handlers[event] = handler;
|
|
23
|
-
}),
|
|
24
|
-
// Helper to trigger close event in tests
|
|
25
|
-
_triggerClose: () => handlers['close']?.(),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
// RealtimeHub
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
describe('RealtimeHub', () => {
|
|
34
|
-
const sampleEvent: BridgeWsEvent = {
|
|
35
|
-
type: 'health',
|
|
36
|
-
payload: { status: 'ok', at: '2026-01-01T00:00:00.000Z' },
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
it('broadcast sends serialized JSON to all connected clients with readyState === 1', () => {
|
|
40
|
-
const hub = new RealtimeHub();
|
|
41
|
-
const client1 = createMockClient(1);
|
|
42
|
-
const client2 = createMockClient(1);
|
|
43
|
-
|
|
44
|
-
hub.addClient(client1 as unknown as WebSocket);
|
|
45
|
-
hub.addClient(client2 as unknown as WebSocket);
|
|
46
|
-
hub.broadcast(sampleEvent);
|
|
47
|
-
|
|
48
|
-
const expected = JSON.stringify(sampleEvent);
|
|
49
|
-
expect(client1.send).toHaveBeenCalledTimes(1);
|
|
50
|
-
expect(client1.send).toHaveBeenCalledWith(expected);
|
|
51
|
-
expect(client2.send).toHaveBeenCalledTimes(1);
|
|
52
|
-
expect(client2.send).toHaveBeenCalledWith(expected);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('broadcast skips clients where readyState !== 1 (e.g., CLOSED)', () => {
|
|
56
|
-
const hub = new RealtimeHub();
|
|
57
|
-
const openClient = createMockClient(1);
|
|
58
|
-
const closedClient = createMockClient(3); // WebSocket.CLOSED = 3
|
|
59
|
-
|
|
60
|
-
hub.addClient(openClient as unknown as WebSocket);
|
|
61
|
-
hub.addClient(closedClient as unknown as WebSocket);
|
|
62
|
-
hub.broadcast(sampleEvent);
|
|
63
|
-
|
|
64
|
-
expect(openClient.send).toHaveBeenCalledTimes(1);
|
|
65
|
-
expect(closedClient.send).not.toHaveBeenCalled();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('addClient registers a client; after triggering close, client is removed and no longer receives broadcasts', () => {
|
|
69
|
-
const hub = new RealtimeHub();
|
|
70
|
-
const client = createMockClient(1);
|
|
71
|
-
|
|
72
|
-
hub.addClient(client as unknown as WebSocket);
|
|
73
|
-
|
|
74
|
-
// Verify the close handler was registered
|
|
75
|
-
expect(client.on).toHaveBeenCalledWith('close', expect.any(Function));
|
|
76
|
-
|
|
77
|
-
// Client should receive broadcasts before close
|
|
78
|
-
hub.broadcast(sampleEvent);
|
|
79
|
-
expect(client.send).toHaveBeenCalledTimes(1);
|
|
80
|
-
|
|
81
|
-
// Trigger close -- client should be removed
|
|
82
|
-
client._triggerClose();
|
|
83
|
-
|
|
84
|
-
// Reset mock to verify no further calls
|
|
85
|
-
client.send.mockClear();
|
|
86
|
-
hub.broadcast(sampleEvent);
|
|
87
|
-
expect(client.send).not.toHaveBeenCalled();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('broadcast on empty hub does nothing (no errors thrown)', () => {
|
|
91
|
-
const hub = new RealtimeHub();
|
|
92
|
-
|
|
93
|
-
expect(() => hub.broadcast(sampleEvent)).not.toThrow();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('multiple clients each receive the same broadcast payload', () => {
|
|
97
|
-
const hub = new RealtimeHub();
|
|
98
|
-
const clients = [
|
|
99
|
-
createMockClient(1),
|
|
100
|
-
createMockClient(1),
|
|
101
|
-
createMockClient(1),
|
|
102
|
-
];
|
|
103
|
-
|
|
104
|
-
for (const client of clients) {
|
|
105
|
-
hub.addClient(client as unknown as WebSocket);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
hub.broadcast(sampleEvent);
|
|
109
|
-
|
|
110
|
-
const expected = JSON.stringify(sampleEvent);
|
|
111
|
-
for (const client of clients) {
|
|
112
|
-
expect(client.send).toHaveBeenCalledTimes(1);
|
|
113
|
-
expect(client.send).toHaveBeenCalledWith(expected);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|