codex-overleaf-link 2.1.2 → 2.1.3

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 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.1.2-blue" alt="version">
6
+ <img src="https://img.shields.io/badge/version-2.1.3-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.1.2 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.2/install.sh)"
41
+ CODEX_OVERLEAF_REF=v2.1.3 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.3/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.1.2/install.ps1 -OutFile install.ps1
48
- $env:CODEX_OVERLEAF_REF='v2.1.2'
47
+ iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.3/install.ps1 -OutFile install.ps1
48
+ $env:CODEX_OVERLEAF_REF='v2.1.3'
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.1.2 -- install-managed
59
+ npm exec --yes codex-overleaf-link@2.1.3 -- 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.
@@ -86,9 +86,9 @@ npm installs, updates, and uninstalls the coordinated managed extension/native p
86
86
 
87
87
  | Action | Command |
88
88
  |--------|---------|
89
- | Install / update | `npm exec --yes codex-overleaf-link@2.1.2 -- install-managed` |
90
- | Diagnose | `npm exec --yes codex-overleaf-link@2.1.2 -- doctor` |
91
- | Uninstall | `npm exec --yes codex-overleaf-link@2.1.2 -- uninstall-managed` |
89
+ | Install / update | `npm exec --yes codex-overleaf-link@2.1.3 -- install-managed` |
90
+ | Diagnose | `npm exec --yes codex-overleaf-link@2.1.3 -- doctor` |
91
+ | Uninstall | `npm exec --yes codex-overleaf-link@2.1.3 -- uninstall-managed` |
92
92
 
93
93
  Use `--extension-id <chrome-extension-id>` only for a custom/dev unpacked extension id that differs from the official bundled id.
94
94
 
@@ -98,13 +98,13 @@ Managed installations discover signed stable updates automatically and apply the
98
98
 
99
99
  ## GitHub Release Artifacts
100
100
 
101
- The v2.1.2 GitHub Release contains:
101
+ The v2.1.3 GitHub Release contains:
102
102
 
103
- - `codex-overleaf-link-extension-v2.1.2.zip`: loadable Chrome extension package for manual unpacked installation.
104
- - `codex-overleaf-native-host-v2.1.2.tar.gz`: native host runtime files used by the installer and release verification.
105
- - `codex-overleaf-link-2.1.2.tgz`: npm native host CLI package for pinned install, doctor, and uninstall flows.
106
- - `install.sh`: release-pinned macOS / Linux installer that defaults to `v2.1.2` when run directly from the release artifact.
107
- - `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v2.1.2` when run directly from the release artifact.
103
+ - `codex-overleaf-link-extension-v2.1.3.zip`: loadable Chrome extension package for manual unpacked installation.
104
+ - `codex-overleaf-native-host-v2.1.3.tar.gz`: native host runtime files used by the installer and release verification.
105
+ - `codex-overleaf-link-2.1.3.tgz`: npm native host CLI package for pinned install, doctor, and uninstall flows.
106
+ - `install.sh`: release-pinned macOS / Linux installer that defaults to `v2.1.3` when run directly from the release artifact.
107
+ - `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v2.1.3` when run directly from the release artifact.
108
108
  - `uninstall-native-host.mjs`: native host uninstaller that removes the Chrome Native Messaging manifest, bridge executable, and runtime copy.
109
109
  - `nativeHostPlatform.js`, `manifest.js`, `runtimeInstaller.js`: helper files required by the loose uninstaller asset.
110
110
  - `SHA256SUMS` and `release-manifest.json`: checksum and artifact metadata for release verification.
@@ -115,7 +115,7 @@ The v2.1.2 GitHub Release contains:
115
115
  Remove the native host (use `--browser chromium` on Linux Chromium):
116
116
 
117
117
  ```bash
118
- npm exec --yes codex-overleaf-link@2.1.2 -- uninstall-managed
118
+ npm exec --yes codex-overleaf-link@2.1.3 -- uninstall-managed
119
119
  ```
120
120
 
121
121
  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.
@@ -150,13 +150,13 @@ Then remove the extension from `chrome://extensions`. To delete local data: on m
150
150
  Linux Chromium install or update:
151
151
 
152
152
  ```bash
153
- CODEX_OVERLEAF_REF=v2.1.2 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.2/install.sh)" -- --browser chromium
153
+ CODEX_OVERLEAF_REF=v2.1.3 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.3/install.sh)" -- --browser chromium
154
154
  ```
