codex-overleaf-link 2.2.1 → 2.3.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 +25 -23
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/runtime-manifest.json +5 -71
- package/extension/src/background.js +67 -63
- package/extension/src/backgroundUpdateCoordinator.js +128 -66
- package/extension/src/content/applyResultFormatters.js +2 -3
- package/extension/src/content/composerPanel.js +0 -2
- package/extension/src/content/contentRuntime.js +757 -1558
- package/extension/src/content/contextTray.js +4 -6
- package/extension/src/content/diagnosticsController.js +1 -2
- package/extension/src/content/diffReviewPanel.js +14 -13
- package/extension/src/content/generated/content.bundle.js +41605 -0
- package/extension/src/content/generated/content.bundle.meta.json +103 -0
- package/extension/src/content/legacyGlobalRegistry.js +129 -0
- package/extension/src/content/markdownText.js +17 -17
- package/extension/src/content/mathText.js +155 -9
- package/extension/src/content/modelPicker.js +1 -1
- package/extension/src/content/modelPickerSupport.js +10 -5
- package/extension/src/content/moduleRegistryKernel.js +125 -0
- package/extension/src/content/nativeCompatibilityController.js +313 -0
- package/extension/src/content/otWarmMirror.js +8 -6
- package/extension/src/content/pageBridgeClient.js +224 -0
- package/extension/src/content/panelMaintenance.js +8 -3
- package/extension/src/content/postNavigationSettlementPersistence.js +100 -0
- package/extension/src/content/projectProviderSelection.js +4 -12
- package/extension/src/content/projectSessionCleanup.js +3 -3
- package/extension/src/content/providerSettingsCoordinator.js +59 -26
- package/extension/src/content/providerSettingsDialog.js +30 -18
- package/extension/src/content/recentProjects.js +15 -23
- package/extension/src/content/runGuidanceController.js +1 -1
- package/extension/src/content/runQueueScheduler.js +129 -29
- package/extension/src/content/runSettlementPersistence.js +51 -0
- package/extension/src/content/runTimelineView.js +17 -8
- package/extension/src/content/scopedPersistenceCoordinator.js +100 -0
- package/extension/src/content/scopedPersistenceDetachedCommit.js +47 -0
- package/extension/src/content/scopedPersistencePanelState.js +111 -0
- package/extension/src/content/sessionManager.js +15 -12
- package/extension/src/content/sessionPersistence.js +67 -8
- package/extension/src/content/updateNotice.js +10 -4
- package/extension/src/content/writebackOrchestrator.js +89 -68
- package/extension/src/contentScript.js +5 -1
- package/extension/src/page/trackedChangesLifecycle.js +16 -5
- package/extension/src/page/writebackRouter.js +6 -2
- package/extension/src/pageBridge.js +47 -98
- package/extension/src/shared/agentTranscript.js +18 -8
- package/extension/src/shared/compatibility.js +1 -1
- package/extension/src/shared/governanceRules.js +1 -1
- package/extension/src/shared/i18n.js +2 -4
- package/extension/src/shared/managedUpdateProjection.js +337 -0
- package/extension/src/shared/nativeRequestIdentity.js +60 -0
- package/extension/src/shared/otText.js +0 -19
- package/extension/src/shared/pageRpcContract.js +136 -0
- package/extension/src/shared/runExecutionSnapshot.js +187 -0
- package/extension/src/shared/runExecutionSnapshotCodec.js +171 -0
- package/extension/src/shared/runInputQueue.js +81 -34
- package/extension/src/shared/scopedPersistenceBrowserAdapter.js +79 -0
- package/extension/src/shared/scopedPersistenceQueuePolicy.js +200 -0
- package/extension/src/shared/scopedPersistenceReceipt.js +60 -0
- package/extension/src/shared/scopedPersistenceTransaction.js +241 -0
- package/extension/src/shared/sessionState.js +110 -59
- package/extension/src/shared/settlementFacts.js +351 -0
- package/extension/src/shared/storageDb.js +25 -10
- package/extension/src/shared/storageMigration.js +275 -61
- package/extension/src/shared/storageSessionClaims.js +60 -0
- package/extension/src/shared/updateConsent.js +4 -0
- package/extension/src/shared/updateRevocationIntent.js +109 -0
- package/extension/src/shared/writebackEvidenceProjection.js +150 -0
- package/extension/src/shared/writebackOperationEvidence.js +153 -0
- package/extension/src/shared/writebackSettlement.js +727 -0
- package/extension/styles/panel.css +18 -8
- package/native-host/src/codexPromptAssembly.js +1 -1
- package/native-host/src/codexRuntimeIdentity.js +1 -1
- package/native-host/src/codexSessionRunner.js +7 -13
- package/native-host/src/index.js +3 -69
- package/native-host/src/managedInstall.js +50 -8
- package/native-host/src/nativeTransportEnvelope.js +148 -0
- package/native-host/src/taskRunnerRuntime.js +14 -84
- package/native-host/src/updateManager.js +36 -1
- package/package.json +13 -5
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<h1>Codex Overleaf Link</h1>
|
|
4
4
|
<p><strong>Empower Overleaf with Codex.</strong></p>
|
|
5
5
|
<p>
|
|
6
|
-
<img src="https://img.shields.io/badge/version-2.
|
|
6
|
+
<img src="https://img.shields.io/badge/version-2.3.1-blue" alt="version">
|
|
7
7
|
<img src="https://img.shields.io/badge/platform-macOS%20%2F%20Windows%20%2F%20Linux-lightgrey" alt="platform">
|
|
8
8
|
<img src="https://img.shields.io/badge/chrome-MV3-green" alt="chrome manifest v3">
|
|
9
9
|
<img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="node version">
|
|
@@ -38,14 +38,14 @@ One command installs the managed native host **and** managed extension runtime.
|
|
|
38
38
|
macOS / Linux:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
CODEX_OVERLEAF_REF=v2.
|
|
41
|
+
CODEX_OVERLEAF_REF=v2.3.1 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.3.1/install.sh)"
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Windows PowerShell:
|
|
45
45
|
|
|
46
46
|
```powershell
|
|
47
|
-
iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.
|
|
48
|
-
$env:CODEX_OVERLEAF_REF='v2.
|
|
47
|
+
iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.3.1/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v2.3.1'
|
|
49
49
|
powershell -ExecutionPolicy Bypass -File install.ps1
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -56,7 +56,7 @@ Then, in the `chrome://extensions` tab the script opened: enable **Developer mod
|
|
|
56
56
|
`npm exec` installs the same managed native host and extension runtime without keeping a source checkout. Use it if you prefer a pinned npm package.
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
npm exec --yes codex-overleaf-link@2.
|
|
59
|
+
npm exec --yes codex-overleaf-link@2.3.1 -- install-managed
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Then, in `chrome://extensions`, enable **Developer mode**, click **Load unpacked**, and select the managed extension path printed by the command. The Release extension zip remains available for explicitly unmanaged/manual installations.
|
|
@@ -73,6 +73,8 @@ The bundled extension key gives the official build a stable id, so normal instal
|
|
|
73
73
|
```bash
|
|
74
74
|
git clone https://github.com/Ghqqqq/codex-overleaf-link.git
|
|
75
75
|
cd codex-overleaf-link
|
|
76
|
+
npm ci
|
|
77
|
+
npm run build:content
|
|
76
78
|
npm run install:native
|
|
77
79
|
```
|
|
78
80
|
|
|
@@ -86,9 +88,9 @@ npm installs, updates, and uninstalls the coordinated managed extension/native p
|
|
|
86
88
|
|
|
87
89
|
| Action | Command |
|
|
88
90
|
|--------|---------|
|
|
89
|
-
| Install / update | `npm exec --yes codex-overleaf-link@2.
|
|
90
|
-
| Diagnose | `npm exec --yes codex-overleaf-link@2.
|
|
91
|
-
| Uninstall | `npm exec --yes codex-overleaf-link@2.
|
|
91
|
+
| Install / update | `npm exec --yes codex-overleaf-link@2.3.1 -- install-managed` |
|
|
92
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@2.3.1 -- doctor` |
|
|
93
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@2.3.1 -- uninstall-managed` |
|
|
92
94
|
|
|
93
95
|
Use `--extension-id <chrome-extension-id>` only for a custom/dev unpacked extension id that differs from the official bundled id.
|
|
94
96
|
|
|
@@ -102,13 +104,13 @@ Managed installations discover signed stable updates automatically and apply the
|
|
|
102
104
|
|
|
103
105
|
v2.2.0 introduces Bootstrap protocol 2. Existing v2.1.x managed installations must run the pinned `install-managed` command once, then reload the extension and Overleaf. Later protocol-2 releases use the in-product signed updater for ordinary runtime, style, vendor, and Native Host feature changes.
|
|
104
106
|
|
|
105
|
-
The v2.
|
|
107
|
+
The v2.3.1 GitHub Release contains:
|
|
106
108
|
|
|
107
|
-
- `codex-overleaf-link-extension-v2.
|
|
108
|
-
- `codex-overleaf-native-host-v2.
|
|
109
|
-
- `codex-overleaf-link-2.
|
|
110
|
-
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v2.
|
|
111
|
-
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v2.
|
|
109
|
+
- `codex-overleaf-link-extension-v2.3.1.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
110
|
+
- `codex-overleaf-native-host-v2.3.1.tar.gz`: native host runtime files used by the installer and release verification.
|
|
111
|
+
- `codex-overleaf-link-2.3.1.tgz`: npm native host CLI package for pinned install, doctor, and uninstall flows.
|
|
112
|
+
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v2.3.1` when run directly from the release artifact.
|
|
113
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v2.3.1` when run directly from the release artifact.
|
|
112
114
|
- `uninstall-native-host.mjs`: native host uninstaller that removes the Chrome Native Messaging manifest, bridge executable, and runtime copy.
|
|
113
115
|
- `nativeHostPlatform.js`, `manifest.js`, `runtimeInstaller.js`: helper files required by the loose uninstaller asset.
|
|
114
116
|
- `SHA256SUMS` and `release-manifest.json`: checksum and artifact metadata for release verification.
|
|
@@ -119,7 +121,7 @@ The v2.2.1 GitHub Release contains:
|
|
|
119
121
|
Remove the native host (use `--browser chromium` on Linux Chromium):
|
|
120
122
|
|
|
121
123
|
```bash
|
|
122
|
-
npm exec --yes codex-overleaf-link@2.
|
|
124
|
+
npm exec --yes codex-overleaf-link@2.3.1 -- uninstall-managed
|
|
123
125
|
```
|
|
124
126
|
|
|
125
127
|
The same command works on Windows PowerShell. If you installed from a manual checkout or source installer, you can also run `npm run uninstall:native` inside the repo, use `node ~/.codex-overleaf/source/scripts/uninstall-native-host.mjs` on macOS / Linux, or use `node $env:LOCALAPPDATA\CodexOverleaf\source\scripts\uninstall-native-host.mjs` on Windows PowerShell.
|
|
@@ -154,13 +156,13 @@ Then remove the extension from `chrome://extensions`. To delete local data: on m
|
|
|
154
156
|
Linux Chromium install or update:
|
|
155
157
|
|
|
156
158
|
```bash
|
|
157
|
-
CODEX_OVERLEAF_REF=v2.
|
|
159
|
+
CODEX_OVERLEAF_REF=v2.3.1 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.3.1/install.sh)" -- --browser chromium
|
|
158
160
|
```
|
|
159
161
|
|
|
160
162
|
Linux Chromium uninstall:
|
|
161
163
|
|
|
162
164
|
```bash
|
|
163
|
-
npm exec --yes codex-overleaf-link@2.
|
|
165
|
+
npm exec --yes codex-overleaf-link@2.3.1 -- uninstall-managed --browser chromium
|
|
164
166
|
```
|
|
165
167
|
|
|
166
168
|
## Features
|
|
@@ -296,7 +298,7 @@ Composer attachments are turn-scoped Codex context. Limits are 8 attachments per
|
|
|
296
298
|
Re-run any [native host installer](#install), reload the extension in `chrome://extensions`, then refresh the Overleaf tab. This also fixes extension/native version mismatch and native protocol mismatch.
|
|
297
299
|
|
|
298
300
|
```bash
|
|
299
|
-
npm exec --yes codex-overleaf-link@2.
|
|
301
|
+
npm exec --yes codex-overleaf-link@2.3.1 -- install-managed
|
|
300
302
|
```
|
|
301
303
|
|
|
302
304
|
**The Windows popup or panel shows a Bash recovery command**
|
|
@@ -345,8 +347,8 @@ Use this matrix for release-candidate signoff and compatibility reports. Record
|
|
|
345
347
|
| Browser/channel/version | Google Chrome channel and version. | Google Chrome channel and version. | Google Chrome channel and version. | Chromium channel/package and version. |
|
|
346
348
|
| Install mode | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout; native host installed with `--browser chromium`. |
|
|
347
349
|
| Extension id | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. |
|
|
348
|
-
| Installer/update command | `npm exec --yes codex-overleaf-link@2.
|
|
349
|
-
| Uninstall command | `npm exec --yes codex-overleaf-link@2.
|
|
350
|
+
| Installer/update command | `npm exec --yes codex-overleaf-link@2.3.1 -- install-managed` | `npm exec --yes codex-overleaf-link@2.3.1 -- install-managed` | `npm exec --yes codex-overleaf-link@2.3.1 -- install-managed` | `npm exec --yes codex-overleaf-link@2.3.1 -- install-managed --browser chromium` |
|
|
351
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@2.3.1 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.3.1 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.3.1 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.3.1 -- uninstall-managed --browser chromium` |
|
|
350
352
|
| Manifest/registry path | `~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.codex.overleaf.json` | `HKCU\Software\Google\Chrome\NativeMessagingHosts\com.codex.overleaf` -> `%LOCALAPPDATA%\CodexOverleaf\native-host-runtime\com.codex.overleaf.json` | `~/.config/google-chrome/NativeMessagingHosts/com.codex.overleaf.json` | `~/.config/chromium/NativeMessagingHosts/com.codex.overleaf.json` |
|
|
351
353
|
| Bridge/runtime/source path | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. | Bridge `%LOCALAPPDATA%\CodexOverleaf\codex-overleaf-bridge.cmd`; runtime `%LOCALAPPDATA%\CodexOverleaf\native-host-runtime`; source `%LOCALAPPDATA%\CodexOverleaf\source`. | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. |
|
|
352
354
|
| Node/Git/Codex/TeX | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. |
|
|
@@ -382,7 +384,7 @@ Contributions are welcome. Please open an issue before submitting large changes
|
|
|
382
384
|
The recommended v1.9 installation owns one stable unpacked-extension directory and a versioned native-host directory:
|
|
383
385
|
|
|
384
386
|
```bash
|
|
385
|
-
npm exec --yes codex-overleaf-link@2.
|
|
387
|
+
npm exec --yes codex-overleaf-link@2.3.1 -- install-managed
|
|
386
388
|
```
|
|
387
389
|
|
|
388
390
|
Load the printed extension path once from `chrome://extensions`. Starting with the next signed stable release, Codex Overleaf Link checks GitHub Releases automatically, downloads and verifies the coordinated extension/native-host bundle, waits until every connected Overleaf tab is saved and idle, and then updates both components together. A failed health check restores the previous version automatically.
|
|
@@ -392,11 +394,11 @@ The stable updater ignores drafts and prereleases, performs no telemetry, and ca
|
|
|
392
394
|
The legacy native-only installer remains available for source or unmanaged extension directories:
|
|
393
395
|
|
|
394
396
|
```bash
|
|
395
|
-
npm exec --yes codex-overleaf-link@2.
|
|
397
|
+
npm exec --yes codex-overleaf-link@2.3.1 -- install-native
|
|
396
398
|
```
|
|
397
399
|
|
|
398
400
|
Legacy native-only installations can be removed with:
|
|
399
401
|
|
|
400
402
|
```bash
|
|
401
|
-
npm exec --yes codex-overleaf-link@2.
|
|
403
|
+
npm exec --yes codex-overleaf-link@2.3.1 -- uninstall-native
|
|
402
404
|
```
|
|
@@ -7,77 +7,11 @@
|
|
|
7
7
|
"https://overleaf.com/project/*"
|
|
8
8
|
],
|
|
9
9
|
"js": [
|
|
10
|
-
"src/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"src/shared/lineReferences.js",
|
|
16
|
-
"src/shared/undoOperations.js",
|
|
17
|
-
"src/shared/otText.js",
|
|
18
|
-
"src/shared/i18n.js",
|
|
19
|
-
"src/shared/models.js",
|
|
20
|
-
"src/shared/providerProfiles.js",
|
|
21
|
-
"src/shared/runInputQueue.js",
|
|
22
|
-
"src/shared/sessionState.js",
|
|
23
|
-
"src/shared/storageKeys.js",
|
|
24
|
-
"src/shared/staleGuard.js",
|
|
25
|
-
"src/shared/storageRunActions.js",
|
|
26
|
-
"src/shared/storageDb.js",
|
|
27
|
-
"src/shared/storageMigration.js",
|
|
28
|
-
"src/shared/compileAdapter.js",
|
|
29
|
-
"src/shared/compatibility.js",
|
|
30
|
-
"src/shared/governanceRules.js",
|
|
31
|
-
"src/shared/sensitiveScan.js",
|
|
32
|
-
"src/shared/auditRecords.js",
|
|
33
|
-
"src/content/nativeChannel.js",
|
|
34
|
-
"src/content/writebackController.js",
|
|
35
|
-
"src/content/reviewHunks.js",
|
|
36
|
-
"src/content/diffReviewPanel.js",
|
|
37
|
-
"src/content/contextTray.js",
|
|
38
|
-
"src/content/localSkillsPanel.js",
|
|
39
|
-
"src/content/runController.js",
|
|
40
|
-
"src/content/mirrorHealth.js",
|
|
41
|
-
"src/content/otWarmMirrorController.js",
|
|
42
|
-
"src/content/composerAttachments.js",
|
|
43
|
-
"src/content/panelRenderer.js",
|
|
44
|
-
"src/content/sessionPanel.js",
|
|
45
|
-
"src/content/settingsPanel.js",
|
|
46
|
-
"src/content/providerSettingsDialog.js",
|
|
47
|
-
"src/content/projectProviderSelection.js",
|
|
48
|
-
"src/content/providerSettingsCoordinator.js",
|
|
49
|
-
"src/content/sessionPersistence.js",
|
|
50
|
-
"src/content/diagnosticsPanel.js",
|
|
51
|
-
"src/content/runQueueScheduler.js",
|
|
52
|
-
"src/content/activeTurnControl.js",
|
|
53
|
-
"src/content/pendingInputView.js",
|
|
54
|
-
"src/content/composerPanel.js",
|
|
55
|
-
"src/content/themeController.js",
|
|
56
|
-
"vendor/katex/katex.min.js",
|
|
57
|
-
"vendor/markdown-it/markdown-it.min.js",
|
|
58
|
-
"src/content/mathText.js",
|
|
59
|
-
"src/content/markdownDomRenderer.js",
|
|
60
|
-
"src/content/markdownText.js",
|
|
61
|
-
"src/content/diagnosticsController.js",
|
|
62
|
-
"src/content/runGuidanceView.js",
|
|
63
|
-
"src/content/runGuidanceController.js",
|
|
64
|
-
"src/content/runTimelineView.js",
|
|
65
|
-
"src/content/projectSettingsCoordinator.js",
|
|
66
|
-
"src/content/sessionMenuView.js",
|
|
67
|
-
"src/content/sessionManager.js",
|
|
68
|
-
"src/content/applyResultFormatters.js",
|
|
69
|
-
"src/content/modelPickerSupport.js",
|
|
70
|
-
"src/content/modelPicker.js",
|
|
71
|
-
"src/content/projectSessionCleanup.js",
|
|
72
|
-
"src/content/recentProjects.js",
|
|
73
|
-
"src/content/otWarmMirror.js",
|
|
74
|
-
"src/content/writebackOrchestrator.js",
|
|
75
|
-
"src/content/panelMaintenance.js",
|
|
76
|
-
"src/content/updateIdle.js",
|
|
77
|
-
"src/content/updateNotice.js",
|
|
78
|
-
"src/content/contentRuntime.js",
|
|
79
|
-
"src/contentScript.js"
|
|
10
|
+
"src/content/generated/content.bundle.js"
|
|
11
|
+
],
|
|
12
|
+
"css": [
|
|
13
|
+
"vendor/katex/katex.min.css",
|
|
14
|
+
"styles/panel.css"
|
|
80
15
|
],
|
|
81
|
-
"css": ["vendor/katex/katex.min.css", "styles/panel.css"],
|
|
82
16
|
"runAt": "document_idle"
|
|
83
17
|
}
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
if (!globalThis.CodexOverleafCompatibility) {
|
|
2
2
|
importScripts('shared/compatibility.js');
|
|
3
3
|
}
|
|
4
|
+
if (!globalThis.CodexOverleafManagedUpdateProjection) {
|
|
5
|
+
const runtimeBase = String(globalThis.__CODEX_OVERLEAF_RUNTIME_BASE__ || '');
|
|
6
|
+
const projectionPath = runtimeBase
|
|
7
|
+
? `${runtimeBase}/src/shared/managedUpdateProjection.js`
|
|
8
|
+
: 'shared/managedUpdateProjection.js';
|
|
9
|
+
importScripts(runtimeBase ? chrome.runtime.getURL(projectionPath) : projectionPath);
|
|
10
|
+
}
|
|
11
|
+
if (!globalThis.CodexOverleafNativeRequestIdentity) {
|
|
12
|
+
const runtimeBase = String(globalThis.__CODEX_OVERLEAF_RUNTIME_BASE__ || '');
|
|
13
|
+
const identityPath = runtimeBase
|
|
14
|
+
? `${runtimeBase}/src/shared/nativeRequestIdentity.js`
|
|
15
|
+
: 'shared/nativeRequestIdentity.js';
|
|
16
|
+
importScripts(runtimeBase ? chrome.runtime.getURL(identityPath) : identityPath);
|
|
17
|
+
}
|
|
4
18
|
|
|
5
19
|
(function initBackground() {
|
|
6
20
|
'use strict';
|
|
7
21
|
|
|
8
22
|
const HOST_NAME = 'com.codex.overleaf';
|
|
9
23
|
const MANAGED_UPDATE_STATE_KEY = 'codex-overleaf-managed-update-state-v1';
|
|
24
|
+
const MANAGED_UPDATE_CONSENT_KEY = 'codex-overleaf-update-consent-v1';
|
|
10
25
|
const MANAGED_UPDATE_TABS_KEY = 'codex-overleaf-managed-update-tabs-v1';
|
|
11
26
|
const MANAGED_OVERLEAF_MATCHES = [
|
|
12
27
|
'https://www.overleaf.com/project',
|
|
@@ -14,11 +29,6 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
14
29
|
'https://www.overleaf.com/project/*',
|
|
15
30
|
'https://overleaf.com/project/*'
|
|
16
31
|
];
|
|
17
|
-
const MANAGED_UPDATE_PHASE_TIMEOUT_MS = Object.freeze({
|
|
18
|
-
applying: 90 * 1000,
|
|
19
|
-
awaiting_health: 2 * 60 * 1000,
|
|
20
|
-
rolling_back: 60 * 1000
|
|
21
|
-
});
|
|
22
32
|
const COMPATIBILITY_REQUIRED_METHODS = new Set([
|
|
23
33
|
'codex.run',
|
|
24
34
|
'codex.steer',
|
|
@@ -47,6 +57,8 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
47
57
|
'codex.cancel'
|
|
48
58
|
]);
|
|
49
59
|
const CodexOverleafCompatibility = globalThis.CodexOverleafCompatibility;
|
|
60
|
+
const ManagedUpdateProjection = globalThis.CodexOverleafManagedUpdateProjection;
|
|
61
|
+
const NativeRequestIdentity = globalThis.CodexOverleafNativeRequestIdentity;
|
|
50
62
|
let port = null;
|
|
51
63
|
let managedUpdateExecutionLocked = false;
|
|
52
64
|
const pending = new Map();
|
|
@@ -222,7 +234,14 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
222
234
|
}
|
|
223
235
|
|
|
224
236
|
function sendNativeRequest(payload, sender, options = {}) {
|
|
225
|
-
const
|
|
237
|
+
const identity = NativeRequestIdentity.resolve(payload?.id, () => crypto.randomUUID());
|
|
238
|
+
if (!identity.ok) {
|
|
239
|
+
return Promise.resolve({
|
|
240
|
+
ok: false,
|
|
241
|
+
error: identity.error
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
const id = identity.id;
|
|
226
245
|
const requestWithEvidence = { ...payload, id };
|
|
227
246
|
const compatibilityBlock = options.skipCompatibility ? null : getNativeCompatibilityBlock(requestWithEvidence);
|
|
228
247
|
if (compatibilityBlock) {
|
|
@@ -366,18 +385,14 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
366
385
|
}
|
|
367
386
|
|
|
368
387
|
async function repairManagedUpdatePhaseMetadata(state) {
|
|
369
|
-
const
|
|
370
|
-
|
|
388
|
+
const repaired = ManagedUpdateProjection.ensurePhaseMetadata(state, {
|
|
389
|
+
currentVersion: chrome.runtime.getManifest().version
|
|
390
|
+
});
|
|
391
|
+
if (Number(repaired.deadlineAt || 0) === Number(state?.deadlineAt || 0)) {
|
|
371
392
|
return;
|
|
372
393
|
}
|
|
373
|
-
const now = Date.now();
|
|
374
394
|
await chrome.storage.local.set({
|
|
375
|
-
[MANAGED_UPDATE_STATE_KEY]:
|
|
376
|
-
...state,
|
|
377
|
-
phaseStartedAt: now,
|
|
378
|
-
deadlineAt: now + timeoutMs,
|
|
379
|
-
heartbeatAt: now
|
|
380
|
-
}
|
|
395
|
+
[MANAGED_UPDATE_STATE_KEY]: repaired
|
|
381
396
|
});
|
|
382
397
|
}
|
|
383
398
|
|
|
@@ -392,78 +407,57 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
392
407
|
}
|
|
393
408
|
|
|
394
409
|
const transaction = response.result?.transaction || null;
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
await
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
transactionId: transaction.id || state.transactionId,
|
|
402
|
-
code: transaction.reasonCode || state.code || 'update_rolled_back'
|
|
403
|
-
});
|
|
404
|
-
await reloadManagedUpdateTabs();
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
if (transaction?.state === 'committed') {
|
|
408
|
-
const targetVersion = transaction.targetVersion || state.latestVersion || state.currentVersion;
|
|
410
|
+
if (transaction?.state === 'superseded') {
|
|
411
|
+
const activeVersion = response.result?.activeVersion || chrome.runtime.getManifest().version;
|
|
412
|
+
await chrome.storage.local.remove([
|
|
413
|
+
MANAGED_UPDATE_CONSENT_KEY,
|
|
414
|
+
MANAGED_UPDATE_TABS_KEY
|
|
415
|
+
]);
|
|
409
416
|
await setManagedUpdateState({
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
currentVersion:
|
|
413
|
-
latestVersion:
|
|
417
|
+
state: 'idle',
|
|
418
|
+
managed: true,
|
|
419
|
+
currentVersion: activeVersion,
|
|
420
|
+
latestVersion: activeVersion,
|
|
414
421
|
transactionId: '',
|
|
415
422
|
blocker: '',
|
|
416
423
|
blockers: [],
|
|
417
424
|
code: '',
|
|
418
425
|
message: ''
|
|
419
426
|
});
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const state = await getManagedUpdateState();
|
|
430
|
+
const reconciled = ManagedUpdateProjection.reconcile(state, transaction, {
|
|
431
|
+
currentVersion: chrome.runtime.getManifest().version
|
|
432
|
+
});
|
|
433
|
+
await setManagedUpdateState(reconciled.state);
|
|
434
|
+
if (reconciled.action === 'reload_tabs') {
|
|
420
435
|
await reloadManagedUpdateTabs();
|
|
421
436
|
return;
|
|
422
437
|
}
|
|
423
|
-
if (
|
|
424
|
-
await setManagedUpdateState({
|
|
425
|
-
...state,
|
|
426
|
-
state: 'staged',
|
|
427
|
-
transactionId: transaction.id || state.transactionId,
|
|
428
|
-
blocker: '',
|
|
429
|
-
blockers: [],
|
|
430
|
-
code: '',
|
|
431
|
-
message: '',
|
|
432
|
-
phaseStartedAt: 0,
|
|
433
|
-
deadlineAt: 0,
|
|
434
|
-
heartbeatAt: 0
|
|
435
|
-
});
|
|
438
|
+
if (reconciled.action === 'retry_install') {
|
|
436
439
|
setTimeout(() => {
|
|
437
440
|
void globalThis.CodexOverleafManagedUpdateExecutor?.installAuthorizedUpdate?.().catch?.(() => {});
|
|
438
441
|
}, 250);
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
if (!transaction && ['applying', 'awaiting_health', 'rolling_back'].includes(state.state)) {
|
|
442
|
-
await setManagedUpdateState({
|
|
443
|
-
...state,
|
|
444
|
-
state: 'failed',
|
|
445
|
-
code: 'update_transaction_lost',
|
|
446
|
-
message: 'The managed update transaction could not be recovered. Use the manual update command.',
|
|
447
|
-
phaseStartedAt: 0,
|
|
448
|
-
deadlineAt: 0,
|
|
449
|
-
heartbeatAt: 0
|
|
450
|
-
});
|
|
451
442
|
}
|
|
452
443
|
}
|
|
453
444
|
|
|
454
445
|
async function getManagedUpdateState() {
|
|
455
446
|
const stored = await chrome.storage.local.get(MANAGED_UPDATE_STATE_KEY);
|
|
456
|
-
return stored?.[MANAGED_UPDATE_STATE_KEY] || {
|
|
447
|
+
return ManagedUpdateProjection.normalize(stored?.[MANAGED_UPDATE_STATE_KEY] || {
|
|
457
448
|
state: 'idle',
|
|
458
449
|
managed: true,
|
|
459
450
|
currentVersion: chrome.runtime.getManifest().version,
|
|
460
451
|
latestVersion: chrome.runtime.getManifest().version
|
|
461
|
-
};
|
|
452
|
+
}, { currentVersion: chrome.runtime.getManifest().version });
|
|
462
453
|
}
|
|
463
454
|
|
|
464
455
|
async function setManagedUpdateState(state) {
|
|
465
|
-
|
|
466
|
-
|
|
456
|
+
const value = ManagedUpdateProjection.ensurePhaseMetadata(state, {
|
|
457
|
+
currentVersion: chrome.runtime.getManifest().version
|
|
458
|
+
});
|
|
459
|
+
await chrome.storage.local.set({ [MANAGED_UPDATE_STATE_KEY]: value });
|
|
460
|
+
return value;
|
|
467
461
|
}
|
|
468
462
|
|
|
469
463
|
async function reloadManagedUpdateTabs() {
|
|
@@ -638,7 +632,14 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
638
632
|
|
|
639
633
|
function sendNativeCancel(payload) {
|
|
640
634
|
const nativePort = ensurePort();
|
|
641
|
-
const
|
|
635
|
+
const identity = NativeRequestIdentity.resolve(payload?.id, () => crypto.randomUUID());
|
|
636
|
+
if (!identity.ok) {
|
|
637
|
+
const error = new Error(identity.error.message);
|
|
638
|
+
error.code = identity.error.code;
|
|
639
|
+
error.details = identity.error.details;
|
|
640
|
+
throw error;
|
|
641
|
+
}
|
|
642
|
+
const id = identity.id;
|
|
642
643
|
const request = sanitizeNativeRequest({ ...payload, id });
|
|
643
644
|
try {
|
|
644
645
|
nativePort.postMessage(request);
|
|
@@ -1046,6 +1047,9 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
1046
1047
|
if (!root.CodexOverleafUpdateConsent) {
|
|
1047
1048
|
importScripts(chrome.runtime.getURL(runtimePrefix + 'src/shared/updateConsent.js'));
|
|
1048
1049
|
}
|
|
1050
|
+
if (!root.CodexOverleafUpdateRevocation) {
|
|
1051
|
+
importScripts(chrome.runtime.getURL(runtimePrefix + 'src/shared/updateRevocationIntent.js'));
|
|
1052
|
+
}
|
|
1049
1053
|
if (!root.CodexOverleafUpdateCoordinator) {
|
|
1050
1054
|
importScripts(chrome.runtime.getURL(runtimePrefix + 'src/backgroundUpdateCoordinator.js'));
|
|
1051
1055
|
}
|