codex-overleaf-link 2.4.1 → 2.5.1
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 +275 -305
- package/README.zh-CN.md +290 -320
- package/extension/bootstrap/background.js +99 -19
- package/extension/bootstrap/manifest.template.json +9 -4
- package/extension/bootstrap/popup.html +11 -16
- package/extension/bootstrap/popupFallback.js +55 -0
- package/extension/bootstrap/update.js +25 -2
- package/extension/bootstrap/updateStatus.js +1 -0
- package/extension/runtime-manifest.json +3 -1
- package/extension/src/background.js +234 -56
- package/extension/src/backgroundBootstrapMigration.js +181 -0
- package/extension/src/backgroundSharedSessions.js +440 -0
- package/extension/src/backgroundUpdateCoordinator.js +541 -381
- package/extension/src/backgroundUpdateSafety.js +173 -0
- package/extension/src/content/activeTurnControl.js +16 -2
- package/extension/src/content/applyResultFormatters.js +46 -73
- package/extension/src/content/assetTransferBroker.js +244 -12
- package/extension/src/content/changeHistoryView.js +175 -0
- package/extension/src/content/composerAttachments.js +117 -67
- package/extension/src/content/composerPanel.js +41 -8
- package/extension/src/content/contentRuntime.js +1084 -1099
- package/extension/src/content/diagnosticsController.js +122 -97
- package/extension/src/content/diagnosticsExport.js +236 -0
- package/extension/src/content/diagnosticsPanel.js +78 -19
- package/extension/src/content/diffReviewPanel.js +8 -5
- package/extension/src/content/directoryCleanupRecovery.js +54 -0
- package/extension/src/content/generated/content.bundle.js +14680 -3606
- package/extension/src/content/generated/content.bundle.meta.json +30 -3
- package/extension/src/content/globalPreferencesController.js +1 -1
- package/extension/src/content/legacyGlobalRegistry.js +25 -1
- package/extension/src/content/localSkillsPanel.js +141 -16
- package/extension/src/content/markdownDomRenderer.js +9 -4
- package/extension/src/content/markdownText.js +5 -6
- package/extension/src/content/modelPicker.js +8 -5
- package/extension/src/content/nativeCompatibilityController.js +45 -20
- package/extension/src/content/otWarmMirror.js +4 -5
- package/extension/src/content/otWarmMirrorController.js +17 -20
- package/extension/src/content/pageBridgeClient.js +33 -5
- package/extension/src/content/panelMaintenance.js +87 -132
- package/extension/src/content/panelRenderer.js +10 -0
- package/extension/src/content/pendingInputView.js +109 -76
- package/extension/src/content/projectProviderSelection.js +13 -4
- package/extension/src/content/projectSessionCleanup.js +109 -62
- package/extension/src/content/projectSettingsCoordinator.js +39 -2
- package/extension/src/content/providerSettingsCoordinator.js +63 -14
- package/extension/src/content/providerSettingsDialog.js +724 -113
- package/extension/src/content/recentProjects.js +21 -6
- package/extension/src/content/runActivitySummary.js +665 -0
- package/extension/src/content/runCompletionMeta.js +344 -0
- package/extension/src/content/runController.js +40 -15
- package/extension/src/content/runFailureNotice.js +34 -12
- package/extension/src/content/runGuidanceController.js +76 -30
- package/extension/src/content/runGuidanceView.js +59 -10
- package/extension/src/content/runPresence.js +306 -0
- package/extension/src/content/runQueueScheduler.js +150 -43
- package/extension/src/content/runRecoveryActions.js +146 -0
- package/extension/src/content/runResultActions.js +11 -8
- package/extension/src/content/runReviewController.js +574 -0
- package/extension/src/content/runScrollLayout.js +21 -2
- package/extension/src/content/runTimelineView.js +315 -290
- package/extension/src/content/scopedPersistencePanelState.js +51 -6
- package/extension/src/content/selectionContextView.js +300 -0
- package/extension/src/content/sensitivePreflight.js +140 -0
- package/extension/src/content/sessionForkController.js +80 -17
- package/extension/src/content/sessionManager.js +1 -1
- package/extension/src/content/sessionPersistence.js +6 -1
- package/extension/src/content/settingsPanel.js +84 -55
- package/extension/src/content/settingsWorkbench.js +379 -0
- package/extension/src/content/sharedSessionViewSync.js +109 -0
- package/extension/src/content/subagentActivityView.js +195 -0
- package/extension/src/content/trackedChangeCaptureController.js +7 -3
- package/extension/src/content/updateIdle.js +4 -1
- package/extension/src/content/updateNotice.js +179 -56
- package/extension/src/content/updateSafetyReceiver.js +58 -0
- package/extension/src/content/writebackController.js +308 -2
- package/extension/src/content/writebackOrchestrator.js +213 -199
- package/extension/src/content/writebackPlan.js +231 -0
- package/extension/src/content/writebackRecovery.js +122 -0
- package/extension/src/content/writingStyleSettings.js +600 -0
- package/extension/src/content/writtenChangesView.js +152 -0
- package/extension/src/page/binaryAssetUploader.js +223 -23
- package/extension/src/page/fileMover.js +256 -0
- package/extension/src/page/overleafProjectSnapshot.js +1 -0
- package/extension/src/page/ownedDirectoryCleanup.js +94 -0
- package/extension/src/page/referenceProjects.js +149 -0
- package/extension/src/page/reviewContext.js +113 -0
- package/extension/src/page/saveState.js +20 -6
- package/extension/src/page/snapshotRouter.js +124 -48
- package/extension/src/page/textCoordinates.js +102 -0
- package/extension/src/page/textFileCreator.js +442 -71
- package/extension/src/page/trackedChangeCapture.js +53 -57
- package/extension/src/page/trackedChangeOwnership.js +216 -0
- package/extension/src/page/trackedChangeReplay.js +184 -0
- package/extension/src/page/trackedChangesLifecycle.js +343 -339
- package/extension/src/page/treeOperations.js +33 -12
- package/extension/src/page/updateSafetyProbe.js +41 -0
- package/extension/src/page/writebackReceiptJournal.js +114 -0
- package/extension/src/page/writebackRouter.js +242 -201
- package/extension/src/pageBridge.js +73 -102
- package/extension/src/popup.js +261 -65
- package/extension/src/shared/agentTranscript.js +41 -4
- package/extension/src/shared/auditRecords.js +73 -0
- package/extension/src/shared/changeHistoryModel.js +94 -0
- package/extension/src/shared/compatibility.js +22 -6
- package/extension/src/shared/compileAdapter.js +101 -37
- package/extension/src/shared/composerAttachmentDraft.js +151 -0
- package/extension/src/shared/directoryCleanupProof.js +43 -0
- package/extension/src/shared/failureReasons.js +329 -3
- package/extension/src/shared/globalPreferences.js +31 -14
- package/extension/src/shared/governanceRules.js +4 -37
- package/extension/src/shared/i18n.js +389 -25
- package/extension/src/shared/managedUpdateProjection.js +8 -5
- package/extension/src/shared/nativeRequestIdentity.js +1 -0
- package/extension/src/shared/pageRpcContract.js +9 -2
- package/extension/src/shared/projectFiles.js +21 -44
- package/extension/src/shared/providerProfiles.js +114 -3
- package/extension/src/shared/runActivityModel.js +361 -0
- package/extension/src/shared/runExecutionSnapshot.js +8 -2
- package/extension/src/shared/runExecutionSnapshotCodec.js +16 -4
- package/extension/src/shared/runInputQueue.js +48 -5
- package/extension/src/shared/scopedPersistenceBrowserAdapter.js +6 -3
- package/extension/src/shared/selectionContext.js +37 -0
- package/extension/src/shared/sessionState.js +166 -30
- package/extension/src/shared/settlementFacts.js +10 -2
- package/extension/src/shared/sharedSessionBridge.js +311 -0
- package/extension/src/shared/sharedSessionTransfer.js +140 -0
- package/extension/src/shared/staleGuard.js +118 -13
- package/extension/src/shared/storageDb.js +77 -78
- package/extension/src/shared/storageMigration.js +74 -111
- package/extension/src/shared/storageRunActions.js +211 -22
- package/extension/src/shared/storageValuePruning.js +40 -0
- package/extension/src/shared/subagentActivityModel.js +174 -0
- package/extension/src/shared/undoOperations.js +216 -6
- package/extension/src/shared/updateConsent.js +42 -11
- package/extension/src/shared/updateRuntimeIdentity.js +1 -1
- package/extension/src/shared/writebackIntent.js +78 -0
- package/extension/src/shared/writebackOperationEvidence.js +4 -15
- package/extension/src/shared/writebackSettlement.js +67 -48
- package/extension/src/shared/writingStyle.js +33 -0
- package/extension/styles/panel.css +1987 -385
- package/extension/styles/popup.css +110 -0
- package/native-host/src/anthropicBridgeRequest.js +6 -3
- package/native-host/src/anthropicBridgeResponse.js +6 -2
- package/native-host/src/anthropicMessagesBridge.js +24 -16
- package/native-host/src/bootstrapMigration.js +296 -0
- package/native-host/src/bootstrapMigrationContract.js +101 -0
- package/native-host/src/bootstrapUpdate.js +233 -0
- package/native-host/src/bootstrapUpdateWatchdog.js +44 -0
- package/native-host/src/chatBridgeResponse.js +10 -0
- package/native-host/src/chatCompletionsBridge.js +21 -15
- package/native-host/src/codexConfigPaths.js +106 -0
- package/native-host/src/codexHome.js +66 -73
- package/native-host/src/codexHomeScope.js +124 -0
- package/native-host/src/codexInheritedAuth.js +90 -0
- package/native-host/src/codexLocalSkills.js +301 -0
- package/native-host/src/codexModelRecovery.js +107 -0
- package/native-host/src/codexPromptAssembly.js +33 -12
- package/native-host/src/codexProviderLaunch.js +3 -3
- package/native-host/src/codexProviderTest.js +24 -26
- package/native-host/src/codexRuntimeIdentity.js +1 -0
- package/native-host/src/codexSessionRunner.js +211 -318
- package/native-host/src/codexSessionTiming.js +21 -8
- package/native-host/src/codexSkillIsolation.js +170 -0
- package/native-host/src/codexThreadFork.js +19 -3
- package/native-host/src/index.js +19 -7
- package/native-host/src/managedInstall.js +115 -39
- package/native-host/src/managedInstallRecovery.js +140 -0
- package/native-host/src/managedRuntimeEvidence.js +57 -0
- package/native-host/src/mirrorWorkspace.js +92 -22
- package/native-host/src/nativeDoctor.js +15 -0
- package/native-host/src/nativeEnvironment.js +70 -0
- package/native-host/src/nativeHelperLifecycle.js +21 -0
- package/native-host/src/nativeHostRegistration.js +33 -0
- package/native-host/src/nativeQuotas.js +15 -8
- package/native-host/src/nativeRunLifecycle.js +71 -0
- package/native-host/src/overleafWorkspaceRules.js +16 -0
- package/native-host/src/processStopBarrier.js +115 -0
- package/native-host/src/projectPathPlatform.js +30 -0
- package/native-host/src/providerHttp.js +80 -0
- package/native-host/src/providerModelCatalog.js +4 -3
- package/native-host/src/providerProfile.js +17 -3
- package/native-host/src/providerReasoning.js +10 -11
- package/native-host/src/providerRuntime.js +1 -0
- package/native-host/src/providerStore.js +76 -14
- package/native-host/src/releaseTransport.js +14 -5
- package/native-host/src/responsesPassthroughBridge.js +266 -52
- package/native-host/src/runtimeInstaller.js +21 -1
- package/native-host/src/selectionScope.js +86 -0
- package/native-host/src/skills/parallel-subagents/SKILL.md +31 -3
- package/native-host/src/skills/writing-style-builder/SKILL.md +146 -0
- package/native-host/src/subagentAdmission.js +26 -0
- package/native-host/src/subagentBroker.js +176 -159
- package/native-host/src/subagentTelemetry.js +325 -0
- package/native-host/src/subagentWorkspace.js +103 -0
- package/native-host/src/subagentWorkspacePath.js +34 -0
- package/native-host/src/taskRunnerRuntime.js +130 -57
- package/native-host/src/tomlStatements.js +140 -0
- package/native-host/src/turnAttachments.js +113 -0
- package/native-host/src/updateManager.js +406 -38
- package/native-host/src/updateNetworkControl.js +75 -0
- package/native-host/src/updateTrust.js +21 -2
- package/native-host/src/vendor/pdfjs/LICENSE +177 -0
- package/native-host/src/vendor/pdfjs/SOURCE.txt +3 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/native-host/src/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
- package/native-host/src/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/LICENSE +36 -0
- package/native-host/src/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/native-host/src/vendor/pdfjs/pdf.mjs +26740 -0
- package/native-host/src/vendor/pdfjs/pdf.worker.mjs +62201 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +102 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/native-host/src/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/native-host/src/writingStyleEvidence.js +102 -0
- package/native-host/src/writingStylePdfWorker.js +35 -0
- package/native-host/src/writingStyleProfile.js +165 -0
- package/native-host/src/writingStyleRuntime.js +475 -0
- package/native-host/src/writingStyleStore.js +73 -0
- package/package.json +1 -1
- package/scripts/install-managed.mjs +1 -0
|
@@ -15,11 +15,13 @@
|
|
|
15
15
|
return JSON.parse(JSON.stringify(value));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async function applyReviewTransition({ getState, runId, transition, persist }) {
|
|
18
|
+
async function applyReviewTransition({ getState, runId, transition, persist, legacyUndo = false, assertCurrent }) {
|
|
19
19
|
const targets = () => Array.from(new Set([
|
|
20
20
|
...(getState().runs || []),
|
|
21
21
|
...(getState().sessions || []).flatMap(session => session.runs || [])
|
|
22
22
|
])).filter(run => run.id === runId);
|
|
23
|
+
assertCurrent?.();
|
|
24
|
+
const capturedState = getState(), capturedSessionId = capturedState.activeSessionId;
|
|
23
25
|
const records = targets();
|
|
24
26
|
const sessions = (getState().sessions || []).filter(session =>
|
|
25
27
|
(session.runs || []).some(run => run.id === runId));
|
|
@@ -31,12 +33,19 @@
|
|
|
31
33
|
(Date.parse(session.lastActivityAt) || 0) + 1)).toISOString();
|
|
32
34
|
session.lastActivityAt = session.updatedAt;
|
|
33
35
|
}
|
|
36
|
+
const staged = records.map(record => JSON.stringify(record));
|
|
34
37
|
try {
|
|
35
|
-
await persist({ preserveRunActionPayload: true, reviewRunIds: [runId] });
|
|
38
|
+
await persist({ preserveRunActionPayload: true, reviewRunIds: [runId], requireDurable: true });
|
|
39
|
+
assertCurrent?.();
|
|
40
|
+
if (getState() !== capturedState || getState().activeSessionId !== capturedSessionId
|
|
41
|
+
|| records.some(record => !targets().includes(record))) throw reviewPersistenceError();
|
|
36
42
|
} catch (error) {
|
|
43
|
+
try { assertCurrent?.(); } catch (_stale) { throw error; }
|
|
37
44
|
// The remote action may have succeeded. Keep its recovery data and expose uncertainty.
|
|
38
|
-
for (const record of
|
|
39
|
-
|
|
45
|
+
for (const record of records) {
|
|
46
|
+
if (getState() !== capturedState || !targets().includes(record)
|
|
47
|
+
|| JSON.stringify(record) !== staged[records.indexOf(record)]) continue;
|
|
48
|
+
Object.assign(record, cloneSnapshot(previous), legacyUndo ? { undoStatus: 'partial' } : { trackedChangeStatus: 'needs_review' });
|
|
40
49
|
for (const field of ['settlement', 'settlementFacts']) {
|
|
41
50
|
if (!Object.prototype.hasOwnProperty.call(previous, field)) delete record[field];
|
|
42
51
|
}
|
|
@@ -51,6 +60,28 @@
|
|
|
51
60
|
});
|
|
52
61
|
}
|
|
53
62
|
|
|
63
|
+
function verifyRecoveredRuns(recoveredRuns, proposed, written) {
|
|
64
|
+
for (var target of recoveredRuns || []) {
|
|
65
|
+
var expectedSession = proposed.find(session => session.id === target.sessionId);
|
|
66
|
+
var storedSession = (written || []).find(session => session.id === target.sessionId
|
|
67
|
+
&& session.projectId === expectedSession?.projectId
|
|
68
|
+
&& session.accountScopeId === expectedSession?.accountScopeId);
|
|
69
|
+
var expected = expectedSession?.runs?.find(run => run.id === target.runId);
|
|
70
|
+
var stored = storedSession?.runs?.find(run => run.id === target.runId);
|
|
71
|
+
var retained = expected && stored
|
|
72
|
+
&& expected.runProjectId === target.projectId && stored.runProjectId === target.projectId
|
|
73
|
+
&& Number(stored.nativeEventSeq || 0) >= Number(expected.nativeEventSeq || 0)
|
|
74
|
+
&& stored.codexThreadId === expected.codexThreadId
|
|
75
|
+
&& stored.codexTurnId === expected.codexTurnId
|
|
76
|
+
&& JSON.stringify(stored.interruptedDraft) === JSON.stringify(expected.interruptedDraft)
|
|
77
|
+
&& (expected.events || []).every(event => (stored.events || [])
|
|
78
|
+
.some(saved => JSON.stringify(saved) === JSON.stringify(event)));
|
|
79
|
+
if (!retained) throw Object.assign(new Error('Recovered run was not durably saved; its replay journal is retained.'), {
|
|
80
|
+
code: 'recovery_state_not_persisted'
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
54
85
|
async function persistPanelState(input) {
|
|
55
86
|
var state = cloneSnapshot(input.state || {});
|
|
56
87
|
var compactState = cloneSnapshot(input.compactState || {});
|
|
@@ -71,6 +102,12 @@
|
|
|
71
102
|
code: 'stale_view'
|
|
72
103
|
});
|
|
73
104
|
}
|
|
105
|
+
if ((input.recoveryRuns || []).some(target => target.projectId !== projectId
|
|
106
|
+
|| target.accountScopeId !== accountScopeId)) {
|
|
107
|
+
throw Object.assign(new Error('Journal recovery scope changed before persistence.'), {
|
|
108
|
+
code: 'recovery_scope_changed'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
74
111
|
var reviewRuns = (input.reviewRunIds || []).map(id =>
|
|
75
112
|
(state.sessions || []).flatMap(session => session.runs || []).find(run => run.id === id));
|
|
76
113
|
if (reviewRuns.some(run => !run)) throw reviewPersistenceError();
|
|
@@ -129,10 +166,11 @@
|
|
|
129
166
|
focusFiles: Array.isArray(session.focusFiles) ? session.focusFiles : [],
|
|
130
167
|
createdAt: session.createdAt,
|
|
131
168
|
updatedAt: session.updatedAt,
|
|
132
|
-
|
|
169
|
+
pendingInputs: (Array.isArray(session.pendingInputs) ? session.pendingInputs : [])
|
|
133
170
|
.filter(function (item) { return !queueTombstones[item?.id]; })
|
|
134
171
|
}), { preserveRunActionPayload: true });
|
|
135
172
|
});
|
|
173
|
+
sessionRecords = StorageDb.compactSessionBatchActions?.(sessionRecords, { activeSessionId: state.activeSessionId }) || sessionRecords;
|
|
136
174
|
var written = await input.SessionPersistence.writeSessions({
|
|
137
175
|
Migration: Migration,
|
|
138
176
|
StorageDb: StorageDb,
|
|
@@ -146,8 +184,15 @@
|
|
|
146
184
|
writerId: input.persistenceContext?.writerId || ''
|
|
147
185
|
});
|
|
148
186
|
if (!reviewRuns.every(reviewRun => (written || []).some(session => (session.runs || []).some(run =>
|
|
149
|
-
run.id === reviewRun.id
|
|
187
|
+
run.id === reviewRun.id
|
|
188
|
+
&& (!reviewRun.trackedChangeStatus && ['applied', 'partial'].includes(reviewRun.undoStatus)
|
|
189
|
+
? run.undoStatus === reviewRun.undoStatus && (reviewRun.undoStatus === 'applied'
|
|
190
|
+
|| ['undoOperations', 'undoBaseFiles', 'undoExpectedFiles', 'undoTrackedChanges']
|
|
191
|
+
.every(field => JSON.stringify(run[field] || []) === JSON.stringify(reviewRun[field] || [])))
|
|
192
|
+
: run.trackedChangeStatus === reviewRun.trackedChangeStatus)
|
|
150
193
|
)))) throw reviewPersistenceError();
|
|
194
|
+
verifyRecoveredRuns(input.recoveryRuns, sessionRecords, written);
|
|
195
|
+
return written;
|
|
151
196
|
}
|
|
152
197
|
|
|
153
198
|
return Object.freeze({ persistPanelState: persistPanelState, applyReviewTransition: applyReviewTransition });
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
(function (root, factory) {
|
|
2
|
+
if (typeof module === 'object' && module.exports) module.exports = factory(require('../shared/selectionContext'));
|
|
3
|
+
else root.CodexOverleafModuleRegistry.define('SelectionContextView', ['SelectionContext'], factory);
|
|
4
|
+
})(typeof globalThis !== 'undefined' ? globalThis : window, function (SelectionContext) {
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
// The chip shared by the composer and sent messages: file:lines, the edit-only
|
|
8
|
+
// scope label, and the selected text behind a disclosure.
|
|
9
|
+
function buildChip(selection, { document: doc = globalThis.document, tx = en => en, expanded = false } = {}) {
|
|
10
|
+
const lines = selection.lineStart === selection.lineEnd
|
|
11
|
+
? String(selection.lineStart) : selection.lineStart + '-' + selection.lineEnd;
|
|
12
|
+
const location = selection.path + ':' + lines;
|
|
13
|
+
const details = doc.createElement('details');
|
|
14
|
+
details.open = expanded;
|
|
15
|
+
const summary = doc.createElement('summary');
|
|
16
|
+
summary.title = location;
|
|
17
|
+
summary.setAttribute('aria-label', tx('Preview selection from ' + location, '预览选区:' + location));
|
|
18
|
+
const file = doc.createElement('span');
|
|
19
|
+
file.className = 'codex-selection-file';
|
|
20
|
+
file.textContent = selection.path.split('/').pop();
|
|
21
|
+
const range = doc.createElement('span');
|
|
22
|
+
range.className = 'codex-selection-range';
|
|
23
|
+
range.textContent = ':' + lines;
|
|
24
|
+
summary.append(file, range);
|
|
25
|
+
if (selection.mode === 'edit') {
|
|
26
|
+
const scope = doc.createElement('span');
|
|
27
|
+
scope.className = 'codex-selection-scope';
|
|
28
|
+
scope.textContent = tx('Selection only', '仅此处');
|
|
29
|
+
summary.append(scope);
|
|
30
|
+
}
|
|
31
|
+
const source = doc.createElement('pre');
|
|
32
|
+
source.textContent = selection.text;
|
|
33
|
+
details.append(summary, source);
|
|
34
|
+
return details;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Read-only chip for a sent message: the selection travels with the run's
|
|
38
|
+
// execution snapshot, so the bubble keeps showing what was attached.
|
|
39
|
+
function renderSent(host, value, options = {}) {
|
|
40
|
+
if (!host) return;
|
|
41
|
+
const selection = SelectionContext.normalize(value);
|
|
42
|
+
host.replaceChildren();
|
|
43
|
+
host.hidden = !selection;
|
|
44
|
+
if (selection) host.append(buildChip(selection, options));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function create(deps = {}) {
|
|
48
|
+
let generation = 0;
|
|
49
|
+
let probeGeneration = 0;
|
|
50
|
+
let timer = null;
|
|
51
|
+
let controller = null;
|
|
52
|
+
let toolbar = null;
|
|
53
|
+
let candidate = null;
|
|
54
|
+
let pointerSelecting = false;
|
|
55
|
+
let pointerEditor = null;
|
|
56
|
+
const resetEvent = 'codex-overleaf-selection-ui-reset';
|
|
57
|
+
const tx = (en, zh) => deps.tx ? deps.tx(en, zh) : en;
|
|
58
|
+
|
|
59
|
+
function capture() {
|
|
60
|
+
const selection = SelectionContext.normalize(deps.getState()?.selectionContext);
|
|
61
|
+
return selection?.projectId === deps.getProjectId() ? selection : null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function clear() {
|
|
65
|
+
generation += 1;
|
|
66
|
+
hideFloating();
|
|
67
|
+
deps.setSelection(null);
|
|
68
|
+
render();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function render() {
|
|
72
|
+
const panel = deps.getPanel();
|
|
73
|
+
if (toolbar && !toolbar.hidden) syncFloatingAppearance();
|
|
74
|
+
const host = panel?.querySelector('[data-composer-selection]');
|
|
75
|
+
if (!host) return;
|
|
76
|
+
const selection = capture();
|
|
77
|
+
const id = selection ? [selection.projectId, selection.path, selection.from, selection.to,
|
|
78
|
+
selection.documentHash, selection.capturedAt, selection.mode].join(':') : '';
|
|
79
|
+
const expanded = Boolean(id && host.dataset.selectionId === id && host.querySelector('details')?.open);
|
|
80
|
+
host.replaceChildren();
|
|
81
|
+
host.dataset.selectionId = id;
|
|
82
|
+
host.hidden = !selection;
|
|
83
|
+
if (!selection) return;
|
|
84
|
+
|
|
85
|
+
host.append(buildChip(selection, { document, tx, expanded }));
|
|
86
|
+
const remove = document.createElement('button');
|
|
87
|
+
remove.type = 'button';
|
|
88
|
+
remove.textContent = '\u00d7';
|
|
89
|
+
remove.title = tx('Remove selection', '移除选区');
|
|
90
|
+
remove.setAttribute('aria-label', remove.title);
|
|
91
|
+
remove.addEventListener('click', clear);
|
|
92
|
+
host.append(remove);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function attach(mode = 'reference', selected = null) {
|
|
96
|
+
const request = ++generation;
|
|
97
|
+
const projectId = deps.getProjectId();
|
|
98
|
+
const sessionId = deps.getState()?.activeSessionId;
|
|
99
|
+
if (selected && (selected.projectId !== projectId || selected.sessionId !== sessionId)) return null;
|
|
100
|
+
hideFloating();
|
|
101
|
+
try {
|
|
102
|
+
const response = selected
|
|
103
|
+
? { ok: true, selection: selected.selection }
|
|
104
|
+
: await deps.callPageBridge('getSelectionContext', { runProjectId: projectId });
|
|
105
|
+
if (request !== generation || projectId !== deps.getProjectId()
|
|
106
|
+
|| sessionId !== deps.getState()?.activeSessionId) return null;
|
|
107
|
+
const selection = SelectionContext.normalize({
|
|
108
|
+
...(response?.selection || response), mode: mode === 'edit' ? 'edit' : 'reference'
|
|
109
|
+
});
|
|
110
|
+
if (response?.ok !== true || !selection || selection.projectId !== projectId) {
|
|
111
|
+
deps.toast?.(response?.code === 'selection_too_large'
|
|
112
|
+
? tx('Select a shorter passage (up to 20,000 characters).', '请选择较短的片段,最多 20,000 个字符。')
|
|
113
|
+
: tx('Select text in the source editor first.', '请先在源码编辑器中选中文字。'));
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
await deps.openComposer?.();
|
|
117
|
+
if (request !== generation || projectId !== deps.getProjectId()
|
|
118
|
+
|| sessionId !== deps.getState()?.activeSessionId) return null;
|
|
119
|
+
deps.setSelection(selection, { edit: selection.mode === 'edit' });
|
|
120
|
+
render();
|
|
121
|
+
const panel = deps.getPanel();
|
|
122
|
+
const tray = panel?.querySelector('[data-context-tray]');
|
|
123
|
+
if (tray) tray.hidden = true;
|
|
124
|
+
panel?.querySelector('[data-add-context]')?.setAttribute('aria-expanded', 'false');
|
|
125
|
+
panel?.querySelector('[data-task]')?.focus();
|
|
126
|
+
return selection;
|
|
127
|
+
} catch (_) {
|
|
128
|
+
if (request === generation && projectId === deps.getProjectId()
|
|
129
|
+
&& sessionId === deps.getState()?.activeSessionId) {
|
|
130
|
+
deps.toast?.(tx('Could not attach the selection. Select it again and retry.', '未能添加选区,请重新选取后再试。'));
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function editorFor(node) {
|
|
137
|
+
const element = node?.nodeType === 1 ? node : node?.parentElement;
|
|
138
|
+
const editor = element?.closest?.('.cm-editor');
|
|
139
|
+
return editor && !editor.closest('#codex-overleaf-panel') ? editor : null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function hideFloating() {
|
|
143
|
+
probeGeneration += 1;
|
|
144
|
+
clearTimeout(timer);
|
|
145
|
+
timer = null;
|
|
146
|
+
candidate = null;
|
|
147
|
+
if (!toolbar) return;
|
|
148
|
+
if (typeof toolbar.hidePopover === 'function' && toolbar.matches(':popover-open')) toolbar.hidePopover();
|
|
149
|
+
toolbar.hidden = true;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function syncFloatingAppearance() {
|
|
153
|
+
if (!toolbar) return;
|
|
154
|
+
const panel = deps.getPanel();
|
|
155
|
+
const computed = panel ? window.getComputedStyle(panel) : null;
|
|
156
|
+
const theme = deps.getState()?.theme;
|
|
157
|
+
const dark = theme === 'dark' || (theme !== 'light' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
158
|
+
const colors = dark
|
|
159
|
+
? ['#26282b', '#f1f2f4', '#adb4be', '#454b53', '#353a41', '#91b7e1']
|
|
160
|
+
: ['#ffffff', '#24292f', '#67717e', '#d8dde3', '#f0f3f6', '#2f73b8'];
|
|
161
|
+
['--tl-surface-0', '--tl-fg-1', '--tl-fg-3', '--tl-border-strong', '--tl-hover', '--tl-accent']
|
|
162
|
+
.forEach((name, index) => toolbar.style.setProperty(name, computed?.getPropertyValue(name).trim() || colors[index]));
|
|
163
|
+
if (computed?.fontFamily) toolbar.style.fontFamily = computed.fontFamily;
|
|
164
|
+
toolbar.setAttribute('aria-label', tx('Selected text actions', '选区操作'));
|
|
165
|
+
toolbar.querySelector('[data-selection-action="reference"]').textContent = tx('Add to Chat', '加入对话');
|
|
166
|
+
toolbar.querySelector('[data-selection-action="edit"]').textContent = tx('Edit Selection', '仅编辑此处');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function ensureToolbar() {
|
|
170
|
+
if (toolbar) return;
|
|
171
|
+
toolbar = document.createElement('div');
|
|
172
|
+
toolbar.className = 'codex-selection-actions';
|
|
173
|
+
toolbar.setAttribute('data-codex-selection-actions', '');
|
|
174
|
+
toolbar.setAttribute('role', 'toolbar');
|
|
175
|
+
toolbar.hidden = true;
|
|
176
|
+
if (typeof toolbar.showPopover === 'function') toolbar.setAttribute('popover', 'manual');
|
|
177
|
+
for (const mode of ['reference', 'edit']) {
|
|
178
|
+
if (mode === 'edit') {
|
|
179
|
+
const divider = document.createElement('span');
|
|
180
|
+
divider.className = 'codex-selection-action-divider';
|
|
181
|
+
divider.setAttribute('aria-hidden', 'true');
|
|
182
|
+
toolbar.append(divider);
|
|
183
|
+
}
|
|
184
|
+
const button = document.createElement('button');
|
|
185
|
+
button.type = 'button';
|
|
186
|
+
button.dataset.selectionAction = mode;
|
|
187
|
+
button.addEventListener('click', () => {
|
|
188
|
+
const selected = candidate;
|
|
189
|
+
if (selected) void attach(mode, selected);
|
|
190
|
+
});
|
|
191
|
+
toolbar.append(button);
|
|
192
|
+
}
|
|
193
|
+
document.body.append(toolbar);
|
|
194
|
+
syncFloatingAppearance();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function showFloating(anchor) {
|
|
198
|
+
ensureToolbar();
|
|
199
|
+
syncFloatingAppearance();
|
|
200
|
+
toolbar.hidden = false;
|
|
201
|
+
if (typeof toolbar.showPopover === 'function' && !toolbar.matches(':popover-open')) toolbar.showPopover();
|
|
202
|
+
const rect = toolbar.getBoundingClientRect();
|
|
203
|
+
const width = window.innerWidth, height = window.innerHeight;
|
|
204
|
+
const left = Math.max(8, Math.min(width - rect.width - 8,
|
|
205
|
+
(anchor.left + anchor.right) / 2 - rect.width / 2));
|
|
206
|
+
const preferredTop = anchor.top - rect.height - 8;
|
|
207
|
+
const top = Math.max(8, Math.min(height - rect.height - 8,
|
|
208
|
+
preferredTop >= 8 ? preferredTop : anchor.bottom + 8));
|
|
209
|
+
toolbar.style.left = left + 'px';
|
|
210
|
+
toolbar.style.top = top + 'px';
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function schedule(editor) {
|
|
214
|
+
hideFloating();
|
|
215
|
+
if (!controller || pointerSelecting || !editor) return;
|
|
216
|
+
const request = ++probeGeneration;
|
|
217
|
+
timer = setTimeout(() => { timer = null; void probe(editor, request); }, 90);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async function probe(editor, request) {
|
|
221
|
+
if (!controller || request !== probeGeneration || document.hidden
|
|
222
|
+
|| !editor.isConnected || !editor.contains(document.activeElement)) return;
|
|
223
|
+
const projectId = deps.getProjectId();
|
|
224
|
+
const sessionId = deps.getState()?.activeSessionId;
|
|
225
|
+
try {
|
|
226
|
+
const response = await deps.callPageBridge('getSelectionContext', { runProjectId: projectId });
|
|
227
|
+
if (request !== probeGeneration || projectId !== deps.getProjectId()
|
|
228
|
+
|| sessionId !== deps.getState()?.activeSessionId || !editor.isConnected
|
|
229
|
+
|| !editor.contains(document.activeElement)) return;
|
|
230
|
+
const selection = SelectionContext.normalize(response?.selection || response);
|
|
231
|
+
const anchor = response?.anchor;
|
|
232
|
+
if (!response?.ok || !selection || selection.projectId !== projectId || !anchor
|
|
233
|
+
|| !['left', 'right', 'top', 'bottom'].every(key => Number.isFinite(anchor[key]))
|
|
234
|
+
|| anchor.bottom < 0 || anchor.top > window.innerHeight) return;
|
|
235
|
+
candidate = { selection, anchor, projectId, sessionId };
|
|
236
|
+
showFloating(anchor);
|
|
237
|
+
} catch (_) { /* Transient editor states do not interrupt ordinary selection. */ }
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function start() {
|
|
241
|
+
if (controller) return;
|
|
242
|
+
// Replacing a content runtime retires the old selection listener set.
|
|
243
|
+
document.dispatchEvent(new Event(resetEvent));
|
|
244
|
+
controller = new AbortController();
|
|
245
|
+
const options = { capture: true, signal: controller.signal };
|
|
246
|
+
document.addEventListener(resetEvent, destroy, options);
|
|
247
|
+
document.addEventListener('pointerdown', event => {
|
|
248
|
+
if (toolbar?.contains(event.target)) {
|
|
249
|
+
if (event.button === 0) event.preventDefault();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
hideFloating();
|
|
253
|
+
pointerEditor = editorFor(event.target);
|
|
254
|
+
pointerSelecting = Boolean(pointerEditor && event.button === 0);
|
|
255
|
+
}, options);
|
|
256
|
+
document.addEventListener('pointerup', () => {
|
|
257
|
+
if (!pointerSelecting) return;
|
|
258
|
+
pointerSelecting = false;
|
|
259
|
+
const editor = pointerEditor;
|
|
260
|
+
pointerEditor = null;
|
|
261
|
+
schedule(editor);
|
|
262
|
+
}, options);
|
|
263
|
+
document.addEventListener('pointercancel', () => {
|
|
264
|
+
pointerSelecting = false;
|
|
265
|
+
pointerEditor = null;
|
|
266
|
+
hideFloating();
|
|
267
|
+
}, options);
|
|
268
|
+
document.addEventListener('selectionchange', () => {
|
|
269
|
+
if (pointerSelecting || toolbar?.contains(document.activeElement)) return;
|
|
270
|
+
schedule(editorFor(document.activeElement));
|
|
271
|
+
}, options);
|
|
272
|
+
document.addEventListener('keyup', event => {
|
|
273
|
+
if (event.key !== 'Escape' && editorFor(event.target)) schedule(editorFor(event.target));
|
|
274
|
+
}, options);
|
|
275
|
+
document.addEventListener('keydown', event => {
|
|
276
|
+
if (event.key === 'Escape') hideFloating();
|
|
277
|
+
}, options);
|
|
278
|
+
document.addEventListener('scroll', hideFloating, { ...options, passive: true });
|
|
279
|
+
document.addEventListener('visibilitychange', () => { if (document.hidden) hideFloating(); }, options);
|
|
280
|
+
window.addEventListener('resize', hideFloating, { ...options, passive: true });
|
|
281
|
+
window.addEventListener('blur', hideFloating, options);
|
|
282
|
+
window.addEventListener('pagehide', event => { if (event.persisted) hideFloating(); else destroy(); }, options);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function destroy() {
|
|
286
|
+
generation += 1;
|
|
287
|
+
hideFloating();
|
|
288
|
+
controller?.abort();
|
|
289
|
+
controller = null;
|
|
290
|
+
pointerSelecting = false;
|
|
291
|
+
pointerEditor = null;
|
|
292
|
+
toolbar?.remove();
|
|
293
|
+
toolbar = null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return { attach, capture, clear, render, start, destroy, getRevision: () => generation };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return { create, buildChip, renderSent };
|
|
300
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
(function initCodexOverleafSensitivePreflight(root, factory) {
|
|
2
|
+
if (typeof module === 'object' && module.exports) {
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
} else {
|
|
5
|
+
root.CodexOverleafSensitivePreflight = factory();
|
|
6
|
+
}
|
|
7
|
+
})(typeof window !== 'undefined' ? window : globalThis, function sensitivePreflightFactory() {
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
function create({
|
|
11
|
+
SensitiveScan, normalizeGovernanceRules, isTextSnapshotFile, sendBackgroundNative,
|
|
12
|
+
getCurrentProjectId, appendRunEvent, appendCompletionReport, showPluginConfirm, tr, tx
|
|
13
|
+
}) {
|
|
14
|
+
async function runSensitivePreflight(options) {
|
|
15
|
+
options = options || {};
|
|
16
|
+
const { task, project, rules, useExistingMirror = false, guidance = false } = options;
|
|
17
|
+
const normalizedRules = normalizeGovernanceRules(rules);
|
|
18
|
+
if (normalizedRules.sensitiveCheckEnabled === false) {
|
|
19
|
+
return { blocked: false, findings: [] };
|
|
20
|
+
}
|
|
21
|
+
if (!SensitiveScan?.scanSensitiveInputs && !useExistingMirror) {
|
|
22
|
+
return { blocked: false, findings: [] };
|
|
23
|
+
}
|
|
24
|
+
let findings = SensitiveScan?.scanSensitiveInputs
|
|
25
|
+
? SensitiveScan.scanSensitiveInputs({
|
|
26
|
+
task,
|
|
27
|
+
files: guidance ? [] : (project?.files || []).filter(isTextSnapshotFile)
|
|
28
|
+
})
|
|
29
|
+
: [];
|
|
30
|
+
if (useExistingMirror && !guidance) {
|
|
31
|
+
findings = dedupeSensitiveFindings([
|
|
32
|
+
...findings,
|
|
33
|
+
...await scanNativeMirrorSensitiveFindings()
|
|
34
|
+
]);
|
|
35
|
+
}
|
|
36
|
+
if (!findings.length) {
|
|
37
|
+
return { blocked: false, findings: [] };
|
|
38
|
+
}
|
|
39
|
+
options.assertCurrent?.();
|
|
40
|
+
appendRunEvent({
|
|
41
|
+
title: tx(
|
|
42
|
+
`Sensitive content check found ${findings.length} item(s).`,
|
|
43
|
+
`敏感内容检查发现 ${findings.length} 项。`
|
|
44
|
+
),
|
|
45
|
+
status: 'failed',
|
|
46
|
+
detail: findings.slice(0, 8).map(finding => ({
|
|
47
|
+
[tr('detailFile')]: finding.path || finding.source || 'task',
|
|
48
|
+
[tr('detailReason')]: finding.detectorId,
|
|
49
|
+
[tx('Preview', '预览')]: finding.preview || '[REDACTED]'
|
|
50
|
+
}))
|
|
51
|
+
});
|
|
52
|
+
if (normalizedRules.sensitiveConfirmAllowed === true) {
|
|
53
|
+
const approved = await showPluginConfirm({
|
|
54
|
+
title: tr('sensitiveConfirmTitle'),
|
|
55
|
+
message: formatSensitiveConfirmMessage(findings),
|
|
56
|
+
confirmLabel: guidance ? tx('Send guidance', '发送指导') : tr('sensitiveConfirmRun'),
|
|
57
|
+
cancelLabel: tr('confirmDefaultCancel'),
|
|
58
|
+
destructive: true
|
|
59
|
+
});
|
|
60
|
+
options.assertCurrent?.();
|
|
61
|
+
return { blocked: !approved, findings };
|
|
62
|
+
}
|
|
63
|
+
// Blocking an extra message must not finish the task already in progress.
|
|
64
|
+
if (guidance) return { blocked: true, findings };
|
|
65
|
+
appendCompletionReport({
|
|
66
|
+
conclusion: tx(
|
|
67
|
+
'This run was blocked before Codex received project context because sensitive content was detected.',
|
|
68
|
+
'检测到敏感内容,本轮已在向 Codex 发送项目上下文前阻止。'
|
|
69
|
+
),
|
|
70
|
+
status: 'blocked',
|
|
71
|
+
operations: [],
|
|
72
|
+
applyResults: [],
|
|
73
|
+
nextStep: tx(
|
|
74
|
+
'Remove the sensitive content, narrow @context, or enable explicit sensitive confirmation in Project Settings.',
|
|
75
|
+
'请移除敏感内容、缩小 @context,或在项目设置里允许敏感内容显式确认。'
|
|
76
|
+
)
|
|
77
|
+
});
|
|
78
|
+
return { blocked: true, findings };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function formatSensitiveConfirmMessage(findings = []) {
|
|
82
|
+
const visible = findings.slice(0, 8).map(finding => {
|
|
83
|
+
const path = finding.path || finding.source || 'task';
|
|
84
|
+
return `${path}: ${finding.detectorId || 'sensitive'} (${finding.preview || '[REDACTED]'})`;
|
|
85
|
+
});
|
|
86
|
+
return [
|
|
87
|
+
tr('sensitiveConfirmMessage'),
|
|
88
|
+
'',
|
|
89
|
+
...visible,
|
|
90
|
+
findings.length > visible.length ? tx(`${findings.length - visible.length} more finding(s).`, `另有 ${findings.length - visible.length} 项。`) : ''
|
|
91
|
+
].filter(Boolean).join('\n');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function scanNativeMirrorSensitiveFindings() {
|
|
95
|
+
try {
|
|
96
|
+
const response = await sendBackgroundNative({
|
|
97
|
+
method: 'mirror.scanSensitive',
|
|
98
|
+
params: { projectId: getCurrentProjectId() }
|
|
99
|
+
});
|
|
100
|
+
if (response?.ok) {
|
|
101
|
+
return Array.isArray(response.result?.findings) ? response.result.findings : [];
|
|
102
|
+
}
|
|
103
|
+
return [{
|
|
104
|
+
detectorId: 'mirror-sensitive-scan-unavailable',
|
|
105
|
+
source: 'local-mirror',
|
|
106
|
+
preview: response?.error?.message || 'Could not scan the local mirror before Codex runs.'
|
|
107
|
+
}];
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return [{
|
|
110
|
+
detectorId: 'mirror-sensitive-scan-unavailable',
|
|
111
|
+
source: 'local-mirror',
|
|
112
|
+
preview: error?.message || 'Could not scan the local mirror before Codex runs.'
|
|
113
|
+
}];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function dedupeSensitiveFindings(findings = []) {
|
|
118
|
+
const seen = new Set();
|
|
119
|
+
const deduped = [];
|
|
120
|
+
for (const finding of findings || []) {
|
|
121
|
+
const key = [
|
|
122
|
+
finding?.detectorId || '',
|
|
123
|
+
finding?.source || '',
|
|
124
|
+
finding?.path || '',
|
|
125
|
+
finding?.preview || ''
|
|
126
|
+
].join('\u0000');
|
|
127
|
+
if (seen.has(key)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
seen.add(key);
|
|
131
|
+
deduped.push(finding);
|
|
132
|
+
}
|
|
133
|
+
return deduped;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return { run: runSensitivePreflight };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return { create };
|
|
140
|
+
});
|