155
155
 
156
156
  Linux Chromium uninstall:
157
157
 
158
158
  ```bash
159
- npm exec --yes codex-overleaf-link@2.1.2 -- uninstall-managed --browser chromium
159
+ npm exec --yes codex-overleaf-link@2.1.3 -- uninstall-managed --browser chromium
160
160
  ```
161
161
 
162
162
  ## Features
@@ -292,7 +292,7 @@ Composer attachments are turn-scoped Codex context. Limits are 8 attachments per
292
292
  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.
293
293
 
294
294
  ```bash
295
- npm exec --yes codex-overleaf-link@2.1.2 -- install-managed
295
+ npm exec --yes codex-overleaf-link@2.1.3 -- install-managed
296
296
  ```
297
297
 
298
298
  **The Windows popup or panel shows a Bash recovery command**
@@ -341,8 +341,8 @@ Use this matrix for release-candidate signoff and compatibility reports. Record
341
341
  | Browser/channel/version | Google Chrome channel and version. | Google Chrome channel and version. | Google Chrome channel and version. | Chromium channel/package and version. |
342
342
  | 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`. |
343
343
  | 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`. |
344
- | Installer/update command | `npm exec --yes codex-overleaf-link@2.1.2 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.2 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.2 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.2 -- install-managed --browser chromium` |
345
- | Uninstall command | `npm exec --yes codex-overleaf-link@2.1.2 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.2 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.2 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.2 -- uninstall-managed --browser chromium` |
344
+ | Installer/update command | `npm exec --yes codex-overleaf-link@2.1.3 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.3 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.3 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.3 -- install-managed --browser chromium` |
345
+ | Uninstall command | `npm exec --yes codex-overleaf-link@2.1.3 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.3 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.3 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.3 -- uninstall-managed --browser chromium` |
346
346
  | 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` |
347
347
  | 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`. |
348
348
  | 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. |
@@ -378,7 +378,7 @@ Contributions are welcome. Please open an issue before submitting large changes
378
378
  The recommended v1.9 installation owns one stable unpacked-extension directory and a versioned native-host directory:
379
379
 
380
380
  ```bash
381
- npm exec --yes codex-overleaf-link@2.1.2 -- install-managed
381
+ npm exec --yes codex-overleaf-link@2.1.3 -- install-managed
382
382
  ```
383
383
 
384
384
  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.
@@ -388,11 +388,11 @@ The stable updater ignores drafts and prereleases, performs no telemetry, and ca
388
388
  The legacy native-only installer remains available for source or unmanaged extension directories:
389
389
 
390
390
  ```bash
391
- npm exec --yes codex-overleaf-link@2.1.2 -- install-native
391
+ npm exec --yes codex-overleaf-link@2.1.3 -- install-native
392
392
  ```
393
393
 
394
394
  Legacy native-only installations can be removed with:
395
395
 
396
396
  ```bash
397
- npm exec --yes codex-overleaf-link@2.1.2 -- uninstall-native
397
+ npm exec --yes codex-overleaf-link@2.1.3 -- uninstall-native
398
398
  ```
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Codex Overleaf Link",
4
- "version": "2.1.2",
4
+ "version": "2.1.3",
5
5
  "description": "Connect the active Overleaf project to a local Codex bridge.",
