codex-overleaf-link 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -23
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/runtime-manifest.json +5 -71
- package/extension/src/background.js +53 -69
- package/extension/src/backgroundUpdateCoordinator.js +128 -66
- package/extension/src/content/applyResultFormatters.js +2 -3
- package/extension/src/content/contentRuntime.js +650 -1449
- 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 +41370 -0
- package/extension/src/content/generated/content.bundle.meta.json +102 -0
- package/extension/src/content/legacyGlobalRegistry.js +129 -0
- package/extension/src/content/markdownText.js +5 -7
- 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 +7 -5
- 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 +11 -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 +91 -23
- package/extension/src/contentScript.js +5 -1
- package/extension/src/page/trackedChangesLifecycle.js +6 -1
- package/extension/src/pageBridge.js +47 -98
- package/extension/src/shared/agentTranscript.js +8 -5
- package/extension/src/shared/compatibility.js +1 -1
- package/extension/src/shared/governanceRules.js +1 -1
- 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 +177 -0
- package/extension/src/shared/runExecutionSnapshotCodec.js +168 -0
- package/extension/src/shared/runInputQueue.js +81 -34
- package/extension/src/shared/scopedPersistenceBrowserAdapter.js +79 -0
- package/extension/src/shared/scopedPersistenceQueuePolicy.js +181 -0
- package/extension/src/shared/scopedPersistenceTransaction.js +238 -0
- package/extension/src/shared/sessionState.js +64 -48
- package/extension/src/shared/settlementFacts.js +351 -0
- package/extension/src/shared/storageDb.js +19 -5
- 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 +143 -0
- package/extension/src/shared/writebackSettlement.js +705 -0
- 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 +3 -3
- 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.0-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.0 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.3.0/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.0/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v2.3.0'
|
|
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.0 -- 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.0 -- install-managed` |
|
|
92
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@2.3.0 -- doctor` |
|
|
93
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@2.3.0 -- 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.0 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.0.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
110
|
+
- `codex-overleaf-native-host-v2.3.0.tar.gz`: native host runtime files used by the installer and release verification.
|
|
111
|
+
- `codex-overleaf-link-2.3.0.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.0` when run directly from the release artifact.
|
|
113
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v2.3.0` 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.0 -- 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.0 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.3.0/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.0 -- 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.0 -- 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.0 -- install-managed` | `npm exec --yes codex-overleaf-link@2.3.0 -- install-managed` | `npm exec --yes codex-overleaf-link@2.3.0 -- install-managed` | `npm exec --yes codex-overleaf-link@2.3.0 -- install-managed --browser chromium` |
|
|
351
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@2.3.0 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.3.0 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.3.0 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.3.0 -- 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.0 -- 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.0 -- 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.0 -- 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,6 +1,20 @@
|
|
|
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';
|
|
@@ -14,11 +28,6 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
14
28
|
'https://www.overleaf.com/project/*',
|
|
15
29
|
'https://overleaf.com/project/*'
|
|
16
30
|
];
|
|
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
31
|
const COMPATIBILITY_REQUIRED_METHODS = new Set([
|
|
23
32
|
'codex.run',
|
|
24
33
|
'codex.steer',
|
|
@@ -47,6 +56,8 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
47
56
|
'codex.cancel'
|
|
48
57
|
]);
|
|
49
58
|
const CodexOverleafCompatibility = globalThis.CodexOverleafCompatibility;
|
|
59
|
+
const ManagedUpdateProjection = globalThis.CodexOverleafManagedUpdateProjection;
|
|
60
|
+
const NativeRequestIdentity = globalThis.CodexOverleafNativeRequestIdentity;
|
|
50
61
|
let port = null;
|
|
51
62
|
let managedUpdateExecutionLocked = false;
|
|
52
63
|
const pending = new Map();
|
|
@@ -222,7 +233,14 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
222
233
|
}
|
|
223
234
|
|
|
224
235
|
function sendNativeRequest(payload, sender, options = {}) {
|
|
225
|
-
const
|
|
236
|
+
const identity = NativeRequestIdentity.resolve(payload?.id, () => crypto.randomUUID());
|
|
237
|
+
if (!identity.ok) {
|
|
238
|
+
return Promise.resolve({
|
|
239
|
+
ok: false,
|
|
240
|
+
error: identity.error
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
const id = identity.id;
|
|
226
244
|
const requestWithEvidence = { ...payload, id };
|
|
227
245
|
const compatibilityBlock = options.skipCompatibility ? null : getNativeCompatibilityBlock(requestWithEvidence);
|
|
228
246
|
if (compatibilityBlock) {
|
|
@@ -366,18 +384,14 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
366
384
|
}
|
|
367
385
|
|
|
368
386
|
async function repairManagedUpdatePhaseMetadata(state) {
|
|
369
|
-
const
|
|
370
|
-
|
|
387
|
+
const repaired = ManagedUpdateProjection.ensurePhaseMetadata(state, {
|
|
388
|
+
currentVersion: chrome.runtime.getManifest().version
|
|
389
|
+
});
|
|
390
|
+
if (Number(repaired.deadlineAt || 0) === Number(state?.deadlineAt || 0)) {
|
|
371
391
|
return;
|
|
372
392
|
}
|
|
373
|
-
const now = Date.now();
|
|
374
393
|
await chrome.storage.local.set({
|
|
375
|
-
[MANAGED_UPDATE_STATE_KEY]:
|
|
376
|
-
...state,
|
|
377
|
-
phaseStartedAt: now,
|
|
378
|
-
deadlineAt: now + timeoutMs,
|
|
379
|
-
heartbeatAt: now
|
|
380
|
-
}
|
|
394
|
+
[MANAGED_UPDATE_STATE_KEY]: repaired
|
|
381
395
|
});
|
|
382
396
|
}
|
|
383
397
|
|
|
@@ -393,77 +407,37 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
393
407
|
|
|
394
408
|
const transaction = response.result?.transaction || null;
|
|
395
409
|
const state = await getManagedUpdateState();
|
|
396
|
-
|
|
397
|
-
|
|
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;
|
|
409
|
-
await setManagedUpdateState({
|
|
410
|
-
...state,
|
|
411
|
-
state: 'committed',
|
|
412
|
-
currentVersion: targetVersion,
|
|
413
|
-
latestVersion: targetVersion,
|
|
414
|
-
transactionId: '',
|
|
415
|
-
blocker: '',
|
|
416
|
-
blockers: [],
|
|
417
|
-
code: '',
|
|
418
|
-
message: ''
|
|
419
|
-
});
|
|
410
|
+
const reconciled = ManagedUpdateProjection.reconcile(state, transaction, {
|
|
411
|
+
currentVersion: chrome.runtime.getManifest().version
|
|
412
|
+
});
|
|
413
|
+
await setManagedUpdateState(reconciled.state);
|
|
414
|
+
if (reconciled.action === 'reload_tabs') {
|
|
420
415
|
await reloadManagedUpdateTabs();
|
|
421
416
|
return;
|
|
422
417
|
}
|
|
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
|
-
});
|
|
418
|
+
if (reconciled.action === 'retry_install') {
|
|
436
419
|
setTimeout(() => {
|
|
437
420
|
void globalThis.CodexOverleafManagedUpdateExecutor?.installAuthorizedUpdate?.().catch?.(() => {});
|
|
438
421
|
}, 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
422
|
}
|
|
452
423
|
}
|
|
453
424
|
|
|
454
425
|
async function getManagedUpdateState() {
|
|
455
426
|
const stored = await chrome.storage.local.get(MANAGED_UPDATE_STATE_KEY);
|
|
456
|
-
return stored?.[MANAGED_UPDATE_STATE_KEY] || {
|
|
427
|
+
return ManagedUpdateProjection.normalize(stored?.[MANAGED_UPDATE_STATE_KEY] || {
|
|
457
428
|
state: 'idle',
|
|
458
429
|
managed: true,
|
|
459
430
|
currentVersion: chrome.runtime.getManifest().version,
|
|
460
431
|
latestVersion: chrome.runtime.getManifest().version
|
|
461
|
-
};
|
|
432
|
+
}, { currentVersion: chrome.runtime.getManifest().version });
|
|
462
433
|
}
|
|
463
434
|
|
|
464
435
|
async function setManagedUpdateState(state) {
|
|
465
|
-
|
|
466
|
-
|
|
436
|
+
const value = ManagedUpdateProjection.ensurePhaseMetadata(state, {
|
|
437
|
+
currentVersion: chrome.runtime.getManifest().version
|
|
438
|
+
});
|
|
439
|
+
await chrome.storage.local.set({ [MANAGED_UPDATE_STATE_KEY]: value });
|
|
440
|
+
return value;
|
|
467
441
|
}
|
|
468
442
|
|
|
469
443
|
async function reloadManagedUpdateTabs() {
|
|
@@ -638,7 +612,14 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
638
612
|
|
|
639
613
|
function sendNativeCancel(payload) {
|
|
640
614
|
const nativePort = ensurePort();
|
|
641
|
-
const
|
|
615
|
+
const identity = NativeRequestIdentity.resolve(payload?.id, () => crypto.randomUUID());
|
|
616
|
+
if (!identity.ok) {
|
|
617
|
+
const error = new Error(identity.error.message);
|
|
618
|
+
error.code = identity.error.code;
|
|
619
|
+
error.details = identity.error.details;
|
|
620
|
+
throw error;
|
|
621
|
+
}
|
|
622
|
+
const id = identity.id;
|
|
642
623
|
const request = sanitizeNativeRequest({ ...payload, id });
|
|
643
624
|
try {
|
|
644
625
|
nativePort.postMessage(request);
|
|
@@ -1046,6 +1027,9 @@ if (!globalThis.CodexOverleafCompatibility) {
|
|
|
1046
1027
|
if (!root.CodexOverleafUpdateConsent) {
|
|
1047
1028
|
importScripts(chrome.runtime.getURL(runtimePrefix + 'src/shared/updateConsent.js'));
|
|
1048
1029
|
}
|
|
1030
|
+
if (!root.CodexOverleafUpdateRevocation) {
|
|
1031
|
+
importScripts(chrome.runtime.getURL(runtimePrefix + 'src/shared/updateRevocationIntent.js'));
|
|
1032
|
+
}
|
|
1049
1033
|
if (!root.CodexOverleafUpdateCoordinator) {
|
|
1050
1034
|
importScripts(chrome.runtime.getURL(runtimePrefix + 'src/backgroundUpdateCoordinator.js'));
|
|
1051
1035
|
}
|