6
6
  "icons": {
7
7
  "16": "assets/icons/icon16.png",
@@ -12,7 +12,7 @@
12
12
  const MIN_NATIVE_VERSION = '1.0.0';
13
13
  const MIN_COMPATIBLE_NATIVE_VERSION = '1.0.0';
14
14
  const MIN_COMPATIBLE_EXTENSION_VERSION = '1.0.0';
15
- const BUILD_TARGET_VERSION = '2.1.2';
15
+ const BUILD_TARGET_VERSION = '2.1.3';
16
16
  const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
17
17
  const REQUIRED_CAPABILITIES = Object.freeze([
18
18
  'bridgePing',
@@ -0,0 +1,217 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs');
4
+ const os = require('node:os');
5
+ const path = require('node:path');
6
+ const { spawnSync } = require('node:child_process');
7
+
8
+ const RUNTIME_ENV_KEY = 'CODEX_OVERLEAF_CODEX_RUNTIME_JSON';
9
+ const MAX_CODEX_CANDIDATES = 8;
10
+ const VERSION_TIMEOUT_MS = 700;
11
+
12
+ function buildCodexRuntimeIdentity(options = {}) {
13
+ const env = options.env || process.env;
14
+ const platform = options.platform || process.platform;
15
+ const delimiter = options.delimiter || (platform === 'win32' ? ';' : path.delimiter);
16
+ const selectedPath = String(options.selectedPath || '').trim();
17
+ const discovered = discoverCodexCandidates(options.pathValue || env.PATH || '', {
18
+ delimiter,
19
+ env,
20
+ platform
21
+ });
22
+ const candidatePaths = selectedPath
23
+ ? [selectedPath, ...discovered.filter(candidate => !sameExecutablePath(candidate, selectedPath, platform))]
24
+ : discovered;
25
+ const candidates = candidatePaths.slice(0, MAX_CODEX_CANDIDATES).map((candidatePath, index) => ({
26
+ path: candidatePath,
27
+ displayPath: compactHomePath(candidatePath, env, platform),
28
+ version: readCodexVersion(candidatePath, { env, platform }),
29
+ source: classifyCodexSource(candidatePath),
30
+ selected: index === 0 && Boolean(selectedPath)
31
+ }));
32
+ const selected = candidates.find(candidate => candidate.selected) || null;
33
+
34
+ return {
35
+ schemaVersion: 1,
36
+ selected,
37
+ candidates,
38
+ multipleInstallations: candidates.length > 1,
39
+ selectedBy: selected ? 'path-order' : 'not-found'
40
+ };
41
+ }
42
+
43
+ function discoverCodexCandidates(pathValue, options = {}) {
44
+ const platform = options.platform || process.platform;
45
+ const delimiter = options.delimiter || (platform === 'win32' ? ';' : path.delimiter);
46
+ const extensions = executableExtensions(options.env || process.env, platform);
47
+ const seen = new Set();
48
+ const result = [];
49
+
50
+ for (const rawSegment of String(pathValue || '').split(delimiter)) {
51
+ const segment = rawSegment.trim();
52
+ if (!segment) continue;
53
+ for (const extension of extensions) {
54
+ const candidate = path.join(segment, `codex${extension}`);
55
+ const key = platform === 'win32' ? candidate.toLowerCase() : candidate;
56
+ if (seen.has(key) || !isExecutableFile(candidate, platform)) continue;
57
+ seen.add(key);
58
+ result.push(candidate);
59
+ break;
60
+ }
61
+ }
62
+ return result;
63
+ }
64
+
65
+ function executableExtensions(env, platform) {
66
+ if (platform !== 'win32') return [''];
67
+ const configured = String(env.PATHEXT || '.COM;.EXE;.BAT;.CMD')
68
+ .split(';')
69
+ .map(value => value.trim().toLowerCase())
70
+ .filter(Boolean);
71
+ return ['', ...new Set(configured)];
72
+ }
73
+
74
+ function isExecutableFile(candidate, platform) {
75
+ try {
76
+ if (!fs.statSync(candidate).isFile()) return false;
77
+ fs.accessSync(candidate, platform === 'win32' ? fs.constants.F_OK : fs.constants.X_OK);
78
+ return true;
79
+ } catch {
80
+ return false;
81
+ }
82
+ }
83
+
84
+ function readCodexVersion(candidatePath, options = {}) {
85
+ if (!candidatePath) return '';
86
+ const platform = options.platform || process.platform;
87
+ const result = spawnSync(candidatePath, ['--version'], {
88
+ encoding: 'utf8',
89
+ env: options.env || process.env,
90
+ maxBuffer: 64 * 1024,
91
+ shell: platform === 'win32' && /\.(?:cmd|bat)$/i.test(candidatePath),
92
+ timeout: VERSION_TIMEOUT_MS,
93
+ windowsHide: true
94
+ });
95
+ const output = `${result.stdout || ''}\n${result.stderr || ''}`.trim();
96
+ const match = output.match(/\bcodex(?:-cli)?\s+v?([^\s]+)/i);
97
+ return match ? match[1] : '';
98
+ }
99
+
100
+ function classifyCodexSource(candidatePath) {
101
+ const normalized = normalizeSlashes(candidatePath).toLowerCase();
102
+ let resolved = normalized;
103
+ try {
104
+ resolved = normalizeSlashes(fs.realpathSync(candidatePath)).toLowerCase();
105
+ } catch {
106
+ // Keep the visible path when a symlink target cannot be resolved.
107
+ }
108
+ if (normalized.includes('/applications/chatgpt.app/')) return 'chatgpt-app';
109
+ if (normalized.includes('/applications/codex.app/')) return 'codex-app';
110
+ if (normalized.includes('/.nvm/versions/node/')) return 'npm-nvm';
111
+ if (resolved.includes('/node_modules/@openai/codex')) return 'npm-global';
112
+ if (normalized.includes('/opt/homebrew/') || normalized.includes('/homebrew/')) return 'homebrew-prefix';
113
+ if (normalized.includes('/.npm-global/')) return 'npm-global';
114
+ return 'path';
115
+ }
116
+
117
+ function compactHomePath(candidatePath, env = process.env, platform = process.platform) {
118
+ const home = String(env.HOME || env.USERPROFILE || os.homedir() || '');
119
+ if (!home) return candidatePath;
120
+ const caseFold = value => platform === 'win32' ? value.toLowerCase() : value;
121
+ const normalizedCandidate = path.normalize(candidatePath);
122
+ const normalizedHome = path.normalize(home);
123
+ if (caseFold(normalizedCandidate) === caseFold(normalizedHome)) return '~';
124
+ if (caseFold(normalizedCandidate).startsWith(`${caseFold(normalizedHome)}${path.sep}`)) {
125
+ return `~${path.sep}${normalizedCandidate.slice(normalizedHome.length + 1)}`;
126
+ }
127
+ return candidatePath;
128
+ }
129
+
130
+ function serializeCodexRuntimeIdentity(identity) {
131
+ return JSON.stringify(identity || emptyIdentity());
132
+ }
133
+
134
+ function getCodexRuntimeIdentityFromEnv(env = process.env) {
135
+ try {
136
+ const parsed = JSON.parse(String(env[RUNTIME_ENV_KEY] || ''));
137
+ if (parsed && typeof parsed === 'object' && Array.isArray(parsed.candidates)) return parsed;
138
+ } catch {
139
+ // Fall through to the legacy single-path representation.
140
+ }
141
+ const selectedPath = String(env.CODEX_OVERLEAF_CODEX_PATH || '').trim();
142
+ const selected = selectedPath ? {
143
+ path: selectedPath,
144
+ displayPath: compactHomePath(selectedPath, env, env.CODEX_OVERLEAF_PLATFORM || process.platform),
145
+ version: String(env.CODEX_OVERLEAF_CODEX_VERSION || ''),
146
+ source: String(env.CODEX_OVERLEAF_CODEX_SOURCE || classifyCodexSource(selectedPath)),
147
+ selected: true
148
+ } : null;
149
+ return {
150
+ schemaVersion: 1,
151
+ selected,
152
+ candidates: selected ? [selected] : [],
153
+ multipleInstallations: false,
154
+ selectedBy: selected ? 'legacy-path' : 'not-found'
155
+ };
156
+ }
157
+
158
+ function buildCodexRuntimeEvent(env = process.env) {
159
+ const identity = getCodexRuntimeIdentityFromEnv(env);
160
+ const selected = identity.selected;
161
+ if (!selected) return null;
162
+ const version = selected.version || 'unknown version';
163
+ const candidateCount = identity.candidates.length;
164
+ return {
165
+ type: 'codex.runtime.selected',
166
+ title: identity.multipleInstallations
167
+ ? `Using Codex CLI ${version}; ${candidateCount} installations were detected.`
168
+ : `Using Codex CLI ${version}.`,
169
+ status: 'completed',
170
+ detail: {
171
+ path: selected.displayPath || selected.path,
172
+ version: selected.version || '',
173
+ source: selected.source || 'path',
174
+ selectedBy: identity.selectedBy || 'path-order',
175
+ multipleInstallations: identity.multipleInstallations === true,
176
+ warningCode: identity.multipleInstallations ? 'multiple_codex_installations' : '',
177
+ candidates: identity.candidates.map(candidate => ({
178
+ path: candidate.displayPath || candidate.path,
179
+ version: candidate.version || '',
180
+ source: candidate.source || 'path',
181
+ selected: candidate.selected === true
182
+ })),
183
+ technical: true
184
+ }
185
+ };
186
+ }
187
+
188
+ function sameExecutablePath(left, right, platform) {
189
+ const normalize = value => path.normalize(String(value || ''));
190
+ return platform === 'win32'
191
+ ? normalize(left).toLowerCase() === normalize(right).toLowerCase()
192
+ : normalize(left) === normalize(right);
193
+ }
194
+
195
+ function normalizeSlashes(value) {
196
+ return String(value || '').replace(/\\/g, '/');
197
+ }
198
+
199
+ function emptyIdentity() {
200
+ return {
201
+ schemaVersion: 1,
202
+ selected: null,
203
+ candidates: [],
204
+ multipleInstallations: false,
205
+ selectedBy: 'not-found'
206
+ };
207
+ }
208
+
209
+ module.exports = {
210
+ RUNTIME_ENV_KEY,
211
+ buildCodexRuntimeEvent,
212
+ buildCodexRuntimeIdentity,
213
+ discoverCodexCandidates,
214
+ getCodexRuntimeIdentityFromEnv,
215
+ readCodexVersion,
216
+ serializeCodexRuntimeIdentity
217
+ };
@@ -56,6 +56,7 @@ async function runDoctor(options = {}) {
56
56
  errors: []
57
57
  },
58
58
  bridge: null,
59
+ codex: null,
59
60
  ping: {
60
61
  attempted: false
61
62
  },
@@ -106,6 +107,10 @@ async function runDoctor(options = {}) {
106
107
  body.ping = pingResult;
107
108
 
108
109
  if (body.ping.ok) {
110
+ body.codex = sanitizeCodexRuntime(
111
+ rawPingResponse?.result?.environment?.codex,
112
+ pathOptions
113
+ );
109
114
  body.compatibility = sanitizeCompatibility(
110
115
  evaluateNativeCompatibility(rawPingResponse, { version: PACKAGE_VERSION })
111
116
  );
@@ -206,6 +211,19 @@ function formatDoctorHuman(body = {}) {
206
211
  lines.push(`Native compatibility: ${body.compatibility.classification || 'unknown'}`);
207
212
  lines.push(`Native version: ${body.compatibility.nativeVersion || 'unknown'}`);
208
213
  }
214
+ if (body.codex) {
215
+ lines.push(`Codex status: ${body.codex.ok ? 'available' : 'not found'}`);
216
+ lines.push(`Codex path: ${body.codex.path || 'unknown'}`);
217
+ lines.push(`Codex version: ${body.codex.version || 'unknown'}`);
218
+ lines.push(`Codex source: ${body.codex.source || 'unknown'}`);
219
+ if (body.codex.multipleInstallations) {
220
+ lines.push('Warning: multiple Codex installations detected.');
221
+ lines.push('Codex candidates:');
222
+ for (const candidate of body.codex.candidates) {
223
+ lines.push(` ${candidate.selected ? '*' : '-'} ${candidate.path || 'unknown'} (${candidate.version || 'unknown'}, ${candidate.source || 'path'})`);
224
+ }
225
+ }
226
+ }
209
227
  if (body.ping?.ok === false) {
210
228
  lines.push(`Ping: failed (${body.ping.error || 'unknown error'})`);
211
229
  } else if (body.ping?.ok === true) {
@@ -255,6 +273,28 @@ function normalizeDiagnosticPath(targetPath, options = {}) {
255
273
  return value;
256
274
  }
257
275
 
276
+ function sanitizeCodexRuntime(codex, pathOptions) {
277
+ if (!codex || typeof codex !== 'object') return null;
278
+ const normalizeCodexPath = value => {
279
+ const normalized = normalizeDiagnosticPath(value, pathOptions);
280
+ return normalized.includes('<absolute-path>') ? String(value || '') : normalized;
281
+ };
282
+ return {
283
+ ok: codex.ok === true,
284
+ path: normalizeCodexPath(codex.path || ''),
285
+ version: String(codex.version || ''),
286
+ source: String(codex.source || ''),
287
+ selectedBy: String(codex.selectedBy || ''),
288
+ multipleInstallations: codex.multipleInstallations === true,
289
+ candidates: Array.isArray(codex.candidates) ? codex.candidates.map(candidate => ({
290
+ path: normalizeCodexPath(candidate?.path || ''),
291
+ version: String(candidate?.version || ''),
292
+ source: String(candidate?.source || ''),
293
+ selected: candidate?.selected === true
294
+ })) : []
295
+ };
296
+ }
297
+
258
298
  function finalizeDoctorResult(body) {
259
299
  const classification = classifyDoctorResult(body);
260
300
  body.ok = classification.ok;
@@ -4,6 +4,11 @@ const fs = require('node:fs');
4
4
  const os = require('node:os');
5
5
  const path = require('node:path');
6
6
  const { spawnSync } = require('node:child_process');
7
+ const {
8
+ buildCodexRuntimeIdentity,
9
+ getCodexRuntimeIdentityFromEnv,
10
+ serializeCodexRuntimeIdentity
11
+ } = require('./codexRuntimeIdentity');
7
12
 
8
13
  const TOOL_NAMES = ['codex', 'latexmk', 'pdflatex', 'xelatex', 'lualatex', 'bibtex', 'biber'];
9
14
  const LATEX_TOOL_NAMES = ['latexmk', 'pdflatex', 'xelatex', 'lualatex', 'bibtex', 'biber'];
@@ -32,6 +37,16 @@ function buildNativeRuntimeEnv(baseEnv = process.env, options = {}) {
32
37
  for (const tool of TOOL_NAMES) {
33
38
  env[getToolEnvName(tool)] = resolveExecutable(tool, env.PATH, { ...runtimeOptions, env }) || '';
34
39
  }
40
+ const codexRuntime = buildCodexRuntimeIdentity({
41
+ selectedPath: env.CODEX_OVERLEAF_CODEX_PATH,
42
+ pathValue: env.PATH,
43
+ delimiter: runtimeOptions.delimiter,
44
+ env,
45
+ platform: runtimeOptions.platform
46
+ });
47
+ env.CODEX_OVERLEAF_CODEX_RUNTIME_JSON = serializeCodexRuntimeIdentity(codexRuntime);
48
+ env.CODEX_OVERLEAF_CODEX_VERSION = codexRuntime.selected?.version || '';
49
+ env.CODEX_OVERLEAF_CODEX_SOURCE = codexRuntime.selected?.source || '';
35
50
 
36
51
  return env;
37
52
  }
@@ -200,13 +215,25 @@ function resolveExecutable(name, pathValue, options = {}) {
200
215
  }
201
216
 
202
217
  function summarizeNativeEnvironment(env = process.env, options = {}) {
218
+ const codexRuntime = getCodexRuntimeIdentityFromEnv(env);
219
+ const selectedCodex = codexRuntime.selected || {};
203
220
  const runtimeOptions = { ...options, platform: getNativeRuntimePlatform({ ...options, env }) };
204
221
  const availableLatex = LATEX_TOOL_NAMES.filter(tool => Boolean(env[getToolEnvName(tool)]));
205
222
  const missingLatex = LATEX_TOOL_NAMES.filter(tool => !env[getToolEnvName(tool)]);
206
223
  return {
207
224
  codex: {
208
225
  ok: Boolean(env.CODEX_OVERLEAF_CODEX_PATH),
209
- path: env.CODEX_OVERLEAF_CODEX_PATH || ''
226
+ path: env.CODEX_OVERLEAF_CODEX_PATH || '',
227
+ version: selectedCodex.version || '',
228
+ source: selectedCodex.source || '',
229
+ selectedBy: codexRuntime.selectedBy || 'not-found',
230
+ multipleInstallations: codexRuntime.multipleInstallations === true,
231
+ candidates: codexRuntime.candidates.map(candidate => ({
232
+ path: candidate.displayPath || candidate.path || '',
233
+ version: candidate.version || '',
234
+ source: candidate.source || 'path',
235
+ selected: candidate.selected === true
236
+ }))
210
237
  },
211
238
  latex: {
212
239
  ok: availableLatex.length > 0,
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const { buildCodexRuntimeEvent } = require('./codexRuntimeIdentity');
4
+
3
5
  const { spawn } = require('node:child_process');
4
6
  const crypto = require('node:crypto');
5
7
  const { buildOperationSummary, splitDeletePlan } = require('../../extension/src/shared/summary');
@@ -157,6 +159,10 @@ async function handleCodexRun(request, env, emit) {
157
159
  'Codex CLI was not found. Install Codex or make sure the `codex` command is available in your login shell.'
158
160
  );
159
161
  }
162
+ const codexRuntimeEvent = buildCodexRuntimeEvent(env);
163
+ if (codexRuntimeEvent && typeof emit === 'function') {
164
+ emit(codexRuntimeEvent);
165
+ }
160
166
 
161
167
  const projectKey = resolveProjectKey(params);
162
168
  const lockToken = acquireProjectLock(projectKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-overleaf-link",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Cross-platform Chrome bridge that connects Codex to the active Overleaf project.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",